@1upvision/protocol 0.1.0
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/components/index.d.ts +399 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +197 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/messages/index.d.ts +518 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +115 -0
- package/package.json +31 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare enum VisionComponentType {
|
|
3
|
+
CompactView = "CompactView",
|
|
4
|
+
List = "List",
|
|
5
|
+
Text = "Text",
|
|
6
|
+
Image = "Image",
|
|
7
|
+
Button = "Button",
|
|
8
|
+
TextField = "TextField",
|
|
9
|
+
TextArea = "TextArea",
|
|
10
|
+
NumberField = "NumberField",
|
|
11
|
+
Toggle = "Toggle",
|
|
12
|
+
Dropdown = "Dropdown",
|
|
13
|
+
Box = "Box"
|
|
14
|
+
}
|
|
15
|
+
export type VisionComponentNode = {
|
|
16
|
+
_id: string;
|
|
17
|
+
type: VisionComponentType;
|
|
18
|
+
props: Record<string, unknown>;
|
|
19
|
+
children: VisionComponentNode[];
|
|
20
|
+
};
|
|
21
|
+
export interface VisionStyle {
|
|
22
|
+
display?: string;
|
|
23
|
+
flexDirection?: string;
|
|
24
|
+
flexWrap?: string;
|
|
25
|
+
alignItems?: string;
|
|
26
|
+
justifyContent?: string;
|
|
27
|
+
alignSelf?: string;
|
|
28
|
+
gap?: string | number;
|
|
29
|
+
flex?: string | number;
|
|
30
|
+
flexGrow?: number;
|
|
31
|
+
flexShrink?: number;
|
|
32
|
+
flexBasis?: string | number;
|
|
33
|
+
gridTemplateColumns?: string;
|
|
34
|
+
gridTemplateRows?: string;
|
|
35
|
+
gridColumn?: string;
|
|
36
|
+
gridRow?: string;
|
|
37
|
+
gridGap?: string | number;
|
|
38
|
+
position?: "relative" | "absolute";
|
|
39
|
+
top?: string | number;
|
|
40
|
+
right?: string | number;
|
|
41
|
+
bottom?: string | number;
|
|
42
|
+
left?: string | number;
|
|
43
|
+
zIndex?: number;
|
|
44
|
+
width?: string | number;
|
|
45
|
+
height?: string | number;
|
|
46
|
+
minWidth?: string | number;
|
|
47
|
+
maxWidth?: string | number;
|
|
48
|
+
minHeight?: string | number;
|
|
49
|
+
maxHeight?: string | number;
|
|
50
|
+
aspectRatio?: string | number;
|
|
51
|
+
padding?: string | number;
|
|
52
|
+
paddingTop?: string | number;
|
|
53
|
+
paddingRight?: string | number;
|
|
54
|
+
paddingBottom?: string | number;
|
|
55
|
+
paddingLeft?: string | number;
|
|
56
|
+
margin?: string | number;
|
|
57
|
+
marginTop?: string | number;
|
|
58
|
+
marginRight?: string | number;
|
|
59
|
+
marginBottom?: string | number;
|
|
60
|
+
marginLeft?: string | number;
|
|
61
|
+
color?: string;
|
|
62
|
+
backgroundColor?: string;
|
|
63
|
+
background?: string;
|
|
64
|
+
opacity?: number;
|
|
65
|
+
border?: string;
|
|
66
|
+
borderWidth?: string | number;
|
|
67
|
+
borderColor?: string;
|
|
68
|
+
borderStyle?: string;
|
|
69
|
+
borderRadius?: string | number;
|
|
70
|
+
borderTop?: string;
|
|
71
|
+
borderRight?: string;
|
|
72
|
+
borderBottom?: string;
|
|
73
|
+
borderLeft?: string;
|
|
74
|
+
fontSize?: string | number;
|
|
75
|
+
fontWeight?: string | number;
|
|
76
|
+
fontFamily?: string;
|
|
77
|
+
fontStyle?: string;
|
|
78
|
+
textAlign?: string;
|
|
79
|
+
textDecoration?: string;
|
|
80
|
+
textTransform?: string;
|
|
81
|
+
lineHeight?: string | number;
|
|
82
|
+
letterSpacing?: string | number;
|
|
83
|
+
whiteSpace?: string;
|
|
84
|
+
overflow?: string;
|
|
85
|
+
textOverflow?: string;
|
|
86
|
+
wordBreak?: string;
|
|
87
|
+
transform?: string;
|
|
88
|
+
transformOrigin?: string;
|
|
89
|
+
transition?: string;
|
|
90
|
+
boxShadow?: string;
|
|
91
|
+
textShadow?: string;
|
|
92
|
+
filter?: string;
|
|
93
|
+
backdropFilter?: string;
|
|
94
|
+
objectFit?: string;
|
|
95
|
+
pointerEvents?: string;
|
|
96
|
+
userSelect?: string;
|
|
97
|
+
cursor?: string;
|
|
98
|
+
overflowX?: string;
|
|
99
|
+
overflowY?: string;
|
|
100
|
+
}
|
|
101
|
+
export declare const VisionStyleSchema: z.ZodType<VisionStyle>;
|
|
102
|
+
export interface CompactViewProps {
|
|
103
|
+
title?: string;
|
|
104
|
+
style?: VisionStyle;
|
|
105
|
+
children?: VisionComponentNode[];
|
|
106
|
+
}
|
|
107
|
+
export interface ListProps {
|
|
108
|
+
gap?: number;
|
|
109
|
+
style?: VisionStyle;
|
|
110
|
+
children?: VisionComponentNode[];
|
|
111
|
+
}
|
|
112
|
+
export interface TextProps {
|
|
113
|
+
content: string;
|
|
114
|
+
variant?: "default" | "muted" | "bold" | "heading";
|
|
115
|
+
style?: VisionStyle;
|
|
116
|
+
}
|
|
117
|
+
export interface ImageProps {
|
|
118
|
+
src: string;
|
|
119
|
+
alt?: string;
|
|
120
|
+
width?: number;
|
|
121
|
+
height?: number;
|
|
122
|
+
style?: VisionStyle;
|
|
123
|
+
}
|
|
124
|
+
export interface ButtonProps {
|
|
125
|
+
label: string;
|
|
126
|
+
variant?: "default" | "secondary" | "outline" | "destructive";
|
|
127
|
+
disabled?: boolean;
|
|
128
|
+
onClick?: string;
|
|
129
|
+
style?: VisionStyle;
|
|
130
|
+
}
|
|
131
|
+
export interface TextFieldProps {
|
|
132
|
+
label?: string;
|
|
133
|
+
placeholder?: string;
|
|
134
|
+
value?: string;
|
|
135
|
+
onChange?: string;
|
|
136
|
+
disabled?: boolean;
|
|
137
|
+
style?: VisionStyle;
|
|
138
|
+
}
|
|
139
|
+
export interface TextAreaProps {
|
|
140
|
+
label?: string;
|
|
141
|
+
placeholder?: string;
|
|
142
|
+
value?: string;
|
|
143
|
+
onChange?: string;
|
|
144
|
+
rows?: number;
|
|
145
|
+
disabled?: boolean;
|
|
146
|
+
style?: VisionStyle;
|
|
147
|
+
}
|
|
148
|
+
export interface NumberFieldProps {
|
|
149
|
+
label?: string;
|
|
150
|
+
value?: number;
|
|
151
|
+
min?: number;
|
|
152
|
+
max?: number;
|
|
153
|
+
step?: number;
|
|
154
|
+
onChange?: string;
|
|
155
|
+
disabled?: boolean;
|
|
156
|
+
style?: VisionStyle;
|
|
157
|
+
}
|
|
158
|
+
export interface ToggleProps {
|
|
159
|
+
label?: string;
|
|
160
|
+
checked?: boolean;
|
|
161
|
+
onChange?: string;
|
|
162
|
+
disabled?: boolean;
|
|
163
|
+
style?: VisionStyle;
|
|
164
|
+
}
|
|
165
|
+
export interface DropdownProps {
|
|
166
|
+
label?: string;
|
|
167
|
+
value?: string;
|
|
168
|
+
options: Array<{
|
|
169
|
+
label: string;
|
|
170
|
+
value: string;
|
|
171
|
+
}>;
|
|
172
|
+
onChange?: string;
|
|
173
|
+
disabled?: boolean;
|
|
174
|
+
style?: VisionStyle;
|
|
175
|
+
}
|
|
176
|
+
export interface BoxProps {
|
|
177
|
+
style?: VisionStyle;
|
|
178
|
+
children?: VisionComponentNode[];
|
|
179
|
+
}
|
|
180
|
+
export declare const CompactViewPropsSchema: z.ZodObject<{
|
|
181
|
+
title: z.ZodOptional<z.ZodString>;
|
|
182
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
183
|
+
children: z.ZodOptional<z.ZodLazy<z.ZodArray<z.ZodType<VisionComponentNode, z.ZodTypeDef, VisionComponentNode>, "many">>>;
|
|
184
|
+
}, "strip", z.ZodTypeAny, {
|
|
185
|
+
title?: string | undefined;
|
|
186
|
+
style?: VisionStyle | undefined;
|
|
187
|
+
children?: VisionComponentNode[] | undefined;
|
|
188
|
+
}, {
|
|
189
|
+
title?: string | undefined;
|
|
190
|
+
style?: VisionStyle | undefined;
|
|
191
|
+
children?: VisionComponentNode[] | undefined;
|
|
192
|
+
}>;
|
|
193
|
+
export declare const ListPropsSchema: z.ZodObject<{
|
|
194
|
+
gap: z.ZodOptional<z.ZodNumber>;
|
|
195
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
196
|
+
children: z.ZodOptional<z.ZodLazy<z.ZodArray<z.ZodType<VisionComponentNode, z.ZodTypeDef, VisionComponentNode>, "many">>>;
|
|
197
|
+
}, "strip", z.ZodTypeAny, {
|
|
198
|
+
gap?: number | undefined;
|
|
199
|
+
style?: VisionStyle | undefined;
|
|
200
|
+
children?: VisionComponentNode[] | undefined;
|
|
201
|
+
}, {
|
|
202
|
+
gap?: number | undefined;
|
|
203
|
+
style?: VisionStyle | undefined;
|
|
204
|
+
children?: VisionComponentNode[] | undefined;
|
|
205
|
+
}>;
|
|
206
|
+
export declare const TextPropsSchema: z.ZodObject<{
|
|
207
|
+
content: z.ZodString;
|
|
208
|
+
variant: z.ZodOptional<z.ZodEnum<["default", "muted", "bold", "heading"]>>;
|
|
209
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
content: string;
|
|
212
|
+
style?: VisionStyle | undefined;
|
|
213
|
+
variant?: "default" | "muted" | "bold" | "heading" | undefined;
|
|
214
|
+
}, {
|
|
215
|
+
content: string;
|
|
216
|
+
style?: VisionStyle | undefined;
|
|
217
|
+
variant?: "default" | "muted" | "bold" | "heading" | undefined;
|
|
218
|
+
}>;
|
|
219
|
+
export declare const ImagePropsSchema: z.ZodObject<{
|
|
220
|
+
src: z.ZodString;
|
|
221
|
+
alt: z.ZodOptional<z.ZodString>;
|
|
222
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
224
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
225
|
+
}, "strip", z.ZodTypeAny, {
|
|
226
|
+
src: string;
|
|
227
|
+
width?: number | undefined;
|
|
228
|
+
height?: number | undefined;
|
|
229
|
+
style?: VisionStyle | undefined;
|
|
230
|
+
alt?: string | undefined;
|
|
231
|
+
}, {
|
|
232
|
+
src: string;
|
|
233
|
+
width?: number | undefined;
|
|
234
|
+
height?: number | undefined;
|
|
235
|
+
style?: VisionStyle | undefined;
|
|
236
|
+
alt?: string | undefined;
|
|
237
|
+
}>;
|
|
238
|
+
export declare const ButtonPropsSchema: z.ZodObject<{
|
|
239
|
+
label: z.ZodString;
|
|
240
|
+
variant: z.ZodOptional<z.ZodEnum<["default", "secondary", "outline", "destructive"]>>;
|
|
241
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
242
|
+
onClick: z.ZodOptional<z.ZodString>;
|
|
243
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
244
|
+
}, "strip", z.ZodTypeAny, {
|
|
245
|
+
label: string;
|
|
246
|
+
style?: VisionStyle | undefined;
|
|
247
|
+
variant?: "default" | "secondary" | "outline" | "destructive" | undefined;
|
|
248
|
+
disabled?: boolean | undefined;
|
|
249
|
+
onClick?: string | undefined;
|
|
250
|
+
}, {
|
|
251
|
+
label: string;
|
|
252
|
+
style?: VisionStyle | undefined;
|
|
253
|
+
variant?: "default" | "secondary" | "outline" | "destructive" | undefined;
|
|
254
|
+
disabled?: boolean | undefined;
|
|
255
|
+
onClick?: string | undefined;
|
|
256
|
+
}>;
|
|
257
|
+
export declare const TextFieldPropsSchema: z.ZodObject<{
|
|
258
|
+
label: z.ZodOptional<z.ZodString>;
|
|
259
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
260
|
+
value: z.ZodOptional<z.ZodString>;
|
|
261
|
+
onChange: z.ZodOptional<z.ZodString>;
|
|
262
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
263
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
264
|
+
}, "strip", z.ZodTypeAny, {
|
|
265
|
+
value?: string | undefined;
|
|
266
|
+
style?: VisionStyle | undefined;
|
|
267
|
+
label?: string | undefined;
|
|
268
|
+
disabled?: boolean | undefined;
|
|
269
|
+
placeholder?: string | undefined;
|
|
270
|
+
onChange?: string | undefined;
|
|
271
|
+
}, {
|
|
272
|
+
value?: string | undefined;
|
|
273
|
+
style?: VisionStyle | undefined;
|
|
274
|
+
label?: string | undefined;
|
|
275
|
+
disabled?: boolean | undefined;
|
|
276
|
+
placeholder?: string | undefined;
|
|
277
|
+
onChange?: string | undefined;
|
|
278
|
+
}>;
|
|
279
|
+
export declare const TextAreaPropsSchema: z.ZodObject<{
|
|
280
|
+
label: z.ZodOptional<z.ZodString>;
|
|
281
|
+
placeholder: z.ZodOptional<z.ZodString>;
|
|
282
|
+
value: z.ZodOptional<z.ZodString>;
|
|
283
|
+
onChange: z.ZodOptional<z.ZodString>;
|
|
284
|
+
rows: z.ZodOptional<z.ZodNumber>;
|
|
285
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
286
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
287
|
+
}, "strip", z.ZodTypeAny, {
|
|
288
|
+
value?: string | undefined;
|
|
289
|
+
style?: VisionStyle | undefined;
|
|
290
|
+
label?: string | undefined;
|
|
291
|
+
disabled?: boolean | undefined;
|
|
292
|
+
placeholder?: string | undefined;
|
|
293
|
+
onChange?: string | undefined;
|
|
294
|
+
rows?: number | undefined;
|
|
295
|
+
}, {
|
|
296
|
+
value?: string | undefined;
|
|
297
|
+
style?: VisionStyle | undefined;
|
|
298
|
+
label?: string | undefined;
|
|
299
|
+
disabled?: boolean | undefined;
|
|
300
|
+
placeholder?: string | undefined;
|
|
301
|
+
onChange?: string | undefined;
|
|
302
|
+
rows?: number | undefined;
|
|
303
|
+
}>;
|
|
304
|
+
export declare const NumberFieldPropsSchema: z.ZodObject<{
|
|
305
|
+
label: z.ZodOptional<z.ZodString>;
|
|
306
|
+
value: z.ZodOptional<z.ZodNumber>;
|
|
307
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
308
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
309
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
310
|
+
onChange: z.ZodOptional<z.ZodString>;
|
|
311
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
312
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
313
|
+
}, "strip", z.ZodTypeAny, {
|
|
314
|
+
value?: number | undefined;
|
|
315
|
+
style?: VisionStyle | undefined;
|
|
316
|
+
label?: string | undefined;
|
|
317
|
+
disabled?: boolean | undefined;
|
|
318
|
+
onChange?: string | undefined;
|
|
319
|
+
min?: number | undefined;
|
|
320
|
+
max?: number | undefined;
|
|
321
|
+
step?: number | undefined;
|
|
322
|
+
}, {
|
|
323
|
+
value?: number | undefined;
|
|
324
|
+
style?: VisionStyle | undefined;
|
|
325
|
+
label?: string | undefined;
|
|
326
|
+
disabled?: boolean | undefined;
|
|
327
|
+
onChange?: string | undefined;
|
|
328
|
+
min?: number | undefined;
|
|
329
|
+
max?: number | undefined;
|
|
330
|
+
step?: number | undefined;
|
|
331
|
+
}>;
|
|
332
|
+
export declare const TogglePropsSchema: z.ZodObject<{
|
|
333
|
+
label: z.ZodOptional<z.ZodString>;
|
|
334
|
+
checked: z.ZodOptional<z.ZodBoolean>;
|
|
335
|
+
onChange: z.ZodOptional<z.ZodString>;
|
|
336
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
337
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
338
|
+
}, "strip", z.ZodTypeAny, {
|
|
339
|
+
style?: VisionStyle | undefined;
|
|
340
|
+
label?: string | undefined;
|
|
341
|
+
disabled?: boolean | undefined;
|
|
342
|
+
onChange?: string | undefined;
|
|
343
|
+
checked?: boolean | undefined;
|
|
344
|
+
}, {
|
|
345
|
+
style?: VisionStyle | undefined;
|
|
346
|
+
label?: string | undefined;
|
|
347
|
+
disabled?: boolean | undefined;
|
|
348
|
+
onChange?: string | undefined;
|
|
349
|
+
checked?: boolean | undefined;
|
|
350
|
+
}>;
|
|
351
|
+
export declare const DropdownPropsSchema: z.ZodObject<{
|
|
352
|
+
label: z.ZodOptional<z.ZodString>;
|
|
353
|
+
value: z.ZodOptional<z.ZodString>;
|
|
354
|
+
options: z.ZodArray<z.ZodObject<{
|
|
355
|
+
label: z.ZodString;
|
|
356
|
+
value: z.ZodString;
|
|
357
|
+
}, "strip", z.ZodTypeAny, {
|
|
358
|
+
value: string;
|
|
359
|
+
label: string;
|
|
360
|
+
}, {
|
|
361
|
+
value: string;
|
|
362
|
+
label: string;
|
|
363
|
+
}>, "many">;
|
|
364
|
+
onChange: z.ZodOptional<z.ZodString>;
|
|
365
|
+
disabled: z.ZodOptional<z.ZodBoolean>;
|
|
366
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
367
|
+
}, "strip", z.ZodTypeAny, {
|
|
368
|
+
options: {
|
|
369
|
+
value: string;
|
|
370
|
+
label: string;
|
|
371
|
+
}[];
|
|
372
|
+
value?: string | undefined;
|
|
373
|
+
style?: VisionStyle | undefined;
|
|
374
|
+
label?: string | undefined;
|
|
375
|
+
disabled?: boolean | undefined;
|
|
376
|
+
onChange?: string | undefined;
|
|
377
|
+
}, {
|
|
378
|
+
options: {
|
|
379
|
+
value: string;
|
|
380
|
+
label: string;
|
|
381
|
+
}[];
|
|
382
|
+
value?: string | undefined;
|
|
383
|
+
style?: VisionStyle | undefined;
|
|
384
|
+
label?: string | undefined;
|
|
385
|
+
disabled?: boolean | undefined;
|
|
386
|
+
onChange?: string | undefined;
|
|
387
|
+
}>;
|
|
388
|
+
export declare const BoxPropsSchema: z.ZodObject<{
|
|
389
|
+
style: z.ZodOptional<z.ZodType<VisionStyle, z.ZodTypeDef, VisionStyle>>;
|
|
390
|
+
children: z.ZodOptional<z.ZodLazy<z.ZodArray<z.ZodType<VisionComponentNode, z.ZodTypeDef, VisionComponentNode>, "many">>>;
|
|
391
|
+
}, "strip", z.ZodTypeAny, {
|
|
392
|
+
style?: VisionStyle | undefined;
|
|
393
|
+
children?: VisionComponentNode[] | undefined;
|
|
394
|
+
}, {
|
|
395
|
+
style?: VisionStyle | undefined;
|
|
396
|
+
children?: VisionComponentNode[] | undefined;
|
|
397
|
+
}>;
|
|
398
|
+
export declare const VisionComponentNodeSchema: z.ZodType<VisionComponentNode>;
|
|
399
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,oBAAY,mBAAmB;IAC7B,WAAW,gBAAgB;IAC3B,IAAI,SAAS;IACb,IAAI,SAAS;IACb,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,SAAS,cAAc;IACvB,QAAQ,aAAa;IACrB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,GAAG,QAAQ;CACZ;AAMD,MAAM,MAAM,mBAAmB,GAAG;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,mBAAmB,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,QAAQ,EAAE,mBAAmB,EAAE,CAAC;CACjC,CAAC;AAMF,MAAM,WAAW,WAAW;IAE1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc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;;;;;;;;;;;EAO9B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;EAGzB,CAAC;AAMH,eAAO,MAAM,yBAAyB,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,CAQpE,CAAC"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// ---------------------------------------------------------------------------
|
|
3
|
+
// Component type enum
|
|
4
|
+
// ---------------------------------------------------------------------------
|
|
5
|
+
export var VisionComponentType;
|
|
6
|
+
(function (VisionComponentType) {
|
|
7
|
+
VisionComponentType["CompactView"] = "CompactView";
|
|
8
|
+
VisionComponentType["List"] = "List";
|
|
9
|
+
VisionComponentType["Text"] = "Text";
|
|
10
|
+
VisionComponentType["Image"] = "Image";
|
|
11
|
+
VisionComponentType["Button"] = "Button";
|
|
12
|
+
VisionComponentType["TextField"] = "TextField";
|
|
13
|
+
VisionComponentType["TextArea"] = "TextArea";
|
|
14
|
+
VisionComponentType["NumberField"] = "NumberField";
|
|
15
|
+
VisionComponentType["Toggle"] = "Toggle";
|
|
16
|
+
VisionComponentType["Dropdown"] = "Dropdown";
|
|
17
|
+
VisionComponentType["Box"] = "Box";
|
|
18
|
+
})(VisionComponentType || (VisionComponentType = {}));
|
|
19
|
+
export const VisionStyleSchema = z.object({
|
|
20
|
+
// Layout
|
|
21
|
+
display: z.string().optional(),
|
|
22
|
+
flexDirection: z.string().optional(),
|
|
23
|
+
flexWrap: z.string().optional(),
|
|
24
|
+
alignItems: z.string().optional(),
|
|
25
|
+
justifyContent: z.string().optional(),
|
|
26
|
+
alignSelf: z.string().optional(),
|
|
27
|
+
gap: z.union([z.string(), z.number()]).optional(),
|
|
28
|
+
flex: z.union([z.string(), z.number()]).optional(),
|
|
29
|
+
flexGrow: z.number().optional(),
|
|
30
|
+
flexShrink: z.number().optional(),
|
|
31
|
+
flexBasis: z.union([z.string(), z.number()]).optional(),
|
|
32
|
+
gridTemplateColumns: z.string().optional(),
|
|
33
|
+
gridTemplateRows: z.string().optional(),
|
|
34
|
+
gridColumn: z.string().optional(),
|
|
35
|
+
gridRow: z.string().optional(),
|
|
36
|
+
gridGap: z.union([z.string(), z.number()]).optional(),
|
|
37
|
+
// Position
|
|
38
|
+
position: z.enum(["relative", "absolute"]).optional(),
|
|
39
|
+
top: z.union([z.string(), z.number()]).optional(),
|
|
40
|
+
right: z.union([z.string(), z.number()]).optional(),
|
|
41
|
+
bottom: z.union([z.string(), z.number()]).optional(),
|
|
42
|
+
left: z.union([z.string(), z.number()]).optional(),
|
|
43
|
+
zIndex: z.number().optional(),
|
|
44
|
+
// Sizing
|
|
45
|
+
width: z.union([z.string(), z.number()]).optional(),
|
|
46
|
+
height: z.union([z.string(), z.number()]).optional(),
|
|
47
|
+
minWidth: z.union([z.string(), z.number()]).optional(),
|
|
48
|
+
maxWidth: z.union([z.string(), z.number()]).optional(),
|
|
49
|
+
minHeight: z.union([z.string(), z.number()]).optional(),
|
|
50
|
+
maxHeight: z.union([z.string(), z.number()]).optional(),
|
|
51
|
+
aspectRatio: z.union([z.string(), z.number()]).optional(),
|
|
52
|
+
// Spacing
|
|
53
|
+
padding: z.union([z.string(), z.number()]).optional(),
|
|
54
|
+
paddingTop: z.union([z.string(), z.number()]).optional(),
|
|
55
|
+
paddingRight: z.union([z.string(), z.number()]).optional(),
|
|
56
|
+
paddingBottom: z.union([z.string(), z.number()]).optional(),
|
|
57
|
+
paddingLeft: z.union([z.string(), z.number()]).optional(),
|
|
58
|
+
margin: z.union([z.string(), z.number()]).optional(),
|
|
59
|
+
marginTop: z.union([z.string(), z.number()]).optional(),
|
|
60
|
+
marginRight: z.union([z.string(), z.number()]).optional(),
|
|
61
|
+
marginBottom: z.union([z.string(), z.number()]).optional(),
|
|
62
|
+
marginLeft: z.union([z.string(), z.number()]).optional(),
|
|
63
|
+
// Colors
|
|
64
|
+
color: z.string().optional(),
|
|
65
|
+
backgroundColor: z.string().optional(),
|
|
66
|
+
background: z.string().optional(),
|
|
67
|
+
opacity: z.number().optional(),
|
|
68
|
+
// Border
|
|
69
|
+
border: z.string().optional(),
|
|
70
|
+
borderWidth: z.union([z.string(), z.number()]).optional(),
|
|
71
|
+
borderColor: z.string().optional(),
|
|
72
|
+
borderStyle: z.string().optional(),
|
|
73
|
+
borderRadius: z.union([z.string(), z.number()]).optional(),
|
|
74
|
+
borderTop: z.string().optional(),
|
|
75
|
+
borderRight: z.string().optional(),
|
|
76
|
+
borderBottom: z.string().optional(),
|
|
77
|
+
borderLeft: z.string().optional(),
|
|
78
|
+
// Typography
|
|
79
|
+
fontSize: z.union([z.string(), z.number()]).optional(),
|
|
80
|
+
fontWeight: z.union([z.string(), z.number()]).optional(),
|
|
81
|
+
fontFamily: z.string().optional(),
|
|
82
|
+
fontStyle: z.string().optional(),
|
|
83
|
+
textAlign: z.string().optional(),
|
|
84
|
+
textDecoration: z.string().optional(),
|
|
85
|
+
textTransform: z.string().optional(),
|
|
86
|
+
lineHeight: z.union([z.string(), z.number()]).optional(),
|
|
87
|
+
letterSpacing: z.union([z.string(), z.number()]).optional(),
|
|
88
|
+
whiteSpace: z.string().optional(),
|
|
89
|
+
overflow: z.string().optional(),
|
|
90
|
+
textOverflow: z.string().optional(),
|
|
91
|
+
wordBreak: z.string().optional(),
|
|
92
|
+
// Transform
|
|
93
|
+
transform: z.string().optional(),
|
|
94
|
+
transformOrigin: z.string().optional(),
|
|
95
|
+
transition: z.string().optional(),
|
|
96
|
+
// Effects
|
|
97
|
+
boxShadow: z.string().optional(),
|
|
98
|
+
textShadow: z.string().optional(),
|
|
99
|
+
filter: z.string().optional(),
|
|
100
|
+
backdropFilter: z.string().optional(),
|
|
101
|
+
// Other
|
|
102
|
+
objectFit: z.string().optional(),
|
|
103
|
+
pointerEvents: z.string().optional(),
|
|
104
|
+
userSelect: z.string().optional(),
|
|
105
|
+
cursor: z.string().optional(),
|
|
106
|
+
overflowX: z.string().optional(),
|
|
107
|
+
overflowY: z.string().optional(),
|
|
108
|
+
}).strict();
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Zod schemas – props
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
export const CompactViewPropsSchema = z.object({
|
|
113
|
+
title: z.string().optional(),
|
|
114
|
+
style: VisionStyleSchema.optional(),
|
|
115
|
+
children: z.lazy(() => z.array(VisionComponentNodeSchema)).optional(),
|
|
116
|
+
});
|
|
117
|
+
export const ListPropsSchema = z.object({
|
|
118
|
+
gap: z.number().optional(),
|
|
119
|
+
style: VisionStyleSchema.optional(),
|
|
120
|
+
children: z.lazy(() => z.array(VisionComponentNodeSchema)).optional(),
|
|
121
|
+
});
|
|
122
|
+
export const TextPropsSchema = z.object({
|
|
123
|
+
content: z.string(),
|
|
124
|
+
variant: z.enum(["default", "muted", "bold", "heading"]).optional(),
|
|
125
|
+
style: VisionStyleSchema.optional(),
|
|
126
|
+
});
|
|
127
|
+
export const ImagePropsSchema = z.object({
|
|
128
|
+
src: z.string(),
|
|
129
|
+
alt: z.string().optional(),
|
|
130
|
+
width: z.number().optional(),
|
|
131
|
+
height: z.number().optional(),
|
|
132
|
+
style: VisionStyleSchema.optional(),
|
|
133
|
+
});
|
|
134
|
+
export const ButtonPropsSchema = z.object({
|
|
135
|
+
label: z.string(),
|
|
136
|
+
variant: z
|
|
137
|
+
.enum(["default", "secondary", "outline", "destructive"])
|
|
138
|
+
.optional(),
|
|
139
|
+
disabled: z.boolean().optional(),
|
|
140
|
+
onClick: z.string().optional(),
|
|
141
|
+
style: VisionStyleSchema.optional(),
|
|
142
|
+
});
|
|
143
|
+
export const TextFieldPropsSchema = z.object({
|
|
144
|
+
label: z.string().optional(),
|
|
145
|
+
placeholder: z.string().optional(),
|
|
146
|
+
value: z.string().optional(),
|
|
147
|
+
onChange: z.string().optional(),
|
|
148
|
+
disabled: z.boolean().optional(),
|
|
149
|
+
style: VisionStyleSchema.optional(),
|
|
150
|
+
});
|
|
151
|
+
export const TextAreaPropsSchema = z.object({
|
|
152
|
+
label: z.string().optional(),
|
|
153
|
+
placeholder: z.string().optional(),
|
|
154
|
+
value: z.string().optional(),
|
|
155
|
+
onChange: z.string().optional(),
|
|
156
|
+
rows: z.number().optional(),
|
|
157
|
+
disabled: z.boolean().optional(),
|
|
158
|
+
style: VisionStyleSchema.optional(),
|
|
159
|
+
});
|
|
160
|
+
export const NumberFieldPropsSchema = z.object({
|
|
161
|
+
label: z.string().optional(),
|
|
162
|
+
value: z.number().optional(),
|
|
163
|
+
min: z.number().optional(),
|
|
164
|
+
max: z.number().optional(),
|
|
165
|
+
step: z.number().optional(),
|
|
166
|
+
onChange: z.string().optional(),
|
|
167
|
+
disabled: z.boolean().optional(),
|
|
168
|
+
style: VisionStyleSchema.optional(),
|
|
169
|
+
});
|
|
170
|
+
export const TogglePropsSchema = z.object({
|
|
171
|
+
label: z.string().optional(),
|
|
172
|
+
checked: z.boolean().optional(),
|
|
173
|
+
onChange: z.string().optional(),
|
|
174
|
+
disabled: z.boolean().optional(),
|
|
175
|
+
style: VisionStyleSchema.optional(),
|
|
176
|
+
});
|
|
177
|
+
export const DropdownPropsSchema = z.object({
|
|
178
|
+
label: z.string().optional(),
|
|
179
|
+
value: z.string().optional(),
|
|
180
|
+
options: z.array(z.object({ label: z.string(), value: z.string() })),
|
|
181
|
+
onChange: z.string().optional(),
|
|
182
|
+
disabled: z.boolean().optional(),
|
|
183
|
+
style: VisionStyleSchema.optional(),
|
|
184
|
+
});
|
|
185
|
+
export const BoxPropsSchema = z.object({
|
|
186
|
+
style: VisionStyleSchema.optional(),
|
|
187
|
+
children: z.lazy(() => z.array(VisionComponentNodeSchema)).optional(),
|
|
188
|
+
});
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
// Zod schema – VisionComponentNode (recursive)
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
export const VisionComponentNodeSchema = z.lazy(() => z.object({
|
|
193
|
+
_id: z.string(),
|
|
194
|
+
type: z.nativeEnum(VisionComponentType),
|
|
195
|
+
props: z.record(z.unknown()),
|
|
196
|
+
children: z.array(VisionComponentNodeSchema),
|
|
197
|
+
}));
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export type JsonRpcRequest = {
|
|
3
|
+
jsonrpc: "2.0";
|
|
4
|
+
id: string;
|
|
5
|
+
method: string;
|
|
6
|
+
params?: unknown;
|
|
7
|
+
};
|
|
8
|
+
export type JsonRpcResponse = {
|
|
9
|
+
jsonrpc: "2.0";
|
|
10
|
+
id: string;
|
|
11
|
+
result?: unknown;
|
|
12
|
+
error?: {
|
|
13
|
+
code: number;
|
|
14
|
+
message: string;
|
|
15
|
+
data?: unknown;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type JsonRpcNotification = {
|
|
19
|
+
jsonrpc: "2.0";
|
|
20
|
+
method: string;
|
|
21
|
+
params?: unknown;
|
|
22
|
+
};
|
|
23
|
+
export type JsonRpcMessage = JsonRpcRequest | JsonRpcResponse | JsonRpcNotification;
|
|
24
|
+
export type UIRenderNotification = {
|
|
25
|
+
jsonrpc: "2.0";
|
|
26
|
+
method: "ui.render";
|
|
27
|
+
params: {
|
|
28
|
+
tree: import("../components/index.js").VisionComponentNode[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export type UIReadyNotification = {
|
|
32
|
+
jsonrpc: "2.0";
|
|
33
|
+
method: "ui.ready";
|
|
34
|
+
};
|
|
35
|
+
export type StorageGetRequest = {
|
|
36
|
+
jsonrpc: "2.0";
|
|
37
|
+
id: string;
|
|
38
|
+
method: "storage.get";
|
|
39
|
+
params: {
|
|
40
|
+
keys?: string[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type StorageSetRequest = {
|
|
44
|
+
jsonrpc: "2.0";
|
|
45
|
+
id: string;
|
|
46
|
+
method: "storage.set";
|
|
47
|
+
params: {
|
|
48
|
+
data: Record<string, unknown>;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
export type EventCallbackNotification = {
|
|
52
|
+
jsonrpc: "2.0";
|
|
53
|
+
method: "event.callback";
|
|
54
|
+
params: {
|
|
55
|
+
handlerId: string;
|
|
56
|
+
args: unknown[];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
export type LifecycleInitRequest = {
|
|
60
|
+
jsonrpc: "2.0";
|
|
61
|
+
id: string;
|
|
62
|
+
method: "lifecycle.init";
|
|
63
|
+
params: {
|
|
64
|
+
extensionId: string;
|
|
65
|
+
target: "editor" | "layer" | "interactive";
|
|
66
|
+
overlayId: string;
|
|
67
|
+
storage: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export type LifecycleDestroyNotification = {
|
|
71
|
+
jsonrpc: "2.0";
|
|
72
|
+
method: "lifecycle.destroy";
|
|
73
|
+
};
|
|
74
|
+
export type StorageUpdateNotification = {
|
|
75
|
+
jsonrpc: "2.0";
|
|
76
|
+
method: "storage.update";
|
|
77
|
+
params: {
|
|
78
|
+
storage: Record<string, unknown>;
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export type SandboxToHostMessage = UIRenderNotification | UIReadyNotification | StorageGetRequest | StorageSetRequest;
|
|
82
|
+
export type HostToSandboxMessage = EventCallbackNotification | LifecycleInitRequest | LifecycleDestroyNotification | StorageUpdateNotification;
|
|
83
|
+
export declare const JsonRpcRequestSchema: z.ZodObject<{
|
|
84
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
method: z.ZodString;
|
|
87
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
jsonrpc: "2.0";
|
|
90
|
+
id: string;
|
|
91
|
+
method: string;
|
|
92
|
+
params?: unknown;
|
|
93
|
+
}, {
|
|
94
|
+
jsonrpc: "2.0";
|
|
95
|
+
id: string;
|
|
96
|
+
method: string;
|
|
97
|
+
params?: unknown;
|
|
98
|
+
}>;
|
|
99
|
+
export declare const JsonRpcResponseSchema: z.ZodObject<{
|
|
100
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
101
|
+
id: z.ZodString;
|
|
102
|
+
result: z.ZodOptional<z.ZodUnknown>;
|
|
103
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
104
|
+
code: z.ZodNumber;
|
|
105
|
+
message: z.ZodString;
|
|
106
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
107
|
+
}, "strip", z.ZodTypeAny, {
|
|
108
|
+
code: number;
|
|
109
|
+
message: string;
|
|
110
|
+
data?: unknown;
|
|
111
|
+
}, {
|
|
112
|
+
code: number;
|
|
113
|
+
message: string;
|
|
114
|
+
data?: unknown;
|
|
115
|
+
}>>;
|
|
116
|
+
}, "strip", z.ZodTypeAny, {
|
|
117
|
+
jsonrpc: "2.0";
|
|
118
|
+
id: string;
|
|
119
|
+
result?: unknown;
|
|
120
|
+
error?: {
|
|
121
|
+
code: number;
|
|
122
|
+
message: string;
|
|
123
|
+
data?: unknown;
|
|
124
|
+
} | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
jsonrpc: "2.0";
|
|
127
|
+
id: string;
|
|
128
|
+
result?: unknown;
|
|
129
|
+
error?: {
|
|
130
|
+
code: number;
|
|
131
|
+
message: string;
|
|
132
|
+
data?: unknown;
|
|
133
|
+
} | undefined;
|
|
134
|
+
}>;
|
|
135
|
+
export declare const JsonRpcNotificationSchema: z.ZodObject<{
|
|
136
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
137
|
+
method: z.ZodString;
|
|
138
|
+
params: z.ZodOptional<z.ZodUnknown>;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
jsonrpc: "2.0";
|
|
141
|
+
method: string;
|
|
142
|
+
params?: unknown;
|
|
143
|
+
}, {
|
|
144
|
+
jsonrpc: "2.0";
|
|
145
|
+
method: string;
|
|
146
|
+
params?: unknown;
|
|
147
|
+
}>;
|
|
148
|
+
export declare const UIRenderNotificationSchema: z.ZodObject<{
|
|
149
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
150
|
+
method: z.ZodLiteral<"ui.render">;
|
|
151
|
+
params: z.ZodObject<{
|
|
152
|
+
tree: z.ZodArray<z.ZodType<import("..").VisionComponentNode, z.ZodTypeDef, import("..").VisionComponentNode>, "many">;
|
|
153
|
+
}, "strip", z.ZodTypeAny, {
|
|
154
|
+
tree: import("..").VisionComponentNode[];
|
|
155
|
+
}, {
|
|
156
|
+
tree: import("..").VisionComponentNode[];
|
|
157
|
+
}>;
|
|
158
|
+
}, "strip", z.ZodTypeAny, {
|
|
159
|
+
params: {
|
|
160
|
+
tree: import("..").VisionComponentNode[];
|
|
161
|
+
};
|
|
162
|
+
jsonrpc: "2.0";
|
|
163
|
+
method: "ui.render";
|
|
164
|
+
}, {
|
|
165
|
+
params: {
|
|
166
|
+
tree: import("..").VisionComponentNode[];
|
|
167
|
+
};
|
|
168
|
+
jsonrpc: "2.0";
|
|
169
|
+
method: "ui.render";
|
|
170
|
+
}>;
|
|
171
|
+
export declare const UIReadyNotificationSchema: z.ZodObject<{
|
|
172
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
173
|
+
method: z.ZodLiteral<"ui.ready">;
|
|
174
|
+
}, "strip", z.ZodTypeAny, {
|
|
175
|
+
jsonrpc: "2.0";
|
|
176
|
+
method: "ui.ready";
|
|
177
|
+
}, {
|
|
178
|
+
jsonrpc: "2.0";
|
|
179
|
+
method: "ui.ready";
|
|
180
|
+
}>;
|
|
181
|
+
export declare const StorageGetRequestSchema: z.ZodObject<{
|
|
182
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
183
|
+
id: z.ZodString;
|
|
184
|
+
method: z.ZodLiteral<"storage.get">;
|
|
185
|
+
params: z.ZodObject<{
|
|
186
|
+
keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
keys?: string[] | undefined;
|
|
189
|
+
}, {
|
|
190
|
+
keys?: string[] | undefined;
|
|
191
|
+
}>;
|
|
192
|
+
}, "strip", z.ZodTypeAny, {
|
|
193
|
+
params: {
|
|
194
|
+
keys?: string[] | undefined;
|
|
195
|
+
};
|
|
196
|
+
jsonrpc: "2.0";
|
|
197
|
+
id: string;
|
|
198
|
+
method: "storage.get";
|
|
199
|
+
}, {
|
|
200
|
+
params: {
|
|
201
|
+
keys?: string[] | undefined;
|
|
202
|
+
};
|
|
203
|
+
jsonrpc: "2.0";
|
|
204
|
+
id: string;
|
|
205
|
+
method: "storage.get";
|
|
206
|
+
}>;
|
|
207
|
+
export declare const StorageSetRequestSchema: z.ZodObject<{
|
|
208
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
209
|
+
id: z.ZodString;
|
|
210
|
+
method: z.ZodLiteral<"storage.set">;
|
|
211
|
+
params: z.ZodObject<{
|
|
212
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
213
|
+
}, "strip", z.ZodTypeAny, {
|
|
214
|
+
data: Record<string, unknown>;
|
|
215
|
+
}, {
|
|
216
|
+
data: Record<string, unknown>;
|
|
217
|
+
}>;
|
|
218
|
+
}, "strip", z.ZodTypeAny, {
|
|
219
|
+
params: {
|
|
220
|
+
data: Record<string, unknown>;
|
|
221
|
+
};
|
|
222
|
+
jsonrpc: "2.0";
|
|
223
|
+
id: string;
|
|
224
|
+
method: "storage.set";
|
|
225
|
+
}, {
|
|
226
|
+
params: {
|
|
227
|
+
data: Record<string, unknown>;
|
|
228
|
+
};
|
|
229
|
+
jsonrpc: "2.0";
|
|
230
|
+
id: string;
|
|
231
|
+
method: "storage.set";
|
|
232
|
+
}>;
|
|
233
|
+
export declare const EventCallbackNotificationSchema: z.ZodObject<{
|
|
234
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
235
|
+
method: z.ZodLiteral<"event.callback">;
|
|
236
|
+
params: z.ZodObject<{
|
|
237
|
+
handlerId: z.ZodString;
|
|
238
|
+
args: z.ZodArray<z.ZodUnknown, "many">;
|
|
239
|
+
}, "strip", z.ZodTypeAny, {
|
|
240
|
+
handlerId: string;
|
|
241
|
+
args: unknown[];
|
|
242
|
+
}, {
|
|
243
|
+
handlerId: string;
|
|
244
|
+
args: unknown[];
|
|
245
|
+
}>;
|
|
246
|
+
}, "strip", z.ZodTypeAny, {
|
|
247
|
+
params: {
|
|
248
|
+
handlerId: string;
|
|
249
|
+
args: unknown[];
|
|
250
|
+
};
|
|
251
|
+
jsonrpc: "2.0";
|
|
252
|
+
method: "event.callback";
|
|
253
|
+
}, {
|
|
254
|
+
params: {
|
|
255
|
+
handlerId: string;
|
|
256
|
+
args: unknown[];
|
|
257
|
+
};
|
|
258
|
+
jsonrpc: "2.0";
|
|
259
|
+
method: "event.callback";
|
|
260
|
+
}>;
|
|
261
|
+
export declare const LifecycleInitRequestSchema: z.ZodObject<{
|
|
262
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
263
|
+
id: z.ZodString;
|
|
264
|
+
method: z.ZodLiteral<"lifecycle.init">;
|
|
265
|
+
params: z.ZodObject<{
|
|
266
|
+
extensionId: z.ZodString;
|
|
267
|
+
target: z.ZodEnum<["editor", "layer", "interactive"]>;
|
|
268
|
+
overlayId: z.ZodString;
|
|
269
|
+
storage: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
270
|
+
}, "strip", z.ZodTypeAny, {
|
|
271
|
+
extensionId: string;
|
|
272
|
+
target: "editor" | "layer" | "interactive";
|
|
273
|
+
overlayId: string;
|
|
274
|
+
storage: Record<string, unknown>;
|
|
275
|
+
}, {
|
|
276
|
+
extensionId: string;
|
|
277
|
+
target: "editor" | "layer" | "interactive";
|
|
278
|
+
overlayId: string;
|
|
279
|
+
storage: Record<string, unknown>;
|
|
280
|
+
}>;
|
|
281
|
+
}, "strip", z.ZodTypeAny, {
|
|
282
|
+
params: {
|
|
283
|
+
extensionId: string;
|
|
284
|
+
target: "editor" | "layer" | "interactive";
|
|
285
|
+
overlayId: string;
|
|
286
|
+
storage: Record<string, unknown>;
|
|
287
|
+
};
|
|
288
|
+
jsonrpc: "2.0";
|
|
289
|
+
id: string;
|
|
290
|
+
method: "lifecycle.init";
|
|
291
|
+
}, {
|
|
292
|
+
params: {
|
|
293
|
+
extensionId: string;
|
|
294
|
+
target: "editor" | "layer" | "interactive";
|
|
295
|
+
overlayId: string;
|
|
296
|
+
storage: Record<string, unknown>;
|
|
297
|
+
};
|
|
298
|
+
jsonrpc: "2.0";
|
|
299
|
+
id: string;
|
|
300
|
+
method: "lifecycle.init";
|
|
301
|
+
}>;
|
|
302
|
+
export declare const LifecycleDestroyNotificationSchema: z.ZodObject<{
|
|
303
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
304
|
+
method: z.ZodLiteral<"lifecycle.destroy">;
|
|
305
|
+
}, "strip", z.ZodTypeAny, {
|
|
306
|
+
jsonrpc: "2.0";
|
|
307
|
+
method: "lifecycle.destroy";
|
|
308
|
+
}, {
|
|
309
|
+
jsonrpc: "2.0";
|
|
310
|
+
method: "lifecycle.destroy";
|
|
311
|
+
}>;
|
|
312
|
+
export declare const StorageUpdateNotificationSchema: z.ZodObject<{
|
|
313
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
314
|
+
method: z.ZodLiteral<"storage.update">;
|
|
315
|
+
params: z.ZodObject<{
|
|
316
|
+
storage: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
317
|
+
}, "strip", z.ZodTypeAny, {
|
|
318
|
+
storage: Record<string, unknown>;
|
|
319
|
+
}, {
|
|
320
|
+
storage: Record<string, unknown>;
|
|
321
|
+
}>;
|
|
322
|
+
}, "strip", z.ZodTypeAny, {
|
|
323
|
+
params: {
|
|
324
|
+
storage: Record<string, unknown>;
|
|
325
|
+
};
|
|
326
|
+
jsonrpc: "2.0";
|
|
327
|
+
method: "storage.update";
|
|
328
|
+
}, {
|
|
329
|
+
params: {
|
|
330
|
+
storage: Record<string, unknown>;
|
|
331
|
+
};
|
|
332
|
+
jsonrpc: "2.0";
|
|
333
|
+
method: "storage.update";
|
|
334
|
+
}>;
|
|
335
|
+
export declare const SandboxToHostMessageSchema: z.ZodDiscriminatedUnion<"method", [z.ZodObject<{
|
|
336
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
337
|
+
method: z.ZodLiteral<"ui.render">;
|
|
338
|
+
params: z.ZodObject<{
|
|
339
|
+
tree: z.ZodArray<z.ZodType<import("..").VisionComponentNode, z.ZodTypeDef, import("..").VisionComponentNode>, "many">;
|
|
340
|
+
}, "strip", z.ZodTypeAny, {
|
|
341
|
+
tree: import("..").VisionComponentNode[];
|
|
342
|
+
}, {
|
|
343
|
+
tree: import("..").VisionComponentNode[];
|
|
344
|
+
}>;
|
|
345
|
+
}, "strip", z.ZodTypeAny, {
|
|
346
|
+
params: {
|
|
347
|
+
tree: import("..").VisionComponentNode[];
|
|
348
|
+
};
|
|
349
|
+
jsonrpc: "2.0";
|
|
350
|
+
method: "ui.render";
|
|
351
|
+
}, {
|
|
352
|
+
params: {
|
|
353
|
+
tree: import("..").VisionComponentNode[];
|
|
354
|
+
};
|
|
355
|
+
jsonrpc: "2.0";
|
|
356
|
+
method: "ui.render";
|
|
357
|
+
}>, z.ZodObject<{
|
|
358
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
359
|
+
method: z.ZodLiteral<"ui.ready">;
|
|
360
|
+
}, "strip", z.ZodTypeAny, {
|
|
361
|
+
jsonrpc: "2.0";
|
|
362
|
+
method: "ui.ready";
|
|
363
|
+
}, {
|
|
364
|
+
jsonrpc: "2.0";
|
|
365
|
+
method: "ui.ready";
|
|
366
|
+
}>, z.ZodObject<{
|
|
367
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
368
|
+
id: z.ZodString;
|
|
369
|
+
method: z.ZodLiteral<"storage.get">;
|
|
370
|
+
params: z.ZodObject<{
|
|
371
|
+
keys: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
372
|
+
}, "strip", z.ZodTypeAny, {
|
|
373
|
+
keys?: string[] | undefined;
|
|
374
|
+
}, {
|
|
375
|
+
keys?: string[] | undefined;
|
|
376
|
+
}>;
|
|
377
|
+
}, "strip", z.ZodTypeAny, {
|
|
378
|
+
params: {
|
|
379
|
+
keys?: string[] | undefined;
|
|
380
|
+
};
|
|
381
|
+
jsonrpc: "2.0";
|
|
382
|
+
id: string;
|
|
383
|
+
method: "storage.get";
|
|
384
|
+
}, {
|
|
385
|
+
params: {
|
|
386
|
+
keys?: string[] | undefined;
|
|
387
|
+
};
|
|
388
|
+
jsonrpc: "2.0";
|
|
389
|
+
id: string;
|
|
390
|
+
method: "storage.get";
|
|
391
|
+
}>, z.ZodObject<{
|
|
392
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
393
|
+
id: z.ZodString;
|
|
394
|
+
method: z.ZodLiteral<"storage.set">;
|
|
395
|
+
params: z.ZodObject<{
|
|
396
|
+
data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
397
|
+
}, "strip", z.ZodTypeAny, {
|
|
398
|
+
data: Record<string, unknown>;
|
|
399
|
+
}, {
|
|
400
|
+
data: Record<string, unknown>;
|
|
401
|
+
}>;
|
|
402
|
+
}, "strip", z.ZodTypeAny, {
|
|
403
|
+
params: {
|
|
404
|
+
data: Record<string, unknown>;
|
|
405
|
+
};
|
|
406
|
+
jsonrpc: "2.0";
|
|
407
|
+
id: string;
|
|
408
|
+
method: "storage.set";
|
|
409
|
+
}, {
|
|
410
|
+
params: {
|
|
411
|
+
data: Record<string, unknown>;
|
|
412
|
+
};
|
|
413
|
+
jsonrpc: "2.0";
|
|
414
|
+
id: string;
|
|
415
|
+
method: "storage.set";
|
|
416
|
+
}>]>;
|
|
417
|
+
export declare const HostToSandboxMessageSchema: z.ZodDiscriminatedUnion<"method", [z.ZodObject<{
|
|
418
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
419
|
+
method: z.ZodLiteral<"event.callback">;
|
|
420
|
+
params: z.ZodObject<{
|
|
421
|
+
handlerId: z.ZodString;
|
|
422
|
+
args: z.ZodArray<z.ZodUnknown, "many">;
|
|
423
|
+
}, "strip", z.ZodTypeAny, {
|
|
424
|
+
handlerId: string;
|
|
425
|
+
args: unknown[];
|
|
426
|
+
}, {
|
|
427
|
+
handlerId: string;
|
|
428
|
+
args: unknown[];
|
|
429
|
+
}>;
|
|
430
|
+
}, "strip", z.ZodTypeAny, {
|
|
431
|
+
params: {
|
|
432
|
+
handlerId: string;
|
|
433
|
+
args: unknown[];
|
|
434
|
+
};
|
|
435
|
+
jsonrpc: "2.0";
|
|
436
|
+
method: "event.callback";
|
|
437
|
+
}, {
|
|
438
|
+
params: {
|
|
439
|
+
handlerId: string;
|
|
440
|
+
args: unknown[];
|
|
441
|
+
};
|
|
442
|
+
jsonrpc: "2.0";
|
|
443
|
+
method: "event.callback";
|
|
444
|
+
}>, z.ZodObject<{
|
|
445
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
446
|
+
id: z.ZodString;
|
|
447
|
+
method: z.ZodLiteral<"lifecycle.init">;
|
|
448
|
+
params: z.ZodObject<{
|
|
449
|
+
extensionId: z.ZodString;
|
|
450
|
+
target: z.ZodEnum<["editor", "layer", "interactive"]>;
|
|
451
|
+
overlayId: z.ZodString;
|
|
452
|
+
storage: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
453
|
+
}, "strip", z.ZodTypeAny, {
|
|
454
|
+
extensionId: string;
|
|
455
|
+
target: "editor" | "layer" | "interactive";
|
|
456
|
+
overlayId: string;
|
|
457
|
+
storage: Record<string, unknown>;
|
|
458
|
+
}, {
|
|
459
|
+
extensionId: string;
|
|
460
|
+
target: "editor" | "layer" | "interactive";
|
|
461
|
+
overlayId: string;
|
|
462
|
+
storage: Record<string, unknown>;
|
|
463
|
+
}>;
|
|
464
|
+
}, "strip", z.ZodTypeAny, {
|
|
465
|
+
params: {
|
|
466
|
+
extensionId: string;
|
|
467
|
+
target: "editor" | "layer" | "interactive";
|
|
468
|
+
overlayId: string;
|
|
469
|
+
storage: Record<string, unknown>;
|
|
470
|
+
};
|
|
471
|
+
jsonrpc: "2.0";
|
|
472
|
+
id: string;
|
|
473
|
+
method: "lifecycle.init";
|
|
474
|
+
}, {
|
|
475
|
+
params: {
|
|
476
|
+
extensionId: string;
|
|
477
|
+
target: "editor" | "layer" | "interactive";
|
|
478
|
+
overlayId: string;
|
|
479
|
+
storage: Record<string, unknown>;
|
|
480
|
+
};
|
|
481
|
+
jsonrpc: "2.0";
|
|
482
|
+
id: string;
|
|
483
|
+
method: "lifecycle.init";
|
|
484
|
+
}>, z.ZodObject<{
|
|
485
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
486
|
+
method: z.ZodLiteral<"lifecycle.destroy">;
|
|
487
|
+
}, "strip", z.ZodTypeAny, {
|
|
488
|
+
jsonrpc: "2.0";
|
|
489
|
+
method: "lifecycle.destroy";
|
|
490
|
+
}, {
|
|
491
|
+
jsonrpc: "2.0";
|
|
492
|
+
method: "lifecycle.destroy";
|
|
493
|
+
}>, z.ZodObject<{
|
|
494
|
+
jsonrpc: z.ZodLiteral<"2.0">;
|
|
495
|
+
method: z.ZodLiteral<"storage.update">;
|
|
496
|
+
params: z.ZodObject<{
|
|
497
|
+
storage: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
498
|
+
}, "strip", z.ZodTypeAny, {
|
|
499
|
+
storage: Record<string, unknown>;
|
|
500
|
+
}, {
|
|
501
|
+
storage: Record<string, unknown>;
|
|
502
|
+
}>;
|
|
503
|
+
}, "strip", z.ZodTypeAny, {
|
|
504
|
+
params: {
|
|
505
|
+
storage: Record<string, unknown>;
|
|
506
|
+
};
|
|
507
|
+
jsonrpc: "2.0";
|
|
508
|
+
method: "storage.update";
|
|
509
|
+
}, {
|
|
510
|
+
params: {
|
|
511
|
+
storage: Record<string, unknown>;
|
|
512
|
+
};
|
|
513
|
+
jsonrpc: "2.0";
|
|
514
|
+
method: "storage.update";
|
|
515
|
+
}>]>;
|
|
516
|
+
export declare function parseSandboxToHostMessage(data: unknown): SandboxToHostMessage;
|
|
517
|
+
export declare function parseHostToSandboxMessage(data: unknown): HostToSandboxMessage;
|
|
518
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,KAAK,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,eAAe,GAAG,mBAAmB,CAAC;AAMpF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,WAAW,CAAC;IACpB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKrC,CAAC;AAEH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAKrC,CAAC;AAMH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,OAAO,GAAG,oBAAoB,CAE7E;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,OAAO,GAAG,oBAAoB,CAE7E"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { VisionComponentNodeSchema } from "../components/index";
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Zod schemas – base envelopes
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
export const JsonRpcRequestSchema = z.object({
|
|
7
|
+
jsonrpc: z.literal("2.0"),
|
|
8
|
+
id: z.string(),
|
|
9
|
+
method: z.string(),
|
|
10
|
+
params: z.unknown().optional(),
|
|
11
|
+
});
|
|
12
|
+
export const JsonRpcResponseSchema = z.object({
|
|
13
|
+
jsonrpc: z.literal("2.0"),
|
|
14
|
+
id: z.string(),
|
|
15
|
+
result: z.unknown().optional(),
|
|
16
|
+
error: z
|
|
17
|
+
.object({
|
|
18
|
+
code: z.number(),
|
|
19
|
+
message: z.string(),
|
|
20
|
+
data: z.unknown().optional(),
|
|
21
|
+
})
|
|
22
|
+
.optional(),
|
|
23
|
+
});
|
|
24
|
+
export const JsonRpcNotificationSchema = z.object({
|
|
25
|
+
jsonrpc: z.literal("2.0"),
|
|
26
|
+
method: z.string(),
|
|
27
|
+
params: z.unknown().optional(),
|
|
28
|
+
});
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Zod schemas – Sandbox → Host
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
export const UIRenderNotificationSchema = z.object({
|
|
33
|
+
jsonrpc: z.literal("2.0"),
|
|
34
|
+
method: z.literal("ui.render"),
|
|
35
|
+
params: z.object({
|
|
36
|
+
tree: z.array(VisionComponentNodeSchema),
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
export const UIReadyNotificationSchema = z.object({
|
|
40
|
+
jsonrpc: z.literal("2.0"),
|
|
41
|
+
method: z.literal("ui.ready"),
|
|
42
|
+
});
|
|
43
|
+
export const StorageGetRequestSchema = z.object({
|
|
44
|
+
jsonrpc: z.literal("2.0"),
|
|
45
|
+
id: z.string(),
|
|
46
|
+
method: z.literal("storage.get"),
|
|
47
|
+
params: z.object({
|
|
48
|
+
keys: z.array(z.string()).optional(),
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
export const StorageSetRequestSchema = z.object({
|
|
52
|
+
jsonrpc: z.literal("2.0"),
|
|
53
|
+
id: z.string(),
|
|
54
|
+
method: z.literal("storage.set"),
|
|
55
|
+
params: z.object({
|
|
56
|
+
data: z.record(z.unknown()),
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// Zod schemas – Host → Sandbox
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
export const EventCallbackNotificationSchema = z.object({
|
|
63
|
+
jsonrpc: z.literal("2.0"),
|
|
64
|
+
method: z.literal("event.callback"),
|
|
65
|
+
params: z.object({
|
|
66
|
+
handlerId: z.string(),
|
|
67
|
+
args: z.array(z.unknown()),
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
export const LifecycleInitRequestSchema = z.object({
|
|
71
|
+
jsonrpc: z.literal("2.0"),
|
|
72
|
+
id: z.string(),
|
|
73
|
+
method: z.literal("lifecycle.init"),
|
|
74
|
+
params: z.object({
|
|
75
|
+
extensionId: z.string(),
|
|
76
|
+
target: z.enum(["editor", "layer", "interactive"]),
|
|
77
|
+
overlayId: z.string(),
|
|
78
|
+
storage: z.record(z.unknown()),
|
|
79
|
+
}),
|
|
80
|
+
});
|
|
81
|
+
export const LifecycleDestroyNotificationSchema = z.object({
|
|
82
|
+
jsonrpc: z.literal("2.0"),
|
|
83
|
+
method: z.literal("lifecycle.destroy"),
|
|
84
|
+
});
|
|
85
|
+
export const StorageUpdateNotificationSchema = z.object({
|
|
86
|
+
jsonrpc: z.literal("2.0"),
|
|
87
|
+
method: z.literal("storage.update"),
|
|
88
|
+
params: z.object({
|
|
89
|
+
storage: z.record(z.unknown()),
|
|
90
|
+
}),
|
|
91
|
+
});
|
|
92
|
+
// ---------------------------------------------------------------------------
|
|
93
|
+
// Discriminated union schemas
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
export const SandboxToHostMessageSchema = z.discriminatedUnion("method", [
|
|
96
|
+
UIRenderNotificationSchema,
|
|
97
|
+
UIReadyNotificationSchema,
|
|
98
|
+
StorageGetRequestSchema,
|
|
99
|
+
StorageSetRequestSchema,
|
|
100
|
+
]);
|
|
101
|
+
export const HostToSandboxMessageSchema = z.discriminatedUnion("method", [
|
|
102
|
+
EventCallbackNotificationSchema,
|
|
103
|
+
LifecycleInitRequestSchema,
|
|
104
|
+
LifecycleDestroyNotificationSchema,
|
|
105
|
+
StorageUpdateNotificationSchema,
|
|
106
|
+
]);
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
// Parsers
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
export function parseSandboxToHostMessage(data) {
|
|
111
|
+
return SandboxToHostMessageSchema.parse(data);
|
|
112
|
+
}
|
|
113
|
+
export function parseHostToSandboxMessage(data) {
|
|
114
|
+
return HostToSandboxMessageSchema.parse(data);
|
|
115
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@1upvision/protocol",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Wire protocol types and Zod schemas for the Vision extension platform",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"zod": "^3.23.8"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.8.3",
|
|
22
|
+
"@vision/tsconfig": "0.0.0"
|
|
23
|
+
},
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc --project tsconfig.build.json",
|
|
29
|
+
"typecheck": "tsc --noEmit"
|
|
30
|
+
}
|
|
31
|
+
}
|