SparkleTree SDK API reference (@sparkletree/core and @sparkletree/react), generated from the TSDoc in the source. Index: https://docs.sparkletree.io/llms.txt # About the API reference Source: https://docs.sparkletree.io/developers/api/ Markdown: https://docs.sparkletree.io/developers/api.md The API reference for [`@sparkletree/core`](https://www.npmjs.com/package/@sparkletree/core) and [`@sparkletree/react`](https://www.npmjs.com/package/@sparkletree/react) is generated from the TSDoc in the SDK source (`core/src/index.ts` and `react/src/index.ts`) with [starlight-typedoc](https://starlight-typedoc.vercel.app/), so it is always as current as the code it documents. Generation is on by default: a normal build from the monorepo root includes the package pages in the sidebar: ```bash pnpm install pnpm --filter @sparkletree/docs-site build ``` No `core/dist` or `react/dist` build is required first. `docs-site/typedoc.tsconfig.react.json` maps `@sparkletree/core` onto its source entry point, and the core tsconfig documents the source tree directly. If you are reading this page on the published site and see no package pages in the sidebar, the site was built with the escape hatch (`STARLIGHT_TYPEDOC=0`, for checkouts where the sdk workspace is not installed). The prose API documentation is complete and hand-written either way: - [Provider, components & useIsland](https://docs.sparkletree.io/developers/sdk/components.md): `SparkletreeProvider`, `Hero`, `Cta`, `useIsland`, `StreamText`. - [Using it without React](https://docs.sparkletree.io/developers/sdk/core.md): `openStream`, `createClient`, and the obligations React was handling for you. --- # CopyChoreographer Source: https://docs.sparkletree.io/developers/api/core/classes/copychoreographer/ Markdown: https://docs.sparkletree.io/developers/api/core/classes/copychoreographer.md Defined in: state.ts:421 Owns one island's copy for one page view. Fed wire events; emits states. Pure with respect to the DOM: it decides WHAT should be on screen and when, and never touches how. That is what lets the same choreography drive React, the iframe shell, and anything else without several copies of these rules. ## Constructors ### Constructor > **new CopyChoreographer**(`options?`): `CopyChoreographer` Defined in: state.ts:484 #### Parameters ##### options? [`ChoreographerOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/choreographeroptions.md) = `{}` #### Returns `CopyChoreographer` ## Methods ### backgroundReady() > **backgroundReady**(`bgImage`): `void` Defined in: state.ts:1124 Absence of this event means KEEP THE BAKED THEME WASH. It does not mean clear the art layer — the server omits it when there is no creative image. The patch waits for the browser to DECODE the image first, so a new background never paints before its pixels exist. On failure the patch still lands; outside a browser it is immediate. #### Parameters ##### bgImage `string` #### Returns `void` *** ### checkDeadline() > **checkDeadline**(): `void` Defined in: state.ts:701 Apply a hold expiry whose time has already passed but whose timer has not run: a background tab throttles timers, and a page restored from the back/forward cache resumes with them overdue. Copy events call this first, so text arriving after the deadline is never shown in place of the fallback. Renderers call it when the page is shown again. Idempotent. The typing stall (`TYPING_STALL_MS`) is checked here on the same clock: a field whose last text is that old is decided now, and a chunk that arrives after that is dropped. A field that kept receiving text while a timer ran late has not stalled. While the page is hidden (`setPageVisible(false)`) no field stalls. #### Returns `void` *** ### copyChunk() > **copyChunk**(`field`, `text`): `void` Defined in: state.ts:1006 A delta landed. While holding (and in view) the first text takes the canvas; on a live field it extends the text. Dropped for a final field. #### Parameters ##### field [`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md) ##### text `string` #### Returns `void` *** ### copyDone() > **copyDone**(`field`, `text`): `void` Defined in: state.ts:1037 A field closed. Its text completes what the field shows: it lands whole on a blank field and finishes a typed one. It never replaces different visible text — if it does not extend what was typed, the typed text stands (and development builds warn). For a final field this only marks it settled. #### Parameters ##### field [`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md) ##### text `string` #### Returns `void` *** ### copyStart() > **copyStart**(`field`, `mode`, `source`): `void` Defined in: state.ts:966 A field opened: proof of life, and provenance. The first `*-start` of a field the page shows restarts the hold budget once if it is running: a fresh budget from now. Otherwise dropped for a final field. A field the fallback does not define (`fallbackDefinesSlots`) is never shown, but its start is proof of life too, and the hero stream opens with `greeting-start`. While the hold runs and has not been restarted, such a start extends it so that it ends no earlier than one budget from now, without spending the one restart: the restart stays for the first field the page shows, as before. The preamble (`theme-ready`, `layout-ready`) counts for neither: the edge sends it before generation begins, so a stalled generation sends it too. Both stay inside the absolute maximum, and neither runs after the hold expired (`checkDeadline` first) or paints anything. #### Parameters ##### field [`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md) ##### mode `"generate"` \| `"replay"` \| `null` ##### source `"generated"` \| `"cached"` \| `"static"` #### Returns `void` *** ### ctaReady() > **ctaReady**(`text`, `style`, `action?`): `void` Defined in: state.ts:1193 #### Parameters ##### text `string` ##### style `unknown` ##### action? `string` #### Returns `void` *** ### ctaStyleReady() > **ctaStyleReady**(`style`): `void` Defined in: state.ts:1188 #### Parameters ##### style `unknown` #### Returns `void` *** ### dispose() > **dispose**(): `void` Defined in: state.ts:1333 Release timers and listeners. After it every public method is a no-op: nothing changes `getState()` and nothing is emitted. Safe to call twice. #### Returns `void` *** ### done() > **done**(`meta`): `void` Defined in: state.ts:1257 Terminal, success. #### Parameters ##### meta `Record`\<`string`, `unknown`\> #### Returns `void` *** ### failed() > **failed**(`message`): `void` Defined in: state.ts:1311 Terminal, failure. No failure blanks the canvas: copy that closed stays, a blank field gets its fallback, and a field the stream was still writing goes through the `UnfinishedCopyPolicy` (by default its fallback replaces the half line, once). #### Parameters ##### message `string` #### Returns `void` *** ### getState() > **getState**(): [`CreativeState`](https://docs.sparkletree.io/developers/api/core/interfaces/creativestate.md) Defined in: state.ts:532 #### Returns [`CreativeState`](https://docs.sparkletree.io/developers/api/core/interfaces/creativestate.md) *** ### keepFallback() > **keepFallback**(`field`): `void` Defined in: state.ts:1079 The renderer will not show this field's copy: it does not fit the slot its fallback reserved. The fallback lands instead and is final for the view; later copy for the field is dropped. Call it before the copy is painted (a renderer measures before the browser paints), never for text the visitor has seen. #### Parameters ##### field [`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md) #### Returns `void` *** ### layoutReady() > **layoutReady**(`layout`, `manifest?`): `void` Defined in: state.ts:1108 #### Parameters ##### layout `string` ##### manifest? `unknown` #### Returns `void` *** ### legalReady() > **legalReady**(`lines`): `void` Defined in: state.ts:1170 Legal lines for the viewer's market. Lines are deduplicated on `id` and kept in the order given; a line without text is skipped. A later `legal-ready` in the same stream replaces the list. #### Parameters ##### lines `unknown` #### Returns `void` *** ### liveReady() > **liveReady**(`block`): `void` Defined in: state.ts:1158 The live player for this slot. A block for the channel already showing changes nothing: the state keeps the block it has, so a renderer leaves its playing iframe alone. A block for another channel replaces it. #### Parameters ##### block [`LiveBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md) \| `null` #### Returns `void` *** ### sequenceReady() > **sequenceReady**(`frames`, `heroIndex`, `fps`): `void` Defined in: state.ts:1143 #### Parameters ##### frames `string`[] ##### heroIndex `number` ##### fps `number` #### Returns `void` *** ### setPageVisible() > **setPageVisible**(`visible`): `void` Defined in: state.ts:725 Tell the choreographer whether the page is visible (a renderer calls it on `visibilitychange`, `pagehide`/`pageshow` and `freeze`/`resume`; `watchPageVisibility` does that). Stall time counts only while the page is visible: while it is hidden or frozen no line stalls, and when it is visible again every line being written gets a fresh `TYPING_STALL_MS` from that moment. Chunks that were buffered meanwhile restart the clock as usual when they arrive. The hold is not affected. Idempotent. #### Parameters ##### visible `boolean` #### Returns `void` *** ### slotInView() > **slotInView**(): `void` Defined in: state.ts:646 Call when the slot is in view (already in view at mount counts). Only meaningful with `holdStartsInView`; otherwise the slot is in view from the start and this is a no-op. At that moment copy the stream already delivered takes the canvas — finished fields land whole, unfinished ones type from the buffer — and with nothing delivered the hold budget starts. #### Returns `void` *** ### streamOpened() > **streamOpened**(): `void` Defined in: state.ts:597 Call when live copy is coming: when the stream request opens, or earlier when a renderer already knows it will (a stream waiting on a shared variant). Idempotent. Arms the hold when there is fallback copy the visitor has not seen. Copy the visitor can already see (`initialIsOnScreen`) or finished creative (`serverRendered`) is final instead: nothing to hold, nothing to replace. #### Returns `void` *** ### subscribe() > **subscribe**(`listener`): () => `void` Defined in: state.ts:536 #### Parameters ##### listener `Listener` #### Returns () => `void` *** ### themeReady() > **themeReady**(`colors`, `sources`): `void` Defined in: state.ts:1103 #### Parameters ##### colors `Record`\<`string`, `string`\> ##### sources `Record`\<`string`, `string`\> #### Returns `void` *** ### videoReady() > **videoReady**(`videoUrl`): `void` Defined in: state.ts:1148 #### Parameters ##### videoUrl `string` #### Returns `void` --- # ImpressionRecorder Source: https://docs.sparkletree.io/developers/api/core/classes/impressionrecorder/ Markdown: https://docs.sparkletree.io/developers/api/core/classes/impressionrecorder.md Defined in: analytics.ts:309 Records at most one impression per island per page view. The guard is an instance, not a module global, so two islands on one page each get their own — while a single island being re-rendered, re-subscribed or double-invoked by React strict mode gets exactly one. ## Constructors ### Constructor > **new ImpressionRecorder**(`context`): `ImpressionRecorder` Defined in: analytics.ts:312 #### Parameters ##### context [`AnalyticsContext`](https://docs.sparkletree.io/developers/api/core/interfaces/analyticscontext.md) #### Returns `ImpressionRecorder` ## Accessors ### hasFired #### Get Signature > **get** **hasFired**(): `boolean` Defined in: analytics.ts:314 ##### Returns `boolean` ## Methods ### record() > **record**(`detail`): `boolean` Defined in: analytics.ts:319 Idempotent. Returns true only for the call that actually recorded. #### Parameters ##### detail [`ImpressionDetail`](https://docs.sparkletree.io/developers/api/core/interfaces/impressiondetail.md) #### Returns `boolean` --- # SseParser Source: https://docs.sparkletree.io/developers/api/core/classes/sseparser/ Markdown: https://docs.sparkletree.io/developers/api/core/classes/sseparser.md Defined in: sse.ts:33 Incremental SSE frame parser. Feed it decoded text; it yields complete messages. Holds partial frames across chunk boundaries — a `data:` line split mid-UTF-8-sequence or mid-JSON is the normal case on a real network, not an edge case. ## Constructors ### Constructor > **new SseParser**(): `SseParser` #### Returns `SseParser` ## Methods ### flush() > **flush**(): [`SseMessage`](https://docs.sparkletree.io/developers/api/core/interfaces/ssemessage.md)[] Defined in: sse.ts:71 Flush a trailing frame that never got its blank line (server closed). #### Returns [`SseMessage`](https://docs.sparkletree.io/developers/api/core/interfaces/ssemessage.md)[] *** ### push() > **push**(`chunk`): [`SseMessage`](https://docs.sparkletree.io/developers/api/core/interfaces/ssemessage.md)[] Defined in: sse.ts:43 Feed a chunk of decoded text; returns every message it completed. #### Parameters ##### chunk `string` #### Returns [`SseMessage`](https://docs.sparkletree.io/developers/api/core/interfaces/ssemessage.md)[] --- # VariantRegistry Source: https://docs.sparkletree.io/developers/api/core/classes/variantregistry/ Markdown: https://docs.sparkletree.io/developers/api/core/classes/variantregistry.md Defined in: variant.ts:115 ## Constructors ### Constructor > **new VariantRegistry**(): `VariantRegistry` #### Returns `VariantRegistry` ## Accessors ### viewId #### Get Signature > **get** **viewId**(): `string` \| `null` Defined in: variant.ts:140 The explicit page view the registry is scoped to, or null for the implicit view (the one `reset()` starts). ##### Returns `string` \| `null` ## Methods ### enterView() > **enterView**(`viewId`): `boolean` Defined in: variant.ts:152 Scope the registry to page view `viewId`. A different id than the current one starts a new page view: pins, reservations and slot memories of the old view are dropped (as `reset()` does) before anything is pinned for the new one. The same id again changes nothing, so calling it on every render is safe. Returns true when it started a new view. #### Parameters ##### viewId `string` #### Returns `boolean` *** ### fallbackShown() > **fallbackShown**(`key`): `boolean` Defined in: variant.ts:191 Has this slot's fallback already been shown in this page view? #### Parameters ##### key `string` #### Returns `boolean` *** ### get() > **get**(`key`): `string` \| `undefined` Defined in: variant.ts:200 The variant to request for this pin key — the campaign id, or the surface id for surface-only islands — if one is already pinned. Undefined means "let the server choose" — which it should, exactly once. #### Parameters ##### key `string` #### Returns `string` \| `undefined` *** ### markFallbackShown() > **markFallbackShown**(`key`): `void` Defined in: variant.ts:186 Record that a slot's fallback has been shown in this page view (the hold ran out, or a server reservation revealed it). It is final for the rest of the page view: a later mount of the same slot — a re-render, a suspended boundary resolving — shows it again instead of holding, and no later stream replaces it. `key` is the renderer's slot identity. #### Parameters ##### key `string` #### Returns `void` *** ### onNewView() > **onNewView**(`listener`): () => `void` Defined in: variant.ts:129 Run `listener` whenever a page view ends and a new one begins (a client navigation, `enterView` with a different view, or `reset` after use). Not for the page's first view: state a server render left for it stays. Returns the unsubscribe. #### Parameters ##### listener () => `void` #### Returns () => `void` *** ### pin() > **pin**(`key`, `variantId`): `string` Defined in: variant.ts:213 Record a resolved variant. First writer wins. Later calls are ignored rather than overwriting, because a second resolution arriving at all means one island raced ahead of the pin — and in that case the right repair is to keep the value already reported on the impression, not to adopt the newer one and disagree with our own analytics. #### Parameters ##### key `string` ##### variantId `string` #### Returns `string` *** ### reserve() > **reserve**(`key`, `timeoutMs?`): [`VariantReservation`](https://docs.sparkletree.io/developers/api/core/type-aliases/variantreservation.md) Defined in: variant.ts:230 Claim, or wait for, this page view's variant for a pin key (campaign id, or surface id for surface-only islands). The first caller (per key, per page view) gets a LEADER reservation and must eventually call `resolve` or `abort` on it. Everyone else gets a FOLLOWER whose promise resolves with the leader's variant, capped at `timeoutMs`. A key that is already pinned returns a follower whose promise is already resolved — awaiting it costs one microtask. #### Parameters ##### key `string` ##### timeoutMs? `number` = `RESERVATION_TIMEOUT_MS` #### Returns [`VariantReservation`](https://docs.sparkletree.io/developers/api/core/type-aliases/variantreservation.md) *** ### reset() > **reset**(): `void` Defined in: variant.ts:281 New page view. Call on client-side navigation, or scope the registry to explicit views with `enterView` (the provider does this for you when it is given a `serverContext` or a `viewKey`). #### Returns `void` *** ### slot() > **slot**(`key`): [`SlotMemory`](https://docs.sparkletree.io/developers/api/core/interfaces/slotmemory.md) Defined in: variant.ts:163 The memory of one copy slot in this page view, created empty on first use. `key` is the renderer's slot identity. Cleared with the view. #### Parameters ##### key `string` #### Returns [`SlotMemory`](https://docs.sparkletree.io/developers/api/core/interfaces/slotmemory.md) --- # activePlayer Source: https://docs.sparkletree.io/developers/api/core/functions/activeplayer/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/activeplayer.md > **activePlayer**(): [`AudioHandle`](https://docs.sparkletree.io/developers/api/core/interfaces/audiohandle.md) \| `null` Defined in: audio.ts:512 The currently mounted player, if any. ## Returns [`AudioHandle`](https://docs.sparkletree.io/developers/api/core/interfaces/audiohandle.md) \| `null` --- # applyServerContext Source: https://docs.sparkletree.io/developers/api/core/functions/applyservercontext/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/applyservercontext.md > **applyServerContext**(`context`, `serverContext`): `Record`\<`string`, `unknown`\> Defined in: visitorContext.ts:112 `context` with the server's decisions applied: each of `SERVER_CONTEXT_KEYS` takes the server's value, or is removed when the server had none. Without a `serverContext`, `context` is returned as is. ## Parameters ### context `Record`\<`string`, `unknown`\> ### serverContext [`ServerContext`](https://docs.sparkletree.io/developers/api/core/interfaces/servercontext.md) \| `null` \| `undefined` ## Returns `Record`\<`string`, `unknown`\> --- # applyTheme Source: https://docs.sparkletree.io/developers/api/core/functions/applytheme/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/applytheme.md > **applyTheme**(`element`, `theme`): () => `void` Defined in: theme.ts:52 Write tokens onto an element. Returns a function restoring the previous values, so a component that unmounts mid-stream does not leave a half-applied theme behind on a long-lived host element. ## Parameters ### element `HTMLElement` ### theme [`ResolvedTheme`](https://docs.sparkletree.io/developers/api/core/interfaces/resolvedtheme.md) \| `null` ## Returns () => `void` --- # ask Source: https://docs.sparkletree.io/developers/api/core/functions/ask/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/ask.md > **ask**(`options`): `Promise`\<[`AskResult`](https://docs.sparkletree.io/developers/api/core/interfaces/askresult.md)\> Defined in: ask.ts:123 Ask one question. Never rejects. ## Parameters ### options [`AskOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/askoptions.md) ## Returns `Promise`\<[`AskResult`](https://docs.sparkletree.io/developers/api/core/interfaces/askresult.md)\> --- # buildContentUrl Source: https://docs.sparkletree.io/developers/api/core/functions/buildcontenturl/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/buildcontenturl.md > **buildContentUrl**(`target`, `protocol?`): `string` Defined in: protocol.ts:133 Build the `/content` URL used for first paint. Same pinning rules as the stream — but deliberately NOT the same `sdk=1` rule. `sdk=1` is a promise: "the SDK will record this impression itself". The stream path keeps that promise — `useIsland` owns a visibility-gated recorder. The content path CANNOT: its consumers (CopyCard, ProductCard, the cookbook's content-only recipes) have no observer and no recorder, so sending `sdk=1` here told the server to stop counting while nobody else started — zero impressions for every content-only integration. Omitting it leaves the server owning the `/content` impression, exactly as it does for every non-SDK consumer of the endpoint. ## Parameters ### target [`StreamTarget`](https://docs.sparkletree.io/developers/api/core/interfaces/streamtarget.md) ### protocol? `number` = `PROTOCOL_CURRENT` ## Returns `string` --- # buildFactsUrl Source: https://docs.sparkletree.io/developers/api/core/functions/buildfactsurl/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/buildfactsurl.md > **buildFactsUrl**(`options`): `string` Defined in: facts.ts:173 The facts URL for these options. The key is never put in it. ## Parameters ### options #### apiBase `string` #### campaignId? `string` #### organizationId `string` #### products? readonly `string`[] #### surfaceId? `string` ## Returns `string` --- # buildStreamUrl Source: https://docs.sparkletree.io/developers/api/core/functions/buildstreamurl/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/buildstreamurl.md > **buildStreamUrl**(`target`, `protocol?`): `string` Defined in: protocol.ts:96 Build the stream URL. `sdk=1` is not optional and not a feature flag: it tells the server to suppress its own server-side impression for this request. The SDK renders inside the customer's page, so it is the only party that knows whether the creative was ever actually on screen — and a server-side impression on top of the client's own would double-count every view, and would keep counting from a CDN-cached SSR response that no human ever saw. ## Parameters ### target [`StreamTarget`](https://docs.sparkletree.io/developers/api/core/interfaces/streamtarget.md) ### protocol? `number` = `PROTOCOL_CURRENT` ## Returns `string` --- # canonicalContextString Source: https://docs.sparkletree.io/developers/api/core/functions/canonicalcontextstring/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/canonicalcontextstring.md > **canonicalContextString**(`dims`): `string` Defined in: context.ts:271 Canonical form: drop absent/unknown keys → lowercase → sort keys bytewise → join "k:v|k:v". Already-normalized dims only; run normalizeDims first. ## Parameters ### dims [`CanonicalDims`](https://docs.sparkletree.io/developers/api/core/type-aliases/canonicaldims.md) ## Returns `string` --- # canonicalJson Source: https://docs.sparkletree.io/developers/api/core/functions/canonicaljson/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/canonicaljson.md > **canonicalJson**(`value`): `string` Defined in: facts.ts:421 Canonical JSON as the edge signs it: RFC 8785 (JCS) for the values a facts document contains. Object members sorted by the UTF-16 code units of their names, no whitespace, strings escaping only `"`, `\` and U+0000 to U+001F (`\b \f \n \r \t` where they exist, lower-case `\u00xx` otherwise). Everything else, `<`, `>`, `&`, U+2028 and U+2029 included, is written as is. Numbers are written as ECMAScript writes them, which is what JCS requires. Members whose value is undefined are left out, as in JSON. Throws TypeError on a value JSON cannot represent (a non-finite number, a bigint, a function). ## Parameters ### value `unknown` ## Returns `string` --- # checkSetup Source: https://docs.sparkletree.io/developers/api/core/functions/checksetup/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/checksetup.md > **checkSetup**(`options`): `Promise`\<[`WhoamiResult`](https://docs.sparkletree.io/developers/api/core/interfaces/whoamiresult.md)\> Defined in: setup.ts:102 Check a key and an origin against the edge. Never rejects. ## Parameters ### options [`CheckSetupOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/checksetupoptions.md) ## Returns `Promise`\<[`WhoamiResult`](https://docs.sparkletree.io/developers/api/core/interfaces/whoamiresult.md)\> --- # computeContextHash Source: https://docs.sparkletree.io/developers/api/core/functions/computecontexthash/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/computecontexthash.md > **computeContextHash**(`dims`): `Promise`\<`string`\> Defined in: context.ts:292 sha256(canonical) → hex, truncated to 16 chars (64 bits). ## Parameters ### dims [`CanonicalDims`](https://docs.sparkletree.io/developers/api/core/type-aliases/canonicaldims.md) ## Returns `Promise`\<`string`\> --- # computeFieldBudget Source: https://docs.sparkletree.io/developers/api/core/functions/computefieldbudget/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/computefieldbudget.md > **computeFieldBudget**(`fallback`, `kind`): `number` Defined in: context.ts:344 Piecewise: identity at or below `QUANTIZE_ABOVE`, tapered and quantized above it. Below the frozen boundary this is exactly the historical function — ceil(max(len × 1.3, floor)) — so every schema hash computed by any shipped SDK is stable across releases. Above it, two properties for large fields: - The multiplier tapers (1.05·len + 125, which equals 1.3·len exactly at len = 500, so the curve is continuous): ±30% of a paragraph is a line, ±30% of 5,000 chars is ~250px of layout shift. - The result quantizes to steps of 64. The raw budget is in the schema hash, so un-quantized, EVERY character edit re-keys the cache and costs a fresh generation; stepped, a typo stays on the same copy while a new sentence is honestly new. Server twin: mosaic/services/fragments/fragmentService.ts computeFieldBudget — adopted in the fragments-0.3 release that lifted the caps, byte-identical, held to the shared vectors (including `quantized_vectors`). The server recomputes and never trusts the client's number. ## Parameters ### fallback `string` ### kind `string` ## Returns `number` --- # computeSchemaHash Source: https://docs.sparkletree.io/developers/api/core/functions/computeschemahash/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/computeschemahash.md > **computeSchemaHash**(`fields`): `Promise`\<`string`\> Defined in: context.ts:360 Schema hash: keys + kinds + budgets, never the fallback prose (prose in the GET URL would make the CDN object private and delete the cost story). MUST stay byte-identical to mosaic/services/fragments/fragmentService.ts computeSchemaHash; the shared vectors in parity/fixtures/ctxhash/schema-vectors.json are the contract. ## Parameters ### fields readonly `object`[] ## Returns `Promise`\<`string`\> --- # consentAllowed Source: https://docs.sparkletree.io/developers/api/core/functions/consentallowed/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/consentallowed.md > **consentAllowed**(): `boolean` Defined in: analytics.ts:184 Does the viewer allow analytics? False under Global Privacy Control (`navigator.globalPrivacyControl`) or Do Not Track (`"1"` or `"yes"` on `navigator.doNotTrack` or `window.doNotTrack`, and the legacy numeric 1), the same rule as the SparkleTree edge tracker. Read on every send, so a signal that changes mid-visit applies at once. ## Returns `boolean` --- # copyLength Source: https://docs.sparkletree.io/developers/api/core/functions/copylength/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/copylength.md > **copyLength**(`text`): `number` Defined in: slots.ts:35 The length of copy as a length budget counts it: Unicode code points, so an emoji or an accented letter written as one character counts as one. ## Parameters ### text `string` ## Returns `number` --- # createClient Source: https://docs.sparkletree.io/developers/api/core/functions/createclient/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/createclient.md > **createClient**(`options`): [`SparkletreeClient`](https://docs.sparkletree.io/developers/api/core/interfaces/sparkletreeclient.md) Defined in: fragments.ts:1483 Vanilla entry point, in core where the wire lives. Throws TypeError on a malformed key or missing configuration — setup errors surface at setup time; only the resolved `fragments()` call is the never-rejects path. ## Parameters ### options [`CreateClientOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/createclientoptions.md) ## Returns [`SparkletreeClient`](https://docs.sparkletree.io/developers/api/core/interfaces/sparkletreeclient.md) --- # decideChrome Source: https://docs.sparkletree.io/developers/api/core/functions/decidechrome/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/decidechrome.md > **decideChrome**(`contentSource`, `viewerPrefersStandard`): [`ChromeDecision`](https://docs.sparkletree.io/developers/api/core/interfaces/chromedecision.md) Defined in: trust.ts:42 Should this copy carry the adaptation mark? `cached` counts as adapted: the copy WAS generated, for an earlier viewer in the same variant × context bucket. It is not fresh, but it is not authored either, and calling it authored would be the same lie in the other direction. ## Parameters ### contentSource `"generated"` \| `"cached"` \| `"static"` ### viewerPrefersStandard `boolean` ## Returns [`ChromeDecision`](https://docs.sparkletree.io/developers/api/core/interfaces/chromedecision.md) --- # declaredToDims Source: https://docs.sparkletree.io/developers/api/core/functions/declaredtodims/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/declaredtodims.md > **declaredToDims**(`declared`): `Record`\<`string`, `unknown`\> Defined in: context.ts:249 Maps the public DeclaredContext shape onto short-key dims. ## Parameters ### declared [`DeclaredContext`](https://docs.sparkletree.io/developers/api/core/interfaces/declaredcontext.md) ## Returns `Record`\<`string`, `unknown`\> --- # decodePublishableKey Source: https://docs.sparkletree.io/developers/api/core/functions/decodepublishablekey/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/decodepublishablekey.md > **decodePublishableKey**(`key`): [`PublishableKeyPayload`](https://docs.sparkletree.io/developers/api/core/interfaces/publishablekeypayload.md) Defined in: publishableKey.ts:58 Decode a publishable key. Throws TypeError on anything malformed — a bad key is a configuration error at integration time, not a runtime condition to degrade around. Whitespace around the key (the newline a key pasted from an env file carries) is not part of it and is ignored, as every call that sends a key ignores it. ## Parameters ### key `string` ## Returns [`PublishableKeyPayload`](https://docs.sparkletree.io/developers/api/core/interfaces/publishablekeypayload.md) --- # destroyActiveAudio Source: https://docs.sparkletree.io/developers/api/core/functions/destroyactiveaudio/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/destroyactiveaudio.md > **destroyActiveAudio**(): `void` Defined in: audio.ts:537 ## Returns `void` --- # deviceTypeForViewport Source: https://docs.sparkletree.io/developers/api/core/functions/devicetypeforviewport/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/devicetypeforviewport.md > **deviceTypeForViewport**(`matchesMobileQuery`): [`DeviceType`](https://docs.sparkletree.io/developers/api/core/type-aliases/devicetype.md) Defined in: visitorContext.ts:39 The device bucket for a viewport that does or does not match `MOBILE_VIEWPORT_QUERY`. ## Parameters ### matchesMobileQuery `boolean` ## Returns [`DeviceType`](https://docs.sparkletree.io/developers/api/core/type-aliases/devicetype.md) --- # encodePublishableKey Source: https://docs.sparkletree.io/developers/api/core/functions/encodepublishablekey/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/encodepublishablekey.md > **encodePublishableKey**(`options`): `string` Defined in: publishableKey.ts:88 Encode the ADDRESSING half of a publishable key — organizationId and apiBase, no `sig`. The SDK holds no secret, so a key encoded here is unsigned and the server rejects it (`unsigned`) when enforcement is on. Signed keys are minted in the dashboard. This exists for tests and for self-hosters who run their own signer downstream. ## Parameters ### options #### apiBase `string` #### env [`PublishableKeyEnv`](https://docs.sparkletree.io/developers/api/core/type-aliases/publishablekeyenv.md) #### organizationId `string` ## Returns `string` --- # expandFieldSpecs Source: https://docs.sparkletree.io/developers/api/core/functions/expandfieldspecs/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/expandfieldspecs.md > **expandFieldSpecs**(`fields`): `Record`\<`string`, [`FragmentFieldSpec`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentfieldspec.md)\> Defined in: fragments.ts:334 Expand array fallbacks into ordinary per-paragraph fields: `intro` with three elements becomes `intro1`, `intro2`, `intro3`, each inheriting the field's kind and swap. Runs BEFORE hashing and before the wire, in both the React and the core paths, so the server never learns arrays exist. Idempotent: expanded specs contain no arrays. ## Parameters ### fields `Record`\<`string`, [`FragmentFieldSpec`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentfieldspec.md)\> ## Returns `Record`\<`string`, [`FragmentFieldSpec`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentfieldspec.md)\> --- # factText Source: https://docs.sparkletree.io/developers/api/core/functions/facttext/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/facttext.md > **factText**(`product`, `fact`, `language?`, `labels?`): `string` \| `undefined` Defined in: facts.ts:353 The text for one fact of one product, or undefined when the workspace has not stated it (the fallback then stays). `price` is the amount formatted with its currency for `language` (`Intl.NumberFormat(language, { style: "currency", currency })`), or the raw amount when the currency is not known or cannot be formatted. `amount` is always the raw decimal string. `availability` is the label in `labels` for the stated state (`in_stock` or `out_of_stock`), and undefined when there is no label for it, when no labels are given, or when the state is `"unknown"`: the stated code is data (`product.availability`), never text for a page. The same inputs give the same string on a server and in a browser that share the same Intl data. ## Parameters ### product [`FactProduct`](https://docs.sparkletree.io/developers/api/core/interfaces/factproduct.md) \| `undefined` ### fact `"amount"` \| `"name"` \| `"price"` \| `"currency"` \| `"availability"` \| `"sku"` \| `"description"` ### language? `string` = `"en"` ### labels? `Partial`\<`Record`\<`"in_stock"` \| `"out_of_stock"`, `string`\>\> ## Returns `string` \| `undefined` --- # fetchContent Source: https://docs.sparkletree.io/developers/api/core/functions/fetchcontent/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/fetchcontent.md > **fetchContent**(`target`, `options?`): `Promise`\<[`ContentSnapshot`](https://docs.sparkletree.io/developers/api/core/interfaces/contentsnapshot.md) \| `null`\> Defined in: client.ts:145 Fetch the first-paint content. Content-first, rewrite-once: this is what the SDK paints BEFORE any stream exists, so there is never a skeleton on screen. If it fails, the consumer's `fallback` prop is what stands in — which is why that prop is required rather than optional. ## Parameters ### target [`StreamTarget`](https://docs.sparkletree.io/developers/api/core/interfaces/streamtarget.md) ### options? [`FetchContentOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/fetchcontentoptions.md) = `{}` ## Returns `Promise`\<[`ContentSnapshot`](https://docs.sparkletree.io/developers/api/core/interfaces/contentsnapshot.md) \| `null`\> --- # fetchFacts Source: https://docs.sparkletree.io/developers/api/core/functions/fetchfacts/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/fetchfacts.md > **fetchFacts**(`options`): `Promise`\<[`FactsResult`](https://docs.sparkletree.io/developers/api/core/interfaces/factsresult.md)\> Defined in: facts.ts:213 Read the stated facts for a campaign, a surface or named products. Never rejects. ## Parameters ### options [`FetchFactsOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/fetchfactsoptions.md) ## Returns `Promise`\<[`FactsResult`](https://docs.sparkletree.io/developers/api/core/interfaces/factsresult.md)\> --- # fetchFragments Source: https://docs.sparkletree.io/developers/api/core/functions/fetchfragments/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/fetchfragments.md > **fetchFragments**(`options`): `Promise`\<[`FragmentsResult`](https://docs.sparkletree.io/developers/api/core/interfaces/fragmentsresult.md)\> Defined in: fragments.ts:745 Resolve fragments for a declared context. Resolves fast; NEVER rejects; fallback-shaped on any failure. One declaration may mix three kinds of field, resolved under this one call into one `fields` map: generated fields (the mint path, unchanged), fact fields (one `fetchFacts` call for every product named) and slot fields (one `/content` call per distinct campaign or surface). Only generated fields enter the schema hash and the mint request. A fact or slot value that does not fit its field's budget is refused and the fallback stays. ## Parameters ### options [`FetchFragmentsOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/fetchfragmentsoptions.md) ## Returns `Promise`\<[`FragmentsResult`](https://docs.sparkletree.io/developers/api/core/interfaces/fragmentsresult.md)\> --- # findFactProduct Source: https://docs.sparkletree.io/developers/api/core/functions/findfactproduct/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/findfactproduct.md > **findFactProduct**(`facts`, `product`): [`FactProduct`](https://docs.sparkletree.io/developers/api/core/interfaces/factproduct.md) \| `undefined` Defined in: facts.ts:326 The product a declaration names, by id or handle. Matched without regard to case, as the edge matches it. ## Parameters ### facts [`FactsPayload`](https://docs.sparkletree.io/developers/api/core/interfaces/factspayload.md) \| `null` \| `undefined` ### product `string` ## Returns [`FactProduct`](https://docs.sparkletree.io/developers/api/core/interfaces/factproduct.md) \| `undefined` --- # flattenCustomContext Source: https://docs.sparkletree.io/developers/api/core/functions/flattencustomcontext/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/flattencustomcontext.md > **flattenCustomContext**\<`T`\>(`context`): `Record`\<`string`, `unknown`\> Defined in: context.ts:233 A context object as the wire carries it: the entries of `custom` become `x.` keys (lowercased; they win over literal `x.*` keys) and `custom` itself is removed. Every other key is kept as is. The server reads custom dimensions only as `x.*` keys, so the browser's streams and the server read both send context through this one function. ## Type Parameters ### T `T` *extends* `Record`\<`string`, `unknown`\> ## Parameters ### context `T` ## Returns `Record`\<`string`, `unknown`\> --- # formatPrice Source: https://docs.sparkletree.io/developers/api/core/functions/formatprice/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/formatprice.md > **formatPrice**(`amount`, `currency`, `language?`): `string` Defined in: facts.ts:396 Format a stated amount for display. Falls back to the raw amount when the currency is unknown, the amount is not a plain decimal, or Intl refuses the language or currency. ## Parameters ### amount `string` ### currency `string` \| `undefined` ### language? `string` = `"en"` ## Returns `string` --- # fragmentSwapPolicy Source: https://docs.sparkletree.io/developers/api/core/functions/fragmentswappolicy/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/fragmentswappolicy.md > **fragmentSwapPolicy**(`_spec?`, `_kind?`): [`FragmentSwapPolicy`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentswappolicy.md) Defined in: fragments.ts:176 The swap policy that applies to a field: `"never"`, whatever the field declares. The deprecated `"before-paint"` and `"always"` are accepted and behave as `"never"`. (`spec` and `kind` are accepted for compatibility.) ## Parameters ### \_spec? [`FragmentFieldSpec`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentfieldspec.md) ### \_kind? `"headline"` \| `"body"` \| `"cta"` \| `"label"` \| `"empty-state"` ## Returns [`FragmentSwapPolicy`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentswappolicy.md) --- # hashDeclaredContext Source: https://docs.sparkletree.io/developers/api/core/functions/hashdeclaredcontext/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/hashdeclaredcontext.md > **hashDeclaredContext**(`declared`): `Promise`\<\{ `dims`: [`CanonicalDims`](https://docs.sparkletree.io/developers/api/core/type-aliases/canonicaldims.md); `dropped`: `string`[]; `hash`: `string`; \}\> Defined in: context.ts:378 Convenience: declared shape → normalized dims → hash. Declared dims ONLY — no environment parameter, by design: env signals must never enter the fragment identity (fragments.ts doctrine), or the shared CDN cache keys on device/daypart combinations and bills a fresh generation for each. A signature that ACCEPTED an env bag was a standing invitation to defeat that fence. ## Parameters ### declared [`DeclaredContext`](https://docs.sparkletree.io/developers/api/core/interfaces/declaredcontext.md) ## Returns `Promise`\<\{ `dims`: [`CanonicalDims`](https://docs.sparkletree.io/developers/api/core/type-aliases/canonicaldims.md); `dropped`: `string`[]; `hash`: `string`; \}\> --- # hourInTimeZone Source: https://docs.sparkletree.io/developers/api/core/functions/hourintimezone/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/hourintimezone.md > **hourInTimeZone**(`date`, `timeZone?`): `number` Defined in: visitorContext.ts:60 The hour (0–23) of `date` in `timeZone`. Without a time zone, the runtime's local hour (in a browser, the visitor's own). ## Parameters ### date `Date` ### timeZone? `string` ## Returns `number` --- # inDevelopment Source: https://docs.sparkletree.io/developers/api/core/functions/indevelopment/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/indevelopment.md > **inDevelopment**(): `boolean` Defined in: devwarn.ts:38 ## Returns `boolean` --- # isClearlyErrorText Source: https://docs.sparkletree.io/developers/api/core/functions/isclearlyerrortext/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/isclearlyerrortext.md > **isClearlyErrorText**(`text`): `boolean` Defined in: state.ts:265 True when `text` is very clearly not copy: it contains an error message, a stack or status text, raw markup or JSON, or a model refusal. Conservative by design — anything that could be ordinary copy returns false. The default policy no longer reads it (an unfinished line is replaced whatever it says). `keepUnlessClearlyError` does, and so can your own policy or logging. ## Parameters ### text `string` ## Returns `boolean` --- # isFirstPartyApiBase Source: https://docs.sparkletree.io/developers/api/core/functions/isfirstpartyapibase/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/isfirstpartyapibase.md > **isFirstPartyApiBase**(`apiBase`): `boolean` Defined in: safeUrl.ts:115 Is this apiBase first-party — the hosted SparkleTree edge, or loopback? "First-party" is the fixed set of hosts SparkleTree itself operates: sparkletree.io (the platform and the campaigns edge alias) and qrtree.ai (the public edge origin the dashboard writes into every publishable key, `p.qrtree.ai`). A key minted by the dashboard therefore mints as-is; a hand-encoded key pointing anywhere else still gets content and no token. The publishable key is an unsigned address ANYONE can hand-encode (see publishableKey.ts), so an apiBase that arrived via a key proves nothing about who chose it. The one value that must never follow an unproven address is the signed mint token: it is a real spend credential, and a doctored key pointing at an attacker host would receive it on the mint POST and replay it against the real API for its TTL (security review S-2). The mint therefore fires only when the apiBase is explicit (the developer's own prop — their choice to make), first-party, or loopback. Self-hosted bases are exactly what the explicit `apiBase` escape hatch is for; a self-made key carrying a third-party host gets content but no mint. ## Parameters ### apiBase `string` ## Returns `boolean` --- # isSameLiveBlock Source: https://docs.sparkletree.io/developers/api/core/functions/issameliveblock/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/issameliveblock.md > **isSameLiveBlock**(`a`, `b`): `boolean` Defined in: live.ts:119 Do two blocks show the same player? The channel id decides; a block without one is told apart by its address. ## Parameters ### a [`LiveBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md) \| `null` \| `undefined` ### b [`LiveBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md) \| `null` \| `undefined` ## Returns `boolean` --- # isSecureApiBase Source: https://docs.sparkletree.io/developers/api/core/functions/issecureapibase/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/issecureapibase.md > **isSecureApiBase**(`apiBase`): `boolean` Defined in: safeUrl.ts:84 Is this apiBase allowed to carry SDK traffic? Production traffic is `https:` only — an `http:` apiBase sends campaign configuration and context over a channel any middlebox can rewrite, which is S-4 with extra steps. The one exception is loopback (`http://localhost`, `http://127.0.0.1`, any port), because local development against a dev edge is a real and legitimate setup. ## Parameters ### apiBase `string` ## Returns `boolean` --- # isValidTimeZone Source: https://docs.sparkletree.io/developers/api/core/functions/isvalidtimezone/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/isvalidtimezone.md > **isValidTimeZone**(`timeZone`): `boolean` Defined in: visitorContext.ts:46 True for an IANA time zone name this runtime knows, such as `Europe/Stockholm`. ## Parameters ### timeZone `string` ## Returns `boolean` --- # isVisitorChange Source: https://docs.sparkletree.io/developers/api/core/functions/isvisitorchange/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/isvisitorchange.md > **isVisitorChange**(`seen`): `boolean` Defined in: slots.ts:117 Internal: has the visitor announced a change since generation `seen`, recently enough that the change being rendered now is the one they caused? ## Parameters ### seen `number` ## Returns `boolean` --- # lengthBudgets Source: https://docs.sparkletree.io/developers/api/core/functions/lengthbudgets/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/lengthbudgets.md > **lengthBudgets**(`fallback`, `fields`): `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `number`\>\> Defined in: slots.ts:44 The length budget per field: the length of each field's fallback, for the fields named in `fields` whose fallback is not empty. A field without a fallback has no slot and no budget. ## Parameters ### fallback `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `string` \| `undefined`\>\> \| `null` \| `undefined` ### fields readonly [`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md)[] ## Returns `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `number`\>\> --- # markVisitorChange Source: https://docs.sparkletree.io/developers/api/core/functions/markvisitorchange/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/markvisitorchange.md > **markVisitorChange**(): `void` Defined in: slots.ts:103 Announce that the visitor caused the next change to what islands and fragments show — call it in the interaction handler (a click, a submit, a choice) before the state update that changes their campaign, context or declaration: ```tsx onClick={() => { markVisitorChange(); setAudience("teams"); }} ``` Visible copy then changes once, with one cross-fade. Without it, a change keeps the visible copy until the slot is off screen or the next page view. ## Returns `void` --- # mountAudio Source: https://docs.sparkletree.io/developers/api/core/functions/mountaudio/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/mountaudio.md > **mountAudio**(`block`, `host`): [`AudioHandle`](https://docs.sparkletree.io/developers/api/core/interfaces/audiohandle.md) \| `null` Defined in: audio.ts:523 Mount a player for `block` inside `host`. Destroys any existing player first — the single-player invariant. A page cycling variants would otherwise stack tracks on top of each other, and the viewer has no way to stop one they can no longer see. ## Parameters ### block [`AudioBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/audioblock.md) ### host `HTMLElement` ## Returns [`AudioHandle`](https://docs.sparkletree.io/developers/api/core/interfaces/audiohandle.md) \| `null` --- # negotiatedProtocol Source: https://docs.sparkletree.io/developers/api/core/functions/negotiatedprotocol/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/negotiatedprotocol.md > **negotiatedProtocol**(`response`): `number` Defined in: protocol.ts:162 Read the negotiated version off a response. An absent header means an older deployment that predates negotiation, which by contract is protocol 1 — not an error, and specifically not a reason to refuse the stream. Treating silence as failure here would break every customer whose traffic happens to land on an edge revision mid-rollout. ## Parameters ### response #### headers `Headers` ## Returns `number` --- # normalizeDims Source: https://docs.sparkletree.io/developers/api/core/functions/normalizedims/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/normalizedims.md > **normalizeDims**(`raw`): [`NormalizeResult`](https://docs.sparkletree.io/developers/api/core/interfaces/normalizeresult.md) Defined in: context.ts:159 Normalizes a raw dim map into canonical dims: unknown keys dropped, enum values validated, tokens pattern-checked, custom dims capped at MAX_CUSTOM_DIMS (bytewise-first wins, deterministically), notes scrubbed. ## Parameters ### raw `Record`\<`string`, `unknown`\> ## Returns [`NormalizeResult`](https://docs.sparkletree.io/developers/api/core/interfaces/normalizeresult.md) --- # normalizeFieldSpecs Source: https://docs.sparkletree.io/developers/api/core/functions/normalizefieldspecs/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/normalizefieldspecs.md > **normalizeFieldSpecs**(`fields`): [`NormalizedFragmentField`](https://docs.sparkletree.io/developers/api/core/interfaces/normalizedfragmentfield.md)[] Defined in: fragments.ts:425 The normalized mint schema of a declaration. Fact and slot fields are left out: they are never generated, so they never enter the schema hash. ## Parameters ### fields `Record`\<`string`, [`FragmentFieldSpec`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentfieldspec.md)\> ## Returns [`NormalizedFragmentField`](https://docs.sparkletree.io/developers/api/core/interfaces/normalizedfragmentfield.md)[] --- # normalizeNotes Source: https://docs.sparkletree.io/developers/api/core/functions/normalizenotes/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/normalizenotes.md > **normalizeNotes**(`raw`): `string` \| `undefined` Defined in: context.ts:130 Normalizes the free-text `notes` dim. Returns undefined when the field is empty after scrubbing or matches a rejected shape (emails, phone numbers, long token-like runs) — the field is dropped, never partially kept. ## Parameters ### raw `string` ## Returns `string` \| `undefined` --- # observeVisibility Source: https://docs.sparkletree.io/developers/api/core/functions/observevisibility/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/observevisibility.md > **observeVisibility**(`element`, `onVisible`, `options?`): () => `void` Defined in: analytics.ts:355 Fire `onVisible` once, when the element has been meaningfully on screen. Where IntersectionObserver does not exist, this fires immediately rather than never: under-counting every impression in older browsers would be a silent, systematic bias in the numbers a customer is billed and optimised against. Over-counting there is the lesser wrong, and it is at least visible. ## Parameters ### element `Element` ### onVisible () => `void` ### options? [`VisibilityOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/visibilityoptions.md) = `{}` ## Returns () => `void` --- # openStream Source: https://docs.sparkletree.io/developers/api/core/functions/openstream/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/openstream.md > **openStream**(`options`): [`StreamHandle`](https://docs.sparkletree.io/developers/api/core/interfaces/streamhandle.md) Defined in: client.ts:223 Open an island stream and choreograph it. Returns immediately with a handle; `finished` resolves with the terminal state. It never rejects — a broken stream leaves whatever was painted on screen and reports `phase: "failed"`, because throwing from inside a customer's render tree is a worse outcome than a creative that stopped adapting. ## Parameters ### options [`StreamOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/streamoptions.md) ## Returns [`StreamHandle`](https://docs.sparkletree.io/developers/api/core/interfaces/streamhandle.md) --- # parseLiveReady Source: https://docs.sparkletree.io/developers/api/core/functions/parseliveready/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/parseliveready.md > **parseLiveReady**(`payload`): [`LiveBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md) \| `null` Defined in: live.ts:101 Read a `live-ready` payload into a `LiveBlock`, or `null` when it does not describe a player the SDK will show. The payload is untrusted. Its `html` is never inserted anywhere: only the iframe's `src` (checked by `safeLiveSrc`) and `title` (as plain text) are taken from it. ## Parameters ### payload `unknown` ## Returns [`LiveBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md) \| `null` --- # plainText Source: https://docs.sparkletree.io/developers/api/core/functions/plaintext/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/plaintext.md > **plainText**(`value`): `string` Defined in: text.ts:12 Wire text arrives from catalog systems that store rich text — Shopify product descriptions are `body_html`, and campaign tooling pastes markdown. The SDK never renders wire content as HTML (that would hand every catalog entry a script slot), so display text is normalized to plain text instead: tags stripped, block boundaries kept as spaces, the handful of entities that actually occur decoded. ## Parameters ### value `string` ## Returns `string` --- # readableTextColor Source: https://docs.sparkletree.io/developers/api/core/functions/readabletextcolor/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/readabletextcolor.md > **readableTextColor**(`color`): `string` Defined in: theme.ts:84 The ink that reads on a given hex color — the SDK twin of the shell's ReadableTextColor (mosaic-edge-serve/internal/theme/theme.go) and the TS resolver's readableTextColor (mosaic/services/themeService.ts). Same perceived-luminance rule in all three places; change them together. Non-hex input returns light ink, matching both twins. ## Parameters ### color `string` ## Returns `string` --- # readSseStream Source: https://docs.sparkletree.io/developers/api/core/functions/readssestream/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/readssestream.md > **readSseStream**(`response`, `options`): `Promise`\<`void`\> Defined in: sse.ts:118 Drain a fetch Response body as SSE. Returns when the server closes the stream. Aborting via `signal` resolves rather than throwing: a component unmounting mid-stream is the normal way these end, not an error worth surfacing in a customer's console. ## Parameters ### response `Response` ### options `ReadSseOptions` ## Returns `Promise`\<`void`\> --- # recordPageView Source: https://docs.sparkletree.io/developers/api/core/functions/recordpageview/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/recordpageview.md > **recordPageView**(`context`): `boolean` Defined in: analytics.ts:275 Record the page view: once per page load per organization and campaign, whatever number of islands or calls the page makes. It is how a site visit is counted at all: a visit where no island was seen and nothing was clicked still sends this one event. A page view is never an impression and never a site action. Client-side route changes in a single-page app are not new page views. Islands call it when they mount; a page without islands can call it itself. No-op outside a browser, without a campaign id, or when the viewer has Global Privacy Control or Do Not Track on. Returns true only for the call that sent it. ## Parameters ### context [`AnalyticsContext`](https://docs.sparkletree.io/developers/api/core/interfaces/analyticscontext.md) ## Returns `boolean` --- # resolvePublishableConfig Source: https://docs.sparkletree.io/developers/api/core/functions/resolvepublishableconfig/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/resolvepublishableconfig.md > **resolvePublishableConfig**(`options`, `caller?`): [`ResolvedPublishableConfig`](https://docs.sparkletree.io/developers/api/core/interfaces/resolvedpublishableconfig.md) Defined in: fragments.ts:1446 The ONE resolution of `{ publishableKey?, organizationId?, apiBase? }`: explicit props win, the key fills the gaps, and missing configuration or an insecure apiBase throws at setup time (an apiBase that is neither https nor loopback http would send org configuration over a channel any middlebox can rewrite). `createClient` and the React provider both call this — as two hand-rolled copies they had already diverged once, with the provider silently accepting a plain-http apiBase that createClient refused. ## Parameters ### options #### apiBase? `string` #### organizationId? `string` #### publishableKey? `string` ### caller? `string` = `"createClient"` ## Returns [`ResolvedPublishableConfig`](https://docs.sparkletree.io/developers/api/core/interfaces/resolvedpublishableconfig.md) --- # safeActionUrl Source: https://docs.sparkletree.io/developers/api/core/functions/safeactionurl/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/safeactionurl.md > **safeActionUrl**(`url`): `string` \| `undefined` Defined in: safeUrl.ts:48 Vet a server-supplied action URL before it reaches an ``. Allowed through unchanged: - absolute `https:`, `http:`, `mailto:`, `tel:` URLs; - relative references — `/…`, `./…`, `#…`, `?…` — which resolve against the customer's own origin; plus protocol-relative `//…`, which keeps the page's scheme and is no worse than the absolute `https:` URLs we already allow (both can point at any host). Anything else returns `undefined`: `javascript:`/`data:`/`vbscript:` outright, but also bare strings with no scheme and no relative prefix — we cannot prove where they point, and a CTA with no destination degrades to a plain button, which is the honest outcome. The input is trimmed first because browsers strip leading ASCII whitespace from `href` before parsing — without that, `" javascript:…"` would sneak a scheme past a prefix check that the browser would then honour. ## Parameters ### url `string` \| `null` \| `undefined` ## Returns `string` \| `undefined` --- # safeLiveSrc Source: https://docs.sparkletree.io/developers/api/core/functions/safelivesrc/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/safelivesrc.md > **safeLiveSrc**(`src`): `string` \| `null` Defined in: live.ts:47 Check a live player address and rebuild it from its checked parts. Accepts only `https://.cloudflarestream.com//iframe`, with no credentials and no port. Of the query, only the player switches `autoplay`, `muted` and `controls` with the value `true` or `false` are kept; anything else is left out. Returns `null` for every other input. ## Parameters ### src `string` \| `null` \| `undefined` ## Returns `string` \| `null` --- # sessionId Source: https://docs.sparkletree.io/developers/api/core/functions/sessionid/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/sessionid.md > **sessionId**(): `string` Defined in: analytics.ts:68 ## Returns `string` --- # setLengthParams Source: https://docs.sparkletree.io/developers/api/core/functions/setlengthparams/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/setlengthparams.md > **setLengthParams**(`params`, `budgets`): `void` Defined in: slots.ts:57 Add `len.` parameters for `budgets`, in field order. ## Parameters ### params `URLSearchParams` ### budgets `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `number`\>\> \| `null` \| `undefined` ## Returns `void` --- # setViewerPrefersStandard Source: https://docs.sparkletree.io/developers/api/core/functions/setviewerprefersstandard/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/setviewerprefersstandard.md > **setViewerPrefersStandard**(`value`, `storage?`): `void` Defined in: trust.ts:90 Persist the viewer's preference. Silent on failure, for the same reason. ## Parameters ### value `boolean` ### storage? `Storage` ## Returns `void` --- # splitFieldSpecs Source: https://docs.sparkletree.io/developers/api/core/functions/splitfieldspecs/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/splitfieldspecs.md > **splitFieldSpecs**(`fields`): `object` Defined in: fragments.ts:402 Split a declaration into its generated fields (the mint path), its fact fields and its slot fields. Array fallbacks are expanded first, so the generated part is what `normalizeFieldSpecs` hashes. Only the generated part ever enters the schema hash or the mint request. ## Parameters ### fields `Record`\<`string`, [`FragmentFieldSpec`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentfieldspec.md)\> ## Returns `object` ### facts > **facts**: `Record`\<`string`, [`FactFieldSpec`](https://docs.sparkletree.io/developers/api/core/interfaces/factfieldspec.md)\> ### generated > **generated**: `Record`\<`string`, `string` \| [`GeneratedFieldSpec`](https://docs.sparkletree.io/developers/api/core/interfaces/generatedfieldspec.md)\> ### slots > **slots**: `Record`\<`string`, [`SlotFieldSpec`](https://docs.sparkletree.io/developers/api/core/interfaces/slotfieldspec.md)\> --- # strongestFragmentSource Source: https://docs.sparkletree.io/developers/api/core/functions/strongestfragmentsource/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/strongestfragmentsource.md > **strongestFragmentSource**(`fields`): `"generated"` \| `"cached"` \| `"static"` Defined in: fragments.ts:515 Strongest provenance across a set of field states (static < cached < generated). A stated fact is static, so it never makes a group adapted. ## Parameters ### fields `Iterable`\<\{ `source`: `"generated"` \| `"cached"` \| `"static"`; \}\> ## Returns `"generated"` \| `"cached"` \| `"static"` --- # themeStyle Source: https://docs.sparkletree.io/developers/api/core/functions/themestyle/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/themestyle.md > **themeStyle**(`theme`): `Record`\<`string`, `string`\> Defined in: theme.ts:36 Theme tokens as a style object, ready for React's `style` prop or `Object.assign(el.style, …)`. Values are passed through as authored. Sanitising here would mean parsing CSS colour syntax in the client, which is both a losing game and the wrong layer — the server owns what a valid resolved colour is. ## Parameters ### theme [`ResolvedTheme`](https://docs.sparkletree.io/developers/api/core/interfaces/resolvedtheme.md) \| `null` ## Returns `Record`\<`string`, `string`\> --- # timeOfDayForHour Source: https://docs.sparkletree.io/developers/api/core/functions/timeofdayforhour/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/timeofdayforhour.md > **timeOfDayForHour**(`hour`): [`TimeOfDay`](https://docs.sparkletree.io/developers/api/core/type-aliases/timeofday.md) Defined in: visitorContext.ts:31 Bucket an hour of the day (0–23, in the visitor's time zone): before 6 is night, before 12 morning, before 18 afternoon, the rest evening. ## Parameters ### hour `number` ## Returns [`TimeOfDay`](https://docs.sparkletree.io/developers/api/core/type-aliases/timeofday.md) --- # tokenName Source: https://docs.sparkletree.io/developers/api/core/functions/tokenname/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/tokenname.md > **tokenName**(`key`): `string` Defined in: theme.ts:24 `primaryColor` → `--st-primary-color`. ## Parameters ### key `string` ## Returns `string` --- # tokenSource Source: https://docs.sparkletree.io/developers/api/core/functions/tokensource/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/tokensource.md > **tokenSource**(`theme`, `key`): `string` \| `null` Defined in: theme.ts:73 Where a token came from — for the Ledger, and for anyone debugging why a brand colour did not win. ## Parameters ### theme [`ResolvedTheme`](https://docs.sparkletree.io/developers/api/core/interfaces/resolvedtheme.md) \| `null` ### key `string` ## Returns `string` \| `null` --- # track Source: https://docs.sparkletree.io/developers/api/core/functions/track/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/track.md > **track**(`context`, `eventType`, `eventData?`): `Promise`\<`void`\> Defined in: analytics.ts:217 POST an event. Fire-and-forget: telemetry never blocks or breaks a render. Nothing is sent when the viewer has Global Privacy Control or Do Not Track on (`consentAllowed`). Keys the server reads from `eventData`: `variantId`, `surfaceId`, `productId`, `generatedContentId`, `context` (any JSON object), and for a `conversion`, `amount` (a number), `currency` (an ISO 4217 code) and `checkoutToken`. The server stores `currency` and `checkoutToken` only when the conversion also has an `amount`. `variantId` defaults to the value in the first argument, and `surfaceId` does too when that value is a UUID. The SDK sets `sessionId`. `source` is kept only for values reserved for SparkleTree's Shopify extensions, and `customEventName` only for the SDK's own page view (`recordPageView`). Other top-level keys are not stored; put your own detail under `eventData.context`. ## Parameters ### context [`AnalyticsContext`](https://docs.sparkletree.io/developers/api/core/interfaces/analyticscontext.md) ### eventType [`EventType`](https://docs.sparkletree.io/developers/api/core/type-aliases/eventtype.md) ### eventData? `Record`\<`string`, `unknown`\> = `{}` ## Returns `Promise`\<`void`\> --- # verifyFacts Source: https://docs.sparkletree.io/developers/api/core/functions/verifyfacts/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/verifyfacts.md > **verifyFacts**(`facts`, `options?`): `Promise`\<[`VerifyFactsResult`](https://docs.sparkletree.io/developers/api/core/interfaces/verifyfactsresult.md)\> Defined in: facts.ts:533 Check a facts document's Ed25519 signature with WebCrypto. Works in browsers and in Node where `crypto.subtle` supports Ed25519. Never rejects: where Ed25519 is not available it resolves `{ valid: false, reason: "unsupported" }`. ## Parameters ### facts [`FactsPayload`](https://docs.sparkletree.io/developers/api/core/interfaces/factspayload.md) \| `null` \| `undefined` ### options? [`VerifyFactsOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/verifyfactsoptions.md) = `{}` ## Returns `Promise`\<[`VerifyFactsResult`](https://docs.sparkletree.io/developers/api/core/interfaces/verifyfactsresult.md)\> --- # viewerPrefersStandard Source: https://docs.sparkletree.io/developers/api/core/functions/viewerprefersstandard/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/viewerprefersstandard.md > **viewerPrefersStandard**(`storage?`): `boolean` Defined in: trust.ts:81 Read the viewer's preference. Any failure — no storage, disabled storage, SSR, a privacy mode that throws on access — means "no stated preference", which is the marked default. A storage error must never be a route to an unmarked creative. ## Parameters ### storage? `Storage` ## Returns `boolean` --- # visitorChangeGeneration Source: https://docs.sparkletree.io/developers/api/core/functions/visitorchangegeneration/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/visitorchangegeneration.md > **visitorChangeGeneration**(): `number` Defined in: slots.ts:109 Internal: the current visitor-change generation, to remember as seen. ## Returns `number` --- # warnDev Source: https://docs.sparkletree.io/developers/api/core/functions/warndev/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/warndev.md > **warnDev**(`key`, `message`): `void` Defined in: devwarn.ts:58 ## Parameters ### key `string` ### message `string` ## Returns `void` --- # watchPageVisibility Source: https://docs.sparkletree.io/developers/api/core/functions/watchpagevisibility/ Markdown: https://docs.sparkletree.io/developers/api/core/functions/watchpagevisibility.md > **watchPageVisibility**(`target`): () => `void` Defined in: pageVisibility.ts:25 Tell `target` whether the page is visible, now and on every change: `visibilitychange`, `pagehide`/`pageshow` (the back/forward cache) and `freeze`/`resume` (a page the browser froze). When the page is shown again it also calls `checkDeadline()`, so a hold that ran out while timers were throttled or frozen is applied. Outside a browser it does nothing. Returns a cleanup that removes every listener. `openStream` calls it for a choreographer it creates; `useIsland` and the custom elements call it for their own. Call it yourself when you create a `CopyChoreographer` and pass it to `openStream({ choreographer })`. ## Parameters ### target [`VisibilityTarget`](https://docs.sparkletree.io/developers/api/core/interfaces/visibilitytarget.md) ## Returns () => `void` --- # AnalyticsContext Source: https://docs.sparkletree.io/developers/api/core/interfaces/analyticscontext/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/analyticscontext.md Defined in: analytics.ts:26 ## Properties ### apiBase > **apiBase**: `string` Defined in: analytics.ts:27 *** ### campaignId > **campaignId**: `string` Defined in: analytics.ts:29 *** ### fetchImpl? > `optional` **fetchImpl?**: (`input`, `init?`) => `Promise`\<`Response`\> Defined in: analytics.ts:38 The same transport seam every other request honors. Without it, beacons bypass an integrator's proxied or instrumented fetch (CSP connect-src, test transports) and the loss is invisible — content renders, counts read zero. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) #### Parameters ##### input `URL` \| `RequestInfo` ##### init? `RequestInit` #### Returns `Promise`\<`Response`\> *** ### organizationId > **organizationId**: `string` Defined in: analytics.ts:28 *** ### surfaceId? > `optional` **surfaceId?**: `string` Defined in: analytics.ts:31 *** ### variantId? > `optional` **variantId?**: `string` Defined in: analytics.ts:30 --- # AskLink Source: https://docs.sparkletree.io/developers/api/core/interfaces/asklink/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/asklink.md Defined in: ask.ts:35 ## Properties ### label > **label**: `string` Defined in: ask.ts:36 *** ### url > **url**: `string` Defined in: ask.ts:37 --- # AskOptions Source: https://docs.sparkletree.io/developers/api/core/interfaces/askoptions/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/askoptions.md Defined in: ask.ts:40 ## Properties ### apiBase > **apiBase**: `string` Defined in: ask.ts:41 *** ### apiBaseProvenance? > `optional` **apiBaseProvenance?**: `"explicit"` \| `"key"` Defined in: ask.ts:64 Where `apiBase` came from; see `FetchFragmentsOptions.apiBaseProvenance`. Defaults to "explicit". *** ### campaignId? > `optional` **campaignId?**: `string` Defined in: ask.ts:44 Pin the answer to one public campaign. *** ### fetchImpl? > `optional` **fetchImpl?**: (`input`, `init?`) => `Promise`\<`Response`\> Defined in: ask.ts:66 Test seam; defaults to the platform fetch. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) #### Parameters ##### input `URL` \| `RequestInfo` ##### init? `RequestInit` #### Returns `Promise`\<`Response`\> *** ### idleTimeoutMs? > `optional` **idleTimeoutMs?**: `number` Defined in: ask.ts:62 How long the call waits with no bytes from the edge, in milliseconds. Default 30000. Each piece that arrives starts it again. `0` or `Infinity` turns it off. *** ### onChunk? > `optional` **onChunk?**: (`chunk`, `answer`) => `void` Defined in: ask.ts:56 Called with each piece of the answer as it is written. Giving it makes the request a stream. `answer` is the text received so far. #### Parameters ##### chunk `string` ##### answer `string` #### Returns `void` *** ### organizationId? > `optional` **organizationId?**: `string` Defined in: ask.ts:46 Without a campaign, the brand's whole live roster answers. Needs a live key or a brand host. *** ### publishableKey? > `optional` **publishableKey?**: `string` Defined in: ask.ts:48 `st_pk_live_…`. Sent as `Authorization: Bearer `. *** ### question > **question**: `string` Defined in: ask.ts:42 *** ### session? > `optional` **session?**: `string` Defined in: ask.ts:50 The `session` from an earlier answer, to continue that conversation. *** ### signal? > `optional` **signal?**: `AbortSignal` Defined in: ask.ts:51 --- # AskResult Source: https://docs.sparkletree.io/developers/api/core/interfaces/askresult/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/askresult.md Defined in: ask.ts:95 ## Properties ### answer > **answer**: `string` Defined in: ask.ts:98 The answer, or the text received before the call stopped. *** ### campaign? > `optional` **campaign?**: `object` Defined in: ask.ts:105 The campaign the answer is about, when there is one. #### id > **id**: `string` #### name > **name**: `string` #### url > **url**: `string` *** ### error? > `optional` **error?**: `string` Defined in: ask.ts:119 The edge's error message, when it sent one. *** ### followUps > **followUps**: `string`[] Defined in: ask.ts:101 Suggested next questions. Empty when there are none. *** ### homeCampaignId? > `optional` **homeCampaignId?**: `string` Defined in: ask.ts:111 The campaign the conversation is grounded in, which stays the same when an answer recommends another campaign. Pin this, not `campaign.id`, to continue the thread. *** ### links > **links**: [`AskLink`](https://docs.sparkletree.io/developers/api/core/interfaces/asklink.md)[] Defined in: ask.ts:99 *** ### ok > **ok**: `boolean` Defined in: ask.ts:96 *** ### reason? > `optional` **reason?**: [`AskFailureReason`](https://docs.sparkletree.io/developers/api/core/type-aliases/askfailurereason.md) Defined in: ask.ts:115 Set when `ok` is false. *** ### session > **session**: `string` Defined in: ask.ts:103 Send this back as `session` to continue the conversation. Empty when there is none. *** ### status? > `optional` **status?**: `number` Defined in: ask.ts:117 The HTTP status, when the edge answered. *** ### truncated? > `optional` **truncated?**: `boolean` Defined in: ask.ts:113 The answer was cut off upstream. It is usable but may be incomplete. --- # AudioBlock Source: https://docs.sparkletree.io/developers/api/core/interfaces/audioblock/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/audioblock.md Defined in: audio.ts:29 ## Properties ### artist? > `optional` **artist?**: `string` Defined in: audio.ts:35 *** ### artwork? > `optional` **artwork?**: `object` Defined in: audio.ts:38 #### url > **url**: `string` *** ### audioUrl? > `optional` **audioUrl?**: `string` Defined in: audio.ts:32 Direct media URL (suno) or provider URI (spotify). *** ### durationMs? > `optional` **durationMs?**: `number` Defined in: audio.ts:36 *** ### loop? > `optional` **loop?**: `boolean` Defined in: audio.ts:37 *** ### provider > **provider**: [`AudioProvider`](https://docs.sparkletree.io/developers/api/core/type-aliases/audioprovider.md) Defined in: audio.ts:30 *** ### title? > `optional` **title?**: `string` Defined in: audio.ts:34 *** ### trackRef? > `optional` **trackRef?**: `string` Defined in: audio.ts:33 --- # AudioCapabilities Source: https://docs.sparkletree.io/developers/api/core/interfaces/audiocapabilities/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/audiocapabilities.md Defined in: audio.ts:56 ## Properties ### anonymousPlayback > **anonymousPlayback**: `boolean` Defined in: audio.ts:63 Does playback work without the viewer holding a provider account? *** ### customChrome > **customChrome**: `boolean` Defined in: audio.ts:61 May the consumer render its own transport UI? False for providers whose embed is a fixed iframe we are not permitted to hide or reskin. --- # AudioHandle Source: https://docs.sparkletree.io/developers/api/core/interfaces/audiohandle/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/audiohandle.md Defined in: audio.ts:66 ## Properties ### caps > **caps**: [`AudioCapabilities`](https://docs.sparkletree.io/developers/api/core/interfaces/audiocapabilities.md) Defined in: audio.ts:68 *** ### provider > **provider**: [`AudioProvider`](https://docs.sparkletree.io/developers/api/core/type-aliases/audioprovider.md) Defined in: audio.ts:67 ## Methods ### destroy() > **destroy**(): `void` Defined in: audio.ts:76 #### Returns `void` *** ### getState() > **getState**(): [`AudioState`](https://docs.sparkletree.io/developers/api/core/interfaces/audiostate.md) Defined in: audio.ts:69 #### Returns [`AudioState`](https://docs.sparkletree.io/developers/api/core/interfaces/audiostate.md) *** ### on() > **on**(`event`, `listener`): () => `void` Defined in: audio.ts:75 #### Parameters ##### event [`AudioEvent`](https://docs.sparkletree.io/developers/api/core/type-aliases/audioevent.md) ##### listener (`state`) => `void` #### Returns () => `void` *** ### pause() > **pause**(): `void` Defined in: audio.ts:71 #### Returns `void` *** ### play() > **play**(): `void` Defined in: audio.ts:70 #### Returns `void` *** ### seek() > **seek**(`positionMs`): `void` Defined in: audio.ts:74 No-op on providers that do not expose seeking. #### Parameters ##### positionMs `number` #### Returns `void` *** ### toggle() > **toggle**(): `void` Defined in: audio.ts:72 #### Returns `void` --- # AudioState Source: https://docs.sparkletree.io/developers/api/core/interfaces/audiostate/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/audiostate.md Defined in: audio.ts:43 ## Properties ### durationMs > **durationMs**: `number` Defined in: audio.ts:47 *** ### ended > **ended**: `boolean` Defined in: audio.ts:52 *** ### errored > **errored**: `boolean` Defined in: audio.ts:53 *** ### listenedMs > **listenedMs**: `number` Defined in: audio.ts:51 Wall-clock time this track was actually audible. Drives listen analytics. *** ### percent > **percent**: `number` Defined in: audio.ts:49 0..1. Zero when the duration is not yet known — never NaN. *** ### playing > **playing**: `boolean` Defined in: audio.ts:45 *** ### positionMs > **positionMs**: `number` Defined in: audio.ts:46 *** ### provider > **provider**: [`AudioProvider`](https://docs.sparkletree.io/developers/api/core/type-aliases/audioprovider.md) Defined in: audio.ts:44 --- # CheckSetupOptions Source: https://docs.sparkletree.io/developers/api/core/interfaces/checksetupoptions/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/checksetupoptions.md Defined in: setup.ts:64 ## Properties ### apiBase > **apiBase**: `string` Defined in: setup.ts:65 *** ### apiBaseProvenance? > `optional` **apiBaseProvenance?**: `"explicit"` \| `"key"` Defined in: setup.ts:76 Where `apiBase` came from; see `FetchFragmentsOptions.apiBaseProvenance`. Defaults to "explicit". *** ### fetchImpl? > `optional` **fetchImpl?**: (`input`, `init?`) => `Promise`\<`Response`\> Defined in: setup.ts:85 Test seam; defaults to the platform fetch. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) #### Parameters ##### input `URL` \| `RequestInfo` ##### init? `RequestInit` #### Returns `Promise`\<`Response`\> *** ### organizationId? > `optional` **organizationId?**: `string` Defined in: setup.ts:69 When given, it must match the key's organization. *** ### origin? > `optional` **origin?**: `string` Defined in: setup.ts:74 The origin to check, for example `https://shop.example`. Without it the edge reads the request's `Origin` header (a browser sends its own page's). *** ### publishableKey? > `optional` **publishableKey?**: `string` Defined in: setup.ts:67 `st_pk_…`. Sent as `Authorization: Bearer `. *** ### signal? > `optional` **signal?**: `AbortSignal` Defined in: setup.ts:77 *** ### timeoutMs? > `optional` **timeoutMs?**: `number` Defined in: setup.ts:83 How long the check waits for the whole answer, in milliseconds. Default 10000. Past it the request is stopped and the result is not reached, with `reason: "timeout"`. `0` or `Infinity` turns the deadline off. --- # ChoreographerOptions Source: https://docs.sparkletree.io/developers/api/core/interfaces/choreographeroptions/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/choreographeroptions.md Defined in: state.ts:294 ## Extended by - [`StreamOptions`](https://docs.sparkletree.io/developers/api/core/interfaces/streamoptions.md) ## Properties ### clearTimeout? > `optional` **clearTimeout?**: (`handle`) => `void` Defined in: state.ts:406 #### Parameters ##### handle `unknown` #### Returns `void` *** ### fallback? > `optional` **fallback?**: `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `string`\>\> Defined in: state.ts:394 The authored fallback, when `initial` is other copy (for example copy already produced for this view). It is what `keepFallback` lands. Defaults to `initial`. *** ### fallbackDefinesSlots? > `optional` **fallbackDefinesSlots?**: `boolean` Defined in: state.ts:381 When true, the fallback decides which fields exist: a field whose `initial` copy is empty is never shown, and the stream's copy for it is dropped. A slot sized by its fallback has no room for a field the fallback does not have. Ignored when `initial` has no copy at all. *** ### holdElapsedMs? > `optional` **holdElapsedMs?**: `number` Defined in: state.ts:333 How long the slot has ALREADY been holding before this choreographer took over — for example, since a server-rendered reservation first painted. It is spent from the budget and from the absolute maximum, so the wait before hydration and the wait after it are one hold. Defaults to 0. *** ### holdMs? > `optional` **holdMs?**: `number` Defined in: state.ts:326 The hold budget for this view. Defaults to `COPY_HOLD_MS`; restarts once when the stream proves alive. However the restart falls, the hold never lasts longer than twice this in total. *** ### holdStartsInView? > `optional` **holdStartsInView?**: `boolean` Defined in: state.ts:357 When true, the hold budget does not start until `slotInView()` is called. The stream may open (and buffer) earlier; a slot that never comes into view never shows anything changing. When false (the default), the slot is treated as in view from `streamOpened()`. *** ### initial? > `optional` **initial?**: `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `string`\>\> Defined in: state.ts:299 The fallback: what lands if live copy does not arrive in time. Required by doctrine — there is no skeleton mode. *** ### initialIsComplete? > `optional` **initialIsComplete?**: `boolean` Defined in: state.ts:350 With `serverRendered`: the `initial` copy is the WHOLE copy for this view, so the stream writes no field, empty ones included. Use it for copy decided before the slot was shown (for example cached copy a server read for this visitor): a field it left empty stays empty rather than gaining text later. *** ### initialIsOnScreen? > `optional` **initialIsOnScreen?**: `boolean` Defined in: state.ts:309 True when the initial copy is ALREADY VISIBLE when the stream opens: copy at rest from earlier in this view, or a fallback the page revealed before the SDK could hold it. Every non-empty field is then final for this view: no hold, and the stream's copy events for it are dropped. Leave it unset for copy that has not been seen yet — the normal case. The hold then keeps the slot blank until live copy or the fallback lands. *** ### initialLive? > `optional` **initialLive?**: [`LiveBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md) \| `null` Defined in: state.ts:403 The live player this slot is ALREADY showing, from an earlier stream in the same view of the page. It stays in `state.live` until this stream says otherwise: `live-ready` for the same channel keeps it (the same object, so the iframe is left alone), `live-ready` for another channel replaces it, and a stream that finishes without one drops it. A stream that fails keeps it. *** ### initialSource? > `optional` **initialSource?**: `"generated"` \| `"cached"` \| `"static"` Defined in: state.ts:340 Provenance of the `initial` copy when it is finished creative (`serverRendered`), for example copy already generated for this view. Those fields carry it as their `source` and are settled from the start. Defaults to `static`. *** ### initialSources? > `optional` **initialSources?**: `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `"generated"` \| `"cached"` \| `"static"`\>\> Defined in: state.ts:388 Per-field provenance of the `initial` copy when it is finished creative (`serverRendered`). Overrides `initialSource` for the fields it names, for copy that mixes provenance, such as live copy for one field and the fallback for another. *** ### initialVariantId? > `optional` **initialVariantId?**: `string` Defined in: state.ts:342 The variant the `initial` copy belongs to, if known. Seeds `variantId`. *** ### now? > `optional` **now?**: () => `number` Defined in: state.ts:407 #### Returns `number` *** ### releaseOn? > `optional` **releaseOn?**: `"text"` \| `"complete"` Defined in: state.ts:369 When the held canvas is handed to the stream. `"text"` (default): on the first text the stream delivers — live copy types into the blank slot. `"complete"`: only when the stream finishes (`done`), so the whole new copy lands at once. For a slot whose canvas is showing something else in the meantime (a campaign or context change); the hold budget still applies. *** ### serverRendered? > `optional` **serverRendered?**: `boolean` Defined in: state.ts:320 True when the initial copy is FINISHED CAMPAIGN CREATIVE rendered by the platform — not a developer's fallback. It is the copy for this view: nothing holds, and the stream's copy events for those fields are dropped (theme, media and the action still apply). Fields left empty may still be written by the stream. Do not set it for a `fallback`: a fallback is what lands only when live copy does not. *** ### setTimeout? > `optional` **setTimeout?**: (`fn`, `ms`) => `unknown` Defined in: state.ts:405 Injectable for tests; defaults to the platform timers and clock. #### Parameters ##### fn () => `void` ##### ms `number` #### Returns `unknown` *** ### unfinishedCopy? > `optional` **unfinishedCopy?**: [`UnfinishedCopyPolicy`](https://docs.sparkletree.io/developers/api/core/type-aliases/unfinishedcopypolicy.md) Defined in: state.ts:374 What happens to a field the stream started and did not finish: when the stream ends, or when the field gets no new text for `TYPING_STALL_MS`. Defaults to `fallbackForUnfinished` (the fallback replaces the half line, once). `keepUnlessClearlyError` keeps it. --- # ChromeDecision Source: https://docs.sparkletree.io/developers/api/core/interfaces/chromedecision/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/chromedecision.md Defined in: trust.ts:23 ## Properties ### marked > **marked**: `boolean` Defined in: trust.ts:26 Does this copy count as adapted for this viewer? (Feeds the impression beacon, and any label your own UI shows.) *** ### reason > **reason**: `"generated"` \| `"cached"` \| `"static"` \| `"viewer-opted-out"` Defined in: trust.ts:31 Why, in one machine-readable word. Reported on the impression, so the chrome state of real traffic is measurable rather than assumed. --- # ContentImage Source: https://docs.sparkletree.io/developers/api/core/interfaces/contentimage/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/contentimage.md Defined in: client.ts:47 The image the server sends in `ContentSnapshot.content.image`. It is an object, not a URL string: for an `` src read `.url`, and for a video poster read `.heroFrame?.url`. ## Properties ### alt? > `optional` **alt?**: `string` Defined in: client.ts:49 *** ### focal? > `optional` **focal?**: `unknown` Defined in: client.ts:54 Opaque; shape owned by the server. *** ### heroFrame? > `optional` **heroFrame?**: `object` Defined in: client.ts:50 #### url? > `optional` **url?**: `string` *** ### sequence? > `optional` **sequence?**: `unknown` Defined in: client.ts:52 Opaque; shape owned by the server. *** ### url? > `optional` **url?**: `string` Defined in: client.ts:48 --- # ContentSnapshot Source: https://docs.sparkletree.io/developers/api/core/interfaces/contentsnapshot/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/contentsnapshot.md Defined in: client.ts:57 ## Properties ### campaignId > **campaignId**: `string` Defined in: client.ts:58 *** ### content > **content**: `object` Defined in: client.ts:60 #### body? > `optional` **body?**: `string` #### cta? > `optional` **cta?**: `string` \| \{ `text?`: `string`; \} #### experienceManifest? > `optional` **experienceManifest?**: `unknown` #### headline? > `optional` **headline?**: `string` #### image? > `optional` **image?**: [`ContentImage`](https://docs.sparkletree.io/developers/api/core/interfaces/contentimage.md) \| `null` An object. Use `image.url` as an `` src, not `image` itself. `null` when the variant has no image: the edge server sends `"image": null`, and the app server leaves the key out. *** ### meta? > `optional` **meta?**: `Record`\<`string`, `unknown`\> Defined in: client.ts:74 *** ### products? > `optional` **products?**: `unknown`[] Defined in: client.ts:73 *** ### slots? > `optional` **slots?**: `Record`\<`string`, `string`\> Defined in: client.ts:80 The chosen variant's custom slots, by name: string values only, each at most 2000 characters. Absent when the variant has none. Read them through a `{ kind: "slot" }` declaration, which checks each value. *** ### theme? > `optional` **theme?**: `object` Defined in: client.ts:72 #### colors > **colors**: `Record`\<`string`, `string`\> #### sources > **sources**: `Record`\<`string`, `string`\> *** ### variantId > **variantId**: `string` Defined in: client.ts:59 --- # CreateClientOptions Source: https://docs.sparkletree.io/developers/api/core/interfaces/createclientoptions/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/createclientoptions.md Defined in: fragments.ts:1384 ## Properties ### apiBase? > `optional` **apiBase?**: `string` Defined in: fragments.ts:1391 *** ### fetchImpl? > `optional` **fetchImpl?**: (`input`, `init?`) => `Promise`\<`Response`\> Defined in: fragments.ts:1394 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) #### Parameters ##### input `URL` \| `RequestInfo` ##### init? `RequestInit` #### Returns `Promise`\<`Response`\> *** ### mintToken? > `optional` **mintToken?**: [`MintTokenSource`](https://docs.sparkletree.io/developers/api/core/type-aliases/minttokensource.md) Defined in: fragments.ts:1393 Signed mint token (or a function returning one), sent on the mint POST. *** ### organizationId? > `optional` **organizationId?**: `string` Defined in: fragments.ts:1390 *** ### publishableKey? > `optional` **publishableKey?**: `string` Defined in: fragments.ts:1389 `st_pk_…` from the dashboard: a signed credential the server requires on every stream and content request (see publishableKey.ts). Explicit organizationId/apiBase win over its payload; the key is still sent, including on the fragment mint POST (see FetchFragmentsOptions). --- # CreativeState Source: https://docs.sparkletree.io/developers/api/core/interfaces/creativestate/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/creativestate.md Defined in: state.ts:130 ## Properties ### backgroundImage > **backgroundImage**: `string` \| `null` Defined in: state.ts:136 *** ### contentSource > **contentSource**: `"generated"` \| `"cached"` \| `"static"` Defined in: state.ts:171 Provenance of the copy on the canvas, stream-wide: the strongest any field declared while live, the server's terminal word once settled, and `static` whenever no adapted copy actually reached the canvas. If you label AI-generated copy, decide it per field (`field.source`), not from this. *** ### ctaAction > **ctaAction**: `string` \| `null` Defined in: state.ts:161 *** ### ctaStyle > **ctaStyle**: `unknown` Defined in: state.ts:160 *** ### degraded > **degraded**: `string` \| `null` Defined in: state.ts:173 Set when the server served a deterministic winner instead. *** ### error > **error**: `string` \| `null` Defined in: state.ts:177 Human-readable failure, if any. Never blanks painted copy. *** ### experienceManifest > **experienceManifest**: `unknown` Defined in: state.ts:135 *** ### fields > **fields**: `Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md)\> Defined in: state.ts:132 *** ### held? > `optional` **held?**: `Partial`\<`Record`\<[`CopyField`](https://docs.sparkletree.io/developers/api/core/type-aliases/copyfield.md), `string`\>\> \| `null` Defined in: state.ts:186 What the hold reserved, per field: the copy that will land if the hold runs out. A renderer draws it invisibly so a blank field keeps its exact geometry. Null when no hold armed in this view. Optional so a hand-built `CreativeState` (a test mock, a story fixture) still compiles: read it as `state.held?.`. *** ### layout > **layout**: `string` \| `null` Defined in: state.ts:134 *** ### legal? > `optional` **legal?**: `string`[] Defined in: state.ts:159 Legal lines for the viewer's market, verbatim, in the author's order (`legal-ready`). They are not copy: no hold, no mark, and the stream never replaces them. Empty when the stream sent none, which means the campaign has none for this market. Render each line exactly as given. Optional so a hand-built `CreativeState` still compiles: read it as `state.legal ?? []`. *** ### live? > `optional` **live?**: [`LiveBlock`](https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md) \| `null` Defined in: state.ts:149 The live player for this slot, when a running live channel is routed to it (or the variant carries its own live block). `null` when there is none. The object keeps its identity for as long as the same channel is showing, across streams too (see `ChoreographerOptions.initialLive`), so a renderer keyed on it never reloads a playing iframe. Optional so a hand-built `CreativeState` still compiles: read it as `state.live ?? null`. *** ### meta > **meta**: `Record`\<`string`, `unknown`\> \| `null` Defined in: state.ts:163 Terminal `done.meta`, verbatim. *** ### phase > **phase**: [`Phase`](https://docs.sparkletree.io/developers/api/core/type-aliases/phase.md) Defined in: state.ts:131 *** ### rewrites > **rewrites**: `number` Defined in: state.ts:195 How many times text the visitor could see was replaced. The hold, the stream's entrance and the fallback's landing all write into blank slots, so a stream that finishes its lines counts `0`. One per field is added when the fallback replaces a line the stream had started writing and did not finish (`UnfinishedCopyPolicy`), at most once per field. `useIsland` adds one per cross-fade after a campaign or context change. *** ### sequence > **sequence**: \{ `fps`: `number`; `frames`: `string`[]; `heroIndex`: `number`; \} \| `null` Defined in: state.ts:137 *** ### theme > **theme**: \{ `colors`: `Record`\<`string`, `string`\>; `sources`: `Record`\<`string`, `string`\>; \} \| `null` Defined in: state.ts:133 *** ### variantId > **variantId**: `string` \| `null` Defined in: state.ts:175 Resolved variant, for pinning subsequent calls in this page view. *** ### videoUrl > **videoUrl**: `string` \| `null` Defined in: state.ts:138 --- # DeclaredContext Source: https://docs.sparkletree.io/developers/api/core/interfaces/declaredcontext/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/declaredcontext.md Defined in: context.ts:88 Developer-declared placement, the public shape (long field names). ## Indexable > \[`key`: `` `x.${string}` ``\]: `string` \| `undefined` Literal custom dims: `"x.tier": "pro"` — same dim as `custom.tier`, which wins on collision. Accepted because the server extractor accepts them; dropping them client-side desyncs ctxhash from the signed hash. ## Properties ### audience? > `optional` **audience?**: `string` Defined in: context.ts:94 Placement descriptor, never a user identifier. *** ### custom? > `optional` **custom?**: `Record`\<`string`, `string`\> Defined in: context.ts:101 Org-declared custom dims: `{ tier: "pro" }` becomes dim `x.tier`. *** ### intent? > `optional` **intent?**: `string` Defined in: context.ts:92 Platform intent enum. *** ### notes? > `optional` **notes?**: `string` Defined in: context.ts:99 Free text, ≤280 chars, describing the placement — never the visitor. Hashed in full: a distinct notes value is a distinct context. *** ### page? > `optional` **page?**: `string` Defined in: context.ts:90 Declared page class, `[a-z0-9-]{1,32}`. Never a URL or path. --- # DisclosurePayload Source: https://docs.sparkletree.io/developers/api/core/interfaces/disclosurepayload/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/disclosurepayload.md Defined in: wire.ts:275 Art.50 disclosure for non-SDK renderers. Stripping it is a terms violation; a resolution failure must never silence the label. ## Properties ### label > **label**: `string` Defined in: wire.ts:277 Localized Art.50 disclosure label, ready to render. *** ### locale > **locale**: `string` Defined in: wire.ts:279 BCP-47 tag of the label's language. *** ### status > **status**: `string` Defined in: wire.ts:281 Resolution status, e.g. attested | fail-safe. --- # DoneMeta Source: https://docs.sparkletree.io/developers/api/core/interfaces/donemeta/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/donemeta.md Defined in: wire.ts:141 Terminal metadata. Everything a client needs to attribute the impression it is about to report. ## Properties ### campaignId > **campaignId**: `string` Defined in: wire.ts:146 Campaign actually served (may differ from the requested one after surface resolution). *** ### contentSource > **contentSource**: `"generated"` \| `"cached"` \| `"static"` Defined in: wire.ts:159 W5. Whether the copy in this stream was generated for this request, replayed from cache, or stored static content. Trust chrome keys off this. *** ### contextApplied? > `optional` **contextApplied?**: `string`[] Defined in: wire.ts:169 Context rules that actually changed the output. Empty array means context was read but changed nothing. *** ### contextHash? > `optional` **contextHash?**: `string` Defined in: wire.ts:191 Canonical declared-context hash that participated in resolution. Feeds attribution and the rung-3 promotion report. *** ### conversation? > `optional` **conversation?**: `unknown` Defined in: wire.ts:180 Conversational-ad config passthrough. Shape owned by the conversation service. *** ### ctaAction? > `optional` **ctaAction?**: `string` Defined in: wire.ts:171 Resolved CTA destination. *** ### ctaType? > `optional` **ctaType?**: `string` Defined in: wire.ts:173 CTA behaviour class (link, modal, conversation…). *** ### degraded? > `optional` **degraded?**: `"quota"` \| `"spend-cap"` \| `"upstream"` \| `"timeout"` Defined in: wire.ts:164 W8. Present only when the server fell back to deterministic static serving. Absent means full service. *** ### fit? > `optional` **fit?**: `number` Defined in: wire.ts:211 Design fit of the served design (also in pickReason.fit). Only with a signed dashboard preview grant, when design fit applied. *** ### fitCues? > `optional` **fitCues?**: `string`[] Defined in: wire.ts:213 The cues behind fit (also in pickReason.cues). Same audience as fit. *** ### pickReason? > `optional` **pickReason?**: `PickReason` Defined in: wire.ts:206 Why the edge served this design. Only with a signed dashboard preview grant (?st-preview=, minted for a signed-in user): absent on every public serve. Never render it to an end viewer. *** ### resolvedFrom? > `optional` **resolvedFrom?**: `"pinned"` \| `"surface"` \| `"context"` Defined in: wire.ts:186 How the served campaign was chosen: an explicit variant pin, surface resolution, or declared-context resolution. Absent means pinned on older edges. *** ### servedLanguage? > `optional` **servedLanguage?**: `string` Defined in: wire.ts:198 BCP 47 tag of the language the copy was written for on this serve (e.g. ja-JP). Clients copy it into context.servedLanguage of the impression and click they report, so analytics can say which language each market saw. Absent on older edges and on streams that served no campaign. *** ### servedLanguageReason? > `optional` **servedLanguageReason?**: `"english"` \| `"fixed"` \| `"fixed-default"` \| `"local-geo-locale"` \| `"local-geo-country"` \| `"local-browser-locale"` \| `"local-accept-language"` \| `"local-default"` \| `"language-check-fallback"` Defined in: wire.ts:200 Why the edge chose servedLanguage. Present whenever servedLanguage is. *** ### staticHandoffUrl? > `optional` **staticHandoffUrl?**: `string` Defined in: wire.ts:175 QR/handoff target for physical surfaces. *** ### variantId > **variantId**: `string` Defined in: wire.ts:151 Variant the ε-greedy resolver picked. Clients MUST pin this on every subsequent call in the page view. *** ### variantName? > `optional` **variantName?**: `string` Defined in: wire.ts:153 Human label for the variant, for the Ledger and Studio. --- # FactFieldSpec Source: https://docs.sparkletree.io/developers/api/core/interfaces/factfieldspec/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/factfieldspec.md Defined in: fragments.ts:124 A field filled with one stated fact of one product, read from the workspace's records (`fetchFacts`). Never generated. A landed fact is `source: "static"` (it is not adapted copy) with `stated: true`, and the renderers stamp it `data-content-source="stated"`. `product` is the product's id or handle. `price` is the amount formatted with its currency for the call's `language`; `amount` is the raw decimal string; `availability` shows the page's own words for the stated state, from `labels`. When the workspace has not stated the fact, the fallback stays. Fact fields never enter the schema hash or the mint request. ## Properties ### fact > **fact**: `"amount"` \| `"name"` \| `"price"` \| `"currency"` \| `"availability"` \| `"sku"` \| `"description"` Defined in: fragments.ts:127 *** ### fallback > **fallback**: `string` Defined in: fragments.ts:128 *** ### kind > **kind**: `"fact"` Defined in: fragments.ts:125 *** ### labels? > `optional` **labels?**: `Partial`\<`Record`\<`"in_stock"` \| `"out_of_stock"`, `string`\>\> Defined in: fragments.ts:137 With `fact: "availability"`: the words to show for each state, for example `{ in_stock: "In stock", out_of_stock: "Sold out" }`. The field lands the label for the stated state. With no label for that state, no labels, or an unknown state, the fallback stays. Each label must fit the fallback's space like any other value, so make the fallback the longest label. Ignored for other facts. *** ### product > **product**: `string` Defined in: fragments.ts:126 *** ### swap? > `optional` **swap?**: [`FragmentSwapPolicy`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentswappolicy.md) Defined in: fragments.ts:139 Accepted and ignored, as on generated fields: every field behaves as `"never"`. --- # FactProduct Source: https://docs.sparkletree.io/developers/api/core/interfaces/factproduct/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/factproduct.md Defined in: facts.ts:45 One product as the facts endpoint states it. Absent values are omitted. ## Properties ### availability? > `optional` **availability?**: [`FactAvailability`](https://docs.sparkletree.io/developers/api/core/type-aliases/factavailability.md) Defined in: facts.ts:54 *** ### currency? > `optional` **currency?**: `string` Defined in: facts.ts:53 ISO 4217 code, for example `"SEK"`. *** ### description? > `optional` **description?**: `string` Defined in: facts.ts:49 *** ### handle? > `optional` **handle?**: `string` Defined in: facts.ts:47 *** ### id > **id**: `string` Defined in: facts.ts:46 *** ### imageUrl? > `optional` **imageUrl?**: `string` Defined in: facts.ts:57 *** ### name > **name**: `string` Defined in: facts.ts:48 *** ### price? > `optional` **price?**: `string` Defined in: facts.ts:51 The amount as stored, as a decimal string, for example `"249.00"`. Not formatted. *** ### sku? > `optional` **sku?**: `string` Defined in: facts.ts:55 *** ### url? > `optional` **url?**: `string` Defined in: facts.ts:56 --- # FactsPayload Source: https://docs.sparkletree.io/developers/api/core/interfaces/factspayload/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/factspayload.md Defined in: facts.ts:69 The body of `GET /api/embed/v1/facts`. ## Properties ### ask > **ask**: \{ `campaign`: `string`; `url`: `string`; \} \| `null` Defined in: facts.ts:76 Present only when the campaign is public on the edge. *** ### asOf > **asOf**: `string` Defined in: facts.ts:78 *** ### campaign > **campaign**: \{ `id`: `string`; `legalLines?`: `string`[]; `name`: `string`; `url?`: `string`; \} \| `null` Defined in: facts.ts:73 Null when no campaign resolved. `url` only when the campaign is public. *** ### facts > **facts**: `1` Defined in: facts.ts:70 *** ### organization > **organization**: `object` Defined in: facts.ts:71 #### id > **id**: `string` #### name > **name**: `string` #### url? > `optional` **url?**: `string` *** ### products > **products**: [`FactProduct`](https://docs.sparkletree.io/developers/api/core/interfaces/factproduct.md)[] Defined in: facts.ts:74 *** ### signature > **signature**: [`FactsSignature`](https://docs.sparkletree.io/developers/api/core/interfaces/factssignature.md) \| `null` Defined in: facts.ts:80 Null when the edge has no signing key. *** ### source > **source**: `"stated"` Defined in: facts.ts:77 --- # FactsPublicKey Source: https://docs.sparkletree.io/developers/api/core/interfaces/factspublickey/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/factspublickey.md Defined in: facts.ts:473 One public key, as `/.well-known/sparkletree-keys.json` lists it (a JWK). ## Properties ### alg? > `optional` **alg?**: `string` Defined in: facts.ts:479 *** ### crv? > `optional` **crv?**: `string` Defined in: facts.ts:478 *** ### kid > **kid**: `string` Defined in: facts.ts:474 *** ### kty? > `optional` **kty?**: `string` Defined in: facts.ts:477 *** ### use? > `optional` **use?**: `string` Defined in: facts.ts:480 *** ### x > **x**: `string` Defined in: facts.ts:476 Base64url of the raw 32-byte Ed25519 public key. --- # FactsResult Source: https://docs.sparkletree.io/developers/api/core/interfaces/factsresult/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/factsresult.md Defined in: facts.ts:100 ## Properties ### facts > **facts**: [`FactsPayload`](https://docs.sparkletree.io/developers/api/core/interfaces/factspayload.md) \| `null` Defined in: facts.ts:103 The document exactly as the edge sent it (unknown members kept, so it still verifies). *** ### ok > **ok**: `boolean` Defined in: facts.ts:101 *** ### reason? > `optional` **reason?**: [`FactsFailureReason`](https://docs.sparkletree.io/developers/api/core/type-aliases/factsfailurereason.md) Defined in: facts.ts:105 Set when `ok` is false. *** ### status? > `optional` **status?**: `number` Defined in: facts.ts:107 The HTTP status, when the edge answered. *** ### url? > `optional` **url?**: `string` Defined in: facts.ts:109 The URL that was requested, when a request was made. --- # FactsSignature Source: https://docs.sparkletree.io/developers/api/core/interfaces/factssignature/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/factssignature.md Defined in: facts.ts:60 ## Properties ### alg > **alg**: `"ed25519"` Defined in: facts.ts:61 *** ### keyId > **keyId**: `string` Defined in: facts.ts:63 First 8 hex characters of sha256 of the raw public key, unless the edge sets its own id. *** ### value > **value**: `string` Defined in: facts.ts:65 Base64url without padding. --- # FetchContentOptions Source: https://docs.sparkletree.io/developers/api/core/interfaces/fetchcontentoptions/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fetchcontentoptions.md Defined in: client.ts:164 ## Properties ### fetchImpl? > `optional` **fetchImpl?**: (`input`, `init?`) => `Promise`\<`Response`\> Defined in: client.ts:173 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) #### Parameters ##### input `URL` \| `RequestInfo` ##### init? `RequestInit` #### Returns `Promise`\<`Response`\> *** ### signal? > `optional` **signal?**: `AbortSignal` Defined in: client.ts:165 *** ### timeoutMs? > `optional` **timeoutMs?**: `number` Defined in: client.ts:172 How long to wait for the whole answer, in milliseconds. Off by default: without it the read waits for as long as the connection stays open, or until `signal` aborts. Past it the request is stopped and the call resolves null. `0` or `Infinity` is the same as leaving it out. --- # FetchFactsOptions Source: https://docs.sparkletree.io/developers/api/core/interfaces/fetchfactsoptions/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fetchfactsoptions.md Defined in: facts.ts:112 ## Properties ### apiBase > **apiBase**: `string` Defined in: facts.ts:113 *** ### apiBaseProvenance? > `optional` **apiBaseProvenance?**: `"explicit"` \| `"key"` Defined in: facts.ts:122 Where `apiBase` came from; see `FetchFragmentsOptions.apiBaseProvenance`. Defaults to "explicit". *** ### campaignId? > `optional` **campaignId?**: `string` Defined in: facts.ts:117 *** ### fetchImpl? > `optional` **fetchImpl?**: (`input`, `init?`) => `Promise`\<`Response`\> Defined in: facts.ts:132 Test seam; defaults to the platform fetch. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) #### Parameters ##### input `URL` \| `RequestInfo` ##### init? `RequestInit` #### Returns `Promise`\<`Response`\> *** ### organizationId > **organizationId**: `string` Defined in: facts.ts:114 *** ### products? > `optional` **products?**: readonly `string`[] Defined in: facts.ts:120 Product ids or handles, at most 20. Without them, a campaign's or surface's own products. *** ### publishableKey? > `optional` **publishableKey?**: `string` Defined in: facts.ts:116 `st_pk_…`. Sent as `Authorization: Bearer `. *** ### signal? > `optional` **signal?**: `AbortSignal` Defined in: facts.ts:123 *** ### surfaceId? > `optional` **surfaceId?**: `string` Defined in: facts.ts:118 *** ### timeoutMs? > `optional` **timeoutMs?**: `number` Defined in: facts.ts:130 How long the call waits for the whole answer, in milliseconds. Default 10000. Past it the request is stopped and the call resolves with `reason: "timeout"`. `0` or `Infinity` waits for as long as the connection stays open. --- # FetchFragmentsOptions Source: https://docs.sparkletree.io/developers/api/core/interfaces/fetchfragmentsoptions/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fetchfragmentsoptions.md Defined in: fragments.ts:218 ## Properties ### apiBase > **apiBase**: `string` Defined in: fragments.ts:220 *** ### apiBaseProvenance? > `optional` **apiBaseProvenance?**: `"explicit"` \| `"key"` Defined in: fragments.ts:240 Where `apiBase` came from. The SDK cannot verify a key's signature (it holds no secret), so a key-derived apiBase is still an unproven host client-side: it earns content fetches but NOT the mint POST (which carries the signed mint token and the declared dims) unless the host is first-party or loopback (S-2). Defaults to "explicit": a caller passing apiBase directly has chosen it themselves. *** ### campaignId? > `optional` **campaignId?**: `string` Defined in: fragments.ts:244 Default campaign for slot fields that name neither campaign nor surface. *** ### context? > `optional` **context?**: [`DeclaredContext`](https://docs.sparkletree.io/developers/api/core/interfaces/declaredcontext.md) Defined in: fragments.ts:221 *** ### fetchImpl? > `optional` **fetchImpl?**: (`input`, `init?`) => `Promise`\<`Response`\> Defined in: fragments.ts:242 Test seam; defaults to the platform fetch. [MDN Reference](https://developer.mozilla.org/docs/Web/API/Window/fetch) #### Parameters ##### input `URL` \| `RequestInfo` ##### init? `RequestInit` #### Returns `Promise`\<`Response`\> *** ### fields > **fields**: `Record`\<`string`, [`FragmentFieldSpec`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentfieldspec.md)\> Defined in: fragments.ts:222 *** ### language? > `optional` **language?**: `string` Defined in: fragments.ts:252 The page language for `fact: "price"`, a BCP 47 tag such as `"sv-SE"`. Defaults to `"en"`. Core never reads it from the browser: pass the same value on the server and in the browser and both format the same string. *** ### mintToken? > `optional` **mintToken?**: [`MintTokenSource`](https://docs.sparkletree.io/developers/api/core/type-aliases/minttokensource.md) Defined in: fragments.ts:226 Sent on the mint POST only — never on the GET, which is a shared CDN object and must be byte-identical for every caller. Optional: without it the mint goes unsigned and the server admits it or not. *** ### onMintStarted? > `optional` **onMintStarted?**: () => `void` Defined in: fragments.ts:276 Called once when the server has accepted a request-time generation and is writing the copy for this very page view. A renderer holding the canvas may restart its budget ONCE here — the same rule as an island stream proving it is alive (`copyStart`). #### Returns `void` *** ### organizationId > **organizationId**: `string` Defined in: fragments.ts:219 *** ### publishableKey? > `optional` **publishableKey?**: `string` Defined in: fragments.ts:233 `st_pk_…` from the dashboard. Sent on the mint POST only, as `Authorization: Bearer ` — never on the GET, for the same reason as the token. A live key sent from an origin registered to the org is enough for the server to admit the mint, so a site with no backend (a brand page) gets live copy. When `mintToken` is also given, both are sent and the server prefers the token. *** ### signal? > `optional` **signal?**: `AbortSignal` Defined in: fragments.ts:263 Stops the call's reads (the fragments read, facts and slots). Aborted, the call resolves at once with the fallbacks (it still never rejects). The renderers abort when their hold ends with nothing landed and when they unmount, so a stalled connection does not keep a read open. A mint POST that was already sent is not stopped: the server is writing copy for the views after this one. The call resolves without waiting for it. *** ### surfaceId? > `optional` **surfaceId?**: `string` Defined in: fragments.ts:246 Default surface for slot fields that name neither campaign nor surface. *** ### timeoutMs? > `optional` **timeoutMs?**: `number` Defined in: fragments.ts:271 How long the call waits, in milliseconds, before it stops its reads and resolves with the fallbacks, as an abort does. Default 10000. It covers the fragments read, the facts read, the slot reads and waiting for a mint's copy; a mint POST already sent is not stopped. `0` or `Infinity` turns the deadline off. --- # FieldState Source: https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md Defined in: state.ts:92 ## Extended by - [`FragmentFieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fragmentfieldstate.md) ## Properties ### crossfade? > `optional` **crossfade?**: `boolean` Defined in: state.ts:113 True when `text` deliberately replaces text that may have been visible: an unfinished line replaced by the fallback after a failure or a stall (`UnfinishedCopyPolicy`), or new copy after the campaign or context changed. Renderers cross-fade once (`COPY_MOTION_MS`, `COPY_MOTION_EASING`) instead of typing. Absent on every other field — no other change ever replaces visible text. *** ### mode > **mode**: `"generate"` \| `"replay"` \| `null` Defined in: state.ts:99 Declared delivery mode, once the field has opened. *** ### settled > **settled**: `boolean` Defined in: state.ts:104 `text` is final for this stream: closed by the server, or settled by the SDK at the end of the stream. *** ### source > **source**: `"generated"` \| `"cached"` \| `"static"` Defined in: state.ts:97 Provenance of `text`. `generated` and `cached` may carry the adaptation mark, `static` may not — `decideChrome` is the one place that decides. *** ### text > **text**: `string` Defined in: state.ts:94 What a consumer should render right now. Never a placeholder. *** ### typing > **typing**: `boolean` Defined in: state.ts:101 True while live deltas are landing — consumers may animate a caret. --- # FollowerReservation Source: https://docs.sparkletree.io/developers/api/core/interfaces/followerreservation/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/followerreservation.md Defined in: variant.ts:72 ## Properties ### kind > **kind**: `"follower"` Defined in: variant.ts:73 *** ### variantId > **variantId**: `Promise`\<`string` \| `undefined`\> Defined in: variant.ts:80 Resolves with the pinned variant, or `undefined` when the leader aborted, the wait timed out, or the leader finished without a variant — in which case the follower should request unpinned, exactly as it would have before reservations existed. Never rejects. --- # FragmentField Source: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentfield/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentfield.md Defined in: wire.ts:243 One resolved fragment field. Provenance rules are identical to copy fields: static copy may never wear the adaptation mark. ## Properties ### source > **source**: `"generated"` \| `"cached"` \| `"static"` Defined in: wire.ts:247 W5 provenance. Static copy may never wear the mark. *** ### text > **text**: `string` Defined in: wire.ts:245 Final text, within the server-enforced length budget. --- # FragmentFieldState Source: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentfieldstate/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentfieldstate.md Defined in: fragments.ts:166 A resolved field: a `FieldState`, assignable to one. `source` keeps its three values and says whether the copy is adapted. `stated` is true on a field that shows a stated fact (its `source` is then `"static"`). ## Extends - [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md) ## Properties ### crossfade? > `optional` **crossfade?**: `boolean` Defined in: state.ts:113 True when `text` deliberately replaces text that may have been visible: an unfinished line replaced by the fallback after a failure or a stall (`UnfinishedCopyPolicy`), or new copy after the campaign or context changed. Renderers cross-fade once (`COPY_MOTION_MS`, `COPY_MOTION_EASING`) instead of typing. Absent on every other field — no other change ever replaces visible text. #### Inherited from [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md).[`crossfade`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md#crossfade) *** ### mode > **mode**: `"generate"` \| `"replay"` \| `null` Defined in: state.ts:99 Declared delivery mode, once the field has opened. #### Inherited from [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md).[`mode`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md#mode) *** ### settled > **settled**: `boolean` Defined in: state.ts:104 `text` is final for this stream: closed by the server, or settled by the SDK at the end of the stream. #### Inherited from [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md).[`settled`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md#settled) *** ### source > **source**: `"generated"` \| `"cached"` \| `"static"` Defined in: state.ts:97 Provenance of `text`. `generated` and `cached` may carry the adaptation mark, `static` may not — `decideChrome` is the one place that decides. #### Inherited from [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md).[`source`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md#source) *** ### stated? > `optional` **stated?**: `true` Defined in: fragments.ts:168 The text is a stated fact from the workspace's records. Absent otherwise. *** ### text > **text**: `string` Defined in: state.ts:94 What a consumer should render right now. Never a placeholder. #### Inherited from [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md).[`text`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md#text) *** ### typing > **typing**: `boolean` Defined in: state.ts:101 True while live deltas are landing — consumers may animate a caret. #### Inherited from [`FieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md).[`typing`](https://docs.sparkletree.io/developers/api/core/interfaces/fieldstate.md#typing) --- # FragmentsResponse Source: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentsresponse/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentsresponse.md Defined in: wire.ts:289 GET /embed/v1/fragments — cache-first microcopy for a declared context. NEVER blocks on generation. A cold miss returns an EMPTY map with pending:true; the client owns the fallback. ## Properties ### contextHash > **contextHash**: `string` Defined in: wire.ts:296 Server-computed canonical hash. THE identity. Third leg of the pin key. *** ### degraded? > `optional` **degraded?**: `"quota"` \| `"spend-cap"` \| `"upstream"` \| `"timeout"` Defined in: wire.ts:305 W8 vocabulary, verbatim. *** ### disclosure? > `optional` **disclosure?**: [`DisclosurePayload`](https://docs.sparkletree.io/developers/api/core/interfaces/disclosurepayload.md) Defined in: wire.ts:310 Art.50 label + locale, for non-SDK renderers. Present whenever any field is non-static. *** ### fragments > **fragments**: `Record`\<`string`, [`FragmentField`](https://docs.sparkletree.io/developers/api/core/interfaces/fragmentfield.md)\> Defined in: wire.ts:294 Keyed by the caller's own field names. Empty on a cold miss — never echoes caller-supplied text. *** ### meta > **meta**: `unknown` Defined in: wire.ts:312 ttl, epoch, schemaHash, budget state. *** ### pending? > `optional` **pending?**: `boolean` Defined in: wire.ts:303 True when the client should POST /mint once. *** ### warmth > **warmth**: `"cold"` \| `"warming"` \| `"warm"` Defined in: wire.ts:301 cold = static now | warming = fill in flight | warm = generated for this bucket. --- # FragmentsResult Source: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentsresult/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/fragmentsresult.md Defined in: fragments.ts:279 ## Properties ### contextHash > **contextHash**: `string` Defined in: fragments.ts:284 Locally computed declared-context hash. Third leg of the pin key. *** ### disclosure? > `optional` **disclosure?**: [`DisclosurePayload`](https://docs.sparkletree.io/developers/api/core/interfaces/disclosurepayload.md) Defined in: fragments.ts:295 The server's localized label for AI-generated copy (for example "AI-generated content"), when the read served non-static copy and sent one. Data only: the SDK never renders it. Show it yourself, in your own words or these, if your site labels AI-generated copy. *** ### fields > **fields**: `Record`\<`string`, [`FragmentFieldState`](https://docs.sparkletree.io/developers/api/core/interfaces/fragmentfieldstate.md)\> Defined in: fragments.ts:282 One field per requested key: the shape islands produce. A landed fact field is `source: "static"` with `stated: true`. *** ### marked > **marked**: `boolean` Defined in: fragments.ts:288 decideChrome over the strongest served provenance (cached counts as adapted). Data only: the SDK shows no visible label from it. *** ### warmth > **warmth**: `"cold"` \| `"warming"` \| `"warm"` Defined in: fragments.ts:285 --- # GeneratedFieldSpec Source: https://docs.sparkletree.io/developers/api/core/interfaces/generatedfieldspec/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/generatedfieldspec.md Defined in: fragments.ts:102 A field whose copy is written for the declared context (the mint path). ## Properties ### fallback > **fallback**: `string` \| `string`[] Defined in: fragments.ts:104 *** ### kind? > `optional` **kind?**: `"headline"` \| `"body"` \| `"cta"` \| `"label"` \| `"empty-state"` Defined in: fragments.ts:103 *** ### swap? > `optional` **swap?**: [`FragmentSwapPolicy`](https://docs.sparkletree.io/developers/api/core/type-aliases/fragmentswappolicy.md) Defined in: fragments.ts:107 Late-swap policy. Every value behaves as `"never"`; the other values are deprecated (see `FragmentSwapPolicy`). --- # ImpressionDetail Source: https://docs.sparkletree.io/developers/api/core/interfaces/impressiondetail/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/impressiondetail.md Defined in: analytics.ts:41 ## Properties ### chromeMarked > **chromeMarked**: `boolean` Defined in: analytics.ts:49 Was adapted copy on screen (the chrome decision)? Reported so chrome state is measurable; the visible mark itself is the integrator's opt-in. *** ### contentSource > **contentSource**: `"generated"` \| `"cached"` \| `"static"` \| `"cached-stale"` Defined in: analytics.ts:46 Where the copy the viewer saw came from. `cached-stale` is cached copy served past its freshness window (still within its serving window). *** ### degraded? > `optional` **degraded?**: `string` \| `null` Defined in: analytics.ts:51 W8 — set when the server served a deterministic winner. *** ### island? > `optional` **island?**: `string` Defined in: analytics.ts:52 --- # InitialCopy Source: https://docs.sparkletree.io/developers/api/core/interfaces/initialcopy/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/initialcopy.md Defined in: visitorContext.ts:131 Copy already produced for this view, ready for the `initialCopy` option of `useIsland`, `Hero` and `Cta`. It renders visibly from the first frame, settled and final. ## Properties ### campaignId? > `optional` **campaignId?**: `string` Defined in: visitorContext.ts:143 The campaign the copy belongs to. Impressions attribute to it. *** ### contentSource > **contentSource**: `"generated"` \| `"cached"` \| `"static"` Defined in: visitorContext.ts:139 Where the copy came from: `cached` for copy read from the live-copy cache. *** ### copy > **copy**: `object` Defined in: visitorContext.ts:132 #### body? > `optional` **body?**: `string` #### cta? > `optional` **cta?**: `string` #### greeting? > `optional` **greeting?**: `string` #### headline? > `optional` **headline?**: `string` *** ### freshness? > `optional` **freshness?**: `"fresh"` \| `"stale"` Defined in: visitorContext.ts:149 For cached copy: `fresh`, or `stale` when it was past its freshness window but still within its serving window. Reported with the impression. *** ### variantId? > `optional` **variantId?**: `string` Defined in: visitorContext.ts:141 The variant the copy belongs to. Pins the page's variant. --- # LeaderReservation Source: https://docs.sparkletree.io/developers/api/core/interfaces/leaderreservation/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/leaderreservation.md Defined in: variant.ts:57 ## Properties ### abort > **abort**: () => `void` Defined in: variant.ts:69 The leader failed (or unmounted) before learning a variant. Followers currently waiting are released unpinned, and the NEXT `reserve()` call for this pin key leads. Idempotent. #### Returns `void` *** ### kind > **kind**: `"leader"` Defined in: variant.ts:58 *** ### resolve > **resolve**: (`variantId`) => `void` Defined in: variant.ts:63 The stream resolved: pin `variantId` and release every follower with it. Idempotent; calls after `resolve` or `abort` are ignored. #### Parameters ##### variantId `string` #### Returns `void` --- # LiveBlock Source: https://docs.sparkletree.io/developers/api/core/interfaces/liveblock/ Markdown: https://docs.sparkletree.io/developers/api/core/interfaces/liveblock.md Defined in: live.ts:14 What a renderer needs to show a live player. ## Properties ### channelId > **channelId**: `string` Defined in: live.ts:16 The live channel's id: the identity the player is kept by. *** ### src > **src**: `string` Defined in: live.ts:22 The player's iframe address, rebuilt from checked parts: `https://