@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.
Files changed (194) hide show
  1. package/dist/colors.d.ts +4 -4
  2. package/dist/colors.js +20 -20
  3. package/dist/constants.d.ts +17 -1
  4. package/dist/constants.js +19 -1
  5. package/dist/index.d.ts +4 -6
  6. package/dist/index.js +2 -4
  7. package/dist/react/accent-context.d.ts +3 -1
  8. package/dist/react/accent-context.js +7 -4
  9. package/dist/react/catalog-renderer.js +4 -0
  10. package/dist/react/components/action-button.d.ts +2 -1
  11. package/dist/react/components/action-button.js +32 -13
  12. package/dist/react/components/badge.js +8 -8
  13. package/dist/react/components/bar-chart.d.ts +5 -0
  14. package/dist/react/components/bar-chart.js +26 -0
  15. package/dist/react/components/cell-grid.d.ts +5 -0
  16. package/dist/react/components/cell-grid.js +87 -0
  17. package/dist/react/components/icon.js +4 -10
  18. package/dist/react/components/input.js +12 -6
  19. package/dist/react/components/item-group.js +3 -1
  20. package/dist/react/components/item.d.ts +3 -3
  21. package/dist/react/components/item.js +4 -3
  22. package/dist/react/components/progress.js +3 -3
  23. package/dist/react/components/separator.js +3 -1
  24. package/dist/react/components/slider.js +15 -10
  25. package/dist/react/components/switch.js +10 -12
  26. package/dist/react/components/text.js +6 -14
  27. package/dist/react/components/toggle-group.js +20 -6
  28. package/dist/react/hooks/use-snap-colors.d.ts +38 -0
  29. package/dist/react/hooks/use-snap-colors.js +81 -0
  30. package/dist/react/index.d.ts +13 -1
  31. package/dist/react/index.js +9 -188
  32. package/dist/react/snap-view-core.d.ts +11 -0
  33. package/dist/react/snap-view-core.js +224 -0
  34. package/dist/react/v1/snap-view.d.ts +16 -0
  35. package/dist/react/v1/snap-view.js +90 -0
  36. package/dist/react/v2/snap-view.d.ts +23 -0
  37. package/dist/react/v2/snap-view.js +91 -0
  38. package/dist/react-native/catalog-renderer.d.ts +5 -0
  39. package/dist/react-native/catalog-renderer.js +40 -0
  40. package/dist/react-native/components/snap-action-button.d.ts +2 -0
  41. package/dist/react-native/components/snap-action-button.js +69 -0
  42. package/dist/react-native/components/snap-badge.d.ts +2 -0
  43. package/dist/react-native/components/snap-badge.js +41 -0
  44. package/dist/react-native/components/snap-bar-chart.d.ts +2 -0
  45. package/dist/react-native/components/snap-bar-chart.js +39 -0
  46. package/dist/react-native/components/snap-cell-grid.d.ts +2 -0
  47. package/dist/react-native/components/snap-cell-grid.js +94 -0
  48. package/dist/react-native/components/snap-icon.d.ts +5 -0
  49. package/dist/react-native/components/snap-icon.js +56 -0
  50. package/dist/react-native/components/snap-image.d.ts +2 -0
  51. package/dist/react-native/components/snap-image.js +23 -0
  52. package/dist/react-native/components/snap-input.d.ts +2 -0
  53. package/dist/react-native/components/snap-input.js +37 -0
  54. package/dist/react-native/components/snap-item-group.d.ts +5 -0
  55. package/dist/react-native/components/snap-item-group.js +23 -0
  56. package/dist/react-native/components/snap-item.d.ts +5 -0
  57. package/dist/react-native/components/snap-item.js +42 -0
  58. package/dist/react-native/components/snap-progress.d.ts +2 -0
  59. package/dist/react-native/components/snap-progress.js +26 -0
  60. package/dist/react-native/components/snap-separator.d.ts +2 -0
  61. package/dist/react-native/components/snap-separator.js +23 -0
  62. package/dist/react-native/components/snap-slider.d.ts +2 -0
  63. package/dist/react-native/components/snap-slider.js +43 -0
  64. package/dist/react-native/components/snap-stack.d.ts +5 -0
  65. package/dist/react-native/components/snap-stack.js +49 -0
  66. package/dist/react-native/components/snap-switch.d.ts +2 -0
  67. package/dist/react-native/components/snap-switch.js +31 -0
  68. package/dist/react-native/components/snap-text.d.ts +2 -0
  69. package/dist/react-native/components/snap-text.js +35 -0
  70. package/dist/react-native/components/snap-toggle-group.d.ts +2 -0
  71. package/dist/react-native/components/snap-toggle-group.js +99 -0
  72. package/dist/react-native/confetti-overlay.d.ts +1 -0
  73. package/dist/react-native/confetti-overlay.js +106 -0
  74. package/dist/react-native/index.d.ts +28 -0
  75. package/dist/react-native/index.js +15 -0
  76. package/dist/react-native/snap-view-core.d.ts +11 -0
  77. package/dist/react-native/snap-view-core.js +153 -0
  78. package/dist/react-native/theme.d.ts +27 -0
  79. package/dist/react-native/theme.js +43 -0
  80. package/dist/react-native/types.d.ts +42 -0
  81. package/dist/react-native/types.js +1 -0
  82. package/dist/react-native/use-snap-palette.d.ts +13 -0
  83. package/dist/react-native/use-snap-palette.js +48 -0
  84. package/dist/react-native/v1/snap-view.d.ts +24 -0
  85. package/dist/react-native/v1/snap-view.js +96 -0
  86. package/dist/react-native/v2/snap-view.d.ts +33 -0
  87. package/dist/react-native/v2/snap-view.js +114 -0
  88. package/dist/schemas.d.ts +100 -13
  89. package/dist/schemas.js +28 -10
  90. package/dist/server/parseRequest.d.ts +10 -0
  91. package/dist/server/parseRequest.js +48 -7
  92. package/dist/server/verify.d.ts +1 -0
  93. package/dist/server/verify.js +1 -0
  94. package/dist/ui/badge.d.ts +7 -2
  95. package/dist/ui/badge.js +2 -0
  96. package/dist/ui/bar-chart.d.ts +30 -0
  97. package/dist/ui/bar-chart.js +30 -0
  98. package/dist/ui/button.d.ts +4 -6
  99. package/dist/ui/button.js +1 -1
  100. package/dist/ui/catalog.d.ts +90 -16
  101. package/dist/ui/catalog.js +17 -3
  102. package/dist/ui/cell-grid.d.ts +34 -0
  103. package/dist/ui/cell-grid.js +39 -0
  104. package/dist/ui/icon.d.ts +2 -2
  105. package/dist/ui/image.d.ts +1 -2
  106. package/dist/ui/image.js +1 -1
  107. package/dist/ui/index.d.ts +4 -0
  108. package/dist/ui/index.js +2 -0
  109. package/dist/ui/item.d.ts +1 -3
  110. package/dist/ui/item.js +1 -1
  111. package/dist/ui/schema.d.ts +6 -2
  112. package/dist/ui/schema.js +2 -2
  113. package/dist/ui/slider.d.ts +1 -0
  114. package/dist/ui/slider.js +2 -0
  115. package/dist/ui/text.d.ts +2 -4
  116. package/dist/ui/text.js +2 -2
  117. package/dist/validator.d.ts +3 -2
  118. package/dist/validator.js +198 -2
  119. package/llms.txt +199 -0
  120. package/package.json +9 -3
  121. package/src/colors.ts +20 -20
  122. package/src/constants.ts +23 -1
  123. package/src/index.ts +16 -13
  124. package/src/react/accent-context.tsx +13 -6
  125. package/src/react/catalog-renderer.tsx +4 -0
  126. package/src/react/components/action-button.tsx +47 -20
  127. package/src/react/components/badge.tsx +14 -18
  128. package/src/react/components/bar-chart.tsx +69 -0
  129. package/src/react/components/cell-grid.tsx +128 -0
  130. package/src/react/components/icon.tsx +5 -18
  131. package/src/react/components/input.tsx +20 -9
  132. package/src/react/components/item-group.tsx +4 -1
  133. package/src/react/components/item.tsx +13 -10
  134. package/src/react/components/progress.tsx +12 -7
  135. package/src/react/components/separator.tsx +8 -1
  136. package/src/react/components/slider.tsx +28 -15
  137. package/src/react/components/switch.tsx +12 -16
  138. package/src/react/components/text.tsx +14 -23
  139. package/src/react/components/toggle-group.tsx +26 -9
  140. package/src/react/hooks/use-snap-colors.ts +128 -0
  141. package/src/react/index.tsx +49 -265
  142. package/src/react/snap-view-core.tsx +340 -0
  143. package/src/react/v1/snap-view.tsx +176 -0
  144. package/src/react/v2/snap-view.tsx +199 -0
  145. package/src/react-native/catalog-renderer.tsx +41 -0
  146. package/src/react-native/components/snap-action-button.tsx +96 -0
  147. package/src/react-native/components/snap-badge.tsx +60 -0
  148. package/src/react-native/components/snap-bar-chart.tsx +73 -0
  149. package/src/react-native/components/snap-cell-grid.tsx +150 -0
  150. package/src/react-native/components/snap-icon.tsx +102 -0
  151. package/src/react-native/components/snap-image.tsx +37 -0
  152. package/src/react-native/components/snap-input.tsx +58 -0
  153. package/src/react-native/components/snap-item-group.tsx +43 -0
  154. package/src/react-native/components/snap-item.tsx +66 -0
  155. package/src/react-native/components/snap-progress.tsx +40 -0
  156. package/src/react-native/components/snap-separator.tsx +32 -0
  157. package/src/react-native/components/snap-slider.tsx +85 -0
  158. package/src/react-native/components/snap-stack.tsx +66 -0
  159. package/src/react-native/components/snap-switch.tsx +46 -0
  160. package/src/react-native/components/snap-text.tsx +51 -0
  161. package/src/react-native/components/snap-toggle-group.tsx +127 -0
  162. package/src/react-native/confetti-overlay.tsx +134 -0
  163. package/src/react-native/index.tsx +83 -0
  164. package/src/react-native/snap-view-core.tsx +209 -0
  165. package/src/react-native/theme.tsx +85 -0
  166. package/src/react-native/types.ts +38 -0
  167. package/src/react-native/use-snap-palette.ts +64 -0
  168. package/src/react-native/v1/snap-view.tsx +229 -0
  169. package/src/react-native/v2/snap-view.tsx +283 -0
  170. package/src/schemas.ts +68 -17
  171. package/src/server/parseRequest.ts +68 -9
  172. package/src/server/verify.ts +2 -0
  173. package/src/ui/README.md +8 -8
  174. package/src/ui/badge.ts +2 -0
  175. package/src/ui/bar-chart.ts +38 -0
  176. package/src/ui/button.ts +1 -1
  177. package/src/ui/catalog.ts +19 -3
  178. package/src/ui/cell-grid.ts +49 -0
  179. package/src/ui/image.ts +1 -1
  180. package/src/ui/index.ts +6 -0
  181. package/src/ui/item.ts +1 -1
  182. package/src/ui/schema.ts +2 -2
  183. package/src/ui/slider.ts +2 -0
  184. package/src/ui/text.ts +2 -2
  185. package/src/validator.ts +246 -2
  186. package/dist/dataStore.d.ts +0 -12
  187. package/dist/dataStore.js +0 -35
  188. package/dist/middleware.d.ts +0 -3
  189. package/dist/middleware.js +0 -3
  190. package/dist/react/hooks/use-snap-accent.d.ts +0 -13
  191. package/dist/react/hooks/use-snap-accent.js +0 -32
  192. package/src/dataStore.ts +0 -62
  193. package/src/middleware.ts +0 -7
  194. package/src/react/hooks/use-snap-accent.ts +0 -45
