@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,156 @@
|
|
|
1
|
+
import { bytesSha256 } from "../../kernel/font-seal.js";
|
|
2
|
+
import "../../kernel/pptx-read/index.js";
|
|
3
|
+
import { peekShapeTreeObjectIdentity, resolveExternalRelationshipTarget, resolveInternalRelationshipTarget } from "../../kernel/pptx-read/resources.js";
|
|
4
|
+
import { A_NS, P14_NS, P_NS, REL_MEDIA, R_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
5
|
+
import { mediaTrimSchema } from "./media-schemas.js";
|
|
6
|
+
import { importNativeTrimEnd, isMediaTrimWithinDuration, maxMediaStopDelay, mediaStopDelay, parseNativeTrimTime, trimTimeNumber } from "./media-trim.js";
|
|
7
|
+
import { mediaExtensionUri } from "./media.js";
|
|
8
|
+
import { readPicture } from "./picture-import.js";
|
|
9
|
+
// ../core/dist/capabilities/shared/media-import.js
|
|
10
|
+
function hasPosterModifications({ crop, geometry, style }) {
|
|
11
|
+
return crop !== void 0 || geometry !== void 0 || Object.keys(style ?? {}).some((key) => key !== "position" && key !== "left" && key !== "top" && key !== "width" && key !== "height");
|
|
12
|
+
}
|
|
13
|
+
/** Reads an embedded or linked media resource and its authorable picture surface. */
|
|
14
|
+
function readMediaPicture(context, options) {
|
|
15
|
+
const { cursor, part, slideIndex } = context;
|
|
16
|
+
const { kind } = options;
|
|
17
|
+
const identity = peekShapeTreeObjectIdentity(cursor.element);
|
|
18
|
+
const location = {
|
|
19
|
+
part,
|
|
20
|
+
xpath: cursor.xpath,
|
|
21
|
+
slideIndex,
|
|
22
|
+
...identity
|
|
23
|
+
};
|
|
24
|
+
const nvPr = cursor.child(P_NS, "nvPicPr")?.child(P_NS, "nvPr");
|
|
25
|
+
const fileId = nvPr?.child(A_NS, `${kind}File`)?.attr("link", R_NS);
|
|
26
|
+
const media = (nvPr?.child(P_NS, "extLst"))?.children(P_NS, "ext").find((ext) => ext.element.getAttribute("uri") === mediaExtensionUri);
|
|
27
|
+
media?.consumeAttr("uri");
|
|
28
|
+
const nativeMedia = media?.child(P14_NS, "media");
|
|
29
|
+
const embedId = nativeMedia?.attr("embed", R_NS);
|
|
30
|
+
const linkId = nativeMedia?.attr("link", R_NS);
|
|
31
|
+
const relationId = (embedId || linkId || fileId) ?? "";
|
|
32
|
+
const relType = embedId || linkId ? REL_MEDIA : `${R_NS}/${kind}`;
|
|
33
|
+
const relationships = context.relationships ?? /* @__PURE__ */ new Map();
|
|
34
|
+
const targetRel = relationships.get(relationId);
|
|
35
|
+
let src;
|
|
36
|
+
let duration;
|
|
37
|
+
if (targetRel?.TargetMode === "External" && !embedId) {
|
|
38
|
+
const resource = resolveExternalRelationshipTarget(relationships, relationId, location, relType);
|
|
39
|
+
if (!resource.ok) return { diagnostics: [resource.diagnostic] };
|
|
40
|
+
if (resource.target.trim() === "" || resource.target === "NULL") return { diagnostics: [{
|
|
41
|
+
code: "corrupt-part",
|
|
42
|
+
category: "corrupt-input",
|
|
43
|
+
disposition: "omitted",
|
|
44
|
+
location
|
|
45
|
+
}] };
|
|
46
|
+
src = { externalUrl: resource.target };
|
|
47
|
+
} else {
|
|
48
|
+
const resource = resolveInternalRelationshipTarget(context.package, relationships, part, relationId, location, relType);
|
|
49
|
+
if (!resource.ok) return { diagnostics: [resource.diagnostic] };
|
|
50
|
+
const format = options.detectMedia(resource.bytes);
|
|
51
|
+
if (format === void 0) return { diagnostics: [{
|
|
52
|
+
code: "corrupt-part",
|
|
53
|
+
category: "corrupt-input",
|
|
54
|
+
disposition: "omitted",
|
|
55
|
+
location,
|
|
56
|
+
cascaded: [{
|
|
57
|
+
location: { part: resource.targetPart },
|
|
58
|
+
role: "media"
|
|
59
|
+
}]
|
|
60
|
+
}] };
|
|
61
|
+
src = resource.bytes;
|
|
62
|
+
duration = format.duration;
|
|
63
|
+
}
|
|
64
|
+
const diagnostics = [];
|
|
65
|
+
const nativeTrim = nativeMedia?.child(P14_NS, "trim");
|
|
66
|
+
const rawStart = nativeTrim?.attr("st");
|
|
67
|
+
const rawEnd = nativeTrim?.attr("end");
|
|
68
|
+
const parsedStart = parseNativeTrimTime(rawStart);
|
|
69
|
+
const start = parsedStart === void 0 ? void 0 : trimTimeNumber(parsedStart);
|
|
70
|
+
const removed = parseNativeTrimTime(rawEnd);
|
|
71
|
+
const selectedTiming = identity.objectId === void 0 ? void 0 : context.mediaTiming?.get(identity.objectId);
|
|
72
|
+
const timing = selectedTiming?.kind === kind ? selectedTiming : void 0;
|
|
73
|
+
const validStart = rawStart === void 0 || start !== void 0 && (duration === void 0 || start < duration);
|
|
74
|
+
const legacyEndpoint = duration === void 0 && nativeTrim !== void 0 && rawEnd === void 0 ? timing?.duration : void 0;
|
|
75
|
+
const startTrim = validStart && start !== void 0 ? { start } : {};
|
|
76
|
+
let end;
|
|
77
|
+
if (removed !== void 0) end = importNativeTrimEnd(removed, duration, validStart ? parsedStart : void 0);
|
|
78
|
+
if (legacyEndpoint !== void 0) {
|
|
79
|
+
const endpoint = (startTrim.start ?? 0) + legacyEndpoint.milliseconds;
|
|
80
|
+
if (legacyEndpoint.milliseconds > maxMediaStopDelay || mediaStopDelay(endpoint, startTrim.start) > maxMediaStopDelay) diagnostics.push({
|
|
81
|
+
code: "invalid-xml-value",
|
|
82
|
+
category: "corrupt-input",
|
|
83
|
+
disposition: "recovered",
|
|
84
|
+
location: {
|
|
85
|
+
...location,
|
|
86
|
+
xpath: legacyEndpoint.xpath
|
|
87
|
+
},
|
|
88
|
+
attributeOrElement: "p:cTn/@dur",
|
|
89
|
+
rawValue: String(legacyEndpoint.milliseconds)
|
|
90
|
+
});
|
|
91
|
+
else if (timing?.loop) diagnostics.push({
|
|
92
|
+
code: "compatibility-fallback",
|
|
93
|
+
category: "unsupported",
|
|
94
|
+
disposition: "fallback",
|
|
95
|
+
location: {
|
|
96
|
+
...location,
|
|
97
|
+
xpath: legacyEndpoint.xpath
|
|
98
|
+
},
|
|
99
|
+
preferredMechanism: "absolute-media-trim-end-with-unknown-duration-and-loop",
|
|
100
|
+
selectedFallback: "looping-media-without-trim-end",
|
|
101
|
+
loss: {
|
|
102
|
+
lost: "native-mechanism",
|
|
103
|
+
retainedAs: kind
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
else end = endpoint;
|
|
107
|
+
}
|
|
108
|
+
const checkedTrim = mediaTrimSchema.safeParse({
|
|
109
|
+
...startTrim,
|
|
110
|
+
end
|
|
111
|
+
});
|
|
112
|
+
const validTrim = checkedTrim.success && (duration === void 0 || isMediaTrimWithinDuration(checkedTrim.data, duration));
|
|
113
|
+
if (!validTrim || !validStart || rawEnd !== void 0 && end === void 0) diagnostics.push({
|
|
114
|
+
code: "invalid-xml-value",
|
|
115
|
+
category: "corrupt-input",
|
|
116
|
+
disposition: "recovered",
|
|
117
|
+
location: {
|
|
118
|
+
...location,
|
|
119
|
+
xpath: nativeTrim?.xpath ?? cursor.xpath
|
|
120
|
+
},
|
|
121
|
+
attributeOrElement: "p14:trim",
|
|
122
|
+
rawValue: JSON.stringify({
|
|
123
|
+
st: rawStart,
|
|
124
|
+
end: rawEnd
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
const trim = validTrim && end !== void 0 ? {
|
|
128
|
+
...startTrim,
|
|
129
|
+
end
|
|
130
|
+
} : startTrim;
|
|
131
|
+
const picture = readPicture(context, {
|
|
132
|
+
objectKind: kind,
|
|
133
|
+
createNode(props) {
|
|
134
|
+
const { src: artwork, link: _link, ...surface } = props;
|
|
135
|
+
const poster = artwork instanceof Uint8Array && !hasPosterModifications(props) && bytesSha256(artwork) === bytesSha256(options.defaultPoster().bytes) ? void 0 : artwork;
|
|
136
|
+
return options.createNode({
|
|
137
|
+
...surface,
|
|
138
|
+
src,
|
|
139
|
+
...poster === void 0 ? {} : { poster },
|
|
140
|
+
...Object.keys(trim).length === 0 ? {} : { trim },
|
|
141
|
+
...timing === void 0 ? {} : {
|
|
142
|
+
autoPlay: timing.autoPlay,
|
|
143
|
+
loop: timing.loop,
|
|
144
|
+
...timing.volume === void 0 ? {} : { volume: timing.volume },
|
|
145
|
+
...timing.muted === void 0 ? {} : { muted: timing.muted },
|
|
146
|
+
...kind !== "audio" || timing.showWhenStopped === void 0 ? {} : { hideDuringShow: !timing.showWhenStopped }
|
|
147
|
+
}
|
|
148
|
+
}, location, diagnostics);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
...picture,
|
|
153
|
+
diagnostics: [...diagnostics, ...picture.diagnostics ?? []]
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export { readMediaPicture };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { motionPropKeys } from "./motion-schemas.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
// ../core/dist/capabilities/shared/media-placement.js
|
|
5
|
+
function hasEffects(input) {
|
|
6
|
+
return [
|
|
7
|
+
"enter",
|
|
8
|
+
"emphasis",
|
|
9
|
+
"exit"
|
|
10
|
+
].some((key) => {
|
|
11
|
+
const value = input.props[key];
|
|
12
|
+
return value !== void 0 && (!Array.isArray(value) || value.length > 0);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Rejects media placements that have no standalone playback representation. */
|
|
16
|
+
function validateMediaPlacement(input, { insideSlide, ancestors }) {
|
|
17
|
+
if (!insideSlide || ancestors.some((ancestor) => ancestor.type === "group")) throw new CapabilityError("unsupported-media-host", "Media objects must be placed on a Slide outside of a Group");
|
|
18
|
+
if (motionPropKeys.some((key) => input.props[key] !== void 0) || ancestors.some((ancestor) => ancestor.type === "motion-step" || ancestor.type === "motion-scope" || hasEffects(ancestor))) throw new CapabilityError("unsupported-motion-host", "Media objects cannot participate in graphic animation, Step, or MotionScope");
|
|
19
|
+
}
|
|
20
|
+
export { validateMediaPlacement };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { zlibSync } from "fflate";
|
|
2
|
+
// ../core/dist/capabilities/shared/media-poster.js
|
|
3
|
+
const pngSignature = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
|
|
4
|
+
/** Encodes row-major straight RGBA bytes as a deterministic 8-bit PNG. */
|
|
5
|
+
function encodeRgbaPng(width, height, pixels) {
|
|
6
|
+
const stride = width * 4;
|
|
7
|
+
if (!Number.isInteger(width) || width <= 0 || width > 2147483647 || !Number.isInteger(height) || height <= 0 || height > 2147483647 || pixels.length !== stride * height) throw new RangeError("Invalid PNG dimensions or RGBA pixel count");
|
|
8
|
+
const header = /* @__PURE__ */ new Uint8Array(13);
|
|
9
|
+
const dimensions = new DataView(header.buffer);
|
|
10
|
+
dimensions.setUint32(0, width);
|
|
11
|
+
dimensions.setUint32(4, height);
|
|
12
|
+
header[8] = 8;
|
|
13
|
+
header[9] = 6;
|
|
14
|
+
const scanlines = new Uint8Array((stride + 1) * height);
|
|
15
|
+
for (let y = 0; y < height; y += 1) scanlines.set(pixels.subarray(y * stride, (y + 1) * stride), y * (stride + 1) + 1);
|
|
16
|
+
const chunks = [
|
|
17
|
+
pngSignature,
|
|
18
|
+
chunk("IHDR", header),
|
|
19
|
+
chunk("IDAT", zlibSync(scanlines)),
|
|
20
|
+
chunk("IEND", /* @__PURE__ */ new Uint8Array())
|
|
21
|
+
];
|
|
22
|
+
const png = new Uint8Array(chunks.reduce((total, bytes) => total + bytes.length, 0));
|
|
23
|
+
let offset = 0;
|
|
24
|
+
for (const bytes of chunks) {
|
|
25
|
+
png.set(bytes, offset);
|
|
26
|
+
offset += bytes.length;
|
|
27
|
+
}
|
|
28
|
+
return png;
|
|
29
|
+
}
|
|
30
|
+
function chunk(type, data) {
|
|
31
|
+
const bytes = new Uint8Array(data.length + 12);
|
|
32
|
+
const view = new DataView(bytes.buffer);
|
|
33
|
+
view.setUint32(0, data.length);
|
|
34
|
+
for (let i = 0; i < 4; i += 1) bytes[i + 4] = type.charCodeAt(i);
|
|
35
|
+
bytes.set(data, 8);
|
|
36
|
+
let crc = 4294967295;
|
|
37
|
+
for (const byte of bytes.subarray(4, bytes.length - 4)) {
|
|
38
|
+
crc ^= byte;
|
|
39
|
+
for (let bit = 0; bit < 8; bit += 1) crc = crc >>> 1 ^ (crc & 1 ? 3988292384 : 0);
|
|
40
|
+
}
|
|
41
|
+
view.setUint32(bytes.length - 4, crc ^ 4294967295);
|
|
42
|
+
return bytes;
|
|
43
|
+
}
|
|
44
|
+
/** Renders an opaque default poster without external assets or a native codec. */
|
|
45
|
+
function renderMediaPoster(width, height, pixel) {
|
|
46
|
+
const pixels = new Uint8Array(width * height * 4);
|
|
47
|
+
for (let y = 0; y < height; y += 1) for (let x = 0; x < width; x += 1) pixels.set([...pixel(x, y), 255], (y * width + x) * 4);
|
|
48
|
+
return encodeRgbaPng(width, height, pixels);
|
|
49
|
+
}
|
|
50
|
+
export { encodeRgbaPng, renderMediaPoster };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
2
|
+
import { layoutStyleSchema } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { geometrySchema } from "../../kernel/geometry-schemas.js";
|
|
4
|
+
import { resourceSourceSchema } from "../../kernel/resource-source.js";
|
|
5
|
+
import "./geometry.js";
|
|
6
|
+
import { optionalNameSchema } from "./identity.js";
|
|
7
|
+
import { morphKeySchema } from "./morph-api.js";
|
|
8
|
+
import "../../kernel/capability.js";
|
|
9
|
+
import { imageAltSchema, imageCropInputSchema, imageFitSchema, imageStyleSchema } from "./image-schemas.js";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
// ../core/dist/capabilities/shared/media-schemas.js
|
|
12
|
+
const trimTimeSchema = z.number().finite().nonnegative();
|
|
13
|
+
const mediaTrimSchema = z.strictObject({
|
|
14
|
+
start: trimTimeSchema.optional(),
|
|
15
|
+
end: z.union([trimTimeSchema, z.strictObject({ fromEnd: trimTimeSchema }).readonly()]).optional()
|
|
16
|
+
}).readonly().refine(({ start, end }) => typeof end !== "number" || end > (start ?? 0), {
|
|
17
|
+
message: "Media trim end must be greater than start",
|
|
18
|
+
path: ["end"]
|
|
19
|
+
});
|
|
20
|
+
const mediaPlaybackPropsShape = {
|
|
21
|
+
autoPlay: z.boolean().optional(),
|
|
22
|
+
loop: z.boolean().optional(),
|
|
23
|
+
muted: z.boolean().optional(),
|
|
24
|
+
volume: z.number().finite().min(0).max(1).optional(),
|
|
25
|
+
trim: mediaTrimSchema.optional()
|
|
26
|
+
};
|
|
27
|
+
const mediaPlaybackPropsSchema = z.strictObject(mediaPlaybackPropsShape).readonly();
|
|
28
|
+
const commonMediaPropsShape = {
|
|
29
|
+
id: authorIdSchema.optional(),
|
|
30
|
+
name: optionalNameSchema.optional(),
|
|
31
|
+
alt: imageAltSchema,
|
|
32
|
+
src: resourceSourceSchema,
|
|
33
|
+
poster: resourceSourceSchema.optional(),
|
|
34
|
+
...mediaPlaybackPropsShape
|
|
35
|
+
};
|
|
36
|
+
const audioDeclarationPropsObjectSchema = z.strictObject({
|
|
37
|
+
...commonMediaPropsShape,
|
|
38
|
+
style: layoutStyleSchema.optional(),
|
|
39
|
+
hideDuringShow: z.boolean().optional()
|
|
40
|
+
});
|
|
41
|
+
const audioDeclarationPropsSchema = audioDeclarationPropsObjectSchema.readonly();
|
|
42
|
+
const videoDeclarationPropsObjectSchema = z.strictObject({
|
|
43
|
+
...commonMediaPropsShape,
|
|
44
|
+
placeholder: z.string().optional(),
|
|
45
|
+
morphKey: morphKeySchema.optional(),
|
|
46
|
+
geometry: geometrySchema.optional(),
|
|
47
|
+
style: imageStyleSchema.optional(),
|
|
48
|
+
fit: imageFitSchema.optional(),
|
|
49
|
+
crop: imageCropInputSchema.optional()
|
|
50
|
+
});
|
|
51
|
+
const videoDeclarationPropsSchema = videoDeclarationPropsObjectSchema.readonly();
|
|
52
|
+
const mediaAllowedPropSets = {
|
|
53
|
+
audio: new Set(Object.keys(audioDeclarationPropsObjectSchema.shape)),
|
|
54
|
+
video: new Set(Object.keys(videoDeclarationPropsObjectSchema.shape))
|
|
55
|
+
};
|
|
56
|
+
/** Whether a native audio or video declaration accepts the named author property. */
|
|
57
|
+
function supportsMediaProperty(kind, name) {
|
|
58
|
+
return mediaAllowedPropSets[kind].has(name);
|
|
59
|
+
}
|
|
60
|
+
export { audioDeclarationPropsObjectSchema, audioDeclarationPropsSchema, mediaPlaybackPropsSchema, mediaPlaybackPropsShape, mediaTrimSchema, supportsMediaProperty, videoDeclarationPropsObjectSchema, videoDeclarationPropsSchema };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { isImmutableBytes, markImmutableBytes } from "../../kernel/font-seal.js";
|
|
3
|
+
import { resourceSourceSchema } from "../../kernel/resource-source.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
// ../core/dist/capabilities/shared/media-source.js
|
|
6
|
+
function* readMediaSource(source, detectMedia) {
|
|
7
|
+
const parsed = resourceSourceSchema.safeParse(source);
|
|
8
|
+
if (!parsed.success) throw new CapabilityError("invalid-resource", "Media.src must be a file path, file URL, media bytes, or externalUrl descriptor", void 0, {
|
|
9
|
+
field: "src",
|
|
10
|
+
resourceKind: "media"
|
|
11
|
+
});
|
|
12
|
+
const data = parsed.data;
|
|
13
|
+
if (typeof data === "object" && "externalUrl" in data) return {
|
|
14
|
+
kind: "external",
|
|
15
|
+
externalUrl: data.externalUrl
|
|
16
|
+
};
|
|
17
|
+
let bytes;
|
|
18
|
+
try {
|
|
19
|
+
bytes = data instanceof Uint8Array ? data : yield data;
|
|
20
|
+
} catch {
|
|
21
|
+
throw new CapabilityError("invalid-resource", "Failed to read media resource", void 0, {
|
|
22
|
+
field: "src",
|
|
23
|
+
resourceKind: "media"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const format = detectMedia(bytes);
|
|
27
|
+
if (format === void 0) throw new CapabilityError("invalid-resource", "Media resource has an invalid or unsupported container header", void 0, {
|
|
28
|
+
field: "src",
|
|
29
|
+
resourceKind: "media"
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
kind: "embedded",
|
|
33
|
+
bytes: isImmutableBytes(bytes) ? bytes : markImmutableBytes(new Uint8Array(bytes)),
|
|
34
|
+
format
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function fourcc(view, start) {
|
|
38
|
+
return String.fromCharCode(view.getUint8(start), view.getUint8(start + 1), view.getUint8(start + 2), view.getUint8(start + 3));
|
|
39
|
+
}
|
|
40
|
+
function* bmffBoxes(view, start, end) {
|
|
41
|
+
for (let offset = start; offset + 8 <= end;) {
|
|
42
|
+
const type = fourcc(view, offset + 4);
|
|
43
|
+
const size32 = view.getUint32(offset);
|
|
44
|
+
const header = size32 === 1 ? 16 : 8;
|
|
45
|
+
if (offset + header > end) return;
|
|
46
|
+
const size = size32 === 1 ? Number(view.getBigUint64(offset + 8)) : size32 === 0 ? end - offset : size32;
|
|
47
|
+
if (size < header || size > end - offset) return;
|
|
48
|
+
const next = offset + size;
|
|
49
|
+
yield {
|
|
50
|
+
type,
|
|
51
|
+
dataStart: offset + header,
|
|
52
|
+
end: next
|
|
53
|
+
};
|
|
54
|
+
offset = next;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Reads BMFF brands and the movie duration in milliseconds without decoding media. */
|
|
58
|
+
function readBmffMetadata(bytes) {
|
|
59
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
60
|
+
const entries = bmffBoxes(view, 0, bytes.length);
|
|
61
|
+
const first = entries.next();
|
|
62
|
+
if (first.done === true) return void 0;
|
|
63
|
+
const { type, dataStart, end } = first.value;
|
|
64
|
+
if (type !== "ftyp" || end - dataStart < 8 || (end - dataStart) % 4 !== 0) return void 0;
|
|
65
|
+
const brands = [fourcc(view, dataStart)];
|
|
66
|
+
for (let offset = dataStart + 8; offset < end; offset += 4) brands.push(fourcc(view, offset));
|
|
67
|
+
if (brands.some((brand) => !/^[ -~]{4}$/u.test(brand) || brand.trim() === "")) return void 0;
|
|
68
|
+
for (const box of entries) {
|
|
69
|
+
if (box.type !== "moov") continue;
|
|
70
|
+
for (const child of bmffBoxes(view, box.dataStart, box.end)) {
|
|
71
|
+
if (child.type !== "mvhd" || child.dataStart === child.end) continue;
|
|
72
|
+
const version = view.getUint8(child.dataStart);
|
|
73
|
+
if (version !== 0 && version !== 1) continue;
|
|
74
|
+
const timescaleOffset = child.dataStart + (version === 0 ? 12 : 20);
|
|
75
|
+
if (timescaleOffset + (version === 0 ? 8 : 12) > child.end) continue;
|
|
76
|
+
const timescale = view.getUint32(timescaleOffset);
|
|
77
|
+
const duration = version === 0 ? BigInt(view.getUint32(timescaleOffset + 4)) : view.getBigUint64(timescaleOffset + 4);
|
|
78
|
+
if (timescale > 0 && duration > 0n && duration !== (version === 0 ? 4294967295n : 18446744073709551615n)) return {
|
|
79
|
+
brands,
|
|
80
|
+
duration: Number(duration) * 1e3 / timescale
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { brands };
|
|
85
|
+
}
|
|
86
|
+
/** Distinguishes audio-only ISO BMFF files that use a generic ftyp brand. */
|
|
87
|
+
function hasBmffAudioOnlyTracks(bytes) {
|
|
88
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
89
|
+
let audio = false;
|
|
90
|
+
for (const box of bmffBoxes(view, 0, bytes.length)) {
|
|
91
|
+
if (box.type !== "moov") continue;
|
|
92
|
+
for (const track of bmffBoxes(view, box.dataStart, box.end)) {
|
|
93
|
+
if (track.type !== "trak") continue;
|
|
94
|
+
for (const media of bmffBoxes(view, track.dataStart, track.end)) {
|
|
95
|
+
if (media.type !== "mdia") continue;
|
|
96
|
+
for (const handler of bmffBoxes(view, media.dataStart, media.end)) {
|
|
97
|
+
if (handler.type !== "hdlr" || handler.end - handler.dataStart < 12) continue;
|
|
98
|
+
const kind = fourcc(view, handler.dataStart + 8);
|
|
99
|
+
if (kind === "vide") return false;
|
|
100
|
+
if (kind === "soun") audio = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return audio;
|
|
106
|
+
}
|
|
107
|
+
export { hasBmffAudioOnlyTracks, readBmffMetadata, readMediaSource };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// ../core/dist/capabilities/shared/media-trim.js
|
|
2
|
+
const trimScale = 1076;
|
|
3
|
+
const decimalTime = new Intl.NumberFormat("en-US", {
|
|
4
|
+
useGrouping: false,
|
|
5
|
+
signDisplay: "never",
|
|
6
|
+
maximumSignificantDigits: 17
|
|
7
|
+
});
|
|
8
|
+
const trimUnitExponents = {
|
|
9
|
+
h: 5,
|
|
10
|
+
min: 4,
|
|
11
|
+
s: 3,
|
|
12
|
+
ms: 0,
|
|
13
|
+
µs: -3,
|
|
14
|
+
ns: -6
|
|
15
|
+
};
|
|
16
|
+
/** Reads a native universal time offset into fixed-scale milliseconds. */
|
|
17
|
+
function parseNativeTrimTime(raw) {
|
|
18
|
+
const match = /^(\d+)(?:\.(\d+))?([A-Za-z]{1,3}|µ[sS])?$/u.exec(raw?.trim() ?? "");
|
|
19
|
+
if (match === null) return void 0;
|
|
20
|
+
const [, integer = "", fraction = "", suffix = "ms"] = match;
|
|
21
|
+
const unit = suffix.toLowerCase();
|
|
22
|
+
const exponent = trimUnitExponents[unit];
|
|
23
|
+
if (exponent === void 0) return void 0;
|
|
24
|
+
const offset = scaleTrimTime(integer, fraction, exponent, unit === "h" ? 36n : unit === "min" ? 6n : 1n);
|
|
25
|
+
return offset !== void 0 && Number.isFinite(trimTimeNumber(offset)) ? offset : void 0;
|
|
26
|
+
}
|
|
27
|
+
function scaleTrimTime(integer, fraction, exponent, factor) {
|
|
28
|
+
const digits = integer + fraction;
|
|
29
|
+
const first = digits.search(/[1-9]/u);
|
|
30
|
+
if (first === -1) return 0n;
|
|
31
|
+
const wholeDigits = integer.length + exponent - first;
|
|
32
|
+
if (wholeDigits > 309) return void 0;
|
|
33
|
+
const length = Math.max(0, wholeDigits + trimScale + 2);
|
|
34
|
+
const available = digits.slice(first, first + length);
|
|
35
|
+
const product = BigInt(available.padEnd(length, "0") || "0") * factor;
|
|
36
|
+
const tail = /[1-9]/u.test(digits.slice(first + length));
|
|
37
|
+
const scaled = product / 100n;
|
|
38
|
+
return product % 100n !== 0n || tail ? scaled | 1n : scaled;
|
|
39
|
+
}
|
|
40
|
+
function numericTrimTime(value) {
|
|
41
|
+
const [integer = "", fraction = ""] = decimalTime.format(value).split(".");
|
|
42
|
+
return scaleTrimTime(integer, fraction, 0, 1n);
|
|
43
|
+
}
|
|
44
|
+
function formatTrimTime(value) {
|
|
45
|
+
const digits = value.toString().padStart(1077, "0");
|
|
46
|
+
const fraction = digits.slice(-1076).replace(/0+$/u, "");
|
|
47
|
+
return digits.slice(0, -1076) + (fraction === "" ? "" : `.${fraction}`);
|
|
48
|
+
}
|
|
49
|
+
/** Converts a native time offset to the public millisecond representation. */
|
|
50
|
+
function trimTimeNumber(value) {
|
|
51
|
+
return Number(formatTrimTime(value));
|
|
52
|
+
}
|
|
53
|
+
/** Chooses an authorable end that preserves the native amount removed. */
|
|
54
|
+
function importNativeTrimEnd(removed, duration, start = 0n) {
|
|
55
|
+
const fromEnd = trimTimeNumber(removed);
|
|
56
|
+
if (duration !== void 0) {
|
|
57
|
+
const nativeDuration = numericTrimTime(duration);
|
|
58
|
+
const endpoint = nativeDuration - removed;
|
|
59
|
+
if (endpoint <= start) return void 0;
|
|
60
|
+
const absolute = trimTimeNumber(endpoint);
|
|
61
|
+
if (nativeDuration - numericTrimTime(absolute) === removed && (duration - absolute === fromEnd || numericTrimTime(fromEnd) !== removed)) return absolute;
|
|
62
|
+
}
|
|
63
|
+
return { fromEnd };
|
|
64
|
+
}
|
|
65
|
+
/** Checks the interval against a known duration after individual values are parsed. */
|
|
66
|
+
function isMediaTrimWithinDuration({ start = 0, end }, duration) {
|
|
67
|
+
if (typeof end === "number") return start < end && end <= duration;
|
|
68
|
+
return numericTrimTime(start) + numericTrimTime(end?.fromEnd ?? 0) < numericTrimTime(duration);
|
|
69
|
+
}
|
|
70
|
+
/** Largest millisecond delay represented by the native ST_TLTime unsigned integer. */
|
|
71
|
+
const maxMediaStopDelay = 2 ** 32 - 1;
|
|
72
|
+
/** Quantizes an offline absolute interval to the native millisecond delay. */
|
|
73
|
+
function mediaStopDelay(end, start = 0) {
|
|
74
|
+
return Math.max(1, Math.round(end - start));
|
|
75
|
+
}
|
|
76
|
+
/** Formats an end as native decimal milliseconds removed from the underlying asset. */
|
|
77
|
+
function emitNativeTrimEnd(end, duration) {
|
|
78
|
+
if (typeof end === "number") return duration === void 0 ? void 0 : formatTrimTime(numericTrimTime(duration) - numericTrimTime(end));
|
|
79
|
+
return end === void 0 ? void 0 : decimalTime.format(end.fromEnd);
|
|
80
|
+
}
|
|
81
|
+
/** Formats a public offset as native decimal milliseconds. */
|
|
82
|
+
function emitNativeTrimStart(start) {
|
|
83
|
+
return decimalTime.format(start);
|
|
84
|
+
}
|
|
85
|
+
/** Validates trim bounds against clip duration, loop constraints, and native ST_TLTime stop delay. */
|
|
86
|
+
function validateMediaTrimBounds(trim, duration, loop) {
|
|
87
|
+
if (typeof trim?.end === "number" && duration === void 0) {
|
|
88
|
+
if (loop) return {
|
|
89
|
+
field: "trim.end",
|
|
90
|
+
message: "Media trim.end needs a known clip duration for looping. Use { fromEnd: milliseconds } to trim from the end."
|
|
91
|
+
};
|
|
92
|
+
if (mediaStopDelay(trim.end, trim.start) > maxMediaStopDelay) return {
|
|
93
|
+
field: "trim.end",
|
|
94
|
+
message: `Media trim.end exceeds the native delay maximum of ${maxMediaStopDelay} milliseconds for media with unknown duration. Use { fromEnd: milliseconds } to trim from the end.`
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (trim !== void 0 && duration !== void 0 && !isMediaTrimWithinDuration(trim, duration)) return {
|
|
98
|
+
field: (trim.start ?? 0) >= duration ? "trim.start" : typeof trim.end === "object" ? "trim.end.fromEnd" : "trim.end",
|
|
99
|
+
message: "Media trim must describe a nonempty range within the clip duration"
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export { emitNativeTrimEnd, emitNativeTrimStart, importNativeTrimEnd, isMediaTrimWithinDuration, maxMediaStopDelay, mediaStopDelay, parseNativeTrimTime, trimTimeNumber, validateMediaTrimBounds };
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { CapabilityError, zodIssueField } from "../../kernel/diagnostics.js";
|
|
2
|
+
import "../../kernel/capability.js";
|
|
3
|
+
import { P14_NS, REL_MEDIA, R_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
4
|
+
import { xmlEscape } from "../../kernel/pptx-write/xml.js";
|
|
5
|
+
import { audioDeclarationPropsObjectSchema, mediaPlaybackPropsSchema, mediaPlaybackPropsShape, supportsMediaProperty } from "./media-schemas.js";
|
|
6
|
+
import { readMediaSource } from "./media-source.js";
|
|
7
|
+
import { emitNativeTrimEnd, emitNativeTrimStart, mediaStopDelay, validateMediaTrimBounds } from "./media-trim.js";
|
|
8
|
+
import { bindPicture, emitImageModel, readImageSource } from "./picture.js";
|
|
9
|
+
import { compatiblePlaceholderRoles } from "./placeholder-roles.js";
|
|
10
|
+
// ../core/dist/capabilities/shared/media.js
|
|
11
|
+
const mediaExtensionUri = "{DAA4B4D4-6D71-4841-9C94-3DE7FCFB9230}";
|
|
12
|
+
const mediaAction = "ppaction://media";
|
|
13
|
+
function mediaResourceObservation(media) {
|
|
14
|
+
return media.kind === "embedded" ? { kind: "embedded" } : {
|
|
15
|
+
kind: "external",
|
|
16
|
+
url: media.externalUrl
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Binds a video or audio surface using common poster layout and standalone playback rules. */
|
|
20
|
+
function* bindMediaPicture(input, context, options) {
|
|
21
|
+
const isVideo = options.kind === "video";
|
|
22
|
+
const label = isVideo ? "Video" : "Audio";
|
|
23
|
+
const unknown = Object.keys(input.props).find((key) => !supportsMediaProperty(options.kind, key));
|
|
24
|
+
if (unknown !== void 0) throw new CapabilityError("unknown-parameter", `${label} contains unsupported parameter ${unknown}`);
|
|
25
|
+
if (input.children.some((child) => "props" in child || child.text.trim() !== "")) throw new CapabilityError("unsupported-children", `${label} does not accept children`);
|
|
26
|
+
const role = context.placeholder?.nativeRef.type;
|
|
27
|
+
if (role !== void 0 && (!isVideo || !compatiblePlaceholderRoles.video.has(role))) throw new CapabilityError("incompatible-placeholder-content", `${label} cannot be bound to ${role} placeholder`);
|
|
28
|
+
const parsed = mediaPlaybackPropsSchema.safeParse(Object.fromEntries(Object.keys(mediaPlaybackPropsShape).map((name) => [name, input.props[name]])));
|
|
29
|
+
if (!parsed.success) throw new CapabilityError("invalid-parameter", parsed.error.issues[0]?.message ?? "Invalid media playback", void 0, { field: zodIssueField(parsed.error.issues[0]) });
|
|
30
|
+
const { autoPlay = false, loop = false, muted = false, volume = muted ? 0 : 1, trim } = parsed.data;
|
|
31
|
+
const parsedHide = audioDeclarationPropsObjectSchema.shape.hideDuringShow.safeParse(input.props["hideDuringShow"]);
|
|
32
|
+
if (!parsedHide.success) throw new CapabilityError("invalid-parameter", "hideDuringShow must be a boolean", void 0, { field: "hideDuringShow" });
|
|
33
|
+
const hideDuringShow = !isVideo && (parsedHide.data ?? autoPlay);
|
|
34
|
+
const media = yield* readMediaSource(input.props["src"], options.detectMedia);
|
|
35
|
+
const duration = media.kind === "embedded" ? media.format.duration : void 0;
|
|
36
|
+
const trimIssue = validateMediaTrimBounds(trim, duration, loop);
|
|
37
|
+
if (trimIssue !== void 0) throw new CapabilityError("invalid-parameter", trimIssue.message, void 0, { field: trimIssue.field });
|
|
38
|
+
if (typeof trim?.end === "object") Object.freeze(trim.end);
|
|
39
|
+
const playback = Object.freeze({
|
|
40
|
+
autoPlay,
|
|
41
|
+
loop,
|
|
42
|
+
muted,
|
|
43
|
+
volume,
|
|
44
|
+
...trim === void 0 ? {} : { trim: Object.freeze(trim) }
|
|
45
|
+
});
|
|
46
|
+
const poster = options.defaultPoster();
|
|
47
|
+
return yield* bindPicture(input, context, {
|
|
48
|
+
label,
|
|
49
|
+
layoutOnlyStyle: !isVideo,
|
|
50
|
+
externalSize: {
|
|
51
|
+
width: poster.width,
|
|
52
|
+
height: poster.height
|
|
53
|
+
},
|
|
54
|
+
*readSource() {
|
|
55
|
+
const source = input.props["poster"];
|
|
56
|
+
return source === void 0 ? {
|
|
57
|
+
kind: "embedded",
|
|
58
|
+
...poster
|
|
59
|
+
} : yield* readImageSource(source);
|
|
60
|
+
},
|
|
61
|
+
resolve(picture, resolution) {
|
|
62
|
+
return options.resolve({
|
|
63
|
+
kind: options.kind,
|
|
64
|
+
picture,
|
|
65
|
+
media,
|
|
66
|
+
playback,
|
|
67
|
+
hideDuringShow
|
|
68
|
+
}, resolution);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
function emitMediaPicture(model, context) {
|
|
73
|
+
const { kind, media, playback, hideDuringShow } = model;
|
|
74
|
+
const legacy = context.registerResource(media.kind === "embedded" ? {
|
|
75
|
+
bytes: media.bytes,
|
|
76
|
+
extension: media.format.extension,
|
|
77
|
+
contentType: media.format.contentType,
|
|
78
|
+
relationshipType: `${R_NS}/${kind}`
|
|
79
|
+
} : {
|
|
80
|
+
externalTarget: media.externalUrl,
|
|
81
|
+
relationshipType: `${R_NS}/${kind}`
|
|
82
|
+
});
|
|
83
|
+
const mediaId = context.registerResource(media.kind === "embedded" ? {
|
|
84
|
+
bytes: media.bytes,
|
|
85
|
+
extension: media.format.extension,
|
|
86
|
+
contentType: media.format.contentType,
|
|
87
|
+
relationshipType: REL_MEDIA
|
|
88
|
+
} : {
|
|
89
|
+
externalTarget: media.externalUrl,
|
|
90
|
+
relationshipType: REL_MEDIA
|
|
91
|
+
});
|
|
92
|
+
const { trim } = playback;
|
|
93
|
+
const start = trim?.start;
|
|
94
|
+
const duration = media.kind === "embedded" ? media.format.duration : void 0;
|
|
95
|
+
const end = emitNativeTrimEnd(trim?.end, duration);
|
|
96
|
+
const trimXml = start === void 0 && trim?.end === void 0 ? "" : `<p14:trim${start === void 0 ? "" : ` st="${emitNativeTrimStart(start)}"`}${end === void 0 ? "" : ` end="${end}"`}/>`;
|
|
97
|
+
const relationship = media.kind === "embedded" ? "embed" : "link";
|
|
98
|
+
const properties = `<a:${kind}File r:link="${xmlEscape(legacy)}"/><p:extLst><p:ext uri="${mediaExtensionUri}"><p14:media xmlns:p14="${P14_NS}" r:${relationship}="${xmlEscape(mediaId)}">${trimXml}</p14:media></p:ext></p:extLst>`;
|
|
99
|
+
const output = emitImageModel(model.picture, context, {
|
|
100
|
+
action: `<a:hlinkClick r:id="" action="${mediaAction}"/>`,
|
|
101
|
+
properties
|
|
102
|
+
});
|
|
103
|
+
const stopAfter = typeof trim?.end !== "number" || duration !== void 0 ? void 0 : mediaStopDelay(trim.end, start);
|
|
104
|
+
const target = `<p:tgtEl><p:spTgt spid="${context.id}"/></p:tgtEl>`;
|
|
105
|
+
const click = `<p:cond evt="onClick" delay="0">${target}</p:cond>`;
|
|
106
|
+
const condition = "<p:stCondLst><p:cond delay=\"0\"/></p:stCondLst>";
|
|
107
|
+
const mediaAttributes = ` vol="${Math.round(playback.volume * 1e5)}"${playback.muted ? " mute=\"1\"" : ""}${kind === "audio" ? ` showWhenStopped="${hideDuringShow ? 0 : 1}"` : ""}`;
|
|
108
|
+
return {
|
|
109
|
+
...output,
|
|
110
|
+
timing(ids) {
|
|
111
|
+
const rootChildren = [];
|
|
112
|
+
const mediaCommand = (preset, command, nodeType, delay = 0) => {
|
|
113
|
+
const startCondition = `<p:stCondLst><p:cond delay="${delay}"/></p:stCondLst>`;
|
|
114
|
+
return `<p:par><p:cTn id="${ids.take()}" presetID="${preset}" presetClass="mediacall" presetSubtype="0" fill="hold" nodeType="${nodeType}">${startCondition}<p:childTnLst><p:cmd type="call" cmd="${command}"><p:cBhvr><p:cTn id="${ids.take()}" dur="1" fill="hold"/>${target}</p:cBhvr></p:cmd></p:childTnLst></p:cTn></p:par>`;
|
|
115
|
+
};
|
|
116
|
+
const effects = (trigger) => [!playback.autoPlay && stopAfter === void 0 ? mediaCommand(2, "togglePause", trigger) : mediaCommand(1, "playFrom(0.0)", trigger), ...stopAfter !== void 0 ? [mediaCommand(3, "stop", "withEffect", stopAfter)] : []];
|
|
117
|
+
const startupEffects = playback.autoPlay ? effects("withEffect") : [];
|
|
118
|
+
if (!playback.autoPlay) {
|
|
119
|
+
const seq = ids.take();
|
|
120
|
+
const group = ids.take();
|
|
121
|
+
const step = ids.take();
|
|
122
|
+
rootChildren.push(`<p:seq concurrent="1" nextAc="seek"><p:cTn id="${seq}" restart="whenNotActive" fill="hold" evtFilter="cancelBubble" nodeType="interactiveSeq"><p:stCondLst>${click}</p:stCondLst><p:endSync evt="end" delay="0"><p:rtn val="all"/></p:endSync><p:childTnLst><p:par><p:cTn id="${group}" fill="hold">${condition}<p:childTnLst><p:par><p:cTn id="${step}" fill="hold">${condition}<p:childTnLst>${effects("clickEffect").join("")}</p:childTnLst></p:cTn></p:par></p:childTnLst></p:cTn></p:par></p:childTnLst></p:cTn><p:nextCondLst>${click}</p:nextCondLst></p:seq>`);
|
|
123
|
+
}
|
|
124
|
+
const audioEnd = kind === "audio" ? "<p:endCondLst><p:cond evt=\"onStopAudio\" delay=\"0\"><p:tgtEl><p:sldTgt/></p:tgtEl></p:cond></p:endCondLst>" : "";
|
|
125
|
+
rootChildren.push(`<p:${kind}><p:cMediaNode${mediaAttributes}><p:cTn id="${ids.take()}"${stopAfter === void 0 ? "" : ` dur="${stopAfter}"`}${playback.loop ? " repeatCount=\"indefinite\"" : ""} fill="hold" display="0"><p:stCondLst><p:cond delay="indefinite"/></p:stCondLst>${audioEnd}</p:cTn>${target}</p:cMediaNode></p:${kind}>`);
|
|
126
|
+
return {
|
|
127
|
+
rootChildren,
|
|
128
|
+
startupEffects,
|
|
129
|
+
requiresMainSequence: !playback.autoPlay
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
export { bindMediaPicture, emitMediaPicture, mediaAction, mediaExtensionUri, mediaResourceObservation };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isMorphKey } from "
|
|
2
|
-
import { linkTargetSchema } from "
|
|
3
|
-
import "
|
|
4
|
-
import "
|
|
1
|
+
import { isMorphKey } from "../../kernel/morph.js";
|
|
2
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
import "../../kernel/index.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
// ../
|
|
6
|
+
// ../core/dist/capabilities/shared/morph-api.js
|
|
7
7
|
/** Runtime-identity-preserving Zod schema for handles created by `createMorphScope().handle(name)`. */
|
|
8
8
|
const morphKeySchema = z.custom(isMorphKey, "morphKey must be created by createMorphScope().handle(name)");
|
|
9
9
|
z.strictObject({ morphKey: morphKeySchema.optional() }).readonly();
|