@officedk/pptxdk 0.0.0-stage → 0.1.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 (194) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/build.d.ts +94 -0
  4. package/dist/build.js +148 -0
  5. package/dist/capabilities/dist/all.js +32 -0
  6. package/dist/capabilities/dist/box/box-codegen.js +51 -0
  7. package/dist/capabilities/dist/box/box-declaration.js +31 -0
  8. package/dist/capabilities/dist/box/box-elements.js +17 -0
  9. package/dist/capabilities/dist/box/box.js +138 -0
  10. package/dist/capabilities/dist/chart/chart-codegen.js +77 -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 +2272 -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 +1078 -0
  17. package/dist/capabilities/dist/chart/chart-xml.js +788 -0
  18. package/dist/capabilities/dist/chart/chart.js +1124 -0
  19. package/dist/capabilities/dist/chart/preview/axes-and-grid.js +298 -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 +190 -0
  24. package/dist/capabilities/dist/chart/preview/layout.js +519 -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 +48 -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 +148 -0
  37. package/dist/capabilities/dist/font/font-embedding.js +289 -0
  38. package/dist/capabilities/dist/font/font-family.js +10 -0
  39. package/dist/capabilities/dist/font/font-import.js +302 -0
  40. package/dist/capabilities/dist/font/font-subset.js +55 -0
  41. package/dist/capabilities/dist/font/font.js +25 -0
  42. package/dist/capabilities/dist/group/group-codegen.js +51 -0
  43. package/dist/capabilities/dist/group/group-declaration.js +42 -0
  44. package/dist/capabilities/dist/group/group-elements.js +12 -0
  45. package/dist/capabilities/dist/group/group-import.js +319 -0
  46. package/dist/capabilities/dist/group/group-xml.js +7 -0
  47. package/dist/capabilities/dist/group/group.js +211 -0
  48. package/dist/capabilities/dist/image/gif-decoder.js +244 -0
  49. package/dist/capabilities/dist/image/image-codegen.js +94 -0
  50. package/dist/capabilities/dist/image/image-declaration.js +8 -0
  51. package/dist/capabilities/dist/image/image-decode.js +221 -0
  52. package/dist/capabilities/dist/image/image-elements.js +12 -0
  53. package/dist/capabilities/dist/image/image-import.js +778 -0
  54. package/dist/capabilities/dist/image/image-schemas.js +149 -0
  55. package/dist/capabilities/dist/image/image-xml.js +12 -0
  56. package/dist/capabilities/dist/image/image.js +472 -0
  57. package/dist/capabilities/dist/masters/footer-placeholder.js +685 -0
  58. package/dist/capabilities/dist/masters/masters-codegen.js +21 -0
  59. package/dist/capabilities/dist/masters/masters.js +250 -0
  60. package/dist/capabilities/dist/motion/motion-api.js +527 -0
  61. package/dist/capabilities/dist/motion/motion-codegen.js +340 -0
  62. package/dist/capabilities/dist/motion/motion-elements.js +43 -0
  63. package/dist/capabilities/dist/motion/motion-import.js +1033 -0
  64. package/dist/capabilities/dist/motion/motion-plan.js +2189 -0
  65. package/dist/capabilities/dist/motion/motion-query.js +420 -0
  66. package/dist/capabilities/dist/motion/motion-schemas.js +216 -0
  67. package/dist/capabilities/dist/motion/motion.js +1372 -0
  68. package/dist/capabilities/dist/notes/notes-codegen.js +20 -0
  69. package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
  70. package/dist/capabilities/dist/notes/notes-elements.js +12 -0
  71. package/dist/capabilities/dist/notes/notes-import.js +292 -0
  72. package/dist/capabilities/dist/notes/notes-schemas.js +35 -0
  73. package/dist/capabilities/dist/notes/notes-xml.js +38 -0
  74. package/dist/capabilities/dist/notes/notes.js +191 -0
  75. package/dist/capabilities/dist/placeholder/placeholder-codegen.js +23 -0
  76. package/dist/capabilities/dist/placeholder/placeholder-elements.js +12 -0
  77. package/dist/capabilities/dist/placeholder/placeholder.js +292 -0
  78. package/dist/capabilities/dist/shape/shape-codegen.js +166 -0
  79. package/dist/capabilities/dist/shape/shape-declaration.js +57 -0
  80. package/dist/capabilities/dist/shape/shape-elements.js +12 -0
  81. package/dist/capabilities/dist/shape/shape-import.js +579 -0
  82. package/dist/capabilities/dist/shape/shape-xml.js +6 -0
  83. package/dist/capabilities/dist/shape/shape.js +337 -0
  84. package/dist/capabilities/dist/shared/geometry.js +1423 -0
  85. package/dist/capabilities/dist/shared/identity.js +205 -0
  86. package/dist/capabilities/dist/shared/morph-api.js +11 -0
  87. package/dist/capabilities/dist/shared/placeholder-import.js +113 -0
  88. package/dist/capabilities/dist/shared/preset-definitions.js +21390 -0
  89. package/dist/capabilities/dist/shared/style-inheritance.js +166 -0
  90. package/dist/capabilities/dist/shared/style-parse.js +11 -0
  91. package/dist/capabilities/dist/shared/text-schemas.js +216 -0
  92. package/dist/capabilities/dist/shared/text-service.js +1883 -0
  93. package/dist/capabilities/dist/shared/visual.js +918 -0
  94. package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
  95. package/dist/capabilities/dist/slide-background/slide-background-import.js +161 -0
  96. package/dist/capabilities/dist/slide-background/slide-background-xml.js +21 -0
  97. package/dist/capabilities/dist/slide-background/slide-background.js +221 -0
  98. package/dist/capabilities/dist/table/table-codegen.js +81 -0
  99. package/dist/capabilities/dist/table/table-declaration.js +15 -0
  100. package/dist/capabilities/dist/table/table-elements.js +27 -0
  101. package/dist/capabilities/dist/table/table-import.js +539 -0
  102. package/dist/capabilities/dist/table/table-schemas.js +279 -0
  103. package/dist/capabilities/dist/table/table-xml.js +37 -0
  104. package/dist/capabilities/dist/table/table.js +662 -0
  105. package/dist/capabilities/dist/text/text-codegen.js +129 -0
  106. package/dist/capabilities/dist/text/text-declaration.js +19 -0
  107. package/dist/capabilities/dist/text/text-elements.js +38 -0
  108. package/dist/capabilities/dist/text/text-import.js +1077 -0
  109. package/dist/capabilities/dist/text/text-xml.js +9 -0
  110. package/dist/capabilities/dist/text/text.js +335 -0
  111. package/dist/capabilities/dist/transition/transition-api.js +139 -0
  112. package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
  113. package/dist/capabilities/dist/transition/transition-import.js +477 -0
  114. package/dist/capabilities/dist/transition/transition.js +260 -0
  115. package/dist/capability-D_xeNVIw.d.ts +29496 -0
  116. package/dist/cli.js +20 -0
  117. package/dist/codegen/dist/assets.js +78 -0
  118. package/dist/codegen/dist/codegen.js +611 -0
  119. package/dist/codegen/dist/identifiers.js +193 -0
  120. package/dist/codegen/dist/index.js +3 -0
  121. package/dist/codegen/dist/printer.js +143 -0
  122. package/dist/codegen/dist/types.js +49 -0
  123. package/dist/core/dist/author-ids.js +48 -0
  124. package/dist/core/dist/author-schemas.js +313 -0
  125. package/dist/core/dist/block-flex-layout.js +749 -0
  126. package/dist/core/dist/build.js +4 -0
  127. package/dist/core/dist/capability.js +13 -0
  128. package/dist/core/dist/declaration.js +15 -0
  129. package/dist/core/dist/diagnostics.js +21 -0
  130. package/dist/core/dist/document-internals.js +13 -0
  131. package/dist/core/dist/document.js +408 -0
  132. package/dist/core/dist/geometry-schemas.js +249 -0
  133. package/dist/core/dist/grid-layout.js +445 -0
  134. package/dist/core/dist/host.js +40 -0
  135. package/dist/core/dist/index.js +15 -0
  136. package/dist/core/dist/input-values.js +45 -0
  137. package/dist/core/dist/layout-protocol.js +66 -0
  138. package/dist/core/dist/layout-schemas.js +208 -0
  139. package/dist/core/dist/layout.js +299 -0
  140. package/dist/core/dist/masters.js +169 -0
  141. package/dist/core/dist/morph.js +30 -0
  142. package/dist/core/dist/placeholders.js +213 -0
  143. package/dist/core/dist/query.js +155 -0
  144. package/dist/core/dist/resolution.js +11 -0
  145. package/dist/core/dist/resolve.js +1827 -0
  146. package/dist/core/dist/stage-options.js +67 -0
  147. package/dist/core/dist/theme.js +931 -0
  148. package/dist/document-BHPUODPP.d.ts +27759 -0
  149. package/dist/emit/dist/emit.js +936 -0
  150. package/dist/emit/dist/index.js +5 -0
  151. package/dist/emit/dist/ooxml.js +606 -0
  152. package/dist/emit/dist/shape-tree.js +12 -0
  153. package/dist/import/dist/alternate-content.js +54 -0
  154. package/dist/import/dist/diagnostics.js +153 -0
  155. package/dist/import/dist/fonts.js +250 -0
  156. package/dist/import/dist/import.js +504 -0
  157. package/dist/import/dist/index.js +16 -0
  158. package/dist/import/dist/masters.js +1153 -0
  159. package/dist/import/dist/mechanism.js +10 -0
  160. package/dist/import/dist/namespaces.js +60 -0
  161. package/dist/import/dist/notes-masters.js +300 -0
  162. package/dist/import/dist/opc.js +233 -0
  163. package/dist/import/dist/resources.js +166 -0
  164. package/dist/import/dist/sections.js +139 -0
  165. package/dist/import/dist/themes.js +671 -0
  166. package/dist/import/dist/visual.js +761 -0
  167. package/dist/import/dist/xml-fragments.js +36 -0
  168. package/dist/import/dist/xml-reader.js +267 -0
  169. package/dist/index-B5m3hqjC.d.ts +7 -0
  170. package/dist/index-CCy-Yo8G.d.ts +1208 -0
  171. package/dist/index-DpxcZ4Gs.d.ts +725 -0
  172. package/dist/index.d.ts +7 -0
  173. package/dist/index.js +70 -0
  174. package/dist/node.d.ts +53 -0
  175. package/dist/node.js +194 -0
  176. package/dist/pptxdk/src/cli-commands.js +913 -0
  177. package/dist/pptxdk/src/compose.js +44 -0
  178. package/dist/pptxdk/src/slide.js +9 -0
  179. package/dist/preview/dist/index.js +240 -0
  180. package/dist/preview/dist/options.js +53 -0
  181. package/dist/preview-Cfw0QdMM.d.ts +86 -0
  182. package/dist/preview.d.ts +3 -0
  183. package/dist/preview.js +27 -0
  184. package/dist/react/dist/append.js +66 -0
  185. package/dist/react/dist/document-adapter.js +65 -0
  186. package/dist/react/dist/elements.js +59 -0
  187. package/dist/react/dist/index.js +68 -0
  188. package/dist/react/dist/reconciler.js +290 -0
  189. package/dist/react.d.ts +145 -0
  190. package/dist/react.js +27 -0
  191. package/dist/transition-Cips9wma.d.ts +82 -0
  192. package/dist/vanilla.d.ts +4 -0
  193. package/dist/vanilla.js +14 -0
  194. package/package.json +78 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 officedk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
