document-content-model 4.3.2 → 7.6.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 (96) hide show
  1. package/README.md +274 -95
  2. package/dist/border-weight.cjs +26 -0
  3. package/dist/border-weight.d.cts +12 -0
  4. package/dist/border-weight.d.ts +12 -0
  5. package/dist/border-weight.js +23 -0
  6. package/dist/codec.d.cts +1 -1
  7. package/dist/codec.d.ts +1 -1
  8. package/dist/{construct-ETSlnMle.d.cts → construct-GVdTKrE7.d.cts} +242 -2
  9. package/dist/{construct-ETSlnMle.d.ts → construct-GVdTKrE7.d.ts} +242 -2
  10. package/dist/construct.cjs +13 -6
  11. package/dist/construct.d.cts +1 -1
  12. package/dist/construct.d.ts +1 -1
  13. package/dist/construct.js +13 -6
  14. package/dist/content-BCOxY0Eb.d.ts +10273 -0
  15. package/dist/content-BzkhrS6P.d.cts +10273 -0
  16. package/dist/content-json-schema-defs.cjs +1056 -189
  17. package/dist/content-json-schema-defs.js +1056 -189
  18. package/dist/content.cjs +514 -36
  19. package/dist/content.d.cts +2 -2
  20. package/dist/content.d.ts +2 -2
  21. package/dist/content.js +488 -37
  22. package/dist/decompose.cjs +7 -17
  23. package/dist/decompose.d.cts +5 -5
  24. package/dist/decompose.d.ts +5 -5
  25. package/dist/decompose.js +7 -17
  26. package/dist/definitions.cjs +5 -1
  27. package/dist/definitions.d.cts +37 -1
  28. package/dist/definitions.d.ts +37 -1
  29. package/dist/definitions.js +5 -1
  30. package/dist/factor-styles.cjs +14 -8
  31. package/dist/factor-styles.d.cts +6 -6
  32. package/dist/factor-styles.d.ts +6 -6
  33. package/dist/factor-styles.js +15 -9
  34. package/dist/flatten.cjs +5 -5
  35. package/dist/flatten.d.cts +4 -4
  36. package/dist/flatten.d.ts +4 -4
  37. package/dist/flatten.js +5 -5
  38. package/dist/font-port.d.cts +2 -2
  39. package/dist/font-port.d.ts +2 -2
  40. package/dist/index.cjs +54 -14
  41. package/dist/index.d.cts +14 -12
  42. package/dist/index.d.ts +14 -12
  43. package/dist/index.js +12 -10
  44. package/dist/{math-BlG8Tjk-.d.cts → math-BScHxedi.d.cts} +97 -14
  45. package/dist/{math-BlG8Tjk-.d.ts → math-BScHxedi.d.ts} +97 -14
  46. package/dist/math-layout.d.cts +6 -6
  47. package/dist/math-layout.d.ts +6 -6
  48. package/dist/math.cjs +32 -6
  49. package/dist/math.d.cts +2 -2
  50. package/dist/math.d.ts +2 -2
  51. package/dist/math.js +29 -7
  52. package/dist/{mathml-B1oTCtzc.d.cts → mathml-Czqc1mdZ.d.cts} +3 -3
  53. package/dist/{mathml-B1oTCtzc.d.ts → mathml-Czqc1mdZ.d.ts} +3 -3
  54. package/dist/mathml.cjs +9 -2
  55. package/dist/mathml.d.cts +1 -1
  56. package/dist/mathml.d.ts +1 -1
  57. package/dist/mathml.js +9 -2
  58. package/dist/metadata.cjs +12 -1
  59. package/dist/metadata.d.cts +13 -0
  60. package/dist/metadata.d.ts +13 -0
  61. package/dist/metadata.js +12 -1
  62. package/dist/package-node-C4mh1hLY.d.ts +1989 -0
  63. package/dist/package-node-RQMDBzwd.d.cts +1989 -0
  64. package/dist/package-node.cjs +21 -21
  65. package/dist/package-node.d.cts +2 -2
  66. package/dist/package-node.d.ts +2 -2
  67. package/dist/package-node.js +14 -14
  68. package/dist/package.cjs +5 -3
  69. package/dist/package.d.cts +253 -8
  70. package/dist/package.d.ts +253 -8
  71. package/dist/package.js +5 -3
  72. package/dist/schema-io.cjs +21 -11
  73. package/dist/schema-io.d.cts +13 -9
  74. package/dist/schema-io.d.ts +13 -9
  75. package/dist/schema-io.js +21 -12
  76. package/dist/source-Bas5ol6f.d.cts +43 -0
  77. package/dist/source-Bas5ol6f.d.ts +43 -0
  78. package/dist/source.cjs +27 -0
  79. package/dist/source.d.cts +2 -0
  80. package/dist/source.d.ts +2 -0
  81. package/dist/source.js +25 -0
  82. package/dist/style-D06NwxAJ.d.cts +29 -0
  83. package/dist/style-D06NwxAJ.d.ts +29 -0
  84. package/dist/style.cjs +2 -0
  85. package/dist/style.d.cts +2 -24
  86. package/dist/style.d.ts +2 -24
  87. package/dist/style.js +2 -1
  88. package/dist/text-layout.d.cts +1 -1
  89. package/dist/text-layout.d.ts +1 -1
  90. package/package.json +28 -29
  91. package/schemas/content-document.schema.json +6623 -1694
  92. package/schemas/{document-package.schema.json → document-tree.schema.json} +1826 -143
  93. package/dist/content-BLwxI5ba.d.cts +0 -2481
  94. package/dist/content-BdzcBsxm.d.ts +0 -2481
  95. package/dist/package-node-C-ewnL0v.d.cts +0 -459
  96. package/dist/package-node-D3scv-Cl.d.ts +0 -459
package/dist/content.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { ColorSchema } from "./color.js";
2
+ import { SourceResidueSchema } from "./source.js";
2
3
  import { ConstructDescriptorSchema } from "./construct.js";
3
4
  import { MathExpressionSchema, MathPresentationSchema, MathProvenanceSchema, SymbolTableSchema } from "./math.js";
4
- import { BoxSchema, LayoutFrameSchema, MarginsSchema, PageSizeSchema } from "./geometry.js";
5
5
  import { MathMlNodeSchema } from "./mathml.js";
6
+ import { BoxSchema, LayoutFrameSchema, MarginsSchema, PageSizeSchema } from "./geometry.js";
7
+ import { AlignmentSchema, TextDirectionSchema } from "./style.js";
6
8
  import { LayoutMetadataSchema } from "./metadata.js";
7
- import { AlignmentSchema } from "./style.js";
8
9
  import { z } from "zod";
9
10
  //#region src/content.ts
10
11
  const ContentRunSchema = z.object({
@@ -17,17 +18,55 @@ const ContentRunSchema = z.object({
17
18
  sizePt: z.number().positive().optional(),
18
19
  color: ColorSchema.optional(),
19
20
  hyperlink: z.string().optional(),
21
+ verticalAlign: z.enum(["superscript", "subscript"]).optional(),
22
+ direction: TextDirectionSchema.optional(),
20
23
  sourcePath: z.string().optional(),
24
+ source: SourceResidueSchema.optional(),
21
25
  frames: z.array(LayoutFrameSchema).optional()
22
26
  });
23
27
  const ContentListMembershipSchema = z.object({
24
28
  numId: z.string().optional(),
25
- level: z.number().int().nonnegative()
29
+ level: z.number().int().nonnegative(),
30
+ checked: z.boolean().optional(),
31
+ itemId: z.string().optional(),
32
+ format: z.enum([
33
+ "bullet",
34
+ "decimal",
35
+ "lowerLetter",
36
+ "upperLetter",
37
+ "lowerRoman",
38
+ "upperRoman"
39
+ ]).optional()
40
+ });
41
+ const RunConstructExtentSchema = z.object({
42
+ descriptor: ConstructDescriptorSchema,
43
+ startRun: z.number().int().nonnegative(),
44
+ endRun: z.number().int().nonnegative()
45
+ });
46
+ const ContentStrokeStyleSchema = z.enum([
47
+ "solid",
48
+ "dashed",
49
+ "dotted",
50
+ "double"
51
+ ]);
52
+ const ContentBorderSchema = z.object({
53
+ color: ColorSchema,
54
+ widthPt: z.number().positive(),
55
+ style: ContentStrokeStyleSchema.optional()
56
+ });
57
+ const ContentParagraphBordersSchema = z.object({
58
+ left: ContentBorderSchema.optional(),
59
+ right: ContentBorderSchema.optional(),
60
+ top: ContentBorderSchema.optional(),
61
+ bottom: ContentBorderSchema.optional()
26
62
  });
27
63
  const ContentParagraphSchema = z.object({
28
64
  kind: z.literal("paragraph"),
29
65
  runs: z.array(ContentRunSchema),
66
+ constructs: z.array(RunConstructExtentSchema).optional(),
30
67
  styleId: z.string().optional(),
68
+ codeLanguage: z.string().optional(),
69
+ preformatted: z.boolean().optional(),
31
70
  headingLevel: z.number().int().positive().optional(),
32
71
  alignment: AlignmentSchema.optional(),
33
72
  list: ContentListMembershipSchema.optional(),
@@ -35,26 +74,75 @@ const ContentParagraphSchema = z.object({
35
74
  spacingAfterPt: z.number().optional(),
36
75
  lineSpacing: z.number().positive().optional(),
37
76
  indentLeftPt: z.number().optional(),
77
+ indentRightPt: z.number().optional(),
38
78
  indentFirstLinePt: z.number().optional(),
79
+ direction: TextDirectionSchema.optional(),
80
+ pageBreakBefore: z.boolean().optional(),
81
+ pageBreakAfter: z.boolean().optional(),
82
+ borders: ContentParagraphBordersSchema.optional(),
39
83
  sourcePath: z.string().optional(),
84
+ source: SourceResidueSchema.optional(),
40
85
  frames: z.array(LayoutFrameSchema).optional()
41
86
  });
42
87
  function clampHeadingLevel(level) {
43
88
  return Math.min(6, Math.max(1, Math.round(level)));
44
89
  }
90
+ const ContentFloatOriginSchema = z.enum([
91
+ "page",
92
+ "margin",
93
+ "leftMargin",
94
+ "rightMargin",
95
+ "topMargin",
96
+ "bottomMargin",
97
+ "insideMargin",
98
+ "outsideMargin",
99
+ "column",
100
+ "character",
101
+ "paragraph",
102
+ "line",
103
+ "frame"
104
+ ]);
105
+ const ContentFloatAlignSchema = z.enum([
106
+ "left",
107
+ "right",
108
+ "top",
109
+ "bottom",
110
+ "center",
111
+ "inside",
112
+ "outside"
113
+ ]);
114
+ const ContentFloatAxisSchema = z.union([z.strictObject({
115
+ relativeTo: ContentFloatOriginSchema,
116
+ offsetPt: z.number()
117
+ }), z.strictObject({
118
+ relativeTo: ContentFloatOriginSchema,
119
+ align: ContentFloatAlignSchema
120
+ })]);
121
+ const ContentFloatPositionSchema = z.object({
122
+ horizontal: ContentFloatAxisSchema,
123
+ vertical: ContentFloatAxisSchema
124
+ });
45
125
  const ContentImageBlockSchema = z.object({
46
126
  kind: z.literal("image"),
47
- format: z.enum(["png", "jpeg"]),
127
+ format: z.enum([
128
+ "png",
129
+ "jpeg",
130
+ "svg",
131
+ "gif"
132
+ ]),
48
133
  base64: z.string(),
49
134
  widthPt: z.number().positive(),
50
135
  heightPt: z.number().positive(),
51
136
  altText: z.string().optional(),
137
+ floatPosition: ContentFloatPositionSchema.optional(),
52
138
  sourcePath: z.string().optional(),
139
+ source: SourceResidueSchema.optional(),
53
140
  frames: z.array(LayoutFrameSchema).optional()
54
141
  });
55
142
  const ContentPageBreakSchema = z.object({
56
143
  kind: z.literal("pageBreak"),
57
144
  sourcePath: z.string().optional(),
145
+ source: SourceResidueSchema.optional(),
58
146
  frames: z.array(LayoutFrameSchema).optional()
59
147
  });
60
148
  const ContentConstructStartSchema = z.object({
@@ -75,24 +163,29 @@ function isContentTableRow(value) {
75
163
  return isRecord(value) && Array.isArray(value.cells) && value.cells.every(isContentTableCell) && (value.heightPt === void 0 || typeof value.heightPt === "number");
76
164
  }
77
165
  function isContentEmbeddedObjectKind(value) {
78
- return value === "formula" || value === "wordprocessing" || value === "presentation" || value === "spreadsheet" || value === "drawing";
166
+ return value === "formula" || value === "wordprocessing" || value === "presentation" || value === "spreadsheet" || value === "drawing" || value === "chart";
79
167
  }
80
168
  function isContentEmbeddedObject(value) {
81
169
  return isRecord(value) && isContentEmbeddedObjectKind(value.objectKind) && BoxSchema.safeParse(value.frame).success && ContentDocumentSchema.safeParse(value.document).success && (value.anchorRow === void 0 || typeof value.anchorRow === "number" && Number.isInteger(value.anchorRow) && value.anchorRow >= 0) && (value.anchorColumn === void 0 || typeof value.anchorColumn === "number" && Number.isInteger(value.anchorColumn) && value.anchorColumn >= 0) && (value.offsetXPt === void 0 || typeof value.offsetXPt === "number") && (value.offsetYPt === void 0 || typeof value.offsetYPt === "number");
82
170
  }
83
- function isContentEmbeddedObjectBlock(value) {
84
- return isRecord(value) && value.kind === "embeddedObject" && isContentEmbeddedObject(value);
85
- }
86
171
  function isContentConstructStart(value) {
87
172
  return isRecord(value) && value.kind === "constructStart" && ConstructDescriptorSchema.safeParse(value.descriptor).success;
88
173
  }
89
174
  function isContentConstructEnd(value) {
90
175
  return isRecord(value) && value.kind === "constructEnd";
91
176
  }
177
+ function isRunConstructExtent(value) {
178
+ if (!isRecord(value)) return false;
179
+ if (!ConstructDescriptorSchema.safeParse(value.descriptor).success) return false;
180
+ return isValidRunBound(value.startRun) && isValidRunBound(value.endRun);
181
+ }
182
+ function isValidRunBound(value) {
183
+ return typeof value === "number" && Number.isInteger(value) && value >= 0;
184
+ }
92
185
  function isContentBlock(value) {
93
186
  if (!isRecord(value)) return false;
94
187
  const kind = value.kind;
95
- if (kind === "paragraph") return Array.isArray(value.runs) && value.runs.every(isContentRun);
188
+ if (kind === "paragraph") return Array.isArray(value.runs) && value.runs.every(isContentRun) && (value.constructs === void 0 || Array.isArray(value.constructs) && value.constructs.every(isRunConstructExtent));
96
189
  if (kind === "image") return (value.format === "png" || value.format === "jpeg") && typeof value.base64 === "string" && typeof value.widthPt === "number" && typeof value.heightPt === "number";
97
190
  if (kind === "pageBreak") return true;
98
191
  if (kind === "table") return Array.isArray(value.rows) && value.rows.every(isContentTableRow) && Array.isArray(value.columnWidthsPt) && value.columnWidthsPt.every((w) => typeof w === "number");
@@ -101,9 +194,30 @@ function isContentBlock(value) {
101
194
  if (kind === "constructEnd") return true;
102
195
  return false;
103
196
  }
104
- const ContentBlockSchema = z.custom(isContentBlock);
105
- const ContentEmbeddedObjectSchema = z.custom(isContentEmbeddedObject);
106
- const ContentEmbeddedObjectBlockSchema = z.custom(isContentEmbeddedObjectBlock);
197
+ const CONTENT_EMBEDDED_OBJECT_FIELDS = {
198
+ objectKind: z.enum([
199
+ "formula",
200
+ "wordprocessing",
201
+ "presentation",
202
+ "spreadsheet",
203
+ "drawing",
204
+ "chart"
205
+ ]),
206
+ document: z.lazy(() => ContentDocumentSchema),
207
+ frame: BoxSchema,
208
+ anchorRow: z.number().int().nonnegative().optional(),
209
+ anchorColumn: z.number().int().nonnegative().optional(),
210
+ offsetXPt: z.number().optional(),
211
+ offsetYPt: z.number().optional(),
212
+ source: SourceResidueSchema.optional()
213
+ };
214
+ const ContentEmbeddedObjectSchema = z.object(CONTENT_EMBEDDED_OBJECT_FIELDS);
215
+ const ContentEmbeddedObjectBlockSchema = z.object({
216
+ kind: z.literal("embeddedObject"),
217
+ ...CONTENT_EMBEDDED_OBJECT_FIELDS,
218
+ sourcePath: z.string().optional(),
219
+ frames: z.array(LayoutFrameSchema).optional()
220
+ });
107
221
  function findConstructMarkerImbalance(blocks) {
108
222
  const openStartIndices = [];
109
223
  for (const [index, block] of blocks.entries()) if (isContentConstructStart(block)) openStartIndices.push(index);
@@ -117,47 +231,153 @@ function findConstructMarkerImbalance(blocks) {
117
231
  index: outermostUnclosed
118
232
  };
119
233
  }
120
- const ContentStrokeStyleSchema = z.enum([
121
- "solid",
122
- "dashed",
123
- "dotted",
124
- "double"
125
- ]);
126
- const ContentBorderSchema = z.object({
127
- color: ColorSchema,
128
- widthPt: z.number().positive(),
129
- style: ContentStrokeStyleSchema.optional()
130
- });
234
+ function findRunConstructFault(paragraph) {
235
+ const constructs = paragraph.constructs;
236
+ if (constructs === void 0) return void 0;
237
+ for (const [index, extent] of constructs.entries()) {
238
+ if (extent.startRun > extent.endRun) return {
239
+ kind: "invertedRange",
240
+ index
241
+ };
242
+ if (extent.startRun < 0 || extent.endRun > paragraph.runs.length) return {
243
+ kind: "beyondRuns",
244
+ index
245
+ };
246
+ }
247
+ }
131
248
  const ContentCellBordersSchema = z.object({
132
249
  left: ContentBorderSchema.optional(),
133
250
  right: ContentBorderSchema.optional(),
134
251
  top: ContentBorderSchema.optional(),
135
- bottom: ContentBorderSchema.optional()
252
+ bottom: ContentBorderSchema.optional(),
253
+ diagonalUp: ContentBorderSchema.optional(),
254
+ diagonalDown: ContentBorderSchema.optional()
136
255
  });
256
+ const ContentCellPatternTypeSchema = z.enum([
257
+ "percent5",
258
+ "percent10",
259
+ "percent12",
260
+ "percent15",
261
+ "percent20",
262
+ "percent25",
263
+ "percent30",
264
+ "percent35",
265
+ "percent37",
266
+ "percent40",
267
+ "percent45",
268
+ "percent50",
269
+ "percent55",
270
+ "percent60",
271
+ "percent62",
272
+ "percent65",
273
+ "percent70",
274
+ "percent75",
275
+ "percent80",
276
+ "percent85",
277
+ "percent87",
278
+ "percent90",
279
+ "percent95",
280
+ "horizontalStripe",
281
+ "verticalStripe",
282
+ "diagonalStripe",
283
+ "reverseDiagonalStripe",
284
+ "horizontalCross",
285
+ "diagonalCross",
286
+ "thinHorizontalStripe",
287
+ "thinVerticalStripe",
288
+ "thinDiagonalStripe",
289
+ "thinReverseDiagonalStripe",
290
+ "thinHorizontalCross",
291
+ "thinDiagonalCross",
292
+ "mediumGray",
293
+ "darkGray",
294
+ "lightGray",
295
+ "darkHorizontal",
296
+ "darkVertical",
297
+ "darkDown",
298
+ "darkUp",
299
+ "darkGrid",
300
+ "darkTrellis",
301
+ "lightHorizontal",
302
+ "lightVertical",
303
+ "lightDown",
304
+ "lightUp",
305
+ "lightGrid",
306
+ "lightTrellis",
307
+ "gray125",
308
+ "gray0625"
309
+ ]);
310
+ const ContentCellFillSchema = z.discriminatedUnion("kind", [z.object({
311
+ kind: z.literal("solid"),
312
+ color: ColorSchema
313
+ }), z.object({
314
+ kind: z.literal("pattern"),
315
+ patternType: ContentCellPatternTypeSchema,
316
+ foregroundColor: ColorSchema.optional(),
317
+ backgroundColor: ColorSchema.optional()
318
+ })]);
319
+ function resolveCellFillColor(fill) {
320
+ return fill.kind === "solid" ? fill.color : fill.foregroundColor ?? fill.backgroundColor;
321
+ }
322
+ function unrecognizedFillKind(fill) {
323
+ return String(fill.kind);
324
+ }
137
325
  const ContentTableCellSchema = z.object({
138
- blocks: z.array(ContentBlockSchema),
326
+ blocks: z.lazy(() => z.array(ContentBlockSchema)),
139
327
  colSpan: z.number().int().positive().optional(),
140
328
  rowSpan: z.number().int().positive().optional(),
141
- background: ColorSchema.optional(),
329
+ background: ContentCellFillSchema.optional(),
142
330
  borders: ContentCellBordersSchema.optional(),
331
+ verticalAlign: z.enum([
332
+ "top",
333
+ "center",
334
+ "bottom"
335
+ ]).optional(),
336
+ formula: z.string().optional(),
143
337
  sourcePath: z.string().optional(),
338
+ source: SourceResidueSchema.optional(),
144
339
  frames: z.array(LayoutFrameSchema).optional()
145
340
  });
146
341
  const ContentTableRowSchema = z.object({
147
342
  cells: z.array(ContentTableCellSchema),
148
- heightPt: z.number().positive().optional()
343
+ heightPt: z.number().positive().optional(),
344
+ direction: TextDirectionSchema.optional()
149
345
  });
150
346
  const ContentTableSchema = z.object({
151
347
  kind: z.literal("table"),
152
348
  rows: z.array(ContentTableRowSchema),
153
- columnWidthsPt: z.array(z.number().positive()),
349
+ columnWidthsPt: z.array(z.number().nonnegative()),
154
350
  sourcePath: z.string().optional(),
351
+ source: SourceResidueSchema.optional(),
155
352
  frames: z.array(LayoutFrameSchema).optional()
156
353
  });
354
+ const ContentBlockSchema = z.discriminatedUnion("kind", [
355
+ ContentParagraphSchema,
356
+ ContentTableSchema,
357
+ ContentImageBlockSchema,
358
+ ContentPageBreakSchema,
359
+ ContentEmbeddedObjectBlockSchema,
360
+ ContentConstructStartSchema,
361
+ ContentConstructEndSchema
362
+ ]);
363
+ const ContentPageFurnitureSchema = z.object({
364
+ default: z.lazy(() => z.array(ContentBlockSchema)).optional(),
365
+ even: z.lazy(() => z.array(ContentBlockSchema)).optional(),
366
+ first: z.lazy(() => z.array(ContentBlockSchema)).optional()
367
+ });
157
368
  const ContentSectionSchema = z.object({
158
369
  pageSize: PageSizeSchema,
159
370
  margins: MarginsSchema,
160
- blocks: z.array(ContentBlockSchema)
371
+ blocks: z.lazy(() => z.array(ContentBlockSchema)),
372
+ breakType: z.enum([
373
+ "nextPage",
374
+ "continuous",
375
+ "evenPage",
376
+ "oddPage"
377
+ ]).optional(),
378
+ headers: ContentPageFurnitureSchema.optional(),
379
+ footers: ContentPageFurnitureSchema.optional(),
380
+ source: SourceResidueSchema.optional()
161
381
  });
162
382
  const ContentShapeSchema = z.object({
163
383
  name: z.string().optional(),
@@ -171,13 +391,15 @@ const ContentShapeSchema = z.object({
171
391
  lineSpacingReduction: z.number().nonnegative().optional(),
172
392
  paintOrder: z.number().optional(),
173
393
  sourcePath: z.string().optional(),
394
+ source: SourceResidueSchema.optional(),
174
395
  frames: z.array(LayoutFrameSchema).optional(),
175
- blocks: z.array(ContentBlockSchema)
396
+ blocks: z.lazy(() => z.array(ContentBlockSchema))
176
397
  });
177
398
  const ContentSlideSchema = z.object({
178
399
  size: PageSizeSchema,
179
400
  shapes: z.array(ContentShapeSchema),
180
- notes: z.string()
401
+ notes: z.string(),
402
+ source: SourceResidueSchema.optional()
181
403
  });
182
404
  const DecimalStringSchema = z.string().regex(/^-?(0|[1-9]\d*)(\.\d+)?$/);
183
405
  const ContentCellValueSchema = z.discriminatedUnion("kind", [
@@ -238,10 +460,11 @@ const ContentSheetCellSchema = z.object({
238
460
  value: ContentCellValueSchema,
239
461
  formula: z.string().optional(),
240
462
  displayText: z.string(),
463
+ numberFormatCode: z.string().optional(),
241
464
  runs: z.array(ContentRunSchema).optional(),
242
465
  colSpan: z.number().int().positive().optional(),
243
466
  rowSpan: z.number().int().positive().optional(),
244
- background: ColorSchema.optional(),
467
+ background: ContentCellFillSchema.optional(),
245
468
  borders: ContentCellBordersSchema.optional(),
246
469
  alignment: AlignmentSchema.optional(),
247
470
  verticalAlignment: z.enum([
@@ -251,6 +474,7 @@ const ContentSheetCellSchema = z.object({
251
474
  ]).optional(),
252
475
  comment: ContentSheetCellCommentSchema.optional(),
253
476
  sourcePath: z.string().optional(),
477
+ source: SourceResidueSchema.optional(),
254
478
  frames: z.array(LayoutFrameSchema).optional()
255
479
  });
256
480
  const ContentSheetColumnSchema = z.object({
@@ -292,6 +516,167 @@ const ContentSheetPrintSettingsSchema = z.object({
292
516
  columns: z.array(z.number().int().nonnegative())
293
517
  }).optional()
294
518
  });
519
+ const ContentSheetRangeSchema = z.object({
520
+ startRow: z.number().int().nonnegative(),
521
+ startColumn: z.number().int().nonnegative(),
522
+ endRow: z.number().int().nonnegative(),
523
+ endColumn: z.number().int().nonnegative()
524
+ });
525
+ const SheetRuleOperatorSchema = z.enum([
526
+ "between",
527
+ "notBetween",
528
+ "equal",
529
+ "notEqual",
530
+ "greaterThan",
531
+ "greaterThanOrEqual",
532
+ "lessThan",
533
+ "lessThanOrEqual"
534
+ ]);
535
+ const ContentSheetDataValidationTypeSchema = z.enum([
536
+ "whole",
537
+ "decimal",
538
+ "list",
539
+ "date",
540
+ "time",
541
+ "textLength",
542
+ "custom"
543
+ ]);
544
+ const ContentSheetDataValidationSchema = z.object({
545
+ ranges: z.array(ContentSheetRangeSchema),
546
+ type: ContentSheetDataValidationTypeSchema,
547
+ operator: SheetRuleOperatorSchema.optional(),
548
+ formula1: z.string().optional(),
549
+ formula2: z.string().optional(),
550
+ allowBlank: z.boolean().optional(),
551
+ showInputMessage: z.boolean().optional(),
552
+ promptTitle: z.string().optional(),
553
+ prompt: z.string().optional(),
554
+ showErrorMessage: z.boolean().optional(),
555
+ errorStyle: z.enum([
556
+ "stop",
557
+ "warning",
558
+ "information"
559
+ ]).optional(),
560
+ errorTitle: z.string().optional(),
561
+ error: z.string().optional(),
562
+ source: SourceResidueSchema.optional()
563
+ });
564
+ const ContentSheetConditionalFormatStyleSchema = z.object({
565
+ textColor: ColorSchema.optional(),
566
+ background: ColorSchema.optional(),
567
+ source: SourceResidueSchema.optional()
568
+ });
569
+ const cfvoTypeSchema = z.enum([
570
+ "num",
571
+ "percent",
572
+ "max",
573
+ "min",
574
+ "formula",
575
+ "percentile"
576
+ ]);
577
+ const ContentSheetConditionalFormatValueSchema = z.object({
578
+ type: cfvoTypeSchema,
579
+ value: z.string().optional()
580
+ });
581
+ const conditionalFormatCommonFields = {
582
+ ranges: z.array(ContentSheetRangeSchema),
583
+ priority: z.number().int().optional(),
584
+ stopIfTrue: z.boolean().optional(),
585
+ source: SourceResidueSchema.optional()
586
+ };
587
+ const ContentSheetConditionalFormatSchema = z.discriminatedUnion("type", [
588
+ z.object({
589
+ type: z.literal("cellIs"),
590
+ ...conditionalFormatCommonFields,
591
+ operator: SheetRuleOperatorSchema,
592
+ formula1: z.string(),
593
+ formula2: z.string().optional(),
594
+ style: ContentSheetConditionalFormatStyleSchema.optional()
595
+ }),
596
+ z.object({
597
+ type: z.enum([
598
+ "containsText",
599
+ "notContainsText",
600
+ "beginsWith",
601
+ "endsWith"
602
+ ]),
603
+ ...conditionalFormatCommonFields,
604
+ text: z.string(),
605
+ style: ContentSheetConditionalFormatStyleSchema.optional()
606
+ }),
607
+ z.object({
608
+ type: z.enum([
609
+ "containsBlanks",
610
+ "notContainsBlanks",
611
+ "containsErrors",
612
+ "notContainsErrors",
613
+ "uniqueValues",
614
+ "duplicateValues"
615
+ ]),
616
+ ...conditionalFormatCommonFields,
617
+ style: ContentSheetConditionalFormatStyleSchema.optional()
618
+ }),
619
+ z.object({
620
+ type: z.literal("top10"),
621
+ ...conditionalFormatCommonFields,
622
+ rank: z.number().positive(),
623
+ percent: z.boolean().optional(),
624
+ bottom: z.boolean().optional(),
625
+ style: ContentSheetConditionalFormatStyleSchema.optional()
626
+ }),
627
+ z.object({
628
+ type: z.literal("aboveAverage"),
629
+ ...conditionalFormatCommonFields,
630
+ aboveAverage: z.boolean().optional(),
631
+ equalAverage: z.boolean().optional(),
632
+ stdDev: z.number().int().positive().optional(),
633
+ style: ContentSheetConditionalFormatStyleSchema.optional()
634
+ }),
635
+ z.object({
636
+ type: z.literal("timePeriod"),
637
+ ...conditionalFormatCommonFields,
638
+ timePeriod: z.enum([
639
+ "yesterday",
640
+ "today",
641
+ "tomorrow",
642
+ "last7Days",
643
+ "thisMonth",
644
+ "lastMonth",
645
+ "nextMonth",
646
+ "thisWeek",
647
+ "lastWeek",
648
+ "nextWeek",
649
+ "thisYear",
650
+ "lastYear",
651
+ "nextYear"
652
+ ]),
653
+ style: ContentSheetConditionalFormatStyleSchema.optional()
654
+ }),
655
+ z.object({
656
+ type: z.literal("colorScale"),
657
+ ...conditionalFormatCommonFields,
658
+ stops: z.array(z.object({
659
+ value: ContentSheetConditionalFormatValueSchema,
660
+ color: ColorSchema
661
+ })).min(2).max(3)
662
+ }),
663
+ z.object({
664
+ type: z.literal("dataBar"),
665
+ ...conditionalFormatCommonFields,
666
+ min: ContentSheetConditionalFormatValueSchema,
667
+ max: ContentSheetConditionalFormatValueSchema,
668
+ color: ColorSchema,
669
+ showValue: z.boolean().optional()
670
+ }),
671
+ z.object({
672
+ type: z.literal("iconSet"),
673
+ ...conditionalFormatCommonFields,
674
+ iconSetType: z.string(),
675
+ thresholds: z.array(ContentSheetConditionalFormatValueSchema),
676
+ reverse: z.boolean().optional(),
677
+ showValue: z.boolean().optional()
678
+ })
679
+ ]);
295
680
  const ContentSheetImageSchema = ContentImageBlockSchema.extend({
296
681
  anchorRow: z.number().int().nonnegative(),
297
682
  anchorColumn: z.number().int().nonnegative(),
@@ -305,13 +690,67 @@ const ContentSheetSchema = z.object({
305
690
  rows: z.array(ContentSheetRowSchema),
306
691
  images: z.array(ContentSheetImageSchema),
307
692
  printSettings: ContentSheetPrintSettingsSchema,
308
- embeddedObjects: z.array(ContentEmbeddedObjectSchema).optional()
693
+ embeddedObjects: z.array(ContentEmbeddedObjectSchema).optional(),
694
+ dataValidations: z.array(ContentSheetDataValidationSchema).optional(),
695
+ conditionalFormats: z.array(ContentSheetConditionalFormatSchema).optional(),
696
+ source: SourceResidueSchema.optional()
697
+ });
698
+ const ContentStrokeDashSchema = z.object({
699
+ dots1: z.number().int().positive(),
700
+ dots1LengthPt: z.number().positive(),
701
+ dots2: z.number().int().positive().optional(),
702
+ dots2LengthPt: z.number().positive().optional(),
703
+ distancePt: z.number().nonnegative()
309
704
  });
310
705
  const ContentStrokeSchema = z.object({
311
706
  color: ColorSchema,
312
707
  widthPt: z.number().positive(),
313
- style: ContentStrokeStyleSchema.optional()
708
+ style: ContentStrokeStyleSchema.optional(),
709
+ opacity: z.number().min(0).max(1).optional(),
710
+ dashPattern: ContentStrokeDashSchema.optional()
711
+ });
712
+ const ContentGradientStyleSchema = z.enum([
713
+ "linear",
714
+ "axial",
715
+ "radial",
716
+ "ellipsoid",
717
+ "square",
718
+ "rectangular"
719
+ ]);
720
+ const ContentGradientFillSchema = z.object({
721
+ kind: z.literal("gradient"),
722
+ style: ContentGradientStyleSchema,
723
+ startColor: ColorSchema,
724
+ endColor: ColorSchema,
725
+ angleDeg: z.number().optional()
726
+ });
727
+ const ContentHatchStyleSchema = z.enum([
728
+ "single",
729
+ "double",
730
+ "triple"
731
+ ]);
732
+ const ContentHatchFillSchema = z.object({
733
+ kind: z.literal("hatch"),
734
+ style: ContentHatchStyleSchema,
735
+ color: ColorSchema,
736
+ distancePt: z.number().nonnegative(),
737
+ rotationDeg: z.number().optional()
738
+ });
739
+ const ContentBitmapFillSchema = z.object({
740
+ kind: z.literal("bitmap"),
741
+ format: z.enum([
742
+ "png",
743
+ "jpeg",
744
+ "svg",
745
+ "gif"
746
+ ]),
747
+ base64: z.string()
314
748
  });
749
+ const ContentFillPatternSchema = z.discriminatedUnion("kind", [
750
+ ContentGradientFillSchema,
751
+ ContentHatchFillSchema,
752
+ ContentBitmapFillSchema
753
+ ]);
315
754
  const ContentPathPointSchema = z.object({
316
755
  xPt: z.number(),
317
756
  yPt: z.number()
@@ -336,9 +775,12 @@ const ContentVectorSchema = z.discriminatedUnion("kind", [
336
775
  frame: BoxSchema,
337
776
  rotationDeg: z.number().optional(),
338
777
  fill: ColorSchema.optional(),
778
+ fillPattern: ContentFillPatternSchema.optional(),
779
+ fillOpacity: z.number().min(0).max(1).optional(),
339
780
  stroke: ContentStrokeSchema.optional(),
340
781
  paintOrder: z.number().optional(),
341
782
  sourcePath: z.string().optional(),
783
+ source: SourceResidueSchema.optional(),
342
784
  frames: z.array(LayoutFrameSchema).optional()
343
785
  }),
344
786
  z.object({
@@ -346,9 +788,12 @@ const ContentVectorSchema = z.discriminatedUnion("kind", [
346
788
  frame: BoxSchema,
347
789
  rotationDeg: z.number().optional(),
348
790
  fill: ColorSchema.optional(),
791
+ fillPattern: ContentFillPatternSchema.optional(),
792
+ fillOpacity: z.number().min(0).max(1).optional(),
349
793
  stroke: ContentStrokeSchema.optional(),
350
794
  paintOrder: z.number().optional(),
351
795
  sourcePath: z.string().optional(),
796
+ source: SourceResidueSchema.optional(),
352
797
  frames: z.array(LayoutFrameSchema).optional()
353
798
  }),
354
799
  z.object({
@@ -358,6 +803,7 @@ const ContentVectorSchema = z.discriminatedUnion("kind", [
358
803
  stroke: ContentStrokeSchema,
359
804
  paintOrder: z.number().optional(),
360
805
  sourcePath: z.string().optional(),
806
+ source: SourceResidueSchema.optional(),
361
807
  frames: z.array(LayoutFrameSchema).optional()
362
808
  }),
363
809
  z.object({
@@ -366,24 +812,29 @@ const ContentVectorSchema = z.discriminatedUnion("kind", [
366
812
  rotationDeg: z.number().optional(),
367
813
  subpaths: z.array(ContentSubpathSchema),
368
814
  fill: ColorSchema.optional(),
815
+ fillPattern: ContentFillPatternSchema.optional(),
816
+ fillOpacity: z.number().min(0).max(1).optional(),
369
817
  fillRule: z.enum(["nonzero", "evenodd"]).optional(),
370
818
  stroke: ContentStrokeSchema.optional(),
371
819
  paintOrder: z.number().optional(),
372
820
  sourcePath: z.string().optional(),
821
+ source: SourceResidueSchema.optional(),
373
822
  frames: z.array(LayoutFrameSchema).optional()
374
823
  })
375
824
  ]);
376
825
  const ContentDrawPageSchema = z.object({
377
826
  size: PageSizeSchema,
378
827
  shapes: z.array(ContentShapeSchema),
379
- vectors: z.array(ContentVectorSchema)
828
+ vectors: z.array(ContentVectorSchema),
829
+ source: SourceResidueSchema.optional()
380
830
  });
381
831
  const ContentFormulaSchema = z.object({
382
832
  mathml: z.array(MathMlNodeSchema),
383
833
  starMath: z.string().optional(),
384
834
  presentation: MathPresentationSchema.optional(),
385
835
  content: MathExpressionSchema.optional(),
386
- provenance: MathProvenanceSchema.optional()
836
+ provenance: MathProvenanceSchema.optional(),
837
+ source: SourceResidueSchema.optional()
387
838
  });
388
839
  const contentDocumentSharedFields = { symbolTable: SymbolTableSchema.optional() };
389
840
  const ContentDocumentSchema = z.discriminatedUnion("kind", [
@@ -419,4 +870,4 @@ const ContentDocumentSchema = z.discriminatedUnion("kind", [
419
870
  })
420
871
  ]);
421
872
  //#endregion
422
- export { ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellValueSchema, ContentConstructEndSchema, ContentConstructStartSchema, 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, findConstructMarkerImbalance, isContentBlock, isContentConstructEnd, isContentConstructStart };
873
+ export { ContentBitmapFillSchema, ContentBlockSchema, ContentBorderSchema, ContentCellBordersSchema, ContentCellFillSchema, ContentCellPatternTypeSchema, ContentCellValueSchema, ContentConstructEndSchema, ContentConstructStartSchema, ContentDocumentSchema, ContentDrawPageSchema, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectSchema, ContentFillPatternSchema, ContentFloatAlignSchema, ContentFloatAxisSchema, ContentFloatOriginSchema, ContentFloatPositionSchema, ContentFormulaSchema, ContentGradientFillSchema, ContentGradientStyleSchema, ContentHatchFillSchema, ContentHatchStyleSchema, ContentImageBlockSchema, ContentListMembershipSchema, ContentPageBreakSchema, ContentPageFurnitureSchema, ContentParagraphBordersSchema, ContentParagraphSchema, ContentPathPointSchema, ContentPathSegmentSchema, ContentRunSchema, ContentSectionSchema, ContentShapeSchema, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumnSchema, ContentSheetConditionalFormatSchema, ContentSheetConditionalFormatStyleSchema, ContentSheetConditionalFormatValueSchema, ContentSheetDataValidationSchema, ContentSheetDataValidationTypeSchema, ContentSheetImageSchema, ContentSheetPrintRangeSchema, ContentSheetPrintSettingsSchema, ContentSheetRangeSchema, ContentSheetRepeatRangeSchema, ContentSheetRowSchema, ContentSheetSchema, ContentSlideSchema, ContentStrokeDashSchema, ContentStrokeSchema, ContentStrokeStyleSchema, ContentSubpathSchema, ContentTableCellSchema, ContentTableRowSchema, ContentTableSchema, ContentVectorSchema, DecimalStringSchema, RunConstructExtentSchema, SheetRuleOperatorSchema, clampHeadingLevel, contentDocumentSharedFields, findConstructMarkerImbalance, findRunConstructFault, isContentBlock, isContentConstructEnd, isContentConstructStart, isRunConstructExtent, resolveCellFillColor, unrecognizedFillKind };