Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 62680f5

Browse files
committed
Adding Typescript scripting
This sets up Typescript scripting. As a sideeffect, this also adds a local webserver that can be used to develop maps locally.
1 parent 83a5dea commit 62680f5

File tree

9 files changed

+123
-2
lines changed

9 files changed

+123
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/

docs/create_repo.png

-158 KB
Binary file not shown.

docs/github_pages.png

-175 KB
Binary file not shown.

docs/website_address.png

-43.6 KB
Binary file not shown.

map.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,14 @@
143143
"nextlayerid":14,
144144
"nextobjectid":1,
145145
"orientation":"orthogonal",
146+
"properties":[
147+
{
148+
"name":"script",
149+
"type":"string",
150+
"value":"script.js"
151+
}],
146152
"renderorder":"right-down",
147-
"tiledversion":"1.3.3",
153+
"tiledversion":"2021.03.23",
148154
"tileheight":32,
149155
"tilesets":[
150156
{
@@ -897,6 +903,6 @@
897903
}],
898904
"tilewidth":32,
899905
"type":"map",
900-
"version":1.2,
906+
"version":1.5,
901907
"width":46
902908
}

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "workadventure-map-starter-kit",
3+
"version": "1.0.0",
4+
"main": "index.js",
5+
"license": "MIT",
6+
"devDependencies": {
7+
"@workadventure/iframe-api-typings": "^1.2.0",
8+
"eslint": "^6.8.0",
9+
"html-webpack-plugin": "^4.3.0",
10+
"ts-loader": "^6.2.2",
11+
"ts-node": "^8.10.2",
12+
"typescript": "^3.8.3",
13+
"webpack": "^4.42.1",
14+
"webpack-cli": "^3.3.11",
15+
"webpack-dev-server": "^3.10.3",
16+
"webpack-merge": "^4.2.2"
17+
},
18+
"scripts": {
19+
"start": "webpack-dev-server --open",
20+
"build": "webpack --config webpack.prod.js",
21+
"test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json",
22+
"lint": "node_modules/.bin/eslint src/ . --ext .ts",
23+
"fix": "node_modules/.bin/eslint --fix src/ . --ext .ts"
24+
}
25+
}

src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/// <reference path="../node_modules/@workadventure/iframe-api-typings/iframe_api.d.ts" />
2+
3+
console.log('Script started successfully');
4+
WA.openCoWebSite('https://workadventu.re');

tsconfig.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"compilerOptions": {
3+
"outDir": "./dist/",
4+
"sourceMap": true,
5+
"moduleResolution": "node",
6+
"module": "CommonJS",
7+
"target": "ES2015",
8+
"declaration": false,
9+
"downlevelIteration": true,
10+
"jsx": "react",
11+
"allowJs": true,
12+
13+
"strict": true, /* Enable all strict type-checking options. */
14+
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
15+
"strictNullChecks": true, /* Enable strict null checks. */
16+
"strictFunctionTypes": true, /* Enable strict checking of function types. */
17+
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
18+
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
19+
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
20+
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
21+
22+
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
23+
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */
24+
}
25+
}

webpack.config.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
const path = require('path');
2+
const webpack = require('webpack');
3+
const HtmlWebpackPlugin = require('html-webpack-plugin');
4+
5+
module.exports = {
6+
entry: './src/index.ts',
7+
devtool: 'inline-source-map',
8+
devServer: {
9+
contentBase: '.',
10+
//host: '0.0.0.0',
11+
host: 'localhost',
12+
//sockPort: 80,
13+
disableHostCheck: true,
14+
headers: {
15+
"Access-Control-Allow-Origin": "*",
16+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
17+
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
18+
}
19+
},
20+
module: {
21+
rules: [
22+
{
23+
test: /\.tsx?$/,
24+
use: 'ts-loader',
25+
exclude: /node_modules/,
26+
},
27+
],
28+
},
29+
resolve: {
30+
extensions: [ '.tsx', '.ts', '.js' ],
31+
},
32+
output: {
33+
filename: 'script.js',
34+
path: path.resolve(__dirname, 'dist'),
35+
publicPath: '/'
36+
},
37+
/*externals:[
38+
require('webpack-require-http')
39+
],*/
40+
plugins: [
41+
/*new webpack.ProvidePlugin({
42+
WA: ['@workadventure/iframe-api-typings', 'window.WA']
43+
}),*/
44+
/*new webpack.EnvironmentPlugin({
45+
'API_URL': null,
46+
'PUSHER_URL': undefined,
47+
'UPLOADER_URL': null,
48+
'ADMIN_URL': null,
49+
'DEBUG_MODE': null,
50+
'STUN_SERVER': null,
51+
'TURN_SERVER': null,
52+
'TURN_USER': null,
53+
'TURN_PASSWORD': null,
54+
'JITSI_URL': null,
55+
'JITSI_PRIVATE_MODE': null,
56+
'START_ROOM_URL': null
57+
})*/
58+
],
59+
60+
};

0 commit comments

Comments
 (0)