@officedk/pptxdk 0.2.0 → 0.2.2
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 +8 -7
- 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,510 @@
|
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { pxToEmu } from "../../kernel/drawing-units.js";
|
|
3
|
+
import { resourceSourceSchema } from "../../kernel/resource-source.js";
|
|
4
|
+
import { parseLinkTarget } from "../../kernel/author-schemas.js";
|
|
5
|
+
import { layoutStyleKeys, parseCapabilityLayoutContract } from "../../kernel/layout.js";
|
|
6
|
+
import { evaluateGeometry } from "./geometry.js";
|
|
7
|
+
import { nativeLinkXml, parseMorphKey, parseOptionalName } from "./identity.js";
|
|
8
|
+
import { readImage } from "./image-decode.js";
|
|
9
|
+
import { imageAltSchema, imageCoordinateValueSchema, imageCropInputSchema, imageExtentValueSchema, imageFitSchema, imageStyleKeys, imageVisualStyleKeys } from "./image-schemas.js";
|
|
10
|
+
import { motionAnnotations, pickMotionProps } from "./motion-api.js";
|
|
11
|
+
import { hasLocalDeclaration, resolvePlaceholderGeometry, resolvePlaceholderVisualStyle } from "./style-inheritance.js";
|
|
12
|
+
import { bindVisualModel, emitVisualModel, gradientDefSvg, paintImageFillSvg, resolveVisualModel, visualSvgTransform } from "./visual.js";
|
|
13
|
+
import "../../kernel/capability.js";
|
|
14
|
+
import { assertXml10Characters, xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
15
|
+
import { imageXml } from "./picture-xml.js";
|
|
16
|
+
// ../core/dist/capabilities/shared/picture.js
|
|
17
|
+
function roundSvgNumber(value) {
|
|
18
|
+
const rounded = Math.round(value * 1e6) / 1e6;
|
|
19
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
20
|
+
}
|
|
21
|
+
function borderStrokeAttributes(border) {
|
|
22
|
+
const w = Math.max(1, border.width);
|
|
23
|
+
let dashAttr = "";
|
|
24
|
+
switch (border.style) {
|
|
25
|
+
case "solid":
|
|
26
|
+
dashAttr = "";
|
|
27
|
+
break;
|
|
28
|
+
case "dashed":
|
|
29
|
+
dashAttr = ` stroke-dasharray="${roundSvgNumber(w * 4)} ${roundSvgNumber(w * 3)}"`;
|
|
30
|
+
break;
|
|
31
|
+
case "dotted":
|
|
32
|
+
dashAttr = ` stroke-dasharray="${roundSvgNumber(w)} ${roundSvgNumber(w * 2)}"`;
|
|
33
|
+
break;
|
|
34
|
+
default: return border.style;
|
|
35
|
+
}
|
|
36
|
+
return `stroke="#${border.color.hex}" stroke-opacity="${roundSvgNumber(border.color.alpha ?? 1)}" stroke-width="${roundSvgNumber(border.width)}"${dashAttr}`;
|
|
37
|
+
}
|
|
38
|
+
const imageRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
39
|
+
function emitImageModel(model, emitContext, mediaNonVisual) {
|
|
40
|
+
const omitFill = model.visual.fill.kind === "none" && model.placeholder?.hasLocalFill !== true;
|
|
41
|
+
const properties = emitVisualModel(model.visual, (resource) => emitContext.registerResource(resource), { omitFill });
|
|
42
|
+
const escapedName = xmlEscape(model.name);
|
|
43
|
+
const escapedAlt = model.alt === void 0 ? void 0 : xmlEscape(model.alt);
|
|
44
|
+
let relationshipId;
|
|
45
|
+
try {
|
|
46
|
+
relationshipId = model.image.kind === "external" ? emitContext.registerResource({
|
|
47
|
+
externalTarget: model.image.externalUrl,
|
|
48
|
+
relationshipType: imageRelationshipType
|
|
49
|
+
}) : emitContext.registerResource({
|
|
50
|
+
bytes: model.image.bytes,
|
|
51
|
+
extension: model.image.extension,
|
|
52
|
+
contentType: model.image.contentType,
|
|
53
|
+
relationshipType: imageRelationshipType
|
|
54
|
+
});
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof CapabilityError) throw error;
|
|
57
|
+
throw new CapabilityError("image-resource-failure", error instanceof Error ? error.message : String(error));
|
|
58
|
+
}
|
|
59
|
+
const { sourceCrop } = model.placement;
|
|
60
|
+
const serializedCrop = Object.fromEntries([
|
|
61
|
+
["l", sourceCrop.l],
|
|
62
|
+
["t", sourceCrop.t],
|
|
63
|
+
["r", sourceCrop.r],
|
|
64
|
+
["b", sourceCrop.b]
|
|
65
|
+
].filter(([, fraction]) => fraction !== 0));
|
|
66
|
+
return { xml: imageXml(emitContext.id, escapedName, escapedAlt, {
|
|
67
|
+
kind: model.image.kind === "external" ? "link" : "embed",
|
|
68
|
+
relationshipId
|
|
69
|
+
}, model.placement.box, serializedCrop, properties.xml, properties.opacity, mediaNonVisual?.action ?? nativeLinkXml(emitContext.nativeLink), model.placeholder === void 0 ? void 0 : {
|
|
70
|
+
nativeRef: model.placeholder.nativeRef,
|
|
71
|
+
...model.placeholder.omitSpPrTransform ? { spPrXml: "<p:spPr/>" } : {}
|
|
72
|
+
}, mediaNonVisual?.properties) };
|
|
73
|
+
}
|
|
74
|
+
function roundCropFraction(fraction) {
|
|
75
|
+
return Math.round(fraction * 1e5) / 1e5;
|
|
76
|
+
}
|
|
77
|
+
function paintImageModel(model, paintContext) {
|
|
78
|
+
const { image, placement, visual } = model;
|
|
79
|
+
const { box, sourceCrop } = placement;
|
|
80
|
+
const hasFinitePositiveBox = Number.isFinite(box.x) && Number.isFinite(box.y) && Number.isFinite(box.width) && Number.isFinite(box.height) && box.width > 1e-6 && box.height > 1e-6;
|
|
81
|
+
const externalPlaceholders = [...image.kind === "external" ? [{
|
|
82
|
+
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
83
|
+
path: paintContext.path,
|
|
84
|
+
url: image.externalUrl
|
|
85
|
+
}] : [], ...visual.fill.kind === "image" && visual.fill.source.kind === "external" ? [{
|
|
86
|
+
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
87
|
+
path: paintContext.path,
|
|
88
|
+
url: visual.fill.source.externalUrl
|
|
89
|
+
}] : []];
|
|
90
|
+
if (!hasFinitePositiveBox) return {
|
|
91
|
+
svg: "",
|
|
92
|
+
...externalPlaceholders.length === 0 ? {} : { placeholders: externalPlaceholders }
|
|
93
|
+
};
|
|
94
|
+
if (image.kind === "external") {
|
|
95
|
+
const evaluated = evaluateGeometry(visual.geometry, box);
|
|
96
|
+
const placeholderShapes = evaluated.paths.filter((pathItem) => pathItem.fillMode !== "none" && pathItem.d !== "").map((pathItem) => `<path d="${pathItem.d}" fill="#F1F5F9" stroke="#94A3B8" stroke-width="1" stroke-dasharray="4 4"/>`).join("");
|
|
97
|
+
const borderElements = visual.border !== void 0 ? evaluated.paths.filter((pathItem) => pathItem.stroke && pathItem.d !== "").map((pathItem) => `<path d="${pathItem.d}" fill="none" ${borderStrokeAttributes(visual.border)}/>`).join("") : "";
|
|
98
|
+
return {
|
|
99
|
+
svg: `<g transform="${visualSvgTransform(visual)}">${placeholderShapes}${borderElements}</g>`,
|
|
100
|
+
placeholders: [{
|
|
101
|
+
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
102
|
+
path: paintContext.path,
|
|
103
|
+
url: image.externalUrl
|
|
104
|
+
}, ...visual.fill.kind === "image" && visual.fill.source.kind === "external" ? [{
|
|
105
|
+
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
106
|
+
path: paintContext.path,
|
|
107
|
+
url: visual.fill.source.externalUrl
|
|
108
|
+
}] : []]
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
const href = paintContext.registerRasterResource(image, {
|
|
112
|
+
normalizeToPng: true,
|
|
113
|
+
diagnostic: { field: "src" }
|
|
114
|
+
});
|
|
115
|
+
const leftCrop = roundCropFraction(sourceCrop.l);
|
|
116
|
+
const topCrop = roundCropFraction(sourceCrop.t);
|
|
117
|
+
const rightCrop = roundCropFraction(sourceCrop.r);
|
|
118
|
+
const bottomCrop = roundCropFraction(sourceCrop.b);
|
|
119
|
+
const widthFactor = 1 - leftCrop - rightCrop;
|
|
120
|
+
const heightFactor = 1 - topCrop - bottomCrop;
|
|
121
|
+
const prefix = `img-s${paintContext.slideNumber}-o${paintContext.objectId}`;
|
|
122
|
+
const defs = [];
|
|
123
|
+
const evaluated = evaluateGeometry(visual.geometry, box);
|
|
124
|
+
const fillablePaths = evaluated.paths.filter((pathItem) => pathItem.fillMode !== "none" && pathItem.d !== "");
|
|
125
|
+
let backgroundElements = "";
|
|
126
|
+
if (visual.fill.kind !== "none" && fillablePaths.length > 0) {
|
|
127
|
+
let fillAttr = "fill=\"none\"";
|
|
128
|
+
if (visual.fill.kind === "solid") fillAttr = `fill="#${visual.fill.color.hex}" fill-opacity="${roundSvgNumber(visual.fill.color.alpha ?? 1)}"`;
|
|
129
|
+
else if (visual.fill.kind === "linear-gradient" || visual.fill.kind === "radial-gradient") {
|
|
130
|
+
const bgDefId = `${prefix}-bg`;
|
|
131
|
+
defs.push(gradientDefSvg(bgDefId, visual.fill));
|
|
132
|
+
fillAttr = `fill="url(#${bgDefId})"`;
|
|
133
|
+
} else if (visual.fill.kind === "image") {
|
|
134
|
+
const bgDefId = `${prefix}-bg`;
|
|
135
|
+
const patternSvg = paintImageFillSvg(visual.fill, bgDefId, box, paintContext.registerRasterResource);
|
|
136
|
+
if (patternSvg !== "") {
|
|
137
|
+
defs.push(patternSvg);
|
|
138
|
+
fillAttr = `fill="url(#${bgDefId})"`;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
backgroundElements = fillablePaths.map((pathItem) => `<path d="${pathItem.d}" ${fillAttr} stroke="none" stroke-width="0"/>`).join("");
|
|
142
|
+
}
|
|
143
|
+
const opacity = visual.opacity ?? 1;
|
|
144
|
+
let imageElement = "";
|
|
145
|
+
if (widthFactor > 1e-6 && heightFactor > 1e-6 && fillablePaths.length > 0) {
|
|
146
|
+
const imgWidth = box.width / widthFactor;
|
|
147
|
+
const imgHeight = box.height / heightFactor;
|
|
148
|
+
const imgX = box.x - leftCrop * imgWidth;
|
|
149
|
+
const imgY = box.y - topCrop * imgHeight;
|
|
150
|
+
if (Number.isFinite(imgX) && Number.isFinite(imgY) && Number.isFinite(imgWidth) && Number.isFinite(imgHeight) && imgWidth > 1e-6 && imgHeight > 1e-6) {
|
|
151
|
+
const clipId = `${prefix}-clip`;
|
|
152
|
+
const clipMarkup = fillablePaths.map((pathItem) => `<path d="${pathItem.d}"/>`).join("");
|
|
153
|
+
defs.push(`<clipPath id="${clipId}" clipPathUnits="userSpaceOnUse">${clipMarkup}</clipPath>`);
|
|
154
|
+
const opacityAttr = opacity === 1 ? "" : ` opacity="${roundSvgNumber(opacity)}"`;
|
|
155
|
+
imageElement = `<image clip-path="url(#${clipId})" x="${roundSvgNumber(imgX)}" y="${roundSvgNumber(imgY)}" width="${roundSvgNumber(imgWidth)}" height="${roundSvgNumber(imgHeight)}" preserveAspectRatio="none"${opacityAttr} href="${href}"/>`;
|
|
156
|
+
if (visual.softEdge !== void 0 && visual.softEdge > 0) {
|
|
157
|
+
const r = visual.softEdge;
|
|
158
|
+
const minSide = Math.min(box.width, box.height);
|
|
159
|
+
const borderPad = visual.border === void 0 ? 0 : visual.border.width;
|
|
160
|
+
const pad = Math.ceil(r * 2 + borderPad + 8);
|
|
161
|
+
const maskX = roundSvgNumber(box.x - pad);
|
|
162
|
+
const maskY = roundSvgNumber(box.y - pad);
|
|
163
|
+
const maskW = roundSvgNumber(box.width + pad * 2);
|
|
164
|
+
const maskH = roundSvgNumber(box.height + pad * 2);
|
|
165
|
+
const blurId = `${prefix}-soft-blur`;
|
|
166
|
+
const maskId = `${prefix}-soft-mask`;
|
|
167
|
+
const innerStrokeWidth = r >= minSide / 2 ? 0 : Math.min(r, minSide * .45);
|
|
168
|
+
const maskAttrs = innerStrokeWidth > 0 ? `fill="white" stroke="black" stroke-width="${roundSvgNumber(innerStrokeWidth)}" filter="url(#${blurId})"` : `fill="white" stroke="none" filter="url(#${blurId})"`;
|
|
169
|
+
const maskShapes = fillablePaths.map((pathItem) => `<path d="${pathItem.d}" ${maskAttrs}/>`).join("");
|
|
170
|
+
defs.push(`<filter id="${blurId}" filterUnits="userSpaceOnUse" x="${maskX}" y="${maskY}" width="${maskW}" height="${maskH}"><feGaussianBlur stdDeviation="${roundSvgNumber(r / 2)}"/></filter>`);
|
|
171
|
+
defs.push(`<mask id="${maskId}" maskUnits="userSpaceOnUse" x="${maskX}" y="${maskY}" width="${maskW}" height="${maskH}">${maskShapes}</mask>`);
|
|
172
|
+
imageElement = `<g mask="url(#${maskId})">${imageElement}</g>`;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
let borderElements = "";
|
|
177
|
+
if (visual.border !== void 0) {
|
|
178
|
+
const strokeAttr = borderStrokeAttributes(visual.border);
|
|
179
|
+
borderElements = evaluated.paths.filter((pathItem) => pathItem.stroke && pathItem.d !== "").map((pathItem) => `<path d="${pathItem.d}" fill="none" ${strokeAttr}/>`).join("");
|
|
180
|
+
}
|
|
181
|
+
let layer = `<g transform="${visualSvgTransform(visual)}">${backgroundElements}${imageElement}${borderElements}</g>`;
|
|
182
|
+
if (visual.boxShadow !== void 0) {
|
|
183
|
+
const shadow = visual.boxShadow;
|
|
184
|
+
const cx = box.x + box.width / 2;
|
|
185
|
+
const cy = box.y + box.height / 2;
|
|
186
|
+
const halfDiag = Math.hypot(box.width, box.height) / 2;
|
|
187
|
+
const rad = shadow.angle * Math.PI / 180;
|
|
188
|
+
const dx = shadow.distance * Math.cos(rad);
|
|
189
|
+
const dy = shadow.distance * Math.sin(rad);
|
|
190
|
+
const sigma = shadow.blur / 2;
|
|
191
|
+
const borderPad = visual.border === void 0 ? 0 : visual.border.width;
|
|
192
|
+
const pad = shadow.blur * 3 + Math.abs(dx) + Math.abs(dy) + borderPad + 16;
|
|
193
|
+
const minX = roundSvgNumber(cx - halfDiag - pad);
|
|
194
|
+
const minY = roundSvgNumber(cy - halfDiag - pad);
|
|
195
|
+
const filterSize = roundSvgNumber((halfDiag + pad) * 2);
|
|
196
|
+
const shadowId = `${prefix}-shadow`;
|
|
197
|
+
defs.push(`<filter id="${shadowId}" filterUnits="userSpaceOnUse" x="${minX}" y="${minY}" width="${filterSize}" height="${filterSize}"><feDropShadow dx="${roundSvgNumber(dx)}" dy="${roundSvgNumber(dy)}" stdDeviation="${roundSvgNumber(sigma)}" flood-color="#${shadow.color.hex}" flood-opacity="${roundSvgNumber(shadow.color.alpha ?? 1)}"/></filter>`);
|
|
198
|
+
layer = `<g filter="url(#${shadowId})">${layer}</g>`;
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
svg: `${defs.length > 0 ? `<defs>${defs.join("")}</defs>` : ""}${layer}`,
|
|
202
|
+
...visual.fill.kind === "image" && visual.fill.source.kind === "external" ? { placeholders: [{
|
|
203
|
+
...model.authorId === void 0 ? {} : { id: model.authorId },
|
|
204
|
+
path: paintContext.path,
|
|
205
|
+
url: visual.fill.source.externalUrl
|
|
206
|
+
}] } : {}
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
/** Shared image placement calculation for native OOXML output and static preview. */
|
|
210
|
+
function imagePlacement(image, fit, crop, allocated) {
|
|
211
|
+
const { width, height } = allocated;
|
|
212
|
+
const box = { ...allocated };
|
|
213
|
+
let l = crop?.l ?? 0;
|
|
214
|
+
let t = crop?.t ?? 0;
|
|
215
|
+
let r = crop?.r ?? 0;
|
|
216
|
+
let b = crop?.b ?? 0;
|
|
217
|
+
if (crop === void 0 && image.width !== void 0 && image.height !== void 0) {
|
|
218
|
+
const imageRatio = image.width / image.height;
|
|
219
|
+
const boxRatio = width / height;
|
|
220
|
+
switch (fit) {
|
|
221
|
+
case "fill": break;
|
|
222
|
+
case "cover":
|
|
223
|
+
if (imageRatio > boxRatio) {
|
|
224
|
+
const excess = (1 - boxRatio / imageRatio) / 2;
|
|
225
|
+
l = excess;
|
|
226
|
+
r = excess;
|
|
227
|
+
} else if (imageRatio < boxRatio) {
|
|
228
|
+
const excess = (1 - imageRatio / boxRatio) / 2;
|
|
229
|
+
t = excess;
|
|
230
|
+
b = excess;
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
case "contain":
|
|
234
|
+
if (imageRatio > boxRatio) {
|
|
235
|
+
const fittedHeight = width / imageRatio;
|
|
236
|
+
box.y += (height - fittedHeight) / 2;
|
|
237
|
+
box.height = fittedHeight;
|
|
238
|
+
} else if (imageRatio < boxRatio) {
|
|
239
|
+
const fittedWidth = height * imageRatio;
|
|
240
|
+
box.x += (width - fittedWidth) / 2;
|
|
241
|
+
box.width = fittedWidth;
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
default: throw new Error(`Unsupported image fit: ${String(fit)}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
box.width = dimension(box.width, "width");
|
|
248
|
+
box.height = dimension(box.height, "height");
|
|
249
|
+
return {
|
|
250
|
+
box,
|
|
251
|
+
sourceCrop: {
|
|
252
|
+
l,
|
|
253
|
+
t,
|
|
254
|
+
r,
|
|
255
|
+
b
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
const maximumShapeExtentEmu = 2147483647;
|
|
260
|
+
function isRecord(value) {
|
|
261
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
262
|
+
}
|
|
263
|
+
function dimension(value, name, fallback) {
|
|
264
|
+
const actual = value === void 0 ? fallback : value;
|
|
265
|
+
const isExtent = name === "width" || name === "height";
|
|
266
|
+
const field = name === "x" ? "style.left" : name === "y" ? "style.top" : `style.${name}`;
|
|
267
|
+
if (isExtent && typeof actual === "number" && Number.isFinite(actual)) {
|
|
268
|
+
if (actual === 0 || pxToEmu(actual) === 0) throw new CapabilityError("invalid-coordinate", `Computed ${name} is 0px; ${name} must be greater than 0px`, void 0, { field });
|
|
269
|
+
if (actual < 0 || pxToEmu(actual) < 1) throw new CapabilityError("invalid-coordinate", `Computed ${name} is ${actual}px; ${name} must be greater than 0px`, void 0, { field });
|
|
270
|
+
}
|
|
271
|
+
const parsed = isExtent ? imageExtentValueSchema.safeParse(actual) : imageCoordinateValueSchema.safeParse(actual);
|
|
272
|
+
if (!parsed.success) throw new CapabilityError("invalid-coordinate", `${name} must be a finite pixel number, width and height must be greater than 0, and coordinates must be between -1000000 and 1000000`, void 0, { field });
|
|
273
|
+
if (isExtent) {
|
|
274
|
+
const extentEmu = pxToEmu(parsed.data);
|
|
275
|
+
if (extentEmu < 1 || extentEmu > maximumShapeExtentEmu) throw new CapabilityError("invalid-coordinate", `${name} must convert to an EMU value between 1 and ${maximumShapeExtentEmu} inclusive`, void 0, { field });
|
|
276
|
+
}
|
|
277
|
+
return parsed.data;
|
|
278
|
+
}
|
|
279
|
+
function parseCropValues(value, path) {
|
|
280
|
+
if (value === void 0) return void 0;
|
|
281
|
+
const parsed = imageCropInputSchema.safeParse(value);
|
|
282
|
+
if (!parsed.success) {
|
|
283
|
+
const issue = parsed.error.issues[0];
|
|
284
|
+
if (issue?.code === "unrecognized_keys") throw new CapabilityError("unknown-parameter", `crop contains unknown parameter ${issue.keys[0]}`, path);
|
|
285
|
+
throw new CapabilityError("invalid-crop", issue?.message ?? "crop must be a four-sided fraction object", path, { field: zodIssueField(issue, "crop") });
|
|
286
|
+
}
|
|
287
|
+
const { left, top, right, bottom } = parsed.data;
|
|
288
|
+
return {
|
|
289
|
+
...left === void 0 ? {} : { l: left },
|
|
290
|
+
...top === void 0 ? {} : { t: top },
|
|
291
|
+
...right === void 0 ? {} : { r: right },
|
|
292
|
+
...bottom === void 0 ? {} : { b: bottom }
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
function* readImageSource(source) {
|
|
296
|
+
const parsed = resourceSourceSchema.safeParse(source);
|
|
297
|
+
if (!parsed.success) throw new CapabilityError("invalid-image-source", "Image.src must be a file path, file URL, image bytes, or externalUrl descriptor");
|
|
298
|
+
const data = parsed.data;
|
|
299
|
+
if (typeof data === "string" || data instanceof Uint8Array || data instanceof URL) return {
|
|
300
|
+
kind: "embedded",
|
|
301
|
+
...yield* readImage(data)
|
|
302
|
+
};
|
|
303
|
+
return {
|
|
304
|
+
kind: "external",
|
|
305
|
+
externalUrl: data.externalUrl
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
/** Binds a native picture surface with shared sizing, crop, visual style, and poster paint. */
|
|
309
|
+
function* bindPicture(input, context, options) {
|
|
310
|
+
const { placeholder } = context;
|
|
311
|
+
const requestedName = parseOptionalName(input.props["name"]);
|
|
312
|
+
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
313
|
+
const link = parseLinkTarget(input.props["link"]);
|
|
314
|
+
const altParsed = imageAltSchema.safeParse(input.props["alt"]);
|
|
315
|
+
if (!altParsed.success) throw new CapabilityError("invalid-parameter", "alt must be a string", void 0, { field: "alt" });
|
|
316
|
+
const altValue = altParsed.data;
|
|
317
|
+
const allowedStyleKeys = new Set(options.layoutOnlyStyle === true ? layoutStyleKeys : imageStyleKeys);
|
|
318
|
+
const contract = parseCapabilityLayoutContract({
|
|
319
|
+
nativeKind: "pic",
|
|
320
|
+
props: input.props,
|
|
321
|
+
allowedStyleKeys,
|
|
322
|
+
allowPadding: false,
|
|
323
|
+
path: context.path
|
|
324
|
+
});
|
|
325
|
+
const rawSlideStyle = isRecord(input.props["style"]) ? input.props["style"] : void 0;
|
|
326
|
+
const imageStyle = placeholder !== void 0 ? resolvePlaceholderVisualStyle(placeholder, rawSlideStyle) : rawSlideStyle !== void 0 ? { ...rawSlideStyle } : {};
|
|
327
|
+
const hasLocalFill = hasLocalDeclaration(rawSlideStyle, "background");
|
|
328
|
+
const requestedFit = input.props["fit"];
|
|
329
|
+
let fit = "fill";
|
|
330
|
+
if (requestedFit !== void 0) {
|
|
331
|
+
const parsedFit = imageFitSchema.safeParse(requestedFit);
|
|
332
|
+
if (!parsedFit.success) throw new CapabilityError("unsupported-fit", "fit must be fill, cover, or contain", void 0, { field: "fit" });
|
|
333
|
+
fit = parsedFit.data;
|
|
334
|
+
}
|
|
335
|
+
const crop = parseCropValues(input.props["crop"]);
|
|
336
|
+
const image = yield* options.readSource();
|
|
337
|
+
const naturalSize = image.kind === "embedded" ? image : options.externalSize;
|
|
338
|
+
const geometry = input.props["geometry"];
|
|
339
|
+
const initialVisual = yield* bindVisualModel({
|
|
340
|
+
theme: context.theme,
|
|
341
|
+
style: imageStyle,
|
|
342
|
+
box: {
|
|
343
|
+
x: 0,
|
|
344
|
+
y: 0,
|
|
345
|
+
width: 100,
|
|
346
|
+
height: 100
|
|
347
|
+
},
|
|
348
|
+
...geometry !== void 0 ? { geometry } : {},
|
|
349
|
+
image: true
|
|
350
|
+
});
|
|
351
|
+
const placeholderGeometry = placeholder === void 0 ? void 0 : resolvePlaceholderGeometry(placeholder, input.props);
|
|
352
|
+
const hasLocalVisualOverride = geometry !== void 0 || [...imageVisualStyleKeys].some((key) => key !== "opacity" && hasLocalDeclaration(rawSlideStyle, key));
|
|
353
|
+
const declaredX = placeholderGeometry?.x;
|
|
354
|
+
const declaredY = placeholderGeometry?.y;
|
|
355
|
+
const requestedWidth = placeholderGeometry?.width ?? contract.explicitPixelSize?.width;
|
|
356
|
+
const requestedHeight = placeholderGeometry?.height ?? contract.explicitPixelSize?.height;
|
|
357
|
+
const hasFixedWidth = placeholderGeometry?.width !== void 0 && placeholderGeometry.width !== "auto" || (contract.fixedAxes?.width ?? false);
|
|
358
|
+
const hasFixedHeight = placeholderGeometry?.height !== void 0 && placeholderGeometry.height !== "auto" || (contract.fixedAxes?.height ?? false);
|
|
359
|
+
const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
|
|
360
|
+
const motionProps = pickMotionProps(input.props);
|
|
361
|
+
const native = {
|
|
362
|
+
...morphKey === void 0 ? {} : { morphKey },
|
|
363
|
+
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
364
|
+
...link === void 0 ? {} : { link }
|
|
365
|
+
};
|
|
366
|
+
return {
|
|
367
|
+
contract,
|
|
368
|
+
...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
|
|
369
|
+
measureLayout(request) {
|
|
370
|
+
const declaredWidth = typeof requestedWidth === "number" ? requestedWidth : void 0;
|
|
371
|
+
const declaredHeight = typeof requestedHeight === "number" ? requestedHeight : void 0;
|
|
372
|
+
if (naturalSize === void 0) {
|
|
373
|
+
if (declaredWidth !== void 0 && declaredHeight !== void 0) return {
|
|
374
|
+
width: declaredWidth,
|
|
375
|
+
height: declaredHeight,
|
|
376
|
+
minContentWidth: hasFixedWidth ? 0 : declaredWidth,
|
|
377
|
+
minContentHeight: hasFixedHeight ? 0 : declaredHeight
|
|
378
|
+
};
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
const width = declaredWidth ?? (declaredHeight !== void 0 ? declaredHeight * naturalSize.width / naturalSize.height : request.widthMode === "exactly" && request.availableWidth !== void 0 ? request.availableWidth : Math.min(naturalSize.width, request.availableWidth ?? naturalSize.width));
|
|
382
|
+
const height = declaredHeight ?? width * naturalSize.height / naturalSize.width;
|
|
383
|
+
const intrinsicMinWidth = declaredHeight !== void 0 ? declaredHeight * naturalSize.width / naturalSize.height : naturalSize.width;
|
|
384
|
+
const intrinsicMinHeight = declaredWidth !== void 0 ? declaredWidth * naturalSize.height / naturalSize.width : naturalSize.height;
|
|
385
|
+
return {
|
|
386
|
+
width,
|
|
387
|
+
height,
|
|
388
|
+
minContentWidth: hasFixedWidth ? 0 : intrinsicMinWidth,
|
|
389
|
+
minContentHeight: hasFixedHeight ? 0 : intrinsicMinHeight
|
|
390
|
+
};
|
|
391
|
+
},
|
|
392
|
+
resolve(resolveContext) {
|
|
393
|
+
const x = dimension(resolveContext.layoutBox?.x ?? declaredX, "x", 0);
|
|
394
|
+
const y = dimension(resolveContext.layoutBox?.y ?? declaredY, "y", 0);
|
|
395
|
+
let width;
|
|
396
|
+
let height;
|
|
397
|
+
if (resolveContext.layoutBox !== void 0) {
|
|
398
|
+
width = dimension(resolveContext.layoutBox.width, "width");
|
|
399
|
+
height = dimension(resolveContext.layoutBox.height, "height");
|
|
400
|
+
} else if (naturalSize === void 0) {
|
|
401
|
+
width = dimension(requestedWidth, "width");
|
|
402
|
+
height = dimension(requestedHeight, "height");
|
|
403
|
+
} else if (requestedWidth === void 0 && requestedHeight === void 0) {
|
|
404
|
+
width = naturalSize.width;
|
|
405
|
+
height = naturalSize.height;
|
|
406
|
+
} else if (requestedWidth === void 0) {
|
|
407
|
+
height = dimension(requestedHeight, "height");
|
|
408
|
+
width = height * naturalSize.width / naturalSize.height;
|
|
409
|
+
} else if (requestedHeight === void 0) {
|
|
410
|
+
width = dimension(requestedWidth, "width");
|
|
411
|
+
height = width * naturalSize.height / naturalSize.width;
|
|
412
|
+
} else {
|
|
413
|
+
width = dimension(requestedWidth, "width");
|
|
414
|
+
height = dimension(requestedHeight, "height");
|
|
415
|
+
}
|
|
416
|
+
width = dimension(width, "width");
|
|
417
|
+
height = dimension(height, "height");
|
|
418
|
+
const placement = imagePlacement(naturalSize ?? {}, fit, crop, {
|
|
419
|
+
x,
|
|
420
|
+
y,
|
|
421
|
+
width,
|
|
422
|
+
height
|
|
423
|
+
});
|
|
424
|
+
const { box } = placement;
|
|
425
|
+
const boxChangedByFit = Math.abs(box.x - x) > .01 || Math.abs(box.y - y) > .01 || Math.abs(box.width - width) > .01 || Math.abs(box.height - height) > .01;
|
|
426
|
+
const resolvedVisual = resolveVisualModel({
|
|
427
|
+
theme: resolveContext.theme,
|
|
428
|
+
style: imageStyle,
|
|
429
|
+
box,
|
|
430
|
+
...geometry === void 0 ? {} : { geometry },
|
|
431
|
+
image: true
|
|
432
|
+
}, initialVisual.fill);
|
|
433
|
+
const name = resolveContext.morphName ?? requestedName ?? placeholder?.layoutPlaceholder?.name ?? `${options.label} ${resolveContext.id - 1}`;
|
|
434
|
+
for (const [field, value] of [["name", name], ["alt", altValue]]) {
|
|
435
|
+
if (value === void 0) continue;
|
|
436
|
+
try {
|
|
437
|
+
assertXml10Characters(value);
|
|
438
|
+
} catch {
|
|
439
|
+
throw new CapabilityError("invalid-xml-character", `${options.label}.${field} contains characters not allowed in XML 1.0`, void 0, { field });
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
const angle = resolvedVisual.rotate;
|
|
443
|
+
const annotations = options.label === "Image" ? motionAnnotations(motionProps, {
|
|
444
|
+
kind: "image",
|
|
445
|
+
name,
|
|
446
|
+
...authorId === void 0 ? {} : { authorId },
|
|
447
|
+
textBody: false,
|
|
448
|
+
filled: resolvedVisual.fill.kind !== "none",
|
|
449
|
+
box,
|
|
450
|
+
rotationDegrees: angle,
|
|
451
|
+
hasBackground: resolvedVisual.fill.kind !== "none" || resolvedVisual.border !== void 0
|
|
452
|
+
}) : [];
|
|
453
|
+
const omitSpPrTransform = placeholder !== void 0 && placeholderGeometry?.hasLocalBoxOverride !== true && !hasLocalVisualOverride && !boxChangedByFit;
|
|
454
|
+
const model = {
|
|
455
|
+
image,
|
|
456
|
+
placement,
|
|
457
|
+
visual: resolvedVisual,
|
|
458
|
+
name,
|
|
459
|
+
...authorId === void 0 ? {} : { authorId },
|
|
460
|
+
...altValue === void 0 ? {} : { alt: altValue },
|
|
461
|
+
...placeholder === void 0 ? {} : { placeholder: {
|
|
462
|
+
nativeRef: placeholder.nativeRef,
|
|
463
|
+
omitSpPrTransform,
|
|
464
|
+
hasLocalFill
|
|
465
|
+
} }
|
|
466
|
+
};
|
|
467
|
+
const imageObservation = image.kind === "external" ? Object.freeze({
|
|
468
|
+
kind: "external",
|
|
469
|
+
...authorId === void 0 ? {} : { id: authorId },
|
|
470
|
+
path: resolveContext.path,
|
|
471
|
+
url: image.externalUrl,
|
|
472
|
+
placeholder: Object.freeze({
|
|
473
|
+
...authorId === void 0 ? {} : { id: authorId },
|
|
474
|
+
path: resolveContext.path,
|
|
475
|
+
url: image.externalUrl
|
|
476
|
+
})
|
|
477
|
+
}) : Object.freeze({
|
|
478
|
+
kind: "embedded",
|
|
479
|
+
contentType: image.contentType,
|
|
480
|
+
width: image.width,
|
|
481
|
+
height: image.height
|
|
482
|
+
});
|
|
483
|
+
const picture = {
|
|
484
|
+
observation: {
|
|
485
|
+
id: resolveContext.id,
|
|
486
|
+
kind: "image",
|
|
487
|
+
name,
|
|
488
|
+
box,
|
|
489
|
+
image: imageObservation
|
|
490
|
+
},
|
|
491
|
+
transform: {
|
|
492
|
+
box,
|
|
493
|
+
angle,
|
|
494
|
+
flipH: resolvedVisual.flipH,
|
|
495
|
+
flipV: resolvedVisual.flipV
|
|
496
|
+
},
|
|
497
|
+
extensions: [],
|
|
498
|
+
...annotations.length === 0 ? {} : { annotations },
|
|
499
|
+
emit(emitContext) {
|
|
500
|
+
return emitImageModel(model, emitContext);
|
|
501
|
+
},
|
|
502
|
+
paint(paintContext) {
|
|
503
|
+
return paintImageModel(model, paintContext);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
return options.resolve(model, picture);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
export { bindPicture, emitImageModel, paintImageModel, readImageSource };
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
5
|
-
import { P_NS } from "
|
|
6
|
-
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "
|
|
7
|
-
import "
|
|
1
|
+
import { pxToEmu } from "../../kernel/drawing-units.js";
|
|
2
|
+
import { matchLayoutPlaceholderKey, matchMasterPlaceholderSpec, nativePlaceholderRefSchema, resolvePlaceholderBoxFromLayers } from "../../kernel/placeholders.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
import "../../kernel/pptx-read/index.js";
|
|
5
|
+
import { P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
6
|
+
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema, ooxmlPlaceholderRoleSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
7
|
+
import { readPlaceholderTransform, readTransformXml } from "../../kernel/pptx-read/visual.js";
|
|
8
|
+
import "../../kernel/pptx-write/xml.js";
|
|
9
|
+
import { compatiblePlaceholderRoles } from "./placeholder-roles.js";
|
|
8
10
|
import { resolvePlaceholderVisualStyle } from "./style-inheritance.js";
|
|
9
|
-
// ../
|
|
11
|
+
// ../core/dist/capabilities/shared/placeholder-import.js
|
|
10
12
|
const P14_MOD_ID_EXT_URI = "{D42A27DB-BD31-4B8C-83A1-F6EECF244321}";
|
|
11
13
|
/** Finds a direct child XML element matching namespace URI and local name without mutating cursor tracking. */
|
|
12
14
|
function directElementChild(parent, namespaceUri, localName) {
|
|
@@ -67,8 +69,7 @@ function readNvPrPlaceholder(nvPr, location, diagnostics) {
|
|
|
67
69
|
"orient",
|
|
68
70
|
"hasCustomPrompt"
|
|
69
71
|
]);
|
|
70
|
-
const
|
|
71
|
-
const parsedRole = placeholderRoleSchema.safeParse(rawPh["type"] ?? "obj");
|
|
72
|
+
const parsedRole = ooxmlPlaceholderRoleSchema.safeParse(rawPh["type"]);
|
|
72
73
|
if (!parsedRole.success) {
|
|
73
74
|
diagnostics.push({
|
|
74
75
|
code: "unsupported-mechanism",
|
|
@@ -88,7 +89,6 @@ function readNvPrPlaceholder(nvPr, location, diagnostics) {
|
|
|
88
89
|
const hasPromptParsed = ooxmlBoolSchema.safeParse(rawPh["hasCustomPrompt"]);
|
|
89
90
|
const parsedNativeRef = nativePlaceholderRefSchema.safeParse({
|
|
90
91
|
type: parsedRole.data,
|
|
91
|
-
explicitType,
|
|
92
92
|
...idxParsed.success ? { idx: idxParsed.data } : {},
|
|
93
93
|
...rawPh["sz"] !== void 0 ? { size: rawPh["sz"] } : {},
|
|
94
94
|
...rawPh["orient"] !== void 0 ? { orient: rawPh["orient"] } : {},
|
|
@@ -118,7 +118,7 @@ function readNvPrPlaceholder(nvPr, location, diagnostics) {
|
|
|
118
118
|
* or must materialize its 5-layer master/layout cascade and unbind into a free slide object.
|
|
119
119
|
*/
|
|
120
120
|
function resolvePlaceholderImportClaim(args) {
|
|
121
|
-
const { context, nativeRef,
|
|
121
|
+
const { context, nativeRef, objectKind } = args;
|
|
122
122
|
const matchedKey = matchLayoutPlaceholderKey(context.layoutPlaceholders, {
|
|
123
123
|
type: nativeRef.type,
|
|
124
124
|
idx: nativeRef.idx
|
|
@@ -126,7 +126,7 @@ function resolvePlaceholderImportClaim(args) {
|
|
|
126
126
|
const layoutPlaceholder = matchedKey === void 0 ? void 0 : context.layoutPlaceholders?.[matchedKey];
|
|
127
127
|
const effectiveRole = layoutPlaceholder?.type ?? nativeRef.type;
|
|
128
128
|
const masterPlaceholder = matchMasterPlaceholderSpec(context.masterPlaceholders, effectiveRole);
|
|
129
|
-
const roleCompatible =
|
|
129
|
+
const roleCompatible = objectKind === void 0 ? true : objectKind === "audio" ? false : compatiblePlaceholderRoles[objectKind].has(effectiveRole);
|
|
130
130
|
const alreadyClaimed = matchedKey !== void 0 && context.claimedPlaceholderKeys?.has(matchedKey) === true;
|
|
131
131
|
if (matchedKey !== void 0 && layoutPlaceholder !== void 0 && roleCompatible && !alreadyClaimed) {
|
|
132
132
|
context.claimedPlaceholderKeys?.add(matchedKey);
|
|
@@ -137,10 +137,6 @@ function resolvePlaceholderImportClaim(args) {
|
|
|
137
137
|
...masterPlaceholder === void 0 ? {} : { masterPlaceholder }
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
if (allowMasterDirectFallback && matchedKey === void 0 && nativeRef.idx === 4294967295 && roleCompatible && masterPlaceholder !== void 0) return {
|
|
141
|
-
bound: true,
|
|
142
|
-
masterPlaceholder
|
|
143
|
-
};
|
|
144
140
|
const inheritanceContext = {
|
|
145
141
|
...layoutPlaceholder === void 0 ? {} : { layoutPlaceholder },
|
|
146
142
|
...masterPlaceholder === void 0 ? {} : { masterPlaceholder },
|
|
@@ -191,12 +187,46 @@ function resolveUnboundPlaceholderBox(args) {
|
|
|
191
187
|
...hasHeight ? { height: resolved.height } : {}
|
|
192
188
|
};
|
|
193
189
|
}
|
|
190
|
+
/** Reads a chart or table frame, recovering missing local components only for unbound placeholders. */
|
|
191
|
+
function readPlaceholderFrameBox(xfrm, claim, location, diagnostics) {
|
|
192
|
+
if (claim !== void 0 && !claim.bound) {
|
|
193
|
+
const { offset, extent } = readPlaceholderTransform(xfrm, location, diagnostics);
|
|
194
|
+
const box = resolveUnboundPlaceholderBox({
|
|
195
|
+
inheritanceContext: claim.inheritanceContext,
|
|
196
|
+
localBox: {
|
|
197
|
+
...offset,
|
|
198
|
+
...extent
|
|
199
|
+
},
|
|
200
|
+
requireHeight: true
|
|
201
|
+
});
|
|
202
|
+
if (box !== void 0 && box.height !== void 0) return {
|
|
203
|
+
...box,
|
|
204
|
+
height: box.height
|
|
205
|
+
};
|
|
206
|
+
emitPlaceholderUnbindDiagnostic({
|
|
207
|
+
diagnostics,
|
|
208
|
+
location,
|
|
209
|
+
retainedAs: "omitted"
|
|
210
|
+
});
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (xfrm === void 0) {
|
|
214
|
+
diagnostics.push({
|
|
215
|
+
code: "corrupt-part",
|
|
216
|
+
category: "corrupt-input",
|
|
217
|
+
disposition: "omitted",
|
|
218
|
+
location
|
|
219
|
+
});
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
return readTransformXml(xfrm, location, diagnostics);
|
|
223
|
+
}
|
|
194
224
|
/** Removes `"none"` placeholder-clear sentinels from a style record materialized onto a free object. */
|
|
195
225
|
function stripPlaceholderClearSentinels(style) {
|
|
196
226
|
const cleaned = {};
|
|
197
227
|
for (const [key, value] of Object.entries(style)) {
|
|
198
228
|
if (value === void 0) continue;
|
|
199
|
-
if ((key === "background" || key === "border" || key === "boxShadow" || key === "textShadow") && value === "none") continue;
|
|
229
|
+
if ((key === "background" || key === "border" || key === "boxShadow" || key === "textShadow" || key === "textStroke") && value === "none") continue;
|
|
200
230
|
cleaned[key] = value;
|
|
201
231
|
}
|
|
202
232
|
return cleaned;
|
|
@@ -220,7 +250,7 @@ function materializeUnboundVisualStyle(args) {
|
|
|
220
250
|
}
|
|
221
251
|
return resolved;
|
|
222
252
|
}
|
|
223
|
-
/**
|
|
253
|
+
/** Reports loss of native inheritance after materializing or omitting a page placeholder. */
|
|
224
254
|
function emitPlaceholderUnbindDiagnostic(args) {
|
|
225
255
|
args.diagnostics.push({
|
|
226
256
|
code: "compatibility-fallback",
|
|
@@ -235,4 +265,4 @@ function emitPlaceholderUnbindDiagnostic(args) {
|
|
|
235
265
|
}
|
|
236
266
|
});
|
|
237
267
|
}
|
|
238
|
-
export { directElementChild, directPlaceholderElement, emitPlaceholderUnbindDiagnostic, isPlaceholderGraphicFrameElement, isPlaceholderPicElement, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, roundRectBorderRadiusForBox, stripPlaceholderClearSentinels };
|
|
268
|
+
export { directElementChild, directPlaceholderElement, emitPlaceholderUnbindDiagnostic, isPlaceholderGraphicFrameElement, isPlaceholderPicElement, isPlaceholderSpElement, materializeUnboundVisualStyle, readNvPrPlaceholder, readPlaceholderFrameBox, resolvePlaceholderImportClaim, resolveUnboundPlaceholderBox, roundRectBorderRadiusForBox, stripPlaceholderClearSentinels };
|