@hd-front-end/jsbridge-sdk 1.0.4 → 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.umd.js CHANGED
@@ -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, data, (result) => {
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,