doc-schema.js 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +30 -4
  2. package/dist/canonicalise.cjs +20 -0
  3. package/dist/canonicalise.d.cts +5 -0
  4. package/dist/canonicalise.d.ts +5 -0
  5. package/dist/canonicalise.js +18 -0
  6. package/dist/codec.d.cts +1 -1
  7. package/dist/codec.d.ts +1 -1
  8. package/dist/{construct-D5pdDPqM.d.cts → construct-CdQuI9f5.d.cts} +6 -6
  9. package/dist/{construct-D5pdDPqM.d.ts → construct-CdQuI9f5.d.ts} +6 -6
  10. package/dist/construct.d.cts +1 -1
  11. package/dist/construct.d.ts +1 -1
  12. package/dist/{content-B5VNueO_.d.cts → content-BmqzegMG.d.cts} +2 -2
  13. package/dist/{content-DPtA7fC1.d.ts → content-CIwPb_yh.d.ts} +2 -2
  14. package/dist/content.d.cts +1 -1
  15. package/dist/content.d.ts +1 -1
  16. package/dist/decompose.cjs +186 -0
  17. package/dist/decompose.d.cts +18 -0
  18. package/dist/decompose.d.ts +18 -0
  19. package/dist/decompose.js +177 -0
  20. package/dist/definitions.d.cts +1 -1
  21. package/dist/definitions.d.ts +1 -1
  22. package/dist/factor-styles.cjs +435 -0
  23. package/dist/factor-styles.d.cts +9 -0
  24. package/dist/factor-styles.d.ts +9 -0
  25. package/dist/factor-styles.js +432 -0
  26. package/dist/flatten.cjs +154 -0
  27. package/dist/flatten.d.cts +6 -0
  28. package/dist/flatten.d.ts +6 -0
  29. package/dist/flatten.js +153 -0
  30. package/dist/index.cjs +8 -0
  31. package/dist/index.d.cts +8 -5
  32. package/dist/index.d.ts +8 -5
  33. package/dist/index.js +4 -1
  34. package/dist/{package-node-BGOvE4E_.d.ts → package-node-C7RiYhyk.d.ts} +2 -2
  35. package/dist/{package-node-Cz-iiwsx.d.cts → package-node-a9CyRaD3.d.cts} +2 -2
  36. package/dist/package-node.d.cts +1 -1
  37. package/dist/package-node.d.ts +1 -1
  38. package/dist/package.d.cts +1 -1
  39. package/dist/package.d.ts +1 -1
  40. package/dist/schema-io.cjs +2 -2
  41. package/dist/schema-io.d.cts +1 -1
  42. package/dist/schema-io.d.ts +1 -1
  43. package/dist/schema-io.js +2 -2
  44. package/package.json +2 -2
  45. package/schemas/content-document.schema.json +3 -3
  46. package/schemas/document-package.schema.json +3 -3
package/README.md CHANGED
@@ -52,7 +52,7 @@ graph TD
52
52
 
53
53
  The `LayoutDocument` family (pages of positioned `LayoutItem`s — `text`/`image`/`rect`/`line`/`ellipse`/`path`/`link` in PDF user-space coordinates) no longer lives here: 4.0.0 demoted it to a pdf-codec-private model ([pdf-codec#65](https://github.com/ExaDev/pdf-codec/issues/65)), where the only codec that ever read or wrote it owns it outright. `documentFromJson` recognises old layout-document `$schema` URIs and throws a tombstone pointing at pdf-codec rather than failing as if the value were unrelated. Dependents stay on document-schema.js 3.x via semver until their own majors, so the demotion is not a cascade-breaker.
54
54
 
55
- The package contains only [Zod](https://zod.dev) schemas, their inferred types, trivial schema-attached helpers (hex-colour conversion, recursive structural type guards, the style-resolution helpers of `src/definitions.ts`, the construct-marker balance check of `src/content.ts`), and one small structural interface (`ContentCodec`, see [Codecs](#codecs)). No XML, ZIP, PDF, or binary handling; the sole dependency is `zod`.
55
+ The package contains [Zod](https://zod.dev) schemas, their inferred types, trivial schema-attached helpers (hex-colour conversion, recursive structural type guards, the style-resolution helpers of `src/definitions.ts`, the construct-marker balance check of `src/content.ts`), one small structural interface (`ContentCodec`, see [Codecs](#codecs)), and the structural transform between the two encodings it defines (`decompose`/`flattenPackage`/`factorStyles`/`assemblePackage`, see [The package boundary](#the-package-boundary)). No format-specific behaviour and no I/O of any kind — no XML, ZIP, PDF, or binary handling; the sole dependency is `zod`.
56
56
 
57
57
  Two format-agnostic helpers live here because they operate on the content model itself: cell-addressing utilities in `src/a1.ts` (0-based row/column indices, row-first order matching `ContentSheetCell`'s `{row, column}`) and the `FontFace` interface in `src/font-port.ts` (`{family, bold, italic}`).
58
58
 
@@ -102,7 +102,33 @@ The flat `ContentDocument` and the tree are **one format, two encodings**, relat
102
102
  2. **Effective-property equality, universally** — resolve styles first, then compare: a factored and an unfactored serialisation of one document are equal (this is also why content hashing and structural diffing resolve first).
103
103
  3. **Minting idempotence** — factoring a package a second time mints the identical styles table: `decompose(flatten(decompose(x))) === decompose(x)`.
104
104
 
105
- The codecs do not change: they keep producing flat `ContentDocument`s (their natural reading shape); decomposition runs once at the package boundary in documents.js and flatten runs once where a builder consumes a package.
105
+ The codecs do not change: they keep producing flat `ContentDocument`s (their natural reading shape); decomposition runs once where a package is assembled and flatten runs once where a builder consumes one. Both directions live here — see [The package boundary](#the-package-boundary).
106
+
107
+ ## The package boundary
108
+
109
+ The transform between the two encodings lives in this package, alongside the schemas that define them:
110
+
111
+ ```ts
112
+ import { assemblePackage, decompose, factorStyles, flattenPackage } from 'document-schema.js';
113
+
114
+ // The one call a construction site makes: decompose the flat content into the tree, splice the envelope
115
+ // onto the root, and mint a styles table over the result. `pages` is optional -- pass it once a layout
116
+ // pass has produced each rendered page's own size.
117
+ const pkg = assemblePackage(content, pages);
118
+
119
+ // The inverse, with every style ref resolved away: a fully materialised, ref-free ContentDocument.
120
+ const flat = flattenPackage(pkg);
121
+
122
+ // The two halves on their own, for a caller composing its own boundary.
123
+ const children = decompose(content); // flat -> the tree `children` a package carries
124
+ const reminted = factorStyles(pkg); // re-mint an already-assembled tree (idempotent)
125
+ ```
126
+
127
+ `decompose` throws `ConstructMarkerImbalanceError` — carrying `src/content.ts`'s own `ConstructMarkerImbalance` payload, so a caller narrows with `instanceof` and reads the offending block index rather than parsing a message — when a container's `constructStart`/`constructEnd` markers do not pair up. Promotion is defined only over a balanced stream, so an unbalanced one is refused rather than repaired into a plausible tree.
128
+
129
+ **This is a deliberate amendment to the "schemas only" charter, not a drift from it.** The transform is not business logic and not format-specific behaviour: it is the canonical, purely structural, zero-I/O relationship between the two shapes this package already defines, and its correctness contract *is* the three laws above. It lives here because it has to: `ooxml.js`, `odf.js`, `markdown-codec`, and `pdf-codec` all depend on this package and none of them depends on `documents.js`, so a codec whose public read/write functions speak `DocumentPackage` directly can only reach the transform if the transform sits at or below the schema layer. Everything the charter actually guards against — XML, ZIP, PDF, fonts, layout, bytes, filesystem — remains firmly out.
130
+
131
+ The laws are pinned in `src/bijection.test.ts` over a corpus spanning every document kind, every leaf the tree vocabulary admits, and every grouping signal `decompose` reads (headings, list levels, and construct boundaries in each block flow that admits them). `documents.js` runs the same law harness over its own real-format corpus — reader output for every format it supports, editor builds, and conversion captures carrying a layout pass's real frames and pages — which is the complement this package cannot host, since every reader in it belongs to a package that depends on this one.
106
132
 
107
133
  ## Fidelity constructs
108
134
 
@@ -199,7 +225,7 @@ Each is its own root field rather than three more tenants of `definitions`, for
199
225
 
200
226
  A styles entry carries `{ paragraph?, run? }` sub-objects of **resolved canonical properties only**: paragraph `alignment`/`list`/`spacingBeforePt`/`spacingAfterPt`/`lineSpacing`/`indentLeftPt`/`indentFirstLinePt`, run `bold`/`italic`/`underline`/`strike`/`fontFamily`/`sizePt`/`color`. Never `frames`, never `sourcePath`, never `styleId` (per-node facts — a position is a fact about a node, not a style), never a `basedOn` graph (the table is a dictionary, not a program) — and the ban list is **enforced by schema shape** (strict objects that reject those keys outright), not merely documented.
201
227
 
202
- Resolution is one overlay chain — outermost ancestor group's style, each nearer group's style, the node's own direct properties; innermost wins, with the resolved run half applying one level further down as run defaults under each run's own properties. `src/definitions.ts` exports the pure helpers that implement it (`overlayStyleEntries`, `resolveStyleChain`, `applyParagraphStyleProperties`, `applyRunStyleProperties`); minting entries (the deterministic frequency pass that factors repeated property tuples into `s1`, `s2`, … refs) is documents.js's boundary behaviour, not this package's.
228
+ Resolution is one overlay chain — outermost ancestor group's style, each nearer group's style, the node's own direct properties; innermost wins, with the resolved run half applying one level further down as run defaults under each run's own properties. `src/definitions.ts` exports the pure helpers that implement it (`overlayStyleEntries`, `resolveStyleChain`, `applyParagraphStyleProperties`, `applyRunStyleProperties`), and `factorStyles` (`src/factor-styles.ts`) is the deterministic frequency pass that mints entries, factoring repeated property tuples into `s1`, `s2`, … refs see [The package boundary](#the-package-boundary).
203
229
 
204
230
  Every module is also importable directly — `tsdown` builds one file per source module, and `package.json`'s `"./*"` export makes each individually resolvable:
205
231
 
@@ -311,7 +337,7 @@ try {
311
337
 
312
338
  - [ooxml.js](https://github.com/ExaDev/ooxml.js) — `readDocx`/`readPptx`/`readXlsxContent` return types are typed against this package's schemas, not a local lookalike.
313
339
  - [odf.js](https://github.com/ExaDev/odf.js) — ODF typed readers return the same shared types, so ODF and OOXML speak the identical pivot.
314
- - [documents.js](https://github.com/ExaDev/documents.js) — primary consumer of `ContentDocument` and `DocumentPackage`; its `DOCUMENT_FORMAT_CODECS` registry implements `ContentCodec` per format, and its package boundary runs decompose/flatten against the tree form.
340
+ - [documents.js](https://github.com/ExaDev/documents.js) — primary consumer of `ContentDocument` and `DocumentPackage`; its `DOCUMENT_FORMAT_CODECS` registry implements `ContentCodec` per format, and its conversion pipeline calls `assemblePackage`/`flattenPackage` from here at every package construction site.
315
341
  - [pdf-codec](https://github.com/ExaDev/pdf-codec) — owns its layout item model outright since 4.0.0; `readPdf`/`writePdf` operate on pdf-codec's own `LayoutDocument`, and this package's `ContentDocument` remains its content pivot.
316
342
  - [markdown-codec](https://github.com/ExaDev/markdown-codec) — `readMarkdown`/`writeMarkdown` read and write this package's `ContentDocument` directly.
317
343
 
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/canonicalise.ts
3
+ function canonicalise(value) {
4
+ if (Array.isArray(value)) return value.map(canonicalise);
5
+ if (isRecord(value)) {
6
+ const sorted = {};
7
+ for (const key of Object.keys(value).sort()) sorted[key] = canonicalise(value[key]);
8
+ return sorted;
9
+ }
10
+ return value;
11
+ }
12
+ function isRecord(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function canonicalKey(value) {
16
+ return JSON.stringify(canonicalise(value));
17
+ }
18
+ //#endregion
19
+ exports.canonicalKey = canonicalKey;
20
+ exports.canonicalise = canonicalise;
@@ -0,0 +1,5 @@
1
+ //#region src/canonicalise.d.ts
2
+ declare function canonicalise(value: unknown): unknown;
3
+ declare function canonicalKey(value: unknown): string;
4
+ //#endregion
5
+ export { canonicalKey, canonicalise };
@@ -0,0 +1,5 @@
1
+ //#region src/canonicalise.d.ts
2
+ declare function canonicalise(value: unknown): unknown;
3
+ declare function canonicalKey(value: unknown): string;
4
+ //#endregion
5
+ export { canonicalKey, canonicalise };
@@ -0,0 +1,18 @@
1
+ //#region src/canonicalise.ts
2
+ function canonicalise(value) {
3
+ if (Array.isArray(value)) return value.map(canonicalise);
4
+ if (isRecord(value)) {
5
+ const sorted = {};
6
+ for (const key of Object.keys(value).sort()) sorted[key] = canonicalise(value[key]);
7
+ return sorted;
8
+ }
9
+ return value;
10
+ }
11
+ function isRecord(value) {
12
+ return typeof value === "object" && value !== null && !Array.isArray(value);
13
+ }
14
+ function canonicalKey(value) {
15
+ return JSON.stringify(canonicalise(value));
16
+ }
17
+ //#endregion
18
+ export { canonicalKey, canonicalise };
package/dist/codec.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { m as ContentDocument } from "./content-B5VNueO_.cjs";
1
+ import { m as ContentDocument } from "./content-BmqzegMG.cjs";
2
2
  //#region src/codec.d.ts
3
3
  interface ContentCodec<TOptions = unknown> {
4
4
  read(bytes: Uint8Array, options?: TOptions): ContentDocument;
package/dist/codec.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { m as ContentDocument } from "./content-DPtA7fC1.js";
1
+ import { m as ContentDocument } from "./content-CIwPb_yh.js";
2
2
  //#region src/codec.d.ts
3
3
  interface ContentCodec<TOptions = unknown> {
4
4
  read(bytes: Uint8Array, options?: TOptions): ContentDocument;
@@ -1,12 +1,12 @@
1
1
  import { z } from "zod";
2
2
  //#region src/construct.d.ts
3
3
  declare const ContentControlTypeSchema: z.ZodEnum<{
4
- date: "date";
5
4
  richText: "richText";
6
5
  plainText: "plainText";
7
6
  checkbox: "checkbox";
8
7
  dropDown: "dropDown";
9
8
  comboBox: "comboBox";
9
+ date: "date";
10
10
  picture: "picture";
11
11
  repeatingSection: "repeatingSection";
12
12
  button: "button";
@@ -23,12 +23,12 @@ type ContentControlLock = z.infer<typeof ContentControlLockSchema>;
23
23
  declare const ContentControlDescriptorSchema: z.ZodObject<{
24
24
  kind: z.ZodLiteral<"contentControl">;
25
25
  controlType: z.ZodEnum<{
26
- date: "date";
27
26
  richText: "richText";
28
27
  plainText: "plainText";
29
28
  checkbox: "checkbox";
30
29
  dropDown: "dropDown";
31
30
  comboBox: "comboBox";
31
+ date: "date";
32
32
  picture: "picture";
33
33
  repeatingSection: "repeatingSection";
34
34
  button: "button";
@@ -54,19 +54,19 @@ declare const FieldDescriptorSchema: z.ZodObject<{
54
54
  }, z.core.$strict>;
55
55
  type FieldDescriptor = z.infer<typeof FieldDescriptorSchema>;
56
56
  declare const AnchorTypeSchema: z.ZodEnum<{
57
- comment: "comment";
58
57
  bookmark: "bookmark";
59
58
  footnote: "footnote";
60
59
  endnote: "endnote";
60
+ comment: "comment";
61
61
  }>;
62
62
  type AnchorType = z.infer<typeof AnchorTypeSchema>;
63
63
  declare const AnchorDescriptorSchema: z.ZodObject<{
64
64
  kind: z.ZodLiteral<"anchor">;
65
65
  anchorType: z.ZodEnum<{
66
- comment: "comment";
67
66
  bookmark: "bookmark";
68
67
  footnote: "footnote";
69
68
  endnote: "endnote";
69
+ comment: "comment";
70
70
  }>;
71
71
  name: z.ZodString;
72
72
  definition: z.ZodOptional<z.ZodString>;
@@ -132,12 +132,12 @@ type DivisionDescriptor = z.infer<typeof DivisionDescriptorSchema>;
132
132
  declare const ConstructDescriptorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
133
133
  kind: z.ZodLiteral<"contentControl">;
134
134
  controlType: z.ZodEnum<{
135
- date: "date";
136
135
  richText: "richText";
137
136
  plainText: "plainText";
138
137
  checkbox: "checkbox";
139
138
  dropDown: "dropDown";
140
139
  comboBox: "comboBox";
140
+ date: "date";
141
141
  picture: "picture";
142
142
  repeatingSection: "repeatingSection";
143
143
  button: "button";
@@ -161,10 +161,10 @@ declare const ConstructDescriptorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
161
161
  }, z.core.$strict>, z.ZodObject<{
162
162
  kind: z.ZodLiteral<"anchor">;
163
163
  anchorType: z.ZodEnum<{
164
- comment: "comment";
165
164
  bookmark: "bookmark";
166
165
  footnote: "footnote";
167
166
  endnote: "endnote";
167
+ comment: "comment";
168
168
  }>;
169
169
  name: z.ZodString;
170
170
  definition: z.ZodOptional<z.ZodString>;
@@ -1,12 +1,12 @@
1
1
  import { z } from "zod";
2
2
  //#region src/construct.d.ts
3
3
  declare const ContentControlTypeSchema: z.ZodEnum<{
4
- date: "date";
5
4
  richText: "richText";
6
5
  plainText: "plainText";
7
6
  checkbox: "checkbox";
8
7
  dropDown: "dropDown";
9
8
  comboBox: "comboBox";
9
+ date: "date";
10
10
  picture: "picture";
11
11
  repeatingSection: "repeatingSection";
12
12
  button: "button";
@@ -23,12 +23,12 @@ type ContentControlLock = z.infer<typeof ContentControlLockSchema>;
23
23
  declare const ContentControlDescriptorSchema: z.ZodObject<{
24
24
  kind: z.ZodLiteral<"contentControl">;
25
25
  controlType: z.ZodEnum<{
26
- date: "date";
27
26
  richText: "richText";
28
27
  plainText: "plainText";
29
28
  checkbox: "checkbox";
30
29
  dropDown: "dropDown";
31
30
  comboBox: "comboBox";
31
+ date: "date";
32
32
  picture: "picture";
33
33
  repeatingSection: "repeatingSection";
34
34
  button: "button";
@@ -54,19 +54,19 @@ declare const FieldDescriptorSchema: z.ZodObject<{
54
54
  }, z.core.$strict>;
55
55
  type FieldDescriptor = z.infer<typeof FieldDescriptorSchema>;
56
56
  declare const AnchorTypeSchema: z.ZodEnum<{
57
- comment: "comment";
58
57
  bookmark: "bookmark";
59
58
  footnote: "footnote";
60
59
  endnote: "endnote";
60
+ comment: "comment";
61
61
  }>;
62
62
  type AnchorType = z.infer<typeof AnchorTypeSchema>;
63
63
  declare const AnchorDescriptorSchema: z.ZodObject<{
64
64
  kind: z.ZodLiteral<"anchor">;
65
65
  anchorType: z.ZodEnum<{
66
- comment: "comment";
67
66
  bookmark: "bookmark";
68
67
  footnote: "footnote";
69
68
  endnote: "endnote";
69
+ comment: "comment";
70
70
  }>;
71
71
  name: z.ZodString;
72
72
  definition: z.ZodOptional<z.ZodString>;
@@ -132,12 +132,12 @@ type DivisionDescriptor = z.infer<typeof DivisionDescriptorSchema>;
132
132
  declare const ConstructDescriptorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
133
133
  kind: z.ZodLiteral<"contentControl">;
134
134
  controlType: z.ZodEnum<{
135
- date: "date";
136
135
  richText: "richText";
137
136
  plainText: "plainText";
138
137
  checkbox: "checkbox";
139
138
  dropDown: "dropDown";
140
139
  comboBox: "comboBox";
140
+ date: "date";
141
141
  picture: "picture";
142
142
  repeatingSection: "repeatingSection";
143
143
  button: "button";
@@ -161,10 +161,10 @@ declare const ConstructDescriptorSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
161
161
  }, z.core.$strict>, z.ZodObject<{
162
162
  kind: z.ZodLiteral<"anchor">;
163
163
  anchorType: z.ZodEnum<{
164
- comment: "comment";
165
164
  bookmark: "bookmark";
166
165
  footnote: "footnote";
167
166
  endnote: "endnote";
167
+ comment: "comment";
168
168
  }>;
169
169
  name: z.ZodString;
170
170
  definition: z.ZodOptional<z.ZodString>;
@@ -1,2 +1,2 @@
1
- import { C as ProvenanceChange, E as ProvenanceDescriptorSchema, S as LinkTargetSchema, T as ProvenanceDescriptor, _ as FieldDescriptor, a as ConstructDescriptor, b as LinkDescriptorSchema, c as ContentControlDescriptorSchema, d as ContentControlType, f as ContentControlTypeSchema, g as DivisionSourceSchema, h as DivisionSource, i as AnchorTypeSchema, l as ContentControlLock, m as DivisionDescriptorSchema, n as AnchorDescriptorSchema, o as ConstructDescriptorSchema, p as DivisionDescriptor, r as AnchorType, s as ContentControlDescriptor, t as AnchorDescriptor, u as ContentControlLockSchema, v as FieldDescriptorSchema, w as ProvenanceChangeSchema, x as LinkTarget, y as LinkDescriptor } from "./construct-D5pdDPqM.cjs";
1
+ import { C as ProvenanceChange, E as ProvenanceDescriptorSchema, S as LinkTargetSchema, T as ProvenanceDescriptor, _ as FieldDescriptor, a as ConstructDescriptor, b as LinkDescriptorSchema, c as ContentControlDescriptorSchema, d as ContentControlType, f as ContentControlTypeSchema, g as DivisionSourceSchema, h as DivisionSource, i as AnchorTypeSchema, l as ContentControlLock, m as DivisionDescriptorSchema, n as AnchorDescriptorSchema, o as ConstructDescriptorSchema, p as DivisionDescriptor, r as AnchorType, s as ContentControlDescriptor, t as AnchorDescriptor, u as ContentControlLockSchema, v as FieldDescriptorSchema, w as ProvenanceChangeSchema, x as LinkTarget, y as LinkDescriptor } from "./construct-CdQuI9f5.cjs";
2
2
  export { AnchorDescriptor, AnchorDescriptorSchema, AnchorType, AnchorTypeSchema, ConstructDescriptor, ConstructDescriptorSchema, ContentControlDescriptor, ContentControlDescriptorSchema, ContentControlLock, ContentControlLockSchema, ContentControlType, ContentControlTypeSchema, DivisionDescriptor, DivisionDescriptorSchema, DivisionSource, DivisionSourceSchema, FieldDescriptor, FieldDescriptorSchema, LinkDescriptor, LinkDescriptorSchema, LinkTarget, LinkTargetSchema, ProvenanceChange, ProvenanceChangeSchema, ProvenanceDescriptor, ProvenanceDescriptorSchema };
@@ -1,2 +1,2 @@
1
- import { C as ProvenanceChange, E as ProvenanceDescriptorSchema, S as LinkTargetSchema, T as ProvenanceDescriptor, _ as FieldDescriptor, a as ConstructDescriptor, b as LinkDescriptorSchema, c as ContentControlDescriptorSchema, d as ContentControlType, f as ContentControlTypeSchema, g as DivisionSourceSchema, h as DivisionSource, i as AnchorTypeSchema, l as ContentControlLock, m as DivisionDescriptorSchema, n as AnchorDescriptorSchema, o as ConstructDescriptorSchema, p as DivisionDescriptor, r as AnchorType, s as ContentControlDescriptor, t as AnchorDescriptor, u as ContentControlLockSchema, v as FieldDescriptorSchema, w as ProvenanceChangeSchema, x as LinkTarget, y as LinkDescriptor } from "./construct-D5pdDPqM.js";
1
+ import { C as ProvenanceChange, E as ProvenanceDescriptorSchema, S as LinkTargetSchema, T as ProvenanceDescriptor, _ as FieldDescriptor, a as ConstructDescriptor, b as LinkDescriptorSchema, c as ContentControlDescriptorSchema, d as ContentControlType, f as ContentControlTypeSchema, g as DivisionSourceSchema, h as DivisionSource, i as AnchorTypeSchema, l as ContentControlLock, m as DivisionDescriptorSchema, n as AnchorDescriptorSchema, o as ConstructDescriptorSchema, p as DivisionDescriptor, r as AnchorType, s as ContentControlDescriptor, t as AnchorDescriptor, u as ContentControlLockSchema, v as FieldDescriptorSchema, w as ProvenanceChangeSchema, x as LinkTarget, y as LinkDescriptor } from "./construct-CdQuI9f5.js";
2
2
  export { AnchorDescriptor, AnchorDescriptorSchema, AnchorType, AnchorTypeSchema, ConstructDescriptor, ConstructDescriptorSchema, ContentControlDescriptor, ContentControlDescriptorSchema, ContentControlLock, ContentControlLockSchema, ContentControlType, ContentControlTypeSchema, DivisionDescriptor, DivisionDescriptorSchema, DivisionSource, DivisionSourceSchema, FieldDescriptor, FieldDescriptorSchema, LinkDescriptor, LinkDescriptorSchema, LinkTarget, LinkTargetSchema, ProvenanceChange, ProvenanceChangeSchema, ProvenanceDescriptor, ProvenanceDescriptorSchema };
@@ -126,12 +126,12 @@ declare const ContentConstructStartSchema: z.ZodObject<{
126
126
  descriptor: z.ZodDiscriminatedUnion<[z.ZodObject<{
127
127
  kind: z.ZodLiteral<"contentControl">;
128
128
  controlType: z.ZodEnum<{
129
- date: "date";
130
129
  richText: "richText";
131
130
  plainText: "plainText";
132
131
  checkbox: "checkbox";
133
132
  dropDown: "dropDown";
134
133
  comboBox: "comboBox";
134
+ date: "date";
135
135
  picture: "picture";
136
136
  repeatingSection: "repeatingSection";
137
137
  button: "button";
@@ -155,10 +155,10 @@ declare const ContentConstructStartSchema: z.ZodObject<{
155
155
  }, z.core.$strict>, z.ZodObject<{
156
156
  kind: z.ZodLiteral<"anchor">;
157
157
  anchorType: z.ZodEnum<{
158
- comment: "comment";
159
158
  bookmark: "bookmark";
160
159
  footnote: "footnote";
161
160
  endnote: "endnote";
161
+ comment: "comment";
162
162
  }>;
163
163
  name: z.ZodString;
164
164
  definition: z.ZodOptional<z.ZodString>;
@@ -126,12 +126,12 @@ declare const ContentConstructStartSchema: z.ZodObject<{
126
126
  descriptor: z.ZodDiscriminatedUnion<[z.ZodObject<{
127
127
  kind: z.ZodLiteral<"contentControl">;
128
128
  controlType: z.ZodEnum<{
129
- date: "date";
130
129
  richText: "richText";
131
130
  plainText: "plainText";
132
131
  checkbox: "checkbox";
133
132
  dropDown: "dropDown";
134
133
  comboBox: "comboBox";
134
+ date: "date";
135
135
  picture: "picture";
136
136
  repeatingSection: "repeatingSection";
137
137
  button: "button";
@@ -155,10 +155,10 @@ declare const ContentConstructStartSchema: z.ZodObject<{
155
155
  }, z.core.$strict>, z.ZodObject<{
156
156
  kind: z.ZodLiteral<"anchor">;
157
157
  anchorType: z.ZodEnum<{
158
- comment: "comment";
159
158
  bookmark: "bookmark";
160
159
  footnote: "footnote";
161
160
  endnote: "endnote";
161
+ comment: "comment";
162
162
  }>;
163
163
  name: z.ZodString;
164
164
  definition: z.ZodOptional<z.ZodString>;
@@ -1,2 +1,2 @@
1
- import { $ as ContentSheetPrintRangeSchema, A as ContentPageBreakSchema, At as isContentConstructEnd, B as ContentSectionSchema, C as ContentFormula, Ct as DecimalString, D as ContentListMembership, Dt as contentDocumentSharedFields, E as ContentImageBlockSchema, Et as clampHeadingLevel, F as ContentPathSegment, G as ContentSheetCellComment, H as ContentShapeSchema, I as ContentPathSegmentSchema, J as ContentSheetColumn, K as ContentSheetCellCommentSchema, L as ContentRun, M as ContentParagraphSchema, N as ContentPathPoint, O as ContentListMembershipSchema, Ot as findConstructMarkerImbalance, P as ContentPathPointSchema, Q as ContentSheetPrintRange, R as ContentRunSchema, S as ContentEmbeddedObjectSchema, St as ContentVectorSchema, T as ContentImageBlock, Tt as FusedNode, U as ContentSheet, V as ContentShape, W as ContentSheetCell, X as ContentSheetImage, Y as ContentSheetColumnSchema, Z as ContentSheetImageSchema, _ as ContentDrawPageSchema, _t as ContentTableCellSchema, a as ContentBorderSchema, at as ContentSheetRowSchema, b as ContentEmbeddedObjectBlockSchema, bt as ContentTableSchema, c as ContentCellValue, ct as ContentSlideSchema, d as ContentConstructEndSchema, dt as ContentStrokeStyle, et as ContentSheetPrintSettings, f as ContentConstructStart, ft as ContentStrokeStyleSchema, g as ContentDrawPage, gt as ContentTableCell, h as ContentDocumentSchema, ht as ContentTable, i as ContentBorder, it as ContentSheetRow, j as ContentParagraph, jt as isContentConstructStart, k as ContentPageBreak, kt as isContentBlock, l as ContentCellValueSchema, lt as ContentStroke, m as ContentDocument, mt as ContentSubpathSchema, n as ContentBlock, nt as ContentSheetRepeatRange, o as ContentCellBorders, ot as ContentSheetSchema, p as ContentConstructStartSchema, pt as ContentSubpath, q as ContentSheetCellSchema, r as ContentBlockSchema, rt as ContentSheetRepeatRangeSchema, s as ContentCellBordersSchema, st as ContentSlide, t as ConstructMarkerImbalance, tt as ContentSheetPrintSettingsSchema, u as ContentConstructEnd, ut as ContentStrokeSchema, v as ContentEmbeddedObject, vt as ContentTableRow, w as ContentFormulaSchema, wt as DecimalStringSchema, x as ContentEmbeddedObjectKind, xt as ContentVector, y as ContentEmbeddedObjectBlock, yt as ContentTableRowSchema, z as ContentSection } from "./content-B5VNueO_.cjs";
1
+ import { $ as ContentSheetPrintRangeSchema, A as ContentPageBreakSchema, At as isContentConstructEnd, B as ContentSectionSchema, C as ContentFormula, Ct as DecimalString, D as ContentListMembership, Dt as contentDocumentSharedFields, E as ContentImageBlockSchema, Et as clampHeadingLevel, F as ContentPathSegment, G as ContentSheetCellComment, H as ContentShapeSchema, I as ContentPathSegmentSchema, J as ContentSheetColumn, K as ContentSheetCellCommentSchema, L as ContentRun, M as ContentParagraphSchema, N as ContentPathPoint, O as ContentListMembershipSchema, Ot as findConstructMarkerImbalance, P as ContentPathPointSchema, Q as ContentSheetPrintRange, R as ContentRunSchema, S as ContentEmbeddedObjectSchema, St as ContentVectorSchema, T as ContentImageBlock, Tt as FusedNode, U as ContentSheet, V as ContentShape, W as ContentSheetCell, X as ContentSheetImage, Y as ContentSheetColumnSchema, Z as ContentSheetImageSchema, _ as ContentDrawPageSchema, _t as ContentTableCellSchema, a as ContentBorderSchema, at as ContentSheetRowSchema, b as ContentEmbeddedObjectBlockSchema, bt as ContentTableSchema, c as ContentCellValue, ct as ContentSlideSchema, d as ContentConstructEndSchema, dt as ContentStrokeStyle, et as ContentSheetPrintSettings, f as ContentConstructStart, ft as ContentStrokeStyleSchema, g as ContentDrawPage, gt as ContentTableCell, h as ContentDocumentSchema, ht as ContentTable, i as ContentBorder, it as ContentSheetRow, j as ContentParagraph, jt as isContentConstructStart, k as ContentPageBreak, kt as isContentBlock, l as ContentCellValueSchema, lt as ContentStroke, m as ContentDocument, mt as ContentSubpathSchema, n as ContentBlock, nt as ContentSheetRepeatRange, o as ContentCellBorders, ot as ContentSheetSchema, p as ContentConstructStartSchema, pt as ContentSubpath, q as ContentSheetCellSchema, r as ContentBlockSchema, rt as ContentSheetRepeatRangeSchema, s as ContentCellBordersSchema, st as ContentSlide, t as ConstructMarkerImbalance, tt as ContentSheetPrintSettingsSchema, u as ContentConstructEnd, ut as ContentStrokeSchema, v as ContentEmbeddedObject, vt as ContentTableRow, w as ContentFormulaSchema, wt as DecimalStringSchema, x as ContentEmbeddedObjectKind, xt as ContentVector, y as ContentEmbeddedObjectBlock, yt as ContentTableRowSchema, z as ContentSection } from "./content-BmqzegMG.cjs";
2
2
  export { ConstructMarkerImbalance, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellValue, ContentCellValueSchema, ContentConstructEnd, ContentConstructEndSchema, ContentConstructStart, ContentConstructStartSchema, ContentDocument, ContentDocumentSchema, ContentDrawPage, ContentDrawPageSchema, ContentEmbeddedObject, ContentEmbeddedObjectBlock, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectKind, ContentEmbeddedObjectSchema, ContentFormula, ContentFormulaSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembershipSchema, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentPathPoint, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellComment, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStrokeSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentSubpath, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentVector, ContentVectorSchema, DecimalString, DecimalStringSchema, FusedNode, clampHeadingLevel, contentDocumentSharedFields, findConstructMarkerImbalance, isContentBlock, isContentConstructEnd, isContentConstructStart };
package/dist/content.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as ContentSheetPrintRangeSchema, A as ContentPageBreakSchema, At as isContentConstructEnd, B as ContentSectionSchema, C as ContentFormula, Ct as DecimalString, D as ContentListMembership, Dt as contentDocumentSharedFields, E as ContentImageBlockSchema, Et as clampHeadingLevel, F as ContentPathSegment, G as ContentSheetCellComment, H as ContentShapeSchema, I as ContentPathSegmentSchema, J as ContentSheetColumn, K as ContentSheetCellCommentSchema, L as ContentRun, M as ContentParagraphSchema, N as ContentPathPoint, O as ContentListMembershipSchema, Ot as findConstructMarkerImbalance, P as ContentPathPointSchema, Q as ContentSheetPrintRange, R as ContentRunSchema, S as ContentEmbeddedObjectSchema, St as ContentVectorSchema, T as ContentImageBlock, Tt as FusedNode, U as ContentSheet, V as ContentShape, W as ContentSheetCell, X as ContentSheetImage, Y as ContentSheetColumnSchema, Z as ContentSheetImageSchema, _ as ContentDrawPageSchema, _t as ContentTableCellSchema, a as ContentBorderSchema, at as ContentSheetRowSchema, b as ContentEmbeddedObjectBlockSchema, bt as ContentTableSchema, c as ContentCellValue, ct as ContentSlideSchema, d as ContentConstructEndSchema, dt as ContentStrokeStyle, et as ContentSheetPrintSettings, f as ContentConstructStart, ft as ContentStrokeStyleSchema, g as ContentDrawPage, gt as ContentTableCell, h as ContentDocumentSchema, ht as ContentTable, i as ContentBorder, it as ContentSheetRow, j as ContentParagraph, jt as isContentConstructStart, k as ContentPageBreak, kt as isContentBlock, l as ContentCellValueSchema, lt as ContentStroke, m as ContentDocument, mt as ContentSubpathSchema, n as ContentBlock, nt as ContentSheetRepeatRange, o as ContentCellBorders, ot as ContentSheetSchema, p as ContentConstructStartSchema, pt as ContentSubpath, q as ContentSheetCellSchema, r as ContentBlockSchema, rt as ContentSheetRepeatRangeSchema, s as ContentCellBordersSchema, st as ContentSlide, t as ConstructMarkerImbalance, tt as ContentSheetPrintSettingsSchema, u as ContentConstructEnd, ut as ContentStrokeSchema, v as ContentEmbeddedObject, vt as ContentTableRow, w as ContentFormulaSchema, wt as DecimalStringSchema, x as ContentEmbeddedObjectKind, xt as ContentVector, y as ContentEmbeddedObjectBlock, yt as ContentTableRowSchema, z as ContentSection } from "./content-DPtA7fC1.js";
1
+ import { $ as ContentSheetPrintRangeSchema, A as ContentPageBreakSchema, At as isContentConstructEnd, B as ContentSectionSchema, C as ContentFormula, Ct as DecimalString, D as ContentListMembership, Dt as contentDocumentSharedFields, E as ContentImageBlockSchema, Et as clampHeadingLevel, F as ContentPathSegment, G as ContentSheetCellComment, H as ContentShapeSchema, I as ContentPathSegmentSchema, J as ContentSheetColumn, K as ContentSheetCellCommentSchema, L as ContentRun, M as ContentParagraphSchema, N as ContentPathPoint, O as ContentListMembershipSchema, Ot as findConstructMarkerImbalance, P as ContentPathPointSchema, Q as ContentSheetPrintRange, R as ContentRunSchema, S as ContentEmbeddedObjectSchema, St as ContentVectorSchema, T as ContentImageBlock, Tt as FusedNode, U as ContentSheet, V as ContentShape, W as ContentSheetCell, X as ContentSheetImage, Y as ContentSheetColumnSchema, Z as ContentSheetImageSchema, _ as ContentDrawPageSchema, _t as ContentTableCellSchema, a as ContentBorderSchema, at as ContentSheetRowSchema, b as ContentEmbeddedObjectBlockSchema, bt as ContentTableSchema, c as ContentCellValue, ct as ContentSlideSchema, d as ContentConstructEndSchema, dt as ContentStrokeStyle, et as ContentSheetPrintSettings, f as ContentConstructStart, ft as ContentStrokeStyleSchema, g as ContentDrawPage, gt as ContentTableCell, h as ContentDocumentSchema, ht as ContentTable, i as ContentBorder, it as ContentSheetRow, j as ContentParagraph, jt as isContentConstructStart, k as ContentPageBreak, kt as isContentBlock, l as ContentCellValueSchema, lt as ContentStroke, m as ContentDocument, mt as ContentSubpathSchema, n as ContentBlock, nt as ContentSheetRepeatRange, o as ContentCellBorders, ot as ContentSheetSchema, p as ContentConstructStartSchema, pt as ContentSubpath, q as ContentSheetCellSchema, r as ContentBlockSchema, rt as ContentSheetRepeatRangeSchema, s as ContentCellBordersSchema, st as ContentSlide, t as ConstructMarkerImbalance, tt as ContentSheetPrintSettingsSchema, u as ContentConstructEnd, ut as ContentStrokeSchema, v as ContentEmbeddedObject, vt as ContentTableRow, w as ContentFormulaSchema, wt as DecimalStringSchema, x as ContentEmbeddedObjectKind, xt as ContentVector, y as ContentEmbeddedObjectBlock, yt as ContentTableRowSchema, z as ContentSection } from "./content-CIwPb_yh.js";
2
2
  export { ConstructMarkerImbalance, ContentBlock, ContentBlockSchema, ContentBorder, ContentBorderSchema, ContentCellBorders, ContentCellBordersSchema, ContentCellValue, ContentCellValueSchema, ContentConstructEnd, ContentConstructEndSchema, ContentConstructStart, ContentConstructStartSchema, ContentDocument, ContentDocumentSchema, ContentDrawPage, ContentDrawPageSchema, ContentEmbeddedObject, ContentEmbeddedObjectBlock, ContentEmbeddedObjectBlockSchema, ContentEmbeddedObjectKind, ContentEmbeddedObjectSchema, ContentFormula, ContentFormulaSchema, ContentImageBlock, ContentImageBlockSchema, ContentListMembership, ContentListMembershipSchema, ContentPageBreak, ContentPageBreakSchema, ContentParagraph, ContentParagraphSchema, ContentPathPoint, ContentPathPointSchema, ContentPathSegment, ContentPathSegmentSchema, ContentRun, ContentRunSchema, ContentSection, ContentSectionSchema, ContentShape, ContentShapeSchema, ContentSheet, ContentSheetCell, ContentSheetCellComment, ContentSheetCellCommentSchema, ContentSheetCellSchema, ContentSheetColumn, ContentSheetColumnSchema, ContentSheetImage, ContentSheetImageSchema, ContentSheetPrintRange, ContentSheetPrintRangeSchema, ContentSheetPrintSettings, ContentSheetPrintSettingsSchema, ContentSheetRepeatRange, ContentSheetRepeatRangeSchema, ContentSheetRow, ContentSheetRowSchema, ContentSheetSchema, ContentSlide, ContentSlideSchema, ContentStroke, ContentStrokeSchema, ContentStrokeStyle, ContentStrokeStyleSchema, ContentSubpath, ContentSubpathSchema, ContentTable, ContentTableCell, ContentTableCellSchema, ContentTableRow, ContentTableRowSchema, ContentTableSchema, ContentVector, ContentVectorSchema, DecimalString, DecimalStringSchema, FusedNode, clampHeadingLevel, contentDocumentSharedFields, findConstructMarkerImbalance, isContentBlock, isContentConstructEnd, isContentConstructStart };
@@ -0,0 +1,186 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_content = require("./content.cjs");
3
+ //#region src/decompose.ts
4
+ function isHeadingParagraph(paragraph) {
5
+ return paragraph.headingLevel !== void 0;
6
+ }
7
+ function isListParagraph(paragraph) {
8
+ return paragraph.list !== void 0;
9
+ }
10
+ var ConstructMarkerImbalanceError = class extends Error {
11
+ imbalance;
12
+ constructor(imbalance) {
13
+ super(imbalance.kind === "unmatchedEnd" ? `decompose: the constructEnd marker at index ${imbalance.index} of this container's block flow closes no open construct` : `decompose: the constructStart marker at index ${imbalance.index} of this container's block flow is never closed`);
14
+ this.name = "ConstructMarkerImbalanceError";
15
+ this.imbalance = imbalance;
16
+ }
17
+ };
18
+ function decompose(content) {
19
+ switch (content.kind) {
20
+ case "wordprocessing": return content.sections.map(decomposeSection);
21
+ case "presentation": return content.slides.map(decomposeSlide);
22
+ case "spreadsheet": return content.sheets.map(decomposeSheet);
23
+ case "drawing": return content.pages.map(decomposeDrawPage);
24
+ case "formula": return [content.formula];
25
+ }
26
+ }
27
+ function decomposeSection(section) {
28
+ const { blocks, ...rest } = section;
29
+ return {
30
+ node: {
31
+ kind: "section",
32
+ ...rest
33
+ },
34
+ children: decomposeSectionBlocks(blocks)
35
+ };
36
+ }
37
+ function assertBalancedConstructMarkers(blocks) {
38
+ const imbalance = require_content.findConstructMarkerImbalance(blocks);
39
+ if (imbalance !== void 0) throw new ConstructMarkerImbalanceError(imbalance);
40
+ }
41
+ function decomposeSectionBlocks(blocks) {
42
+ assertBalancedConstructMarkers(blocks);
43
+ return walkSectionBlocks(blocks.values());
44
+ }
45
+ function walkSectionBlocks(cursor) {
46
+ const root = [];
47
+ const headingStack = [];
48
+ const listStack = [];
49
+ const headingScope = () => headingStack.at(-1)?.children ?? root;
50
+ for (let step = cursor.next(); step.done !== true; step = cursor.next()) {
51
+ const block = step.value;
52
+ if (block.kind === "constructEnd") return root;
53
+ if (block.kind === "constructStart") {
54
+ openConstructGroup(block.descriptor, cursor, listStack, headingScope());
55
+ continue;
56
+ }
57
+ if (block.kind !== "paragraph") {
58
+ const parent = listStack.at(-1);
59
+ (parent !== void 0 ? parent.children : headingScope()).push(block);
60
+ continue;
61
+ }
62
+ if (isHeadingParagraph(block)) {
63
+ listStack.length = 0;
64
+ const level = block.headingLevel;
65
+ for (let top = headingStack.at(-1); top !== void 0 && top.node.headingLevel >= level; top = headingStack.at(-1)) headingStack.pop();
66
+ const group = {
67
+ node: block,
68
+ children: []
69
+ };
70
+ const parent = headingStack.at(-1);
71
+ (parent !== void 0 ? parent.children : root).push(group);
72
+ headingStack.push(group);
73
+ } else if (isListParagraph(block)) openListGroup(listStack, headingScope(), block);
74
+ else {
75
+ listStack.length = 0;
76
+ headingScope().push(block);
77
+ }
78
+ }
79
+ return root;
80
+ }
81
+ function decomposeSlide(slide) {
82
+ const { shapes, ...rest } = slide;
83
+ return {
84
+ node: {
85
+ kind: "slide",
86
+ ...rest
87
+ },
88
+ children: shapes.map(decomposeShape)
89
+ };
90
+ }
91
+ function decomposeSheet(sheet) {
92
+ const { images, embeddedObjects, ...rest } = sheet;
93
+ const children = [...images, ...embeddedObjects ?? []];
94
+ return {
95
+ node: {
96
+ kind: "sheet",
97
+ ...rest
98
+ },
99
+ children
100
+ };
101
+ }
102
+ function decomposeDrawPage(page) {
103
+ const { shapes, vectors, ...rest } = page;
104
+ const children = [...shapes.map(decomposeShape), ...vectors];
105
+ return {
106
+ node: {
107
+ kind: "drawPage",
108
+ ...rest
109
+ },
110
+ children
111
+ };
112
+ }
113
+ function decomposeShape(shape) {
114
+ const { blocks, ...rest } = shape;
115
+ return {
116
+ node: rest,
117
+ children: decomposeShapeBlocks(blocks)
118
+ };
119
+ }
120
+ function decomposeShapeBlocks(blocks) {
121
+ assertBalancedConstructMarkers(blocks);
122
+ return walkShapeBlocks(blocks.values());
123
+ }
124
+ function walkShapeBlocks(cursor) {
125
+ const root = [];
126
+ const listStack = [];
127
+ for (let step = cursor.next(); step.done !== true; step = cursor.next()) {
128
+ const block = step.value;
129
+ if (block.kind === "constructEnd") return root;
130
+ if (block.kind === "constructStart") {
131
+ const parent = listStack.at(-1);
132
+ (parent !== void 0 ? parent.children : root).push({
133
+ node: block.descriptor,
134
+ children: walkShapeBlocks(cursor)
135
+ });
136
+ continue;
137
+ }
138
+ if (block.kind !== "paragraph") {
139
+ const parent = listStack.at(-1);
140
+ (parent !== void 0 ? parent.children : root).push(block);
141
+ continue;
142
+ }
143
+ if (isListParagraph(block)) {
144
+ openListGroup(listStack, root, block);
145
+ continue;
146
+ }
147
+ listStack.length = 0;
148
+ root.push(block);
149
+ }
150
+ return root;
151
+ }
152
+ function openConstructGroup(descriptor, cursor, listStack, headingScope) {
153
+ const parent = listStack.at(-1);
154
+ if (parent === void 0) {
155
+ headingScope.push({
156
+ node: descriptor,
157
+ children: walkSectionBlocks(cursor)
158
+ });
159
+ return;
160
+ }
161
+ parent.children.push({
162
+ node: descriptor,
163
+ children: walkShapeBlocks(cursor)
164
+ });
165
+ }
166
+ function openListGroup(listStack, scopeChildren, paragraph) {
167
+ const level = paragraph.list.level;
168
+ for (let top = listStack.at(-1); top !== void 0 && top.node.list.level >= level; top = listStack.at(-1)) listStack.pop();
169
+ const group = {
170
+ node: paragraph,
171
+ children: []
172
+ };
173
+ const parent = listStack.at(-1);
174
+ (parent !== void 0 ? parent.children : scopeChildren).push(group);
175
+ listStack.push(group);
176
+ }
177
+ //#endregion
178
+ exports.ConstructMarkerImbalanceError = ConstructMarkerImbalanceError;
179
+ exports.decompose = decompose;
180
+ exports.decomposeDrawPage = decomposeDrawPage;
181
+ exports.decomposeSection = decomposeSection;
182
+ exports.decomposeShape = decomposeShape;
183
+ exports.decomposeSheet = decomposeSheet;
184
+ exports.decomposeSlide = decomposeSlide;
185
+ exports.isHeadingParagraph = isHeadingParagraph;
186
+ exports.isListParagraph = isListParagraph;
@@ -0,0 +1,18 @@
1
+ import { C as ContentFormula, U as ContentSheet, V as ContentShape, g as ContentDrawPage, j as ContentParagraph, m as ContentDocument, st as ContentSlide, t as ConstructMarkerImbalance, z as ContentSection } from "./content-BmqzegMG.cjs";
2
+ import { B as SheetGroupNode, F as ShapeGroupNode, O as SectionGroupNode, W as SlideGroupNode, c as HeadingParagraph, i as DrawPageGroupNode, p as ListParagraph } from "./package-node-a9CyRaD3.cjs";
3
+ //#region src/decompose.d.ts
4
+ declare function isHeadingParagraph(paragraph: ContentParagraph): paragraph is HeadingParagraph;
5
+ declare function isListParagraph(paragraph: ContentParagraph): paragraph is ListParagraph;
6
+ declare class ConstructMarkerImbalanceError extends Error {
7
+ readonly imbalance: ConstructMarkerImbalance;
8
+ constructor(imbalance: ConstructMarkerImbalance);
9
+ }
10
+ type PackageChildren = SectionGroupNode[] | SlideGroupNode[] | SheetGroupNode[] | DrawPageGroupNode[] | ContentFormula[];
11
+ declare function decompose(content: ContentDocument): PackageChildren;
12
+ declare function decomposeSection(section: ContentSection): SectionGroupNode;
13
+ declare function decomposeSlide(slide: ContentSlide): SlideGroupNode;
14
+ declare function decomposeSheet(sheet: ContentSheet): SheetGroupNode;
15
+ declare function decomposeDrawPage(page: ContentDrawPage): DrawPageGroupNode;
16
+ declare function decomposeShape(shape: ContentShape): ShapeGroupNode;
17
+ //#endregion
18
+ export { ConstructMarkerImbalanceError, PackageChildren, decompose, decomposeDrawPage, decomposeSection, decomposeShape, decomposeSheet, decomposeSlide, isHeadingParagraph, isListParagraph };
@@ -0,0 +1,18 @@
1
+ import { C as ContentFormula, U as ContentSheet, V as ContentShape, g as ContentDrawPage, j as ContentParagraph, m as ContentDocument, st as ContentSlide, t as ConstructMarkerImbalance, z as ContentSection } from "./content-CIwPb_yh.js";
2
+ import { B as SheetGroupNode, F as ShapeGroupNode, O as SectionGroupNode, W as SlideGroupNode, c as HeadingParagraph, i as DrawPageGroupNode, p as ListParagraph } from "./package-node-C7RiYhyk.js";
3
+ //#region src/decompose.d.ts
4
+ declare function isHeadingParagraph(paragraph: ContentParagraph): paragraph is HeadingParagraph;
5
+ declare function isListParagraph(paragraph: ContentParagraph): paragraph is ListParagraph;
6
+ declare class ConstructMarkerImbalanceError extends Error {
7
+ readonly imbalance: ConstructMarkerImbalance;
8
+ constructor(imbalance: ConstructMarkerImbalance);
9
+ }
10
+ type PackageChildren = SectionGroupNode[] | SlideGroupNode[] | SheetGroupNode[] | DrawPageGroupNode[] | ContentFormula[];
11
+ declare function decompose(content: ContentDocument): PackageChildren;
12
+ declare function decomposeSection(section: ContentSection): SectionGroupNode;
13
+ declare function decomposeSlide(slide: ContentSlide): SlideGroupNode;
14
+ declare function decomposeSheet(sheet: ContentSheet): SheetGroupNode;
15
+ declare function decomposeDrawPage(page: ContentDrawPage): DrawPageGroupNode;
16
+ declare function decomposeShape(shape: ContentShape): ShapeGroupNode;
17
+ //#endregion
18
+ export { ConstructMarkerImbalanceError, PackageChildren, decompose, decomposeDrawPage, decomposeSection, decomposeShape, decomposeSheet, decomposeSlide, isHeadingParagraph, isListParagraph };