@farero-ai/ui 0.4.4 → 0.4.6
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 +26 -1
- package/dist/chunks/DataTable-ITEU54LT.js +1 -0
- package/dist/chunks/catalog-FuTW6oW-.d.ts +329 -0
- package/dist/chunks/chunk-5WPOTZ7L.js +3 -0
- package/dist/chunks/chunk-6RFRRT4V.js +1 -0
- package/dist/chunks/chunk-HE55M4S6.js +1 -0
- package/dist/chunks/{chunk-756GM57N.js → chunk-JMYCJ5PW.js} +1 -1
- package/dist/chunks/chunk-MMVOWP5T.js +0 -0
- package/dist/chunks/chunk-QHXTSMN4.js +5 -0
- package/dist/controls.d.ts +13 -2
- package/dist/controls.js +1 -1
- package/dist/diagram.js +1 -1
- package/dist/generated-ui/parse.d.ts +56 -0
- package/dist/generated-ui/parse.js +1 -0
- package/dist/generated-ui.d.ts +48 -0
- package/dist/generated-ui.js +1 -0
- package/dist/markdown.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/table.d.ts +3 -1
- package/dist/table.js +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/transcript.js +12 -9
- package/package.json +12 -2
- package/dist/chunks/DataTable-GR4HPUOJ.js +0 -1
- package/dist/chunks/chunk-UNO25KYE.js +0 -1
- package/dist/chunks/chunk-YUMLJSXL.js +0 -5
- /package/dist/chunks/{chunk-WMKRKKIS.js → chunk-RWGTJDY3.js} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Farero UI
|
|
2
2
|
|
|
3
|
-
React components that draw agent replies
|
|
3
|
+
React components that draw agent replies, chat transcripts, and generated panels the way Farero draws them. Farero's web app uses them from this workspace as `@farero/ui`. Other apps install the published build, `@farero-ai/ui`.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -144,6 +144,31 @@ Chat tabs and the full-pane transcript loader are the only app surfaces that use
|
|
|
144
144
|
|
|
145
145
|
The development-only `/activity-preview.html` renders the actual app components with local sample data, supports closing/restoring and reordering sample tabs, and shows all 18 assignments. It does not connect to a workspace.
|
|
146
146
|
|
|
147
|
+
## Render a generated panel
|
|
148
|
+
|
|
149
|
+
A generated panel is a fenced block in a message. The header is `farero-ui`, a stable id, and a short title. Each following line is one JSON patch (`add`, `replace`, or `remove`) on `/root`, `/elements`, or `/state`. A closing fence publishes the panel. Prose before and after the fence stays prose.
|
|
150
|
+
|
|
151
|
+
The parser and the React renderer share one implementation. Import the parser from `@farero-ai/ui/generated-ui/parse`. That entry does not import React, so a Worker can use it. `generatedUiParts` splits a message into frozen blocks. Each block has `start` and `end`, and a panel's `source` is the exact fence text. `preservesPublishedPanels(original, edited)` is true when every complete fence is still there, in order, with the same id, title, and source. An unclosed fence is not a published panel. `parseGeneratedUi` validates a complete panel.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { generatedUiParts, preservesPublishedPanels } from '@farero-ai/ui/generated-ui/parse'
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Draw the same split in a browser:
|
|
158
|
+
|
|
159
|
+
```tsx
|
|
160
|
+
import '@farero-ai/ui/styles.css'
|
|
161
|
+
import { GeneratedUiContent, releaseGeneratedUiMemory } from '@farero-ai/ui/generated-ui'
|
|
162
|
+
|
|
163
|
+
<GeneratedUiContent text={message} memoryKey={`${accountId}:${conversationId}:${messageId}`} />
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
`memoryKey` keeps that reader's filters, tabs, sort, and selections in memory. Scrolling away and back uses the same key and the same controls. `releaseGeneratedUiMemory()` drops them when the person signs out. Closing the page drops them too. The package does not write `localStorage`, send a request, or submit a chat message.
|
|
167
|
+
|
|
168
|
+
Pass `onSubmit` only when a button click should leave the panel. Without it, buttons stay inactive. Omit `store` unless the host has its own saved fields. Farero passes its store and `onSubmit`; other callers can leave both off.
|
|
169
|
+
|
|
170
|
+
`renderText` draws the prose with your own Markdown. The default uses `MarkdownBody`.
|
|
171
|
+
|
|
147
172
|
## Work on the package in Farero
|
|
148
173
|
|
|
149
174
|
Farero imports the TypeScript source through `@farero/ui/<entry>`, and Vite compiles it with the app. Its own stylesheet imports the package's Markdown and control styles. The package reads Farero's browser-safe protocol modules in `src/` and nothing from `web/`. `yarn check:imports` enforces that boundary.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as a}from"./chunk-6RFRRT4V.js";import"./chunk-LHMFMBHY.js";import"./chunk-ITKN2ASJ.js";import"./chunk-RR7BB4EQ.js";import"./chunk-ZVJQ5X63.js";import"./chunk-HGN4GN2E.js";import"./chunk-5SBKMKFB.js";import"./chunk-3I4YBQX6.js";export{a as default};
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import * as _json_render_core from '@json-render/core';
|
|
2
|
+
import { VisibilityCondition } from '@json-render/core';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/** The same component definitions describe the agent's choices and type the React registry. */
|
|
6
|
+
declare const generatedUiComponents: {
|
|
7
|
+
Stack: {
|
|
8
|
+
props: z.ZodObject<{
|
|
9
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
horizontal: "horizontal";
|
|
11
|
+
vertical: "vertical";
|
|
12
|
+
}>>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
slots: string[];
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
Card: {
|
|
18
|
+
props: z.ZodObject<{
|
|
19
|
+
title: z.ZodOptional<z.ZodString>;
|
|
20
|
+
description: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>;
|
|
22
|
+
slots: string[];
|
|
23
|
+
description: string;
|
|
24
|
+
};
|
|
25
|
+
Text: {
|
|
26
|
+
props: z.ZodObject<{
|
|
27
|
+
text: z.ZodString;
|
|
28
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
muted: "muted";
|
|
30
|
+
normal: "normal";
|
|
31
|
+
}>>;
|
|
32
|
+
}, z.core.$strict>;
|
|
33
|
+
slots: never[];
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
Table: {
|
|
37
|
+
props: z.ZodObject<{
|
|
38
|
+
columns: z.ZodArray<z.ZodString>;
|
|
39
|
+
rows: z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
40
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strict>;
|
|
42
|
+
slots: never[];
|
|
43
|
+
description: string;
|
|
44
|
+
};
|
|
45
|
+
Chart: {
|
|
46
|
+
props: z.ZodObject<{
|
|
47
|
+
title: z.ZodString;
|
|
48
|
+
kind: z.ZodEnum<{
|
|
49
|
+
line: "line";
|
|
50
|
+
bar: "bar";
|
|
51
|
+
}>;
|
|
52
|
+
data: z.ZodArray<z.ZodObject<{
|
|
53
|
+
label: z.ZodString;
|
|
54
|
+
value: z.ZodNumber;
|
|
55
|
+
}, z.core.$strict>>;
|
|
56
|
+
valueLabel: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
slots: never[];
|
|
59
|
+
description: string;
|
|
60
|
+
};
|
|
61
|
+
Tabs: {
|
|
62
|
+
props: z.ZodObject<{
|
|
63
|
+
name: z.ZodOptional<z.ZodString>;
|
|
64
|
+
labels: z.ZodArray<z.ZodString>;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
slots: string[];
|
|
67
|
+
description: string;
|
|
68
|
+
};
|
|
69
|
+
Input: {
|
|
70
|
+
props: z.ZodObject<{
|
|
71
|
+
name: z.ZodString;
|
|
72
|
+
label: z.ZodString;
|
|
73
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
74
|
+
number: "number";
|
|
75
|
+
text: "text";
|
|
76
|
+
email: "email";
|
|
77
|
+
}>>;
|
|
78
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
79
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
80
|
+
value: z.ZodOptional<z.ZodString>;
|
|
81
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
slots: never[];
|
|
84
|
+
description: string;
|
|
85
|
+
};
|
|
86
|
+
Select: {
|
|
87
|
+
props: z.ZodObject<{
|
|
88
|
+
name: z.ZodString;
|
|
89
|
+
label: z.ZodString;
|
|
90
|
+
options: z.ZodArray<z.ZodObject<{
|
|
91
|
+
label: z.ZodString;
|
|
92
|
+
value: z.ZodString;
|
|
93
|
+
}, z.core.$strict>>;
|
|
94
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
95
|
+
value: z.ZodOptional<z.ZodString>;
|
|
96
|
+
}, z.core.$strict>;
|
|
97
|
+
slots: never[];
|
|
98
|
+
description: string;
|
|
99
|
+
};
|
|
100
|
+
Toggle: {
|
|
101
|
+
props: z.ZodObject<{
|
|
102
|
+
name: z.ZodString;
|
|
103
|
+
label: z.ZodString;
|
|
104
|
+
defaultValue: z.ZodOptional<z.ZodBoolean>;
|
|
105
|
+
checked: z.ZodOptional<z.ZodBoolean>;
|
|
106
|
+
}, z.core.$strict>;
|
|
107
|
+
slots: never[];
|
|
108
|
+
description: string;
|
|
109
|
+
};
|
|
110
|
+
Button: {
|
|
111
|
+
props: z.ZodObject<{
|
|
112
|
+
label: z.ZodString;
|
|
113
|
+
}, z.core.$strict>;
|
|
114
|
+
slots: never[];
|
|
115
|
+
description: string;
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
declare const generatedUiCatalog: _json_render_core.Catalog<{
|
|
119
|
+
spec: _json_render_core.SchemaType<"object", {
|
|
120
|
+
root: _json_render_core.SchemaType<"string", unknown>;
|
|
121
|
+
elements: _json_render_core.SchemaType<"record", _json_render_core.SchemaType<"object", {
|
|
122
|
+
type: _json_render_core.SchemaType<"ref", string>;
|
|
123
|
+
props: _json_render_core.SchemaType<"propsOf", string>;
|
|
124
|
+
children: _json_render_core.SchemaType<"array", _json_render_core.SchemaType<"string", unknown>>;
|
|
125
|
+
slots: {
|
|
126
|
+
optional: true;
|
|
127
|
+
kind: "record";
|
|
128
|
+
inner?: _json_render_core.SchemaType<"array", _json_render_core.SchemaType<"string", unknown>> | undefined;
|
|
129
|
+
};
|
|
130
|
+
visible: {
|
|
131
|
+
optional: true;
|
|
132
|
+
kind: "any";
|
|
133
|
+
inner?: unknown;
|
|
134
|
+
};
|
|
135
|
+
repeat: {
|
|
136
|
+
optional: true;
|
|
137
|
+
kind: "any";
|
|
138
|
+
inner?: unknown;
|
|
139
|
+
};
|
|
140
|
+
}>>;
|
|
141
|
+
}>;
|
|
142
|
+
catalog: _json_render_core.SchemaType<"object", {
|
|
143
|
+
components: _json_render_core.SchemaType<"map", {
|
|
144
|
+
props: _json_render_core.SchemaType<"zod", unknown>;
|
|
145
|
+
slots: _json_render_core.SchemaType<"array", _json_render_core.SchemaType<"string", unknown>>;
|
|
146
|
+
description: _json_render_core.SchemaType<"string", unknown>;
|
|
147
|
+
example: _json_render_core.SchemaType<"any", unknown>;
|
|
148
|
+
}>;
|
|
149
|
+
actions: _json_render_core.SchemaType<"map", {
|
|
150
|
+
params: _json_render_core.SchemaType<"zod", unknown>;
|
|
151
|
+
description: _json_render_core.SchemaType<"string", unknown>;
|
|
152
|
+
}>;
|
|
153
|
+
}>;
|
|
154
|
+
}, {
|
|
155
|
+
components: {
|
|
156
|
+
Stack: {
|
|
157
|
+
props: z.ZodObject<{
|
|
158
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
159
|
+
horizontal: "horizontal";
|
|
160
|
+
vertical: "vertical";
|
|
161
|
+
}>>;
|
|
162
|
+
}, z.core.$strict>;
|
|
163
|
+
slots: string[];
|
|
164
|
+
description: string;
|
|
165
|
+
};
|
|
166
|
+
Card: {
|
|
167
|
+
props: z.ZodObject<{
|
|
168
|
+
title: z.ZodOptional<z.ZodString>;
|
|
169
|
+
description: z.ZodOptional<z.ZodString>;
|
|
170
|
+
}, z.core.$strict>;
|
|
171
|
+
slots: string[];
|
|
172
|
+
description: string;
|
|
173
|
+
};
|
|
174
|
+
Text: {
|
|
175
|
+
props: z.ZodObject<{
|
|
176
|
+
text: z.ZodString;
|
|
177
|
+
tone: z.ZodOptional<z.ZodEnum<{
|
|
178
|
+
muted: "muted";
|
|
179
|
+
normal: "normal";
|
|
180
|
+
}>>;
|
|
181
|
+
}, z.core.$strict>;
|
|
182
|
+
slots: never[];
|
|
183
|
+
description: string;
|
|
184
|
+
};
|
|
185
|
+
Table: {
|
|
186
|
+
props: z.ZodObject<{
|
|
187
|
+
columns: z.ZodArray<z.ZodString>;
|
|
188
|
+
rows: z.ZodArray<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
|
|
189
|
+
caption: z.ZodOptional<z.ZodString>;
|
|
190
|
+
}, z.core.$strict>;
|
|
191
|
+
slots: never[];
|
|
192
|
+
description: string;
|
|
193
|
+
};
|
|
194
|
+
Chart: {
|
|
195
|
+
props: z.ZodObject<{
|
|
196
|
+
title: z.ZodString;
|
|
197
|
+
kind: z.ZodEnum<{
|
|
198
|
+
line: "line";
|
|
199
|
+
bar: "bar";
|
|
200
|
+
}>;
|
|
201
|
+
data: z.ZodArray<z.ZodObject<{
|
|
202
|
+
label: z.ZodString;
|
|
203
|
+
value: z.ZodNumber;
|
|
204
|
+
}, z.core.$strict>>;
|
|
205
|
+
valueLabel: z.ZodOptional<z.ZodString>;
|
|
206
|
+
}, z.core.$strict>;
|
|
207
|
+
slots: never[];
|
|
208
|
+
description: string;
|
|
209
|
+
};
|
|
210
|
+
Tabs: {
|
|
211
|
+
props: z.ZodObject<{
|
|
212
|
+
name: z.ZodOptional<z.ZodString>;
|
|
213
|
+
labels: z.ZodArray<z.ZodString>;
|
|
214
|
+
}, z.core.$strict>;
|
|
215
|
+
slots: string[];
|
|
216
|
+
description: string;
|
|
217
|
+
};
|
|
218
|
+
Input: {
|
|
219
|
+
props: z.ZodObject<{
|
|
220
|
+
name: z.ZodString;
|
|
221
|
+
label: z.ZodString;
|
|
222
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
223
|
+
number: "number";
|
|
224
|
+
text: "text";
|
|
225
|
+
email: "email";
|
|
226
|
+
}>>;
|
|
227
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
228
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
229
|
+
value: z.ZodOptional<z.ZodString>;
|
|
230
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
231
|
+
}, z.core.$strict>;
|
|
232
|
+
slots: never[];
|
|
233
|
+
description: string;
|
|
234
|
+
};
|
|
235
|
+
Select: {
|
|
236
|
+
props: z.ZodObject<{
|
|
237
|
+
name: z.ZodString;
|
|
238
|
+
label: z.ZodString;
|
|
239
|
+
options: z.ZodArray<z.ZodObject<{
|
|
240
|
+
label: z.ZodString;
|
|
241
|
+
value: z.ZodString;
|
|
242
|
+
}, z.core.$strict>>;
|
|
243
|
+
defaultValue: z.ZodOptional<z.ZodString>;
|
|
244
|
+
value: z.ZodOptional<z.ZodString>;
|
|
245
|
+
}, z.core.$strict>;
|
|
246
|
+
slots: never[];
|
|
247
|
+
description: string;
|
|
248
|
+
};
|
|
249
|
+
Toggle: {
|
|
250
|
+
props: z.ZodObject<{
|
|
251
|
+
name: z.ZodString;
|
|
252
|
+
label: z.ZodString;
|
|
253
|
+
defaultValue: z.ZodOptional<z.ZodBoolean>;
|
|
254
|
+
checked: z.ZodOptional<z.ZodBoolean>;
|
|
255
|
+
}, z.core.$strict>;
|
|
256
|
+
slots: never[];
|
|
257
|
+
description: string;
|
|
258
|
+
};
|
|
259
|
+
Button: {
|
|
260
|
+
props: z.ZodObject<{
|
|
261
|
+
label: z.ZodString;
|
|
262
|
+
}, z.core.$strict>;
|
|
263
|
+
slots: never[];
|
|
264
|
+
description: string;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
actions: {
|
|
268
|
+
submit: {
|
|
269
|
+
params: z.ZodObject<{
|
|
270
|
+
prompt: z.ZodString;
|
|
271
|
+
}, z.core.$strict>;
|
|
272
|
+
description: string;
|
|
273
|
+
};
|
|
274
|
+
};
|
|
275
|
+
}>;
|
|
276
|
+
declare const generatedUiInputSchema: z.ZodObject<{
|
|
277
|
+
id: z.ZodString;
|
|
278
|
+
title: z.ZodString;
|
|
279
|
+
spec: z.ZodObject<{
|
|
280
|
+
root: z.ZodString;
|
|
281
|
+
elements: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
282
|
+
type: z.ZodEnum<{
|
|
283
|
+
Stack: "Stack";
|
|
284
|
+
Card: "Card";
|
|
285
|
+
Text: "Text";
|
|
286
|
+
Table: "Table";
|
|
287
|
+
Chart: "Chart";
|
|
288
|
+
Tabs: "Tabs";
|
|
289
|
+
Input: "Input";
|
|
290
|
+
Select: "Select";
|
|
291
|
+
Toggle: "Toggle";
|
|
292
|
+
Button: "Button";
|
|
293
|
+
}>;
|
|
294
|
+
props: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
295
|
+
children: z.ZodArray<z.ZodString>;
|
|
296
|
+
visible: z.ZodOptional<z.ZodType<VisibilityCondition, unknown, z.core.$ZodTypeInternals<VisibilityCondition, unknown>>>;
|
|
297
|
+
on: z.ZodOptional<z.ZodObject<{
|
|
298
|
+
press: z.ZodObject<{
|
|
299
|
+
action: z.ZodLiteral<"submit">;
|
|
300
|
+
params: z.ZodObject<{
|
|
301
|
+
prompt: z.ZodString;
|
|
302
|
+
}, z.core.$strict>;
|
|
303
|
+
}, z.core.$strict>;
|
|
304
|
+
}, z.core.$strict>>;
|
|
305
|
+
}, z.core.$strict>>;
|
|
306
|
+
state: z.ZodOptional<z.ZodObject<{
|
|
307
|
+
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
308
|
+
values: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>>;
|
|
309
|
+
}, z.core.$strict>>;
|
|
310
|
+
}, z.core.$strict>;
|
|
311
|
+
}, z.core.$strict>;
|
|
312
|
+
type GeneratedUiInput = z.infer<typeof generatedUiInputSchema>;
|
|
313
|
+
type GeneratedUiSpec = GeneratedUiInput['spec'];
|
|
314
|
+
interface GeneratedUiSnapshot extends GeneratedUiInput {
|
|
315
|
+
version: 1;
|
|
316
|
+
sessionId: string;
|
|
317
|
+
}
|
|
318
|
+
/** Validation precedes persistence and rendering. Expressions only read panel-owned data. */
|
|
319
|
+
declare function parseGeneratedUi(input: unknown): GeneratedUiInput;
|
|
320
|
+
declare function generatedUiInitialValues(spec: GeneratedUiSpec): Record<string, string | boolean>;
|
|
321
|
+
declare function generatedUiState(spec: GeneratedUiSpec, values?: Record<string, string | boolean>): {
|
|
322
|
+
data: Record<string, unknown>;
|
|
323
|
+
values: {
|
|
324
|
+
[x: string]: string | boolean;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
export { generatedUiComponents as c, generatedUiInitialValues as d, generatedUiInputSchema as e, generatedUiState as f, generatedUiCatalog as g, parseGeneratedUi as p };
|
|
329
|
+
export type { GeneratedUiInput as G, GeneratedUiSpec as a, GeneratedUiSnapshot as b };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as p}from"./chunk-3I4YBQX6.js";import{resolveElementProps as $}from"@json-render/core";import{z as s}from"zod";var k=s.string().regex(/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/).refine(e=>!["constructor","prototype","__proto__"].includes(e),"Reserved name"),U=s.string().max(300).regex(/^\/(?:values|data)(?:\/[a-zA-Z0-9_-]+)*$/).refine(e=>!e.split("/").some(n=>["constructor","prototype","__proto__"].includes(n))),G=s.union([s.boolean(),s.strictObject({$state:U,eq:s.unknown().optional(),neq:s.unknown().optional(),gt:s.number().optional(),gte:s.number().optional(),lt:s.number().optional(),lte:s.number().optional(),not:s.boolean().optional()})]),v=s.lazy(()=>s.union([G,s.array(v).max(20),s.strictObject({$or:s.array(v).max(20)})]));function j(e,n=0){if(n>20)throw new Error("Panel data is nested too deeply");if(e&&typeof e=="object"){if(Object.keys(e).length>500)throw new Error("Too many panel values");for(let[r,o]of Object.entries(e)){if(["__proto__","prototype","constructor"].includes(r))throw new Error("Reserved property");j(o,n+1)}}}p(j,"boundUiJson");var C=s.lazy(()=>s.union([s.strictObject({$state:U}),s.strictObject({$bindState:U.regex(/^\/values\/[a-zA-Z][a-zA-Z0-9_-]*$/)}),s.strictObject({$template:s.string().max(8e3)}),s.strictObject({$computed:s.enum(["filter","sum","multiply","formatNumber"]),args:s.record(s.string(),s.unknown())})])),V={filter:p(({items:e,field:n,value:r,operator:o="eq"})=>Array.isArray(e)?e.slice(0,500).filter(a=>{let i=a&&typeof a=="object"&&Object.hasOwn(a,String(n))?a[String(n)]:void 0;return o==="lte"?Number(i)<=Number(r):o==="gte"?Number(i)>=Number(r):o==="contains"?String(i??"").toLowerCase().includes(String(r??"").toLowerCase()):i===r}):[],"filter"),sum:p(({items:e,field:n})=>Array.isArray(e)?e.slice(0,500).reduce((r,o)=>{let a=n===void 0?o:o&&typeof o=="object"&&Object.hasOwn(o,String(n))?o[String(n)]:0,i=r+Number(a);return Number.isFinite(i)?i:r},0):0,"sum"),multiply:p(({a:e,b:n})=>Number.isFinite(Number(e)*Number(n))?Number(e)*Number(n):0,"multiply"),formatNumber:p(({value:e})=>Number.isFinite(Number(e))?new Intl.NumberFormat("en",{maximumFractionDigits:2}).format(Number(e)):"","formatNumber")};function S(e,n=0){if(n>12)throw new Error("Panel values can nest at most 12 levels");if(Array.isArray(e)){if(e.length>500)throw new Error("Panel arrays can contain at most 500 items");for(let r of e)S(r,n+1)}else if(e&&typeof e=="object"){let r=e,o=Object.keys(r);if(o.some(a=>["__proto__","constructor","prototype"].includes(a)))throw new Error("Reserved property");if(o.some(a=>a.startsWith("$"))&&(C.parse(r),typeof r.$template=="string"))for(let a of r.$template.matchAll(/\$\{([^}]+)\}/g))U.parse(a[1]);for(let a of Object.values(r))S(a,n+1)}else if(typeof e=="number"&&!Number.isFinite(e))throw new Error("Panel numbers must be finite")}p(S,"validateUiValue");function E(e,n){return $(e,{stateModel:n,functions:V})}p(E,"resolveUiProps");import{defineCatalog as R}from"@json-render/core";import{schema as Z}from"@json-render/react/schema";import{z as t}from"zod";var b=t.string().max(300),P=t.string().max(8e3),x=k,F=t.union([t.string().max(2e3),t.number().finite(),t.boolean(),t.null()]),J=t.strictObject({label:b,value:t.string().max(300)}),N={Stack:{props:t.strictObject({direction:t.enum(["vertical","horizontal"]).optional()}),slots:["default"],description:"A responsive group of components. Horizontal groups wrap on small screens."},Card:{props:t.strictObject({title:b.optional(),description:P.optional()}),slots:["default"],description:"Group related content under an optional heading."},Text:{props:t.strictObject({text:P,tone:t.enum(["normal","muted"]).optional()}),slots:[],description:"Plain text. Include sources, assumptions and estimates here."},Table:{props:t.strictObject({columns:t.array(b).min(1).max(20),rows:t.array(t.array(F).max(20)).max(500),caption:b.optional()}),slots:[],description:"A table with local filtering, sorting, row selection and CSV export."},Chart:{props:t.strictObject({title:b,kind:t.enum(["bar","line"]),data:t.array(t.strictObject({label:b,value:t.number().finite()})).min(1).max(100),valueLabel:b.optional()}),slots:[],description:"A chart of supplied numeric data with a local label filter and accessible values."},Tabs:{props:t.strictObject({name:x.optional(),labels:t.array(b).min(1).max(8)}),slots:["default"],description:"One label per child, in the same order. The selected child is saved across reloads and revisions. Keep the element key (or optional name) and child keys stable."},Input:{props:t.strictObject({name:x,label:b,type:t.enum(["text","number","email"]).optional(),placeholder:b.optional(),defaultValue:t.string().max(4e3).optional(),value:t.string().max(4e3).optional(),required:t.boolean().optional()}),slots:[],description:"A named form field. Names are unique across the panel. Values go to the agent only on Submit."},Select:{props:t.strictObject({name:x,label:b,options:t.array(J).min(1).max(50),defaultValue:t.string().max(300).optional(),value:t.string().max(300).optional()}),slots:[],description:"A named single-choice field."},Toggle:{props:t.strictObject({name:x,label:b,defaultValue:t.boolean().optional(),checked:t.boolean().optional()}),slots:[],description:"A named boolean field."},Button:{props:t.strictObject({label:b}),slots:[],description:"Sends the form values to this chat when clicked. Requires on.press with action submit and params.prompt describing the request."}},re=R(Z,{components:N,actions:{submit:{params:t.strictObject({prompt:P.min(1)}),description:"Send the user-selected values and this request to the same chat through normal prompt intake."}}}),q=t.strictObject({type:t.enum(["Stack","Card","Text","Table","Chart","Tabs","Input","Select","Toggle","Button"]),props:t.record(t.string(),t.unknown()),children:t.array(x).max(100),visible:v.optional(),on:t.strictObject({press:t.strictObject({action:t.literal("submit"),params:t.strictObject({prompt:P.min(1)})})}).optional()}),I=t.strictObject({id:x.describe("A stable panel name within this chat. Reuse it for an updated version; earlier versions remain in history."),title:b.min(1),spec:t.strictObject({root:x,elements:t.record(x,q),state:t.strictObject({data:t.record(t.string(),t.unknown()).optional(),values:t.record(x,t.union([t.string().max(4e3),t.boolean()])).optional()}).optional()})});function T(e){if(j(e),new TextEncoder().encode(JSON.stringify(e)).length>256*1024)throw new Error("A panel must fit within 256 KiB");S(e?.spec?.state);let n=I.parse(e);if(new TextEncoder().encode(JSON.stringify(n)).length>256*1024)throw new Error("A panel must fit within 256 KiB");let{root:r,elements:o}=n.spec,a=_(n.spec);if(Object.keys(o).length>100)throw new Error("A panel can contain at most 100 elements");let i=new Set,h=new Set,O=new Set,u=p((m,w)=>{if(w>12)throw new Error("A panel can nest at most 12 levels");if(i.has(m))throw new Error(`Element ${m} is repeated or forms a cycle`);if(!Object.hasOwn(o,m))throw new Error(`Missing element ${m}`);i.add(m);let c=o[m],g=N[c.type];S(c.props);let f=g.props.parse(E(c.props,a));for(let l of["name","defaultValue","options","type"])if(JSON.stringify(c.props[l])!==JSON.stringify(f[l]))throw new Error(`${l} must be literal`);for(let[l,d]of Object.entries(c.props)){if(["Input","Select","Toggle"].includes(c.type)&&["value","checked"].includes(l)&&d&&typeof d=="object"&&!("$bindState"in d))throw new Error("Editable values must bind to their own field");if(d&&typeof d=="object"&&"$bindState"in d&&(!["Input","Select","Toggle"].includes(c.type)||!["value","checked"].includes(l)||d.$bindState!==`/values/${f.name}`))throw new Error("Inputs must bind to their own named value")}if(!g.slots.length&&c.children.length)throw new Error(`${c.type} cannot have children`);if(c.type==="Button"?!c.on:c.on)throw new Error("Only Button supports actions, and every Button needs on.press");let y=c.type==="Tabs"?f.name??m:f.name;if(typeof y=="string"){let l=c.type==="Tabs"?O:h;if(l.has(y))throw new Error(`Duplicate field name ${y}`);l.add(y)}if(c.type==="Table"){let l=f;if(l.rows.some(d=>d.length!==l.columns.length))throw new Error("Every table row needs one cell per column")}if(c.type==="Tabs"&&f.labels.length!==c.children.length)throw new Error("Tabs need one label per child");if(c.type==="Select"){let l=f;if(l.defaultValue!==void 0&&!l.options.some(d=>d.value===l.defaultValue))throw new Error("Select defaultValue must name one of its options")}for(let l of c.children)u(l,w+1)},"visit");if(u(r,1),i.size!==Object.keys(o).length)throw new Error("Every element must be reachable from the root");return n}p(T,"parseGeneratedUi");function B(e){let n={};for(let r of Object.values(e.elements))r.type==="Input"&&(n[String(r.props.name)]=String(r.props.defaultValue??(typeof r.props.value=="string"?r.props.value:""))),r.type==="Select"&&(n[String(r.props.name)]=String(r.props.defaultValue??(typeof r.props.value=="string"?r.props.value:void 0)??r.props.options?.[0]?.value??"")),r.type==="Toggle"&&(n[String(r.props.name)]=(r.props.defaultValue??r.props.checked)===!0);return{...n,...e.state?.values}}p(B,"generatedUiInitialValues");function _(e,n={}){return{data:e.state?.data??{},values:{...B(e),...n}}}p(_,"generatedUiState");import{createSpecStreamCompiler as M}from"@json-render/core";function K(e){return!e||typeof e!="object"||Array.isArray(e)||!("op"in e)||typeof e.op!="string"||!("path"in e)||typeof e.path!="string"?!1:["add","replace","remove"].includes(e.op)&&/^\/(root|elements|state)(\/[^/~]+)*$/.test(e.path)&&!e.path.split("/").some(n=>["__proto__","constructor","prototype"].includes(n))}p(K,"isPatch");function L(e){let n=_(e.spec),r=new Set,o=p((i,h)=>{let O=e.spec.elements[i];if(!O||r.has(i)||h>12)return;r.add(i);let u=structuredClone(O),m={},w=[],c=[],g=E(u.props,n);for(let[f,y]of u.children.entries()){let l=o(y,h+1);l&&(Object.assign(m,l),w.push(y),Array.isArray(g.labels)&&c.push(g.labels[f]))}u.children=w,u.type==="Tabs"&&(u.props.labels=c),m[i]=u;try{return T({...e,spec:{root:i,elements:m,state:n}}),m}catch{return}},"visit"),a=o(e.spec.root,1);return a?{...e,spec:{...e.spec,elements:a,state:n}}:void 0}p(L,"previewPanel");function z(e){return D(e).filter(n=>n.kind==="panel"&&n.complete)}p(z,"published");function le(e,n){let r=z(e),o=z(n);return r.length===o.length&&r.every((a,i)=>{let h=o[i];return h!==void 0&&a.id===h.id&&a.title===h.title&&a.source===h.source})}p(le,"preservesPublishedPanels");function D(e){let n=[],r=/^```farero-ui ([a-zA-Z][a-zA-Z0-9_-]{0,63}) ([^\r\n]{1,300})\r?\n/gm,o=0,a=0;for(let i=r.exec(e);i;i=r.exec(e)){if(i.index<o)continue;i.index>o&&n.push(Object.freeze({kind:"text",text:e.slice(o,i.index),offset:o,start:o,end:i.index}));let h=i.index+i[0].length,O=/^```\s*$/gm;O.lastIndex=h;let u=O.exec(e),m=!!u,w=u?u.index+u[0].length:e.length,c=e.slice(h,u?.index??e.length),g={kind:"panel",index:a++,id:i[1],title:i[2],complete:m,start:i.index,end:w,source:e.slice(i.index,w)};try{if(k.parse(g.id),c.length>256*1024)throw new Error("Panel is too large");let f=M(),y=c.split(`
|
|
2
|
+
`);if(m||y.pop(),y.length>1200)throw new Error("Too many panel updates");for(let d of y){if(!d.trim())continue;let A=JSON.parse(d);if(j(A),!K(A))throw new Error("Invalid panel patch");f.push(`${JSON.stringify(A)}
|
|
3
|
+
`)}let l={id:g.id,title:g.title,spec:f.getResult()};if(m)g.panel=T(l);else{let d=I.safeParse(l);d.success&&(g.panel=L(d.data))}}catch(f){g.error=f instanceof Error?f.message:"Invalid panel"}if(n.push(Object.freeze(g)),o=w,!u)break;r.lastIndex=o}return o<e.length&&n.push(Object.freeze({kind:"text",text:e.slice(o),offset:o,start:o,end:e.length})),Object.freeze(n)}p(D,"generatedUiParts");export{k as a,G as b,v as c,j as d,C as e,V as f,S as g,E as h,N as i,re as j,I as k,T as l,B as m,_ as n,le as o,D as p};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Z,b as _,c as j,e as J}from"./chunk-LHMFMBHY.js";import{g as G}from"./chunk-RR7BB4EQ.js";import{a as Q,c as k}from"./chunk-ZVJQ5X63.js";import{a as O}from"./chunk-HGN4GN2E.js";import{a as l}from"./chunk-3I4YBQX6.js";import{useContext as le,useEffect as ae,useMemo as Y,useRef as E,useState as L}from"react";import{createPortal as re}from"react-dom";import{useState as U}from"react";function W(n,a,m){if(n!==void 0){let c=a.get(n);if(c)return c.value}return m()}l(W,"readRetained");var X=[];function T(){let n=new Map;return X.push(n),n}l(T,"retainMap");function fe(){for(let n of X)n.clear()}l(fe,"releaseRetained");function C(n,a,m){let[c,y]=U(n),[N,b]=U(()=>W(n,a,m));return c!==n&&(y(n),b(W(n,a,m))),[N,l(f=>{n!==void 0&&a.set(n,{value:f}),b(f)},"update")]}l(C,"useRetained");import{jsx as t,jsxs as r}from"react/jsx-runtime";var ce=T(),ie=T(),ue=T(),de=T(),x=100,p="rounded-md px-2 py-1 text-xs text-muted hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent disabled:opacity-40";function pe({columns:n,rows:a,sourceRows:m,sourceTable:c,totalRows:y,onClose:N,retentionKey:b}){let P=le(Z),[f,R]=C(b,ce,()=>""),[s,H]=C(b,ie,()=>null),[i,M]=C(b,ue,()=>new Set),[K,w]=C(b,de,()=>0),[g,S]=L(!1),[$,B]=L(),V=E(null),z=E(null),[ee,te]=L(0),D=E(null),F=Y(()=>m??a.map(e=>e.map(o=>typeof o=="string"?o:String(o??""))),[m,a]),u=Y(()=>{let e=f.toLocaleLowerCase(),o=F.map((d,v)=>({cells:d,index:v})).filter(d=>!e||d.cells.some(v=>v.toLocaleLowerCase().includes(e)));return s&&o.sort((d,v)=>(d.cells[s.column]??"").localeCompare(v.cells[s.column]??"",void 0,{numeric:!0})*(s.descending?-1:1)||d.index-v.index),o},[F,f,s]),h=Math.min(K,Math.max(0,Math.ceil(u.length/x)-1)),ne=u.slice(h*x,(h+1)*x),oe=u.filter(e=>i.has(e.index)).length;ae(()=>{if(g)return V.current?.showModal(),()=>D.current?.focus({preventScroll:!0})},[g]);let A=l(()=>u.filter(e=>!i.size||i.has(e.index)),"exportMatches"),se=l(()=>c?j(c,A().map(e=>e.index)):null,"exportTable"),I=l(()=>[n,...A().map(e=>e.cells)],"exported"),q=r("div",{className:"flex min-h-0 flex-col rounded-lg border border-border-soft bg-bg text-xs",children:[r("div",{className:"flex flex-wrap items-center gap-1 border-border-soft border-b p-2","data-document-controls":!0,children:[t("input",{type:"search","aria-label":"Filter table rows",placeholder:"Filter rows\u2026",value:f,onChange:e=>{R(e.target.value),w(0)},className:"min-w-0 flex-1 rounded-md border border-border-soft bg-bg px-2 py-1 text-base sm:text-xs"}),t("button",{type:"button",className:p,onClick:()=>{H(null),R(""),w(0),M(new Set)},children:"Original order"}),t("button",{type:"button",className:p,onClick:l(()=>{B(void 0),O(k(I()," ")).catch(()=>B("Could not copy rows. Try again."))},"copy"),children:i.size?`Copy ${oe} selected in view`:"Copy for spreadsheet"}),c?t(J,{getTable:se}):null,i.size?t("button",{type:"button",className:p,onClick:()=>M(new Set),children:"Clear selection"}):null,t("button",{type:"button",className:p,onClick:()=>Q(new Blob([k(I(),",")],{type:"text/csv;charset=utf-8"}),_(P,n)),children:"CSV"}),t("button",{ref:D,type:"button",className:p,onClick:()=>{g||te(z.current?.getBoundingClientRect().height??0),S(e=>!e)},children:g?"Exit fullscreen":"Fullscreen"}),N&&!g?t("button",{type:"button",className:p,onClick:N,children:"Authored view"}):null]}),r("p",{className:"!m-0 px-2 py-1 text-muted tabular-nums","data-document-controls":!0,children:[u.length," supplied rows",y!==void 0&&y>a.length?` of ${y}; remaining rows not supplied`:"; dataset completeness unknown",". ",s?"Sorted view":"Original order",f?" \xB7 filtered":"",". Exports use the current view",i.size?" and selection":"","."]}),t("div",{className:"max-h-[60dvh] min-h-0 overflow-auto overscroll-contain",children:r("table",{className:"!m-0 w-full",children:[t("thead",{className:"sticky top-0 z-10 bg-surface",children:r("tr",{children:[t("th",{scope:"col",children:t("span",{className:"sr-only",children:"Select row"})}),n.map((e,o)=>t("th",{scope:"col","aria-sort":s?.column===o?s.descending?"descending":"ascending":"none",children:r("button",{type:"button",className:"w-full text-left",onClick:()=>{H({column:o,descending:s?.column===o&&!s.descending}),w(0)},children:[e,s?.column===o?s.descending?" \u2193":" \u2191":""]})},`${o}:${e}`))]})}),t("tbody",{children:ne.map(({index:e})=>r("tr",{children:[t("td",{children:t("input",{type:"checkbox","aria-label":`Select supplied row ${e+1}`,checked:i.has(e),onChange:()=>{let o=new Set(i);o.has(e)?o.delete(e):o.add(e),M(o)}})}),a[e].map((o,d)=>t("td",{children:o},`${e}:${d}`))]},e))})]})}),u.length>x?r("div",{className:"flex items-center justify-end gap-2 p-2","data-document-controls":!0,children:[t("button",{type:"button",className:p,disabled:!h,onClick:()=>w(h-1),children:"Previous"}),r("span",{className:"tabular-nums",children:["Page ",h+1," of ",Math.ceil(u.length/x)]}),t("button",{type:"button",className:p,disabled:(h+1)*x>=u.length,onClick:()=>w(h+1),children:"Next"})]}):null,$?t("p",{role:"status",className:"px-2 text-del",children:$}):null]});return t("div",{ref:z,className:"farero-ui",style:g?{height:ee}:void 0,children:g?re(r("dialog",{ref:V,onCancel:()=>S(!1),"aria-label":"Table exploration",className:"farero-ui fixed inset-0 m-auto max-h-[90dvh] w-[96vw] max-w-6xl overflow-hidden overscroll-contain rounded-xl border border-border bg-bg p-0 text-text backdrop:bg-black/60",children:[t(G,{title:"Table",closeLabel:"Close fullscreen table",onClose:()=>S(!1)}),q]}),document.body):q})}l(pe,"DataTable");export{T as a,fe as b,C as c,pe as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as s}from"./chunk-5SBKMKFB.js";import{a as r}from"./chunk-3I4YBQX6.js";import{useId as y,useLayoutEffect as x,useRef as P,useState as c}from"react";import{jsx as d,jsxs as C}from"react/jsx-runtime";var h=r(({children:n,className:o})=>{let p=P(null),a=y(),[e,m]=c(!1),[b,f]=c(!1);return x(()=>{let t=p.current;if(!t||e)return;let i=r(()=>f(t.scrollHeight>t.clientHeight),"measure"),l=new ResizeObserver(i);return l.observe(t),i(),()=>l.disconnect()},[n,e]),C("div",{children:[d("p",{ref:p,id:a,className:s(o,!e&&"line-clamp-3"),children:n}),b||e?d("button",{type:"button","aria-expanded":e,"aria-controls":a,onClick:()=>m(t=>!t),className:"mt-0.5 rounded-sm text-accent text-xs underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-accent",children:e?"Show less":"Show more"}):null]})},"ExpandableText");import{jsx as u}from"react/jsx-runtime";var g=r(({id:n,checked:o,onChange:p,label:a,disabled:e=!1})=>u("button",{id:n,type:"button",role:"switch","aria-checked":o,"aria-label":a,disabled:e,onClick:p,className:s("relative h-6 w-11 shrink-0 rounded-full transition-colors disabled:opacity-50",o?"bg-accent":"border border-border bg-surface"),children:u("span",{"aria-hidden":!0,className:s("absolute top-1/2 left-0.5 size-5 -translate-y-1/2 rounded-full shadow-sm transition-transform",o?"translate-x-5 bg-on-solid":"translate-x-0 border border-border bg-white")})}),"Switch");export{h as a,g as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u,e as x}from"./chunk-LHMFMBHY.js";import{b as h}from"./chunk-ITKN2ASJ.js";import{f as y}from"./chunk-HGN4GN2E.js";import{a as s}from"./chunk-3I4YBQX6.js";import{TableProperties as v}from"lucide-react";import{Children as p,cloneElement as f,isValidElement as l,lazy as k,Suspense as w,useRef as E,useState as P}from"react";import{Fragment as D,jsx as o,jsxs as b}from"react/jsx-runtime";var A=k(()=>import("./DataTable-
|
|
1
|
+
import{c as u,e as x}from"./chunk-LHMFMBHY.js";import{b as h}from"./chunk-ITKN2ASJ.js";import{f as y}from"./chunk-HGN4GN2E.js";import{a as s}from"./chunk-3I4YBQX6.js";import{TableProperties as v}from"lucide-react";import{Children as p,cloneElement as f,isValidElement as l,lazy as k,Suspense as w,useRef as E,useState as P}from"react";import{Fragment as D,jsx as o,jsxs as b}from"react/jsx-runtime";var A=k(()=>import("./DataTable-ITEU54LT.js"));function g(c){let a=[];return p.forEach(c,e=>{!l(e)||e.type!=="tbody"||p.forEach(e.props.children,t=>{!l(t)||t.type!=="tr"||a.push(p.toArray(t.props.children).flatMap(r=>l(r)&&r.type==="td"?[r.props.children]:[]))})}),a}s(g,"bodyCells");function N(c,a){return p.map(c,e=>{if(!l(e))return e;if(e.type==="thead")return f(e,{children:N(e.props.children,a)});if(e.type!=="tr")return e;let t=p.toArray(e.props.children),r=t.findLastIndex(i=>l(i)&&i.type==="th"),n=t[r];return l(n)?(t[r]=f(n,{children:b("div",{className:"flex items-center gap-2",children:[o("span",{className:"min-w-0 flex-1",children:n.props.children}),a]})}),f(e,{children:t})):e})}s(N,"withTableAction");var q=s(({node:c,children:a,...e})=>{let t=E(null),[r,n]=P(),i=s(()=>{let d=t.current;if(!d)return;let T=Array.from(d.querySelectorAll("thead th"),m=>m.textContent??""),R=Array.from(d.querySelectorAll("tbody tr"),m=>Array.from(m.children,C=>C.textContent??""));n({columns:T,rows:g(a),sourceRows:R,sourceTable:u(d)})},"explore");return b("div",{"data-block-id":e["data-block-id"],className:"farero-ui my-3",children:[r?o(w,{fallback:o("p",{className:"text-muted text-xs",children:"Opening table\u2026"}),children:o(A,{...r,onClose:()=>n(void 0)})}):null,o("div",{hidden:!!r,className:"overflow-x-auto overscroll-x-contain",children:o("table",{...e,ref:t,children:N(a,b(D,{children:[o(x,{compact:!0,getTable:()=>t.current?u(t.current):null}),o(h,{label:"Explore table",className:"shrink-0",children:o(y,{onClick:i,"aria-label":"Explore table","data-document-controls":!0,className:"size-6 rounded-md hover:bg-surface-2 focus-visible:outline-2 focus-visible:outline-accent",children:o(v,{size:14,"aria-hidden":!0})})})]}))})})]})},"MarkdownTable");export{q as a};
|
|
File without changes
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{a as B}from"./chunk-JMYCJ5PW.js";import{a as k,b as v}from"./chunk-ONVWTQLU.js";import{a as _,j as D}from"./chunk-RWGTJDY3.js";import{e as N}from"./chunk-RR7BB4EQ.js";import{b as W,c as z}from"./chunk-PCK4EJ7D.js";import{e as w,i as O}from"./chunk-YGPVIEBZ.js";import{a as H,c as $,g as y,h as b}from"./chunk-2FSGXRY6.js";import{d as I}from"./chunk-HGN4GN2E.js";import{a as S}from"./chunk-5SBKMKFB.js";import{a as s}from"./chunk-3I4YBQX6.js";var x="farero-attachment.invalid";function C(e){return`https://${x}/?path=${encodeURIComponent(e)}`}s(C,"attachmentHref");function E(e,t=!1){let n=H(e);for(let a=n.length-1;a>=0;a--){let l=n[a],u=n[a+1],c=u&&!e.slice(l.end,u.start).trim()?`
|
|
2
|
+
${e.slice(u.start)}`:e.slice(l.end),p=l.handoff.sources.at(-1).title.replace(/[\\`*_[\]<>]/g,"\\$&");e=`${e.slice(0,l.start)}[${p}](${$(l.handoff)})${c}`}let r=y(e);if(!r.length)return e;let i="",o=0;for(let a of r){if(i+=e.slice(o,a.start),!t||!/^Transcript of .+\.md$/.test(a.name)){let l=a.name.replace(/[\\`*_[\]<>]/g,"\\$&");i+=`[${l}](${C(a.path)})`}o=a.end}return i+e.slice(o)}s(E,"markdownSource");function We(e){return/\.(?:md|markdown|mdown|mkd|mkdn)$/i.test(e)}s(We,"isMarkdownFile");import{useId as le,useMemo as X}from"react";import ce from"react-markdown";import ue from"remark-breaks";import de from"remark-gfm";import pe from"remark-math";function T({foldHeadings:e=!0}={}){return t=>{let n=s(r=>{for(let i of r){if(i.type!=="element")continue;let o=i.position?.start.offset;if(o!==void 0&&/^(h[1-6]|p|table|pre)$/.test(i.tagName)&&(i.properties["data-block-id"]=`b${o}`),i.tagName==="pre"){let a=i.children.find(l=>l.type==="element"&&l.tagName==="code");a?.type==="element"&&(i.properties["data-fence-complete"]=a.properties["data-fence-complete"])}n(i.children)}},"anchor");n(t.children),e&&(t.children=U(t.children))}}s(T,"documentStructure");function U(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.type!=="element"||!/^h[1-6]$/.test(r.tagName)){t.push(r);continue}let i=Number(r.tagName[1]),o=n+1;for(;o<e.length;){let l=e[o];if(l.type==="element"&&/^h[1-6]$/.test(l.tagName)&&Number(l.tagName[1])<=i)break;o++}let a={type:"element",tagName:"summary",properties:{},children:[r]};t.push({type:"element",tagName:"details",properties:{open:!0,"data-document-section":!0},children:[a,...U(e.slice(n+1,o)).filter(l=>l.type!=="doctype")]}),n=o-1}return t}s(U,"sections");function q(){let e="",t,n=!1;return s(function(){let i=this.parser;i&&(this.parser=(o,a)=>{let l,u=o.startsWith(e);u||(n=!1);let c=t&&u&&!n?t.children.slice(0,-2):[],p=t?.children[c.length],f=c.length?p?.position?.start:void 0;f?.offset!==void 0?(l=i(o.slice(f.offset),a),K(l,f),l.children=[...c,...l.children]):l=i(o,a),!n&&l.children.slice(c.length).some(G)&&(n=!0,c.length&&(l=i(o,a)));for(let m of l.children.slice(n?0:c.length))V(m,o);return e=o,t=l,l})},"plugin")}s(q,"incrementalMarkdown");function G(e){return["definition","footnoteDefinition","linkReference","imageReference","footnoteReference"].includes(e.type)||e.type==="text"&&/\[[^\]\n]+\]/.test(e.value)?!0:(e.children??[]).some(G)}s(G,"hasReferences");function K(e,t){if(e.position)for(let n of[e.position.start,e.position.end])n.line===1&&(n.column+=t.column-1),n.line+=t.line-1,n.offset!==void 0&&(n.offset+=t.offset??0);for(let n of e.children??[])K(n,t)}s(K,"shiftPositions");function V(e,t){if(e.type==="code"){let n=t.slice(e.position?.start.offset,e.position?.end.offset),r=n.match(/^ {0,3}(`{3,}|~{3,})/),i=n.slice(n.lastIndexOf(`
|
|
3
|
+
`)+1).replace(/^\s*(?:>\s*)+/,"").trimStart(),o=!r||n.includes(`
|
|
4
|
+
`)&&new RegExp(`^ {0,3}${r[1][0]}{${r[1].length},}[ \\t]*$`).test(i);e.data={...e.data,hProperties:{...e.data?.hProperties,"data-fence-complete":o?"true":"false"}}}for(let n of e.children??[])V(n,t)}s(V,"markFence");import{jsx as Z}from"react/jsx-runtime";var fe=[T],me=[[T,{foldHeadings:!1}]],nt=s(({children:e,components:t,foldHeadings:n=!0,hideTranscriptAttachments:r=!1,onContextMenu:i})=>{let o=X(()=>[de,[pe,{singleDollarTextMath:!1}],q(),ue],[]),a=le(),l=X(()=>({clobberPrefix:`note-${a}-`}),[a]);return Z("div",{className:"md farero-ui",onContextMenu:i,children:Z(ce,{remarkPlugins:o,rehypePlugins:n?fe:me,remarkRehypeOptions:l,components:t,children:E(e,r)})})},"MarkdownBody");function j(e,t=null){return e.startsWith("~/")||/^[A-Za-z]:[\\/]/.test(e)||t&&(e===t||e.startsWith(`${t}/`))?!0:e.startsWith("/Users/")||e.startsWith("/home/")||e.startsWith("/private/")}s(j,"isAbsoluteFilePath");function Y(e){if(!e.startsWith("file://"))return null;let t=e.slice(7),n=t.startsWith("/")?t:t.startsWith("localhost/")?t.slice(9):null;return n?/^\/[A-Za-z]:[\\/]/.test(n)?n.slice(1):n:null}s(Y,"fileUrlToLocalPath");function J(e){let t="",n=s(r=>{for(let i of r)i.type==="text"?t+=i.value:i.type==="element"&&n(i.children)},"walk");return n(e.children),t.replace(/\n$/,"")}s(J,"fenceSource");function h(e){if(!e)return null;try{let t=new URL(e);return t.hostname===x?t.searchParams.get("path"):null}catch{return null}}s(h,"attachmentPath");function P(e){if(!e)return!1;try{let t=new URL(e,location.origin);return t.origin===location.origin&&t.pathname.startsWith("/w/")&&t.searchParams.has("handoff")&&!!t.searchParams.get("session")}catch{return!1}}s(P,"isChatHandoffHref");function L(e){let t=e&&(Y(e)??e);if(!t?.startsWith("/")||!j(t))return null;let n=t.match(/:([1-9]\d*)(?::\d+)?$/),r=n?t.slice(0,-n[0].length):t;return b(r)?null:r.slice(r.lastIndexOf("/")+1).includes(".")?t:null}s(L,"sourceReference");function dt(e){if(!e)return null;let t=e.split(/\r?\n/).filter(Boolean);if(t.length<2)return null;let n=t.map(L);return n.every(r=>r!==null)?n:null}s(dt,"sourceReferences");function pt({reference:e,external:t,externalPreview:n,button:r,metaKey:i,ctrlKey:o,shiftKey:a,altKey:l,defaultPrevented:u}){return u?"browser":r===0&&!i&&!o&&!a&&!l&&!e&&t&&n?"external-preview":e&&(r===0||r===1)?"preview":"browser"}s(pt,"chatLinkAction");var ge=/^[a-z0-9-]+(?:\.[a-z0-9-]+)+$/,he=/^[\d.]+$/,ye=/(?:^|\.)(?:corp|example|home|home\.arpa|internal|intranet|invalid|lan|local|localhost|onion|private|test|ts\.net)$/;function ft(e){let t;try{t=new URL(e).hostname}catch{return null}return!ge.test(t)||he.test(t)||ye.test(t)||t===location.hostname?null:`https://icons.duckduckgo.com/ip3/${t}.ico`}s(ft,"linkFaviconUrl");function mt(e){return typeof e=="string"?e:Array.isArray(e)&&e.filter(n=>typeof n=="string").join("")||null}s(mt,"linkText");import{Children as be,isValidElement as ne}from"react";import{jsx as M,jsxs as te}from"react/jsx-runtime";function Q(e){return typeof e=="string"&&!e.trim()}s(Q,"isBlank");function xe(e){return ne(e)&&e.type==="br"}s(xe,"isLineBreak");function ee(e){if(!ne(e))return null;let{href:t}=e.props;return typeof t!="string"?null:h(t)!==null||P(t)?t:null}s(ee,"referenceHref");var oe=s(({children:e,node:t,...n})=>{let r=be.toArray(e),i=[],o=[],a=[],l=0;for(let c=0;c<=r.length;c++){if(c<r.length&&!xe(r[c])){a.push(r[c]);continue}if(!a.every(p=>Q(p)||ee(p)))break;for(let p of a){let f=ee(p);if(!f)continue;let m=h(f);m&&b(m)?i.push(p):o.push(p)}a=[],l=c+1}if(!i.length&&!o.length)return M("p",{...n,children:e});let u=r.slice(l);return te("p",{...n,children:[te("span",{className:S("flex flex-col gap-1",u.some(c=>!Q(c))&&"mb-[0.5em]"),children:[i.length?M("span",{className:"flex flex-wrap items-start gap-2",children:i}):null,o.length?M("span",{className:"flex flex-wrap items-center gap-1.5",children:o}):null]}),u]})},"ChatParagraph");import{useCallback as Ce,useEffect as Pe,useRef as re,useState as Re}from"react";import{createPortal as we}from"react-dom";import{Fragment as ke,jsx as R,jsxs as ie}from"react/jsx-runtime";var se=s(({href:e,children:t,...n})=>{let[r,i]=Re(),o=re(null),a=re(null),l=Ce(()=>{i(void 0),o.current?.focus({preventScroll:!0})},[]);return Pe(()=>{if(!r)return;a.current?.querySelector("button")?.focus({preventScroll:!0});let u=s(f=>{let m=f.target;!o.current?.contains(m)&&!a.current?.contains(m)&&i(void 0)},"dismiss"),c=s(f=>{f.key==="Escape"&&(f.preventDefault(),f.stopPropagation(),i(void 0),o.current?.focus({preventScroll:!0}))},"onEscape"),p=s(f=>{a.current?.contains(f.target)||i(void 0)},"scroll");return document.addEventListener("pointerdown",u),document.addEventListener("keydown",c,!0),document.addEventListener("scroll",p,!0),window.addEventListener("resize",l),()=>{document.removeEventListener("pointerdown",u),document.removeEventListener("keydown",c,!0),document.removeEventListener("scroll",p,!0),window.removeEventListener("resize",l)}},[r,l]),ie(ke,{children:[R("a",{...n,ref:o,href:e,"aria-expanded":!!r,"aria-haspopup":"dialog",onClick:u=>{let c=u.currentTarget.closest(".md"),p=e?.slice(1),f=p?Array.from(c?.querySelectorAll("[id]")??[]).find(g=>g.id===p):void 0;if(!f)return;u.preventDefault();let m=f.cloneNode(!0);for(let g of m.querySelectorAll("[data-footnote-backref]"))g.remove();let F=u.currentTarget.getBoundingClientRect();i(g=>g?void 0:{text:m.textContent?.trim()??"",left:Math.max(8,Math.min(F.left,window.innerWidth-272)),top:Math.max(8,Math.min(F.bottom+6,window.innerHeight-208))})},children:t}),r?we(ie("div",{ref:a,role:"dialog","aria-label":"Footnote","data-document-controls":!0,className:"farero-ui fixed z-50 max-h-48 w-64 max-w-[calc(100vw-1rem)] overflow-auto overscroll-contain rounded-lg border border-border bg-surface p-3 text-text text-xs shadow-xl",style:{left:r.left,top:r.top},children:[R("p",{className:"whitespace-pre-wrap",children:r.text}),R("a",{href:e,className:"mt-2 inline-block text-accent underline",onClick:()=>{let u=e?document.getElementById(e.slice(1)):null;for(let c=u?.closest("details");c;c=c.parentElement?.closest("details")??null)c.open=!0;i(void 0)},children:"Go to note"}),R("button",{type:"button",className:"ml-3 rounded px-1 text-muted",onClick:l,children:"Close"})]}),document.body):null]})},"FootnoteReference");import{MessageSquare as ve,Paperclip as Ne}from"lucide-react";import{lazy as Ee,Suspense as Te}from"react";import{jsx as d,jsxs as A}from"react/jsx-runtime";var Le=Ee(()=>import("./MathEquation-7ZVYQFEK.js")),Me=/^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;function ae(e){return e.startsWith("http://")||e.startsWith("https://")}s(ae,"isHttpUrl");function Ae(e){return typeof e=="string"?e:Array.isArray(e)&&e.every(t=>typeof t=="string")?e.join(""):null}s(Ae,"fenceText");var Fe=s(({href:e,children:t,onOpenFile:n,filePaths:r,node:i,...o})=>{if(i?.properties.dataFootnoteRef)return d(se,{href:e,...o,children:t});if(!e)return d("span",{title:o.title,children:t});let a=h(e);if(a){let[u]=y(C(a)),c=u?u.name:a.slice(a.lastIndexOf("/")+1),p=[N(t??c),o.title,a].filter(Boolean).join(`
|
|
5
|
+
`);return d("span",{title:a,className:k(),children:d(v,{icon:Ne,title:p,children:t??c})})}if(P(e))return d("span",{className:k(),children:d(v,{icon:ve,title:N(t),children:t})});let l=L(e)??(r?.includes(e)?e:null);return l?n?d("button",{type:"button",title:`Open ${l}`,onClick:()=>n(l),className:"inline select-text text-left text-accent underline decoration-accent/40 underline-offset-2 hover:decoration-accent focus-visible:outline-2 focus-visible:outline-accent",children:t}):d("code",{title:l,className:"text-accent underline decoration-dotted underline-offset-2",children:t}):ae(e)?d("a",{href:e,target:"_blank",rel:"noopener noreferrer",...o,children:t}):d("a",{href:e,...o,children:t})},"ReadonlyLink"),Se=s(({className:e,children:t,node:n,...r})=>{let i=w(e),o=Ae(t);return e?.includes("language-math")&&o!==null?d(Te,{fallback:d("code",{children:o}),children:d(Le,{source:o.replace(/\n$/,""),display:e.includes("math-display")})}):!e&&o!==null&&Me.test(o)?A("code",{...r,children:[d("span",{"aria-hidden":"true",style:{backgroundColor:o},className:"mr-1 inline-block size-[0.85em] shrink-0 translate-y-[0.1em] rounded-[3px] border border-black/25 dark:border-white/25"}),t]}):d("code",{className:e,...r,children:i&&o!==null?d(O,{text:o,language:i}):t})},"ReadonlyCode"),He=s(({src:e,alt:t,node:n,images:r,...i})=>{if(typeof e=="string"&&ae(e))return d("img",{src:e,alt:t??"",...i});let o=typeof e=="string"?r?.[e]:void 0;return o?d("img",{...i,src:o.src,width:o.width,height:o.height,alt:t??"",decoding:"async",className:"border border-border-soft"}):A("span",{className:"my-2 block rounded-lg border border-border-soft px-3 py-2 text-muted text-xs",children:[t||"Image"," unavailable in preview"]})},"ReadonlyImage"),$e=s(({node:e,children:t,...n})=>{let r=e?J(e):"",i=e?.children.find(c=>c.type==="element"&&c.tagName==="code"),o=i?.type==="element"?i.properties.className:void 0,a=_(o),l=e?.properties["data-fence-complete"]!=="false";if(r&&a&&l)return d("div",{children:d(D,{source:r,language:a},a)});let u=Array.isArray(o)?o.join(" "):typeof o=="string"?o:void 0;if(r&&!u?.includes("language-math")){let c=u?.match(/language-([\w+-]+)/)?.[1]?.toLowerCase()??"";return d(z,{source:r,language:w(u)??(c||null),kind:W(c,r),complete:l})}return A("div",{className:"group relative my-3 overflow-hidden rounded-xl border border-border-soft bg-bg",children:[d("pre",{...n,className:"!m-0 !rounded-none !border-0 overflow-x-auto overscroll-x-contain",children:t}),r?d("div",{className:"absolute top-1 right-1 rounded-md border border-border-soft bg-bg/90 opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100 sm:group-focus-within:opacity-100",children:d(I,{text:r,label:"code",size:12,className:"size-6 rounded-md"})}):null]})},"ReadonlyPre");function Oe(e={}){let{onOpenFile:t,filePaths:n,images:r}=e;return{a:s(a=>d(Fe,{...a,onOpenFile:t,filePaths:n}),"link"),code:Se,img:s(a=>d(He,{...a,images:r}),"image"),p:oe,pre:$e,table:B}}s(Oe,"createReadonlyComponents");var Kt=Oe();export{x as a,C as b,E as c,We as d,nt as e,j as f,Y as g,J as h,h as i,P as j,L as k,dt as l,pt as m,ft as n,mt as o,oe as p,se as q,Oe as r,Kt as s};
|
package/dist/controls.d.ts
CHANGED
|
@@ -179,6 +179,17 @@ declare function Segments<const T extends string>({ value, options, onChange, on
|
|
|
179
179
|
touchReach?: boolean;
|
|
180
180
|
}): react.JSX.Element;
|
|
181
181
|
|
|
182
|
+
/** Shared toggle switch. Pass the visible caption as its accessible label. */
|
|
183
|
+
interface SwitchProps {
|
|
184
|
+
id?: string;
|
|
185
|
+
checked: boolean;
|
|
186
|
+
onChange: () => void;
|
|
187
|
+
/** Accessible name — always pass the visible caption. */
|
|
188
|
+
label: string;
|
|
189
|
+
disabled?: boolean;
|
|
190
|
+
}
|
|
191
|
+
declare const Switch: FC<SwitchProps>;
|
|
192
|
+
|
|
182
193
|
interface TooltipProps {
|
|
183
194
|
label: string;
|
|
184
195
|
/** A second, muted line, such as why the control is unavailable. */
|
|
@@ -229,5 +240,5 @@ interface WordWrapToggleProps {
|
|
|
229
240
|
}
|
|
230
241
|
declare const WordWrapToggle: FC<WordWrapToggleProps>;
|
|
231
242
|
|
|
232
|
-
export { Button, CopyButton, CopyErrorToast, DismissButton, DismissibleError, ExpandableText, Eyebrow, HeaderIconButton, KeyboardHint, LongPressButton, MenuContext, PopoverMenu, ReferenceChipLabel, SearchHit, Segments, Spinner, Tooltip, ViewerAction, ViewerHeader, WordWrapToggle, ZoomControls, copyFormatted, copyText, formattedFragment, referenceChipClass };
|
|
233
|
-
export type { ButtonProps, ButtonSize, ButtonVariant, CopyButtonProps, CopyErrorToastProps, DismissButtonProps, DismissibleErrorProps, ExpandableTextProps, EyebrowProps, HeaderIconButtonProps, KeyboardHintProps, LongPressButtonProps, MenuItem, MenuProps, ReferenceChipClassOptions, ReferenceChipLabelProps, SearchHitProps, SpinnerProps, TooltipProps, ViewerActionProps, ViewerHeaderProps, WordWrapToggleProps, ZoomControlsProps };
|
|
243
|
+
export { Button, CopyButton, CopyErrorToast, DismissButton, DismissibleError, ExpandableText, Eyebrow, HeaderIconButton, KeyboardHint, LongPressButton, MenuContext, PopoverMenu, ReferenceChipLabel, SearchHit, Segments, Spinner, Switch, Tooltip, ViewerAction, ViewerHeader, WordWrapToggle, ZoomControls, copyFormatted, copyText, formattedFragment, referenceChipClass };
|
|
244
|
+
export type { ButtonProps, ButtonSize, ButtonVariant, CopyButtonProps, CopyErrorToastProps, DismissButtonProps, DismissibleErrorProps, ExpandableTextProps, EyebrowProps, HeaderIconButtonProps, KeyboardHintProps, LongPressButtonProps, MenuItem, MenuProps, ReferenceChipClassOptions, ReferenceChipLabelProps, SearchHitProps, SpinnerProps, SwitchProps, TooltipProps, ViewerActionProps, ViewerHeaderProps, WordWrapToggleProps, ZoomControlsProps };
|
package/dist/controls.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as k,b as v}from"./chunks/chunk-HE55M4S6.js";import{a as s,b as t}from"./chunks/chunk-ONVWTQLU.js";import{a as d,b as w}from"./chunks/chunk-ITKN2ASJ.js";import{a,b,c}from"./chunks/chunk-S3DX6DGB.js";import{a as q,b as r}from"./chunks/chunk-T3JXEXIJ.js";import{a as l,b as m,c as n,d as o,f as x,g as y}from"./chunks/chunk-RR7BB4EQ.js";import{a as z}from"./chunks/chunk-WQZ3EUKA.js";import{a as p,b as u}from"./chunks/chunk-FW2QVWXL.js";import{a as e,b as f,c as g,d as h,e as i,f as j}from"./chunks/chunk-HGN4GN2E.js";import"./chunks/chunk-5SBKMKFB.js";import"./chunks/chunk-3I4YBQX6.js";export{d as Button,h as CopyButton,n as CopyErrorToast,m as DismissButton,l as DismissibleError,k as ExpandableText,a as Eyebrow,j as HeaderIconButton,c as KeyboardHint,p as LongPressButton,r as MenuContext,q as PopoverMenu,t as ReferenceChipLabel,b as SearchHit,u as Segments,o as Spinner,v as Switch,w as Tooltip,x as ViewerAction,y as ViewerHeader,z as WordWrapToggle,i as ZoomControls,f as copyFormatted,e as copyText,g as formattedFragment,s as referenceChipClass};
|
package/dist/diagram.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as r,c as m,d as e,e as i,f as g,g as t,h as o,i as D,j as p}from"./chunks/chunk-
|
|
1
|
+
import{a,b as r,c as m,d as e,e as i,f as g,g as t,h as o,i as D,j as p}from"./chunks/chunk-RWGTJDY3.js";import"./chunks/chunk-YPRVAH5G.js";import"./chunks/chunk-T3JXEXIJ.js";import"./chunks/chunk-RR7BB4EQ.js";import"./chunks/chunk-FW2QVWXL.js";import"./chunks/chunk-HGN4GN2E.js";import"./chunks/chunk-5SBKMKFB.js";import"./chunks/chunk-3I4YBQX6.js";export{p as Diagram,g as containDiagram,m as defaultDiagramLayout,a as diagramLanguage,r as diagramLayouts,i as fitDiagram,D as readDiagramTheme,e as renderDiagram,o as useDiagramViewport,t as zoomDiagramAt};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { G as GeneratedUiInput } from '../chunks/catalog-FuTW6oW-.js';
|
|
2
|
+
export { b as GeneratedUiSnapshot, a as GeneratedUiSpec, g as generatedUiCatalog, c as generatedUiComponents, d as generatedUiInitialValues, e as generatedUiInputSchema, f as generatedUiState, p as parseGeneratedUi } from '../chunks/catalog-FuTW6oW-.js';
|
|
3
|
+
import { ComputedFunction } from '@json-render/core';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
|
|
6
|
+
interface GeneratedUiTextPart {
|
|
7
|
+
kind: 'text';
|
|
8
|
+
text: string;
|
|
9
|
+
/** Start of this slice. Kept for callers that already read `offset`. */
|
|
10
|
+
offset: number;
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
}
|
|
14
|
+
interface GeneratedUiPanelPart {
|
|
15
|
+
kind: 'panel';
|
|
16
|
+
index: number;
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
complete: boolean;
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
/** Exact original fence, including its header and closing line. */
|
|
23
|
+
source: string;
|
|
24
|
+
panel?: GeneratedUiInput;
|
|
25
|
+
error?: string;
|
|
26
|
+
}
|
|
27
|
+
type UiMessagePart = GeneratedUiTextPart | GeneratedUiPanelPart;
|
|
28
|
+
/**
|
|
29
|
+
* True when every complete panel fence is still present, in order, with the same id, title, and source.
|
|
30
|
+
* Prose around those fences may change. An open fence is not a published panel.
|
|
31
|
+
*/
|
|
32
|
+
declare function preservesPublishedPanels(original: string, edited: string): boolean;
|
|
33
|
+
/** Only explicit assistant-owned fences are interfaces. Other JSON and code remain ordinary prose. */
|
|
34
|
+
declare function generatedUiParts(text: string): readonly UiMessagePart[];
|
|
35
|
+
|
|
36
|
+
declare const uiIdentifier: z.ZodString;
|
|
37
|
+
declare const uiConditionAtom: z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
38
|
+
$state: z.ZodString;
|
|
39
|
+
eq: z.ZodOptional<z.ZodUnknown>;
|
|
40
|
+
neq: z.ZodOptional<z.ZodUnknown>;
|
|
41
|
+
gt: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
gte: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
lt: z.ZodOptional<z.ZodNumber>;
|
|
44
|
+
lte: z.ZodOptional<z.ZodNumber>;
|
|
45
|
+
not: z.ZodOptional<z.ZodBoolean>;
|
|
46
|
+
}, z.core.$strict>]>;
|
|
47
|
+
declare const uiCondition: z.ZodType;
|
|
48
|
+
declare function boundUiJson(value: unknown, depth?: number): void;
|
|
49
|
+
declare const uiExpression: z.ZodType;
|
|
50
|
+
declare const uiFunctions: Record<string, ComputedFunction>;
|
|
51
|
+
/** Bound expression trees before the library traverses them; no arbitrary directives or prototype paths. */
|
|
52
|
+
declare function validateUiValue(value: unknown, depth?: number): void;
|
|
53
|
+
declare function resolveUiProps(props: Record<string, unknown>, state: Record<string, unknown>): Record<string, unknown>;
|
|
54
|
+
|
|
55
|
+
export { GeneratedUiInput, boundUiJson, generatedUiParts, preservesPublishedPanels, resolveUiProps, uiCondition, uiConditionAtom, uiExpression, uiFunctions, uiIdentifier, validateUiValue };
|
|
56
|
+
export type { GeneratedUiPanelPart, GeneratedUiTextPart, UiMessagePart };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as t,c as i,d as r,e as a,f as n,g as o,h as d,i as s,j as p,k as U,l as u,m as l,n as g,o as m,p as P}from"../chunks/chunk-5WPOTZ7L.js";import"../chunks/chunk-3I4YBQX6.js";export{r as boundUiJson,p as generatedUiCatalog,s as generatedUiComponents,l as generatedUiInitialValues,U as generatedUiInputSchema,P as generatedUiParts,g as generatedUiState,u as parseGeneratedUi,m as preservesPublishedPanels,d as resolveUiProps,i as uiCondition,t as uiConditionAtom,a as uiExpression,n as uiFunctions,e as uiIdentifier,o as validateUiValue};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
import { StateStore } from '@json-render/react';
|
|
3
|
+
import { GeneratedUiInput, GeneratedUiSpec } from './generated-ui/parse.js';
|
|
4
|
+
import { StateStore as StateStore$1 } from '@json-render/core';
|
|
5
|
+
import 'zod';
|
|
6
|
+
|
|
7
|
+
interface GeneratedUiSubmissionRequest {
|
|
8
|
+
prompt: string;
|
|
9
|
+
values: unknown;
|
|
10
|
+
}
|
|
11
|
+
interface GeneratedPanelProps {
|
|
12
|
+
panel: GeneratedUiInput;
|
|
13
|
+
/**
|
|
14
|
+
* Keeps this reader's controls until `releaseGeneratedUiMemory` or the page closes.
|
|
15
|
+
* Ignored when `store` is set.
|
|
16
|
+
*/
|
|
17
|
+
memoryKey?: string;
|
|
18
|
+
/** The host's store. Farero uses this for its own saved fields. */
|
|
19
|
+
store?: StateStore;
|
|
20
|
+
streaming?: boolean;
|
|
21
|
+
ready?: boolean;
|
|
22
|
+
notice?: string;
|
|
23
|
+
status?: string;
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
/** Absent, a button does not submit and nothing is sent. */
|
|
26
|
+
onSubmit?: (submission: GeneratedUiSubmissionRequest) => unknown;
|
|
27
|
+
}
|
|
28
|
+
/** A panel owns its controls. Expanding never remounts them. */
|
|
29
|
+
declare const GeneratedPanel: FC<GeneratedPanelProps>;
|
|
30
|
+
|
|
31
|
+
interface GeneratedUiContentProps {
|
|
32
|
+
text: string;
|
|
33
|
+
/** Prefix for each panel's in-memory controls. Include the account, conversation, message, and reader. */
|
|
34
|
+
memoryKey: string;
|
|
35
|
+
renderText?: (text: string) => ReactNode;
|
|
36
|
+
streaming?: boolean;
|
|
37
|
+
onSubmit?: (submission: GeneratedUiSubmissionRequest) => unknown;
|
|
38
|
+
}
|
|
39
|
+
/** Splits a message into prose and panels with the same boundaries the parser reports. */
|
|
40
|
+
declare const GeneratedUiContent: FC<GeneratedUiContentProps>;
|
|
41
|
+
|
|
42
|
+
/** One store per caller key for the life of the page. A new key starts from the published defaults. */
|
|
43
|
+
declare function memoryPanelStore(key: string, spec: GeneratedUiSpec): StateStore$1;
|
|
44
|
+
/** Drops in-memory panel controls. Closing the page does this on its own. */
|
|
45
|
+
declare function releaseGeneratedUiMemory(): void;
|
|
46
|
+
|
|
47
|
+
export { GeneratedPanel, GeneratedUiContent, memoryPanelStore, releaseGeneratedUiMemory };
|
|
48
|
+
export type { GeneratedPanelProps, GeneratedUiContentProps, GeneratedUiSubmissionRequest };
|