@officedk/pptxdk 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/dist/build-zrZuX4fK.d.ts +3 -0
- package/dist/build.d.ts +35 -0
- package/dist/build.js +128 -0
- package/dist/capabilities/dist/all.js +34 -0
- package/dist/capabilities/dist/box/box-codegen.js +84 -0
- package/dist/capabilities/dist/box/box-declaration.js +32 -0
- package/dist/capabilities/dist/box/box-elements.js +17 -0
- package/dist/capabilities/dist/box/box.js +142 -0
- package/dist/capabilities/dist/chart/chart-codegen.js +79 -0
- package/dist/capabilities/dist/chart/chart-declaration.js +7 -0
- package/dist/capabilities/dist/chart/chart-elements.js +12 -0
- package/dist/capabilities/dist/chart/chart-import.js +2403 -0
- package/dist/capabilities/dist/chart/chart-labels.js +86 -0
- package/dist/capabilities/dist/chart/chart-model.js +9 -0
- package/dist/capabilities/dist/chart/chart-schemas.js +1088 -0
- package/dist/capabilities/dist/chart/chart-xml.js +788 -0
- package/dist/capabilities/dist/chart/chart.js +1119 -0
- package/dist/capabilities/dist/chart/preview/axes-and-grid.js +311 -0
- package/dist/capabilities/dist/chart/preview/bar-column.js +143 -0
- package/dist/capabilities/dist/chart/preview/data-labels.js +334 -0
- package/dist/capabilities/dist/chart/preview/error-bars.js +213 -0
- package/dist/capabilities/dist/chart/preview/index.js +192 -0
- package/dist/capabilities/dist/chart/preview/layout.js +592 -0
- package/dist/capabilities/dist/chart/preview/legend.js +273 -0
- package/dist/capabilities/dist/chart/preview/line-area.js +404 -0
- package/dist/capabilities/dist/chart/preview/markers.js +100 -0
- package/dist/capabilities/dist/chart/preview/number-format.js +247 -0
- package/dist/capabilities/dist/chart/preview/pie-doughnut.js +159 -0
- package/dist/capabilities/dist/chart/preview/scales.js +365 -0
- package/dist/capabilities/dist/chart/preview/scatter.js +131 -0
- package/dist/capabilities/dist/chart/preview/style.js +60 -0
- package/dist/capabilities/dist/chart/preview/text-render.js +116 -0
- package/dist/capabilities/dist/chart/preview/trendlines.js +537 -0
- package/dist/capabilities/dist/chart/preview/types.js +5 -0
- package/dist/capabilities/dist/document.js +168 -0
- package/dist/capabilities/dist/font/font-embedding.js +119 -0
- package/dist/capabilities/dist/font/font-engine.js +834 -0
- package/dist/capabilities/dist/font/font-import.js +766 -0
- package/dist/capabilities/dist/font/font-subset.js +55 -0
- package/dist/capabilities/dist/font/font.js +72 -0
- package/dist/capabilities/dist/group/group-codegen.js +74 -0
- package/dist/capabilities/dist/group/group-declaration.js +41 -0
- package/dist/capabilities/dist/group/group-elements.js +12 -0
- package/dist/capabilities/dist/group/group-import.js +649 -0
- package/dist/capabilities/dist/group/group-xml.js +8 -0
- package/dist/capabilities/dist/group/group.js +260 -0
- package/dist/capabilities/dist/image/gif-decoder.js +244 -0
- package/dist/capabilities/dist/image/image-codegen.js +164 -0
- package/dist/capabilities/dist/image/image-declaration.js +8 -0
- package/dist/capabilities/dist/image/image-decode.js +244 -0
- package/dist/capabilities/dist/image/image-elements.js +12 -0
- package/dist/capabilities/dist/image/image-import.js +984 -0
- package/dist/capabilities/dist/image/image-schemas.js +147 -0
- package/dist/capabilities/dist/image/image-xml.js +12 -0
- package/dist/capabilities/dist/image/image.js +552 -0
- package/dist/capabilities/dist/line/line-codegen.js +89 -0
- package/dist/capabilities/dist/line/line-declaration.js +72 -0
- package/dist/capabilities/dist/line/line-elements.js +12 -0
- package/dist/capabilities/dist/line/line-import.js +504 -0
- package/dist/capabilities/dist/line/line-xml.js +9 -0
- package/dist/capabilities/dist/line/line.js +331 -0
- package/dist/capabilities/dist/masters/footer-placeholder.js +683 -0
- package/dist/capabilities/dist/masters/masters-codegen.js +69 -0
- package/dist/capabilities/dist/masters/masters.js +250 -0
- package/dist/capabilities/dist/motion/motion-api.js +757 -0
- package/dist/capabilities/dist/motion/motion-codegen.js +406 -0
- package/dist/capabilities/dist/motion/motion-elements.js +43 -0
- package/dist/capabilities/dist/motion/motion-import.js +1568 -0
- package/dist/capabilities/dist/motion/motion-plan.js +2340 -0
- package/dist/capabilities/dist/motion/motion-query.js +423 -0
- package/dist/capabilities/dist/motion/motion-schemas.js +339 -0
- package/dist/capabilities/dist/motion/motion.js +1617 -0
- package/dist/capabilities/dist/notes/notes-codegen.js +19 -0
- package/dist/capabilities/dist/notes/notes-declaration.js +8 -0
- package/dist/capabilities/dist/notes/notes-elements.js +12 -0
- package/dist/capabilities/dist/notes/notes-import.js +292 -0
- package/dist/capabilities/dist/notes/notes-schemas.js +38 -0
- package/dist/capabilities/dist/notes/notes-xml.js +38 -0
- package/dist/capabilities/dist/notes/notes.js +194 -0
- package/dist/capabilities/dist/placeholder/placeholder-codegen.js +54 -0
- package/dist/capabilities/dist/placeholder/placeholder-elements.js +13 -0
- package/dist/capabilities/dist/placeholder/placeholder-schemas.js +33 -0
- package/dist/capabilities/dist/placeholder/placeholder.js +451 -0
- package/dist/capabilities/dist/shape/shape-codegen.js +236 -0
- package/dist/capabilities/dist/shape/shape-declaration.js +45 -0
- package/dist/capabilities/dist/shape/shape-elements.js +12 -0
- package/dist/capabilities/dist/shape/shape-import.js +628 -0
- package/dist/capabilities/dist/shape/shape-xml.js +6 -0
- package/dist/capabilities/dist/shape/shape.js +320 -0
- package/dist/capabilities/dist/shared/geometry.js +1681 -0
- package/dist/capabilities/dist/shared/identity.js +205 -0
- package/dist/capabilities/dist/shared/morph-api.js +11 -0
- package/dist/capabilities/dist/shared/placeholder-import.js +238 -0
- package/dist/capabilities/dist/shared/preset-definitions.js +22423 -0
- package/dist/capabilities/dist/shared/style-inheritance.js +161 -0
- package/dist/capabilities/dist/shared/text-schemas.js +241 -0
- package/dist/capabilities/dist/shared/text-service.js +2252 -0
- package/dist/capabilities/dist/shared/visual.js +1197 -0
- package/dist/capabilities/dist/slide-background/slide-background-codegen.js +44 -0
- package/dist/capabilities/dist/slide-background/slide-background-import.js +166 -0
- package/dist/capabilities/dist/slide-background/slide-background-xml.js +34 -0
- package/dist/capabilities/dist/slide-background/slide-background.js +238 -0
- package/dist/capabilities/dist/table/table-codegen.js +125 -0
- package/dist/capabilities/dist/table/table-declaration.js +15 -0
- package/dist/capabilities/dist/table/table-elements.js +27 -0
- package/dist/capabilities/dist/table/table-import.js +606 -0
- package/dist/capabilities/dist/table/table-schemas.js +334 -0
- package/dist/capabilities/dist/table/table-xml.js +30 -0
- package/dist/capabilities/dist/table/table.js +739 -0
- package/dist/capabilities/dist/text/text-codegen.js +198 -0
- package/dist/capabilities/dist/text/text-declaration.js +27 -0
- package/dist/capabilities/dist/text/text-elements.js +54 -0
- package/dist/capabilities/dist/text/text-import.js +1224 -0
- package/dist/capabilities/dist/text/text-xml.js +9 -0
- package/dist/capabilities/dist/text/text.js +320 -0
- package/dist/capabilities/dist/transition/transition-api.js +136 -0
- package/dist/capabilities/dist/transition/transition-codegen.js +45 -0
- package/dist/capabilities/dist/transition/transition-import.js +477 -0
- package/dist/capabilities/dist/transition/transition.js +260 -0
- package/dist/capability-BbKW9w4O.d.ts +2131 -0
- package/dist/cli.js +20 -0
- package/dist/codegen/dist/assets.js +79 -0
- package/dist/codegen/dist/codegen.js +691 -0
- package/dist/codegen/dist/identifiers.js +203 -0
- package/dist/codegen/dist/index.js +3 -0
- package/dist/codegen/dist/printer.js +143 -0
- package/dist/codegen/dist/types.js +77 -0
- package/dist/core/dist/author-ids.js +51 -0
- package/dist/core/dist/author-schemas.js +330 -0
- package/dist/core/dist/block-flex-layout.js +801 -0
- package/dist/core/dist/build.js +4 -0
- package/dist/core/dist/capability.js +15 -0
- package/dist/core/dist/declaration.js +16 -0
- package/dist/core/dist/diagnostics.js +353 -0
- package/dist/core/dist/document-internals.js +26 -0
- package/dist/core/dist/document.js +417 -0
- package/dist/core/dist/font-seal.js +204 -0
- package/dist/core/dist/geometry-schemas.js +256 -0
- package/dist/core/dist/grid-layout.js +449 -0
- package/dist/core/dist/host.js +40 -0
- package/dist/core/dist/index.js +15 -0
- package/dist/core/dist/input-values.js +61 -0
- package/dist/core/dist/layout-protocol.js +61 -0
- package/dist/core/dist/layout-schemas.js +201 -0
- package/dist/core/dist/layout.js +340 -0
- package/dist/core/dist/masters.js +194 -0
- package/dist/core/dist/morph.js +30 -0
- package/dist/core/dist/placeholders.js +275 -0
- package/dist/core/dist/query.js +190 -0
- package/dist/core/dist/resolution.js +12 -0
- package/dist/core/dist/resolve.js +2246 -0
- package/dist/core/dist/stage-options.js +300 -0
- package/dist/core/dist/theme.js +1023 -0
- package/dist/core/dist/transform-geometry.js +72 -0
- package/dist/document-41spD7bq.d.ts +1350 -0
- package/dist/emit/dist/emit.js +957 -0
- package/dist/emit/dist/index.js +5 -0
- package/dist/emit/dist/ooxml.js +661 -0
- package/dist/emit/dist/shape-tree.js +12 -0
- package/dist/import/dist/alternate-content.js +54 -0
- package/dist/import/dist/diagnostics.js +157 -0
- package/dist/import/dist/fonts.js +309 -0
- package/dist/import/dist/import.js +513 -0
- package/dist/import/dist/index.js +16 -0
- package/dist/import/dist/masters.js +1293 -0
- package/dist/import/dist/mechanism.js +10 -0
- package/dist/import/dist/namespaces.js +61 -0
- package/dist/import/dist/notes-masters.js +300 -0
- package/dist/import/dist/opc.js +233 -0
- package/dist/import/dist/resources.js +166 -0
- package/dist/import/dist/sections.js +139 -0
- package/dist/import/dist/themes.js +777 -0
- package/dist/import/dist/visual.js +821 -0
- package/dist/import/dist/xml-fragments.js +277 -0
- package/dist/import/dist/xml-reader.js +267 -0
- package/dist/index-1ag7U9Jt.d.ts +63 -0
- package/dist/index-BEwhk7c8.d.ts +72 -0
- package/dist/index-cK2KtukZ.d.ts +161 -0
- package/dist/index-v77CTJev.d.ts +55 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +82 -0
- package/dist/node.d.ts +53 -0
- package/dist/node.js +225 -0
- package/dist/pptxdk/src/cli-commands.js +907 -0
- package/dist/pptxdk/src/compose.js +53 -0
- package/dist/pptxdk/src/slide.js +9 -0
- package/dist/preview/dist/index.js +342 -0
- package/dist/preview/dist/options.js +40 -0
- package/dist/preview/dist/svg-guard.js +1089 -0
- package/dist/preview.d.ts +12 -0
- package/dist/preview.js +29 -0
- package/dist/react/dist/append.js +66 -0
- package/dist/react/dist/document-adapter.js +404 -0
- package/dist/react/dist/elements.js +82 -0
- package/dist/react/dist/from-vanilla.js +57 -0
- package/dist/react/dist/index.js +89 -0
- package/dist/react/dist/mount.js +34 -0
- package/dist/react/dist/reconciler.js +290 -0
- package/dist/react.d.ts +235 -0
- package/dist/react.js +31 -0
- package/dist/transition-6n8GZxSg.d.ts +9 -0
- package/dist/vanilla.d.ts +4 -0
- package/dist/vanilla.js +15 -0
- package/package.json +79 -3
- package/README.md +0 -3
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { defineSlideLayout as defineSlideLayout$1 } from "../../core/dist/masters.js";
|
|
2
|
+
import "../../core/dist/index.js";
|
|
3
|
+
import { CommonNode, createDeckNode, createSectionNode, createSlideLayoutNode, createSlideMasterNode, createSlideNode } from "../../core/dist/document.js";
|
|
4
|
+
import { createBoxNode } from "./box/box-declaration.js";
|
|
5
|
+
import { createChartNode } from "./chart/chart-declaration.js";
|
|
6
|
+
import { font, fromFontCollection } from "./font/font.js";
|
|
7
|
+
import { createGroupNode } from "./group/group-declaration.js";
|
|
8
|
+
import { createImageNode } from "./image/image-declaration.js";
|
|
9
|
+
import { createLineNode } from "./line/line-declaration.js";
|
|
10
|
+
import { after, appear, breathe, collapse, createMotionScopeHandle, createMotionScopeNode, createMotionStepIdentity, createMotionStepNode, disappear, fade, fadeOut, fillColor, floatDown, floatOut, floatUp, fly, flyOut, onStep, repeat, spin, spinIn, spinOut, stretch, wipe, wipeOut, zoom, zoomOut } from "./motion/motion-api.js";
|
|
11
|
+
import { createNotesNode } from "./notes/notes-declaration.js";
|
|
12
|
+
import "./placeholder/placeholder.js";
|
|
13
|
+
import { createShapeNode } from "./shape/shape-declaration.js";
|
|
14
|
+
import { motionSchedule } from "./motion/motion-query.js";
|
|
15
|
+
import { createCellNode, createRowNode, createTableNode } from "./table/table-declaration.js";
|
|
16
|
+
import { createPlaceholderNode } from "./placeholder/placeholder-schemas.js";
|
|
17
|
+
import { createParagraphNode, createSlideNumberNode, createSpanNode, createSubNode, createSupNode, createTextNode } from "./text/text-declaration.js";
|
|
18
|
+
import { transitions } from "./transition/transition-api.js";
|
|
19
|
+
import { blockArc, path, preset } from "./shared/geometry.js";
|
|
20
|
+
import { linearGradient, radialGradient } from "./shared/visual.js";
|
|
21
|
+
// ../capabilities/dist/document.js
|
|
22
|
+
/** Narrowed `defineSlideLayout` wrapper enforcing capability-typed `transition` declarations. */
|
|
23
|
+
function defineSlideLayout(spec) {
|
|
24
|
+
return defineSlideLayout$1(spec);
|
|
25
|
+
}
|
|
26
|
+
function isPropsRecord(value) {
|
|
27
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
|
|
28
|
+
if (value instanceof CommonNode) return false;
|
|
29
|
+
return Object.prototype.toString.call(value) === "[object Object]";
|
|
30
|
+
}
|
|
31
|
+
function splitContent(args) {
|
|
32
|
+
const last = args.at(-1);
|
|
33
|
+
const hasProps = isPropsRecord(last);
|
|
34
|
+
return {
|
|
35
|
+
content: (hasProps ? args.slice(0, -1) : args).flatMap((value) => value === void 0 ? [] : Array.isArray(value) ? value : [value]),
|
|
36
|
+
props: hasProps ? last : void 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function deck(props = {}) {
|
|
40
|
+
return createDeckNode(props);
|
|
41
|
+
}
|
|
42
|
+
/** Creates an editable native SlideMaster container owning SlideLayouts. */
|
|
43
|
+
function slideMaster(props = {}) {
|
|
44
|
+
return createSlideMasterNode(props);
|
|
45
|
+
}
|
|
46
|
+
/** Creates an editable native SlideLayout node from inline props or a `defineSlideLayout` spec. */
|
|
47
|
+
function slideLayout(propsOrDefinition = {}) {
|
|
48
|
+
return createSlideLayoutNode(propsOrDefinition);
|
|
49
|
+
}
|
|
50
|
+
function slide(props) {
|
|
51
|
+
const { placeholders, ...rest } = props;
|
|
52
|
+
const entries = placeholders === void 0 ? [] : Object.entries(placeholders).filter(([, value]) => value !== void 0);
|
|
53
|
+
const keepEmptyPlaceholders = placeholders !== void 0 && props.layout === void 0 && entries.length === 0;
|
|
54
|
+
const node = createSlideNode(keepEmptyPlaceholders ? {
|
|
55
|
+
...rest,
|
|
56
|
+
placeholders
|
|
57
|
+
} : rest);
|
|
58
|
+
for (const [key, value] of entries) if (typeof value === "string" || Array.isArray(value)) node.append(text(value, { placeholder: key }));
|
|
59
|
+
else if (value instanceof CommonNode) {
|
|
60
|
+
if (value.type === "paragraph" || value.type === "span" || value.type === "sup" || value.type === "sub" || value.type === "slide-number") node.append(text(value, { placeholder: key }));
|
|
61
|
+
else {
|
|
62
|
+
value.set({ placeholder: key });
|
|
63
|
+
node.append(value);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return node;
|
|
67
|
+
}
|
|
68
|
+
function section(props) {
|
|
69
|
+
return createSectionNode(props);
|
|
70
|
+
}
|
|
71
|
+
function box(props = {}) {
|
|
72
|
+
return createBoxNode(props);
|
|
73
|
+
}
|
|
74
|
+
function shape(...args) {
|
|
75
|
+
const { content, props } = splitContent(args);
|
|
76
|
+
const node = createShapeNode(props ?? {});
|
|
77
|
+
node.content(...content);
|
|
78
|
+
return node;
|
|
79
|
+
}
|
|
80
|
+
/** Creates an unpopulated native content placeholder bound to a layout placeholder slot. */
|
|
81
|
+
function placeholder(props = {}) {
|
|
82
|
+
return createPlaceholderNode(props);
|
|
83
|
+
}
|
|
84
|
+
/** Creates a native image whose source bytes, crop, fit, and visuals remain editable after attachment. */
|
|
85
|
+
function image(props) {
|
|
86
|
+
return createImageNode(props);
|
|
87
|
+
}
|
|
88
|
+
/** Creates a 1D line or connector (`<p:cxnSp>`) with box-layout or anchored `from`/`to` positioning. */
|
|
89
|
+
function line(props = {}) {
|
|
90
|
+
return createLineNode(props);
|
|
91
|
+
}
|
|
92
|
+
/** Creates a native group preserving member identity and layout children. */
|
|
93
|
+
function group(props = {}) {
|
|
94
|
+
return createGroupNode(props);
|
|
95
|
+
}
|
|
96
|
+
/** Creates a native table whose rows and cells remain editable after attachment. */
|
|
97
|
+
function table(props) {
|
|
98
|
+
return createTableNode(props);
|
|
99
|
+
}
|
|
100
|
+
/** Creates a native table row; attach it to a table and add cells through its content operations. */
|
|
101
|
+
function row(props = {}) {
|
|
102
|
+
return createRowNode(props);
|
|
103
|
+
}
|
|
104
|
+
function cell(...args) {
|
|
105
|
+
const { content, props } = splitContent(args);
|
|
106
|
+
const node = createCellNode(props ?? {});
|
|
107
|
+
node.content(...content);
|
|
108
|
+
return node;
|
|
109
|
+
}
|
|
110
|
+
/** Creates a native chart whose data, options, and styles remain editable after attachment. */
|
|
111
|
+
function chart(props) {
|
|
112
|
+
return createChartNode(props);
|
|
113
|
+
}
|
|
114
|
+
function text(...args) {
|
|
115
|
+
const { content, props } = splitContent(args);
|
|
116
|
+
const node = createTextNode(props ?? {});
|
|
117
|
+
node.content(...content);
|
|
118
|
+
return node;
|
|
119
|
+
}
|
|
120
|
+
function notes(...args) {
|
|
121
|
+
const { content, props } = splitContent(args);
|
|
122
|
+
const node = createNotesNode(props ?? {});
|
|
123
|
+
node.content(...content);
|
|
124
|
+
return node;
|
|
125
|
+
}
|
|
126
|
+
function paragraph(...args) {
|
|
127
|
+
const { content, props } = splitContent(args);
|
|
128
|
+
const node = createParagraphNode(props ?? {});
|
|
129
|
+
node.content(...content);
|
|
130
|
+
return node;
|
|
131
|
+
}
|
|
132
|
+
function span(...args) {
|
|
133
|
+
const { content, props } = splitContent(args);
|
|
134
|
+
const node = createSpanNode(props ?? {});
|
|
135
|
+
node.content(...content);
|
|
136
|
+
return node;
|
|
137
|
+
}
|
|
138
|
+
function sup(...args) {
|
|
139
|
+
const { content, props } = splitContent(args);
|
|
140
|
+
const node = createSupNode(props ?? {});
|
|
141
|
+
node.content(...content);
|
|
142
|
+
return node;
|
|
143
|
+
}
|
|
144
|
+
function sub(...args) {
|
|
145
|
+
const { content, props } = splitContent(args);
|
|
146
|
+
const node = createSubNode(props ?? {});
|
|
147
|
+
node.content(...content);
|
|
148
|
+
return node;
|
|
149
|
+
}
|
|
150
|
+
/** Emits the native slide number field, resolved by the presentation application. */
|
|
151
|
+
function slideNumber(props = {}) {
|
|
152
|
+
return createSlideNumberNode(props);
|
|
153
|
+
}
|
|
154
|
+
/** Creates an orchestration scope whose parent chain and click step are derived by each build. */
|
|
155
|
+
function motionScope(scope, props = {}) {
|
|
156
|
+
return createMotionScopeNode({
|
|
157
|
+
...props,
|
|
158
|
+
scope
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/** Creates a click-step container; omitted n gives this Step its own independent trigger. */
|
|
162
|
+
function step(props = {}) {
|
|
163
|
+
return createMotionStepNode({
|
|
164
|
+
...props,
|
|
165
|
+
stepIdentity: createMotionStepIdentity()
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export { after, appear, blockArc, box, breathe, cell, chart, collapse, createMotionScopeHandle, deck, defineSlideLayout, disappear, fade, fadeOut, fillColor, floatDown, floatOut, floatUp, fly, flyOut, font, fromFontCollection, group, image, line, linearGradient, motionSchedule, motionScope, notes, onStep, paragraph, path, placeholder, preset, radialGradient, repeat, row, section, shape, slide, slideLayout, slideMaster, slideNumber, span, spin, spinIn, spinOut, step, stretch, sub, sup, table, text, transitions, wipe, wipeOut, zoom, zoomOut };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { CapabilityError } from "../../../core/dist/diagnostics.js";
|
|
2
|
+
import "../../../core/dist/capability.js";
|
|
3
|
+
import { xmlEscape } from "../../../emit/dist/ooxml.js";
|
|
4
|
+
import "../../../emit/dist/index.js";
|
|
5
|
+
import { buildEmbeddedEotPayload, fontFamilyKey, validateEmbeddableTrueTypeFont } from "./font-engine.js";
|
|
6
|
+
// ../capabilities/dist/font/font-embedding.js
|
|
7
|
+
/** Retains control characters and default ignorable code points in text stream without requiring standalone cmap glyphs. */
|
|
8
|
+
function requiresFontGlyph(character) {
|
|
9
|
+
return !/^[\p{Cc}\p{Default_Ignorable_Code_Point}]$/u.test(character);
|
|
10
|
+
}
|
|
11
|
+
/** Checks whether a character is a visible non-whitespace character requiring a non-.notdef glyph. */
|
|
12
|
+
function requiresVisibleFontGlyph(character) {
|
|
13
|
+
return !/^[\p{Cc}\p{Default_Ignorable_Code_Point}\p{White_Space}]$/u.test(character);
|
|
14
|
+
}
|
|
15
|
+
const fontRelationship = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font";
|
|
16
|
+
const fontContentType = "application/x-fontdata";
|
|
17
|
+
function fail(use, code, message, extraDetails) {
|
|
18
|
+
throw new CapabilityError(code, message, use.path, {
|
|
19
|
+
font: {
|
|
20
|
+
family: use.family,
|
|
21
|
+
weight: use.weight,
|
|
22
|
+
style: use.style
|
|
23
|
+
},
|
|
24
|
+
...extraDetails
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function slot(bold, italic) {
|
|
28
|
+
if (bold) return italic ? "boldItalic" : "bold";
|
|
29
|
+
return italic ? "italic" : "regular";
|
|
30
|
+
}
|
|
31
|
+
function slotOrder(value) {
|
|
32
|
+
return {
|
|
33
|
+
regular: 0,
|
|
34
|
+
bold: 1,
|
|
35
|
+
italic: 2,
|
|
36
|
+
boldItalic: 3
|
|
37
|
+
}[value];
|
|
38
|
+
}
|
|
39
|
+
function formatEmbeddedFontSlotConflictMessage(family, styleSlot, nativeLegacyFamily) {
|
|
40
|
+
if (nativeLegacyFamily !== void 0 && fontFamilyKey(nativeLegacyFamily) !== fontFamilyKey(family)) return `Font family "${family}" maps multiple font files to the "${styleSlot}" embedding slot (conflicting file native Name ID 1: "${nativeLegacyFamily}"). OOXML (<p:embeddedFont>) supports only four slots per font family (regular, bold, italic, boldItalic); register "${nativeLegacyFamily}" as a separate font family.`;
|
|
41
|
+
return `Font family "${family}" maps multiple font files to the "${styleSlot}" embedding slot${nativeLegacyFamily === void 0 ? "" : ` (file native Name ID 1: "${nativeLegacyFamily}")`}. OOXML (<p:embeddedFont>) supports only four slots per font family (regular, bold, italic, boldItalic); register additional weights (such as 500 Medium or 600 SemiBold) under a separate font family name (for example "${family} Medium").`;
|
|
42
|
+
}
|
|
43
|
+
function embeddedFontSlotConflictDetails(use) {
|
|
44
|
+
return {
|
|
45
|
+
font: {
|
|
46
|
+
family: use.family,
|
|
47
|
+
weight: use.weight,
|
|
48
|
+
style: use.style
|
|
49
|
+
},
|
|
50
|
+
reason: "not-embeddable"
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Generates full fonts or presentation character subsets according to emitted families and styles. */
|
|
54
|
+
function fontPresentationContributions(uses, requested) {
|
|
55
|
+
if (requested === void 0) return [];
|
|
56
|
+
const contributions = [];
|
|
57
|
+
const slots = /* @__PURE__ */ new Map();
|
|
58
|
+
const recordContents = /* @__PURE__ */ new Map();
|
|
59
|
+
for (const use of uses) {
|
|
60
|
+
const checked = validateEmbeddableTrueTypeFont(use, requested);
|
|
61
|
+
const styleSlot = slot(checked.os2Bold, checked.isItalic);
|
|
62
|
+
const family = xmlEscape(use.family);
|
|
63
|
+
const recordKey = fontFamilyKey(use.family);
|
|
64
|
+
let recordContent = recordContents.get(recordKey);
|
|
65
|
+
if (recordContent === void 0) {
|
|
66
|
+
recordContent = `<p:font typeface="${family}"${checked.panose === void 0 ? "" : ` panose="${checked.panose}"`} pitchFamily="${checked.pitchFamily}" charset="${checked.charset}"/>`;
|
|
67
|
+
recordContents.set(recordKey, recordContent);
|
|
68
|
+
}
|
|
69
|
+
const recordIdentity = recordKey;
|
|
70
|
+
const itemKey = `${recordKey}\u0000${styleSlot}`;
|
|
71
|
+
const existing = slots.get(itemKey);
|
|
72
|
+
const conflictDetails = embeddedFontSlotConflictDetails(use);
|
|
73
|
+
if (existing !== void 0 && existing.identity !== use.identity) {
|
|
74
|
+
const conflictNative = checked.primaryLegacyFamily !== void 0 && fontFamilyKey(checked.primaryLegacyFamily) !== fontFamilyKey(use.family) ? checked.primaryLegacyFamily : existing.primaryLegacyFamily ?? checked.primaryLegacyFamily;
|
|
75
|
+
return fail(use, "font-unavailable", formatEmbeddedFontSlotConflictMessage(use.family, styleSlot, conflictNative), { reason: "not-embeddable" });
|
|
76
|
+
}
|
|
77
|
+
if (existing !== void 0) continue;
|
|
78
|
+
slots.set(itemKey, {
|
|
79
|
+
identity: use.identity,
|
|
80
|
+
primaryLegacyFamily: checked.primaryLegacyFamily
|
|
81
|
+
});
|
|
82
|
+
const conflictMessage = formatEmbeddedFontSlotConflictMessage(use.family, styleSlot, checked.primaryLegacyFamily);
|
|
83
|
+
const resourceClaim = {
|
|
84
|
+
kind: "font-face",
|
|
85
|
+
key: use.claimKey
|
|
86
|
+
};
|
|
87
|
+
const resolveBytes = requested === "subset" ? (characters) => buildEmbeddedEotPayload(use.bytes, checked, "subset", characters, use, requiresVisibleFontGlyph) : void 0;
|
|
88
|
+
contributions.push({
|
|
89
|
+
collection: "p:embeddedFontLst",
|
|
90
|
+
presentationAttributes: { embedTrueTypeFonts: "1" },
|
|
91
|
+
record: {
|
|
92
|
+
key: recordKey,
|
|
93
|
+
identity: recordIdentity,
|
|
94
|
+
tagName: "p:embeddedFont",
|
|
95
|
+
content: recordContent
|
|
96
|
+
},
|
|
97
|
+
item: {
|
|
98
|
+
key: styleSlot,
|
|
99
|
+
identity: use.identity,
|
|
100
|
+
order: slotOrder(styleSlot),
|
|
101
|
+
relationshipType: fontRelationship,
|
|
102
|
+
pathTemplate: "ppt/fonts/font{n}.fntdata",
|
|
103
|
+
contentType: fontContentType,
|
|
104
|
+
...resolveBytes === void 0 ? { bytes: buildEmbeddedEotPayload(use.bytes, checked, "full", void 0, use, requiresVisibleFontGlyph) } : {
|
|
105
|
+
resourceClaim,
|
|
106
|
+
resolveBytes
|
|
107
|
+
},
|
|
108
|
+
content: (relationshipId) => `<p:${styleSlot} r:id="${xmlEscape(relationshipId)}"/>`,
|
|
109
|
+
onConflict: {
|
|
110
|
+
code: "font-unavailable",
|
|
111
|
+
message: conflictMessage,
|
|
112
|
+
details: conflictDetails
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return contributions;
|
|
118
|
+
}
|
|
119
|
+
export { fontPresentationContributions, requiresFontGlyph, requiresVisibleFontGlyph };
|