fixed #16248: .wasm / .asm.js files are both downloaded on web platform (#16679)

This commit is contained in:
James Chen
2024-01-11 15:30:05 +08:00
committed by GitHub
parent 82ee6a32a5
commit 75c6f6d16d
12 changed files with 133 additions and 132 deletions
+3 -3
View File
@@ -650,10 +650,10 @@
"value": false,
"internal": true
},
"WASM_SUPPORT_MODE": {
"comment": "Whether support wasm, here we provide 3 options:\n0: The platform doesn't support WASM\n1: The platform supports WASM\n2: The platform may support WASM, especially on Web platform",
"NATIVE_CODE_BUNDLE_MODE": {
"comment": "Native code (wasm/asmjs) bundle mode, 0: asmjs, 1: wasm, 2: both",
"type": "number",
"value": "($HTML5 || $BYTEDANCE) ? 2 : ($NATIVE ? (($OPEN_HARMONY||$IOS)?0:1): ($MINIGAME? ($WECHAT?1:0) :0))",
"value": 2,
"internal": true
},
"WASM_SUBPACKAGE": {
+19 -18
View File
@@ -21,13 +21,13 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { CULL_MESHOPT, WASM_SUPPORT_MODE } from 'internal:constants';
import { CULL_MESHOPT, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm';
import { sys, logID } from '../../core';
import { sys, logID, error } from '../../core';
import { game } from '../../game';
import { WebAssemblySupportMode } from '../../misc/webassembly-support';
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
export const MeshoptDecoder = {} as any;
@@ -63,9 +63,9 @@ function initDecoderWASM (wasm_factory: any, wasm_url: string): Promise<void> {
}
function shouldUseWasmModule (): boolean {
if (WASM_SUPPORT_MODE === (WebAssemblySupportMode.MAYBE_SUPPORT as number)) {
if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.BOTH as number)) {
return sys.hasFeature(sys.Feature.WASM);
} else if (WASM_SUPPORT_MODE === (WebAssemblySupportMode.SUPPORT as number)) {
} else if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.WASM as number)) {
return true;
} else {
return false;
@@ -73,21 +73,22 @@ function shouldUseWasmModule (): boolean {
}
export function InitDecoder (): Promise<void> {
return ensureWasmModuleReady().then(() => Promise.all([
import('external:emscripten/meshopt/meshopt_decoder.asm.js'),
import('external:emscripten/meshopt/meshopt_decoder.wasm.js'),
import('external:emscripten/meshopt/meshopt_decoder.wasm.wasm'),
]).then(([
{ default: meshopt_asm_factory },
{ default: meshopt_wasm_factory },
{ default: meshopt_wasm_url },
]) => {
if (shouldUseWasmModule() && meshopt_wasm_url) {
return initDecoderWASM(meshopt_wasm_factory, meshopt_wasm_url);
const errorReport = (msg: any): void => { error(msg); };
return ensureWasmModuleReady().then(() => {
if (shouldUseWasmModule()) {
return Promise.all([
import('external:emscripten/meshopt/meshopt_decoder.wasm.js'),
import('external:emscripten/meshopt/meshopt_decoder.wasm.wasm'),
]).then(([
{ default: meshopt_wasm_factory },
{ default: meshopt_wasm_url },
]) => initDecoderWASM(meshopt_wasm_factory, meshopt_wasm_url));
} else {
return initDecoderASM(meshopt_asm_factory);
return import('external:emscripten/meshopt/meshopt_decoder.asm.js').then(
({ default: meshopt_asm_factory }) => initDecoderASM(meshopt_asm_factory),
);
}
}));
}).catch(errorReport);
}
if (!CULL_MESHOPT) {
+5 -5
View File
@@ -1,8 +1,8 @@
/**
* An enum type for WASM_SUPPORT_MODE constant, making the support mode more readable.
* An enum type for NATIVE_CODE_BUNDLE_MODE constant, making the support mode more readable.
*/
export const enum WebAssemblySupportMode {
NONE = 0,
SUPPORT = 1,
MAYBE_SUPPORT = 2,
export const enum NativeCodeBundleMode {
ASMJS = 0,
WASM = 1,
BOTH = 2,
}
+17 -17
View File
@@ -23,11 +23,11 @@
*/
import { instantiateWasm, ensureWasmModuleReady } from 'pal/wasm';
import { WASM_SUPPORT_MODE } from 'internal:constants';
import { NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
import { game } from '../../game';
import { error, sys, IVec2Like, log } from '../../core';
import { WebAssemblySupportMode } from '../../misc/webassembly-support';
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
// eslint-disable-next-line import/no-mutable-exports
export let B2 = {} as any;
@@ -164,9 +164,9 @@ function initAsm (asmFactory): Promise<void> {
}
function shouldUseWasmModule (): boolean {
if (WASM_SUPPORT_MODE === WebAssemblySupportMode.MAYBE_SUPPORT as number) {
if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.BOTH as number)) {
return sys.hasFeature(sys.Feature.WASM);
} else if (WASM_SUPPORT_MODE === WebAssemblySupportMode.SUPPORT as number) {
} else if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.WASM as number)) {
return true;
} else {
return false;
@@ -175,21 +175,21 @@ function shouldUseWasmModule (): boolean {
export function waitForBox2dWasmInstantiation (): Promise<void> {
const errorReport = (msg: any): void => { error(msg); };
return ensureWasmModuleReady().then(() => Promise.all([
import('external:emscripten/box2d/box2d.release.wasm.js'),
import('external:emscripten/box2d/box2d.release.wasm.wasm'),
import('external:emscripten/box2d/box2d.release.asm.js'),
]).then(([
{ default: wasmFactory },
{ default: wasmUrl },
{ default: asmFactory },
]) => {
if (shouldUseWasmModule() && wasmUrl) {
return initWasm(wasmFactory, wasmUrl);
return ensureWasmModuleReady().then(() => {
if (shouldUseWasmModule()) {
return Promise.all([
import('external:emscripten/box2d/box2d.release.wasm.js'),
import('external:emscripten/box2d/box2d.release.wasm.wasm'),
]).then(([
{ default: wasmFactory },
{ default: wasmUrl },
]) => initWasm(wasmFactory, wasmUrl));
} else {
return initAsm(asmFactory);
return import('external:emscripten/box2d/box2d.release.asm.js').then(
({ default: asmFactory }) => initAsm(asmFactory),
);
}
})).catch(errorReport);
}).catch(errorReport);
}
game.onPostInfrastructureInitDelegate.add(waitForBox2dWasmInstantiation);
+17 -19
View File
@@ -23,10 +23,10 @@
*/
import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm';
import { WASM_SUPPORT_MODE } from 'internal:constants';
import { NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
import { game } from '../../game';
import { error, log, sys } from '../../core';
import { WebAssemblySupportMode } from '../../misc/webassembly-support';
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
//corresponds to bulletType in bullet-compile
export enum EBulletType{
@@ -126,11 +126,9 @@ function initASM (asmFactory): Promise<void> {
}
function shouldUseWasmModule (): boolean {
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
if (WASM_SUPPORT_MODE === WebAssemblySupportMode.MAYBE_SUPPORT) {
if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.BOTH as number)) {
return sys.hasFeature(sys.Feature.WASM);
// eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison
} else if (WASM_SUPPORT_MODE === WebAssemblySupportMode.SUPPORT) {
} else if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.WASM as number)) {
return true;
} else {
return false;
@@ -139,21 +137,21 @@ function shouldUseWasmModule (): boolean {
export function waitForAmmoInstantiation (): Promise<void> {
const errorReport = (msg: any): void => { error(msg); };
return ensureWasmModuleReady().then(() => Promise.all([
import('external:emscripten/bullet/bullet.release.wasm.js'),
import('external:emscripten/bullet/bullet.release.wasm.wasm'),
import('external:emscripten/bullet/bullet.release.asm.js'),
]).then(([
{ default: bulletWasmFactory },
{ default: bulletWasmUrl },
{ default: bulletAsmFactory },
]) => {
if (shouldUseWasmModule() && bulletWasmUrl) {
return initWASM(bulletWasmFactory, bulletWasmUrl);
return ensureWasmModuleReady().then(() => {
if (shouldUseWasmModule()) {
return Promise.all([
import('external:emscripten/bullet/bullet.release.wasm.js'),
import('external:emscripten/bullet/bullet.release.wasm.wasm'),
]).then(([
{ default: bulletWasmFactory },
{ default: bulletWasmUrl },
]) => initWASM(bulletWasmFactory, bulletWasmUrl));
} else {
return initASM(bulletAsmFactory);
return import('external:emscripten/bullet/bullet.release.asm.js').then(
({ default: bulletAsmFactory }) => initASM(bulletAsmFactory),
);
}
})).catch(errorReport);
}).catch(errorReport);
}
game.onPostInfrastructureInitDelegate.add(waitForAmmoInstantiation);
+38 -38
View File
@@ -30,10 +30,10 @@
/* eslint-disable no-lonely-if */
/* eslint-disable import/order */
import { WebAssemblySupportMode } from '../../misc/webassembly-support';
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
import { ensureWasmModuleReady, instantiateWasm } from 'pal/wasm';
import { BYTEDANCE, DEBUG, EDITOR, TEST, WASM_SUPPORT_MODE } from 'internal:constants';
import { IQuatLike, IVec3Like, Quat, RecyclePool, Vec3, cclegacy, geometry, Settings, settings, sys, Color } from '../../core';
import { BYTEDANCE, DEBUG, EDITOR, TEST, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
import { IQuatLike, IVec3Like, Quat, RecyclePool, Vec3, cclegacy, geometry, Settings, settings, sys, Color, error, IVec3 } from '../../core';
import { shrinkPositions } from '../utils/util';
import { IRaycastOptions } from '../spec/i-physics-world';
import { IPhysicsConfig, PhysicsRayResult, PhysicsSystem, CharacterControllerContact } from '../framework';
@@ -67,23 +67,22 @@ export function InitPhysXLibs (): Promise<void> {
resolve();
});
} else {
return ensureWasmModuleReady().then(() => Promise.all([
import('external:emscripten/physx/physx.release.wasm.js'),
import('external:emscripten/physx/physx.release.wasm.wasm'),
import('external:emscripten/physx/physx.release.asm.js'),
]).then(([
{ default: physxWasmFactory },
{ default: physxWasmUrl },
{ default: physxAsmFactory },
]) => InitPhysXLibsInternal(physxWasmFactory, physxWasmUrl, physxAsmFactory)));
}
}
function InitPhysXLibsInternal (physxWasmFactory, physxWasmUrl: string, physxAsmFactory): any {
if (shouldUseWasmModule() && physxWasmUrl) {
return initWASM(physxWasmFactory, physxWasmUrl);
} else {
return initASM(physxAsmFactory);
const errorReport = (msg: any): void => { error(msg); };
return ensureWasmModuleReady().then(() => {
if (shouldUseWasmModule()) {
return Promise.all([
import('external:emscripten/physx/physx.release.wasm.js'),
import('external:emscripten/physx/physx.release.wasm.wasm'),
]).then(([
{ default: physxWasmFactory },
{ default: physxWasmUrl },
]) => initWASM(physxWasmFactory, physxWasmUrl));
} else {
return import('external:emscripten/physx/physx.release.asm.js').then(
({ default: physxAsmFactory }) => initASM(physxAsmFactory),
);
}
}).catch(errorReport);
}
}
@@ -131,9 +130,9 @@ function initWASM (physxWasmFactory, physxWasmUrl: string): any {
}
function shouldUseWasmModule (): boolean {
if (WASM_SUPPORT_MODE === WebAssemblySupportMode.MAYBE_SUPPORT) {
if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.BOTH as number)) {
return sys.hasFeature(sys.Feature.WASM);
} else if (WASM_SUPPORT_MODE === WebAssemblySupportMode.SUPPORT) {
} else if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.WASM as number)) {
return true;
} else {
return false;
@@ -286,22 +285,22 @@ export function copyPhysXTransform (node: Node, transform: any): void {
const dontUpdate = physXEqualsCocosVec3(transform, wp) && physXEqualsCocosQuat(transform, wr);
if (dontUpdate) return;
if (USE_BYTEDANCE) {
node.setWorldPosition(transform.p);
node.setWorldRotation(transform.q);
node.setWorldPosition(transform.p as Vec3);
node.setWorldRotation(transform.q as Quat);
} else {
node.setWorldPosition(transform.translation);
node.setWorldRotation(transform.rotation);
node.setWorldPosition(transform.translation as Vec3);
node.setWorldRotation(transform.rotation as Quat);
}
}
export function physXEqualsCocosVec3 (trans: any, v3: IVec3Like): boolean {
const pos = USE_BYTEDANCE ? trans.p : trans.translation;
return Vec3.equals(pos, v3, PX.EPSILON);
return Vec3.equals(pos as IVec3Like, v3, PX.EPSILON as number);
}
export function physXEqualsCocosQuat (trans: any, q: IQuatLike): boolean {
const rot = USE_BYTEDANCE ? trans.q : trans.rotation;
return Quat.equals(rot, q, PX.EPSILON);
return Quat.equals(rot as IQuatLike, q, PX.EPSILON as number);
}
export function applyImpulse (isGlobal: boolean, impl: any, vec: IVec3Like, rp: IVec3Like): void {
@@ -351,13 +350,14 @@ export function getShapeFlags (isTrigger: boolean): any {
return new PX.PxShapeFlags(flag);
}
// eslint-disable-next-line default-param-last
export function getShapeWorldBounds (shape: any, actor: any, i = 1.01, out: geometry.AABB): void {
if (USE_BYTEDANCE) {
const b3 = PX.RigidActorExt.getWorldBounds(shape, actor, i);
geometry.AABB.fromPoints(out, b3.minimum, b3.maximum);
geometry.AABB.fromPoints(out, b3.minimum as IVec3, b3.maximum as IVec3);
} else {
const b3 = shape.getWorldBounds(actor, i);
geometry.AABB.fromPoints(out, b3.minimum, b3.maximum);
geometry.AABB.fromPoints(out, b3.minimum as IVec3, b3.maximum as IVec3);
}
}
@@ -592,7 +592,7 @@ export function raycastAll (
const block = r[i];
const collider = getWrapShape<PhysXShape>(block.shapeData).collider;
const result = pool.add();
result._assign(block.position, block.distance, collider, block.normal);
result._assign(block.position as IVec3Like, block.distance as number, collider, block.normal as IVec3Like);
results.push(result);
}
return true;
@@ -619,7 +619,7 @@ export function raycastAll (
const block = blocks.get(i);
const collider = getWrapShape<PhysXShape>(block.getShape()).collider;
const result = pool.add();
result._assign(block.position, block.distance, collider, block.normal);
result._assign(block.position as IVec3Like, block.distance as number, collider, block.normal as IVec3Like);
results.push(result);
}
return true;
@@ -654,7 +654,7 @@ export function raycastClosest (world: PhysXWorld, worldRay: geometry.Ray, optio
);
if (block) {
const collider = getWrapShape<PhysXShape>(block.shapeData).collider;
result._assign(block.position, block.distance, collider, block.normal);
result._assign(block.position as IVec3Like, block.distance as number, collider, block.normal as IVec3Like);
return true;
}
} else {
@@ -674,7 +674,7 @@ export function raycastClosest (world: PhysXWorld, worldRay: geometry.Ray, optio
);
if (r) {
const collider = getWrapShape<PhysXShape>(block.getShape()).collider;
result._assign(block.position, block.distance, collider, block.normal);
result._assign(block.position as IVec3Like, block.distance as number, collider, block.normal as IVec3Like);
return true;
}
}
@@ -722,7 +722,7 @@ export function sweepAll (
const block = blocks.get(i);
const collider = getWrapShape<PhysXShape>(block.getShape()).collider;
const result = pool.add();
result._assign(block.position, block.distance, collider, block.normal);
result._assign(block.position as IVec3Like, block.distance as number, collider, block.normal as IVec3Like);
results.push(result);
}
return true;
@@ -768,7 +768,7 @@ export function sweepClosest (
);
if (r) {
const collider = getWrapShape<PhysXShape>(block.getShape()).collider;
result._assign(block.position, block.distance, collider, block.normal);
result._assign(block.position as IVec3Like, block.distance as number, collider, block.normal as IVec3Like);
return true;
}
@@ -846,7 +846,7 @@ export function initializeWorld (world: any): void {
*/
export function getContactPosition (pxContactOrOffset: any, out: IVec3Like, buf: any): void {
if (USE_BYTEDANCE) {
Vec3.fromArray(out, new Float32Array(buf, pxContactOrOffset, 3));
Vec3.fromArray(out, new Float32Array(buf as ArrayBufferLike, pxContactOrOffset as number, 3));
} else {
Vec3.copy(out, pxContactOrOffset.position);
}
@@ -854,7 +854,7 @@ export function getContactPosition (pxContactOrOffset: any, out: IVec3Like, buf:
export function getContactNormal (pxContactOrOffset: any, out: IVec3Like, buf: any): void {
if (USE_BYTEDANCE) {
Vec3.fromArray(out, new Float32Array(buf, (pxContactOrOffset as number) + 12, 3));
Vec3.fromArray(out, new Float32Array(buf as ArrayBufferLike, (pxContactOrOffset as number) + 12, 3));
} else {
Vec3.copy(out, pxContactOrOffset.normal);
}
+21 -19
View File
@@ -23,10 +23,10 @@
*/
import { instantiateWasm, fetchBuffer, ensureWasmModuleReady } from 'pal/wasm';
import { JSB, WASM_SUPPORT_MODE } from 'internal:constants';
import { JSB, NATIVE_CODE_BUNDLE_MODE } from 'internal:constants';
import { game } from '../../game';
import { getError, error, sys } from '../../core';
import { WebAssemblySupportMode } from '../../misc/webassembly-support';
import { NativeCodeBundleMode } from '../../misc/webassembly-support';
import { overrideSpineDefine } from './spine-define';
const PAGESIZE = 65536; // 64KiB
@@ -88,9 +88,9 @@ function initAsmJS (asmFactory, asmJsMemUrl: string): Promise<void> {
}
function shouldUseWasmModule (): boolean {
if (WASM_SUPPORT_MODE === WebAssemblySupportMode.MAYBE_SUPPORT) {
if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.BOTH as number)) {
return sys.hasFeature(sys.Feature.WASM);
} else if (WASM_SUPPORT_MODE === WebAssemblySupportMode.SUPPORT) {
} else if (NATIVE_CODE_BUNDLE_MODE === (NativeCodeBundleMode.WASM as number)) {
return true;
} else {
return false;
@@ -99,23 +99,25 @@ function shouldUseWasmModule (): boolean {
export function waitForSpineWasmInstantiation (): Promise<void> {
const errorReport = (msg: any): void => { error(msg); };
return ensureWasmModuleReady().then(() => Promise.all([
import('external:emscripten/spine/spine.asm.js'),
import('external:emscripten/spine/spine.js.mem'),
import('external:emscripten/spine/spine.wasm.js'),
import('external:emscripten/spine/spine.wasm'),
]).then(([
{ default: asmFactory },
{ default: asmJsMemUrl },
{ default: wasmFactory },
{ default: spineWasmUrl },
]) => {
if (shouldUseWasmModule() && spineWasmUrl) {
return initWasm(wasmFactory, spineWasmUrl);
return ensureWasmModuleReady().then(() => {
if (shouldUseWasmModule()) {
return Promise.all([
import('external:emscripten/spine/spine.wasm.js'),
import('external:emscripten/spine/spine.wasm'),
]).then(([
{ default: wasmFactory },
{ default: spineWasmUrl },
]) => initWasm(wasmFactory, spineWasmUrl));
} else {
return initAsmJS(asmFactory, asmJsMemUrl);
return Promise.all([
import('external:emscripten/spine/spine.asm.js'),
import('external:emscripten/spine/spine.js.mem'),
]).then(([
{ default: asmFactory },
{ default: asmJsMemUrl },
]) => initAsmJS(asmFactory, asmJsMemUrl));
}
})).catch(errorReport);
}).catch(errorReport);
}
if (!JSB) {
+4 -4
View File
@@ -27,7 +27,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { WASM_SUPPORT_MODE, WEBGPU } from 'internal:constants';
import { NATIVE_CODE_BUNDLE_MODE, WEBGPU } from 'internal:constants';
import webgpuUrl from 'external:emscripten/webgpu/webgpu_wasm.wasm';
import glslangUrl from 'external:emscripten/webgpu/glslang.wasm';
import twgslUrl from 'external:emscripten/webgpu/twgsl.wasm'
@@ -36,7 +36,7 @@ import wasmDevice from 'external:emscripten/webgpu/webgpu_wasm.js';
import glslangLoader from 'external:emscripten/webgpu/glslang.js';
import twgslLoader from 'external:emscripten/webgpu/twgsl.js'
import { legacyCC } from '../core/global-exports';
import { WebAssemblySupportMode } from '../misc/webassembly-support';
import { NativeCodeBundleMode } from '../misc/webassembly-support';
export const glslangWasmModule: any = {
glslang: null,
@@ -57,7 +57,7 @@ export const webgpuAdapter: any = {
};
export const promiseForWebGPUInstantiation = (() => {
if (WEBGPU && WASM_SUPPORT_MODE !== WebAssemblySupportMode.NONE) {
if (WEBGPU && NATIVE_CODE_BUNDLE_MODE !== NativeCodeBundleMode.ASMJS) {
// TODO: we need to support AsmJS fallback option
return Promise.all([
glslangLoader(new URL(glslangUrl, import.meta.url).href).then((res) => {
@@ -92,7 +92,7 @@ export const promiseForWebGPUInstantiation = (() => {
return Promise.resolve();
})();
if (WEBGPU && WASM_SUPPORT_MODE !== WebAssemblySupportMode.NONE) {
if (WEBGPU && NATIVE_CODE_BUNDLE_MODE !== NativeCodeBundleMode.ASMJS) {
const intervalId = setInterval(() => {
if (legacyCC.game) {
legacyCC.game.onPreInfrastructureInitDelegate.add(() => promiseForWebGPUInstantiation);
+4 -4
View File
@@ -13,7 +13,7 @@
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@cocos/box2d": "1.0.1",
"@cocos/cannon": "1.2.8",
"@cocos/ccbuild": "~2.1.0",
"@cocos/ccbuild": "2.2.1",
"@cocos/dragonbones-js": "^1.0.1"
},
"devDependencies": {
@@ -2330,9 +2330,9 @@
}
},
"node_modules/@cocos/ccbuild": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@cocos/ccbuild/-/ccbuild-2.1.0.tgz",
"integrity": "sha512-9vAaFn/uAvqr9mWwRA546DMhESUttr3VKmICJOE/RaCg9aQpYC73Z7RJTiF4luqy1GoaFPOhiTrQUVngQ16lBQ==",
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/@cocos/ccbuild/-/ccbuild-2.2.1.tgz",
"integrity": "sha512-ssmn2V0VnmgW1muTJPKmTHDyjL1xkQDIwcW68lUgmm4nDC1bDSh/AfOV4dYuPJDPLUShHFCcqOLaLVO/bNtArg==",
"dependencies": {
"@babel/core": "^7.20.12",
"@babel/helper-module-imports": "7.18.6",
+1 -1
View File
@@ -81,7 +81,7 @@
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@cocos/box2d": "1.0.1",
"@cocos/cannon": "1.2.8",
"@cocos/ccbuild": "~2.1.0",
"@cocos/ccbuild": "2.2.1",
"@cocos/dragonbones-js": "^1.0.1"
}
}
+2 -2
View File
@@ -107,9 +107,9 @@ export enum Feature {
*/
EVENT_HANDHELD = 'EVENT_HANDHELD',
/**
* @en Check whether Webassembly is supported at runtime. Generally, it needs to be checked when the constant `WASM_SUPPORT_MODE` is 2.
* @en Check whether Webassembly is supported at runtime. Generally, it needs to be checked when the constant `NATIVE_CODE_BUNDLE_MODE` is 2.
* If it is not supported, you need to fallback to the Asm solution.
* @zh 运行时检测是否支持 Webassembly,一般在宏 `WASM_SUPPORT_MODE` 为 2 时需要检测,如果不支持,需要回滚到 Asm 方案
* @zh 运行时检测是否支持 Webassembly,一般在宏 `NATIVE_CODE_BUNDLE_MODE` 为 2 时需要检测,如果不支持,需要回滚到 Asm 方案
*/
WASM = 'WASM',
}
+2 -2
View File
@@ -1,4 +1,4 @@
import { WebAssemblySupportMode } from "../cocos/misc/webassembly-support";
import { NativeCodeBundleMode } from "../cocos/misc/webassembly-support";
const _globalThis = typeof global === 'undefined' ? globalThis : global;
const _global = typeof window === 'undefined' ? _globalThis : window;
@@ -41,4 +41,4 @@ export const VIVO = tryDefineGlobal('CC_VIVO', false);
// @ts-expect-error: 'loadRuntime' exits only in runtime environment.
export const SUPPORT_JIT = tryDefineGlobal('CC_SUPPORT_JIT', (typeof loadRuntime === 'function'));
export const SERVER_MODE = false;
export const WASM_SUPPORT_MODE = WebAssemblySupportMode.SUPPORT;
export const NATIVE_CODE_BUNDLE_MODE = NativeCodeBundleMode.WASM;