@wix/himalaya-cli 0.1696.0 → 0.1698.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 +88 -14
- package/guides/hhp.md +1 -1
- package/package.json +2 -2
package/dist/cli.mjs
CHANGED
|
@@ -16198,7 +16198,6 @@ function webViewOriginAllowed(url, origins) {
|
|
|
16198
16198
|
}
|
|
16199
16199
|
var init_webview_origin = __esm({
|
|
16200
16200
|
"../../core/ts/src/webview-origin.ts"() {
|
|
16201
|
-
"use strict";
|
|
16202
16201
|
init_define_HHP_CATALOG();
|
|
16203
16202
|
}
|
|
16204
16203
|
});
|
|
@@ -31833,7 +31832,6 @@ function resolveIdiom(tokens2, ctx = {}) {
|
|
|
31833
31832
|
var IDIOM_CONTEXTS, UNSAFE_KEYS;
|
|
31834
31833
|
var init_idiom = __esm({
|
|
31835
31834
|
"../../core/ts/src/idiom.ts"() {
|
|
31836
|
-
"use strict";
|
|
31837
31835
|
init_define_HHP_CATALOG();
|
|
31838
31836
|
IDIOM_CONTEXTS = {
|
|
31839
31837
|
ios: { native: ["ios"] },
|
|
@@ -260398,13 +260396,18 @@ var init_run3 = __esm({
|
|
|
260398
260396
|
var native_exports = {};
|
|
260399
260397
|
__export(native_exports, {
|
|
260400
260398
|
BLANK_CONTRAST: () => BLANK_CONTRAST,
|
|
260399
|
+
COMMAND_TIMEOUT_MS: () => COMMAND_TIMEOUT_MS,
|
|
260400
|
+
SYSTEM_WINDOW: () => SYSTEM_WINDOW,
|
|
260401
260401
|
defaultRunner: () => defaultRunner3,
|
|
260402
260402
|
deviceFor: () => deviceFor,
|
|
260403
|
+
focusedWindow: () => focusedWindow,
|
|
260403
260404
|
nativeCapture: () => nativeCapture,
|
|
260404
260405
|
parseAppLocales: () => parseAppLocales,
|
|
260405
260406
|
parseNightMode: () => parseNightMode,
|
|
260406
260407
|
parsePlistArray: () => parsePlistArray,
|
|
260408
|
+
pngSize: () => pngSize3,
|
|
260407
260409
|
resumedPackages: () => resumedPackages,
|
|
260410
|
+
runWithTimeout: () => runWithTimeout,
|
|
260408
260411
|
sameLocalOrigin: () => sameLocalOrigin,
|
|
260409
260412
|
screenLink: () => screenLink
|
|
260410
260413
|
});
|
|
@@ -260416,6 +260419,34 @@ function resumedPackages(dumpsys) {
|
|
|
260416
260419
|
if (!lines2.length) return void 0;
|
|
260417
260420
|
return lines2.flatMap((l3) => [...l3.matchAll(/\s([A-Za-z0-9_.]+)\/[A-Za-z0-9_.$]+/g)].map((m2) => m2[1]));
|
|
260418
260421
|
}
|
|
260422
|
+
function focusedWindow(dumpsys) {
|
|
260423
|
+
const m2 = /mCurrentFocus=Window\{\S+ \S+ ([^}]+)\}/.exec(dumpsys);
|
|
260424
|
+
return m2?.[1]?.trim();
|
|
260425
|
+
}
|
|
260426
|
+
function runWithTimeout(cmd, args, timeoutMs) {
|
|
260427
|
+
return new Promise((resolve116) => {
|
|
260428
|
+
const child3 = spawn11(cmd, args, { stdio: ["ignore", "pipe", "ignore"] });
|
|
260429
|
+
const chunks = [];
|
|
260430
|
+
const timer = setTimeout(() => {
|
|
260431
|
+
child3.kill("SIGKILL");
|
|
260432
|
+
child3.stdout.destroy();
|
|
260433
|
+
resolve116({ code: 124, stdout: Buffer.concat(chunks), timedOut: true });
|
|
260434
|
+
}, timeoutMs);
|
|
260435
|
+
child3.stdout.on("data", (c2) => chunks.push(c2));
|
|
260436
|
+
child3.on("error", () => {
|
|
260437
|
+
clearTimeout(timer);
|
|
260438
|
+
resolve116({ code: 127, stdout: Buffer.alloc(0) });
|
|
260439
|
+
});
|
|
260440
|
+
child3.on("close", (code2) => {
|
|
260441
|
+
clearTimeout(timer);
|
|
260442
|
+
resolve116({ code: code2 ?? 1, stdout: Buffer.concat(chunks) });
|
|
260443
|
+
});
|
|
260444
|
+
});
|
|
260445
|
+
}
|
|
260446
|
+
function pngSize3(buf) {
|
|
260447
|
+
if (buf.length < 24 || buf.readUInt32BE(0) !== 2303741511) return void 0;
|
|
260448
|
+
return { width: buf.readUInt32BE(16), height: buf.readUInt32BE(20) };
|
|
260449
|
+
}
|
|
260419
260450
|
function deviceFor(devices, platform, variant) {
|
|
260420
260451
|
if (variant === "tablet") return platform === "ios" ? devices.iosTablet : devices.androidTablet;
|
|
260421
260452
|
return platform === "ios" ? devices.ios : devices.android;
|
|
@@ -260430,7 +260461,13 @@ function screenLink(appId3, screen, entry, release3) {
|
|
|
260430
260461
|
return `himi://app/${encodeURIComponent(appId3)}/screen/${encodeURIComponent(screen)}${qs2 ? `?${qs2}` : ""}`;
|
|
260431
260462
|
}
|
|
260432
260463
|
function nativeCapture(devices, opts) {
|
|
260433
|
-
const
|
|
260464
|
+
const baseRun = opts.run ?? defaultRunner3;
|
|
260465
|
+
const run3 = async (cmd, args) => {
|
|
260466
|
+
const r3 = await baseRun(cmd, args);
|
|
260467
|
+
if (r3.timedOut && (cmd === "adb" || cmd === "xcrun")) throw new DeviceTimeout(`${cmd} ${args.join(" ")} did not answer`);
|
|
260468
|
+
return r3;
|
|
260469
|
+
};
|
|
260470
|
+
const gone = /* @__PURE__ */ new Set();
|
|
260434
260471
|
const read2 = opts.readFile ?? ((p2) => readFileSync170(p2));
|
|
260435
260472
|
const sleep2 = opts.sleep ?? ((ms2) => new Promise((r3) => setTimeout(r3, ms2)));
|
|
260436
260473
|
const settleMs = opts.settleMs ?? 1e3;
|
|
@@ -260479,14 +260516,24 @@ function nativeCapture(devices, opts) {
|
|
|
260479
260516
|
} else {
|
|
260480
260517
|
const night = await ok5("adb", ["-s", id, "shell", "cmd", "uimode", "night"]);
|
|
260481
260518
|
const locales = await run3("adb", ["-s", id, "shell", "cmd", "locale", "get-app-locales", await playerPackage(id)]);
|
|
260482
|
-
|
|
260519
|
+
const auto = await run3("adb", ["-s", id, "shell", "settings", "get", "system", "accelerometer_rotation"]);
|
|
260520
|
+
const user = await run3("adb", ["-s", id, "shell", "settings", "get", "system", "user_rotation"]);
|
|
260521
|
+
const setting = (r3) => {
|
|
260522
|
+
const v2 = r3.stdout.toString().trim();
|
|
260523
|
+
return r3.code === 0 && /^(?:\d+|null)$/.test(v2) ? v2 : void 0;
|
|
260524
|
+
};
|
|
260525
|
+
const was = { auto: setting(auto), user: setting(user) };
|
|
260526
|
+
const rotation = was.auto !== void 0 && was.user !== void 0 ? { auto: was.auto, user: was.user } : void 0;
|
|
260527
|
+
saved.set(key4, { appearance: parseNightMode(night), language: locales.code === 0 ? parseAppLocales(locales.stdout.toString()) : void 0, ...rotation ? { rotation } : {} });
|
|
260483
260528
|
}
|
|
260484
260529
|
}
|
|
260485
260530
|
async function apply2(platform, id, variant) {
|
|
260486
260531
|
const key4 = `${platform}:${id}`;
|
|
260487
260532
|
const want = variant === "dark" ? "dark" : variant === "rtl" ? "rtl" : "light";
|
|
260488
260533
|
if (applied.get(key4) === want) return;
|
|
260534
|
+
const first = !saved.has(key4);
|
|
260489
260535
|
await remember(platform, id);
|
|
260536
|
+
if (platform === "android" && first && saved.get(key4)?.rotation) await pinPortrait(id);
|
|
260490
260537
|
const dark = want === "dark", right = want === "rtl";
|
|
260491
260538
|
if (platform === "ios") {
|
|
260492
260539
|
await ok5("xcrun", ["simctl", "ui", id, "appearance", dark ? "dark" : "light"]);
|
|
@@ -260499,6 +260546,13 @@ function nativeCapture(devices, opts) {
|
|
|
260499
260546
|
}
|
|
260500
260547
|
applied.set(key4, want);
|
|
260501
260548
|
}
|
|
260549
|
+
async function pinPortrait(id) {
|
|
260550
|
+
const size = await run3("adb", ["-s", id, "shell", "wm", "size"]);
|
|
260551
|
+
const m2 = /Physical size:\s*(\d+)x(\d+)/.exec(size.stdout.toString());
|
|
260552
|
+
const landscape = m2 ? Number(m2[1]) > Number(m2[2]) : false;
|
|
260553
|
+
await run3("adb", ["-s", id, "shell", "settings", "put", "system", "accelerometer_rotation", "0"]);
|
|
260554
|
+
await run3("adb", ["-s", id, "shell", "settings", "put", "system", "user_rotation", landscape ? "1" : "0"]);
|
|
260555
|
+
}
|
|
260502
260556
|
async function originMismatch(id) {
|
|
260503
260557
|
if (!opts.serveOrigin) return "";
|
|
260504
260558
|
const known2 = originChecked.get(id);
|
|
@@ -260529,7 +260583,13 @@ function nativeCapture(devices, opts) {
|
|
|
260529
260583
|
const r3 = await run3("adb", ["-s", id, "shell", "dumpsys", "activity", "activities"]);
|
|
260530
260584
|
const resumed = r3.code === 0 ? resumedPackages(r3.stdout.toString()) : void 0;
|
|
260531
260585
|
const player = await playerPackage(id);
|
|
260532
|
-
|
|
260586
|
+
if (resumed && !resumed.includes(player)) return `the Player was not in front (${resumed.join(", ") || "nothing resumed"})`;
|
|
260587
|
+
const w2 = await run3("adb", ["-s", id, "shell", "dumpsys", "window"]);
|
|
260588
|
+
const focus = w2.code === 0 ? focusedWindow(w2.stdout.toString()) : void 0;
|
|
260589
|
+
if (!focus) return "";
|
|
260590
|
+
const owner = focus.includes("/") ? focus.slice(0, focus.indexOf("/")) : void 0;
|
|
260591
|
+
if (SYSTEM_WINDOW.test(focus) || owner !== void 0 && owner !== player) return `a system window covered the Player (${focus})`;
|
|
260592
|
+
return "";
|
|
260533
260593
|
}
|
|
260534
260594
|
async function settle2(platform, id, file2, notFrame) {
|
|
260535
260595
|
let previous;
|
|
@@ -260559,6 +260619,10 @@ function nativeCapture(devices, opts) {
|
|
|
260559
260619
|
frames.push({ surface: platform, screen, variant, skipped: { reason: `no ${platform}${variant === "tablet" ? " tablet" : ""} device passed (${flag3})` } });
|
|
260560
260620
|
continue;
|
|
260561
260621
|
}
|
|
260622
|
+
if (gone.has(id)) {
|
|
260623
|
+
frames.push({ surface: platform, screen, variant, skipped: { reason: `${id} stopped answering earlier in this run` } });
|
|
260624
|
+
continue;
|
|
260625
|
+
}
|
|
260562
260626
|
try {
|
|
260563
260627
|
const mismatch = platform === "ios" ? await originMismatch(id) : "";
|
|
260564
260628
|
if (mismatch) {
|
|
@@ -260586,9 +260650,17 @@ function nativeCapture(devices, opts) {
|
|
|
260586
260650
|
continue;
|
|
260587
260651
|
}
|
|
260588
260652
|
}
|
|
260653
|
+
const size = pngSize3(read2(file2));
|
|
260654
|
+
if (size && size.width > size.height) {
|
|
260655
|
+
frames.push({ surface: platform, screen, variant, skipped: { reason: `the ${platform} frame is landscape (${size.width}x${size.height}): turn the device upright` } });
|
|
260656
|
+
continue;
|
|
260657
|
+
}
|
|
260589
260658
|
frames.push({ surface: platform, screen, variant, file: file2 });
|
|
260590
260659
|
} catch (e2) {
|
|
260591
|
-
|
|
260660
|
+
if (e2 instanceof DeviceTimeout) {
|
|
260661
|
+
gone.add(id);
|
|
260662
|
+
frames.push({ surface: platform, screen, variant, skipped: { reason: `${id} stopped answering: ${e2.message}` } });
|
|
260663
|
+
} else frames.push({ surface: platform, screen, variant, skipped: { reason: `capture failed: ${e2.message}` } });
|
|
260592
260664
|
}
|
|
260593
260665
|
}
|
|
260594
260666
|
return frames;
|
|
@@ -260605,6 +260677,10 @@ function nativeCapture(devices, opts) {
|
|
|
260605
260677
|
} else {
|
|
260606
260678
|
if (was.appearance) await run3("adb", ["-s", id, "shell", "cmd", "uimode", "night", was.appearance]);
|
|
260607
260679
|
await run3("adb", ["-s", id, "shell", "cmd", "locale", "set-app-locales", packages.get(id) ?? androidPackage, "--locales", was.language ?? ""]);
|
|
260680
|
+
for (const [name, value2] of [["user_rotation", was.rotation?.user], ["accelerometer_rotation", was.rotation?.auto]]) {
|
|
260681
|
+
if (value2 === void 0) continue;
|
|
260682
|
+
await run3("adb", ["-s", id, "shell", "settings", ...value2 && value2 !== "null" ? ["put", "system", name, value2] : ["delete", "system", name]]);
|
|
260683
|
+
}
|
|
260608
260684
|
}
|
|
260609
260685
|
} catch {
|
|
260610
260686
|
}
|
|
@@ -260636,18 +260712,16 @@ function parseAppLocales(out2) {
|
|
|
260636
260712
|
function parsePlistArray(out2) {
|
|
260637
260713
|
return out2.replace(/^\s*\(|\)\s*$/g, "").split(",").map((s5) => s5.trim().replace(/^"|"$/g, "")).filter(Boolean);
|
|
260638
260714
|
}
|
|
260639
|
-
var BLANK_CONTRAST, defaultRunner3;
|
|
260715
|
+
var BLANK_CONTRAST, COMMAND_TIMEOUT_MS, defaultRunner3, DeviceTimeout, SYSTEM_WINDOW;
|
|
260640
260716
|
var init_native = __esm({
|
|
260641
260717
|
"src/fidelity/native.ts"() {
|
|
260642
260718
|
init_define_HHP_CATALOG();
|
|
260643
260719
|
BLANK_CONTRAST = 0.03;
|
|
260644
|
-
|
|
260645
|
-
|
|
260646
|
-
|
|
260647
|
-
|
|
260648
|
-
|
|
260649
|
-
child3.on("close", (code2) => resolve116({ code: code2 ?? 1, stdout: Buffer.concat(chunks) }));
|
|
260650
|
-
});
|
|
260720
|
+
COMMAND_TIMEOUT_MS = 9e4;
|
|
260721
|
+
defaultRunner3 = (cmd, args) => runWithTimeout(cmd, args, COMMAND_TIMEOUT_MS);
|
|
260722
|
+
DeviceTimeout = class extends Error {
|
|
260723
|
+
};
|
|
260724
|
+
SYSTEM_WINDOW = /^(?:Application Not Responding|Application Error|Waiting For Debugger)\b|^(?:NotificationShade|StatusBar)$/i;
|
|
260651
260725
|
}
|
|
260652
260726
|
});
|
|
260653
260727
|
|
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.
|
|
3
|
+
"version": "0.1698.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": "
|
|
84
|
+
"falconPackageHash": "681ee63d7c67ac19a89d41236645ec46069a8dae13c2523a10faefb9"
|
|
85
85
|
}
|