Skip to content

Commit

Permalink
[v3.8.6] Continue to remove unused platforms support. (#17902)
Browse files Browse the repository at this point in the history
* Continue to remove unused platforms support.
  • Loading branch information
dumganhar authored Nov 22, 2024
1 parent 4eb1074 commit 667005f
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 118 deletions.
35 changes: 2 additions & 33 deletions cc.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,6 @@
"value": false,
"internal": false
},
"BAIDU": {
"comment": "Running in the baidu's mini game.",
"type": "boolean",
"value": false,
"ccGlobal": true,
"internal": false
},
"XIAOMI": {
"comment": "Running in the xiaomi's quick game.",
"type": "boolean",
Expand Down Expand Up @@ -539,35 +532,13 @@
"ccGlobal": true,
"internal": false
},
"COCOSPLAY": {
"comment": "Running in the cocosplay.",
"type": "boolean",
"value": false,
"ccGlobal": true,
"internal": false
},
"QTT": {
"comment": "Running in the qtt's quick game.",
"type": "boolean",
"value": false,
"ccGlobal": true,
"internal": false
},
"LINKSURE": {
"comment": "Running in the linksure's quick game.",
"type": "boolean",
"value": false,
"ccGlobal": true,
"internal": false
},
"MIGU": {
"comment": "Running in the migu's quick game.",
"type": "boolean",
"value": false,
"ccGlobal": true,
"internal": false
},

"EDITOR": {
"comment": "Running in the editor.",
"type": "boolean",
Expand Down Expand Up @@ -622,8 +593,6 @@
"value": false,
"internal": true
},


"DEV": {
"comment": "Running in the editor or preview.",
"type": "boolean",
Expand All @@ -635,14 +604,14 @@
"MINIGAME": {
"comment": "Running in mini game.",
"type": "boolean",
"value": "$WECHAT || $WECHAT_MINI_PROGRAM || $BAIDU || $XIAOMI || $ALIPAY || $TAOBAO || $TAOBAO_MINIGAME || $BYTEDANCE",
"value": "$WECHAT || $WECHAT_MINI_PROGRAM || $XIAOMI || $ALIPAY || $TAOBAO || $TAOBAO_MINIGAME || $BYTEDANCE",
"ccGlobal": true,
"internal": false
},
"RUNTIME_BASED": {
"comment": "Running in runtime based environment.",
"type": "boolean",
"value": "$OPPO || $VIVO || $HUAWEI || $COCOSPLAY || $QTT || $LINKSURE || $MIGU",
"value": "$OPPO || $VIVO || $HUAWEI || $MIGU",
"ccGlobal": true,
"internal": false
},
Expand Down
4 changes: 2 additions & 2 deletions cocos/asset/assets/image-asset.jsb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import { ALIPAY, XIAOMI, JSB, TEST, BAIDU, EDITOR } from 'internal:constants';
import { ALIPAY, XIAOMI, JSB, TEST, EDITOR } from 'internal:constants';
import { Format, FormatFeatureBit, deviceManager } from '../../gfx';
import { PixelFormat } from './asset-enum';
import { sys, macro, warnID, cclegacy } from '../../core';
Expand Down Expand Up @@ -54,7 +54,7 @@ function isImageBitmap (imageSource: any): boolean {
}

function isNativeImage (imageSource: ImageSource): imageSource is (HTMLImageElement | HTMLCanvasElement | ImageBitmap) {
if (ALIPAY || XIAOMI || BAIDU) {
if (ALIPAY || XIAOMI) {
// We're unable to grab the constructors of Alipay native image or canvas object.
return !('_data' in imageSource);
}
Expand Down
4 changes: 2 additions & 2 deletions cocos/asset/assets/image-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

// @ts-check
import { ccclass, override } from 'cc.decorator';
import { EDITOR, ALIPAY, XIAOMI, JSB, TEST, BAIDU, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM, BYTEDANCE } from 'internal:constants';
import { EDITOR, ALIPAY, XIAOMI, JSB, TEST, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM, BYTEDANCE } from 'internal:constants';
import { Device, Format, FormatFeatureBit, deviceManager } from '../../gfx';
import { Asset } from './asset';
import { PixelFormat } from './asset-enum';
Expand Down Expand Up @@ -163,7 +163,7 @@ function fetchImageSource (imageSource: ImageSource): HTMLCanvasElement | HTMLIm

// 返回该图像源是否是平台提供的图像对象。
function isNativeImage (imageSource: ImageSource): imageSource is (HTMLImageElement | HTMLCanvasElement | ImageBitmap) {
if (ALIPAY || TAOBAO || TAOBAO_MINIGAME || XIAOMI || BAIDU || WECHAT_MINI_PROGRAM || BYTEDANCE) {
if (ALIPAY || TAOBAO || TAOBAO_MINIGAME || XIAOMI || WECHAT_MINI_PROGRAM || BYTEDANCE) {
// We're unable to grab the constructors of Alipay native image or canvas object.
return !('_data' in imageSource);
}
Expand Down
39 changes: 27 additions & 12 deletions cocos/core/platform/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ markAsWarning(sys, 'sys', [
]);

// deprecate languageCode field
replaceProperty(sys, 'sys',
replaceProperty(
sys,
'sys',
['UNKNOWN', 'ENGLISH', 'CHINESE', 'FRENCH', 'ITALIAN',
'GERMAN', 'SPANISH', 'DUTCH', 'RUSSIAN', 'KOREAN',
'JAPANESE', 'HUNGARIAN', 'PORTUGUESE', 'ARABIC', 'NORWEGIAN',
Expand All @@ -52,19 +54,25 @@ replaceProperty(sys, 'sys',
newName: item,
target: sys.Language,
targetName: 'sys.Language',
})));
})),
);

// deprecate os field
replaceProperty(sys, 'sys',
replaceProperty(
sys,
'sys',
['UNKNOWN', 'IOS', 'ANDROID', 'WINDOWS', 'LINUX', 'OSX'].map((item) => ({
name: `OS_${item}`,
newName: item,
target: sys.OS,
targetName: 'sys.OS',
})));
})),
);

