@wix/himalaya-cli 0.1018.0 → 0.1019.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
@@ -5345,6 +5345,7 @@ function walk(node, registry, path2, out) {
5345
5345
  var SYSTEM_FONT_FAMILY;
5346
5346
  var init_tokens = __esm({
5347
5347
  "../../core/ts/src/tokens.ts"() {
5348
+ "use strict";
5348
5349
  SYSTEM_FONT_FAMILY = "$system";
5349
5350
  }
5350
5351
  });
@@ -19815,6 +19816,7 @@ function shouldRevealError(args) {
19815
19816
  var EMAIL_RE, URL_HOST_RE, INTEGER_RE, NUMBER_RE;
19816
19817
  var init_validation = __esm({
19817
19818
  "../../core/ts/src/validation.ts"() {
19819
+ "use strict";
19818
19820
  EMAIL_RE = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}$/;
19819
19821
  URL_HOST_RE = /^[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(:[0-9]+)?$/;
19820
19822
  INTEGER_RE = /^[+-]?[0-9]+$/;
@@ -23239,6 +23241,7 @@ function validateWorkerSubtree(raw, slotId, policy, actionCatalog) {
23239
23241
  var WORKER_SUBTREE_CEILINGS, ID_PART, ACTION_ID;
23240
23242
  var init_worker_subtree = __esm({
23241
23243
  "../../core/ts/src/worker-subtree.ts"() {
23244
+ "use strict";
23242
23245
  init_worker_subtree_safe_types_generated();
23243
23246
  WORKER_SUBTREE_CEILINGS = Object.freeze({
23244
23247
  maxEncodedBytes: 65536,
@@ -46474,7 +46477,7 @@ var init_assets = __esm({
46474
46477
  async function checkPinnedRead(input) {
46475
46478
  const { secret, token, app, releaseId, screenId, authorizePreview } = input;
46476
46479
  if (!secret) return authorizePreview ? { status: 503, body: { error: "preview_token_unavailable" } } : null;
46477
- if (!token) return await input.isLive() ? null : { status: 401, body: { error: "preview_token_required", app, releaseId } };
46480
+ if (!token) return await input.isPublic() ? null : { status: 401, body: { error: "preview_token_required", app, releaseId } };
46478
46481
  const verified = await verifyPreviewToken({ token, secret, app, releaseId, screenId });
46479
46482
  if (verified.ok) {
46480
46483
  if (authorizePreview ? !await authorizePreview(verified.claims) : !!verified.claims.siteLease) {
@@ -46756,9 +46759,30 @@ function makeServeHandler(opts) {
46756
46759
  function resolvePin(request, url) {
46757
46760
  return request.headers.get("x-himalaya-release") || url.searchParams.get("release") || null;
46758
46761
  }
46762
+ const RELEASE_SOURCE_HEADER = "x-himalaya-release-source";
46759
46763
  function resolvePreviewToken(request, url) {
46760
46764
  return request.headers.get("x-himalaya-preview-token") || url.searchParams.get("pvt") || null;
46761
46765
  }
46766
+ const RING_CACHE_CAP = 500;
46767
+ const ringCache = /* @__PURE__ */ new Map();
46768
+ async function isRingRelease(app, releaseId) {
46769
+ if (!opts.ringReleases) return false;
46770
+ const hit = ringCache.get(app);
46771
+ let ids = hit && Date.now() - hit.at < manifestCacheTtlMs ? hit.ids : void 0;
46772
+ if (!ids) {
46773
+ try {
46774
+ ids = new Set(await opts.ringReleases(app));
46775
+ } catch {
46776
+ ids = /* @__PURE__ */ new Set();
46777
+ }
46778
+ if (!ringCache.has(app) && ringCache.size >= RING_CACHE_CAP) {
46779
+ const oldest = ringCache.keys().next().value;
46780
+ if (oldest !== void 0) ringCache.delete(oldest);
46781
+ }
46782
+ ringCache.set(app, { ids, at: Date.now() });
46783
+ }
46784
+ return ids.has(releaseId);
46785
+ }
46762
46786
  async function pinnedManifest(app, releaseId) {
46763
46787
  const key2 = `${app}
46764
46788
  ${releaseId}`;
@@ -46843,11 +46867,40 @@ ${releaseId}`;
46843
46867
  app,
46844
46868
  releaseId,
46845
46869
  screenId,
46846
- isLive: async () => (await manifest(app))?.releaseId === releaseId,
46870
+ isPublic: async () => (await manifest(app))?.releaseId === releaseId || await isRingRelease(app, releaseId),
46847
46871
  authorizePreview: opts.authorizePreview
46848
46872
  });
46849
46873
  return denied && json3(denied.status, denied.body);
46850
46874
  }
46875
+ async function honourRingPin(request) {
46876
+ const kept = { request, dropped: false };
46877
+ if (request.method !== "GET" && request.method !== "HEAD") return kept;
46878
+ if (request.headers.get(RELEASE_SOURCE_HEADER) !== "ring") return kept;
46879
+ const pin = request.headers.get("x-himalaya-release");
46880
+ if (!pin) return kept;
46881
+ const url = new URL(request.url);
46882
+ const app = /^\/v1\/app-config\/([^/]+)$/.exec(url.pathname)?.[1] ?? resolveApp(request, url);
46883
+ if (!app) return kept;
46884
+ const drop = () => {
46885
+ const headers2 = new Headers(request.headers);
46886
+ headers2.delete("x-himalaya-release");
46887
+ headers2.delete(RELEASE_SOURCE_HEADER);
46888
+ return { request: new Request(request, { headers: headers2 }), dropped: true };
46889
+ };
46890
+ if (/^\/v1\/app-config\/[^/]+$/.test(url.pathname)) return drop();
46891
+ let servable;
46892
+ try {
46893
+ const live2 = await manifest(app);
46894
+ const eligible = live2?.releaseId === pin || await isRingRelease(app, pin);
46895
+ const pinned = eligible ? await pinnedManifest(app, pin) : null;
46896
+ servable = pinned !== null;
46897
+ const screenId = /^\/v1\/screen\/([^/]+)$/.exec(url.pathname)?.[1];
46898
+ if (servable && screenId && !pinned?.screens[screenId]) servable = false;
46899
+ } catch {
46900
+ return kept;
46901
+ }
46902
+ return servable ? kept : drop();
46903
+ }
46851
46904
  const corsHeaders = (request) => {
46852
46905
  const origin = request.headers.get("origin");
46853
46906
  if (!origin) return {};
@@ -46856,7 +46909,7 @@ ${releaseId}`;
46856
46909
  "access-control-allow-origin": origin,
46857
46910
  vary: "Origin",
46858
46911
  "access-control-allow-methods": "GET, HEAD, POST, PUT, DELETE, OPTIONS",
46859
- "access-control-allow-headers": "Content-Type, If-None-Match, X-Himalaya-Schema-Versions, Accept-Language, X-Himalaya-Session, X-Himalaya-User, X-Himalaya-Platform, X-Himalaya-App-Version, X-Himalaya-App, X-Himalaya-Release, X-Himalaya-Preview-Token",
46912
+ "access-control-allow-headers": "Content-Type, If-None-Match, X-Himalaya-Schema-Versions, Accept-Language, X-Himalaya-Session, X-Himalaya-User, X-Himalaya-Platform, X-Himalaya-App-Version, X-Himalaya-App, X-Himalaya-Release, X-Himalaya-Release-Source, X-Himalaya-Preview-Token",
46860
46913
  "access-control-expose-headers": "ETag, X-Himalaya-Bundle-Integrity, X-Himalaya-App",
46861
46914
  "access-control-allow-credentials": "true"
46862
46915
  };
@@ -47396,7 +47449,8 @@ ${releaseId}`;
47396
47449
  }
47397
47450
  const mm = m;
47398
47451
  const readDoc = (hash, live2) => pin ? hash ? pinnedBody(app, hash, live2) : Promise.resolve(null) : live2();
47399
- const cfgBytes = await readDoc(mm.appConfigHash, () => store.getAppConfig(app));
47452
+ const ringPinned = pin !== null && request.headers.get(RELEASE_SOURCE_HEADER) === "ring";
47453
+ const cfgBytes = ringPinned ? await store.getAppConfig(app) : await readDoc(mm.appConfigHash, () => store.getAppConfig(app));
47400
47454
  if (!cfgBytes) return json3(404, { error: "app_config_not_found", app });
47401
47455
  let appConfig;
47402
47456
  try {
@@ -47404,7 +47458,7 @@ ${releaseId}`;
47404
47458
  } catch {
47405
47459
  return json3(500, { error: "app_config_invalid", app });
47406
47460
  }
47407
- const bootOverlay = !pin && opts.devControl ? devControlOverlay.get(app) : void 0;
47461
+ const bootOverlay = (!pin || ringPinned) && opts.devControl ? devControlOverlay.get(app) : void 0;
47408
47462
  if (bootOverlay) appConfig.control = { ...appConfig.control ?? {}, ...bootOverlay };
47409
47463
  const tokensBytes = await readDoc(mm.tokensHash, () => store.getTokens(app));
47410
47464
  let tokens = null;
@@ -47421,9 +47475,18 @@ ${releaseId}`;
47421
47475
  let screen = null;
47422
47476
  let screenHash = "";
47423
47477
  let homeBundle = null;
47424
- const homeMeta = homeScreenId ? mm.screens[homeScreenId] : void 0;
47478
+ let homeFrom = mm;
47479
+ let readHome = readDoc;
47480
+ if (ringPinned && homeScreenId && !mm.screens[homeScreenId]) {
47481
+ const live2 = await manifest(app);
47482
+ if (live2?.screens[homeScreenId]) {
47483
+ homeFrom = live2;
47484
+ readHome = (_hash, liveSlot) => liveSlot();
47485
+ }
47486
+ }
47487
+ const homeMeta = homeScreenId ? homeFrom.screens[homeScreenId] : void 0;
47425
47488
  if (homeScreenId && homeMeta) {
47426
- const body = await readDoc(homeMeta.descriptorHash, () => store.getScreen(app, homeScreenId));
47489
+ const body = await readHome(homeMeta.descriptorHash, () => store.getScreen(app, homeScreenId));
47427
47490
  if (body) {
47428
47491
  try {
47429
47492
  screen = JSON.parse(utf8Decode(body));
@@ -47433,7 +47496,7 @@ ${releaseId}`;
47433
47496
  }
47434
47497
  }
47435
47498
  if (homeMeta.bundle) {
47436
- const entry = mm.bundles[homeMeta.bundle];
47499
+ const entry = homeFrom.bundles[homeMeta.bundle];
47437
47500
  if (entry?.sha256 && entry?.sri) {
47438
47501
  homeBundle = {
47439
47502
  sha256: entry.sha256,
@@ -47443,9 +47506,10 @@ ${releaseId}`;
47443
47506
  }
47444
47507
  }
47445
47508
  }
47446
- const etag = strongEtag(`${mm.releaseId}:${mm.appConfigHash ?? ""}:${mm.tokensHash ?? ""}:${screenHash}:${homeBundle?.sha256 ?? ""}`);
47447
- const cache = pin ? PINNED_CACHE_CONTROL : DOC_CACHE_CONTROL;
47448
- const vary = pin ? { vary: "x-himalaya-release" } : {};
47509
+ const cfgTag = ringPinned ? sha256hex(JSON.stringify(appConfig)) : mm.appConfigHash ?? "";
47510
+ const etag = strongEtag(`${mm.releaseId}:${cfgTag}:${mm.tokensHash ?? ""}:${screenHash}:${homeBundle?.sha256 ?? ""}`);
47511
+ const cache = pin && !ringPinned ? PINNED_CACHE_CONTROL : DOC_CACHE_CONTROL;
47512
+ const vary = pin ? { vary: ringPinned ? `x-himalaya-release, ${RELEASE_SOURCE_HEADER}` : "x-himalaya-release" } : {};
47449
47513
  if (request.headers.get("if-none-match") === etag) {
47450
47514
  return new Response(null, { status: 304, headers: { etag, "cache-control": cache, ...vary } });
47451
47515
  }
@@ -47626,7 +47690,14 @@ ${releaseId}`;
47626
47690
  if (request.method === "OPTIONS") {
47627
47691
  return new Response(null, { status: 204, headers: { ...corsHeaders(request), "content-length": "0" } });
47628
47692
  }
47629
- const response = await handle(request);
47693
+ const ring = await honourRingPin(request);
47694
+ const response = await handle(ring.request);
47695
+ if (ring.dropped) {
47696
+ const parts = new Set(
47697
+ [...response.headers.get("vary")?.split(",") ?? [], "x-himalaya-release", RELEASE_SOURCE_HEADER].map((s) => s.trim()).filter(Boolean)
47698
+ );
47699
+ response.headers.set("vary", [...parts].join(", "));
47700
+ }
47630
47701
  if (resolvePreviewToken(request, new URL(request.url))) {
47631
47702
  response.headers.set("cache-control", "private, no-store");
47632
47703
  response.headers.set("vary", "x-himalaya-preview-token, x-himalaya-release");
@@ -47996,19 +48067,19 @@ var init_preview_assets_generated = __esm({
47996
48067
  "../../packages/serve/src/preview-assets.generated.ts"() {
47997
48068
  init_preview_assets_format();
47998
48069
  PREVIEW_ASSET_MANIFEST = [
47999
- { key: "assets/index-DRerTUYc.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 1016478, sha256: "42a5b901a0a58a495e5261f68782d28d12aa95cf64df33d9d8d14236e8ea6ead" },
48000
- { key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 1016486, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
48001
- { key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 1107410, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
48002
- { key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 1198394, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
48003
- { key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 1289374, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
48004
- { key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 1380246, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
48005
- { key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 1471226, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
48006
- { key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 1579862, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
48007
- { key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 1688946, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
48008
- { key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 1797994, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
48009
- { key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 1905694, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
48010
- { key: "index.html", contentType: "text/html; charset=utf-8", offset: 1993802, length: 4448, sha256: "98239860f1289aebffdb28d2b9f5ce15fbb95a657bb63d262c650ca21513dde3" },
48011
- { key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 1998250, length: 17209, sha256: "dffc9718e2faa63ae2cc919e0a842f585ed565aaaa7c53778e90379442c731b6" }
48070
+ { key: "assets/index-Bsi3iDy5.js", contentType: "application/javascript; charset=utf-8", offset: 8, length: 1018562, sha256: "8487d8635f18c5a32f124ebc217f0570d5b8242ac964de661fa0644b80843116" },
48071
+ { key: "fonts/WixMadeforDisplay-Bold.ttf", contentType: "font/ttf", offset: 1018570, length: 90924, sha256: "ec4c7d63772d980d6e147b2df6215fd2737e4b04cebe0cf7e11dc695fb63cdcf" },
48072
+ { key: "fonts/WixMadeforDisplay-ExtraBold.ttf", contentType: "font/ttf", offset: 1109494, length: 90984, sha256: "bf4c16a2774edd38a921edf3099469866cd74c094fd596f3fa4e81f54a04dfaa" },
48073
+ { key: "fonts/WixMadeforDisplay-Medium.ttf", contentType: "font/ttf", offset: 1200478, length: 90980, sha256: "368faca44fb9f7207e4af784e94750b1ee59c1098b8689e0f4a918926f244fb5" },
48074
+ { key: "fonts/WixMadeforDisplay-Regular.ttf", contentType: "font/ttf", offset: 1291458, length: 90872, sha256: "97ed8f1a6772abe26e3d8af5cecfc4b02faa94497d585b0398b5053b739a70c1" },
48075
+ { key: "fonts/WixMadeforDisplay-SemiBold.ttf", contentType: "font/ttf", offset: 1382330, length: 90980, sha256: "642feab8a48ddf6c7a89d7c2a7c0edfa0e6e773f671287e460e222703563191e" },
48076
+ { key: "fonts/WixMadeforText-Bold.ttf", contentType: "font/ttf", offset: 1473310, length: 108636, sha256: "37c179b4fefb63ea9637322b84583a2df53aa226c150294eea1675c14b1b8e29" },
48077
+ { key: "fonts/WixMadeforText-ExtraBold.ttf", contentType: "font/ttf", offset: 1581946, length: 109084, sha256: "62e2fe4718129f36ecdb0ae4de385bd6b81ecc876146447167c6c140fad699a9" },
48078
+ { key: "fonts/WixMadeforText-Medium.ttf", contentType: "font/ttf", offset: 1691030, length: 109048, sha256: "4ecf270136af928612c76fe4ebade91d8156975e5ea4c0cf9225501dd1788e02" },
48079
+ { key: "fonts/WixMadeforText-Regular.ttf", contentType: "font/ttf", offset: 1800078, length: 107700, sha256: "dee56f09fd3efc127c1ea95557edc74110c1460a46287da36e0af25efd341ef5" },
48080
+ { key: "fonts/WixMadeforText-SemiBold.ttf", contentType: "font/ttf", offset: 1907778, length: 88108, sha256: "dced97a77624bc5f8b1ae65850360908297f4588e09feb6f22792d29dc7e765b" },
48081
+ { key: "index.html", contentType: "text/html; charset=utf-8", offset: 1995886, length: 4448, sha256: "60540583e7c95a5564940f1f05510886f0f59a6ec612af78881031a5e9c04b9a" },
48082
+ { key: "t5-frame.html", contentType: "text/html; charset=utf-8", offset: 2000334, length: 17209, sha256: "dffc9718e2faa63ae2cc919e0a842f585ed565aaaa7c53778e90379442c731b6" }
48012
48083
  ];
48013
48084
  }
48014
48085
  });
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/himalaya-cli",
3
- "version": "0.1018.0",
3
+ "version": "0.1019.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": "94fed53fcfc6d8dbb2472ab3ebd2f6fc24d2cbe457604bc1f3601f2d"
68
+ "falconPackageHash": "1bc07d659f8a5254f7afe76b39faf5f6d53dff12518cfd6257039a78"
69
69
  }