@officedk/pptxdk 0.2.0 → 0.2.2
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 +5 -8
- package/dist/build.js +44 -52
- 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/{capabilities/dist → core/dist/capabilities}/box/box-codegen.js +7 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/box/box.js +14 -15
- package/dist/core/dist/capabilities/box/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-codegen.js +11 -18
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-import.js +891 -468
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-labels.js +30 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-model.js +1 -1
- 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 +73 -79
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart-xml.js +41 -36
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/chart.js +175 -113
- package/dist/core/dist/capabilities/chart/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/axes-and-grid.js +2 -2
- 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 +28 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/layout.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/legend.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/line-area.js +1 -1
- 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 +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/chart/preview/style.js +1 -1
- 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 +3 -3
- 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 +113 -50
- 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/{capabilities/dist → core/dist/capabilities}/group/group-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-declaration.js +8 -8
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-import.js +36 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/group/group.js +17 -17
- 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/{capabilities/dist → core/dist/capabilities}/line/line-codegen.js +6 -7
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-declaration.js +15 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-import.js +15 -95
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line-xml.js +1 -1
- package/dist/{capabilities/dist → core/dist/capabilities}/line/line.js +41 -43
- package/dist/core/dist/capabilities/masters/entry.js +1 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters-codegen.js +7 -26
- package/dist/{capabilities/dist → core/dist/capabilities}/masters/masters.js +23 -35
- package/dist/core/dist/capabilities/motion/entry.js +5 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-codegen.js +15 -35
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-import.js +25 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-plan.js +17 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion-query.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/motion/motion.js +79 -75
- package/dist/core/dist/capabilities/notes/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes-codegen.js +4 -5
- 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 +6 -6
- package/dist/{capabilities/dist → core/dist/capabilities}/notes/notes.js +16 -41
- 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/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-codegen.js +5 -15
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder-schemas.js +7 -9
- package/dist/{capabilities/dist → core/dist/capabilities}/placeholder/placeholder.js +50 -107
- 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 +44 -30
- package/dist/core/dist/capabilities/shared/container-slots.js +59 -0
- package/dist/core/dist/capabilities/shared/date-time.js +98 -0
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-embedding.js +5 -6
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-engine.js +34 -13
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-import.js +62 -23
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font-subset.js +24 -9
- package/dist/{capabilities/dist → core/dist/capabilities/shared}/font/font.js +4 -4
- package/dist/core/dist/capabilities/shared/geometry-codegen.js +101 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/geometry.js +47 -44
- 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 -79
- package/dist/{capabilities/dist/image → core/dist/capabilities/shared}/image-schemas.js +16 -26
- 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/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-api.js +112 -99
- package/dist/{capabilities/dist/motion → core/dist/capabilities/shared}/motion-schemas.js +19 -5
- package/dist/{capabilities/dist/image/image-import.js → core/dist/capabilities/shared/picture-import.js} +97 -158
- package/dist/core/dist/capabilities/shared/picture-xml.js +13 -0
- package/dist/core/dist/capabilities/shared/picture.js +510 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/placeholder-import.js +50 -20
- package/dist/core/dist/capabilities/shared/placeholder-roles.js +42 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/preset-definitions.js +1 -1
- package/dist/core/dist/capabilities/shared/print-xml.js +77 -0
- package/dist/{capabilities/dist/text/text-codegen.js → core/dist/capabilities/shared/rich-text-codegen.js} +23 -102
- package/dist/core/dist/capabilities/shared/rich-text-import.js +472 -0
- package/dist/{capabilities/dist/shape → core/dist/capabilities/shared}/shape-declaration.js +14 -14
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/style-inheritance.js +12 -5
- package/dist/{capabilities/dist/text → core/dist/capabilities/shared}/text-declaration.js +7 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-schemas.js +77 -77
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/text-service.js +571 -260
- package/dist/{capabilities/dist → core/dist/capabilities}/shared/visual.js +137 -112
- 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 +5 -5
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background-xml.js +2 -3
- package/dist/{capabilities/dist → core/dist/capabilities}/slide-background/slide-background.js +27 -33
- package/dist/core/dist/capabilities/table/entry.js +2 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-codegen.js +6 -13
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-declaration.js +2 -2
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-import.js +22 -57
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-schemas.js +40 -37
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table-xml.js +9 -4
- package/dist/{capabilities/dist → core/dist/capabilities}/table/table.js +60 -45
- 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 +61 -54
- package/dist/core/dist/capabilities/transition/entry.js +3 -0
- package/dist/{capabilities/dist → core/dist/capabilities}/transition/transition-api.js +1 -1
- 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 +13 -8
- package/dist/{codegen/dist → core/dist/codegen}/codegen.js +54 -122
- package/dist/{codegen/dist → core/dist/codegen}/identifiers.js +17 -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 +122 -60
- package/dist/core/dist/emit/index.js +6 -0
- package/dist/core/dist/emit/ooxml.js +241 -0
- package/dist/{import/dist → core/dist/import}/import.js +221 -187
- package/dist/core/dist/import/index.js +19 -0
- package/dist/{import/dist → core/dist/import}/masters.js +253 -317
- 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} +1 -1
- package/dist/core/dist/{author-schemas.js → kernel/author-schemas.js} +59 -98
- package/dist/core/dist/{block-flex-layout.js → kernel/block-flex-layout.js} +109 -78
- package/dist/core/dist/kernel/build.js +4 -0
- package/dist/core/dist/kernel/capability.js +17 -0
- package/dist/{codegen/dist/types.js → core/dist/kernel/codegen.js} +22 -2
- 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} +1 -1
- package/dist/core/dist/{diagnostics.js → kernel/diagnostics.js} +22 -5
- package/dist/core/dist/{document-internals.js → kernel/document-internals.js} +1 -1
- package/dist/core/dist/{document.js → kernel/document.js} +6 -5
- package/dist/core/dist/kernel/drawing-units.js +14 -0
- package/dist/core/dist/{font-seal.js → kernel/font-seal.js} +2 -2
- package/dist/core/dist/{geometry-schemas.js → kernel/geometry-schemas.js} +2 -6
- package/dist/core/dist/{grid-layout.js → kernel/grid-layout.js} +156 -55
- package/dist/core/dist/{host.js → kernel/host.js} +1 -1
- package/dist/core/dist/kernel/index.js +24 -0
- package/dist/core/dist/{input-values.js → kernel/input-values.js} +4 -3
- package/dist/core/dist/kernel/layout-definition.js +7 -0
- package/dist/core/dist/{layout-protocol.js → kernel/layout-protocol.js} +1 -1
- package/dist/core/dist/{layout-schemas.js → kernel/layout-schemas.js} +2 -6
- package/dist/core/dist/{layout.js → kernel/layout.js} +37 -38
- package/dist/core/dist/{masters.js → kernel/masters.js} +32 -55
- package/dist/core/dist/{morph.js → kernel/morph.js} +1 -1
- package/dist/core/dist/{placeholders.js → kernel/placeholders.js} +23 -9
- 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 +1 -1
- package/dist/core/dist/kernel/pptx-read/drawing-list-import.js +251 -0
- package/dist/{import/dist → core/dist/kernel/pptx-read}/fonts.js +1 -1
- 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 +5 -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 +40 -5
- package/dist/{import/dist → core/dist/kernel/pptx-read}/visual.js +94 -67
- package/dist/{import/dist → core/dist/kernel/pptx-read}/xml-fragments.js +56 -13
- 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} +62 -274
- package/dist/core/dist/{query.js → kernel/query.js} +5 -1
- package/dist/core/dist/{resolution.js → kernel/resolution.js} +1 -1
- package/dist/core/dist/kernel/resolve-work.js +58 -0
- package/dist/core/dist/{resolve.js → kernel/resolve.js} +226 -257
- package/dist/core/dist/kernel/resource-source.js +11 -0
- package/dist/core/dist/{stage-options.js → kernel/stage-options.js} +23 -11
- package/dist/core/dist/{theme.js → kernel/theme.js} +54 -36
- package/dist/core/dist/{transform-geometry.js → kernel/transform-geometry.js} +1 -1
- package/dist/core/dist/kernel/xml-values.js +13 -0
- package/dist/{document-41spD7bq.d.ts → document-C0lPlH-L.d.ts} +614 -522
- package/dist/{capability-BbKW9w4O.d.ts → index-B9_OUeA-.d.ts} +660 -553
- package/dist/{index-BEwhk7c8.d.ts → index-BJEzQxWV.d.ts} +27 -24
- package/dist/{index-cK2KtukZ.d.ts → index-DA9flrlR.d.ts} +2 -17
- package/dist/{index-v77CTJev.d.ts → index-GSt0t9VO.d.ts} +3 -4
- package/dist/index.d.ts +7 -8
- package/dist/index.js +68 -66
- package/dist/node.d.ts +16 -14
- package/dist/node.js +86 -43
- package/dist/pptxdk/src/cli-commands.js +9 -5
- package/dist/pptxdk/src/compose.js +28 -29
- 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 +84 -34
- package/dist/preview/dist/options.js +8 -4
- package/dist/preview/dist/raster.js +66 -0
- package/dist/preview/dist/svg-guard.js +8 -7
- package/dist/preview.d.ts +3 -9
- package/dist/preview.js +7 -25
- 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/{capabilities/dist/text → react/dist/author}/text-elements.js +15 -5
- package/dist/react/dist/author/video-elements.js +14 -0
- package/dist/react/dist/document-adapter.js +4 -4
- package/dist/react/dist/elements.js +7 -4
- package/dist/react/dist/from-vanilla.js +3 -3
- package/dist/react/dist/index.js +17 -3
- package/dist/react/dist/reconciler.js +3 -3
- package/dist/react.d.ts +103 -69
- package/dist/react.js +28 -28
- package/dist/{index-1ag7U9Jt.d.ts → stages-DYHSHKt4.d.ts} +23 -6
- package/dist/vanilla.d.ts +4 -4
- package/dist/vanilla.js +14 -15
- package/package.json +8 -7
- package/dist/build-zrZuX4fK.d.ts +0 -3
- package/dist/capabilities/dist/all.js +0 -34
- 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 -168
- package/dist/capabilities/dist/group/group-elements.js +0 -12
- package/dist/capabilities/dist/image/image-codegen.js +0 -164
- 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 -552
- package/dist/capabilities/dist/line/line-elements.js +0 -12
- 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-elements.js +0 -13
- package/dist/capabilities/dist/shape/shape-codegen.js +0 -236
- package/dist/capabilities/dist/shape/shape-elements.js +0 -12
- package/dist/capabilities/dist/shape/shape-import.js +0 -628
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +0 -44
- package/dist/capabilities/dist/text/text-import.js +0 -1224
- package/dist/core/dist/build.js +0 -4
- package/dist/core/dist/capability.js +0 -15
- package/dist/emit/dist/index.js +0 -5
- package/dist/import/dist/index.js +0 -16
- package/dist/pptxdk/src/slide.js +0 -9
- package/dist/transition-6n8GZxSg.d.ts +0 -9
package/dist/node.js
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { BuildError, toBuildDiagnostic } from "./core/dist/diagnostics.js";
|
|
2
|
-
import {
|
|
3
|
-
import "./core/dist/
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import "./
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { BuildError, toBuildDiagnostic } from "./core/dist/kernel/diagnostics.js";
|
|
2
|
+
import { CommonNode } from "./core/dist/kernel/document.js";
|
|
3
|
+
import { buildDiagnosticSchema, buildOptionsShape, previewErrorSchema, previewPlaceholderSchema, resolveOptionsSchema, resolveOptionsShape } from "./core/dist/kernel/stage-options.js";
|
|
4
|
+
import "./core/dist/kernel/index.js";
|
|
5
|
+
import { ImportError } from "./core/dist/kernel/pptx-read/diagnostics.js";
|
|
6
|
+
import { validateOptions } from "./core/dist/emit/emit.js";
|
|
7
|
+
import "./core/dist/document/stages.js";
|
|
8
|
+
import { importPptx } from "./core/dist/document/default.js";
|
|
9
|
+
import { throwIfInvalidReferenceDateOption } from "./pptxdk/src/compose.js";
|
|
10
|
+
import { build, resolve as resolve$1 } from "./index.js";
|
|
10
11
|
import { registerHooks } from "node:module";
|
|
11
12
|
import { z } from "zod";
|
|
12
|
-
import { extname, sep } from "node:path";
|
|
13
|
-
import { readFileSync } from "node:fs";
|
|
14
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
13
|
import { readFile } from "node:fs/promises";
|
|
14
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
15
|
+
import { extname, sep } from "node:path";
|
|
16
|
+
import { readFileSync, statSync } from "node:fs";
|
|
16
17
|
import { transformSync } from "esbuild";
|
|
17
18
|
// src/node.ts
|
|
18
19
|
const sourceLoaders = {
|
|
@@ -21,6 +22,11 @@ const sourceLoaders = {
|
|
|
21
22
|
".mts": "ts",
|
|
22
23
|
".jsx": "jsx"
|
|
23
24
|
};
|
|
25
|
+
const relativeSourceFallbacks = {
|
|
26
|
+
".js": [".ts", ".tsx"],
|
|
27
|
+
".jsx": [".tsx"],
|
|
28
|
+
".mjs": [".mts"]
|
|
29
|
+
};
|
|
24
30
|
const rawExportNameSchema = z.string().min(1);
|
|
25
31
|
const exportNameSchema = rawExportNameSchema;
|
|
26
32
|
const buildFromSourceOptionsSchema = z.strictObject({
|
|
@@ -28,8 +34,8 @@ const buildFromSourceOptionsSchema = z.strictObject({
|
|
|
28
34
|
exportName: rawExportNameSchema.optional()
|
|
29
35
|
}).readonly();
|
|
30
36
|
const previewFromSourceOptionsSchema = z.strictObject({
|
|
37
|
+
...resolveOptionsShape,
|
|
31
38
|
pages: z.array(z.int().positive()).readonly().optional(),
|
|
32
|
-
signal: z.instanceof(AbortSignal).optional(),
|
|
33
39
|
exportName: rawExportNameSchema.optional()
|
|
34
40
|
}).readonly();
|
|
35
41
|
const resolveFromSourceOptionsSchema = z.strictObject({
|
|
@@ -42,8 +48,14 @@ const resolveFromSourceOptionsSchema = z.strictObject({
|
|
|
42
48
|
*/
|
|
43
49
|
async function importPptxFile(entry, options = {}) {
|
|
44
50
|
if (options.signal?.aborted) throw options.signal.reason;
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
let bytes;
|
|
52
|
+
try {
|
|
53
|
+
bytes = await readFile(entry, options.signal === void 0 ? void 0 : { signal: options.signal });
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (options.signal?.aborted) throw options.signal.reason;
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
return importPptx(bytes, options);
|
|
47
59
|
}
|
|
48
60
|
/** Error thrown when loading author deck source fails. */
|
|
49
61
|
var SourceLoadError = class extends Error {
|
|
@@ -52,27 +64,53 @@ var SourceLoadError = class extends Error {
|
|
|
52
64
|
this.name = "SourceLoadError";
|
|
53
65
|
}
|
|
54
66
|
};
|
|
67
|
+
function findRelativeSourceFallbackUrl(specifier, parentURL) {
|
|
68
|
+
const targetUrl = new URL(specifier, parentURL);
|
|
69
|
+
if (targetUrl.protocol !== "file:") return void 0;
|
|
70
|
+
const currentExt = extname(targetUrl.pathname);
|
|
71
|
+
const fallbackExts = relativeSourceFallbacks[currentExt];
|
|
72
|
+
if (fallbackExts === void 0) return void 0;
|
|
73
|
+
const stem = targetUrl.pathname.slice(0, -currentExt.length);
|
|
74
|
+
for (const fallbackExt of fallbackExts) {
|
|
75
|
+
const candidateUrl = new URL(targetUrl.href);
|
|
76
|
+
candidateUrl.pathname = `${stem}${fallbackExt}`;
|
|
77
|
+
if (statSync(fileURLToPath(candidateUrl), { throwIfNoEntry: false })?.isFile() === true) return candidateUrl.href;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
55
80
|
function registerSourceLoader() {
|
|
56
|
-
return registerHooks({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
return registerHooks({
|
|
82
|
+
resolve(specifier, context, nextResolve) {
|
|
83
|
+
if (typeof context.parentURL !== "string" || !context.parentURL.startsWith("file:") || !specifier.startsWith("./") && !specifier.startsWith("../") || fileURLToPath(context.parentURL).split(sep).includes("node_modules")) return nextResolve(specifier, context);
|
|
84
|
+
try {
|
|
85
|
+
return nextResolve(specifier, context);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error?.code !== "ERR_MODULE_NOT_FOUND") throw error;
|
|
88
|
+
const fallbackUrl = findRelativeSourceFallbackUrl(specifier, context.parentURL);
|
|
89
|
+
if (fallbackUrl === void 0) throw error;
|
|
90
|
+
return nextResolve(fallbackUrl, context);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
load(url, context, nextLoad) {
|
|
94
|
+
if (!url.startsWith("file:")) return nextLoad(url, context);
|
|
95
|
+
const file = fileURLToPath(url);
|
|
96
|
+
if (file.split(sep).includes("node_modules")) return nextLoad(url, context);
|
|
97
|
+
const loader = sourceLoaders[extname(file)];
|
|
98
|
+
if (loader === void 0) return nextLoad(url, context);
|
|
99
|
+
return {
|
|
100
|
+
format: "module",
|
|
101
|
+
source: transformSync(readFileSync(file, "utf8"), {
|
|
102
|
+
loader,
|
|
103
|
+
format: "esm",
|
|
104
|
+
jsx: "automatic",
|
|
105
|
+
jsxImportSource: "react",
|
|
106
|
+
sourcemap: "inline",
|
|
107
|
+
sourcefile: file,
|
|
108
|
+
target: "node24"
|
|
109
|
+
}).code,
|
|
110
|
+
shortCircuit: true
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
76
114
|
}
|
|
77
115
|
function sourceUrl(entry) {
|
|
78
116
|
if (entry instanceof URL) {
|
|
@@ -144,9 +182,10 @@ async function loadDeck(url, exportName, signal) {
|
|
|
144
182
|
}
|
|
145
183
|
/**
|
|
146
184
|
* Run a formal build from a Node.js local ESM source entry. TS, TSX, MTS, and JSX are loaded by this entry;
|
|
147
|
-
* the entry and its source dependencies are resolved according to Node file locations
|
|
148
|
-
*
|
|
149
|
-
*
|
|
185
|
+
* the entry and its source dependencies are resolved according to Node file locations, with local relative
|
|
186
|
+
* `NodeNext` extension fallback (`.js` -> `.ts`/`.tsx`, `.jsx` -> `.tsx`, `.mjs` -> `.mts`) outside `node_modules`.
|
|
187
|
+
* Cancellation signals also cover source import, async deck promises, and expansion, preserving the original
|
|
188
|
+
* cancellation reason. The return value is identical to `build`.
|
|
150
189
|
*/
|
|
151
190
|
async function buildFromSource(entry, options = {}) {
|
|
152
191
|
const url = sourceUrl(entry);
|
|
@@ -168,8 +207,9 @@ async function buildFromSource(entry, options = {}) {
|
|
|
168
207
|
}
|
|
169
208
|
}
|
|
170
209
|
/**
|
|
171
|
-
* Run a formal static preview from a Node.js local ESM source entry. Shares source loading
|
|
172
|
-
* and cancellation semantics
|
|
210
|
+
* Run a formal static preview from a Node.js local ESM source entry. Shares source loading (including local
|
|
211
|
+
* relative `NodeNext` extension fallback outside `node_modules`), export selection, and cancellation semantics
|
|
212
|
+
* with `buildFromSource`.
|
|
173
213
|
* The return value is identical to `preview`.
|
|
174
214
|
*/
|
|
175
215
|
async function previewFromSource(entry, options = {}) {
|
|
@@ -180,6 +220,7 @@ async function previewFromSource(entry, options = {}) {
|
|
|
180
220
|
const issue = parsed.error.issues[0];
|
|
181
221
|
if (issue?.path[0] === "pages") throw new RangeError("Preview page numbers must be positive integers");
|
|
182
222
|
if (issue?.path[0] === "exportName") throw new TypeError("Preview options exportName must be a non-empty string");
|
|
223
|
+
throwIfInvalidReferenceDateOption(issue?.path[0], options);
|
|
183
224
|
if (issue?.path[0] === "signal") throw new TypeError("Preview options signal must be an AbortSignal");
|
|
184
225
|
if (issue?.path.length === 0 && issue.code === "unrecognized_keys") throw new TypeError(`Preview options contain unknown parameter ${issue.keys[0]}`);
|
|
185
226
|
throw new TypeError("Preview options must be an object");
|
|
@@ -194,8 +235,9 @@ async function previewFromSource(entry, options = {}) {
|
|
|
194
235
|
}
|
|
195
236
|
}
|
|
196
237
|
/**
|
|
197
|
-
* Run a read-only resolve from a Node.js local ESM source entry. Shares source loading
|
|
198
|
-
*
|
|
238
|
+
* Run a read-only resolve from a Node.js local ESM source entry. Shares source loading (including local
|
|
239
|
+
* relative `NodeNext` extension fallback outside `node_modules`), export selection, and cancellation semantics
|
|
240
|
+
* with `buildFromSource` and `previewFromSource`, without emitting PPTX or PNGs.
|
|
199
241
|
* The return value is identical to `resolve`.
|
|
200
242
|
*/
|
|
201
243
|
async function resolveFromSource(entry, options = {}) {
|
|
@@ -208,6 +250,7 @@ async function resolveFromSource(entry, options = {}) {
|
|
|
208
250
|
prop: String(issue.keys[0]),
|
|
209
251
|
scope: "options"
|
|
210
252
|
})]);
|
|
253
|
+
throwIfInvalidReferenceDateOption(issue?.path[0], options);
|
|
211
254
|
if (issue?.path[0] === "signal") throw new BuildError([toBuildDiagnostic("resolve.signal", "invalid-options", "Resolve options signal must be an AbortSignal", { field: "signal" })]);
|
|
212
255
|
if (issue?.path[0] === "exportName") throw new BuildError([toBuildDiagnostic("resolve.exportName", "invalid-options", "exportName must be a non-empty string", { field: "exportName" })]);
|
|
213
256
|
throw new BuildError([toBuildDiagnostic("resolve", "invalid-options", "Resolve options must be an object")]);
|
|
@@ -217,7 +260,7 @@ async function resolveFromSource(entry, options = {}) {
|
|
|
217
260
|
const hooks = registerSourceLoader();
|
|
218
261
|
try {
|
|
219
262
|
const deck = await loadDeck(url, exportName, resolveOptions.signal);
|
|
220
|
-
return await
|
|
263
|
+
return await resolve$1(deck, resolveOptions);
|
|
221
264
|
} finally {
|
|
222
265
|
hooks.deregister();
|
|
223
266
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { previewErrorOptionSchemas } from "../../core/dist/stage-options.js";
|
|
2
|
-
import "../../core/dist/
|
|
1
|
+
import { previewErrorOptionSchemas } from "../../core/dist/kernel/stage-options.js";
|
|
2
|
+
import "../../core/dist/kernel/index.js";
|
|
3
3
|
import { findPackageJSON } from "node:module";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { randomUUID } from "node:crypto";
|
|
6
|
-
import {
|
|
6
|
+
import { lstat, mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
7
7
|
import { basename, dirname, extname, posix, relative, resolve } from "node:path";
|
|
8
|
+
import { strToU8, zipSync } from "fflate";
|
|
8
9
|
import { readFileSync } from "node:fs";
|
|
9
|
-
import { lstat, mkdir, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
10
10
|
import { isNodeBrokenPipe } from "@boringparts/cli-contract/node";
|
|
11
11
|
import { CliWriteError, defineCli, executeCli, helpCapability, parseCliInvocation, schemaCapability, text, versionCapability } from "@boringparts/cli-contract";
|
|
12
12
|
import { BuildError, CodegenError, ImportError, buildDiagnosticSchema, codegen, codegenDiagnosticSchema, codegenTargetSchema, fatalImportIssueSchema, fontEmbeddingModeSchema, importDiagnosticSchema, previewPlaceholderSchema, targetNameSchema, targets } from "@officedk/pptxdk";
|
|
@@ -281,7 +281,10 @@ function formatImportDiagnostic(diagnostic) {
|
|
|
281
281
|
case "compatibility-fallback":
|
|
282
282
|
extras.push(`preferred=${diagnostic.preferredMechanism}`, `fallback=${diagnostic.selectedFallback}`, `loss=${diagnostic.loss.lost}->${diagnostic.loss.retainedAs}`);
|
|
283
283
|
break;
|
|
284
|
-
case "unconsumed-xml":
|
|
284
|
+
case "unconsumed-xml":
|
|
285
|
+
extras.push(`xml=${diagnostic.kind}:${diagnostic.namespaceUri}:${diagnostic.localName}`);
|
|
286
|
+
break;
|
|
287
|
+
default: throw new Error(`Unsupported import diagnostic: ${String(diagnostic)}`);
|
|
285
288
|
}
|
|
286
289
|
if ("cascaded" in diagnostic && diagnostic.cascaded !== void 0) extras.push(`cascaded=${diagnostic.cascaded.length}`);
|
|
287
290
|
const detailSuffix = extras.length > 0 ? ` (${extras.join(", ")})` : "";
|
|
@@ -309,6 +312,7 @@ function formatFatalImportIssue(issue) {
|
|
|
309
312
|
return `Invalid presentation root at ${formatImportLocation(issue.location)}${suffix}`;
|
|
310
313
|
}
|
|
311
314
|
case "unsupported-format-baseline": return `Unsupported format baseline ${issue.baseline} (${issue.detectedNamespace}) at ${formatImportLocation(issue.location)}`;
|
|
315
|
+
default: throw new Error(`Unsupported fatal import issue: ${String(issue)}`);
|
|
312
316
|
}
|
|
313
317
|
}
|
|
314
318
|
const define = defineCli();
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import "../../core/dist/
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import "../../
|
|
1
|
+
import { CommonNode } from "../../core/dist/kernel/document.js";
|
|
2
|
+
import { captureDeclaration, isCapturedDeclaration } from "../../core/dist/kernel/declaration-snapshot.js";
|
|
3
|
+
import { validateResolveOptions } from "../../core/dist/kernel/resolve.js";
|
|
4
|
+
import "../../core/dist/kernel/index.js";
|
|
5
|
+
import { emit, emittedBuildQuery, validateOptions } from "../../core/dist/emit/emit.js";
|
|
6
|
+
import "../../core/dist/document/stages.js";
|
|
7
7
|
// src/compose.ts
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
if ("$$typeof" in value && typeof value.$$typeof === "symbol") return true;
|
|
11
|
-
return "type" in value && "props" in value && !("children" in value && Array.isArray(value.children));
|
|
8
|
+
function throwIfInvalidReferenceDateOption(issueField, options) {
|
|
9
|
+
if (issueField === "referenceDate") validateResolveOptions({ referenceDate: options.referenceDate });
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*/
|
|
11
|
+
function prepareDocumentInput(input) {
|
|
12
|
+
return input instanceof CommonNode ? captureDeclaration(input) : input;
|
|
13
|
+
}
|
|
14
|
+
/** Resolves a captured document or expands JSX with the lazily loaded React adapter. */
|
|
17
15
|
async function resolveDocumentInput(resolveDeclaration, input, options = {}) {
|
|
18
|
-
|
|
16
|
+
validateResolveOptions(options);
|
|
17
|
+
options.signal?.throwIfAborted();
|
|
18
|
+
if (input instanceof CommonNode || isCapturedDeclaration(input)) return resolveDeclaration(input, options);
|
|
19
19
|
const { expandDocument } = await import("../../react/dist/index.js");
|
|
20
|
+
options.signal?.throwIfAborted();
|
|
20
21
|
return resolveDeclaration(await expandDocument(input, options), options);
|
|
21
22
|
}
|
|
22
23
|
/** Emits a PPTX archive and BuildResult from an immutable Resolution snapshot. */
|
|
23
|
-
function emitBuildResult(resolution, options = {}) {
|
|
24
|
-
const
|
|
24
|
+
async function emitBuildResult(resolution, options = {}) {
|
|
25
|
+
const { referenceDate: _referenceDate, ...emitOptions } = options;
|
|
26
|
+
const emitted = await emit(resolution, emitOptions);
|
|
25
27
|
const query = emittedBuildQuery(emitted.report, resolution);
|
|
26
28
|
return Object.freeze({
|
|
27
29
|
pptx: emitted.pptx,
|
|
@@ -30,24 +32,21 @@ function emitBuildResult(resolution, options = {}) {
|
|
|
30
32
|
slide: (id) => query.slide(id)
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
37
|
-
function createStagePipeline(modules) {
|
|
38
|
-
const resolveDeclaration = createResolver(modules);
|
|
39
|
-
function resolve(document, options = {}) {
|
|
40
|
-
if (isJsxLikeInput(document)) throw new BuildError([toBuildDiagnostic("deck", "invalid-structure", "Root resolve() synchronously accepts only an expanded CommonNode document, not a JSX/React element; await expandDocument(element) first, call resolveFromSource() from @officedk/pptxdk/node, or use async resolve() from @officedk/pptxdk/build")]);
|
|
41
|
-
return resolveDeclaration(document, options);
|
|
35
|
+
function createStagePipeline(resolveDeclaration) {
|
|
36
|
+
function resolve(input, options = {}) {
|
|
37
|
+
return resolveDocumentInput(resolveDeclaration, input, options);
|
|
42
38
|
}
|
|
43
39
|
async function build(input, options = {}) {
|
|
44
40
|
validateOptions(options);
|
|
45
|
-
const
|
|
46
|
-
return emitBuildResult(await
|
|
41
|
+
const { referenceDate, signal } = options;
|
|
42
|
+
return emitBuildResult(await resolve(input, {
|
|
43
|
+
referenceDate,
|
|
44
|
+
signal
|
|
45
|
+
}), options);
|
|
47
46
|
}
|
|
48
47
|
return {
|
|
49
48
|
resolve,
|
|
50
49
|
build
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
|
-
export { createStagePipeline, emitBuildResult, resolveDocumentInput };
|
|
52
|
+
export { createStagePipeline, emitBuildResult, prepareDocumentInput, resolveDocumentInput, throwIfInvalidReferenceDateOption };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { resolve } from "../../core/dist/document/default.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { paint } from "../../preview/dist/index.js";
|
|
4
|
+
import { validatePaintOptions } from "../../preview/dist/options.js";
|
|
5
|
+
import { resolveDocumentInput } from "./compose.js";
|
|
6
|
+
// src/preview-result.ts
|
|
7
|
+
async function runPreview(input, options = {}) {
|
|
8
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) validatePaintOptions(options);
|
|
9
|
+
const { referenceDate, ...paintOptions } = options;
|
|
10
|
+
const validatedOptions = validatePaintOptions(paintOptions);
|
|
11
|
+
if (validatedOptions.signal?.aborted) throw validatedOptions.signal.reason;
|
|
12
|
+
const resolution = await resolveDocumentInput(resolve, input, {
|
|
13
|
+
referenceDate,
|
|
14
|
+
signal: validatedOptions.signal
|
|
15
|
+
});
|
|
16
|
+
const { pages } = await paint(resolution, validatedOptions);
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
report: resolution.report,
|
|
19
|
+
pages,
|
|
20
|
+
slides: resolution.slides,
|
|
21
|
+
slide: (id) => resolution.slide(id)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export { runPreview };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CapabilityError } from "
|
|
2
|
-
import "
|
|
3
|
-
// ../
|
|
1
|
+
import { CapabilityError } from "../../core/dist/kernel/diagnostics.js";
|
|
2
|
+
import "../../core/dist/kernel/index.js";
|
|
3
|
+
// ../preview/dist/gif-decoder.js
|
|
4
4
|
function corruptGif(message) {
|
|
5
5
|
throw new CapabilityError("preview-corrupt-image", message);
|
|
6
6
|
}
|
|
@@ -16,7 +16,7 @@ function skipSubBlocks(bytes, startOffset) {
|
|
|
16
16
|
offset += size;
|
|
17
17
|
if (offset > bytes.length) corruptGif("Failed to decode GIF image: truncated extension sub-block");
|
|
18
18
|
}
|
|
19
|
-
corruptGif("Failed to decode GIF image: unterminated extension sub-block");
|
|
19
|
+
return corruptGif("Failed to decode GIF image: unterminated extension sub-block");
|
|
20
20
|
}
|
|
21
21
|
function collectSubBlocks(bytes, startOffset) {
|
|
22
22
|
const chunks = [];
|
|
@@ -42,7 +42,7 @@ function collectSubBlocks(bytes, startOffset) {
|
|
|
42
42
|
totalLength += size;
|
|
43
43
|
offset += size;
|
|
44
44
|
}
|
|
45
|
-
corruptGif("Failed to decode GIF image: unterminated image data sub-block");
|
|
45
|
+
return corruptGif("Failed to decode GIF image: unterminated image data sub-block");
|
|
46
46
|
}
|
|
47
47
|
function decompressLzw(compressed, lzwMinCodeSize, expectedPixels) {
|
|
48
48
|
if (lzwMinCodeSize < 2 || lzwMinCodeSize > 11) corruptGif(`Failed to decode GIF image: invalid LZW minimum code size ${lzwMinCodeSize}`);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { CapabilityError } from "../../core/dist/diagnostics.js";
|
|
2
|
-
import { PreviewPageRangeError, previewErrorSchema, previewPlaceholderSchema } from "../../core/dist/stage-options.js";
|
|
3
|
-
import "../../core/dist/
|
|
4
|
-
import
|
|
1
|
+
import { CapabilityError } from "../../core/dist/kernel/diagnostics.js";
|
|
2
|
+
import { PreviewPageRangeError, previewErrorSchema, previewPlaceholderSchema } from "../../core/dist/kernel/stage-options.js";
|
|
3
|
+
import { getInternalResolution } from "../../core/dist/kernel/resolution.js";
|
|
4
|
+
import "../../core/dist/kernel/index.js";
|
|
5
5
|
import { paintOptionsSchema, previewOptionsSchema, previewPageNumberSchema, previewPagesSchema, screenGeometrySchema, screenPointSchema, validatePaintOptions } from "./options.js";
|
|
6
|
+
import { decodeImageToPngBytes, loadImageDecoders } from "./raster.js";
|
|
6
7
|
import { createPageRasterRegistry, sanitizeSvgForRasterization } from "./svg-guard.js";
|
|
7
|
-
import {
|
|
8
|
+
import { setImmediate } from "node:timers/promises";
|
|
8
9
|
// ../preview/dist/index.js
|
|
9
10
|
const defaultCanvasBackground = "<rect width=\"100%\" height=\"100%\" fill=\"white\"/>";
|
|
10
11
|
function roundScreenMetric(value) {
|
|
@@ -63,15 +64,6 @@ function screenGeometry(box, transforms) {
|
|
|
63
64
|
})
|
|
64
65
|
};
|
|
65
66
|
}
|
|
66
|
-
let cachedResvg;
|
|
67
|
-
function getResvg() {
|
|
68
|
-
if (cachedResvg === void 0) {
|
|
69
|
-
const loaded = createRequire(import.meta.url)("@resvg/resvg-js");
|
|
70
|
-
if (typeof loaded !== "object" || loaded === null || !("Resvg" in loaded) || typeof loaded.Resvg !== "function") throw new Error("Failed to load @resvg/resvg-js Resvg constructor");
|
|
71
|
-
cachedResvg = loaded.Resvg;
|
|
72
|
-
}
|
|
73
|
-
return cachedResvg;
|
|
74
|
-
}
|
|
75
67
|
function maxPaintObjectId(layers) {
|
|
76
68
|
let maxId = 0;
|
|
77
69
|
for (const layer of layers) {
|
|
@@ -180,8 +172,8 @@ function recordPaintPlaceholders(placeholders, records, defaultPath, defaultId)
|
|
|
180
172
|
}));
|
|
181
173
|
}
|
|
182
174
|
}
|
|
183
|
-
function paintLayer(layer, pageNumber,
|
|
184
|
-
const childrenSvg = layer.childComposition === "members" ? layer.memberLayers.map((child) => paintLayer(child, pageNumber,
|
|
175
|
+
function paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, paintIdOffset = 0, recordNodes = true) {
|
|
176
|
+
const childrenSvg = layer.childComposition === "members" ? layer.memberLayers.map((child) => paintLayer(child, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, paintIdOffset, recordNodes)).join("") : layer.childComposition === "siblings" ? layer.siblingLayers.map((child) => paintLayer(child, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, paintIdOffset, recordNodes)).join("") : void 0;
|
|
185
177
|
if (layer.childComposition !== "leaf" && layer.emitsObject && !layer.hasObservation) return "";
|
|
186
178
|
const recordNodeIdentity = () => {
|
|
187
179
|
if (!recordNodes || !layer.hasObservation) return;
|
|
@@ -196,7 +188,7 @@ function paintLayer(layer, pageNumber, errors, placeholders, nodePaths, transfor
|
|
|
196
188
|
...layer.box === void 0 ? {} : { box: layer.box },
|
|
197
189
|
theme: layer.theme,
|
|
198
190
|
...childrenSvg === void 0 ? {} : { childrenSvg },
|
|
199
|
-
registerRasterResource
|
|
191
|
+
registerRasterResource: registerForHook(layer.path, layer.declarationType)
|
|
200
192
|
});
|
|
201
193
|
recordNodeIdentity();
|
|
202
194
|
recordPaintPlaceholders(placeholders, output.placeholders, layer.path, layer.authorId);
|
|
@@ -204,11 +196,11 @@ function paintLayer(layer, pageNumber, errors, placeholders, nodePaths, transfor
|
|
|
204
196
|
} catch (error) {
|
|
205
197
|
recordNodeIdentity();
|
|
206
198
|
const errorPath = error instanceof CapabilityError && error.path !== void 0 ? `${layer.path}/${error.path}` : layer.path;
|
|
207
|
-
|
|
199
|
+
pendingOutcomes.push(toPreviewError(error, errorPath, layer.declarationType));
|
|
208
200
|
return "";
|
|
209
201
|
}
|
|
210
202
|
recordNodeIdentity();
|
|
211
|
-
|
|
203
|
+
pendingOutcomes.push(Object.freeze({
|
|
212
204
|
code: "preview-unsupported-capability",
|
|
213
205
|
path: layer.path,
|
|
214
206
|
message: `Preview does not support ${layer.declarationType}`,
|
|
@@ -216,8 +208,13 @@ function paintLayer(layer, pageNumber, errors, placeholders, nodePaths, transfor
|
|
|
216
208
|
}));
|
|
217
209
|
return "";
|
|
218
210
|
}
|
|
211
|
+
async function rasterize(svg) {
|
|
212
|
+
const { renderAsync } = await import("@resvg/resvg-js");
|
|
213
|
+
const image = await renderAsync(svg, { font: { loadSystemFonts: false } });
|
|
214
|
+
return new Uint8Array(image.asPng());
|
|
215
|
+
}
|
|
219
216
|
/** Paints static preview pages directly from a Resolution without running emit(). */
|
|
220
|
-
function paint(resolution, options = {}) {
|
|
217
|
+
async function paint(resolution, options = {}) {
|
|
221
218
|
const { pages: requestedPages, signal } = validatePaintOptions(options);
|
|
222
219
|
if (signal?.aborted) throw signal.reason;
|
|
223
220
|
const internal = getInternalResolution(resolution);
|
|
@@ -227,22 +224,40 @@ function paint(resolution, options = {}) {
|
|
|
227
224
|
for (const [index, slide] of internal.slides.entries()) {
|
|
228
225
|
const pageNumber = slide.index;
|
|
229
226
|
if (selected !== void 0 && !selected.has(pageNumber)) continue;
|
|
227
|
+
if (signal !== void 0 && pages.length > 0) await setImmediate();
|
|
228
|
+
signal?.throwIfAborted();
|
|
230
229
|
const slideObservation = resolution.report.slides[index];
|
|
231
230
|
if (slideObservation === void 0) throw new Error("Missing resolved slide observation for paint");
|
|
232
|
-
const
|
|
231
|
+
const pendingOutcomes = [];
|
|
233
232
|
const placeholders = [];
|
|
234
233
|
const nodePaths = /* @__PURE__ */ new Map();
|
|
235
234
|
const transforms = /* @__PURE__ */ new Map();
|
|
236
235
|
const rasterRegistry = createPageRasterRegistry(`shared-img-s${pageNumber}`);
|
|
237
|
-
|
|
236
|
+
let rasterCount = 0;
|
|
237
|
+
const registerForHook = (path, declaration) => {
|
|
238
|
+
const register = (resource, options) => {
|
|
239
|
+
if (options?.normalizeToPng !== true) return rasterRegistry.register(resource);
|
|
240
|
+
const token = `urn:pptxdk-pending-raster:${rasterCount++}`;
|
|
241
|
+
pendingOutcomes.push({
|
|
242
|
+
resource,
|
|
243
|
+
path: options.diagnostic?.path ?? path,
|
|
244
|
+
...options.diagnostic === void 0 ? {} : { field: options.diagnostic.field },
|
|
245
|
+
declaration,
|
|
246
|
+
hook: register,
|
|
247
|
+
token
|
|
248
|
+
});
|
|
249
|
+
return token;
|
|
250
|
+
};
|
|
251
|
+
return register;
|
|
252
|
+
};
|
|
238
253
|
const masterOffset = maxPaintObjectId(slide.layers) + 1e3;
|
|
239
254
|
const wrapSharedObjectSvg = (svg) => svg !== "" && internal.mastersCanvas !== void 0 ? internal.mastersCanvas.paintSharedObject(svg).svg : svg;
|
|
240
|
-
const masterLayerFragments = (slide.masterLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber,
|
|
255
|
+
const masterLayerFragments = (slide.masterLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, masterOffset, false)));
|
|
241
256
|
const masterLayersSvg = internal.mastersCanvas !== void 0 ? internal.mastersCanvas.paintMasterLayers(masterLayerFragments).svg : masterLayerFragments.join("");
|
|
242
257
|
const layoutOffset = masterOffset + maxPaintObjectId(slide.masterLayers ?? []) + 1e3;
|
|
243
|
-
const layoutLayerFragments = (slide.layoutLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber,
|
|
258
|
+
const layoutLayerFragments = (slide.layoutLayers ?? []).map((layer) => wrapSharedObjectSvg(paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook, layoutOffset, false)));
|
|
244
259
|
const layoutLayersSvg = internal.mastersCanvas !== void 0 ? internal.mastersCanvas.paintLayoutLayers(layoutLayerFragments).svg : layoutLayerFragments.join("");
|
|
245
|
-
const layers = slide.layers.map((layer) => paintLayer(layer, pageNumber,
|
|
260
|
+
const layers = slide.layers.map((layer) => paintLayer(layer, pageNumber, pendingOutcomes, placeholders, nodePaths, transforms, registerForHook)).join("");
|
|
246
261
|
let background;
|
|
247
262
|
let shapeTreeCapSvg = "";
|
|
248
263
|
let hasExplicitSlideBackground = false;
|
|
@@ -255,16 +270,16 @@ function paint(resolution, options = {}) {
|
|
|
255
270
|
dimensions: internal.dimensions,
|
|
256
271
|
theme: slideCap.theme,
|
|
257
272
|
slideNumber: pageNumber,
|
|
258
|
-
registerRasterResource
|
|
273
|
+
registerRasterResource: registerForHook(slideCap.path, slideCap.declaration)
|
|
259
274
|
});
|
|
260
275
|
if (slideCap.slot === "background" && previewOutput.svg !== "") background = previewOutput.svg;
|
|
261
276
|
else if (slideCap.slot === "shape-tree" && previewOutput.svg !== "") shapeTreeCapSvg += previewOutput.svg;
|
|
262
277
|
recordPaintPlaceholders(placeholders, previewOutput.placeholders, slideCap.path, slide.authorId);
|
|
263
278
|
} catch (error) {
|
|
264
279
|
const errorPath = error instanceof CapabilityError && error.path !== void 0 ? error.path : slideCap.path;
|
|
265
|
-
|
|
280
|
+
pendingOutcomes.push(toPreviewError(error, errorPath, slideCap.declaration));
|
|
266
281
|
}
|
|
267
|
-
else if (slideCap.slot === "background" && slideCap.hasSlideProps)
|
|
282
|
+
else if (slideCap.slot === "background" && slideCap.hasSlideProps) pendingOutcomes.push(Object.freeze({
|
|
268
283
|
code: "preview-unsupported-capability",
|
|
269
284
|
path: slideCap.path,
|
|
270
285
|
message: `Preview does not support ${slideCap.declaration}`,
|
|
@@ -277,17 +292,18 @@ function paint(resolution, options = {}) {
|
|
|
277
292
|
dimensions: internal.dimensions,
|
|
278
293
|
theme: slide.inheritedBackground.theme,
|
|
279
294
|
slideNumber: pageNumber,
|
|
280
|
-
registerRasterResource
|
|
295
|
+
registerRasterResource: registerForHook(slide.inheritedBackground.path, slide.inheritedBackground.declaration)
|
|
281
296
|
});
|
|
282
297
|
if (inheritedOutput.svg !== "") background = inheritedOutput.svg;
|
|
283
298
|
recordPaintPlaceholders(placeholders, inheritedOutput.placeholders, slide.inheritedBackground.path);
|
|
284
299
|
} catch (error) {
|
|
285
300
|
const errorPath = error instanceof CapabilityError && error.path !== void 0 ? error.path : slide.inheritedBackground.path;
|
|
286
|
-
|
|
301
|
+
pendingOutcomes.push(toPreviewError(error, errorPath, slide.inheritedBackground.declaration));
|
|
287
302
|
}
|
|
288
303
|
const nodes = [];
|
|
289
304
|
const collect = (objects, ancestors = []) => {
|
|
290
305
|
for (const object of objects) {
|
|
306
|
+
if (object.audio?.hideDuringShow === true) continue;
|
|
291
307
|
const own = transforms.get(object.id);
|
|
292
308
|
const chain = own === void 0 ? ancestors : [own, ...ancestors];
|
|
293
309
|
const screen = object.box === void 0 ? void 0 : screenGeometry(object.box, chain);
|
|
@@ -303,7 +319,37 @@ function paint(resolution, options = {}) {
|
|
|
303
319
|
}
|
|
304
320
|
};
|
|
305
321
|
collect(slideObservation.objects);
|
|
306
|
-
const
|
|
322
|
+
const tokens = /* @__PURE__ */ new Map();
|
|
323
|
+
const pageErrors = [];
|
|
324
|
+
const failedHooks = /* @__PURE__ */ new Set();
|
|
325
|
+
let decoders;
|
|
326
|
+
if (rasterCount > 0) try {
|
|
327
|
+
decoders = await loadImageDecoders();
|
|
328
|
+
} finally {
|
|
329
|
+
signal?.throwIfAborted();
|
|
330
|
+
}
|
|
331
|
+
for (const entry of pendingOutcomes) {
|
|
332
|
+
if (!("resource" in entry)) {
|
|
333
|
+
pageErrors.push(entry);
|
|
334
|
+
continue;
|
|
335
|
+
}
|
|
336
|
+
if (failedHooks.has(entry.hook)) continue;
|
|
337
|
+
try {
|
|
338
|
+
const bytes = decodeImageToPngBytes(entry.resource, decoders);
|
|
339
|
+
tokens.set(entry.token, rasterRegistry.register({
|
|
340
|
+
bytes,
|
|
341
|
+
contentType: "image/png"
|
|
342
|
+
}));
|
|
343
|
+
} catch (error) {
|
|
344
|
+
failedHooks.add(entry.hook);
|
|
345
|
+
const issue = toPreviewError(error, entry.path, entry.declaration);
|
|
346
|
+
pageErrors.push(Object.freeze({
|
|
347
|
+
...issue,
|
|
348
|
+
...entry.field === void 0 ? {} : { field: entry.field }
|
|
349
|
+
}));
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
Object.freeze(pageErrors);
|
|
307
353
|
const pagePlaceholders = Object.freeze([...placeholders]);
|
|
308
354
|
if (pageErrors.length > 0) {
|
|
309
355
|
pages.push(Object.freeze({
|
|
@@ -323,9 +369,13 @@ function paint(resolution, options = {}) {
|
|
|
323
369
|
...slide.effectiveThemeOverride === void 0 ? {} : { themeOverride: slide.effectiveThemeOverride }
|
|
324
370
|
}).svg : defaultCanvasBackground;
|
|
325
371
|
const rawSvg = `<svg xmlns="http://www.w3.org/2000/svg" width="${internal.dimensions.width}" height="${internal.dimensions.height}" viewBox="0 0 ${internal.dimensions.width} ${internal.dimensions.height}">${background ?? fallbackBackground}${masterLayersSvg}${layoutLayersSvg}${shapeTreeCapSvg}${layers}</svg>`;
|
|
326
|
-
const svg = sanitizeSvgForRasterization(rawSvg, internal.dimensions, rasterRegistry);
|
|
327
|
-
|
|
328
|
-
|
|
372
|
+
const svg = sanitizeSvgForRasterization(rawSvg, internal.dimensions, rasterRegistry, tokens);
|
|
373
|
+
let png;
|
|
374
|
+
try {
|
|
375
|
+
png = await rasterize(svg);
|
|
376
|
+
} finally {
|
|
377
|
+
signal?.throwIfAborted();
|
|
378
|
+
}
|
|
329
379
|
pages.push(Object.freeze({
|
|
330
380
|
id: slide.id,
|
|
331
381
|
page: pageNumber,
|
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import { PreviewPageRangeError, previewErrorSchema, previewPlaceholderSchema } from "../../core/dist/stage-options.js";
|
|
2
|
-
import "../../core/dist/
|
|
1
|
+
import { PreviewPageRangeError, previewErrorSchema, previewPlaceholderSchema, resolveOptionsShape } from "../../core/dist/kernel/stage-options.js";
|
|
2
|
+
import "../../core/dist/kernel/index.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
// ../preview/dist/options.js
|
|
5
5
|
const rawPreviewPageNumberSchema = z.int().positive();
|
|
6
6
|
const previewPageNumberSchema = rawPreviewPageNumberSchema;
|
|
7
7
|
const rawPreviewPagesSchema = z.array(rawPreviewPageNumberSchema).readonly();
|
|
8
8
|
const previewPagesSchema = rawPreviewPagesSchema;
|
|
9
|
-
const
|
|
9
|
+
const paintOptionsShape = {
|
|
10
10
|
/** 1-based page numbers to paint. Omit to draw all pages; an empty list draws none. */
|
|
11
11
|
pages: rawPreviewPagesSchema.optional(),
|
|
12
12
|
signal: z.instanceof(AbortSignal).optional()
|
|
13
|
+
};
|
|
14
|
+
const paintOptionsSchema = z.strictObject(paintOptionsShape).readonly();
|
|
15
|
+
const previewOptionsSchema = z.strictObject({
|
|
16
|
+
...paintOptionsShape,
|
|
17
|
+
referenceDate: resolveOptionsShape.referenceDate
|
|
13
18
|
}).readonly();
|
|
14
|
-
const previewOptionsSchema = paintOptionsSchema;
|
|
15
19
|
const rawScreenPointSchema = z.object({
|
|
16
20
|
x: z.number(),
|
|
17
21
|
y: z.number()
|