@officedk/pptxdk 0.0.0-stage → 0.2.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 (206) hide show
  1. package/LICENSE +21 -0
  2. package/dist/build-zrZuX4fK.d.ts +3 -0
  3. package/dist/build.d.ts +35 -0
  4. package/dist/build.js +128 -0
  5. package/dist/capabilities/dist/all.js +34 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +84 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +32 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +142 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
  11. package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
  12. package/dist/capabilities/dist/chart/chart-elements.js +12 -0
  13. package/dist/capabilities/dist/chart/chart-import.js +2403 -0
  14. package/dist/capabilities/dist/chart/chart-labels.js +86 -0
  15. package/dist/capabilities/dist/chart/chart-model.js +9 -0
  16. package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1119 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
  20. package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
  21. package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
  22. package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
  23. package/dist/capabilities/dist/chart/preview/index.js +192 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +592 -0
  25. package/dist/capabilities/dist/chart/preview/legend.js +273 -0
  26. package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
  27. package/dist/capabilities/dist/chart/preview/markers.js +100 -0
  28. package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
  29. package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
  30. package/dist/capabilities/dist/chart/preview/scales.js +365 -0
  31. package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
  32. package/dist/capabilities/dist/chart/preview/style.js +60 -0
  33. package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
  34. package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
  35. package/dist/capabilities/dist/chart/preview/types.js +5 -0
  36. package/dist/capabilities/dist/document.js +168 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +119 -0
  38. package/dist/capabilities/dist/font/font-engine.js +834 -0
  39. package/dist/capabilities/dist/font/font-import.js +766 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +72 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +74 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +41 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +649 -0
  46. package/dist/capabilities/dist/group/group-xml.js +8 -0
  47. package/dist/capabilities/dist/group/group.js +260 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +164 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +244 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +984 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +147 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +552 -0
  57. package/dist/capabilities/dist/line/line-codegen.js +89 -0
  58. package/dist/capabilities/dist/line/line-declaration.js +72 -0
  59. package/dist/capabilities/dist/line/line-elements.js +12 -0
  60. package/dist/capabilities/dist/line/line-import.js +504 -0
  61. package/dist/capabilities/dist/line/line-xml.js +9 -0
  62. package/dist/capabilities/dist/line/line.js +331 -0
  63. package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
  64. package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
  65. package/dist/capabilities/dist/masters/masters.js +250 -0
  66. package/dist/capabilities/dist/motion/motion-api.js +757 -0
  67. package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
  68. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  69. package/dist/capabilities/dist/motion/motion-import.js +1568 -0
  70. package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
  71. package/dist/capabilities/dist/motion/motion-query.js +423 -0
  72. package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
  73. package/dist/capabilities/dist/motion/motion.js +1617 -0
  74. package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
  75. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  76. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  77. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  78. package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
  79. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  80. package/dist/capabilities/dist/notes/notes.js +194 -0
  81. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
  82. package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
  83. package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
  84. package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
  85. package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
  86. package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
  87. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  88. package/dist/capabilities/dist/shape/shape-import.js +628 -0
  89. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  90. package/dist/capabilities/dist/shape/shape.js +320 -0
  91. package/dist/capabilities/dist/shared/geometry.js +1681 -0
  92. package/dist/capabilities/dist/shared/identity.js +205 -0
  93. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  94. package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
  95. package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
  96. package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
  97. package/dist/capabilities/dist/shared/text-schemas.js +241 -0
  98. package/dist/capabilities/dist/shared/text-service.js +2252 -0
  99. package/dist/capabilities/dist/shared/visual.js +1197 -0
  100. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  101. package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
  102. package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
  103. package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
  104. package/dist/capabilities/dist/table/table-codegen.js +125 -0
  105. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  106. package/dist/capabilities/dist/table/table-elements.js +27 -0
  107. package/dist/capabilities/dist/table/table-import.js +606 -0
  108. package/dist/capabilities/dist/table/table-schemas.js +334 -0
  109. package/dist/capabilities/dist/table/table-xml.js +30 -0
  110. package/dist/capabilities/dist/table/table.js +739 -0
  111. package/dist/capabilities/dist/text/text-codegen.js +198 -0
  112. package/dist/capabilities/dist/text/text-declaration.js +27 -0
  113. package/dist/capabilities/dist/text/text-elements.js +54 -0
  114. package/dist/capabilities/dist/text/text-import.js +1224 -0
  115. package/dist/capabilities/dist/text/text-xml.js +9 -0
  116. package/dist/capabilities/dist/text/text.js +320 -0
  117. package/dist/capabilities/dist/transition/transition-api.js +136 -0
  118. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  119. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  120. package/dist/capabilities/dist/transition/transition.js +260 -0
  121. package/dist/capability-BbKW9w4O.d.ts +2131 -0
  122. package/dist/cli.js +20 -0
  123. package/dist/codegen/dist/assets.js +79 -0
  124. package/dist/codegen/dist/codegen.js +691 -0
  125. package/dist/codegen/dist/identifiers.js +203 -0
  126. package/dist/codegen/dist/index.js +3 -0
  127. package/dist/codegen/dist/printer.js +143 -0
  128. package/dist/codegen/dist/types.js +77 -0
  129. package/dist/core/dist/author-ids.js +51 -0
  130. package/dist/core/dist/author-schemas.js +330 -0
  131. package/dist/core/dist/block-flex-layout.js +801 -0
  132. package/dist/core/dist/build.js +4 -0
  133. package/dist/core/dist/capability.js +15 -0
  134. package/dist/core/dist/declaration.js +16 -0
  135. package/dist/core/dist/diagnostics.js +353 -0
  136. package/dist/core/dist/document-internals.js +26 -0
  137. package/dist/core/dist/document.js +417 -0
  138. package/dist/core/dist/font-seal.js +204 -0
  139. package/dist/core/dist/geometry-schemas.js +256 -0
  140. package/dist/core/dist/grid-layout.js +449 -0
  141. package/dist/core/dist/host.js +40 -0
  142. package/dist/core/dist/index.js +15 -0
  143. package/dist/core/dist/input-values.js +61 -0
  144. package/dist/core/dist/layout-protocol.js +61 -0
  145. package/dist/core/dist/layout-schemas.js +201 -0
  146. package/dist/core/dist/layout.js +340 -0
  147. package/dist/core/dist/masters.js +194 -0
  148. package/dist/core/dist/morph.js +30 -0
  149. package/dist/core/dist/placeholders.js +275 -0
  150. package/dist/core/dist/query.js +190 -0
  151. package/dist/core/dist/resolution.js +12 -0
  152. package/dist/core/dist/resolve.js +2246 -0
  153. package/dist/core/dist/stage-options.js +300 -0
  154. package/dist/core/dist/theme.js +1023 -0
  155. package/dist/core/dist/transform-geometry.js +72 -0
  156. package/dist/document-41spD7bq.d.ts +1350 -0
  157. package/dist/emit/dist/emit.js +957 -0
  158. package/dist/emit/dist/index.js +5 -0
  159. package/dist/emit/dist/ooxml.js +661 -0
  160. package/dist/emit/dist/shape-tree.js +12 -0
  161. package/dist/import/dist/alternate-content.js +54 -0
  162. package/dist/import/dist/diagnostics.js +157 -0
  163. package/dist/import/dist/fonts.js +309 -0
  164. package/dist/import/dist/import.js +513 -0
  165. package/dist/import/dist/index.js +16 -0
  166. package/dist/import/dist/masters.js +1293 -0
  167. package/dist/import/dist/mechanism.js +10 -0
  168. package/dist/import/dist/namespaces.js +61 -0
  169. package/dist/import/dist/notes-masters.js +300 -0
  170. package/dist/import/dist/opc.js +233 -0
  171. package/dist/import/dist/resources.js +166 -0
  172. package/dist/import/dist/sections.js +139 -0
  173. package/dist/import/dist/themes.js +777 -0
  174. package/dist/import/dist/visual.js +821 -0
  175. package/dist/import/dist/xml-fragments.js +277 -0
  176. package/dist/import/dist/xml-reader.js +267 -0
  177. package/dist/index-1ag7U9Jt.d.ts +63 -0
  178. package/dist/index-BEwhk7c8.d.ts +72 -0
  179. package/dist/index-cK2KtukZ.d.ts +161 -0
  180. package/dist/index-v77CTJev.d.ts +55 -0
  181. package/dist/index.d.ts +8 -0
  182. package/dist/index.js +82 -0
  183. package/dist/node.d.ts +53 -0
  184. package/dist/node.js +225 -0
  185. package/dist/pptxdk/src/cli-commands.js +907 -0
  186. package/dist/pptxdk/src/compose.js +53 -0
  187. package/dist/pptxdk/src/slide.js +9 -0
  188. package/dist/preview/dist/index.js +342 -0
  189. package/dist/preview/dist/options.js +40 -0
  190. package/dist/preview/dist/svg-guard.js +1089 -0
  191. package/dist/preview.d.ts +12 -0
  192. package/dist/preview.js +29 -0
  193. package/dist/react/dist/append.js +66 -0
  194. package/dist/react/dist/document-adapter.js +404 -0
  195. package/dist/react/dist/elements.js +82 -0
  196. package/dist/react/dist/from-vanilla.js +57 -0
  197. package/dist/react/dist/index.js +89 -0
  198. package/dist/react/dist/mount.js +34 -0
  199. package/dist/react/dist/reconciler.js +290 -0
  200. package/dist/react.d.ts +235 -0
  201. package/dist/react.js +31 -0
  202. package/dist/transition-6n8GZxSg.d.ts +9 -0
  203. package/dist/vanilla.d.ts +4 -0
  204. package/dist/vanilla.js +15 -0
  205. package/package.json +79 -3
  206. package/README.md +0 -3
