@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,805 @@
|
|
|
1
|
+
import { defaultTheme, defineTheme, isFont, isTheme } from "../../../kernel/theme.js";
|
|
2
|
+
import { masterTextStyleCategoryForRole, matchMasterPlaceholderSpec } from "../../../kernel/placeholders.js";
|
|
3
|
+
import { isInlineRichTextNodeType } from "../text-schemas.js";
|
|
4
|
+
import "../../../kernel/capability.js";
|
|
5
|
+
import { P_NS } from "../../../kernel/pptx-read/namespaces.js";
|
|
6
|
+
import { readEmbeddedFontList, readPresentationThemeFontScheme, unpackEotFontData } from "../../../kernel/pptx-read/fonts.js";
|
|
7
|
+
import { CommonNode } from "../../../kernel/document.js";
|
|
8
|
+
import "../../../kernel/pptx-read/index.js";
|
|
9
|
+
import { fontFamilyKey, inspectImportedEmbeddedFont } from "./font-engine.js";
|
|
10
|
+
import { font } from "./font.js";
|
|
11
|
+
// ../core/dist/capabilities/shared/font/font-import.js
|
|
12
|
+
const reservedThemeFontPattern = /^(?:major|minor|\+(?:mj|mn)-)/iu;
|
|
13
|
+
function isPlainRecord(value) {
|
|
14
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15
|
+
}
|
|
16
|
+
function fallbackWeightForSlot(slot) {
|
|
17
|
+
return slot === "bold" || slot === "boldItalic" ? 700 : 400;
|
|
18
|
+
}
|
|
19
|
+
function fallbackStyleForSlot(slot) {
|
|
20
|
+
return slot === "italic" || slot === "boldItalic" ? "italic" : "normal";
|
|
21
|
+
}
|
|
22
|
+
function isBoldWeight(weight) {
|
|
23
|
+
if (weight === "bold") return true;
|
|
24
|
+
if (weight === "normal") return false;
|
|
25
|
+
if (typeof weight === "number") return weight >= 600;
|
|
26
|
+
}
|
|
27
|
+
function numericWeightOrUndefined(weight) {
|
|
28
|
+
if (weight === "normal") return 400;
|
|
29
|
+
if (weight === "bold") return 700;
|
|
30
|
+
if (typeof weight === "number") return weight;
|
|
31
|
+
}
|
|
32
|
+
function isItalicFontStyle(style) {
|
|
33
|
+
if (style === "italic") return true;
|
|
34
|
+
if (style === "normal") return false;
|
|
35
|
+
}
|
|
36
|
+
function slotForBoldItalic(bold, italic) {
|
|
37
|
+
if (bold) return italic ? "boldItalic" : "bold";
|
|
38
|
+
return italic ? "italic" : "regular";
|
|
39
|
+
}
|
|
40
|
+
function upgradeFontToken(family, fontsByKey) {
|
|
41
|
+
if (typeof family !== "string" || family === "major" || family === "minor") return;
|
|
42
|
+
return fontsByKey.get(fontFamilyKey(family));
|
|
43
|
+
}
|
|
44
|
+
function resolveEffectiveFamilyKey(fontFamily, themeFonts, script = "latin") {
|
|
45
|
+
if (isFont(fontFamily)) return fontFamilyKey(fontFamily.family);
|
|
46
|
+
if (typeof fontFamily !== "string" || fontFamily.trim() === "") return;
|
|
47
|
+
if (fontFamily === "major" || fontFamily === "minor") {
|
|
48
|
+
const mapped = script === "ea" ? themeFonts[fontFamily === "major" ? "majorEastAsian" : "minorEastAsian"] ?? themeFonts[fontFamily] : themeFonts[fontFamily];
|
|
49
|
+
if (isFont(mapped)) return fontFamilyKey(mapped.family);
|
|
50
|
+
if (typeof mapped === "string" && mapped.trim() !== "") return fontFamilyKey(mapped);
|
|
51
|
+
}
|
|
52
|
+
return fontFamilyKey(fontFamily);
|
|
53
|
+
}
|
|
54
|
+
function applyStyleContextOnly(inherited, style) {
|
|
55
|
+
if (!isPlainRecord(style)) return inherited;
|
|
56
|
+
const nextFontFamily = style["fontFamily"] !== void 0 ? style["fontFamily"] : inherited.fontFamily;
|
|
57
|
+
const nextEaFontFamily = style["eastAsianFontFamily"] !== void 0 ? style["eastAsianFontFamily"] : inherited.eastAsianFontFamily;
|
|
58
|
+
const nextBold = isBoldWeight(style["fontWeight"]) ?? inherited.bold;
|
|
59
|
+
const nextItalic = isItalicFontStyle(style["fontStyle"]) ?? inherited.italic;
|
|
60
|
+
const nextWeight = numericWeightOrUndefined(style["fontWeight"]) ?? inherited.effectiveWeight;
|
|
61
|
+
return {
|
|
62
|
+
themeFonts: inherited.themeFonts,
|
|
63
|
+
fontFamily: nextFontFamily,
|
|
64
|
+
eastAsianFontFamily: nextEaFontFamily,
|
|
65
|
+
bold: nextBold,
|
|
66
|
+
italic: nextItalic,
|
|
67
|
+
effectiveWeight: nextWeight
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function foldStyleLayers(base, layers) {
|
|
71
|
+
let current = base;
|
|
72
|
+
for (const layer of layers) current = applyStyleContextOnly(current, layer);
|
|
73
|
+
return current;
|
|
74
|
+
}
|
|
75
|
+
function upgradeStyleRecordFontAndWeight(style, inherited, lookup, options) {
|
|
76
|
+
if (!isPlainRecord(style)) {
|
|
77
|
+
if (options?.backfillInheritedLeaf === true) {
|
|
78
|
+
const familyKey = resolveEffectiveFamilyKey(inherited.fontFamily, inherited.themeFonts);
|
|
79
|
+
const slot = slotForBoldItalic(inherited.bold, inherited.italic);
|
|
80
|
+
const slotWeight = familyKey === void 0 ? void 0 : lookup.slotWeightsByKey.get(familyKey)?.[slot];
|
|
81
|
+
if (slotWeight !== void 0 && slotWeight !== inherited.effectiveWeight) return {
|
|
82
|
+
changed: true,
|
|
83
|
+
value: { fontWeight: slotWeight },
|
|
84
|
+
nextContext: {
|
|
85
|
+
...inherited,
|
|
86
|
+
effectiveWeight: slotWeight
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
changed: false,
|
|
92
|
+
nextContext: inherited
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
const matched = upgradeFontToken(style["fontFamily"], lookup.fontsByKey);
|
|
96
|
+
const matchedEa = upgradeFontToken(style["eastAsianFontFamily"], lookup.fontsByKey);
|
|
97
|
+
const nextRec = {
|
|
98
|
+
...style,
|
|
99
|
+
...matched === void 0 ? {} : { fontFamily: matched },
|
|
100
|
+
...matchedEa === void 0 ? {} : { eastAsianFontFamily: matchedEa }
|
|
101
|
+
};
|
|
102
|
+
let changed = matched !== void 0 || matchedEa !== void 0;
|
|
103
|
+
const hasLocalFontFamily = style["fontFamily"] !== void 0;
|
|
104
|
+
const hasLocalEaFontFamily = style["eastAsianFontFamily"] !== void 0;
|
|
105
|
+
const hasLocalFontWeight = style["fontWeight"] !== void 0;
|
|
106
|
+
const hasLocalFontStyle = style["fontStyle"] !== void 0;
|
|
107
|
+
const hasAnyLocalFontDecl = hasLocalFontFamily || hasLocalEaFontFamily || hasLocalFontWeight || hasLocalFontStyle;
|
|
108
|
+
const nextFontFamily = hasLocalFontFamily ? nextRec["fontFamily"] : inherited.fontFamily;
|
|
109
|
+
const nextEaFontFamily = hasLocalEaFontFamily ? nextRec["eastAsianFontFamily"] : inherited.eastAsianFontFamily;
|
|
110
|
+
const nextBold = isBoldWeight(style["fontWeight"]) ?? inherited.bold;
|
|
111
|
+
const nextItalic = isItalicFontStyle(style["fontStyle"]) ?? inherited.italic;
|
|
112
|
+
const currentEffectiveWeight = numericWeightOrUndefined(style["fontWeight"]) ?? inherited.effectiveWeight;
|
|
113
|
+
const familyKey = hasLocalEaFontFamily && !hasLocalFontFamily ? resolveEffectiveFamilyKey(nextEaFontFamily, inherited.themeFonts, "ea") ?? resolveEffectiveFamilyKey(nextFontFamily, inherited.themeFonts) : resolveEffectiveFamilyKey(nextFontFamily, inherited.themeFonts);
|
|
114
|
+
const slot = slotForBoldItalic(nextBold, nextItalic);
|
|
115
|
+
const slotWeights = familyKey === void 0 ? void 0 : lookup.slotWeightsByKey.get(familyKey);
|
|
116
|
+
let slotWeight = slotWeights?.[slot];
|
|
117
|
+
if (slotWeight === void 0 && nextBold && slotWeights !== void 0) {
|
|
118
|
+
const candidate = slotWeights[nextItalic ? "italic" : "regular"];
|
|
119
|
+
if (candidate !== void 0 && candidate >= 600) slotWeight = candidate;
|
|
120
|
+
}
|
|
121
|
+
let nextEffectiveWeight = currentEffectiveWeight;
|
|
122
|
+
if (slotWeight !== void 0 && slotWeight !== currentEffectiveWeight && (hasAnyLocalFontDecl || options?.backfillInheritedLeaf === true)) {
|
|
123
|
+
nextRec["fontWeight"] = slotWeight;
|
|
124
|
+
changed = true;
|
|
125
|
+
nextEffectiveWeight = slotWeight;
|
|
126
|
+
}
|
|
127
|
+
const nextContext = {
|
|
128
|
+
themeFonts: inherited.themeFonts,
|
|
129
|
+
fontFamily: nextFontFamily,
|
|
130
|
+
eastAsianFontFamily: nextEaFontFamily,
|
|
131
|
+
bold: nextBold,
|
|
132
|
+
italic: nextItalic,
|
|
133
|
+
effectiveWeight: nextEffectiveWeight
|
|
134
|
+
};
|
|
135
|
+
return changed ? {
|
|
136
|
+
changed: true,
|
|
137
|
+
value: nextRec,
|
|
138
|
+
nextContext
|
|
139
|
+
} : {
|
|
140
|
+
changed: false,
|
|
141
|
+
nextContext
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function hasUnstyledTextLeaf(node) {
|
|
145
|
+
if (isInlineRichTextNodeType(node.type)) return true;
|
|
146
|
+
if (node.type === "text" || node.type === "cell" || node.type === "notes" || node.type === "paragraph") return node.children.length === 0 || node.children.some((child) => !(child instanceof CommonNode));
|
|
147
|
+
if (node.type === "shape") return node.children.some((child) => !(child instanceof CommonNode));
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
function upgradePlaceholderListStylesFont(listStyles, contextForLevel, lookup) {
|
|
151
|
+
if (listStyles === void 0) return {
|
|
152
|
+
value: void 0,
|
|
153
|
+
changed: false
|
|
154
|
+
};
|
|
155
|
+
let changed = false;
|
|
156
|
+
const next = {};
|
|
157
|
+
for (const [levelKey, levelStyle] of Object.entries(listStyles)) {
|
|
158
|
+
if (levelStyle === void 0) continue;
|
|
159
|
+
const levelNum = Number(levelKey);
|
|
160
|
+
const upgraded = upgradeStyleRecordFontAndWeight(levelStyle, contextForLevel(Number.isInteger(levelNum) && levelNum >= 1 ? levelNum : 1), lookup);
|
|
161
|
+
if (upgraded.changed && upgraded.value !== void 0) {
|
|
162
|
+
next[levelKey] = upgraded.value;
|
|
163
|
+
changed = true;
|
|
164
|
+
} else next[levelKey] = levelStyle;
|
|
165
|
+
}
|
|
166
|
+
return changed ? {
|
|
167
|
+
value: next,
|
|
168
|
+
changed: true
|
|
169
|
+
} : {
|
|
170
|
+
value: listStyles,
|
|
171
|
+
changed: false
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function upgradePlaceholdersFont(placeholders, baseContext, masterTextStyles, masterPlaceholders, lookup) {
|
|
175
|
+
if (placeholders === void 0) return {
|
|
176
|
+
value: void 0,
|
|
177
|
+
changed: false
|
|
178
|
+
};
|
|
179
|
+
let changed = false;
|
|
180
|
+
const next = {};
|
|
181
|
+
for (const [key, spec] of Object.entries(placeholders)) {
|
|
182
|
+
const isFooterRole = spec.type === "dt" || spec.type === "ftr" || spec.type === "sldNum";
|
|
183
|
+
const category = masterTextStyleCategoryForRole(spec.type);
|
|
184
|
+
const masterTx = isFooterRole ? void 0 : masterTextStyles?.[category];
|
|
185
|
+
const masterPh = masterPlaceholders === void 0 ? void 0 : matchMasterPlaceholderSpec(masterPlaceholders, spec.type);
|
|
186
|
+
const styleInherited = foldStyleLayers(baseContext, [
|
|
187
|
+
masterTx?.[1],
|
|
188
|
+
masterPh?.style,
|
|
189
|
+
masterPh?.listStyles?.[1]
|
|
190
|
+
]);
|
|
191
|
+
const styleUp = upgradeStyleRecordFontAndWeight(spec.style, styleInherited, lookup);
|
|
192
|
+
const effectiveSpecStyle = styleUp.changed ? styleUp.value : spec.style;
|
|
193
|
+
const listUp = upgradePlaceholderListStylesFont(spec.listStyles, (levelNum) => {
|
|
194
|
+
const key1to9 = Math.min(9, Math.max(1, levelNum));
|
|
195
|
+
return foldStyleLayers(baseContext, [
|
|
196
|
+
masterTx?.[key1to9],
|
|
197
|
+
masterPh?.style,
|
|
198
|
+
masterPh?.listStyles?.[key1to9],
|
|
199
|
+
effectiveSpecStyle
|
|
200
|
+
]);
|
|
201
|
+
}, lookup);
|
|
202
|
+
if (styleUp.changed || listUp.changed) {
|
|
203
|
+
changed = true;
|
|
204
|
+
next[key] = {
|
|
205
|
+
...spec,
|
|
206
|
+
...styleUp.changed && styleUp.value !== void 0 ? { style: styleUp.value } : {},
|
|
207
|
+
...listUp.changed && listUp.value !== void 0 ? { listStyles: listUp.value } : {}
|
|
208
|
+
};
|
|
209
|
+
} else next[key] = spec;
|
|
210
|
+
}
|
|
211
|
+
return changed ? {
|
|
212
|
+
value: next,
|
|
213
|
+
changed: true
|
|
214
|
+
} : {
|
|
215
|
+
value: placeholders,
|
|
216
|
+
changed: false
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
function upgradeFooterPlaceholdersRecord(rawFooterPlaceholders, baseContext, inheritedFooterPlaceholders, lookup) {
|
|
220
|
+
if (!isPlainRecord(rawFooterPlaceholders)) return { changed: false };
|
|
221
|
+
let changed = false;
|
|
222
|
+
const nextPlaceholders = { ...rawFooterPlaceholders };
|
|
223
|
+
for (const [slot, spec] of Object.entries(nextPlaceholders)) {
|
|
224
|
+
if (!isPlainRecord(spec)) continue;
|
|
225
|
+
const inheritedSpec = inheritedFooterPlaceholders?.[slot];
|
|
226
|
+
const inheritedContext = isPlainRecord(inheritedSpec) ? applyStyleContextOnly(baseContext, inheritedSpec["style"]) : baseContext;
|
|
227
|
+
const nextStyle = upgradeStyleRecordFontAndWeight(spec["style"], inheritedContext, lookup);
|
|
228
|
+
if (nextStyle.changed && nextStyle.value !== void 0) {
|
|
229
|
+
nextPlaceholders[slot] = {
|
|
230
|
+
...spec,
|
|
231
|
+
style: nextStyle.value
|
|
232
|
+
};
|
|
233
|
+
changed = true;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return changed ? {
|
|
237
|
+
value: nextPlaceholders,
|
|
238
|
+
changed: true
|
|
239
|
+
} : {
|
|
240
|
+
value: rawFooterPlaceholders,
|
|
241
|
+
changed: false
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function upgradeThemeFontMap(fonts, fontsByKey) {
|
|
245
|
+
if (fonts === void 0) return { changed: false };
|
|
246
|
+
const nextFonts = {};
|
|
247
|
+
let changed = false;
|
|
248
|
+
for (const slot of [
|
|
249
|
+
"major",
|
|
250
|
+
"minor",
|
|
251
|
+
"majorEastAsian",
|
|
252
|
+
"minorEastAsian"
|
|
253
|
+
]) {
|
|
254
|
+
const token = fonts[slot];
|
|
255
|
+
if (token === void 0) continue;
|
|
256
|
+
if (typeof token === "string") {
|
|
257
|
+
const matched = fontsByKey.get(fontFamilyKey(token));
|
|
258
|
+
if (matched !== void 0) {
|
|
259
|
+
nextFonts[slot] = matched;
|
|
260
|
+
changed = true;
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
nextFonts[slot] = token;
|
|
264
|
+
} else if (isFont(token)) nextFonts[slot] = token;
|
|
265
|
+
}
|
|
266
|
+
return changed ? {
|
|
267
|
+
fonts: nextFonts,
|
|
268
|
+
changed: true
|
|
269
|
+
} : { changed: false };
|
|
270
|
+
}
|
|
271
|
+
function extractThemeFonts(themeValue) {
|
|
272
|
+
if (isTheme(themeValue)) return themeValue.fonts;
|
|
273
|
+
if (isPlainRecord(themeValue) && isPlainRecord(themeValue["fonts"])) return themeValue["fonts"];
|
|
274
|
+
return {};
|
|
275
|
+
}
|
|
276
|
+
function upgradeThemeOverrideOnNode(node, fontsByKey) {
|
|
277
|
+
const rawOverride = node.props["themeOverride"];
|
|
278
|
+
if (!isPlainRecord(rawOverride)) return void 0;
|
|
279
|
+
const rawFonts = isPlainRecord(rawOverride["fonts"]) ? rawOverride["fonts"] : void 0;
|
|
280
|
+
const upgraded = upgradeThemeFontMap(rawFonts, fontsByKey);
|
|
281
|
+
if (upgraded.changed && upgraded.fonts !== void 0) {
|
|
282
|
+
node.set({ themeOverride: {
|
|
283
|
+
...rawOverride,
|
|
284
|
+
fonts: upgraded.fonts
|
|
285
|
+
} });
|
|
286
|
+
return upgraded.fonts;
|
|
287
|
+
}
|
|
288
|
+
return rawFonts;
|
|
289
|
+
}
|
|
290
|
+
function upgradeChartTextStyleContainer(container, inherited, lookup) {
|
|
291
|
+
if (!isPlainRecord(container)) return {
|
|
292
|
+
changed: false,
|
|
293
|
+
nextContext: inherited
|
|
294
|
+
};
|
|
295
|
+
const styleUp = upgradeStyleRecordFontAndWeight(container["style"], inherited, lookup);
|
|
296
|
+
if (!styleUp.changed || styleUp.value === void 0) return {
|
|
297
|
+
changed: false,
|
|
298
|
+
nextContext: styleUp.nextContext
|
|
299
|
+
};
|
|
300
|
+
return {
|
|
301
|
+
changed: true,
|
|
302
|
+
value: {
|
|
303
|
+
...container,
|
|
304
|
+
style: styleUp.value
|
|
305
|
+
},
|
|
306
|
+
nextContext: styleUp.nextContext
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
function upgradeChartSeriesFonts(series, inherited, lookup) {
|
|
310
|
+
if (!isPlainRecord(series)) return series;
|
|
311
|
+
const labels = upgradeChartTextStyleContainer(series["dataLabels"], inherited, lookup);
|
|
312
|
+
const patch = {};
|
|
313
|
+
if (labels.changed) patch["dataLabels"] = labels.value;
|
|
314
|
+
const rawPoints = series["points"];
|
|
315
|
+
if (isPlainRecord(rawPoints)) {
|
|
316
|
+
const changedPoints = {};
|
|
317
|
+
for (const [index, point] of Object.entries(rawPoints)) {
|
|
318
|
+
if (!isPlainRecord(point)) continue;
|
|
319
|
+
const pointLabels = upgradeChartTextStyleContainer(point["dataLabels"], labels.nextContext, lookup);
|
|
320
|
+
if (pointLabels.changed) changedPoints[index] = {
|
|
321
|
+
...point,
|
|
322
|
+
dataLabels: pointLabels.value
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
if (Object.keys(changedPoints).length > 0) patch["points"] = {
|
|
326
|
+
...rawPoints,
|
|
327
|
+
...changedPoints
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
return Object.keys(patch).length === 0 ? series : {
|
|
331
|
+
...series,
|
|
332
|
+
...patch
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
function upgradeChartPropsFonts(node, chartContext, lookup) {
|
|
336
|
+
const patch = {};
|
|
337
|
+
const legendUp = upgradeStyleRecordFontAndWeight(node.props["legendStyle"], chartContext, lookup);
|
|
338
|
+
if (legendUp.changed && legendUp.value !== void 0) patch["legendStyle"] = legendUp.value;
|
|
339
|
+
const titleUp = upgradeChartTextStyleContainer(node.props["title"], chartContext, lookup);
|
|
340
|
+
if (titleUp.changed && titleUp.value !== void 0) patch["title"] = titleUp.value;
|
|
341
|
+
const rawAxes = node.props["axes"];
|
|
342
|
+
if (isPlainRecord(rawAxes)) {
|
|
343
|
+
let axesChanged = false;
|
|
344
|
+
const nextAxes = { ...rawAxes };
|
|
345
|
+
for (const [axisKey, rawAxis] of Object.entries(rawAxes)) {
|
|
346
|
+
if (!isPlainRecord(rawAxis)) continue;
|
|
347
|
+
const axisUp = upgradeChartTextStyleContainer(rawAxis, chartContext, lookup);
|
|
348
|
+
let nextAxis = axisUp.changed && axisUp.value !== void 0 ? { ...axisUp.value } : { ...rawAxis };
|
|
349
|
+
let axisModified = axisUp.changed;
|
|
350
|
+
const axisTitleUp = upgradeChartTextStyleContainer(nextAxis["title"], axisUp.nextContext, lookup);
|
|
351
|
+
if (axisTitleUp.changed && axisTitleUp.value !== void 0) {
|
|
352
|
+
nextAxis = {
|
|
353
|
+
...nextAxis,
|
|
354
|
+
title: axisTitleUp.value
|
|
355
|
+
};
|
|
356
|
+
axisModified = true;
|
|
357
|
+
}
|
|
358
|
+
if (axisModified) {
|
|
359
|
+
nextAxes[axisKey] = nextAxis;
|
|
360
|
+
axesChanged = true;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
if (axesChanged) patch["axes"] = nextAxes;
|
|
364
|
+
}
|
|
365
|
+
const rawGroups = node.props["groups"];
|
|
366
|
+
if (Array.isArray(rawGroups)) {
|
|
367
|
+
let groupsChanged = false;
|
|
368
|
+
const nextGroups = rawGroups.map((group) => {
|
|
369
|
+
if (!isPlainRecord(group)) return group;
|
|
370
|
+
const labelsUp = upgradeChartTextStyleContainer(group["dataLabels"], chartContext, lookup);
|
|
371
|
+
const rawSeries = group["series"];
|
|
372
|
+
const series = Array.isArray(rawSeries) ? rawSeries.map((entry) => upgradeChartSeriesFonts(entry, labelsUp.nextContext, lookup)) : [];
|
|
373
|
+
const seriesChanged = Array.isArray(rawSeries) && series.some((entry, index) => entry !== rawSeries[index]);
|
|
374
|
+
if (!labelsUp.changed && !seriesChanged) return group;
|
|
375
|
+
groupsChanged = true;
|
|
376
|
+
return {
|
|
377
|
+
...group,
|
|
378
|
+
...labelsUp.changed ? { dataLabels: labelsUp.value } : {},
|
|
379
|
+
...seriesChanged ? { series } : {}
|
|
380
|
+
};
|
|
381
|
+
});
|
|
382
|
+
if (groupsChanged) patch["groups"] = nextGroups;
|
|
383
|
+
}
|
|
384
|
+
if (Object.keys(patch).length > 0) node.set(patch);
|
|
385
|
+
}
|
|
386
|
+
const footerSlotToRole = {
|
|
387
|
+
dateTime: "dt",
|
|
388
|
+
footer: "ftr",
|
|
389
|
+
slideNumber: "sldNum"
|
|
390
|
+
};
|
|
391
|
+
function resolveFooterInheritanceLayers(slideSlot, layout) {
|
|
392
|
+
const role = footerSlotToRole[slideSlot];
|
|
393
|
+
const masterFooterStyle = isPlainRecord(layout?.master?.footerPlaceholders?.[slideSlot]) ? layout.master.footerPlaceholders[slideSlot]["style"] : void 0;
|
|
394
|
+
const masterPh = layout?.master?.placeholders === void 0 ? void 0 : matchMasterPlaceholderSpec(layout.master.placeholders, role);
|
|
395
|
+
const layoutFooterStyle = isPlainRecord(layout?.footerPlaceholders?.[slideSlot]) ? layout.footerPlaceholders[slideSlot]["style"] : void 0;
|
|
396
|
+
const layoutPh = layout?.placeholders === void 0 ? void 0 : matchMasterPlaceholderSpec(layout.placeholders, role);
|
|
397
|
+
return [
|
|
398
|
+
masterPh?.style,
|
|
399
|
+
masterPh?.listStyles?.[1],
|
|
400
|
+
masterFooterStyle,
|
|
401
|
+
layoutPh?.style,
|
|
402
|
+
layoutPh?.listStyles?.[1],
|
|
403
|
+
layoutFooterStyle
|
|
404
|
+
];
|
|
405
|
+
}
|
|
406
|
+
function buildMasterCascadeLookup(masterNode, deckThemeFonts) {
|
|
407
|
+
const masterFonts = extractThemeFonts(masterNode.props["theme"]);
|
|
408
|
+
return {
|
|
409
|
+
themeFonts: Object.keys(masterFonts).length > 0 ? {
|
|
410
|
+
...deckThemeFonts,
|
|
411
|
+
...masterFonts
|
|
412
|
+
} : deckThemeFonts,
|
|
413
|
+
textStyles: masterNode.props["textStyles"],
|
|
414
|
+
placeholders: masterNode.props["placeholders"],
|
|
415
|
+
footerPlaceholders: isPlainRecord(masterNode.props["footerPlaceholders"]) ? masterNode.props["footerPlaceholders"] : void 0
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
function resolveSlideLayoutLookup(slideNode, deckThemeFonts, masterLookups, layoutLookups) {
|
|
419
|
+
const layoutProp = slideNode.props["layout"];
|
|
420
|
+
if (layoutProp === void 0) return void 0;
|
|
421
|
+
if (layoutProp instanceof CommonNode) {
|
|
422
|
+
const cached = layoutLookups.get(layoutProp);
|
|
423
|
+
if (cached !== void 0) return cached;
|
|
424
|
+
const parentMaster = layoutProp.parent instanceof CommonNode && layoutProp.parent.type === "slide-master" ? layoutProp.parent : void 0;
|
|
425
|
+
const masterLookup = parentMaster === void 0 ? void 0 : masterLookups.get(parentMaster) ?? buildMasterCascadeLookup(parentMaster, deckThemeFonts);
|
|
426
|
+
const baseFonts = masterLookup?.themeFonts ?? deckThemeFonts;
|
|
427
|
+
const overrideFonts = extractThemeFonts(layoutProp.props["themeOverride"]);
|
|
428
|
+
return {
|
|
429
|
+
themeFonts: Object.keys(overrideFonts).length > 0 ? {
|
|
430
|
+
...baseFonts,
|
|
431
|
+
...overrideFonts
|
|
432
|
+
} : baseFonts,
|
|
433
|
+
...masterLookup === void 0 ? {} : { master: masterLookup },
|
|
434
|
+
placeholders: layoutProp.props["placeholders"],
|
|
435
|
+
footerPlaceholders: isPlainRecord(layoutProp.props["footerPlaceholders"]) ? layoutProp.props["footerPlaceholders"] : void 0
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
if (isPlainRecord(layoutProp)) {
|
|
439
|
+
const overrideFonts = extractThemeFonts(layoutProp["themeOverride"]);
|
|
440
|
+
return {
|
|
441
|
+
themeFonts: Object.keys(overrideFonts).length > 0 ? {
|
|
442
|
+
...deckThemeFonts,
|
|
443
|
+
...overrideFonts
|
|
444
|
+
} : deckThemeFonts,
|
|
445
|
+
placeholders: layoutProp["placeholders"],
|
|
446
|
+
footerPlaceholders: isPlainRecord(layoutProp["footerPlaceholders"]) ? layoutProp["footerPlaceholders"] : void 0
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
function attachEmbeddedFontsToSubtree(node, inherited, lookup, masterLookups, layoutLookups, activeLayout, placeholderContext) {
|
|
451
|
+
const mutableNode = node;
|
|
452
|
+
let currentContext = inherited;
|
|
453
|
+
let nextLayout = activeLayout;
|
|
454
|
+
if (node.type === "slide-master") {
|
|
455
|
+
const masterThemeFonts = extractThemeFonts(node.props["theme"]);
|
|
456
|
+
currentContext = {
|
|
457
|
+
themeFonts: Object.keys(masterThemeFonts).length > 0 ? {
|
|
458
|
+
...inherited.themeFonts,
|
|
459
|
+
...masterThemeFonts
|
|
460
|
+
} : inherited.themeFonts,
|
|
461
|
+
fontFamily: "minor",
|
|
462
|
+
eastAsianFontFamily: "minor",
|
|
463
|
+
bold: false,
|
|
464
|
+
italic: false,
|
|
465
|
+
effectiveWeight: 400
|
|
466
|
+
};
|
|
467
|
+
const rawTextStyles = node.props["textStyles"];
|
|
468
|
+
if (rawTextStyles !== void 0) {
|
|
469
|
+
const levelContext = (_levelNum) => currentContext;
|
|
470
|
+
const titleUp = upgradePlaceholderListStylesFont(rawTextStyles.titleStyle, levelContext, lookup);
|
|
471
|
+
const bodyUp = upgradePlaceholderListStylesFont(rawTextStyles.bodyStyle, levelContext, lookup);
|
|
472
|
+
const otherUp = upgradePlaceholderListStylesFont(rawTextStyles.otherStyle, levelContext, lookup);
|
|
473
|
+
if (titleUp.changed || bodyUp.changed || otherUp.changed) mutableNode.set({ textStyles: {
|
|
474
|
+
...titleUp.value === void 0 ? {} : { titleStyle: titleUp.value },
|
|
475
|
+
...bodyUp.value === void 0 ? {} : { bodyStyle: bodyUp.value },
|
|
476
|
+
...otherUp.value === void 0 ? {} : { otherStyle: otherUp.value }
|
|
477
|
+
} });
|
|
478
|
+
}
|
|
479
|
+
const updatedTextStyles = node.props["textStyles"];
|
|
480
|
+
const rawPlaceholders = node.props["placeholders"];
|
|
481
|
+
const upgradedPh = upgradePlaceholdersFont(rawPlaceholders, currentContext, updatedTextStyles, void 0, lookup);
|
|
482
|
+
if (upgradedPh.changed && upgradedPh.value !== void 0) mutableNode.set({ placeholders: upgradedPh.value });
|
|
483
|
+
const footerUp = upgradeFooterPlaceholdersRecord(node.props["footerPlaceholders"], currentContext, void 0, lookup);
|
|
484
|
+
if (footerUp.changed && footerUp.value !== void 0) mutableNode.set({ footerPlaceholders: footerUp.value });
|
|
485
|
+
masterLookups.set(node, buildMasterCascadeLookup(node, inherited.themeFonts));
|
|
486
|
+
} else if (node.type === "slide-layout") {
|
|
487
|
+
const parentMaster = node.parent instanceof CommonNode && node.parent.type === "slide-master" ? masterLookups.get(node.parent) : void 0;
|
|
488
|
+
const overrideFonts = upgradeThemeOverrideOnNode(mutableNode, lookup.fontsByKey);
|
|
489
|
+
const baseFonts = parentMaster?.themeFonts ?? inherited.themeFonts;
|
|
490
|
+
const effectiveThemeFonts = overrideFonts !== void 0 && Object.keys(overrideFonts).length > 0 ? {
|
|
491
|
+
...baseFonts,
|
|
492
|
+
...overrideFonts
|
|
493
|
+
} : baseFonts;
|
|
494
|
+
currentContext = {
|
|
495
|
+
themeFonts: effectiveThemeFonts,
|
|
496
|
+
fontFamily: "minor",
|
|
497
|
+
eastAsianFontFamily: "minor",
|
|
498
|
+
bold: false,
|
|
499
|
+
italic: false,
|
|
500
|
+
effectiveWeight: 400
|
|
501
|
+
};
|
|
502
|
+
const rawPlaceholders = node.props["placeholders"];
|
|
503
|
+
const upgradedPh = upgradePlaceholdersFont(rawPlaceholders, currentContext, parentMaster?.textStyles, parentMaster?.placeholders, lookup);
|
|
504
|
+
if (upgradedPh.changed && upgradedPh.value !== void 0) mutableNode.set({ placeholders: upgradedPh.value });
|
|
505
|
+
const footerUp = upgradeFooterPlaceholdersRecord(node.props["footerPlaceholders"], currentContext, parentMaster?.footerPlaceholders, lookup);
|
|
506
|
+
if (footerUp.changed && footerUp.value !== void 0) mutableNode.set({ footerPlaceholders: footerUp.value });
|
|
507
|
+
layoutLookups.set(node, {
|
|
508
|
+
themeFonts: effectiveThemeFonts,
|
|
509
|
+
...parentMaster === void 0 ? {} : { master: parentMaster },
|
|
510
|
+
placeholders: node.props["placeholders"],
|
|
511
|
+
footerPlaceholders: isPlainRecord(node.props["footerPlaceholders"]) ? node.props["footerPlaceholders"] : void 0
|
|
512
|
+
});
|
|
513
|
+
} else if (node.type === "slide") {
|
|
514
|
+
nextLayout = resolveSlideLayoutLookup(node, inherited.themeFonts, masterLookups, layoutLookups);
|
|
515
|
+
const overrideFonts = upgradeThemeOverrideOnNode(mutableNode, lookup.fontsByKey);
|
|
516
|
+
const effectiveThemeFonts = {
|
|
517
|
+
...nextLayout?.themeFonts ?? inherited.themeFonts,
|
|
518
|
+
...overrideFonts
|
|
519
|
+
};
|
|
520
|
+
currentContext = {
|
|
521
|
+
...inherited,
|
|
522
|
+
themeFonts: effectiveThemeFonts
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
if (node.type === "chart") {
|
|
526
|
+
const overrideFonts = upgradeThemeOverrideOnNode(mutableNode, lookup.fontsByKey);
|
|
527
|
+
currentContext = {
|
|
528
|
+
...currentContext,
|
|
529
|
+
themeFonts: {
|
|
530
|
+
...currentContext.themeFonts,
|
|
531
|
+
...overrideFonts
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
let childPlaceholderContext = placeholderContext;
|
|
536
|
+
let nodeStyleInherited = currentContext;
|
|
537
|
+
if (node.type !== "deck" && node.type !== "slide-master" && node.type !== "slide-layout" && node.type !== "slide") {
|
|
538
|
+
if (placeholderContext !== void 0 && node.type === "paragraph" && isPlainRecord(node.props["style"])) {
|
|
539
|
+
const listProp = node.props["style"]["list"];
|
|
540
|
+
const levelIndex0 = isPlainRecord(listProp) && typeof listProp["level"] === "number" ? listProp["level"] : 0;
|
|
541
|
+
const key1to9 = Math.min(9, Math.max(1, levelIndex0 + 1));
|
|
542
|
+
nodeStyleInherited = foldStyleLayers({
|
|
543
|
+
themeFonts: currentContext.themeFonts,
|
|
544
|
+
fontFamily: "minor",
|
|
545
|
+
eastAsianFontFamily: "minor",
|
|
546
|
+
bold: false,
|
|
547
|
+
italic: false,
|
|
548
|
+
effectiveWeight: 400
|
|
549
|
+
}, [
|
|
550
|
+
placeholderContext.masterTx?.[key1to9],
|
|
551
|
+
placeholderContext.masterPh?.style,
|
|
552
|
+
placeholderContext.masterPh?.listStyles?.[key1to9],
|
|
553
|
+
placeholderContext.layoutPh?.style,
|
|
554
|
+
placeholderContext.layoutPh?.listStyles?.[key1to9],
|
|
555
|
+
placeholderContext.slideTextNodeStyle
|
|
556
|
+
]);
|
|
557
|
+
} else if (typeof node.props["placeholder"] === "string") {
|
|
558
|
+
const layoutPh = nextLayout?.placeholders?.[node.props["placeholder"]];
|
|
559
|
+
if (layoutPh !== void 0) {
|
|
560
|
+
const role = layoutPh.type;
|
|
561
|
+
const category = masterTextStyleCategoryForRole(role);
|
|
562
|
+
const masterTx = nextLayout?.master?.textStyles?.[category];
|
|
563
|
+
const masterPh = nextLayout?.master?.placeholders === void 0 ? void 0 : matchMasterPlaceholderSpec(nextLayout.master.placeholders, role);
|
|
564
|
+
nodeStyleInherited = foldStyleLayers({
|
|
565
|
+
themeFonts: currentContext.themeFonts,
|
|
566
|
+
fontFamily: "minor",
|
|
567
|
+
eastAsianFontFamily: "minor",
|
|
568
|
+
bold: false,
|
|
569
|
+
italic: false,
|
|
570
|
+
effectiveWeight: 400
|
|
571
|
+
}, [
|
|
572
|
+
masterTx?.[1],
|
|
573
|
+
masterPh?.style,
|
|
574
|
+
masterPh?.listStyles?.[1],
|
|
575
|
+
layoutPh?.style,
|
|
576
|
+
layoutPh?.listStyles?.[1]
|
|
577
|
+
]);
|
|
578
|
+
childPlaceholderContext = {
|
|
579
|
+
layoutPh,
|
|
580
|
+
masterPh,
|
|
581
|
+
masterTx,
|
|
582
|
+
slideTextNodeStyle: node.props["style"]
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
const styleUp = upgradeStyleRecordFontAndWeight(node.props["style"], nodeStyleInherited, lookup, { backfillInheritedLeaf: hasUnstyledTextLeaf(node) });
|
|
588
|
+
if (styleUp.changed && styleUp.value !== void 0) {
|
|
589
|
+
const patch = {};
|
|
590
|
+
const prevStyle = isPlainRecord(node.props["style"]) ? node.props["style"] : void 0;
|
|
591
|
+
if (styleUp.value["fontFamily"] !== prevStyle?.["fontFamily"]) patch["fontFamily"] = styleUp.value["fontFamily"];
|
|
592
|
+
if (styleUp.value["eastAsianFontFamily"] !== prevStyle?.["eastAsianFontFamily"]) patch["eastAsianFontFamily"] = styleUp.value["eastAsianFontFamily"];
|
|
593
|
+
if (styleUp.value["fontWeight"] !== prevStyle?.["fontWeight"]) patch["fontWeight"] = styleUp.value["fontWeight"];
|
|
594
|
+
if (Object.keys(patch).length > 0) mutableNode.style(patch);
|
|
595
|
+
if (childPlaceholderContext !== void 0 && placeholderContext === void 0) childPlaceholderContext = {
|
|
596
|
+
...childPlaceholderContext,
|
|
597
|
+
slideTextNodeStyle: node.props["style"]
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
if (node.type === "chart") upgradeChartPropsFonts(mutableNode, styleUp.nextContext, lookup);
|
|
601
|
+
if (node.type === "slide") for (const slideSlot of [
|
|
602
|
+
"dateTime",
|
|
603
|
+
"footer",
|
|
604
|
+
"slideNumber"
|
|
605
|
+
]) {
|
|
606
|
+
const rawSlot = node.props[slideSlot];
|
|
607
|
+
if (!isPlainRecord(rawSlot)) continue;
|
|
608
|
+
const footerInherited = foldStyleLayers(currentContext, resolveFooterInheritanceLayers(slideSlot, nextLayout));
|
|
609
|
+
const nextStyle = upgradeStyleRecordFontAndWeight(rawSlot["style"], footerInherited, lookup);
|
|
610
|
+
if (nextStyle.changed && nextStyle.value !== void 0) mutableNode.set({ [slideSlot]: {
|
|
611
|
+
...rawSlot,
|
|
612
|
+
style: nextStyle.value
|
|
613
|
+
} });
|
|
614
|
+
}
|
|
615
|
+
const childInherited = node.type === "deck" || node.type === "slide-master" || node.type === "slide-layout" || node.type === "slide" ? {
|
|
616
|
+
...styleUp.nextContext,
|
|
617
|
+
themeFonts: currentContext.themeFonts
|
|
618
|
+
} : styleUp.nextContext;
|
|
619
|
+
for (const child of node.children) if (child instanceof CommonNode) attachEmbeddedFontsToSubtree(child, childInherited, lookup, masterLookups, layoutLookups, nextLayout, node.type === "slide-master" || node.type === "slide-layout" || node.type === "slide" ? void 0 : childPlaceholderContext);
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Reads `<p:embeddedFontLst>` from `presentation.xml`, unpacks uncompressed EOT font parts
|
|
623
|
+
* into detached `Font` resources, attaches them to theme font slots and text nodes, and
|
|
624
|
+
* isolates compressed, obfuscated, or corrupt `.fntdata` gracefully.
|
|
625
|
+
*/
|
|
626
|
+
function readEmbeddedFontsIntoDeck(context) {
|
|
627
|
+
const { presentationCursor, deckNode, package: pkg } = context;
|
|
628
|
+
const diagnostics = [];
|
|
629
|
+
const records = readEmbeddedFontList(presentationCursor, pkg.presentationRels, pkg, diagnostics);
|
|
630
|
+
const fontsByKey = /* @__PURE__ */ new Map();
|
|
631
|
+
const slotWeightsByKey = /* @__PURE__ */ new Map();
|
|
632
|
+
for (const record of records) {
|
|
633
|
+
const faces = [];
|
|
634
|
+
const slotWeights = {};
|
|
635
|
+
let requiresSubstitute = false;
|
|
636
|
+
for (const slot of record.slots) {
|
|
637
|
+
const unpacked = unpackEotFontData(slot.bytes);
|
|
638
|
+
if (unpacked.status === "unsupported") {
|
|
639
|
+
diagnostics.push({
|
|
640
|
+
code: "unsupported-mechanism",
|
|
641
|
+
category: "unsupported",
|
|
642
|
+
disposition: "omitted",
|
|
643
|
+
location: {
|
|
644
|
+
part: slot.partPath,
|
|
645
|
+
xpath: slot.xpath
|
|
646
|
+
},
|
|
647
|
+
namespaceUri: P_NS,
|
|
648
|
+
localName: slot.slot,
|
|
649
|
+
mechanismHint: unpacked.reason
|
|
650
|
+
});
|
|
651
|
+
continue;
|
|
652
|
+
}
|
|
653
|
+
if (unpacked.status === "corrupt") {
|
|
654
|
+
diagnostics.push({
|
|
655
|
+
code: "corrupt-part",
|
|
656
|
+
category: "corrupt-input",
|
|
657
|
+
disposition: "omitted",
|
|
658
|
+
location: {
|
|
659
|
+
part: slot.partPath,
|
|
660
|
+
xpath: slot.xpath
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
const inspected = inspectImportedEmbeddedFont(unpacked.ttfBytes, record.typeface);
|
|
666
|
+
if (inspected === void 0) {
|
|
667
|
+
diagnostics.push({
|
|
668
|
+
code: "corrupt-part",
|
|
669
|
+
category: "corrupt-input",
|
|
670
|
+
disposition: "omitted",
|
|
671
|
+
location: {
|
|
672
|
+
part: slot.partPath,
|
|
673
|
+
xpath: slot.xpath
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
continue;
|
|
677
|
+
}
|
|
678
|
+
if (!inspected.familyMatches) requiresSubstitute = true;
|
|
679
|
+
const weight = inspected.weight ?? fallbackWeightForSlot(slot.slot);
|
|
680
|
+
const style = inspected.style ?? fallbackStyleForSlot(slot.slot);
|
|
681
|
+
slotWeights[slot.slot] = weight;
|
|
682
|
+
faces.push({
|
|
683
|
+
weight,
|
|
684
|
+
style,
|
|
685
|
+
data: new Uint8Array(unpacked.ttfBytes)
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
if (faces.length > 0 && record.typeface.trim() !== "" && !reservedThemeFontPattern.test(record.typeface.trim())) {
|
|
689
|
+
const key = fontFamilyKey(record.typeface);
|
|
690
|
+
fontsByKey.set(key, font(record.typeface, faces, requiresSubstitute ? { substitute: true } : {}));
|
|
691
|
+
slotWeightsByKey.set(key, slotWeights);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
const schemeDiagnostics = [...context.existingDiagnostics ?? []];
|
|
695
|
+
const previousDiagnosticsCount = schemeDiagnostics.length;
|
|
696
|
+
const scheme = readPresentationThemeFontScheme(pkg, schemeDiagnostics);
|
|
697
|
+
diagnostics.push(...schemeDiagnostics.slice(previousDiagnosticsCount));
|
|
698
|
+
const attachFontsToThemeInput = (existing) => {
|
|
699
|
+
if (existing === void 0) return { changed: false };
|
|
700
|
+
const existingFonts = existing.fonts ?? {};
|
|
701
|
+
const nextFonts = {};
|
|
702
|
+
let changed = false;
|
|
703
|
+
for (const slot of [
|
|
704
|
+
"major",
|
|
705
|
+
"minor",
|
|
706
|
+
"majorEastAsian",
|
|
707
|
+
"minorEastAsian"
|
|
708
|
+
]) {
|
|
709
|
+
const token = existingFonts[slot];
|
|
710
|
+
if (token === void 0) continue;
|
|
711
|
+
if (typeof token === "string") {
|
|
712
|
+
const matched = fontsByKey.get(fontFamilyKey(token));
|
|
713
|
+
if (matched !== void 0) {
|
|
714
|
+
nextFonts[slot] = matched;
|
|
715
|
+
changed = true;
|
|
716
|
+
continue;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
nextFonts[slot] = token;
|
|
720
|
+
}
|
|
721
|
+
if (!changed) return { changed: false };
|
|
722
|
+
return {
|
|
723
|
+
changed: true,
|
|
724
|
+
theme: defineTheme({
|
|
725
|
+
...existing,
|
|
726
|
+
fonts: nextFonts
|
|
727
|
+
})
|
|
728
|
+
};
|
|
729
|
+
};
|
|
730
|
+
let masterFallbackTheme;
|
|
731
|
+
const mutatedThemes = /* @__PURE__ */ new Set();
|
|
732
|
+
for (const child of deckNode.children) if (child instanceof CommonNode && child.type === "slide-master") {
|
|
733
|
+
const masterTheme = child.props["theme"];
|
|
734
|
+
masterFallbackTheme ??= masterTheme;
|
|
735
|
+
if (isTheme(masterTheme) && masterTheme !== defaultTheme) {
|
|
736
|
+
if (!mutatedThemes.has(masterTheme)) {
|
|
737
|
+
mutatedThemes.add(masterTheme);
|
|
738
|
+
const updatedMasterTheme = attachFontsToThemeInput(masterTheme);
|
|
739
|
+
if (updatedMasterTheme.changed && updatedMasterTheme.theme !== void 0) masterTheme.set({ fonts: updatedMasterTheme.theme.fonts });
|
|
740
|
+
}
|
|
741
|
+
} else {
|
|
742
|
+
const updatedMasterTheme = attachFontsToThemeInput(masterTheme);
|
|
743
|
+
if (updatedMasterTheme.changed && updatedMasterTheme.theme !== void 0) child.set({ theme: updatedMasterTheme.theme });
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
const existingDeckTheme = deckNode.props["theme"];
|
|
747
|
+
const baseDeckTheme = existingDeckTheme ?? masterFallbackTheme;
|
|
748
|
+
if (scheme !== void 0) {
|
|
749
|
+
const resolvedMajor = scheme.majorTypeface === void 0 ? void 0 : fontsByKey.get(fontFamilyKey(scheme.majorTypeface)) ?? scheme.majorTypeface;
|
|
750
|
+
const resolvedMinor = scheme.minorTypeface === void 0 ? void 0 : fontsByKey.get(fontFamilyKey(scheme.minorTypeface)) ?? scheme.minorTypeface;
|
|
751
|
+
const hasDistinctMajorEa = scheme.majorEastAsianTypeface !== void 0 && scheme.majorEastAsianTypeface !== scheme.majorTypeface;
|
|
752
|
+
const hasDistinctMinorEa = scheme.minorEastAsianTypeface !== void 0 && scheme.minorEastAsianTypeface !== scheme.minorTypeface;
|
|
753
|
+
const resolvedMajorEa = !hasDistinctMajorEa ? void 0 : fontsByKey.get(fontFamilyKey(scheme.majorEastAsianTypeface)) ?? scheme.majorEastAsianTypeface;
|
|
754
|
+
const resolvedMinorEa = !hasDistinctMinorEa ? void 0 : fontsByKey.get(fontFamilyKey(scheme.minorEastAsianTypeface)) ?? scheme.minorEastAsianTypeface;
|
|
755
|
+
const hasCustomMajor = resolvedMajor !== void 0 && resolvedMajor !== defaultTheme.fonts.major;
|
|
756
|
+
const hasCustomMinor = resolvedMinor !== void 0 && resolvedMinor !== defaultTheme.fonts.minor;
|
|
757
|
+
if (hasCustomMajor || hasCustomMinor || resolvedMajorEa !== void 0 || resolvedMinorEa !== void 0) {
|
|
758
|
+
const upgradedBase = attachFontsToThemeInput(baseDeckTheme).theme ?? baseDeckTheme;
|
|
759
|
+
const themeName = scheme.themeName ?? upgradedBase?.name;
|
|
760
|
+
const nextFonts = {};
|
|
761
|
+
if (upgradedBase?.fonts !== void 0) for (const slot of [
|
|
762
|
+
"major",
|
|
763
|
+
"minor",
|
|
764
|
+
"majorEastAsian",
|
|
765
|
+
"minorEastAsian"
|
|
766
|
+
]) {
|
|
767
|
+
const token = upgradedBase.fonts[slot];
|
|
768
|
+
if (token !== void 0) nextFonts[slot] = token;
|
|
769
|
+
}
|
|
770
|
+
if (resolvedMajor !== void 0) nextFonts["major"] = resolvedMajor;
|
|
771
|
+
if (resolvedMinor !== void 0) nextFonts["minor"] = resolvedMinor;
|
|
772
|
+
if (resolvedMajorEa !== void 0) nextFonts["majorEastAsian"] = resolvedMajorEa;
|
|
773
|
+
if (resolvedMinorEa !== void 0) nextFonts["minorEastAsian"] = resolvedMinorEa;
|
|
774
|
+
deckNode.set({ theme: defineTheme({
|
|
775
|
+
...upgradedBase,
|
|
776
|
+
...themeName === void 0 ? {} : { name: themeName },
|
|
777
|
+
fonts: nextFonts
|
|
778
|
+
}) });
|
|
779
|
+
} else if (existingDeckTheme !== void 0) {
|
|
780
|
+
const updated = attachFontsToThemeInput(existingDeckTheme);
|
|
781
|
+
if (updated.changed && updated.theme !== void 0) deckNode.set({ theme: updated.theme });
|
|
782
|
+
}
|
|
783
|
+
} else if (existingDeckTheme !== void 0) {
|
|
784
|
+
const updated = attachFontsToThemeInput(existingDeckTheme);
|
|
785
|
+
if (updated.changed && updated.theme !== void 0) deckNode.set({ theme: updated.theme });
|
|
786
|
+
}
|
|
787
|
+
if (fontsByKey.size > 0) attachEmbeddedFontsToSubtree(deckNode, {
|
|
788
|
+
themeFonts: extractThemeFonts(deckNode.props["theme"]),
|
|
789
|
+
fontFamily: "minor",
|
|
790
|
+
eastAsianFontFamily: "minor",
|
|
791
|
+
bold: false,
|
|
792
|
+
italic: false,
|
|
793
|
+
effectiveWeight: 400
|
|
794
|
+
}, {
|
|
795
|
+
fontsByKey,
|
|
796
|
+
slotWeightsByKey
|
|
797
|
+
}, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), void 0);
|
|
798
|
+
return { diagnostics };
|
|
799
|
+
}
|
|
800
|
+
/** Deck-level import handler wired into `embeddedFontMechanism`. */
|
|
801
|
+
const embeddedFontImportHandler = {
|
|
802
|
+
target: "deck",
|
|
803
|
+
read: readEmbeddedFontsIntoDeck
|
|
804
|
+
};
|
|
805
|
+
export { embeddedFontImportHandler, readEmbeddedFontsIntoDeck };
|