@farcaster/snap 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.d.ts +0 -3
- package/dist/constants.js +0 -4
- package/dist/schemas.d.ts +1 -41
- package/dist/schemas.js +4 -17
- package/dist/server/parseRequest.d.ts +1 -1
- package/dist/server/parseRequest.js +1 -1
- package/dist/ui/bar-chart.d.ts +30 -0
- package/dist/ui/bar-chart.js +14 -0
- package/dist/ui/button-group.d.ts +11 -0
- package/dist/ui/button-group.js +10 -0
- package/dist/ui/button.d.ts +32 -0
- package/dist/ui/button.js +10 -0
- package/dist/ui/catalog.d.ts +271 -0
- package/dist/ui/catalog.js +114 -0
- package/dist/ui/divider.d.ts +3 -0
- package/dist/ui/divider.js +2 -0
- package/dist/ui/grid.d.ts +22 -0
- package/dist/ui/grid.js +16 -0
- package/dist/ui/group.d.ts +8 -0
- package/dist/ui/group.js +4 -0
- package/dist/ui/image.d.ts +13 -0
- package/dist/ui/image.js +7 -0
- package/dist/ui/index.d.ts +32 -0
- package/dist/ui/index.js +17 -0
- package/dist/ui/list.d.ts +13 -0
- package/dist/ui/list.js +13 -0
- package/dist/ui/progress.d.ts +18 -0
- package/dist/ui/progress.js +8 -0
- package/dist/ui/schema.d.ts +32 -0
- package/dist/ui/schema.js +31 -0
- package/dist/ui/slider.d.ts +12 -0
- package/dist/ui/slider.js +11 -0
- package/dist/ui/spacer.d.ts +9 -0
- package/dist/ui/spacer.js +5 -0
- package/dist/ui/stack.d.ts +3 -0
- package/dist/ui/stack.js +2 -0
- package/dist/ui/text-input.d.ts +7 -0
- package/dist/ui/text-input.js +12 -0
- package/dist/ui/text.d.ts +16 -0
- package/dist/ui/text.js +7 -0
- package/dist/ui/toggle.d.ts +7 -0
- package/dist/ui/toggle.js +6 -0
- package/dist/validator.d.ts +1 -1
- package/dist/validator.js +0 -1
- package/package.json +83 -2
- package/src/constants.ts +0 -4
- package/src/schemas.ts +3 -20
- package/src/server/parseRequest.ts +1 -1
- package/src/ui/README.md +50 -0
- package/src/ui/bar-chart.ts +23 -0
- package/src/ui/button-group.ts +13 -0
- package/src/ui/button.ts +15 -0
- package/src/ui/catalog.ts +128 -0
- package/src/ui/divider.ts +5 -0
- package/src/ui/grid.ts +25 -0
- package/src/ui/group.ts +7 -0
- package/src/ui/image.ts +10 -0
- package/src/ui/index.ts +47 -0
- package/src/ui/list.ts +17 -0
- package/src/ui/progress.ts +11 -0
- package/src/ui/schema.ts +37 -0
- package/src/ui/slider.ts +14 -0
- package/src/ui/spacer.ts +8 -0
- package/src/ui/stack.ts +5 -0
- package/src/ui/text-input.ts +15 -0
- package/src/ui/text.ts +10 -0
- package/src/ui/toggle.ts +9 -0
- package/src/validator.ts +1 -2
package/dist/constants.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export declare const MEDIA_TYPE: "application/vnd.farcaster.snap+json";
|
|
|
4
4
|
export declare const LIMITS: {
|
|
5
5
|
readonly maxElementsPerPage: 5;
|
|
6
6
|
readonly maxButtonsPerPage: 4;
|
|
7
|
-
readonly maxVideoDurationSeconds: 30;
|
|
8
7
|
readonly maxTextInputChars: 280;
|
|
9
8
|
readonly maxListItems: 4;
|
|
10
9
|
readonly minListItems: 1;
|
|
@@ -33,7 +32,6 @@ export declare const TEXT_STYLE: {
|
|
|
33
32
|
export declare const TEXT_STYLE_VALUES: readonly ["title", "body", "caption", "label"];
|
|
34
33
|
export declare const TEXT_ALIGN_VALUES: readonly ["left", "center", "right"];
|
|
35
34
|
export declare const IMAGE_ASPECT_VALUES: readonly ["1:1", "16:9", "4:3", "3:4", "9:16"];
|
|
36
|
-
export declare const VIDEO_ASPECT_VALUES: readonly ["1:1", "16:9", "9:16"];
|
|
37
35
|
export declare const SPACER_SIZE: {
|
|
38
36
|
readonly small: "small";
|
|
39
37
|
readonly medium: "medium";
|
|
@@ -103,7 +101,6 @@ export declare const PAGE_ROOT_TYPE: {
|
|
|
103
101
|
export declare const ELEMENT_TYPE: {
|
|
104
102
|
readonly text: "text";
|
|
105
103
|
readonly image: "image";
|
|
106
|
-
readonly video: "video";
|
|
107
104
|
readonly divider: "divider";
|
|
108
105
|
readonly spacer: "spacer";
|
|
109
106
|
readonly progress: "progress";
|
package/dist/constants.js
CHANGED
|
@@ -4,7 +4,6 @@ export const MEDIA_TYPE = "application/vnd.farcaster.snap+json";
|
|
|
4
4
|
export const LIMITS = {
|
|
5
5
|
maxElementsPerPage: 5,
|
|
6
6
|
maxButtonsPerPage: 4,
|
|
7
|
-
maxVideoDurationSeconds: 30,
|
|
8
7
|
maxTextInputChars: 280,
|
|
9
8
|
maxListItems: 4,
|
|
10
9
|
minListItems: 1,
|
|
@@ -44,7 +43,6 @@ export const IMAGE_ASPECT_VALUES = [
|
|
|
44
43
|
"3:4",
|
|
45
44
|
"9:16",
|
|
46
45
|
];
|
|
47
|
-
export const VIDEO_ASPECT_VALUES = ["1:1", "16:9", "9:16"];
|
|
48
46
|
export const SPACER_SIZE = {
|
|
49
47
|
small: "small",
|
|
50
48
|
medium: "medium",
|
|
@@ -162,7 +160,6 @@ export const PAGE_ROOT_TYPE = {
|
|
|
162
160
|
export const ELEMENT_TYPE = {
|
|
163
161
|
text: "text",
|
|
164
162
|
image: "image",
|
|
165
|
-
video: "video",
|
|
166
163
|
divider: "divider",
|
|
167
164
|
spacer: "spacer",
|
|
168
165
|
progress: "progress",
|
|
@@ -191,7 +188,6 @@ export const SLIDER_STEP_ALIGN_EPS = 1e-6;
|
|
|
191
188
|
export const DEFAULT_SLIDER_STEP = 1;
|
|
192
189
|
export const MEDIA_ELEMENT_TYPES = [
|
|
193
190
|
ELEMENT_TYPE.image,
|
|
194
|
-
ELEMENT_TYPE.video,
|
|
195
191
|
ELEMENT_TYPE.grid,
|
|
196
192
|
];
|
|
197
193
|
export const INTERACTIVE_ELEMENT_TYPES = [
|
package/dist/schemas.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
declare const buttonSchema: z.ZodObject<{
|
|
3
3
|
label: z.ZodString;
|
|
4
4
|
action: z.ZodEnum<{
|
|
@@ -39,16 +39,6 @@ declare const elementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
39
39
|
"9:16": "9:16";
|
|
40
40
|
}>;
|
|
41
41
|
alt: z.ZodOptional<z.ZodString>;
|
|
42
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
43
|
-
type: z.ZodLiteral<"video">;
|
|
44
|
-
url: z.ZodString;
|
|
45
|
-
aspect: z.ZodEnum<{
|
|
46
|
-
"1:1": "1:1";
|
|
47
|
-
"16:9": "16:9";
|
|
48
|
-
"9:16": "9:16";
|
|
49
|
-
}>;
|
|
50
|
-
maxDuration: z.ZodOptional<z.ZodNumber>;
|
|
51
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
52
42
|
}, z.core.$strip>, z.ZodObject<{
|
|
53
43
|
type: z.ZodLiteral<"divider">;
|
|
54
44
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -363,16 +353,6 @@ declare const elementsSchema: z.ZodObject<{
|
|
|
363
353
|
"9:16": "9:16";
|
|
364
354
|
}>;
|
|
365
355
|
alt: z.ZodOptional<z.ZodString>;
|
|
366
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
367
|
-
type: z.ZodLiteral<"video">;
|
|
368
|
-
url: z.ZodString;
|
|
369
|
-
aspect: z.ZodEnum<{
|
|
370
|
-
"1:1": "1:1";
|
|
371
|
-
"16:9": "16:9";
|
|
372
|
-
"9:16": "9:16";
|
|
373
|
-
}>;
|
|
374
|
-
maxDuration: z.ZodOptional<z.ZodNumber>;
|
|
375
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
376
356
|
}, z.core.$strip>, z.ZodObject<{
|
|
377
357
|
type: z.ZodLiteral<"divider">;
|
|
378
358
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -714,16 +694,6 @@ export declare const rootSchema: z.ZodObject<{
|
|
|
714
694
|
"9:16": "9:16";
|
|
715
695
|
}>;
|
|
716
696
|
alt: z.ZodOptional<z.ZodString>;
|
|
717
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
718
|
-
type: z.ZodLiteral<"video">;
|
|
719
|
-
url: z.ZodString;
|
|
720
|
-
aspect: z.ZodEnum<{
|
|
721
|
-
"1:1": "1:1";
|
|
722
|
-
"16:9": "16:9";
|
|
723
|
-
"9:16": "9:16";
|
|
724
|
-
}>;
|
|
725
|
-
maxDuration: z.ZodOptional<z.ZodNumber>;
|
|
726
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
727
697
|
}, z.core.$strip>, z.ZodObject<{
|
|
728
698
|
type: z.ZodLiteral<"divider">;
|
|
729
699
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -1078,16 +1048,6 @@ export declare const firstPageRootSchema: z.ZodObject<{
|
|
|
1078
1048
|
"9:16": "9:16";
|
|
1079
1049
|
}>;
|
|
1080
1050
|
alt: z.ZodOptional<z.ZodString>;
|
|
1081
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1082
|
-
type: z.ZodLiteral<"video">;
|
|
1083
|
-
url: z.ZodString;
|
|
1084
|
-
aspect: z.ZodEnum<{
|
|
1085
|
-
"1:1": "1:1";
|
|
1086
|
-
"16:9": "16:9";
|
|
1087
|
-
"9:16": "9:16";
|
|
1088
|
-
}>;
|
|
1089
|
-
maxDuration: z.ZodOptional<z.ZodNumber>;
|
|
1090
|
-
alt: z.ZodOptional<z.ZodString>;
|
|
1091
1051
|
}, z.core.$strip>, z.ZodObject<{
|
|
1092
1052
|
type: z.ZodLiteral<"divider">;
|
|
1093
1053
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/schemas.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { z } from "zod
|
|
2
|
-
import { BAR_CHART_COLOR_VALUES, BUTTON_ACTION, BUTTON_ACTION_VALUES, BUTTON_GROUP_STYLE, BUTTON_GROUP_STYLE_VALUES, BUTTON_LAYOUT_VALUES, BUTTON_STYLE_VALUES, DEFAULT_BUTTON_LAYOUT, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, DEFAULT_THEME_ACCENT, EFFECT_VALUES, ELEMENT_TYPE, GRID_CELL_SIZE_VALUES, GRID_GAP_VALUES, GROUP_LAYOUT_VALUES, HEX_COLOR_6_RE, HTTP_PREFIX, HTTPS_PREFIX, IMAGE_ASPECT_VALUES, INTERACTIVE_ELEMENT_TYPES, LIMITS, LIST_STYLE_VALUES, MEDIA_ELEMENT_TYPES, PAGE_ROOT_TYPE, PALETTE_COLOR_VALUES, PROGRESS_COLOR_VALUES, SLIDER_STEP_ALIGN_EPS, SPACER_SIZE, SPACER_SIZE_VALUES, SPEC_VERSION, TEXT_ALIGN_VALUES, TEXT_CONTENT_MAX, TEXT_STYLE, TEXT_STYLE_VALUES,
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BAR_CHART_COLOR_VALUES, BUTTON_ACTION, BUTTON_ACTION_VALUES, BUTTON_GROUP_STYLE, BUTTON_GROUP_STYLE_VALUES, BUTTON_LAYOUT_VALUES, BUTTON_STYLE_VALUES, DEFAULT_BUTTON_LAYOUT, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, DEFAULT_THEME_ACCENT, EFFECT_VALUES, ELEMENT_TYPE, GRID_CELL_SIZE_VALUES, GRID_GAP_VALUES, GROUP_LAYOUT_VALUES, HEX_COLOR_6_RE, HTTP_PREFIX, HTTPS_PREFIX, IMAGE_ASPECT_VALUES, INTERACTIVE_ELEMENT_TYPES, LIMITS, LIST_STYLE_VALUES, MEDIA_ELEMENT_TYPES, PAGE_ROOT_TYPE, PALETTE_COLOR_VALUES, PROGRESS_COLOR_VALUES, SLIDER_STEP_ALIGN_EPS, SPACER_SIZE, SPACER_SIZE_VALUES, SPEC_VERSION, TEXT_ALIGN_VALUES, TEXT_CONTENT_MAX, TEXT_STYLE, TEXT_STYLE_VALUES, } from "./constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* post/link/mini_app targets must be HTTPS in production; allow HTTP only for
|
|
5
5
|
* loopback hosts so local snap servers (e.g. http://localhost:3014/snap) validate.
|
|
@@ -48,11 +48,6 @@ const imageUrlSchema = z
|
|
|
48
48
|
.refine((s) => hasAllowedMediaExtension(s, ["jpg", "png", "gif", "webp"]), {
|
|
49
49
|
message: "image URL must use HTTPS and end with a supported extension (.jpg, .png, .gif, .webp)",
|
|
50
50
|
});
|
|
51
|
-
const videoUrlSchema = z
|
|
52
|
-
.string()
|
|
53
|
-
.refine((s) => hasAllowedMediaExtension(s, ["mp4", "webm"]), {
|
|
54
|
-
message: "video URL must use HTTPS and end with a supported extension (.mp4, .webm)",
|
|
55
|
-
});
|
|
56
51
|
const textAlignSchema = z.enum(TEXT_ALIGN_VALUES);
|
|
57
52
|
const textElementSchema = z
|
|
58
53
|
.object({
|
|
@@ -77,13 +72,6 @@ const imageElementSchema = z.object({
|
|
|
77
72
|
aspect: z.enum(IMAGE_ASPECT_VALUES),
|
|
78
73
|
alt: z.string().optional(),
|
|
79
74
|
});
|
|
80
|
-
const videoElementSchema = z.object({
|
|
81
|
-
type: z.literal(ELEMENT_TYPE.video),
|
|
82
|
-
url: videoUrlSchema,
|
|
83
|
-
aspect: z.enum(VIDEO_ASPECT_VALUES),
|
|
84
|
-
maxDuration: z.number().max(LIMITS.maxVideoDurationSeconds).optional(),
|
|
85
|
-
alt: z.string().optional(),
|
|
86
|
-
});
|
|
87
75
|
const dividerElementSchema = z.object({
|
|
88
76
|
type: z.literal(ELEMENT_TYPE.divider),
|
|
89
77
|
});
|
|
@@ -357,7 +345,6 @@ const groupElementSchema = z.object({
|
|
|
357
345
|
const elementSchema = z.discriminatedUnion("type", [
|
|
358
346
|
textElementSchema,
|
|
359
347
|
imageElementSchema,
|
|
360
|
-
videoElementSchema,
|
|
361
348
|
dividerElementSchema,
|
|
362
349
|
spacerElementSchema,
|
|
363
350
|
progressElementSchema,
|
|
@@ -407,7 +394,7 @@ export const rootSchema = z
|
|
|
407
394
|
if (mediaCount > 1) {
|
|
408
395
|
ctx.addIssue({
|
|
409
396
|
code: "custom",
|
|
410
|
-
message: `cannot have more than 1 media element (image
|
|
397
|
+
message: `cannot have more than 1 media element (image or grid)`,
|
|
411
398
|
path: ["elements", "children"],
|
|
412
399
|
});
|
|
413
400
|
}
|
|
@@ -431,7 +418,7 @@ export const firstPageRootSchema = rootSchema.superRefine((root, ctx) => {
|
|
|
431
418
|
if (!hasInteractive && !hasMedia) {
|
|
432
419
|
ctx.addIssue({
|
|
433
420
|
code: "custom",
|
|
434
|
-
message: "first page must have at least one interactive element (button_group, slider, text_input, toggle) or media element (image,
|
|
421
|
+
message: "first page must have at least one interactive element (button_group, slider, text_input, toggle) or media element (image, grid)",
|
|
435
422
|
path: ["page", "elements", "children"],
|
|
436
423
|
});
|
|
437
424
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { payloadSchema } from "../schemas.js";
|
|
2
2
|
import { decodePayload, verifyJFSRequestBody } from "./verify.js";
|
|
3
|
-
import { z } from "zod
|
|
3
|
+
import { z } from "zod";
|
|
4
4
|
/** Default replay window per SPEC.md § Replay Protection (5 minutes). */
|
|
5
5
|
const DEFAULT_SNAP_POST_MAX_SKEW_SECONDS = 300;
|
|
6
6
|
const requestBodySchema = z.object({
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const barChartProps: z.ZodObject<{
|
|
3
|
+
bars: z.ZodArray<z.ZodObject<{
|
|
4
|
+
label: z.ZodString;
|
|
5
|
+
value: z.ZodNumber;
|
|
6
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
gray: "gray";
|
|
8
|
+
blue: "blue";
|
|
9
|
+
red: "red";
|
|
10
|
+
amber: "amber";
|
|
11
|
+
green: "green";
|
|
12
|
+
teal: "teal";
|
|
13
|
+
purple: "purple";
|
|
14
|
+
pink: "pink";
|
|
15
|
+
}>>;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
19
|
+
gray: "gray";
|
|
20
|
+
blue: "blue";
|
|
21
|
+
red: "red";
|
|
22
|
+
amber: "amber";
|
|
23
|
+
green: "green";
|
|
24
|
+
teal: "teal";
|
|
25
|
+
purple: "purple";
|
|
26
|
+
pink: "pink";
|
|
27
|
+
accent: "accent";
|
|
28
|
+
}>>;
|
|
29
|
+
}, z.core.$strip>;
|
|
30
|
+
export type BarChartProps = z.infer<typeof barChartProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BAR_CHART_COLOR_VALUES, LIMITS, PALETTE_COLOR_VALUES, } from "../constants.js";
|
|
3
|
+
export const barChartProps = z.object({
|
|
4
|
+
bars: z
|
|
5
|
+
.array(z.object({
|
|
6
|
+
label: z.string(),
|
|
7
|
+
value: z.number().nonnegative(),
|
|
8
|
+
color: z.enum(PALETTE_COLOR_VALUES).optional(),
|
|
9
|
+
}))
|
|
10
|
+
.min(1)
|
|
11
|
+
.max(LIMITS.maxBarChartBars),
|
|
12
|
+
max: z.number().nonnegative().optional(),
|
|
13
|
+
color: z.enum(BAR_CHART_COLOR_VALUES).optional(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const buttonGroupProps: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
options: z.ZodArray<z.ZodString>;
|
|
5
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
6
|
+
row: "row";
|
|
7
|
+
stack: "stack";
|
|
8
|
+
grid: "grid";
|
|
9
|
+
}>>;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type ButtonGroupProps = z.infer<typeof buttonGroupProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BUTTON_GROUP_STYLE_VALUES, LIMITS } from "../constants.js";
|
|
3
|
+
export const buttonGroupProps = z.object({
|
|
4
|
+
name: z.string().min(1),
|
|
5
|
+
options: z
|
|
6
|
+
.array(z.string())
|
|
7
|
+
.min(LIMITS.minButtonGroupOptions)
|
|
8
|
+
.max(LIMITS.maxButtonGroupOptions),
|
|
9
|
+
style: z.enum(BUTTON_GROUP_STYLE_VALUES).optional(),
|
|
10
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const actionButtonProps: z.ZodObject<{
|
|
3
|
+
label: z.ZodString;
|
|
4
|
+
action: z.ZodEnum<{
|
|
5
|
+
post: "post";
|
|
6
|
+
link: "link";
|
|
7
|
+
mini_app: "mini_app";
|
|
8
|
+
sdk: "sdk";
|
|
9
|
+
}>;
|
|
10
|
+
target: z.ZodString;
|
|
11
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
primary: "primary";
|
|
13
|
+
secondary: "secondary";
|
|
14
|
+
}>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export type ActionButtonProps = z.infer<typeof actionButtonProps>;
|
|
17
|
+
/** Same schema as `actionButtonProps` (legacy export name). */
|
|
18
|
+
export declare const buttonProps: z.ZodObject<{
|
|
19
|
+
label: z.ZodString;
|
|
20
|
+
action: z.ZodEnum<{
|
|
21
|
+
post: "post";
|
|
22
|
+
link: "link";
|
|
23
|
+
mini_app: "mini_app";
|
|
24
|
+
sdk: "sdk";
|
|
25
|
+
}>;
|
|
26
|
+
target: z.ZodString;
|
|
27
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
primary: "primary";
|
|
29
|
+
secondary: "secondary";
|
|
30
|
+
}>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type ButtonProps = ActionButtonProps;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { BUTTON_ACTION_VALUES, BUTTON_STYLE_VALUES } from "../constants.js";
|
|
3
|
+
export const actionButtonProps = z.object({
|
|
4
|
+
label: z.string(),
|
|
5
|
+
action: z.enum(BUTTON_ACTION_VALUES),
|
|
6
|
+
target: z.string(),
|
|
7
|
+
style: z.enum(BUTTON_STYLE_VALUES).optional(),
|
|
8
|
+
});
|
|
9
|
+
/** Same schema as `actionButtonProps` (legacy export name). */
|
|
10
|
+
export const buttonProps = actionButtonProps;
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Basic catalog: one json-render component per snap element type, plus ActionButton for snap buttons.
|
|
4
|
+
* Does not validate cross-field rules (media count, height budget); snap JSON still goes through `@farcaster/snap` validation.
|
|
5
|
+
*/
|
|
6
|
+
export declare const snapJsonRenderCatalog: import("@json-render/core").Catalog<{
|
|
7
|
+
spec: import("@json-render/core").SchemaType<"object", {
|
|
8
|
+
root: import("@json-render/core").SchemaType<"string", unknown>;
|
|
9
|
+
elements: import("@json-render/core").SchemaType<"record", import("@json-render/core").SchemaType<"object", {
|
|
10
|
+
type: import("@json-render/core").SchemaType<"ref", string>;
|
|
11
|
+
props: import("@json-render/core").SchemaType<"propsOf", string>;
|
|
12
|
+
children: {
|
|
13
|
+
optional: true;
|
|
14
|
+
kind: "array";
|
|
15
|
+
inner?: import("@json-render/core").SchemaType<"string", unknown> | undefined;
|
|
16
|
+
};
|
|
17
|
+
}>>;
|
|
18
|
+
}>;
|
|
19
|
+
catalog: import("@json-render/core").SchemaType<"object", {
|
|
20
|
+
components: import("@json-render/core").SchemaType<"map", {
|
|
21
|
+
props: import("@json-render/core").SchemaType<"zod", unknown>;
|
|
22
|
+
description: import("@json-render/core").SchemaType<"string", unknown>;
|
|
23
|
+
}>;
|
|
24
|
+
actions: import("@json-render/core").SchemaType<"map", {
|
|
25
|
+
description: import("@json-render/core").SchemaType<"string", unknown>;
|
|
26
|
+
params: {
|
|
27
|
+
optional: true;
|
|
28
|
+
kind: "zod";
|
|
29
|
+
inner?: unknown;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
}, {
|
|
34
|
+
components: {
|
|
35
|
+
Text: {
|
|
36
|
+
props: z.ZodObject<{
|
|
37
|
+
style: z.ZodEnum<{
|
|
38
|
+
title: "title";
|
|
39
|
+
body: "body";
|
|
40
|
+
caption: "caption";
|
|
41
|
+
label: "label";
|
|
42
|
+
}>;
|
|
43
|
+
content: z.ZodString;
|
|
44
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
45
|
+
left: "left";
|
|
46
|
+
center: "center";
|
|
47
|
+
right: "right";
|
|
48
|
+
}>>;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
Image: {
|
|
53
|
+
props: z.ZodObject<{
|
|
54
|
+
url: z.ZodString;
|
|
55
|
+
aspect: z.ZodEnum<{
|
|
56
|
+
"1:1": "1:1";
|
|
57
|
+
"16:9": "16:9";
|
|
58
|
+
"4:3": "4:3";
|
|
59
|
+
"3:4": "3:4";
|
|
60
|
+
"9:16": "9:16";
|
|
61
|
+
}>;
|
|
62
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
description: string;
|
|
65
|
+
};
|
|
66
|
+
Divider: {
|
|
67
|
+
props: z.ZodObject<{}, z.core.$strip>;
|
|
68
|
+
description: string;
|
|
69
|
+
};
|
|
70
|
+
Spacer: {
|
|
71
|
+
props: z.ZodObject<{
|
|
72
|
+
size: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
small: "small";
|
|
74
|
+
medium: "medium";
|
|
75
|
+
large: "large";
|
|
76
|
+
}>>;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
Progress: {
|
|
81
|
+
props: z.ZodObject<{
|
|
82
|
+
value: z.ZodNumber;
|
|
83
|
+
max: z.ZodNumber;
|
|
84
|
+
label: z.ZodOptional<z.ZodString>;
|
|
85
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
gray: "gray";
|
|
87
|
+
blue: "blue";
|
|
88
|
+
red: "red";
|
|
89
|
+
amber: "amber";
|
|
90
|
+
green: "green";
|
|
91
|
+
teal: "teal";
|
|
92
|
+
purple: "purple";
|
|
93
|
+
pink: "pink";
|
|
94
|
+
accent: "accent";
|
|
95
|
+
}>>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
description: string;
|
|
98
|
+
};
|
|
99
|
+
List: {
|
|
100
|
+
props: z.ZodObject<{
|
|
101
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
102
|
+
ordered: "ordered";
|
|
103
|
+
unordered: "unordered";
|
|
104
|
+
plain: "plain";
|
|
105
|
+
}>>;
|
|
106
|
+
items: z.ZodArray<z.ZodObject<{
|
|
107
|
+
content: z.ZodString;
|
|
108
|
+
trailing: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, z.core.$strip>>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
description: string;
|
|
112
|
+
};
|
|
113
|
+
Grid: {
|
|
114
|
+
props: z.ZodObject<{
|
|
115
|
+
cols: z.ZodNumber;
|
|
116
|
+
rows: z.ZodNumber;
|
|
117
|
+
cells: z.ZodArray<z.ZodObject<{
|
|
118
|
+
row: z.ZodNumber;
|
|
119
|
+
col: z.ZodNumber;
|
|
120
|
+
color: z.ZodOptional<z.ZodString>;
|
|
121
|
+
content: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
cellSize: z.ZodOptional<z.ZodEnum<{
|
|
124
|
+
auto: "auto";
|
|
125
|
+
square: "square";
|
|
126
|
+
}>>;
|
|
127
|
+
gap: z.ZodOptional<z.ZodEnum<{
|
|
128
|
+
small: "small";
|
|
129
|
+
medium: "medium";
|
|
130
|
+
none: "none";
|
|
131
|
+
}>>;
|
|
132
|
+
interactive: z.ZodOptional<z.ZodBoolean>;
|
|
133
|
+
}, z.core.$strip>;
|
|
134
|
+
description: string;
|
|
135
|
+
};
|
|
136
|
+
TextInput: {
|
|
137
|
+
props: z.ZodObject<{
|
|
138
|
+
name: z.ZodString;
|
|
139
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
140
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
141
|
+
}, z.core.$strip>;
|
|
142
|
+
description: string;
|
|
143
|
+
};
|
|
144
|
+
Slider: {
|
|
145
|
+
props: z.ZodObject<{
|
|
146
|
+
name: z.ZodString;
|
|
147
|
+
min: z.ZodNumber;
|
|
148
|
+
max: z.ZodNumber;
|
|
149
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
label: z.ZodOptional<z.ZodString>;
|
|
152
|
+
minLabel: z.ZodOptional<z.ZodString>;
|
|
153
|
+
maxLabel: z.ZodOptional<z.ZodString>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
description: string;
|
|
156
|
+
};
|
|
157
|
+
ButtonGroup: {
|
|
158
|
+
props: z.ZodObject<{
|
|
159
|
+
name: z.ZodString;
|
|
160
|
+
options: z.ZodArray<z.ZodString>;
|
|
161
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
162
|
+
row: "row";
|
|
163
|
+
stack: "stack";
|
|
164
|
+
grid: "grid";
|
|
165
|
+
}>>;
|
|
166
|
+
}, z.core.$strip>;
|
|
167
|
+
description: string;
|
|
168
|
+
};
|
|
169
|
+
Toggle: {
|
|
170
|
+
props: z.ZodObject<{
|
|
171
|
+
name: z.ZodString;
|
|
172
|
+
label: z.ZodString;
|
|
173
|
+
value: z.ZodOptional<z.ZodBoolean>;
|
|
174
|
+
}, z.core.$strip>;
|
|
175
|
+
description: string;
|
|
176
|
+
};
|
|
177
|
+
BarChart: {
|
|
178
|
+
props: z.ZodObject<{
|
|
179
|
+
bars: z.ZodArray<z.ZodObject<{
|
|
180
|
+
label: z.ZodString;
|
|
181
|
+
value: z.ZodNumber;
|
|
182
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
183
|
+
gray: "gray";
|
|
184
|
+
blue: "blue";
|
|
185
|
+
red: "red";
|
|
186
|
+
amber: "amber";
|
|
187
|
+
green: "green";
|
|
188
|
+
teal: "teal";
|
|
189
|
+
purple: "purple";
|
|
190
|
+
pink: "pink";
|
|
191
|
+
}>>;
|
|
192
|
+
}, z.core.$strip>>;
|
|
193
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
195
|
+
gray: "gray";
|
|
196
|
+
blue: "blue";
|
|
197
|
+
red: "red";
|
|
198
|
+
amber: "amber";
|
|
199
|
+
green: "green";
|
|
200
|
+
teal: "teal";
|
|
201
|
+
purple: "purple";
|
|
202
|
+
pink: "pink";
|
|
203
|
+
accent: "accent";
|
|
204
|
+
}>>;
|
|
205
|
+
}, z.core.$strip>;
|
|
206
|
+
description: string;
|
|
207
|
+
};
|
|
208
|
+
Group: {
|
|
209
|
+
props: z.ZodObject<{
|
|
210
|
+
layout: z.ZodEnum<{
|
|
211
|
+
row: "row";
|
|
212
|
+
grid: "grid";
|
|
213
|
+
}>;
|
|
214
|
+
}, z.core.$strip>;
|
|
215
|
+
description: string;
|
|
216
|
+
};
|
|
217
|
+
Stack: {
|
|
218
|
+
props: z.ZodObject<{}, z.core.$strip>;
|
|
219
|
+
description: string;
|
|
220
|
+
};
|
|
221
|
+
ActionButton: {
|
|
222
|
+
props: z.ZodObject<{
|
|
223
|
+
label: z.ZodString;
|
|
224
|
+
action: z.ZodEnum<{
|
|
225
|
+
post: "post";
|
|
226
|
+
link: "link";
|
|
227
|
+
mini_app: "mini_app";
|
|
228
|
+
sdk: "sdk";
|
|
229
|
+
}>;
|
|
230
|
+
target: z.ZodString;
|
|
231
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
232
|
+
primary: "primary";
|
|
233
|
+
secondary: "secondary";
|
|
234
|
+
}>>;
|
|
235
|
+
}, z.core.$strip>;
|
|
236
|
+
description: string;
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
actions: {
|
|
240
|
+
snap_post: {
|
|
241
|
+
description: string;
|
|
242
|
+
params: z.ZodObject<{
|
|
243
|
+
buttonIndex: z.ZodNumber;
|
|
244
|
+
target: z.ZodString;
|
|
245
|
+
label: z.ZodOptional<z.ZodString>;
|
|
246
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
247
|
+
primary: "primary";
|
|
248
|
+
secondary: "secondary";
|
|
249
|
+
}>>;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
};
|
|
252
|
+
snap_link: {
|
|
253
|
+
description: string;
|
|
254
|
+
params: z.ZodObject<{
|
|
255
|
+
target: z.ZodString;
|
|
256
|
+
}, z.core.$strip>;
|
|
257
|
+
};
|
|
258
|
+
snap_mini_app: {
|
|
259
|
+
description: string;
|
|
260
|
+
params: z.ZodObject<{
|
|
261
|
+
target: z.ZodString;
|
|
262
|
+
}, z.core.$strip>;
|
|
263
|
+
};
|
|
264
|
+
snap_sdk: {
|
|
265
|
+
description: string;
|
|
266
|
+
params: z.ZodObject<{
|
|
267
|
+
target: z.ZodString;
|
|
268
|
+
}, z.core.$strip>;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
}>;
|