Initial commit: Client Doc docs Server Tools

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
ud18010
2026-07-10 10:24:29 +08:00
co-authored by Cursor
commit 7e35d8da31
3374 changed files with 680813 additions and 0 deletions
@@ -0,0 +1,299 @@
import moduleHelper from './module-helper';
import response from './response';
import { formatJsonStr, uid } from './utils';
import { resumeWebAudio } from './audio/utils';
const ads = {};
export default {
WXCreateBannerAd(conf) {
const config = formatJsonStr(conf);
config.style = JSON.parse(config.styleRaw || '{}');
const ad = wx.createBannerAd(config);
const key = uid();
ads[key] = ad;
ad.onError((res) => {
console.error(res);
moduleHelper.send('ADOnErrorCallback', JSON.stringify({
callbackId: key,
errMsg: res.errMsg,
errCode: res.errCode || res.err_code,
}));
});
ad.onLoad(() => {
moduleHelper.send('ADOnLoadCallback', JSON.stringify({
callbackId: key,
errMsg: '',
}));
});
ad.onResize((res) => {
moduleHelper.send('ADOnResizeCallback', JSON.stringify({
callbackId: key,
errMsg: '',
...res,
}));
});
return key;
},
WXCreateFixedBottomMiddleBannerAd(adUnitId, adIntervals, height) {
const info = wx.getSystemInfoSync();
const ad = wx.createBannerAd({
adUnitId,
adIntervals,
style: {
left: 0,
top: info.windowHeight - height,
height,
width: info.windowWidth,
},
});
const key = uid();
ads[key] = ad;
ad.onError((res) => {
console.error(res);
moduleHelper.send('ADOnErrorCallback', JSON.stringify({
callbackId: key,
errMsg: res.errMsg,
errCode: res.errCode || res.err_code,
}));
});
ad.onLoad(() => {
moduleHelper.send('ADOnLoadCallback', JSON.stringify({
callbackId: key,
errMsg: '',
}));
});
const oldWidth = info.windowWidth;
ad.onResize((res) => {
if (Math.abs(res.height - height) > 1 || Math.abs(res.width - oldWidth) > 1) {
ad.style.left = Math.round((info.windowWidth - res.width) / 2);
ad.style.top = Math.round(info.windowHeight - res.height);
}
moduleHelper.send('ADOnResizeCallback', JSON.stringify({
callbackId: key,
errMsg: '',
...res,
}));
});
return key;
},
WXCreateRewardedVideoAd(conf) {
const config = formatJsonStr(conf);
const ad = wx.createRewardedVideoAd(config);
const key = uid();
ads[key] = ad;
if (!config.multiton) {
// 单例模式要处理一下
ad.offLoad();
ad.offError();
ad.offClose();
}
ad.onError((res) => {
console.error(res);
moduleHelper.send('ADOnErrorCallback', JSON.stringify({
callbackId: key,
errMsg: res.errMsg,
errCode: res.errCode || res.err_code,
}));
});
ad.onLoad((res) => {
moduleHelper.send('ADOnLoadCallback', JSON.stringify({
callbackId: key,
errMsg: '',
...res,
}));
});
ad.onClose((res) => {
moduleHelper.send('ADOnVideoCloseCallback', JSON.stringify({
callbackId: key,
errMsg: '',
...res,
}));
setTimeout(() => {
resumeWebAudio();
}, 0);
});
return key;
},
WXCreateInterstitialAd(conf) {
const config = formatJsonStr(conf);
const ad = wx.createInterstitialAd(config);
const key = uid();
ads[key] = ad;
ad.onError((res) => {
console.error(res);
moduleHelper.send('ADOnErrorCallback', JSON.stringify({
callbackId: key,
errMsg: res.errMsg,
errCode: res.errCode || res.err_code,
}));
});
ad.onLoad(() => {
moduleHelper.send('ADOnLoadCallback', JSON.stringify({
callbackId: key,
errMsg: '',
}));
});
ad.onClose(() => {
moduleHelper.send('ADOnCloseCallback', JSON.stringify({
callbackId: key,
errMsg: '',
}));
});
return key;
},
WXCreateCustomAd(conf) {
const config = formatJsonStr(conf);
config.style = JSON.parse(config.styleRaw || '{}');
const ad = wx.createCustomAd(config);
const key = uid();
ads[key] = ad;
ad.onError((res) => {
console.error(res);
moduleHelper.send('ADOnErrorCallback', JSON.stringify({
callbackId: key,
errMsg: res.errMsg,
errCode: res.errCode || res.err_code,
}));
});
ad.onLoad(() => {
moduleHelper.send('ADOnLoadCallback', JSON.stringify({
callbackId: key,
errMsg: '',
}));
});
ad.onClose(() => {
moduleHelper.send('ADOnCloseCallback', JSON.stringify({
callbackId: key,
errMsg: '',
}));
});
ad.onHide(() => {
moduleHelper.send('ADOnHideCallback', JSON.stringify({
callbackId: key,
errMsg: '',
}));
});
return key;
},
WXADStyleChange(id, key, value) {
if (!ads[id]) {
return false;
}
if (typeof ads[id].style === 'undefined') {
return;
}
ads[id].style[key] = value;
},
WXShowAd(id, succ, fail) {
if (!ads[id]) {
return false;
}
ads[id]
.show()
.then(() => {
response.textFormat(succ, {
errMsg: 'show:ok',
});
})
.catch((e) => {
response.textFormat(fail, {
errMsg: e.errMsg || '',
});
});
},
WXShowAd2(id, branchId, branchDim, succ, fail) {
if (!ads[id]) {
return false;
}
ads[id]
.show({ branchId, branchDim })
.then(() => {
response.textFormat(succ, {
errMsg: 'show:ok',
});
})
.catch((e) => {
response.textFormat(fail, {
errMsg: e.errMsg || '',
});
});
},
WXHideAd(id, succ, fail) {
if (!ads[id]) {
return false;
}
if (typeof ads[id].hide === 'undefined') {
return;
}
if (succ || fail) {
const promise = ads[id].hide();
if (promise) {
promise
.then(() => {
response.textFormat(succ, {
errMsg: 'hide:ok',
});
})
.catch((e) => {
response.textFormat(fail, {
errMsg: e.errMsg || '',
});
});
}
else {
response.textFormat(succ, {
errMsg: 'hide:ok',
});
}
}
else {
ads[id].hide();
}
},
WXADGetStyleValue(id, key) {
if (!ads[id]) {
return -1;
}
if (typeof ads[id].style === 'undefined') {
return;
}
return ads[id].style[key];
},
WXADDestroy(id) {
if (!ads[id]) {
return false;
}
ads[id].destroy();
delete ads[id];
},
WXADLoad(id, succ, fail) {
if (!ads[id]) {
return false;
}
if (typeof ads[id].load === 'undefined') {
return;
}
ads[id]
.load()
.then(() => {
response.textFormat(succ, {});
})
.catch((res) => {
moduleHelper.send('ADLoadErrorCallback', JSON.stringify({
callbackId: fail,
...res,
}));
});
},
WXReportShareBehavior(id, conf) {
if (!ads[id]) {
return '{}';
}
if (typeof ads[id].reportShareBehavior === 'undefined') {
return;
}
const config = formatJsonStr(conf);
return JSON.stringify(ads[id].reportShareBehavior(config));
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e87ffd5c0171de44e8c4159d2e0ae851
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e62e7423705621d4d9944004419857cd
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,51 @@
import { WEBAudio, audios } from './store';
import { resumeWebAudio, mkCacheDir } from './utils';
mkCacheDir();
export default {
WXGetAudioCount() {
return {
innerAudio: Object.keys(audios).length,
webAudio: WEBAudio.bufferSourceNodeLength,
buffer: WEBAudio.audioBufferLength,
};
},
};
const HandleInterruption = {
init() {
let INTERRUPT_LIST = {};
wx.onHide(() => {
Object.keys(audios).forEach((key) => {
if (!audios[key].paused !== false) {
INTERRUPT_LIST[key] = true;
}
});
});
wx.onShow(() => {
Object.keys(audios).forEach((key) => {
if (audios[key].paused !== false && INTERRUPT_LIST[key]) {
audios[key].play();
}
});
INTERRUPT_LIST = {};
});
wx.onAudioInterruptionBegin(() => {
Object.keys(audios).forEach((key) => {
if (!audios[key].paused !== false) {
INTERRUPT_LIST[key] = true;
}
});
});
wx.onAudioInterruptionEnd(() => {
Object.keys(audios).forEach((key) => {
if (audios[key].paused !== false && INTERRUPT_LIST[key]) {
audios[key].play();
}
});
INTERRUPT_LIST = {};
resumeWebAudio();
});
},
};
HandleInterruption.init();
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1346b877eca95bc4e981004851766fa3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,3 @@
export const INNER_AUDIO_UNDEFINED_MSG = 'InnerAudioContext does not exist!';
export const IGNORE_ERROR_MSG = 'audio is playing, don\'t play again';
export const TEMP_DIR_PATH = `${wx.env.USER_DATA_PATH}/__GAME_FILE_CACHE/audios`;
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 585369bd09f595d4b954f11aad189025
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
import innerAudio from './inner-audio';
import unityAudio from './unity-audio';
import common from './common';
export default {
...innerAudio,
...unityAudio,
...common,
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2706efb73cecc9a408b84934894867a3
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,365 @@
import moduleHelper from '../module-helper';
import { isSupportPlayBackRate } from '../../check-version';
import { audios, localAudioMap, downloadingAudioMap } from './store';
import { createInnerAudio, destroyInnerAudio, printErrMsg } from './utils';
import { IGNORE_ERROR_MSG, INNER_AUDIO_UNDEFINED_MSG } from './const';
const funs = {
getFullUrl(v) {
if (!/^https?:\/\//.test(v) && !/^wxfile:\/\//.test(v)) {
const cdnPath = GameGlobal.manager.assetPath;
v = `${cdnPath.replace(/\/$/, '')}/${v.replace(/^\//, '').replace(/^Assets\//, '')}`;
}
return v;
},
downloadAudios(paths) {
const list = paths.split(',');
return Promise.all(list.map((v) => {
const src = funs.getFullUrl(v);
return new Promise((resolve, reject) => {
if (!downloadingAudioMap[src]) {
downloadingAudioMap[src] = [
{
resolve,
reject,
},
];
if (funs.checkLocalFile(src)) {
funs.handleDownloadEnd(src, true);
}
else if (!GameGlobal.unityNamespace.isCacheableFile(src)) {
wx.downloadFile({
url: src,
success(res) {
if (res.statusCode === 200 && res.tempFilePath) {
localAudioMap[src] = res.tempFilePath;
funs.handleDownloadEnd(src, true);
}
else {
funs.handleDownloadEnd(src, false);
}
},
fail(e) {
funs.handleDownloadEnd(src, false);
printErrMsg(e);
},
});
}
else {
const xmlhttp = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
xmlhttp.open('GET', src, true);
xmlhttp.responseType = 'arraybuffer';
xmlhttp.onsave = () => {
localAudioMap[src] = GameGlobal.manager.getCachePath(src);
funs.handleDownloadEnd(src, true);
};
xmlhttp.onsavefail = () => {
funs.handleDownloadEnd(src, false);
};
xmlhttp.onerror = () => {
funs.handleDownloadEnd(src, false);
};
xmlhttp.send();
}
}
else {
downloadingAudioMap[src].push({
resolve,
reject,
});
}
});
}));
},
handleDownloadEnd(src, succeeded) {
if (!downloadingAudioMap[src]) {
return;
}
while (downloadingAudioMap[src] && downloadingAudioMap[src].length > 0) {
const item = downloadingAudioMap[src].shift();
if (!succeeded) {
item?.reject();
}
else {
item?.resolve('');
}
}
delete downloadingAudioMap[src];
},
// 是否存在本地文件
checkLocalFile(src) {
if (localAudioMap[src]) {
return true;
}
const path = GameGlobal.manager.getCachePath(src);
if (path) {
localAudioMap[src] = path;
return true;
}
return false;
},
// 设置路径
setAudioSrc(audio, getSrc) {
return new Promise((resolve, reject) => {
const src = funs.getFullUrl(getSrc);
// 设置原始路径,后面用此路径作为key值
audio.isLoading = src;
if (funs.checkLocalFile(src)) {
audio.src = localAudioMap[src];
delete audio.isLoading;
funs.handleDownloadEnd(src, true);
resolve(localAudioMap[src]);
}
else if (audio.needDownload) {
funs
.downloadAudios(src)
.then(() => {
if (audio) {
audio.src = localAudioMap[src];
delete audio.isLoading;
resolve(localAudioMap[src]);
}
else {
console.warn('资源已被删除:', src);
reject({
errCode: -1,
errMsg: '资源已被删除',
});
}
})
.catch(() => {
console.warn('资源下载失败:', src);
if (audio) {
audio.src = src;
delete audio.isLoading;
}
reject({
errCode: -1,
errMsg: '资源下载失败',
});
});
}
else {
// 不推荐这样处理,建议优先下载再使用,除非是需要立即播放的长音频文件或一次性播放音频
// console.warn('建议优先下载再使用:', src);
audio.src = src;
delete audio.isLoading;
resolve(src);
}
});
},
};
function checkHasAudio(id) {
if (audios[id]) {
return true;
}
console.error(INNER_AUDIO_UNDEFINED_MSG, id);
return false;
}
export default {
// 创建audio对象
WXCreateInnerAudioContext(src, loop, startTime, autoplay, volume, playbackRate, needDownload) {
const { audio: getAudio, id } = createInnerAudio();
getAudio.needDownload = needDownload;
if (src) {
// 设置原始src
funs.setAudioSrc(getAudio, src).catch((e) => {
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: 'onError',
result: JSON.stringify(e),
}));
});
}
if (loop) {
getAudio.loop = true;
}
if (autoplay) {
getAudio.autoplay = true;
}
if (typeof startTime === 'undefined') {
startTime = 0;
}
if (startTime > 0) {
getAudio.startTime = +startTime.toFixed(2);
}
if (typeof volume === 'undefined') {
volume = 1;
}
if (volume !== 1) {
getAudio.volume = +volume.toFixed(2);
}
if (!isSupportPlayBackRate) {
playbackRate = 1;
}
if (typeof playbackRate !== 'undefined' && playbackRate !== 1) {
getAudio.playbackRate = +playbackRate.toFixed(2);
}
return id;
},
WXInnerAudioContextSetBool(id, k, v) {
if (!checkHasAudio(id)) {
return;
}
audios[id][k] = Boolean(+v);
},
WXInnerAudioContextSetString(id, k, v) {
if (!checkHasAudio(id)) {
return;
}
if (k === 'src') {
funs.setAudioSrc(audios[id], v);
}
else if (k === 'needDownload') {
audios[id].needDownload = !!v;
}
else {
audios[id][k] = v;
}
},
WXInnerAudioContextSetFloat(id, k, v) {
if (!checkHasAudio(id)) {
return;
}
audios[id][k] = +v.toFixed(2);
},
WXInnerAudioContextGetFloat(id, k) {
if (!checkHasAudio(id)) {
return 0;
}
return audios[id][k];
},
WXInnerAudioContextGetBool(id, k) {
if (!checkHasAudio(id)) {
return false;
}
return audios[id][k];
},
WXInnerAudioContextPlay(id) {
if (!checkHasAudio(id)) {
return;
}
const url = audios[id].isLoading;
if (url) {
if (downloadingAudioMap[url]) {
downloadingAudioMap[url].push({
resolve: () => {
if (typeof audios[id] !== 'undefined') {
audios[id].play();
}
},
reject: () => { },
});
}
else {
audios[id].src = url;
audios[id].play();
}
}
else {
audios[id].play();
}
},
WXInnerAudioContextPause(id) {
if (!checkHasAudio(id)) {
return;
}
audios[id].pause();
},
WXInnerAudioContextStop(id) {
if (!checkHasAudio(id)) {
return;
}
audios[id].stop();
},
WXInnerAudioContextDestroy(id) {
if (!checkHasAudio(id)) {
return;
}
destroyInnerAudio(id, false);
},
WXInnerAudioContextSeek(id, position) {
if (!checkHasAudio(id)) {
return;
}
audios[id].seek(+position.toFixed(3));
},
WXInnerAudioContextAddListener(id, key) {
if (!checkHasAudio(id)) {
return;
}
if (key === 'onCanplay') {
audios[id][key](() => {
const { duration, buffered, referrerPolicy, volume } = audios[id];
setTimeout(() => {
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: key,
}));
}, 0);
});
}
else if (key === 'onError') {
audios[id][key]((e) => {
if (key === 'onError') {
console.error(e);
if (e.errMsg && e.errMsg.indexOf(IGNORE_ERROR_MSG) > -1) {
return;
}
}
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: key,
result: JSON.stringify(e),
}));
});
}
else {
audios[id][key](() => {
moduleHelper.send('OnAudioCallback', JSON.stringify({
callbackId: id,
errMsg: key,
}));
});
}
},
WXInnerAudioContextRemoveListener(id, key) {
if (!checkHasAudio(id)) {
return;
}
audios[id][key]();
},
WXPreDownloadAudios(paths, id) {
funs
.downloadAudios(paths)
.then(() => {
moduleHelper.send('WXPreDownloadAudiosCallback', JSON.stringify({
callbackId: id.toString(),
errMsg: '0',
}));
})
.catch(() => {
moduleHelper.send('WXPreDownloadAudiosCallback', JSON.stringify({
callbackId: id.toString(),
errMsg: '1',
}));
});
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 783d3d4e7ae93344aadefb76a6c5248a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
export const WEBAudio = {
audioInstanceIdCounter: 0,
audioInstances: {},
audioContext: null,
audioWebEnabled: 0,
audioCache: [],
lOrientation: {
x: 0,
y: 0,
z: 0,
xUp: 0,
yUp: 0,
zUp: 0,
},
lPosition: { x: 0, y: 0, z: 0 },
audio3DSupport: 0,
audioWebSupport: 0,
bufferSourceNodeLength: 0,
audioBufferLength: 0,
};
export const audios = {};
export const localAudioMap = {};
export const downloadingAudioMap = {};
export const soundVolumeHandler = {};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 89a6a02588fcb274aaa8ddca052949a0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a0e0368c963c215469b90cd1924ff6bf
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
import { uid } from '../utils';
import { isSupportCacheAudio } from '../../check-version';
import { WEBAudio, audios } from './store';
import { TEMP_DIR_PATH } from './const';
export const resumeWebAudio = () => {
if (WEBAudio.audioContext
&& (WEBAudio.audioContext.state === 'suspended' || WEBAudio.audioContext.state === 'interrupted')) {
WEBAudio.audioContext.resume();
}
};
export const createInnerAudio = () => {
const id = uid();
const audio = (isSupportCacheAudio && WEBAudio.audioCache.length ? WEBAudio.audioCache.shift() : wx.createInnerAudioContext());
if (audio) {
audios[id] = audio;
}
return {
id,
audio,
};
};
export const destroyInnerAudio = (id, useCache) => {
if (!id) {
return;
}
if (!useCache || !isSupportCacheAudio || WEBAudio.audioCache.length > 32) {
audios[id].destroy();
}
else {
['Play', 'Pause', 'Stop', 'Canplay', 'Error', 'Ended', 'Waiting', 'Seeking', 'Seeked', 'TimeUpdate'].forEach((eventName) => {
audios[id][`off${eventName}`]();
});
const state = {
startTime: 0,
obeyMuteSwitch: true,
volume: 1,
autoplay: false,
loop: false,
referrerPolicy: '',
};
Object.keys(state).forEach((key) => {
try {
audios[id][key] = state[key];
}
catch (e) { }
});
audios[id].stop();
const cacheAudio = audios[id];
setTimeout(() => {
WEBAudio.audioCache.push(cacheAudio);
}, 1000);
}
delete audios[id];
};
export const printErrMsg = (msg) => {
GameGlobal.manager.printErr(msg);
};
export function mkCacheDir() {
const fs = wx.getFileSystemManager();
fs.rmdir({
dirPath: TEMP_DIR_PATH,
recursive: true,
complete: () => {
fs.mkdir({
dirPath: TEMP_DIR_PATH,
});
},
});
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e2a44d191d5dc284b82ce97ddb30f888
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,24 @@
import moduleHelper from './module-helper';
import { formatJsonStr } from './utils';
let resolveFn = null;
export default {
WX_OnNeedPrivacyAuthorization() {
const callback = (resolve) => {
resolveFn = resolve;
moduleHelper.send('_OnNeedPrivacyAuthorizationCallback', '{}');
};
wx.onNeedPrivacyAuthorization(callback);
},
WX_PrivacyAuthorizeResolve(conf) {
const config = formatJsonStr(conf);
config.event = config.eventString;
if (resolveFn) {
resolveFn(config);
if (config.event === 'agree' || config.event === 'disagree') {
resolveFn = null;
}
}
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9248bb15ec0e0e94c98e921653cdd1b5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,100 @@
import moduleHelper from './module-helper';
import { formatJsonStr, cacheArrayBuffer, getListObject } from './utils';
const cameraList = {};
const getObject = getListObject(cameraList, 'camera');
export default {
WXCameraCreateCamera(conf, callbackId) {
const obj = wx.createCamera({
...formatJsonStr(conf),
success(res) {
moduleHelper.send('CameraCreateCallback', JSON.stringify({
callbackId,
type: 'success',
res: JSON.stringify(res),
}));
},
fail(res) {
moduleHelper.send('CameraCreateCallback', JSON.stringify({
callbackId,
type: 'fail',
res: JSON.stringify(res),
}));
},
complete(res) {
moduleHelper.send('CameraCreateCallback', JSON.stringify({
callbackId,
type: 'complete',
res: JSON.stringify(res),
}));
},
});
cameraList[callbackId] = obj;
},
WXCameraCloseFrameChange(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.closeFrameChange();
},
WXCameraDestroy(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.destroy();
},
WXCameraListenFrameChange(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.listenFrameChange();
},
WXCameraOnAuthCancel(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('CameraOnAuthCancelCallback', resStr);
};
obj.onAuthCancel(callback);
},
WXCameraOnCameraFrame(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
cacheArrayBuffer(id, res.data);
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify({
width: res.width,
height: res.height,
}),
});
moduleHelper.send('CameraOnCameraFrameCallback', resStr);
};
obj.onCameraFrame(callback);
},
WXCameraOnStop(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('CameraOnStopCallback', resStr);
};
obj.onStop(callback);
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d47af7e8f9a50f446bf39a0589cae248
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
const callbacks = [];
let isTriggered = false;
export default {
addCreatedListener(callback) {
if (isTriggered) {
callback();
}
else {
callbacks.push(callback);
}
},
_triggerCallback() {
isTriggered = true;
callbacks.forEach(v => v());
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6b3566bc3a916b94cae488c7d177f65c
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,46 @@
import response from './response';
import moduleHelper from './module-helper';
import { formatJsonStr } from './utils';
function getDefaultData(canvas, conf) {
const config = formatJsonStr(conf);
if (typeof config.x === 'undefined') {
config.x = 0;
}
if (typeof config.y === 'undefined') {
config.y = 0;
}
if (typeof config.width === 'undefined' || config.width === 0) {
config.width = canvas.width;
}
if (typeof config.height === 'undefined' || config.height === 0) {
config.height = canvas.height;
}
if (typeof config.destWidth === 'undefined' || config.destWidth === 0) {
config.destWidth = canvas.width;
}
if (typeof config.destHeight === 'undefined' || config.destHeight === 0) {
config.destHeight = canvas.height;
}
return config;
}
export default {
WXToTempFilePathSync(conf) {
return canvas.toTempFilePathSync(getDefaultData(canvas, conf));
},
WXToTempFilePath(conf, s, f, c) {
if (conf) {
canvas.toTempFilePath({
...getDefaultData(canvas, conf),
...response.handleText(s, f, c),
success: (res) => {
moduleHelper.send('ToTempFilePathCallback', JSON.stringify({
callbackId: s,
errMsg: res.errMsg,
errCode: res.errCode || 0,
tempFilePath: res.tempFilePath,
}));
},
});
}
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0fd6799d2bdb20a4a9bb599faf72c085
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,171 @@
import moduleHelper from './module-helper';
import { formatJsonStr, uid } from './utils';
let MiniGameChat;
let instance;
let onList;
function createMiniGameChat(options, callback) {
try {
if (typeof requirePlugin !== 'undefined') {
if (!MiniGameChat) {
MiniGameChat = requirePlugin('MiniGameChat', {
enableRequireHostModule: true,
customEnv: {
wx,
},
}).default;
}
if (instance) {
return '';
}
instance = new MiniGameChat(options);
if (typeof instance === 'undefined' || typeof instance.on === 'undefined') {
console.error('MiniGameChat create error');
return '';
}
// 等待插件初始化完成
instance.on('ready', () => {
if (!GameGlobal.miniGameChat) {
GameGlobal.miniGameChat = instance;
if (!onList) {
onList = {};
}
Object.keys(onList).forEach((eventType) => {
if (!onList) {
onList = {};
}
Object.values(onList[eventType]).forEach((callback) => {
instance.on(eventType, callback);
});
});
instance.emit('ready');
callback(instance);
}
});
instance.on('error', (err) => {
console.log('插件初始化失败', err);
});
return uid();
}
}
catch (e) {
console.error(e);
return '';
}
}
export default {
WXChatCreate(optionsStr) {
const options = formatJsonStr(optionsStr);
return createMiniGameChat({
x: options.x,
y: options.y,
autoShow: false,
logoUrl: options.logoUrl || '',
movable: options.movable,
enableSnap: options.enableSnap,
scale: options.scale,
}, (instance) => {
instance.on('error', (err) => {
console.error('error', err);
});
});
},
WXChatHide() {
if (!GameGlobal.miniGameChat) {
return;
}
GameGlobal.miniGameChat.hide();
},
WXChatShow(optionsStr) {
if (!GameGlobal.miniGameChat) {
return;
}
const options = formatJsonStr(optionsStr);
GameGlobal.miniGameChat.show({
x: options.x,
y: options.y,
});
},
WXChatClose() {
if (!GameGlobal.miniGameChat) {
return;
}
GameGlobal.miniGameChat.close();
},
WXChatOpen(key) {
if (!GameGlobal.miniGameChat) {
return;
}
GameGlobal.miniGameChat.open(key || '');
},
WXChatSetTabs(keysStr) {
if (!GameGlobal.miniGameChat) {
return;
}
if (!keysStr) {
// eslint-disable-next-line no-param-reassign
keysStr = '[]';
}
const keys = JSON.parse(keysStr);
GameGlobal.miniGameChat.setTabs(keys);
},
WXChatOff(eventType) {
const { miniGameChat } = GameGlobal;
if (!miniGameChat) {
return;
}
if (!miniGameChat || typeof onList === 'undefined' || typeof onList[eventType] === 'undefined') {
return;
}
for (const key in Object.keys(onList[eventType])) {
const callback = onList[eventType][key];
if (callback) {
miniGameChat.off(eventType, callback);
}
}
onList[eventType] = {};
},
WXChatOn(eventType) {
const callbackId = uid();
const callback = (res) => {
let result = '';
if (res) {
result = JSON.stringify(res);
}
const resStr = JSON.stringify({
eventType,
result,
});
moduleHelper.send('OnWXChatCallback', resStr);
};
if (!onList) {
onList = {};
}
if (typeof onList[eventType] === 'undefined') {
onList[eventType] = {};
}
if (onList[eventType]) {
onList[eventType][callbackId] = callback;
const { miniGameChat } = GameGlobal;
if (miniGameChat) {
miniGameChat.on(eventType, callback);
}
return callbackId;
}
return '';
},
WXChatSetSignature(signature) {
const { miniGameChat } = GameGlobal;
if (miniGameChat) {
miniGameChat.setChatSignature({ signature });
}
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cadba8d765a1a364f80866476496c3ad
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
import response from './response';
import { formatJsonStr } from './utils';
const CloudIDObject = {};
function fixWXCallFunctionData(data) {
for (const key in data) {
if (typeof data[key] === 'object') {
fixWXCallFunctionData(data[key]);
}
else if (typeof data[key] === 'string' && CloudIDObject[data[key]]) {
data[key] = CloudIDObject[data[key]];
}
}
}
export default {
WXCallFunctionInit(conf) {
const config = formatJsonStr(conf);
wx.cloud.init(config);
},
WXCallFunction(name, data, conf, s, f, c) {
const d = JSON.parse(data);
fixWXCallFunctionData(d);
wx.cloud.callFunction({
name,
data: d,
config: conf === '' ? null : JSON.parse(conf),
...response.handlecloudCallFunction(s, f, c),
});
},
WXCloudID(cloudId) {
const res = wx.cloud.CloudID(cloudId);
const r = JSON.stringify(res);
CloudIDObject[r] = res;
return r;
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: aafccbbbbaa00a447844823407a06c54
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1 @@
export const MODULE_NAME = 'WXSDKManagerHandler';
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 6fde30b28fa0ad841879b969541b8684
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,87 @@
export default {
init() {
this.fixTimer();
},
fixTimer() {
const wm = {};
const privateSetTimeout = window.setTimeout;
let id = 0;
const getId = function () {
id += 1;
if (id > 100000000) {
id = 0;
}
return id;
};
window.setTimeout = function (vCallback, nDelay) {
const aArgs = Array.prototype.slice.call(arguments, 2);
const id = getId();
const t = privateSetTimeout(vCallback instanceof Function
? () => {
vCallback.apply(null, aArgs);
delete wm[id];
}
: vCallback, nDelay);
wm[id] = t;
return id;
};
const privateClearTimeout = window.clearTimeout;
window.clearTimeout = function (id) {
if (id) {
const t = wm[id];
if (t) {
privateClearTimeout(t);
delete wm[id];
}
}
};
const privateSetInterval = window.setInterval;
window.setInterval = function (vCallback, nDelay) {
const aArgs = Array.prototype.slice.call(arguments, 2);
const id = getId();
const t = privateSetInterval(vCallback instanceof Function
? () => {
vCallback.apply(null, aArgs);
}
: vCallback, nDelay);
wm[id] = t;
return id;
};
const privateClearInterval = window.clearInterval;
window.clearInterval = function (id) {
if (id) {
const t = wm[id];
if (t) {
privateClearInterval(t);
delete wm[id];
}
}
};
const privateRequestAnimationFrame = window.requestAnimationFrame;
window.requestAnimationFrame = function (vCallback) {
const id = getId();
const t = privateRequestAnimationFrame(() => {
vCallback(0);
delete wm[id];
});
wm[id] = t;
return id;
};
const privateCancelAnimationFrame = window.cancelAnimationFrame;
window.cancelAnimationFrame = function (id) {
const t = wm[id];
if (t) {
privateCancelAnimationFrame(t);
delete wm[id];
}
};
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1c23889505c31a94380074a0bc61dd88
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f6215d5ab5ef679498939e01a0e1b7f8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,66 @@
export default function fixCmapTable(arrayBuffer) {
const font = new DataView(arrayBuffer);
const tableCount = font.getUint16(4);
let cmapOffset = 0;
let cmapLength = 0;
let cmapCheckSumOffset = 0;
let cmapCheckSum = 0;
for (let i = 0; i < tableCount; i++) {
const tag = font.getUint32(12 + i * 16);
if (tag === 0x636D6170) {
cmapCheckSumOffset = 12 + i * 16 + 4;
cmapCheckSum = font.getUint32(cmapCheckSumOffset);
cmapOffset = font.getUint32(12 + i * 16 + 8);
cmapLength = font.getUint32(12 + i * 16 + 12);
GameGlobal.manager.Logger.pluginLog(`[font]cmapCheckSubOffset [${cmapCheckSumOffset}], cmapCheckSum [${cmapCheckSum}], cmapOffset [${cmapOffset}], cmapLength [${cmapLength}]`);
}
}
if (cmapOffset === 0) {
GameGlobal.manager.Logger.pluginError('[font]not found cmap');
return false;
}
const cmap = new DataView(arrayBuffer, cmapOffset, cmapLength);
const numTables = cmap.getUint16(2);
let subtableOffset = 4;
let targetSubtableOffset = 0;
for (let i = 0; i < numTables; i++) {
const platformId = cmap.getUint16(subtableOffset);
const encodingId = cmap.getUint16(subtableOffset + 2);
if (platformId === 0 && encodingId === 5) {
if (i === (numTables - 1)) {
targetSubtableOffset = subtableOffset;
GameGlobal.manager.Logger.pluginLog(`[font]targetSubtableOffset ${targetSubtableOffset}`);
}
break;
}
subtableOffset += 8;
}
if (targetSubtableOffset > 0) {
const newCmapView = new DataView(arrayBuffer, cmapOffset, cmapLength - 8);
newCmapView.setUint16(2, numTables - 1);
let sum = 0;
const lengthInUint32 = (newCmapView.byteLength + 3) / 4;
for (let i = 0; i < lengthInUint32; i++) {
sum += newCmapView.getUint32(i);
}
font.setUint32(cmapCheckSumOffset, sum);
return true;
}
GameGlobal.manager.Logger.pluginLog('[font]not found cmap subtable');
return false;
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: bb3a71ed8ecb9ac4486138760082906e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
import moduleHelper from '../module-helper';
import { formatJsonStr } from '../utils';
import fixCmapTable from './fix-cmap';
import readMetrics from './read-metrics';
import splitTTCToBufferOnlySC from './split-sc';
const { platform } = wx.getSystemInfoSync();
const tempCacheObj = {};
let fontDataCache;
let getFontPromise;
let isReadFromCache = false;
const isIOS = platform === 'ios';
const isAndroid = platform === 'android';
function handleGetFontData(config, forceLoad = false) {
const canGetWxCommonFont = !!GameGlobal.manager?.font?.getCommonFont;
if (!config && !canGetWxCommonFont) {
return Promise.reject('invalid usage');
}
if (!getFontPromise || forceLoad) {
getFontPromise = new Promise((resolve, reject) => {
if (!canGetWxCommonFont && !!config) {
const xhr = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
xhr.open('GET', config.fallbackUrl, true);
xhr.responseType = 'arraybuffer';
xhr.onload = () => {
if ((xhr.status === 200 || xhr.status === 0) && xhr.response) {
const notoFontData = xhr.response;
fontDataCache = notoFontData;
isReadFromCache = xhr.isReadFromCache;
resolve();
}
};
xhr.onerror = reject;
xhr.send();
return;
}
GameGlobal.manager.font.getCommonFont({
success(fontData) {
if (isIOS) {
fixCmapTable(fontData);
}
if (isAndroid) {
const tempData = splitTTCToBufferOnlySC(fontData);
if (tempData) {
fontData = tempData;
}
}
fontDataCache = fontData;
resolve();
},
fail: reject,
});
});
}
return getFontPromise;
}
function WXGetFontRawData(conf, callbackId) {
const config = formatJsonStr(conf);
const loadFromRemote = !GameGlobal.manager?.font?.getCommonFont;
GameGlobal.manager.TimeLogger.timeStart('WXGetFontRawData');
handleGetFontData(config).then(() => {
if (fontDataCache) {
GameGlobal.manager.font.reportGetFontCost(GameGlobal.manager.TimeLogger.timeEnd('WXGetFontRawData'), { loadFromRemote, isReadFromCache, preloadWXFont: GameGlobal.unityNamespace.preloadWXFont });
const { ascent, descent, lineGap, unitsPerEm } = readMetrics(fontDataCache) || {};
tempCacheObj[callbackId] = fontDataCache;
moduleHelper.send('GetFontRawDataCallback', JSON.stringify({ callbackId, type: 'success', res: JSON.stringify({ byteLength: fontDataCache.byteLength, ascent, descent, lineGap, unitsPerEm }) }));
GameGlobal.manager.Logger.pluginLog(`[font] load font from ${loadFromRemote ? `network, url=${config.fallbackUrl}` : 'local'}`);
fontDataCache = null;
}
else {
GameGlobal.manager.Logger.pluginError('[font] load font error: empty content');
}
})
.catch((err) => {
GameGlobal.manager.Logger.pluginError('[font] load font error: ', err);
});
}
function WXShareFontBuffer(buffer, offset, callbackId) {
if (typeof tempCacheObj[callbackId] === 'string') {
GameGlobal.manager.Logger.pluginError('[font]内存写入异常');
}
buffer.set(new Uint8Array(tempCacheObj[callbackId]), offset);
delete tempCacheObj[callbackId];
}
export function preloadWxCommonFont() {
if (!!GameGlobal.unityNamespace.preloadWXFont && !!GameGlobal.manager?.font?.getCommonFont) {
handleGetFontData();
}
}
export default {
WXGetFontRawData,
WXShareFontBuffer,
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 0ae59ac9cad5d0341ae29f64c79fb367
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,41 @@
import { toBytesInt32 } from './util';
export default function readMetrics(arrayBuffer) {
const font = new DataView(arrayBuffer);
const tableCount = font.getUint16(4);
const ppem = 1;
let ascent = 0;
let descent = 0;
let lineGap = 0;
let unitsPerEm;
for (let i = 0; i < tableCount; i++) {
const tag = font.getUint32(12 + i * 16);
const tagStr = toBytesInt32(tag);
if (tagStr === 'hhea') {
const offset = font.getUint32(12 + i * 16 + 8);
const length = font.getUint32(12 + i * 16 + 12);
const hhea = new DataView(arrayBuffer, offset, length);
ascent = hhea.getInt16(4);
descent = hhea.getInt16(6);
lineGap = hhea.getInt16(8);
}
else if (tagStr === 'head') {
const offset = font.getUint32(12 + i * 16 + 8);
const length = font.getUint32(12 + i * 16 + 12);
const head = new DataView(arrayBuffer, offset, length);
unitsPerEm = head.getUint16(18);
}
}
if (!ascent || !descent || !unitsPerEm) {
return undefined;
}
return {
ascent: ascent * ppem / unitsPerEm,
descent: descent * ppem / unitsPerEm,
lineGap: lineGap * ppem / unitsPerEm,
unitsPerEm,
};
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ba0614c832510aa43b86dd9a8356abc9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,140 @@
import { ceil4, toBytesInt32, decodeUnicode } from './util';
function extractTTF(ttcView, tableHeaderOffset) {
const subFontTableCount = ttcView.getUint16(tableHeaderOffset + 0x04);
const subFontHeaderLength = 0x0C + subFontTableCount * 0x10;
let tableLength = 0;
for (let j = 0; j < subFontTableCount; j++) {
const length = ttcView.getUint32(tableHeaderOffset + 0x0C + 0x0C + j * 0x10);
tableLength += ceil4(length);
}
const totalLength = subFontHeaderLength + tableLength;
const newBuf = new ArrayBuffer(totalLength);
const newBufUint = new Uint8Array(newBuf);
const newBufData = new DataView(newBuf);
newBufUint.set(new Uint8Array(ttcView.buffer, tableHeaderOffset, subFontHeaderLength), 0);
let currentOffset = subFontHeaderLength;
for (let j = 0; j < subFontTableCount; j++) {
const offset = ttcView.getUint32(tableHeaderOffset + 0x0C + 0x08 + j * 0x10);
const length = ttcView.getUint32(tableHeaderOffset + 0x0C + 0x0C + j * 0x10);
newBufData.setUint32(0x0C + 0x08 + j * 0x10, currentOffset);
newBufUint.set(new Uint8Array(ttcView.buffer, offset, length), currentOffset);
currentOffset += ceil4(length);
}
return newBufData;
}
function parseTableToDataView(fontDataView, tableName, startOffset = 0) {
const font = fontDataView;
const tableCount = font.getUint16(startOffset + 4);
for (let i = 0; i < tableCount; i++) {
const tag = font.getUint32(startOffset + 12 + i * 16);
const tagStr = toBytesInt32(tag);
if (tagStr === tableName) {
const offset = font.getUint32(startOffset + 12 + i * 16 + 8);
const length = font.getUint32(startOffset + 12 + i * 16 + 12);
return new DataView(fontDataView.buffer, offset, length);
}
}
GameGlobal.manager.Logger.pluginError(`\tTable#${tableName} not found in DataView`);
return undefined;
}
function parseNameTable(fontDataView, startOffset = 0) {
const nameTable = parseTableToDataView(fontDataView, 'name', startOffset);
if (!nameTable) {
return undefined;
}
const result = {};
result.data = nameTable;
result.format = nameTable.getUint16(0);
result.count = nameTable.getUint16(2);
result.stringOffset = nameTable.getUint16(4);
const nameRecords = [];
for (let i = 0; i < result.count; i++) {
const offset = 6 + i * 12;
nameRecords.push({
platformID: nameTable.getUint16(offset),
platformSpecificID: nameTable.getUint16(offset + 2),
languageID: nameTable.getUint16(offset + 4),
nameID: nameTable.getUint16(offset + 6),
length: nameTable.getUint16(offset + 8),
offset: nameTable.getUint16(offset + 10),
});
}
result.nameRecords = nameRecords;
return result;
}
function parseFamilyName(fontDataView, startOffset = 0) {
const nameTable = parseNameTable(fontDataView, startOffset);
if (!nameTable) {
return undefined;
}
if (nameTable.nameRecords) {
for (const record of nameTable.nameRecords) {
const { nameID } = record;
if (nameID === 1) {
const { offset } = record;
const byteLength = record.length;
return decodeUnicode(fontDataView.buffer, (nameTable.data?.byteOffset || 0) + (nameTable.stringOffset || 0) + offset, byteLength);
}
}
}
return undefined;
}
export default function splitTTCToBufferOnlySC(arrayBuffer) {
const ttc = new DataView(arrayBuffer);
const tag = ttc.getUint32(0);
if (toBytesInt32(tag) !== 'ttcf') {
GameGlobal.manager.Logger.pluginError('input not a valid ttc file');
return undefined;
}
const ttfCount = ttc.getInt32(8);
let fontSCHeaderOffset = undefined;
const reg = /S\0?C/;
for (let i = 0; i < ttfCount; i++) {
const tableHeaderOffset = ttc.getUint32(0x0C + i * 4);
const familyName = parseFamilyName(ttc, tableHeaderOffset);
if (typeof familyName === 'string' && reg.test(familyName)) {
fontSCHeaderOffset = tableHeaderOffset;
break;
}
}
if (!fontSCHeaderOffset) {
GameGlobal.manager.Logger.pluginError('SC Font not found in TTC File.');
return undefined;
}
return extractTTF(ttc, fontSCHeaderOffset).buffer;
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2f94e57070564964cb628dc0d1d597a5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
export function toBytesInt32(num) {
let ascii = '';
for (let i = 3; i >= 0; i--) {
ascii += String.fromCharCode((num >> (8 * i)) & 255);
}
return ascii;
}
;
export function ceil4(n) {
return (n + 3) & ~3;
}
export function decodeUnicode(buffer, byteOffset, byteLength) {
const dataview = new Uint8Array(buffer, byteOffset, byteLength);
const ret = String.fromCharCode.apply(null, Array.from(dataview));
return ret;
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 905521993cef08345ac22af6b193656b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,456 @@
import response from './response';
import moduleHelper from './module-helper';
import { cacheArrayBuffer, formatJsonStr, formatResponse } from './utils';
function runMethod(method, option, callbackId, isString = false) {
try {
const fs = wx.getFileSystemManager();
let config;
if (typeof option === 'string') {
config = formatJsonStr(option);
}
else {
config = option;
}
if (method === 'readZipEntry' && !config.encoding) {
config.encoding = 'utf-8';
console.error('fs.readZipEntry不支持读取ArrayBuffer,已改为utf-8');
}
fs[method]({
...config,
success(res) {
let returnRes = '';
if (method === 'read') {
cacheArrayBuffer(callbackId, res.arrayBuffer);
returnRes = JSON.stringify({
bytesRead: res.bytesRead,
arrayBufferLength: res.arrayBuffer.byteLength,
});
}
else if (method === 'readCompressedFile') {
cacheArrayBuffer(callbackId, res.data);
returnRes = JSON.stringify({
arrayBufferLength: res.data.byteLength,
});
}
else if (method === 'readFile') {
if (config.encoding) {
returnRes = JSON.stringify({
stringData: res.data,
});
}
else {
cacheArrayBuffer(callbackId, res.data);
returnRes = JSON.stringify({
arrayBufferLength: res.data.byteLength,
});
}
}
else {
returnRes = JSON.stringify(res);
}
moduleHelper.send('FileSystemManagerCallback', JSON.stringify({
callbackId, type: 'success', res: returnRes, method: isString ? `${method}_string` : method,
}));
},
fail(res) {
moduleHelper.send('FileSystemManagerCallback', JSON.stringify({
callbackId, type: 'fail', res: JSON.stringify(res), method: isString ? `${method}_string` : method,
}));
},
complete(res) {
moduleHelper.send('FileSystemManagerCallback', JSON.stringify({
callbackId, type: 'complete', res: JSON.stringify(res), method: isString ? `${method}_string` : method,
}));
},
});
}
catch (e) {
moduleHelper.send('FileSystemManagerCallback', JSON.stringify({
callbackId, type: 'complete', res: 'fail', method: isString ? `${method}_string` : method,
}));
}
}
export default {
WXGetUserDataPath() {
return wx.env.USER_DATA_PATH;
},
WXWriteFileSync(filePath, data, encoding) {
try {
const fs = wx.getFileSystemManager();
fs.writeFileSync(filePath, data, encoding);
}
catch (e) {
console.error(e);
if (e.message) {
return e.message;
}
return 'fail';
}
return 'ok';
},
WXAccessFileSync(filePath) {
try {
const fs = wx.getFileSystemManager();
fs.accessSync(filePath);
return 'access:ok';
}
catch (e) {
if (e.message) {
return e.message;
}
return 'fail';
}
},
WXAccessFile(path, s, f, c) {
const fs = wx.getFileSystemManager();
fs.access({
path,
...response.handleText(s, f, c),
});
},
WXCopyFileSync(src, dst) {
try {
const fs = wx.getFileSystemManager();
fs.copyFileSync(src, dst);
return 'copyFile:ok';
}
catch (e) {
console.error(e);
if (e.message) {
return e.message;
}
return 'fail';
}
},
WXCopyFile(srcPath, destPath, s, f, c) {
const fs = wx.getFileSystemManager();
fs.copyFile({
srcPath,
destPath,
...response.handleText(s, f, c),
});
},
WXUnlinkSync(filePath) {
try {
const fs = wx.getFileSystemManager();
fs.unlinkSync(filePath);
return 'unlink:ok';
}
catch (e) {
console.error(e);
if (e.message) {
return e.message;
}
return 'fail';
}
},
WXUnlink(filePath, s, f, c) {
const fs = wx.getFileSystemManager();
fs.unlink({
filePath,
...response.handleText(s, f, c),
});
},
WXWriteFile(filePath, data, encoding, s, f, c) {
const fs = wx.getFileSystemManager();
fs.writeFile({
filePath,
data: data.buffer,
encoding,
...response.handleTextLongBack(s, f, c),
});
},
WXWriteStringFile(filePath, data, encoding, s, f, c) {
const fs = wx.getFileSystemManager();
fs.writeFile({
filePath,
data,
encoding,
...response.handleTextLongBack(s, f, c),
});
},
WXAppendFile(filePath, data, encoding, s, f, c) {
const fs = wx.getFileSystemManager();
fs.appendFile({
filePath,
data: data.buffer,
encoding,
...response.handleTextLongBack(s, f, c),
});
},
WXAppendStringFile(filePath, data, encoding, s, f, c) {
const fs = wx.getFileSystemManager();
fs.appendFile({
filePath,
data,
encoding,
...response.handleTextLongBack(s, f, c),
});
},
WXWriteBinFileSync(filePath, data, encoding) {
const fs = wx.getFileSystemManager();
try {
fs.writeFileSync(filePath, data.buffer, encoding);
}
catch (e) {
console.error(e);
if (e.message) {
return e.message;
}
return 'fail';
}
return 'ok';
},
WXReadFile(option, callbackId) {
runMethod('readFile', option, callbackId);
},
WXReadFileSync(option) {
const fs = wx.getFileSystemManager();
const config = formatJsonStr(option);
try {
const { filePath } = config;
const res = fs.readFileSync(config.filePath, config.encoding, config.position, config.length);
if (!config.encoding && typeof res !== 'string') {
cacheArrayBuffer(filePath, res);
return `${res.byteLength}`;
}
return res;
}
catch (e) {
console.error(e);
if (e.message) {
return e.message;
}
return 'fail';
}
},
WXMkdir(dirPath, recursive, s, f, c) {
const fs = wx.getFileSystemManager();
fs.mkdir({
dirPath,
recursive: Boolean(recursive),
...response.handleText(s, f, c),
});
},
WXMkdirSync(dirPath, recursive) {
try {
const fs = wx.getFileSystemManager();
fs.mkdirSync(dirPath, Boolean(recursive));
return 'mkdir:ok';
}
catch (e) {
console.error(e);
if (e.message) {
return e.message;
}
return 'fail';
}
},
WXRmdir(dirPath, recursive, s, f, c) {
const fs = wx.getFileSystemManager();
fs.rmdir({
dirPath,
recursive: Boolean(recursive),
...response.handleText(s, f, c),
});
},
WXRmdirSync(dirPath, recursive) {
try {
const fs = wx.getFileSystemManager();
fs.rmdirSync(dirPath, Boolean(recursive));
return 'rmdirSync:ok';
}
catch (e) {
console.error(e);
if (e.message) {
return e.message;
}
return 'fail';
}
},
WXStat(conf, callbackId) {
const config = formatJsonStr(conf);
wx.getFileSystemManager().stat({
...config,
success(res) {
if (!Array.isArray(res.stats)) {
res.one_stat = res.stats;
res.stats = null;
}
moduleHelper.send('StatCallback', JSON.stringify({
callbackId,
type: 'success',
res: JSON.stringify(res),
}));
},
fail(res) {
moduleHelper.send('StatCallback', JSON.stringify({
callbackId,
type: 'fail',
res: JSON.stringify(res),
}));
},
complete(res) {
if (!Array.isArray(res.stats)) {
res.one_stat = res.stats;
res.stats = null;
}
moduleHelper.send('StatCallback', JSON.stringify({
callbackId,
type: 'complete',
res: JSON.stringify(res),
}));
},
});
},
WX_FileSystemManagerClose(option, callbackId) {
runMethod('close', option, callbackId);
},
WX_FileSystemManagerFstat(option, callbackId) {
runMethod('fstat', option, callbackId);
},
WX_FileSystemManagerFtruncate(option, callbackId) {
runMethod('ftruncate', option, callbackId);
},
WX_FileSystemManagerGetFileInfo(option, callbackId) {
runMethod('getFileInfo', option, callbackId);
},
WX_FileSystemManagerGetSavedFileList(option, callbackId) {
runMethod('getSavedFileList', option, callbackId);
},
WX_FileSystemManagerOpen(option, callbackId) {
runMethod('open', option, callbackId);
},
WX_FileSystemManagerRead(option, data, callbackId) {
const config = formatJsonStr(option);
config.arrayBuffer = data.buffer;
runMethod('read', config, callbackId);
},
WX_FileSystemManagerReadCompressedFile(option, callbackId) {
runMethod('readCompressedFile', option, callbackId);
},
WX_FileSystemManagerReadZipEntry(option, callbackId) {
runMethod('readZipEntry', option, callbackId);
},
WX_FileSystemManagerReadZipEntryString(option, callbackId) {
runMethod('readZipEntry', option, callbackId, true);
},
WX_FileSystemManagerReaddir(option, callbackId) {
runMethod('readdir', option, callbackId);
},
WX_FileSystemManagerRemoveSavedFile(option, callbackId) {
runMethod('removeSavedFile', option, callbackId);
},
WX_FileSystemManagerRename(option, callbackId) {
runMethod('rename', option, callbackId);
},
WX_FileSystemManagerSaveFile(option, callbackId) {
runMethod('saveFile', option, callbackId);
},
WX_FileSystemManagerTruncate(option, callbackId) {
runMethod('truncate', option, callbackId);
},
WX_FileSystemManagerUnzip(option, callbackId) {
runMethod('unzip', option, callbackId);
},
WX_FileSystemManagerWrite(option, data, callbackId) {
const config = formatJsonStr(option);
config.data = data.buffer;
runMethod('write', config, callbackId);
},
WX_FileSystemManagerWriteString(option, callbackId) {
runMethod('write', option, callbackId, true);
},
WX_FileSystemManagerReaddirSync(dirPath) {
const fs = wx.getFileSystemManager();
return JSON.stringify(fs.readdirSync(dirPath));
},
WX_FileSystemManagerReadCompressedFileSync(option, callbackId) {
const fs = wx.getFileSystemManager();
const res = fs.readCompressedFileSync(formatJsonStr(option));
cacheArrayBuffer(callbackId, res);
return res.byteLength;
},
WX_FileSystemManagerAppendFileStringSync(filePath, data, encoding) {
const fs = wx.getFileSystemManager();
fs.appendFileSync(filePath, data, encoding);
},
WX_FileSystemManagerAppendFileSync(filePath, data, encoding) {
const fs = wx.getFileSystemManager();
fs.appendFileSync(filePath, data.buffer, encoding);
},
WX_FileSystemManagerRenameSync(oldPath, newPath) {
const fs = wx.getFileSystemManager();
fs.renameSync(oldPath, newPath);
return 'ok';
},
WX_FileSystemManagerReadSync(option, callbackId) {
const fs = wx.getFileSystemManager();
const res = fs.readSync(formatJsonStr(option));
cacheArrayBuffer(callbackId, res.arrayBuffer);
return JSON.stringify({
bytesRead: res.bytesRead,
arrayBufferLength: res.arrayBuffer.byteLength,
});
},
WX_FileSystemManagerFstatSync(option) {
const fs = wx.getFileSystemManager();
const res = fs.fstatSync(formatJsonStr(option));
formatResponse('Stats', res);
return JSON.stringify(res);
},
WX_FileSystemManagerStatSync(path, recursive) {
const fs = wx.getFileSystemManager();
return JSON.stringify(fs.statSync(path, recursive));
},
WX_FileSystemManagerWriteSync(option, data) {
const fs = wx.getFileSystemManager();
const optionConfig = formatJsonStr(option);
optionConfig.data = data.buffer;
const res = fs.writeSync(optionConfig);
return JSON.stringify({
mode: res.bytesWritten,
});
},
WX_FileSystemManagerWriteStringSync(option) {
const fs = wx.getFileSystemManager();
const res = fs.writeSync(formatJsonStr(option));
return JSON.stringify({
mode: res.bytesWritten,
});
},
WX_FileSystemManagerOpenSync(option) {
const fs = wx.getFileSystemManager();
return fs.openSync(formatJsonStr(option));
},
WX_FileSystemManagerSaveFileSync(tempFilePath, filePath) {
const fs = wx.getFileSystemManager();
return fs.saveFileSync(tempFilePath, filePath);
},
WX_FileSystemManagerCloseSync(option) {
const fs = wx.getFileSystemManager();
fs.closeSync(formatJsonStr(option));
return 'ok';
},
WX_FileSystemManagerFtruncateSync(option) {
const fs = wx.getFileSystemManager();
fs.ftruncateSync(formatJsonStr(option));
return 'ok';
},
WX_FileSystemManagerTruncateSync(option) {
const fs = wx.getFileSystemManager();
fs.truncateSync(formatJsonStr(option));
return 'ok';
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4e0c3e0185127cf4db5bdc8fe4d82e95
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,99 @@
import moduleHelper from './module-helper';
import { formatJsonStr, getListObject, uid } from './utils';
const gameClubButtonList = {};
const typeEnum = {
0: 'text',
1: 'image',
};
const iconEnum = {
0: 'green',
1: 'white',
2: 'dark',
3: 'light',
};
const getObject = getListObject(gameClubButtonList, 'gameClubButton');
export default {
WXCreateGameClubButton(conf) {
const config = formatJsonStr(conf);
config.style = JSON.parse(config.styleRaw);
if (config.style.fontSize === 0) {
config.style.fontSize = undefined;
}
config.type = typeEnum[config.type];
config.icon = iconEnum[config.icon];
const id = uid();
gameClubButtonList[id] = wx.createGameClubButton(config);
return id;
},
WXGameClubButtonDestroy(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.destroy();
if (gameClubButtonList) {
delete gameClubButtonList[id];
}
},
WXGameClubButtonHide(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.hide();
},
WXGameClubButtonShow(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.show();
},
WXGameClubButtonAddListener(id, key) {
const obj = getObject(id);
if (!obj) {
return;
}
obj[key](() => {
moduleHelper.send('OnGameClubButtonCallback', JSON.stringify({
callbackId: id,
errMsg: key,
}));
});
},
WXGameClubButtonRemoveListener(id, key) {
const obj = getObject(id);
if (!obj) {
return;
}
obj[key]();
},
WXGameClubButtonSetProperty(id, key, value) {
const obj = getObject(id);
if (!obj) {
return;
}
obj[key] = value;
},
WXGameClubStyleChangeInt(id, key, value) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.style[key] = value;
},
WXGameClubStyleChangeStr(id, key, value) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.style[key] = value;
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c32fda3ed97284545a5c5b519aec3b4b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,112 @@
import moduleHelper from './module-helper';
import { formatJsonStr, getListObject, uid } from './utils';
const gameRecorderList = {};
let wxGameRecorderList;
const getObject = getListObject(gameRecorderList, 'gameRecorder');
export default {
WX_GetGameRecorder() {
const id = uid();
gameRecorderList[id] = wx.getGameRecorder();
return id;
},
WX_GameRecorderOff(id, eventType) {
const obj = getObject(id);
if (!obj) {
return;
}
if (!obj || typeof wxGameRecorderList === 'undefined' || typeof wxGameRecorderList[eventType] === 'undefined') {
return;
}
for (const key in Object.keys(wxGameRecorderList[eventType])) {
const callback = wxGameRecorderList[eventType][key];
if (callback) {
obj.off(eventType, callback);
}
}
wxGameRecorderList[eventType] = {};
},
WX_GameRecorderOn(id, eventType) {
const obj = getObject(id);
if (!obj) {
return;
}
if (!wxGameRecorderList) {
wxGameRecorderList = {
start: {},
stop: {},
pause: {},
resume: {},
abort: {},
timeUpdate: {},
error: {},
};
}
const callbackId = uid();
const callback = (res) => {
let result = '';
if (res) {
result = JSON.stringify(res);
}
const resStr = JSON.stringify({
id,
res: JSON.stringify({
eventType,
result,
}),
});
moduleHelper.send('_OnGameRecorderCallback', resStr);
};
if (wxGameRecorderList[eventType]) {
wxGameRecorderList[eventType][callbackId] = callback;
obj.on(eventType, callback);
return callbackId;
}
return '';
},
WX_GameRecorderStart(id, option) {
const obj = getObject(id);
if (!obj) {
return;
}
const data = formatJsonStr(option);
obj.start(data);
},
WX_GameRecorderAbort(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.abort();
},
WX_GameRecorderPause(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.pause();
},
WX_GameRecorderResume(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.resume();
},
WX_GameRecorderStop(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.stop();
},
WX_OperateGameRecorderVideo(option) {
if (typeof wx.operateGameRecorderVideo !== 'undefined') {
const data = formatJsonStr(option);
data.fail = (res) => {
console.error(res);
};
wx.operateGameRecorderVideo(data);
}
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4e8a6bd86c83db94f83bfc2aacff25a4
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,102 @@
import storage from './storage';
import userInfo from './userinfo';
import moduleHelper from './module-helper';
import share from './share';
import ad from './ad';
import canvasHelper from './canvas';
import fs from './fs';
import openData from './open-data';
import util from './util';
import cloud from './cloud';
import audio from './audio/index';
import texture from './texture';
import fix from './fix';
import canvasContext from './canvas-context';
import video from './video';
import logger from './logger';
import gameClub from './game-club';
import sdk from './sdk';
import camera from './camera';
import recorder from './recorder';
import uploadFile from './upload-file';
import gameRecorder from './game-recorder';
import chat from './chat';
import font from './font/index';
import authorize from './authorize';
import videoDecoder from './video/index';
const unityVersion = '$unityVersion$';
GameGlobal.unityNamespace = GameGlobal.unityNamespace || {};
GameGlobal.unityNamespace.unityVersion = unityVersion;
window._ScaleRate = 1;
if (unityVersion && unityVersion.split('.').slice(0, 2)
.join('') < '20193') {
const width = window.innerWidth * window.devicePixelRatio;
const height = window.innerHeight * window.devicePixelRatio;
canvas.width = width;
canvas.height = height;
window._ScaleRate = window.devicePixelRatio;
}
Object.defineProperty(canvas, 'clientHeight', {
get() {
return window.innerHeight * window._ScaleRate;
},
configurable: true,
});
Object.defineProperty(canvas, 'clientWidth', {
get() {
return window.innerWidth * window._ScaleRate;
},
configurable: true,
});
Object.defineProperty(document.body, 'clientHeight', {
get() {
return window.innerHeight * window._ScaleRate;
},
configurable: true,
});
Object.defineProperty(document.body, 'clientWidth', {
get() {
return window.innerWidth * window._ScaleRate;
},
configurable: true,
});
Object.defineProperty(document, 'fullscreenEnabled', {
get() {
return true;
},
configurable: true,
});
fix.init();
const WXWASMSDK = {
WXInitializeSDK() {
moduleHelper.init();
moduleHelper.send('Inited', 200);
},
...storage,
...userInfo,
...share,
...ad,
...canvasHelper,
...fs,
...openData,
...util,
...cloud,
...audio,
...texture,
...video,
...logger,
...gameClub,
canvasContext,
...sdk,
...camera,
...recorder,
...uploadFile,
...gameRecorder,
...chat,
...font,
...authorize,
...videoDecoder,
};
GameGlobal.WXWASMSDK = WXWASMSDK;
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 96a81fa16373b9a4aac6a58155230ff0
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,27 @@
let logger;
export default {
WXLogManagerDebug(str) {
if (!logger) {
logger = wx.getLogManager({ level: 0 });
}
logger.debug(str);
},
WXLogManagerInfo(str) {
if (!logger) {
logger = wx.getLogManager({ level: 0 });
}
logger.info(str);
},
WXLogManagerLog(str) {
if (!logger) {
logger = wx.getLogManager({ level: 0 });
}
logger.log(str);
},
WXLogManagerWarn(str) {
if (!logger) {
logger = wx.getLogManager({ level: 0 });
}
logger.warn(str);
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 86ec7ae332fef814195934dd106d73c5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,14 @@
import { MODULE_NAME } from './conf';
export default {
_send: null,
init() {
this._send = GameGlobal.Module.SendMessage;
},
send(method, str = '') {
if (!this._send) {
this.init();
}
this._send(MODULE_NAME, method, str);
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: fe3a1aef723b2df428a83c049dd07942
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,92 @@
let cachedOpenDataContext;
let cachedSharedCanvas;
function getOpenDataContext() {
return cachedOpenDataContext || wx.getOpenDataContext();
}
function getSharedCanvas() {
return cachedSharedCanvas || getOpenDataContext().canvas;
}
let timerId;
let textureObject = null;
let textureId;
function hookUnityRender() {
if (!textureId) {
return;
}
const { GL } = GameGlobal.manager.gameInstance.Module;
const gl = GL.currentContext.GLctx;
if (!textureObject) {
textureObject = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D, textureObject);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, getSharedCanvas());
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
}
else {
gl.bindTexture(gl.TEXTURE_2D, textureObject);
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, getSharedCanvas());
}
GL.textures[textureId] = textureObject;
timerId = requestAnimationFrame(hookUnityRender);
}
function stopLastRenderLoop() {
if (typeof timerId !== 'undefined') {
cancelAnimationFrame(timerId);
}
}
function startHookUnityRender() {
stopLastRenderLoop();
hookUnityRender();
}
function stopHookUnityRender() {
stopLastRenderLoop();
const sharedCanvas = getSharedCanvas();
sharedCanvas.width = 1;
sharedCanvas.height = 1;
const { GL } = GameGlobal.manager.gameInstance.Module;
const gl = GL.currentContext.GLctx;
gl.deleteTexture(textureObject);
textureObject = null;
}
export default {
WXDataContextPostMessage(msg) {
getOpenDataContext().postMessage(msg);
},
WXShowOpenData(id, x, y, width, height) {
if (width <= 0 || height <= 0) {
console.error('[unity-sdk]: WXShowOpenData要求 width 和 height 参数必须大于0');
}
const openDataContext = getOpenDataContext();
const sharedCanvas = openDataContext.canvas;
sharedCanvas.width = width;
sharedCanvas.height = height;
openDataContext.postMessage({
type: 'WXRender',
x,
y,
width,
height,
devicePixelRatio: window.devicePixelRatio,
});
textureId = id;
startHookUnityRender();
},
WXHideOpenData() {
getOpenDataContext().postMessage({
type: 'WXDestroy',
});
stopHookUnityRender();
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: c57236f4d3d037242a5947fd2215d8cc
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,156 @@
import moduleHelper from './module-helper';
import { formatJsonStr, cacheArrayBuffer, getListObject, uid } from './utils';
const recorderManagerList = {};
const getObject = getListObject(recorderManagerList, 'video');
export default {
WX_GetRecorderManager() {
const id = uid();
recorderManagerList[id] = wx.getRecorderManager();
return id;
},
WX_OnRecorderError(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('_OnRecorderErrorCallback', resStr);
};
obj.onError(callback);
},
WX_OnRecorderFrameRecorded(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
cacheArrayBuffer(id, res.frameBuffer);
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify({
frameBufferLength: res.frameBuffer.byteLength,
isLastFrame: res.isLastFrame,
}),
});
moduleHelper.send('_OnRecorderFrameRecordedCallback', resStr);
};
obj.onFrameRecorded(callback);
},
WX_OnRecorderInterruptionBegin(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('_OnRecorderInterruptionBeginCallback', resStr);
};
obj.onInterruptionBegin(callback);
},
WX_OnRecorderInterruptionEnd(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('_OnRecorderInterruptionEndCallback', resStr);
};
obj.onInterruptionEnd(callback);
},
WX_OnRecorderPause(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('_OnRecorderPauseCallback', resStr);
};
obj.onPause(callback);
},
WX_OnRecorderResume(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('_OnRecorderResumeCallback', resStr);
};
obj.onResume(callback);
},
WX_OnRecorderStart(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('_OnRecorderStartCallback', resStr);
};
obj.onStart(callback);
},
WX_OnRecorderStop(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: id,
res: JSON.stringify(res),
});
moduleHelper.send('_OnRecorderStopCallback', resStr);
};
obj.onStop(callback);
},
WX_RecorderPause(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.pause();
},
WX_RecorderResume(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.resume();
},
WX_RecorderStart(id, option) {
const obj = getObject(id);
if (!obj) {
return;
}
const conf = formatJsonStr(option);
obj.start(conf);
},
WX_RecorderStop(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.stop();
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 5a3e79a66a4ca824996872634307c5dd
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 657309b60263ab940bb772014e6df0ce
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
export const ResTypeOther = {
Stats: {
lastAccessedTime: 'number',
lastModifiedTime: 'number',
mode: 'number',
size: 'number',
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 71ad2dc918b60fc4e9c1f2563f948c12
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,98 @@
import moduleHelper from './module-helper';
export default {
handleText(s, f, c) {
const self = this;
return {
success(res) {
self.textFormat(s, res);
},
fail(res) {
self.textFormat(f, res);
},
complete(res) {
self.textFormat(c, res);
},
};
},
handleTextLongBack(s, f, c) {
const self = this;
return {
success(res) {
self.textFormatLongBack(s, res);
},
fail(res) {
self.textFormatLongBack(f, res);
},
complete(res) {
self.textFormatLongBack(c, res);
},
};
},
textFormat(id, res) {
if (!id) {
return false;
}
moduleHelper.send('TextResponseCallback', JSON.stringify({
callbackId: id,
errMsg: res.errMsg,
errCode: res.errCode,
}));
},
textFormatLongBack(id, res) {
if (!id) {
return false;
}
moduleHelper.send('TextResponseLongCallback', JSON.stringify({
callbackId: id,
errMsg: res.errMsg,
errCode: res.errCode,
}));
},
handlecloudCallFunction(s, f, c) {
const self = this;
return {
success(res) {
self.cloudCallFunctionFormat(s, res);
},
fail(res) {
self.cloudCallFunctionFormat(f, res);
},
complete(res) {
self.cloudCallFunctionFormat(c, res);
},
};
},
cloudCallFunctionFormat(id, res) {
if (!id) {
return false;
}
moduleHelper.send('CloudCallFunctionResponseCallback', JSON.stringify({
callbackId: id,
errMsg: res.errMsg,
result: typeof res.result === 'object' ? JSON.stringify(res.result) : res.result,
requestID: res.requestID,
}));
},
handle(formatFunc, s, f, c) {
return {
success(res) {
if (!s) {
return false;
}
formatFunc(s, res);
},
fail(res) {
if (!f) {
return false;
}
formatFunc(f, res);
},
complete(res) {
if (!c) {
return false;
}
formatFunc(c, res);
},
};
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 4ca528a60b39d35438668b0d04e5d25a
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 7cabd49f1f9a9b94f982552f4ddd219b
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,29 @@
import moduleHelper from './module-helper';
import { formatJsonStr } from './utils';
let shareResolve;
export default {
WXShareAppMessage(conf) {
wx.shareAppMessage({
...formatJsonStr(conf),
});
},
WXOnShareAppMessage(conf, isPromise) {
wx.onShareAppMessage(() => ({
...formatJsonStr(conf),
promise: isPromise
? new Promise((resolve) => {
shareResolve = resolve;
moduleHelper.send('OnShareAppMessageCallback');
})
: null,
}));
},
WXOnShareAppMessageResolve(conf) {
if (shareResolve) {
shareResolve(formatJsonStr(conf));
}
},
};
wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline'],
});
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 14340126ad5fea54a814b10d19a49c0e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,155 @@
const PreLoadKeys = '$PreLoadKeys';
const storage = {
_cacheData: {},
_handleList: [],
isRunning: false,
isCallDeletedAll: false,
getData(key, defaultValue) {
let v = this._cacheData[key];
if (v === null) {
return defaultValue;
}
if (typeof v !== 'undefined') {
return v;
}
if (this.isCallDeletedAll) {
return defaultValue;
}
try {
v = wx.getStorageSync(key);
this._cacheData[key] = v !== '' ? v : null;
return v === '' ? defaultValue : v;
}
catch (e) {
// console.error(e);
return defaultValue;
}
},
setData(key, value) {
this._cacheData[key] = value;
this._handleList.push({
type: 'setData',
key,
value,
});
this._doRun();
},
deleteKey(key) {
this._cacheData[key] = null;
this._handleList.push({
type: 'deleteKey',
key,
});
this._doRun();
},
deleteAll() {
Object.keys(this._cacheData).forEach((key) => {
this._cacheData[key] = null;
});
this.isCallDeletedAll = true;
this._handleList.push({
type: 'deleteAll',
});
this._doRun();
},
_doRun() {
if (this.isRunning || this._handleList.length === 0) {
return false;
}
this.isRunning = true;
const task = this._handleList.shift();
if (!task) {
this.isRunning = false;
this._doRun();
return;
}
if (task.type === 'setData') {
wx.setStorage({
key: task.key || 'defaultKey',
data: task.value,
fail({ errMsg }) {
console.error(errMsg);
},
complete: () => {
this.isRunning = false;
this._doRun();
},
});
}
else if (task.type === 'deleteKey') {
wx.removeStorage({
key: task.key || 'defaultKey',
fail({ errMsg }) {
console.error(errMsg);
},
complete: () => {
this.isRunning = false;
this._doRun();
},
});
}
else if (task.type === 'deleteAll') {
wx.clearStorage({
fail({ errMsg }) {
console.error(errMsg);
},
complete: () => {
this.isRunning = false;
this._doRun();
},
});
}
else {
this.isRunning = false;
this._doRun();
}
},
init() {
if (Array.isArray(PreLoadKeys) && PreLoadKeys.length > 0) {
const key = PreLoadKeys.shift();
wx.getStorage({
key,
success(res) {
storage._cacheData[key] = res.data;
storage.init();
},
fail() {
storage._cacheData[key] = null;
storage.init();
},
});
}
},
};
setTimeout(() => {
storage.init();
}, 0);
export default {
WXStorageGetIntSync(key, defaultValue) {
return +(storage.getData(key, defaultValue) || '');
},
WXStorageSetIntSync(key, value) {
storage.setData(key, value);
},
WXStorageGetFloatSync(key, defaultValue) {
return +(storage.getData(key, defaultValue) || '');
},
WXStorageSetFloatSync(key, value) {
storage.setData(key, value);
},
WXStorageGetStringSync(key, defaultValue) {
return storage.getData(key, defaultValue) || '';
},
WXStorageSetStringSync(key, value) {
storage.setData(key, value);
},
WXStorageDeleteAllSync() {
storage.deleteAll();
},
WXStorageDeleteKeySync(key) {
storage.deleteKey(key);
},
WXStorageHasKeySync(key) {
return storage.getData(key, '') !== '';
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a63cd37e1e122994aa6e04c9bb338aee
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,273 @@
import canvasContext from './canvas-context';
const downloadedTextures = {};
const downloadingTextures = {};
const downloadFailedTextures = {};
let hasCheckSupportedExtensions = false;
if (typeof window !== 'undefined' && window.indexedDB) {
Object.defineProperty(window, 'indexedDB', {
get() {
return undefined;
},
set() { },
enumerable: true,
configurable: true,
});
}
const PotList = [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096];
const UseDXT5 = '$UseDXT5$';
const pngPath = GameGlobal.unityNamespace.unityColorSpace && GameGlobal.unityNamespace.unityColorSpace === 'Linear' ? 'lpng' : 'png';
let isStopDownloadTexture = false;
const cachedDownloadTask = [];
wx.stopDownloadTexture = function () {
isStopDownloadTexture = true;
};
wx.starDownloadTexture = function () {
isStopDownloadTexture = false;
while (cachedDownloadTask.length > 0) {
const task = cachedDownloadTask.shift();
if (task) {
mod.WXDownloadTexture(task.path, task.width, task.height, task.callback, task.limitType);
}
}
};
const mod = {
getSupportedExtensions() {
if (hasCheckSupportedExtensions) {
return GameGlobal.TextureCompressedFormat;
}
const list = canvas
.getContext(GameGlobal.managerConfig.contextConfig.contextType === 2 ? 'webgl2' : 'webgl')
.getSupportedExtensions();
const noneLimitSupportedTextures = ['']; // 兜底采用png
GameGlobal.TextureCompressedFormat = '';
if (list.indexOf('WEBGL_compressed_texture_s3tc') !== -1 && UseDXT5) {
GameGlobal.TextureCompressedFormat = 'dds';
}
if (list.indexOf('WEBGL_compressed_texture_pvrtc') !== -1) {
GameGlobal.TexturePVRTCSupported = true;
GameGlobal.TextureCompressedFormat = 'pvr';
}
if (list.indexOf('WEBGL_compressed_texture_etc') !== -1) {
GameGlobal.TextureEtc2Supported = true;
noneLimitSupportedTextures.push('etc2');
GameGlobal.TextureCompressedFormat = 'etc2';
}
if (list.indexOf('WEBGL_compressed_texture_astc') !== -1) {
noneLimitSupportedTextures.push('astc');
GameGlobal.TextureCompressedFormat = 'astc';
}
hasCheckSupportedExtensions = true;
GameGlobal.NoneLimitSupportedTexture = noneLimitSupportedTextures.pop();
return GameGlobal.TextureCompressedFormat;
},
getRemoteImageFile(path, width, height, limitType) {
let textureFormat = GameGlobal.TextureCompressedFormat;
if (textureFormat && limitType) {
textureFormat = GameGlobal.NoneLimitSupportedTexture;
}
if (!textureFormat
|| (textureFormat === 'pvr' && (width !== height || PotList.indexOf(width) === -1))
|| (textureFormat === 'dds' && (width % 4 !== 0 || height % 4 !== 0))) {
mod.downloadFile(path, width, height);
}
else {
mod.requestFile(path, width, height, textureFormat, limitType);
}
},
reTryRemoteImageFile(path, width, height, limitType = false) {
const cid = path;
if (!downloadFailedTextures[cid]) {
downloadFailedTextures[cid] = {
count: 0,
path,
width,
height,
limitType,
};
}
if (downloadFailedTextures[cid].count > 4) {
return;
}
setTimeout(() => {
mod.getRemoteImageFile(path, width, height, limitType);
}, Math.pow(2, downloadFailedTextures[cid].count) * 250);
downloadFailedTextures[cid].count++;
},
requestFile(path, width, height, format, limitType) {
const cid = path;
const url = `${GameGlobal.manager.assetPath.replace(/\/$/, '')}/Textures/${format}/${width}/${path}.txt`;
const xmlhttp = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
xmlhttp.responseType = 'arraybuffer';
xmlhttp.open('GET', url, true);
xmlhttp.onload = function () {
const res = xmlhttp;
if (res.status === 200) {
downloadedTextures[cid] = {
data: res.response,
tmpFile: '',
};
downloadingTextures[cid].forEach(v => v());
delete downloadingTextures[cid];
delete downloadFailedTextures[cid];
delete downloadedTextures[cid].data;
}
else {
// err("压缩纹理下载失败!url:"+url);
mod.reTryRemoteImageFile(path, width, height, limitType);
}
};
xmlhttp.onerror = function () {
// err("压缩纹理下载失败!url:"+url);
mod.reTryRemoteImageFile(path, width, height, limitType);
};
xmlhttp.send(null);
},
callbackPngFile(path, cid) {
const image = wx.createImage();
image.crossOrigin = '';
image.src = path;
image.onload = function () {
downloadedTextures[cid] = {
data: image,
tmpFile: '',
};
downloadingTextures[cid].forEach(v => v());
delete downloadingTextures[cid];
delete downloadFailedTextures[cid];
delete downloadedTextures[cid];
};
},
downloadFile(path, width, height) {
const url = `${GameGlobal.manager.assetPath.replace(/\/$/, '')}/Textures/${pngPath}/${width}/${path}.png`;
const cid = path;
const cache = GameGlobal.manager.getCachePath(url);
if (cache) {
mod.callbackPngFile(cache, cid);
}
else {
if (GameGlobal.unityNamespace.needCacheTextures) {
const xmlhttp = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
xmlhttp.responseType = 'arraybuffer';
xmlhttp.open('GET', url, true);
xmlhttp.onsave = function (path) {
mod.callbackPngFile(path, cid);
};
xmlhttp.onerror = function () {
mod.reTryRemoteImageFile(path, width, height);
};
xmlhttp.send(null);
}
else {
const image = wx.createImage();
image.crossOrigin = '';
image.src = url;
image.onload = function () {
downloadedTextures[cid] = {
data: image,
tmpFile: '',
};
downloadingTextures[cid].forEach(v => v());
delete downloadingTextures[cid];
delete downloadFailedTextures[cid];
delete downloadedTextures[cid];
};
image.onerror = function () {
mod.reTryRemoteImageFile(path, width, height);
};
}
}
},
WXDownloadTexture(path, width, height, callback, limitType = false) {
const width4m = width % 4;
if (width4m !== 0) {
width += 4 - width4m;
}
if (!hasCheckSupportedExtensions) {
mod.getSupportedExtensions();
}
const cid = path;
if (!cid) { // 可能由于瘦身资源发起的下载此处将直接忽略
return;
}
/*
if(downloadedTextures[cid]){
if(downloadedTextures[cid].data){
callback();
}else{
mod.readFile(id,type,callback,width,height);
}
}else */
if (isStopDownloadTexture) {
cachedDownloadTask.push({
path,
width,
height,
callback,
limitType,
});
return;
}
if (downloadingTextures[cid]) {
downloadingTextures[cid].push(callback);
}
else {
downloadingTextures[cid] = [callback];
mod.getRemoteImageFile(path, width, height, limitType);
}
},
};
GameGlobal.DownloadedTextures = downloadedTextures;
GameGlobal.TextureCompressedFormat = ''; // 支持的压缩格式
GameGlobal.ParalleLDownloadTexture = function (filename) {
filename = filename.replace(GameGlobal.managerConfig.DATA_CDN, '').replace(/^\//, '');
filename = `/${filename}`;
if (GameGlobal.TEXTURE_BUNDLES[filename]) {
GameGlobal.TEXTURE_BUNDLES[filename].forEach((v) => {
const f = GameGlobal.TextureCompressedFormat;
if (!f) {
const p = `${GameGlobal.manager.assetPath}/Textures/png/${v.w}/${v.p}.png`;
const image = wx.createImage();
image.crossOrigin = '';
image.src = p;
}
else if (f !== 'pvr') {
const http = new GameGlobal.unityNamespace.UnityLoader.UnityCache.XMLHttpRequest();
const p = `${GameGlobal.manager.assetPath}/Textures/${f}/${v.w}/${v.p}.txt`;
http.open('GET', p, true);
http.responseType = 'arraybuffer';
http.send();
}
});
}
};
export default {
WXDownloadTexture: mod.WXDownloadTexture,
};
canvasContext.addCreatedListener(() => {
if (GameGlobal.USED_TEXTURE_COMPRESSION) {
mod.getSupportedExtensions();
if (GameGlobal.TextureCompressedFormat === '' || GameGlobal.TextureCompressedFormat === 'pvr') {
wx.getSystemInfo({
success(res) {
if (res.platform === 'ios') {
wx.showModal({
title: '提示',
content: '当前操作系统版本过低,建议您升级至最新版本。',
});
}
},
});
}
}
wx.onNetworkStatusChange((res) => {
if (res.isConnected) {
Object.keys(downloadFailedTextures).forEach((key) => {
const v = downloadFailedTextures[key];
if (v.count > 4) {
mod.getRemoteImageFile(v.path, v.width, v.height, v.limitType);
}
});
}
});
});
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: cc3fd4cf919ece64b83233e09d6f6f06
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,82 @@
import moduleHelper from './module-helper';
import { formatJsonStr, getListObject, offEventCallback, onEventCallback } from './utils';
const uploadTaskList = {};
const wxUpdateTaskOnProgressList = {};
const wxUpdateTaskOnHeadersList = {};
const getObject = getListObject(uploadTaskList, 'uploadTask');
export default {
WX_UploadFile(option, callbackId) {
const conf = formatJsonStr(option);
const obj = wx.uploadFile({
...conf,
success: (res) => {
moduleHelper.send('UploadFileCallback', JSON.stringify({
callbackId,
type: 'success',
res: JSON.stringify(res),
}));
},
fail: (res) => {
moduleHelper.send('UploadFileCallback', JSON.stringify({
callbackId,
type: 'fail',
res: JSON.stringify(res),
}));
},
complete: (res) => {
moduleHelper.send('UploadFileCallback', JSON.stringify({
callbackId,
type: 'complete',
res: JSON.stringify(res),
}));
setTimeout(() => {
if (uploadTaskList) {
delete uploadTaskList[callbackId];
}
}, 0);
},
});
uploadTaskList[callbackId] = obj;
},
WXUploadTaskAbort(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.abort();
},
WXUploadTaskOffHeadersReceived(id) {
const obj = getObject(id);
if (!obj) {
return;
}
offEventCallback(wxUpdateTaskOnHeadersList, (v) => {
obj.offHeadersReceived(v);
}, id);
},
WXUploadTaskOffProgressUpdate(id) {
const obj = getObject(id);
if (!obj) {
return;
}
offEventCallback(wxUpdateTaskOnProgressList, (v) => {
obj.offProgressUpdate(v);
}, id);
},
WXUploadTaskOnHeadersReceived(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = onEventCallback(wxUpdateTaskOnHeadersList, '_OnHeadersReceivedCallback', id);
obj.onHeadersReceived(callback);
},
WXUploadTaskOnProgressUpdate(id) {
const obj = getObject(id);
if (!obj) {
return;
}
const callback = onEventCallback(wxUpdateTaskOnProgressList, '_OnProgressUpdateCallback', id);
obj.onProgressUpdate(callback);
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 9e4da8007591b3e489b18616e30597cd
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,90 @@
import moduleHelper from './module-helper';
import { getListObject, uid } from './utils';
const userInfoButtonList = {};
const getObject = getListObject(userInfoButtonList, 'userInfoButton');
export default {
WXCreateUserInfoButton(x, y, width, height, lang, withCredentials) {
const id = uid();
const button = wx.createUserInfoButton({
type: 'text',
text: '',
withCredentials,
lang,
style: {
left: x / window.devicePixelRatio,
top: y / window.devicePixelRatio,
width: width / window.devicePixelRatio,
height: height / window.devicePixelRatio,
backgroundColor: 'rgba(0, 0, 0, 0)',
color: 'rgba(0, 0, 0, 0)',
textAlign: 'center',
fontSize: 0,
borderRadius: 0,
borderColor: '#FFFFFF',
borderWidth: 0,
lineHeight: height / window.devicePixelRatio,
},
});
userInfoButtonList[id] = button;
return id;
},
WXUserInfoButtonShow(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.show();
},
WXUserInfoButtonDestroy(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.destroy();
if (userInfoButtonList) {
delete userInfoButtonList[id];
}
},
WXUserInfoButtonHide(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.hide();
},
WXUserInfoButtonOffTap(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.offTap();
},
WXUserInfoButtonOnTap(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.onTap((res) => {
res.userInfo = res.userInfo || {};
moduleHelper.send('UserInfoButtonOnTapCallback', JSON.stringify({
callbackId: id,
errCode: res.err_code || (res.errMsg.indexOf('getUserInfo:fail') === 0 ? 1 : 0),
errMsg: res.errMsg || '',
signature: res.signature || '',
encryptedData: res.encryptedData || '',
iv: res.iv || '',
cloudID: res.cloudID || '',
userInfoRaw: JSON.stringify({
nickName: res.userInfo.nickName || '',
avatarUrl: res.userInfo.avatarUrl || '',
country: res.userInfo.country || '',
province: res.userInfo.province || '',
city: res.userInfo.city || '',
language: res.userInfo.language || '',
gender: res.userInfo.gender || 0,
}),
}));
});
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1716c316c491a3d479a92da1ed73c97d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,160 @@
import moduleHelper from './module-helper';
import { launchEventType } from '../plugin-config';
import { setArrayBuffer, uid } from './utils';
export default {
WXReportGameStart() {
GameGlobal.manager.reportCustomLaunchInfo();
},
WXReportGameSceneError(sceneId, errorType, errStr, extInfo) {
if (GameGlobal.manager && GameGlobal.manager.reportGameSceneError) {
GameGlobal.manager.reportGameSceneError(sceneId, errorType, errStr, extInfo);
}
},
WXWriteLog(str) {
if (GameGlobal.manager && GameGlobal.manager.writeLog) {
GameGlobal.manager.writeLog(str);
}
},
WXWriteWarn(str) {
if (GameGlobal.manager && GameGlobal.manager.writeWarn) {
GameGlobal.manager.writeWarn(str);
}
},
WXHideLoadingPage() {
if (GameGlobal.manager && GameGlobal.manager.hideLoadingPage) {
GameGlobal.manager.hideLoadingPage();
}
},
WXReportUserBehaviorBranchAnalytics(branchId, branchDim, eventType) {
wx.reportUserBehaviorBranchAnalytics({ branchId, branchDim, eventType });
},
WXPreloadConcurrent(count) {
if (GameGlobal.manager && GameGlobal.manager.setConcurrent) {
GameGlobal.manager.setConcurrent(count);
}
},
WXIsCloudTest() {
if (typeof GameGlobal.isTest !== 'undefined' && GameGlobal.isTest) {
return true;
}
return false;
},
WXUncaughtException(needAbort) {
function currentStackTrace() {
const err = new Error('WXUncaughtException');
return err;
}
const err = currentStackTrace();
let fullTrace = err.stack?.toString();
if (fullTrace) {
const posOfThisFunc = fullTrace.indexOf('WXUncaughtException');
if (posOfThisFunc !== -1) {
fullTrace = fullTrace.substr(posOfThisFunc);
}
const posOfRaf = fullTrace.lastIndexOf('browserIterationFunc');
if (posOfRaf !== -1) {
fullTrace = fullTrace.substr(0, posOfRaf);
}
}
const realTimelog = wx.getRealtimeLogManager();
realTimelog.error(fullTrace);
const logmanager = wx.getLogManager({ level: 0 });
logmanager.warn(fullTrace);
if (needAbort === true) {
GameGlobal.onCrash(err);
throw err;
}
else {
setTimeout(() => {
throw err;
}, 0);
}
},
WXCleanAllFileCache() {
if (GameGlobal.manager && GameGlobal.manager.cleanCache) {
const key = uid();
GameGlobal.manager.cleanAllCache().then((res) => {
moduleHelper.send('CleanAllFileCacheCallback', JSON.stringify({
callbackId: key,
result: res,
}));
});
return key;
}
return '';
},
WXCleanFileCache(fileSize) {
if (GameGlobal.manager && GameGlobal.manager.cleanCache) {
const key = uid();
GameGlobal.manager.cleanCache(fileSize).then((res) => {
moduleHelper.send('CleanFileCacheCallback', JSON.stringify({
callbackId: key,
result: res,
}));
});
return key;
}
return '';
},
WXRemoveFile(path) {
if (GameGlobal.manager && GameGlobal.manager.removeFile && path) {
const key = uid();
GameGlobal.manager.removeFile(path).then((res) => {
moduleHelper.send('RemoveFileCallback', JSON.stringify({
callbackId: key,
result: res,
}));
});
return key;
}
return '';
},
WXGetCachePath(url) {
if (GameGlobal.manager && GameGlobal.manager.getCachePath) {
return GameGlobal.manager.getCachePath(url);
}
},
WXGetPluginCachePath() {
if (GameGlobal.manager && GameGlobal.manager.PLUGIN_CACHE_PATH) {
return GameGlobal.manager.PLUGIN_CACHE_PATH;
}
},
WXOnLaunchProgress() {
if (GameGlobal.manager && GameGlobal.manager.onLaunchProgress) {
const key = uid();
// 异步执行,保证C#已经记录这个回调ID
setTimeout(() => {
GameGlobal.manager.onLaunchProgress((e) => {
moduleHelper.send('OnLaunchProgressCallback', JSON.stringify({
callbackId: key,
res: JSON.stringify(Object.assign({}, e.data, {
type: e.type,
})),
}));
if (e.type === launchEventType.prepareGame) {
moduleHelper.send('RemoveLaunchProgressCallback', JSON.stringify({
callbackId: key,
}));
}
});
}, 0);
return key;
}
return '';
},
WXSetDataCDN(path) {
if (GameGlobal.manager && GameGlobal.manager.setDataCDN) {
GameGlobal.manager.setDataCDN(path);
}
},
WXSetPreloadList(paths) {
if (GameGlobal.manager && GameGlobal.manager.setPreloadList) {
const list = (paths || '').split(',').filter(str => !!str && !!str.trim());
GameGlobal.manager.setPreloadList(list);
}
},
WXSetArrayBuffer(buffer, offset, callbackId) {
setArrayBuffer(buffer, offset, callbackId);
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 203e8a6c16552ff4bbd6ad5a63ee2928
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,214 @@
import moduleHelper from './module-helper';
import { ResType } from './resType';
import { ResTypeOther } from './resTypeOther';
Object.assign(ResType, ResTypeOther);
function realUid(length = 20, char = true) {
const soup = `${char ? '' : '!#%()*+,-./:;=?@[]^_`{|}~'}ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`;
const soupLength = soup.length;
const id = [];
for (let i = 0; i < length; i++) {
id[i] = soup.charAt(Math.random() * soupLength);
}
return id.join('');
}
const identifierCache = [];
const tempCacheObj = {};
const typeMap = {
array: [],
arrayBuffer: [],
string: '',
number: 0,
bool: false,
object: {},
};
const interfaceTypeMap = {
array: 'object',
arrayBuffer: 'object',
string: 'string',
number: 'number',
bool: 'boolean',
object: 'object',
};
export const uid = () => realUid(20, true);
export function formatIdentifier(identifier) {
if (identifier >= 0 && Math.abs(identifier) < 2147483648) {
return Math.round(identifier);
}
for (const key in identifierCache) {
if (identifierCache[key] && identifierCache[key].key === identifier) {
return identifierCache[key].value;
}
}
let value = parseInt(`${Math.random() * 2147483648}`, 10);
while (identifierCache.some(v => v.value === value)) {
value += 1;
}
identifierCache.push({
key: identifier,
value,
});
if (identifierCache.length > 30) {
identifierCache.shift();
}
return value;
}
export function formatTouchEvent(v) {
return {
identifier: formatIdentifier(v.identifier),
clientX: v.clientX * window.devicePixelRatio,
clientY: (window.innerHeight - v.clientY) * window.devicePixelRatio,
pageX: v.pageX * window.devicePixelRatio,
pageY: (window.innerHeight - v.pageY) * window.devicePixelRatio,
};
}
export function formatResponse(type, data, id) {
if (!data) {
data = {};
}
if (typeof data !== 'object') {
return {};
}
const conf = ResType[type];
if (!conf) {
return data;
}
Object.keys(conf).forEach((key) => {
if (data[key] === null || typeof data[key] === 'undefined') {
if (typeof typeMap[conf[key]] === 'undefined') {
data[key] = {};
if (ResType[conf[key]]) {
formatResponse(conf[key], data[key]);
}
}
else {
data[key] = typeMap[conf[key]];
}
}
else if (conf[key] === 'long') {
data[key] = parseInt(data[key], 10);
}
else if (conf[key] === 'number' && typeof data[key] === 'string') {
data[key] = Number(data[key]);
}
else if (conf[key] === 'string' && typeof data[key] === 'number') {
data[key] = `${data[key]}`;
}
else if (conf[key] === 'bool' && (typeof data[key] === 'number' || typeof data[key] === 'string')) {
data[key] = !!data[key];
}
else if (conf[key] === 'arrayBuffer' && id) {
cacheArrayBuffer(id, data[key]);
data.arrayBufferLength = data[key].byteLength;
data[key] = [];
}
else if (typeof data[key] === 'object' && conf[key] === 'object') {
Object.keys(data[key]).forEach((v) => {
if (typeof data[key][v] === 'object') {
data[key][v] = JSON.stringify(data[key][v]);
}
else {
data[key][v] += '';
}
});
}
else if (typeof data[key] === 'object' && conf[key]) {
const array = conf[key].match(/(.+)\[\]/);
if (array) {
for (const itemKey of Object.keys(data[key])) {
if (array[1] === 'string') {
data[key][itemKey] = `${data[key][itemKey]}`;
}
else if (array[1] === 'number') {
data[key][itemKey] = Number(data[key][itemKey]);
}
else {
formatResponse(array[1], data[key][itemKey]);
}
}
}
else {
formatResponse(conf[key], data[key]);
}
}
});
if (conf.anyKeyWord) {
return data;
}
Object.keys(data).forEach((key) => {
if (typeof conf[key] === 'undefined') {
delete data[key];
}
else {
const getType = interfaceTypeMap[conf[key]];
if (getType && getType !== typeof data[key]) {
data[key] = typeMap[conf[key]];
}
}
});
return data;
}
export function formatJsonStr(str) {
if (!str) {
return {};
}
try {
const conf = JSON.parse(str);
const keys = Object.keys(conf);
keys.forEach((v) => {
if (conf[v] === null) {
delete conf[v];
}
});
return conf;
}
catch (e) {
return str;
}
}
export function cacheArrayBuffer(callbackId, data) {
tempCacheObj[callbackId] = data;
}
export function setArrayBuffer(buffer, offset, callbackId) {
buffer.set(new Uint8Array(tempCacheObj[callbackId]), offset);
delete tempCacheObj[callbackId];
}
export function getListObject(list, name) {
return (id) => {
if (!list) {
list = {};
}
const obj = list[id];
if (!obj) {
console.error(`${name} 不存在:`, id);
}
return obj;
};
}
export function onEventCallback(list, eventName, id, callbackId) {
if (!list[id]) {
list[id] = [];
}
const callback = (res) => {
const resStr = JSON.stringify({
callbackId: callbackId || id,
res: JSON.stringify(res),
});
moduleHelper.send(eventName, resStr);
};
list[id].push(callback);
return callback;
}
export function offEventCallback(list, callback, id) {
if (!list || !list[id]) {
return;
}
list[id].forEach(callback);
delete list[id];
}
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 29d7142147ee8a74da3f550b7ec3e4ce
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,104 @@
import moduleHelper from './module-helper';
import { formatJsonStr, getListObject, uid } from './utils';
const videoList = {};
const getObject = getListObject(videoList, 'video');
export default {
WXCreateVideo(conf) {
const id = uid();
const params = formatJsonStr(conf);
if (params.underGameView) {
GameGlobal.enableTransparentCanvas = true;
}
videoList[id] = wx.createVideo(params);
return id;
},
WXVideoSetProperty(id, key, value) {
const obj = getObject(id);
if (!obj) {
return;
}
if (key === 'x' || key === 'y' || key === 'width' || key === 'height') {
obj[key] = +value;
}
else if (key === 'src' || key === 'poster') {
obj[key] = value;
}
},
WXVideoPlay(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.play();
},
WXVideoAddListener(id, key) {
const obj = getObject(id);
if (!obj) {
return;
}
obj[key]((e) => {
moduleHelper.send('OnVideoCallback', JSON.stringify({
callbackId: id,
errMsg: key,
position: e && e.position,
buffered: e && e.buffered,
duration: e && e.duration,
}));
if (key === 'onError') {
GameGlobal.enableTransparentCanvas = false;
console.error(e);
}
});
},
WXVideoDestroy(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.destroy();
GameGlobal.enableTransparentCanvas = false;
},
WXVideoExitFullScreen(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.exitFullScreen();
},
WXVideoPause(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.pause();
},
WXVideoRequestFullScreen(id, direction) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.requestFullScreen(direction);
},
WXVideoSeek(id, time) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.seek(time);
},
WXVideoStop(id) {
const obj = getObject(id);
if (!obj) {
return;
}
obj.stop();
},
WXVideoRemoveListener(id, key) {
const obj = getObject(id);
if (!obj) {
return;
}
obj[key]();
},
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 3a2de080b2ad5e8499d8257e11a4cd0e
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6e94932faf7f58142b6904e19c99ab2d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,436 @@
import { isH5Renderer, isSupportVideoDecoder } from '../../check-version';
let FrameworkData = null;
const isDebug = false;
const videoInstances = {};
function _JS_Video_CanPlayFormat(format, data) {
FrameworkData = data;
return !!isSupportVideoDecoder;
}
let videoInstanceIdCounter = 0;
function dynCall_vi(...args) {
if (FrameworkData) {
FrameworkData.dynCall_vi(...args);
}
}
function dynCall_vii(...args) {
if (FrameworkData) {
FrameworkData.dynCall_vii(...args);
}
}
function jsVideoEnded() {
if (isDebug) {
console.log('jsVideoEnded');
}
if (this.onendedCallback) {
dynCall_vi(this.onendedCallback, this.onendedRef);
}
}
function _JS_Video_Create(url) {
let source = '';
if (FrameworkData) {
source = FrameworkData.UTF8ToString(url);
}
if (isDebug) {
console.log('_JS_Video_Create', source);
}
if (isH5Renderer) {
const video = GameGlobal.manager.createWKVideo(source, FrameworkData.GLctx);
videoInstances[++videoInstanceIdCounter] = video;
}
else {
const videoDecoder = wx.createVideoDecoder({
type: 'wemedia',
});
const videoInstance = {
videoDecoder,
videoWidth: 0,
videoHeight: 0,
isReady: false,
paused: false,
ended: false,
duration: 1,
};
videoInstances[++videoInstanceIdCounter] = videoInstance;
videoDecoder.on('start', (res) => {
if (isDebug) {
console.warn('wxVideoDecoder start:', res);
}
videoInstance.paused = false;
if (!videoInstance.isReady) {
videoInstance.duration = res.video?.duration ?? 0;
videoInstance.videoWidth = res.width ?? 0;
videoInstance.videoHeight = res.height ?? 0;
videoInstance.isReady = true;
videoDecoder.stop();
}
});
videoDecoder.on('stop', (res) => {
if (isDebug) {
console.warn('wxVideoDecoder stop:', res);
}
videoInstance.paused = true;
});
videoDecoder.on('seek', (res) => {
if (isDebug) {
console.warn('wxVideoDecoder seek:', res);
}
});
videoDecoder.on('bufferchange', (res) => {
if (isDebug) {
console.warn('wxVideoDecoder bufferchange:', res);
}
});
videoDecoder.on('ended', (res) => {
if (isDebug) {
console.warn('wxVideoDecoder ended:', res);
}
if (videoInstance.loop) {
videoInstance.seek(0);
}
else {
videoInstance.ended = true;
videoInstance.onended?.();
}
});
videoDecoder.on('frame', (res) => {
videoInstance.currentTime = res.pts / 1000;
videoInstance.frameData = new Uint8ClampedArray(res.data);
});
videoInstance.play = () => videoDecoder.start({
source,
});
videoInstance.pause = () => {
videoDecoder.stop();
};
videoInstance.seek = (time) => {
videoDecoder.avSync.seek({ stamp: time });
};
videoInstance.play();
videoInstance.destroy = () => {
videoDecoder.remove();
if (videoInstance.loopEndPollInterval) {
clearInterval(videoInstance.loopEndPollInterval);
}
delete videoInstance.onendedCallback;
delete videoInstance.frameData;
videoInstance.paused = false;
videoInstance.ended = false;
videoInstance.currentTime = 0;
videoInstance.onended = null;
};
}
return videoInstanceIdCounter;
}
function _JS_Video_Destroy(video) {
if (isDebug) {
console.log('_JS_Video_Destroy', video);
}
videoInstances[video].destroy();
delete videoInstances[video];
}
function _JS_Video_Duration(video) {
return videoInstances[video].duration;
}
function _JS_Video_EnableAudioTrack(video, trackIndex, enabled) {
const v = videoInstances[video];
if (!v.enabledTracks) {
v.enabledTracks = [];
}
while (v.enabledTracks.length <= trackIndex) {
v.enabledTracks.push(true);
}
v.enabledTracks[trackIndex] = enabled;
const tracks = v.audioTracks;
if (!tracks) {
return;
}
const track = tracks[trackIndex];
if (track) {
track.enabled = !!enabled;
}
}
function _JS_Video_GetAudioLanguageCode(video, trackIndex) {
const tracks = videoInstances[video].audioTracks;
if (!tracks) {
return '';
}
const track = tracks[trackIndex];
return track ? track.language : '';
}
function _JS_Video_GetNumAudioTracks(video) {
const tracks = videoInstances[video].audioTracks;
// console.log('_JS_Video_GetNumAudioTracks', tracks);
return tracks ? tracks.length : 1;
}
function _JS_Video_Height(video) {
return videoInstances[video].videoHeight;
}
function _JS_Video_IsPlaying(video) {
if (isH5Renderer) {
const v = videoInstances[video];
return v.isPlaying;
}
const v = videoInstances[video];
return v.isReady && !v.paused && !v.ended;
}
function _JS_Video_IsReady(video) {
const v = videoInstances[video];
return !!v.isReady;
}
function _JS_Video_Pause(video) {
if (isDebug) {
console.log('_JS_Video_Pause');
}
const v = videoInstances[video];
v.pause();
if (v.loopEndPollInterval) {
clearInterval(v.loopEndPollInterval);
}
}
function _JS_Video_SetLoop(video, loop = false) {
if (isDebug) {
console.log('_JS_Video_SetLoop', video);
}
const v = videoInstances[video];
if (v.loopEndPollInterval) {
clearInterval(v.loopEndPollInterval);
}
v.loop = loop;
if (loop) {
v.loopEndPollInterval = setInterval(() => {
if (typeof v.currentTime !== 'undefined' && typeof v.lastSeenPlaybackTime !== 'undefined') {
if (v.currentTime < v.lastSeenPlaybackTime) {
jsVideoEnded.apply(v);
}
}
v.lastSeenPlaybackTime = v.currentTime;
}, 1e3 / 30);
v.lastSeenPlaybackTime = v.currentTime;
v.onended = null;
}
else {
v.onended = jsVideoEnded;
}
}
function jsVideoAllAudioTracksAreDisabled(v) {
if (isDebug) {
console.log('jsVideoAllAudioTracksAreDisabled');
}
if (!v.enabledTracks) {
return false;
}
for (let i = 0; i < v.enabledTracks.length; ++i) {
if (v.enabledTracks[i]) {
return false;
}
}
return true;
}
function _JS_Video_Play(video, muted) {
if (isDebug) {
console.log('_JS_Video_Play', video, muted);
}
const v = videoInstances[video];
v.muted = muted || jsVideoAllAudioTracksAreDisabled(v);
v.play();
_JS_Video_SetLoop(video, v.loop);
}
function _JS_Video_Seek(video, time) {
if (isDebug) {
console.log('_JS_Video_Seek', video, time);
}
const v = videoInstances[video];
v.seek(time);
}
function _JS_Video_SetEndedHandler(video, ref, onended) {
if (isDebug) {
console.log('_JS_Video_SetEndedHandler', video, ref, onended);
}
const v = videoInstances[video];
v.onendedCallback = onended;
v.onendedRef = ref;
}
function _JS_Video_SetErrorHandler(video, ref, onerror) {
if (isDebug) {
console.log('_JS_Video_SetErrorHandler', video, ref, onerror);
}
if (isH5Renderer) {
videoInstances[video].on('error', (errMsg) => {
dynCall_vii(onerror, ref, errMsg);
});
}
}
function _JS_Video_SetMute(video, muted) {
if (isDebug) {
console.log('_JS_Video_SetMute', video, muted);
}
const v = videoInstances[video];
v.muted = muted || jsVideoAllAudioTracksAreDisabled(v);
}
function _JS_Video_SetPlaybackRate(video, rate) {
if (isDebug) {
console.log('_JS_Video_SetPlaybackRate', video, rate);
}
console.error('暂不支持设置playbackRate');
return;
}
function _JS_Video_SetReadyHandler(video, ref, onready) {
if (isDebug) {
console.log('_JS_Video_SetReadyHandler', video, ref, onready);
}
const v = videoInstances[video];
if (isH5Renderer) {
v.on('canplay', () => {
dynCall_vi(onready, ref);
});
}
else {
const fn = () => {
console.log('_JS_Video_SetReadyHandler onCanPlay');
dynCall_vi(onready, ref);
v.videoDecoder.off('bufferchange', fn);
};
v.videoDecoder.on('bufferchange', fn);
}
}
function _JS_Video_SetSeekedOnceHandler(video, ref, onseeked) {
if (isDebug) {
console.log('_JS_Video_SetSeekedOnceHandler', video, ref, onseeked);
}
const v = videoInstances[video];
if (isH5Renderer) {
v.on('seek', () => {
dynCall_vi(onseeked, ref);
});
}
else {
v.videoDecoder.on('seek', () => {
dynCall_vi(onseeked, ref);
});
}
}
function _JS_Video_SetVolume(video, volume) {
if (isDebug) {
console.log('_JS_Video_SetVolume');
}
videoInstances[video].volume = volume;
}
function _JS_Video_Time(video) {
return videoInstances[video].currentTime;
}
function _JS_Video_UpdateToTexture(video, tex) {
const v = videoInstances[video];
if (!(v.videoWidth > 0 && v.videoHeight > 0)) {
return false;
}
if (v.lastUpdateTextureTime === v.currentTime) {
return false;
}
v.lastUpdateTextureTime = v.currentTime;
if (!FrameworkData) {
return false;
}
const { GL, GLctx } = FrameworkData;
GLctx.pixelStorei(GLctx.UNPACK_FLIP_Y_WEBGL, true);
const internalFormat = GLctx.RGBA;
const format = GLctx.RGBA;
const width = v.videoWidth;
const height = v.videoHeight;
if (v.previousUploadedWidth !== width || v.previousUploadedHeight !== height) {
GLctx.deleteTexture(GL.textures[tex]);
const t = GLctx.createTexture();
t.name = tex;
GL.textures[tex] = t;
GLctx.bindTexture(GLctx.TEXTURE_2D, t);
GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_WRAP_S, GLctx.CLAMP_TO_EDGE);
GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_WRAP_T, GLctx.CLAMP_TO_EDGE);
GLctx.texParameteri(GLctx.TEXTURE_2D, GLctx.TEXTURE_MIN_FILTER, GLctx.LINEAR);
if (isH5Renderer) {
v.render();
}
else {
GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, v.videoWidth, v.videoHeight, 0, format, GLctx.UNSIGNED_BYTE, v.frameData);
}
v.previousUploadedWidth = width;
v.previousUploadedHeight = height;
}
else {
GLctx.bindTexture(GLctx.TEXTURE_2D, GL.textures[tex]);
if (isH5Renderer) {
v.render();
}
else {
GLctx.texImage2D(GLctx.TEXTURE_2D, 0, internalFormat, v.videoWidth, v.videoHeight, 0, format, GLctx.UNSIGNED_BYTE, v.frameData);
}
}
GLctx.pixelStorei(GLctx.UNPACK_FLIP_Y_WEBGL, false);
return true;
}
function _JS_Video_Width(video) {
return videoInstances[video].videoWidth;
}
function _JS_Video_SetSeekedHandler(video, ref, onseeked) {
const v = videoInstances[video];
if (isH5Renderer) {
v.on('seek', () => {
dynCall_vi(onseeked, ref);
});
}
else {
v.videoDecoder.on('seek', () => {
dynCall_vi(onseeked, ref);
});
}
}
function _JS_Video_GetPlaybackRate(video) {
return videoInstances[video].playbackRate;
}
export default {
_JS_Video_CanPlayFormat,
_JS_Video_Create,
_JS_Video_Destroy,
_JS_Video_Duration,
_JS_Video_EnableAudioTrack,
_JS_Video_GetAudioLanguageCode,
_JS_Video_GetNumAudioTracks,
_JS_Video_Height,
_JS_Video_IsPlaying,
_JS_Video_IsReady,
_JS_Video_Pause,
_JS_Video_SetLoop,
_JS_Video_Play,
_JS_Video_Seek,
_JS_Video_SetEndedHandler,
_JS_Video_SetErrorHandler,
_JS_Video_SetMute,
_JS_Video_SetPlaybackRate,
_JS_Video_SetReadyHandler,
_JS_Video_SetSeekedOnceHandler,
_JS_Video_SetVolume,
_JS_Video_Time,
_JS_Video_UpdateToTexture,
_JS_Video_Width,
_JS_Video_SetSeekedHandler,
_JS_Video_GetPlaybackRate,
};
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: ec826f27b0a2a3f4692a92cb8452bb8f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: