@office-open/core 0.10.14 → 0.11.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.
Files changed (83) hide show
  1. package/README.md +2 -1
  2. package/dist/chart/index.d.mts +2 -2
  3. package/dist/chart/index.mjs +2 -2
  4. package/dist/chart-Kf_utasF.mjs +1780 -0
  5. package/dist/chart-Kf_utasF.mjs.map +1 -0
  6. package/dist/color-mapping-CFF0vRSe.mjs +117 -0
  7. package/dist/color-mapping-CFF0vRSe.mjs.map +1 -0
  8. package/dist/descriptor/index.d.mts +2 -2
  9. package/dist/descriptor/index.mjs +1 -1
  10. package/dist/{descriptor-BjNkn5jo.mjs → descriptor-BX8xW8na.mjs} +6 -2
  11. package/dist/{descriptor-BjNkn5jo.mjs.map → descriptor-BX8xW8na.mjs.map} +1 -1
  12. package/dist/drawing/index.d.mts +2 -0
  13. package/dist/drawing/index.mjs +2 -0
  14. package/dist/{drawingml-sj1J3lb0.mjs → drawing-FBzd2I0m.mjs} +2596 -1518
  15. package/dist/drawing-FBzd2I0m.mjs.map +1 -0
  16. package/dist/{converters-C_Y2QX1w.mjs → generators-CElPsAhd.mjs} +699 -258
  17. package/dist/generators-CElPsAhd.mjs.map +1 -0
  18. package/dist/index-BsTUn4K1.d.mts +28 -0
  19. package/dist/index-BsTUn4K1.d.mts.map +1 -0
  20. package/dist/index-C0ClOhmZ.d.mts +869 -0
  21. package/dist/index-C0ClOhmZ.d.mts.map +1 -0
  22. package/dist/{index-BVK2dv6C.d.mts → index-CLX7gU9J.d.mts} +8 -3
  23. package/dist/index-CLX7gU9J.d.mts.map +1 -0
  24. package/dist/index-Cgz88FU0.d.mts +308 -0
  25. package/dist/index-Cgz88FU0.d.mts.map +1 -0
  26. package/dist/{index-CE53SwpZ.d.mts → index-CnjCK-lF.d.mts} +497 -351
  27. package/dist/index-CnjCK-lF.d.mts.map +1 -0
  28. package/dist/{index-BfHfKuKy.d.mts → index-DpPeyf5f.d.mts} +61 -20
  29. package/dist/index-DpPeyf5f.d.mts.map +1 -0
  30. package/dist/index-DxwLMnBF.d.mts +384 -0
  31. package/dist/index-DxwLMnBF.d.mts.map +1 -0
  32. package/dist/index.d.mts +175 -22
  33. package/dist/index.d.mts.map +1 -1
  34. package/dist/index.mjs +523 -70
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/patch/index.mjs +1 -1
  37. package/dist/{patch-BmRfghOo.mjs → patch-3KLx2yEP.mjs} +4 -4
  38. package/dist/patch-3KLx2yEP.mjs.map +1 -0
  39. package/dist/smartart/index.d.mts +2 -2
  40. package/dist/smartart/index.mjs +2 -2
  41. package/dist/smartart-BxnkROOp.mjs +1649 -0
  42. package/dist/smartart-BxnkROOp.mjs.map +1 -0
  43. package/dist/style-matrix-DAP6XrLv.mjs +123 -0
  44. package/dist/style-matrix-DAP6XrLv.mjs.map +1 -0
  45. package/dist/theme/index.d.mts +4 -2
  46. package/dist/theme/index.mjs +3 -2
  47. package/dist/theme-OAuRcA9_.mjs +460 -0
  48. package/dist/theme-OAuRcA9_.mjs.map +1 -0
  49. package/dist/theme-options-BbWccl85.d.mts +109 -0
  50. package/dist/theme-options-BbWccl85.d.mts.map +1 -0
  51. package/dist/util/index.d.mts +3 -3
  52. package/dist/util/index.mjs +3 -3
  53. package/dist/{util-Tq9PSjK0.mjs → util-C94-JKtp.mjs} +175 -429
  54. package/dist/util-C94-JKtp.mjs.map +1 -0
  55. package/dist/{values-8di32lIe.d.mts → values-aVoirbWB.d.mts} +4 -2
  56. package/dist/values-aVoirbWB.d.mts.map +1 -0
  57. package/dist/vector/index.d.mts +2 -0
  58. package/dist/vector/index.mjs +2 -0
  59. package/dist/vector-TpjW6ZSc.mjs +3092 -0
  60. package/dist/vector-TpjW6ZSc.mjs.map +1 -0
  61. package/package.json +15 -7
  62. package/dist/chart-DIGJna_6.mjs +0 -582
  63. package/dist/chart-DIGJna_6.mjs.map +0 -1
  64. package/dist/converters-C_Y2QX1w.mjs.map +0 -1
  65. package/dist/drawingml/index.d.mts +0 -2
  66. package/dist/drawingml/index.mjs +0 -2
  67. package/dist/drawingml-sj1J3lb0.mjs.map +0 -1
  68. package/dist/index-BVK2dv6C.d.mts.map +0 -1
  69. package/dist/index-BfHfKuKy.d.mts.map +0 -1
  70. package/dist/index-CE53SwpZ.d.mts.map +0 -1
  71. package/dist/index-D6VE-MnJ.d.mts +0 -43
  72. package/dist/index-D6VE-MnJ.d.mts.map +0 -1
  73. package/dist/index-DE4CLElr.d.mts +0 -145
  74. package/dist/index-DE4CLElr.d.mts.map +0 -1
  75. package/dist/index-DlPA26cw.d.mts +0 -91
  76. package/dist/index-DlPA26cw.d.mts.map +0 -1
  77. package/dist/patch-BmRfghOo.mjs.map +0 -1
  78. package/dist/smartart-B7ukZ-Tw.mjs +0 -305
  79. package/dist/smartart-B7ukZ-Tw.mjs.map +0 -1
  80. package/dist/theme-CiNzdl-9.mjs +0 -177
  81. package/dist/theme-CiNzdl-9.mjs.map +0 -1
  82. package/dist/util-Tq9PSjK0.mjs.map +0 -1
  83. package/dist/values-8di32lIe.d.mts.map +0 -1
@@ -1,32 +1,6 @@
1
- import { U as encodeBase64, W as Buffer } from "./converters-C_Y2QX1w.mjs";
2
- import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, unzipSync as unzipSync$1, zip, zipSync } from "fflate";
1
+ import { $ as Buffer, Q as encodeBase64 } from "./generators-CElPsAhd.mjs";
2
+ import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, unzipSync as unzipSync$1, zip, zipSync, zipSync as zipSync$1 } from "fflate";
3
3
  import { sha512 } from "@noble/hashes/sha2.js";
4
- //#region src/opc/output.ts
5
- /**
6
- * Output type definitions for OOXML document export.
7
- *
8
- * @module
9
- */
10
- const OoxmlMimeType = {
11
- DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
12
- PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
13
- XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
14
- };
15
- const convertOutput = (data, type, mimeType = OoxmlMimeType.DOCX) => {
16
- switch (type) {
17
- case "nodebuffer": return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
18
- case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: mimeType });
19
- case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
20
- case "uint8array": return data;
21
- case "base64": return encodeBase64(data);
22
- case "string":
23
- case "text":
24
- case "binarystring": return strFromU8(data, true);
25
- case "array": return [...data];
26
- default: return data;
27
- }
28
- };
29
- //#endregion
30
4
  //#region src/opc/zip-native.ts
31
5
  const CRC_TABLE = new Int32Array(256);
