@officedk/pptxdk 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +5 -8
- package/dist/build.js +44 -52
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +113 -50
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +5 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +2 -5
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
|
@@ -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 {
|
|
@@ -44,23 +45,23 @@ const rawLineStrokeObjectSchema = z.strictObject({
|
|
|
44
45
|
const lineStrokeValueSchema = z.union([z.literal("none"), rawLineStrokeObjectSchema]);
|
|
45
46
|
Object.keys(lineEndStyleObjectSchema.shape);
|
|
46
47
|
Object.keys(visualStyleShape);
|
|
47
|
-
function invalid(code, message) {
|
|
48
|
-
throw new CapabilityError(code, message);
|
|
48
|
+
function invalid(code, message, field) {
|
|
49
|
+
throw new CapabilityError(code, message, void 0, { field });
|
|
49
50
|
}
|
|
50
51
|
function isRecord(value) {
|
|
51
52
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
52
53
|
}
|
|
53
|
-
function finite(value, label) {
|
|
54
|
-
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);
|
|
55
56
|
return value;
|
|
56
57
|
}
|
|
57
58
|
function emu(value, label, allowZero = true, signed = false) {
|
|
58
59
|
const converted = pxToEmu(value);
|
|
59
60
|
if (!allowZero && !signed) {
|
|
60
|
-
if (!Number.isFinite(value) || value === 0 || converted === 0) invalid("invalid-visual-style", `Computed ${label} is 0px; ${label} must be greater than 0px`);
|
|
61
|
-
if (value < 0 || converted < 1) invalid("invalid-visual-style", `Computed ${label} is ${value}px; ${label} must be greater than 0px`);
|
|
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}`);
|
|
62
63
|
}
|
|
63
|
-
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`);
|
|
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}`);
|
|
64
65
|
return converted;
|
|
65
66
|
}
|
|
66
67
|
/** Validates that a visible object box has valid DrawingML EMU extents during resolve. */
|
|
@@ -130,23 +131,26 @@ function textShadowXml(theme, value) {
|
|
|
130
131
|
}
|
|
131
132
|
const gradientSchema = z.union([linearGradientSchema, radialGradientSchema]).refine((value) => value.stops.length >= 2);
|
|
132
133
|
/** Resolves and validates a linear or radial gradient declaration against a ThemeContext. */
|
|
133
|
-
function resolveGradientSpec(theme, image, opacity) {
|
|
134
|
+
function resolveGradientSpec(theme, image, opacity, field = "style.background") {
|
|
134
135
|
const parsed = gradientSchema.safeParse(image);
|
|
135
136
|
if (!parsed.success) {
|
|
136
137
|
const issue = parsed.error.issues[0];
|
|
137
|
-
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`);
|
|
138
139
|
if (issue?.path[0] === "stops" && isRecord(image) && Array.isArray(image["stops"])) {
|
|
139
140
|
const idx = typeof issue.path[1] === "number" ? issue.path[1] : void 0;
|
|
140
141
|
if (idx !== void 0 && issue.path[2] === "position") {
|
|
141
142
|
const stop = image["stops"][idx];
|
|
142
|
-
if (isRecord(stop))
|
|
143
|
+
if (isRecord(stop)) {
|
|
144
|
+
const positionField = `${field}.stops.${idx}.position`;
|
|
145
|
+
finite(stop["position"], positionField, positionField);
|
|
146
|
+
}
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
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");
|
|
146
|
-
invalid("invalid-gradient", "backgroundImage must be a linear or radial gradient with at least two color stops");
|
|
150
|
+
invalid("invalid-gradient", "backgroundImage must be a linear or radial gradient with at least two color stops", zodIssueField(issue, field));
|
|
147
151
|
}
|
|
148
152
|
const stops = parsed.data.stops.map((stop, index) => {
|
|
149
|
-
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`);
|
|
150
154
|
const color = withOpacity(theme.resolveColor(stop.color), opacity);
|
|
151
155
|
return {
|
|
152
156
|
position: stop.position,
|
|
@@ -182,13 +186,19 @@ function isFiniteSingleZeroBox(box) {
|
|
|
182
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);
|
|
183
187
|
}
|
|
184
188
|
/** Generates deterministic SVG `<linearGradient>` or `<radialGradient>` definition markup. */
|
|
185
|
-
function gradientDefSvg(id, gradient) {
|
|
189
|
+
function gradientDefSvg(id, gradient, screenBox) {
|
|
186
190
|
const stops = gradientStopsSvg(gradient.stops);
|
|
187
191
|
switch (gradient.kind) {
|
|
188
192
|
case "linear-gradient": {
|
|
189
|
-
const rad = (Number.isFinite(gradient.angle) ? gradient.angle : 0) * Math.PI / 180;
|
|
193
|
+
const rad = (Number.isFinite(gradient.angle) ? gradient.angle % 360 : 0) * Math.PI / 180;
|
|
190
194
|
const dx = Math.sin(rad);
|
|
191
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
|
+
}
|
|
192
202
|
const halfSpan = (Math.abs(dx) + Math.abs(dy)) / 2;
|
|
193
203
|
const x1Val = .5 - dx * halfSpan;
|
|
194
204
|
const y1Val = .5 - dy * halfSpan;
|
|
@@ -197,7 +207,9 @@ function gradientDefSvg(id, gradient) {
|
|
|
197
207
|
const validVec = Number.isFinite(x1Val) && Number.isFinite(y1Val) && Number.isFinite(x2Val) && Number.isFinite(y2Val) && Math.hypot(x2Val - x1Val, y2Val - y1Val) > 1e-6;
|
|
198
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>`;
|
|
199
209
|
}
|
|
200
|
-
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>`;
|
|
201
213
|
default: return gradient;
|
|
202
214
|
}
|
|
203
215
|
}
|
|
@@ -214,10 +226,10 @@ function rotationUnits(style) {
|
|
|
214
226
|
units
|
|
215
227
|
};
|
|
216
228
|
}
|
|
217
|
-
function resolveImageFillSource(source) {
|
|
218
|
-
if (
|
|
229
|
+
function* resolveImageFillSource(source) {
|
|
230
|
+
if (typeof source === "object" && "externalUrl" in source && typeof source.externalUrl === "string") return {
|
|
219
231
|
kind: "external",
|
|
220
|
-
externalUrl: source
|
|
232
|
+
externalUrl: source.externalUrl
|
|
221
233
|
};
|
|
222
234
|
if (source instanceof URL && (source.protocol === "http:" || source.protocol === "https:")) return {
|
|
223
235
|
kind: "external",
|
|
@@ -229,7 +241,7 @@ function resolveImageFillSource(source) {
|
|
|
229
241
|
};
|
|
230
242
|
return {
|
|
231
243
|
kind: "embedded",
|
|
232
|
-
...readImage(source)
|
|
244
|
+
...yield* readImage(source)
|
|
233
245
|
};
|
|
234
246
|
}
|
|
235
247
|
function resolvePositionCoordinate(value) {
|
|
@@ -288,14 +300,14 @@ function resolveImageBackgroundPosition(position) {
|
|
|
288
300
|
};
|
|
289
301
|
}
|
|
290
302
|
/** Validates and resolves `{ image, fit?, position?, opacity? }` background declarations. */
|
|
291
|
-
function resolveImageBackgroundSpec(spec, opacity) {
|
|
303
|
+
function* resolveImageBackgroundSpec(spec, opacity) {
|
|
292
304
|
const parsed = imageBackgroundSchema.safeParse(spec);
|
|
293
305
|
if (!parsed.success) {
|
|
294
306
|
const issue = parsed.error.issues[0];
|
|
295
307
|
if (issue?.code === "unrecognized_keys" && issue.keys[0] !== void 0) invalid("invalid-visual-style", `background image contains unsupported parameter ${issue.keys[0]}`);
|
|
296
308
|
invalid("invalid-visual-style", issue?.message ?? "Invalid image background declaration");
|
|
297
309
|
}
|
|
298
|
-
const source = resolveImageFillSource(parsed.data.image);
|
|
310
|
+
const source = yield* resolveImageFillSource(parsed.data.image);
|
|
299
311
|
const combinedOpacity = (parsed.data.opacity ?? 1) * (opacity ?? 1);
|
|
300
312
|
return {
|
|
301
313
|
kind: "image",
|
|
@@ -306,18 +318,18 @@ function resolveImageBackgroundSpec(spec, opacity) {
|
|
|
306
318
|
};
|
|
307
319
|
}
|
|
308
320
|
/** Resolves a unified `BackgroundValue` (`"none"`, color, gradient, or `{ image, fit?, position?, opacity? }`). */
|
|
309
|
-
function resolveBackgroundValue(theme, value, opacity) {
|
|
321
|
+
function* resolveBackgroundValue(theme, value, opacity) {
|
|
310
322
|
if (value === void 0 || value === "none") return { kind: "none" };
|
|
311
|
-
if (isRecord(value) && Object.hasOwn(value, "image")) return resolveImageBackgroundSpec(value, opacity);
|
|
323
|
+
if (isRecord(value) && Object.hasOwn(value, "image")) return yield* resolveImageBackgroundSpec(value, opacity);
|
|
312
324
|
if (isRecord(value) && (value["type"] === "linear-gradient" || value["type"] === "radial-gradient")) return resolveGradientSpec(theme, value, opacity);
|
|
313
325
|
return {
|
|
314
326
|
kind: "solid",
|
|
315
327
|
color: withOpacity(theme.resolveColor(value), opacity)
|
|
316
328
|
};
|
|
317
329
|
}
|
|
318
|
-
function resolveVisualFill(theme, style, opacity) {
|
|
330
|
+
function* resolveVisualFill(theme, style, opacity) {
|
|
319
331
|
try {
|
|
320
|
-
return resolveBackgroundValue(theme, style["background"], opacity);
|
|
332
|
+
return yield* resolveBackgroundValue(theme, style["background"], opacity);
|
|
321
333
|
} catch (error) {
|
|
322
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, {
|
|
323
335
|
...error.details,
|
|
@@ -331,7 +343,7 @@ function resolveStrokeValue(theme, rawStroke, opacity, schema, label) {
|
|
|
331
343
|
const parsed = schema.safeParse(rawStroke);
|
|
332
344
|
if (!parsed.success || parsed.data === "none") {
|
|
333
345
|
const issue = parsed.success ? void 0 : parsed.error.issues[0];
|
|
334
|
-
if (issue?.code === "unrecognized_keys" && issue.keys[0] !== void 0) invalid("invalid-visual-style", `${label} contains unsupported property ${issue.keys[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}`));
|
|
335
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`);
|
|
336
348
|
invalid("invalid-visual-style", issue?.message ?? `Invalid ${label} declaration`);
|
|
337
349
|
}
|
|
@@ -356,6 +368,9 @@ function resolveLineStroke(theme, rawStroke, opacity) {
|
|
|
356
368
|
style: "solid"
|
|
357
369
|
} : rawStroke, opacity, lineStrokeValueSchema, "stroke");
|
|
358
370
|
}
|
|
371
|
+
function resolveTextStroke(theme, value) {
|
|
372
|
+
return resolveStrokeValue(theme, value, void 0, borderValueSchema, "textStroke");
|
|
373
|
+
}
|
|
359
374
|
function resolveVisualBorder(theme, style, opacity) {
|
|
360
375
|
if (!Object.hasOwn(style, "border") || style["border"] === void 0) return;
|
|
361
376
|
return resolveStrokeValue(theme, style["border"], opacity, borderValueSchema, "border");
|
|
@@ -370,7 +385,10 @@ function hasVisibleBoxStyle(style) {
|
|
|
370
385
|
* Validates and resolves visual styles, geometry, fill, border, shadow, softEdge, and transforms
|
|
371
386
|
* into a closed strongly-typed model consumed exhaustively by emitVisualModel and paintVisualModel.
|
|
372
387
|
*/
|
|
373
|
-
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) {
|
|
374
392
|
const { theme, style, box } = options;
|
|
375
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`);
|
|
376
394
|
const flipH = Boolean(style["flipH"]);
|
|
@@ -380,7 +398,7 @@ function resolveVisualModel(options) {
|
|
|
380
398
|
if (options.image && style["borderRadius"] !== void 0) invalid("unsupported-style-combination", "Image does not support borderRadius");
|
|
381
399
|
const radius = style["borderRadius"] === void 0 ? void 0 : finite(style["borderRadius"], "borderRadius");
|
|
382
400
|
if (radius !== void 0 && radius < 0) invalid("invalid-visual-style", "borderRadius must be a non-negative length");
|
|
383
|
-
const fill = resolveVisualFill(theme, style, opacity);
|
|
401
|
+
const fill = imageFill ?? (yield* resolveVisualFill(theme, style, opacity));
|
|
384
402
|
const border = options.borderOverride !== void 0 ? options.borderOverride ?? void 0 : resolveVisualBorder(theme, style, opacity);
|
|
385
403
|
const explicitNoShadow = style["boxShadow"] === "none";
|
|
386
404
|
const boxShadow = style["boxShadow"] === void 0 || explicitNoShadow ? void 0 : resolveShadow(theme, style["boxShadow"], "boxShadow");
|
|
@@ -810,7 +828,7 @@ function paintVisualModel(options) {
|
|
|
810
828
|
const patternSvg = imageFillMechanism.paint(model.fill, {
|
|
811
829
|
id: candidateId,
|
|
812
830
|
box,
|
|
813
|
-
|
|
831
|
+
registerRasterResource: options.registerRasterResource
|
|
814
832
|
}).svg;
|
|
815
833
|
if (patternSvg !== "") {
|
|
816
834
|
fillDefId = candidateId;
|
|
@@ -866,7 +884,7 @@ function paintVisualModel(options) {
|
|
|
866
884
|
/** Reads DrawingML `<a:blipFill>` embedded image bytes and validates them against supported decoders. */
|
|
867
885
|
function readBlipFill(blipFillCursor, pkg, location, diagnostics) {
|
|
868
886
|
return readBlipFill$1(blipFillCursor, pkg, location, diagnostics, (bytes) => {
|
|
869
|
-
|
|
887
|
+
readImageBytes(bytes);
|
|
870
888
|
});
|
|
871
889
|
}
|
|
872
890
|
/**
|
|
@@ -1077,54 +1095,64 @@ function emitImageFillXml(fill, registerResource, box) {
|
|
|
1077
1095
|
if (fill.source.kind === "embedded" && fill.source.width > 0 && fill.source.height > 0 && box !== void 0 && box.width > 0 && box.height > 0) {
|
|
1078
1096
|
const imgRatio = fill.source.width / fill.source.height;
|
|
1079
1097
|
const boxRatio = box.width / box.height;
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
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;
|
|
1093
1121
|
}
|
|
1094
|
-
|
|
1095
|
-
l
|
|
1096
|
-
t
|
|
1097
|
-
r
|
|
1098
|
-
b
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
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)}`);
|
|
1114
1149
|
}
|
|
1115
|
-
const attrs = formatOoxmlRectAttrs({
|
|
1116
|
-
l,
|
|
1117
|
-
t,
|
|
1118
|
-
r,
|
|
1119
|
-
b
|
|
1120
|
-
});
|
|
1121
|
-
if (attrs !== "") fillRectXml = `<a:fillRect${attrs}/>`;
|
|
1122
1150
|
}
|
|
1123
1151
|
}
|
|
1124
1152
|
return `<a:blipFill rotWithShape="1">${blipXml}${srcRectXml}<a:stretch>${fillRectXml}</a:stretch></a:blipFill>`;
|
|
1125
1153
|
}
|
|
1126
1154
|
/** Renders deterministic SVG `<pattern>` markup for embedded or external image background fills. */
|
|
1127
|
-
function paintImageFillSvg(fill, id, box, registerRasterResource) {
|
|
1155
|
+
function paintImageFillSvg(fill, id, box, registerRasterResource, diagnostic = { field: "style.background" }) {
|
|
1128
1156
|
if (!isFinitePositiveBox(box)) return "";
|
|
1129
1157
|
const bx = roundSvgNumber(box.x);
|
|
1130
1158
|
const by = roundSvgNumber(box.y);
|
|
@@ -1133,20 +1161,10 @@ function paintImageFillSvg(fill, id, box, registerRasterResource) {
|
|
|
1133
1161
|
const opacity = fill.opacity ?? 1;
|
|
1134
1162
|
const imgOpacity = roundSvgNumber(opacity);
|
|
1135
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>`;
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
}
|
|
1140
|
-
if (error instanceof CapabilityError && error.details?.["field"] === void 0) throw new CapabilityError(error.code, error.message, error.path, {
|
|
1141
|
-
...error.details,
|
|
1142
|
-
field: "style.background"
|
|
1143
|
-
});
|
|
1144
|
-
throw error;
|
|
1145
|
-
}
|
|
1146
|
-
const href = registerRasterResource !== void 0 ? registerRasterResource({
|
|
1147
|
-
contentType: "image/png",
|
|
1148
|
-
bytes: pngBytes
|
|
1149
|
-
}) : `data:image/png;base64,${Buffer.from(pngBytes).toString("base64")}`;
|
|
1164
|
+
const href = registerRasterResource(fill.source, {
|
|
1165
|
+
normalizeToPng: true,
|
|
1166
|
+
diagnostic
|
|
1167
|
+
});
|
|
1150
1168
|
let drawX = 0;
|
|
1151
1169
|
let drawY = 0;
|
|
1152
1170
|
let drawW = box.width;
|
|
@@ -1154,21 +1172,28 @@ function paintImageFillSvg(fill, id, box, registerRasterResource) {
|
|
|
1154
1172
|
if (fill.fit !== "fill" && fill.source.width > 0 && fill.source.height > 0 && box.width > 0 && box.height > 0) {
|
|
1155
1173
|
const imgRatio = fill.source.width / fill.source.height;
|
|
1156
1174
|
const boxRatio = box.width / box.height;
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
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)}`);
|
|
1172
1197
|
}
|
|
1173
1198
|
}
|
|
1174
1199
|
drawX = (box.width - drawW) * fill.position.x;
|
|
@@ -1194,4 +1219,4 @@ const imageFillMechanism = defineCanvasMechanism({
|
|
|
1194
1219
|
read: readFillSubElement
|
|
1195
1220
|
}
|
|
1196
1221
|
});
|
|
1197
|
-
export { arrowTypeSchema, assertVisualBoxExtent, 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, resolveVisualModel, solidFillMechanism, textShadowXml, visualSvgTransform };
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { slideBackgroundCapability, slideBackgroundGradientMechanism, slideBackgroundImageMechanism, slideBackgroundRefMechanism, slideBackgroundSolidMechanism } from "./slide-background.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { slideBackgroundSchema } from "../../kernel/author-schemas.js";
|
|
2
|
+
import { serializeImageDescriptorValue } from "../shared/image-codegen.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
import { defineSlideCodegen, expr } from "../../kernel/codegen.js";
|
|
5
|
+
// ../core/dist/capabilities/slide-background/slide-background-codegen.js
|
|
6
|
+
/** Source codegen contribution for `Slide.background` / `SlideMaster.background` / `SlideLayout.background` and gradients. */
|
|
7
|
+
const slideBackgroundCodegen = defineSlideCodegen({
|
|
8
|
+
slideProps: { background: (value, ctx) => {
|
|
9
|
+
const parsed = slideBackgroundSchema.safeParse(value);
|
|
10
|
+
if (!parsed.success) ctx.fail("unexpressible-value", parsed.error.issues[0]?.message ?? "Slide.background declaration is invalid");
|
|
11
|
+
return expr(ctx.emitValueExpr(parsed.data));
|
|
12
|
+
} },
|
|
13
|
+
valueSerializers: [serializeImageDescriptorValue]
|
|
14
|
+
});
|
|
15
|
+
export { slideBackgroundCodegen };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A_NS, P_NS } from "
|
|
2
|
-
import { ooxmlBoolSchema } from "
|
|
3
|
-
import { readDrawingColor, readGradientFill } from "
|
|
4
|
-
import "../../../import/dist/index.js";
|
|
1
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
2
|
+
import { ooxmlBoolSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
3
|
+
import { readDrawingColor, readGradientFill } from "../../kernel/pptx-read/visual.js";
|
|
5
4
|
import { readBlipFill } from "../shared/visual.js";
|
|
5
|
+
import "../../kernel/pptx-read/index.js";
|
|
6
6
|
import { z } from "zod";
|
|
7
|
-
// ../
|
|
7
|
+
// ../core/dist/capabilities/slide-background/slide-background-import.js
|
|
8
8
|
const BgAttrsSchema = z.object({ shadeToTitle: ooxmlBoolSchema.optional() });
|
|
9
9
|
const BgPrAttrsSchema = z.object({ rotWithShape: ooxmlBoolSchema.optional() });
|
|
10
10
|
const bgRefAttrsSchema = z.object({ idx: z.enum([
|
package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js
RENAMED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { resolvedColorXml, xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
2
|
-
import "../../../emit/dist/index.js";
|
|
3
1
|
import { emitImageFillXml, gradientFillXml } from "../shared/visual.js";
|
|
4
|
-
|
|
2
|
+
import { resolvedColorXml, xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
3
|
+
// ../core/dist/capabilities/slide-background/slide-background-xml.js
|
|
5
4
|
/** Internal PresentationML slide background wrapper for explicit `"none"` clearing. */
|
|
6
5
|
function slideBackgroundNoneXml() {
|
|
7
6
|
return "<p:bg><p:bgPr><a:noFill/><a:effectLst/></p:bgPr></p:bg>";
|
package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js
RENAMED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import { applyFormatColorTransforms } from "
|
|
3
|
-
import { slideBackgroundSchema } from "
|
|
4
|
-
import "
|
|
5
|
-
import {
|
|
6
|
-
import "
|
|
7
|
-
import { readImage } from "../image/image-decode.js";
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { applyFormatColorTransforms } from "../../kernel/theme.js";
|
|
3
|
+
import { slideBackgroundSchema } from "../../kernel/author-schemas.js";
|
|
4
|
+
import { backgroundSlots } from "../shared/container-slots.js";
|
|
5
|
+
import { readImage } from "../shared/image-decode.js";
|
|
6
|
+
import { defineCanvasMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
8
7
|
import { gradientDefSvg, paintImageFillSvg, resolveGradientSpec, resolveImageBackgroundSpec } from "../shared/visual.js";
|
|
8
|
+
import "../../kernel/capability.js";
|
|
9
|
+
import "../../kernel/pptx-read/index.js";
|
|
10
|
+
import { finishResolveWork } from "../../kernel/resolve-work.js";
|
|
9
11
|
import { slideBackgroundCodegen } from "./slide-background-codegen.js";
|
|
10
12
|
import { readSlideBackgroundSlot } from "./slide-background-import.js";
|
|
11
13
|
import { slideBackgroundGradientXml, slideBackgroundImageXml, slideBackgroundNoneXml, slideBackgroundRefXml, slideBackgroundSolidXml } from "./slide-background-xml.js";
|
|
12
|
-
// ../
|
|
14
|
+
// ../core/dist/capabilities/slide-background/slide-background.js
|
|
13
15
|
function resolveFormatColor(theme, refColor, transform) {
|
|
14
16
|
const base = transform.color === "phClr" ? refColor : theme.resolveColor(transform.color);
|
|
15
17
|
return applyFormatColorTransforms(base, transform);
|
|
@@ -39,7 +41,7 @@ function resolveBgRefFill(theme, idx, refColor) {
|
|
|
39
41
|
stops
|
|
40
42
|
};
|
|
41
43
|
}
|
|
42
|
-
function resolveSlideBackground(theme, background) {
|
|
44
|
+
function* resolveSlideBackground(theme, background, field) {
|
|
43
45
|
if (background === void 0) return { kind: "default" };
|
|
44
46
|
if (background === "none") return { kind: "none" };
|
|
45
47
|
const parsed = slideBackgroundSchema.safeParse(background);
|
|
@@ -50,19 +52,19 @@ function resolveSlideBackground(theme, background) {
|
|
|
50
52
|
};
|
|
51
53
|
if (typeof background === "object" && background !== null && !Array.isArray(background)) {
|
|
52
54
|
const candidate = background;
|
|
53
|
-
if (candidate["type"] === "linear-gradient" || candidate["type"] === "radial-gradient") return resolveGradientSpec(theme, background, void 0);
|
|
54
|
-
if (Object.keys(candidate).length === 1 && Object.hasOwn(candidate, "image")) readImage(candidate["image"]);
|
|
55
|
+
if (candidate["type"] === "linear-gradient" || candidate["type"] === "radial-gradient") return resolveGradientSpec(theme, background, void 0, field);
|
|
56
|
+
if (Object.keys(candidate).length === 1 && Object.hasOwn(candidate, "image")) yield* readImage(candidate["image"]);
|
|
55
57
|
if ("color" in candidate && !("ref" in candidate)) return {
|
|
56
58
|
kind: "solid",
|
|
57
59
|
color: theme.resolveColor(background)
|
|
58
60
|
};
|
|
59
61
|
}
|
|
60
|
-
throw new CapabilityError("invalid-slide-background", parsed.error.issues[0]?.message ?? "Slide.background declaration is invalid");
|
|
62
|
+
throw new CapabilityError("invalid-slide-background", parsed.error.issues[0]?.message ?? "Slide.background declaration is invalid", void 0, { field: zodIssueField(parsed.error.issues[0], field) });
|
|
61
63
|
}
|
|
62
64
|
const value = parsed.data;
|
|
63
65
|
if (value === "none") return { kind: "none" };
|
|
64
66
|
if (typeof value === "object" && value !== null) {
|
|
65
|
-
if ("image" in value) return resolveImageBackgroundSpec(value, void 0);
|
|
67
|
+
if ("image" in value) return yield* resolveImageBackgroundSpec(value, void 0);
|
|
66
68
|
if ("ref" in value) {
|
|
67
69
|
const refColor = theme.resolveColor(value.color ?? "bg1");
|
|
68
70
|
return {
|
|
@@ -72,7 +74,7 @@ function resolveSlideBackground(theme, background) {
|
|
|
72
74
|
fill: resolveBgRefFill(theme, value.ref, refColor)
|
|
73
75
|
};
|
|
74
76
|
}
|
|
75
|
-
if ("type" in value) return resolveGradientSpec(theme, value, void 0);
|
|
77
|
+
if ("type" in value) return resolveGradientSpec(theme, value, void 0, field);
|
|
76
78
|
}
|
|
77
79
|
return {
|
|
78
80
|
kind: "solid",
|
|
@@ -109,23 +111,16 @@ function paintSlideBackground(resolved, paintContext, field = "style.background"
|
|
|
109
111
|
}
|
|
110
112
|
case "image": {
|
|
111
113
|
const patId = `bg-s${paintContext.slideNumber}-img`;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
def = paintImageFillSvg(resolved, patId, {
|
|
114
|
+
return {
|
|
115
|
+
svg: `<defs>${paintImageFillSvg(resolved, patId, {
|
|
115
116
|
x: 0,
|
|
116
117
|
y: 0,
|
|
117
118
|
width,
|
|
118
119
|
height
|
|
119
|
-
}, paintContext.registerRasterResource
|
|
120
|
-
|
|
121
|
-
const message = error instanceof Error ? error.message : "Failed to decode slide background image for preview";
|
|
122
|
-
throw new CapabilityError("preview-corrupt-image", message, `${paintContext.path}/background`, {
|
|
123
|
-
...error instanceof CapabilityError ? error.details : void 0,
|
|
120
|
+
}, paintContext.registerRasterResource, {
|
|
121
|
+
path: `${paintContext.path}/background`,
|
|
124
122
|
field
|
|
125
|
-
})
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
svg: `<defs>${def}</defs><rect x="0" y="0" width="${width}" height="${height}" fill="url(#${patId})"/>`,
|
|
123
|
+
})}</defs><rect x="0" y="0" width="${width}" height="${height}" fill="url(#${patId})"/>`,
|
|
129
124
|
...resolved.source.kind === "external" ? { placeholders: [{
|
|
130
125
|
path: `${paintContext.path}/background`,
|
|
131
126
|
url: resolved.source.externalUrl
|
|
@@ -198,9 +193,7 @@ const slideBackgroundRefMechanism = defineCanvasMechanism({
|
|
|
198
193
|
* and owns both PresentationML `<p:bg>` emission and static preview canvas painting.
|
|
199
194
|
*/
|
|
200
195
|
const slideBackgroundCapability = {
|
|
201
|
-
|
|
202
|
-
slideProp: "background",
|
|
203
|
-
consumesOwnerBackgroundStyle: true,
|
|
196
|
+
...backgroundSlots,
|
|
204
197
|
slot: "background",
|
|
205
198
|
always: true,
|
|
206
199
|
codegen: slideBackgroundCodegen,
|
|
@@ -210,19 +203,20 @@ const slideBackgroundCapability = {
|
|
|
210
203
|
slideBackgroundImageMechanism,
|
|
211
204
|
slideBackgroundRefMechanism
|
|
212
205
|
],
|
|
213
|
-
bindSlide(input, context) {
|
|
206
|
+
*bindSlide(input, context) {
|
|
214
207
|
const rawStyle = input.props["style"];
|
|
215
208
|
const styleBackground = typeof rawStyle === "object" && rawStyle !== null && !Array.isArray(rawStyle) ? rawStyle["background"] : void 0;
|
|
216
209
|
const backgroundField = styleBackground !== void 0 ? "style.background" : "background";
|
|
217
210
|
const background = styleBackground ?? input.props["background"];
|
|
211
|
+
let initial;
|
|
218
212
|
try {
|
|
219
|
-
resolveSlideBackground(context.theme, background);
|
|
213
|
+
initial = yield* resolveSlideBackground(context.theme, background, backgroundField);
|
|
220
214
|
} catch (error) {
|
|
221
|
-
if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, `${context.path}/background
|
|
215
|
+
if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, error.code === "invalid-slide-background" || error.code === "invalid-gradient" ? context.path : `${context.path}/background`, error.details);
|
|
222
216
|
throw error;
|
|
223
217
|
}
|
|
224
218
|
return { resolveSlide(resolveContext) {
|
|
225
|
-
const resolved = resolveSlideBackground(resolveContext.theme, background);
|
|
219
|
+
const resolved = initial.kind === "image" ? initial : finishResolveWork(resolveSlideBackground(resolveContext.theme, background, backgroundField));
|
|
226
220
|
return {
|
|
227
221
|
extensions: [],
|
|
228
222
|
emit(emitContext) {
|