diff --git a/JetStreamDriver.js b/JetStreamDriver.js index 7df47233..9e4e78a1 100644 --- a/JetStreamDriver.js +++ b/JetStreamDriver.js @@ -905,8 +905,11 @@ class Benchmark { } if (this.plan.preload) { let preloadCode = ""; - for (let [ variableName, blobURLOrPath ] of this.preloads) + for (let [ variableName, blobURLOrPath ] of this.preloads) { + console.assert(variableName?.length > 0, "Invalid preload name."); + console.assert(blobURLOrPath?.length > 0, "Invalid preload data."); preloadCode += `JetStream.preload[${JSON.stringify(variableName)}] = "${blobURLOrPath}";\n`; + } scripts.add(preloadCode); } @@ -1060,8 +1063,8 @@ class Benchmark { if (this.plan.preload) { this.preloads = []; - for (let prop of Object.getOwnPropertyNames(this.plan.preload)) { - promises.push(this.loadBlob("preload", prop, this.plan.preload[prop]).then((blobData) => { + for (const [name, resource] of Object.entries(this.plan.preload)) { + promises.push(this.loadBlob("preload", name, resource).then((blobData) => { if (!globalThis.allIsGood) return; this.preloads.push([ blobData.prop, blobData.blobURL ]); @@ -1070,7 +1073,7 @@ class Benchmark { // We'll try again later in retryPrefetchResourceForBrowser(). Don't throw an error. if (!this.failedPreloads) this.failedPreloads = { }; - this.failedPreloads[prop] = true; + this.failedPreloads[name] = true; JetStream.counter.failedPreloadResources++; })); } @@ -1127,9 +1130,8 @@ class Benchmark { } if (this.plan.preload) { - for (const prop of Object.getOwnPropertyNames(this.plan.preload)) { - const resource = this.plan.preload[prop]; - const allDone = await this.retryPrefetchResource("preload", prop, resource); + for (const [name, resource] of Object.entries(this.plan.preload)) { + const allDone = await this.retryPrefetchResource("preload", name, resource); if (allDone) return true; // All resources loaded, nothing more to do. } @@ -1149,21 +1151,21 @@ class Benchmark { if (!this.plan.preload) { return; } - for (let [name, file] of Object.entries(this.plan.preload)) { - const compressed = isCompressed(file); + for (let [name, resource] of Object.entries(this.plan.preload)) { + const compressed = isCompressed(resource); if (compressed && !JetStreamParams.prefetchResources) { - file = uncompressedName(file); + resource = uncompressedName(resource); } if (JetStreamParams.prefetchResources) { - let bytes = new Int8Array(read(file, "binary")); + let bytes = new Int8Array(read(resource, "binary")); if (compressed) { bytes = zlib.decompress(bytes); } - this.shellPrefetchedResources[file] = bytes; + this.shellPrefetchedResources[resource] = bytes; } - this.preloads.push([name, file]); + this.preloads.push([name, resource]); } } @@ -1753,10 +1755,10 @@ class WasmLegacyBenchmark extends Benchmark { } str += "};\n"; - - const keys = Object.keys(this.plan.preload); - for (let i = 0; i < keys.length; ++i) { - str += `JetStream.loadBlob("${keys[i]}", "${this.plan.preload[keys[i]]}", () => {\n`; + let preloadCount = 0; + for (const [name, resource] of Object.entries(this.plan.preload)) { + preloadCount++; + str += `JetStream.loadBlob(${JSON.stringify(name)}, "${resource}", () => {\n`; } if (this.plan.async) { str += `doRun().catch((e) => { @@ -1767,7 +1769,7 @@ class WasmLegacyBenchmark extends Benchmark { } else { str += `doRun();` } - for (let i = 0; i < keys.length; ++i) { + for (let i = 0; i < preloadCount; ++i) { str += `})`; } str += `;`; diff --git a/mobx/dist/LICENSE.txt b/mobx/dist/LICENSE.txt new file mode 100644 index 00000000..b27039ea --- /dev/null +++ b/mobx/dist/LICENSE.txt @@ -0,0 +1,35 @@ +This file was generated with the generate-license-file npm package! +https://www.npmjs.com/package/generate-license-file + +The following npm package may be included in this product: + + - mobx@6.13.7 + +This package contains the following license: + +The MIT License (MIT) + +Copyright (c) 2015 Michel Weststrate + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +----------- + +This file was generated with the generate-license-file npm package! +https://www.npmjs.com/package/generate-license-file diff --git a/mobx/webpack.config.mjs b/mobx/webpack.config.mjs index 5562b9c6..fdfe638f 100644 --- a/mobx/webpack.config.mjs +++ b/mobx/webpack.config.mjs @@ -3,7 +3,7 @@ import { fileURLToPath } from "url"; import TerserPlugin from "terser-webpack-plugin"; import { LicenseFilePlugin } from "generate-license-file-webpack-plugin"; -import CacheBusterCommentPlugin from "../startup-helper/BabelCacheBuster.mjs"; +import CacheBusterCommentPlugin from "../utils/BabelCacheBuster.mjs"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename);