@office-open/core 0.10.12 → 0.10.13
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 +10 -9
- package/dist/chart/index.d.mts +1 -1
- package/dist/chart/index.mjs +1 -1
- package/dist/{chart-DwE8FCFk.mjs → chart-DOO1st0K.mjs} +3 -1
- package/dist/chart-DOO1st0K.mjs.map +1 -0
- package/dist/converters-C_Y2QX1w.mjs +1789 -0
- package/dist/converters-C_Y2QX1w.mjs.map +1 -0
- package/dist/data-type-CZMKVaaT.d.mts +10 -0
- package/dist/data-type-CZMKVaaT.d.mts.map +1 -0
- package/dist/descriptor/index.d.mts +2 -2
- package/dist/descriptor/index.mjs +2 -2
- package/dist/{descriptor-DAER86Rt.mjs → descriptor-BjNkn5jo.mjs} +3 -33
- package/dist/descriptor-BjNkn5jo.mjs.map +1 -0
- package/dist/drawingml/index.d.mts +2 -2
- package/dist/drawingml/index.mjs +2 -2
- package/dist/{src-bVqU5Bh3.mjs → drawingml-sj1J3lb0.mjs} +22 -3728
- package/dist/drawingml-sj1J3lb0.mjs.map +1 -0
- package/dist/index-BVK2dv6C.d.mts +63 -0
- package/dist/index-BVK2dv6C.d.mts.map +1 -0
- package/dist/index-BfHfKuKy.d.mts +275 -0
- package/dist/index-BfHfKuKy.d.mts.map +1 -0
- package/dist/index-CE53SwpZ.d.mts +1463 -0
- package/dist/index-CE53SwpZ.d.mts.map +1 -0
- package/dist/{index-3STznXzZ.d.mts → index-D6VE-MnJ.d.mts} +3 -15
- package/dist/index-D6VE-MnJ.d.mts.map +1 -0
- package/dist/{index-CN0YjNSx.d.mts → index-DDyd2ErZ.d.mts} +3 -15
- package/dist/index-DDyd2ErZ.d.mts.map +1 -0
- package/dist/{index-CsQP7Cl4.d.mts → index-DlPA26cw.d.mts} +2 -47
- package/dist/index-DlPA26cw.d.mts.map +1 -0
- package/dist/index-k8WKLXnA.d.mts +150 -0
- package/dist/index-k8WKLXnA.d.mts.map +1 -0
- package/dist/index.d.mts +650 -8
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1271 -7
- package/dist/index.mjs.map +1 -0
- package/dist/output-D_G_JR_8.d.mts +24 -0
- package/dist/output-D_G_JR_8.d.mts.map +1 -0
- package/dist/patch/index.d.mts +2 -2
- package/dist/patch/index.mjs +1 -1
- package/dist/{patch-OSbQIQAi.mjs → patch-BmRfghOo.mjs} +65 -84
- package/dist/patch-BmRfghOo.mjs.map +1 -0
- package/dist/smartart/index.d.mts +1 -1
- package/dist/smartart/index.mjs +1 -1
- package/dist/{smartart-DCY-Vdv7.mjs → smartart-B7ukZ-Tw.mjs} +5 -3
- package/dist/smartart-B7ukZ-Tw.mjs.map +1 -0
- package/dist/theme/index.d.mts +1 -1
- package/dist/theme-CiNzdl-9.mjs +2 -0
- package/dist/theme-CiNzdl-9.mjs.map +1 -0
- package/dist/util/index.d.mts +4 -0
- package/dist/util/index.mjs +3 -0
- package/dist/util-Tq9PSjK0.mjs +1113 -0
- package/dist/util-Tq9PSjK0.mjs.map +1 -0
- package/dist/values-8di32lIe.d.mts +56 -0
- package/dist/values-8di32lIe.d.mts.map +1 -0
- package/package.json +7 -6
- package/dist/index-CHGFwCCQ.d.mts +0 -266
- package/dist/index-CpNwAcem.d.mts +0 -169
- package/dist/index-DdXU1_sq.d.mts +0 -5029
- package/dist/util/values.d.mts +0 -2
- package/dist/util/values.mjs +0 -2
- package/dist/values-CVIZcTRw.mjs +0 -371
- package/dist/values-DQfI1FSg.d.mts +0 -426
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util-Tq9PSjK0.mjs","names":[],"sources":["../src/opc/output.ts","../src/opc/zip-native.ts","../src/opc/packer.ts","../src/util/compile.ts","../src/util/crypto.ts","../src/util/placeholder.ts","../src/util/values.ts"],"sourcesContent":["/**\n * Output type definitions for OOXML document export.\n *\n * @module\n */\n\nimport { strFromU8 } from \"fflate\";\n\nimport { encodeBase64 } from \"../util/base64\";\n\nexport interface OutputByType {\n base64: string;\n string: string;\n text: string;\n binarystring: string;\n array: readonly number[];\n uint8array: Uint8Array;\n arraybuffer: ArrayBuffer;\n blob: Blob;\n nodebuffer: Buffer;\n}\n\nexport type OutputType = keyof OutputByType;\n\n/* V8 ignore start */\nexport const OoxmlMimeType = {\n DOCX: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n PPTX: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n XLSX: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n} as const;\n\nexport const convertOutput = <T extends OutputType>(\n data: Uint8Array,\n type: T,\n mimeType: string = OoxmlMimeType.DOCX,\n): OutputByType[T] => {\n switch (type) {\n case \"nodebuffer\":\n // Zero-copy: wrap the zip output's underlying ArrayBuffer as a Buffer\n // view instead of copying it (~11MB for an image-heavy file) on every\n // generate(). Safe because the source buffer is freshly allocated and\n // never mutated after this point.\n return Buffer.from(data.buffer, data.byteOffset, data.byteLength) as OutputByType[T];\n case \"blob\":\n return new Blob(\n [(data.buffer as ArrayBuffer).slice(data.byteOffset, data.byteOffset + data.byteLength)],\n { type: mimeType },\n ) as OutputByType[T];\n case \"arraybuffer\":\n return data.buffer.slice(\n data.byteOffset,\n data.byteOffset + data.byteLength,\n ) as OutputByType[T];\n case \"uint8array\":\n return data as OutputByType[T];\n case \"base64\":\n return encodeBase64(data) as OutputByType[T];\n case \"string\":\n case \"text\":\n case \"binarystring\":\n return strFromU8(data, true) as OutputByType[T];\n case \"array\":\n return [...data] as unknown as OutputByType[T];\n /* V8 ignore next */\n default:\n return data as unknown as OutputByType[T];\n }\n};\n/* V8 ignore stop */\n","/**\n * Native ZIP reader/writer with automatic fallback to fflate.\n *\n * `node:zlib` resolves in Node and Bun (via its Node compat layer), giving\n * `deflateRawSync` / `inflateRawSync` for DEFLATE/INFLATE and `zlib.crc32`\n * for CRC-32 — ~2-3x faster than fflate's pure-JS implementation. Browsers\n * and Deno lack a resolvable `node:zlib`, so the dynamic import rejects and\n * packer.ts falls back to fflate. We probe via the import itself rather than\n * `process.versions.node`: core's `shims: true` swaps `process` for a browser\n * stub that drops `versions.node`, which would silently disable native zlib\n * in any package consuming core's polyfilled build.\n *\n * @module\n */\n\nimport type { Zippable, ZipOptions } from \"fflate\";\n\n// ── CRC-32 lookup table ──\n\nconst CRC_TABLE = new Int32Array(256);\nfor (let i = 0; i < 256; i++) {\n let c = i;\n for (let k = 0; k < 8; k++) c = c & 1 ? (c >>> 1) ^ -306674912 : c >>> 1;\n CRC_TABLE[i] = c;\n}\n\nfunction computeCrc32(data: Uint8Array): number {\n let crc = -1;\n // CRC_TABLE is a fixed 256-entry lookup; the index is masked to [0,255], so the\n // access is guaranteed in-bounds — the `!` is a compile-time narrow, not a runtime check.\n for (const byte of data) {\n crc = CRC_TABLE[(crc ^ byte) & 0xff]! ^ (crc >>> 8);\n }\n return ~crc;\n}\n\n// ── Native zlib detection (Node.js ESM) ──\n\ntype DeflateFn = (data: Uint8Array, level: number) => Uint8Array;\ntype AsyncDeflateFn = (data: Uint8Array, level: number) => Promise<Uint8Array>;\ntype InflateFn = (data: Uint8Array) => Uint8Array;\ntype Crc32Fn = (data: Uint8Array) => number;\n\nlet _nativeDeflate: DeflateFn | undefined;\nlet _nativeDeflateAsync: AsyncDeflateFn | undefined;\nlet _nativeInflate: InflateFn | undefined;\nlet _nativeCrc32: Crc32Fn | undefined;\n\n// `node:zlib` resolves in Node and Bun (via its Node compat layer); in\n// browsers and Deno the dynamic import rejects, so we fall back to fflate.\n// The import itself is the probe — do NOT gate on `process.versions.node`:\n// core's `shims: true` swaps `process` for a browser stub that drops\n// `versions.node`, which would silently disable native zlib in any package\n// that consumes core's polyfilled build.\ntry {\n // top-level await — ESM standard. Resolves to zlib with deflateRawSync;\n // rejects (or yields a stub without it) on incomplete polyfills.\n const zlib = await import(\"node:zlib\");\n if (typeof zlib.deflateRawSync !== \"function\") throw new Error(\"no native deflate\");\n _nativeDeflate = (data: Uint8Array, level: number): Uint8Array =>\n zlib.deflateRawSync(data, { level });\n _nativeDeflateAsync = (data: Uint8Array, level: number): Promise<Uint8Array> =>\n new Promise<Uint8Array>((resolve, reject) =>\n zlib.deflateRaw(data, { level }, (err, result) => {\n if (err) reject(err);\n else resolve(result);\n }),\n );\n _nativeCrc32 =\n typeof zlib.crc32 === \"function\" ? (data: Uint8Array) => zlib.crc32(data) : computeCrc32;\n // Inflate is optional (deflate presence doesn't guarantee it), so probe\n // separately — nativeUnzip only becomes available when this resolves.\n if (typeof zlib.inflateRawSync === \"function\") {\n _nativeInflate = (data: Uint8Array): Uint8Array => zlib.inflateRawSync(data);\n }\n} catch {\n // Browser/Deno or Node-like runtime without usable zlib — fflate fallback\n}\n\nexport const hasNativeDeflate = (): boolean => _nativeDeflate !== undefined;\n\nexport const hasNativeInflate = (): boolean => _nativeInflate !== undefined;\n\n// ── LE write helpers ──\n\nfunction wU16(b: Uint8Array, o: number, v: number): void {\n b[o] = v & 0xff;\n b[o + 1] = (v >> 8) & 0xff;\n}\n\nfunction wU32(b: Uint8Array, o: number, v: number): void {\n b[o] = v & 0xff;\n b[o + 1] = (v >> 8) & 0xff;\n b[o + 2] = (v >> 16) & 0xff;\n b[o + 3] = (v >> 24) & 0xff;\n}\n\n// ── Per-entry metadata ──\n\ninterface Entry {\n filename: Uint8Array;\n data: Uint8Array;\n uncompressedSize: number;\n crc: number;\n method: number; // 0 = STORE, 8 = DEFLATE\n localOffset: number;\n}\n\n// ── Phase 1 helpers ──\n\nfunction resolveEntryData(\n raw: Zippable[string],\n defaultLevel: number,\n): { data: Uint8Array; level: number } {\n if (Array.isArray(raw)) {\n return { data: raw[0] as Uint8Array, level: (raw[1] as ZipOptions).level ?? defaultLevel };\n }\n return { data: raw as Uint8Array, level: defaultLevel };\n}\n\nfunction compressOne(\n data: Uint8Array,\n level: number,\n deflate: DeflateFn,\n): { compressed: Uint8Array; method: number } {\n if (level === 0) return { compressed: data, method: 0 };\n const compressed = deflate(data, level);\n if (compressed.length >= data.length) return { compressed: data, method: 0 };\n return { compressed, method: 8 };\n}\n\nasync function compressOneAsync(\n data: Uint8Array,\n level: number,\n deflate: AsyncDeflateFn,\n): Promise<{ compressed: Uint8Array; method: number }> {\n if (level === 0) return { compressed: data, method: 0 };\n const compressed = await deflate(data, level);\n if (compressed.length >= data.length) return { compressed: data, method: 0 };\n return { compressed, method: 8 };\n}\n\n// ── Phase 2+3: calculate sizes + write ZIP buffer ──\n\nfunction writeZipBuffer(entries: Entry[]): Uint8Array {\n let totalSize = 0;\n for (const e of entries) {\n totalSize += 30 + e.filename.length + e.data.length;\n }\n const cdOffset = totalSize;\n let cdSize = 0;\n for (const e of entries) {\n cdSize += 46 + e.filename.length;\n }\n totalSize += cdSize + 22;\n\n const buf = new Uint8Array(totalSize);\n let offset = 0;\n\n // Local file headers + data\n for (const e of entries) {\n e.localOffset = offset;\n wU32(buf, offset, 0x04034b50); // signature\n wU16(buf, offset + 4, 20); // version needed\n wU16(buf, offset + 6, 0); // flags\n wU16(buf, offset + 8, e.method); // compression method\n wU16(buf, offset + 10, 0); // mod time\n wU16(buf, offset + 12, 0); // mod date\n wU32(buf, offset + 14, e.crc);\n wU32(buf, offset + 18, e.data.length); // compressed size\n wU32(buf, offset + 22, e.uncompressedSize);\n wU16(buf, offset + 26, e.filename.length);\n wU16(buf, offset + 28, 0); // extra field length\n offset += 30;\n\n buf.set(e.filename, offset);\n offset += e.filename.length;\n\n buf.set(e.data, offset);\n offset += e.data.length;\n }\n\n // Central directory\n for (const e of entries) {\n wU32(buf, offset, 0x02014b50); // signature\n wU16(buf, offset + 4, 20); // version made by\n wU16(buf, offset + 6, 20); // version needed\n wU16(buf, offset + 8, 0); // flags\n wU16(buf, offset + 10, e.method);\n wU16(buf, offset + 12, 0); // mod time\n wU16(buf, offset + 14, 0); // mod date\n wU32(buf, offset + 16, e.crc);\n wU32(buf, offset + 20, e.data.length);\n wU32(buf, offset + 24, e.uncompressedSize);\n wU16(buf, offset + 28, e.filename.length);\n wU16(buf, offset + 30, 0); // extra field length\n wU16(buf, offset + 32, 0); // comment length\n wU16(buf, offset + 34, 0); // disk number start\n wU16(buf, offset + 36, 0); // internal attrs\n wU32(buf, offset + 38, 0); // external attrs\n wU32(buf, offset + 42, e.localOffset);\n offset += 46;\n\n buf.set(e.filename, offset);\n offset += e.filename.length;\n }\n\n // End of Central Directory Record\n wU32(buf, offset, 0x06054b50);\n wU16(buf, offset + 4, 0); // disk number\n wU16(buf, offset + 6, 0); // CD disk\n wU16(buf, offset + 8, entries.length);\n wU16(buf, offset + 10, entries.length);\n wU32(buf, offset + 12, cdSize);\n wU32(buf, offset + 16, cdOffset);\n wU16(buf, offset + 20, 0); // comment length\n\n return buf;\n}\n\n// ── Public API ──\n\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\nexport function nativeZip(files: Zippable, level: number = 6): Uint8Array {\n if (!_nativeDeflate) throw new Error(\"Native deflate not available\");\n const crc = _nativeCrc32 ?? computeCrc32;\n const entries: Entry[] = [];\n\n for (const key of Object.keys(files)) {\n const raw = files[key];\n if (raw === undefined) continue; // Object.keys guarantees presence; guard narrows the type\n const { data, level: entryLevel } = resolveEntryData(raw, level);\n const c = crc(data);\n const { compressed, method } = compressOne(data, entryLevel, _nativeDeflate);\n entries.push({\n filename: textEncoder.encode(key),\n data: compressed,\n uncompressedSize: data.length,\n crc: c,\n method,\n localOffset: 0,\n });\n }\n\n return writeZipBuffer(entries);\n}\n\nexport async function nativeZipAsync(files: Zippable, level: number = 6): Promise<Uint8Array> {\n if (!_nativeDeflateAsync) throw new Error(\"Native async deflate not available\");\n const crc = _nativeCrc32 ?? computeCrc32;\n const entries: Entry[] = [];\n\n for (const key of Object.keys(files)) {\n const raw = files[key];\n if (raw === undefined) continue; // Object.keys guarantees presence; guard narrows the type\n const { data, level: entryLevel } = resolveEntryData(raw, level);\n const c = crc(data);\n const { compressed, method } = await compressOneAsync(data, entryLevel, _nativeDeflateAsync);\n entries.push({\n filename: textEncoder.encode(key),\n data: compressed,\n uncompressedSize: data.length,\n crc: c,\n method,\n localOffset: 0,\n });\n }\n\n return writeZipBuffer(entries);\n}\n\n// ── LE read helpers (ZIP parsing) ──\n\nfunction rU16(b: Uint8Array, o: number): number {\n return b[o]! | (b[o + 1]! << 8);\n}\n\nfunction rU32(b: Uint8Array, o: number): number {\n return (b[o]! | (b[o + 1]! << 8) | (b[o + 2]! << 16) | (b[o + 3]! << 24)) >>> 0;\n}\n\n// ── ZIP central-directory parsing ──\n\nconst EOCD_MAGIC = 0x06054b50;\nconst CD_MAGIC = 0x02014b50;\n\ninterface ZipEntryMeta {\n name: string;\n method: number;\n compSize: number;\n crc: number;\n dataStart: number;\n}\n\n/** Locate the End-of-Central-Directory record (within a 64 KB comment window). */\nfunction findEocd(b: Uint8Array): number {\n const min = Math.max(0, b.length - 65557); // 22-byte EOCD + up to 65535-byte comment\n for (let i = b.length - 22; i >= min; i--) {\n if (rU32(b, i) === EOCD_MAGIC) return i;\n }\n throw new Error(\"ZIP EOCD record not found\");\n}\n\n/** Walk the central directory and resolve each entry's payload offset. */\nfunction readCentralDirectory(buf: Uint8Array): ZipEntryMeta[] {\n const eocd = findEocd(buf);\n const count = rU16(buf, eocd + 10);\n const cdOffset = rU32(buf, eocd + 16);\n const entries: ZipEntryMeta[] = [];\n let p = cdOffset;\n for (let i = 0; i < count; i++) {\n if (rU32(buf, p) !== CD_MAGIC) throw new Error(`ZIP central directory corrupt at offset ${p}`);\n const method = rU16(buf, p + 10);\n const crc = rU32(buf, p + 16);\n const compSize = rU32(buf, p + 20);\n const nameLen = rU16(buf, p + 28);\n const extraLen = rU16(buf, p + 30);\n const cmtLen = rU16(buf, p + 32);\n const localOff = rU32(buf, p + 42);\n // Uint8Array.toString() yields \"120,46,...\" (comma-joined bytes), not the\n // UTF-8 string — decode explicitly so entry names are real paths.\n const name = textDecoder.decode(buf.subarray(p + 46, p + 46 + nameLen));\n // The local header carries its own name/extra lengths, which can differ\n // from the CD's; read them to locate the entry's payload precisely.\n const lNameLen = rU16(buf, localOff + 26);\n const lExtraLen = rU16(buf, localOff + 28);\n entries.push({\n name,\n method,\n compSize,\n crc,\n dataStart: localOff + 30 + lNameLen + lExtraLen,\n });\n p += 46 + nameLen + extraLen + cmtLen;\n }\n return entries;\n}\n\n/**\n * Decompress a ZIP archive via `node:zlib` `inflateRawSync`, mirroring fflate's\n * `unzipSync` signature and CRC-32 integrity check. Node/Bun only — callers\n * gate on {@link hasNativeInflate} and fall back to fflate `unzipSync` elsewhere.\n * Measured ~2x faster than fflate on large OOXML packages.\n */\nexport function nativeUnzip(buf: Uint8Array): Record<string, Uint8Array> {\n if (!_nativeInflate) throw new Error(\"Native inflate not available\");\n const inflate = _nativeInflate;\n const crc = _nativeCrc32 ?? computeCrc32;\n const out: Record<string, Uint8Array> = {};\n for (const e of readCentralDirectory(buf)) {\n const raw = buf.subarray(e.dataStart, e.dataStart + e.compSize);\n const dec = e.method === 0 ? raw.slice() : inflate(raw);\n // >>> 0 normalizes the signed CRC_TABLE accumulation against zlib's unsigned crc32.\n if (crc(dec) >>> 0 !== e.crc) throw new Error(`ZIP CRC-32 mismatch: ${e.name}`);\n out[e.name] = dec;\n }\n return out;\n}\n","/**\n * Shared packer utilities for OOXML document generation.\n *\n * @module\n */\n\nimport {\n type AsyncZippable,\n type ZipOptions,\n type Zippable,\n AsyncZipDeflate,\n Zip,\n ZipPassThrough,\n zip,\n zipSync,\n} from \"fflate\";\n\nimport { convertOutput } from \"./output\";\nimport type { OutputByType, OutputType } from \"./output\";\nimport { hasNativeDeflate, nativeZip, nativeZipAsync } from \"./zip-native\";\n\nexport type { Zippable, ZipOptions } from \"fflate\";\nexport { strFromU8, unzipSync } from \"fflate\";\n\nexport interface XmlifyedFile {\n path: string;\n data: string | Uint8Array;\n}\n\n/** Default DEFLATE level for XML entries (SuperFast, matching MS Office). */\nexport const ZIP_DEFLATE_LEVEL = 1;\n\n/** Default DEFLATE level for compressible media (EMF/WMF/BMP/TIFF/SVG). MS\n * Office uses CompressionOption.Normal (~zlib 6); SuperFast (1) inflates EMF\n * output ~15% (measured against a real Office-generated package). */\nexport const ZIP_MEDIA_LEVEL = 6;\n\n/** Level for already-compressed media — STORE (no compression). */\nexport const ZIP_STORED_LEVEL = 0;\n\n/**\n * Media formats already compressed internally (DEFLATE for PNG, DCT for JPEG,\n * LZW for GIF). Re-compressing via zip DEFLATE wastes CPU and often inflates\n * the data, so MS Office STORE-s these (CompressionOption.NotCompressed → zip\n * method 0). Everything else (EMF/WMF/BMP/TIFF/SVG/…) is compressible → DEFLATE.\n */\nconst PRECOMPRESSED_MEDIA_EXT = new Set([\"jpg\", \"jpeg\", \"png\", \"gif\"]);\n\n/**\n * Resolve the ZIP level for a media entry by file-name extension, matching MS\n * Office: already-compressed raster formats → STORE (0), everything else →\n * DEFLATE (`mediaLevel`, default Normal). A `compression.media` override\n * therefore applies only to compressible formats, never forcing DEFLATE onto\n * pre-compressed assets.\n */\nexport const levelForMediaName = (fileName: string, mediaLevel: number): number => {\n const dot = fileName.lastIndexOf(\".\");\n const ext = dot < 0 ? \"\" : fileName.slice(dot + 1).toLowerCase();\n return PRECOMPRESSED_MEDIA_EXT.has(ext) ? ZIP_STORED_LEVEL : mediaLevel;\n};\n\n/** Compression options for ZIP output (zlib levels 0-9, matching fflate). */\nexport interface CompressionOptions {\n /** DEFLATE level for XML files. Default: 1 (SuperFast, matching MS Office). */\n xml?: number;\n /**\n * DEFLATE level for compressible media (EMF/WMF/BMP/TIFF/…). Already-compressed\n * formats (PNG/JPEG/GIF) are always STOREd regardless, matching MS Office.\n * Default: 6 (Normal, matching MS Office for EMF/WMF).\n */\n media?: number;\n}\n\n/** Options for Packer output methods. */\nexport interface PackerOptions<T extends OutputType = \"nodebuffer\"> {\n /** Output format. Defaults to `\"nodebuffer\"` (Node.js Buffer). */\n type?: T;\n /** Custom XML/ZIP file overrides. */\n overrides?: XmlifyedFile[];\n /** Compression levels for ZIP entries. */\n compression?: CompressionOptions;\n}\n\n/**\n * Asynchronously compress files and convert to the requested output format.\n *\n * Uses fflate Web Workers for non-blocking DEFLATE compression.\n * XML entries use DEFLATE level 1 (SuperFast) by default. Media entries are\n * split by type, matching MS Office: already-compressed formats (PNG/JPEG/GIF)\n * are STOREd, everything else uses the `media` level (default Normal).\n * Set `{ media: ZIP_STORED_LEVEL }` to STORE all compressible media too.\n */\nexport const zipAndConvert = async <T extends OutputType>(\n files: Zippable,\n type: T,\n mimeType: string,\n level: number = ZIP_DEFLATE_LEVEL,\n): Promise<OutputByType[T]> => {\n const zipped = hasNativeDeflate()\n ? await nativeZipAsync(files, level)\n : await new Promise<Uint8Array>((resolve, reject) => {\n zip(\n files as AsyncZippable,\n { level: level as ZipOptions[\"level\"], consume: true },\n (err, data) => {\n if (err) reject(err);\n else resolve(data);\n },\n );\n });\n return convertOutput(zipped, type, mimeType);\n};\n\n/**\n * Synchronously compress files and convert to the requested output format.\n *\n * Uses synchronous DEFLATE compression for maximum throughput.\n * Blocks the event loop — prefer {@link zipAndConvert} in server contexts.\n */\nexport const zipSyncAndConvert = <T extends OutputType>(\n files: Zippable,\n type: T,\n mimeType: string,\n level: number = ZIP_DEFLATE_LEVEL,\n): OutputByType[T] => {\n const zipped = hasNativeDeflate()\n ? nativeZip(files, level)\n : zipSync(files, { level: level as ZipOptions[\"level\"] });\n return convertOutput(zipped, type, mimeType);\n};\n\n/**\n * Create a `ReadableStream<Uint8Array>` from compressed file entries.\n *\n * Uses fflate's `AsyncZipDeflate` for non-blocking DEFLATE compression.\n * `STORED` entries (media) pass through synchronously.\n * Works in both Node.js and browsers (Web Streams API).\n */\nexport const createZipStream = (\n files: Zippable,\n defaultLevel: number = ZIP_DEFLATE_LEVEL,\n): ReadableStream<Uint8Array> => {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n try {\n const zip = new Zip((err, chunk, _final) => {\n if (err) {\n controller.error(err);\n return;\n }\n controller.enqueue(chunk);\n if (_final) {\n controller.close();\n }\n });\n\n for (const [name, data] of Object.entries(files)) {\n const raw = Array.isArray(data) ? (data[0] as Uint8Array) : (data as Uint8Array);\n const level = Array.isArray(data)\n ? ((data[1] as ZipOptions).level ?? defaultLevel)\n : defaultLevel;\n const entry =\n level === ZIP_STORED_LEVEL\n ? new ZipPassThrough(name)\n : new AsyncZipDeflate(name, { level: level as ZipOptions[\"level\"] });\n zip.add(entry);\n entry.push(raw, true);\n }\n\n zip.end();\n } catch (err) {\n controller.error(err instanceof Error ? err : new Error(String(err)));\n }\n },\n });\n};\n\n// ── Factory function ──\n\n/**\n * Compile function provided by each package to convert a file object into a Zippable map.\n */\nexport type CompileFn<TFile> = (\n file: TFile,\n overrides?: XmlifyedFile[],\n mediaLevel?: number,\n) => Zippable;\n\n/**\n * Packer interface returned by {@link createPacker}.\n *\n * Async methods use fflate Web Workers for non-blocking compression.\n * Sync methods use synchronous compression for maximum throughput in\n * CLI scripts and build tools.\n */\nexport interface Packer<TFile> {\n /** Compile file to Zippable map (synchronous). */\n compile: CompileFn<TFile>;\n\n /** Generic async output — returns the requested OutputType. */\n pack<T extends OutputType = \"nodebuffer\">(\n file: TFile,\n options?: PackerOptions<T>,\n ): Promise<OutputByType[T]>;\n /** Generic sync output — returns the requested OutputType. */\n packSync<T extends OutputType = \"nodebuffer\">(\n file: TFile,\n options?: PackerOptions<T>,\n ): OutputByType[T];\n\n /** Async → `Promise<Uint8Array>` (like `Response.bytes()`). */\n toBytes(file: TFile, options?: PackerOptions): Promise<Uint8Array>;\n /** Sync → `Uint8Array`. */\n toBytesSync(file: TFile, options?: PackerOptions): Uint8Array;\n\n /** Async → `Promise<string>` (raw ZIP content as string). */\n toString(file: TFile, options?: PackerOptions): Promise<string>;\n /** Sync → `string`. */\n toStringSync(file: TFile, options?: PackerOptions): string;\n\n /** Async → `Promise<Buffer>` (Node.js). */\n toBuffer(file: TFile, options?: PackerOptions): Promise<Buffer>;\n /** Sync → `Buffer` (Node.js). */\n toBufferSync(file: TFile, options?: PackerOptions): Buffer;\n\n /** Async → `Promise<string>` (base64-encoded). */\n toBase64(file: TFile, options?: PackerOptions): Promise<string>;\n /** Sync → `string` (base64-encoded). */\n toBase64Sync(file: TFile, options?: PackerOptions): string;\n\n /** Async → `Promise<Blob>` (browser). */\n toBlob(file: TFile, options?: PackerOptions): Promise<Blob>;\n /** Sync → `Blob`. */\n toBlobSync(file: TFile, options?: PackerOptions): Blob;\n\n /** Async → `Promise<ArrayBuffer>`. */\n toArrayBuffer(file: TFile, options?: PackerOptions): Promise<ArrayBuffer>;\n /** Sync → `ArrayBuffer`. */\n toArrayBufferSync(file: TFile, options?: PackerOptions): ArrayBuffer;\n\n /** Streaming output via `ReadableStream<Uint8Array>` (cross-platform, uses Web Workers). */\n toStream(file: TFile, options?: PackerOptions): ReadableStream<Uint8Array>;\n}\n\n/**\n * Create a Packer object with all output format methods.\n *\n * Centralises the ZIP → convert pipeline and the streaming implementation\n * so that each OOXML package only needs to provide a `compile` function and\n * a MIME type.\n */\nexport const createPacker = <TFile>(options: {\n compile: CompileFn<TFile>;\n mimeType: string;\n}): Packer<TFile> => {\n const { compile, mimeType } = options;\n\n const pack = async <T extends OutputType = \"nodebuffer\">(\n file: TFile,\n opts?: PackerOptions<T>,\n ): Promise<OutputByType[T]> => {\n const type = opts?.type ?? (\"nodebuffer\" as T);\n const files = compile(file, opts?.overrides ?? [], opts?.compression?.media ?? ZIP_MEDIA_LEVEL);\n return zipAndConvert(files, type, mimeType, opts?.compression?.xml ?? ZIP_DEFLATE_LEVEL);\n };\n\n const toBytes = (file: TFile, opts?: PackerOptions) =>\n pack(file, { ...opts, type: \"uint8array\" });\n const toString = (file: TFile, opts?: PackerOptions) => pack(file, { ...opts, type: \"string\" });\n const toBuffer = (file: TFile, opts?: PackerOptions) =>\n pack(file, { ...opts, type: \"nodebuffer\" });\n const toBase64 = (file: TFile, opts?: PackerOptions) => pack(file, { ...opts, type: \"base64\" });\n const toBlob = (file: TFile, opts?: PackerOptions) => pack(file, { ...opts, type: \"blob\" });\n const toArrayBuffer = (file: TFile, opts?: PackerOptions) =>\n pack(file, { ...opts, type: \"arraybuffer\" });\n\n // ── Sync methods (zipSync, maximum throughput) ──\n\n const packSync = <T extends OutputType = \"nodebuffer\">(\n file: TFile,\n opts?: PackerOptions<T>,\n ): OutputByType[T] => {\n const type = opts?.type ?? (\"nodebuffer\" as T);\n const files = compile(file, opts?.overrides ?? [], opts?.compression?.media ?? ZIP_MEDIA_LEVEL);\n return zipSyncAndConvert(files, type, mimeType, opts?.compression?.xml ?? ZIP_DEFLATE_LEVEL);\n };\n\n const toBytesSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"uint8array\" });\n const toStringSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"string\" });\n const toBufferSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"nodebuffer\" });\n const toBase64Sync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"base64\" });\n const toBlobSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"blob\" });\n const toArrayBufferSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"arraybuffer\" });\n\n // ── Stream ──\n\n const toStream = (file: TFile, opts?: PackerOptions) => {\n const mediaLevel = opts?.compression?.media ?? ZIP_MEDIA_LEVEL;\n let files: Zippable;\n try {\n files = compile(file, opts?.overrides ?? [], mediaLevel);\n } catch (err) {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.error(err instanceof Error ? err : new Error(String(err)));\n },\n });\n }\n return createZipStream(files, opts?.compression?.xml ?? ZIP_DEFLATE_LEVEL);\n };\n\n return {\n compile,\n pack,\n packSync,\n toBytes,\n toBytesSync,\n toString,\n toStringSync,\n toBuffer,\n toBufferSync,\n toBase64,\n toBase64Sync,\n toBlob,\n toBlobSync,\n toArrayBuffer,\n toArrayBufferSync,\n toStream,\n };\n};\n","/**\n * Shared compiler utilities for OOXML document generation.\n *\n * @module\n */\n\nimport { levelForMediaName } from \"../opc/packer\";\nimport type { XmlifyedFile, ZipOptions, Zippable } from \"../opc/packer\";\n\n/** Reusable TextEncoder instance (stateless, safe to share). */\nconst encoder = new TextEncoder();\n\n/**\n * Convert a mapping of XML files + overrides + media into a Zippable structure.\n *\n * Centralises the mapping→Zippable conversion shared by all three compilers.\n */\nexport function compileMapping(\n mapping: Record<string, { data: string; path: string }>,\n overrides?: XmlifyedFile[],\n media?: { data: Uint8Array; path: string }[],\n mediaLevel: number = 0,\n): Zippable {\n const files: Zippable = {};\n for (const entry of Object.values(mapping)) {\n files[entry.path] = encoder.encode(entry.data);\n }\n if (overrides) {\n for (const o of overrides) {\n files[o.path] = typeof o.data === \"string\" ? encoder.encode(o.data) : o.data;\n }\n }\n if (media) {\n for (const m of media) {\n // Already-compressed formats (PNG/JPEG/GIF) → STORE, else the media level.\n // Matches MS Office, which STORE-s pre-compressed assets and DEFLATE-s the rest.\n files[m.path] = [\n m.data,\n { level: levelForMediaName(m.path, mediaLevel) as ZipOptions[\"level\"] },\n ];\n }\n }\n return files;\n}\n","/**\n * Password hashing utilities for OOXML document protection.\n *\n * Implements ECMA-376 Agile Encryption password derivation.\n * Passwords are encoded as UTF-16LE per the OOXML specification.\n *\n * Uses @noble/hashes for SHA-512 — audited, cross-platform,\n * and comparable in speed to node:crypto for this workload.\n *\n * @module\n */\n\nimport { sha512 } from \"@noble/hashes/sha2.js\";\n\nimport { encodeBase64 } from \"./base64\";\n\n// ── Helpers ──\n\nfunction utf16leEncode(str: string): Uint8Array {\n const bytes = new Uint8Array(str.length * 2);\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n bytes[i * 2] = code & 0xff;\n bytes[i * 2 + 1] = (code >> 8) & 0xff;\n }\n return bytes;\n}\n\n// ── Public API ──\n\nexport function randomBytes(length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof crypto !== \"undefined\" && crypto.getRandomValues) {\n crypto.getRandomValues(bytes);\n } else {\n for (let i = 0; i < length; i++) {\n bytes[i] = Math.floor(Math.random() * 256);\n }\n }\n return bytes;\n}\n\n/**\n * Computes the ECMA-376 Agile Encryption hash for a password.\n *\n * Algorithm: SHA-512(salt + UTF-16LE(password)), then iterate\n * SHA-512(hash + i.toUint32LE()) spinCount times.\n */\nexport function hashPasswordAgile(password: string, salt: Uint8Array, spinCount: number): string {\n const pwBytes = utf16leEncode(password);\n\n // h = SHA-512(salt + password_utf16le)\n const initial = new Uint8Array(salt.length + pwBytes.length);\n initial.set(salt, 0);\n initial.set(pwBytes, salt.length);\n\n let h = sha512(initial);\n for (let i = 0; i < spinCount; i++) {\n const buf = new Uint8Array(h.length + 4);\n buf.set(h, 0);\n buf[h.length] = i & 0xff;\n buf[h.length + 1] = (i >> 8) & 0xff;\n buf[h.length + 2] = (i >> 16) & 0xff;\n buf[h.length + 3] = (i >> 24) & 0xff;\n h = sha512(buf);\n }\n\n return encodeBase64(new Uint8Array(h));\n}\n\n/**\n * Derives a password hash for OOXML document protection.\n *\n * Returns base64-encoded hashValue, saltValue, spinCount, and algorithmName\n * suitable for direct use in document protection options.\n */\nexport function derivePasswordHash(\n password: string,\n spinCount = 100000,\n): { hashValue: string; saltValue: string; spinCount: number; algorithmName: string } {\n const salt = randomBytes(16);\n const hashValue = hashPasswordAgile(password, salt, spinCount);\n return {\n hashValue,\n saltValue: encodeBase64(salt),\n spinCount,\n algorithmName: \"SHA-512\",\n };\n}\n","/**\n * Placeholder detection and replacement utilities for compiler post-processing.\n *\n * Both DOCX and PPTX compilers use placeholder tokens (e.g. `{chart:key}`)\n * in XML strings to defer relationship ID assignment. This module provides\n * fast pre-check utilities and shared replacement functions.\n */\n\nexport type IdFormat = \"rId\" | \"plain\";\n\nexport const formatId = (offset: number, index: number, style: IdFormat): string =>\n style === \"rId\" ? `rId${offset + index}` : `${offset + index}`;\n\n/** Single-pass regex replacement for `{key}` placeholders using a Map lookup. */\nconst PLACEHOLDER_RE = /\\{([^{}]+)\\}/g;\n\nfunction replacePlaceholders(xml: string, map: Map<string, string>): string {\n const parts: string[] = [];\n let last = 0;\n for (const m of xml.matchAll(PLACEHOLDER_RE)) {\n const key = m[1];\n if (key === undefined) continue;\n const replacement = map.get(key);\n if (replacement !== undefined) {\n parts.push(xml.substring(last, m.index!), replacement);\n last = m.index! + m[0].length;\n }\n }\n if (last === 0) return xml;\n parts.push(xml.substring(last));\n return parts.join(\"\");\n}\n\nexport function hasPlaceholders(xml: string): boolean {\n return xml.includes(\"{\");\n}\n\nexport function collectPlaceholderKeys(xml: string, prefix: string): string[] {\n const keys = new Set<string>();\n const search = `{${prefix}`;\n let pos = 0;\n\n while ((pos = xml.indexOf(search, pos)) !== -1) {\n const keyStart = pos + search.length;\n const keyEnd = xml.indexOf(\"}\", keyStart);\n if (keyEnd === -1) break;\n\n const key = xml.substring(keyStart, keyEnd);\n if (key.length > 0) keys.add(key);\n pos = keyEnd + 1;\n }\n\n return [...keys];\n}\n\nexport function replaceImagePlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n idFormat: IdFormat = \"rId\",\n): string {\n if (mediaData.length === 0) return xml;\n const map = new Map<string, string>();\n for (const [i, item] of mediaData.entries()) {\n map.set(item.fileName, formatId(offset, i, idFormat));\n }\n return replacePlaceholders(xml, map);\n}\n\nexport function getReferencedMedia(\n xml: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n return mediaArray.filter((image) => xml.includes(`{${image.fileName}}`));\n}\n\n/**\n * Combined find + replace for image placeholders in a single pass.\n *\n * Scans XML for `{fileName}` placeholders, replaces them with formatted IDs,\n * and returns the list of referenced media items for relationship registration.\n * More efficient than calling getReferencedMedia() + replaceImagePlaceholders() separately.\n */\nexport function findAndReplaceImagePlaceholders(\n xml: string,\n mediaArray: { fileName: string }[],\n offset: number,\n idFormat: IdFormat = \"rId\",\n): { xml: string; referenced: { fileName: string }[] } {\n if (mediaArray.length === 0 || !hasPlaceholders(xml)) {\n return { xml, referenced: [] };\n }\n // Build fileName → mediaItem lookup\n const itemMap = new Map<string, { fileName: string }>();\n for (const item of mediaArray) {\n itemMap.set(item.fileName, item);\n }\n\n const referenced: { fileName: string }[] = [];\n const replaceMap = new Map<string, string>();\n const parts: string[] = [];\n let last = 0;\n\n for (const m of xml.matchAll(PLACEHOLDER_RE)) {\n const key = m[1];\n if (key === undefined) continue;\n const item = itemMap.get(key);\n if (item !== undefined) {\n if (!replaceMap.has(key)) {\n // Use the referenced-local position (not the global media index) so the\n // generated IDs align with the caller's per-part addRelationship(offset+i)\n // loop. Using the global index desyncs the body's r:embed from the part's\n // .rels when a part references only a subset of the global media array\n // (e.g. headers/footers, whose images sit at high global indices).\n replaceMap.set(key, formatId(offset, referenced.length, idFormat));\n referenced.push(item);\n }\n parts.push(xml.substring(last, m.index!), replaceMap.get(key)!);\n last = m.index! + m[0].length;\n }\n }\n\n if (last === 0) return { xml, referenced: [] };\n parts.push(xml.substring(last));\n return { xml: parts.join(\"\"), referenced };\n}\n\n/**\n * Replace all placeholder types in a single pass.\n *\n * Combines image, chart, smartart, and arbitrary key-value replacements\n * into one regex scan of the XML string. Used by compilers to avoid\n * multiple full-string passes on large documents.\n */\nexport function replaceAllPlaceholders(\n xml: string,\n entries: Array<{ prefix?: string; key: string; value: string }>,\n): string {\n if (entries.length === 0 || !hasPlaceholders(xml)) return xml;\n const map = new Map<string, string>();\n for (const { prefix, key, value } of entries) {\n map.set(prefix ? `${prefix}${key}` : key, value);\n }\n return replacePlaceholders(xml, map);\n}\n\nexport function replaceChartPlaceholders(\n xml: string,\n chartKeys: string[],\n offset: number,\n idFormat: IdFormat = \"rId\",\n): string {\n if (chartKeys.length === 0) return xml;\n const map = new Map<string, string>();\n for (let i = 0; i < chartKeys.length; i++) {\n map.set(`chart:${chartKeys[i]}`, formatId(offset, i, idFormat));\n }\n return replacePlaceholders(xml, map);\n}\n\nimport type { RelationshipType } from \"../opc/relationships\";\n\nexport interface SmartArtRelOptions {\n pathPrefix: string;\n styleRelType: RelationshipType;\n}\n\nexport function replaceSmartArtPlaceholders(\n xml: string,\n keys: string[],\n dataOffset: number,\n idFormat: IdFormat = \"rId\",\n): string {\n if (keys.length === 0) return xml;\n const count = keys.length;\n const loOffset = dataOffset + count;\n const qsOffset = loOffset + count;\n const csOffset = qsOffset + count;\n\n const map = new Map<string, string>();\n for (let i = 0; i < count; i++) {\n map.set(`smartart:${keys[i]}`, formatId(dataOffset, i, idFormat));\n map.set(`smartart-lo:${keys[i]}`, formatId(loOffset, i, idFormat));\n map.set(`smartart-qs:${keys[i]}`, formatId(qsOffset, i, idFormat));\n map.set(`smartart-cs:${keys[i]}`, formatId(csOffset, i, idFormat));\n }\n return replacePlaceholders(xml, map);\n}\n\nexport function addSmartArtRelationships(\n keys: string[],\n addRel: (id: number, type: RelationshipType, target: string, targetMode?: string) => void,\n baseOffset: number,\n globalStartIndex: number,\n options: SmartArtRelOptions,\n): void {\n const { pathPrefix, styleRelType } = options;\n const count = keys.length;\n const loOffset = baseOffset + count;\n const qsOffset = loOffset + count;\n const csOffset = qsOffset + count;\n\n for (let i = 0; i < keys.length; i++) {\n const gi = globalStartIndex + i;\n addRel(\n baseOffset + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData\",\n `${pathPrefix}diagrams/data${gi + 1}.xml`,\n );\n addRel(\n loOffset + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout\",\n `${pathPrefix}diagrams/layout${gi + 1}.xml`,\n );\n addRel(qsOffset + i, styleRelType, `${pathPrefix}diagrams/quickStyle${gi + 1}.xml`);\n addRel(\n csOffset + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors\",\n `${pathPrefix}diagrams/colors${gi + 1}.xml`,\n );\n const drOffset = csOffset + count;\n addRel(\n drOffset + i,\n \"http://schemas.microsoft.com/office/2007/relationships/diagramDrawing\",\n `${pathPrefix}diagrams/drawing${gi + 1}.xml`,\n );\n }\n}\n\n// ── Numbering placeholders (DOCX) ──\n\n/** Replace `{reference-instance}` placeholders with numId values. */\nexport function replaceNumberingPlaceholders(\n xml: string,\n concreteNumberings: readonly { reference: string; instance: number; numId: number }[],\n): string {\n if (concreteNumberings.length === 0) return xml;\n const map = new Map<string, string>();\n for (const { reference, instance, numId } of concreteNumberings) {\n map.set(`${reference}-${instance}`, numId.toString());\n }\n return replacePlaceholders(xml, map);\n}\n\n// ── Media/Video placeholders (PPTX) ──\n\n/** Replace `{media:fileName}` placeholders with relationship IDs. */\nexport function replaceMediaPlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n): string {\n if (mediaData.length === 0) return xml;\n const map = new Map<string, string>();\n for (const [i, item] of mediaData.entries()) {\n map.set(`media:${item.fileName}`, formatId(offset, i, \"rId\"));\n }\n return replacePlaceholders(xml, map);\n}\n\n/** Replace `{video:fileName}` placeholders with relationship IDs. */\nexport function replaceVideoPlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n): string {\n if (mediaData.length === 0) return xml;\n const map = new Map<string, string>();\n for (const [i, item] of mediaData.entries()) {\n map.set(`video:${item.fileName}`, formatId(offset, i, \"rId\"));\n }\n return replacePlaceholders(xml, map);\n}\n\n/** Collect media items referenced by `{media:...}` placeholders in XML. */\nexport function getMediaRefs(\n xml: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n return collectPrefixedRefs(xml, \"media:\", mediaArray);\n}\n\n/** Collect media items referenced by `{video:...}` placeholders in XML. */\nexport function getVideoRefs(\n xml: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n return collectPrefixedRefs(xml, \"video:\", mediaArray);\n}\n\nfunction collectPrefixedRefs(\n xml: string,\n prefix: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n const keys = new Set<string>();\n const search = `{${prefix}`;\n let pos = 0;\n while ((pos = xml.indexOf(search, pos)) !== -1) {\n const keyStart = pos + search.length;\n const keyEnd = xml.indexOf(\"}\", keyStart);\n if (keyEnd === -1) break;\n keys.add(xml.substring(keyStart, keyEnd));\n pos = keyEnd + 1;\n }\n return mediaArray.filter((m) => keys.has(m.fileName));\n}\n\n// ── Hyperlink placeholders (PPTX) ──\n\n/** Replace `{hlink:key}` placeholders with relationship IDs. */\nexport function replaceHyperlinkPlaceholders(\n xml: string,\n hyperlinks: { key: string }[],\n offset: number,\n): string {\n if (hyperlinks.length === 0) return xml;\n const map = new Map<string, string>();\n for (const [i, h] of hyperlinks.entries()) {\n map.set(`hlink:${h.key}`, formatId(offset, i, \"rId\"));\n }\n return replacePlaceholders(xml, map);\n}\n","/**\n * Runtime validation and type conversion functions for OOXML specification values.\n *\n * This module provides runtime checks and cleanup for value types in the OOXML spec\n * that aren't easily expressed through the TypeScript type system alone. These\n * validators help prevent silent failures and corrupted documents by enforcing\n * spec-compliant values at runtime.\n *\n * @module\n */\n\n/**\n * A measurement value with optional sign and unit suffix.\n *\n * Supports units: mm (millimeters), cm (centimeters), in (inches), pt (points),\n * pc (picas), pi (picas), and a project-only px (96 DPI pixels).\n *\n * px is NOT part of OOXML's ST_UniversalMeasure (whose pattern is\n * `-?[0-9]+(\\.[0-9]+)?(mm|cm|in|pt|pc|pi)`); it is a project extension so\n * geometry APIs can accept `\"200px\"` alongside `\"5cm\"`. px is converted to EMU\n * (or TWIP) on input and never written to XML verbatim. Note: Word line spacing\n * with lineRule=\"auto\" uses a bare multiple (240ths of a line), not a measure,\n * so px is irrelevant there; spacing before/after and indents accept px and\n * convert it to twips (1px = 15twip).\n *\n * @example\n * ```typescript\n * const measure: UniversalMeasure = \"10.5mm\";\n * const px: UniversalMeasure = \"200px\";\n * const negative: UniversalMeasure = \"-5pt\";\n * ```\n */\nexport type UniversalMeasure =\n `${\"-\" | \"\"}${number}${\"mm\" | \"cm\" | \"in\" | \"pt\" | \"pc\" | \"pi\" | \"px\"}`;\n\n/**\n * A positive measurement value with unit suffix.\n *\n * Same as UniversalMeasure but restricted to positive values only.\n *\n * Reference: ST_PositiveUniversalMeasure in OOXML specification\n *\n * @example\n * ```typescript\n * const measure: PositiveUniversalMeasure = \"10.5mm\";\n * ```\n */\nexport type PositiveUniversalMeasure = `${number}${\"mm\" | \"cm\" | \"in\" | \"pt\" | \"pc\" | \"pi\"}`;\n\n/**\n * A percentage value with optional sign.\n *\n * Pattern: `-?[0-9]+(\\.[0-9]+)?%`\n *\n * Reference: ST_Percentage in OOXML specification\n *\n * @example\n * ```typescript\n * const percent: Percentage = \"50%\";\n * const negative: Percentage = \"-10.5%\";\n * ```\n */\nexport type Percentage = `${\"-\" | \"\"}${number}%`;\n\n/**\n * A positive percentage value.\n *\n * Same as Percentage but restricted to positive values only.\n *\n * Reference: ST_PositivePercentage in OOXML specification\n *\n * @example\n * ```typescript\n * const percent: PositivePercentage = \"50%\";\n * ```\n */\nexport type PositivePercentage = `${number}%`;\n\n/**\n * A relative measurement value using em or ex units.\n *\n * Used in VML text boxes for font-relative measurements.\n *\n * @example\n * ```typescript\n * const measure: RelativeMeasure = \"2em\";\n * const negative: RelativeMeasure = \"-0.5ex\";\n * ```\n */\nexport type RelativeMeasure = `${\"-\" | \"\"}${number}${\"em\" | \"ex\"}`;\n\n/**\n * Validates and converts a number to an integer (decimal number).\n *\n * Reference: ST_DecimalNumber in OOXML specification\n *\n * @param val - The number to validate and convert\n * @returns The floored integer value\n * @throws Error if the value is NaN\n *\n * @example\n * ```typescript\n * const num = decimalNumber(10.7); // Returns 10\n * const negative = decimalNumber(-5.3); // Returns -5\n * ```\n */\nexport const decimalNumber = (val: number): number => {\n if (!Number.isFinite(val)) {\n throw new Error(`Invalid value '${val}' specified. Must be a finite number.`);\n }\n return Math.floor(val);\n};\n\n/**\n * Validates and converts a number to a positive integer (unsigned decimal number).\n *\n * Reference: ST_UnsignedDecimalNumber in OOXML specification\n *\n * @param val - The number to validate and convert\n * @returns The floored positive integer value\n * @throws Error if the value is NaN or negative\n *\n * @example\n * ```typescript\n * const num = unsignedDecimalNumber(10.7); // Returns 10\n * const invalid = unsignedDecimalNumber(-5); // Throws Error\n * ```\n */\nexport const unsignedDecimalNumber = (val: number): number => {\n const value = decimalNumber(val);\n if (value < 0) {\n throw new Error(`Invalid value '${val}' specified. Must be a positive integer.`);\n }\n return value;\n};\n\n/**\n * Validates and normalizes a hexadecimal binary value.\n *\n * The xsd:hexBinary type represents binary data as a sequence of binary octets\n * using hexadecimal encoding, where each binary octet is a two-character\n * hexadecimal number. Both lowercase and uppercase letters A-F are permitted.\n *\n * @param val - The hexadecimal string to validate\n * @param length - The expected length in bytes (not characters)\n * @returns The validated hexadecimal string\n * @throws Error if the value is not a valid hex string of the expected length\n *\n * @example\n * ```typescript\n * hexBinary(\"0FB8\", 2); // Valid: 2 bytes = 4 characters\n * hexBinary(\"ABC\", 2); // Invalid: wrong length\n * ```\n */\nexport const hexBinary = (val: string, length: number): string => {\n const expectedLength = length * 2;\n if (val.length !== expectedLength || isNaN(Number(`0x${val}`))) {\n throw new Error(`Invalid hex value '${val}'. Expected ${expectedLength} digit hex value`);\n }\n return val;\n};\n\n/**\n * Validates a long hexadecimal number (4 bytes / 8 characters).\n *\n * Reference: ST_LongHexNumber in OOXML specification\n *\n * @param val - The hexadecimal string to validate\n * @returns The validated hexadecimal string\n * @throws Error if the value is not a valid 8-character hex string\n *\n * @example\n * ```typescript\n * const hex = longHexNumber(\"ABCD1234\"); // Valid\n * ```\n */\nexport const longHexNumber = (val: string): string => hexBinary(val, 4);\n\n/**\n * Validates a short hexadecimal number (2 bytes / 4 characters).\n *\n * Reference: ST_ShortHexNumber in OOXML specification\n *\n * @param val - The hexadecimal string to validate\n * @returns The validated hexadecimal string\n * @throws Error if the value is not a valid 4-character hex string\n *\n * @example\n * ```typescript\n * const hex = shortHexNumber(\"AB12\"); // Valid\n * ```\n */\nexport const shortHexNumber = (val: string): string => hexBinary(val, 2);\n\n/**\n * Validates a single-byte hexadecimal number (1 byte / 2 characters).\n *\n * Reference: ST_UcharHexNumber in OOXML specification\n *\n * @param val - The hexadecimal string to validate\n * @returns The validated hexadecimal string\n * @throws Error if the value is not a valid 2-character hex string\n *\n * @example\n * ```typescript\n * const hex = uCharHexNumber(\"FF\"); // Valid\n * ```\n */\nexport const uCharHexNumber = (val: string): string => hexBinary(val, 1);\n\n/**\n * Normalizes a universal measure value by parsing and reformatting.\n *\n * Ensures the numeric portion is properly formatted while preserving the unit.\n *\n * Reference: ST_UniversalMeasure in OOXML specification\n *\n * @param val - The universal measure string to normalize\n * @returns The normalized universal measure\n *\n * @example\n * ```typescript\n * const measure = universalMeasureValue(\"10.500mm\"); // Returns \"10.5mm\"\n * ```\n */\nexport const universalMeasureValue = (val: UniversalMeasure): UniversalMeasure => {\n const unit = val.slice(-2);\n const amount = val.substring(0, val.length - 2);\n return `${Number(amount)}${unit}` as UniversalMeasure;\n};\n\n/**\n * Validates and normalizes a positive universal measure value.\n *\n * Reference: ST_PositiveUniversalMeasure in OOXML specification\n *\n * @param val - The positive universal measure string to validate\n * @returns The normalized positive universal measure\n * @throws Error if the value is negative\n *\n * @example\n * ```typescript\n * const measure = positiveUniversalMeasureValue(\"10.5mm\"); // Valid\n * const invalid = positiveUniversalMeasureValue(\"-5mm\"); // Throws Error\n * ```\n */\nexport const positiveUniversalMeasureValue = (\n val: PositiveUniversalMeasure,\n): PositiveUniversalMeasure => {\n const value = universalMeasureValue(val);\n if (parseFloat(value) < 0) {\n throw new Error(`Invalid value '${value}' specified. Expected a positive number.`);\n }\n return value as PositiveUniversalMeasure;\n};\n\n/**\n * Validates and normalizes a hexadecimal color value.\n *\n * Accepts either \"auto\" or a 6-character RGB hex value (with or without # prefix).\n * The # prefix is commonly used but technically invalid in OOXML, so it is stripped\n * for strict compliance.\n *\n * Reference: ST_HexColor in OOXML specification\n *\n * @param val - The color value to validate (\"auto\" or hex color)\n * @returns The normalized color value\n * @throws Error if the hex color is invalid\n *\n * @example\n * ```typescript\n * const color1 = hexColorValue(\"auto\"); // Returns \"auto\"\n * const color2 = hexColorValue(\"FF0000\"); // Returns \"FF0000\"\n * const color3 = hexColorValue(\"#00FF00\"); // Returns \"00FF00\" (# stripped)\n * ```\n */\nexport const hexColorValue = (val: string): string => {\n if (val === \"auto\") {\n return val;\n }\n // It's super common to see colors prefixed with a pound, but technically invalid here.\n // Most clients work with it, but strip it off anyway for strict compliance.\n const color = val.charAt(0) === \"#\" ? val.substring(1) : val;\n return hexBinary(color, 3);\n};\n\n/**\n * Validates a signed TWIP measurement value.\n *\n * Accepts either a universal measure string or a numeric TWIP value.\n *\n * Reference: ST_SignedTwipsMeasure in OOXML specification\n *\n * @param val - The measurement value (universal measure or number)\n * @returns The normalized measurement value\n *\n * @example\n * ```typescript\n * const measure1 = signedTwipsMeasureValue(\"10mm\");\n * const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP\n * ```\n */\nexport const signedTwipsMeasureValue = (\n val: UniversalMeasure | number,\n): UniversalMeasure | number =>\n typeof val === \"string\" ? universalMeasureValue(val) : decimalNumber(val);\n\n/**\n * Validates a half-point (HPS) measurement value.\n *\n * Accepts either a positive universal measure string or a positive number.\n * HPS (half-points) are commonly used for font sizes.\n *\n * Reference: ST_HpsMeasure in OOXML specification\n *\n * @param val - The measurement value (positive universal measure or number)\n * @returns The normalized measurement value\n *\n * @example\n * ```typescript\n * const fontSize1 = hpsMeasureValue(\"12pt\");\n * const fontSize2 = hpsMeasureValue(24); // 12pt in half-points\n * ```\n */\nexport const hpsMeasureValue = (val: PositiveUniversalMeasure | number): string | number =>\n typeof val === \"string\" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);\n\n/**\n * Validates a signed half-point (HPS) measurement value.\n *\n * Accepts either a universal measure string or a numeric value.\n *\n * Reference: ST_SignedHpsMeasure in OOXML specification\n *\n * @param val - The measurement value (universal measure or number)\n * @returns The normalized measurement value\n *\n * @example\n * ```typescript\n * const spacing1 = signedHpsMeasureValue(\"6pt\");\n * const spacing2 = signedHpsMeasureValue(-12); // Negative spacing\n * ```\n */\nexport const signedHpsMeasureValue = (val: UniversalMeasure | number): string | number =>\n typeof val === \"string\" ? universalMeasureValue(val) : decimalNumber(val);\n\n/**\n * Validates a positive TWIP measurement value.\n *\n * Accepts either a positive universal measure string or a positive number.\n *\n * Reference: ST_TwipsMeasure in OOXML specification\n *\n * @param val - The measurement value (positive universal measure or number)\n * @returns The normalized measurement value\n *\n * @example\n * ```typescript\n * const width1 = twipsMeasureValue(\"25.4mm\");\n * const width2 = twipsMeasureValue(1440); // 1 inch in TWIP\n * ```\n */\nexport const twipsMeasureValue = (\n val: PositiveUniversalMeasure | number,\n): PositiveUniversalMeasure | number =>\n typeof val === \"string\" ? positiveUniversalMeasureValue(val) : unsignedDecimalNumber(val);\n\n/**\n * Normalizes a percentage value by parsing and reformatting.\n *\n * Reference: ST_Percentage in OOXML specification\n *\n * @param val - The percentage string to normalize\n * @returns The normalized percentage\n *\n * @example\n * ```typescript\n * const percent = percentageValue(\"50.000%\"); // Returns \"50%\"\n * ```\n */\nexport const percentageValue = (val: Percentage): Percentage => {\n const percent = val.substring(0, val.length - 1);\n return `${Number(percent)}%`;\n};\n\n/**\n * Validates a measurement value that can be expressed as a number, percentage, or universal measure.\n *\n * Reference: ST_MeasurementOrPercent in OOXML specification\n *\n * @param val - The measurement value (number, percentage, or universal measure)\n * @returns The normalized measurement value\n *\n * @example\n * ```typescript\n * const measure1 = measurementOrPercentValue(100); // Unqualified number\n * const measure2 = measurementOrPercentValue(\"50%\"); // Percentage\n * const measure3 = measurementOrPercentValue(\"10mm\"); // Universal measure\n * ```\n */\nexport const measurementOrPercentValue = (\n val: number | Percentage | UniversalMeasure,\n): number | UniversalMeasure | Percentage => {\n if (typeof val === \"number\") {\n return decimalNumber(val);\n }\n if (val.slice(-1) === \"%\") {\n return percentageValue(val as Percentage);\n }\n return universalMeasureValue(val as UniversalMeasure);\n};\n\n/**\n * Validates an eighth-point measurement value.\n *\n * Eighth-points are used for fine-grained measurements in text formatting.\n *\n * Reference: ST_EighthPointMeasure in OOXML specification\n *\n * @param val - The measurement value in eighth-points\n * @returns The validated positive integer value\n *\n * @example\n * ```typescript\n * const measure = eighthPointMeasureValue(16); // 2 points\n * ```\n */\nexport const eighthPointMeasureValue = unsignedDecimalNumber;\n\n/**\n * Validates a point measurement value.\n *\n * Reference: ST_PointMeasure in OOXML specification\n *\n * @param val - The measurement value in points\n * @returns The validated positive integer value\n *\n * @example\n * ```typescript\n * const fontSize = pointMeasureValue(12); // 12pt\n * ```\n */\nexport const pointMeasureValue = unsignedDecimalNumber;\n\n// Cspell:words CCYY\n/**\n * Converts a JavaScript Date object to an ISO 8601 date-time string.\n *\n * The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.\n * This matches the xsd:dateTime format required by OOXML.\n *\n * Reference: ST_DateTime in OOXML specification\n *\n * @param val - The Date object to convert\n * @returns An ISO 8601 formatted date-time string\n *\n * @example\n * ```typescript\n * const now = new Date();\n * const timestamp = dateTimeValue(now); // Returns \"2024-01-15T10:30:00.000Z\"\n * ```\n */\nexport const dateTimeValue = (val: Date): string => val.toISOString();\n\n/**\n * Theme color values used throughout OOXML for referencing document theme colors.\n *\n * Reference: ST_ThemeColor in OOXML specification\n *\n * @publicApi\n */\nexport const ThemeColor = {\n DARK1: \"dark1\",\n LIGHT1: \"light1\",\n DARK2: \"dark2\",\n LIGHT2: \"light2\",\n ACCENT1: \"accent1\",\n ACCENT2: \"accent2\",\n ACCENT3: \"accent3\",\n ACCENT4: \"accent4\",\n ACCENT5: \"accent5\",\n ACCENT6: \"accent6\",\n HYPERLINK: \"hyperlink\",\n FOLLOWED_HYPERLINK: \"followedHyperlink\",\n NONE: \"none\",\n BACKGROUND1: \"background1\",\n TEXT1: \"text1\",\n BACKGROUND2: \"background2\",\n TEXT2: \"text2\",\n} as const;\n\n/**\n * Theme font values used for referencing document theme fonts.\n *\n * Reference: ST_Theme in OOXML specification\n *\n * @publicApi\n */\nexport const ThemeFont = {\n MAJOR_EAST_ASIA: \"majorEastAsia\",\n MAJOR_BIDI: \"maj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AO;CACP,QAAQ;CACR,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,SAAS;CACT,WAAW;CACX,oBAAoB;CACpB,MAAM;CACN,aAAa;CACb,OAAO;CACP,aAAa;CACb,OAAO;AACT;;;;;;;;AASA,MAAa,YAAY;CACvB,iBAAiB;CACjB,YAAY;CACZ,aAAa;CACb,cAAc;CACd,iBAAiB;CACjB,YAAY;CACZ,aAAa;CACb,cAAc;AAChB"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/util/values.d.ts
|
|
2
|
+
type UniversalMeasure = `${"-" | ""}${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi" | "px"}`;
|
|
3
|
+
type PositiveUniversalMeasure = `${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
|
|
4
|
+
type Percentage = `${"-" | ""}${number}%`;
|
|
5
|
+
type PositivePercentage = `${number}%`;
|
|
6
|
+
type RelativeMeasure = `${"-" | ""}${number}${"em" | "ex"}`;
|
|
7
|
+
declare const decimalNumber: (val: number) => number;
|
|
8
|
+
declare const unsignedDecimalNumber: (val: number) => number;
|
|
9
|
+
declare const hexBinary: (val: string, length: number) => string;
|
|
10
|
+
declare const longHexNumber: (val: string) => string;
|
|
11
|
+
declare const shortHexNumber: (val: string) => string;
|
|
12
|
+
declare const uCharHexNumber: (val: string) => string;
|
|
13
|
+
declare const universalMeasureValue: (val: UniversalMeasure) => UniversalMeasure;
|
|
14
|
+
declare const positiveUniversalMeasureValue: (val: PositiveUniversalMeasure) => PositiveUniversalMeasure;
|
|
15
|
+
declare const hexColorValue: (val: string) => string;
|
|
16
|
+
declare const signedTwipsMeasureValue: (val: UniversalMeasure | number) => UniversalMeasure | number;
|
|
17
|
+
declare const hpsMeasureValue: (val: PositiveUniversalMeasure | number) => string | number;
|
|
18
|
+
declare const signedHpsMeasureValue: (val: UniversalMeasure | number) => string | number;
|
|
19
|
+
declare const twipsMeasureValue: (val: PositiveUniversalMeasure | number) => PositiveUniversalMeasure | number;
|
|
20
|
+
declare const percentageValue: (val: Percentage) => Percentage;
|
|
21
|
+
declare const measurementOrPercentValue: (val: number | Percentage | UniversalMeasure) => number | UniversalMeasure | Percentage;
|
|
22
|
+
declare const eighthPointMeasureValue: (val: number) => number;
|
|
23
|
+
declare const pointMeasureValue: (val: number) => number;
|
|
24
|
+
declare const dateTimeValue: (val: Date) => string;
|
|
25
|
+
declare const ThemeColor: {
|
|
26
|
+
readonly DARK1: "dark1";
|
|
27
|
+
readonly LIGHT1: "light1";
|
|
28
|
+
readonly DARK2: "dark2";
|
|
29
|
+
readonly LIGHT2: "light2";
|
|
30
|
+
readonly ACCENT1: "accent1";
|
|
31
|
+
readonly ACCENT2: "accent2";
|
|
32
|
+
readonly ACCENT3: "accent3";
|
|
33
|
+
readonly ACCENT4: "accent4";
|
|
34
|
+
readonly ACCENT5: "accent5";
|
|
35
|
+
readonly ACCENT6: "accent6";
|
|
36
|
+
readonly HYPERLINK: "hyperlink";
|
|
37
|
+
readonly FOLLOWED_HYPERLINK: "followedHyperlink";
|
|
38
|
+
readonly NONE: "none";
|
|
39
|
+
readonly BACKGROUND1: "background1";
|
|
40
|
+
readonly TEXT1: "text1";
|
|
41
|
+
readonly BACKGROUND2: "background2";
|
|
42
|
+
readonly TEXT2: "text2";
|
|
43
|
+
};
|
|
44
|
+
declare const ThemeFont: {
|
|
45
|
+
readonly MAJOR_EAST_ASIA: "majorEastAsia";
|
|
46
|
+
readonly MAJOR_BIDI: "majorBidi";
|
|
47
|
+
readonly MAJOR_ASCII: "majorAscii";
|
|
48
|
+
readonly MAJOR_H_ANSI: "majorHAnsi";
|
|
49
|
+
readonly MINOR_EAST_ASIA: "minorEastAsia";
|
|
50
|
+
readonly MINOR_BIDI: "minorBidi";
|
|
51
|
+
readonly MINOR_ASCII: "minorAscii";
|
|
52
|
+
readonly MINOR_H_ANSI: "minorHAnsi";
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { uCharHexNumber as C, twipsMeasureValue as S, unsignedDecimalNumber as T, pointMeasureValue as _, ThemeColor as a, signedHpsMeasureValue as b, dateTimeValue as c, hexBinary as d, hexColorValue as f, percentageValue as g, measurementOrPercentValue as h, RelativeMeasure as i, decimalNumber as l, longHexNumber as m, PositivePercentage as n, ThemeFont as o, hpsMeasureValue as p, PositiveUniversalMeasure as r, UniversalMeasure as s, Percentage as t, eighthPointMeasureValue as u, positiveUniversalMeasureValue as v, universalMeasureValue as w, signedTwipsMeasureValue as x, shortHexNumber as y };
|
|
56
|
+
//# sourceMappingURL=values-8di32lIe.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"values-8di32lIe.d.mts","names":[],"sources":["../src/util/values.ts"],"mappings":";KAgCY,gBAAA;AAAA,KAeA,wBAAA;AAAA,KAeA,UAAA;AAAA,KAcA,kBAAA;AAAA,KAaA,eAAA;AAAA,cAiBC,aAAA,GAAiB,GAAW;AAAA,cAsB5B,qBAAA,GAAyB,GAAW;AAAA,cA0BpC,SAAA,GAAa,GAAA,UAAa,MAAc;AAAA,cAsBxC,aAAA,GAAiB,GAAW;AAAA,cAgB5B,cAAA,GAAkB,GAAW;AAAA,cAgB7B,cAAA,GAAkB,GAAW;AAAA,cAiB7B,qBAAA,GAAyB,GAAA,EAAK,gBAAA,KAAmB,gBAI7D;AAAA,cAiBY,6BAAA,GACX,GAAA,EAAK,wBAAA,KACJ,wBAMF;AAAA,cAsBY,aAAA,GAAiB,GAAW;AAAA,cA0B5B,uBAAA,GACX,GAAA,EAAK,gBAAA,cACJ,gBAAgB;AAAA,cAoBN,eAAA,GAAmB,GAAsC,EAAjC,wBAAwB;AAAA,cAmBhD,qBAAA,GAAyB,GAA8B,EAAzB,gBAAgB;AAAA,cAmB9C,iBAAA,GACX,GAAA,EAAK,wBAAA,cACJ,wBAAwB;AAAA,cAgBd,eAAA,GAAmB,GAAA,EAAK,UAAA,KAAa,UAGjD;AAAA,cAiBY,yBAAA,GACX,GAAA,WAAc,UAAA,GAAa,gBAAA,cACjB,gBAAA,GAAmB,UAAA;AAAA,cAyBlB,uBAAA,GAAuB,GA3Sa;AAAA,cA0TpC,iBAAA,GAAiB,GA1TmB;AAAA,cA8UpC,aAAA,GAAiB,GAAS,EAAJ,IAAI;AAAA,cAS1B,UAAA;EAAA;;;;;;;;;;;;;;;;;;cA2BA,SAAA;EAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@office-open/core",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.13",
|
|
4
4
|
"description": "Shared OOXML infrastructure — XML components, validators, converters, charts, and SmartArt",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"core",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"type": "module",
|
|
30
|
+
"sideEffects": false,
|
|
30
31
|
"main": "dist/index.mjs",
|
|
31
32
|
"types": "dist/index.d.mts",
|
|
32
33
|
"exports": {
|
|
@@ -34,10 +35,6 @@
|
|
|
34
35
|
"types": "./dist/index.d.mts",
|
|
35
36
|
"import": "./dist/index.mjs"
|
|
36
37
|
},
|
|
37
|
-
"./util/values": {
|
|
38
|
-
"types": "./dist/util/values.d.mts",
|
|
39
|
-
"import": "./dist/util/values.mjs"
|
|
40
|
-
},
|
|
41
38
|
"./smartart": {
|
|
42
39
|
"types": "./dist/smartart/index.d.mts",
|
|
43
40
|
"import": "./dist/smartart/index.mjs"
|
|
@@ -61,12 +58,16 @@
|
|
|
61
58
|
"./theme": {
|
|
62
59
|
"types": "./dist/theme/index.d.mts",
|
|
63
60
|
"import": "./dist/theme/index.mjs"
|
|
61
|
+
},
|
|
62
|
+
"./util": {
|
|
63
|
+
"types": "./dist/util/index.d.mts",
|
|
64
|
+
"import": "./dist/util/index.mjs"
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
68
|
"@noble/hashes": "2.2.0",
|
|
68
69
|
"fflate": "0.8.3",
|
|
69
|
-
"@office-open/xml": "0.10.
|
|
70
|
+
"@office-open/xml": "0.10.13"
|
|
70
71
|
},
|
|
71
72
|
"scripts": {
|
|
72
73
|
"dev": "basis build --stub",
|
|
@@ -1,266 +0,0 @@
|
|
|
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
|
-
/** Options for {@link toUint8Array}. */
|
|
10
|
-
interface ToUint8ArrayOptions {
|
|
11
|
-
/**
|
|
12
|
-
* How to interpret a plain (non-data-URL) string input. Data URLs
|
|
13
|
-
* (`data:...;base64,...`) and binary inputs (Buffer/Uint8Array/ArrayBuffer/
|
|
14
|
-
* DataView/number[]) are auto-detected and ignore this hint.
|
|
15
|
-
*
|
|
16
|
-
* - `"utf8"` (default): UTF-8 text.
|
|
17
|
-
* - `"base64"`: base64-encoded binary — e.g. an image supplied via
|
|
18
|
-
* `readFileSync(...).toString("base64")`.
|
|
19
|
-
*/
|
|
20
|
-
encoding?: "utf8" | "base64";
|
|
21
|
-
}
|
|
22
|
-
/** Normalize any supported binary input to a `Uint8Array`. */
|
|
23
|
-
declare function toUint8Array(data: DataType, options?: ToUint8ArrayOptions): Uint8Array;
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/opc/output.d.ts
|
|
26
|
-
/**
|
|
27
|
-
* Output type definitions for OOXML document export.
|
|
28
|
-
*
|
|
29
|
-
* @module
|
|
30
|
-
*/
|
|
31
|
-
interface OutputByType {
|
|
32
|
-
base64: string;
|
|
33
|
-
string: string;
|
|
34
|
-
text: string;
|
|
35
|
-
binarystring: string;
|
|
36
|
-
array: readonly number[];
|
|
37
|
-
uint8array: Uint8Array;
|
|
38
|
-
arraybuffer: ArrayBuffer;
|
|
39
|
-
blob: Blob;
|
|
40
|
-
nodebuffer: Buffer;
|
|
41
|
-
}
|
|
42
|
-
type OutputType = keyof OutputByType;
|
|
43
|
-
declare const OoxmlMimeType: {
|
|
44
|
-
readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
45
|
-
readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
46
|
-
readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
47
|
-
};
|
|
48
|
-
declare const convertOutput: <T extends OutputType>(data: Uint8Array, type: T, mimeType?: string) => OutputByType[T];
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/opc/core.d.ts
|
|
51
|
-
type IXmlableObject = Readonly<Record<string, unknown>>;
|
|
52
|
-
/**
|
|
53
|
-
* Core document properties (docProps/core.xml).
|
|
54
|
-
*
|
|
55
|
-
* Shared across docx/pptx/xlsx: each format's top-level Options extends this,
|
|
56
|
-
* parse emits the same shape, and patch overrides it — read/write symmetry
|
|
57
|
-
* (CONTRIBUTING §Property Naming). Field names follow the OPC core-properties
|
|
58
|
-
* XSD element local names (`creator` = dc:creator, … — never `author`).
|
|
59
|
-
*/
|
|
60
|
-
interface CorePropertiesOptions {
|
|
61
|
-
title?: string;
|
|
62
|
-
subject?: string;
|
|
63
|
-
creator?: string;
|
|
64
|
-
keywords?: string;
|
|
65
|
-
description?: string;
|
|
66
|
-
lastModifiedBy?: string;
|
|
67
|
-
revision?: number;
|
|
68
|
-
lastPrinted?: string;
|
|
69
|
-
/** Creation timestamp (W3CDTF), round-tripped from dcterms:created. */
|
|
70
|
-
created?: string;
|
|
71
|
-
/** Last modified timestamp (W3CDTF), round-tripped from dcterms:modified. */
|
|
72
|
-
modified?: string;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Parse core properties from an already-parsed XML element.
|
|
76
|
-
* Shared by docx/pptx/xlsx to extract Dublin Core metadata into the unified
|
|
77
|
-
* {@link CorePropertiesOptions} shape.
|
|
78
|
-
*/
|
|
79
|
-
declare function parseCorePropsElement(el: Element | undefined): CorePropertiesOptions;
|
|
80
|
-
/**
|
|
81
|
-
* Build a cp:coreProperties XML object from metadata.
|
|
82
|
-
*
|
|
83
|
-
* Shared by docx and pptx to avoid duplicating namespace declarations
|
|
84
|
-
* and Dublin Core property construction.
|
|
85
|
-
*/
|
|
86
|
-
declare function buildCorePropertiesXml(opts: {
|
|
87
|
-
title?: string;
|
|
88
|
-
subject?: string;
|
|
89
|
-
creator?: string;
|
|
90
|
-
keywords?: string;
|
|
91
|
-
description?: string;
|
|
92
|
-
lastModifiedBy?: string;
|
|
93
|
-
revision?: number;
|
|
94
|
-
}): IXmlableObject;
|
|
95
|
-
/**
|
|
96
|
-
* Build a cp:coreProperties XML string directly (fast path).
|
|
97
|
-
*
|
|
98
|
-
* Shared by pptx and xlsx to bypass the toXml() → xml() pipeline.
|
|
99
|
-
* created/modified default to now when not supplied; all other fields emit
|
|
100
|
-
* only when present.
|
|
101
|
-
*/
|
|
102
|
-
declare function buildCorePropertiesXmlString(opts: CorePropertiesOptions): string;
|
|
103
|
-
//#endregion
|
|
104
|
-
//#region src/patch/xml-namespace.d.ts
|
|
105
|
-
/**
|
|
106
|
-
* Namespace configuration for XML patch operations.
|
|
107
|
-
*
|
|
108
|
-
* Parameterises element names so the same patch algorithm works for both
|
|
109
|
-
* DOCX (`w:*`) and PPTX (`a:*`) documents.
|
|
110
|
-
*/
|
|
111
|
-
interface XmlNamespaceConfig {
|
|
112
|
-
paragraph: string;
|
|
113
|
-
run: string;
|
|
114
|
-
text: string;
|
|
115
|
-
runProperties: string;
|
|
116
|
-
}
|
|
117
|
-
declare const DOCX_NS: XmlNamespaceConfig;
|
|
118
|
-
declare const PPTX_NS: XmlNamespaceConfig;
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region src/patch/xml-replacer.d.ts
|
|
121
|
-
interface ReplacerConfig {
|
|
122
|
-
ns: XmlNamespaceConfig;
|
|
123
|
-
formatChild: (child: unknown, context: unknown) => Element[];
|
|
124
|
-
preserveSpace?: boolean;
|
|
125
|
-
}
|
|
126
|
-
interface ReplacerResult {
|
|
127
|
-
element: Element;
|
|
128
|
-
didFindOccurrence: boolean;
|
|
129
|
-
}
|
|
130
|
-
declare function createReplacer(config: ReplacerConfig): ({
|
|
131
|
-
json,
|
|
132
|
-
patch,
|
|
133
|
-
patchText,
|
|
134
|
-
context,
|
|
135
|
-
keepOriginalStyles
|
|
136
|
-
}: {
|
|
137
|
-
json: Element;
|
|
138
|
-
patch: {
|
|
139
|
-
type: string;
|
|
140
|
-
children: readonly unknown[];
|
|
141
|
-
};
|
|
142
|
-
patchText: string;
|
|
143
|
-
context: unknown;
|
|
144
|
-
keepOriginalStyles?: boolean;
|
|
145
|
-
}) => ReplacerResult;
|
|
146
|
-
//#endregion
|
|
147
|
-
//#region src/patch/run-renderer.d.ts
|
|
148
|
-
interface ElementWrapper {
|
|
149
|
-
element: Element;
|
|
150
|
-
index: number;
|
|
151
|
-
parent: ElementWrapper | undefined;
|
|
152
|
-
}
|
|
153
|
-
interface RenderedParagraphNode {
|
|
154
|
-
text: string;
|
|
155
|
-
runs: readonly RenderedRunNode[];
|
|
156
|
-
index: number;
|
|
157
|
-
pathToParagraph: readonly number[];
|
|
158
|
-
}
|
|
159
|
-
interface StartAndEnd {
|
|
160
|
-
start: number;
|
|
161
|
-
end: number;
|
|
162
|
-
}
|
|
163
|
-
type IParts = {
|
|
164
|
-
text: string;
|
|
165
|
-
index: number;
|
|
166
|
-
} & StartAndEnd;
|
|
167
|
-
type RenderedRunNode = {
|
|
168
|
-
text: string;
|
|
169
|
-
parts: readonly IParts[];
|
|
170
|
-
index: number;
|
|
171
|
-
} & StartAndEnd;
|
|
172
|
-
declare function createRunRenderer(ns: XmlNamespaceConfig): (node: ElementWrapper) => RenderedParagraphNode;
|
|
173
|
-
//#endregion
|
|
174
|
-
//#region src/patch/xml-traverser.d.ts
|
|
175
|
-
declare function createTraverser(ns: XmlNamespaceConfig): {
|
|
176
|
-
traverse: (node: Element) => readonly RenderedParagraphNode[];
|
|
177
|
-
findLocationOfText: (node: Element, text: string) => readonly RenderedParagraphNode[];
|
|
178
|
-
};
|
|
179
|
-
//#endregion
|
|
180
|
-
//#region src/patch/paragraph-token-replacer.d.ts
|
|
181
|
-
declare function createTokenReplacer(createTextElementContents: (text: string) => Element[], options?: {
|
|
182
|
-
readonly preserveSpace?: boolean;
|
|
183
|
-
}): ({
|
|
184
|
-
paragraphElement,
|
|
185
|
-
renderedParagraph,
|
|
186
|
-
originalText,
|
|
187
|
-
replacementText
|
|
188
|
-
}: {
|
|
189
|
-
paragraphElement: Element;
|
|
190
|
-
renderedParagraph: RenderedParagraphNode;
|
|
191
|
-
originalText: string;
|
|
192
|
-
replacementText: string;
|
|
193
|
-
}) => Element;
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region src/patch/paragraph-split-inject.d.ts
|
|
196
|
-
declare class TokenNotFoundError extends Error {
|
|
197
|
-
constructor(token: string);
|
|
198
|
-
}
|
|
199
|
-
declare function createSplitInject(ns: XmlNamespaceConfig, createTextElementContents: (text: string) => Element[], options?: {
|
|
200
|
-
readonly preserveSpace?: boolean;
|
|
201
|
-
}): {
|
|
202
|
-
findRunElementIndexWithToken: (paragraphElement: Element, token: string) => number;
|
|
203
|
-
splitRunElement: (runElement: Element, token: string) => {
|
|
204
|
-
readonly left: Element;
|
|
205
|
-
readonly right: Element;
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
//#endregion
|
|
209
|
-
//#region src/patch/xml-patch-utils.d.ts
|
|
210
|
-
declare const toJson: (xmlData: string) => Element;
|
|
211
|
-
/**
|
|
212
|
-
* Creates the inner content of a text element (`w:t` / `a:t`).
|
|
213
|
-
*
|
|
214
|
-
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
|
|
215
|
-
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
|
|
216
|
-
*/
|
|
217
|
-
declare const createTextElementContents: (text: string) => Element[];
|
|
218
|
-
declare const patchSpaceAttribute: (element: Element) => Element;
|
|
219
|
-
declare const getFirstLevelElements: (relationships: Element, id: string) => Element[];
|
|
220
|
-
/**
|
|
221
|
-
* Next sequential numeric id: the largest `attr` value among direct children
|
|
222
|
-
* named `childName`, plus one. `seed` is the floor — e.g. PPTX `<p:sldId>`
|
|
223
|
-
* values start at 255, so the first appended id is at least 256.
|
|
224
|
-
*
|
|
225
|
-
* Unifies the per-package `maxCommentId` / `maxSldId` / `maxSheetId` helpers.
|
|
226
|
-
*/
|
|
227
|
-
declare const nextNumericId: (parent: Element | undefined, childName: string, attr: string, seed?: number) => number;
|
|
228
|
-
//#endregion
|
|
229
|
-
//#region src/patch/content-types-manager.d.ts
|
|
230
|
-
declare const appendContentType: (element: Element, contentType: string, extension: string) => void;
|
|
231
|
-
/**
|
|
232
|
-
* Append an `<Override>` element to a `[Content_Types].xml` root, deduped by
|
|
233
|
-
* `PartName`. Sibling to {@link appendContentType} (which handles `<Default>`):
|
|
234
|
-
* unifies the per-package Override-dedup blocks in docx/pptx/xlsx patchers.
|
|
235
|
-
*/
|
|
236
|
-
declare const appendOverride: (element: Element, partName: string, contentType: string) => void;
|
|
237
|
-
//#endregion
|
|
238
|
-
//#region src/patch/relationship-manager.d.ts
|
|
239
|
-
declare const getNextRelationshipIndex: (relationships: Element) => number;
|
|
240
|
-
declare const appendRelationship: (relationships: Element, id: number | string, type: string, target: string, targetMode?: string) => readonly Element[];
|
|
241
|
-
//#endregion
|
|
242
|
-
//#region src/patch/core-properties-override.d.ts
|
|
243
|
-
declare function applyCorePropertiesOverride(corePropsDoc: Element, overrides: Partial<CorePropertiesOptions>): string;
|
|
244
|
-
//#endregion
|
|
245
|
-
//#region src/patch/types.d.ts
|
|
246
|
-
/** Placeholder delimiter pair surrounding a patch key (e.g. `{{` / `}}`). */
|
|
247
|
-
interface PlaceholderDelimiters {
|
|
248
|
-
start: string;
|
|
249
|
-
end: string;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Shared base options for patch operations.
|
|
253
|
-
*
|
|
254
|
-
* Format-specific patch functions extend this with their `patches` field
|
|
255
|
-
* (and any format-specific options like `keepOriginalStyles`).
|
|
256
|
-
*/
|
|
257
|
-
interface BasePatchOptions<T extends OutputType = OutputType> {
|
|
258
|
-
/** Source document bytes (Buffer / Uint8Array / ArrayBuffer / base64 data URL / …). */
|
|
259
|
-
data: DataType;
|
|
260
|
-
/** Output container type — controls the return type via OutputByType. */
|
|
261
|
-
outputType: T;
|
|
262
|
-
/** Custom placeholder delimiters (default `{{` / `}}`). */
|
|
263
|
-
placeholderDelimiters?: PlaceholderDelimiters;
|
|
264
|
-
}
|
|
265
|
-
//#endregion
|
|
266
|
-
export { OutputType as A, XmlNamespaceConfig as C, parseCorePropsElement as D, buildCorePropertiesXmlString as E, toUint8Array as F, DataType as M, ToUint8ArrayOptions as N, OoxmlMimeType as O, isBase64DataURL as P, PPTX_NS as S, buildCorePropertiesXml as T, RenderedParagraphNode as _, getNextRelationshipIndex as a, createReplacer as b, createTextElementContents as c, patchSpaceAttribute as d, toJson as f, createTraverser as g, createTokenReplacer as h, appendRelationship as i, convertOutput as j, OutputByType as k, getFirstLevelElements as l, createSplitInject as m, PlaceholderDelimiters as n, appendContentType as o, TokenNotFoundError as p, applyCorePropertiesOverride as r, appendOverride as s, BasePatchOptions as t, nextNumericId as u, createRunRenderer as v, CorePropertiesOptions as w, DOCX_NS as x, ReplacerConfig as y };
|