@sentientui/react 0.43.0 → 0.44.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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `hero:developer_v1|cta:baseline` → { hero: 'developer_v1', cta: 'baseline' }.
3
+ * Same grammar as the script tag's link, versions only: a `tone=urgent` spec
4
+ * forces style dimensions, which a React component does not have. A bare
5
+ * `?sentient_preview=hero` (no colon) is the editor's own preview-bar link
6
+ * and is left to it.
7
+ */
8
+ declare function parseVersionPreview(search: string): Record<string, string> | null;
9
+
10
+ /** Tests only. */
11
+ declare function resetVersionPreviewForTests(): void;
12
+ /**
13
+ * Start the preview for the versions the link asked for (`forced`, parsed by
14
+ * version-preview-link.ts). Idempotent. Resolves once the override is applied
15
+ * (or was not) — awaited by tests, ignored by the provider.
16
+ */
17
+ declare function maybeStartVersionPreview(apiKey: string, apiBaseUrl?: string): Promise<void>;
18
+
19
+ export { maybeStartVersionPreview, parseVersionPreview, resetVersionPreviewForTests };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `hero:developer_v1|cta:baseline` → { hero: 'developer_v1', cta: 'baseline' }.
3
+ * Same grammar as the script tag's link, versions only: a `tone=urgent` spec
4
+ * forces style dimensions, which a React component does not have. A bare
5
+ * `?sentient_preview=hero` (no colon) is the editor's own preview-bar link
6
+ * and is left to it.
7
+ */
8
+ declare function parseVersionPreview(search: string): Record<string, string> | null;
9
+
10
+ /** Tests only. */
11
+ declare function resetVersionPreviewForTests(): void;
12
+ /**
13
+ * Start the preview for the versions the link asked for (`forced`, parsed by
14
+ * version-preview-link.ts). Idempotent. Resolves once the override is applied
15
+ * (or was not) — awaited by tests, ignored by the provider.
16
+ */
17
+ declare function maybeStartVersionPreview(apiKey: string, apiBaseUrl?: string): Promise<void>;
18
+
19
+ export { maybeStartVersionPreview, parseVersionPreview, resetVersionPreviewForTests };
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ "use strict";var u=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},O=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of P(t))!R.call(e,r)&&r!==n&&u(e,r,{get:()=>t[r],enumerable:!(o=x(t,r))||o.enumerable});return e};var E=e=>O(u({},"__esModule",{value:!0}),e);var F={};C(F,{maybeStartVersionPreview:()=>Z,parseVersionPreview:()=>_,resetVersionPreviewForTests:()=>N});module.exports=E(F);function A(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function p(e,t){A()[e]=t}function y(e){window.__sentient_vocabulary_override=e}function k(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function S(e,t){k()[e]=t}function m(e){let t=null;try{let n=location.hash.slice(1),o=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(o){t=o[2];let r=n.slice(o.index+o[0].length);o[1]!="&"&&r[0]=="&"&&(r=o[1]+r.slice(1));let l=n.slice(0,o.index)+r;history.replaceState(history.state,"",l?"#"+l:location.pathname+location.search)}}catch(n){}return t}var T="sentient:overrides-changed";function b(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(T))}var L={on:!1,listeners:new Set};function M(){if(typeof window=="undefined")return L;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function f(e){let t=M();if(t.on!==e){t.on=e;for(let n of t.listeners)n()}}var z="sentient_preview",W=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,$=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function _(e){let t;try{t=new URLSearchParams(e).get(z)}catch(o){return null}if(!t)return null;let n={};for(let o of t.split("|")){let r=o.indexOf(":");if(r<=0)continue;let l=o.slice(0,r),c=o.slice(r+1);W.test(l)&&$.test(c)&&(n[l]=c)}return Object.keys(n).length>0?n:null}var j="sentient_preview_token",I=5e3,v=!1;function N(){v=!1}async function Z(e,t){var g;if(typeof window=="undefined"||v)return;let n=_(window.location.search);if(!n){f(!1);return}v=!0,f(!0);let o=m(j);if(!e)return;let r=new URLSearchParams(window.location.search),l=r.get("sentient_context"),c=r.get("sentient_persona"),h=(t!=null?t:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=null;try{let s=new AbortController,d=setTimeout(()=>s.abort(),I);try{let a=await fetch(`${h}/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({slotsFrom:"registry",includeDrafts:!0,previewToken:o||void 0,context:l||void 0,persona:c||void 0,force:n}),signal:s.signal});i=a.ok?await a.json():null}finally{clearTimeout(d)}}catch(s){i=null}if(!(i!=null&&i.slotConfig))return;let w=!1;for(let[s,d]of Object.entries(n)){let a=i.slotConfig[s];!a||((g=i.slots)==null?void 0:g[s])!==d||(p(s,a),S(s,d),w=!0)}w&&(i.vocabulary&&Array.isArray(i.vocabulary.entries)&&y(i.vocabulary),b())}0&&(module.exports={maybeStartVersionPreview,parseVersionPreview,resetVersionPreviewForTests});
3
+ //# sourceMappingURL=version-preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/version-preview.ts","../src/devtools-slot-config-overrides.ts","../src/devtools-slot-overrides.ts","../src/hash-param.ts","../src/override-events.ts","../src/preview-mode.ts","../src/version-preview-link.ts"],"sourcesContent":["// Read-only version preview: ?sentient_preview=<component>:<version>\n//\n// The same link the script tag has always honoured\n// (packages/snippet/src/preview.ts), for sites that run this SDK. It shows\n// ONE component with a chosen version — a generated one, one written in the\n// dashboard, or the original — in place, with the page's real CSS.\n//\n// Why it exists: the only way to see such a version on a React site was\n// ?sentient_preview_cell= (cell-preview.ts), which rides the on-site editor's\n// one-time code. That credential becomes a token that can PUBLISH, so it can\n// only ever be opened by a signed-in operator's own browser. Anything else\n// that needs to look at a version — the browser that takes the dashboard's\n// pictures, a link pasted to a colleague — had no way to.\n//\n// What makes this one safe to hand out:\n// - it asks /v1/explain, which only reads (no impression, no decision, no\n// slot_decisions row), with the site's public key;\n// - the version is forced through the override channel AdaptiveSlot already\n// renders exposure-free ('override' source: never tracked, never a trial),\n// and the whole page view runs in preview mode, which sends no events;\n// - unpublished versions, and versions kept for a named campaign audience,\n// are only returned with the read-only draft credential\n// (#sentient_preview_token — five minutes, cannot edit or publish), which\n// this takes out of the address bar before anything else runs.\n//\n// The override is applied ONLY when the server confirms it resolved the\n// version asked for. If it did not (a retired version, a draft without the\n// credential) the page is left exactly as a visitor gets it — a preview that\n// quietly shows something else is worse than no preview.\nimport type { SlotConfigEntry, StyleVocabulary } from '@sentientui/core';\nimport { setSlotConfigOverride, setVocabularyOverride } from './devtools-slot-config-overrides.js';\nimport { setSlotOverride } from './devtools-slot-overrides.js';\nimport { takeHashParam } from './hash-param.js';\nimport { notifyOverridesChanged } from './override-events.js';\nimport { setPreviewMode } from './preview-mode.js';\nimport { parseVersionPreview } from './version-preview-link.js';\n\nexport { parseVersionPreview };\n\n// Published as its own entry (@sentientui/react/version-preview) and loaded\n// with import() by the provider only when the link is in the address bar\n// (version-preview-link.ts decides): statically imported, it put ~450 gzip\n// bytes in front of every visitor of every React site for a link only the\n// dashboard's screenshot browser opens. As an import() INSIDE the main bundle\n// it did not help — the build split the runtime helpers and the modules\n// below into a chunk every page loaded. This entry carries its own copies of\n// those modules; that is safe because they keep all their state on window\n// (the override maps, the preview switch, the change event).\n\nconst TOKEN_PARAM = 'sentient_preview_token';\nconst EXPLAIN_TIMEOUT_MS = 5000;\ntype ExplainAnswer = {\n slots?: Record<string, unknown>;\n slotConfig?: Record<string, SlotConfigEntry>;\n vocabulary?: StyleVocabulary;\n};\n\nlet started = false;\n\n/** Tests only. */\nexport function resetVersionPreviewForTests(): void {\n started = false;\n}\n\n/**\n * Start the preview for the versions the link asked for (`forced`, parsed by\n * version-preview-link.ts). Idempotent. Resolves once the override is applied\n * (or was not) — awaited by tests, ignored by the provider.\n */\nexport async function maybeStartVersionPreview(apiKey: string, apiBaseUrl?: string): Promise<void> {\n if (typeof window === 'undefined' || started) return;\n const forced = parseVersionPreview(window.location.search);\n if (!forced) {\n // The provider switched preview mode on for anything shaped like the\n // link; this one is not a link we wrote, so it is an ordinary visit\n // (the script tag's rule for a malformed ?sentient_preview=).\n setPreviewMode(false);\n return;\n }\n started = true;\n // A preview is not a visit. Before the answer is back the page would\n // otherwise decide and record an exposure for whatever it was served;\n // preview mode (the devtools' own switch) makes the client write nothing\n // for the whole page view — the script tag's \"no decide, no events\".\n setPreviewMode(true);\n // Out of the address bar first, whatever happens next: a credential left in\n // the hash is in every \"copy link\" and every screenshot of the tab.\n const previewToken = takeHashParam(TOKEN_PARAM);\n if (!apiKey) return;\n const params = new URLSearchParams(window.location.search);\n const context = params.get('sentient_context');\n const persona = params.get('sentient_persona');\n const base = (apiBaseUrl ?? 'https://api.sentient-ui.com/v1').replace(/\\/$/, '');\n\n let data: ExplainAnswer | null = null;\n try {\n const ctrl = new AbortController();\n const timer = setTimeout(() => ctrl.abort(), EXPLAIN_TIMEOUT_MS);\n try {\n const res = await fetch(`${base}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n // JSON leaves out the fields that are undefined.\n body: JSON.stringify({\n slotsFrom: 'registry',\n // Drafts too: a version is looked at precisely to decide whether to\n // publish it. The server ignores this without the credential.\n includeDrafts: true,\n previewToken: previewToken || undefined,\n context: context || undefined,\n persona: persona || undefined,\n force: forced,\n }),\n signal: ctrl.signal,\n });\n data = res.ok ? ((await res.json()) as ExplainAnswer) : null;\n } finally {\n clearTimeout(timer);\n }\n } catch {\n data = null;\n }\n if (!data?.slotConfig) return;\n\n let applied = false;\n for (const [slotId, arm] of Object.entries(forced)) {\n const entry = data.slotConfig[slotId];\n // The server answers with what it RESOLVED. Anything but the version we\n // asked for means it could not show it; forcing our id onto another\n // version's content would label the wrong thing.\n if (!entry || data.slots?.[slotId] !== arm) continue;\n setSlotConfigOverride(slotId, entry);\n setSlotOverride(slotId, arm);\n applied = true;\n }\n if (!applied) return;\n // A redesigned version borrows the site's own styles; the decision that\n // would normally carry them never ran.\n if (data.vocabulary && Array.isArray(data.vocabulary.entries)) setVocabularyOverride(data.vocabulary);\n notifyOverridesChanged();\n}\n","import type { SlotConfigEntry, StyleVocabulary } from '@sentientui/core';\n\n/**\n * Slot-CONFIG override store — the channel `useSlotConfig` reads (AdaptiveSlot).\n * Separate from `__sentient_slot_overrides` (which forces the slot RESULT — the\n * arm): forcing an arm alone can't test AdaptiveSlot's rendering, because the\n * content/blocks live in the config entry. Window-backed so the /devtools and\n * /testing bundles and the main bundle share one store.\n */\nfunction store(): Record<string, SlotConfigEntry> {\n const w = window as unknown as { __sentient_slot_config_overrides?: Record<string, SlotConfigEntry> };\n if (!w.__sentient_slot_config_overrides) w.__sentient_slot_config_overrides = {};\n return w.__sentient_slot_config_overrides;\n}\n\n/** Force `slotId`'s config entry — read by `useSlotConfig`. */\nexport function setSlotConfigOverride(slotId: string, entry: SlotConfigEntry): void {\n store()[slotId] = entry;\n}\n\n/** Site styles for forced configs (the on-site preview of a redesigned\n * section): the decision that would normally carry them never ran. */\nexport function setVocabularyOverride(v: StyleVocabulary | null): void {\n (window as unknown as { __sentient_vocabulary_override?: StyleVocabulary | null }).__sentient_vocabulary_override = v;\n}\n\nexport function getVocabularyOverride(): StyleVocabulary | null {\n if (typeof window === 'undefined') return null;\n return (window as unknown as { __sentient_vocabulary_override?: StyleVocabulary | null }).__sentient_vocabulary_override ?? null;\n}\n\nexport function clearSlotConfigOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotConfigOverrides(): Record<string, SlotConfigEntry> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","// Credentials the dashboard hands the site (`sentient_preview_token`, the\n// editor's one-time `sentient_editor_code`) ride the URL FRAGMENT, which is\n// never sent over the network — no server/CDN log, no Referer (grades C13, E1).\n//\n// The fragment is also where hash-routed sites keep their route (grade E2).\n// The first version wrote `#sentient_preview_token=…` over the whole hash, so a\n// preview of `/#/pricing` opened the home route instead. The dashboard now\n// APPENDS the param (appendHashParam in apps/dashboard/app/lib/hash-param.ts):\n// '' → #name=v\n// '/pricing' → #/pricing?name=v (routers read it as a query param, so\n// '/p?x=1' → #/p?x=1&name=v the route still matches pre-strip)\n// and this takes it back out, restoring the site's own hash EXACTLY — or\n// removing the '#' altogether when the site had none. Twin of\n// packages/snippet/src/hash-param.ts (the snippet cannot import this package\n// and vice versa); keep the two in step — both suites run the same cases.\nexport function takeHashParam(name: string): string | null {\n let v: string | null = null;\n try {\n const h = location.hash.slice(1);\n const m = RegExp('(^|[?&])' + name + '=([^&]*)').exec(h);\n if (m) {\n // Taken BEFORE the rewrite: an opaque-origin frame may refuse\n // replaceState, and the value is still ours to use. Base64url, so no\n // decoding (the dashboard never percent-encodes it).\n v = m[2]!;\n let after = h.slice(m.index + m[0].length);\n // '?name=v&rest' / 'name=v&rest': the next param inherits the separator.\n if (m[1] != '&' && after[0] == '&') after = m[1] + after.slice(1);\n const rest = h.slice(0, m.index) + after;\n // replaceState, not location.hash=: no hashchange, so a hash router does\n // not re-route mid-boot; history.state kept so its entry key survives.\n history.replaceState(history.state, '', rest ? '#' + rest : location.pathname + location.search);\n }\n } catch {\n /* fail-safe */\n }\n return v;\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n isUnified: (componentId) => inner.isUnified?.(componentId) ?? false,\n assign: (componentId, variantIds, agentData, agentDataByVariant, opts) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant, opts),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getSlotConfig: (slotId) => inner.getSlotConfig(slotId),\n getSitePalette: () => inner.getSitePalette(),\n reportSlots: (ids) => inner.reportSlots(ids),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n flush: () => inner.flush(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","// The read-only preview link's grammar (?sentient_preview=<component>:<version>).\n// Part of the @sentientui/react/version-preview entry only — the provider\n// makes a cheaper check of the link's shape before loading it.\n\nconst PARAM = 'sentient_preview';\n\n/** The registry's own id rules; anything else is not a link we wrote. */\nconst SLOT_RE = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/;\nconst ARM_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;\n\n/**\n * `hero:developer_v1|cta:baseline` → { hero: 'developer_v1', cta: 'baseline' }.\n * Same grammar as the script tag's link, versions only: a `tone=urgent` spec\n * forces style dimensions, which a React component does not have. A bare\n * `?sentient_preview=hero` (no colon) is the editor's own preview-bar link\n * and is left to it.\n */\nexport function parseVersionPreview(search: string): Record<string, string> | null {\n let raw: string | null;\n try {\n raw = new URLSearchParams(search).get(PARAM);\n } catch {\n return null;\n }\n if (!raw) return null;\n const out: Record<string, string> = {};\n for (const part of raw.split('|')) {\n const colon = part.indexOf(':');\n if (colon <= 0) continue;\n const slotId = part.slice(0, colon);\n const arm = part.slice(colon + 1);\n if (SLOT_RE.test(slotId) && ARM_RE.test(arm)) out[slotId] = arm;\n }\n return Object.keys(out).length > 0 ? out : null;\n}\n"],"mappings":";yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,8BAAAE,EAAA,wBAAAC,EAAA,gCAAAC,IAAA,eAAAC,EAAAL,GCSA,SAASM,GAAyC,CAChD,IAAMC,EAAI,OACV,OAAKA,EAAE,mCAAkCA,EAAE,iCAAmC,CAAC,GACxEA,EAAE,gCACX,CAGO,SAASC,EAAsBC,EAAgBC,EAA8B,CAClFJ,EAAM,EAAEG,CAAM,EAAIC,CACpB,CAIO,SAASC,EAAsBC,EAAiC,CACpE,OAAkF,+BAAiCA,CACtH,CCfA,SAASC,GAAoC,CAC3C,IAAMC,EAAI,OACV,OAAKA,EAAE,4BAA2BA,EAAE,0BAA4B,CAAC,GAC1DA,EAAE,yBACX,CAGO,SAASC,EAAgBC,EAAgBC,EAA0B,CACxEJ,EAAM,EAAEG,CAAM,EAAIC,CACpB,CCHO,SAASC,EAAcC,EAA6B,CACzD,IAAIC,EAAmB,KACvB,GAAI,CACF,IAAMC,EAAI,SAAS,KAAK,MAAM,CAAC,EACzBC,EAAI,OAAO,WAAaH,EAAO,UAAU,EAAE,KAAKE,CAAC,EACvD,GAAIC,EAAG,CAILF,EAAIE,EAAE,CAAC,EACP,IAAIC,EAAQF,EAAE,MAAMC,EAAE,MAAQA,EAAE,CAAC,EAAE,MAAM,EAErCA,EAAE,CAAC,GAAK,KAAOC,EAAM,CAAC,GAAK,MAAKA,EAAQD,EAAE,CAAC,EAAIC,EAAM,MAAM,CAAC,GAChE,IAAMC,EAAOH,EAAE,MAAM,EAAGC,EAAE,KAAK,EAAIC,EAGnC,QAAQ,aAAa,QAAQ,MAAO,GAAIC,EAAO,IAAMA,EAAO,SAAS,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AG,CAClD,IAAMiB,EAAQR,EAAK,WAAWM,CAAM,EAIhC,CAACE,KAASlB,EAAAU,EAAK,QAAL,YAAAV,EAAagB,MAAYC,IACvCE,EAAsBH,EAAQE,CAAK,EACnCE,EAAgBJ,EAAQC,CAAG,EAC3BF,EAAU,GACZ,CACKA,IAGDL,EAAK,YAAc,MAAM,QAAQA,EAAK,WAAW,OAAO,GAAGW,EAAsBX,EAAK,UAAU,EACpGY,EAAuB,EACzB","names":["version_preview_exports","__export","maybeStartVersionPreview","parseVersionPreview","resetVersionPreviewForTests","__toCommonJS","store","w","setSlotConfigOverride","slotId","entry","setVocabularyOverride","v","store","w","setSlotOverride","slotId","result","takeHashParam","name","v","h","m","after","rest","e","EVENT","notifyOverridesChanged","_a","w","EVENT","ssrFallback","state","w","setPreviewMode","on","s","fn","PARAM","SLOT_RE","ARM_RE","parseVersionPreview","search","raw","e","out","part","colon","slotId","arm","TOKEN_PARAM","EXPLAIN_TIMEOUT_MS","started","resetVersionPreviewForTests","maybeStartVersionPreview","apiKey","apiBaseUrl","_a","forced","parseVersionPreview","setPreviewMode","previewToken","takeHashParam","params","context","persona","base","data","ctrl","timer","res","e","applied","slotId","arm","entry","setSlotConfigOverride","setSlotOverride","setVocabularyOverride","notifyOverridesChanged"]}
@@ -0,0 +1,3 @@
1
+ 'use client';
2
+ function x(){let e=window;return e.__sentient_slot_config_overrides||(e.__sentient_slot_config_overrides={}),e.__sentient_slot_config_overrides}function w(e,t){x()[e]=t}function g(e){window.__sentient_vocabulary_override=e}function P(){let e=window;return e.__sentient_slot_overrides||(e.__sentient_slot_overrides={}),e.__sentient_slot_overrides}function p(e,t){P()[e]=t}function y(e){let t=null;try{let n=location.hash.slice(1),o=RegExp("(^|[?&])"+e+"=([^&]*)").exec(n);if(o){t=o[2];let r=n.slice(o.index+o[0].length);o[1]!="&"&&r[0]=="&"&&(r=o[1]+r.slice(1));let l=n.slice(0,o.index)+r;history.replaceState(history.state,"",l?"#"+l:location.pathname+location.search)}}catch(n){}return t}var R="sentient:overrides-changed";function S(){var t;if(typeof window=="undefined")return;let e=window;e.__sentient_overrides_version=((t=e.__sentient_overrides_version)!=null?t:0)+1,window.dispatchEvent(new Event(R))}var C={on:!1,listeners:new Set};function O(){if(typeof window=="undefined")return C;let e=window;return e.__sentient_preview||(e.__sentient_preview={on:!1,listeners:new Set}),e.__sentient_preview}function u(e){let t=O();if(t.on!==e){t.on=e;for(let n of t.listeners)n()}}var E="sentient_preview",V=/^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/,A=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function m(e){let t;try{t=new URLSearchParams(e).get(E)}catch(o){return null}if(!t)return null;let n={};for(let o of t.split("|")){let r=o.indexOf(":");if(r<=0)continue;let l=o.slice(0,r),c=o.slice(r+1);V.test(l)&&A.test(c)&&(n[l]=c)}return Object.keys(n).length>0?n:null}var k="sentient_preview_token",T=5e3,f=!1;function X(){f=!1}async function q(e,t){var v;if(typeof window=="undefined"||f)return;let n=m(window.location.search);if(!n){u(!1);return}f=!0,u(!0);let o=y(k);if(!e)return;let r=new URLSearchParams(window.location.search),l=r.get("sentient_context"),c=r.get("sentient_persona"),b=(t!=null?t:"https://api.sentient-ui.com/v1").replace(/\/$/,""),i=null;try{let s=new AbortController,d=setTimeout(()=>s.abort(),T);try{let a=await fetch(`${b}/explain`,{method:"POST",headers:{"content-type":"application/json",authorization:`Bearer ${e}`},body:JSON.stringify({slotsFrom:"registry",includeDrafts:!0,previewToken:o||void 0,context:l||void 0,persona:c||void 0,force:n}),signal:s.signal});i=a.ok?await a.json():null}finally{clearTimeout(d)}}catch(s){i=null}if(!(i!=null&&i.slotConfig))return;let _=!1;for(let[s,d]of Object.entries(n)){let a=i.slotConfig[s];!a||((v=i.slots)==null?void 0:v[s])!==d||(w(s,a),p(s,d),_=!0)}_&&(i.vocabulary&&Array.isArray(i.vocabulary.entries)&&g(i.vocabulary),S())}export{q as maybeStartVersionPreview,m as parseVersionPreview,X as resetVersionPreviewForTests};
3
+ //# sourceMappingURL=version-preview.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/devtools-slot-config-overrides.ts","../src/devtools-slot-overrides.ts","../src/hash-param.ts","../src/override-events.ts","../src/preview-mode.ts","../src/version-preview-link.ts","../src/version-preview.ts"],"sourcesContent":["import type { SlotConfigEntry, StyleVocabulary } from '@sentientui/core';\n\n/**\n * Slot-CONFIG override store — the channel `useSlotConfig` reads (AdaptiveSlot).\n * Separate from `__sentient_slot_overrides` (which forces the slot RESULT — the\n * arm): forcing an arm alone can't test AdaptiveSlot's rendering, because the\n * content/blocks live in the config entry. Window-backed so the /devtools and\n * /testing bundles and the main bundle share one store.\n */\nfunction store(): Record<string, SlotConfigEntry> {\n const w = window as unknown as { __sentient_slot_config_overrides?: Record<string, SlotConfigEntry> };\n if (!w.__sentient_slot_config_overrides) w.__sentient_slot_config_overrides = {};\n return w.__sentient_slot_config_overrides;\n}\n\n/** Force `slotId`'s config entry — read by `useSlotConfig`. */\nexport function setSlotConfigOverride(slotId: string, entry: SlotConfigEntry): void {\n store()[slotId] = entry;\n}\n\n/** Site styles for forced configs (the on-site preview of a redesigned\n * section): the decision that would normally carry them never ran. */\nexport function setVocabularyOverride(v: StyleVocabulary | null): void {\n (window as unknown as { __sentient_vocabulary_override?: StyleVocabulary | null }).__sentient_vocabulary_override = v;\n}\n\nexport function getVocabularyOverride(): StyleVocabulary | null {\n if (typeof window === 'undefined') return null;\n return (window as unknown as { __sentient_vocabulary_override?: StyleVocabulary | null }).__sentient_vocabulary_override ?? null;\n}\n\nexport function clearSlotConfigOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotConfigOverrides(): Record<string, SlotConfigEntry> {\n return { ...store() };\n}\n","import type { SlotResult } from '@sentientui/core';\n\n/**\n * Slot-override store — the channel `useSlotResult` reads (`useAdaptiveTokens` /\n * `AdaptiveGroup`). Separate from `__sentient_overrides` (variant components):\n * a slot result is a token object (`{ tone: 'urgent' }`) or an arm string\n * (`'social_first'`), never a bare variant id. Window-backed so the /devtools\n * bundle and the main bundle share one store.\n */\nfunction store(): Record<string, SlotResult> {\n const w = window as unknown as { __sentient_slot_overrides?: Record<string, SlotResult> };\n if (!w.__sentient_slot_overrides) w.__sentient_slot_overrides = {};\n return w.__sentient_slot_overrides;\n}\n\n/** Force `slotId` to resolve to `result` — read by `useSlotResult`. */\nexport function setSlotOverride(slotId: string, result: SlotResult): void {\n store()[slotId] = result;\n}\n\nexport function clearSlotOverride(slotId: string): void {\n delete store()[slotId];\n}\n\nexport function getSlotOverrides(): Record<string, SlotResult> {\n return { ...store() };\n}\n","// Credentials the dashboard hands the site (`sentient_preview_token`, the\n// editor's one-time `sentient_editor_code`) ride the URL FRAGMENT, which is\n// never sent over the network — no server/CDN log, no Referer (grades C13, E1).\n//\n// The fragment is also where hash-routed sites keep their route (grade E2).\n// The first version wrote `#sentient_preview_token=…` over the whole hash, so a\n// preview of `/#/pricing` opened the home route instead. The dashboard now\n// APPENDS the param (appendHashParam in apps/dashboard/app/lib/hash-param.ts):\n// '' → #name=v\n// '/pricing' → #/pricing?name=v (routers read it as a query param, so\n// '/p?x=1' → #/p?x=1&name=v the route still matches pre-strip)\n// and this takes it back out, restoring the site's own hash EXACTLY — or\n// removing the '#' altogether when the site had none. Twin of\n// packages/snippet/src/hash-param.ts (the snippet cannot import this package\n// and vice versa); keep the two in step — both suites run the same cases.\nexport function takeHashParam(name: string): string | null {\n let v: string | null = null;\n try {\n const h = location.hash.slice(1);\n const m = RegExp('(^|[?&])' + name + '=([^&]*)').exec(h);\n if (m) {\n // Taken BEFORE the rewrite: an opaque-origin frame may refuse\n // replaceState, and the value is still ours to use. Base64url, so no\n // decoding (the dashboard never percent-encodes it).\n v = m[2]!;\n let after = h.slice(m.index + m[0].length);\n // '?name=v&rest' / 'name=v&rest': the next param inherits the separator.\n if (m[1] != '&' && after[0] == '&') after = m[1] + after.slice(1);\n const rest = h.slice(0, m.index) + after;\n // replaceState, not location.hash=: no hashchange, so a hash router does\n // not re-route mid-boot; history.state kept so its entry key survives.\n history.replaceState(history.state, '', rest ? '#' + rest : location.pathname + location.search);\n }\n } catch {\n /* fail-safe */\n }\n return v;\n}\n","/**\n * Cross-bundle re-render bus for devtools overrides. The main entry and the\n * /devtools entry are separate bundles, so state and notifications go through\n * window (a version counter + a DOM event) — never module-local state.\n */\nconst EVENT = 'sentient:overrides-changed';\n\ntype VersionWindow = Window & { __sentient_overrides_version?: number };\n\nexport function getOverridesVersion(): number {\n if (typeof window === 'undefined') return 0;\n return (window as VersionWindow).__sentient_overrides_version ?? 0;\n}\n\nexport function notifyOverridesChanged(): void {\n if (typeof window === 'undefined') return;\n const w = window as VersionWindow;\n w.__sentient_overrides_version = (w.__sentient_overrides_version ?? 0) + 1;\n window.dispatchEvent(new Event(EVENT));\n}\n\nexport function subscribeOverridesChanged(fn: () => void): () => void {\n if (typeof window === 'undefined') return () => undefined;\n window.addEventListener(EVENT, fn);\n return () => window.removeEventListener(EVENT, fn);\n}\n","import type { SentientClient } from '@sentientui/core';\n\ntype PreviewState = { on: boolean; listeners: Set<() => void> };\nconst ssrFallback: PreviewState = { on: false, listeners: new Set() };\n\n// Window-backed: the /devtools entry (a separate bundle) toggles preview mode\n// and the provider (main bundle) must observe it.\nfunction state(): PreviewState {\n if (typeof window === 'undefined') return ssrFallback;\n const w = window as unknown as { __sentient_preview?: PreviewState };\n if (!w.__sentient_preview) w.__sentient_preview = { on: false, listeners: new Set() };\n return w.__sentient_preview;\n}\n\nexport function setPreviewMode(on: boolean): void {\n const s = state();\n if (s.on === on) return;\n s.on = on;\n for (const fn of s.listeners) fn();\n}\n\nexport function getPreviewMode(): boolean {\n return state().on;\n}\n\nexport function subscribePreview(fn: () => void): () => void {\n const listeners = state().listeners;\n listeners.add(fn);\n return () => {\n listeners.delete(fn);\n };\n}\n\n/**\n * Wraps a client so it writes nothing: reads pass through, all emitters no-op.\n * Used while previewing variants/personas so no `variant_assigned`, goal, or\n * session events are sent.\n */\nexport function createPreviewClient(inner: SentientClient): SentientClient {\n return {\n isLocal: inner.isLocal,\n track: () => undefined,\n goal: () => undefined,\n componentGoal: () => undefined,\n identify: () => undefined,\n fetchWeights: () => Promise.resolve([]),\n getAssignment: (componentId, segment) => inner.getAssignment(componentId, segment),\n isUnified: (componentId) => inner.isUnified?.(componentId) ?? false,\n assign: (componentId, variantIds, agentData, agentDataByVariant, opts) =>\n inner.assign(componentId, variantIds, agentData, agentDataByVariant, opts),\n // Reads pass through; decide is a write (slot decisions persist server-side)\n // so preview mode never issues it.\n decide: () => Promise.resolve(null),\n getSlotResult: (slotId) => inner.getSlotResult(slotId),\n getSlotConfig: (slotId) => inner.getSlotConfig(slotId),\n getSitePalette: () => inner.getSitePalette(),\n reportSlots: (ids) => inner.reportSlots(ids),\n getPersona: () => inner.getPersona(),\n getGraph: () => inner.getGraph(),\n flush: () => inner.flush(),\n dispose: () => inner.dispose(),\n destroy: () => inner.destroy(),\n };\n}\n","// The read-only preview link's grammar (?sentient_preview=<component>:<version>).\n// Part of the @sentientui/react/version-preview entry only — the provider\n// makes a cheaper check of the link's shape before loading it.\n\nconst PARAM = 'sentient_preview';\n\n/** The registry's own id rules; anything else is not a link we wrote. */\nconst SLOT_RE = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,127}$/;\nconst ARM_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;\n\n/**\n * `hero:developer_v1|cta:baseline` → { hero: 'developer_v1', cta: 'baseline' }.\n * Same grammar as the script tag's link, versions only: a `tone=urgent` spec\n * forces style dimensions, which a React component does not have. A bare\n * `?sentient_preview=hero` (no colon) is the editor's own preview-bar link\n * and is left to it.\n */\nexport function parseVersionPreview(search: string): Record<string, string> | null {\n let raw: string | null;\n try {\n raw = new URLSearchParams(search).get(PARAM);\n } catch {\n return null;\n }\n if (!raw) return null;\n const out: Record<string, string> = {};\n for (const part of raw.split('|')) {\n const colon = part.indexOf(':');\n if (colon <= 0) continue;\n const slotId = part.slice(0, colon);\n const arm = part.slice(colon + 1);\n if (SLOT_RE.test(slotId) && ARM_RE.test(arm)) out[slotId] = arm;\n }\n return Object.keys(out).length > 0 ? out : null;\n}\n","// Read-only version preview: ?sentient_preview=<component>:<version>\n//\n// The same link the script tag has always honoured\n// (packages/snippet/src/preview.ts), for sites that run this SDK. It shows\n// ONE component with a chosen version — a generated one, one written in the\n// dashboard, or the original — in place, with the page's real CSS.\n//\n// Why it exists: the only way to see such a version on a React site was\n// ?sentient_preview_cell= (cell-preview.ts), which rides the on-site editor's\n// one-time code. That credential becomes a token that can PUBLISH, so it can\n// only ever be opened by a signed-in operator's own browser. Anything else\n// that needs to look at a version — the browser that takes the dashboard's\n// pictures, a link pasted to a colleague — had no way to.\n//\n// What makes this one safe to hand out:\n// - it asks /v1/explain, which only reads (no impression, no decision, no\n// slot_decisions row), with the site's public key;\n// - the version is forced through the override channel AdaptiveSlot already\n// renders exposure-free ('override' source: never tracked, never a trial),\n// and the whole page view runs in preview mode, which sends no events;\n// - unpublished versions, and versions kept for a named campaign audience,\n// are only returned with the read-only draft credential\n// (#sentient_preview_token — five minutes, cannot edit or publish), which\n// this takes out of the address bar before anything else runs.\n//\n// The override is applied ONLY when the server confirms it resolved the\n// version asked for. If it did not (a retired version, a draft without the\n// credential) the page is left exactly as a visitor gets it — a preview that\n// quietly shows something else is worse than no preview.\nimport type { SlotConfigEntry, StyleVocabulary } from '@sentientui/core';\nimport { setSlotConfigOverride, setVocabularyOverride } from './devtools-slot-config-overrides.js';\nimport { setSlotOverride } from './devtools-slot-overrides.js';\nimport { takeHashParam } from './hash-param.js';\nimport { notifyOverridesChanged } from './override-events.js';\nimport { setPreviewMode } from './preview-mode.js';\nimport { parseVersionPreview } from './version-preview-link.js';\n\nexport { parseVersionPreview };\n\n// Published as its own entry (@sentientui/react/version-preview) and loaded\n// with import() by the provider only when the link is in the address bar\n// (version-preview-link.ts decides): statically imported, it put ~450 gzip\n// bytes in front of every visitor of every React site for a link only the\n// dashboard's screenshot browser opens. As an import() INSIDE the main bundle\n// it did not help — the build split the runtime helpers and the modules\n// below into a chunk every page loaded. This entry carries its own copies of\n// those modules; that is safe because they keep all their state on window\n// (the override maps, the preview switch, the change event).\n\nconst TOKEN_PARAM = 'sentient_preview_token';\nconst EXPLAIN_TIMEOUT_MS = 5000;\ntype ExplainAnswer = {\n slots?: Record<string, unknown>;\n slotConfig?: Record<string, SlotConfigEntry>;\n vocabulary?: StyleVocabulary;\n};\n\nlet started = false;\n\n/** Tests only. */\nexport function resetVersionPreviewForTests(): void {\n started = false;\n}\n\n/**\n * Start the preview for the versions the link asked for (`forced`, parsed by\n * version-preview-link.ts). Idempotent. Resolves once the override is applied\n * (or was not) — awaited by tests, ignored by the provider.\n */\nexport async function maybeStartVersionPreview(apiKey: string, apiBaseUrl?: string): Promise<void> {\n if (typeof window === 'undefined' || started) return;\n const forced = parseVersionPreview(window.location.search);\n if (!forced) {\n // The provider switched preview mode on for anything shaped like the\n // link; this one is not a link we wrote, so it is an ordinary visit\n // (the script tag's rule for a malformed ?sentient_preview=).\n setPreviewMode(false);\n return;\n }\n started = true;\n // A preview is not a visit. Before the answer is back the page would\n // otherwise decide and record an exposure for whatever it was served;\n // preview mode (the devtools' own switch) makes the client write nothing\n // for the whole page view — the script tag's \"no decide, no events\".\n setPreviewMode(true);\n // Out of the address bar first, whatever happens next: a credential left in\n // the hash is in every \"copy link\" and every screenshot of the tab.\n const previewToken = takeHashParam(TOKEN_PARAM);\n if (!apiKey) return;\n const params = new URLSearchParams(window.location.search);\n const context = params.get('sentient_context');\n const persona = params.get('sentient_persona');\n const base = (apiBaseUrl ?? 'https://api.sentient-ui.com/v1').replace(/\\/$/, '');\n\n let data: ExplainAnswer | null = null;\n try {\n const ctrl = new AbortController();\n const timer = setTimeout(() => ctrl.abort(), EXPLAIN_TIMEOUT_MS);\n try {\n const res = await fetch(`${base}/explain`, {\n method: 'POST',\n headers: { 'content-type': 'application/json', authorization: `Bearer ${apiKey}` },\n // JSON leaves out the fields that are undefined.\n body: JSON.stringify({\n slotsFrom: 'registry',\n // Drafts too: a version is looked at precisely to decide whether to\n // publish it. The server ignores this without the credential.\n includeDrafts: true,\n previewToken: previewToken || undefined,\n context: context || undefined,\n persona: persona || undefined,\n force: forced,\n }),\n signal: ctrl.signal,\n });\n data = res.ok ? ((await res.json()) as ExplainAnswer) : null;\n } finally {\n clearTimeout(timer);\n }\n } catch {\n data = null;\n }\n if (!data?.slotConfig) return;\n\n let applied = false;\n for (const [slotId, arm] of Object.entries(forced)) {\n const entry = data.slotConfig[slotId];\n // The server answers with what it RESOLVED. Anything but the version we\n // asked for means it could not show it; forcing our id onto another\n // version's content would label the wrong thing.\n if (!entry || data.slots?.[slotId] !== arm) continue;\n setSlotConfigOverride(slotId, entry);\n setSlotOverride(slotId, arm);\n applied = true;\n }\n if (!applied) return;\n // A redesigned version borrows the site's own styles; the decision that\n // would normally carry them never ran.\n if (data.vocabulary && Array.isArray(data.vocabulary.entries)) setVocabularyOverride(data.vocabulary);\n notifyOverridesChanged();\n}\n"],"mappings":";AASA,SAASA,GAAyC,CAChD,IAAMC,EAAI,OACV,OAAKA,EAAE,mCAAkCA,EAAE,iCAAmC,CAAC,GACxEA,EAAE,gCACX,CAGO,SAASC,EAAsBC,EAAgBC,EAA8B,CAClFJ,EAAM,EAAEG,CAAM,EAAIC,CACpB,CAIO,SAASC,EAAsBC,EAAiC,CACpE,OAAkF,+BAAiCA,CACtH,CCfA,SAASC,GAAoC,CAC3C,IAAMC,EAAI,OACV,OAAKA,EAAE,4BAA2BA,EAAE,0BAA4B,CAAC,GAC1DA,EAAE,yBACX,CAGO,SAASC,EAAgBC,EAAgBC,EAA0B,CACxEJ,EAAM,EAAEG,CAAM,EAAIC,CACpB,CCHO,SAASC,EAAcC,EAA6B,CACzD,IAAIC,EAAmB,KACvB,GAAI,CACF,IAAMC,EAAI,SAAS,KAAK,MAAM,CAAC,EACzBC,EAAI,OAAO,WAAaH,EAAO,UA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X,cAAe,GACf,aAAcM,GAAgB,OAC9B,QAASG,GAAW,OACpB,QAASC,GAAW,OACpB,MAAOP,CACT,CAAC,EACD,OAAQU,EAAK,MACf,CAAC,EACDD,EAAOG,EAAI,GAAO,MAAMA,EAAI,KAAK,EAAuB,IAC1D,QAAE,CACA,aAAaD,CAAK,CACpB,CACF,OAAQE,EAAA,CACNJ,EAAO,IACT,CACA,GAAI,EAACA,GAAA,MAAAA,EAAM,YAAY,OAEvB,IAAIK,EAAU,GACd,OAAW,CAACC,EAAQC,CAAG,IAAK,OAAO,QAAQhB,CAAM,EAAG,CAClD,IAAMiB,EAAQR,EAAK,WAAWM,CAAM,EAIhC,CAACE,KAASlB,EAAAU,EAAK,QAAL,YAAAV,EAAagB,MAAYC,IACvCE,EAAsBH,EAAQE,CAAK,EACnCE,EAAgBJ,EAAQC,CAAG,EAC3BF,EAAU,GACZ,CACKA,IAGDL,EAAK,YAAc,MAAM,QAAQA,EAAK,WAAW,OAAO,GAAGW,EAAsBX,EAAK,UAAU,EACpGY,EAAuB,EACzB","names":["store","w","setSlotConfigOverride","slotId","entry","setVocabularyOverride","v","store","w","setSlotOverride","slotId","result","takeHashParam","name","v","h","m","after","rest","e","EVENT","notifyOverridesChanged","_a","w","EVENT","ssrFallback","state","w","setPreviewMode","on","s","fn","PARAM","SLOT_RE","ARM_RE","parseVersionPreview","search","raw","e","out","part","colon","slotId","arm","TOKEN_PARAM","EXPLAIN_TIMEOUT_MS","started","resetVersionPreviewForTests","maybeStartVersionPreview","apiKey","apiBaseUrl","_a","forced","parseVersionPreview","setPreviewMode","previewToken","takeHashParam","params","context","persona","base","data","ctrl","timer","res","e","applied","slotId","arm","entry","setSlotConfigOverride","setSlotOverride","setVocabularyOverride","notifyOverridesChanged"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/react",
3
- "version": "0.43.0",
3
+ "version": "0.44.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -52,6 +52,11 @@
52
52
  "import": "./dist/devtools.mjs",
53
53
  "require": "./dist/devtools.js"
54
54
  },
55
+ "./version-preview": {
56
+ "types": "./dist/version-preview.d.ts",
57
+ "import": "./dist/version-preview.mjs",
58
+ "require": "./dist/version-preview.js"
59
+ },
55
60
  "./testing": {
56
61
  "types": "./dist/testing.d.ts",
57
62
  "import": "./dist/testing.mjs",
@@ -78,8 +83,8 @@
78
83
  "llms.txt"
79
84
  ],
80
85
  "dependencies": {
81
- "@sentientui/core": "0.42.0",
82
- "@sentientui/policy": "0.17.1"
86
+ "@sentientui/core": "0.43.0",
87
+ "@sentientui/policy": "0.18.0"
83
88
  },
84
89
  "peerDependencies": {
85
90
  "@testing-library/react": ">=14.0.0 <17.0.0",
package/dist/server.d.cts DELETED
@@ -1,123 +0,0 @@
1
- import * as _sentientui_core from '@sentientui/core';
2
- import * as _sentientui_core_server from '@sentientui/core/server';
3
- import { ServerAssignments } from '@sentientui/core/server';
4
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie, signUserId, trackServerGoal } from '@sentientui/core/server';
5
-
6
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
7
- type LoadAdaptiveAssignmentsResult = {
8
- assignments: ServerAssignments;
9
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
10
- sessionId: string;
11
- /** Components the operator moved onto the shared track: not in
12
- * `assignments`. Pass as `initialUnified` to `<AdaptiveProvider>`. */
13
- unified: string[];
14
- };
15
- type LoadAdaptiveAssignmentsOptions = {
16
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
17
- cookies: {
18
- get(name: string): {
19
- value: string;
20
- } | undefined;
21
- };
22
- apiKey: string;
23
- baseUrl: string;
24
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
25
- createSessionId?: () => string;
26
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
27
- origin?: string;
28
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
29
- userAgent?: string;
30
- /** From Next.js `headers().get('referer')`. */
31
- referer?: string;
32
- /**
33
- * `utm_*` params from the landing URL. The Referer header never carries the
34
- * page's OWN query string, so without this the SSR-minted session has no
35
- * campaign attribution until the client SDK hydrates and re-upserts.
36
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
37
- */
38
- utmParams?: Record<string, string>;
39
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
40
- clickIds?: Record<string, string>;
41
- /** The landing page's path (no query string) — recognises a paid click to a product page or a `/discount/` link on the first decision. */
42
- landingPath?: string;
43
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
44
- doNotTrack?: boolean;
45
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
46
- timeoutMs?: number;
47
- /**
48
- * Declared persona — the role your app already knows for this visitor (e.g.
49
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
50
- * project's persona vocabulary; unrecognized values are ignored server-side.
51
- * Never a user id or email.
52
- */
53
- persona?: string;
54
- /**
55
- * Your team / a test site — the same flag as `<AdaptiveProvider internal>`,
56
- * sent on the SSR upsert and decide so a server-rendered first page is
57
- * never counted or learned from. The request's `sentient_internal` cookie
58
- * (the "mark this browser" link) is read from `cookies` and forwarded too.
59
- */
60
- internal?: boolean;
61
- };
62
- /**
63
- * Fetches bandit assignments on the server for SEO-safe HTML.
64
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
65
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
66
- */
67
- declare function loadAdaptiveAssignments(components: Array<{
68
- id: string;
69
- variantIds: string[];
70
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
71
-
72
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
73
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
74
- sessionId: string;
75
- };
76
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
77
- /**
78
- * Section IDs in default order. Passed to /v1/decide as the candidate
79
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
80
- * one of `sections`/`components`/`slots` must be non-empty).
81
- */
82
- sections?: string[];
83
- /** Components to assign in the same decide call. */
84
- components?: Array<{
85
- id: string;
86
- variantIds?: string[];
87
- }>;
88
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
89
- slots?: _sentientui_core_server.SlotDeclInput[];
90
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
91
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
92
- * Requires `registrySlotIds`. */
93
- slotsFrom?: 'request' | 'registry';
94
- /**
95
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
96
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
97
- * the call downgrades to request mode (with a console.error) instead of
98
- * recording a close-out trial for every published slot on every page.
99
- */
100
- registrySlotIds?: string[];
101
- /**
102
- * Registry mode: what each slot on this page can render, keyed by slot id
103
- * (see `preloadDecisions`). Ids without an entry get core's default caps.
104
- * A hybrid `<Adaptive variants>{children}</Adaptive>` needs its entry: the
105
- * server draws `authored.<key>` only for keys the page declares here.
106
- */
107
- renderCaps?: Record<string, Omit<_sentientui_core.RenderCaps, 'fp'>>;
108
- };
109
- /**
110
- * SSR helper for pages with a declared section layout and/or adaptive slots.
111
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
112
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
113
- * adopts the same session on first visit.
114
- *
115
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
116
- * Under the `development` export condition the decision is computed by the
117
- * deterministic local engine with the same sessionId the client will adopt —
118
- * server and client agree by construction. In production the engine resolves
119
- * to a stub and defaults are returned with one console.error.
120
- */
121
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
122
-
123
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };
package/dist/server.d.ts DELETED
@@ -1,123 +0,0 @@
1
- import * as _sentientui_core from '@sentientui/core';
2
- import * as _sentientui_core_server from '@sentientui/core/server';
3
- import { ServerAssignments } from '@sentientui/core/server';
4
- export { DecideResult, ServerAssignConfig, ServerAssignments, SlotDeclInput, SlotResult, preloadAssignments, preloadDecisions, readSessionCookie, signUserId, trackServerGoal } from '@sentientui/core/server';
5
-
6
- /** Return value of `loadAdaptiveAssignments` — includes the session ID used for SSR. */
7
- type LoadAdaptiveAssignmentsResult = {
8
- assignments: ServerAssignments;
9
- /** The session ID used for SSR assignment. Pass as `ssrSessionId` to `<AdaptiveProvider>`. */
10
- sessionId: string;
11
- /** Components the operator moved onto the shared track: not in
12
- * `assignments`. Pass as `initialUnified` to `<AdaptiveProvider>`. */
13
- unified: string[];
14
- };
15
- type LoadAdaptiveAssignmentsOptions = {
16
- /** Next.js `cookies()` return value, or any object with `get(name)`. */
17
- cookies: {
18
- get(name: string): {
19
- value: string;
20
- } | undefined;
21
- };
22
- apiKey: string;
23
- baseUrl: string;
24
- /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */
25
- createSessionId?: () => string;
26
- /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */
27
- origin?: string;
28
- /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */
29
- userAgent?: string;
30
- /** From Next.js `headers().get('referer')`. */
31
- referer?: string;
32
- /**
33
- * `utm_*` params from the landing URL. The Referer header never carries the
34
- * page's OWN query string, so without this the SSR-minted session has no
35
- * campaign attribution until the client SDK hydrates and re-upserts.
36
- * Derive with `extractTrackedParams(searchParams)` from `@sentientui/core/server`.
37
- */
38
- utmParams?: Record<string, string>;
39
- /** Ad-platform click IDs (gclid, fbclid, ttclid, …) from the landing URL — same derivation as `utmParams`. */
40
- clickIds?: Record<string, string>;
41
- /** The landing page's path (no query string) — recognises a paid click to a product page or a `/discount/` link on the first decision. */
42
- landingPath?: string;
43
- /** Set true when the request carries `DNT: 1` or `Sec-GPC: 1` — skips the SSR session upsert + assignment so no session is minted for an opted-out visitor (audit P4). `AdaptiveRoot` sets this automatically from the request headers. */
44
- doNotTrack?: boolean;
45
- /** Milliseconds to wait for the API before returning default variants. Defaults to 1000 (typical decide is well under 150 ms; the full budget is only reached on a cold start or a distant API). */
46
- timeoutMs?: number;
47
- /**
48
- * Declared persona — the role your app already knows for this visitor (e.g.
49
- * from your auth context: 'admin', 'evaluator'). Must be a key in the
50
- * project's persona vocabulary; unrecognized values are ignored server-side.
51
- * Never a user id or email.
52
- */
53
- persona?: string;
54
- /**
55
- * Your team / a test site — the same flag as `<AdaptiveProvider internal>`,
56
- * sent on the SSR upsert and decide so a server-rendered first page is
57
- * never counted or learned from. The request's `sentient_internal` cookie
58
- * (the "mark this browser" link) is read from `cookies` and forwarded too.
59
- */
60
- internal?: boolean;
61
- };
62
- /**
63
- * Fetches bandit assignments on the server for SEO-safe HTML.
64
- * Pass `assignments` as `initialAssignments` and `sessionId` as `ssrSessionId`
65
- * on `<AdaptiveProvider>` so the client adopts the same session on first visit.
66
- */
67
- declare function loadAdaptiveAssignments(components: Array<{
68
- id: string;
69
- variantIds: string[];
70
- }>, options: LoadAdaptiveAssignmentsOptions): Promise<LoadAdaptiveAssignmentsResult>;
71
-
72
- /** Return value of `loadAdaptiveDecision` — includes the session ID used for SSR. */
73
- type LoadAdaptiveDecisionResult = _sentientui_core_server.DecideResult & {
74
- sessionId: string;
75
- };
76
- type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {
77
- /**
78
- * Section IDs in default order. Passed to /v1/decide as the candidate
79
- * layout. Optional since 0.13.0 — slot-only pages may omit it (at least
80
- * one of `sections`/`components`/`slots` must be non-empty).
81
- */
82
- sections?: string[];
83
- /** Components to assign in the same decide call. */
84
- components?: Array<{
85
- id: string;
86
- variantIds?: string[];
87
- }>;
88
- /** Adaptive-slot declarations (useAdaptiveTokens / AdaptiveGroup) to decide server-side. */
89
- slots?: _sentientui_core_server.SlotDeclInput[];
90
- /** 'registry' serves the project's published slot definitions (`<Adaptive id>`)
91
- * and is the only way `slotConfig`/`palette` come back. Default 'request'.
92
- * Requires `registrySlotIds`. */
93
- slotsFrom?: 'request' | 'registry';
94
- /**
95
- * Registry mode: the `<Adaptive id>`s THIS page renders — the decide is
96
- * scoped to exactly these. Required with `slotsFrom: 'registry'`; without it
97
- * the call downgrades to request mode (with a console.error) instead of
98
- * recording a close-out trial for every published slot on every page.
99
- */
100
- registrySlotIds?: string[];
101
- /**
102
- * Registry mode: what each slot on this page can render, keyed by slot id
103
- * (see `preloadDecisions`). Ids without an entry get core's default caps.
104
- * A hybrid `<Adaptive variants>{children}</Adaptive>` needs its entry: the
105
- * server draws `authored.<key>` only for keys the page declares here.
106
- */
107
- renderCaps?: Record<string, Omit<_sentientui_core.RenderCaps, 'fp'>>;
108
- };
109
- /**
110
- * SSR helper for pages with a declared section layout and/or adaptive slots.
111
- * Calls `/v1/decide` instead of multiple `/v1/assign` round trips.
112
- * Pass `sessionId` as `ssrSessionId` on `<AdaptiveProvider>` so the client
113
- * adopts the same session on first visit.
114
- *
115
- * Keyless: with no valid `pk_` key this never fetches (no timeout burn).
116
- * Under the `development` export condition the decision is computed by the
117
- * deterministic local engine with the same sessionId the client will adopt —
118
- * server and client agree by construction. In production the engine resolves
119
- * to a stub and defaults are returned with one console.error.
120
- */
121
- declare function loadAdaptiveDecision(options: LoadAdaptiveDecisionOptions): Promise<LoadAdaptiveDecisionResult>;
122
-
123
- export { type LoadAdaptiveAssignmentsOptions, type LoadAdaptiveAssignmentsResult, type LoadAdaptiveDecisionOptions, type LoadAdaptiveDecisionResult, loadAdaptiveAssignments, loadAdaptiveDecision };