@@ -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: import("@json-render/core").SchemaType<"propsOf", string>;
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> | undefined;
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
- outline: "outline";
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<{
@@ -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 | secondary | destructive | outline.",
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: lg (heading), md (body, default), sm (caption). Optional weight and align.",
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 target URL in the system browser.",
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";
@@ -1,12 +1,11 @@
1
1
  import { z } from "zod";
2
- export declare const IMAGE_ASPECTS: readonly ["1:1", "16:9", "4:3", "3:4", "9:16"];
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
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- export const IMAGE_ASPECTS = ["1:1", "16:9", "4:3", "3:4", "9:16"];
2
+ export const IMAGE_ASPECTS = ["1:1", "16:9", "4:3", "9:16"];
3
3
  export const imageProps = z.object({
4
4
  url: z.string(),
5
5
  aspect: z.enum(IMAGE_ASPECTS),
@@ -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", "outline", "muted"];
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
@@ -1,5 +1,5 @@
1
1
  import { z } from "zod";
2
- export const ITEM_VARIANTS = ["default", "outline", "muted"];
2
+ export const ITEM_VARIANTS = ["default"];
3
3
  export const ITEM_MAX_TITLE_CHARS = 100;
4
4
  export const ITEM_MAX_DESCRIPTION_CHARS = 160;
5
5
  export const itemProps = z.object({
@@ -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: import("@json-render/core").SchemaType<"propsOf", string>;
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> | undefined;
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 pages use a Stack root with at most 6 body children and 1 media element (Image); keep generated trees small.",
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
  });
@@ -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 ["lg", "md", "sm"];
3
- export declare const TEXT_WEIGHTS: readonly ["bold", "medium", "normal"];
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 = ["lg", "md", "sm"];
3
- export const TEXT_WEIGHTS = ["bold", "medium", "normal"];
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({
@@ -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;