@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,10 @@
1
+ // ../import/dist/mechanism.js
2
+ /** Defines a native canvas mechanism requiring production `emit`, `paint`, and `import` directions. */
3
+ function defineCanvasMechanism(definition) {
4
+ return Object.freeze(definition);
5
+ }
6
+ /** Defines a native show mechanism requiring production `emit` and `import` directions without `paint`. */
7
+ function defineShowMechanism(definition) {
8
+ return Object.freeze(definition);
9
+ }
10
+ export { defineCanvasMechanism, defineShowMechanism };
@@ -0,0 +1,61 @@
1
+ // ../import/dist/namespaces.js
2
+ const XMLNS_NS = "http://www.w3.org/2000/xmlns/";
3
+ const XML_NS = "http://www.w3.org/XML/1998/namespace";
4
+ const OPC_REL_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
5
+ const MC_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
6
+ const P_NS = "http://schemas.openxmlformats.org/presentationml/2006/main";
7
+ const P14_NS = "http://schemas.microsoft.com/office/powerpoint/2010/main";
8
+ const P159_NS = "http://schemas.microsoft.com/office/powerpoint/2015/09/main";
9
+ const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
10
+ const C_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
11
+ const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
12
+ const REL_OFFICE_DOCUMENT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
13
+ const REL_CHART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
14
+ const REL_SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
15
+ const REL_SLIDE_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
16
+ const REL_SLIDE_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster";
17
+ const REL_THEME = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
18
+ const REL_NOTES_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster";
19
+ const REL_NOTES_SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide";
20
+ const REL_HANDOUT_MASTER = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster";
21
+ const REL_THEME_OVERRIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride";
22
+ const REL_FONT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font";
23
+ const REL_IMAGE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
24
+ const REL_HYPERLINK = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
25
+ const REL_DIAGRAM_DATA = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData";
26
+ const REL_DIAGRAM_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout";
27
+ const REL_DIAGRAM_QUICK_STYLE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle";
28
+ const REL_DIAGRAM_COLORS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors";
29
+ const REL_DIAGRAM_DRAWING = "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing";
30
+ const DIAGRAM_NS = "http://schemas.openxmlformats.org/drawingml/2006/diagram";
31
+ const DSP_NS = "http://schemas.microsoft.com/office/drawing/2008/diagram";
32
+ const CHART_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
33
+ const TABLE_NS_URI = "http://schemas.openxmlformats.org/drawingml/2006/table";
34
+ const P14_SECTION_LIST_EXT_URI = "{521415D9-36F7-43E2-AB2F-B90AF26B5E84}";
35
+ const P14_CREATION_ID_EXT_URI = "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}";
36
+ const STRICT_NS_PREFIX = "http://purl.oclc.org/ooxml/";
37
+ const EMU_PER_PX = 9525;
38
+ /** Converts DrawingML English Metric Units (EMU) to logical pixels (96 DPI). */
39
+ function emuToPx(emu) {
40
+ return emu / EMU_PER_PX;
41
+ }
42
+ const canonicalPrefixes = /* @__PURE__ */ new Map([
43
+ [P_NS, "p"],
44
+ [P14_NS, "p14"],
45
+ [P159_NS, "p159"],
46
+ [A_NS, "a"],
47
+ [C_NS, "c"],
48
+ [R_NS, "r"],
49
+ [MC_NS, "mc"],
50
+ [DIAGRAM_NS, "dgm"],
51
+ [CHART_NS, "c"],
52
+ [XML_NS, "xml"]
53
+ ]);
54
+ /** Formats an element or attribute name with a canonical prefix for deterministic diagnostic XPaths. */
55
+ function canonicalQName(namespaceUri, localName) {
56
+ if (!namespaceUri) return localName;
57
+ const prefix = canonicalPrefixes.get(namespaceUri);
58
+ if (prefix !== void 0) return `${prefix}:${localName}`;
59
+ return `{${namespaceUri}}${localName}`;
60
+ }
61
+ export { A_NS, CHART_NS, C_NS, DIAGRAM_NS, DSP_NS, EMU_PER_PX, MC_NS, OPC_REL_NS, P14_CREATION_ID_EXT_URI, P14_NS, P14_SECTION_LIST_EXT_URI, P159_NS, P_NS, REL_CHART, REL_DIAGRAM_COLORS, REL_DIAGRAM_DATA, REL_DIAGRAM_DRAWING, REL_DIAGRAM_LAYOUT, REL_DIAGRAM_QUICK_STYLE, REL_FONT, REL_HANDOUT_MASTER, REL_HYPERLINK, REL_IMAGE, REL_NOTES_MASTER, REL_NOTES_SLIDE, REL_OFFICE_DOCUMENT, REL_SLIDE, REL_SLIDE_LAYOUT, REL_SLIDE_MASTER, REL_THEME, REL_THEME_OVERRIDE, R_NS, STRICT_NS_PREFIX, TABLE_NS_URI, XMLNS_NS, XML_NS, canonicalQName, emuToPx };
@@ -0,0 +1,300 @@
1
+ import { appendUnconsumedDiagnostics, consumeIdentityShapeTreeBoilerplate } from "./masters.js";
2
+ import { A_NS, P_NS, REL_HANDOUT_MASTER, REL_NOTES_MASTER, R_NS } from "./namespaces.js";
3
+ import { resolvePartPath } from "./opc.js";
4
+ import { peekShapeTreeObjectIdentity } from "./resources.js";
5
+ import { ooxmlNonNegativeIntSchema } from "./xml-fragments.js";
6
+ import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
7
+ import { z } from "zod";
8
+ // ../import/dist/notes-masters.js
9
+ const standardNotesMasterPlaceholders = /* @__PURE__ */ new Set([
10
+ "sldImg",
11
+ "body",
12
+ "hdr",
13
+ "ftr",
14
+ "dt",
15
+ "sldNum"
16
+ ]);
17
+ const standardHandoutMasterPlaceholders = /* @__PURE__ */ new Set([
18
+ "hdr",
19
+ "ftr",
20
+ "dt",
21
+ "sldNum"
22
+ ]);
23
+ const defaultColorMap = {
24
+ bg1: "lt1",
25
+ tx1: "dk1",
26
+ bg2: "lt2",
27
+ tx2: "dk2",
28
+ accent1: "accent1",
29
+ accent2: "accent2",
30
+ accent3: "accent3",
31
+ accent4: "accent4",
32
+ accent5: "accent5",
33
+ accent6: "accent6",
34
+ hlink: "hlink",
35
+ folHlink: "folHlink"
36
+ };
37
+ const placeholderTypeXmlSchema = z.object({
38
+ type: z.string().optional(),
39
+ idx: ooxmlNonNegativeIntSchema.optional(),
40
+ sz: z.enum([
41
+ "full",
42
+ "half",
43
+ "quarter"
44
+ ]).optional(),
45
+ orient: z.enum(["horz", "vert"]).optional()
46
+ });
47
+ const bgRefAttrsSchema = z.object({ idx: ooxmlNonNegativeIntSchema });
48
+ function isStandardColorMap(clrMap) {
49
+ const attrs = clrMap.element.attributes;
50
+ const observed = /* @__PURE__ */ new Map();
51
+ for (let i = 0; i < attrs.length; i += 1) {
52
+ const attr = attrs.item(i);
53
+ if (attr === null) continue;
54
+ const ns = attr.namespaceURI ?? "";
55
+ const local = attr.localName ?? attr.name;
56
+ if (ns === "" && local in defaultColorMap) observed.set(local, attr.value);
57
+ }
58
+ const matches = Object.entries(defaultColorMap).every(([slot, target]) => observed.get(slot) === target);
59
+ if (matches) for (const slot of Object.keys(defaultColorMap)) clrMap.consumeAttr(slot);
60
+ return matches;
61
+ }
62
+ function isBaselineBgRef(bg) {
63
+ const bgRef = bg.child(P_NS, "bgRef");
64
+ if (bgRef === void 0) return false;
65
+ const raw = bgRef.attrsObject(["idx"]);
66
+ const parsed = bgRefAttrsSchema.safeParse(raw);
67
+ if (!parsed.success || parsed.data.idx !== 1001) return false;
68
+ const schemeClr = bgRef.child(A_NS, "schemeClr");
69
+ if (schemeClr === void 0) return false;
70
+ return schemeClr.attr("val") === "bg1";
71
+ }
72
+ function consumeBenignCreationIdExtLst(cSld) {
73
+ const extLst = cSld.child(P_NS, "extLst");
74
+ if (extLst === void 0) return;
75
+ for (const ext of extLst.children(P_NS, "ext")) {
76
+ if (ext.element.getAttribute("uri") !== "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}") continue;
77
+ ext.consumeAttr("uri");
78
+ ext.suppressUnconsumed();
79
+ }
80
+ }
81
+ function readPlaceholderTypeOnSp(spCursor) {
82
+ const nvSpPr = spCursor.child(P_NS, "nvSpPr");
83
+ if (nvSpPr === void 0) return void 0;
84
+ const cNvPr = nvSpPr.child(P_NS, "cNvPr");
85
+ if (cNvPr !== void 0) {
86
+ cNvPr.consumeAttr("id");
87
+ cNvPr.consumeAttr("name");
88
+ }
89
+ const cNvSpPr = nvSpPr.child(P_NS, "cNvSpPr");
90
+ if (cNvSpPr !== void 0) cNvSpPr.suppressUnconsumed();
91
+ const nvPr = nvSpPr.child(P_NS, "nvPr");
92
+ if (nvPr === void 0) return void 0;
93
+ const ph = nvPr.child(P_NS, "ph");
94
+ if (ph === void 0) return void 0;
95
+ const parsed = placeholderTypeXmlSchema.safeParse(ph.attrsObject([
96
+ "type",
97
+ "idx",
98
+ "sz",
99
+ "orient"
100
+ ]));
101
+ return parsed.success ? parsed.data.type : void 0;
102
+ }
103
+ function inspectPrintMasterPart(pkg, masterPartPath, kind, diagnostics) {
104
+ const xmlText = pkg.readTextPart(masterPartPath);
105
+ if (xmlText === void 0) return;
106
+ let rootEl;
107
+ try {
108
+ rootEl = parseXmlPart(masterPartPath, xmlText);
109
+ } catch {
110
+ diagnostics.push({
111
+ code: "corrupt-part",
112
+ category: "corrupt-input",
113
+ disposition: "omitted",
114
+ location: { part: masterPartPath }
115
+ });
116
+ return;
117
+ }
118
+ if ((rootEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/presentationml/2006/main" || (rootEl.localName ?? rootEl.tagName) !== kind) {
119
+ diagnostics.push({
120
+ code: "corrupt-part",
121
+ category: "corrupt-input",
122
+ disposition: "omitted",
123
+ location: { part: masterPartPath }
124
+ });
125
+ return;
126
+ }
127
+ const retainedAs = kind === "notesMaster" ? "default-notes-master" : "omitted";
128
+ const allowedPlaceholders = kind === "notesMaster" ? standardNotesMasterPlaceholders : standardHandoutMasterPlaceholders;
129
+ const masterCursor = XmlElementCursor.createRoot(rootEl, masterPartPath, `/p:${kind}`);
130
+ const rels = pkg.readRelationships(masterPartPath);
131
+ diagnostics.push(...rels.diagnostics);
132
+ let reportedCustomLoss = false;
133
+ const cSld = masterCursor.child(P_NS, "cSld");
134
+ if (cSld !== void 0) {
135
+ cSld.consumeAttr("name");
136
+ const bg = cSld.child(P_NS, "bg");
137
+ if (bg !== void 0) {
138
+ if (!isBaselineBgRef(bg)) {
139
+ reportedCustomLoss = true;
140
+ diagnostics.push({
141
+ code: "unsupported-mechanism",
142
+ category: "unsupported",
143
+ disposition: "omitted",
144
+ location: {
145
+ part: masterPartPath,
146
+ xpath: bg.xpath
147
+ },
148
+ namespaceUri: bg.namespaceUri,
149
+ localName: bg.localName,
150
+ mechanismHint: `${kind}-custom-background`,
151
+ loss: {
152
+ lost: "custom-print-layout",
153
+ retainedAs
154
+ }
155
+ });
156
+ bg.suppressUnconsumed();
157
+ }
158
+ }
159
+ const spTree = cSld.child(P_NS, "spTree");
160
+ if (spTree !== void 0) {
161
+ consumeIdentityShapeTreeBoilerplate(spTree);
162
+ for (const item of spTree.remainingElementChildren()) {
163
+ if (item.namespaceUri === "http://schemas.openxmlformats.org/presentationml/2006/main" && item.localName === "sp") {
164
+ const phType = readPlaceholderTypeOnSp(item);
165
+ if (phType !== void 0 && allowedPlaceholders.has(phType)) {
166
+ item.suppressUnconsumed();
167
+ continue;
168
+ }
169
+ }
170
+ reportedCustomLoss = true;
171
+ const identity = peekShapeTreeObjectIdentity(item.element);
172
+ diagnostics.push({
173
+ code: "unsupported-mechanism",
174
+ category: "unsupported",
175
+ disposition: "omitted",
176
+ location: {
177
+ part: masterPartPath,
178
+ xpath: item.xpath,
179
+ ...identity
180
+ },
181
+ namespaceUri: item.namespaceUri,
182
+ localName: item.localName,
183
+ mechanismHint: `${kind}-custom-object`,
184
+ loss: {
185
+ lost: "custom-print-layout",
186
+ retainedAs
187
+ }
188
+ });
189
+ item.suppressUnconsumed();
190
+ }
191
+ }
192
+ consumeBenignCreationIdExtLst(cSld);
193
+ }
194
+ const clrMap = masterCursor.child(P_NS, "clrMap");
195
+ if (clrMap !== void 0 && !isStandardColorMap(clrMap)) {
196
+ reportedCustomLoss = true;
197
+ diagnostics.push({
198
+ code: "unsupported-mechanism",
199
+ category: "unsupported",
200
+ disposition: "omitted",
201
+ location: {
202
+ part: masterPartPath,
203
+ xpath: clrMap.xpath
204
+ },
205
+ namespaceUri: clrMap.namespaceUri,
206
+ localName: clrMap.localName,
207
+ mechanismHint: `${kind}-custom-color-map`,
208
+ loss: {
209
+ lost: "custom-print-layout",
210
+ retainedAs
211
+ }
212
+ });
213
+ clrMap.suppressUnconsumed();
214
+ }
215
+ const styleElementName = kind === "notesMaster" ? "notesStyle" : "handoutStyle";
216
+ const masterStyle = masterCursor.child(P_NS, styleElementName);
217
+ if (masterStyle !== void 0) masterStyle.suppressUnconsumed();
218
+ if (kind === "handoutMaster" && !reportedCustomLoss) diagnostics.push({
219
+ code: "unsupported-mechanism",
220
+ category: "unsupported",
221
+ disposition: "omitted",
222
+ location: {
223
+ part: masterPartPath,
224
+ xpath: masterCursor.xpath
225
+ },
226
+ namespaceUri: P_NS,
227
+ localName: kind,
228
+ mechanismHint: "handout-master-print-layout",
229
+ loss: {
230
+ lost: "custom-print-layout",
231
+ retainedAs: "omitted"
232
+ }
233
+ });
234
+ appendUnconsumedDiagnostics(masterCursor, void 0, diagnostics);
235
+ }
236
+ /**
237
+ * Inspects `<p:notesMasterIdLst>` and `<p:handoutMasterIdLst>` from `presentation.xml`.
238
+ *
239
+ * Standard baseline `notesMaster` parts produce zero false-loss diagnostics, while custom
240
+ * non-placeholder print graphics/backgrounds and `handoutMaster` layouts report exact part
241
+ * locations and `custom-print-layout` editability loss without blocking slide notes import.
242
+ */
243
+ function inspectNotesAndHandoutMasters(presCursor, pkg, presRelById, diagnostics) {
244
+ const visitedParts = /* @__PURE__ */ new Set();
245
+ const inspectList = (listTag, entryTag, relType, kind) => {
246
+ const lst = presCursor.child(P_NS, listTag);
247
+ if (lst === void 0) return;
248
+ for (const idCursor of lst.children(P_NS, entryTag)) {
249
+ const rId = idCursor.attr("id", R_NS);
250
+ if (rId === void 0) {
251
+ diagnostics.push({
252
+ code: "broken-relationship",
253
+ category: "corrupt-input",
254
+ disposition: "omitted",
255
+ location: {
256
+ part: pkg.presentationPath,
257
+ xpath: idCursor.xpath
258
+ },
259
+ relationshipId: ""
260
+ });
261
+ continue;
262
+ }
263
+ const rel = presRelById.get(rId);
264
+ if (rel === void 0 || rel.Type !== relType || rel.TargetMode === "External") {
265
+ diagnostics.push({
266
+ code: "broken-relationship",
267
+ category: "corrupt-input",
268
+ disposition: "omitted",
269
+ location: {
270
+ part: pkg.presentationPath,
271
+ xpath: idCursor.xpath
272
+ },
273
+ relationshipId: rId
274
+ });
275
+ continue;
276
+ }
277
+ const targetPart = resolvePartPath(pkg.presentationPath, rel.Target);
278
+ if (targetPart === void 0 || !pkg.hasPart(targetPart)) {
279
+ diagnostics.push({
280
+ code: "missing-target-part",
281
+ category: "corrupt-input",
282
+ disposition: "omitted",
283
+ location: {
284
+ part: pkg.presentationPath,
285
+ xpath: idCursor.xpath
286
+ },
287
+ relationshipId: rId,
288
+ targetPart: targetPart ?? rel.Target
289
+ });
290
+ continue;
291
+ }
292
+ if (visitedParts.has(targetPart)) continue;
293
+ visitedParts.add(targetPart);
294
+ inspectPrintMasterPart(pkg, targetPart, kind, diagnostics);
295
+ }
296
+ };
297
+ inspectList("notesMasterIdLst", "notesMasterId", REL_NOTES_MASTER, "notesMaster");
298
+ inspectList("handoutMasterIdLst", "handoutMasterId", REL_HANDOUT_MASTER, "handoutMaster");
299
+ }
300
+ export { inspectNotesAndHandoutMasters };
@@ -0,0 +1,233 @@
1
+ import { ImportError } from "./diagnostics.js";
2
+ import { OPC_REL_NS, REL_OFFICE_DOCUMENT } from "./namespaces.js";
3
+ import { MalformedXmlPartError, XmlElementCursor, parseXmlPart } from "./xml-reader.js";
4
+ import { z } from "zod";
5
+ import { strFromU8, unzipSync } from "fflate";
6
+ import { posix } from "node:path";
7
+ // ../import/dist/opc.js
8
+ /** Zod schema for an OPC `<Relationship>` element attributes. */
9
+ const opcRelationshipSchema = z.object({
10
+ Id: z.string().min(1),
11
+ Type: z.string().min(1),
12
+ Target: z.string().min(1),
13
+ TargetMode: z.enum(["Internal", "External"]).default("Internal")
14
+ });
15
+ /** Computes the OPC relationships part path for a given source part (or `""` for package root). */
16
+ function relsPathFor(partPath) {
17
+ if (partPath === "") return "_rels/.rels";
18
+ const dir = posix.dirname(partPath);
19
+ const base = posix.basename(partPath);
20
+ return dir === "." ? `_rels/${base}.rels` : `${dir}/_rels/${base}.rels`;
21
+ }
22
+ /** Resolves a relative or root-anchored OPC target against its owning part path. */
23
+ function resolvePartPath(sourcePartPath, target) {
24
+ const normalizedTarget = target.replace(/\\/gu, "/");
25
+ if (normalizedTarget === "") return void 0;
26
+ const baseDir = sourcePartPath === "" || sourcePartPath === "_rels/.rels" ? "" : posix.dirname(sourcePartPath);
27
+ const joined = normalizedTarget.startsWith("/") ? normalizedTarget.slice(1) : baseDir === "" || baseDir === "." ? normalizedTarget : posix.join(baseDir, normalizedTarget);
28
+ const normalized = posix.normalize(joined);
29
+ if (normalized === "." || normalized === ".." || normalized.startsWith("../") || normalized.startsWith("/")) return;
30
+ return normalized;
31
+ }
32
+ /** Parses and validates all `<Relationship>` entries in an OPC `.rels` XML part. */
33
+ function parseRelationshipsXml(relsPartPath, xmlText) {
34
+ const root = parseXmlPart(relsPartPath, xmlText);
35
+ if ((root.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/package/2006/relationships" || (root.localName ?? root.tagName) !== "Relationships") throw new MalformedXmlPartError(relsPartPath, `Expected OPC Relationships root, got ${root.namespaceURI ?? ""}:${root.localName ?? root.tagName}`);
36
+ const cursor = XmlElementCursor.createRoot(root, relsPartPath, "/Relationships");
37
+ const entries = [];
38
+ const diagnostics = [];
39
+ for (const relCursor of cursor.children(OPC_REL_NS, "Relationship")) {
40
+ const raw = relCursor.attrsObject([
41
+ "Id",
42
+ "Type",
43
+ "Target",
44
+ "TargetMode"
45
+ ]);
46
+ const parsed = opcRelationshipSchema.safeParse(raw);
47
+ if (!parsed.success) {
48
+ diagnostics.push({
49
+ code: "broken-relationship",
50
+ category: "corrupt-input",
51
+ disposition: "omitted",
52
+ location: {
53
+ part: relsPartPath,
54
+ xpath: relCursor.xpath
55
+ },
56
+ relationshipId: raw["Id"] ?? ""
57
+ });
58
+ continue;
59
+ }
60
+ entries.push({
61
+ ...parsed.data,
62
+ xpath: relCursor.xpath
63
+ });
64
+ }
65
+ return {
66
+ entries,
67
+ diagnostics
68
+ };
69
+ }
70
+ function detectStrictBaselineIssue(part, entries) {
71
+ for (const entry of entries) if (entry.Type.startsWith("http://purl.oclc.org/ooxml/")) return new ImportError({
72
+ code: "unsupported-format-baseline",
73
+ category: "unsupported",
74
+ disposition: "aborted",
75
+ baseline: "ISO/IEC 29500 Strict",
76
+ detectedNamespace: entry.Type,
77
+ location: {
78
+ part,
79
+ xpath: entry.xpath
80
+ }
81
+ }, `Unsupported ISO/IEC 29500 Strict OOXML relationship (${entry.Type}) in ${part}`);
82
+ }
83
+ /**
84
+ * Unzips a PPTX archive into detached entries, validates OPC package entry points,
85
+ * rejects ISO/IEC 29500 Strict OOXML with structured diagnostics, and loads `presentation.xml`.
86
+ */
87
+ function openPptxPackage(input) {
88
+ let rawEntries;
89
+ try {
90
+ rawEntries = unzipSync(input);
91
+ } catch (error) {
92
+ throw new ImportError({
93
+ code: "corrupt-archive",
94
+ category: "corrupt-input",
95
+ disposition: "aborted"
96
+ }, `Failed to unzip PPTX archive: ${error instanceof Error ? error.message : String(error)}`);
97
+ }
98
+ const entries = /* @__PURE__ */ new Map();
99
+ for (const [name, bytes] of Object.entries(rawEntries)) entries.set(name.replace(/^\/+/u, ""), new Uint8Array(bytes));
100
+ const rootRelsPath = "_rels/.rels";
101
+ const rootRelsBytes = entries.get(rootRelsPath);
102
+ if (rootRelsBytes === void 0) throw new ImportError({
103
+ code: "missing-entry",
104
+ category: "corrupt-input",
105
+ disposition: "aborted",
106
+ location: { part: rootRelsPath },
107
+ expectedRelationshipType: REL_OFFICE_DOCUMENT
108
+ }, "Missing package entry relationships (_rels/.rels)");
109
+ let rootRels;
110
+ try {
111
+ rootRels = parseRelationshipsXml(rootRelsPath, strFromU8(rootRelsBytes)).entries;
112
+ } catch (error) {
113
+ throw new ImportError({
114
+ code: "malformed-xml",
115
+ category: "corrupt-input",
116
+ disposition: "aborted",
117
+ location: { part: rootRelsPath },
118
+ ...error instanceof Error ? { detail: error.message } : {}
119
+ }, `Malformed XML in ${rootRelsPath}`);
120
+ }
121
+ const strictFromRels = detectStrictBaselineIssue(rootRelsPath, rootRels);
122
+ if (strictFromRels !== void 0) throw strictFromRels;
123
+ const officeDocRel = rootRels.find((entry) => entry.Type === REL_OFFICE_DOCUMENT);
124
+ if (officeDocRel === void 0) throw new ImportError({
125
+ code: "missing-entry",
126
+ category: "corrupt-input",
127
+ disposition: "aborted",
128
+ location: { part: rootRelsPath },
129
+ expectedRelationshipType: REL_OFFICE_DOCUMENT
130
+ }, "Missing Transitional officeDocument relationship in _rels/.rels");
131
+ const presentationPath = officeDocRel.TargetMode === "External" ? void 0 : resolvePartPath("", officeDocRel.Target);
132
+ if (presentationPath === void 0) throw new ImportError({
133
+ code: "broken-entry-relationship",
134
+ category: "corrupt-input",
135
+ disposition: "aborted",
136
+ location: {
137
+ part: rootRelsPath,
138
+ xpath: officeDocRel.xpath
139
+ },
140
+ relationshipId: officeDocRel.Id,
141
+ target: officeDocRel.Target
142
+ }, `Invalid officeDocument relationship target ${officeDocRel.Target}`);
143
+ const presentationBytes = entries.get(presentationPath);
144
+ if (presentationBytes === void 0) throw new ImportError({
145
+ code: "broken-entry-relationship",
146
+ category: "corrupt-input",
147
+ disposition: "aborted",
148
+ location: {
149
+ part: rootRelsPath,
150
+ xpath: officeDocRel.xpath
151
+ },
152
+ relationshipId: officeDocRel.Id,
153
+ target: presentationPath
154
+ }, `Missing presentation part ${presentationPath} referenced by ${officeDocRel.Id}`);
155
+ let presElement;
156
+ try {
157
+ presElement = parseXmlPart(presentationPath, strFromU8(presentationBytes));
158
+ } catch (error) {
159
+ throw new ImportError({
160
+ code: "malformed-xml",
161
+ category: "corrupt-input",
162
+ disposition: "aborted",
163
+ location: { part: presentationPath },
164
+ ...error instanceof Error ? { detail: error.message } : {}
165
+ }, `Malformed XML in ${presentationPath}`);
166
+ }
167
+ const presNs = presElement.namespaceURI ?? "";
168
+ const presLocal = presElement.localName ?? presElement.tagName;
169
+ if (presNs.startsWith("http://purl.oclc.org/ooxml/")) throw new ImportError({
170
+ code: "unsupported-format-baseline",
171
+ category: "unsupported",
172
+ disposition: "aborted",
173
+ baseline: "ISO/IEC 29500 Strict",
174
+ detectedNamespace: presNs,
175
+ location: {
176
+ part: presentationPath,
177
+ xpath: `/${presLocal}`
178
+ }
179
+ }, `Unsupported ISO/IEC 29500 Strict presentation namespace ${presNs}`);
180
+ if (presNs !== "http://schemas.openxmlformats.org/presentationml/2006/main" || presLocal !== "presentation") throw new ImportError({
181
+ code: "invalid-presentation-root",
182
+ category: "corrupt-input",
183
+ disposition: "aborted",
184
+ location: {
185
+ part: presentationPath,
186
+ xpath: `/${presLocal}`
187
+ },
188
+ namespaceUri: presNs,
189
+ localName: presLocal
190
+ }, `Expected Transitional PresentationML root element, got ${presNs}:${presLocal}`);
191
+ const presentationRoot = XmlElementCursor.createRoot(presElement, presentationPath, "/p:presentation");
192
+ const readRelationships = (partPath) => {
193
+ const relsPart = relsPathFor(partPath);
194
+ const bytes = entries.get(relsPart);
195
+ if (bytes === void 0) return {
196
+ entries: [],
197
+ diagnostics: []
198
+ };
199
+ try {
200
+ return parseRelationshipsXml(relsPart, strFromU8(bytes));
201
+ } catch {
202
+ return {
203
+ entries: [],
204
+ diagnostics: [{
205
+ code: "corrupt-part",
206
+ category: "corrupt-input",
207
+ disposition: "omitted",
208
+ location: { part: relsPart }
209
+ }]
210
+ };
211
+ }
212
+ };
213
+ const presRels = readRelationships(presentationPath);
214
+ return {
215
+ presentationPath,
216
+ presentationRoot,
217
+ presentationRels: presRels.entries,
218
+ relDiagnostics: presRels.diagnostics,
219
+ hasPart(partPath) {
220
+ return entries.has(partPath);
221
+ },
222
+ readTextPart(partPath) {
223
+ const bytes = entries.get(partPath);
224
+ return bytes === void 0 ? void 0 : strFromU8(bytes);
225
+ },
226
+ readDetachedBytes(partPath) {
227
+ const bytes = entries.get(partPath);
228
+ return bytes === void 0 ? void 0 : new Uint8Array(bytes);
229
+ },
230
+ readRelationships
231
+ };
232
+ }
233
+ export { opcRelationshipSchema, openPptxPackage, parseRelationshipsXml, relsPathFor, resolvePartPath };