@officedk/pptxdk 0.1.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 +14 -76
- package/dist/build.js +69 -97
- package/dist/cli.js +1 -1
- 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/core/dist/capabilities/box/box-codegen.js +83 -0
- package/dist/core/dist/capabilities/box/box-declaration.js +32 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +32 -29
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +17 -22
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +1025 -471
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +3 -3
- 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 +216 -212
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +228 -171
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +23 -10
- 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 +30 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +160 -89
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +4 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +4 -4
- 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 +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +15 -3
- 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 +5 -5
- 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 +194 -133
- 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/core/dist/capabilities/group/group-codegen.js +73 -0
- package/dist/core/dist/capabilities/group/group-declaration.js +41 -0
- package/dist/core/dist/capabilities/group/group-import.js +608 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +4 -3
- package/dist/core/dist/capabilities/group/group.js +260 -0
- 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/core/dist/capabilities/line/line-codegen.js +88 -0
- package/dist/core/dist/capabilities/line/line-declaration.js +78 -0
- package/dist/core/dist/capabilities/line/line-import.js +424 -0
- package/dist/core/dist/capabilities/line/line-xml.js +9 -0
- package/dist/core/dist/capabilities/line/line.js +329 -0
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/core/dist/capabilities/masters/masters-codegen.js +50 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +35 -47
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +97 -51
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +653 -102
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +317 -163
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +9 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +357 -108
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +5 -7
- 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 +12 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +20 -42
- 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/core/dist/capabilities/placeholder/placeholder-codegen.js +44 -0
- package/dist/core/dist/capabilities/placeholder/placeholder-schemas.js +31 -0
- package/dist/core/dist/capabilities/placeholder/placeholder.js +394 -0
- 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 +100 -103
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/core/dist/capabilities/shared/font/font-embedding.js +118 -0
- package/dist/core/dist/capabilities/shared/font/font-engine.js +855 -0
- package/dist/core/dist/capabilities/shared/font/font-import.js +805 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/core/dist/capabilities/shared/font/font.js +72 -0
- package/dist/{capabilities/dist/shape/shape-codegen.js → core/dist/capabilities/shared/geometry-codegen.js} +4 -69
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +384 -123
- 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 -56
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +49 -61
- 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/core/dist/capabilities/shared/motion-api.js +770 -0
- package/dist/core/dist/capabilities/shared/motion-schemas.js +353 -0
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +313 -168
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/core/dist/capabilities/shared/placeholder-import.js +268 -0
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1221 -188
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/core/dist/capabilities/shared/rich-text-codegen.js +119 -0
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/core/dist/capabilities/shared/shape-declaration.js +45 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +26 -24
- package/dist/core/dist/capabilities/shared/text-declaration.js +31 -0
- package/dist/core/dist/capabilities/shared/text-schemas.js +241 -0
- package/dist/core/dist/capabilities/shared/text-service.js +2563 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +441 -137
- 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 +12 -7
- package/dist/core/dist/capabilities/slide-background/slide-background-xml.js +33 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +61 -50
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/core/dist/capabilities/table/table-codegen.js +118 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +116 -84
- package/dist/core/dist/capabilities/table/table-schemas.js +337 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +13 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +284 -192
- 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 +103 -111
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +13 -16
- 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 +16 -10
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +152 -140
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +27 -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 +173 -90
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/core/dist/import/import.js +547 -0
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +404 -328
- 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} +9 -6
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +105 -127
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +225 -142
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/core/dist/kernel/codegen.js +97 -0
- 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} +3 -2
- package/dist/core/dist/kernel/diagnostics.js +370 -0
- package/dist/core/dist/kernel/document-internals.js +26 -0
- package/dist/core/dist/{document.js → kernel/document.js} +23 -13
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/kernel/font-seal.js +204 -0
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +21 -18
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +177 -72
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/kernel/input-values.js +62 -0
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +5 -10
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +33 -44
- package/dist/core/dist/kernel/layout.js +339 -0
- package/dist/core/dist/kernel/masters.js +171 -0
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/kernel/placeholders.js +289 -0
- 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 +33 -29
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +71 -12
- 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 +6 -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 +182 -41
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +175 -88
- package/dist/core/dist/kernel/pptx-read/xml-fragments.js +320 -0
- 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} +133 -290
- package/dist/core/dist/{query.js → kernel/query.js} +76 -37
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +2 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +797 -409
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/kernel/stage-options.js +312 -0
- package/dist/core/dist/{theme.js → kernel/theme.js} +399 -289
- package/dist/core/dist/kernel/transform-geometry.js +72 -0
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/document-C0lPlH-L.d.ts +1442 -0
- package/dist/index-B9_OUeA-.d.ts +2238 -0
- package/dist/index-BJEzQxWV.d.ts +75 -0
- package/dist/index-DA9flrlR.d.ts +146 -0
- package/dist/index-GSt0t9VO.d.ts +54 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +75 -61
- package/dist/node.d.ts +37 -35
- package/dist/node.js +125 -51
- package/dist/pptxdk/src/cli-commands.js +79 -81
- package/dist/pptxdk/src/compose.js +32 -24
- 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 +229 -77
- package/dist/preview/dist/options.js +17 -26
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +1090 -0
- package/dist/preview.d.ts +6 -3
- package/dist/preview.js +8 -24
- 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/react/dist/author/text-elements.js +64 -0
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +376 -37
- package/dist/react/dist/elements.js +30 -4
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +47 -12
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +26 -26
- package/dist/react.d.ts +174 -50
- package/dist/react.js +31 -27
- package/dist/stages-DYHSHKt4.d.ts +80 -0
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -14
- package/package.json +6 -8
- package/README.md +0 -49
- package/dist/capabilities/dist/all.js +0 -32
- package/dist/capabilities/dist/box/box-codegen.js +0 -51
- package/dist/capabilities/dist/box/box-declaration.js +0 -31
- 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 -148
- package/dist/capabilities/dist/font/font-embedding.js +0 -289
- package/dist/capabilities/dist/font/font-family.js +0 -10
- package/dist/capabilities/dist/font/font-import.js +0 -302
- package/dist/capabilities/dist/font/font.js +0 -25
- package/dist/capabilities/dist/group/group-codegen.js +0 -51
- package/dist/capabilities/dist/group/group-declaration.js +0 -42
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/group/group-import.js +0 -319
- package/dist/capabilities/dist/group/group.js +0 -211
- package/dist/capabilities/dist/image/image-codegen.js +0 -94
- 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 -472
- package/dist/capabilities/dist/masters/masters-codegen.js +0 -21
- package/dist/capabilities/dist/motion/motion-api.js +0 -527
- package/dist/capabilities/dist/motion/motion-schemas.js +0 -216
- 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-codegen.js +0 -23
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -12
- package/dist/capabilities/dist/placeholder/placeholder.js +0 -292
- package/dist/capabilities/dist/shape/shape-declaration.js +0 -57
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -579
- package/dist/capabilities/dist/shared/placeholder-import.js +0 -113
- package/dist/capabilities/dist/shared/style-parse.js +0 -11
- package/dist/capabilities/dist/shared/text-schemas.js +0 -216
- package/dist/capabilities/dist/shared/text-service.js +0 -1883
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +0 -21
- package/dist/capabilities/dist/table/table-codegen.js +0 -81
- package/dist/capabilities/dist/table/table-schemas.js +0 -279
- package/dist/capabilities/dist/text/text-codegen.js +0 -129
- package/dist/capabilities/dist/text/text-declaration.js +0 -19
- package/dist/capabilities/dist/text/text-elements.js +0 -38
- package/dist/capabilities/dist/text/text-import.js +0 -1077
- package/dist/capability-D_xeNVIw.d.ts +0 -29496
- package/dist/codegen/dist/types.js +0 -49
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -13
- package/dist/core/dist/diagnostics.js +0 -21
- package/dist/core/dist/document-internals.js +0 -13
- package/dist/core/dist/input-values.js +0 -45
- package/dist/core/dist/layout.js +0 -299
- package/dist/core/dist/masters.js +0 -169
- package/dist/core/dist/placeholders.js +0 -213
- package/dist/core/dist/stage-options.js +0 -67
- package/dist/document-BHPUODPP.d.ts +0 -27759
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/import.js +0 -504
- package/dist/import/dist/index.js +0 -16
- package/dist/import/dist/xml-fragments.js +0 -36
- package/dist/index-B5m3hqjC.d.ts +0 -7
- package/dist/index-CCy-Yo8G.d.ts +0 -1208
- package/dist/index-DpxcZ4Gs.d.ts +0 -725
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/preview-Cfw0QdMM.d.ts +0 -86
- package/dist/transition-Cips9wma.d.ts +0 -82
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import {
|
|
3
|
-
import "
|
|
4
|
-
import {
|
|
5
|
-
import "
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import "
|
|
10
|
-
import {
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { pxToEmu } from "../../kernel/drawing-units.js";
|
|
3
|
+
import { borderObjectShape, borderValueSchema, imageBackgroundSchema, linearGradientSchema, radialGradientSchema, shadowSchema, visualStyleShape } from "../../kernel/theme.js";
|
|
4
|
+
import { readImage, readImageBytes } from "./image-decode.js";
|
|
5
|
+
import "../../kernel/capability.js";
|
|
6
|
+
import "../../kernel/pptx-read/index.js";
|
|
7
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
8
|
+
import { arrowTypeSchema, readBlipFill as readBlipFill$1, readDrawingColor, readEffectList, readGradientFill, readLineBorder, readTransformXml } from "../../kernel/pptx-read/visual.js";
|
|
9
|
+
import { defineCanvasMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
10
|
+
import { resolvedColorXml, xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
11
|
+
import { finishResolveWork } from "../../kernel/resolve-work.js";
|
|
11
12
|
import { evaluateGeometry, readCustomGeometryXml, readPresetGeometryXml, resolveGeometry, resolvedGeometryXml, shadeHex } from "./geometry.js";
|
|
12
13
|
import { z } from "zod";
|
|
13
|
-
// ../
|
|
14
|
+
// ../core/dist/capabilities/shared/visual.js
|
|
14
15
|
const imageRelationship = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
|
|
15
16
|
function linearGradient(angle, ...stops) {
|
|
16
17
|
return {
|
|
@@ -31,27 +32,51 @@ function radialGradient(...stops) {
|
|
|
31
32
|
})
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
const
|
|
35
|
+
const lineEndStyleObjectSchema = z.strictObject({
|
|
36
|
+
startArrow: arrowTypeSchema.optional(),
|
|
37
|
+
endArrow: arrowTypeSchema.optional()
|
|
38
|
+
});
|
|
39
|
+
lineEndStyleObjectSchema.readonly();
|
|
40
|
+
const rawLineStrokeObjectSchema = z.strictObject({
|
|
41
|
+
...borderObjectShape,
|
|
35
42
|
startArrow: arrowTypeSchema.optional(),
|
|
36
43
|
endArrow: arrowTypeSchema.optional()
|
|
37
44
|
}).readonly();
|
|
38
|
-
|
|
39
|
-
Object.keys(
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
const lineStrokeValueSchema = z.union([z.literal("none"), rawLineStrokeObjectSchema]);
|
|
46
|
+
Object.keys(lineEndStyleObjectSchema.shape);
|
|
47
|
+
Object.keys(visualStyleShape);
|
|
48
|
+
function invalid(code, message, field) {
|
|
49
|
+
throw new CapabilityError(code, message, void 0, { field });
|
|
42
50
|
}
|
|
43
51
|
function isRecord(value) {
|
|
44
52
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
45
53
|
}
|
|
46
|
-
function finite(value, label) {
|
|
47
|
-
if (typeof value !== "number" || !Number.isFinite(value)) invalid("invalid-visual-style", `${label} must be a finite number
|
|
54
|
+
function finite(value, label, field = `style.${label}`) {
|
|
55
|
+
if (typeof value !== "number" || !Number.isFinite(value)) invalid("invalid-visual-style", `${label} must be a finite number`, field);
|
|
48
56
|
return value;
|
|
49
57
|
}
|
|
50
58
|
function emu(value, label, allowZero = true, signed = false) {
|
|
51
59
|
const converted = pxToEmu(value);
|
|
52
|
-
if (!
|
|
60
|
+
if (!allowZero && !signed) {
|
|
61
|
+
if (!Number.isFinite(value) || value === 0 || converted === 0) invalid("invalid-visual-style", `Computed ${label} is 0px; ${label} must be greater than 0px`, `style.${label}`);
|
|
62
|
+
if (value < 0 || converted < 1) invalid("invalid-visual-style", `Computed ${label} is ${value}px; ${label} must be greater than 0px`, `style.${label}`);
|
|
63
|
+
}
|
|
64
|
+
if (!Number.isSafeInteger(converted) || !signed && converted < (allowZero ? 0 : 1) || !signed && converted > 2147483647) invalid("invalid-visual-style", `${label} must be within writable DrawingML range after conversion`, `style.${label}`);
|
|
53
65
|
return converted;
|
|
54
66
|
}
|
|
67
|
+
/** Validates that a visible object box has valid DrawingML EMU extents during resolve. */
|
|
68
|
+
function assertVisualBoxExtent(box, options) {
|
|
69
|
+
emu(box.x, "x", true, true);
|
|
70
|
+
emu(box.y, "y", true, true);
|
|
71
|
+
if (options?.allowSingleZeroExtent === true) {
|
|
72
|
+
const cx = emu(box.width, "width", true);
|
|
73
|
+
const cy = emu(box.height, "height", true);
|
|
74
|
+
if (cx === 0 && cy === 0) invalid("invalid-visual-style", "Computed width and height are both 0px; at least one axis must be greater than 0px");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
emu(box.width, "width", false);
|
|
78
|
+
emu(box.height, "height", false);
|
|
79
|
+
}
|
|
55
80
|
function lineWidthEmu(value) {
|
|
56
81
|
const converted = pxToEmu(value);
|
|
57
82
|
if (!Number.isSafeInteger(converted) || converted < 1 || converted > 20116800) invalid("invalid-visual-style", "borderWidth must be within the DrawingML line width range of 1 to 20116800 EMU after conversion");
|
|
@@ -79,6 +104,7 @@ function resolveShadow(theme, value, label) {
|
|
|
79
104
|
invalid("invalid-shadow", `${label}.blur and distance must be non-negative lengths`);
|
|
80
105
|
}
|
|
81
106
|
if (key === "angle") finite(value[key], `${label}.angle`);
|
|
107
|
+
if (key === "color") invalid("invalid-color", issue?.message ?? `${label}.color is invalid`);
|
|
82
108
|
invalid("invalid-shadow", issue?.message ?? `${label} is invalid`);
|
|
83
109
|
}
|
|
84
110
|
const blur = parsed.data.blur ?? 4;
|
|
@@ -105,22 +131,26 @@ function textShadowXml(theme, value) {
|
|
|
105
131
|
}
|
|
106
132
|
const gradientSchema = z.union([linearGradientSchema, radialGradientSchema]).refine((value) => value.stops.length >= 2);
|
|
107
133
|
/** Resolves and validates a linear or radial gradient declaration against a ThemeContext. */
|
|
108
|
-
function resolveGradientSpec(theme, image, opacity) {
|
|
134
|
+
function resolveGradientSpec(theme, image, opacity, field = "style.background") {
|
|
109
135
|
const parsed = gradientSchema.safeParse(image);
|
|
110
136
|
if (!parsed.success) {
|
|
111
137
|
const issue = parsed.error.issues[0];
|
|
112
|
-
if (issue?.path[0] === "angle" && isRecord(image)) finite(image["angle"],
|
|
138
|
+
if (issue?.path[0] === "angle" && isRecord(image)) finite(image["angle"], `${field}.angle`, `${field}.angle`);
|
|
113
139
|
if (issue?.path[0] === "stops" && isRecord(image) && Array.isArray(image["stops"])) {
|
|
114
140
|
const idx = typeof issue.path[1] === "number" ? issue.path[1] : void 0;
|
|
115
141
|
if (idx !== void 0 && issue.path[2] === "position") {
|
|
116
142
|
const stop = image["stops"][idx];
|
|
117
|
-
if (isRecord(stop))
|
|
143
|
+
if (isRecord(stop)) {
|
|
144
|
+
const positionField = `${field}.stops.${idx}.position`;
|
|
145
|
+
finite(stop["position"], positionField, positionField);
|
|
146
|
+
}
|
|
118
147
|
}
|
|
119
148
|
}
|
|
120
|
-
|
|
149
|
+
if (parsed.error.issues.some((entry) => entry.path[0] === "stops" && entry.path[2] === "color" || entry.code === "invalid_union" && entry.errors.some((branch) => branch.some((sub) => sub.path[0] === "stops" && sub.path[2] === "color")))) invalid("invalid-color", "Gradient stop color is invalid");
|
|
150
|
+
invalid("invalid-gradient", "backgroundImage must be a linear or radial gradient with at least two color stops", zodIssueField(issue, field));
|
|
121
151
|
}
|
|
122
152
|
const stops = parsed.data.stops.map((stop, index) => {
|
|
123
|
-
if (stop.position < 0 || stop.position > 1) invalid("invalid-gradient", `position for gradient stop ${index + 1} must be between 0 and 1`);
|
|
153
|
+
if (stop.position < 0 || stop.position > 1) invalid("invalid-gradient", `position for gradient stop ${index + 1} must be between 0 and 1`, `${field}.stops.${index}.position`);
|
|
124
154
|
const color = withOpacity(theme.resolveColor(stop.color), opacity);
|
|
125
155
|
return {
|
|
126
156
|
position: stop.position,
|
|
@@ -149,18 +179,37 @@ function gradientFillXml(gradient) {
|
|
|
149
179
|
function gradientStopsSvg(stops) {
|
|
150
180
|
return [...stops].sort((a, b) => a.position - b.position).map((stop) => `<stop offset="${roundSvgNumber(stop.position * 100)}%" stop-color="#${stop.color.hex}" stop-opacity="${roundSvgNumber(stop.color.alpha ?? 1)}"/>`).join("");
|
|
151
181
|
}
|
|
182
|
+
function isFinitePositiveBox(box) {
|
|
183
|
+
return Number.isFinite(box.x) && Number.isFinite(box.y) && Number.isFinite(box.width) && Number.isFinite(box.height) && box.width > 1e-6 && box.height > 1e-6;
|
|
184
|
+
}
|
|
185
|
+
function isFiniteSingleZeroBox(box) {
|
|
186
|
+
return Number.isFinite(box.x) && Number.isFinite(box.y) && Number.isFinite(box.width) && Number.isFinite(box.height) && box.width >= 0 && box.height >= 0 && (box.width > 1e-6 || box.height > 1e-6);
|
|
187
|
+
}
|
|
152
188
|
/** Generates deterministic SVG `<linearGradient>` or `<radialGradient>` definition markup. */
|
|
153
|
-
function gradientDefSvg(id, gradient) {
|
|
189
|
+
function gradientDefSvg(id, gradient, screenBox) {
|
|
154
190
|
const stops = gradientStopsSvg(gradient.stops);
|
|
155
191
|
switch (gradient.kind) {
|
|
156
192
|
case "linear-gradient": {
|
|
157
|
-
const rad = gradient.angle * Math.PI / 180;
|
|
193
|
+
const rad = (Number.isFinite(gradient.angle) ? gradient.angle % 360 : 0) * Math.PI / 180;
|
|
158
194
|
const dx = Math.sin(rad);
|
|
159
195
|
const dy = -Math.cos(rad);
|
|
196
|
+
if (screenBox !== void 0) {
|
|
197
|
+
const cx = screenBox.x + screenBox.width / 2;
|
|
198
|
+
const cy = screenBox.y + screenBox.height / 2;
|
|
199
|
+
const span = (Math.abs(dx) * screenBox.width + Math.abs(dy) * screenBox.height) / 2;
|
|
200
|
+
return `<linearGradient id="${id}" gradientUnits="userSpaceOnUse" x1="${roundSvgNumber(cx - dx * span)}" y1="${roundSvgNumber(cy - dy * span)}" x2="${roundSvgNumber(cx + dx * span)}" y2="${roundSvgNumber(cy + dy * span)}">${stops}</linearGradient>`;
|
|
201
|
+
}
|
|
160
202
|
const halfSpan = (Math.abs(dx) + Math.abs(dy)) / 2;
|
|
161
|
-
|
|
203
|
+
const x1Val = .5 - dx * halfSpan;
|
|
204
|
+
const y1Val = .5 - dy * halfSpan;
|
|
205
|
+
const x2Val = .5 + dx * halfSpan;
|
|
206
|
+
const y2Val = .5 + dy * halfSpan;
|
|
207
|
+
const validVec = Number.isFinite(x1Val) && Number.isFinite(y1Val) && Number.isFinite(x2Val) && Number.isFinite(y2Val) && Math.hypot(x2Val - x1Val, y2Val - y1Val) > 1e-6;
|
|
208
|
+
return `<linearGradient id="${id}" gradientUnits="objectBoundingBox" x1="${validVec ? roundSvgNumber(x1Val) : "0"}" y1="${validVec ? roundSvgNumber(y1Val) : "0"}" x2="${validVec ? roundSvgNumber(x2Val) : "1"}" y2="${validVec ? roundSvgNumber(y2Val) : "0"}">${stops}</linearGradient>`;
|
|
162
209
|
}
|
|
163
|
-
case "radial-gradient":
|
|
210
|
+
case "radial-gradient":
|
|
211
|
+
if (screenBox !== void 0) return `<radialGradient id="${id}" gradientUnits="userSpaceOnUse" gradientTransform="${`translate(${roundSvgNumber(screenBox.x)} ${roundSvgNumber(screenBox.y)}) scale(${roundSvgNumber(screenBox.width)} ${roundSvgNumber(screenBox.height)})`}" cx="0.5" cy="0.5" r="0.707107">${stops}</radialGradient>`;
|
|
212
|
+
return `<radialGradient id="${id}" gradientUnits="objectBoundingBox" cx="0.5" cy="0.5" r="0.707107">${stops}</radialGradient>`;
|
|
164
213
|
default: return gradient;
|
|
165
214
|
}
|
|
166
215
|
}
|
|
@@ -177,77 +226,182 @@ function rotationUnits(style) {
|
|
|
177
226
|
units
|
|
178
227
|
};
|
|
179
228
|
}
|
|
180
|
-
function
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
229
|
+
function* resolveImageFillSource(source) {
|
|
230
|
+
if (typeof source === "object" && "externalUrl" in source && typeof source.externalUrl === "string") return {
|
|
231
|
+
kind: "external",
|
|
232
|
+
externalUrl: source.externalUrl
|
|
233
|
+
};
|
|
234
|
+
if (source instanceof URL && (source.protocol === "http:" || source.protocol === "https:")) return {
|
|
235
|
+
kind: "external",
|
|
236
|
+
externalUrl: source.toString()
|
|
237
|
+
};
|
|
238
|
+
if (typeof source === "string" && (source.startsWith("http://") || source.startsWith("https://"))) return {
|
|
239
|
+
kind: "external",
|
|
240
|
+
externalUrl: source
|
|
241
|
+
};
|
|
242
|
+
return {
|
|
243
|
+
kind: "embedded",
|
|
244
|
+
...yield* readImage(source)
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function resolvePositionCoordinate(value) {
|
|
248
|
+
if (value === void 0) return .5;
|
|
249
|
+
if (typeof value === "number") return Math.max(0, Math.min(1, value));
|
|
250
|
+
const parsed = Number.parseFloat(value.slice(0, -1));
|
|
251
|
+
return Number.isFinite(parsed) ? Math.max(0, Math.min(1, parsed / 100)) : .5;
|
|
252
|
+
}
|
|
253
|
+
function resolveImageBackgroundPosition(position) {
|
|
254
|
+
if (position === void 0) return {
|
|
255
|
+
x: .5,
|
|
256
|
+
y: .5
|
|
257
|
+
};
|
|
258
|
+
if (typeof position === "string") switch (position) {
|
|
259
|
+
case "center": return {
|
|
260
|
+
x: .5,
|
|
261
|
+
y: .5
|
|
262
|
+
};
|
|
263
|
+
case "top": return {
|
|
264
|
+
x: .5,
|
|
265
|
+
y: 0
|
|
266
|
+
};
|
|
267
|
+
case "bottom": return {
|
|
268
|
+
x: .5,
|
|
269
|
+
y: 1
|
|
270
|
+
};
|
|
271
|
+
case "left": return {
|
|
272
|
+
x: 0,
|
|
273
|
+
y: .5
|
|
274
|
+
};
|
|
275
|
+
case "right": return {
|
|
276
|
+
x: 1,
|
|
277
|
+
y: .5
|
|
278
|
+
};
|
|
279
|
+
case "top left": return {
|
|
280
|
+
x: 0,
|
|
281
|
+
y: 0
|
|
282
|
+
};
|
|
283
|
+
case "top right": return {
|
|
284
|
+
x: 1,
|
|
285
|
+
y: 0
|
|
286
|
+
};
|
|
287
|
+
case "bottom left": return {
|
|
288
|
+
x: 0,
|
|
289
|
+
y: 1
|
|
290
|
+
};
|
|
291
|
+
case "bottom right": return {
|
|
292
|
+
x: 1,
|
|
293
|
+
y: 1
|
|
294
|
+
};
|
|
295
|
+
default: return position;
|
|
201
296
|
}
|
|
202
|
-
|
|
297
|
+
return {
|
|
298
|
+
x: resolvePositionCoordinate(position.x),
|
|
299
|
+
y: resolvePositionCoordinate(position.y)
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
/** Validates and resolves `{ image, fit?, position?, opacity? }` background declarations. */
|
|
303
|
+
function* resolveImageBackgroundSpec(spec, opacity) {
|
|
304
|
+
const parsed = imageBackgroundSchema.safeParse(spec);
|
|
305
|
+
if (!parsed.success) {
|
|
306
|
+
const issue = parsed.error.issues[0];
|
|
307
|
+
if (issue?.code === "unrecognized_keys" && issue.keys[0] !== void 0) invalid("invalid-visual-style", `background image contains unsupported parameter ${issue.keys[0]}`);
|
|
308
|
+
invalid("invalid-visual-style", issue?.message ?? "Invalid image background declaration");
|
|
309
|
+
}
|
|
310
|
+
const source = yield* resolveImageFillSource(parsed.data.image);
|
|
311
|
+
const combinedOpacity = (parsed.data.opacity ?? 1) * (opacity ?? 1);
|
|
312
|
+
return {
|
|
313
|
+
kind: "image",
|
|
314
|
+
source,
|
|
315
|
+
fit: parsed.data.fit ?? "fill",
|
|
316
|
+
position: resolveImageBackgroundPosition(parsed.data.position),
|
|
317
|
+
...combinedOpacity < 1 ? { opacity: combinedOpacity } : {}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/** Resolves a unified `BackgroundValue` (`"none"`, color, gradient, or `{ image, fit?, position?, opacity? }`). */
|
|
321
|
+
function* resolveBackgroundValue(theme, value, opacity) {
|
|
322
|
+
if (value === void 0 || value === "none") return { kind: "none" };
|
|
323
|
+
if (isRecord(value) && Object.hasOwn(value, "image")) return yield* resolveImageBackgroundSpec(value, opacity);
|
|
324
|
+
if (isRecord(value) && (value["type"] === "linear-gradient" || value["type"] === "radial-gradient")) return resolveGradientSpec(theme, value, opacity);
|
|
203
325
|
return {
|
|
204
326
|
kind: "solid",
|
|
205
|
-
color: withOpacity(theme.resolveColor(
|
|
327
|
+
color: withOpacity(theme.resolveColor(value), opacity)
|
|
206
328
|
};
|
|
207
329
|
}
|
|
208
|
-
function
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
|
|
330
|
+
function* resolveVisualFill(theme, style, opacity) {
|
|
331
|
+
try {
|
|
332
|
+
return yield* resolveBackgroundValue(theme, style["background"], opacity);
|
|
333
|
+
} catch (error) {
|
|
334
|
+
if (error instanceof CapabilityError && error.details?.["field"] === void 0 && Object.hasOwn(style, "background") && style["background"] !== void 0) throw new CapabilityError(error.code, error.message, error.path, {
|
|
335
|
+
...error.details,
|
|
336
|
+
field: "style.background"
|
|
337
|
+
});
|
|
338
|
+
throw error;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function resolveStrokeValue(theme, rawStroke, opacity, schema, label) {
|
|
342
|
+
if (rawStroke === void 0 || rawStroke === "none") return;
|
|
343
|
+
const parsed = schema.safeParse(rawStroke);
|
|
344
|
+
if (!parsed.success || parsed.data === "none") {
|
|
345
|
+
const issue = parsed.success ? void 0 : parsed.error.issues[0];
|
|
346
|
+
if (issue?.code === "unrecognized_keys" && issue.keys[0] !== void 0) invalid("invalid-visual-style", `${label} contains unsupported property ${issue.keys[0]}`, zodIssueField(issue, `style.${label}`));
|
|
347
|
+
if (issue?.path[0] === "color" || issue?.code === "invalid_union" && issue.errors.some((branch) => branch.some((sub) => sub.path[0] === "color"))) invalid("invalid-color", issue?.message ?? `Invalid ${label} color`);
|
|
348
|
+
invalid("invalid-visual-style", issue?.message ?? `Invalid ${label} declaration`);
|
|
349
|
+
}
|
|
350
|
+
const width = parsed.data.width ?? 1;
|
|
351
|
+
if (width === 0) return;
|
|
220
352
|
lineWidthEmu(width);
|
|
353
|
+
const startArrow = parsed.data.startArrow;
|
|
354
|
+
const endArrow = parsed.data.endArrow;
|
|
221
355
|
return {
|
|
222
|
-
color: withOpacity(theme.resolveColor(color), opacity),
|
|
356
|
+
color: withOpacity(theme.resolveColor(parsed.data.color), opacity),
|
|
223
357
|
width,
|
|
224
|
-
style:
|
|
225
|
-
...
|
|
226
|
-
...
|
|
358
|
+
style: parsed.data.style ?? "solid",
|
|
359
|
+
...startArrow === void 0 ? {} : { startArrow },
|
|
360
|
+
...endArrow === void 0 ? {} : { endArrow }
|
|
227
361
|
};
|
|
228
362
|
}
|
|
363
|
+
/** Validates and resolves top-level `Line.stroke` into a closed `ResolvedBorder` (defaulting to solid `tx1` 1px when omitted). */
|
|
364
|
+
function resolveLineStroke(theme, rawStroke, opacity) {
|
|
365
|
+
return resolveStrokeValue(theme, rawStroke === void 0 ? {
|
|
366
|
+
color: "tx1",
|
|
367
|
+
width: 1,
|
|
368
|
+
style: "solid"
|
|
369
|
+
} : rawStroke, opacity, lineStrokeValueSchema, "stroke");
|
|
370
|
+
}
|
|
371
|
+
function resolveTextStroke(theme, value) {
|
|
372
|
+
return resolveStrokeValue(theme, value, void 0, borderValueSchema, "textStroke");
|
|
373
|
+
}
|
|
374
|
+
function resolveVisualBorder(theme, style, opacity) {
|
|
375
|
+
if (!Object.hasOwn(style, "border") || style["border"] === void 0) return;
|
|
376
|
+
return resolveStrokeValue(theme, style["border"], opacity, borderValueSchema, "border");
|
|
377
|
+
}
|
|
229
378
|
/** Determines whether a Box style specifies visible fill, border, or shadow. */
|
|
230
379
|
function hasVisibleBoxStyle(style) {
|
|
231
380
|
if (style === void 0 || typeof style !== "object" || style === null) return false;
|
|
232
|
-
const
|
|
233
|
-
return style["
|
|
381
|
+
const hasNewBorder = style["border"] !== void 0 && style["border"] !== "none" && !(typeof style["border"] === "object" && style["border"] !== null && style["border"]["width"] === 0);
|
|
382
|
+
return style["background"] !== void 0 && style["background"] !== "none" || hasNewBorder || style["boxShadow"] !== void 0 && style["boxShadow"] !== "none";
|
|
234
383
|
}
|
|
235
384
|
/**
|
|
236
385
|
* Validates and resolves visual styles, geometry, fill, border, shadow, softEdge, and transforms
|
|
237
386
|
* into a closed strongly-typed model consumed exhaustively by emitVisualModel and paintVisualModel.
|
|
238
387
|
*/
|
|
239
|
-
function resolveVisualModel(options) {
|
|
388
|
+
function resolveVisualModel(options, boundFill) {
|
|
389
|
+
return finishResolveWork(bindVisualModel(options, boundFill.kind === "image" ? boundFill : void 0));
|
|
390
|
+
}
|
|
391
|
+
function* bindVisualModel(options, imageFill) {
|
|
240
392
|
const { theme, style, box } = options;
|
|
241
|
-
const
|
|
242
|
-
|
|
393
|
+
for (const [name, value] of [["flipH", style["flipH"]], ["flipV", style["flipV"]]]) if (value !== void 0 && typeof value !== "boolean") invalid("invalid-visual-style", `${name} must be a boolean`);
|
|
394
|
+
const flipH = Boolean(style["flipH"]);
|
|
395
|
+
const flipV = Boolean(style["flipV"]);
|
|
243
396
|
const opacity = style["opacity"] === void 0 ? void 0 : finite(style["opacity"], "opacity");
|
|
244
397
|
if (opacity !== void 0 && (opacity < 0 || opacity > 1)) invalid("invalid-visual-style", "opacity must be a number between 0 and 1");
|
|
245
|
-
if (options.image &&
|
|
398
|
+
if (options.image && style["borderRadius"] !== void 0) invalid("unsupported-style-combination", "Image does not support borderRadius");
|
|
246
399
|
const radius = style["borderRadius"] === void 0 ? void 0 : finite(style["borderRadius"], "borderRadius");
|
|
247
400
|
if (radius !== void 0 && radius < 0) invalid("invalid-visual-style", "borderRadius must be a non-negative length");
|
|
248
|
-
const fill = resolveVisualFill(theme, style,
|
|
249
|
-
const border = resolveVisualBorder(theme, style, opacity);
|
|
250
|
-
const
|
|
401
|
+
const fill = imageFill ?? (yield* resolveVisualFill(theme, style, opacity));
|
|
402
|
+
const border = options.borderOverride !== void 0 ? options.borderOverride ?? void 0 : resolveVisualBorder(theme, style, opacity);
|
|
403
|
+
const explicitNoShadow = style["boxShadow"] === "none";
|
|
404
|
+
const boxShadow = style["boxShadow"] === void 0 || explicitNoShadow ? void 0 : resolveShadow(theme, style["boxShadow"], "boxShadow");
|
|
251
405
|
let softEdge;
|
|
252
406
|
if (style["softEdge"] !== void 0) {
|
|
253
407
|
const rawSoft = finite(style["softEdge"], "softEdge");
|
|
@@ -257,14 +411,13 @@ function resolveVisualModel(options) {
|
|
|
257
411
|
softEdge = rawSoft;
|
|
258
412
|
}
|
|
259
413
|
}
|
|
260
|
-
const hasVisibleStyle =
|
|
414
|
+
const hasVisibleStyle = hasVisibleBoxStyle(style) || border !== void 0;
|
|
261
415
|
const layoutOnlyWhenInvisible = Boolean(options.layoutOnlyWhenInvisible);
|
|
262
416
|
const resolvedGeometry = resolveGeometry({
|
|
263
417
|
geometry: options.geometry,
|
|
264
418
|
borderRadius: layoutOnlyWhenInvisible && !hasVisibleStyle ? void 0 : radius,
|
|
265
419
|
box
|
|
266
420
|
});
|
|
267
|
-
warnings.push(...resolvedGeometry.warnings);
|
|
268
421
|
const rotation = rotationUnits(style);
|
|
269
422
|
return {
|
|
270
423
|
box,
|
|
@@ -274,23 +427,23 @@ function resolveVisualModel(options) {
|
|
|
274
427
|
...border === void 0 ? {} : { border },
|
|
275
428
|
...opacity === void 0 ? {} : { opacity },
|
|
276
429
|
...boxShadow === void 0 ? {} : { boxShadow },
|
|
430
|
+
...explicitNoShadow ? { explicitNoShadow: true } : {},
|
|
277
431
|
...softEdge === void 0 ? {} : { softEdge },
|
|
278
432
|
rotate: rotation.degrees,
|
|
279
433
|
...rotation.units === void 0 ? {} : { rotationUnits: rotation.units },
|
|
280
|
-
flipH
|
|
281
|
-
flipV
|
|
434
|
+
flipH,
|
|
435
|
+
flipV,
|
|
282
436
|
hasVisibleStyle,
|
|
283
|
-
layoutOnlyWhenInvisible
|
|
284
|
-
warnings
|
|
437
|
+
layoutOnlyWhenInvisible
|
|
285
438
|
};
|
|
286
439
|
}
|
|
287
|
-
function emitFillXml(fill, registerResource) {
|
|
440
|
+
function emitFillXml(fill, registerResource, box) {
|
|
288
441
|
switch (fill.kind) {
|
|
289
442
|
case "none": return "<a:noFill/>";
|
|
290
443
|
case "solid": return solidFillMechanism.emit(fill, void 0).xml;
|
|
291
444
|
case "linear-gradient":
|
|
292
445
|
case "radial-gradient": return gradientFillMechanism.emit(fill, void 0).xml;
|
|
293
|
-
case "image": return
|
|
446
|
+
case "image": return emitImageFillXml(fill, registerResource, box);
|
|
294
447
|
default: return fill;
|
|
295
448
|
}
|
|
296
449
|
}
|
|
@@ -313,7 +466,7 @@ function emitBorderXml(border) {
|
|
|
313
466
|
const tailEnd = border.endArrow === void 0 ? "" : `<a:tailEnd type="${border.endArrow}"/>`;
|
|
314
467
|
return `<a:ln w="${lineWidthEmu(border.width)}"><a:solidFill>${resolvedColorXml(border.color)}</a:solidFill>${dash === void 0 ? "" : `<a:prstDash val="${dash}"/>`}${headEnd}${tailEnd}</a:ln>`;
|
|
315
468
|
}
|
|
316
|
-
function emitEffectsXml(model) {
|
|
469
|
+
function emitEffectsXml(model, options) {
|
|
317
470
|
const items = [];
|
|
318
471
|
if (model.boxShadow !== void 0) {
|
|
319
472
|
const shadow = model.boxShadow;
|
|
@@ -321,15 +474,17 @@ function emitEffectsXml(model) {
|
|
|
321
474
|
items.push(`<a:outerShdw blurRad="${emu(shadow.blur, "boxShadow.blur")}" dist="${emu(shadow.distance, "boxShadow.distance")}" dir="${dir}" algn="ctr" rotWithShape="0">${resolvedColorXml(shadow.color)}</a:outerShdw>`);
|
|
322
475
|
}
|
|
323
476
|
if (model.softEdge !== void 0 && model.softEdge > 0) items.push(`<a:softEdge rad="${emu(model.softEdge, "softEdge", false)}"/>`);
|
|
324
|
-
|
|
477
|
+
if (items.length > 0) return `<a:effectLst>${items.join("")}</a:effectLst>`;
|
|
478
|
+
return options?.explicitEmptyWhenCleared && model.explicitNoShadow ? "<a:effectLst/>" : "";
|
|
325
479
|
}
|
|
326
480
|
/** Serializes a ResolvedVisualModel into PresentationML `<p:spPr>` XML. */
|
|
327
481
|
function emitVisualModel(model, registerResource, options) {
|
|
328
482
|
const { box } = model;
|
|
483
|
+
const allowSingleZeroExtent = Boolean(options?.allowSingleZeroExtent);
|
|
484
|
+
if (allowSingleZeroExtent && !(model.layoutOnlyWhenInvisible && !model.hasVisibleStyle)) assertVisualBoxExtent(box, { allowSingleZeroExtent: true });
|
|
329
485
|
return {
|
|
330
|
-
xml: `<p:spPr>${model.layoutOnlyWhenInvisible && !model.hasVisibleStyle ? "" : `<a:xfrm${model.rotationUnits === void 0 || model.rotationUnits === 0 ? "" : ` rot="${model.rotationUnits}"`}${model.flipH ? " flipH=\"1\"" : ""}${model.flipV ? " flipV=\"1\"" : ""}><a:off x="${emu(box.x, "x", true, true)}" y="${emu(box.y, "y", true, true)}"/><a:ext cx="${emu(box.width, "width",
|
|
486
|
+
xml: `<p:spPr>${model.layoutOnlyWhenInvisible && !model.hasVisibleStyle ? "" : `<a:xfrm${model.rotationUnits === void 0 || model.rotationUnits === 0 ? "" : ` rot="${model.rotationUnits}"`}${model.flipH ? " flipH=\"1\"" : ""}${model.flipV ? " flipV=\"1\"" : ""}><a:off x="${emu(box.x, "x", true, true)}" y="${emu(box.y, "y", true, true)}"/><a:ext cx="${emu(box.width, "width", allowSingleZeroExtent)}" cy="${emu(box.height, "height", allowSingleZeroExtent)}"/></a:xfrm>`}${resolvedGeometryXml(model.geometry)}${options?.omitFill ? "" : emitFillXml(model.fill, registerResource, box)}${emitBorderXml(model.border)}${emitEffectsXml(model)}</p:spPr>`,
|
|
331
487
|
...model.opacity === void 0 ? {} : { opacity: model.opacity },
|
|
332
|
-
warnings: model.warnings,
|
|
333
488
|
hasVisibleStyle: model.hasVisibleStyle,
|
|
334
489
|
geometryName: model.geometryName,
|
|
335
490
|
geometry: model.geometry
|
|
@@ -343,17 +498,17 @@ function emitPlaceholderVisualSpPr(model, flags, registerResource) {
|
|
|
343
498
|
let xfrmXml = "";
|
|
344
499
|
if (flags.hasBox || flags.hasRotate || flags.hasFlipH || flags.hasFlipV) {
|
|
345
500
|
const rotAttr = flags.hasRotate ? ` rot="${model.rotationUnits ?? 0}"` : "";
|
|
346
|
-
const flipHAttr = flags.hasFlipH
|
|
347
|
-
const flipVAttr = flags.hasFlipV
|
|
501
|
+
const flipHAttr = flags.hasFlipH ? model.flipH ? " flipH=\"1\"" : " flipH=\"0\"" : "";
|
|
502
|
+
const flipVAttr = flags.hasFlipV ? model.flipV ? " flipV=\"1\"" : " flipV=\"0\"" : "";
|
|
348
503
|
if (flags.hasBox) {
|
|
349
504
|
const { box } = model;
|
|
350
505
|
xfrmXml = `<a:xfrm${rotAttr}${flipHAttr}${flipVAttr}><a:off x="${emu(box.x, "x", true, true)}" y="${emu(box.y, "y", true, true)}"/><a:ext cx="${emu(box.width, "width", false)}" cy="${emu(box.height, "height", false)}"/></a:xfrm>`;
|
|
351
506
|
} else xfrmXml = `<a:xfrm${rotAttr}${flipHAttr}${flipVAttr}/>`;
|
|
352
507
|
}
|
|
353
508
|
const geomXml = flags.hasGeometryOrRadius || flags.hasBox && flags.includeDefaultRectWhenHasBox === true ? resolvedGeometryXml(model.geometry) : "";
|
|
354
|
-
const fillXml = flags.hasFill ? emitFillXml(model.fill, registerResource) : "";
|
|
509
|
+
const fillXml = flags.hasFill ? emitFillXml(model.fill, registerResource, model.box) : "";
|
|
355
510
|
const borderXml = flags.hasBorder ? emitBorderXml(model.border) : "";
|
|
356
|
-
const effectsXml = flags.hasEffects ? emitEffectsXml(model) : "";
|
|
511
|
+
const effectsXml = flags.hasEffects ? emitEffectsXml(model, { explicitEmptyWhenCleared: true }) : "";
|
|
357
512
|
const inner = `${xfrmXml}${geomXml}${fillXml}${borderXml}${effectsXml}`;
|
|
358
513
|
return inner === "" ? "<p:spPr/>" : `<p:spPr>${inner}</p:spPr>`;
|
|
359
514
|
}
|
|
@@ -653,6 +808,10 @@ function renderEvaluatedGeometryElements(model, fillDefId, overrideAttrs) {
|
|
|
653
808
|
function paintVisualModel(options) {
|
|
654
809
|
const { model, slideNumber, objectId } = options;
|
|
655
810
|
const { box } = model;
|
|
811
|
+
if (!(options.allowSingleZeroExtent ? isFiniteSingleZeroBox(box) : isFinitePositiveBox(box))) return {
|
|
812
|
+
svg: "",
|
|
813
|
+
...model.fill.kind === "image" && model.fill.source.kind === "external" ? { placeholders: [{ url: model.fill.source.externalUrl }] } : {}
|
|
814
|
+
};
|
|
656
815
|
const prefix = `obj-s${slideNumber}-o${objectId}`;
|
|
657
816
|
const defs = [];
|
|
658
817
|
let fillDefId;
|
|
@@ -664,13 +823,19 @@ function paintVisualModel(options) {
|
|
|
664
823
|
fillDefId = `${prefix}-fill`;
|
|
665
824
|
defs.push(gradientFillMechanism.paint(model.fill, { id: fillDefId }).svg);
|
|
666
825
|
break;
|
|
667
|
-
case "image":
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
id:
|
|
671
|
-
box
|
|
672
|
-
|
|
826
|
+
case "image": {
|
|
827
|
+
const candidateId = `${prefix}-fill`;
|
|
828
|
+
const patternSvg = imageFillMechanism.paint(model.fill, {
|
|
829
|
+
id: candidateId,
|
|
830
|
+
box,
|
|
831
|
+
registerRasterResource: options.registerRasterResource
|
|
832
|
+
}).svg;
|
|
833
|
+
if (patternSvg !== "") {
|
|
834
|
+
fillDefId = candidateId;
|
|
835
|
+
defs.push(patternSvg);
|
|
836
|
+
}
|
|
673
837
|
break;
|
|
838
|
+
}
|
|
674
839
|
default: return model.fill;
|
|
675
840
|
}
|
|
676
841
|
let content = renderEvaluatedGeometryElements(model, fillDefId);
|
|
@@ -711,23 +876,26 @@ function paintVisualModel(options) {
|
|
|
711
876
|
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>`);
|
|
712
877
|
layer = `<g filter="url(#${shadowId})">${layer}</g>`;
|
|
713
878
|
}
|
|
714
|
-
return {
|
|
879
|
+
return {
|
|
880
|
+
svg: `${defs.length > 0 ? `<defs>${defs.join("")}</defs>` : ""}${layer}`,
|
|
881
|
+
...model.fill.kind === "image" && model.fill.source.kind === "external" ? { placeholders: [{ url: model.fill.source.externalUrl }] } : {}
|
|
882
|
+
};
|
|
715
883
|
}
|
|
716
884
|
/** Reads DrawingML `<a:blipFill>` embedded image bytes and validates them against supported decoders. */
|
|
717
885
|
function readBlipFill(blipFillCursor, pkg, location, diagnostics) {
|
|
718
886
|
return readBlipFill$1(blipFillCursor, pkg, location, diagnostics, (bytes) => {
|
|
719
|
-
|
|
887
|
+
readImageBytes(bytes);
|
|
720
888
|
});
|
|
721
889
|
}
|
|
722
890
|
/**
|
|
723
891
|
* Reads PresentationML `<p:spPr>` geometry, fills, borders, and effects (without requiring `<a:xfrm>`).
|
|
724
892
|
* Used both by full-shape import and placeholder import where transform overrides may be absent.
|
|
725
893
|
*/
|
|
726
|
-
function readSpPrAppearance(spPrCursor, pkg, fallbackUnits, location, diagnostics) {
|
|
894
|
+
function readSpPrAppearance(spPrCursor, pkg, fallbackUnits, location, diagnostics, options) {
|
|
727
895
|
let geometry;
|
|
728
|
-
let
|
|
729
|
-
let
|
|
730
|
-
let
|
|
896
|
+
let background;
|
|
897
|
+
let hasNoFill = false;
|
|
898
|
+
let hasEmptyEffectLst = false;
|
|
731
899
|
let border = {};
|
|
732
900
|
let effects = {};
|
|
733
901
|
for (const child of spPrCursor.remainingElementChildren()) {
|
|
@@ -753,25 +921,28 @@ function readSpPrAppearance(spPrCursor, pkg, fallbackUnits, location, diagnostic
|
|
|
753
921
|
case "custGeom":
|
|
754
922
|
geometry = readCustomGeometryXml(child, fallbackUnits, location, diagnostics);
|
|
755
923
|
break;
|
|
756
|
-
case "noFill":
|
|
924
|
+
case "noFill":
|
|
925
|
+
hasNoFill = true;
|
|
926
|
+
break;
|
|
757
927
|
case "solidFill":
|
|
758
|
-
|
|
928
|
+
background = readDrawingColor(child, location, diagnostics);
|
|
759
929
|
break;
|
|
760
930
|
case "gradFill":
|
|
761
|
-
|
|
931
|
+
background = readGradientFill(child, location, diagnostics);
|
|
762
932
|
break;
|
|
763
933
|
case "blipFill": {
|
|
764
934
|
const blip = readBlipFill(child, pkg, location, diagnostics);
|
|
765
|
-
if (blip !== void 0) {
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
}
|
|
935
|
+
if (blip !== void 0) background = {
|
|
936
|
+
image: blip.image,
|
|
937
|
+
...blip.opacity === void 0 ? {} : { opacity: blip.opacity }
|
|
938
|
+
};
|
|
769
939
|
break;
|
|
770
940
|
}
|
|
771
941
|
case "ln":
|
|
772
942
|
border = readLineBorder(child, location, diagnostics);
|
|
773
943
|
break;
|
|
774
944
|
case "effectLst":
|
|
945
|
+
hasEmptyEffectLst = child.element.children.length === 0;
|
|
775
946
|
effects = readEffectList(child, location, diagnostics);
|
|
776
947
|
break;
|
|
777
948
|
case "extLst":
|
|
@@ -791,21 +962,27 @@ function readSpPrAppearance(spPrCursor, pkg, fallbackUnits, location, diagnostic
|
|
|
791
962
|
});
|
|
792
963
|
}
|
|
793
964
|
}
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
...border.
|
|
798
|
-
...border.
|
|
799
|
-
|
|
965
|
+
const resolvedBackground = background ?? (hasNoFill ? "none" : void 0);
|
|
966
|
+
const resolvedBorder = border.borderColor !== void 0 ? {
|
|
967
|
+
color: border.borderColor,
|
|
968
|
+
...border.borderWidth === void 0 ? {} : { width: border.borderWidth },
|
|
969
|
+
...border.borderStyle === void 0 ? {} : { style: border.borderStyle }
|
|
970
|
+
} : border.noFill === true ? "none" : void 0;
|
|
971
|
+
const borderArrows = border.startArrow !== void 0 || border.endArrow !== void 0 ? {
|
|
800
972
|
...border.startArrow === void 0 ? {} : { startArrow: border.startArrow },
|
|
801
|
-
...border.endArrow === void 0 ? {} : { endArrow: border.endArrow }
|
|
802
|
-
|
|
803
|
-
|
|
973
|
+
...border.endArrow === void 0 ? {} : { endArrow: border.endArrow }
|
|
974
|
+
} : void 0;
|
|
975
|
+
const resolvedBoxShadow = effects.boxShadow ?? (options?.preservePlaceholderClears === true && hasEmptyEffectLst && effects.softEdge === void 0 ? "none" : void 0);
|
|
976
|
+
const style = {
|
|
977
|
+
...resolvedBackground === void 0 ? {} : { background: resolvedBackground },
|
|
978
|
+
...resolvedBorder === void 0 ? {} : { border: resolvedBorder },
|
|
979
|
+
...resolvedBoxShadow === void 0 ? {} : { boxShadow: resolvedBoxShadow },
|
|
804
980
|
...effects.softEdge === void 0 ? {} : { softEdge: effects.softEdge }
|
|
805
981
|
};
|
|
806
982
|
return {
|
|
807
983
|
...geometry === void 0 ? {} : { geometry },
|
|
808
|
-
style
|
|
984
|
+
style,
|
|
985
|
+
...borderArrows === void 0 ? {} : { borderArrows }
|
|
809
986
|
};
|
|
810
987
|
}
|
|
811
988
|
/**
|
|
@@ -835,12 +1012,15 @@ function readSpPrVisuals(spPrCursor, pkg, location, diagnostics) {
|
|
|
835
1012
|
}, location, diagnostics);
|
|
836
1013
|
const style = {
|
|
837
1014
|
...appearance.style,
|
|
838
|
-
...transform.rotate === void 0 ? {} : { rotate: transform.rotate }
|
|
1015
|
+
...transform.rotate === void 0 ? {} : { rotate: transform.rotate },
|
|
1016
|
+
...transform.flipH === true ? { flipH: true } : {},
|
|
1017
|
+
...transform.flipV === true ? { flipV: true } : {}
|
|
839
1018
|
};
|
|
840
1019
|
return {
|
|
841
1020
|
transform,
|
|
842
1021
|
...appearance.geometry === void 0 ? {} : { geometry: appearance.geometry },
|
|
843
|
-
style
|
|
1022
|
+
style,
|
|
1023
|
+
...appearance.borderArrows === void 0 ? {} : { borderArrows: appearance.borderArrows }
|
|
844
1024
|
};
|
|
845
1025
|
}
|
|
846
1026
|
function readFillSubElement(context) {
|
|
@@ -887,26 +1067,150 @@ const gradientFillMechanism = defineCanvasMechanism({
|
|
|
887
1067
|
read: readFillSubElement
|
|
888
1068
|
}
|
|
889
1069
|
});
|
|
1070
|
+
function formatOoxmlRectAttrs(rect) {
|
|
1071
|
+
const attrs = [];
|
|
1072
|
+
if (rect.l !== 0) attrs.push(`l="${rect.l}"`);
|
|
1073
|
+
if (rect.t !== 0) attrs.push(`t="${rect.t}"`);
|
|
1074
|
+
if (rect.r !== 0) attrs.push(`r="${rect.r}"`);
|
|
1075
|
+
if (rect.b !== 0) attrs.push(`b="${rect.b}"`);
|
|
1076
|
+
return attrs.length === 0 ? "" : ` ${attrs.join(" ")}`;
|
|
1077
|
+
}
|
|
1078
|
+
/** Emits DrawingML `<a:blipFill>` XML for embedded or external image background fills. */
|
|
1079
|
+
function emitImageFillXml(fill, registerResource, box) {
|
|
1080
|
+
if (registerResource === void 0) invalid("image-resource-failure", "Cannot emit image background fill without resource registrar");
|
|
1081
|
+
const relationshipId = fill.source.kind === "external" ? registerResource({
|
|
1082
|
+
externalTarget: fill.source.externalUrl,
|
|
1083
|
+
relationshipType: imageRelationship
|
|
1084
|
+
}) : registerResource({
|
|
1085
|
+
bytes: fill.source.bytes,
|
|
1086
|
+
extension: fill.source.extension,
|
|
1087
|
+
contentType: fill.source.contentType,
|
|
1088
|
+
relationshipType: imageRelationship
|
|
1089
|
+
});
|
|
1090
|
+
const relAttr = fill.source.kind === "external" ? `r:link="${xmlEscape(relationshipId)}"` : `r:embed="${xmlEscape(relationshipId)}"`;
|
|
1091
|
+
const alpha = fill.opacity === void 0 ? "" : `<a:alphaModFix amt="${Math.round(fill.opacity * 1e5)}"/>`;
|
|
1092
|
+
const blipXml = alpha === "" ? `<a:blip ${relAttr}/>` : `<a:blip ${relAttr}>${alpha}</a:blip>`;
|
|
1093
|
+
let srcRectXml = "";
|
|
1094
|
+
let fillRectXml = "<a:fillRect/>";
|
|
1095
|
+
if (fill.source.kind === "embedded" && fill.source.width > 0 && fill.source.height > 0 && box !== void 0 && box.width > 0 && box.height > 0) {
|
|
1096
|
+
const imgRatio = fill.source.width / fill.source.height;
|
|
1097
|
+
const boxRatio = box.width / box.height;
|
|
1098
|
+
switch (fill.fit) {
|
|
1099
|
+
case "cover": {
|
|
1100
|
+
let l = 0;
|
|
1101
|
+
let t = 0;
|
|
1102
|
+
let r = 0;
|
|
1103
|
+
let b = 0;
|
|
1104
|
+
if (imgRatio > boxRatio) {
|
|
1105
|
+
const cropX = 1 - boxRatio / imgRatio;
|
|
1106
|
+
l = Math.round(cropX * fill.position.x * 1e5);
|
|
1107
|
+
r = Math.round(cropX * (1 - fill.position.x) * 1e5);
|
|
1108
|
+
} else if (imgRatio < boxRatio) {
|
|
1109
|
+
const cropY = 1 - imgRatio / boxRatio;
|
|
1110
|
+
t = Math.round(cropY * fill.position.y * 1e5);
|
|
1111
|
+
b = Math.round(cropY * (1 - fill.position.y) * 1e5);
|
|
1112
|
+
}
|
|
1113
|
+
const attrs = formatOoxmlRectAttrs({
|
|
1114
|
+
l,
|
|
1115
|
+
t,
|
|
1116
|
+
r,
|
|
1117
|
+
b
|
|
1118
|
+
});
|
|
1119
|
+
if (attrs !== "") srcRectXml = `<a:srcRect${attrs}/>`;
|
|
1120
|
+
break;
|
|
1121
|
+
}
|
|
1122
|
+
case "contain": {
|
|
1123
|
+
let l = 0;
|
|
1124
|
+
let t = 0;
|
|
1125
|
+
let r = 0;
|
|
1126
|
+
let b = 0;
|
|
1127
|
+
if (imgRatio > boxRatio) {
|
|
1128
|
+
const insY = 1 - boxRatio / imgRatio;
|
|
1129
|
+
t = Math.round(insY * fill.position.y * 1e5);
|
|
1130
|
+
b = Math.round(insY * (1 - fill.position.y) * 1e5);
|
|
1131
|
+
} else if (imgRatio < boxRatio) {
|
|
1132
|
+
const insX = 1 - imgRatio / boxRatio;
|
|
1133
|
+
l = Math.round(insX * fill.position.x * 1e5);
|
|
1134
|
+
r = Math.round(insX * (1 - fill.position.x) * 1e5);
|
|
1135
|
+
}
|
|
1136
|
+
const attrs = formatOoxmlRectAttrs({
|
|
1137
|
+
l,
|
|
1138
|
+
t,
|
|
1139
|
+
r,
|
|
1140
|
+
b
|
|
1141
|
+
});
|
|
1142
|
+
if (attrs !== "") fillRectXml = `<a:fillRect${attrs}/>`;
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
case "fill": break;
|
|
1146
|
+
default: {
|
|
1147
|
+
const exhaustive = fill.fit;
|
|
1148
|
+
throw new Error(`Unsupported image background fit: ${String(exhaustive)}`);
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
return `<a:blipFill rotWithShape="1">${blipXml}${srcRectXml}<a:stretch>${fillRectXml}</a:stretch></a:blipFill>`;
|
|
1153
|
+
}
|
|
1154
|
+
/** Renders deterministic SVG `<pattern>` markup for embedded or external image background fills. */
|
|
1155
|
+
function paintImageFillSvg(fill, id, box, registerRasterResource, diagnostic = { field: "style.background" }) {
|
|
1156
|
+
if (!isFinitePositiveBox(box)) return "";
|
|
1157
|
+
const bx = roundSvgNumber(box.x);
|
|
1158
|
+
const by = roundSvgNumber(box.y);
|
|
1159
|
+
const bw = roundSvgNumber(box.width);
|
|
1160
|
+
const bh = roundSvgNumber(box.height);
|
|
1161
|
+
const opacity = fill.opacity ?? 1;
|
|
1162
|
+
const imgOpacity = roundSvgNumber(opacity);
|
|
1163
|
+
if (fill.source.kind === "external") return `<pattern id="${id}" patternUnits="userSpaceOnUse" x="${bx}" y="${by}" width="${bw}" height="${bh}"><rect x="0" y="0" width="${bw}" height="${bh}" fill="#F1F5F9" fill-opacity="${imgOpacity}"/></pattern>`;
|
|
1164
|
+
const href = registerRasterResource(fill.source, {
|
|
1165
|
+
normalizeToPng: true,
|
|
1166
|
+
diagnostic
|
|
1167
|
+
});
|
|
1168
|
+
let drawX = 0;
|
|
1169
|
+
let drawY = 0;
|
|
1170
|
+
let drawW = box.width;
|
|
1171
|
+
let drawH = box.height;
|
|
1172
|
+
if (fill.fit !== "fill" && fill.source.width > 0 && fill.source.height > 0 && box.width > 0 && box.height > 0) {
|
|
1173
|
+
const imgRatio = fill.source.width / fill.source.height;
|
|
1174
|
+
const boxRatio = box.width / box.height;
|
|
1175
|
+
switch (fill.fit) {
|
|
1176
|
+
case "cover":
|
|
1177
|
+
if (imgRatio > boxRatio) {
|
|
1178
|
+
drawH = box.height;
|
|
1179
|
+
drawW = box.height * imgRatio;
|
|
1180
|
+
} else {
|
|
1181
|
+
drawW = box.width;
|
|
1182
|
+
drawH = box.width / imgRatio;
|
|
1183
|
+
}
|
|
1184
|
+
break;
|
|
1185
|
+
case "contain":
|
|
1186
|
+
if (imgRatio > boxRatio) {
|
|
1187
|
+
drawW = box.width;
|
|
1188
|
+
drawH = box.width / imgRatio;
|
|
1189
|
+
} else {
|
|
1190
|
+
drawH = box.height;
|
|
1191
|
+
drawW = box.height * imgRatio;
|
|
1192
|
+
}
|
|
1193
|
+
break;
|
|
1194
|
+
default: {
|
|
1195
|
+
const exhaustive = fill.fit;
|
|
1196
|
+
throw new Error(`Unsupported image background fit: ${String(exhaustive)}`);
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
drawX = (box.width - drawW) * fill.position.x;
|
|
1200
|
+
drawY = (box.height - drawH) * fill.position.y;
|
|
1201
|
+
}
|
|
1202
|
+
const opacityAttr = opacity === 1 ? "" : ` opacity="${imgOpacity}"`;
|
|
1203
|
+
return `<pattern id="${id}" patternUnits="userSpaceOnUse" x="${bx}" y="${by}" width="${bw}" height="${bh}"><image x="${roundSvgNumber(drawX)}" y="${roundSvgNumber(drawY)}" width="${roundSvgNumber(drawW)}" height="${roundSvgNumber(drawH)}" preserveAspectRatio="none"${opacityAttr} href="${href}"/></pattern>`;
|
|
1204
|
+
}
|
|
890
1205
|
/** Native canvas mechanism for DrawingML `<a:blipFill>` shape image fills. */
|
|
891
1206
|
const imageFillMechanism = defineCanvasMechanism({
|
|
892
1207
|
key: "image-fill",
|
|
893
1208
|
role: "canvas",
|
|
894
1209
|
emit(fill, registerResource) {
|
|
895
|
-
|
|
896
|
-
const relationshipId = registerResource({
|
|
897
|
-
bytes: fill.image.bytes,
|
|
898
|
-
extension: fill.image.extension,
|
|
899
|
-
contentType: fill.image.contentType,
|
|
900
|
-
relationshipType: imageRelationship
|
|
901
|
-
});
|
|
902
|
-
const alpha = fill.opacity === void 0 ? "" : `<a:alphaModFix amt="${Math.round(fill.opacity * 1e5)}"/>`;
|
|
903
|
-
return { xml: `<a:blipFill rotWithShape="1"><a:blip r:embed="${xmlEscape(relationshipId)}">${alpha}</a:blip><a:stretch><a:fillRect/></a:stretch></a:blipFill>` };
|
|
1210
|
+
return { xml: emitImageFillXml(fill, registerResource) };
|
|
904
1211
|
},
|
|
905
1212
|
paint(fill, context) {
|
|
906
|
-
|
|
907
|
-
const base64 = Buffer.from(pngBytes).toString("base64");
|
|
908
|
-
const imgOpacity = roundSvgNumber(fill.opacity ?? 1);
|
|
909
|
-
return { svg: `<pattern id="${context.id}" patternUnits="userSpaceOnUse" x="${roundSvgNumber(context.box.x)}" y="${roundSvgNumber(context.box.y)}" width="${roundSvgNumber(context.box.width)}" height="${roundSvgNumber(context.box.height)}"><image x="0" y="0" width="${roundSvgNumber(context.box.width)}" height="${roundSvgNumber(context.box.height)}" preserveAspectRatio="none" opacity="${imgOpacity}" href="data:image/png;base64,${base64}"/></pattern>` };
|
|
1213
|
+
return { svg: paintImageFillSvg(fill, context.id, context.box, context.registerRasterResource) };
|
|
910
1214
|
},
|
|
911
1215
|
import: {
|
|
912
1216
|
target: "shape-tree",
|
|
@@ -915,4 +1219,4 @@ const imageFillMechanism = defineCanvasMechanism({
|
|
|
915
1219
|
read: readFillSubElement
|
|
916
1220
|
}
|
|
917
1221
|
});
|
|
918
|
-
export { arrowTypeSchema, emitPlaceholderVisualSpPr, emitVisualModel, gradientDefSvg, gradientFillMechanism, gradientFillXml, hasVisibleBoxStyle, imageFillMechanism,
|
|
1222
|
+
export { arrowTypeSchema, assertVisualBoxExtent, bindVisualModel, borderAttributes, emitFillXml, emitImageFillXml, emitPlaceholderVisualSpPr, emitVisualModel, gradientDefSvg, gradientFillMechanism, gradientFillXml, hasVisibleBoxStyle, imageFillMechanism, lineStrokeValueSchema, linearGradient, paintImageFillSvg, paintVisualModel, radialGradient, readBlipFill, readDrawingColor, readEffectList, readGradientFill, readLineBorder, readSpPrAppearance, readSpPrVisuals, readTransformXml, resolveBackgroundValue, resolveGradientSpec, resolveImageBackgroundPosition, resolveImageBackgroundSpec, resolveLineStroke, resolveShadow, resolveTextStroke, resolveVisualModel, solidFillMechanism, textShadowXml, visualSvgTransform };
|