@jhh96/light-app-bridge 1.4.0 → 1.4.2

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.
@@ -104,6 +104,8 @@ function bindMessageBackend(cb) {
104
104
  ev.off('native-call-js', handler);
105
105
  else if (ev && typeof ev.removeListener === 'function')
106
106
  ev.removeListener('native-call-js', handler);
107
+ else if (ev && typeof ev.remove === 'function')
108
+ ev.remove('native-call-js', handler); // waltz ≥1.1.7 API
107
109
  });
108
110
  }
109
111
  // 2. 定义 handleMessageFromNative 路径:无 waltz 时。
@@ -152,6 +154,12 @@ function parseHandleMessageFromNative(raw) {
152
154
  // handleMessageFromNative 入参带 responseId 包装
153
155
  responseData = parsed && parsed.responseData != null ? parsed.responseData : parsed;
154
156
  }
157
+ // waltz ≥1.1.7:event 总线(bl)派发载荷为 {id, data} 包装,responseData 在 .data 里
158
+ //(旧版 nativeCallWeb 直接派发裸 responseData)。裸数据有 .body 无 .data、包装有
159
+ // .data 无 .body,判据互斥,两种版本同一解析出口。
160
+ if (responseData && responseData.body == null && responseData.data != null) {
161
+ responseData = responseData.data;
162
+ }
155
163
  if (!responseData || !responseData.body || responseData.body.eventName !== 'plugin-message') {
156
164
  return null;
157
165
  }
@@ -392,6 +400,11 @@ export default class LightAppBridge {
392
400
  this._connectStarted = true;
393
401
  // 等监听后端绑定完成后再握手,避免对端的 ack/hello 在监听绑定前到达而丢失
394
402
  const listenerReady = (_a = this._listenerReady) !== null && _a !== void 0 ? _a : Promise.resolve();
403
+ // dynamic 目标轮询在「发起握手时」即启动(幂等),不等握手成功——
404
+ // 插件在未集成 SDK 的轻应用上打开时握手必超时,若轮询依赖 _onConnected
405
+ // 则永远不启动,此后切到集成 SDK 的窗口也不会跟随迁移(实测卡死旧目标)。
406
+ // 轮询独立于连接状态:探测到新目标 ack 即 _rebindTo 建立连接。
407
+ this._startDynamicPoll();
395
408
  // 握手超时保护:仅插件(主动方)需要——它发了 hello 却收不到 ack 说明对端异常。
396
409
  // 轻应用(被动方)持续等待,不超时:插件可能任意晚才发起连接。
397
410
  if (this.role === 'plugin') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jhh96/light-app-bridge",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "type": "module",
5
5
  "description": "招商随行(WorkLink)插件窗口(plugin)与轻应用窗口(lightapp)之间的双向通信 SDK",
6
6
  "main": "./dist/index.js",