Browse Source

Merge pull request #6 from moufmouf/typescript_script

Adding Typescript scripting
pull/8/head
David Négrier 1 year ago committed by GitHub
parent
commit
1b7764c464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 20
      .github/workflows/build-and-deploy.yml
  2. 1
      .gitignore
  3. BIN
      docs/create_repo.png
  4. BIN
      docs/github_pages.png
  5. BIN
      docs/website_address.png
  6. 56
      index.html
  7. 10
      map.json
  8. 5970
      package-lock.json
  9. 25
      package.json
  10. 7
      src/index.ts
  11. 25
      tsconfig.json
  12. 61
      webpack.config.js
  13. 7
      webpack.prod.js

20
.github/workflows/build-and-deploy.yml

@ -1,9 +1,7 @@ @@ -1,9 +1,7 @@
name: Optimize map and deploy
on:
push:
branches:
- master
- push
jobs:
@ -19,7 +17,22 @@ jobs: @@ -19,7 +17,22 @@ jobs:
- name: Optimize map
uses: thecodingmachine/map-optimizer-action@master
- uses: actions/setup-node@v2
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- name: "Install dependencies"
run: npm install
- name: "Build scripts"
run: npm run build
- name: "Move scripts"
run: mv dist/* .
- name: Bash
if: github.ref == 'refs/heads/master'
run: |
ls -al
git config --global user.email "d.negrier@thecodingmachine.com"
@ -29,6 +42,7 @@ jobs: @@ -29,6 +42,7 @@ jobs:
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
if: github.ref == 'refs/heads/master'
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages # The branch the action should deploy to.

1
.gitignore vendored

@ -0,0 +1 @@ @@ -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

56
index.html

@ -1,5 +1,27 @@ @@ -1,5 +1,27 @@
<html>
<head>
<link href="https://fonts.googleapis.com/css?family=Press+Start+2P" rel="stylesheet">
<link href="https://unpkg.com/nes.css@2.3.0/css/nes.min.css" rel="stylesheet" />
<style>
.margin-constraint{
/*On indique tout simplement une marge*/
margin-left: 20px;
margin-right: 20px;
}
.useful-width{
/*On règle ensuite la largeur utile puis on centre*/
max-width: 800px;
margin-left: auto;
margin-right: auto;
}
.margin-constraint, .useful-width{
/*Si vous utilisez uniquement des div, cette dernière règle css n'est même pas nécessaire*/
display: block;
width: auto;
}
</style>
<script>
window.onload = function() {
var path = window.location.pathname;
@ -8,13 +30,41 @@ @@ -8,13 +30,41 @@
}
var url = 'https://play.workadventu.re/_/global/'+window.location.host+path+'map.json';
document.getElementById('mapLink').href = url;
document.getElementById('mapLink2').href = url;
document.getElementById('mapLink').innerText = url;
var mapUrl = window.location.protocol+'//'+window.location.host+path+'map.json';
document.getElementById('mapUrl').innerText = mapUrl;
var gettingStartedLink = 'https://workadventu.re/getting-started?name=Map&mapUrl='+mapUrl;
document.getElementById('gettingStartedLink').href = gettingStartedLink;
};
</script>
</head>
<body>
This website contains a map for <a href="https://workadventu.re">Workadventu.re</a>.
<br/>
You can access this map at <a id="mapLink" href=""></a>
<div class="useful-width">
<div style="text-align: center; margin-top: 3rem">
<img src="https://workadventu.re/img/logo.png" alt=""/>
</div>
<div class="nes-container with-title is-centered" style="margin-top: 3rem">
<p class="title">WorkAdventure map</p>
<p>This website contains a map for <a href="https://workadventu.re">Workadventu.re</a>.</p>
</div>
<div class="nes-container with-title is-centered" style="margin-top: 1rem">
<p class="title">Test this map</p>
<p>You can test this map at <a id="mapLink" href=""></a>.</p>
<p><a id="mapLink2" href="" class="nes-btn is-primary">Test this map</a></p>
</div>
<div class="nes-container with-title is-centered" style="margin-top: 1rem">
<p class="title">Happy with the result?</p>
<p>Register your room on Workadventu.re.</p>
<p><a id="gettingStartedLink" href="" class="nes-btn is-primary">Create a new room</a></p>
<p>or copy and paste the map URL in WorkAdventu.re's administration panel:</p>
<p><span id="mapUrl" style="color: gray" /></p>
</div>
</div>
</body>
</html>

10
map.json

@ -143,8 +143,14 @@ @@ -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 @@ @@ -897,6 +903,6 @@
}],
"tilewidth":32,
"type":"map",
"version":1.2,
"version":1.5,
"width":46
}

5970
package-lock.json generated

File diff suppressed because it is too large Load Diff

25
package.json

@ -0,0 +1,25 @@ @@ -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.1",
"eslint": "^7.24.0",
"html-webpack-plugin": "^5.3.1",
"ts-loader": "^8.1.0",
"ts-node": "^9.1.1",
"typescript": "^4.2.4",
"webpack": "^5.31.2",
"webpack-cli": "^4.6.0",
"webpack-dev-server": "^3.11.2",
"webpack-merge": "^5.7.3"
},
"scripts": {
"start": "webpack serve --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"
}
}

7
src/index.ts

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
/// <reference path="../node_modules/@workadventure/iframe-api-typings/iframe_api.d.ts" />
// You can write your WorkAdventure script here, if any.
// The "WA" global object is available from anywhere.
console.log('Script started successfully');
WA.openCoWebSite('https://workadventu.re');

25
tsconfig.json

@ -0,0 +1,25 @@ @@ -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. */
}
}

61
webpack.config.js

@ -0,0 +1,61 @@ @@ -0,0 +1,61 @@
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
mode: 'development',
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
})*/
],
};

7
webpack.prod.js

@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
const { merge } = require('webpack-merge');
const common = require('./webpack.config.js');
module.exports = merge(common, {
mode: 'production',
devtool: 'source-map'
});
Loading…
Cancel
Save