@scgczm/bridge 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -219,3 +219,24 @@ export interface IGetCaptchaVerifyParamData {
219
219
  */
220
220
  export declare const scgcGetCaptchaVerifyParam: (data: IGetCaptchaVerifyParamData) => void;
221
221
  export { setDevMode, isScgcApp } from './utils';
222
+ export interface IProgramData {
223
+ programId: string;
224
+ groupId: string;
225
+ episodeId: string;
226
+ }
227
+ /**
228
+ * @description 打开原生综艺页面
229
+ * @param {IProgramData} data
230
+ * @param {string} data.programId 节目Id
231
+ * @param {string} data.groupId 合集Id
232
+ * @param {string} data.episodeId 单集Id
233
+ */
234
+ export declare const scgctoVarietyshow: (data: IProgramData) => void;
235
+ /**
236
+ * @description 打开原生纪录片页面
237
+ * @param {IProgramData} data
238
+ * @param {string} data.programId 节目Id
239
+ * @param {string} data.groupId 合集Id
240
+ * @param {string} data.episodeId 单集Id
241
+ */
242
+ export declare const scgctoDocumentshow: (data: IProgramData) => void;
package/dist/cjs/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isScgcApp = exports.setDevMode = exports.scgcGetCaptchaVerifyParam = exports.scgcGetPhoneNumber = exports.scgcGetNickName = exports.scgcGetAvatar = exports.scgcGetUserId = exports.scgcChangeStateBarColor = exports.scgcToAppHome = exports.scgcToKuaipai = exports.scgcToMall = exports.scgcFocusWeb = exports.scgcToMallDetail = exports.scgcToSubSpecial = exports.scgcSetVolume = exports.scgcToTopic = exports.scgcToLive = exports.scgcToSpecial = exports.scgcToDetail = exports.scgcToH5 = exports.scgcShare = exports.scgcSaveimage = exports.scgcOpenwechat = exports.scgcOpenexplorer = exports.scgcClose = exports.scgcScan = exports.scgcLogin = exports.scgcGetSlideData = void 0;
3
+ exports.scgctoDocumentshow = exports.scgctoVarietyshow = exports.isScgcApp = exports.setDevMode = exports.scgcGetCaptchaVerifyParam = exports.scgcGetPhoneNumber = exports.scgcGetNickName = exports.scgcGetAvatar = exports.scgcGetUserId = exports.scgcChangeStateBarColor = exports.scgcToAppHome = exports.scgcToKuaipai = exports.scgcToMall = exports.scgcFocusWeb = exports.scgcToMallDetail = exports.scgcToSubSpecial = exports.scgcSetVolume = exports.scgcToTopic = exports.scgcToLive = exports.scgcToSpecial = exports.scgcToDetail = exports.scgcToH5 = exports.scgcShare = exports.scgcSaveimage = exports.scgcOpenwechat = exports.scgcOpenexplorer = exports.scgcClose = exports.scgcScan = exports.scgcLogin = exports.scgcGetSlideData = void 0;
4
4
  /*#__PURE__*/
5
5
  var utils_1 = require("./utils");
6
6
  (0, utils_1.initAsyncCallbackPool)();
@@ -246,3 +246,25 @@ exports.scgcGetCaptchaVerifyParam = scgcGetCaptchaVerifyParam;
246
246
  var utils_2 = require("./utils");
247
247
  Object.defineProperty(exports, "setDevMode", { enumerable: true, get: function () { return utils_2.setDevMode; } });
248
248
  Object.defineProperty(exports, "isScgcApp", { enumerable: true, get: function () { return utils_2.isScgcApp; } });
249
+ /**
250
+ * @description 打开原生综艺页面
251
+ * @param {IProgramData} data
252
+ * @param {string} data.programId 节目Id
253
+ * @param {string} data.groupId 合集Id
254
+ * @param {string} data.episodeId 单集Id
255
+ */
256
+ var scgctoVarietyshow = function (data) {
257
+ return commonBridge('toVarietyshow', data);
258
+ };
259
+ exports.scgctoVarietyshow = scgctoVarietyshow;
260
+ /**
261
+ * @description 打开原生纪录片页面
262
+ * @param {IProgramData} data
263
+ * @param {string} data.programId 节目Id
264
+ * @param {string} data.groupId 合集Id
265
+ * @param {string} data.episodeId 单集Id
266
+ */
267
+ var scgctoDocumentshow = function (data) {
268
+ return commonBridge('toDocumentary', data);
269
+ };
270
+ exports.scgctoDocumentshow = scgctoDocumentshow;
@@ -2,7 +2,7 @@ export interface ICommonResult<T> {
2
2
  success: boolean;
3
3
  data: T;
4
4
  }
5
- type TSyncFuns = 'getSlideData' | 'login' | 'scan' | 'close' | 'openexplorer' | 'openwechat' | 'saveimage' | 'share' | 'toH5' | 'toDetail' | 'toLive' | 'toTopic' | 'setVolume' | 'toSubSpecial' | 'detailJson' | 'focusWeb' | 'mall' | 'mainPage' | 'changeStatebarColor' | 'release' | 'toSpecial' | 'getCaptchaVerifyParam';
5
+ type TSyncFuns = 'getSlideData' | 'login' | 'scan' | 'close' | 'openexplorer' | 'openwechat' | 'saveimage' | 'share' | 'toH5' | 'toDetail' | 'toLive' | 'toTopic' | 'setVolume' | 'toSubSpecial' | 'detailJson' | 'focusWeb' | 'mall' | 'mainPage' | 'changeStatebarColor' | 'release' | 'toSpecial' | 'getCaptchaVerifyParam' | 'toVarietyshow' | 'toDocumentary';
6
6
  type TAsyncFuns = 'getToken' | 'getUserId' | 'getNickName' | 'getAvatar' | 'getPhoneNumber' | 'getPromise';
7
7
  export declare const setDevMode: () => void;
8
8
  export declare const initAsyncCallbackPool: () => void;
@@ -219,3 +219,24 @@ export interface IGetCaptchaVerifyParamData {
219
219
  */
220
220
  export declare const scgcGetCaptchaVerifyParam: (data: IGetCaptchaVerifyParamData) => void;
221
221
  export { setDevMode, isScgcApp } from './utils';
222
+ export interface IProgramData {
223
+ programId: string;
224
+ groupId: string;
225
+ episodeId: string;
226
+ }
227
+ /**
228
+ * @description 打开原生综艺页面
229
+ * @param {IProgramData} data
230
+ * @param {string} data.programId 节目Id
231
+ * @param {string} data.groupId 合集Id
232
+ * @param {string} data.episodeId 单集Id
233
+ */
234
+ export declare const scgctoVarietyshow: (data: IProgramData) => void;
235
+ /**
236
+ * @description 打开原生纪录片页面
237
+ * @param {IProgramData} data
238
+ * @param {string} data.programId 节目Id
239
+ * @param {string} data.groupId 合集Id
240
+ * @param {string} data.episodeId 单集Id
241
+ */
242
+ export declare const scgctoDocumentshow: (data: IProgramData) => void;
package/dist/esm/index.js CHANGED
@@ -215,3 +215,23 @@ export var scgcGetCaptchaVerifyParam = function (data) {
215
215
  return commonBridge('getCaptchaVerifyParam', data);
216
216
  };
217
217
  export { setDevMode, isScgcApp } from './utils';
218
+ /**
219
+ * @description 打开原生综艺页面
220
+ * @param {IProgramData} data
221
+ * @param {string} data.programId 节目Id
222
+ * @param {string} data.groupId 合集Id
223
+ * @param {string} data.episodeId 单集Id
224
+ */
225
+ export var scgctoVarietyshow = function (data) {
226
+ return commonBridge('toVarietyshow', data);
227
+ };
228
+ /**
229
+ * @description 打开原生纪录片页面
230
+ * @param {IProgramData} data
231
+ * @param {string} data.programId 节目Id
232
+ * @param {string} data.groupId 合集Id
233
+ * @param {string} data.episodeId 单集Id
234
+ */
235
+ export var scgctoDocumentshow = function (data) {
236
+ return commonBridge('toDocumentary', data);
237
+ };
@@ -2,7 +2,7 @@ export interface ICommonResult<T> {
2
2
  success: boolean;
3
3
  data: T;
4
4
  }
5
- type TSyncFuns = 'getSlideData' | 'login' | 'scan' | 'close' | 'openexplorer' | 'openwechat' | 'saveimage' | 'share' | 'toH5' | 'toDetail' | 'toLive' | 'toTopic' | 'setVolume' | 'toSubSpecial' | 'detailJson' | 'focusWeb' | 'mall' | 'mainPage' | 'changeStatebarColor' | 'release' | 'toSpecial' | 'getCaptchaVerifyParam';
5
+ type TSyncFuns = 'getSlideData' | 'login' | 'scan' | 'close' | 'openexplorer' | 'openwechat' | 'saveimage' | 'share' | 'toH5' | 'toDetail' | 'toLive' | 'toTopic' | 'setVolume' | 'toSubSpecial' | 'detailJson' | 'focusWeb' | 'mall' | 'mainPage' | 'changeStatebarColor' | 'release' | 'toSpecial' | 'getCaptchaVerifyParam' | 'toVarietyshow' | 'toDocumentary';
6
6
  type TAsyncFuns = 'getToken' | 'getUserId' | 'getNickName' | 'getAvatar' | 'getPhoneNumber' | 'getPromise';
7
7
  export declare const setDevMode: () => void;
8
8
  export declare const initAsyncCallbackPool: () => void;
@@ -1 +1 @@
1
- !function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.scgcBridge=e():n.scgcBridge=e()}(self,()=>(()=>{"use strict";var __webpack_modules__={"./src/index.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isScgcApp: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.isScgcApp),\n/* harmony export */ scgcChangeStateBarColor: () => (/* binding */ scgcChangeStateBarColor),\n/* harmony export */ scgcClose: () => (/* binding */ scgcClose),\n/* harmony export */ scgcFocusWeb: () => (/* binding */ scgcFocusWeb),\n/* harmony export */ scgcGetAvatar: () => (/* binding */ scgcGetAvatar),\n/* harmony export */ scgcGetCaptchaVerifyParam: () => (/* binding */ scgcGetCaptchaVerifyParam),\n/* harmony export */ scgcGetNickName: () => (/* binding */ scgcGetNickName),\n/* harmony export */ scgcGetPhoneNumber: () => (/* binding */ scgcGetPhoneNumber),\n/* harmony export */ scgcGetSlideData: () => (/* binding */ scgcGetSlideData),\n/* harmony export */ scgcGetUserId: () => (/* binding */ scgcGetUserId),\n/* harmony export */ scgcLogin: () => (/* binding */ scgcLogin),\n/* harmony export */ scgcOpenexplorer: () => (/* binding */ scgcOpenexplorer),\n/* harmony export */ scgcOpenwechat: () => (/* binding */ scgcOpenwechat),\n/* harmony export */ scgcSaveimage: () => (/* binding */ scgcSaveimage),\n/* harmony export */ scgcScan: () => (/* binding */ scgcScan),\n/* harmony export */ scgcSetVolume: () => (/* binding */ scgcSetVolume),\n/* harmony export */ scgcShare: () => (/* binding */ scgcShare),\n/* harmony export */ scgcToAppHome: () => (/* binding */ scgcToAppHome),\n/* harmony export */ scgcToDetail: () => (/* binding */ scgcToDetail),\n/* harmony export */ scgcToH5: () => (/* binding */ scgcToH5),\n/* harmony export */ scgcToKuaipai: () => (/* binding */ scgcToKuaipai),\n/* harmony export */ scgcToLive: () => (/* binding */ scgcToLive),\n/* harmony export */ scgcToMall: () => (/* binding */ scgcToMall),\n/* harmony export */ scgcToMallDetail: () => (/* binding */ scgcToMallDetail),\n/* harmony export */ scgcToSpecial: () => (/* binding */ scgcToSpecial),\n/* harmony export */ scgcToSubSpecial: () => (/* binding */ scgcToSubSpecial),\n/* harmony export */ scgcToTopic: () => (/* binding */ scgcToTopic),\n/* harmony export */ setDevMode: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.setDevMode)\n/* harmony export */ });\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/utils.ts\");\n/*#__PURE__*/\n\n(0,_utils__WEBPACK_IMPORTED_MODULE_0__.initAsyncCallbackPool)();\nvar commonBridge = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.commonBridgeFun)();\n/**\n * @deprecated 因阿里验证码1.0升级至2.0,原有scgcGetSlideData方法已使用scgcGetCaptchaVerifyParam替换,自 v1.1.0 起弃用,将在 v2.0.0 中移除\n *\n * @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)\n * @param {IGetSlideDataData} data\n */\nvar scgcGetSlideData = function (data) {\n commonBridge('getSlideData', data);\n};\n/**\n * @description 调用app登录\n */\nvar scgcLogin = function () {\n commonBridge('login');\n};\n/**\n * @description 调用app扫码\n */\nvar scgcScan = function () {\n commonBridge('scan');\n};\n/**\n * @description 关闭当前webview\n */\nvar scgcClose = function () {\n commonBridge('close');\n};\n/**\n * @description 使用系统浏览器打开指定的url\n * @param {IOpenexplorerData} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcOpenexplorer = function (data) {\n commonBridge('openexplorer', data);\n};\n/**\n * @description 打开微信小程序\n * @param {IOpenwechatData} data\n * @param {string} data.appid 小程序appid,格式为gh开头\n * @param {string} data.path 小程序路径\n */\nvar scgcOpenwechat = function (data) {\n commonBridge('openwechat', data);\n};\n/**\n * @description 保存图片\n * @param {ISaveimageData} data\n * @param {string} data.data base64数据\n */\nvar scgcSaveimage = function (data) {\n commonBridge('saveimage', data);\n};\n/**\n * @description 配置app分享\n * @param {IShareData} data\n * @param {string} data.shareUrl 需要分享的地址\n * @param {string} data.shareImg 分享的封面\n * @param {string} data.shareTitle 分享的标题\n * @param {string} data.shareDesc 分享的说明\n * @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置\n */\nvar scgcShare = function (data) {\n commonBridge('share', data);\n};\n/**\n * @description 打开一个webview\n * @param {ItoH5Data} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcToH5 = function (data) {\n commonBridge('toH5', data);\n};\n/**\n * @description 打开app原生新闻页\n * @param {IToDetailData} data\n * @param {string} data.path 新闻json地址 --相对地址,没有域名前缀的形式\n * @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链\n */\nvar scgcToDetail = function (data) {\n commonBridge('toDetail', data);\n};\n/**\n * @description 打开app原生专题详情页\n * @param {IToSpecialData} data\n * @param {string} data.id 专题id\n */\nvar scgcToSpecial = function (data) {\n commonBridge('toSpecial', data);\n};\n/**\n * @description 打开app原生直播页\n * @param {IToLiveData} data\n * @param {string} data.id 直播id\n * @param {string} data.type 直播样式 1 横版 2 竖版\n */\nvar scgcToLive = function (data) {\n commonBridge('toLive', data);\n};\n/**\n * @description 打开app话题页\n * @param {IToTopicData} data\n * @param {string} data.name 话题名称\n * @param {string} data.cover 话题封面图(完整的图片地址)\n * @param {string} data.id 话题id\n */\nvar scgcToTopic = function (data) {\n commonBridge('toTopic', data);\n};\n/**\n * @description 设置app音量\n * @param {ISetVolumeData} data\n * @param {number} data.type 0 调小 1 调大\n */\nvar scgcSetVolume = function (data) {\n commonBridge('setVolume', data);\n};\n/**\n * @description 打开app原生专题新闻列表页\n * @param {IToSubSpecialData} data\n * @param {string} data.title 专题标题\n * @param {string} data.id 专题id\n */\nvar scgcToSubSpecial = function (data) {\n commonBridge('toSubSpecial', data);\n};\n/**\n * @description 打开积分商城商品详情\n * @param {IMallDetailData} data\n * @param {string} data.json 商品详情json地址\n * @param {string} data.url 商品详情网页地址\n * @param {string} data.ptype todo 未知\n * @param {number} data.isDark 0 普通模式 1 黑暗模式\n */\nvar scgcToMallDetail = function (data) {\n commonBridge('detailJson', data);\n};\n/**\n * @description 是否禁用app左右滑动(主要用户嵌入在app首页的swiper,避免滑动swiper的情况下,会滑动app首页的tab页)\n * @param {IMallDetailData} data\n * @param {boolean} data.focus 是否禁止app滑动\n *\n */\nvar scgcFocusWeb = function (data) {\n commonBridge('focusWeb', data);\n};\n/**\n * @description 跳转至积分商城\n */\nvar scgcToMall = function () {\n commonBridge('mall');\n};\n/**\n * @description 跳转至快拍\n */\nvar scgcToKuaipai = function () {\n commonBridge('release');\n};\n/**\n * @description 跳转至app首页\n */\nvar scgcToAppHome = function () {\n commonBridge('mainPage');\n};\n/**\n * @description 设置app顶部时间栏颜色\n * @param {IChangeStateBarColorData} data\n * @param {number} data.type 1 黑色 2 白色\n *\n */\nvar scgcChangeStateBarColor = function (data) {\n commonBridge('changeStatebarColor', data);\n};\n/**\n * @description 获取app 用户id\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetUserId = function () {\n return commonBridge('getUserId');\n};\n/**\n * @description 获取app 用户头像\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetAvatar = function () {\n return commonBridge('getAvatar');\n};\n/**\n * @description 获取app 用户昵称\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetNickName = function () {\n return commonBridge('getNickName');\n};\n// /**\n// * @description 获取app 用户手机号\n// * @return {Promise((success:boolean,data:string))} 返回promise\n// *\n// */\nvar scgcGetPhoneNumber = function () {\n return commonBridge('getPhoneNumber');\n};\n/**\n * @description 传递验证码参数到app(阿里验证码2.0使用)\n * @param {IGetCaptchaVerifyParamData} data\n * @param {string} data.captchaVerifyParam 验证码参数\n */\nvar scgcGetCaptchaVerifyParam = function (data) {\n return commonBridge('getCaptchaVerifyParam', data);\n};\n\n\n\n//# sourceURL=webpack://scgcBridge/./src/index.ts?\n}")},"./src/utils.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ commonBridgeFun: () => (/* binding */ commonBridgeFun),\n/* harmony export */ initAsyncCallbackPool: () => (/* binding */ initAsyncCallbackPool),\n/* harmony export */ isScgcApp: () => (/* binding */ isScgcApp),\n/* harmony export */ setDevMode: () => (/* binding */ setDevMode)\n/* harmony export */ });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar distinctionPlatform = function () {\n var ua = navigator.userAgent;\n if (/(iPhone|iPad|iPod)/i.test(ua)) {\n return 'ios';\n }\n else if (/Android/i.test(ua)) {\n return 'android';\n }\n else if (/openharmony/i.test(ua)) {\n return 'harmony';\n }\n else {\n return 'unknow';\n }\n};\nvar asyncFunsArr = [\n 'getToken',\n 'getUserId',\n 'getAvatar',\n 'getNickName',\n 'getPhoneNumber',\n 'getPromise', //测试用\n];\nvar androidAsyncFunsArr = ['getPromise'];\nvar devMode = false;\nvar setDevMode = function () {\n devMode = true;\n};\nvar initAsyncCallbackPool = function () {\n window.bridgeCallbacks = {};\n};\nvar devFn = function (platform, fnName, data) {\n //动态判断是否为devMode,避免初始化commonBridgeFun比调用setDevMode的早的情况下,devMode参数已固定(损失的性能可以接受)\n if (devMode) {\n var devInfo = {\n platform: platform,\n fnName: fnName,\n data: data,\n };\n console.log(devInfo);\n }\n};\nfunction makeRandomId(fnName) {\n return \"\".concat(fnName || 'anonymous', \"_\").concat(Date.now());\n}\nfunction registerCallback(fnName, cb) {\n if (!cb) {\n return null;\n }\n var callbackId = makeRandomId(fnName);\n if (!window.hasOwnProperty('bridgeCallbacks')) {\n window.bridgeCallbacks = {};\n }\n window.bridgeCallbacks[callbackId] = function (data) {\n var result;\n if (typeof data === 'object') {\n result = data;\n }\n else if (typeof data === 'string') {\n try {\n result = JSON.parse(data);\n }\n catch (e) {\n result = data;\n }\n }\n cb(result);\n };\n return \"bridgeCallbacks.\".concat(callbackId);\n}\nfunction androidBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b;\n var androidParams = {\n Method: fnName,\n Data: data,\n };\n devFn('android', fnName, data);\n if (fnName == 'getSlideData') {\n (_a = window === null || window === void 0 ? void 0 : window.testInterface) === null || _a === void 0 ? void 0 : _a.getSlideData(JSON.stringify(androidParams));\n }\n else if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {\n var res, result;\n var _a, _b;\n return __generator(this, function (_c) {\n try {\n //安卓使用了异步返回\n if (androidAsyncFunsArr.includes(fnName)) {\n (_a = window === null || window === void 0 ? void 0 : window.newBridge) === null || _a === void 0 ? void 0 : _a[fnName](JSON.stringify({\n callback: registerCallback(fnName, resolve),\n }));\n }\n else {\n res = (_b = window === null || window === void 0 ? void 0 : window.newBridge) === null || _b === void 0 ? void 0 : _b[fnName]();\n result = void 0;\n if (typeof res === 'object') {\n result = res;\n }\n else if (typeof res === 'string') {\n try {\n result = JSON.parse(res);\n }\n catch (e) {\n result = { success: false, data: res };\n }\n }\n if ((result === null || result === void 0 ? void 0 : result.success) == true) {\n resolve(result);\n }\n else {\n reject(result);\n }\n }\n }\n catch (error) {\n reject(error);\n }\n return [2 /*return*/];\n });\n }); });\n return promiseRes;\n }\n else {\n (_b = window === null || window === void 0 ? void 0 : window.bridge) === null || _b === void 0 ? void 0 : _b.callRouter(JSON.stringify(androidParams), function () { });\n }\n}\nfunction iosBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b, _c;\n devFn('ios', fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a, _b, _c;\n try {\n var _cb = function (res) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n try {\n if ((res === null || res === void 0 ? void 0 : res.success) == 'true') {\n resolve({\n success: true,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n else {\n reject({\n success: false,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n return [2 /*return*/];\n });\n }); };\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage({\n data: {},\n callback: registerCallback(fnName, _cb),\n });\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n });\n return promiseRes;\n }\n else {\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage(data);\n }\n}\nfunction harmonyBridgeFn(fnName, data) {\n var _a, _b;\n devFn('harmony', fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a;\n try {\n (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]({\n data: data,\n callback: registerCallback(fnName, resolve),\n });\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n else {\n (_b = (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]) === null || _b === void 0 ? void 0 : _b.call(_a, data);\n }\n}\nfunction defaultBridgeFn(fnName, data) {\n console.log('请使用scgc app打开');\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n try {\n resolve('请使用scgc app打开');\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n}\nvar commonBridgeFun = function () {\n var platform = distinctionPlatform();\n if (platform == 'android') {\n return androidBridgeFn;\n }\n else if (platform == 'ios') {\n return iosBridgeFn;\n }\n else if (platform == 'harmony') {\n return harmonyBridgeFn;\n }\n else {\n return defaultBridgeFn;\n }\n};\n/**\n * @description 是否为app环境\n * @return {boolean} true 是 false 否\n */\nvar isScgcApp = function () {\n return navigator.userAgent.indexOf('SCGC_UA') > -1;\n};\n\n\n//# sourceURL=webpack://scgcBridge/./src/utils.ts?\n}")}},__webpack_module_cache__={};function __webpack_require__(n){var e=__webpack_module_cache__[n];if(void 0!==e)return e.exports;var a=__webpack_module_cache__[n]={exports:{}};return __webpack_modules__[n](a,a.exports,__webpack_require__),a.exports}__webpack_require__.d=(n,e)=>{for(var a in e)__webpack_require__.o(e,a)&&!__webpack_require__.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},__webpack_require__.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),__webpack_require__.r=n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__("./src/index.ts");return __webpack_exports__})());
1
+ !function(n,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.scgcBridge=e():n.scgcBridge=e()}(self,()=>(()=>{"use strict";var __webpack_modules__={"./src/index.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ isScgcApp: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.isScgcApp),\n/* harmony export */ scgcChangeStateBarColor: () => (/* binding */ scgcChangeStateBarColor),\n/* harmony export */ scgcClose: () => (/* binding */ scgcClose),\n/* harmony export */ scgcFocusWeb: () => (/* binding */ scgcFocusWeb),\n/* harmony export */ scgcGetAvatar: () => (/* binding */ scgcGetAvatar),\n/* harmony export */ scgcGetCaptchaVerifyParam: () => (/* binding */ scgcGetCaptchaVerifyParam),\n/* harmony export */ scgcGetNickName: () => (/* binding */ scgcGetNickName),\n/* harmony export */ scgcGetPhoneNumber: () => (/* binding */ scgcGetPhoneNumber),\n/* harmony export */ scgcGetSlideData: () => (/* binding */ scgcGetSlideData),\n/* harmony export */ scgcGetUserId: () => (/* binding */ scgcGetUserId),\n/* harmony export */ scgcLogin: () => (/* binding */ scgcLogin),\n/* harmony export */ scgcOpenexplorer: () => (/* binding */ scgcOpenexplorer),\n/* harmony export */ scgcOpenwechat: () => (/* binding */ scgcOpenwechat),\n/* harmony export */ scgcSaveimage: () => (/* binding */ scgcSaveimage),\n/* harmony export */ scgcScan: () => (/* binding */ scgcScan),\n/* harmony export */ scgcSetVolume: () => (/* binding */ scgcSetVolume),\n/* harmony export */ scgcShare: () => (/* binding */ scgcShare),\n/* harmony export */ scgcToAppHome: () => (/* binding */ scgcToAppHome),\n/* harmony export */ scgcToDetail: () => (/* binding */ scgcToDetail),\n/* harmony export */ scgcToH5: () => (/* binding */ scgcToH5),\n/* harmony export */ scgcToKuaipai: () => (/* binding */ scgcToKuaipai),\n/* harmony export */ scgcToLive: () => (/* binding */ scgcToLive),\n/* harmony export */ scgcToMall: () => (/* binding */ scgcToMall),\n/* harmony export */ scgcToMallDetail: () => (/* binding */ scgcToMallDetail),\n/* harmony export */ scgcToSpecial: () => (/* binding */ scgcToSpecial),\n/* harmony export */ scgcToSubSpecial: () => (/* binding */ scgcToSubSpecial),\n/* harmony export */ scgcToTopic: () => (/* binding */ scgcToTopic),\n/* harmony export */ scgctoDocumentshow: () => (/* binding */ scgctoDocumentshow),\n/* harmony export */ scgctoVarietyshow: () => (/* binding */ scgctoVarietyshow),\n/* harmony export */ setDevMode: () => (/* reexport safe */ _utils__WEBPACK_IMPORTED_MODULE_0__.setDevMode)\n/* harmony export */ });\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils */ \"./src/utils.ts\");\n/*#__PURE__*/\n\n(0,_utils__WEBPACK_IMPORTED_MODULE_0__.initAsyncCallbackPool)();\nvar commonBridge = (0,_utils__WEBPACK_IMPORTED_MODULE_0__.commonBridgeFun)();\n/**\n * @deprecated 因阿里验证码1.0升级至2.0,原有scgcGetSlideData方法已使用scgcGetCaptchaVerifyParam替换,自 v1.1.0 起弃用,将在 v2.0.0 中移除\n *\n * @description 阿里滑动验证(使用的旧版api,目前官方文档已散佚,可参考其他项目)\n * @param {IGetSlideDataData} data\n */\nvar scgcGetSlideData = function (data) {\n commonBridge('getSlideData', data);\n};\n/**\n * @description 调用app登录\n */\nvar scgcLogin = function () {\n commonBridge('login');\n};\n/**\n * @description 调用app扫码\n */\nvar scgcScan = function () {\n commonBridge('scan');\n};\n/**\n * @description 关闭当前webview\n */\nvar scgcClose = function () {\n commonBridge('close');\n};\n/**\n * @description 使用系统浏览器打开指定的url\n * @param {IOpenexplorerData} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcOpenexplorer = function (data) {\n commonBridge('openexplorer', data);\n};\n/**\n * @description 打开微信小程序\n * @param {IOpenwechatData} data\n * @param {string} data.appid 小程序appid,格式为gh开头\n * @param {string} data.path 小程序路径\n */\nvar scgcOpenwechat = function (data) {\n commonBridge('openwechat', data);\n};\n/**\n * @description 保存图片\n * @param {ISaveimageData} data\n * @param {string} data.data base64数据\n */\nvar scgcSaveimage = function (data) {\n commonBridge('saveimage', data);\n};\n/**\n * @description 配置app分享\n * @param {IShareData} data\n * @param {string} data.shareUrl 需要分享的地址\n * @param {string} data.shareImg 分享的封面\n * @param {string} data.shareTitle 分享的标题\n * @param {string} data.shareDesc 分享的说明\n * @param {boolean} data.doShare 是否在调用bridge时立即触发app的分享,默认为仅修改配置\n */\nvar scgcShare = function (data) {\n commonBridge('share', data);\n};\n/**\n * @description 打开一个webview\n * @param {ItoH5Data} data\n * @param {string} data.path 需要打开的url\n */\nvar scgcToH5 = function (data) {\n commonBridge('toH5', data);\n};\n/**\n * @description 打开app原生新闻页\n * @param {IToDetailData} data\n * @param {string} data.path 新闻json地址 --相对地址,没有域名前缀的形式\n * @param {number} data.newsType 新闻类型 --1.图文 2.音频 3.视频 4.纯视频新闻 6 外链\n */\nvar scgcToDetail = function (data) {\n commonBridge('toDetail', data);\n};\n/**\n * @description 打开app原生专题详情页\n * @param {IToSpecialData} data\n * @param {string} data.id 专题id\n */\nvar scgcToSpecial = function (data) {\n commonBridge('toSpecial', data);\n};\n/**\n * @description 打开app原生直播页\n * @param {IToLiveData} data\n * @param {string} data.id 直播id\n * @param {string} data.type 直播样式 1 横版 2 竖版\n */\nvar scgcToLive = function (data) {\n commonBridge('toLive', data);\n};\n/**\n * @description 打开app话题页\n * @param {IToTopicData} data\n * @param {string} data.name 话题名称\n * @param {string} data.cover 话题封面图(完整的图片地址)\n * @param {string} data.id 话题id\n */\nvar scgcToTopic = function (data) {\n commonBridge('toTopic', data);\n};\n/**\n * @description 设置app音量\n * @param {ISetVolumeData} data\n * @param {number} data.type 0 调小 1 调大\n */\nvar scgcSetVolume = function (data) {\n commonBridge('setVolume', data);\n};\n/**\n * @description 打开app原生专题新闻列表页\n * @param {IToSubSpecialData} data\n * @param {string} data.title 专题标题\n * @param {string} data.id 专题id\n */\nvar scgcToSubSpecial = function (data) {\n commonBridge('toSubSpecial', data);\n};\n/**\n * @description 打开积分商城商品详情\n * @param {IMallDetailData} data\n * @param {string} data.json 商品详情json地址\n * @param {string} data.url 商品详情网页地址\n * @param {string} data.ptype todo 未知\n * @param {number} data.isDark 0 普通模式 1 黑暗模式\n */\nvar scgcToMallDetail = function (data) {\n commonBridge('detailJson', data);\n};\n/**\n * @description 是否禁用app左右滑动(主要用户嵌入在app首页的swiper,避免滑动swiper的情况下,会滑动app首页的tab页)\n * @param {IMallDetailData} data\n * @param {boolean} data.focus 是否禁止app滑动\n *\n */\nvar scgcFocusWeb = function (data) {\n commonBridge('focusWeb', data);\n};\n/**\n * @description 跳转至积分商城\n */\nvar scgcToMall = function () {\n commonBridge('mall');\n};\n/**\n * @description 跳转至快拍\n */\nvar scgcToKuaipai = function () {\n commonBridge('release');\n};\n/**\n * @description 跳转至app首页\n */\nvar scgcToAppHome = function () {\n commonBridge('mainPage');\n};\n/**\n * @description 设置app顶部时间栏颜色\n * @param {IChangeStateBarColorData} data\n * @param {number} data.type 1 黑色 2 白色\n *\n */\nvar scgcChangeStateBarColor = function (data) {\n commonBridge('changeStatebarColor', data);\n};\n/**\n * @description 获取app 用户id\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetUserId = function () {\n return commonBridge('getUserId');\n};\n/**\n * @description 获取app 用户头像\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetAvatar = function () {\n return commonBridge('getAvatar');\n};\n/**\n * @description 获取app 用户昵称\n * @return {Promise((success:boolean,data:string))} 返回promise\n *\n */\nvar scgcGetNickName = function () {\n return commonBridge('getNickName');\n};\n// /**\n// * @description 获取app 用户手机号\n// * @return {Promise((success:boolean,data:string))} 返回promise\n// *\n// */\nvar scgcGetPhoneNumber = function () {\n return commonBridge('getPhoneNumber');\n};\n/**\n * @description 传递验证码参数到app(阿里验证码2.0使用)\n * @param {IGetCaptchaVerifyParamData} data\n * @param {string} data.captchaVerifyParam 验证码参数\n */\nvar scgcGetCaptchaVerifyParam = function (data) {\n return commonBridge('getCaptchaVerifyParam', data);\n};\n\n/**\n * @description 打开原生综艺页面\n * @param {IProgramData} data\n * @param {string} data.programId 节目Id\n * @param {string} data.groupId 合集Id\n * @param {string} data.episodeId 单集Id\n */\nvar scgctoVarietyshow = function (data) {\n return commonBridge('toVarietyshow', data);\n};\n/**\n * @description 打开原生纪录片页面\n * @param {IProgramData} data\n * @param {string} data.programId 节目Id\n * @param {string} data.groupId 合集Id\n * @param {string} data.episodeId 单集Id\n */\nvar scgctoDocumentshow = function (data) {\n return commonBridge('toDocumentary', data);\n};\n\n\n//# sourceURL=webpack://scgcBridge/./src/index.ts?\n}")},"./src/utils.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ commonBridgeFun: () => (/* binding */ commonBridgeFun),\n/* harmony export */ initAsyncCallbackPool: () => (/* binding */ initAsyncCallbackPool),\n/* harmony export */ isScgcApp: () => (/* binding */ isScgcApp),\n/* harmony export */ setDevMode: () => (/* binding */ setDevMode)\n/* harmony export */ });\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === \"function\" ? Iterator : Object).prototype);\n return g.next = verb(0), g[\"throw\"] = verb(1), g[\"return\"] = verb(2), typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (g && (g = 0, op[0] && (_ = 0)), _) try {\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar distinctionPlatform = function () {\n var ua = navigator.userAgent;\n if (/(iPhone|iPad|iPod)/i.test(ua)) {\n return 'ios';\n }\n else if (/Android/i.test(ua)) {\n return 'android';\n }\n else if (/openharmony/i.test(ua)) {\n return 'harmony';\n }\n else {\n return 'unknow';\n }\n};\nvar asyncFunsArr = [\n 'getToken',\n 'getUserId',\n 'getAvatar',\n 'getNickName',\n 'getPhoneNumber',\n 'getPromise', //测试用\n];\nvar androidAsyncFunsArr = ['getPromise'];\nvar devMode = false;\nvar setDevMode = function () {\n devMode = true;\n};\nvar initAsyncCallbackPool = function () {\n window.bridgeCallbacks = {};\n};\nvar devFn = function (platform, fnName, data) {\n //动态判断是否为devMode,避免初始化commonBridgeFun比调用setDevMode的早的情况下,devMode参数已固定(损失的性能可以接受)\n if (devMode) {\n var devInfo = {\n platform: platform,\n fnName: fnName,\n data: data,\n };\n console.log(devInfo);\n }\n};\nfunction makeRandomId(fnName) {\n return \"\".concat(fnName || 'anonymous', \"_\").concat(Date.now());\n}\nfunction registerCallback(fnName, cb) {\n if (!cb) {\n return null;\n }\n var callbackId = makeRandomId(fnName);\n if (!window.hasOwnProperty('bridgeCallbacks')) {\n window.bridgeCallbacks = {};\n }\n window.bridgeCallbacks[callbackId] = function (data) {\n var result;\n if (typeof data === 'object') {\n result = data;\n }\n else if (typeof data === 'string') {\n try {\n result = JSON.parse(data);\n }\n catch (e) {\n result = data;\n }\n }\n cb(result);\n };\n return \"bridgeCallbacks.\".concat(callbackId);\n}\nfunction androidBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b;\n var androidParams = {\n Method: fnName,\n Data: data,\n };\n devFn('android', fnName, data);\n if (fnName == 'getSlideData') {\n (_a = window === null || window === void 0 ? void 0 : window.testInterface) === null || _a === void 0 ? void 0 : _a.getSlideData(JSON.stringify(androidParams));\n }\n else if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {\n var res, result;\n var _a, _b;\n return __generator(this, function (_c) {\n try {\n //安卓使用了异步返回\n if (androidAsyncFunsArr.includes(fnName)) {\n (_a = window === null || window === void 0 ? void 0 : window.newBridge) === null || _a === void 0 ? void 0 : _a[fnName](JSON.stringify({\n callback: registerCallback(fnName, resolve),\n }));\n }\n else {\n res = (_b = window === null || window === void 0 ? void 0 : window.newBridge) === null || _b === void 0 ? void 0 : _b[fnName]();\n result = void 0;\n if (typeof res === 'object') {\n result = res;\n }\n else if (typeof res === 'string') {\n try {\n result = JSON.parse(res);\n }\n catch (e) {\n result = { success: false, data: res };\n }\n }\n if ((result === null || result === void 0 ? void 0 : result.success) == true) {\n resolve(result);\n }\n else {\n reject(result);\n }\n }\n }\n catch (error) {\n reject(error);\n }\n return [2 /*return*/];\n });\n }); });\n return promiseRes;\n }\n else {\n (_b = window === null || window === void 0 ? void 0 : window.bridge) === null || _b === void 0 ? void 0 : _b.callRouter(JSON.stringify(androidParams), function () { });\n }\n}\nfunction iosBridgeFn(fnName, data) {\n var _this = this;\n var _a, _b, _c;\n devFn('ios', fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a, _b, _c;\n try {\n var _cb = function (res) { return __awaiter(_this, void 0, void 0, function () {\n return __generator(this, function (_a) {\n try {\n if ((res === null || res === void 0 ? void 0 : res.success) == 'true') {\n resolve({\n success: true,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n else {\n reject({\n success: false,\n data: res === null || res === void 0 ? void 0 : res.data,\n });\n }\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n return [2 /*return*/];\n });\n }); };\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage({\n data: {},\n callback: registerCallback(fnName, _cb),\n });\n }\n catch (error) {\n reject({\n success: false,\n data: error,\n });\n }\n });\n return promiseRes;\n }\n else {\n (_c = (_b = (_a = window === null || window === void 0 ? void 0 : window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[fnName]) === null || _c === void 0 ? void 0 : _c.postMessage(data);\n }\n}\nfunction harmonyBridgeFn(fnName, data) {\n var _a, _b;\n devFn('harmony', fnName, data);\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n var _a;\n try {\n (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]({\n data: data,\n callback: registerCallback(fnName, resolve),\n });\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n else {\n (_b = (_a = window === null || window === void 0 ? void 0 : window.harmonyBridge) === null || _a === void 0 ? void 0 : _a[fnName]) === null || _b === void 0 ? void 0 : _b.call(_a, data);\n }\n}\nfunction defaultBridgeFn(fnName, data) {\n console.log('请使用scgc app打开');\n if (asyncFunsArr.includes(fnName)) {\n var promiseRes = new Promise(function (resolve, reject) {\n try {\n resolve('请使用scgc app打开');\n }\n catch (error) {\n reject(error);\n }\n });\n return promiseRes;\n }\n}\nvar commonBridgeFun = function () {\n var platform = distinctionPlatform();\n if (platform == 'android') {\n return androidBridgeFn;\n }\n else if (platform == 'ios') {\n return iosBridgeFn;\n }\n else if (platform == 'harmony') {\n return harmonyBridgeFn;\n }\n else {\n return defaultBridgeFn;\n }\n};\n/**\n * @description 是否为app环境\n * @return {boolean} true 是 false 否\n */\nvar isScgcApp = function () {\n return navigator.userAgent.indexOf('SCGC_UA') > -1;\n};\n\n\n//# sourceURL=webpack://scgcBridge/./src/utils.ts?\n}")}},__webpack_module_cache__={};function __webpack_require__(n){var e=__webpack_module_cache__[n];if(void 0!==e)return e.exports;var a=__webpack_module_cache__[n]={exports:{}};return __webpack_modules__[n](a,a.exports,__webpack_require__),a.exports}__webpack_require__.d=(n,e)=>{for(var a in e)__webpack_require__.o(e,a)&&!__webpack_require__.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},__webpack_require__.o=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),__webpack_require__.r=n=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__("./src/index.ts");return __webpack_exports__})());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scgczm/bridge",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "scgczm app jsbridge",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",