- # Temporary Holding Version
1
+ # @officedk/pptxdk
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Create editable PowerPoint presentations with JavaScript, TypeScript or React. The package includes the SDK and the `pptxdk` command for building, previewing and generating source from presentations.
4
+
5
+ ## Build your first presentation
6
+
7
+ Install the package in a project running Node.js 26.13 or a later 26.x release.
8
+
9
+ ```sh
10
+ npm install @officedk/pptxdk
11
+ ```
12
+
13
+ Save the following as `slides.mjs`.
14
+
15
+ ```js
16
+ import { deck, shape, slide } from "@officedk/pptxdk/vanilla";
17
+
18
+ export default deck({ width: 960, height: 540 }).append(
19
+ slide({ id: "intro" }).append(
20
+ shape({
21
+ id: "title",
22
+ x: 64,
23
+ y: 80,
24
+ width: 600,
25
+ height: 96,
26
+ text: "My first presentation",
27
+ }),
28
+ ),
29
+ );
30
+ ```
31
+
32
+ Run the CLI from the project directory to write `slides.pptx`.
33
+
34
+ ```sh
35
+ npx pptxdk build slides.mjs
36
+ ```
37
+
38
+ To use the SDK from another ES module, pass the same document to `build`.
39
+
40
+ ```js
41
+ import { writeFile } from "node:fs/promises";
42
+
43
+ import { build } from "@officedk/pptxdk";
44
+
45
+ import slides from "./slides.mjs";
46
+
47
+ const { pptx } = await build(slides);
48
+ await writeFile("slides.pptx", pptx);
49
+ ```
@@ -0,0 +1,94 @@
1
+ import { C as CodegenEntryName, D as CodegenResult, E as CodegenOptions, M as codegenDiagnosticSchema, N as codegenOptionsSchema, O as CodegenTarget, P as codegenTargetSchema, S as CodegenDiagnosticCode, T as CodegenFileContent, _ as importLocationSchema, a as CascadedOmission, b as createCodegen, c as ImportDiagnostic, d as ImportOptions, f as ImportReport, g as importDiagnosticSchema, h as fatalImportIssueSchema, j as codegenDiagnosticCodeSchema, l as ImportError, m as editabilityLossSchema, n as createImporter, o as EditabilityLoss, p as cascadedOmissionSchema, s as FatalImportIssue, t as ImportResult, u as ImportLocation, v as importOptionsSchema, w as CodegenError, x as CodegenDiagnostic, y as importReportSchema } from "./index-DpxcZ4Gs.js";
2
+ import { At as formatBaselineSchema, C as BuildError, Ct as buildOptionsSchema, Dt as extensionSchema, Et as emitOptionsSchema, Jr as DeclarationContainer, L as EmitResult, M as CapabilityModule, Mt as targetNameSchema, Nt as targetSchema, O as BuildReport, Ot as fontEmbeddingModeSchema, Pt as targets, St as TargetName, Tt as diagnosticSeveritySchema, Xr as DeclarationText, Yr as DeclarationNode, _t as EmitOptions, bt as ResolveOptions, gt as DiagnosticSeverity, ht as Diagnostic, jt as resolveOptionsSchema, k as BuildResult, kt as formatBaseline, mt as BuildOptions, nt as ResolutionReport, o as CommonNode, qr as DeclarationChild, t as createResolver, tt as Resolution, vt as Extension, w as CapabilityError, wt as diagnosticSchema, xt as Target, yt as FontEmbeddingMode } from "./capability-D_xeNVIw.js";
3
+ import { t as emit } from "./index-B5m3hqjC.js";
4
+ import { z } from "zod";
5
+ import { ReactNode } from "react";
6
+ /** Complete list of official capability names in canonical order. */
7
+ export declare const officialCapabilityNames: readonly ["box", "chart", "footer-placeholder", "group", "image", "masters", "motion", "notes", "placeholder", "shape", "slide-background", "table", "text", "transition"];
8
+ export declare const officialCapabilityNameSchema: z.ZodEnum<{
9
+ box: "box";
10
+ chart: "chart";
11
+ "footer-placeholder": "footer-placeholder";
12
+ group: "group";
13
+ image: "image";
14
+ masters: "masters";
15
+ motion: "motion";
16
+ notes: "notes";
17
+ placeholder: "placeholder";
18
+ shape: "shape";
19
+ "slide-background": "slide-background";
20
+ table: "table";
21
+ text: "text";
22
+ transition: "transition";
23
+ }>;
24
+ /** Official capability module names accepted by `@officedk/pptxdk/build`. */
25
+ export type OfficialCapabilityName = z.infer<typeof officialCapabilityNameSchema>;
26
+ export declare const trimmedResolveOptionsSchema: z.ZodReadonly<z.ZodObject<{
27
+ signal: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
28
+ capabilities: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
29
+ box: "box";
30
+ chart: "chart";
31
+ "footer-placeholder": "footer-placeholder";
32
+ group: "group";
33
+ image: "image";
34
+ masters: "masters";
35
+ motion: "motion";
36
+ notes: "notes";
37
+ placeholder: "placeholder";
38
+ shape: "shape";
39
+ "slide-background": "slide-background";
40
+ table: "table";
41
+ text: "text";
42
+ transition: "transition";
43
+ }>>>;
44
+ }, z.core.$strict>>;
45
+ export type TrimmedResolveOptions = z.infer<typeof trimmedResolveOptionsSchema>;
46
+ export declare const trimmedBuildOptionsSchema: z.ZodReadonly<z.ZodObject<{
47
+ embedFonts: z.ZodOptional<z.ZodEnum<{
48
+ full: "full";
49
+ subset: "subset";
50
+ }>>;
51
+ target: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
52
+ name: z.ZodString;
53
+ format: z.ZodLiteral<"ECMA-376 5th edition Transitional">;
54
+ extensions: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
55
+ c15: "c15";
56
+ p14: "p14";
57
+ p159: "p159";
58
+ }>>>;
59
+ }, z.core.$strict>>>;
60
+ signal: z.ZodOptional<z.ZodInstanceOf<AbortSignal>>;
61
+ capabilities: z.ZodReadonly<z.ZodArray<z.ZodEnum<{
62
+ box: "box";
63
+ chart: "chart";
64
+ "footer-placeholder": "footer-placeholder";
65
+ group: "group";
66
+ image: "image";
67
+ masters: "masters";
68
+ motion: "motion";
69
+ notes: "notes";
70
+ placeholder: "placeholder";
71
+ shape: "shape";
72
+ "slide-background": "slide-background";
73
+ table: "table";
74
+ text: "text";
75
+ transition: "transition";
76
+ }>>>;
77
+ }, z.core.$strict>>;
78
+ export type TrimmedBuildOptions = z.infer<typeof trimmedBuildOptionsSchema>;
79
+ /**
80
+ * Dynamically loads only the requested official capability modules in deduplicated first-seen order.
81
+ */
82
+ export declare function selectCapabilities(names: readonly OfficialCapabilityName[], options?: {
83
+ readonly signal?: AbortSignal;
84
+ }): Promise<readonly CapabilityModule[]>;
85
+ /**
86
+ * Loads only the selected official capabilities and resolves either a CommonNode document or a JSX
87
+ * element into an immutable Resolution snapshot for `emit` and `paint`.
88
+ */
89
+ export declare function resolve(input: ReactNode | CommonNode, options: TrimmedResolveOptions): Promise<Resolution>;
90
+ /**
91
+ * Loads only the selected official capabilities, resolves the document, and emits a PPTX archive.
92
+ */
93
+ export declare function build(input: ReactNode | CommonNode, options: TrimmedBuildOptions): Promise<BuildResult>;
94
+ export { BuildError, type BuildOptions, type BuildReport, type BuildResult, CapabilityError, type CapabilityModule, type CascadedOmission, type CodegenDiagnostic, type CodegenDiagnosticCode, type CodegenEntryName, CodegenError, type CodegenFileContent, type CodegenOptions, type CodegenResult, type CodegenTarget, type DeclarationChild, type DeclarationContainer, type DeclarationNode, type DeclarationText, type Diagnostic, type DiagnosticSeverity, type EditabilityLoss, type EmitOptions, type EmitResult, type Extension, type FatalImportIssue, type FontEmbeddingMode, type ImportDiagnostic, ImportError, type ImportLocation, type ImportOptions, type ImportReport, type ImportResult, type Resolution, type ResolutionReport, type ResolveOptions, type Target, type TargetName, buildOptionsSchema, cascadedOmissionSchema, codegenDiagnosticCodeSchema, codegenDiagnosticSchema, codegenOptionsSchema, codegenTargetSchema, createCodegen, createImporter, createResolver, diagnosticSchema, diagnosticSeveritySchema, editabilityLossSchema, emit, emitOptionsSchema, extensionSchema, fatalImportIssueSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema, resolveOptionsSchema, targetNameSchema, targetSchema, targets };
package/dist/build.js ADDED
@@ -0,0 +1,148 @@
1
+ import { BuildError, CapabilityError } from "./core/dist/diagnostics.js";
2
+ import { buildOptionsSchema, diagnosticSchema, diagnosticSeveritySchema, emitOptionsSchema, extensionSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, resolveOptionsSchema, targetNameSchema, targetSchema, targets } from "./core/dist/stage-options.js";
3
+ import { createResolver } from "./core/dist/resolve.js";
4
+ import "./codegen/dist/index.js";
5
+ import { emit, validateOptions } from "./emit/dist/emit.js";
6
+ import "./core/dist/build.js";
7
+ import { ImportError, cascadedOmissionSchema, editabilityLossSchema, fatalImportIssueSchema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema } from "./import/dist/diagnostics.js";
8
+ import { createImporter } from "./import/dist/import.js";
9
+ import "./emit/dist/index.js";
10
+ import { CodegenError, codegenDiagnosticCodeSchema, codegenDiagnosticSchema, codegenOptionsSchema, codegenTargetSchema } from "./codegen/dist/types.js";
11
+ import { createCodegen } from "./codegen/dist/codegen.js";
12
+ import "./import/dist/index.js";
13
+ import { emitBuildResult, resolveDocumentInput } from "./pptxdk/src/compose.js";
14
+ import { z } from "zod";
15
+ // src/build.ts
16
+ /** Complete list of official capability names in canonical order. */
17
+ const officialCapabilityNames = Object.freeze([
18
+ "box",
19
+ "chart",
20
+ "footer-placeholder",
21
+ "group",
22
+ "image",
23
+ "masters",
24
+ "motion",
25
+ "notes",
26
+ "placeholder",
27
+ "shape",
28
+ "slide-background",
29
+ "table",
30
+ "text",
31
+ "transition"
32
+ ]);
33
+ const officialCapabilityNameSchema = z.enum(officialCapabilityNames);
34
+ const capabilitiesSelectionSchema = z.array(officialCapabilityNameSchema).readonly();
35
+ const capabilityLoaders = {
36
+ box: async () => (await import("./capabilities/dist/box/box.js")).boxCapability,
37
+ chart: async () => (await import("./capabilities/dist/chart/chart.js")).chartCapability,
38
+ "footer-placeholder": async () => (await import("./capabilities/dist/masters/footer-placeholder.js")).footerPlaceholderCapability,
39
+ group: async () => (await import("./capabilities/dist/group/group.js")).groupCapability,
40
+ image: async () => (await import("./capabilities/dist/image/image.js")).imageCapability,
41
+ masters: async () => (await import("./capabilities/dist/masters/masters.js")).mastersCapability,
42
+ motion: async () => (await import("./capabilities/dist/motion/motion.js")).motionCapability,
43
+ notes: async () => (await import("./capabilities/dist/notes/notes.js")).notesCapability,
44
+ placeholder: async () => (await import("./capabilities/dist/placeholder/placeholder.js")).placeholderCapability,
45
+ shape: async () => (await import("./capabilities/dist/shape/shape.js")).shapeCapability,
46
+ "slide-background": async () => (await import("./capabilities/dist/slide-background/slide-background.js")).slideBackgroundCapability,
47
+ table: async () => (await import("./capabilities/dist/table/table.js")).tableCapability,
48
+ text: async () => (await import("./capabilities/dist/text/text.js")).textCapability,
49
+ transition: async () => (await import("./capabilities/dist/transition/transition.js")).transitionCapability
50
+ };
51
+ const trimmedResolveOptionsSchema = resolveOptionsSchema.unwrap().extend({ capabilities: capabilitiesSelectionSchema }).readonly();
52
+ const trimmedBuildOptionsSchema = buildOptionsSchema.unwrap().extend({ capabilities: capabilitiesSelectionSchema }).readonly();
53
+ function validateCapabilityNames(names) {
54
+ const parsed = capabilitiesSelectionSchema.safeParse(names);
55
+ if (!parsed.success) {
56
+ const issue = parsed.error.issues[0];
57
+ if (issue !== void 0 && issue.path.length > 0) {
58
+ const index = Number(issue.path[0]);
59
+ const badName = Array.isArray(names) ? names[index] : void 0;
60
+ throw new BuildError([{
61
+ severity: "error",
62
+ code: "unknown-capability",
63
+ path: `build.capabilities[${index}]`,
64
+ message: `Unknown official capability ${JSON.stringify(badName)}`
65
+ }]);
66
+ }
67
+ throw new BuildError([{
68
+ severity: "error",
69
+ code: "invalid-capability-selection",
70
+ path: "build.capabilities",
71
+ message: "capabilities must be an array of official capability names"
72
+ }]);
73
+ }
74
+ return [...new Set(parsed.data)];
75
+ }
76
+ /**
77
+ * Dynamically loads only the requested official capability modules in deduplicated first-seen order.
78
+ */
79
+ async function selectCapabilities(names, options = {}) {
80
+ const orderedNames = validateCapabilityNames(names);
81
+ if (options.signal?.aborted) throw options.signal.reason;
82
+ const modules = await Promise.all(orderedNames.map((name) => capabilityLoaders[name]()));
83
+ if (options.signal?.aborted) throw options.signal.reason;
84
+ return Object.freeze(modules);
85
+ }
86
+ async function resolveSelected(input, capabilities, signal) {
87
+ const signalOption = signal === void 0 ? {} : { signal };
88
+ const modules = await selectCapabilities(capabilities, signalOption);
89
+ return resolveDocumentInput(createResolver(modules), input, signalOption);
90
+ }
91
+ /**
92
+ * Loads only the selected official capabilities and resolves either a CommonNode document or a JSX
93
+ * element into an immutable Resolution snapshot for `emit` and `paint`.
94
+ */
95
+ async function resolve(input, options) {
96
+ const parsed = trimmedResolveOptionsSchema.safeParse(options);
97
+ if (!parsed.success) {
98
+ const issue = parsed.error.issues[0];
99
+ if (issue?.path[0] === "capabilities") validateCapabilityNames(options.capabilities);
100
+ if (issue?.path.length === 0 && issue.code === "unrecognized_keys") throw new BuildError([{
101
+ severity: "error",
102
+ code: "unknown-parameter",
103
+ path: "resolve",
104
+ message: `Resolve options contain unknown parameter ${issue.keys[0]}`
105
+ }]);
106
+ if (issue?.path[0] === "signal") throw new BuildError([{
107
+ severity: "error",
108
+ code: "invalid-options",
109
+ path: "resolve.signal",
110
+ message: "Resolve options signal must be an AbortSignal"
111
+ }]);
112
+ throw new BuildError([{
113
+ severity: "error",
114
+ code: "invalid-options",
115
+ path: "resolve",
116
+ message: "Build options must be an object"
117
+ }]);
118
+ }
119
+ return resolveSelected(input, validateCapabilityNames(parsed.data.capabilities), parsed.data.signal);
120
+ }
121
+ /**
122
+ * Loads only the selected official capabilities, resolves the document, and emits a PPTX archive.
123
+ */
124
+ async function build(input, options) {
125
+ const parsed = trimmedBuildOptionsSchema.safeParse(options);
126
+ if (!parsed.success) {
127
+ if (typeof options !== "object" || options === null || Array.isArray(options)) throw new BuildError([{
128
+ severity: "error",
129
+ code: "invalid-options",
130
+ path: "build",
131
+ message: "Build options must be an object"
132
+ }]);
133
+ const { capabilities, ...buildOptions } = options;
134
+ validateOptions(buildOptions);
135
+ validateCapabilityNames(capabilities);
136
+ throw new BuildError([{
137
+ severity: "error",
138
+ code: "invalid-options",
139
+ path: "build",
140
+ message: "Build options are invalid"
141
+ }]);
142
+ }
143
+ const capabilities = validateCapabilityNames(parsed.data.capabilities);
144
+ const { capabilities: _capabilities, ...buildOptions } = parsed.data;
145
+ const resolution = await resolveSelected(input, capabilities, buildOptions.signal);
146
+ return emitBuildResult(resolution, buildOptions);
147
+ }
148
+ export { BuildError, CapabilityError, CodegenError, ImportError, build, buildOptionsSchema, cascadedOmissionSchema, codegenDiagnosticCodeSchema, codegenDiagnosticSchema, codegenOptionsSchema, codegenTargetSchema, createCodegen, createImporter, createResolver, diagnosticSchema, diagnosticSeveritySchema, editabilityLossSchema, emit, emitOptionsSchema, extensionSchema, fatalImportIssueSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema, officialCapabilityNameSchema, officialCapabilityNames, resolve, resolveOptionsSchema, selectCapabilities, targetNameSchema, targetSchema, targets, trimmedBuildOptionsSchema, trimmedResolveOptionsSchema };
@@ -0,0 +1,32 @@
1
+ import { boxCapability } from "./box/box.js";
2
+ import { chartCapability } from "./chart/chart.js";
3
+ import { groupCapability } from "./group/group.js";
4
+ import { imageCapability } from "./image/image.js";
5
+ import { footerPlaceholderCapability } from "./masters/footer-placeholder.js";
6
+ import { mastersCapability } from "./masters/masters.js";
7
+ import { motionCapability } from "./motion/motion.js";
8
+ import { notesCapability } from "./notes/notes.js";
9
+ import { placeholderCapability } from "./placeholder/placeholder.js";
10
+ import { shapeCapability } from "./shape/shape.js";
11
+ import { slideBackgroundCapability } from "./slide-background/slide-background.js";
12
+ import { tableCapability } from "./table/table.js";
13
+ import { textCapability } from "./text/text.js";
14
+ import { transitionCapability } from "./transition/transition.js";
15
+ /** Baseline capabilities enabled by the public document build; factories never register capabilities. */
16
+ const documentCapabilities = Object.freeze([
17
+ boxCapability,
18
+ chartCapability,
19
+ footerPlaceholderCapability,
20
+ groupCapability,
21
+ imageCapability,
22
+ mastersCapability,
23
+ motionCapability,
24
+ notesCapability,
25
+ placeholderCapability,
26
+ shapeCapability,
27
+ slideBackgroundCapability,
28
+ tableCapability,
29
+ textCapability,
30
+ transitionCapability
31
+ ]);
32
+ export { documentCapabilities };
@@ -0,0 +1,51 @@
1
+ import "../../../codegen/dist/index.js";
2
+ import { defineObjectCodegen } from "../../../codegen/dist/types.js";
3
+ import { CommonNode } from "../../../core/dist/document.js";
4
+ // ../capabilities/dist/box/box-codegen.js
5
+ const objectMotionPropKeys = /* @__PURE__ */ new Set([
6
+ "enter",
7
+ "emphasis",
8
+ "motion"
9
+ ]);
10
+ function collectBoxProps(node, ctx) {
11
+ const extra = ctx.emitObjectExtraProps(node.props);
12
+ const entries = [];
13
+ for (const [key, value] of Object.entries(node.props)) {
14
+ if (value === void 0) continue;
15
+ if (objectMotionPropKeys.has(key)) {
16
+ if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
17
+ else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
18
+ continue;
19
+ }
20
+ entries.push([key, value]);
21
+ }
22
+ return entries;
23
+ }
24
+ function emitBoxChildren(node, ctx) {
25
+ const children = [];
26
+ let childIndex = 0;
27
+ for (const child of node.children) if (child instanceof CommonNode) {
28
+ children.push(ctx.emitChildNode(child, childIndex));
29
+ childIndex += 1;
30
+ } else if ("text" in child && typeof child.text === "string" && child.text.trim() !== "") ctx.fail("invalid-document", "Box cannot directly contain text content");
31
+ return children;
32
+ }
33
+ function emitBoxVanilla(node, ctx) {
34
+ const callee = ctx.useImport("box");
35
+ const propsEntries = collectBoxProps(node, ctx);
36
+ const args = propsEntries.length === 0 ? [] : [ctx.formatProps(propsEntries)];
37
+ const children = emitBoxChildren(node, ctx);
38
+ return ctx.formatVanillaCall(callee, args, children);
39
+ }
40
+ function emitBoxReact(node, ctx) {
41
+ const tag = ctx.useImport("Box");
42
+ const propsEntries = collectBoxProps(node, ctx);
43
+ const children = emitBoxChildren(node, ctx);
44
+ return ctx.formatJsxElement(tag, propsEntries, children);
45
+ }
46
+ /** Source codegen contribution for `box` layout container declarations. */
47
+ const boxCodegen = defineObjectCodegen({ declarations: { box: {
48
+ emitVanilla: emitBoxVanilla,
49
+ emitReact: emitBoxReact
50
+ } } });
51
+ export { boxCodegen };
@@ -0,0 +1,31 @@
1
+ import { authorIdSchema } from "../../../core/dist/author-ids.js";
2
+ import { layoutStyleSchema } from "../../../core/dist/layout-schemas.js";
3
+ import { textStyleSchema, themeScopeSchema, visualStyleSchema } from "../../../core/dist/theme.js";
4
+ import { linkTargetSchema } from "../../../core/dist/author-schemas.js";
5
+ import "../../../core/dist/capability.js";
6
+ import { CommonContainer } from "../../../core/dist/document.js";
7
+ import { motionPropsSchema } from "../motion/motion-schemas.js";
8
+ import { morphKeySchema } from "../shared/morph-api.js";
9
+ import { z } from "zod";
10
+ const boxStyleSchema = z.strictObject({
11
+ ...layoutStyleSchema.unwrap().shape,
12
+ ...textStyleSchema.unwrap().shape,
13
+ ...visualStyleSchema.unwrap().shape
14
+ }).readonly();
15
+ const motionPropsShape = motionPropsSchema.unwrap().shape;
16
+ const boxDeclarationPropsObjectSchema = z.strictObject({
17
+ id: authorIdSchema.optional(),
18
+ morphKey: morphKeySchema.optional(),
19
+ link: linkTargetSchema.optional(),
20
+ style: boxStyleSchema.optional(),
21
+ theme: themeScopeSchema.optional(),
22
+ enter: motionPropsShape.enter,
23
+ motion: motionPropsShape.motion
24
+ });
25
+ const boxDeclarationPropsKeys = Object.keys(boxDeclarationPropsObjectSchema.shape);
26
+ boxDeclarationPropsObjectSchema.readonly();
27
+ /** Creates the editable layout container shared by the command factory and the Box JSX element. */
28
+ function createBoxNode(props) {
29
+ return new CommonContainer("box", "box", props);
30
+ }
31
+ export { boxDeclarationPropsKeys, boxStyleSchema, createBoxNode };
@@ -0,0 +1,17 @@
1
+ import { hostNodeCreator } from "../../../core/dist/host.js";
2
+ import { createBoxNode } from "./box-declaration.js";
3
+ import { createElement } from "react";
4
+ // ../capabilities/dist/box/box-elements.js
5
+ /**
6
+ * Visible Box backgrounds and descendants inherit its entrance only when they do not declare one.
7
+ *
8
+ * The local `enter` and `motion` values stay on the editable node. Inheritance is derived by the next
9
+ * formal build from the current document, so a moved Box does not leave a stale provider context.
10
+ */
11
+ function Box({ children, ...props }) {
12
+ return createElement("box", {
13
+ ...props,
14
+ [hostNodeCreator]: createBoxNode
15
+ }, children);
16
+ }
17
+ export { Box };
@@ -0,0 +1,138 @@
1
+ import { CapabilityError } from "../../../core/dist/diagnostics.js";
2
+ import { textStyleFrom } from "../../../core/dist/theme.js";
3
+ import { parseLinkTarget } from "../../../core/dist/author-schemas.js";
4
+ import { parseCapabilityLayoutContract } from "../../../core/dist/layout.js";
5
+ import "../../../core/dist/capability.js";
6
+ import { xmlEscape } from "../../../emit/dist/ooxml.js";
7
+ import "../../../emit/dist/index.js";
8
+ import { motionContainerAnnotations, validateMotionFlag } from "../motion/motion-api.js";
9
+ import { nativeLinkXml, parseMorphKey } from "../shared/identity.js";
10
+ import { emitVisualModel, hasVisibleBoxStyle, paintVisualModel, resolveVisualModel } from "../shared/visual.js";
11
+ import { boxCodegen } from "./box-codegen.js";
12
+ import { boxDeclarationPropsKeys, boxStyleSchema } from "./box-declaration.js";
13
+ // ../capabilities/dist/box/box.js
14
+ const boxAllowedParameters = boxDeclarationPropsKeys;
15
+ const boxAllowedStyleKeys = new Set(Object.keys(boxStyleSchema.unwrap().shape));
16
+ function styleRecord(value) {
17
+ if (value === void 0) return {};
18
+ if (typeof value !== "object" || value === null || Array.isArray(value)) throw new CapabilityError("invalid-style", "Box.style must be an object");
19
+ return value;
20
+ }
21
+ function objectXml(id, escapedName, properties, linkXml) {
22
+ return `<p:sp><p:nvSpPr><p:cNvPr id="${id}" name="${escapedName}">${linkXml}</p:cNvPr><p:cNvSpPr/><p:nvPr/></p:nvSpPr>${properties}</p:sp>`;
23
+ }
24
+ /** Visible Box backgrounds use the same shape property writer; boxes without fill, stroke, or shadow retain layout semantics only. */
25
+ const boxCapability = {
26
+ declaration: "box",
27
+ codegen: boxCodegen,
28
+ bind(input, context) {
29
+ const unknown = Object.keys(input.props).find((key) => !boxAllowedParameters.includes(key));
30
+ if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Box contains unknown parameter ${unknown}`);
31
+ validateMotionFlag(input.props["motion"]);
32
+ const morphKey = parseMorphKey(input.props["morphKey"]);
33
+ const link = parseLinkTarget(input.props["link"]);
34
+ const style = { ...styleRecord(input.props["style"]) };
35
+ const hasVisibleStyle = hasVisibleBoxStyle(style);
36
+ if (morphKey !== void 0 && !hasVisibleStyle) throw new CapabilityError("morph-needs-object", "Only visible Box elements generating native background shapes can participate in Morph");
37
+ const contract = parseCapabilityLayoutContract({
38
+ nativeKind: "sp",
39
+ props: input.props,
40
+ allowedStyleKeys: boxAllowedStyleKeys,
41
+ allowPadding: true,
42
+ isContainer: true,
43
+ path: context.path
44
+ });
45
+ const theme = context.theme.with(input.props["theme"], textStyleFrom(style));
46
+ resolveVisualModel({
47
+ theme,
48
+ style,
49
+ box: {
50
+ x: 0,
51
+ y: 0,
52
+ width: 100,
53
+ height: 100
54
+ },
55
+ layoutOnlyWhenInvisible: true
56
+ });
57
+ const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
58
+ const motionProps = {
59
+ ...input.props["enter"] !== void 0 ? { enter: input.props["enter"] } : {},
60
+ ...input.props["motion"] !== void 0 ? { motion: input.props["motion"] } : {}
61
+ };
62
+ const container = {
63
+ children: input.children,
64
+ theme,
65
+ emitsObject: hasVisibleStyle,
66
+ observesLayout: true,
67
+ propagatesBaseline: true,
68
+ checksCanvasOverflow: true
69
+ };
70
+ const native = {
71
+ ...morphKey === void 0 ? {} : { morphKey },
72
+ ...link === void 0 ? {} : { link }
73
+ };
74
+ return {
75
+ contract,
76
+ container,
77
+ ...morphKey !== void 0 || link !== void 0 ? { native } : {},
78
+ resolve(resolveContext) {
79
+ const box = resolveContext.layoutBox;
80
+ if (box === void 0) throw new CapabilityError("layout-unavailable", "Box is missing layout results");
81
+ const name = resolveContext.morphName ?? `Box ${resolveContext.id - 1}`;
82
+ let escapedName;
83
+ try {
84
+ escapedName = xmlEscape(name);
85
+ } catch {
86
+ throw new CapabilityError("invalid-xml-character", "Box.name contains characters not allowed in XML 1.0");
87
+ }
88
+ const visual = resolveVisualModel({
89
+ theme: resolveContext.theme,
90
+ style,
91
+ box,
92
+ layoutOnlyWhenInvisible: true
93
+ });
94
+ const geometryName = visual.geometry.kind === "custom" ? "custom" : visual.geometry.name;
95
+ const motionTarget = {
96
+ kind: "shape",
97
+ name,
98
+ ...authorId === void 0 ? {} : { authorId },
99
+ textBody: false,
100
+ filled: style["backgroundColor"] !== void 0 || style["backgroundImage"] !== void 0
101
+ };
102
+ const annotations = motionContainerAnnotations(motionProps, visual.hasVisibleStyle ? motionTarget : void 0, { propagatesDefaultEnter: true });
103
+ const transform = visual.hasVisibleStyle ? {
104
+ box,
105
+ angle: visual.rotate,
106
+ flipH: visual.flipH,
107
+ flipV: visual.flipV
108
+ } : void 0;
109
+ return {
110
+ observation: {
111
+ id: resolveContext.id,
112
+ kind: "shape",
113
+ name,
114
+ geometry: geometryName,
115
+ box
116
+ },
117
+ ...transform === void 0 ? {} : { transform },
118
+ extensions: [],
119
+ ...annotations.length === 0 ? {} : { annotations },
120
+ ...visual.warnings.length === 0 ? {} : { warnings: visual.warnings },
121
+ emit(emitContext) {
122
+ return { xml: visual.hasVisibleStyle ? objectXml(emitContext.id, escapedName, emitVisualModel(visual, (resource) => emitContext.registerResource(resource)).xml, nativeLinkXml(emitContext.nativeLink)) : "" };
123
+ },
124
+ paint(paintContext) {
125
+ const childrenSvg = paintContext.childrenSvg ?? "";
126
+ if (!visual.hasVisibleStyle) return { svg: childrenSvg };
127
+ return { svg: `${paintVisualModel({
128
+ model: visual,
129
+ slideNumber: paintContext.slideNumber,
130
+ objectId: paintContext.objectId
131
+ }).svg}${childrenSvg}` };
132
+ }
133
+ };
134
+ }
135
+ };
136
+ }
137
+ };
138
+ export { boxCapability };