document-schema 3.3.0 → 4.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.
Files changed (47) hide show
  1. package/README.md +141 -30
  2. package/dist/codec.d.cts +2 -7
  3. package/dist/codec.d.ts +2 -7
  4. package/dist/construct-CdQuI9f5.d.cts +204 -0
  5. package/dist/construct-CdQuI9f5.d.ts +204 -0
  6. package/dist/construct.cjs +106 -0
  7. package/dist/construct.d.cts +2 -0
  8. package/dist/construct.d.ts +2 -0
  9. package/dist/construct.js +93 -0
  10. package/dist/content-BN0PWqpt.d.cts +2393 -0
  11. package/dist/content-CiZf6Fqn.d.ts +2393 -0
  12. package/dist/content-json-schema-defs.cjs +1227 -0
  13. package/dist/content-json-schema-defs.js +1227 -0
  14. package/dist/content.cjs +1 -7
  15. package/dist/content.d.cts +2 -2354
  16. package/dist/content.d.ts +2 -2354
  17. package/dist/content.js +1 -7
  18. package/dist/definitions.cjs +109 -0
  19. package/dist/definitions.d.cts +115 -0
  20. package/dist/definitions.d.ts +115 -0
  21. package/dist/definitions.js +99 -0
  22. package/dist/index.cjs +60 -18
  23. package/dist/index.d.cts +8 -6
  24. package/dist/index.d.ts +8 -6
  25. package/dist/index.js +7 -5
  26. package/dist/package-node-BiUEzIzl.d.cts +456 -0
  27. package/dist/package-node-DLUobcDQ.d.ts +456 -0
  28. package/dist/package-node.cjs +133 -0
  29. package/dist/package-node.d.cts +2 -0
  30. package/dist/package-node.d.ts +2 -0
  31. package/dist/package-node.js +102 -0
  32. package/dist/package.cjs +40 -7
  33. package/dist/package.d.cts +497 -755
  34. package/dist/package.d.ts +497 -755
  35. package/dist/package.js +42 -8
  36. package/dist/schema-io.cjs +55 -25
  37. package/dist/schema-io.d.cts +13 -11
  38. package/dist/schema-io.d.ts +13 -11
  39. package/dist/schema-io.js +54 -25
  40. package/package.json +2 -2
  41. package/schemas/content-document.schema.json +1813 -68
  42. package/schemas/document-package.schema.json +3528 -30
  43. package/dist/layout.cjs +0 -150
  44. package/dist/layout.d.cts +0 -684
  45. package/dist/layout.d.ts +0 -684
  46. package/dist/layout.js +0 -136
  47. package/schemas/layout-document.schema.json +0 -760
package/dist/content.js CHANGED
@@ -358,44 +358,38 @@ const ContentFormulaSchema = z.object({
358
358
  content: MathExpressionSchema.optional(),
359
359
  provenance: MathProvenanceSchema.optional()
360
360
  });
361
- const CONTENT_FORMAT_VERSION = 3;
362
361
  const contentDocumentSharedFields = { symbolTable: SymbolTableSchema.optional() };
363
362
  const ContentDocumentSchema = z.discriminatedUnion("kind", [
364
363
  z.object({
365
364
  kind: z.literal("wordprocessing"),
366
- formatVersion: z.literal(3),
367
365
  metadata: LayoutMetadataSchema,
368
366
  ...contentDocumentSharedFields,
369
367
  sections: z.array(ContentSectionSchema)
370
368
  }),
371
369
  z.object({
372
370
  kind: z.literal("presentation"),
373
- formatVersion: z.literal(3),
374
371
  metadata: LayoutMetadataSchema,
375
372
  ...contentDocumentSharedFields,
376
373
  slides: z.array(ContentSlideSchema)
377
374
  }),
378
375
  z.object({
379
376
  kind: z.literal("spreadsheet"),
380
- formatVersion: z.literal(3),
381
377
  metadata: LayoutMetadataSchema,
382
378
  ...contentDocumentSharedFields,
383
379
  sheets: z.array(ContentSheetSchema)
384
380
  }),
385
381
  z.object({
386
382
  kind: z.literal("drawing"),
387
- formatVersion: z.literal(3),
388
383
  metadata: LayoutMetadataSchema,
389
384
  ...contentDocumentSharedFields,
390
385
  pages: z.array(ContentDrawPageSchema)
391
386
  }),
392
387
  z.object({
393
388
  kind: z.literal("formula"),
394
- formatVersion: z.literal(3),
395
389
  metadata: LayoutMetadataSchema,
396
390
  ...contentDocumentSharedFields,
397
391
  formula: ContentFormulaSchema
398
392
  })
399
393
  ]);
400
394
  //#endregion
