mirror of
https://github.com/wechat-miniprogram/minigame-tuanjie-transform-sdk.git
synced 2025-11-12 19:25:55 +08:00
Auto-publish WXSDK.
This commit is contained in:
parent
95043afbae
commit
940d8b69ba
15
CHANGELOG.md
15
CHANGELOG.md
@ -6,14 +6,25 @@ Removed - 删除功能/接口
|
||||
Fixed - 修复问题
|
||||
Others - 其他
|
||||
-->
|
||||
## 2024-3-5 【普通更新】
|
||||
* 普通:WXAssetBundle支持切换CDN
|
||||
* 普通:优化VideoPlayer组件
|
||||
* 普通:更新小游戏模板捕获全局错误
|
||||
* 普通:高性能+模式不再限制需要iOS>15.0
|
||||
### Fixed
|
||||
* 普通:修复wx.onBluetoothDeviceFound
|
||||
* 普通:修复wx.onUserCaptureScreen
|
||||
* 普通:修复wx.getAppAuthorizeSetting
|
||||
* 普通:修复fs.stat
|
||||
* 普通:修复截屏回调
|
||||
* 普通:unity21.3网络超时时间设置
|
||||
|
||||
## 2024-1-18 【普通更新】
|
||||
包含重要bugfix、特性支持
|
||||
* 普通:更新适配插件版本到1.2.38
|
||||
### Fixed
|
||||
* 普通:不支持WebGL2的旧Android微信版本提供升级指引
|
||||
|
||||
## 2024-1-15 【普通更新】
|
||||
包含重要bugfix、特性支持
|
||||
### Feature
|
||||
* 重要:增加iOS高性能+(iOSPerformancePlus)选项,请查阅[高性能+模式](https://developers.weixin.qq.com/minigame/dev/guide/performance/perf-high-performance-plus.html),有助于提升渲染兼容性、降低WebContent进程内存
|
||||
* 普通:陀螺仪去json性能优化
|
||||
|
||||
@ -93,6 +93,7 @@ namespace WeChatWASM
|
||||
Debug.LogError("若游戏曾使用旧版本微信SDK,需删除 Assets/WX-WASM-SDK 文件夹后再导入最新工具包。");
|
||||
return WXExportError.BUILD_WEBGL_FAILED;
|
||||
}
|
||||
CheckBuildTarget();
|
||||
Init();
|
||||
// JSLib
|
||||
SettingWXTextureMinJSLib();
|
||||
@ -159,6 +160,20 @@ namespace WeChatWASM
|
||||
return WXExportError.SUCCEED;
|
||||
}
|
||||
|
||||
private static void CheckBuildTarget()
|
||||
{
|
||||
if (UnityUtil.GetEngineVersion() == UnityUtil.EngineVersion.Unity)
|
||||
{
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WebGL, BuildTarget.WebGL);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if TUANJIE_2022_3_OR_NEWER
|
||||
EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.WeixinMiniGame, BuildTarget.WeixinMiniGame);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateGraphicAPI()
|
||||
{
|
||||
GraphicsDeviceType[] targets = new GraphicsDeviceType[] { };
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
{
|
||||
public class WXPluginVersion
|
||||
{
|
||||
public static string pluginVersion = "202401191135"; // 这一行不要改他,导出的时候会自动替换
|
||||
public static string pluginVersion = "202403051510"; // 这一行不要改他,导出的时候会自动替换
|
||||
}
|
||||
|
||||
public class WXPluginConf
|
||||
|
||||
Binary file not shown.
@ -54,7 +54,7 @@ var WXAssetBundleLibrary = {
|
||||
WXFS.fs = wx.getFileSystemManager();
|
||||
WXFS.nowfd = FS.MAX_OPEN_FDS + 1;
|
||||
WXFS.isWXAssetBundle = function(url){
|
||||
if(url.startsWith(GameGlobal.unityNamespace.DATA_CDN)||url.startsWith('/vfs_streamingassets')){
|
||||
if(WXFS._url2path.has(url)||url.startsWith(GameGlobal.unityNamespace.DATA_CDN)||url.startsWith('/vfs_streamingassets')){
|
||||
return unityNamespace.isWXAssetBundle(WXFS.url2path(url));
|
||||
}
|
||||
return unityNamespace.isWXAssetBundle(url);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -38,8 +38,8 @@ const isLibVersionValid = compareVersion(SDKVersion, '2.17.0');
|
||||
const isH5LibVersionValid = compareVersion(SDKVersion, '2.23.1');
|
||||
// 压缩纹理需要iOS系统版本>=14.0,检测到不支持压缩纹理时会提示升级系统
|
||||
const isIOSH5SystemVersionValid = compareVersion(systemVersion, '14.0');
|
||||
// iOS系统版本>=15支持webgl2
|
||||
const isIOSWebgl2SystemVersionValid = compareVersion(systemVersion, '15.0');
|
||||
// iOS系统版本>=15支持webgl2,高性能模式+无此系统要求
|
||||
const isIOSWebgl2SystemVersionValid = compareVersion(systemVersion, '15.0') || GameGlobal.isIOSHighPerformanceModePlus;
|
||||
// Android客户端版本>=8.0.19支持webgl2
|
||||
const isAndroidWebGL2ClientVersionValid = compareVersion(version, '8.0.19');
|
||||
// 是否用了webgl2
|
||||
|
||||
@ -79,6 +79,10 @@ checkVersion().then((enable) => {
|
||||
}).default;
|
||||
}
|
||||
catch (error) {
|
||||
GameGlobal.realtimeLogManager.error(error);
|
||||
// logManager不支持自动处理错误对象
|
||||
GameGlobal.logmanager.warn(error.stack);
|
||||
console.error('requirePlugin:', error);
|
||||
if (error.message.indexOf('not defined') !== -1) {
|
||||
console.error('!!!插件需要申请才可使用\n请勿使用测试AppID,并登录 https://mp.weixin.qq.com/ 并前往:能力地图-开发提效包-快适配 开通\n阅读文档获取详情:https://github.com/wechat-miniprogram/minigame-unity-webgl-transform/blob/main/Design/Transform.md');
|
||||
}
|
||||
@ -144,6 +148,7 @@ checkVersion().then((enable) => {
|
||||
},
|
||||
});
|
||||
GameGlobal.managerConfig = managerConfig;
|
||||
// 显示启动封面
|
||||
const gameManager = new UnityManager(managerConfig);
|
||||
gameManager.onLaunchProgress((e) => {
|
||||
// interface LaunchEvent {
|
||||
@ -185,30 +190,11 @@ checkVersion().then((enable) => {
|
||||
gameManager.assetPath = `${(managerConfig.DATA_CDN || '').replace(/\/$/, '')}/Assets`;
|
||||
preloadWxCommonFont();
|
||||
});
|
||||
// 上报初始化信息
|
||||
const systeminfo = wx.getSystemInfoSync();
|
||||
const bootinfo = {
|
||||
renderer: systeminfo.renderer || '',
|
||||
isH5Plus: GameGlobal.isIOSHighPerformanceModePlus || false,
|
||||
abi: systeminfo.abi || '',
|
||||
brand: systeminfo.brand,
|
||||
model: systeminfo.model,
|
||||
platform: systeminfo.platform,
|
||||
system: systeminfo.system,
|
||||
version: systeminfo.version,
|
||||
SDKVersion: systeminfo.SDKVersion,
|
||||
benchmarkLevel: systeminfo.benchmarkLevel,
|
||||
};
|
||||
wx.getRealtimeLogManager().info('game starting', bootinfo);
|
||||
wx.getLogManager({ level: 0 }).info('game starting', bootinfo);
|
||||
console.info('game starting', bootinfo);
|
||||
// 默认上报小游戏实时日志与用户反馈日志(所有error日志+小程序框架异常)
|
||||
wx.onError((result) => {
|
||||
gameManager.printErr(result.message);
|
||||
});
|
||||
// 插件捕获到引擎错误后,会通过此事件抛给游戏
|
||||
gameManager.onLogError = function (err) {
|
||||
GameGlobal.realtimeLogManager.error(err);
|
||||
GameGlobal.logmanager.warn(err);
|
||||
const isErrorObj = err && err.stack;
|
||||
GameGlobal.logmanager.warn(isErrorObj ? err.stack : err);
|
||||
};
|
||||
// iOS高性能模式定期GC
|
||||
if (GameGlobal.canUseiOSAutoGC && unityNamespace.iOSAutoGCInterval !== 0) {
|
||||
@ -216,6 +202,7 @@ checkVersion().then((enable) => {
|
||||
wx.triggerGC();
|
||||
}, unityNamespace.iOSAutoGCInterval);
|
||||
}
|
||||
// 开始执行游戏启动流程
|
||||
gameManager.startGame();
|
||||
GameGlobal.manager = gameManager;
|
||||
GameGlobal.events.on('launchOperaPushMsgToWasm', (callback, args) => GameGlobal.WXWASMSDK.WXLaunchOperaBridgeToC(callback, args));
|
||||
|
||||
@ -23,7 +23,7 @@
|
||||
],
|
||||
"plugins": {
|
||||
"UnityPlugin": {
|
||||
"version": "1.2.39",
|
||||
"version": "1.2.41",
|
||||
"provider": "wxe5a48f1ed5f544b7",
|
||||
"contexts": [
|
||||
{
|
||||
|
||||
@ -99,25 +99,69 @@ unityNamespace.isErasableFile = function (info) {
|
||||
}
|
||||
return true;
|
||||
};
|
||||
const { version, SDKVersion, platform, renderer, system } = wx.getSystemInfoSync();
|
||||
unityNamespace.version = version;
|
||||
unityNamespace.SDKVersion = SDKVersion;
|
||||
unityNamespace.platform = platform;
|
||||
unityNamespace.renderer = renderer;
|
||||
unityNamespace.system = system;
|
||||
unityNamespace.isPc = platform === 'windows' || platform === 'mac';
|
||||
unityNamespace.isDevtools = platform === 'devtools';
|
||||
unityNamespace.isMobile = !unityNamespace.isPc && !unityNamespace.isDevtools;
|
||||
unityNamespace.isH5Renderer = unityNamespace.isMobile && unityNamespace.renderer === 'h5';
|
||||
unityNamespace.isIOS = platform === 'ios';
|
||||
unityNamespace.isAndroid = platform === 'android';
|
||||
GameGlobal.WebAssembly = GameGlobal.WXWebAssembly;
|
||||
GameGlobal.unityNamespace = GameGlobal.unityNamespace || unityNamespace;
|
||||
GameGlobal.realtimeLogManager = wx.getRealtimeLogManager();
|
||||
GameGlobal.logmanager = wx.getLogManager({ level: 0 });
|
||||
// 提前监听错误并打日志
|
||||
function bindGloblException() {
|
||||
// 默认上报小游戏实时日志与用户反馈日志(所有error日志+小程序框架异常)
|
||||
wx.onError((result) => {
|
||||
// 若manager已初始化,则直接用manager打日志即可
|
||||
if (GameGlobal.manager) {
|
||||
GameGlobal.manager.printErr(result.message);
|
||||
}
|
||||
else {
|
||||
GameGlobal.realtimeLogManager.error(result);
|
||||
const isErrorObj = result && result.stack;
|
||||
GameGlobal.logmanager.warn(isErrorObj ? result.stack : result);
|
||||
console.error('onError:', result);
|
||||
}
|
||||
});
|
||||
wx.onUnhandledRejection((result) => {
|
||||
GameGlobal.realtimeLogManager.error(result);
|
||||
const isErrorObj = result && result.reason && result.reason.stack;
|
||||
GameGlobal.logmanager.warn(isErrorObj ? result.reason.stack : result.reason);
|
||||
console.error('unhandledRejection:', result.reason);
|
||||
});
|
||||
// 上报初始信息
|
||||
function printSystemInfo(systemInfo) {
|
||||
GameGlobal.systemInfoCached = systemInfo;
|
||||
const bootinfo = {
|
||||
renderer: systemInfo.renderer || '',
|
||||
isH5Plus: GameGlobal.isIOSHighPerformanceModePlus || false,
|
||||
abi: systemInfo.abi || '',
|
||||
brand: systemInfo.brand,
|
||||
model: systemInfo.model,
|
||||
platform: systemInfo.platform,
|
||||
system: systemInfo.system,
|
||||
version: systemInfo.version,
|
||||
SDKVersion: systemInfo.SDKVersion,
|
||||
benchmarkLevel: systemInfo.benchmarkLevel,
|
||||
};
|
||||
GameGlobal.realtimeLogManager.info('game starting', bootinfo);
|
||||
GameGlobal.logmanager.info('game starting', bootinfo);
|
||||
console.info('game starting', bootinfo);
|
||||
}
|
||||
const systemInfoSync = wx.getSystemInfoSync();
|
||||
const isEmptySystemInfo = systemInfoSync && Object.keys(systemInfoSync).length === 0;
|
||||
// iOS会出现getSystemInfoSync返回空对象的情况,使用异步方法替代
|
||||
if (isEmptySystemInfo) {
|
||||
wx.getSystemInfo({
|
||||
success(systemInfo) {
|
||||
printSystemInfo(systemInfo);
|
||||
},
|
||||
});
|
||||
}
|
||||
else {
|
||||
printSystemInfo(systemInfoSync);
|
||||
}
|
||||
}
|
||||
bindGloblException();
|
||||
// eslint-disable-next-line no-multi-assign
|
||||
GameGlobal.onCrash = GameGlobal.unityNamespace.onCrash = function () {
|
||||
GameGlobal.manager.showAbort();
|
||||
// 避免已经修改屏幕尺寸,故不使用缓存的systeminfo
|
||||
const sysInfo = wx.getSystemInfoSync();
|
||||
wx.createFeedbackButton({
|
||||
type: 'text',
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { convertDataToPointer } from "../utils";
|
||||
import { convertDataToPointer } from '../utils';
|
||||
let wxOnBLECharacteristicValueChangeCallback;
|
||||
const OnBLECharacteristicValueChange = (res) => {
|
||||
const deviceIdPtr = convertDataToPointer(res.deviceId);
|
||||
|
||||
@ -411,8 +411,15 @@ export default {
|
||||
},
|
||||
WX_FileSystemManagerStatSync(path, recursive) {
|
||||
const fs = wx.getFileSystemManager();
|
||||
|
||||
return JSON.stringify(fs.statSync(path, recursive));
|
||||
const res = fs.statSync(path, recursive);
|
||||
let resArray;
|
||||
if (Array.isArray(res)) {
|
||||
resArray = res;
|
||||
}
|
||||
else {
|
||||
resArray = [res];
|
||||
}
|
||||
return JSON.stringify(resArray);
|
||||
},
|
||||
WX_FileSystemManagerWriteSync(option, data) {
|
||||
const fs = wx.getFileSystemManager();
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
import moduleHelper from './module-helper';
|
||||
import { uid, formatResponse, formatJsonStr, onEventCallback, offEventCallback, getListObject } from './utils';
|
||||
import { uid, formatResponse, formatJsonStr, onEventCallback, offEventCallback, getListObject, stringifyRes } from './utils';
|
||||
let OnAccelerometerChangeList;
|
||||
let OnAudioInterruptionBeginList;
|
||||
let OnAudioInterruptionEndList;
|
||||
@ -3331,7 +3331,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnAccelerometerChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnAccelerometerChangeCallback', resStr);
|
||||
};
|
||||
OnAccelerometerChangeList.push(callback);
|
||||
@ -3348,7 +3348,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('GeneralCallbackResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnAudioInterruptionBeginCallback', resStr);
|
||||
};
|
||||
OnAudioInterruptionBeginList.push(callback);
|
||||
@ -3365,7 +3365,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('GeneralCallbackResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnAudioInterruptionEndCallback', resStr);
|
||||
};
|
||||
OnAudioInterruptionEndList.push(callback);
|
||||
@ -3382,7 +3382,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBLEConnectionStateChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBLEConnectionStateChangeCallback', resStr);
|
||||
};
|
||||
OnBLEConnectionStateChangeList.push(callback);
|
||||
@ -3399,7 +3399,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBLEMTUChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBLEMTUChangeCallback', resStr);
|
||||
};
|
||||
OnBLEMTUChangeList.push(callback);
|
||||
@ -3416,7 +3416,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBLEPeripheralConnectionStateChangedListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBLEPeripheralConnectionStateChangedCallback', resStr);
|
||||
};
|
||||
OnBLEPeripheralConnectionStateChangedList.push(callback);
|
||||
@ -3430,7 +3430,7 @@ export default {
|
||||
WX_OnBackgroundFetchData() {
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBackgroundFetchDataListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBackgroundFetchDataCallback', resStr);
|
||||
};
|
||||
wx.onBackgroundFetchData(callback);
|
||||
@ -3441,7 +3441,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBeaconServiceChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBeaconServiceChangeCallback', resStr);
|
||||
};
|
||||
OnBeaconServiceChangeList.push(callback);
|
||||
@ -3458,7 +3458,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBeaconUpdateListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBeaconUpdateCallback', resStr);
|
||||
};
|
||||
OnBeaconUpdateList.push(callback);
|
||||
@ -3475,7 +3475,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBluetoothAdapterStateChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBluetoothAdapterStateChangeCallback', resStr);
|
||||
};
|
||||
OnBluetoothAdapterStateChangeList.push(callback);
|
||||
@ -3492,7 +3492,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnBluetoothDeviceFoundListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnBluetoothDeviceFoundCallback', resStr);
|
||||
};
|
||||
OnBluetoothDeviceFoundList.push(callback);
|
||||
@ -3509,7 +3509,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnCompassChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnCompassChangeCallback', resStr);
|
||||
};
|
||||
OnCompassChangeList.push(callback);
|
||||
@ -3526,7 +3526,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnDeviceMotionChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnDeviceMotionChangeCallback', resStr);
|
||||
};
|
||||
OnDeviceMotionChangeList.push(callback);
|
||||
@ -3543,7 +3543,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnDeviceOrientationChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnDeviceOrientationChangeCallback', resStr);
|
||||
};
|
||||
OnDeviceOrientationChangeList.push(callback);
|
||||
@ -3560,7 +3560,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('Error', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnErrorCallback', resStr);
|
||||
};
|
||||
OnErrorList.push(callback);
|
||||
@ -3577,7 +3577,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('GeneralCallbackResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnHideCallback', resStr);
|
||||
};
|
||||
OnHideList.push(callback);
|
||||
@ -3610,7 +3610,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnKeyDownListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnKeyDownCallback', resStr);
|
||||
};
|
||||
OnKeyDownList.push(callback);
|
||||
@ -3627,7 +3627,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnKeyDownListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnKeyUpCallback', resStr);
|
||||
};
|
||||
OnKeyUpList.push(callback);
|
||||
@ -3644,7 +3644,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnKeyboardInputListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnKeyboardCompleteCallback', resStr);
|
||||
};
|
||||
OnKeyboardCompleteList.push(callback);
|
||||
@ -3661,7 +3661,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnKeyboardInputListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnKeyboardConfirmCallback', resStr);
|
||||
};
|
||||
OnKeyboardConfirmList.push(callback);
|
||||
@ -3678,7 +3678,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnKeyboardHeightChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnKeyboardHeightChangeCallback', resStr);
|
||||
};
|
||||
OnKeyboardHeightChangeList.push(callback);
|
||||
@ -3695,7 +3695,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnKeyboardInputListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnKeyboardInputCallback', resStr);
|
||||
};
|
||||
OnKeyboardInputList.push(callback);
|
||||
@ -3712,7 +3712,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnMemoryWarningListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnMemoryWarningCallback', resStr);
|
||||
};
|
||||
OnMemoryWarningList.push(callback);
|
||||
@ -3736,7 +3736,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnMouseDownListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnMouseDownCallback', resStr);
|
||||
};
|
||||
OnMouseDownList.push(callback);
|
||||
@ -3753,7 +3753,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnMouseMoveListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnMouseMoveCallback', resStr);
|
||||
};
|
||||
OnMouseMoveList.push(callback);
|
||||
@ -3770,7 +3770,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnMouseDownListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnMouseUpCallback', resStr);
|
||||
};
|
||||
OnMouseUpList.push(callback);
|
||||
@ -3787,7 +3787,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnNetworkStatusChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnNetworkStatusChangeCallback', resStr);
|
||||
};
|
||||
OnNetworkStatusChangeList.push(callback);
|
||||
@ -3804,7 +3804,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnNetworkWeakChangeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnNetworkWeakChangeCallback', resStr);
|
||||
};
|
||||
OnNetworkWeakChangeList.push(callback);
|
||||
@ -3821,7 +3821,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnScreenRecordingStateChangedListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnScreenRecordingStateChangedCallback', resStr);
|
||||
};
|
||||
OnScreenRecordingStateChangedList.push(callback);
|
||||
@ -3835,7 +3835,7 @@ export default {
|
||||
WX_OnShareMessageToFriend() {
|
||||
const callback = (res) => {
|
||||
formatResponse('OnShareMessageToFriendListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnShareMessageToFriendCallback', resStr);
|
||||
};
|
||||
wx.onShareMessageToFriend(callback);
|
||||
@ -3846,7 +3846,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnShowListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnShowCallback', resStr);
|
||||
};
|
||||
OnShowList.push(callback);
|
||||
@ -3863,7 +3863,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnUnhandledRejectionListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnUnhandledRejectionCallback', resStr);
|
||||
};
|
||||
OnUnhandledRejectionList.push(callback);
|
||||
@ -3880,7 +3880,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('GeneralCallbackResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnUserCaptureScreenCallback', resStr);
|
||||
};
|
||||
OnUserCaptureScreenList.push(callback);
|
||||
@ -3897,7 +3897,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnVoIPChatInterruptedListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnVoIPChatInterruptedCallback', resStr);
|
||||
};
|
||||
OnVoIPChatInterruptedList.push(callback);
|
||||
@ -3914,7 +3914,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnVoIPChatMembersChangedListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnVoIPChatMembersChangedCallback', resStr);
|
||||
};
|
||||
OnVoIPChatMembersChangedList.push(callback);
|
||||
@ -3931,7 +3931,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnVoIPChatSpeakersChangedListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnVoIPChatSpeakersChangedCallback', resStr);
|
||||
};
|
||||
OnVoIPChatSpeakersChangedList.push(callback);
|
||||
@ -3948,7 +3948,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnVoIPChatStateChangedListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnVoIPChatStateChangedCallback', resStr);
|
||||
};
|
||||
OnVoIPChatStateChangedList.push(callback);
|
||||
@ -3965,7 +3965,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnWheelListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnWheelCallback', resStr);
|
||||
};
|
||||
OnWheelList.push(callback);
|
||||
@ -3982,7 +3982,7 @@ export default {
|
||||
}
|
||||
const callback = (res) => {
|
||||
formatResponse('OnWindowResizeListenerResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnWindowResizeCallback', resStr);
|
||||
};
|
||||
OnWindowResizeList.push(callback);
|
||||
@ -3995,7 +3995,7 @@ export default {
|
||||
},
|
||||
WX_OnAddToFavorites() {
|
||||
const callback = (res) => {
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnAddToFavoritesCallback', resStr);
|
||||
return wxOnAddToFavoritesResolveConf;
|
||||
};
|
||||
@ -4015,7 +4015,7 @@ export default {
|
||||
},
|
||||
WX_OnCopyUrl() {
|
||||
const callback = (res) => {
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnCopyUrlCallback', resStr);
|
||||
return wxOnCopyUrlResolveConf;
|
||||
};
|
||||
@ -4035,7 +4035,7 @@ export default {
|
||||
},
|
||||
WX_OnHandoff() {
|
||||
const callback = (res) => {
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnHandoffCallback', resStr);
|
||||
return wxOnHandoffResolveConf;
|
||||
};
|
||||
@ -4055,7 +4055,7 @@ export default {
|
||||
},
|
||||
WX_OnShareTimeline() {
|
||||
const callback = (res) => {
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnShareTimelineCallback', resStr);
|
||||
return wxOnShareTimelineResolveConf;
|
||||
};
|
||||
@ -4076,7 +4076,7 @@ export default {
|
||||
WX_OnGameLiveStateChange() {
|
||||
const callback = (res) => {
|
||||
formatResponse('OnGameLiveStateChangeCallbackResult', res);
|
||||
const resStr = JSON.stringify(res);
|
||||
const resStr = stringifyRes(res);
|
||||
moduleHelper.send('_OnGameLiveStateChangeCallback', resStr);
|
||||
return wxOnGameLiveStateChangeResolveConf;
|
||||
};
|
||||
|
||||
@ -79,11 +79,16 @@ export function formatResponse(type, data, id) {
|
||||
Object.keys(conf).forEach((key) => {
|
||||
if (data[key] === null || typeof data[key] === 'undefined') {
|
||||
if (typeof typeMap[conf[key]] === 'undefined') {
|
||||
if (conf[key].indexOf('[]') > -1) {
|
||||
data[key] = [];
|
||||
}
|
||||
else {
|
||||
data[key] = {};
|
||||
if (ResType[conf[key]]) {
|
||||
formatResponse(conf[key], data[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
data[key] = typeMap[conf[key]];
|
||||
}
|
||||
@ -100,12 +105,21 @@ export function formatResponse(type, data, id) {
|
||||
else if (conf[key] === 'bool' && (typeof data[key] === 'number' || typeof data[key] === 'string')) {
|
||||
data[key] = !!data[key];
|
||||
}
|
||||
else if (conf[key] === 'arrayBuffer' && id) {
|
||||
else if (conf[key] === 'arrayBuffer') {
|
||||
if (id) {
|
||||
|
||||
cacheArrayBuffer(id, data[key]);
|
||||
data.arrayBufferLength = data[key].byteLength;
|
||||
data[key] = [];
|
||||
}
|
||||
else if (data[key] instanceof ArrayBuffer) {
|
||||
data[key] = new Uint8Array(data[key]);
|
||||
data[key] = Array.from(data[key]);
|
||||
}
|
||||
else {
|
||||
data[key] = [];
|
||||
}
|
||||
}
|
||||
else if (typeof data[key] === 'object' && conf[key] === 'object') {
|
||||
Object.keys(data[key]).forEach((v) => {
|
||||
if (typeof data[key][v] === 'object') {
|
||||
@ -343,3 +357,9 @@ function infoToUint8Array(info) {
|
||||
export function convertInfoToPointer(info) {
|
||||
return allocateAndSet(infoToUint8Array(info));
|
||||
}
|
||||
export function stringifyRes(obj) {
|
||||
if (!obj) {
|
||||
return '{}';
|
||||
}
|
||||
return JSON.stringify(obj);
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ import { isH5Renderer, isSupportVideoPlayer, isPc, isDevtools } from '../../chec
|
||||
let FrameworkData = null;
|
||||
const isWebVideo = isH5Renderer || isPc || isDevtools;
|
||||
const isDebug = false;
|
||||
const needCache = true;
|
||||
const cacheVideoDecoder = [];
|
||||
const videoInstances = {};
|
||||
function _JS_Video_CanPlayFormat(format, data) {
|
||||
|
||||
@ -44,11 +46,17 @@ function _JS_Video_Create(url) {
|
||||
|
||||
videoInstances[++videoInstanceIdCounter] = video;
|
||||
}
|
||||
else {
|
||||
let videoDecoder;
|
||||
if (cacheVideoDecoder.length > 0) {
|
||||
videoDecoder = cacheVideoDecoder.pop();
|
||||
}
|
||||
else {
|
||||
|
||||
const videoDecoder = wx.createVideoDecoder({
|
||||
videoDecoder = wx.createVideoDecoder({
|
||||
type: 'wemedia',
|
||||
});
|
||||
}
|
||||
|
||||
const videoInstance = {
|
||||
videoDecoder,
|
||||
@ -122,10 +130,17 @@ function _JS_Video_Create(url) {
|
||||
};
|
||||
videoInstance.play();
|
||||
videoInstance.destroy = () => {
|
||||
if (needCache) {
|
||||
videoDecoder.stop();
|
||||
cacheVideoDecoder.push(videoDecoder);
|
||||
}
|
||||
else {
|
||||
videoDecoder.remove();
|
||||
}
|
||||
if (videoInstance.loopEndPollInterval) {
|
||||
clearInterval(videoInstance.loopEndPollInterval);
|
||||
}
|
||||
delete videoInstance.videoDecoder;
|
||||
delete videoInstance.onendedCallback;
|
||||
delete videoInstance.frameData;
|
||||
videoInstance.paused = false;
|
||||
@ -314,9 +329,9 @@ function _JS_Video_SetReadyHandler(video, ref, onready) {
|
||||
const fn = () => {
|
||||
console.log('_JS_Video_SetReadyHandler onCanPlay');
|
||||
dynCall_vi(onready, ref);
|
||||
v.videoDecoder.off('bufferchange', fn);
|
||||
v.videoDecoder?.off('bufferchange', fn);
|
||||
};
|
||||
v.videoDecoder.on('bufferchange', fn);
|
||||
v.videoDecoder?.on('bufferchange', fn);
|
||||
}
|
||||
}
|
||||
function _JS_Video_SetSeekedOnceHandler(video, ref, onseeked) {
|
||||
@ -330,7 +345,7 @@ function _JS_Video_SetSeekedOnceHandler(video, ref, onseeked) {
|
||||
});
|
||||
}
|
||||
else {
|
||||
v.videoDecoder.on('seek', () => {
|
||||
v.videoDecoder?.on('seek', () => {
|
||||
dynCall_vi(onseeked, ref);
|
||||
});
|
||||
}
|
||||
@ -406,7 +421,7 @@ function _JS_Video_SetSeekedHandler(video, ref, onseeked) {
|
||||
});
|
||||
}
|
||||
else {
|
||||
v.videoDecoder.on('seek', () => {
|
||||
v.videoDecoder?.on('seek', () => {
|
||||
dynCall_vi(onseeked, ref);
|
||||
});
|
||||
}
|
||||
|
||||
15
package.json
15
package.json
@ -1,14 +1 @@
|
||||
{
|
||||
"name": "com.qq.weixin.minigame",
|
||||
"displayName": "WXSDK",
|
||||
"description": "WeChat Mini Game Tuanjie Engine Adapter SDK Package.",
|
||||
"version": "0.1.0",
|
||||
"unity": "2019.4",
|
||||
"unityRelease": "29f1",
|
||||
"keywords": [
|
||||
"Tuanjie",
|
||||
"WX"
|
||||
],
|
||||
"dependencies": {
|
||||
}
|
||||
}
|
||||
{"name":"com.qq.weixin.minigame","displayName":"WXSDK","description":"WeChat Mini Game Tuanjie Engine Adapter SDK Package.","version":"0.1.1","unity":"2019.4","unityRelease":"29f1","keywords":["Tuanjie","WX"],"dependencies":{}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user