@hd-front-end/jsbridge-sdk 1.0.3 → 1.0.5
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.
- package/dist/index.d.ts +1 -4
- package/dist/index.esm.js +14 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +14 -16
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +18 -18
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports'
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSBridgeSDK = {}
|
|
5
|
-
})(this, (function (exports
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JSBridgeSDK = {}));
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* JSBridge 核心通信层
|
|
@@ -229,9 +229,20 @@
|
|
|
229
229
|
const timeoutId = setTimeout(() => {
|
|
230
230
|
reject(new Error(`${method} 调用超时`));
|
|
231
231
|
}, 10000);
|
|
232
|
+
// 核心防御:防止 DataCloneError 和 Vue Proxy 序列化失败
|
|
233
|
+
// 剥离可能存在的不可序列化对象(如 success/fail 回调函数,或者 Vue 的 Proxy 对象)
|
|
234
|
+
let safeData = data;
|
|
235
|
+
if (data && typeof data === 'object') {
|
|
236
|
+
try {
|
|
237
|
+
safeData = JSON.parse(JSON.stringify(data));
|
|
238
|
+
}
|
|
239
|
+
catch (e) {
|
|
240
|
+
// 忽略异常,保留原数据
|
|
241
|
+
}
|
|
242
|
+
}
|
|
232
243
|
// Android 调用
|
|
233
244
|
if (this.platform === 'android' && this.bridge) {
|
|
234
|
-
this.bridge.callHandler(method,
|
|
245
|
+
this.bridge.callHandler(method, safeData, (result) => {
|
|
235
246
|
clearTimeout(timeoutId);
|
|
236
247
|
resolve(result);
|
|
237
248
|
});
|
|
@@ -253,17 +264,6 @@
|
|
|
253
264
|
reject(err);
|
|
254
265
|
}
|
|
255
266
|
};
|
|
256
|
-
// 核心防御:防止 DataCloneError
|
|
257
|
-
// 剥离可能存在的不可序列化对象(如 success/fail 回调函数)
|
|
258
|
-
let safeData = data;
|
|
259
|
-
if (data && typeof data === 'object') {
|
|
260
|
-
try {
|
|
261
|
-
safeData = JSON.parse(JSON.stringify(data));
|
|
262
|
-
}
|
|
263
|
-
catch (e) {
|
|
264
|
-
// 忽略异常,保留原数据
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
267
|
handler.postMessage({
|
|
268
268
|
handlerName: method,
|
|
269
269
|
data: safeData,
|
|
@@ -1576,8 +1576,8 @@
|
|
|
1576
1576
|
//Cannot assign to read only property 'chooseImage' of object '[object Object]'
|
|
1577
1577
|
// chooseImage是只读的,无法替换,只能用代理模式,如果有好方法替换可以删除这个类
|
|
1578
1578
|
const UniProxy = {
|
|
1579
|
-
chooseImage: uni.chooseImage,
|
|
1580
|
-
pathToBase64:
|
|
1579
|
+
chooseImage: typeof uni !== 'undefined' ? uni.chooseImage : null,
|
|
1580
|
+
pathToBase64: null
|
|
1581
1581
|
};
|
|
1582
1582
|
|
|
1583
1583
|
function hdH5Adapter() {
|