@heyplaybook/hydrogen 0.8.0 → 0.9.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.
package/dist/index.d.ts CHANGED
@@ -479,6 +479,30 @@ declare function playbookHeadSnippet(cloak: PlaybookCloakConfig | null | undefin
479
479
  /** The same nodes as an HTML string, for a non-React head. '' when untargeted. */
480
480
  declare function playbookHeadSnippetHtml(cloak: PlaybookCloakConfig | null | undefined, options?: PlaybookHeadSnippetOptions): string;
481
481
 
482
+ /**
483
+ * 0.9.0: product-field tokens (`{{product.rating}}`, `{{product.model_line}}`,
484
+ * …) in a server-rendered arm — a VENDORED copy of the fill in the platform's
485
+ * `shared/src/editor-protocol/product-fields.ts` (the package can't import the
486
+ * monorepo's internal packages). `__tests__/product-fields.test.ts` fails if
487
+ * the two drift: the browser SDK adopts the server's markup, so both must
488
+ * produce the same bytes for the same product.
489
+ *
490
+ * A token names a fact of the page's product; the platform reads the values
491
+ * (`/api/storefront/product-fields`) and this fills them in. A token with no
492
+ * value for the product hides its element (the nearest `data-pb-field`
493
+ * element, else the innermost one): `data-pb-field-missing` plus an inline
494
+ * `display:none !important`. Values are HTML-escaped.
495
+ */
496
+ type ProductFields = Record<string, string>;
497
+ declare const PRODUCT_FIELD_MISSING_ATTR = "data-pb-field-missing";
498
+ declare function productTokensIn(html: unknown): string[];
499
+ interface FillResult {
500
+ html: string;
501
+ used: string[];
502
+ missing: string[];
503
+ }
504
+ declare function fillProductTokens(html: string, fields: ProductFields | null | undefined): FillResult;
505
+
482
506
  /**
483
507
  * 0.8.0: the server-render slot vocabulary — a VENDORED copy of the
484
508
  * platform's `shared/src/editor-protocol/ssr-slots.ts` (the package can't
@@ -528,6 +552,13 @@ interface SsrSnapshotNode {
528
552
  interface SsrSnapshot {
529
553
  v: number;
530
554
  nodes: SsrSnapshotNode[];
555
+ /**
556
+ * 0.9.0: the product-field tokens the markup names (`rating`,
557
+ * `model_line`, …). The platform sends a snapshot with tokens only to a
558
+ * package that asked for them (`fields=1` on the doc URL); the package
559
+ * reads the page product's values and fills them before rendering.
560
+ */
561
+ pf?: string[];
531
562
  }
