@wix/himalaya-cli 0.1042.0 → 0.1043.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 +37 -10
  2. package/package.json +2 -2
package/dist/cli.mjs CHANGED
@@ -33630,11 +33630,13 @@ async function readBody2(req) {
33630
33630
  function makeEtag(body) {
33631
33631
  return `"${createHash16("sha256").update(body).digest("hex").slice(0, 32)}"`;
33632
33632
  }
33633
+ function servedTokensPath(app) {
33634
+ return app.module.designTokensPath ?? resolve31(app.dir, app.module.config.designTokensPath ?? "tokens.json");
33635
+ }
33633
33636
  function readAppTokens(state) {
33634
33637
  if (!state.app) return null;
33635
33638
  try {
33636
- const tokenPath = state.app.module.designTokensPath ?? resolve31(state.app.dir, state.app.module.config.designTokensPath ?? "tokens.json");
33637
- const parsed = JSON.parse(readFileSync41(tokenPath, "utf8"));
33639
+ const parsed = JSON.parse(readFileSync41(servedTokensPath(state.app), "utf8"));
33638
33640
  delete parsed._meta;
33639
33641
  return parsed;
33640
33642
  } catch {
@@ -34503,13 +34505,17 @@ async function reloadAppModuleNow(state, opts) {
34503
34505
  state.moduleStore = next.createStore(current.name);
34504
34506
  }
34505
34507
  state.serverCache.clear();
34506
- const screenIds = [.../* @__PURE__ */ new Set([...oldMeta.screenIds, ...state.app.meta.screenIds])];
34507
- publishSSE(state, "screen.invalidated", { screenIds, reason: opts.reason });
34508
+ if (opts.invalidateScreens !== false) {
34509
+ const screenIds = [.../* @__PURE__ */ new Set([...oldMeta.screenIds, ...state.app.meta.screenIds])];
34510
+ publishSSE(state, "screen.invalidated", { screenIds, reason: opts.reason });
34511
+ }
34508
34512
  const newNav = JSON.stringify(deriveNavigationConfig(state.app.meta) ?? null);
34509
34513
  if (oldNav !== newNav) {
34510
34514
  publishSSE(state, "config.invalidated", { reason: opts.reason, at: Date.now() });
34511
34515
  }
34512
- if (idiomOf(next) !== oldIdiom) {
34516
+ const tokensHash = servedTokensHash(state.app);
34517
+ if (idiomOf(next) !== oldIdiom || tokensHash !== state.announcedTokensHash) {
34518
+ state.announcedTokensHash = tokensHash;
34513
34519
  publishSSE(state, "tokens.changed", { reason: opts.reason, at: Date.now() });
34514
34520
  }
34515
34521
  console.log(`[himalaya-dev] reloaded app module in-process: ${current.name} (${opts.reason})`);
@@ -34525,6 +34531,17 @@ async function reloadAppModuleNow(state, opts) {
34525
34531
  }
34526
34532
  }
34527
34533
  }
34534
+ function tokensAreDerived(state) {
34535
+ if (!state.app) return false;
34536
+ return resolve31(servedTokensPath(state.app)) !== resolve31(state.app.dir, "tokens.json");
34537
+ }
34538
+ function servedTokensHash(app) {
34539
+ try {
34540
+ return createHash16("sha256").update(readFileSync41(servedTokensPath(app))).digest("hex");
34541
+ } catch {
34542
+ return "";
34543
+ }
34544
+ }
34528
34545
  function classifyAppPath(rel) {
34529
34546
  if (!rel || rel.startsWith("..")) return null;
34530
34547
  if (rel === "tokens.json") return "tokens";
@@ -34550,21 +34567,30 @@ function startAppSourceWatcher(state) {
34550
34567
  pending.clear();
34551
34568
  if (paths.length === 0) return;
34552
34569
  const kinds = new Set(paths.map(classifyAppPath));
34553
- if (kinds.has("tokens")) {
34554
- publishSSE(state, "tokens.changed", { reason: "file_changed", at: Date.now() });
34555
- }
34570
+ const tokensNeedReload = kinds.has("tokens") && tokensAreDerived(state);
34556
34571
  if (kinds.has("appconfig")) {
34557
34572
  publishSSE(state, "config.invalidated", { reason: "file_changed", at: Date.now() });
34558
34573
  }
34559
- if (kinds.has("module")) {
34574
+ if (kinds.has("module") || tokensNeedReload) {
34560
34575
  reloading = true;
34561
34576
  const recreateStore = paths.some((p) => p.startsWith("data/") || p.startsWith("seed/"));
34562
34577
  try {
34563
- await reloadAppModule(state, { reason: "source_changed", recreateStore });
34578
+ await reloadAppModule(state, {
34579
+ reason: kinds.has("module") ? "source_changed" : "tokens_changed",
34580
+ recreateStore,
34581
+ invalidateScreens: kinds.has("module")
34582
+ });
34564
34583
  } finally {
34565
34584
  reloading = false;
34566
34585
  }
34567
34586
  }
34587
+ if (kinds.has("tokens") && state.app) {
34588
+ const tokensHash = servedTokensHash(state.app);
34589
+ if (tokensHash !== state.announcedTokensHash) {
34590
+ state.announcedTokensHash = tokensHash;
34591
+ publishSSE(state, "tokens.changed", { reason: "file_changed", at: Date.now() });
34592
+ }
34593
+ }
34568
34594
  };
34569
34595
  try {
34570
34596
  const watcher2 = watch(appDir2, { persistent: false, recursive: true }, (_event, filename) => {
@@ -36003,6 +36029,7 @@ function createDevServer(opts = {}) {
36003
36029
  if (state.hotReloadEnabled) {
36004
36030
  state.bundleWatcher = startBundleArtifactWatcher(state);
36005
36031
  state.bundleSourceWatcher = startBundleSourceWatcher(state);
36032
+ if (state.app) state.announcedTokensHash = servedTokensHash(state.app);
36006
36033
  state.appWatcher = startAppSourceWatcher(state);
36007
36034
  }
36008
36035
  const handleRequest = (req, res) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1042.0",
3
+ "version": "0.1043.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": [
@@ -65,5 +65,5 @@
65
65
  "artifactId": "himalaya-cli"
66
66
  }
67
67
  },
68
- "falconPackageHash": "d80f9cca0922b2f864a60197972f9e23f2e17ddc1e40669cdf7a63a6"
68
+ "falconPackageHash": "a5e6e48bed44a158e954ca18b52ebff9ef438aac9078851aa8034c92"
69
69
  }