@bitbitpress/client 1.1.0-alpha.0 → 1.1.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.
- package/README.md +235 -10
- package/dist/generated/openapi.d.ts +6 -3
- package/dist/react/index.d.ts +25 -6
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +26 -9
- package/dist/react/index.js.map +1 -1
- package/dist/react-native-expo/index.d.ts +20 -9
- package/dist/react-native-expo/index.d.ts.map +1 -1
- package/dist/react-native-expo/index.js +25 -11
- package/dist/react-native-expo/index.js.map +1 -1
- package/dist/synthesisView/devLog.d.ts +10 -0
- package/dist/synthesisView/devLog.d.ts.map +1 -0
- package/dist/synthesisView/devLog.js +23 -0
- package/dist/synthesisView/devLog.js.map +1 -0
- package/dist/synthesisView/engine.js +27 -1
- package/dist/synthesisView/engine.js.map +1 -1
- package/dist/synthesisView/types.d.ts +50 -1
- package/dist/synthesisView/types.d.ts.map +1 -1
- package/dist/synthesisView/useEventDrivenView.d.ts +32 -0
- package/dist/synthesisView/useEventDrivenView.d.ts.map +1 -0
- package/dist/synthesisView/useEventDrivenView.js +157 -0
- package/dist/synthesisView/useEventDrivenView.js.map +1 -0
- package/dist/user/synthesize-batch-manager.js +1 -0
- package/dist/user/synthesize-batch-manager.js.map +1 -1
- package/dist/user/synthesize.d.ts +14 -3
- package/dist/user/synthesize.d.ts.map +1 -1
- package/dist/user/synthesize.js +1 -1
- package/dist/user/synthesize.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -554,12 +554,12 @@ client.user.synthesizeItem(
|
|
|
554
554
|
|
|
555
555
|
##### Parameters
|
|
556
556
|
|
|
557
|
-
- `item` (required): A single synthesize item (same shape as items in `synthesize`): `inputs`, `output` (schema as JSON string or Zod 4 schema), optional `configurationKeyName`, optional `
|
|
557
|
+
- `item` (required): A single synthesize item (same shape as items in `synthesize`): `inputs`, `output` (schema as JSON string or Zod 4 schema), optional `configurationKeyName`, optional `synthesisHistoryLimit` (how many recent stored outputs to expose in `synthesisHistory`; defaults to `0` — no history emitted), optional `searchOptionsOverrides` (e.g. `{ lookbackMinutes: 1440 }` for 24-hour lookback)
|
|
558
558
|
- `onStreamingData` (optional): Callback invoked with streaming data whenever a stream event has `complete: false` for this item. Type: `(data: unknown) => void`.
|
|
559
559
|
|
|
560
560
|
##### Returns
|
|
561
561
|
|
|
562
|
-
- `Promise<SynthesizeItemResponse>`: Resolves with the final data event for this item — `data` is the synthesized object (keys match your output schema) when present; `error` is set on failure
|
|
562
|
+
- `Promise<SynthesizeItemResponse>`: Resolves with the final data event for this item — `data` is the synthesized object (keys match your output schema) when present; `synthesisHistory` is an array of recent stored `data` payloads when `synthesisHistoryLimit > 0` (most-recent first; the first entry is the current synthesis itself); `error` is set on failure
|
|
563
563
|
|
|
564
564
|
##### Behavior
|
|
565
565
|
|
|
@@ -614,7 +614,7 @@ client.user.synthesize(
|
|
|
614
614
|
- `inputs` (optional): Context for synthesis — array of `{ type: "externalId" | "text" | "excludeExternalIds", value: string }` (article ID, freeform text, or comma-separated external IDs to exclude)
|
|
615
615
|
- `output`: `{ schema: string | ZodType }` — output schema as a JSON string or Zod 4 schema (top-level type must be `"object"`; supports object, string, number, boolean, array, and enum)
|
|
616
616
|
- `configurationKeyName` (optional): Key name for configuration
|
|
617
|
-
- `
|
|
617
|
+
- `synthesisHistoryLimit` (optional): How many recent stored synthesis outputs to expose in the final data event's `synthesisHistory` field. Defaults to `0` (no history emitted). When `> 0`, the final event includes a `synthesisHistory` array of up to N `data` payloads (most-recent first; first entry is the current synthesis itself).
|
|
618
618
|
- `searchOptionsOverrides` (optional): Per-request overrides, e.g. `{ lookbackMinutes: 1440 }` for 24-hour lookback.
|
|
619
619
|
- `options` (optional): `{ onStreamingData?: (index: number, data: unknown) => void }` — if provided, `onStreamingData` is called for each data event with `complete: false`, with the item's index and streaming data
|
|
620
620
|
|
|
@@ -626,7 +626,7 @@ client.user.synthesize(
|
|
|
626
626
|
|
|
627
627
|
- `{ type: "connected" }`: Connection established
|
|
628
628
|
- `{ type: "complete" }`: Stream complete
|
|
629
|
-
- `{ index, data?, complete, error? }`: Data event for that item. Multiple events may be sent per index as partial updates; the final event has `complete: true` and the validated object. When `complete` is false, `data` is streaming data (partial object). `error` is set on failure.
|
|
629
|
+
- `{ index, data?, synthesisHistory?, complete, error? }`: Data event for that item. Multiple events may be sent per index as partial updates; the final event has `complete: true` and the validated object. When `complete` is false, `data` is streaming data (partial object). `synthesisHistory` (only on the final event, only when `synthesisHistoryLimit > 0`) is an array of recent stored `data` payloads, most-recent first. `error` is set on failure.
|
|
630
630
|
|
|
631
631
|
##### Example
|
|
632
632
|
|
|
@@ -995,13 +995,13 @@ type SignalResponse = {
|
|
|
995
995
|
|
|
996
996
|
#### SynthesizeRequest
|
|
997
997
|
|
|
998
|
-
Request body for POST `/v1/user/synthesize` (from OpenAPI). Each item has `inputs`, `output`, optional `configurationKeyName`, optional `
|
|
998
|
+
Request body for POST `/v1/user/synthesize` (from OpenAPI). Each item has `inputs`, `output`, optional `configurationKeyName`, optional `synthesisHistoryLimit` (defaults to `0`), and optional `searchOptionsOverrides`.
|
|
999
999
|
|
|
1000
1000
|
```typescript
|
|
1001
1001
|
type SynthesizeRequest = {
|
|
1002
1002
|
items: Array<{
|
|
1003
1003
|
configurationKeyName?: string;
|
|
1004
|
-
|
|
1004
|
+
synthesisHistoryLimit?: number; // how many recent stored outputs to include in synthesisHistory; defaults to 0 (no history emitted)
|
|
1005
1005
|
searchOptionsOverrides?: { lookbackMinutes?: number };
|
|
1006
1006
|
inputs?: Array<{ type: 'externalId' | 'text' | 'excludeExternalIds'; value: string }>;
|
|
1007
1007
|
output: {
|
|
@@ -1027,10 +1027,10 @@ Stream events (SSE). Connection events use `type`; data events use `index`, opti
|
|
|
1027
1027
|
type SynthesizeEvent =
|
|
1028
1028
|
| { type: 'connected' }
|
|
1029
1029
|
| { type: 'complete' }
|
|
1030
|
-
| { index: number; data?: unknown; complete: boolean; error?: string };
|
|
1030
|
+
| { index: number; data?: unknown; synthesisHistory?: unknown[]; complete: boolean; error?: string };
|
|
1031
1031
|
```
|
|
1032
1032
|
|
|
1033
|
-
When `complete` is true, `data` is the full synthesized object (keys match your output schema). When `complete` is false, `data` is streaming data (partial update). `error` is set on failure.
|
|
1033
|
+
When `complete` is true, `data` is the full synthesized object (keys match your output schema). When `complete` is false, `data` is streaming data (partial update). When the request set `synthesisHistoryLimit > 0`, the final event also includes `synthesisHistory`: an array of recent stored `data` payloads (most-recent first; first entry is the current synthesis itself — identical to `data` unless user reranking is configured server-side). `error` is set on failure.
|
|
1034
1034
|
|
|
1035
1035
|
#### SynthesizeItemResponse
|
|
1036
1036
|
|
|
@@ -1038,8 +1038,9 @@ Return type of `synthesizeItem`. Same shape as a data event payload (without `in
|
|
|
1038
1038
|
|
|
1039
1039
|
```typescript
|
|
1040
1040
|
type SynthesizeItemResponse = {
|
|
1041
|
-
data?: unknown;
|
|
1042
|
-
|
|
1041
|
+
data?: unknown; // synthesized object when present
|
|
1042
|
+
synthesisHistory?: unknown[]; // recent stored outputs when synthesisHistoryLimit > 0; most-recent first
|
|
1043
|
+
error?: string; // set on failure
|
|
1043
1044
|
};
|
|
1044
1045
|
```
|
|
1045
1046
|
|
|
@@ -1141,3 +1142,227 @@ type InteractionResponseResponse = {
|
|
|
1141
1142
|
appUserResponse: Record<string, unknown>;
|
|
1142
1143
|
}
|
|
1143
1144
|
```
|
|
1145
|
+
|
|
1146
|
+
## Synthesis Views
|
|
1147
|
+
|
|
1148
|
+
A **synthesis view** is a UI that BitBit Press generates on the server for a
|
|
1149
|
+
named placement in your app (a feed card, a detail panel, a settings
|
|
1150
|
+
screen, etc.). You set up the view once in the BitBit CMS — choose a key
|
|
1151
|
+
name, write a prompt, point it at a synthesis config. Then in your app you
|
|
1152
|
+
mount it like this:
|
|
1153
|
+
|
|
1154
|
+
```tsx
|
|
1155
|
+
<BitBitView client={client} keyName="story-card" />
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
The SDK fetches the generated UI, renders it using a small library of
|
|
1159
|
+
built-in primitives (`Row`, `Column`, `Text`, `Image`, `Button`, etc.), and
|
|
1160
|
+
splices in any of your own React components you've registered. As the user
|
|
1161
|
+
interacts with the UI, the SDK either routes the event to you (so your app
|
|
1162
|
+
handles navigation, mutations, etc.) or sends it back to the server so the
|
|
1163
|
+
agent can generate the next UI.
|
|
1164
|
+
|
|
1165
|
+
The same surface is exported from both `@bitbitpress/client/react` and
|
|
1166
|
+
`@bitbitpress/client/react-native-expo`. This section uses the web names;
|
|
1167
|
+
the Expo entry is identical.
|
|
1168
|
+
|
|
1169
|
+
### Quick start
|
|
1170
|
+
|
|
1171
|
+
```tsx
|
|
1172
|
+
import { BitBitView } from '@bitbitpress/client/react';
|
|
1173
|
+
import client from '@/lib/bitbit-client';
|
|
1174
|
+
import { MyCard } from '@/components/my-card';
|
|
1175
|
+
|
|
1176
|
+
export function Feed({ keyName }: { keyName: string }) {
|
|
1177
|
+
return (
|
|
1178
|
+
<BitBitView
|
|
1179
|
+
client={client}
|
|
1180
|
+
keyName={keyName}
|
|
1181
|
+
components={{ MyCard }}
|
|
1182
|
+
onEvent={(event) => console.log('host event', event)}
|
|
1183
|
+
/>
|
|
1184
|
+
);
|
|
1185
|
+
}
|
|
1186
|
+
```
|
|
1187
|
+
|
|
1188
|
+
That's enough to render any view whose generated UI uses only the SDK's
|
|
1189
|
+
built-in primitives, plus your `MyCard`.
|
|
1190
|
+
|
|
1191
|
+
### Registering your own components
|
|
1192
|
+
|
|
1193
|
+
In the CMS you can register a component as **"provided by your app"** —
|
|
1194
|
+
the server then refers to it by a name like `MyCard` in the generated UI,
|
|
1195
|
+
and the SDK looks it up in your registry to render it. The mapping from
|
|
1196
|
+
name to React component is what you pass in `components`:
|
|
1197
|
+
|
|
1198
|
+
```tsx
|
|
1199
|
+
<BitBitView
|
|
1200
|
+
client={client}
|
|
1201
|
+
keyName="story-card"
|
|
1202
|
+
components={{ MyCard, MyButton, MyAvatar }}
|
|
1203
|
+
/>
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
If you'll use the same component map across many views, register them
|
|
1207
|
+
once at the top of your app with `BitBitProvider` instead. Per-view
|
|
1208
|
+
`components` overrides still apply:
|
|
1209
|
+
|
|
1210
|
+
```tsx
|
|
1211
|
+
import { BitBitProvider } from '@bitbitpress/client/react';
|
|
1212
|
+
|
|
1213
|
+
<BitBitProvider components={{ MyCard, MyButton, MyAvatar }}>
|
|
1214
|
+
<App />
|
|
1215
|
+
</BitBitProvider>
|
|
1216
|
+
```
|
|
1217
|
+
|
|
1218
|
+
Components receive their bound props from the CMS contract you set up,
|
|
1219
|
+
plus a `children` prop when the view nested other components inside
|
|
1220
|
+
them. See [Handling events](#handling-events) below for how to also
|
|
1221
|
+
accept event callbacks.
|
|
1222
|
+
|
|
1223
|
+
### Rendering pre-fetched UI
|
|
1224
|
+
|
|
1225
|
+
If you already have the generated UI as a `uiData` array (for example,
|
|
1226
|
+
you cached the most recent response, or you're rendering a gallery of
|
|
1227
|
+
tiles fetched in one shot), use `BitBitViewRenderer` to skip the fetch:
|
|
1228
|
+
|
|
1229
|
+
```tsx
|
|
1230
|
+
import { BitBitViewRenderer, type FlatUiNode } from '@bitbitpress/client/react';
|
|
1231
|
+
|
|
1232
|
+
export function StaticTile({ uiData }: { uiData: FlatUiNode[] }) {
|
|
1233
|
+
return <BitBitViewRenderer uiData={uiData} components={{ MyCard }} />;
|
|
1234
|
+
}
|
|
1235
|
+
```
|
|
1236
|
+
|
|
1237
|
+
### Handling events
|
|
1238
|
+
|
|
1239
|
+
Each event the view emits has a `handleWith` setting (chosen in the CMS):
|
|
1240
|
+
|
|
1241
|
+
- **`HOST`** — the SDK forwards the event to your `onEvent` callback and
|
|
1242
|
+
does nothing else. Use this for navigation, mutations, anything where
|
|
1243
|
+
your app owns the consequence.
|
|
1244
|
+
- **`AGENT`** — the SDK sends the event back to the synthesis endpoint
|
|
1245
|
+
with the prior UI as context, the agent returns a new UI, and the SDK
|
|
1246
|
+
re-renders with it. Your `onEvent` is **not** called for AGENT events
|
|
1247
|
+
(the handling is internal); they show up in the dev log if you need to
|
|
1248
|
+
observe them. Nodes whose ids appear in both the old and new tree
|
|
1249
|
+
preserve their React state, so a well-behaved view feels like a
|
|
1250
|
+
partial update rather than a full reload.
|
|
1251
|
+
|
|
1252
|
+
```tsx
|
|
1253
|
+
<BitBitView
|
|
1254
|
+
client={client}
|
|
1255
|
+
keyName="story-card"
|
|
1256
|
+
onEvent={(event) => {
|
|
1257
|
+
if (event.name === 'open-detail') {
|
|
1258
|
+
navigation.push('Detail', { id: event.payload.id });
|
|
1259
|
+
}
|
|
1260
|
+
}}
|
|
1261
|
+
/>
|
|
1262
|
+
```
|
|
1263
|
+
|
|
1264
|
+
The event object you receive is:
|
|
1265
|
+
|
|
1266
|
+
```ts
|
|
1267
|
+
{
|
|
1268
|
+
name: string; // identifier from the CMS event binding
|
|
1269
|
+
componentName: string; // name of the component that fired
|
|
1270
|
+
slot: string; // which slot on the component (e.g. 'onClick')
|
|
1271
|
+
payload: object; // anything the binding declared + anything the host passed
|
|
1272
|
+
}
|
|
1273
|
+
```
|
|
1274
|
+
|
|
1275
|
+
The runtime also includes a `nodeId` (the internal id of the rendered
|
|
1276
|
+
instance) and `handleWith` (always `'HOST'` by the time your callback
|
|
1277
|
+
runs). Both are present for debugging and rarely need to be consumed.
|
|
1278
|
+
|
|
1279
|
+
#### Events on your components
|
|
1280
|
+
|
|
1281
|
+
If you registered a component with events in its CMS contract (e.g. an
|
|
1282
|
+
`onClick` slot), the SDK passes a callback for that slot as a prop. Call
|
|
1283
|
+
it from inside your component to fire the event through the BB pipeline,
|
|
1284
|
+
exactly as if it had come from a built-in primitive:
|
|
1285
|
+
|
|
1286
|
+
```tsx
|
|
1287
|
+
function MyCard({
|
|
1288
|
+
title,
|
|
1289
|
+
onClick,
|
|
1290
|
+
}: {
|
|
1291
|
+
title: string;
|
|
1292
|
+
onClick?: (payload?: unknown) => void;
|
|
1293
|
+
}) {
|
|
1294
|
+
return <Pressable onPress={() => onClick?.()}>{title}</Pressable>;
|
|
1295
|
+
}
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
Anything you pass (a plain object) is merged with the payload the CMS
|
|
1299
|
+
binding declared before the event fires.
|
|
1300
|
+
|
|
1301
|
+
### When a component name isn't registered
|
|
1302
|
+
|
|
1303
|
+
If the generated UI references a component name you haven't registered,
|
|
1304
|
+
the SDK falls back to a placeholder. The default behavior depends on
|
|
1305
|
+
your environment:
|
|
1306
|
+
|
|
1307
|
+
- **Development** (`process.env.NODE_ENV !== 'production'`) — renders a
|
|
1308
|
+
labeled marker (`⚠ Unknown component: X`) so you can see what's
|
|
1309
|
+
missing.
|
|
1310
|
+
- **Production** — renders nothing. Avoids visible debug artifacts in
|
|
1311
|
+
real user UIs as you grow the registry over time.
|
|
1312
|
+
|
|
1313
|
+
Override with `renderUnknown`, or set `dev` to force development behavior
|
|
1314
|
+
in environments where `NODE_ENV` doesn't reflect what you want (for
|
|
1315
|
+
example, a CMS preview tool that ships as a production build but should
|
|
1316
|
+
still surface missing components):
|
|
1317
|
+
|
|
1318
|
+
```tsx
|
|
1319
|
+
<BitBitView client={client} keyName={keyName} dev /> // always show warnings
|
|
1320
|
+
<BitBitView
|
|
1321
|
+
client={client}
|
|
1322
|
+
keyName={keyName}
|
|
1323
|
+
renderUnknown={(name) => <YourPlaceholder name={name} />}
|
|
1324
|
+
/>
|
|
1325
|
+
```
|
|
1326
|
+
|
|
1327
|
+
### Performance: speculative preloading
|
|
1328
|
+
|
|
1329
|
+
The SDK can prefetch the next UI for AGENT events whose payload it can
|
|
1330
|
+
predict ahead of time, so the user's click lands on a cached response
|
|
1331
|
+
with no server roundtrip. This is on by default. To disable:
|
|
1332
|
+
|
|
1333
|
+
```tsx
|
|
1334
|
+
<BitBitView client={client} keyName={keyName} preloadNextUi={false} />
|
|
1335
|
+
```
|
|
1336
|
+
|
|
1337
|
+
### Dev diagnostics
|
|
1338
|
+
|
|
1339
|
+
In dev mode (or when you pass `dev={true}`), the SDK prints every event
|
|
1340
|
+
to the console, prefixed with `[BB]`:
|
|
1341
|
+
|
|
1342
|
+
```
|
|
1343
|
+
[BB] event MyCard.onClick → AGENT { name: 'open-detail', payload: { id: '…' }, ... }
|
|
1344
|
+
```
|
|
1345
|
+
|
|
1346
|
+
These logs are completely stripped in production builds — no SDK chatter
|
|
1347
|
+
in real user devices.
|
|
1348
|
+
|
|
1349
|
+
### Custom rendering (advanced)
|
|
1350
|
+
|
|
1351
|
+
If you want to render the UI tree yourself but still use the SDK's fetch +
|
|
1352
|
+
AGENT continuation + preload cache, use the hook directly:
|
|
1353
|
+
|
|
1354
|
+
```tsx
|
|
1355
|
+
import { useEventDrivenView } from '@bitbitpress/client/react';
|
|
1356
|
+
|
|
1357
|
+
const { uiData, loading, error, handleEvent } = useEventDrivenView(
|
|
1358
|
+
client,
|
|
1359
|
+
keyName,
|
|
1360
|
+
onHostEvent,
|
|
1361
|
+
contentInputs,
|
|
1362
|
+
viewInputs,
|
|
1363
|
+
);
|
|
1364
|
+
```
|
|
1365
|
+
|
|
1366
|
+
`uiData` is the same array `BitBitViewRenderer` consumes; wire
|
|
1367
|
+
`handleEvent` as your custom renderer's event callback to keep AGENT
|
|
1368
|
+
events flowing through the SDK.
|
|
@@ -683,8 +683,8 @@ export interface paths {
|
|
|
683
683
|
items: {
|
|
684
684
|
/** @description Optional configuration key name. Loads an existing synthesis config by this name; omit for default configuration. */
|
|
685
685
|
configurationKeyName?: string;
|
|
686
|
-
/** @description
|
|
687
|
-
|
|
686
|
+
/** @description How many recent stored synthesis outputs to expose in the streamed `synthesisHistory` field. Defaults to 0 (no history emitted). When > 0, the final data event includes a `synthesisHistory` array of up to N `data` payloads (most-recent first). The first entry is the current synthesis itself — the same payload `data` is derived from — and the remaining entries are older stored rows. */
|
|
687
|
+
synthesisHistoryLimit?: number;
|
|
688
688
|
/** @description Per-request overrides for search options. */
|
|
689
689
|
searchOptionsOverrides?: {
|
|
690
690
|
/** @description Override for search lookback window in minutes (e.g. 1440 for last 24 hours). */
|
|
@@ -723,10 +723,13 @@ export interface paths {
|
|
|
723
723
|
* {
|
|
724
724
|
* "index": number,
|
|
725
725
|
* "data": {...},
|
|
726
|
+
* "synthesisHistory"?: [{...}, ...],
|
|
726
727
|
* "complete": false | true
|
|
727
728
|
* }
|
|
728
729
|
* ```
|
|
729
|
-
* `data` is
|
|
730
|
+
* `data` is always a single synthesized object (keys match your output schema). `complete` is `false` for partial streaming updates and `true` for the final validated payload.
|
|
731
|
+
*
|
|
732
|
+
* When `synthesisHistoryLimit > 0`, the final event additionally includes `synthesisHistory`: an array of up to N `data` payloads (most-recent first). The first entry is the current synthesis itself — the raw payload `data` is derived from (identical to `data` when reranking isn't configured; the unreranked source when it is) — and the remaining entries are older stored rows. The primary `data` field stays a single object — when user reranking is configured, it is built by pooling items at the reranking field across the fetched rows and scoring against the user profile.
|
|
730
733
|
*
|
|
731
734
|
* **Data Events (error):**
|
|
732
735
|
* ```json
|
package/dist/react/index.d.ts
CHANGED
|
@@ -2,35 +2,54 @@ import { type RenderUnknown, type SynthesisViewTreeProps } from '../synthesisVie
|
|
|
2
2
|
import type { ComponentMap, ContentInput, SynthesisViewEvent, SynthesizeViewFetcher } from '../synthesisView/types.js';
|
|
3
3
|
export { type BitBitContextValue, BitBitProvider } from '../synthesisView/context.js';
|
|
4
4
|
export { createComponentMap, type GlobModules, type RequireContext, } from '../synthesisView/createComponentMap.js';
|
|
5
|
-
export type { ComponentMap, ContentInput, FlatUiKeyNameNode, FlatUiNode, FlatUiPrimitiveNode, SynthesisViewEvent, SynthesizeViewFetcher, ViewInputs, } from '../synthesisView/types.js';
|
|
5
|
+
export type { ComponentMap, ContentInput, FlatUiKeyNameNode, FlatUiNode, FlatUiPrimitiveNode, SynthesisViewEvent, SynthesisViewEventInput, SynthesizeViewFetcher, ViewEventHandleWith, ViewInputs, } from '../synthesisView/types.js';
|
|
6
|
+
export { type UseEventDrivenViewOptions, type UseEventDrivenViewResult, useEventDrivenView, } from '../synthesisView/useEventDrivenView.js';
|
|
6
7
|
export { bitBitBuiltins } from './primitives.js';
|
|
7
8
|
export type BitBitViewRendererProps = Omit<SynthesisViewTreeProps, 'renderUnknown' | 'defaultComponents'> & {
|
|
8
|
-
/** Override how unregistered components render. Defaults to a
|
|
9
|
+
/** Override how unregistered components render. Defaults to a dev-only
|
|
10
|
+
* marker (see {@link isDevEnvironment}). */
|
|
9
11
|
renderUnknown?: RenderUnknown;
|
|
12
|
+
/** Force the in-dev warning behavior regardless of `process.env.NODE_ENV`.
|
|
13
|
+
* Set true in CMS / preview hosts (e.g. BitBitPress's own admin UI) so
|
|
14
|
+
* unknown components stay visible even when those hosts are built in
|
|
15
|
+
* production mode. Defaults to env-derived. */
|
|
16
|
+
dev?: boolean;
|
|
10
17
|
};
|
|
11
18
|
/** Web renderer for a pre-fetched `uiData` array. BB built-in primitives are
|
|
12
19
|
* registered automatically; pass `components` to add or override entries by
|
|
13
20
|
* name. Use `<BitBitView>` if you want it to fetch for you. */
|
|
14
|
-
export declare function BitBitViewRenderer({ renderUnknown, ...rest }: BitBitViewRendererProps): import("react").FunctionComponentElement<SynthesisViewTreeProps>;
|
|
21
|
+
export declare function BitBitViewRenderer({ renderUnknown, dev, onEvent, ...rest }: BitBitViewRendererProps): import("react").FunctionComponentElement<SynthesisViewTreeProps>;
|
|
15
22
|
export type BitBitViewProps = {
|
|
16
23
|
/** A BitBitPressClient (or anything with `user.synthesizeViewItem`). */
|
|
17
24
|
client: SynthesizeViewFetcher;
|
|
18
25
|
keyName: string;
|
|
19
26
|
contentInputs?: ContentInput[];
|
|
20
27
|
components?: ComponentMap;
|
|
28
|
+
/** Fires for `HOST` events the component contract declared. `AGENT`
|
|
29
|
+
* events are handled internally — the SDK rounds-trips to the synthesis
|
|
30
|
+
* endpoint and swaps the UI in place; customers don't see them unless
|
|
31
|
+
* they explicitly opt in via the contract. */
|
|
21
32
|
onEvent?: (event: SynthesisViewEvent) => void;
|
|
22
33
|
renderUnknown?: RenderUnknown;
|
|
34
|
+
/** Force the in-dev warning behavior regardless of `process.env.NODE_ENV`.
|
|
35
|
+
* See {@link BitBitViewRendererProps.dev}. */
|
|
36
|
+
dev?: boolean;
|
|
23
37
|
/** Force a dark/light mode. Defaults to the browser's
|
|
24
38
|
* `prefers-color-scheme` (live-updates if the user toggles their OS
|
|
25
39
|
* theme). */
|
|
26
40
|
darkMode?: boolean;
|
|
41
|
+
/** When true (default), speculatively prefetches the agent's next-UI for
|
|
42
|
+
* AGENT events whose payloads don't need runtime input. Real clicks land
|
|
43
|
+
* on the cached response with zero server roundtrip. Set false to
|
|
44
|
+
* disable. */
|
|
45
|
+
preloadNextUi?: boolean;
|
|
27
46
|
};
|
|
28
47
|
/**
|
|
29
48
|
* Web view: fetches a synthesis view by `keyName` and renders it in place.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
49
|
+
* AGENT-handled events drive the next UI back through the agent
|
|
50
|
+
* (preloaded when possible). HOST events fire to `onEvent`.
|
|
32
51
|
*/
|
|
33
|
-
export declare function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, darkMode, }: BitBitViewProps): import("react").DetailedReactHTMLElement<{
|
|
52
|
+
export declare function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, dev, darkMode, preloadNextUi, }: BitBitViewProps): import("react").DetailedReactHTMLElement<{
|
|
34
53
|
'data-bitbit-error': boolean;
|
|
35
54
|
style: {
|
|
36
55
|
color: "#b00020";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AACpC,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C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd;;kBAEc;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;mBAGe;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,OAAO,EACP,aAAa,EACb,UAAU,EACV,OAAO,EACP,aAAa,EACb,GAAG,EACH,QAAQ,EACR,aAAa,GACd,EAAE,eAAe;;;;;;;2FAgCjB"}
|
package/dist/react/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { createElement, useEffect, useState } from 'react';
|
|
2
|
+
import { devLog, isDevEnvironment } from '../synthesisView/devLog.js';
|
|
2
3
|
import { SynthesisViewTree, } from '../synthesisView/engine.js';
|
|
3
|
-
import {
|
|
4
|
+
import { useEventDrivenView } from '../synthesisView/useEventDrivenView.js';
|
|
4
5
|
import { bitBitBuiltins } from './primitives.js';
|
|
5
6
|
export { BitBitProvider } from '../synthesisView/context.js';
|
|
6
7
|
export { createComponentMap, } from '../synthesisView/createComponentMap.js';
|
|
8
|
+
export { useEventDrivenView, } from '../synthesisView/useEventDrivenView.js';
|
|
7
9
|
export { bitBitBuiltins } from './primitives.js';
|
|
8
10
|
/** Track the browser's `prefers-color-scheme` and re-render on change. Returns
|
|
9
11
|
* `null` during SSR or when the API isn't available — callers fall back to
|
|
@@ -24,30 +26,44 @@ function useSystemDarkMode() {
|
|
|
24
26
|
}, []);
|
|
25
27
|
return isDark;
|
|
26
28
|
}
|
|
27
|
-
const
|
|
29
|
+
const renderUnknownWarning = (name) => createElement('span', {
|
|
28
30
|
'data-bitbit-unknown': name,
|
|
29
31
|
style: { color: '#b00020', fontFamily: 'monospace', fontSize: 12 },
|
|
30
32
|
}, `⚠ Unknown component: ${name}`);
|
|
33
|
+
/** Silent in production: an unknown name renders nothing rather than splashing
|
|
34
|
+
* a debug marker in the customer's real app. */
|
|
35
|
+
const renderUnknownSilent = () => null;
|
|
36
|
+
/** Wrap `onEvent` so each emission prints to the console with the dispatch
|
|
37
|
+
* routing inline. Routed through {@link devLog} so the message is auto-
|
|
38
|
+
* prefixed with `[BB]` and stripped to a no-op outside dev. */
|
|
39
|
+
function withDevEventLog(dev, onEvent) {
|
|
40
|
+
return (event) => {
|
|
41
|
+
devLog(dev, `event ${event.componentName}.${event.slot} → ${event.handleWith}`, event);
|
|
42
|
+
onEvent?.(event);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
31
45
|
/** Web renderer for a pre-fetched `uiData` array. BB built-in primitives are
|
|
32
46
|
* registered automatically; pass `components` to add or override entries by
|
|
33
47
|
* name. Use `<BitBitView>` if you want it to fetch for you. */
|
|
34
|
-
export function BitBitViewRenderer({ renderUnknown, ...rest }) {
|
|
48
|
+
export function BitBitViewRenderer({ renderUnknown, dev, onEvent, ...rest }) {
|
|
49
|
+
const isDev = dev ?? isDevEnvironment();
|
|
35
50
|
return createElement(SynthesisViewTree, {
|
|
36
51
|
...rest,
|
|
37
52
|
defaultComponents: bitBitBuiltins,
|
|
38
|
-
renderUnknown: renderUnknown ??
|
|
53
|
+
renderUnknown: renderUnknown ?? (isDev ? renderUnknownWarning : renderUnknownSilent),
|
|
54
|
+
onEvent: isDev ? withDevEventLog(dev, onEvent) : onEvent,
|
|
39
55
|
});
|
|
40
56
|
}
|
|
41
57
|
/**
|
|
42
58
|
* Web view: fetches a synthesis view by `keyName` and renders it in place.
|
|
43
|
-
*
|
|
44
|
-
*
|
|
59
|
+
* AGENT-handled events drive the next UI back through the agent
|
|
60
|
+
* (preloaded when possible). HOST events fire to `onEvent`.
|
|
45
61
|
*/
|
|
46
|
-
export function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, darkMode, }) {
|
|
62
|
+
export function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, dev, darkMode, preloadNextUi, }) {
|
|
47
63
|
const systemDark = useSystemDarkMode();
|
|
48
64
|
const resolvedDark = darkMode ?? systemDark ?? undefined;
|
|
49
65
|
const viewInputs = resolvedDark !== undefined ? { darkMode: resolvedDark } : undefined;
|
|
50
|
-
const { uiData, loading, error } =
|
|
66
|
+
const { uiData, loading, error, handleEvent } = useEventDrivenView(client, keyName, onEvent, contentInputs, viewInputs, { preloadNextUi });
|
|
51
67
|
if (loading)
|
|
52
68
|
return null;
|
|
53
69
|
if (error) {
|
|
@@ -61,8 +77,9 @@ export function BitBitView({ client, keyName, contentInputs, components, onEvent
|
|
|
61
77
|
return createElement(BitBitViewRenderer, {
|
|
62
78
|
uiData,
|
|
63
79
|
components,
|
|
64
|
-
onEvent,
|
|
80
|
+
onEvent: handleEvent,
|
|
65
81
|
renderUnknown,
|
|
82
|
+
dev,
|
|
66
83
|
});
|
|
67
84
|
}
|
|
68
85
|
//# sourceMappingURL=index.js.map
|
package/dist/react/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAEL,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAEL,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAA2B,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACtF,OAAO,EACL,kBAAkB,GAGnB,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AAG,kBAAkB,CAChE,MAAM,EACN,OAAO,EACP,OAAO,EACP,aAAa,EACb,UAAU,EACV,EAAE,aAAa,EAAE,CAClB,CAAC;IACF,IAAI,OAAO;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,aAAa,CAClB,KAAK,EACL;YACE,mBAAmB,EAAE,IAAI;YACzB,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,EAAE,EAAE;SACnE,EACD,KAAK,CACN,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,aAAa,CAAC,kBAAkB,EAAE;QACvC,MAAM;QACN,UAAU;QACV,OAAO,EAAE,WAAW;QACpB,aAAa;QACb,GAAG;KACJ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -2,15 +2,18 @@ import { type RenderUnknown, type SynthesisViewTreeProps } from '../synthesisVie
|
|
|
2
2
|
import type { ComponentMap, ContentInput, SynthesisViewEvent, SynthesizeViewFetcher } from '../synthesisView/types.js';
|
|
3
3
|
export { type BitBitContextValue, BitBitProvider } from '../synthesisView/context.js';
|
|
4
4
|
export { createComponentMap, type GlobModules, type RequireContext, } from '../synthesisView/createComponentMap.js';
|
|
5
|
-
export type { ComponentMap, ContentInput, FlatUiKeyNameNode, FlatUiNode, FlatUiPrimitiveNode, SynthesisViewEvent, SynthesizeViewFetcher, ViewInputs, } from '../synthesisView/types.js';
|
|
5
|
+
export type { ComponentMap, ContentInput, FlatUiKeyNameNode, FlatUiNode, FlatUiPrimitiveNode, SynthesisViewEvent, SynthesisViewEventInput, SynthesizeViewFetcher, ViewEventHandleWith, ViewInputs, } from '../synthesisView/types.js';
|
|
6
|
+
export { type UseEventDrivenViewOptions, type UseEventDrivenViewResult, useEventDrivenView, } from '../synthesisView/useEventDrivenView.js';
|
|
6
7
|
export { bitBitBuiltins } from './primitives.js';
|
|
7
8
|
export type BitBitViewRendererProps = Omit<SynthesisViewTreeProps, 'renderUnknown' | 'defaultComponents'> & {
|
|
8
9
|
/**
|
|
9
|
-
* Override how unregistered components render. Defaults
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Override how unregistered components render. Defaults are env-derived:
|
|
11
|
+
* a dev-only warning marker when `process.env.NODE_ENV !== 'production'`,
|
|
12
|
+
* silent in production builds. Set `dev` to force the warning behavior.
|
|
12
13
|
*/
|
|
13
14
|
renderUnknown?: RenderUnknown;
|
|
15
|
+
/** Force the in-dev warning behavior regardless of `process.env.NODE_ENV`. */
|
|
16
|
+
dev?: boolean;
|
|
14
17
|
};
|
|
15
18
|
/**
|
|
16
19
|
* React Native (Expo) renderer for a pre-fetched `uiData` array. BB built-in
|
|
@@ -19,24 +22,32 @@ export type BitBitViewRendererProps = Omit<SynthesisViewTreeProps, 'renderUnknow
|
|
|
19
22
|
* on Expo packages (`expo-linear-gradient`, etc.). Use `<BitBitView>` if you
|
|
20
23
|
* want it to fetch for you.
|
|
21
24
|
*/
|
|
22
|
-
export declare function BitBitViewRenderer({ renderUnknown, ...rest }: BitBitViewRendererProps): import("react").FunctionComponentElement<SynthesisViewTreeProps>;
|
|
25
|
+
export declare function BitBitViewRenderer({ renderUnknown, dev, onEvent, ...rest }: BitBitViewRendererProps): import("react").FunctionComponentElement<SynthesisViewTreeProps>;
|
|
23
26
|
export type BitBitViewProps = {
|
|
24
27
|
/** A BitBitPressClient (or anything with `user.synthesizeViewItem`). */
|
|
25
28
|
client: SynthesizeViewFetcher;
|
|
26
29
|
keyName: string;
|
|
27
30
|
contentInputs?: ContentInput[];
|
|
28
31
|
components?: ComponentMap;
|
|
32
|
+
/** Fires for `HOST` events the component contract declared. `AGENT`
|
|
33
|
+
* events are handled internally — the SDK round-trips to the synthesis
|
|
34
|
+
* endpoint and swaps the UI in place. */
|
|
29
35
|
onEvent?: (event: SynthesisViewEvent) => void;
|
|
30
36
|
renderUnknown?: RenderUnknown;
|
|
37
|
+
/** Force the in-dev warning behavior regardless of `process.env.NODE_ENV`.
|
|
38
|
+
* See {@link BitBitViewRendererProps.dev}. */
|
|
39
|
+
dev?: boolean;
|
|
31
40
|
/** Force a dark/light mode. Defaults to the system appearance via RN's
|
|
32
41
|
* `useColorScheme` (re-renders when the user toggles their OS theme). */
|
|
33
42
|
darkMode?: boolean;
|
|
43
|
+
/** When true (default), speculatively prefetches AGENT events with
|
|
44
|
+
* payload-less contracts so real clicks render with zero roundtrip. */
|
|
45
|
+
preloadNextUi?: boolean;
|
|
34
46
|
};
|
|
35
47
|
/**
|
|
36
48
|
* React Native (Expo) view: fetches a synthesis view by `keyName` and renders
|
|
37
|
-
* it in place.
|
|
38
|
-
*
|
|
39
|
-
* into a single batched request.
|
|
49
|
+
* it in place. AGENT events drive next UIs back through the agent (preloaded
|
|
50
|
+
* when possible). HOST events fire `onEvent`.
|
|
40
51
|
*/
|
|
41
|
-
export declare function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, darkMode, }: BitBitViewProps): import("react").FunctionComponentElement<BitBitViewRendererProps> | null;
|
|
52
|
+
export declare function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, dev, darkMode, preloadNextUi, }: BitBitViewProps): import("react").FunctionComponentElement<BitBitViewRendererProps> | null;
|
|
42
53
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,aAAa,EAElB,KAAK,sBAAsB,EAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EAEtB,MAAM,2BAA2B,CAAC;AAInC,OAAO,EAA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AC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,EACzB,MAAM,EACN,OAAO,EACP,aAAa,EACb,UAAU,EACV,OAAO,EACP,aAAa,EACb,GAAG,EACH,QAAQ,EACR,aAAa,GACd,EAAE,eAAe,4EAsBjB"}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { createElement } from 'react';
|
|
2
|
-
import { useColorScheme } from 'react-native';
|
|
2
|
+
import { Text, useColorScheme } from 'react-native';
|
|
3
|
+
import { devLog, isDevEnvironment } from '../synthesisView/devLog.js';
|
|
3
4
|
import { SynthesisViewTree, } from '../synthesisView/engine.js';
|
|
4
|
-
import {
|
|
5
|
+
import { useEventDrivenView } from '../synthesisView/useEventDrivenView.js';
|
|
5
6
|
import { bitBitBuiltins } from './primitives.js';
|
|
6
7
|
export { BitBitProvider } from '../synthesisView/context.js';
|
|
7
8
|
export { createComponentMap, } from '../synthesisView/createComponentMap.js';
|
|
9
|
+
export { useEventDrivenView, } from '../synthesisView/useEventDrivenView.js';
|
|
8
10
|
export { bitBitBuiltins } from './primitives.js';
|
|
9
|
-
const
|
|
11
|
+
const renderUnknownWarning = (name) => createElement(Text, { style: { color: '#b00020', fontFamily: 'monospace', fontSize: 12 } }, `⚠ Unknown component: ${name}`);
|
|
12
|
+
const renderUnknownSilent = () => null;
|
|
10
13
|
const DEFAULT_FONT_SIZE = 16;
|
|
11
14
|
/** Extract the primary family name from a CSS-shape `fontFamily` value.
|
|
12
15
|
* Web takes the full fallback chain (`'"Inter-Regular", "Inter", ...'`);
|
|
@@ -40,6 +43,15 @@ function normalizeRNStyle(value) {
|
|
|
40
43
|
}
|
|
41
44
|
return changed ? out : value;
|
|
42
45
|
}
|
|
46
|
+
/** Wrap `onEvent` so each emission prints to the console with the dispatch
|
|
47
|
+
* routing inline. Routed through {@link devLog} so the message is auto-
|
|
48
|
+
* prefixed with `[BB]` and stripped to a no-op outside dev. */
|
|
49
|
+
function withDevEventLog(dev, onEvent) {
|
|
50
|
+
return (event) => {
|
|
51
|
+
devLog(dev, `event ${event.componentName}.${event.slot} → ${event.handleWith}`, event);
|
|
52
|
+
onEvent?.(event);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
43
55
|
/**
|
|
44
56
|
* React Native (Expo) renderer for a pre-fetched `uiData` array. BB built-in
|
|
45
57
|
* primitives are registered automatically; pass `components` to add or
|
|
@@ -47,32 +59,34 @@ function normalizeRNStyle(value) {
|
|
|
47
59
|
* on Expo packages (`expo-linear-gradient`, etc.). Use `<BitBitView>` if you
|
|
48
60
|
* want it to fetch for you.
|
|
49
61
|
*/
|
|
50
|
-
export function BitBitViewRenderer({ renderUnknown, ...rest }) {
|
|
62
|
+
export function BitBitViewRenderer({ renderUnknown, dev, onEvent, ...rest }) {
|
|
63
|
+
const isDev = dev ?? isDevEnvironment();
|
|
51
64
|
return createElement(SynthesisViewTree, {
|
|
52
65
|
...rest,
|
|
53
66
|
defaultComponents: bitBitBuiltins,
|
|
54
67
|
normalizeStyle: normalizeRNStyle,
|
|
55
|
-
renderUnknown: renderUnknown ??
|
|
68
|
+
renderUnknown: renderUnknown ?? (isDev ? renderUnknownWarning : renderUnknownSilent),
|
|
69
|
+
onEvent: isDev ? withDevEventLog(dev, onEvent) : onEvent,
|
|
56
70
|
});
|
|
57
71
|
}
|
|
58
72
|
/**
|
|
59
73
|
* React Native (Expo) view: fetches a synthesis view by `keyName` and renders
|
|
60
|
-
* it in place.
|
|
61
|
-
*
|
|
62
|
-
* into a single batched request.
|
|
74
|
+
* it in place. AGENT events drive next UIs back through the agent (preloaded
|
|
75
|
+
* when possible). HOST events fire `onEvent`.
|
|
63
76
|
*/
|
|
64
|
-
export function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, darkMode, }) {
|
|
77
|
+
export function BitBitView({ client, keyName, contentInputs, components, onEvent, renderUnknown, dev, darkMode, preloadNextUi, }) {
|
|
65
78
|
const systemScheme = useColorScheme();
|
|
66
79
|
const resolvedDark = darkMode ?? (systemScheme === 'dark' ? true : systemScheme === 'light' ? false : undefined);
|
|
67
80
|
const viewInputs = resolvedDark !== undefined ? { darkMode: resolvedDark } : undefined;
|
|
68
|
-
const { uiData, loading, error } =
|
|
81
|
+
const { uiData, loading, error, handleEvent } = useEventDrivenView(client, keyName, onEvent, contentInputs, viewInputs, { preloadNextUi });
|
|
69
82
|
if (loading || error || !uiData.length)
|
|
70
83
|
return null;
|
|
71
84
|
return createElement(BitBitViewRenderer, {
|
|
72
85
|
uiData,
|
|
73
86
|
components,
|
|
74
|
-
onEvent,
|
|
87
|
+
onEvent: handleEvent,
|
|
75
88
|
renderUnknown,
|
|
89
|
+
dev,
|
|
76
90
|
});
|
|
77
91
|
}
|
|
78
92
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react-native-expo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAEL,iBAAiB,GAElB,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAA2B,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACtF,OAAO,EACL,kBAAkB,GAGnB,MAAM,wCAAwC,CAAC;AAahD,OAAO,EAGL,kBAAkB,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G;AACH,MAAM,UAAU,UAAU,CAAC,EACzB,MAAM,EACN,OAAO,EACP,aAAa,EACb,UAAU,EACV,OAAO,EACP,aAAa,EACb,GAAG,EACH,QAAQ,EACR,aAAa,GACG;IAChB,MAAM,YAAY,GAAG,cAAc,EAAE,CAAC;IACtC,MAAM,YAAY,GAChB,QAAQ,IAAI,CAAC,YAAY,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9F,MAAM,UAAU,GACd,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,kBAAkB,CAChE,MAAM,EACN,OAAO,EACP,OAAO,EACP,aAAa,EACb,UAAU,EACV,EAAE,aAAa,EAAE,CAClB,CAAC;IACF,IAAI,OAAO,IAAI,KAAK,IAAI,CAAC,MAAM,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACpD,OAAO,aAAa,CAAC,kBAAkB,EAAE;QACvC,MAAM;QACN,UAAU;QACV,OAAO,EAAE,WAAW;QACpB,aAAa;QACb,GAAG;KACJ,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** True when the bundle was built outside production. Read at runtime so
|
|
2
|
+
* bundlers can DCE the dev-log path during minification. Guarded for
|
|
3
|
+
* environments where `process` is undefined (some edge runtimes). */
|
|
4
|
+
export declare function isDevEnvironment(): boolean;
|
|
5
|
+
/** Single sink for every diagnostic log shipped from the SDK. Auto-prefixes
|
|
6
|
+
* with `[BB]` and silently no-ops outside dev so customer production builds
|
|
7
|
+
* don't carry SDK chatter. Pass `dev` explicitly to override env detection
|
|
8
|
+
* (e.g. CMS preview hosts that ship as prod bundles but want diagnostics). */
|
|
9
|
+
export declare function devLog(dev: boolean | undefined, ...args: unknown[]): void;
|
|
10
|
+
//# sourceMappingURL=devLog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devLog.d.ts","sourceRoot":"","sources":["../../src/synthesisView/devLog.ts"],"names":[],"mappings":"AAAA;;sEAEsE;AACtE,wBAAgB,gBAAgB,IAAI,OAAO,CAM1C;AAED;;;+EAG+E;AAC/E,wBAAgB,MAAM,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAKzE"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** True when the bundle was built outside production. Read at runtime so
|
|
2
|
+
* bundlers can DCE the dev-log path during minification. Guarded for
|
|
3
|
+
* environments where `process` is undefined (some edge runtimes). */
|
|
4
|
+
export function isDevEnvironment() {
|
|
5
|
+
try {
|
|
6
|
+
return typeof process !== 'undefined' && process.env?.NODE_ENV !== 'production';
|
|
7
|
+
}
|
|
8
|
+
catch {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** Single sink for every diagnostic log shipped from the SDK. Auto-prefixes
|
|
13
|
+
* with `[BB]` and silently no-ops outside dev so customer production builds
|
|
14
|
+
* don't carry SDK chatter. Pass `dev` explicitly to override env detection
|
|
15
|
+
* (e.g. CMS preview hosts that ship as prod bundles but want diagnostics). */
|
|
16
|
+
export function devLog(dev, ...args) {
|
|
17
|
+
const isDev = dev ?? isDevEnvironment();
|
|
18
|
+
if (!isDev)
|
|
19
|
+
return;
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log('[BB]', ...args);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=devLog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"devLog.js","sourceRoot":"","sources":["../../src/synthesisView/devLog.ts"],"names":[],"mappings":"AAAA;;sEAEsE;AACtE,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC;QACH,OAAO,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,QAAQ,KAAK,YAAY,CAAC;IAClF,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;+EAG+E;AAC/E,MAAM,UAAU,MAAM,CAAC,GAAwB,EAAE,GAAG,IAAe;IACjE,MAAM,KAAK,GAAG,GAAG,IAAI,gBAAgB,EAAE,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,OAAO;IACnB,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;AAC/B,CAAC"}
|
|
@@ -81,7 +81,14 @@ function renderPrimitiveNode(node, context) {
|
|
|
81
81
|
if (componentPayload && typeof componentPayload === 'object') {
|
|
82
82
|
Object.assign(payload, componentPayload);
|
|
83
83
|
}
|
|
84
|
-
emit({
|
|
84
|
+
emit({
|
|
85
|
+
name: event.name,
|
|
86
|
+
payload,
|
|
87
|
+
slot,
|
|
88
|
+
nodeId: node.id,
|
|
89
|
+
componentName: node.component,
|
|
90
|
+
handleWith: event.handleWith ?? 'AGENT',
|
|
91
|
+
});
|
|
85
92
|
};
|
|
86
93
|
}
|
|
87
94
|
}
|
|
@@ -101,6 +108,25 @@ function renderPrimitiveNode(node, context) {
|
|
|
101
108
|
function renderKeyNameNode(node, context) {
|
|
102
109
|
const Component = context.components[node.component];
|
|
103
110
|
const props = { ...(node.props ?? {}) };
|
|
111
|
+
if (node.events && context.onEvent) {
|
|
112
|
+
const emit = context.onEvent;
|
|
113
|
+
for (const [slot, event] of Object.entries(node.events)) {
|
|
114
|
+
props[slot] = (componentPayload) => {
|
|
115
|
+
const payload = { ...(event.payload ?? {}) };
|
|
116
|
+
if (componentPayload && typeof componentPayload === 'object') {
|
|
117
|
+
Object.assign(payload, componentPayload);
|
|
118
|
+
}
|
|
119
|
+
emit({
|
|
120
|
+
name: event.name,
|
|
121
|
+
payload,
|
|
122
|
+
slot,
|
|
123
|
+
nodeId: node.id,
|
|
124
|
+
componentName: node.component,
|
|
125
|
+
handleWith: event.handleWith ?? 'AGENT',
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
}
|
|
104
130
|
const childIds = nodeChildIds(node);
|
|
105
131
|
if (childIds) {
|
|
106
132
|
props.children = childIds.map((childId) => renderNode(childId, context));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/synthesisView/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAyBhD,SAAS,YAAY,CAAC,KAA+B;IACnD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC1C,IAAI,CAAC,KAAK;QAAE,OAAO,GAAG,CAAC;IACvB,KAAK,MAAM,CAAC,IAAI,KAAK;QAAE,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,EAAE,KAAK,QAAQ;YAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC3E,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,YAAY,CAAC,IAAgB;IACpC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvD,IAAI,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACxD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS;IAC9C,IAAI;IACJ,MAAM;IACN,WAAW;IACX,UAAU;IACV,OAAO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,EAAE,OAAO,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,aAAa,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,aAAa,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -19,10 +19,20 @@ export type FlatUiPrimitiveNode = {
|
|
|
19
19
|
/** Single nested-node id shorthand. */
|
|
20
20
|
child?: string;
|
|
21
21
|
/** Host-facing event bindings. Component-emitted payloads (e.g.
|
|
22
|
-
* `TextField` `{value}`) merge over the static payload at fire time.
|
|
22
|
+
* `TextField` `{value}`) merge over the static payload at fire time.
|
|
23
|
+
* `handleWith` is lifted from the component contract by the flattener so
|
|
24
|
+
* the SDK can route the event without re-fetching the catalog:
|
|
25
|
+
* - `HOST` — fires `onEvent` to the customer.
|
|
26
|
+
* - `AGENT` (default) — `<BitBitView>` round-trips to the synthesis
|
|
27
|
+
* endpoint with the event as continuation context; the agent emits
|
|
28
|
+
* the next UI. The customer's `onEvent` still fires for observability.
|
|
29
|
+
* - `payloadSchema` (when present) opts the event out of speculative
|
|
30
|
+
* preload — the payload requires runtime input. */
|
|
23
31
|
events?: Record<string, {
|
|
24
32
|
name: string;
|
|
25
33
|
payload?: Record<string, unknown>;
|
|
34
|
+
handleWith?: ViewEventHandleWith;
|
|
35
|
+
payloadSchema?: unknown;
|
|
26
36
|
}>;
|
|
27
37
|
/** Other fields (`text`, `src`, `title`, …) are static props on the node. */
|
|
28
38
|
[prop: string]: unknown;
|
|
@@ -36,12 +46,46 @@ export type FlatUiKeyNameNode = {
|
|
|
36
46
|
/** Projected children (ids in the same array). */
|
|
37
47
|
children?: string[];
|
|
38
48
|
child?: string;
|
|
49
|
+
/** Host-facing event bindings — same shape and semantics as on
|
|
50
|
+
* {@link FlatUiPrimitiveNode}. The SDK wires each slot into a prop
|
|
51
|
+
* callback on the host component so customer code can fire BB events
|
|
52
|
+
* (`AGENT` continuations, `HOST` dispatches) without grabbing the
|
|
53
|
+
* provider context manually. */
|
|
54
|
+
events?: Record<string, {
|
|
55
|
+
name: string;
|
|
56
|
+
payload?: Record<string, unknown>;
|
|
57
|
+
handleWith?: ViewEventHandleWith;
|
|
58
|
+
payloadSchema?: unknown;
|
|
59
|
+
}>;
|
|
39
60
|
};
|
|
40
61
|
export type FlatUiNode = FlatUiPrimitiveNode | FlatUiKeyNameNode;
|
|
62
|
+
export type ViewEventHandleWith = 'AGENT' | 'HOST';
|
|
41
63
|
export type SynthesisViewEvent = {
|
|
64
|
+
/** Host-facing event name — what the view-author bound the slot to. */
|
|
42
65
|
name: string;
|
|
66
|
+
/** Resolved payload — static `payload` from the binding merged with any
|
|
67
|
+
* runtime payload the primitive emitted (e.g. `TextField` `{value}`). */
|
|
43
68
|
payload: Record<string, unknown>;
|
|
69
|
+
/** Slot that fired (e.g. `onPress`). Useful when several slots are bound
|
|
70
|
+
* to the same host event name. */
|
|
71
|
+
slot: string;
|
|
72
|
+
/** The flat-uid of the node that fired. SDK-internal mostly; useful for
|
|
73
|
+
* the CMS preview to disambiguate multiple instances. */
|
|
44
74
|
nodeId: string;
|
|
75
|
+
/** Catalog name of the component the event was fired from. */
|
|
76
|
+
componentName: string;
|
|
77
|
+
/** Routing the component contract declared. `null` defaults to `AGENT`. */
|
|
78
|
+
handleWith: ViewEventHandleWith;
|
|
79
|
+
};
|
|
80
|
+
/** Sent to the synthesis endpoint as `viewInputs.event` when an `AGENT` event
|
|
81
|
+
* fires. The agent gets the prior UI + event as continuation context and
|
|
82
|
+
* emits the next UI in response. */
|
|
83
|
+
export type SynthesisViewEventInput = {
|
|
84
|
+
name: string;
|
|
85
|
+
componentName: string;
|
|
86
|
+
payload?: Record<string, unknown>;
|
|
87
|
+
sourceNodeId?: string;
|
|
88
|
+
priorUiData: FlatUiNode[];
|
|
45
89
|
};
|
|
46
90
|
/** Maps component names → React implementations. Used both for BB
|
|
47
91
|
* primitives and for the host-registered `KEY_NAME` components. */
|
|
@@ -53,6 +97,11 @@ export type ContentInput = {
|
|
|
53
97
|
export type ViewInputs = {
|
|
54
98
|
/** Provide the dark mode setting of the current UI to the agent. */
|
|
55
99
|
darkMode?: boolean;
|
|
100
|
+
/** Event continuation. Set by the SDK on AGENT-handled events (and on
|
|
101
|
+
* speculative preload calls); the agent re-renders given the prior UI
|
|
102
|
+
* plus this event. Customers don't pass this — `<BitBitView>` manages it
|
|
103
|
+
* internally. */
|
|
104
|
+
event?: SynthesisViewEventInput;
|
|
56
105
|
};
|
|
57
106
|
/**
|
|
58
107
|
* Minimal structural shape `<BitBitView>` needs to fetch a view. A
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/synthesisView/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,WAAW,CAAC;IAClB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,+BAA+B;IAC/B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/synthesisView/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG;IA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AAC;SACzB,GAAG,OAAO,CAAC;YACV,MAAM,EAAE,OAAO,EAAE,CAAC;SACnB,CAAC,CAAC;KACJ,CAAC;CACH"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ContentInput, FlatUiNode, SynthesisViewEvent, SynthesizeViewFetcher, ViewInputs } from './types.js';
|
|
2
|
+
export type UseEventDrivenViewOptions = {
|
|
3
|
+
/** When true (default), speculatively prefetches the agent's next-UI for
|
|
4
|
+
* every AGENT event whose payload is fully derivable from the rendered
|
|
5
|
+
* tree (i.e. the contract declared no `payloadSchema`). On the real
|
|
6
|
+
* click, the SDK swaps in the prefetched response without a server hop. */
|
|
7
|
+
preloadNextUi?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type UseEventDrivenViewResult = {
|
|
10
|
+
uiData: FlatUiNode[];
|
|
11
|
+
loading: boolean;
|
|
12
|
+
error: string | null;
|
|
13
|
+
/** Wire this to `<BitBitViewRenderer onEvent={...}>`. Routes the event
|
|
14
|
+
* based on its `handleWith`:
|
|
15
|
+
* - `HOST` — fires the supplied `onHostEvent` callback.
|
|
16
|
+
* - `AGENT` — re-fetches with the event as continuation context (cache
|
|
17
|
+
* hit if a speculative preload landed first), swaps `uiData` in
|
|
18
|
+
* place. The customer's `onHostEvent` is NOT fired for AGENT events. */
|
|
19
|
+
handleEvent: (event: SynthesisViewEvent) => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Live-view hook on top of `useSynthesisView`. Owns:
|
|
23
|
+
* - the live `uiData` (swaps in place on AGENT events),
|
|
24
|
+
* - a per-tree preload cache so deterministic event sequences are 0ms,
|
|
25
|
+
* - an event dispatcher the renderer calls back into.
|
|
26
|
+
*
|
|
27
|
+
* Resets state whenever the underlying view (keyName / contentInputs)
|
|
28
|
+
* changes — speculative entries from a stale tree aren't relevant to a
|
|
29
|
+
* different view.
|
|
30
|
+
*/
|
|
31
|
+
export declare function useEventDrivenView(client: SynthesizeViewFetcher, keyName: string, onHostEvent: ((event: SynthesisViewEvent) => void) | undefined, contentInputs?: ContentInput[], baseViewInputs?: ViewInputs, options?: UseEventDrivenViewOptions): UseEventDrivenViewResult;
|
|
32
|
+
//# sourceMappingURL=useEventDrivenView.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventDrivenView.d.ts","sourceRoot":"","sources":["../../src/synthesisView/useEventDrivenView.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EAEV,kBAAkB,EAElB,qBAAqB,EACrB,UAAU,EACX,MAAM,YAAY,CAAC;AAGpB,MAAM,MAAM,yBAAyB,GAAG;IACtC;;;gFAG4E;IAC5E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;;;;;gFAK4E;IAC5E,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC;CAClD,CAAC;AA4DF;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,qBAAqB,EAC7B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,CAAC,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAC,GAAG,SAAS,EAC9D,aAAa,CAAC,EAAE,YAAY,EAAE,EAC9B,cAAc,CAAC,EAAE,UAAU,EAC3B,OAAO,CAAC,EAAE,yBAAyB,GAClC,wBAAwB,CAuG1B"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useSynthesisView } from './useSynthesisView.js';
|
|
3
|
+
function isPrimitive(node) {
|
|
4
|
+
return node.kind === 'PRIMITIVE';
|
|
5
|
+
}
|
|
6
|
+
/** Stable string key for an event's cache entry. Speculation + real fire
|
|
7
|
+
* produce the same key when the runtime payload matches the declared one. */
|
|
8
|
+
function buildEventKey(componentName, eventName, sourceNodeId, payload) {
|
|
9
|
+
// Sort keys so payload order doesn't matter.
|
|
10
|
+
const payloadStr = payload
|
|
11
|
+
? JSON.stringify(Object.keys(payload)
|
|
12
|
+
.sort()
|
|
13
|
+
.reduce((acc, k) => {
|
|
14
|
+
acc[k] = payload[k];
|
|
15
|
+
return acc;
|
|
16
|
+
}, {}))
|
|
17
|
+
: '';
|
|
18
|
+
return `${componentName}:${eventName}:${sourceNodeId}:${payloadStr}`;
|
|
19
|
+
}
|
|
20
|
+
/** Walks the rendered tree and pulls out AGENT events with empty
|
|
21
|
+
* `payloadSchema` — those have payloads that don't depend on user input,
|
|
22
|
+
* so the SDK can fabricate the request and prefetch the agent's response. */
|
|
23
|
+
function findPreloadCandidates(uiData) {
|
|
24
|
+
const out = [];
|
|
25
|
+
for (const node of uiData) {
|
|
26
|
+
if (!isPrimitive(node) || !node.events)
|
|
27
|
+
continue;
|
|
28
|
+
for (const [, event] of Object.entries(node.events)) {
|
|
29
|
+
const handleWith = event.handleWith ?? 'AGENT';
|
|
30
|
+
if (handleWith !== 'AGENT')
|
|
31
|
+
continue;
|
|
32
|
+
// Skip events that need runtime payload — we can't fabricate the value.
|
|
33
|
+
if (event.payloadSchema)
|
|
34
|
+
continue;
|
|
35
|
+
out.push({
|
|
36
|
+
key: buildEventKey(node.component, event.name, node.id, event.payload),
|
|
37
|
+
event: {
|
|
38
|
+
name: event.name,
|
|
39
|
+
componentName: node.component,
|
|
40
|
+
payload: event.payload,
|
|
41
|
+
sourceNodeId: node.id,
|
|
42
|
+
priorUiData: uiData,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Live-view hook on top of `useSynthesisView`. Owns:
|
|
51
|
+
* - the live `uiData` (swaps in place on AGENT events),
|
|
52
|
+
* - a per-tree preload cache so deterministic event sequences are 0ms,
|
|
53
|
+
* - an event dispatcher the renderer calls back into.
|
|
54
|
+
*
|
|
55
|
+
* Resets state whenever the underlying view (keyName / contentInputs)
|
|
56
|
+
* changes — speculative entries from a stale tree aren't relevant to a
|
|
57
|
+
* different view.
|
|
58
|
+
*/
|
|
59
|
+
export function useEventDrivenView(client, keyName, onHostEvent, contentInputs, baseViewInputs, options) {
|
|
60
|
+
const fetched = useSynthesisView(client, keyName, contentInputs, baseViewInputs);
|
|
61
|
+
// Live tree: starts as the fetched one, replaced on AGENT events.
|
|
62
|
+
const [liveUiData, setLiveUiData] = useState(fetched.uiData);
|
|
63
|
+
// Preload cache scoped to the current view; reset on every base refetch.
|
|
64
|
+
const preloadCacheRef = useRef(new Map());
|
|
65
|
+
const inFlightRef = useRef(new Map());
|
|
66
|
+
// Keep `onHostEvent` reachable inside the stable `handleEvent` callback
|
|
67
|
+
// without making the callback identity churn on every render.
|
|
68
|
+
const onHostEventRef = useRef(onHostEvent);
|
|
69
|
+
onHostEventRef.current = onHostEvent;
|
|
70
|
+
const baseViewInputsRef = useRef(baseViewInputs);
|
|
71
|
+
baseViewInputsRef.current = baseViewInputs;
|
|
72
|
+
// When the base fetch produces new uiData (initial load, or a view change),
|
|
73
|
+
// adopt it and drop any stale speculations.
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
setLiveUiData(fetched.uiData);
|
|
76
|
+
preloadCacheRef.current = new Map();
|
|
77
|
+
inFlightRef.current = new Map();
|
|
78
|
+
}, [fetched.uiData]);
|
|
79
|
+
const preload = options?.preloadNextUi ?? true;
|
|
80
|
+
/** Fire one speculative event lookup and stash the result. Idempotent on
|
|
81
|
+
* the cache key — concurrent triggers share the in-flight promise. */
|
|
82
|
+
const speculate = useCallback(async (candidate) => {
|
|
83
|
+
if (preloadCacheRef.current.has(candidate.key)) {
|
|
84
|
+
return preloadCacheRef.current.get(candidate.key) ?? [];
|
|
85
|
+
}
|
|
86
|
+
const existing = inFlightRef.current.get(candidate.key);
|
|
87
|
+
if (existing)
|
|
88
|
+
return existing;
|
|
89
|
+
const promise = client.user
|
|
90
|
+
.synthesizeViewItem({
|
|
91
|
+
keyName,
|
|
92
|
+
contentInputs,
|
|
93
|
+
viewInputs: { ...baseViewInputsRef.current, event: candidate.event },
|
|
94
|
+
})
|
|
95
|
+
.then((res) => {
|
|
96
|
+
const next = Array.isArray(res.uiData) ? res.uiData : [];
|
|
97
|
+
preloadCacheRef.current.set(candidate.key, next);
|
|
98
|
+
inFlightRef.current.delete(candidate.key);
|
|
99
|
+
return next;
|
|
100
|
+
})
|
|
101
|
+
.catch(() => {
|
|
102
|
+
inFlightRef.current.delete(candidate.key);
|
|
103
|
+
return [];
|
|
104
|
+
});
|
|
105
|
+
inFlightRef.current.set(candidate.key, promise);
|
|
106
|
+
return promise;
|
|
107
|
+
},
|
|
108
|
+
// contentInputs object identity changes are tolerated by the
|
|
109
|
+
// fetch path; we only need a fresh `keyName` to invalidate.
|
|
110
|
+
[client, keyName, contentInputs]);
|
|
111
|
+
// Preload pump: whenever the live tree changes, look up speculatable
|
|
112
|
+
// events and prefetch them in the background. Cap so a giant gallery
|
|
113
|
+
// doesn't blow up the LLM budget.
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!preload)
|
|
116
|
+
return;
|
|
117
|
+
const candidates = findPreloadCandidates(liveUiData).slice(0, MAX_SPECULATIONS);
|
|
118
|
+
for (const candidate of candidates)
|
|
119
|
+
void speculate(candidate);
|
|
120
|
+
}, [liveUiData, preload, speculate]);
|
|
121
|
+
const handleEvent = useCallback((event) => {
|
|
122
|
+
if (event.handleWith === 'HOST') {
|
|
123
|
+
onHostEventRef.current?.(event);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
const key = buildEventKey(event.componentName, event.name, event.nodeId, event.payload);
|
|
127
|
+
const cached = preloadCacheRef.current.get(key);
|
|
128
|
+
if (cached) {
|
|
129
|
+
setLiveUiData(cached);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
// Cache miss → live call. The result joins the cache so a repeat
|
|
133
|
+
// event-sequence step is 0ms.
|
|
134
|
+
const candidate = {
|
|
135
|
+
key,
|
|
136
|
+
event: {
|
|
137
|
+
name: event.name,
|
|
138
|
+
componentName: event.componentName,
|
|
139
|
+
payload: event.payload,
|
|
140
|
+
sourceNodeId: event.nodeId,
|
|
141
|
+
priorUiData: liveUiData,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
void speculate(candidate).then((next) => {
|
|
145
|
+
if (next.length > 0)
|
|
146
|
+
setLiveUiData(next);
|
|
147
|
+
});
|
|
148
|
+
}, [liveUiData, speculate]);
|
|
149
|
+
return {
|
|
150
|
+
uiData: liveUiData,
|
|
151
|
+
loading: fetched.loading,
|
|
152
|
+
error: fetched.error,
|
|
153
|
+
handleEvent,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const MAX_SPECULATIONS = 8;
|
|
157
|
+
//# sourceMappingURL=useEventDrivenView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEventDrivenView.js","sourceRoot":"","sources":["../../src/synthesisView/useEventDrivenView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAuBzD,SAAS,WAAW,CAAC,IAAgB;IACnC,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC;AACnC,CAAC;AAED;8EAC8E;AAC9E,SAAS,aAAa,CACpB,aAAqB,EACrB,SAAiB,EACjB,YAAoB,EACpB,OAA4C;IAE5C,6CAA6C;IAC7C,MAAM,UAAU,GAAG,OAAO;QACxB,CAAC,CAAC,IAAI,CAAC,SAAS,CACZ,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;aACjB,IAAI,EAAE;aACN,MAAM,CAA0B,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AS,CAAC,CACxB,CAAC;IAEF,OAAO;QACL,MAAM,EAAE,UAAU;QAClB,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW;KACZ,CAAC;AACJ,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synthesize-batch-manager.js","sourceRoot":"","sources":["../../src/user/synthesize-batch-manager.ts"],"names":[],"mappings":";;;AACA,mDAAgG;AAGhG,mDAAmD;AACnD,SAAS,aAAa;IACpB,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,QAAQ,GAAG,aAAa,EAAE,CAAC;AACjC,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC;AASrC;;;GAGG;AACH,MAAa,sBAAsB;IACzB,KAAK,GAKR,EAAE,CAAC;IACA,KAAK,GAAiB,IAAI,CAAC;IAC3B,SAAS,CAA+B;IACxC,YAAY,CAAS;IAE7B,YAAY,SAAuC,EAAE,YAAoB;QACvE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,MAAqB;QAChC,IAAI,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,CACL,IAAoB,EACpB,eAA2C;QAE3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;YAE5D,cAAc;YACd,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,UAAU,CAAC,IAA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3,"file":"synthesize-batch-manager.js","sourceRoot":"","sources":["../../src/user/synthesize-batch-manager.ts"],"names":[],"mappings":";;;AACA,mDAAgG;AAGhG,mDAAmD;AACnD,SAAS,aAAa;IACpB,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,SAAS,eAAe;IACtB,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,QAAQ,GAAG,aAAa,EAAE,CAAC;AACjC,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC;AASrC;;;GAGG;AACH,MAAa,sBAAsB;IACzB,KAAK,GAKR,EAAE,CAAC;IACA,KAAK,GAAiB,IAAI,CAAC;IAC3B,SAAS,CAA+B;IACxC,YAAY,CAAS;IAE7B,YAAY,SAAuC,EAAE,YAAoB;QACvE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,MAAqB;QAChC,IAAI,CAAC,SAAS,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,CAAC;IAED,OAAO,CACL,IAAoB,EACpB,eAA2C;QAE3C,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC,CAAC;YAE5D,cAAc;YACd,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACzB,CAAC;YAED,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,GAAG,EAAE;gBACzB,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,I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C,IAAI,CAAC,KAAK;wBAAE,SAAS;oBACrB,IAAI,KAAK,CAAC,QAAQ,KAAK,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;wBACpD,KAAK,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;oBACtC,CAAC;yBAAM,CAAC;wBACN,KAAK,CAAC,OAAO,CAAC;4BACZ,IAAI,EAAE,KAAK,CAAC,IAAI;4BAChB,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;4BACxC,KAAK,EAAE,KAAK,CAAC,KAAK;yBACnB,CAAC,CAAC;wBACH,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACrC,CAAC;gBACH,CAAC;YACH,CAAC;YAED,sEAAsE;YACtE,KAAK,MAAM,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;gBACjD,MAAM,CAAC,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC,CAAC;YACrE,CAAC;YACD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACzB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,+BAA+B;YAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACvE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -2,14 +2,24 @@ import type { RequestConfig } from '../request.js';
|
|
|
2
2
|
import type { SynthesizeItems } from './typeDefs.js';
|
|
3
3
|
export type SynthesizeItemResponse = {
|
|
4
4
|
data?: unknown;
|
|
5
|
+
/**
|
|
6
|
+
* Recent stored synthesis outputs when the request set `synthesisHistoryLimit > 0`,
|
|
7
|
+
* ordered most-recent first. The first entry is the current synthesis itself
|
|
8
|
+
* (identical to `data` unless user reranking is configured server-side).
|
|
9
|
+
*/
|
|
10
|
+
synthesisHistory?: unknown[];
|
|
5
11
|
error?: string;
|
|
6
12
|
};
|
|
7
13
|
/**
|
|
8
14
|
* Synthesize stream event types (SSE). Per OpenAPI spec:
|
|
9
15
|
* - Connection: `{ type: 'connected' | 'complete' }`
|
|
10
|
-
* - Data: `{ index, data?, complete, error? }`.
|
|
16
|
+
* - Data: `{ index, data?, synthesisHistory?, complete, error? }`.
|
|
11
17
|
* Multiple events may be sent for the same index as partial object updates; the final event
|
|
12
|
-
* for that index has `complete: true` and contains the validated object.
|
|
18
|
+
* for that index has `complete: true` and contains the validated object. When the request
|
|
19
|
+
* set `synthesisHistoryLimit > 0`, the final event also includes `synthesisHistory`: an
|
|
20
|
+
* array of recent stored `data` payloads (most-recent first; the first entry is the current
|
|
21
|
+
* synthesis itself — identical to `data` unless user reranking is configured, in which case
|
|
22
|
+
* it is the unreranked source).
|
|
13
23
|
*/
|
|
14
24
|
export type SynthesizeEvent = {
|
|
15
25
|
type: 'connected';
|
|
@@ -18,6 +28,7 @@ export type SynthesizeEvent = {
|
|
|
18
28
|
} | {
|
|
19
29
|
index: number;
|
|
20
30
|
data?: unknown;
|
|
31
|
+
synthesisHistory?: unknown[];
|
|
21
32
|
complete: boolean;
|
|
22
33
|
error?: string;
|
|
23
34
|
};
|
|
@@ -30,7 +41,7 @@ export interface SynthesizeOptions {
|
|
|
30
41
|
* Synthesize content items personalized to the user (streaming SSE).
|
|
31
42
|
*
|
|
32
43
|
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
33
|
-
* @param items - Array of items: each has optional inputs (`type`: externalId | text | excludeExternalIds, `value`), output (schema as JSON string or Zod 4 schema), optional configurationKeyName, optional
|
|
44
|
+
* @param items - Array of items: each has optional inputs (`type`: externalId | text | excludeExternalIds, `value`), output (schema as JSON string or Zod 4 schema), optional configurationKeyName, optional synthesisHistoryLimit (how many recent stored outputs to expose in the final event's `synthesisHistory` array; defaults to 0 — no history emitted), optional searchOptionsOverrides (e.g. lookbackMinutes)
|
|
34
45
|
* @param options - Optional: onStreamingData(index, data) called for each streaming data update per item index
|
|
35
46
|
* @returns AsyncIterable yielding connection events (connected, complete) and data events (index, data?, complete, error?). Data may be partial until an event with complete: true for that index.
|
|
36
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/user/synthesize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"synthesize.d.ts","sourceRoot":"","sources":["../../src/user/synthesize.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,eAAe,CAAC;AAExE,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IACE,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gBAAgB,CAAC,EAAE,OAAO,EAAE,CAAC;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAsBN,kGAAkG;AAClG,MAAM,WAAW,iBAAiB;IAChC,qFAAqF;IACrF,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CAC1D;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAsBzC;AAED,wEAAwE;AACxE,MAAM,MAAM,yBAAyB,GACnC,OAAO,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
package/dist/user/synthesize.js
CHANGED
|
@@ -25,7 +25,7 @@ function normalizeSynthesizeItems(items) {
|
|
|
25
25
|
* Synthesize content items personalized to the user (streaming SSE).
|
|
26
26
|
*
|
|
27
27
|
* @param config - Request configuration with base URL, timeout, fetch, and optional token
|
|
28
|
-
* @param items - Array of items: each has optional inputs (`type`: externalId | text | excludeExternalIds, `value`), output (schema as JSON string or Zod 4 schema), optional configurationKeyName, optional
|
|
28
|
+
* @param items - Array of items: each has optional inputs (`type`: externalId | text | excludeExternalIds, `value`), output (schema as JSON string or Zod 4 schema), optional configurationKeyName, optional synthesisHistoryLimit (how many recent stored outputs to expose in the final event's `synthesisHistory` array; defaults to 0 — no history emitted), optional searchOptionsOverrides (e.g. lookbackMinutes)
|
|
29
29
|
* @param options - Optional: onStreamingData(index, data) called for each streaming data update per item index
|
|
30
30
|
* @returns AsyncIterable yielding connection events (connected, complete) and data events (index, data?, complete, error?). Data may be partial until an event with complete: true for that index.
|
|
31
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synthesize.js","sourceRoot":"","sources":["../../src/user/synthesize.ts"],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