diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2021-03-06 16:15:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-06 16:15:09 +0100 |
commit | a4b5edf468888a1f26009ce6748c338831319064 (patch) | |
tree | a7f28a3054df9aa76f1ad7eebae2eaa9fe0eaa7f /platform/javascript/js/engine/config.js | |
parent | ac249032bf5868e2f88eb206d3c5b261ed63c375 (diff) | |
parent | fd7697718311338fa1d546ded4f8dc4a8a9ae8eb (diff) |
Merge pull request #46728 from Faless/js/4.x_fetch_world
[HTML5] Replace XMLHttpRequest(s) with Fetch.
Diffstat (limited to 'platform/javascript/js/engine/config.js')
-rw-r--r-- | platform/javascript/js/engine/config.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/platform/javascript/js/engine/config.js b/platform/javascript/js/engine/config.js index bba20dc360..82ff273ecf 100644 --- a/platform/javascript/js/engine/config.js +++ b/platform/javascript/js/engine/config.js @@ -101,6 +101,11 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- */ gdnativeLibs: [], /** + * @ignore + * @type {Array.<string>} + */ + fileSizes: [], + /** * 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. @@ -219,6 +224,7 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- this.canvasResizePolicy = parse('canvasResizePolicy', this.canvasResizePolicy); this.persistentPaths = parse('persistentPaths', this.persistentPaths); this.gdnativeLibs = parse('gdnativeLibs', this.gdnativeLibs); + this.fileSizes = parse('fileSizes', this.fileSizes); this.args = parse('args', this.args); this.onExecute = parse('onExecute', this.onExecute); this.onExit = parse('onExit', this.onExit); @@ -227,10 +233,10 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- /** * @ignore * @param {string} loadPath - * @param {Promise} loadPromise + * @param {Response} response */ - Config.prototype.getModuleConfig = function (loadPath, loadPromise) { - let loader = loadPromise; + Config.prototype.getModuleConfig = function (loadPath, response) { + let r = response; return { 'print': this.onPrint, 'printErr': this.onPrintError, @@ -238,12 +244,17 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- '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']); + function done(result) { + onSuccess(result['instance'], result['module']); + } + if (typeof (WebAssembly.instantiateStreaming) !== 'undefined') { + WebAssembly.instantiateStreaming(Promise.resolve(r), imports).then(done); + } else { + r.arrayBuffer().then(function (buffer) { + WebAssembly.instantiate(buffer, imports).then(done); }); - }); - loader = null; + } + r = null; return {}; }, 'locateFile': function (path) { |