@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
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { emuToPx } from "../drawing-units.js";
|
|
2
|
+
import { maximumParagraphIndentEmu, placeholderLevelStyleSchema } from "../placeholders.js";
|
|
3
|
+
import { A_NS } from "./namespaces.js";
|
|
4
|
+
import { cascadeOoxmlTextDecoration, normalizeBulletCharacter, ooxmlAutoNumStartAtSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlLineSpacingPercentSchema, ooxmlLineSpacingPointsSchema, ooxmlListLevelSchema, ooxmlNonNegativeIntSchema, ooxmlParagraphSpacingPointsSchema, ooxmlWritableExtentEmuSchema, ooxmlWritableInt32CoordEmuSchema } from "./xml-fragments.js";
|
|
5
|
+
import { XmlElementCursor } from "./xml-reader.js";
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
// ../core/dist/kernel/pptx-read/drawing-list-import.js
|
|
8
|
+
const alignments = {
|
|
9
|
+
l: "left",
|
|
10
|
+
ctr: "center",
|
|
11
|
+
r: "right",
|
|
12
|
+
just: "justify"
|
|
13
|
+
};
|
|
14
|
+
function readAttribute(cursor, name, schema, location, diagnostics, required = false) {
|
|
15
|
+
const raw = cursor.attr(name);
|
|
16
|
+
if (raw === void 0 && !required) return void 0;
|
|
17
|
+
const parsed = schema.safeParse(raw);
|
|
18
|
+
if (parsed.success) return parsed.data;
|
|
19
|
+
diagnostics.push({
|
|
20
|
+
code: "invalid-xml-value",
|
|
21
|
+
category: "corrupt-input",
|
|
22
|
+
disposition: "omitted",
|
|
23
|
+
location: {
|
|
24
|
+
...location,
|
|
25
|
+
xpath: `${cursor.xpath}/@${name}`
|
|
26
|
+
},
|
|
27
|
+
attributeOrElement: `@${name}`,
|
|
28
|
+
rawValue: raw ?? ""
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Reads the paragraph geometry shared by chart text and regular DrawingML text. */
|
|
32
|
+
function readDrawingParagraphLayout(pPr, location, diagnostics) {
|
|
33
|
+
const alignValue = readAttribute(pPr, "algn", z.enum([
|
|
34
|
+
"l",
|
|
35
|
+
"ctr",
|
|
36
|
+
"r",
|
|
37
|
+
"just"
|
|
38
|
+
]), location, diagnostics);
|
|
39
|
+
const align = alignValue === void 0 ? void 0 : alignments[alignValue];
|
|
40
|
+
const line = pPr.child(A_NS, "lnSpc");
|
|
41
|
+
const linePoints = line?.child(A_NS, "spcPts");
|
|
42
|
+
const linePercent = line?.child(A_NS, "spcPct");
|
|
43
|
+
let lineHeight;
|
|
44
|
+
if (linePoints !== void 0) {
|
|
45
|
+
const points = readAttribute(linePoints, "val", ooxmlLineSpacingPointsSchema, location, diagnostics, true);
|
|
46
|
+
if (points !== void 0) lineHeight = `${points / 100}pt`;
|
|
47
|
+
} else if (linePercent !== void 0) {
|
|
48
|
+
const percent = readAttribute(linePercent, "val", ooxmlLineSpacingPercentSchema, location, diagnostics, true);
|
|
49
|
+
if (percent !== void 0) lineHeight = `${percent / 1e3}%`;
|
|
50
|
+
}
|
|
51
|
+
const afterPoints = pPr.child(A_NS, "spcAft")?.child(A_NS, "spcPts");
|
|
52
|
+
const pointsAfter = afterPoints === void 0 ? void 0 : readAttribute(afterPoints, "val", ooxmlParagraphSpacingPointsSchema, location, diagnostics, true);
|
|
53
|
+
return {
|
|
54
|
+
...align === void 0 ? {} : { align },
|
|
55
|
+
...lineHeight === void 0 ? {} : { lineHeight },
|
|
56
|
+
...pointsAfter === void 0 ? {} : { spacingAfter: pointsAfter / 75 }
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function readDrawingParagraphProperties(pPr, location, diagnostics, readRun, options) {
|
|
60
|
+
const attr = (name, schema) => readAttribute(pPr, name, schema, location, diagnostics);
|
|
61
|
+
const layout = readDrawingParagraphLayout(pPr, location, diagnostics);
|
|
62
|
+
const level = attr("lvl", ooxmlListLevelSchema);
|
|
63
|
+
const marginEmu = attr("marL", ooxmlWritableExtentEmuSchema.refine((value) => value <= maximumParagraphIndentEmu));
|
|
64
|
+
const indentEmu = attr("indent", ooxmlWritableInt32CoordEmuSchema.refine((value) => Math.abs(value) <= maximumParagraphIndentEmu));
|
|
65
|
+
if (options?.listStyle && !options.placeholder) {
|
|
66
|
+
const reportUnsupported = (name) => {
|
|
67
|
+
diagnostics.push({
|
|
68
|
+
code: "unsupported-mechanism",
|
|
69
|
+
category: "unsupported",
|
|
70
|
+
disposition: "omitted",
|
|
71
|
+
location: {
|
|
72
|
+
...location,
|
|
73
|
+
xpath: `${pPr.xpath}/@${name}`
|
|
74
|
+
},
|
|
75
|
+
namespaceUri: A_NS,
|
|
76
|
+
localName: name,
|
|
77
|
+
mechanismHint: "list-style"
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
for (const [name, defaultValue] of [
|
|
81
|
+
["rtl", false],
|
|
82
|
+
["eaLnBrk", true],
|
|
83
|
+
["latinLnBrk", true],
|
|
84
|
+
["hangingPunct", false]
|
|
85
|
+
]) {
|
|
86
|
+
const value = attr(name, ooxmlBoolSchema);
|
|
87
|
+
if (value !== void 0 && value !== defaultValue) reportUnsupported(name);
|
|
88
|
+
}
|
|
89
|
+
const fontAlignment = attr("fontAlgn", z.enum([
|
|
90
|
+
"auto",
|
|
91
|
+
"t",
|
|
92
|
+
"ctr",
|
|
93
|
+
"base",
|
|
94
|
+
"b"
|
|
95
|
+
]));
|
|
96
|
+
if (fontAlignment !== void 0 && fontAlignment !== "base") reportUnsupported("fontAlgn");
|
|
97
|
+
if (attr("defTabSz", z.union([ooxmlIntSchema.refine((value) => value >= -2147483648 && value <= 2147483647), z.string().regex(/^-?[0-9]+(?:\.[0-9]+)?(?:mm|cm|in|pt|pc|pi)$/u)])) !== void 0) reportUnsupported("defTabSz");
|
|
98
|
+
} else {
|
|
99
|
+
attr("rtl", ooxmlBoolSchema);
|
|
100
|
+
pPr.attrsObject([
|
|
101
|
+
"fontAlgn",
|
|
102
|
+
"eaLnBrk",
|
|
103
|
+
"latinLnBrk",
|
|
104
|
+
"hangingPunct",
|
|
105
|
+
"defTabSz"
|
|
106
|
+
]);
|
|
107
|
+
}
|
|
108
|
+
const spacingBeforeNode = pPr.child(A_NS, "spcBef");
|
|
109
|
+
const beforePoints = spacingBeforeNode?.child(A_NS, "spcPts");
|
|
110
|
+
if (!options?.listStyle || options.placeholder) spacingBeforeNode?.child(A_NS, "spcPct")?.consumeAttr("val");
|
|
111
|
+
const before = beforePoints === void 0 ? void 0 : readAttribute(beforePoints, "val", ooxmlParagraphSpacingPointsSchema, location, diagnostics, true);
|
|
112
|
+
if (beforePoints !== void 0 && options?.listStyle && !options.placeholder) diagnostics.push({
|
|
113
|
+
code: "unsupported-mechanism",
|
|
114
|
+
category: "unsupported",
|
|
115
|
+
disposition: "omitted",
|
|
116
|
+
location: {
|
|
117
|
+
...location,
|
|
118
|
+
xpath: spacingBeforeNode.xpath
|
|
119
|
+
},
|
|
120
|
+
namespaceUri: A_NS,
|
|
121
|
+
localName: "spcBef",
|
|
122
|
+
mechanismHint: "paragraph-spacing-before"
|
|
123
|
+
});
|
|
124
|
+
const afterPercent = pPr.child(A_NS, "spcAft")?.child(A_NS, "spcPct");
|
|
125
|
+
const percentAfter = afterPercent === void 0 ? void 0 : readAttribute(afterPercent, "val", ooxmlNonNegativeIntSchema, location, diagnostics, true);
|
|
126
|
+
const buNone = pPr.child(A_NS, "buNone") !== void 0;
|
|
127
|
+
pPr.child(A_NS, "buFont")?.attrsObject([
|
|
128
|
+
"typeface",
|
|
129
|
+
"pitchFamily",
|
|
130
|
+
"charset",
|
|
131
|
+
"panose"
|
|
132
|
+
]);
|
|
133
|
+
const buChar = pPr.child(A_NS, "buChar");
|
|
134
|
+
const buAutoNum = pPr.child(A_NS, "buAutoNum");
|
|
135
|
+
let list;
|
|
136
|
+
if (buChar !== void 0) {
|
|
137
|
+
const raw = buChar.attr("char");
|
|
138
|
+
const normalized = normalizeBulletCharacter(raw);
|
|
139
|
+
if (normalized.recovered) diagnostics.push({
|
|
140
|
+
code: "invalid-xml-value",
|
|
141
|
+
category: "corrupt-input",
|
|
142
|
+
disposition: "recovered",
|
|
143
|
+
location: {
|
|
144
|
+
...location,
|
|
145
|
+
xpath: buChar.xpath
|
|
146
|
+
},
|
|
147
|
+
attributeOrElement: "a:buChar/@char",
|
|
148
|
+
rawValue: raw ?? ""
|
|
149
|
+
});
|
|
150
|
+
list = {
|
|
151
|
+
type: "bullet",
|
|
152
|
+
character: normalized.character
|
|
153
|
+
};
|
|
154
|
+
} else if (buAutoNum !== void 0) {
|
|
155
|
+
const type = readAttribute(buAutoNum, "type", z.string().min(1), location, diagnostics, !options?.placeholder);
|
|
156
|
+
const startAt = readAttribute(buAutoNum, "startAt", ooxmlAutoNumStartAtSchema, location, diagnostics);
|
|
157
|
+
if (type !== void 0 || options?.placeholder) {
|
|
158
|
+
if (type !== void 0 && type !== "arabicPeriod" && !options?.placeholder) diagnostics.push({
|
|
159
|
+
code: "unsupported-mechanism",
|
|
160
|
+
category: "unsupported",
|
|
161
|
+
disposition: "omitted",
|
|
162
|
+
location: {
|
|
163
|
+
...location,
|
|
164
|
+
xpath: buAutoNum.xpath
|
|
165
|
+
},
|
|
166
|
+
namespaceUri: A_NS,
|
|
167
|
+
localName: "buAutoNum",
|
|
168
|
+
mechanismHint: type
|
|
169
|
+
});
|
|
170
|
+
list = {
|
|
171
|
+
type: "number",
|
|
172
|
+
style: "arabicPeriod",
|
|
173
|
+
...startAt === void 0 ? {} : { startAt }
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const defRPr = pPr.child(A_NS, "defRPr");
|
|
178
|
+
const run = defRPr === void 0 ? void 0 : readRun(defRPr);
|
|
179
|
+
const style = {
|
|
180
|
+
...run?.style,
|
|
181
|
+
...layout,
|
|
182
|
+
...before === void 0 || !options?.placeholder ? {} : { spacingBefore: before / 75 },
|
|
183
|
+
...marginEmu === void 0 ? {} : { marginLeft: emuToPx(marginEmu) },
|
|
184
|
+
...indentEmu === void 0 ? {} : { indent: emuToPx(indentEmu) },
|
|
185
|
+
...list === void 0 ? {} : { list }
|
|
186
|
+
};
|
|
187
|
+
const valid = placeholderLevelStyleSchema.safeParse(style);
|
|
188
|
+
return {
|
|
189
|
+
style: valid.success ? valid.data : Object.fromEntries(Object.entries(style).filter(([key, value]) => placeholderLevelStyleSchema.safeParse({ [key]: value }).success)),
|
|
190
|
+
...run?.decoration === void 0 ? {} : { decoration: run.decoration },
|
|
191
|
+
...level === void 0 ? {} : { level },
|
|
192
|
+
...buNone ? { buNone } : {},
|
|
193
|
+
...layout.spacingAfter === void 0 && afterPercent !== void 0 && percentAfter !== void 0 ? { spacingAfterPercent: {
|
|
194
|
+
val: percentAfter,
|
|
195
|
+
xpath: afterPercent.xpath
|
|
196
|
+
} } : {}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
/** Reads defaults and level-specific properties with scoped diagnostics for unsupported list XML. */
|
|
200
|
+
function readDrawingListStyles(container, location, diagnostics, readRun, placeholder = false) {
|
|
201
|
+
if (container === void 0) return void 0;
|
|
202
|
+
const list = XmlElementCursor.createRoot(container.element, container.part, container.xpath);
|
|
203
|
+
const read = (name) => {
|
|
204
|
+
const properties = list.child(A_NS, name);
|
|
205
|
+
return properties === void 0 ? void 0 : readDrawingParagraphProperties(properties, location, diagnostics, readRun, {
|
|
206
|
+
placeholder,
|
|
207
|
+
listStyle: true
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
const defaults = read("defPPr");
|
|
211
|
+
const levels = Array.from({ length: 9 }, (_, level) => cascadeDrawingParagraphProperties(defaults, read(`lvl${level + 1}pPr`), level));
|
|
212
|
+
container.suppressUnconsumed();
|
|
213
|
+
for (const item of list.collectUnconsumed()) diagnostics.push({
|
|
214
|
+
code: "unsupported-mechanism",
|
|
215
|
+
category: "unsupported",
|
|
216
|
+
disposition: "omitted",
|
|
217
|
+
location: {
|
|
218
|
+
...location,
|
|
219
|
+
...item.location
|
|
220
|
+
},
|
|
221
|
+
namespaceUri: item.namespaceUri,
|
|
222
|
+
localName: item.localName,
|
|
223
|
+
mechanismHint: "list-style"
|
|
224
|
+
});
|
|
225
|
+
return levels.some((level) => level.decoration !== void 0 || Object.keys(level.style).length > 0 || level.buNone || level.spacingAfterPercent !== void 0) ? levels : void 0;
|
|
226
|
+
}
|
|
227
|
+
/** Applies a paragraph property layer, including explicit clearing of an inherited list. */
|
|
228
|
+
function cascadeDrawingParagraphProperties(base, local, level) {
|
|
229
|
+
const { list: _baseList, spacingAfter: _baseSpacing, ...baseStyle } = base?.style ?? {};
|
|
230
|
+
const { list: _localList, spacingAfter: _localSpacing, ...localStyle } = local?.style ?? {};
|
|
231
|
+
const list = local?.buNone ? void 0 : local?.style.list ?? base?.style.list;
|
|
232
|
+
const buNone = local?.buNone ?? (local?.style.list === void 0 ? base?.buNone : void 0);
|
|
233
|
+
const spacing = local?.style.spacingAfter !== void 0 || local?.spacingAfterPercent !== void 0 ? local : base;
|
|
234
|
+
const spacingAfter = spacing?.style.spacingAfter;
|
|
235
|
+
const spacingAfterPercent = spacing?.spacingAfterPercent;
|
|
236
|
+
return {
|
|
237
|
+
style: {
|
|
238
|
+
...baseStyle,
|
|
239
|
+
...localStyle,
|
|
240
|
+
...list === void 0 ? {} : { list: {
|
|
241
|
+
...list,
|
|
242
|
+
...level === 0 ? {} : { level }
|
|
243
|
+
} },
|
|
244
|
+
...spacingAfter === void 0 ? {} : { spacingAfter }
|
|
245
|
+
},
|
|
246
|
+
...base?.decoration === void 0 && local?.decoration === void 0 ? {} : { decoration: cascadeOoxmlTextDecoration(base?.decoration, local?.decoration) },
|
|
247
|
+
...buNone ? { buNone } : {},
|
|
248
|
+
...spacingAfterPercent === void 0 ? {} : { spacingAfterPercent }
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
export { cascadeDrawingParagraphProperties, readDrawingListStyles, readDrawingParagraphLayout, readDrawingParagraphProperties };
|
|
@@ -3,7 +3,7 @@ import { resolvePartPath } from "./opc.js";
|
|
|
3
3
|
import { ooxmlBoolSchema, ooxmlIntSchema } from "./xml-fragments.js";
|
|
4
4
|
import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
// ../
|
|
6
|
+
// ../core/dist/kernel/pptx-read/fonts.js
|
|
7
7
|
const fontSlotNames = [
|
|
8
8
|
"regular",
|
|
9
9
|
"bold",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { EMU_PER_PX, emuToPx } from "../drawing-units.js";
|
|
2
|
+
import { A_NS, C_NS, DIAGRAM_NS, DSP_NS, MC_NS, P14_CREATION_ID_EXT_URI, P14_NS, P159_NS, P_NS, REL_CHART, REL_DIAGRAM_DATA, REL_DIAGRAM_DRAWING, REL_HYPERLINK, REL_IMAGE, REL_NOTES_SLIDE, REL_SLIDE, R_NS, TABLE_NS_URI, XMLNS_NS, XML_NS, canonicalQName } from "./namespaces.js";
|
|
3
|
+
import "./alternate-content.js";
|
|
4
|
+
import { arrowTypeSchema, readBlipFill, readDrawingColor, readEffectList, readGradientFill, readLineBorder, readPlaceholderSpPrVisuals, readPlaceholderTransform, readRunFillAndStroke, readTransformXml } from "./visual.js";
|
|
5
|
+
import { ImportError, cascadedOmissionSchema, editabilityLossSchema, fatalImportIssueSchema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema } from "./diagnostics.js";
|
|
6
|
+
import { readPartThemeOverride } from "./themes.js";
|
|
7
|
+
import { readEmbeddedFontList, readPresentationThemeFontScheme, readRunFontSlots, unpackEotFontData } from "./fonts.js";
|
|
8
|
+
import { resolvePartPath } from "./opc.js";
|
|
9
|
+
import { allocateScopedAuthorId, appendUnconsumedDiagnostics, consumeIdentityShapeTreeBoilerplate } from "./shape-tree.js";
|
|
10
|
+
import { buildRelationshipIndex, inspectUnsupportedGraphicFrame, peekShapeTreeObjectIdentity, resolveExternalRelationshipTarget, resolveInternalRelationshipTarget } from "./resources.js";
|
|
11
|
+
import { MAXIMUM_COORDINATE_PX, MAXIMUM_WRITABLE_EMU, cascadeOoxmlTextDecoration, extentEmuFragmentSchema, hexRgb6Schema, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlListLevelSchema, ooxmlNonNegativeIntSchema, ooxmlPlaceholderRoleSchema, ooxmlPositiveFixedAngleSchema, ooxmlPositiveIntSchema, ooxmlPositiveLineWidthEmuSchema, ooxmlWritableExtentEmuSchema, ooxmlWritablePositiveExtentEmuSchema, projectOoxmlTextDecoration, readOoxmlBoxInsets, readOoxmlRunAttrStyles, readOoxmlTextDecoration, reportOoxmlTextDecorationLoss, transformAttributesFragmentSchema } from "./xml-fragments.js";
|
|
12
|
+
import { defineCanvasMechanism, defineShowMechanism } from "./mechanism.js";
|
|
13
|
+
import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
14
|
+
import "./media.js";
|
|
15
|
+
export { A_NS, C_NS, DIAGRAM_NS, DSP_NS, EMU_PER_PX, ImportError, MAXIMUM_COORDINATE_PX, MAXIMUM_WRITABLE_EMU, MC_NS, P14_CREATION_ID_EXT_URI, P14_NS, P159_NS, P_NS, REL_CHART, REL_DIAGRAM_DATA, REL_DIAGRAM_DRAWING, REL_HYPERLINK, REL_IMAGE, REL_NOTES_SLIDE, REL_SLIDE, R_NS, TABLE_NS_URI, XMLNS_NS, XML_NS, XmlElementCursor, allocateScopedAuthorId, appendUnconsumedDiagnostics, arrowTypeSchema, buildRelationshipIndex, canonicalQName, cascadeOoxmlTextDecoration, cascadedOmissionSchema, consumeIdentityShapeTreeBoilerplate, defineCanvasMechanism, defineShowMechanism, editabilityLossSchema, emuToPx, extentEmuFragmentSchema, fatalImportIssueSchema, hexRgb6Schema, importDiagnosticSchema, importLocationSchema, importOptionsSchema, importReportSchema, inspectUnsupportedGraphicFrame, offsetEmuFragmentSchema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlListLevelSchema, ooxmlNonNegativeIntSchema, ooxmlPlaceholderRoleSchema, ooxmlPositiveFixedAngleSchema, ooxmlPositiveIntSchema, ooxmlPositiveLineWidthEmuSchema, ooxmlWritableExtentEmuSchema, ooxmlWritablePositiveExtentEmuSchema, parseXmlPart, peekShapeTreeObjectIdentity, projectOoxmlTextDecoration, readBlipFill, readDrawingColor, readEffectList, readEmbeddedFontList, readGradientFill, readLineBorder, readOoxmlBoxInsets, readOoxmlRunAttrStyles, readOoxmlTextDecoration, readPartThemeOverride, readPlaceholderSpPrVisuals, readPlaceholderTransform, readPresentationThemeFontScheme, readRunFillAndStroke, readRunFontSlots, readTransformXml, reportOoxmlTextDecorationLoss, resolveExternalRelationshipTarget, resolveInternalRelationshipTarget, resolvePartPath, transformAttributesFragmentSchema, unpackEotFontData };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { P14_NS } from "./namespaces.js";
|
|
2
|
+
import { resolvePartPath } from "./opc.js";
|
|
3
|
+
// ../core/dist/kernel/pptx-read/media.js
|
|
4
|
+
/** Identifies a native media picture without claiming any XML on the import cursor. */
|
|
5
|
+
function mediaPictureKind(element) {
|
|
6
|
+
if (element.namespaceURI !== "http://schemas.openxmlformats.org/presentationml/2006/main" || element.localName !== "pic") return void 0;
|
|
7
|
+
if (element.getElementsByTagNameNS("http://schemas.openxmlformats.org/drawingml/2006/main", "videoFile").length > 0) return "video";
|
|
8
|
+
if (element.getElementsByTagNameNS("http://schemas.openxmlformats.org/drawingml/2006/main", "audioFile").length > 0) return "audio";
|
|
9
|
+
if (element.getElementsByTagNameNS("http://schemas.microsoft.com/office/powerpoint/2010/main", "media").length > 0) return "media";
|
|
10
|
+
}
|
|
11
|
+
/** Determines the media kind when PowerPoint's legacy audioFile or videoFile marker is absent. */
|
|
12
|
+
function inferModernMediaKind(element, pkg, part, relationships, timingKind) {
|
|
13
|
+
const media = element.getElementsByTagNameNS(P14_NS, "media")[0];
|
|
14
|
+
const id = media?.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "embed") || media?.getAttributeNS("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "link");
|
|
15
|
+
const relationship = id ? relationships.get(id) : void 0;
|
|
16
|
+
if (relationship?.Type !== "http://schemas.microsoft.com/office/2007/relationships/media") return timingKind;
|
|
17
|
+
const internalPart = relationship.TargetMode === "Internal" ? resolvePartPath(part, relationship.Target) : void 0;
|
|
18
|
+
const contentType = internalPart === void 0 ? void 0 : pkg.readContentType(internalPart);
|
|
19
|
+
if (contentType?.startsWith("audio/")) return "audio";
|
|
20
|
+
if (contentType?.startsWith("video/")) return "video";
|
|
21
|
+
if (timingKind !== void 0) return timingKind;
|
|
22
|
+
const path = relationship.Target.split(/[?#]/u, 1)[0] ?? "";
|
|
23
|
+
if (/\.(wav|mp3|m4a)$/iu.test(path)) return "audio";
|
|
24
|
+
if (/\.mp4$/iu.test(path)) return "video";
|
|
25
|
+
}
|
|
26
|
+
export { inferModernMediaKind, mediaPictureKind };
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { EMU_PER_PX, emuToPx } from "../drawing-units.js";
|
|
2
|
+
// ../core/dist/kernel/pptx-read/namespaces.js
|
|
2
3
|
const XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
|
3
4
|
const XML_NS = "http://www.w3.org/XML/1998/namespace";
|
|
4
5
|
const OPC_REL_NS = "http://schemas.openxmlformats.org/package/2006/relationships";
|
|
6
|
+
const CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
5
7
|
const MC_NS = "http://schemas.openxmlformats.org/markup-compatibility/2006";
|
|
6
8
|
const P_NS = "http://schemas.openxmlformats.org/presentationml/2006/main";
|
|
7
9
|
const P14_NS = "http://schemas.microsoft.com/office/powerpoint/2010/main";
|
|
@@ -10,6 +12,7 @@ const A_NS = "http://schemas.openxmlformats.org/drawingml/2006/main";
|
|
|
10
12
|
const C_NS = "http://schemas.openxmlformats.org/drawingml/2006/chart";
|
|
11
13
|
const R_NS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
|
|
12
14
|
const REL_OFFICE_DOCUMENT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
|
|
15
|
+
const REL_MEDIA = "http://schemas.microsoft.com/office/2007/relationships/media";
|
|
13
16
|
const REL_CHART = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart";
|
|
14
17
|
const REL_SLIDE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide";
|
|
15
18
|
const REL_SLIDE_LAYOUT = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout";
|
|
@@ -34,11 +37,6 @@ const TABLE_NS_URI = "http://schemas.openxmlformats.org/drawingml/2006/table";
|
|
|
34
37
|
const P14_SECTION_LIST_EXT_URI = "{521415D9-36F7-43E2-AB2F-B90AF26B5E84}";
|
|
35
38
|
const P14_CREATION_ID_EXT_URI = "{BB962C8B-B14F-4D97-AF65-F5344CB8AC3E}";
|
|
36
39
|
const STRICT_NS_PREFIX = "http://purl.oclc.org/ooxml/";
|
|
37
|
-
const EMU_PER_PX = 9525;
|
|
38
|
-
/** Converts DrawingML English Metric Units (EMU) to logical pixels (96 DPI). */
|
|
39
|
-
function emuToPx(emu) {
|
|
40
|
-
return emu / EMU_PER_PX;
|
|
41
|
-
}
|
|
42
40
|
const canonicalPrefixes = /* @__PURE__ */ new Map([
|
|
43
41
|
[P_NS, "p"],
|
|
44
42
|
[P14_NS, "p14"],
|
|
@@ -58,4 +56,4 @@ function canonicalQName(namespaceUri, localName) {
|
|
|
58
56
|
if (prefix !== void 0) return `${prefix}:${localName}`;
|
|
59
57
|
return `{${namespaceUri}}${localName}`;
|
|
60
58
|
}
|
|
61
|
-
export { A_NS, CHART_NS, C_NS, DIAGRAM_NS, DSP_NS, EMU_PER_PX, MC_NS, OPC_REL_NS, P14_CREATION_ID_EXT_URI, P14_NS, P14_SECTION_LIST_EXT_URI, P159_NS, P_NS, REL_CHART, REL_DIAGRAM_COLORS, REL_DIAGRAM_DATA, REL_DIAGRAM_DRAWING, REL_DIAGRAM_LAYOUT, REL_DIAGRAM_QUICK_STYLE, REL_FONT, REL_HANDOUT_MASTER, REL_HYPERLINK, REL_IMAGE, REL_NOTES_MASTER, REL_NOTES_SLIDE, REL_OFFICE_DOCUMENT, REL_SLIDE, REL_SLIDE_LAYOUT, REL_SLIDE_MASTER, REL_THEME, REL_THEME_OVERRIDE, R_NS, STRICT_NS_PREFIX, TABLE_NS_URI, XMLNS_NS, XML_NS, canonicalQName, emuToPx };
|
|
59
|
+
export { A_NS, CHART_NS, CONTENT_TYPES_NS, C_NS, DIAGRAM_NS, DSP_NS, EMU_PER_PX, MC_NS, OPC_REL_NS, P14_CREATION_ID_EXT_URI, P14_NS, P14_SECTION_LIST_EXT_URI, P159_NS, P_NS, REL_CHART, REL_DIAGRAM_COLORS, REL_DIAGRAM_DATA, REL_DIAGRAM_DRAWING, REL_DIAGRAM_LAYOUT, REL_DIAGRAM_QUICK_STYLE, REL_FONT, REL_HANDOUT_MASTER, REL_HYPERLINK, REL_IMAGE, REL_MEDIA, REL_NOTES_MASTER, REL_NOTES_SLIDE, REL_OFFICE_DOCUMENT, REL_SLIDE, REL_SLIDE_LAYOUT, REL_SLIDE_MASTER, REL_THEME, REL_THEME_OVERRIDE, R_NS, STRICT_NS_PREFIX, TABLE_NS_URI, XMLNS_NS, XML_NS, canonicalQName, emuToPx };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ImportError } from "./diagnostics.js";
|
|
2
|
-
import { OPC_REL_NS, REL_OFFICE_DOCUMENT } from "./namespaces.js";
|
|
2
|
+
import { CONTENT_TYPES_NS, OPC_REL_NS, REL_OFFICE_DOCUMENT } from "./namespaces.js";
|
|
3
3
|
import { MalformedXmlPartError, XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { strFromU8, unzipSync } from "fflate";
|
|
6
5
|
import { posix } from "node:path";
|
|
7
|
-
|
|
6
|
+
import { strFromU8, unzip } from "fflate";
|
|
7
|
+
// ../core/dist/kernel/pptx-read/opc.js
|
|
8
8
|
/** Zod schema for an OPC `<Relationship>` element attributes. */
|
|
9
9
|
const opcRelationshipSchema = z.object({
|
|
10
10
|
Id: z.string().min(1),
|
|
@@ -80,21 +80,64 @@ function detectStrictBaselineIssue(part, entries) {
|
|
|
80
80
|
}
|
|
81
81
|
}, `Unsupported ISO/IEC 29500 Strict OOXML relationship (${entry.Type}) in ${part}`);
|
|
82
82
|
}
|
|
83
|
+
function archiveError(error) {
|
|
84
|
+
return new ImportError({
|
|
85
|
+
code: "corrupt-archive",
|
|
86
|
+
category: "corrupt-input",
|
|
87
|
+
disposition: "aborted"
|
|
88
|
+
}, `Failed to unzip PPTX archive: ${error instanceof Error ? error.message : String(error)}`);
|
|
89
|
+
}
|
|
83
90
|
/**
|
|
84
|
-
*
|
|
91
|
+
* Copies the caller's bytes before asynchronous decompression, validates OPC entry points,
|
|
85
92
|
* rejects ISO/IEC 29500 Strict OOXML with structured diagnostics, and loads `presentation.xml`.
|
|
86
93
|
*/
|
|
87
|
-
function openPptxPackage(input) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
94
|
+
async function openPptxPackage(input, signal) {
|
|
95
|
+
if (signal?.aborted) throw signal.reason;
|
|
96
|
+
if (!(input instanceof Uint8Array)) throw archiveError(/* @__PURE__ */ new TypeError("PPTX input must be a Uint8Array"));
|
|
97
|
+
const snapshot = new Uint8Array(input);
|
|
98
|
+
const entries = await new Promise((resolve, reject) => {
|
|
99
|
+
const onAbort = () => {
|
|
100
|
+
signal?.removeEventListener?.("abort", onAbort);
|
|
101
|
+
terminate();
|
|
102
|
+
reject(signal?.reason);
|
|
103
|
+
};
|
|
104
|
+
const terminate = unzip(snapshot, (error, files) => {
|
|
105
|
+
signal?.removeEventListener?.("abort", onAbort);
|
|
106
|
+
if (error) reject(error);
|
|
107
|
+
else resolve(files);
|
|
108
|
+
});
|
|
109
|
+
signal?.addEventListener?.("abort", onAbort, { once: true });
|
|
110
|
+
}).catch((error) => {
|
|
111
|
+
if (signal?.aborted) throw signal.reason;
|
|
112
|
+
throw archiveError(error);
|
|
113
|
+
});
|
|
114
|
+
if (signal?.aborted) throw signal.reason;
|
|
115
|
+
return openPackageEntries(entries);
|
|
116
|
+
}
|
|
117
|
+
function readContentTypes(bytes) {
|
|
118
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
119
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
120
|
+
if (bytes !== void 0) try {
|
|
121
|
+
const root = parseXmlPart("[Content_Types].xml", strFromU8(bytes));
|
|
122
|
+
for (const item of Array.from(root.getElementsByTagNameNS(CONTENT_TYPES_NS, "Override"))) {
|
|
123
|
+
const part = item.getAttribute("PartName");
|
|
124
|
+
const contentType = item.getAttribute("ContentType");
|
|
125
|
+
if (part?.startsWith("/") && contentType) overrides.set(part.slice(1), contentType);
|
|
126
|
+
}
|
|
127
|
+
for (const item of Array.from(root.getElementsByTagNameNS(CONTENT_TYPES_NS, "Default"))) {
|
|
128
|
+
const extension = item.getAttribute("Extension");
|
|
129
|
+
const contentType = item.getAttribute("ContentType");
|
|
130
|
+
if (extension && contentType) defaults.set(extension.toLowerCase(), contentType);
|
|
131
|
+
}
|
|
91
132
|
} catch (error) {
|
|
92
|
-
throw
|
|
93
|
-
code: "corrupt-archive",
|
|
94
|
-
category: "corrupt-input",
|
|
95
|
-
disposition: "aborted"
|
|
96
|
-
}, `Failed to unzip PPTX archive: ${error instanceof Error ? error.message : String(error)}`);
|
|
133
|
+
if (!(error instanceof MalformedXmlPartError)) throw error;
|
|
97
134
|
}
|
|
135
|
+
return {
|
|
136
|
+
overrides,
|
|
137
|
+
defaults
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function openPackageEntries(rawEntries) {
|
|
98
141
|
const entries = /* @__PURE__ */ new Map();
|
|
99
142
|
for (const [name, bytes] of Object.entries(rawEntries)) entries.set(name.replace(/^\/+/u, ""), new Uint8Array(bytes));
|
|
100
143
|
const rootRelsPath = "_rels/.rels";
|
|
@@ -211,6 +254,7 @@ function openPptxPackage(input) {
|
|
|
211
254
|
}
|
|
212
255
|
};
|
|
213
256
|
const presRels = readRelationships(presentationPath);
|
|
257
|
+
let contentTypes;
|
|
214
258
|
return {
|
|
215
259
|
presentationPath,
|
|
216
260
|
presentationRoot,
|
|
@@ -219,6 +263,11 @@ function openPptxPackage(input) {
|
|
|
219
263
|
hasPart(partPath) {
|
|
220
264
|
return entries.has(partPath);
|
|
221
265
|
},
|
|
266
|
+
readContentType(partPath) {
|
|
267
|
+
contentTypes ??= readContentTypes(entries.get("[Content_Types].xml"));
|
|
268
|
+
const extension = posix.extname(partPath).slice(1).toLowerCase();
|
|
269
|
+
return contentTypes.overrides.get(partPath) ?? contentTypes.defaults.get(extension);
|
|
270
|
+
},
|
|
222
271
|
readTextPart(partPath) {
|
|
223
272
|
const bytes = entries.get(partPath);
|
|
224
273
|
return bytes === void 0 ? void 0 : strFromU8(bytes);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A_NS, DIAGRAM_NS, P_NS, REL_DIAGRAM_COLORS, REL_DIAGRAM_DATA, REL_DIAGRAM_LAYOUT, REL_DIAGRAM_QUICK_STYLE, R_NS } from "./namespaces.js";
|
|
2
2
|
import { resolvePartPath } from "./opc.js";
|
|
3
|
-
// ../
|
|
3
|
+
// ../core/dist/kernel/pptx-read/resources.js
|
|
4
4
|
/** Reads and indexes all OPC relationships owned by `sourcePartPath`. */
|
|
5
5
|
function buildRelationshipIndex(pkg, sourcePartPath) {
|
|
6
6
|
const { entries, diagnostics } = pkg.readRelationships(sourcePartPath);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { A_NS, P_NS } from "./namespaces.js";
|
|
2
|
+
// ../core/dist/kernel/pptx-read/shape-tree.js
|
|
3
|
+
function allocateScopedAuthorId(requested, used, fallbackBase) {
|
|
4
|
+
const base = requested !== void 0 && requested.trim().length > 0 ? requested.trim() : fallbackBase;
|
|
5
|
+
if (!used.has(base)) {
|
|
6
|
+
used.add(base);
|
|
7
|
+
return base;
|
|
8
|
+
}
|
|
9
|
+
let suffix = 2;
|
|
10
|
+
while (used.has(`${base}-${suffix}`)) suffix += 1;
|
|
11
|
+
const unique = `${base}-${suffix}`;
|
|
12
|
+
used.add(unique);
|
|
13
|
+
return unique;
|
|
14
|
+
}
|
|
15
|
+
/** Consumes standard identity `<p:nvGrpSpPr>` and `<p:grpSpPr>` transform boilerplate on an `spTree`. */
|
|
16
|
+
function consumeIdentityShapeTreeBoilerplate(spTree) {
|
|
17
|
+
const nvGrpSpPr = spTree.child(P_NS, "nvGrpSpPr");
|
|
18
|
+
if (nvGrpSpPr !== void 0) {
|
|
19
|
+
const cNvPr = nvGrpSpPr.child(P_NS, "cNvPr");
|
|
20
|
+
if (cNvPr !== void 0) {
|
|
21
|
+
cNvPr.consumeAttr("id");
|
|
22
|
+
cNvPr.consumeAttr("name");
|
|
23
|
+
}
|
|
24
|
+
nvGrpSpPr.ignoreEmptyChild(P_NS, "cNvGrpSpPr");
|
|
25
|
+
nvGrpSpPr.ignoreEmptyChild(P_NS, "nvPr");
|
|
26
|
+
}
|
|
27
|
+
const grpSpPr = spTree.child(P_NS, "grpSpPr");
|
|
28
|
+
if (grpSpPr !== void 0) {
|
|
29
|
+
const xfrm = grpSpPr.child(A_NS, "xfrm");
|
|
30
|
+
if (xfrm !== void 0) {
|
|
31
|
+
const off = xfrm.child(A_NS, "off");
|
|
32
|
+
if (off !== void 0 && off.attr("x") === "0" && off.attr("y") === "0") {}
|
|
33
|
+
const ext = xfrm.child(A_NS, "ext");
|
|
34
|
+
if (ext !== void 0 && ext.attr("cx") === "0" && ext.attr("cy") === "0") {}
|
|
35
|
+
const chOff = xfrm.child(A_NS, "chOff");
|
|
36
|
+
if (chOff !== void 0 && chOff.attr("x") === "0" && chOff.attr("y") === "0") {}
|
|
37
|
+
const chExt = xfrm.child(A_NS, "chExt");
|
|
38
|
+
if (chExt !== void 0 && chExt.attr("cx") === "0" && chExt.attr("cy") === "0") {}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Records `unconsumed-xml` diagnostics for all unconsumed attributes/elements under a root cursor. */
|
|
43
|
+
function appendUnconsumedDiagnostics(cursor, slideIndex, diagnostics) {
|
|
44
|
+
for (const item of cursor.collectUnconsumed()) diagnostics.push({
|
|
45
|
+
code: "unconsumed-xml",
|
|
46
|
+
category: "unsupported",
|
|
47
|
+
disposition: "omitted",
|
|
48
|
+
kind: item.kind,
|
|
49
|
+
location: {
|
|
50
|
+
...item.location,
|
|
51
|
+
...slideIndex === void 0 ? {} : { slideIndex }
|
|
52
|
+
},
|
|
53
|
+
namespaceUri: item.namespaceUri,
|
|
54
|
+
localName: item.localName
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export { allocateScopedAuthorId, appendUnconsumedDiagnostics, consumeIdentityShapeTreeBoilerplate };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { colorMapSchema, defaultColorMap, defineTheme, nativeColorSlots, schemeColorNames, schemeColorSlots } from "
|
|
2
|
-
import "
|
|
1
|
+
import { colorMapSchema, defaultColorMap, defineTheme, nativeColorSlots, schemeColorNames, schemeColorSlots } from "../theme.js";
|
|
2
|
+
import "../index.js";
|
|
3
3
|
import { A_NS } from "./namespaces.js";
|
|
4
|
+
import { resolvePartPath } from "./opc.js";
|
|
4
5
|
import { hexRgb6Schema, ooxmlBoolSchema, ooxmlIntSchema, ooxmlLineWidthEmuSchema, ooxmlNonNegativeIntSchema, ooxmlPositiveFixedAngleSchema, ooxmlWritableExtentEmuSchema } from "./xml-fragments.js";
|
|
5
6
|
import { XmlElementCursor, parseXmlPart } from "./xml-reader.js";
|
|
6
7
|
import { z } from "zod";
|
|
7
|
-
// ../
|
|
8
|
+
// ../core/dist/kernel/pptx-read/themes.js
|
|
8
9
|
const percentValAttrSchema = z.object({ val: ooxmlNonNegativeIntSchema });
|
|
9
10
|
const percentPosAttrSchema = z.object({ pos: ooxmlNonNegativeIntSchema });
|
|
10
11
|
const sysClrAttrSchema = z.object({
|
|
@@ -714,7 +715,41 @@ function readThemePart(pkg, themePartPath, themesByPartPath, diagnostics) {
|
|
|
714
715
|
themesByPartPath.set(themePartPath, theme);
|
|
715
716
|
return theme;
|
|
716
717
|
}
|
|
717
|
-
/**
|
|
718
|
+
/** Returns the first usable package theme override and reports broken relationships in either order. */
|
|
719
|
+
function readPartThemeOverride(pkg, relationships, owner, diagnostics) {
|
|
720
|
+
let override;
|
|
721
|
+
for (const relationship of relationships) {
|
|
722
|
+
if (relationship.Type !== "http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride") continue;
|
|
723
|
+
const location = {
|
|
724
|
+
...owner,
|
|
725
|
+
xpath: relationship.xpath
|
|
726
|
+
};
|
|
727
|
+
if (relationship.TargetMode === "External") {
|
|
728
|
+
diagnostics.push({
|
|
729
|
+
code: "broken-relationship",
|
|
730
|
+
category: "corrupt-input",
|
|
731
|
+
disposition: "omitted",
|
|
732
|
+
location,
|
|
733
|
+
relationshipId: relationship.Id
|
|
734
|
+
});
|
|
735
|
+
continue;
|
|
736
|
+
}
|
|
737
|
+
const target = resolvePartPath(owner.part, relationship.Target);
|
|
738
|
+
if (target === void 0 || !pkg.hasPart(target)) {
|
|
739
|
+
diagnostics.push({
|
|
740
|
+
code: "missing-target-part",
|
|
741
|
+
category: "corrupt-input",
|
|
742
|
+
disposition: "omitted",
|
|
743
|
+
location,
|
|
744
|
+
relationshipId: relationship.Id,
|
|
745
|
+
targetPart: target ?? relationship.Target
|
|
746
|
+
});
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
override ??= readThemeOverridePart(pkg, target, owner.slideIndex, diagnostics);
|
|
750
|
+
}
|
|
751
|
+
return override;
|
|
752
|
+
}
|
|
718
753
|
function readThemeOverridePart(pkg, overridePartPath, slideIndex, diagnostics) {
|
|
719
754
|
const xmlText = pkg.readTextPart(overridePartPath);
|
|
720
755
|
if (xmlText === void 0) return void 0;
|
|
@@ -774,4 +809,4 @@ function readThemeOverridePart(pkg, overridePartPath, slideIndex, diagnostics) {
|
|
|
774
809
|
function isNonDefaultColorMap(map) {
|
|
775
810
|
return !colorMapsEqual(map, defaultColorMap);
|
|
776
811
|
}
|
|
777
|
-
export { isNonDefaultColorMap, readColorMapElement, readColorMapOverride,
|
|
812
|
+
export { isNonDefaultColorMap, readColorMapElement, readColorMapOverride, readPartThemeOverride, readThemePart };
|