@farcaster/snap 1.4.0 → 1.4.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/constants.d.ts +1 -0
- package/dist/constants.js +3 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/schemas.d.ts +141 -0
- package/package.json +1 -1
- package/src/constants.ts +4 -2
- package/src/index.ts +6 -0
- package/src/schemas.ts +4 -0
package/dist/constants.d.ts
CHANGED
|
@@ -60,6 +60,7 @@ export declare const PALETTE_COLOR: {
|
|
|
60
60
|
readonly purple: "purple";
|
|
61
61
|
readonly pink: "pink";
|
|
62
62
|
};
|
|
63
|
+
export declare const PALETTE_COLOR_ACCENT: "accent";
|
|
63
64
|
export declare const PALETTE_COLOR_VALUES: readonly ["gray", "blue", "red", "amber", "green", "teal", "purple", "pink"];
|
|
64
65
|
export type PaletteColor = (typeof PALETTE_COLOR_VALUES)[number];
|
|
65
66
|
/** Light-mode hex for each palette color (emulator / reference client). */
|
package/dist/constants.js
CHANGED
|
@@ -75,6 +75,7 @@ export const PALETTE_COLOR = {
|
|
|
75
75
|
purple: "purple",
|
|
76
76
|
pink: "pink",
|
|
77
77
|
};
|
|
78
|
+
export const PALETTE_COLOR_ACCENT = "accent";
|
|
78
79
|
export const PALETTE_COLOR_VALUES = [
|
|
79
80
|
PALETTE_COLOR.gray,
|
|
80
81
|
PALETTE_COLOR.blue,
|
|
@@ -108,7 +109,7 @@ export const PALETTE_DARK_HEX = {
|
|
|
108
109
|
pink: "#F12B82",
|
|
109
110
|
};
|
|
110
111
|
export const PROGRESS_COLOR_VALUES = [
|
|
111
|
-
|
|
112
|
+
PALETTE_COLOR_ACCENT,
|
|
112
113
|
...PALETTE_COLOR_VALUES,
|
|
113
114
|
];
|
|
114
115
|
export const LIST_STYLE_VALUES = ["ordered", "unordered", "plain"];
|
|
@@ -148,7 +149,7 @@ export const BUTTON_STYLE_VALUES = [
|
|
|
148
149
|
export const BUTTON_LAYOUT_VALUES = ["stack", "row", "grid"];
|
|
149
150
|
export const DEFAULT_BUTTON_LAYOUT = BUTTON_LAYOUT_VALUES[0];
|
|
150
151
|
export const BAR_CHART_COLOR_VALUES = [
|
|
151
|
-
|
|
152
|
+
PALETTE_COLOR_ACCENT,
|
|
152
153
|
...PALETTE_COLOR_VALUES,
|
|
153
154
|
];
|
|
154
155
|
export const EFFECT_VALUES = ["confetti"];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE, DEFAULT_THEME_ACCENT, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, PALETTE_COLOR, PALETTE_COLOR_VALUES, PALETTE_LIGHT_HEX, PALETTE_DARK_HEX, type PaletteColor, } from "./constants.js";
|
|
2
|
-
export { snapResponseSchema, firstPageResponseSchema, payloadSchema, type SnapAction, type SnapContext, type SnapResponse, type SnapHandlerResult, type SnapFunction, type SnapPayload, } from "./schemas.js";
|
|
1
|
+
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE, DEFAULT_THEME_ACCENT, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, PALETTE_COLOR, PALETTE_COLOR_ACCENT, PALETTE_COLOR_VALUES, PALETTE_LIGHT_HEX, PALETTE_DARK_HEX, type PaletteColor, } from "./constants.js";
|
|
2
|
+
export { snapResponseSchema, firstPageResponseSchema, payloadSchema, type Button, type Element, type Elements, type GroupChildElement, type SnapAction, type SnapPageElementInput, type SnapContext, type SnapResponse, type SnapHandlerResult, type SnapFunction, type SnapPayload, } from "./schemas.js";
|
|
3
3
|
export { validateSnapResponse, validateFirstPageResponse, type ValidationResult, } from "./validator.js";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE, DEFAULT_THEME_ACCENT, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, PALETTE_COLOR, PALETTE_COLOR_VALUES, PALETTE_LIGHT_HEX, PALETTE_DARK_HEX, } from "./constants.js";
|
|
1
|
+
export { POST_GRID_TAP_KEY, PAGE_ROOT_TYPE, ELEMENT_TYPE, MEDIA_TYPE, DEFAULT_THEME_ACCENT, DEFAULT_LIST_STYLE, DEFAULT_SLIDER_STEP, PALETTE_COLOR, PALETTE_COLOR_ACCENT, PALETTE_COLOR_VALUES, PALETTE_LIGHT_HEX, PALETTE_DARK_HEX, } from "./constants.js";
|
|
2
2
|
export { snapResponseSchema, firstPageResponseSchema, payloadSchema, } from "./schemas.js";
|
|
3
3
|
export { validateSnapResponse, validateFirstPageResponse, } from "./validator.js";
|
package/dist/schemas.d.ts
CHANGED
|
@@ -14,6 +14,146 @@ declare const buttonSchema: z.ZodObject<{
|
|
|
14
14
|
}>>;
|
|
15
15
|
}, z.core.$strip>;
|
|
16
16
|
export type Button = z.infer<typeof buttonSchema>;
|
|
17
|
+
/** Child elements allowed inside `group` (no media, no nested group) */
|
|
18
|
+
declare const groupChildElementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
19
|
+
type: z.ZodLiteral<"text">;
|
|
20
|
+
style: z.ZodEnum<{
|
|
21
|
+
title: "title";
|
|
22
|
+
body: "body";
|
|
23
|
+
caption: "caption";
|
|
24
|
+
label: "label";
|
|
25
|
+
}>;
|
|
26
|
+
content: z.ZodString;
|
|
27
|
+
align: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
left: "left";
|
|
29
|
+
center: "center";
|
|
30
|
+
right: "right";
|
|
31
|
+
}>>;
|
|
32
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
33
|
+
type: z.ZodLiteral<"divider">;
|
|
34
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
35
|
+
type: z.ZodLiteral<"spacer">;
|
|
36
|
+
size: z.ZodDefault<z.ZodEnum<{
|
|
37
|
+
small: "small";
|
|
38
|
+
medium: "medium";
|
|
39
|
+
large: "large";
|
|
40
|
+
}>>;
|
|
41
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
42
|
+
type: z.ZodLiteral<"progress">;
|
|
43
|
+
value: z.ZodNumber;
|
|
44
|
+
max: z.ZodNumber;
|
|
45
|
+
label: z.ZodOptional<z.ZodString>;
|
|
46
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
47
|
+
gray: "gray";
|
|
48
|
+
blue: "blue";
|
|
49
|
+
red: "red";
|
|
50
|
+
amber: "amber";
|
|
51
|
+
green: "green";
|
|
52
|
+
teal: "teal";
|
|
53
|
+
purple: "purple";
|
|
54
|
+
pink: "pink";
|
|
55
|
+
accent: "accent";
|
|
56
|
+
}>>;
|
|
57
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
58
|
+
type: z.ZodLiteral<"list">;
|
|
59
|
+
style: z.ZodDefault<z.ZodEnum<{
|
|
60
|
+
ordered: "ordered";
|
|
61
|
+
unordered: "unordered";
|
|
62
|
+
plain: "plain";
|
|
63
|
+
}>>;
|
|
64
|
+
items: z.ZodArray<z.ZodObject<{
|
|
65
|
+
content: z.ZodString;
|
|
66
|
+
trailing: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
69
|
+
type: z.ZodLiteral<"text_input">;
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
72
|
+
maxLength: z.ZodOptional<z.ZodNumber>;
|
|
73
|
+
}, z.core.$strip>, z.ZodPipe<z.ZodObject<{
|
|
74
|
+
type: z.ZodLiteral<"slider">;
|
|
75
|
+
name: z.ZodString;
|
|
76
|
+
min: z.ZodNumber;
|
|
77
|
+
max: z.ZodNumber;
|
|
78
|
+
step: z.ZodDefault<z.ZodNumber>;
|
|
79
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
label: z.ZodOptional<z.ZodString>;
|
|
81
|
+
minLabel: z.ZodOptional<z.ZodString>;
|
|
82
|
+
maxLabel: z.ZodOptional<z.ZodString>;
|
|
83
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
84
|
+
value: number;
|
|
85
|
+
type: "slider";
|
|
86
|
+
name: string;
|
|
87
|
+
min: number;
|
|
88
|
+
max: number;
|
|
89
|
+
step: number;
|
|
90
|
+
label?: string | undefined;
|
|
91
|
+
minLabel?: string | undefined;
|
|
92
|
+
maxLabel?: string | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
type: "slider";
|
|
95
|
+
name: string;
|
|
96
|
+
min: number;
|
|
97
|
+
max: number;
|
|
98
|
+
step: number;
|
|
99
|
+
value?: number | undefined;
|
|
100
|
+
label?: string | undefined;
|
|
101
|
+
minLabel?: string | undefined;
|
|
102
|
+
maxLabel?: string | undefined;
|
|
103
|
+
}>>, z.ZodPipe<z.ZodObject<{
|
|
104
|
+
type: z.ZodLiteral<"button_group">;
|
|
105
|
+
name: z.ZodString;
|
|
106
|
+
options: z.ZodArray<z.ZodString>;
|
|
107
|
+
style: z.ZodOptional<z.ZodEnum<{
|
|
108
|
+
row: "row";
|
|
109
|
+
stack: "stack";
|
|
110
|
+
grid: "grid";
|
|
111
|
+
}>>;
|
|
112
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
113
|
+
style: "row" | "stack" | "grid";
|
|
114
|
+
type: "button_group";
|
|
115
|
+
name: string;
|
|
116
|
+
options: string[];
|
|
117
|
+
}, {
|
|
118
|
+
type: "button_group";
|
|
119
|
+
name: string;
|
|
120
|
+
options: string[];
|
|
121
|
+
style?: "row" | "stack" | "grid" | undefined;
|
|
122
|
+
}>>, z.ZodObject<{
|
|
123
|
+
type: z.ZodLiteral<"toggle">;
|
|
124
|
+
name: z.ZodString;
|
|
125
|
+
label: z.ZodString;
|
|
126
|
+
value: z.ZodDefault<z.ZodBoolean>;
|
|
127
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
128
|
+
type: z.ZodLiteral<"bar_chart">;
|
|
129
|
+
bars: z.ZodArray<z.ZodObject<{
|
|
130
|
+
label: z.ZodString;
|
|
131
|
+
value: z.ZodNumber;
|
|
132
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
133
|
+
gray: "gray";
|
|
134
|
+
blue: "blue";
|
|
135
|
+
red: "red";
|
|
136
|
+
amber: "amber";
|
|
137
|
+
green: "green";
|
|
138
|
+
teal: "teal";
|
|
139
|
+
purple: "purple";
|
|
140
|
+
pink: "pink";
|
|
141
|
+
}>>;
|
|
142
|
+
}, z.core.$strip>>;
|
|
143
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
144
|
+
color: z.ZodOptional<z.ZodEnum<{
|
|
145
|
+
gray: "gray";
|
|
146
|
+
blue: "blue";
|
|
147
|
+
red: "red";
|
|
148
|
+
amber: "amber";
|
|
149
|
+
green: "green";
|
|
150
|
+
teal: "teal";
|
|
151
|
+
purple: "purple";
|
|
152
|
+
pink: "pink";
|
|
153
|
+
accent: "accent";
|
|
154
|
+
}>>;
|
|
155
|
+
}, z.core.$strip>], "type">;
|
|
156
|
+
export type GroupChildElement = z.infer<typeof groupChildElementSchema>;
|
|
17
157
|
/** Any single page element, including media and `group` */
|
|
18
158
|
declare const elementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
19
159
|
type: z.ZodLiteral<"text">;
|
|
@@ -328,6 +468,7 @@ declare const elementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
328
468
|
}>>;
|
|
329
469
|
}, z.core.$strip>], "type">;
|
|
330
470
|
export type Element = z.infer<typeof elementSchema>;
|
|
471
|
+
export type SnapPageElementInput = z.input<typeof elementSchema>;
|
|
331
472
|
declare const elementsSchema: z.ZodObject<{
|
|
332
473
|
type: z.ZodLiteral<"stack">;
|
|
333
474
|
children: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
package/package.json
CHANGED
package/src/constants.ts
CHANGED
|
@@ -85,6 +85,8 @@ export const PALETTE_COLOR = {
|
|
|
85
85
|
pink: "pink",
|
|
86
86
|
} as const;
|
|
87
87
|
|
|
88
|
+
export const PALETTE_COLOR_ACCENT = "accent" as const;
|
|
89
|
+
|
|
88
90
|
export const PALETTE_COLOR_VALUES = [
|
|
89
91
|
PALETTE_COLOR.gray,
|
|
90
92
|
PALETTE_COLOR.blue,
|
|
@@ -123,7 +125,7 @@ export const PALETTE_DARK_HEX: Record<PaletteColor, string> = {
|
|
|
123
125
|
};
|
|
124
126
|
|
|
125
127
|
export const PROGRESS_COLOR_VALUES = [
|
|
126
|
-
|
|
128
|
+
PALETTE_COLOR_ACCENT,
|
|
127
129
|
...PALETTE_COLOR_VALUES,
|
|
128
130
|
] as const;
|
|
129
131
|
|
|
@@ -174,7 +176,7 @@ export const BUTTON_LAYOUT_VALUES = ["stack", "row", "grid"] as const;
|
|
|
174
176
|
export const DEFAULT_BUTTON_LAYOUT = BUTTON_LAYOUT_VALUES[0];
|
|
175
177
|
|
|
176
178
|
export const BAR_CHART_COLOR_VALUES = [
|
|
177
|
-
|
|
179
|
+
PALETTE_COLOR_ACCENT,
|
|
178
180
|
...PALETTE_COLOR_VALUES,
|
|
179
181
|
] as const;
|
|
180
182
|
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ export {
|
|
|
7
7
|
DEFAULT_LIST_STYLE,
|
|
8
8
|
DEFAULT_SLIDER_STEP,
|
|
9
9
|
PALETTE_COLOR,
|
|
10
|
+
PALETTE_COLOR_ACCENT,
|
|
10
11
|
PALETTE_COLOR_VALUES,
|
|
11
12
|
PALETTE_LIGHT_HEX,
|
|
12
13
|
PALETTE_DARK_HEX,
|
|
@@ -16,7 +17,12 @@ export {
|
|
|
16
17
|
snapResponseSchema,
|
|
17
18
|
firstPageResponseSchema,
|
|
18
19
|
payloadSchema,
|
|
20
|
+
type Button,
|
|
21
|
+
type Element,
|
|
22
|
+
type Elements,
|
|
23
|
+
type GroupChildElement,
|
|
19
24
|
type SnapAction,
|
|
25
|
+
type SnapPageElementInput,
|
|
20
26
|
type SnapContext,
|
|
21
27
|
type SnapResponse,
|
|
22
28
|
type SnapHandlerResult,
|
package/src/schemas.ts
CHANGED
|
@@ -407,6 +407,8 @@ const groupChildElementSchema = z.discriminatedUnion("type", [
|
|
|
407
407
|
barChartElementSchema,
|
|
408
408
|
]);
|
|
409
409
|
|
|
410
|
+
export type GroupChildElement = z.infer<typeof groupChildElementSchema>;
|
|
411
|
+
|
|
410
412
|
const groupElementSchema = z.object({
|
|
411
413
|
type: z.literal(ELEMENT_TYPE.group),
|
|
412
414
|
layout: z.enum(GROUP_LAYOUT_VALUES),
|
|
@@ -435,6 +437,8 @@ const elementSchema = z.discriminatedUnion("type", [
|
|
|
435
437
|
|
|
436
438
|
export type Element = z.infer<typeof elementSchema>;
|
|
437
439
|
|
|
440
|
+
export type SnapPageElementInput = z.input<typeof elementSchema>;
|
|
441
|
+
|
|
438
442
|
const elementsSchema = z
|
|
439
443
|
.object({
|
|
440
444
|
type: z.literal(PAGE_ROOT_TYPE.stack),
|