mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 02:46:23 +00:00
Minification
This commit is contained in:
parent
eb6d7be2d0
commit
0247e0f9d6
9 changed files with 111 additions and 19 deletions
|
@ -1,12 +1,11 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
# 4.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/f7fa5d41487a424233b40e903020455606d68fee)
|
# 4.0.1
|
||||||
- Fixed iOS bug for iPads
|
- Complete application re-write. Everything changed.
|
||||||
- Added netplay! (only working on new cores)
|
|
||||||
|
|
||||||
# 3.1.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/f7fa5d41487a424233b40e903020455606d68fee)
|
# 3.1.5 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/f7fa5d41487a424233b40e903020455606d68fee)
|
||||||
- Fixed iOS bug for iPads
|
- Fixed iOS bug for iPads
|
||||||
- Added netplay! (only working on new cores)
|
- Added netplay! (only working on old cores)
|
||||||
|
|
||||||
# 3.1.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/614f5cb55e2768199ba05b756b47d0ab7ab283fd)
|
# 3.1.0 [View Tree](https://github.com/EmulatorJS/EmulatorJS/tree/614f5cb55e2768199ba05b756b47d0ab7ab283fd)
|
||||||
- Added ability to drag and drop save states.
|
- Added ability to drag and drop save states.
|
||||||
|
|
|
@ -232,8 +232,6 @@ class EmulatorJS {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.createStartButton();
|
this.createStartButton();
|
||||||
|
|
||||||
console.log(this)
|
|
||||||
}
|
}
|
||||||
setColor(color) {
|
setColor(color) {
|
||||||
if (typeof color !== "string") color = "";
|
if (typeof color !== "string") color = "";
|
||||||
|
@ -874,7 +872,7 @@ class EmulatorJS {
|
||||||
'totalDependencies': 0,
|
'totalDependencies': 0,
|
||||||
'monitorRunDependencies': () => {},
|
'monitorRunDependencies': () => {},
|
||||||
'locateFile': function(fileName) {
|
'locateFile': function(fileName) {
|
||||||
console.log(fileName);
|
if (this.debug) console.log(fileName);
|
||||||
if (fileName.endsWith(".wasm")) {
|
if (fileName.endsWith(".wasm")) {
|
||||||
return URL.createObjectURL(new Blob([wasmData], {type: "application/wasm"}));
|
return URL.createObjectURL(new Blob([wasmData], {type: "application/wasm"}));
|
||||||
}
|
}
|
||||||
|
@ -888,7 +886,7 @@ class EmulatorJS {
|
||||||
const args = [];
|
const args = [];
|
||||||
if (this.debug) args.push('-v');
|
if (this.debug) args.push('-v');
|
||||||
args.push('/'+this.fileName);
|
args.push('/'+this.fileName);
|
||||||
console.log(args);
|
if (this.debug) console.log(args);
|
||||||
this.Module.callMain(args);
|
this.Module.callMain(args);
|
||||||
this.Module.resumeMainLoop();
|
this.Module.resumeMainLoop();
|
||||||
if (this.touch) {
|
if (this.touch) {
|
||||||
|
@ -1548,7 +1546,7 @@ class EmulatorJS {
|
||||||
|
|
||||||
|
|
||||||
if (this.config.buttonOpts) {
|
if (this.config.buttonOpts) {
|
||||||
console.log(this.config.buttonOpts);
|
if (this.debug) console.log(this.config.buttonOpts);
|
||||||
if (this.config.buttonOpts.playPause === false) {
|
if (this.config.buttonOpts.playPause === false) {
|
||||||
pauseButton.style.display = "none";
|
pauseButton.style.display = "none";
|
||||||
playButton.style.display = "none";
|
playButton.style.display = "none";
|
||||||
|
@ -2635,7 +2633,7 @@ class EmulatorJS {
|
||||||
}
|
}
|
||||||
menuOptionChanged(option, value) {
|
menuOptionChanged(option, value) {
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
console.log(option, value);
|
if (this.debug) console.log(option, value);
|
||||||
if (option === "shader") {
|
if (option === "shader") {
|
||||||
try {
|
try {
|
||||||
this.Module.FS.unlink("/shader/shader.glslp");
|
this.Module.FS.unlink("/shader/shader.glslp");
|
||||||
|
@ -3162,7 +3160,7 @@ class EmulatorJS {
|
||||||
this.netplay.socket = io(this.netplay.url);
|
this.netplay.socket = io(this.netplay.url);
|
||||||
this.netplay.socket.on("connect", () => callback());
|
this.netplay.socket.on("connect", () => callback());
|
||||||
this.netplay.socket.on("users-updated", (users) => {
|
this.netplay.socket.on("users-updated", (users) => {
|
||||||
console.log(users);
|
if (this.debug) console.log(users);
|
||||||
this.netplay.players = users;
|
this.netplay.players = users;
|
||||||
this.netplay.updatePlayersTable();
|
this.netplay.updatePlayersTable();
|
||||||
if (this.netplay.owner) this.netplay.sync();
|
if (this.netplay.owner) this.netplay.sync();
|
||||||
|
@ -3194,7 +3192,7 @@ class EmulatorJS {
|
||||||
password: password
|
password: password
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log("error: ", error);
|
if (this.debug) console.log("error: ", error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.netplay.roomJoined(true, roomName, password, sessionid);
|
this.netplay.roomJoined(true, roomName, password, sessionid);
|
||||||
|
@ -3202,7 +3200,7 @@ class EmulatorJS {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.netplay.leaveRoom = () => {
|
this.netplay.leaveRoom = () => {
|
||||||
console.log("asd");
|
if (this.debug) console.log("asd");
|
||||||
this.netplay.roomLeft();
|
this.netplay.roomLeft();
|
||||||
}
|
}
|
||||||
this.netplay.joinRoom = (sessionid, roomName) => {
|
this.netplay.joinRoom = (sessionid, roomName) => {
|
||||||
|
@ -3224,7 +3222,7 @@ class EmulatorJS {
|
||||||
//password: password
|
//password: password
|
||||||
}, (error, users) => {
|
}, (error, users) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log("error: ", error);
|
if (this.debug) console.log("error: ", error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.netplay.players = users;
|
this.netplay.players = users;
|
||||||
|
@ -3238,7 +3236,7 @@ class EmulatorJS {
|
||||||
this.isNetplay = true;
|
this.isNetplay = true;
|
||||||
this.netplay.inputs = {};
|
this.netplay.inputs = {};
|
||||||
this.netplay.owner = isOwner;
|
this.netplay.owner = isOwner;
|
||||||
console.log(this.netplay.extra);
|
if (this.debug) console.log(this.netplay.extra);
|
||||||
this.netplay.roomNameElem.innerText = roomName;
|
this.netplay.roomNameElem.innerText = roomName;
|
||||||
this.netplay.tabs[0].style.display = "none";
|
this.netplay.tabs[0].style.display = "none";
|
||||||
this.netplay.tabs[1].style.display = "";
|
this.netplay.tabs[1].style.display = "";
|
||||||
|
@ -3326,13 +3324,13 @@ class EmulatorJS {
|
||||||
this.updateCheatUI();
|
this.updateCheatUI();
|
||||||
}
|
}
|
||||||
this.netplay.setLoading = (loading) => {
|
this.netplay.setLoading = (loading) => {
|
||||||
console.log("loading:", loading);
|
if (this.debug) console.log("loading:", loading);
|
||||||
}
|
}
|
||||||
let syncing = false;
|
let syncing = false;
|
||||||
this.netplay.sync = async () => {
|
this.netplay.sync = async () => {
|
||||||
if (syncing) return;
|
if (syncing) return;
|
||||||
syncing = true;
|
syncing = true;
|
||||||
console.log("sync")
|
if (this.debug) console.log("sync")
|
||||||
this.netplay.ready = 0;
|
this.netplay.ready = 0;
|
||||||
const state = await this.gameManager.getState();
|
const state = await this.gameManager.getState();
|
||||||
this.netplay.sendMessage({
|
this.netplay.sendMessage({
|
||||||
|
|
1
data/emulator.min.css
vendored
Normal file
1
data/emulator.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
data/emulator.min.js
vendored
Normal file
1
data/emulator.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -33,7 +33,7 @@
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (('undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX) || true) {
|
if (('undefined' != typeof EJS_DEBUG_XX && true === EJS_DEBUG_XX)) {
|
||||||
await loadScript('emulator.js');
|
await loadScript('emulator.js');
|
||||||
await loadScript('nipplejs.js');
|
await loadScript('nipplejs.js');
|
||||||
await loadScript('shaders.js');
|
await loadScript('shaders.js');
|
||||||
|
@ -42,6 +42,10 @@
|
||||||
await loadScript('GameManager.js');
|
await loadScript('GameManager.js');
|
||||||
await loadScript('socket.io.min.js');
|
await loadScript('socket.io.min.js');
|
||||||
await loadStyle('emulator.css');
|
await loadStyle('emulator.css');
|
||||||
|
} else {
|
||||||
|
await loadScript('emulator.min.js');
|
||||||
|
await loadStyle('emulator.min.css');
|
||||||
|
|
||||||
}
|
}
|
||||||
const config = {};
|
const config = {};
|
||||||
config.gameUrl = window.EJS_gameUrl;
|
config.gameUrl = window.EJS_gameUrl;
|
||||||
|
|
35
data/minify/README.md
Normal file
35
data/minify/README.md
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
|
||||||
|
# Minifying
|
||||||
|
|
||||||
|
Before pushing the script files onto your production <br>
|
||||||
|
server it is recommended to minify them to save on <br>
|
||||||
|
load times as well as bandwidth.
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- **[NodeJS]**
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
## Steps
|
||||||
|
|
||||||
|
1. Open a terminal in `/data/minify` .
|
||||||
|
|
||||||
|
2. Install the dependencies with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Start the minification with:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
node index.js
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
<!----------------------------------------------------------------------------->
|
||||||
|
|
||||||
|
[NodeJS]: https://nodejs.org/en/download/
|
33
data/minify/index.js
Normal file
33
data/minify/index.js
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
const UglifyJS = require("uglify-js");
|
||||||
|
const fs = require('fs');
|
||||||
|
const uglifycss = require('uglifycss');
|
||||||
|
|
||||||
|
if (!String.prototype.replaceAll) {
|
||||||
|
String.prototype.replaceAll = function(a, b) {
|
||||||
|
return this.split(a).join(b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let files = [
|
||||||
|
'nipplejs.js',
|
||||||
|
'shaders.js',
|
||||||
|
'storage.js',
|
||||||
|
'gamepad.js',
|
||||||
|
'GameManager.js',
|
||||||
|
'socket.io.min.js',
|
||||||
|
'emulator.js'
|
||||||
|
]
|
||||||
|
let code = "";
|
||||||
|
for (let i=0; i<files.length; i++) {
|
||||||
|
code += fs.readFileSync('../'+files[i], 'utf8') + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
function minify(source){
|
||||||
|
const ast = UglifyJS.parse(source);
|
||||||
|
return UglifyJS.minify(ast).code;
|
||||||
|
}
|
||||||
|
console.log('minifying');
|
||||||
|
fs.writeFileSync('../emulator.min.css', uglifycss.processString(fs.readFileSync('../emulator.css', 'utf8')));
|
||||||
|
const min = minify(code);
|
||||||
|
console.log('done!');
|
||||||
|
|
||||||
|
fs.writeFileSync('../emulator.min.js', min);
|
22
data/minify/package.json
Normal file
22
data/minify/package.json
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
{
|
||||||
|
"name": "emulatorjs-minify",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"description": "Minify the EmulatorJS javascript files",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "node index.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/EmulatorJS/EmulatorJS.git"
|
||||||
|
},
|
||||||
|
"author": "Ethan O'Brien",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/EmulatorJS/EmulatorJS/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/EmulatorJS/EmulatorJS#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"uglify-js": "^3.17.4",
|
||||||
|
"uglifycss": "0.0.29"
|
||||||
|
}
|
||||||
|
}
|
|
@ -168,7 +168,6 @@
|
||||||
window.EJS_core = core
|
window.EJS_core = core
|
||||||
window.EJS_pathtodata = "data/"
|
window.EJS_pathtodata = "data/"
|
||||||
window.EJS_startOnLoaded = true;
|
window.EJS_startOnLoaded = true;
|
||||||
window.EJS_DEBUG_XX = true;
|
|
||||||
|
|
||||||
if (window.location.hostname === "demo.emulatorjs.org") {
|
if (window.location.hostname === "demo.emulatorjs.org") {
|
||||||
window.EJS_AdUrl = "https://ads.emulatorjs.org/";
|
window.EJS_AdUrl = "https://ads.emulatorjs.org/";
|
||||||
|
|
Loading…
Reference in a new issue