@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.
- package/LICENSE +21 -0
- package/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -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.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Ft as ResolveOptions, H as CapabilityModule, et as Resolution, mi as DeclarationNode, pi as DeclarationContainer } from "./capability-BbKW9w4O.js";
|
|
2
|
+
declare function createResolver(modules: readonly CapabilityModule[]): (declaration: DeclarationContainer | DeclarationNode, options?: ResolveOptions) => Resolution;
|
|
3
|
+
export { createResolver as t };
|
package/dist/build.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { a as CodegenError, c as CodegenResult, d as codegenDiagnosticSchema, f as codegenOptionsSchema, i as CodegenEntryName, l as CodegenTarget, m as emit, n as CodegenDiagnostic, o as CodegenFileContent, p as codegenTargetSchema, r as CodegenDiagnosticCode, s as CodegenOptions, t as createCodegen, u as codegenDiagnosticCodeSchema } from "./index-1ag7U9Jt.js";
|
|
2
|
+
import { t as createResolver } from "./build-zrZuX4fK.js";
|
|
3
|
+
import { At as Extension, B as BuildReport, Bt as buildOptionsSchema, Dt as BuildDiagnosticFontUnavailableReason, Et as BuildDiagnostic, Ft as ResolveOptions, G as FontUsage, Gt as formatBaselineSchema, H as CapabilityModule, Ht as extensionSchema, It as Target, J as LocatorResource, Jt as resolveOptionsSchema, Kt as previewErrorSchema, Lt as TargetName, Mt as PreviewError, Ot as BuildOptions, Pt as PreviewPlaceholder, Q as Rect, Rt as buildDiagnosticFontUnavailableReasonSchema, Tt as CapabilityError, U as EmitResult, Ut as fontEmbeddingModeSchema, V as BuildResult, Vt as emitOptionsSchema, W as FontStyleDescriptor, Wt as formatBaseline, X as ObjectTransform, Xt as targetSchema, Yt as targetNameSchema, Zt as targets, _t as UnmeasuredFontIssue, a as CommonNode, at as ResolvedImage, b as ResolvedPlaceholder, dt as ResolvedTableCell, et as Resolution, fi as DeclarationChild, ft as ResolvedTableRow, gt as TextMetrics, hi as DeclarationText, ht as SlideLocator, it as ResolvedFooterSlot, jt as FontEmbeddingMode, kt as EmitOptions, lt as ResolvedSlide, mi as DeclarationNode, nt as ResolutionReport, ot as ResolvedLayout, pi as DeclarationContainer, pt as ScreenPoint, q as Locator, qt as previewPlaceholderSchema, rt as ResolvedFooter, st as ResolvedObject, tt as ResolutionDimensionsSummary, ut as ResolvedTable, wt as BuildError, x as ResolvedSlideLayout, y as ResolvedMaster, zt as buildDiagnosticSchema } from "./capability-BbKW9w4O.js";
|
|
4
|
+
import { _ as importOptionsSchema, a as EditabilityLoss, c as ImportError, d as ImportReport, f as cascadedOmissionSchema, g as importLocationSchema, h as importDiagnosticSchema, i as CascadedOmission, l as ImportLocation, m as fatalImportIssueSchema, n as createImporter, o as FatalImportIssue, p as editabilityLossSchema, s as ImportDiagnostic, t as ImportResult, u as ImportOptions, v as importReportSchema } from "./index-cK2KtukZ.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { ReactNode } from "react";
|
|
7
|
+
/** Complete list of official capability names in canonical order. */
|
|
8
|
+
export declare const officialCapabilityNames: readonly ["box", "chart", "footer-placeholder", "group", "image", "line", "masters", "motion", "notes", "placeholder", "shape", "slide-background", "table", "text", "transition"];
|
|
9
|
+
/** Official capability module names accepted by `@officedk/pptxdk/build`. */
|
|
10
|
+
export type OfficialCapabilityName = "box" | "chart" | "footer-placeholder" | "group" | "image" | "line" | "masters" | "motion" | "notes" | "placeholder" | "shape" | "slide-background" | "table" | "text" | "transition";
|
|
11
|
+
export declare const officialCapabilityNameSchema: z.ZodType<OfficialCapabilityName>;
|
|
12
|
+
export type TrimmedResolveOptions = ResolveOptions & {
|
|
13
|
+
readonly capabilities: readonly OfficialCapabilityName[];
|
|
14
|
+
};
|
|
15
|
+
export declare const trimmedResolveOptionsSchema: z.ZodType<TrimmedResolveOptions>;
|
|
16
|
+
export type TrimmedBuildOptions = BuildOptions & {
|
|
17
|
+
readonly capabilities: readonly OfficialCapabilityName[];
|
|
18
|
+
};
|
|
19
|
+
export declare const trimmedBuildOptionsSchema: z.ZodType<TrimmedBuildOptions>;
|
|
20
|
+
/**
|
|
21
|
+
* Dynamically loads only the requested official capability modules in deduplicated first-seen order.
|
|
22
|
+
*/
|
|
23
|
+
export declare function selectCapabilities(names: readonly OfficialCapabilityName[], options?: {
|
|
24
|
+
readonly signal?: AbortSignal;
|
|
25
|
+
}): Promise<readonly CapabilityModule[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Loads only the selected official capabilities and resolves either a CommonNode document or a JSX
|
|
28
|
+
* element into an immutable Resolution snapshot for `emit` and `paint`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function resolve(input: ReactNode | CommonNode, options: TrimmedResolveOptions): Promise<Resolution>;
|
|
31
|
+
/**
|
|
32
|
+
* Loads only the selected official capabilities, resolves the document, and emits a PPTX archive.
|
|
33
|
+
*/
|
|
34
|
+
export declare function build(input: ReactNode | CommonNode, options: TrimmedBuildOptions): Promise<BuildResult>;
|
|
35
|
+
export { type BuildDiagnostic, type BuildDiagnosticFontUnavailableReason, 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 EditabilityLoss, type EmitOptions, type EmitResult, type Extension, type FatalImportIssue, type FontEmbeddingMode, type FontStyleDescriptor, type FontUsage, type ImportDiagnostic, ImportError, type ImportLocation, type ImportOptions, type ImportReport, type ImportResult, type Locator, type LocatorResource, type ObjectTransform, type PreviewError, type PreviewPlaceholder, type Rect, type Resolution, type ResolutionDimensionsSummary, type ResolutionReport, type ResolveOptions, type ResolvedFooter, type ResolvedFooterSlot, type ResolvedImage, type ResolvedLayout, type ResolvedMaster, type ResolvedObject, type ResolvedPlaceholder, type ResolvedSlide, type ResolvedSlideLayout, type ResolvedTable, type ResolvedTableCell, type ResolvedTableRow, type ScreenPoint, type SlideLocator, type Target, type TargetName, type TextMetrics, type UnmeasuredFontIssue, buildDiagnosticFontUnavailableReasonSchema, buildDiagnosticSchema, buildOptionsSchema, cascadedOmissionSchema, codegenDiagnosticCodeSchema, codegenDiagnosticSchema, codegenOptionsSchema, codegenTargetSchema, createCodegen, createImporter, createResolver, editabilityLossSchema, emit, emitOptionsSchema, extensionSchema, fatalImportIssueSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema, previewErrorSchema, previewPlaceholderSchema, resolveOptionsSchema, targetNameSchema, targetSchema, targets };
|
package/dist/build.js
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { BuildError, CapabilityError, toBuildDiagnostic } from "./core/dist/diagnostics.js";
|
|
2
|
+
import { buildDiagnosticFontUnavailableReasonSchema, buildDiagnosticSchema, buildOptionsSchema, buildOptionsShape, emitOptionsSchema, extensionSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, previewErrorSchema, previewPlaceholderSchema, resolveOptionsSchema, resolveOptionsShape, 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
|
+
"line",
|
|
24
|
+
"masters",
|
|
25
|
+
"motion",
|
|
26
|
+
"notes",
|
|
27
|
+
"placeholder",
|
|
28
|
+
"shape",
|
|
29
|
+
"slide-background",
|
|
30
|
+
"table",
|
|
31
|
+
"text",
|
|
32
|
+
"transition"
|
|
33
|
+
]);
|
|
34
|
+
const rawOfficialCapabilityNameSchema = z.enum(officialCapabilityNames);
|
|
35
|
+
const officialCapabilityNameSchema = rawOfficialCapabilityNameSchema;
|
|
36
|
+
const capabilitiesSelectionSchema = z.array(rawOfficialCapabilityNameSchema).readonly();
|
|
37
|
+
const capabilityLoaders = {
|
|
38
|
+
box: async () => (await import("./capabilities/dist/box/box.js")).boxCapability,
|
|
39
|
+
chart: async () => (await import("./capabilities/dist/chart/chart.js")).chartCapability,
|
|
40
|
+
"footer-placeholder": async () => (await import("./capabilities/dist/masters/footer-placeholder.js")).footerPlaceholderCapability,
|
|
41
|
+
group: async () => (await import("./capabilities/dist/group/group.js")).groupCapability,
|
|
42
|
+
image: async () => (await import("./capabilities/dist/image/image.js")).imageCapability,
|
|
43
|
+
line: async () => (await import("./capabilities/dist/line/line.js")).lineCapability,
|
|
44
|
+
masters: async () => (await import("./capabilities/dist/masters/masters.js")).mastersCapability,
|
|
45
|
+
motion: async () => (await import("./capabilities/dist/motion/motion.js")).motionCapability,
|
|
46
|
+
notes: async () => (await import("./capabilities/dist/notes/notes.js")).notesCapability,
|
|
47
|
+
placeholder: async () => (await import("./capabilities/dist/placeholder/placeholder.js")).placeholderCapability,
|
|
48
|
+
shape: async () => (await import("./capabilities/dist/shape/shape.js")).shapeCapability,
|
|
49
|
+
"slide-background": async () => (await import("./capabilities/dist/slide-background/slide-background.js")).slideBackgroundCapability,
|
|
50
|
+
table: async () => (await import("./capabilities/dist/table/table.js")).tableCapability,
|
|
51
|
+
text: async () => (await import("./capabilities/dist/text/text.js")).textCapability,
|
|
52
|
+
transition: async () => (await import("./capabilities/dist/transition/transition.js")).transitionCapability
|
|
53
|
+
};
|
|
54
|
+
const trimmedResolveOptionsSchema = z.strictObject({
|
|
55
|
+
...resolveOptionsShape,
|
|
56
|
+
capabilities: capabilitiesSelectionSchema
|
|
57
|
+
}).readonly();
|
|
58
|
+
const trimmedBuildOptionsSchema = z.strictObject({
|
|
59
|
+
...buildOptionsShape,
|
|
60
|
+
capabilities: capabilitiesSelectionSchema
|
|
61
|
+
}).readonly();
|
|
62
|
+
function validateCapabilityNames(names) {
|
|
63
|
+
const parsed = capabilitiesSelectionSchema.safeParse(names);
|
|
64
|
+
if (!parsed.success) {
|
|
65
|
+
const issue = parsed.error.issues[0];
|
|
66
|
+
if (issue !== void 0 && issue.path.length > 0) {
|
|
67
|
+
const index = Number(issue.path[0]);
|
|
68
|
+
const badName = Array.isArray(names) ? names[index] : void 0;
|
|
69
|
+
throw new BuildError([toBuildDiagnostic(`build.capabilities[${index}]`, "unknown-capability", `Unknown official capability ${JSON.stringify(badName)}`, {
|
|
70
|
+
capability: typeof badName === "string" ? badName : String(badName),
|
|
71
|
+
field: "capabilities"
|
|
72
|
+
})]);
|
|
73
|
+
}
|
|
74
|
+
throw new BuildError([toBuildDiagnostic("build.capabilities", "invalid-capability-selection", "capabilities must be an array of official capability names", { field: "capabilities" })]);
|
|
75
|
+
}
|
|
76
|
+
return [...new Set(parsed.data)];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Dynamically loads only the requested official capability modules in deduplicated first-seen order.
|
|
80
|
+
*/
|
|
81
|
+
async function selectCapabilities(names, options = {}) {
|
|
82
|
+
const orderedNames = validateCapabilityNames(names);
|
|
83
|
+
if (options.signal?.aborted) throw options.signal.reason;
|
|
84
|
+
const modules = await Promise.all(orderedNames.map((name) => capabilityLoaders[name]()));
|
|
85
|
+
if (options.signal?.aborted) throw options.signal.reason;
|
|
86
|
+
return Object.freeze(modules);
|
|
87
|
+
}
|
|
88
|
+
async function resolveSelected(input, capabilities, signal) {
|
|
89
|
+
const signalOption = signal === void 0 ? {} : { signal };
|
|
90
|
+
const modules = await selectCapabilities(capabilities, signalOption);
|
|
91
|
+
return resolveDocumentInput(createResolver(modules), input, signalOption);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Loads only the selected official capabilities and resolves either a CommonNode document or a JSX
|
|
95
|
+
* element into an immutable Resolution snapshot for `emit` and `paint`.
|
|
96
|
+
*/
|
|
97
|
+
async function resolve(input, options) {
|
|
98
|
+
const parsed = trimmedResolveOptionsSchema.safeParse(options);
|
|
99
|
+
if (!parsed.success) {
|
|
100
|
+
const issue = parsed.error.issues[0];
|
|
101
|
+
if (issue?.path[0] === "capabilities") validateCapabilityNames(options.capabilities);
|
|
102
|
+
if (issue?.path.length === 0 && issue.code === "unrecognized_keys") throw new BuildError([toBuildDiagnostic("resolve", "unknown-parameter", `Resolve options contain unknown parameter ${issue.keys[0]}`, {
|
|
103
|
+
prop: String(issue.keys[0]),
|
|
104
|
+
scope: "options"
|
|
105
|
+
})]);
|
|
106
|
+
if (issue?.path[0] === "signal") throw new BuildError([toBuildDiagnostic("resolve.signal", "invalid-options", "Resolve options signal must be an AbortSignal", { field: "signal" })]);
|
|
107
|
+
throw new BuildError([toBuildDiagnostic("resolve", "invalid-options", "Build options must be an object")]);
|
|
108
|
+
}
|
|
109
|
+
return resolveSelected(input, validateCapabilityNames(parsed.data.capabilities), parsed.data.signal);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Loads only the selected official capabilities, resolves the document, and emits a PPTX archive.
|
|
113
|
+
*/
|
|
114
|
+
async function build(input, options) {
|
|
115
|
+
const parsed = trimmedBuildOptionsSchema.safeParse(options);
|
|
116
|
+
if (!parsed.success) {
|
|
117
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) throw new BuildError([toBuildDiagnostic("build", "invalid-options", "Build options must be an object")]);
|
|
118
|
+
const { capabilities, ...buildOptions } = options;
|
|
119
|
+
validateOptions(buildOptions);
|
|
120
|
+
validateCapabilityNames(capabilities);
|
|
121
|
+
throw new BuildError([toBuildDiagnostic("build", "invalid-options", "Build options are invalid")]);
|
|
122
|
+
}
|
|
123
|
+
const capabilities = validateCapabilityNames(parsed.data.capabilities);
|
|
124
|
+
const { capabilities: _capabilities, ...buildOptions } = parsed.data;
|
|
125
|
+
const resolution = await resolveSelected(input, capabilities, buildOptions.signal);
|
|
126
|
+
return emitBuildResult(resolution, buildOptions);
|
|
127
|
+
}
|
|
128
|
+
export { BuildError, CapabilityError, CodegenError, ImportError, build, buildDiagnosticFontUnavailableReasonSchema, buildDiagnosticSchema, buildOptionsSchema, cascadedOmissionSchema, codegenDiagnosticCodeSchema, codegenDiagnosticSchema, codegenOptionsSchema, codegenTargetSchema, createCodegen, createImporter, createResolver, editabilityLossSchema, emit, emitOptionsSchema, extensionSchema, fatalImportIssueSchema, fontEmbeddingModeSchema, formatBaseline, formatBaselineSchema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema, officialCapabilityNameSchema, officialCapabilityNames, previewErrorSchema, previewPlaceholderSchema, resolve, resolveOptionsSchema, selectCapabilities, targetNameSchema, targetSchema, targets, trimmedBuildOptionsSchema, trimmedResolveOptionsSchema };
|
|
@@ -0,0 +1,34 @@
|
|
|
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 { lineCapability } from "./line/line.js";
|
|
6
|
+
import { footerPlaceholderCapability } from "./masters/footer-placeholder.js";
|
|
7
|
+
import { mastersCapability } from "./masters/masters.js";
|
|
8
|
+
import { motionCapability } from "./motion/motion.js";
|
|
9
|
+
import { notesCapability } from "./notes/notes.js";
|
|
10
|
+
import { placeholderCapability } from "./placeholder/placeholder.js";
|
|
11
|
+
import { shapeCapability } from "./shape/shape.js";
|
|
12
|
+
import { slideBackgroundCapability } from "./slide-background/slide-background.js";
|
|
13
|
+
import { tableCapability } from "./table/table.js";
|
|
14
|
+
import { textCapability } from "./text/text.js";
|
|
15
|
+
import { transitionCapability } from "./transition/transition.js";
|
|
16
|
+
/** Baseline capabilities enabled by the public document build; factories never register capabilities. */
|
|
17
|
+
const documentCapabilities = Object.freeze([
|
|
18
|
+
boxCapability,
|
|
19
|
+
chartCapability,
|
|
20
|
+
footerPlaceholderCapability,
|
|
21
|
+
groupCapability,
|
|
22
|
+
imageCapability,
|
|
23
|
+
lineCapability,
|
|
24
|
+
mastersCapability,
|
|
25
|
+
motionCapability,
|
|
26
|
+
notesCapability,
|
|
27
|
+
placeholderCapability,
|
|
28
|
+
shapeCapability,
|
|
29
|
+
slideBackgroundCapability,
|
|
30
|
+
tableCapability,
|
|
31
|
+
textCapability,
|
|
32
|
+
transitionCapability
|
|
33
|
+
]);
|
|
34
|
+
export { documentCapabilities };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../../core/dist/document-internals.js";
|
|
2
|
+
import "../../../codegen/dist/index.js";
|
|
3
|
+
import "../../../core/dist/capability.js";
|
|
4
|
+
import { CommonNode } from "../../../core/dist/document.js";
|
|
5
|
+
import { defineObjectCodegen, expr } from "../../../codegen/dist/types.js";
|
|
6
|
+
import { serializeImageDescriptorValue } from "../image/image-codegen.js";
|
|
7
|
+
import { motionPropKeySet } from "../motion/motion-schemas.js";
|
|
8
|
+
import { boxDeclarationPropsKeys, boxStyleSchema } from "./box-declaration.js";
|
|
9
|
+
// ../capabilities/dist/box/box-codegen.js
|
|
10
|
+
const objectMotionPropKeys = motionPropKeySet;
|
|
11
|
+
const boxAllowedPropKeys = new Set(boxDeclarationPropsKeys);
|
|
12
|
+
function isPlainRecord(value) {
|
|
13
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
14
|
+
const proto = Object.getPrototypeOf(value);
|
|
15
|
+
return proto === Object.prototype || proto === null;
|
|
16
|
+
}
|
|
17
|
+
function serializeBoxStyleProp(style, ctx) {
|
|
18
|
+
if (!isPlainRecord(style)) ctx.fail("unexpressible-value", "Box.style must be a plain object", "@style");
|
|
19
|
+
const parsed = boxStyleSchema.safeParse(style);
|
|
20
|
+
if (!parsed.success) {
|
|
21
|
+
const issue = parsed.error.issues[0];
|
|
22
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
23
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Box.style cannot be expressed", issuePath);
|
|
24
|
+
}
|
|
25
|
+
const entries = [];
|
|
26
|
+
for (const [key, entryValue] of Object.entries(style)) {
|
|
27
|
+
if (entryValue === void 0) continue;
|
|
28
|
+
if (key === "background") {
|
|
29
|
+
const serializedImage = serializeImageDescriptorValue(entryValue, ctx);
|
|
30
|
+
entries.push([key, serializedImage ?? entryValue]);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
entries.push([key, entryValue]);
|
|
34
|
+
}
|
|
35
|
+
return expr(ctx.formatProps(entries));
|
|
36
|
+
}
|
|
37
|
+
function collectBoxProps(node, ctx) {
|
|
38
|
+
const props = readInternalDeclarationProps(node);
|
|
39
|
+
const extra = ctx.emitObjectExtraProps(props);
|
|
40
|
+
const entries = [];
|
|
41
|
+
for (const [key, value] of Object.entries(props)) {
|
|
42
|
+
if (value === void 0) continue;
|
|
43
|
+
if (!boxAllowedPropKeys.has(key)) ctx.fail("invalid-document", `box declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
44
|
+
if (key === "style") {
|
|
45
|
+
entries.push([key, serializeBoxStyleProp(value, ctx)]);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (objectMotionPropKeys.has(key)) {
|
|
49
|
+
if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
|
|
50
|
+
else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
entries.push([key, value]);
|
|
54
|
+
}
|
|
55
|
+
return entries;
|
|
56
|
+
}
|
|
57
|
+
function emitBoxChildren(node, ctx) {
|
|
58
|
+
const children = [];
|
|
59
|
+
let childIndex = 0;
|
|
60
|
+
for (const child of node.children) if (child instanceof CommonNode) {
|
|
61
|
+
children.push(ctx.emitChildNode(child, childIndex));
|
|
62
|
+
childIndex += 1;
|
|
63
|
+
} else if ("text" in child && typeof child.text === "string" && child.text.trim() !== "") ctx.fail("invalid-document", "Box cannot directly contain text content");
|
|
64
|
+
return children;
|
|
65
|
+
}
|
|
66
|
+
function emitBoxVanilla(node, ctx) {
|
|
67
|
+
const callee = ctx.useImport("box");
|
|
68
|
+
const propsEntries = collectBoxProps(node, ctx);
|
|
69
|
+
const args = propsEntries.length === 0 ? [] : [ctx.formatProps(propsEntries)];
|
|
70
|
+
const children = emitBoxChildren(node, ctx);
|
|
71
|
+
return ctx.formatVanillaCall(callee, args, children);
|
|
72
|
+
}
|
|
73
|
+
function emitBoxReact(node, ctx) {
|
|
74
|
+
const tag = ctx.useImport("Box");
|
|
75
|
+
const propsEntries = collectBoxProps(node, ctx);
|
|
76
|
+
const children = emitBoxChildren(node, ctx);
|
|
77
|
+
return ctx.formatJsxElement(tag, propsEntries, children);
|
|
78
|
+
}
|
|
79
|
+
/** Source codegen contribution for `box` layout container declarations. */
|
|
80
|
+
const boxCodegen = defineObjectCodegen({ declarations: { box: {
|
|
81
|
+
emitVanilla: emitBoxVanilla,
|
|
82
|
+
emitReact: emitBoxReact
|
|
83
|
+
} } });
|
|
84
|
+
export { boxCodegen };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { authorIdSchema } from "../../../core/dist/author-ids.js";
|
|
2
|
+
import { layoutStyleShape } from "../../../core/dist/layout-schemas.js";
|
|
3
|
+
import { textStyleShape, visualStyleShape } 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 { motionPropsShape } from "../motion/motion-schemas.js";
|
|
8
|
+
import { morphKeySchema } from "../shared/morph-api.js";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
// ../capabilities/dist/box/box-declaration.js
|
|
11
|
+
const boxStyleObjectSchema = z.strictObject({
|
|
12
|
+
...layoutStyleShape,
|
|
13
|
+
...textStyleShape,
|
|
14
|
+
...visualStyleShape
|
|
15
|
+
});
|
|
16
|
+
const boxStyleKeys = Object.keys(boxStyleObjectSchema.shape);
|
|
17
|
+
const rawBoxStyleSchema = boxStyleObjectSchema.readonly();
|
|
18
|
+
const boxStyleSchema = rawBoxStyleSchema;
|
|
19
|
+
const boxDeclarationPropsObjectSchema = z.strictObject({
|
|
20
|
+
id: authorIdSchema.optional(),
|
|
21
|
+
morphKey: morphKeySchema.optional(),
|
|
22
|
+
link: linkTargetSchema.optional(),
|
|
23
|
+
style: rawBoxStyleSchema.optional(),
|
|
24
|
+
...motionPropsShape
|
|
25
|
+
});
|
|
26
|
+
const boxDeclarationPropsKeys = Object.keys(boxDeclarationPropsObjectSchema.shape);
|
|
27
|
+
boxDeclarationPropsObjectSchema.readonly();
|
|
28
|
+
/** Creates the editable layout container shared by the command factory and the Box JSX element. */
|
|
29
|
+
function createBoxNode(props) {
|
|
30
|
+
return new CommonContainer("box", "box", props);
|
|
31
|
+
}
|
|
32
|
+
export { boxDeclarationPropsKeys, boxStyleKeys, 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,142 @@
|
|
|
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, pickMotionProps, validateMotionFlag } from "../motion/motion-api.js";
|
|
9
|
+
import { nativeLinkXml, parseMorphKey } from "../shared/identity.js";
|
|
10
|
+
import { assertVisualBoxExtent, emitVisualModel, hasVisibleBoxStyle, paintVisualModel, resolveVisualModel } from "../shared/visual.js";
|
|
11
|
+
import { boxCodegen } from "./box-codegen.js";
|
|
12
|
+
import { boxDeclarationPropsKeys, boxStyleKeys } from "./box-declaration.js";
|
|
13
|
+
// ../capabilities/dist/box/box.js
|
|
14
|
+
const boxAllowedParameters = boxDeclarationPropsKeys;
|
|
15
|
+
const boxAllowedStyleKeys = new Set(boxStyleKeys);
|
|
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(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 = pickMotionProps(input.props);
|
|
59
|
+
const container = {
|
|
60
|
+
children: input.children,
|
|
61
|
+
theme,
|
|
62
|
+
emitsObject: hasVisibleStyle,
|
|
63
|
+
observesLayout: true,
|
|
64
|
+
propagatesBaseline: true
|
|
65
|
+
};
|
|
66
|
+
const native = {
|
|
67
|
+
...morphKey === void 0 ? {} : { morphKey },
|
|
68
|
+
...link === void 0 ? {} : { link }
|
|
69
|
+
};
|
|
70
|
+
return {
|
|
71
|
+
contract,
|
|
72
|
+
container,
|
|
73
|
+
...morphKey !== void 0 || link !== void 0 ? { native } : {},
|
|
74
|
+
resolve(resolveContext) {
|
|
75
|
+
const box = resolveContext.layoutBox;
|
|
76
|
+
if (box === void 0) throw new CapabilityError("layout-unavailable", "Box is missing layout results");
|
|
77
|
+
const name = resolveContext.morphName ?? `Box ${resolveContext.id - 1}`;
|
|
78
|
+
let escapedName;
|
|
79
|
+
try {
|
|
80
|
+
escapedName = xmlEscape(name);
|
|
81
|
+
} catch {
|
|
82
|
+
throw new CapabilityError("invalid-xml-character", "Box.name contains characters not allowed in XML 1.0");
|
|
83
|
+
}
|
|
84
|
+
const visual = resolveVisualModel({
|
|
85
|
+
theme: resolveContext.theme,
|
|
86
|
+
style,
|
|
87
|
+
box,
|
|
88
|
+
layoutOnlyWhenInvisible: true
|
|
89
|
+
});
|
|
90
|
+
if (visual.hasVisibleStyle) assertVisualBoxExtent(box);
|
|
91
|
+
const geometryName = visual.geometry.kind === "custom" ? "custom" : visual.geometry.name;
|
|
92
|
+
const motionTarget = {
|
|
93
|
+
kind: "shape",
|
|
94
|
+
name,
|
|
95
|
+
...authorId === void 0 ? {} : { authorId },
|
|
96
|
+
textBody: false,
|
|
97
|
+
filled: visual.fill.kind !== "none"
|
|
98
|
+
};
|
|
99
|
+
const annotations = motionContainerAnnotations(motionProps, visual.hasVisibleStyle ? motionTarget : void 0, {
|
|
100
|
+
propagatesDefaultEnter: true,
|
|
101
|
+
groupsAsParallelUnit: true
|
|
102
|
+
});
|
|
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
|
+
emit(emitContext) {
|
|
121
|
+
return { xml: visual.hasVisibleStyle ? objectXml(emitContext.id, escapedName, emitVisualModel(visual, (resource) => emitContext.registerResource(resource)).xml, nativeLinkXml(emitContext.nativeLink)) : "" };
|
|
122
|
+
},
|
|
123
|
+
paint(paintContext) {
|
|
124
|
+
const childrenSvg = paintContext.childrenSvg ?? "";
|
|
125
|
+
if (!visual.hasVisibleStyle) return { svg: childrenSvg };
|
|
126
|
+
const background = paintVisualModel({
|
|
127
|
+
model: visual,
|
|
128
|
+
slideNumber: paintContext.slideNumber,
|
|
129
|
+
objectId: paintContext.objectId,
|
|
130
|
+
...paintContext.registerRasterResource === void 0 ? {} : { registerRasterResource: paintContext.registerRasterResource }
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
svg: `${background.svg}${childrenSvg}`,
|
|
134
|
+
...background.placeholders === void 0 ? {} : { placeholders: background.placeholders }
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
export { boxCapability };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../../core/dist/document-internals.js";
|
|
2
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
3
|
+
import "../../../codegen/dist/index.js";
|
|
4
|
+
import "../../../core/dist/capability.js";
|
|
5
|
+
import "../../../core/dist/document.js";
|
|
6
|
+
import { defineObjectCodegen } from "../../../codegen/dist/types.js";
|
|
7
|
+
import { motionPropKeySet } from "../motion/motion-schemas.js";
|
|
8
|
+
import { chartAllowedPropKeys, chartAxesSchema, chartDisplayBlanksAsSchema, chartLegendSchema, chartPlotAreaSchema, chartStyleSchema, chartTitleSchema, parseChartGroupBySchema } from "./chart-schemas.js";
|
|
9
|
+
// ../capabilities/dist/chart/chart-codegen.js
|
|
10
|
+
const chartAllowedPropKeySet = new Set(chartAllowedPropKeys);
|
|
11
|
+
const objectMotionPropKeys = motionPropKeySet;
|
|
12
|
+
function isPlainRecord(value) {
|
|
13
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
14
|
+
const proto = Object.getPrototypeOf(value);
|
|
15
|
+
return proto === Object.prototype || proto === null;
|
|
16
|
+
}
|
|
17
|
+
function validatePropWithSchema(schema, value, propKey, ctx) {
|
|
18
|
+
if (value === void 0) return;
|
|
19
|
+
const parsed = schema.safeParse(value);
|
|
20
|
+
if (!parsed.success) {
|
|
21
|
+
const issue = parsed.error.issues[0];
|
|
22
|
+
ctx.fail("unexpressible-value", issue?.message ?? `Chart.${propKey} cannot be expressed`, `@${propKey}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function validateChartStructure(props, ctx) {
|
|
26
|
+
const rawGroups = props["groups"];
|
|
27
|
+
if (!Array.isArray(rawGroups) || rawGroups.length === 0) ctx.fail("unexpressible-value", "Chart.groups must be a non-empty array", "@groups");
|
|
28
|
+
for (const [index, rawGroup] of rawGroups.entries()) try {
|
|
29
|
+
parseChartGroupBySchema(rawGroup, `Chart.groups[${index}]`);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
const message = error instanceof CapabilityError ? error.message : `Chart.groups[${index}] is invalid`;
|
|
32
|
+
ctx.fail("unexpressible-value", message, `@groups[${index}]`);
|
|
33
|
+
}
|
|
34
|
+
const nativePh = props["nativePlaceholder"];
|
|
35
|
+
if (isPlainRecord(nativePh) && Object.hasOwn(nativePh, "sz") && nativePh["sz"] !== void 0) ctx.fail("unexpressible-value", "Chart.nativePlaceholder.sz is no longer supported; use size", "@nativePlaceholder.sz");
|
|
36
|
+
validatePropWithSchema(chartAxesSchema, props["axes"], "axes", ctx);
|
|
37
|
+
validatePropWithSchema(chartTitleSchema, props["title"], "title", ctx);
|
|
38
|
+
validatePropWithSchema(chartDisplayBlanksAsSchema, props["displayBlanksAs"], "displayBlanksAs", ctx);
|
|
39
|
+
validatePropWithSchema(chartLegendSchema, props["legend"], "legend", ctx);
|
|
40
|
+
validatePropWithSchema(chartPlotAreaSchema, props["plotArea"], "plotArea", ctx);
|
|
41
|
+
validatePropWithSchema(chartStyleSchema, props["style"], "style", ctx);
|
|
42
|
+
}
|
|
43
|
+
function collectChartProps(node, ctx) {
|
|
44
|
+
if (node.children.length > 0) ctx.fail("invalid-document", "Chart declaration cannot have children");
|
|
45
|
+
const props = readInternalDeclarationProps(node);
|
|
46
|
+
const extra = ctx.emitObjectExtraProps(props);
|
|
47
|
+
const entries = [];
|
|
48
|
+
for (const [key, value] of Object.entries(props)) {
|
|
49
|
+
if (value === void 0) continue;
|
|
50
|
+
if (!chartAllowedPropKeySet.has(key)) ctx.fail("invalid-document", `chart declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
51
|
+
if (objectMotionPropKeys.has(key)) {
|
|
52
|
+
if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
|
|
53
|
+
else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
entries.push([key, value]);
|
|
57
|
+
}
|
|
58
|
+
return entries;
|
|
59
|
+
}
|
|
60
|
+
function emitChartVanilla(node, ctx) {
|
|
61
|
+
const callee = ctx.useImport("chart");
|
|
62
|
+
const propsEntries = collectChartProps(node, ctx);
|
|
63
|
+
const formattedProps = ctx.formatProps(propsEntries);
|
|
64
|
+
validateChartStructure(readInternalDeclarationProps(node), ctx);
|
|
65
|
+
return ctx.formatVanillaCall(callee, [formattedProps]);
|
|
66
|
+
}
|
|
67
|
+
function emitChartReact(node, ctx) {
|
|
68
|
+
const tag = ctx.useImport("Chart");
|
|
69
|
+
const propsEntries = collectChartProps(node, ctx);
|
|
70
|
+
const jsx = ctx.formatJsxElement(tag, propsEntries, []);
|
|
71
|
+
validateChartStructure(readInternalDeclarationProps(node), ctx);
|
|
72
|
+
return jsx;
|
|
73
|
+
}
|
|
74
|
+
/** Source codegen contribution for `chart` (`chart(props)` / `<Chart {...props} />`) declarations. */
|
|
75
|
+
const chartCodegen = defineObjectCodegen({ declarations: { chart: {
|
|
76
|
+
emitVanilla: emitChartVanilla,
|
|
77
|
+
emitReact: emitChartReact
|
|
78
|
+
} } });
|
|
79
|
+
export { chartCodegen };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommonNode } from "../../../core/dist/document.js";
|
|
2
|
+
// ../capabilities/dist/chart/chart-declaration.js
|
|
3
|
+
/** Creates the editable native chart shared by the command factory and the Chart JSX element. */
|
|
4
|
+
function createChartNode(props) {
|
|
5
|
+
return new CommonNode("chart", "chart", props);
|
|
6
|
+
}
|
|
7
|
+
export { createChartNode };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { hostNodeCreator } from "../../../core/dist/host.js";
|
|
2
|
+
import { motionElement } from "../motion/motion-elements.js";
|
|
3
|
+
import { createChartNode } from "./chart-declaration.js";
|
|
4
|
+
// ../capabilities/dist/chart/chart-elements.js
|
|
5
|
+
/** Declares an object compiled into a native chart by the official capability module. */
|
|
6
|
+
function Chart(props) {
|
|
7
|
+
return motionElement("chart", {
|
|
8
|
+
...props,
|
|
9
|
+
[hostNodeCreator]: createChartNode
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
export { Chart };
|