From b1c00a561a18e2f940a9c303f27c00dd2d575846 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 13:47:28 +0800 Subject: [PATCH 01/13] Remove WASM fallback logic. --- modules/build-engine/src/engine-js/index.ts | 1 - .../rollup-plugins/external-wasm-loader.ts | 26 +----------- .../engine-ts/plugins/external-wasm-loader.ts | 18 --------- modules/stats-query/src/index.ts | 8 ---- test/build-engine/engine-js.test.ts | 4 +- test/test-engine-source/cc.config.json | 6 --- .../wasm/emscripten/wasm_c.wasm.fallback | Bin 13963 -> 0 bytes .../wasm/emscripten/wasm_c.wasm.fallback.js | 2 - test/test-engine-source/wasm/emscripten.ts | 38 ++++++++++-------- 9 files changed, 24 insertions(+), 79 deletions(-) delete mode 100644 test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback delete mode 100644 test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js diff --git a/modules/build-engine/src/engine-js/index.ts b/modules/build-engine/src/engine-js/index.ts index b5921d05..ee4a2083 100644 --- a/modules/build-engine/src/engine-js/index.ts +++ b/modules/build-engine/src/engine-js/index.ts @@ -246,7 +246,6 @@ export async function buildJsEngine(options: Required): Pro cullAsmJsModule: buildTimeConstants.CULL_ASM_JS_MODULE, cullMeshopt: buildTimeConstants.CULL_MESHOPT, format: 'relative-from-chunk', - wasmFallback: buildTimeConstants.WASM_FALLBACK, wasmSubpackage: buildTimeConstants.WASM_SUBPACKAGE, }), diff --git a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts index 17ac7c49..9841e3db 100644 --- a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts @@ -22,7 +22,6 @@ interface ISuffixReplaceConfig { const suffixReplaceConfig: ISuffixReplaceConfig = { '.mem': '.mem.bin', - '.wasm.fallback': '.wasm.fallback.bin', }; /** @@ -110,25 +109,7 @@ const loadConfig: ILoadConfig = { }, '.asm.js': { shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return (options.wasmSupportMode === 1 && !shouldCullBulletWasmModule(options, id)) || shouldCullAsmJsModule(options, id) || shouldCullMeshoptModule(options, id); - }, - shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { - return false; - }, - cullingContent: `export default function () {}`, - }, - '.wasm.fallback': { - shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return loadConfig['.wasm'].shouldCullModule(options, id) || !options.wasmFallback; - }, - shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { - return !this.shouldCullModule(options, id); - }, - cullingContent: `export default '';`, - }, - '.wasm.fallback.js': { - shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return loadConfig['.wasm.js'].shouldCullModule(options, id) || !options.wasmFallback; + return options.nativeCodeBundleMode === 'wasm' || shouldCullMeshoptModule(options, id); }, shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { return false; @@ -338,11 +319,6 @@ export declare namespace externalWasmLoader { * 2. maybe support */ wasmSupportMode: number; - /** - * Whether need a fallback of wasm. - * If true, we need to build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. - */ - wasmFallback: boolean; /** * Whether force banning to emit bullet wasm. */ diff --git a/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts index de4d30c1..42c99649 100644 --- a/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts @@ -85,24 +85,6 @@ const loadConfig: ILoadConfig = { }, cullingContent: `let $: any;export default $;`, }, - '.wasm.fallback': { - shouldCullModule (options: externalWasmLoaderFactory.Options, id: string): boolean { - return true; // we don't need wasm.fallback module for OH platform - }, - shouldEmitAsset (options: externalWasmLoaderFactory.Options, id: string): boolean { - return !this.shouldCullModule(options, id); - }, - cullingContent: `export default '';`, - }, - '.wasm.fallback.js': { - shouldCullModule (options: externalWasmLoaderFactory.Options, id: string): boolean { - return true; // we don't need wasm.fallback module for OH platform - }, - shouldEmitAsset (options: externalWasmLoaderFactory.Options, id: string): boolean { - return false; - }, - cullingContent: `export default function () {}`, - }, }; // NOTE: we use rollup to transform CommonJS to ES Module. diff --git a/modules/stats-query/src/index.ts b/modules/stats-query/src/index.ts index 98de19bf..20678c54 100644 --- a/modules/stats-query/src/index.ts +++ b/modules/stats-query/src/index.ts @@ -307,14 +307,6 @@ export namespace StatsQuery { * @default false */ CULL_MESHOPT: boolean; - /** - * An internal constant to indicate whether need a fallback of wasm. - * If true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. - * This is useful when we use wasm on different version of Safari browsers. - * - * @default false - */ - WASM_FALLBACK: boolean; /** * An internal constant to indicate whether we use wasm assets as minigame subpackage. * This is useful when we need to reduce code size. diff --git a/test/build-engine/engine-js.test.ts b/test/build-engine/engine-js.test.ts index a0575433..903a746a 100644 --- a/test/build-engine/engine-js.test.ts +++ b/test/build-engine/engine-js.test.ts @@ -219,9 +219,7 @@ describe('engine-js', () => { platform: 'OPEN_HARMONY', features: ['wasm-test'], flags: { - // force flag value to test inline dynamic import - WASM_SUPPORT_MODE: 1, - WASM_FALLBACK: true, + WASM_SUPPORT_MODE: 1, // force flag value to test inline dynamic import }, moduleFormat: 'esm', }); diff --git a/test/test-engine-source/cc.config.json b/test/test-engine-source/cc.config.json index c419fc3c..a2792161 100644 --- a/test/test-engine-source/cc.config.json +++ b/test/test-engine-source/cc.config.json @@ -402,12 +402,6 @@ "value": false, "internal": true }, - "WASM_FALLBACK": { - "comment": "An internal constant to indicate whether need a fallback of wasm.\nIf true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.\nThis is useful when we use wasm on different version of Safari browsers.", - "type": "boolean", - "value": "$HTML5", - "internal": true - }, "WASM_SUBPACKAGE": { "comment": "An internal constant to indicate whether we use wasm assets as minigame subpackage.\nThis is useful when we need to reduce code size.", "type": "boolean", diff --git a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback b/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback deleted file mode 100644 index 2d81841d8df1d797c1c7c3e2df482be7826e1e2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13963 zcmbuG>v9~&b;o-yi`~Txu!98_x22<=5uHF5DMPjlQHo=6DC;gOitV^usZ@a%K^7Mj zNL)nGWeS@w`RE78!=&;8`IbsmKI9$p3i2p7)&y0TfLw~Y& zeB!^pbNr?M{LX_1ckkTWUzm41M$WnDfBx-Xr$4uP+ePEs$#^{G7KMwu?cD9ydXn+! zI6Ad)ce}+b>zx}vZCcD?Ds#rS)A8vk59ws&={S0NyR9ew**JH1J2|zd0L$Huo&r8T zJ!LK{wOKqxj)sd@A>;n;@xh%($6q`=*?n}h_xS$a*ROUy|7`c`qx&a&Zec#zJ9s?U z`||kS(fvm!dk4E;?tOXh(eHQf-v6CzC+DEOk-AnC&qZ;PBrc8PsO1);sMBl5#Zs2_ zqwd1|atx2ssFmj{DJ_@8E^+aolb!<Q5`zcjHa8pw9ifK z&4KvCqux;by4<5Rt*xlVbIy!i``{3cdJ16%a9=PSX z&p&_g)$teZ#>VdM{e#c$AMM>c+5P;hgL@j@J-KuD!CvHM8FYMtMlkjMiF;*ZhH;_) zcYCZp+S_wKym;*Ho#Q>Xy?)`ky@Su(t6hWht2>YP+>df={}O$Cc(mt!yfAOiHKg2g zuU)wi#=WnOj`j{t+)wh)et+<`STMRjy6@iXp5s>J>L_c?wc2I1Fwe+;{1X@V#+)l& zDYmjJQ8J!zy>zuJBkz1vq?AbC2?Jh7>zPO z$5C4g{C<_tm3X%mU#ZfaxKL}QY|$0(#8Ljnpx>d{nsN>N^;#Ps>&wWywv?!mT*3qIVbOhXt@@ig-((9^9rtvVl7 z-8wlLRW0Azib2|UYUjJd{i-wC;W@4II^}s(rCQ*8XJ6fOKH3MjR+$D=TE6YO`&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yawv?>okW>5`?HV5(o1K&{nTGR2%PcLP!+rNQy$o9 zf@I3R=gViao9ftHT|V6Twbb^x`?{xmL<s8)3ogXxH7$`-F(?5pNckJ07akX zUC^zi{OLod#&3*A#mngCS@}`cQd~11TBU&9Chi5mhIhWeTU4!ew6#f=Gs z$#>g8!Vzu7H!7i+WyPY8dMd$O0?~ZZGf)-31*7?bi!DXixWw0CqZoQXF0CTX>Qst% zEbzES`QzHUx0dGIrZ(nD$9%qG51)JKrcX2Bmb|ke9A$zaUz&Kw!t6x?fQCGUpSZ8rN~amo!U diff --git a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js b/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js deleted file mode 100644 index 083def88..00000000 --- a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js +++ /dev/null @@ -1,2 +0,0 @@ -// simply file code -export default function wasmFallbackModule () {} \ No newline at end of file diff --git a/test/test-engine-source/wasm/emscripten.ts b/test/test-engine-source/wasm/emscripten.ts index 827e39d6..3ef47f76 100644 --- a/test/test-engine-source/wasm/emscripten.ts +++ b/test/test-engine-source/wasm/emscripten.ts @@ -1,4 +1,4 @@ -import { WASM_FALLBACK, WASM_SUPPORT_MODE } from 'internal:constants'; +import { WASM_SUPPORT_MODE } from 'internal:constants'; import { isSupportWASM } from './is-support-wasm'; import wasmUrl from 'external:wasm/emscripten/wasm_c.wasm'; import wasmFactory from 'external:wasm/emscripten/wasm_c.wasm.js'; @@ -8,21 +8,6 @@ import asmJsMemUrl from 'external:wasm/emscripten/wasm_c.js.mem'; function initializeWasm (): Promise { return new Promise((resolve, reject) => { - if (WASM_FALLBACK) { - Promise.all([import('external:wasm/emscripten/wasm_c.wasm.fallback'), import('external:wasm/emscripten/wasm_c.wasm.fallback.js')]).then(([ - { default: wasmFallbackUrl }, - { default: wasmFallbackFactory }, - ]) => { - return wasmFallbackFactory({ - locateFile(_) { - return wasmFallbackUrl; - } - }).then(inst => { - resolve(inst); - }).catch(reject); - }); - return; - } wasmFactory({ locateFile(_) { return wasmUrl; @@ -33,6 +18,27 @@ function initializeWasm (): Promise { }); } +// function initializeWasm (): Promise { +// return Promise.all([ +// import('external:wasm/emscripten/wasm_c.wasm'), +// import('external:wasm/emscripten/wasm_c.wasm.js'), +// ]).then(([ +// { default: wasmUrl }, +// { default: wasmFactory }, +// ]) => { +// return new Promise((resolve, reject) => { +// wasmFactory({ +// locateFile(_) { +// return wasmUrl; +// } +// }).then(inst => { +// resolve(inst); +// }).catch(reject); +// }); + +// }); +// } + function initializeAsm (): Promise { return new Promise((resolve, reject) => { asmFactory({ From f48d8e00981025c55a6ffc820681abc8bb50e4f7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 13:48:22 +0800 Subject: [PATCH 02/13] Add nativeCodeBundleMode. --- modules/build-engine/src/engine-js/index.ts | 21 +++--- .../rollup-plugins/external-wasm-loader.ts | 30 ++------- modules/build-engine/src/index.ts | 18 ++--- modules/stats-query/src/index.ts | 9 +-- test/build-engine/engine-js.test.ts | 65 +++++-------------- test/stats-query/constant-manager.test.ts | 8 +-- test/test-engine-source/cc.config.json | 12 ---- .../exports/internal-constants.ts | 4 +- test/test-engine-source/wasm/wasm-pack.ts | 2 +- 9 files changed, 49 insertions(+), 120 deletions(-) diff --git a/modules/build-engine/src/engine-js/index.ts b/modules/build-engine/src/engine-js/index.ts index ee4a2083..17cbd8d7 100644 --- a/modules/build-engine/src/engine-js/index.ts +++ b/modules/build-engine/src/engine-js/index.ts @@ -6,6 +6,7 @@ import realFs from 'fs'; import tsConfigPaths from './rollup-plugins/ts-paths'; import moduleQueryPlugin from './rollup-plugins/module-query-plugin'; import removeDeprecatedFeatures from './rollup-plugins/remove-deprecated-features'; +import { rpNamedChunk } from './rollup-plugins/systemjs-named-register-plugin'; import type { buildEngine } from '../index'; import { externalWasmLoader } from './rollup-plugins/external-wasm-loader'; import { StatsQuery } from '@ccbuild/stats-query'; @@ -87,11 +88,14 @@ export async function buildJsEngine(options: Required): Pro } - let { ammoJsWasm } = options; - ammoJsWasm ??= true; // default is true - const forceBanningBulletWasm = !ammoJsWasm; + let { nativeCodeBundleMode } = options; + nativeCodeBundleMode ??= 'both'; // default is true + const flags = options.flags ?? {}; - flags.FORCE_BANNING_BULLET_WASM = forceBanningBulletWasm; + + // meshopt is only used in 3d module, so cull it if 3d module is disabled. + flags.CULL_MESHOPT = !features.includes('3d'); + const intrinsicFlags = statsQuery.getIntrinsicFlagsOfFeatures(features); let buildTimeConstants = statsQuery.constantManager.genBuildTimeConstants({ mode: options.mode, @@ -241,9 +245,7 @@ export async function buildJsEngine(options: Required): Pro rollupPlugins.push( externalWasmLoader({ externalRoot: ps.join(engineRoot, 'native/external'), - wasmSupportMode: buildTimeConstants.WASM_SUPPORT_MODE, - forceBanningBulletWasm, - cullAsmJsModule: buildTimeConstants.CULL_ASM_JS_MODULE, + nativeCodeBundleMode, cullMeshopt: buildTimeConstants.CULL_MESHOPT, format: 'relative-from-chunk', wasmSubpackage: buildTimeConstants.WASM_SUBPACKAGE, @@ -300,6 +302,8 @@ export async function buildJsEngine(options: Required): Pro skipPreflightCheck: true, ...babelOptions, }), + + // rpNamedChunk(), ); // if (options.progress) { @@ -456,6 +460,5 @@ export async function buildJsEngine(options: Required): Pro } result.hasCriticalWarns = hasCriticalWarns; - return result; -} \ No newline at end of file +} diff --git a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts index 9841e3db..af8f9080 100644 --- a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts @@ -67,14 +67,6 @@ interface ILoadConfig { } } -function shouldCullBulletWasmModule (options: externalWasmLoader.Options, id: string): boolean { - return options.forceBanningBulletWasm && id.includes('bullet'); -} - -function shouldCullAsmJsModule (options: externalWasmLoader.Options, id: string): boolean { - return options.wasmSupportMode !== 0 && options.cullAsmJsModule; -} - function shouldCullMeshoptModule (options: externalWasmLoader.Options, id: string): boolean { return options.cullMeshopt && id.includes('meshopt'); } @@ -82,7 +74,7 @@ function shouldCullMeshoptModule (options: externalWasmLoader.Options, id: strin const loadConfig: ILoadConfig = { '.wasm': { shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return options.wasmSupportMode === 0 || shouldCullBulletWasmModule(options, id) || shouldCullMeshoptModule(options, id); + return options.nativeCodeBundleMode === 'asmjs' || shouldCullMeshoptModule(options, id); }, shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { return !this.shouldCullModule(options, id); @@ -91,7 +83,7 @@ const loadConfig: ILoadConfig = { }, '.js.mem': { shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return (options.wasmSupportMode === 1 && !shouldCullBulletWasmModule(options, id)) || shouldCullAsmJsModule(options, id) || shouldCullMeshoptModule(options, id); + return options.nativeCodeBundleMode === 'wasm' || shouldCullMeshoptModule(options, id); }, shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { return !this.shouldCullModule(options, id); @@ -100,7 +92,7 @@ const loadConfig: ILoadConfig = { }, '.wasm.js': { shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return options.wasmSupportMode === 0 || shouldCullBulletWasmModule(options, id) || shouldCullMeshoptModule(options, id); + return options.nativeCodeBundleMode === 'asmjs' || shouldCullMeshoptModule(options, id); }, shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { return false; @@ -312,21 +304,11 @@ export declare namespace externalWasmLoader { * The root path of external repository */ externalRoot: string, + /** - * The wasm support mode: - * 0. not support - * 1. support - * 2. maybe support - */ - wasmSupportMode: number; - /** - * Whether force banning to emit bullet wasm. - */ - forceBanningBulletWasm: boolean; - /** - * Whether cull asm js module. + * The bundle mode of native code while building scripts. */ - cullAsmJsModule: boolean; + nativeCodeBundleMode: 'wasm' | 'asmjs' | 'both'; /** * Whether cull meshopt module, including wasm and asm.js. */ diff --git a/modules/build-engine/src/index.ts b/modules/build-engine/src/index.ts index 2aace1ac..bd852bcf 100644 --- a/modules/build-engine/src/index.ts +++ b/modules/build-engine/src/index.ts @@ -111,20 +111,12 @@ export namespace buildEngine { split?: boolean; /** - * 使用的 ammo.js 版本,也即 `@cocos/ammo` 映射到的版本。 - * - 为 `true` 时使用 WebAssembly 版本的 ammo.js; - * - 为 `false` 时使用 asm.js 版本的 ammo.js; - * - 为 `'fallback` 时同时在结果中包含两个版本的 ammo.js,并自动根据环境 fallback 选择。 - * - * 注意,`'fallback'` 只有在 SystemJS 和 Async functions 同时支持时才有效。 - * @default true - * - * @deprecated 从 1.1.5 版本开始,该选项只会影响 FORCE_BANNING_BULLET_WASM 宏的值 - * - 为 `true` 时,FORCE_BANNING_BULLET_WASM 为 false - * - 为 `false` 时,FORCE_BANNING_BULLET_WASM 为 true - * - 为 `'fallback'` 时, FORCE_BANNING_BULLET_WASM 为 false + * 原生代码的打包模式 + * - 为 `wasm` 时使用 wasm 版本原生库 + * - 为 `asmjs` 时使用 asmjs 版本的原生库 + * - 为 `both` 时同时在结果中包含 wasm 与 asmjs 两个版本的原生库 */ - ammoJsWasm?: boolean | 'fallback'; + nativeCodeBundleMode?: 'wasm' | 'asmjs' | 'both'; /** * If true, all deprecated features/API are excluded. diff --git a/modules/stats-query/src/index.ts b/modules/stats-query/src/index.ts index 20678c54..c9ceeb2e 100644 --- a/modules/stats-query/src/index.ts +++ b/modules/stats-query/src/index.ts @@ -293,14 +293,7 @@ export namespace StatsQuery { NOT_PACK_PHYSX_LIBS: boolean; WEBGPU: boolean; WASM_SUPPORT_MODE: number; - FORCE_BANNING_BULLET_WASM: boolean; - /** - * Whether cull the asm.js module. - * If this is true, the external modules ending with '.asm.js' or 'js.mem' will be culled. - * - * @default false - */ - CULL_ASM_JS_MODULE: boolean; + /** * An internal constant to indicate whether we cull the meshopt wasm module and asm.js module. * diff --git a/test/build-engine/engine-js.test.ts b/test/build-engine/engine-js.test.ts index 903a746a..9566053f 100644 --- a/test/build-engine/engine-js.test.ts +++ b/test/build-engine/engine-js.test.ts @@ -14,12 +14,13 @@ describe('engine-js', () => { platform: 'WECHAT', features: ['wasm-test'], moduleFormat: 'system', + nativeCodeBundleMode: 'wasm', }); expect(await getOutputDirStructure(out)).toMatchSnapshot(); expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); await del(out, { force: true }); - // cull asm.js module + // build wasm module only await buildEngine({ engine: ps.join(__dirname, '../test-engine-source'), out, @@ -27,9 +28,8 @@ describe('engine-js', () => { platform: 'WECHAT', features: ['wasm-test'], moduleFormat: 'system', - flags: { - CULL_ASM_JS_MODULE: true, - } + nativeCodeBundleMode: 'wasm', + flags: {}, }); expect(await getOutputDirStructure(out)).toMatchSnapshot('cull asm.js module'); // expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); // this is too much for a snapshot output @@ -43,6 +43,7 @@ describe('engine-js', () => { platform: 'WECHAT', features: ['wasm-test'], moduleFormat: 'system', + nativeCodeBundleMode: 'wasm', flags: { WASM_SUBPACKAGE: true, } @@ -66,7 +67,7 @@ describe('engine-js', () => { expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); await del(out, { force: true }); - // cull asm.js module + // build wasm module only await buildEngine({ engine: ps.join(__dirname, '../test-engine-source'), out, @@ -74,9 +75,8 @@ describe('engine-js', () => { platform: 'HTML5', features: ['wasm-test'], moduleFormat: 'system', - flags: { - CULL_ASM_JS_MODULE: true, - } + nativeCodeBundleMode: 'wasm', + flags: {}, }); expect(await getOutputDirStructure(out)).toMatchSnapshot('cull asm.js module'); // expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); // this is too much for a snapshot output @@ -92,29 +92,11 @@ describe('engine-js', () => { platform: 'XIAOMI', features: ['wasm-test'], moduleFormat: 'system', + nativeCodeBundleMode: 'asmjs', }); expect(await getOutputDirStructure(out)).toMatchSnapshot(); expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); await del(out, { force: true }); - - // cull asm.js module - const buildResult = await buildEngine({ - engine: ps.join(__dirname, '../test-engine-source'), - out, - mode: 'BUILD', - platform: 'XIAOMI', - features: ['wasm-test'], - moduleFormat: 'system', - flags: { - CULL_ASM_JS_MODULE: true, - } - }); - expect(await getOutputDirStructure(out)).toMatchSnapshot('cull asm.js module'); - // expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); // this is too much for a snapshot output - await del(out, { force: true }); - - - expect(buildResult).toMatchSnapshot('build result'); }); test('enumerate dependents', async () => { @@ -136,7 +118,7 @@ describe('engine-js', () => { await del(out, { force: true }); }); - test('build width option ammoJsWasm true', async () => { + test('build width option nativeCodeBundleMode wasm', async () => { const out = ps.join(__dirname, './lib-js'); await buildEngine({ engine: ps.join(__dirname, '../test-engine-source'), @@ -145,29 +127,14 @@ describe('engine-js', () => { platform: 'XIAOMI', features: ['internal-constants'], moduleFormat: 'esm', - ammoJsWasm: true, + nativeCodeBundleMode: 'wasm', }); expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); await del(out, { force: true }); }); - test('build width option ammoJsWasm false', async () => { - const out = ps.join(__dirname, './lib-js'); - await buildEngine({ - engine: ps.join(__dirname, '../test-engine-source'), - out, - mode: 'BUILD', - platform: 'XIAOMI', - features: ['internal-constants'], - moduleFormat: 'esm', - ammoJsWasm: false, - }); - expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); - await del(out, { force: true }); - }); - - test('build width option ammoJsWasm fallback', async () => { + test('build width option nativeCodeBundleMode asmjs', async () => { const out = ps.join(__dirname, './lib-js'); await buildEngine({ engine: ps.join(__dirname, '../test-engine-source'), @@ -176,13 +143,13 @@ describe('engine-js', () => { platform: 'XIAOMI', features: ['internal-constants'], moduleFormat: 'esm', - ammoJsWasm: 'fallback', + nativeCodeBundleMode: 'asmjs', }); expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); await del(out, { force: true }); }); - test('build without option ammoJsWasm', async () => { + test('build width option nativeCodeBundleMode both', async () => { const out = ps.join(__dirname, './lib-js'); await buildEngine({ engine: ps.join(__dirname, '../test-engine-source'), @@ -191,6 +158,7 @@ describe('engine-js', () => { platform: 'XIAOMI', features: ['internal-constants'], moduleFormat: 'esm', + nativeCodeBundleMode: 'both', }); expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); await del(out, { force: true }); @@ -218,6 +186,7 @@ describe('engine-js', () => { mode: 'BUILD', platform: 'OPEN_HARMONY', features: ['wasm-test'], + nativeCodeBundleMode: 'wasm', flags: { WASM_SUPPORT_MODE: 1, // force flag value to test inline dynamic import }, @@ -236,6 +205,7 @@ describe('engine-js', () => { platform: 'WECHAT', features: ['cull-meshopt'], moduleFormat: 'system', + nativeCodeBundleMode: 'wasm', flags: { CULL_MESHOPT: true, }, @@ -252,6 +222,7 @@ describe('engine-js', () => { platform: 'BYTEDANCE', features: ['cull-meshopt'], moduleFormat: 'system', + nativeCodeBundleMode: 'asmjs', flags: { CULL_MESHOPT: true, }, diff --git a/test/stats-query/constant-manager.test.ts b/test/stats-query/constant-manager.test.ts index a3e03278..c2c8737b 100644 --- a/test/stats-query/constant-manager.test.ts +++ b/test/stats-query/constant-manager.test.ts @@ -16,7 +16,7 @@ test('genCCEnvConstants', () => { expect(cm.genCCEnvConstants({ mode: 'TEST', platform: 'NATIVE', - flags: { DEBUG: false, SERVER_MODE: true, FORCE_BANNING_BULLET_WASM: true }, + flags: { DEBUG: false, SERVER_MODE: true }, })).toMatchSnapshot(); }); @@ -25,7 +25,7 @@ test('exportStaticConstants', () => { cm.exportStaticConstants({ mode: 'PREVIEW', platform: 'WECHAT', - flags: { DEBUG: false, SERVER_MODE: true, FORCE_BANNING_BULLET_WASM: true, CULL_ASM_JS_MODULE: false }, + flags: { DEBUG: false, SERVER_MODE: true }, }) ).toMatchSnapshot(); }); @@ -35,7 +35,7 @@ test('exportDynamicConstants', () => { cm.exportDynamicConstants({ mode: 'BUILD', platform: 'WECHAT', - flags: { DEBUG: true, SERVER_MODE: true, FORCE_BANNING_BULLET_WASM: true, CULL_ASM_JS_MODULE: true }, + flags: { DEBUG: true, SERVER_MODE: true }, }) ).toMatchSnapshot(); }); @@ -44,7 +44,7 @@ test('genBuildTimeConstants', () => { const result = cm.genBuildTimeConstants({ mode: 'TEST', platform: 'NATIVE', - flags: { DEBUG: false, SERVER_MODE: true, FORCE_BANNING_BULLET_WASM: true, CULL_ASM_JS_MODULE: true }, + flags: { DEBUG: false, SERVER_MODE: true }, }); expect(result).toMatchSnapshot(); }); diff --git a/test/test-engine-source/cc.config.json b/test/test-engine-source/cc.config.json index a2792161..63a79545 100644 --- a/test/test-engine-source/cc.config.json +++ b/test/test-engine-source/cc.config.json @@ -390,18 +390,6 @@ "internal": false, "dynamic": true }, - "FORCE_BANNING_BULLET_WASM": { - "comment": "Whether force banning using bullet wasm and use asmjs instead.", - "type": "boolean", - "value": false, - "internal": true - }, - "CULL_ASM_JS_MODULE": { - "comment": "Whether cull the asm js module\nThe external modules ending with '.asm.js'. or '.js.mem' is culled if this constant is true.", - "type": "boolean", - "value": false, - "internal": true - }, "WASM_SUBPACKAGE": { "comment": "An internal constant to indicate whether we use wasm assets as minigame subpackage.\nThis is useful when we need to reduce code size.", "type": "boolean", diff --git a/test/test-engine-source/exports/internal-constants.ts b/test/test-engine-source/exports/internal-constants.ts index ee3d72ea..662a651f 100644 --- a/test/test-engine-source/exports/internal-constants.ts +++ b/test/test-engine-source/exports/internal-constants.ts @@ -1,3 +1,3 @@ -import { FORCE_BANNING_BULLET_WASM } from "internal:constants"; +import { WASM_SUPPORT_MODE } from 'internal:constants'; -console.log(FORCE_BANNING_BULLET_WASM); \ No newline at end of file +console.log(WASM_SUPPORT_MODE); \ No newline at end of file diff --git a/test/test-engine-source/wasm/wasm-pack.ts b/test/test-engine-source/wasm/wasm-pack.ts index ff5145cd..62c1311f 100644 --- a/test/test-engine-source/wasm/wasm-pack.ts +++ b/test/test-engine-source/wasm/wasm-pack.ts @@ -1,6 +1,6 @@ import { WASM_SUPPORT_MODE } from 'internal:constants'; import wasmUrl from 'external:wasm/wasm-pack/wasm_rust.wasm'; -import init from 'external:wasm/wasm-pack/wasm_rust.js' +import init from 'external:wasm/wasm-pack/wasm_rust.js'; import { isSupportWASM } from './is-support-wasm'; if (WASM_SUPPORT_MODE === 1) { From cd97b960e2700b4416d052f93bbfaf97e5817a2e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 13:51:57 +0800 Subject: [PATCH 03/13] Revert "Remove WASM fallback logic." This reverts commit 7c0013a359e49090d1dc2ff6d066eb8e2fc7be18. --- modules/build-engine/src/engine-js/index.ts | 1 + .../rollup-plugins/external-wasm-loader.ts | 24 +++++++++++ .../engine-ts/plugins/external-wasm-loader.ts | 18 +++++++++ modules/stats-query/src/index.ts | 8 ++++ test/build-engine/engine-js.test.ts | 4 +- test/test-engine-source/cc.config.json | 6 +++ .../wasm/emscripten/wasm_c.wasm.fallback | Bin 0 -> 13963 bytes .../wasm/emscripten/wasm_c.wasm.fallback.js | 2 + test/test-engine-source/wasm/emscripten.ts | 38 ++++++++---------- 9 files changed, 78 insertions(+), 23 deletions(-) create mode 100644 test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback create mode 100644 test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js diff --git a/modules/build-engine/src/engine-js/index.ts b/modules/build-engine/src/engine-js/index.ts index 17cbd8d7..86472910 100644 --- a/modules/build-engine/src/engine-js/index.ts +++ b/modules/build-engine/src/engine-js/index.ts @@ -248,6 +248,7 @@ export async function buildJsEngine(options: Required): Pro nativeCodeBundleMode, cullMeshopt: buildTimeConstants.CULL_MESHOPT, format: 'relative-from-chunk', + wasmFallback: buildTimeConstants.WASM_FALLBACK, wasmSubpackage: buildTimeConstants.WASM_SUBPACKAGE, }), diff --git a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts index af8f9080..a1f16d67 100644 --- a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts @@ -22,6 +22,7 @@ interface ISuffixReplaceConfig { const suffixReplaceConfig: ISuffixReplaceConfig = { '.mem': '.mem.bin', + '.wasm.fallback': '.wasm.fallback.bin', }; /** @@ -108,6 +109,24 @@ const loadConfig: ILoadConfig = { }, cullingContent: `export default function () {}`, }, + '.wasm.fallback': { + shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { + return loadConfig['.wasm'].shouldCullModule(options, id) || !options.wasmFallback; + }, + shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { + return !this.shouldCullModule(options, id); + }, + cullingContent: `export default '';`, + }, + '.wasm.fallback.js': { + shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { + return loadConfig['.wasm.js'].shouldCullModule(options, id) || !options.wasmFallback; + }, + shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { + return false; + }, + cullingContent: `export default function () {}`, + }, }; declare namespace ExternalWasmModuleBundler { @@ -305,6 +324,11 @@ export declare namespace externalWasmLoader { */ externalRoot: string, + /** + * Whether need a fallback of wasm. + * If true, we need to build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. + */ + wasmFallback: boolean; /** * The bundle mode of native code while building scripts. */ diff --git a/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts index 42c99649..de4d30c1 100644 --- a/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts @@ -85,6 +85,24 @@ const loadConfig: ILoadConfig = { }, cullingContent: `let $: any;export default $;`, }, + '.wasm.fallback': { + shouldCullModule (options: externalWasmLoaderFactory.Options, id: string): boolean { + return true; // we don't need wasm.fallback module for OH platform + }, + shouldEmitAsset (options: externalWasmLoaderFactory.Options, id: string): boolean { + return !this.shouldCullModule(options, id); + }, + cullingContent: `export default '';`, + }, + '.wasm.fallback.js': { + shouldCullModule (options: externalWasmLoaderFactory.Options, id: string): boolean { + return true; // we don't need wasm.fallback module for OH platform + }, + shouldEmitAsset (options: externalWasmLoaderFactory.Options, id: string): boolean { + return false; + }, + cullingContent: `export default function () {}`, + }, }; // NOTE: we use rollup to transform CommonJS to ES Module. diff --git a/modules/stats-query/src/index.ts b/modules/stats-query/src/index.ts index c9ceeb2e..a30e9e30 100644 --- a/modules/stats-query/src/index.ts +++ b/modules/stats-query/src/index.ts @@ -300,6 +300,14 @@ export namespace StatsQuery { * @default false */ CULL_MESHOPT: boolean; + /** + * An internal constant to indicate whether need a fallback of wasm. + * If true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. + * This is useful when we use wasm on different version of Safari browsers. + * + * @default false + */ + WASM_FALLBACK: boolean; /** * An internal constant to indicate whether we use wasm assets as minigame subpackage. * This is useful when we need to reduce code size. diff --git a/test/build-engine/engine-js.test.ts b/test/build-engine/engine-js.test.ts index 9566053f..d13dd5d3 100644 --- a/test/build-engine/engine-js.test.ts +++ b/test/build-engine/engine-js.test.ts @@ -188,7 +188,9 @@ describe('engine-js', () => { features: ['wasm-test'], nativeCodeBundleMode: 'wasm', flags: { - WASM_SUPPORT_MODE: 1, // force flag value to test inline dynamic import + // force flag value to test inline dynamic import + WASM_SUPPORT_MODE: 1, + WASM_FALLBACK: true, }, moduleFormat: 'esm', }); diff --git a/test/test-engine-source/cc.config.json b/test/test-engine-source/cc.config.json index 63a79545..7109ec79 100644 --- a/test/test-engine-source/cc.config.json +++ b/test/test-engine-source/cc.config.json @@ -390,6 +390,12 @@ "internal": false, "dynamic": true }, + "WASM_FALLBACK": { + "comment": "An internal constant to indicate whether need a fallback of wasm.\nIf true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.\nThis is useful when we use wasm on different version of Safari browsers.", + "type": "boolean", + "value": "$HTML5", + "internal": true + }, "WASM_SUBPACKAGE": { "comment": "An internal constant to indicate whether we use wasm assets as minigame subpackage.\nThis is useful when we need to reduce code size.", "type": "boolean", diff --git a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback b/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback new file mode 100644 index 0000000000000000000000000000000000000000..2d81841d8df1d797c1c7c3e2df482be7826e1e2b GIT binary patch literal 13963 zcmbuG>v9~&b;o-yi`~Txu!98_x22<=5uHF5DMPjlQHo=6DC;gOitV^usZ@a%K^7Mj zNL)nGWeS@w`RE78!=&;8`IbsmKI9$p3i2p7)&y0TfLw~Y& zeB!^pbNr?M{LX_1ckkTWUzm41M$WnDfBx-Xr$4uP+ePEs$#^{G7KMwu?cD9ydXn+! zI6Ad)ce}+b>zx}vZCcD?Ds#rS)A8vk59ws&={S0NyR9ew**JH1J2|zd0L$Huo&r8T zJ!LK{wOKqxj)sd@A>;n;@xh%($6q`=*?n}h_xS$a*ROUy|7`c`qx&a&Zec#zJ9s?U z`||kS(fvm!dk4E;?tOXh(eHQf-v6CzC+DEOk-AnC&qZ;PBrc8PsO1);sMBl5#Zs2_ zqwd1|atx2ssFmj{DJ_@8E^+aolb!<Q5`zcjHa8pw9ifK z&4KvCqux;by4<5Rt*xlVbIy!i``{3cdJ16%a9=PSX z&p&_g)$teZ#>VdM{e#c$AMM>c+5P;hgL@j@J-KuD!CvHM8FYMtMlkjMiF;*ZhH;_) zcYCZp+S_wKym;*Ho#Q>Xy?)`ky@Su(t6hWht2>YP+>df={}O$Cc(mt!yfAOiHKg2g zuU)wi#=WnOj`j{t+)wh)et+<`STMRjy6@iXp5s>J>L_c?wc2I1Fwe+;{1X@V#+)l& zDYmjJQ8J!zy>zuJBkz1vq?AbC2?Jh7>zPO z$5C4g{C<_tm3X%mU#ZfaxKL}QY|$0(#8Ljnpx>d{nsN>N^;#Ps>&wWywv?!mT*3qIVbOhXt@@ig-((9^9rtvVl7 z-8wlLRW0Azib2|UYU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X8@dt*K>!OOzzpDt=d!J z?S$)v$eEp(mBcZX7wRs2%^F{Yawv?>okW>5`?HV5(o1K&{nTGR2%PcLP!+rNQy$o9 zf@I3R=gViao9ftHT|V6Twbb^x`?{xmL<s8)3ogXxH7$`-F(?5pNckJ07akX zUC^zi{OLod#&3*A#mngCS@}`cQd~11TBU&9Chi5mhIhWeTU4!ew6#f=Gs z$#>g8!Vzu7H!7i+WyPY8dMd$O0?~ZZGf)-31*7?bi!DXixWw0CqZoQXF0CTX>Qst% zEbzES`QzHUx0dGIrZ(nD$9%qG51)JKrcX2Bmb|ke9A$zaUz&Kw!t6x?fQCGUpSZ8rN~amo!U literal 0 HcmV?d00001 diff --git a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js b/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js new file mode 100644 index 00000000..083def88 --- /dev/null +++ b/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js @@ -0,0 +1,2 @@ +// simply file code +export default function wasmFallbackModule () {} \ No newline at end of file diff --git a/test/test-engine-source/wasm/emscripten.ts b/test/test-engine-source/wasm/emscripten.ts index 3ef47f76..827e39d6 100644 --- a/test/test-engine-source/wasm/emscripten.ts +++ b/test/test-engine-source/wasm/emscripten.ts @@ -1,4 +1,4 @@ -import { WASM_SUPPORT_MODE } from 'internal:constants'; +import { WASM_FALLBACK, WASM_SUPPORT_MODE } from 'internal:constants'; import { isSupportWASM } from './is-support-wasm'; import wasmUrl from 'external:wasm/emscripten/wasm_c.wasm'; import wasmFactory from 'external:wasm/emscripten/wasm_c.wasm.js'; @@ -8,6 +8,21 @@ import asmJsMemUrl from 'external:wasm/emscripten/wasm_c.js.mem'; function initializeWasm (): Promise { return new Promise((resolve, reject) => { + if (WASM_FALLBACK) { + Promise.all([import('external:wasm/emscripten/wasm_c.wasm.fallback'), import('external:wasm/emscripten/wasm_c.wasm.fallback.js')]).then(([ + { default: wasmFallbackUrl }, + { default: wasmFallbackFactory }, + ]) => { + return wasmFallbackFactory({ + locateFile(_) { + return wasmFallbackUrl; + } + }).then(inst => { + resolve(inst); + }).catch(reject); + }); + return; + } wasmFactory({ locateFile(_) { return wasmUrl; @@ -18,27 +33,6 @@ function initializeWasm (): Promise { }); } -// function initializeWasm (): Promise { -// return Promise.all([ -// import('external:wasm/emscripten/wasm_c.wasm'), -// import('external:wasm/emscripten/wasm_c.wasm.js'), -// ]).then(([ -// { default: wasmUrl }, -// { default: wasmFactory }, -// ]) => { -// return new Promise((resolve, reject) => { -// wasmFactory({ -// locateFile(_) { -// return wasmUrl; -// } -// }).then(inst => { -// resolve(inst); -// }).catch(reject); -// }); - -// }); -// } - function initializeAsm (): Promise { return new Promise((resolve, reject) => { asmFactory({ From 4e45bb73495c76b868ab0e25b2d2e137716eac64 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:07:23 +0800 Subject: [PATCH 04/13] Override CULL_MESHOPT only when it's undefined. --- modules/build-engine/src/engine-js/index.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/build-engine/src/engine-js/index.ts b/modules/build-engine/src/engine-js/index.ts index 86472910..6fcd6822 100644 --- a/modules/build-engine/src/engine-js/index.ts +++ b/modules/build-engine/src/engine-js/index.ts @@ -94,7 +94,9 @@ export async function buildJsEngine(options: Required): Pro const flags = options.flags ?? {}; // meshopt is only used in 3d module, so cull it if 3d module is disabled. - flags.CULL_MESHOPT = !features.includes('3d'); + if (flags.CULL_MESHOPT === undefined) { + flags.CULL_MESHOPT = !features.includes('3d'); + } const intrinsicFlags = statsQuery.getIntrinsicFlagsOfFeatures(features); let buildTimeConstants = statsQuery.constantManager.genBuildTimeConstants({ From 9e730287c82dc94258dda050f04a7415fb3779e8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:08:04 +0800 Subject: [PATCH 05/13] Revert a engine-js test --- test/build-engine/engine-js.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/build-engine/engine-js.test.ts b/test/build-engine/engine-js.test.ts index d13dd5d3..3ec70e67 100644 --- a/test/build-engine/engine-js.test.ts +++ b/test/build-engine/engine-js.test.ts @@ -97,6 +97,25 @@ describe('engine-js', () => { expect(await getOutputDirStructure(out)).toMatchSnapshot(); expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); await del(out, { force: true }); + + + // build asmjs only + const buildResult = await buildEngine({ + engine: ps.join(__dirname, '../test-engine-source'), + out, + mode: 'BUILD', + platform: 'XIAOMI', + features: ['wasm-test'], + moduleFormat: 'system', + flags: {}, + nativeCodeBundleMode: 'asmjs', + }); + expect(await getOutputDirStructure(out)).toMatchSnapshot('cull asm.js module'); + // expect(await getOutputContent(ps.join(out, 'cc.js'))).toMatchSnapshot(); // this is too much for a snapshot output + await del(out, { force: true }); + + expect(buildResult).toMatchSnapshot('build result'); + }); test('enumerate dependents', async () => { From 1cd0032a90197dea028e809186dbd1e605d96d91 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:08:38 +0800 Subject: [PATCH 06/13] Revert "Revert "Remove WASM fallback logic."" This reverts commit 1644df8801d80f8434c5b8ce4ac8cfd772f6982a. --- modules/build-engine/src/engine-js/index.ts | 1 - .../rollup-plugins/external-wasm-loader.ts | 24 ----------- .../engine-ts/plugins/external-wasm-loader.ts | 18 --------- modules/stats-query/src/index.ts | 8 ---- test/build-engine/engine-js.test.ts | 4 +- test/test-engine-source/cc.config.json | 6 --- .../wasm/emscripten/wasm_c.wasm.fallback | Bin 13963 -> 0 bytes .../wasm/emscripten/wasm_c.wasm.fallback.js | 2 - test/test-engine-source/wasm/emscripten.ts | 38 ++++++++++-------- 9 files changed, 23 insertions(+), 78 deletions(-) delete mode 100644 test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback delete mode 100644 test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js diff --git a/modules/build-engine/src/engine-js/index.ts b/modules/build-engine/src/engine-js/index.ts index 6fcd6822..2d6a7c42 100644 --- a/modules/build-engine/src/engine-js/index.ts +++ b/modules/build-engine/src/engine-js/index.ts @@ -250,7 +250,6 @@ export async function buildJsEngine(options: Required): Pro nativeCodeBundleMode, cullMeshopt: buildTimeConstants.CULL_MESHOPT, format: 'relative-from-chunk', - wasmFallback: buildTimeConstants.WASM_FALLBACK, wasmSubpackage: buildTimeConstants.WASM_SUBPACKAGE, }), diff --git a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts index a1f16d67..af8f9080 100644 --- a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts @@ -22,7 +22,6 @@ interface ISuffixReplaceConfig { const suffixReplaceConfig: ISuffixReplaceConfig = { '.mem': '.mem.bin', - '.wasm.fallback': '.wasm.fallback.bin', }; /** @@ -109,24 +108,6 @@ const loadConfig: ILoadConfig = { }, cullingContent: `export default function () {}`, }, - '.wasm.fallback': { - shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return loadConfig['.wasm'].shouldCullModule(options, id) || !options.wasmFallback; - }, - shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { - return !this.shouldCullModule(options, id); - }, - cullingContent: `export default '';`, - }, - '.wasm.fallback.js': { - shouldCullModule (options: externalWasmLoader.Options, id: string): boolean { - return loadConfig['.wasm.js'].shouldCullModule(options, id) || !options.wasmFallback; - }, - shouldEmitAsset (options: externalWasmLoader.Options, id: string): boolean { - return false; - }, - cullingContent: `export default function () {}`, - }, }; declare namespace ExternalWasmModuleBundler { @@ -324,11 +305,6 @@ export declare namespace externalWasmLoader { */ externalRoot: string, - /** - * Whether need a fallback of wasm. - * If true, we need to build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. - */ - wasmFallback: boolean; /** * The bundle mode of native code while building scripts. */ diff --git a/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts index de4d30c1..42c99649 100644 --- a/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-ts/plugins/external-wasm-loader.ts @@ -85,24 +85,6 @@ const loadConfig: ILoadConfig = { }, cullingContent: `let $: any;export default $;`, }, - '.wasm.fallback': { - shouldCullModule (options: externalWasmLoaderFactory.Options, id: string): boolean { - return true; // we don't need wasm.fallback module for OH platform - }, - shouldEmitAsset (options: externalWasmLoaderFactory.Options, id: string): boolean { - return !this.shouldCullModule(options, id); - }, - cullingContent: `export default '';`, - }, - '.wasm.fallback.js': { - shouldCullModule (options: externalWasmLoaderFactory.Options, id: string): boolean { - return true; // we don't need wasm.fallback module for OH platform - }, - shouldEmitAsset (options: externalWasmLoaderFactory.Options, id: string): boolean { - return false; - }, - cullingContent: `export default function () {}`, - }, }; // NOTE: we use rollup to transform CommonJS to ES Module. diff --git a/modules/stats-query/src/index.ts b/modules/stats-query/src/index.ts index a30e9e30..c9ceeb2e 100644 --- a/modules/stats-query/src/index.ts +++ b/modules/stats-query/src/index.ts @@ -300,14 +300,6 @@ export namespace StatsQuery { * @default false */ CULL_MESHOPT: boolean; - /** - * An internal constant to indicate whether need a fallback of wasm. - * If true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. - * This is useful when we use wasm on different version of Safari browsers. - * - * @default false - */ - WASM_FALLBACK: boolean; /** * An internal constant to indicate whether we use wasm assets as minigame subpackage. * This is useful when we need to reduce code size. diff --git a/test/build-engine/engine-js.test.ts b/test/build-engine/engine-js.test.ts index 3ec70e67..6503f178 100644 --- a/test/build-engine/engine-js.test.ts +++ b/test/build-engine/engine-js.test.ts @@ -207,9 +207,7 @@ describe('engine-js', () => { features: ['wasm-test'], nativeCodeBundleMode: 'wasm', flags: { - // force flag value to test inline dynamic import - WASM_SUPPORT_MODE: 1, - WASM_FALLBACK: true, + WASM_SUPPORT_MODE: 1, // force flag value to test inline dynamic import }, moduleFormat: 'esm', }); diff --git a/test/test-engine-source/cc.config.json b/test/test-engine-source/cc.config.json index 7109ec79..63a79545 100644 --- a/test/test-engine-source/cc.config.json +++ b/test/test-engine-source/cc.config.json @@ -390,12 +390,6 @@ "internal": false, "dynamic": true }, - "WASM_FALLBACK": { - "comment": "An internal constant to indicate whether need a fallback of wasm.\nIf true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten.\nThis is useful when we use wasm on different version of Safari browsers.", - "type": "boolean", - "value": "$HTML5", - "internal": true - }, "WASM_SUBPACKAGE": { "comment": "An internal constant to indicate whether we use wasm assets as minigame subpackage.\nThis is useful when we need to reduce code size.", "type": "boolean", diff --git a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback b/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback deleted file mode 100644 index 2d81841d8df1d797c1c7c3e2df482be7826e1e2b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 13963 zcmbuG>v9~&b;o-yi`~Txu!98_x22<=5uHF5DMPjlQHo=6DC;gOitV^usZ@a%K^7Mj zNL)nGWeS@w`RE78!=&;8`IbsmKI9$p3i2p7)&y0TfLw~Y& zeB!^pbNr?M{LX_1ckkTWUzm41M$WnDfBx-Xr$4uP+ePEs$#^{G7KMwu?cD9ydXn+! zI6Ad)ce}+b>zx}vZCcD?Ds#rS)A8vk59ws&={S0NyR9ew**JH1J2|zd0L$Huo&r8T zJ!LK{wOKqxj)sd@A>;n;@xh%($6q`=*?n}h_xS$a*ROUy|7`c`qx&a&Zec#zJ9s?U z`||kS(fvm!dk4E;?tOXh(eHQf-v6CzC+DEOk-AnC&qZ;PBrc8PsO1);sMBl5#Zs2_ zqwd1|atx2ssFmj{DJ_@8E^+aolb!<Q5`zcjHa8pw9ifK z&4KvCqux;by4<5Rt*xlVbIy!i``{3cdJ16%a9=PSX z&p&_g)$teZ#>VdM{e#c$AMM>c+5P;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^vl85on$T&HA3nPMzP*!k(xq1pg<&FC2^ecCsa^1bWYLDnj+7Aj-mI8h9^JMXyDM z1P3ieK1<5)U{prWEBf4urM#_S)3XV8#d7(k^RASz0b&I1K3;F%C*fVPDZ(6Ggy3b>yPix5Dx&%=n;D@akv-4Z%L_fbnr|k93N|Q) zFYXM$&FKc{3mS1A6crRe=VzcMpl5cg6G0CZ2rzy+dDr&V1*j#qzW+RU(=BJWNF@NH zT`I}ZmOTYZ#6{VPWB-YuYzJ4ol>I8ww}*^ab;C7>P@Zm%K$Bk?-*UlegoBFlg9xZB zfFH_a$Gqm_VX8@dt*K>!OOzzpDt=d!J z?S$)v$eEp(mBcZX7wRs2%^F{Yawv?>okW>5`?HV5(o1K&{nTGR2%PcLP!+rNQy$o9 zf@I3R=gViao9ftHT|V6Twbb^x`?{xmL<s8)3ogXxH7$`-F(?5pNckJ07akX zUC^zi{OLod#&3*A#mngCS@}`cQd~11TBU&9Chi5mhIhWeTU4!ew6#f=Gs z$#>g8!Vzu7H!7i+WyPY8dMd$O0?~ZZGf)-31*7?bi!DXixWw0CqZoQXF0CTX>Qst% zEbzES`QzHUx0dGIrZ(nD$9%qG51)JKrcX2Bmb|ke9A$zaUz&Kw!t6x?fQCGUpSZ8rN~amo!U diff --git a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js b/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js deleted file mode 100644 index 083def88..00000000 --- a/test/test-engine-source/native/external/wasm/emscripten/wasm_c.wasm.fallback.js +++ /dev/null @@ -1,2 +0,0 @@ -// simply file code -export default function wasmFallbackModule () {} \ No newline at end of file diff --git a/test/test-engine-source/wasm/emscripten.ts b/test/test-engine-source/wasm/emscripten.ts index 827e39d6..3ef47f76 100644 --- a/test/test-engine-source/wasm/emscripten.ts +++ b/test/test-engine-source/wasm/emscripten.ts @@ -1,4 +1,4 @@ -import { WASM_FALLBACK, WASM_SUPPORT_MODE } from 'internal:constants'; +import { WASM_SUPPORT_MODE } from 'internal:constants'; import { isSupportWASM } from './is-support-wasm'; import wasmUrl from 'external:wasm/emscripten/wasm_c.wasm'; import wasmFactory from 'external:wasm/emscripten/wasm_c.wasm.js'; @@ -8,21 +8,6 @@ import asmJsMemUrl from 'external:wasm/emscripten/wasm_c.js.mem'; function initializeWasm (): Promise { return new Promise((resolve, reject) => { - if (WASM_FALLBACK) { - Promise.all([import('external:wasm/emscripten/wasm_c.wasm.fallback'), import('external:wasm/emscripten/wasm_c.wasm.fallback.js')]).then(([ - { default: wasmFallbackUrl }, - { default: wasmFallbackFactory }, - ]) => { - return wasmFallbackFactory({ - locateFile(_) { - return wasmFallbackUrl; - } - }).then(inst => { - resolve(inst); - }).catch(reject); - }); - return; - } wasmFactory({ locateFile(_) { return wasmUrl; @@ -33,6 +18,27 @@ function initializeWasm (): Promise { }); } +// function initializeWasm (): Promise { +// return Promise.all([ +// import('external:wasm/emscripten/wasm_c.wasm'), +// import('external:wasm/emscripten/wasm_c.wasm.js'), +// ]).then(([ +// { default: wasmUrl }, +// { default: wasmFactory }, +// ]) => { +// return new Promise((resolve, reject) => { +// wasmFactory({ +// locateFile(_) { +// return wasmUrl; +// } +// }).then(inst => { +// resolve(inst); +// }).catch(reject); +// }); + +// }); +// } + function initializeAsm (): Promise { return new Promise((resolve, reject) => { asmFactory({ From 54bdbcfe3d8d530a2e33f2a08b4749d27376035e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:11:01 +0800 Subject: [PATCH 07/13] Use dynamic import wasm in wasm/emscripten.ts --- test/test-engine-source/wasm/emscripten.ts | 49 ++++++++-------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/test/test-engine-source/wasm/emscripten.ts b/test/test-engine-source/wasm/emscripten.ts index 3ef47f76..0e06a7a5 100644 --- a/test/test-engine-source/wasm/emscripten.ts +++ b/test/test-engine-source/wasm/emscripten.ts @@ -1,44 +1,31 @@ import { WASM_SUPPORT_MODE } from 'internal:constants'; import { isSupportWASM } from './is-support-wasm'; -import wasmUrl from 'external:wasm/emscripten/wasm_c.wasm'; -import wasmFactory from 'external:wasm/emscripten/wasm_c.wasm.js'; + import asmFactory from 'external:wasm/emscripten/wasm_c.asm.js'; import asmJsMemUrl from 'external:wasm/emscripten/wasm_c.js.mem'; function initializeWasm (): Promise { - return new Promise((resolve, reject) => { - wasmFactory({ - locateFile(_) { - return wasmUrl; - } - }).then(inst => { - resolve(inst); - }).catch(reject); + return Promise.all([ + import('external:wasm/emscripten/wasm_c.wasm'), + import('external:wasm/emscripten/wasm_c.wasm.js'), + ]).then(([ + { default: wasmUrl }, + { default: wasmFactory }, + ]) => { + return new Promise((resolve, reject) => { + wasmFactory({ + locateFile(_) { + return wasmUrl; + } + }).then(inst => { + resolve(inst); + }).catch(reject); + }); + }); } -// function initializeWasm (): Promise { -// return Promise.all([ -// import('external:wasm/emscripten/wasm_c.wasm'), -// import('external:wasm/emscripten/wasm_c.wasm.js'), -// ]).then(([ -// { default: wasmUrl }, -// { default: wasmFactory }, -// ]) => { -// return new Promise((resolve, reject) => { -// wasmFactory({ -// locateFile(_) { -// return wasmUrl; -// } -// }).then(inst => { -// resolve(inst); -// }).catch(reject); -// }); - -// }); -// } - function initializeAsm (): Promise { return new Promise((resolve, reject) => { asmFactory({ From 00da5ff289fdfb06e27e90b9d14f1a0b3847865e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:12:28 +0800 Subject: [PATCH 08/13] Update public.d.ts --- .api/public.d.ts | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) diff --git a/.api/public.d.ts b/.api/public.d.ts index b8a0cd08..57e7f053 100644 --- a/.api/public.d.ts +++ b/.api/public.d.ts @@ -71,20 +71,12 @@ declare module "@cocos/ccbuild" { */ split?: boolean; /** - * 使用的 ammo.js 版本,也即 `@cocos/ammo` 映射到的版本。 - * - 为 `true` 时使用 WebAssembly 版本的 ammo.js; - * - 为 `false` 时使用 asm.js 版本的 ammo.js; - * - 为 `'fallback` 时同时在结果中包含两个版本的 ammo.js,并自动根据环境 fallback 选择。 - * - * 注意,`'fallback'` 只有在 SystemJS 和 Async functions 同时支持时才有效。 - * @default true - * - * @deprecated 从 1.1.5 版本开始,该选项只会影响 FORCE_BANNING_BULLET_WASM 宏的值 - * - 为 `true` 时,FORCE_BANNING_BULLET_WASM 为 false - * - 为 `false` 时,FORCE_BANNING_BULLET_WASM 为 true - * - 为 `'fallback'` 时, FORCE_BANNING_BULLET_WASM 为 false + * 原生代码的打包模式 + * - 为 `wasm` 时使用 wasm 版本原生库 + * - 为 `asmjs` 时使用 asmjs 版本的原生库 + * - 为 `both` 时同时在结果中包含 wasm 与 asmjs 两个版本的原生库 */ - ammoJsWasm?: boolean | "fallback"; + nativeCodeBundleMode?: "wasm" | "asmjs" | "both"; /** * If true, all deprecated features/API are excluded. * You can also specify a version range(in semver range) to exclude deprecations in specified version(s). @@ -247,28 +239,12 @@ declare module "@cocos/ccbuild" { NOT_PACK_PHYSX_LIBS: boolean; WEBGPU: boolean; WASM_SUPPORT_MODE: number; - FORCE_BANNING_BULLET_WASM: boolean; - /** - * Whether cull the asm.js module. - * If this is true, the external modules ending with '.asm.js' or 'js.mem' will be culled. - * - * @default false - */ - CULL_ASM_JS_MODULE: boolean; /** * An internal constant to indicate whether we cull the meshopt wasm module and asm.js module. * * @default false */ CULL_MESHOPT: boolean; - /** - * An internal constant to indicate whether need a fallback of wasm. - * If true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. - * This is useful when we use wasm on different version of Safari browsers. - * - * @default false - */ - WASM_FALLBACK: boolean; /** * An internal constant to indicate whether we use wasm assets as minigame subpackage. * This is useful when we need to reduce code size. From 37aa9acf151c915d0cd4c6f2b10ed36b7a439eb2 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:14:18 +0800 Subject: [PATCH 09/13] Update package.json and .vscode/setting.json --- .vscode/settings.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3074864d..a96b47b5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "editor.codeActionsOnSave": { - "source.fixAll": true + "source.fixAll": "explicit" }, "cSpell.enabled": true, "cSpell.words": [ diff --git a/package.json b/package.json index 8aad4d29..4484aa7d 100644 --- a/package.json +++ b/package.json @@ -66,9 +66,9 @@ "typedoc": "^0.24.8" }, "dependencies": { - "@ccbuild/dts-bundler": "*", "@ccbuild/build-engine": "*", "@ccbuild/bundler": "*", + "@ccbuild/dts-bundler": "*", "@ccbuild/modularize": "*", "@ccbuild/stats-query": "*", "@ccbuild/transformer": "*", From 8fe408f10e382f59beec355e04c1b5b825a984fb Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:17:56 +0800 Subject: [PATCH 10/13] Update snapshot. --- .../__snapshots__/engine-js.test.ts.snap | 2324 +---------------- .../__snapshots__/engine-ts.test.ts.snap | 49 +- .../constant-manager.test.ts.snap | 33 - 3 files changed, 56 insertions(+), 2350 deletions(-) diff --git a/test/build-engine/__snapshots__/engine-js.test.ts.snap b/test/build-engine/__snapshots__/engine-js.test.ts.snap index 81abc79c..211c79a2 100644 --- a/test/build-engine/__snapshots__/engine-js.test.ts.snap +++ b/test/build-engine/__snapshots__/engine-js.test.ts.snap @@ -2,622 +2,39 @@ exports[`engine-js build WASM module on platform maybe supporting WASM 1`] = ` [ + "_virtual_cc-63580829.js", "assets/wasm_c-8515ca89.wasm", "assets/wasm_c.js.mem-429cc1f7.bin", - "assets/wasm_c.wasm.fallback-26103d05.bin", "assets/wasm_rust-404aff2f.wasm", "cc.js", - "wasm_c.wasm-a82df3d4.js", - "wasm_c.wasm.fallback-721977f8.js", + "wasm_c-a7853123.js", + "wasm_c.wasm-8489fd77.js", ] `; exports[`engine-js build WASM module on platform maybe supporting WASM 2`] = ` -"System.register([], (function (exports, module) { - 'use strict'; - return { - execute: (function () { +"System.register(['./_virtual_cc-63580829.js'], (function () { + 'use strict'; + return { + setters: [function () {}], + execute: (function () { - function tryDefineGlobal (name, value) { - const _global = typeof window === 'undefined' ? global : window; - if (typeof _global[name] === 'undefined') { - return (_global[name] = value); - } else { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return _global[name]; - } - } - tryDefineGlobal('CC_WECHAT', false); - tryDefineGlobal('CC_BAIDU', false); - tryDefineGlobal('CC_XIAOMI', false); - tryDefineGlobal('CC_ALIPAY', false); - tryDefineGlobal('CC_BYTEDANCE', false); - tryDefineGlobal('CC_OPPO', false); - tryDefineGlobal('CC_VIVO', false); - tryDefineGlobal('CC_HUAWEI', false); - tryDefineGlobal('CC_COCOSPLAY', false); - tryDefineGlobal('CC_QTT', false); - tryDefineGlobal('CC_LINKSURE', false); - tryDefineGlobal('CC_EDITOR', false); - tryDefineGlobal('CC_PREVIEW', false); - tryDefineGlobal('CC_BUILD', true); - tryDefineGlobal('CC_TEST', false); - tryDefineGlobal('CC_DEBUG', true); - tryDefineGlobal('CC_DEV', false); - tryDefineGlobal('CC_MINIGAME', false); - tryDefineGlobal('CC_RUNTIME_BASED', false); - tryDefineGlobal('CC_SUPPORT_JIT', true); - tryDefineGlobal('CC_JSB', false); - var wasmUrl = 'assets/wasm_rust-404aff2f.wasm'; /* asset-hash:829fe457 */ - - function _regeneratorRuntime() { - _regeneratorRuntime = function () { - return exports; - }; - var exports = {}, - Op = Object.prototype, - hasOwn = Op.hasOwnProperty, - defineProperty = Object.defineProperty || function (obj, key, desc) { - obj[key] = desc.value; - }, - $Symbol = "function" == typeof Symbol ? Symbol : {}, - iteratorSymbol = $Symbol.iterator || "@@iterator", - asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", - toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; - function define(obj, key, value) { - return Object.defineProperty(obj, key, { - value: value, - enumerable: !0, - configurable: !0, - writable: !0 - }), obj[key]; - } - try { - define({}, ""); - } catch (err) { - define = function (obj, key, value) { - return obj[key] = value; - }; - } - function wrap(innerFn, outerFn, self, tryLocsList) { - var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, - generator = Object.create(protoGenerator.prototype), - context = new Context(tryLocsList || []); - return defineProperty(generator, "_invoke", { - value: makeInvokeMethod(innerFn, self, context) - }), generator; - } - function tryCatch(fn, obj, arg) { - try { - return { - type: "normal", - arg: fn.call(obj, arg) - }; - } catch (err) { - return { - type: "throw", - arg: err - }; - } - } - exports.wrap = wrap; - var ContinueSentinel = {}; - function Generator() {} - function GeneratorFunction() {} - function GeneratorFunctionPrototype() {} - var IteratorPrototype = {}; - define(IteratorPrototype, iteratorSymbol, function () { - return this; - }); - var getProto = Object.getPrototypeOf, - NativeIteratorPrototype = getProto && getProto(getProto(values([]))); - NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); - var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function (method) { - define(prototype, method, function (arg) { - return this._invoke(method, arg); - }); - }); - } - function AsyncIterator(generator, PromiseImpl) { - function invoke(method, arg, resolve, reject) { - var record = tryCatch(generator[method], generator, arg); - if ("throw" !== record.type) { - var result = record.arg, - value = result.value; - return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { - invoke("next", value, resolve, reject); - }, function (err) { - invoke("throw", err, resolve, reject); - }) : PromiseImpl.resolve(value).then(function (unwrapped) { - result.value = unwrapped, resolve(result); - }, function (error) { - return invoke("throw", error, resolve, reject); - }); - } - reject(record.arg); - } - var previousPromise; - defineProperty(this, "_invoke", { - value: function (method, arg) { - function callInvokeWithMethodAndArg() { - return new PromiseImpl(function (resolve, reject) { - invoke(method, arg, resolve, reject); - }); - } - return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); - } - }); - } - function makeInvokeMethod(innerFn, self, context) { - var state = "suspendedStart"; - return function (method, arg) { - if ("executing" === state) throw new Error("Generator is already running"); - if ("completed" === state) { - if ("throw" === method) throw arg; - return { - value: void 0, - done: !0 - }; - } - for (context.method = method, context.arg = arg;;) { - var delegate = context.delegate; - if (delegate) { - var delegateResult = maybeInvokeDelegate(delegate, context); - if (delegateResult) { - if (delegateResult === ContinueSentinel) continue; - return delegateResult; - } - } - if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { - if ("suspendedStart" === state) throw state = "completed", context.arg; - context.dispatchException(context.arg); - } else "return" === context.method && context.abrupt("return", context.arg); - state = "executing"; - var record = tryCatch(innerFn, self, context); - if ("normal" === record.type) { - if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; - return { - value: record.arg, - done: context.done - }; - } - "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); - } - }; - } - function maybeInvokeDelegate(delegate, context) { - var methodName = context.method, - method = delegate.iterator[methodName]; - if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; - var record = tryCatch(method, delegate.iterator, context.arg); - if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; - var info = record.arg; - return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); - } - function pushTryEntry(locs) { - var entry = { - tryLoc: locs[0] - }; - 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); - } - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal", delete record.arg, entry.completion = record; - } - function Context(tryLocsList) { - this.tryEntries = [{ - tryLoc: "root" - }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); - } - function values(iterable) { - if (iterable || "" === iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) return iteratorMethod.call(iterable); - if ("function" == typeof iterable.next) return iterable; - if (!isNaN(iterable.length)) { - var i = -1, - next = function next() { - for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; - return next.value = undefined, next.done = !0, next; - }; - return next.next = next; - } - } - throw new TypeError(typeof iterable + " is not iterable"); - } - return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { - value: GeneratorFunctionPrototype, - configurable: !0 - }), defineProperty(GeneratorFunctionPrototype, "constructor", { - value: GeneratorFunction, - configurable: !0 - }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { - var ctor = "function" == typeof genFun && genFun.constructor; - return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); - }, exports.mark = function (genFun) { - return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; - }, exports.awrap = function (arg) { - return { - __await: arg - }; - }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { - return this; - }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { - void 0 === PromiseImpl && (PromiseImpl = Promise); - var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); - return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { - return result.done ? result.value : iter.next(); - }); - }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { - return this; - }), define(Gp, "toString", function () { - return "[object Generator]"; - }), exports.keys = function (val) { - var object = Object(val), - keys = []; - for (var key in object) keys.push(key); - return keys.reverse(), function next() { - for (; keys.length;) { - var key = keys.pop(); - if (key in object) return next.value = key, next.done = !1, next; - } - return next.done = !0, next; - }; - }, exports.values = values, Context.prototype = { - constructor: Context, - reset: function (skipTempReset) { - if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); - }, - stop: function () { - this.done = !0; - var rootRecord = this.tryEntries[0].completion; - if ("throw" === rootRecord.type) throw rootRecord.arg; - return this.rval; - }, - dispatchException: function (exception) { - if (this.done) throw exception; - var context = this; - function handle(loc, caught) { - return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; - } - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i], - record = entry.completion; - if ("root" === entry.tryLoc) return handle("end"); - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"), - hasFinally = hasOwn.call(entry, "finallyLoc"); - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); - if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); - } else if (hasCatch) { - if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); - } else { - if (!hasFinally) throw new Error("try statement without catch or finally"); - if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); - } - } - } - }, - abrupt: function (type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; - } - } - finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); - var record = finallyEntry ? finallyEntry.completion : {}; - return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); - }, - complete: function (record, afterLoc) { - if ("throw" === record.type) throw record.arg; - return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; - }, - finish: function (finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; - } - }, - catch: function (tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc === tryLoc) { - var record = entry.completion; - if ("throw" === record.type) { - var thrown = record.arg; - resetTryEntry(entry); - } - return thrown; - } - } - throw new Error("illegal catch attempt"); - }, - delegateYield: function (iterable, resultName, nextLoc) { - return this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }, "next" === this.method && (this.arg = undefined), ContinueSentinel; - } - }, exports; - } - function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - if (info.done) { - resolve(value); - } else { - Promise.resolve(value).then(_next, _throw); - } - } - function _asyncToGenerator(fn) { - return function () { - var self = this, - args = arguments; - return new Promise(function (resolve, reject) { - var gen = fn.apply(self, args); - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - _next(undefined); - }); - }; - } - var wasm; - var cachedTextDecoder = new TextDecoder('utf-8', { - ignoreBOM: true, - fatal: true - }); - cachedTextDecoder.decode(); - var cachedUint8Memory0 = null; - function getUint8Memory0() { - if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { - cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8Memory0; - } - function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); - } - function load(_x, _x2) { - return _load.apply(this, arguments); - } - function _load() { - _load = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(module, imports) { - var bytes, instance; - return _regeneratorRuntime().wrap(function _callee$(_context) { - while (1) switch (_context.prev = _context.next) { - case 0: - if (!(typeof Response === 'function' && module instanceof Response)) { - _context.next = 23; - break; - } - if (!(typeof WebAssembly.instantiateStreaming === 'function')) { - _context.next = 15; - break; - } - _context.prev = 2; - _context.next = 5; - return WebAssembly.instantiateStreaming(module, imports); - case 5: - return _context.abrupt("return", _context.sent); - case 8: - _context.prev = 8; - _context.t0 = _context["catch"](2); - if (!(module.headers.get('Content-Type') != 'application/wasm')) { - _context.next = 14; - break; - } - console.warn("\`WebAssembly.instantiateStreaming\` failed because your server does not serve wasm with \`application/wasm\` MIME type. Falling back to \`WebAssembly.instantiate\` which is slower. Original error:\\n", _context.t0); - _context.next = 15; - break; - case 14: - throw _context.t0; - case 15: - _context.next = 17; - return module.arrayBuffer(); - case 17: - bytes = _context.sent; - _context.next = 20; - return WebAssembly.instantiate(bytes, imports); - case 20: - return _context.abrupt("return", _context.sent); - case 23: - _context.next = 25; - return WebAssembly.instantiate(module, imports); - case 25: - instance = _context.sent; - if (!(instance instanceof WebAssembly.Instance)) { - _context.next = 30; - break; - } - return _context.abrupt("return", { - instance: instance, - module: module - }); - case 30: - return _context.abrupt("return", instance); - case 31: - case "end": - return _context.stop(); - } - }, _callee, null, [[2, 8]]); - })); - return _load.apply(this, arguments); - } - function getImports() { - var imports = {}; - imports.wbg = {}; - imports.wbg.__wbg_alert_685e3cc61a9b8233 = function (arg0, arg1) { - alert(getStringFromWasm0(arg0, arg1)); - }; - return imports; - } - function finalizeInit(instance, module) { - wasm = instance.exports; - init.__wbindgen_wasm_module = module; - cachedUint8Memory0 = null; - return wasm; - } - function init(_x3) { - return _init.apply(this, arguments); - } - function _init() { - _init = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(input) { - var imports, _yield$load, instance, module$1; - return _regeneratorRuntime().wrap(function _callee2$(_context2) { - while (1) switch (_context2.prev = _context2.next) { - case 0: - if (typeof input === 'undefined') { - input = new URL('wasm_rust.wasm', module.meta.url); - } - imports = getImports(); - if (typeof input === 'string' || typeof Request === 'function' && input instanceof Request || typeof URL === 'function' && input instanceof URL) { - input = fetch(input); - } - _context2.t0 = load; - _context2.next = 7; - return input; - case 7: - _context2.t1 = _context2.sent; - _context2.t2 = imports; - _context2.next = 11; - return (0, _context2.t0)(_context2.t1, _context2.t2); - case 11: - _yield$load = _context2.sent; - instance = _yield$load.instance; - module$1 = _yield$load.module; - return _context2.abrupt("return", finalizeInit(instance, module$1)); - case 15: - case "end": - return _context2.stop(); - } - }, _callee2); - })); - return _init.apply(this, arguments); - } - - var isSupportWASM = function () { - try { - if (typeof WebAssembly === 'object' && typeof WebAssembly.instantiate === 'function') { - var module = new WebAssembly.Module(new Uint8Array([0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00])); - if (module instanceof WebAssembly.Module) { - return !!(new WebAssembly.Instance(module) instanceof WebAssembly.Instance); - } - } - } catch (e) { - return false; - } - return false; - }(); - - { - if (isSupportWASM) { - init(wasmUrl).then(function (inst) { - inst.greet(); - }); - } - } - - var Module = (() => { - var _scriptDir = module.meta.url; - - return ( - async function(Module = {}) { - - var Module=typeof Module!="undefined"?Module:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject;});var moduleOverrides=Object.assign({},Module);var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var read_,readAsync,readBinary;if(ENVIRONMENT_IS_NODE){const{createRequire:createRequire}=await module.import('module');var require=createRequire(module.meta.url);var fs=require("fs");var nodePath=require("path");if(ENVIRONMENT_IS_WORKER){scriptDirectory=nodePath.dirname(scriptDirectory)+"/";}else {scriptDirectory=require("url").fileURLToPath(new URL("./",module.meta.url));}read_=(filename,binary)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read_(filename,true);if(!ret.buffer){ret=new Uint8Array(ret);}return ret};readAsync=(filename,onload,onerror)=>{filename=isFileURI(filename)?new URL(filename):nodePath.normalize(filename);fs.readFile(filename,function(err,data){if(err)onerror(err);else onload(data.buffer);});};if(!Module["thisProgram"]&&process.argv.length>1){process.argv[1].replace(/\\\\/g,"/");}process.argv.slice(2);Module["inspect"]=function(){return "[Emscripten Module object]"};}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href;}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src;}if(_scriptDir){scriptDirectory=_scriptDir;}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1);}else {scriptDirectory="";}{read_=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)};}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror();};xhr.onerror=onerror;xhr.send(null);};}}else;var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])Module["arguments"];if(Module["thisProgram"])Module["thisProgram"];if(Module["quit"])Module["quit"];var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];Module["noExitRuntime"]||true;var WebAssembly={Memory:function(opts){this.buffer=new ArrayBuffer(opts["initial"]*65536);},Module:function(binary){},Instance:function(module,info){this.exports=( - // EMSCRIPTEN_START_ASM - function instantiate(G){function c(d){d.set=function(a,b){this[a]=b;};d.get=function(a){return this[a]};return d}function E(F){var e=F.a;var f=e.a;var g=f.buffer;var h=new Int8Array(g);var j=new Int32Array(g);var k=new Uint8Array(g);var z=e.b;var A=e.c;var B=67760; - // EMSCRIPTEN_START_FUNCS - function H(a){var b=0,c=0,d=0,e=0,f=0,g=0;c=1024;d=j[264];a:{if(!d){if(I()){break a}d=j[264];}b=d;d=j[265];if(b-d>>>0>>0){return C[j[269]](1040,1024,a)|0}b:{if(j[280]<0){break b}b=a;while(1){e=b;if(!b){e=0;break b}b=e-1|0;if(k[b+1024|0]!=10){continue}break}b=C[j[269]](1040,1024,e)|0;if(e>>>0>b>>>0){break a}c=e+1024|0;a=a-e|0;d=j[265];}b=d;c:{if(a>>>0>=512){A(b|0,c|0,a|0);break c}f=a+b|0;d:{if(!((b^c)&3)){e:{if(!(b&3)|!a){break e}while(1){h[b|0]=k[c|0];c=c+1|0;b=b+1|0;if(!(b&3)){break e}if(b>>>0>>0){continue}break}}g=f&-4;f:{if(g>>>0<64){break f}d=g+-64|0;if(d>>>0>>0){break f}while(1){j[b>>2]=j[c>>2];j[b+4>>2]=j[c+4>>2];j[b+8>>2]=j[c+8>>2];j[b+12>>2]=j[c+12>>2];j[b+16>>2]=j[c+16>>2];j[b+20>>2]=j[c+20>>2];j[b+24>>2]=j[c+24>>2];j[b+28>>2]=j[c+28>>2];j[b+32>>2]=j[c+32>>2];j[b+36>>2]=j[c+36>>2];j[b+40>>2]=j[c+40>>2];j[b+44>>2]=j[c+44>>2];j[b+48>>2]=j[c+48>>2];j[b+52>>2]=j[c+52>>2];j[b+56>>2]=j[c+56>>2];j[b+60>>2]=j[c+60>>2];c=c- -64|0;b=b- -64|0;if(d>>>0>=b>>>0){continue}break}}if(b>>>0>=g>>>0){break d}while(1){j[b>>2]=j[c>>2];c=c+4|0;b=b+4|0;if(g>>>0>b>>>0){continue}break}break d}if(f>>>0<4){break d}d=f-4|0;if(d>>>0>>0){break d}while(1){h[b|0]=k[c|0];h[b+1|0]=k[c+1|0];h[b+2|0]=k[c+2|0];h[b+3|0]=k[c+3|0];c=c+4|0;b=b+4|0;if(d>>>0>=b>>>0){continue}break}}if(b>>>0>>0){while(1){h[b|0]=k[c|0];c=c+1|0;b=b+1|0;if((f|0)!=(b|0)){continue}break}}}j[265]=j[265]+a;b=a+e|0;}return b}function O(a,b,c){a=a|0;b=b|0;c=c|0;var d=0,e=0,f=0,g=0,h=0,i=0,k=0;f=B-32|0;B=f;d=j[a+28>>2];j[f+16>>2]=d;g=j[a+20>>2];j[f+28>>2]=c;j[f+24>>2]=b;b=g-d|0;j[f+20>>2]=b;g=b+c|0;i=2;a:{b:{b=f+16|0;d=z(j[a+60>>2],b|0,2,f+12|0)|0;if(d){j[554]=d;d=-1;}else {d=0;}c:{d:{if(d){d=b;break d}while(1){e=j[f+12>>2];if((e|0)==(g|0)){break c}if((e|0)<0){d=b;break b}h=j[b+4>>2];k=h>>>0>>0;d=(k<<3)+b|0;h=e-(k?h:0)|0;j[d>>2]=h+j[d>>2];b=(k?12:4)+b|0;j[b>>2]=j[b>>2]-h;g=g-e|0;b=d;i=i-k|0;e=z(j[a+60>>2],b|0,i|0,f+12|0)|0;if(e){j[554]=e;e=-1;}else {e=0;}if(!e){continue}break}}if((g|0)!=-1){break b}}b=j[a+44>>2];j[a+28>>2]=b;j[a+20>>2]=b;j[a+16>>2]=b+j[a+48>>2];a=c;break a}j[a+28>>2]=0;j[a+16>>2]=0;j[a+20>>2]=0;j[a>>2]=j[a>>2]|32;a=0;if((i|0)==2){break a}a=c-j[d+4>>2]|0;}B=f+32|0;return a|0}function Q(){var a=0,b=0,c=0;b=1024;while(1){a=b;b=a+4|0;c=j[a>>2];if(!((c^-1)&c-16843009&-2139062144)){continue}break}while(1){b=a;a=a+1|0;if(k[b|0]){continue}break}c=b-1024|0;a=c;a:{if(j[279]<0){b=H(a);break a}b=H(a);}if((a|0)!=(b|0)){a=b;}b:{if((((a|0)!=(c|0)?-1:0)|0)<0){break b}c:{if(j[280]==10){break c}a=j[265];if((a|0)==j[264]){break c}j[265]=a+1;h[a|0]=10;break b}b=B-16|0;B=b;h[b+15|0]=10;a=j[264];d:{if(!a){if(I()){break d}a=j[264];}c=a;a=j[265];if(!((c|0)==(a|0)|j[280]==10)){j[265]=a+1;h[a|0]=10;break d}if((C[j[269]](1040,b+15|0,1)|0)!=1){break d}}B=b+16|0;}return 0} - function I(){var a=0;a=j[278];j[278]=a-1|a;a=j[260];if(a&8){j[260]=a|32;return -1}j[261]=0;j[262]=0;a=j[271];j[267]=a;j[265]=a;j[264]=a+j[272];return 0}function M(a,b,c,d){return 0}function P(a){a=a|0;a=B-a&-16;B=a;return a|0}function N(a){return 0}function L(){return B|0}function K(a){a=a|0;B=a;}function J(){} - // EMSCRIPTEN_END_FUNCS - var C=c([null,N,O,M]);return {"d":J,"e":Q,"f":C,"g":L,"h":K,"i":P}}return E(G)} - // EMSCRIPTEN_END_ASM - - - )(info);},instantiate:function(binary,info){return {then:function(ok){var module=new WebAssembly.Module(binary);ok({"instance":new WebAssembly.Instance(module,info)});}}},RuntimeError:Error};wasmBinary=[];if(typeof WebAssembly!="object"){abort("no native wasm support detected");}var wasmMemory;var ABORT=false;function assert(condition,text){if(!condition){abort(text);}}var HEAP8,HEAPU8,HEAPU32;function updateMemoryViews(){var b=wasmMemory.buffer;Module["HEAP8"]=HEAP8=new Int8Array(b);Module["HEAP16"]=new Int16Array(b);Module["HEAP32"]=new Int32Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);Module["HEAPU16"]=new Uint16Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);Module["HEAPF32"]=new Float32Array(b);Module["HEAPF64"]=new Float64Array(b);}var INITIAL_MEMORY=Module["INITIAL_MEMORY"]||16777216;assert(INITIAL_MEMORY>=65536,"INITIAL_MEMORY should be larger than STACK_SIZE, was "+INITIAL_MEMORY+"! (STACK_SIZE="+65536+")");if(Module["wasmMemory"]){wasmMemory=Module["wasmMemory"];}else {wasmMemory=new WebAssembly.Memory({"initial":INITIAL_MEMORY/65536,"maximum":INITIAL_MEMORY/65536});}updateMemoryViews();INITIAL_MEMORY=wasmMemory.buffer.byteLength;var __ATPRERUN__=[];var __ATINIT__=[];var __ATPOSTRUN__=[];function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift());}}callRuntimeCallbacks(__ATPRERUN__);}function initRuntime(){callRuntimeCallbacks(__ATINIT__);}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift());}}callRuntimeCallbacks(__ATPOSTRUN__);}function addOnPreRun(cb){__ATPRERUN__.unshift(cb);}function addOnInit(cb){__ATINIT__.unshift(cb);}function addOnPostRun(cb){__ATPOSTRUN__.unshift(cb);}var runDependencies=0;var dependenciesFulfilled=null;function addRunDependency(id){runDependencies++;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies);}}function removeRunDependency(id){runDependencies--;if(Module["monitorRunDependencies"]){Module["monitorRunDependencies"](runDependencies);}if(runDependencies==0){if(dependenciesFulfilled){var callback=dependenciesFulfilled;dependenciesFulfilled=null;callback();}}}function abort(what){if(Module["onAbort"]){Module["onAbort"](what);}what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject(e);throw e}var dataURIPrefix="data:application/octet-stream;base64,";function isDataURI(filename){return filename.startsWith(dataURIPrefix)}function isFileURI(filename){return filename.startsWith("file://")}var wasmBinaryFile;if(Module["locateFile"]){wasmBinaryFile="wasm_c.asm.wasm";if(!isDataURI(wasmBinaryFile)){wasmBinaryFile=locateFile(wasmBinaryFile);}}else {wasmBinaryFile=new URL("wasm_c.asm.wasm",module.meta.url).href;}function getBinary(file){try{if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw "both async and sync fetching of the wasm failed"}catch(err){abort(err);}}function getBinaryPromise(binaryFile){if(!wasmBinary&&(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER)){if(typeof fetch=="function"&&!isFileURI(binaryFile)){return fetch(binaryFile,{credentials:"same-origin"}).then(function(response){if(!response["ok"]){throw "failed to load wasm binary file at '"+binaryFile+"'"}return response["arrayBuffer"]()}).catch(function(){return getBinary(binaryFile)})}else {if(readAsync){return new Promise(function(resolve,reject){readAsync(binaryFile,function(response){resolve(new Uint8Array(response));},reject);})}}}return Promise.resolve().then(function(){return getBinary(binaryFile)})}function instantiateArrayBuffer(binaryFile,imports,receiver){return getBinaryPromise(binaryFile).then(function(binary){return WebAssembly.instantiate(binary,imports)}).then(function(instance){return instance}).then(receiver,function(reason){err("failed to asynchronously prepare wasm: "+reason);abort(reason);})}function instantiateAsync(binary,binaryFile,imports,callback){if(!binary&&typeof WebAssembly.instantiateStreaming=="function"&&!isDataURI(binaryFile)&&!isFileURI(binaryFile)&&!ENVIRONMENT_IS_NODE&&typeof fetch=="function"){return fetch(binaryFile,{credentials:"same-origin"}).then(function(response){var result=WebAssembly.instantiateStreaming(response,imports);return result.then(callback,function(reason){err("wasm streaming compile failed: "+reason);err("falling back to ArrayBuffer instantiation");return instantiateArrayBuffer(binaryFile,imports,callback)})})}else {return instantiateArrayBuffer(binaryFile,imports,callback)}}function createWasm(){var info={"a":wasmImports};function receiveInstance(instance,module){var exports=instance.exports;Module["asm"]=exports;runMemoryInitializer();Module["asm"]["f"];addOnInit(Module["asm"]["d"]);removeRunDependency();return exports}addRunDependency();function receiveInstantiationResult(result){receiveInstance(result["instance"]);}if(Module["instantiateWasm"]){try{return Module["instantiateWasm"](info,receiveInstance)}catch(e){err("Module.instantiateWasm callback failed with error: "+e);readyPromiseReject(e);}}instantiateAsync(wasmBinary,wasmBinaryFile,info,receiveInstantiationResult).catch(readyPromiseReject);return {}}var memoryInitializer="wasm_c.asm.js.mem";function runMemoryInitializer(){if(!isDataURI(memoryInitializer)){memoryInitializer=locateFile(memoryInitializer);}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=readBinary(memoryInitializer);HEAPU8.set(data,1024);}else {addRunDependency();var applyMemoryInitializer=data=>{if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,1024);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency();};var doBrowserLoad=()=>{readAsync(memoryInitializer,applyMemoryInitializer,function(){var e=new Error("could not load memory initializer "+memoryInitializer);readyPromiseReject(e);});};if(Module["memoryInitializerRequest"]){var useRequest=()=>{var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}applyMemoryInitializer(response);};if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0);}else {Module["memoryInitializerRequest"].addEventListener("load",useRequest);}}else {doBrowserLoad();}}}function callRuntimeCallbacks(callbacks){while(callbacks.length>0){callbacks.shift()(Module);}}function _emscripten_memcpy_big(dest,src,num){HEAPU8.copyWithin(dest,src,src+num);}var printCharBuffers=[null,[],[]];var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx>10,56320|ch&1023);}}return str}function printChar(stream,curr){var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer,0));buffer.length=0;}else {buffer.push(curr);}}function UTF8ToString(ptr,maxBytesToRead){return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function _fd_write(fd,iov,iovcnt,pnum){var num=0;for(var i=0;i>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j>2]=num;return 0}function getCFunc(ident){var func=Module["_"+ident];return func}function writeArrayToMemory(array,buffer){HEAP8.set(array,buffer);}function lengthBytesUTF8(str){var len=0;for(var i=0;i=55296&&c<=57343){len+=4;++i;}else {len+=3;}}return len}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023;}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++]=u;}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++]=192|u>>6;heap[outIdx++]=128|u&63;}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++]=224|u>>12;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;}else {if(outIdx+3>=endIdx)break;heap[outIdx++]=240|u>>18;heap[outIdx++]=128|u>>12&63;heap[outIdx++]=128|u>>6&63;heap[outIdx++]=128|u&63;}}heap[outIdx]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function stringToUTF8OnStack(str){var size=lengthBytesUTF8(str)+1;var ret=stackAlloc(size);stringToUTF8(str,ret,size);return ret}function ccall(ident,returnType,argTypes,args,opts){var toC={"string":str=>{var ret=0;if(str!==null&&str!==undefined&&str!==0){ret=stringToUTF8OnStack(str);}return ret},"array":arr=>{var ret=stackAlloc(arr.length);writeArrayToMemory(arr,ret);return ret}};function convertReturnValue(ret){if(returnType==="string"){return UTF8ToString(ret)}if(returnType==="boolean")return Boolean(ret);return ret}var func=getCFunc(ident);var cArgs=[];var stack=0;if(args){for(var i=0;itype==="number"||type==="boolean");var numericRet=returnType!=="string";if(numericRet&&numericArgs&&!opts){return getCFunc(ident)}return function(){return ccall(ident,returnType,argTypes,arguments)}}var wasmImports={"c":_emscripten_memcpy_big,"b":_fd_write,"a":wasmMemory};createWasm();Module["_hello"]=function(){return (Module["_hello"]=Module["asm"]["e"]).apply(null,arguments)};var stackSave=function(){return (stackSave=Module["asm"]["g"]).apply(null,arguments)};var stackRestore=function(){return (stackRestore=Module["asm"]["h"]).apply(null,arguments)};var stackAlloc=function(){return (stackAlloc=Module["asm"]["i"]).apply(null,arguments)};Module["ccall"]=ccall;Module["cwrap"]=cwrap;var calledRun;dependenciesFulfilled=function runCaller(){if(!calledRun)run();if(!calledRun)dependenciesFulfilled=runCaller;};function run(){if(runDependencies>0){return}preRun();if(runDependencies>0){return}function doRun(){if(calledRun)return;calledRun=true;Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve(Module);if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();postRun();}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(function(){setTimeout(function(){Module["setStatus"]("");},1);doRun();},1);}else {doRun();}}if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].pop()();}}run(); - - - return Module.ready - } - - ); - })(); - - var asmJsMemUrl = 'assets/wasm_c.js.mem-429cc1f7.bin'; /* asset-hash:2cbb215d */ - - function initializeWasm() { - return new Promise(function (resolve, reject) { - { - Promise.all([module.import('./wasm_c.wasm-a82df3d4.js'), module.import('./wasm_c.wasm.fallback-721977f8.js')]).then(function (_ref) { - var wasmFallbackUrl = _ref[0]["default"], - wasmFallbackFactory = _ref[1]["default"]; - return wasmFallbackFactory({ - locateFile: function locateFile(_) { - return wasmFallbackUrl; - } - }).then(function (inst) { - resolve(inst); - })["catch"](reject); - }); - return; - } - }); - } - function initializeAsm() { - return new Promise(function (resolve, reject) { - Module({ - memoryInitializerRequest: { - response: asmJsMemUrl, - status: 200 - } - }).then(function (inst) { - resolve(inst); - })["catch"](reject); - }); - } - { - if (isSupportWASM) { - initializeWasm().then(function (inst) { - inst._hello(); - }); - } else { - initializeAsm().then(function (inst) { - inst._hello(); - }); - } - } - - }) - }; + }) + }; })); " `; exports[`engine-js build WASM module on platform maybe supporting WASM: cull asm.js module 1`] = ` [ + "_virtual_cc-aa67b7c2.js", "assets/wasm_c-8515ca89.wasm", - "assets/wasm_c.wasm.fallback-26103d05.bin", "assets/wasm_rust-404aff2f.wasm", "cc.js", - "wasm_c.wasm-a82df3d4.js", - "wasm_c.wasm.fallback-721977f8.js", + "wasm_c-a7853123.js", + "wasm_c.wasm-12bb28a2.js", ] `; @@ -771,1664 +188,38 @@ exports[`engine-js build WASM module on platform not supporting WASM: cull asm.j exports[`engine-js build WASM module on platform supporting WASM 1`] = ` [ + "_virtual_cc-557f4653.js", "assets/wasm_c-8515ca89.wasm", "assets/wasm_rust-404aff2f.wasm", "cc.js", + "wasm_c-a7853123.js", + "wasm_c.wasm-d6fe14a1.js", ] `; exports[`engine-js build WASM module on platform supporting WASM 2`] = ` -"System.register([], (function (exports, module) { - 'use strict'; - return { - execute: (function () { +"System.register(['./_virtual_cc-557f4653.js'], (function () { + 'use strict'; + return { + setters: [function () {}], + execute: (function () { - function tryDefineGlobal (name, value) { - const _global = typeof window === 'undefined' ? global : window; - if (typeof _global[name] === 'undefined') { - return (_global[name] = value); - } else { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return _global[name]; - } - } - tryDefineGlobal('CC_WECHAT', true); - tryDefineGlobal('CC_BAIDU', false); - tryDefineGlobal('CC_XIAOMI', false); - tryDefineGlobal('CC_ALIPAY', false); - tryDefineGlobal('CC_BYTEDANCE', false); - tryDefineGlobal('CC_OPPO', false); - tryDefineGlobal('CC_VIVO', false); - tryDefineGlobal('CC_HUAWEI', false); - tryDefineGlobal('CC_COCOSPLAY', false); - tryDefineGlobal('CC_QTT', false); - tryDefineGlobal('CC_LINKSURE', false); - tryDefineGlobal('CC_EDITOR', false); - tryDefineGlobal('CC_PREVIEW', false); - tryDefineGlobal('CC_BUILD', true); - tryDefineGlobal('CC_TEST', false); - tryDefineGlobal('CC_DEBUG', true); - tryDefineGlobal('CC_DEV', false); - tryDefineGlobal('CC_MINIGAME', true); - tryDefineGlobal('CC_RUNTIME_BASED', false); - tryDefineGlobal('CC_SUPPORT_JIT', false); - tryDefineGlobal('CC_JSB', false); - - var wasmUrl$1 = 'assets/wasm_rust-404aff2f.wasm'; /* asset-hash:829fe457 */ - - function _regeneratorRuntime() { - _regeneratorRuntime = function () { - return exports; - }; - var exports = {}, - Op = Object.prototype, - hasOwn = Op.hasOwnProperty, - defineProperty = Object.defineProperty || function (obj, key, desc) { - obj[key] = desc.value; - }, - $Symbol = "function" == typeof Symbol ? Symbol : {}, - iteratorSymbol = $Symbol.iterator || "@@iterator", - asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", - toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; - function define(obj, key, value) { - return Object.defineProperty(obj, key, { - value: value, - enumerable: !0, - configurable: !0, - writable: !0 - }), obj[key]; - } - try { - define({}, ""); - } catch (err) { - define = function (obj, key, value) { - return obj[key] = value; - }; - } - function wrap(innerFn, outerFn, self, tryLocsList) { - var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, - generator = Object.create(protoGenerator.prototype), - context = new Context(tryLocsList || []); - return defineProperty(generator, "_invoke", { - value: makeInvokeMethod(innerFn, self, context) - }), generator; - } - function tryCatch(fn, obj, arg) { - try { - return { - type: "normal", - arg: fn.call(obj, arg) - }; - } catch (err) { - return { - type: "throw", - arg: err - }; - } - } - exports.wrap = wrap; - var ContinueSentinel = {}; - function Generator() {} - function GeneratorFunction() {} - function GeneratorFunctionPrototype() {} - var IteratorPrototype = {}; - define(IteratorPrototype, iteratorSymbol, function () { - return this; - }); - var getProto = Object.getPrototypeOf, - NativeIteratorPrototype = getProto && getProto(getProto(values([]))); - NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); - var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); - function defineIteratorMethods(prototype) { - ["next", "throw", "return"].forEach(function (method) { - define(prototype, method, function (arg) { - return this._invoke(method, arg); - }); - }); - } - function AsyncIterator(generator, PromiseImpl) { - function invoke(method, arg, resolve, reject) { - var record = tryCatch(generator[method], generator, arg); - if ("throw" !== record.type) { - var result = record.arg, - value = result.value; - return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { - invoke("next", value, resolve, reject); - }, function (err) { - invoke("throw", err, resolve, reject); - }) : PromiseImpl.resolve(value).then(function (unwrapped) { - result.value = unwrapped, resolve(result); - }, function (error) { - return invoke("throw", error, resolve, reject); - }); - } - reject(record.arg); - } - var previousPromise; - defineProperty(this, "_invoke", { - value: function (method, arg) { - function callInvokeWithMethodAndArg() { - return new PromiseImpl(function (resolve, reject) { - invoke(method, arg, resolve, reject); - }); - } - return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); - } - }); - } - function makeInvokeMethod(innerFn, self, context) { - var state = "suspendedStart"; - return function (method, arg) { - if ("executing" === state) throw new Error("Generator is already running"); - if ("completed" === state) { - if ("throw" === method) throw arg; - return { - value: void 0, - done: !0 - }; - } - for (context.method = method, context.arg = arg;;) { - var delegate = context.delegate; - if (delegate) { - var delegateResult = maybeInvokeDelegate(delegate, context); - if (delegateResult) { - if (delegateResult === ContinueSentinel) continue; - return delegateResult; - } - } - if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { - if ("suspendedStart" === state) throw state = "completed", context.arg; - context.dispatchException(context.arg); - } else "return" === context.method && context.abrupt("return", context.arg); - state = "executing"; - var record = tryCatch(innerFn, self, context); - if ("normal" === record.type) { - if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; - return { - value: record.arg, - done: context.done - }; - } - "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); - } - }; - } - function maybeInvokeDelegate(delegate, context) { - var methodName = context.method, - method = delegate.iterator[methodName]; - if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; - var record = tryCatch(method, delegate.iterator, context.arg); - if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; - var info = record.arg; - return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); - } - function pushTryEntry(locs) { - var entry = { - tryLoc: locs[0] - }; - 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); - } - function resetTryEntry(entry) { - var record = entry.completion || {}; - record.type = "normal", delete record.arg, entry.completion = record; - } - function Context(tryLocsList) { - this.tryEntries = [{ - tryLoc: "root" - }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); - } - function values(iterable) { - if (iterable || "" === iterable) { - var iteratorMethod = iterable[iteratorSymbol]; - if (iteratorMethod) return iteratorMethod.call(iterable); - if ("function" == typeof iterable.next) return iterable; - if (!isNaN(iterable.length)) { - var i = -1, - next = function next() { - for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; - return next.value = undefined, next.done = !0, next; - }; - return next.next = next; - } - } - throw new TypeError(typeof iterable + " is not iterable"); - } - return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { - value: GeneratorFunctionPrototype, - configurable: !0 - }), defineProperty(GeneratorFunctionPrototype, "constructor", { - value: GeneratorFunction, - configurable: !0 - }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { - var ctor = "function" == typeof genFun && genFun.constructor; - return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); - }, exports.mark = function (genFun) { - return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; - }, exports.awrap = function (arg) { - return { - __await: arg - }; - }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { - return this; - }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { - void 0 === PromiseImpl && (PromiseImpl = Promise); - var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); - return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { - return result.done ? result.value : iter.next(); - }); - }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { - return this; - }), define(Gp, "toString", function () { - return "[object Generator]"; - }), exports.keys = function (val) { - var object = Object(val), - keys = []; - for (var key in object) keys.push(key); - return keys.reverse(), function next() { - for (; keys.length;) { - var key = keys.pop(); - if (key in object) return next.value = key, next.done = !1, next; - } - return next.done = !0, next; - }; - }, exports.values = values, Context.prototype = { - constructor: Context, - reset: function (skipTempReset) { - if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); - }, - stop: function () { - this.done = !0; - var rootRecord = this.tryEntries[0].completion; - if ("throw" === rootRecord.type) throw rootRecord.arg; - return this.rval; - }, - dispatchException: function (exception) { - if (this.done) throw exception; - var context = this; - function handle(loc, caught) { - return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; - } - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i], - record = entry.completion; - if ("root" === entry.tryLoc) return handle("end"); - if (entry.tryLoc <= this.prev) { - var hasCatch = hasOwn.call(entry, "catchLoc"), - hasFinally = hasOwn.call(entry, "finallyLoc"); - if (hasCatch && hasFinally) { - if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); - if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); - } else if (hasCatch) { - if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); - } else { - if (!hasFinally) throw new Error("try statement without catch or finally"); - if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); - } - } - } - }, - abrupt: function (type, arg) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { - var finallyEntry = entry; - break; - } - } - finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); - var record = finallyEntry ? finallyEntry.completion : {}; - return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); - }, - complete: function (record, afterLoc) { - if ("throw" === record.type) throw record.arg; - return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; - }, - finish: function (finallyLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; - } - }, - catch: function (tryLoc) { - for (var i = this.tryEntries.length - 1; i >= 0; --i) { - var entry = this.tryEntries[i]; - if (entry.tryLoc === tryLoc) { - var record = entry.completion; - if ("throw" === record.type) { - var thrown = record.arg; - resetTryEntry(entry); - } - return thrown; - } - } - throw new Error("illegal catch attempt"); - }, - delegateYield: function (iterable, resultName, nextLoc) { - return this.delegate = { - iterator: values(iterable), - resultName: resultName, - nextLoc: nextLoc - }, "next" === this.method && (this.arg = undefined), ContinueSentinel; - } - }, exports; - } - function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - if (info.done) { - resolve(value); - } else { - Promise.resolve(value).then(_next, _throw); - } - } - function _asyncToGenerator(fn) { - return function () { - var self = this, - args = arguments; - return new Promise(function (resolve, reject) { - var gen = fn.apply(self, args); - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - _next(undefined); - }); - }; - } - - var wasm; - var cachedTextDecoder = new TextDecoder('utf-8', { - ignoreBOM: true, - fatal: true - }); - cachedTextDecoder.decode(); - var cachedUint8Memory0 = null; - function getUint8Memory0() { - if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { - cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8Memory0; - } - function getStringFromWasm0(ptr, len) { - return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); - } - function load(_x, _x2) { - return _load.apply(this, arguments); - } - function _load() { - _load = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(module, imports) { - var bytes, instance; - return _regeneratorRuntime().wrap(function _callee$(_context) { - while (1) switch (_context.prev = _context.next) { - case 0: - if (!(typeof Response === 'function' && module instanceof Response)) { - _context.next = 23; - break; - } - if (!(typeof WebAssembly.instantiateStreaming === 'function')) { - _context.next = 15; - break; - } - _context.prev = 2; - _context.next = 5; - return WebAssembly.instantiateStreaming(module, imports); - case 5: - return _context.abrupt("return", _context.sent); - case 8: - _context.prev = 8; - _context.t0 = _context["catch"](2); - if (!(module.headers.get('Content-Type') != 'application/wasm')) { - _context.next = 14; - break; - } - console.warn("\`WebAssembly.instantiateStreaming\` failed because your server does not serve wasm with \`application/wasm\` MIME type. Falling back to \`WebAssembly.instantiate\` which is slower. Original error:\\n", _context.t0); - _context.next = 15; - break; - case 14: - throw _context.t0; - case 15: - _context.next = 17; - return module.arrayBuffer(); - case 17: - bytes = _context.sent; - _context.next = 20; - return WebAssembly.instantiate(bytes, imports); - case 20: - return _context.abrupt("return", _context.sent); - case 23: - _context.next = 25; - return WebAssembly.instantiate(module, imports); - case 25: - instance = _context.sent; - if (!(instance instanceof WebAssembly.Instance)) { - _context.next = 30; - break; - } - return _context.abrupt("return", { - instance: instance, - module: module - }); - case 30: - return _context.abrupt("return", instance); - case 31: - case "end": - return _context.stop(); - } - }, _callee, null, [[2, 8]]); - })); - return _load.apply(this, arguments); - } - function getImports() { - var imports = {}; - imports.wbg = {}; - imports.wbg.__wbg_alert_685e3cc61a9b8233 = function (arg0, arg1) { - alert(getStringFromWasm0(arg0, arg1)); - }; - return imports; - } - function finalizeInit(instance, module) { - wasm = instance.exports; - init.__wbindgen_wasm_module = module; - cachedUint8Memory0 = null; - return wasm; - } - function init(_x3) { - return _init.apply(this, arguments); - } - function _init() { - _init = _asyncToGenerator(_regeneratorRuntime().mark(function _callee2(input) { - var imports, _yield$load, instance, module$1; - return _regeneratorRuntime().wrap(function _callee2$(_context2) { - while (1) switch (_context2.prev = _context2.next) { - case 0: - if (typeof input === 'undefined') { - input = new URL('wasm_rust.wasm', module.meta.url); - } - imports = getImports(); - if (typeof input === 'string' || typeof Request === 'function' && input instanceof Request || typeof URL === 'function' && input instanceof URL) { - input = fetch(input); - } - _context2.t0 = load; - _context2.next = 7; - return input; - case 7: - _context2.t1 = _context2.sent; - _context2.t2 = imports; - _context2.next = 11; - return (0, _context2.t0)(_context2.t1, _context2.t2); - case 11: - _yield$load = _context2.sent; - instance = _yield$load.instance; - module$1 = _yield$load.module; - return _context2.abrupt("return", finalizeInit(instance, module$1)); - case 15: - case "end": - return _context2.stop(); - } - }, _callee2); - })); - return _init.apply(this, arguments); - } - - (function () { - try { - if (typeof WebAssembly === 'object' && typeof WebAssembly.instantiate === 'function') { - var module = new WebAssembly.Module(new Uint8Array([0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00])); - if (module instanceof WebAssembly.Module) { - return !!(new WebAssembly.Instance(module) instanceof WebAssembly.Instance); - } - } - } catch (e) { - return false; - } - return false; - })(); - { - init(wasmUrl$1).then(function (inst) { - inst.greet(); - }); - } - - var wasmUrl = 'assets/wasm_c-8515ca89.wasm'; /* asset-hash:5994068c */ - - var Module = function () { - var _scriptDir = module.meta.url; - return function (Module) { - try { - var _arguments = arguments; - if (Module === void 0) { - Module = {}; - } - return function () { - var _ref = _asyncToGenerator(_regeneratorRuntime().mark(function _callee(Module) { - var readyPromiseResolve, readyPromiseReject, moduleOverrides, arguments_, thisProgram, quit_, ENVIRONMENT_IS_WEB, ENVIRONMENT_IS_WORKER, ENVIRONMENT_IS_NODE, ENVIRONMENT_IS_SHELL, scriptDirectory, locateFile, read_, readAsync, readBinary, setWindowTitle, nodeVersion, numericVersion, minVersion, _yield$import, createRequire, require, fs, nodePath, out, err, IDBFS, PROXYFS, WORKERFS, NODEFS, wasmBinary, noExitRuntime, wasmMemory, ABORT, EXITSTATUS, assert, _malloc, _free, HEAP, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64, updateMemoryViews, wasmTable, writeStackCookie, checkStackCookie, __ATPRERUN__, __ATINIT__, __ATEXIT__, __ATPOSTRUN__, runtimeInitialized, runtimeKeepaliveCounter, keepRuntimeAlive, preRun, initRuntime, postRun, addOnPreRun, addOnInit, addOnExit, addOnPostRun, runDependencies, runDependencyWatcher, dependenciesFulfilled, runDependencyTracking, getUniqueRunDependency, addRunDependency, removeRunDependency, abort, FS, dataURIPrefix, isDataURI, isFileURI, createExportWrapper, wasmBinaryFile, getBinary, getBinaryPromise, instantiateArrayBuffer, instantiateAsync, createWasm, tempDouble, tempI64, legacyModuleProp, ignoredModuleProp, isExportedByForceFilesystem, missingGlobal, missingLibrarySymbol, unexportedRuntimeSymbol, dbg, ExitStatus, callRuntimeCallbacks, getValue, ptrToString, setValue, warnOnce, _emscripten_memcpy_big, printCharBuffers, UTF8Decoder, UTF8ArrayToString, printChar, flush_NO_FILESYSTEM, UTF8ToString, SYSCALLS, _fd_write, getCFunc, writeArrayToMemory, lengthBytesUTF8, stringToUTF8Array, stringToUTF8, stringToUTF8OnStack, ccall, cwrap, checkIncomingModuleAPI, wasmImports, asm, ___wasm_call_ctors, _hello, ___errno_location, _fflush, _emscripten_stack_init2, _emscripten_stack_get_free2, _emscripten_stack_get_base2, _emscripten_stack_get_end2, stackSave, stackRestore, stackAlloc, _emscripten_stack_get_current2, dynCall_jiji, missingLibrarySymbols, unexportedSymbols, calledRun, stackCheckInit, run, checkUnflushedContent; - return _regeneratorRuntime().wrap(function _callee$(_context) { - while (1) switch (_context.prev = _context.next) { - case 0: - checkUnflushedContent = function _checkUnflushedConten() { - var oldOut = out; - var oldErr = err; - var has = false; - out = err = function err(x) { - has = true; - }; - try { - flush_NO_FILESYSTEM(); - } catch (e) {} - out = oldOut; - err = oldErr; - if (has) { - warnOnce('stdio streams had content in them that was not flushed. you should set EXIT_RUNTIME to 1 (see the FAQ), or make sure to emit a newline when you printf etc.'); - warnOnce('(this may also be due to not including full filesystem support - try building with -sFORCE_FILESYSTEM)'); - } - }; - run = function _run() { - if (runDependencies > 0) { - return; - } - stackCheckInit(); - preRun(); - if (runDependencies > 0) { - return; - } - function doRun() { - if (calledRun) return; - calledRun = true; - Module['calledRun'] = true; - if (ABORT) return; - initRuntime(); - readyPromiseResolve(Module); - if (Module['onRuntimeInitialized']) Module['onRuntimeInitialized'](); - assert(!Module['_main'], 'compiled without a main, but one is present. if you added it from JS, use Module["onRuntimeInitialized"]'); - postRun(); - } - if (Module['setStatus']) { - Module['setStatus']('Running...'); - setTimeout(function () { - setTimeout(function () { - Module['setStatus'](''); - }, 1); - doRun(); - }, 1); - } else { - doRun(); - } - checkStackCookie(); - }; - stackCheckInit = function _stackCheckInit() { - _emscripten_stack_init2(); - writeStackCookie(); - }; - checkIncomingModuleAPI = function _checkIncomingModuleA() { - ignoredModuleProp('fetchSettings'); - }; - cwrap = function _cwrap(ident, returnType, argTypes, opts) { - return function () { - return ccall(ident, returnType, argTypes, arguments, opts); - }; - }; - ccall = function _ccall(ident, returnType, argTypes, args, opts) { - var toC = { - 'string': function string(str) { - var ret = 0; - if (str !== null && str !== undefined && str !== 0) { - ret = stringToUTF8OnStack(str); - } - return ret; - }, - 'array': function array(arr) { - var ret = stackAlloc(arr.length); - writeArrayToMemory(arr, ret); - return ret; - } - }; - function convertReturnValue(ret) { - if (returnType === 'string') { - return UTF8ToString(ret); - } - if (returnType === 'boolean') return Boolean(ret); - return ret; - } - var func = getCFunc(ident); - var cArgs = []; - var stack = 0; - assert(returnType !== 'array', 'Return type should not be "array".'); - if (args) { - for (var i = 0; i < args.length; i++) { - var converter = toC[argTypes[i]]; - if (converter) { - if (stack === 0) stack = stackSave(); - cArgs[i] = converter(args[i]); - } else { - cArgs[i] = args[i]; - } - } - } - var ret = func.apply(null, cArgs); - function onDone(ret) { - if (stack !== 0) stackRestore(stack); - return convertReturnValue(ret); - } - ret = onDone(ret); - return ret; - }; - stringToUTF8OnStack = function _stringToUTF8OnStack(str) { - var size = lengthBytesUTF8(str) + 1; - var ret = stackAlloc(size); - stringToUTF8(str, ret, size); - return ret; - }; - stringToUTF8 = function _stringToUTF(str, outPtr, maxBytesToWrite) { - assert(typeof maxBytesToWrite == 'number', 'stringToUTF8(str, outPtr, maxBytesToWrite) is missing the third parameter that specifies the length of the output buffer!'); - return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite); - }; - stringToUTF8Array = function _stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) { - assert(typeof str === 'string'); - if (!(maxBytesToWrite > 0)) return 0; - var startIdx = outIdx; - var endIdx = outIdx + maxBytesToWrite - 1; - for (var i = 0; i < str.length; ++i) { - var u = str.charCodeAt(i); - if (u >= 0xD800 && u <= 0xDFFF) { - var u1 = str.charCodeAt(++i); - u = 0x10000 + ((u & 0x3FF) << 10) | u1 & 0x3FF; - } - if (u <= 0x7F) { - if (outIdx >= endIdx) break; - heap[outIdx++] = u; - } else if (u <= 0x7FF) { - if (outIdx + 1 >= endIdx) break; - heap[outIdx++] = 0xC0 | u >> 6; - heap[outIdx++] = 0x80 | u & 63; - } else if (u <= 0xFFFF) { - if (outIdx + 2 >= endIdx) break; - heap[outIdx++] = 0xE0 | u >> 12; - heap[outIdx++] = 0x80 | u >> 6 & 63; - heap[outIdx++] = 0x80 | u & 63; - } else { - if (outIdx + 3 >= endIdx) break; - if (u > 0x10FFFF) warnOnce('Invalid Unicode code point ' + ptrToString(u) + ' encountered when serializing a JS string to a UTF-8 string in wasm memory! (Valid unicode code points should be in range 0-0x10FFFF).'); - heap[outIdx++] = 0xF0 | u >> 18; - heap[outIdx++] = 0x80 | u >> 12 & 63; - heap[outIdx++] = 0x80 | u >> 6 & 63; - heap[outIdx++] = 0x80 | u & 63; - } - } - heap[outIdx] = 0; - return outIdx - startIdx; - }; - lengthBytesUTF8 = function _lengthBytesUTF(str) { - var len = 0; - for (var i = 0; i < str.length; ++i) { - var c = str.charCodeAt(i); - if (c <= 0x7F) { - len++; - } else if (c <= 0x7FF) { - len += 2; - } else if (c >= 0xD800 && c <= 0xDFFF) { - len += 4; - ++i; - } else { - len += 3; - } - } - return len; - }; - writeArrayToMemory = function _writeArrayToMemory(array, buffer) { - assert(array.length >= 0, 'writeArrayToMemory array must have a length (should be an array or typed array)'); - HEAP8.set(array, buffer); - }; - getCFunc = function _getCFunc(ident) { - var func = Module['_' + ident]; - assert(func, 'Cannot call unknown function ' + ident + ', make sure it is exported'); - return func; - }; - _fd_write = function _fd_write2(fd, iov, iovcnt, pnum) { - var num = 0; - for (var i = 0; i < iovcnt; i++) { - var ptr = HEAPU32[iov >> 2]; - var len = HEAPU32[iov + 4 >> 2]; - iov += 8; - for (var j = 0; j < len; j++) { - printChar(fd, HEAPU8[ptr + j]); - } - num += len; - } - HEAPU32[pnum >> 2] = num; - return 0; - }; - UTF8ToString = function _UTF8ToString(ptr, maxBytesToRead) { - assert(typeof ptr == 'number'); - return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead) : ''; - }; - flush_NO_FILESYSTEM = function _flush_NO_FILESYSTEM() { - _fflush(0); - if (printCharBuffers[1].length) printChar(1, 10); - if (printCharBuffers[2].length) printChar(2, 10); - }; - printChar = function _printChar(stream, curr) { - var buffer = printCharBuffers[stream]; - assert(buffer); - if (curr === 0 || curr === 10) { - (stream === 1 ? out : err)(UTF8ArrayToString(buffer, 0)); - buffer.length = 0; - } else { - buffer.push(curr); - } - }; - UTF8ArrayToString = function _UTF8ArrayToString(heapOrArray, idx, maxBytesToRead) { - var endIdx = idx + maxBytesToRead; - var endPtr = idx; - while (heapOrArray[endPtr] && !(endPtr >= endIdx)) ++endPtr; - if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) { - return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr)); - } - var str = ''; - while (idx < endPtr) { - var u0 = heapOrArray[idx++]; - if (!(u0 & 0x80)) { - str += String.fromCharCode(u0); - continue; - } - var u1 = heapOrArray[idx++] & 63; - if ((u0 & 0xE0) == 0xC0) { - str += String.fromCharCode((u0 & 31) << 6 | u1); - continue; - } - var u2 = heapOrArray[idx++] & 63; - if ((u0 & 0xF0) == 0xE0) { - u0 = (u0 & 15) << 12 | u1 << 6 | u2; - } else { - if ((u0 & 0xF8) != 0xF0) warnOnce('Invalid UTF-8 leading byte ' + ptrToString(u0) + ' encountered when deserializing a UTF-8 string in wasm memory to a JS string!'); - u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63; - } - if (u0 < 0x10000) { - str += String.fromCharCode(u0); - } else { - var ch = u0 - 0x10000; - str += String.fromCharCode(0xD800 | ch >> 10, 0xDC00 | ch & 0x3FF); - } - } - return str; - }; - _emscripten_memcpy_big = function _emscripten_memcpy_bi(dest, src, num) { - HEAPU8.copyWithin(dest, src, src + num); - }; - warnOnce = function _warnOnce(text) { - if (!warnOnce.shown) warnOnce.shown = {}; - if (!warnOnce.shown[text]) { - warnOnce.shown[text] = 1; - if (ENVIRONMENT_IS_NODE) text = 'warning: ' + text; - err(text); - } - }; - setValue = function _setValue(ptr, value, type) { - if (type === void 0) { - type = 'i8'; - } - if (type.endsWith('*')) type = '*'; - switch (type) { - case 'i1': - HEAP8[ptr >> 0] = value; - break; - case 'i8': - HEAP8[ptr >> 0] = value; - break; - case 'i16': - HEAP16[ptr >> 1] = value; - break; - case 'i32': - HEAP32[ptr >> 2] = value; - break; - case 'i64': - tempI64 = [value >>> 0, (tempDouble = value, +Math.abs(tempDouble) >= 1.0 ? tempDouble > 0.0 ? (Math.min(+Math.floor(tempDouble / 4294967296.0), 4294967295.0) | 0) >>> 0 : ~~+Math.ceil((tempDouble - +(~~tempDouble >>> 0)) / 4294967296.0) >>> 0 : 0)], HEAP32[ptr >> 2] = tempI64[0], HEAP32[ptr + 4 >> 2] = tempI64[1]; - break; - case 'float': - HEAPF32[ptr >> 2] = value; - break; - case 'double': - HEAPF64[ptr >> 3] = value; - break; - case '*': - HEAPU32[ptr >> 2] = value; - break; - default: - abort('invalid type for setValue: ' + type); - } - }; - ptrToString = function _ptrToString(ptr) { - assert(typeof ptr === 'number'); - return '0x' + ptr.toString(16).padStart(8, '0'); - }; - getValue = function _getValue(ptr, type) { - if (type === void 0) { - type = 'i8'; - } - if (type.endsWith('*')) type = '*'; - switch (type) { - case 'i1': - return HEAP8[ptr >> 0]; - case 'i8': - return HEAP8[ptr >> 0]; - case 'i16': - return HEAP16[ptr >> 1]; - case 'i32': - return HEAP32[ptr >> 2]; - case 'i64': - return HEAP32[ptr >> 2]; - case 'float': - return HEAPF32[ptr >> 2]; - case 'double': - return HEAPF64[ptr >> 3]; - case '*': - return HEAPU32[ptr >> 2]; - default: - abort('invalid type for getValue: ' + type); - } - }; - callRuntimeCallbacks = function _callRuntimeCallbacks(callbacks) { - while (callbacks.length > 0) { - callbacks.shift()(Module); - } - }; - ExitStatus = function _ExitStatus(status) { - this.name = 'ExitStatus'; - this.message = 'Program terminated with exit(' + status + ')'; - this.status = status; - }; - dbg = function _dbg(text) { - console.error.apply(console, arguments); - }; - unexportedRuntimeSymbol = function _unexportedRuntimeSym(sym) { - if (!Object.getOwnPropertyDescriptor(Module, sym)) { - Object.defineProperty(Module, sym, { - configurable: true, - get: function get() { - var msg = "'" + sym + "' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the FAQ)"; - if (isExportedByForceFilesystem(sym)) { - msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'; - } - abort(msg); - } - }); - } - }; - missingLibrarySymbol = function _missingLibrarySymbol(sym) { - if (typeof globalThis !== 'undefined' && !Object.getOwnPropertyDescriptor(globalThis, sym)) { - Object.defineProperty(globalThis, sym, { - configurable: true, - get: function get() { - var msg = '\`' + sym + '\` is a library symbol and not included by default; add it to your library.js __deps or to DEFAULT_LIBRARY_FUNCS_TO_INCLUDE on the command line'; - var librarySymbol = sym; - if (!librarySymbol.startsWith('_')) { - librarySymbol = '$' + sym; - } - msg += " (e.g. -sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=" + librarySymbol + ")"; - if (isExportedByForceFilesystem(sym)) { - msg += '. Alternatively, forcing filesystem support (-sFORCE_FILESYSTEM) can export this for you'; - } - warnOnce(msg); - return undefined; - } - }); - } - unexportedRuntimeSymbol(sym); - }; - missingGlobal = function _missingGlobal(sym, msg) { - if (typeof globalThis !== 'undefined') { - Object.defineProperty(globalThis, sym, { - configurable: true, - get: function get() { - warnOnce('\`' + sym + '\` is not longer defined by emscripten. ' + msg); - return undefined; - } - }); - } - }; - isExportedByForceFilesystem = function _isExportedByForceFil(name) { - return name === 'FS_createPath' || name === 'FS_createDataFile' || name === 'FS_createPreloadedFile' || name === 'FS_unlink' || name === 'addRunDependency' || name === 'FS_createLazyFile' || name === 'FS_createDevice' || name === 'removeRunDependency'; - }; - ignoredModuleProp = function _ignoredModuleProp(prop) { - if (Object.getOwnPropertyDescriptor(Module, prop)) { - abort('\`Module.' + prop + '\` was supplied but \`' + prop + '\` not included in INCOMING_MODULE_JS_API'); - } - }; - legacyModuleProp = function _legacyModuleProp(prop, newName) { - if (!Object.getOwnPropertyDescriptor(Module, prop)) { - Object.defineProperty(Module, prop, { - configurable: true, - get: function get() { - abort('Module.' + prop + ' has been replaced with plain ' + newName + ' (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name)'); - } - }); - } - }; - createWasm = function _createWasm() { - var info = { - 'env': wasmImports, - 'wasi_snapshot_preview1': wasmImports - }; - function receiveInstance(instance, module) { - var exports = instance.exports; - Module['asm'] = exports; - wasmMemory = Module['asm']['memory']; - assert(wasmMemory, "memory not found in wasm exports"); - updateMemoryViews(); - wasmTable = Module['asm']['__indirect_function_table']; - assert(wasmTable, "table not found in wasm exports"); - addOnInit(Module['asm']['__wasm_call_ctors']); - removeRunDependency('wasm-instantiate'); - return exports; - } - addRunDependency('wasm-instantiate'); - var trueModule = Module; - function receiveInstantiationResult(result) { - assert(Module === trueModule, 'the Module object should not be replaced during async compilation - perhaps the order of HTML elements is wrong?'); - trueModule = null; - receiveInstance(result['instance']); - } - if (Module['instantiateWasm']) { - try { - return Module['instantiateWasm'](info, receiveInstance); - } catch (e) { - err('Module.instantiateWasm callback failed with error: ' + e); - readyPromiseReject(e); - } - } - instantiateAsync(wasmBinary, wasmBinaryFile, info, receiveInstantiationResult)["catch"](readyPromiseReject); - return {}; - }; - instantiateAsync = function _instantiateAsync(binary, binaryFile, imports, callback) { - if (!binary && typeof WebAssembly.instantiateStreaming == 'function' && !isDataURI(binaryFile) && !isFileURI(binaryFile) && !ENVIRONMENT_IS_NODE && typeof fetch == 'function') { - return fetch(binaryFile, { - credentials: 'same-origin' - }).then(function (response) { - var result = WebAssembly.instantiateStreaming(response, imports); - return result.then(callback, function (reason) { - err('wasm streaming compile failed: ' + reason); - err('falling back to ArrayBuffer instantiation'); - return instantiateArrayBuffer(binaryFile, imports, callback); - }); - }); - } else { - return instantiateArrayBuffer(binaryFile, imports, callback); - } - }; - instantiateArrayBuffer = function _instantiateArrayBuff(binaryFile, imports, receiver) { - return getBinaryPromise(binaryFile).then(function (binary) { - return WebAssembly.instantiate(binary, imports); - }).then(function (instance) { - return instance; - }).then(receiver, function (reason) { - err('failed to asynchronously prepare wasm: ' + reason); - if (isFileURI(wasmBinaryFile)) { - err('warning: Loading from a file URI (' + wasmBinaryFile + ') is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing'); - } - abort(reason); - }); - }; - getBinaryPromise = function _getBinaryPromise(binaryFile) { - if (!wasmBinary && (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - if (typeof fetch == 'function' && !isFileURI(binaryFile)) { - return fetch(binaryFile, { - credentials: 'same-origin' - }).then(function (response) { - if (!response['ok']) { - throw "failed to load wasm binary file at '" + binaryFile + "'"; - } - return response['arrayBuffer'](); - })["catch"](function () { - return getBinary(binaryFile); - }); - } else { - if (readAsync) { - return new Promise(function (resolve, reject) { - readAsync(binaryFile, function (response) { - resolve(new Uint8Array(response)); - }, reject); - }); - } - } - } - return Promise.resolve().then(function () { - return getBinary(binaryFile); - }); - }; - getBinary = function _getBinary(file) { - try { - if (file == wasmBinaryFile && wasmBinary) { - return new Uint8Array(wasmBinary); - } - if (readBinary) { - return readBinary(file); - } - throw "both async and sync fetching of the wasm failed"; - } catch (err) { - abort(err); - } - }; - createExportWrapper = function _createExportWrapper(name, fixedasm) { - return function () { - var displayName = name; - var asm = fixedasm; - if (!fixedasm) { - asm = Module['asm']; - } - assert(runtimeInitialized, 'native function \`' + displayName + '\` called before runtime initialization'); - if (!asm[name]) { - assert(asm[name], 'exported native function \`' + displayName + '\` not found'); - } - return asm[name].apply(null, arguments); - }; - }; - isFileURI = function _isFileURI(filename) { - return filename.startsWith('file://'); - }; - isDataURI = function _isDataURI(filename) { - return filename.startsWith(dataURIPrefix); - }; - abort = function _abort(what) { - if (Module['onAbort']) { - Module['onAbort'](what); - } - what = 'Aborted(' + what + ')'; - err(what); - ABORT = true; - EXITSTATUS = 1; - var e = new WebAssembly.RuntimeError(what); - readyPromiseReject(e); - throw e; - }; - removeRunDependency = function _removeRunDependency(id) { - runDependencies--; - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies); - } - if (id) { - assert(runDependencyTracking[id]); - delete runDependencyTracking[id]; - } else { - err('warning: run dependency removed without ID'); - } - if (runDependencies == 0) { - if (runDependencyWatcher !== null) { - clearInterval(runDependencyWatcher); - runDependencyWatcher = null; - } - if (dependenciesFulfilled) { - var callback = dependenciesFulfilled; - dependenciesFulfilled = null; - callback(); - } - } - }; - addRunDependency = function _addRunDependency(id) { - runDependencies++; - if (Module['monitorRunDependencies']) { - Module['monitorRunDependencies'](runDependencies); - } - if (id) { - assert(!runDependencyTracking[id]); - runDependencyTracking[id] = 1; - if (runDependencyWatcher === null && typeof setInterval != 'undefined') { - runDependencyWatcher = setInterval(function () { - if (ABORT) { - clearInterval(runDependencyWatcher); - runDependencyWatcher = null; - return; - } - var shown = false; - for (var dep in runDependencyTracking) { - if (!shown) { - shown = true; - err('still waiting on run dependencies:'); - } - err('dependency: ' + dep); - } - if (shown) { - err('(end of list)'); - } - }, 10000); - } - } else { - err('warning: run dependency added without ID'); - } - }; - getUniqueRunDependency = function _getUniqueRunDependen(id) { - var orig = id; - while (1) { - if (!runDependencyTracking[id]) return id; - id = orig + Math.random(); - } - }; - addOnPostRun = function _addOnPostRun(cb) { - __ATPOSTRUN__.unshift(cb); - }; - addOnExit = function _addOnExit(cb) {}; - addOnInit = function _addOnInit(cb) { - __ATINIT__.unshift(cb); - }; - addOnPreRun = function _addOnPreRun(cb) { - __ATPRERUN__.unshift(cb); - }; - postRun = function _postRun() { - checkStackCookie(); - if (Module['postRun']) { - if (typeof Module['postRun'] == 'function') Module['postRun'] = [Module['postRun']]; - while (Module['postRun'].length) { - addOnPostRun(Module['postRun'].shift()); - } - } - callRuntimeCallbacks(__ATPOSTRUN__); - }; - initRuntime = function _initRuntime() { - assert(!runtimeInitialized); - runtimeInitialized = true; - checkStackCookie(); - callRuntimeCallbacks(__ATINIT__); - }; - preRun = function _preRun() { - if (Module['preRun']) { - if (typeof Module['preRun'] == 'function') Module['preRun'] = [Module['preRun']]; - while (Module['preRun'].length) { - addOnPreRun(Module['preRun'].shift()); - } - } - callRuntimeCallbacks(__ATPRERUN__); - }; - keepRuntimeAlive = function _keepRuntimeAlive() { - return noExitRuntime || runtimeKeepaliveCounter > 0; - }; - checkStackCookie = function _checkStackCookie() { - if (ABORT) return; - var max = _emscripten_stack_get_end2(); - if (max == 0) { - max += 4; - } - var cookie1 = HEAPU32[max >> 2]; - var cookie2 = HEAPU32[max + 4 >> 2]; - if (cookie1 != 0x02135467 || cookie2 != 0x89BACDFE) { - abort('Stack overflow! Stack cookie has been overwritten at ' + ptrToString(max) + ', expected hex dwords 0x89BACDFE and 0x2135467, but received ' + ptrToString(cookie2) + ' ' + ptrToString(cookie1)); - } - if (HEAPU32[0] !== 0x63736d65) { - abort('Runtime error: The application has corrupted its heap memory area (address zero)!'); - } - }; - writeStackCookie = function _writeStackCookie() { - var max = _emscripten_stack_get_end2(); - assert((max & 3) == 0); - if (max == 0) { - max += 4; - } - HEAPU32[max >> 2] = 0x02135467; - HEAPU32[max + 4 >> 2] = 0x89BACDFE; - HEAPU32[0] = 0x63736d65; - }; - updateMemoryViews = function _updateMemoryViews() { - var b = wasmMemory.buffer; - Module['HEAP8'] = HEAP8 = new Int8Array(b); - Module['HEAP16'] = HEAP16 = new Int16Array(b); - Module['HEAP32'] = HEAP32 = new Int32Array(b); - Module['HEAPU8'] = HEAPU8 = new Uint8Array(b); - Module['HEAPU16'] = HEAPU16 = new Uint16Array(b); - Module['HEAPU32'] = HEAPU32 = new Uint32Array(b); - Module['HEAPF32'] = HEAPF32 = new Float32Array(b); - Module['HEAPF64'] = HEAPF64 = new Float64Array(b); - }; - _free = function _free2() { - abort("free() called but not included in the build - add '_free' to EXPORTED_FUNCTIONS"); - }; - _malloc = function _malloc2() { - abort("malloc() called but not included in the build - add '_malloc' to EXPORTED_FUNCTIONS"); - }; - assert = function _assert(condition, text) { - if (!condition) { - abort('Assertion failed' + (text ? ': ' + text : '')); - } - }; - locateFile = function _locateFile(path) { - if (Module['locateFile']) { - return Module['locateFile'](path, scriptDirectory); - } - return scriptDirectory + path; - }; - Module = typeof Module != 'undefined' ? Module : {}; - Module['ready'] = new Promise(function (resolve, reject) { - readyPromiseResolve = resolve; - readyPromiseReject = reject; - }); - ["_hello", "_fflush", "onRuntimeInitialized"].forEach(function (prop) { - if (!Object.getOwnPropertyDescriptor(Module['ready'], prop)) { - Object.defineProperty(Module['ready'], prop, { - get: function get() { - return abort('You are getting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'); - }, - set: function set() { - return abort('You are setting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'); - } - }); - } - }); - moduleOverrides = Object.assign({}, Module); - arguments_ = []; - thisProgram = './this.program'; - quit_ = function quit_(status, toThrow) { - throw toThrow; - }; - ENVIRONMENT_IS_WEB = typeof window == 'object'; - ENVIRONMENT_IS_WORKER = typeof importScripts == 'function'; - ENVIRONMENT_IS_NODE = typeof process == 'object' && typeof process.versions == 'object' && typeof process.versions.node == 'string'; - ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIRONMENT_IS_WORKER; - if (!Module['ENVIRONMENT']) { - _context.next = 71; - break; - } - throw new Error('Module.ENVIRONMENT has been deprecated. To force the environment, use the ENVIRONMENT compile-time option (for example, -sENVIRONMENT=web or -sENVIRONMENT=node)'); - case 71: - scriptDirectory = ''; - if (!ENVIRONMENT_IS_NODE) { - _context.next = 98; - break; - } - if (!(typeof process == 'undefined' || !process.release || process.release.name !== 'node')) { - _context.next = 75; - break; - } - throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); - case 75: - nodeVersion = process.versions.node; - numericVersion = nodeVersion.split('.').slice(0, 3); - numericVersion = numericVersion[0] * 10000 + numericVersion[1] * 100 + numericVersion[2].split('-')[0] * 1; - minVersion = 101900; - if (!(numericVersion < 101900)) { - _context.next = 81; - break; - } - throw new Error('This emscripten-generated code requires node v10.19.19.0 (detected v' + nodeVersion + ')'); - case 81: - _context.next = 83; - return module.import('module'); - case 83: - _yield$import = _context.sent; - createRequire = _yield$import.createRequire; - require = createRequire(module.meta.url); - fs = require('fs'); - nodePath = require('path'); - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = nodePath.dirname(scriptDirectory) + '/'; - } else { - scriptDirectory = require('url').fileURLToPath(new URL('./', module.meta.url)); - } - read_ = function read_(filename, binary) { - filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename); - return fs.readFileSync(filename, binary ? undefined : 'utf8'); - }; - readBinary = function readBinary(filename) { - var ret = read_(filename, true); - if (!ret.buffer) { - ret = new Uint8Array(ret); - } - assert(ret.buffer); - return ret; - }; - readAsync = function readAsync(filename, onload, onerror) { - filename = isFileURI(filename) ? new URL(filename) : nodePath.normalize(filename); - fs.readFile(filename, function (err, data) { - if (err) onerror(err);else onload(data.buffer); - }); - }; - if (!Module['thisProgram'] && process.argv.length > 1) { - thisProgram = process.argv[1].replace(/\\\\/g, '/'); - } - arguments_ = process.argv.slice(2); - quit_ = function quit_(status, toThrow) { - process.exitCode = status; - throw toThrow; - }; - Module['inspect'] = function () { - return '[Emscripten Module object]'; - }; - _context.next = 123; - break; - case 98: - if (!ENVIRONMENT_IS_SHELL) { - _context.next = 110; - break; - } - if (!(typeof process == 'object' && typeof require === 'function' || typeof window == 'object' || typeof importScripts == 'function')) { - _context.next = 101; - break; - } - throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); - case 101: - if (typeof read != 'undefined') { - read_ = function shell_read(f) { - return read(f); - }; - } - readBinary = function readBinary(f) { - var data; - if (typeof readbuffer == 'function') { - return new Uint8Array(readbuffer(f)); - } - data = read(f, 'binary'); - assert(typeof data == 'object'); - return data; - }; - readAsync = function readAsync(f, onload, onerror) { - setTimeout(function () { - return onload(readBinary(f)); - }, 0); - }; - if (typeof clearTimeout == 'undefined') { - globalThis.clearTimeout = function (id) {}; - } - if (typeof scriptArgs != 'undefined') { - arguments_ = scriptArgs; - } else if (typeof _arguments != 'undefined') { - arguments_ = _arguments; - } - if (typeof quit == 'function') { - quit_ = function quit_(status, toThrow) { - setTimeout(function () { - if (!(toThrow instanceof ExitStatus)) { - var toLog = toThrow; - if (toThrow && typeof toThrow == 'object' && toThrow.stack) { - toLog = [toThrow, toThrow.stack]; - } - err('exiting due to exception: ' + toLog); - } - quit(status); - }); - throw toThrow; - }; - } - if (typeof print != 'undefined') { - if (typeof console == 'undefined') console = {}; - console.log = print; - console.warn = console.error = typeof printErr != 'undefined' ? printErr : print; - } - _context.next = 123; - break; - case 110: - if (!(ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER)) { - _context.next = 122; - break; - } - if (ENVIRONMENT_IS_WORKER) { - scriptDirectory = self.location.href; - } else if (typeof document != 'undefined' && document.currentScript) { - scriptDirectory = document.currentScript.src; - } - if (_scriptDir) { - scriptDirectory = _scriptDir; - } - if (scriptDirectory.indexOf('blob:') !== 0) { - scriptDirectory = scriptDirectory.substr(0, scriptDirectory.replace(/[?#].*/, "").lastIndexOf('/') + 1); - } else { - scriptDirectory = ''; - } - if (typeof window == 'object' || typeof importScripts == 'function') { - _context.next = 116; - break; - } - throw new Error('not compiled for this environment (did you build to HTML and try to run it not on the web, or set ENVIRONMENT to something - like node - and run it someplace else - like on the web?)'); - case 116: - read_ = function read_(url) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, false); - xhr.send(null); - return xhr.responseText; - }; - if (ENVIRONMENT_IS_WORKER) { - readBinary = function readBinary(url) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, false); - xhr.responseType = 'arraybuffer'; - xhr.send(null); - return new Uint8Array(xhr.response); - }; - } - readAsync = function readAsync(url, onload, onerror) { - var xhr = new XMLHttpRequest(); - xhr.open('GET', url, true); - xhr.responseType = 'arraybuffer'; - xhr.onload = function () { - if (xhr.status == 200 || xhr.status == 0 && xhr.response) { - onload(xhr.response); - return; - } - onerror(); - }; - xhr.onerror = onerror; - xhr.send(null); - }; - setWindowTitle = function setWindowTitle(title) { - return document.title = title; - }; - _context.next = 123; - break; - case 122: - throw new Error('environment detection error'); - case 123: - out = Module['print'] || console.log.bind(console); - err = Module['printErr'] || console.warn.bind(console); - Object.assign(Module, moduleOverrides); - moduleOverrides = null; - checkIncomingModuleAPI(); - if (Module['arguments']) arguments_ = Module['arguments']; - legacyModuleProp('arguments', 'arguments_'); - if (Module['thisProgram']) thisProgram = Module['thisProgram']; - legacyModuleProp('thisProgram', 'thisProgram'); - if (Module['quit']) quit_ = Module['quit']; - legacyModuleProp('quit', 'quit_'); - assert(typeof Module['memoryInitializerPrefixURL'] == 'undefined', 'Module.memoryInitializerPrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['pthreadMainPrefixURL'] == 'undefined', 'Module.pthreadMainPrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['cdInitializerPrefixURL'] == 'undefined', 'Module.cdInitializerPrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['filePackagePrefixURL'] == 'undefined', 'Module.filePackagePrefixURL option was removed, use Module.locateFile instead'); - assert(typeof Module['read'] == 'undefined', 'Module.read option was removed (modify read_ in JS)'); - assert(typeof Module['readAsync'] == 'undefined', 'Module.readAsync option was removed (modify readAsync in JS)'); - assert(typeof Module['readBinary'] == 'undefined', 'Module.readBinary option was removed (modify readBinary in JS)'); - assert(typeof Module['setWindowTitle'] == 'undefined', 'Module.setWindowTitle option was removed (modify setWindowTitle in JS)'); - assert(typeof Module['TOTAL_MEMORY'] == 'undefined', 'Module.TOTAL_MEMORY has been renamed Module.INITIAL_MEMORY'); - legacyModuleProp('read', 'read_'); - legacyModuleProp('readAsync', 'readAsync'); - legacyModuleProp('readBinary', 'readBinary'); - legacyModuleProp('setWindowTitle', 'setWindowTitle'); - IDBFS = 'IDBFS is no longer included by default; build with -lidbfs.js'; - PROXYFS = 'PROXYFS is no longer included by default; build with -lproxyfs.js'; - WORKERFS = 'WORKERFS is no longer included by default; build with -lworkerfs.js'; - NODEFS = 'NODEFS is no longer included by default; build with -lnodefs.js'; - assert(!ENVIRONMENT_IS_SHELL, "shell environment detected but not enabled at build time. Add 'shell' to \`-sENVIRONMENT\` to enable."); - if (Module['wasmBinary']) wasmBinary = Module['wasmBinary']; - legacyModuleProp('wasmBinary', 'wasmBinary'); - noExitRuntime = Module['noExitRuntime'] || true; - legacyModuleProp('noExitRuntime', 'noExitRuntime'); - if (typeof WebAssembly != 'object') { - abort('no native wasm support detected'); - } - ABORT = false; - assert(!Module['STACK_SIZE'], 'STACK_SIZE can no longer be set at runtime. Use -sSTACK_SIZE at link time'); - assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined, 'JS engine does not provide full typed array support'); - assert(!Module['wasmMemory'], 'Use of \`wasmMemory\` detected. Use -sIMPORTED_MEMORY to define wasmMemory externally'); - assert(!Module['INITIAL_MEMORY'], 'Detected runtime INITIAL_MEMORY setting. Use -sIMPORTED_MEMORY to define wasmMemory dynamically'); - (function () { - var h16 = new Int16Array(1); - var h8 = new Int8Array(h16.buffer); - h16[0] = 0x6373; - if (h8[0] !== 0x73 || h8[1] !== 0x63) throw 'Runtime error: expected the system to be little-endian! (Run with -sSUPPORT_BIG_ENDIAN to bypass)'; - })(); - __ATPRERUN__ = []; - __ATINIT__ = []; - __ATEXIT__ = []; - __ATPOSTRUN__ = []; - runtimeInitialized = false; - runtimeKeepaliveCounter = 0; - assert(Math.imul, 'This browser does not support Math.imul(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); - assert(Math.fround, 'This browser does not support Math.fround(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); - assert(Math.clz32, 'This browser does not support Math.clz32(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); - assert(Math.trunc, 'This browser does not support Math.trunc(), build with LEGACY_VM_SUPPORT or POLYFILL_OLD_MATH_FUNCTIONS to add in a polyfill'); - runDependencies = 0; - runDependencyWatcher = null; - dependenciesFulfilled = null; - runDependencyTracking = {}; - FS = { - error: function error() { - abort('Filesystem support (FS) was not included. The problem is that you are using files from JS, but files were not used from C/C++, so filesystem support was not auto-included. You can force-include filesystem support with -sFORCE_FILESYSTEM'); - }, - init: function init() { - FS.error(); - }, - createDataFile: function createDataFile() { - FS.error(); - }, - createPreloadedFile: function createPreloadedFile() { - FS.error(); - }, - createLazyFile: function createLazyFile() { - FS.error(); - }, - open: function open() { - FS.error(); - }, - mkdev: function mkdev() { - FS.error(); - }, - registerDevice: function registerDevice() { - FS.error(); - }, - analyzePath: function analyzePath() { - FS.error(); - }, - ErrnoError: function ErrnoError() { - FS.error(); - } - }; - Module['FS_createDataFile'] = FS.createDataFile; - Module['FS_createPreloadedFile'] = FS.createPreloadedFile; - dataURIPrefix = 'data:application/octet-stream;base64,'; - if (Module['locateFile']) { - wasmBinaryFile = 'wasm_c.wasm'; - if (!isDataURI(wasmBinaryFile)) { - wasmBinaryFile = locateFile(wasmBinaryFile); - } - } else { - wasmBinaryFile = new URL('wasm_c.wasm', module.meta.url).href; - } - missingGlobal('buffer', 'Please use HEAP8.buffer or wasmMemory.buffer'); - printCharBuffers = [null, [], []]; - UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf8') : undefined; - SYSCALLS = { - varargs: undefined, - get: function get() { - assert(SYSCALLS.varargs != undefined); - SYSCALLS.varargs += 4; - var ret = HEAP32[SYSCALLS.varargs - 4 >> 2]; - return ret; - }, - getStr: function getStr(ptr) { - var ret = UTF8ToString(ptr); - return ret; - } - }; - wasmImports = { - "emscripten_memcpy_big": _emscripten_memcpy_big, - "fd_write": _fd_write - }; - asm = createWasm(); - ___wasm_call_ctors = createExportWrapper("__wasm_call_ctors"); - _hello = Module["_hello"] = createExportWrapper("hello"); - ___errno_location = createExportWrapper("__errno_location"); - _fflush = Module["_fflush"] = createExportWrapper("fflush"); - _emscripten_stack_init2 = function _emscripten_stack_init() { - return (_emscripten_stack_init2 = Module["asm"]["emscripten_stack_init"]).apply(null, arguments); - }; - _emscripten_stack_get_free2 = function _emscripten_stack_get_free() { - return (_emscripten_stack_get_free2 = Module["asm"]["emscripten_stack_get_free"]).apply(null, arguments); - }; - _emscripten_stack_get_base2 = function _emscripten_stack_get_base() { - return (_emscripten_stack_get_base2 = Module["asm"]["emscripten_stack_get_base"]).apply(null, arguments); - }; - _emscripten_stack_get_end2 = function _emscripten_stack_get_end() { - return (_emscripten_stack_get_end2 = Module["asm"]["emscripten_stack_get_end"]).apply(null, arguments); - }; - stackSave = createExportWrapper("stackSave"); - stackRestore = createExportWrapper("stackRestore"); - stackAlloc = createExportWrapper("stackAlloc"); - _emscripten_stack_get_current2 = function _emscripten_stack_get_current() { - return (_emscripten_stack_get_current2 = Module["asm"]["emscripten_stack_get_current"]).apply(null, arguments); - }; - dynCall_jiji = Module["dynCall_jiji"] = createExportWrapper("dynCall_jiji"); - Module["ccall"] = ccall; - Module["cwrap"] = cwrap; - missingLibrarySymbols = ['zeroMemory', 'exitJS', 'getHeapMax', 'abortOnCannotGrowMemory', 'emscripten_realloc_buffer', 'isLeapYear', 'ydayFromDate', 'arraySum', 'addDays', 'setErrNo', 'inetPton4', 'inetNtop4', 'inetPton6', 'inetNtop6', 'readSockaddr', 'writeSockaddr', 'getHostByName', 'initRandomFill', 'randomFill', 'traverseStack', 'getCallstack', 'emscriptenLog', 'convertPCtoSourceLocation', 'readEmAsmArgs', 'jstoi_q', 'jstoi_s', 'getExecutableName', 'listenOnce', 'autoResumeAudioContext', 'dynCallLegacy', 'getDynCaller', 'dynCall', 'handleException', 'runtimeKeepalivePush', 'runtimeKeepalivePop', 'callUserCallback', 'maybeExit', 'safeSetTimeout', 'asmjsMangle', 'asyncLoad', 'alignMemory', 'mmapAlloc', 'HandleAllocator', 'getNativeTypeSize', 'STACK_SIZE', 'STACK_ALIGN', 'POINTER_SIZE', 'ASSERTIONS', 'writeI53ToI64', 'writeI53ToI64Clamped', 'writeI53ToI64Signaling', 'writeI53ToU64Clamped', 'writeI53ToU64Signaling', 'readI53FromI64', 'readI53FromU64', 'convertI32PairToI53', 'convertI32PairToI53Checked', 'convertU32PairToI53', 'uleb128Encode', 'sigToWasmTypes', 'generateFuncType', 'convertJsFunctionToWasm', 'getEmptyTableSlot', 'updateTableMap', 'getFunctionAddress', 'addFunction', 'removeFunction', 'reallyNegative', 'unSign', 'strLen', 'reSign', 'formatString', 'intArrayFromString', 'intArrayToString', 'AsciiToString', 'stringToAscii', 'UTF16ToString', 'stringToUTF16', 'lengthBytesUTF16', 'UTF32ToString', 'stringToUTF32', 'lengthBytesUTF32', 'stringToNewUTF8', 'getSocketFromFD', 'getSocketAddress', 'registerKeyEventCallback', 'maybeCStringToJsString', 'findEventTarget', 'findCanvasEventTarget', 'getBoundingClientRect', 'fillMouseEventData', 'registerMouseEventCallback', 'registerWheelEventCallback', 'registerUiEventCallback', 'registerFocusEventCallback', 'fillDeviceOrientationEventData', 'registerDeviceOrientationEventCallback', 'fillDeviceMotionEventData', 'registerDeviceMotionEventCallback', 'screenOrientation', 'fillOrientationChangeEventData', 'registerOrientationChangeEventCallback', 'fillFullscreenChangeEventData', 'registerFullscreenChangeEventCallback', 'JSEvents_requestFullscreen', 'JSEvents_resizeCanvasForFullscreen', 'registerRestoreOldStyle', 'hideEverythingExceptGivenElement', 'restoreHiddenElements', 'setLetterbox', 'softFullscreenResizeWebGLRenderTarget', 'doRequestFullscreen', 'fillPointerlockChangeEventData', 'registerPointerlockChangeEventCallback', 'registerPointerlockErrorEventCallback', 'requestPointerLock', 'fillVisibilityChangeEventData', 'registerVisibilityChangeEventCallback', 'registerTouchEventCallback', 'fillGamepadEventData', 'registerGamepadEventCallback', 'registerBeforeUnloadEventCallback', 'fillBatteryEventData', 'battery', 'registerBatteryEventCallback', 'setCanvasElementSize', 'getCanvasElementSize', 'demangle', 'demangleAll', 'jsStackTrace', 'stackTrace', 'getEnvStrings', 'checkWasiClock', 'wasiRightsToMuslOFlags', 'wasiOFlagsToMuslOFlags', 'createDyncallWrapper', 'setImmediateWrapped', 'clearImmediateWrapped', 'polyfillSetImmediate', 'getPromise', 'makePromise', 'idsToPromises', 'makePromiseCallback', 'ExceptionInfo', 'setMainLoop', '_setNetworkCallback', 'heapObjectForWebGLType', 'heapAccessShiftForWebGLHeap', 'webgl_enable_ANGLE_instanced_arrays', 'webgl_enable_OES_vertex_array_object', 'webgl_enable_WEBGL_draw_buffers', 'webgl_enable_WEBGL_multi_draw', 'emscriptenWebGLGet', 'computeUnpackAlignedImageSize', 'colorChannelsInGlTextureFormat', 'emscriptenWebGLGetTexPixelData', '__glGenObject', 'emscriptenWebGLGetUniform', 'webglGetUniformLocation', 'webglPrepareUniformLocationsBeforeFirstUse', 'webglGetLeftBracePos', 'emscriptenWebGLGetVertexAttrib', '__glGetActiveAttribOrUniform', 'writeGLArray', 'registerWebGlEventCallback', 'runAndAbortIfError', 'SDL_unicode', 'SDL_ttfContext', 'SDL_audio', 'GLFW_Window', 'ALLOC_NORMAL', 'ALLOC_STACK', 'allocate', 'writeStringToMemory', 'writeAsciiToMemory']; - missingLibrarySymbols.forEach(missingLibrarySymbol); - unexportedSymbols = ['run', 'addOnPreRun', 'addOnInit', 'addOnPreMain', 'addOnExit', 'addOnPostRun', 'addRunDependency', 'removeRunDependency', 'FS_createFolder', 'FS_createPath', 'FS_createDataFile', 'FS_createPreloadedFile', 'FS_createLazyFile', 'FS_createLink', 'FS_createDevice', 'FS_unlink', 'out', 'err', 'callMain', 'abort', 'keepRuntimeAlive', 'wasmMemory', 'stackAlloc', 'stackSave', 'stackRestore', 'getTempRet0', 'setTempRet0', 'writeStackCookie', 'checkStackCookie', 'ptrToString', 'ENV', 'MONTH_DAYS_REGULAR', 'MONTH_DAYS_LEAP', 'MONTH_DAYS_REGULAR_CUMULATIVE', 'MONTH_DAYS_LEAP_CUMULATIVE', 'ERRNO_CODES', 'ERRNO_MESSAGES', 'DNS', 'Protocols', 'Sockets', 'timers', 'warnOnce', 'UNWIND_CACHE', 'readEmAsmArgsArray', 'getCFunc', 'freeTableIndexes', 'functionsInTableMap', 'setValue', 'getValue', 'PATH', 'PATH_FS', 'UTF8Decoder', 'UTF8ArrayToString', 'UTF8ToString', 'stringToUTF8Array', 'stringToUTF8', 'lengthBytesUTF8', 'UTF16Decoder', 'stringToUTF8OnStack', 'writeArrayToMemory', 'SYSCALLS', 'JSEvents', 'specialHTMLTargets', 'currentFullscreenStrategy', 'restoreOldWindowedStyle', 'ExitStatus', 'flush_NO_FILESYSTEM', 'dlopenMissingError', 'promiseMap', 'uncaughtExceptionCount', 'exceptionLast', 'exceptionCaught', 'Browser', 'wget', 'FS', 'MEMFS', 'TTY', 'PIPEFS', 'SOCKFS', 'tempFixedLengthArray', 'miniTempWebGLFloatBuffers', 'miniTempWebGLIntBuffers', 'GL', 'emscripten_webgl_power_preferences', 'AL', 'GLUT', 'EGL', 'GLEW', 'IDBStore', 'SDL', 'SDL_gfx', 'GLFW', 'allocateUTF8', 'allocateUTF8OnStack']; - unexportedSymbols.forEach(unexportedRuntimeSymbol); - dependenciesFulfilled = function runCaller() { - if (!calledRun) run(); - if (!calledRun) dependenciesFulfilled = runCaller; - }; - if (Module['preInit']) { - if (typeof Module['preInit'] == 'function') Module['preInit'] = [Module['preInit']]; - while (Module['preInit'].length > 0) { - Module['preInit'].pop()(); - } - } - run(); - return _context.abrupt("return", Module.ready); - case 211: - case "end": - return _context.stop(); - } - }, _callee); - })); - return function (_x) { - return _ref.apply(this, arguments); - }; - }()(Module); - } catch (e) { - return Promise.reject(e); - } - }; - }(); - - function initializeWasm() { - return new Promise(function (resolve, reject) { - Module({ - locateFile: function locateFile(_) { - return wasmUrl; - } - }).then(function (inst) { - resolve(inst); - })["catch"](reject); - }); - } - { - initializeWasm().then(function (inst) { - inst._hello(); - }); - } - }) - }; + }) + }; })); " `; exports[`engine-js build WASM module on platform supporting WASM: cull asm.js module 1`] = ` [ + "_virtual_cc-557f4653.js", "assets/wasm_c-8515ca89.wasm", "assets/wasm_rust-404aff2f.wasm", "cc.js", + "wasm_c-a7853123.js", + "wasm_c.wasm-d6fe14a1.js", ] `; @@ -2442,45 +233,7 @@ exports[`engine-js build WASM module on platform supporting WASM: wasm subpackag ] `; -exports[`engine-js build width option ammoJsWasm fallback 1`] = ` -"function tryDefineGlobal (name, value) { - const _global = typeof window === 'undefined' ? global : window; - if (typeof _global[name] === 'undefined') { - return (_global[name] = value); - } else { - // eslint-disable-next-line @typescript-eslint/no-unsafe-return - return _global[name]; - } -} -tryDefineGlobal('CC_WECHAT', false); -tryDefineGlobal('CC_BAIDU', false); -tryDefineGlobal('CC_XIAOMI', true); -tryDefineGlobal('CC_ALIPAY', false); -tryDefineGlobal('CC_BYTEDANCE', false); -tryDefineGlobal('CC_OPPO', false); -tryDefineGlobal('CC_VIVO', false); -tryDefineGlobal('CC_HUAWEI', false); -tryDefineGlobal('CC_COCOSPLAY', false); -tryDefineGlobal('CC_QTT', false); -tryDefineGlobal('CC_LINKSURE', false); -tryDefineGlobal('CC_EDITOR', false); -tryDefineGlobal('CC_PREVIEW', false); -tryDefineGlobal('CC_BUILD', true); -tryDefineGlobal('CC_TEST', false); -tryDefineGlobal('CC_DEBUG', true); -tryDefineGlobal('CC_DEV', false); -tryDefineGlobal('CC_MINIGAME', true); -tryDefineGlobal('CC_RUNTIME_BASED', false); -tryDefineGlobal('CC_SUPPORT_JIT', false); -tryDefineGlobal('CC_JSB', false); - -const FORCE_BANNING_BULLET_WASM = false; - -console.log(FORCE_BANNING_BULLET_WASM); -" -`; - -exports[`engine-js build width option ammoJsWasm false 1`] = ` +exports[`engine-js build width option nativeCodeBundleMode asmjs 1`] = ` "function tryDefineGlobal (name, value) { const _global = typeof window === 'undefined' ? global : window; if (typeof _global[name] === 'undefined') { @@ -2512,13 +265,13 @@ tryDefineGlobal('CC_RUNTIME_BASED', false); tryDefineGlobal('CC_SUPPORT_JIT', false); tryDefineGlobal('CC_JSB', false); -const FORCE_BANNING_BULLET_WASM = true; +const WASM_SUPPORT_MODE = 0; -console.log(FORCE_BANNING_BULLET_WASM); +console.log(WASM_SUPPORT_MODE); " `; -exports[`engine-js build width option ammoJsWasm true 1`] = ` +exports[`engine-js build width option nativeCodeBundleMode both 1`] = ` "function tryDefineGlobal (name, value) { const _global = typeof window === 'undefined' ? global : window; if (typeof _global[name] === 'undefined') { @@ -2550,13 +303,13 @@ tryDefineGlobal('CC_RUNTIME_BASED', false); tryDefineGlobal('CC_SUPPORT_JIT', false); tryDefineGlobal('CC_JSB', false); -const FORCE_BANNING_BULLET_WASM = false; +const WASM_SUPPORT_MODE = 0; -console.log(FORCE_BANNING_BULLET_WASM); +console.log(WASM_SUPPORT_MODE); " `; -exports[`engine-js build without option ammoJsWasm 1`] = ` +exports[`engine-js build width option nativeCodeBundleMode wasm 1`] = ` "function tryDefineGlobal (name, value) { const _global = typeof window === 'undefined' ? global : window; if (typeof _global[name] === 'undefined') { @@ -2588,9 +341,9 @@ tryDefineGlobal('CC_RUNTIME_BASED', false); tryDefineGlobal('CC_SUPPORT_JIT', false); tryDefineGlobal('CC_JSB', false); -const FORCE_BANNING_BULLET_WASM = false; +const WASM_SUPPORT_MODE = 0; -console.log(FORCE_BANNING_BULLET_WASM); +console.log(WASM_SUPPORT_MODE); " `; @@ -2727,6 +480,9 @@ exports[`engine-js enumerate dependents 1`] = ` "assets/wasm_rust-404aff2f.wasm", "assets/wasm_c-8515ca89.wasm", "wasm-test.js", + "wasm-test-1db8bc36.js", + "wasm_c-a7853123.js", + "wasm_c.wasm-7cf70cb9.js", "module", ] `; @@ -2734,6 +490,9 @@ exports[`engine-js enumerate dependents 1`] = ` exports[`engine-js enumerate dependents 2`] = ` [ "wasm-test.js", + "wasm-test-1db8bc36.js", + "wasm_c-a7853123.js", + "wasm_c.wasm-7cf70cb9.js", "module", ] `; @@ -2748,7 +507,6 @@ exports[`engine-js enumerate dependents 3`] = ` exports[`engine-js inline dynamic import for OH platform 1`] = ` [ "assets/wasm_c-8515ca89.wasm", - "assets/wasm_c.wasm.fallback-26103d05.bin", "assets/wasm_rust-404aff2f.wasm", "cc.js", ] diff --git a/test/build-engine/__snapshots__/engine-ts.test.ts.snap b/test/build-engine/__snapshots__/engine-ts.test.ts.snap index 1266a095..e4f1cb6a 100644 --- a/test/build-engine/__snapshots__/engine-ts.test.ts.snap +++ b/test/build-engine/__snapshots__/engine-ts.test.ts.snap @@ -33,40 +33,26 @@ export { Module as default }; ", "native/external/wasm/emscripten/wasm_c.js.mem.0e186.ts": "export default 'assets/wasm_c.js.mem';", "native/external/wasm/emscripten/wasm_c.wasm.195b9.ts": "export default '';", - "native/external/wasm/emscripten/wasm_c.wasm.fallback.f2f95.ts": "export default '';", - "native/external/wasm/emscripten/wasm_c.wasm.fallback.js.382fe.ts": "export default function () {}", "native/external/wasm/emscripten/wasm_c.wasm.js.0e998.ts": "let $: any;export default $;", - "wasm/emscripten.ts": "import { WASM_FALLBACK, WASM_SUPPORT_MODE } from "../__virtual__/internal_constants"; + "wasm/emscripten.ts": "import { WASM_SUPPORT_MODE } from "../__virtual__/internal_constants"; import { isSupportWASM } from './is-support-wasm'; -import wasmUrl from "../native/external/wasm/emscripten/wasm_c.wasm.195b9"; -import wasmFactory from "../native/external/wasm/emscripten/wasm_c.wasm.js.0e998"; import asmFactory from "../native/external/wasm/emscripten/wasm_c.asm.js.36955"; import asmJsMemUrl from "../native/external/wasm/emscripten/wasm_c.js.mem.0e186"; function initializeWasm(): Promise { - return new Promise((resolve, reject) => { - if (WASM_FALLBACK) { - Promise.all([window.__cc_module_context__.import("../native/external/wasm/emscripten/wasm_c.wasm.fallback.f2f95"), window.__cc_module_context__.import("../native/external/wasm/emscripten/wasm_c.wasm.fallback.js.382fe")]).then(([{ - default: wasmFallbackUrl - }, { - default: wasmFallbackFactory - }]) => { - return wasmFallbackFactory({ - locateFile(_) { - return wasmFallbackUrl; - } - }).then(inst => { - resolve(inst); - }).catch(reject); - }); - return; - } - wasmFactory({ - locateFile(_) { - return wasmUrl; - } - }).then(inst => { - resolve(inst); - }).catch(reject); + return Promise.all([window.__cc_module_context__.import("../native/external/wasm/emscripten/wasm_c.wasm.195b9"), window.__cc_module_context__.import("../native/external/wasm/emscripten/wasm_c.wasm.js.0e998")]).then(([{ + default: wasmUrl + }, { + default: wasmFactory + }]) => { + return new Promise((resolve, reject) => { + wasmFactory({ + locateFile(_) { + return wasmUrl; + } + }).then(inst => { + resolve(inst); + }).catch(reject); + }); }); } function initializeAsm(): Promise { @@ -117,8 +103,6 @@ exports[`WASM build WASM: get output dir structure 1`] = ` "native/external/wasm/emscripten/wasm_c.asm.js.36955.ts", "native/external/wasm/emscripten/wasm_c.js.mem.0e186.ts", "native/external/wasm/emscripten/wasm_c.wasm.195b9.ts", - "native/external/wasm/emscripten/wasm_c.wasm.fallback.f2f95.ts", - "native/external/wasm/emscripten/wasm_c.wasm.fallback.js.382fe.ts", "native/external/wasm/emscripten/wasm_c.wasm.js.0e998.ts", "native/external/wasm/wasm-pack/wasm_rust.js.ce353.ts", "native/external/wasm/wasm-pack/wasm_rust.wasm.ba172.ts", @@ -272,9 +256,6 @@ export const NET_MODE = 0; export const WEBGPU = false; export let WASM_SUPPORT_MODE = 0; export const EDITOR_NOT_IN_PREVIEW = false; -export const FORCE_BANNING_BULLET_WASM = false; -export const CULL_ASM_JS_MODULE = false; -export const WASM_FALLBACK = false; export const WASM_SUBPACKAGE = false; export const CULL_MESHOPT = false;", }, diff --git a/test/stats-query/__snapshots__/constant-manager.test.ts.snap b/test/stats-query/__snapshots__/constant-manager.test.ts.snap index f3f3b09f..d025ffc8 100644 --- a/test/stats-query/__snapshots__/constant-manager.test.ts.snap +++ b/test/stats-query/__snapshots__/constant-manager.test.ts.snap @@ -102,12 +102,6 @@ export const WEBGPU = false; export const WASM_SUPPORT_MODE = 1; -export const FORCE_BANNING_BULLET_WASM = true; - -export const CULL_ASM_JS_MODULE = true; - -export const WASM_FALLBACK = false; - export const WASM_SUBPACKAGE = false; export const CULL_MESHOPT = false; @@ -224,12 +218,6 @@ export const WASM_SUPPORT_MODE = 1; export const EDITOR_NOT_IN_PREVIEW = false; -export const FORCE_BANNING_BULLET_WASM = true; - -export const CULL_ASM_JS_MODULE = false; - -export const WASM_FALLBACK = false; - export const WASM_SUBPACKAGE = false; export const CULL_MESHOPT = false; @@ -245,13 +233,11 @@ exports[`genBuildTimeConstants 1`] = ` "BUILD": false, "BYTEDANCE": false, "COCOSPLAY": false, - "CULL_ASM_JS_MODULE": true, "CULL_MESHOPT": false, "DEBUG": false, "DEV": true, "EDITOR": false, "EDITOR_NOT_IN_PREVIEW": false, - "FORCE_BANNING_BULLET_WASM": true, "HTML5": false, "HUAWEI": false, "IOS": false, @@ -275,7 +261,6 @@ exports[`genBuildTimeConstants 1`] = ` "TAOBAO_MINIGAME": false, "TEST": true, "VIVO": false, - "WASM_FALLBACK": false, "WASM_SUBPACKAGE": false, "WASM_SUPPORT_MODE": 1, "WEBGPU": false, @@ -713,24 +698,6 @@ exports[`generateInternalConstants 1`] = ` */ export const EDITOR_NOT_IN_PREVIEW: boolean; - /** - * Whether force banning using bullet wasm and use asmjs instead. - */ - export const FORCE_BANNING_BULLET_WASM: boolean; - - /** - * Whether cull the asm js module - * The external modules ending with '.asm.js'. or '.js.mem' is culled if this constant is true. - */ - export const CULL_ASM_JS_MODULE: boolean; - - /** - * An internal constant to indicate whether need a fallback of wasm. - * If true, we build a wasm fallback module for the compatibility of wasm files compiled by different version of emscripten. - * This is useful when we use wasm on different version of Safari browsers. - */ - export const WASM_FALLBACK: boolean; - /** * An internal constant to indicate whether we use wasm assets as minigame subpackage. * This is useful when we need to reduce code size. From 27eb37556606836f5b3036687574e32afc0c5cc4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:22:12 +0800 Subject: [PATCH 11/13] Revert --- modules/build-engine/src/engine-js/index.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/modules/build-engine/src/engine-js/index.ts b/modules/build-engine/src/engine-js/index.ts index 2d6a7c42..fd27fc27 100644 --- a/modules/build-engine/src/engine-js/index.ts +++ b/modules/build-engine/src/engine-js/index.ts @@ -6,7 +6,6 @@ import realFs from 'fs'; import tsConfigPaths from './rollup-plugins/ts-paths'; import moduleQueryPlugin from './rollup-plugins/module-query-plugin'; import removeDeprecatedFeatures from './rollup-plugins/remove-deprecated-features'; -import { rpNamedChunk } from './rollup-plugins/systemjs-named-register-plugin'; import type { buildEngine } from '../index'; import { externalWasmLoader } from './rollup-plugins/external-wasm-loader'; import { StatsQuery } from '@ccbuild/stats-query'; @@ -305,7 +304,6 @@ export async function buildJsEngine(options: Required): Pro ...babelOptions, }), - // rpNamedChunk(), ); // if (options.progress) { From 1226b9bc0d210392d3ff05316a27ba5e1d665192 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 14:45:20 +0800 Subject: [PATCH 12/13] 2.1.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 97719995..c42dc0ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cocos/ccbuild", - "version": "2.0.3", + "version": "2.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cocos/ccbuild", - "version": "2.0.3", + "version": "2.1.0", "hasInstallScript": true, "license": "MIT", "workspaces": [ diff --git a/package.json b/package.json index 4484aa7d..78666580 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cocos/ccbuild", - "version": "2.0.3", + "version": "2.1.0", "description": "The next generation of build tool for Cocos engine.", "main": "./lib/index.js", "types": "./lib/index.d.ts", From 84256d3c6327090e180d17ba35d00ff9bfa0d042 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 9 Jan 2024 18:31:22 +0800 Subject: [PATCH 13/13] Fix a line ending issue on windows. --- .github/workflows/test.yaml | 13 +++++++++++-- .../rollup-plugins/external-wasm-loader.ts | 4 ++-- modules/stats-query/src/index.ts | 6 +++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0bd3a76a..f4387ae6 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,6 +1,6 @@ name: test run-name: ${{ github.actor }} - test -on: [pull_request] +on: [pull_request, push] jobs: test: strategy: @@ -14,6 +14,15 @@ jobs: with: node-version: '18.17.0' + - run: node --version + - run: npm --version + - run: npm ci - - run: npm test \ No newline at end of file + - run: npm test + + # - name: Upload Artifact + # uses: actions/upload-artifact@v3 + # with: + # name: ${{ matrix.os }} + # path: test/build-engine diff --git a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts index af8f9080..74dd7938 100644 --- a/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts +++ b/modules/build-engine/src/engine-js/rollup-plugins/external-wasm-loader.ts @@ -255,12 +255,12 @@ export function externalWasmLoader (options: externalWasmLoader.Options): rollup } else if (config.shouldEmitAsset(options, id)) { return emitAsset(this, filePath); } else { - return await fs.readFile(filePath, 'utf8'); + return (await fs.readFile(filePath, 'utf8')).replace(/\r\n/g, '\n'); } } } // some external module that doesn't obey the suffix specification, we return its content by default. - return await fs.readFile(filePath, 'utf8'); + return (await fs.readFile(filePath, 'utf8')).replace(/\r\n/g, '\n'); } return null; }, diff --git a/modules/stats-query/src/index.ts b/modules/stats-query/src/index.ts index c9ceeb2e..7c75380e 100644 --- a/modules/stats-query/src/index.ts +++ b/modules/stats-query/src/index.ts @@ -358,10 +358,10 @@ export namespace StatsQuery { // init helper let result = ''; if (this._hasCCGlobal(config)) { - result += fs.readFileSync(ps.join(__dirname, '../../../static/helper-global-exporter.txt'), 'utf8') + '\n'; + result += fs.readFileSync(ps.join(__dirname, '../../../static/helper-global-exporter.txt'), 'utf8').replace(/\r\n/g, '\n') + '\n'; } if (this._hasDynamic(config)) { - result += fs.readFileSync(ps.join(__dirname, '../../../static/helper-dynamic-constants.txt'), 'utf8') + '\n'; + result += fs.readFileSync(ps.join(__dirname, '../../../static/helper-dynamic-constants.txt'), 'utf8').replace(/\r\n/g, '\n') + '\n'; } // update value @@ -448,7 +448,7 @@ export namespace StatsQuery { // init helper let result = ''; if (this._hasCCGlobal(config)) { - result += fs.readFileSync(ps.join(__dirname, '../../../static/helper-global-exporter.txt'), 'utf8') + '\n'; + result += fs.readFileSync(ps.join(__dirname, '../../../static/helper-global-exporter.txt'), 'utf8').replace(/\r\n/g, '\n') + '\n'; } // update value