json2pptx-schema 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/index.mjs ADDED
@@ -0,0 +1,765 @@
1
+ // versions/v1/defaults.ts
2
+ var DEFAULT_SCHEMA_VERSION = "1.0.0";
3
+ var DEFAULT_TITLE = "\u672A\u547D\u540D\u6F14\u793A\u6587\u7A3F";
4
+ var DEFAULT_WIDTH = 1e3;
5
+ var DEFAULT_HEIGHT = 562.5;
6
+ var DEFAULT_THEME_SHADOW = {
7
+ h: 3,
8
+ v: 3,
9
+ blur: 2,
10
+ color: "#808080"
11
+ };
12
+ var DEFAULT_THEME_OUTLINE = {
13
+ width: 2,
14
+ color: "#525252",
15
+ style: "solid"
16
+ };
17
+ var DEFAULT_THEME = {
18
+ themeColors: [],
19
+ fontColor: "#333",
20
+ fontName: "",
21
+ backgroundColor: "#fff",
22
+ shadow: DEFAULT_THEME_SHADOW,
23
+ outline: DEFAULT_THEME_OUTLINE
24
+ };
25
+ var DEFAULT_SLIDE_TYPE = "content";
26
+ var DEFAULT_SLIDE_REMARK = "";
27
+ var DEFAULT_TEXT_COLOR = "#333";
28
+ var DEFAULT_ELEMENT_ROTATE = 0;
29
+ var DEFAULT_IMAGE_FIXED_RATIO = true;
30
+ var DEFAULT_SHAPE_FIXED_RATIO = false;
31
+ var DEFAULT_LINE_STYLE = "solid";
32
+ var DEFAULT_LINE_WIDTH = 2;
33
+ var LEGACY_SLIDE_TYPE_MAP = {
34
+ agenda: "contents",
35
+ section: "transition",
36
+ ending: "end"
37
+ };
38
+ var V1_DEFAULTS = {
39
+ schemaVersion: DEFAULT_SCHEMA_VERSION,
40
+ title: DEFAULT_TITLE,
41
+ width: DEFAULT_WIDTH,
42
+ height: DEFAULT_HEIGHT,
43
+ theme: DEFAULT_THEME
44
+ };
45
+
46
+ // runtime/errors.ts
47
+ var SchemaValidationError = class extends Error {
48
+ constructor(issues, message = "Schema validation failed") {
49
+ super(message);
50
+ this.name = "SchemaValidationError";
51
+ this.issues = issues;
52
+ }
53
+ };
54
+ var UnsupportedSchemaVersionError = class extends Error {
55
+ constructor(receivedVersion, supportedVersion) {
56
+ const received = receivedVersion === void 0 || receivedVersion === null ? void 0 : String(receivedVersion);
57
+ super(
58
+ received ? `Unsupported schema version: ${received}. Supported version: ${supportedVersion}.` : `Unsupported schema version. Supported version: ${supportedVersion}.`
59
+ );
60
+ this.code = "UNSUPPORTED_SCHEMA_VERSION";
61
+ this.name = "UnsupportedSchemaVersionError";
62
+ this.supportedVersion = supportedVersion;
63
+ this.receivedVersion = received;
64
+ }
65
+ };
66
+
67
+ // runtime/migrate.ts
68
+ var V1_VERSION_EQUIVALENTS = /* @__PURE__ */ new Set(["1", "1.0", "1.0.0"]);
69
+ function isRecord(value) {
70
+ return typeof value === "object" && value !== null && !Array.isArray(value);
71
+ }
72
+ function cloneValue(value) {
73
+ if (typeof structuredClone === "function") {
74
+ return structuredClone(value);
75
+ }
76
+ return JSON.parse(JSON.stringify(value));
77
+ }
78
+ function normalizeVersion(value) {
79
+ if (typeof value === "number" && Number.isFinite(value)) {
80
+ if (value === 1) return DEFAULT_SCHEMA_VERSION;
81
+ return null;
82
+ }
83
+ if (typeof value !== "string") return null;
84
+ const trimmed = value.trim();
85
+ if (!trimmed) return null;
86
+ if (V1_VERSION_EQUIVALENTS.has(trimmed)) return DEFAULT_SCHEMA_VERSION;
87
+ return null;
88
+ }
89
+ function migrateSlideType(type) {
90
+ if (typeof type !== "string") return type;
91
+ const normalized = type.trim().toLowerCase();
92
+ return LEGACY_SLIDE_TYPE_MAP[normalized] ?? type;
93
+ }
94
+ function migrateDocument(input, toVersion = DEFAULT_SCHEMA_VERSION) {
95
+ if (!isRecord(input)) return input;
96
+ const migrated = cloneValue(input);
97
+ const incomingVersion = migrated.schemaVersion ?? migrated.version;
98
+ if (incomingVersion === void 0) {
99
+ migrated.schemaVersion = toVersion;
100
+ } else {
101
+ const normalizedVersion = normalizeVersion(incomingVersion);
102
+ if (!normalizedVersion || normalizedVersion !== toVersion) {
103
+ throw new UnsupportedSchemaVersionError(incomingVersion, toVersion);
104
+ }
105
+ migrated.schemaVersion = toVersion;
106
+ }
107
+ delete migrated.version;
108
+ if (isRecord(migrated.theme)) {
109
+ const theme = migrated.theme;
110
+ if (typeof theme.fontname === "string" && theme.fontName === void 0) {
111
+ theme.fontName = theme.fontname;
112
+ delete theme.fontname;
113
+ }
114
+ }
115
+ if (Array.isArray(migrated.slides)) {
116
+ migrated.slides = migrated.slides.map((slide) => {
117
+ if (!isRecord(slide)) return slide;
118
+ const nextSlide = cloneValue(slide);
119
+ nextSlide.type = migrateSlideType(nextSlide.type);
120
+ return nextSlide;
121
+ });
122
+ }
123
+ return migrated;
124
+ }
125
+
126
+ // runtime/normalize.ts
127
+ function isRecord2(value) {
128
+ return typeof value === "object" && value !== null && !Array.isArray(value);
129
+ }
130
+ function cloneValue2(value) {
131
+ if (typeof structuredClone === "function") {
132
+ return structuredClone(value);
133
+ }
134
+ return JSON.parse(JSON.stringify(value));
135
+ }
136
+ function asString(value, fallback) {
137
+ return typeof value === "string" ? value : fallback;
138
+ }
139
+ function asNumber(value, fallback) {
140
+ return typeof value === "number" && Number.isFinite(value) ? value : fallback;
141
+ }
142
+ function asBoolean(value, fallback) {
143
+ return typeof value === "boolean" ? value : fallback;
144
+ }
145
+ function asPair(value, fallback) {
146
+ if (!Array.isArray(value) || value.length < 2) return fallback;
147
+ return [asNumber(value[0], fallback[0]), asNumber(value[1], fallback[1])];
148
+ }
149
+ function asLinePoints(value) {
150
+ if (!Array.isArray(value)) return ["", ""];
151
+ const first = typeof value[0] === "string" ? value[0] : "";
152
+ const second = typeof value[1] === "string" ? value[1] : "";
153
+ return [first, second];
154
+ }
155
+ function normalizeShadow(value) {
156
+ const source = isRecord2(value) ? value : {};
157
+ return {
158
+ ...source,
159
+ h: asNumber(source.h, DEFAULT_THEME_SHADOW.h),
160
+ v: asNumber(source.v, DEFAULT_THEME_SHADOW.v),
161
+ blur: asNumber(source.blur, DEFAULT_THEME_SHADOW.blur),
162
+ color: asString(source.color, DEFAULT_THEME_SHADOW.color)
163
+ };
164
+ }
165
+ function normalizeOutline(value) {
166
+ const source = isRecord2(value) ? value : {};
167
+ return {
168
+ ...source,
169
+ width: asNumber(source.width, DEFAULT_THEME_OUTLINE.width),
170
+ color: asString(source.color, DEFAULT_THEME_OUTLINE.color),
171
+ style: asString(source.style, DEFAULT_THEME_OUTLINE.style)
172
+ };
173
+ }
174
+ function normalizeTheme(value) {
175
+ const source = isRecord2(value) ? value : {};
176
+ const themeColors = Array.isArray(source.themeColors) ? source.themeColors.filter((item) => typeof item === "string") : DEFAULT_THEME.themeColors.slice();
177
+ return {
178
+ ...source,
179
+ themeColors,
180
+ fontColor: asString(source.fontColor, DEFAULT_THEME.fontColor),
181
+ fontName: asString(source.fontName, DEFAULT_THEME.fontName),
182
+ backgroundColor: asString(source.backgroundColor, DEFAULT_THEME.backgroundColor),
183
+ shadow: normalizeShadow(source.shadow),
184
+ outline: normalizeOutline(source.outline)
185
+ };
186
+ }
187
+ function normalizeBackground(value, fallbackColor) {
188
+ if (!isRecord2(value)) return void 0;
189
+ const type = typeof value.type === "string" && value.type.trim().length > 0 ? value.type : "solid";
190
+ const normalized = {
191
+ ...value,
192
+ type
193
+ };
194
+ if (type === "solid" && typeof normalized.color !== "string") {
195
+ normalized.color = fallbackColor;
196
+ }
197
+ return normalized;
198
+ }
199
+ function normalizeElement(value, slideIndex, elementIndex, theme) {
200
+ const fallbackId = `slide-${slideIndex + 1}-element-${elementIndex + 1}`;
201
+ if (!isRecord2(value)) {
202
+ return {
203
+ type: "unknown",
204
+ id: fallbackId,
205
+ left: 0,
206
+ top: 0,
207
+ rotate: DEFAULT_ELEMENT_ROTATE
208
+ };
209
+ }
210
+ const type = typeof value.type === "string" && value.type.trim().length > 0 ? value.type : "unknown";
211
+ const base = {
212
+ ...value,
213
+ type,
214
+ id: asString(value.id, fallbackId),
215
+ left: asNumber(value.left, 0),
216
+ top: asNumber(value.top, 0),
217
+ rotate: asNumber(value.rotate, DEFAULT_ELEMENT_ROTATE)
218
+ };
219
+ if (type === "text") {
220
+ const textElement = {
221
+ ...base,
222
+ type: "text",
223
+ width: asNumber(value.width, 0),
224
+ height: asNumber(value.height, 0),
225
+ content: asString(value.content, ""),
226
+ defaultColor: asString(value.defaultColor, theme.fontColor || DEFAULT_TEXT_COLOR),
227
+ defaultFontName: asString(value.defaultFontName, theme.fontName),
228
+ vertical: asBoolean(value.vertical, false)
229
+ };
230
+ return textElement;
231
+ }
232
+ if (type === "shape") {
233
+ const width = asNumber(value.width, 0);
234
+ const height = asNumber(value.height, 0);
235
+ const shapeElement = {
236
+ ...base,
237
+ type: "shape",
238
+ width,
239
+ height,
240
+ path: asString(value.path, ""),
241
+ viewBox: asPair(value.viewBox, [width, height]),
242
+ fill: asString(value.fill, ""),
243
+ fixedRatio: asBoolean(value.fixedRatio, DEFAULT_SHAPE_FIXED_RATIO)
244
+ };
245
+ return shapeElement;
246
+ }
247
+ if (type === "line") {
248
+ const lineElement = {
249
+ ...base,
250
+ type: "line",
251
+ width: asNumber(value.width, DEFAULT_LINE_WIDTH),
252
+ start: asPair(value.start, [0, 0]),
253
+ end: asPair(value.end, [0, 0]),
254
+ points: asLinePoints(value.points),
255
+ color: asString(value.color, "#000000"),
256
+ style: asString(value.style, DEFAULT_LINE_STYLE)
257
+ };
258
+ return lineElement;
259
+ }
260
+ if (type === "image") {
261
+ const imageElement = {
262
+ ...base,
263
+ type: "image",
264
+ width: asNumber(value.width, 0),
265
+ height: asNumber(value.height, 0),
266
+ src: asString(value.src, ""),
267
+ fixedRatio: asBoolean(value.fixedRatio, DEFAULT_IMAGE_FIXED_RATIO)
268
+ };
269
+ return imageElement;
270
+ }
271
+ return base;
272
+ }
273
+ function normalizeSlide(value, index, theme) {
274
+ if (!isRecord2(value)) {
275
+ return {
276
+ id: `slide-${index + 1}`,
277
+ type: DEFAULT_SLIDE_TYPE,
278
+ remark: DEFAULT_SLIDE_REMARK,
279
+ elements: []
280
+ };
281
+ }
282
+ const rawType = typeof value.type === "string" ? value.type.trim() : "";
283
+ const normalizedType = rawType && LEGACY_SLIDE_TYPE_MAP[rawType.toLowerCase()] ? LEGACY_SLIDE_TYPE_MAP[rawType.toLowerCase()] : rawType || DEFAULT_SLIDE_TYPE;
284
+ const sourceElements = Array.isArray(value.elements) ? value.elements : [];
285
+ const elements = sourceElements.map(
286
+ (element, elementIndex) => normalizeElement(element, index, elementIndex, theme)
287
+ );
288
+ const background = normalizeBackground(value.background, theme.backgroundColor);
289
+ return {
290
+ ...value,
291
+ id: asString(value.id, `slide-${index + 1}`),
292
+ type: normalizedType,
293
+ remark: asString(value.remark, DEFAULT_SLIDE_REMARK),
294
+ background,
295
+ elements
296
+ };
297
+ }
298
+ function normalizeDocument(input) {
299
+ const source = cloneValue2(input);
300
+ if (!isRecord2(source)) {
301
+ return {
302
+ schemaVersion: DEFAULT_SCHEMA_VERSION,
303
+ title: DEFAULT_TITLE,
304
+ width: DEFAULT_WIDTH,
305
+ height: DEFAULT_HEIGHT,
306
+ theme: normalizeTheme(void 0),
307
+ slides: []
308
+ };
309
+ }
310
+ const theme = normalizeTheme(source.theme);
311
+ const sourceSlides = Array.isArray(source.slides) ? source.slides : [];
312
+ const slides = sourceSlides.map((slide, index) => normalizeSlide(slide, index, theme));
313
+ const normalized = {
314
+ ...source,
315
+ schemaVersion: DEFAULT_SCHEMA_VERSION,
316
+ title: asString(source.title, DEFAULT_TITLE),
317
+ width: asNumber(source.width, DEFAULT_WIDTH),
318
+ height: asNumber(source.height, DEFAULT_HEIGHT),
319
+ theme,
320
+ slides
321
+ };
322
+ delete normalized.version;
323
+ return normalized;
324
+ }
325
+
326
+ // runtime/validate.ts
327
+ import Ajv from "ajv";
328
+
329
+ // versions/v1/schema.json
330
+ var schema_default = {
331
+ $schema: "http://json-schema.org/draft-07/schema#",
332
+ $id: "https://json2pptx.dev/schema/v1",
333
+ title: "json2pptx document schema v1",
334
+ type: "object",
335
+ required: ["slides"],
336
+ properties: {
337
+ schemaVersion: {
338
+ const: "1.0.0"
339
+ },
340
+ version: {
341
+ oneOf: [
342
+ { type: "string" },
343
+ { type: "number" }
344
+ ]
345
+ },
346
+ title: {
347
+ type: "string"
348
+ },
349
+ width: {
350
+ type: "number",
351
+ exclusiveMinimum: 0
352
+ },
353
+ height: {
354
+ type: "number",
355
+ exclusiveMinimum: 0
356
+ },
357
+ theme: {
358
+ $ref: "#/definitions/theme"
359
+ },
360
+ slides: {
361
+ type: "array",
362
+ items: {
363
+ $ref: "#/definitions/slide"
364
+ }
365
+ }
366
+ },
367
+ additionalProperties: true,
368
+ definitions: {
369
+ shadow: {
370
+ type: "object",
371
+ required: ["h", "v", "blur", "color"],
372
+ properties: {
373
+ h: { type: "number" },
374
+ v: { type: "number" },
375
+ blur: { type: "number" },
376
+ color: { type: "string" }
377
+ },
378
+ additionalProperties: true
379
+ },
380
+ outline: {
381
+ type: "object",
382
+ required: ["width", "color", "style"],
383
+ properties: {
384
+ width: { type: "number" },
385
+ color: { type: "string" },
386
+ style: { type: "string" }
387
+ },
388
+ additionalProperties: true
389
+ },
390
+ gradientStop: {
391
+ type: "object",
392
+ required: ["pos", "color"],
393
+ properties: {
394
+ pos: { type: "number" },
395
+ color: { type: "string" }
396
+ },
397
+ additionalProperties: true
398
+ },
399
+ gradient: {
400
+ type: "object",
401
+ required: ["type", "rotate", "colors"],
402
+ properties: {
403
+ type: { type: "string" },
404
+ rotate: { type: "number" },
405
+ colors: {
406
+ type: "array",
407
+ minItems: 2,
408
+ items: {
409
+ $ref: "#/definitions/gradientStop"
410
+ }
411
+ }
412
+ },
413
+ additionalProperties: true
414
+ },
415
+ theme: {
416
+ type: "object",
417
+ properties: {
418
+ themeColors: {
419
+ type: "array",
420
+ items: { type: "string" }
421
+ },
422
+ fontColor: { type: "string" },
423
+ fontName: { type: "string" },
424
+ backgroundColor: { type: "string" },
425
+ shadow: { $ref: "#/definitions/shadow" },
426
+ outline: { $ref: "#/definitions/outline" }
427
+ },
428
+ additionalProperties: true
429
+ },
430
+ pair: {
431
+ type: "array",
432
+ minItems: 2,
433
+ maxItems: 2,
434
+ items: { type: "number" }
435
+ },
436
+ linePoints: {
437
+ type: "array",
438
+ minItems: 2,
439
+ maxItems: 2,
440
+ items: { type: "string" }
441
+ },
442
+ shapeText: {
443
+ type: "object",
444
+ required: ["content"],
445
+ properties: {
446
+ content: { type: "string" },
447
+ defaultColor: { type: "string" },
448
+ defaultFontName: { type: "string" },
449
+ align: { type: "string" },
450
+ lineHeight: { type: "number" },
451
+ type: { type: "string" }
452
+ },
453
+ additionalProperties: true
454
+ },
455
+ clip: {
456
+ type: "object",
457
+ required: ["shape", "range"],
458
+ properties: {
459
+ shape: { type: "string" },
460
+ range: {
461
+ type: "array",
462
+ minItems: 2,
463
+ maxItems: 2,
464
+ items: {
465
+ $ref: "#/definitions/pair"
466
+ }
467
+ }
468
+ },
469
+ additionalProperties: true
470
+ },
471
+ filters: {
472
+ type: "object",
473
+ properties: {
474
+ opacity: {
475
+ oneOf: [
476
+ { type: "string" },
477
+ { type: "number" }
478
+ ]
479
+ },
480
+ grayscale: {
481
+ oneOf: [
482
+ { type: "string" },
483
+ { type: "number" }
484
+ ]
485
+ },
486
+ blur: {
487
+ oneOf: [
488
+ { type: "string" },
489
+ { type: "number" }
490
+ ]
491
+ },
492
+ sepia: {
493
+ oneOf: [
494
+ { type: "string" },
495
+ { type: "number" }
496
+ ]
497
+ },
498
+ saturate: {
499
+ oneOf: [
500
+ { type: "string" },
501
+ { type: "number" }
502
+ ]
503
+ }
504
+ },
505
+ additionalProperties: true
506
+ },
507
+ tableCellStyle: {
508
+ type: "object",
509
+ properties: {
510
+ fontname: { type: "string" },
511
+ color: { type: "string" },
512
+ align: { type: "string" },
513
+ fontsize: { type: "string" },
514
+ backcolor: { type: "string" }
515
+ },
516
+ additionalProperties: true
517
+ },
518
+ tableCell: {
519
+ type: "object",
520
+ properties: {
521
+ id: { type: "string" },
522
+ colspan: { type: "number" },
523
+ rowspan: { type: "number" },
524
+ text: { type: "string" },
525
+ style: { $ref: "#/definitions/tableCellStyle" }
526
+ },
527
+ additionalProperties: true
528
+ },
529
+ element: {
530
+ type: "object",
531
+ required: ["type"],
532
+ properties: {
533
+ type: { type: "string" },
534
+ id: { type: "string" },
535
+ groupId: { type: "string" },
536
+ left: { type: "number" },
537
+ top: { type: "number" },
538
+ width: { type: "number" },
539
+ height: { type: "number" },
540
+ rotate: { type: "number" },
541
+ lock: { type: "boolean" },
542
+ opacity: { type: "number" },
543
+ flipH: { type: "boolean" },
544
+ flipV: { type: "boolean" },
545
+ shadow: { $ref: "#/definitions/shadow" },
546
+ outline: { $ref: "#/definitions/outline" }
547
+ },
548
+ allOf: [
549
+ {
550
+ if: {
551
+ required: ["type"],
552
+ properties: {
553
+ type: { const: "text" }
554
+ }
555
+ },
556
+ then: {
557
+ required: ["content", "left", "top", "width", "height"],
558
+ properties: {
559
+ content: { type: "string" },
560
+ defaultColor: { type: "string" },
561
+ defaultFontName: { type: "string" },
562
+ fill: { type: "string" },
563
+ lineHeight: { type: "number" },
564
+ paragraphSpace: { type: "number" },
565
+ textType: { type: "string" },
566
+ vertical: { type: "boolean" },
567
+ wordSpace: { type: "number" }
568
+ }
569
+ }
570
+ },
571
+ {
572
+ if: {
573
+ required: ["type"],
574
+ properties: {
575
+ type: { const: "shape" }
576
+ }
577
+ },
578
+ then: {
579
+ required: [
580
+ "path",
581
+ "viewBox",
582
+ "fill",
583
+ "left",
584
+ "top",
585
+ "width",
586
+ "height"
587
+ ],
588
+ properties: {
589
+ path: { type: "string" },
590
+ viewBox: { $ref: "#/definitions/pair" },
591
+ fill: { type: "string" },
592
+ fixedRatio: { type: "boolean" },
593
+ keypoints: {
594
+ type: "array",
595
+ items: { type: "number" }
596
+ },
597
+ pathFormula: { type: "string" },
598
+ gradient: { $ref: "#/definitions/gradient" },
599
+ special: { type: "boolean" },
600
+ text: { $ref: "#/definitions/shapeText" }
601
+ }
602
+ }
603
+ },
604
+ {
605
+ if: {
606
+ required: ["type"],
607
+ properties: {
608
+ type: { const: "line" }
609
+ }
610
+ },
611
+ then: {
612
+ required: [
613
+ "start",
614
+ "end",
615
+ "points",
616
+ "color",
617
+ "width",
618
+ "left",
619
+ "top"
620
+ ],
621
+ properties: {
622
+ start: { $ref: "#/definitions/pair" },
623
+ end: { $ref: "#/definitions/pair" },
624
+ points: { $ref: "#/definitions/linePoints" },
625
+ broken: { $ref: "#/definitions/pair" },
626
+ color: { type: "string" },
627
+ style: { type: "string" },
628
+ width: { type: "number" }
629
+ }
630
+ }
631
+ },
632
+ {
633
+ if: {
634
+ required: ["type"],
635
+ properties: {
636
+ type: { const: "image" }
637
+ }
638
+ },
639
+ then: {
640
+ required: ["src", "left", "top", "width", "height"],
641
+ properties: {
642
+ src: { type: "string" },
643
+ fixedRatio: { type: "boolean" },
644
+ clip: { $ref: "#/definitions/clip" },
645
+ filters: { $ref: "#/definitions/filters" },
646
+ imageType: { type: "string" },
647
+ radius: { type: "number" },
648
+ colorMask: { type: "string" }
649
+ }
650
+ }
651
+ },
652
+ {
653
+ if: {
654
+ required: ["type"],
655
+ properties: {
656
+ type: { const: "table" }
657
+ }
658
+ },
659
+ then: {
660
+ required: ["left", "top", "width", "height"],
661
+ properties: {
662
+ colWidths: {
663
+ type: "array",
664
+ items: { type: "number" }
665
+ },
666
+ data: {
667
+ type: "array",
668
+ items: {
669
+ type: "array",
670
+ items: {
671
+ $ref: "#/definitions/tableCell"
672
+ }
673
+ }
674
+ },
675
+ cellMinHeight: { type: "number" }
676
+ }
677
+ }
678
+ }
679
+ ],
680
+ additionalProperties: true
681
+ },
682
+ slideBackground: {
683
+ type: "object",
684
+ properties: {
685
+ type: { type: "string" },
686
+ color: { type: "string" },
687
+ src: { type: "string" },
688
+ gradient: { $ref: "#/definitions/gradient" }
689
+ },
690
+ additionalProperties: true
691
+ },
692
+ slide: {
693
+ type: "object",
694
+ required: ["elements"],
695
+ properties: {
696
+ id: { type: "string" },
697
+ type: { type: "string" },
698
+ remark: { type: "string" },
699
+ background: { $ref: "#/definitions/slideBackground" },
700
+ elements: {
701
+ type: "array",
702
+ items: {
703
+ $ref: "#/definitions/element"
704
+ }
705
+ }
706
+ },
707
+ additionalProperties: true
708
+ }
709
+ }
710
+ };
711
+
712
+ // runtime/validate.ts
713
+ var ajv = new Ajv({
714
+ allErrors: true,
715
+ strict: false,
716
+ allowUnionTypes: true
717
+ });
718
+ var validateV1 = ajv.compile(schema_default);
719
+ function mapError(error) {
720
+ return {
721
+ code: "SCHEMA_VALIDATION_ERROR",
722
+ path: error.instancePath || "/",
723
+ message: error.message ?? "Invalid value",
724
+ keyword: error.keyword,
725
+ params: error.params && typeof error.params === "object" ? error.params : void 0
726
+ };
727
+ }
728
+ function validateDocument(input) {
729
+ const valid = validateV1(input);
730
+ if (!valid) {
731
+ const issues = (validateV1.errors ?? []).map(mapError);
732
+ throw new SchemaValidationError(issues);
733
+ }
734
+ return input;
735
+ }
736
+
737
+ // runtime/parse.ts
738
+ function parseDocument(input) {
739
+ const migrated = migrateDocument(input);
740
+ const validated = validateDocument(migrated);
741
+ return normalizeDocument(validated);
742
+ }
743
+
744
+ // versions/v1/types.ts
745
+ var V1_SCHEMA_VERSION = "1.0.0";
746
+ export {
747
+ DEFAULT_HEIGHT,
748
+ DEFAULT_SCHEMA_VERSION,
749
+ DEFAULT_SLIDE_REMARK,
750
+ DEFAULT_SLIDE_TYPE,
751
+ DEFAULT_THEME,
752
+ DEFAULT_THEME_OUTLINE,
753
+ DEFAULT_THEME_SHADOW,
754
+ DEFAULT_TITLE,
755
+ DEFAULT_WIDTH,
756
+ SchemaValidationError,
757
+ UnsupportedSchemaVersionError,
758
+ V1_DEFAULTS,
759
+ V1_SCHEMA_VERSION,
760
+ migrateDocument,
761
+ normalizeDocument,
762
+ parseDocument,
763
+ validateDocument
764
+ };
765
+ //# sourceMappingURL=index.mjs.map