@sentientui/react 0.3.1 → 0.3.2

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.
@@ -68,6 +68,11 @@ type AdaptiveRootProps = Omit<AdaptiveProviderProps, 'initialAssignments'> & {
68
68
  appOrigin?: string;
69
69
  /** Override: when set no network fetch is made. Useful for tests. */
70
70
  initialAssignments?: ServerAssignments;
71
+ /**
72
+ * Milliseconds to wait for the API before rendering default variants.
73
+ * Defaults to 1500. Increase if you see unexpected fallbacks in production.
74
+ */
75
+ timeoutMs?: number;
71
76
  children: ReactNode;
72
77
  };
73
78
  /**
@@ -54,7 +54,8 @@ async function loadAdaptiveAssignments(components, options) {
54
54
  baseUrl: options.baseUrl,
55
55
  origin: options.origin,
56
56
  userAgent: options.userAgent,
57
- referer: options.referer
57
+ referer: options.referer,
58
+ timeoutMs: options.timeoutMs
58
59
  });
59
60
  }
60
61
  async function loadAdaptiveDecision(options) {
@@ -72,7 +73,8 @@ async function loadAdaptiveDecision(options) {
72
73
  baseUrl: options.baseUrl,
73
74
  origin: options.origin,
74
75
  userAgent: options.userAgent,
75
- referer: options.referer
76
+ referer: options.referer,
77
+ timeoutMs: options.timeoutMs
76
78
  }
77
79
  );
78
80
  }
@@ -89,6 +91,7 @@ async function AdaptiveRoot(props) {
89
91
  serverApiKey,
90
92
  appOrigin,
91
93
  initialAssignments: initialAssignmentsOverride,
94
+ timeoutMs,
92
95
  children
93
96
  } = _a, providerProps = __objRest(_a, [
94
97
  "components",
@@ -96,6 +99,7 @@ async function AdaptiveRoot(props) {
96
99
  "serverApiKey",
97
100
  "appOrigin",
98
101
  "initialAssignments",
102
+ "timeoutMs",
99
103
  "children"
100
104
  ]);
101
105
  const headerStore = await headers();
@@ -117,7 +121,8 @@ async function AdaptiveRoot(props) {
117
121
  baseUrl: DEFAULT_API_BASE_URL,
118
122
  origin: resolvedOrigin,
119
123
  userAgent,
120
- referer
124
+ referer,
125
+ timeoutMs
121
126
  });
122
127
  initialAssignments = decision.assignments;
123
128
  initialLayoutOrder = decision.layoutOrder;
@@ -128,7 +133,8 @@ async function AdaptiveRoot(props) {
128
133
  baseUrl: DEFAULT_API_BASE_URL,
129
134
  origin: resolvedOrigin,
130
135
  userAgent,
131
- referer
136
+ referer,
137
+ timeoutMs
132
138
  });
133
139
  }
134
140
  return /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/next/adaptive-root.tsx","../../src/server.ts"],"sourcesContent":["import { deriveSessionSegment } from '@sentientui/core';\nimport { cookies, headers } from 'next/headers';\nimport type { ReactNode } from 'react';\nimport type { AdaptiveProviderProps } from '../provider.js';\nimport {\n loadAdaptiveAssignments,\n loadAdaptiveDecision,\n type ServerAssignments,\n} from '../server.js';\nimport { AdaptiveRootClient } from './adaptive-root-client.js';\n\nconst DEFAULT_API_BASE_URL = 'https://sentient-api.fly.dev/v1';\n\nexport type PreloadComponent = { id: string; variantIds: string[] };\n\nexport type AdaptiveRootProps = Omit<AdaptiveProviderProps, 'initialAssignments'> & {\n /** Components to assign server-side (SEO-safe). */\n components: PreloadComponent[];\n /**\n * Declare page section IDs in their default order. When provided,\n * AdaptiveRoot calls `/v1/decide` (single round trip) instead of\n * individual `/v1/assign` calls, and `useLayoutOrder()` returns the\n * persona-specific order on first render.\n *\n * @example sections={['hero', 'pricing', 'features', 'social_proof']}\n */\n sections?: string[];\n /** Server-only API key for `/v1/sessions`, `/v1/assign`, and `/v1/decide`. */\n serverApiKey: string;\n /** App origin — must be in the project's `allowed_origins`. */\n appOrigin?: string;\n /** Override: when set no network fetch is made. Useful for tests. */\n initialAssignments?: ServerAssignments;\n children: ReactNode;\n};\n\n/**\n * Next.js Server Component that resolves variant assignments (and optionally\n * section layout order) server-side for zero layout shift on first paint.\n *\n * When `sections` is provided, a single `POST /v1/decide` call returns both\n * the persona-specific section order and all component assignments.\n * Without `sections`, individual `/v1/assign` calls are made per component.\n *\n * @example\n * // app/page.tsx — with section layout\n * import { AdaptiveRoot } from '@sentientui/react/next';\n *\n * export default async function Page() {\n * return (\n * <AdaptiveRoot\n * apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY!}\n * serverApiKey={process.env.SENTIENT_SECRET_KEY!}\n * context={{ appId: 'my-app' }}\n * sections={['hero', 'pricing', 'features', 'social_proof']}\n * components={[\n * { id: 'hero_cta', variantIds: ['default', 'accent'] },\n * ]}\n * >\n * <HeroSection />\n * <PricingSection />\n * <FeaturesSection />\n * <SocialProofSection />\n * </AdaptiveRoot>\n * );\n * }\n */\nexport async function AdaptiveRoot(props: AdaptiveRootProps): Promise<JSX.Element> {\n const {\n components,\n sections,\n serverApiKey,\n appOrigin,\n initialAssignments: initialAssignmentsOverride,\n children,\n ...providerProps\n } = props;\n\n const headerStore = await headers();\n const resolvedOrigin = appOrigin ?? 'http://localhost:3001';\n const userAgent = headerStore.get('user-agent') ?? undefined;\n const referer = headerStore.get('referer') ?? undefined;\n const sessionSegment = deriveSessionSegment({ userAgent, referer, appOrigin: resolvedOrigin });\n const cookieStore = await cookies();\n\n let initialAssignments: ServerAssignments;\n let initialLayoutOrder: string[] | null = null;\n\n if (initialAssignmentsOverride) {\n initialAssignments = initialAssignmentsOverride;\n } else if (sections && sections.length > 0) {\n const decision = await loadAdaptiveDecision({\n sections,\n components,\n cookies: cookieStore,\n apiKey: serverApiKey,\n baseUrl: DEFAULT_API_BASE_URL,\n origin: resolvedOrigin,\n userAgent,\n referer,\n });\n initialAssignments = decision.assignments;\n initialLayoutOrder = decision.layoutOrder;\n } else {\n initialAssignments = await loadAdaptiveAssignments(components, {\n cookies: cookieStore,\n apiKey: serverApiKey,\n baseUrl: DEFAULT_API_BASE_URL,\n origin: resolvedOrigin,\n userAgent,\n referer,\n });\n }\n\n return (\n <AdaptiveRootClient\n {...providerProps}\n initialAssignments={initialAssignments}\n initialLayoutOrder={initialLayoutOrder}\n sessionSegment={sessionSegment}\n >\n {children}\n </AdaptiveRootClient>\n );\n}\n","/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass the result as `initialAssignments` on `<AdaptiveProvider>`.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<ServerAssignments> {\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n });\n}\n\nexport { preloadDecisions, type DecideResult } from '@sentientui/core';\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /** Section IDs in default order. Passed to /v1/decide as the candidate layout. */\n sections: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n};\n\n/**\n * SSR helper for pages with a declared section layout. Calls `/v1/decide`\n * instead of multiple `/v1/assign` round trips.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<import('@sentientui/core').DecideResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core');\n\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,4BAA4B;AACrC,SAAS,SAAS,eAAe;;;ACEjC;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAiDP,SAAS,wBAA2C;AA7BpD,SAAS,mBAA2B;AAClC,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,OAAO,WAAW;AAAA,EAC3B;AACA,SAAO,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACrE;AAMA,eAAsB,wBACpB,YACA,SAC4B;AA1C9B;AA2CE,QAAM,aACJ,6BAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAO,mBAAmB,YAAY,WAAW;AAAA,IAC/C,QAAQ,QAAQ;AAAA,IAChB,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,WAAW,QAAQ;AAAA,IACnB,SAAS,QAAQ;AAAA,EACnB,CAAC;AACH;AAeA,eAAsB,qBACpB,SACkD;AAxEpD;AAyEE,QAAM,EAAE,kBAAAA,mBAAkB,mBAAAC,mBAAkB,IAAI,MAAM,OAAO,kBAAkB;AAE/E,QAAM,aACJ,WAAAA,mBAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAOD;AAAA,IACL;AAAA,MACE,UAAU,QAAQ;AAAA,MAClB,aAAY,aAAQ,eAAR,YAAsB,CAAC;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ;AAAA,MACjB,QAAQ,QAAQ;AAAA,MAChB,WAAW,QAAQ;AAAA,MACnB,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AACF;;;ADrFA,SAAS,0BAA0B;AA0G/B;AAxGJ,IAAM,uBAAuB;AAwD7B,eAAsB,aAAa,OAAgD;AAnEnF;AAoEE,QAQI,YAPF;AAAA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,oBAAoB;AAAA,IACpB;AAAA,EA1EJ,IA4EM,IADC,0BACD,IADC;AAAA,IANH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAIF,QAAM,cAAc,MAAM,QAAQ;AAClC,QAAM,iBAAiB,gCAAa;AACpC,QAAM,aAAY,iBAAY,IAAI,YAAY,MAA5B,YAAiC;AACnD,QAAM,WAAU,iBAAY,IAAI,SAAS,MAAzB,YAA8B;AAC9C,QAAM,iBAAiB,qBAAqB,EAAE,WAAW,SAAS,WAAW,eAAe,CAAC;AAC7F,QAAM,cAAc,MAAM,QAAQ;AAElC,MAAI;AACJ,MAAI,qBAAsC;AAE1C,MAAI,4BAA4B;AAC9B,yBAAqB;AAAA,EACvB,WAAW,YAAY,SAAS,SAAS,GAAG;AAC1C,UAAM,WAAW,MAAM,qBAAqB;AAAA,MAC1C;AAAA,MACA;AAAA,MACA,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,IACF,CAAC;AACD,yBAAqB,SAAS;AAC9B,yBAAqB,SAAS;AAAA,EAChC,OAAO;AACL,yBAAqB,MAAM,wBAAwB,YAAY;AAAA,MAC7D,SAAS;AAAA,MACT,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SACE;AAAA,IAAC;AAAA,qCACK,gBADL;AAAA,MAEC;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACH;AAEJ;","names":["preloadDecisions","readSessionCookie"]}
1
+ {"version":3,"sources":["../../src/next/adaptive-root.tsx","../../src/server.ts"],"sourcesContent":["import { deriveSessionSegment } from '@sentientui/core';\nimport { cookies, headers } from 'next/headers';\nimport type { ReactNode } from 'react';\nimport type { AdaptiveProviderProps } from '../provider.js';\nimport {\n loadAdaptiveAssignments,\n loadAdaptiveDecision,\n type ServerAssignments,\n} from '../server.js';\nimport { AdaptiveRootClient } from './adaptive-root-client.js';\n\nconst DEFAULT_API_BASE_URL = 'https://sentient-api.fly.dev/v1';\n\nexport type PreloadComponent = { id: string; variantIds: string[] };\n\nexport type AdaptiveRootProps = Omit<AdaptiveProviderProps, 'initialAssignments'> & {\n /** Components to assign server-side (SEO-safe). */\n components: PreloadComponent[];\n /**\n * Declare page section IDs in their default order. When provided,\n * AdaptiveRoot calls `/v1/decide` (single round trip) instead of\n * individual `/v1/assign` calls, and `useLayoutOrder()` returns the\n * persona-specific order on first render.\n *\n * @example sections={['hero', 'pricing', 'features', 'social_proof']}\n */\n sections?: string[];\n /** Server-only API key for `/v1/sessions`, `/v1/assign`, and `/v1/decide`. */\n serverApiKey: string;\n /** App origin — must be in the project's `allowed_origins`. */\n appOrigin?: string;\n /** Override: when set no network fetch is made. Useful for tests. */\n initialAssignments?: ServerAssignments;\n /**\n * Milliseconds to wait for the API before rendering default variants.\n * Defaults to 1500. Increase if you see unexpected fallbacks in production.\n */\n timeoutMs?: number;\n children: ReactNode;\n};\n\n/**\n * Next.js Server Component that resolves variant assignments (and optionally\n * section layout order) server-side for zero layout shift on first paint.\n *\n * When `sections` is provided, a single `POST /v1/decide` call returns both\n * the persona-specific section order and all component assignments.\n * Without `sections`, individual `/v1/assign` calls are made per component.\n *\n * @example\n * // app/page.tsx — with section layout\n * import { AdaptiveRoot } from '@sentientui/react/next';\n *\n * export default async function Page() {\n * return (\n * <AdaptiveRoot\n * apiKey={process.env.NEXT_PUBLIC_SENTIENT_API_KEY!}\n * serverApiKey={process.env.SENTIENT_SECRET_KEY!}\n * context={{ appId: 'my-app' }}\n * sections={['hero', 'pricing', 'features', 'social_proof']}\n * components={[\n * { id: 'hero_cta', variantIds: ['default', 'accent'] },\n * ]}\n * >\n * <HeroSection />\n * <PricingSection />\n * <FeaturesSection />\n * <SocialProofSection />\n * </AdaptiveRoot>\n * );\n * }\n */\nexport async function AdaptiveRoot(props: AdaptiveRootProps): Promise<JSX.Element> {\n const {\n components,\n sections,\n serverApiKey,\n appOrigin,\n initialAssignments: initialAssignmentsOverride,\n timeoutMs,\n children,\n ...providerProps\n } = props;\n\n const headerStore = await headers();\n const resolvedOrigin = appOrigin ?? 'http://localhost:3001';\n const userAgent = headerStore.get('user-agent') ?? undefined;\n const referer = headerStore.get('referer') ?? undefined;\n const sessionSegment = deriveSessionSegment({ userAgent, referer, appOrigin: resolvedOrigin });\n const cookieStore = await cookies();\n\n let initialAssignments: ServerAssignments;\n let initialLayoutOrder: string[] | null = null;\n\n if (initialAssignmentsOverride) {\n initialAssignments = initialAssignmentsOverride;\n } else if (sections && sections.length > 0) {\n const decision = await loadAdaptiveDecision({\n sections,\n components,\n cookies: cookieStore,\n apiKey: serverApiKey,\n baseUrl: DEFAULT_API_BASE_URL,\n origin: resolvedOrigin,\n userAgent,\n referer,\n timeoutMs,\n });\n initialAssignments = decision.assignments;\n initialLayoutOrder = decision.layoutOrder;\n } else {\n initialAssignments = await loadAdaptiveAssignments(components, {\n cookies: cookieStore,\n apiKey: serverApiKey,\n baseUrl: DEFAULT_API_BASE_URL,\n origin: resolvedOrigin,\n userAgent,\n referer,\n timeoutMs,\n });\n }\n\n return (\n <AdaptiveRootClient\n {...providerProps}\n initialAssignments={initialAssignments}\n initialLayoutOrder={initialLayoutOrder}\n sessionSegment={sessionSegment}\n >\n {children}\n </AdaptiveRootClient>\n );\n}\n","/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n /** Milliseconds to wait for the API before returning default variants. Defaults to 1500. */\n timeoutMs?: number;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass the result as `initialAssignments` on `<AdaptiveProvider>`.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<ServerAssignments> {\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n timeoutMs: options.timeoutMs,\n });\n}\n\nexport { preloadDecisions, type DecideResult } from '@sentientui/core';\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /** Section IDs in default order. Passed to /v1/decide as the candidate layout. */\n sections: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n};\n\n/**\n * SSR helper for pages with a declared section layout. Calls `/v1/decide`\n * instead of multiple `/v1/assign` round trips.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<import('@sentientui/core').DecideResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core');\n\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n timeoutMs: options.timeoutMs,\n },\n );\n}\n"],"mappings":"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","names":["preloadDecisions","readSessionCookie"]}
package/dist/server.d.cts CHANGED
@@ -19,6 +19,8 @@ type LoadAdaptiveAssignmentsOptions = {
19
19
  userAgent?: string;
20
20
  /** From Next.js `headers().get('referer')`. */
