@sentientui/core 0.20.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,135 @@
1
1
  import { b as SlotDeclInput } from './session-meta-BVvq5RBB.cjs';
2
2
  import { SlotResult } from '@sentientui/policy';
3
3
 
4
+ /**
5
+ * Composition Blocks (spec: 2026-08-20-nocode-composition-variants-design.md §4).
6
+ *
7
+ * A bounded, TYPED component tree — never HTML — that a registry arm may carry
8
+ * (`published_config.arms[].blocks`). The vocabulary is the whitelist: every
9
+ * prop value is an enumerated token, validated server-side before publish
10
+ * (apps/api/src/domain/composition-blocks.ts) and rendered client-side through
11
+ * document.createElement + property assignment only. No innerHTML/outerHTML/
12
+ * insertAdjacentHTML exists anywhere on this path — the security property is
13
+ * preserved by never accepting HTML, not by sanitizing it, which is why there
14
+ * is no sanitizer to keep honest.
15
+ *
16
+ * Token lists live here (not in the API domain like SlotOps' mirrors) because
17
+ * three parties must agree byte-for-byte: the server validator, the snippet
18
+ * renderer, and eventually the React renderer (§11) — a drifted copy would let
19
+ * a published arm fail to render, which the fail-safe turns into an invisibly
20
+ * missing section, not an error.
21
+ */
22
+ declare const BLOCK_GAPS: readonly ["none", "sm", "md", "lg"];
23
+ declare const BLOCK_ALIGNS: readonly ["start", "center", "end", "stretch"];
24
+ declare const BLOCK_JUSTIFIES: readonly ["start", "center", "end", "between"];
25
+ declare const BLOCK_SIZES: readonly ["sm", "md", "lg"];
26
+ declare const BLOCK_WEIGHTS: readonly ["normal", "medium", "bold"];
27
+ declare const BLOCK_TONES: readonly ["default", "muted", "accent"];
28
+ declare const BLOCK_EMPHASES: readonly ["primary", "secondary", "ghost"];
29
+ declare const BLOCK_TEXT_ALIGNS: readonly ["left", "center", "right"];
30
+ declare const BLOCK_RATIOS: readonly ["auto", "square", "landscape", "wide"];
31
+ declare const BLOCK_FITS: readonly ["cover", "contain"];
32
+ declare const BLOCK_GRID_COLUMNS: readonly [2, 3, 4];
33
+ declare const BLOCK_HEADING_LEVELS: readonly [2, 3, 4];
34
+ type BlockGap = (typeof BLOCK_GAPS)[number];
35
+ type BlockAlign = (typeof BLOCK_ALIGNS)[number];
36
+ type BlockJustify = (typeof BLOCK_JUSTIFIES)[number];
37
+ type BlockSize = (typeof BLOCK_SIZES)[number];
38
+ type BlockWeight = (typeof BLOCK_WEIGHTS)[number];
39
+ type BlockTone = (typeof BLOCK_TONES)[number];
40
+ type BlockEmphasis = (typeof BLOCK_EMPHASES)[number];
41
+ type BlockTextAlign = (typeof BLOCK_TEXT_ALIGNS)[number];
42
+ type BlockRatio = (typeof BLOCK_RATIOS)[number];
43
+ type BlockFit = (typeof BLOCK_FITS)[number];
44
+ /** Flex row/column container. */
45
+ type StackBlock = {
46
+ type: 'stack';
47
+ direction: 'row' | 'column';
48
+ children: BlockNode[];
49
+ gap?: BlockGap;
50
+ align?: BlockAlign;
51
+ justify?: BlockJustify;
52
+ wrap?: boolean;
53
+ };
54
+ /** 2–4 equal-column grid container. */
55
+ type GridBlock = {
56
+ type: 'grid';
57
+ columns: (typeof BLOCK_GRID_COLUMNS)[number];
58
+ children: BlockNode[];
59
+ gap?: BlockGap;
60
+ align?: BlockAlign;
61
+ };
62
+ /** Paragraph / label. */
63
+ type TextBlock = {
64
+ type: 'text';
65
+ value: string;
66
+ size?: BlockSize;
67
+ weight?: BlockWeight;
68
+ tone?: BlockTone;
69
+ align?: BlockTextAlign;
70
+ };
71
+ /** h2–h4 — never h1 (the page owns its h1). */
72
+ type HeadingBlock = {
73
+ type: 'heading';
74
+ value: string;
75
+ level: (typeof BLOCK_HEADING_LEVELS)[number];
76
+ size?: BlockSize;
77
+ align?: BlockTextAlign;
78
+ };
79
+ /** Link styled as a button. `tag` feeds agent legibility (agentDataByVariant). */
80
+ type ButtonBlock = {
81
+ type: 'button';
82
+ label: string;
83
+ href: string;
84
+ emphasis?: BlockEmphasis;
85
+ size?: BlockSize;
86
+ tag?: string;
87
+ };
88
+ /** Inline text link. */
89
+ type LinkBlock = {
90
+ type: 'link';
91
+ label: string;
92
+ href: string;
93
+ tag?: string;
94
+ };
95
+ /** Image. `alt` is required; empty only with an explicit `decorative: true`. */
96
+ type ImageBlock = {
97
+ type: 'image';
98
+ src: string;
99
+ alt: string;
100
+ decorative?: boolean;
101
+ ratio?: BlockRatio;
102
+ fit?: BlockFit;
103
+ };
104
+ /** Eyebrow / pill. */
105
+ type BadgeBlock = {
106
+ type: 'badge';
107
+ value: string;
108
+ tone?: BlockTone;
109
+ };
110
+ /** Vertical rhythm. */
111
+ type SpacerBlock = {
112
+ type: 'spacer';
113
+ size: BlockSize;
114
+ };
115
+ type BlockNode = StackBlock | GridBlock | TextBlock | HeadingBlock | ButtonBlock | LinkBlock | ImageBlock | BadgeBlock | SpacerBlock;
116
+ /** The derived site palette (spec §4 "Colour and type: derived, not chosen").
117
+ * Sampled by the on-site editor from the live page's own buttons — computed
118
+ * styles, so values are plain colors (rgb/hex), never var()/url() — validated
119
+ * server-side, stored per project, and served with the decision so injected
120
+ * blocks render in the merchant's own primary color and corner radius.
121
+ * Absent → the renderer's neutral inherit-first defaults. */
122
+ type SitePalette = {
123
+ primaryBg: string;
124
+ primaryText: string;
125
+ radius: string;
126
+ };
127
+ declare const MAX_BLOCK_NODES = 64;
128
+ declare const MAX_BLOCK_DEPTH = 5;
129
+ declare const MAX_BLOCK_CHILDREN = 12;
130
+ declare const MAX_BLOCK_ARMS = 4;
131
+ declare const MAX_BLOCK_TEXT_LEN = 500;
132
+
4
133
  /** Manages anonymous session identity with cookie + localStorage layers. */
