@office-open/core 0.3.6 → 0.4.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/_chunks/index-B3rs5exK.d.mts +87 -0
- package/dist/_chunks/{index-eOE0yRGG.d.mts → index-hmJg8TDw.d.mts} +1 -1
- package/dist/_chunks/smartart-D_qXltR5.mjs +336 -0
- package/dist/chart/index.d.mts +42 -12
- package/dist/chart/index.mjs +263 -12
- package/dist/drawingml/index.d.mts +105 -76
- package/dist/drawingml/index.mjs +225 -123
- package/dist/index.d.mts +75 -17
- package/dist/index.mjs +167 -7
- package/dist/smartart/index.d.mts +2 -69
- package/dist/smartart/index.mjs +2 -304
- package/dist/values.d.mts +1 -1
- package/package.json +3 -3
- /package/dist/_chunks/{values--NnXAmqa.d.mts → values-COMdgNmb.d.mts} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Relationship, elementToXml, findRel, findRelsByType, getImageType, listFiles, parseRels, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap, zipToBuffer } from "./archive.mjs";
|
|
2
|
-
import { A as IContext, C as AttributePayload, D as IgnoreIfEmptyXmlComponent, E as EMPTY_OBJECT, M as IXmlableObject, O as XmlComponent, S as AttributeMap, T as XmlAttributeComponent, _ as stringContainerObj, a as BuilderElement, b as wrapEl, c as NumberValueElement, d as StringEnumValueElement, f as StringValueElement, g as onOffObj, h as numberValObj, i as convertToXmlComponent, j as IXmlAttribute, k as BaseXmlComponent, l as OnOffElement, m as hpsMeasureObj, n as ImportedRootElementAttributes, o as EmptyElement, p as chartAttr, r as ImportedXmlComponent, s as HpsMeasureElement, t as InitializableXmlComponent, u as StringContainer, v as stringEnumValObj, w as NextAttributeComponent, x as AttributeData, y as stringValObj } from "./_chunks/index-
|
|
3
|
-
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./_chunks/values
|
|
4
|
-
import {
|
|
2
|
+
import { A as IContext, C as AttributePayload, D as IgnoreIfEmptyXmlComponent, E as EMPTY_OBJECT, M as IXmlableObject, O as XmlComponent, S as AttributeMap, T as XmlAttributeComponent, _ as stringContainerObj, a as BuilderElement, b as wrapEl, c as NumberValueElement, d as StringEnumValueElement, f as StringValueElement, g as onOffObj, h as numberValObj, i as convertToXmlComponent, j as IXmlAttribute, k as BaseXmlComponent, l as OnOffElement, m as hpsMeasureObj, n as ImportedRootElementAttributes, o as EmptyElement, p as chartAttr, r as ImportedXmlComponent, s as HpsMeasureElement, t as InitializableXmlComponent, u as StringContainer, v as stringEnumValObj, w as NextAttributeComponent, x as AttributeData, y as stringValObj } from "./_chunks/index-hmJg8TDw.mjs";
|
|
3
|
+
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./_chunks/values-COMdgNmb.mjs";
|
|
4
|
+
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtCollection, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as ISmartArtData, s as DataModel, t as ITreeNode, u as getColorXml } from "./_chunks/index-B3rs5exK.mjs";
|
|
5
5
|
import { Element } from "@office-open/xml";
|
|
6
6
|
|
|
7
7
|
//#region src/converters.d.ts
|
|
@@ -127,6 +127,35 @@ declare class Relationships extends BaseXmlComponent {
|
|
|
127
127
|
prepForXml(_context: IContext): IXmlableObject;
|
|
128
128
|
}
|
|
129
129
|
//#endregion
|
|
130
|
+
//#region src/opc/content-types.d.ts
|
|
131
|
+
interface DefaultAttributes {
|
|
132
|
+
readonly contentType: string;
|
|
133
|
+
readonly extension?: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Creates a Default element mapping a file extension to a MIME content type.
|
|
137
|
+
*/
|
|
138
|
+
declare const createDefault: (contentType: string, extension?: string) => XmlComponent;
|
|
139
|
+
interface OverrideAttributes {
|
|
140
|
+
readonly contentType: string;
|
|
141
|
+
readonly partName?: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Creates an Override element mapping a specific part path to a MIME content type.
|
|
145
|
+
*/
|
|
146
|
+
declare const createOverride: (contentType: string, partName?: string) => XmlComponent;
|
|
147
|
+
/**
|
|
148
|
+
* Attributes for the Types (Content Types) root element.
|
|
149
|
+
* Declares the XML namespace for the content types part.
|
|
150
|
+
*/
|
|
151
|
+
declare class ContentTypeAttributes extends XmlAttributeComponent<{
|
|
152
|
+
readonly xmlns?: string;
|
|
153
|
+
}> {
|
|
154
|
+
protected readonly xmlKeys: {
|
|
155
|
+
xmlns: string;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
130
159
|
//#region src/formatter.d.ts
|
|
131
160
|
/**
|
|
132
161
|
* Converts an XmlComponent tree into a serializable XML object.
|
|
@@ -149,24 +178,53 @@ interface CoreProperties {
|
|
|
149
178
|
modified?: string;
|
|
150
179
|
}
|
|
151
180
|
declare function parseCoreProperties(zip: Map<string, Uint8Array>): CoreProperties;
|
|
181
|
+
/**
|
|
182
|
+
* Build a cp:coreProperties XML object from metadata.
|
|
183
|
+
*
|
|
184
|
+
* Shared by docx and pptx to avoid duplicating namespace declarations
|
|
185
|
+
* and Dublin Core property construction.
|
|
186
|
+
*/
|
|
187
|
+
declare function buildCorePropertiesXml(opts: {
|
|
188
|
+
readonly title?: string;
|
|
189
|
+
readonly subject?: string;
|
|
190
|
+
readonly creator?: string;
|
|
191
|
+
readonly keywords?: string;
|
|
192
|
+
readonly description?: string;
|
|
193
|
+
readonly lastModifiedBy?: string;
|
|
194
|
+
readonly revision?: number;
|
|
195
|
+
}): IXmlableObject;
|
|
152
196
|
//#endregion
|
|
153
197
|
//#region src/parser.d.ts
|
|
154
198
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
199
|
+
* Parsed OOXML document backed by an unzipped ZIP map.
|
|
200
|
+
*
|
|
201
|
+
* Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)
|
|
202
|
+
* for reading and modifying individual parts, then serializing back to a ZIP buffer.
|
|
158
203
|
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
204
|
+
declare class ParsedDocument {
|
|
205
|
+
private readonly zip;
|
|
206
|
+
private readonly modified;
|
|
207
|
+
private readonly wrapperCache;
|
|
208
|
+
constructor(zip: Map<string, Uint8Array>);
|
|
209
|
+
/** Read an XML part as an Element tree. */
|
|
210
|
+
get(path: string): Element | undefined;
|
|
211
|
+
/** Write an XML part (Element → XML string). */
|
|
212
|
+
set(path: string, element: Element): void;
|
|
213
|
+
/** Read raw binary data (images, media, etc.). */
|
|
214
|
+
getRaw(path: string): Uint8Array | undefined;
|
|
215
|
+
/** Write raw binary data. */
|
|
216
|
+
setRaw(path: string, data: Uint8Array): void;
|
|
217
|
+
/** Remove a part. Returns true if it existed. */
|
|
218
|
+
remove(path: string): boolean;
|
|
219
|
+
/** Check if a part exists. */
|
|
220
|
+
has(path: string): boolean;
|
|
221
|
+
/** List all paths matching an optional prefix. */
|
|
222
|
+
keys(prefix?: string): string[];
|
|
223
|
+
/** Serialize back to a ZIP buffer, merging original zip + modifications. */
|
|
224
|
+
save(): Uint8Array;
|
|
162
225
|
}
|
|
163
|
-
/**
|
|
164
|
-
declare function
|
|
165
|
-
/**
|
|
166
|
-
* Mixed content array: typed children interleaved with unknown raw elements,
|
|
167
|
-
* preserving original document order for lossless round-trip.
|
|
168
|
-
*/
|
|
169
|
-
type MixedChildren<T> = Array<T | RawElement>;
|
|
226
|
+
/** Parse an OOXML file (.docx, .pptx) into a ParsedDocument. */
|
|
227
|
+
declare function parseDocument(data: Uint8Array): ParsedDocument;
|
|
170
228
|
//#endregion
|
|
171
229
|
//#region src/raw-passthrough.d.ts
|
|
172
230
|
/**
|
|
@@ -213,4 +271,4 @@ interface SmartArtRelOptions {
|
|
|
213
271
|
declare function replaceSmartArtPlaceholders(xml: string, keys: readonly string[], dataOffset: number, idFormat?: IdFormat): string;
|
|
214
272
|
declare function addSmartArtRelationships(keys: readonly string[], addRel: (id: number, type: RelationshipType, target: string, targetMode?: string) => void, baseOffset: number, globalStartIndex: number, options: SmartArtRelOptions): void;
|
|
215
273
|
//#endregion
|
|
216
|
-
export { AppProperties, AttributeData, AttributeMap, AttributePayload, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, Connection, CoreProperties, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IContext, ISmartArtData, ITreeNode, IXmlAttribute, IXmlableObject, IXmlifyedFile, IdFormat, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES,
|
|
274
|
+
export { AppProperties, AttributeData, AttributeMap, AttributePayload, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, Connection, ContentTypeAttributes, CoreProperties, DEFAULT_DRAWING_XML, DataModel, type DefaultAttributes, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IContext, ISmartArtData, ITreeNode, IXmlAttribute, IXmlableObject, IXmlifyedFile, IdFormat, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, NextAttributeComponent, NumberValueElement, OnOffElement, OoxmlMimeType, OutputByType, OutputType, type OverrideAttributes, ParsedDocument, Percentage, Point, PositivePercentage, PositiveUniversalMeasure, PrettifyType, RawPassthrough, Relationship, type RelationshipType, Relationships, RelativeMeasure, STYLE_CATEGORIES, SmartArtCollection, SmartArtRelOptions, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, ThemeColor, ThemeFont, TransPoint, UniqueNumericIdCreator, UniversalMeasure, XmlAttributeComponent, XmlComponent, addSmartArtRelationships, buildCorePropertiesXml, chartAttr, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertPrettifyType, convertToXmlComponent, createDataModel, createDefault, createOverride, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, elementToXml, escapeRegex, findRel, findRelsByType, formatId, getColorXml, getImageType, getLayoutXml, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, listFiles, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseCoreProperties, parseDocument, parseRels, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, stringContainerObj, stringEnumValObj, stringValObj, twipsMeasureValue, uCharHexNumber, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipToMap, wrapEl, zipToBuffer };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { C as EMPTY_OBJECT, E as BaseXmlComponent, S as XmlAttributeComponent, T as XmlComponent, _ as stringContainerObj, a as BuilderElement, b as wrapEl, c as NumberValueElement, d as StringEnumValueElement, f as StringValueElement, g as onOffObj, h as numberValObj, i as convertToXmlComponent, l as OnOffElement, m as hpsMeasureObj, n as ImportedRootElementAttributes, o as EmptyElement, p as chartAttr, r as ImportedXmlComponent, s as HpsMeasureElement, t as InitializableXmlComponent, u as StringContainer, v as stringEnumValObj, w as IgnoreIfEmptyXmlComponent, x as NextAttributeComponent, y as stringValObj } from "./_chunks/xml-components-CN6syVNr.mjs";
|
|
2
2
|
import { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber } from "./values.mjs";
|
|
3
3
|
import { a as convertEmuToInches, c as convertInchesToEmu, d as convertPixelsToEmu, f as convertPointsToEmu, i as uniqueUuid, l as convertInchesToTwip, n as uniqueId, o as convertEmuToPixels, r as uniqueNumericIdCreator, s as convertEmuToPoints, t as hashedId, u as convertMillimetersToTwip } from "./_chunks/id-generators-Ch07cHW1.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { a as DataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as TransPoint, l as getLayoutXml, n as SmartArtCollection, o as Connection, p as STYLE_CATEGORIES, r as Point, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "./_chunks/smartart-D_qXltR5.mjs";
|
|
5
5
|
import { elementToXml, findRel, findRelsByType, getImageType, listFiles, parseRels, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap, zipToBuffer } from "./archive.mjs";
|
|
6
|
-
import { textOf } from "@office-open/xml";
|
|
7
|
-
import { strFromU8 } from "fflate";
|
|
6
|
+
import { js2xml, textOf, xml2js } from "@office-open/xml";
|
|
7
|
+
import { strFromU8, strToU8 } from "fflate";
|
|
8
8
|
//#region src/output-type.ts
|
|
9
9
|
/**
|
|
10
10
|
* Output type definitions for OOXML document export.
|
|
@@ -86,6 +86,57 @@ var Relationships = class extends BaseXmlComponent {
|
|
|
86
86
|
}
|
|
87
87
|
};
|
|
88
88
|
//#endregion
|
|
89
|
+
//#region src/opc/content-types.ts
|
|
90
|
+
/**
|
|
91
|
+
* Content Types components for OPC (Open Packaging Convention).
|
|
92
|
+
*
|
|
93
|
+
* Provides Default and Override elements used in [Content_Types].xml
|
|
94
|
+
* to map file extensions and part paths to MIME content types.
|
|
95
|
+
*
|
|
96
|
+
* Reference: ECMA-376 Part 2, Section 10.1
|
|
97
|
+
*
|
|
98
|
+
* @module
|
|
99
|
+
*/
|
|
100
|
+
/**
|
|
101
|
+
* Creates a Default element mapping a file extension to a MIME content type.
|
|
102
|
+
*/
|
|
103
|
+
const createDefault = (contentType, extension) => new BuilderElement({
|
|
104
|
+
attributes: {
|
|
105
|
+
contentType: {
|
|
106
|
+
key: "ContentType",
|
|
107
|
+
value: contentType
|
|
108
|
+
},
|
|
109
|
+
extension: {
|
|
110
|
+
key: "Extension",
|
|
111
|
+
value: extension
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
name: "Default"
|
|
115
|
+
});
|
|
116
|
+
/**
|
|
117
|
+
* Creates an Override element mapping a specific part path to a MIME content type.
|
|
118
|
+
*/
|
|
119
|
+
const createOverride = (contentType, partName) => new BuilderElement({
|
|
120
|
+
attributes: {
|
|
121
|
+
contentType: {
|
|
122
|
+
key: "ContentType",
|
|
123
|
+
value: contentType
|
|
124
|
+
},
|
|
125
|
+
partName: {
|
|
126
|
+
key: "PartName",
|
|
127
|
+
value: partName
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
name: "Override"
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Attributes for the Types (Content Types) root element.
|
|
134
|
+
* Declares the XML namespace for the content types part.
|
|
135
|
+
*/
|
|
136
|
+
var ContentTypeAttributes = class extends XmlAttributeComponent {
|
|
137
|
+
xmlKeys = { xmlns: "xmlns" };
|
|
138
|
+
};
|
|
139
|
+
//#endregion
|
|
89
140
|
//#region src/formatter.ts
|
|
90
141
|
const XML_DECL = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
|
|
91
142
|
/**
|
|
@@ -149,11 +200,120 @@ function parseCoreProperties(zip) {
|
|
|
149
200
|
}
|
|
150
201
|
return props;
|
|
151
202
|
}
|
|
203
|
+
const CORE_PROPS_NS = Object.freeze({ _attr: Object.freeze({
|
|
204
|
+
"xmlns:cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
205
|
+
"xmlns:dc": "http://purl.org/dc/elements/1.1/",
|
|
206
|
+
"xmlns:dcmitype": "http://purl.org/dc/dcmitype/",
|
|
207
|
+
"xmlns:dcterms": "http://purl.org/dc/terms/",
|
|
208
|
+
"xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
|
|
209
|
+
}) });
|
|
210
|
+
const W3CDTF_ATTR = Object.freeze({ _attr: Object.freeze({ "xsi:type": "dcterms:W3CDTF" }) });
|
|
211
|
+
/**
|
|
212
|
+
* Build a cp:coreProperties XML object from metadata.
|
|
213
|
+
*
|
|
214
|
+
* Shared by docx and pptx to avoid duplicating namespace declarations
|
|
215
|
+
* and Dublin Core property construction.
|
|
216
|
+
*/
|
|
217
|
+
function buildCorePropertiesXml(opts) {
|
|
218
|
+
const children = [CORE_PROPS_NS];
|
|
219
|
+
if (opts.title) children.push({ "dc:title": [opts.title] });
|
|
220
|
+
if (opts.subject) children.push({ "dc:subject": [opts.subject] });
|
|
221
|
+
if (opts.creator) children.push({ "dc:creator": [opts.creator] });
|
|
222
|
+
if (opts.keywords) children.push({ "cp:keywords": [opts.keywords] });
|
|
223
|
+
if (opts.description) children.push({ "dc:description": [opts.description] });
|
|
224
|
+
if (opts.lastModifiedBy) children.push({ "cp:lastModifiedBy": [opts.lastModifiedBy] });
|
|
225
|
+
if (opts.revision) children.push({ "cp:revision": [String(opts.revision)] });
|
|
226
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
227
|
+
children.push({ "dcterms:created": [W3CDTF_ATTR, now] });
|
|
228
|
+
children.push({ "dcterms:modified": [W3CDTF_ATTR, now] });
|
|
229
|
+
return { "cp:coreProperties": children };
|
|
230
|
+
}
|
|
152
231
|
//#endregion
|
|
153
232
|
//#region src/parser.ts
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
233
|
+
const XML_PARSE_OPTIONS = {
|
|
234
|
+
nativeTypeAttributes: true,
|
|
235
|
+
captureSpacesBetweenElements: true
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Parsed OOXML document backed by an unzipped ZIP map.
|
|
239
|
+
*
|
|
240
|
+
* Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)
|
|
241
|
+
* for reading and modifying individual parts, then serializing back to a ZIP buffer.
|
|
242
|
+
*/
|
|
243
|
+
var ParsedDocument = class {
|
|
244
|
+
zip;
|
|
245
|
+
modified = /* @__PURE__ */ new Map();
|
|
246
|
+
wrapperCache = /* @__PURE__ */ new Map();
|
|
247
|
+
constructor(zip) {
|
|
248
|
+
this.zip = zip;
|
|
249
|
+
}
|
|
250
|
+
/** Read an XML part as an Element tree. */
|
|
251
|
+
get(path) {
|
|
252
|
+
const modData = this.modified.get(path);
|
|
253
|
+
if (modData) {
|
|
254
|
+
const wrapper = xml2js(strFromU8(modData), XML_PARSE_OPTIONS);
|
|
255
|
+
this.wrapperCache.set(path, wrapper);
|
|
256
|
+
return wrapper.elements?.find((e) => e.type === "element");
|
|
257
|
+
}
|
|
258
|
+
const data = this.zip.get(path);
|
|
259
|
+
if (data === void 0) return void 0;
|
|
260
|
+
const cached = this.wrapperCache.get(path);
|
|
261
|
+
if (cached) return cached.elements?.find((e) => e.type === "element");
|
|
262
|
+
const wrapper = xml2js(strFromU8(data), XML_PARSE_OPTIONS);
|
|
263
|
+
this.wrapperCache.set(path, wrapper);
|
|
264
|
+
return wrapper.elements?.find((e) => e.type === "element");
|
|
265
|
+
}
|
|
266
|
+
/** Write an XML part (Element → XML string). */
|
|
267
|
+
set(path, element) {
|
|
268
|
+
const wrapper = this.wrapperCache.get(path);
|
|
269
|
+
const xml = js2xml(wrapper ? {
|
|
270
|
+
...wrapper,
|
|
271
|
+
elements: [{
|
|
272
|
+
...element,
|
|
273
|
+
type: "element"
|
|
274
|
+
}]
|
|
275
|
+
} : { elements: [{
|
|
276
|
+
...element,
|
|
277
|
+
type: "element"
|
|
278
|
+
}] });
|
|
279
|
+
this.modified.set(path, strToU8(xml));
|
|
280
|
+
}
|
|
281
|
+
/** Read raw binary data (images, media, etc.). */
|
|
282
|
+
getRaw(path) {
|
|
283
|
+
return this.modified.get(path) ?? this.zip.get(path);
|
|
284
|
+
}
|
|
285
|
+
/** Write raw binary data. */
|
|
286
|
+
setRaw(path, data) {
|
|
287
|
+
this.modified.set(path, data);
|
|
288
|
+
this.wrapperCache.delete(path);
|
|
289
|
+
}
|
|
290
|
+
/** Remove a part. Returns true if it existed. */
|
|
291
|
+
remove(path) {
|
|
292
|
+
this.wrapperCache.delete(path);
|
|
293
|
+
return this.modified.delete(path) || this.zip.delete(path);
|
|
294
|
+
}
|
|
295
|
+
/** Check if a part exists. */
|
|
296
|
+
has(path) {
|
|
297
|
+
return this.modified.has(path) || this.zip.has(path);
|
|
298
|
+
}
|
|
299
|
+
/** List all paths matching an optional prefix. */
|
|
300
|
+
keys(prefix) {
|
|
301
|
+
const all = /* @__PURE__ */ new Set();
|
|
302
|
+
for (const key of this.zip.keys()) if (!prefix || key.startsWith(prefix)) all.add(key);
|
|
303
|
+
for (const key of this.modified.keys()) if (!prefix || key.startsWith(prefix)) all.add(key);
|
|
304
|
+
return [...all];
|
|
305
|
+
}
|
|
306
|
+
/** Serialize back to a ZIP buffer, merging original zip + modifications. */
|
|
307
|
+
save() {
|
|
308
|
+
const files = /* @__PURE__ */ new Map();
|
|
309
|
+
for (const [path, data] of this.zip) if (!this.modified.has(path)) files.set(path, data);
|
|
310
|
+
for (const [path, data] of this.modified) files.set(path, data);
|
|
311
|
+
return zipToBuffer(files);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
/** Parse an OOXML file (.docx, .pptx) into a ParsedDocument. */
|
|
315
|
+
function parseDocument(data) {
|
|
316
|
+
return new ParsedDocument(unzipToMap(data));
|
|
157
317
|
}
|
|
158
318
|
//#endregion
|
|
159
319
|
//#region src/raw-passthrough.ts
|
|
@@ -261,4 +421,4 @@ function addSmartArtRelationships(keys, addRel, baseOffset, globalStartIndex, op
|
|
|
261
421
|
});
|
|
262
422
|
}
|
|
263
423
|
//#endregion
|
|
264
|
-
export { AppProperties, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, Connection, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, NextAttributeComponent, NumberValueElement, OnOffElement, OoxmlMimeType, Point, PrettifyType, RawPassthrough, Relationships, STYLE_CATEGORIES, SmartArtCollection, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, ThemeColor, ThemeFont, TransPoint, XmlAttributeComponent, XmlComponent, addSmartArtRelationships, chartAttr, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertPrettifyType, convertToXmlComponent, createDataModel, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, elementToXml, escapeRegex, findRel, findRelsByType, formatId, getImageType, getReferencedMedia, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue,
|
|
424
|
+
export { AppProperties, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, Connection, ContentTypeAttributes, DEFAULT_DRAWING_XML, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, HpsMeasureElement, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, NextAttributeComponent, NumberValueElement, OnOffElement, OoxmlMimeType, ParsedDocument, Point, PrettifyType, RawPassthrough, Relationships, STYLE_CATEGORIES, SmartArtCollection, StringContainer, StringEnumValueElement, StringValueElement, TargetModeType, ThemeColor, ThemeFont, TransPoint, XmlAttributeComponent, XmlComponent, addSmartArtRelationships, buildCorePropertiesXml, chartAttr, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertPrettifyType, convertToXmlComponent, createDataModel, createDefault, createOverride, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, elementToXml, escapeRegex, findRel, findRelsByType, formatId, getColorXml, getImageType, getLayoutXml, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, listFiles, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseCoreProperties, parseDocument, parseRels, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, stringContainerObj, stringEnumValObj, stringValObj, twipsMeasureValue, uCharHexNumber, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipToMap, wrapEl, zipToBuffer };
|
|
@@ -1,69 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/smartart/categories.d.ts
|
|
4
|
-
/** Layout ID → OOXML category type */
|
|
5
|
-
declare const LAYOUT_CATEGORIES: Record<string, string>;
|
|
6
|
-
/** Style ID → OOXML category type */
|
|
7
|
-
declare const STYLE_CATEGORIES: Record<string, string>;
|
|
8
|
-
/** Color ID → OOXML category type */
|
|
9
|
-
declare const COLOR_CATEGORIES: Record<string, string>;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region src/smartart/data-model/connection.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* dgm:cxn — SmartArt data model connection (edge).
|
|
14
|
-
*/
|
|
15
|
-
declare class Connection extends XmlComponent {
|
|
16
|
-
constructor(modelId: string, srcId: string, destId: string, type?: string, srcOrd?: number, destOrd?: number, parTransId?: string, sibTransId?: string);
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/smartart/data-model/data-model.d.ts
|
|
20
|
-
/**
|
|
21
|
-
* CT_DataModel — the complete data model for a SmartArt diagram.
|
|
22
|
-
*/
|
|
23
|
-
declare class DataModel extends XmlComponent {
|
|
24
|
-
constructor(points: readonly XmlComponent[], connections: readonly Connection[]);
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/smartart/data-model/point.d.ts
|
|
28
|
-
/**
|
|
29
|
-
* dgm:pt — SmartArt data model point (node).
|
|
30
|
-
*/
|
|
31
|
-
declare class Point extends XmlComponent {
|
|
32
|
-
constructor(modelId: string, text: string, type?: string);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Transition point (parTrans or sibTrans) — no text body, references a connection.
|
|
36
|
-
*/
|
|
37
|
-
declare class TransPoint extends XmlComponent {
|
|
38
|
-
constructor(modelId: string, type: string, cxnId: string);
|
|
39
|
-
}
|
|
40
|
-
//#endregion
|
|
41
|
-
//#region src/smartart/smartart-collection.d.ts
|
|
42
|
-
interface ISmartArtData {
|
|
43
|
-
readonly key: string;
|
|
44
|
-
readonly dataModel: DataModel;
|
|
45
|
-
readonly layout: string;
|
|
46
|
-
readonly style: string;
|
|
47
|
-
readonly color: string;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Manages SmartArt parts in a document.
|
|
51
|
-
*/
|
|
52
|
-
declare class SmartArtCollection {
|
|
53
|
-
private readonly map;
|
|
54
|
-
constructor();
|
|
55
|
-
addSmartArt(key: string, data: ISmartArtData): void;
|
|
56
|
-
get Array(): readonly ISmartArtData[];
|
|
57
|
-
}
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/smartart/tree-to-model.d.ts
|
|
60
|
-
interface ITreeNode {
|
|
61
|
-
readonly text: string;
|
|
62
|
-
readonly children?: readonly ITreeNode[];
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Creates a DataModel from tree nodes with layout/style/color settings.
|
|
66
|
-
*/
|
|
67
|
-
declare const createDataModel: (nodes: readonly ITreeNode[], layout?: string, style?: string, color?: string) => DataModel;
|
|
68
|
-
//#endregion
|
|
69
|
-
export { COLOR_CATEGORIES, Connection, DataModel, ISmartArtData, ITreeNode, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel };
|
|
1
|
+
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtCollection, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as ISmartArtData, s as DataModel, t as ITreeNode, u as getColorXml } from "../_chunks/index-B3rs5exK.mjs";
|
|
2
|
+
export { COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, ISmartArtData, ITreeNode, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, TransPoint, createDataModel, getColorXml, getLayoutXml, getStyleXml };
|