32
6
  for (let i = 0; i < 256; i++) {
@@ -56,6 +30,15 @@ try {
56
30
  } catch {}
57
31
  const hasNativeDeflate = () => _nativeDeflate !== void 0;
58
32
  const hasNativeInflate = () => _nativeInflate !== void 0;
33
+ /**
34
+ * Synchronous native CRC-32 (`zlib.crc32`, Node/Bun only) — undefined where no
35
+ * native zlib resolved (browsers/Deno). Used by media dedup as a fast content
36
+ * key; callers keep their own JS fallback. ~59× faster than a JS hash on
37
+ * 100 MB inputs.
38
+ */
39
+ function nativeCrc32(data) {
40
+ return _nativeCrc32?.(data);
41
+ }
59
42
  function wU16(b, o, v) {
60
43
  b[o] = v & 255;
61
44
  b[o + 1] = v >> 8 & 255;
@@ -274,6 +257,32 @@ function nativeUnzip(buf) {
274
257
  return out;
275
258
  }
276
259
  //#endregion
260
+ //#region src/opc/output.ts
261
+ /**
262
+ * Output type definitions for OOXML document export.
263
+ *
264
+ * @module
265
+ */
266
+ const OoxmlMimeType = {
267
+ DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
268
+ PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
269
+ XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
270
+ };
271
+ const convertOutput = (data, type, mimeType = OoxmlMimeType.DOCX) => {
272
+ switch (type) {
273
+ case "nodebuffer": return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
274
+ case "blob": return new Blob([data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength)], { type: mimeType });
275
+ case "arraybuffer": return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
276
+ case "uint8array": return data;
277
+ case "base64": return encodeBase64(data);
278
+ case "string":
279
+ case "text":
280
+ case "binarystring": return strFromU8(data, true);
281
+ case "array": return [...data];
282
+ default: return data;
283
+ }
284
+ };
285
+ //#endregion
277
286
  //#region src/opc/packer.ts
278
287
  /**
279
288
  * Shared packer utilities for OOXML document generation.
@@ -286,15 +295,26 @@ const ZIP_DEFLATE_LEVEL = 1;
286
295
  const ZIP_STORED_LEVEL = 0;
287
296
  /**
288
297
  * Media formats already compressed internally (DEFLATE for PNG, DCT for JPEG,
289
- * LZW for GIF). Re-compressing via zip DEFLATE wastes CPU and often inflates
290
- * the data, so MS Office STORE-s these (CompressionOption.NotCompressed zip
291
- * method 0). Everything else (EMF/WMF/BMP/TIFF/SVG/…) is compressible DEFLATE.
298
+ * LZW for GIF; video/audio containers carry their own codec streams).
299
+ * Re-compressing via zip DEFLATE wastes CPU and often inflates the data, so
300
+ * MS Office STORE-s these (CompressionOption.NotCompressed zip method 0).
301
+ * Everything else (EMF/WMF/BMP/TIFF/SVG/WAV…) is compressible → DEFLATE —
302
+ * measured on a real Office package, EMF at zlib level 6 matches Office
303
+ * output where SuperFast inflates ~15%.
292
304
  */
293
305
  const PRECOMPRESSED_MEDIA_EXT = new Set([
294
306
  "jpg",
295
307
  "jpeg",
296
308
  "png",
297
- "gif"
309
+ "gif",
310
+ "mp4",
311
+ "mov",
312
+ "wmv",
313
+ "mpg",
314
+ "mpeg",
315
+ "mp3",
316
+ "wma",
317
+ "aac"
298
318
  ]);
299
319
  /**
300
320
  * Resolve the ZIP level for a media entry by file-name extension, matching MS
@@ -369,6 +389,45 @@ const createZipStream = (files, defaultLevel = 1) => {
369
389
  } });
370
390
  };
371
391
  /**
392
+ * Incremental ZIP archive writer over fflate's streaming `Zip` — parts are
393
+ * added and completed one at a time; compressed output flows to `ondata` as
394
+ * it is produced. This is the constant-memory counterpart to
395
+ * {@link createZipStream} (which requires the complete `Zippable` up front):
396
+ * serialize each part chunk-wise into the returned sink instead of building
397
+ * the full part string.
398
+ *
399
+ * Parts must be added in order — `[Content_Types].xml` first per OPC. The
400
+ * whole archive finishes when {@link ZipStreamWriter.end} is called.
401
+ */
402
+ var ZipStreamWriter = class {
403
+ defaultLevel;
404
+ zip;
405
+ current;
406
+ constructor(ondata, defaultLevel = 1) {
407
+ this.defaultLevel = defaultLevel;
408
+ this.zip = new Zip(ondata);
409
+ }
410
+ /** Add a part and return its incremental sink. `end()` the previous first. */
411
+ addPart(name, level = this.defaultLevel) {
412
+ if (this.current) throw new Error(`ZipStreamWriter: previous part not finalized`);
413
+ const entry = level === 0 ? new ZipPassThrough(name) : new AsyncZipDeflate(name, { level });
414
+ this.zip.add(entry);
415
+ this.current = entry;
416
+ return {
417
+ push: (chunk) => entry.push(chunk, false),
418
+ end: (lastChunk) => {
419
+ entry.push(lastChunk ?? new Uint8Array(0), true);
420
+ this.current = void 0;
421
+ }
422
+ };
423
+ }
424
+ /** Finish the archive (central directory + EOCD). */
425
+ end() {
426
+ if (this.current) throw new Error(`ZipStreamWriter: unclosed part at end()`);
427
+ this.zip.end();
428
+ }
429
+ };
430
+ /**
372
431
  * Create a Packer object with all output format methods.
373
432
  *
374
433
  * Centralises the ZIP → convert pipeline and the streaming implementation
@@ -473,16 +532,25 @@ const createPacker = (options) => {
473
532
  */
474
533
  /** Reusable TextEncoder instance (stateless, safe to share). */
475
534
  const encoder = new TextEncoder();
535
+ /** Add one binary ZIP entry using the shared media compression policy. */
536
+ function addBinaryFile(files, path, data, mediaLevel) {
537
+ files[path] = [data, { level: levelForMediaName(path, mediaLevel) }];
538
+ }
476
539
  /**
477
- * Convert a mapping of XML files + overrides + media into a Zippable structure.
540
+ * Convert XML files, overrides, and media into a Zippable structure.
478
541
  *
479
- * Centralises the mapping→Zippable conversion shared by all three compilers.
542
+ * Mapping values may be optional arrays so package compilers can pass their
543
+ * natural part mappings without reimplementing flattening and byte encoding.
480
544
  */
481
545
  function compileMapping(mapping, overrides, media, mediaLevel = 0) {
482
546
  const files = {};
483
- for (const entry of Object.values(mapping)) files[entry.path] = encoder.encode(entry.data);
484
- if (overrides) for (const o of overrides) files[o.path] = typeof o.data === "string" ? encoder.encode(o.data) : o.data;
485
- if (media) for (const m of media) files[m.path] = [m.data, { level: levelForMediaName(m.path, mediaLevel) }];
547
+ for (const entry of Object.values(mapping)) {
548
+ if (entry === void 0) continue;
549
+ const entries = Array.isArray(entry) ? entry : [entry];
550
+ for (const file of entries) files[file.path] = typeof file.data === "string" ? encoder.encode(file.data) : file.data;
551
+ }
552
+ for (const override of overrides ?? []) files[override.path] = typeof override.data === "string" ? encoder.encode(override.data) : override.data;
553
+ for (const file of media ?? []) addBinaryFile(files, file.path, file.data, mediaLevel);
486
554
  return files;
487
555
  }
488
556
  //#endregion
@@ -554,19 +622,45 @@ function derivePasswordHash(password, spinCount = 1e5) {
554
622
  //#endregion
555
623
  //#region src/util/placeholder.ts
556
624
  const formatId = (offset, index, style) => style === "rId" ? `rId${offset + index}` : `${offset + index}`;
557
- /** Single-pass regex replacement for `{key}` placeholders using a Map lookup. */
558
- const PLACEHOLDER_RE = /\{([^{}]+)\}/g;
625
+ /**
626
+ * Find the next `{key}` placeholder at/after `from`. Returns `[open, close]`
627
+ * brace indices, or undefined when none remain. Mirrors the semantics of
628
+ * `/\{([^{}]+)\}/g`: empty keys and keys containing `{` are skipped (the scan
629
+ * restarts after the nested brace), matching what the regex would accept.
630
+ */
631
+ function nextPlaceholder(xml, from) {
632
+ let pos = from;
633
+ for (;;) {
634
+ const open = xml.indexOf("{", pos);
635
+ if (open === -1) return void 0;
636
+ const close = xml.indexOf("}", open + 1);
637
+ if (close === -1) return void 0;
638
+ if (close - open - 1 === 0) {
639
+ pos = open + 1;
640
+ continue;
641
+ }
642
+ const nextOpen = xml.indexOf("{", open + 1);
643
+ if (nextOpen !== -1 && nextOpen < close) {
644
+ pos = open + 1;
645
+ continue;
646
+ }
647
+ return [open, close];
648
+ }
649
+ }
559
650
  function replacePlaceholders(xml, map) {
560
651
  const parts = [];
561
652
  let last = 0;
562
- for (const m of xml.matchAll(PLACEHOLDER_RE)) {
563
- const key = m[1];
564
- if (key === void 0) continue;
565
- const replacement = map.get(key);
653
+ let pos = 0;
654
+ for (;;) {
655
+ const found = nextPlaceholder(xml, pos);
656
+ if (found === void 0) break;
657
+ const [open, close] = found;
658
+ const replacement = map.get(xml.substring(open + 1, close));
566
659
  if (replacement !== void 0) {
567
- parts.push(xml.substring(last, m.index), replacement);
568
- last = m.index + m[0].length;
660
+ parts.push(xml.substring(last, open), replacement);
661
+ last = close + 1;
569
662
  }
663
+ pos = close + 1;
570
664
  }
571
665
  if (last === 0) return xml;
572
666
  parts.push(xml.substring(last));
@@ -616,18 +710,24 @@ function findAndReplaceImagePlaceholders(xml, mediaArray, offset, idFormat = "rI
616
710
  const replaceMap = /* @__PURE__ */ new Map();
617
711
  const parts = [];
618
712
  let last = 0;
619
- for (const m of xml.matchAll(PLACEHOLDER_RE)) {
620
- const key = m[1];
621
- if (key === void 0) continue;
713
+ let pos = 0;
714
+ for (;;) {
715
+ const found = nextPlaceholder(xml, pos);
716
+ if (found === void 0) break;
717
+ const [open, close] = found;
718
+ const key = xml.substring(open + 1, close);
622
719
  const item = itemMap.get(key);
623
720
  if (item !== void 0) {
624
- if (!replaceMap.has(key)) {
625
- replaceMap.set(key, formatId(offset, referenced.length, idFormat));
721
+ let id = replaceMap.get(key);
722
+ if (id === void 0) {
723
+ id = formatId(offset, referenced.length, idFormat);
724
+ replaceMap.set(key, id);
626
725
  referenced.push(item);
627
726
  }
628
- parts.push(xml.substring(last, m.index), replaceMap.get(key));
629
- last = m.index + m[0].length;
727
+ parts.push(xml.substring(last, open), id);
728
+ last = close + 1;
630
729
  }
730
+ pos = close + 1;
631
731
  }
632
732
  if (last === 0) return {
633
733
  xml,
@@ -697,16 +797,24 @@ function replaceNumberingPlaceholders(xml, concreteNumberings) {
697
797
  }
698
798
  /** Replace `{media:fileName}` placeholders with relationship IDs. */
699
799
  function replaceMediaPlaceholders(xml, mediaData, offset) {
700
- if (mediaData.length === 0) return xml;
701
- const map = /* @__PURE__ */ new Map();
702
- for (const [i, item] of mediaData.entries()) map.set(`media:${item.fileName}`, formatId(offset, i, "rId"));
703
- return replacePlaceholders(xml, map);
800
+ return replacePrefixedPlaceholders(xml, mediaData, offset, "media:");
704
801
  }
705
802
  /** Replace `{video:fileName}` placeholders with relationship IDs. */
706
803
  function replaceVideoPlaceholders(xml, mediaData, offset) {
804
+ return replacePrefixedPlaceholders(xml, mediaData, offset, "video:");
805
+ }
806
+ /** Replace `{audio:fileName}` placeholders with relationship IDs. */
807
+ function replaceAudioPlaceholders(xml, mediaData, offset) {
808
+ return replacePrefixedPlaceholders(xml, mediaData, offset, "audio:");
809
+ }
810
+ /** Replace `{ole:fileName}` placeholders with relationship IDs. */
811
+ function replaceOlePlaceholders(xml, embeddings, offset) {
812
+ return replacePrefixedPlaceholders(xml, embeddings, offset, "ole:");
813
+ }
814
+ function replacePrefixedPlaceholders(xml, mediaData, offset, prefix) {
707
815
  if (mediaData.length === 0) return xml;
708
816
  const map = /* @__PURE__ */ new Map();
709
- for (const [i, item] of mediaData.entries()) map.set(`video:${item.fileName}`, formatId(offset, i, "rId"));
817
+ for (const [i, item] of mediaData.entries()) map.set(`${prefix}${item.fileName}`, formatId(offset, i, "rId"));
710
818
  return replacePlaceholders(xml, map);
711
819
  }
712
820
  /** Collect media items referenced by `{media:...}` placeholders in XML. */
@@ -717,6 +825,14 @@ function getMediaRefs(xml, mediaArray) {
717
825
  function getVideoRefs(xml, mediaArray) {
718
826
  return collectPrefixedRefs(xml, "video:", mediaArray);
719
827
  }
828
+ /** Collect media items referenced by `{audio:...}` placeholders in XML. */
829
+ function getAudioRefs(xml, mediaArray) {
830
+ return collectPrefixedRefs(xml, "audio:", mediaArray);
831
+ }
832
+ /** Collect OLE embeddings referenced by `{ole:...}` placeholders in XML. */
833
+ function getOleRefs(xml, embeddings) {
834
+ return collectPrefixedRefs(xml, "ole:", embeddings);
835
+ }
720
836
  function collectPrefixedRefs(xml, prefix, mediaArray) {
721
837
  const keys = /* @__PURE__ */ new Set();
722
838
  const search = `{${prefix}`;
@@ -738,376 +854,6 @@ function replaceHyperlinkPlaceholders(xml, hyperlinks, offset) {
738
854
  return replacePlaceholders(xml, map);
739
855
  }
740
856
  //#endregion
741
- //#region src/util/values.ts
742
- /**
743
- * Validates and converts a number to an integer (decimal number).
744
- *
745
- * Reference: ST_DecimalNumber in OOXML specification
746
- *
747
- * @param val - The number to validate and convert
748
- * @returns The floored integer value
749
- * @throws Error if the value is NaN
750
- *
751
- * @example
752
- * ```typescript
753
- * const num = decimalNumber(10.7); // Returns 10
754
- * const negative = decimalNumber(-5.3); // Returns -5
755
- * ```
756
- */
757
- const decimalNumber = (val) => {
758
- if (!Number.isFinite(val)) throw new Error(`Invalid value '${val}' specified. Must be a finite number.`);
759
- return Math.floor(val);
760
- };
761
- /**
762
- * Validates and converts a number to a positive integer (unsigned decimal number).
763
- *
764
- * Reference: ST_UnsignedDecimalNumber in OOXML specification
765
- *
766
- * @param val - The number to validate and convert
767
- * @returns The floored positive integer value
768
- * @throws Error if the value is NaN or negative
769
- *
770
- * @example
771
- * ```typescript
772
- * const num = unsignedDecimalNumber(10.7); // Returns 10
773
- * const invalid = unsignedDecimalNumber(-5); // Throws Error
774
- * ```
775
- */
776
- const unsignedDecimalNumber = (val) => {
777
- const value = decimalNumber(val);
778
- if (value < 0) throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`);
779
- return value;
780
- };
781
- /**
782
- * Validates and normalizes a hexadecimal binary value.
783
- *
784
- * The xsd:hexBinary type represents binary data as a sequence of binary octets
785
- * using hexadecimal encoding, where each binary octet is a two-character
786
- * hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
787
- *
788
- * @param val - The hexadecimal string to validate
789
- * @param length - The expected length in bytes (not characters)
790
- * @returns The validated hexadecimal string
791
- * @throws Error if the value is not a valid hex string of the expected length
792
- *
793
- * @example
794
- * ```typescript
795
- * hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
796
- * hexBinary("ABC", 2); // Invalid: wrong length
797
- * ```
798
- */
799
- const hexBinary = (val, length) => {
800
- const expectedLength = length * 2;
801
- if (val.length !== expectedLength || isNaN(Number(`0x${val}`))) throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`);
802
- return val;
803
- };
804
- /**
805
- * Validates a long hexadecimal number (4 bytes / 8 characters).
806
- *
807
- * Reference: ST_LongHexNumber in OOXML specification
808
- *
809
- * @param val - The hexadecimal string to validate
810
- * @returns The validated hexadecimal string
811
- * @throws Error if the value is not a valid 8-character hex string
812
- *
813
- * @example
814
- * ```typescript
815
- * const hex = longHexNumber("ABCD1234"); // Valid
816
- * ```
817
- */
818
- const longHexNumber = (val) => hexBinary(val, 4);
819
- /**
820
- * Validates a short hexadecimal number (2 bytes / 4 characters).
821
- *
822
- * Reference: ST_ShortHexNumber in OOXML specification
823
- *
824
- * @param val - The hexadecimal string to validate
825
- * @returns The validated hexadecimal string
826
- * @throws Error if the value is not a valid 4-character hex string
827
- *
828
- * @example
829
- * ```typescript
830
- * const hex = shortHexNumber("AB12"); // Valid
831
- * ```
832
- */
833
- const shortHexNumber = (val) => hexBinary(val, 2);
834
- /**
835
- * Validates a single-byte hexadecimal number (1 byte / 2 characters).
836
- *
837
- * Reference: ST_UcharHexNumber in OOXML specification
838
- *
839
- * @param val - The hexadecimal string to validate
840
- * @returns The validated hexadecimal string
841
- * @throws Error if the value is not a valid 2-character hex string
842
- *
843
- * @example
844
- * ```typescript
845
- * const hex = uCharHexNumber("FF"); // Valid
846
- * ```
847
- */
848
- const uCharHexNumber = (val) => hexBinary(val, 1);
849
- /**
850
- * Normalizes a universal measure value by parsing and reformatting.
851
- *
852
- * Ensures the numeric portion is properly formatted while preserving the unit.
853
- *
854
- * Reference: ST_UniversalMeasure in OOXML specification
855
- *
856
- * @param val - The universal measure string to normalize
857
- * @returns The normalized universal measure
858
- *
859
- * @example
860
- * ```typescript
861
- * const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
862
- * ```
863
- */
864
- const universalMeasureValue = (val) => {
865
- const unit = val.slice(-2);
866
- const amount = val.substring(0, val.length - 2);
867
- return `${Number(amount)}${unit}`;
868
- };
869
- /**
870
- * Validates and normalizes a positive universal measure value.
871
- *
872
- * Reference: ST_PositiveUniversalMeasure in OOXML specification
873
- *
874
- * @param val - The positive universal measure string to validate
875
- * @returns The normalized positive universal measure
876
- * @throws Error if the value is negative
877
- *
878
- * @example
879
- * ```typescript
880
- * const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
881
- * const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
882
- * ```
883
- */
884
- const positiveUniversalMeasureValue = (val) => {
885
- const value = universalMeasureValue(val);
886
- if (parseFloat(value) < 0) throw new Error(`Invalid value '${value}' specified. Expected a positive number.`);
887
- return value;
888
- };
889
- /**
890
- * Validates and normalizes a hexadecimal color value.
891
- *
892
- * Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
893
- * The # prefix is commonly used but technically invalid in OOXML, so it is stripped
894
- * for strict compliance.
895
- *
896
- * Reference: ST_HexColor in OOXML specification
897
- *
898
- * @param val - The color value to validate ("auto" or hex color)
899
- * @returns The normalized color value
900
- * @throws Error if the hex color is invalid
901
- *
902
- * @example
903
- * ```typescript
904
- * const color1 = hexColorValue("auto"); // Returns "auto"
905
- * const color2 = hexColorValue("FF0000"); // Returns "FF0000"
906
- * const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
907
- * ```
908
- */
909
- const hexColorValue = (val) => {
910
- if (val === "auto") return val;
911
- return hexBinary(val.charAt(0) === "#" ? val.substring(1) : val, 3);
912
- };
913
- /**
914
- * Validates a signed TWIP measurement value.
915
- *
916
- * Accepts either a universal measure string or a numeric TWIP value.
917
- *
918
- * Reference: ST_SignedTwipsMeasure in OOXML specification
919
- *
920
- * @param val - The measurement value (universal measure or number)
921
- * @returns The normalized measurement value
922
- *
923
- * @example
924
- * ```typescript
925
- * const measure1 = signedTwipsMeasureValue("10mm");
926
- * const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
927
- * ```
928
- */
929
- const signedTwipsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
930
- /**
931
- * Validates a half-point (HPS) measurement value.
932
- *
933
- * Accepts either a positive universal measure string or a positive number.
934
- * HPS (half-points) are commonly used for font sizes.
935
- *
936
- * Reference: ST_HpsMeasure in OOXML specification
937
- *
938
- * @param val - The measurement value (positive universal measure or number)
939
- * @returns The normalized measurement value
940
- *
941
- * @example
942
- * ```typescript
943
- * const fontSize1 = hpsMeasureValue("12pt");
944
- * const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
945
- * ```
946
- */
947
- const hpsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
948
- /**
949
- * Validates a signed half-point (HPS) measurement value.
950
- *
951
- * Accepts either a universal measure string or a numeric value.
952
- *
953
- * Reference: ST_SignedHpsMeasure in OOXML specification
954
- *
955
- * @param val - The measurement value (universal measure or number)
956
- * @returns The normalized measurement value
957
- *
958
- * @example
959
- * ```typescript
960
- * const spacing1 = signedHpsMeasureValue("6pt");
961
- * const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
962
- * ```
963
- */
964
- const signedHpsMeasureValue = (val) => typeof val === "string" ? universalMeasureValue(val) : decimalNumber(val);
965
- /**
966
- * Validates a positive TWIP measurement value.
967
- *
968
- * Accepts either a positive universal measure string or a positive number.
969
- *
970
- * Reference: ST_TwipsMeasure in OOXML specification
971
- *
972
- * @param val - The measurement value (positive universal measure or number)
973
- * @returns The normalized measurement value
974
- *
975
- * @example
976
- * ```typescript
977
- * const width1 = twipsMeasureValue("25.4mm");
978
- * const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
979
- * ```
980
- */
981
- const twipsMeasureValue = (val) => typeof val === "string" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);
982
- /**
983
- * Normalizes a percentage value by parsing and reformatting.
984
- *
985
- * Reference: ST_Percentage in OOXML specification
986
- *
987
- * @param val - The percentage string to normalize
988
- * @returns The normalized percentage
989
- *
990
- * @example
991
- * ```typescript
992
- * const percent = percentageValue("50.000%"); // Returns "50%"
993
- * ```
994
- */
995
- const percentageValue = (val) => {
996
- const percent = val.substring(0, val.length - 1);
997
- return `${Number(percent)}%`;
998
- };
999
- /**
1000
- * Validates a measurement value that can be expressed as a number, percentage, or universal measure.
1001
- *
1002
- * Reference: ST_MeasurementOrPercent in OOXML specification
1003
- *
1004
- * @param val - The measurement value (number, percentage, or universal measure)
1005
- * @returns The normalized measurement value
1006
- *
1007
- * @example
1008
- * ```typescript
1009
- * const measure1 = measurementOrPercentValue(100); // Unqualified number
1010
- * const measure2 = measurementOrPercentValue("50%"); // Percentage
1011
- * const measure3 = measurementOrPercentValue("10mm"); // Universal measure
1012
- * ```
1013
- */
1014
- const measurementOrPercentValue = (val) => {
1015
- if (typeof val === "number") return decimalNumber(val);
1016
- if (val.slice(-1) === "%") return percentageValue(val);
1017
- return universalMeasureValue(val);
1018
- };
1019
- /**
1020
- * Validates an eighth-point measurement value.
1021
- *
1022
- * Eighth-points are used for fine-grained measurements in text formatting.
1023
- *
1024
- * Reference: ST_EighthPointMeasure in OOXML specification
1025
- *
1026
- * @param val - The measurement value in eighth-points
1027
- * @returns The validated positive integer value
1028
- *
1029
- * @example
1030
- * ```typescript
1031
- * const measure = eighthPointMeasureValue(16); // 2 points
1032
- * ```
1033
- */
1034
- const eighthPointMeasureValue = unsignedDecimalNumber;
1035
- /**
1036
- * Validates a point measurement value.
1037
- *
1038
- * Reference: ST_PointMeasure in OOXML specification
1039
- *
1040
- * @param val - The measurement value in points
1041
- * @returns The validated positive integer value
1042
- *
1043
- * @example
1044
- * ```typescript
1045
- * const fontSize = pointMeasureValue(12); // 12pt
1046
- * ```
1047
- */
1048
- const pointMeasureValue = unsignedDecimalNumber;
1049
- /**
1050
- * Converts a JavaScript Date object to an ISO 8601 date-time string.
1051
- *
1052
- * The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
1053
- * This matches the xsd:dateTime format required by OOXML.
1054
- *
1055
- * Reference: ST_DateTime in OOXML specification
1056
- *
1057
- * @param val - The Date object to convert
1058
- * @returns An ISO 8601 formatted date-time string
1059
- *
1060
- * @example
1061
- * ```typescript
1062
- * const now = new Date();
1063
- * const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
1064
- * ```
1065
- */
1066
- const dateTimeValue = (val) => val.toISOString();
1067
- /**
1068
- * Theme color values used throughout OOXML for referencing document theme colors.
1069
- *
1070
- * Reference: ST_ThemeColor in OOXML specification
1071
- *
1072
- * @publicApi
1073
- */
1074
- const ThemeColor = {
1075
- DARK1: "dark1",
1076
- LIGHT1: "light1",
1077
- DARK2: "dark2",
1078
- LIGHT2: "light2",
1079
- ACCENT1: "accent1",
1080
- ACCENT2: "accent2",
1081
- ACCENT3: "accent3",
1082
- ACCENT4: "accent4",
1083
- ACCENT5: "accent5",
1084
- ACCENT6: "accent6",
1085
- HYPERLINK: "hyperlink",
1086
- FOLLOWED_HYPERLINK: "followedHyperlink",
1087
- NONE: "none",
1088
- BACKGROUND1: "background1",
1089
- TEXT1: "text1",
1090
- BACKGROUND2: "background2",
1091
- TEXT2: "text2"
1092
- };
1093
- /**
1094
- * Theme font values used for referencing document theme fonts.
1095
- *
1096
- * Reference: ST_Theme in OOXML specification
1097
- *
1098
- * @publicApi
1099
- */
1100
- const ThemeFont = {
1101
- MAJOR_EAST_ASIA: "majorEastAsia",
1102
- MAJOR_BIDI: "majorBidi",
1103
- MAJOR_ASCII: "majorAscii",
1104
- MAJOR_H_ANSI: "majorHAnsi",
1105
- MINOR_EAST_ASIA: "minorEastAsia",
1106
- MINOR_BIDI: "minorBidi",
1107
- MINOR_ASCII: "minorAscii",
1108
- MINOR_H_ANSI: "minorHAnsi"
1109
- };
1110
- //#endregion
1111
- export { convertOutput as $, replaceChartPlaceholders as A, compileMapping as B, findAndReplaceImagePlaceholders as C, getVideoRefs as D, getReferencedMedia as E, replaceSmartArtPlaceholders as F, levelForMediaName as G, ZIP_STORED_LEVEL as H, replaceVideoPlaceholders as I, zipAndConvert as J, strFromU8$1 as K, derivePasswordHash as L, replaceImagePlaceholders as M, replaceMediaPlaceholders as N, hasPlaceholders as O, replaceNumberingPlaceholders as P, OoxmlMimeType as Q, hashPasswordAgile as R, collectPlaceholderKeys as S, getMediaRefs as T, createPacker as U, ZIP_DEFLATE_LEVEL as V, createZipStream as W, hasNativeInflate as X, zipSyncAndConvert as Y, nativeUnzip as Z, twipsMeasureValue as _, eighthPointMeasureValue as a, unsignedDecimalNumber as b, hpsMeasureValue as c, percentageValue as d, pointMeasureValue as f, signedTwipsMeasureValue as g, signedHpsMeasureValue as h, decimalNumber as i, replaceHyperlinkPlaceholders as j, replaceAllPlaceholders as k, longHexNumber as l, shortHexNumber as m, ThemeFont as n, hexBinary as o, positiveUniversalMeasureValue as p, unzipSync$1 as q, dateTimeValue as r, hexColorValue as s, ThemeColor as t, measurementOrPercentValue as u, uCharHexNumber as v, formatId as w, addSmartArtRelationships as x, universalMeasureValue as y, randomBytes as z };
857
+ export { createZipStream as A, nativeCrc32 as B, randomBytes as C, ZIP_STORED_LEVEL as D, ZIP_DEFLATE_LEVEL as E, zipSync$1 as F, zipSyncAndConvert as I, OoxmlMimeType as L, strFromU8$1 as M, unzipSync$1 as N, ZipStreamWriter as O, zipAndConvert as P, convertOutput as R, hashPasswordAgile as S, compileMapping as T, nativeUnzip as V, replaceNumberingPlaceholders as _, getAudioRefs as a, replaceVideoPlaceholders as b, getReferencedMedia as c, replaceAllPlaceholders as d, replaceAudioPlaceholders as f, replaceMediaPlaceholders as g, replaceImagePlaceholders as h, formatId as i, levelForMediaName as j, createPacker as k, getVideoRefs as l, replaceHyperlinkPlaceholders as m, collectPlaceholderKeys as n, getMediaRefs as o, replaceChartPlaceholders as p, findAndReplaceImagePlaceholders as r, getOleRefs as s, addSmartArtRelationships as t, hasPlaceholders as u, replaceOlePlaceholders as v, addBinaryFile as w, derivePasswordHash as x, replaceSmartArtPlaceholders as y, hasNativeInflate as z };
1112
858
 
1113
- //# sourceMappingURL=util-Tq9PSjK0.mjs.map
859
+ //# sourceMappingURL=util-C94-JKtp.mjs.map