Merge pull request #46446 from Faless/js/4.x_jsdoc

[HTML5] Document Engine and EngineConfig (jsdoc).
This commit is contained in:
Rémi Verschelde 2021-02-26 15:31:44 +01:00 committed by GitHub
commit 75d03f1fbd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 1073 additions and 281 deletions

View File

@ -35,11 +35,12 @@ jobs:
run: | run: |
bash ./misc/scripts/black_format.sh bash ./misc/scripts/black_format.sh
- name: JavaScript style checks via ESLint - name: JavaScript style and documentation checks via ESLint and JSDoc
run: | run: |
cd platform/javascript cd platform/javascript
npm ci npm ci
npm run lint npm run lint
npm run docs -- -d dry-run
- name: Documentation checks - name: Documentation checks
run: | run: |

View File

@ -2,6 +2,7 @@ BASEDIR = $(CURDIR)
CLASSES = $(BASEDIR)/classes/ $(BASEDIR)/../modules/ CLASSES = $(BASEDIR)/classes/ $(BASEDIR)/../modules/
OUTPUTDIR = $(BASEDIR)/_build OUTPUTDIR = $(BASEDIR)/_build
TOOLSDIR = $(BASEDIR)/tools TOOLSDIR = $(BASEDIR)/tools
JSDIR = $(BASEDIR)/../platform/javascript
.ONESHELL: .ONESHELL:
@ -16,6 +17,10 @@ doxygen:
rst: rst:
rm -rf $(OUTPUTDIR)/rst rm -rf $(OUTPUTDIR)/rst
mkdir -p $(OUTPUTDIR)/rst mkdir -p $(OUTPUTDIR)/rst
pushd $(OUTPUTDIR)/rst python3 $(TOOLSDIR)/makerst.py -o $(OUTPUTDIR)/rst $(CLASSES)
python3 $(TOOLSDIR)/makerst.py $(CLASSES)
popd rstjs:
rm -rf $(OUTPUTDIR)/rstjs
mkdir -p $(OUTPUTDIR)/rstjs
npm --prefix $(JSDIR) ci
npm --prefix $(JSDIR) run docs -- --destination $(OUTPUTDIR)/rstjs/html5_shell_classref.rst

View File

@ -3,9 +3,8 @@ module.exports = {
"./.eslintrc.js", "./.eslintrc.js",
], ],
"globals": { "globals": {
"EngineConfig": true, "InternalConfig": true,
"Godot": true, "Godot": true,
"Preloader": true, "Preloader": true,
"Utils": true,
}, },
}; };

View File

@ -73,7 +73,6 @@ sys_env.Depends(build[0], sys_env["JS_EXTERNS"])
engine = [ engine = [
"js/engine/preloader.js", "js/engine/preloader.js",
"js/engine/utils.js",
"js/engine/config.js", "js/engine/config.js",
"js/engine/engine.js", "js/engine/engine.js",
] ]

View File

