@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,35 +1,58 @@
|
|
|
1
|
-
import { CapabilityError } from "./diagnostics.js";
|
|
1
|
+
import { CapabilityError, zodIssueField } from "./diagnostics.js";
|
|
2
|
+
import { isSealedFont } from "./font-seal.js";
|
|
2
3
|
import { snapshotValue } from "./input-values.js";
|
|
4
|
+
import { resourceSourceSchema, uint8ArraySchema } from "./resource-source.js";
|
|
3
5
|
import { z } from "zod";
|
|
4
|
-
// ../core/dist/theme.js
|
|
5
|
-
const
|
|
6
|
-
const fontWeightNumberSchema = z.
|
|
6
|
+
// ../core/dist/kernel/theme.js
|
|
7
|
+
const rawFontFaceStyleSchema = z.enum(["normal", "italic"]);
|
|
8
|
+
const fontWeightNumberSchema = z.number().int("fontWeight must be normal, bold, or an integer between 1 and 1000").min(1, "fontWeight must be normal, bold, or an integer between 1 and 1000").max(1e3, "fontWeight must be normal, bold, or an integer between 1 and 1000");
|
|
7
9
|
const fontWeightSchema = z.union([
|
|
8
10
|
z.literal("normal"),
|
|
9
11
|
z.literal("bold"),
|
|
10
12
|
fontWeightNumberSchema
|
|
11
13
|
]);
|
|
12
|
-
const
|
|
13
|
-
/** Font files provided by the caller can be used for measurement or embedded according to build options. */
|
|
14
|
-
const fontFaceSchema = z.strictObject({
|
|
14
|
+
const rawFontFaceSchema = z.strictObject({
|
|
15
15
|
weight: fontWeightNumberSchema.optional(),
|
|
16
|
-
style:
|
|
16
|
+
style: rawFontFaceStyleSchema.optional(),
|
|
17
17
|
data: uint8ArraySchema.refine((bytes) => bytes.byteLength > 0, "Font face data cannot be empty").optional()
|
|
18
18
|
}).readonly();
|
|
19
19
|
const nonEmptyTrimmedStringSchema = z.string().refine((value) => value.trim() !== "", "Value cannot be empty");
|
|
20
|
-
|
|
21
|
-
const fontSchema = z.strictObject({
|
|
20
|
+
const unsealedFontObjectSchema = z.strictObject({
|
|
22
21
|
family: nonEmptyTrimmedStringSchema,
|
|
23
|
-
faces: z.array(
|
|
22
|
+
faces: z.array(rawFontFaceSchema).readonly().optional(),
|
|
24
23
|
substitute: z.boolean().optional(),
|
|
25
24
|
embeddable: z.boolean().optional()
|
|
26
25
|
}).readonly();
|
|
26
|
+
const sealedFontSchema = z.custom(isSealedFont);
|
|
27
|
+
const rawFontSchema = z.union([sealedFontSchema, unsealedFontObjectSchema]);
|
|
28
|
+
/** Internal schema used by `font()` constructor to report exact per-field validation issues. */
|
|
29
|
+
const unsealedFontSchema = unsealedFontObjectSchema;
|
|
27
30
|
const fontOptionsSchema = z.strictObject({
|
|
28
31
|
substitute: z.boolean().optional(),
|
|
29
32
|
embeddable: z.boolean().optional()
|
|
30
33
|
}).readonly();
|
|
31
|
-
const
|
|
32
|
-
const
|
|
34
|
+
const themeFontSlots = ["major", "minor"];
|
|
35
|
+
const themeFontSlotSchema = z.enum(themeFontSlots);
|
|
36
|
+
function isThemeFontSlot(value) {
|
|
37
|
+
return value === "major" || value === "minor";
|
|
38
|
+
}
|
|
39
|
+
const rawFontReferenceSchema = z.union([
|
|
40
|
+
nonEmptyTrimmedStringSchema,
|
|
41
|
+
sealedFontSchema,
|
|
42
|
+
unsealedFontObjectSchema
|
|
43
|
+
]);
|
|
44
|
+
const reservedThemeFontPattern = /^(?:major|minor|\+(?:mj|mn)-)/iu;
|
|
45
|
+
const themeFontReservedSlotMessage = "Theme font slot cannot use reserved placeholders 'major', 'minor', '+mj-*', or '+mn-*'";
|
|
46
|
+
function isAllowedThemeFontFamily(family) {
|
|
47
|
+
const trimmed = family.trim();
|
|
48
|
+
return trimmed !== "" && !reservedThemeFontPattern.test(trimmed);
|
|
49
|
+
}
|
|
50
|
+
const allowedThemeSealedFontSchema = z.custom((value) => isSealedFont(value) && isAllowedThemeFontFamily(value.family), { message: themeFontReservedSlotMessage });
|
|
51
|
+
const rawThemeFontValueSchema = z.union([
|
|
52
|
+
nonEmptyTrimmedStringSchema.refine(isAllowedThemeFontFamily, themeFontReservedSlotMessage),
|
|
53
|
+
allowedThemeSealedFontSchema,
|
|
54
|
+
unsealedFontObjectSchema.refine((fontValue) => isAllowedThemeFontFamily(fontValue.family), themeFontReservedSlotMessage)
|
|
55
|
+
]);
|
|
33
56
|
const textLengthPattern = /^(\d+(?:\.\d+)?)(px|pt)$/u;
|
|
34
57
|
const textLengthStringSchema = z.string().regex(textLengthPattern);
|
|
35
58
|
function textLengthToPixels(value) {
|
|
@@ -43,16 +66,28 @@ function fontSizeToPoints(value) {
|
|
|
43
66
|
if (typeof value === "string" && value.endsWith("pt")) return Number(value.slice(0, -2));
|
|
44
67
|
return textLengthToPixels(value) * .75;
|
|
45
68
|
}
|
|
46
|
-
const
|
|
47
|
-
const validatedFontSizeSchema =
|
|
69
|
+
const rawFontSizeSchema = z.union([z.number().finite().positive(), textLengthStringSchema.refine((value) => textLengthToPixels(value) > 0, "Text length must be greater than 0")]);
|
|
70
|
+
const validatedFontSizeSchema = rawFontSizeSchema.refine((value) => {
|
|
48
71
|
const serialized = Math.round(fontSizeToPoints(value) * 100);
|
|
49
72
|
return serialized >= 100 && serialized <= 4e5;
|
|
50
73
|
}, "fontSize converted value must be within DrawingML range of 1 to 4000pt");
|
|
51
|
-
const
|
|
74
|
+
const lineHeightPercentPattern = /^(\d+(?:\.\d+)?)%$/u;
|
|
75
|
+
const lineHeightPercentStringSchema = z.string().regex(lineHeightPercentPattern);
|
|
76
|
+
function parseLineHeightPercentThousandths(value) {
|
|
77
|
+
const match = lineHeightPercentPattern.exec(value);
|
|
78
|
+
if (match === null) return void 0;
|
|
79
|
+
const pct = Number(match[1]);
|
|
80
|
+
if (!Number.isFinite(pct)) return void 0;
|
|
81
|
+
const thousandths = Math.round(pct * 1e3);
|
|
82
|
+
if (thousandths < 1 || thousandths > 132e5) return void 0;
|
|
83
|
+
return thousandths;
|
|
84
|
+
}
|
|
85
|
+
const validatedLineHeightSchema = z.union([rawFontSizeSchema, lineHeightPercentStringSchema.refine((value) => parseLineHeightPercentThousandths(value) !== void 0, "lineHeight percentage must be greater than 0% and within DrawingML ST_TextSpacingPercent range (up to 13200%)")]).refine((value) => {
|
|
86
|
+
if (typeof value === "string" && value.endsWith("%")) return parseLineHeightPercentThousandths(value) !== void 0;
|
|
52
87
|
const centipoints = Math.round(textLengthToPixels(value) * 75);
|
|
53
88
|
return centipoints >= 0 && centipoints <= 158400;
|
|
54
|
-
}, "lineHeight
|
|
55
|
-
const
|
|
89
|
+
}, "lineHeight must be a positive pixel value, px/pt length within 0 to 1584pt, or percentage within 0% to 13200%");
|
|
90
|
+
const rawTextAlignmentSchema = z.enum([
|
|
56
91
|
"left",
|
|
57
92
|
"center",
|
|
58
93
|
"right",
|
|
@@ -72,7 +107,7 @@ const nativeColorSlots = [
|
|
|
72
107
|
"hlink",
|
|
73
108
|
"folHlink"
|
|
74
109
|
];
|
|
75
|
-
const
|
|
110
|
+
const rawNativeColorSlotSchema = z.enum(nativeColorSlots);
|
|
76
111
|
const schemeColorSlots = [
|
|
77
112
|
"bg1",
|
|
78
113
|
"tx1",
|
|
@@ -106,22 +141,24 @@ const schemeColorNames = [
|
|
|
106
141
|
"hlink",
|
|
107
142
|
"folHlink"
|
|
108
143
|
];
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
bg1:
|
|
113
|
-
tx1:
|
|
114
|
-
bg2:
|
|
115
|
-
tx2:
|
|
116
|
-
accent1:
|
|
117
|
-
accent2:
|
|
118
|
-
accent3:
|
|
119
|
-
accent4:
|
|
120
|
-
accent5:
|
|
121
|
-
accent6:
|
|
122
|
-
hlink:
|
|
123
|
-
folHlink:
|
|
144
|
+
const rawSchemeColorNameSchema = z.enum(schemeColorNames);
|
|
145
|
+
const schemeColorNameSchema = rawSchemeColorNameSchema;
|
|
146
|
+
const rawColorMapSchema = z.strictObject({
|
|
147
|
+
bg1: rawNativeColorSlotSchema,
|
|
148
|
+
tx1: rawNativeColorSlotSchema,
|
|
149
|
+
bg2: rawNativeColorSlotSchema,
|
|
150
|
+
tx2: rawNativeColorSlotSchema,
|
|
151
|
+
accent1: rawNativeColorSlotSchema,
|
|
152
|
+
accent2: rawNativeColorSlotSchema,
|
|
153
|
+
accent3: rawNativeColorSlotSchema,
|
|
154
|
+
accent4: rawNativeColorSlotSchema,
|
|
155
|
+
accent5: rawNativeColorSlotSchema,
|
|
156
|
+
accent6: rawNativeColorSlotSchema,
|
|
157
|
+
hlink: rawNativeColorSlotSchema,
|
|
158
|
+
folHlink: rawNativeColorSlotSchema
|
|
124
159
|
}).readonly();
|
|
160
|
+
/** Native `<p:clrMap>` / `<a:overrideClrMapping>` mapping the 12 scheme slots to 12 theme palette slots. */
|
|
161
|
+
const colorMapSchema = rawColorMapSchema;
|
|
125
162
|
const defaultColorMap = Object.freeze({
|
|
126
163
|
bg1: "lt1",
|
|
127
164
|
tx1: "dk1",
|
|
@@ -136,75 +173,138 @@ const defaultColorMap = Object.freeze({
|
|
|
136
173
|
hlink: "hlink",
|
|
137
174
|
folHlink: "folHlink"
|
|
138
175
|
});
|
|
139
|
-
const colorMapOverrideSchema = z.union([z.literal("master"),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
slot: schemeColorNameSchema,
|
|
176
|
+
const colorMapOverrideSchema = z.union([z.literal("master"), rawColorMapSchema]);
|
|
177
|
+
const rawThemeShadeSchema = z.strictObject({
|
|
178
|
+
slot: rawSchemeColorNameSchema,
|
|
143
179
|
lumMod: z.number().finite().min(0).max(1),
|
|
144
180
|
lumOff: z.number().finite().min(0).max(1).optional()
|
|
145
181
|
}).readonly();
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
182
|
+
const themeHexColorPattern = /^\s*#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})\s*$/u;
|
|
183
|
+
const styleHexColorPattern = /^\s*#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\s*$/u;
|
|
184
|
+
function normalizeThemeHexColor(raw) {
|
|
185
|
+
const digits = raw.trim().slice(1);
|
|
186
|
+
return `#${(digits.length === 3 ? digits.split("").map((digit) => digit + digit).join("") : digits).toUpperCase()}`;
|
|
187
|
+
}
|
|
188
|
+
const rawThemeHexColorSchema = z.string().regex(themeHexColorPattern, "Theme color slot must be an opaque #RGB or #RRGGBB hex color").transform(normalizeThemeHexColor);
|
|
189
|
+
const rawStyleHexColorSchema = z.string().regex(styleHexColorPattern, "Color hex value must be #RGB, #RGBA, #RRGGBB, or #RRGGBBAA");
|
|
190
|
+
const rawThemeColorSchema = z.union([
|
|
191
|
+
rawSchemeColorNameSchema,
|
|
192
|
+
rawStyleHexColorSchema,
|
|
193
|
+
rawThemeShadeSchema
|
|
194
|
+
]);
|
|
195
|
+
const rawColorValueSchema = z.union([
|
|
196
|
+
rawSchemeColorNameSchema,
|
|
197
|
+
rawStyleHexColorSchema,
|
|
198
|
+
rawThemeShadeSchema,
|
|
151
199
|
z.strictObject({
|
|
152
|
-
color:
|
|
200
|
+
color: rawThemeColorSchema,
|
|
153
201
|
alpha: z.number().finite().min(0).max(1).optional()
|
|
154
202
|
}).readonly()
|
|
155
203
|
]);
|
|
204
|
+
/** Color entry can directly provide a scheme color, hex color, or theme shade, optionally with alpha. */
|
|
205
|
+
const colorValueSchema = rawColorValueSchema;
|
|
156
206
|
z.strictObject({
|
|
157
207
|
hex: z.string(),
|
|
158
208
|
alpha: z.number().finite().min(0).max(1).optional(),
|
|
159
|
-
slot:
|
|
160
|
-
scheme:
|
|
209
|
+
slot: rawNativeColorSlotSchema.optional(),
|
|
210
|
+
scheme: rawSchemeColorNameSchema.optional(),
|
|
161
211
|
lumMod: z.number().finite().min(0).max(1).optional(),
|
|
162
212
|
lumOff: z.number().finite().min(0).max(1).optional()
|
|
163
213
|
}).readonly();
|
|
164
|
-
const
|
|
165
|
-
color:
|
|
214
|
+
const rawGradientStopSchema = z.strictObject({
|
|
215
|
+
color: rawColorValueSchema,
|
|
166
216
|
position: z.number().finite()
|
|
167
217
|
}).readonly();
|
|
168
|
-
const
|
|
218
|
+
const rawLinearGradientSchema = z.strictObject({
|
|
169
219
|
type: z.literal("linear-gradient"),
|
|
170
220
|
angle: z.number().finite(),
|
|
171
|
-
stops: z.array(
|
|
221
|
+
stops: z.array(rawGradientStopSchema).readonly()
|
|
172
222
|
}).readonly();
|
|
173
|
-
const
|
|
223
|
+
const linearGradientSchema = rawLinearGradientSchema;
|
|
224
|
+
const rawRadialGradientSchema = z.strictObject({
|
|
174
225
|
type: z.literal("radial-gradient"),
|
|
175
|
-
stops: z.array(
|
|
226
|
+
stops: z.array(rawGradientStopSchema).readonly()
|
|
176
227
|
}).readonly();
|
|
177
|
-
const
|
|
178
|
-
|
|
228
|
+
const radialGradientSchema = rawRadialGradientSchema;
|
|
229
|
+
const rawImageBackgroundFitSchema = z.enum([
|
|
230
|
+
"fill",
|
|
231
|
+
"cover",
|
|
232
|
+
"contain"
|
|
233
|
+
]);
|
|
234
|
+
const imageBackgroundFitSchema = rawImageBackgroundFitSchema;
|
|
235
|
+
const positionPercentSchema = z.string().regex(/^(-?(?:\d+(?:\.\d*)?|\.\d+))%$/u);
|
|
236
|
+
const positionCoordinateSchema = z.union([z.number().finite(), positionPercentSchema]);
|
|
237
|
+
const rawImageBackgroundPositionKeywordSchema = z.enum([
|
|
238
|
+
"center",
|
|
239
|
+
"top",
|
|
240
|
+
"bottom",
|
|
241
|
+
"left",
|
|
242
|
+
"right",
|
|
243
|
+
"top left",
|
|
244
|
+
"top right",
|
|
245
|
+
"bottom left",
|
|
246
|
+
"bottom right"
|
|
247
|
+
]);
|
|
248
|
+
const imageBackgroundPositionKeywordSchema = rawImageBackgroundPositionKeywordSchema;
|
|
249
|
+
const rawImageBackgroundPositionSchema = z.union([rawImageBackgroundPositionKeywordSchema, z.strictObject({
|
|
250
|
+
x: positionCoordinateSchema.optional(),
|
|
251
|
+
y: positionCoordinateSchema.optional()
|
|
252
|
+
}).readonly()]);
|
|
253
|
+
const imageBackgroundPositionSchema = rawImageBackgroundPositionSchema;
|
|
254
|
+
const imageBackgroundObjectSchema = z.strictObject({
|
|
255
|
+
image: resourceSourceSchema,
|
|
256
|
+
fit: rawImageBackgroundFitSchema.optional(),
|
|
257
|
+
position: rawImageBackgroundPositionSchema.optional(),
|
|
258
|
+
opacity: z.number().finite().min(0).max(1).optional()
|
|
259
|
+
});
|
|
260
|
+
const rawImageBackgroundSchema = imageBackgroundObjectSchema.readonly();
|
|
261
|
+
const imageBackgroundSchema = rawImageBackgroundSchema;
|
|
262
|
+
const rawBackgroundValueSchema = z.union([
|
|
263
|
+
z.literal("none"),
|
|
264
|
+
rawColorValueSchema,
|
|
265
|
+
rawLinearGradientSchema,
|
|
266
|
+
rawRadialGradientSchema,
|
|
267
|
+
rawImageBackgroundSchema
|
|
268
|
+
]);
|
|
269
|
+
const backgroundValueSchema = rawBackgroundValueSchema;
|
|
270
|
+
const rawBorderStyleSchema = z.enum([
|
|
271
|
+
"solid",
|
|
272
|
+
"dashed",
|
|
273
|
+
"dotted"
|
|
274
|
+
]);
|
|
275
|
+
const borderStyleSchema = rawBorderStyleSchema;
|
|
276
|
+
const borderObjectRawSchema = z.strictObject({
|
|
277
|
+
color: rawColorValueSchema,
|
|
278
|
+
width: z.number().finite().nonnegative().optional(),
|
|
279
|
+
style: rawBorderStyleSchema.optional()
|
|
280
|
+
});
|
|
281
|
+
const borderObjectShape = borderObjectRawSchema.shape;
|
|
282
|
+
const rawBorderObjectSchema = borderObjectRawSchema.readonly();
|
|
283
|
+
const borderObjectSchema = rawBorderObjectSchema;
|
|
284
|
+
const rawBorderValueSchema = z.union([z.literal("none"), rawBorderObjectSchema]);
|
|
285
|
+
const borderValueSchema = rawBorderValueSchema;
|
|
286
|
+
const rawShadowSchema = z.strictObject({
|
|
287
|
+
color: rawColorValueSchema.optional(),
|
|
179
288
|
blur: z.number().finite().nonnegative().optional(),
|
|
180
289
|
distance: z.number().finite().nonnegative().optional(),
|
|
181
290
|
angle: z.number().finite().optional()
|
|
182
291
|
}).readonly();
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
z.strictObject({ image: z.union([
|
|
190
|
-
z.string(),
|
|
191
|
-
z.instanceof(URL),
|
|
192
|
-
uint8ArraySchema
|
|
193
|
-
]) }).readonly()
|
|
194
|
-
]).optional(),
|
|
195
|
-
borderColor: colorValueSchema.optional(),
|
|
196
|
-
borderWidth: z.number().finite().optional(),
|
|
197
|
-
borderStyle: z.enum([
|
|
198
|
-
"solid",
|
|
199
|
-
"dashed",
|
|
200
|
-
"dotted"
|
|
201
|
-
]).optional(),
|
|
292
|
+
const shadowSchema = rawShadowSchema;
|
|
293
|
+
const rawBoxShadowValueSchema = z.union([z.literal("none"), rawShadowSchema]);
|
|
294
|
+
const boxShadowValueSchema = rawBoxShadowValueSchema;
|
|
295
|
+
const visualStyleObjectSchema = z.strictObject({
|
|
296
|
+
background: rawBackgroundValueSchema.optional(),
|
|
297
|
+
border: rawBorderValueSchema.optional(),
|
|
202
298
|
borderRadius: z.number().finite().optional(),
|
|
203
299
|
opacity: z.number().finite().optional(),
|
|
204
|
-
boxShadow:
|
|
300
|
+
boxShadow: rawBoxShadowValueSchema.optional(),
|
|
205
301
|
softEdge: z.number().finite().optional(),
|
|
206
|
-
rotate: z.number().finite().optional()
|
|
207
|
-
|
|
302
|
+
rotate: z.number().finite().optional(),
|
|
303
|
+
flipH: z.boolean().optional(),
|
|
304
|
+
flipV: z.boolean().optional()
|
|
305
|
+
});
|
|
306
|
+
const visualStyleShape = visualStyleObjectSchema.shape;
|
|
307
|
+
visualStyleObjectSchema.readonly();
|
|
208
308
|
const bcp47LangSchema = z.string().refine((value) => value.trim() !== "" && /^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$/.test(value), "Text language must be a valid BCP 47 language tag").refine((value) => {
|
|
209
309
|
try {
|
|
210
310
|
const canonical = Intl.getCanonicalLocales(value);
|
|
@@ -213,12 +313,21 @@ const bcp47LangSchema = z.string().refine((value) => value.trim() !== "" && /^[A
|
|
|
213
313
|
return false;
|
|
214
314
|
}
|
|
215
315
|
}, "Text language must be a valid BCP 47 language tag");
|
|
316
|
+
const textFillSchema = z.union([
|
|
317
|
+
rawColorValueSchema,
|
|
318
|
+
rawLinearGradientSchema,
|
|
319
|
+
rawRadialGradientSchema
|
|
320
|
+
]).refine((value) => !isTextGradient(value) || value.stops.length >= 2 && value.stops.every(({ position }) => position >= 0 && position <= 1), "Text gradients require at least two stops with positions between 0 and 1");
|
|
321
|
+
function isTextGradient(value) {
|
|
322
|
+
return record(value) && (value["type"] === "linear-gradient" || value["type"] === "radial-gradient");
|
|
323
|
+
}
|
|
216
324
|
const textStyleObjectSchema = z.strictObject({
|
|
217
|
-
fontFamily:
|
|
325
|
+
fontFamily: rawFontReferenceSchema.optional(),
|
|
326
|
+
eastAsianFontFamily: rawFontReferenceSchema.optional(),
|
|
218
327
|
fontSize: validatedFontSizeSchema.optional(),
|
|
219
328
|
fontWeight: fontWeightSchema.optional(),
|
|
220
|
-
fontStyle:
|
|
221
|
-
color:
|
|
329
|
+
fontStyle: rawFontFaceStyleSchema.optional(),
|
|
330
|
+
color: textFillSchema.optional(),
|
|
222
331
|
lineHeight: validatedLineHeightSchema.optional(),
|
|
223
332
|
verticalAlign: z.enum([
|
|
224
333
|
"top",
|
|
@@ -226,7 +335,7 @@ const textStyleObjectSchema = z.strictObject({
|
|
|
226
335
|
"bottom"
|
|
227
336
|
]).optional(),
|
|
228
337
|
/** Paragraph alignment when not explicitly overridden. */
|
|
229
|
-
align:
|
|
338
|
+
align: rawTextAlignmentSchema.optional(),
|
|
230
339
|
/** Paragraph space-after when not explicitly overridden, in pixels. */
|
|
231
340
|
spacingAfter: z.number().finite().nonnegative().refine((value) => {
|
|
232
341
|
const centipoints = Math.round(value * 75);
|
|
@@ -243,7 +352,12 @@ const textStyleObjectSchema = z.strictObject({
|
|
|
243
352
|
"underline",
|
|
244
353
|
"line-through"
|
|
245
354
|
]).optional(),
|
|
246
|
-
|
|
355
|
+
textStroke: rawBorderValueSchema.refine((value) => {
|
|
356
|
+
if (value === "none" || value.width === void 0 || value.width === 0) return true;
|
|
357
|
+
const emu = Math.round(value.width * 9525);
|
|
358
|
+
return emu >= 1 && emu <= 20116800;
|
|
359
|
+
}, "textStroke width is outside the DrawingML line width range").optional(),
|
|
360
|
+
textShadow: z.union([rawShadowSchema, z.literal("none")]).optional(),
|
|
247
361
|
/** Whether the text box wraps normally or keeps each line on a single line. */
|
|
248
362
|
textWrap: z.enum(["normal", "nowrap"]).optional(),
|
|
249
363
|
/** Natural language (BCP 47 language tag, e.g. zh-CN, en-US). */
|
|
@@ -252,10 +366,10 @@ const textStyleObjectSchema = z.strictObject({
|
|
|
252
366
|
const textStyleShape = textStyleObjectSchema.shape;
|
|
253
367
|
/** Inheritable text style fields shared across text objects and containers. */
|
|
254
368
|
const textStyleSchema = textStyleObjectSchema.readonly();
|
|
255
|
-
const
|
|
369
|
+
const rawFormatColorTransformSchema = z.strictObject({
|
|
256
370
|
color: z.union([
|
|
257
371
|
z.literal("phClr"),
|
|
258
|
-
|
|
372
|
+
rawSchemeColorNameSchema,
|
|
259
373
|
z.string()
|
|
260
374
|
]),
|
|
261
375
|
alpha: z.number().finite().min(0).max(1).optional(),
|
|
@@ -265,20 +379,20 @@ const formatColorTransformSchema = z.strictObject({
|
|
|
265
379
|
shade: z.number().finite().min(0).max(1).optional(),
|
|
266
380
|
satMod: z.number().finite().min(0).optional()
|
|
267
381
|
}).readonly();
|
|
268
|
-
const
|
|
382
|
+
const rawFormatGradientStopSchema = z.strictObject({
|
|
269
383
|
position: z.number().finite().min(0).max(1),
|
|
270
|
-
color:
|
|
384
|
+
color: rawFormatColorTransformSchema
|
|
271
385
|
}).readonly();
|
|
272
|
-
const
|
|
386
|
+
const rawFormatFillStyleSchema = z.union([
|
|
273
387
|
z.strictObject({ kind: z.literal("none") }).readonly(),
|
|
274
388
|
z.strictObject({
|
|
275
389
|
kind: z.literal("solid"),
|
|
276
|
-
color:
|
|
390
|
+
color: rawFormatColorTransformSchema
|
|
277
391
|
}).readonly(),
|
|
278
392
|
z.strictObject({
|
|
279
393
|
kind: z.literal("gradient"),
|
|
280
394
|
rotWithShape: z.boolean().optional(),
|
|
281
|
-
stops: z.array(
|
|
395
|
+
stops: z.array(rawFormatGradientStopSchema).readonly(),
|
|
282
396
|
linear: z.strictObject({
|
|
283
397
|
angle: z.number().finite(),
|
|
284
398
|
scaled: z.boolean().optional()
|
|
@@ -298,7 +412,7 @@ const formatFillStyleSchema = z.union([
|
|
|
298
412
|
}).readonly().optional()
|
|
299
413
|
}).readonly()
|
|
300
414
|
]);
|
|
301
|
-
const
|
|
415
|
+
const rawFormatLineStyleSchema = z.strictObject({
|
|
302
416
|
widthEmu: z.number().int().nonnegative().optional(),
|
|
303
417
|
cap: z.enum([
|
|
304
418
|
"rnd",
|
|
@@ -314,93 +428,96 @@ const formatLineStyleSchema = z.strictObject({
|
|
|
314
428
|
]).optional(),
|
|
315
429
|
align: z.enum(["ctr", "in"]).optional(),
|
|
316
430
|
dash: z.string().optional(),
|
|
317
|
-
fill:
|
|
431
|
+
fill: rawFormatFillStyleSchema.optional()
|
|
318
432
|
}).readonly();
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
const formatSchemeSchema = z.strictObject({
|
|
433
|
+
const rawFormatEffectStyleSchema = z.strictObject({ shadow: rawShadowSchema.optional() }).readonly();
|
|
434
|
+
const rawFormatSchemeSchema = z.strictObject({
|
|
322
435
|
name: z.string().optional(),
|
|
323
|
-
fillStyles: z.array(
|
|
324
|
-
lineStyles: z.array(
|
|
325
|
-
effectStyles: z.array(
|
|
326
|
-
bgFillStyles: z.array(
|
|
436
|
+
fillStyles: z.array(rawFormatFillStyleSchema).readonly().optional(),
|
|
437
|
+
lineStyles: z.array(rawFormatLineStyleSchema).readonly().optional(),
|
|
438
|
+
effectStyles: z.array(rawFormatEffectStyleSchema).readonly().optional(),
|
|
439
|
+
bgFillStyles: z.array(rawFormatFillStyleSchema).readonly().optional()
|
|
327
440
|
}).readonly();
|
|
328
|
-
/**
|
|
441
|
+
/** DrawingML `<a:fmtScheme>` style matrix stored on a native theme or theme override. */
|
|
442
|
+
const formatSchemeSchema = rawFormatSchemeSchema;
|
|
443
|
+
/** Deck-level or master-level theme input; major/minor fonts and 12 native color slots are written to native PPTX theme. */
|
|
329
444
|
const themeInputSchema = z.strictObject({
|
|
330
445
|
name: z.string().optional(),
|
|
331
|
-
colors: z.
|
|
332
|
-
dk1:
|
|
333
|
-
lt1:
|
|
334
|
-
dk2:
|
|
335
|
-
lt2:
|
|
336
|
-
accent1:
|
|
337
|
-
accent2:
|
|
338
|
-
accent3:
|
|
339
|
-
accent4:
|
|
340
|
-
accent5:
|
|
341
|
-
accent6:
|
|
342
|
-
hlink:
|
|
343
|
-
folHlink:
|
|
344
|
-
}).
|
|
345
|
-
fonts: z.
|
|
346
|
-
major:
|
|
347
|
-
minor:
|
|
348
|
-
|
|
349
|
-
|
|
446
|
+
colors: z.strictObject({
|
|
447
|
+
dk1: rawThemeHexColorSchema.optional(),
|
|
448
|
+
lt1: rawThemeHexColorSchema.optional(),
|
|
449
|
+
dk2: rawThemeHexColorSchema.optional(),
|
|
450
|
+
lt2: rawThemeHexColorSchema.optional(),
|
|
451
|
+
accent1: rawThemeHexColorSchema.optional(),
|
|
452
|
+
accent2: rawThemeHexColorSchema.optional(),
|
|
453
|
+
accent3: rawThemeHexColorSchema.optional(),
|
|
454
|
+
accent4: rawThemeHexColorSchema.optional(),
|
|
455
|
+
accent5: rawThemeHexColorSchema.optional(),
|
|
456
|
+
accent6: rawThemeHexColorSchema.optional(),
|
|
457
|
+
hlink: rawThemeHexColorSchema.optional(),
|
|
458
|
+
folHlink: rawThemeHexColorSchema.optional()
|
|
459
|
+
}).readonly().optional(),
|
|
460
|
+
fonts: z.strictObject({
|
|
461
|
+
major: rawThemeFontValueSchema.optional(),
|
|
462
|
+
minor: rawThemeFontValueSchema.optional(),
|
|
463
|
+
majorEastAsian: rawThemeFontValueSchema.optional(),
|
|
464
|
+
minorEastAsian: rawThemeFontValueSchema.optional()
|
|
465
|
+
}).readonly().optional(),
|
|
466
|
+
formatScheme: rawFormatSchemeSchema.optional()
|
|
350
467
|
}).readonly();
|
|
351
|
-
/** Native `<a:themeOverride>` partial override for a
|
|
468
|
+
/** Native `<a:themeOverride>` partial override for a layout, slide, or chart. */
|
|
352
469
|
const themeOverrideSchema = z.strictObject({
|
|
353
470
|
colors: z.strictObject({
|
|
354
|
-
dk1:
|
|
355
|
-
lt1:
|
|
356
|
-
dk2:
|
|
357
|
-
lt2:
|
|
358
|
-
accent1:
|
|
359
|
-
accent2:
|
|
360
|
-
accent3:
|
|
361
|
-
accent4:
|
|
362
|
-
accent5:
|
|
363
|
-
accent6:
|
|
364
|
-
hlink:
|
|
365
|
-
folHlink:
|
|
471
|
+
dk1: rawThemeHexColorSchema.optional(),
|
|
472
|
+
lt1: rawThemeHexColorSchema.optional(),
|
|
473
|
+
dk2: rawThemeHexColorSchema.optional(),
|
|
474
|
+
lt2: rawThemeHexColorSchema.optional(),
|
|
475
|
+
accent1: rawThemeHexColorSchema.optional(),
|
|
476
|
+
accent2: rawThemeHexColorSchema.optional(),
|
|
477
|
+
accent3: rawThemeHexColorSchema.optional(),
|
|
478
|
+
accent4: rawThemeHexColorSchema.optional(),
|
|
479
|
+
accent5: rawThemeHexColorSchema.optional(),
|
|
480
|
+
accent6: rawThemeHexColorSchema.optional(),
|
|
481
|
+
hlink: rawThemeHexColorSchema.optional(),
|
|
482
|
+
folHlink: rawThemeHexColorSchema.optional()
|
|
366
483
|
}).readonly().optional(),
|
|
367
484
|
fonts: z.strictObject({
|
|
368
|
-
major:
|
|
369
|
-
minor:
|
|
485
|
+
major: rawThemeFontValueSchema.optional(),
|
|
486
|
+
minor: rawThemeFontValueSchema.optional(),
|
|
487
|
+
majorEastAsian: rawThemeFontValueSchema.optional(),
|
|
488
|
+
minorEastAsian: rawThemeFontValueSchema.optional()
|
|
370
489
|
}).readonly().optional(),
|
|
371
|
-
formatScheme:
|
|
490
|
+
formatScheme: rawFormatSchemeSchema.optional()
|
|
372
491
|
}).readonly();
|
|
373
|
-
const
|
|
492
|
+
const rawThemeDataSchema = z.strictObject({
|
|
374
493
|
name: z.string(),
|
|
375
|
-
colors: z.
|
|
376
|
-
dk1:
|
|
377
|
-
lt1:
|
|
378
|
-
dk2:
|
|
379
|
-
lt2:
|
|
380
|
-
accent1:
|
|
381
|
-
accent2:
|
|
382
|
-
accent3:
|
|
383
|
-
accent4:
|
|
384
|
-
accent5:
|
|
385
|
-
accent6:
|
|
386
|
-
hlink:
|
|
387
|
-
folHlink:
|
|
388
|
-
}).
|
|
389
|
-
fonts: z.
|
|
390
|
-
major:
|
|
391
|
-
minor:
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}).readonly()
|
|
395
|
-
|
|
396
|
-
/** Local theme scopes on slides or containers can only override color and font tokens already present in the deck. */
|
|
397
|
-
const themeScopeSchema = z.strictObject({
|
|
398
|
-
colors: z.record(z.string(), themeColorSchema).readonly().optional(),
|
|
399
|
-
fonts: z.record(z.string(), fontTokenSchema).readonly().optional()
|
|
494
|
+
colors: z.strictObject({
|
|
495
|
+
dk1: rawThemeHexColorSchema,
|
|
496
|
+
lt1: rawThemeHexColorSchema,
|
|
497
|
+
dk2: rawThemeHexColorSchema,
|
|
498
|
+
lt2: rawThemeHexColorSchema,
|
|
499
|
+
accent1: rawThemeHexColorSchema,
|
|
500
|
+
accent2: rawThemeHexColorSchema,
|
|
501
|
+
accent3: rawThemeHexColorSchema,
|
|
502
|
+
accent4: rawThemeHexColorSchema,
|
|
503
|
+
accent5: rawThemeHexColorSchema,
|
|
504
|
+
accent6: rawThemeHexColorSchema,
|
|
505
|
+
hlink: rawThemeHexColorSchema,
|
|
506
|
+
folHlink: rawThemeHexColorSchema
|
|
507
|
+
}).readonly(),
|
|
508
|
+
fonts: z.strictObject({
|
|
509
|
+
major: rawThemeFontValueSchema,
|
|
510
|
+
minor: rawThemeFontValueSchema,
|
|
511
|
+
majorEastAsian: rawThemeFontValueSchema.optional(),
|
|
512
|
+
minorEastAsian: rawThemeFontValueSchema.optional()
|
|
513
|
+
}).readonly(),
|
|
514
|
+
formatScheme: rawFormatSchemeSchema.optional()
|
|
400
515
|
}).readonly();
|
|
516
|
+
const themeDataSchema = rawThemeDataSchema;
|
|
517
|
+
const themeSchema = rawThemeDataSchema.transform((data) => defineTheme(data));
|
|
401
518
|
z.strictObject({
|
|
402
519
|
family: z.string(),
|
|
403
|
-
font:
|
|
520
|
+
font: rawFontSchema.optional(),
|
|
404
521
|
themeFont: z.enum(["major", "minor"]).optional()
|
|
405
522
|
}).readonly();
|
|
406
523
|
const officeColors = {
|
|
@@ -418,22 +535,26 @@ const officeColors = {
|
|
|
418
535
|
folHlink: "#800080"
|
|
419
536
|
};
|
|
420
537
|
const contextRecords = /* @__PURE__ */ new WeakMap();
|
|
538
|
+
/** Reads the combined native overrides for writers that need to materialize a complete scheme. */
|
|
539
|
+
function themeContextOverride(context) {
|
|
540
|
+
return contextRecords.get(context);
|
|
541
|
+
}
|
|
421
542
|
const textStyleKeys = new Set(Object.keys(textStyleObjectSchema.shape));
|
|
422
543
|
function textStyleErrorForIssue(issue, rawStyle) {
|
|
423
544
|
const field = issue?.path[0];
|
|
424
|
-
if (field === "fontFamily") {
|
|
425
|
-
if (issue?.path[1] === "faces") return new CapabilityError("invalid-font-face", "Font.faces contains invalid weight, style, or resource");
|
|
426
|
-
return new CapabilityError("invalid-font-family", issue?.message ??
|
|
545
|
+
if (field === "fontFamily" || field === "eastAsianFontFamily") {
|
|
546
|
+
if (issue?.path[1] === "faces" || issue?.code === "invalid_union" && issue.errors.some((branch) => branch.some((sub) => sub.path[0] === "faces"))) return new CapabilityError("invalid-font-face", "Font.faces contains invalid weight, style, or resource", void 0, { field: zodIssueField(issue, "style") });
|
|
547
|
+
return new CapabilityError("invalid-font-family", issue?.message ?? `${field} must be a font value or non-empty family string`, void 0, { field: zodIssueField(issue, "style") });
|
|
427
548
|
}
|
|
428
549
|
if (field === "fontSize") {
|
|
429
550
|
const raw = rawStyle["fontSize"];
|
|
430
551
|
const validLengthSyntax = typeof raw === "number" || typeof raw === "string" && textLengthPattern.test(raw);
|
|
431
552
|
return new CapabilityError(validLengthSyntax ? "invalid-font-size" : "invalid-text-length", validLengthSyntax ? "fontSize must be greater than 0 and within DrawingML range of 1 to 4000pt" : "fontSize must be a positive pixel value or px/pt length");
|
|
432
553
|
}
|
|
433
|
-
if (field === "fontWeight") return new CapabilityError("invalid-font-weight", "fontWeight must be normal, bold, or
|
|
434
|
-
if (field === "fontStyle") return new CapabilityError("invalid-font-style", "fontStyle must be normal or italic");
|
|
435
|
-
if (field === "color") return new CapabilityError("invalid-color", "Invalid color value format");
|
|
436
|
-
if (field === "lineHeight") return new CapabilityError("invalid-text-length", "lineHeight must be a positive pixel value
|
|
554
|
+
if (field === "fontWeight") return new CapabilityError("invalid-font-weight", "fontWeight must be normal, bold, or an integer between 1 and 1000", void 0, { field: "style.fontWeight" });
|
|
555
|
+
if (field === "fontStyle") return new CapabilityError("invalid-font-style", "fontStyle must be normal or italic", void 0, { field: "style.fontStyle" });
|
|
556
|
+
if (field === "color") return new CapabilityError("invalid-color", "Invalid color value format", void 0, { field: "style.color" });
|
|
557
|
+
if (field === "lineHeight") return new CapabilityError("invalid-text-length", "lineHeight must be a positive pixel value, px/pt length within 0 to 1584pt, or percentage within 0% to 13200%");
|
|
437
558
|
if (field === "verticalAlign") return new CapabilityError("invalid-vertical-align", "verticalAlign must be top, middle, or bottom");
|
|
438
559
|
if (field === "align") return new CapabilityError("invalid-text-alignment", "align must be left, center, right, or justify");
|
|
439
560
|
if (field === "spacingAfter") return new CapabilityError("invalid-paragraph-spacing", "spacingAfter must be a finite non-negative pixel number within DrawingML range of 0 to 1584pt");
|
|
@@ -441,7 +562,10 @@ function textStyleErrorForIssue(issue, rawStyle) {
|
|
|
441
562
|
if (field === "textTransform") return new CapabilityError("invalid-text-transform", "textTransform must be none or uppercase");
|
|
442
563
|
if (field === "textDecoration") return new CapabilityError("invalid-text-decoration", "textDecoration must be none, underline, or line-through");
|
|
443
564
|
if (field === "textWrap") return new CapabilityError("invalid-text-wrap", "textWrap must be normal or nowrap");
|
|
444
|
-
if (field === "textShadow")
|
|
565
|
+
if (field === "textShadow") {
|
|
566
|
+
if (issue?.path[1] === "color") return new CapabilityError("invalid-color", "Invalid color value format", void 0, { field: "style.textShadow.color" });
|
|
567
|
+
return new CapabilityError("invalid-shadow", issue?.message ?? "textShadow must be a shadow object or 'none'");
|
|
568
|
+
}
|
|
445
569
|
if (field === "lang") return new CapabilityError("invalid-text-lang", `Text language must be a valid BCP 47 language tag: ${String(rawStyle["lang"])}`);
|
|
446
570
|
return new CapabilityError("invalid-style", issue?.message ?? "Invalid text style");
|
|
447
571
|
}
|
|
@@ -453,14 +577,21 @@ function validateTextStyle(style, theme) {
|
|
|
453
577
|
for (const [key, item] of Object.entries(style)) if (textStyleKeys.has(key) && item !== void 0) candidate[key] = item;
|
|
454
578
|
const parsed = textStyleObjectSchema.safeParse(candidate);
|
|
455
579
|
if (!parsed.success) throw textStyleErrorForIssue(parsed.error.issues[0], candidate);
|
|
456
|
-
|
|
457
|
-
if (theme !== void 0) {
|
|
458
|
-
if (typeof validated.fontFamily === "string") theme.resolveFont(validated.fontFamily);
|
|
459
|
-
if (validated.color !== void 0) theme.resolveColor(validated.color);
|
|
460
|
-
if (validated.textShadow !== void 0 && validated.textShadow !== "none" && validated.textShadow.color !== void 0) theme.resolveColor(validated.textShadow.color);
|
|
461
|
-
}
|
|
580
|
+
validateTextStyleTheme(parsed.data, theme);
|
|
462
581
|
return style;
|
|
463
582
|
}
|
|
583
|
+
/** Checks references against the active theme after the host's text style schema has validated their shape. */
|
|
584
|
+
function validateTextStyleTheme(style, theme) {
|
|
585
|
+
if (theme === void 0) return;
|
|
586
|
+
if (typeof style.fontFamily === "string") theme.resolveFont(style.fontFamily);
|
|
587
|
+
if (typeof style.eastAsianFontFamily === "string") theme.resolveEastAsianFont(style.eastAsianFontFamily);
|
|
588
|
+
if (style.color !== void 0) {
|
|
589
|
+
if (isTextGradient(style.color)) for (const stop of style.color.stops) theme.resolveColor(stop.color);
|
|
590
|
+
else theme.resolveColor(style.color);
|
|
591
|
+
}
|
|
592
|
+
if (style.textStroke !== void 0 && style.textStroke !== "none") theme.resolveColor(style.textStroke.color);
|
|
593
|
+
if (style.textShadow !== void 0 && style.textShadow !== "none" && style.textShadow.color !== void 0) theme.resolveColor(style.textShadow.color);
|
|
594
|
+
}
|
|
464
595
|
/**
|
|
465
596
|
* Asserts that a value is a valid BCP 47 language tag.
|
|
466
597
|
* Rejects non-string values, empty or whitespace strings, and malformed tags.
|
|
@@ -499,7 +630,7 @@ function isSchemeColorName(value) {
|
|
|
499
630
|
function isFont(value) {
|
|
500
631
|
return record(value) && typeof value["family"] === "string";
|
|
501
632
|
}
|
|
502
|
-
const themeBrandSymbol = Symbol.for("
|
|
633
|
+
const themeBrandSymbol = Symbol.for("#/kernel/theme.ts");
|
|
503
634
|
/** Checks whether a runtime value is an identity-bearing `Theme` instance produced by `defineTheme`. */
|
|
504
635
|
function isTheme(value) {
|
|
505
636
|
return typeof value === "object" && value !== null && themeBrandSymbol in value;
|
|
@@ -556,7 +687,8 @@ var NativeThemeRecord = class {
|
|
|
556
687
|
const parsed = themeInputSchema.safeParse(patch);
|
|
557
688
|
if (!parsed.success) {
|
|
558
689
|
const issue = parsed.error.issues[0];
|
|
559
|
-
|
|
690
|
+
const field = zodIssueField(issue, "theme");
|
|
691
|
+
throw new CapabilityError("invalid-theme", issue?.message ?? "Invalid theme declaration", void 0, { field });
|
|
560
692
|
}
|
|
561
693
|
const validPatch = parsed.data;
|
|
562
694
|
if (validPatch.name !== void 0) this.#name = validPatch.name;
|
|
@@ -564,10 +696,11 @@ var NativeThemeRecord = class {
|
|
|
564
696
|
...this.#colors,
|
|
565
697
|
...validPatch.colors
|
|
566
698
|
});
|
|
567
|
-
if (validPatch.fonts !== void 0)
|
|
568
|
-
...this.#fonts
|
|
569
|
-
|
|
570
|
-
|
|
699
|
+
if (validPatch.fonts !== void 0) {
|
|
700
|
+
const mergedFonts = { ...this.#fonts };
|
|
701
|
+
for (const [key, value] of Object.entries(validPatch.fonts)) if (value !== void 0) mergedFonts[key] = value;
|
|
702
|
+
this.#fonts = snapshotValue(mergedFonts);
|
|
703
|
+
}
|
|
571
704
|
if (validPatch.formatScheme !== void 0) {
|
|
572
705
|
const hadFormatScheme = Object.hasOwn(this, "formatScheme");
|
|
573
706
|
this.#formatScheme = snapshotValue(validPatch.formatScheme);
|
|
@@ -585,7 +718,8 @@ function parseThemeInputData(input = {}) {
|
|
|
585
718
|
const parsed = themeInputSchema.safeParse(input);
|
|
586
719
|
if (!parsed.success) {
|
|
587
720
|
const issue = parsed.error.issues[0];
|
|
588
|
-
|
|
721
|
+
const field = zodIssueField(issue, "theme");
|
|
722
|
+
throw new CapabilityError("invalid-theme", issue?.message ?? "Invalid theme declaration", void 0, { field });
|
|
589
723
|
}
|
|
590
724
|
const validInput = parsed.data;
|
|
591
725
|
const colors = snapshotValue({
|
|
@@ -593,9 +727,10 @@ function parseThemeInputData(input = {}) {
|
|
|
593
727
|
...validInput.colors
|
|
594
728
|
});
|
|
595
729
|
const fonts = snapshotValue({
|
|
596
|
-
...validInput.fonts,
|
|
597
730
|
major: validInput.fonts?.major ?? "Aptos Display",
|
|
598
|
-
minor: validInput.fonts?.minor ?? "Aptos"
|
|
731
|
+
minor: validInput.fonts?.minor ?? "Aptos",
|
|
732
|
+
...validInput.fonts?.majorEastAsian === void 0 ? {} : { majorEastAsian: validInput.fonts.majorEastAsian },
|
|
733
|
+
...validInput.fonts?.minorEastAsian === void 0 ? {} : { minorEastAsian: validInput.fonts.minorEastAsian }
|
|
599
734
|
});
|
|
600
735
|
const formatScheme = validInput.formatScheme === void 0 ? void 0 : snapshotValue(validInput.formatScheme);
|
|
601
736
|
return {
|
|
@@ -633,28 +768,6 @@ function lighter(slot, amount) {
|
|
|
633
768
|
function isNativeColorSlot(value) {
|
|
634
769
|
return nativeSlot(value);
|
|
635
770
|
}
|
|
636
|
-
function scopeValue(context, name) {
|
|
637
|
-
let current = context;
|
|
638
|
-
while (current !== void 0) {
|
|
639
|
-
const scope = contextRecords.get(current)?.scope;
|
|
640
|
-
if (scope?.colors !== void 0 && Object.hasOwn(scope.colors, name)) return {
|
|
641
|
-
value: scope.colors[name],
|
|
642
|
-
...contextRecords.get(current)?.parent === void 0 ? {} : { parent: contextRecords.get(current).parent }
|
|
643
|
-
};
|
|
644
|
-
current = contextRecords.get(current)?.parent;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
function scopeFontValue(context, name) {
|
|
648
|
-
let current = context;
|
|
649
|
-
while (current !== void 0) {
|
|
650
|
-
const scope = contextRecords.get(current)?.scope;
|
|
651
|
-
if (scope?.fonts !== void 0 && Object.hasOwn(scope.fonts, name)) return {
|
|
652
|
-
value: scope.fonts[name],
|
|
653
|
-
...contextRecords.get(current)?.parent === void 0 ? {} : { parent: contextRecords.get(current).parent }
|
|
654
|
-
};
|
|
655
|
-
current = contextRecords.get(current)?.parent;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
771
|
function rgbChannelsFromHex(hex) {
|
|
659
772
|
return [
|
|
660
773
|
0,
|
|
@@ -759,52 +872,49 @@ function checkedFraction(value, label) {
|
|
|
759
872
|
return value;
|
|
760
873
|
}
|
|
761
874
|
function effectiveThemeColor(context, slot) {
|
|
762
|
-
return contextRecords.get(context)?.
|
|
875
|
+
return contextRecords.get(context)?.colors?.[slot] ?? context.theme.colors[slot];
|
|
876
|
+
}
|
|
877
|
+
function parseThemeHexValue(raw) {
|
|
878
|
+
const digits = raw.trim().slice(1);
|
|
879
|
+
const expanded = digits.length === 3 || digits.length === 4 ? digits.split("").map((digit) => digit + digit).join("") : digits;
|
|
880
|
+
if (!/^[0-9a-f]{6}([0-9a-f]{2})?$/iu.test(expanded)) throw new CapabilityError("invalid-color", `Invalid color value: ${raw}`);
|
|
881
|
+
const alpha = expanded.length === 8 ? Number.parseInt(expanded.slice(6), 16) / 255 : void 0;
|
|
882
|
+
return {
|
|
883
|
+
hex: expanded.slice(0, 6).toUpperCase(),
|
|
884
|
+
...alpha === void 0 || alpha === 1 ? {} : { alpha }
|
|
885
|
+
};
|
|
763
886
|
}
|
|
764
|
-
function resolveColorName(raw, context
|
|
765
|
-
if (depth > 16) throw new CapabilityError("invalid-color", `Circular color token reference: ${raw}`);
|
|
887
|
+
function resolveColorName(raw, context) {
|
|
766
888
|
const value = raw.trim();
|
|
767
|
-
if (value.startsWith("#"))
|
|
768
|
-
const digits = value.slice(1);
|
|
769
|
-
const expanded = digits.length === 3 || digits.length === 4 ? digits.split("").map((digit) => digit + digit).join("") : digits;
|
|
770
|
-
if (!/^[0-9a-f]{6}([0-9a-f]{2})?$/iu.test(expanded)) throw new CapabilityError("invalid-color", `Invalid color value: ${raw}`);
|
|
771
|
-
const alpha = expanded.length === 8 ? Number.parseInt(expanded.slice(6), 16) / 255 : void 0;
|
|
772
|
-
return {
|
|
773
|
-
hex: expanded.slice(0, 6).toUpperCase(),
|
|
774
|
-
...alpha === void 0 || alpha === 1 ? {} : { alpha }
|
|
775
|
-
};
|
|
776
|
-
}
|
|
889
|
+
if (value.startsWith("#")) return parseThemeHexValue(value);
|
|
777
890
|
if (schemeSlot(value)) {
|
|
778
891
|
const mappedSlot = context.colorMap[value];
|
|
892
|
+
const configured = effectiveThemeColor(context, mappedSlot);
|
|
893
|
+
if (!configured.trim().startsWith("#")) throw new CapabilityError("invalid-color", `Invalid color value: ${configured}`);
|
|
779
894
|
return {
|
|
780
|
-
...
|
|
895
|
+
...parseThemeHexValue(configured),
|
|
781
896
|
slot: mappedSlot,
|
|
782
897
|
scheme: value
|
|
783
898
|
};
|
|
784
899
|
}
|
|
785
|
-
if (nativeSlot(value))
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
}
|
|
796
|
-
function
|
|
797
|
-
|
|
798
|
-
while (contextRecords.get(current)?.parent !== void 0) current = contextRecords.get(current).parent;
|
|
799
|
-
return current;
|
|
800
|
-
}
|
|
801
|
-
function resolveColorValue(value, context, depth) {
|
|
802
|
-
if (typeof value === "string") return resolveColorName(value, context, depth);
|
|
900
|
+
if (nativeSlot(value)) {
|
|
901
|
+
const configured = effectiveThemeColor(context, value);
|
|
902
|
+
if (!configured.trim().startsWith("#")) throw new CapabilityError("invalid-color", `Invalid color value: ${configured}`);
|
|
903
|
+
return {
|
|
904
|
+
...parseThemeHexValue(configured),
|
|
905
|
+
slot: value,
|
|
906
|
+
scheme: value
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
throw new CapabilityError("invalid-color", `Unknown color or scheme color slot: ${raw}`);
|
|
910
|
+
}
|
|
911
|
+
function resolveColorValue(value, context) {
|
|
912
|
+
if (typeof value === "string") return resolveColorName(value, context);
|
|
803
913
|
if (!record(value) || !schemeColorName(String(value["slot"])) || typeof value["lumMod"] !== "number" || !Number.isFinite(value["lumMod"])) throw new CapabilityError("invalid-color", "Invalid theme shade value");
|
|
804
914
|
const lumMod = checkedFraction(value["lumMod"], "lumMod");
|
|
805
915
|
const lumOff = value["lumOff"] === void 0 ? void 0 : checkedFraction(value["lumOff"], "lumOff");
|
|
806
916
|
const scheme = value["slot"];
|
|
807
|
-
const base = resolveColorName(scheme, context
|
|
917
|
+
const base = resolveColorName(scheme, context);
|
|
808
918
|
return {
|
|
809
919
|
hex: shadeHex(base.hex, lumMod, lumOff ?? 0),
|
|
810
920
|
...base.slot === void 0 ? {} : { slot: base.slot },
|
|
@@ -813,16 +923,19 @@ function resolveColorValue(value, context, depth) {
|
|
|
813
923
|
...lumOff === void 0 ? {} : { lumOff }
|
|
814
924
|
};
|
|
815
925
|
}
|
|
926
|
+
function definedThemeSlots(slots) {
|
|
927
|
+
return Object.fromEntries(Object.entries(slots ?? {}).filter(([, value]) => value !== void 0));
|
|
928
|
+
}
|
|
816
929
|
function mergeThemeOverrides(base, next) {
|
|
817
930
|
if (base === void 0) return next;
|
|
818
931
|
if (next === void 0) return base;
|
|
819
932
|
const colors = base.colors === void 0 && next.colors === void 0 ? void 0 : {
|
|
820
933
|
...base.colors,
|
|
821
|
-
...next.colors
|
|
934
|
+
...definedThemeSlots(next.colors)
|
|
822
935
|
};
|
|
823
936
|
const fonts = base.fonts === void 0 && next.fonts === void 0 ? void 0 : {
|
|
824
937
|
...base.fonts,
|
|
825
|
-
...next.fonts
|
|
938
|
+
...definedThemeSlots(next.fonts)
|
|
826
939
|
};
|
|
827
940
|
const formatScheme = next.formatScheme ?? base.formatScheme;
|
|
828
941
|
return Object.freeze({
|
|
@@ -831,7 +944,7 @@ function mergeThemeOverrides(base, next) {
|
|
|
831
944
|
...formatScheme === void 0 ? {} : { formatScheme }
|
|
832
945
|
});
|
|
833
946
|
}
|
|
834
|
-
function createContext(theme,
|
|
947
|
+
function createContext(theme, textStyle, colorMap = defaultColorMap, themeOverride) {
|
|
835
948
|
const formatScheme = themeOverride?.formatScheme ?? theme.formatScheme;
|
|
836
949
|
let context;
|
|
837
950
|
context = Object.freeze({
|
|
@@ -839,38 +952,20 @@ function createContext(theme, parent, scope, textStyle, colorMap = defaultColorM
|
|
|
839
952
|
colorMap,
|
|
840
953
|
formatScheme,
|
|
841
954
|
textStyle: Object.freeze(textStyle),
|
|
842
|
-
with(
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
const parsedScope = themeScopeSchema.safeParse(nextScope);
|
|
846
|
-
if (!parsedScope.success) throw new CapabilityError("invalid-theme-scope", parsedScope.error.issues[0]?.message ?? "Local theme scope is invalid");
|
|
847
|
-
const colors = parsedScope.data.colors;
|
|
848
|
-
for (const name of Object.keys(colors ?? {})) {
|
|
849
|
-
if (schemeColorName(name)) throw new CapabilityError("invalid-theme-scope", `Local theme scope cannot redefine native color slot ${name}`);
|
|
850
|
-
if (!Object.hasOwn(theme.colors, name)) throw new CapabilityError("invalid-theme-scope", `Theme has no color token ${name}`);
|
|
851
|
-
}
|
|
852
|
-
const fonts = parsedScope.data.fonts;
|
|
853
|
-
for (const name of Object.keys(fonts ?? {})) if (!Object.hasOwn(theme.fonts, name)) throw new CapabilityError("invalid-theme-scope", `Theme has no font token ${name}`);
|
|
854
|
-
checkedScope = Object.freeze({
|
|
855
|
-
...colors === void 0 ? {} : { colors: Object.freeze({ ...colors }) },
|
|
856
|
-
...fonts === void 0 ? {} : { fonts: Object.freeze({ ...fonts }) }
|
|
857
|
-
});
|
|
858
|
-
}
|
|
859
|
-
const candidateContext = createContext(theme, context, checkedScope, context.textStyle, colorMap, themeOverride);
|
|
860
|
-
const validated = style === void 0 ? {} : textStyleFrom(style, candidateContext);
|
|
861
|
-
const nextStyle = {
|
|
955
|
+
with(style) {
|
|
956
|
+
const validated = style === void 0 ? {} : textStyleFrom(style, context);
|
|
957
|
+
return createContext(theme, {
|
|
862
958
|
...context.textStyle,
|
|
863
959
|
...validated
|
|
864
|
-
};
|
|
865
|
-
return createContext(theme, context, checkedScope, nextStyle, colorMap, themeOverride);
|
|
960
|
+
}, colorMap, themeOverride);
|
|
866
961
|
},
|
|
867
962
|
withTextStyle(style) {
|
|
868
|
-
return createContext(theme,
|
|
963
|
+
return createContext(theme, textStyleFrom(style, context), colorMap, themeOverride);
|
|
869
964
|
},
|
|
870
965
|
withNativeOverrides(nextThemeOverride, nextColorMapOverride) {
|
|
871
966
|
const mergedOverride = mergeThemeOverrides(themeOverride, nextThemeOverride);
|
|
872
967
|
const nextColorMap = nextColorMapOverride === void 0 || nextColorMapOverride === "master" ? colorMap : nextColorMapOverride;
|
|
873
|
-
return createContext(theme, context
|
|
968
|
+
return createContext(theme, context.textStyle, nextColorMap, mergedOverride);
|
|
874
969
|
},
|
|
875
970
|
resolveColor(value) {
|
|
876
971
|
let raw;
|
|
@@ -880,7 +975,7 @@ function createContext(theme, parent, scope, textStyle, colorMap = defaultColorM
|
|
|
880
975
|
raw = value["color"];
|
|
881
976
|
alpha = value["alpha"] === void 0 ? void 0 : checkedFraction(value["alpha"], "color alpha");
|
|
882
977
|
} else throw new CapabilityError("invalid-color", "Invalid color value format");
|
|
883
|
-
const resolved = typeof raw === "string" ? resolveColorName(raw, context
|
|
978
|
+
const resolved = typeof raw === "string" ? resolveColorName(raw, context) : resolveColorValue(raw, context);
|
|
884
979
|
if (alpha === void 0) return resolved;
|
|
885
980
|
return {
|
|
886
981
|
...resolved,
|
|
@@ -892,32 +987,47 @@ function createContext(theme, parent, scope, textStyle, colorMap = defaultColorM
|
|
|
892
987
|
family: value.family,
|
|
893
988
|
font: value
|
|
894
989
|
};
|
|
895
|
-
if (typeof value !== "string" || value.trim() === "") throw new CapabilityError("invalid-font-family", "fontFamily cannot be empty");
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
990
|
+
if (typeof value !== "string" || value.trim() === "") throw new CapabilityError("invalid-font-family", "fontFamily cannot be empty", void 0, { field: "style.fontFamily" });
|
|
991
|
+
if (isThemeFontSlot(value)) {
|
|
992
|
+
const slotFont = themeOverride?.fonts?.[value] ?? theme.fonts[value];
|
|
993
|
+
if (isFont(slotFont)) return {
|
|
994
|
+
family: slotFont.family,
|
|
995
|
+
font: slotFont,
|
|
996
|
+
themeFont: value
|
|
997
|
+
};
|
|
998
|
+
return {
|
|
999
|
+
family: slotFont,
|
|
1000
|
+
themeFont: value
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
1003
|
+
return { family: value.trim() };
|
|
1004
|
+
},
|
|
1005
|
+
resolveEastAsianFont(value) {
|
|
1006
|
+
if (isFont(value)) return {
|
|
1007
|
+
family: value.family,
|
|
1008
|
+
font: value
|
|
910
1009
|
};
|
|
1010
|
+
if (typeof value !== "string" || value.trim() === "") throw new CapabilityError("invalid-font-family", "eastAsianFontFamily cannot be empty", void 0, { field: "style.eastAsianFontFamily" });
|
|
1011
|
+
if (isThemeFontSlot(value)) {
|
|
1012
|
+
const eaKey = value === "major" ? "majorEastAsian" : "minorEastAsian";
|
|
1013
|
+
const slotFont = themeOverride?.fonts?.[eaKey] ?? theme.fonts[eaKey] ?? themeOverride?.fonts?.[value] ?? theme.fonts[value];
|
|
1014
|
+
if (isFont(slotFont)) return {
|
|
1015
|
+
family: slotFont.family,
|
|
1016
|
+
font: slotFont,
|
|
1017
|
+
themeFont: value
|
|
1018
|
+
};
|
|
1019
|
+
return {
|
|
1020
|
+
family: slotFont,
|
|
1021
|
+
themeFont: value
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
return { family: value.trim() };
|
|
911
1025
|
}
|
|
912
1026
|
});
|
|
913
|
-
contextRecords.set(context,
|
|
914
|
-
...parent === void 0 ? {} : { parent },
|
|
915
|
-
...scope === void 0 ? {} : { scope },
|
|
916
|
-
...themeOverride === void 0 ? {} : { themeOverride }
|
|
917
|
-
});
|
|
1027
|
+
if (themeOverride !== void 0) contextRecords.set(context, themeOverride);
|
|
918
1028
|
return context;
|
|
919
1029
|
}
|
|
920
|
-
/** Create a theme chain unique to a single build;
|
|
1030
|
+
/** Create a theme chain unique to a single build; container text defaults do not mutate the shared theme object. */
|
|
921
1031
|
function createThemeContext(input, style, options = {}) {
|
|
922
1032
|
if (style !== void 0) {
|
|
923
1033
|
if (!record(style)) throw new CapabilityError("invalid-style", "style must be an object");
|
|
@@ -926,6 +1036,6 @@ function createThemeContext(input, style, options = {}) {
|
|
|
926
1036
|
}
|
|
927
1037
|
const theme = normalizeTheme(input);
|
|
928
1038
|
const colorMap = options.colorMap ?? defaultColorMap;
|
|
929
|
-
return createContext(theme,
|
|
1039
|
+
return createContext(theme, textStyleFrom(style, createContext(theme, {}, colorMap, options.themeOverride)), colorMap, options.themeOverride);
|
|
930
1040
|
}
|
|
931
|
-
export { applyFormatColorTransforms, assertValidLang,
|
|
1041
|
+
export { applyFormatColorTransforms, assertValidLang, backgroundValueSchema, bcp47LangSchema, borderObjectSchema, borderObjectShape, borderStyleSchema, borderValueSchema, boxShadowValueSchema, colorMapOverrideSchema, colorMapSchema, colorValueSchema, createThemeContext, darker, defaultColorMap, defaultTheme, defineTheme, fontOptionsSchema, formatSchemeSchema, imageBackgroundFitSchema, imageBackgroundObjectSchema, imageBackgroundPositionKeywordSchema, imageBackgroundPositionSchema, imageBackgroundSchema, isFont, isNativeColorSlot, isSchemeColorName, isSchemeColorSlot, isTextGradient, isTheme, isThemeFontSlot, lighter, linearGradientSchema, nativeColorSlots, radialGradientSchema, schemeColorNameSchema, schemeColorNames, schemeColorSlots, shadowSchema, textStyleErrorForIssue, textStyleFrom, textStyleKeys, textStyleSchema, textStyleShape, themeContextOverride, themeDataSchema, themeFontSlotSchema, themeFontSlots, themeInputSchema, themeOverrideSchema, themeSchema, unsealedFontSchema, validateTextStyle, validateTextStyleTheme, visualStyleShape };
|