@polotno/schema 0.1.6 → 0.3.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/lib/bleed.d.ts +0 -1
- package/lib/bleed.js +0 -1
- package/lib/defaults.d.ts +24 -434
- package/lib/defaults.js +62 -243
- package/lib/design.schema.json +5 -0
- package/lib/errors.d.ts +34 -0
- package/lib/errors.js +22 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/normalize.d.ts +20 -3
- package/lib/normalize.js +192 -44
- package/lib/schema.d.ts +11 -1
- package/lib/schema.js +61 -22
- package/lib/types-parity.d.ts +0 -1
- package/lib/types-parity.js +0 -1
- package/lib/types.d.ts +2 -1
- package/lib/types.js +0 -1
- package/package.json +8 -8
- package/lib/bleed.d.ts.map +0 -1
- package/lib/bleed.js.map +0 -1
- package/lib/constants.d.ts +0 -6
- package/lib/constants.d.ts.map +0 -1
- package/lib/constants.js +0 -61
- package/lib/constants.js.map +0 -1
- package/lib/defaults.d.ts.map +0 -1
- package/lib/defaults.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/migrate.d.ts +0 -6
- package/lib/migrate.d.ts.map +0 -1
- package/lib/migrate.js +0 -58
- package/lib/migrate.js.map +0 -1
- package/lib/normalize.d.ts.map +0 -1
- package/lib/normalize.js.map +0 -1
- package/lib/processors.d.ts +0 -13
- package/lib/processors.d.ts.map +0 -1
- package/lib/processors.js +0 -170
- package/lib/processors.js.map +0 -1
- package/lib/schema.d.ts.map +0 -1
- package/lib/schema.js.map +0 -1
- package/lib/traverse.d.ts +0 -3
- package/lib/traverse.d.ts.map +0 -1
- package/lib/traverse.js +0 -32
- package/lib/traverse.js.map +0 -1
- package/lib/types-parity.d.ts.map +0 -1
- package/lib/types-parity.js.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js.map +0 -1
- package/lib/validate.d.ts +0 -19
- package/lib/validate.d.ts.map +0 -1
- package/lib/validate.js +0 -383
- package/lib/validate.js.map +0 -1
package/lib/defaults.js
CHANGED
|
@@ -1,254 +1,73 @@
|
|
|
1
|
-
// Canonical
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
showInExport: true,
|
|
57
|
-
};
|
|
58
|
-
export const IMAGE_DEFAULTS = {
|
|
59
|
-
...SHAPE_DEFAULTS,
|
|
60
|
-
type: 'image',
|
|
61
|
-
width: 100,
|
|
62
|
-
height: 100,
|
|
63
|
-
src: '',
|
|
64
|
-
cropX: 0,
|
|
65
|
-
cropY: 0,
|
|
66
|
-
cropWidth: 1,
|
|
67
|
-
cropHeight: 1,
|
|
68
|
-
cornerRadius: 0,
|
|
69
|
-
flipX: false,
|
|
70
|
-
flipY: false,
|
|
71
|
-
clipSrc: '',
|
|
72
|
-
borderColor: 'black',
|
|
73
|
-
borderSize: 0,
|
|
74
|
-
keepRatio: false,
|
|
75
|
-
stretchEnabled: false,
|
|
1
|
+
// Canonical text RENDERING defaults — the values every renderer assumes when a
|
|
2
|
+
// field is missing. Single source of truth: the zod text schema builds its
|
|
3
|
+
// `.default()`s from this map, and @polotno/core (`text-types.ts`) applies it
|
|
4
|
+
// to loose, un-normalized elements at render/measure time. zod-free on purpose
|
|
5
|
+
// so runtime consumers can import `@polotno/schema/defaults` without pulling
|
|
6
|
+
// the validator.
|
|
7
|
+
// Table-cell properties that inherit from the table element when a cell
|
|
8
|
+
// leaves them undefined. Shared by the editor's table model and the svg/html
|
|
9
|
+
// exporters so the inheritance vocabulary can't drift. (pdf-export uses a
|
|
10
|
+
// deliberate subset without stroke/strokeWidth — see its table.ts.)
|
|
11
|
+
export const TABLE_CELL_OVERRIDABLE_KEYS = [
|
|
12
|
+
'fontSize',
|
|
13
|
+
'fontFamily',
|
|
14
|
+
'fontWeight',
|
|
15
|
+
'fontStyle',
|
|
16
|
+
'textDecoration',
|
|
17
|
+
'textTransform',
|
|
18
|
+
'fill',
|
|
19
|
+
'align',
|
|
20
|
+
'verticalAlign',
|
|
21
|
+
'lineHeight',
|
|
22
|
+
'letterSpacing',
|
|
23
|
+
'strokeWidth',
|
|
24
|
+
'stroke',
|
|
25
|
+
'cellBackground',
|
|
26
|
+
'cellPadding',
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* Resolve cell inheritance: every overridable text property a cell leaves
|
|
30
|
+
* undefined is filled from the table element (canvas parity — no fallback
|
|
31
|
+
* literals downstream). Returns shallow clones; the input is untouched
|
|
32
|
+
* (source may be frozen JSON).
|
|
33
|
+
*/
|
|
34
|
+
export const resolveTableCellDefaults = (element) => (element.cells || []).map((cell) => {
|
|
35
|
+
if (!cell)
|
|
36
|
+
return cell;
|
|
37
|
+
const c = { ...cell };
|
|
38
|
+
for (const key of TABLE_CELL_OVERRIDABLE_KEYS) {
|
|
39
|
+
if (c[key] === undefined)
|
|
40
|
+
c[key] = element[key];
|
|
41
|
+
}
|
|
42
|
+
return c;
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Per-side border resolution: a cell's `borders[side]` overrides win over
|
|
46
|
+
* the table element's `border{Width,Style,Color}` (canvas table-model
|
|
47
|
+
* parity). Shared by the svg/html/pdf exporters.
|
|
48
|
+
*/
|
|
49
|
+
export const resolveTableCellBorder = (cell, element, side) => {
|
|
50
|
+
const overrides = cell.borders?.[side];
|
|
51
|
+
return {
|
|
52
|
+
width: overrides?.width ?? element.borderWidth,
|
|
53
|
+
style: overrides?.style ?? element.borderStyle,
|
|
54
|
+
color: overrides?.color ?? element.borderColor,
|
|
55
|
+
};
|
|
76
56
|
};
|
|
77
57
|
export const TEXT_DEFAULTS = {
|
|
78
|
-
...SHAPE_DEFAULTS,
|
|
79
|
-
type: 'text',
|
|
80
|
-
text: '',
|
|
81
|
-
placeholder: '',
|
|
82
58
|
fontSize: 14,
|
|
83
59
|
fontFamily: 'Roboto',
|
|
84
|
-
fontStyle: 'normal',
|
|
85
60
|
fontWeight: 'normal',
|
|
86
|
-
|
|
87
|
-
textTransform: 'none',
|
|
88
|
-
fill: 'black',
|
|
89
|
-
align: 'center',
|
|
90
|
-
width: 100,
|
|
91
|
-
height: 0, // afterCreate sets round(fontSize * lineHeight) when falsy
|
|
92
|
-
verticalAlign: 'top',
|
|
93
|
-
strokeWidth: 0,
|
|
94
|
-
stroke: 'black',
|
|
61
|
+
fontStyle: 'normal',
|
|
95
62
|
lineHeight: 1.2,
|
|
96
63
|
letterSpacing: 0,
|
|
97
|
-
backgroundEnabled: false,
|
|
98
|
-
backgroundColor: '#7ED321',
|
|
99
|
-
backgroundOpacity: 1,
|
|
100
|
-
backgroundCornerRadius: 0.5,
|
|
101
|
-
backgroundPadding: 0.5,
|
|
102
|
-
curveEnabled: false,
|
|
103
|
-
curvePower: 0.5,
|
|
104
|
-
};
|
|
105
|
-
export const SVG_DEFAULTS = {
|
|
106
|
-
...SHAPE_DEFAULTS,
|
|
107
|
-
type: 'svg',
|
|
108
|
-
src: '',
|
|
109
|
-
maskSrc: '',
|
|
110
|
-
cropX: 0,
|
|
111
|
-
cropY: 0,
|
|
112
|
-
cropWidth: 1,
|
|
113
|
-
cropHeight: 1,
|
|
114
|
-
keepRatio: true,
|
|
115
|
-
stretchEnabled: true,
|
|
116
|
-
flipX: false,
|
|
117
|
-
flipY: false,
|
|
118
|
-
width: 100,
|
|
119
|
-
height: 100,
|
|
120
|
-
borderColor: 'black',
|
|
121
|
-
borderSize: 0,
|
|
122
|
-
cornerRadius: 0,
|
|
123
|
-
};
|
|
124
|
-
export const LINE_DEFAULTS = {
|
|
125
|
-
...SHAPE_DEFAULTS,
|
|
126
|
-
type: 'line',
|
|
127
|
-
width: 400,
|
|
128
|
-
height: 10,
|
|
129
|
-
color: 'black',
|
|
130
|
-
startHead: '',
|
|
131
|
-
endHead: '',
|
|
132
|
-
};
|
|
133
|
-
export const FIGURE_DEFAULTS = {
|
|
134
|
-
...SHAPE_DEFAULTS,
|
|
135
|
-
type: 'figure',
|
|
136
|
-
subType: 'rect',
|
|
137
|
-
fill: 'rgb(0, 161, 255)',
|
|
138
|
-
strokeWidth: 0,
|
|
139
|
-
stroke: 'rgba(98, 197, 255, 1)',
|
|
140
|
-
cornerRadius: 0,
|
|
141
|
-
};
|
|
142
|
-
export const GIF_DEFAULTS = {
|
|
143
|
-
...IMAGE_DEFAULTS,
|
|
144
|
-
type: 'gif',
|
|
145
|
-
duration: 0,
|
|
146
|
-
keepRatio: true,
|
|
147
|
-
};
|
|
148
|
-
export const VIDEO_DEFAULTS = {
|
|
149
|
-
...IMAGE_DEFAULTS,
|
|
150
|
-
type: 'video',
|
|
151
|
-
duration: 0,
|
|
152
|
-
startTime: 0,
|
|
153
|
-
endTime: 1,
|
|
154
|
-
volume: 1,
|
|
155
|
-
speed: 1,
|
|
156
|
-
};
|
|
157
|
-
// TableElement inherits Shape (so blur/shadow are FILLED then stripped by the
|
|
158
|
-
// table postProcessor — keep them here to match MST's fill-then-strip).
|
|
159
|
-
export const TABLE_DEFAULTS = {
|
|
160
|
-
...SHAPE_DEFAULTS,
|
|
161
|
-
type: 'table',
|
|
162
|
-
width: 300,
|
|
163
|
-
height: 200,
|
|
164
|
-
rows: 3,
|
|
165
|
-
cols: 3,
|
|
166
|
-
borderColor: '#000000',
|
|
167
|
-
borderWidth: 1,
|
|
168
|
-
borderStyle: 'solid',
|
|
169
|
-
fontSize: 30,
|
|
170
|
-
fontFamily: 'Roboto',
|
|
171
|
-
fontWeight: 'normal',
|
|
172
|
-
fontStyle: 'normal',
|
|
173
|
-
textDecoration: '',
|
|
174
64
|
textTransform: 'none',
|
|
175
|
-
|
|
65
|
+
textDecoration: '',
|
|
176
66
|
align: 'center',
|
|
177
|
-
|
|
178
|
-
lineHeight: 1.2,
|
|
179
|
-
letterSpacing: 0,
|
|
180
|
-
strokeWidth: 0,
|
|
67
|
+
fill: 'black',
|
|
181
68
|
stroke: 'black',
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
...NODE_DEFAULTS,
|
|
187
|
-
type: 'group',
|
|
188
|
-
};
|
|
189
|
-
// TableCell direct defaults (overridable `_`-prefixed styling props inherit from
|
|
190
|
-
// the table and are not defaulted here).
|
|
191
|
-
export const TABLE_CELL_DEFAULTS = {
|
|
192
|
-
type: 'tablecell',
|
|
193
|
-
text: '',
|
|
194
|
-
opacity: 1,
|
|
195
|
-
rowSpan: 1,
|
|
196
|
-
colSpan: 1,
|
|
197
|
-
name: '',
|
|
198
|
-
};
|
|
199
|
-
export const PAGE_DEFAULTS = {
|
|
200
|
-
width: 'auto',
|
|
201
|
-
height: 'auto',
|
|
202
|
-
background: 'white',
|
|
203
|
-
bleed: 0,
|
|
204
|
-
duration: 5000,
|
|
205
|
-
};
|
|
206
|
-
export const AUDIO_DEFAULTS = {
|
|
207
|
-
src: '',
|
|
208
|
-
duration: 0,
|
|
209
|
-
startTime: 0,
|
|
210
|
-
endTime: 1,
|
|
211
|
-
volume: 1,
|
|
212
|
-
delay: 0,
|
|
213
|
-
speed: 1,
|
|
214
|
-
};
|
|
215
|
-
export const FONT_DEFAULTS = {
|
|
216
|
-
url: '',
|
|
217
|
-
};
|
|
218
|
-
// Serialized store-level fields (the subset `store.toJSON()` emits).
|
|
219
|
-
export const STORE_DEFAULTS = {
|
|
220
|
-
width: 1080,
|
|
221
|
-
height: 1080,
|
|
222
|
-
unit: 'px',
|
|
223
|
-
dpi: 72,
|
|
224
|
-
schemaVersion: 4,
|
|
225
|
-
};
|
|
226
|
-
export const CURRENT_SCHEMA_VERSION = 4;
|
|
227
|
-
// Maps a built-in element `type` to its default table. Unknown/custom types
|
|
228
|
-
// fall back to SHAPE_DEFAULTS (base normalization + passthrough).
|
|
229
|
-
export const DEFAULTS_BY_TYPE = {
|
|
230
|
-
image: IMAGE_DEFAULTS,
|
|
231
|
-
text: TEXT_DEFAULTS,
|
|
232
|
-
svg: SVG_DEFAULTS,
|
|
233
|
-
line: LINE_DEFAULTS,
|
|
234
|
-
figure: FIGURE_DEFAULTS,
|
|
235
|
-
gif: GIF_DEFAULTS,
|
|
236
|
-
video: VIDEO_DEFAULTS,
|
|
237
|
-
table: TABLE_DEFAULTS,
|
|
238
|
-
group: GROUP_DEFAULTS,
|
|
239
|
-
};
|
|
240
|
-
// Structural (MST-typed) empty defaults per element type — the arrays/maps MST
|
|
241
|
-
// serializes as []/{} (DEFAULTS_BY_TYPE carries only scalars). Single source for
|
|
242
|
-
// both normalize (fills them) and validate (marks them optional in partial mode).
|
|
243
|
-
export const STRUCTURAL_DEFAULTS_BY_TYPE = {
|
|
244
|
-
image: { animations: [], filters: {} },
|
|
245
|
-
text: { animations: [], filters: {} },
|
|
246
|
-
svg: { animations: [], filters: {}, colorsReplace: {} },
|
|
247
|
-
line: { animations: [], filters: {}, dash: [] },
|
|
248
|
-
figure: { animations: [], filters: {}, dash: [] },
|
|
249
|
-
gif: { animations: [], filters: {} },
|
|
250
|
-
video: { animations: [], filters: {} },
|
|
251
|
-
table: { animations: [], filters: {}, colWidths: [], rowHeights: [], cells: [] },
|
|
252
|
-
group: { animations: [], children: [] },
|
|
69
|
+
strokeWidth: 0,
|
|
70
|
+
strokeLineJoin: 'round',
|
|
71
|
+
curveEnabled: false,
|
|
72
|
+
curvePower: 0.5,
|
|
253
73
|
};
|
|
254
|
-
//# sourceMappingURL=defaults.js.map
|
package/lib/design.schema.json
CHANGED
|
@@ -504,6 +504,11 @@
|
|
|
504
504
|
"description": "Stroke color.",
|
|
505
505
|
"type": "string"
|
|
506
506
|
},
|
|
507
|
+
"strokeLineJoin": {
|
|
508
|
+
"default": "round",
|
|
509
|
+
"description": "Stroke corner join: round, miter, bevel.",
|
|
510
|
+
"type": "string"
|
|
511
|
+
},
|
|
507
512
|
"lineHeight": {
|
|
508
513
|
"default": 1.2,
|
|
509
514
|
"description": "Line height multiplier or 'auto'.",
|
package/lib/errors.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured errors, Node.js-style: a plain `Error` with a semver-stable
|
|
3
|
+
* `code` property (branch on it, like `err.code === 'ENOENT'`) and optional
|
|
4
|
+
* JSON-serializable `details`. Messages are for humans and may change in any
|
|
5
|
+
* release — never match on them. No classes, no instanceof — a code check
|
|
6
|
+
* works on any copy of any package. See the error-codes table in the repo
|
|
7
|
+
* root CLAUDE.md.
|
|
8
|
+
*
|
|
9
|
+
* `@polotno/schema` is the layer *below* `@polotno/core`, so it can't import
|
|
10
|
+
* core's shared error map — it defines its own. It only ever throws
|
|
11
|
+
* `DESIGN_INVALID`; the `details` shape here is kept identical to core's entry
|
|
12
|
+
* for that code, so a consumer sees the same fields whichever layer threw it.
|
|
13
|
+
*/
|
|
14
|
+
/** Codes thrown by this package. Append-only. */
|
|
15
|
+
export type PolotnoErrorCode = 'DESIGN_INVALID';
|
|
16
|
+
/** Exhaustive `details` shape per code (only `DESIGN_INVALID` here). */
|
|
17
|
+
export interface PolotnoErrorDetailsMap {
|
|
18
|
+
DESIGN_INVALID: {
|
|
19
|
+
errors: {
|
|
20
|
+
path: string;
|
|
21
|
+
message: string;
|
|
22
|
+
}[];
|
|
23
|
+
/** Recognised element types, when the design references an unknown one. */
|
|
24
|
+
knownTypes?: string[];
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export type PolotnoError<Code extends PolotnoErrorCode = PolotnoErrorCode> = {
|
|
28
|
+
[K in Code]: Error & {
|
|
29
|
+
code: K;
|
|
30
|
+
details?: PolotnoErrorDetailsMap[K];
|
|
31
|
+
cause?: unknown;
|
|
32
|
+
};
|
|
33
|
+
}[Code];
|
|
34
|
+
export declare function polotnoError<Code extends PolotnoErrorCode>(code: Code, message: string, details?: PolotnoErrorDetailsMap[Code], cause?: unknown): PolotnoError<Code>;
|
package/lib/errors.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured errors, Node.js-style: a plain `Error` with a semver-stable
|
|
3
|
+
* `code` property (branch on it, like `err.code === 'ENOENT'`) and optional
|
|
4
|
+
* JSON-serializable `details`. Messages are for humans and may change in any
|
|
5
|
+
* release — never match on them. No classes, no instanceof — a code check
|
|
6
|
+
* works on any copy of any package. See the error-codes table in the repo
|
|
7
|
+
* root CLAUDE.md.
|
|
8
|
+
*
|
|
9
|
+
* `@polotno/schema` is the layer *below* `@polotno/core`, so it can't import
|
|
10
|
+
* core's shared error map — it defines its own. It only ever throws
|
|
11
|
+
* `DESIGN_INVALID`; the `details` shape here is kept identical to core's entry
|
|
12
|
+
* for that code, so a consumer sees the same fields whichever layer threw it.
|
|
13
|
+
*/
|
|
14
|
+
export function polotnoError(code, message, details, cause) {
|
|
15
|
+
const err = new Error(message);
|
|
16
|
+
err.code = code;
|
|
17
|
+
if (details !== undefined)
|
|
18
|
+
err.details = details;
|
|
19
|
+
if (cause !== undefined)
|
|
20
|
+
err.cause = cause;
|
|
21
|
+
return err;
|
|
22
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
export type { PolotnoError, PolotnoErrorCode } from './errors.js';
|
|
1
2
|
export { normalizeDesign, parseDesign } from './normalize.js';
|
|
2
3
|
export type { ParseOptions } from './normalize.js';
|
|
3
4
|
export { resolveBleed, ZERO_BLEED } from './bleed.js';
|
|
4
5
|
export type { ResolvedBleed } from './bleed.js';
|
|
6
|
+
export { TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, } from './defaults.js';
|
|
5
7
|
export { validateDesign, assertValidDesign, designSchemaLenient, designSchemaCanonical, CURRENT_SCHEMA_VERSION, } from './schema.js';
|
|
6
8
|
export type { DesignInput, ValidationError, ValidationResult, ValidateOptions, } from './schema.js';
|
|
7
9
|
export type * from './types.js';
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.js
CHANGED
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
// types. zod is a regular dependency (normalize parses with it).
|
|
5
5
|
export { normalizeDesign, parseDesign } from './normalize.js';
|
|
6
6
|
export { resolveBleed, ZERO_BLEED } from './bleed.js';
|
|
7
|
+
// Also available zod-free via the `@polotno/schema/defaults` subpath.
|
|
8
|
+
export { TEXT_DEFAULTS, TABLE_CELL_OVERRIDABLE_KEYS, resolveTableCellDefaults, resolveTableCellBorder, } from './defaults.js';
|
|
7
9
|
export { validateDesign, assertValidDesign, designSchemaLenient, designSchemaCanonical, CURRENT_SCHEMA_VERSION, } from './schema.js';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/lib/normalize.d.ts
CHANGED
|
@@ -12,10 +12,28 @@ export interface ParseOptions extends ValidateOptions {
|
|
|
12
12
|
* Assign a synthetic `id` to any page/element/cell that lacks one before
|
|
13
13
|
* validating. `id` is otherwise required, but it's identity metadata the
|
|
14
14
|
* renderer doesn't draw, so consumers that accept hand-built JSON (the export
|
|
15
|
-
* converters) stay tolerant.
|
|
16
|
-
*
|
|
15
|
+
* converters) stay tolerant. Ids are DETERMINISTIC (structural index paths
|
|
16
|
+
* like `el-0-2`) so identical input yields identical output. Real
|
|
17
|
+
* `store.toJSON()` output always has ids, so this is a no-op there. Does not
|
|
18
|
+
* touch the caller's input (works on a copy).
|
|
17
19
|
*/
|
|
18
20
|
fillMissingIds?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Editor-export compatibility: preserve client-owned content the way the
|
|
23
|
+
* editor's own SVG/HTML export historically did (it rendered raw JSON).
|
|
24
|
+
* - Elements whose type is outside the schema union (the editor's
|
|
25
|
+
* `registerShapeModel` extensions) skip validation and stay in place —
|
|
26
|
+
* handed through as shallow copies of the CALLER's objects (`id` filled
|
|
27
|
+
* when `fillMissingIds` is set), so they survive to element hooks.
|
|
28
|
+
* Renderers fall back to a placeholder for them.
|
|
29
|
+
* - Unrecognized ad-hoc keys the zod pass strips are copied back onto
|
|
30
|
+
* parsed elements/pages/cells/audios from the caller's input.
|
|
31
|
+
* Schema-recognized keys keep their validated values; `null` stays
|
|
32
|
+
* "unset".
|
|
33
|
+
* - `custom` needs no special handling: it is JSON-like data by contract
|
|
34
|
+
* and the schema keeps it everywhere, so it survives parsing as-is.
|
|
35
|
+
*/
|
|
36
|
+
preserveClientData?: boolean;
|
|
19
37
|
}
|
|
20
38
|
/**
|
|
21
39
|
* The one entry a consumer should use to accept design JSON: validate, then
|
|
@@ -24,4 +42,3 @@ export interface ParseOptions extends ValidateOptions {
|
|
|
24
42
|
* with `assertValidDesign`.
|
|
25
43
|
*/
|
|
26
44
|
export declare function parseDesign(input: unknown, opts?: ParseOptions): Design;
|
|
27
|
-
//# sourceMappingURL=normalize.d.ts.map
|