mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-19 14:52:40 +08:00
+16
-2
@@ -577,6 +577,13 @@
|
||||
"value": false,
|
||||
"internal": false
|
||||
},
|
||||
"XIAOMI": {
|
||||
"comment": "Running in the xiaomi's quick game.",
|
||||
"type": "boolean",
|
||||
"value": false,
|
||||
"ccGlobal": true,
|
||||
"internal": false
|
||||
},
|
||||
"ALIPAY": {
|
||||
"comment": "Running in the alipay's mini game.",
|
||||
"type": "boolean",
|
||||
@@ -624,6 +631,13 @@
|
||||
"ccGlobal": true,
|
||||
"internal": false
|
||||
},
|
||||
"MIGU": {
|
||||
"comment": "Running in the migu's quick game.",
|
||||
"type": "boolean",
|
||||
"value": false,
|
||||
"ccGlobal": true,
|
||||
"internal": false
|
||||
},
|
||||
"HONOR": {
|
||||
"comment": "Running in the honor's quick game.",
|
||||
"type": "boolean",
|
||||
@@ -724,14 +738,14 @@
|
||||
"MINIGAME": {
|
||||
"comment": "Running in mini game.",
|
||||
"type": "boolean",
|
||||
"value": "$WECHAT || $WECHAT_MINI_PROGRAM || $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 || $HONOR || $COCOS_RUNTIME || $SUD || $SUDV2",
|
||||
"value": "$OPPO || $VIVO || $HUAWEI || $MIGU || $HONOR || $COCOS_RUNTIME || $SUD || $SUDV2",
|
||||
"ccGlobal": true,
|
||||
"internal": false
|
||||
},
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { XIAOMI } from 'internal:constants';
|
||||
import { getError } from '../../core';
|
||||
import { ccwindow } from '../../core/global-exports';
|
||||
|
||||
@@ -33,7 +34,8 @@ export default function downloadDomImage (
|
||||
): HTMLImageElement {
|
||||
const img = new ccwindow.Image();
|
||||
|
||||
if (ccwindow.location.protocol !== 'file:') {
|
||||
// NOTE: on xiaomi platform, we need to force setting img.crossOrigin as 'anonymous'
|
||||
if (ccwindow.location.protocol !== 'file:' || XIAOMI) {
|
||||
img.crossOrigin = 'anonymous';
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { ALIPAY, JSB, TEST, EDITOR, NODEJS } from 'internal:constants';
|
||||
import { ALIPAY, XIAOMI, JSB, TEST, EDITOR, NODEJS } from 'internal:constants';
|
||||
import { Format, FormatFeatureBit, deviceManager } from '../../gfx';
|
||||
import { PixelFormat } from './asset-enum';
|
||||
import { sys, macro, warnID, cclegacy } from '../../core';
|
||||
@@ -54,7 +54,7 @@ function isImageBitmap (imageSource: any): boolean {
|
||||
}
|
||||
|
||||
function isNativeImage (imageSource: ImageSource): imageSource is (HTMLImageElement | HTMLCanvasElement | ImageBitmap) {
|
||||
if (ALIPAY) {
|
||||
if (ALIPAY || XIAOMI) {
|
||||
// We're unable to grab the constructors of Alipay native image or canvas object.
|
||||
return !('_data' in imageSource);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
// @ts-check
|
||||
import { ccclass, override } from 'cc.decorator';
|
||||
import { EDITOR, NODEJS, ALIPAY, JSB, TEST, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM, BYTEDANCE } from 'internal:constants';
|
||||
import { EDITOR, NODEJS, 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';
|
||||
@@ -163,7 +163,7 @@ function fetchImageSource (imageSource: ImageSource): HTMLCanvasElement | HTMLIm
|
||||
|
||||
// 返回该图像源是否是平台提供的图像对象。
|
||||
function isNativeImage (imageSource: ImageSource): imageSource is (HTMLImageElement | HTMLCanvasElement | ImageBitmap) {
|
||||
if (ALIPAY || TAOBAO || TAOBAO_MINIGAME || 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);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ replaceProperty(
|
||||
sys,
|
||||
'sys',
|
||||
['UNKNOWN', 'EDITOR_PAGE', 'EDITOR_CORE', 'MOBILE_BROWSER', 'DESKTOP_BROWSER', 'WIN32', 'MACOS', 'IOS', 'ANDROID', 'OHOS',
|
||||
'WECHAT_GAME', 'ALIPAY_MINI_GAME', 'BYTEDANCE_MINI_GAME',
|
||||
'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,
|
||||
|
||||
Vendored
+4
-1
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/* eslint-disable import/no-dynamic-require */
|
||||
import { TAOBAO, TAOBAO_MINIGAME, WECHAT, WECHAT_MINI_PROGRAM } 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;
|
||||
@@ -37,6 +37,9 @@ export function findCanvas (): { frame: HTMLDivElement, container: HTMLDivElemen
|
||||
}
|
||||
|
||||
export function loadJsFile (path: string): any {
|
||||
if (XIAOMI) {
|
||||
return require(`../../${path}`);
|
||||
}
|
||||
if (WECHAT || WECHAT_MINI_PROGRAM) {
|
||||
return __wxRequire(path);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright (c) 2022-2023 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { IMiniGame } from 'pal/minigame';
|
||||
import { checkPalIntegrity, withImpl } from '../integrity-check';
|
||||
import { Orientation } from '../screen-adapter/enum-type';
|
||||
import { cloneObject, createInnerAudioContextPolyfill } from '../utils';
|
||||
import { warn } from '../../cocos/core/platform/debug';
|
||||
|
||||
declare let qg: any;
|
||||
|
||||
const minigame: IMiniGame = {} as IMiniGame;
|
||||
cloneObject(minigame, qg);
|
||||
|
||||
// #region SystemInfo
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
minigame.isDevTool = false;
|
||||
|
||||
minigame.isLandscape = systemInfo.screenWidth > systemInfo.screenHeight;
|
||||
// init landscapeOrientation as LANDSCAPE_RIGHT
|
||||
const landscapeOrientation = Orientation.LANDSCAPE_RIGHT;
|
||||
// NOTE: onDeviceOrientationChange is not supported on this platform
|
||||
// qg.onDeviceOrientationChange((res) => {
|
||||
// if (res.value === 'landscape') {
|
||||
// landscapeOrientation = Orientation.LANDSCAPE_RIGHT;
|
||||
// } else if (res.value === 'landscapeReverse') {
|
||||
// landscapeOrientation = Orientation.LANDSCAPE_LEFT;
|
||||
// }
|
||||
// });
|
||||
Object.defineProperty(minigame, 'orientation', {
|
||||
get () {
|
||||
return minigame.isLandscape ? landscapeOrientation : Orientation.PORTRAIT;
|
||||
},
|
||||
});
|
||||
// #endregion SystemInfo
|
||||
|
||||
// #region TouchEvent
|
||||
minigame.onTouchStart = (cb): void => {
|
||||
window.canvas.ontouchstart = cb;
|
||||
};
|
||||
minigame.onTouchMove = (cb): void => {
|
||||
window.canvas.ontouchmove = cb;
|
||||
};
|
||||
minigame.onTouchEnd = (cb): void => {
|
||||
window.canvas.ontouchend = cb;
|
||||
};
|
||||
minigame.onTouchCancel = (cb): void => {
|
||||
window.canvas.ontouchcancel = cb;
|
||||
};
|
||||
// #endregion TouchEvent
|
||||
|
||||
// // Keyboard
|
||||
// globalAdapter.showKeyboard = function (res) {
|
||||
// res.confirmHold = true; // HACK: confirmHold not working on Xiaomi platform
|
||||
// qg.showKeyboard(res);
|
||||
// };
|
||||
|
||||
// #region Accelerometer
|
||||
let _customAccelerometerCb: AccelerometerChangeCallback | undefined;
|
||||
let _innerAccelerometerCb: AccelerometerChangeCallback | undefined;
|
||||
minigame.onAccelerometerChange = (cb: AccelerometerChangeCallback): void => {
|
||||
// qg.offAccelerometerChange() is not supported.
|
||||
// so we can only register AccelerometerChange callback, but can't unregister.
|
||||
if (!_innerAccelerometerCb) {
|
||||
_innerAccelerometerCb = (res: any): void => {
|
||||
let x = res.x;
|
||||
let y = res.y;
|
||||
if (minigame.isLandscape) {
|
||||
const orientationFactor = (landscapeOrientation === Orientation.LANDSCAPE_RIGHT ? 1 : -1);
|
||||
const tmp = x;
|
||||
x = -y * orientationFactor;
|
||||
y = tmp * orientationFactor;
|
||||
}
|
||||
|
||||
const standardFactor = -0.1;
|
||||
x *= standardFactor;
|
||||
y *= standardFactor;
|
||||
const resClone = {
|
||||
x,
|
||||
y,
|
||||
z: res.z,
|
||||
};
|
||||
_customAccelerometerCb?.(resClone);
|
||||
};
|
||||
qg.onAccelerometerChange(_innerAccelerometerCb);
|
||||
}
|
||||
_customAccelerometerCb = cb;
|
||||
};
|
||||
minigame.offAccelerometerChange = (cb?: AccelerometerChangeCallback): void => {
|
||||
// qg.offAccelerometerChange() is not supported.
|
||||
_customAccelerometerCb = undefined;
|
||||
};
|
||||
// #endregion Accelerometer
|
||||
|
||||
// #region InnerAudioContext
|
||||
minigame.createInnerAudioContext = createInnerAudioContextPolyfill(qg, {
|
||||
onPlay: true,
|
||||
onPause: true,
|
||||
onStop: true,
|
||||
onSeek: false,
|
||||
});
|
||||
const originalCreateInnerAudioContext = minigame.createInnerAudioContext;
|
||||
minigame.createInnerAudioContext = (): InnerAudioContext => {
|
||||
const audioContext = originalCreateInnerAudioContext.call(minigame);
|
||||
const originalStop = audioContext.stop;
|
||||
Object.defineProperty(audioContext, 'stop', {
|
||||
configurable: true,
|
||||
value (): void {
|
||||
// NOTE: stop won't seek to 0 when audio is paused on Xiaomi platform.
|
||||
audioContext.seek(0);
|
||||
originalStop.call(audioContext);
|
||||
},
|
||||
});
|
||||
return audioContext;
|
||||
};
|
||||
// #endregion InnerAudioContext
|
||||
|
||||
// #region SafeArea
|
||||
minigame.getSafeArea = (): SafeArea => {
|
||||
warn('getSafeArea is not supported on this platform');
|
||||
const systemInfo = minigame.getSystemInfoSync();
|
||||
return {
|
||||
top: 0,
|
||||
left: 0,
|
||||
bottom: systemInfo.screenHeight,
|
||||
right: systemInfo.screenWidth,
|
||||
width: systemInfo.screenWidth,
|
||||
height: systemInfo.screenHeight,
|
||||
};
|
||||
};
|
||||
// #endregion SafeArea
|
||||
|
||||
export { minigame };
|
||||
|
||||
checkPalIntegrity<typeof import('pal/minigame')>(withImpl<typeof import('./xiaomi')>());
|
||||
@@ -40,6 +40,7 @@ export enum Platform {
|
||||
// Minigame
|
||||
WECHAT_GAME = 'WECHAT_GAME',
|
||||
WECHAT_MINI_PROGRAM = 'WECHAT_MINI_PROGRAM',
|
||||
XIAOMI_QUICK_GAME = 'XIAOMI_QUICK_GAME',
|
||||
ALIPAY_MINI_GAME = 'ALIPAY_MINI_GAME',
|
||||
TAOBAO_CREATIVE_APP = 'TAOBAO_CREATIVE_APP',
|
||||
TAOBAO_MINI_GAME = 'TAOBAO_MINI_GAME',
|
||||
@@ -48,6 +49,7 @@ export enum Platform {
|
||||
OPPO_MINI_GAME = 'OPPO_MINI_GAME',
|
||||
VIVO_MINI_GAME = 'VIVO_MINI_GAME',
|
||||
HUAWEI_QUICK_GAME = 'HUAWEI_QUICK_GAME',
|
||||
MIGU_MINI_GAME = 'MIGU_MINI_GAME',
|
||||
HONOR_MINI_GAME = 'HONOR_MINI_GAME',
|
||||
SUD_MINI_GAME = 'SUD_MINI_GAME',
|
||||
SUDV2_MINI_GAME = 'SUDV2_MINI_GAME',
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { ALIPAY, BYTEDANCE, HUAWEI, OPPO, RUNTIME_BASED, SUD, SUDV2, VIVO, HONOR, WECHAT, DEBUG, TEST, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants';
|
||||
import { ALIPAY, BYTEDANCE, HUAWEI, OPPO, RUNTIME_BASED, SUD, SUDV2, VIVO, MIGU, HONOR, WECHAT, XIAOMI, DEBUG, TEST, TAOBAO, TAOBAO_MINIGAME, WECHAT_MINI_PROGRAM } from 'internal:constants';
|
||||
import { minigame, SystemInfo as MinigameSystemInfo } from 'pal/minigame';
|
||||
import { IFeatureMap } from 'pal/system-info';
|
||||
import { EventTarget } from '../../../cocos/core/event';
|
||||
@@ -38,6 +38,8 @@ if (WECHAT) {
|
||||
currentPlatform = Platform.WECHAT_GAME;
|
||||
} else if (WECHAT_MINI_PROGRAM) {
|
||||
currentPlatform = Platform.WECHAT_MINI_PROGRAM;
|
||||
} else if (XIAOMI) {
|
||||
currentPlatform = Platform.XIAOMI_QUICK_GAME;
|
||||
} else if (ALIPAY) {
|
||||
currentPlatform = Platform.ALIPAY_MINI_GAME;
|
||||
} else if (TAOBAO) {
|
||||
@@ -52,6 +54,8 @@ if (WECHAT) {
|
||||
currentPlatform = Platform.VIVO_MINI_GAME;
|
||||
} else if (HUAWEI) {
|
||||
currentPlatform = Platform.HUAWEI_QUICK_GAME;
|
||||
} else if (MIGU) {
|
||||
currentPlatform = Platform.MIGU_MINI_GAME;
|
||||
} else if (HONOR) {
|
||||
currentPlatform = Platform.HONOR_MINI_GAME;
|
||||
} else if (SUD) {
|
||||
@@ -197,7 +201,7 @@ class SystemInfo extends EventTarget {
|
||||
|
||||
// init isMobile and platform
|
||||
this.platform = currentPlatform;
|
||||
// Some minigame platforms don't support getting the platform, such as runtime, so this.os returns UNKNOWN.
|
||||
// Some minigame platforms don't support getting the platform, such as runtime and Xiaomi, so this.os returns UNKNOWN.
|
||||
// Most platforms are mobile, so set UNKNOWN to mobile.
|
||||
this.isMobile = this.os === OS.ANDROID || this.os === OS.IOS || this.os === OS.UNKNOWN;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { HUAWEI, TAOBAO_MINIGAME, WASM_SUBPACKAGE } from 'internal:constants';
|
||||
import { HUAWEI, TAOBAO_MINIGAME, WASM_SUBPACKAGE, XIAOMI } from 'internal:constants';
|
||||
import { minigame } from 'pal/minigame';
|
||||
import { basename } from '../../cocos/core/utils/path';
|
||||
import { checkPalIntegrity, withImpl } from '../integrity-check';
|
||||
@@ -116,7 +116,9 @@ export function ensureWasmModuleReady (): Promise<void> {
|
||||
*/
|
||||
function getPlatformBinaryUrl (binaryUrl: string): Promise<string> {
|
||||
return new Promise((resolve) => {
|
||||
if (TAOBAO_MINIGAME && WASM_SUBPACKAGE) {
|
||||
if (XIAOMI) {
|
||||
resolve(`src/cocos-js/${binaryUrl}`);
|
||||
} if (TAOBAO_MINIGAME && WASM_SUBPACKAGE) {
|
||||
resolve(`__ccWasmAssetSubpkg__/${basename(binaryUrl)}`);
|
||||
} else {
|
||||
resolve(`cocos-js/${binaryUrl}`);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Adapter for MiniGame platform
|
||||
included platforms:
|
||||
- WeChat
|
||||
- Xiaomi
|
||||
- Alipay
|
||||
- ByteDance
|
||||
- Taobao
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,180 @@
|
||||
(function () {
|
||||
if (!(cc && cc.EditBoxComponent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const EditBoxComp = cc.EditBoxComponent;
|
||||
const js = cc.js;
|
||||
const KeyboardReturnType = EditBoxComp.KeyboardReturnType;
|
||||
const MAX_VALUE = 65535;
|
||||
const KEYBOARD_HIDE_TIME = 600;
|
||||
let _hideKeyboardTimeout = null;
|
||||
let _currentEditBoxImpl = null;
|
||||
|
||||
function getKeyboardReturnType (type) {
|
||||
switch (type) {
|
||||
case KeyboardReturnType.DEFAULT:
|
||||
case KeyboardReturnType.DONE:
|
||||
return 'done';
|
||||
case KeyboardReturnType.SEND:
|
||||
return 'send';
|
||||
case KeyboardReturnType.SEARCH:
|
||||
return 'search';
|
||||
case KeyboardReturnType.GO:
|
||||
return 'go';
|
||||
case KeyboardReturnType.NEXT:
|
||||
return 'next';
|
||||
}
|
||||
return 'done';
|
||||
}
|
||||
|
||||
function MiniGameEditBoxImpl () {
|
||||
this._delegate = null;
|
||||
this._editing = false;
|
||||
|
||||
this._eventListeners = {
|
||||
onKeyboardInput: null,
|
||||
onKeyboardConfirm: null,
|
||||
onKeyboardComplete: null,
|
||||
};
|
||||
}
|
||||
|
||||
js.extend(MiniGameEditBoxImpl, EditBoxComp._EditBoxImpl);
|
||||
EditBoxComp._EditBoxImpl = MiniGameEditBoxImpl;
|
||||
|
||||
Object.assign(MiniGameEditBoxImpl.prototype, {
|
||||
init (delegate) {
|
||||
if (!delegate) {
|
||||
cc.error('EditBox init failed');
|
||||
return;
|
||||
}
|
||||
this._delegate = delegate;
|
||||
},
|
||||
|
||||
beginEditing () {
|
||||
// In case multiply register events
|
||||
if (this._editing) {
|
||||
return;
|
||||
}
|
||||
this._ensureKeyboardHide(() => {
|
||||
let delegate = this._delegate;
|
||||
this._showKeyboard(() => {
|
||||
// NOTE: pass defaultValue when showKeyboard is invalid on Xiaomi platform
|
||||
// need to manually update the value
|
||||
__globalAdapter.updateKeyboard({
|
||||
value: delegate.string,
|
||||
});
|
||||
// NOTE: need to delay the event registering on Xiaomi platform
|
||||
// the input event callback is invoked twice when show keyboard.
|
||||
this._registerKeyboardEvent();
|
||||
this._editing = true;
|
||||
_currentEditBoxImpl = this;
|
||||
delegate._editBoxEditingDidBegan();
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
endEditing () {
|
||||
this._hideKeyboard();
|
||||
let cbs = this._eventListeners;
|
||||
cbs.onKeyboardComplete && cbs.onKeyboardComplete();
|
||||
},
|
||||
|
||||
_registerKeyboardEvent () {
|
||||
let self = this;
|
||||
let delegate = this._delegate;
|
||||
let cbs = this._eventListeners;
|
||||
|
||||
cbs.onKeyboardInput = function (res) {
|
||||
if (delegate._string !== res.value) {
|
||||
delegate._editBoxTextChanged(res.value);
|
||||
}
|
||||
}
|
||||
|
||||
cbs.onKeyboardConfirm = function (res) {
|
||||
delegate._editBoxEditingReturn();
|
||||
let cbs = self._eventListeners;
|
||||
cbs.onKeyboardComplete && cbs.onKeyboardComplete();
|
||||
}
|
||||
|
||||
cbs.onKeyboardComplete = function () {
|
||||
self._editing = false;
|
||||
_currentEditBoxImpl = null;
|
||||
self._unregisterKeyboardEvent();
|
||||
delegate._editBoxEditingDidEnded();
|
||||
}
|
||||
|
||||
__globalAdapter.onKeyboardInput(cbs.onKeyboardInput);
|
||||
__globalAdapter.onKeyboardConfirm(cbs.onKeyboardConfirm);
|
||||
__globalAdapter.onKeyboardComplete(cbs.onKeyboardComplete);
|
||||
},
|
||||
|
||||
_unregisterKeyboardEvent () {
|
||||
let cbs = this._eventListeners;
|
||||
|
||||
if (cbs.onKeyboardInput) {
|
||||
__globalAdapter.offKeyboardInput(cbs.onKeyboardInput);
|
||||
cbs.onKeyboardInput = null;
|
||||
}
|
||||
if (cbs.onKeyboardConfirm) {
|
||||
__globalAdapter.offKeyboardConfirm(cbs.onKeyboardConfirm);
|
||||
cbs.onKeyboardConfirm = null;
|
||||
}
|
||||
if (cbs.onKeyboardComplete) {
|
||||
__globalAdapter.offKeyboardComplete(cbs.onKeyboardComplete);
|
||||
cbs.onKeyboardComplete = null;
|
||||
}
|
||||
},
|
||||
|
||||
_otherEditing () {
|
||||
return !!_currentEditBoxImpl && _currentEditBoxImpl !== this && _currentEditBoxImpl._editing;
|
||||
},
|
||||
|
||||
_ensureKeyboardHide (cb) {
|
||||
let otherEditing = this._otherEditing();
|
||||
if (!otherEditing && !_hideKeyboardTimeout) {
|
||||
return cb();
|
||||
}
|
||||
if (_hideKeyboardTimeout) {
|
||||
clearTimeout(_hideKeyboardTimeout);
|
||||
}
|
||||
if (otherEditing) {
|
||||
_currentEditBoxImpl.endEditing();
|
||||
}
|
||||
_hideKeyboardTimeout = setTimeout(() => {
|
||||
_hideKeyboardTimeout = null;
|
||||
cb();
|
||||
}, KEYBOARD_HIDE_TIME);
|
||||
},
|
||||
|
||||
_showKeyboard (successCB) {
|
||||
let delegate = this._delegate;
|
||||
let multiline = (delegate.inputMode === EditBoxComp.InputMode.ANY);
|
||||
__globalAdapter.showKeyboard({
|
||||
defaultValue: delegate.string,
|
||||
maxLength: delegate.maxLength < 0 ? MAX_VALUE : delegate.maxLength,
|
||||
multiple: multiline,
|
||||
confirmHold: false,
|
||||
confirmType: getKeyboardReturnType(delegate.returnType),
|
||||
success (res) {
|
||||
successCB && successCB();
|
||||
},
|
||||
fail (res) {
|
||||
cc.warn(res.errMsg);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_hideKeyboard () {
|
||||
__globalAdapter.hideKeyboard({
|
||||
success (res) {
|
||||
|
||||
},
|
||||
fail (res) {
|
||||
cc.warn(res.errMsg);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
const downloader = cc.assetManager.downloader;
|
||||
const originalDownloadTTF = downloader.handlers['.ttf'];
|
||||
|
||||
function downloadTTF (url, options, onComplete) {
|
||||
// can't use cached ttf on Xiaomi platform
|
||||
options.cacheEnabled = false;
|
||||
originalDownloadTTF(url, options, onComplete);
|
||||
}
|
||||
|
||||
downloader.register({
|
||||
'.ttf': downloadTTF,
|
||||
});
|
||||
@@ -0,0 +1,4 @@
|
||||
require('../fs-utils');
|
||||
require('../../../../common/engine/index');
|
||||
require('./download-ttf');
|
||||
require('./Editbox');
|
||||
@@ -0,0 +1,262 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2017-2019 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://www.cocos.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated engine source code (the "Software"), a limited,
|
||||
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
||||
to use Cocos Creator solely to develop games on your target platforms. You shall
|
||||
not use Cocos Creator software for developing other software or tools that's
|
||||
used for developing games. You are not granted to publish, distribute,
|
||||
sublicense, and/or sell copies of Cocos Creator.
|
||||
|
||||
The software or tools in this License Agreement are licensed, not sold.
|
||||
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
const fs = qg.getFileSystemManager ? qg.getFileSystemManager() : null;
|
||||
const outOfStorageRegExp = /the maximum size of the file storage/; // not exactly right
|
||||
|
||||
const fsUtils = {
|
||||
|
||||
fs,
|
||||
|
||||
isOutOfStorage (errMsg) {
|
||||
return outOfStorageRegExp.test(errMsg);
|
||||
},
|
||||
|
||||
getUserDataPath () {
|
||||
return qg.env.USER_DATA_PATH;
|
||||
},
|
||||
|
||||
checkFsValid () {
|
||||
if (!fs) {
|
||||
console.warn('can not get the file system!');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
deleteFile (filePath, onComplete) {
|
||||
fs.unlink({
|
||||
filePath,
|
||||
success () {
|
||||
onComplete && onComplete(null);
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Delete file failed: path: ${filePath} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(res.errMsg));
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
downloadFile (remoteUrl, filePath, header, onProgress, onComplete) {
|
||||
const options = {
|
||||
url: remoteUrl,
|
||||
success (res) {
|
||||
if (res.statusCode === 200) {
|
||||
onComplete && onComplete(null, res.tempFilePath || res.filePath);
|
||||
} else {
|
||||
if (res.filePath) {
|
||||
fsUtils.deleteFile(res.filePath);
|
||||
}
|
||||
console.warn(`Download file failed: path: ${remoteUrl} message: ${res.statusCode}`);
|
||||
onComplete && onComplete(new Error(res.statusCode), null);
|
||||
}
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Download file failed: path: ${remoteUrl} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(res.errMsg), null);
|
||||
},
|
||||
};
|
||||
if (filePath) options.filePath = filePath;
|
||||
if (header) options.header = header;
|
||||
const task = qg.downloadFile(options);
|
||||
onProgress && task.onProgressUpdate(onProgress);
|
||||
},
|
||||
|
||||
saveFile (srcPath, destPath, onComplete) {
|
||||
qg.saveFile({
|
||||
tempFilePath: srcPath,
|
||||
filePath: destPath,
|
||||
success (res) {
|
||||
onComplete && onComplete(null);
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Save file failed: path: ${srcPath} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(res.errMsg));
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
copyFile (srcPath, destPath, onComplete) {
|
||||
fs.copyFile({
|
||||
srcPath,
|
||||
destPath,
|
||||
success () {
|
||||
onComplete && onComplete(null);
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Copy file failed: path: ${srcPath} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(res.errMsg));
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
writeFile (path, data, encoding, onComplete) {
|
||||
fs.writeFile({
|
||||
filePath: path,
|
||||
encoding,
|
||||
data,
|
||||
success () {
|
||||
onComplete && onComplete(null);
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Write file failed: path: ${path} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(res.errMsg));
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
writeFileSync (path, data, encoding) {
|
||||
try {
|
||||
fs.writeFileSync(path, data, encoding);
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.warn(`Write file failed: path: ${path} message: ${e.message}`);
|
||||
return new Error(e.message);
|
||||
}
|
||||
},
|
||||
|
||||
readFile (filePath, encoding, onComplete) {
|
||||
fs.readFile({
|
||||
filePath,
|
||||
encoding,
|
||||
success (res) {
|
||||
onComplete && onComplete(null, res.data);
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Read file failed: path: ${filePath} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(res.errMsg), null);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
readDir (filePath, onComplete) {
|
||||
fs.readdir({
|
||||
dirPath: filePath,
|
||||
success (res) {
|
||||
onComplete && onComplete(null, res.files);
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Read directory failed: path ${filePath} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(res.errMsg), null);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
readText (filePath, onComplete) {
|
||||
fsUtils.readFile(filePath, 'utf8', onComplete);
|
||||
},
|
||||
|
||||
readArrayBuffer (filePath, onComplete) {
|
||||
fsUtils.readFile(filePath, '', onComplete);
|
||||
},
|
||||
|
||||
readJson (filePath, onComplete) {
|
||||
fsUtils.readFile(filePath, 'utf8', (err, text) => {
|
||||
let out = null;
|
||||
if (!err) {
|
||||
try {
|
||||
out = JSON.parse(text);
|
||||
} catch (e) {
|
||||
console.warn(`Read json failed: path: ${filePath} message: ${e.message}`);
|
||||
err = new Error(e.message);
|
||||
}
|
||||
}
|
||||
onComplete && onComplete(err, out);
|
||||
});
|
||||
},
|
||||
|
||||
readJsonSync (path) {
|
||||
try {
|
||||
const str = fs.readFileSync(path, 'utf8');
|
||||
return JSON.parse(str.data);
|
||||
} catch (e) {
|
||||
console.warn(`Read json failed: path: ${path} message: ${e.message}`);
|
||||
return new Error(e.message);
|
||||
}
|
||||
},
|
||||
|
||||
makeDirSync (path, recursive) {
|
||||
try {
|
||||
fs.mkdirSync(path, recursive);
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.warn(`Make directory failed: path: ${path} message: ${e.message}`);
|
||||
return new Error(e.message);
|
||||
}
|
||||
},
|
||||
|
||||
rmdirSync (dirPath, recursive) {
|
||||
try {
|
||||
fs.rmdirSync(dirPath, recursive);
|
||||
return null;
|
||||
} catch (e) {
|
||||
console.warn(`rm directory failed: path: ${dirPath} message: ${e.message}`);
|
||||
return new Error(e.message);
|
||||
}
|
||||
},
|
||||
|
||||
exists (filePath, onComplete) {
|
||||
fs.access({
|
||||
path: filePath,
|
||||
success () {
|
||||
onComplete && onComplete(true);
|
||||
},
|
||||
fail () {
|
||||
onComplete && onComplete(false);
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
loadSubpackage (name, onProgress, onComplete) {
|
||||
name = `usr_${name}`; // prevention of name conflicts with platform
|
||||
const task = qg.loadSubpackage({
|
||||
name,
|
||||
success () {
|
||||
onComplete && onComplete();
|
||||
},
|
||||
fail (res) {
|
||||
console.warn(`Load Subpackage failed: name: ${name} message: ${res.errMsg}`);
|
||||
onComplete && onComplete(new Error(`Failed to load subpackage ${name}: ${res.errMsg}`));
|
||||
},
|
||||
});
|
||||
onProgress && task.onProgressUpdate(onProgress);
|
||||
return task;
|
||||
},
|
||||
|
||||
unzip (zipFilePath, targetPath, onComplete) {
|
||||
fs.unzip({
|
||||
zipFilePath,
|
||||
targetPath,
|
||||
success () {
|
||||
onComplete && onComplete(null);
|
||||
},
|
||||
fail (errMsg) {
|
||||
console.warn(`unzip failed: path: ${zipFilePath} message: ${errMsg}`);
|
||||
onComplete && onComplete(new Error(`unzip failed: ${errMsg}`));
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
window.fsUtils = module.exports = fsUtils;
|
||||
@@ -0,0 +1,123 @@
|
||||
const utils = require('./utils');
|
||||
|
||||
window.__globalAdapter = window.__globalAdapter || {};
|
||||
if (window.__globalAdapter) {
|
||||
let globalAdapter = window.__globalAdapter;
|
||||
// SystemInfo
|
||||
globalAdapter.isSubContext = false; // sub context not supported
|
||||
globalAdapter.isDevTool = false;
|
||||
utils.cloneMethod(globalAdapter, qg, 'getSystemInfoSync');
|
||||
|
||||
// TouchEvent
|
||||
globalAdapter.onTouchStart = function (cb) {
|
||||
window.canvas.ontouchstart = cb;
|
||||
};
|
||||
globalAdapter.onTouchMove = function (cb) {
|
||||
window.canvas.ontouchmove = cb;
|
||||
};
|
||||
globalAdapter.onTouchEnd = function (cb) {
|
||||
window.canvas.ontouchend = cb;
|
||||
};
|
||||
globalAdapter.onTouchCancel = function (cb) {
|
||||
window.canvas.ontouchcancel = cb;
|
||||
};
|
||||
|
||||
// Audio
|
||||
utils.cloneMethod(globalAdapter, qg, 'createInnerAudioContext');
|
||||
|
||||
// FrameRate
|
||||
utils.cloneMethod(globalAdapter, qg, 'setPreferredFramesPerSecond');
|
||||
|
||||
// Keyboard
|
||||
globalAdapter.showKeyboard = function (res) {
|
||||
res.confirmHold = true; // HACK: confirmHold not working on Xiaomi platform
|
||||
qg.showKeyboard(res);
|
||||
};
|
||||
utils.cloneMethod(globalAdapter, qg, 'hideKeyboard');
|
||||
utils.cloneMethod(globalAdapter, qg, 'updateKeyboard');
|
||||
utils.cloneMethod(globalAdapter, qg, 'onKeyboardInput');
|
||||
utils.cloneMethod(globalAdapter, qg, 'onKeyboardConfirm');
|
||||
utils.cloneMethod(globalAdapter, qg, 'onKeyboardComplete');
|
||||
utils.cloneMethod(globalAdapter, qg, 'offKeyboardInput');
|
||||
utils.cloneMethod(globalAdapter, qg, 'offKeyboardConfirm');
|
||||
utils.cloneMethod(globalAdapter, qg, 'offKeyboardComplete');
|
||||
|
||||
// Message
|
||||
utils.cloneMethod(globalAdapter, qg, 'getOpenDataContext');
|
||||
utils.cloneMethod(globalAdapter, qg, 'onMessage');
|
||||
|
||||
// Subpackage
|
||||
utils.cloneMethod(globalAdapter, qg, 'loadSubpackage');
|
||||
|
||||
// SharedCanvas
|
||||
utils.cloneMethod(globalAdapter, qg, 'getSharedCanvas');
|
||||
|
||||
// Font
|
||||
utils.cloneMethod(globalAdapter, qg, 'loadFont');
|
||||
|
||||
// hide show Event
|
||||
utils.cloneMethod(globalAdapter, qg, 'onShow');
|
||||
utils.cloneMethod(globalAdapter, qg, 'onHide');
|
||||
|
||||
// Accelerometer
|
||||
// NOTE: There is no LANDSCAPE_LEFT on Xiaomi platform
|
||||
// const LANDSCAPE_LEFT = -90;
|
||||
const LANDSCAPE_RIGHT = 90;
|
||||
// NOTE: the data in callback registered on onAccelerometerChange is 10 times than the standard data
|
||||
// Need to be scaled by 0.1
|
||||
const accelerometerFactor = -0.1;
|
||||
let isAccelerometerInit = false;
|
||||
let deviceOrientation = 1;
|
||||
let isLandscape = window.orientation === LANDSCAPE_RIGHT;
|
||||
if (qg.onDeviceOrientationChange) {
|
||||
qg.onDeviceOrientationChange(function (res) {
|
||||
if (res.value === 'landscape') {
|
||||
deviceOrientation = 1;
|
||||
}
|
||||
else if (res.value === 'landscapeReverse') {
|
||||
deviceOrientation = -1;
|
||||
}
|
||||
});
|
||||
}
|
||||
Object.assign(globalAdapter, {
|
||||
startAccelerometer (cb) {
|
||||
if (!isAccelerometerInit) {
|
||||
isAccelerometerInit = true;
|
||||
qg.onAccelerometerChange && qg.onAccelerometerChange(function (res) {
|
||||
let resClone = {};
|
||||
let x = res.x;
|
||||
let y = res.y;
|
||||
if (isLandscape) {
|
||||
let tmp = x;
|
||||
x = -y;
|
||||
y = tmp;
|
||||
}
|
||||
|
||||
resClone.x = x * accelerometerFactor;
|
||||
resClone.y = y * accelerometerFactor;
|
||||
resClone.z = res.z;
|
||||
cb && cb(resClone);
|
||||
});
|
||||
}
|
||||
else {
|
||||
qg.startAccelerometer && qg.startAccelerometer({
|
||||
fail (err) {
|
||||
console.error('start accelerometer failed', err);
|
||||
},
|
||||
// success () {},
|
||||
// complete () {},
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
stopAccelerometer () {
|
||||
qg.stopAccelerometer && qg.stopAccelerometer({
|
||||
fail (err) {
|
||||
console.error('stop accelerometer failed', err);
|
||||
},
|
||||
// success () {},
|
||||
// complete () {},
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
let utils = {
|
||||
/**
|
||||
* @param {Object} target
|
||||
* @param {Object} origin
|
||||
* @param {String} methodName
|
||||
* @param {String} targetMethodName
|
||||
*/
|
||||
cloneMethod (target, origin, methodName, targetMethodName) {
|
||||
if (origin[methodName]) {
|
||||
targetMethodName = targetMethodName || methodName;
|
||||
target[targetMethodName] = origin[methodName].bind(origin);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = utils;
|
||||
@@ -2,4 +2,5 @@
|
||||
included platforms:
|
||||
- vivo
|
||||
- OPPO
|
||||
- huawei
|
||||
- huawei
|
||||
- Migu
|
||||
@@ -56,7 +56,7 @@ async function bundleMinigameAdapter () {
|
||||
for (const platform of platforms) {
|
||||
console.log(`handle platform: ${green(platform)}`);
|
||||
|
||||
const needUglify = true;
|
||||
const needUglify = (platform !== 'xiaomi'); // uglify conflicts with the webpack tool on xiaomi platform
|
||||
|
||||
// bundle engine-adapter.js
|
||||
const engineEntry = normalizePath(ps.join(engineRoot, `platforms/minigame/platforms/${platform}/wrapper/engine/index.js`));
|
||||
@@ -64,7 +64,10 @@ async function bundleMinigameAdapter () {
|
||||
await bundle(engineEntry, engineOutput, needUglify);
|
||||
|
||||
// bundle web-adapter.js
|
||||
const builtinEntry = normalizePath(ps.join(engineRoot, `platforms/minigame/platforms/${platform}/wrapper/builtin/index.js`));
|
||||
let builtinEntry = normalizePath(ps.join(engineRoot, `platforms/minigame/platforms/${platform}/wrapper/builtin/index.js`));
|
||||
if (platform === 'xiaomi') {
|
||||
builtinEntry = normalizePath(ps.join(engineRoot, `platforms/minigame/platforms/${platform}/wrapper/builtin.js`));
|
||||
}
|
||||
const builtinOutput = normalizePath(ps.join(engineRoot, `bin/adapter/minigame/${platform}/web-adapter.js`));
|
||||
await bundle(builtinEntry, builtinOutput, needUglify);
|
||||
}
|
||||
@@ -93,6 +96,7 @@ async function bundleNodejsAdapter () {
|
||||
const webAdapterEntry = normalizePath(ps.join(engineRoot, 'platforms/nodejs/builtin/index.js'));
|
||||
const webAdapterOutput = normalizePath(ps.join(engineRoot, 'bin/adapter/nodejs/web-adapter.js'));
|
||||
await bundle(webAdapterEntry, webAdapterOutput, true);
|
||||
|
||||
}
|
||||
|
||||
function normalizePath (path) {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
module.exports = function(api) {
|
||||
api.cache(true);
|
||||
return {
|
||||
presets: ["@babel/preset-env"],
|
||||
plugins: ["@babel/plugin-transform-modules-commonjs"],
|
||||
babelrcRoots: [".", "node_modules"]
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIIDMTCCAhmgAwIBAgIJAMKpjyszxkDpMA0GCSqGSIb3DQEBCwUAMC4xCzAJBgNV
|
||||
BAYTAkNOMQwwCgYDVQQKDANSUEsxETAPBgNVBAMMCFJQS0RlYnVnMCAXDTE3MDQx
|
||||
OTAyMzE0OVoYDzIxMTYwMzI2MDIzMTQ5WjAuMQswCQYDVQQGEwJDTjEMMAoGA1UE
|
||||
CgwDUlBLMREwDwYDVQQDDAhSUEtEZWJ1ZzCCASIwDQYJKoZIhvcNAQEBBQADggEP
|
||||
ADCCAQoCggEBAK3kPd9jzvTctTIA3XNZVv9cHHDbAc6nTBfdZp9mtPOTkXFpvyCb
|
||||
kL0QjOog0+1pv8D7dFeP4ptWXU5CT3ImvaPR+16dAtMRcsxEr5q4zieJzx3O6huL
|
||||
UBa1k+xrzjXpRzkcOysmc8fTxt0tAwbDgJ2AA5TlXLTcVyb7GmJ+hl5CjnhoG5NN
|
||||
LrkqI7S29c1U3uokj8Q7hzaj0TURu/uB5ZIMCLZY9KFDugqaEcvmUyJiD0fuV6sA
|
||||
O/4kpiZUOnhV8/xWpRbMI4WFQsfgLOCV+X9uzUa29D677y//46t/EDSuQTHyBZbl
|
||||
AcNMENkpMWZsH7J/+F19+U0/Hd5bJgneVRkCAwEAAaNQME4wHQYDVR0OBBYEFKDN
|
||||
SZtt47ttOBDQzIchFYyxsg3mMB8GA1UdIwQYMBaAFKDNSZtt47ttOBDQzIchFYyx
|
||||
sg3mMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBABaZctNrn4gLmNf/
|
||||
eNJ3x5CJIPjPwm6j9nwKhtadJ6BF+TIzSkJuHSgxULjW436F37otv94NPzT5PCBF
|
||||
WxgXoqgLqnWwvsaqC4LUEjsZviWW4CB824YDUquEUVGFLE/U5KTZ7Kh1ceyUk4N8
|
||||
+mtkXkanWoBBk0OF24lNrAsNLB63yTLr9HxEe75+kmvxf1qVJUGtaOEWIhiFMiAB
|
||||
5D4w/j2EFWktumjuy5TTwU0zhl52bc8V9SNixM1IaqzNrVPrdjv8viUX548pU3WT
|
||||
xZ5ylDsxhMC1q4BXQVeIY8C0cMEX+WHOmOCvWrkxCkP91pKsSPkuVrWlzrkn8Ojo
|
||||
swP6sBw=
|
||||
-----END CERTIFICATE-----
|
||||
@@ -0,0 +1,28 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCt5D3fY8703LUy
|
||||
AN1zWVb/XBxw2wHOp0wX3WafZrTzk5Fxab8gm5C9EIzqINPtab/A+3RXj+KbVl1O
|
||||
Qk9yJr2j0ftenQLTEXLMRK+auM4nic8dzuobi1AWtZPsa8416Uc5HDsrJnPH08bd
|
||||
LQMGw4CdgAOU5Vy03Fcm+xpifoZeQo54aBuTTS65KiO0tvXNVN7qJI/EO4c2o9E1
|
||||
Ebv7geWSDAi2WPShQ7oKmhHL5lMiYg9H7lerADv+JKYmVDp4VfP8VqUWzCOFhULH
|
||||
4Czglfl/bs1GtvQ+u+8v/+OrfxA0rkEx8gWW5QHDTBDZKTFmbB+yf/hdfflNPx3e
|
||||
WyYJ3lUZAgMBAAECggEBAJTnCBBdUB+fSs1prjeS/gsmnfgJoY+K9H7PCIxgj3yw
|
||||
FXAvZAmRDKzJGlF2EOOQlTG0YNiGDj6EAtv7rjoKcINyULSg8IU6wLmn61MrAuUa
|
||||
fa+Bujgh4E/B5swhOHAztNhzkzsM70Hi17wXSislh+HWd7qteOgqcbqgdOR4gaj+
|
||||
HUqtcxG3H3hCL3dWugnjLZMtestLKGHSSZvbQNjYM3kKy2LvO8NpxmDE4a+TXygK
|
||||
qhaZjmS/dc/nJBJzOfkzby58RvGbzlJflfW/Uu3/gizj13GFQKWonq1xh630RAhv
|
||||
xX5ySok2aAx/+/SiJSpNXvM09grQuoORSr7D1tm+5rECgYEA3vf0hRfua0XAOu6f
|
||||
pyzNvLRRJ/pEew7XpNPCyS2TuMTd1yvXjGVxQfP46N6x1IM3SRU0zE+LSk80EF7l
|
||||
u1Or7GyCEhabYNe/7P2F8ENP73Do0HwvcI1jGrgr6r9oK0J27Xei+f6Q0bgJOPI2
|
||||
qaLj+V37cOjkNSM1mhTjtDwK8k0CgYEAx6cMrkjHl1+lDIIOc3qAEL3jb3xQveYk
|
||||
WrMF/B+j048k6boU4VvFJAIyQxOxMNxLjw3/9+zXCFJT4WaZK3TMXlg614ASGx3H
|
||||
tKjJM9O07ywwMq1gbutFS4nHCg3L3Os6esL0SPwMdATR3Yh22n5OGI9o+/aURulL
|
||||
GPEXef1Z2/0CgYEAgmwp5LxV4vu+8Pnp+4DSq4ISQr861XyeGTUhKEp3sUm+tgFY
|
||||
KTChakHKpHS3Mqa6bQ5xft08je/8dWL9IHFWDIqAHxKIOsKY6oh1k0/cbyPtmx45
|
||||
Ja4efV+jmMHzrfJH3KnxdCg7D+GFy4CrBtlYXuJhlO81pft9fC6h7yh8ArUCgYBq
|
||||
gvkl5Zftbs4rnRq+iqTVyagTKvwcQzIz3PwdZHfO/rfPpUFMdNv4eN99n3zRN0Vs
|
||||
HSjoiEazntA3GLgwUdBRqLpDi4SdSMbo337vkksdqbJQ5uPiaMuAIBG6kF+pDSkW
|
||||
ovkWErlGD+gySoI10FozihaVDRhPuFgjB0PiBcIxtQKBgGNSzX+Bx5+ux1Qny0Sn
|
||||
SUcBtepLnO8M8wafoGNyehbMnLzfuMbaDiJOdozGlBNHZTtPB3r4AYb8WnltdKW0
|
||||
7i3fk26YZGiMVeUJvewA6/LOBEaqMdwoNwnoptvbR6ehHeE/PPtRtge2cD3bPIM7
|
||||
U9VlWgfgj9Dxfwhslqb9hmyp
|
||||
-----END PRIVATE KEY-----
|
||||
@@ -0,0 +1,39 @@
|
||||
require('./web-adapter');
|
||||
|
||||
<% if(polyfillsBundleFile) { %>
|
||||
// Polyfills bundle.
|
||||
require("<%= polyfillsBundleFile %>");
|
||||
<% } %>
|
||||
|
||||
// SystemJS support.
|
||||
require("<%= systemJsBundleFile %>");
|
||||
|
||||
// hack for Xiaomi havent screen;
|
||||
screen = window.screen;
|
||||
|
||||
// Adjust initial canvas size
|
||||
if (canvas && window.devicePixelRatio >= 2) {canvas.width *= 2; canvas.height *= 2;}
|
||||
|
||||
const importMap = require("./<%= importMapFile%>").default;
|
||||
System.warmup({
|
||||
importMap,
|
||||
importMapUrl: '<%= importMapFile%>',
|
||||
defaultHandler: (urlNoSchema) => {
|
||||
require('.' + urlNoSchema);
|
||||
},
|
||||
});
|
||||
|
||||
System.import('<%= applicationJs %>').then(({ Application }) => {
|
||||
return new Application();
|
||||
}).then((application) => {
|
||||
return onApplicationCreated(application);
|
||||
}).catch((err) => {
|
||||
console.error(err);
|
||||
});
|
||||
|
||||
function onApplicationCreated(application) {
|
||||
return System.import('cc').then((cc) => {
|
||||
require('./engine-adapter');
|
||||
return application.init(cc);
|
||||
}).then(() => application.start());
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"package": "",
|
||||
"name": "",
|
||||
"versionName": "1.0.0",
|
||||
"versionCode": 1201,
|
||||
"minPlatformVersion": 1056,
|
||||
"icon": "/image/icon.png",
|
||||
"orientation": "portrait",
|
||||
"type": "game",
|
||||
"config": {},
|
||||
"display": {},
|
||||
"subpackages": []
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "xiaomi-adapter",
|
||||
"version": "1.0.0",
|
||||
"build-template": "xiaomigame",
|
||||
"scripts": {
|
||||
"build": "quickgame build --cocos-wx-game --include-file-ext .pem,.pkm,.webp,.astc",
|
||||
"build-ignore-res": "quickgame build --cocos-wx-game --include-file-ext .pem,.pkm,.webp,.astc --ignore remote,res",
|
||||
"release": "quickgame release --cocos-wx-game --include-file-ext .pem,.pkm,.webp,.astc",
|
||||
"release-ignore-res": "quickgame release --cocos-wx-game --include-file-ext .pem,.pkm,.webp,.astc --ignore remote,res",
|
||||
"server": "quickgame server",
|
||||
"debug": "quickgame debug"
|
||||
},
|
||||
"babel": {
|
||||
"plugins": [
|
||||
"babel-plugin-transform-remove-strict-mode"
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"quickgame-cli": "^0.1.19"
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ export const WECHAT = tryDefineGlobal('CC_WECHAT', !!(defined('wx') && (wx.getSy
|
||||
export const MINIGAME = tryDefineGlobal('CC_MINIGAME', false);
|
||||
export const RUNTIME_BASED = tryDefineGlobal('CC_RUNTIME_BASED', false);
|
||||
export const ALIPAY = tryDefineGlobal('CC_ALIPAY', false);
|
||||
export const XIAOMI = tryDefineGlobal('CC_XIAOMI', false);
|
||||
export const BYTEDANCE = tryDefineGlobal('CC_BYTEDANCE', false);
|
||||
export const HUAWEI = tryDefineGlobal('CC_HUAWEI', false);
|
||||
export const OPPO = tryDefineGlobal('CC_OPPO', false);
|
||||
|
||||
Reference in New Issue
Block a user