@wix/himalaya-cli 0.1696.0 → 0.1697.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
@@ -33656,6 +33656,7 @@ function shouldRevealError(args) {
33656
33656
  var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE, AUTHORED_PATTERN_LIMIT, authoredPatterns;
33657
33657
  var init_validation = __esm({
33658
33658
  "../../core/ts/src/validation.ts"() {
33659
+ "use strict";
33659
33660
  init_define_HHP_CATALOG();
33660
33661
  EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
33661
33662
  URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
@@ -260398,13 +260399,18 @@ var init_run3 = __esm({
260398
260399
  var native_exports = {};
260399
260400
  __export(native_exports, {
260400
260401
  BLANK_CONTRAST: () => BLANK_CONTRAST,
260402
+ COMMAND_TIMEOUT_MS: () => COMMAND_TIMEOUT_MS,
260403
+ SYSTEM_WINDOW: () => SYSTEM_WINDOW,
260401
260404
  defaultRunner: () => defaultRunner3,
260402
260405
  deviceFor: () => deviceFor,
260406
+ focusedWindow: () => focusedWindow,
260403
260407
  nativeCapture: () => nativeCapture,
260404
260408
  parseAppLocales: () => parseAppLocales,
260405
260409
  parseNightMode: () => parseNightMode,
260406
260410
  parsePlistArray: () => parsePlistArray,
260411
+ pngSize: () => pngSize3,
260407
260412
  resumedPackages: () => resumedPackages,
260413
+ runWithTimeout: () => runWithTimeout,
260408
260414
  sameLocalOrigin: () => sameLocalOrigin,
260409
260415
  screenLink: () => screenLink
260410
260416
  });
@@ -260416,6 +260422,34 @@ function resumedPackages(dumpsys) {
260416
260422
  if (!lines2.length) return void 0;
260417
260423
  return lines2.flatMap((l3) => [...l3.matchAll(/\s([A-Za-z0-9_.]+)\/[A-Za-z0-9_.$]+/g)].map((m2) => m2[1]));
260418
260424
  }
260425
+ function focusedWindow(dumpsys) {
260426
+ const m2 = /mCurrentFocus=Window\{\S+ \S+ ([^}]+)\}/.exec(dumpsys);
260427
+ return m2?.[1]?.trim();
260428
+ }
260429
+ function runWithTimeout(cmd, args, timeoutMs) {
260430
+ return new Promise((resolve116) => {
260431
+ const child3 = spawn11(cmd, args, { stdio: ["ignore", "pipe", "ignore"] });
260432
+ const chunks = [];
260433
+ const timer = setTimeout(() => {
260434
+ child3.kill("SIGKILL");
260435
+ child3.stdout.destroy();
260436
+ resolve116({ code: 124, stdout: Buffer.concat(chunks), timedOut: true });
260437
+ }, timeoutMs);
260438
+ child3.stdout.on("data", (c2) => chunks.push(c2));
260439
+ child3.on("error", () => {
260440
+ clearTimeout(timer);
260441
+ resolve116({ code: 127, stdout: Buffer.alloc(0) });
260442
+ });
260443
+ child3.on("close", (code2) => {
260444
+ clearTimeout(timer);
260445
+ resolve116({ code: code2 ?? 1, stdout: Buffer.concat(chunks) });
260446
+ });
260447
+ });
260448
+ }
260449
+ function pngSize3(buf) {
260450
+ if (buf.length < 24 || buf.readUInt32BE(0) !== 2303741511) return void 0;
260451
+ return { width: buf.readUInt32BE(16), height: buf.readUInt32BE(20) };
260452
+ }
260419
260453
  function deviceFor(devices, platform, variant) {
260420
260454
  if (variant === "tablet") return platform === "ios" ? devices.iosTablet : devices.androidTablet;
260421
260455
  return platform === "ios" ? devices.ios : devices.android;
@@ -260430,7 +260464,13 @@ function screenLink(appId3, screen, entry, release3) {
260430
260464
  return `himi://app/${encodeURIComponent(appId3)}/screen/${encodeURIComponent(screen)}${qs2 ? `?${qs2}` : ""}`;
260431
260465
  }
260432
260466
  function nativeCapture(devices, opts) {
260433
- const run3 = opts.run ?? defaultRunner3;
260467
+ const baseRun = opts.run ?? defaultRunner3;
260468
+ const run3 = async (cmd, args) => {
260469
+ const r3 = await baseRun(cmd, args);
260470
+ if (r3.timedOut && (cmd === "adb" || cmd === "xcrun")) throw new DeviceTimeout(`${cmd} ${args.join(" ")} did not answer`);
260471
+ return r3;
260472
+ };
260473
+ const gone = /* @__PURE__ */ new Set();
260434
260474
  const read2 = opts.readFile ?? ((p2) => readFileSync170(p2));
260435
260475
  const sleep2 = opts.sleep ?? ((ms2) => new Promise((r3) => setTimeout(r3, ms2)));
260436
260476
  const settleMs = opts.settleMs ?? 1e3;
@@ -260479,14 +260519,24 @@ function nativeCapture(devices, opts) {
260479
260519
  } else {
260480
260520
  const night = await ok5("adb", ["-s", id, "shell", "cmd", "uimode", "night"]);
260481
260521
  const locales = await run3("adb", ["-s", id, "shell", "cmd", "locale", "get-app-locales", await playerPackage(id)]);
260482
- saved.set(key4, { appearance: parseNightMode(night), language: locales.code === 0 ? parseAppLocales(locales.stdout.toString()) : void 0 });
260522
+ const auto = await run3("adb", ["-s", id, "shell", "settings", "get", "system", "accelerometer_rotation"]);
260523
+ const user = await run3("adb", ["-s", id, "shell", "settings", "get", "system", "user_rotation"]);
260524
+ const setting = (r3) => {
260525
+ const v2 = r3.stdout.toString().trim();
260526
+ return r3.code === 0 && /^(?:\d+|null)$/.test(v2) ? v2 : void 0;
260527
+ };
260528
+ const was = { auto: setting(auto), user: setting(user) };
260529
+ const rotation = was.auto !== void 0 && was.user !== void 0 ? { auto: was.auto, user: was.user } : void 0;
260530
+ saved.set(key4, { appearance: parseNightMode(night), language: locales.code === 0 ? parseAppLocales(locales.stdout.toString()) : void 0, ...rotation ? { rotation } : {} });
260483
260531
  }
260484
260532
  }
260485
260533
  async function apply2(platform, id, variant) {
260486
260534
  const key4 = `${platform}:${id}`;
260487
260535
  const want = variant === "dark" ? "dark" : variant === "rtl" ? "rtl" : "light";
260488
260536
  if (applied.get(key4) === want) return;
260537
+ const first = !saved.has(key4);
260489
260538
  await remember(platform, id);
260539
+ if (platform === "android" && first && saved.get(key4)?.rotation) await pinPortrait(id);
260490
260540
  const dark = want === "dark", right = want === "rtl";
260491
260541
  if (platform === "ios") {
260492
260542
  await ok5("xcrun", ["simctl", "ui", id, "appearance", dark ? "dark" : "light"]);
@@ -260499,6 +260549,13 @@ function nativeCapture(devices, opts) {
260499
260549
  }
260500
260550
  applied.set(key4, want);
260501
260551
  }
260552
+ async function pinPortrait(id) {
260553
+ const size = await run3("adb", ["-s", id, "shell", "wm", "size"]);
260554
+ const m2 = /Physical size:\s*(\d+)x(\d+)/.exec(size.stdout.toString());
260555
+ const landscape = m2 ? Number(m2[1]) > Number(m2[2]) : false;
260556
+ await run3("adb", ["-s", id, "shell", "settings", "put", "system", "accelerometer_rotation", "0"]);
260557
+ await run3("adb", ["-s", id, "shell", "settings", "put", "system", "user_rotation", landscape ? "1" : "0"]);
260558
+ }
260502
260559
  async function originMismatch(id) {
260503
260560
  if (!opts.serveOrigin) return "";
260504
260561
  const known2 = originChecked.get(id);
@@ -260529,7 +260586,13 @@ function nativeCapture(devices, opts) {
260529
260586
  const r3 = await run3("adb", ["-s", id, "shell", "dumpsys", "activity", "activities"]);
260530
260587
  const resumed = r3.code === 0 ? resumedPackages(r3.stdout.toString()) : void 0;
260531
260588
  const player = await playerPackage(id);
260532
- return !resumed || resumed.includes(player) ? "" : `the Player was not in front (${resumed.join(", ") || "nothing resumed"})`;
260589
+ if (resumed && !resumed.includes(player)) return `the Player was not in front (${resumed.join(", ") || "nothing resumed"})`;
260590
+ const w2 = await run3("adb", ["-s", id, "shell", "dumpsys", "window"]);
260591
+ const focus = w2.code === 0 ? focusedWindow(w2.stdout.toString()) : void 0;
260592
+ if (!focus) return "";
260593
+ const owner = focus.includes("/") ? focus.slice(0, focus.indexOf("/")) : void 0;
260594
+ if (SYSTEM_WINDOW.test(focus) || owner !== void 0 && owner !== player) return `a system window covered the Player (${focus})`;
260595
+ return "";
260533
260596
  }
260534
260597
  async function settle2(platform, id, file2, notFrame) {
260535
260598
  let previous;
@@ -260559,6 +260622,10 @@ function nativeCapture(devices, opts) {
260559
260622
  frames.push({ surface: platform, screen, variant, skipped: { reason: `no ${platform}${variant === "tablet" ? " tablet" : ""} device passed (${flag3})` } });
260560
260623
  continue;
260561
260624
  }
260625
+ if (gone.has(id)) {
260626
+ frames.push({ surface: platform, screen, variant, skipped: { reason: `${id} stopped answering earlier in this run` } });
260627
+ continue;
260628
+ }
260562
260629
  try {
260563
260630
  const mismatch = platform === "ios" ? await originMismatch(id) : "";
260564
260631
  if (mismatch) {
@@ -260586,9 +260653,17 @@ function nativeCapture(devices, opts) {
260586
260653
  continue;
260587
260654
  }
260588
260655
  }
260656
+ const size = pngSize3(read2(file2));
260657
+ if (size && size.width > size.height) {
260658
+ frames.push({ surface: platform, screen, variant, skipped: { reason: `the ${platform} frame is landscape (${size.width}x${size.height}): turn the device upright` } });
260659
+ continue;
260660
+ }
260589
260661
  frames.push({ surface: platform, screen, variant, file: file2 });
260590
260662
  } catch (e2) {
260591
- frames.push({ surface: platform, screen, variant, skipped: { reason: `capture failed: ${e2.message}` } });
260663
+ if (e2 instanceof DeviceTimeout) {
260664
+ gone.add(id);
260665
+ frames.push({ surface: platform, screen, variant, skipped: { reason: `${id} stopped answering: ${e2.message}` } });
260666
+ } else frames.push({ surface: platform, screen, variant, skipped: { reason: `capture failed: ${e2.message}` } });
260592
260667
  }
260593
260668
  }
260594
260669
  return frames;
@@ -260605,6 +260680,10 @@ function nativeCapture(devices, opts) {
260605
260680
  } else {
260606
260681
  if (was.appearance) await run3("adb", ["-s", id, "shell", "cmd", "uimode", "night", was.appearance]);
260607
260682
  await run3("adb", ["-s", id, "shell", "cmd", "locale", "set-app-locales", packages.get(id) ?? androidPackage, "--locales", was.language ?? ""]);
260683
+ for (const [name, value2] of [["user_rotation", was.rotation?.user], ["accelerometer_rotation", was.rotation?.auto]]) {
260684
+ if (value2 === void 0) continue;
260685
+ await run3("adb", ["-s", id, "shell", "settings", ...value2 && value2 !== "null" ? ["put", "system", name, value2] : ["delete", "system", name]]);
260686
+ }
260608
260687
  }
260609
260688
  } catch {
260610
260689
  }
@@ -260636,18 +260715,16 @@ function parseAppLocales(out2) {
260636
260715
  function parsePlistArray(out2) {
260637
260716
  return out2.replace(/^\s*\(|\)\s*$/g, "").split(",").map((s5) => s5.trim().replace(/^"|"$/g, "")).filter(Boolean);
260638
260717
  }
260639
- var BLANK_CONTRAST, defaultRunner3;
260718
+ var BLANK_CONTRAST, COMMAND_TIMEOUT_MS, defaultRunner3, DeviceTimeout, SYSTEM_WINDOW;
260640
260719
  var init_native = __esm({
260641
260720
  "src/fidelity/native.ts"() {
260642
260721
  init_define_HHP_CATALOG();
260643
260722
  BLANK_CONTRAST = 0.03;
260644
- defaultRunner3 = (cmd, args) => new Promise((resolve116) => {
260645
- const child3 = spawn11(cmd, args, { stdio: ["ignore", "pipe", "ignore"] });
260646
- const chunks = [];
260647
- child3.stdout.on("data", (c2) => chunks.push(c2));
260648
- child3.on("error", () => resolve116({ code: 127, stdout: Buffer.alloc(0) }));
260649
- child3.on("close", (code2) => resolve116({ code: code2 ?? 1, stdout: Buffer.concat(chunks) }));
260650
- });
260723
+ COMMAND_TIMEOUT_MS = 9e4;
260724
+ defaultRunner3 = (cmd, args) => runWithTimeout(cmd, args, COMMAND_TIMEOUT_MS);
260725
+ DeviceTimeout = class extends Error {
260726
+ };
260727
+ SYSTEM_WINDOW = /^(?:Application Not Responding|Application Error|Waiting For Debugger)\b|^(?:NotificationShade|StatusBar)$/i;
260651
260728
  }
260652
260729
  });
260653
260730
 
package/guides/hhp.md CHANGED
@@ -218,7 +218,7 @@ himi fidelity --content <dir> [--screen a,b] [--variant light,dark,rtl,tablet] [
218
218
  For each screen and variant (`light`, `dark`, `rtl`, `tablet`), the command does four things:
219
219
 
220
220
  1. **Captures the mockup.** It draws the page in Chromium at the variant's width. Dark mode is drawn by emulating `prefers-color-scheme`. RTL is drawn by setting `dir=rtl` on the page.
221
- 2. **Captures the web render** from the app's recorded data, as `himi render` does by default. Native frames come from Himi Player on the devices you pass: `--ios <udid>` and `--android <serial>`, plus `--ios-tablet` and `--android-tablet` for the tablet variant. Only those devices are touched. For each variant the command sets dark or light appearance and, for `rtl`, the app's right-to-left language (iOS `AppleLanguages`, Android per-app locale, API 33+). It opens `himi://app/<app>/screen/<screen>` and captures once two frames match, the frame is not a blank or loading page, and, on Android, the Player is the app in front rather than the launcher. A screen that has not settled that way after 30 seconds is reported `skipped` as `capture_unsettled`, never judged. Every setting it changed is restored afterwards, also on Ctrl-C. A variant with no device is reported `skipped`, never passed. Without `--release <id>` or `--serve <port>` the Player shows the app's **live** release, not your working copy. `--serve <port>` serves the working copy on `127.0.0.1:<port>` as `himi run` does, so native and web render the same release. The Player reads a local origin only from a Debug build that compiled it in (see [View your package on a device](himi-player-implementation.md#view-your-package-on-a-device)): build it with `HIMALAYA_API_BASE_URL_INFO=http://127.0.0.1:<port>` on iOS and `-PhimalayaDevServeBaseUrl=http://10.0.2.2:<port>` on Android. An iOS device whose Player reads another origin is skipped with the rebuild to run. Android's origin cannot be read back from the installed app, so check that build yourself. A screen that declares `params` is skipped natively for now, because the Player's deep link does not carry them yet. With `--serve`, a screen a link cannot open is skipped natively too, with the reason: when config.ts declares `navigation.linkableScreens`, the Player opens only a tab root, the home screen, or a linkable screen marked `isPublic: true`, and stays on home for any other. On a fresh iOS simulator, open one `himi://` link by hand first and accept iOS's "Open in Himi Player?" prompt: the command cannot answer it, and until it is accepted every iOS capture shows the prompt.
221
+ 2. **Captures the web render** from the app's recorded data, as `himi render` does by default. Native frames come from Himi Player on the devices you pass: `--ios <udid>` and `--android <serial>`, plus `--ios-tablet` and `--android-tablet` for the tablet variant. Only those devices are touched. For each variant the command sets dark or light appearance and, for `rtl`, the app's right-to-left language (iOS `AppleLanguages`, Android per-app locale, API 33+). It opens `himi://app/<app>/screen/<screen>` and captures once two frames match, the frame is not a blank or loading page, and, on Android, the Player is the app in front rather than the launcher. A screen that has not settled that way after 30 seconds is reported `skipped` as `capture_unsettled`, never judged. On Android a system window over the Player, such as a "System UI isn't responding" dialog, also keeps a frame from settling. The run turns an Android device upright for its duration, as the web render is portrait, and reports any landscape frame `skipped`. A device call that does not answer within 90 seconds marks that device gone: its remaining frames are reported `skipped`, so a device that shut down mid-run cannot hang the run. Every setting it changed is restored afterwards, also on Ctrl-C. A variant with no device is reported `skipped`, never passed. Without `--release <id>` or `--serve <port>` the Player shows the app's **live** release, not your working copy. `--serve <port>` serves the working copy on `127.0.0.1:<port>` as `himi run` does, so native and web render the same release. The Player reads a local origin only from a Debug build that compiled it in (see [View your package on a device](himi-player-implementation.md#view-your-package-on-a-device)): build it with `HIMALAYA_API_BASE_URL_INFO=http://127.0.0.1:<port>` on iOS and `-PhimalayaDevServeBaseUrl=http://10.0.2.2:<port>` on Android. An iOS device whose Player reads another origin is skipped with the rebuild to run. Android's origin cannot be read back from the installed app, so check that build yourself. A screen that declares `params` is skipped natively for now, because the Player's deep link does not carry them yet. With `--serve`, a screen a link cannot open is skipped natively too, with the reason: when config.ts declares `navigation.linkableScreens`, the Player opens only a tab root, the home screen, or a linkable screen marked `isPublic: true`, and stays on home for any other. On a fresh iOS simulator, open one `himi://` link by hand first and accept iOS's "Open in Himi Player?" prompt: the command cannot answer it, and until it is accepted every iOS capture shows the prompt.
222
222
  3. **Scores mockup↔web** with ImageMagick SSIM, globally and per tile. The worst tile says where the screens differ most.
223
223
  4. **Asks a fresh model** two questions, using the repo's fidelity judge prompt. The model never ran in the session that wrote the app.
224
224
  - **Design:** does WEB look like the MOCKUP? This judges the port.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1696.0",
3
+ "version": "0.1697.0",
4
4
  "type": "module",
5
5
  "description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
6
6
  "keywords": [
@@ -81,5 +81,5 @@
81
81
  "artifactId": "himalaya-cli"
82
82
  }
83
83
  },
84
- "falconPackageHash": "dcce9f61aa11697fcef4163a6cc7e9405c8e9a379966470becc179ff"
84
+ "falconPackageHash": "f9dd6889f4ab500742346844777accfc22fa427e7505ee2308b17cc4"
85
85
  }