@office-open/core 0.10.15 → 0.12.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/README.md +2 -1
- package/dist/chart/index.d.mts +2 -2
- package/dist/chart/index.mjs +2 -2
- package/dist/chart-DED4tXC9.mjs +2325 -0
- package/dist/chart-DED4tXC9.mjs.map +1 -0
- package/dist/color-mapping-CFF0vRSe.mjs +117 -0
- package/dist/color-mapping-CFF0vRSe.mjs.map +1 -0
- package/dist/data-type-CZMKVaaT.d.mts.map +1 -1
- package/dist/descriptor/index.d.mts +2 -2
- package/dist/descriptor/index.mjs +1 -1
- package/dist/{descriptor-BjNkn5jo.mjs → descriptor-BqaNZrrZ.mjs} +43 -11
- package/dist/{descriptor-BjNkn5jo.mjs.map → descriptor-BqaNZrrZ.mjs.map} +1 -1
- package/dist/drawing/index.d.mts +2 -0
- package/dist/drawing/index.mjs +2 -0
- package/dist/{drawingml-sj1J3lb0.mjs → drawing-BCAyrCCw.mjs} +4456 -3452
- package/dist/drawing-BCAyrCCw.mjs.map +1 -0
- package/dist/{converters-C_Y2QX1w.mjs → ext-uri-BHBcIrW7.mjs} +742 -45
- package/dist/ext-uri-BHBcIrW7.mjs.map +1 -0
- package/dist/index-BAxlDUQ1.d.mts +590 -0
- package/dist/index-BAxlDUQ1.d.mts.map +1 -0
- package/dist/index-BP541uS-.d.mts +489 -0
- package/dist/index-BP541uS-.d.mts.map +1 -0
- package/dist/{index-BVK2dv6C.d.mts → index-BQLIofaF.d.mts} +10 -4
- package/dist/index-BQLIofaF.d.mts.map +1 -0
- package/dist/{index-k8WKLXnA.d.mts → index-CaNwM5_e.d.mts} +19 -20
- package/dist/index-CaNwM5_e.d.mts.map +1 -0
- package/dist/index-DPkf_CtG.d.mts +1578 -0
- package/dist/index-DPkf_CtG.d.mts.map +1 -0
- package/dist/index-DcukVskh.d.mts +31 -0
- package/dist/index-DcukVskh.d.mts.map +1 -0
- package/dist/index-Di6XPdGl.d.mts +322 -0
- package/dist/index-Di6XPdGl.d.mts.map +1 -0
- package/dist/index-L6AXewfV.d.mts +872 -0
- package/dist/index-L6AXewfV.d.mts.map +1 -0
- package/dist/index.d.mts +294 -30
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1327 -112
- package/dist/index.mjs.map +1 -1
- package/dist/{output-D_G_JR_8.d.mts → output-yyxdkG0C.d.mts} +2 -3
- package/dist/output-yyxdkG0C.d.mts.map +1 -0
- package/dist/patch/index.d.mts +2 -2
- package/dist/patch/index.mjs +2 -2
- package/dist/{patch-BmRfghOo.mjs → patch-AkQY17CD.mjs} +73 -28
- package/dist/patch-AkQY17CD.mjs.map +1 -0
- package/dist/smartart/index.d.mts +2 -2
- package/dist/smartart/index.mjs +2 -2
- package/dist/smartart-n1kYJ6Jg.mjs +1650 -0
- package/dist/smartart-n1kYJ6Jg.mjs.map +1 -0
- package/dist/style-matrix-B6jhPAT3.mjs +123 -0
- package/dist/style-matrix-B6jhPAT3.mjs.map +1 -0
- package/dist/theme/index.d.mts +4 -2
- package/dist/theme/index.mjs +4 -2
- package/dist/theme-BKnXRmvn.mjs +426 -0
- package/dist/theme-BKnXRmvn.mjs.map +1 -0
- package/dist/theme-options-kO89NUEX.d.mts +109 -0
- package/dist/theme-options-kO89NUEX.d.mts.map +1 -0
- package/dist/util/index.d.mts +3 -3
- package/dist/util/index.mjs +3 -3
- package/dist/{util-Tq9PSjK0.mjs → util-ptE16MEk.mjs} +237 -459
- package/dist/util-ptE16MEk.mjs.map +1 -0
- package/dist/{values-8di32lIe.d.mts → values-BECDm4zr.d.mts} +17 -31
- package/dist/values-BECDm4zr.d.mts.map +1 -0
- package/dist/vector/index.d.mts +2 -0
- package/dist/vector/index.mjs +2 -0
- package/dist/vector-DhLGZjP5.mjs +3049 -0
- package/dist/vector-DhLGZjP5.mjs.map +1 -0
- package/package.json +16 -8
- package/dist/chart-DIGJna_6.mjs +0 -582
- package/dist/chart-DIGJna_6.mjs.map +0 -1
- package/dist/converters-C_Y2QX1w.mjs.map +0 -1
- package/dist/drawingml/index.d.mts +0 -2
- package/dist/drawingml/index.mjs +0 -2
- package/dist/drawingml-sj1J3lb0.mjs.map +0 -1
- package/dist/index-BVK2dv6C.d.mts.map +0 -1
- package/dist/index-BfHfKuKy.d.mts +0 -275
- package/dist/index-BfHfKuKy.d.mts.map +0 -1
- package/dist/index-CE53SwpZ.d.mts +0 -1463
- package/dist/index-CE53SwpZ.d.mts.map +0 -1
- package/dist/index-D6VE-MnJ.d.mts +0 -43
- package/dist/index-D6VE-MnJ.d.mts.map +0 -1
- package/dist/index-DE4CLElr.d.mts +0 -145
- package/dist/index-DE4CLElr.d.mts.map +0 -1
- package/dist/index-DlPA26cw.d.mts +0 -91
- package/dist/index-DlPA26cw.d.mts.map +0 -1
- package/dist/index-k8WKLXnA.d.mts.map +0 -1
- package/dist/output-D_G_JR_8.d.mts.map +0 -1
- package/dist/patch-BmRfghOo.mjs.map +0 -1
- package/dist/smartart-B7ukZ-Tw.mjs +0 -305
- package/dist/smartart-B7ukZ-Tw.mjs.map +0 -1
- package/dist/theme-CiNzdl-9.mjs +0 -177
- package/dist/theme-CiNzdl-9.mjs.map +0 -1
- package/dist/util-Tq9PSjK0.mjs.map +0 -1
- package/dist/values-8di32lIe.d.mts.map +0 -1
|
@@ -1,5 +1,376 @@
|
|
|
1
1
|
import { sha1 } from "@noble/hashes/legacy.js";
|
|
2
2
|
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
3
|
+
//#region src/util/values.ts
|
|
4
|
+
/**
|
|
5
|
+
* Validates and converts a number to an integer (decimal number).
|
|
6
|
+
*
|
|
7
|
+
* Reference: ST_DecimalNumber in OOXML specification
|
|
8
|
+
*
|
|
9
|
+
* @param val - The number to validate and convert
|
|
10
|
+
* @returns The floored integer value
|
|
11
|
+
* @throws Error if the value is NaN
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const num = decimalNumber(10.7); // Returns 10
|
|
16
|
+
* const negative = decimalNumber(-5.3); // Returns -5
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
const decimalNumber = (val) => {
|
|
20
|
+
if (!Number.isFinite(val)) throw new Error(`Invalid value '${val}' specified. Must be a finite number.`);
|
|
21
|
+
return Math.floor(val);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Validates and converts a number to a positive integer (unsigned decimal number).
|
|
25
|
+
*
|
|
26
|
+
* Reference: ST_UnsignedDecimalNumber in OOXML specification
|
|
27
|
+
*
|
|
28
|
+
* @param val - The number to validate and convert
|
|
29
|
+
* @returns The floored positive integer value
|
|
30
|
+
* @throws Error if the value is NaN or negative
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const num = unsignedDecimalNumber(10.7); // Returns 10
|
|
35
|
+
* const invalid = unsignedDecimalNumber(-5); // Throws Error
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
const unsignedDecimalNumber = (val) => {
|
|
39
|
+
const value = decimalNumber(val);
|
|
40
|
+
if (value < 0) throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`);
|
|
41
|
+
return value;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Validates and normalizes a hexadecimal binary value.
|
|
45
|
+
*
|
|
46
|
+
* The xsd:hexBinary type represents binary data as a sequence of binary octets
|
|
47
|
+
* using hexadecimal encoding, where each binary octet is a two-character
|
|
48
|
+
* hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
|
|
49
|
+
*
|
|
50
|
+
* @param val - The hexadecimal string to validate
|
|
51
|
+
* @param length - The expected length in bytes (not characters)
|
|
52
|
+
* @returns The validated hexadecimal string
|
|
53
|
+
* @throws Error if the value is not a valid hex string of the expected length
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
|
|
58
|
+
* hexBinary("ABC", 2); // Invalid: wrong length
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
const hexBinary = (val, length) => {
|
|
62
|
+
const expectedLength = length * 2;
|
|
63
|
+
if (val.length !== expectedLength || isNaN(Number(`0x${val}`))) throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`);
|
|
64
|
+
return val;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Validates a long hexadecimal number (4 bytes / 8 characters).
|
|
68
|
+
*
|
|
69
|
+
* Reference: ST_LongHexNumber in OOXML specification
|
|
70
|
+
*
|
|
71
|
+
* @param val - The hexadecimal string to validate
|
|
72
|
+
* @returns The validated hexadecimal string
|
|
73
|
+
* @throws Error if the value is not a valid 8-character hex string
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* const hex = longHexNumber("ABCD1234"); // Valid
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
const longHexNumber = (val) => hexBinary(val, 4);
|
|
81
|
+
/**
|
|
82
|
+
* Validates a short hexadecimal number (2 bytes / 4 characters).
|
|
83
|
+
*
|
|
84
|
+
* Reference: ST_ShortHexNumber in OOXML specification
|
|
85
|
+
*
|
|
86
|
+
* @param val - The hexadecimal string to validate
|
|
87
|
+
* @returns The validated hexadecimal string
|
|
88
|
+
* @throws Error if the value is not a valid 4-character hex string
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const hex = shortHexNumber("AB12"); // Valid
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
const shortHexNumber = (val) => hexBinary(val, 2);
|
|
96
|
+
/**
|
|
97
|
+
* Validates a single-byte hexadecimal number (1 byte / 2 characters).
|
|
98
|
+
*
|
|
99
|
+
* Reference: ST_UcharHexNumber in OOXML specification
|
|
100
|
+
*
|
|
101
|
+
* @param val - The hexadecimal string to validate
|
|
102
|
+
* @returns The validated hexadecimal string
|
|
103
|
+
* @throws Error if the value is not a valid 2-character hex string
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const hex = uCharHexNumber("FF"); // Valid
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
const uCharHexNumber = (val) => hexBinary(val, 1);
|
|
111
|
+
/**
|
|
112
|
+
* Normalizes a universal measure value by parsing and reformatting.
|
|
113
|
+
*
|
|
114
|
+
* Ensures the numeric portion is properly formatted while preserving the unit.
|
|
115
|
+
*
|
|
116
|
+
* Reference: ST_UniversalMeasure in OOXML specification
|
|
117
|
+
*
|
|
118
|
+
* @param val - The universal measure string to normalize
|
|
119
|
+
* @returns The normalized universal measure
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
const universalMeasureValue = (val) => {
|
|
127
|
+
const unit = val.slice(-2);
|
|
128
|
+
const amount = val.substring(0, val.length - 2);
|
|
129
|
+
return `${Number(amount)}${unit}`;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Validates and normalizes a positive universal measure value.
|
|
133
|
+
*
|
|
134
|
+
* Reference: ST_PositiveUniversalMeasure in OOXML specification
|
|
135
|
+
*
|
|
136
|
+
* @param val - The positive universal measure string to validate
|
|
137
|
+
* @returns The normalized positive universal measure
|
|
138
|
+
* @throws Error if the value is negative
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
|
|
143
|
+
* const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
const positiveUniversalMeasureValue = (val) => {
|
|
147
|
+
const value = universalMeasureValue(val);
|
|
148
|
+
if (parseFloat(value) < 0) throw new Error(`Invalid value '${value}' specified. Expected a positive number.`);
|
|
149
|
+
return value;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Validates and normalizes a hexadecimal color value.
|
|
153
|
+
*
|
|
154
|
+
* Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
|
|
155
|
+
* The # prefix is commonly used but technically invalid in OOXML, so it is stripped
|
|
156
|
+
* for strict compliance.
|
|
157
|
+
*
|
|
158
|
+
* Reference: ST_HexColor in OOXML specification
|
|
159
|
+
*
|
|
160
|
+
* @param val - The color value to validate ("auto" or hex color)
|
|
161
|
+
* @returns The normalized color value
|
|
162
|
+
* @throws Error if the hex color is invalid
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const color1 = hexColorValue("auto"); // Returns "auto"
|
|
167
|
+
* const color2 = hexColorValue("FF0000"); // Returns "FF0000"
|
|
168
|
+
* const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
const hexColorValue = (val) => {
|
|
172
|
+
if (val === "auto") return val;
|
|
173
|
+
const color = stripColorHashPrefix(val);
|
|
174
|
+
return hexBinary(color, 3);
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Strips the leading "#" prefix from a color string if present.
|
|
178
|
+
*
|
|
179
|
+
* Hex color values in OOXML do not include the "#" prefix, but user input
|
|
180
|
+
* commonly includes it. This helper normalizes color strings for OOXML output.
|
|
181
|
+
*
|
|
182
|
+
* @param color - The color string (with or without "#" prefix)
|
|
183
|
+
* @returns The color string without the "#" prefix
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```typescript
|
|
187
|
+
* stripColorHashPrefix("#FF0000"); // Returns "FF0000"
|
|
188
|
+
* stripColorHashPrefix("00FF00"); // Returns "00FF00"
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
const stripColorHashPrefix = (color) => color.charAt(0) === "#" ? color.substring(1) : color;
|
|
192
|
+
/**
|
|
193
|
+
* Parses an ST_OnOff / xsd:boolean attribute value.
|
|
194
|
+
*
|
|
195
|
+
* Accepts the full union lexical space leniently on read: true/false, 1/0
|
|
196
|
+
* (number or string — nativeTypeAttributes coerces 1/0 to numbers), and
|
|
197
|
+
* on/off (legal only in wml's ST_OnOff union, not in xsd:boolean). Emission
|
|
198
|
+
* stays per-schema canonical ("1"/"0").
|
|
199
|
+
*
|
|
200
|
+
* Reference: ST_OnOff in shared-commonSimpleTypes.xsd
|
|
201
|
+
*
|
|
202
|
+
* @param raw - The raw attribute value (string, number, or boolean)
|
|
203
|
+
* @returns The parsed boolean, or undefined when unrecognized
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* parseOnOff("1"); // true
|
|
208
|
+
* parseOnOff("off"); // false
|
|
209
|
+
* parseOnOff(1); // true (nativeTypeAttributes number coercion)
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
const parseOnOff = (raw) => {
|
|
213
|
+
if (raw === void 0) return void 0;
|
|
214
|
+
if (typeof raw === "boolean") return raw;
|
|
215
|
+
const s = String(raw).toLowerCase();
|
|
216
|
+
if (s === "1" || s === "true" || s === "on" || s === "t") return true;
|
|
217
|
+
if (s === "0" || s === "false" || s === "off" || s === "f") return false;
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Validates a signed TWIP measurement value.
|
|
221
|
+
*
|
|
222
|
+
* Accepts either a universal measure string or a numeric TWIP value.
|
|
223
|
+
*
|
|
224
|
+
* Reference: ST_SignedTwipsMeasure in OOXML specification
|
|
225
|
+
*
|
|
226
|
+
* @param val - The measurement value (universal measure or number)
|
|
227
|
+
* @returns The normalized measurement value
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* const measure1 = signedTwipsMeasureValue("10mm");
|
|
232
|
+
* const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
const signedTwipsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
|
|
236
|
+
/**
|
|
237
|
+
* Validates a half-point (HPS) measurement value.
|
|
238
|
+
*
|
|
239
|
+
* Accepts either a positive universal measure string or a positive number.
|
|
240
|
+
* HPS (half-points) are commonly used for font sizes.
|
|
241
|
+
*
|
|
242
|
+
* Reference: ST_HpsMeasure in OOXML specification
|
|
243
|
+
*
|
|
244
|
+
* @param val - The measurement value (positive universal measure or number)
|
|
245
|
+
* @returns The normalized measurement value
|
|
246
|
+
*
|
|
247
|
+
* @example
|
|
248
|
+
* ```typescript
|
|
249
|
+
* const fontSize1 = hpsMeasureValue("12pt");
|
|
250
|
+
* const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
const hpsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
|
|
254
|
+
/**
|
|
255
|
+
* Validates a signed half-point (HPS) measurement value.
|
|
256
|
+
*
|
|
257
|
+
* Accepts either a universal measure string or a numeric value.
|
|
258
|
+
*
|
|
259
|
+
* Reference: ST_SignedHpsMeasure in OOXML specification
|
|
260
|
+
*
|
|
261
|
+
* @param val - The measurement value (universal measure or number)
|
|
262
|
+
* @returns The normalized measurement value
|
|
263
|
+
*
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const spacing1 = signedHpsMeasureValue("6pt");
|
|
267
|
+
* const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
|
|
268
|
+
* ```
|
|
269
|
+
*/
|
|
270
|
+
const signedHpsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
|
|
271
|
+
/**
|
|
272
|
+
* Validates a positive TWIP measurement value.
|
|
273
|
+
*
|
|
274
|
+
* Accepts either a positive universal measure string or a positive number.
|
|
275
|
+
*
|
|
276
|
+
* Reference: ST_TwipsMeasure in OOXML specification
|
|
277
|
+
*
|
|
278
|
+
* @param val - The measurement value (positive universal measure or number)
|
|
279
|
+
* @returns The normalized measurement value
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```typescript
|
|
283
|
+
* const width1 = twipsMeasureValue("25.4mm");
|
|
284
|
+
* const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
const twipsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
|
|
288
|
+
/**
|
|
289
|
+
* Normalizes a percentage value by parsing and reformatting.
|
|
290
|
+
*
|
|
291
|
+
* Reference: ST_Percentage in OOXML specification
|
|
292
|
+
*
|
|
293
|
+
* @param val - The percentage string to normalize
|
|
294
|
+
* @returns The normalized percentage
|
|
295
|
+
*
|
|
296
|
+
* @example
|
|
297
|
+
* ```typescript
|
|
298
|
+
* const percent = percentageValue("50.000%"); // Returns "50%"
|
|
299
|
+
* ```
|
|
300
|
+
*/
|
|
301
|
+
const percentageValue = (val) => {
|
|
302
|
+
const percent = val.substring(0, val.length - 1);
|
|
303
|
+
return `${Number(percent)}%`;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Validates a measurement value that can be expressed as a number, percentage, or universal measure.
|
|
307
|
+
*
|
|
308
|
+
* Reference: ST_MeasurementOrPercent in OOXML specification
|
|
309
|
+
*
|
|
310
|
+
* @param val - The measurement value (number, percentage, or universal measure)
|
|
311
|
+
* @returns The normalized measurement value
|
|
312
|
+
*
|
|
313
|
+
* @example
|
|
314
|
+
* ```typescript
|
|
315
|
+
* const measure1 = measurementOrPercentValue(100); // Unqualified number
|
|
316
|
+
* const measure2 = measurementOrPercentValue("50%"); // Percentage
|
|
317
|
+
* const measure3 = measurementOrPercentValue("10mm"); // Universal measure
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
const measurementOrPercentValue = (val) => {
|
|
321
|
+
if (typeof val === "number") return decimalNumber(val);
|
|
322
|
+
if (val.slice(-1) === "%") return percentageValue(val);
|
|
323
|
+
return universalMeasureValue(val);
|
|
324
|
+
};
|
|
325
|
+
/**
|
|
326
|
+
* Validates an eighth-point measurement value.
|
|
327
|
+
*
|
|
328
|
+
* Eighth-points are used for fine-grained measurements in text formatting.
|
|
329
|
+
*
|
|
330
|
+
* Reference: ST_EighthPointMeasure in OOXML specification
|
|
331
|
+
*
|
|
332
|
+
* @param val - The measurement value in eighth-points
|
|
333
|
+
* @returns The validated positive integer value
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* const measure = eighthPointMeasureValue(16); // 2 points
|
|
338
|
+
* ```
|
|
339
|
+
*/
|
|
340
|
+
const eighthPointMeasureValue = unsignedDecimalNumber;
|
|
341
|
+
/**
|
|
342
|
+
* Validates a point measurement value.
|
|
343
|
+
*
|
|
344
|
+
* Reference: ST_PointMeasure in OOXML specification
|
|
345
|
+
*
|
|
346
|
+
* @param val - The measurement value in points
|
|
347
|
+
* @returns The validated positive integer value
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```typescript
|
|
351
|
+
* const fontSize = pointMeasureValue(12); // 12pt
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
const pointMeasureValue = unsignedDecimalNumber;
|
|
355
|
+
/**
|
|
356
|
+
* Converts a JavaScript Date object to an ISO 8601 date-time string.
|
|
357
|
+
*
|
|
358
|
+
* The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
|
|
359
|
+
* This matches the xsd:dateTime format required by OOXML.
|
|
360
|
+
*
|
|
361
|
+
* Reference: ST_DateTime in OOXML specification
|
|
362
|
+
*
|
|
363
|
+
* @param val - The Date object to convert
|
|
364
|
+
* @returns An ISO 8601 formatted date-time string
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```typescript
|
|
368
|
+
* const now = new Date();
|
|
369
|
+
* const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
const dateTimeValue = (val) => val.toISOString();
|
|
373
|
+
//#endregion
|
|
3
374
|
//#region \0polyfill-node.global.js
|
|
4
375
|
var _polyfill_node_global_default = typeof _polyfill_node_global_default !== "undefined" ? _polyfill_node_global_default : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
|
|
5
376
|
//#endregion
|
|
@@ -523,18 +894,23 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
|
|
|
523
894
|
byteOffset = +byteOffset;
|
|
524
895
|
if (isNaN(byteOffset)) byteOffset = dir ? 0 : buffer.length - 1;
|
|
525
896
|
if (byteOffset < 0) byteOffset = buffer.length + byteOffset;
|
|
526
|
-
if (byteOffset >= buffer.length)
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
else
|
|
897
|
+
if (byteOffset >= buffer.length) {
|
|
898
|
+
if (dir) return -1;
|
|
899
|
+
else byteOffset = buffer.length - 1;
|
|
900
|
+
} else if (byteOffset < 0) {
|
|
901
|
+
if (dir) byteOffset = 0;
|
|
902
|
+
else return -1;
|
|
903
|
+
}
|
|
530
904
|
if (typeof val === "string") val = Buffer.from(val, encoding);
|
|
531
905
|
if (internalIsBuffer(val)) {
|
|
532
906
|
if (val.length === 0) return -1;
|
|
533
907
|
return arrayIndexOf(buffer, val, byteOffset, encoding, dir);
|
|
534
908
|
} else if (typeof val === "number") {
|
|
535
909
|
val = val & 255;
|
|
536
|
-
if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function")
|
|
537
|
-
|
|
910
|
+
if (Buffer.TYPED_ARRAY_SUPPORT && typeof Uint8Array.prototype.indexOf === "function") {
|
|
911
|
+
if (dir) return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset);
|
|
912
|
+
else return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset);
|
|
913
|
+
}
|
|
538
914
|
return arrayIndexOf(buffer, [val], byteOffset, encoding, dir);
|
|
539
915
|
}
|
|
540
916
|
throw new TypeError("val must be string, number or Buffer");
|
|
@@ -1327,41 +1703,6 @@ function toUint8Array(data, options) {
|
|
|
1327
1703
|
throw new TypeError(`Unsupported data type: ${typeof data}`);
|
|
1328
1704
|
}
|
|
1329
1705
|
//#endregion
|
|
1330
|
-
//#region src/util/generators.ts
|
|
1331
|
-
/**
|
|
1332
|
-
* Unique ID generation utilities.
|
|
1333
|
-
*
|
|
1334
|
-
* @module
|
|
1335
|
-
*/
|
|
1336
|
-
/**
|
|
1337
|
-
* Creates a unique numeric ID generator with sequential numbering.
|
|
1338
|
-
*/
|
|
1339
|
-
const uniqueNumericIdCreator = (initial = 0) => {
|
|
1340
|
-
let currentCount = initial;
|
|
1341
|
-
return () => ++currentCount;
|
|
1342
|
-
};
|
|
1343
|
-
const URL_ALPHABET = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1344
|
-
/**
|
|
1345
|
-
* Generates a unique lowercase alphanumeric ID using crypto.getRandomValues.
|
|
1346
|
-
*/
|
|
1347
|
-
const uniqueId = () => {
|
|
1348
|
-
const bytes = new Uint8Array(21);
|
|
1349
|
-
crypto.getRandomValues(bytes);
|
|
1350
|
-
let id = "";
|
|
1351
|
-
for (const byte of bytes) id += URL_ALPHABET[byte & 63];
|
|
1352
|
-
return id.toLowerCase();
|
|
1353
|
-
};
|
|
1354
|
-
/**
|
|
1355
|
-
* Generates a SHA-1 hash of the provided data.
|
|
1356
|
-
*/
|
|
1357
|
-
const hashedId = (data) => {
|
|
1358
|
-
return bytesToHex(sha1(data instanceof ArrayBuffer ? new Uint8Array(data) : typeof data === "string" ? new TextEncoder().encode(data) : data));
|
|
1359
|
-
};
|
|
1360
|
-
/**
|
|
1361
|
-
* Generates a UUID v4-style unique identifier using crypto.randomUUID.
|
|
1362
|
-
*/
|
|
1363
|
-
const uniqueUuid = () => crypto.randomUUID();
|
|
1364
|
-
//#endregion
|
|
1365
1706
|
//#region src/util/mappings.ts
|
|
1366
1707
|
/**
|
|
1367
1708
|
* Bidirectional mappings between user-friendly values and XSD abbreviated values.
|
|
@@ -1478,6 +1819,16 @@ const xsdPresetShadow = bidi({
|
|
|
1478
1819
|
shadow19: "shdw19",
|
|
1479
1820
|
shadow20: "shdw20"
|
|
1480
1821
|
});
|
|
1822
|
+
const xsdLightRigDirection = bidi({
|
|
1823
|
+
topLeft: "tl",
|
|
1824
|
+
top: "t",
|
|
1825
|
+
topRight: "tr",
|
|
1826
|
+
left: "l",
|
|
1827
|
+
right: "r",
|
|
1828
|
+
bottomLeft: "bl",
|
|
1829
|
+
bottom: "b",
|
|
1830
|
+
bottomRight: "br"
|
|
1831
|
+
});
|
|
1481
1832
|
const xsdMaterialType = bidi({
|
|
1482
1833
|
legacyMatte: "legacyMatte",
|
|
1483
1834
|
legacyPlastic: "legacyPlastic",
|
|
@@ -1570,13 +1921,279 @@ const xsdTextCaps = bidi({
|
|
|
1570
1921
|
all: "all",
|
|
1571
1922
|
small: "small"
|
|
1572
1923
|
});
|
|
1924
|
+
const xsdAxisPosition = bidi({
|
|
1925
|
+
bottom: "b",
|
|
1926
|
+
left: "l",
|
|
1927
|
+
right: "r",
|
|
1928
|
+
top: "t"
|
|
1929
|
+
});
|
|
1930
|
+
const xsdLegendPosition = bidi({
|
|
1931
|
+
bottom: "b",
|
|
1932
|
+
topRight: "tr",
|
|
1933
|
+
left: "l",
|
|
1934
|
+
right: "r",
|
|
1935
|
+
top: "t"
|
|
1936
|
+
});
|
|
1937
|
+
const xsdDataLabelPosition = bidi({
|
|
1938
|
+
bottom: "b",
|
|
1939
|
+
center: "ctr",
|
|
1940
|
+
insideBase: "inBase",
|
|
1941
|
+
insideEnd: "inEnd",
|
|
1942
|
+
left: "l",
|
|
1943
|
+
outsideEnd: "outEnd",
|
|
1944
|
+
right: "r",
|
|
1945
|
+
top: "t"
|
|
1946
|
+
});
|
|
1947
|
+
const xsdAxisCrossBetween = bidi({ middleOfCategory: "midCat" });
|
|
1948
|
+
const xsdAxisCrosses = bidi({ zero: "autoZero" });
|
|
1949
|
+
const xsdComments = bidi({
|
|
1950
|
+
none: "commNone",
|
|
1951
|
+
indicator: "commIndicator",
|
|
1952
|
+
comment: "commIndAndComment"
|
|
1953
|
+
});
|
|
1954
|
+
const xsdErrorValueType = bidi({
|
|
1955
|
+
custom: "cust",
|
|
1956
|
+
fixedValue: "fixedVal",
|
|
1957
|
+
standardDeviation: "stdDev",
|
|
1958
|
+
standardError: "stdErr"
|
|
1959
|
+
});
|
|
1960
|
+
const xsdSizeRepresents = bidi({ width: "w" });
|
|
1961
|
+
const xsdSplitType = bidi({
|
|
1962
|
+
custom: "cust",
|
|
1963
|
+
position: "pos",
|
|
1964
|
+
value: "val"
|
|
1965
|
+
});
|
|
1966
|
+
const xsdAxisLabelAlignment = bidi({
|
|
1967
|
+
center: "ctr",
|
|
1968
|
+
left: "l",
|
|
1969
|
+
right: "r"
|
|
1970
|
+
});
|
|
1971
|
+
const xsdAxisOrientation = bidi({
|
|
1972
|
+
ascending: "minMax",
|
|
1973
|
+
descending: "maxMin"
|
|
1974
|
+
});
|
|
1975
|
+
const xsdTrendlineType = bidi({
|
|
1976
|
+
exponential: "exp",
|
|
1977
|
+
logarithmic: "log",
|
|
1978
|
+
movingAverage: "movingAvg",
|
|
1979
|
+
polynomial: "poly"
|
|
1980
|
+
});
|
|
1981
|
+
const xsdTextTabAlignment = bidi({
|
|
1982
|
+
left: "l",
|
|
1983
|
+
center: "ctr",
|
|
1984
|
+
right: "r",
|
|
1985
|
+
decimal: "dec"
|
|
1986
|
+
});
|
|
1987
|
+
const xsdFontAlignment = bidi({
|
|
1988
|
+
top: "t",
|
|
1989
|
+
center: "ctr",
|
|
1990
|
+
bottom: "b"
|
|
1991
|
+
});
|
|
1992
|
+
const xsdAnimLevel = bidi({
|
|
1993
|
+
level: "lvl",
|
|
1994
|
+
center: "ctr"
|
|
1995
|
+
});
|
|
1996
|
+
const xsdHierBranch = bidi({
|
|
1997
|
+
left: "l",
|
|
1998
|
+
right: "r",
|
|
1999
|
+
hanging: "hang",
|
|
2000
|
+
standard: "std",
|
|
2001
|
+
initial: "init"
|
|
2002
|
+
});
|
|
2003
|
+
const xsdHueDirection = bidi({
|
|
2004
|
+
clockwise: "cw",
|
|
2005
|
+
counterClockwise: "ccw"
|
|
2006
|
+
});
|
|
2007
|
+
const xsdDiagramDirection = bidi({
|
|
2008
|
+
normal: "norm",
|
|
2009
|
+
reversed: "rev"
|
|
2010
|
+
});
|
|
2011
|
+
const xsdResizeHandles = bidi({
|
|
2012
|
+
exact: "exact",
|
|
2013
|
+
relative: "rel"
|
|
2014
|
+
});
|
|
2015
|
+
const xsdOnOffStyle = bidi({ default: "def" });
|
|
2016
|
+
const xsdAnimClass = bidi({
|
|
2017
|
+
entrance: "entr",
|
|
2018
|
+
emphasis: "emph",
|
|
2019
|
+
mediaCall: "mediacall"
|
|
2020
|
+
});
|
|
2021
|
+
const xsdAnimCalcMode = bidi({
|
|
2022
|
+
linear: "lin",
|
|
2023
|
+
formula: "fmla"
|
|
2024
|
+
});
|
|
2025
|
+
const xsdAnimValueType = bidi({
|
|
2026
|
+
string: "str",
|
|
2027
|
+
number: "num",
|
|
2028
|
+
color: "clr"
|
|
2029
|
+
});
|
|
2030
|
+
const xsdTextBuild = bidi({
|
|
2031
|
+
paragraph: "p",
|
|
2032
|
+
custom: "cust"
|
|
2033
|
+
});
|
|
2034
|
+
const xsdDiagramBuild = bidi({
|
|
2035
|
+
clockwise: "cw",
|
|
2036
|
+
clockwiseIn: "cwIn",
|
|
2037
|
+
clockwiseOut: "cwOut",
|
|
2038
|
+
counterclockwise: "ccw",
|
|
2039
|
+
counterclockwiseIn: "ccwIn",
|
|
2040
|
+
counterclockwiseOut: "ccwOut",
|
|
2041
|
+
custom: "cust"
|
|
2042
|
+
});
|
|
2043
|
+
const xsdChartBuild = bidi({
|
|
2044
|
+
seriesElement: "seriesEl",
|
|
2045
|
+
categoryElement: "categoryEl"
|
|
2046
|
+
});
|
|
2047
|
+
const xsdAnimationDgmBuild = bidi({
|
|
2048
|
+
levelOne: "lvlOne",
|
|
2049
|
+
levelAtOnce: "lvlAtOnce"
|
|
2050
|
+
});
|
|
2051
|
+
const xsdIterateType = bidi({
|
|
2052
|
+
element: "el",
|
|
2053
|
+
word: "wd",
|
|
2054
|
+
letter: "lt"
|
|
2055
|
+
});
|
|
2056
|
+
const xsdSlideLayoutType = bidi({
|
|
2057
|
+
text: "tx",
|
|
2058
|
+
twoColumnText: "twoColTx",
|
|
2059
|
+
object: "obj",
|
|
2060
|
+
sectionHeader: "secHead",
|
|
2061
|
+
table: "tbl",
|
|
2062
|
+
clipArtAndText: "clipArtAndTx",
|
|
2063
|
+
pictureText: "picTx",
|
|
2064
|
+
twoObjects: "twoObj",
|
|
2065
|
+
twoTextAndTwoObjects: "twoTxTwoObj",
|
|
2066
|
+
objectAndText: "objTx",
|
|
2067
|
+
verticalText: "vertTx",
|
|
2068
|
+
verticalTitleAndText: "vertTitleAndTx"
|
|
2069
|
+
});
|
|
2070
|
+
const xsdTextVerticalType = bidi({
|
|
2071
|
+
horizontal: "horz",
|
|
2072
|
+
vertical: "vert",
|
|
2073
|
+
vertical270: "vert270",
|
|
2074
|
+
wordArtVertical: "wordArtVert",
|
|
2075
|
+
eastAsianVertical: "eaVert",
|
|
2076
|
+
mongolianVertical: "mongolianVert",
|
|
2077
|
+
wordArtVerticalRightToLeft: "wordArtVertRtl"
|
|
2078
|
+
});
|
|
2079
|
+
const xsdDashStyle = bidi({
|
|
2080
|
+
longDash: "lgDash",
|
|
2081
|
+
systemDot: "sysDot",
|
|
2082
|
+
systemDash: "sysDash"
|
|
2083
|
+
});
|
|
2084
|
+
const xsdOrient = bidi({
|
|
2085
|
+
horizontal: "horz",
|
|
2086
|
+
vertical: "vert"
|
|
2087
|
+
});
|
|
2088
|
+
const xsdPlaceholderType = bidi({
|
|
2089
|
+
centerTitle: "ctrTitle",
|
|
2090
|
+
date: "dt",
|
|
2091
|
+
slideNumber: "sldNum",
|
|
2092
|
+
footer: "ftr",
|
|
2093
|
+
header: "hdr",
|
|
2094
|
+
object: "obj",
|
|
2095
|
+
table: "tbl",
|
|
2096
|
+
diagram: "dgm",
|
|
2097
|
+
slideImage: "sldImg",
|
|
2098
|
+
picture: "pic"
|
|
2099
|
+
});
|
|
2100
|
+
const xsdMathStyle = bidi({
|
|
2101
|
+
plain: "p",
|
|
2102
|
+
bold: "b",
|
|
2103
|
+
italic: "i",
|
|
2104
|
+
boldItalic: "bi"
|
|
2105
|
+
});
|
|
2106
|
+
const xsdTableWidthType = bidi({
|
|
2107
|
+
twips: "dxa",
|
|
2108
|
+
percent: "pct"
|
|
2109
|
+
});
|
|
2110
|
+
const xsdJcAlignment = bidi({ numericTab: "numTab" });
|
|
2111
|
+
const xsdConsolidateFunction = bidi({
|
|
2112
|
+
countNumbers: "countNums",
|
|
2113
|
+
standardDeviation: "stdDev",
|
|
2114
|
+
standardDeviationPopulation: "stdDevp",
|
|
2115
|
+
variance: "var",
|
|
2116
|
+
variancePopulation: "varp"
|
|
2117
|
+
});
|
|
2118
|
+
const xsdShadingPattern = bidi({
|
|
2119
|
+
horizontalStripe: "horzStripe",
|
|
2120
|
+
verticalStripe: "vertStripe",
|
|
2121
|
+
reverseDiagonalStripe: "reverseDiagStripe",
|
|
2122
|
+
diagonalStripe: "diagStripe",
|
|
2123
|
+
horizontalCross: "horzCross",
|
|
2124
|
+
diagonalCross: "diagCross",
|
|
2125
|
+
thinHorizontalStripe: "thinHorzStripe",
|
|
2126
|
+
thinVerticalStripe: "thinVertStripe",
|
|
2127
|
+
thinReverseDiagonalStripe: "thinReverseDiagStripe",
|
|
2128
|
+
thinDiagonalStripe: "thinDiagStripe",
|
|
2129
|
+
thinHorizontalCross: "thinHorzCross",
|
|
2130
|
+
thinDiagonalCross: "thinDiagCross",
|
|
2131
|
+
percent5: "pct5",
|
|
2132
|
+
percent10: "pct10",
|
|
2133
|
+
percent12: "pct12",
|
|
2134
|
+
percent15: "pct15",
|
|
2135
|
+
percent20: "pct20",
|
|
2136
|
+
percent25: "pct25",
|
|
2137
|
+
percent30: "pct30",
|
|
2138
|
+
percent35: "pct35",
|
|
2139
|
+
percent37: "pct37",
|
|
2140
|
+
percent40: "pct40",
|
|
2141
|
+
percent45: "pct45",
|
|
2142
|
+
percent50: "pct50",
|
|
2143
|
+
percent55: "pct55",
|
|
2144
|
+
percent60: "pct60",
|
|
2145
|
+
percent62: "pct62",
|
|
2146
|
+
percent65: "pct65",
|
|
2147
|
+
percent70: "pct70",
|
|
2148
|
+
percent75: "pct75",
|
|
2149
|
+
percent80: "pct80",
|
|
2150
|
+
percent85: "pct85",
|
|
2151
|
+
percent87: "pct87",
|
|
2152
|
+
percent90: "pct90",
|
|
2153
|
+
percent95: "pct95"
|
|
2154
|
+
});
|
|
2155
|
+
const xsdTotalsRowFunction = bidi({
|
|
2156
|
+
countNumbers: "countNums",
|
|
2157
|
+
standardDeviation: "stdDev",
|
|
2158
|
+
variance: "var"
|
|
2159
|
+
});
|
|
1573
2160
|
//#endregion
|
|
1574
2161
|
//#region src/util/converters.ts
|
|
1575
2162
|
/**
|
|
1576
|
-
*
|
|
2163
|
+
* Apply `fn` to `value` unless it is `undefined`; `undefined` passes through.
|
|
1577
2164
|
*
|
|
1578
|
-
*
|
|
2165
|
+
* Lets an optional field (e.g. `radius?: number | UniversalMeasure`) be threaded
|
|
2166
|
+
* through a conversion without a per-call ternary.
|
|
2167
|
+
*/
|
|
2168
|
+
const mapOptional = (value, fn) => value === void 0 ? void 0 : fn(value);
|
|
2169
|
+
/**
|
|
2170
|
+
* Convert public percent (100 = 100%) to OOXML ST_Percentage scalar (1/1000).
|
|
2171
|
+
* Math.round ensures JSON-first float input produces exact integer output.
|
|
2172
|
+
*/
|
|
2173
|
+
const emitPercent = (percent) => Math.round(percent * 1e3);
|
|
2174
|
+
/**
|
|
2175
|
+
* Convert OOXML ST_Percentage scalar (1/1000) to public percent.
|
|
1579
2176
|
*/
|
|
2177
|
+
const parsePercent = (value) => value / 1e3;
|
|
2178
|
+
/**
|
|
2179
|
+
* Parse an ST_Percentage attribute that may arrive as either a 1/1000th
|
|
2180
|
+
* integer ("50000" = 50%) or a percent literal ("50%"); both are XSD-valid.
|
|
2181
|
+
* Returns the caller-facing integer percent.
|
|
2182
|
+
*/
|
|
2183
|
+
const parsePercentAttr = (raw) => {
|
|
2184
|
+
if (raw === void 0) return void 0;
|
|
2185
|
+
const s = typeof raw === "number" ? String(raw) : raw;
|
|
2186
|
+
return s.endsWith("%") ? Number(s.slice(0, -1)) : parsePercent(Number(s));
|
|
2187
|
+
};
|
|
2188
|
+
/**
|
|
2189
|
+
* Convert public degrees to OOXML ST_Angle / ST_FixedAngle scalar (1/60000).
|
|
2190
|
+
* Math.round ensures JSON-first float input produces exact integer output.
|
|
2191
|
+
*/
|
|
2192
|
+
const emitAngle = (degrees) => Math.round(degrees * 6e4);
|
|
2193
|
+
/**
|
|
2194
|
+
* Convert OOXML ST_Angle / ST_FixedAngle scalar (1/60000) to public degrees.
|
|
2195
|
+
*/
|
|
2196
|
+
const parseAngle = (value) => value / 6e4;
|
|
1580
2197
|
/**
|
|
1581
2198
|
* Converts millimeters to TWIP (twentieths of a point).
|
|
1582
2199
|
*/
|
|
@@ -1615,6 +2232,14 @@ const convertPointsToEmu = (points) => Math.round(points * 12700);
|
|
|
1615
2232
|
* Converts EMU to points.
|
|
1616
2233
|
*/
|
|
1617
2234
|
const convertEmuToPoints = (emus) => emus / 12700;
|
|
2235
|
+
/** Converts EMU to TWIP (1 TWIP = 635 EMU). */
|
|
2236
|
+
const convertEmuToTwip = (emus) => Math.round(emus / 635);
|
|
2237
|
+
/** Converts TWIP to EMU (1 TWIP = 635 EMU). */
|
|
2238
|
+
const convertTwipToEmu = (twips) => twips * 635;
|
|
2239
|
+
/** Converts points to TWIP (1 point = 20 TWIP). */
|
|
2240
|
+
const convertPointsToTwip = (points) => Math.round(points * 20);
|
|
2241
|
+
/** Converts TWIP to points (1 point = 20 TWIP). */
|
|
2242
|
+
const convertTwipToPoints = (twips) => twips / 20;
|
|
1618
2243
|
/**
|
|
1619
2244
|
* Parse a UniversalMeasure string into its numeric value and unit.
|
|
1620
2245
|
*
|
|
@@ -1784,6 +2409,78 @@ const convertUniversalMeasureToInch = (measure) => {
|
|
|
1784
2409
|
*/
|
|
1785
2410
|
const convertToInch = (val) => typeof val === "string" ? convertUniversalMeasureToInch(val) : val;
|
|
1786
2411
|
//#endregion
|
|
1787
|
-
|
|
2412
|
+
//#region src/util/generators.ts
|
|
2413
|
+
/**
|
|
2414
|
+
* Unique ID generation utilities.
|
|
2415
|
+
*
|
|
2416
|
+
* @module
|
|
2417
|
+
*/
|
|
2418
|
+
/**
|
|
2419
|
+
* Creates a unique numeric ID generator with sequential numbering.
|
|
2420
|
+
*/
|
|
2421
|
+
const uniqueNumericIdCreator = (initial = 0) => {
|
|
2422
|
+
let currentCount = initial;
|
|
2423
|
+
return () => ++currentCount;
|
|
2424
|
+
};
|
|
2425
|
+
const URL_ALPHABET = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
2426
|
+
/**
|
|
2427
|
+
* Generates a unique lowercase alphanumeric ID using crypto.getRandomValues.
|
|
2428
|
+
*/
|
|
2429
|
+
const uniqueId = () => {
|
|
2430
|
+
const bytes = /* @__PURE__ */ new Uint8Array(21);
|
|
2431
|
+
crypto.getRandomValues(bytes);
|
|
2432
|
+
let id = "";
|
|
2433
|
+
for (const byte of bytes) id += URL_ALPHABET[byte & 63];
|
|
2434
|
+
return id.toLowerCase();
|
|
2435
|
+
};
|
|
2436
|
+
/**
|
|
2437
|
+
* Generates a SHA-1 hash of the provided data.
|
|
2438
|
+
*/
|
|
2439
|
+
const hashedId = (data) => {
|
|
2440
|
+
const bytes = data instanceof ArrayBuffer ? new Uint8Array(data) : typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
2441
|
+
return bytesToHex(sha1(bytes));
|
|
2442
|
+
};
|
|
2443
|
+
/**
|
|
2444
|
+
* Generates a UUID v4-style unique identifier using crypto.randomUUID.
|
|
2445
|
+
*/
|
|
2446
|
+
const uniqueUuid = () => crypto.randomUUID();
|
|
2447
|
+
//#endregion
|
|
2448
|
+
//#region src/util/image-type.ts
|
|
2449
|
+
/** Map a media path's file extension to an image type token. */
|
|
2450
|
+
function imageTypeFromPath(path) {
|
|
2451
|
+
switch (path.split(".").pop()?.toLowerCase() ?? "") {
|
|
2452
|
+
case "jpg":
|
|
2453
|
+
case "jpeg": return "jpg";
|
|
2454
|
+
case "png": return "png";
|
|
2455
|
+
case "gif": return "gif";
|
|
2456
|
+
case "bmp": return "bmp";
|
|
2457
|
+
case "tif":
|
|
2458
|
+
case "tiff": return "tif";
|
|
2459
|
+
case "ico": return "ico";
|
|
2460
|
+
case "emf": return "emf";
|
|
2461
|
+
case "wmf": return "wmf";
|
|
2462
|
+
default: return "png";
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
//#endregion
|
|
2466
|
+
//#region src/util/ext-uri.ts
|
|
2467
|
+
/**
|
|
2468
|
+
* Extension-uri matching for a:ext/p:ext style extension lists.
|
|
2469
|
+
*
|
|
2470
|
+
* @module
|
|
2471
|
+
*/
|
|
2472
|
+
/**
|
|
2473
|
+
* Match an `@uri` attribute against a known extension uri. Producers write
|
|
2474
|
+
* GUID-style uris with or without the enclosing braces and in mixed case —
|
|
2475
|
+
* both spellings denote the same extension, so compare brace-stripped and
|
|
2476
|
+
* case-insensitively.
|
|
2477
|
+
*/
|
|
2478
|
+
function extUriMatches(actual, expected) {
|
|
2479
|
+
if (actual === void 0) return false;
|
|
2480
|
+
const norm = (uri) => uri.replace(/^[{]+|[}]+$/g, "").toLowerCase();
|
|
2481
|
+
return norm(actual) === norm(expected);
|
|
2482
|
+
}
|
|
2483
|
+
//#endregion
|
|
2484
|
+
export { xsdDiagramDirection as $, pointMeasureValue as $t, parseAngle as A, xsdTextBuild as At, xsdAxisCrossBetween as B, decodeBase64 as Bt, convertUniversalMeasureToEmu as C, xsdSizeRepresents as Ct, emitAngle as D, xsdTableWidthType as Dt, convertUniversalMeasureToTwip as E, xsdStrikeStyle as Et, xsdAnimCalcMode as F, xsdTrendlineType as Ft, xsdBlendMode as G, eighthPointMeasureValue as Gt, xsdAxisLabelAlignment as H, Buffer as Ht, xsdAnimClass as I, xsdUnderlineStyle as It, xsdCompoundLine as J, hpsMeasureValue as Jt, xsdChartBuild as K, hexBinary as Kt, xsdAnimLevel as L, xsdVerticalMergeRev as Lt, parsePercentAttr as M, xsdTextTabAlignment as Mt, parseUniversalMeasure as N, xsdTextVerticalType as Nt, emitPercent as O, xsdTextAlign as Ot, invertMap as P, xsdTotalsRowFunction as Pt, xsdDiagramBuild as Q, percentageValue as Qt, xsdAnimValueType as R, isBase64DataURL as Rt, convertTwipToPoints as S, xsdShadingPattern as St, convertUniversalMeasureToPt as T, xsdSplitType as Tt, xsdAxisOrientation as U, dateTimeValue as Ut, xsdAxisCrosses as V, encodeBase64 as Vt, xsdAxisPosition as W, decimalNumber as Wt, xsdDashStyle as X, measurementOrPercentValue as Xt, xsdConsolidateFunction as Y, longHexNumber as Yt, xsdDataLabelPosition as Z, parseOnOff as Zt, convertToEmu as _, xsdPenAlignment as _t, uniqueNumericIdCreator as a, twipsMeasureValue as an, xsdIterateType as at, convertToTwip as b, xsdRectAlignment as bt, convertEmuToPixels as c, unsignedDecimalNumber as cn, xsdLightRigDirection as ct, convertInchesToEmu as d, xsdMaterialType as dt, positiveUniversalMeasureValue as en, xsdEffectContainer as et, convertInchesToTwip as f, xsdMathStyle as ft, convertPointsToTwip as g, xsdPattern as gt, convertPointsToEmu as h, xsdPathFillMode as ht, uniqueId as i, stripColorHashPrefix as in, xsdHueDirection as it, parsePercent as j, xsdTextCaps as jt, mapOptional as k, xsdTextAnchor as kt, convertEmuToPoints as l, xsdLineCap as lt, convertPixelsToEmu as m, xsdOrient as mt, imageTypeFromPath as n, signedHpsMeasureValue as nn, xsdFontAlignment as nt, uniqueUuid as o, uCharHexNumber as on, xsdJcAlignment as ot, convertMillimetersToTwip as p, xsdOnOffStyle as pt, xsdComments as q, hexColorValue as qt, hashedId as r, signedTwipsMeasureValue as rn, xsdHierBranch as rt, convertEmuToInches as s, universalMeasureValue as sn, xsdLegendPosition as st, extUriMatches as t, shortHexNumber as tn, xsdErrorValueType as tt, convertEmuToTwip as u, xsdLineEndSize as ut, convertToInch as v, xsdPlaceholderType as vt, convertUniversalMeasureToInch as w, xsdSlideLayoutType as wt, convertTwipToEmu as x, xsdResizeHandles as xt, convertToPt as y, xsdPresetShadow as yt, xsdAnimationDgmBuild as z, toUint8Array as zt };
|
|
1788
2485
|
|
|
1789
|
-
//# sourceMappingURL=
|
|
2486
|
+
//# sourceMappingURL=ext-uri-BHBcIrW7.mjs.map
|