mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
Bytedance mini-game WASM support for both android and iOS platforms. (#16644)
This commit is contained in:
@@ -64,6 +64,9 @@ if (WECHAT) {
|
||||
let isVersionGreaterOrEqualTo;
|
||||
if (BYTEDANCE) {
|
||||
isVersionGreaterOrEqualTo = function isVersionGreaterOrEqualTo (versionA: string, versionB: string): boolean {
|
||||
if (!versionA || !versionB) {
|
||||
return false;
|
||||
}
|
||||
// Split the version number string into an array of integers
|
||||
function parseVersion (version: string): number[] {
|
||||
return version.split('.').map((part: string) => parseInt(part, 10));
|
||||
@@ -167,9 +170,15 @@ class SystemInfo extends EventTarget {
|
||||
}
|
||||
|
||||
if (BYTEDANCE) {
|
||||
let minSDKVersionSupportWasm = '';
|
||||
if (this.os === OS.ANDROID) {
|
||||
minSDKVersionSupportWasm = '3.9.0';
|
||||
} else if (this.os === OS.IOS) {
|
||||
minSDKVersionSupportWasm = '3.8.0';
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-expect-error TTWebAssembly is defined if bytedance client supports wasm.
|
||||
if (isVersionGreaterOrEqualTo(minigameSysInfo.SDKVersion, '3.7.0') && typeof TTWebAssembly === 'object') {
|
||||
if (isVersionGreaterOrEqualTo(minigameSysInfo.SDKVersion, minSDKVersionSupportWasm) && typeof TTWebAssembly === 'object') {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,8 @@ if (!GameGlobal.__isAdapterInjected) {
|
||||
GameGlobal.__isAdapterInjected = true;
|
||||
inject();
|
||||
}
|
||||
//NOTE: Don't override global `WebAssembly` variable since bytedance platform has a bug that will cause TTWebAssembly.instantiate fails.
|
||||
// So we add our own `CCWebAssembly` variable here.
|
||||
global.CCWebAssembly = global.TTWebAssembly;
|
||||
|
||||
global.WebAssembly = global.CCWebAssembly = global.TTWebAssembly;
|
||||
|
||||
require('../../../../common/xmldom/dom-parser');
|
||||
require('../unify');
|
||||
|
||||
Reference in New Issue
Block a user