@10up/block-renderer-block-schemas 0.1.4

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.
@@ -0,0 +1,285 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Helper to check if a support is enabled.
4
+ */
5
+ function isEnabled(support) {
6
+ if (support === undefined)
7
+ return false;
8
+ if (typeof support === 'boolean')
9
+ return support;
10
+ return true; // Object means enabled with options
11
+ }
12
+ /**
13
+ * Helper to get support options or empty object.
14
+ */
15
+ function getOptions(support) {
16
+ if (typeof support === 'object')
17
+ return support;
18
+ return {};
19
+ }
20
+ /**
21
+ * Resolves block supports configuration to generated attribute definitions.
22
+ * This maps the `supports` object in block.json to actual attributes.
23
+ */
24
+ export function resolveSupportsToAttributes(supports) {
25
+ if (!supports)
26
+ return {};
27
+ const attributes = {};
28
+ // Anchor support -> anchor attribute
29
+ if (isEnabled(supports.anchor)) {
30
+ attributes.anchor = { type: 'string' };
31
+ }
32
+ // Align support -> align attribute
33
+ if (supports.align) {
34
+ if (Array.isArray(supports.align)) {
35
+ attributes.align = {
36
+ type: 'string',
37
+ enum: supports.align
38
+ };
39
+ }
40
+ else if (supports.align === true) {
41
+ attributes.align = {
42
+ type: 'string',
43
+ enum: ['left', 'center', 'right', 'wide', 'full', 'none']
44
+ };
45
+ }
46
+ }
47
+ // Color supports
48
+ const colorOptions = getOptions(supports.color);
49
+ if (isEnabled(supports.color)) {
50
+ // Background color
51
+ if (colorOptions.background !== false) {
52
+ attributes.backgroundColor = { type: 'string' };
53
+ }
54
+ // Text color
55
+ if (colorOptions.text !== false) {
56
+ attributes.textColor = { type: 'string' };
57
+ }
58
+ // Gradient
59
+ if (colorOptions.gradients !== false) {
60
+ attributes.gradient = { type: 'string' };
61
+ }
62
+ }
63
+ // Typography supports
64
+ const typographyOptions = getOptions(supports.typography);
65
+ if (isEnabled(supports.typography)) {
66
+ if (typographyOptions.fontSize !== false) {
67
+ attributes.fontSize = { type: 'string' };
68
+ }
69
+ if (typographyOptions.fontFamily || typographyOptions.__experimentalFontFamily) {
70
+ attributes.fontFamily = { type: 'string' };
71
+ }
72
+ }
73
+ // Border supports
74
+ const borderOptions = getOptions(supports.border);
75
+ if (isEnabled(supports.border)) {
76
+ if (borderOptions.color !== false) {
77
+ attributes.borderColor = { type: 'string' };
78
+ }
79
+ }
80
+ // Shadow support
81
+ if (isEnabled(supports.shadow)) {
82
+ attributes.shadow = { type: 'string' };
83
+ }
84
+ return attributes;
85
+ }
86
+ /**
87
+ * Creates a Zod schema for the `style` attribute based on supports.
88
+ */
89
+ export function createStyleSchema(supports) {
90
+ if (!supports) {
91
+ return z.record(z.unknown()).optional();
92
+ }
93
+ const styleShape = {};
94
+ // Color styles
95
+ const colorOptions = getOptions(supports.color);
96
+ if (isEnabled(supports.color)) {
97
+ const colorShape = {};
98
+ if (colorOptions.background !== false) {
99
+ colorShape.background = z.string().optional();
100
+ }
101
+ if (colorOptions.text !== false) {
102
+ colorShape.text = z.string().optional();
103
+ }
104
+ if (colorOptions.gradients !== false) {
105
+ colorShape.gradient = z.string().optional();
106
+ }
107
+ if (colorOptions.link !== false) {
108
+ colorShape.link = z.string().optional();
109
+ }
110
+ if (Object.keys(colorShape).length > 0) {
111
+ styleShape.color = z.object(colorShape).passthrough().optional();
112
+ }
113
+ }
114
+ // Typography styles
115
+ const typographyOptions = getOptions(supports.typography);
116
+ if (isEnabled(supports.typography)) {
117
+ const typographyShape = {};
118
+ if (typographyOptions.fontSize !== false) {
119
+ typographyShape.fontSize = z.string().optional();
120
+ }
121
+ if (typographyOptions.lineHeight !== false) {
122
+ typographyShape.lineHeight = z.string().optional();
123
+ }
124
+ if (typographyOptions.fontFamily || typographyOptions.__experimentalFontFamily) {
125
+ typographyShape.fontFamily = z.string().optional();
126
+ }
127
+ if (typographyOptions.fontStyle || typographyOptions.__experimentalFontStyle) {
128
+ typographyShape.fontStyle = z.string().optional();
129
+ }
130
+ if (typographyOptions.fontWeight || typographyOptions.__experimentalFontWeight) {
131
+ typographyShape.fontWeight = z.string().optional();
132
+ }
133
+ if (typographyOptions.letterSpacing || typographyOptions.__experimentalLetterSpacing) {
134
+ typographyShape.letterSpacing = z.string().optional();
135
+ }
136
+ if (typographyOptions.textDecoration || typographyOptions.__experimentalTextDecoration) {
137
+ typographyShape.textDecoration = z.string().optional();
138
+ }
139
+ if (typographyOptions.textTransform || typographyOptions.__experimentalTextTransform) {
140
+ typographyShape.textTransform = z.string().optional();
141
+ }
142
+ if (typographyOptions.textAlign) {
143
+ typographyShape.textAlign = z.string().optional();
144
+ }
145
+ if (Object.keys(typographyShape).length > 0) {
146
+ styleShape.typography = z.object(typographyShape).passthrough().optional();
147
+ }
148
+ }
149
+ // Spacing styles
150
+ const spacingOptions = getOptions(supports.spacing);
151
+ if (isEnabled(supports.spacing)) {
152
+ const spacingShape = {};
153
+ const sideSchema = z.object({
154
+ top: z.string().optional(),
155
+ right: z.string().optional(),
156
+ bottom: z.string().optional(),
157
+ left: z.string().optional(),
158
+ }).passthrough().optional();
159
+ if (spacingOptions.margin !== false) {
160
+ spacingShape.margin = sideSchema;
161
+ }
162
+ if (spacingOptions.padding !== false) {
163
+ spacingShape.padding = sideSchema;
164
+ }
165
+ if (spacingOptions.blockGap !== false) {
166
+ spacingShape.blockGap = z.union([
167
+ z.string(),
168
+ z.object({
169
+ horizontal: z.string().optional(),
170
+ vertical: z.string().optional(),
171
+ })
172
+ ]).optional();
173
+ }
174
+ if (Object.keys(spacingShape).length > 0) {
175
+ styleShape.spacing = z.object(spacingShape).passthrough().optional();
176
+ }
177
+ }
178
+ // Border styles
179
+ const borderOptions = getOptions(supports.border);
180
+ if (isEnabled(supports.border)) {
181
+ const borderShape = {};
182
+ if (borderOptions.color !== false) {
183
+ borderShape.color = z.string().optional();
184
+ }
185
+ if (borderOptions.radius !== false) {
186
+ borderShape.radius = z.union([
187
+ z.string(),
188
+ z.object({
189
+ topLeft: z.string().optional(),
190
+ topRight: z.string().optional(),
191
+ bottomLeft: z.string().optional(),
192
+ bottomRight: z.string().optional(),
193
+ })
194
+ ]).optional();
195
+ }
196
+ if (borderOptions.style !== false) {
197
+ borderShape.style = z.string().optional();
198
+ }
199
+ if (borderOptions.width !== false) {
200
+ borderShape.width = z.string().optional();
201
+ }
202
+ // Individual sides
203
+ const sideSchema = z.object({
204
+ color: z.string().optional(),
205
+ style: z.string().optional(),
206
+ width: z.string().optional(),
207
+ }).optional();
208
+ borderShape.top = sideSchema;
209
+ borderShape.right = sideSchema;
210
+ borderShape.bottom = sideSchema;
211
+ borderShape.left = sideSchema;
212
+ if (Object.keys(borderShape).length > 0) {
213
+ styleShape.border = z.object(borderShape).passthrough().optional();
214
+ }
215
+ }
216
+ // Dimensions styles
217
+ const dimensionsOptions = getOptions(supports.dimensions);
218
+ if (isEnabled(supports.dimensions)) {
219
+ const dimensionsShape = {};
220
+ if (dimensionsOptions.minHeight !== false) {
221
+ dimensionsShape.minHeight = z.string().optional();
222
+ }
223
+ if (dimensionsOptions.aspectRatio !== false) {
224
+ dimensionsShape.aspectRatio = z.string().optional();
225
+ }
226
+ if (Object.keys(dimensionsShape).length > 0) {
227
+ styleShape.dimensions = z.object(dimensionsShape).passthrough().optional();
228
+ }
229
+ }
230
+ // Position styles
231
+ if (isEnabled(supports.position)) {
232
+ styleShape.position = z.object({
233
+ type: z.enum(['sticky', 'fixed']).optional(),
234
+ top: z.string().optional(),
235
+ }).passthrough().optional();
236
+ }
237
+ // Shadow style
238
+ if (isEnabled(supports.shadow)) {
239
+ styleShape.shadow = z.string().optional();
240
+ }
241
+ // Background styles
242
+ const backgroundOptions = getOptions(supports.background);
243
+ if (isEnabled(supports.background)) {
244
+ const backgroundShape = {};
245
+ if (backgroundOptions.backgroundImage !== false) {
246
+ backgroundShape.backgroundImage = z.object({
247
+ url: z.string().optional(),
248
+ id: z.number().optional(),
249
+ source: z.string().optional(),
250
+ title: z.string().optional(),
251
+ }).optional();
252
+ }
253
+ if (backgroundOptions.backgroundSize !== false) {
254
+ backgroundShape.backgroundPosition = z.string().optional();
255
+ backgroundShape.backgroundSize = z.string().optional();
256
+ backgroundShape.backgroundRepeat = z.string().optional();
257
+ }
258
+ if (Object.keys(backgroundShape).length > 0) {
259
+ styleShape.background = z.object(backgroundShape).passthrough().optional();
260
+ }
261
+ }
262
+ if (Object.keys(styleShape).length === 0) {
263
+ return z.record(z.unknown()).optional();
264
+ }
265
+ return z.object(styleShape).passthrough().optional();
266
+ }
267
+ /**
268
+ * Creates a Zod schema for the `layout` attribute based on supports.
269
+ */
270
+ export function createLayoutSchema(supports) {
271
+ if (!supports?.layout)
272
+ return undefined;
273
+ return z.object({
274
+ type: z.enum(['constrained', 'flex', 'flow', 'grid']).optional(),
275
+ justifyContent: z.string().optional(),
276
+ orientation: z.enum(['horizontal', 'vertical']).optional(),
277
+ flexWrap: z.enum(['wrap', 'nowrap']).optional(),
278
+ verticalAlignment: z.string().optional(),
279
+ contentSize: z.string().optional(),
280
+ wideSize: z.string().optional(),
281
+ columnCount: z.number().optional(),
282
+ minimumColumnWidth: z.string().optional(),
283
+ }).passthrough().optional();
284
+ }
285
+ //# sourceMappingURL=supports-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supports-resolver.js","sourceRoot":"","sources":["../src/supports-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8ExB;;GAEG;AACH,SAAS,SAAS,CAAC,OAAqC;IACtD,IAAI,OAAO,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACxC,IAAI,OAAO,OAAO,KAAK,SAAS;QAAE,OAAO,OAAO,CAAC;IACjD,OAAO,IAAI,CAAC,CAAC,oCAAoC;AACnD,CAAC;AAED;;GAEG;AACH,SAAS,UAAU,CAAmB,OAAgC;IACpE,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAChD,OAAO,EAA2B,CAAC;AACrC,CAAC;AAED;;;GAGG;AACH,MA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AAM,UAAU,kBAAkB,CAChC,QAAmC;IAEnC,IAAI,CAAC,QAAQ,EAAE,MAAM;QAAE,OAAO,SAAS,CAAC;IAExC,OAAO,CAAC,CAAC,MAAM,CAAC;QACd,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE;QAChE,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACrC,WAAW,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC,QAAQ,EAAE;QAC1D,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;QAC/C,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QACxC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC/B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC1C,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { z } from 'zod';
2
+ import type { BlockAttributeDefinition, BlockAttributeType } from '@10up/block-renderer-core';
3
+ /**
4
+ * Maps a WordPress attribute type to a Zod schema.
5
+ */
6
+ export declare function mapTypeToZod(attrType: BlockAttributeType): z.ZodTypeAny;
7
+ /**
8
+ * Creates a union type from multiple WordPress types.
9
+ */
10
+ export declare function createUnionSchema(types: BlockAttributeType[]): z.ZodTypeAny;
11
+ /**
12
+ * Options for converting an attribute to a Zod schema.
13
+ */
14
+ export interface AttributeSchemaOptions {
15
+ /** Whether this attribute is required for the block to render */
16
+ required?: boolean;
17
+ }
18
+ /**
19
+ * Creates a Zod schema from a WordPress attribute definition.
20
+ *
21
+ * @param attr - The attribute definition from block.json
22
+ * @param options - Options for schema generation
23
+ */
24
+ export declare function attributeToZodSchema(attr: BlockAttributeDefinition, options?: AttributeSchemaOptions): z.ZodTypeAny;
25
+ /**
26
+ * Options for building a Zod schema from attributes.
27
+ */
28
+ export interface AttributesSchemaOptions {
29
+ /** List of attribute names that are required for the block to render */
30
+ requiredAttributes?: string[];
31
+ }
32
+ /**
33
+ * Creates a complete Zod schema from a map of attribute definitions.
34
+ *
35
+ * @param attributes - The attribute definitions from block.json
36
+ * @param options - Options for schema generation
37
+ */
38
+ export declare function attributesToZodSchema(attributes: Record<string, BlockAttributeDefinition>, options?: AttributesSchemaOptions): z.ZodObject<z.ZodRawShape>;
39
+ //# sourceMappingURL=type-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-mapper.d.ts","sourceRoot":"","sources":["../src/type-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE9F;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,kBAAkB,GAAG,CAAC,CAAC,UAAU,CAoBvE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,EAAE,GAAG,CAAC,CAAC,UAAU,CAW3E;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,wBAAwB,EAC9B,OAAO,GAAE,sBAA2B,GACnC,CAAC,CAAC,UAAU,CA0Cd;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,wEAAwE;IACxE,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,CAAC,EACpD,OAAO,GAAE,uBAA4B,GACpC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAW5B"}
@@ -0,0 +1,107 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Maps a WordPress attribute type to a Zod schema.
4
+ */
5
+ export function mapTypeToZod(attrType) {
6
+ switch (attrType) {
7
+ case 'string':
8
+ case 'rich-text':
9
+ return z.string();
10
+ case 'number':
11
+ return z.number();
12
+ case 'integer':
13
+ return z.number().int();
14
+ case 'boolean':
15
+ return z.boolean();
16
+ case 'object':
17
+ return z.record(z.unknown());
18
+ case 'array':
19
+ return z.array(z.unknown());
20
+ case 'null':
21
+ return z.null();
22
+ default:
23
+ return z.unknown();
24
+ }
25
+ }
26
+ /**
27
+ * Creates a union type from multiple WordPress types.
28
+ */
29
+ export function createUnionSchema(types) {
30
+ if (types.length === 0) {
31
+ return z.unknown();
32
+ }
33
+ if (types.length === 1) {
34
+ return mapTypeToZod(types[0]);
35
+ }
36
+ const schemas = types.map(mapTypeToZod);
37
+ // Use z.union for 2+ types
38
+ return z.union([schemas[0], schemas[1], ...schemas.slice(2)]);
39
+ }
40
+ /**
41
+ * Creates a Zod schema from a WordPress attribute definition.
42
+ *
43
+ * @param attr - The attribute definition from block.json
44
+ * @param options - Options for schema generation
45
+ */
46
+ export function attributeToZodSchema(attr, options = {}) {
47
+ let schema;
48
+ // Handle enum first (takes precedence over type)
49
+ if (attr.enum && attr.enum.length > 0) {
50
+ // Create enum from values
51
+ const enumValues = attr.enum.map(v => {
52
+ if (typeof v === 'string')
53
+ return z.literal(v);
54
+ if (typeof v === 'number')
55
+ return z.literal(v);
56
+ if (typeof v === 'boolean')
57
+ return z.literal(v);
58
+ return z.literal(v);
59
+ });
60
+ if (enumValues.length === 1) {
61
+ schema = enumValues[0];
62
+ }
63
+ else {
64
+ schema = z.union([enumValues[0], enumValues[1], ...enumValues.slice(2)]);
65
+ }
66
+ }
67
+ else if (attr.type) {
68
+ // Handle single type or union of types
69
+ if (Array.isArray(attr.type)) {
70
+ schema = createUnionSchema(attr.type);
71
+ }
72
+ else {
73
+ schema = mapTypeToZod(attr.type);
74
+ }
75
+ }
76
+ else {
77
+ // No type specified, allow unknown
78
+ schema = z.unknown();
79
+ }
80
+ // Apply default if present
81
+ if (attr.default !== undefined) {
82
+ schema = schema.default(attr.default);
83
+ }
84
+ // Make optional unless explicitly required
85
+ // Required attributes are needed for the block to render meaningful output
86
+ if (!options.required) {
87
+ schema = schema.optional();
88
+ }
89
+ return schema;
90
+ }
91
+ /**
92
+ * Creates a complete Zod schema from a map of attribute definitions.
93
+ *
94
+ * @param attributes - The attribute definitions from block.json
95
+ * @param options - Options for schema generation
96
+ */
97
+ export function attributesToZodSchema(attributes, options = {}) {
98
+ const shape = {};
99
+ const requiredSet = new Set(options.requiredAttributes || []);
100
+ for (const [key, attr] of Object.entries(attributes)) {
101
+ shape[key] = attributeToZodSchema(attr, {
102
+ required: requiredSet.has(key),
103
+ });
104
+ }
105
+ return z.object(shape).passthrough();
106
+ }
107
+ //# sourceMappingURL=type-mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-mapper.js","sourceRoot":"","sources":["../src/type-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAA4B;IACvD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,WAAW;YACd,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO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AC;IACxC,CAAC;IAED,2CAA2C;IAC3C,2EAA2E;IAC3E,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,UAAoD,EACpD,UAAmC,EAAE;IAErC,MAAM,KAAK,GAAkB,EAAE,CAAC;IAChC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IAE9D,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QACrD,KAAK,CAAC,GAAG,CAAC,GAAG,oBAAoB,CAAC,IAAI,EAAE;YACtC,QAAQ,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACvC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@10up/block-renderer-block-schemas",
3
+ "version": "0.1.4",
4
+ "description": "Block.json parser and Zod schema generator for WordPress blocks",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist"
17
+ ],
18
+ "dependencies": {
19
+ "zod": "^3.24.0",
20
+ "@10up/block-renderer-core": "0.1.4"
21
+ },
22
+ "devDependencies": {
23
+ "typescript": "^5.7.0",
24
+ "vitest": "^2.1.0"
25
+ },
26
+ "keywords": [
27
+ "wordpress",
28
+ "blocks",
29
+ "gutenberg",
30
+ "schema",
31
+ "zod"
32
+ ],
33
+ "license": "MIT",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/10up/json-block-renderer",
37
+ "directory": "packages/block-schemas"
38
+ },
39
+ "publishConfig": {
40
+ "access": "public"
41
+ },
42
+ "scripts": {
43
+ "build": "tsc -p tsconfig.build.json",
44
+ "dev": "tsc -p tsconfig.build.json --watch",
45
+ "typecheck": "tsc --noEmit",
46
+ "clean": "rm -rf dist",
47
+ "test": "vitest run",
48
+ "test:watch": "vitest",
49
+ "bench": "vitest bench --run"
50
+ }
51
+ }