@officedk/pptxdk 0.2.0 → 0.2.1
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/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { expr } from "../../kernel/codegen.js";
|
|
2
|
+
// ../core/dist/capabilities/shared/geometry-codegen.js
|
|
3
|
+
function isRecord(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
function formatSvgNumber(value, ctx, propPath) {
|
|
7
|
+
if (typeof value !== "number" || !Number.isFinite(value)) ctx.fail("unexpressible-value", `Non-finite geometry coordinate ${String(value)} cannot be expressed in source`, propPath);
|
|
8
|
+
return Object.is(value, -0) ? "0" : String(value);
|
|
9
|
+
}
|
|
10
|
+
function commandsToSvgPath(commands, ctx, basePath) {
|
|
11
|
+
if (commands.length === 0) return void 0;
|
|
12
|
+
const segments = [];
|
|
13
|
+
for (let index = 0; index < commands.length; index += 1) {
|
|
14
|
+
const command = commands[index];
|
|
15
|
+
if (!isRecord(command) || typeof command["op"] !== "string") return;
|
|
16
|
+
const cmdPath = `${basePath}.commands[${index}]`;
|
|
17
|
+
switch (command["op"]) {
|
|
18
|
+
case "M":
|
|
19
|
+
case "L": {
|
|
20
|
+
if (index === 0 && command["op"] !== "M") return void 0;
|
|
21
|
+
const x = formatSvgNumber(command["x"], ctx, `${cmdPath}.x`);
|
|
22
|
+
const y = formatSvgNumber(command["y"], ctx, `${cmdPath}.y`);
|
|
23
|
+
segments.push(`${command["op"]} ${x} ${y}`);
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
case "C": {
|
|
27
|
+
if (index === 0) return void 0;
|
|
28
|
+
const x1 = formatSvgNumber(command["x1"], ctx, `${cmdPath}.x1`);
|
|
29
|
+
const y1 = formatSvgNumber(command["y1"], ctx, `${cmdPath}.y1`);
|
|
30
|
+
const x2 = formatSvgNumber(command["x2"], ctx, `${cmdPath}.x2`);
|
|
31
|
+
const y2 = formatSvgNumber(command["y2"], ctx, `${cmdPath}.y2`);
|
|
32
|
+
const x = formatSvgNumber(command["x"], ctx, `${cmdPath}.x`);
|
|
33
|
+
const y = formatSvgNumber(command["y"], ctx, `${cmdPath}.y`);
|
|
34
|
+
segments.push(`C ${x1} ${y1} ${x2} ${y2} ${x} ${y}`);
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
case "Q": {
|
|
38
|
+
if (index === 0) return void 0;
|
|
39
|
+
const x1 = formatSvgNumber(command["x1"], ctx, `${cmdPath}.x1`);
|
|
40
|
+
const y1 = formatSvgNumber(command["y1"], ctx, `${cmdPath}.y1`);
|
|
41
|
+
const x = formatSvgNumber(command["x"], ctx, `${cmdPath}.x`);
|
|
42
|
+
const y = formatSvgNumber(command["y"], ctx, `${cmdPath}.y`);
|
|
43
|
+
segments.push(`Q ${x1} ${y1} ${x} ${y}`);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "Z":
|
|
47
|
+
if (index === 0) return void 0;
|
|
48
|
+
segments.push("Z");
|
|
49
|
+
break;
|
|
50
|
+
default: return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return segments.join(" ");
|
|
54
|
+
}
|
|
55
|
+
function trySerializeCustomAsPath(value, ctx) {
|
|
56
|
+
if (value["connectionSites"] !== void 0) return;
|
|
57
|
+
const width = value["width"];
|
|
58
|
+
const height = value["height"];
|
|
59
|
+
const paths = value["paths"];
|
|
60
|
+
if (typeof width !== "number" || !Number.isFinite(width) || width <= 0 || typeof height !== "number" || !Number.isFinite(height) || height <= 0 || !Array.isArray(paths) || paths.length === 0) return;
|
|
61
|
+
const firstPath = paths[0];
|
|
62
|
+
if (!isRecord(firstPath)) return void 0;
|
|
63
|
+
const uniformFill = firstPath["fill"];
|
|
64
|
+
const uniformStroke = firstPath["stroke"];
|
|
65
|
+
const svgStrings = [];
|
|
66
|
+
for (let index = 0; index < paths.length; index += 1) {
|
|
67
|
+
const entry = paths[index];
|
|
68
|
+
if (!isRecord(entry) || !Array.isArray(entry["commands"])) return;
|
|
69
|
+
if (entry["fill"] !== uniformFill || entry["stroke"] !== uniformStroke) return;
|
|
70
|
+
const svg = commandsToSvgPath(entry["commands"], ctx, `@geometry.paths[${index}]`);
|
|
71
|
+
if (svg === void 0) return void 0;
|
|
72
|
+
svgStrings.push(svg);
|
|
73
|
+
}
|
|
74
|
+
const pathFn = ctx.useImport("path");
|
|
75
|
+
const dataExpr = svgStrings.length === 1 ? JSON.stringify(svgStrings[0]) : ctx.emitValueExpr(svgStrings, "@geometry.paths");
|
|
76
|
+
const optionsObj = {
|
|
77
|
+
viewBox: [width, height],
|
|
78
|
+
...uniformFill === void 0 ? {} : { fill: uniformFill },
|
|
79
|
+
...uniformStroke === void 0 ? {} : { stroke: uniformStroke }
|
|
80
|
+
};
|
|
81
|
+
return expr(`${pathFn}(${dataExpr}, ${ctx.emitValueExpr(optionsObj, "@geometry")})`);
|
|
82
|
+
}
|
|
83
|
+
function serializeGeometryProp(value, ctx) {
|
|
84
|
+
if (typeof value === "string") return value;
|
|
85
|
+
if (!isRecord(value)) return expr(ctx.emitValueExpr(value, "@geometry"));
|
|
86
|
+
if (value["type"] === "preset" && typeof value["name"] === "string") {
|
|
87
|
+
const presetFn = ctx.useImport("preset");
|
|
88
|
+
const adjust = value["adjust"];
|
|
89
|
+
if (adjust !== void 0) {
|
|
90
|
+
if (!isRecord(adjust)) ctx.fail("unexpressible-value", "Preset geometry adjust must be a plain record", "@geometry.adjust");
|
|
91
|
+
if (Object.entries(adjust).filter(([, entryValue]) => entryValue !== void 0).length > 0) return expr(`${presetFn}(${JSON.stringify(value["name"])}, ${ctx.emitValueExpr(adjust, "@geometry.adjust")})`);
|
|
92
|
+
}
|
|
93
|
+
return expr(`${presetFn}(${JSON.stringify(value["name"])})`);
|
|
94
|
+
}
|
|
95
|
+
if (value["type"] === "custom") {
|
|
96
|
+
const asPath = trySerializeCustomAsPath(value, ctx);
|
|
97
|
+
if (asPath !== void 0) return asPath;
|
|
98
|
+
}
|
|
99
|
+
return expr(ctx.emitValueExpr(value, "@geometry"));
|
|
100
|
+
}
|
|
101
|
+
export { serializeGeometryProp };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import {
|
|
3
|
-
import "
|
|
4
|
-
import
|
|
5
|
-
import "
|
|
6
|
-
import { A_NS
|
|
7
|
-
import { ooxmlBoolSchema, ooxmlIntSchema, ooxmlPositiveIntSchema } from "
|
|
8
|
-
import "
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { emuToPx, pxToEmu } from "../../kernel/drawing-units.js";
|
|
3
|
+
import { customGeometrySchema, geometryAdjustKeySchema, geometryAdjustSchema, geometrySchema, presetGeometryNameSchema, presetGeometryTuple } from "../../kernel/geometry-schemas.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import "../../kernel/pptx-read/index.js";
|
|
6
|
+
import { A_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
7
|
+
import { ooxmlBoolSchema, ooxmlIntSchema, ooxmlPositiveIntSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
8
|
+
import "../../kernel/pptx-write/xml.js";
|
|
9
9
|
import { presetDefinitions } from "./preset-definitions.js";
|
|
10
10
|
import { z } from "zod";
|
|
11
|
-
// ../
|
|
11
|
+
// ../core/dist/capabilities/shared/geometry.js
|
|
12
12
|
const STANDARD_CARDINAL_CXN = [
|
|
13
13
|
["hc", "t"],
|
|
14
14
|
["l", "vc"],
|
|
@@ -68,8 +68,8 @@ function getGeometryConnectionSiteCount(geometry) {
|
|
|
68
68
|
}
|
|
69
69
|
/** Complete DrawingML preset geometry enumeration from ECMA-376 ST_ShapeType. */
|
|
70
70
|
const presetGeometryNames = new Set(presetGeometryTuple);
|
|
71
|
-
function invalidGeometry(message) {
|
|
72
|
-
throw new CapabilityError("invalid-geometry", message);
|
|
71
|
+
function invalidGeometry(message, field = "geometry") {
|
|
72
|
+
throw new CapabilityError("invalid-geometry", message, void 0, { field });
|
|
73
73
|
}
|
|
74
74
|
function preset(name, adjust) {
|
|
75
75
|
if (!presetGeometryNameSchema.safeParse(name).success) throw new CapabilityError("unsupported-geometry", `Unsupported preset geometry ${String(name)}`);
|
|
@@ -560,7 +560,7 @@ function isRecord(value) {
|
|
|
560
560
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
561
561
|
}
|
|
562
562
|
function finiteGeometryNumber(value, label) {
|
|
563
|
-
if (typeof value !== "number" || !Number.isFinite(value)) throw new CapabilityError("invalid-visual-style", `${label} must be a finite number
|
|
563
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new CapabilityError("invalid-visual-style", `${label} must be a finite number`, void 0, { field: label });
|
|
564
564
|
return value;
|
|
565
565
|
}
|
|
566
566
|
/** Checks whether a path coordinate in point units (`value * 1000`) stays within DrawingML signed 32-bit bounds excluding `-2^31`. */
|
|
@@ -582,34 +582,35 @@ function arePathCommandsBounded(commands) {
|
|
|
582
582
|
case "L": return isValidPathUnit(cmd.x) && isValidPathUnit(cmd.y);
|
|
583
583
|
case "Q": return isValidPathUnit(cmd.x1) && isValidPathUnit(cmd.y1) && isValidPathUnit(cmd.x) && isValidPathUnit(cmd.y);
|
|
584
584
|
case "C": return isValidPathUnit(cmd.x1) && isValidPathUnit(cmd.y1) && isValidPathUnit(cmd.x2) && isValidPathUnit(cmd.y2) && isValidPathUnit(cmd.x) && isValidPathUnit(cmd.y);
|
|
585
|
+
default: return false;
|
|
585
586
|
}
|
|
586
587
|
});
|
|
587
588
|
}
|
|
588
589
|
function pointUnit(value, label) {
|
|
589
590
|
const coordinate = Math.round(finiteGeometryNumber(value, label) * 1e3);
|
|
590
|
-
if (!Number.isSafeInteger(coordinate) || Math.abs(coordinate) > 2147483647) invalidGeometry(`${label} exceeds DrawingML path coordinate range after conversion
|
|
591
|
+
if (!Number.isSafeInteger(coordinate) || Math.abs(coordinate) > 2147483647) invalidGeometry(`${label} exceeds DrawingML path coordinate range after conversion`, label);
|
|
591
592
|
return String(coordinate);
|
|
592
593
|
}
|
|
593
|
-
function validatePathCommand(command) {
|
|
594
|
+
function validatePathCommand(command, field) {
|
|
594
595
|
switch (command.op) {
|
|
595
596
|
case "M":
|
|
596
597
|
case "L":
|
|
597
|
-
pointUnit(command.x,
|
|
598
|
-
pointUnit(command.y,
|
|
598
|
+
pointUnit(command.x, `${field}.x`);
|
|
599
|
+
pointUnit(command.y, `${field}.y`);
|
|
599
600
|
return;
|
|
600
601
|
case "C":
|
|
601
|
-
pointUnit(command.x1,
|
|
602
|
-
pointUnit(command.y1,
|
|
603
|
-
pointUnit(command.x2,
|
|
604
|
-
pointUnit(command.y2,
|
|
605
|
-
pointUnit(command.x,
|
|
606
|
-
pointUnit(command.y,
|
|
602
|
+
pointUnit(command.x1, `${field}.x1`);
|
|
603
|
+
pointUnit(command.y1, `${field}.y1`);
|
|
604
|
+
pointUnit(command.x2, `${field}.x2`);
|
|
605
|
+
pointUnit(command.y2, `${field}.y2`);
|
|
606
|
+
pointUnit(command.x, `${field}.x`);
|
|
607
|
+
pointUnit(command.y, `${field}.y`);
|
|
607
608
|
return;
|
|
608
609
|
case "Q":
|
|
609
|
-
pointUnit(command.x1,
|
|
610
|
-
pointUnit(command.y1,
|
|
611
|
-
pointUnit(command.x,
|
|
612
|
-
pointUnit(command.y,
|
|
610
|
+
pointUnit(command.x1, `${field}.x1`);
|
|
611
|
+
pointUnit(command.y1, `${field}.y1`);
|
|
612
|
+
pointUnit(command.x, `${field}.x`);
|
|
613
|
+
pointUnit(command.y, `${field}.y`);
|
|
613
614
|
return;
|
|
614
615
|
case "Z": return;
|
|
615
616
|
default: invalidGeometry("Custom path contains unsupported command");
|
|
@@ -623,27 +624,25 @@ function resolveGeometry(options) {
|
|
|
623
624
|
const parsedCustom = customGeometrySchema.safeParse(value);
|
|
624
625
|
if (!parsedCustom.success) {
|
|
625
626
|
const issue = parsedCustom.error.issues[0];
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
invalidGeometry(issue?.message ?? "Custom geometry must have a positive viewBox and at least one path");
|
|
627
|
+
const dimension = issue?.path[0];
|
|
628
|
+
if (dimension === "width" || dimension === "height") finiteGeometryNumber(value[dimension], `geometry.${dimension}`);
|
|
629
|
+
invalidGeometry(issue?.message ?? "Invalid custom geometry", zodIssueField(issue, "geometry"));
|
|
631
630
|
}
|
|
632
631
|
const custom = parsedCustom.data;
|
|
633
632
|
const widthUnits = pointUnit(custom.width, "geometry.width");
|
|
634
633
|
const heightUnits = pointUnit(custom.height, "geometry.height");
|
|
635
|
-
if (Number(widthUnits) === 0 || Number(heightUnits) === 0) invalidGeometry("Custom geometry viewBox must retain positive width and height in path coordinate space after conversion");
|
|
636
|
-
const resolvedPaths = custom.paths.map((item) => {
|
|
637
|
-
for (const command of item.commands) validatePathCommand(command);
|
|
634
|
+
if (Number(widthUnits) === 0 || Number(heightUnits) === 0) invalidGeometry("Custom geometry viewBox must retain positive width and height in path coordinate space after conversion", Number(widthUnits) === 0 ? "geometry.width" : "geometry.height");
|
|
635
|
+
const resolvedPaths = custom.paths.map((item, pathIndex) => {
|
|
636
|
+
for (const [commandIndex, command] of item.commands.entries()) validatePathCommand(command, `geometry.paths.${pathIndex}.commands.${commandIndex}`);
|
|
638
637
|
return {
|
|
639
638
|
commands: item.commands,
|
|
640
639
|
fill: item.fill ?? true,
|
|
641
640
|
stroke: item.stroke ?? true
|
|
642
641
|
};
|
|
643
642
|
});
|
|
644
|
-
const resolvedSites = custom.connectionSites?.map((site) => {
|
|
645
|
-
pointUnit(site.x,
|
|
646
|
-
pointUnit(site.y,
|
|
643
|
+
const resolvedSites = custom.connectionSites?.map((site, index) => {
|
|
644
|
+
pointUnit(site.x, `geometry.connectionSites.${index}.x`);
|
|
645
|
+
pointUnit(site.y, `geometry.connectionSites.${index}.y`);
|
|
647
646
|
return {
|
|
648
647
|
x: site.x,
|
|
649
648
|
y: site.y
|
|
@@ -664,17 +663,18 @@ function resolveGeometry(options) {
|
|
|
664
663
|
const adjust = {};
|
|
665
664
|
if (value === void 0) rawName = radius !== void 0 && radius > 0 ? "roundRect" : "rect";
|
|
666
665
|
else if (typeof value === "string") rawName = value;
|
|
667
|
-
else if (isRecord(value) && value["type"] === "preset"
|
|
666
|
+
else if (isRecord(value) && value["type"] === "preset") {
|
|
667
|
+
if (typeof value["name"] !== "string") invalidGeometry("preset.name must be a preset geometry name", "geometry.name");
|
|
668
668
|
rawName = value["name"];
|
|
669
669
|
if (value["adjust"] !== void 0) {
|
|
670
|
-
if (!isRecord(value["adjust"])) invalidGeometry("preset.adjust must be an object");
|
|
670
|
+
if (!isRecord(value["adjust"])) invalidGeometry("preset.adjust must be an object", "geometry.adjust");
|
|
671
671
|
const parsedAdjust = geometryAdjustSchema.safeParse(value["adjust"]);
|
|
672
|
-
if (!parsedAdjust.success) invalidGeometry(`preset.adjust.${String(parsedAdjust.error.issues[0]?.path[0] ?? "adjust")} must be a finite integer
|
|
672
|
+
if (!parsedAdjust.success) invalidGeometry(`preset.adjust.${String(parsedAdjust.error.issues[0]?.path[0] ?? "adjust")} must be a finite integer`, zodIssueField(parsedAdjust.error.issues[0], "geometry.adjust"));
|
|
673
673
|
Object.assign(adjust, parsedAdjust.data);
|
|
674
674
|
}
|
|
675
|
-
} else invalidGeometry("geometry must be a preset name, preset(...), or custom path");
|
|
675
|
+
} else invalidGeometry("geometry must be a preset name, preset(...), or custom path", isRecord(value) ? "geometry.type" : "geometry");
|
|
676
676
|
const parsedPresetName = presetGeometryNameSchema.safeParse(rawName);
|
|
677
|
-
if (!parsedPresetName.success) throw new CapabilityError("unsupported-geometry", `Unsupported preset geometry ${rawName}
|
|
677
|
+
if (!parsedPresetName.success) throw new CapabilityError("unsupported-geometry", `Unsupported preset geometry ${rawName}`, void 0, { field: typeof value === "string" ? "geometry" : "geometry.name" });
|
|
678
678
|
let name = parsedPresetName.data;
|
|
679
679
|
if (radius !== void 0 && radius > 0) {
|
|
680
680
|
if (name !== "rect" && name !== "roundRect") throw new CapabilityError("unsupported-style-combination", "borderRadius is only applicable to rect or roundRect geometry");
|
|
@@ -727,8 +727,8 @@ function resolvedGeometryXml(geometry) {
|
|
|
727
727
|
}).join("");
|
|
728
728
|
const sites = geometry.connectionSites ?? [];
|
|
729
729
|
return `<a:custGeom><a:avLst/>${sites.length === 0 ? "<a:gdLst/>" : `<a:gdLst>${sites.map((site, index) => {
|
|
730
|
-
const xUnits = pointUnit(site.x,
|
|
731
|
-
const yUnits = pointUnit(site.y,
|
|
730
|
+
const xUnits = pointUnit(site.x, `geometry.connectionSites.${index}.x`);
|
|
731
|
+
const yUnits = pointUnit(site.y, `geometry.connectionSites.${index}.y`);
|
|
732
732
|
return `<a:gd name="cxnX${index}" fmla="*/ ${xUnits} w ${widthUnits}"/><a:gd name="cxnY${index}" fmla="*/ ${yUnits} h ${heightUnits}"/>`;
|
|
733
733
|
}).join("")}</a:gdLst>`}<a:ahLst/>${sites.length === 0 ? "<a:cxnLst/>" : `<a:cxnLst>${sites.map((_site, index) => `<a:cxn ang="0"><a:pos x="cxnX${index}" y="cxnY${index}"/></a:cxn>`).join("")}</a:cxnLst>`}<a:rect l="l" t="t" r="r" b="b"/><a:pathLst>${pathList}</a:pathLst></a:custGeom>`;
|
|
734
734
|
}
|
|
@@ -1009,6 +1009,7 @@ function evaluatePresetGeometry(name, adjust, box) {
|
|
|
1009
1009
|
x: toPageX(cmd.x),
|
|
1010
1010
|
y: toPageY(cmd.y)
|
|
1011
1011
|
};
|
|
1012
|
+
default: return cmd;
|
|
1012
1013
|
}
|
|
1013
1014
|
};
|
|
1014
1015
|
const commands = [];
|
|
@@ -1084,6 +1085,8 @@ function evaluatePresetGeometry(name, adjust, box) {
|
|
|
1084
1085
|
curX = subStartX;
|
|
1085
1086
|
curY = subStartY;
|
|
1086
1087
|
commands.push({ op: "Z" });
|
|
1088
|
+
break;
|
|
1089
|
+
default: invalidGeometry(`Preset ${name} contains unsupported path command ${String(cmd[0])}`);
|
|
1087
1090
|
}
|
|
1088
1091
|
return {
|
|
1089
1092
|
d: commandsToSvgD(commands),
|
|
@@ -1,41 +1,16 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import { isMorphKey } from "
|
|
3
|
-
import { parseLinkTarget } from "
|
|
4
|
-
import "
|
|
5
|
-
import
|
|
6
|
-
import "
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import "../../../import/dist/index.js";
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { isMorphKey } from "../../kernel/morph.js";
|
|
3
|
+
import { parseLinkTarget } from "../../kernel/author-schemas.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import "../../kernel/pptx-read/index.js";
|
|
6
|
+
import { A_NS, P_NS, REL_HYPERLINK, R_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
7
|
+
import { resolvePartPath } from "../../kernel/pptx-read/opc.js";
|
|
8
|
+
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
9
|
+
import { resolveExternalRelationshipTarget } from "../../kernel/pptx-read/resources.js";
|
|
10
|
+
import { xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
12
11
|
import { z } from "zod";
|
|
13
|
-
// ../
|
|
12
|
+
// ../core/dist/capabilities/shared/identity.js
|
|
14
13
|
const NvPrUserDrawnSchema = z.object({ userDrawn: ooxmlBoolSchema.optional() });
|
|
15
|
-
function directChildDom(parent, namespaceUri, localName) {
|
|
16
|
-
for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
|
|
17
|
-
if (child.nodeType !== 1) continue;
|
|
18
|
-
const el = child;
|
|
19
|
-
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Side-effect-free check for `<p:ph>` inside an object's `<p:nvPr>`. */
|
|
23
|
-
function hasPlaceholderElement(cursor) {
|
|
24
|
-
for (const wrapperName of [
|
|
25
|
-
"nvSpPr",
|
|
26
|
-
"nvPicPr",
|
|
27
|
-
"nvGrpSpPr",
|
|
28
|
-
"nvGraphicFramePr",
|
|
29
|
-
"nvCxnSpPr"
|
|
30
|
-
]) {
|
|
31
|
-
const wrapper = directChildDom(cursor.element, P_NS, wrapperName);
|
|
32
|
-
if (wrapper === void 0) continue;
|
|
33
|
-
const nvPr = directChildDom(wrapper, P_NS, "nvPr");
|
|
34
|
-
if (nvPr === void 0) continue;
|
|
35
|
-
if (directChildDom(nvPr, "http://schemas.openxmlformats.org/presentationml/2006/main", "ph") !== void 0) return true;
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
14
|
/** Consumes `<p:nvPr>` (and optional `userDrawn` flag) for non-placeholder objects. */
|
|
40
15
|
function consumeNonPlaceholderNvPr(nvParentCursor) {
|
|
41
16
|
const nvPr = nvParentCursor.child(P_NS, "nvPr");
|
|
@@ -52,7 +27,7 @@ const HlinkClickFragmentSchema = z.object({
|
|
|
52
27
|
function parseOptionalName(value, path) {
|
|
53
28
|
if (value === void 0) return void 0;
|
|
54
29
|
const parsed = optionalNameSchema.safeParse(value);
|
|
55
|
-
if (!parsed.success) throw new CapabilityError("invalid-parameter", "name must be a non-empty string", path);
|
|
30
|
+
if (!parsed.success) throw new CapabilityError("invalid-parameter", "name must be a non-empty string", path, { field: "name" });
|
|
56
31
|
return parsed.data;
|
|
57
32
|
}
|
|
58
33
|
/** Validates an optional Morph handle created by createMorphScope().handle(name). */
|
|
@@ -202,4 +177,47 @@ function attachDeferredSlideLink(node, deferredSlideLink, context) {
|
|
|
202
177
|
}
|
|
203
178
|
});
|
|
204
179
|
}
|
|
205
|
-
|
|
180
|
+
const NonVisualIdAttrSchema = z.object({
|
|
181
|
+
id: ooxmlNonNegativeIntSchema,
|
|
182
|
+
name: z.string().optional()
|
|
183
|
+
});
|
|
184
|
+
/** Reads `<p:cNvPr>` id, name, and hyperlink without assuming shape vs group wrapper tag. */
|
|
185
|
+
function readNonVisualCommonProperties(cNvPrCursor, context, diagnostics) {
|
|
186
|
+
if (cNvPrCursor === void 0) return {};
|
|
187
|
+
const raw = cNvPrCursor.attrsObject(["id", "name"]);
|
|
188
|
+
const parsed = NonVisualIdAttrSchema.safeParse(raw);
|
|
189
|
+
let objectId;
|
|
190
|
+
let objectName;
|
|
191
|
+
if (!parsed.success) diagnostics.push({
|
|
192
|
+
code: "invalid-xml-value",
|
|
193
|
+
category: "corrupt-input",
|
|
194
|
+
disposition: "recovered",
|
|
195
|
+
location: {
|
|
196
|
+
part: context.part,
|
|
197
|
+
xpath: cNvPrCursor.xpath,
|
|
198
|
+
slideIndex: context.slideIndex
|
|
199
|
+
},
|
|
200
|
+
attributeOrElement: "p:cNvPr",
|
|
201
|
+
rawValue: JSON.stringify(raw)
|
|
202
|
+
});
|
|
203
|
+
else {
|
|
204
|
+
objectId = parsed.data.id;
|
|
205
|
+
if (parsed.data.name !== void 0 && parsed.data.name.trim() !== "") objectName = parsed.data.name;
|
|
206
|
+
}
|
|
207
|
+
const hlinkClick = cNvPrCursor.child(A_NS, "hlinkClick");
|
|
208
|
+
let clickResult;
|
|
209
|
+
if (hlinkClick !== void 0) {
|
|
210
|
+
clickResult = readClickLink(hlinkClick, context, {
|
|
211
|
+
...objectId === void 0 ? {} : { objectId },
|
|
212
|
+
...objectName === void 0 ? {} : { objectName }
|
|
213
|
+
});
|
|
214
|
+
diagnostics.push(...clickResult.diagnostics);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
...objectId === void 0 ? {} : { objectId },
|
|
218
|
+
...objectName === void 0 ? {} : { objectName },
|
|
219
|
+
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
220
|
+
...clickResult?.deferredSlideLink === void 0 ? {} : { deferredSlideLink: clickResult.deferredSlideLink }
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export { attachDeferredSlideLink, consumeNonPlaceholderNvPr, nativeLinkXml, optionalNameSchema, parseLinkTarget, parseMorphKey, parseOptionalName, readClickLink, readNonVisualCommonProperties };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { markImmutableBytes } from "../../kernel/font-seal.js";
|
|
2
|
+
import { externalResourceSourceSchema } from "../../kernel/resource-source.js";
|
|
3
|
+
import { imageBackgroundObjectSchema } from "../../kernel/theme.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import { expr } from "../../kernel/codegen.js";
|
|
6
|
+
import { CommonNode } from "../../kernel/document.js";
|
|
7
|
+
import { finishResolveWork } from "../../kernel/resolve-work.js";
|
|
8
|
+
import { readImage } from "./image-decode.js";
|
|
9
|
+
import { imageStyleSchema } from "./image-schemas.js";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
// ../core/dist/capabilities/shared/image-codegen.js
|
|
13
|
+
function readCodegenImage(source) {
|
|
14
|
+
return finishResolveWork(readImage(source), (path) => markImmutableBytes(readFileSync(path instanceof URL ? fileURLToPath(path) : path)));
|
|
15
|
+
}
|
|
16
|
+
const dummyImageBytes = new Uint8Array([0]);
|
|
17
|
+
function isPlainObject(value) {
|
|
18
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
19
|
+
const proto = Object.getPrototypeOf(value);
|
|
20
|
+
return proto === Object.prototype || proto === null;
|
|
21
|
+
}
|
|
22
|
+
function assertNoLeafDeclarationChildren(label, node, ctx) {
|
|
23
|
+
for (const child of node.children) {
|
|
24
|
+
if (child instanceof CommonNode) ctx.fail("invalid-document", `${label} does not accept child declarations`);
|
|
25
|
+
const leaf = child;
|
|
26
|
+
if (leaf.type === "#text" && leaf.text.trim() !== "") ctx.fail("invalid-document", `${label} does not accept text children`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function serializeImageSrcProp(value, ctx, field = "@src", label = "Image.src") {
|
|
30
|
+
if (isPlainObject(value) && Object.hasOwn(value, "externalUrl")) {
|
|
31
|
+
const parsedExternal = externalResourceSourceSchema.safeParse(value);
|
|
32
|
+
if (!parsedExternal.success) ctx.fail("unexpressible-value", `${label} externalUrl must be a non-empty string`, field);
|
|
33
|
+
return expr(ctx.emitValueExpr({ externalUrl: parsedExternal.data.externalUrl }, field));
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const loaded = readCodegenImage(value);
|
|
37
|
+
const assetVar = ctx.registerImageAsset(loaded.bytes, loaded.extension);
|
|
38
|
+
return expr(assetVar);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return ctx.fail("unexpressible-value", error instanceof Error ? error.message : `${label} could not be read or decoded`, field);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function serializeImageStyleProp(style, ctx) {
|
|
44
|
+
if (!isPlainObject(style)) ctx.fail("unexpressible-value", "Image.style must be a plain object", "@style");
|
|
45
|
+
const parsed = imageStyleSchema.safeParse(style);
|
|
46
|
+
if (!parsed.success) {
|
|
47
|
+
const issue = parsed.error.issues[0];
|
|
48
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
49
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Image.style cannot be expressed", issuePath);
|
|
50
|
+
}
|
|
51
|
+
const styleEntries = [];
|
|
52
|
+
for (const [key, entryValue] of Object.entries(style)) {
|
|
53
|
+
if (entryValue === void 0) continue;
|
|
54
|
+
if (key === "background") {
|
|
55
|
+
const serializedBg = serializeImageDescriptorValue(entryValue, ctx);
|
|
56
|
+
styleEntries.push([key, serializedBg ?? entryValue]);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
styleEntries.push([key, entryValue]);
|
|
60
|
+
}
|
|
61
|
+
return expr(ctx.formatProps(styleEntries));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Serializes an `{ image, fit?, position?, opacity? }` descriptor (used in `style.background`
|
|
65
|
+
* and `Slide.background`) by reading/validating embedded image bytes or `{ externalUrl }`
|
|
66
|
+
* and emitting a formatted descriptor expression.
|
|
67
|
+
*/
|
|
68
|
+
function serializeImageDescriptorValue(value, ctx) {
|
|
69
|
+
if (!isPlainObject(value) || value["image"] === void 0) return;
|
|
70
|
+
if (Object.keys(value).some((key) => value[key] !== void 0 && !Object.hasOwn(imageBackgroundObjectSchema.shape, key))) return;
|
|
71
|
+
const subPath = ctx.path.includes("@") ? void 0 : "@style.background";
|
|
72
|
+
const rawSource = value["image"];
|
|
73
|
+
let imageExpr;
|
|
74
|
+
if (isPlainObject(rawSource) && Object.hasOwn(rawSource, "externalUrl")) {
|
|
75
|
+
const parsedExternal = externalResourceSourceSchema.safeParse(rawSource);
|
|
76
|
+
if (!parsedExternal.success) ctx.fail("unexpressible-value", "Background image externalUrl must be a non-empty string", subPath);
|
|
77
|
+
imageExpr = expr(ctx.emitValueExpr({ externalUrl: parsedExternal.data.externalUrl }, subPath));
|
|
78
|
+
} else try {
|
|
79
|
+
const loaded = readCodegenImage(rawSource);
|
|
80
|
+
const assetVar = ctx.registerImageAsset(loaded.bytes, loaded.extension);
|
|
81
|
+
imageExpr = expr(assetVar);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
ctx.fail("unexpressible-value", error instanceof Error ? error.message : "Background image source could not be read or decoded", subPath);
|
|
84
|
+
}
|
|
85
|
+
const parsedOptions = imageBackgroundObjectSchema.safeParse({
|
|
86
|
+
...value,
|
|
87
|
+
image: dummyImageBytes
|
|
88
|
+
});
|
|
89
|
+
if (!parsedOptions.success) ctx.fail("unexpressible-value", parsedOptions.error.issues[0]?.message ?? "Background image descriptor options are invalid", subPath);
|
|
90
|
+
const descriptorEntries = [["image", imageExpr]];
|
|
91
|
+
for (const [optionKey, optionValue] of Object.entries(parsedOptions.data)) if (optionKey !== "image" && optionValue !== void 0) descriptorEntries.push([optionKey, expr(ctx.emitValueExpr(optionValue, subPath))]);
|
|
92
|
+
return expr(ctx.formatProps(descriptorEntries));
|
|
93
|
+
}
|
|
94
|
+
export { assertNoLeafDeclarationChildren, isPlainObject, serializeImageDescriptorValue, serializeImageSrcProp, serializeImageStyleProp };
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import { isImmutableBytes, markImmutableBytes } from "
|
|
3
|
-
import "
|
|
4
|
-
|
|
5
|
-
import { createRequire } from "node:module";
|
|
6
|
-
import { readFileSync } from "node:fs";
|
|
7
|
-
import { fileURLToPath } from "node:url";
|
|
8
|
-
// ../capabilities/dist/image/image-decode.js
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { isImmutableBytes, markImmutableBytes } from "../../kernel/font-seal.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
// ../core/dist/capabilities/shared/image-decode.js
|
|
9
5
|
function uint32(data, offset) {
|
|
10
6
|
return ((data[offset] ?? 0) << 24 >>> 0) + ((data[offset + 1] ?? 0) << 16) + ((data[offset + 2] ?? 0) << 8) + (data[offset + 3] ?? 0);
|
|
11
7
|
}
|
|
@@ -161,26 +157,9 @@ function gifMetadata(data) {
|
|
|
161
157
|
hasImageData = true;
|
|
162
158
|
}
|
|
163
159
|
}
|
|
164
|
-
/**
|
|
165
|
-
function
|
|
166
|
-
|
|
167
|
-
let bytes;
|
|
168
|
-
try {
|
|
169
|
-
if (source instanceof Uint8Array) {
|
|
170
|
-
if (isImmutableBytes(source)) bytes = source;
|
|
171
|
-
else {
|
|
172
|
-
const copy = new Uint8Array(source);
|
|
173
|
-
markImmutableBytes(copy);
|
|
174
|
-
bytes = copy;
|
|
175
|
-
}
|
|
176
|
-
} else {
|
|
177
|
-
const copy = new Uint8Array(readFileSync(source instanceof URL ? fileURLToPath(source) : source));
|
|
178
|
-
markImmutableBytes(copy);
|
|
179
|
-
bytes = copy;
|
|
180
|
-
}
|
|
181
|
-
} catch {
|
|
182
|
-
throw new CapabilityError("image-read-failed", "Failed to read image resource");
|
|
183
|
-
}
|
|
160
|
+
/** Validates PNG, JPEG, or GIF header metadata from owned or caller-provided bytes. */
|
|
161
|
+
function readImageBytes(source) {
|
|
162
|
+
const bytes = isImmutableBytes(source) ? source : markImmutableBytes(new Uint8Array(source));
|
|
184
163
|
const metadata = pngMetadata(bytes) ?? jpegMetadata(bytes) ?? gifMetadata(bytes);
|
|
185
164
|
if (metadata === void 0) throw new CapabilityError("unsupported-image-format", "Invalid image resource content or unsupported format; only PNG, JPEG, and GIF are supported");
|
|
186
165
|
return {
|
|
@@ -188,57 +167,16 @@ function readImage(source) {
|
|
|
188
167
|
bytes
|
|
189
168
|
};
|
|
190
169
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
cachedDecoders = {
|
|
197
|
-
png: require("pngjs"),
|
|
198
|
-
jpeg: require("jpeg-js")
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return cachedDecoders;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Decodes PNG, JPEG, or static first-frame GIF bytes into normalized PNG bytes for SVG embedding.
|
|
205
|
-
* Throws `preview-corrupt-image` if compressed pixel data is invalid.
|
|
206
|
-
*/
|
|
207
|
-
function decodeImageToPngBytes(image) {
|
|
208
|
-
const immutableSource = isImmutableBytes(image.bytes);
|
|
209
|
-
if (immutableSource) {
|
|
210
|
-
const cached = normalizedPngByImmutableBytes.get(image.bytes);
|
|
211
|
-
if (cached !== void 0) return cached;
|
|
212
|
-
}
|
|
213
|
-
const { png: pngModule, jpeg: jpegModule } = imageDecoders();
|
|
214
|
-
let decoded;
|
|
170
|
+
/** Resolves embedded image bytes at their binding site, preserving source diagnostics. */
|
|
171
|
+
function* readImage(source) {
|
|
172
|
+
if (source instanceof Uint8Array) return readImageBytes(source);
|
|
173
|
+
if (typeof source !== "string" && !(source instanceof URL)) throw new CapabilityError("invalid-image-source", "Image.src must be a file path, file URL, or image bytes");
|
|
174
|
+
let bytes;
|
|
215
175
|
try {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
break;
|
|
220
|
-
case "jpeg":
|
|
221
|
-
decoded = jpegModule.decode(image.bytes, { tolerantDecoding: false });
|
|
222
|
-
break;
|
|
223
|
-
case "gif":
|
|
224
|
-
decoded = decodeGifFirstFrame(image.bytes);
|
|
225
|
-
break;
|
|
226
|
-
default: return image.extension;
|
|
227
|
-
}
|
|
228
|
-
} catch (error) {
|
|
229
|
-
if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, error.path, error.details ?? { format: image.extension });
|
|
230
|
-
throw new CapabilityError("preview-corrupt-image", error instanceof Error ? `Failed to decode ${image.extension.toUpperCase()} image for preview: ${error.message}` : `Failed to decode ${image.extension.toUpperCase()} image for preview`, void 0, { format: image.extension });
|
|
231
|
-
}
|
|
232
|
-
const normalized = new pngModule.PNG({
|
|
233
|
-
width: decoded.width,
|
|
234
|
-
height: decoded.height
|
|
235
|
-
});
|
|
236
|
-
normalized.data = Buffer.from(decoded.data);
|
|
237
|
-
const pngBytes = new Uint8Array(pngModule.PNG.sync.write(normalized));
|
|
238
|
-
if (immutableSource) {
|
|
239
|
-
markImmutableBytes(pngBytes);
|
|
240
|
-
normalizedPngByImmutableBytes.set(image.bytes, pngBytes);
|
|
176
|
+
bytes = yield source;
|
|
177
|
+
} catch {
|
|
178
|
+
throw new CapabilityError("image-read-failed", "Failed to read image resource");
|
|
241
179
|
}
|
|
242
|
-
return
|
|
180
|
+
return readImageBytes(bytes);
|
|
243
181
|
}
|
|
244
|
-
export {
|
|
182
|
+
export { readImage, readImageBytes };
|