gamelet-pixui-frame
Version:
pixui开发者框架
117 lines • 6.13 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GameletAPI = void 0;
var igameletapi_1 = require("./framework/interfaces/igameletapi");
var jssdk_gameletapi_1 = require("./framework/impl/jssdkimpl/jssdk_gameletapi");
var unitygameletapi_1 = require("./framework/impl/unitysdkimpl/unitygameletapi");
var uegameletapi_1 = require("./framework/impl/uesdkimpl/uegameletapi");
var pxidegameletapi_1 = require("./framework/impl/pxideimpl/pxidegameletapi");
var unsupported_gameletapi_1 = require("./framework/impl/unsupportedimpl/unsupported_gameletapi");
var gameletapi_1 = require("./framework/gameletapi");
var utilities_1 = require("./framework/utilities/utilities");
var getcookiedjc_1 = require("./getcookiedjc/getcookiedjc");
var pluginsForActivityCenter_1 = require("./pluginsForActivityCenter/pluginsForActivityCenter");
//@ts-ignore
var packageJson = __importStar(require("../package.json"));
// re-export 现有 index.ts 的全部内容,保证存量用户零破坏
__exportStar(require("./framework/gameletapi"), exports);
__exportStar(require("./thirdparty/thirdparyt"), exports);
__exportStar(require("./getcookiedjc/getcookiedjc"), exports);
__exportStar(require("./pluginsForActivityCenter/pluginsForActivityCenter"), exports);
function createAutoGameletAPI() {
console.log("[GameletAPI auto] packageJson.version:".concat(packageJson.version));
var impl;
var sdkType;
if (window.navigator.userAgent.search('PixUI') >= 0) {
/**
* 环境筛选,区分执行环境是 unity潘多拉、 GameletSDK、 pxIDE、 未支持环境(浏览器)
* 目前为了兼容各种模拟器的环境不同把默认环境切换为模拟器,后续旧版模拟器废弃掉后会把默认环境切换到 UNSUPPORT_SDK
*/
// pxIDE 使用 pxExtConfig
if (globalThis.pxExtConfig) {
var pxExtConfig = JSON.parse(globalThis.pxExtConfig);
globalThis._sdk_info = pxExtConfig['_sdk_info'];
}
// @ts-ignore 西米哥要求置空创建 crash 的接口
external.crash = undefined;
if ((0, utilities_1.getQueryParam)("_sdk_info") == "openplatform_unity") {
// running on unity
sdkType = igameletapi_1.RuntimeSDK.UNITY_SDK;
impl = unitygameletapi_1.UnityGameletAPI.getInstance();
console.log("[GameletAPI auto] 运行环境: PandoraUnity_SDK");
}
else if ((0, utilities_1.getQueryParam)("_sdk_info") == "openplatform_ue") {
// running on UE
sdkType = igameletapi_1.RuntimeSDK.UE_SDK;
impl = uegameletapi_1.UEGameletAPI.getInstance();
console.log("[GameletAPI auto] 运行环境: PandoraUE_SDK");
}
else if (window["___ns_openplatform"] || (0, utilities_1.getQueryParam)("env_runtimeEnv") == "jssdk") {
// running on js-sdk
sdkType = igameletapi_1.RuntimeSDK.GAMELET_SDK;
impl = jssdk_gameletapi_1.JSSDKGameletAPI.getInstance();
console.log("[GameletAPI auto] \u8FD0\u884C\u73AF\u5883: GAMELET_SDK InnerVersion:".concat((0, utilities_1.getGameletInnerVersion)()));
// 仅在 JSSDK 运行态下注入活动中心插件实现
(0, pluginsForActivityCenter_1._setActivityCenterImpl)(jssdk_gameletapi_1.JSSDKGameletAPI.getInstance());
}
else if ((0, utilities_1.getQueryParam)("_sdk_info") == "openplatform_pxide" || globalThis._sdk_info == "openplatform_pxide") {
// running on pxIDE
sdkType = igameletapi_1.RuntimeSDK.PXIDE_SDK;
impl = pxidegameletapi_1.PxIDEGameletAPI.getInstance();
console.log("[GameletAPI auto] 运行环境: PxIDE");
}
else {
// unsupported / fallback
sdkType = igameletapi_1.RuntimeSDK.UNSUPPORT_SDK;
impl = unsupported_gameletapi_1.UnsupportedGameletAPI.getInstance();
console.log("[GameletAPI auto] 运行环境: UNSUPPORT_SDK");
}
}
else {
// running on web-explorer
sdkType = igameletapi_1.RuntimeSDK.UNSUPPORT_SDK;
impl = unsupported_gameletapi_1.UnsupportedGameletAPI.getInstance();
console.log("[GameletAPI auto] 运行环境: UNSUPPORT_SDK");
}
return new gameletapi_1.GameletAPIImpl(impl, sdkType);
}
exports.GameletAPI = createAutoGameletAPI();
// 把刚创建的 GameletAPI 实例注入到 GetCookieDJC,避免循环依赖
(0, getcookiedjc_1.setGameletAPI)(exports.GameletAPI);
//# sourceMappingURL=auto.js.map