@ -1,100 +1,309 @@
/** @constructor */ /**
function EngineConfig(opts) { * An object used to configure the Engine instance based on godot export options, and to override those in custom HTML
// Module config * templates if needed.
this.unloadAfterInit = true; *
this.onPrintError = function () { * @header Engine configuration
console.error.apply(console, Array.from(arguments)); // eslint-disable-line no-console * @summary The Engine configuration object. This is just a typedef, create it like a regular object, e.g.:
}; *
this.onPrint = function () { * ``const MyConfig = { executable: 'godot', unloadAfterInit: false }``
console.log.apply(console, Array.from(arguments)); // eslint-disable-line no-console *
}; * @typedef {Object} EngineConfig
this.onProgress = null; */
const EngineConfig = {}; // eslint-disable-line no-unused-vars
// Godot Config /**
this.canvas = null; * @struct
this.executable = ''; * @constructor
this.mainPack = null; * @ignore
this.locale = null; */
this.canvasResizePolicy = false; const InternalConfig = function (initConfig) { // eslint-disable-line no-unused-vars
this.persistentPaths = ['/userfs']; const cfg = /** @lends {InternalConfig.prototype} */ {
this.gdnativeLibs = []; /**
this.args = []; * Whether the unload the engine automatically after the instance is initialized.
this.onExecute = null; *
this.onExit = null; * @memberof EngineConfig
this.update(opts); * @default
} * @type {boolean}
*/
EngineConfig.prototype.update = function (opts) { unloadAfterInit: true,
const config = opts || {}; /**
function parse(key, def) { * The HTML DOM Canvas object to use.
if (typeof (config[key]) === 'undefined') { *
return def; * By default, the first canvas element in the document will be used is none is specified.
} *
return config[key]; * @memberof EngineConfig
} * @default
// Module config * @type {?HTMLCanvasElement}
this.unloadAfterInit = parse('unloadAfterInit', this.unloadAfterInit); */
this.onPrintError = parse('onPrintError', this.onPrintError); canvas: null,
this.onPrint = parse('onPrint', this.onPrint); /**
this.onProgress = parse('onProgress', this.onProgress); * The name of the WASM file without the extension. (Set by Godot Editor export process).
*
// Godot config * @memberof EngineConfig
this.canvas = parse('canvas', this.canvas); * @default
this.executable = parse('executable', this.executable); * @type {string}
this.mainPack = parse('mainPack', this.mainPack); */
this.locale = parse('locale', this.locale); executable: '',
this.canvasResizePolicy = parse('canvasResizePolicy', this.canvasResizePolicy); /**
this.persistentPaths = parse('persistentPaths', this.persistentPaths); * An alternative name for the game pck to load. The executable name is used otherwise.
this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs); *
this.args = parse('args', this.args); * @memberof EngineConfig
this.onExecute = parse('onExecute', this.onExecute); * @default
this.onExit = parse('onExit', this.onExit); * @type {?string}
}; */
mainPack: null,
EngineConfig.prototype.getModuleConfig = function (loadPath, loadPromise) { /**
const me = this; * Specify a language code to select the proper localization for the game.
return { *
'print': this.onPrint, * The browser locale will be used if none is specified. See complete list of
'printErr': this.onPrintError, * :ref:`supported locales <doc_locales>`.
'locateFile': Utils.createLocateRewrite(loadPath), *
'instantiateWasm': Utils.createInstantiatePromise(loadPromise), * @memberof EngineConfig
'thisProgram': me.executable, * @type {?string}
'noExitRuntime': true, * @default
'dynamicLibraries': [`${me.executable}.side.wasm`], */
}; locale: null,
}; /**
* The canvas resize policy determines how the canvas should be resized by Godot.
EngineConfig.prototype.getGodotConfig = function (cleanup) { *
if (!(this.canvas instanceof HTMLCanvasElement)) { * ``0`` means Godot won't do any resizing. This is useful if you want to control the canvas size from
this.canvas = Utils.findCanvas(); * javascript code in your template.
if (!this.canvas) { *
throw new Error('No canvas found in page'); * ``1`` means Godot will resize the canvas on start, and when changing window size via engine functions.
} *
} * ``2`` means Godot will adapt the canvas size to match the whole browser window.
*
// Canvas can grab focus on click, or key events won't work. * @memberof EngineConfig
if (this.canvas.tabIndex < 0) { * @type {number}
this.canvas.tabIndex = 0; * @default
} */
canvasResizePolicy: 2,
// Browser locale, or custom one if defined. /**
let locale = this.locale; * The arguments to be passed as command line arguments on startup.
if (!locale) { *
locale = navigator.languages ? navigator.languages[0] : navigator.language; * See :ref:`command line tutorial <doc_command_line_tutorial>`.
locale = locale.split('.')[0]; *
} * **Note**: :js:meth:`startGame <Engine.prototype.startGame>` will always add the ``--main-pack`` argument.
const onExit = this.onExit; *
// Godot configuration. * @memberof EngineConfig
return { * @type {Array<string>}
'canvas': this.canvas, * @default
'canvasResizePolicy': this.canvasResizePolicy, */
'locale': locale, args: [],
'onExecute': this.onExecute, /**
'onExit': function (p_code) { * @ignore
cleanup(); // We always need to call the cleanup callback to free memory. * @type {Array.<string>}
if (typeof (onExit) === 'function') { */
onExit(p_code); persistentPaths: ['/userfs'],
} /**
* @ignore
* @type {Array.<string>}
*/
gdnativeLibs: [],
/**
* A callback function for handling Godot's ``OS.execute`` calls.
*
* This is for example used in the Web Editor template to switch between project manager and editor, and for running the game.
*
* @callback EngineConfig.onExecute
* @param {string} path The path that Godot's wants executed.
* @param {Array.<string>} args The arguments of the "command" to execute.
*/
/**
* @ignore
* @type {?function(string, Array.<string>)}
*/
onExecute: null,
/**
* A callback function for being notified when the Godot instance quits.
*
* **Note**: This function will not be called if the engine crashes or become unresponsive.
*
* @callback EngineConfig.onExit
* @param {number} status_code The status code returned by Godot on exit.
*/
/**
* @ignore
* @type {?function(number)}
*/
onExit: null,
/**
* A callback function for displaying download progress.
*
* The function is called once per frame while downloading files, so the usage of ``requestAnimationFrame()``
* is not necessary.
*
* If the callback function receives a total amount of bytes as 0, this means that it is impossible to calculate.
* Possible reasons include:
*
* - Files are delivered with server-side chunked compression
* - Files are delivered with server-side compression on Chromium
* - Not all file downloads have started yet (usually on servers without multi-threading)
*
* @callback EngineConfig.onProgress
* @param {number} current The current amount of downloaded bytes so far.
* @param {number} total The total amount of bytes to be downloaded.
*/
/**
* @ignore
* @type {?function(number, number)}
*/
onProgress: null,
/**
* A callback function for handling the standard output stream. This method should usually only be used in debug pages.
*
* By default, ``console.log()`` is used.
*
* @callback EngineConfig.onPrint
* @param {...*} [var_args] A variadic number of arguments to be printed.
*/
/**
* @ignore
* @type {?function(...*)}
*/
onPrint: function () {
console.log.apply(console, Array.from(arguments)); // eslint-disable-line no-console
},
/**
* A callback function for handling the standard error stream. This method should usually only be used in debug pages.
*
* By default, ``console.error()`` is used.
*
* @callback EngineConfig.onPrintError
* @param {...*} [var_args] A variadic number of arguments to be printed as errors.
*/
/**
* @ignore
* @type {?function(...*)}
*/
onPrintError: function (var_args) {
console.error.apply(console, Array.from(arguments)); // eslint-disable-line no-console
}, },
}; };
/**
* @ignore
* @struct
* @constructor
* @param {EngineConfig} opts
*/
function Config(opts) {
this.update(opts);
}
Config.prototype = cfg;
/**
* @ignore
* @param {EngineConfig} opts
*/
Config.prototype.update = function (opts) {
const config = opts || {};
function parse(key, def) {
if (typeof (config[key]) === 'undefined') {
return def;
}
return config[key];
}
// Module config
this.unloadAfterInit = parse('unloadAfterInit', this.unloadAfterInit);
this.onPrintError = parse('onPrintError', this.onPrintError);
this.onPrint = parse('onPrint', this.onPrint);
this.onProgress = parse('onProgress', this.onProgress);
// Godot config
this.canvas = parse('canvas', this.canvas);
this.executable = parse('executable', this.executable);
this.mainPack = parse('mainPack', this.mainPack);
this.locale = parse('locale', this.locale);
this.canvasResizePolicy = parse('canvasResizePolicy', this.canvasResizePolicy);
this.persistentPaths = parse('persistentPaths', this.persistentPaths);
this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs);
this.args = parse('args', this.args);
this.onExecute = parse('onExecute', this.onExecute);
this.onExit = parse('onExit', this.onExit);
};
/**
* @ignore
* @param {string} loadPath
* @param {Promise} loadPromise
*/
Config.prototype.getModuleConfig = function (loadPath, loadPromise) {
let loader = loadPromise;
return {
'print': this.onPrint,
'printErr': this.onPrintError,
'thisProgram': this.executable,
'noExitRuntime': true,
'dynamicLibraries': [`${loadPath}.side.wasm`],
'instantiateWasm': function (imports, onSuccess) {
loader.then(function (xhr) {
WebAssembly.instantiate(xhr.response, imports).then(function (result) {
onSuccess(result['instance'], result['module']);
});
});
loader = null;
return {};
},
'locateFile': function (path) {
if (path.endsWith('.worker.js')) {
return `${loadPath}.worker.js`;
} else if (path.endsWith('.audio.worklet.js')) {
return `${loadPath}.audio.worklet.js`;
} else if (path.endsWith('.js')) {
return `${loadPath}.js`;
} else if (path.endsWith('.side.wasm')) {
return `${loadPath}.side.wasm`;
} else if (path.endsWith('.wasm')) {
return `${loadPath}.wasm`;
}
return path;
},
};
};
/**
* @ignore
* @param {function()} cleanup
*/
Config.prototype.getGodotConfig = function (cleanup) {
// Try to find a canvas
if (!(this.canvas instanceof HTMLCanvasElement)) {
const nodes = document.getElementsByTagName('canvas');
if (nodes.length && nodes[0] instanceof HTMLCanvasElement) {
this.canvas = nodes[0];
}
if (!this.canvas) {
throw new Error('No canvas found in page');
}
}
// Canvas can grab focus on click, or key events won't work.
if (this.canvas.tabIndex < 0) {
this.canvas.tabIndex = 0;
}
// Browser locale, or custom one if defined.
let locale = this.locale;
if (!locale) {
locale = navigator.languages ? navigator.languages[0] : navigator.language;
locale = locale.split('.')[0];
}
const onExit = this.onExit;
// Godot configuration.
return {
'canvas': this.canvas,
'canvasResizePolicy': this.canvasResizePolicy,
'locale': locale,
'onExecute': this.onExecute,
'onExit': function (p_code) {
cleanup(); // We always need to call the cleanup callback to free memory.
if (typeof (onExit) === 'function') {
onExit(p_code);
}
},
};
};
return new Config(initConfig);
}; };

