@wix/himalaya-cli 0.1423.0 → 0.1424.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.
Files changed (2) hide show
  1. package/dist/cli.mjs +70 -15
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -7715,6 +7715,7 @@ function resolveTranslation(value, catalog3, sourceCatalog) {
7715
7715
  var BINDING_SIGILS, BINDING_SIGIL_RE, TRANSLATION_PREFIX, TRANSLATION_KEY_RE;
7716
7716
  var init_bindings = __esm({
7717
7717
  "../../core/ts/src/bindings.ts"() {
7718
+ "use strict";
7718
7719
  BINDING_SIGILS = ["service", "flag", "item", "t"];
7719
7720
  BINDING_SIGIL_RE = new RegExp(
7720
7721
  `^\\$(?:${BINDING_SIGILS.filter((s2) => s2 !== "t").join("|")})\\b|^\\$t:`
@@ -10225,15 +10226,44 @@ var init_raw_json_depth = __esm({
10225
10226
  });
10226
10227
 
10227
10228
  // ../../core/dev-server/src/realm-parity.ts
10228
- function withheldGlobalsSource(hide) {
10229
- if (!hide?.length) return "";
10230
- return `${JSON.stringify(hide)}.forEach(function (n) { try { delete globalThis[n]; } catch (e) { /* non-configurable: leave it */ } });`;
10229
+ function allowlistSweepSource(keep = []) {
10230
+ const key2 = [...keep].sort().join(",");
10231
+ let source = sweepSources.get(key2);
10232
+ if (source === void 0) {
10233
+ source = buildSweepSource([.../* @__PURE__ */ new Set([...WORKER_ALLOWLIST, ...keep])].sort());
10234
+ if (sweepSources.size >= 32) sweepSources.clear();
10235
+ sweepSources.set(key2, source);
10236
+ }
10237
+ return source;
10238
+ }
10239
+ function buildSweepSource(allow) {
10240
+ return `(function (allow) {
10241
+ var keep = Object.create(null);
10242
+ for (var i = 0; i < allow.length; i++) keep[allow[i]] = true;
10243
+ for (var o = globalThis; o && o !== Object.prototype; o = Object.getPrototypeOf(o)) {
10244
+ var names = Object.getOwnPropertyNames(o);
10245
+ for (var j = 0; j < names.length; j++) {
10246
+ var n = names[j];
10247
+ if (keep[n] || n === "constructor" || n.indexOf("himi.quickjs.") === 0) continue;
10248
+ try { delete o[n]; } catch (e) { /* non-configurable: leave it */ }
10249
+ }
10250
+ }
10251
+ })(${JSON.stringify(allow)});`;
10252
+ }
10253
+ function explainWithheldError(message, deviceParity) {
10254
+ if (!deviceParity || message.includes(FETCH_ADVICE)) return message;
10255
+ return BARE_FETCH_UNDEFINED.test(message) ? `${message} \u2014 ${FETCH_ADVICE}` : message;
10231
10256
  }
10232
10257
  function realmInstallsIntl(intl, hide) {
10233
10258
  return intl === true && !(hide ?? []).includes("Intl");
10234
10259
  }
10260
+ var sweepSources, FETCH_ADVICE, BARE_FETCH_UNDEFINED;
10235
10261
  var init_realm_parity = __esm({
10236
10262
  "../../core/dev-server/src/realm-parity.ts"() {
10263
+ init_allowlist();
10264
+ sweepSources = /* @__PURE__ */ new Map();
10265
+ FETCH_ADVICE = "`fetch` is not available to a Tier-5 worker (no device has it: iOS's JSContext never did and the Android worker strips it, #4499) \u2014 load data through the sanctioned Wix transport (`@himalaya/wix-*` or `globalThis.himalaya.wixApi.call`).";
10266
+ BARE_FETCH_UNDEFINED = /(?:^|[^.\w$'])'?fetch'? is not (?:defined|a function)\b/;
10237
10267
  }
10238
10268
  });
10239
10269
 
@@ -10266,6 +10296,7 @@ __export(validate_descriptor_core_exports, {
10266
10296
  RAW_JSON_MAX_DEPTH: () => RAW_JSON_MAX_DEPTH,
10267
10297
  SERVICE_ONLY_BINDING_PROPS: () => SERVICE_ONLY_BINDING_PROPS,
10268
10298
  WHOLE_VALUE_BINDING: () => WHOLE_VALUE_BINDING,
10299
+ allowlistSweepSource: () => allowlistSweepSource,
10269
10300
  bareNestedClass: () => bareNestedClass,
10270
10301
  bootBundleWorker: () => bootBundleWorker,
10271
10302
  collectServiceBindings: () => collectServiceBindings,
@@ -10275,6 +10306,7 @@ __export(validate_descriptor_core_exports, {
10275
10306
  deviceParityWithheldFrom: () => deviceParityWithheldFrom,
10276
10307
  dryRunBundle: () => dryRunBundle,
10277
10308
  enumFieldNames: () => enumFieldNames,
10309
+ explainWithheldError: () => explainWithheldError,
10278
10310
  extractBundleContract: () => extractBundleContract,
10279
10311
  extractBundleServices: () => extractBundleServices,
10280
10312
  findSkipDerive: () => findSkipDerive,
@@ -10301,7 +10333,6 @@ __export(validate_descriptor_core_exports, {
10301
10333
  setDefaultEvaluator: () => setDefaultEvaluator,
10302
10334
  topBarFindings: () => topBarFindings,
10303
10335
  validateScreenDescriptor: () => validateScreenDescriptor,
10304
- withheldGlobalsSource: () => withheldGlobalsSource,
10305
10336
  workerSubtreeAllowed: () => workerSubtreeAllowed
10306
10337
  });
10307
10338
  function makeInert() {
@@ -10699,6 +10730,7 @@ async function bootBundleWorker(bundleJs, opts) {
10699
10730
  timeoutMs: 2e3 + budgetMs,
10700
10731
  filename: "himi-bundle.js",
10701
10732
  hide,
10733
+ deviceParity: opts.deviceParity === true,
10702
10734
  wixCall: wixApi.call,
10703
10735
  dispatch: dispatchHost,
10704
10736
  skipLoad: opts.skipLoad === true,
@@ -10709,13 +10741,13 @@ async function bootBundleWorker(bundleJs, opts) {
10709
10741
  guestActions = ran.actions;
10710
10742
  guestSession = ran.session;
10711
10743
  if (ran.error) {
10712
- errors.push({ service: "(boot)", message: ran.error });
10744
+ errors.push({ service: "(boot)", message: explainWithheldError(ran.error, opts.deviceParity === true) });
10713
10745
  }
10714
10746
  } else {
10715
- realm.run(bundleJs, sandbox, { timeoutMs: 2e3, filename: "himi-bundle.js", hide, ...pins });
10747
+ realm.run(bundleJs, sandbox, { timeoutMs: 2e3, filename: "himi-bundle.js", hide, deviceParity: opts.deviceParity === true, ...pins });
10716
10748
  }
10717
10749
  } catch (err) {
10718
- errors.push({ service: "(boot)", message: err?.message ?? String(err), ...err?.stack ? { stack: err.stack } : {} });
10750
+ errors.push({ service: "(boot)", message: explainWithheldError(err?.message ?? String(err), opts.deviceParity === true), ...err?.stack ? { stack: err.stack } : {} });
10719
10751
  }
10720
10752
  const clone = (v2) => {
10721
10753
  try {
@@ -10788,6 +10820,17 @@ async function bootBundleWorker(bundleJs, opts) {
10788
10820
  delete state._error;
10789
10821
  return state;
10790
10822
  }
10823
+ const explainActionError = (err) => {
10824
+ if (!(err && typeof err === "object" && typeof err.message === "string")) return;
10825
+ const e2 = err;
10826
+ const explained = explainWithheldError(e2.message, opts.deviceParity === true);
10827
+ if (explained !== e2.message) {
10828
+ try {
10829
+ e2.message = explained;
10830
+ } catch {
10831
+ }
10832
+ }
10833
+ };
10791
10834
  const commitActionFailure = (def, err) => {
10792
10835
  const prev = def.state;
10793
10836
  if (!prev || typeof prev !== "object" || Array.isArray(prev)) return;
@@ -10818,6 +10861,7 @@ async function bootBundleWorker(bundleJs, opts) {
10818
10861
  const next = await Promise.race([Promise.resolve(fn2(def.state, ...args)), timeout]);
10819
10862
  applyResult(def, next);
10820
10863
  } catch (err) {
10864
+ explainActionError(err);
10821
10865
  commitActionFailure(def, err);
10822
10866
  throw err;
10823
10867
  } finally {
@@ -10833,6 +10877,7 @@ async function bootBundleWorker(bundleJs, opts) {
10833
10877
  def.state = entry.state;
10834
10878
  }
10835
10879
  if (entry.error !== void 0) {
10880
+ entry.error = explainWithheldError(entry.error, opts.deviceParity === true);
10836
10881
  commitActionFailure(def, entry.error);
10837
10882
  if (recordErrors && entry.reportError) errors.push({ service: entry.name, message: entry.error });
10838
10883
  continue;
@@ -12658,6 +12703,7 @@ var init_validate_descriptor_core = __esm({
12658
12703
  init_worker_subtree();
12659
12704
  init_raw_json_depth();
12660
12705
  init_realm_parity();
12706
+ init_realm_parity();
12661
12707
  CRAWL_BLOCKING_PASSES = /* @__PURE__ */ new Set([
12662
12708
  // A screen whose bindings do not resolve has no state to crawl.
12663
12709
  "bindings",
@@ -14241,6 +14287,7 @@ __export(validate_descriptor_exports, {
14241
14287
  RAW_JSON_MAX_DEPTH: () => RAW_JSON_MAX_DEPTH,
14242
14288
  SERVICE_ONLY_BINDING_PROPS: () => SERVICE_ONLY_BINDING_PROPS,
14243
14289
  WHOLE_VALUE_BINDING: () => WHOLE_VALUE_BINDING,
14290
+ allowlistSweepSource: () => allowlistSweepSource,
14244
14291
  appWorkerActionsFor: () => appWorkerActionsFor,
14245
14292
  bareNestedClass: () => bareNestedClass,
14246
14293
  bootBundleWorker: () => bootBundleWorker,
@@ -14253,6 +14300,7 @@ __export(validate_descriptor_exports, {
14253
14300
  discoverNativeActions: () => discoverNativeActions,
14254
14301
  dryRunBundle: () => dryRunBundle,
14255
14302
  enumFieldNames: () => enumFieldNames,
14303
+ explainWithheldError: () => explainWithheldError,
14256
14304
  extractBundleContract: () => extractBundleContract,
14257
14305
  extractBundleServices: () => extractBundleServices,
14258
14306
  findSkipDerive: () => findSkipDerive,
@@ -14285,7 +14333,6 @@ __export(validate_descriptor_exports, {
14285
14333
  setDefaultEvaluator: () => setDefaultEvaluator,
14286
14334
  topBarFindings: () => topBarFindings,
14287
14335
  validateScreenDescriptor: () => validateScreenDescriptor,
14288
- withheldGlobalsSource: () => withheldGlobalsSource,
14289
14336
  workerSubtreeAllowed: () => workerSubtreeAllowed
14290
14337
  });
14291
14338
  import { readFileSync as readFileSync15, existsSync as existsSync13, readdirSync as readdirSync11 } from "node:fs";
@@ -14387,8 +14434,9 @@ var init_validate_descriptor = __esm({
14387
14434
  nodeVmEvaluator = {
14388
14435
  run(code, sandbox, opts) {
14389
14436
  const context = createContext(sandbox);
14390
- const hideSource = withheldGlobalsSource((opts.hide ?? []).filter((name) => !(name in sandbox)));
14391
- if (hideSource) runInContext(hideSource, context, { filename: "himi-hide.js" });
14437
+ if (opts.deviceParity) {
14438
+ runInContext(allowlistSweepSource(Object.keys(sandbox)), context, { filename: "himi-sweep.js" });
14439
+ }
14392
14440
  const pins = pinnedIntrinsicsSource(opts);
14393
14441
  if (pins) {
14394
14442
  const pinned = runInContext(`(${pins})(Date, Math)`, context, { timeout: opts.timeoutMs, filename: "himi-pins.js" });
@@ -16127,6 +16175,10 @@ ${opts.liveTransport ? ` // Every action completion crosses as a RAW, ordered r
16127
16175
  // minimum local overlay needed for the worker's own subsequent reads; the host replays these
16128
16176
  // records through applyResult, which remains the authoritative merge/directive dialect.
16129
16177
  var actionBody = "";
16178
+ // The host bridges, captured into this closure: under deviceParity the closing sweep deletes
16179
+ // them from globalThis, so a bundle cannot call a bridge that exists on no device (#4537).
16180
+ var hostWixCall = globalThis.__himiWixCall;
16181
+ var hostDispatch = globalThis.__himiDispatch;
16130
16182
  var isArray = Array.isArray;
16131
16183
  var promiseResolve = Promise.resolve.bind(Promise);
16132
16184
  var promiseReject = Promise.reject.bind(Promise);
@@ -16375,7 +16427,7 @@ ${opts.liveTransport ? ` var handle = { getState: function () { return def
16375
16427
  call: function (method, path, body, headers) {
16376
16428
  var raw;
16377
16429
  try {
16378
- raw = __himiWixCall(
16430
+ raw = hostWixCall(
16379
16431
  String(method),
16380
16432
  String(path),
16381
16433
  stringify(body === undefined ? null : body),
@@ -16397,7 +16449,7 @@ ${opts.liveTransport ? ` var handle = { getState: function () { return def
16397
16449
  dispatch: function (action, params) {
16398
16450
  var raw;
16399
16451
  try {
16400
- raw = __himiDispatch(stringValue(action), stringify(params === undefined ? null : params));
16452
+ raw = hostDispatch(stringValue(action), stringify(params === undefined ? null : params));
16401
16453
  } catch (e) {
16402
16454
  return promiseReject(e instanceof Error ? e : new Error(stringValue(e)));
16403
16455
  }
@@ -16526,9 +16578,11 @@ ${opts.clock === void 0 ? "" : opts.freezeDate ? ` globalThis.Date = (${pinnedI
16526
16578
  return sweepPromise;
16527
16579
  },
16528
16580
  });` : ""}
16529
- // LAST, so nothing the prelude installed (the \`fetch\` stub) or the engine carries natively
16530
- // (QuickJS-ng 0.15's \`performance\`, \`queueMicrotask\`) survives deviceParity (#4511).
16531
- ${withheldGlobalsSource(opts.hide)}
16581
+ // LAST, under deviceParity: the realm sweeps its OWN globals against the worker allow-list
16582
+ // (#4537), so nothing the prelude installed (the \`fetch\` stub), nothing the engine carries
16583
+ // natively (QuickJS-ng 0.15's \`performance\`, \`queueMicrotask\`) and none of the host bridges
16584
+ // (\`__himiWixCall\`, \`__himiDispatch\` \u2014 captured into this closure above) survives.
16585
+ ${opts.deviceParity ? allowlistSweepSource() : ""}
16532
16586
  return ${opts.liveTransport ? "{ readback: readback, dispatch: dispatchAction, actions: readActions }" : "readback"};
16533
16587
  })();
16534
16588
  `;
@@ -16597,6 +16651,7 @@ async function createQuickJsEvaluator(options = {}) {
16597
16651
  clock: opts.clock ?? options.clock,
16598
16652
  freezeDate: opts.clock !== void 0,
16599
16653
  hide: opts.hide,
16654
+ deviceParity: opts.deviceParity === true,
16600
16655
  ...opts.seed === void 0 ? {} : { seed: opts.seed },
16601
16656
  ...opts.mirrorRandom ? { mirrorRandom: true } : {}
16602
16657
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1423.0",
3
+ "version": "0.1424.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": [
@@ -71,5 +71,5 @@
71
71
  "artifactId": "himalaya-cli"
72
72
  }
73
73
  },
74
- "falconPackageHash": "843d4fd1bc22694e9fd665efd8f59bb6fd4e4e9aa78612885a3ce661"
74
+ "falconPackageHash": "a0147b33ea7375fa7cf11b0027a0388feef592ede284346c3d5c9919"
75
75
  }