21
21
  referer?: string;
22
+ /** Milliseconds to wait for the API before returning default variants. Defaults to 1500. */
23
+ timeoutMs?: number;
22
24
  };
23
25
  /**
24
26
  * Fetches bandit assignments on the server for SEO-safe HTML.
package/dist/server.d.ts CHANGED
@@ -19,6 +19,8 @@ type LoadAdaptiveAssignmentsOptions = {
19
19
  userAgent?: string;
20
20
  /** From Next.js `headers().get('referer')`. */
21
21
  referer?: string;
22
+ /** Milliseconds to wait for the API before returning default variants. Defaults to 1500. */
23
+ timeoutMs?: number;
22
24
  };
23
25
  /**
24
26
  * Fetches bandit assignments on the server for SEO-safe HTML.
package/dist/server.js CHANGED
@@ -53,7 +53,8 @@ async function loadAdaptiveAssignments(components, options) {
53
53
  baseUrl: options.baseUrl,
54
54
  origin: options.origin,
55
55
  userAgent: options.userAgent,
56
- referer: options.referer
56
+ referer: options.referer,
57
+ timeoutMs: options.timeoutMs
57
58
  });
58
59
  }
59
60
  async function loadAdaptiveDecision(options) {
@@ -71,7 +72,8 @@ async function loadAdaptiveDecision(options) {
71
72
  baseUrl: options.baseUrl,
72
73
  origin: options.origin,
73
74
  userAgent: options.userAgent,
74
- referer: options.referer
75
+ referer: options.referer,
76
+ timeoutMs: options.timeoutMs
75
77
  }
76
78
  );
77
79
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass the result as `initialAssignments` on `<AdaptiveProvider>`.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<ServerAssignments> {\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n });\n}\n\nexport { preloadDecisions, type DecideResult } from '@sentientui/core';\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /** Section IDs in default order. Passed to /v1/decide as the candidate layout. */\n sections: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n};\n\n/**\n * SSR helper for pages with a declared section layout. Calls `/v1/decide`\n * instead of multiple `/v1/assign` round trips.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<import('@sentientui/core').DecideResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core');\n\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAKO;AAiDP,IAAAA,eAAoD;AA7BpD,SAAS,mBAA2B;AAClC,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,OAAO,WAAW;AAAA,EAC3B;AACA,SAAO,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACrE;AAMA,eAAsB,wBACpB,YACA,SAC4B;AA1C9B;AA2CE,QAAM,aACJ,8CAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,aAAO,gCAAmB,YAAY,WAAW;AAAA,IAC/C,QAAQ,QAAQ;AAAA,IAChB,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,WAAW,QAAQ;AAAA,IACnB,SAAS,QAAQ;AAAA,EACnB,CAAC;AACH;AAeA,eAAsB,qBACpB,SACkD;AAxEpD;AAyEE,QAAM,EAAE,kBAAAC,mBAAkB,mBAAAC,mBAAkB,IAAI,MAAM,OAAO,kBAAkB;AAE/E,QAAM,aACJ,WAAAA,mBAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAOD;AAAA,IACL;AAAA,MACE,UAAU,QAAQ;AAAA,MAClB,aAAY,aAAQ,eAAR,YAAsB,CAAC;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ;AAAA,MACjB,QAAQ,QAAQ;AAAA,MAChB,WAAW,QAAQ;AAAA,MACnB,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AACF;","names":["import_core","preloadDecisions","readSessionCookie"]}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n /** Milliseconds to wait for the API before returning default variants. Defaults to 1500. */\n timeoutMs?: number;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass the result as `initialAssignments` on `<AdaptiveProvider>`.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<ServerAssignments> {\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n timeoutMs: options.timeoutMs,\n });\n}\n\nexport { preloadDecisions, type DecideResult } from '@sentientui/core';\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /** Section IDs in default order. Passed to /v1/decide as the candidate layout. */\n sections: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n};\n\n/**\n * SSR helper for pages with a declared section layout. Calls `/v1/decide`\n * instead of multiple `/v1/assign` round trips.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<import('@sentientui/core').DecideResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core');\n\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n timeoutMs: options.timeoutMs,\n },\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAKO;AAoDP,IAAAA,eAAoD;AA9BpD,SAAS,mBAA2B;AAClC,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,OAAO,WAAW;AAAA,EAC3B;AACA,SAAO,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACrE;AAMA,eAAsB,wBACpB,YACA,SAC4B;AA5C9B;AA6CE,QAAM,aACJ,8CAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,aAAO,gCAAmB,YAAY,WAAW;AAAA,IAC/C,QAAQ,QAAQ;AAAA,IAChB,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,WAAW,QAAQ;AAAA,IACnB,SAAS,QAAQ;AAAA,IACjB,WAAW,QAAQ;AAAA,EACrB,CAAC;AACH;AAeA,eAAsB,qBACpB,SACkD;AA3EpD;AA4EE,QAAM,EAAE,kBAAAC,mBAAkB,mBAAAC,mBAAkB,IAAI,MAAM,OAAO,kBAAkB;AAE/E,QAAM,aACJ,WAAAA,mBAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAOD;AAAA,IACL;AAAA,MACE,UAAU,QAAQ;AAAA,MAClB,aAAY,aAAQ,eAAR,YAAsB,CAAC;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ;AAAA,MACjB,QAAQ,QAAQ;AAAA,MAChB,WAAW,QAAQ;AAAA,MACnB,SAAS,QAAQ;AAAA,MACjB,WAAW,QAAQ;AAAA,IACrB;AAAA,EACF;AACF;","names":["import_core","preloadDecisions","readSessionCookie"]}
package/dist/server.mjs CHANGED
@@ -18,7 +18,8 @@ async function loadAdaptiveAssignments(components, options) {
18
18
  baseUrl: options.baseUrl,
19
19
  origin: options.origin,
20
20
  userAgent: options.userAgent,
21
- referer: options.referer
21
+ referer: options.referer,
22
+ timeoutMs: options.timeoutMs
22
23
  });
23
24
  }
24
25
  async function loadAdaptiveDecision(options) {
@@ -36,7 +37,8 @@ async function loadAdaptiveDecision(options) {
36
37
  baseUrl: options.baseUrl,
37
38
  origin: options.origin,
38
39
  userAgent: options.userAgent,
39
- referer: options.referer
40
+ referer: options.referer,
41
+ timeoutMs: options.timeoutMs
40
42
  }
41
43
  );
42
44
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts"],"sourcesContent":["/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass the result as `initialAssignments` on `<AdaptiveProvider>`.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<ServerAssignments> {\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n });\n}\n\nexport { preloadDecisions, type DecideResult } from '@sentientui/core';\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /** Section IDs in default order. Passed to /v1/decide as the candidate layout. */\n sections: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n};\n\n/**\n * SSR helper for pages with a declared section layout. Calls `/v1/decide`\n * instead of multiple `/v1/assign` round trips.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<import('@sentientui/core').DecideResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core');\n\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n },\n );\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAiDP,SAAS,wBAA2C;AA7BpD,SAAS,mBAA2B;AAClC,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,OAAO,WAAW;AAAA,EAC3B;AACA,SAAO,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACrE;AAMA,eAAsB,wBACpB,YACA,SAC4B;AA1C9B;AA2CE,QAAM,aACJ,6BAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAO,mBAAmB,YAAY,WAAW;AAAA,IAC/C,QAAQ,QAAQ;AAAA,IAChB,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,WAAW,QAAQ;AAAA,IACnB,SAAS,QAAQ;AAAA,EACnB,CAAC;AACH;AAeA,eAAsB,qBACpB,SACkD;AAxEpD;AAyEE,QAAM,EAAE,kBAAAA,mBAAkB,mBAAAC,mBAAkB,IAAI,MAAM,OAAO,kBAAkB;AAE/E,QAAM,aACJ,WAAAA,mBAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAOD;AAAA,IACL;AAAA,MACE,UAAU,QAAQ;AAAA,MAClB,aAAY,aAAQ,eAAR,YAAsB,CAAC;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ;AAAA,MACjB,QAAQ,QAAQ;AAAA,MAChB,WAAW,QAAQ;AAAA,MACnB,SAAS,QAAQ;AAAA,IACnB;AAAA,EACF;AACF;","names":["preloadDecisions","readSessionCookie"]}
1
+ {"version":3,"sources":["../src/server.ts"],"sourcesContent":["/**\n * Server-only helpers for Next.js / SSR. No React or DOM APIs.\n */\nimport {\n preloadAssignments,\n readSessionCookie,\n type ServerAssignConfig,\n type ServerAssignments,\n} from '@sentientui/core';\n\nexport { preloadAssignments, readSessionCookie };\nexport type { ServerAssignConfig, ServerAssignments };\n\nexport type LoadAdaptiveAssignmentsOptions = {\n /** Next.js `cookies()` return value, or any object with `get(name)`. */\n cookies: { get(name: string): { value: string } | undefined };\n apiKey: string;\n baseUrl: string;\n /** Used when `_snt_uid` is absent (e.g. first visit, many crawlers). */\n createSessionId?: () => string;\n /** Must match a value in the project's `allowed_origins` (e.g. `http://localhost:3001`). */\n origin?: string;\n /** From Next.js `headers().get('user-agent')` — aligns SSR segment with the client. */\n userAgent?: string;\n /** From Next.js `headers().get('referer')`. */\n referer?: string;\n /** Milliseconds to wait for the API before returning default variants. Defaults to 1500. */\n timeoutMs?: number;\n};\n\nfunction defaultSessionId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `snt-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;\n}\n\n/**\n * Fetches bandit assignments on the server for SEO-safe HTML.\n * Pass the result as `initialAssignments` on `<AdaptiveProvider>`.\n */\nexport async function loadAdaptiveAssignments(\n components: Array<{ id: string; variantIds: string[] }>,\n options: LoadAdaptiveAssignmentsOptions,\n): Promise<ServerAssignments> {\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadAssignments(components, sessionId, {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n timeoutMs: options.timeoutMs,\n });\n}\n\nexport { preloadDecisions, type DecideResult } from '@sentientui/core';\n\nexport type LoadAdaptiveDecisionOptions = LoadAdaptiveAssignmentsOptions & {\n /** Section IDs in default order. Passed to /v1/decide as the candidate layout. */\n sections: string[];\n /** Components to assign in the same decide call. */\n components?: Array<{ id: string; variantIds?: string[] }>;\n};\n\n/**\n * SSR helper for pages with a declared section layout. Calls `/v1/decide`\n * instead of multiple `/v1/assign` round trips.\n */\nexport async function loadAdaptiveDecision(\n options: LoadAdaptiveDecisionOptions,\n): Promise<import('@sentientui/core').DecideResult> {\n const { preloadDecisions, readSessionCookie } = await import('@sentientui/core');\n\n const sessionId =\n readSessionCookie(options.cookies) ??\n options.createSessionId?.() ??\n defaultSessionId();\n\n return preloadDecisions(\n {\n sections: options.sections,\n components: options.components ?? [],\n },\n sessionId,\n {\n apiKey: options.apiKey,\n baseUrl: options.baseUrl,\n origin: options.origin,\n userAgent: options.userAgent,\n referer: options.referer,\n timeoutMs: options.timeoutMs,\n },\n );\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAoDP,SAAS,wBAA2C;AA9BpD,SAAS,mBAA2B;AAClC,MAAI,OAAO,WAAW,eAAe,OAAO,OAAO,eAAe,YAAY;AAC5E,WAAO,OAAO,WAAW;AAAA,EAC3B;AACA,SAAO,OAAO,KAAK,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,EAAE,CAAC;AACrE;AAMA,eAAsB,wBACpB,YACA,SAC4B;AA5C9B;AA6CE,QAAM,aACJ,6BAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAO,mBAAmB,YAAY,WAAW;AAAA,IAC/C,QAAQ,QAAQ;AAAA,IAChB,SAAS,QAAQ;AAAA,IACjB,QAAQ,QAAQ;AAAA,IAChB,WAAW,QAAQ;AAAA,IACnB,SAAS,QAAQ;AAAA,IACjB,WAAW,QAAQ;AAAA,EACrB,CAAC;AACH;AAeA,eAAsB,qBACpB,SACkD;AA3EpD;AA4EE,QAAM,EAAE,kBAAAA,mBAAkB,mBAAAC,mBAAkB,IAAI,MAAM,OAAO,kBAAkB;AAE/E,QAAM,aACJ,WAAAA,mBAAkB,QAAQ,OAAO,MAAjC,aACA,aAAQ,oBAAR,qCADA,YAEA,iBAAiB;AAEnB,SAAOD;AAAA,IACL;AAAA,MACE,UAAU,QAAQ;AAAA,MAClB,aAAY,aAAQ,eAAR,YAAsB,CAAC;AAAA,IACrC;AAAA,IACA;AAAA,IACA;AAAA,MACE,QAAQ,QAAQ;AAAA,MAChB,SAAS,QAAQ;AAAA,MACjB,QAAQ,QAAQ;AAAA,MAChB,WAAW,QAAQ;AAAA,MACnB,SAAS,QAAQ;AAAA,MACjB,WAAW,QAAQ;AAAA,IACrB;AAAA,EACF;AACF;","names":["preloadDecisions","readSessionCookie"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentientui/react",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",