@fayz-ai/storefront 0.82.0 → 0.83.1

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 (36) hide show
  1. package/dist/analytics/meta-pixel.d.ts.map +1 -1
  2. package/dist/analytics/posthog.d.ts +3 -0
  3. package/dist/analytics/posthog.d.ts.map +1 -1
  4. package/dist/app/router.d.ts +2 -2
  5. package/dist/chunk-4REZOGGW.js +153 -0
  6. package/dist/chunk-4REZOGGW.js.map +1 -0
  7. package/dist/{chunk-UJHCVRK3.js → chunk-7N5HKQBM.js} +2 -2
  8. package/dist/{chunk-UJHCVRK3.js.map → chunk-7N5HKQBM.js.map} +1 -1
  9. package/dist/{chunk-GI5BTJK6.js → chunk-G2R6OJQA.js} +4 -4
  10. package/dist/{chunk-GI5BTJK6.js.map → chunk-G2R6OJQA.js.map} +1 -1
  11. package/dist/{chunk-RYWQGQ4M.js → chunk-OV6DVQMB.js} +128 -115
  12. package/dist/chunk-OV6DVQMB.js.map +1 -0
  13. package/dist/components/delivery/StoreCover.d.ts +0 -17
  14. package/dist/components/delivery/StoreCover.d.ts.map +1 -1
  15. package/dist/document/config.d.ts +7 -5
  16. package/dist/document/config.d.ts.map +1 -1
  17. package/dist/edge.d.ts +1 -1
  18. package/dist/edge.d.ts.map +1 -1
  19. package/dist/edge.js +16 -26
  20. package/dist/edge.js.map +1 -1
  21. package/dist/experiments/assign.d.ts +41 -53
  22. package/dist/experiments/assign.d.ts.map +1 -1
  23. package/dist/experiments/react.d.ts +4 -3
  24. package/dist/experiments/react.d.ts.map +1 -1
  25. package/dist/host/edge-handler.d.ts +15 -12
  26. package/dist/host/edge-handler.d.ts.map +1 -1
  27. package/dist/host.js +4 -4
  28. package/dist/index.js +7 -7
  29. package/dist/lib/theme.d.ts +2 -0
  30. package/dist/lib/theme.d.ts.map +1 -1
  31. package/dist/render.js +4 -4
  32. package/dist/tanstack.js +3 -3
  33. package/package.json +4 -4
  34. package/dist/chunk-746BEU7H.js +0 -160
  35. package/dist/chunk-746BEU7H.js.map +0 -1
  36. package/dist/chunk-RYWQGQ4M.js.map +0 -1
@@ -1,21 +1,4 @@
1
1
  import React from 'react';
