@office-open/core 0.9.7 → 0.10.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/dist/chart/index.d.mts +1 -1
- package/dist/descriptor/index.d.mts +2 -2
- package/dist/descriptor/index.mjs +2 -2
- package/dist/descriptor-BdWTH1vv.mjs +444 -0
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/{index-DMw7eid7.d.mts → index-BEQ12eyX.d.mts} +42 -42
- package/dist/{index-eu1aFQCm.d.mts → index-CsQP7Cl4.d.mts} +36 -36
- package/dist/index-DEeO4sOq.d.mts +239 -0
- package/dist/index-L82O3q6V.d.mts +170 -0
- package/dist/{index-CDYC3mxJ.d.mts → index-pvj6gDsT.d.mts} +832 -179
- package/dist/{index-4hjRdzMU.d.mts → index-vEeWkbm5.d.mts} +20 -20
- package/dist/index.d.mts +7 -7
- package/dist/index.mjs +4 -4
- package/dist/patch/index.d.mts +2 -2
- package/dist/patch/index.mjs +2 -2
- package/dist/{patch-ilNZTQmG.mjs → patch-DocIv0Sn.mjs} +125 -3
- package/dist/smartart/index.d.mts +1 -1
- package/dist/{src-DlZssiRY.mjs → src-CXdJt0WZ.mjs} +1214 -263
- package/dist/theme/index.d.mts +1 -1
- package/package.json +2 -2
- package/dist/descriptor-DcQm32dg.mjs +0 -71
- package/dist/index-C4r2WLEy.d.mts +0 -73
- package/dist/index-DmPBJwSk.d.mts +0 -127
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as CustomDescriptor } from "./index-L82O3q6V.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/chart/chart-collection.d.ts
|
|
4
4
|
/**
|
|
@@ -27,10 +27,10 @@ declare class ChartCollection {
|
|
|
27
27
|
* @module
|
|
28
28
|
*/
|
|
29
29
|
interface BubbleSeriesData {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
name: string;
|
|
31
|
+
xValues: readonly number[];
|
|
32
|
+
yValues: readonly number[];
|
|
33
|
+
bubbleSize: readonly number[];
|
|
34
34
|
}
|
|
35
35
|
declare const TrendlineType: {
|
|
36
36
|
readonly EXP: "exp";
|
|
@@ -42,15 +42,15 @@ declare const TrendlineType: {
|
|
|
42
42
|
};
|
|
43
43
|
type TrendlineType = (typeof TrendlineType)[keyof typeof TrendlineType];
|
|
44
44
|
interface TrendlineOptions {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
type?: TrendlineType;
|
|
46
|
+
name?: string;
|
|
47
|
+
order?: number;
|
|
48
|
+
period?: number;
|
|
49
|
+
forward?: number;
|
|
50
|
+
backward?: number;
|
|
51
|
+
intercept?: number;
|
|
52
|
+
dispRSqr?: boolean;
|
|
53
|
+
dispEq?: boolean;
|
|
54
54
|
}
|
|
55
55
|
declare const ErrorBarDirection: {
|
|
56
56
|
readonly BOTH: "both";
|
|
@@ -73,10 +73,10 @@ declare const ErrorValueType: {
|
|
|
73
73
|
};
|
|
74
74
|
type ErrorValueType = (typeof ErrorValueType)[keyof typeof ErrorValueType];
|
|
75
75
|
interface ErrorBarOptions {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
direction?: ErrorBarDirection;
|
|
77
|
+
barType?: ErrorBarType;
|
|
78
|
+
valueType?: ErrorValueType;
|
|
79
|
+
value?: number;
|
|
80
80
|
}
|
|
81
81
|
declare const DataLabelPosition: {
|
|
82
82
|
readonly BEST_FIT: "bestFit";
|
|
@@ -91,31 +91,31 @@ declare const DataLabelPosition: {
|
|
|
91
91
|
};
|
|
92
92
|
type DataLabelPosition = (typeof DataLabelPosition)[keyof typeof DataLabelPosition];
|
|
93
93
|
interface DataLabelsOptions {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
position?: DataLabelPosition;
|
|
95
|
+
showVal?: boolean;
|
|
96
|
+
showCatName?: boolean;
|
|
97
|
+
showSerName?: boolean;
|
|
98
|
+
showPercent?: boolean;
|
|
99
|
+
showBubbleSize?: boolean;
|
|
100
|
+
showLeaderLines?: boolean;
|
|
101
101
|
}
|
|
102
102
|
interface ChartSeriesData {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
103
|
+
name: string;
|
|
104
|
+
values: readonly number[];
|
|
105
|
+
trendlines?: readonly TrendlineOptions[];
|
|
106
|
+
errorBars?: ErrorBarOptions;
|
|
107
|
+
dataLabels?: DataLabelsOptions;
|
|
108
108
|
}
|
|
109
109
|
type ChartType = "column" | "bar" | "line" | "pie" | "area" | "scatter" | "bubble" | "doughnut" | "radar" | "stock" | "surface";
|
|
110
110
|
type AxisChartType = Exclude<ChartType, "bubble">;
|
|
111
111
|
interface ChartSpaceOptions {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
112
|
+
title?: string;
|
|
113
|
+
type: ChartType;
|
|
114
|
+
categories?: readonly string[];
|
|
115
|
+
series: readonly ChartSeriesData[] | readonly BubbleSeriesData[];
|
|
116
|
+
showLegend?: boolean;
|
|
117
|
+
style?: number;
|
|
118
|
+
threeD?: boolean;
|
|
119
119
|
}
|
|
120
120
|
declare const TimeUnit: {
|
|
121
121
|
readonly DAYS: "days";
|
|
@@ -124,11 +124,11 @@ declare const TimeUnit: {
|
|
|
124
124
|
};
|
|
125
125
|
type TimeUnit = (typeof TimeUnit)[keyof typeof TimeUnit];
|
|
126
126
|
interface View3DOptions {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
127
|
+
rotX?: number;
|
|
128
|
+
rotY?: number;
|
|
129
|
+
depthPercent?: number;
|
|
130
|
+
rAngAx?: boolean;
|
|
131
|
+
perspective?: number;
|
|
132
132
|
}
|
|
133
133
|
//#endregion
|
|
134
134
|
//#region src/chart/chart-descriptors.d.ts
|
|
@@ -55,40 +55,40 @@ declare function stringifyDataModel(points: readonly string[], connections: read
|
|
|
55
55
|
//#endregion
|
|
56
56
|
//#region src/smartart/data-model/point.d.ts
|
|
57
57
|
interface PointPropertySetOptions {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
58
|
+
presentationAssociationId?: string;
|
|
59
|
+
presentationName?: string;
|
|
60
|
+
presentationStyleLabel?: string;
|
|
61
|
+
presentationStyleIndex?: number;
|
|
62
|
+
presentationStyleCount?: number;
|
|
63
|
+
placeholderText?: string;
|
|
64
|
+
placeholder?: boolean;
|
|
65
|
+
customAngle?: number;
|
|
66
|
+
customFlipVertical?: boolean;
|
|
67
|
+
customFlipHorizontal?: boolean;
|
|
68
|
+
customSizeX?: number;
|
|
69
|
+
customSizeY?: number;
|
|
70
|
+
customScaleX?: number;
|
|
71
|
+
customScaleY?: number;
|
|
72
|
+
customText?: boolean;
|
|
73
|
+
customLinearFactorX?: number;
|
|
74
|
+
customLinearFactorY?: number;
|
|
75
|
+
customLinearFactorNeighborX?: number;
|
|
76
|
+
customLinearFactorNeighborY?: number;
|
|
77
|
+
customRadialScaleRadius?: number;
|
|
78
|
+
customRadialScaleIncrement?: number;
|
|
79
|
+
coherent3DOffset?: boolean;
|
|
80
|
+
hideGeometry?: boolean;
|
|
81
|
+
hideLastTransition?: boolean;
|
|
82
|
+
lockTextEntry?: boolean;
|
|
83
|
+
moveWith?: string;
|
|
84
|
+
useDefault?: boolean;
|
|
85
|
+
zOrderOffset?: number;
|
|
86
|
+
layoutTypeId?: string;
|
|
87
|
+
layoutCategoryId?: string;
|
|
88
|
+
quickStyleTypeId?: string;
|
|
89
|
+
quickStyleCategoryId?: string;
|
|
90
|
+
colorStyleTypeId?: string;
|
|
91
|
+
colorStyleCategoryId?: string;
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* dgm:pt — SmartArt data model point (node) XML stringifier.
|
|
@@ -124,8 +124,8 @@ declare class SmartArtCollection {
|
|
|
124
124
|
//#endregion
|
|
125
125
|
//#region src/smartart/tree-to-model.d.ts
|
|
126
126
|
interface TreeNode {
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
text: string;
|
|
128
|
+
children?: readonly TreeNode[];
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Creates SmartArt data model XML from tree nodes with layout/style/color settings.
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { Element } from "@office-open/xml";
|
|
2
|
+
import { Buffer } from "\u0000polyfill-node.buffer";
|
|
3
|
+
|
|
4
|
+
//#region src/util/data-type.d.ts
|
|
5
|
+
/** Supported binary input shapes. */
|
|
6
|
+
type DataType = ArrayBufferLike | Blob | DataView | number[] | ReadableStream | string | Uint8Array;
|
|
7
|
+
/** Test whether a string is a base64 data URL (`data:[mime];base64,...`). */
|
|
8
|
+
declare function isBase64DataURL(input: string): boolean;
|
|
9
|
+
/** Normalize any supported binary input to a `Uint8Array`. */
|
|
10
|
+
declare function toUint8Array(data: DataType): Uint8Array;
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/opc/core.d.ts
|
|
13
|
+
type IXmlableObject = Readonly<Record<string, unknown>>;
|
|
14
|
+
/**
|
|
15
|
+
* Core document properties (docProps/core.xml).
|
|
16
|
+
*
|
|
17
|
+
* Shared across docx/pptx/xlsx: each format's top-level Options extends this,
|
|
18
|
+
* parse emits the same shape, and patch overrides it — read/write symmetry
|
|
19
|
+
* (CONTRIBUTING §Property Naming). Field names follow the OPC core-properties
|
|
20
|
+
* XSD element local names (`creator` = dc:creator, … — never `author`).
|
|
21
|
+
*/
|
|
22
|
+
interface CorePropertiesOptions {
|
|
23
|
+
title?: string;
|
|
24
|
+
subject?: string;
|
|
25
|
+
creator?: string;
|
|
26
|
+
keywords?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
lastModifiedBy?: string;
|
|
29
|
+
revision?: number;
|
|
30
|
+
lastPrinted?: string;
|
|
31
|
+
/** Creation timestamp (W3CDTF), round-tripped from dcterms:created. */
|
|
32
|
+
created?: string;
|
|
33
|
+
/** Last modified timestamp (W3CDTF), round-tripped from dcterms:modified. */
|
|
34
|
+
modified?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Parse core properties from an already-parsed XML element.
|
|
38
|
+
* Shared by docx/pptx/xlsx to extract Dublin Core metadata into the unified
|
|
39
|
+
* {@link CorePropertiesOptions} shape.
|
|
40
|
+
*/
|
|
41
|
+
declare function parseCorePropsElement(el: Element | undefined): CorePropertiesOptions;
|
|
42
|
+
/**
|
|
43
|
+
* Build a cp:coreProperties XML object from metadata.
|
|
44
|
+
*
|
|
45
|
+
* Shared by docx and pptx to avoid duplicating namespace declarations
|
|
46
|
+
* and Dublin Core property construction.
|
|
47
|
+
*/
|
|
48
|
+
declare function buildCorePropertiesXml(opts: {
|
|
49
|
+
title?: string;
|
|
50
|
+
subject?: string;
|
|
51
|
+
creator?: string;
|
|
52
|
+
keywords?: string;
|
|
53
|
+
description?: string;
|
|
54
|
+
lastModifiedBy?: string;
|
|
55
|
+
revision?: number;
|
|
56
|
+
}): IXmlableObject;
|
|
57
|
+
/**
|
|
58
|
+
* Build a cp:coreProperties XML string directly (fast path).
|
|
59
|
+
*
|
|
60
|
+
* Shared by pptx and xlsx to bypass the toXml() → xml() pipeline.
|
|
61
|
+
* created/modified default to now when not supplied; all other fields emit
|
|
62
|
+
* only when present.
|
|
63
|
+
*/
|
|
64
|
+
declare function buildCorePropertiesXmlString(opts: CorePropertiesOptions): string;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/opc/output.d.ts
|
|
67
|
+
/**
|
|
68
|
+
* Output type definitions for OOXML document export.
|
|
69
|
+
*
|
|
70
|
+
* @module
|
|
71
|
+
*/
|
|
72
|
+
interface OutputByType {
|
|
73
|
+
base64: string;
|
|
74
|
+
string: string;
|
|
75
|
+
text: string;
|
|
76
|
+
binarystring: string;
|
|
77
|
+
array: readonly number[];
|
|
78
|
+
uint8array: Uint8Array;
|
|
79
|
+
arraybuffer: ArrayBuffer;
|
|
80
|
+
blob: Blob;
|
|
81
|
+
nodebuffer: Buffer;
|
|
82
|
+
}
|
|
83
|
+
type OutputType = keyof OutputByType;
|
|
84
|
+
declare const OoxmlMimeType: {
|
|
85
|
+
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
86
|
+
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
87
|
+
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
88
|
+
};
|
|
89
|
+
declare const convertOutput: <T extends OutputType>(data: Uint8Array, type: T, mimeType?: string) => OutputByType[T];
|
|
90
|
+
//#endregion
|
|
91
|
+
//#region src/patch/xml-namespace.d.ts
|
|
92
|
+
/**
|
|
93
|
+
* Namespace configuration for XML patch operations.
|
|
94
|
+
*
|
|
95
|
+
* Parameterises element names so the same patch algorithm works for both
|
|
96
|
+
* DOCX (`w:*`) and PPTX (`a:*`) documents.
|
|
97
|
+
*/
|
|
98
|
+
interface XmlNamespaceConfig {
|
|
99
|
+
paragraph: string;
|
|
100
|
+
run: string;
|
|
101
|
+
text: string;
|
|
102
|
+
runProperties: string;
|
|
103
|
+
}
|
|
104
|
+
declare const DOCX_NS: XmlNamespaceConfig;
|
|
105
|
+
declare const PPTX_NS: XmlNamespaceConfig;
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/patch/xml-replacer.d.ts
|
|
108
|
+
interface ReplacerConfig {
|
|
109
|
+
ns: XmlNamespaceConfig;
|
|
110
|
+
formatChild: (child: unknown, context: unknown) => Element[];
|
|
111
|
+
preserveSpace?: boolean;
|
|
112
|
+
}
|
|
113
|
+
interface ReplacerResult {
|
|
114
|
+
element: Element;
|
|
115
|
+
didFindOccurrence: boolean;
|
|
116
|
+
}
|
|
117
|
+
declare function createReplacer(config: ReplacerConfig): ({
|
|
118
|
+
json,
|
|
119
|
+
patch,
|
|
120
|
+
patchText,
|
|
121
|
+
context,
|
|
122
|
+
keepOriginalStyles
|
|
123
|
+
}: {
|
|
124
|
+
json: Element;
|
|
125
|
+
patch: {
|
|
126
|
+
type: string;
|
|
127
|
+
children: readonly unknown[];
|
|
128
|
+
};
|
|
129
|
+
patchText: string;
|
|
130
|
+
context: unknown;
|
|
131
|
+
keepOriginalStyles?: boolean;
|
|
132
|
+
}) => ReplacerResult;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/patch/run-renderer.d.ts
|
|
135
|
+
interface ElementWrapper {
|
|
136
|
+
element: Element;
|
|
137
|
+
index: number;
|
|
138
|
+
parent: ElementWrapper | undefined;
|
|
139
|
+
}
|
|
140
|
+
interface RenderedParagraphNode {
|
|
141
|
+
text: string;
|
|
142
|
+
runs: readonly RenderedRunNode[];
|
|
143
|
+
index: number;
|
|
144
|
+
pathToParagraph: readonly number[];
|
|
145
|
+
}
|
|
146
|
+
interface StartAndEnd {
|
|
147
|
+
start: number;
|
|
148
|
+
end: number;
|
|
149
|
+
}
|
|
150
|
+
type IParts = {
|
|
151
|
+
text: string;
|
|
152
|
+
index: number;
|
|
153
|
+
} & StartAndEnd;
|
|
154
|
+
type RenderedRunNode = {
|
|
155
|
+
text: string;
|
|
156
|
+
parts: readonly IParts[];
|
|
157
|
+
index: number;
|
|
158
|
+
} & StartAndEnd;
|
|
159
|
+
declare function createRunRenderer(ns: XmlNamespaceConfig): (node: ElementWrapper) => RenderedParagraphNode;
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/patch/xml-traverser.d.ts
|
|
162
|
+
declare function createTraverser(ns: XmlNamespaceConfig): {
|
|
163
|
+
traverse: (node: Element) => readonly RenderedParagraphNode[];
|
|
164
|
+
findLocationOfText: (node: Element, text: string) => readonly RenderedParagraphNode[];
|
|
165
|
+
};
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/patch/paragraph-token-replacer.d.ts
|
|
168
|
+
declare function createTokenReplacer(createTextElementContents: (text: string) => Element[], options?: {
|
|
169
|
+
readonly preserveSpace?: boolean;
|
|
170
|
+
}): ({
|
|
171
|
+
paragraphElement,
|
|
172
|
+
renderedParagraph,
|
|
173
|
+
originalText,
|
|
174
|
+
replacementText
|
|
175
|
+
}: {
|
|
176
|
+
paragraphElement: Element;
|
|
177
|
+
renderedParagraph: RenderedParagraphNode;
|
|
178
|
+
originalText: string;
|
|
179
|
+
replacementText: string;
|
|
180
|
+
}) => Element;
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region src/patch/paragraph-split-inject.d.ts
|
|
183
|
+
declare class TokenNotFoundError extends Error {
|
|
184
|
+
constructor(token: string);
|
|
185
|
+
}
|
|
186
|
+
declare function createSplitInject(ns: XmlNamespaceConfig, createTextElementContents: (text: string) => Element[], options?: {
|
|
187
|
+
readonly preserveSpace?: boolean;
|
|
188
|
+
}): {
|
|
189
|
+
findRunElementIndexWithToken: (paragraphElement: Element, token: string) => number;
|
|
190
|
+
splitRunElement: (runElement: Element, token: string) => {
|
|
191
|
+
readonly left: Element;
|
|
192
|
+
readonly right: Element;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/patch/xml-patch-utils.d.ts
|
|
197
|
+
declare const toJson: (xmlData: string) => Element;
|
|
198
|
+
/**
|
|
199
|
+
* Creates the inner content of a text element (`w:t` / `a:t`).
|
|
200
|
+
*
|
|
201
|
+
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
|
|
202
|
+
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
|
|
203
|
+
*/
|
|
204
|
+
declare const createTextElementContents: (text: string) => Element[];
|
|
205
|
+
declare const patchSpaceAttribute: (element: Element) => Element;
|
|
206
|
+
declare const getFirstLevelElements: (relationships: Element, id: string) => Element[];
|
|
207
|
+
//#endregion
|
|
208
|
+
//#region src/patch/content-types-manager.d.ts
|
|
209
|
+
declare const appendContentType: (element: Element, contentType: string, extension: string) => void;
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/patch/relationship-manager.d.ts
|
|
212
|
+
declare const getNextRelationshipIndex: (relationships: Element) => number;
|
|
213
|
+
declare const appendRelationship: (relationships: Element, id: number | string, type: string, target: string, targetMode?: string) => readonly Element[];
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/patch/core-properties-override.d.ts
|
|
216
|
+
declare function applyCorePropertiesOverride(corePropsDoc: Element, overrides: Partial<CorePropertiesOptions>): string;
|
|
217
|
+
//#endregion
|
|
218
|
+
//#region src/patch/types.d.ts
|
|
219
|
+
/** Placeholder delimiter pair surrounding a patch key (e.g. `{{` / `}}`). */
|
|
220
|
+
interface PlaceholderDelimiters {
|
|
221
|
+
start: string;
|
|
222
|
+
end: string;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Shared base options for patch operations.
|
|
226
|
+
*
|
|
227
|
+
* Format-specific patch functions extend this with their `patches` field
|
|
228
|
+
* (and any format-specific options like `keepOriginalStyles`).
|
|
229
|
+
*/
|
|
230
|
+
interface BasePatchOptions<T extends OutputType = OutputType> {
|
|
231
|
+
/** Source document bytes (Buffer / Uint8Array / ArrayBuffer / base64 data URL / …). */
|
|
232
|
+
data: DataType;
|
|
233
|
+
/** Output container type — controls the return type via OutputByType. */
|
|
234
|
+
outputType: T;
|
|
235
|
+
/** Custom placeholder delimiters (default `{{` / `}}`). */
|
|
236
|
+
placeholderDelimiters?: PlaceholderDelimiters;
|
|
237
|
+
}
|
|
238
|
+
//#endregion
|
|
239
|
+
export { DataType as A, OutputByType as C, buildCorePropertiesXml as D, CorePropertiesOptions as E, toUint8Array as M, buildCorePropertiesXmlString as O, OoxmlMimeType as S, convertOutput as T, ReplacerConfig as _, getNextRelationshipIndex as a, PPTX_NS as b, getFirstLevelElements as c, TokenNotFoundError as d, createSplitInject as f, createRunRenderer as g, RenderedParagraphNode as h, appendRelationship as i, isBase64DataURL as j, parseCorePropsElement as k, patchSpaceAttribute as l, createTraverser as m, PlaceholderDelimiters as n, appendContentType as o, createTokenReplacer as p, applyCorePropertiesOverride as r, createTextElementContents as s, BasePatchOptions as t, toJson as u, createReplacer as v, OutputType as w, XmlNamespaceConfig as x, DOCX_NS as y };
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Element } from "@office-open/xml";
|
|
2
|
+
|
|
3
|
+
//#region src/descriptor/context.d.ts
|
|
4
|
+
/** Context passed during stringify (write path). */
|
|
5
|
+
interface WriteContext {
|
|
6
|
+
/** Register a relationship and return its rId. */
|
|
7
|
+
addRelationship(type: string, target: string, mode?: string): string;
|
|
8
|
+
/** Add a media file and return its reference. */
|
|
9
|
+
addMedia(data: Uint8Array, type: string): string;
|
|
10
|
+
}
|
|
11
|
+
/** Context passed during parse (parse path). */
|
|
12
|
+
interface ReadContext {
|
|
13
|
+
/** Resolve a relationship rId to its target path. */
|
|
14
|
+
resolveRelationship(rId: string): string | undefined;
|
|
15
|
+
/** Get a parsed XML part by path. */
|
|
16
|
+
getPart(path: string): Element | undefined;
|
|
17
|
+
/** Get raw binary data (images, media, etc.) by path. */
|
|
18
|
+
getRaw(path: string): Uint8Array | undefined;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/descriptor/types.d.ts
|
|
22
|
+
/** Custom descriptor — hand-written stringify/parse for an OOXML part. */
|
|
23
|
+
interface CustomDescriptor<T, Ctx = WriteContext> {
|
|
24
|
+
kind: "custom";
|
|
25
|
+
stringify(value: T, ctx: Ctx): string | undefined;
|
|
26
|
+
parse(el: Element, ctx: ReadContext): T;
|
|
27
|
+
}
|
|
28
|
+
/** Alias for "any descriptor" — retained for call-site readability. */
|
|
29
|
+
type Descriptor<T> = CustomDescriptor<T>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/descriptor/runtime.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* Serialize an Options object to an XML string using its descriptor.
|
|
34
|
+
* Returns `undefined` when an optional element should be omitted.
|
|
35
|
+
*/
|
|
36
|
+
declare function stringify$1<T>(desc: CustomDescriptor<T>, value: T, ctx: WriteContext): string | undefined;
|
|
37
|
+
/** Parse an XML Element into an Options object using its descriptor. */
|
|
38
|
+
declare function parse$1<T>(desc: CustomDescriptor<T>, el: Element, ctx: ReadContext): T;
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/descriptor/helpers.d.ts
|
|
41
|
+
/**
|
|
42
|
+
* OOXML-specific encode/decode helpers for descriptors.
|
|
43
|
+
*
|
|
44
|
+
* XML traversal helpers (findChild, etc.) are in @office-open/xml utils.
|
|
45
|
+
* This file only contains OOXML value encoding/decoding.
|
|
46
|
+
*
|
|
47
|
+
* @module
|
|
48
|
+
*/
|
|
49
|
+
/** Encode boolean for CT_OnOff: true → omit val, false → "0". */
|
|
50
|
+
declare const boolEncode: (v: boolean | undefined) => string | undefined;
|
|
51
|
+
/** Decode CT_OnOff: absent or "true"/"1" → true, "0"/"false" → false. */
|
|
52
|
+
declare const boolDecode: (raw: string) => boolean;
|
|
53
|
+
/** Create an enum encoder from a JS↔XML mapping. */
|
|
54
|
+
declare const enumEncode: (map: Record<string, string>) => (v: string | undefined) => string | undefined;
|
|
55
|
+
/** Create an enum decoder from a JS↔XML mapping (inverted). */
|
|
56
|
+
declare const enumDecode: (map: Record<string, string>) => (raw: string) => string;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/descriptor/registry.d.ts
|
|
59
|
+
declare class DescriptorRegistry {
|
|
60
|
+
private static readonly _map;
|
|
61
|
+
/** Register a descriptor with its XML tag. */
|
|
62
|
+
static register(tag: string, desc: Descriptor<any>): void;
|
|
63
|
+
/** Look up a descriptor by XML tag. */
|
|
64
|
+
static get(tag: string): Descriptor<any> | undefined;
|
|
65
|
+
/** Get all registered tags. */
|
|
66
|
+
static tags(): ReadonlySet<string>;
|
|
67
|
+
/** Check if a tag is registered. */
|
|
68
|
+
static has(tag: string): boolean;
|
|
69
|
+
/** Get the number of registered descriptors. */
|
|
70
|
+
static get size(): number;
|
|
71
|
+
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/descriptor/field-spec.d.ts
|
|
74
|
+
/**
|
|
75
|
+
* Declarative field-consistency spec for descriptors.
|
|
76
|
+
*
|
|
77
|
+
* The `CustomDescriptor<T>` closure carries no field metadata, so the three
|
|
78
|
+
* places that must agree — the Options interface, the stringify body, and the
|
|
79
|
+
* parse body — drift silently (reflection dropping 9/14 props, styles
|
|
80
|
+
* round-trip loss, core-properties 8-interface/10-write/8-parse inflation).
|
|
81
|
+
*
|
|
82
|
+
* Each entry declares the three field sets in a single semantic dimension
|
|
83
|
+
* (Options field names, not XML tags), so {@link diffTagSets} can surface the
|
|
84
|
+
* asymmetries directly:
|
|
85
|
+
* - F1 write-loss — declared on the interface but never written
|
|
86
|
+
* - F2 write-only — written but absent from the interface (inflation)
|
|
87
|
+
* - F3 parse-loss — written but never restored on parse (round-trip loss)
|
|
88
|
+
* - F5 parse-only — restored but never written
|
|
89
|
+
*
|
|
90
|
+
* @module
|
|
91
|
+
*/
|
|
92
|
+
interface DescriptorFieldSpec {
|
|
93
|
+
/** Stable identifier, matched to the descriptor under test. */
|
|
94
|
+
id: string;
|
|
95
|
+
/** Options interface name (documentation / assertion messages). */
|
|
96
|
+
optionsInterface: string;
|
|
97
|
+
/** Fields declared on the Options interface — the contract. */
|
|
98
|
+
interfaceFields: readonly string[];
|
|
99
|
+
/** Fields the stringify path actually emits; may carry inflation not on the interface. */
|
|
100
|
+
writeFields: readonly string[];
|
|
101
|
+
/** Fields the parse path actually restores. */
|
|
102
|
+
parseFields: readonly string[];
|
|
103
|
+
/** Expected child order when the XSD mandates sequence; omitted when order-independent. */
|
|
104
|
+
order?: readonly string[];
|
|
105
|
+
/** Sample exercising the interface fields, for F4 round-trip deep-equality. */
|
|
106
|
+
sampleOptions: unknown;
|
|
107
|
+
/**
|
|
108
|
+
* Interface fields excluded from the contract comparison — input-side sugar
|
|
109
|
+
* (thematicBreak→border, rightTabStop→tabStops) and control flags
|
|
110
|
+
* (includeIfEmpty) that map field→XML but XML→a different field, breaking the
|
|
111
|
+
* 1:1 round-trip assumption. The interface-drift test asserts
|
|
112
|
+
* `interfaceFields === (live interface fields − excludeFields)`.
|
|
113
|
+
*/
|
|
114
|
+
excludeFields?: readonly string[];
|
|
115
|
+
notes?: string;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Curated high-value targets — each maps to a known historical drift.
|
|
119
|
+
* `settings` is intentionally absent: its round-trip is rawXml-based (byte
|
|
120
|
+
* passthrough), so field-level diff would mislabel every field as F2.
|
|
121
|
+
*/
|
|
122
|
+
declare const FIELD_SPECS: readonly DescriptorFieldSpec[];
|
|
123
|
+
declare function findFieldSpec(id: string): DescriptorFieldSpec | undefined;
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/descriptor/field-consistency.d.ts
|
|
126
|
+
interface FieldConsistencyReport {
|
|
127
|
+
/** F1 — declared on the interface but never written (write-loss). */
|
|
128
|
+
f1WriteLoss: readonly string[];
|
|
129
|
+
/** F2 — written but absent from the interface (write-only inflation). */
|
|
130
|
+
f2WriteOnly: readonly string[];
|
|
131
|
+
/** F3 — written but never restored on parse (round-trip loss). */
|
|
132
|
+
f3ParseLoss: readonly string[];
|
|
133
|
+
/** F5 — restored on parse but never written (parse-only). */
|
|
134
|
+
f5ParseOnly: readonly string[];
|
|
135
|
+
}
|
|
136
|
+
/** Diff the interface / write / parse field sets declared on a spec. */
|
|
137
|
+
declare function diffTagSets(spec: DescriptorFieldSpec): FieldConsistencyReport;
|
|
138
|
+
interface RoundTripResult {
|
|
139
|
+
/** Present in the sample, absent after round-trip. */
|
|
140
|
+
lost: readonly string[];
|
|
141
|
+
/** Absent from the sample, present after round-trip. */
|
|
142
|
+
gained: readonly string[];
|
|
143
|
+
/** Present on both sides with differing values. */
|
|
144
|
+
mutated: readonly string[];
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Run a stringify→parse cycle over a sample and diff the result field set.
|
|
148
|
+
* Returns the F4 round-trip drift. The caller supplies the descriptor's own
|
|
149
|
+
* stringify/parse (a `CustomDescriptor` pair or a function pair).
|
|
150
|
+
*/
|
|
151
|
+
declare function roundTripFields<T extends object, WC = unknown, RC = unknown>(stringifyFn: (opts: T, ctx: WC) => string | undefined, parseFn: (el: Element, ctx: RC) => T, sample: T, writeCtx: WC, readCtx: RC): RoundTripResult;
|
|
152
|
+
interface OrderViolation {
|
|
153
|
+
/** Position of the offending child within its parent. */
|
|
154
|
+
index: number;
|
|
155
|
+
/** Local name of the child element (namespace prefix stripped). */
|
|
156
|
+
tag: string;
|
|
157
|
+
/** Why the child violates the expected sequence. */
|
|
158
|
+
reason: "unexpected" | "out-of-order";
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Verify the child element order of a stringified container against an XSD
|
|
162
|
+
* sequence — the F6 check. Namespace prefixes are normalized, so `expected`
|
|
163
|
+
* entries may be qualified (`w:pStyle`) or local (`pStyle`); both match a
|
|
164
|
+
* `<w:pStyle>` child. Elements absent from `expected` are flagged "unexpected";
|
|
165
|
+
* a child whose expected position precedes the previous child's is
|
|
166
|
+
* "out-of-order".
|
|
167
|
+
*/
|
|
168
|
+
declare function checkOrder(xml: string, expected: readonly string[]): readonly OrderViolation[];
|
|
169
|
+
//#endregion
|
|
170
|
+
export { CustomDescriptor as _, diffTagSets as a, WriteContext as b, FIELD_SPECS as c, boolDecode as d, boolEncode as f, stringify$1 as g, parse$1 as h, checkOrder as i, findFieldSpec as l, enumEncode as m, OrderViolation as n, roundTripFields as o, enumDecode as p, RoundTripResult as r, DescriptorFieldSpec as s, FieldConsistencyReport as t, DescriptorRegistry as u, Descriptor as v, ReadContext as y };
|