// deprecate browserType field
replaceProperty(sys, 'sys',
replaceProperty(
sys,
'sys',
['UNKNOWN', 'WECHAT', 'ANDROID', 'IE', 'EDGE', 'QQ', 'MOBILE_QQ',
'UC', 'UCBS', 'BAIDU_APP', 'BAIDU', 'MAXTHON', 'OPERA',
'OUPENG', 'MIUI', 'FIREFOX', 'SAFARI', 'CHROME', 'LIEBAO',
Expand All @@ -73,7 +81,8 @@ replaceProperty(sys, 'sys',
newName: item,
target: sys.BrowserType,
targetName: 'sys.BrowserType',
})));
})),
);
replaceProperty(sys, 'sys', [
{
name: 'BROWSER_TYPE_360',
Expand All @@ -84,14 +93,17 @@ replaceProperty(sys, 'sys', [
]);

// deprecate platform field
replaceProperty(sys, 'sys',
replaceProperty(
sys,
'sys',
['UNKNOWN', 'EDITOR_PAGE', 'EDITOR_CORE', 'MOBILE_BROWSER', 'DESKTOP_BROWSER', 'WIN32', 'MACOS', 'IOS', 'ANDROID', 'OHOS',
'WECHAT_GAME', 'BAIDU_MINI_GAME', 'XIAOMI_QUICK_GAME', 'ALIPAY_MINI_GAME', 'BYTEDANCE_MINI_GAME',
'OPPO_MINI_GAME', 'VIVO_MINI_GAME', 'HUAWEI_QUICK_GAME', 'COCOSPLAY', 'LINKSURE_MINI_GAME', 'QTT_MINI_GAME'].map((item) => ({
'WECHAT_GAME', 'XIAOMI_QUICK_GAME', 'ALIPAY_MINI_GAME', 'BYTEDANCE_MINI_GAME',
'OPPO_MINI_GAME', 'VIVO_MINI_GAME', 'HUAWEI_QUICK_GAME'].map((item) => ({
name: item,
target: sys.Platform,
targetName: 'sys.Platform',
})));
})),
);

// remove platform field
replaceProperty(sys, 'sys', [
Expand All @@ -108,11 +120,14 @@ replaceProperty(sys, 'sys', [
targetName: 'sys.Platform',
},
]);
removeProperty(sys, 'sys',
removeProperty(
sys,
'sys',
['LINUX', 'BLACKBERRY', 'NACL', 'EMSCRIPTEN', 'TIZEN',
'WINRT', 'WP8', 'QQ_PLAY', 'FB_PLAYABLE_ADS'].map((item) => ({
name: item,
})));
})),
);
replaceProperty(sys, 'sys', [
{
name: 'windowPixelResolution',
Expand Down
4 changes: 2 additions & 2 deletions cocos/gfx/webgl/webgl-swapchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import { ALIPAY, RUNTIME_BASED, BYTEDANCE, WECHAT, LINKSURE, QTT, COCOSPLAY, HUAWEI, EDITOR, VIVO, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants';
import { ALIPAY, RUNTIME_BASED, BYTEDANCE, WECHAT, HUAWEI, EDITOR, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants';
import { systemInfo } from 'pal/system-info';
import { WebGLStateCache } from './webgl-state-cache';
import { WebGLTexture } from './webgl-texture';
Expand Down Expand Up @@ -149,7 +149,7 @@ export function getExtensions (gl: WebGLRenderingContext): IWebGLExtensions {

if (RUNTIME_BASED) {
// VAO implementations doesn't work well on some runtime platforms
if (LINKSURE || QTT || COCOSPLAY || HUAWEI) {
if (HUAWEI) {
res.OES_vertex_array_object$ = null;
}
}
Expand Down
9 changes: 2 additions & 7 deletions cocos/scene-graph/scene-globals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
ccclass, visible, type, displayOrder, readOnly, slide, range, rangeStep,
editable, serializable, rangeMin, tooltip, formerlySerializedAs, displayName,
} from 'cc.decorator';
import { BAIDU } from 'internal:constants';

import { TextureCube } from '../asset/assets/texture-cube';
import { CCFloat, CCInteger } from '../core/data/utils/attribute';
import { Color, Quat, Vec3, Vec2, Vec4 } from '../core/math';
Expand Down Expand Up @@ -862,11 +862,6 @@ export class ShadowsInfo {
}
}
get enabled (): boolean {
if (BAIDU) {
if (this._type !== ShadowType.Planar) {
this._enabled = false;
}
}
return this._enabled;
}

Expand Down Expand Up @@ -1708,7 +1703,7 @@ export class SceneGlobals {
this.skin.activate(sceneData.skin);
this.postSettings.activate(sceneData.postSettings);
if (this.lightProbeInfo && sceneData.lightProbes) {
this.lightProbeInfo.activate(scene, sceneData.lightProbes as LightProbes);
this.lightProbeInfo.activate(scene, sceneData.lightProbes);
}

const root = legacyCC.director.root as Root;
Expand Down
5 changes: 1 addition & 4 deletions pal/env/minigame/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

/* eslint-disable import/no-dynamic-require */
import { BAIDU, TAOBAO, TAOBAO_MINIGAME, WECHAT, WECHAT_MINI_PROGRAM, XIAOMI } from 'internal:constants';
import { TAOBAO, TAOBAO_MINIGAME, WECHAT, WECHAT_MINI_PROGRAM, XIAOMI } from 'internal:constants';
import { checkPalIntegrity, withImpl } from '../../integrity-check';

declare const require: (path: string) => any;
Expand All @@ -40,9 +40,6 @@ export function loadJsFile (path: string): any {
if (XIAOMI) {
return require(`../../${path}`);
}
if (BAIDU) {
return __baiduRequire(`./${path}`);
}
if (WECHAT || WECHAT_MINI_PROGRAM) {
return __wxRequire(path);
}
Expand Down
13 changes: 3 additions & 10 deletions pal/env/runtime/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,16 @@
THE SOFTWARE.
*/

import { COCOSPLAY, HUAWEI, OPPO, VIVO } from 'internal:constants';
import { HUAWEI, OPPO, VIVO } from 'internal:constants';
import { checkPalIntegrity, withImpl } from '../../integrity-check';

declare const require: (path: string) => Promise<void>;
declare const ral: any;

export function findCanvas (): { frame: HTMLDivElement, container: HTMLDivElement, canvas: HTMLCanvasElement } {
const container = document.createElement('div');
let frame;
if (COCOSPLAY) {
frame = {
clientWidth: window.innerWidth,
clientHeight: window.innerHeight,
} as any;
} else {
frame = container.parentNode === document.body ? document.documentElement : container.parentNode as any;
}
const frame = container.parentNode === document.body ? document.documentElement : container.parentNode as any;

let canvas;
if (VIVO) {
canvas = window.mainCanvas;
Expand Down
35 changes: 7 additions & 28 deletions pal/minigame/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import { COCOSPLAY, HUAWEI, LINKSURE, OPPO, QTT, VIVO } from 'internal:constants';
import { VIVO } from 'internal:constants';
import { SystemInfo, IMiniGame } from 'pal/minigame';
import { checkPalIntegrity, withImpl } from '../integrity-check';

Expand Down Expand Up @@ -66,17 +66,6 @@ Object.defineProperty(minigame, 'orientation', {
},
});

if (LINKSURE || COCOSPLAY) {
// TODO: update system info when view resized, currently the resize callback is not supported.
let cachedSystemInfo = ral.getSystemInfoSync() as SystemInfo;
minigame.onWindowResize?.(() => {
// update cached system info
cachedSystemInfo = ral.getSystemInfoSync() as SystemInfo;
});
minigame.getSystemInfoSync = function (): SystemInfo {
return cachedSystemInfo;
};
}
// #endregion SystemInfo

// #region Accelerometer
Expand Down Expand Up @@ -115,22 +104,12 @@ minigame.offAccelerometerChange = function (cb): void {
};
// #endregion Accelerometer

// NOTE: Audio playing crash on COCOSPLAY, need to play audio asynchronously.
if (COCOSPLAY) {
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(ral, {
onPlay: true, // polyfill for vivo
onPause: true,
onStop: true,
onSeek: true,
}, true);
} else {
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(ral, {
onPlay: true, // polyfill for vivo
onPause: true,
onStop: true,
onSeek: true,
});
}
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(ral, {
onPlay: true, // polyfill for vivo
onPause: true,
onStop: true,
onSeek: true,
});

// #region SafeArea
minigame.getSafeArea = function (): SafeArea {

Check warning on line 115 in pal/minigame/runtime.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unexpected unnamed function
Expand Down
4 changes: 0 additions & 4 deletions pal/system-info/enum-type/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export enum Platform {
// Minigame
WECHAT_GAME = 'WECHAT_GAME',
WECHAT_MINI_PROGRAM = 'WECHAT_MINI_PROGRAM',
BAIDU_MINI_GAME = 'BAIDU_MINI_GAME',
XIAOMI_QUICK_GAME = 'XIAOMI_QUICK_GAME',
ALIPAY_MINI_GAME = 'ALIPAY_MINI_GAME',
TAOBAO_CREATIVE_APP = 'TAOBAO_CREATIVE_APP',
Expand All @@ -49,8 +48,5 @@ export enum Platform {
OPPO_MINI_GAME = 'OPPO_MINI_GAME',
VIVO_MINI_GAME = 'VIVO_MINI_GAME',
HUAWEI_QUICK_GAME = 'HUAWEI_QUICK_GAME',
COCOSPLAY = 'COCOSPLAY',
LINKSURE_MINI_GAME = 'LINKSURE_MINI_GAME',
QTT_MINI_GAME = 'QTT_MINI_GAME',
MIGU_MINI_GAME = 'MIGU_MINI_GAME',
}
10 changes: 1 addition & 9 deletions pal/system-info/minigame/system-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import { ALIPAY, BAIDU, BYTEDANCE, COCOSPLAY, HUAWEI, LINKSURE, OPPO, QTT, VIVO, MIGU, WECHAT, XIAOMI, DEBUG, TEST, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants';
import { ALIPAY, BYTEDANCE, HUAWEI, OPPO, VIVO, MIGU, WECHAT, XIAOMI, DEBUG, TEST, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants';

Check warning on line 25 in pal/system-info/minigame/system-info.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

This line has a length of 156. Maximum allowed is 150
import { minigame } from 'pal/minigame';
import { IFeatureMap } from 'pal/system-info';
import { EventTarget } from '../../../cocos/core/event';
Expand All @@ -36,8 +36,6 @@ if (WECHAT) {
currentPlatform = Platform.WECHAT_GAME;
} else if (WECHAT_MINI_PROGRAM) {
currentPlatform = Platform.WECHAT_MINI_PROGRAM;
} else if (BAIDU) {
currentPlatform = Platform.BAIDU_MINI_GAME;
} else if (XIAOMI) {
currentPlatform = Platform.XIAOMI_QUICK_GAME;
} else if (ALIPAY) {
Expand All @@ -54,12 +52,6 @@ if (WECHAT) {
currentPlatform = Platform.VIVO_MINI_GAME;
} else if (HUAWEI) {
currentPlatform = Platform.HUAWEI_QUICK_GAME;
} else if (COCOSPLAY) {
currentPlatform = Platform.COCOSPLAY;
} else if (LINKSURE) {
currentPlatform = Platform.LINKSURE_MINI_GAME;
} else if (QTT) {
currentPlatform = Platform.QTT_MINI_GAME;
} else if (MIGU) {
currentPlatform = Platform.MIGU_MINI_GAME;
}
Expand Down
Loading

0 comments on commit 667005f

Please sign in to comment.