5
134
  type SessionConfig = {
6
135
  cookieName?: string;
@@ -171,6 +300,11 @@ type SlotConfigEntry = {
171
300
  locator?: CompoundLocator;
172
301
  content?: string;
173
302
  ops?: SlotOps;
303
+ /** Composition Blocks per arm — ALL arms, not just the served one, because
304
+ * Option-B rendering pre-paints every arm hidden and reveals the served one
305
+ * (spec §6). Holdout sessions receive the baseline arm's tree only, so the
306
+ * control group's DOM stays meaningful. Absent for non-composition slots. */
307
+ blocks?: Record<string, BlockNode>;
174
308
  };
175
309
  type DecisionSnapshot = {
176
310
  v: 1;
@@ -180,6 +314,10 @@ type DecisionSnapshot = {
180
314
  layoutOrder: string[] | null;
181
315
  savedAt: number;
182
316
  slotConfig?: Record<string, SlotConfigEntry>;
317
+ /** Derived site palette for Composition Block rendering — cached so the
318
+ * pre-paint render already looks native (a palette that pops in post-decide
319
+ * would be its own flash). */
320
+ palette?: SitePalette;
183
321
  };
184
322
  /** Returns null on missing, corrupt, or wrong-version data — never throws. */
185
323
  declare function readSnapshot(apiKey: string): DecisionSnapshot | null;
@@ -333,6 +471,7 @@ type DecideOutcome = {
333
471
  slotConfig?: Record<string, SlotConfigEntry>;
334
472
  goals?: GoalDefinition[];
335
473
  sectionMap?: SectionMapEntry[];
474
+ palette?: SitePalette;
336
475
  };
337
476
  type DecideInput = {
338
477
  sections?: string[];
@@ -455,4 +594,4 @@ declare function grantConsent(apiKey?: string): void;
455
594
  */
456
595
  declare function init(config: SentientConfig): SentientClient;
457
596
 
458
- export { type AssignResult as A, renderPrePaintScript as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, sanitizePageUrl as F, type GoalDefinition as G, writeSnapshot as H, LOCAL_MODE_BANNER as L, type MicroSignalEmitter as M, PROD_KEYLESS_ERROR as P, type QueueConfig as Q, SNAPSHOT_STORAGE_KEY_PREFIX as S, type WeightEntry as W, type Assignment as a, type AssignmentCache as b, type ComponentWeightEntry as c, type CompoundLocator as d, type DecideOutcome as e, type DecisionSnapshot as f, type EventType as g, type GoalOptions as h, type GraphClient as i, type GraphConfig as j, type GraphSnapshot as k, type MicroSignalType as l, type PageNode as m, type SectionMapEntry as n, type SentientClient as o, type SentientConfig as p, type SentientEvent as q, type SessionConfig as r, type SessionManager as s, type SlotConfigEntry as t, type SlotOps as u, attachMicroSignalDetectors as v, grantConsent as w, init as x, isDoNotTrackEnabled as y, readSnapshot as z };
597
+ export { PROD_KEYLESS_ERROR as $, type AssignResult as A, BLOCK_ALIGNS as B, type ComponentGoalOptions as C, type ComponentWeightEntry as D, type CompoundLocator as E, type DecideInput as F, type DecideOutcome as G, type DecisionSnapshot as H, type EventQueue as I, type EventType as J, type GoalDefinition as K, type GoalOptions as L, type GraphClient as M, type GraphConfig as N, type GraphSnapshot as O, type GridBlock as P, type HeadingBlock as Q, type ImageBlock as R, LOCAL_MODE_BANNER as S, type LinkBlock as T, MAX_BLOCK_ARMS as U, MAX_BLOCK_CHILDREN as V, MAX_BLOCK_DEPTH as W, MAX_BLOCK_NODES as X, MAX_BLOCK_TEXT_LEN as Y, type MicroSignalEmitter as Z, type MicroSignalType as _, type Assignment as a, type PageNode as a0, type QueueConfig as a1, SNAPSHOT_STORAGE_KEY_PREFIX as a2, type SectionMapEntry as a3, type SentientClient as a4, type SentientConfig as a5, type SentientEvent as a6, type SessionConfig as a7, type SessionManager as a8, type SitePalette as a9, type SlotConfigEntry as aa, type SlotOps as ab, type SpacerBlock as ac, type StackBlock as ad, type TextBlock as ae, type WeightEntry as af, attachMicroSignalDetectors as ag, grantConsent as ah, init as ai, isDoNotTrackEnabled as aj, readSnapshot as ak, renderPrePaintScript as al, sanitizePageUrl as am, writeSnapshot as an, type AssignmentCache as b, BLOCK_EMPHASES as c, BLOCK_FITS as d, BLOCK_GAPS as e, BLOCK_GRID_COLUMNS as f, BLOCK_HEADING_LEVELS as g, BLOCK_JUSTIFIES as h, BLOCK_RATIOS as i, BLOCK_SIZES as j, BLOCK_TEXT_ALIGNS as k, BLOCK_TONES as l, BLOCK_WEIGHTS as m, type BadgeBlock as n, type BlockAlign as o, type BlockEmphasis as p, type BlockFit as q, type BlockGap as r, type BlockJustify as s, type BlockNode as t, type BlockRatio as u, type BlockSize as v, type BlockTextAlign as w, type BlockTone as x, type BlockWeight as y, type ButtonBlock as z };
@@ -1,6 +1,135 @@
1
1
  import { b as SlotDeclInput } from './session-meta-BVvq5RBB.js';
2
2
  import { SlotResult } from '@sentientui/policy';
3
3
 
4
+ /**
5
+ * Composition Blocks (spec: 2026-08-20-nocode-composition-variants-design.md §4).
6
+ *
7
+ * A bounded, TYPED component tree — never HTML — that a registry arm may carry
8
+ * (`published_config.arms[].blocks`). The vocabulary is the whitelist: every
9
+ * prop value is an enumerated token, validated server-side before publish
10
+ * (apps/api/src/domain/composition-blocks.ts) and rendered client-side through
11
+ * document.createElement + property assignment only. No innerHTML/outerHTML/
12
+ * insertAdjacentHTML exists anywhere on this path — the security property is
13
+ * preserved by never accepting HTML, not by sanitizing it, which is why there
14
+ * is no sanitizer to keep honest.
15
+ *
16
+ * Token lists live here (not in the API domain like SlotOps' mirrors) because
17
+ * three parties must agree byte-for-byte: the server validator, the snippet
18
+ * renderer, and eventually the React renderer (§11) — a drifted copy would let
19
+ * a published arm fail to render, which the fail-safe turns into an invisibly
20
+ * missing section, not an error.
21
+ */
22
+ declare const BLOCK_GAPS: readonly ["none", "sm", "md", "lg"];
23
+ declare const BLOCK_ALIGNS: readonly ["start", "center", "end", "stretch"];
24
+ declare const BLOCK_JUSTIFIES: readonly ["start", "center", "end", "between"];
25
+ declare const BLOCK_SIZES: readonly ["sm", "md", "lg"];
26
+ declare const BLOCK_WEIGHTS: readonly ["normal", "medium", "bold"];
27
+ declare const BLOCK_TONES: readonly ["default", "muted", "accent"];
28
+ declare const BLOCK_EMPHASES: readonly ["primary", "secondary", "ghost"];
29
+ declare const BLOCK_TEXT_ALIGNS: readonly ["left", "center", "right"];
30
+ declare const BLOCK_RATIOS: readonly ["auto", "square", "landscape", "wide"];
31
+ declare const BLOCK_FITS: readonly ["cover", "contain"];
32
+ declare const BLOCK_GRID_COLUMNS: readonly [2, 3, 4];
33
+ declare const BLOCK_HEADING_LEVELS: readonly [2, 3, 4];
34
+ type BlockGap = (typeof BLOCK_GAPS)[number];
35
+ type BlockAlign = (typeof BLOCK_ALIGNS)[number];
36
+ type BlockJustify = (typeof BLOCK_JUSTIFIES)[number];
37
+ type BlockSize = (typeof BLOCK_SIZES)[number];
38
+ type BlockWeight = (typeof BLOCK_WEIGHTS)[number];
39
+ type BlockTone = (typeof BLOCK_TONES)[number];
40
+ type BlockEmphasis = (typeof BLOCK_EMPHASES)[number];
41
+ type BlockTextAlign = (typeof BLOCK_TEXT_ALIGNS)[number];
42
+ type BlockRatio = (typeof BLOCK_RATIOS)[number];
43
+ type BlockFit = (typeof BLOCK_FITS)[number];
44
+ /** Flex row/column container. */
45
+ type StackBlock = {
46
+ type: 'stack';
47
+ direction: 'row' | 'column';
48
+ children: BlockNode[];
49
+ gap?: BlockGap;
50
+ align?: BlockAlign;
51
+ justify?: BlockJustify;
52
+ wrap?: boolean;
53
+ };
54
+ /** 2–4 equal-column grid container. */
55
+ type GridBlock = {
56
+ type: 'grid';
57
+ columns: (typeof BLOCK_GRID_COLUMNS)[number];
58
+ children: BlockNode[];
59
+ gap?: BlockGap;
60
+ align?: BlockAlign;
61
+ };
62
+ /** Paragraph / label. */
63
+ type TextBlock = {
64
+ type: 'text';
65
+ value: string;
66
+ size?: BlockSize;
67
+ weight?: BlockWeight;
68
+ tone?: BlockTone;
69
+ align?: BlockTextAlign;
70
+ };
71
+ /** h2–h4 — never h1 (the page owns its h1). */
72
+ type HeadingBlock = {
73
+ type: 'heading';
74
+ value: string;
75
+ level: (typeof BLOCK_HEADING_LEVELS)[number];
76
+ size?: BlockSize;
77
+ align?: BlockTextAlign;
78
+ };
79
+ /** Link styled as a button. `tag` feeds agent legibility (agentDataByVariant). */
80
+ type ButtonBlock = {
81
+ type: 'button';
82
+ label: string;
83
+ href: string;
84
+ emphasis?: BlockEmphasis;
85
+ size?: BlockSize;
86
+ tag?: string;
87
+ };
88
+ /** Inline text link. */
89
+ type LinkBlock = {
90
+ type: 'link';
91
+ label: string;
92
+ href: string;
93
+ tag?: string;
94
+ };
95
+ /** Image. `alt` is required; empty only with an explicit `decorative: true`. */
96
+ type ImageBlock = {
97
+ type: 'image';
98
+ src: string;
99
+ alt: string;
100
+ decorative?: boolean;
101
+ ratio?: BlockRatio;
102
+ fit?: BlockFit;
103
+ };
104
+ /** Eyebrow / pill. */
105
+ type BadgeBlock = {
106
+ type: 'badge';
107
+ value: string;
108
+ tone?: BlockTone;
109
+ };
110
+ /** Vertical rhythm. */
111
+ type SpacerBlock = {
112
+ type: 'spacer';
113
+ size: BlockSize;
114
+ };
115
+ type BlockNode = StackBlock | GridBlock | TextBlock | HeadingBlock | ButtonBlock | LinkBlock | ImageBlock | BadgeBlock | SpacerBlock;
116
+ /** The derived site palette (spec §4 "Colour and type: derived, not chosen").
117
+ * Sampled by the on-site editor from the live page's own buttons — computed
118
+ * styles, so values are plain colors (rgb/hex), never var()/url() — validated
119
+ * server-side, stored per project, and served with the decision so injected
120
+ * blocks render in the merchant's own primary color and corner radius.
121
+ * Absent → the renderer's neutral inherit-first defaults. */
122
+ type SitePalette = {
123
+ primaryBg: string;
124
+ primaryText: string;
125
+ radius: string;
126
+ };
127
+ declare const MAX_BLOCK_NODES = 64;
128
+ declare const MAX_BLOCK_DEPTH = 5;
129
+ declare const MAX_BLOCK_CHILDREN = 12;
130
+ declare const MAX_BLOCK_ARMS = 4;
131
+ declare const MAX_BLOCK_TEXT_LEN = 500;
132
+
4
133
  /** Manages anonymous session identity with cookie + localStorage layers. */
5
134
  type SessionConfig = {
6
135
  cookieName?: string;
@@ -171,6 +300,11 @@ type SlotConfigEntry = {
171
300
  locator?: CompoundLocator;
172
301
  content?: string;
173
302
  ops?: SlotOps;
303
+ /** Composition Blocks per arm — ALL arms, not just the served one, because
304
+ * Option-B rendering pre-paints every arm hidden and reveals the served one
305
+ * (spec §6). Holdout sessions receive the baseline arm's tree only, so the
306
+ * control group's DOM stays meaningful. Absent for non-composition slots. */
307
+ blocks?: Record<string, BlockNode>;
174
308
  };
175
309
  type DecisionSnapshot = {
176
310
  v: 1;
@@ -180,6 +314,10 @@ type DecisionSnapshot = {
180
314
  layoutOrder: string[] | null;
181
315
  savedAt: number;
182
316
  slotConfig?: Record<string, SlotConfigEntry>;
317
+ /** Derived site palette for Composition Block rendering — cached so the
318
+ * pre-paint render already looks native (a palette that pops in post-decide
319
+ * would be its own flash). */
320
+ palette?: SitePalette;
183
321
  };
184
322
  /** Returns null on missing, corrupt, or wrong-version data — never throws. */
185
323
  declare function readSnapshot(apiKey: string): DecisionSnapshot | null;
@@ -333,6 +471,7 @@ type DecideOutcome = {
333
471
  slotConfig?: Record<string, SlotConfigEntry>;
334
472
  goals?: GoalDefinition[];
335
473
  sectionMap?: SectionMapEntry[];
474
+ palette?: SitePalette;
336
475
  };
337
476
  type DecideInput = {
338
477
  sections?: string[];
@@ -455,4 +594,4 @@ declare function grantConsent(apiKey?: string): void;
455
594
  */
456
595
  declare function init(config: SentientConfig): SentientClient;
457
596
 
458
- export { type AssignResult as A, renderPrePaintScript as B, type ComponentGoalOptions as C, type DecideInput as D, type EventQueue as E, sanitizePageUrl as F, type GoalDefinition as G, writeSnapshot as H, LOCAL_MODE_BANNER as L, type MicroSignalEmitter as M, PROD_KEYLESS_ERROR as P, type QueueConfig as Q, SNAPSHOT_STORAGE_KEY_PREFIX as S, type WeightEntry as W, type Assignment as a, type AssignmentCache as b, type ComponentWeightEntry as c, type CompoundLocator as d, type DecideOutcome as e, type DecisionSnapshot as f, type EventType as g, type GoalOptions as h, type GraphClient as i, type GraphConfig as j, type GraphSnapshot as k, type MicroSignalType as l, type PageNode as m, type SectionMapEntry as n, type SentientClient as o, type SentientConfig as p, type SentientEvent as q, type SessionConfig as r, type SessionManager as s, type SlotConfigEntry as t, type SlotOps as u, attachMicroSignalDetectors as v, grantConsent as w, init as x, isDoNotTrackEnabled as y, readSnapshot as z };
597
+ export { PROD_KEYLESS_ERROR as $, type AssignResult as A, BLOCK_ALIGNS as B, type ComponentGoalOptions as C, type ComponentWeightEntry as D, type CompoundLocator as E, type DecideInput as F, type DecideOutcome as G, type DecisionSnapshot as H, type EventQueue as I, type EventType as J, type GoalDefinition as K, type GoalOptions as L, type GraphClient as M, type GraphConfig as N, type GraphSnapshot as O, type GridBlock as P, type HeadingBlock as Q, type ImageBlock as R, LOCAL_MODE_BANNER as S, type LinkBlock as T, MAX_BLOCK_ARMS as U, MAX_BLOCK_CHILDREN as V, MAX_BLOCK_DEPTH as W, MAX_BLOCK_NODES as X, MAX_BLOCK_TEXT_LEN as Y, type MicroSignalEmitter as Z, type MicroSignalType as _, type Assignment as a, type PageNode as a0, type QueueConfig as a1, SNAPSHOT_STORAGE_KEY_PREFIX as a2, type SectionMapEntry as a3, type SentientClient as a4, type SentientConfig as a5, type SentientEvent as a6, type SessionConfig as a7, type SessionManager as a8, type SitePalette as a9, type SlotConfigEntry as aa, type SlotOps as ab, type SpacerBlock as ac, type StackBlock as ad, type TextBlock as ae, type WeightEntry as af, attachMicroSignalDetectors as ag, grantConsent as ah, init as ai, isDoNotTrackEnabled as aj, readSnapshot as ak, renderPrePaintScript as al, sanitizePageUrl as am, writeSnapshot as an, type AssignmentCache as b, BLOCK_EMPHASES as c, BLOCK_FITS as d, BLOCK_GAPS as e, BLOCK_GRID_COLUMNS as f, BLOCK_HEADING_LEVELS as g, BLOCK_JUSTIFIES as h, BLOCK_RATIOS as i, BLOCK_SIZES as j, BLOCK_TEXT_ALIGNS as k, BLOCK_TONES as l, BLOCK_WEIGHTS as m, type BadgeBlock as n, type BlockAlign as o, type BlockEmphasis as p, type BlockFit as q, type BlockGap as r, type BlockJustify as s, type BlockNode as t, type BlockRatio as u, type BlockSize as v, type BlockTextAlign as w, type BlockTone as x, type BlockWeight as y, type ButtonBlock as z };