@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,41 +1,16 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import { isMorphKey } from "
|
|
3
|
-
import { parseLinkTarget } from "
|
|
4
|
-
import "
|
|
5
|
-
import
|
|
6
|
-
import "
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import "../../../import/dist/index.js";
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { isMorphKey } from "../../kernel/morph.js";
|
|
3
|
+
import { parseLinkTarget } from "../../kernel/author-schemas.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import "../../kernel/pptx-read/index.js";
|
|
6
|
+
import { A_NS, P_NS, REL_HYPERLINK, R_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
7
|
+
import { resolvePartPath } from "../../kernel/pptx-read/opc.js";
|
|
8
|
+
import { ooxmlBoolSchema, ooxmlNonNegativeIntSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
9
|
+
import { resolveExternalRelationshipTarget } from "../../kernel/pptx-read/resources.js";
|
|
10
|
+
import { xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
12
11
|
import { z } from "zod";
|
|
13
|
-
// ../
|
|
12
|
+
// ../core/dist/capabilities/shared/identity.js
|
|
14
13
|
const NvPrUserDrawnSchema = z.object({ userDrawn: ooxmlBoolSchema.optional() });
|
|
15
|
-
function directChildDom(parent, namespaceUri, localName) {
|
|
16
|
-
for (let child = parent.firstChild; child !== null; child = child.nextSibling) {
|
|
17
|
-
if (child.nodeType !== 1) continue;
|
|
18
|
-
const el = child;
|
|
19
|
-
if ((el.namespaceURI ?? "") === namespaceUri && (el.localName ?? el.tagName) === localName) return el;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** Side-effect-free check for `<p:ph>` inside an object's `<p:nvPr>`. */
|
|
23
|
-
function hasPlaceholderElement(cursor) {
|
|
24
|
-
for (const wrapperName of [
|
|
25
|
-
"nvSpPr",
|
|
26
|
-
"nvPicPr",
|
|
27
|
-
"nvGrpSpPr",
|
|
28
|
-
"nvGraphicFramePr",
|
|
29
|
-
"nvCxnSpPr"
|
|
30
|
-
]) {
|
|
31
|
-
const wrapper = directChildDom(cursor.element, P_NS, wrapperName);
|
|
32
|
-
if (wrapper === void 0) continue;
|
|
33
|
-
const nvPr = directChildDom(wrapper, P_NS, "nvPr");
|
|
34
|
-
if (nvPr === void 0) continue;
|
|
35
|
-
if (directChildDom(nvPr, "http://schemas.openxmlformats.org/presentationml/2006/main", "ph") !== void 0) return true;
|
|
36
|
-
}
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
14
|
/** Consumes `<p:nvPr>` (and optional `userDrawn` flag) for non-placeholder objects. */
|
|
40
15
|
function consumeNonPlaceholderNvPr(nvParentCursor) {
|
|
41
16
|
const nvPr = nvParentCursor.child(P_NS, "nvPr");
|
|
@@ -52,7 +27,7 @@ const HlinkClickFragmentSchema = z.object({
|
|
|
52
27
|
function parseOptionalName(value, path) {
|
|
53
28
|
if (value === void 0) return void 0;
|
|
54
29
|
const parsed = optionalNameSchema.safeParse(value);
|
|
55
|
-
if (!parsed.success) throw new CapabilityError("invalid-parameter", "name must be a non-empty string", path);
|
|
30
|
+
if (!parsed.success) throw new CapabilityError("invalid-parameter", "name must be a non-empty string", path, { field: "name" });
|
|
56
31
|
return parsed.data;
|
|
57
32
|
}
|
|
58
33
|
/** Validates an optional Morph handle created by createMorphScope().handle(name). */
|
|
@@ -202,4 +177,47 @@ function attachDeferredSlideLink(node, deferredSlideLink, context) {
|
|
|
202
177
|
}
|
|
203
178
|
});
|
|
204
179
|
}
|
|
205
|
-
|
|
180
|
+
const NonVisualIdAttrSchema = z.object({
|
|
181
|
+
id: ooxmlNonNegativeIntSchema,
|
|
182
|
+
name: z.string().optional()
|
|
183
|
+
});
|
|
184
|
+
/** Reads `<p:cNvPr>` id, name, and hyperlink without assuming shape vs group wrapper tag. */
|
|
185
|
+
function readNonVisualCommonProperties(cNvPrCursor, context, diagnostics) {
|
|
186
|
+
if (cNvPrCursor === void 0) return {};
|
|
187
|
+
const raw = cNvPrCursor.attrsObject(["id", "name"]);
|
|
188
|
+
const parsed = NonVisualIdAttrSchema.safeParse(raw);
|
|
189
|
+
let objectId;
|
|
190
|
+
let objectName;
|
|
191
|
+
if (!parsed.success) diagnostics.push({
|
|
192
|
+
code: "invalid-xml-value",
|
|
193
|
+
category: "corrupt-input",
|
|
194
|
+
disposition: "recovered",
|
|
195
|
+
location: {
|
|
196
|
+
part: context.part,
|
|
197
|
+
xpath: cNvPrCursor.xpath,
|
|
198
|
+
slideIndex: context.slideIndex
|
|
199
|
+
},
|
|
200
|
+
attributeOrElement: "p:cNvPr",
|
|
201
|
+
rawValue: JSON.stringify(raw)
|
|
202
|
+
});
|
|
203
|
+
else {
|
|
204
|
+
objectId = parsed.data.id;
|
|
205
|
+
if (parsed.data.name !== void 0 && parsed.data.name.trim() !== "") objectName = parsed.data.name;
|
|
206
|
+
}
|
|
207
|
+
const hlinkClick = cNvPrCursor.child(A_NS, "hlinkClick");
|
|
208
|
+
let clickResult;
|
|
209
|
+
if (hlinkClick !== void 0) {
|
|
210
|
+
clickResult = readClickLink(hlinkClick, context, {
|
|
211
|
+
...objectId === void 0 ? {} : { objectId },
|
|
212
|
+
...objectName === void 0 ? {} : { objectName }
|
|
213
|
+
});
|
|
214
|
+
diagnostics.push(...clickResult.diagnostics);
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
...objectId === void 0 ? {} : { objectId },
|
|
218
|
+
...objectName === void 0 ? {} : { objectName },
|
|
219
|
+
...clickResult?.link === void 0 ? {} : { link: clickResult.link },
|
|
220
|
+
...clickResult?.deferredSlideLink === void 0 ? {} : { deferredSlideLink: clickResult.deferredSlideLink }
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
export { attachDeferredSlideLink, consumeNonPlaceholderNvPr, nativeLinkXml, optionalNameSchema, parseLinkTarget, parseMorphKey, parseOptionalName, readClickLink, readNonVisualCommonProperties };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { markImmutableBytes } from "../../kernel/font-seal.js";
|
|
2
|
+
import { externalResourceSourceSchema } from "../../kernel/resource-source.js";
|
|
3
|
+
import { imageBackgroundObjectSchema } from "../../kernel/theme.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import { expr } from "../../kernel/codegen.js";
|
|
6
|
+
import { CommonNode } from "../../kernel/document.js";
|
|
7
|
+
import { finishResolveWork } from "../../kernel/resolve-work.js";
|
|
8
|
+
import { readImage } from "./image-decode.js";
|
|
9
|
+
import { imageStyleSchema } from "./image-schemas.js";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { readFileSync } from "node:fs";
|
|
12
|
+
// ../core/dist/capabilities/shared/image-codegen.js
|
|
13
|
+
function readCodegenImage(source) {
|
|
14
|
+
return finishResolveWork(readImage(source), (path) => markImmutableBytes(readFileSync(path instanceof URL ? fileURLToPath(path) : path)));
|
|
15
|
+
}
|
|
16
|
+
const dummyImageBytes = new Uint8Array([0]);
|
|
17
|
+
function isPlainObject(value) {
|
|
18
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
19
|
+
const proto = Object.getPrototypeOf(value);
|
|
20
|
+
return proto === Object.prototype || proto === null;
|
|
21
|
+
}
|
|
22
|
+
function assertNoLeafDeclarationChildren(label, node, ctx) {
|
|
23
|
+
for (const child of node.children) {
|
|
24
|
+
if (child instanceof CommonNode) ctx.fail("invalid-document", `${label} does not accept child declarations`);
|
|
25
|
+
const leaf = child;
|
|
26
|
+
if (leaf.type === "#text" && leaf.text.trim() !== "") ctx.fail("invalid-document", `${label} does not accept text children`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function serializeImageSrcProp(value, ctx, field = "@src", label = "Image.src") {
|
|
30
|
+
if (isPlainObject(value) && Object.hasOwn(value, "externalUrl")) {
|
|
31
|
+
const parsedExternal = externalResourceSourceSchema.safeParse(value);
|
|
32
|
+
if (!parsedExternal.success) ctx.fail("unexpressible-value", `${label} externalUrl must be a non-empty string`, field);
|
|
33
|
+
return expr(ctx.emitValueExpr({ externalUrl: parsedExternal.data.externalUrl }, field));
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
const loaded = readCodegenImage(value);
|
|
37
|
+
const assetVar = ctx.registerImageAsset(loaded.bytes, loaded.extension);
|
|
38
|
+
return expr(assetVar);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
return ctx.fail("unexpressible-value", error instanceof Error ? error.message : `${label} could not be read or decoded`, field);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function serializeImageStyleProp(style, ctx) {
|
|
44
|
+
if (!isPlainObject(style)) ctx.fail("unexpressible-value", "Image.style must be a plain object", "@style");
|
|
45
|
+
const parsed = imageStyleSchema.safeParse(style);
|
|
46
|
+
if (!parsed.success) {
|
|
47
|
+
const issue = parsed.error.issues[0];
|
|
48
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
49
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Image.style cannot be expressed", issuePath);
|
|
50
|
+
}
|
|
51
|
+
const styleEntries = [];
|
|
52
|
+
for (const [key, entryValue] of Object.entries(style)) {
|
|
53
|
+
if (entryValue === void 0) continue;
|
|
54
|
+
if (key === "background") {
|
|
55
|
+
const serializedBg = serializeImageDescriptorValue(entryValue, ctx);
|
|
56
|
+
styleEntries.push([key, serializedBg ?? entryValue]);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
styleEntries.push([key, entryValue]);
|
|
60
|
+
}
|
|
61
|
+
return expr(ctx.formatProps(styleEntries));
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Serializes an `{ image, fit?, position?, opacity? }` descriptor (used in `style.background`
|
|
65
|
+
* and `Slide.background`) by reading/validating embedded image bytes or `{ externalUrl }`
|
|
66
|
+
* and emitting a formatted descriptor expression.
|
|
67
|
+
*/
|
|
68
|
+
function serializeImageDescriptorValue(value, ctx) {
|
|
69
|
+
if (!isPlainObject(value) || value["image"] === void 0) return;
|
|
70
|
+
if (Object.keys(value).some((key) => value[key] !== void 0 && !Object.hasOwn(imageBackgroundObjectSchema.shape, key))) return;
|
|
71
|
+
const subPath = ctx.path.includes("@") ? void 0 : "@style.background";
|
|
72
|
+
const rawSource = value["image"];
|
|
73
|
+
let imageExpr;
|
|
74
|
+
if (isPlainObject(rawSource) && Object.hasOwn(rawSource, "externalUrl")) {
|
|
75
|
+
const parsedExternal = externalResourceSourceSchema.safeParse(rawSource);
|
|
76
|
+
if (!parsedExternal.success) ctx.fail("unexpressible-value", "Background image externalUrl must be a non-empty string", subPath);
|
|
77
|
+
imageExpr = expr(ctx.emitValueExpr({ externalUrl: parsedExternal.data.externalUrl }, subPath));
|
|
78
|
+
} else try {
|
|
79
|
+
const loaded = readCodegenImage(rawSource);
|
|
80
|
+
const assetVar = ctx.registerImageAsset(loaded.bytes, loaded.extension);
|
|
81
|
+
imageExpr = expr(assetVar);
|
|
82
|
+
} catch (error) {
|
|
83
|
+
ctx.fail("unexpressible-value", error instanceof Error ? error.message : "Background image source could not be read or decoded", subPath);
|
|
84
|
+
}
|
|
85
|
+
const parsedOptions = imageBackgroundObjectSchema.safeParse({
|
|
86
|
+
...value,
|
|
87
|
+
image: dummyImageBytes
|
|
88
|
+
});
|
|
89
|
+
if (!parsedOptions.success) ctx.fail("unexpressible-value", parsedOptions.error.issues[0]?.message ?? "Background image descriptor options are invalid", subPath);
|
|
90
|
+
const descriptorEntries = [["image", imageExpr]];
|
|
91
|
+
for (const [optionKey, optionValue] of Object.entries(parsedOptions.data)) if (optionKey !== "image" && optionValue !== void 0) descriptorEntries.push([optionKey, expr(ctx.emitValueExpr(optionValue, subPath))]);
|
|
92
|
+
return expr(ctx.formatProps(descriptorEntries));
|
|
93
|
+
}
|
|
94
|
+
export { assertNoLeafDeclarationChildren, isPlainObject, serializeImageDescriptorValue, serializeImageSrcProp, serializeImageStyleProp };
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import "
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { readFileSync } from "node:fs";
|
|
6
|
-
import { fileURLToPath } from "node:url";
|
|
7
|
-
// ../capabilities/dist/image/image-decode.js
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { isImmutableBytes, markImmutableBytes } from "../../kernel/font-seal.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
// ../core/dist/capabilities/shared/image-decode.js
|
|
8
5
|
function uint32(data, offset) {
|
|
9
6
|
return ((data[offset] ?? 0) << 24 >>> 0) + ((data[offset + 1] ?? 0) << 16) + ((data[offset + 2] ?? 0) << 8) + (data[offset + 3] ?? 0);
|
|
10
7
|
}
|
|
@@ -160,15 +157,9 @@ function gifMetadata(data) {
|
|
|
160
157
|
hasImageData = true;
|
|
161
158
|
}
|
|
162
159
|
}
|
|
163
|
-
/**
|
|
164
|
-
function
|
|
165
|
-
|
|
166
|
-
let bytes;
|
|
167
|
-
try {
|
|
168
|
-
bytes = source instanceof Uint8Array ? new Uint8Array(source) : new Uint8Array(readFileSync(source instanceof URL ? fileURLToPath(source) : source));
|
|
169
|
-
} catch {
|
|
170
|
-
throw new CapabilityError("image-read-failed", "Failed to read image resource");
|
|
171
|
-
}
|
|
160
|
+
/** Validates PNG, JPEG, or GIF header metadata from owned or caller-provided bytes. */
|
|
161
|
+
function readImageBytes(source) {
|
|
162
|
+
const bytes = isImmutableBytes(source) ? source : markImmutableBytes(new Uint8Array(source));
|
|
172
163
|
const metadata = pngMetadata(bytes) ?? jpegMetadata(bytes) ?? gifMetadata(bytes);
|
|
173
164
|
if (metadata === void 0) throw new CapabilityError("unsupported-image-format", "Invalid image resource content or unsupported format; only PNG, JPEG, and GIF are supported");
|
|
174
165
|
return {
|
|
@@ -176,46 +167,16 @@ function readImage(source) {
|
|
|
176
167
|
bytes
|
|
177
168
|
};
|
|
178
169
|
}
|
|
179
|
-
|
|
180
|
-
function
|
|
181
|
-
if (
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
png: require("pngjs"),
|
|
185
|
-
jpeg: require("jpeg-js")
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
return cachedDecoders;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Decodes PNG, JPEG, or static first-frame GIF bytes into normalized PNG bytes for SVG embedding.
|
|
192
|
-
* Throws `preview-corrupt-image` if compressed pixel data is invalid.
|
|
193
|
-
*/
|
|
194
|
-
function decodeImageToPngBytes(image) {
|
|
195
|
-
const { png: pngModule, jpeg: jpegModule } = imageDecoders();
|
|
196
|
-
let decoded;
|
|
170
|
+
/** Resolves embedded image bytes at their binding site, preserving source diagnostics. */
|
|
171
|
+
function* readImage(source) {
|
|
172
|
+
if (source instanceof Uint8Array) return readImageBytes(source);
|
|
173
|
+
if (typeof source !== "string" && !(source instanceof URL)) throw new CapabilityError("invalid-image-source", "Image.src must be a file path, file URL, or image bytes");
|
|
174
|
+
let bytes;
|
|
197
175
|
try {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
break;
|
|
202
|
-
case "jpeg":
|
|
203
|
-
decoded = jpegModule.decode(image.bytes, { tolerantDecoding: false });
|
|
204
|
-
break;
|
|
205
|
-
case "gif":
|
|
206
|
-
decoded = decodeGifFirstFrame(image.bytes);
|
|
207
|
-
break;
|
|
208
|
-
default: return image.extension;
|
|
209
|
-
}
|
|
210
|
-
} catch (error) {
|
|
211
|
-
if (error instanceof CapabilityError) throw error;
|
|
212
|
-
throw new CapabilityError("preview-corrupt-image", error instanceof Error ? `Failed to decode ${image.extension.toUpperCase()} image for preview: ${error.message}` : `Failed to decode ${image.extension.toUpperCase()} image for preview`);
|
|
176
|
+
bytes = yield source;
|
|
177
|
+
} catch {
|
|
178
|
+
throw new CapabilityError("image-read-failed", "Failed to read image resource");
|
|
213
179
|
}
|
|
214
|
-
|
|
215
|
-
width: decoded.width,
|
|
216
|
-
height: decoded.height
|
|
217
|
-
});
|
|
218
|
-
normalized.data = Buffer.from(decoded.data);
|
|
219
|
-
return new Uint8Array(pngModule.PNG.sync.write(normalized));
|
|
180
|
+
return readImageBytes(bytes);
|
|
220
181
|
}
|
|
221
|
-
export {
|
|
182
|
+
export { readImage, readImageBytes };
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
import { authorIdSchema } from "
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import "
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
2
|
+
import { layoutStyleShape } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { geometrySchema } from "../../kernel/geometry-schemas.js";
|
|
4
|
+
import { resourceSourceSchema } from "../../kernel/resource-source.js";
|
|
5
|
+
import { visualStyleShape } from "../../kernel/theme.js";
|
|
6
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
7
|
+
import "./geometry.js";
|
|
8
|
+
import { optionalNameSchema } from "./identity.js";
|
|
9
|
+
import { morphKeySchema } from "./morph-api.js";
|
|
10
|
+
import { ooxmlIntSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema, ooxmlPositiveLineWidthEmuSchema, ooxmlWritableExtentEmuSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
11
|
+
import { motionPropsShape } from "./motion-schemas.js";
|
|
12
|
+
import "../../kernel/capability.js";
|
|
13
|
+
import "../../kernel/pptx-read/index.js";
|
|
14
14
|
import { z } from "zod";
|
|
15
|
-
// ../
|
|
16
|
-
const
|
|
15
|
+
// ../core/dist/capabilities/shared/image-schemas.js
|
|
16
|
+
const rawImageFitSchema = z.enum([
|
|
17
17
|
"fill",
|
|
18
18
|
"cover",
|
|
19
19
|
"contain"
|
|
20
20
|
]);
|
|
21
|
+
const imageFitSchema = rawImageFitSchema;
|
|
21
22
|
const cropFractionSchema = z.number().finite().min(0).max(1);
|
|
22
|
-
const
|
|
23
|
+
const rawImageCropInputSchema = z.strictObject({
|
|
23
24
|
left: cropFractionSchema.optional(),
|
|
24
25
|
top: cropFractionSchema.optional(),
|
|
25
26
|
right: cropFractionSchema.optional(),
|
|
@@ -36,60 +37,47 @@ const imageCropInputSchema = z.strictObject({
|
|
|
36
37
|
path: ["top"]
|
|
37
38
|
});
|
|
38
39
|
});
|
|
39
|
-
const
|
|
40
|
-
const imageSourceSchema = z.union([
|
|
41
|
-
z.string(),
|
|
42
|
-
z.instanceof(URL),
|
|
43
|
-
z.custom((value) => value instanceof Uint8Array),
|
|
44
|
-
externalImageSourceSchema
|
|
45
|
-
]);
|
|
40
|
+
const imageCropInputSchema = rawImageCropInputSchema;
|
|
46
41
|
const imageCoordinateValueSchema = z.number().finite().min(-1e6).max(1e6);
|
|
47
42
|
const imageExtentValueSchema = z.number().finite().positive();
|
|
48
|
-
const coreVisualShape = visualStyleSchema.unwrap().shape;
|
|
49
43
|
const imageVisualStyleObjectSchema = z.strictObject({
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
44
|
+
background: visualStyleShape.background,
|
|
45
|
+
border: visualStyleShape.border,
|
|
46
|
+
opacity: visualStyleShape.opacity,
|
|
47
|
+
boxShadow: visualStyleShape.boxShadow,
|
|
48
|
+
softEdge: visualStyleShape.softEdge,
|
|
49
|
+
rotate: visualStyleShape.rotate,
|
|
50
|
+
flipH: visualStyleShape.flipH,
|
|
51
|
+
flipV: visualStyleShape.flipV
|
|
57
52
|
});
|
|
58
53
|
imageVisualStyleObjectSchema.readonly();
|
|
59
54
|
const imageVisualStyleKeys = new Set(Object.keys(imageVisualStyleObjectSchema.shape));
|
|
60
|
-
const
|
|
61
|
-
...
|
|
55
|
+
const imageStyleObjectSchema = z.strictObject({
|
|
56
|
+
...layoutStyleShape,
|
|
62
57
|
...imageVisualStyleObjectSchema.shape
|
|
63
|
-
})
|
|
64
|
-
const
|
|
58
|
+
});
|
|
59
|
+
const imageStyleKeys = Object.keys(imageStyleObjectSchema.shape);
|
|
60
|
+
const rawImageStyleSchema = imageStyleObjectSchema.readonly();
|
|
61
|
+
const imageStyleSchema = rawImageStyleSchema;
|
|
65
62
|
const imageDeclarationPropsObjectSchema = z.strictObject({
|
|
66
63
|
id: authorIdSchema.optional(),
|
|
67
64
|
name: optionalNameSchema.optional(),
|
|
68
65
|
placeholder: z.string().optional(),
|
|
69
|
-
nativePlaceholder: nativePlaceholderRefSchema.optional(),
|
|
70
66
|
morphKey: morphKeySchema.optional(),
|
|
71
67
|
link: linkTargetSchema.optional(),
|
|
72
|
-
src:
|
|
68
|
+
src: resourceSourceSchema,
|
|
73
69
|
/** Alternative text for the image. */
|
|
74
70
|
alt: z.string().optional(),
|
|
75
|
-
/** Position and bounds in px; position defaults to 0, width and height default to original image dimensions. */
|
|
76
|
-
x: imageCoordinateValueSchema.optional(),
|
|
77
|
-
y: imageCoordinateValueSchema.optional(),
|
|
78
|
-
width: imageExtentValueSchema.optional(),
|
|
79
|
-
height: imageExtentValueSchema.optional(),
|
|
80
71
|
geometry: geometrySchema.optional(),
|
|
81
|
-
|
|
82
|
-
flipV: z.boolean().optional(),
|
|
83
|
-
style: imageStyleSchema.optional(),
|
|
72
|
+
style: rawImageStyleSchema.optional(),
|
|
84
73
|
/** `fill` stretches, `cover` crops centered, `contain` preserves aspect ratio; defaults to `fill`. */
|
|
85
|
-
fit:
|
|
74
|
+
fit: rawImageFitSchema.optional(),
|
|
86
75
|
/** Explicit crop fraction for each side of the original image; takes precedence over `fit` when provided. */
|
|
87
|
-
crop:
|
|
88
|
-
|
|
89
|
-
emphasis: motionPropsShape.emphasis,
|
|
90
|
-
motion: motionPropsShape.motion
|
|
76
|
+
crop: rawImageCropInputSchema.optional(),
|
|
77
|
+
...motionPropsShape
|
|
91
78
|
});
|
|
92
|
-
const
|
|
79
|
+
const imageAltSchema = imageDeclarationPropsObjectSchema.shape.alt;
|
|
80
|
+
imageDeclarationPropsObjectSchema.readonly();
|
|
93
81
|
const imageAllowedParameters = Object.keys(imageDeclarationPropsObjectSchema.shape);
|
|
94
82
|
const nonVisualPicIdSchema = z.object({
|
|
95
83
|
id: ooxmlNonNegativeIntSchema,
|
|
@@ -110,8 +98,8 @@ const geomGuideFragmentSchema = z.object({
|
|
|
110
98
|
fmla: z.string().regex(/^val (-?\d+)$/u)
|
|
111
99
|
});
|
|
112
100
|
const customPathAttributesSchema = z.object({
|
|
113
|
-
w: ooxmlPositiveIntSchema.optional(),
|
|
114
|
-
h: ooxmlPositiveIntSchema.optional(),
|
|
101
|
+
w: ooxmlPositiveIntSchema.refine((v) => v <= 2147483647).optional(),
|
|
102
|
+
h: ooxmlPositiveIntSchema.refine((v) => v <= 2147483647).optional(),
|
|
115
103
|
fill: z.enum([
|
|
116
104
|
"none",
|
|
117
105
|
"norm",
|
|
@@ -128,10 +116,10 @@ const customPathAttributesSchema = z.object({
|
|
|
128
116
|
]).optional()
|
|
129
117
|
});
|
|
130
118
|
const customPathPointSchema = z.object({
|
|
131
|
-
x: ooxmlIntSchema,
|
|
132
|
-
y: ooxmlIntSchema
|
|
119
|
+
x: ooxmlIntSchema.refine((v) => v >= -2147483647 && v <= 2147483647),
|
|
120
|
+
y: ooxmlIntSchema.refine((v) => v >= -2147483647 && v <= 2147483647)
|
|
133
121
|
});
|
|
134
|
-
const lineAttributesFragmentSchema = z.object({ w:
|
|
122
|
+
const lineAttributesFragmentSchema = z.object({ w: ooxmlPositiveLineWidthEmuSchema.optional() });
|
|
135
123
|
const presetDashFragmentSchema = z.object({ val: z.enum([
|
|
136
124
|
"solid",
|
|
137
125
|
"dash",
|
|
@@ -139,11 +127,11 @@ const presetDashFragmentSchema = z.object({ val: z.enum([
|
|
|
139
127
|
"dot"
|
|
140
128
|
]) });
|
|
141
129
|
const outerShadowFragmentSchema = z.object({
|
|
142
|
-
blurRad:
|
|
143
|
-
dist:
|
|
144
|
-
dir:
|
|
130
|
+
blurRad: ooxmlWritableExtentEmuSchema.optional(),
|
|
131
|
+
dist: ooxmlWritableExtentEmuSchema.optional(),
|
|
132
|
+
dir: ooxmlIntSchema.optional(),
|
|
145
133
|
algn: z.string().optional(),
|
|
146
134
|
rotWithShape: z.string().optional()
|
|
147
135
|
});
|
|
148
|
-
const softEdgeFragmentSchema = z.object({ rad:
|
|
149
|
-
export { alphaModFixFragmentSchema, cropFractionSchema, customPathAttributesSchema, customPathPointSchema,
|
|
136
|
+
const softEdgeFragmentSchema = z.object({ rad: ooxmlWritableExtentEmuSchema });
|
|
137
|
+
export { alphaModFixFragmentSchema, cropFractionSchema, customPathAttributesSchema, customPathPointSchema, geomGuideFragmentSchema, imageAllowedParameters, imageAltSchema, imageCoordinateValueSchema, imageCropInputSchema, imageExtentValueSchema, imageFitSchema, imageStyleKeys, imageStyleSchema, imageVisualStyleKeys, lineAttributesFragmentSchema, nonVisualPicIdSchema, outerShadowFragmentSchema, presetDashFragmentSchema, presetGeomFragmentSchema, softEdgeFragmentSchema, srcRectFragmentSchema };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
2
|
+
import { directElementChild, isPlaceholderSpElement } from "./placeholder-import.js";
|
|
3
|
+
// ../core/dist/capabilities/shared/line-match.js
|
|
4
|
+
const linePresetNames = /* @__PURE__ */ new Set([
|
|
5
|
+
"line",
|
|
6
|
+
"lineInv",
|
|
7
|
+
"straightConnector1",
|
|
8
|
+
"bentConnector2",
|
|
9
|
+
"bentConnector3",
|
|
10
|
+
"bentConnector4",
|
|
11
|
+
"bentConnector5",
|
|
12
|
+
"curvedConnector2",
|
|
13
|
+
"curvedConnector3",
|
|
14
|
+
"curvedConnector4",
|
|
15
|
+
"curvedConnector5"
|
|
16
|
+
]);
|
|
17
|
+
const fillElementNames = /* @__PURE__ */ new Set([
|
|
18
|
+
"solidFill",
|
|
19
|
+
"gradFill",
|
|
20
|
+
"blipFill",
|
|
21
|
+
"pattFill",
|
|
22
|
+
"grpFill"
|
|
23
|
+
]);
|
|
24
|
+
function hasTextBoxFlag(spElement) {
|
|
25
|
+
const nvSpPr = directElementChild(spElement, P_NS, "nvSpPr");
|
|
26
|
+
if (nvSpPr === void 0) return false;
|
|
27
|
+
const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
|
|
28
|
+
if (cNvSpPr === void 0) return false;
|
|
29
|
+
const txBox = cNvSpPr.getAttribute("txBox");
|
|
30
|
+
return txBox === "1" || txBox === "true";
|
|
31
|
+
}
|
|
32
|
+
function hasEffectiveSpText(spElement) {
|
|
33
|
+
const txBody = directElementChild(spElement, P_NS, "txBody");
|
|
34
|
+
if (txBody === void 0) return false;
|
|
35
|
+
for (let child = txBody.firstChild; child !== null; child = child.nextSibling) {
|
|
36
|
+
if (child.nodeType !== 1) continue;
|
|
37
|
+
const pEl = child;
|
|
38
|
+
if ((pEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/drawingml/2006/main" || (pEl.localName ?? pEl.tagName) !== "p") continue;
|
|
39
|
+
const pPr = directElementChild(pEl, A_NS, "pPr");
|
|
40
|
+
if (pPr !== void 0) {
|
|
41
|
+
if (directElementChild(pPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "buChar") !== void 0 || directElementChild(pPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "buAutoNum") !== void 0 || directElementChild(pPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "defRPr") !== void 0) return true;
|
|
42
|
+
}
|
|
43
|
+
if (directElementChild(pEl, "http://schemas.openxmlformats.org/drawingml/2006/main", "r") !== void 0 || directElementChild(pEl, "http://schemas.openxmlformats.org/drawingml/2006/main", "fld") !== void 0 || directElementChild(pEl, "http://schemas.openxmlformats.org/drawingml/2006/main", "br") !== void 0) return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Side-effect-free predicate matching `<p:sp>` elements that represent pure 1D lines or connectors
|
|
49
|
+
* (no fill, no effective text, and a `line` / `lineInv` / `*Connector*` preset geometry).
|
|
50
|
+
*/
|
|
51
|
+
function isLineNormalizedSpElement(cursor) {
|
|
52
|
+
if (isPlaceholderSpElement(cursor)) return false;
|
|
53
|
+
const spEl = cursor.element;
|
|
54
|
+
if (hasTextBoxFlag(spEl)) return false;
|
|
55
|
+
const spPr = directElementChild(spEl, P_NS, "spPr");
|
|
56
|
+
if (spPr === void 0) return false;
|
|
57
|
+
if (directElementChild(spPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "custGeom") !== void 0) return false;
|
|
58
|
+
const prstGeom = directElementChild(spPr, A_NS, "prstGeom");
|
|
59
|
+
if (prstGeom === void 0) return false;
|
|
60
|
+
const prst = prstGeom.getAttribute("prst") ?? "";
|
|
61
|
+
if (!linePresetNames.has(prst)) return false;
|
|
62
|
+
for (let child = spPr.firstChild; child !== null; child = child.nextSibling) {
|
|
63
|
+
if (child.nodeType !== 1) continue;
|
|
64
|
+
const el = child;
|
|
65
|
+
if ((el.namespaceURI ?? "") === "http://schemas.openxmlformats.org/drawingml/2006/main" && fillElementNames.has(el.localName ?? el.tagName)) return false;
|
|
66
|
+
}
|
|
67
|
+
const pStyle = directElementChild(spEl, P_NS, "style");
|
|
68
|
+
if (pStyle !== void 0) {
|
|
69
|
+
const fillRef = directElementChild(pStyle, A_NS, "fillRef");
|
|
70
|
+
if (fillRef !== void 0) {
|
|
71
|
+
const idx = fillRef.getAttribute("idx");
|
|
72
|
+
if (idx !== null && idx !== "" && idx !== "0") return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (hasEffectiveSpText(spEl)) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
export { isLineNormalizedSpElement };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../kernel/document-internals.js";
|
|
2
|
+
import { layoutStyleSchema } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { serializeGeometryProp } from "./geometry-codegen.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import { defineObjectCodegen, expr } from "../../kernel/codegen.js";
|
|
6
|
+
import { markImmutableBytes } from "../../kernel/font-seal.js";
|
|
7
|
+
import { finishResolveWork } from "../../kernel/resolve-work.js";
|
|
8
|
+
import { assertNoLeafDeclarationChildren, isPlainObject, serializeImageSrcProp, serializeImageStyleProp } from "./image-codegen.js";
|
|
9
|
+
import { audioDeclarationPropsSchema, supportsMediaProperty, videoDeclarationPropsSchema } from "./media-schemas.js";
|
|
10
|
+
import { readMediaSource } from "./media-source.js";
|
|
11
|
+
import { validateMediaTrimBounds } from "./media-trim.js";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
// ../core/dist/capabilities/shared/media-codegen.js
|
|
15
|
+
const dummySourceBytes = new Uint8Array([0]);
|
|
16
|
+
function serializeAudioStyleProp(style, ctx) {
|
|
17
|
+
if (!isPlainObject(style)) ctx.fail("unexpressible-value", "Audio.style must be a plain object", "@style");
|
|
18
|
+
const parsed = layoutStyleSchema.safeParse(style);
|
|
19
|
+
if (!parsed.success) {
|
|
20
|
+
const issue = parsed.error.issues[0];
|
|
21
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
22
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Audio.style cannot be expressed", issuePath);
|
|
23
|
+
}
|
|
24
|
+
const styleEntries = Object.entries(style).filter(([, entryValue]) => entryValue !== void 0);
|
|
25
|
+
return expr(ctx.formatProps(styleEntries));
|
|
26
|
+
}
|
|
27
|
+
function defineMediaCodegen(kind, detectMedia) {
|
|
28
|
+
const label = kind === "video" ? "Video" : "Audio";
|
|
29
|
+
const schema = kind === "video" ? videoDeclarationPropsSchema : audioDeclarationPropsSchema;
|
|
30
|
+
function collectProps(node, ctx) {
|
|
31
|
+
assertNoLeafDeclarationChildren(label, node, ctx);
|
|
32
|
+
const props = readInternalDeclarationProps(node);
|
|
33
|
+
const entries = [];
|
|
34
|
+
const schemaCandidate = { src: dummySourceBytes };
|
|
35
|
+
let sawSrc = false;
|
|
36
|
+
let loadedDuration;
|
|
37
|
+
for (const [key, value] of Object.entries(props)) {
|
|
38
|
+
if (value === void 0) continue;
|
|
39
|
+
if (!supportsMediaProperty(kind, key)) ctx.fail("invalid-document", `${kind} declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
40
|
+
if (key === "src") {
|
|
41
|
+
sawSrc = true;
|
|
42
|
+
try {
|
|
43
|
+
const loaded = finishResolveWork(readMediaSource(value, detectMedia), (file) => markImmutableBytes(readFileSync(file instanceof URL ? fileURLToPath(file) : file)));
|
|
44
|
+
loadedDuration = loaded.kind === "embedded" ? loaded.format.duration : void 0;
|
|
45
|
+
entries.push([key, loaded.kind === "external" ? { externalUrl: loaded.externalUrl } : expr(ctx.registerMediaAsset(loaded.bytes, loaded.format.extension))]);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
ctx.fail("unexpressible-value", error instanceof Error ? error.message : `${label}.src could not be read`, "@src");
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (key === "poster") {
|
|
52
|
+
entries.push([key, serializeImageSrcProp(value, ctx, "@poster", `${label}.poster`)]);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (key === "style") {
|
|
56
|
+
entries.push([key, kind === "video" ? serializeImageStyleProp(value, ctx) : serializeAudioStyleProp(value, ctx)]);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (key === "geometry") {
|
|
60
|
+
entries.push([key, serializeGeometryProp(value, ctx)]);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
schemaCandidate[key] = value;
|
|
64
|
+
entries.push([key, value]);
|
|
65
|
+
}
|
|
66
|
+
if (!sawSrc) ctx.fail("unexpressible-value", `${label} declaration is missing src`, "@src");
|
|
67
|
+
const parsed = schema.safeParse(schemaCandidate);
|
|
68
|
+
if (!parsed.success) {
|
|
69
|
+
const issue = parsed.error.issues[0];
|
|
70
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@${issue.path.join(".")}` : void 0;
|
|
71
|
+
ctx.fail("unexpressible-value", issue?.message ?? `${label} declaration cannot be expressed`, issuePath);
|
|
72
|
+
}
|
|
73
|
+
const trimIssue = validateMediaTrimBounds(parsed.data.trim, loadedDuration, parsed.data.loop ?? false);
|
|
74
|
+
if (trimIssue !== void 0) ctx.fail("unexpressible-value", trimIssue.message, loadedDuration === void 0 ? `@${trimIssue.field}` : "@trim");
|
|
75
|
+
return entries;
|
|
76
|
+
}
|
|
77
|
+
return defineObjectCodegen({ declarations: { [kind]: {
|
|
78
|
+
emitVanilla(node, ctx) {
|
|
79
|
+
return ctx.formatVanillaCall(ctx.useImport(kind), [ctx.formatProps(collectProps(node, ctx))]);
|
|
80
|
+
},
|
|
81
|
+
emitReact(node, ctx) {
|
|
82
|
+
return ctx.formatJsxElement(ctx.useImport(label), collectProps(node, ctx));
|
|
83
|
+
}
|
|
84
|
+
} } });
|
|
85
|
+
}
|
|
86
|
+
export { defineMediaCodegen };
|