401
- export { CONTENT_FORMAT_VERSION, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentDocumentSchema, ContentDrawPageSchema, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectSchema, ContentFormulaSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeSchema, ContentStrokeStyleSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentVectorSchema, DecimalStringSchema, clampHeadingLevel, isContentBlock };
395
+ export { ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentDocumentSchema, ContentDrawPageSchema, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectSchema, ContentFormulaSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeSchema, ContentStrokeStyleSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentVectorSchema, DecimalStringSchema, clampHeadingLevel, contentDocumentSharedFields, isContentBlock };
@@ -0,0 +1,109 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_color = require("./color.cjs");
3
+ const require_style = require("./style.cjs");
4
+ const require_content = require("./content.cjs");
5
+ let zod = require("zod");
6
+ //#region src/definitions.ts
7
+ const StyleParagraphPropertiesSchema = zod.z.strictObject({
8
+ alignment: require_style.AlignmentSchema.optional(),
9
+ list: require_content.ContentListMembershipSchema.optional(),
10
+ spacingBeforePt: zod.z.number().optional(),
11
+ spacingAfterPt: zod.z.number().optional(),
12
+ lineSpacing: zod.z.number().positive().optional(),
13
+ indentLeftPt: zod.z.number().optional(),
14
+ indentFirstLinePt: zod.z.number().optional()
15
+ });
16
+ const StyleRunPropertiesSchema = zod.z.strictObject({
17
+ bold: zod.z.boolean().optional(),
18
+ italic: zod.z.boolean().optional(),
19
+ underline: zod.z.boolean().optional(),
20
+ strike: zod.z.boolean().optional(),
21
+ fontFamily: zod.z.string().optional(),
22
+ sizePt: zod.z.number().positive().optional(),
23
+ color: require_color.ColorSchema.optional()
24
+ });
25
+ const StyleEntrySchema = zod.z.strictObject({
26
+ paragraph: StyleParagraphPropertiesSchema.optional(),
27
+ run: StyleRunPropertiesSchema.optional()
28
+ });
29
+ const StylesTableSchema = zod.z.record(zod.z.string(), StyleEntrySchema);
30
+ const DefinitionEntrySchema = zod.z.looseObject({ kind: zod.z.string() });
31
+ const DefinitionsTableSchema = zod.z.record(zod.z.string(), DefinitionEntrySchema);
32
+ function overlayStyleEntries(outer, inner) {
33
+ const paragraph = overlayParagraphProperties(outer.paragraph, inner.paragraph);
34
+ const run = overlayRunProperties(outer.run, inner.run);
35
+ return {
36
+ ...paragraph !== void 0 ? { paragraph } : {},
37
+ ...run !== void 0 ? { run } : {}
38
+ };
39
+ }
40
+ function overlayParagraphProperties(outer, inner) {
41
+ if (outer === void 0) return inner;
42
+ if (inner === void 0) return outer;
43
+ const merged = { ...outer };
44
+ if (inner.alignment !== void 0) merged.alignment = inner.alignment;
45
+ if (inner.list !== void 0) merged.list = inner.list;
46
+ if (inner.spacingBeforePt !== void 0) merged.spacingBeforePt = inner.spacingBeforePt;
47
+ if (inner.spacingAfterPt !== void 0) merged.spacingAfterPt = inner.spacingAfterPt;
48
+ if (inner.lineSpacing !== void 0) merged.lineSpacing = inner.lineSpacing;
49
+ if (inner.indentLeftPt !== void 0) merged.indentLeftPt = inner.indentLeftPt;
50
+ if (inner.indentFirstLinePt !== void 0) merged.indentFirstLinePt = inner.indentFirstLinePt;
51
+ return merged;
52
+ }
53
+ function overlayRunProperties(outer, inner) {
54
+ if (outer === void 0) return inner;
55
+ if (inner === void 0) return outer;
56
+ const merged = { ...outer };
57
+ if (inner.bold !== void 0) merged.bold = inner.bold;
58
+ if (inner.italic !== void 0) merged.italic = inner.italic;
59
+ if (inner.underline !== void 0) merged.underline = inner.underline;
60
+ if (inner.strike !== void 0) merged.strike = inner.strike;
61
+ if (inner.fontFamily !== void 0) merged.fontFamily = inner.fontFamily;
62
+ if (inner.sizePt !== void 0) merged.sizePt = inner.sizePt;
63
+ if (inner.color !== void 0) merged.color = inner.color;
64
+ return merged;
65
+ }
66
+ function resolveStyleChain(styles, refs) {
67
+ let resolved = {};
68
+ for (const ref of refs) {
69
+ const entry = styles[ref];
70
+ if (entry === void 0) throw new Error(`resolveStyleChain: style ref "${ref}" names no entry in the styles table`);
71
+ resolved = overlayStyleEntries(resolved, entry);
72
+ }
73
+ return resolved;
74
+ }
75
+ function applyParagraphStyleProperties(properties, paragraph) {
76
+ if (properties === void 0) return paragraph;
77
+ const effective = { ...paragraph };
78
+ if (effective.alignment === void 0 && properties.alignment !== void 0) effective.alignment = properties.alignment;
79
+ if (effective.list === void 0 && properties.list !== void 0) effective.list = properties.list;
80
+ if (effective.spacingBeforePt === void 0 && properties.spacingBeforePt !== void 0) effective.spacingBeforePt = properties.spacingBeforePt;
81
+ if (effective.spacingAfterPt === void 0 && properties.spacingAfterPt !== void 0) effective.spacingAfterPt = properties.spacingAfterPt;
82
+ if (effective.lineSpacing === void 0 && properties.lineSpacing !== void 0) effective.lineSpacing = properties.lineSpacing;
83
+ if (effective.indentLeftPt === void 0 && properties.indentLeftPt !== void 0) effective.indentLeftPt = properties.indentLeftPt;
84
+ if (effective.indentFirstLinePt === void 0 && properties.indentFirstLinePt !== void 0) effective.indentFirstLinePt = properties.indentFirstLinePt;
85
+ return effective;
86
+ }
87
+ function applyRunStyleProperties(properties, run) {
88
+ if (properties === void 0) return run;
89
+ const effective = { ...run };
90
+ if (effective.bold === void 0 && properties.bold !== void 0) effective.bold = properties.bold;
91
+ if (effective.italic === void 0 && properties.italic !== void 0) effective.italic = properties.italic;
92
+ if (effective.underline === void 0 && properties.underline !== void 0) effective.underline = properties.underline;
93
+ if (effective.strike === void 0 && properties.strike !== void 0) effective.strike = properties.strike;
94
+ if (effective.fontFamily === void 0 && properties.fontFamily !== void 0) effective.fontFamily = properties.fontFamily;
95
+ if (effective.sizePt === void 0 && properties.sizePt !== void 0) effective.sizePt = properties.sizePt;
96
+ if (effective.color === void 0 && properties.color !== void 0) effective.color = properties.color;
97
+ return effective;
98
+ }
99
+ //#endregion
100
+ exports.DefinitionEntrySchema = DefinitionEntrySchema;
101
+ exports.DefinitionsTableSchema = DefinitionsTableSchema;
102
+ exports.StyleEntrySchema = StyleEntrySchema;
103
+ exports.StyleParagraphPropertiesSchema = StyleParagraphPropertiesSchema;
104
+ exports.StyleRunPropertiesSchema = StyleRunPropertiesSchema;
105
+ exports.StylesTableSchema = StylesTableSchema;
106
+ exports.applyParagraphStyleProperties = applyParagraphStyleProperties;
107
+ exports.applyRunStyleProperties = applyRunStyleProperties;
108
+ exports.overlayStyleEntries = overlayStyleEntries;
109
+ exports.resolveStyleChain = resolveStyleChain;
@@ -0,0 +1,115 @@
1
+ import { E as ContentParagraph, M as ContentRun } from "./content-BN0PWqpt.cjs";
2
+ import { z } from "zod";
3
+ //#region src/definitions.d.ts
4
+ declare const StyleParagraphPropertiesSchema: z.ZodObject<{
5
+ alignment: z.ZodOptional<z.ZodEnum<{
6
+ left: "left";
7
+ center: "center";
8
+ right: "right";
9
+ justify: "justify";
10
+ }>>;
11
+ list: z.ZodOptional<z.ZodObject<{
12
+ numId: z.ZodOptional<z.ZodString>;
13
+ level: z.ZodNumber;
14
+ }, z.core.$strip>>;
15
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
16
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
17
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
18
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
19
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strict>;
21
+ type StyleParagraphProperties = z.infer<typeof StyleParagraphPropertiesSchema>;
22
+ declare const StyleRunPropertiesSchema: z.ZodObject<{
23
+ bold: z.ZodOptional<z.ZodBoolean>;
24
+ italic: z.ZodOptional<z.ZodBoolean>;
25
+ underline: z.ZodOptional<z.ZodBoolean>;
26
+ strike: z.ZodOptional<z.ZodBoolean>;
27
+ fontFamily: z.ZodOptional<z.ZodString>;
28
+ sizePt: z.ZodOptional<z.ZodNumber>;
29
+ color: z.ZodOptional<z.ZodObject<{
30
+ r: z.ZodNumber;
31
+ g: z.ZodNumber;
32
+ b: z.ZodNumber;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strict>;
35
+ type StyleRunProperties = z.infer<typeof StyleRunPropertiesSchema>;
36
+ declare const StyleEntrySchema: z.ZodObject<{
37
+ paragraph: z.ZodOptional<z.ZodObject<{
38
+ alignment: z.ZodOptional<z.ZodEnum<{
39
+ left: "left";
40
+ center: "center";
41
+ right: "right";
42
+ justify: "justify";
43
+ }>>;
44
+ list: z.ZodOptional<z.ZodObject<{
45
+ numId: z.ZodOptional<z.ZodString>;
46
+ level: z.ZodNumber;
47
+ }, z.core.$strip>>;
48
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
49
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
50
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
51
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
52
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strict>>;
54
+ run: z.ZodOptional<z.ZodObject<{
55
+ bold: z.ZodOptional<z.ZodBoolean>;
56
+ italic: z.ZodOptional<z.ZodBoolean>;
57
+ underline: z.ZodOptional<z.ZodBoolean>;
58
+ strike: z.ZodOptional<z.ZodBoolean>;
59
+ fontFamily: z.ZodOptional<z.ZodString>;
60
+ sizePt: z.ZodOptional<z.ZodNumber>;
61
+ color: z.ZodOptional<z.ZodObject<{
62
+ r: z.ZodNumber;
63
+ g: z.ZodNumber;
64
+ b: z.ZodNumber;
65
+ }, z.core.$strip>>;
66
+ }, z.core.$strict>>;
67
+ }, z.core.$strict>;
68
+ type StyleEntry = z.infer<typeof StyleEntrySchema>;
69
+ declare const StylesTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
70
+ paragraph: z.ZodOptional<z.ZodObject<{
71
+ alignment: z.ZodOptional<z.ZodEnum<{
72
+ left: "left";
73
+ center: "center";
74
+ right: "right";
75
+ justify: "justify";
76
+ }>>;
77
+ list: z.ZodOptional<z.ZodObject<{
78
+ numId: z.ZodOptional<z.ZodString>;
79
+ level: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
82
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
83
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
84
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
85
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
86
+ }, z.core.$strict>>;
87
+ run: z.ZodOptional<z.ZodObject<{
88
+ bold: z.ZodOptional<z.ZodBoolean>;
89
+ italic: z.ZodOptional<z.ZodBoolean>;
90
+ underline: z.ZodOptional<z.ZodBoolean>;
91
+ strike: z.ZodOptional<z.ZodBoolean>;
92
+ fontFamily: z.ZodOptional<z.ZodString>;
93
+ sizePt: z.ZodOptional<z.ZodNumber>;
94
+ color: z.ZodOptional<z.ZodObject<{
95
+ r: z.ZodNumber;
96
+ g: z.ZodNumber;
97
+ b: z.ZodNumber;
98
+ }, z.core.$strip>>;
99
+ }, z.core.$strict>>;
100
+ }, z.core.$strict>>;
101
+ type StylesTable = z.infer<typeof StylesTableSchema>;
102
+ declare const DefinitionEntrySchema: z.ZodObject<{
103
+ kind: z.ZodString;
104
+ }, z.core.$loose>;
105
+ type DefinitionEntry = z.infer<typeof DefinitionEntrySchema>;
106
+ declare const DefinitionsTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
107
+ kind: z.ZodString;
108
+ }, z.core.$loose>>;
109
+ type DefinitionsTable = z.infer<typeof DefinitionsTableSchema>;
110
+ declare function overlayStyleEntries(outer: StyleEntry, inner: StyleEntry): StyleEntry;
111
+ declare function resolveStyleChain(styles: StylesTable, refs: readonly string[]): StyleEntry;
112
+ declare function applyParagraphStyleProperties(properties: StyleParagraphProperties | undefined, paragraph: ContentParagraph): ContentParagraph;
113
+ declare function applyRunStyleProperties(properties: StyleRunProperties | undefined, run: ContentRun): ContentRun;
114
+ //#endregion
115
+ export { DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StylesTable, StylesTableSchema, applyParagraphStyleProperties, applyRunStyleProperties, overlayStyleEntries, resolveStyleChain };
@@ -0,0 +1,115 @@
1
+ import { E as ContentParagraph, M as ContentRun } from "./content-CiZf6Fqn.js";
2
+ import { z } from "zod";
3
+ //#region src/definitions.d.ts
4
+ declare const StyleParagraphPropertiesSchema: z.ZodObject<{
5
+ alignment: z.ZodOptional<z.ZodEnum<{
6
+ left: "left";
7
+ center: "center";
8
+ right: "right";
9
+ justify: "justify";
10
+ }>>;
11
+ list: z.ZodOptional<z.ZodObject<{
12
+ numId: z.ZodOptional<z.ZodString>;
13
+ level: z.ZodNumber;
14
+ }, z.core.$strip>>;
15
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
16
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
17
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
18
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
19
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
20
+ }, z.core.$strict>;
21
+ type StyleParagraphProperties = z.infer<typeof StyleParagraphPropertiesSchema>;
22
+ declare const StyleRunPropertiesSchema: z.ZodObject<{
23
+ bold: z.ZodOptional<z.ZodBoolean>;
24
+ italic: z.ZodOptional<z.ZodBoolean>;
25
+ underline: z.ZodOptional<z.ZodBoolean>;
26
+ strike: z.ZodOptional<z.ZodBoolean>;
27
+ fontFamily: z.ZodOptional<z.ZodString>;
28
+ sizePt: z.ZodOptional<z.ZodNumber>;
29
+ color: z.ZodOptional<z.ZodObject<{
30
+ r: z.ZodNumber;
31
+ g: z.ZodNumber;
32
+ b: z.ZodNumber;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strict>;
35
+ type StyleRunProperties = z.infer<typeof StyleRunPropertiesSchema>;
36
+ declare const StyleEntrySchema: z.ZodObject<{
37
+ paragraph: z.ZodOptional<z.ZodObject<{
38
+ alignment: z.ZodOptional<z.ZodEnum<{
39
+ left: "left";
40
+ center: "center";
41
+ right: "right";
42
+ justify: "justify";
43
+ }>>;
44
+ list: z.ZodOptional<z.ZodObject<{
45
+ numId: z.ZodOptional<z.ZodString>;
46
+ level: z.ZodNumber;
47
+ }, z.core.$strip>>;
48
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
49
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
50
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
51
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
52
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
53
+ }, z.core.$strict>>;
54
+ run: z.ZodOptional<z.ZodObject<{
55
+ bold: z.ZodOptional<z.ZodBoolean>;
56
+ italic: z.ZodOptional<z.ZodBoolean>;
57
+ underline: z.ZodOptional<z.ZodBoolean>;
58
+ strike: z.ZodOptional<z.ZodBoolean>;
59
+ fontFamily: z.ZodOptional<z.ZodString>;
60
+ sizePt: z.ZodOptional<z.ZodNumber>;
61
+ color: z.ZodOptional<z.ZodObject<{
62
+ r: z.ZodNumber;
63
+ g: z.ZodNumber;
64
+ b: z.ZodNumber;
65
+ }, z.core.$strip>>;
66
+ }, z.core.$strict>>;
67
+ }, z.core.$strict>;
68
+ type StyleEntry = z.infer<typeof StyleEntrySchema>;
69
+ declare const StylesTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
70
+ paragraph: z.ZodOptional<z.ZodObject<{
71
+ alignment: z.ZodOptional<z.ZodEnum<{
72
+ left: "left";
73
+ center: "center";
74
+ right: "right";
75
+ justify: "justify";
76
+ }>>;
77
+ list: z.ZodOptional<z.ZodObject<{
78
+ numId: z.ZodOptional<z.ZodString>;
79
+ level: z.ZodNumber;
80
+ }, z.core.$strip>>;
81
+ spacingBeforePt: z.ZodOptional<z.ZodNumber>;
82
+ spacingAfterPt: z.ZodOptional<z.ZodNumber>;
83
+ lineSpacing: z.ZodOptional<z.ZodNumber>;
84
+ indentLeftPt: z.ZodOptional<z.ZodNumber>;
85
+ indentFirstLinePt: z.ZodOptional<z.ZodNumber>;
86
+ }, z.core.$strict>>;
87
+ run: z.ZodOptional<z.ZodObject<{
88
+ bold: z.ZodOptional<z.ZodBoolean>;
89
+ italic: z.ZodOptional<z.ZodBoolean>;
90
+ underline: z.ZodOptional<z.ZodBoolean>;
91
+ strike: z.ZodOptional<z.ZodBoolean>;
92
+ fontFamily: z.ZodOptional<z.ZodString>;
93
+ sizePt: z.ZodOptional<z.ZodNumber>;
94
+ color: z.ZodOptional<z.ZodObject<{
95
+ r: z.ZodNumber;
96
+ g: z.ZodNumber;
97
+ b: z.ZodNumber;
98
+ }, z.core.$strip>>;
99
+ }, z.core.$strict>>;
100
+ }, z.core.$strict>>;
101
+ type StylesTable = z.infer<typeof StylesTableSchema>;
102
+ declare const DefinitionEntrySchema: z.ZodObject<{
103
+ kind: z.ZodString;
104
+ }, z.core.$loose>;
105
+ type DefinitionEntry = z.infer<typeof DefinitionEntrySchema>;
106
+ declare const DefinitionsTableSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
107
+ kind: z.ZodString;
108
+ }, z.core.$loose>>;
109
+ type DefinitionsTable = z.infer<typeof DefinitionsTableSchema>;
110
+ declare function overlayStyleEntries(outer: StyleEntry, inner: StyleEntry): StyleEntry;
111
+ declare function resolveStyleChain(styles: StylesTable, refs: readonly string[]): StyleEntry;
112
+ declare function applyParagraphStyleProperties(properties: StyleParagraphProperties | undefined, paragraph: ContentParagraph): ContentParagraph;
113
+ declare function applyRunStyleProperties(properties: StyleRunProperties | undefined, run: ContentRun): ContentRun;
114
+ //#endregion
115
+ export { DefinitionEntry, DefinitionEntrySchema, DefinitionsTable, DefinitionsTableSchema, StyleEntry, StyleEntrySchema, StyleParagraphProperties, StyleParagraphPropertiesSchema, StyleRunProperties, StyleRunPropertiesSchema, StylesTable, StylesTableSchema, applyParagraphStyleProperties, applyRunStyleProperties, overlayStyleEntries, resolveStyleChain };
@@ -0,0 +1,99 @@
1
+ import { ColorSchema } from "./color.js";
2
+ import { AlignmentSchema } from "./style.js";
3
+ import { ContentListMembershipSchema } from "./content.js";
4
+ import { z } from "zod";
5
+ //#region src/definitions.ts
6
+ const StyleParagraphPropertiesSchema = z.strictObject({
7
+ alignment: AlignmentSchema.optional(),
8
+ list: ContentListMembershipSchema.optional(),
9
+ spacingBeforePt: z.number().optional(),
10
+ spacingAfterPt: z.number().optional(),
11
+ lineSpacing: z.number().positive().optional(),
12
+ indentLeftPt: z.number().optional(),
13
+ indentFirstLinePt: z.number().optional()
14
+ });
15
+ const StyleRunPropertiesSchema = z.strictObject({
16
+ bold: z.boolean().optional(),
17
+ italic: z.boolean().optional(),
18
+ underline: z.boolean().optional(),
19
+ strike: z.boolean().optional(),
20
+ fontFamily: z.string().optional(),
21
+ sizePt: z.number().positive().optional(),
22
+ color: ColorSchema.optional()
23
+ });
24
+ const StyleEntrySchema = z.strictObject({
25
+ paragraph: StyleParagraphPropertiesSchema.optional(),
26
+ run: StyleRunPropertiesSchema.optional()
27
+ });
28
+ const StylesTableSchema = z.record(z.string(), StyleEntrySchema);
29
+ const DefinitionEntrySchema = z.looseObject({ kind: z.string() });
30
+ const DefinitionsTableSchema = z.record(z.string(), DefinitionEntrySchema);
31
+ function overlayStyleEntries(outer, inner) {
32
+ const paragraph = overlayParagraphProperties(outer.paragraph, inner.paragraph);
33
+ const run = overlayRunProperties(outer.run, inner.run);
34
+ return {
35
+ ...paragraph !== void 0 ? { paragraph } : {},
36
+ ...run !== void 0 ? { run } : {}
37
+ };
38
+ }
39
+ function overlayParagraphProperties(outer, inner) {
40
+ if (outer === void 0) return inner;
41
+ if (inner === void 0) return outer;
42
+ const merged = { ...outer };
43
+ if (inner.alignment !== void 0) merged.alignment = inner.alignment;
44
+ if (inner.list !== void 0) merged.list = inner.list;
45
+ if (inner.spacingBeforePt !== void 0) merged.spacingBeforePt = inner.spacingBeforePt;
46
+ if (inner.spacingAfterPt !== void 0) merged.spacingAfterPt = inner.spacingAfterPt;
47
+ if (inner.lineSpacing !== void 0) merged.lineSpacing = inner.lineSpacing;
48
+ if (inner.indentLeftPt !== void 0) merged.indentLeftPt = inner.indentLeftPt;
49
+ if (inner.indentFirstLinePt !== void 0) merged.indentFirstLinePt = inner.indentFirstLinePt;
50
+ return merged;
51
+ }
52
+ function overlayRunProperties(outer, inner) {
53
+ if (outer === void 0) return inner;
54
+ if (inner === void 0) return outer;
55
+ const merged = { ...outer };
56
+ if (inner.bold !== void 0) merged.bold = inner.bold;
57
+ if (inner.italic !== void 0) merged.italic = inner.italic;
58
+ if (inner.underline !== void 0) merged.underline = inner.underline;
59
+ if (inner.strike !== void 0) merged.strike = inner.strike;
60
+ if (inner.fontFamily !== void 0) merged.fontFamily = inner.fontFamily;
61
+ if (inner.sizePt !== void 0) merged.sizePt = inner.sizePt;
62
+ if (inner.color !== void 0) merged.color = inner.color;
63
+ return merged;
64
+ }
65
+ function resolveStyleChain(styles, refs) {
66
+ let resolved = {};
67
+ for (const ref of refs) {
68
+ const entry = styles[ref];
69
+ if (entry === void 0) throw new Error(`resolveStyleChain: style ref "${ref}" names no entry in the styles table`);
70
+ resolved = overlayStyleEntries(resolved, entry);
71
+ }
72
+ return resolved;
73
+ }
74
+ function applyParagraphStyleProperties(properties, paragraph) {
75
+ if (properties === void 0) return paragraph;
76
+ const effective = { ...paragraph };
77
+ if (effective.alignment === void 0 && properties.alignment !== void 0) effective.alignment = properties.alignment;
78
+ if (effective.list === void 0 && properties.list !== void 0) effective.list = properties.list;
79
+ if (effective.spacingBeforePt === void 0 && properties.spacingBeforePt !== void 0) effective.spacingBeforePt = properties.spacingBeforePt;
80
+ if (effective.spacingAfterPt === void 0 && properties.spacingAfterPt !== void 0) effective.spacingAfterPt = properties.spacingAfterPt;
81
+ if (effective.lineSpacing === void 0 && properties.lineSpacing !== void 0) effective.lineSpacing = properties.lineSpacing;
82
+ if (effective.indentLeftPt === void 0 && properties.indentLeftPt !== void 0) effective.indentLeftPt = properties.indentLeftPt;
83
+ if (effective.indentFirstLinePt === void 0 && properties.indentFirstLinePt !== void 0) effective.indentFirstLinePt = properties.indentFirstLinePt;
84
+ return effective;
85
+ }
86
+ function applyRunStyleProperties(properties, run) {
87
+ if (properties === void 0) return run;
88
+ const effective = { ...run };
89
+ if (effective.bold === void 0 && properties.bold !== void 0) effective.bold = properties.bold;
90
+ if (effective.italic === void 0 && properties.italic !== void 0) effective.italic = properties.italic;
91
+ if (effective.underline === void 0 && properties.underline !== void 0) effective.underline = properties.underline;
92
+ if (effective.strike === void 0 && properties.strike !== void 0) effective.strike = properties.strike;
93
+ if (effective.fontFamily === void 0 && properties.fontFamily !== void 0) effective.fontFamily = properties.fontFamily;
94
+ if (effective.sizePt === void 0 && properties.sizePt !== void 0) effective.sizePt = properties.sizePt;
95
+ if (effective.color === void 0 && properties.color !== void 0) effective.color = properties.color;
96
+ return effective;
97
+ }
98
+ //#endregion
99
+ export { DefinitionEntrySchema, DefinitionsTableSchema, StyleEntrySchema, StyleParagraphPropertiesSchema, StyleRunPropertiesSchema, StylesTableSchema, applyParagraphStyleProperties, applyRunStyleProperties, overlayStyleEntries, resolveStyleChain };
package/dist/index.cjs CHANGED
@@ -2,13 +2,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_a1 = require("./a1.cjs");
3
3
  require("./codec.cjs");
4
4
  const require_color = require("./color.cjs");
5
+ const require_construct = require("./construct.cjs");
5
6
  const require_math = require("./math.cjs");
6
7
  const require_geometry = require("./geometry.cjs");
7
8
  const require_mathml = require("./mathml.cjs");
8
9
  const require_metadata = require("./metadata.cjs");
9
10
  const require_style = require("./style.cjs");
10
11
  const require_content = require("./content.cjs");
11
- const require_layout = require("./layout.cjs");
12
+ const require_definitions = require("./definitions.cjs");
13
+ const require_package_node = require("./package-node.cjs");
12
14
  const require_package = require("./package.cjs");
13
15
  const require_schema_io = require("./schema-io.cjs");
14
16
  const require_content_json_schema_defs = require("./content-json-schema-defs.cjs");
@@ -16,16 +18,21 @@ require("./font-port.cjs");
16
18
  require("./text-layout.cjs");
17
19
  require("./math-layout.cjs");
18
20
  exports.AlignmentSchema = require_style.AlignmentSchema;
21
+ exports.AnchorDescriptorSchema = require_construct.AnchorDescriptorSchema;
22
+ exports.AnchorTypeSchema = require_construct.AnchorTypeSchema;
19
23
  exports.BoxSchema = require_geometry.BoxSchema;
20
24
  exports.COLOR_BLACK = require_color.COLOR_BLACK;
21
25
  exports.CONTENT_DEFS = require_content_json_schema_defs.CONTENT_DEFS;
22
26
  exports.CONTENT_DOCUMENT_URI = require_content_json_schema_defs.CONTENT_DOCUMENT_URI;
23
- exports.CONTENT_FORMAT_VERSION = require_content.CONTENT_FORMAT_VERSION;
24
27
  exports.ColorSchema = require_color.ColorSchema;
28
+ exports.ConstructDescriptorSchema = require_construct.ConstructDescriptorSchema;
25
29
  exports.ContentBlockSchema = require_content.ContentBlockSchema;
26
30
  exports.ContentBorderSchema = require_content.ContentBorderSchema;
27
31
  exports.ContentCellBordersSchema = require_content.ContentCellBordersSchema;
28
32
  exports.ContentCellValueSchema = require_content.ContentCellValueSchema;
33
+ exports.ContentControlDescriptorSchema = require_construct.ContentControlDescriptorSchema;
34
+ exports.ContentControlLockSchema = require_construct.ContentControlLockSchema;
35
+ exports.ContentControlTypeSchema = require_construct.ContentControlTypeSchema;
29
36
  exports.ContentDocumentSchema = require_content.ContentDocumentSchema;
30
37
  exports.ContentDrawPageSchema = require_content.ContentDrawPageSchema;
31
38
  exports.ContentEmbeddedObjectBlockSchema = require_content.ContentEmbeddedObjectBlockSchema;
@@ -58,29 +65,28 @@ exports.ContentTableRowSchema = require_content.ContentTableRowSchema;
58
65
  exports.ContentTableSchema = require_content.ContentTableSchema;
59
66
  exports.ContentVectorSchema = require_content.ContentVectorSchema;
60
67
  exports.DEFAULT_LAYOUT_FONT = require_style.DEFAULT_LAYOUT_FONT;
61
- exports.DOCUMENT_PACKAGE_FORMAT_VERSION = require_package.DOCUMENT_PACKAGE_FORMAT_VERSION;
62
68
  exports.DecimalStringSchema = require_content.DecimalStringSchema;
69
+ exports.DefinitionEntrySchema = require_definitions.DefinitionEntrySchema;
70
+ exports.DefinitionsTableSchema = require_definitions.DefinitionsTableSchema;
63
71
  exports.DimensionVectorSchema = require_math.DimensionVectorSchema;
72
+ exports.DivisionDescriptorSchema = require_construct.DivisionDescriptorSchema;
73
+ exports.DivisionSourceSchema = require_construct.DivisionSourceSchema;
64
74
  exports.DocumentPackageSchema = require_package.DocumentPackageSchema;
75
+ exports.DrawPageDescriptorSchema = require_package_node.DrawPageDescriptorSchema;
76
+ exports.DrawPageGroupSchema = require_package_node.DrawPageGroupSchema;
65
77
  exports.EMBEDDED_OBJECT_KINDS = require_content_json_schema_defs.EMBEDDED_OBJECT_KINDS;
66
78
  exports.ExactRationalSchema = require_math.ExactRationalSchema;
67
- exports.LAYOUT_FORMAT_VERSION = require_layout.LAYOUT_FORMAT_VERSION;
68
- exports.LayoutDocumentSchema = require_layout.LayoutDocumentSchema;
69
- exports.LayoutEllipseSchema = require_layout.LayoutEllipseSchema;
79
+ exports.FieldDescriptorSchema = require_construct.FieldDescriptorSchema;
80
+ exports.HeadingGroupSchema = require_package_node.HeadingGroupSchema;
81
+ exports.HeadingParagraphSchema = require_package_node.HeadingParagraphSchema;
70
82
  exports.LayoutFontSchema = require_style.LayoutFontSchema;
71
83
  exports.LayoutFrameSchema = require_geometry.LayoutFrameSchema;
72
- exports.LayoutImageAssetSchema = require_layout.LayoutImageAssetSchema;
73
- exports.LayoutImageSchema = require_layout.LayoutImageSchema;
74
- exports.LayoutItemSchema = require_layout.LayoutItemSchema;
75
- exports.LayoutLineSchema = require_layout.LayoutLineSchema;
76
- exports.LayoutLinkSchema = require_layout.LayoutLinkSchema;
77
84
  exports.LayoutMetadataSchema = require_metadata.LayoutMetadataSchema;
78
- exports.LayoutPageSchema = require_layout.LayoutPageSchema;
79
- exports.LayoutPathSchema = require_layout.LayoutPathSchema;
80
- exports.LayoutPathSegmentSchema = require_layout.LayoutPathSegmentSchema;
81
- exports.LayoutRectSchema = require_layout.LayoutRectSchema;
82
- exports.LayoutSubpathSchema = require_layout.LayoutSubpathSchema;
83
- exports.LayoutTextSchema = require_layout.LayoutTextSchema;
85
+ exports.LayoutSchemaDemotedError = require_schema_io.LayoutSchemaDemotedError;
86
+ exports.LinkDescriptorSchema = require_construct.LinkDescriptorSchema;
87
+ exports.LinkTargetSchema = require_construct.LinkTargetSchema;
88
+ exports.ListGroupSchema = require_package_node.ListGroupSchema;
89
+ exports.ListParagraphSchema = require_package_node.ListParagraphSchema;
84
90
  exports.MAX_SAFE_INTEGER = require_content_json_schema_defs.MAX_SAFE_INTEGER;
85
91
  exports.MarginsSchema = require_geometry.MarginsSchema;
86
92
  exports.MathAppSchema = require_math.MathAppSchema;
@@ -108,28 +114,64 @@ exports.MathUnitSchema = require_math.MathUnitSchema;
108
114
  exports.MathUnparsedSchema = require_math.MathUnparsedSchema;
109
115
  exports.PAGE_SIZE_A4 = require_geometry.PAGE_SIZE_A4;
110
116
  exports.PAGE_SIZE_LETTER = require_geometry.PAGE_SIZE_LETTER;
117
+ exports.PackageGroupSchema = require_package_node.PackageGroupSchema;
118
+ exports.PackageLeafSchema = require_package_node.PackageLeafSchema;
119
+ exports.PackageNodeSchema = require_package_node.PackageNodeSchema;
111
120
  exports.PageSizeSchema = require_geometry.PageSizeSchema;
121
+ exports.ProvenanceChangeSchema = require_construct.ProvenanceChangeSchema;
122
+ exports.ProvenanceDescriptorSchema = require_construct.ProvenanceDescriptorSchema;
112
123
  exports.SCHEMA_FILE_NAMES = require_schema_io.SCHEMA_FILE_NAMES;
113
124
  exports.SI_BASE_DIMENSIONS = require_math.SI_BASE_DIMENSIONS;
114
125
  exports.SLIDE_SIZE_STANDARD = require_geometry.SLIDE_SIZE_STANDARD;
115
126
  exports.SLIDE_SIZE_WIDESCREEN = require_geometry.SLIDE_SIZE_WIDESCREEN;
127
+ exports.SchemaVersionMismatchError = require_schema_io.SchemaVersionMismatchError;
128
+ exports.SectionConstructGroupSchema = require_package_node.SectionConstructGroupSchema;
129
+ exports.SectionDescriptorSchema = require_package_node.SectionDescriptorSchema;
130
+ exports.SectionGroupSchema = require_package_node.SectionGroupSchema;
131
+ exports.ShapeConstructGroupSchema = require_package_node.ShapeConstructGroupSchema;
132
+ exports.ShapeDescriptorSchema = require_package_node.ShapeDescriptorSchema;
133
+ exports.ShapeGroupSchema = require_package_node.ShapeGroupSchema;
134
+ exports.SheetDescriptorSchema = require_package_node.SheetDescriptorSchema;
135
+ exports.SheetGroupSchema = require_package_node.SheetGroupSchema;
136
+ exports.SlideDescriptorSchema = require_package_node.SlideDescriptorSchema;
137
+ exports.SlideGroupSchema = require_package_node.SlideGroupSchema;
138
+ exports.StyleEntrySchema = require_definitions.StyleEntrySchema;
139
+ exports.StyleParagraphPropertiesSchema = require_definitions.StyleParagraphPropertiesSchema;
140
+ exports.StyleRunPropertiesSchema = require_definitions.StyleRunPropertiesSchema;
141
+ exports.StylesTableSchema = require_definitions.StylesTableSchema;
116
142
  exports.SymbolTableSchema = require_math.SymbolTableSchema;
117
143
  exports.UnrecognizedDocumentSchemaError = require_schema_io.UnrecognizedDocumentSchemaError;
144
+ exports.applyParagraphStyleProperties = require_definitions.applyParagraphStyleProperties;
145
+ exports.applyRunStyleProperties = require_definitions.applyRunStyleProperties;
118
146
  exports.cellReference = require_a1.cellReference;
119
147
  exports.clampHeadingLevel = require_content.clampHeadingLevel;
120
148
  exports.colorToRgbHex = require_color.colorToRgbHex;
121
149
  exports.columnIndexToLetters = require_a1.columnIndexToLetters;
122
150
  exports.columnLettersToIndex = require_a1.columnLettersToIndex;
151
+ exports.contentDocumentSharedFields = require_content.contentDocumentSharedFields;
123
152
  exports.contentDocumentWithSchema = require_schema_io.contentDocumentWithSchema;
124
153
  exports.documentFromJson = require_schema_io.documentFromJson;
125
154
  exports.documentPackageWithSchema = require_schema_io.documentPackageWithSchema;
126
155
  exports.documentSchemaKindOf = require_schema_io.documentSchemaKindOf;
127
156
  exports.isContentBlock = require_content.isContentBlock;
157
+ exports.isDrawPageGroupNode = require_package_node.isDrawPageGroupNode;
158
+ exports.isHeadingGroupNode = require_package_node.isHeadingGroupNode;
159
+ exports.isListGroupNode = require_package_node.isListGroupNode;
128
160
  exports.isMathExpression = require_math.isMathExpression;
129
161
  exports.isMathMlNode = require_mathml.isMathMlNode;
130
- exports.layoutDocumentWithSchema = require_schema_io.layoutDocumentWithSchema;
162
+ exports.isPackageGroup = require_package_node.isPackageGroup;
163
+ exports.isPackageLeaf = require_package_node.isPackageLeaf;
164
+ exports.isPackageNode = require_package_node.isPackageNode;
165
+ exports.isSectionConstructGroupNode = require_package_node.isSectionConstructGroupNode;
166
+ exports.isSectionGroupNode = require_package_node.isSectionGroupNode;
167
+ exports.isShapeConstructGroupNode = require_package_node.isShapeConstructGroupNode;
168
+ exports.isShapeGroupNode = require_package_node.isShapeGroupNode;
169
+ exports.isSheetGroupNode = require_package_node.isSheetGroupNode;
170
+ exports.isSlideGroupNode = require_package_node.isSlideGroupNode;
171
+ exports.overlayStyleEntries = require_definitions.overlayStyleEntries;
131
172
  exports.parseCellReference = require_a1.parseCellReference;
132
173
  exports.parseRangeReference = require_a1.parseRangeReference;
133
174
  exports.rangeReference = require_a1.rangeReference;
175
+ exports.resolveStyleChain = require_definitions.resolveStyleChain;
134
176
  exports.rgbHexToColor = require_color.rgbHexToColor;
135
177
  exports.schemaUriFor = require_schema_io.schemaUriFor;