@wix/himalaya-cli 0.1640.0 → 0.1641.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1640.0",
3
+ "version": "0.1641.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": [
@@ -72,5 +72,5 @@
72
72
  "artifactId": "himalaya-cli"
73
73
  }
74
74
  },
75
- "falconPackageHash": "3b191ba213c74f26a02bc55c55d4c8e53cfb05b1b366874fbfc8dbac"
75
+ "falconPackageHash": "7af626ee21c1652fe37958bdb1e4a724c37de914dc7ddbfe1f6c15be"
76
76
  }
@@ -229,7 +229,11 @@ function resolveCollection(arg: unknown): CmsCollectionDefinition | undefined {
229
229
  return id ? list.find((candidate) => candidate.id === id) : undefined;
230
230
  }
231
231
 
232
- let loadingCollectionId = "";
232
+ // The in-flight load, keyed by collection. A second load() for the same collection JOINS it and
233
+ // resolves to its result — it must not return the stale `loading` state it was handed, because the
234
+ // module-scope boot load starts first and the host's onAppear load (what `himi render --live`
235
+ // awaits before reading state) arrives while it is still running.
236
+ let inflight: { id: string; promise: Promise<State> } | null = null;
233
237
 
234
238
  const svc = defineService<State, {
235
239
  load: (state: State, arg?: unknown) => Promise<State>;
@@ -245,8 +249,8 @@ const svc = defineService<State, {
245
249
  if (!collection) return { ...state, status: "error", isLoading: false, notLoading: true, isErrored: true, notErrored: false, errorText: copyParam("cmsCollection.notConfiguredError", "This collection is not configured for the app.") };
246
250
  const force = argValue(arg, "force") === "1";
247
251
  if (!force && state.collectionId === collection.id && state.status === "ready") return state;
248
- if (!force && loadingCollectionId === collection.id) return state;
249
- loadingCollectionId = collection.id;
252
+ if (!force && inflight && inflight.id === collection.id) return inflight.promise;
253
+ const run = (async (): Promise<State> => {
250
254
  // Last-synced items for THIS collection (offline-safe; empty on first-ever run).
251
255
  const cached = await readCached(collection.id);
252
256
  try {
@@ -278,9 +282,11 @@ const svc = defineService<State, {
278
282
  ? copyParam("cmsCollection.memberSignInError", "Sign in from Profile to view this member collection.")
279
283
  : copyParam("cmsCollection.unavailableError", "This collection is temporarily unavailable."),
280
284
  };
281
- } finally {
282
- loadingCollectionId = "";
283
285
  }
286
+ })();
287
+ const entry = { id: collection.id, promise: run };
288
+ inflight = entry;
289
+ try { return await run; } finally { if (inflight === entry) inflight = null; }
284
290
  },
285
291
  search: (state, arg) => {
286
292
  const query = argValue(arg, "value").trim().toLowerCase();
@@ -229,7 +229,11 @@ function resolveCollection(arg: unknown): CmsCollectionDefinition | undefined {
229
229
  return id ? list.find((candidate) => candidate.id === id) : undefined;
230
230
  }
231
231
 
232
- let loadingCollectionId = "";
232
+ // The in-flight load, keyed by collection. A second load() for the same collection JOINS it and
233
+ // resolves to its result — it must not return the stale `loading` state it was handed, because the
234
+ // module-scope boot load starts first and the host's onAppear load (what `himi render --live`
235
+ // awaits before reading state) arrives while it is still running.
236
+ let inflight: { id: string; promise: Promise<State> } | null = null;
233
237
 
234
238
  const svc = defineService<State, {
235
239
  load: (state: State, arg?: unknown) => Promise<State>;
@@ -245,8 +249,8 @@ const svc = defineService<State, {
245
249
  if (!collection) return { ...state, status: "error", isLoading: false, notLoading: true, isErrored: true, notErrored: false, errorText: copyParam("cmsCollection.notConfiguredError", "This collection is not configured for the app.") };
246
250
  const force = argValue(arg, "force") === "1";
247
251
  if (!force && state.collectionId === collection.id && state.status === "ready") return state;
248
- if (!force && loadingCollectionId === collection.id) return state;
249
- loadingCollectionId = collection.id;
252
+ if (!force && inflight && inflight.id === collection.id) return inflight.promise;
253
+ const run = (async (): Promise<State> => {
250
254
  // Last-synced items for THIS collection (offline-safe; empty on first-ever run).
251
255
  const cached = await readCached(collection.id);
252
256
  try {
@@ -278,9 +282,11 @@ const svc = defineService<State, {
278
282
  ? copyParam("cmsCollection.memberSignInError", "Sign in from Profile to view this member collection.")
279
283
  : copyParam("cmsCollection.unavailableError", "This collection is temporarily unavailable."),
280
284
  };
281
- } finally {
282
- loadingCollectionId = "";
283
285
  }
286
+ })();
287
+ const entry = { id: collection.id, promise: run };
288
+ inflight = entry;
289
+ try { return await run; } finally { if (inflight === entry) inflight = null; }
284
290
  },
285
291
  search: (state, arg) => {
286
292
  const query = argValue(arg, "value").trim().toLowerCase();