View File

@ -1,3 +1,13 @@
/**
* Projects exported for the Web expose the :js:class:`Engine` class to the JavaScript environment, that allows
* fine control over the engine's start-up process.
*
* This API is built in an asynchronous manner and requires basic understanding
* of `Promises <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_promises>`__.
*
* @module Engine
* @header HTML5 shell class reference
*/
const Engine = (function () { const Engine = (function () {
const preloader = new Preloader(); const preloader = new Preloader();
@ -5,139 +15,254 @@ const Engine = (function () {
let loadPath = ''; let loadPath = '';
let initPromise = null; let initPromise = null;
function load(basePath) { /**
* @classdesc The ``Engine`` class provides methods for loading and starting exported projects on the Web. For default export
* settings, this is already part of the exported HTML page. To understand practical use of the ``Engine`` class,
* see :ref:`Custom HTML page for Web export <doc_customizing_html5_shell>`.
*
* @description Create a new Engine instance with the given configuration.
*
* @global
* @constructor
* @param {EngineConfig} initConfig The initial config for this instance.
*/
function Engine(initConfig) { // eslint-disable-line no-shadow
this.config = new InternalConfig(initConfig);
this.rtenv = null;
}
/**
* Load the engine from the specified base path.
*
* @param {string} basePath Base path of the engine to load.
* @returns {Promise} A Promise that resolves once the engine is loaded.
*
* @function Engine.load
*/
Engine.load = function (basePath) {
if (loadPromise == null) { if (loadPromise == null) {
loadPath = basePath; loadPath = basePath;
loadPromise = preloader.loadPromise(`${loadPath}.wasm`); loadPromise = preloader.loadPromise(`${loadPath}.wasm`);
requestAnimationFrame(preloader.animateProgress); requestAnimationFrame(preloader.animateProgress);
} }
return loadPromise; return loadPromise;
} };
function unload() { /**
* Unload the engine to free memory.
*
* This method will be called automatically depending on the configuration. See :js:attr:`unloadAfterInit`.
*
* @function Engine.unload
*/
Engine.unload = function () {
loadPromise = null; loadPromise = null;
} };
/** @constructor */ /**
function Engine(opts) { // eslint-disable-line no-shadow * Check whether WebGL is available. Optionally, specify a particular version of WebGL to check for.
this.config = new EngineConfig(opts); *
this.rtenv = null; * @param {number=} [majorVersion=1] The major WebGL version to check for.
} * @returns {boolean} If the given major version of WebGL is available.
* @function Engine.isWebGLAvailable
*/
Engine.isWebGLAvailable = function (majorVersion = 1) {
try {
return !!document.createElement('canvas').getContext(['webgl', 'webgl2'][majorVersion - 1]);
} catch (e) { /* Not available */ }
return false;
};
Engine.prototype.init = /** @param {string=} basePath */ function (basePath) { /**
if (initPromise) { * Safe Engine constructor, creates a new prototype for every new instance to avoid prototype pollution.
return initPromise; * @ignore
} * @constructor
if (loadPromise == null) { */
if (!basePath) { function SafeEngine(initConfig) {
initPromise = Promise.reject(new Error('A base path must be provided when calling `init` and the engine is not loaded.')); const proto = /** @lends Engine.prototype */ {
return initPromise; /**
} * Initialize the engine instance. Optionally, pass the base path to the engine to load it,
load(basePath); * if it hasn't been loaded yet. See :js:meth:`Engine.load`.
} *
preloader.setProgressFunc(this.config.onProgress); * @param {string=} basePath Base path of the engine to load.
let config = this.config.getModuleConfig(loadPath, loadPromise); * @return {Promise} A ``Promise`` that resolves once the engine is loaded and initialized.
const me = this; */
initPromise = new Promise(function (resolve, reject) { init: function (basePath) {
Godot(config).then(function (module) { if (initPromise) {
module['initFS'](me.config.persistentPaths).then(function (fs_err) { return initPromise;
me.rtenv = module; }
if (me.config.unloadAfterInit) { if (loadPromise == null) {
unload(); if (!basePath) {
initPromise = Promise.reject(new Error('A base path must be provided when calling `init` and the engine is not loaded.'));
return initPromise;
} }
resolve(); Engine.load(basePath);
config = null; }
}); preloader.setProgressFunc(this.config.onProgress);
}); let config = this.config.getModuleConfig(loadPath, loadPromise);
}); const me = this;
return initPromise; initPromise = new Promise(function (resolve, reject) {
}; Godot(config).then(function (module) {
module['initFS'](me.config.persistentPaths).then(function (fs_err) {
/** @type {function(string, string):Object} */ me.rtenv = module;
Engine.prototype.preloadFile = function (file, path) { if (me.config.unloadAfterInit) {
return preloader.preload(file, path); Engine.unload();
}; }
resolve();
/** @type {function(...string):Object} */ config = null;
Engine.prototype.start = function (override) { });
this.config.update(override);
const me = this;
return me.init().then(function () {
if (!me.rtenv) {
return Promise.reject(new Error('The engine must be initialized before it can be started'));
}
let config = {};
try {
config = me.config.getGodotConfig(function () {
me.rtenv = null;
});
} catch (e) {
return Promise.reject(e);
}
// Godot configuration.
me.rtenv['initConfig'](config);
// Preload GDNative libraries.
const libs = [];
me.config.gdnativeLibs.forEach(function (lib) {
libs.push(me.rtenv['loadDynamicLibrary'](lib, { 'loadAsync': true }));
});
return Promise.all(libs).then(function () {
return new Promise(function (resolve, reject) {
preloader.preloadedFiles.forEach(function (file) {
me.rtenv['copyToFS'](file.path, file.buffer);
}); });
preloader.preloadedFiles.length = 0; // Clear memory
me.rtenv['callMain'](me.config.args);
initPromise = null;
resolve();
}); });
}); return initPromise;
}); },
};
Engine.prototype.startGame = function (override) { /**
this.config.update(override); * Load a file so it is available in the instance's file system once it runs. Must be called **before** starting the
// Add main-pack argument. * instance.
const exe = this.config.executable; *
const pack = this.config.mainPack || `${exe}.pck`; * If not provided, the ``path`` is derived from the URL of the loaded file.
this.config.args = ['--main-pack', pack].concat(this.config.args); *
// Start and init with execName as loadPath if not inited. * @param {string|ArrayBuffer} file The file to preload.
const me = this; *
return Promise.all([ * If a ``string`` the file will be loaded from that path.
this.init(exe), *
this.preloadFile(pack, pack), * If an ``ArrayBuffer`` or a view on one, the buffer will used as the content of the file.
]).then(function () { *
return me.start.apply(me); * @param {string=} path Path by which the file will be accessible. Required, if ``file`` is not a string.
}); *
}; * @returns {Promise} A Promise that resolves once the file is loaded.
*/
preloadFile: function (file, path) {
return preloader.preload(file, path);
},
Engine.prototype.copyToFS = function (path, buffer) { /**
if (this.rtenv == null) { * Start the engine instance using the given override configuration (if any).
throw new Error('Engine must be inited before copying files'); * :js:meth:`startGame <Engine.prototype.startGame>` can be used in typical cases instead.
} *
this.rtenv['copyToFS'](path, buffer); * This will initialize the instance if it is not initialized. For manual initialization, see :js:meth:`init <Engine.prototype.init>`.
}; * The engine must be loaded beforehand.
*
* Fails if a canvas cannot be found on the page, or not specified in the configuration.
*
* @param {EngineConfig} override An optional configuration override.
* @return {Promise} Promise that resolves once the engine started.
*/
start: function (override) {
this.config.update(override);
const me = this;
return me.init().then(function () {
if (!me.rtenv) {
return Promise.reject(new Error('The engine must be initialized before it can be started'));
}
Engine.prototype.requestQuit = function () { let config = {};
if (this.rtenv) { try {
this.rtenv['request_quit'](); config = me.config.getGodotConfig(function () {
} me.rtenv = null;
}; });
} catch (e) {
return Promise.reject(e);
}
// Godot configuration.
me.rtenv['initConfig'](config);
// Closure compiler exported engine methods. // Preload GDNative libraries.
/** @export */ const libs = [];
Engine['isWebGLAvailable'] = Utils.isWebGLAvailable; me.config.gdnativeLibs.forEach(function (lib) {
Engine['load'] = load; libs.push(me.rtenv['loadDynamicLibrary'](lib, { 'loadAsync': true }));
Engine['unload'] = unload; });
Engine.prototype['init'] = Engine.prototype.init; return Promise.all(libs).then(function () {
Engine.prototype['preloadFile'] = Engine.prototype.preloadFile; return new Promise(function (resolve, reject) {
Engine.prototype['start'] = Engine.prototype.start; preloader.preloadedFiles.forEach(function (file) {
Engine.prototype['startGame'] = Engine.prototype.startGame; me.rtenv['copyToFS'](file.path, file.buffer);
Engine.prototype['copyToFS'] = Engine.prototype.copyToFS; });
Engine.prototype['requestQuit'] = Engine.prototype.requestQuit; preloader.preloadedFiles.length = 0; // Clear memory
return Engine; me.rtenv['callMain'](me.config.args);
initPromise = null;
resolve();
});
});
});
},
/**
* Start the game instance using the given configuration override (if any).
*
* This will initialize the instance if it is not initialized. For manual initialization, see :js:meth:`init <Engine.prototype.init>`.
*
* This will load the engine if it is not loaded, and preload the main pck.
*
* This method expects the initial config (or the override) to have both the :js:attr:`executable` and :js:attr:`mainPack`
* properties set (normally done by the editor during export).
*
* @param {EngineConfig} override An optional configuration override.
* @return {Promise} Promise that resolves once the game started.
*/
startGame: function (override) {
this.config.update(override);
// Add main-pack argument.
const exe = this.config.executable;
const pack = this.config.mainPack || `${exe}.pck`;
this.config.args = ['--main-pack', pack].concat(this.config.args);
// Start and init with execName as loadPath if not inited.
const me = this;
return Promise.all([
this.init(exe),
this.preloadFile(pack, pack),
]).then(function () {
return me.start.apply(me);
});
},
/**
* Create a file at the specified ``path`` with the passed as ``buffer`` in the instance's file system.
*
* @param {string} path The location where the file will be created.
* @param {ArrayBuffer} buffer The content of the file.
*/
copyToFS: function (path, buffer) {
if (this.rtenv == null) {
throw new Error('Engine must be inited before copying files');
}
this.rtenv['copyToFS'](path, buffer);
},
/**
* Request that the current instance quit.
*
* This is akin the user pressing the close button in the window manager, and will
* have no effect if the engine has crashed, or is stuck in a loop.
*
*/
requestQuit: function () {
if (this.rtenv) {
this.rtenv['request_quit']();
}
},
};
Engine.prototype = proto;
// Closure compiler exported instance methods.
Engine.prototype['init'] = Engine.prototype.init;
Engine.prototype['preloadFile'] = Engine.prototype.preloadFile;
Engine.prototype['start'] = Engine.prototype.start;
Engine.prototype['startGame'] = Engine.prototype.startGame;
Engine.prototype['copyToFS'] = Engine.prototype.copyToFS;
Engine.prototype['requestQuit'] = Engine.prototype.requestQuit;
// Also expose static methods as instance methods
Engine.prototype['load'] = Engine.load;
Engine.prototype['unload'] = Engine.unload;
Engine.prototype['isWebGLAvailable'] = Engine.isWebGLAvailable;
return new Engine(initConfig);
}
// Closure compiler exported static methods.
SafeEngine['load'] = Engine.load;
SafeEngine['unload'] = Engine.unload;
SafeEngine['isWebGLAvailable'] = Engine.isWebGLAvailable;
return SafeEngine;
}()); }());
if (typeof window !== 'undefined') { if (typeof window !== 'undefined') {
window['Engine'] = Engine; window['Engine'] = Engine;

View File

@ -1,58 +0,0 @@
const Utils = { // eslint-disable-line no-unused-vars
createLocateRewrite: function (execName) {
function rw(path) {
if (path.endsWith('.worker.js')) {
return `${execName}.worker.js`;
} else if (path.endsWith('.audio.worklet.js')) {
return `${execName}.audio.worklet.js`;
} else if (path.endsWith('.js')) {
return `${execName}.js`;
} else if (path.endsWith('.side.wasm')) {
return `${execName}.side.wasm`;
} else if (path.endsWith('.wasm')) {
return `${execName}.wasm`;
}
return path;
}
return rw;
},
createInstantiatePromise: function (wasmLoader) {
let loader = wasmLoader;
function instantiateWasm(imports, onSuccess) {
loader.then(function (xhr) {
WebAssembly.instantiate(xhr.response, imports).then(function (result) {
onSuccess(result['instance'], result['module']);
});
});
loader = null;
return {};
}
return instantiateWasm;
},
findCanvas: function () {
const nodes = document.getElementsByTagName('canvas');
if (nodes.length && nodes[0] instanceof HTMLCanvasElement) {
return nodes[0];
}
return null;
},
isWebGLAvailable: function (majorVersion = 1) {
let testContext = false;
try {
const testCanvas = document.createElement('canvas');
if (majorVersion === 1) {
testContext = testCanvas.getContext('webgl') || testCanvas.getContext('experimental-webgl');
} else if (majorVersion === 2) {
testContext = testCanvas.getContext('webgl2') || testCanvas.getContext('experimental-webgl2');
}
} catch (e) {
// Not available
}
return !!testContext;
},
};

View File

@ -0,0 +1,354 @@
/* eslint-disable strict */
'use strict';
const fs = require('fs');
class JSDoclet {
constructor(doc) {
this.doc = doc;
this.description = doc['description'] || '';
this.name = doc['name'] || 'unknown';
this.longname = doc['longname'] || '';
this.types = [];
if (doc['type'] && doc['type']['names']) {
this.types = doc['type']['names'].slice();
}
this.type = this.types.length > 0 ? this.types.join('\\|') : '*';
this.variable = doc['variable'] || false;
this.kind = doc['kind'] || '';
this.memberof = doc['memberof'] || null;
this.scope = doc['scope'] || '';
this.members = [];
this.optional = doc['optional'] || false;
this.defaultvalue = doc['defaultvalue'];
this.summary = doc['summary'] || null;
this.classdesc = doc['classdesc'] || null;
// Parameters (functions)
this.params = [];
this.returns = doc['returns'] ? doc['returns'][0]['type']['names'][0] : 'void';
this.returns_desc = doc['returns'] ? doc['returns'][0]['description'] : null;
this.params = (doc['params'] || []).slice().map((p) => new JSDoclet(p));
// Custom tags
this.tags = doc['tags'] || [];
this.header = this.tags.filter((t) => t['title'] === 'header').map((t) => t['text']).pop() || null;
}
add_member(obj) {
this.members.push(obj);
}
is_static() {
return this.scope === 'static';
}
is_instance() {
return this.scope === 'instance';
}
is_object() {
return this.kind === 'Object' || (this.kind === 'typedef' && this.type === 'Object');
}
is_class() {
return this.kind === 'class';
}
is_function() {
return this.kind === 'function' || (this.kind === 'typedef' && this.type === 'function');
}
is_module() {
return this.kind === 'module';
}
}
function format_table(f, data, depth = 0) {
if (!data.length) {
return;
}
const column_sizes = new Array(data[0].length).fill(0);
data.forEach((row) => {
row.forEach((e, idx) => {
column_sizes[idx] = Math.max(e.length, column_sizes[idx]);
});
});
const indent = ' '.repeat(depth);
let sep = indent;
column_sizes.forEach((size) => {
sep += '+';
sep += '-'.repeat(size + 2);
});
sep += '+\n';
f.write(sep);
data.forEach((row) => {
let row_text = `${indent}|`;
row.forEach((entry, idx) => {
row_text += ` ${entry.padEnd(column_sizes[idx])} |`;
});
row_text += '\n';
f.write(row_text);
f.write(sep);
});
f.write('\n');
}
function make_header(header, sep) {
return `${header}\n${sep.repeat(header.length)}\n\n`;
}
function indent_multiline(text, depth) {
const indent = ' '.repeat(depth);
return text.split('\n').map((l) => (l === '' ? l : indent + l)).join('\n');
}
function make_rst_signature(obj, types = false, style = false) {
let out = '';
const fmt = style ? '*' : '';
obj.params.forEach((arg, idx) => {
if (idx > 0) {
if (arg.optional) {
out += ` ${fmt}[`;
}
out += ', ';
} else {
out += ' ';
if (arg.optional) {
out += `${fmt}[ `;
}
}
if (types) {
out += `${arg.type} `;
}
const variable = arg.variable ? '...' : '';
const defval = arg.defaultvalue !== undefined ? `=${arg.defaultvalue}` : '';
out += `${variable}${arg.name}${defval}`;
if (arg.optional) {
out += ` ]${fmt}`;
}
});
out += ' ';
return out;
}
function make_rst_param(f, obj, depth = 0) {
const indent = ' '.repeat(depth * 3);
f.write(indent);
f.write(`:param ${obj.type} ${obj.name}:\n`);
f.write(indent_multiline(obj.description, (depth + 1) * 3));
f.write('\n\n');
}
function make_rst_attribute(f, obj, depth = 0, brief = false) {
const indent = ' '.repeat(depth * 3);
f.write(indent);
f.write(`.. js:attribute:: ${obj.name}\n\n`);
if (brief) {
if (obj.summary) {
f.write(indent_multiline(obj.summary, (depth + 1) * 3));
}
f.write('\n\n');
return;
}
f.write(indent_multiline(obj.description, (depth + 1) * 3));
f.write('\n\n');
f.write(indent);
f.write(` :type: ${obj.type}\n\n`);
if (obj.defaultvalue !== undefined) {
let defval = obj.defaultvalue;
if (defval === '') {
defval = '""';
}
f.write(indent);
f.write(` :value: \`\`${defval}\`\`\n\n`);
}
}
function make_rst_function(f, obj, depth = 0) {
let prefix = '';
if (obj.is_instance()) {
prefix = 'prototype.';
}
const indent = ' '.repeat(depth * 3);
const sig = make_rst_signature(obj);
f.write(indent);
f.write(`.. js:function:: ${prefix}${obj.name}(${sig})\n`);
f.write('\n');
f.write(indent_multiline(obj.description, (depth + 1) * 3));
f.write('\n\n');
obj.params.forEach((param) => {
make_rst_param(f, param, depth + 1);
});
if (obj.returns !== 'void') {
f.write(indent);
f.write(' :return:\n');
f.write(indent_multiline(obj.returns_desc, (depth + 2) * 3));
f.write('\n\n');
f.write(indent);
f.write(` :rtype: ${obj.returns}\n\n`);
}
}
function make_rst_object(f, obj) {
let brief = false;
// Our custom header flag.
if (obj.header !== null) {
f.write(make_header(obj.header, '-'));
f.write(`${obj.description}\n\n`);
brief = true;
}
// Format members table and descriptions
const data = [['type', 'name']].concat(obj.members.map((m) => [m.type, `:js:attr:\`${m.name}\``]));
f.write(make_header('Properties', '^'));
format_table(f, data, 0);
make_rst_attribute(f, obj, 0, brief);
if (!obj.members.length) {
return;
}
f.write(' **Property Descriptions**\n\n');
// Properties first
obj.members.filter((m) => !m.is_function()).forEach((m) => {
make_rst_attribute(f, m, 1);
});
// Callbacks last
obj.members.filter((m) => m.is_function()).forEach((m) => {
make_rst_function(f, m, 1);
});
}
function make_rst_class(f, obj) {
const header = obj.header ? obj.header : obj.name;
f.write(make_header(header, '-'));
if (obj.classdesc) {
f.write(`${obj.classdesc}\n\n`);
}
const funcs = obj.members.filter((m) => m.is_function());
function make_data(m) {
const base = m.is_static() ? obj.name : `${obj.name}.prototype`;
const params = make_rst_signature(m, true, true);
const sig = `:js:attr:\`${m.name} <${base}.${m.name}>\` **(**${params}**)**`;
return [m.returns, sig];
}
const sfuncs = funcs.filter((m) => m.is_static());
const ifuncs = funcs.filter((m) => !m.is_static());
f.write(make_header('Static Methods', '^'));
format_table(f, sfuncs.map((m) => make_data(m)));
f.write(make_header('Instance Methods', '^'));
format_table(f, ifuncs.map((m) => make_data(m)));
const sig = make_rst_signature(obj);
f.write(`.. js:class:: ${obj.name}(${sig})\n\n`);
f.write(indent_multiline(obj.description, 3));
f.write('\n\n');
obj.params.forEach((p) => {
make_rst_param(f, p, 1);
});
f.write(' **Static Methods**\n\n');
sfuncs.forEach((m) => {
make_rst_function(f, m, 1);
});
f.write(' **Instance Methods**\n\n');
ifuncs.forEach((m) => {
make_rst_function(f, m, 1);
});
}
function make_rst_module(f, obj) {
const header = obj.header !== null ? obj.header : obj.name;
f.write(make_header(header, '='));
f.write(obj.description);
f.write('\n\n');
}
function write_base_object(f, obj) {
if (obj.is_object()) {
make_rst_object(f, obj);
} else if (obj.is_function()) {
make_rst_function(f, obj);
} else if (obj.is_class()) {
make_rst_class(f, obj);
} else if (obj.is_module()) {
make_rst_module(f, obj);
}
}
function generate(f, docs) {
const globs = [];
const SYMBOLS = {};
docs.filter((d) => !d.ignore && d.kind !== 'package').forEach((d) => {
SYMBOLS[d.name] = d;
if (d.memberof) {
const up = SYMBOLS[d.memberof];
if (up === undefined) {
console.log(d); // eslint-disable-line no-console
console.log(`Undefined symbol! ${d.memberof}`); // eslint-disable-line no-console
throw new Error('Undefined symbol!');
}
SYMBOLS[d.memberof].add_member(d);
} else {
globs.push(d);
}
});
f.write('.. _doc_html5_shell_classref:\n\n');
globs.forEach((obj) => write_base_object(f, obj));
}
/**
* Generate documentation output.
*
* @param {TAFFY} data - A TaffyDB collection representing
* all the symbols documented in your code.
* @param {object} opts - An object with options information.
*/
exports.publish = function (data, opts) {
const docs = data().get().filter((doc) => !doc.undocumented && !doc.ignore).map((doc) => new JSDoclet(doc));
const dest = opts.destination;
if (dest === 'dry-run') {
process.stdout.write('Dry run... ');
generate({
write: function () { /* noop */ },
}, docs);
process.stdout.write('Okay!\n');
return;
}
if (dest !== '' && !dest.endsWith('.rst')) {
throw new Error('Destination file must be either a ".rst" file, or an empty string (for printing to stdout)');
}
if (dest !== '') {
const f = fs.createWriteStream(dest);
generate(f, docs);
} else {
generate(process.stdout, docs);
}
};

View File

@ -43,6 +43,12 @@
} }
} }
}, },
"@babel/parser": {
"version": "7.13.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.13.4.tgz",
"integrity": "sha512-uvoOulWHhI+0+1f9L4BoozY7U5cIkZ9PgJqvb041d6vypgUmtVPG4vmGm4pSggjl8BELzvHyUeJSUyEMY6b+qA==",
"dev": true
},
"@eslint/eslintrc": { "@eslint/eslintrc": {
"version": "0.1.3", "version": "0.1.3",
"resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.1.3.tgz",
@ -202,6 +208,12 @@
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true "dev": true
}, },
"bluebird": {
"version": "3.7.2",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz",
"integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==",
"dev": true
},
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -218,6 +230,15 @@
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"dev": true "dev": true
}, },
"catharsis": {
"version": "0.8.11",
"resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.8.11.tgz",
"integrity": "sha512-a+xUyMV7hD1BrDQA/3iPV7oc+6W26BgVJO05PGEoatMyIuPScQKsde6i3YorWX1qs+AZjnJ18NqdKoCtKiNh1g==",
"dev": true,
"requires": {
"lodash": "^4.17.14"
}
},
"chalk": { "chalk": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz",
@ -362,6 +383,12 @@
"ansi-colors": "^4.1.1" "ansi-colors": "^4.1.1"
} }
}, },
"entities": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz",
"integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==",
"dev": true
},
"error-ex": { "error-ex": {
"version": "1.3.2", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
@ -925,6 +952,51 @@
"esprima": "^4.0.0" "esprima": "^4.0.0"
} }
}, },
"js2xmlparser": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.1.tgz",
"integrity": "sha512-KrPTolcw6RocpYjdC7pL7v62e55q7qOMHvLX1UCLc5AAS8qeJ6nukarEJAF2KL2PZxlbGueEbINqZR2bDe/gUw==",
"dev": true,
"requires": {
"xmlcreate": "^2.0.3"
}
},
"jsdoc": {
"version": "3.6.6",
"resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.6.tgz",
"integrity": "sha512-znR99e1BHeyEkSvgDDpX0sTiTu+8aQyDl9DawrkOGZTTW8hv0deIFXx87114zJ7gRaDZKVQD/4tr1ifmJp9xhQ==",
"dev": true,
"requires": {
"@babel/parser": "^7.9.4",
"bluebird": "^3.7.2",
"catharsis": "^0.8.11",
"escape-string-regexp": "^2.0.0",
"js2xmlparser": "^4.0.1",
"klaw": "^3.0.0",
"markdown-it": "^10.0.0",
"markdown-it-anchor": "^5.2.7",
"marked": "^0.8.2",
"mkdirp": "^1.0.4",
"requizzle": "^0.2.3",
"strip-json-comments": "^3.1.0",
"taffydb": "2.6.2",
"underscore": "~1.10.2"
},
"dependencies": {
"escape-string-regexp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz",
"integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==",
"dev": true
},
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true
}
}
},
"json-schema-traverse": { "json-schema-traverse": {
"version": "0.4.1", "version": "0.4.1",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
@ -946,6 +1018,15 @@
"minimist": "^1.2.0" "minimist": "^1.2.0"
} }
}, },
"klaw": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz",
"integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.9"
}
},
"levn": { "levn": {
"version": "0.4.1", "version": "0.4.1",
"resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz",
@ -956,6 +1037,15 @@
"type-check": "~0.4.0" "type-check": "~0.4.0"
} }
}, },
"linkify-it": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz",
"integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==",
"dev": true,
"requires": {
"uc.micro": "^1.0.1"
}
},
"load-json-file": { "load-json-file": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz",
@ -984,6 +1074,37 @@
"integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==", "integrity": "sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==",
"dev": true "dev": true
}, },
"markdown-it": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz",
"integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==",
"dev": true,
"requires": {
"argparse": "^1.0.7",
"entities": "~2.0.0",
"linkify-it": "^2.0.0",
"mdurl": "^1.0.1",
"uc.micro": "^1.0.5"
}
},
"markdown-it-anchor": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz",
"integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==",
"dev": true
},
"marked": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.8.2.tgz",
"integrity": "sha512-EGwzEeCcLniFX51DhTpmTom+dSA/MG/OBUDjnWtHbEnjAH180VzUeAw+oE4+Zv+CoYBWyRlYOTR0N8SO9R1PVw==",
"dev": true
},
"mdurl": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz",
"integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=",
"dev": true
},
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
@ -1287,6 +1408,15 @@
"integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==",
"dev": true "dev": true
}, },
"requizzle": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz",
"integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==",
"dev": true,
"requires": {
"lodash": "^4.17.14"
}
},
"resolve": { "resolve": {
"version": "1.17.0", "version": "1.17.0",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz",
@ -1513,6 +1643,12 @@
"string-width": "^3.0.0" "string-width": "^3.0.0"
} }
}, },
"taffydb": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz",
"integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=",
"dev": true
},
"text-table": { "text-table": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
@ -1546,6 +1682,18 @@
"integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==",
"dev": true "dev": true
}, },
"uc.micro": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz",
"integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==",
"dev": true
},
"underscore": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.10.2.tgz",
"integrity": "sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg==",
"dev": true
},
"uri-js": { "uri-js": {
"version": "4.4.0", "version": "4.4.0",
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.0.tgz",
@ -1600,6 +1748,12 @@
"requires": { "requires": {
"mkdirp": "^0.5.1" "mkdirp": "^0.5.1"
} }
},
"xmlcreate": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.3.tgz",
"integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ==",
"dev": true
} }
} }
} }

