Browse Source

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.
main
David Négrier 5 months ago
parent
commit
62680f5916
  1. 1
      .gitignore
  2. BIN
      docs/create_repo.png
  3. BIN
      docs/github_pages.png
  4. BIN
      docs/website_address.png
  5. 10
      map.json
  6. 25
      package.json
  7. 4
      src/index.ts
  8. 25
      tsconfig.json
  9. 60
      webpack.config.js

1
.gitignore

@ -0,0 +1 @@
/node_modules/

BIN
docs/create_repo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

BIN
docs/github_pages.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

BIN
docs/website_address.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

10
map.json

@ -143,8 +143,14 @@
"nextlayerid":14,
"nextobjectid":1,
"orientation":"orthogonal",
"properties":[
{
"name":"script",
"type":"string",
"value":"script.js"
}],
"renderorder":"right-down",
"tiledversion":"1.3.3",
"tiledversion":"2021.03.23",
"tileheight":32,
"tilesets":[
{
@ -897,6 +903,6 @@
}],
"tilewidth":32,
"type":"map",
"version":1.2,
"version":1.5,
"width":46
}

25
package.json

@ -0,0 +1,25 @@
{
"name": "workadventure-map-starter-kit",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@workadventure/iframe-api-typings": "^1.2.0",
"eslint": "^6.8.0",
"html-webpack-plugin": "^4.3.0",
"ts-loader": "^6.2.2",
"ts-node": "^8.10.2",
"typescript": "^3.8.3",
"webpack": "^4.42.1",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.10.3",
"webpack-merge": "^4.2.2"
},
"scripts": {
"start": "webpack-dev-server --open",
"build": "webpack --config webpack.prod.js",
"test": "ts-node node_modules/jasmine/bin/jasmine --config=jasmine.json",
"lint": "node_modules/.bin/eslint src/ . --ext .ts",
"fix": "node_modules/.bin/eslint --fix src/ . --ext .ts"
}
}

4
src/index.ts

@ -0,0 +1,4 @@
/// <reference path="../node_modules/@workadventure/iframe-api-typings/iframe_api.d.ts" />
console.log('Script started successfully');
WA.openCoWebSite('https://workadventu.re');

25
tsconfig.json

@ -0,0 +1,25 @@
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"moduleResolution": "node",
"module": "CommonJS",
"target": "ES2015",
"declaration": false,
"downlevelIteration": true,
"jsx": "react",
"allowJs": true,
"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
"strictNullChecks": true, /* Enable strict null checks. */
"strictFunctionTypes": true, /* Enable strict checking of function types. */
"strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
"strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
"noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
"alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
"noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
"noFallthroughCasesInSwitch": true /* Report errors for fallthrough cases in switch statement. */
}
}

60
webpack.config.js

@ -0,0 +1,60 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.ts',
devtool: 'inline-source-map',
devServer: {
contentBase: '.',
//host: '0.0.0.0',
host: 'localhost',
//sockPort: 80,
disableHostCheck: true,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization"
}
},
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [ '.tsx', '.ts', '.js' ],
},
output: {
filename: 'script.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
/*externals:[
require('webpack-require-http')
],*/
plugins: [
/*new webpack.ProvidePlugin({
WA: ['@workadventure/iframe-api-typings', 'window.WA']
}),*/
/*new webpack.EnvironmentPlugin({
'API_URL': null,
'PUSHER_URL': undefined,
'UPLOADER_URL': null,
'ADMIN_URL': null,
'DEBUG_MODE': null,
'STUN_SERVER': null,
'TURN_SERVER': null,
'TURN_USER': null,
'TURN_PASSWORD': null,
'JITSI_URL': null,
'JITSI_PRIVATE_MODE': null,
'START_ROOM_URL': null
})*/
],
};
Loading…
Cancel
Save