@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
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { pxToEmu } from "../../kernel/drawing-units.js";
|
|
3
|
+
import { textStyleFrom } from "../../kernel/theme.js";
|
|
4
|
+
import { parseLinkTarget } from "../../kernel/author-schemas.js";
|
|
5
|
+
import { parseCapabilityLayoutContract } from "../../kernel/layout.js";
|
|
6
|
+
import { nativeLinkXml, parseMorphKey, parseOptionalName } from "../shared/identity.js";
|
|
7
|
+
import { motionContainerAnnotations, pickMotionProps, validateMotionFlag } from "../shared/motion-api.js";
|
|
8
|
+
import { defineCanvasMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
9
|
+
import "../../kernel/capability.js";
|
|
10
|
+
import "../../kernel/pptx-read/index.js";
|
|
11
|
+
import { xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
12
|
+
import { groupCodegen } from "./group-codegen.js";
|
|
13
|
+
import { groupDeclarationPropsKeys, groupStyleKeys, groupTransformShape } from "./group-declaration.js";
|
|
14
|
+
import { groupImportHandler } from "./group-import.js";
|
|
15
|
+
import { groupXml } from "./group-xml.js";
|
|
16
|
+
// ../core/dist/capabilities/group/group.js
|
|
17
|
+
const allowedParameters = groupDeclarationPropsKeys;
|
|
18
|
+
const emuPerPixel = 9525;
|
|
19
|
+
const maximumGroupExtentEmu = 2147483647;
|
|
20
|
+
function motionMembers(objects) {
|
|
21
|
+
return objects.map((object) => ({
|
|
22
|
+
id: object.id,
|
|
23
|
+
kind: object.kind,
|
|
24
|
+
name: object.name,
|
|
25
|
+
...object.authorId === void 0 ? {} : { authorId: object.authorId },
|
|
26
|
+
...object.box === void 0 ? {} : { box: object.box },
|
|
27
|
+
...object.members === void 0 ? {} : { members: motionMembers(object.members) }
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
function bounds(members) {
|
|
31
|
+
if (members.length === 0) throw new CapabilityError("empty-group", "Group requires at least one native object member");
|
|
32
|
+
const memberBoxes = members.map((member) => {
|
|
33
|
+
const box = member.box;
|
|
34
|
+
if (box === void 0 || !Number.isFinite(box.x) || !Number.isFinite(box.y) || !Number.isFinite(box.width) || !Number.isFinite(box.height) || box.width < 0 || box.height < 0 || box.width === 0 && box.height === 0) throw new CapabilityError("member-without-geometry", `Group member ${member.name} is missing composable geometry bounds`);
|
|
35
|
+
const x = pxToEmu(box.x);
|
|
36
|
+
const y = pxToEmu(box.y);
|
|
37
|
+
return {
|
|
38
|
+
x,
|
|
39
|
+
y,
|
|
40
|
+
right: x + pxToEmu(box.width),
|
|
41
|
+
bottom: y + pxToEmu(box.height)
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
const x = Math.min(...memberBoxes.map((box) => box.x));
|
|
45
|
+
const y = Math.min(...memberBoxes.map((box) => box.y));
|
|
46
|
+
const right = Math.max(...memberBoxes.map((box) => box.right));
|
|
47
|
+
const bottom = Math.max(...memberBoxes.map((box) => box.bottom));
|
|
48
|
+
const width = right - x;
|
|
49
|
+
const height = bottom - y;
|
|
50
|
+
if (width < 1) throw new CapabilityError("invalid-group-geometry", "Computed Group width is 0px; width must be greater than 0px");
|
|
51
|
+
if (height < 1) throw new CapabilityError("invalid-group-geometry", "Computed Group height is 0px; height must be greater than 0px");
|
|
52
|
+
if (width > maximumGroupExtentEmu || height > maximumGroupExtentEmu) throw new CapabilityError("invalid-group-geometry", "Group member bounds exceed writable PresentationML dimensions");
|
|
53
|
+
return {
|
|
54
|
+
emu: {
|
|
55
|
+
x,
|
|
56
|
+
y,
|
|
57
|
+
width,
|
|
58
|
+
height
|
|
59
|
+
},
|
|
60
|
+
pixels: {
|
|
61
|
+
x: x / emuPerPixel,
|
|
62
|
+
y: y / emuPerPixel,
|
|
63
|
+
width: width / emuPerPixel,
|
|
64
|
+
height: height / emuPerPixel
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const groupAllowedStyleKeys = new Set(groupStyleKeys);
|
|
69
|
+
function roundSvgNumber(value) {
|
|
70
|
+
const rounded = Math.round(value * 1e6) / 1e6;
|
|
71
|
+
return Object.is(rounded, -0) ? "0" : String(rounded);
|
|
72
|
+
}
|
|
73
|
+
function emitGroupModel(model, emitContext) {
|
|
74
|
+
return { xml: groupXml(emitContext.id, model.escapedName, model.emu, emitContext.childrenXml, model.rotation, nativeLinkXml(emitContext.nativeLink), model.flipH, model.flipV) };
|
|
75
|
+
}
|
|
76
|
+
function paintGroupModel(model, paintContext) {
|
|
77
|
+
const childrenSvg = paintContext.childrenSvg ?? "";
|
|
78
|
+
const cxNum = model.box.x + model.box.width / 2;
|
|
79
|
+
const cyNum = model.box.y + model.box.height / 2;
|
|
80
|
+
const cx = roundSvgNumber(cxNum);
|
|
81
|
+
const cy = roundSvgNumber(cyNum);
|
|
82
|
+
return { svg: `<g transform="${model.flipH || model.flipV ? `translate(${cx} ${cy}) rotate(${roundSvgNumber(model.angle)}) scale(${model.flipH ? -1 : 1} ${model.flipV ? -1 : 1}) translate(${roundSvgNumber(-cxNum)} ${roundSvgNumber(-cyNum)})` : `rotate(${roundSvgNumber(model.angle)} ${cx} ${cy})`}">${childrenSvg}</g>` };
|
|
83
|
+
}
|
|
84
|
+
/** Native canvas mechanism for PresentationML `<p:grpSp>` native groups. */
|
|
85
|
+
const groupMechanism = defineCanvasMechanism({
|
|
86
|
+
key: "group",
|
|
87
|
+
role: "canvas",
|
|
88
|
+
emit: emitGroupModel,
|
|
89
|
+
paint: paintGroupModel,
|
|
90
|
+
import: groupImportHandler
|
|
91
|
+
});
|
|
92
|
+
/** Preserves members as native objects and writes group bounds according to final member geometry; layout participation uses generic container collaboration. */
|
|
93
|
+
const groupCapability = {
|
|
94
|
+
declaration: "group",
|
|
95
|
+
codegen: groupCodegen,
|
|
96
|
+
mechanisms: [groupMechanism],
|
|
97
|
+
bind(input, context) {
|
|
98
|
+
const unknown = Object.keys(input.props).find((key) => !allowedParameters.includes(key));
|
|
99
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Group contains unsupported parameter ${unknown}`);
|
|
100
|
+
validateMotionFlag(input.props["motion"]);
|
|
101
|
+
const requestedName = parseOptionalName(input.props["name"]);
|
|
102
|
+
const morphKey = parseMorphKey(input.props["morphKey"]);
|
|
103
|
+
const link = parseLinkTarget(input.props["link"]);
|
|
104
|
+
const contract = parseCapabilityLayoutContract({
|
|
105
|
+
nativeKind: "grpSp",
|
|
106
|
+
props: input.props,
|
|
107
|
+
allowedStyleKeys: groupAllowedStyleKeys,
|
|
108
|
+
allowPadding: true,
|
|
109
|
+
isContainer: true,
|
|
110
|
+
path: context.path
|
|
111
|
+
});
|
|
112
|
+
const rawStyle = input.props["style"];
|
|
113
|
+
const styleRecord = typeof rawStyle === "object" && rawStyle !== null && !Array.isArray(rawStyle) ? rawStyle : {};
|
|
114
|
+
const rawRotation = styleRecord["rotate"];
|
|
115
|
+
if (rawRotation !== void 0 && !groupTransformShape.rotate.safeParse(rawRotation).success) throw new CapabilityError("invalid-visual-style", "rotate must be a finite angle");
|
|
116
|
+
const rotation = rawRotation;
|
|
117
|
+
const rawFlipH = styleRecord["flipH"];
|
|
118
|
+
if (rawFlipH !== void 0 && !groupTransformShape.flipH.safeParse(rawFlipH).success) throw new CapabilityError("invalid-visual-style", "flipH must be a boolean");
|
|
119
|
+
const rawFlipV = styleRecord["flipV"];
|
|
120
|
+
if (rawFlipV !== void 0 && !groupTransformShape.flipV.safeParse(rawFlipV).success) throw new CapabilityError("invalid-visual-style", "flipV must be a boolean");
|
|
121
|
+
const flipH = Boolean(rawFlipH);
|
|
122
|
+
const flipV = Boolean(rawFlipV);
|
|
123
|
+
const theme = context.theme.with(textStyleFrom(styleRecord));
|
|
124
|
+
const authorId = typeof input.props["id"] === "string" ? input.props["id"] : void 0;
|
|
125
|
+
const motionProps = pickMotionProps(input.props);
|
|
126
|
+
const container = {
|
|
127
|
+
children: input.children,
|
|
128
|
+
theme,
|
|
129
|
+
emitsObject: true,
|
|
130
|
+
childComposition: "members",
|
|
131
|
+
restrictsMemberContinuity: true,
|
|
132
|
+
observesLayout: false,
|
|
133
|
+
propagatesBaseline: false
|
|
134
|
+
};
|
|
135
|
+
const native = {
|
|
136
|
+
...morphKey === void 0 ? {} : { morphKey },
|
|
137
|
+
...requestedName === void 0 ? {} : { hasExplicitName: true },
|
|
138
|
+
...link === void 0 ? {} : { link }
|
|
139
|
+
};
|
|
140
|
+
return {
|
|
141
|
+
contract,
|
|
142
|
+
container,
|
|
143
|
+
...morphKey !== void 0 || requestedName !== void 0 || link !== void 0 ? { native } : {},
|
|
144
|
+
resolve(resolveContext) {
|
|
145
|
+
const resolvedChildren = resolveContext.resolveChildren(input.children);
|
|
146
|
+
const geometry = bounds(resolvedChildren.objects);
|
|
147
|
+
const layoutBox = resolveContext.layoutBox;
|
|
148
|
+
const isPositioned = contract.positioned === true;
|
|
149
|
+
const fixedAxes = contract.fixedAxes ?? {
|
|
150
|
+
width: false,
|
|
151
|
+
height: false
|
|
152
|
+
};
|
|
153
|
+
const sizedAxes = resolveContext.layoutSizedAxes ?? fixedAxes;
|
|
154
|
+
const hasLayoutWidth = sizedAxes.width;
|
|
155
|
+
const hasLayoutHeight = sizedAxes.height;
|
|
156
|
+
let outputGeometry;
|
|
157
|
+
if (isPositioned) {
|
|
158
|
+
const memberBounds = geometry.pixels;
|
|
159
|
+
if (layoutBox !== void 0) {
|
|
160
|
+
const resolvedWidth = fixedAxes.width || hasLayoutWidth && layoutBox.width > 0 ? layoutBox.width : memberBounds.width > 0 ? Math.max(layoutBox.width, memberBounds.width, memberBounds.x + memberBounds.width - layoutBox.x) : layoutBox.width;
|
|
161
|
+
const resolvedHeight = fixedAxes.height || hasLayoutHeight && layoutBox.height > 0 ? layoutBox.height : memberBounds.height > 0 ? Math.max(layoutBox.height, memberBounds.height, memberBounds.y + memberBounds.height - layoutBox.y) : layoutBox.height;
|
|
162
|
+
outputGeometry = {
|
|
163
|
+
x: layoutBox.x,
|
|
164
|
+
y: layoutBox.y,
|
|
165
|
+
width: resolvedWidth,
|
|
166
|
+
height: resolvedHeight
|
|
167
|
+
};
|
|
168
|
+
} else outputGeometry = memberBounds;
|
|
169
|
+
} else {
|
|
170
|
+
const memberBounds = geometry.pixels;
|
|
171
|
+
const useLayoutWidth = fixedAxes.width || hasLayoutWidth && layoutBox !== void 0 && layoutBox.width > 0;
|
|
172
|
+
const useLayoutHeight = fixedAxes.height || hasLayoutHeight && layoutBox !== void 0 && layoutBox.height > 0;
|
|
173
|
+
if (layoutBox !== void 0 && useLayoutWidth && useLayoutHeight) outputGeometry = layoutBox;
|
|
174
|
+
else if (layoutBox !== void 0 && layoutBox.width > 0 && layoutBox.height > 0) {
|
|
175
|
+
const x = useLayoutWidth ? layoutBox.x : memberBounds.width > 0 ? Math.min(layoutBox.x, memberBounds.x) : layoutBox.x;
|
|
176
|
+
const y = useLayoutHeight ? layoutBox.y : memberBounds.height > 0 ? Math.min(layoutBox.y, memberBounds.y) : layoutBox.y;
|
|
177
|
+
const right = useLayoutWidth ? layoutBox.x + layoutBox.width : memberBounds.width > 0 ? Math.max(layoutBox.x + layoutBox.width, memberBounds.x + memberBounds.width) : layoutBox.x + layoutBox.width;
|
|
178
|
+
const bottom = useLayoutHeight ? layoutBox.y + layoutBox.height : memberBounds.height > 0 ? Math.max(layoutBox.y + layoutBox.height, memberBounds.y + memberBounds.height) : layoutBox.y + layoutBox.height;
|
|
179
|
+
outputGeometry = {
|
|
180
|
+
x,
|
|
181
|
+
y,
|
|
182
|
+
width: right - x,
|
|
183
|
+
height: bottom - y
|
|
184
|
+
};
|
|
185
|
+
} else if (layoutBox !== void 0 && (useLayoutWidth || useLayoutHeight)) outputGeometry = {
|
|
186
|
+
x: useLayoutWidth ? layoutBox.x : memberBounds.x,
|
|
187
|
+
y: useLayoutHeight ? layoutBox.y : memberBounds.y,
|
|
188
|
+
width: useLayoutWidth ? layoutBox.width : memberBounds.width,
|
|
189
|
+
height: useLayoutHeight ? layoutBox.height : memberBounds.height
|
|
190
|
+
};
|
|
191
|
+
else outputGeometry = memberBounds;
|
|
192
|
+
}
|
|
193
|
+
if (outputGeometry.width === 0 || pxToEmu(outputGeometry.width) === 0) throw new CapabilityError("invalid-group-geometry", "Computed Group width is 0px; width must be greater than 0px", void 0, { field: "style.width" });
|
|
194
|
+
if (outputGeometry.width < 0 || pxToEmu(outputGeometry.width) < 1) throw new CapabilityError("invalid-group-geometry", `Computed Group width is ${outputGeometry.width}px; width must be greater than 0px`, void 0, { field: "style.width" });
|
|
195
|
+
if (outputGeometry.height === 0 || pxToEmu(outputGeometry.height) === 0) throw new CapabilityError("invalid-group-geometry", "Computed Group height is 0px; height must be greater than 0px", void 0, { field: "style.height" });
|
|
196
|
+
if (outputGeometry.height < 0 || pxToEmu(outputGeometry.height) < 1) throw new CapabilityError("invalid-group-geometry", `Computed Group height is ${outputGeometry.height}px; height must be greater than 0px`, void 0, { field: "style.height" });
|
|
197
|
+
const outputEmu = {
|
|
198
|
+
x: pxToEmu(outputGeometry.x),
|
|
199
|
+
y: pxToEmu(outputGeometry.y),
|
|
200
|
+
width: pxToEmu(outputGeometry.width),
|
|
201
|
+
height: pxToEmu(outputGeometry.height)
|
|
202
|
+
};
|
|
203
|
+
if (outputEmu.width > maximumGroupExtentEmu || outputEmu.height > maximumGroupExtentEmu) throw new CapabilityError("invalid-group-geometry", "Group bounds exceed writable PresentationML dimensions", void 0, { field: outputEmu.width > maximumGroupExtentEmu ? "style.width" : "style.height" });
|
|
204
|
+
const name = resolveContext.morphName ?? requestedName ?? `Group ${resolveContext.id - 1}`;
|
|
205
|
+
let escapedName;
|
|
206
|
+
try {
|
|
207
|
+
escapedName = xmlEscape(name);
|
|
208
|
+
} catch {
|
|
209
|
+
throw new CapabilityError("invalid-xml-character", "Group.name contains characters not allowed in XML 1.0", void 0, { field: "name" });
|
|
210
|
+
}
|
|
211
|
+
const members = motionMembers(resolvedChildren.objects);
|
|
212
|
+
const annotations = motionContainerAnnotations(motionProps, {
|
|
213
|
+
kind: "group",
|
|
214
|
+
name,
|
|
215
|
+
...authorId === void 0 ? {} : { authorId },
|
|
216
|
+
textBody: false,
|
|
217
|
+
filled: false,
|
|
218
|
+
box: outputGeometry,
|
|
219
|
+
rotationDegrees: rotation ?? 0,
|
|
220
|
+
members
|
|
221
|
+
});
|
|
222
|
+
const angle = rotation ?? 0;
|
|
223
|
+
const resolvedModel = {
|
|
224
|
+
escapedName,
|
|
225
|
+
box: outputGeometry,
|
|
226
|
+
emu: outputEmu,
|
|
227
|
+
angle,
|
|
228
|
+
...rotation === void 0 ? {} : { rotation },
|
|
229
|
+
flipH,
|
|
230
|
+
flipV
|
|
231
|
+
};
|
|
232
|
+
const transform = {
|
|
233
|
+
box: outputGeometry,
|
|
234
|
+
angle,
|
|
235
|
+
flipH,
|
|
236
|
+
flipV
|
|
237
|
+
};
|
|
238
|
+
return {
|
|
239
|
+
observation: {
|
|
240
|
+
id: resolveContext.id,
|
|
241
|
+
kind: "group",
|
|
242
|
+
name,
|
|
243
|
+
box: outputGeometry,
|
|
244
|
+
members: resolvedChildren.objects
|
|
245
|
+
},
|
|
246
|
+
transform,
|
|
247
|
+
extensions: [],
|
|
248
|
+
...annotations.length === 0 ? {} : { annotations },
|
|
249
|
+
emit(emitContext) {
|
|
250
|
+
return groupMechanism.emit(resolvedModel, emitContext);
|
|
251
|
+
},
|
|
252
|
+
paint(paintContext) {
|
|
253
|
+
return groupMechanism.paint(resolvedModel, paintContext);
|
|
254
|
+
}
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
export { groupCapability, groupMechanism };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../kernel/document-internals.js";
|
|
2
|
+
import { serializeGeometryProp } from "../shared/geometry-codegen.js";
|
|
3
|
+
import { assertNoLeafDeclarationChildren, serializeImageDescriptorValue, serializeImageSrcProp, serializeImageStyleProp } from "../shared/image-codegen.js";
|
|
4
|
+
import { imageAllowedParameters } from "../shared/image-schemas.js";
|
|
5
|
+
import { motionPropKeySet } from "../shared/motion-schemas.js";
|
|
6
|
+
import "../../kernel/capability.js";
|
|
7
|
+
import { defineObjectCodegen } from "../../kernel/codegen.js";
|
|
8
|
+
// ../core/dist/capabilities/image/image-codegen.js
|
|
9
|
+
const objectMotionPropKeys = motionPropKeySet;
|
|
10
|
+
const imageAllowedPropKeys = new Set(imageAllowedParameters);
|
|
11
|
+
function collectImageProps(node, ctx) {
|
|
12
|
+
assertNoLeafDeclarationChildren("Image", node, ctx);
|
|
13
|
+
const props = readInternalDeclarationProps(node);
|
|
14
|
+
const extra = ctx.emitObjectExtraProps(props);
|
|
15
|
+
const entries = [];
|
|
16
|
+
let sawSrc = false;
|
|
17
|
+
for (const [key, value] of Object.entries(props)) {
|
|
18
|
+
if (value === void 0) continue;
|
|
19
|
+
if (!imageAllowedPropKeys.has(key)) ctx.fail("invalid-document", `image declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
20
|
+
if (key === "src") {
|
|
21
|
+
sawSrc = true;
|
|
22
|
+
entries.push(["src", serializeImageSrcProp(value, ctx)]);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (key === "geometry") {
|
|
26
|
+
entries.push([key, serializeGeometryProp(value, ctx)]);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (key === "style") {
|
|
30
|
+
entries.push([key, serializeImageStyleProp(value, ctx)]);
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (objectMotionPropKeys.has(key)) {
|
|
34
|
+
if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
|
|
35
|
+
else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
entries.push([key, value]);
|
|
39
|
+
}
|
|
40
|
+
if (!sawSrc) ctx.fail("unexpressible-value", "Image declaration is missing src", "@src");
|
|
41
|
+
return entries;
|
|
42
|
+
}
|
|
43
|
+
/** Source codegen contribution for `image` declarations and `{ image, fit?, position?, opacity? }` descriptors. */
|
|
44
|
+
const imageCodegen = defineObjectCodegen({
|
|
45
|
+
declarations: { image: {
|
|
46
|
+
emitVanilla: (node, ctx) => {
|
|
47
|
+
const callee = ctx.useImport("image");
|
|
48
|
+
const props = collectImageProps(node, ctx);
|
|
49
|
+
return ctx.formatVanillaCall(callee, [ctx.formatProps(props)]);
|
|
50
|
+
},
|
|
51
|
+
emitReact: (node, ctx) => {
|
|
52
|
+
const tag = ctx.useImport("Image");
|
|
53
|
+
const props = collectImageProps(node, ctx);
|
|
54
|
+
return ctx.formatJsxElement(tag, props);
|
|
55
|
+
}
|
|
56
|
+
} },
|
|
57
|
+
valueSerializers: [serializeImageDescriptorValue]
|
|
58
|
+
});
|
|
59
|
+
export { imageCodegen };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../shared/image-schemas.js";
|
|
2
|
+
import { CommonNode } from "../../kernel/document.js";
|
|
3
|
+
// ../core/dist/capabilities/image/image-declaration.js
|
|
4
|
+
/** Creates the editable native image shared by the command factory and the Image JSX element. */
|
|
5
|
+
function createImageNode(props) {
|
|
6
|
+
return new CommonNode("image", "image", props);
|
|
7
|
+
}
|
|
8
|
+
export { createImageNode };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { readPicture } from "../shared/picture-import.js";
|
|
2
|
+
import { isPlaceholderPicElement } from "../shared/placeholder-import.js";
|
|
3
|
+
import { mediaPictureKind } from "../../kernel/pptx-read/media.js";
|
|
4
|
+
import { createImageNode } from "./image-declaration.js";
|
|
5
|
+
// ../core/dist/capabilities/image/image-import.js
|
|
6
|
+
function readImagePic(context) {
|
|
7
|
+
return readPicture(context, {
|
|
8
|
+
objectKind: "image",
|
|
9
|
+
createNode: createImageNode
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const imageImportHandler = {
|
|
13
|
+
target: "shape-tree",
|
|
14
|
+
localName: "pic",
|
|
15
|
+
groupMember: true,
|
|
16
|
+
matches: (cursor) => mediaPictureKind(cursor.element) === void 0 && !isPlaceholderPicElement(cursor),
|
|
17
|
+
read: readImagePic
|
|
18
|
+
};
|
|
19
|
+
const picturePlaceholderImportHandler = {
|
|
20
|
+
target: "shape-tree",
|
|
21
|
+
localName: "pic",
|
|
22
|
+
groupMember: true,
|
|
23
|
+
matches: (cursor) => mediaPictureKind(cursor.element) === void 0 && isPlaceholderPicElement(cursor),
|
|
24
|
+
read: readImagePic
|
|
25
|
+
};
|
|
26
|
+
export { imageImportHandler, picturePlaceholderImportHandler };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { imageAllowedParameters } from "../shared/image-schemas.js";
|
|
3
|
+
import { defineCanvasMechanism } from "../../kernel/pptx-read/mechanism.js";
|
|
4
|
+
import { bindPicture, emitImageModel, paintImageModel, readImageSource } from "../shared/picture.js";
|
|
5
|
+
import { compatiblePlaceholderRoles } from "../shared/placeholder-roles.js";
|
|
6
|
+
import "../../kernel/capability.js";
|
|
7
|
+
import "../../kernel/pptx-read/index.js";
|
|
8
|
+
import { imageCodegen } from "./image-codegen.js";
|
|
9
|
+
import { imageImportHandler, picturePlaceholderImportHandler } from "./image-import.js";
|
|
10
|
+
import "../shared/image-decode.js";
|
|
11
|
+
import "./image-declaration.js";
|
|
12
|
+
// ../core/dist/capabilities/image/image.js
|
|
13
|
+
/** Typed native canvas mechanism connecting emit, paint, and import for `image`. */
|
|
14
|
+
const imageMechanism = defineCanvasMechanism({
|
|
15
|
+
key: "image",
|
|
16
|
+
role: "canvas",
|
|
17
|
+
emit: emitImageModel,
|
|
18
|
+
paint: paintImageModel,
|
|
19
|
+
import: imageImportHandler
|
|
20
|
+
});
|
|
21
|
+
/** Typed native canvas mechanism connecting emit, paint, and import for `picture-placeholder`. */
|
|
22
|
+
const picturePlaceholderMechanism = defineCanvasMechanism({
|
|
23
|
+
key: "picture-placeholder",
|
|
24
|
+
role: "canvas",
|
|
25
|
+
emit: emitImageModel,
|
|
26
|
+
paint: paintImageModel,
|
|
27
|
+
import: picturePlaceholderImportHandler
|
|
28
|
+
});
|
|
29
|
+
/** Image module reads and validates formal resources, encapsulates bound state, and emits native picture objects. */
|
|
30
|
+
const imageCapability = {
|
|
31
|
+
declaration: "image",
|
|
32
|
+
codegen: imageCodegen,
|
|
33
|
+
mechanisms: [imageMechanism, picturePlaceholderMechanism],
|
|
34
|
+
*bind(input, context) {
|
|
35
|
+
const placeholder = context.placeholder;
|
|
36
|
+
if (placeholder !== void 0) {
|
|
37
|
+
const role = placeholder.nativeRef.type;
|
|
38
|
+
if (!compatiblePlaceholderRoles.image.has(role)) throw new CapabilityError("incompatible-placeholder-content", `Image cannot be bound to ${role} placeholder`);
|
|
39
|
+
}
|
|
40
|
+
const unknown = Object.keys(input.props).find((key) => !imageAllowedParameters.includes(key));
|
|
41
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `Image contains unsupported parameter ${unknown}`);
|
|
42
|
+
if (input.children.some((child) => "props" in child || child.text.trim() !== "")) throw new CapabilityError("unsupported-children", "Image does not accept children");
|
|
43
|
+
return yield* bindPicture(input, context, {
|
|
44
|
+
label: "Image",
|
|
45
|
+
readSource: () => readImageSource(input.props["src"]),
|
|
46
|
+
resolve(model, picture) {
|
|
47
|
+
const mechanism = placeholder === void 0 ? imageMechanism : picturePlaceholderMechanism;
|
|
48
|
+
return {
|
|
49
|
+
...picture,
|
|
50
|
+
emit: (emitContext) => mechanism.emit(model, emitContext),
|
|
51
|
+
paint: (paintContext) => mechanism.paint(model, paintContext)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export { imageCapability, imageMechanism, picturePlaceholderMechanism };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../kernel/document-internals.js";
|
|
2
|
+
import { motionPropsShape } from "../shared/motion-schemas.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
import { defineObjectCodegen, expr } from "../../kernel/codegen.js";
|
|
5
|
+
import { lineStrokeValueSchema } from "../shared/visual.js";
|
|
6
|
+
import { CommonNode } from "../../kernel/document.js";
|
|
7
|
+
import { lineAdjustSchema, lineAllowedPropKeyList, lineEndpointSchema, lineRoutingSchema, lineStyleSchema } from "./line-declaration.js";
|
|
8
|
+
// ../core/dist/capabilities/line/line-codegen.js
|
|
9
|
+
const objectMotionPropKeys = new Set(Object.keys(motionPropsShape));
|
|
10
|
+
const lineAllowedPropKeys = new Set(lineAllowedPropKeyList);
|
|
11
|
+
function isRecord(value) {
|
|
12
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function isPlainRecord(value) {
|
|
15
|
+
if (!isRecord(value)) return false;
|
|
16
|
+
const proto = Object.getPrototypeOf(value);
|
|
17
|
+
return proto === Object.prototype || proto === null;
|
|
18
|
+
}
|
|
19
|
+
function assertNoLineChildren(node, ctx) {
|
|
20
|
+
for (const child of node.children) {
|
|
21
|
+
if (child instanceof CommonNode) ctx.fail("invalid-document", "Line does not accept child declarations");
|
|
22
|
+
const leaf = child;
|
|
23
|
+
if (leaf.type === "#text" && leaf.text.trim() !== "") ctx.fail("invalid-document", "Line does not accept text children");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function serializeLineStyleProp(style, ctx) {
|
|
27
|
+
if (!isPlainRecord(style)) ctx.fail("unexpressible-value", "Line.style must be a plain object", "@style");
|
|
28
|
+
const parsed = lineStyleSchema.safeParse(style);
|
|
29
|
+
if (!parsed.success) {
|
|
30
|
+
const issue = parsed.error.issues[0];
|
|
31
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
32
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Line.style cannot be expressed", issuePath);
|
|
33
|
+
}
|
|
34
|
+
const entries = [];
|
|
35
|
+
for (const [key, entryValue] of Object.entries(style)) {
|
|
36
|
+
if (entryValue === void 0) continue;
|
|
37
|
+
entries.push([key, entryValue]);
|
|
38
|
+
}
|
|
39
|
+
if (entries.length === 0) return void 0;
|
|
40
|
+
return expr(ctx.formatProps(entries));
|
|
41
|
+
}
|
|
42
|
+
function validateLinePropValue(key, value, ctx) {
|
|
43
|
+
if (key === "routing" && !lineRoutingSchema.safeParse(value).success) ctx.fail("unexpressible-value", "Line.routing cannot be expressed", `@${key}`);
|
|
44
|
+
if (key === "adjust" && !lineAdjustSchema.safeParse(value).success) ctx.fail("unexpressible-value", "Line.adjust cannot be expressed", `@${key}`);
|
|
45
|
+
if (key === "stroke" && !lineStrokeValueSchema.safeParse(value).success) ctx.fail("unexpressible-value", "Line.stroke cannot be expressed", `@${key}`);
|
|
46
|
+
if ((key === "from" || key === "to") && !lineEndpointSchema.safeParse(value).success) ctx.fail("unexpressible-value", `Line.${key} cannot be expressed`, `@${key}`);
|
|
47
|
+
}
|
|
48
|
+
function collectLineProps(node, ctx) {
|
|
49
|
+
const props = readInternalDeclarationProps(node);
|
|
50
|
+
const extra = ctx.emitObjectExtraProps(props);
|
|
51
|
+
const entries = [];
|
|
52
|
+
for (const [key, value] of Object.entries(props)) {
|
|
53
|
+
if (value === void 0) continue;
|
|
54
|
+
if (!lineAllowedPropKeys.has(key)) ctx.fail("invalid-document", `line declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
55
|
+
if (objectMotionPropKeys.has(key)) {
|
|
56
|
+
if (Object.hasOwn(extra, key)) entries.push([key, extra[key]]);
|
|
57
|
+
else ctx.fail("unexpressible-value", `Object property ${JSON.stringify(key)} requires motion codegen support`, `@${key}`);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (key === "style") {
|
|
61
|
+
const styleExpr = serializeLineStyleProp(value, ctx);
|
|
62
|
+
if (styleExpr !== void 0) entries.push([key, styleExpr]);
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
validateLinePropValue(key, value, ctx);
|
|
66
|
+
entries.push([key, value]);
|
|
67
|
+
}
|
|
68
|
+
return entries;
|
|
69
|
+
}
|
|
70
|
+
function emitLineVanilla(node, ctx) {
|
|
71
|
+
assertNoLineChildren(node, ctx);
|
|
72
|
+
const callee = ctx.useImport("line");
|
|
73
|
+
const propsEntries = collectLineProps(node, ctx);
|
|
74
|
+
const args = propsEntries.length === 0 ? [] : [ctx.formatProps(propsEntries)];
|
|
75
|
+
return ctx.formatVanillaCall(callee, args);
|
|
76
|
+
}
|
|
77
|
+
function emitLineReact(node, ctx) {
|
|
78
|
+
assertNoLineChildren(node, ctx);
|
|
79
|
+
const tag = ctx.useImport("Line");
|
|
80
|
+
const propsEntries = collectLineProps(node, ctx);
|
|
81
|
+
return ctx.formatJsxElement(tag, propsEntries);
|
|
82
|
+
}
|
|
83
|
+
/** Source codegen contribution for `line` declarations. */
|
|
84
|
+
const lineCodegen = defineObjectCodegen({ declarations: { line: {
|
|
85
|
+
emitVanilla: emitLineVanilla,
|
|
86
|
+
emitReact: emitLineReact
|
|
87
|
+
} } });
|
|
88
|
+
export { lineCodegen };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
2
|
+
import { layoutStyleShape } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { visualStyleShape } from "../../kernel/theme.js";
|
|
4
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
5
|
+
import { optionalNameSchema } from "../shared/identity.js";
|
|
6
|
+
import { morphKeySchema } from "../shared/morph-api.js";
|
|
7
|
+
import { motionPropsShape } from "../shared/motion-schemas.js";
|
|
8
|
+
import { lineStrokeValueSchema } from "../shared/visual.js";
|
|
9
|
+
import "../../kernel/capability.js";
|
|
10
|
+
import { CommonNode } from "../../kernel/document.js";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
// ../core/dist/capabilities/line/line-declaration.js
|
|
13
|
+
const rawLineRoutingSchema = z.enum([
|
|
14
|
+
"straight",
|
|
15
|
+
"elbow",
|
|
16
|
+
"curved"
|
|
17
|
+
]);
|
|
18
|
+
const lineRoutingSchema = rawLineRoutingSchema;
|
|
19
|
+
const rawLinePortSchema = z.union([z.enum([
|
|
20
|
+
"top",
|
|
21
|
+
"right",
|
|
22
|
+
"bottom",
|
|
23
|
+
"left"
|
|
24
|
+
]), z.number().int().min(0)]);
|
|
25
|
+
const lineCoordinateSchema = z.number().finite().min(-1e6).max(1e6);
|
|
26
|
+
const rawLineEndpointSchema = z.union([z.strictObject({
|
|
27
|
+
id: authorIdSchema,
|
|
28
|
+
port: rawLinePortSchema
|
|
29
|
+
}).readonly(), z.strictObject({
|
|
30
|
+
x: lineCoordinateSchema,
|
|
31
|
+
y: lineCoordinateSchema
|
|
32
|
+
}).readonly()]);
|
|
33
|
+
const lineEndpointSchema = rawLineEndpointSchema;
|
|
34
|
+
const lineAdjustValueSchema = z.number().refine(Number.isSafeInteger, "Geometry adjust must be an integer DrawingML parameter");
|
|
35
|
+
const rawLineAdjustSchema = z.strictObject({
|
|
36
|
+
adj1: lineAdjustValueSchema.optional(),
|
|
37
|
+
adj2: lineAdjustValueSchema.optional(),
|
|
38
|
+
adj3: lineAdjustValueSchema.optional()
|
|
39
|
+
}).readonly();
|
|
40
|
+
const lineAdjustSchema = rawLineAdjustSchema;
|
|
41
|
+
const { padding: _padding, paddingTop: _paddingTop, paddingRight: _paddingRight, paddingBottom: _paddingBottom, paddingLeft: _paddingLeft, ...lineLayoutStyleShape } = layoutStyleShape;
|
|
42
|
+
const lineStyleObjectSchema = z.strictObject({
|
|
43
|
+
...lineLayoutStyleShape,
|
|
44
|
+
rotate: visualStyleShape.rotate,
|
|
45
|
+
flipH: visualStyleShape.flipH,
|
|
46
|
+
flipV: visualStyleShape.flipV,
|
|
47
|
+
opacity: visualStyleShape.opacity,
|
|
48
|
+
boxShadow: visualStyleShape.boxShadow
|
|
49
|
+
});
|
|
50
|
+
const lineEndpointStyleShape = lineStyleObjectSchema.pick({
|
|
51
|
+
display: true,
|
|
52
|
+
zIndex: true,
|
|
53
|
+
opacity: true,
|
|
54
|
+
boxShadow: true
|
|
55
|
+
}).shape;
|
|
56
|
+
const lineStyleKeyList = Object.keys(lineStyleObjectSchema.shape);
|
|
57
|
+
const rawLineStyleSchema = lineStyleObjectSchema.readonly();
|
|
58
|
+
const lineStyleSchema = rawLineStyleSchema;
|
|
59
|
+
const lineDeclarationPropsObjectSchema = z.strictObject({
|
|
60
|
+
id: authorIdSchema.optional(),
|
|
61
|
+
name: optionalNameSchema.optional(),
|
|
62
|
+
morphKey: morphKeySchema.optional(),
|
|
63
|
+
link: linkTargetSchema.optional(),
|
|
64
|
+
routing: rawLineRoutingSchema.optional(),
|
|
65
|
+
adjust: rawLineAdjustSchema.optional(),
|
|
66
|
+
stroke: lineStrokeValueSchema.optional(),
|
|
67
|
+
from: rawLineEndpointSchema.optional(),
|
|
68
|
+
to: rawLineEndpointSchema.optional(),
|
|
69
|
+
style: rawLineStyleSchema.optional(),
|
|
70
|
+
...motionPropsShape
|
|
71
|
+
});
|
|
72
|
+
const lineAllowedPropKeyList = Object.keys(lineDeclarationPropsObjectSchema.shape);
|
|
73
|
+
lineDeclarationPropsObjectSchema.readonly();
|
|
74
|
+
/** Creates the editable native line/connector shared by the command factory and the Line JSX element. */
|
|
75
|
+
function createLineNode(props) {
|
|
76
|
+
return new CommonNode("line", "line", props);
|
|
77
|
+
}
|
|
78
|
+
export { createLineNode, lineAdjustSchema, lineAllowedPropKeyList, lineEndpointSchema, lineEndpointStyleShape, lineRoutingSchema, lineStrokeValueSchema, lineStyleKeyList, lineStyleSchema };
|