View File

@ -5,20 +5,24 @@
"description": "Linting setup for Godot's HTML5 platform code", "description": "Linting setup for Godot's HTML5 platform code",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"lint": "npm run lint:engine && npm run lint:libs && npm run lint:modules", "docs": "jsdoc --template js/jsdoc2rst/ js/engine/engine.js js/engine/config.js --destination ''",
"lint": "npm run lint:engine && npm run lint:libs && npm run lint:modules && npm run lint:tools",
"lint:engine": "eslint \"js/engine/*.js\" --no-eslintrc -c .eslintrc.engine.js", "lint:engine": "eslint \"js/engine/*.js\" --no-eslintrc -c .eslintrc.engine.js",
"lint:libs": "eslint \"js/libs/*.js\" --no-eslintrc -c .eslintrc.libs.js", "lint:libs": "eslint \"js/libs/*.js\" --no-eslintrc -c .eslintrc.libs.js",
"lint:modules": "eslint \"../../modules/**/*.js\" --no-eslintrc -c .eslintrc.libs.js", "lint:modules": "eslint \"../../modules/**/*.js\" --no-eslintrc -c .eslintrc.libs.js",
"format": "npm run format:engine && npm run format:libs && npm run format:modules", "lint:tools": "eslint \"js/jsdoc2rst/**/*.js\" --no-eslintrc -c .eslintrc.engine.js",
"format": "npm run format:engine && npm run format:libs && npm run format:modules && npm run format:tools",
"format:engine": "npm run lint:engine -- --fix", "format:engine": "npm run lint:engine -- --fix",
"format:libs": "npm run lint:libs -- --fix", "format:libs": "npm run lint:libs -- --fix",
"format:modules": "npm run lint:modules -- --fix" "format:modules": "npm run lint:modules -- --fix",
"format:tools": "npm run lint:tools -- --fix"
}, },
"author": "Godot Engine contributors", "author": "Godot Engine contributors",
"license": "MIT", "license": "MIT",
"devDependencies": { "devDependencies": {
"eslint": "^7.9.0", "eslint": "^7.9.0",
"eslint-config-airbnb-base": "^14.2.0", "eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.22.0" "eslint-plugin-import": "^2.22.0",
"jsdoc": "^3.6.6"
} }
} }