@wix/himalaya-cli 0.1778.0 → 0.1779.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.
package/dist/cli.mjs CHANGED
@@ -264,7 +264,7 @@ var init_client = __esm({
264
264
  * One probe costs one extra request only for files that were already going to fail. */
265
265
  async telemetrySend(events2) {
266
266
  const post = (batch) => this.request("telemetry", "POST", "/v1/telemetry/ingest", { body: batch, headers: this.telHeaders() });
267
- const settle2 = (r3, posted) => {
267
+ const settle3 = (r3, posted) => {
268
268
  const j2 = r3.json && typeof r3.json === "object" ? r3.json : null;
269
269
  const n2 = (k3) => typeof j2?.[k3] === "number" ? j2[k3] : 0;
270
270
  const counted = typeof j2?.accepted === "number";
@@ -274,11 +274,11 @@ var init_client = __esm({
274
274
  return { ...r3, ok: false, json: { ...j2 ?? {}, ok: false } };
275
275
  };
276
276
  const first = await post(events2);
277
- if (first.status !== 413 || events2.length <= 1) return settle2(first, events2.length);
277
+ if (first.status !== 413 || events2.length <= 1) return settle3(first, events2.length);
278
278
  const body = first.json;
279
- if (!body || body.error !== "batch_too_large") return settle2(first, events2.length);
279
+ if (!body || body.error !== "batch_too_large") return settle3(first, events2.length);
280
280
  const limit = typeof body.limit === "number" && Number.isInteger(body.limit) && body.limit > 0 ? body.limit : null;
281
- if (limit === null || limit >= events2.length) return settle2(first, events2.length);
281
+ if (limit === null || limit >= events2.length) return settle3(first, events2.length);
282
282
  const totals = { accepted: 0, dropped: 0, failed: 0 };
283
283
  const add = (r3) => {
284
284
  const j2 = r3.json;
@@ -294,14 +294,14 @@ var init_client = __esm({
294
294
  last = await post(chunk2);
295
295
  add(last);
296
296
  if (!last.ok) {
297
- return settle2(
297
+ return settle3(
298
298
  { ...last, json: { ...last.json ?? {}, ...totals, batched: { limit, sent, ...totals, failedAt: i2 } } },
299
299
  events2.length
300
300
  );
301
301
  }
302
302
  sent += chunk2.length;
303
303
  }
304
- return settle2(
304
+ return settle3(
305
305
  { ...last, json: { ...last.json ?? {}, ...totals, batched: { limit, sent, ...totals } } },
306
306
  events2.length
307
307
  );
@@ -7077,7 +7077,6 @@ function webViewOriginAllowed(url, origins) {
7077
7077
  }
7078
7078
  var init_webview_origin = __esm({
7079
7079
  "../../core/ts/src/webview-origin.ts"() {
7080
- "use strict";
7081
7080
  init_define_HHP_CATALOG();
7082
7081
  }
7083
7082
  });
@@ -7239,6 +7238,10 @@ function collectWebViews(descriptor) {
7239
7238
  for (const r3 of roots(descriptor)) visit(r3.c, r3.path, false, { parentType: null, scrollAncestor: null, inVerticalScroll: false });
7240
7239
  return sites;
7241
7240
  }
7241
+ function bridgedWebViews(descriptor) {
7242
+ if (!isRec2(descriptor)) return [];
7243
+ return collectWebViews(descriptor).filter((s5) => isBridged(s5.props)).map((s5) => ({ id: s5.id, path: s5.path, props: s5.props, inTemplate: s5.inTemplate }));
7244
+ }
7242
7245
  function mountable(c2, inTemplate = false) {
7243
7246
  const type2 = typeOf(c2);
7244
7247
  const props2 = propsOf2(c2);
@@ -22262,6 +22265,7 @@ async function bootBundleWorker(bundleJs, opts) {
22262
22265
  input: opts.input ?? {},
22263
22266
  connectivity: { current: opts.connectivity ?? (() => ({ online: true })) },
22264
22267
  ...opts.capabilities ? { capabilities: [...opts.capabilities] } : {},
22268
+ ...opts.webview && grants(opts.capabilities ?? [], "webview") ? { webview: opts.webview } : {},
22265
22269
  wixApi,
22266
22270
  // v1 best-effort stubs — a visitor-scoped load() reads Wix, not device-local state.
22267
22271
  storage: opts.storage ? hostStorage(opts.storage) : { get: () => "", set: () => {
@@ -32854,6 +32858,28 @@ var init_page_methods_generated = __esm({
32854
32858
  }
32855
32859
  });
32856
32860
 
32861
+ // ../../core/sdk/webview/src/page-method-requires.ts
32862
+ var METHOD_REQUIRES;
32863
+ var init_page_method_requires = __esm({
32864
+ "../../core/sdk/webview/src/page-method-requires.ts"() {
32865
+ init_define_HHP_CATALOG();
32866
+ METHOD_REQUIRES = {
32867
+ "presigned_upload.putFile": ["files"],
32868
+ // `prepareImage` decodes and writes its outputs into the `files` substrate.
32869
+ "camera.prepareImage": ["files"],
32870
+ // #4688 — `writeImage` reads the image out of the `files` substrate.
32871
+ "clipboard.writeImage": ["files"],
32872
+ // `addMonitoredRegion` registers an OS geofence, which every bridge gates on `location_background`
32873
+ // (JSWorker.actionRequirements); a companion without it would advertise a call that is refused.
32874
+ "location.addMonitoredRegion": ["location_background"],
32875
+ // The on-device ML image verbs read their image out of the `files` substrate.
32876
+ "text_recognition.recognize": ["files"],
32877
+ "image_labeling.label": ["files"],
32878
+ "barcode_detection.detect": ["files"]
32879
+ };
32880
+ }
32881
+ });
32882
+
32857
32883
  // ../../core/sdk/webview/src/page-worker.ts
32858
32884
  import { createHash as createHash10 } from "node:crypto";
32859
32885
  function companionMethods(id, ids2) {
@@ -32895,25 +32921,12 @@ function companionBundleName(capabilities) {
32895
32921
  const ids2 = [...new Set(capabilities)].sort();
32896
32922
  return `himi-webview-page-${createHash10("sha256").update(ids2.join(",")).digest("hex").slice(0, 10)}`;
32897
32923
  }
32898
- var METHOD_REQUIRES, PAGE_CAPABILITIES, identifier;
32924
+ var PAGE_CAPABILITIES, identifier;
32899
32925
  var init_page_worker = __esm({
32900
32926
  "../../core/sdk/webview/src/page-worker.ts"() {
32901
32927
  init_define_HHP_CATALOG();
32902
32928
  init_page_methods_generated();
32903
- METHOD_REQUIRES = {
32904
- "presigned_upload.putFile": ["files"],
32905
- // `prepareImage` decodes and writes its outputs into the `files` substrate.
32906
- "camera.prepareImage": ["files"],
32907
- // #4688 — `writeImage` reads the image out of the `files` substrate.
32908
- "clipboard.writeImage": ["files"],
32909
- // `addMonitoredRegion` registers an OS geofence, which every bridge gates on `location_background`
32910
- // (JSWorker.actionRequirements); a companion without it would advertise a call that is refused.
32911
- "location.addMonitoredRegion": ["location_background"],
32912
- // The on-device ML image verbs read their image out of the `files` substrate.
32913
- "text_recognition.recognize": ["files"],
32914
- "image_labeling.label": ["files"],
32915
- "barcode_detection.detect": ["files"]
32916
- };
32929
+ init_page_method_requires();
32917
32930
  PAGE_CAPABILITIES = Object.keys(PAGE_METHODS);
32918
32931
  identifier = (id) => "cap_" + id.replace(/[^a-z0-9_]/g, "_");
32919
32932
  }
@@ -40189,7 +40202,6 @@ function resolveIdiom(tokens2, ctx = {}) {
40189
40202
  var IDIOM_CONTEXTS, UNSAFE_KEYS;
40190
40203
  var init_idiom = __esm({
40191
40204
  "../../core/ts/src/idiom.ts"() {
40192
- "use strict";
40193
40205
  init_define_HHP_CATALOG();
40194
40206
  IDIOM_CONTEXTS = {
40195
40207
  ios: { native: ["ios"] },
@@ -40404,9 +40416,9 @@ function springCurve(spring, durationMs2) {
40404
40416
  const x2 = springStep(response, zeta);
40405
40417
  const step = response / 64;
40406
40418
  const envelope = springEnvelope(response, zeta, x2);
40407
- let settle2 = 0;
40408
- for (let t2 = 0; t2 <= SPRING_MAX_SECS && envelope(t2) > SPRING_SETTLE_TOLERANCE; t2 += step) if (Math.abs(1 - x2(t2)) > SPRING_SETTLE_TOLERANCE) settle2 = t2;
40409
- const secs = Math.min(settle2 + step, SPRING_MAX_SECS);
40419
+ let settle3 = 0;
40420
+ for (let t2 = 0; t2 <= SPRING_MAX_SECS && envelope(t2) > SPRING_SETTLE_TOLERANCE; t2 += step) if (Math.abs(1 - x2(t2)) > SPRING_SETTLE_TOLERANCE) settle3 = t2;
40421
+ const secs = Math.min(settle3 + step, SPRING_MAX_SECS);
40410
40422
  const samples = Math.min(200, Math.max(24, Math.ceil(12 * secs / response)));
40411
40423
  const points = [];
40412
40424
  for (let i2 = 0; i2 <= samples; i2++) points.push(i2 === 0 ? 0 : i2 === samples ? 1 : Number(x2(secs * i2 / samples).toFixed(3)));
@@ -45227,7 +45239,7 @@ var init_preview2 = __esm({
45227
45239
  const out2 = [];
45228
45240
  const err = [];
45229
45241
  let settled = false;
45230
- const settle2 = (fn2, v2) => {
45242
+ const settle3 = (fn2, v2) => {
45231
45243
  if (settled) return;
45232
45244
  settled = true;
45233
45245
  clearTimeout(timer);
@@ -45238,14 +45250,14 @@ var init_preview2 = __esm({
45238
45250
  child3.kill("SIGKILL");
45239
45251
  } catch {
45240
45252
  }
45241
- settle2(reject, new Error(`${cmd} ${args[0] ?? ""} timed out after ${timeoutMs}ms`));
45253
+ settle3(reject, new Error(`${cmd} ${args[0] ?? ""} timed out after ${timeoutMs}ms`));
45242
45254
  }, timeoutMs);
45243
45255
  child3.stdout.on("data", (b3) => out2.push(b3));
45244
45256
  child3.stderr.on("data", (b3) => err.push(b3));
45245
- child3.on("error", (e2) => settle2(reject, e2));
45257
+ child3.on("error", (e2) => settle3(reject, e2));
45246
45258
  child3.on("close", (code2) => {
45247
- if (code2 === 0) settle2(resolve130, Buffer.concat(out2));
45248
- else settle2(reject, new Error(`${cmd} exited ${code2}: ${Buffer.concat(err).toString("utf8")}`));
45259
+ if (code2 === 0) settle3(resolve130, Buffer.concat(out2));
45260
+ else settle3(reject, new Error(`${cmd} exited ${code2}: ${Buffer.concat(err).toString("utf8")}`));
45249
45261
  });
45250
45262
  });
45251
45263
  },
@@ -47234,10 +47246,10 @@ function useImageSource(url, box) {
47234
47246
  React4.useEffect(() => {
47235
47247
  if (!url || !load6 || policy !== "ownerScoped" || !adapter) return;
47236
47248
  const controller = new AbortController();
47237
- const settle2 = (next, failed3 = false) => {
47249
+ const settle3 = (next, failed3 = false) => {
47238
47250
  if (!controller.signal.aborted) setResolved({ source: url, adapter, url: next, failed: failed3 });
47239
47251
  };
47240
- adapter.load(load6, controller.signal).then((next) => settle2(next), () => settle2(null, true));
47252
+ adapter.load(load6, controller.signal).then((next) => settle3(next), () => settle3(null, true));
47241
47253
  return () => controller.abort();
47242
47254
  }, [url, load6, policy, adapter, attempt2]);
47243
47255
  const current = resolved3?.source === url && resolved3.adapter === adapter && policy === "ownerScoped" ? resolved3 : null;
@@ -51793,17 +51805,17 @@ var init_controls = __esm({
51793
51805
  if (ni2 !== selIdx) select2(ni2);
51794
51806
  };
51795
51807
  const pagerRef = React16.useRef(null);
51796
- const settle2 = React16.useRef(void 0);
51808
+ const settle3 = React16.useRef(void 0);
51797
51809
  React16.useEffect(() => {
51798
51810
  const el2 = pagerRef.current;
51799
51811
  if (!el2 || !el2.clientWidth) return;
51800
51812
  const x2 = selIdx * el2.clientWidth;
51801
51813
  if (Math.abs(el2.scrollLeft - x2) > 1) el2.scrollTo?.({ left: x2, behavior: "smooth" });
51802
51814
  }, [selIdx, pages2]);
51803
- React16.useEffect(() => () => clearTimeout(settle2.current), []);
51815
+ React16.useEffect(() => () => clearTimeout(settle3.current), []);
51804
51816
  const onPagerScroll = () => {
51805
- clearTimeout(settle2.current);
51806
- settle2.current = setTimeout(() => {
51817
+ clearTimeout(settle3.current);
51818
+ settle3.current = setTimeout(() => {
51807
51819
  const el2 = pagerRef.current;
51808
51820
  if (!el2 || !el2.clientWidth) return;
51809
51821
  const i2 = Math.round(el2.scrollLeft / el2.clientWidth);
@@ -135326,7 +135338,7 @@ function lottieRuntime(lib) {
135326
135338
  } catch {
135327
135339
  }
135328
135340
  };
135329
- const settle2 = (el2) => {
135341
+ const settle3 = (el2) => {
135330
135342
  const anim = lottieAnims.get(el2);
135331
135343
  const host = el2;
135332
135344
  const played = host.dataset.himalayaLottiePlayed;
@@ -135395,7 +135407,7 @@ function lottieRuntime(lib) {
135395
135407
  const stamp = host.getAttribute("data-himalaya-lottie-play");
135396
135408
  if (!anim) return;
135397
135409
  if (!stamp) {
135398
- settle2(el2);
135410
+ settle3(el2);
135399
135411
  return;
135400
135412
  }
135401
135413
  if (host.dataset.himalayaLottiePlayed === stamp) return;
@@ -135412,7 +135424,7 @@ function lottieRuntime(lib) {
135412
135424
  if (r3.type !== "attributes" || !(r3.target instanceof Element)) continue;
135413
135425
  if (r3.attributeName === "data-himalaya-lottie") remount(r3.target);
135414
135426
  else if (r3.attributeName === "data-himalaya-lottie-reduce") applyReduce(r3.target);
135415
- else if (r3.attributeName === "data-himalaya-lottie-gen") settle2(r3.target);
135427
+ else if (r3.attributeName === "data-himalaya-lottie-gen") settle3(r3.target);
135416
135428
  else if (r3.attributeName === "data-himalaya-lottie-loop") applyLoop(r3.target);
135417
135429
  else replay(r3.target);
135418
135430
  }
@@ -140275,7 +140287,7 @@ var init_renderNode = __esm({
140275
140287
  if (!retypeSrc) return;
140276
140288
  let live4 = true;
140277
140289
  let made = null;
140278
- const settle2 = (r3) => {
140290
+ const settle3 = (r3) => {
140279
140291
  const u2 = r3?.url ?? null;
140280
140292
  made = u2;
140281
140293
  if (!live4) {
@@ -140284,7 +140296,7 @@ var init_renderNode = __esm({
140284
140296
  }
140285
140297
  setRetyped({ from: retypeSrc, url: u2, pageCount: r3?.pageCount ?? null });
140286
140298
  };
140287
- loadPdfFetch().then((m2) => m2.retypeAsPdfCounted(retypeSrc)).then(settle2, () => settle2(null));
140299
+ loadPdfFetch().then((m2) => m2.retypeAsPdfCounted(retypeSrc)).then(settle3, () => settle3(null));
140288
140300
  return () => {
140289
140301
  live4 = false;
140290
140302
  if (made) URL.revokeObjectURL(made);
@@ -143668,7 +143680,7 @@ var init_renderNode = __esm({
143668
143680
  const selectedId = isBinding(props2.selectedId) ? boundSel : props2.selectedId;
143669
143681
  const selIdx = Math.max(0, opts.findIndex((o2) => o2?.id === selectedId));
143670
143682
  const viewport = React21.useRef(null);
143671
- const settle2 = React21.useRef(void 0);
143683
+ const settle3 = React21.useRef(void 0);
143672
143684
  const pickerId = React21.useId();
143673
143685
  const interactive = !!ctx.onAction && !!props2.onChange;
143674
143686
  const emit = (index) => {
@@ -143679,7 +143691,7 @@ var init_renderNode = __esm({
143679
143691
  React21.useEffect(() => {
143680
143692
  if (viewport.current) viewport.current.scrollTop = selIdx * 32;
143681
143693
  }, [selIdx, opts.length]);
143682
- React21.useEffect(() => () => clearTimeout(settle2.current), []);
143694
+ React21.useEffect(() => () => clearTimeout(settle3.current), []);
143683
143695
  return /* @__PURE__ */ jsxs11("div", { style: { position: "relative", width: "100%", maxWidth: 220, height: 160, overflow: "hidden", background: C2("surfaceSecondary", "#f5f7fa"), borderRadius: 12, ...wrap }, children: [
143684
143696
  /* @__PURE__ */ jsx14("div", { "aria-hidden": "true", style: { position: "absolute", top: 64, left: 8, right: 8, height: 32, background: C2("surfacePrimary", "#fff"), borderRadius: 8, boxShadow: "inset 0 0 0 1px rgba(0,0,0,.06)" } }),
143685
143697
  /* @__PURE__ */ jsx14(
@@ -143699,8 +143711,8 @@ var init_renderNode = __esm({
143699
143711
  }
143700
143712
  },
143701
143713
  onScroll: () => {
143702
- clearTimeout(settle2.current);
143703
- settle2.current = setTimeout(() => emit(Math.max(0, Math.min(opts.length - 1, Math.round((viewport.current?.scrollTop ?? 0) / 32)))), 120);
143714
+ clearTimeout(settle3.current);
143715
+ settle3.current = setTimeout(() => emit(Math.max(0, Math.min(opts.length - 1, Math.round((viewport.current?.scrollTop ?? 0) / 32)))), 120);
143704
143716
  },
143705
143717
  style: { position: "relative", height: "100%", overflowY: "auto", scrollbarWidth: "none", scrollSnapType: "y mandatory", padding: "64px 0", boxSizing: "border-box" },
143706
143718
  children: opts.map((o2, index) => /* @__PURE__ */ jsx14(
@@ -152208,6 +152220,587 @@ var init_base44_crawl_data = __esm({
152208
152220
  }
152209
152221
  });
152210
152222
 
152223
+ // ../../core/dev-server/src/webview-bridge-crawl.ts
152224
+ function logicBundleOf(descriptor) {
152225
+ if (!isRec3(descriptor)) return null;
152226
+ const lb = descriptor.logicBundle ?? descriptor.logic_bundle;
152227
+ return isRec3(lb) ? lb : null;
152228
+ }
152229
+ function declaredOf(descriptor) {
152230
+ const lb = logicBundleOf(descriptor);
152231
+ const list5 = lb ? lb.declaredCapabilities ?? lb.declared_capabilities : void 0;
152232
+ return Array.isArray(list5) ? list5.filter((c2) => typeof c2 === "string") : [];
152233
+ }
152234
+ function bridgedPages(screenId, descriptor) {
152235
+ if (!isRec3(descriptor)) return { pages: [], templatePages: 0 };
152236
+ const pages2 = [];
152237
+ const renderer = typeof descriptor.renderer === "string" ? descriptor.renderer : "";
152238
+ if (T3_WEBVIEW_RENDERERS.has(renderer) && logicBundleOf(descriptor)) {
152239
+ pages2.push({ node: "(screen)", instanceId: "", path: "", props: {} });
152240
+ }
152241
+ const input = isRec3(descriptor.input) ? descriptor.input : void 0;
152242
+ let templatePages = 0;
152243
+ for (const s5 of bridgedWebViews(descriptor)) {
152244
+ if (s5.inTemplate) {
152245
+ templatePages++;
152246
+ continue;
152247
+ }
152248
+ const explicit3 = typeof s5.props.instanceId === "string" && !s5.props.instanceId.startsWith("$") ? s5.props.instanceId : void 0;
152249
+ pages2.push({ node: s5.id || s5.path, instanceId: effectiveWebViewInstanceId(screenId, input, s5.id, explicit3), path: s5.path, props: s5.props });
152250
+ }
152251
+ return { pages: pages2, templatePages };
152252
+ }
152253
+ function serializationProblem(value2, at2 = "result") {
152254
+ const seen = /* @__PURE__ */ new Set();
152255
+ const walk5 = (v2, path2) => {
152256
+ if (typeof v2 === "bigint") return { fatal: true, what: `a BigInt at ${path2}` };
152257
+ if (typeof v2 === "function") return { fatal: false, what: `a function at ${path2} (JSON drops it)` };
152258
+ if (typeof v2 === "symbol") return { fatal: false, what: `a symbol at ${path2} (JSON drops it)` };
152259
+ if (typeof v2 === "number" && !Number.isFinite(v2)) return { fatal: false, what: `${String(v2)} at ${path2} (JSON sends null)` };
152260
+ if (!v2 || typeof v2 !== "object") return null;
152261
+ if (seen.has(v2)) return { fatal: true, what: `a cycle at ${path2}` };
152262
+ if (typeof v2.toJSON === "function") return null;
152263
+ const tag = tagOf(v2);
152264
+ if (tag === "Map" || tag === "Set" || tag === "WeakMap" || tag === "WeakSet") {
152265
+ return { fatal: false, what: `a ${tag} at ${path2} (JSON sends {})` };
152266
+ }
152267
+ seen.add(v2);
152268
+ try {
152269
+ if (Array.isArray(v2)) {
152270
+ for (let i2 = 0; i2 < v2.length; i2++) {
152271
+ const p2 = walk5(v2[i2], `${path2}[${i2}]`);
152272
+ if (p2) return p2;
152273
+ }
152274
+ return null;
152275
+ }
152276
+ for (const [k3, child3] of Object.entries(v2)) {
152277
+ const p2 = walk5(child3, `${path2}.${k3}`);
152278
+ if (p2) return p2;
152279
+ }
152280
+ return null;
152281
+ } finally {
152282
+ seen.delete(v2);
152283
+ }
152284
+ };
152285
+ return walk5(value2, at2);
152286
+ }
152287
+ function createPageHost() {
152288
+ let pageHandler = null;
152289
+ let lifecycleHandler = null;
152290
+ const outbox = [];
152291
+ let live4 = null;
152292
+ const runtime = {
152293
+ postToPage(msg, instanceId) {
152294
+ const rec = isRec3(msg) ? msg : { value: msg };
152295
+ const field = "result" in rec ? "result" : "chunk" in rec ? "chunk" : "data" in rec ? "data" : null;
152296
+ let problem = field ? serializationProblem(rec[field], field) : null;
152297
+ if (!problem) {
152298
+ try {
152299
+ JSON.stringify(msg);
152300
+ } catch (e2) {
152301
+ problem = { fatal: true, what: String(e2?.message ?? e2) };
152302
+ }
152303
+ }
152304
+ const posted = { iid: typeof instanceId === "string" ? instanceId : "", msg: rec, problem };
152305
+ outbox.push(posted);
152306
+ try {
152307
+ live4?.(posted);
152308
+ } catch {
152309
+ }
152310
+ },
152311
+ onPageMessage(cb) {
152312
+ pageHandler = typeof cb === "function" ? cb : null;
152313
+ },
152314
+ onPageLifecycle(cb) {
152315
+ lifecycleHandler = typeof cb === "function" ? cb : null;
152316
+ }
152317
+ };
152318
+ return {
152319
+ runtime,
152320
+ outbox,
152321
+ listening: () => pageHandler !== null,
152322
+ attach(cb) {
152323
+ live4 = cb;
152324
+ },
152325
+ send(msg, iid) {
152326
+ if (!pageHandler) return null;
152327
+ try {
152328
+ pageHandler(overTheWire(msg), iid);
152329
+ return null;
152330
+ } catch (e2) {
152331
+ return String(e2?.message ?? e2);
152332
+ }
152333
+ },
152334
+ lifecycle(state, iid) {
152335
+ try {
152336
+ lifecycleHandler?.({ v: 1, sys: "lifecycle", iid, state }, iid);
152337
+ } catch {
152338
+ }
152339
+ }
152340
+ };
152341
+ }
152342
+ async function settle(done, ms2) {
152343
+ const end2 = Date.now() + ms2;
152344
+ do
152345
+ await new Promise((r3) => setTimeout(r3, 0));
152346
+ while (!done() && Date.now() < end2);
152347
+ }
152348
+ function bindingValue(state, binding2) {
152349
+ const m2 = /^\$service:([^.[]+)(?:\.(.+))?$/.exec(binding2);
152350
+ if (!m2) return void 0;
152351
+ const svc = state[m2[1]];
152352
+ return m2[2] ? pathValue(svc, m2[2]) : svc;
152353
+ }
152354
+ function typeMismatch(value2, expect) {
152355
+ if (value2 === void 0) return false;
152356
+ if (expect === "boolean") return typeof value2 !== "boolean";
152357
+ if (expect === "number") return typeof value2 !== "number" || !Number.isFinite(value2);
152358
+ return !(typeof value2 === "string" || typeof value2 === "number" || typeof value2 === "boolean");
152359
+ }
152360
+ async function crawlWebViewBridge(o2) {
152361
+ const { screenId, descriptor } = o2;
152362
+ const { pages: pages2, templatePages } = bridgedPages(screenId, descriptor);
152363
+ if (!pages2.length && !templatePages) return null;
152364
+ const declared = declaredOf(descriptor);
152365
+ if (!grants(declared, "webview")) return null;
152366
+ const budgetMs = o2.budgetMs && o2.budgetMs > 0 ? o2.budgetMs : 2e3;
152367
+ if (!pages2.length) {
152368
+ return { screen: screenId, pages: [], templatePages, listening: false, manifest: null, calls: [], probes: { sent: 0, threw: 0 }, events: [], findings: [] };
152369
+ }
152370
+ const host = createPageHost();
152371
+ const w2 = await o2.boot(host.runtime);
152372
+ if (!w2) return null;
152373
+ const findings = [];
152374
+ const calls = [];
152375
+ const seen = /* @__PURE__ */ new Set();
152376
+ const add = (f2) => {
152377
+ const k3 = `${f2.invariant}|${f2.at ?? ""}|${f2.message}`;
152378
+ if (seen.has(k3)) return;
152379
+ seen.add(k3);
152380
+ findings.push({ screen: screenId, trigger: "boot", axis: "webview:bridge", ...f2 });
152381
+ };
152382
+ const page = pages2[0];
152383
+ let seq3 = 0;
152384
+ const nextId = () => `himi-test-${++seq3}`;
152385
+ const answerTo = (id) => host.outbox.find((p2) => p2.msg.id === id && "ok" in p2.msg);
152386
+ try {
152387
+ for (const p2 of pages2) for (const state of ["mounted", "loaded", "active"]) host.lifecycle(state, p2.instanceId);
152388
+ await settle(() => false, DRAIN_MS);
152389
+ const handshake = async (iid) => {
152390
+ const id = nextId();
152391
+ host.send({ v: 1, id, capability: "himalaya", method: "capabilities", args: [] }, iid);
152392
+ await settle(() => !!answerTo(id), budgetMs);
152393
+ const res = answerTo(id)?.msg;
152394
+ const caps = res?.ok === true && isRec3(res.result) && isRec3(res.result.capabilities) ? res.result.capabilities : null;
152395
+ if (!caps) return null;
152396
+ const out2 = {};
152397
+ for (const [k3, v2] of Object.entries(caps)) if (Array.isArray(v2)) out2[k3] = Array.from(v2).filter((m2) => typeof m2 === "string");
152398
+ return out2;
152399
+ };
152400
+ const listening = host.listening();
152401
+ const manifest2 = listening ? await handshake(page.instanceId) : null;
152402
+ if (!listening) {
152403
+ add({
152404
+ invariant: "webview-page-unheard",
152405
+ severity: "warning",
152406
+ at: page.path || void 0,
152407
+ message: `the page of ${page.node === "(screen)" ? "this WebView screen" : `WebView "${page.node}"`} has a worker channel, but the worker never listens on it \u2014 every \`himalaya.*\` call the page makes is unanswered`,
152408
+ hint: `Register the page surface during the bundle's setup: exposeCapabilitiesToPage({...}), onPageRequest(namespace, handlers) or onPageMessage(cb) from @himalaya/webview. If the page needs no native calls, drop bridge: "worker".`
152409
+ });
152410
+ }
152411
+ const staticallyUndeclared = /* @__PURE__ */ new Set();
152412
+ for (const [ns2, methods] of Object.entries(manifest2 ?? {})) {
152413
+ const sdk = PAGE_METHODS[ns2];
152414
+ if (!sdk) continue;
152415
+ if (!grants(declared, ns2)) {
152416
+ staticallyUndeclared.add(ns2);
152417
+ add({
152418
+ invariant: "capability-undeclared",
152419
+ severity: "error",
152420
+ message: `the worker exposes "${ns2}" to the page, but logicBundle.declaredCapabilities does not grant it \u2014 the native registry refuses every call, so the page's ${ns2}.* calls all fail`,
152421
+ hint: `Add "${ns2}" to declaredCapabilities (and to the app config's capabilities), or stop exposing it.`
152422
+ });
152423
+ continue;
152424
+ }
152425
+ for (const m2 of methods) {
152426
+ const missing4 = (METHOD_REQUIRES[`${ns2}.${m2}`] ?? []).filter((r3) => !grants(declared, r3));
152427
+ if (missing4.length) {
152428
+ add({
152429
+ invariant: "capability-undeclared",
152430
+ severity: "error",
152431
+ message: `the page is offered ${ns2}.${m2}, which also needs ${missing4.map((c2) => `"${c2}"`).join(", ")} \u2014 not granted by logicBundle.declaredCapabilities, so the call is refused on device`,
152432
+ hint: `Declare ${missing4.join(", ")} too, or drop "${m2}" from the exposed methods (the generated companion leaves it out).`
152433
+ });
152434
+ }
152435
+ }
152436
+ const also = sdk.dispatchesAlso.filter((c2) => !grants(declared, c2));
152437
+ if (also.length) {
152438
+ add({
152439
+ invariant: "capability-undeclared",
152440
+ severity: "warning",
152441
+ message: `"${ns2}" is exposed to the page, and its package also dispatches ${also.map((c2) => `"${c2}"`).join(", ")}, which logicBundle.declaredCapabilities does not grant \u2014 the methods that use it are refused on device`,
152442
+ hint: `The generated companion declares ${["webview", ns2, ...sdk.dispatchesAlso].join(", ")}.`
152443
+ });
152444
+ }
152445
+ }
152446
+ const loaded2 = [];
152447
+ const notLoaded = [];
152448
+ if (o2.pages && listening) {
152449
+ for (const p2 of pages2) {
152450
+ const src = pageSource(p2, descriptor);
152451
+ if (!src) {
152452
+ notLoaded.push({ node: p2.node, why: "no inlineHtml or url" });
152453
+ continue;
152454
+ }
152455
+ if (src.url && !o2.pages.live) {
152456
+ notLoaded.push({ node: p2.node, why: `remote url ${src.url} \u2014 pass --webview-live to load it` });
152457
+ continue;
152458
+ }
152459
+ try {
152460
+ loaded2.push(await playPage(o2.pages, p2, src, descriptor, host, w2, manifest2, declared, add, staticallyUndeclared));
152461
+ } catch (e2) {
152462
+ notLoaded.push({ node: p2.node, why: String(e2?.message ?? e2).split("\n")[0] });
152463
+ }
152464
+ }
152465
+ } else if (o2.pages && !listening) {
152466
+ for (const p2 of pages2) notLoaded.push({ node: p2.node, why: "the worker never listens on the page channel" });
152467
+ }
152468
+ const inputCrashes = /* @__PURE__ */ new Map();
152469
+ const call = async (iid, ns2, method, args) => {
152470
+ const kind = PAGE_METHODS[ns2] ? "capability" : "namespace";
152471
+ const id = nextId();
152472
+ const deniedBefore = w2.deniedCapabilities.length;
152473
+ const from = host.outbox.length;
152474
+ host.send({ v: 1, id, capability: ns2, method, args }, iid);
152475
+ await settle(() => !!answerTo(id), budgetMs);
152476
+ const answer = answerTo(id);
152477
+ const denied2 = w2.deniedCapabilities.slice(deniedBefore);
152478
+ if (!answer) return { capability: ns2, method, kind, outcome: "unanswered", denied: denied2 };
152479
+ const res = answer.msg;
152480
+ if (res.stream === true) {
152481
+ const isChunk = (p2) => p2.msg.sid === id;
152482
+ const ended = () => host.outbox.slice(from).some((p2) => isChunk(p2) && ("end" in p2.msg || "error" in p2.msg));
152483
+ await settle(ended, budgetMs);
152484
+ const chunks = host.outbox.slice(from).filter((p2) => isChunk(p2) && "chunk" in p2.msg);
152485
+ if (!ended()) host.send({ v: 1, sys: "cancel", sid: id }, iid);
152486
+ const problem = chunks.map((c2) => c2.problem).find(Boolean) ?? null;
152487
+ return { capability: ns2, method, kind, outcome: "stream", chunks: chunks.length, problem, denied: denied2 };
152488
+ }
152489
+ if (res.ok === true) return { capability: ns2, method, kind, outcome: "ok", problem: answer.problem, denied: denied2 };
152490
+ const err = isRec3(res.error) ? res.error : {};
152491
+ return {
152492
+ capability: ns2,
152493
+ method,
152494
+ kind,
152495
+ outcome: "error",
152496
+ denied: denied2,
152497
+ ...typeof err.code === "string" ? { code: err.code } : {},
152498
+ ...typeof err.message === "string" ? { message: err.message } : {}
152499
+ };
152500
+ };
152501
+ for (const pg of manifest2 ? pages2 : []) for (const [ns2, methods] of Object.entries(manifest2 ?? {})) {
152502
+ for (const method of methods) {
152503
+ const r3 = await call(pg.instanceId, ns2, method, []);
152504
+ calls.push({ capability: r3.capability, method: r3.method, kind: r3.kind, outcome: r3.outcome, ...r3.code ? { code: r3.code } : {}, ...r3.chunks !== void 0 ? { chunks: r3.chunks } : {}, ...pages2.length > 1 ? { instanceId: pg.instanceId } : {} });
152505
+ const label4 = `${ns2}.${method}`;
152506
+ if (r3.denied.length && !staticallyUndeclared.has(ns2)) {
152507
+ const ids2 = [...new Set(r3.denied.map((d2) => d2.replace(/^capability\./, "").split(".")[0]))];
152508
+ add({
152509
+ invariant: "capability-undeclared",
152510
+ severity: "error",
152511
+ message: `the page's call ${label4}() reached ${ids2.join(", ")}, which logicBundle.declaredCapabilities does not grant \u2014 refused on device`,
152512
+ hint: `Declare ${ids2.join(", ")}, or stop exposing ${label4}.`
152513
+ });
152514
+ }
152515
+ if (r3.outcome === "unanswered") {
152516
+ const sdk = PAGE_METHODS[ns2];
152517
+ const notExported = sdk && !sdk.methods.includes(method);
152518
+ add({
152519
+ invariant: "webview-call-unanswered",
152520
+ severity: notExported ? "error" : "warning",
152521
+ message: notExported ? `the page is offered ${label4}, but ${sdk.package} has no page-callable "${method}" \u2014 the dispatcher finds no function and never answers, so the page's promise hangs forever` : `the page's call ${label4}() was never answered within the crawl's budget \u2014 a page awaiting it hangs`,
152522
+ hint: notExported ? `${ns2} offers: ${sdk.methods.join(", ")}. Fix the name in exposeCapabilitiesToPage's methods list.` : r3.kind === "namespace" ? "An onPageRequest handler must return or throw; one that waits for something the page never sends leaves the call pending forever. Return a stream (openPageStream) for long-lived answers." : "The exposed SDK call never settled on the crawl's capability bus."
152523
+ });
152524
+ }
152525
+ if (r3.problem) {
152526
+ add({
152527
+ invariant: "webview-answer-unserializable",
152528
+ severity: r3.problem.fatal ? "error" : "warning",
152529
+ message: r3.problem.fatal ? `${label4}() answers ${r3.problem.what} \u2014 the device's bridge cannot JSON-encode it, so the answer is never delivered and the page's promise hangs` : `${label4}() answers ${r3.problem.what} \u2014 the page receives something other than what the worker returned`,
152530
+ hint: "Return plain JSON data from page handlers: objects, arrays, strings, finite numbers, booleans, null."
152531
+ });
152532
+ }
152533
+ if (r3.kind === "namespace") {
152534
+ if (r3.outcome === "error" && r3.message && INPUT_CRASH.test(r3.message)) inputCrashes.set(label4, `() \u2192 ${r3.message}`);
152535
+ for (const args of HOSTILE_ARGS) {
152536
+ if (inputCrashes.has(label4)) break;
152537
+ const h2 = await call(pg.instanceId, ns2, method, args);
152538
+ if (h2.outcome === "error" && h2.message && INPUT_CRASH.test(h2.message)) inputCrashes.set(label4, `(${JSON.stringify(args).slice(1, -1)}) \u2192 ${h2.message}`);
152539
+ }
152540
+ }
152541
+ }
152542
+ }
152543
+ if (inputCrashes.size) {
152544
+ add({
152545
+ invariant: "webview-page-input-crash",
152546
+ severity: "warning",
152547
+ message: `${inputCrashes.size} page handler(s) crash on page input instead of answering a typed error: ${[...inputCrashes].map(([m2, why]) => `${m2}${why}`).join("; ")}`,
152548
+ hint: "The page is untrusted (RFC 0073 \xA75.3). Validate args in each onPageRequest handler and throw an Error with a `code` the page can branch on."
152549
+ });
152550
+ }
152551
+ let threw = 0;
152552
+ const threwOn = [];
152553
+ if (listening) {
152554
+ for (const pg of pages2) for (const probe2 of PROBES) {
152555
+ const err = host.send(probe2.msg, pg.instanceId);
152556
+ if (err !== null) {
152557
+ threw++;
152558
+ threwOn.push(`${probe2.label} (${err})`);
152559
+ }
152560
+ }
152561
+ await settle(() => false, DRAIN_MS);
152562
+ if (threw) {
152563
+ add({
152564
+ invariant: "webview-page-input-crash",
152565
+ severity: "warning",
152566
+ message: `worker code threw on ${threw} malformed page message(s): ${threwOn.slice(0, 4).join("; ")}${threwOn.length > 4 ? "; \u2026" : ""}`,
152567
+ hint: "An onPageMessage handler receives whatever the page posts. Check the shape before reading fields."
152568
+ });
152569
+ }
152570
+ if (manifest2 && (await Promise.all(pages2.map((pg) => handshake(pg.instanceId)))).some((m2) => !m2)) {
152571
+ add({
152572
+ invariant: "webview-call-unanswered",
152573
+ severity: "error",
152574
+ message: "the page channel answered the handshake, then stopped answering after malformed page messages \u2014 one bad message from the page breaks every later call",
152575
+ hint: "Something the page sent corrupted the worker's channel state. Re-run with the probes in webview-bridge-crawl.ts to find which."
152576
+ });
152577
+ }
152578
+ }
152579
+ for (const p2 of pages2) {
152580
+ for (const b3 of BINDING_TYPES) {
152581
+ const binding2 = p2.props[b3.prop];
152582
+ if (typeof binding2 !== "string" || !binding2.startsWith("$service:")) continue;
152583
+ const value2 = bindingValue(w2.state, binding2);
152584
+ if (!typeMismatch(value2, b3.expect)) continue;
152585
+ add({
152586
+ invariant: "webview-binding-type",
152587
+ severity: "warning",
152588
+ at: `${p2.path}.body.props.${b3.prop}`,
152589
+ message: `WebView "${p2.node}" ${b3.prop} "${binding2}" resolves to ${JSON.stringify(value2) ?? String(value2)} \u2014 the host reads ${b3.reads}`,
152590
+ hint: `Keep ${binding2.slice("$service:".length)} as ${b3.reads} in the worker state.`
152591
+ });
152592
+ }
152593
+ }
152594
+ for (const p2 of pages2) host.lifecycle("unmounted", p2.instanceId);
152595
+ const events2 = [...new Set(host.outbox.filter((p2) => typeof p2.msg.ev === "string").map((p2) => `${String(p2.msg.ns)}.${String(p2.msg.ev)}`))].sort();
152596
+ return {
152597
+ screen: screenId,
152598
+ pages: pages2.map((p2) => ({ node: p2.node, instanceId: p2.instanceId })),
152599
+ templatePages,
152600
+ listening,
152601
+ manifest: manifest2,
152602
+ calls,
152603
+ probes: { sent: listening ? PROBES.length * pages2.length : 0, threw },
152604
+ events: events2,
152605
+ ...o2.pages ? { loaded: loaded2, notLoaded } : {},
152606
+ findings
152607
+ };
152608
+ } finally {
152609
+ w2.dispose();
152610
+ }
152611
+ }
152612
+ function pageSource(p2, descriptor) {
152613
+ if (p2.node === "(screen)") {
152614
+ const url = isRec3(descriptor) && typeof descriptor.url === "string" ? descriptor.url : "";
152615
+ return url ? { url } : null;
152616
+ }
152617
+ if (typeof p2.props.inlineHtml === "string" && p2.props.inlineHtml) return { html: p2.props.inlineHtml };
152618
+ if (typeof p2.props.url === "string" && p2.props.url) return { url: p2.props.url };
152619
+ return null;
152620
+ }
152621
+ function allowedOriginsOf2(p2, descriptor) {
152622
+ const config = p2.node === "(screen)" ? isRec3(descriptor) && isRec3(descriptor.webViewConfig) ? descriptor.webViewConfig : {} : isRec3(p2.props.config) ? p2.props.config : {};
152623
+ return Array.isArray(config.allowedOrigins) ? config.allowedOrigins.filter((o2) => typeof o2 === "string") : [];
152624
+ }
152625
+ async function playPage(opt3, p2, src, descriptor, host, w2, manifest2, declared, add, staticallyUndeclared) {
152626
+ const where = p2.node === "(screen)" ? "this WebView screen's page" : `WebView "${p2.node}"'s page`;
152627
+ const requests = [];
152628
+ let traffic = 0;
152629
+ let rawTraffic = 0;
152630
+ const outboxFrom = host.outbox.length;
152631
+ const deniedFrom = w2.deniedCapabilities.length;
152632
+ let session = null;
152633
+ let chain = Promise.resolve();
152634
+ const early = [];
152635
+ const deliver = (posted) => {
152636
+ const s5 = session;
152637
+ chain = chain.then(() => s5.deliver(posted.msg)).catch(() => {
152638
+ });
152639
+ };
152640
+ host.attach((posted) => {
152641
+ if (posted.iid !== p2.instanceId) return;
152642
+ traffic++;
152643
+ if (typeof posted.msg.id !== "string" && typeof posted.msg.sid !== "string" && typeof posted.msg.ev !== "string") rawTraffic++;
152644
+ if (session) deliver(posted);
152645
+ else early.push(posted);
152646
+ });
152647
+ const result = {
152648
+ node: p2.node,
152649
+ source: src.html !== void 0 ? "inline" : "url",
152650
+ calls: [],
152651
+ pageErrors: [],
152652
+ consoleErrors: 0,
152653
+ links: { total: 0, offAllowlist: 0 },
152654
+ blockedRequests: 0
152655
+ };
152656
+ try {
152657
+ session = await opt3.driver.open({
152658
+ ...src,
152659
+ budgetMs: opt3.budgetMs ?? 3e3,
152660
+ network: opt3.live,
152661
+ toWorker: (msg) => {
152662
+ traffic++;
152663
+ if (isRec3(msg) && msg.v === 1 && typeof msg.id === "string" && typeof msg.capability === "string" && typeof msg.method === "string") {
152664
+ requests.push({ id: msg.id, capability: msg.capability, method: msg.method });
152665
+ }
152666
+ host.send(msg, p2.instanceId);
152667
+ }
152668
+ });
152669
+ for (const posted of early.splice(0)) deliver(posted);
152670
+ await session.settle(() => traffic);
152671
+ await chain;
152672
+ const report9 = await session.report();
152673
+ if (report9.loadError) {
152674
+ add({
152675
+ invariant: "webview-page-error",
152676
+ severity: "warning",
152677
+ at: p2.path || void 0,
152678
+ message: `${where} did not load in the crawl's browser: ${report9.loadError}`,
152679
+ hint: "The bridge pass still ran against the worker; only the page's own behaviour is unverified."
152680
+ });
152681
+ }
152682
+ result.pageErrors = report9.pageErrors.slice(0, 10);
152683
+ result.consoleErrors = report9.consoleErrors.length;
152684
+ result.blockedRequests = report9.blockedRequests;
152685
+ const allowed2 = allowedOriginsOf2(p2, descriptor);
152686
+ const httpLinks = report9.links.filter((h2) => originOf2(h2));
152687
+ result.links = {
152688
+ total: httpLinks.length,
152689
+ offAllowlist: allowed2.length ? httpLinks.filter((h2) => !webViewOriginAllowed(h2, allowed2)).length : 0
152690
+ };
152691
+ if (report9.pageErrors.length) {
152692
+ add({
152693
+ invariant: "webview-page-error",
152694
+ severity: "warning",
152695
+ at: p2.path || void 0,
152696
+ message: `${where} threw ${report9.pageErrors.length} uncaught error(s) while loading: ${report9.pageErrors.slice(0, 3).join("; ")}`,
152697
+ hint: report9.blockedRequests ? `Uncaught page errors usually mean a feature silently stopped. ${report9.blockedRequests} network request(s) the page made were refused to keep the run hermetic \u2014 if the errors come from those, --webview-live lets them through.` : "Uncaught page errors usually mean a feature silently stopped. They ran against the real worker, with the crawl's data."
152698
+ });
152699
+ }
152700
+ } finally {
152701
+ host.attach(null);
152702
+ await session?.close().catch(() => {
152703
+ });
152704
+ }
152705
+ const answers2 = host.outbox.slice(outboxFrom).filter((x2) => x2.iid === p2.instanceId && typeof x2.msg.id === "string" && "ok" in x2.msg);
152706
+ const unknownMethods = [];
152707
+ for (const r3 of requests) {
152708
+ if (r3.capability === "himalaya") continue;
152709
+ const a3 = answers2.find((x2) => x2.msg.id === r3.id)?.msg;
152710
+ const outcome = !a3 ? "unanswered" : a3.ok !== true ? "error" : a3.stream === true ? "stream" : "ok";
152711
+ const code2 = a3 && a3.ok !== true && isRec3(a3.error) && typeof a3.error.code === "string" ? a3.error.code : void 0;
152712
+ result.calls.push({ capability: r3.capability, method: r3.method, outcome, ...code2 ? { code: code2 } : {} });
152713
+ const label4 = `${r3.capability}.${r3.method}`;
152714
+ if (outcome === "unanswered") {
152715
+ const offered = manifest2?.[r3.capability];
152716
+ const certain = !!manifest2 && !offered && rawTraffic === 0;
152717
+ add({
152718
+ invariant: "webview-call-unanswered",
152719
+ severity: certain ? "error" : "warning",
152720
+ at: p2.path || void 0,
152721
+ message: certain ? `${where} calls ${label4}() while loading, but the worker does not offer "${r3.capability}" \u2014 the call is never answered and the page's promise hangs` : `${where} calls ${label4}() while loading, and it was not answered within the crawl's budget`,
152722
+ hint: certain ? `The worker offers: ${Object.keys(manifest2 ?? {}).join(", ") || "nothing"}. Expose it (exposeCapabilitiesToPage / onPageRequest), or have the page check himalaya.isEnabled("${r3.capability}", "${r3.method}") first.` : "A page awaiting it hangs; return or throw from the handler, or answer with a stream."
152723
+ });
152724
+ }
152725
+ if (code2 === "unknown_method") unknownMethods.push(label4);
152726
+ }
152727
+ if (unknownMethods.length) {
152728
+ add({
152729
+ invariant: "webview-call-unanswered",
152730
+ severity: "warning",
152731
+ at: p2.path || void 0,
152732
+ message: `${where} calls methods its worker's namespace does not have: ${[...new Set(unknownMethods)].join(", ")} \u2014 each answers unknown_method`,
152733
+ hint: "Add the handler to onPageRequest, or fix the page's method name."
152734
+ });
152735
+ }
152736
+ const denied2 = [...new Set(w2.deniedCapabilities.slice(deniedFrom).map((d2) => d2.replace(/^capability\./, "").split(".")[0]))].filter((c2) => !staticallyUndeclared.has(c2) && !grants(declared, c2));
152737
+ if (denied2.length) {
152738
+ add({
152739
+ invariant: "capability-undeclared",
152740
+ severity: "error",
152741
+ at: p2.path || void 0,
152742
+ message: `${where} drove the worker into ${denied2.join(", ")}, which logicBundle.declaredCapabilities does not grant \u2014 refused on device`,
152743
+ hint: `Declare ${denied2.join(", ")}, or stop exposing what reaches it.`
152744
+ });
152745
+ }
152746
+ return result;
152747
+ }
152748
+ var T3_WEBVIEW_RENDERERS, isRec3, tagOf, overTheWire, DRAIN_MS, INPUT_CRASH, PROBES, HOSTILE_ARGS, BINDING_TYPES, originOf2;
152749
+ var init_webview_bridge_crawl = __esm({
152750
+ "../../core/dev-server/src/webview-bridge-crawl.ts"() {
152751
+ init_define_HHP_CATALOG();
152752
+ init_validate_descriptor_core();
152753
+ init_webview_embedded();
152754
+ init_webview_origin();
152755
+ init_page_methods_generated();
152756
+ init_page_method_requires();
152757
+ init_implications();
152758
+ T3_WEBVIEW_RENDERERS = /* @__PURE__ */ new Set(["webview_native_bridge", "webview_ds"]);
152759
+ isRec3 = (v2) => !!v2 && typeof v2 === "object" && !Array.isArray(v2);
152760
+ tagOf = (v2) => Object.prototype.toString.call(v2).slice(8, -1);
152761
+ overTheWire = (msg) => msg === void 0 ? void 0 : JSON.parse(JSON.stringify(msg));
152762
+ DRAIN_MS = 10;
152763
+ INPUT_CRASH = /Cannot read propert|Cannot destructure|is not a function|is not iterable|undefined is not an object|null is not an object|Cannot convert undefined or null/;
152764
+ PROBES = [
152765
+ { label: "null", msg: null },
152766
+ { label: "a string", msg: "hello" },
152767
+ { label: "a number", msg: 42 },
152768
+ { label: "an array", msg: [1, 2] },
152769
+ { label: "an empty object", msg: {} },
152770
+ { label: "{ v: 1 } alone", msg: { v: 1 } },
152771
+ { label: "a request without args", msg: { v: 1, id: "probe-noargs", capability: "himalaya", method: "capabilities" } },
152772
+ { label: "args that is not an array", msg: { v: 1, id: "probe-args", capability: "himalaya", method: "capabilities", args: "x" } },
152773
+ { label: "13 args", msg: { v: 1, id: "probe-13", capability: "himalaya", method: "capabilities", args: Array.from({ length: 13 }, () => 0) } },
152774
+ { label: "a __proto__ capability", msg: { v: 1, id: "probe-proto", capability: "__proto__", method: "toString", args: [] } },
152775
+ { label: "a cancel for an unknown stream", msg: { v: 1, sys: "cancel", sid: "probe-nostream" } },
152776
+ { label: "a forged lifecycle", msg: { v: 1, sys: "lifecycle", state: "unmounted" } },
152777
+ { label: "a console message with odd args", msg: { v: 1, sys: "console", level: "error", args: "not-an-array" } },
152778
+ { label: "a malformed site report", msg: { v: 1, sys: "site", cart: "lots", member: 7 } },
152779
+ { label: "a deeply nested object", msg: (() => {
152780
+ let o2 = { leaf: true };
152781
+ for (let i2 = 0; i2 < 120; i2++) o2 = { o: o2 };
152782
+ return o2;
152783
+ })() },
152784
+ { label: "a 200 KB string", msg: { v: 1, text: "x".repeat(2e5) } }
152785
+ ];
152786
+ HOSTILE_ARGS = [[null], [{}], ["<img src=x onerror=alert(1)>"]];
152787
+ BINDING_TYPES = [
152788
+ { prop: "activePath", expect: "boolean", reads: "a boolean (false = inactive)" },
152789
+ { prop: "mutedPath", expect: "boolean", reads: "a boolean (true = muted)" },
152790
+ { prop: "heightPath", expect: "number", reads: "a finite number of points/dp" },
152791
+ { prop: "reloadKeyPath", expect: "scalar", reads: "a string, number or boolean" }
152792
+ ];
152793
+ originOf2 = (href) => {
152794
+ try {
152795
+ const u2 = new URL(href);
152796
+ return u2.protocol === "http:" || u2.protocol === "https:" ? u2.origin : null;
152797
+ } catch {
152798
+ return null;
152799
+ }
152800
+ };
152801
+ }
152802
+ });
152803
+
152211
152804
  // ../../core/web-host/src/persistence/query.ts
152212
152805
  function isScalar(v2) {
152213
152806
  return typeof v2 === "string" || typeof v2 === "number" || typeof v2 === "boolean";
@@ -152586,6 +153179,7 @@ __export(screen_crawl_exports, {
152586
153179
  crawlScreenHostile: () => crawlScreenHostile,
152587
153180
  crawlScreenJourney: () => crawlScreenJourney,
152588
153181
  crawlScreenRelations: () => crawlScreenRelations,
153182
+ crawlScreenWebView: () => crawlScreenWebView,
152589
153183
  crawlSignature: () => crawlSignature,
152590
153184
  declaredCapabilitiesOf: () => declaredCapabilitiesOf,
152591
153185
  deepStateSignature: () => deepStateSignature,
@@ -153498,7 +154092,8 @@ async function bootScreenWorker(opts) {
153498
154092
  seed: opts.seed ?? 1,
153499
154093
  skipLoad: opts.authoredLoadOnly === true || !!(appear && parseWorkerAction(appear.actionId)),
153500
154094
  settleAuthoredActions: opts.authoredLoadOnly === true,
153501
- ...opts.evaluator ? { evaluator: opts.evaluator } : {}
154095
+ ...opts.evaluator ? { evaluator: opts.evaluator } : {},
154096
+ ...opts.webview ? { webview: opts.webview } : {}
153502
154097
  });
153503
154098
  let deadLifecycle;
153504
154099
  if (appear) {
@@ -153593,6 +154188,40 @@ async function crawlScreenCapabilitySuccess(opts) {
153593
154188
  };
153594
154189
  });
153595
154190
  }
154191
+ async function crawlScreenWebView(opts) {
154192
+ if (!opts.bundleJs) return null;
154193
+ let realm;
154194
+ try {
154195
+ realm = resolveActionEvaluator(opts.evaluator);
154196
+ } catch {
154197
+ return null;
154198
+ }
154199
+ if (realm.runWithActions) return null;
154200
+ const bundleJs = opts.bundleJs;
154201
+ return withSwallowedRejections(() => crawlWebViewBridge({
154202
+ screenId: opts.screenId,
154203
+ descriptor: opts.descriptor,
154204
+ ...opts.webviewPages ? { pages: opts.webviewPages } : {},
154205
+ ...opts.budgetMs ? { budgetMs: opts.budgetMs } : {},
154206
+ boot: (webview) => {
154207
+ const { call: wixCall } = layeredTransport({ rules: opts.rules, cmsSeed: opts.cmsSeed, canned: opts.canned });
154208
+ return bootScreenWorker({
154209
+ bundleJs,
154210
+ descriptor: opts.descriptor,
154211
+ wixCall,
154212
+ screenId: opts.screenId,
154213
+ inputOverride: opts.inputOverride,
154214
+ budgetMs: opts.budgetMs,
154215
+ clock: opts.clock,
154216
+ seed: opts.seed,
154217
+ localDbSchema: opts.localDbSchema,
154218
+ l10n: opts.l10n,
154219
+ base44Data: opts.base44Data,
154220
+ webview
154221
+ });
154222
+ }
154223
+ }));
154224
+ }
153596
154225
  async function crawlScreen(opts) {
153597
154226
  return withSwallowedRejections(async () => {
153598
154227
  const result = await crawlScreenInner(opts);
@@ -155135,6 +155764,7 @@ var init_screen_crawl = __esm({
155135
155764
  init_bindings();
155136
155765
  init_capability_fixtures();
155137
155766
  init_base44_crawl_data();
155767
+ init_webview_bridge_crawl();
155138
155768
  init_query();
155139
155769
  init_crawl_input();
155140
155770
  init_crawl_relations();
@@ -155941,7 +156571,7 @@ function gitSha() {
155941
156571
  return "dev";
155942
156572
  }
155943
156573
  }
155944
- function logicBundleOf(descriptor) {
156574
+ function logicBundleOf2(descriptor) {
155945
156575
  return descriptor?.logicBundle ?? descriptor?.logic_bundle ?? null;
155946
156576
  }
155947
156577
  function collectComponentTypes(value2, into = /* @__PURE__ */ new Set()) {
@@ -156281,7 +156911,7 @@ async function buildFromLoaded(preloaded, dest, opts = {}) {
156281
156911
  const pinnedLanguage = pinnedLanguageSwap(config.locale, preloaded.dir);
156282
156912
  const workerSources = /* @__PURE__ */ new Map();
156283
156913
  const workerSourceOf = (descriptor) => {
156284
- const url = logicBundleOf(descriptor)?.url;
156914
+ const url = logicBundleOf2(descriptor)?.url;
156285
156915
  const name = typeof url === "string" ? bundleNameFromUrl(url) : null;
156286
156916
  if (!name) return void 0;
156287
156917
  if (!workerSources.has(name)) {
@@ -156750,7 +157380,7 @@ async function buildFromLoaded(preloaded, dest, opts = {}) {
156750
157380
  assertComponentMinVersions(screenId, descriptor);
156751
157381
  collectNativeComponents(descriptor, requiredNativeComponents);
156752
157382
  let bundleName = null;
156753
- const lb = logicBundleOf(descriptor);
157383
+ const lb = logicBundleOf2(descriptor);
156754
157384
  if (lb) {
156755
157385
  bundleName = bundleNameFromUrl(lb.url);
156756
157386
  if (bundleName) {
@@ -156835,7 +157465,7 @@ async function buildFromLoaded(preloaded, dest, opts = {}) {
156835
157465
  const descriptor = await res.json();
156836
157466
  bakePinnedLanguage?.(descriptor);
156837
157467
  delete descriptor.etag;
156838
- const lb = logicBundleOf(descriptor);
157468
+ const lb = logicBundleOf2(descriptor);
156839
157469
  const bundleName = lb ? bundleNameFromUrl(lb.url) : null;
156840
157470
  if (collect2?.lint) {
156841
157471
  const bundleJs = bundleName ? readBundle(bundleName) : void 0;
@@ -156876,7 +157506,7 @@ async function buildFromLoaded(preloaded, dest, opts = {}) {
156876
157506
  continue;
156877
157507
  }
156878
157508
  const descriptor = await res.json();
156879
- const lb = logicBundleOf(descriptor);
157509
+ const lb = logicBundleOf2(descriptor);
156880
157510
  const bundleName = lb ? bundleNameFromUrl(lb.url) : null;
156881
157511
  if (bundleName && !bundles[bundleName]) await addressBundle(bundleName);
156882
157512
  const declared = lb?.declaredCapabilities ?? lb?.declared_capabilities;
@@ -156946,7 +157576,7 @@ async function buildFromLoaded(preloaded, dest, opts = {}) {
156946
157576
  assertComponentMinVersions(screenId, descriptor);
156947
157577
  collectNativeComponents(descriptor, requiredNativeComponents);
156948
157578
  let bundleName = null;
156949
- const lb = logicBundleOf(descriptor);
157579
+ const lb = logicBundleOf2(descriptor);
156950
157580
  if (lb) {
156951
157581
  bundleName = bundleNameFromUrl(lb.url);
156952
157582
  if (bundleName) {
@@ -159421,6 +160051,7 @@ async function loadAuthoring() {
159421
160051
  crawlScreenHostile: crawl.crawlScreenHostile,
159422
160052
  crawlScreenRelations: crawl.crawlScreenRelations,
159423
160053
  crawlScreenCapabilitySuccess: crawl.crawlScreenCapabilitySuccess,
160054
+ crawlScreenWebView: crawl.crawlScreenWebView,
159424
160055
  findingKey: crawl.findingKey,
159425
160056
  startWorkerCoverage: cov.startWorkerCoverage,
159426
160057
  uncoveredFunctions: cov.uncoveredFunctions,
@@ -170256,7 +170887,7 @@ __export(template_evaluate_exports, {
170256
170887
  evaluatedView: () => evaluatedView,
170257
170888
  templatedLabel: () => templatedLabel
170258
170889
  });
170259
- async function settle(work, what) {
170890
+ async function settle2(work, what) {
170260
170891
  let timer;
170261
170892
  try {
170262
170893
  return await Promise.race([
@@ -170310,18 +170941,18 @@ async function buildTemplated(t2, ctx) {
170310
170941
  const placeholder3 = Array.from({ length: Math.max(1, captureCount(t2.pattern)) }, () => ID_PLACEHOLDER);
170311
170942
  let error;
170312
170943
  try {
170313
- const built = await settle(() => t2.build(ctx, placeholder3), `the templated route ${t2.display}`);
170944
+ const built = await settle2(() => t2.build(ctx, placeholder3), `the templated route ${t2.display}`);
170314
170945
  if (built) return { built };
170315
170946
  } catch (e2) {
170316
170947
  error = message(e2);
170317
170948
  }
170318
170949
  if (typeof t2.seedIds === "function") {
170319
170950
  try {
170320
- const ids2 = await settle(() => t2.seedIds(ctx), `seedIds of ${t2.display}`);
170951
+ const ids2 = await settle2(() => t2.seedIds(ctx), `seedIds of ${t2.display}`);
170321
170952
  for (const id of Array.isArray(ids2) ? ids2.slice(0, 20) : []) {
170322
170953
  const m2 = typeof id === "string" ? t2.pattern.exec(id) : null;
170323
170954
  if (!m2) continue;
170324
- const built = await settle(() => t2.build(ctx, m2.slice(1)), `the templated route ${t2.display}`);
170955
+ const built = await settle2(() => t2.build(ctx, m2.slice(1)), `the templated route ${t2.display}`);
170325
170956
  if (built) return { built };
170326
170957
  }
170327
170958
  } catch (e2) {
@@ -170344,7 +170975,7 @@ async function evaluatedView(dir) {
170344
170975
  const routes = [];
170345
170976
  for (const [id, build3] of Object.entries(m2.screens?.exact ?? {})) {
170346
170977
  try {
170347
- const built = await settle(() => build3(ctx), `the screen ${id}`);
170978
+ const built = await settle2(() => build3(ctx), `the screen ${id}`);
170348
170979
  routes.push(built ? row(id, "screen", built) : row(id, "screen", void 0, "the builder returned no descriptor"));
170349
170980
  } catch (e2) {
170350
170981
  routes.push(row(id, "screen", void 0, message(e2)));
@@ -190801,6 +191432,8 @@ async function runCrawl(opts) {
190801
191432
  const bundleOf = new Map(descriptors.map((d2) => [d2.screenId, d2]));
190802
191433
  const hostileFindings = [];
190803
191434
  const relationFindings = [];
191435
+ const webviewFindings = [];
191436
+ const webviewScreens = [];
190804
191437
  let relationsChecked = 0;
190805
191438
  let capabilityModelled = 0;
190806
191439
  const capabilityCoverageByScreen = [];
@@ -190933,6 +191566,14 @@ async function runCrawl(opts) {
190933
191566
  }
190934
191567
  }
190935
191568
  }
191569
+ if (deps.crawlScreenWebView && baked.bundleJs) {
191570
+ const wr2 = await deps.crawlScreenWebView({ ...args, ...opts.webviewPages ? { webviewPages: opts.webviewPages } : {} });
191571
+ if (wr2) {
191572
+ const { findings: wf2, ...row2 } = wr2;
191573
+ webviewFindings.push(...wf2);
191574
+ webviewScreens.push(row2);
191575
+ }
191576
+ }
190936
191577
  await finishScreenCoverage();
190937
191578
  }
190938
191579
  const keep = (f2) => {
@@ -191045,7 +191686,7 @@ async function runCrawl(opts) {
191045
191686
  message: issue3.message,
191046
191687
  hint: "Fix the value in the tokens file; `himi validate` reports the same finding."
191047
191688
  }));
191048
- const all = [...results.flatMap((r3) => r3.findings), ...hostileFindings, ...deepFindings, ...journeyFindings, ...edgeFindings, ...relationFindings, ...writeFindings, ...tokenFindings].filter((f2) => {
191689
+ const all = [...results.flatMap((r3) => r3.findings), ...hostileFindings, ...deepFindings, ...journeyFindings, ...edgeFindings, ...relationFindings, ...webviewFindings, ...writeFindings, ...tokenFindings].filter((f2) => {
191049
191690
  if (f2.invariant === "no-request-issued" && !f2.axis && fetchProven.has(f2.screen)) {
191050
191691
  const by = fetchProven.get(f2.screen);
191051
191692
  if (!retired.some((x2) => x2.screen === f2.screen)) retired.push({ screen: f2.screen, from: by.from, params: by.params });
@@ -191089,6 +191730,7 @@ async function runCrawl(opts) {
191089
191730
  failures,
191090
191731
  warnings,
191091
191732
  unverifiable: results.flatMap((r3) => r3.unverifiable),
191733
+ ...webviewScreens.length ? { webview: webviewScreens } : {},
191092
191734
  ...suppressed.length ? { suppressed } : {},
191093
191735
  ...unknownScreens.length ? { unknownScreens } : {},
191094
191736
  ...notCrawled.length ? { notCrawled } : {},
@@ -191197,12 +191839,40 @@ function formatReport(r3) {
191197
191839
  out2.push(" not verifiable headless (verify on the pushed preview or a sim):");
191198
191840
  for (const [screen, nodes2] of [...unverifiableByScreen].sort(([a3], [b3]) => a3.localeCompare(b3))) {
191199
191841
  for (const n2 of nodes2) {
191200
- const why = n2.why === "native-only" ? "native-only \u2014 does not paint in a web render, but DOES render on device" : "renders blank on device when bound (known renderer gap)";
191842
+ const bridged = n2.type === "WebView" && r3.webview?.some((w2) => w2.screen === screen);
191843
+ const why = n2.why === "native-only" ? bridged ? r3.webview?.some((w2) => w2.screen === screen && w2.loaded?.length) ? "native-only \u2014 pixels not judged; the page WAS loaded in a browser against its worker (see WebView bridge)" : "native-only \u2014 the page was not loaded; its worker channel WAS played (see WebView bridge)" : "native-only \u2014 does not paint in a web render, but DOES render on device" : "renders blank on device when bound (known renderer gap)";
191201
191844
  out2.push(` ${screen} ${n2.node} ${why}`);
191202
191845
  }
191203
191846
  }
191204
191847
  out2.push("");
191205
191848
  }
191849
+ if (r3.webview?.length) {
191850
+ out2.push(" WebView bridge \u2014 the crawl played each bridged page's side of the worker channel:");
191851
+ for (const w2 of [...r3.webview].sort((a3, b3) => a3.screen.localeCompare(b3.screen))) {
191852
+ const pages2 = w2.pages.map((p2) => p2.node === "(screen)" ? "the screen's page" : p2.node).join(", ");
191853
+ if (!w2.pages.length) {
191854
+ out2.push(` ${w2.screen} ${w2.templatePages} bridged WebView(s) in item templates \u2014 not played (one channel per row, keyed by row data)`);
191855
+ continue;
191856
+ }
191857
+ if (!w2.listening) {
191858
+ out2.push(` ${w2.screen} ${pages2}: the worker never listens on the page channel`);
191859
+ continue;
191860
+ }
191861
+ const surface = Object.entries(w2.manifest ?? {}).map(([ns2, ms2]) => `${ns2}.{${ms2.join(",")}}`).join(" ") || "(raw onPageMessage only)";
191862
+ const byOutcome = /* @__PURE__ */ new Map();
191863
+ for (const c2 of w2.calls) byOutcome.set(c2.outcome, (byOutcome.get(c2.outcome) ?? 0) + 1);
191864
+ const answered3 = [...byOutcome].map(([o2, n2]) => `${n2} ${o2}`).join(", ") || "no calls";
191865
+ out2.push(` ${w2.screen} ${pages2}: ${surface}`);
191866
+ out2.push(` ${w2.calls.length} method(s) called as the page \u2014 ${answered3}; ${w2.probes.sent} hostile message(s), ${w2.probes.threw} threw${w2.events.length ? `; events seen: ${w2.events.join(", ")}` : ""}`);
191867
+ if (w2.templatePages) out2.push(` ${w2.templatePages} bridged WebView(s) in item templates not played (one channel per row)`);
191868
+ for (const l3 of w2.loaded ?? []) {
191869
+ const calls = l3.calls.map((c2) => `${c2.capability}.${c2.method}\u2192${c2.outcome}${c2.code ? `(${c2.code})` : ""}`).join(", ") || "no calls";
191870
+ out2.push(` page ${l3.node === "(screen)" ? "(screen)" : l3.node} loaded (${l3.source}): ${calls}; ${l3.pageErrors.length} uncaught error(s), ${l3.consoleErrors} console error(s), ${l3.links.total} link(s)${l3.links.offAllowlist ? ` (${l3.links.offAllowlist} off the allowlist)` : ""}${l3.blockedRequests ? `; ${l3.blockedRequests} network request(s) refused (hermetic; --webview-live allows them)` : ""}`);
191871
+ }
191872
+ for (const n2 of w2.notLoaded ?? []) out2.push(` page ${n2.node} not loaded: ${n2.why}`);
191873
+ }
191874
+ out2.push("");
191875
+ }
191206
191876
  if (r3.writes?.length || r3.unreachedWrites?.length) {
191207
191877
  out2.push(` Writes to Wix (${r3.writes.length}) \u2014 every write the crawl saw a worker attempt (none reached Wix). A write behind a form or a selection shows only under --deep or a journey:`);
191208
191878
  const byScreenW = /* @__PURE__ */ new Map();
@@ -229209,9 +229879,9 @@ async function startConnectServer(opts) {
229209
229879
  const token = randomBytes17(16).toString("hex");
229210
229880
  const prefix = `/c/${token}`;
229211
229881
  const startedAt = now();
229212
- let settle2;
229882
+ let settle3;
229213
229883
  const done = new Promise((resolve130) => {
229214
- settle2 = resolve130;
229884
+ settle3 = resolve130;
229215
229885
  });
229216
229886
  let closed;
229217
229887
  let hostHeader = "";
@@ -229251,7 +229921,7 @@ async function startConnectServer(opts) {
229251
229921
  }
229252
229922
  if (closing || !busy2 && now() - startedAt > ttlMs) {
229253
229923
  await send2(res, 410, "This page has expired.", false);
229254
- settle2("expired");
229924
+ settle3("expired");
229255
229925
  void close();
229256
229926
  return;
229257
229927
  }
@@ -229286,7 +229956,7 @@ async function startConnectServer(opts) {
229286
229956
  consumed = true;
229287
229957
  await send2(res, out2.status, out2.html);
229288
229958
  if (out2.done) {
229289
- settle2("done");
229959
+ settle3("done");
229290
229960
  void close();
229291
229961
  }
229292
229962
  } catch (err) {
@@ -229304,7 +229974,7 @@ async function startConnectServer(opts) {
229304
229974
  if (holding) {
229305
229975
  busy2 = false;
229306
229976
  if (expireWhenIdle && !consumed) {
229307
- settle2("expired");
229977
+ settle3("expired");
229308
229978
  void close();
229309
229979
  }
229310
229980
  }
@@ -229330,12 +230000,12 @@ async function startConnectServer(opts) {
229330
230000
  if (busy2) {
229331
230001
  expireWhenIdle = true;
229332
230002
  grace = setTimeout(() => {
229333
- settle2(consumed ? "done" : "expired");
230003
+ settle3(consumed ? "done" : "expired");
229334
230004
  void close();
229335
230005
  }, graceMs);
229336
230006
  grace.unref();
229337
230007
  } else {
229338
- settle2("expired");
230008
+ settle3("expired");
229339
230009
  void close();
229340
230010
  }
229341
230011
  }, ttlMs);
@@ -229346,7 +230016,7 @@ async function startConnectServer(opts) {
229346
230016
  clearTimeout(timer);
229347
230017
  if (grace)
229348
230018
  clearTimeout(grace);
229349
- settle2("expired");
230019
+ settle3("expired");
229350
230020
  server.close(() => resolve130());
229351
230021
  server.closeAllConnections();
229352
230022
  });
@@ -229529,7 +230199,7 @@ async function runConnectFlow(opts) {
229529
230199
  return { ...show2(), done: true };
229530
230200
  };
229531
230201
  const fail16 = (reason) => finish3({ status: "failed", reason, ...refusal2 ? { signinRefusal: refusal2 } : {} });
229532
- async function settle2(attempt2) {
230202
+ async function settle3(attempt2) {
229533
230203
  await attempt2.next();
229534
230204
  if (over) {
229535
230205
  attempt2.cancel();
@@ -229581,7 +230251,7 @@ async function runConnectFlow(opts) {
229581
230251
  log(`Signing in ${appleId}`);
229582
230252
  const attempt2 = begin({ appleId, password, sms, phoneId, previous, base: base2 });
229583
230253
  password = "";
229584
- return settle2(attempt2);
230254
+ return settle3(attempt2);
229585
230255
  }
229586
230256
  async function onCode(st2, form) {
229587
230257
  if (form.get("method") === "sms") {
@@ -229593,7 +230263,7 @@ async function runConnectFlow(opts) {
229593
230263
  await attempt2.next();
229594
230264
  const next = begin({ appleId: attempt2.appleId, password, sms: true, previous: attempt2.previous, base: base2 });
229595
230265
  password = "";
229596
- return settle2(next);
230266
+ return settle3(next);
229597
230267
  }
229598
230268
  const code2 = (form.get("code") ?? "").replace(/\s+/g, "");
229599
230269
  form.delete("code");
@@ -229602,7 +230272,7 @@ async function runConnectFlow(opts) {
229602
230272
  return show2();
229603
230273
  }
229604
230274
  st2.attempt.answer(code2);
229605
- return settle2(st2.attempt);
230275
+ return settle3(st2.attempt);
229606
230276
  }
229607
230277
  async function signedIn(session) {
229608
230278
  if (over)
@@ -232858,7 +233528,7 @@ async function recordAccepted(inv) {
232858
233528
  await store.markAccepted(hash3, `the published agreement; the portal shows ${accepted.id} accepted on ${accepted.accepted}`);
232859
233529
  return { hash: hash3 };
232860
233530
  }
232861
- var createHash68, mkdir19, readFile20, writeFile15, join131, PROBES, SLUG, AgreementCache, cache3, webClient, AGREEMENT_COMMANDS;
233531
+ var createHash68, mkdir19, readFile20, writeFile15, join131, PROBES2, SLUG, AgreementCache, cache3, webClient, AGREEMENT_COMMANDS;
232862
233532
  var init_commands_agreements = __esm({
232863
233533
  "../../node_modules/@wix/asc/dist/commands-agreements.js"() {
232864
233534
  init_define_HHP_CATALOG();
@@ -232869,7 +233539,7 @@ var init_commands_agreements = __esm({
232869
233539
  ({ createHash: createHash68 } = __ascBuiltin068);
232870
233540
  ({ mkdir: mkdir19, readFile: readFile20, writeFile: writeFile15 } = __ascBuiltin144);
232871
233541
  ({ join: join131 } = __ascBuiltin223);
232872
- PROBES = [
233542
+ PROBES2 = [
232873
233543
  { capability: "apps, versions, metadata, builds, TestFlight, submissions", path: "/v1/apps", query: { limit: "1" } },
232874
233544
  { capability: "certificates, provisioning profiles, bundle IDs, devices", path: "/v1/certificates", query: { limit: "1" } },
232875
233545
  { capability: "in-app purchases, subscriptions, pricing", path: (id) => `/v1/apps/${id}/inAppPurchasesV2`, query: { limit: "1" }, needsApp: true }
@@ -232928,7 +233598,7 @@ var init_commands_agreements = __esm({
232928
233598
  let appId3;
232929
233599
  const rows = [];
232930
233600
  const blocking = /* @__PURE__ */ new Map();
232931
- for (const probe2 of PROBES) {
233601
+ for (const probe2 of PROBES2) {
232932
233602
  if (probe2.needsApp) {
232933
233603
  appId3 ??= inv.opts.app ? (await api4.apps.find(String(inv.opts.app))).id : void 0;
232934
233604
  if (!appId3) {
@@ -234434,8 +235104,8 @@ import * as __ascBuiltin146 from "node:http";
234434
235104
  async function startCallback(timeoutMs) {
234435
235105
  const path2 = `/callback/${b64url3(randomBytes18(16))}`;
234436
235106
  let expected;
234437
- let settle2;
234438
- const result = new Promise((resolve130, reject) => settle2 = { resolve: resolve130, reject });
235107
+ let settle3;
235108
+ const result = new Promise((resolve130, reject) => settle3 = { resolve: resolve130, reject });
234439
235109
  result.catch(() => {
234440
235110
  });
234441
235111
  const page = (status2, text32) => ({ status: status2, body: `<!doctype html><meta charset="utf-8"><title>asc-node</title><p>${text32}</p>` });
@@ -234457,14 +235127,14 @@ async function startCallback(timeoutMs) {
234457
235127
  const code2 = url.searchParams.get("code");
234458
235128
  if (error || !code2) {
234459
235129
  send2(page(400, "Sign-in did not finish. You can close this tab."));
234460
- return settle2.reject(new AscError("auth", `sign-in was not completed (${error ?? "no code"})`));
235130
+ return settle3.reject(new AscError("auth", `sign-in was not completed (${error ?? "no code"})`));
234461
235131
  }
234462
235132
  send2(page(200, "Signed in. You can close this tab and go back to the terminal."));
234463
- settle2.resolve(code2);
235133
+ settle3.resolve(code2);
234464
235134
  });
234465
235135
  await new Promise((resolve130) => server.listen(0, "127.0.0.1", resolve130));
234466
235136
  const port = server.address().port;
234467
- const timer = setTimeout(() => settle2.reject(new AscError("auth", `sign-in to the worker's gateway was not finished within ${Math.round(timeoutMs / 1e3)}s`)), timeoutMs);
235137
+ const timer = setTimeout(() => settle3.reject(new AscError("auth", `sign-in to the worker's gateway was not finished within ${Math.round(timeoutMs / 1e3)}s`)), timeoutMs);
234468
235138
  timer.unref?.();
234469
235139
  return {
234470
235140
  redirect: `http://127.0.0.1:${port}${path2}`,
@@ -244684,10 +245354,10 @@ function deriveRequirements(evidenceDir) {
244684
245354
  }
244685
245355
  }
244686
245356
  for (const page of screen.pages) {
244687
- const pageSource = `${screen.pointer}/layout/items/${page.arrayIndex}`;
244688
- add("route", pageSource, `Page ${page.title ?? page.layoutItemId}${obj7(page.settings).hideFromNavigation === true ? " (hidden)" : ""}`, void 0, page.layoutItemId);
244689
- access3(`${pageSource}/permissions`, page.permissions);
244690
- access3(`${pageSource}/settings`, visibilitySettings(page.settings));
245357
+ const pageSource2 = `${screen.pointer}/layout/items/${page.arrayIndex}`;
245358
+ add("route", pageSource2, `Page ${page.title ?? page.layoutItemId}${obj7(page.settings).hideFromNavigation === true ? " (hidden)" : ""}`, void 0, page.layoutItemId);
245359
+ access3(`${pageSource2}/permissions`, page.permissions);
245360
+ access3(`${pageSource2}/settings`, visibilitySettings(page.settings));
244691
245361
  for (const item2 of page.placements) placement(item2);
244692
245362
  }
244693
245363
  const topBarButton = (button, pointer3, platform) => {
@@ -246238,6 +246908,139 @@ var init_coverage2 = __esm({
246238
246908
  }
246239
246909
  });
246240
246910
 
246911
+ // ../../core/sdk/webview-page/src/page-client.generated.ts
246912
+ var PAGE_CLIENT_SOURCE;
246913
+ var init_page_client_generated = __esm({
246914
+ "../../core/sdk/webview-page/src/page-client.generated.ts"() {
246915
+ init_define_HHP_CATALOG();
246916
+ PAGE_CLIENT_SOURCE = '(function () {\nvar __himalayaPageClientModule = (() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropDesc = Object.getOwnPropertyDescriptor;\n var __getOwnPropNames = Object.getOwnPropertyNames;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n };\n var __copyProps = (to, from, except, desc) => {\n if (from && typeof from === "object" || typeof from === "function") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n };\n var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);\n\n // src/client.ts\n var client_exports = {};\n __export(client_exports, {\n createPageClient: () => createPageClient\n });\n var TIMEOUT_PREFIX = "Himalaya capability call timed out";\n function pageError(error) {\n const out = new Error(error?.message ?? "Himalaya capability call failed");\n if (error?.code) Object.assign(out, { code: error.code });\n return out;\n }\n function createPageClient(getBridge) {\n const pending = /* @__PURE__ */ new Map();\n const abandoned = /* @__PURE__ */ new Set();\n const streams = /* @__PURE__ */ new Map();\n const listeners = /* @__PURE__ */ new Map();\n let installedOn;\n let nextId = 1;\n const clientTag = Math.random().toString(36).slice(2, 10) || "0";\n function workerBridge() {\n const bridge = getBridge();\n if (!bridge || typeof bridge.post !== "function" || typeof bridge.onMessage !== "function") {\n throw new Error(\n "@himalaya/webview-page: this page is not inside a worker-backed Himalaya WebView."\n );\n }\n if (installedOn !== bridge) {\n bridge.onMessage(receive);\n installedOn = bridge;\n }\n return bridge;\n }\n function receive(message) {\n if (!message || typeof message !== "object" || message.v !== 1) return;\n const m = message;\n if (typeof m.id === "string" && typeof m.ok === "boolean") return respond(m);\n if (typeof m.ev === "string" && typeof m.ns === "string") return emit(m);\n if (typeof m.sid === "string") return feed(m);\n }\n function respond(message) {\n const call2 = pending.get(message.id);\n if (!call2) {\n if (abandoned.delete(message.id) && message.ok && message.stream === true) cancelStream(message.id);\n return;\n }\n pending.delete(message.id);\n clearTimeout(call2.timeout);\n if (!message.ok) return call2.reject(pageError(message.error));\n if (message.stream === true) return call2.resolve(openStream(message.id));\n call2.resolve(message.result);\n }\n function emit(event) {\n const handlers = listeners.get(event.ns)?.get(event.ev);\n if (!handlers) return;\n for (const handler of [...handlers]) {\n try {\n handler(event.data);\n } catch {\n }\n }\n }\n function feed(envelope) {\n const state = streams.get(envelope.sid);\n if (!state) return;\n if (!("chunk" in envelope) && !("end" in envelope && envelope.end === true) && !("error" in envelope && envelope.error)) return;\n if ("chunk" in envelope) {\n const waiter = state.waiters.shift();\n if (waiter) waiter.resolve({ value: envelope.chunk, done: false });\n else state.queue.push(envelope.chunk);\n return;\n }\n streams.delete(envelope.sid);\n if ("error" in envelope && envelope.error) {\n state.error = pageError(envelope.error);\n if (state.waiters.length > 0) {\n for (const waiter of state.waiters.splice(0)) waiter.reject(state.error);\n state.error = void 0;\n state.done = true;\n }\n } else if ("end" in envelope && envelope.end === true) {\n state.done = true;\n for (const waiter of state.waiters.splice(0)) waiter.resolve({ value: void 0, done: true });\n }\n }\n function cancelStream(sid) {\n try {\n installedOn?.post({ v: 1, sys: "cancel", sid });\n } catch {\n }\n }\n function openStream(sid) {\n const state = { queue: [], waiters: [], done: false, error: void 0 };\n streams.set(sid, state);\n const iterator = {\n next() {\n if (state.queue.length > 0) return Promise.resolve({ value: state.queue.shift(), done: false });\n if (state.error) {\n const error = state.error;\n state.error = void 0;\n state.done = true;\n return Promise.reject(error);\n }\n if (state.done) return Promise.resolve({ value: void 0, done: true });\n return new Promise((resolve, reject) => state.waiters.push({ resolve, reject }));\n },\n return() {\n if (streams.get(sid) === state) {\n streams.delete(sid);\n cancelStream(sid);\n }\n state.done = true;\n state.queue.length = 0;\n for (const waiter of state.waiters.splice(0)) waiter.resolve({ value: void 0, done: true });\n return Promise.resolve({ value: void 0, done: true });\n }\n };\n return { [Symbol.asyncIterator]: () => iterator };\n }\n function call(capability, method, args = [], timeoutMs = 3e4) {\n const bridge = workerBridge();\n const id = `page-${Date.now().toString(36)}-${clientTag}-${nextId++}`;\n const request = { v: 1, id, capability, method, args };\n return new Promise((resolve, reject) => {\n const timeout = setTimeout(() => {\n pending.delete(id);\n abandoned.add(id);\n if (abandoned.size > 256) abandoned.delete(abandoned.values().next().value);\n reject(new Error(`${TIMEOUT_PREFIX}: ${capability}.${method}`));\n }, timeoutMs);\n pending.set(id, { resolve, reject, timeout });\n if (!bridge.post(request)) {\n clearTimeout(timeout);\n pending.delete(id);\n reject(new Error("@himalaya/webview-page: the native page-to-worker bridge refused the request."));\n }\n });\n }\n function on(namespace2, event, handler) {\n workerBridge();\n if (typeof handler !== "function") throw new Error("@himalaya/webview-page: on() needs a handler function");\n let byEvent = listeners.get(namespace2);\n if (!byEvent) listeners.set(namespace2, byEvent = /* @__PURE__ */ new Map());\n let handlers = byEvent.get(event);\n if (!handlers) byEvent.set(event, handlers = /* @__PURE__ */ new Set());\n const entry = (data) => handler(data);\n handlers.add(entry);\n return () => {\n handlers.delete(entry);\n };\n }\n let manifest;\n function currentBridge() {\n try {\n return workerBridge();\n } catch {\n return void 0;\n }\n }\n function timedOut(error) {\n return error instanceof Error && error.message.startsWith(TIMEOUT_PREFIX);\n }\n let asking;\n function askShared(target, budget) {\n const until = Date.now() + budget;\n if (asking?.on === target) {\n asking.until = Math.max(asking.until, until);\n return asking.answer;\n }\n const state = { on: target, until, answer: Promise.resolve(null) };\n asking = state;\n state.answer = new Promise((resolve) => {\n let done = false;\n const finish = (list) => {\n if (done) return;\n done = true;\n clearInterval(again);\n if (asking === state) asking = void 0;\n if (list) manifest = { on: target, list };\n resolve(list);\n };\n const ask = () => {\n if (done) return;\n const left = state.until - Date.now();\n if (left <= 0 || currentBridge() !== target) return finish(null);\n call("himalaya", "capabilities", [], Math.max(1, Math.min(2e3, left))).then(\n (reply) => finish(reply?.capabilities ?? null),\n // A timed-out question is not an answer; the deadline decides. Anything else is final.\n (error) => {\n if (!timedOut(error)) finish(null);\n }\n );\n };\n const again = setInterval(ask, 500);\n ask();\n });\n return state.answer;\n }\n async function enabledCapabilities(timeoutMs = 3e3) {\n const bridge = currentBridge();\n if (!bridge) return null;\n if (manifest?.on === bridge) return manifest.list;\n if (!(timeoutMs > 0)) return null;\n const budget = Math.min(timeoutMs, 2147483647);\n const answer = askShared(bridge, budget);\n return new Promise((resolve) => {\n const stop = setTimeout(() => resolve(manifest?.on === bridge ? manifest.list : null), budget);\n void answer.then((list) => {\n clearTimeout(stop);\n resolve(list);\n });\n });\n }\n async function isEnabled(capability, method, timeoutMs = 3e3) {\n const enabled = await enabledCapabilities(timeoutMs);\n return enabled?.[capability]?.includes(method) ?? false;\n }\n async function probe(capability, method, args = [], timeoutMs = 3e3) {\n if (!currentBridge()) return false;\n try {\n const result = await call(capability, method, args, timeoutMs);\n const iterate = result?.[Symbol.asyncIterator];\n if (typeof iterate === "function") void iterate.call(result).return?.();\n return true;\n } catch (error) {\n if (error.code === "unknown_method") return false;\n return !(timedOut(error) || /refused the request/.test(error.message));\n }\n }\n const members = /* @__PURE__ */ new Map();\n function pageMember(capability, path) {\n const key = `${capability}:${path.join(".")}`;\n let member = members.get(key);\n if (member) return member;\n const label = `[himalaya.${[capability, ...path].join(".")}]`;\n member = new Proxy((() => {\n }), {\n get(_target, property) {\n if (typeof property !== "string" || property === "then") return void 0;\n if (property === "toString" || property === "valueOf") return () => label;\n if (path.length === 0 && property === "on") {\n return (event, handler) => on(capability, event, handler);\n }\n return pageMember(capability, [...path, property]);\n },\n apply(_target, _thisArg, args) {\n if (path.length === 0) throw new Error(`Himalaya capability namespace is not callable: ${capability}`);\n return call(capability, path.join("."), args);\n }\n });\n members.set(key, member);\n return member;\n }\n const namespace = (capability) => pageMember(capability, []);\n const SITE_FIELDS = ["title", "route", "cart", "member"];\n const site = Object.freeze({\n report(fields) {\n const bridge = currentBridge();\n if (!bridge || !fields || typeof fields !== "object") return false;\n const data = {};\n for (const name of SITE_FIELDS) {\n if (Object.prototype.hasOwnProperty.call(fields, name)) data[name] = fields[name];\n }\n if (Object.keys(data).length === 0) return false;\n try {\n return bridge.post({ v: 1, sys: "site", ev: "report", data }) === true;\n } catch {\n return false;\n }\n }\n });\n function merge(target) {\n const own = { call, on, enabledCapabilities, isEnabled, probe, site, version: 1 };\n for (const name of Object.keys(own)) {\n if (!Object.prototype.hasOwnProperty.call(target, name)) {\n Object.defineProperty(target, name, { value: own[name], enumerable: true, writable: false, configurable: false });\n }\n }\n Object.freeze(target);\n return new Proxy(target, {\n get(t, property, receiver) {\n if (typeof property !== "string" || property in t) return Reflect.get(t, property, receiver);\n if (property === "then") return void 0;\n return namespace(property);\n }\n });\n }\n return { call, on, enabledCapabilities, isEnabled, probe, namespace, site, merge };\n }\n return __toCommonJS(client_exports);\n})();\nreturn __himalayaPageClientModule.createPageClient;\n})()';
246917
+ }
246918
+ });
246919
+
246920
+ // ../../core/dev-server/src/webview-page-driver.ts
246921
+ var webview_page_driver_exports = {};
246922
+ __export(webview_page_driver_exports, {
246923
+ INLINE_PAGE_ORIGIN: () => INLINE_PAGE_ORIGIN,
246924
+ createWebViewPageDriver: () => createWebViewPageDriver,
246925
+ pageShimSource: () => pageShimSource
246926
+ });
246927
+ function pageShimSource() {
246928
+ return `(function () {
246929
+ var cbs = [];
246930
+ var worker = Object.freeze({
246931
+ onMessage: function (cb) { if (typeof cb === 'function') cbs.push(cb); },
246932
+ post: function (msg) {
246933
+ try { window.${POST_BINDING}(JSON.stringify(msg)); return true; } catch (e) { return false; }
246934
+ },
246935
+ __deliver: function (msg) { cbs.forEach(function (cb) { try { cb(msg); } catch (e) {} }); }
246936
+ });
246937
+ Object.defineProperty(window, 'HimalayaWorker', { value: worker, writable: false, configurable: false, enumerable: true });
246938
+ var createPageClient = ${PAGE_CLIENT_SOURCE};
246939
+ var himalaya = createPageClient(function () { return worker; }).merge({});
246940
+ Object.defineProperty(window, 'himalaya', { value: himalaya, writable: false, configurable: false, enumerable: true });
246941
+ })();`;
246942
+ }
246943
+ async function createWebViewPageDriver() {
246944
+ const launched = await launchPngBrowser();
246945
+ if (!launched) return null;
246946
+ const shim = pageShimSource();
246947
+ return {
246948
+ close: () => launched.close(),
246949
+ async open(spec) {
246950
+ const context = await launched.browser.newContext({ viewport: { width: 390, height: 844 }, serviceWorkers: "block" });
246951
+ const page = await context.newPage();
246952
+ const pageErrors = [];
246953
+ const consoleErrors = [];
246954
+ let loadError;
246955
+ page.on("pageerror", (e2) => pageErrors.push(String(e2?.message ?? e2)));
246956
+ page.on("console", (m2) => {
246957
+ if (m2.type() === "error") consoleErrors.push(m2.text());
246958
+ });
246959
+ await page.exposeBinding(POST_BINDING, (_source, json9) => {
246960
+ if (typeof json9 !== "string") return;
246961
+ let msg;
246962
+ try {
246963
+ msg = JSON.parse(json9);
246964
+ } catch {
246965
+ return;
246966
+ }
246967
+ spec.toWorker(msg);
246968
+ });
246969
+ await page.addInitScript({ content: shim });
246970
+ const target = spec.html !== void 0 ? `${INLINE_PAGE_ORIGIN}/` : spec.url;
246971
+ let blockedRequests = 0;
246972
+ let requests = 0;
246973
+ page.on("request", () => {
246974
+ requests++;
246975
+ });
246976
+ const html = spec.html;
246977
+ await page.route("**/*", (route) => {
246978
+ const url = route.request().url();
246979
+ if (html !== void 0 && url === target) return route.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: html });
246980
+ if (url.startsWith(`${INLINE_PAGE_ORIGIN}/`)) return route.fulfill({ status: 404, body: "" });
246981
+ if (spec.network || url.startsWith("data:") || url.startsWith("blob:")) return route.continue();
246982
+ blockedRequests++;
246983
+ return route.abort("blockedbyclient");
246984
+ });
246985
+ try {
246986
+ await page.goto(target, { waitUntil: "load", timeout: Math.max(1e3, spec.budgetMs) });
246987
+ } catch (e2) {
246988
+ loadError = String(e2?.message ?? e2).split("\n")[0];
246989
+ }
246990
+ const started = Date.now();
246991
+ return {
246992
+ async deliver(msg) {
246993
+ await page.evaluate((m2) => {
246994
+ globalThis.HimalayaWorker.__deliver(m2);
246995
+ }, msg);
246996
+ },
246997
+ async settle(bridgeActivity) {
246998
+ const activity = () => bridgeActivity() + requests;
246999
+ let last = activity();
247000
+ let quietSince = Date.now();
247001
+ while (Date.now() - started < spec.budgetMs) {
247002
+ await new Promise((r3) => setTimeout(r3, 100));
247003
+ const now = activity();
247004
+ if (now !== last) {
247005
+ last = now;
247006
+ quietSince = Date.now();
247007
+ continue;
247008
+ }
247009
+ if (Date.now() - quietSince >= 400) break;
247010
+ }
247011
+ },
247012
+ async report() {
247013
+ let links = [];
247014
+ if (!loadError) {
247015
+ try {
247016
+ links = await page.evaluate(() => {
247017
+ const doc = globalThis.document;
247018
+ return Array.from(doc.querySelectorAll("a[href]")).map((a3) => a3.href);
247019
+ });
247020
+ } catch {
247021
+ }
247022
+ }
247023
+ return { ...loadError ? { loadError } : {}, pageErrors, consoleErrors, links, blockedRequests };
247024
+ },
247025
+ async close() {
247026
+ await context.close().catch(() => {
247027
+ });
247028
+ }
247029
+ };
247030
+ }
247031
+ };
247032
+ }
247033
+ var INLINE_PAGE_ORIGIN, POST_BINDING;
247034
+ var init_webview_page_driver = __esm({
247035
+ "../../core/dev-server/src/webview-page-driver.ts"() {
247036
+ init_define_HHP_CATALOG();
247037
+ init_render_descriptor();
247038
+ init_page_client_generated();
247039
+ INLINE_PAGE_ORIGIN = "https://webview.himi-test.invalid";
247040
+ POST_BINDING = "__himiTestWorkerPost";
247041
+ }
247042
+ });
247043
+
246241
247044
  // src/commands/render.ts
246242
247045
  import { readFileSync as readFileSync137 } from "node:fs";
246243
247046
  import { join as join150, resolve as resolve95 } from "node:path";
@@ -280807,7 +281610,7 @@ function nativeCapture(devices, opts) {
280807
281610
  if (SYSTEM_WINDOW.test(focus) || owner !== void 0 && owner !== player) return `a system window covered the Player (${focus})`;
280808
281611
  return "";
280809
281612
  }
280810
- async function settle2(platform, id, file2, notFrame) {
281613
+ async function settle3(platform, id, file2, notFrame) {
280811
281614
  let previous;
280812
281615
  let why = "the screen did not stop changing";
280813
281616
  for (let waited = 0; ; waited += settleMs) {
@@ -280848,15 +281651,15 @@ function nativeCapture(devices, opts) {
280848
281651
  await apply2(platform, id, variant);
280849
281652
  await open6(platform, id, `himi://app/${encodeURIComponent(picker)}`);
280850
281653
  const file2 = join207(outDir, `${screen}.${variant}.${platform}.png`);
280851
- const pickerFrame = (await settle2(platform, id, file2)).frame;
281654
+ const pickerFrame = (await settle3(platform, id, file2)).frame;
280852
281655
  await open6(platform, id, screenLink(opts.appId, screen, entry, opts.release));
280853
- const { unsettled } = await settle2(platform, id, file2, pickerFrame);
281656
+ const { unsettled } = await settle3(platform, id, file2, pickerFrame);
280854
281657
  if (unsettled) {
280855
281658
  frames.push({ surface: platform, screen, variant, skipped: { reason: `capture_unsettled: ${unsettled}` } });
280856
281659
  continue;
280857
281660
  }
280858
281661
  if (platform === "android" && await blackFraction(file2) > 0.95) {
280859
- const retry = await settle2(platform, id, file2, pickerFrame);
281662
+ const retry = await settle3(platform, id, file2, pickerFrame);
280860
281663
  if (retry.unsettled) {
280861
281664
  frames.push({ surface: platform, screen, variant, skipped: { reason: `capture_unsettled: ${retry.unsettled}` } });
280862
281665
  continue;
@@ -281781,7 +282584,9 @@ var BOOLEAN_FLAGS = /* @__PURE__ */ new Set([
281781
282584
  "no-frame",
281782
282585
  "resume",
281783
282586
  "site-pages",
281784
- "all-himi"
282587
+ "all-himi",
282588
+ "no-webview-pages",
282589
+ "webview-live"
281785
282590
  ]);
281786
282591
  var SWITCH_FLAGS = new Set([...BOOLEAN_FLAGS].filter((name) => name !== "deep"));
281787
282592
  var SWITCH_CONSEQUENCE = {
@@ -281957,7 +282762,7 @@ var USAGE = `himi \u2014 the Himalaya authoring CLI (remote dev loop)
281957
282762
  type issues warn normally, fail under --strict. When it
281958
282763
  passes after a source change it refreshes the home picture
281959
282764
  (offline render, 30s budget; homePicture: {image} or {skipped})
281960
- himi test [<screenId>\u2026] [--content <dir>] [--net <file>] [--deep [n]] [--record] [--native [ios|android]] [--no-shots] [--offline] [--no-hostile] [--input-evidence] [--json]
282765
+ himi test [<screenId>\u2026] [--content <dir>] [--net <file>] [--deep [n]] [--record] [--native [ios|android]] [--no-shots] [--no-webview-pages] [--webview-live] [--offline] [--no-hostile] [--input-evidence] [--json]
281961
282766
  behavioral crawl \u2014 NO test files: dispatches every action
281962
282767
  your descriptors already declare against the real worker,
281963
282768
  on hermetic data (your mocks -> cms seed rows -> canned
@@ -282863,7 +283668,7 @@ var COMMANDS = [
282863
283668
  { name: "functions", summary: "inspect/invoke server functions and operate durable jobs or schedules", required: "list|describe|openapi|invoke | jobs list|get|cancel|retry|dlq | schedule describe|invoke [--app <a>] [--environment preview|production] [--release <id>]" },
282864
283669
  { name: "eject", summary: "take ownership of a shared flow module (auth|checkout|screens): copies its source into tier5-src/_ejected/ and repoints this package's imports at the copy. The ladder's escape hatch \u2014 for when the factory options cannot express what you need. AFTER EJECTING, CENTRAL FIXES NO LONGER REACH THIS APP, including future corrections to the fail-closed entitlement and confirm-the-session rules. The floor is unaffected: credentials still go only through the native auth actions and money only through the cashier rail.", required: "<auth|checkout|screens> [--content <dir>]" },
282865
283670
  { name: "validate", summary: 'lint the content package (no push): fixed-contract TypeScript checking for tier5-src workers + schema/proto + token refs + component allowlist + $service bindings + strict-enum foot-guns + capability decls + worker boot dry-run + build/compile failures + copied tier5-src/_shared files that differ from this CLI\'s (a `stale-shared` warning, never promoted by --strict; `// himi:forked` in a file skips it). Type issues are advisory warnings normally; --strict promotes them and hygiene warnings to errors. Exit 1 on any error. Off-repo, the CLI supplies its compiler and SDK declarations. A PASSING validate after a source change also refreshes the home picture: exactly `himi render <homeScreenId> --png --mocks --device iphone` (offline, never --live; with recorded data \u2014 dev/net-mocks.json or cms seed rows \u2014 the picture shows it, and without, its postcard calls it an offline preview), run as a child it kills after 30 seconds, writing .himi/shots/<home>.png \u2014 whose own postcard logic then journals "First look at your app" or, after ten minutes of postcard silence, "Still building" \u2014 reported as `homePicture: {image}` (with `postcard` when one was journaled) or `{skipped: <reason>}`, never a failed validate. Skipped for a validate with errors, a home shot already current, CI or a test runner, and code nobody asked to run: a --remote template still unchanged since init.', required: "[--content <dir>] [--strict]" },
282866
- { name: "test", summary: "DERIVED behavioral crawl \u2014 no test files to write. Boots each screen's real worker, replays its onAppear, then dispatches every action site the descriptor already declares (each from a fresh boot) and checks a narrow set of unambiguous invariants: no uncaught throw, never stuck on `loading`, no `$service:` token or NaN/undefined/[object Object] reaching visible text, no binding aimed at state the worker never defines, no nav param silently dropped, no dead nav target. Catches what validate/render cannot \u2014 a WRONG REDUCER passes both with ok:true. Runs the worker in a DEVICE-PARITY sandbox (no setTimeout/setInterval, as on JSC/WebView) so a bundle that would die on device fails here. Crawls on HERMETIC DATA by default \u2014 zero network: the app's own dev/net-mocks.json first (--net <file> overrides), then the config's CMS `seed:` rows, then a canned fixture of frozen real vertical responses shipped with the CLI (exercises code paths, not API-contract truth) \u2014 so the success/mapping path runs, not just the failure UI. Two boot-only HOSTILE passes (every list empty; every request 500) then check the failure/empty day \u2014 corpus-proven, so their findings are errors. NAV EDGES are followed too: every himi.open site ($item params resolved against row 0 of its list, $service against worker state) and worker _nav directive is harvested, and each baked target is booted WITH the params the source sends \u2014 detail screens finally run their content arm; edge findings are errors tagged edge:<source>. --native runs both real native decoders over the exact baked JSON bytes; --native ios or --native android selects one. It is explicit, runs only from a Himalaya SOURCE CHECKOUT (the decoder oracles are that tree's own HimalayaCore Swift package and Gradle harness, which a published install does not ship), and needs the selected local toolchain. From a source checkout, default runs name missing native verdicts in the coverage ledger; elsewhere the ledger stays silent about them rather than offering a remedy you cannot run. --offline strips all data layers (the old reject-all axis); --no-hostile skips the hostile passes. --record (EXPLICIT, never automatic) refreshes dev/net-mocks.json from live reads first: it boots each screen (load + root onAppear ONLY \u2014 nothing the app's own launch would not fire; the tap/action crawl never sees the live transport, and only proven reads \u2014 GET, or read-shaped POST (/query, /search, /list*, \u2026) \u2014 ever reach the wire), freezes the round-trips, then crawls hermetically on the fresh fixture; record against a QA site, not production. --input-evidence --json adds versioned actual typed-input probes and journey receipts bound to the tested release/config/run; these are observations, not required-behavior acceptance or benign-warning waivers. Nodes it cannot judge headless are named, never silently passed. Exit 1 on any error. The CLI carries the authoring runtime off-repo; no per-app SDK install is required. --browser runs the whole loop (build \u2192 extract \u2192 validate \u2192 render \u2192 test) in YOUR browser instead of here, so the source never reaches a pod: it opens one screen's worker + descriptor in a tab, blocks on a loopback callback, and prints the report it posts back. One screen per tab \u2014 name it. --no-open prints the URL rather than launching a browser (SSH); --timeout <ms> bounds the wait, which matters because the page has no execution deadline of its own and an infinite loop in the worker hangs the tab.", required: "[<screenId>\u2026] [--content <dir>] [--net <file>] [--budget <ms>] [--deep [n]] [--record] [--native [ios|android]] [--no-shots] [--offline] [--no-hostile] [--all-screens] [--browser] [--no-open] [--timeout <ms>] [--input-evidence] [--json]" },
283671
+ { name: "test", summary: "DERIVED behavioral crawl \u2014 no test files to write. Boots each screen's real worker, replays its onAppear, then dispatches every action site the descriptor already declares (each from a fresh boot) and checks a narrow set of unambiguous invariants: no uncaught throw, never stuck on `loading`, no `$service:` token or NaN/undefined/[object Object] reaching visible text, no binding aimed at state the worker never defines, no nav param silently dropped, no dead nav target. Catches what validate/render cannot \u2014 a WRONG REDUCER passes both with ok:true. Runs the worker in a DEVICE-PARITY sandbox (no setTimeout/setInterval, as on JSC/WebView) so a bundle that would die on device fails here. Crawls on HERMETIC DATA by default \u2014 zero network: the app's own dev/net-mocks.json first (--net <file> overrides), then the config's CMS `seed:` rows, then a canned fixture of frozen real vertical responses shipped with the CLI (exercises code paths, not API-contract truth) \u2014 so the success/mapping path runs, not just the failure UI. Two boot-only HOSTILE passes (every list empty; every request 500) then check the failure/empty day \u2014 corpus-proven, so their findings are errors. NAV EDGES are followed too: every himi.open site ($item params resolved against row 0 of its list, $service against worker state) and worker _nav directive is harvested, and each baked target is booted WITH the params the source sends \u2014 detail screens finally run their content arm; edge findings are errors tagged edge:<source>. --native runs both real native decoders over the exact baked JSON bytes; --native ios or --native android selects one. It is explicit, runs only from a Himalaya SOURCE CHECKOUT (the decoder oracles are that tree's own HimalayaCore Swift package and Gradle harness, which a published install does not ship), and needs the selected local toolchain. From a source checkout, default runs name missing native verdicts in the coverage ledger; elsewhere the ledger stays silent about them rather than offering a remedy you cannot run. --offline strips all data layers (the old reject-all axis); --no-hostile skips the hostile passes. --record (EXPLICIT, never automatic) refreshes dev/net-mocks.json from live reads first: it boots each screen (load + root onAppear ONLY \u2014 nothing the app's own launch would not fire; the tap/action crawl never sees the live transport, and only proven reads \u2014 GET, or read-shaped POST (/query, /search, /list*, \u2026) \u2014 ever reach the wire), freezes the round-trips, then crawls hermetically on the fresh fixture; record against a QA site, not production. --input-evidence --json adds versioned actual typed-input probes and journey receipts bound to the tested release/config/run; these are observations, not required-behavior acceptance or benign-warning waivers. WEBVIEW PAGES: for every bridge: 'worker' WebView it boots the worker with a device-shaped page channel and plays the page \u2014 the handshake, every exposed capability against declaredCapabilities, every advertised method called once, hostile page input \u2014 and, when the headless browser is installed, loads each inlineHtml page with the native host's HimalayaWorker shim wired to the real worker (--webview-live also loads url pages from the network; --no-webview-pages skips the browser step). Nodes it cannot judge headless are named, never silently passed. Exit 1 on any error. The CLI carries the authoring runtime off-repo; no per-app SDK install is required. --browser runs the whole loop (build \u2192 extract \u2192 validate \u2192 render \u2192 test) in YOUR browser instead of here, so the source never reaches a pod: it opens one screen's worker + descriptor in a tab, blocks on a loopback callback, and prints the report it posts back. One screen per tab \u2014 name it. --no-open prints the URL rather than launching a browser (SSH); --timeout <ms> bounds the wait, which matters because the page has no execution deadline of its own and an infinite loop in the worker hangs the tab.", required: "[<screenId>\u2026] [--content <dir>] [--net <file>] [--budget <ms>] [--deep [n]] [--record] [--native [ios|android]] [--no-shots] [--no-webview-pages] [--webview-live] [--offline] [--no-hostile] [--all-screens] [--browser] [--no-open] [--timeout <ms>] [--input-evidence] [--json]" },
282867
283672
  { name: "ux", summary: "audit or record mobile UX evidence. `audit` checks the public-safe contract, seeded blank acceptance rows, placeholder source copy, app-specific mocks, and iOS/Android audit records. It warns while existing templates migrate; `--strict` promotes missing evidence. `record` stores checks performed on an installed iOS/Android build: `--checks` is required for passed|failed and empty for unavailable, which drove nothing and needs a `--reason` instead. `record` also STAMPS the release it audited (it resolves the id from a build, the same one a push would publish), because an unforced `himi push` of a release with screens refuses when no drive is recorded for THAT release, or when the one that is recorded says `failed` \u2014 the artifact stopped being advice nobody reads (#2955). `unavailable` still satisfies it; only `failed` refuses. An `unavailable` record is the honest close for an agent with no device: `audit` (strict or not) lists it under `disclosedGaps` with a `<platform>-audit-not-run` warning, and `push` names it in `uxNotDriven` \u2014 a disclosed gap, never a pass (#5607).", required: "audit [--content <dir>] [--strict] [--json] | record --content <dir> --platform ios|android --status passed|failed|unavailable [--checks back,keyboard,...] [--reason <text>]" },
282868
283673
  { name: "progress", summary: 'the build JOURNAL an agent keeps for the owner while it works. `himi progress "<what changed>" --step <1-8|name> --image <png>` appends one postcard to .himi/progress.jsonl \u2014 the step is one of the customer journey\'s eight (discover, classify, plan, implement, brand, validate, review, download) \u2014 and COPIES each image, content-addressed, into .himi/history/, because .himi/shots/ is overwritten by every render and cleared by every full `himi test`, so a path into it would later show a different picture than the one the owner was sent. --image repeats. With NO --image, the home screen\'s current shot is attached automatically, only when it is no older than the last source change and not the picture the latest journaled postcard already shows \u2014 and never a shot that landed on loading placeholders, an empty or an error state (.himi/shot-states.json): then the newest home picture of the current source that shows content goes on instead (its .himi/history copy, `imageNote` saying so), or none \u2014 except on the HANDOVER card (`--step review`), where a repeat is the point and it attaches anyway; that card\'s output also names the making-of (`makingOf`, .himi/making-of.html, rebuilt when missing or older than the journal so it ends on this card) and its `next` says to hand it to the owner beside the preview link; `imageAttached` in the output says whether the postcard carries a picture (with `imageNote` saying why not, or which picture went on instead), and `--no-image` sends a text-only postcard. --notify also raises a best-effort desktop notification for an owner who stepped away. A bare `himi progress` prints the journal with the current step and elapsed time \u2014 also how an agent recovers its place after its context was compacted. APPROVALS: `--approve <gate> "<what>"` records one the customer just gave (gates: site-create, connect, private-data, draft, promote, push-signing, qa-build) in .himi/approvals.jsonl, and `--done <gate>` / `--drop <gate>` closes it \u2014 an approval is owed until then, and the chat that held it does not survive a new session. `--brief` prints plain text for a session start: the current step, the last postcard, every open approval, and whether this app\'s agent files are stale \u2014 the SessionStart hook `himi agent-init` installs runs exactly this. The CLI also journals milestones by itself \u2014 the first PNG render of the home screen (for an app a current `himi init` started: once as the template\'s "Starting point" while the source is what init wrote, then once as "First look at your app" after it diverges, Markdown edits not counting; once per app otherwise), a `himi test` crawl whose outcome changed since the last one (its counts or its home picture; an identical re-run writes none, and a repeat names what changed: "The home screen changed since the last crawl." or the changed counts, was \u2192 now), every draft push (with the home picture only when that shot is newer than the last source edit \u2014 otherwise the postcard says why and names `himi render <home> --png`), and ONE rule for a long silence: a successful home `render --png` more than ten minutes after the newest postcard of any kind, with a picture the latest postcard does not show, journals "Still building: here\'s the home screen now." with it (never twice within the window). When a crawl\'s or a draft\'s home picture is the first of an app whose source diverged, "First look at your app" is journaled first, from that shot, once. All are marked `"by": "himi"`; they never move the journey step, carry no link or credential, and step aside (folded out of every reader) when the agent journals the same step or picture within five minutes. Local only: nothing is sent anywhere.', required: '["<message>" [--step <1-8|name>] [--image <png>]\u2026 [--no-image] [--notify]] [--content <dir>] | --approve|--done|--drop <gate> ["<note>"] | --brief' },
282869
283674
  { name: "studio", summary: "open the BUILD BOARD \u2014 one local page the owner can leave open while an agent builds their app, which fills itself in: every screen as it renders (NEW/CHANGED badges, and each earlier version kept for a filmstrip), the journey stepper and the latest postcard from `himi progress`, the validate/test/UX/draft checks as they run, the site next to the app's home screen with its palette, and the navigation the test crawl followed. Writes .himi/studio/index.html and opens it; the page re-reads its state every two seconds, so nothing needs to be served. OPT-IN BY EXISTENCE: until this command (or `himi init`, which makes the board for every app it creates, without opening a browser) has run, no other command touches .himi/studio/ \u2014 after it, render/test/validate/push/icon/site/ux/progress each refresh the board as they finish (best-effort; never fails a command). Every image is a content-addressed copy in .himi/history/, never a live path into .himi/shots/. Local only, no secrets: it never reads a preview token, handover code or control token. --no-open prints the path instead (SSH, CI). `himi studio reel` writes the MAKING-OF: one self-contained HTML file (every image inlined, nothing fetched) with a flipbook of the home screen version by version, captioned by the postcard in effect at the time, the final screens, and every postcard \u2014 sized to stay attachable, thinning frames first. Defaults to .himi/making-of.html (never archived by push), which every successful `himi push --draft` also rebuilds and names as `reel` in its output; --out to put it elsewhere. The output names that file as the one to hand the owner (`handover: {file, hint}` in JSON; two plain lines at a terminal) \u2014 beside the preview link, never instead of it.", required: "[--content <dir>] [--no-open] | reel [--out <file>] [--no-open]" },
@@ -284909,7 +285714,7 @@ async function testCommand(ctx) {
284909
285714
  return results.every((result2) => result2.ok) ? 0 : 1;
284910
285715
  }
284911
285716
  const app2 = await appId(dir);
284912
- const { buildContentBundles: buildContentBundles2, buildReleaseFromContent: buildReleaseFromContent2, bundleOutDir: bundleOutDir2, crawlScreen: crawlScreen2, crawlScreenJourney: crawlScreenJourney2, crawlScreenHostile: crawlScreenHostile2, crawlScreenRelations: crawlScreenRelations2, crawlScreenCapabilitySuccess: crawlScreenCapabilitySuccess2, findingKey: findingKey2, startWorkerCoverage: startWorkerCoverage2, uncoveredFunctions: uncoveredFunctions2, crawlScreenDeep: crawlScreenDeep2, crawlSignature: crawlSignature2, recordScreenTraffic: recordScreenTraffic2, mintVisitor: mintVisitor2, mintOneAppVisitorToken: mintOneAppVisitorToken2, webWixCall: webWixCall2, freezeTrafficToMocks: freezeTrafficToMocks2, bootAndSnapshotState: bootAndSnapshotState2, isUnservedRequest: isUnservedRequest2, renderDescriptorWeb: renderDescriptorWeb2, renderPngBatch: renderPngBatch2, pngAvailable: pngAvailable2, crawlBlockingPasses } = await loadAuthoring();
285717
+ const { buildContentBundles: buildContentBundles2, buildReleaseFromContent: buildReleaseFromContent2, bundleOutDir: bundleOutDir2, crawlScreen: crawlScreen2, crawlScreenJourney: crawlScreenJourney2, crawlScreenHostile: crawlScreenHostile2, crawlScreenRelations: crawlScreenRelations2, crawlScreenCapabilitySuccess: crawlScreenCapabilitySuccess2, crawlScreenWebView: crawlScreenWebView2, findingKey: findingKey2, startWorkerCoverage: startWorkerCoverage2, uncoveredFunctions: uncoveredFunctions2, crawlScreenDeep: crawlScreenDeep2, crawlSignature: crawlSignature2, recordScreenTraffic: recordScreenTraffic2, mintVisitor: mintVisitor2, mintOneAppVisitorToken: mintOneAppVisitorToken2, webWixCall: webWixCall2, freezeTrafficToMocks: freezeTrafficToMocks2, bootAndSnapshotState: bootAndSnapshotState2, isUnservedRequest: isUnservedRequest2, renderDescriptorWeb: renderDescriptorWeb2, renderPngBatch: renderPngBatch2, pngAvailable: pngAvailable2, crawlBlockingPasses } = await loadAuthoring();
284913
285718
  const { readTestConfig: readTestConfig2, runCrawl: runCrawl2, formatReport: formatReport2, readCannedResponses: readCannedResponses2, makeRecordingWixCall: makeRecordingWixCall2, runRecordPass: runRecordPass2, runShotsPass: runShotsPass2, defaultNetRules: defaultNetRules2, readNetRules: readNetRules2, scopeDescriptors: scopeDescriptors2, writeRecordedMocks: writeRecordedMocks2 } = await Promise.resolve().then(() => (init_test(), test_exports));
284914
285719
  let config;
284915
285720
  let capturedConfig;
@@ -284967,6 +285772,10 @@ async function testCommand(ctx) {
284967
285772
  io2.error(JSON.stringify({ error: "--record writes dev/net-mocks.json and the crawl then reads it \u2014 an explicit --net would shadow what was just recorded; drop one of the flags" }));
284968
285773
  return 2;
284969
285774
  }
285775
+ if (flags["webview-live"] === true && (flags.offline === true || flags["no-webview-pages"] === true)) {
285776
+ io2.error(JSON.stringify({ code: "invalid_usage", error: `--webview-live loads url WebView pages from the live network; it cannot be combined with ${flags.offline === true ? "--offline" : "--no-webview-pages"}` }));
285777
+ return 2;
285778
+ }
284970
285779
  let nativeAvailabilities = [];
284971
285780
  if (flags.native !== void 0) {
284972
285781
  if (flags.browser === true) {
@@ -285009,7 +285818,7 @@ async function testCommand(ctx) {
285009
285818
  );
285010
285819
  if (flags.browser === true) {
285011
285820
  const { runBrowserAuthoring: runBrowserAuthoring2, collectWorkerSources: collectWorkerSources2, collectSdkModules: collectSdkModules2, sdkSubpathReader: sdkSubpathReader2 } = await Promise.resolve().then(() => (init_browser_authoring(), browser_authoring_exports));
285012
- const ignored = ["record", "net", "offline", "no-hostile", "deep", "budget", "no-shots", "native"].filter((f2) => flags[f2] !== void 0);
285821
+ const ignored = ["record", "net", "offline", "no-hostile", "deep", "budget", "no-shots", "native", "no-webview-pages", "webview-live"].filter((f2) => flags[f2] !== void 0);
285013
285822
  if (ignored.length) {
285014
285823
  io2.error(JSON.stringify({
285015
285824
  error: `--browser cannot honour ${ignored.map((f2) => `--${f2}`).join(", ")}: the loop runs in the page, which has its own data layers and no record pass. Drop ${ignored.length > 1 ? "them" : "it"} or drop --browser.`
@@ -285162,8 +285971,10 @@ async function testCommand(ctx) {
285162
285971
  const appServices = appLevelServices2(dir);
285163
285972
  let result;
285164
285973
  io2.checkpoint?.("checking");
285974
+ const webviewPages = flags["no-webview-pages"] === true ? null : await lazyWebViewPageDriver();
285165
285975
  try {
285166
285976
  result = await runCrawl2({
285977
+ ...webviewPages ? { webviewPages: { driver: webviewPages.driver, live: flags["webview-live"] === true, ...budgetMs ? { budgetMs: Math.max(budgetMs, 1500) } : {} } } : {},
285167
285978
  ...captureInputEvidence ? { captureInputEvidence: true } : {},
285168
285979
  dir,
285169
285980
  app: app2,
@@ -285190,11 +286001,13 @@ async function testCommand(ctx) {
285190
286001
  ...deep ? { deep } : {},
285191
286002
  ...offline ? { offline: true } : {},
285192
286003
  ...offline || flags["no-hostile"] === true ? { hostile: false } : {},
285193
- deps: { crawlScreen: crawlScreen2, crawlScreenJourney: crawlScreenJourney2, crawlScreenHostile: crawlScreenHostile2, crawlScreenRelations: crawlScreenRelations2, crawlScreenCapabilitySuccess: crawlScreenCapabilitySuccess2, findingKey: findingKey2, startWorkerCoverage: startWorkerCoverage2, uncoveredFunctions: uncoveredFunctions2, crawlScreenDeep: crawlScreenDeep2, crawlSignature: crawlSignature2 }
286004
+ deps: { crawlScreen: crawlScreen2, crawlScreenJourney: crawlScreenJourney2, crawlScreenHostile: crawlScreenHostile2, crawlScreenRelations: crawlScreenRelations2, crawlScreenCapabilitySuccess: crawlScreenCapabilitySuccess2, crawlScreenWebView: crawlScreenWebView2, findingKey: findingKey2, startWorkerCoverage: startWorkerCoverage2, uncoveredFunctions: uncoveredFunctions2, crawlScreenDeep: crawlScreenDeep2, crawlSignature: crawlSignature2 }
285194
286005
  });
285195
286006
  } catch (e2) {
285196
286007
  io2.error(JSON.stringify({ error: e2.message }));
285197
286008
  return 2;
286009
+ } finally {
286010
+ await webviewPages?.close();
285198
286011
  }
285199
286012
  const release4 = await loadReleaseFromDir(app2, out2);
285200
286013
  if (nativeAvailabilities.length > 0) {
@@ -285344,6 +286157,28 @@ ${[...afterRun.next, ...testReminder ? [testReminder] : []].join("\n")}`);
285344
286157
  if (result.navGraph) await leaveForBoard(dir, "map", result.navGraph);
285345
286158
  return result.ok ? 0 : 1;
285346
286159
  }
286160
+ async function lazyWebViewPageDriver() {
286161
+ let mod;
286162
+ try {
286163
+ mod = await Promise.resolve().then(() => (init_webview_page_driver(), webview_page_driver_exports));
286164
+ } catch {
286165
+ return null;
286166
+ }
286167
+ let launched = null;
286168
+ const real = () => launched ??= mod.createWebViewPageDriver();
286169
+ return {
286170
+ driver: {
286171
+ async open(spec) {
286172
+ const d2 = await real();
286173
+ if (!d2) throw new Error("no headless browser \u2014 install the CLI's Playwright Chromium (the --shots ledger names the command), or pass --no-webview-pages");
286174
+ return d2.open(spec);
286175
+ }
286176
+ },
286177
+ close: async () => {
286178
+ if (launched) await (await launched)?.close();
286179
+ }
286180
+ };
286181
+ }
285347
286182
 
285348
286183
  // src/cli.ts
285349
286184
  init_render();