crh-jssdk 1.0.23 → 1.0.24
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.
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.JYClientTHS = exports.jyBridge = exports.globalBridge = exports.Bridge = exports.JYBridge = void 0;
|
|
10
|
-
//
|
|
11
|
-
// 确保 native WebViewJavascriptBridge 在注入完成并调用 _callWVJBCallbacks 时,WVJBCallbacks 始终存在
|
|
12
|
-
// 避免 "TypeError: undefined is not an object (evaluating 'callbacks.length')" 错误
|
|
10
|
+
// 在脚本加载时立即初始化全局标记
|
|
13
11
|
if (typeof window !== 'undefined') {
|
|
14
12
|
window.WVJBCallbacks = window.WVJBCallbacks || [];
|
|
13
|
+
window._WVJBInitialized = false;
|
|
15
14
|
}
|
|
16
15
|
/**
|
|
17
16
|
* ClientTHS全局桥接对象
|
|
@@ -274,12 +273,14 @@ var Bridge = /** @class */ (function () {
|
|
|
274
273
|
_this.bridge = bridge;
|
|
275
274
|
// 确保bridge.init存在且是函数,且未初始化过
|
|
276
275
|
// 在iOS环境下,App原生可能已经调用过bridge.init(),再次调用会报错"init called twice"
|
|
277
|
-
|
|
276
|
+
// 使用全局标记 window._WVJBInitialized 检测App原生的初始化
|
|
277
|
+
if (bridge && typeof bridge.init === 'function' && !_this._bridgeInitCalled && !window._WVJBInitialized) {
|
|
278
278
|
bridge.init(function () {
|
|
279
279
|
console.log('Bridge初始化完成');
|
|
280
280
|
resolve();
|
|
281
281
|
});
|
|
282
282
|
_this._bridgeInitCalled = true;
|
|
283
|
+
window._WVJBInitialized = true;
|
|
283
284
|
}
|
|
284
285
|
else {
|
|
285
286
|
// 如果bridge已经初始化过或init不存在,直接resolve
|