@@ -0,0 +1,417 @@
1
+ import "./author-ids.js";
2
+ import "./author-schemas.js";
3
+ import { isSlideLayoutDefinition } from "./masters.js";
4
+ import "./layout-schemas.js";
5
+ import { insertDeclarationChild, registerInternalDeclarationProps, removeDeclarationChild, replaceDeclarationProps } from "./document-internals.js";
6
+ import "./placeholders.js";
7
+ import { cloneExternalValue, snapshotValue } from "./input-values.js";
8
+ import "./theme.js";
9
+ // ../core/dist/document.js
10
+ var _a;
11
+ var _b;
12
+ function isRecord(value) {
13
+ return typeof value === "object" && value !== null && !Array.isArray(value);
14
+ }
15
+ function declarationChild(item) {
16
+ if (typeof item === "string") return Object.freeze({
17
+ type: "#text",
18
+ text: item
19
+ });
20
+ if (item instanceof CommonNode) return item;
21
+ throw new TypeError("Rich text content must be a string or an editable document node");
22
+ }
23
+ function requirePatchObject(value, label) {
24
+ if (!isRecord(value)) throw new TypeError(`${label} must be an object`);
25
+ }
26
+ function normalizeProps(props) {
27
+ const copy = {};
28
+ for (const [key, value] of Object.entries(props)) {
29
+ if (key === "children" || value === void 0) continue;
30
+ Object.defineProperty(copy, key, {
31
+ configurable: false,
32
+ enumerable: true,
33
+ value: snapshotValue(value),
34
+ writable: false
35
+ });
36
+ }
37
+ return Object.freeze(copy);
38
+ }
39
+ /**
40
+ * Common editable document node shared by command authoring and the React handoff.
41
+ *
42
+ * The node exposes a read-only declaration view to the formal build. Author mutations go through
43
+ * `set`, `style`, and structure operations so parent ownership, value isolation, and update timing
44
+ * stay in one place. Declaration getters return fresh isolated values; live nodes keep identity.
45
+ */
46
+ var CommonNode = class {
47
+ type;
48
+ kind;
49
+ /** Page-affiliated declarations are reached below hidden canvas parents by the formal build. */
50
+ pageAffiliated;
51
+ #props;
52
+ #children = [];
53
+ #childrenView = Object.freeze([]);
54
+ #parent;
55
+ #owner;
56
+ constructor(kind, type, props = {}, options = {}) {
57
+ this.kind = kind;
58
+ this.type = type;
59
+ this.pageAffiliated = options.pageAffiliated === true;
60
+ const initialProps = normalizeProps(props);
61
+ this.#props = initialProps;
62
+ registerInternalDeclarationProps(this, initialProps);
63
+ if (kind === "deck") this.#owner = this;
64
+ }
65
+ /** Isolated declaration values for external inspection; mutating the returned value cannot edit the node. */
66
+ get props() {
67
+ return cloneExternalValue(this.#props);
68
+ }
69
+ /** Author id declared on this node, ignoring non-string values rejected by the formal build. */
70
+ get id() {
71
+ const value = this.#props["id"];
72
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
73
+ }
74
+ /** Current parent container, or undefined while detached. */
75
+ get parent() {
76
+ return this.#parent;
77
+ }
78
+ /** Scoped author query rooted at this node; it searches children and stops at the next named scope. */
79
+ get query() {
80
+ return new AuthorQuery(this);
81
+ }
82
+ /** Read-only child declaration view; node entries keep their editable identity. */
83
+ get children() {
84
+ return this.#childrenView;
85
+ }
86
+ /**
87
+ * Adapter-only complete declaration replacement for one React commit.
88
+ *
89
+ * React commits all current JSX props, so absent fields must disappear instead of surviving from a
90
+ * previous commit as they would under the author-facing single-level update. Values still pass
91
+ * through the same field-level input snapshot as construction.
92
+ */
93
+ [replaceDeclarationProps](props) {
94
+ const next = normalizeProps(props);
95
+ this.#props = next;
96
+ registerInternalDeclarationProps(this, next);
97
+ }
98
+ /**
99
+ * Adapter-only insertion or same-document reordering during React reconciliation.
100
+ *
101
+ * React may reposition an attached host instance with `insertBefore`; author `append` remains
102
+ * strict and the adapter reaches this operation explicitly. Text entries are accepted so rich-text
103
+ * containers can be reconciled in place without rebuilding their content.
104
+ */
105
+ [insertDeclarationChild](child, before) {
106
+ if (before === child) return;
107
+ if (child instanceof _a) {
108
+ if (child === this) throw new Error("Cannot attach a node inside its own descendant tree");
109
+ if (child.#parent === this) {
110
+ const index = this.#children.indexOf(child);
111
+ if (index !== -1) this.#children.splice(index, 1);
112
+ } else {
113
+ this.assertCanInsert(child, true);
114
+ const previousParent = child.#parent;
115
+ if (previousParent !== void 0) previousParent.#detach(child);
116
+ const owner = this.#owner;
117
+ if (owner !== void 0) child.#assignOwner(owner);
118
+ child.#parent = this;
119
+ }
120
+ } else {
121
+ const index = this.#children.indexOf(child);
122
+ if (index !== -1) this.#children.splice(index, 1);
123
+ }
124
+ const index = before === void 0 ? -1 : this.#children.indexOf(before);
125
+ if (index === -1) this.#children.push(child);
126
+ else this.#children.splice(index, 0, child);
127
+ this.#refreshChildren();
128
+ }
129
+ /** Adapter-only removal during React reconciliation; author removal remains `remove()`. */
130
+ [removeDeclarationChild](child) {
131
+ this.#detach(child);
132
+ }
133
+ /** Applies an ordinary property update; `style` and `children` use their dedicated operations. */
134
+ set(patch) {
135
+ const record = patch;
136
+ requirePatchObject(record, "set() patch");
137
+ if ("style" in record || "children" in record) throw new TypeError("set() cannot update style or children; use style() and structural operations");
138
+ const next = { ...this.#props };
139
+ for (const [key, value] of Object.entries(record)) if (value === void 0) delete next[key];
140
+ else next[key] = snapshotValue(value);
141
+ const frozen = Object.freeze(next);
142
+ this.#props = frozen;
143
+ registerInternalDeclarationProps(this, frozen);
144
+ return this;
145
+ }
146
+ /** Applies a single-level local style update; nested values replace and undefined removes a local declaration. */
147
+ style(patch) {
148
+ const record = patch;
149
+ requirePatchObject(record, "style() patch");
150
+ const next = { ...isRecord(this.#props["style"]) ? this.#props["style"] : {} };
151
+ for (const [key, value] of Object.entries(record)) if (value === void 0) delete next[key];
152
+ else next[key] = snapshotValue(value);
153
+ const frozen = Object.freeze({
154
+ ...this.#props,
155
+ style: Object.freeze(next)
156
+ });
157
+ this.#props = frozen;
158
+ registerInternalDeclarationProps(this, frozen);
159
+ return this;
160
+ }
161
+ /** Detaches this node while retaining its document ownership, mirroring explicit removal semantics. */
162
+ remove() {
163
+ const parent = this.#parent;
164
+ if (parent !== void 0) parent.#detach(this);
165
+ return this;
166
+ }
167
+ /** Moves a node in the same document or attaches a detached node, preserving identity. */
168
+ moveTo(parent, before) {
169
+ if (!(parent instanceof CommonContainer)) throw new TypeError("moveTo() target must be an editable container");
170
+ if (before !== void 0 && before.#parent !== parent) throw new Error("before must be a node that is a direct child of the target container");
171
+ if (before === this) return this;
172
+ parent.assertCanInsert(this, true);
173
+ const previousParent = this.#parent;
174
+ if (previousParent !== void 0) previousParent.#detach(this);
175
+ parent.insertNode(this, before);
176
+ return this;
177
+ }
178
+ #refreshChildren() {
179
+ this.#childrenView = Object.freeze([...this.#children]);
180
+ }
181
+ #detach(child) {
182
+ const index = this.#children.indexOf(child);
183
+ if (index === -1) return;
184
+ this.#children.splice(index, 1);
185
+ if (child instanceof _a) child.#parent = void 0;
186
+ this.#refreshChildren();
187
+ }
188
+ #ownerConflict(owner) {
189
+ if (this.#owner !== void 0 && this.#owner !== owner) return true;
190
+ return this.#children.some((child) => child instanceof _a && child.#ownerConflict(owner));
191
+ }
192
+ #assignOwner(owner) {
193
+ if (this.#owner === void 0) this.#owner = owner;
194
+ for (const child of this.#children) if (child instanceof _a) child.#assignOwner(owner);
195
+ }
196
+ assertCanInsert(child, allowAttached = false) {
197
+ if (child === this) throw new Error("Cannot attach a node inside its own descendant tree");
198
+ for (let ancestor = this.#parent; ancestor !== void 0; ancestor = ancestor.#parent) if (ancestor === child) throw new Error("Cannot attach a node inside its own descendant tree");
199
+ if (!allowAttached && child.#parent !== void 0) throw new Error("Node is already attached; use moveTo() for an explicit same-document move");
200
+ const owner = this.#owner;
201
+ if (owner !== void 0 && child.#ownerConflict(owner)) throw new Error("Cannot attach a node owned by another document");
202
+ }
203
+ insertNode(child, before) {
204
+ this.assertCanInsert(child);
205
+ if (before !== void 0 && before.#parent !== this) throw new Error("before must be a node that is a direct child of the target container");
206
+ const owner = this.#owner;
207
+ if (owner !== void 0) child.#assignOwner(owner);
208
+ child.#parent = this;
209
+ const index = before === void 0 ? this.#children.length : this.#children.indexOf(before);
210
+ this.#children.splice(index, 0, child);
211
+ this.#refreshChildren();
212
+ }
213
+ insertRichTextItems(items, replace) {
214
+ const next = items.map((item) => declarationChild(item));
215
+ const seen = /* @__PURE__ */ new Set();
216
+ for (const child of next) {
217
+ if (seen.has(child)) throw new Error("The same node cannot be attached twice");
218
+ seen.add(child);
219
+ if (child instanceof _a) this.assertCanInsert(child);
220
+ }
221
+ const owner = this.#owner;
222
+ if (replace) {
223
+ for (const child of this.#children) if (child instanceof _a) child.#parent = void 0;
224
+ this.#children = [];
225
+ }
226
+ for (const child of next) {
227
+ if (child instanceof _a) {
228
+ child.#parent = this;
229
+ if (owner !== void 0) child.#assignOwner(owner);
230
+ }
231
+ this.#children.push(child);
232
+ }
233
+ this.#refreshChildren();
234
+ }
235
+ };
236
+ _a = CommonNode;
237
+ /** Editable structural container: deck, slide, section, box, and annotation-only containers. */
238
+ var CommonContainer = class extends CommonNode {
239
+ append(...children) {
240
+ const seen = /* @__PURE__ */ new Set();
241
+ for (const child of children) {
242
+ if (!(child instanceof CommonNode)) throw new TypeError("append() accepts editable document nodes only");
243
+ if (seen.has(child)) throw new Error("The same node cannot be attached twice");
244
+ seen.add(child);
245
+ this.assertCanInsert(child);
246
+ }
247
+ for (const child of children) this.insertNode(child);
248
+ return this;
249
+ }
250
+ };
251
+ /** Rich-text container whose children may also be literal text. */
252
+ var RichTextContainer = class extends CommonContainer {
253
+ append(...items) {
254
+ this.insertRichTextItems(items, false);
255
+ return this;
256
+ }
257
+ /** Replaces all rich-text content atomically after validating every new item. */
258
+ content(...items) {
259
+ this.insertRichTextItems(items, true);
260
+ return this;
261
+ }
262
+ };
263
+ /** Explicit failures raised by scoped author queries instead of returning unchecked nodes. */
264
+ var AuthorQueryError = class extends Error {
265
+ code;
266
+ constructor(code, message) {
267
+ super(message);
268
+ this.code = code;
269
+ this.name = "AuthorQueryError";
270
+ }
271
+ };
272
+ function assertAuthorId(id) {
273
+ if (typeof id !== "string" || id.trim() === "") throw new AuthorQueryError("invalid-id", "Author id must be a non-empty string");
274
+ }
275
+ function authorIdOf(node) {
276
+ const value = node.props["id"];
277
+ return typeof value === "string" && value.trim() !== "" ? value : void 0;
278
+ }
279
+ function authorPath(node) {
280
+ const segments = [];
281
+ for (let current = node; current !== void 0; current = current.parent) {
282
+ if (current.parent === void 0 && current.kind === "deck") {
283
+ segments.unshift("deck");
284
+ continue;
285
+ }
286
+ const id = authorIdOf(current);
287
+ segments.unshift(id === void 0 ? current.kind : `${current.kind}[${id}]`);
288
+ }
289
+ return segments.join("/");
290
+ }
291
+ /**
292
+ * Author-facing locator over the live editable document.
293
+ *
294
+ * A query is scoped to one node. Lookups traverse anonymous layout nodes but stop at the next node
295
+ * declaring an author id, so callers descend explicitly through named scopes. Pages always declare
296
+ * their author id and act as the root author scope. Returned `.node` values are the same editable
297
+ * instances the document holds; they are never build observations.
298
+ */
299
+ var AuthorQuery = class {
300
+ #node;
301
+ constructor(node) {
302
+ this.#node = node;
303
+ }
304
+ /** Editable node at this query scope. */
305
+ get node() {
306
+ return this.#node;
307
+ }
308
+ /** Readable path derived from the current parent chain and declared author ids. */
309
+ get path() {
310
+ return authorPath(this.#node);
311
+ }
312
+ /** Returns the single editable node named `id` directly in this scope. */
313
+ getNode(id) {
314
+ assertAuthorId(id);
315
+ return this.#one(id, "getNode").node;
316
+ }
317
+ /** Returns a scoped query handle for the single node named `id`, enabling stepwise lookups. */
318
+ get(id) {
319
+ assertAuthorId(id);
320
+ return this.#one(id, "get");
321
+ }
322
+ /** Lists every node named `id` in this scope; duplicates remain visible to callers before build validation. */
323
+ getAll(id) {
324
+ assertAuthorId(id);
325
+ return Object.freeze(this.#matches(id).map((match) => new _b(match)));
326
+ }
327
+ /**
328
+ * Returns the node named `id` after checking the caller's type predicate.
329
+ *
330
+ * Missing, ambiguous, and type-mismatched results throw `AuthorQueryError` with distinct codes so
331
+ * callers never need an unchecked assertion to reach an editable capability node.
332
+ */
333
+ getAs(id, guard) {
334
+ const match = this.#one(id, "getAs").node;
335
+ if (!guard(match)) throw new AuthorQueryError("type-mismatch", `Author id ${JSON.stringify(id)} does not match the expected node type`);
336
+ return match;
337
+ }
338
+ #one(id, operation) {
339
+ assertAuthorId(id);
340
+ const matches = this.#matches(id);
341
+ if (matches.length === 0) throw new AuthorQueryError("missing-id", `No author node found for id ${JSON.stringify(id)} in ${this.path}`);
342
+ if (matches.length > 1) throw new AuthorQueryError("ambiguous-id", `Author id ${JSON.stringify(id)} is duplicated in ${this.path}`);
343
+ const [match] = matches;
344
+ if (match === void 0) throw new AuthorQueryError("missing-id", `${operation} could not resolve author id ${JSON.stringify(id)}`);
345
+ return new _b(match);
346
+ }
347
+ #matches(id) {
348
+ const matches = [];
349
+ const visit = (parent) => {
350
+ for (const child of parent.children) {
351
+ if (!(child instanceof CommonNode)) continue;
352
+ const childId = authorIdOf(child);
353
+ if (childId === id) matches.push(child);
354
+ else if (childId === void 0) visit(child);
355
+ }
356
+ };
357
+ visit(this.#node);
358
+ return matches;
359
+ }
360
+ };
361
+ _b = AuthorQuery;
362
+ /** Editable SlideLayout node owned by a SlideMaster. */
363
+ var SlideLayoutContainer = class extends CommonContainer {};
364
+ /** Editable Slide node exposing named placeholder lookup alongside slide styling. */
365
+ var SlideContainer = class extends CommonContainer {
366
+ /** Finds a bound placeholder node on this slide by its layout placeholder key. */
367
+ placeholder(key) {
368
+ for (const child of this.children) if (child instanceof CommonNode && child.props["placeholder"] === key) return child;
369
+ }
370
+ };
371
+ /** Editable SlideMaster node owning its SlideLayouts in declaration order. */
372
+ var SlideMasterContainer = class extends CommonContainer {
373
+ /** Native theme bound to this master (shared by object identity across masters when reused). */
374
+ get theme() {
375
+ return this.props["theme"];
376
+ }
377
+ /** Direct SlideLayout children owned by this master in `<p:sldLayoutIdLst>` order. */
378
+ get layouts() {
379
+ return Object.freeze(this.children.filter((child) => child instanceof CommonNode && child.kind === "slide-layout"));
380
+ }
381
+ };
382
+ /** Editable Deck root node exposing its explicit SlideMasters. */
383
+ var DeckContainer = class extends CommonContainer {
384
+ /** Direct SlideMaster children owned by this deck in `<p:sldMasterIdLst>` order. */
385
+ get masters() {
386
+ return Object.freeze(this.children.filter((child) => child instanceof CommonNode && child.kind === "slide-master"));
387
+ }
388
+ };
389
+ /** Creates the editable Deck node used by both React host expansion and command authoring. */
390
+ function createDeckNode(props) {
391
+ return new DeckContainer("deck", "deck", props);
392
+ }
393
+ /** Creates an editable SlideMaster node used by both React host expansion and command authoring. */
394
+ function createSlideMasterNode(props = {}) {
395
+ return new SlideMasterContainer("slide-master", "slide-master", props);
396
+ }
397
+ /** Creates an editable SlideLayout node from inline props or a shared `defineSlideLayout` definition. */
398
+ function createSlideLayoutNode(propsOrDefinition = {}) {
399
+ if (isSlideLayoutDefinition(propsOrDefinition)) return new SlideLayoutContainer("slide-layout", "slide-layout", {
400
+ ...propsOrDefinition.props,
401
+ layout: propsOrDefinition
402
+ });
403
+ if (isRecord(propsOrDefinition) && isSlideLayoutDefinition(propsOrDefinition["layout"])) return new SlideLayoutContainer("slide-layout", "slide-layout", {
404
+ ...propsOrDefinition["layout"].props,
405
+ ...propsOrDefinition
406
+ });
407
+ return new SlideLayoutContainer("slide-layout", "slide-layout", propsOrDefinition);
408
+ }
409
+ /** Creates the editable Slide node used by both React host expansion and command authoring. */
410
+ function createSlideNode(props) {
411
+ return new SlideContainer("slide", "slide", props);
412
+ }
413
+ /** Creates the editable Section node used by both React host expansion and command authoring. */
414
+ function createSectionNode(props) {
415
+ return new CommonContainer("section", "section", props);
416
+ }
417
+ export { AuthorQuery, AuthorQueryError, CommonContainer, CommonNode, DeckContainer, RichTextContainer, SlideContainer, SlideLayoutContainer, SlideMasterContainer, createDeckNode, createSectionNode, createSlideLayoutNode, createSlideMasterNode, createSlideNode };
@@ -0,0 +1,204 @@
1
+ import { createHash } from "node:crypto";
2
+ // ../core/dist/font-seal.js
3
+ const immutableBytes = /* @__PURE__ */ new WeakSet();
4
+ const sha256ByBytes = /* @__PURE__ */ new WeakMap();
5
+ const classificationByBytes = /* @__PURE__ */ new WeakMap();
6
+ const sealedFonts = /* @__PURE__ */ new WeakSet();
7
+ const sealedFaceResources = /* @__PURE__ */ new WeakMap();
8
+ const sansSerifPanoseStyles = /* @__PURE__ */ new Set([
9
+ 11,
10
+ 12,
11
+ 13,
12
+ 14,
13
+ 15
14
+ ]);
15
+ /** Computes DrawingML `pitchFamily` from 10-byte PANOSE and `post.isFixedPitch`. */
16
+ function computePitchFamilyFromPanose(panose, isFixedPitch) {
17
+ const familyType = panose[0] ?? 0;
18
+ const serifStyle = panose[1] ?? 0;
19
+ const proportion = panose[3] ?? 0;
20
+ const fixedPitch = isFixedPitch !== 0 || proportion === 9;
21
+ return (fixedPitch ? 48 : familyType === 2 ? sansSerifPanoseStyles.has(serifStyle) ? 32 : serifStyle >= 2 ? 16 : 0 : familyType === 3 ? 64 : familyType === 4 || familyType === 5 ? 80 : 0) | (fixedPitch ? 1 : 2);
22
+ }
23
+ /** Formats 10-byte `OS/2.panose` as a 20-character uppercase hexadecimal string. */
24
+ function formatPanoseHex(panose) {
25
+ let out = "";
26
+ for (let index = 0; index < 10; index += 1) out += ((panose[index] ?? 0) & 255).toString(16).padStart(2, "0").toUpperCase();
27
+ return out;
28
+ }
29
+ /**
30
+ * Extracts `OS/2` `panose` and `pitchFamily` from raw SFNT (`.ttf`/`.otf`) bytes using pure
31
+ * `DataView` reads so `@pptxdk/core` and `@pptxdk/emit` stay free of `fontkit`.
32
+ */
33
+ function parseSfntClassificationUncached(bytes) {
34
+ if (bytes.byteLength < 12) return void 0;
35
+ const signature = String.fromCharCode(bytes[0], bytes[1], bytes[2], bytes[3]);
36
+ if (signature !== "\0\0\0" && signature !== "true" && signature !== "OTTO") return;
37
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
38
+ const numTables = view.getUint16(4);
39
+ if (12 + numTables * 16 > bytes.byteLength) return void 0;
40
+ let os2Offset;
41
+ let os2Length = 0;
42
+ let postOffset;
43
+ let postLength = 0;
44
+ for (let index = 0; index < numTables; index += 1) {
45
+ const record = 12 + index * 16;
46
+ const tag = String.fromCharCode(bytes[record], bytes[record + 1], bytes[record + 2], bytes[record + 3]);
47
+ const offset = view.getUint32(record + 8);
48
+ const length = view.getUint32(record + 12);
49
+ if (offset > bytes.byteLength || length > bytes.byteLength - offset) return;
50
+ if (tag === "OS/2") {
51
+ os2Offset = offset;
52
+ os2Length = length;
53
+ } else if (tag === "post") {
54
+ postOffset = offset;
55
+ postLength = length;
56
+ }
57
+ }
58
+ if (os2Offset === void 0 || os2Length < 42) return;
59
+ const panoseBytes = bytes.subarray(os2Offset + 32, os2Offset + 42);
60
+ const isFixedPitch = postOffset !== void 0 && postLength >= 16 ? view.getUint32(postOffset + 12) : 0;
61
+ return {
62
+ panose: formatPanoseHex(panoseBytes),
63
+ pitchFamily: computePitchFamilyFromPanose(panoseBytes, isFixedPitch)
64
+ };
65
+ }
66
+ function getOrParseSfntClassification(bytes) {
67
+ if (immutableBytes.has(bytes)) {
68
+ const cached = classificationByBytes.get(bytes);
69
+ if (cached !== void 0) return cached ?? void 0;
70
+ const parsed = parseSfntClassificationUncached(bytes);
71
+ classificationByBytes.set(bytes, parsed ?? null);
72
+ return parsed;
73
+ }
74
+ return parseSfntClassificationUncached(bytes);
75
+ }
76
+ /**
77
+ * Marks an internally owned `Uint8Array` as immutable so `bytesSha256` can memoize its digest
78
+ * across pipeline stages and `snapshotValue` / `readImage` can reuse it zero-copy.
79
+ */
80
+ function markImmutableBytes(bytes) {
81
+ immutableBytes.add(bytes);
82
+ return bytes;
83
+ }
84
+ /** Returns `true` when `bytes` is an internal immutable buffer registered with `markImmutableBytes`. */
85
+ function isImmutableBytes(bytes) {
86
+ return immutableBytes.has(bytes);
87
+ }
88
+ /**
89
+ * Computes the lowercase hex SHA-256 digest for a `Uint8Array`.
90
+ *
91
+ * Caching in `sha256ByBytes` is restricted to buffers registered via `markImmutableBytes`;
92
+ * unmarked caller-owned buffers are hashed fresh every time to prevent cache poisoning.
93
+ */
94
+ function bytesSha256(bytes) {
95
+ if (!immutableBytes.has(bytes)) return createHash("sha256").update(bytes).digest("hex");
96
+ const cached = sha256ByBytes.get(bytes);
97
+ if (cached !== void 0) return cached;
98
+ const digest = createHash("sha256").update(bytes).digest("hex");
99
+ sha256ByBytes.set(bytes, digest);
100
+ return digest;
101
+ }
102
+ /**
103
+ * Creates a frozen `FontFace` whose private bytes live in a module-private `WeakMap` and whose
104
+ * enumerable `.data` getter returns a fresh defensive `Uint8Array` copy on public reads.
105
+ */
106
+ function createSealedFontFace(input) {
107
+ const faceRecord = {
108
+ ...input.weight === void 0 ? {} : { weight: input.weight },
109
+ ...input.style === void 0 ? {} : { style: input.style }
110
+ };
111
+ if (input.bytes !== void 0) {
112
+ const privateBytes = markImmutableBytes(input.bytes);
113
+ const sha256 = input.sha256 ?? bytesSha256(privateBytes);
114
+ sha256ByBytes.set(privateBytes, sha256);
115
+ Object.defineProperty(faceRecord, "data", {
116
+ enumerable: true,
117
+ configurable: false,
118
+ get() {
119
+ return new Uint8Array(privateBytes);
120
+ }
121
+ });
122
+ const frozenFace = Object.freeze(faceRecord);
123
+ sealedFaceResources.set(frozenFace, {
124
+ bytes: privateBytes,
125
+ sha256,
126
+ ...input.panose === void 0 ? {} : { panose: input.panose },
127
+ ...input.pitchFamily === void 0 ? {} : { pitchFamily: input.pitchFamily }
128
+ });
129
+ return frozenFace;
130
+ }
131
+ return Object.freeze(faceRecord);
132
+ }
133
+ /**
134
+ * Marks a frozen `Font` object as sealed so input snapshotting and Zod validation short-circuit
135
+ * in $O(1)$ without adding extra own properties or symbols to the object.
136
+ */
137
+ function markSealedFont(fontValue) {
138
+ Object.freeze(fontValue);
139
+ sealedFonts.add(fontValue);
140
+ return fontValue;
141
+ }
142
+ /** Returns `true` when `value` is a sealed `Font` created by `font()`. */
143
+ function isSealedFont(value) {
144
+ return typeof value === "object" && value !== null && sealedFonts.has(value);
145
+ }
146
+ /**
147
+ * Checks whether a `FontFace` carries binary bytes without triggering the defensive `.data`
148
+ * getter on sealed faces.
149
+ */
150
+ function hasFontFaceBytes(face) {
151
+ if (sealedFaceResources.has(face)) return true;
152
+ return face.data !== void 0;
153
+ }
154
+ /**
155
+ * Returns the internal bytes and cached SHA-256 digest for a sealed or unsealed `FontFace`
156
+ * without invoking the public defensive `.data` copy getter on sealed faces.
157
+ */
158
+ function peekFontFaceResource(face) {
159
+ const sealed = sealedFaceResources.get(face);
160
+ if (sealed !== void 0) return sealed;
161
+ const rawBytes = face.data;
162
+ if (rawBytes === void 0) return;
163
+ return {
164
+ bytes: rawBytes,
165
+ sha256: bytesSha256(rawBytes)
166
+ };
167
+ }
168
+ /**
169
+ * Returns cached or parsed `OS/2` `panose` and `pitchFamily` metadata for a sealed or unsealed
170
+ * `FontFace` without triggering defensive `.data` copies on sealed faces.
171
+ */
172
+ function peekFontFaceClassification(face) {
173
+ const sealed = sealedFaceResources.get(face);
174
+ if (sealed !== void 0) {
175
+ if (sealed.pitchFamily !== void 0) return {
176
+ ...sealed.panose === void 0 ? {} : { panose: sealed.panose },
177
+ pitchFamily: sealed.pitchFamily
178
+ };
179
+ return getOrParseSfntClassification(sealed.bytes);
180
+ }
181
+ const rawBytes = face.data;
182
+ if (rawBytes === void 0) return void 0;
183
+ return getOrParseSfntClassification(rawBytes);
184
+ }
185
+ /**
186
+ * Resolves `OS/2` classification metadata (`panose` and `pitchFamily`) for a `Font` value,
187
+ * preferring the face matching `(weight, style)`, then `(400, "normal")`, then the first face
188
+ * with classification metadata.
189
+ */
190
+ function resolveFontClassification(fontValue, weight, faceStyle) {
191
+ const faces = fontValue.faces;
192
+ if (faces === void 0 || faces.length === 0) return void 0;
193
+ const targetWeight = weight ?? 400;
194
+ const targetStyle = faceStyle ?? "normal";
195
+ const exact = faces.find((candidate) => (candidate.weight ?? 400) === targetWeight && (candidate.style ?? "normal") === targetStyle && peekFontFaceClassification(candidate) !== void 0);
196
+ if (exact !== void 0) return peekFontFaceClassification(exact);
197
+ const regular = targetWeight === 400 && targetStyle === "normal" ? void 0 : faces.find((candidate) => (candidate.weight ?? 400) === 400 && (candidate.style ?? "normal") === "normal" && peekFontFaceClassification(candidate) !== void 0);
198
+ if (regular !== void 0) return peekFontFaceClassification(regular);
199
+ for (const candidate of faces) {
200
+ const cls = peekFontFaceClassification(candidate);
201
+ if (cls !== void 0) return cls;
202
+ }
203
+ }
204
+ export { bytesSha256, computePitchFamilyFromPanose, createSealedFontFace, formatPanoseHex, hasFontFaceBytes, isImmutableBytes, isSealedFont, markImmutableBytes, markSealedFont, peekFontFaceClassification, peekFontFaceResource, resolveFontClassification };