@office-open/core 0.14.2 → 0.14.3
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/chart/index.mjs +1 -1
- package/dist/{chart-D0AdnVLT.mjs → chart-DgwOj5KH.mjs} +4 -4
- package/dist/{chart-D0AdnVLT.mjs.map → chart-DgwOj5KH.mjs.map} +1 -1
- package/dist/drawing/index.mjs +1 -1
- package/dist/{drawing-BP4zc7an.mjs → drawing-Daklr1d9.mjs} +2 -2
- package/dist/{drawing-BP4zc7an.mjs.map → drawing-Daklr1d9.mjs.map} +1 -1
- package/dist/{ext-uri-5jTDczSP.mjs → ext-uri-CCwd6FZE.mjs} +20 -3
- package/dist/ext-uri-CCwd6FZE.mjs.map +1 -0
- package/dist/{index-Cd0lFS5x.d.mts → index-BETSqrn1.d.mts} +97 -3
- package/dist/index-BETSqrn1.d.mts.map +1 -0
- package/dist/index.d.mts +18 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +66 -219
- package/dist/index.mjs.map +1 -1
- package/dist/smartart/index.mjs +1 -1
- package/dist/{smartart-CrVPot34.mjs → smartart-BMDH5tRW.mjs} +4 -4
- package/dist/{smartart-CrVPot34.mjs.map → smartart-BMDH5tRW.mjs.map} +1 -1
- package/dist/{style-matrix-B69960kl.mjs → style-matrix-BSk2hcAC.mjs} +2 -2
- package/dist/{style-matrix-B69960kl.mjs.map → style-matrix-BSk2hcAC.mjs.map} +1 -1
- package/dist/theme/index.mjs +2 -2
- package/dist/{theme-BINSAPMD.mjs → theme-CSJvGlzF.mjs} +3 -3
- package/dist/{theme-BINSAPMD.mjs.map → theme-CSJvGlzF.mjs.map} +1 -1
- package/dist/util/index.d.mts +2 -2
- package/dist/util/index.mjs +3 -3
- package/dist/{util-D61LJ_Wz.mjs → util-CeVahkDr.mjs} +316 -7
- package/dist/util-CeVahkDr.mjs.map +1 -0
- package/dist/values-BECDm4zr.d.mts.map +1 -1
- package/package.json +2 -2
- package/dist/ext-uri-5jTDczSP.mjs.map +0 -1
- package/dist/index-Cd0lFS5x.d.mts.map +0 -1
- package/dist/util-D61LJ_Wz.mjs.map +0 -1
|
@@ -1,6 +1,302 @@
|
|
|
1
|
-
import { Bt as Buffer, zt as encodeBase64 } from "./ext-uri-
|
|
1
|
+
import { Bt as Buffer, zt as encodeBase64 } from "./ext-uri-CCwd6FZE.mjs";
|
|
2
|
+
import { escapeXml } from "@office-open/xml";
|
|
2
3
|
import { AsyncZipDeflate, Zip, ZipDeflate, ZipPassThrough, inflateSync, strFromU8, strFromU8 as strFromU8$1, unzipSync as unzipSync$1, zip, zipSync, zipSync as zipSync$1 } from "fflate";
|
|
3
4
|
import { sha512 } from "@noble/hashes/sha2.js";
|
|
5
|
+
//#region src/opc/relationships.ts
|
|
6
|
+
/** OPC relationship type URIs keyed by their trailing token — the single
|
|
7
|
+
* source for every relationship type this library emits or accepts. The
|
|
8
|
+
* {@link RelationshipType} union derives from it, so a typo is a compile
|
|
9
|
+
* error instead of a corrupt package. Spec files keep raw URI literals as
|
|
10
|
+
* independent expected-value anchors. */
|
|
11
|
+
const RELATIONSHIP_TYPES = {
|
|
12
|
+
txbxMs: "http://schemas.microsoft.com/office/2006/relationships/txbx",
|
|
13
|
+
diagramColorsMs: "http://schemas.microsoft.com/office/2007/relationships/diagramColors",
|
|
14
|
+
diagramDrawingMs: "http://schemas.microsoft.com/office/2007/relationships/diagramDrawing",
|
|
15
|
+
diagramLayoutMs: "http://schemas.microsoft.com/office/2007/relationships/diagramLayout",
|
|
16
|
+
diagramStyleMs: "http://schemas.microsoft.com/office/2007/relationships/diagramStyle",
|
|
17
|
+
mediaMs: "http://schemas.microsoft.com/office/2007/relationships/media",
|
|
18
|
+
commentsExtendedMs: "http://schemas.microsoft.com/office/2011/relationships/commentsExtended",
|
|
19
|
+
peopleMs: "http://schemas.microsoft.com/office/2011/relationships/people",
|
|
20
|
+
aFChunk: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk",
|
|
21
|
+
attachedTemplate: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate",
|
|
22
|
+
audio: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/audio",
|
|
23
|
+
bibliography: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography",
|
|
24
|
+
calcChain: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain",
|
|
25
|
+
chart: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart",
|
|
26
|
+
chartUserShapes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartUserShapes",
|
|
27
|
+
chartsheet: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet",
|
|
28
|
+
commentAuthors: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors",
|
|
29
|
+
comments: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments",
|
|
30
|
+
connections: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/connections",
|
|
31
|
+
customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties",
|
|
32
|
+
customXml: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml",
|
|
33
|
+
diagramColors: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors",
|
|
34
|
+
diagramData: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData",
|
|
35
|
+
diagramLayout: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout",
|
|
36
|
+
diagramQuickStyle: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle",
|
|
37
|
+
dialogsheet: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/dialogsheet",
|
|
38
|
+
drawing: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing",
|
|
39
|
+
endnotes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes",
|
|
40
|
+
extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties",
|
|
41
|
+
externalLink: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink",
|
|
42
|
+
externalLinkPath: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath",
|
|
43
|
+
font: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/font",
|
|
44
|
+
fontTable: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable",
|
|
45
|
+
footer: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer",
|
|
46
|
+
footnotes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
|
|
47
|
+
glossaryDocument: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument",
|
|
48
|
+
handoutMaster: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster",
|
|
49
|
+
header: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header",
|
|
50
|
+
hyperlink: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink",
|
|
51
|
+
image: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image",
|
|
52
|
+
metadata: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/metadata",
|
|
53
|
+
notesMaster: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster",
|
|
54
|
+
notesSlide: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide",
|
|
55
|
+
numbering: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering",
|
|
56
|
+
officeDocument: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
|
|
57
|
+
oleObject: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject",
|
|
58
|
+
package: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package",
|
|
59
|
+
pivotCacheDefinition: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition",
|
|
60
|
+
pivotCacheRecords: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords",
|
|
61
|
+
pivotTable: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable",
|
|
62
|
+
presProps: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps",
|
|
63
|
+
queryTable: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/queryTable",
|
|
64
|
+
revisionHeaders: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionHeaders",
|
|
65
|
+
revisionLog: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionLog",
|
|
66
|
+
settings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
|
|
67
|
+
sharedStrings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings",
|
|
68
|
+
sheetMetadata: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata",
|
|
69
|
+
slide: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide",
|
|
70
|
+
slideLayout: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout",
|
|
71
|
+
slideMaster: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster",
|
|
72
|
+
slideSyncProperties: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideSyncProperties",
|
|
73
|
+
styles: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles",
|
|
74
|
+
subDocument: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/subDocument",
|
|
75
|
+
table: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/table",
|
|
76
|
+
tableSingleCells: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableSingleCells",
|
|
77
|
+
tableStyles: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles",
|
|
78
|
+
theme: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
|
|
79
|
+
themeManager: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeManager",
|
|
80
|
+
themeOverride: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/themeOverride",
|
|
81
|
+
users: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/users",
|
|
82
|
+
video: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/video",
|
|
83
|
+
viewProps: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps",
|
|
84
|
+
vmlDrawing: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing",
|
|
85
|
+
volTypes: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/volTypes",
|
|
86
|
+
webSettings: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings",
|
|
87
|
+
worksheet: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
|
|
88
|
+
xmlMaps: "http://schemas.openxmlformats.org/officeDocument/2006/relationships/xmlMaps",
|
|
89
|
+
metadataCoreProperties: "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"
|
|
90
|
+
};
|
|
91
|
+
const TargetModeType = { EXTERNAL: "External" };
|
|
92
|
+
/**
|
|
93
|
+
* Manages OOXML relationship entries and serializes to XML.
|
|
94
|
+
*
|
|
95
|
+
* Standalone class — no XmlComponent inheritance.
|
|
96
|
+
* Pure string concatenation for zero-allocation XML output.
|
|
97
|
+
*/
|
|
98
|
+
var Relationships = class {
|
|
99
|
+
entries = [];
|
|
100
|
+
maxId = 0;
|
|
101
|
+
trackId(rid) {
|
|
102
|
+
const n = /^rId(\d+)$/.exec(rid);
|
|
103
|
+
if (n) this.maxId = Math.max(this.maxId, Number(n[1]));
|
|
104
|
+
}
|
|
105
|
+
addRelationship(id, type, target, targetMode) {
|
|
106
|
+
const rid = typeof id === "number" ? `rId${id}` : id;
|
|
107
|
+
this.trackId(rid);
|
|
108
|
+
this.entries.push({
|
|
109
|
+
id: rid,
|
|
110
|
+
type,
|
|
111
|
+
target,
|
|
112
|
+
targetMode
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Register a relationship with an auto-allocated sequential id and return
|
|
117
|
+
* the numeric id. Prefer this over the `relationshipCount + 1` +
|
|
118
|
+
* `addRelationship` pair at every call site that wants the next id; reach
|
|
119
|
+
* for `addRelationship` directly only when the id is externally determined
|
|
120
|
+
* (a contiguous batch pre-computed from an offset, a fixed rId1, …).
|
|
121
|
+
*
|
|
122
|
+
* The id is max(existing) + 1, not count + 1 — externally-determined ids
|
|
123
|
+
* (passthrough source ids) can leave gaps, and a gap-following count-based
|
|
124
|
+
* id would collide with an existing entry (duplicate Relationship ids
|
|
125
|
+
* corrupt the package for Office applications).
|
|
126
|
+
*/
|
|
127
|
+
add(type, target, targetMode) {
|
|
128
|
+
const id = this.maxId + 1;
|
|
129
|
+
this.maxId = id;
|
|
130
|
+
this.entries.push({
|
|
131
|
+
id: `rId${id}`,
|
|
132
|
+
type,
|
|
133
|
+
target,
|
|
134
|
+
targetMode
|
|
135
|
+
});
|
|
136
|
+
return id;
|
|
137
|
+
}
|
|
138
|
+
get relationshipCount() {
|
|
139
|
+
return this.entries.length;
|
|
140
|
+
}
|
|
141
|
+
/** The next free numeric id (max existing + 1) — the safe offset base when
|
|
142
|
+
* externally-determined ids (passthrough source ids) leave gaps below it. */
|
|
143
|
+
get nextRelationshipId() {
|
|
144
|
+
return this.maxId + 1;
|
|
145
|
+
}
|
|
146
|
+
/** Pre-claim a source id without registering an entry. Reserving every
|
|
147
|
+
* passthrough source id up front keeps auto-allocated ids (add(), next)
|
|
148
|
+
* strictly above the source id space, so a part the source didn't carry
|
|
149
|
+
* (a fresh comment, say) can never take an id a later source re-use will
|
|
150
|
+
* need — re-emitting the source rel at a taken id corrupts the package.
|
|
151
|
+
* Accepts the passthrough `rId` form ("rId7") or a bare number. */
|
|
152
|
+
reserveId(id) {
|
|
153
|
+
const n = typeof id === "number" ? id : /^rId(\d+)$/.exec(id)?.[1];
|
|
154
|
+
if (n !== void 0) this.trackId(`rId${n}`);
|
|
155
|
+
}
|
|
156
|
+
/** Reserve every passthrough id held by one source part — the uniform entry
|
|
157
|
+
* point compilers call before filling a part's rels from the model. Without
|
|
158
|
+
* it the model's batch allocations (offset snapshots, add()) can land on a
|
|
159
|
+
* source id, forcing the later source re-emission to collide or renumber
|
|
160
|
+
* (renumbering dangles the verbatim references that motivated keeping the
|
|
161
|
+
* source id). Reserving is invisible to hasId/hasRelationship, so source
|
|
162
|
+
* re-emission and rename-to-source-id still work. */
|
|
163
|
+
reserveSourceRids(source, passthrough) {
|
|
164
|
+
for (const rel of passthrough) if (rel.source === source) this.reserveId(rel.rId);
|
|
165
|
+
}
|
|
166
|
+
/** Rename the first entry matching `type` to `newId` — used to promote a
|
|
167
|
+
* structured rel (e.g. the slide layout) to its source id when the
|
|
168
|
+
* source rId is free. No-op when the slot is taken or no match. */
|
|
169
|
+
renameEntryByType(type, newId) {
|
|
170
|
+
if (this.hasId(`rId${newId}`)) return;
|
|
171
|
+
const entry = this.entries.find((e) => e.type === type);
|
|
172
|
+
if (entry) {
|
|
173
|
+
entry.id = `rId${newId}`;
|
|
174
|
+
this.maxId = Math.max(this.maxId, newId);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** Numeric id of the first entry matching `kind` (last segment of the type
|
|
178
|
+
* URI), or undefined when none is registered. */
|
|
179
|
+
idByKind(kind) {
|
|
180
|
+
const entry = this.entries.find((e) => e.type.split("/").pop() === kind);
|
|
181
|
+
if (!entry) return void 0;
|
|
182
|
+
const m = /^rId(\d+)$/.exec(entry.id);
|
|
183
|
+
if (!m) return void 0;
|
|
184
|
+
return Number(m[1]);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Claim a captured source relationship (round-trip pre-claim). Verbatim
|
|
188
|
+
* part content references the source rIds, so re-emit the rel at its exact
|
|
189
|
+
* source id whenever that slot is still free — renumbering would dangle
|
|
190
|
+
* those references. Skips rels already registered under the same
|
|
191
|
+
* kind+target (the model absorbed them); falls back to an auto id for
|
|
192
|
+
* non-numeric source ids.
|
|
193
|
+
*/
|
|
194
|
+
claimSourceRel(rel) {
|
|
195
|
+
if (this.hasRelationship(rel.relationshipType, rel.target)) return;
|
|
196
|
+
const numeric = /^rId(\d+)$/.exec(rel.rId);
|
|
197
|
+
if (numeric && !this.hasId(rel.rId)) this.addRelationship(Number(numeric[1]), rel.relationshipType, rel.target, rel.targetMode);
|
|
198
|
+
else this.add(rel.relationshipType, rel.target, rel.targetMode);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* True when a relationship of the same kind and target is already
|
|
202
|
+
* registered. The kind compares only the relationship type's last path
|
|
203
|
+
* segment, so the transitional and strict URI forms of the same
|
|
204
|
+
* relationship compare equal — passthrough re-emission uses this to skip
|
|
205
|
+
* relationships the compiler already wired (a duplicate entry corrupts the
|
|
206
|
+
* package for Office applications).
|
|
207
|
+
*/
|
|
208
|
+
hasRelationship(type, target) {
|
|
209
|
+
const kind = type.split("/").pop();
|
|
210
|
+
return this.entries.some((e) => e.type.split("/").pop() === kind && e.target === target);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* True when any entry carries the relationship kind (last type segment).
|
|
214
|
+
* Round-trip re-emission uses this as the ownership test: a rebuilt part
|
|
215
|
+
* that already registered a rel of this kind absorbed the concept, so the
|
|
216
|
+
* captured source rel (possibly a renamed target or the ISO-strict type
|
|
217
|
+
* dual) must not be re-emitted alongside it.
|
|
218
|
+
*/
|
|
219
|
+
hasRelationshipKind(kind) {
|
|
220
|
+
return this.entries.some((e) => e.type.split("/").pop() === kind);
|
|
221
|
+
}
|
|
222
|
+
/** True when an entry already occupies this exact relationship id. */
|
|
223
|
+
hasId(id) {
|
|
224
|
+
return this.entries.some((e) => e.id === id);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The id of the entry matching kind+target (same last-path-segment equality
|
|
228
|
+
* as {@link hasRelationship}), or undefined when absent. Round-trip legs use
|
|
229
|
+
* this to point a reference element at an already-registered relationship.
|
|
230
|
+
*/
|
|
231
|
+
idOf(type, target) {
|
|
232
|
+
const kind = type.split("/").pop();
|
|
233
|
+
return this.entries.find((e) => e.type.split("/").pop() === kind && e.target === target)?.id;
|
|
234
|
+
}
|
|
235
|
+
/** Directly builds XML string — zero intermediate tree allocation. */
|
|
236
|
+
serialize() {
|
|
237
|
+
const p = ["<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">"];
|
|
238
|
+
for (const e of this.entries) {
|
|
239
|
+
const tm = e.targetMode ? ` TargetMode="${escapeXml(e.targetMode)}"` : "";
|
|
240
|
+
p.push(`<Relationship Id="${escapeXml(e.id)}" Type="${escapeXml(e.type)}" Target="${escapeXml(e.target)}"${tm}/>`);
|
|
241
|
+
}
|
|
242
|
+
p.push("</Relationships>");
|
|
243
|
+
return p.join("");
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
/**
|
|
247
|
+
* Serialize a Relationships part only when it carries at least one
|
|
248
|
+
* relationship. Optional parts (fontTable, headers, footers, charts, drawings,
|
|
249
|
+
* worksheets, …) emit no .rels part when empty — Office strips empty rels
|
|
250
|
+
* shells when re-saving, so skipping them keeps generated packages free of
|
|
251
|
+
* redundant empty parts and matches Office's normalized output.
|
|
252
|
+
*
|
|
253
|
+
* Always-on parts (the package `_rels/.rels` and the main
|
|
254
|
+
* document/presentation/workbook parts) carry relationships by construction
|
|
255
|
+
* and must NOT use this gate.
|
|
256
|
+
*/
|
|
257
|
+
function optionalRelsPart(rel, xmlDeclaration, path) {
|
|
258
|
+
return rel.relationshipCount > 0 ? {
|
|
259
|
+
data: xmlDeclaration + rel.serialize(),
|
|
260
|
+
path
|
|
261
|
+
} : void 0;
|
|
262
|
+
}
|
|
263
|
+
/** Build the package root relationships shared by docx, pptx, and xlsx. */
|
|
264
|
+
function buildRootRelationships(mainPartTarget, includeCustomProperties, passthroughRelationships) {
|
|
265
|
+
const rels = new Relationships();
|
|
266
|
+
rels.addRelationship(1, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", mainPartTarget);
|
|
267
|
+
rels.addRelationship(2, "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", "docProps/core.xml");
|
|
268
|
+
rels.addRelationship(3, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", "docProps/app.xml");
|
|
269
|
+
if (includeCustomProperties) rels.addRelationship(4, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties", "docProps/custom.xml");
|
|
270
|
+
for (const rel of passthroughRelationships ?? []) {
|
|
271
|
+
if (rel.source !== "") continue;
|
|
272
|
+
if (rels.hasRelationship(rel.relationshipType, rel.target)) continue;
|
|
273
|
+
rels.add(rel.relationshipType, rel.target, rel.targetMode);
|
|
274
|
+
}
|
|
275
|
+
return rels;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Derive the .rels part path for a package part:
|
|
279
|
+
* "ppt/slides/slide1.xml" → "ppt/slides/_rels/slide1.xml.rels".
|
|
280
|
+
*/
|
|
281
|
+
function partPathToRelsPath(partPath) {
|
|
282
|
+
const idx = partPath.lastIndexOf("/");
|
|
283
|
+
return `${partPath.substring(0, idx)}/_rels/${partPath.substring(idx + 1)}.rels`;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Resolve a relationship target against the referencing part's directory,
|
|
287
|
+
* segment by segment: each ".." pops one directory level. A single
|
|
288
|
+
* String.replace("../", …) only strips the first occurrence and mis-resolves
|
|
289
|
+
* deeper targets like "../../media/image.png".
|
|
290
|
+
*/
|
|
291
|
+
function resolveRelationshipTarget(partPath, target) {
|
|
292
|
+
if (target.startsWith("/")) return target.slice(1);
|
|
293
|
+
const dir = partPath.substring(0, partPath.lastIndexOf("/"));
|
|
294
|
+
const dirParts = dir ? dir.split("/") : [];
|
|
295
|
+
for (const part of target.split("/")) if (part === "..") dirParts.pop();
|
|
296
|
+
else if (part !== "." && part !== "") dirParts.push(part);
|
|
297
|
+
return dirParts.join("/");
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
4
300
|
//#region src/opc/zip-native.ts
|
|
5
301
|
const CRC_TABLE = /* @__PURE__ */ new Int32Array(256);
|
|
6
302
|
for (let i = 0; i < 256; i++) {
|
|
@@ -678,6 +974,19 @@ function addBinaryFile(files, path, data, mediaLevel) {
|
|
|
678
974
|
files[path] = [data, { level: levelForMediaName(path, mediaLevel) }];
|
|
679
975
|
}
|
|
680
976
|
/**
|
|
977
|
+
* Write the media and embedding binaries a package compiler collected into
|
|
978
|
+
* the model back out as ZIP entries under `<packageDir>/media` and
|
|
979
|
+
* `<packageDir>/embeddings`. An svg media entry also writes its fallback
|
|
980
|
+
* raster twin (the mc:AlternateContent image browsers render).
|
|
981
|
+
*/
|
|
982
|
+
function addModelBinaries(files, packageDir, media, embeddings, mediaLevel) {
|
|
983
|
+
for (const m of media) {
|
|
984
|
+
addBinaryFile(files, `${packageDir}/media/${m.fileName}`, m.data, mediaLevel);
|
|
985
|
+
if (m.type === "svg" && m.fallback) addBinaryFile(files, `${packageDir}/media/${m.fallback.fileName}`, m.fallback.data, mediaLevel);
|
|
986
|
+
}
|
|
987
|
+
for (const e of embeddings) addBinaryFile(files, `${packageDir}/embeddings/${e.fileName}`, e.data, mediaLevel);
|
|
988
|
+
}
|
|
989
|
+
/**
|
|
681
990
|
* Convert XML files, overrides, and media into a Zippable structure.
|
|
682
991
|
*
|
|
683
992
|
* Mapping values may be optional arrays so package compilers can pass their
|
|
@@ -923,11 +1232,11 @@ function addSmartArtRelationships(keys, addRel, baseOffset, globalStartIndex, op
|
|
|
923
1232
|
const csOffset = qsOffset + count;
|
|
924
1233
|
for (let i = 0; i < keys.length; i++) {
|
|
925
1234
|
const gi = globalStartIndex + i;
|
|
926
|
-
addRel(baseOffset + i,
|
|
927
|
-
addRel(loOffset + i,
|
|
1235
|
+
addRel(baseOffset + i, RELATIONSHIP_TYPES.diagramData, `${pathPrefix}diagrams/data${gi + 1}.xml`);
|
|
1236
|
+
addRel(loOffset + i, RELATIONSHIP_TYPES.diagramLayout, `${pathPrefix}diagrams/layout${gi + 1}.xml`);
|
|
928
1237
|
addRel(qsOffset + i, styleRelType, `${pathPrefix}diagrams/quickStyle${gi + 1}.xml`);
|
|
929
|
-
addRel(csOffset + i,
|
|
930
|
-
if (hasDrawing === void 0 || hasDrawing(keys[i])) addRel(csOffset + count + i,
|
|
1238
|
+
addRel(csOffset + i, RELATIONSHIP_TYPES.diagramColors, `${pathPrefix}diagrams/colors${gi + 1}.xml`);
|
|
1239
|
+
if (hasDrawing === void 0 || hasDrawing(keys[i])) addRel(csOffset + count + i, RELATIONSHIP_TYPES.diagramDrawingMs, `${pathPrefix}diagrams/drawing${gi + 1}.xml`);
|
|
931
1240
|
}
|
|
932
1241
|
}
|
|
933
1242
|
/** Replace `{reference-instance}` placeholders with numId values. */
|
|
@@ -1008,6 +1317,6 @@ function replaceOleLinkPlaceholders(xml, links, offset) {
|
|
|
1008
1317
|
return replaceKeyedPlaceholders(xml, links, offset, "ole-link:");
|
|
1009
1318
|
}
|
|
1010
1319
|
//#endregion
|
|
1011
|
-
export {
|
|
1320
|
+
export { partPathToRelsPath as $, ZIP_DEFLATE_LEVEL as A, zipSyncAndConvert as B, replaceVideoPlaceholders as C, addBinaryFile as D, randomBytes as E, levelForMediaName as F, nativeCrc32 as G, convertOutput as H, strFromU8$1 as I, RELATIONSHIP_TYPES as J, readCentralDirectory as K, unzipSync$1 as L, ZipStreamWriter as M, createPacker as N, addModelBinaries as O, createZipStream as P, optionalRelsPart as Q, zipAndConvert as R, replaceSmartArtPlaceholders as S, hashPasswordAgile as T, inflateRawWindow as U, OoxmlMimeType as V, inflateZipEntry as W, TargetModeType as X, Relationships as Y, buildRootRelationships as Z, replaceMediaPlaceholders as _, getAudioRefs as a, replaceOlePlaceholders as b, getReferencedMedia as c, replaceAllPlaceholders as d, resolveRelationshipTarget as et, replaceAudioPlaceholders as f, replaceImagePlaceholders as g, replaceImageLinkPlaceholders as h, formatId as i, ZIP_STORED_LEVEL as j, compileMapping as k, getVideoRefs as l, replaceHyperlinkPlaceholders as m, collectPlaceholderKeys as n, getMediaRefs as o, replaceChartPlaceholders as p, readCentralDirectoryAsync as q, findAndReplaceImagePlaceholders as r, getOleRefs as s, addSmartArtRelationships as t, hasPlaceholders as u, replaceNumberingPlaceholders as v, derivePasswordHash as w, replacePlaceholders as x, replaceOleLinkPlaceholders as y, zipSync$1 as z };
|
|
1012
1321
|
|
|
1013
|
-
//# sourceMappingURL=util-
|
|
1322
|
+
//# sourceMappingURL=util-CeVahkDr.mjs.map
|