@officedk/pptxdk 0.2.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 +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 +2 -5
- 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
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { authorIdSchema } from "
|
|
2
|
-
import { layoutStyleShape } from "
|
|
3
|
-
import { geometrySchema } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { linkTargetSchema } from "
|
|
7
|
-
import "
|
|
8
|
-
import "
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import "
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
2
|
+
import { layoutStyleShape } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { geometrySchema } from "../../kernel/geometry-schemas.js";
|
|
4
|
+
import { resourceSourceSchema } from "../../kernel/resource-source.js";
|
|
5
|
+
import { visualStyleShape } from "../../kernel/theme.js";
|
|
6
|
+
import { linkTargetSchema } from "../../kernel/author-schemas.js";
|
|
7
|
+
import "./geometry.js";
|
|
8
|
+
import { optionalNameSchema } from "./identity.js";
|
|
9
|
+
import { morphKeySchema } from "./morph-api.js";
|
|
10
|
+
import { ooxmlIntSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveIntSchema, ooxmlPositiveLineWidthEmuSchema, ooxmlWritableExtentEmuSchema } from "../../kernel/pptx-read/xml-fragments.js";
|
|
11
|
+
import { motionPropsShape } from "./motion-schemas.js";
|
|
12
|
+
import "../../kernel/capability.js";
|
|
13
|
+
import "../../kernel/pptx-read/index.js";
|
|
14
14
|
import { z } from "zod";
|
|
15
|
-
// ../
|
|
15
|
+
// ../core/dist/capabilities/shared/image-schemas.js
|
|
16
16
|
const rawImageFitSchema = z.enum([
|
|
17
17
|
"fill",
|
|
18
18
|
"cover",
|
|
@@ -38,15 +38,6 @@ const rawImageCropInputSchema = z.strictObject({
|
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
40
|
const imageCropInputSchema = rawImageCropInputSchema;
|
|
41
|
-
const rawExternalImageSourceSchema = z.strictObject({ externalUrl: z.string().min(1) });
|
|
42
|
-
const externalImageSourceSchema = rawExternalImageSourceSchema;
|
|
43
|
-
const rawImageSourceSchema = z.union([
|
|
44
|
-
z.string(),
|
|
45
|
-
z.instanceof(URL),
|
|
46
|
-
z.custom((value) => value instanceof Uint8Array),
|
|
47
|
-
rawExternalImageSourceSchema
|
|
48
|
-
]);
|
|
49
|
-
const imageSourceSchema = rawImageSourceSchema;
|
|
50
41
|
const imageCoordinateValueSchema = z.number().finite().min(-1e6).max(1e6);
|
|
51
42
|
const imageExtentValueSchema = z.number().finite().positive();
|
|
52
43
|
const imageVisualStyleObjectSchema = z.strictObject({
|
|
@@ -72,10 +63,9 @@ const imageDeclarationPropsObjectSchema = z.strictObject({
|
|
|
72
63
|
id: authorIdSchema.optional(),
|
|
73
64
|
name: optionalNameSchema.optional(),
|
|
74
65
|
placeholder: z.string().optional(),
|
|
75
|
-
nativePlaceholder: nativePlaceholderRefSchema.optional(),
|
|
76
66
|
morphKey: morphKeySchema.optional(),
|
|
77
67
|
link: linkTargetSchema.optional(),
|
|
78
|
-
src:
|
|
68
|
+
src: resourceSourceSchema,
|
|
79
69
|
/** Alternative text for the image. */
|
|
80
70
|
alt: z.string().optional(),
|
|
81
71
|
geometry: geometrySchema.optional(),
|
|
@@ -144,4 +134,4 @@ const outerShadowFragmentSchema = z.object({
|
|
|
144
134
|
rotWithShape: z.string().optional()
|
|
145
135
|
});
|
|
146
136
|
const softEdgeFragmentSchema = z.object({ rad: ooxmlWritableExtentEmuSchema });
|
|
147
|
-
export { alphaModFixFragmentSchema, cropFractionSchema, customPathAttributesSchema, customPathPointSchema,
|
|
137
|
+
export { alphaModFixFragmentSchema, cropFractionSchema, customPathAttributesSchema, customPathPointSchema, geomGuideFragmentSchema, imageAllowedParameters, imageAltSchema, imageCoordinateValueSchema, imageCropInputSchema, imageExtentValueSchema, imageFitSchema, imageStyleKeys, imageStyleSchema, imageVisualStyleKeys, lineAttributesFragmentSchema, nonVisualPicIdSchema, outerShadowFragmentSchema, presetDashFragmentSchema, presetGeomFragmentSchema, softEdgeFragmentSchema, srcRectFragmentSchema };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { A_NS, P_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
2
|
+
import { directElementChild, isPlaceholderSpElement } from "./placeholder-import.js";
|
|
3
|
+
// ../core/dist/capabilities/shared/line-match.js
|
|
4
|
+
const linePresetNames = /* @__PURE__ */ new Set([
|
|
5
|
+
"line",
|
|
6
|
+
"lineInv",
|
|
7
|
+
"straightConnector1",
|
|
8
|
+
"bentConnector2",
|
|
9
|
+
"bentConnector3",
|
|
10
|
+
"bentConnector4",
|
|
11
|
+
"bentConnector5",
|
|
12
|
+
"curvedConnector2",
|
|
13
|
+
"curvedConnector3",
|
|
14
|
+
"curvedConnector4",
|
|
15
|
+
"curvedConnector5"
|
|
16
|
+
]);
|
|
17
|
+
const fillElementNames = /* @__PURE__ */ new Set([
|
|
18
|
+
"solidFill",
|
|
19
|
+
"gradFill",
|
|
20
|
+
"blipFill",
|
|
21
|
+
"pattFill",
|
|
22
|
+
"grpFill"
|
|
23
|
+
]);
|
|
24
|
+
function hasTextBoxFlag(spElement) {
|
|
25
|
+
const nvSpPr = directElementChild(spElement, P_NS, "nvSpPr");
|
|
26
|
+
if (nvSpPr === void 0) return false;
|
|
27
|
+
const cNvSpPr = directElementChild(nvSpPr, P_NS, "cNvSpPr");
|
|
28
|
+
if (cNvSpPr === void 0) return false;
|
|
29
|
+
const txBox = cNvSpPr.getAttribute("txBox");
|
|
30
|
+
return txBox === "1" || txBox === "true";
|
|
31
|
+
}
|
|
32
|
+
function hasEffectiveSpText(spElement) {
|
|
33
|
+
const txBody = directElementChild(spElement, P_NS, "txBody");
|
|
34
|
+
if (txBody === void 0) return false;
|
|
35
|
+
for (let child = txBody.firstChild; child !== null; child = child.nextSibling) {
|
|
36
|
+
if (child.nodeType !== 1) continue;
|
|
37
|
+
const pEl = child;
|
|
38
|
+
if ((pEl.namespaceURI ?? "") !== "http://schemas.openxmlformats.org/drawingml/2006/main" || (pEl.localName ?? pEl.tagName) !== "p") continue;
|
|
39
|
+
const pPr = directElementChild(pEl, A_NS, "pPr");
|
|
40
|
+
if (pPr !== void 0) {
|
|
41
|
+
if (directElementChild(pPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "buChar") !== void 0 || directElementChild(pPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "buAutoNum") !== void 0 || directElementChild(pPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "defRPr") !== void 0) return true;
|
|
42
|
+
}
|
|
43
|
+
if (directElementChild(pEl, "http://schemas.openxmlformats.org/drawingml/2006/main", "r") !== void 0 || directElementChild(pEl, "http://schemas.openxmlformats.org/drawingml/2006/main", "fld") !== void 0 || directElementChild(pEl, "http://schemas.openxmlformats.org/drawingml/2006/main", "br") !== void 0) return true;
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Side-effect-free predicate matching `<p:sp>` elements that represent pure 1D lines or connectors
|
|
49
|
+
* (no fill, no effective text, and a `line` / `lineInv` / `*Connector*` preset geometry).
|
|
50
|
+
*/
|
|
51
|
+
function isLineNormalizedSpElement(cursor) {
|
|
52
|
+
if (isPlaceholderSpElement(cursor)) return false;
|
|
53
|
+
const spEl = cursor.element;
|
|
54
|
+
if (hasTextBoxFlag(spEl)) return false;
|
|
55
|
+
const spPr = directElementChild(spEl, P_NS, "spPr");
|
|
56
|
+
if (spPr === void 0) return false;
|
|
57
|
+
if (directElementChild(spPr, "http://schemas.openxmlformats.org/drawingml/2006/main", "custGeom") !== void 0) return false;
|
|
58
|
+
const prstGeom = directElementChild(spPr, A_NS, "prstGeom");
|
|
59
|
+
if (prstGeom === void 0) return false;
|
|
60
|
+
const prst = prstGeom.getAttribute("prst") ?? "";
|
|
61
|
+
if (!linePresetNames.has(prst)) return false;
|
|
62
|
+
for (let child = spPr.firstChild; child !== null; child = child.nextSibling) {
|
|
63
|
+
if (child.nodeType !== 1) continue;
|
|
64
|
+
const el = child;
|
|
65
|
+
if ((el.namespaceURI ?? "") === "http://schemas.openxmlformats.org/drawingml/2006/main" && fillElementNames.has(el.localName ?? el.tagName)) return false;
|
|
66
|
+
}
|
|
67
|
+
const pStyle = directElementChild(spEl, P_NS, "style");
|
|
68
|
+
if (pStyle !== void 0) {
|
|
69
|
+
const fillRef = directElementChild(pStyle, A_NS, "fillRef");
|
|
70
|
+
if (fillRef !== void 0) {
|
|
71
|
+
const idx = fillRef.getAttribute("idx");
|
|
72
|
+
if (idx !== null && idx !== "" && idx !== "0") return false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (hasEffectiveSpText(spEl)) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
export { isLineNormalizedSpElement };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { readInternalDeclarationProps } from "../../kernel/document-internals.js";
|
|
2
|
+
import { layoutStyleSchema } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { serializeGeometryProp } from "./geometry-codegen.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
import { defineObjectCodegen, expr } from "../../kernel/codegen.js";
|
|
6
|
+
import { markImmutableBytes } from "../../kernel/font-seal.js";
|
|
7
|
+
import { finishResolveWork } from "../../kernel/resolve-work.js";
|
|
8
|
+
import { assertNoLeafDeclarationChildren, isPlainObject, serializeImageSrcProp, serializeImageStyleProp } from "./image-codegen.js";
|
|
9
|
+
import { audioDeclarationPropsSchema, supportsMediaProperty, videoDeclarationPropsSchema } from "./media-schemas.js";
|
|
10
|
+
import { readMediaSource } from "./media-source.js";
|
|
11
|
+
import { validateMediaTrimBounds } from "./media-trim.js";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
// ../core/dist/capabilities/shared/media-codegen.js
|
|
15
|
+
const dummySourceBytes = new Uint8Array([0]);
|
|
16
|
+
function serializeAudioStyleProp(style, ctx) {
|
|
17
|
+
if (!isPlainObject(style)) ctx.fail("unexpressible-value", "Audio.style must be a plain object", "@style");
|
|
18
|
+
const parsed = layoutStyleSchema.safeParse(style);
|
|
19
|
+
if (!parsed.success) {
|
|
20
|
+
const issue = parsed.error.issues[0];
|
|
21
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@style.${issue.path.join(".")}` : "@style";
|
|
22
|
+
ctx.fail("unexpressible-value", issue?.message ?? "Audio.style cannot be expressed", issuePath);
|
|
23
|
+
}
|
|
24
|
+
const styleEntries = Object.entries(style).filter(([, entryValue]) => entryValue !== void 0);
|
|
25
|
+
return expr(ctx.formatProps(styleEntries));
|
|
26
|
+
}
|
|
27
|
+
function defineMediaCodegen(kind, detectMedia) {
|
|
28
|
+
const label = kind === "video" ? "Video" : "Audio";
|
|
29
|
+
const schema = kind === "video" ? videoDeclarationPropsSchema : audioDeclarationPropsSchema;
|
|
30
|
+
function collectProps(node, ctx) {
|
|
31
|
+
assertNoLeafDeclarationChildren(label, node, ctx);
|
|
32
|
+
const props = readInternalDeclarationProps(node);
|
|
33
|
+
const entries = [];
|
|
34
|
+
const schemaCandidate = { src: dummySourceBytes };
|
|
35
|
+
let sawSrc = false;
|
|
36
|
+
let loadedDuration;
|
|
37
|
+
for (const [key, value] of Object.entries(props)) {
|
|
38
|
+
if (value === void 0) continue;
|
|
39
|
+
if (!supportsMediaProperty(kind, key)) ctx.fail("invalid-document", `${kind} declaration does not support property ${JSON.stringify(key)}`, `@${key}`);
|
|
40
|
+
if (key === "src") {
|
|
41
|
+
sawSrc = true;
|
|
42
|
+
try {
|
|
43
|
+
const loaded = finishResolveWork(readMediaSource(value, detectMedia), (file) => markImmutableBytes(readFileSync(file instanceof URL ? fileURLToPath(file) : file)));
|
|
44
|
+
loadedDuration = loaded.kind === "embedded" ? loaded.format.duration : void 0;
|
|
45
|
+
entries.push([key, loaded.kind === "external" ? { externalUrl: loaded.externalUrl } : expr(ctx.registerMediaAsset(loaded.bytes, loaded.format.extension))]);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
ctx.fail("unexpressible-value", error instanceof Error ? error.message : `${label}.src could not be read`, "@src");
|
|
48
|
+
}
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (key === "poster") {
|
|
52
|
+
entries.push([key, serializeImageSrcProp(value, ctx, "@poster", `${label}.poster`)]);
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (key === "style") {
|
|
56
|
+
entries.push([key, kind === "video" ? serializeImageStyleProp(value, ctx) : serializeAudioStyleProp(value, ctx)]);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (key === "geometry") {
|
|
60
|
+
entries.push([key, serializeGeometryProp(value, ctx)]);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
schemaCandidate[key] = value;
|
|
64
|
+
entries.push([key, value]);
|
|
65
|
+
}
|
|
66
|
+
if (!sawSrc) ctx.fail("unexpressible-value", `${label} declaration is missing src`, "@src");
|
|
67
|
+
const parsed = schema.safeParse(schemaCandidate);
|
|
68
|
+
if (!parsed.success) {
|
|
69
|
+
const issue = parsed.error.issues[0];
|
|
70
|
+
const issuePath = issue !== void 0 && issue.path.length > 0 ? `@${issue.path.join(".")}` : void 0;
|
|
71
|
+
ctx.fail("unexpressible-value", issue?.message ?? `${label} declaration cannot be expressed`, issuePath);
|
|
72
|
+
}
|
|
73
|
+
const trimIssue = validateMediaTrimBounds(parsed.data.trim, loadedDuration, parsed.data.loop ?? false);
|
|
74
|
+
if (trimIssue !== void 0) ctx.fail("unexpressible-value", trimIssue.message, loadedDuration === void 0 ? `@${trimIssue.field}` : "@trim");
|
|
75
|
+
return entries;
|
|
76
|
+
}
|
|
77
|
+
return defineObjectCodegen({ declarations: { [kind]: {
|
|
78
|
+
emitVanilla(node, ctx) {
|
|
79
|
+
return ctx.formatVanillaCall(ctx.useImport(kind), [ctx.formatProps(collectProps(node, ctx))]);
|
|
80
|
+
},
|
|
81
|
+
emitReact(node, ctx) {
|
|
82
|
+
return ctx.formatJsxElement(ctx.useImport(label), collectProps(node, ctx));
|
|
83
|
+
}
|
|
84
|
+
} } });
|
|
85
|
+
}
|
|
86
|
+
export { defineMediaCodegen };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { bytesSha256 } from "../../kernel/font-seal.js";
|
|
2
|
+
import "../../kernel/pptx-read/index.js";
|
|
3
|
+
import { peekShapeTreeObjectIdentity, resolveExternalRelationshipTarget, resolveInternalRelationshipTarget } from "../../kernel/pptx-read/resources.js";
|
|
4
|
+
import { A_NS, P14_NS, P_NS, REL_MEDIA, R_NS } from "../../kernel/pptx-read/namespaces.js";
|
|
5
|
+
import { mediaTrimSchema } from "./media-schemas.js";
|
|
6
|
+
import { importNativeTrimEnd, isMediaTrimWithinDuration, maxMediaStopDelay, mediaStopDelay, parseNativeTrimTime, trimTimeNumber } from "./media-trim.js";
|
|
7
|
+
import { mediaExtensionUri } from "./media.js";
|
|
8
|
+
import { readPicture } from "./picture-import.js";
|
|
9
|
+
// ../core/dist/capabilities/shared/media-import.js
|
|
10
|
+
function hasPosterModifications({ crop, geometry, style }) {
|
|
11
|
+
return crop !== void 0 || geometry !== void 0 || Object.keys(style ?? {}).some((key) => key !== "position" && key !== "left" && key !== "top" && key !== "width" && key !== "height");
|
|
12
|
+
}
|
|
13
|
+
/** Reads an embedded or linked media resource and its authorable picture surface. */
|
|
14
|
+
function readMediaPicture(context, options) {
|
|
15
|
+
const { cursor, part, slideIndex } = context;
|
|
16
|
+
const { kind } = options;
|
|
17
|
+
const identity = peekShapeTreeObjectIdentity(cursor.element);
|
|
18
|
+
const location = {
|
|
19
|
+
part,
|
|
20
|
+
xpath: cursor.xpath,
|
|
21
|
+
slideIndex,
|
|
22
|
+
...identity
|
|
23
|
+
};
|
|
24
|
+
const nvPr = cursor.child(P_NS, "nvPicPr")?.child(P_NS, "nvPr");
|
|
25
|
+
const fileId = nvPr?.child(A_NS, `${kind}File`)?.attr("link", R_NS);
|
|
26
|
+
const media = (nvPr?.child(P_NS, "extLst"))?.children(P_NS, "ext").find((ext) => ext.element.getAttribute("uri") === mediaExtensionUri);
|
|
27
|
+
media?.consumeAttr("uri");
|
|
28
|
+
const nativeMedia = media?.child(P14_NS, "media");
|
|
29
|
+
const embedId = nativeMedia?.attr("embed", R_NS);
|
|
30
|
+
const linkId = nativeMedia?.attr("link", R_NS);
|
|
31
|
+
const relationId = (embedId || linkId || fileId) ?? "";
|
|
32
|
+
const relType = embedId || linkId ? REL_MEDIA : `${R_NS}/${kind}`;
|
|
33
|
+
const relationships = context.relationships ?? /* @__PURE__ */ new Map();
|
|
34
|
+
const targetRel = relationships.get(relationId);
|
|
35
|
+
let src;
|
|
36
|
+
let duration;
|
|
37
|
+
if (targetRel?.TargetMode === "External" && !embedId) {
|
|
38
|
+
const resource = resolveExternalRelationshipTarget(relationships, relationId, location, relType);
|
|
39
|
+
if (!resource.ok) return { diagnostics: [resource.diagnostic] };
|
|
40
|
+
if (resource.target.trim() === "" || resource.target === "NULL") return { diagnostics: [{
|
|
41
|
+
code: "corrupt-part",
|
|
42
|
+
category: "corrupt-input",
|
|
43
|
+
disposition: "omitted",
|
|
44
|
+
location
|
|
45
|
+
}] };
|
|
46
|
+
src = { externalUrl: resource.target };
|
|
47
|
+
} else {
|
|
48
|
+
const resource = resolveInternalRelationshipTarget(context.package, relationships, part, relationId, location, relType);
|
|
49
|
+
if (!resource.ok) return { diagnostics: [resource.diagnostic] };
|
|
50
|
+
const format = options.detectMedia(resource.bytes);
|
|
51
|
+
if (format === void 0) return { diagnostics: [{
|
|
52
|
+
code: "corrupt-part",
|
|
53
|
+
category: "corrupt-input",
|
|
54
|
+
disposition: "omitted",
|
|
55
|
+
location,
|
|
56
|
+
cascaded: [{
|
|
57
|
+
location: { part: resource.targetPart },
|
|
58
|
+
role: "media"
|
|
59
|
+
}]
|
|
60
|
+
}] };
|
|
61
|
+
src = resource.bytes;
|
|
62
|
+
duration = format.duration;
|
|
63
|
+
}
|
|
64
|
+
const diagnostics = [];
|
|
65
|
+
const nativeTrim = nativeMedia?.child(P14_NS, "trim");
|
|
66
|
+
const rawStart = nativeTrim?.attr("st");
|
|
67
|
+
const rawEnd = nativeTrim?.attr("end");
|
|
68
|
+
const parsedStart = parseNativeTrimTime(rawStart);
|
|
69
|
+
const start = parsedStart === void 0 ? void 0 : trimTimeNumber(parsedStart);
|
|
70
|
+
const removed = parseNativeTrimTime(rawEnd);
|
|
71
|
+
const selectedTiming = identity.objectId === void 0 ? void 0 : context.mediaTiming?.get(identity.objectId);
|
|
72
|
+
const timing = selectedTiming?.kind === kind ? selectedTiming : void 0;
|
|
73
|
+
const validStart = rawStart === void 0 || start !== void 0 && (duration === void 0 || start < duration);
|
|
74
|
+
const legacyEndpoint = duration === void 0 && nativeTrim !== void 0 && rawEnd === void 0 ? timing?.duration : void 0;
|
|
75
|
+
const startTrim = validStart && start !== void 0 ? { start } : {};
|
|
76
|
+
let end;
|
|
77
|
+
if (removed !== void 0) end = importNativeTrimEnd(removed, duration, validStart ? parsedStart : void 0);
|
|
78
|
+
if (legacyEndpoint !== void 0) {
|
|
79
|
+
const endpoint = (startTrim.start ?? 0) + legacyEndpoint.milliseconds;
|
|
80
|
+
if (legacyEndpoint.milliseconds > maxMediaStopDelay || mediaStopDelay(endpoint, startTrim.start) > maxMediaStopDelay) diagnostics.push({
|
|
81
|
+
code: "invalid-xml-value",
|
|
82
|
+
category: "corrupt-input",
|
|
83
|
+
disposition: "recovered",
|
|
84
|
+
location: {
|
|
85
|
+
...location,
|
|
86
|
+
xpath: legacyEndpoint.xpath
|
|
87
|
+
},
|
|
88
|
+
attributeOrElement: "p:cTn/@dur",
|
|
89
|
+
rawValue: String(legacyEndpoint.milliseconds)
|
|
90
|
+
});
|
|
91
|
+
else if (timing?.loop) diagnostics.push({
|
|
92
|
+
code: "compatibility-fallback",
|
|
93
|
+
category: "unsupported",
|
|
94
|
+
disposition: "fallback",
|
|
95
|
+
location: {
|
|
96
|
+
...location,
|
|
97
|
+
xpath: legacyEndpoint.xpath
|
|
98
|
+
},
|
|
99
|
+
preferredMechanism: "absolute-media-trim-end-with-unknown-duration-and-loop",
|
|
100
|
+
selectedFallback: "looping-media-without-trim-end",
|
|
101
|
+
loss: {
|
|
102
|
+
lost: "native-mechanism",
|
|
103
|
+
retainedAs: kind
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
else end = endpoint;
|
|
107
|
+
}
|
|
108
|
+
const checkedTrim = mediaTrimSchema.safeParse({
|
|
109
|
+
...startTrim,
|
|
110
|
+
end
|
|
111
|
+
});
|
|
112
|
+
const validTrim = checkedTrim.success && (duration === void 0 || isMediaTrimWithinDuration(checkedTrim.data, duration));
|
|
113
|
+
if (!validTrim || !validStart || rawEnd !== void 0 && end === void 0) diagnostics.push({
|
|
114
|
+
code: "invalid-xml-value",
|
|
115
|
+
category: "corrupt-input",
|
|
116
|
+
disposition: "recovered",
|
|
117
|
+
location: {
|
|
118
|
+
...location,
|
|
119
|
+
xpath: nativeTrim?.xpath ?? cursor.xpath
|
|
120
|
+
},
|
|
121
|
+
attributeOrElement: "p14:trim",
|
|
122
|
+
rawValue: JSON.stringify({
|
|
123
|
+
st: rawStart,
|
|
124
|
+
end: rawEnd
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
const trim = validTrim && end !== void 0 ? {
|
|
128
|
+
...startTrim,
|
|
129
|
+
end
|
|
130
|
+
} : startTrim;
|
|
131
|
+
const picture = readPicture(context, {
|
|
132
|
+
objectKind: kind,
|
|
133
|
+
createNode(props) {
|
|
134
|
+
const { src: artwork, link: _link, ...surface } = props;
|
|
135
|
+
const poster = artwork instanceof Uint8Array && !hasPosterModifications(props) && bytesSha256(artwork) === bytesSha256(options.defaultPoster().bytes) ? void 0 : artwork;
|
|
136
|
+
return options.createNode({
|
|
137
|
+
...surface,
|
|
138
|
+
src,
|
|
139
|
+
...poster === void 0 ? {} : { poster },
|
|
140
|
+
...Object.keys(trim).length === 0 ? {} : { trim },
|
|
141
|
+
...timing === void 0 ? {} : {
|
|
142
|
+
autoPlay: timing.autoPlay,
|
|
143
|
+
loop: timing.loop,
|
|
144
|
+
...timing.volume === void 0 ? {} : { volume: timing.volume },
|
|
145
|
+
...timing.muted === void 0 ? {} : { muted: timing.muted },
|
|
146
|
+
...kind !== "audio" || timing.showWhenStopped === void 0 ? {} : { hideDuringShow: !timing.showWhenStopped }
|
|
147
|
+
}
|
|
148
|
+
}, location, diagnostics);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
return {
|
|
152
|
+
...picture,
|
|
153
|
+
diagnostics: [...diagnostics, ...picture.diagnostics ?? []]
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
export { readMediaPicture };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { motionPropKeys } from "./motion-schemas.js";
|
|
3
|
+
import "../../kernel/capability.js";
|
|
4
|
+
// ../core/dist/capabilities/shared/media-placement.js
|
|
5
|
+
function hasEffects(input) {
|
|
6
|
+
return [
|
|
7
|
+
"enter",
|
|
8
|
+
"emphasis",
|
|
9
|
+
"exit"
|
|
10
|
+
].some((key) => {
|
|
11
|
+
const value = input.props[key];
|
|
12
|
+
return value !== void 0 && (!Array.isArray(value) || value.length > 0);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/** Rejects media placements that have no standalone playback representation. */
|
|
16
|
+
function validateMediaPlacement(input, { insideSlide, ancestors }) {
|
|
17
|
+
if (!insideSlide || ancestors.some((ancestor) => ancestor.type === "group")) throw new CapabilityError("unsupported-media-host", "Media objects must be placed on a Slide outside of a Group");
|
|
18
|
+
if (motionPropKeys.some((key) => input.props[key] !== void 0) || ancestors.some((ancestor) => ancestor.type === "motion-step" || ancestor.type === "motion-scope" || hasEffects(ancestor))) throw new CapabilityError("unsupported-motion-host", "Media objects cannot participate in graphic animation, Step, or MotionScope");
|
|
19
|
+
}
|
|
20
|
+
export { validateMediaPlacement };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { zlibSync } from "fflate";
|
|
2
|
+
// ../core/dist/capabilities/shared/media-poster.js
|
|
3
|
+
const pngSignature = Uint8Array.of(137, 80, 78, 71, 13, 10, 26, 10);
|
|
4
|
+
/** Encodes row-major straight RGBA bytes as a deterministic 8-bit PNG. */
|
|
5
|
+
function encodeRgbaPng(width, height, pixels) {
|
|
6
|
+
const stride = width * 4;
|
|
7
|
+
if (!Number.isInteger(width) || width <= 0 || width > 2147483647 || !Number.isInteger(height) || height <= 0 || height > 2147483647 || pixels.length !== stride * height) throw new RangeError("Invalid PNG dimensions or RGBA pixel count");
|
|
8
|
+
const header = /* @__PURE__ */ new Uint8Array(13);
|
|
9
|
+
const dimensions = new DataView(header.buffer);
|
|
10
|
+
dimensions.setUint32(0, width);
|
|
11
|
+
dimensions.setUint32(4, height);
|
|
12
|
+
header[8] = 8;
|
|
13
|
+
header[9] = 6;
|
|
14
|
+
const scanlines = new Uint8Array((stride + 1) * height);
|
|
15
|
+
for (let y = 0; y < height; y += 1) scanlines.set(pixels.subarray(y * stride, (y + 1) * stride), y * (stride + 1) + 1);
|
|
16
|
+
const chunks = [
|
|
17
|
+
pngSignature,
|
|
18
|
+
chunk("IHDR", header),
|
|
19
|
+
chunk("IDAT", zlibSync(scanlines)),
|
|
20
|
+
chunk("IEND", /* @__PURE__ */ new Uint8Array())
|
|
21
|
+
];
|
|
22
|
+
const png = new Uint8Array(chunks.reduce((total, bytes) => total + bytes.length, 0));
|
|
23
|
+
let offset = 0;
|
|
24
|
+
for (const bytes of chunks) {
|
|
25
|
+
png.set(bytes, offset);
|
|
26
|
+
offset += bytes.length;
|
|
27
|
+
}
|
|
28
|
+
return png;
|
|
29
|
+
}
|
|
30
|
+
function chunk(type, data) {
|
|
31
|
+
const bytes = new Uint8Array(data.length + 12);
|
|
32
|
+
const view = new DataView(bytes.buffer);
|
|
33
|
+
view.setUint32(0, data.length);
|
|
34
|
+
for (let i = 0; i < 4; i += 1) bytes[i + 4] = type.charCodeAt(i);
|
|
35
|
+
bytes.set(data, 8);
|
|
36
|
+
let crc = 4294967295;
|
|
37
|
+
for (const byte of bytes.subarray(4, bytes.length - 4)) {
|
|
38
|
+
crc ^= byte;
|
|
39
|
+
for (let bit = 0; bit < 8; bit += 1) crc = crc >>> 1 ^ (crc & 1 ? 3988292384 : 0);
|
|
40
|
+
}
|
|
41
|
+
view.setUint32(bytes.length - 4, crc ^ 4294967295);
|
|
42
|
+
return bytes;
|
|
43
|
+
}
|
|
44
|
+
/** Renders an opaque default poster without external assets or a native codec. */
|
|
45
|
+
function renderMediaPoster(width, height, pixel) {
|
|
46
|
+
const pixels = new Uint8Array(width * height * 4);
|
|
47
|
+
for (let y = 0; y < height; y += 1) for (let x = 0; x < width; x += 1) pixels.set([...pixel(x, y), 255], (y * width + x) * 4);
|
|
48
|
+
return encodeRgbaPng(width, height, pixels);
|
|
49
|
+
}
|
|
50
|
+
export { encodeRgbaPng, renderMediaPoster };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { authorIdSchema } from "../../kernel/author-ids.js";
|
|
2
|
+
import { layoutStyleSchema } from "../../kernel/layout-schemas.js";
|
|
3
|
+
import { geometrySchema } from "../../kernel/geometry-schemas.js";
|
|
4
|
+
import { resourceSourceSchema } from "../../kernel/resource-source.js";
|
|
5
|
+
import "./geometry.js";
|
|
6
|
+
import { optionalNameSchema } from "./identity.js";
|
|
7
|
+
import { morphKeySchema } from "./morph-api.js";
|
|
8
|
+
import "../../kernel/capability.js";
|
|
9
|
+
import { imageAltSchema, imageCropInputSchema, imageFitSchema, imageStyleSchema } from "./image-schemas.js";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
// ../core/dist/capabilities/shared/media-schemas.js
|
|
12
|
+
const trimTimeSchema = z.number().finite().nonnegative();
|
|
13
|
+
const mediaTrimSchema = z.strictObject({
|
|
14
|
+
start: trimTimeSchema.optional(),
|
|
15
|
+
end: z.union([trimTimeSchema, z.strictObject({ fromEnd: trimTimeSchema }).readonly()]).optional()
|
|
16
|
+
}).readonly().refine(({ start, end }) => typeof end !== "number" || end > (start ?? 0), {
|
|
17
|
+
message: "Media trim end must be greater than start",
|
|
18
|
+
path: ["end"]
|
|
19
|
+
});
|
|
20
|
+
const mediaPlaybackPropsShape = {
|
|
21
|
+
autoPlay: z.boolean().optional(),
|
|
22
|
+
loop: z.boolean().optional(),
|
|
23
|
+
muted: z.boolean().optional(),
|
|
24
|
+
volume: z.number().finite().min(0).max(1).optional(),
|
|
25
|
+
trim: mediaTrimSchema.optional()
|
|
26
|
+
};
|
|
27
|
+
const mediaPlaybackPropsSchema = z.strictObject(mediaPlaybackPropsShape).readonly();
|
|
28
|
+
const commonMediaPropsShape = {
|
|
29
|
+
id: authorIdSchema.optional(),
|
|
30
|
+
name: optionalNameSchema.optional(),
|
|
31
|
+
alt: imageAltSchema,
|
|
32
|
+
src: resourceSourceSchema,
|
|
33
|
+
poster: resourceSourceSchema.optional(),
|
|
34
|
+
...mediaPlaybackPropsShape
|
|
35
|
+
};
|
|
36
|
+
const audioDeclarationPropsObjectSchema = z.strictObject({
|
|
37
|
+
...commonMediaPropsShape,
|
|
38
|
+
style: layoutStyleSchema.optional(),
|
|
39
|
+
hideDuringShow: z.boolean().optional()
|
|
40
|
+
});
|
|
41
|
+
const audioDeclarationPropsSchema = audioDeclarationPropsObjectSchema.readonly();
|
|
42
|
+
const videoDeclarationPropsObjectSchema = z.strictObject({
|
|
43
|
+
...commonMediaPropsShape,
|
|
44
|
+
placeholder: z.string().optional(),
|
|
45
|
+
morphKey: morphKeySchema.optional(),
|
|
46
|
+
geometry: geometrySchema.optional(),
|
|
47
|
+
style: imageStyleSchema.optional(),
|
|
48
|
+
fit: imageFitSchema.optional(),
|
|
49
|
+
crop: imageCropInputSchema.optional()
|
|
50
|
+
});
|
|
51
|
+
const videoDeclarationPropsSchema = videoDeclarationPropsObjectSchema.readonly();
|
|
52
|
+
const mediaAllowedPropSets = {
|
|
53
|
+
audio: new Set(Object.keys(audioDeclarationPropsObjectSchema.shape)),
|
|
54
|
+
video: new Set(Object.keys(videoDeclarationPropsObjectSchema.shape))
|
|
55
|
+
};
|
|
56
|
+
/** Whether a native audio or video declaration accepts the named author property. */
|
|
57
|
+
function supportsMediaProperty(kind, name) {
|
|
58
|
+
return mediaAllowedPropSets[kind].has(name);
|
|
59
|
+
}
|
|
60
|
+
export { audioDeclarationPropsObjectSchema, audioDeclarationPropsSchema, mediaPlaybackPropsSchema, mediaPlaybackPropsShape, mediaTrimSchema, supportsMediaProperty, videoDeclarationPropsObjectSchema, videoDeclarationPropsSchema };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { CapabilityError } from "../../kernel/diagnostics.js";
|
|
2
|
+
import { isImmutableBytes, markImmutableBytes } from "../../kernel/font-seal.js";
|
|
3
|
+
import { resourceSourceSchema } from "../../kernel/resource-source.js";
|
|
4
|
+
import "../../kernel/capability.js";
|
|
5
|
+
// ../core/dist/capabilities/shared/media-source.js
|
|
6
|
+
function* readMediaSource(source, detectMedia) {
|
|
7
|
+
const parsed = resourceSourceSchema.safeParse(source);
|
|
8
|
+
if (!parsed.success) throw new CapabilityError("invalid-resource", "Media.src must be a file path, file URL, media bytes, or externalUrl descriptor", void 0, {
|
|
9
|
+
field: "src",
|
|
10
|
+
resourceKind: "media"
|
|
11
|
+
});
|
|
12
|
+
const data = parsed.data;
|
|
13
|
+
if (typeof data === "object" && "externalUrl" in data) return {
|
|
14
|
+
kind: "external",
|
|
15
|
+
externalUrl: data.externalUrl
|
|
16
|
+
};
|
|
17
|
+
let bytes;
|
|
18
|
+
try {
|
|
19
|
+
bytes = data instanceof Uint8Array ? data : yield data;
|
|
20
|
+
} catch {
|
|
21
|
+
throw new CapabilityError("invalid-resource", "Failed to read media resource", void 0, {
|
|
22
|
+
field: "src",
|
|
23
|
+
resourceKind: "media"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const format = detectMedia(bytes);
|
|
27
|
+
if (format === void 0) throw new CapabilityError("invalid-resource", "Media resource has an invalid or unsupported container header", void 0, {
|
|
28
|
+
field: "src",
|
|
29
|
+
resourceKind: "media"
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
kind: "embedded",
|
|
33
|
+
bytes: isImmutableBytes(bytes) ? bytes : markImmutableBytes(new Uint8Array(bytes)),
|
|
34
|
+
format
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function fourcc(view, start) {
|
|
38
|
+
return String.fromCharCode(view.getUint8(start), view.getUint8(start + 1), view.getUint8(start + 2), view.getUint8(start + 3));
|
|
39
|
+
}
|
|
40
|
+
function* bmffBoxes(view, start, end) {
|
|
41
|
+
for (let offset = start; offset + 8 <= end;) {
|
|
42
|
+
const type = fourcc(view, offset + 4);
|
|
43
|
+
const size32 = view.getUint32(offset);
|
|
44
|
+
const header = size32 === 1 ? 16 : 8;
|
|
45
|
+
if (offset + header > end) return;
|
|
46
|
+
const size = size32 === 1 ? Number(view.getBigUint64(offset + 8)) : size32 === 0 ? end - offset : size32;
|
|
47
|
+
if (size < header || size > end - offset) return;
|
|
48
|
+
const next = offset + size;
|
|
49
|
+
yield {
|
|
50
|
+
type,
|
|
51
|
+
dataStart: offset + header,
|
|
52
|
+
end: next
|
|
53
|
+
};
|
|
54
|
+
offset = next;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/** Reads BMFF brands and the movie duration in milliseconds without decoding media. */
|
|
58
|
+
function readBmffMetadata(bytes) {
|
|
59
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
60
|
+
const entries = bmffBoxes(view, 0, bytes.length);
|
|
61
|
+
const first = entries.next();
|
|
62
|
+
if (first.done === true) return void 0;
|
|
63
|
+
const { type, dataStart, end } = first.value;
|
|
64
|
+
if (type !== "ftyp" || end - dataStart < 8 || (end - dataStart) % 4 !== 0) return void 0;
|
|
65
|
+
const brands = [fourcc(view, dataStart)];
|
|
66
|
+
for (let offset = dataStart + 8; offset < end; offset += 4) brands.push(fourcc(view, offset));
|
|
67
|
+
if (brands.some((brand) => !/^[ -~]{4}$/u.test(brand) || brand.trim() === "")) return void 0;
|
|
68
|
+
for (const box of entries) {
|
|
69
|
+
if (box.type !== "moov") continue;
|
|
70
|
+
for (const child of bmffBoxes(view, box.dataStart, box.end)) {
|
|
71
|
+
if (child.type !== "mvhd" || child.dataStart === child.end) continue;
|
|
72
|
+
const version = view.getUint8(child.dataStart);
|
|
73
|
+
if (version !== 0 && version !== 1) continue;
|
|
74
|
+
const timescaleOffset = child.dataStart + (version === 0 ? 12 : 20);
|
|
75
|
+
if (timescaleOffset + (version === 0 ? 8 : 12) > child.end) continue;
|
|
76
|
+
const timescale = view.getUint32(timescaleOffset);
|
|
77
|
+
const duration = version === 0 ? BigInt(view.getUint32(timescaleOffset + 4)) : view.getBigUint64(timescaleOffset + 4);
|
|
78
|
+
if (timescale > 0 && duration > 0n && duration !== (version === 0 ? 4294967295n : 18446744073709551615n)) return {
|
|
79
|
+
brands,
|
|
80
|
+
duration: Number(duration) * 1e3 / timescale
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return { brands };
|
|
85
|
+
}
|
|
86
|
+
/** Distinguishes audio-only ISO BMFF files that use a generic ftyp brand. */
|
|
87
|
+
function hasBmffAudioOnlyTracks(bytes) {
|
|
88
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
89
|
+
let audio = false;
|
|
90
|
+
for (const box of bmffBoxes(view, 0, bytes.length)) {
|
|
91
|
+
if (box.type !== "moov") continue;
|
|
92
|
+
for (const track of bmffBoxes(view, box.dataStart, box.end)) {
|
|
93
|
+
if (track.type !== "trak") continue;
|
|
94
|
+
for (const media of bmffBoxes(view, track.dataStart, track.end)) {
|
|
95
|
+
if (media.type !== "mdia") continue;
|
|
96
|
+
for (const handler of bmffBoxes(view, media.dataStart, media.end)) {
|
|
97
|
+
if (handler.type !== "hdlr" || handler.end - handler.dataStart < 12) continue;
|
|
98
|
+
const kind = fourcc(view, handler.dataStart + 8);
|
|
99
|
+
if (kind === "vide") return false;
|
|
100
|
+
if (kind === "soun") audio = true;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return audio;
|
|
106
|
+
}
|
|
107
|
+
export { hasBmffAudioOnlyTracks, readBmffMetadata, readMediaSource };
|