2
- /**
3
- * A capa: quem é a loja, se está aberta, e como o pedido chega.
4
- *
5
- * As três perguntas na ordem em que se pergunta, e todas ACIMA do primeiro
6
- * item. É o padrão que os cinco produtos medidos compartilham
7
- * (`docs/artorius/delivery-reference/patterns/`), e não é estética: o modo de
8
- * entrega muda o preço e o prazo de tudo que vem depois. Perguntar embaixo é
9
- * deixar a pessoa montar o carrinho com números que ainda vão mudar.
10
- *
11
- * O estado fica INLINE com o nome — "● Aberto até 22:40" — e não atrás de um
12
- * modal. O horário de fechar é parte do estado: "aberto" às 22:35 e "aberto"
13
- * às 14:00 são informações diferentes para quem vai pedir.
14
- *
15
- * Fundo escuro fixo, e não um token de tema: existe uma foto atrás, e um texto
16
- * que troca de cor com o tema fica ilegível em metade das capas. Sem foto, a
17
- * mesma faixa escura — o cabeçalho nunca depende de haver imagem.
18
- */
19
2
  export declare function StoreCover({ onShowHours, onOpenAccount }: {
20
3
  onShowHours?: () => void;
21
4
  /** The account drawer (AccountDrawer). Absent, no account button is drawn. */
@@ -1 +1 @@
1
- {"version":3,"file":"StoreCover.d.ts","sourceRoot":"","sources":["../../../src/components/delivery/StoreCover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAazB;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE;IACzD,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;CAC3B,qBAwJA"}
1
+ {"version":3,"file":"StoreCover.d.ts","sourceRoot":"","sources":["../../../src/components/delivery/StoreCover.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAkCzB,wBAAgB,UAAU,CAAC,EAAE,WAAW,EAAE,aAAa,EAAE,EAAE;IACzD,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,8EAA8E;IAC9E,aAAa,CAAC,EAAE,MAAM,IAAI,CAAA;CAC3B,qBA0KA"}
@@ -239,11 +239,13 @@ export interface StorefrontConfig {
239
239
  */
240
240
  delivery?: StorefrontDeliveryConfig;
241
241
  /**
242
- * The A/B tests this store runs, by PostHog flag key. Each one is a
243
- * multivariate flag (and a PostHog Experiment over it); the edge assigns the
244
- * variant before render, and any setting typed `Experimental<…>`, any
245
- * `experiment` block or any `useExperiment(key)` call reads it. A key not
246
- * declared here is always 'control'. See docs/storefront/EXPERIMENTS.md.
242
+ * The A/B tests this store runs, by PostHog flag key. This is the source of
243
+ * truth for who sees what: the edge buckets each visitor locally with
244
+ * PostHog's hashing, before render, and any setting typed `Experimental<…>`,
245
+ * any `experiment` block or any `useExperiment(key)` call reads it. The
246
+ * PostHog Experiment on the same key reads the results. A key not declared,
247
+ * or not `status: 'running'`, is always 'control'. See
248
+ * docs/storefront/EXPERIMENTS.md.
247
249
  */
248
250
  experiments?: Record<string, StorefrontExperiment>;
249
251
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/document/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACxE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAA;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;A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AAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,SAAS,CAAA;CACnD;AAUD,wBAAgB,aAAa,CAAC,MAAM,EAAE,gBAAgB,GAAG,wBAAwB,CA2GhF;AAID,eAAO,MAAM,wBAAwB,iDAAmC,CAAA;AAExE,wBAAgB,mBAAmB,IAAI,wBAAwB,CAI9D;AAED,wBAAgB,2BAA2B,IAAI,wBAAwB,GAAG,IAAI,CAE7E;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,wBAAwB,GAAG,oBAAoB,CAE9F"}
package/dist/edge.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { posthogProxy, isPostHogProxyPath, type PostHogProxyOptions } from './analytics/edge';
2
2
  export { createStorefrontEdge, serveStorageImage, isStorageRequest, imageFormatKey, edgeCacheKey, edgeCacheable, assignForRequest, type StorefrontEdgeOptions, type StorefrontEdgeExperiments, } from './host/edge-handler';
3
- export { evaluateExperiments, isBotUserAgent, readVisitorId, visitorCookie, experimentCacheSuffix, encodeExperimentHeader, decodeExperimentHeader, validateExperiments, EXPERIMENT_HEADER, VISITOR_COOKIE, CONTROL, type ExperimentAssignments, type ExperimentAssignment, type StorefrontExperiment, } from './experiments/assign';
3
+ export { assignExperiments, posthogHash, posthogVariant, inPosthogRollout, experimentVariantTable, runningExperiments, isBotUserAgent, readVisitorId, visitorCookie, experimentCacheSuffix, encodeExperimentHeader, decodeExperimentHeader, validateExperiments, EXPERIMENT_HEADER, VISITOR_COOKIE, CONTROL, type ExperimentAssignments, type ExperimentAssignment, type StorefrontExperiment, } from './experiments/assign';
4
4
  //# sourceMappingURL=edge.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"edge.d.ts","sourceRoot":"","sources":["../src/edge.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACd,aAAa,EACb,aAAa,EACb,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,GAC1B,MAAM,sBAAsB,CAAA"}
package/dist/edge.js CHANGED
@@ -1,5 +1,5 @@
1
- import { NO_ASSIGNMENTS, isBotUserAgent, readVisitorId, visitorCookie, readAssignmentCookie, experimentCacheSuffix, evaluateExperiments, assignmentCookie, EXPERIMENT_HEADER, encodeExperimentHeader } from './chunk-746BEU7H.js';
2
- export { CONTROL, EXPERIMENT_HEADER, VISITOR_COOKIE, decodeExperimentHeader, encodeExperimentHeader, evaluateExperiments, experimentCacheSuffix, isBotUserAgent, readVisitorId, validateExperiments, visitorCookie } from './chunk-746BEU7H.js';
1
+ import { runningExperiments, NO_ASSIGNMENTS, isBotUserAgent, readPinnedVisitorId, readVisitorId, isPinnableVisitorId, visitorCookie, assignExperiments, experimentCacheSuffix, EXPERIMENT_HEADER, encodeExperimentHeader } from './chunk-4REZOGGW.js';
2
+ export { CONTROL, EXPERIMENT_HEADER, VISITOR_COOKIE, assignExperiments, decodeExperimentHeader, encodeExperimentHeader, experimentCacheSuffix, experimentVariantTable, inPosthogRollout, isBotUserAgent, posthogHash, posthogVariant, readVisitorId, runningExperiments, validateExperiments, visitorCookie } from './chunk-4REZOGGW.js';
3
3
 
4
4
  // src/analytics/edge.ts
5
5
  function isPostHogProxyPath(pathname, prefix = "/ingest") {
@@ -96,33 +96,23 @@ function isPageRequest(request, url) {
96
96
  if (url.pathname.startsWith("/_serverFn") || url.pathname.startsWith("/_server")) return false;
97
97
  return true;
98
98
  }
99
- async function assignForRequest(request, options, fetchImpl) {
100
- const declared = options.declared ?? {};
101
- const keys = Object.keys(declared);
99
+ async function assignForRequest(request, options) {
100
+ const running = runningExperiments(options.declared);
101
+ const keys = Object.keys(running);
102
102
  const none = { assignments: NO_ASSIGNMENTS, variant: "", cookies: [] };
103
- if (!keys.length || !options.posthogKey) return none;
103
+ if (!keys.length) return none;
104
104
  if (isBotUserAgent(request.headers.get("user-agent"))) return none;
105
105
  const cookieHeader = request.headers.get("cookie");
106
- const secure = new URL(request.url).protocol === "https:";
107
- const known = readVisitorId(cookieHeader, options.posthogKey);
108
- const distinctId = known ?? crypto.randomUUID();
109
- const cookies = known ? [] : [visitorCookie(distinctId, secure)];
110
- const remembered = known ? readAssignmentCookie(cookieHeader, { experiments: declared, distinctId }) : null;
111
- if (remembered) return { assignments: remembered, variant: experimentCacheSuffix(remembered, keys), cookies };
112
- const assignments = await evaluateExperiments({
113
- experiments: declared,
114
- distinctId,
115
- posthogKey: options.posthogKey,
116
- apiHost: `https://${options.region ?? "us"}.i.posthog.com`,
117
- timeoutMs: options.timeoutMs,
118
- fetch: fetchImpl
119
- });
120
- const remember = assignmentCookie(assignments, declared, secure);
121
- return {
122
- assignments,
123
- variant: experimentCacheSuffix(assignments, keys),
124
- cookies: remember ? [...cookies, remember] : cookies
125
- };
106
+ const pinned = readPinnedVisitorId(cookieHeader);
107
+ const known = pinned ?? readVisitorId(cookieHeader, options.posthogKey ?? "");
108
+ const distinctId = known && isPinnableVisitorId(known) ? known : crypto.randomUUID();
109
+ const cookies = pinned ? [] : [visitorCookie(distinctId, new URL(request.url).protocol === "https:")];
110
+ try {
111
+ const assignments = await assignExperiments({ experiments: running, distinctId });
112
+ return { assignments, variant: experimentCacheSuffix(assignments, keys), cookies };
113
+ } catch {
114
+ return { ...none, cookies };
115
+ }
126
116
  }
127
117
  function withAssignment(request, assignments) {
128
118
  const headers = new Headers(request.headers);
package/dist/edge.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/analytics/edge.ts","../src/host/edge-handler.ts"],"names":["response"],"mappings":";;;;AAgBO,SAAS,kBAAA,CAAmB,QAAA,EAAkB,MAAA,GAAS,SAAA,EAAoB;AAChF,EAAA,OAAO,aAAa,MAAA,IAAU,QAAA,CAAS,UAAA,CAAW,CAAA,EAAG,MAAM,CAAA,CAAA,CAAG,CAAA;AAChE;AAEA,eAAsB,YAAA,CAAa,OAAA,EAAkB,OAAA,GAA+B,EAAC,EAAsB;AACzG,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,SAAA;AACjC,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,IAAA;AACjC,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA;AAC/B,EAAA,MAAM,OAAO,GAAA,CAAI,QAAA,CAA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A,EAAO,CAAC,CAAA;AAC1D,IAAA,OAAO,MAAA,CAAO,UAAA,CAAW,QAAA,EAAU,cAAA,EAAgB,MAAM,CAAC,CAAA;AAAA,EAC5D,CAAA;AACF","file":"edge.js","sourcesContent":["/**\n * The store's own door to PostHog, for a Worker (or any fetch-style) host.\n *\n * Events sent to the store's domain under `/ingest` are not dropped by ad\n * blockers the way requests to a known analytics host are, and the store needs\n * no PostHog setting of its own: every store forwards to the same project.\n *\n * if (url.pathname.startsWith('/ingest')) return posthogProxy(request)\n */\nexport interface PostHogProxyOptions {\n /** The path the storefront's analytics client sends to. Default `/ingest`. */\n prefix?: string\n /** PostHog's region. Default `us`. */\n region?: 'us' | 'eu'\n}\n\nexport function isPostHogProxyPath(pathname: string, prefix = '/ingest'): boolean {\n return pathname === prefix || pathname.startsWith(`${prefix}/`)\n}\n\nexport async function posthogProxy(request: Request, options: PostHogProxyOptions = {}): Promise<Response> {\n const prefix = options.prefix ?? '/ingest'\n const region = options.region ?? 'us'\n const url = new URL(request.url)\n const path = url.pathname.slice(prefix.length) || '/'\n // The SDK's script and its remote config live on the assets host.\n const host = path.startsWith('/static/') || path.startsWith('/array/')\n ? `${region}-assets.i.posthog.com`\n : `${region}.i.posthog.com`\n const target = new URL(`https://${host}${path}${url.search}`)\n\n const headers = new Headers(request.headers)\n headers.delete('cookie')\n headers.set('host', host)\n // PostHog geolocates from the visitor, not from the Worker.\n const ip = request.headers.get('cf-connecting-ip') ?? request.headers.get('x-forwarded-for')\n if (ip) headers.set('x-forwarded-for', ip)\n\n const init: RequestInit = { method: request.method, headers, redirect: 'manual' }\n if (request.method !== 'GET' && request.method !== 'HEAD') init.body = await request.arrayBuffer()\n const response = await fetch(target, init)\n const out = new Response(response.body, response)\n out.headers.delete('set-cookie')\n return out\n}\n","import { isPostHogProxyPath, posthogProxy } from '../analytics/edge'\nimport {\n EXPERIMENT_HEADER,\n NO_ASSIGNMENTS,\n assignmentCookie,\n readAssignmentCookie,\n encodeExperimentHeader,\n evaluateExperiments,\n experimentCacheSuffix,\n isBotUserAgent,\n readVisitorId,\n visitorCookie,\n type ExperimentAssignments,\n type StorefrontExperiment,\n} from '../experiments/assign'\n\n// ---------------------------------------------------------------------------\n// The Worker in front of a server-rendered store.\n//\n// Four jobs a store's request handler has before the framework renders\n// anything, first written for artorious-shop and the same for every store:\n//\n// 1. Analytics through the store's own domain (`/ingest` → PostHog), so ad\n// blockers that drop requests to a known analytics host do not drop it.\n// 2. The store's photos from the store's own origin. The bytes live in\n// Supabase Storage; a photo addressed at the storage project is a second\n// origin the browser pays DNS + TLS for (measured 156–241 ms TTFB against\n// 112–141 ms same-origin). Only public objects of the `shop-images`\n// bucket are forwarded — this is not a general proxy.\n// 3. A real edge cache. Public pages already leave with `Cache-Control:\n// public, s-maxage=…`, but on workers.dev nothing in front honours it, so\n// every view paid the full render. The Workers Cache API makes the header\n// mean what it says. Marketing parameters (utm_*, fbclid…) are dropped\n// from the key: ad traffic hits the same entry as everyone else.\n// 4. `X-Robots-Tag: noindex` on any host that is not the store's address, so\n// the deployment URL never competes with the domain.\n// 5. A/B assignment. With `experiments` set, every page request is assigned\n// its variants HERE, before render (see experiments/assign.ts), and the\n// edge cache is keyed by them — one entry per combination of variants,\n// so a cached page is never one visitor's variant served to another.\n// ---------------------------------------------------------------------------\n\n/** `/storage/v1/object/public/shop-images/…` or the `render/image` variant of it. */\nconst STORAGE_PATH = /^\\/storage\\/v1\\/(object|render\\/image)\\/public\\/(shop-images\\/[^?#]+)$/\n\n/** Query parameters the renderer understands. Anything else is dropped rather\n * than forwarded, so a crawler cannot mint unlimited distinct variants. */\nconst RENDER_PARAMS = new Set(['width', 'height', 'quality', 'format', 'resize'])\n\n/** A year: the object path carries a timestamp and is never overwritten. */\nconst IMMUTABLE = 'public, max-age=31536000, s-maxage=31536000, immutable'\n\nconst TRACKING_PARAM = /^(utm_[a-z0-9_]+|fbclid|gclid|gbraid|wbraid|msclkid|ttclid|igshid|mc_cid|mc_eid|_ga|ref)$/i\n\nexport function isStorageRequest(url: URL): boolean {\n return STORAGE_PATH.test(url.pathname)\n}\n\n/**\n * Which format this visitor gets — the only part of the request, besides the\n * URL, that changes the bytes. The renderer answers WebP or the original\n * depending on `accept` and declares no `Vary`, so every cache in front of it\n * has to put the answer in the key itself.\n */\nexport function imageFormatKey(request: Request): 'webp' | 'orig' {\n return /image\\/webp/.test(request.headers.get('accept') ?? '') ? 'webp' : 'orig'\n}\n\n/** Answer a storage request from Supabase, on the store's own origin. */\nexport async function serveStorageImage(request: Request, url: URL, supabaseUrl: string | undefined): Promise<Response> {\n const match = STORAGE_PATH.exec(url.pathname)\n if (!match) return new Response('Not found', { status: 404 })\n const base = supabaseUrl?.replace(/\\/$/, '')\n if (!base) return new Response('Storage is not configured', { status: 502 })\n\n const [, kind, objectPath] = match\n const upstream = new URL(`${base}/storage/v1/${kind}/public/${objectPath}`)\n for (const [key, value] of url.searchParams) {\n if (RENDER_PARAMS.has(key)) upstream.searchParams.set(key, value)\n }\n // A canonical `accept`, not the visitor's verbatim: two browsers that both\n // take WebP must produce the same upstream request.\n const webp = imageFormatKey(request) === 'webp'\n const response = await fetch(upstream.toString(), { headers: { accept: webp ? 'image/webp,image/*;q=0.8' : 'image/*' } })\n if (!response.ok) {\n // Upstream's status is passed through (a deleted photo must not look like\n // a 200), never its cache directives.\n return new Response(response.status === 404 ? 'Not found' : 'Upstream error', {\n status: response.status === 404 ? 404 : 502,\n headers: { 'cache-control': 'public, max-age=60' },\n })\n }\n const headers = new Headers()\n headers.set('content-type', response.headers.get('content-type') ?? 'image/jpeg')\n headers.set('cache-control', IMMUTABLE)\n headers.set('x-image-origin', 'supabase')\n headers.set('vary', 'Accept')\n return new Response(response.body, { status: 200, headers })\n}\n\n/** The cache key for a request, or null when it is not cacheable. `variant`\n * is the experiment part (`experimentCacheSuffix`); empty means control. */\nexport function edgeCacheKey(request: Request, buildId: string, variant = ''): Request | null {\n if (request.method !== 'GET') return null\n const url = new URL(request.url)\n for (const key of [...url.searchParams.keys()]) {\n if (TRACKING_PARAM.test(key)) url.searchParams.delete(key)\n }\n url.hash = ''\n if (isStorageRequest(url)) url.searchParams.set('_fmt', imageFormatKey(request))\n // Cached HTML names this build's hashed chunks, and a deploy deletes them.\n // Keyed by build, old pages stop matching the moment the new Worker serves.\n url.searchParams.set('_build', buildId)\n if (variant) url.searchParams.set('_exp', variant)\n return new Request(url.toString(), { method: 'GET' })\n}\n\n/** Only what the response itself declares shareable and fresh for a while. */\nexport function edgeCacheable(response: Response): boolean {\n if (response.status !== 200) return false\n const cc = response.headers.get('cache-control') ?? ''\n return /\\bpublic\\b/.test(cc) && /\\bs-maxage=[1-9]\\d*/.test(cc) && !/\\b(no-store|private)\\b/.test(cc)\n}\n\nfunction withHeader(response: Response, name: string, value: string): Response {\n const headers = new Headers(response.headers)\n headers.set(name, value)\n return new Response(response.body, { status: response.status, statusText: response.statusText, headers })\n}\n\n/** Adds cookies without touching the ones the page already sets. */\nfunction withCookies(response: Response, cookies: readonly string[]): Response {\n if (!cookies.length) return response\n const headers = new Headers(response.headers)\n for (const cookie of cookies) headers.append('set-cookie', cookie)\n return new Response(response.body, { status: response.status, statusText: response.statusText, headers })\n}\n\nexport interface StorefrontEdgeOptions {\n /** The framework's own handler (TanStack Start's `handler.fetch`). */\n render(request: Request): Response | Promise<Response>\n /** From the store host: `host.isCanonicalHost`. */\n isCanonicalHost(url: URL): boolean\n /** One id per build, for the cache key. */\n buildId: string\n /** The Supabase project the photos live in (`PUBLIC_SUPABASE_URL`). */\n supabaseUrl?: string\n /** Keeps the Worker alive past the response (`waitUntil` from 'cloudflare:workers'). */\n waitUntil(promise: Promise<unknown>): void\n /** The Workers cache (`caches.default`). Omitted: no edge cache. */\n cache?: Cache\n /**\n * Development: NEVER cache. The Cloudflare vite plugin runs the Worker in\n * workerd locally too, and an entry cannot be purged, only outlived — a\n * price edited and reloaded shows the old one with nothing in the browser\n * able to help.\n */\n dev?: boolean\n /**\n * A/B tests: the store's declared experiments (`config.experiments`) and the\n * PostHog project they run in. Omitted or empty: no assignment, no cookie,\n * the cache key is the page's alone — exactly the handler without tests.\n */\n experiments?: StorefrontEdgeExperiments\n}\n\nexport interface StorefrontEdgeExperiments {\n declared: Record<string, StorefrontExperiment> | undefined\n /** The PostHog project token (`phc_…`), the same the storefront sends with. */\n posthogKey: string | undefined\n /** PostHog's region. Default `us`. */\n region?: 'us' | 'eu'\n /** The flags request's deadline; past it every experiment is control. Default 400 ms. */\n timeoutMs?: number\n}\n\n/** A page a visitor navigates to — not an asset, a photo, a feed or a POST. */\nfunction isPageRequest(request: Request, url: URL): boolean {\n if (request.method !== 'GET') return false\n if (isStorageRequest(url) || isPostHogProxyPath(url.pathname)) return false\n // Hashed bundles, fonts, images, the sitemap: anything with an extension.\n if (/\\.[a-z0-9]{1,8}$/i.test(url.pathname)) return false\n // TanStack's server functions and the router's data requests.\n if (url.pathname.startsWith('/_serverFn') || url.pathname.startsWith('/_server')) return false\n return true\n}\n\ninterface PageAssignment {\n assignments: ExperimentAssignments\n /** The cache-key part; empty for control. */\n variant: string\n /** Cookies for THIS visitor's response: a new id, a fresh assignment. */\n cookies: string[]\n}\n\n/** Decide this request's variants. Never throws; every failure is control. */\nexport async function assignForRequest(\n request: Request,\n options: StorefrontEdgeExperiments,\n fetchImpl?: typeof fetch,\n): Promise<PageAssignment> {\n const declared = options.declared ?? {}\n const keys = Object.keys(declared)\n const none: PageAssignment = { assignments: NO_ASSIGNMENTS, variant: '', cookies: [] }\n if (!keys.length || !options.posthogKey) return none\n // Crawlers and unfurlers see control and get no id: what is indexed and\n // shared must not depend on a coin flip, and a bot is not an exposure.\n if (isBotUserAgent(request.headers.get('user-agent'))) return none\n const cookieHeader = request.headers.get('cookie')\n const secure = new URL(request.url).protocol === 'https:'\n const known = readVisitorId(cookieHeader, options.posthogKey)\n const distinctId = known ?? crypto.randomUUID()\n const cookies = known ? [] : [visitorCookie(distinctId, secure)]\n\n // Asked this half hour already: no round trip in front of the page.\n const remembered = known ? readAssignmentCookie(cookieHeader, { experiments: declared, distinctId }) : null\n if (remembered) return { assignments: remembered, variant: experimentCacheSuffix(remembered, keys), cookies }\n\n const assignments = await evaluateExperiments({\n experiments: declared,\n distinctId,\n posthogKey: options.posthogKey,\n apiHost: `https://${options.region ?? 'us'}.i.posthog.com`,\n timeoutMs: options.timeoutMs,\n fetch: fetchImpl,\n })\n // Only a real answer is remembered: after a timeout the next page asks again.\n const remember = assignmentCookie(assignments, declared, secure)\n return {\n assignments,\n variant: experimentCacheSuffix(assignments, keys),\n cookies: remember ? [...cookies, remember] : cookies,\n }\n}\n\n/**\n * The request the renderer sees: the same, plus the variants — and ONLY the\n * variants. The visitor id stays out of the header on purpose: the rendered\n * HTML is cached and shared by every visitor in the same variant bucket, and\n * an id in it would hand one visitor's identity to the next. The browser\n * reads its own id from the cookie (`readVisitorId(document.cookie, …)`).\n */\nfunction withAssignment(request: Request, assignments: ExperimentAssignments): Request {\n const headers = new Headers(request.headers)\n headers.delete(EXPERIMENT_HEADER) // never trust one the visitor sent\n if (Object.keys(assignments.flags).length) {\n headers.set(EXPERIMENT_HEADER, encodeExperimentHeader({ flags: assignments.flags }))\n }\n return new Request(request, { headers })\n}\n\n/** The Worker's `fetch`, from the store's pieces. */\nexport function createStorefrontEdge(options: StorefrontEdgeOptions): (request: Request) => Promise<Response> {\n async function respond(request: Request): Promise<Response> {\n const url = new URL(request.url)\n if (isStorageRequest(url)) return serveStorageImage(request, url, options.supabaseUrl)\n const response = await options.render(request)\n if (options.isCanonicalHost(url)) return response\n return withHeader(response, 'x-robots-tag', 'noindex, nofollow')\n }\n\n return async (incoming) => {\n const url = new URL(incoming.url)\n // Analytics leaves through the store's own domain, never cached.\n if (isPostHogProxyPath(url.pathname)) return posthogProxy(incoming)\n\n // Variants first: they change the HTML, so they are part of the cache key.\n const page = options.experiments && isPageRequest(incoming, url)\n ? await assignForRequest(incoming, options.experiments)\n : null\n const request = page ? withAssignment(incoming, page.assignments) : incoming\n // Cookies are added to what THIS visitor receives, never to the cached\n // copy (a shared entry carrying one visitor's id would hand it to the\n // next), and appended, so a cookie the page itself sets survives.\n const finish = (response: Response) => withCookies(response, page?.cookies ?? [])\n\n if (options.dev || !options.cache) return finish(await respond(request))\n\n const key = edgeCacheKey(request, options.buildId, page?.variant ?? '')\n if (!key) return finish(await respond(request))\n const hit = await options.cache.match(key)\n if (hit) return finish(withHeader(hit, 'x-edge-cache', 'HIT'))\n\n const response = await respond(request)\n if (!edgeCacheable(response)) return finish(withHeader(response, 'x-edge-cache', 'BYPASS'))\n options.waitUntil(options.cache.put(key, response.clone()))\n return finish(withHeader(response, 'x-edge-cache', 'MISS'))\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/analytics/edge.ts","../src/host/edge-handler.ts"],"names":["response"],"mappings":";;;;AAgBO,SAAS,kBAAA,CAAmB,QAAA,EAAkB,MAAA,GAAS,SAAA,EAAoB;AAChF,EAAA,OAAO,aAAa,MAAA,IAAU,QAAA,CAAS,UAAA,CAAW,CAAA,EAAG,MAAM,CAAA,CAAA,CAAG,CAAA;AAChE;AAEA,eAAsB,YAAA,CAAa,OAAA,EAAkB,OAAA,GAA+B,EAAC,EAAsB;AACzG,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,SAAA;AACjC,EAAA,MAAM,MAAA,GAAS,QAAQ,MAAA,IAAU,IAAA;AACjC,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,OAAA,CAAQ,GAAG,CAAA;AAC/B,EAAA,MAAM,OAAO,GAAA,CAAI,QAAA,CAAS,KAAA,CAAM,MAAA,CAAO,MAAM,CAAA,IAAK,GAAA;AAElD,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,IAAK,IAAA,CAAK,UAAA,CAAW,SAAS,CAAA,GACjE,CAAA,EAAG,MAAM,CAAA,qBAAA,CAAA,GACT,GAAG,MAAM,CAAA,cAAA,CAAA;AACb,EAAA,MAAM,MAAA,GAAS,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O,MAAM,OAAA,CAAQ,OAAO,CAAC,CAAA;AAC9C,IAAA,MAAM,GAAA,GAAM,MAAM,OAAA,CAAQ,KAAA,CAAM,MAAM,GAAG,CAAA;AACzC,IAAA,IAAI,KAAK,OAAO,MAAA,CAAO,WAAW,GAAA,EAAK,cAAA,EAAgB,KAAK,CAAC,CAAA;AAE7D,IAAA,MAAM,QAAA,GAAW,MAAM,OAAA,CAAQ,OAAO,CAAA;AACtC,IAAA,IAAI,CAAC,aAAA,CAAc,QAAQ,CAAA,EAAG,OAAO,OAAO,UAAA,CAAW,QAAA,EAAU,cAAA,EAAgB,QAAQ,CAAC,CAAA;AAC1F,IAAA,OAAA,CAAQ,SAAA,CAAU,QAAQ,KAAA,CAAM,GAAA,CAAI,KAAK,QAAA,CAAS,KAAA,EAAO,CAAC,CAAA;AAC1D,IAAA,OAAO,MAAA,CAAO,UAAA,CAAW,QAAA,EAAU,cAAA,EAAgB,MAAM,CAAC,CAAA;AAAA,EAC5D,CAAA;AACF","file":"edge.js","sourcesContent":["/**\n * The store's own door to PostHog, for a Worker (or any fetch-style) host.\n *\n * Events sent to the store's domain under `/ingest` are not dropped by ad\n * blockers the way requests to a known analytics host are, and the store needs\n * no PostHog setting of its own: every store forwards to the same project.\n *\n * if (url.pathname.startsWith('/ingest')) return posthogProxy(request)\n */\nexport interface PostHogProxyOptions {\n /** The path the storefront's analytics client sends to. Default `/ingest`. */\n prefix?: string\n /** PostHog's region. Default `us`. */\n region?: 'us' | 'eu'\n}\n\nexport function isPostHogProxyPath(pathname: string, prefix = '/ingest'): boolean {\n return pathname === prefix || pathname.startsWith(`${prefix}/`)\n}\n\nexport async function posthogProxy(request: Request, options: PostHogProxyOptions = {}): Promise<Response> {\n const prefix = options.prefix ?? '/ingest'\n const region = options.region ?? 'us'\n const url = new URL(request.url)\n const path = url.pathname.slice(prefix.length) || '/'\n // The SDK's script and its remote config live on the assets host.\n const host = path.startsWith('/static/') || path.startsWith('/array/')\n ? `${region}-assets.i.posthog.com`\n : `${region}.i.posthog.com`\n const target = new URL(`https://${host}${path}${url.search}`)\n\n const headers = new Headers(request.headers)\n headers.delete('cookie')\n headers.set('host', host)\n // PostHog geolocates from the visitor, not from the Worker.\n const ip = request.headers.get('cf-connecting-ip') ?? request.headers.get('x-forwarded-for')\n if (ip) headers.set('x-forwarded-for', ip)\n\n const init: RequestInit = { method: request.method, headers, redirect: 'manual' }\n if (request.method !== 'GET' && request.method !== 'HEAD') init.body = await request.arrayBuffer()\n const response = await fetch(target, init)\n const out = new Response(response.body, response)\n out.headers.delete('set-cookie')\n return out\n}\n","import { isPostHogProxyPath, posthogProxy } from '../analytics/edge'\nimport {\n EXPERIMENT_HEADER,\n NO_ASSIGNMENTS,\n assignExperiments,\n encodeExperimentHeader,\n experimentCacheSuffix,\n runningExperiments,\n isBotUserAgent,\n readVisitorId,\n readPinnedVisitorId,\n isPinnableVisitorId,\n visitorCookie,\n type ExperimentAssignments,\n type StorefrontExperiment,\n} from '../experiments/assign'\n\n// ---------------------------------------------------------------------------\n// The Worker in front of a server-rendered store.\n//\n// Five jobs a store's request handler has before the framework renders\n// anything, first written for artorious-shop and the same for every store:\n//\n// 1. Analytics through the store's own domain (`/ingest` → PostHog), so ad\n// blockers that drop requests to a known analytics host do not drop it.\n// 2. The store's photos from the store's own origin. The bytes live in\n// Supabase Storage; a photo addressed at the storage project is a second\n// origin the browser pays DNS + TLS for (measured 156–241 ms TTFB against\n// 112–141 ms same-origin). Only public objects of the `shop-images`\n// bucket are forwarded — this is not a general proxy.\n// 3. A real edge cache. Public pages already leave with `Cache-Control:\n// public, s-maxage=…`, but on workers.dev nothing in front honours it, so\n// every view paid the full render. The Workers Cache API makes the header\n// mean what it says. Marketing parameters (utm_*, fbclid…) are dropped\n// from the key: ad traffic hits the same entry as everyone else.\n// 4. `X-Robots-Tag: noindex` on any host that is not the store's address, so\n// the deployment URL never competes with the domain.\n// 5. A/B assignment. With a running experiment, every page request is\n// assigned its variants HERE, before render, locally with PostHog's\n// bucketing (experiments/assign.ts — no network), and the edge cache is\n// keyed by them: one entry per combination of variants, so a cached page\n// is never one visitor's variant served to another.\n// ---------------------------------------------------------------------------\n\n/** `/storage/v1/object/public/shop-images/…` or the `render/image` variant of it. */\nconst STORAGE_PATH = /^\\/storage\\/v1\\/(object|render\\/image)\\/public\\/(shop-images\\/[^?#]+)$/\n\n/** Query parameters the renderer understands. Anything else is dropped rather\n * than forwarded, so a crawler cannot mint unlimited distinct variants. */\nconst RENDER_PARAMS = new Set(['width', 'height', 'quality', 'format', 'resize'])\n\n/** A year: the object path carries a timestamp and is never overwritten. */\nconst IMMUTABLE = 'public, max-age=31536000, s-maxage=31536000, immutable'\n\nconst TRACKING_PARAM = /^(utm_[a-z0-9_]+|fbclid|gclid|gbraid|wbraid|msclkid|ttclid|igshid|mc_cid|mc_eid|_ga|ref)$/i\n\nexport function isStorageRequest(url: URL): boolean {\n return STORAGE_PATH.test(url.pathname)\n}\n\n/**\n * Which format this visitor gets — the only part of the request, besides the\n * URL, that changes the bytes. The renderer answers WebP or the original\n * depending on `accept` and declares no `Vary`, so every cache in front of it\n * has to put the answer in the key itself.\n */\nexport function imageFormatKey(request: Request): 'webp' | 'orig' {\n return /image\\/webp/.test(request.headers.get('accept') ?? '') ? 'webp' : 'orig'\n}\n\n/** Answer a storage request from Supabase, on the store's own origin. */\nexport async function serveStorageImage(request: Request, url: URL, supabaseUrl: string | undefined): Promise<Response> {\n const match = STORAGE_PATH.exec(url.pathname)\n if (!match) return new Response('Not found', { status: 404 })\n const base = supabaseUrl?.replace(/\\/$/, '')\n if (!base) return new Response('Storage is not configured', { status: 502 })\n\n const [, kind, objectPath] = match\n const upstream = new URL(`${base}/storage/v1/${kind}/public/${objectPath}`)\n for (const [key, value] of url.searchParams) {\n if (RENDER_PARAMS.has(key)) upstream.searchParams.set(key, value)\n }\n // A canonical `accept`, not the visitor's verbatim: two browsers that both\n // take WebP must produce the same upstream request.\n const webp = imageFormatKey(request) === 'webp'\n const response = await fetch(upstream.toString(), { headers: { accept: webp ? 'image/webp,image/*;q=0.8' : 'image/*' } })\n if (!response.ok) {\n // Upstream's status is passed through (a deleted photo must not look like\n // a 200), never its cache directives.\n return new Response(response.status === 404 ? 'Not found' : 'Upstream error', {\n status: response.status === 404 ? 404 : 502,\n headers: { 'cache-control': 'public, max-age=60' },\n })\n }\n const headers = new Headers()\n headers.set('content-type', response.headers.get('content-type') ?? 'image/jpeg')\n headers.set('cache-control', IMMUTABLE)\n headers.set('x-image-origin', 'supabase')\n headers.set('vary', 'Accept')\n return new Response(response.body, { status: 200, headers })\n}\n\n/** The cache key for a request, or null when it is not cacheable. `variant`\n * is the experiment part (`experimentCacheSuffix`); empty means control. */\nexport function edgeCacheKey(request: Request, buildId: string, variant = ''): Request | null {\n if (request.method !== 'GET') return null\n const url = new URL(request.url)\n for (const key of [...url.searchParams.keys()]) {\n if (TRACKING_PARAM.test(key)) url.searchParams.delete(key)\n }\n url.hash = ''\n if (isStorageRequest(url)) url.searchParams.set('_fmt', imageFormatKey(request))\n // Cached HTML names this build's hashed chunks, and a deploy deletes them.\n // Keyed by build, old pages stop matching the moment the new Worker serves.\n url.searchParams.set('_build', buildId)\n if (variant) url.searchParams.set('_exp', variant)\n return new Request(url.toString(), { method: 'GET' })\n}\n\n/** Only what the response itself declares shareable and fresh for a while. */\nexport function edgeCacheable(response: Response): boolean {\n if (response.status !== 200) return false\n const cc = response.headers.get('cache-control') ?? ''\n return /\\bpublic\\b/.test(cc) && /\\bs-maxage=[1-9]\\d*/.test(cc) && !/\\b(no-store|private)\\b/.test(cc)\n}\n\nfunction withHeader(response: Response, name: string, value: string): Response {\n const headers = new Headers(response.headers)\n headers.set(name, value)\n return new Response(response.body, { status: response.status, statusText: response.statusText, headers })\n}\n\n/** Adds cookies without touching the ones the page already sets. */\nfunction withCookies(response: Response, cookies: readonly string[]): Response {\n if (!cookies.length) return response\n const headers = new Headers(response.headers)\n for (const cookie of cookies) headers.append('set-cookie', cookie)\n return new Response(response.body, { status: response.status, statusText: response.statusText, headers })\n}\n\nexport interface StorefrontEdgeOptions {\n /** The framework's own handler (TanStack Start's `handler.fetch`). */\n render(request: Request): Response | Promise<Response>\n /** From the store host: `host.isCanonicalHost`. */\n isCanonicalHost(url: URL): boolean\n /** One id per build, for the cache key. */\n buildId: string\n /** The Supabase project the photos live in (`PUBLIC_SUPABASE_URL`). */\n supabaseUrl?: string\n /** Keeps the Worker alive past the response (`waitUntil` from 'cloudflare:workers'). */\n waitUntil(promise: Promise<unknown>): void\n /** The Workers cache (`caches.default`). Omitted: no edge cache. */\n cache?: Cache\n /**\n * Development: NEVER cache. The Cloudflare vite plugin runs the Worker in\n * workerd locally too, and an entry cannot be purged, only outlived — a\n * price edited and reloaded shows the old one with nothing in the browser\n * able to help.\n */\n dev?: boolean\n /**\n * A/B tests: the store's declared experiments (`config.experiments`).\n * Nothing running: no assignment, no cookie, the cache key is the page's\n * alone — exactly the handler without tests.\n */\n experiments?: StorefrontEdgeExperiments\n}\n\nexport interface StorefrontEdgeExperiments {\n declared: Record<string, StorefrontExperiment> | undefined\n /**\n * The PostHog project token (`phc_…`), the same the storefront sends with —\n * used only to read PostHog's own cookie, so a returning visitor is bucketed\n * by the id PostHog already knows them by. Optional: without it, `fz_vid`.\n */\n posthogKey?: string\n}\n\n/** A page a visitor navigates to — not an asset, a photo, a feed or a POST. */\nfunction isPageRequest(request: Request, url: URL): boolean {\n if (request.method !== 'GET') return false\n if (isStorageRequest(url) || isPostHogProxyPath(url.pathname)) return false\n // Hashed bundles, fonts, images, the sitemap: anything with an extension.\n if (/\\.[a-z0-9]{1,8}$/i.test(url.pathname)) return false\n // TanStack's server functions and the router's data requests.\n if (url.pathname.startsWith('/_serverFn') || url.pathname.startsWith('/_server')) return false\n return true\n}\n\ninterface PageAssignment {\n assignments: ExperimentAssignments\n /** The cache-key part; empty for control. */\n variant: string\n /** Cookies for THIS visitor's response: a new id. */\n cookies: string[]\n}\n\n/**\n * Decide this request's variants — locally, with PostHog's bucketing, no\n * network. Never throws.\n */\nexport async function assignForRequest(request: Request, options: StorefrontEdgeExperiments): Promise<PageAssignment> {\n const running = runningExperiments(options.declared)\n const keys = Object.keys(running)\n const none: PageAssignment = { assignments: NO_ASSIGNMENTS, variant: '', cookies: [] }\n // Nothing running: no id, no cookie, the page's plain cache entry.\n if (!keys.length) return none\n // Crawlers and unfurlers see control and get no id: what is indexed and\n // shared must not depend on a coin flip, and a bot is not an exposure.\n if (isBotUserAgent(request.headers.get('user-agent'))) return none\n const cookieHeader = request.headers.get('cookie')\n // The bucket id is pinned in `fz_vid` the first time and read from there\n // ever after. A returning visitor without one is pinned to the anonymous id\n // PostHog already knows them by; an identified id (an e-mail) is never\n // stored — they get a fresh anonymous one.\n const pinned = readPinnedVisitorId(cookieHeader)\n const known = pinned ?? readVisitorId(cookieHeader, options.posthogKey ?? '')\n const distinctId = known && isPinnableVisitorId(known) ? known : crypto.randomUUID()\n const cookies = pinned ? [] : [visitorCookie(distinctId, new URL(request.url).protocol === 'https:')]\n try {\n const assignments = await assignExperiments({ experiments: running, distinctId })\n return { assignments, variant: experimentCacheSuffix(assignments, keys), cookies }\n } catch {\n // No SubtleCrypto (not a Worker, not a modern runtime): everyone control.\n return { ...none, cookies }\n }\n}\n\n/**\n * The request the renderer sees: the same, plus the variants — and ONLY the\n * variants. The visitor id stays out of the header on purpose: the rendered\n * HTML is cached and shared by every visitor in the same variant bucket, and\n * an id in it would hand one visitor's identity to the next. The browser\n * reads its own id from the cookie (`readVisitorId(document.cookie, …)`).\n */\nfunction withAssignment(request: Request, assignments: ExperimentAssignments): Request {\n const headers = new Headers(request.headers)\n headers.delete(EXPERIMENT_HEADER) // never trust one the visitor sent\n if (Object.keys(assignments.flags).length) {\n headers.set(EXPERIMENT_HEADER, encodeExperimentHeader({ flags: assignments.flags }))\n }\n return new Request(request, { headers })\n}\n\n/** The Worker's `fetch`, from the store's pieces. */\nexport function createStorefrontEdge(options: StorefrontEdgeOptions): (request: Request) => Promise<Response> {\n async function respond(request: Request): Promise<Response> {\n const url = new URL(request.url)\n if (isStorageRequest(url)) return serveStorageImage(request, url, options.supabaseUrl)\n const response = await options.render(request)\n if (options.isCanonicalHost(url)) return response\n return withHeader(response, 'x-robots-tag', 'noindex, nofollow')\n }\n\n return async (incoming) => {\n const url = new URL(incoming.url)\n // Analytics leaves through the store's own domain, never cached.\n if (isPostHogProxyPath(url.pathname)) return posthogProxy(incoming)\n\n // Variants first: they change the HTML, so they are part of the cache key.\n const page = options.experiments && isPageRequest(incoming, url)\n ? await assignForRequest(incoming, options.experiments)\n : null\n const request = page ? withAssignment(incoming, page.assignments) : incoming\n // Cookies are added to what THIS visitor receives, never to the cached\n // copy (a shared entry carrying one visitor's id would hand it to the\n // next), and appended, so a cookie the page itself sets survives.\n const finish = (response: Response) => withCookies(response, page?.cookies ?? [])\n\n if (options.dev || !options.cache) return finish(await respond(request))\n\n const key = edgeCacheKey(request, options.buildId, page?.variant ?? '')\n if (!key) return finish(await respond(request))\n const hit = await options.cache.match(key)\n if (hit) return finish(withHeader(hit, 'x-edge-cache', 'HIT'))\n\n const response = await respond(request)\n if (!edgeCacheable(response)) return finish(withHeader(response, 'x-edge-cache', 'BYPASS'))\n options.waitUntil(options.cache.put(key, response.clone()))\n return finish(withHeader(response, 'x-edge-cache', 'MISS'))\n }\n}\n"]}
@@ -4,31 +4,29 @@ export declare const CONTROL = "control";
4
4
  export declare const EXPERIMENT_HEADER = "x-fayz-experiments";
5
5
  /** First-party cookie holding the anonymous id when PostHog has not set one yet. */
6
6
  export declare const VISITOR_COOKIE = "fz_vid";
7
- /**
8
- * First-party cookie remembering what PostHog answered for this visitor, so
9
- * the edge asks once per visitor per half hour instead of before every page —
10
- * a flags round trip in front of every navigation, cache hits included, is a
11
- * tax every shopper pays for a test most of them are not looking at.
12
- */
13
- export declare const ASSIGNMENT_COOKIE = "fz_exp";
14
- /** How long a remembered assignment is trusted. Stopping or re-rolling an
15
- * experiment in PostHog reaches every visitor within this window. */
16
- export declare const ASSIGNMENT_TTL_SECONDS = 1800;
17
7
  /** One experiment the store runs. */
18
8
  export interface StorefrontExperiment {
19
9
  /**
20
- * The variant keys, as configured on the PostHog flag. Must include
21
- * 'control'. A variant PostHog answers that is not listed here is treated
22
- * as control: the page has no rendering for it.
10
+ * The variant keys, in the order the PostHog flag lists them (the order
11
+ * buckets are laid out in). Must include 'control'.
23
12
  */
24
13
  variants: readonly string[];
14
+ /**
15
+ * 'running' assigns visitors; 'off' (the default) shows everyone control and
16
+ * counts no one. Launching or stopping a test is flipping this and deploying.
17
+ */
18
+ status?: 'running' | 'off';
19
+ /** Percent of visitors per variant, summing to 100. Default: even, remainder to the first. */
20
+ split?: Readonly<Record<string, number>>;
21
+ /** Percent of visitors in the experiment at all (the rest see control, uncounted). Default 100. */
22
+ rollout?: number;
25
23
  /** What is being tested and why — for whoever reads the config next. */
26
24
  description?: string;
27
25
  }
28
26
  /** What a visitor sees for one experiment. */
29
27
  export interface ExperimentAssignment {
30
28
  variant: string;
31
- /** The flag's JSON payload for this variant, when the flag has one. */
29
+ /** Reserved for per-variant data. Local assignment does not set it. */
32
30
  payload?: unknown;
33
31
  }
34
32
  /** Everything the edge decided for one request. */
@@ -37,14 +35,11 @@ export interface ExperimentAssignments {
37
35
  * travels into the rendered (and cached) page — see `withAssignment`. */
38
36
  distinctId?: string;
39
37
  /**
40
- * By flag key, ONLY what PostHog actually assigned — 'control' included when
41
- * PostHog said control. A key the store declares but that is missing here is
42
- * rendered as control but is not part of the experiment: it reports no
43
- * exposure, so a timeout never lands a visitor in the control group.
38
+ * By flag key, ONLY the experiments this visitor is in — 'control' included
39
+ * when bucketed into control. A declared key missing here renders control
40
+ * but reports no exposure: the visitor is outside the experiment.
44
41
  */
45
42
  flags: Record<string, ExperimentAssignment>;
46
- /** PostHog answered (as opposed to: not asked, slow, down, unparsable). */
47
- answered?: boolean;
48
43
  }
49
44
  /** The empty decision: every experiment at control. */
50
45
  export declare const NO_ASSIGNMENTS: ExperimentAssignments;
@@ -61,25 +56,36 @@ export declare function isBotUserAgent(userAgent: string | null | undefined): bo
61
56
  * the browser reports events under), then the store's first-party cookie.
62
57
  */
63
58
  export declare function readVisitorId(cookieHeader: string | null | undefined, posthogKey: string): string | undefined;
59
+ /** The `fz_vid` the edge pinned for this browser, if any. */
60
+ export declare function readPinnedVisitorId(cookieHeader: string | null | undefined): string | undefined;
61
+ /** Whether an id may be stored in `fz_vid` (an anonymous id, never an e-mail). */
62
+ export declare function isPinnableVisitorId(id: string): boolean;
64
63
  /** `Set-Cookie` for a newly minted visitor id: a year, first-party, not readable cross-site. */
65
64
  export declare function visitorCookie(id: string, secure?: boolean): string;
66
- export interface EvaluateExperimentsInput {
67
- /** The store's declared experiments. Only these keys are read from the answer. */
68
- experiments: Record<string, StorefrontExperiment>;
69
- distinctId: string;
70
- /** The PostHog project token (`phc_…`). */
71
- posthogKey: string;
72
- /** Default `https://us.i.posthog.com`. */
73
- apiHost?: string;
74
- /** PostHog is asked with a deadline; past it, every experiment is control. Default 400 ms. */
75
- timeoutMs?: number;
76
- fetch?: typeof fetch;
77
- }
65
+ /** PostHog's bucket for `key` and `distinctId`, in [0, 1]. */
66
+ export declare function posthogHash(key: string, distinctId: string, salt?: string): Promise<number>;
67
+ /** In the rollout when the bucket is at or below the percentage — PostHog's `>` check, inverted. */
68
+ export declare function inPosthogRollout(key: string, distinctId: string, rolloutPercentage: number): Promise<boolean>;
69
+ /** PostHog's variant for a bucketed visitor: the `[min, max)` range its 'variant' hash falls in. */
70
+ export declare function posthogVariant(key: string, distinctId: string, variants: ReadonlyArray<{
71
+ key: string;
72
+ rollout_percentage: number;
73
+ }>): Promise<string | undefined>;
74
+ /** The split as PostHog's variant list: declared order, even by default (remainder to the first). */
75
+ export declare function experimentVariantTable(experiment: StorefrontExperiment): Array<{
76
+ key: string;
77
+ rollout_percentage: number;
78
+ }>;
79
+ /** Experiments that assign anyone. */
80
+ export declare function runningExperiments(experiments: Record<string, StorefrontExperiment> | undefined): Record<string, StorefrontExperiment>;
78
81
  /**
79
- * Ask PostHog which variant this visitor is in, for every declared experiment.
80
- * Never throws and never waits past the deadline.
82
+ * This visitor's variants, computed locally. Only running experiments the
83
+ * visitor's bucket falls inside the rollout of appear in `flags`.
81
84
  */
82
- export declare function evaluateExperiments(input: EvaluateExperimentsInput): Promise<ExperimentAssignments>;
85
+ export declare function assignExperiments(input: {
86
+ experiments: Record<string, StorefrontExperiment> | undefined;
87
+ distinctId: string;
88
+ }): Promise<ExperimentAssignments>;
83
89
  /** The variant of `key`, control when unassigned. */
84
90
  export declare function variantOf(assignments: ExperimentAssignments | null | undefined, key: string): string;
85
91
  /**
@@ -92,22 +98,4 @@ export declare function experimentCacheSuffix(assignments: ExperimentAssignments
92
98
  export declare function encodeExperimentHeader(assignments: ExperimentAssignments): string;
93
99
  /** The renderer's side: never throws, garbage reads as no assignment. */
94
100
  export declare function decodeExperimentHeader(value: string | null | undefined): ExperimentAssignments | null;
95
- /**
96
- * A short, stable fingerprint of the declared experiments. A remembered
97
- * assignment is only trusted for the same declarations: adding an experiment
98
- * or a variant re-asks PostHog on the next page instead of waiting out the TTL.
99
- */
100
- export declare function experimentsFingerprint(experiments: Record<string, StorefrontExperiment>): string;
101
- /**
102
- * The remembered assignment, when it is for this visitor and these
103
- * declarations. Tampering only lets a visitor pick a variant the store
104
- * declared — the same page any other visitor may get — so it is validated, not
105
- * signed; anything that does not validate is ignored and PostHog is asked.
106
- */
107
- export declare function readAssignmentCookie(cookieHeader: string | null | undefined, input: {
108
- experiments: Record<string, StorefrontExperiment>;
109
- distinctId: string;
110
- }): ExperimentAssignments | null;
111
- /** `Set-Cookie` remembering an assignment PostHog made. Null when there is nothing worth remembering. */
112
- export declare function assignmentCookie(assignments: ExperimentAssignments, experiments: Record<string, StorefrontExperiment>, secure?: boolean): string | null;
113
101
  //# sourceMappingURL=assign.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"assign.d.ts","sourceRoot":"","sources":["../../src/experiments/assign.ts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IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAA;CAAE,CAAC,CAK3H;AAED,sCAAsC;AACtC,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAEtI;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE;IAC7C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,GAAG,SAAS,CAAA;IAC7D,UAAU,EAAE,MAAM,CAAA;CACnB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAQjC;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,WAAW,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEpG;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,qBAAqB,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAOzG;AAED,wFAAwF;AACxF,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,qBAAqB,GAAG,MAAM,CAEjF;AAED,yEAAyE;AACzE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,qBAAqB,GAAG,IAAI,CAkBrG"}
@@ -29,9 +29,10 @@ export declare function ExperimentProvider({ assignments, path, children }: Expe
29
29
  * The variant this visitor sees for `key`, and its payload.
30
30
  *
31
31
  * 'control' whenever anything is missing — no provider, an undeclared key, no
32
- * assignment, PostHog unreachable at the edge. The first render that reads an
33
- * experiment PostHog assigned reports the exposure (once per page view): that
34
- * is the event PostHog's experiment analysis counts visitors from.
32
+ * assignment (the experiment is off, the visitor is outside its rollout or is
33
+ * a crawler). The first render that reads an experiment the visitor is in
34
+ * reports the exposure (once per page view): that is the event PostHog's
35
+ * experiment analysis counts visitors from.
35
36
  */
36
37
  export declare function useExperiment(key: string): ExperimentAssignment;
37
38
  /** A setting resolved for this visitor; reads (and reports) the experiment only when bound. */
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../../src/experiments/react.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAA8C,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAG1F,OAAO,EAAW,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAazF,gEAAgE;AAChE,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,mEAAmE;IACnE,UAAU,EAAE,MAAM,CAAA;IAClB,gFAAgF;IAChF,QAAQ,EAAE;QAAE,OAAO,EAAE,CAAC,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;CAC7C;AAED,oDAAoD;AACpD,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAA;AAEtD,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,KAAK,IAAI,iBAAiB,CAAC,CAAC,CAAC,CAOxG;AAED,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,CAAC,CAGjF;AAOD,2EAA2E;AAC3E,wBAAgB,sBAAsB,IAAI,qBAAqB,GAAG,IAAI,CAErE;AAYD,MAAM,WAAW,uBAAuB;IACtC,6EAA6E;IAC7E,WAAW,EAAE,qBAAqB,GAAG,IAAI,GAAG,SAAS,CAAA;IACrD,yFAAyF;IACzF,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC3B;AAED,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C,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,4BAU9F;AAED,uFAAuF;AACvF,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,SAAS,CAAA;CAAE,qBAEtF;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;CAe/B,CAAA;AAED,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;CAkBtC,CAAA;AAED,iBAAiB;AACjB,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C"}
@@ -35,30 +35,33 @@ export interface StorefrontEdgeOptions {
35
35
  */
36
36
  dev?: boolean;
37
37
  /**
38
- * A/B tests: the store's declared experiments (`config.experiments`) and the
39
- * PostHog project they run in. Omitted or empty: no assignment, no cookie,
40
- * the cache key is the page's alone — exactly the handler without tests.
38
+ * A/B tests: the store's declared experiments (`config.experiments`).
39
+ * Nothing running: no assignment, no cookie, the cache key is the page's
40
+ * alone — exactly the handler without tests.
41
41
  */
42
42
  experiments?: StorefrontEdgeExperiments;
43
43
  }
44
44
  export interface StorefrontEdgeExperiments {
45
45
  declared: Record<string, StorefrontExperiment> | undefined;
46
- /** The PostHog project token (`phc_…`), the same the storefront sends with. */
47
- posthogKey: string | undefined;
48
- /** PostHog's region. Default `us`. */
49
- region?: 'us' | 'eu';
50
- /** The flags request's deadline; past it every experiment is control. Default 400 ms. */
51
- timeoutMs?: number;
46
+ /**
47
+ * The PostHog project token (`phc_…`), the same the storefront sends with —
48
+ * used only to read PostHog's own cookie, so a returning visitor is bucketed
49
+ * by the id PostHog already knows them by. Optional: without it, `fz_vid`.
50
+ */
51
+ posthogKey?: string;
52
52
  }
53
53
  interface PageAssignment {
54
54
  assignments: ExperimentAssignments;
55
55
  /** The cache-key part; empty for control. */
56
56
  variant: string;
57
- /** Cookies for THIS visitor's response: a new id, a fresh assignment. */
57
+ /** Cookies for THIS visitor's response: a new id. */
58
58
  cookies: string[];
59
59
  }
60
- /** Decide this request's variants. Never throws; every failure is control. */
61
- export declare function assignForRequest(request: Request, options: StorefrontEdgeExperiments, fetchImpl?: typeof fetch): Promise<PageAssignment>;
60
+ /**
61
+ * Decide this request's variants — locally, with PostHog's bucketing, no
62
+ * network. Never throws.
63
+ */
64
+ export declare function assignForRequest(request: Request, options: StorefrontEdgeExperiments): Promise<PageAssignment>;
62
65
  /** The Worker's `fetch`, from the store's pieces. */
63
66
  export declare function createStorefrontEdge(options: StorefrontEdgeOptions): (request: Request) => Promise<Response>;
64
67
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"edge-handler.d.ts","sourceRoot":"","sources":["../../src/host/edge-handler.ts"],"names":[],"mappings":"AACA,OAAO,EAWL,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAA;AAwC9B,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAElD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAEhE;AAED,yEAAyE;AACzE,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC,CA6BtH;AAED;6EAC6E;AAC7E,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,SAAK,GAAG,OAAO,GAAG,IAAI,CAa5F;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAIzD;AAgBD,MAAM,WAAW,qBAAqB;IACpC,sEAAsE;IACtE,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,QAAQ,G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AAM,EAAE,oBAAoB,CAAC,GAAG,SAAS,CAAA;IAC1D;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAaD,UAAU,cAAc;IACtB,WAAW,EAAE,qBAAqB,CAAA;IAClC,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAA;IACf,qDAAqD;IACrD,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,cAAc,CAAC,CAyBpH;AAkBD,qDAAqD;AACrD,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAoC5G"}
package/dist/host.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { buildRobotsTxt, buildSitemapXml } from './chunk-WCAQRATH.js';
2
2
  export { buildRobotsTxt, buildSitemapXml } from './chunk-WCAQRATH.js';
3
- import { resolveConfig, storefrontPaths, isPublicPath, matchPath, collectDataNeeds, menuDataNeeds, resolvePageDataNeed, isKnownPath, productSeo, menuSeo, pageSeo, toBlockNodes, defaultPageBlocks } from './chunk-UJHCVRK3.js';
4
- export { menuDataNeeds } from './chunk-UJHCVRK3.js';
5
- import { validateExperiments } from './chunk-746BEU7H.js';
6
- export { EXPERIMENT_HEADER, decodeExperimentHeader } from './chunk-746BEU7H.js';
3
+ import { resolveConfig, storefrontPaths, isPublicPath, matchPath, collectDataNeeds, menuDataNeeds, resolvePageDataNeed, isKnownPath, productSeo, menuSeo, pageSeo, toBlockNodes, defaultPageBlocks } from './chunk-7N5HKQBM.js';
4
+ export { menuDataNeeds } from './chunk-7N5HKQBM.js';
5
+ import { validateExperiments } from './chunk-4REZOGGW.js';
6
+ export { EXPERIMENT_HEADER, decodeExperimentHeader } from './chunk-4REZOGGW.js';
7
7
  import { buildSeoTags } from '@fayz-ai/core';
8
8
  import { getShopProvider, setShopProvider } from '@fayz-ai/shop/runtime';
9
9
 
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  export { auditStorefrontSeo, collectSeoAuditInput } from './chunk-6IXTENLB.js';
2
- import { STORE_SECTION_NAMES, isRecord, STORE_SECTIONS, slugifyStoreName, exportStore, validateStore, isJsonValue, sectionToJsonSchema, STOREFRONT_PAGE_KINDS, STOREFRONT_COMPONENT_KEYS, hydrateStoreDocument } from './chunk-GI5BTJK6.js';
3
- export { STOREFRONT_COMPONENT_KEYS, STOREFRONT_PAGE_KINDS, STORE_BACKEND_PROVIDERS, STORE_COMMERCE_MODES, STORE_DOCUMENT_KIND, STORE_PAYMENT_METHOD_KINDS, STORE_PAYMENT_MODES, STORE_ROUTE_CHROMES, STORE_ROUTE_KINDS, STORE_SECTIONS, STORE_SECTION_NAMES, exportStore, hydrateStoreDocument, sectionToJsonSchema, slugifyStoreName, validateStore } from './chunk-GI5BTJK6.js';
4
- import { initStorefrontRuntime, StorefrontConfigHost, StorefrontShell, registerStorefrontBlocks, registerStorefrontExtensionPoints, STOREFRONT_SLOTS, useCatalogStore, formatMoney, useCartStore, useSessionStore, selectTotal, selectShipping, selectDiscountTotal, selectSubtotal, selectCount, placeStorefrontOrder, useDeliveryStore, useBuyerCountry, selectRequiresShipping, StorefrontPage } from './chunk-RYWQGQ4M.js';
5
- export { AddressForm, AddressSheet, AddressStrip, BEFORE_PLACE_ORDER_VALVE, BUYER_COUNTRY_COOKIE, BenefitsRow, CART_LINE_ANNOTATION_POINT, CHECKOUT_FIELD_POINT, CartDrawer, CatalogPage, CategoryShowcase, CheckoutPage, ClosedStoreDialog, CollectionCta, CollectionHero, ContentPage, CountdownBand, CountrySelect, DeliverToPicker, EmailConfirmationRequiredError, EntityListBlock, ExperimentBlock, ExperimentProvider, ExperimentVariantBlock, FaqSection, FiltersPanel, FormBlock, HeroSection, ImageTiles, ItemSheet, ManifestoBlock, MediaCarousel, MenuItemRow, MenuPage, MenuToolbar, MotifStrip, MyPurchasesPage, NewsletterBand, ORDER_METADATA_POINT, OrderConfirmationPage, OrderTrackingTimeline, PAGE_DATA_SCRIPT_ID, PLACEHOLDER_ASPECTS, PRODUCT_CARD_BADGE_POINT, PaymentTerms, Price, ProductCard, ProductDetailPage, ProductEnquiryForm, ProductGallery, ProductGrid, ProductOptionSelector, ProductRail, ProductReviews, ProductSlider, ProductSpecs, ProductSpotlight, PromoBanner, QuantityInput, Reveal, STOREFRONT_SLOTS, ScheduleSheet, SealsBand, SearchOverlay, ServiceHoursModal, Slot, SmoothImage, StepsSection, StoreCover, StorefrontAnalytics, StorefrontConfigHost, StorefrontFooter, StorefrontHeader, StorefrontPage, StorefrontShell, StorefrontThemeStyle, StoryQuote, THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX, TID, Testimonials, TierCards, applyDeliveryPolicy, applyStoreSettings, bannerPlaceholder, buildEnquiryFromForm, collectOrderMetadata, createStorefront, createStorefrontApp, entityListBlockMeta, establishCustomerSession, formatMoney, formatProductOptionSelection, getCartLineAnnotations, getCheckoutFieldContributions, getCustomerAuthAdapter, getProductCardBadges, getProductOptionGroups, hydratedEntriesFor, identifyStorefrontBuyer, initStorefrontRuntime, isExperimentBinding, listSlots, marketForCountry, marketUnitPrice, matchesFacets, mergeCollectionFacet, nextMilestone, normalizeProductOptionSelection, onStorefrontEvent, orderGalleryImages, overrideComponent, overrideProps, pickProductCardImage, placeStorefrontOrder, prefersReducedMotion, productCardComponentContract, productOptionSelectionKey, productPlaceholder, readHydratedPageData, registerStorefrontBlocks, registerStorefrontEntities, registerStorefrontExtensionPoints, registerStorefrontLoaders, resetPageDiagnostics, resetProductOptionsDeprecationWarnings, resetStorefrontExtensionPoints, resolveAuthAdapter, resolveExperimental, resolveOverride, resolvePaymentTerms, resolveStorefrontProvider, resolveVariantForSelection, roundCents, runBeforePlaceOrderValve, sectionsToBlocks, selectCount, selectDiscountTotal, selectIsOpen, selectShipping, selectShowsHours, selectSubtotal, selectTotal, selectionPrice, serializePageData, signInByEmail, signOutCustomer, signUpCustomer, startStorefrontPostHog, storeBuyerId, storefrontComponentContracts, themeToCss, toFacetMap, trackStorefront, useBuyerCountry, useBuyerStore, useCartStore, useCatalogStore, useCategories, useDiscountValidator, useEnquiry, useExperiment, useExperimentValue, useInView, useMarketProduct, useMarketStore, useMyOrders, usePopOnChange, useProduct, useProducts, useScrolled, useServiceStore, useSessionStore, useSlotContext, useStorefrontActions, useStorefrontHead, useStorefrontPage, useStorefrontPageOptional, useT, usedSlots, withFacet, withMarketPrice } from './chunk-RYWQGQ4M.js';
6
- import { resolveConfig, useStorefrontConfig, isNestedBlockRef, BLOCK_STRUCTURAL_KEYS, blockInstanceId } from './chunk-UJHCVRK3.js';
7
- export { BlockDataError, CATALOG_BODY_BLOCK, Link, MESSAGES, PRODUCT_BODY_BLOCK, PageDataScope, StorefrontConfigProvider, StorefrontRouterProvider, checkPageBlocks, collectDataNeeds, contentPagePath, currentStaticRenderPass, defaultPageBlocks, isKnownPath, isPublicPath, matchContentPage, matchPath, menuDataNeeds, menuJsonLd, menuSeo, mergePageTheme, navigateTo, normalizeLanguage, pageSeo, pageThemeSelector, primaryImageUrl, productJsonLd, productSeo, resolveConfig, resolveDataParams, resolvePageData, resolvePageDataNeed, resolveStorefrontRoute, routePathParams, shellRouterAdapter, storefrontPaths, toBlockNodes, translate, useBlockData, useHashPath, useLoader, useNavigate, useRoutePath, useRouterAdapter, useScrollToTopOnNavigate, useStorefrontConfig, useStorefrontConfigOptional, withStaticRenderPass } from './chunk-UJHCVRK3.js';
8
- export { CONTROL as EXPERIMENT_CONTROL, validateExperiments } from './chunk-746BEU7H.js';
2
+ import { STORE_SECTION_NAMES, isRecord, STORE_SECTIONS, slugifyStoreName, exportStore, validateStore, isJsonValue, sectionToJsonSchema, STOREFRONT_PAGE_KINDS, STOREFRONT_COMPONENT_KEYS, hydrateStoreDocument } from './chunk-G2R6OJQA.js';
3
+ export { STOREFRONT_COMPONENT_KEYS, STOREFRONT_PAGE_KINDS, STORE_BACKEND_PROVIDERS, STORE_COMMERCE_MODES, STORE_DOCUMENT_KIND, STORE_PAYMENT_METHOD_KINDS, STORE_PAYMENT_MODES, STORE_ROUTE_CHROMES, STORE_ROUTE_KINDS, STORE_SECTIONS, STORE_SECTION_NAMES, exportStore, hydrateStoreDocument, sectionToJsonSchema, slugifyStoreName, validateStore } from './chunk-G2R6OJQA.js';
4
+ import { initStorefrontRuntime, StorefrontConfigHost, StorefrontShell, registerStorefrontBlocks, registerStorefrontExtensionPoints, STOREFRONT_SLOTS, useCatalogStore, formatMoney, useCartStore, useSessionStore, selectTotal, selectShipping, selectDiscountTotal, selectSubtotal, selectCount, placeStorefrontOrder, useDeliveryStore, useBuyerCountry, selectRequiresShipping, StorefrontPage } from './chunk-OV6DVQMB.js';
5
+ export { AddressForm, AddressSheet, AddressStrip, BEFORE_PLACE_ORDER_VALVE, BUYER_COUNTRY_COOKIE, BenefitsRow, CART_LINE_ANNOTATION_POINT, CHECKOUT_FIELD_POINT, CartDrawer, CatalogPage, CategoryShowcase, CheckoutPage, ClosedStoreDialog, CollectionCta, CollectionHero, ContentPage, CountdownBand, CountrySelect, DeliverToPicker, EmailConfirmationRequiredError, EntityListBlock, ExperimentBlock, ExperimentProvider, ExperimentVariantBlock, FaqSection, FiltersPanel, FormBlock, HeroSection, ImageTiles, ItemSheet, ManifestoBlock, MediaCarousel, MenuItemRow, MenuPage, MenuToolbar, MotifStrip, MyPurchasesPage, NewsletterBand, ORDER_METADATA_POINT, OrderConfirmationPage, OrderTrackingTimeline, PAGE_DATA_SCRIPT_ID, PLACEHOLDER_ASPECTS, PRODUCT_CARD_BADGE_POINT, PaymentTerms, Price, ProductCard, ProductDetailPage, ProductEnquiryForm, ProductGallery, ProductGrid, ProductOptionSelector, ProductRail, ProductReviews, ProductSlider, ProductSpecs, ProductSpotlight, PromoBanner, QuantityInput, Reveal, STOREFRONT_SLOTS, ScheduleSheet, SealsBand, SearchOverlay, ServiceHoursModal, Slot, SmoothImage, StepsSection, StoreCover, StorefrontAnalytics, StorefrontConfigHost, StorefrontFooter, StorefrontHeader, StorefrontPage, StorefrontShell, StorefrontThemeStyle, StoryQuote, THEME_SCALE_FIELDS, THEME_SCALE_VAR_PREFIX, TID, Testimonials, TierCards, applyDeliveryPolicy, applyStoreSettings, bannerPlaceholder, buildEnquiryFromForm, collectOrderMetadata, createStorefront, createStorefrontApp, entityListBlockMeta, establishCustomerSession, formatMoney, formatProductOptionSelection, getCartLineAnnotations, getCheckoutFieldContributions, getCustomerAuthAdapter, getProductCardBadges, getProductOptionGroups, hydratedEntriesFor, identifyStorefrontBuyer, initStorefrontRuntime, isExperimentBinding, listSlots, marketForCountry, marketUnitPrice, matchesFacets, mergeCollectionFacet, nextMilestone, normalizeProductOptionSelection, onStorefrontEvent, orderGalleryImages, overrideComponent, overrideProps, pickProductCardImage, placeStorefrontOrder, prefersReducedMotion, productCardComponentContract, productOptionSelectionKey, productPlaceholder, readHydratedPageData, registerStorefrontBlocks, registerStorefrontEntities, registerStorefrontExtensionPoints, registerStorefrontLoaders, resetPageDiagnostics, resetProductOptionsDeprecationWarnings, resetStorefrontExtensionPoints, resolveAuthAdapter, resolveExperimental, resolveOverride, resolvePaymentTerms, resolveStorefrontProvider, resolveVariantForSelection, roundCents, runBeforePlaceOrderValve, sectionsToBlocks, selectCount, selectDiscountTotal, selectIsOpen, selectShipping, selectShowsHours, selectSubtotal, selectTotal, selectionPrice, serializePageData, signInByEmail, signOutCustomer, signUpCustomer, startStorefrontPostHog, storeBuyerId, storefrontComponentContracts, themeToCss, toFacetMap, trackStorefront, useBuyerCountry, useBuyerStore, useCartStore, useCatalogStore, useCategories, useDiscountValidator, useEnquiry, useExperiment, useExperimentValue, useInView, useMarketProduct, useMarketStore, useMyOrders, usePopOnChange, useProduct, useProducts, useScrolled, useServiceStore, useSessionStore, useSlotContext, useStorefrontActions, useStorefrontHead, useStorefrontPage, useStorefrontPageOptional, useT, usedSlots, withFacet, withMarketPrice } from './chunk-OV6DVQMB.js';
6
+ import { resolveConfig, useStorefrontConfig, isNestedBlockRef, BLOCK_STRUCTURAL_KEYS, blockInstanceId } from './chunk-7N5HKQBM.js';
7
+ export { BlockDataError, CATALOG_BODY_BLOCK, Link, MESSAGES, PRODUCT_BODY_BLOCK, PageDataScope, StorefrontConfigProvider, StorefrontRouterProvider, checkPageBlocks, collectDataNeeds, contentPagePath, currentStaticRenderPass, defaultPageBlocks, isKnownPath, isPublicPath, matchContentPage, matchPath, menuDataNeeds, menuJsonLd, menuSeo, mergePageTheme, navigateTo, normalizeLanguage, pageSeo, pageThemeSelector, primaryImageUrl, productJsonLd, productSeo, resolveConfig, resolveDataParams, resolvePageData, resolvePageDataNeed, resolveStorefrontRoute, routePathParams, shellRouterAdapter, storefrontPaths, toBlockNodes, translate, useBlockData, useHashPath, useLoader, useNavigate, useRoutePath, useRouterAdapter, useScrollToTopOnNavigate, useStorefrontConfig, useStorefrontConfigOptional, withStaticRenderPass } from './chunk-7N5HKQBM.js';
8
+ export { CONTROL as EXPERIMENT_CONTROL, validateExperiments } from './chunk-4REZOGGW.js';
9
9
  import React3 from 'react';
10
10
  import { defineApp, registerScaffold, describeExtensionPoints, handleRegistry, describeEntities, describeLoaders, describeBlocks, ENTITY_FIELD_TYPES, BLOCK_SETTING_TYPES, errorMessage, normalizePostalCode, lookupPostalCode, formatPostalCode, BLOCK_PATH_ATTRIBUTE, BLOCK_TYPE_ATTRIBUTE, setBlockEditorMode, renderApp as renderApp$1 } from '@fayz-ai/core';
11
11
  export { getHandle, getSupabaseClientOptional, handleNameFor, hasHandle, listHandles, registerHandle, resolveHandle } from '@fayz-ai/core';