add compiling of client code to es5
This commit is contained in:
parent
79dd88fd67
commit
7bd1935723
8 changed files with 4181 additions and 13 deletions
|
@ -27,6 +27,7 @@
|
||||||
"socket.io": "^1.4.5",
|
"socket.io": "^1.4.5",
|
||||||
"socket.io-client": "^1.4.5",
|
"socket.io-client": "^1.4.5",
|
||||||
"stylus": "^0.54.2",
|
"stylus": "^0.54.2",
|
||||||
|
"traceur": "0.0.105",
|
||||||
"uglify-js": "^2.6.2",
|
"uglify-js": "^2.6.2",
|
||||||
"uuid": "^2.0.1"
|
"uuid": "^2.0.1"
|
||||||
}
|
}
|
||||||
|
|
2
public/static/js/lib/bootstrap.js
vendored
Normal file
2
public/static/js/lib/bootstrap.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
"use strict";
|
||||||
|
new traceur.WebPageTranscoder(document.location.href).run();
|
4148
public/static/js/lib/traceur-runtime.js
Normal file
4148
public/static/js/lib/traceur-runtime.js
Normal file
File diff suppressed because it is too large
Load diff
8
public/static/js/lib/traceur.js
Normal file
8
public/static/js/lib/traceur.js
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
"use strict";
|
||||||
|
var $__util_45_imports_46_js__,
|
||||||
|
$__compiler_45_imports_46_js__,
|
||||||
|
$__loader_47_loader_45_imports_46_js__;
|
||||||
|
var $__util_45_imports_46_js__ = ($__util_45_imports_46_js__ = require("./util-imports.js"), $__util_45_imports_46_js__ && $__util_45_imports_46_js__.__esModule && $__util_45_imports_46_js__ || {default: $__util_45_imports_46_js__});
|
||||||
|
var $__compiler_45_imports_46_js__ = ($__compiler_45_imports_46_js__ = require("./compiler-imports.js"), $__compiler_45_imports_46_js__ && $__compiler_45_imports_46_js__.__esModule && $__compiler_45_imports_46_js__ || {default: $__compiler_45_imports_46_js__});
|
||||||
|
var $__loader_47_loader_45_imports_46_js__ = ($__loader_47_loader_45_imports_46_js__ = require("./loader/loader-imports.js"), $__loader_47_loader_45_imports_46_js__ && $__loader_47_loader_45_imports_46_js__.__esModule && $__loader_47_loader_45_imports_46_js__ || {default: $__loader_47_loader_45_imports_46_js__});
|
||||||
|
$traceurRuntime.exportStar(Object.defineProperties(module.exports, {__esModule: {value: true}}), $__util_45_imports_46_js__, $__compiler_45_imports_46_js__, $__loader_47_loader_45_imports_46_js__);
|
|
@ -33,25 +33,25 @@ class Input {
|
||||||
document.addEventListener('contextmenu', e => e.preventDefault());
|
document.addEventListener('contextmenu', e => e.preventDefault());
|
||||||
}
|
}
|
||||||
|
|
||||||
mouseMove() {
|
mouseMove(event) {
|
||||||
if (this.locked) return;
|
if (this.locked) return;
|
||||||
var rect = game.renderer.canvas.getBoundingClientRect();
|
var rect = game.renderer.canvas.getBoundingClientRect();
|
||||||
this.mouse.x = event.clientX - rect.left;
|
this.mouse.x = event.clientX - rect.left;
|
||||||
this.mouse.y = event.clientY - rect.top;
|
this.mouse.y = event.clientY - rect.top;
|
||||||
};
|
};
|
||||||
|
|
||||||
mouseDown() {
|
mouseDown(event) {
|
||||||
if (this.locked) return;
|
if (this.locked) return;
|
||||||
this.mouse.pressed[event.which] = true;
|
this.mouse.pressed[event.which] = true;
|
||||||
this.mouse.held[event.which] = true;
|
this.mouse.held[event.which] = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
mouseUp() {
|
mouseUp(event) {
|
||||||
if (this.locked) return;
|
if (this.locked) return;
|
||||||
this.mouse.held[event.which] = false;
|
this.mouse.held[event.which] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyDown() {
|
keyDown(event) {
|
||||||
if (this.locked) {
|
if (this.locked) {
|
||||||
if (event.key == 'Esc' || event.key == 'Enter') {
|
if (event.key == 'Esc' || event.key == 'Enter') {
|
||||||
this.keys.pressed[event.key] = true;
|
this.keys.pressed[event.key] = true;
|
||||||
|
@ -63,18 +63,18 @@ class Input {
|
||||||
this.keys.held[event.key] = true;
|
this.keys.held[event.key] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyUp() {
|
keyUp(event) {
|
||||||
if (this.locked) return;
|
if (this.locked) return;
|
||||||
this.keys.held[event.key] = false;
|
this.keys.held[event.key] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mouseAnyPressed() {
|
mouseAnyPressed(event) {
|
||||||
if (this.locked) return;
|
if (this.locked) return;
|
||||||
var p = this.mouse.pressed;
|
var p = this.mouse.pressed;
|
||||||
return p[1] || p[2] || p[3];
|
return p[1] || p[2] || p[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
clear(event) {
|
||||||
for (var i in this.keys.pressed) this.keys.pressed[i] = false;
|
for (var i in this.keys.pressed) this.keys.pressed[i] = false;
|
||||||
for (var i in this.mouse.pressed) this.mouse.pressed[i] = false;
|
for (var i in this.mouse.pressed) this.mouse.pressed[i] = false;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@ extends layout.jade
|
||||||
block head
|
block head
|
||||||
title
|
title
|
||||||
| Wingbase
|
| Wingbase
|
||||||
|
script(src='js/lib/traceur-runtime.js')
|
||||||
script(src='js/lib/dexie.min.js')
|
script(src='js/lib/dexie.min.js')
|
||||||
script(src='js/lib/domeventslevel3.shim.min.js')
|
script(src='js/lib/domeventslevel3.shim.min.js')
|
||||||
script(src='socket.io/socket.io.js')
|
script(src='socket.io/socket.io.js')
|
||||||
|
|
|
@ -125,7 +125,8 @@ class World {
|
||||||
}
|
}
|
||||||
|
|
||||||
removePlayer(player) {
|
removePlayer(player) {
|
||||||
this.removeBody(player.ship);
|
if (player.ship || true)
|
||||||
|
this.removeBody(player.ship);
|
||||||
this.ships.delete(player);
|
this.ships.delete(player);
|
||||||
this.players.delete(player);
|
this.players.delete(player);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ const colors = require('colors');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const recursive = require('recursive-readdir');
|
const recursive = require('recursive-readdir');
|
||||||
|
const traceur = require('traceur');
|
||||||
const uglify = require('uglify-js');
|
const uglify = require('uglify-js');
|
||||||
|
|
||||||
function minifyJs(callback) {
|
function minifyJs(callback) {
|
||||||
|
@ -21,8 +22,9 @@ function minifyJs(callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
recursive(dir, function(err, files) {
|
recursive(dir, function(err, files) {
|
||||||
for(var i in files) {
|
for(var file of files) {
|
||||||
scripts.push(fs.readFileSync(files[i], 'utf8').toString());
|
let code = fs.readFileSync(file, 'utf8').toString();
|
||||||
|
scripts.push(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
scripts.sort((a, b) => getPriority(b) - getPriority(a));
|
scripts.sort((a, b) => getPriority(b) - getPriority(a));
|
||||||
|
@ -32,8 +34,13 @@ function minifyJs(callback) {
|
||||||
|
|
||||||
cache = scripts.join('');
|
cache = scripts.join('');
|
||||||
|
|
||||||
//Remove to re-enable minifying.
|
if (!wingbase.args.development)
|
||||||
callback(cache); return;
|
cache = traceur.compile(cache);
|
||||||
|
|
||||||
|
if (wingbase.args.development) {
|
||||||
|
callback(cache);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cache = uglify.minify(cache, { fromString: true }).code;
|
cache = uglify.minify(cache, { fromString: true }).code;
|
||||||
|
@ -42,7 +49,7 @@ function minifyJs(callback) {
|
||||||
comment += 'If you would like to view the source in a more readable format, ';
|
comment += 'If you would like to view the source in a more readable format, ';
|
||||||
comment += 'please contact the developer.*/\n'
|
comment += 'please contact the developer.*/\n'
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
console.log('Error parsing kelvin.min.js file'.red);
|
console.log('Error parsing wingbase.min.js file'.red);
|
||||||
|
|
||||||
|
|
||||||
comment = '/* This file could not be minified because of JS syntax errors.';
|
comment = '/* This file could not be minified because of JS syntax errors.';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue