document-schema.js 1.9.0 → 1.10.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 (45) hide show
  1. package/README.md +36 -0
  2. package/dist/color-AELCDH_b.d.cts +13 -0
  3. package/dist/color-AELCDH_b.d.ts +13 -0
  4. package/dist/color.cjs +40 -0
  5. package/dist/color.d.cts +2 -0
  6. package/dist/color.d.ts +2 -0
  7. package/dist/color.js +36 -0
  8. package/dist/content.cjs +341 -0
  9. package/dist/content.d.cts +1188 -0
  10. package/dist/content.d.ts +1188 -0
  11. package/dist/content.js +309 -0
  12. package/dist/geometry-CokwQGtJ.d.cts +27 -0
  13. package/dist/geometry-CokwQGtJ.d.ts +27 -0
  14. package/dist/geometry.cjs +43 -0
  15. package/dist/geometry.d.cts +2 -0
  16. package/dist/geometry.d.ts +2 -0
  17. package/dist/geometry.js +36 -0
  18. package/dist/index.cjs +79 -684
  19. package/dist/index.d.cts +8 -2448
  20. package/dist/index.d.ts +8 -2448
  21. package/dist/index.js +8 -613
  22. package/dist/layout.cjs +147 -0
  23. package/dist/layout.d.cts +636 -0
  24. package/dist/layout.d.ts +636 -0
  25. package/dist/layout.js +133 -0
  26. package/dist/metadata.cjs +15 -0
  27. package/dist/metadata.d.cts +15 -0
  28. package/dist/metadata.d.ts +15 -0
  29. package/dist/metadata.js +14 -0
  30. package/dist/package.cjs +14 -0
  31. package/dist/package.d.cts +528 -0
  32. package/dist/package.d.ts +528 -0
  33. package/dist/package.js +12 -0
  34. package/dist/schema-io.cjs +87 -0
  35. package/dist/schema-io.d.cts +37 -0
  36. package/dist/schema-io.d.ts +37 -0
  37. package/dist/schema-io.js +79 -0
  38. package/dist/style.cjs +23 -0
  39. package/dist/style.d.cts +24 -0
  40. package/dist/style.d.ts +24 -0
  41. package/dist/style.js +20 -0
  42. package/package.json +10 -4
  43. package/schemas/content-document.schema.json +3 -3
  44. package/schemas/document-package.schema.json +3 -3
  45. package/schemas/layout-document.schema.json +1 -1
package/README.md CHANGED
@@ -6,6 +6,35 @@
6
6
 
7
7
  Both `ooxml.js` and `documents.js` independently arrived at the same content vocabulary -- paragraphs, runs, tables, images, shapes, slides -- because `documents.js`'s docx/pptx-to-PDF pipeline needed a richer model than `ooxml.js`'s own readers originally produced, and that model was later ported back into `ooxml.js` itself. The result was two field-identical copies maintained in two places. This package is the fix: one schema, imported by every format package instead of redefined by each. It also sidesteps a circular dependency that would otherwise appear once `odf.js` exists, since `documents.js` depends on both `ooxml.js` and `odf.js`.
8
8
 
9
+ ```mermaid
10
+ graph TD
11
+ schema("document-schema.js")
12
+ ooxml("ooxml.js")
13
+ odf("odf.js")
14
+ pdfcodec("pdf-codec")
15
+ documents("documents.js")
16
+ cli("document-cli")
17
+
18
+ schema --> ooxml
19
+ schema --> odf
20
+ schema --> pdfcodec
21
+ schema --> documents
22
+ ooxml --> documents
23
+ odf --> documents
24
+ pdfcodec --> documents
25
+ documents --> cli
26
+ odf --> cli
27
+
28
+ click schema "https://github.com/ExaDev/document-schema.js" "document-schema.js"
29
+ click ooxml "https://github.com/ExaDev/ooxml.js" "ooxml.js"
30
+ click odf "https://github.com/ExaDev/odf.js" "odf.js"
31
+ click pdfcodec "https://github.com/ExaDev/pdf-codec" "pdf-codec"
32
+ click documents "https://github.com/ExaDev/documents.js" "documents.js"
33
+ click cli "https://github.com/ExaDev/document-cli" "document-cli"
34
+
35
+ style schema fill:#f9a825,stroke:#333,stroke-width:3px
36
+ ```
37
+
9
38
  `ContentDocument` (the semantic pivot) is a discriminated union of four kinds: `wordprocessing` (docx/odt-style sections of paragraphs/runs/tables/images), `presentation` (pptx/odp-style slides of shapes), `spreadsheet` (xlsx/ods-style sheets of cells, columns, rows, and print settings), and `drawing` (odg-style pages of shapes plus vector primitives -- rect/ellipse/line/path). `ContentEmbeddedObjectSchema` lets any of the four embed another whole `ContentDocument`. `LayoutDocument` (the PDF-rendering pivot) is pages of positioned `LayoutItem`s -- `text`/`image`/`rect`/`line`/`ellipse`/`path`/`link` -- in PDF user-space coordinates, with `LayoutPathSchema` modelling a general vector path rather than only axis-aligned rectangles. `DocumentPackageSchema` is a small envelope pairing the two: `content` required, `layout` optional (it's a derived artifact, absent until something lays the content out), correlated via each item's own `sourcePath` when both are present -- a pairing this schema does not itself keep in sync or detect as stale.
10
39
 
11
40
  It contains only [Zod](https://zod.dev) schemas, their inferred types, and a handful of trivial schema-attached helpers (hex-colour conversion, a recursive structural type guard for the mutually-recursive table/block/embedded-object types). There is no XML, ZIP, PDF, or other binary handling here, and no `zod` dependency other than `zod` itself.
@@ -22,6 +51,13 @@ const layout = LayoutDocumentSchema.parse(somePageLayoutValue);
22
51
  const pkg = DocumentPackageSchema.parse({ formatVersion: 1, content, layout });
23
52
  ```
24
53
 
54
+ Every module is also importable directly, without going through the barrel above -- `tsdown` builds one file per source module rather than a single bundle, and `package.json`'s `"./*"` export makes each one individually resolvable by name:
55
+
56
+ ```ts
57
+ import { schemaUriFor } from 'document-schema.js/schema-io';
58
+ import { ColorSchema } from 'document-schema.js/color';
59
+ ```
60
+
25
61
  ## JSON Schema
26
62
 
27
63
  Alongside the Zod schemas/types above, the package publishes three plain [JSON Schema](https://json-schema.org) files -- generated from the same Zod definitions via [`z.toJSONSchema()`](https://zod.dev/json-schema) at build time (`scripts/generate-json-schemas.mjs`) -- for non-TypeScript consumers that want to validate against or generate types from these shapes without depending on Zod at all:
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ //#region src/color.d.ts
3
+ declare const ColorSchema: z.ZodObject<{
4
+ r: z.ZodNumber;
5
+ g: z.ZodNumber;
6
+ b: z.ZodNumber;
7
+ }, z.core.$strip>;
8
+ type Color = z.infer<typeof ColorSchema>;
9
+ declare const COLOR_BLACK: Color;
10
+ declare function rgbHexToColor(hex: string): Color;
11
+ declare function colorToRgbHex(color: Color): string;
12
+ //#endregion
13
+ export { rgbHexToColor as a, colorToRgbHex as i, Color as n, ColorSchema as r, COLOR_BLACK as t };
@@ -0,0 +1,13 @@
1
+ import { z } from "zod";
2
+ //#region src/color.d.ts
3
+ declare const ColorSchema: z.ZodObject<{
4
+ r: z.ZodNumber;
5
+ g: z.ZodNumber;
6
+ b: z.ZodNumber;
7
+ }, z.core.$strip>;
8
+ type Color = z.infer<typeof ColorSchema>;
9
+ declare const COLOR_BLACK: Color;
10
+ declare function rgbHexToColor(hex: string): Color;
11
+ declare function colorToRgbHex(color: Color): string;
12
+ //#endregion
13
+ export { rgbHexToColor as a, colorToRgbHex as i, Color as n, ColorSchema as r, COLOR_BLACK as t };
package/dist/color.cjs ADDED
@@ -0,0 +1,40 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let zod = require("zod");
3
+ //#region src/color.ts
4
+ const ColorSchema = zod.z.object({
5
+ r: zod.z.number().min(0).max(1),
6
+ g: zod.z.number().min(0).max(1),
7
+ b: zod.z.number().min(0).max(1)
8
+ });
9
+ const COLOR_BLACK = {
10
+ r: 0,
11
+ g: 0,
12
+ b: 0
13
+ };
14
+ const HEX_COLOR_PATTERN = /^#?([0-9a-fA-F]{6})$/;
15
+ const HEX_BYTE_MAX = 255;
16
+ function rgbHexToColor(hex) {
17
+ const match = HEX_COLOR_PATTERN.exec(hex);
18
+ if (match === null) throw new Error(`not a 6-digit hex colour: ${hex}`);
19
+ const digits = match[1];
20
+ if (digits === void 0) throw new Error(`not a 6-digit hex colour: ${hex}`);
21
+ const r = Number.parseInt(digits.slice(0, 2), 16);
22
+ const g = Number.parseInt(digits.slice(2, 4), 16);
23
+ const b = Number.parseInt(digits.slice(4, 6), 16);
24
+ return {
25
+ r: r / HEX_BYTE_MAX,
26
+ g: g / HEX_BYTE_MAX,
27
+ b: b / HEX_BYTE_MAX
28
+ };
29
+ }
30
+ function toHexByte(component) {
31
+ return Math.round(component * HEX_BYTE_MAX).toString(16).padStart(2, "0");
32
+ }
33
+ function colorToRgbHex(color) {
34
+ return `${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`;
35
+ }
36
+ //#endregion
37
+ exports.COLOR_BLACK = COLOR_BLACK;
38
+ exports.ColorSchema = ColorSchema;
39
+ exports.colorToRgbHex = colorToRgbHex;
40
+ exports.rgbHexToColor = rgbHexToColor;
@@ -0,0 +1,2 @@
1
+ import { a as rgbHexToColor, i as colorToRgbHex, n as Color, r as ColorSchema, t as COLOR_BLACK } from "./color-AELCDH_b.cjs";
2
+ export { COLOR_BLACK, Color, ColorSchema, colorToRgbHex, rgbHexToColor };
@@ -0,0 +1,2 @@
1
+ import { a as rgbHexToColor, i as colorToRgbHex, n as Color, r as ColorSchema, t as COLOR_BLACK } from "./color-AELCDH_b.js";
2
+ export { COLOR_BLACK, Color, ColorSchema, colorToRgbHex, rgbHexToColor };
package/dist/color.js ADDED
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ //#region src/color.ts
3
+ const ColorSchema = z.object({
4
+ r: z.number().min(0).max(1),
5
+ g: z.number().min(0).max(1),
6
+ b: z.number().min(0).max(1)
7
+ });
8
+ const COLOR_BLACK = {
9
+ r: 0,
10
+ g: 0,
11
+ b: 0
12
+ };
13
+ const HEX_COLOR_PATTERN = /^#?([0-9a-fA-F]{6})$/;
14
+ const HEX_BYTE_MAX = 255;
15
+ function rgbHexToColor(hex) {
16
+ const match = HEX_COLOR_PATTERN.exec(hex);
17
+ if (match === null) throw new Error(`not a 6-digit hex colour: ${hex}`);
18
+ const digits = match[1];
19
+ if (digits === void 0) throw new Error(`not a 6-digit hex colour: ${hex}`);
20
+ const r = Number.parseInt(digits.slice(0, 2), 16);
21
+ const g = Number.parseInt(digits.slice(2, 4), 16);
22
+ const b = Number.parseInt(digits.slice(4, 6), 16);
23
+ return {
24
+ r: r / HEX_BYTE_MAX,
25
+ g: g / HEX_BYTE_MAX,
26
+ b: b / HEX_BYTE_MAX
27
+ };
28
+ }
29
+ function toHexByte(component) {
30
+ return Math.round(component * HEX_BYTE_MAX).toString(16).padStart(2, "0");
31
+ }
32
+ function colorToRgbHex(color) {
33
+ return `${toHexByte(color.r)}${toHexByte(color.g)}${toHexByte(color.b)}`;
34
+ }
35
+ //#endregion
36
+ export { COLOR_BLACK, ColorSchema, colorToRgbHex, rgbHexToColor };
@@ -0,0 +1,341 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_color = require("./color.cjs");
3
+ const require_geometry = require("./geometry.cjs");
4
+ const require_metadata = require("./metadata.cjs");
5
+ const require_style = require("./style.cjs");
6
+ let zod = require("zod");
7
+ //#region src/content.ts
8
+ const ContentRunSchema = zod.z.object({
9
+ text: zod.z.string(),
10
+ bold: zod.z.boolean().optional(),
11
+ italic: zod.z.boolean().optional(),
12
+ underline: zod.z.boolean().optional(),
13
+ strike: zod.z.boolean().optional(),
14
+ fontFamily: zod.z.string().optional(),
15
+ sizePt: zod.z.number().positive().optional(),
16
+ color: require_color.ColorSchema.optional(),
17
+ hyperlink: zod.z.string().optional(),
18
+ sourcePath: zod.z.string().optional()
19
+ });
20
+ const ContentListMembershipSchema = zod.z.object({
21
+ numId: zod.z.string(),
22
+ level: zod.z.number().int().nonnegative()
23
+ });
24
+ const ContentParagraphSchema = zod.z.object({
25
+ kind: zod.z.literal("paragraph"),
26
+ runs: zod.z.array(ContentRunSchema),
27
+ styleId: zod.z.string().optional(),
28
+ alignment: require_style.AlignmentSchema.optional(),
29
+ list: ContentListMembershipSchema.optional(),
30
+ spacingBeforePt: zod.z.number().optional(),
31
+ spacingAfterPt: zod.z.number().optional(),
32
+ lineSpacing: zod.z.number().positive().optional(),
33
+ indentLeftPt: zod.z.number().optional(),
34
+ indentFirstLinePt: zod.z.number().optional(),
35
+ sourcePath: zod.z.string().optional()
36
+ });
37
+ const ContentImageBlockSchema = zod.z.object({
38
+ kind: zod.z.literal("image"),
39
+ format: zod.z.enum(["png", "jpeg"]),
40
+ base64: zod.z.string(),
41
+ widthPt: zod.z.number().positive(),
42
+ heightPt: zod.z.number().positive(),
43
+ altText: zod.z.string().optional(),
44
+ sourcePath: zod.z.string().optional()
45
+ });
46
+ const ContentPageBreakSchema = zod.z.object({
47
+ kind: zod.z.literal("pageBreak"),
48
+ sourcePath: zod.z.string().optional()
49
+ });
50
+ function isRecord(value) {
51
+ return typeof value === "object" && value !== null && !Array.isArray(value);
52
+ }
53
+ function isContentRun(value) {
54
+ return isRecord(value) && typeof value.text === "string";
55
+ }
56
+ function isContentTableCell(value) {
57
+ return isRecord(value) && Array.isArray(value.blocks) && value.blocks.every(isContentBlock);
58
+ }
59
+ function isContentTableRow(value) {
60
+ return isRecord(value) && Array.isArray(value.cells) && value.cells.every(isContentTableCell) && (value.heightPt === void 0 || typeof value.heightPt === "number");
61
+ }
62
+ function isContentEmbeddedObjectKind(value) {
63
+ return value === "formula" || value === "wordprocessing" || value === "presentation" || value === "spreadsheet" || value === "drawing";
64
+ }
65
+ function isContentEmbeddedObject(value) {
66
+ return isRecord(value) && isContentEmbeddedObjectKind(value.objectKind) && require_geometry.BoxSchema.safeParse(value.frame).success && ContentDocumentSchema.safeParse(value.document).success;
67
+ }
68
+ function isContentEmbeddedObjectBlock(value) {
69
+ return isRecord(value) && value.kind === "embeddedObject" && isContentEmbeddedObject(value);
70
+ }
71
+ function isContentBlock(value) {
72
+ if (!isRecord(value)) return false;
73
+ const kind = value.kind;
74
+ if (kind === "paragraph") return Array.isArray(value.runs) && value.runs.every(isContentRun);
75
+ if (kind === "image") return (value.format === "png" || value.format === "jpeg") && typeof value.base64 === "string" && typeof value.widthPt === "number" && typeof value.heightPt === "number";
76
+ if (kind === "pageBreak") return true;
77
+ if (kind === "table") return Array.isArray(value.rows) && value.rows.every(isContentTableRow) && Array.isArray(value.columnWidthsPt) && value.columnWidthsPt.every((w) => typeof w === "number");
78
+ if (kind === "embeddedObject") return isContentEmbeddedObject(value);
79
+ return false;
80
+ }
81
+ const ContentBlockSchema = zod.z.custom(isContentBlock);
82
+ const ContentEmbeddedObjectSchema = zod.z.custom(isContentEmbeddedObject);
83
+ const ContentEmbeddedObjectBlockSchema = zod.z.custom(isContentEmbeddedObjectBlock);
84
+ const ContentTableCellSchema = zod.z.object({
85
+ blocks: zod.z.array(ContentBlockSchema),
86
+ colSpan: zod.z.number().int().positive().optional(),
87
+ rowSpan: zod.z.number().int().positive().optional(),
88
+ background: require_color.ColorSchema.optional()
89
+ });
90
+ const ContentTableRowSchema = zod.z.object({
91
+ cells: zod.z.array(ContentTableCellSchema),
92
+ heightPt: zod.z.number().positive().optional()
93
+ });
94
+ const ContentTableSchema = zod.z.object({
95
+ kind: zod.z.literal("table"),
96
+ rows: zod.z.array(ContentTableRowSchema),
97
+ columnWidthsPt: zod.z.array(zod.z.number().positive()),
98
+ sourcePath: zod.z.string().optional()
99
+ });
100
+ const ContentSectionSchema = zod.z.object({
101
+ pageSize: require_geometry.PageSizeSchema,
102
+ margins: require_geometry.MarginsSchema,
103
+ blocks: zod.z.array(ContentBlockSchema)
104
+ });
105
+ const ContentShapeSchema = zod.z.object({
106
+ name: zod.z.string().optional(),
107
+ frame: require_geometry.BoxSchema,
108
+ rotationDeg: zod.z.number().optional(),
109
+ insetLeftPt: zod.z.number().nonnegative(),
110
+ insetTopPt: zod.z.number().nonnegative(),
111
+ insetRightPt: zod.z.number().nonnegative(),
112
+ insetBottomPt: zod.z.number().nonnegative(),
113
+ fontScale: zod.z.number().positive().optional(),
114
+ lineSpacingReduction: zod.z.number().nonnegative().optional(),
115
+ sourcePath: zod.z.string().optional(),
116
+ blocks: zod.z.array(ContentBlockSchema)
117
+ });
118
+ const ContentSlideSchema = zod.z.object({
119
+ size: require_geometry.PageSizeSchema,
120
+ shapes: zod.z.array(ContentShapeSchema),
121
+ notes: zod.z.string()
122
+ });
123
+ const ContentCellValueSchema = zod.z.discriminatedUnion("kind", [
124
+ zod.z.object({
125
+ kind: zod.z.literal("number"),
126
+ value: zod.z.number()
127
+ }),
128
+ zod.z.object({
129
+ kind: zod.z.literal("percentage"),
130
+ value: zod.z.number()
131
+ }),
132
+ zod.z.object({
133
+ kind: zod.z.literal("currency"),
134
+ value: zod.z.number(),
135
+ currency: zod.z.string().optional()
136
+ }),
137
+ zod.z.object({
138
+ kind: zod.z.literal("boolean"),
139
+ value: zod.z.boolean()
140
+ }),
141
+ zod.z.object({
142
+ kind: zod.z.literal("date"),
143
+ value: zod.z.string()
144
+ }),
145
+ zod.z.object({
146
+ kind: zod.z.literal("time"),
147
+ value: zod.z.string()
148
+ }),
149
+ zod.z.object({
150
+ kind: zod.z.literal("string"),
151
+ value: zod.z.string()
152
+ }),
153
+ zod.z.object({
154
+ kind: zod.z.literal("error"),
155
+ value: zod.z.string()
156
+ }),
157
+ zod.z.object({ kind: zod.z.literal("empty") })
158
+ ]);
159
+ const ContentSheetCellSchema = zod.z.object({
160
+ row: zod.z.number().int().nonnegative(),
161
+ column: zod.z.number().int().nonnegative(),
162
+ value: ContentCellValueSchema,
163
+ formula: zod.z.string().optional(),
164
+ displayText: zod.z.string(),
165
+ runs: zod.z.array(ContentRunSchema).optional(),
166
+ colSpan: zod.z.number().int().positive().optional(),
167
+ rowSpan: zod.z.number().int().positive().optional()
168
+ });
169
+ const ContentSheetColumnSchema = zod.z.object({
170
+ index: zod.z.number().int().nonnegative(),
171
+ widthPt: zod.z.number().nonnegative(),
172
+ hidden: zod.z.boolean().optional()
173
+ });
174
+ const ContentSheetRowSchema = zod.z.object({
175
+ index: zod.z.number().int().nonnegative(),
176
+ heightPt: zod.z.number().nonnegative(),
177
+ hidden: zod.z.boolean().optional()
178
+ });
179
+ const ContentSheetPrintRangeSchema = zod.z.object({
180
+ startRow: zod.z.number().int().nonnegative(),
181
+ startColumn: zod.z.number().int().nonnegative(),
182
+ endRow: zod.z.number().int().nonnegative(),
183
+ endColumn: zod.z.number().int().nonnegative()
184
+ });
185
+ const ContentSheetRepeatRangeSchema = zod.z.object({
186
+ start: zod.z.number().int().nonnegative(),
187
+ end: zod.z.number().int().nonnegative()
188
+ });
189
+ const ContentSheetPrintSettingsSchema = zod.z.object({
190
+ pageSize: require_geometry.PageSizeSchema,
191
+ margins: require_geometry.MarginsSchema,
192
+ printRange: ContentSheetPrintRangeSchema.optional(),
193
+ scale: zod.z.number().positive().optional(),
194
+ fitToPages: zod.z.object({
195
+ width: zod.z.number().int().positive(),
196
+ height: zod.z.number().int().positive()
197
+ }).optional(),
198
+ repeatRows: ContentSheetRepeatRangeSchema.optional(),
199
+ repeatColumns: ContentSheetRepeatRangeSchema.optional(),
200
+ gridlines: zod.z.boolean(),
201
+ headers: zod.z.boolean(),
202
+ pageOrder: zod.z.enum(["downThenOver", "overThenDown"]),
203
+ manualBreaks: zod.z.object({
204
+ rows: zod.z.array(zod.z.number().int().nonnegative()),
205
+ columns: zod.z.array(zod.z.number().int().nonnegative())
206
+ }).optional()
207
+ });
208
+ const ContentSheetImageSchema = ContentImageBlockSchema.extend({
209
+ anchorRow: zod.z.number().int().nonnegative(),
210
+ anchorColumn: zod.z.number().int().nonnegative(),
211
+ offsetXPt: zod.z.number(),
212
+ offsetYPt: zod.z.number()
213
+ });
214
+ const ContentSheetSchema = zod.z.object({
215
+ name: zod.z.string(),
216
+ cells: zod.z.array(ContentSheetCellSchema),
217
+ columns: zod.z.array(ContentSheetColumnSchema),
218
+ rows: zod.z.array(ContentSheetRowSchema),
219
+ images: zod.z.array(ContentSheetImageSchema),
220
+ printSettings: ContentSheetPrintSettingsSchema,
221
+ embeddedObjects: zod.z.array(ContentEmbeddedObjectSchema).optional()
222
+ });
223
+ const ContentStrokeSchema = zod.z.object({
224
+ color: require_color.ColorSchema,
225
+ widthPt: zod.z.number().positive()
226
+ });
227
+ const ContentPathPointSchema = zod.z.object({
228
+ xPt: zod.z.number(),
229
+ yPt: zod.z.number()
230
+ });
231
+ const ContentPathSegmentSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
232
+ kind: zod.z.literal("line"),
233
+ to: ContentPathPointSchema
234
+ }), zod.z.object({
235
+ kind: zod.z.literal("cubic"),
236
+ control1: ContentPathPointSchema,
237
+ control2: ContentPathPointSchema,
238
+ to: ContentPathPointSchema
239
+ })]);
240
+ const ContentSubpathSchema = zod.z.object({
241
+ start: ContentPathPointSchema,
242
+ segments: zod.z.array(ContentPathSegmentSchema),
243
+ closed: zod.z.boolean()
244
+ });
245
+ const ContentVectorSchema = zod.z.discriminatedUnion("kind", [
246
+ zod.z.object({
247
+ kind: zod.z.literal("rect"),
248
+ frame: require_geometry.BoxSchema,
249
+ fill: require_color.ColorSchema.optional(),
250
+ stroke: ContentStrokeSchema.optional(),
251
+ sourcePath: zod.z.string().optional()
252
+ }),
253
+ zod.z.object({
254
+ kind: zod.z.literal("ellipse"),
255
+ frame: require_geometry.BoxSchema,
256
+ fill: require_color.ColorSchema.optional(),
257
+ stroke: ContentStrokeSchema.optional(),
258
+ sourcePath: zod.z.string().optional()
259
+ }),
260
+ zod.z.object({
261
+ kind: zod.z.literal("line"),
262
+ from: ContentPathPointSchema,
263
+ to: ContentPathPointSchema,
264
+ stroke: ContentStrokeSchema,
265
+ sourcePath: zod.z.string().optional()
266
+ }),
267
+ zod.z.object({
268
+ kind: zod.z.literal("path"),
269
+ frame: require_geometry.BoxSchema,
270
+ subpaths: zod.z.array(ContentSubpathSchema),
271
+ fill: require_color.ColorSchema.optional(),
272
+ fillRule: zod.z.enum(["nonzero", "evenodd"]).optional(),
273
+ stroke: ContentStrokeSchema.optional(),
274
+ sourcePath: zod.z.string().optional()
275
+ })
276
+ ]);
277
+ const ContentDrawPageSchema = zod.z.object({
278
+ size: require_geometry.PageSizeSchema,
279
+ shapes: zod.z.array(ContentShapeSchema),
280
+ vectors: zod.z.array(ContentVectorSchema)
281
+ });
282
+ const CONTENT_FORMAT_VERSION = 1;
283
+ const ContentDocumentSchema = zod.z.discriminatedUnion("kind", [
284
+ zod.z.object({
285
+ kind: zod.z.literal("wordprocessing"),
286
+ formatVersion: zod.z.literal(1),
287
+ metadata: require_metadata.LayoutMetadataSchema,
288
+ sections: zod.z.array(ContentSectionSchema)
289
+ }),
290
+ zod.z.object({
291
+ kind: zod.z.literal("presentation"),
292
+ formatVersion: zod.z.literal(1),
293
+ metadata: require_metadata.LayoutMetadataSchema,
294
+ slides: zod.z.array(ContentSlideSchema)
295
+ }),
296
+ zod.z.object({
297
+ kind: zod.z.literal("spreadsheet"),
298
+ formatVersion: zod.z.literal(1),
299
+ metadata: require_metadata.LayoutMetadataSchema,
300
+ sheets: zod.z.array(ContentSheetSchema)
301
+ }),
302
+ zod.z.object({
303
+ kind: zod.z.literal("drawing"),
304
+ formatVersion: zod.z.literal(1),
305
+ metadata: require_metadata.LayoutMetadataSchema,
306
+ pages: zod.z.array(ContentDrawPageSchema)
307
+ })
308
+ ]);
309
+ //#endregion
310
+ exports.CONTENT_FORMAT_VERSION = CONTENT_FORMAT_VERSION;
311
+ exports.ContentBlockSchema = ContentBlockSchema;
312
+ exports.ContentCellValueSchema = ContentCellValueSchema;
313
+ exports.ContentDocumentSchema = ContentDocumentSchema;
314
+ exports.ContentDrawPageSchema = ContentDrawPageSchema;
315
+ exports.ContentEmbeddedObjectBlockSchema = ContentEmbeddedObjectBlockSchema;
316
+ exports.ContentEmbeddedObjectSchema = ContentEmbeddedObjectSchema;
317
+ exports.ContentImageBlockSchema = ContentImageBlockSchema;
318
+ exports.ContentListMembershipSchema = ContentListMembershipSchema;
319
+ exports.ContentPageBreakSchema = ContentPageBreakSchema;
320
+ exports.ContentParagraphSchema = ContentParagraphSchema;
321
+ exports.ContentPathPointSchema = ContentPathPointSchema;
322
+ exports.ContentPathSegmentSchema = ContentPathSegmentSchema;
323
+ exports.ContentRunSchema = ContentRunSchema;
324
+ exports.ContentSectionSchema = ContentSectionSchema;
325
+ exports.ContentShapeSchema = ContentShapeSchema;
326
+ exports.ContentSheetCellSchema = ContentSheetCellSchema;
327
+ exports.ContentSheetColumnSchema = ContentSheetColumnSchema;
328
+ exports.ContentSheetImageSchema = ContentSheetImageSchema;
329
+ exports.ContentSheetPrintRangeSchema = ContentSheetPrintRangeSchema;
330
+ exports.ContentSheetPrintSettingsSchema = ContentSheetPrintSettingsSchema;
331
+ exports.ContentSheetRepeatRangeSchema = ContentSheetRepeatRangeSchema;
332
+ exports.ContentSheetRowSchema = ContentSheetRowSchema;
333
+ exports.ContentSheetSchema = ContentSheetSchema;
334
+ exports.ContentSlideSchema = ContentSlideSchema;
335
+ exports.ContentStrokeSchema = ContentStrokeSchema;
336
+ exports.ContentSubpathSchema = ContentSubpathSchema;
337
+ exports.ContentTableCellSchema = ContentTableCellSchema;
338
+ exports.ContentTableRowSchema = ContentTableRowSchema;
339
+ exports.ContentTableSchema = ContentTableSchema;
340
+ exports.ContentVectorSchema = ContentVectorSchema;
341
+ exports.isContentBlock = isContentBlock;