@officedk/pptxdk 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.d.ts +14 -76
- package/dist/build.js +69 -97
- package/dist/cli.js +1 -1
- package/dist/core/dist/capabilities/audio/audio-declaration.js +7 -0
- package/dist/core/dist/capabilities/audio/audio-source.js +172 -0
- package/dist/core/dist/capabilities/audio/entry.js +122 -0
- package/dist/core/dist/capabilities/box/box-codegen.js +83 -0
- package/dist/core/dist/capabilities/box/box-declaration.js +32 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +32 -29
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +17 -22
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +1025 -471
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +3 -3
- package/dist/{capabilities/dist/chart/preview/number-format.js → core/dist/capabilities/chart/chart-number-format.js} +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-schemas.js +216 -212
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +228 -171
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +23 -10
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/bar-column.js +1 -1
- package/dist/core/dist/capabilities/chart/preview/data-labels.js +474 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/error-bars.js +3 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/index.js +30 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +160 -89
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +4 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +4 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/markers.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/pie-doughnut.js +39 -60
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scales.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/scatter.js +3 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +15 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/text-render.js +34 -24
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/trendlines.js +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/types.js +1 -1
- package/dist/core/dist/capabilities/comment/comment-codegen.js +25 -0
- package/dist/core/dist/capabilities/comment/comment-declaration.js +37 -0
- package/dist/core/dist/capabilities/comment/comment-import.js +176 -0
- package/dist/core/dist/capabilities/comment/comment.js +141 -0
- package/dist/core/dist/capabilities/comment/entry.js +1 -0
- package/dist/core/dist/capabilities/footer-placeholder/entry.js +2 -0
- package/dist/core/dist/capabilities/footer-placeholder/footer-placeholder-codegen.js +16 -0
- package/dist/{capabilities/dist/masters → core/dist/capabilities/footer-placeholder}/footer-placeholder.js +194 -133
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer-import.js +121 -0
- package/dist/core/dist/capabilities/footer-placeholder/print-header-footer.js +123 -0
- package/dist/core/dist/capabilities/group/entry.js +2 -0
- package/dist/core/dist/capabilities/group/group-codegen.js +73 -0
- package/dist/core/dist/capabilities/group/group-declaration.js +41 -0
- package/dist/core/dist/capabilities/group/group-import.js +608 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +4 -3
- package/dist/core/dist/capabilities/group/group.js +260 -0
- package/dist/core/dist/capabilities/image/entry.js +4 -0
- package/dist/core/dist/capabilities/image/image-codegen.js +59 -0
- package/dist/core/dist/capabilities/image/image-declaration.js +8 -0
- package/dist/core/dist/capabilities/image/image-import.js +26 -0
- package/dist/core/dist/capabilities/image/image.js +57 -0
- package/dist/core/dist/capabilities/line/entry.js +3 -0
- package/dist/core/dist/capabilities/line/line-codegen.js +88 -0
- package/dist/core/dist/capabilities/line/line-declaration.js +78 -0
- package/dist/core/dist/capabilities/line/line-import.js +424 -0
- package/dist/core/dist/capabilities/line/line-xml.js +9 -0
- package/dist/core/dist/capabilities/line/line.js +329 -0
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/core/dist/capabilities/masters/masters-codegen.js +50 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +35 -47
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +97 -51
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +653 -102
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +317 -163
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +9 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +357 -108
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +5 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-import.js +16 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-schemas.js +12 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +20 -42
- package/dist/{import/dist/sections.js → core/dist/capabilities/notes/sections-import.js} +5 -5
- package/dist/core/dist/capabilities/placeholder/entry.js +3 -0
- package/dist/core/dist/capabilities/placeholder/placeholder-codegen.js +44 -0
- package/dist/core/dist/capabilities/placeholder/placeholder-schemas.js +31 -0
- package/dist/core/dist/capabilities/placeholder/placeholder.js +394 -0
- package/dist/core/dist/capabilities/shape/entry.js +6 -0
- package/dist/core/dist/capabilities/shape/shape-codegen.js +112 -0
- package/dist/core/dist/capabilities/shape/shape-import.js +152 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/shape/shape.js +100 -103
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/core/dist/capabilities/shared/font/font-embedding.js +118 -0
- package/dist/core/dist/capabilities/shared/font/font-engine.js +855 -0
- package/dist/core/dist/capabilities/shared/font/font-import.js +805 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/core/dist/capabilities/shared/font/font.js +72 -0
- package/dist/{capabilities/dist/shape/shape-codegen.js → core/dist/capabilities/shared/geometry-codegen.js} +4 -69
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +384 -123
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/identity.js +56 -38
- package/dist/core/dist/capabilities/shared/image-codegen.js +94 -0
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-decode.js +17 -56
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +49 -61
- package/dist/core/dist/capabilities/shared/line-match.js +78 -0
- package/dist/core/dist/capabilities/shared/media-codegen.js +86 -0
- package/dist/core/dist/capabilities/shared/media-import.js +156 -0
- package/dist/core/dist/capabilities/shared/media-placement.js +20 -0
- package/dist/core/dist/capabilities/shared/media-poster.js +50 -0
- package/dist/core/dist/capabilities/shared/media-schemas.js +60 -0
- package/dist/core/dist/capabilities/shared/media-source.js +107 -0
- package/dist/core/dist/capabilities/shared/media-trim.js +102 -0
- package/dist/core/dist/capabilities/shared/media.js +134 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/morph-api.js +5 -5
- package/dist/core/dist/capabilities/shared/motion-api.js +770 -0
- package/dist/core/dist/capabilities/shared/motion-schemas.js +353 -0
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +313 -168
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/core/dist/capabilities/shared/placeholder-import.js +268 -0
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1221 -188
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/core/dist/capabilities/shared/rich-text-codegen.js +119 -0
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/core/dist/capabilities/shared/shape-declaration.js +45 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +26 -24
- package/dist/core/dist/capabilities/shared/text-declaration.js +31 -0
- package/dist/core/dist/capabilities/shared/text-schemas.js +241 -0
- package/dist/core/dist/capabilities/shared/text-service.js +2563 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +441 -137
- package/dist/core/dist/capabilities/slide-background/entry.js +1 -0
- package/dist/core/dist/capabilities/slide-background/slide-background-codegen.js +15 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-import.js +12 -7
- package/dist/core/dist/capabilities/slide-background/slide-background-xml.js +33 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +61 -50
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/core/dist/capabilities/table/table-codegen.js +118 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +116 -84
- package/dist/core/dist/capabilities/table/table-schemas.js +337 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +13 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +284 -192
- package/dist/core/dist/capabilities/text/entry.js +3 -0
- package/dist/core/dist/capabilities/text/text-codegen.js +66 -0
- package/dist/core/dist/capabilities/text/text-import.js +468 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text-xml.js +3 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/text/text.js +103 -111
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +13 -16
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-codegen.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-import.js +25 -27
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition.js +23 -23
- package/dist/core/dist/capabilities/video/entry.js +77 -0
- package/dist/core/dist/capabilities/video/video-declaration.js +7 -0
- package/dist/core/dist/capabilities/video/video-source.js +42 -0
- package/dist/{codegen/dist → core/dist/codegen}/assets.js +16 -10
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +152 -140
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +27 -1
- package/dist/{codegen/dist → core/dist/codegen}/index.js +2 -2
- package/dist/{codegen/dist → core/dist/codegen}/printer.js +23 -4
- package/dist/core/dist/document/all.js +41 -0
- package/dist/core/dist/document/default.js +10 -0
- package/dist/core/dist/document/document.js +218 -0
- package/dist/core/dist/document/index.js +62 -0
- package/dist/core/dist/document/stages.js +54 -0
- package/dist/{emit/dist → core/dist/emit}/emit.js +173 -90
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/core/dist/import/import.js +547 -0
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +404 -328
- package/dist/core/dist/import/media-timing.js +233 -0
- package/dist/{import/dist → core/dist/import}/notes-masters.js +48 -45
- package/dist/core/dist/index.js +47 -15
- package/dist/core/dist/{author-ids.js → kernel/author-ids.js} +9 -6
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +105 -127
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +225 -142
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/core/dist/kernel/codegen.js +97 -0
- package/dist/core/dist/kernel/container-slots.js +104 -0
- package/dist/core/dist/kernel/date-time-format.js +18 -0
- package/dist/core/dist/kernel/declaration-snapshot.js +68 -0
- package/dist/core/dist/{declaration.js → kernel/declaration.js} +3 -2
- package/dist/core/dist/kernel/diagnostics.js +370 -0
- package/dist/core/dist/kernel/document-internals.js +26 -0
- package/dist/core/dist/{document.js → kernel/document.js} +23 -13
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/kernel/font-seal.js +204 -0
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +21 -18
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +177 -72
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/kernel/input-values.js +62 -0
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +5 -10
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +33 -44
- package/dist/core/dist/kernel/layout.js +339 -0
- package/dist/core/dist/kernel/masters.js +171 -0
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/kernel/placeholders.js +289 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/alternate-content.js +1 -1
- package/dist/{import/dist → core/dist/kernel/pptx-read}/diagnostics.js +33 -29
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +71 -12
- package/dist/core/dist/kernel/pptx-read/index.js +15 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/mechanism.js +1 -1
- package/dist/core/dist/kernel/pptx-read/media.js +26 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/namespaces.js +6 -7
- package/dist/{import/dist → core/dist/kernel/pptx-read}/opc.js +62 -13
- package/dist/{import/dist → core/dist/kernel/pptx-read}/resources.js +1 -1
- package/dist/core/dist/kernel/pptx-read/shape-tree.js +57 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/themes.js +182 -41
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +175 -88
- package/dist/core/dist/kernel/pptx-read/xml-fragments.js +320 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-reader.js +8 -1
- package/dist/{emit/dist → core/dist/kernel/pptx-write}/shape-tree.js +1 -1
- package/dist/core/dist/kernel/pptx-write/timing.js +52 -0
- package/dist/{emit/dist/ooxml.js → core/dist/kernel/pptx-write/xml.js} +133 -290
- package/dist/core/dist/{query.js → kernel/query.js} +76 -37
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +2 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +797 -409
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/kernel/stage-options.js +312 -0
- package/dist/core/dist/{theme.js → kernel/theme.js} +399 -289
- package/dist/core/dist/kernel/transform-geometry.js +72 -0
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/document-C0lPlH-L.d.ts +1442 -0
- package/dist/index-B9_OUeA-.d.ts +2238 -0
- package/dist/index-BJEzQxWV.d.ts +75 -0
- package/dist/index-DA9flrlR.d.ts +146 -0
- package/dist/index-GSt0t9VO.d.ts +54 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +75 -61
- package/dist/node.d.ts +37 -35
- package/dist/node.js +125 -51
- package/dist/pptxdk/src/cli-commands.js +79 -81
- package/dist/pptxdk/src/compose.js +32 -24
- package/dist/pptxdk/src/preview-result.js +24 -0
- package/dist/{capabilities/dist/image → preview/dist}/gif-decoder.js +5 -5
- package/dist/preview/dist/index.js +229 -77
- package/dist/preview/dist/options.js +17 -26
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +1090 -0
- package/dist/preview.d.ts +6 -3
- package/dist/preview.js +8 -24
- package/dist/react/dist/append.js +3 -3
- package/dist/react/dist/author/audio-elements.js +14 -0
- package/dist/{capabilities/dist/box → react/dist/author}/box-elements.js +5 -3
- package/dist/react/dist/author/chart-elements.js +14 -0
- package/dist/react/dist/author/comment-elements.js +15 -0
- package/dist/react/dist/author/group-elements.js +14 -0
- package/dist/react/dist/author/image-elements.js +14 -0
- package/dist/react/dist/author/line-elements.js +14 -0
- package/dist/{capabilities/dist/motion → react/dist/author}/motion-elements.js +6 -4
- package/dist/react/dist/author/notes-elements.js +14 -0
- package/dist/react/dist/author/placeholder-elements.js +14 -0
- package/dist/react/dist/author/shape-elements.js +14 -0
- package/dist/{capabilities/dist/table → react/dist/author}/table-elements.js +6 -4
- package/dist/react/dist/author/text-elements.js +64 -0
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +376 -37
- package/dist/react/dist/elements.js +30 -4
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +47 -12
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +26 -26
- package/dist/react.d.ts +174 -50
- package/dist/react.js +31 -27
- package/dist/stages-DYHSHKt4.d.ts +80 -0
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -14
- package/package.json +6 -8
- package/README.md +0 -49
- package/dist/capabilities/dist/all.js +0 -32
- package/dist/capabilities/dist/box/box-codegen.js +0 -51
- package/dist/capabilities/dist/box/box-declaration.js +0 -31
- package/dist/capabilities/dist/chart/chart-elements.js +0 -12
- package/dist/capabilities/dist/chart/preview/data-labels.js +0 -334
- package/dist/capabilities/dist/document.js +0 -148
- package/dist/capabilities/dist/font/font-embedding.js +0 -289
- package/dist/capabilities/dist/font/font-family.js +0 -10
- package/dist/capabilities/dist/font/font-import.js +0 -302
- package/dist/capabilities/dist/font/font.js +0 -25
- package/dist/capabilities/dist/group/group-codegen.js +0 -51
- package/dist/capabilities/dist/group/group-declaration.js +0 -42
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/group/group-import.js +0 -319
- package/dist/capabilities/dist/group/group.js +0 -211
- package/dist/capabilities/dist/image/image-codegen.js +0 -94
- package/dist/capabilities/dist/image/image-declaration.js +0 -8
- package/dist/capabilities/dist/image/image-elements.js +0 -12
- package/dist/capabilities/dist/image/image-xml.js +0 -12
- package/dist/capabilities/dist/image/image.js +0 -472
- package/dist/capabilities/dist/masters/masters-codegen.js +0 -21
- package/dist/capabilities/dist/motion/motion-api.js +0 -527
- package/dist/capabilities/dist/motion/motion-schemas.js +0 -216
- package/dist/capabilities/dist/notes/notes-elements.js +0 -12
- package/dist/capabilities/dist/notes/notes-xml.js +0 -38
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +0 -23
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +0 -12
- package/dist/capabilities/dist/placeholder/placeholder.js +0 -292
- package/dist/capabilities/dist/shape/shape-declaration.js +0 -57
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -579
- package/dist/capabilities/dist/shared/placeholder-import.js +0 -113
- package/dist/capabilities/dist/shared/style-parse.js +0 -11
- package/dist/capabilities/dist/shared/text-schemas.js +0 -216
- package/dist/capabilities/dist/shared/text-service.js +0 -1883
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +0 -21
- package/dist/capabilities/dist/table/table-codegen.js +0 -81
- package/dist/capabilities/dist/table/table-schemas.js +0 -279
- package/dist/capabilities/dist/text/text-codegen.js +0 -129
- package/dist/capabilities/dist/text/text-declaration.js +0 -19
- package/dist/capabilities/dist/text/text-elements.js +0 -38
- package/dist/capabilities/dist/text/text-import.js +0 -1077
- package/dist/capability-D_xeNVIw.d.ts +0 -29496
- package/dist/codegen/dist/types.js +0 -49
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -13
- package/dist/core/dist/diagnostics.js +0 -21
- package/dist/core/dist/document-internals.js +0 -13
- package/dist/core/dist/input-values.js +0 -45
- package/dist/core/dist/layout.js +0 -299
- package/dist/core/dist/masters.js +0 -169
- package/dist/core/dist/placeholders.js +0 -213
- package/dist/core/dist/stage-options.js +0 -67
- package/dist/document-BHPUODPP.d.ts +0 -27759
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/import.js +0 -504
- package/dist/import/dist/index.js +0 -16
- package/dist/import/dist/xml-fragments.js +0 -36
- package/dist/index-B5m3hqjC.d.ts +0 -7
- package/dist/index-CCy-Yo8G.d.ts +0 -1208
- package/dist/index-DpxcZ4Gs.d.ts +0 -725
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/preview-Cfw0QdMM.d.ts +0 -86
- package/dist/transition-Cips9wma.d.ts +0 -82
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import { CapabilityError } from "../../core/dist/diagnostics.js";
|
|
2
|
-
import "../../core/dist/
|
|
3
|
-
import { getInternalResolution } from "../../core/dist/resolution.js";
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { CapabilityError } from "../../core/dist/kernel/diagnostics.js";
|
|
2
|
+
import { PreviewPageRangeError, previewErrorSchema, previewPlaceholderSchema } from "../../core/dist/kernel/stage-options.js";
|
|
3
|
+
import { getInternalResolution } from "../../core/dist/kernel/resolution.js";
|
|
4
|
+
import "../../core/dist/kernel/index.js";
|
|
5
|
+
import { paintOptionsSchema, previewOptionsSchema, previewPageNumberSchema, previewPagesSchema, screenGeometrySchema, screenPointSchema, validatePaintOptions } from "./options.js";
|
|
6
|
+
import { decodeImageToPngBytes, loadImageDecoders } from "./raster.js";
|
|
7
|
+
import { createPageRasterRegistry, sanitizeSvgForRasterization } from "./svg-guard.js";
|
|
8
|
+
import { setImmediate } from "node:timers/promises";
|
|
6
9
|
// ../preview/dist/index.js
|
|
7
10
|
const defaultCanvasBackground = "<rect width=\"100%\" height=\"100%\" fill=\"white\"/>";
|
|
11
|
+
function roundScreenMetric(value) {
|
|
12
|
+
const rounded = Math.round(value * 1e9) / 1e9;
|
|
13
|
+
return Object.is(rounded, -0) ? 0 : rounded;
|
|
14
|
+
}
|
|
8
15
|
/**
|
|
9
16
|
* Computes transformed screen corners and axis-aligned screen bounds for a layout box.
|
|
10
17
|
* Applies the local object transform first, followed by enclosing group transforms outward.
|
|
@@ -39,27 +46,24 @@ function screenGeometry(box, transforms) {
|
|
|
39
46
|
point.y = cy + x * Math.sin(angle) + y * Math.cos(angle);
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
|
-
const
|
|
43
|
-
|
|
49
|
+
const rounded = corners.map((point) => Object.freeze({
|
|
50
|
+
x: roundScreenMetric(point.x),
|
|
51
|
+
y: roundScreenMetric(point.y)
|
|
52
|
+
}));
|
|
53
|
+
const left = Math.min(...rounded.map((point) => point.x));
|
|
54
|
+
const top = Math.min(...rounded.map((point) => point.y));
|
|
55
|
+
const right = Math.max(...rounded.map((point) => point.x));
|
|
56
|
+
const bottom = Math.max(...rounded.map((point) => point.y));
|
|
44
57
|
return {
|
|
45
|
-
corners: Object.freeze(
|
|
58
|
+
corners: Object.freeze(rounded),
|
|
46
59
|
screenBox: Object.freeze({
|
|
47
60
|
x: left,
|
|
48
61
|
y: top,
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
62
|
+
width: roundScreenMetric(right - left),
|
|
63
|
+
height: roundScreenMetric(bottom - top)
|
|
51
64
|
})
|
|
52
65
|
};
|
|
53
66
|
}
|
|
54
|
-
let cachedResvg;
|
|
55
|
-
function getResvg() {
|
|
56
|
-
if (cachedResvg === void 0) {
|
|
57
|
-
const loaded = createRequire(import.meta.url)("@resvg/resvg-js");
|
|
58
|
-
if (typeof loaded !== "object" || loaded === null || !("Resvg" in loaded) || typeof loaded.Resvg !== "function") throw new Error("Failed to load @resvg/resvg-js Resvg constructor");
|
|
59
|
-
cachedResvg = loaded.Resvg;
|
|
60
|
-
}
|
|
61
|
-
return cachedResvg;
|
|
62
|
-
}
|
|
63
67
|
function maxPaintObjectId(layers) {
|
|
64
68
|
let maxId = 0;
|
|
65
69
|
for (const layer of layers) {
|
|
@@ -71,8 +75,105 @@ function maxPaintObjectId(layers) {
|
|
|
71
75
|
}
|
|
72
76
|
return maxId;
|
|
73
77
|
}
|
|
74
|
-
function
|
|
75
|
-
const
|
|
78
|
+
function toPreviewError(error, path, fallbackCapability) {
|
|
79
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
80
|
+
if (error instanceof CapabilityError) {
|
|
81
|
+
const details = error.details ?? {};
|
|
82
|
+
const field = typeof details["field"] === "string" && details["field"] !== "" ? details["field"] : void 0;
|
|
83
|
+
const fieldSpread = field === void 0 ? {} : { field };
|
|
84
|
+
const rawFont = details["font"];
|
|
85
|
+
const fontRecord = typeof rawFont === "object" && rawFont !== null ? rawFont : void 0;
|
|
86
|
+
const family = typeof fontRecord?.["family"] === "string" ? fontRecord["family"] : "unknown";
|
|
87
|
+
const weight = typeof fontRecord?.["weight"] === "number" ? fontRecord["weight"] : 400;
|
|
88
|
+
const style = fontRecord?.["style"] === "italic" ? "italic" : "normal";
|
|
89
|
+
switch (error.code) {
|
|
90
|
+
case "preview-missing-font": return Object.freeze({
|
|
91
|
+
code: "preview-missing-font",
|
|
92
|
+
path,
|
|
93
|
+
...fieldSpread,
|
|
94
|
+
message,
|
|
95
|
+
font: Object.freeze({
|
|
96
|
+
family,
|
|
97
|
+
weight,
|
|
98
|
+
style
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
case "preview-unsupported-font": {
|
|
102
|
+
const optionalWeight = typeof fontRecord?.["weight"] === "number" ? fontRecord["weight"] : void 0;
|
|
103
|
+
const optionalStyle = fontRecord?.["style"] === "italic" || fontRecord?.["style"] === "normal" ? fontRecord["style"] : void 0;
|
|
104
|
+
const reason = typeof details["reason"] === "string" ? details["reason"] : void 0;
|
|
105
|
+
return Object.freeze({
|
|
106
|
+
code: "preview-unsupported-font",
|
|
107
|
+
path,
|
|
108
|
+
...fieldSpread,
|
|
109
|
+
message,
|
|
110
|
+
font: Object.freeze({
|
|
111
|
+
family,
|
|
112
|
+
...optionalWeight === void 0 ? {} : { weight: optionalWeight },
|
|
113
|
+
...optionalStyle === void 0 ? {} : { style: optionalStyle }
|
|
114
|
+
}),
|
|
115
|
+
...reason === void 0 ? {} : { reason }
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
case "preview-missing-glyph": {
|
|
119
|
+
const rawChars = details["characters"];
|
|
120
|
+
const characters = Array.isArray(rawChars) ? rawChars.filter((item) => typeof item === "string") : [];
|
|
121
|
+
return Object.freeze({
|
|
122
|
+
code: "preview-missing-glyph",
|
|
123
|
+
path,
|
|
124
|
+
...fieldSpread,
|
|
125
|
+
message,
|
|
126
|
+
font: Object.freeze({
|
|
127
|
+
family,
|
|
128
|
+
weight,
|
|
129
|
+
style
|
|
130
|
+
}),
|
|
131
|
+
characters: Object.freeze(characters)
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
case "preview-corrupt-image": {
|
|
135
|
+
const rawFormat = details["format"];
|
|
136
|
+
const format = rawFormat === "png" || rawFormat === "jpeg" || rawFormat === "gif" ? rawFormat : void 0;
|
|
137
|
+
return Object.freeze({
|
|
138
|
+
code: "preview-corrupt-image",
|
|
139
|
+
path,
|
|
140
|
+
...fieldSpread,
|
|
141
|
+
message,
|
|
142
|
+
...format === void 0 ? {} : { format }
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
case "preview-unsupported-capability": {
|
|
146
|
+
const capability = typeof details["capability"] === "string" ? details["capability"] : fallbackCapability;
|
|
147
|
+
return Object.freeze({
|
|
148
|
+
code: "preview-unsupported-capability",
|
|
149
|
+
path,
|
|
150
|
+
...fieldSpread,
|
|
151
|
+
message,
|
|
152
|
+
capability
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return Object.freeze({
|
|
158
|
+
code: "preview-unsupported-capability",
|
|
159
|
+
path,
|
|
160
|
+
message,
|
|
161
|
+
capability: fallbackCapability
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function recordPaintPlaceholders(placeholders, records, defaultPath, defaultId) {
|
|
165
|
+
if (records === void 0) return;
|
|
166
|
+
for (const item of records) {
|
|
167
|
+
const id = item.id ?? defaultId;
|
|
168
|
+
placeholders.push(Object.freeze({
|
|
169
|
+
...id === void 0 ? {} : { id },
|
|
170
|
+
path: item.path ?? defaultPath,
|
|
171
|
+
url: item.url
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, paintIdOffset = 0, recordNodes = true) {
|
|
176
|
+
const childrenSvg = layer.childComposition === "members" ? layer.memberLayers.map((child) => paintLayer(child, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, paintIdOffset, recordNodes)).join("") : layer.childComposition === "siblings" ? layer.siblingLayers.map((child) => paintLayer(child, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, paintIdOffset, recordNodes)).join("") : void 0;
|
|
76
177
|
if (layer.childComposition !== "leaf" && layer.emitsObject && !layer.hasObservation) return "";
|
|
77
178
|
const recordNodeIdentity = () => {
|
|
78
179
|
if (!recordNodes || !layer.hasObservation) return;
|
|
@@ -86,37 +187,34 @@ function paintLayer(layer, pageNumber, diagnostics, nodePaths, transforms, paint
|
|
|
86
187
|
objectId: layer.paintObjectId + paintIdOffset,
|
|
87
188
|
...layer.box === void 0 ? {} : { box: layer.box },
|
|
88
189
|
theme: layer.theme,
|
|
89
|
-
...childrenSvg === void 0 ? {} : { childrenSvg }
|
|
190
|
+
...childrenSvg === void 0 ? {} : { childrenSvg },
|
|
191
|
+
registerRasterResource: registerForHook(layer.path, layer.declarationType)
|
|
90
192
|
});
|
|
91
193
|
recordNodeIdentity();
|
|
92
|
-
|
|
93
|
-
severity: "warning",
|
|
94
|
-
page: pageNumber,
|
|
95
|
-
path: warning.path === void 0 ? layer.path : `${layer.path}/${warning.path}`,
|
|
96
|
-
message: warning.message
|
|
97
|
-
}));
|
|
194
|
+
recordPaintPlaceholders(placeholders, output.placeholders, layer.path, layer.authorId);
|
|
98
195
|
return output.svg;
|
|
99
196
|
} catch (error) {
|
|
100
197
|
recordNodeIdentity();
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
page: pageNumber,
|
|
104
|
-
path: error instanceof CapabilityError && error.path !== void 0 ? `${layer.path}/${error.path}` : layer.path,
|
|
105
|
-
message: error instanceof Error ? error.message : String(error)
|
|
106
|
-
}));
|
|
198
|
+
const errorPath = error instanceof CapabilityError && error.path !== void 0 ? `${layer.path}/${error.path}` : layer.path;
|
|
199
|
+
pendingOutcomes.push(toPreviewError(error, errorPath, layer.declarationType));
|
|
107
200
|
return "";
|
|
108
201
|
}
|
|
109
202
|
recordNodeIdentity();
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
page: pageNumber,
|
|
203
|
+
pendingOutcomes.push(Object.freeze({
|
|
204
|
+
code: "preview-unsupported-capability",
|
|
113
205
|
path: layer.path,
|
|
114
|
-
message: `Preview does not support ${layer.declarationType}
|
|
206
|
+
message: `Preview does not support ${layer.declarationType}`,
|
|
207
|
+
capability: layer.declarationType
|
|
115
208
|
}));
|
|
116
209
|
return "";
|
|
117
210
|
}
|
|
211
|
+
async function rasterize(svg) {
|
|
212
|
+
const { renderAsync } = await import("@resvg/resvg-js");
|
|
213
|
+
const image = await renderAsync(svg, { font: { loadSystemFonts: false } });
|
|
214
|
+
return new Uint8Array(image.asPng());
|
|
215
|
+
}
|
|
118
216
|
/** Paints static preview pages directly from a Resolution without running emit(). */
|
|
119
|
-
function paint(resolution, options = {}) {
|
|
217
|
+
async function paint(resolution, options = {}) {
|
|
120
218
|
const { pages: requestedPages, signal } = validatePaintOptions(options);
|
|
121
219
|
if (signal?.aborted) throw signal.reason;
|
|
122
220
|
const internal = getInternalResolution(resolution);
|
|
@@ -126,19 +224,40 @@ function paint(resolution, options = {}) {
|
|
|
126
224
|
for (const [index, slide] of internal.slides.entries()) {
|
|
127
225
|
const pageNumber = slide.index;
|
|
128
226
|
if (selected !== void 0 && !selected.has(pageNumber)) continue;
|
|
227
|
+
if (signal !== void 0 && pages.length > 0) await setImmediate();
|
|
228
|
+
signal?.throwIfAborted();
|
|
129
229
|
const slideObservation = resolution.report.slides[index];
|
|
130
230
|
if (slideObservation === void 0) throw new Error("Missing resolved slide observation for paint");
|
|
131
|
-
const
|
|
231
|
+
const pendingOutcomes = [];
|
|
232
|
+
const placeholders = [];
|
|
132
233
|
const nodePaths = /* @__PURE__ */ new Map();
|
|
133
234
|
const transforms = /* @__PURE__ */ new Map();
|
|
235
|
+
const rasterRegistry = createPageRasterRegistry(`shared-img-s${pageNumber}`);
|
|
236
|
+
let rasterCount = 0;
|
|
237
|
+
const registerForHook = (path, declaration) => {
|
|
238
|
+
const register = (resource, options) => {
|
|
239
|
+
if (options?.normalizeToPng !== true) return rasterRegistry.register(resource);
|
|
240
|
+
const token = `urn:pptxdk-pending-raster:${rasterCount++}`;
|
|
241
|
+
pendingOutcomes.push({
|
|
242
|
+
resource,
|
|
243
|
+
path: options.diagnostic?.path ?? path,
|
|
244
|
+
...options.diagnostic === void 0 ? {} : { field: options.diagnostic.field },
|
|
245
|
+
declaration,
|
|
246
|
+
hook: register,
|
|
247
|
+
token
|
|
248
|
+
});
|
|
249
|
+
return token;
|
|
250
|
+
};
|
|
251
|
+
return register;
|
|
252
|
+
};
|
|
134
253
|
const masterOffset = maxPaintObjectId(slide.layers) + 1e3;
|
|
135
254
|
const wrapSharedObjectSvg = (svg) => svg !== "" && internal.mastersCanvas !== void 0 ? internal.mastersCanvas.paintSharedObject(svg).svg : svg;
|
|
136
|
-
const masterLayerFragments = (slide.masterLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber,
|
|
255
|
+
const masterLayerFragments = (slide.masterLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, masterOffset, false)));
|
|
137
256
|
const masterLayersSvg = internal.mastersCanvas !== void 0 ? internal.mastersCanvas.paintMasterLayers(masterLayerFragments).svg : masterLayerFragments.join("");
|
|
138
257
|
const layoutOffset = masterOffset + maxPaintObjectId(slide.masterLayers ?? []) + 1e3;
|
|
139
|
-
const layoutLayerFragments = (slide.layoutLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber,
|
|
258
|
+
const layoutLayerFragments = (slide.layoutLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, layoutOffset, false)));
|
|
140
259
|
const layoutLayersSvg = internal.mastersCanvas !== void 0 ? internal.mastersCanvas.paintLayoutLayers(layoutLayerFragments).svg : layoutLayerFragments.join("");
|
|
141
|
-
const layers = slide.layers.map((layer) => paintLayer(layer, pageNumber,
|
|
260
|
+
const layers = slide.layers.map((layer) => paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook)).join("");
|
|
142
261
|
let background;
|
|
143
262
|
let shapeTreeCapSvg = "";
|
|
144
263
|
let hasExplicitSlideBackground = false;
|
|
@@ -150,29 +269,21 @@ function paint(resolution, options = {}) {
|
|
|
150
269
|
path: slideCap.path,
|
|
151
270
|
dimensions: internal.dimensions,
|
|
152
271
|
theme: slideCap.theme,
|
|
153
|
-
slideNumber: pageNumber
|
|
272
|
+
slideNumber: pageNumber,
|
|
273
|
+
registerRasterResource: registerForHook(slideCap.path, slideCap.declaration)
|
|
154
274
|
});
|
|
155
275
|
if (slideCap.slot === "background" && previewOutput.svg !== "") background = previewOutput.svg;
|
|
156
276
|
else if (slideCap.slot === "shape-tree" && previewOutput.svg !== "") shapeTreeCapSvg += previewOutput.svg;
|
|
157
|
-
|
|
158
|
-
severity: "warning",
|
|
159
|
-
page: pageNumber,
|
|
160
|
-
path: warning.path === void 0 ? slideCap.path : `${slideCap.path}/${warning.path}`,
|
|
161
|
-
message: warning.message
|
|
162
|
-
}));
|
|
277
|
+
recordPaintPlaceholders(placeholders, previewOutput.placeholders, slideCap.path, slide.authorId);
|
|
163
278
|
} catch (error) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
page: pageNumber,
|
|
167
|
-
path: error instanceof CapabilityError && error.path !== void 0 ? error.path : slideCap.path,
|
|
168
|
-
message: error instanceof Error ? error.message : String(error)
|
|
169
|
-
}));
|
|
279
|
+
const errorPath = error instanceof CapabilityError && error.path !== void 0 ? error.path : slideCap.path;
|
|
280
|
+
pendingOutcomes.push(toPreviewError(error, errorPath, slideCap.declaration));
|
|
170
281
|
}
|
|
171
|
-
else if (slideCap.slot === "background" && slideCap.hasSlideProps)
|
|
172
|
-
|
|
173
|
-
page: pageNumber,
|
|
282
|
+
else if (slideCap.slot === "background" && slideCap.hasSlideProps) pendingOutcomes.push(Object.freeze({
|
|
283
|
+
code: "preview-unsupported-capability",
|
|
174
284
|
path: slideCap.path,
|
|
175
|
-
message: `Preview does not support ${slideCap.declaration}
|
|
285
|
+
message: `Preview does not support ${slideCap.declaration}`,
|
|
286
|
+
capability: slideCap.declaration
|
|
176
287
|
}));
|
|
177
288
|
}
|
|
178
289
|
if (!hasExplicitSlideBackground && slide.inheritedBackground?.paint !== void 0) try {
|
|
@@ -180,39 +291,74 @@ function paint(resolution, options = {}) {
|
|
|
180
291
|
path: slide.inheritedBackground.path,
|
|
181
292
|
dimensions: internal.dimensions,
|
|
182
293
|
theme: slide.inheritedBackground.theme,
|
|
183
|
-
slideNumber: pageNumber
|
|
294
|
+
slideNumber: pageNumber,
|
|
295
|
+
registerRasterResource: registerForHook(slide.inheritedBackground.path, slide.inheritedBackground.declaration)
|
|
184
296
|
});
|
|
185
297
|
if (inheritedOutput.svg !== "") background = inheritedOutput.svg;
|
|
298
|
+
recordPaintPlaceholders(placeholders, inheritedOutput.placeholders, slide.inheritedBackground.path);
|
|
186
299
|
} catch (error) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
page: pageNumber,
|
|
190
|
-
path: error instanceof CapabilityError && error.path !== void 0 ? error.path : slide.inheritedBackground.path,
|
|
191
|
-
message: error instanceof Error ? error.message : String(error)
|
|
192
|
-
}));
|
|
300
|
+
const errorPath = error instanceof CapabilityError && error.path !== void 0 ? error.path : slide.inheritedBackground.path;
|
|
301
|
+
pendingOutcomes.push(toPreviewError(error, errorPath, slide.inheritedBackground.declaration));
|
|
193
302
|
}
|
|
194
303
|
const nodes = [];
|
|
195
304
|
const collect = (objects, ancestors = []) => {
|
|
196
305
|
for (const object of objects) {
|
|
306
|
+
if (object.audio?.hideDuringShow === true) continue;
|
|
197
307
|
const own = transforms.get(object.id);
|
|
198
308
|
const chain = own === void 0 ? ancestors : [own, ...ancestors];
|
|
309
|
+
const screen = object.box === void 0 ? void 0 : screenGeometry(object.box, chain);
|
|
199
310
|
nodes.push(Object.freeze({
|
|
200
311
|
...object,
|
|
201
|
-
...
|
|
202
|
-
|
|
312
|
+
...screen === void 0 ? {} : {
|
|
313
|
+
corners: screen.corners,
|
|
314
|
+
bounds: screen.screenBox
|
|
315
|
+
},
|
|
316
|
+
path: nodePaths.get(object.id) ?? object.path
|
|
203
317
|
}));
|
|
204
318
|
if (object.members !== void 0) collect(object.members, chain);
|
|
205
319
|
}
|
|
206
320
|
};
|
|
207
321
|
collect(slideObservation.objects);
|
|
208
|
-
const
|
|
209
|
-
|
|
322
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
323
|
+
const pageErrors = [];
|
|
324
|
+
const failedHooks = /* @__PURE__ */ new Set();
|
|
325
|
+
let decoders;
|
|
326
|
+
if (rasterCount > 0) try {
|
|
327
|
+
decoders = await loadImageDecoders();
|
|
328
|
+
} finally {
|
|
329
|
+
signal?.throwIfAborted();
|
|
330
|
+
}
|
|
331
|
+
for (const entry of pendingOutcomes) {
|
|
332
|
+
if (!("resource" in entry)) {
|
|
333
|
+
pageErrors.push(entry);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (failedHooks.has(entry.hook)) continue;
|
|
337
|
+
try {
|
|
338
|
+
const bytes = decodeImageToPngBytes(entry.resource, decoders);
|
|
339
|
+
tokens.set(entry.token, rasterRegistry.register({
|
|
340
|
+
bytes,
|
|
341
|
+
contentType: "image/png"
|
|
342
|
+
}));
|
|
343
|
+
} catch (error) {
|
|
344
|
+
failedHooks.add(entry.hook);
|
|
345
|
+
const issue = toPreviewError(error, entry.path, entry.declaration);
|
|
346
|
+
pageErrors.push(Object.freeze({
|
|
347
|
+
...issue,
|
|
348
|
+
...entry.field === void 0 ? {} : { field: entry.field }
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
Object.freeze(pageErrors);
|
|
353
|
+
const pagePlaceholders = Object.freeze([...placeholders]);
|
|
354
|
+
if (pageErrors.length > 0) {
|
|
210
355
|
pages.push(Object.freeze({
|
|
211
356
|
id: slide.id,
|
|
212
357
|
page: pageNumber,
|
|
213
358
|
nodes: Object.freeze(nodes),
|
|
214
359
|
layouts: slideObservation.layouts ?? Object.freeze([]),
|
|
215
|
-
|
|
360
|
+
errors: pageErrors,
|
|
361
|
+
placeholders: pagePlaceholders
|
|
216
362
|
}));
|
|
217
363
|
continue;
|
|
218
364
|
}
|
|
@@ -222,9 +368,14 @@ function paint(resolution, options = {}) {
|
|
|
222
368
|
...slide.effectiveColorMapOverride === void 0 ? {} : { colorMapOverride: slide.effectiveColorMapOverride },
|
|
223
369
|
...slide.effectiveThemeOverride === void 0 ? {} : { themeOverride: slide.effectiveThemeOverride }
|
|
224
370
|
}).svg : defaultCanvasBackground;
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
|
|
371
|
+
const rawSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="${internal.dimensions.width}" height="${internal.dimensions.height}" viewBox="0 0 ${internal.dimensions.width} ${internal.dimensions.height}">${background ?? fallbackBackground}${masterLayersSvg}${layoutLayersSvg}${shapeTreeCapSvg}${layers}</svg>`;
|
|
372
|
+
const svg = sanitizeSvgForRasterization(rawSvg, internal.dimensions, rasterRegistry, tokens);
|
|
373
|
+
let png;
|
|
374
|
+
try {
|
|
375
|
+
png = await rasterize(svg);
|
|
376
|
+
} finally {
|
|
377
|
+
signal?.throwIfAborted();
|
|
378
|
+
}
|
|
228
379
|
pages.push(Object.freeze({
|
|
229
380
|
id: slide.id,
|
|
230
381
|
page: pageNumber,
|
|
@@ -232,9 +383,10 @@ function paint(resolution, options = {}) {
|
|
|
232
383
|
png,
|
|
233
384
|
nodes: Object.freeze(nodes),
|
|
234
385
|
layouts: slideObservation.layouts ?? Object.freeze([]),
|
|
235
|
-
|
|
386
|
+
errors: pageErrors,
|
|
387
|
+
placeholders: pagePlaceholders
|
|
236
388
|
}));
|
|
237
389
|
}
|
|
238
390
|
return Object.freeze({ pages: Object.freeze(pages) });
|
|
239
391
|
}
|
|
240
|
-
export { PreviewPageRangeError, paint, paintOptionsSchema,
|
|
392
|
+
export { PreviewPageRangeError, paint, paintOptionsSchema, previewErrorSchema, previewOptionsSchema, previewPageNumberSchema, previewPagesSchema, previewPlaceholderSchema, screenGeometry, screenGeometrySchema, screenPointSchema, validatePaintOptions };
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
+
import { PreviewPageRangeError, previewErrorSchema, previewPlaceholderSchema, resolveOptionsShape } from "../../core/dist/kernel/stage-options.js";
|
|
2
|
+
import "../../core/dist/kernel/index.js";
|
|
1
3
|
import { z } from "zod";
|
|
2
4
|
// ../preview/dist/options.js
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
5
|
+
const rawPreviewPageNumberSchema = z.int().positive();
|
|
6
|
+
const previewPageNumberSchema = rawPreviewPageNumberSchema;
|
|
7
|
+
const rawPreviewPagesSchema = z.array(rawPreviewPageNumberSchema).readonly();
|
|
8
|
+
const previewPagesSchema = rawPreviewPagesSchema;
|
|
9
|
+
const paintOptionsShape = {
|
|
6
10
|
/** 1-based page numbers to paint. Omit to draw all pages; an empty list draws none. */
|
|
7
|
-
pages:
|
|
11
|
+
pages: rawPreviewPagesSchema.optional(),
|
|
8
12
|
signal: z.instanceof(AbortSignal).optional()
|
|
13
|
+
};
|
|
14
|
+
const paintOptionsSchema = z.strictObject(paintOptionsShape).readonly();
|
|
15
|
+
const previewOptionsSchema = z.strictObject({
|
|
16
|
+
...paintOptionsShape,
|
|
17
|
+
referenceDate: resolveOptionsShape.referenceDate
|
|
9
18
|
}).readonly();
|
|
10
|
-
const
|
|
11
|
-
const previewSeveritySchema = z.enum(["error", "warning"]);
|
|
12
|
-
const previewDiagnosticSchema = z.object({
|
|
13
|
-
severity: previewSeveritySchema,
|
|
14
|
-
page: previewPageNumberSchema,
|
|
15
|
-
path: z.string(),
|
|
16
|
-
message: z.string()
|
|
17
|
-
}).readonly();
|
|
18
|
-
const screenPointSchema = z.object({
|
|
19
|
+
const rawScreenPointSchema = z.object({
|
|
19
20
|
x: z.number(),
|
|
20
21
|
y: z.number()
|
|
21
22
|
}).readonly();
|
|
23
|
+
const screenPointSchema = rawScreenPointSchema;
|
|
22
24
|
const screenGeometrySchema = z.object({
|
|
23
|
-
corners: z.array(
|
|
25
|
+
corners: z.array(rawScreenPointSchema).readonly(),
|
|
24
26
|
screenBox: z.object({
|
|
25
27
|
x: z.number(),
|
|
26
28
|
y: z.number(),
|
|
@@ -28,17 +30,6 @@ const screenGeometrySchema = z.object({
|
|
|
28
30
|
height: z.number()
|
|
29
31
|
}).readonly()
|
|
30
32
|
}).readonly();
|
|
31
|
-
/** Error thrown when requested preview page numbers exceed the resolved deck slide count. */
|
|
32
|
-
var PreviewPageRangeError = class extends RangeError {
|
|
33
|
-
requestedPages;
|
|
34
|
-
totalSlides;
|
|
35
|
-
constructor(requestedPages, totalSlides) {
|
|
36
|
-
super("Preview page number is outside the document");
|
|
37
|
-
this.name = "PreviewPageRangeError";
|
|
38
|
-
this.requestedPages = Object.freeze([...requestedPages]);
|
|
39
|
-
this.totalSlides = totalSlides;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
33
|
/** Validates paint/preview options (`pages`, `signal`) via shared pure-data schemas. */
|
|
43
34
|
function validatePaintOptions(options = {}) {
|
|
44
35
|
const parsed = paintOptionsSchema.safeParse(options);
|
|
@@ -50,4 +41,4 @@ function validatePaintOptions(options = {}) {
|
|
|
50
41
|
if (issue.path.length === 0 && issue.code === "unrecognized_keys") throw new TypeError(`Preview options contain unknown parameter ${issue.keys[0]}`);
|
|
51
42
|
throw new TypeError("Preview options must be an object");
|
|
52
43
|
}
|
|
53
|
-
export { PreviewPageRangeError, paintOptionsSchema,
|
|
44
|
+
export { PreviewPageRangeError, paintOptionsSchema, previewErrorSchema, previewOptionsSchema, previewPageNumberSchema, previewPagesSchema, previewPlaceholderSchema, screenGeometrySchema, screenPointSchema, validatePaintOptions };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { CapabilityError } from "../../core/dist/kernel/diagnostics.js";
|
|
2
|
+
import { isImmutableBytes, markImmutableBytes } from "../../core/dist/kernel/font-seal.js";
|
|
3
|
+
import "../../core/dist/kernel/index.js";
|
|
4
|
+
import { decodeGifFirstFrame } from "./gif-decoder.js";
|
|
5
|
+
// ../preview/dist/raster.js
|
|
6
|
+
const rasterFormat = {
|
|
7
|
+
"image/png": "png",
|
|
8
|
+
"image/jpeg": "jpeg",
|
|
9
|
+
"image/gif": "gif"
|
|
10
|
+
};
|
|
11
|
+
let loadingDecoders;
|
|
12
|
+
/** Loads the pixel decoders on demand for embedded images that need normalization. */
|
|
13
|
+
function loadImageDecoders() {
|
|
14
|
+
loadingDecoders ??= Promise.all([import("pngjs"), import("jpeg-js")]).then(([png, jpeg]) => ({
|
|
15
|
+
png,
|
|
16
|
+
jpeg
|
|
17
|
+
}));
|
|
18
|
+
return loadingDecoders;
|
|
19
|
+
}
|
|
20
|
+
const normalizedPngByImmutableBytes = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
/**
|
|
22
|
+
* Decodes PNG, JPEG, or static first-frame GIF bytes into normalized PNG bytes for SVG embedding.
|
|
23
|
+
* Throws `preview-corrupt-image` if compressed pixel data is invalid.
|
|
24
|
+
*/
|
|
25
|
+
function decodeImageToPngBytes(image, decoders) {
|
|
26
|
+
const format = rasterFormat[image.contentType];
|
|
27
|
+
const immutableSource = isImmutableBytes(image.bytes);
|
|
28
|
+
if (immutableSource) {
|
|
29
|
+
const cached = normalizedPngByImmutableBytes.get(image.bytes);
|
|
30
|
+
if (cached?.contentType === image.contentType) return cached.pngBytes;
|
|
31
|
+
}
|
|
32
|
+
const { png: pngModule, jpeg: jpegModule } = decoders;
|
|
33
|
+
let decoded;
|
|
34
|
+
try {
|
|
35
|
+
switch (format) {
|
|
36
|
+
case "png":
|
|
37
|
+
decoded = pngModule.PNG.sync.read(Buffer.from(image.bytes));
|
|
38
|
+
break;
|
|
39
|
+
case "jpeg":
|
|
40
|
+
decoded = jpegModule.decode(image.bytes, { tolerantDecoding: false });
|
|
41
|
+
break;
|
|
42
|
+
case "gif":
|
|
43
|
+
decoded = decodeGifFirstFrame(image.bytes);
|
|
44
|
+
break;
|
|
45
|
+
default: return format;
|
|
46
|
+
}
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error instanceof CapabilityError) throw new CapabilityError(error.code, error.message, error.path, error.details ?? { format });
|
|
49
|
+
throw new CapabilityError("preview-corrupt-image", error instanceof Error ? `Failed to decode ${format.toUpperCase()} image for preview: ${error.message}` : `Failed to decode ${format.toUpperCase()} image for preview`, void 0, { format });
|
|
50
|
+
}
|
|
51
|
+
const normalized = new pngModule.PNG({
|
|
52
|
+
width: decoded.width,
|
|
53
|
+
height: decoded.height
|
|
54
|
+
});
|
|
55
|
+
normalized.data = Buffer.from(decoded.data);
|
|
56
|
+
const pngBytes = new Uint8Array(pngModule.PNG.sync.write(normalized));
|
|
57
|
+
if (immutableSource) {
|
|
58
|
+
markImmutableBytes(pngBytes);
|
|
59
|
+
normalizedPngByImmutableBytes.set(image.bytes, {
|
|
60
|
+
contentType: image.contentType,
|
|
61
|
+
pngBytes
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return pngBytes;
|
|
65
|
+
}
|
|
66
|
+
export { decodeImageToPngBytes, loadImageDecoders };
|