532
563
  interface SsrArm {
533
564
  id: string;
@@ -584,6 +615,22 @@ interface SsrPreview {
584
615
  why: string | null;
585
616
  }
586
617
  declare function ssrUrl(platformUrl: string, shopDomain: string): string;
618
+ /** 0.9.0: the platform's read of one product's field values for one design. */
619
+ declare function productFieldsUrl(platformUrl: string, shopDomain: string, experienceId: string, handle: string): string;
620
+ /** The decision with its snapshot's tokens filled (`./product-fields`); a missing value hides its element. */
621
+ declare function fillSsrDecision(d: SsrDecision, fields: ProductFields | null): SsrDecision;
622
+ /**
623
+ * 0.9.0: fill a decision's product-field tokens before it renders. A product
624
+ * page reads its product's values; any other page has no product, so every
625
+ * token's element is hidden. `{skip}` when the values couldn't be read in
626
+ * time (the browser path draws the arm instead, filled by the platform).
627
+ */
628
+ declare function withProductFields(d: SsrDecision, args: {
629
+ platformUrl: string;
630
+ shopDomain: string;
631
+ waitUntil?: (p: Promise<unknown>) => void;
632
+ fetchImpl?: typeof fetch;
633
+ }): Promise<SsrOutcome>;
587
634
  /** The shop's SSR doc, or null when the read isn't healthy (then: cloak only). Never throws. */
588
635
  declare function getSsrPayload(args: {
589
636
  platformUrl: string;
@@ -591,6 +638,26 @@ declare function getSsrPayload(args: {
591
638
  waitUntil?: (p: Promise<unknown>) => void;
592
639
  fetchImpl?: typeof fetch;
593
640
  }): Promise<SsrPayload | null>;
641
+ /**
642
+ * 0.8.1: the TOTAL budget for the uncached preview read, retry included. Only
643
+ * a `?pb=` preview (staff and the merchant looking at one test) ever waits on
644
+ * it; shopper reads keep `COLD_RENDER_BUDGET_MS` / `RENDER_BUDGET_MS`
645
+ * (./rules.ts). 0.7.1 had 1.5s, and a cold platform function missed it, so
646
+ * the first open of a preview link fell back to the browser's `?pb` path.
647
+ */
648
+ declare const PREVIEW_FETCH_BUDGET_MS = 5000;
649
+ /** 0.8.1: one attempt's share of the budget; a timed-out first attempt leaves room for the retry. */
650
+ declare const PREVIEW_ATTEMPT_BUDGET_MS = 3000;
651
+ /**
652
+ * 0.8.1: the cookie that carries a preview code across CLIENT-SIDE
653
+ * navigations. The browser strips `?pb=` from the address bar once it has
654
+ * resolved the code, so React Router's `.data` requests for later pages don't
655
+ * carry it. Session-only, HttpOnly, Lax. Set when a document request's code
656
+ * is valid; honoured ONLY on `.data` requests; cleared by any full page
657
+ * load without `?pb=` (Exit reloads, a new tab, a typed URL — see
658
+ * `isDocumentRequest`), so it can't follow anyone out of the preview.
659
+ */
660
+ declare const PREVIEW_CODE_COOKIE = "_pb_preview_code";
594
661
  /**
595
662
  * The arm index for `seed` + `id` over `weights` (coverage 1), or -1. GrowthBook
596
663
  * v2: `fnv32a(fnv32a(seed + id) + "") % 10000 / 10000`; weights that don't sum
@@ -614,6 +681,13 @@ interface SsrDecision {
614
681
  code: string;
615
682
  testName: string;
616
683
  armLabel: string;
684
+ /**
685
+ * 0.8.1: decided on a `.data` request (a client-side navigation). It
686
+ * reaches the page through React, not the HTML, so `<PlaybookSlot>` and
687
+ * `<PlaybookSsrHead>` render it only in a tab previewing this code
688
+ * (`carriedPreviewAllowed`).
689
+ */
690
+ carried?: boolean;
617
691
  };
618
692
  /**
619
693
  * 0.8.0: which kind of declared slot serves the arm (`loaderData()` sets it):
@@ -892,6 +966,11 @@ declare function matchTargetedPage(pages: readonly string[] | null | undefined,
892
966
  * `window.__pbSsr` (so the SDK adopts the arm and reports it as shown) and the
893
967
  * arm's theme-section hides, before first paint. Renders nothing without a
894
968
  * decision.
969
+ *
970
+ * 0.8.1: a carried preview decision arrives with a client-side navigation, so
971
+ * an inline <script> would never run: `window.__pbSsr` is set from a layout
972
+ * effect instead, in the same commit that inserts the host, before the
973
+ * experience SDK looks at the new page.
895
974
  */
896
975
  declare function PlaybookSsrHead({ ssr, nonce }: {
897
976
  ssr: SsrDecision | null | undefined;
@@ -1525,4 +1604,4 @@ declare function inNamespace(hashValue: string, namespace: [string, number, numb
1525
1604
  declare function chooseVariation(n: number, ranges: VariationRange[]): number;
1526
1605
  declare function getBucketRanges(numVariations: number, coverage: number | undefined, weights?: number[]): VariationRange[];
1527
1606
 
1528
- export { AA_SITEWIDE_TEST, type AddToCartSource, type AddedLineInput, CART_SYNC_IDLE_MS, CART_VISITOR_ATTRIBUTE, CLOAK_MAX_MS, CLOAK_STYLE_ID, CONSENT_LOADED_EVENTS, CONTROL_ARM, type CartAttribute, type CartAttributeReader, type CartAttributeWriter, type CartLineSnapshot, type CartSyncEvent, type CartSyncSnapshot, type CartWriteResult, type ConsentState, type CreatePlaybookContextOptions, type CreatePlaybookOptions, DEFAULT_DATALAYER_EVENT, DEFAULT_EVENT_URL, DEFAULT_EXPERIENCE_SDK_URL, DEFAULT_EXPOSURE_URL, DEFAULT_PLATFORM_URL, DEFAULT_PROXY_ENDPOINT, DEFAULT_SDK_URL, DEFAULT_SUPPORTED_EVENTS, EXPERIENCE_SDK_SCRIPT_ID, EXPERIENCE_VISITOR_CART_ATTRIBUTE, EXPOSURE_CART_ATTRIBUTE, EXPOSURE_COOKIE, type ExperienceAttributionConsent, type ExperienceAttributionInput, type HeadSnippetParts, LEGACY_VISITOR_COOKIE, MAX_WRITES_PER_CART, PlaybookAAExposure, type PlaybookArm, type PlaybookAssignReason, type PlaybookAssignment, PlaybookBoundary, type PlaybookCartAdapter, type PlaybookClientConsent, type PlaybookCloakConfig, PlaybookCloakHead, type PlaybookConsentAdapter, type PlaybookDataLayerOption, type PlaybookDebugExplain, type PlaybookDebugOptions, PlaybookDebugPanel, type PlaybookDevice, type PlaybookEnv, PlaybookExposure, PlaybookHead, type PlaybookHeadProps, type PlaybookHeadSnippetOptions, type PlaybookLoaderData, type PlaybookPreview, PlaybookProvider, type PlaybookProxyOptions, type PlaybookRequestContext, PlaybookRoot, type PlaybookRootProps, type PlaybookRuleset, PlaybookSections, type PlaybookServerConsent, type PlaybookServerResult, PlaybookSlot, type PlaybookSlotKey, type PlaybookSlotName, type PlaybookSlotProps, PlaybookSsrHead, type PlaybookState, type PlaybookStoreContext, type PlaybookTestRule, type PlaybookTestStatus, type PlaybookVariant, type PlaybookVisitorType, type RulesetSource, SECTION_SLOTS, SESSION_VISITOR_COOKIE, SLOT_REPORT_SAMPLE_RATE, SLOT_REPORT_URL, SSR_SLOT_ATTR, SSR_SLOT_NAMES, STANDARD_EVENTS, type SectionSlotKey, type SsrDecision, type SsrOutcome, type SsrPayload, type SsrSlotRef, type StandardEvent, TRUEVAULT_CONSENT_COOKIE, type TrackScope, type TrackedEntry, type TrueVaultConsentOptions, VISITOR_COOKIE, addedLinesFrom, analyticsConsentFromCookie, armSlot, assignTest, bucketIndex, buildHeadSnippet, cartHasPlaybookAttribute, chooseVariation, consentFromAnalytics, createCartAttributeReader, createCartAttributeSync, createCartAttributeWriter, createPlaybook, createPlaybookContext, createPlaybookProxyHandler, createTrueVaultConsent, debugPanelAllowed, decideSsr, declareConsentRequired, detectDevice, detectGeo, experienceVisitorIdFromCookies, getBucketRanges, getConsentState, getEqualWeights, getServerTrackedLog, getSessionContext, getSsrPayload, getTargetedPages, getTrackedLog, hasPlaybookParams, hasSentExposure, hash, inNamespace, isAnalyticsConsentGranted, isKillSwitchOn, isPreviewHost, isSlotKey, manifestUrl, matchTargetedPage, matchesPathPrefix, mergeAttributes, normalizeExposureList, onConsentChange, onConsentLoaded, playbookBackendUrl, playbookCartAttribute, playbookHeadSnippet, playbookHeadSnippetHtml, playbookTrack, prefetchRuleset, reconcileExperienceCartAttributes, reconcilePlaybookCartAttribute, renderedSlotKeys, reportPageSlots, revealScript, sanitizeManifestPages, sanitizeRuleset, sectionSlotKey, setNextAddSource, shopifyCustomerPrivacyConsent, slotFromSelector, slotMatches, slotSelector, ssrHostInnerHtml, ssrUrl, subscribeTrackedLog, syncVisitorId, takeAddSource, targetPageKey, trackAddToCart, trackAddToCartLines, trueVaultDecision, truevaultConsent, useAnalyticsAllowed, usePageEngagement, usePlaybookConsent, usePlaybookExposure, usePlaybookInteraction, usePlaybookState, usePlaybookVariant, usePreviewParamRedirect, visitorInRunningTest, visitorSeedScript, waitForConsentAPI, withPlaybook, withPlaybookCartAttribute };
1607
+ export { AA_SITEWIDE_TEST, type AddToCartSource, type AddedLineInput, CART_SYNC_IDLE_MS, CART_VISITOR_ATTRIBUTE, CLOAK_MAX_MS, CLOAK_STYLE_ID, CONSENT_LOADED_EVENTS, CONTROL_ARM, type CartAttribute, type CartAttributeReader, type CartAttributeWriter, type CartLineSnapshot, type CartSyncEvent, type CartSyncSnapshot, type CartWriteResult, type ConsentState, type CreatePlaybookContextOptions, type CreatePlaybookOptions, DEFAULT_DATALAYER_EVENT, DEFAULT_EVENT_URL, DEFAULT_EXPERIENCE_SDK_URL, DEFAULT_EXPOSURE_URL, DEFAULT_PLATFORM_URL, DEFAULT_PROXY_ENDPOINT, DEFAULT_SDK_URL, DEFAULT_SUPPORTED_EVENTS, EXPERIENCE_SDK_SCRIPT_ID, EXPERIENCE_VISITOR_CART_ATTRIBUTE, EXPOSURE_CART_ATTRIBUTE, EXPOSURE_COOKIE, type ExperienceAttributionConsent, type ExperienceAttributionInput, type HeadSnippetParts, LEGACY_VISITOR_COOKIE, MAX_WRITES_PER_CART, PREVIEW_ATTEMPT_BUDGET_MS, PREVIEW_CODE_COOKIE, PREVIEW_FETCH_BUDGET_MS, PRODUCT_FIELD_MISSING_ATTR, PlaybookAAExposure, type PlaybookArm, type PlaybookAssignReason, type PlaybookAssignment, PlaybookBoundary, type PlaybookCartAdapter, type PlaybookClientConsent, type PlaybookCloakConfig, PlaybookCloakHead, type PlaybookConsentAdapter, type PlaybookDataLayerOption, type PlaybookDebugExplain, type PlaybookDebugOptions, PlaybookDebugPanel, type PlaybookDevice, type PlaybookEnv, PlaybookExposure, PlaybookHead, type PlaybookHeadProps, type PlaybookHeadSnippetOptions, type PlaybookLoaderData, type PlaybookPreview, PlaybookProvider, type PlaybookProxyOptions, type PlaybookRequestContext, PlaybookRoot, type PlaybookRootProps, type PlaybookRuleset, PlaybookSections, type PlaybookServerConsent, type PlaybookServerResult, PlaybookSlot, type PlaybookSlotKey, type PlaybookSlotName, type PlaybookSlotProps, PlaybookSsrHead, type PlaybookState, type PlaybookStoreContext, type PlaybookTestRule, type PlaybookTestStatus, type PlaybookVariant, type PlaybookVisitorType, type ProductFields, type RulesetSource, SECTION_SLOTS, SESSION_VISITOR_COOKIE, SLOT_REPORT_SAMPLE_RATE, SLOT_REPORT_URL, SSR_SLOT_ATTR, SSR_SLOT_NAMES, STANDARD_EVENTS, type SectionSlotKey, type SsrDecision, type SsrOutcome, type SsrPayload, type SsrSlotRef, type StandardEvent, TRUEVAULT_CONSENT_COOKIE, type TrackScope, type TrackedEntry, type TrueVaultConsentOptions, VISITOR_COOKIE, addedLinesFrom, analyticsConsentFromCookie, armSlot, assignTest, bucketIndex, buildHeadSnippet, cartHasPlaybookAttribute, chooseVariation, consentFromAnalytics, createCartAttributeReader, createCartAttributeSync, createCartAttributeWriter, createPlaybook, createPlaybookContext, createPlaybookProxyHandler, createTrueVaultConsent, debugPanelAllowed, decideSsr, declareConsentRequired, detectDevice, detectGeo, experienceVisitorIdFromCookies, fillProductTokens, fillSsrDecision, getBucketRanges, getConsentState, getEqualWeights, getServerTrackedLog, getSessionContext, getSsrPayload, getTargetedPages, getTrackedLog, hasPlaybookParams, hasSentExposure, hash, inNamespace, isAnalyticsConsentGranted, isKillSwitchOn, isPreviewHost, isSlotKey, manifestUrl, matchTargetedPage, matchesPathPrefix, mergeAttributes, normalizeExposureList, onConsentChange, onConsentLoaded, playbookBackendUrl, playbookCartAttribute, playbookHeadSnippet, playbookHeadSnippetHtml, playbookTrack, prefetchRuleset, productFieldsUrl, productTokensIn, reconcileExperienceCartAttributes, reconcilePlaybookCartAttribute, renderedSlotKeys, reportPageSlots, revealScript, sanitizeManifestPages, sanitizeRuleset, sectionSlotKey, setNextAddSource, shopifyCustomerPrivacyConsent, slotFromSelector, slotMatches, slotSelector, ssrHostInnerHtml, ssrUrl, subscribeTrackedLog, syncVisitorId, takeAddSource, targetPageKey, trackAddToCart, trackAddToCartLines, trueVaultDecision, truevaultConsent, useAnalyticsAllowed, usePageEngagement, usePlaybookConsent, usePlaybookExposure, usePlaybookInteraction, usePlaybookState, usePlaybookVariant, usePreviewParamRedirect, visitorInRunningTest, visitorSeedScript, waitForConsentAPI, withPlaybook, withPlaybookCartAttribute, withProductFields };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import { memo, createContext, isValidElement, Fragment as Fragment$1, Component, useContext, useMemo, useCallback, useState, useEffect, useSyncExternalStore, useRef } from 'react';
2
+ import { memo, createContext, isValidElement, Fragment as Fragment$1, Component, useContext, useMemo, useCallback, useState, useEffect, useSyncExternalStore, useLayoutEffect, useRef } from 'react';
3
3
 
4
4
  // src/growthbook.ts
5
5
  function hashFnv32a(str2) {
@@ -1110,13 +1110,200 @@ function slotFromSelector(selector) {
1110
1110
  return isSlotKey(key) ? key : null;
1111
1111
  }
1112
1112
 
1113
+ // src/product-fields.ts
1114
+ var PRODUCT_FIELD_MISSING_ATTR = "data-pb-field-missing";
1115
+ var SEGMENT = /^[A-Za-z0-9_-]{1,64}$/;
1116
+ var TOKEN_RE = /\{\{\s*product\.([A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+){0,2})\s*\}\}/g;
1117
+ function mayHaveProductTokens(html) {
1118
+ return typeof html === "string" && html.includes("{{") && /\{\{\s*product\./.test(html);
1119
+ }
1120
+ function normalizeFieldPath(raw) {
1121
+ const parts = raw.split(".");
1122
+ if (!parts.every((p) => SEGMENT.test(p))) return null;
1123
+ const head = parts[0].toLowerCase();
1124
+ if (head === "metafield") return parts.length === 3 ? `metafield.${parts[1]}.${parts[2]}` : null;
1125
+ if (head === "detail") return parts.length === 2 ? `detail.${parts[1].toLowerCase().replace(/-/g, "_")}` : null;
1126
+ return parts.length === 1 ? head : null;
1127
+ }
1128
+ function productTokensIn(html) {
1129
+ if (!mayHaveProductTokens(html)) return [];
1130
+ const out = [];
1131
+ for (const m of html.matchAll(TOKEN_RE)) {
1132
+ const path = normalizeFieldPath(m[1]);
1133
+ if (path && !out.includes(path)) out.push(path);
1134
+ }
1135
+ return out;
1136
+ }
1137
+ var escapeHtml = (s2) => s2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
1138
+ var VOID = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "source", "track", "wbr"]);
1139
+ var GROUP_RE = /\sdata-pb-field(?=[\s=/>]|$)/i;
1140
+ function hideTag(tag) {
1141
+ if (tag.includes(PRODUCT_FIELD_MISSING_ATTR)) return tag;
1142
+ const name = /^<[A-Za-z][A-Za-z0-9-]*/.exec(tag)?.[0] ?? "";
1143
+ if (!name) return tag;
1144
+ let rest = tag.slice(name.length);
1145
+ const style = /(\sstyle\s*=\s*)("([^"]*)"|'([^']*)')/i.exec(rest);
1146
+ if (style) {
1147
+ const quote = style[2][0];
1148
+ const value = style[3] ?? style[4] ?? "";
1149
+ rest = rest.slice(0, style.index) + `${style[1]}${quote}display:none !important;${value}${quote}` + rest.slice(style.index + style[0].length);
1150
+ return `${name} ${PRODUCT_FIELD_MISSING_ATTR}=""${rest}`;
1151
+ }
1152
+ return `${name} ${PRODUCT_FIELD_MISSING_ATTR}="" style="display:none !important"${rest}`;
1153
+ }
1154
+ function tagEnd(html, i) {
1155
+ let quote = null;
1156
+ for (let j = i + 1; j < html.length; j++) {
1157
+ const c = html[j];
1158
+ if (quote) {
1159
+ if (c === quote) quote = null;
1160
+ } else if (c === '"' || c === "'") quote = c;
1161
+ else if (c === ">") return j;
1162
+ }
1163
+ return -1;
1164
+ }
1165
+ function fillProductTokens(html, fields) {
1166
+ if (typeof html !== "string" || !mayHaveProductTokens(html)) return { html: typeof html === "string" ? html : "", used: [], missing: [] };
1167
+ const used = [];
1168
+ const missing = [];
1169
+ const valueOf = (raw) => {
1170
+ const path = normalizeFieldPath(raw);
1171
+ if (path && !used.includes(path)) used.push(path);
1172
+ const v = path && fields ? fields[path] : void 0;
1173
+ const ok = typeof v === "string" && v.trim().length > 0;
1174
+ if (!ok && path && !missing.includes(path)) missing.push(path);
1175
+ return ok ? v.trim() : null;
1176
+ };
1177
+ const fillRun = (run) => {
1178
+ let missed = false;
1179
+ const text = run.replace(TOKEN_RE, (_m, raw) => {
1180
+ const v = valueOf(raw);
1181
+ if (v == null) {
1182
+ missed = true;
1183
+ return "";
1184
+ }
1185
+ return escapeHtml(v);
1186
+ });
1187
+ return { text, missed };
1188
+ };
1189
+ const out = [];
1190
+ const stack = [];
1191
+ const hidden = /* @__PURE__ */ new Set();
1192
+ const hideFor = (self) => {
1193
+ const chain = self ? [...stack, self] : stack;
1194
+ for (let k = chain.length - 1; k >= 0; k--) {
1195
+ if (chain[k].group) {
1196
+ hidden.add(chain[k].slot);
1197
+ return;
1198
+ }
1199
+ }
1200
+ const target = self ?? stack[stack.length - 1];
1201
+ if (target) hidden.add(target.slot);
1202
+ };
1203
+ let i = 0;
1204
+ while (i < html.length) {
1205
+ const lt = html.indexOf("<", i);
1206
+ const textEnd = lt === -1 ? html.length : lt;
1207
+ if (textEnd > i) {
1208
+ const { text: text2, missed: missed2 } = fillRun(html.slice(i, textEnd));
1209
+ out.push(text2);
1210
+ if (missed2) hideFor(null);
1211
+ i = textEnd;
1212
+ continue;
1213
+ }
1214
+ if (html.startsWith("<!--", i)) {
1215
+ const end2 = html.indexOf("-->", i + 4);
1216
+ const stop = end2 === -1 ? html.length : end2 + 3;
1217
+ out.push(html.slice(i, stop));
1218
+ i = stop;
1219
+ continue;
1220
+ }
1221
+ const close = /^<\/([A-Za-z][A-Za-z0-9-]*)[^>]*>/.exec(html.slice(i, i + 200));
1222
+ if (close) {
1223
+ const name2 = close[1].toLowerCase();
1224
+ const at = stack.map((t) => t.name).lastIndexOf(name2);
1225
+ if (at !== -1) stack.length = at;
1226
+ out.push(close[0]);
1227
+ i += close[0].length;
1228
+ continue;
1229
+ }
1230
+ if (!/[A-Za-z]/.test(html[i + 1] ?? "")) {
1231
+ out.push("<");
1232
+ i += 1;
1233
+ continue;
1234
+ }
1235
+ const end = tagEnd(html, i);
1236
+ if (end === -1) {
1237
+ out.push(fillRun(html.slice(i)).text);
1238
+ break;
1239
+ }
1240
+ const raw = html.slice(i, end + 1);
1241
+ const name = (/^<([A-Za-z][A-Za-z0-9-]*)/.exec(raw)?.[1] ?? "").toLowerCase();
1242
+ const { text, missed } = fillRun(raw);
1243
+ const tag = { name, slot: out.length, group: GROUP_RE.test(raw) };
1244
+ out.push(text);
1245
+ if (missed) hideFor(tag);
1246
+ if (!VOID.has(name) && !/\/\s*>$/.test(raw)) stack.push(tag);
1247
+ i = end + 1;
1248
+ }
1249
+ for (const slot of hidden) out[slot] = hideTag(out[slot]);
1250
+ return { html: out.join(""), used, missing };
1251
+ }
1252
+
1113
1253
  // src/ssr.ts
1114
1254
  var SSR_SNAPSHOT_VERSION = 1;
1115
1255
  function ssrUrl(platformUrl, shopDomain) {
1116
1256
  const url = new URL("/api/storefront/ssr", platformUrl);
1117
1257
  url.searchParams.set("shop", shopDomain);
1258
+ url.searchParams.set("fields", "1");
1118
1259
  return url.toString();
1119
1260
  }
1261
+ function productFieldsUrl(platformUrl, shopDomain, experienceId, handle) {
1262
+ const url = new URL("/api/storefront/product-fields", platformUrl);
1263
+ url.searchParams.set("shop", shopDomain);
1264
+ url.searchParams.set("x", experienceId);
1265
+ url.searchParams.set("handle", handle);
1266
+ return url.toString();
1267
+ }
1268
+ function sanitizeProductFields(json) {
1269
+ if (!json || typeof json !== "object") return null;
1270
+ const f = json.fields;
1271
+ if (!f || typeof f !== "object" || Array.isArray(f)) return null;
1272
+ const fields = {};
1273
+ for (const [k, v] of Object.entries(f)) if (typeof v === "string") fields[k] = v;
1274
+ return { fields };
1275
+ }
1276
+ var productFieldsFetcher = createCachedJsonFetcher({ label: "product fields", sanitize: sanitizeProductFields });
1277
+ function decisionNeedsProductFields(d) {
1278
+ if (!d.snapshot) return false;
1279
+ return !!d.snapshot.pf?.length || d.snapshot.nodes.some((n) => mayHaveProductTokens(n.html));
1280
+ }
1281
+ async function getSsrProductFields(args) {
1282
+ try {
1283
+ const { value, source } = await productFieldsFetcher.getWithSource({
1284
+ url: productFieldsUrl(args.platformUrl, args.shopDomain, args.experienceId, args.handle),
1285
+ waitUntil: args.waitUntil,
1286
+ fetchImpl: args.fetchImpl
1287
+ });
1288
+ return value && HEALTHY2.has(source) ? value.fields : null;
1289
+ } catch {
1290
+ return null;
1291
+ }
1292
+ }
1293
+ function fillSsrDecision(d, fields) {
1294
+ if (!d.snapshot) return d;
1295
+ return {
1296
+ ...d,
1297
+ snapshot: { ...d.snapshot, nodes: d.snapshot.nodes.map((n) => ({ ...n, html: fillProductTokens(n.html || "", fields).html })) }
1298
+ };
1299
+ }
1300
+ async function withProductFields(d, args) {
1301
+ if (!decisionNeedsProductFields(d) || !d.experienceId) return { decision: d };
1302
+ if (d.page.t !== "product" || !d.page.h) return { decision: fillSsrDecision(d, null) };
1303
+ const fields = await getSsrProductFields({ ...args, experienceId: d.experienceId, handle: d.page.h });
1304
+ if (!fields) return { skip: "product-fields-unavailable" };
1305
+ return { decision: fillSsrDecision(d, fields) };
1306
+ }
1120
1307
  function sanitizeSsrPayload(json) {
1121
1308
  if (!json || typeof json !== "object") return null;
1122
1309
  const j = json;
@@ -1144,31 +1331,84 @@ async function getSsrPayload(args) {
1144
1331
  }
1145
1332
  var PREVIEW_CODE_RE = /^[0-9A-HJKMNP-TV-Z]{4,8}$/;
1146
1333
  function previewCodeFromRequestUrl(url) {
1147
- const raw = url.searchParams.get("pb");
1148
- if (!raw) return null;
1149
- const code = raw.trim().toUpperCase();
1150
- return PREVIEW_CODE_RE.test(code) ? code : null;
1334
+ return normalizePreviewCode(url.searchParams.get("pb"));
1151
1335
  }
1152
- var PREVIEW_FETCH_BUDGET_MS = 1500;
1153
- async function getSsrPreviewPayload(args) {
1336
+ var PREVIEW_FETCH_BUDGET_MS = 5e3;
1337
+ var PREVIEW_ATTEMPT_BUDGET_MS = 3e3;
1338
+ var PREVIEW_RETRY_MIN_MS = 500;
1339
+ async function previewAttempt(url, timeoutMs, fetchImpl) {
1154
1340
  const controller = new AbortController();
1155
- const timer = setTimeout(() => controller.abort(), PREVIEW_FETCH_BUDGET_MS);
1341
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
1342
+ try {
1343
+ const res = await fetchImpl(url, { headers: { accept: "application/json" }, signal: controller.signal });
1344
+ if (!res.ok) return { payload: null, retry: res.status >= 500 };
1345
+ return { payload: sanitizeSsrPayload(await res.json()), retry: false };
1346
+ } catch {
1347
+ return { payload: null, retry: true };
1348
+ } finally {
1349
+ clearTimeout(timer);
1350
+ }
1351
+ }
1352
+ async function getSsrPreviewPayload(args) {
1156
1353
  try {
1157
1354
  const url = new URL(ssrUrl(args.platformUrl, args.shopDomain));
1158
1355
  url.searchParams.set("pb", args.code);
1159
- const res = await (args.fetchImpl ?? fetch)(url.toString(), {
1160
- headers: { accept: "application/json" },
1161
- signal: controller.signal
1162
- });
1163
- if (!res.ok) return null;
1164
- return sanitizeSsrPayload(await res.json());
1356
+ const budget = args.budgetMs ?? PREVIEW_FETCH_BUDGET_MS;
1357
+ const perAttempt = Math.min(args.attemptBudgetMs ?? PREVIEW_ATTEMPT_BUDGET_MS, budget);
1358
+ const fetchImpl = args.fetchImpl ?? fetch;
1359
+ const started = Date.now();
1360
+ const first = await previewAttempt(url.toString(), perAttempt, fetchImpl);
1361
+ if (first.payload || !first.retry) return first.payload;
1362
+ const left = budget - (Date.now() - started);
1363
+ if (left < Math.min(PREVIEW_RETRY_MIN_MS, budget / 4)) return null;
1364
+ return (await previewAttempt(url.toString(), left, fetchImpl)).payload;
1165
1365
  } catch {
1166
1366
  return null;
1167
- } finally {
1168
- clearTimeout(timer);
1169
1367
  }
1170
1368
  }
1171
- function decidePreviewSsr(payload, pageKey, matchesPage) {
1369
+ var PREVIEW_CODE_COOKIE = "_pb_preview_code";
1370
+ function normalizePreviewCode(raw) {
1371
+ if (!raw) return null;
1372
+ const code = raw.trim().toUpperCase();
1373
+ return PREVIEW_CODE_RE.test(code) ? code : null;
1374
+ }
1375
+ function isDataRequest(url) {
1376
+ return url.pathname.endsWith(".data");
1377
+ }
1378
+ var DOCUMENT_FETCH_DESTS = /* @__PURE__ */ new Set(["document", "iframe", "frame"]);
1379
+ function isDocumentRequest(request, url) {
1380
+ if (isDataRequest(url) || url.pathname === "/__manifest") return false;
1381
+ const dest = request.headers.get("sec-fetch-dest");
1382
+ if (dest) return DOCUMENT_FETCH_DESTS.has(dest.trim().toLowerCase());
1383
+ return (request.headers.get("accept") ?? "").toLowerCase().includes("text/html");
1384
+ }
1385
+ function dataRequestPagePath(pathname) {
1386
+ if (!pathname.endsWith(".data")) return pathname;
1387
+ if (pathname === "/_root.data") return "/";
1388
+ return pathname.slice(0, -".data".length) || "/";
1389
+ }
1390
+ var PREVIEW_SESSION_STORAGE_KEY = "_pb_preview";
1391
+ function carriedPreviewAllowed(d) {
1392
+ if (!d?.preview) return false;
1393
+ if (!d.preview.carried) return true;
1394
+ if (typeof window === "undefined") return false;
1395
+ const code = d.preview.code;
1396
+ try {
1397
+ const live = window.__pbSsr;
1398
+ if (live?.preview?.code === code) return true;
1399
+ } catch {
1400
+ }
1401
+ try {
1402
+ const raw = window.sessionStorage?.getItem(PREVIEW_SESSION_STORAGE_KEY);
1403
+ if (!raw) return false;
1404
+ const s2 = JSON.parse(raw);
1405
+ if (typeof s2?.code !== "string" || s2.code.toUpperCase() !== code) return false;
1406
+ return typeof s2.expiresAt !== "string" || Date.parse(s2.expiresAt) > Date.now();
1407
+ } catch {
1408
+ return false;
1409
+ }
1410
+ }
1411
+ function decidePreviewSsr(payload, pageKey, matchesPage, carried = false) {
1172
1412
  const p = payload.preview;
1173
1413
  if (!p) return { skip: "preview-unresolved" };
1174
1414
  if (p.why) return { skip: `preview-${p.why}` };
@@ -1186,7 +1426,7 @@ function decidePreviewSsr(payload, pageKey, matchesPage) {
1186
1426
  arm: p.arm,
1187
1427
  snapshot: p.snapshot,
1188
1428
  page: { t, h },
1189
- preview: { code: p.code, testName: p.testName, armLabel: p.armLabel }
1429
+ preview: { code: p.code, testName: p.testName, armLabel: p.armLabel, ...carried ? { carried: true } : {} }
1190
1430
  }
1191
1431
  };
1192
1432
  }
@@ -1291,7 +1531,10 @@ function ssrHostInnerHtml(snapshot, page) {
1291
1531
  return `<template shadowrootmode="open"><style data-pb-ssr-snapshot>${BASE}</style><div data-pb-experience-root data-pb-ssr-snapshot>${nodes}</div></template>`;
1292
1532
  }
1293
1533
  function ssrStateScript(d) {
1294
- const state = {
1534
+ return `window.__pbSsr=${JSON.stringify(ssrStateObject(d)).replace(/</g, "\\u003c")};`;
1535
+ }
1536
+ function ssrStateObject(d) {
1537
+ return {
1295
1538
  experimentId: d.experimentId,
1296
1539
  armId: d.armId,
1297
1540
  experienceId: d.experienceId,
@@ -1303,7 +1546,6 @@ function ssrStateScript(d) {
1303
1546
  // A preview render: the SDK keeps it without resolving or recording.
1304
1547
  ...d.preview ? { preview: d.preview } : {}
1305
1548
  };
1306
- return `window.__pbSsr=${JSON.stringify(state).replace(/</g, "\\u003c")};`;
1307
1549
  }
1308
1550
  function armSlot(a) {
1309
1551
  if (!a) return null;
@@ -1361,6 +1603,35 @@ function createPlaybookContext({
1361
1603
  const platformUrl = platformUrlOption || str(e.PLAYBOOK_PLATFORM_URL) || DEFAULT_PLATFORM_URL;
1362
1604
  let promise = null;
1363
1605
  let settled = false;
1606
+ const requestUrl = (() => {
1607
+ try {
1608
+ return new URL(request.url);
1609
+ } catch {
1610
+ return null;
1611
+ }
1612
+ })();
1613
+ const isGet = request.method === "GET";
1614
+ const isData = !!requestUrl && isDataRequest(requestUrl);
1615
+ const urlCode = requestUrl ? previewCodeFromRequestUrl(requestUrl) : null;
1616
+ const carryCookieRaw = isGet ? parseCookies(request.headers.get("cookie"))[PREVIEW_CODE_COOKIE] : void 0;
1617
+ const carryCode = normalizePreviewCode(carryCookieRaw);
1618
+ const previewCode = shopId && isGet && ssrSlots.length > 0 ? isData ? urlCode ?? carryCode : urlCode : null;
1619
+ const extraCookies = [];
1620
+ const secure = requestUrl?.protocol === "https:";
1621
+ const setCarry = (code) => extraCookies.push(serializeCookie(PREVIEW_CODE_COOKIE, code, { httpOnly: true, secure }));
1622
+ const clearCarry = () => extraCookies.push(serializeCookie(PREVIEW_CODE_COOKIE, "", { httpOnly: true, secure, maxAge: 0 }));
1623
+ const isDocument = !!requestUrl && isDocumentRequest(request, requestUrl);
1624
+ if (shopId && isGet && isDocument && !urlCode && carryCookieRaw !== void 0) clearCarry();
1625
+ let previewFetch = null;
1626
+ const previewShopDomain = () => requestUrl ? normalizeDomain(shopDomainOption ?? str(e.PUBLIC_PLAYBOOK_SHOP_DOMAIN) ?? requestUrl.hostname) : "";
1627
+ const previewPayload = () => {
1628
+ if (!previewFetch) {
1629
+ const shopDomain = previewShopDomain();
1630
+ previewFetch = previewCode && shopDomain ? getSsrPreviewPayload({ platformUrl, shopDomain, code: previewCode, fetchImpl }).catch(() => null) : Promise.resolve(null);
1631
+ }
1632
+ return previewFetch;
1633
+ };
1634
+ if (previewCode) void previewPayload();
1364
1635
  if (shopId && request.method === "GET") {
1365
1636
  try {
1366
1637
  prefetchRuleset({ platformUrl, shopId, waitUntil, fetchImpl });
@@ -1452,21 +1723,24 @@ function createPlaybookContext({
1452
1723
  return cloakPromise;
1453
1724
  };
1454
1725
  let ssrRendered = false;
1726
+ const noStore = () => ssrRendered || !!previewCode;
1455
1727
  const slotRefs = ssrSlots.map(toSlotRef);
1456
1728
  let ssrPromise = null;
1457
1729
  const ssrFor = (cloak) => {
1458
1730
  if (!ssrPromise) {
1459
1731
  ssrPromise = (async () => {
1460
1732
  if (ssrSlots.length === 0) return { ssr: null, skip: null };
1461
- const url = new URL(request.url);
1462
- const code = request.method === "GET" && !url.pathname.endsWith(".data") ? previewCodeFromRequestUrl(url) : null;
1463
- if (code && shopId) {
1464
- const shopDomain = normalizeDomain(shopDomainOption ?? str(e.PUBLIC_PLAYBOOK_SHOP_DOMAIN) ?? url.hostname);
1465
- if (!shopDomain) return { ssr: null, skip: "preview-no-shop" };
1466
- const payload2 = await getSsrPreviewPayload({ platformUrl, shopDomain, code, fetchImpl });
1733
+ if (previewCode && requestUrl) {
1734
+ const payload2 = await previewPayload();
1467
1735
  if (!payload2) return { ssr: null, skip: "preview-unavailable" };
1468
- const pageKey = targetPageKey(url.pathname);
1469
- const out2 = decidePreviewSsr(payload2, pageKey, (pages) => matchTargetedPage(pages, url.pathname) !== null);
1736
+ if (!payload2.preview) {
1737
+ if (carryCookieRaw !== void 0 && (carryCode === previewCode || !carryCode)) clearCarry();
1738
+ } else if (!isData && carryCode !== previewCode) {
1739
+ setCarry(previewCode);
1740
+ }
1741
+ const pagePath = dataRequestPagePath(requestUrl.pathname);
1742
+ const pageKey = targetPageKey(pagePath);
1743
+ const out2 = decidePreviewSsr(payload2, pageKey, (pages) => matchTargetedPage(pages, pagePath) !== null, isData);
1470
1744
  if ("skip" in out2) return { ssr: null, skip: out2.skip };
1471
1745
  let d2 = out2.decision;
1472
1746
  if (d2.experienceId) {
@@ -1474,6 +1748,9 @@ function createPlaybookContext({
1474
1748
  if (!via) return { ssr: null, skip: "preview-no-slot" };
1475
1749
  d2 = { ...d2, matchedBy: via };
1476
1750
  }
1751
+ const filled2 = await withProductFields(d2, { platformUrl, shopDomain: previewShopDomain(), waitUntil, fetchImpl });
1752
+ if ("skip" in filled2) return { ssr: null, skip: filled2.skip };
1753
+ d2 = filled2.decision;
1477
1754
  ssrRendered = true;
1478
1755
  return { ssr: d2, skip: null };
1479
1756
  }
@@ -1496,6 +1773,9 @@ function createPlaybookContext({
1496
1773
  if (!via) return { ssr: null, skip: "no-slot" };
1497
1774
  d = { ...d, matchedBy: via };
1498
1775
  }
1776
+ const filled = await withProductFields(d, { platformUrl, shopDomain: cloak.shopDomain, waitUntil, fetchImpl });
1777
+ if ("skip" in filled) return { ssr: null, skip: filled.skip };
1778
+ d = filled.decision;
1499
1779
  ssrRendered = true;
1500
1780
  return { ssr: d, skip: null };
1501
1781
  })().catch(() => ({ ssr: null, skip: "error" }));
@@ -1555,26 +1835,28 @@ function createPlaybookContext({
1555
1835
  },
1556
1836
  async appendCookies(headers) {
1557
1837
  try {
1558
- append(headers, await cookiesFor(FINALIZE_WAIT_MS));
1559
- if (ssrRendered) headers.set("Cache-Control", "private, no-store");
1838
+ append(headers, [...await cookiesFor(FINALIZE_WAIT_MS), ...extraCookies]);
1839
+ if (noStore()) headers.set("Cache-Control", "private, no-store");
1560
1840
  } catch {
1561
1841
  }
1562
1842
  },
1563
1843
  async finalize(response) {
1564
1844
  try {
1565
1845
  const isRedirect = response.status >= 300 && response.status < 400;
1566
- const cookies = await cookiesFor(
1567
- isRedirect ? FINALIZE_REDIRECT_WAIT_MS : FINALIZE_WAIT_MS
1568
- );
1569
- if (!cookies.length && !ssrRendered) return response;
1846
+ const cookies = [
1847
+ ...await cookiesFor(isRedirect ? FINALIZE_REDIRECT_WAIT_MS : FINALIZE_WAIT_MS),
1848
+ ...extraCookies
1849
+ ];
1850
+ const privateResponse = noStore();
1851
+ if (!cookies.length && !privateResponse) return response;
1570
1852
  try {
1571
1853
  append(response.headers, cookies);
1572
- if (ssrRendered) response.headers.set("Cache-Control", "private, no-store");
1854
+ if (privateResponse) response.headers.set("Cache-Control", "private, no-store");
1573
1855
  return response;
1574
1856
  } catch {
1575
1857
  const headers = new Headers(response.headers);
1576
1858
  append(headers, cookies);
1577
- if (ssrRendered) headers.set("Cache-Control", "private, no-store");
1859
+ if (privateResponse) headers.set("Cache-Control", "private, no-store");
1578
1860
  return new Response(response.body, {
1579
1861
  status: response.status,
1580
1862
  statusText: response.statusText,
@@ -1772,29 +2054,68 @@ function playbookHeadSnippetHtml(cloak, options = {}) {
1772
2054
  const attrs = Object.entries(parts.sdk.attrs).map(([k, v]) => ` ${k}="${escapeAttr(v)}"`).join("");
1773
2055
  return `<style id="${CLOAK_STYLE_ID}"${nonce}>${parts.css}</style><script${nonce}>${parts.script}</script><script id="${EXPERIENCE_SDK_SCRIPT_ID}" src="${escapeAttr(parts.sdk.src)}"${nonce} async${attrs}></script>`;
1774
2056
  }
1775
- function PlaybookSsrHead({ ssr, nonce }) {
2057
+ var useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
2058
+ function renderable(ssr) {
1776
2059
  if (!ssr) return null;
1777
- const hide = ssr.experienceId ? (ssr.arm.hide || []).map((s2) => `${s2}{display:none!important}`).join("") : "";
2060
+ if (ssr.preview?.carried && !carriedPreviewAllowed(ssr)) return null;
2061
+ return ssr;
2062
+ }
2063
+ function PlaybookSsrHead({ ssr, nonce }) {
2064
+ const d = renderable(ssr);
2065
+ const carried = !!d?.preview?.carried;
2066
+ const stateKey = carried && d ? `${d.experimentId}:${d.armId}:${d.page.t}:${d.page.h}` : null;
2067
+ useIsoLayoutEffect(() => {
2068
+ if (!carried || !d) return;
2069
+ try {
2070
+ window.__pbSsr = ssrStateObject(d);
2071
+ } catch {
2072
+ }
2073
+ }, [stateKey]);
2074
+ if (!d) return null;
2075
+ const hide = d.experienceId ? (d.arm.hide || []).map((s2) => `${s2}{display:none!important}`).join("") : "";
1778
2076
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1779
- /* @__PURE__ */ jsx("script", { nonce, "data-pb-ssr-state": "", dangerouslySetInnerHTML: { __html: ssrStateScript(ssr) } }),
2077
+ carried ? null : /* @__PURE__ */ jsx("script", { nonce, "data-pb-ssr-state": "", dangerouslySetInnerHTML: { __html: ssrStateScript(d) } }),
1780
2078
  hide ? /* @__PURE__ */ jsx("style", { id: "pb-ssr-hide", nonce, dangerouslySetInnerHTML: { __html: escStyle(hide) } }) : null
1781
2079
  ] });
1782
2080
  }
2081
+ function attachDeclarativeShadow(host) {
2082
+ if (host.shadowRoot) return true;
2083
+ const tpl = Array.from(host.children).find(
2084
+ (c) => c.tagName === "TEMPLATE" && c.hasAttribute("shadowrootmode")
2085
+ );
2086
+ if (!tpl) return false;
2087
+ try {
2088
+ const root = host.attachShadow({ mode: "open" });
2089
+ root.appendChild(host.ownerDocument.importNode(tpl.content, true));
2090
+ tpl.remove();
2091
+ root.querySelectorAll("template[shadowrootmode]").forEach((t) => {
2092
+ if (t.parentElement) attachDeclarativeShadow(t.parentElement);
2093
+ });
2094
+ return true;
2095
+ } catch {
2096
+ return false;
2097
+ }
2098
+ }
2099
+ function ssrHostRef(el) {
2100
+ if (el) attachDeclarativeShadow(el);
2101
+ }
1783
2102
  function SsrHost({ ssr }) {
1784
2103
  return /* @__PURE__ */ jsx(
1785
2104
  "div",
1786
2105
  {
2106
+ ref: ssrHostRef,
1787
2107
  id: "pb-experience-root",
1788
2108
  "data-pb-experience-mount": "",
1789
2109
  "data-pb-ssr": ssr.experimentId,
1790
2110
  style: { display: "block", boxSizing: "border-box", maxWidth: "100%" },
1791
2111
  suppressHydrationWarning: true,
1792
2112
  dangerouslySetInnerHTML: { __html: ssrHostInnerHtml(ssr.snapshot, ssr.page) }
1793
- }
2113
+ },
2114
+ `${ssr.experimentId}:${ssr.armId}:${ssr.page.t}:${ssr.page.h}`
1794
2115
  );
1795
2116
  }
1796
2117
  function PlaybookSlot(props) {
1797
- const { ssr } = props;
2118
+ const ssr = renderable(props.ssr);
1798
2119
  if (typeof props.name === "string") {
1799
2120
  const key = props.name;
1800
2121
  if (!isSlotKey(key)) return null;
@@ -3417,4 +3738,4 @@ function trackAddToCartLines(lines, cartLines, source) {
3417
3738
  }
3418
3739
  }
3419
3740
 
3420
- export { AA_SITEWIDE_TEST, CART_SYNC_IDLE_MS, CART_VISITOR_ATTRIBUTE, CLOAK_MAX_MS, CLOAK_STYLE_ID, CONSENT_LOADED_EVENTS, CONTROL_ARM, DEFAULT_DATALAYER_EVENT, DEFAULT_EVENT_URL, DEFAULT_EXPERIENCE_SDK_URL, DEFAULT_EXPOSURE_URL, DEFAULT_PLATFORM_URL, DEFAULT_PROXY_ENDPOINT, DEFAULT_SDK_URL, DEFAULT_SUPPORTED_EVENTS, EXPERIENCE_SDK_SCRIPT_ID, EXPERIENCE_VISITOR_CART_ATTRIBUTE, EXPOSURE_CART_ATTRIBUTE, EXPOSURE_COOKIE, LEGACY_VISITOR_COOKIE, MAX_WRITES_PER_CART, PlaybookAAExposure, PlaybookBoundary, PlaybookCloakHead, PlaybookDebugPanel, PlaybookExposure, PlaybookHead, PlaybookProvider, PlaybookRoot, PlaybookSections, PlaybookSlot, PlaybookSsrHead, SECTION_SLOTS, SESSION_VISITOR_COOKIE, SLOT_REPORT_SAMPLE_RATE, SLOT_REPORT_URL, SSR_SLOT_ATTR, SSR_SLOT_NAMES, STANDARD_EVENTS, TRUEVAULT_CONSENT_COOKIE, VISITOR_COOKIE, addedLinesFrom, analyticsConsentFromCookie, armSlot, assignTest, bucketIndex, buildHeadSnippet, cartHasPlaybookAttribute, chooseVariation, consentFromAnalytics, createCartAttributeReader, createCartAttributeSync, createCartAttributeWriter, createPlaybook, createPlaybookContext, createPlaybookProxyHandler, createTrueVaultConsent, debugPanelAllowed, decideSsr, declareConsentRequired, detectDevice, detectGeo, experienceVisitorIdFromCookies, getBucketRanges, getConsentState, getEqualWeights, getServerTrackedLog, getSessionContext, getSsrPayload, getTargetedPages, getTrackedLog, hasPlaybookParams, hasSentExposure, hash, inNamespace, isAnalyticsConsentGranted, isKillSwitchOn, isPreviewHost, isSlotKey, manifestUrl, matchTargetedPage, matchesPathPrefix, mergeAttributes, normalizeExposureList, onConsentChange, onConsentLoaded, playbookBackendUrl, playbookCartAttribute, playbookHeadSnippet, playbookHeadSnippetHtml, playbookTrack, prefetchRuleset, reconcileExperienceCartAttributes, reconcilePlaybookCartAttribute, renderedSlotKeys, reportPageSlots, revealScript, sanitizeManifestPages, sanitizeRuleset, sectionSlotKey, setNextAddSource, shopifyCustomerPrivacyConsent, slotFromSelector, slotMatches, slotSelector, ssrHostInnerHtml, ssrUrl, subscribeTrackedLog, syncVisitorId, takeAddSource, targetPageKey, trackAddToCart, trackAddToCartLines, trueVaultDecision, truevaultConsent, useAnalyticsAllowed, usePageEngagement, usePlaybookConsent, usePlaybookExposure, usePlaybookInteraction, usePlaybookState, usePlaybookVariant, usePreviewParamRedirect, visitorInRunningTest, visitorSeedScript, waitForConsentAPI, withPlaybook, withPlaybookCartAttribute };
3741
+ export { AA_SITEWIDE_TEST, CART_SYNC_IDLE_MS, CART_VISITOR_ATTRIBUTE, CLOAK_MAX_MS, CLOAK_STYLE_ID, CONSENT_LOADED_EVENTS, CONTROL_ARM, DEFAULT_DATALAYER_EVENT, DEFAULT_EVENT_URL, DEFAULT_EXPERIENCE_SDK_URL, DEFAULT_EXPOSURE_URL, DEFAULT_PLATFORM_URL, DEFAULT_PROXY_ENDPOINT, DEFAULT_SDK_URL, DEFAULT_SUPPORTED_EVENTS, EXPERIENCE_SDK_SCRIPT_ID, EXPERIENCE_VISITOR_CART_ATTRIBUTE, EXPOSURE_CART_ATTRIBUTE, EXPOSURE_COOKIE, LEGACY_VISITOR_COOKIE, MAX_WRITES_PER_CART, PREVIEW_ATTEMPT_BUDGET_MS, PREVIEW_CODE_COOKIE, PREVIEW_FETCH_BUDGET_MS, PRODUCT_FIELD_MISSING_ATTR, PlaybookAAExposure, PlaybookBoundary, PlaybookCloakHead, PlaybookDebugPanel, PlaybookExposure, PlaybookHead, PlaybookProvider, PlaybookRoot, PlaybookSections, PlaybookSlot, PlaybookSsrHead, SECTION_SLOTS, SESSION_VISITOR_COOKIE, SLOT_REPORT_SAMPLE_RATE, SLOT_REPORT_URL, SSR_SLOT_ATTR, SSR_SLOT_NAMES, STANDARD_EVENTS, TRUEVAULT_CONSENT_COOKIE, VISITOR_COOKIE, addedLinesFrom, analyticsConsentFromCookie, armSlot, assignTest, bucketIndex, buildHeadSnippet, cartHasPlaybookAttribute, chooseVariation, consentFromAnalytics, createCartAttributeReader, createCartAttributeSync, createCartAttributeWriter, createPlaybook, createPlaybookContext, createPlaybookProxyHandler, createTrueVaultConsent, debugPanelAllowed, decideSsr, declareConsentRequired, detectDevice, detectGeo, experienceVisitorIdFromCookies, fillProductTokens, fillSsrDecision, getBucketRanges, getConsentState, getEqualWeights, getServerTrackedLog, getSessionContext, getSsrPayload, getTargetedPages, getTrackedLog, hasPlaybookParams, hasSentExposure, hash, inNamespace, isAnalyticsConsentGranted, isKillSwitchOn, isPreviewHost, isSlotKey, manifestUrl, matchTargetedPage, matchesPathPrefix, mergeAttributes, normalizeExposureList, onConsentChange, onConsentLoaded, playbookBackendUrl, playbookCartAttribute, playbookHeadSnippet, playbookHeadSnippetHtml, playbookTrack, prefetchRuleset, productFieldsUrl, productTokensIn, reconcileExperienceCartAttributes, reconcilePlaybookCartAttribute, renderedSlotKeys, reportPageSlots, revealScript, sanitizeManifestPages, sanitizeRuleset, sectionSlotKey, setNextAddSource, shopifyCustomerPrivacyConsent, slotFromSelector, slotMatches, slotSelector, ssrHostInnerHtml, ssrUrl, subscribeTrackedLog, syncVisitorId, takeAddSource, targetPageKey, trackAddToCart, trackAddToCartLines, trueVaultDecision, truevaultConsent, useAnalyticsAllowed, usePageEngagement, usePlaybookConsent, usePlaybookExposure, usePlaybookInteraction, usePlaybookState, usePlaybookVariant, usePreviewParamRedirect, visitorInRunningTest, visitorSeedScript, waitForConsentAPI, withPlaybook, withPlaybookCartAttribute, withProductFields };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyplaybook/hydrogen",
3
- "version": "0.8.0",
3
+ "version": "0.9.1",
4
4
  "description": "Playbook store-edit tests for Shopify Hydrogen storefronts: server-side assignment, consent-gated visitor cookie, in-view exposures and cart attribution.",
5
5
  "license": "MIT",
6
6
  "author": "Pack Digital Inc.",