@open-wxa/wxa-runner-core 0.10.1 → 0.11.0

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.
@@ -1018,9 +1018,9 @@ ${frames}` : "");
1018
1018
  (this.replies.get(query.id) ?? Promise.resolve(null)).then((reply) => port.postMessage(reply));
1019
1019
  }
1020
1020
  };
1021
- function installMockMirror() {
1022
- if (navigator.webdriver || !navigator.serviceWorker) return null;
1023
- navigator.serviceWorker.register(SERVICE_WORKER_URL, { scope: "/" }).catch((error) => console.warn("[wxa-runner] Service Worker \u6CE8\u518C\u5931\u8D25\uFF0C\u88AB\u62E6\u622A\u7684\u8BF7\u6C42\u4E0D\u4F1A\u663E\u793A\u5728 Network \u9762\u677F\u91CC", error));
1021
+ function installMockMirror(externalServiceWorker = false) {
1022
+ if (!externalServiceWorker && navigator.webdriver || !navigator.serviceWorker) return null;
1023
+ if (!externalServiceWorker) navigator.serviceWorker.register(SERVICE_WORKER_URL, { scope: "/" }).catch((error) => console.warn("[wxa-runner] Service Worker \u6CE8\u518C\u5931\u8D25\uFF0C\u88AB\u62E6\u622A\u7684\u8BF7\u6C42\u4E0D\u4F1A\u663E\u793A\u5728 Network \u9762\u677F\u91CC", error));
1024
1024
  return new MockMirror(navigator.serviceWorker);
1025
1025
  }
1026
1026
 
@@ -2553,8 +2553,6 @@ html, body { margin: 0; height: 100%; background: radial-gradient(120% 80% at 50
2553
2553
  this.api = new ApiRegistry((context) => this.reportUnimplemented(context));
2554
2554
  /** setup 和测试 API 声明的请求拦截 */
2555
2555
  this.routes = new RequestRoutes();
2556
- /** 把被拦截的请求显示在 Network 面板里 */
2557
- this.mockMirror = installMockMirror();
2558
2556
  this.mapOperations = new MapOperations((webviewId, event, data) => this.publishToPages(event, data, [webviewId]));
2559
2557
  this.service = null;
2560
2558
  /** 新版基础库的业务子上下文;旧版基础库业务代码直接在逻辑层 iframe 里 */
@@ -2570,6 +2568,7 @@ html, body { margin: 0; height: 100%; background: radial-gradient(120% 80% at 50
2570
2568
  this.routeListeners = [];
2571
2569
  /** 渲染层报来的 2d、webgl 画布,按编号记下所在页面和最近的位置,供 placeCanvas 认出逻辑层的画布元素 */
2572
2570
  this.canvases = /* @__PURE__ */ new Map();
2571
+ this.mockMirror = installMockMirror(info.externalServiceWorker);
2573
2572
  this.device = info.device;
2574
2573
  this.forwarder = new ConsoleForwarder(
2575
2574
  info.forwardConsole ?? false,
@@ -3418,7 +3417,7 @@ ${script}
3418
3417
  const root = document.getElementById("wxa-root");
3419
3418
  const info = await (await fetch("/__wxa__/app-info.json")).json();
3420
3419
  const restore = new PageStackRestore(info.appid);
3421
- const sendReport = connectDevServer(restore);
3420
+ const sendReport = info.liveReload === false ? () => void 0 : connectDevServer(restore);
3422
3421
  if (info.buildError) {
3423
3422
  new PhoneShell(root, info.device).showError(`\u7F16\u8BD1\u5931\u8D25
3424
3423