@farcaster/snap 2.0.0 → 2.0.1
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/dist/colors.d.ts +4 -4
- package/dist/colors.js +20 -20
- package/dist/constants.d.ts +17 -1
- package/dist/constants.js +19 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.js +2 -4
- package/dist/react/accent-context.d.ts +3 -1
- package/dist/react/accent-context.js +7 -4
- package/dist/react/catalog-renderer.js +4 -0
- package/dist/react/components/action-button.d.ts +2 -1
- package/dist/react/components/action-button.js +32 -13
- package/dist/react/components/badge.js +8 -8
- package/dist/react/components/bar-chart.d.ts +5 -0
- package/dist/react/components/bar-chart.js +26 -0
- package/dist/react/components/cell-grid.d.ts +5 -0
- package/dist/react/components/cell-grid.js +87 -0
- package/dist/react/components/icon.js +4 -10
- package/dist/react/components/input.js +12 -6
- package/dist/react/components/item-group.js +3 -1
- package/dist/react/components/item.d.ts +3 -3
- package/dist/react/components/item.js +4 -3
- package/dist/react/components/progress.js +3 -3
- package/dist/react/components/separator.js +3 -1
- package/dist/react/components/slider.js +15 -10
- package/dist/react/components/switch.js +10 -12
- package/dist/react/components/text.js +6 -14
- package/dist/react/components/toggle-group.js +20 -6
- package/dist/react/hooks/use-snap-colors.d.ts +38 -0
- package/dist/react/hooks/use-snap-colors.js +81 -0
- package/dist/react/index.d.ts +13 -1
- package/dist/react/index.js +9 -188
- package/dist/react/snap-view-core.d.ts +11 -0
- package/dist/react/snap-view-core.js +224 -0
- package/dist/react/v1/snap-view.d.ts +16 -0
- package/dist/react/v1/snap-view.js +90 -0
- package/dist/react/v2/snap-view.d.ts +23 -0
- package/dist/react/v2/snap-view.js +91 -0
- package/dist/react-native/catalog-renderer.d.ts +5 -0
- package/dist/react-native/catalog-renderer.js +40 -0
- package/dist/react-native/components/snap-action-button.d.ts +2 -0
- package/dist/react-native/components/snap-action-button.js +69 -0
- package/dist/react-native/components/snap-badge.d.ts +2 -0
- package/dist/react-native/components/snap-badge.js +41 -0
- package/dist/react-native/components/snap-bar-chart.d.ts +2 -0
- package/dist/react-native/components/snap-bar-chart.js +39 -0
- package/dist/react-native/components/snap-cell-grid.d.ts +2 -0
- package/dist/react-native/components/snap-cell-grid.js +94 -0
- package/dist/react-native/components/snap-icon.d.ts +5 -0
- package/dist/react-native/components/snap-icon.js +56 -0
- package/dist/react-native/components/snap-image.d.ts +2 -0
- package/dist/react-native/components/snap-image.js +23 -0
- package/dist/react-native/components/snap-input.d.ts +2 -0
- package/dist/react-native/components/snap-input.js +37 -0
- package/dist/react-native/components/snap-item-group.d.ts +5 -0
- package/dist/react-native/components/snap-item-group.js +23 -0
- package/dist/react-native/components/snap-item.d.ts +5 -0
- package/dist/react-native/components/snap-item.js +42 -0
- package/dist/react-native/components/snap-progress.d.ts +2 -0
- package/dist/react-native/components/snap-progress.js +26 -0
- package/dist/react-native/components/snap-separator.d.ts +2 -0
- package/dist/react-native/components/snap-separator.js +23 -0
- package/dist/react-native/components/snap-slider.d.ts +2 -0
- package/dist/react-native/components/snap-slider.js +43 -0
- package/dist/react-native/components/snap-stack.d.ts +5 -0
- package/dist/react-native/components/snap-stack.js +49 -0
- package/dist/react-native/components/snap-switch.d.ts +2 -0
- package/dist/react-native/components/snap-switch.js +31 -0
- package/dist/react-native/components/snap-text.d.ts +2 -0
- package/dist/react-native/components/snap-text.js +35 -0
- package/dist/react-native/components/snap-toggle-group.d.ts +2 -0
- package/dist/react-native/components/snap-toggle-group.js +99 -0
- package/dist/react-native/confetti-overlay.d.ts +1 -0
- package/dist/react-native/confetti-overlay.js +106 -0
- package/dist/react-native/index.d.ts +28 -0
- package/dist/react-native/index.js +15 -0
- package/dist/react-native/snap-view-core.d.ts +11 -0
- package/dist/react-native/snap-view-core.js +153 -0
- package/dist/react-native/theme.d.ts +27 -0
- package/dist/react-native/theme.js +43 -0
- package/dist/react-native/types.d.ts +42 -0
- package/dist/react-native/types.js +1 -0
- package/dist/react-native/use-snap-palette.d.ts +13 -0
- package/dist/react-native/use-snap-palette.js +48 -0
- package/dist/react-native/v1/snap-view.d.ts +24 -0
- package/dist/react-native/v1/snap-view.js +96 -0
- package/dist/react-native/v2/snap-view.d.ts +33 -0
- package/dist/react-native/v2/snap-view.js +114 -0
- package/dist/schemas.d.ts +100 -13
- package/dist/schemas.js +28 -10
- package/dist/server/parseRequest.d.ts +10 -0
- package/dist/server/parseRequest.js +48 -7
- package/dist/server/verify.d.ts +1 -0
- package/dist/server/verify.js +1 -0
- package/dist/ui/badge.d.ts +7 -2
- package/dist/ui/badge.js +2 -0
- package/dist/ui/bar-chart.d.ts +30 -0
- package/dist/ui/bar-chart.js +30 -0
- package/dist/ui/button.d.ts +4 -6
- package/dist/ui/button.js +1 -1
- package/dist/ui/catalog.d.ts +90 -16
- package/dist/ui/catalog.js +17 -3
- package/dist/ui/cell-grid.d.ts +34 -0
- package/dist/ui/cell-grid.js +39 -0
- package/dist/ui/icon.d.ts +2 -2
- package/dist/ui/image.d.ts +1 -2
- package/dist/ui/image.js +1 -1
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +2 -0
- package/dist/ui/item.d.ts +1 -3
- package/dist/ui/item.js +1 -1
- package/dist/ui/schema.d.ts +6 -2
- package/dist/ui/schema.js +2 -2
- package/dist/ui/slider.d.ts +1 -0
- package/dist/ui/slider.js +2 -0
- package/dist/ui/text.d.ts +2 -4
- package/dist/ui/text.js +2 -2
- package/dist/validator.d.ts +3 -2
- package/dist/validator.js +198 -2
- package/llms.txt +199 -0
- package/package.json +9 -3
- package/src/colors.ts +20 -20
- package/src/constants.ts +23 -1
- package/src/index.ts +16 -13
- package/src/react/accent-context.tsx +13 -6
- package/src/react/catalog-renderer.tsx +4 -0
- package/src/react/components/action-button.tsx +47 -20
- package/src/react/components/badge.tsx +14 -18
- package/src/react/components/bar-chart.tsx +69 -0
- package/src/react/components/cell-grid.tsx +128 -0
- package/src/react/components/icon.tsx +5 -18
- package/src/react/components/input.tsx +20 -9
- package/src/react/components/item-group.tsx +4 -1
- package/src/react/components/item.tsx +13 -10
- package/src/react/components/progress.tsx +12 -7
- package/src/react/components/separator.tsx +8 -1
- package/src/react/components/slider.tsx +28 -15
- package/src/react/components/switch.tsx +12 -16
- package/src/react/components/text.tsx +14 -23
- package/src/react/components/toggle-group.tsx +26 -9
- package/src/react/hooks/use-snap-colors.ts +128 -0
- package/src/react/index.tsx +49 -265
- package/src/react/snap-view-core.tsx +340 -0
- package/src/react/v1/snap-view.tsx +176 -0
- package/src/react/v2/snap-view.tsx +199 -0
- package/src/react-native/catalog-renderer.tsx +41 -0
- package/src/react-native/components/snap-action-button.tsx +96 -0
- package/src/react-native/components/snap-badge.tsx +60 -0
- package/src/react-native/components/snap-bar-chart.tsx +73 -0
- package/src/react-native/components/snap-cell-grid.tsx +150 -0
- package/src/react-native/components/snap-icon.tsx +102 -0
- package/src/react-native/components/snap-image.tsx +37 -0
- package/src/react-native/components/snap-input.tsx +58 -0
- package/src/react-native/components/snap-item-group.tsx +43 -0
- package/src/react-native/components/snap-item.tsx +66 -0
- package/src/react-native/components/snap-progress.tsx +40 -0
- package/src/react-native/components/snap-separator.tsx +32 -0
- package/src/react-native/components/snap-slider.tsx +85 -0
- package/src/react-native/components/snap-stack.tsx +66 -0
- package/src/react-native/components/snap-switch.tsx +46 -0
- package/src/react-native/components/snap-text.tsx +51 -0
- package/src/react-native/components/snap-toggle-group.tsx +127 -0
- package/src/react-native/confetti-overlay.tsx +134 -0
- package/src/react-native/index.tsx +83 -0
- package/src/react-native/snap-view-core.tsx +209 -0
- package/src/react-native/theme.tsx +85 -0
- package/src/react-native/types.ts +38 -0
- package/src/react-native/use-snap-palette.ts +64 -0
- package/src/react-native/v1/snap-view.tsx +229 -0
- package/src/react-native/v2/snap-view.tsx +283 -0
- package/src/schemas.ts +68 -17
- package/src/server/parseRequest.ts +68 -9
- package/src/server/verify.ts +2 -0
- package/src/ui/README.md +8 -8
- package/src/ui/badge.ts +2 -0
- package/src/ui/bar-chart.ts +38 -0
- package/src/ui/button.ts +1 -1
- package/src/ui/catalog.ts +19 -3
- package/src/ui/cell-grid.ts +49 -0
- package/src/ui/image.ts +1 -1
- package/src/ui/index.ts +6 -0
- package/src/ui/item.ts +1 -1
- package/src/ui/schema.ts +2 -2
- package/src/ui/slider.ts +2 -0
- package/src/ui/text.ts +2 -2
- package/src/validator.ts +246 -2
- package/dist/dataStore.d.ts +0 -12
- package/dist/dataStore.js +0 -35
- package/dist/middleware.d.ts +0 -3
- package/dist/middleware.js +0 -3
- package/dist/react/hooks/use-snap-accent.d.ts +0 -13
- package/dist/react/hooks/use-snap-accent.js +0 -32
- package/src/dataStore.ts +0 -62
- package/src/middleware.ts +0 -7
- package/src/react/hooks/use-snap-accent.ts +0 -45
package/dist/ui/catalog.d.ts
CHANGED
|
@@ -10,11 +10,15 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
10
10
|
root: import("@json-render/core").SchemaType<"string", unknown>;
|
|
11
11
|
elements: import("@json-render/core").SchemaType<"record", import("@json-render/core").SchemaType<"object", {
|
|
12
12
|
type: import("@json-render/core").SchemaType<"ref", string>;
|
|
13
|
-
props:
|
|
13
|
+
props: {
|
|
14
|
+
optional: true;
|
|
15
|
+
kind: "propsOf";
|
|
16
|
+
inner?: string;
|
|
17
|
+
};
|
|
14
18
|
children: {
|
|
15
19
|
optional: true;
|
|
16
20
|
kind: "array";
|
|
17
|
-
inner?: import("@json-render/core").SchemaType<"string", unknown
|
|
21
|
+
inner?: import("@json-render/core").SchemaType<"string", unknown>;
|
|
18
22
|
};
|
|
19
23
|
}>>;
|
|
20
24
|
}>;
|
|
@@ -37,6 +41,10 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
37
41
|
badge: {
|
|
38
42
|
props: z.ZodObject<{
|
|
39
43
|
label: z.ZodString;
|
|
44
|
+
variant: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
default: "default";
|
|
46
|
+
outline: "outline";
|
|
47
|
+
}>>;
|
|
40
48
|
color: z.ZodOptional<z.ZodEnum<{
|
|
41
49
|
gray: "gray";
|
|
42
50
|
blue: "blue";
|
|
@@ -49,18 +57,18 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
49
57
|
accent: "accent";
|
|
50
58
|
}>>;
|
|
51
59
|
icon: z.ZodOptional<z.ZodEnum<{
|
|
52
|
-
check: "check";
|
|
53
|
-
repeat: "repeat";
|
|
54
60
|
"arrow-right": "arrow-right";
|
|
55
61
|
"arrow-left": "arrow-left";
|
|
56
62
|
"external-link": "external-link";
|
|
57
63
|
"chevron-right": "chevron-right";
|
|
64
|
+
check: "check";
|
|
58
65
|
x: "x";
|
|
59
66
|
"alert-triangle": "alert-triangle";
|
|
60
67
|
info: "info";
|
|
61
68
|
clock: "clock";
|
|
62
69
|
heart: "heart";
|
|
63
70
|
"message-circle": "message-circle";
|
|
71
|
+
repeat: "repeat";
|
|
64
72
|
share: "share";
|
|
65
73
|
user: "user";
|
|
66
74
|
users: "users";
|
|
@@ -90,24 +98,22 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
90
98
|
props: z.ZodObject<{
|
|
91
99
|
label: z.ZodString;
|
|
92
100
|
variant: z.ZodOptional<z.ZodEnum<{
|
|
93
|
-
default: "default";
|
|
94
101
|
secondary: "secondary";
|
|
95
|
-
|
|
96
|
-
ghost: "ghost";
|
|
102
|
+
primary: "primary";
|
|
97
103
|
}>>;
|
|
98
104
|
icon: z.ZodOptional<z.ZodEnum<{
|
|
99
|
-
check: "check";
|
|
100
|
-
repeat: "repeat";
|
|
101
105
|
"arrow-right": "arrow-right";
|
|
102
106
|
"arrow-left": "arrow-left";
|
|
103
107
|
"external-link": "external-link";
|
|
104
108
|
"chevron-right": "chevron-right";
|
|
109
|
+
check: "check";
|
|
105
110
|
x: "x";
|
|
106
111
|
"alert-triangle": "alert-triangle";
|
|
107
112
|
info: "info";
|
|
108
113
|
clock: "clock";
|
|
109
114
|
heart: "heart";
|
|
110
115
|
"message-circle": "message-circle";
|
|
116
|
+
repeat: "repeat";
|
|
111
117
|
share: "share";
|
|
112
118
|
user: "user";
|
|
113
119
|
users: "users";
|
|
@@ -179,8 +185,6 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
179
185
|
description: z.ZodOptional<z.ZodString>;
|
|
180
186
|
variant: z.ZodOptional<z.ZodEnum<{
|
|
181
187
|
default: "default";
|
|
182
|
-
outline: "outline";
|
|
183
|
-
muted: "muted";
|
|
184
188
|
}>>;
|
|
185
189
|
}, z.core.$strip>;
|
|
186
190
|
description: string;
|
|
@@ -201,18 +205,18 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
201
205
|
icon: {
|
|
202
206
|
props: z.ZodObject<{
|
|
203
207
|
name: z.ZodEnum<{
|
|
204
|
-
check: "check";
|
|
205
|
-
repeat: "repeat";
|
|
206
208
|
"arrow-right": "arrow-right";
|
|
207
209
|
"arrow-left": "arrow-left";
|
|
208
210
|
"external-link": "external-link";
|
|
209
211
|
"chevron-right": "chevron-right";
|
|
212
|
+
check: "check";
|
|
210
213
|
x: "x";
|
|
211
214
|
"alert-triangle": "alert-triangle";
|
|
212
215
|
info: "info";
|
|
213
216
|
clock: "clock";
|
|
214
217
|
heart: "heart";
|
|
215
218
|
"message-circle": "message-circle";
|
|
219
|
+
repeat: "repeat";
|
|
216
220
|
share: "share";
|
|
217
221
|
user: "user";
|
|
218
222
|
users: "users";
|
|
@@ -260,7 +264,6 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
260
264
|
"1:1": "1:1";
|
|
261
265
|
"16:9": "16:9";
|
|
262
266
|
"4:3": "4:3";
|
|
263
|
-
"3:4": "3:4";
|
|
264
267
|
"9:16": "9:16";
|
|
265
268
|
}>;
|
|
266
269
|
alt: z.ZodOptional<z.ZodString>;
|
|
@@ -292,6 +295,7 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
292
295
|
step: z.ZodOptional<z.ZodNumber>;
|
|
293
296
|
defaultValue: z.ZodOptional<z.ZodNumber>;
|
|
294
297
|
label: z.ZodOptional<z.ZodString>;
|
|
298
|
+
showValue: z.ZodOptional<z.ZodBoolean>;
|
|
295
299
|
}, z.core.$strip>;
|
|
296
300
|
description: string;
|
|
297
301
|
};
|
|
@@ -323,11 +327,9 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
323
327
|
size: z.ZodOptional<z.ZodEnum<{
|
|
324
328
|
sm: "sm";
|
|
325
329
|
md: "md";
|
|
326
|
-
lg: "lg";
|
|
327
330
|
}>>;
|
|
328
331
|
weight: z.ZodOptional<z.ZodEnum<{
|
|
329
332
|
bold: "bold";
|
|
330
|
-
medium: "medium";
|
|
331
333
|
normal: "normal";
|
|
332
334
|
}>>;
|
|
333
335
|
align: z.ZodOptional<z.ZodEnum<{
|
|
@@ -338,6 +340,72 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
338
340
|
}, z.core.$strip>;
|
|
339
341
|
description: string;
|
|
340
342
|
};
|
|
343
|
+
bar_chart: {
|
|
344
|
+
props: z.ZodObject<{
|
|
345
|
+
bars: z.ZodArray<z.ZodObject<{
|
|
346
|
+
label: z.ZodString;
|
|
347
|
+
value: z.ZodNumber;
|
|
348
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
349
|
+
gray: "gray";
|
|
350
|
+
blue: "blue";
|
|
351
|
+
red: "red";
|
|
352
|
+
amber: "amber";
|
|
353
|
+
green: "green";
|
|
354
|
+
teal: "teal";
|
|
355
|
+
purple: "purple";
|
|
356
|
+
pink: "pink";
|
|
357
|
+
}>>;
|
|
358
|
+
}, z.core.$strip>>;
|
|
359
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
360
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
361
|
+
gray: "gray";
|
|
362
|
+
blue: "blue";
|
|
363
|
+
red: "red";
|
|
364
|
+
amber: "amber";
|
|
365
|
+
green: "green";
|
|
366
|
+
teal: "teal";
|
|
367
|
+
purple: "purple";
|
|
368
|
+
pink: "pink";
|
|
369
|
+
accent: "accent";
|
|
370
|
+
}>>;
|
|
371
|
+
}, z.core.$strip>;
|
|
372
|
+
description: string;
|
|
373
|
+
};
|
|
374
|
+
cell_grid: {
|
|
375
|
+
props: z.ZodObject<{
|
|
376
|
+
name: z.ZodOptional<z.ZodString>;
|
|
377
|
+
cols: z.ZodNumber;
|
|
378
|
+
rows: z.ZodNumber;
|
|
379
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
380
|
+
row: z.ZodNumber;
|
|
381
|
+
col: z.ZodNumber;
|
|
382
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
383
|
+
gray: "gray";
|
|
384
|
+
blue: "blue";
|
|
385
|
+
red: "red";
|
|
386
|
+
amber: "amber";
|
|
387
|
+
green: "green";
|
|
388
|
+
teal: "teal";
|
|
389
|
+
purple: "purple";
|
|
390
|
+
pink: "pink";
|
|
391
|
+
}>>;
|
|
392
|
+
content: z.ZodOptional<z.ZodString>;
|
|
393
|
+
}, z.core.$strip>>;
|
|
394
|
+
gap: z.ZodOptional<z.ZodEnum<{
|
|
395
|
+
sm: "sm";
|
|
396
|
+
md: "md";
|
|
397
|
+
none: "none";
|
|
398
|
+
lg: "lg";
|
|
399
|
+
}>>;
|
|
400
|
+
rowHeight: z.ZodOptional<z.ZodNumber>;
|
|
401
|
+
select: z.ZodOptional<z.ZodEnum<{
|
|
402
|
+
multiple: "multiple";
|
|
403
|
+
off: "off";
|
|
404
|
+
single: "single";
|
|
405
|
+
}>>;
|
|
406
|
+
}, z.core.$strip>;
|
|
407
|
+
description: string;
|
|
408
|
+
};
|
|
341
409
|
};
|
|
342
410
|
actions: {
|
|
343
411
|
submit: {
|
|
@@ -352,6 +420,12 @@ export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<
|
|
|
352
420
|
target: z.ZodString;
|
|
353
421
|
}, z.core.$strip>;
|
|
354
422
|
};
|
|
423
|
+
open_snap: {
|
|
424
|
+
description: string;
|
|
425
|
+
params: z.ZodObject<{
|
|
426
|
+
target: z.ZodString;
|
|
427
|
+
}, z.core.$strip>;
|
|
428
|
+
};
|
|
355
429
|
open_mini_app: {
|
|
356
430
|
description: string;
|
|
357
431
|
params: z.ZodObject<{
|
package/dist/ui/catalog.js
CHANGED
|
@@ -15,6 +15,8 @@ import { separatorProps } from "./separator.js";
|
|
|
15
15
|
import { sliderProps } from "./slider.js";
|
|
16
16
|
import { stackProps } from "./stack.js";
|
|
17
17
|
import { textProps } from "./text.js";
|
|
18
|
+
import { barChartProps } from "./bar-chart.js";
|
|
19
|
+
import { cellGridProps } from "./cell-grid.js";
|
|
18
20
|
const snapClientParams = z.object({
|
|
19
21
|
client_action: z.record(z.string(), z.unknown()),
|
|
20
22
|
});
|
|
@@ -28,7 +30,7 @@ export const snapJsonRenderCatalog = defineCatalog(snapJsonRenderSchema, {
|
|
|
28
30
|
components: {
|
|
29
31
|
badge: {
|
|
30
32
|
props: badgeProps,
|
|
31
|
-
description: "Inline label — variant: default
|
|
33
|
+
description: "Inline label — variant: default (filled) or outline (bordered). Optional color and icon.",
|
|
32
34
|
},
|
|
33
35
|
button: {
|
|
34
36
|
props: buttonProps,
|
|
@@ -80,7 +82,15 @@ export const snapJsonRenderCatalog = defineCatalog(snapJsonRenderSchema, {
|
|
|
80
82
|
},
|
|
81
83
|
text: {
|
|
82
84
|
props: textProps,
|
|
83
|
-
description: "Text block — size:
|
|
85
|
+
description: "Text block — size: md (body, default), sm (caption). Optional weight and align.",
|
|
86
|
+
},
|
|
87
|
+
bar_chart: {
|
|
88
|
+
props: barChartProps,
|
|
89
|
+
description: "Horizontal bar chart — 1–6 bars with label, value, and optional per-bar color. Optional max and default color.",
|
|
90
|
+
},
|
|
91
|
+
cell_grid: {
|
|
92
|
+
props: cellGridProps,
|
|
93
|
+
description: "Cell grid — sparse colored cells on a rows×cols grid. Optional gap and selection mode (taps write to inputs[name]).",
|
|
84
94
|
},
|
|
85
95
|
},
|
|
86
96
|
actions: {
|
|
@@ -89,7 +99,11 @@ export const snapJsonRenderCatalog = defineCatalog(snapJsonRenderSchema, {
|
|
|
89
99
|
params: z.object({ target: z.string() }),
|
|
90
100
|
},
|
|
91
101
|
open_url: {
|
|
92
|
-
description: "Open
|
|
102
|
+
description: "Open external URL in browser.",
|
|
103
|
+
params: z.object({ target: z.string() }),
|
|
104
|
+
},
|
|
105
|
+
open_snap: {
|
|
106
|
+
description: "Open a snap URL inline. The client renders the target as a snap rather than opening a browser.",
|
|
93
107
|
params: z.object({ target: z.string() }),
|
|
94
108
|
},
|
|
95
109
|
open_mini_app: {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const cellGridProps: z.ZodObject<{
|
|
3
|
+
name: z.ZodOptional<z.ZodString>;
|
|
4
|
+
cols: z.ZodNumber;
|
|
5
|
+
rows: z.ZodNumber;
|
|
6
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
7
|
+
row: z.ZodNumber;
|
|
8
|
+
col: z.ZodNumber;
|
|
9
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
gray: "gray";
|
|
11
|
+
blue: "blue";
|
|
12
|
+
red: "red";
|
|
13
|
+
amber: "amber";
|
|
14
|
+
green: "green";
|
|
15
|
+
teal: "teal";
|
|
16
|
+
purple: "purple";
|
|
17
|
+
pink: "pink";
|
|
18
|
+
}>>;
|
|
19
|
+
content: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, z.core.$strip>>;
|
|
21
|
+
gap: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
sm: "sm";
|
|
23
|
+
md: "md";
|
|
24
|
+
none: "none";
|
|
25
|
+
lg: "lg";
|
|
26
|
+
}>>;
|
|
27
|
+
rowHeight: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
select: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
multiple: "multiple";
|
|
30
|
+
off: "off";
|
|
31
|
+
single: "single";
|
|
32
|
+
}>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type CellGridProps = z.infer<typeof cellGridProps>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PALETTE_COLOR_VALUES } from "../colors.js";
|
|
3
|
+
import { GRID_MIN_COLS, GRID_MAX_COLS, GRID_MIN_ROWS, GRID_MAX_ROWS, GRID_GAP_VALUES, } from "../constants.js";
|
|
4
|
+
const cellGridCellSchema = z.object({
|
|
5
|
+
row: z.number().int().nonnegative(),
|
|
6
|
+
col: z.number().int().nonnegative(),
|
|
7
|
+
color: z.enum(PALETTE_COLOR_VALUES).optional(),
|
|
8
|
+
content: z.string().optional(),
|
|
9
|
+
});
|
|
10
|
+
export const cellGridProps = z
|
|
11
|
+
.object({
|
|
12
|
+
name: z.string().min(1).optional(),
|
|
13
|
+
cols: z.number().int().min(GRID_MIN_COLS).max(GRID_MAX_COLS),
|
|
14
|
+
rows: z.number().int().min(GRID_MIN_ROWS).max(GRID_MAX_ROWS),
|
|
15
|
+
cells: z.array(cellGridCellSchema),
|
|
16
|
+
gap: z.enum(GRID_GAP_VALUES).optional(),
|
|
17
|
+
rowHeight: z.number().int().min(8).max(64).optional(),
|
|
18
|
+
select: z.enum(["off", "single", "multiple"]).optional(),
|
|
19
|
+
})
|
|
20
|
+
.superRefine((val, ctx) => {
|
|
21
|
+
const { cols, rows, cells } = val;
|
|
22
|
+
for (let i = 0; i < cells.length; i++) {
|
|
23
|
+
const c = cells[i];
|
|
24
|
+
if (c.row < 0 || c.row >= rows) {
|
|
25
|
+
ctx.addIssue({
|
|
26
|
+
code: "custom",
|
|
27
|
+
message: `cell_grid cell row ${c.row} out of bounds (0–${rows - 1})`,
|
|
28
|
+
path: ["cells", i, "row"],
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
if (c.col < 0 || c.col >= cols) {
|
|
32
|
+
ctx.addIssue({
|
|
33
|
+
code: "custom",
|
|
34
|
+
message: `cell_grid cell col ${c.col} out of bounds (0–${cols - 1})`,
|
|
35
|
+
path: ["cells", i, "col"],
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
package/dist/ui/icon.d.ts
CHANGED
|
@@ -3,18 +3,18 @@ export declare const ICON_NAMES: readonly ["arrow-right", "arrow-left", "externa
|
|
|
3
3
|
export declare const ICON_SIZES: readonly ["sm", "md"];
|
|
4
4
|
export declare const iconProps: z.ZodObject<{
|
|
5
5
|
name: z.ZodEnum<{
|
|
6
|
-
check: "check";
|
|
7
|
-
repeat: "repeat";
|
|
8
6
|
"arrow-right": "arrow-right";
|
|
9
7
|
"arrow-left": "arrow-left";
|
|
10
8
|
"external-link": "external-link";
|
|
11
9
|
"chevron-right": "chevron-right";
|
|
10
|
+
check: "check";
|
|
12
11
|
x: "x";
|
|
13
12
|
"alert-triangle": "alert-triangle";
|
|
14
13
|
info: "info";
|
|
15
14
|
clock: "clock";
|
|
16
15
|
heart: "heart";
|
|
17
16
|
"message-circle": "message-circle";
|
|
17
|
+
repeat: "repeat";
|
|
18
18
|
share: "share";
|
|
19
19
|
user: "user";
|
|
20
20
|
users: "users";
|
package/dist/ui/image.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const IMAGE_ASPECTS: readonly ["1:1", "16:9", "4:3", "
|
|
2
|
+
export declare const IMAGE_ASPECTS: readonly ["1:1", "16:9", "4:3", "9:16"];
|
|
3
3
|
export declare const imageProps: z.ZodObject<{
|
|
4
4
|
url: z.ZodString;
|
|
5
5
|
aspect: z.ZodEnum<{
|
|
6
6
|
"1:1": "1:1";
|
|
7
7
|
"16:9": "16:9";
|
|
8
8
|
"4:3": "4:3";
|
|
9
|
-
"3:4": "3:4";
|
|
10
9
|
"9:16": "9:16";
|
|
11
10
|
}>;
|
|
12
11
|
alt: z.ZodOptional<z.ZodString>;
|
package/dist/ui/image.js
CHANGED
package/dist/ui/index.d.ts
CHANGED
|
@@ -28,3 +28,7 @@ export { stackProps } from "./stack.js";
|
|
|
28
28
|
export type { StackProps } from "./stack.js";
|
|
29
29
|
export { textProps } from "./text.js";
|
|
30
30
|
export type { TextProps } from "./text.js";
|
|
31
|
+
export { barChartProps } from "./bar-chart.js";
|
|
32
|
+
export type { BarChartProps } from "./bar-chart.js";
|
|
33
|
+
export { cellGridProps } from "./cell-grid.js";
|
|
34
|
+
export type { CellGridProps } from "./cell-grid.js";
|
package/dist/ui/index.js
CHANGED
|
@@ -14,3 +14,5 @@ export { separatorProps } from "./separator.js";
|
|
|
14
14
|
export { sliderProps } from "./slider.js";
|
|
15
15
|
export { stackProps } from "./stack.js";
|
|
16
16
|
export { textProps } from "./text.js";
|
|
17
|
+
export { barChartProps } from "./bar-chart.js";
|
|
18
|
+
export { cellGridProps } from "./cell-grid.js";
|
package/dist/ui/item.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const ITEM_VARIANTS: readonly ["default"
|
|
2
|
+
export declare const ITEM_VARIANTS: readonly ["default"];
|
|
3
3
|
export declare const ITEM_MAX_TITLE_CHARS = 100;
|
|
4
4
|
export declare const ITEM_MAX_DESCRIPTION_CHARS = 160;
|
|
5
5
|
export declare const itemProps: z.ZodObject<{
|
|
@@ -7,8 +7,6 @@ export declare const itemProps: z.ZodObject<{
|
|
|
7
7
|
description: z.ZodOptional<z.ZodString>;
|
|
8
8
|
variant: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
default: "default";
|
|
10
|
-
outline: "outline";
|
|
11
|
-
muted: "muted";
|
|
12
10
|
}>>;
|
|
13
11
|
}, z.core.$strip>;
|
|
14
12
|
export type ItemProps = z.infer<typeof itemProps>;
|
package/dist/ui/item.js
CHANGED
package/dist/ui/schema.d.ts
CHANGED
|
@@ -7,11 +7,15 @@ export declare const snapJsonRenderSchema: import("@json-render/core").Schema<{
|
|
|
7
7
|
root: import("@json-render/core").SchemaType<"string", unknown>;
|
|
8
8
|
elements: import("@json-render/core").SchemaType<"record", import("@json-render/core").SchemaType<"object", {
|
|
9
9
|
type: import("@json-render/core").SchemaType<"ref", string>;
|
|
10
|
-
props:
|
|
10
|
+
props: {
|
|
11
|
+
optional: true;
|
|
12
|
+
kind: "propsOf";
|
|
13
|
+
inner?: string;
|
|
14
|
+
};
|
|
11
15
|
children: {
|
|
12
16
|
optional: true;
|
|
13
17
|
kind: "array";
|
|
14
|
-
inner?: import("@json-render/core").SchemaType<"string", unknown
|
|
18
|
+
inner?: import("@json-render/core").SchemaType<"string", unknown>;
|
|
15
19
|
};
|
|
16
20
|
}>>;
|
|
17
21
|
}>;
|
package/dist/ui/schema.js
CHANGED
|
@@ -8,7 +8,7 @@ export const snapJsonRenderSchema = defineSchema((s) => ({
|
|
|
8
8
|
root: s.string(),
|
|
9
9
|
elements: s.record(s.object({
|
|
10
10
|
type: s.ref("catalog.components"),
|
|
11
|
-
props: s.propsOf("catalog.components"),
|
|
11
|
+
props: { ...s.propsOf("catalog.components"), optional: true },
|
|
12
12
|
children: { ...s.array(s.string()), optional: true },
|
|
13
13
|
})),
|
|
14
14
|
}),
|
|
@@ -25,7 +25,7 @@ export const snapJsonRenderSchema = defineSchema((s) => ({
|
|
|
25
25
|
}), {
|
|
26
26
|
defaultRules: [
|
|
27
27
|
"You are generating auxiliary UI for a Farcaster Snap. Prefer components matching snap element types (Item, Badge, ButtonGroup, Input, Switch, ToggleGroup, Slider, Progress, Image, Separator).",
|
|
28
|
-
"Snap
|
|
28
|
+
"Snap structural limits: max 64 elements, max 7 children on root, max 6 children per non-root container, max 4 levels of nesting. Keep generated trees small.",
|
|
29
29
|
"Bottom-of-card snap buttons are Button components; use actions post / link / mini_app / sdk per SPEC.md.",
|
|
30
30
|
],
|
|
31
31
|
});
|
package/dist/ui/slider.d.ts
CHANGED
|
@@ -9,5 +9,6 @@ export declare const sliderProps: z.ZodObject<{
|
|
|
9
9
|
step: z.ZodOptional<z.ZodNumber>;
|
|
10
10
|
defaultValue: z.ZodOptional<z.ZodNumber>;
|
|
11
11
|
label: z.ZodOptional<z.ZodString>;
|
|
12
|
+
showValue: z.ZodOptional<z.ZodBoolean>;
|
|
12
13
|
}, z.core.$strip>;
|
|
13
14
|
export type SliderProps = z.infer<typeof sliderProps>;
|
package/dist/ui/slider.js
CHANGED
|
@@ -10,6 +10,8 @@ export const sliderProps = z
|
|
|
10
10
|
step: z.number().optional(),
|
|
11
11
|
defaultValue: z.number().optional(),
|
|
12
12
|
label: z.string().max(SLIDER_MAX_LABEL_CHARS).optional(),
|
|
13
|
+
/** When true, display the current value next to the label. */
|
|
14
|
+
showValue: z.boolean().optional(),
|
|
13
15
|
})
|
|
14
16
|
.superRefine((val, ctx) => {
|
|
15
17
|
if (val.min > val.max) {
|
package/dist/ui/text.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const TEXT_SIZES: readonly ["
|
|
3
|
-
export declare const TEXT_WEIGHTS: readonly ["bold", "
|
|
2
|
+
export declare const TEXT_SIZES: readonly ["md", "sm"];
|
|
3
|
+
export declare const TEXT_WEIGHTS: readonly ["bold", "normal"];
|
|
4
4
|
export declare const TEXT_ALIGNS: readonly ["left", "center", "right"];
|
|
5
5
|
export declare const TEXT_MAX_CONTENT_CHARS = 320;
|
|
6
6
|
export declare const textProps: z.ZodObject<{
|
|
@@ -8,11 +8,9 @@ export declare const textProps: z.ZodObject<{
|
|
|
8
8
|
size: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
sm: "sm";
|
|
10
10
|
md: "md";
|
|
11
|
-
lg: "lg";
|
|
12
11
|
}>>;
|
|
13
12
|
weight: z.ZodOptional<z.ZodEnum<{
|
|
14
13
|
bold: "bold";
|
|
15
|
-
medium: "medium";
|
|
16
14
|
normal: "normal";
|
|
17
15
|
}>>;
|
|
18
16
|
align: z.ZodOptional<z.ZodEnum<{
|
package/dist/ui/text.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export const TEXT_SIZES = ["
|
|
3
|
-
export const TEXT_WEIGHTS = ["bold", "
|
|
2
|
+
export const TEXT_SIZES = ["md", "sm"];
|
|
3
|
+
export const TEXT_WEIGHTS = ["bold", "normal"];
|
|
4
4
|
export const TEXT_ALIGNS = ["left", "center", "right"];
|
|
5
5
|
export const TEXT_MAX_CONTENT_CHARS = 320;
|
|
6
6
|
export const textProps = z.object({
|
package/dist/validator.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ export type ValidationResult = {
|
|
|
4
4
|
issues: z.core.$ZodIssue[];
|
|
5
5
|
};
|
|
6
6
|
/**
|
|
7
|
-
* Validates a snap response against the schema.
|
|
7
|
+
* Validates a snap response against the schema, structural constraints, and URL rules.
|
|
8
8
|
* Element-level prop validation is handled by the json-render catalog.
|
|
9
|
-
* This validates the snap envelope (version, theme, effects, spec shape)
|
|
9
|
+
* This validates the snap envelope (version, theme, effects, spec shape)
|
|
10
|
+
* and enforces structural limits (element count, children, depth) and URL validation.
|
|
10
11
|
*/
|
|
11
12
|
export declare function validateSnapResponse(json: unknown): ValidationResult;
|