@office-open/core 0.10.12 → 0.10.14

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 (62) hide show
  1. package/README.md +10 -9
  2. package/dist/chart/index.d.mts +2 -2
  3. package/dist/chart/index.mjs +1 -1
  4. package/dist/{chart-DwE8FCFk.mjs → chart-DIGJna_6.mjs} +220 -9
  5. package/dist/chart-DIGJna_6.mjs.map +1 -0
  6. package/dist/converters-C_Y2QX1w.mjs +1789 -0
  7. package/dist/converters-C_Y2QX1w.mjs.map +1 -0
  8. package/dist/data-type-CZMKVaaT.d.mts +10 -0
  9. package/dist/data-type-CZMKVaaT.d.mts.map +1 -0
  10. package/dist/descriptor/index.d.mts +2 -2
  11. package/dist/descriptor/index.mjs +2 -2
  12. package/dist/{descriptor-DAER86Rt.mjs → descriptor-BjNkn5jo.mjs} +3 -33
  13. package/dist/descriptor-BjNkn5jo.mjs.map +1 -0
  14. package/dist/drawingml/index.d.mts +2 -2
  15. package/dist/drawingml/index.mjs +2 -2
  16. package/dist/{src-bVqU5Bh3.mjs → drawingml-sj1J3lb0.mjs} +22 -3728
  17. package/dist/drawingml-sj1J3lb0.mjs.map +1 -0
  18. package/dist/index-BVK2dv6C.d.mts +63 -0
  19. package/dist/index-BVK2dv6C.d.mts.map +1 -0
  20. package/dist/index-BfHfKuKy.d.mts +275 -0
  21. package/dist/index-BfHfKuKy.d.mts.map +1 -0
  22. package/dist/index-CE53SwpZ.d.mts +1463 -0
  23. package/dist/index-CE53SwpZ.d.mts.map +1 -0
  24. package/dist/{index-3STznXzZ.d.mts → index-D6VE-MnJ.d.mts} +3 -15
  25. package/dist/index-D6VE-MnJ.d.mts.map +1 -0
  26. package/dist/{index-CN0YjNSx.d.mts → index-DE4CLElr.d.mts} +29 -21
  27. package/dist/index-DE4CLElr.d.mts.map +1 -0
  28. package/dist/{index-CsQP7Cl4.d.mts → index-DlPA26cw.d.mts} +2 -47
  29. package/dist/index-DlPA26cw.d.mts.map +1 -0
  30. package/dist/index-k8WKLXnA.d.mts +150 -0
  31. package/dist/index-k8WKLXnA.d.mts.map +1 -0
  32. package/dist/index.d.mts +650 -8
  33. package/dist/index.d.mts.map +1 -0
  34. package/dist/index.mjs +1271 -7
  35. package/dist/index.mjs.map +1 -0
  36. package/dist/output-D_G_JR_8.d.mts +24 -0
  37. package/dist/output-D_G_JR_8.d.mts.map +1 -0
  38. package/dist/patch/index.d.mts +2 -2
  39. package/dist/patch/index.mjs +1 -1
  40. package/dist/{patch-OSbQIQAi.mjs → patch-BmRfghOo.mjs} +65 -84
  41. package/dist/patch-BmRfghOo.mjs.map +1 -0
  42. package/dist/smartart/index.d.mts +1 -1
  43. package/dist/smartart/index.mjs +1 -1
  44. package/dist/{smartart-DCY-Vdv7.mjs → smartart-B7ukZ-Tw.mjs} +5 -3
  45. package/dist/smartart-B7ukZ-Tw.mjs.map +1 -0
  46. package/dist/theme/index.d.mts +1 -1
  47. package/dist/theme-CiNzdl-9.mjs +2 -0
  48. package/dist/theme-CiNzdl-9.mjs.map +1 -0
  49. package/dist/util/index.d.mts +4 -0
  50. package/dist/util/index.mjs +3 -0
  51. package/dist/util-Tq9PSjK0.mjs +1113 -0
  52. package/dist/util-Tq9PSjK0.mjs.map +1 -0
  53. package/dist/values-8di32lIe.d.mts +56 -0
  54. package/dist/values-8di32lIe.d.mts.map +1 -0
  55. package/package.json +7 -6
  56. package/dist/index-CHGFwCCQ.d.mts +0 -266
  57. package/dist/index-CpNwAcem.d.mts +0 -169
  58. package/dist/index-DdXU1_sq.d.mts +0 -5029
  59. package/dist/util/values.d.mts +0 -2
  60. package/dist/util/values.mjs +0 -2
  61. package/dist/values-CVIZcTRw.mjs +0 -371
  62. package/dist/values-DQfI1FSg.d.mts +0 -426
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["unzipSync","strFromU8"],"sources":["../src/opc/relationships.ts","../src/opc/media.ts","../src/opc/content-types.ts","../src/opc/app-properties.ts","../src/opc/custom-properties.ts","../src/opc/parser.ts","../src/opc/opc-consistency.ts","../src/opc/part-registry.ts","../src/opc/content-type-overrides.ts"],"sourcesContent":["import { escapeXml } from \"@office-open/xml\";\n\nimport type { XmlifyedFile } from \"./packer\";\n\nexport type RelationshipType =\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/image\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\"\n | \"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramQuickStyle\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors\"\n | \"http://schemas.microsoft.com/office/2007/relationships/diagramLayout\"\n | \"http://schemas.microsoft.com/office/2007/relationships/diagramStyle\"\n | \"http://schemas.microsoft.com/office/2007/relationships/diagramColors\"\n | \"http://schemas.microsoft.com/office/2007/relationships/diagramDrawing\"\n // WordprocessingML specific\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/header\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/custom-properties\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/bibliography\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/glossaryDocument\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/font\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/subDocument\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject\"\n // PresentationML specific\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideMaster\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesSlide\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/tableStyles\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/handoutMaster\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideSyncProperties\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/commentAuthors\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/video\"\n | \"http://schemas.microsoft.com/office/2007/relationships/media\"\n // SpreadsheetML specific\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/calcChain\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/vmlDrawing\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotTable\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheDefinition\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/pivotCacheRecords\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/table\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLink\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/externalLinkPath\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionHeaders\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/revisionLog\"\n | \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/users\";\n\nexport const TargetModeType = {\n EXTERNAL: \"External\",\n} as const;\n\ninterface RelationshipEntry {\n id: string;\n type: RelationshipType;\n target: string;\n targetMode?: string;\n}\n\n/**\n * Manages OOXML relationship entries and serializes to XML.\n *\n * Standalone class — no XmlComponent inheritance.\n * Pure string concatenation for zero-allocation XML output.\n */\nexport class Relationships {\n private entries: RelationshipEntry[] = [];\n\n public addRelationship(\n id: number | string,\n type: RelationshipType,\n target: string,\n targetMode?: (typeof TargetModeType)[keyof typeof TargetModeType],\n ): void {\n this.entries.push({ id: `rId${id}`, type, target, targetMode });\n }\n\n public get relationshipCount(): number {\n return this.entries.length;\n }\n\n /** Directly builds XML string — zero intermediate tree allocation. */\n public serialize(): string {\n const p: string[] = [\n '<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">',\n ];\n for (const e of this.entries) {\n const tm = e.targetMode ? ` TargetMode=\"${escapeXml(e.targetMode)}\"` : \"\";\n p.push(\n `<Relationship Id=\"${escapeXml(e.id)}\" Type=\"${escapeXml(e.type)}\" Target=\"${escapeXml(e.target)}\"${tm}/>`,\n );\n }\n p.push(\"</Relationships>\");\n return p.join(\"\");\n }\n}\n\n/**\n * Serialize a Relationships part only when it carries at least one\n * relationship. Optional parts (fontTable, headers, footers, charts, drawings,\n * worksheets, …) emit no .rels part when empty — Office strips empty rels\n * shells when re-saving, so skipping them keeps generated packages free of\n * redundant empty parts and matches Office's normalized output.\n *\n * Always-on parts (the package `_rels/.rels` and the main\n * document/presentation/workbook parts) carry relationships by construction\n * and must NOT use this gate.\n */\nexport function optionalRelsPart(\n rel: Relationships,\n xmlDeclaration: string,\n path: string,\n): XmlifyedFile | undefined {\n return rel.relationshipCount > 0 ? { data: xmlDeclaration + rel.serialize(), path } : undefined;\n}\n","/**\n * Content-deduplicated media collection for OOXML packages.\n *\n * Stores image entries keyed by file name. `addMedia` deduplicates by raw byte\n * content — byte-identical images referenced N times share one file, while\n * per-image metadata (transformation, extent, fallback) stays with each\n * reference in its own drawing XML and is passed via the `build` callback so it\n * never participates in the dedup key.\n *\n * Lookup is O(1) amortized: a `WeakMap` memoizes the resolved entry per input\n * `Uint8Array` (the hot path — a single document reuses the same buffer object\n * for repeated references), and an FNV-1a hash index resolves cross-object\n * duplicates (e.g. a freshly-decoded buffer carrying bytes already seen) with a\n * one-time byte verification to rule out hash collisions.\n *\n * @module\n */\n\n/**\n * Minimum fields every media entry carries. Package-specific entry types\n * extend this with their own transformation/extent/fallback fields.\n */\nexport interface BaseMediaEntry {\n fileName: string;\n data: Uint8Array;\n type: string;\n}\n\n/**\n * FNV-1a hash is a pure function of the bytes, so memoize it across\n * {@link Media} instances — repeated `generate()` calls that reuse the same\n * buffer objects (the common case) skip recomputation entirely.\n */\nconst hashKeyCache = new WeakMap<Uint8Array, string>();\n\n/**\n * Shared media collection for docx/pptx/xlsx. Generic over the package's entry\n * type so each package keeps its own metadata while sharing the registration +\n * dedup logic.\n */\nexport class Media<T extends BaseMediaEntry> {\n private readonly map = new Map<string, T>();\n /** FNV-1a content key (\"len:hash\") -> canonical file name, for cross-object dedup. */\n private readonly byContent = new Map<string, string>();\n /** Memoized result per input buffer — the repeated-reference hot path. */\n private readonly verified = new WeakMap<Uint8Array, string>();\n private counter = 0;\n\n /**\n * Register media, reusing the existing entry when the bytes already exist.\n * Returns the canonical entry (shared across all identical references) —\n * callers read `entry.fileName` for placeholders/relationship targets or use\n * the whole entry (e.g. drawing XML). The `build` callback constructs the\n * package-specific entry from the allocated file name.\n *\n * Pass `fileName` to pin the name (round-trip scenarios preserving a source\n * file name); omit it to allocate the next sequential `imageN.ext`.\n */\n public addMedia(\n data: Uint8Array,\n type: string,\n build: (fileName: string) => T,\n fileName?: string,\n ): T {\n // Hot path: the same buffer object referenced repeatedly resolves instantly.\n // The cached entry must match the requested type — identical bytes registered\n // under a different type (e.g. EMF bytes also carried as WMF in an\n // mc:AlternateContent fallback) are distinct resources with different\n // content-types and must NOT collapse into one part.\n const verifiedName = this.verified.get(data);\n if (verifiedName !== undefined) {\n const existing = this.map.get(verifiedName)!;\n if (existing.type === type) return existing;\n }\n\n // Type-scoped content key: same bytes under different types stay separate.\n const key = `${type}:${this.contentKey(data)}`;\n const existingName = this.byContent.get(key);\n if (existingName !== undefined) {\n const existing = this.map.get(existingName)!;\n // Hash hit — confirm bytes + type match to exclude a collision, then memoize.\n if (existing.type === type && this.byteEqual(existing.data, data)) {\n this.verified.set(data, existingName);\n return existing;\n }\n }\n\n // A pinned name may already be taken by different bytes (e.g. a\n // counter-allocated name colliding with a source basename, or two round-trip\n // paths resolving to the same name). Re-allocate rather than overwrite —\n // overwriting would silently drop the prior media's bytes.\n const resolvedName = fileName ?? this.nextName(type);\n const finalName = this.map.has(resolvedName) ? this.nextName(type) : resolvedName;\n const entry = build(finalName);\n this.map.set(finalName, entry);\n this.byContent.set(key, finalName);\n this.verified.set(data, finalName);\n return entry;\n }\n\n /** Next sequential `imageN.${type}` that isn't already in use. */\n private nextName(type: string): string {\n let name = `image${++this.counter}.${type}`;\n while (this.map.has(name)) name = `image${++this.counter}.${type}`;\n return name;\n }\n\n /** \"length:hash\" content key for `data` (FNV-1a over the raw bytes), memoized. */\n private contentKey(data: Uint8Array): string {\n const cached = hashKeyCache.get(data);\n if (cached !== undefined) return cached;\n let hash = 0x811c9dc5;\n for (const byte of data) {\n hash ^= byte;\n hash = Math.imul(hash, 0x01000193);\n }\n const key = `${data.length}:${(hash >>> 0).toString(16)}`;\n hashKeyCache.set(data, key);\n return key;\n }\n\n /** Structural equality with early exit on the first mismatch. */\n private byteEqual(a: Uint8Array, b: Uint8Array): boolean {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n }\n\n /** All registered media entries. */\n public get array(): T[] {\n return [...this.map.values()];\n }\n}\n","/**\n * Content Types components for OPC (Open Packaging Convention).\n *\n * Provides Default and Override elements used in [Content_Types].xml\n * to map file extensions and part paths to MIME content types.\n *\n * Reference: ECMA-376 Part 2, Section 10.1\n *\n * @module\n */\n\nexport interface DefaultProperties {\n contentType: string;\n extension?: string;\n}\n\n/**\n * Creates a Default element mapping a file extension to a MIME content type.\n */\nexport const createDefault = (contentType: string, extension?: string): string =>\n extension !== undefined\n ? `<Default ContentType=\"${contentType}\" Extension=\"${extension}\"/>`\n : `<Default ContentType=\"${contentType}\"/>`;\n\nexport interface OverrideProperties {\n contentType: string;\n partName?: string;\n}\n\n/**\n * Creates an Override element mapping a specific part path to a MIME content type.\n */\nexport const createOverride = (contentType: string, partName?: string): string =>\n partName !== undefined\n ? `<Override ContentType=\"${contentType}\" PartName=\"${partName}\"/>`\n : `<Override ContentType=\"${contentType}\"/>`;\n","/**\n * Extended (App) Properties module — shared OPC part (docProps/app.xml).\n *\n * Format-agnostic: CT_Properties (ISO-IEC29500-2_2016 shared-documentPropertiesExtended.xsd)\n * is identical across docx/pptx/xlsx. Each package surfaces only the fields it populates\n * (Pages/Words for docx, Slides for pptx, etc.) — all fields are optional.\n *\n * @module\n */\n\n// ── Descriptor ──\n\nimport { escapeXml } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\n\n/** xsd:boolean lexical form — spec canonical form is \"true\"/\"false\" (Word's convention). */\nconst xsdBoolean = (value: boolean): string => (value ? \"true\" : \"false\");\n\n/**\n * Options for docProps/app.xml extended properties (CT_Properties).\n *\n * Only the scalar (string/number/boolean) child elements are modelled.\n * Structured vector/blob elements (HeadingPairs, TitlesOfParts, HLinks,\n * DigSig, PresentationFormat) are intentionally omitted.\n *\n * Property order follows the CT_Properties xsd:all sequence so the\n * emitted XML matches the reference schema ordering.\n */\nexport interface AppPropertiesOptions {\n /** Template name */\n template?: string;\n /** Manager name */\n manager?: string;\n /** Company name */\n company?: string;\n /** Page count */\n pages?: number;\n /** Word count */\n words?: number;\n /** Character count */\n characters?: number;\n /** Line count */\n lines?: number;\n /** Paragraph count */\n paragraphs?: number;\n /** Notes count */\n notes?: number;\n /** Slides count */\n slides?: number;\n /** Total editing time (minutes) */\n totalTime?: number;\n /** Hidden slides count */\n hiddenSlides?: number;\n /** Multimedia clips count */\n mmClips?: number;\n /** Characters including spaces */\n charactersWithSpaces?: number;\n /** Document security level */\n docSecurity?: number;\n /** Hyperlink base URL */\n hyperlinkBase?: string;\n /** Application name */\n application?: string;\n /** Application version */\n appVersion?: string;\n /** Whether the document is scaled/cropped */\n scaleCrop?: boolean;\n /** Whether links are up to date */\n linksUpToDate?: boolean;\n /** Whether the document is shared */\n sharedDoc?: boolean;\n /** Whether hyperlinks changed */\n hyperlinksChanged?: boolean;\n}\n\n/** Subset of AppPropertiesOptions accepted by stringify. */\nexport type AppPropertiesInput = AppPropertiesOptions;\n\nexport const appPropertiesDesc: CustomDescriptor<AppPropertiesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n // xsd:all is unordered, but emit in schema order for readability.\n const p: string[] = [\n '<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/extended-properties\"' +\n ' xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">',\n ];\n\n // Schema order: Template, Manager, Company, Pages, Words, Characters,\n // PresentationFormat, Lines, Paragraphs, Slides, Notes, TotalTime,\n // HiddenSlides, MMClips, ScaleCrop, HeadingPairs, TitlesOfParts,\n // LinksUpToDate, CharactersWithSpaces, SharedDoc, HyperlinkBase, HLinks,\n // HyperlinksChanged, DigSig, Application, AppVersion, DocSecurity.\n if (opts.template !== undefined) p.push(`<Template>${escapeXml(opts.template)}</Template>`);\n if (opts.manager !== undefined) p.push(`<Manager>${escapeXml(opts.manager)}</Manager>`);\n if (opts.company !== undefined) p.push(`<Company>${escapeXml(opts.company)}</Company>`);\n if (opts.pages !== undefined) p.push(`<Pages>${opts.pages}</Pages>`);\n if (opts.words !== undefined) p.push(`<Words>${opts.words}</Words>`);\n if (opts.characters !== undefined) p.push(`<Characters>${opts.characters}</Characters>`);\n if (opts.lines !== undefined) p.push(`<Lines>${opts.lines}</Lines>`);\n if (opts.paragraphs !== undefined) p.push(`<Paragraphs>${opts.paragraphs}</Paragraphs>`);\n if (opts.slides !== undefined) p.push(`<Slides>${opts.slides}</Slides>`);\n if (opts.notes !== undefined) p.push(`<Notes>${opts.notes}</Notes>`);\n if (opts.totalTime !== undefined) p.push(`<TotalTime>${opts.totalTime}</TotalTime>`);\n if (opts.hiddenSlides !== undefined)\n p.push(`<HiddenSlides>${opts.hiddenSlides}</HiddenSlides>`);\n if (opts.mmClips !== undefined) p.push(`<MMClips>${opts.mmClips}</MMClips>`);\n if (opts.scaleCrop !== undefined)\n p.push(`<ScaleCrop>${xsdBoolean(opts.scaleCrop)}</ScaleCrop>`);\n if (opts.linksUpToDate !== undefined)\n p.push(`<LinksUpToDate>${xsdBoolean(opts.linksUpToDate)}</LinksUpToDate>`);\n if (opts.charactersWithSpaces !== undefined)\n p.push(`<CharactersWithSpaces>${opts.charactersWithSpaces}</CharactersWithSpaces>`);\n if (opts.sharedDoc !== undefined)\n p.push(`<SharedDoc>${xsdBoolean(opts.sharedDoc)}</SharedDoc>`);\n if (opts.hyperlinkBase !== undefined)\n p.push(`<HyperlinkBase>${escapeXml(opts.hyperlinkBase)}</HyperlinkBase>`);\n if (opts.hyperlinksChanged !== undefined)\n p.push(`<HyperlinksChanged>${xsdBoolean(opts.hyperlinksChanged)}</HyperlinksChanged>`);\n if (opts.application !== undefined)\n p.push(`<Application>${escapeXml(opts.application)}</Application>`);\n if (opts.appVersion !== undefined)\n p.push(`<AppVersion>${escapeXml(opts.appVersion)}</AppVersion>`);\n if (opts.docSecurity !== undefined) p.push(`<DocSecurity>${opts.docSecurity}</DocSecurity>`);\n\n p.push(\"</Properties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const result: AppPropertiesOptions = {};\n for (const child of el.elements ?? []) {\n if (typeof child.name !== \"string\") continue;\n const text = child.elements?.[0]?.text;\n switch (child.name) {\n case \"Template\":\n if (typeof text === \"string\") result.template = text;\n break;\n case \"Manager\":\n if (typeof text === \"string\") result.manager = text;\n break;\n case \"Company\":\n if (typeof text === \"string\") result.company = text;\n break;\n case \"Pages\":\n if (typeof text === \"string\") result.pages = Number(text);\n break;\n case \"Words\":\n if (typeof text === \"string\") result.words = Number(text);\n break;\n case \"Characters\":\n if (typeof text === \"string\") result.characters = Number(text);\n break;\n case \"Lines\":\n if (typeof text === \"string\") result.lines = Number(text);\n break;\n case \"Paragraphs\":\n if (typeof text === \"string\") result.paragraphs = Number(text);\n break;\n case \"Slides\":\n if (typeof text === \"string\") result.slides = Number(text);\n break;\n case \"Notes\":\n if (typeof text === \"string\") result.notes = Number(text);\n break;\n case \"TotalTime\":\n if (typeof text === \"string\") result.totalTime = Number(text);\n break;\n case \"HiddenSlides\":\n if (typeof text === \"string\") result.hiddenSlides = Number(text);\n break;\n case \"MMClips\":\n if (typeof text === \"string\") result.mmClips = Number(text);\n break;\n case \"ScaleCrop\":\n if (typeof text === \"string\") result.scaleCrop = text === \"1\" || text === \"true\";\n break;\n case \"LinksUpToDate\":\n if (typeof text === \"string\") result.linksUpToDate = text === \"1\" || text === \"true\";\n break;\n case \"CharactersWithSpaces\":\n if (typeof text === \"string\") result.charactersWithSpaces = Number(text);\n break;\n case \"SharedDoc\":\n if (typeof text === \"string\") result.sharedDoc = text === \"1\" || text === \"true\";\n break;\n case \"HyperlinkBase\":\n if (typeof text === \"string\") result.hyperlinkBase = text;\n break;\n case \"HyperlinksChanged\":\n if (typeof text === \"string\") result.hyperlinksChanged = text === \"1\" || text === \"true\";\n break;\n case \"Application\":\n if (typeof text === \"string\") result.application = text;\n break;\n case \"AppVersion\":\n if (typeof text === \"string\") result.appVersion = text;\n break;\n case \"DocSecurity\":\n if (typeof text === \"string\") result.docSecurity = Number(text);\n break;\n }\n }\n return result;\n },\n};\n","/**\n * Custom Properties module — shared OPC part (docProps/custom.xml).\n *\n * Format-agnostic: CT_CustomProperties (ISO-IEC29500-4_2016 shared-documentPropertiesCustom.xsd)\n * is identical across docx/pptx/xlsx.\n *\n * @module\n */\n\nimport { attr, escapeXml, textOf } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\n\n/**\n * Options for a single custom property.\n *\n * @property name - The property name\n * @property value - The property value (as string)\n */\nexport interface CustomPropertyOptions {\n /** The property name */\n name: string;\n /** The property value (as string) */\n value: string;\n}\n\n/** Input shape for the custom-properties descriptor. */\nexport interface CustomPropertiesInput {\n properties: CustomPropertyOptions[];\n}\n\nexport const customPropertiesDesc: CustomDescriptor<CustomPropertiesInput> = {\n kind: \"custom\",\n\n stringify(opts, _ctx) {\n const p: string[] = [\n '<Properties xmlns=\"http://schemas.openxmlformats.org/officeDocument/2006/custom-properties\"' +\n ' xmlns:vt=\"http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes\">',\n ];\n let pid = 2;\n for (const prop of opts.properties) {\n p.push(\n `<property fmtid=\"{D5CDD505-2E9C-101B-9397-08002B2CF9AE}\" pid=\"${pid}\" name=\"${escapeXml(prop.name)}\">` +\n `<vt:lpwstr>${escapeXml(prop.value)}</vt:lpwstr>` +\n `</property>`,\n );\n pid++;\n }\n p.push(\"</Properties>\");\n return p.join(\"\");\n },\n\n parse(el, _ctx) {\n const properties: CustomPropertyOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"property\") continue;\n const name = attr(child, \"name\");\n if (!name) continue;\n\n // Find the value element (vt:lpwstr, vt:lpstr, vt:i4, etc.)\n const valueEl = child.elements?.find((e) => e.name?.startsWith(\"vt:\"));\n const value = valueEl ? (textOf(valueEl) ?? \"\") : \"\";\n properties.push({ name, value });\n }\n return { properties };\n },\n};\n","import { xml2js, js2xml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\nimport { unzipSync, zipSync, strFromU8, strToU8, type Zippable } from \"fflate\";\n\nimport { hasNativeInflate, nativeUnzip } from \"./zip-native\";\n\nconst XML_PARSE_OPTIONS = {\n nativeTypeAttributes: true,\n captureSpacesBetweenElements: true,\n};\n\n/**\n * Parsed OOXML archive backed by an unzipped ZIP map.\n *\n * Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)\n * for reading and modifying individual parts, then serializing back to a ZIP buffer.\n */\nexport class ParsedArchive {\n private readonly zip: Map<string, Uint8Array>;\n private readonly modified = new Map<string, Uint8Array>();\n private readonly wrapperCache = new Map<string, Element>();\n\n public constructor(data: Uint8Array) {\n // Native inflate is the fast path; on any failure (unsupported ZIP variant\n // or corruption) fall back to fflate unzipSync, the reference implementation.\n let unzipped: Record<string, Uint8Array>;\n try {\n unzipped = hasNativeInflate() ? nativeUnzip(data) : unzipSync(data);\n } catch {\n unzipped = unzipSync(data);\n }\n this.zip = new Map(Object.entries(unzipped));\n }\n\n /** Read an XML part as an Element tree. */\n public get(path: string): Element | undefined {\n // Check modified first\n const modData = this.modified.get(path);\n if (modData) {\n const wrapper = xml2js(strFromU8(modData), XML_PARSE_OPTIONS) as Element;\n this.wrapperCache.set(path, wrapper);\n return wrapper.elements?.find((e) => e.type === \"element\");\n }\n\n const data = this.zip.get(path);\n if (data === undefined) return undefined;\n\n // Try cache\n const cached = this.wrapperCache.get(path);\n if (cached) return cached.elements?.find((e) => e.type === \"element\");\n\n // Parse and cache\n const wrapper = xml2js(strFromU8(data), XML_PARSE_OPTIONS) as Element;\n this.wrapperCache.set(path, wrapper);\n return wrapper.elements?.find((e) => e.type === \"element\");\n }\n\n /** Write an XML part (Element → XML string). */\n public set(path: string, element: Element): void {\n const wrapper = this.wrapperCache.get(path);\n const doc: Element = wrapper\n ? { ...wrapper, elements: [{ ...element, type: \"element\" as const }] }\n : { elements: [{ ...element, type: \"element\" as const }] };\n const xml = js2xml(doc);\n this.modified.set(path, strToU8(xml));\n }\n\n /** Read raw binary data (images, media, etc.). */\n public getRaw(path: string): Uint8Array | undefined {\n return this.modified.get(path) ?? this.zip.get(path);\n }\n\n /** Write raw binary data. */\n public setRaw(path: string, data: Uint8Array): void {\n this.modified.set(path, data);\n this.wrapperCache.delete(path);\n }\n\n /** Remove a part. Returns true if it existed. */\n public remove(path: string): boolean {\n this.wrapperCache.delete(path);\n return this.modified.delete(path) || this.zip.delete(path);\n }\n\n /** Check if a part exists. */\n public has(path: string): boolean {\n return this.modified.has(path) || this.zip.has(path);\n }\n\n /** List all paths matching an optional prefix. */\n public keys(prefix?: string): string[] {\n const all = new Set<string>();\n for (const key of this.zip.keys()) {\n if (!prefix || key.startsWith(prefix)) all.add(key);\n }\n for (const key of this.modified.keys()) {\n if (!prefix || key.startsWith(prefix)) all.add(key);\n }\n return [...all];\n }\n\n /** Serialize back to a ZIP buffer, merging original zip + modifications. */\n public save(): Uint8Array {\n const files: Zippable = {};\n for (const [path, data] of this.zip) {\n if (!this.modified.has(path)) {\n files[path] = isMediaPath(path) ? [data, { level: MEDIA_STORED_LEVEL }] : data;\n }\n }\n for (const [path, data] of this.modified) {\n files[path] = isMediaPath(path) ? [data, { level: MEDIA_STORED_LEVEL }] : data;\n }\n return zipSync(files);\n }\n}\n\n/** Media file extensions that should use STORE (no compression). */\nconst MEDIA_EXTENSIONS = new Set([\n \".png\",\n \".jpg\",\n \".jpeg\",\n \".gif\",\n \".wmf\",\n \".emf\",\n \".tif\",\n \".tiff\",\n \".avi\",\n \".mp4\",\n \".mp3\",\n \".wav\",\n]);\n\n/** Check if a file path has a media extension that should use STORE (no compression). */\nfunction isMediaPath(path: string): boolean {\n const dot = path.lastIndexOf(\".\");\n if (dot === -1) return false;\n return MEDIA_EXTENSIONS.has(path.slice(dot).toLowerCase());\n}\n\n/** STORE level for already-compressed media formats. */\nconst MEDIA_STORED_LEVEL = 0;\n\n/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedArchive. */\nexport function parseArchive(data: Uint8Array): ParsedArchive {\n return new ParsedArchive(data);\n}\n","/**\n * OPC (Open Packaging Convention) consistency validator.\n *\n * Pure function operating on an already-unzipped part map. Detects the three\n * classes of cross-part breakage that single-part XSD validation cannot see:\n *\n * - relationship integrity — dangling targets, duplicate rIds (O3/O7)\n * - content-type integrity — parts with no Override/Default, stale\n * Overrides pointing at absent parts (O5/O6)\n * - structural integrity — missing `always` parts, undeclared orphans\n * (O1/O2)\n *\n * O3/O5/O6/O7 are derived directly from the ZIP + `.rels` + `[Content_Types].xml`\n * and need no registry. O1/O2 consult {@link PackagePartRegistry}.\n *\n * Reference: ECMA-376 Part 2 (OPC).\n *\n * @module\n */\nimport { xml2js } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { PackagePartRegistry } from \"./part-registry\";\n\nexport type OpcSeverity = \"error\" | \"warn\";\n\nexport type OpcCode = \"O1\" | \"O2\" | \"O3\" | \"O5\" | \"O6\" | \"O7\";\n\nexport interface OpcIssue {\n code: OpcCode;\n severity: OpcSeverity;\n /** Path of the offending part, `.rels`, or Override `PartName`. */\n part: string;\n message: string;\n}\n\ninterface RelationshipEntry {\n id: string;\n type: string;\n target: string;\n targetMode?: string;\n}\n\ninterface ParsedRels {\n relsPath: string;\n entries: readonly RelationshipEntry[];\n}\n\ninterface ContentTypesDoc {\n defaults: ReadonlyMap<string, string>;\n overrides: ReadonlyMap<string, string>;\n}\n\n// ── XML parsing helpers ─────────────────────────────────────────────────────\n\nfunction rootElement(xml: string): Element | undefined {\n try {\n const wrapper = xml2js(xml) as Element;\n return wrapper.elements?.find((e) => e.type === \"element\");\n } catch {\n return undefined;\n }\n}\n\nfunction parseContentTypes(entries: ReadonlyMap<string, string>): ContentTypesDoc {\n const defaults = new Map<string, string>();\n const overrides = new Map<string, string>();\n const xml = entries.get(\"[Content_Types].xml\");\n const root = xml ? rootElement(xml) : undefined;\n if (!root) return { defaults, overrides };\n for (const child of root.elements ?? []) {\n if (child.type !== \"element\") continue;\n if (child.name === \"Default\") {\n const ext = String(child.attributes?.Extension ?? \"\").toLowerCase();\n const ct = String(child.attributes?.ContentType ?? \"\");\n if (ext && ct) defaults.set(ext, ct);\n } else if (child.name === \"Override\") {\n const partName = normalizePartName(String(child.attributes?.PartName ?? \"\"));\n const ct = String(child.attributes?.ContentType ?? \"\");\n if (partName && ct) overrides.set(partName, ct);\n }\n }\n return { defaults, overrides };\n}\n\nfunction parseAllRels(entries: ReadonlyMap<string, string>): ParsedRels[] {\n const out: ParsedRels[] = [];\n for (const [relsPath, xml] of entries) {\n if (!relsPath.endsWith(\".rels\")) continue;\n const root = rootElement(xml);\n if (!root) continue;\n const list: RelationshipEntry[] = [];\n for (const child of root.elements ?? []) {\n if (child.type !== \"element\" || child.name !== \"Relationship\") continue;\n list.push({\n id: String(child.attributes?.Id ?? \"\"),\n type: String(child.attributes?.Type ?? \"\"),\n target: String(child.attributes?.Target ?? \"\"),\n targetMode: child.attributes?.TargetMode ? String(child.attributes?.TargetMode) : undefined,\n });\n }\n out.push({ relsPath, entries: list });\n }\n return out;\n}\n\n/** Strip the leading slash OPC uses on `PartName` to align with ZIP paths. */\nfunction normalizePartName(partName: string): string {\n return partName.startsWith(\"/\") ? partName.slice(1) : partName;\n}\n\n/**\n * Resolve a relationship `Target` (relative to its owning `.rels`) against the\n * ZIP root. Handles the `..` segments slides/masters use to reference siblings.\n */\nfunction resolveRelTarget(relsPath: string, target: string): string {\n const slash = relsPath.lastIndexOf(\"/\");\n const relsDir = slash === -1 ? \"\" : relsPath.slice(0, slash);\n // `<partDir>/_rels` → `<partDir>`; root-level `_rels` → \"\"\n const base =\n relsDir === \"_rels\" ? \"\" : relsDir.endsWith(\"/_rels\") ? relsDir.slice(0, -6) : relsDir;\n const segments = (base ? base.split(\"/\") : []).concat(target.split(\"/\"));\n const resolved: string[] = [];\n for (const seg of segments) {\n if (seg === \"\" || seg === \".\") continue;\n if (seg === \"..\") resolved.pop();\n else resolved.push(seg);\n }\n return resolved.join(\"/\");\n}\n\n/** Compile a registry path template (with `${i}`) into an anchored matcher. */\nfunction pathMatcher(template: string): RegExp {\n const marked = template.replace(/\\$\\{i\\}/g, \"\u0000\");\n const escaped = marked.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n const pattern = escaped.replace(/\u0000/g, \"(\\\\d+)\");\n return new RegExp(`^${pattern}$`);\n}\n\nfunction extensionOf(path: string): string {\n const dot = path.lastIndexOf(\".\");\n return dot === -1 ? \"\" : path.slice(dot + 1).toLowerCase();\n}\n\n// ── Validator ───────────────────────────────────────────────────────────────\n\n/**\n * Validate OPC consistency of an unzipped package.\n *\n * @param entries ZIP path → decoded XML/binary text. Binary parts (media,\n * fonts) are never parsed here — only their presence matters.\n * @param registry Declarative part expectations for the package format.\n * @returns Issues sorted by code then part. Empty array = consistent.\n */\nexport function validateOpcConsistency(\n entries: ReadonlyMap<string, string>,\n registry: PackagePartRegistry,\n): OpcIssue[] {\n const issues: OpcIssue[] = [];\n const contentTypes = parseContentTypes(entries);\n const relsFiles = parseAllRels(entries);\n\n // O2 — missing `always` part. Conditional/repeated absences are legitimate.\n for (const def of registry.parts) {\n if (def.presence.kind !== \"always\" || def.path.includes(\"${i}\")) continue;\n if (!entries.has(def.path)) {\n issues.push({\n code: \"O2\",\n severity: \"error\",\n part: def.path,\n message: `required ${registry.format} part is absent from the package`,\n });\n }\n }\n\n // O1 — orphan part: present but not declared and not whitelisted.\n const matchers = registry.parts.map((def) => pathMatcher(def.path));\n for (const path of entries.keys()) {\n if (path === \"[Content_Types].xml\") continue;\n if (path.endsWith(\".rels\")) continue;\n if (registry.orphanWhitelist.some((prefix) => path.startsWith(prefix))) continue;\n if (matchers.some((re) => re.test(path))) continue;\n issues.push({\n code: \"O1\",\n severity: \"warn\",\n part: path,\n message: `part not declared in the ${registry.format} registry (possible orphan)`,\n });\n }\n\n // O3 — dangling internal relationship target.\n for (const rf of relsFiles) {\n for (const rel of rf.entries) {\n if (rel.targetMode === \"External\") continue;\n if (/^https?:\\/\\//i.test(rel.target)) continue;\n const resolved = resolveRelTarget(rf.relsPath, rel.target);\n if (!resolved || entries.has(resolved)) continue;\n issues.push({\n code: \"O3\",\n severity: \"error\",\n part: rf.relsPath,\n message: `relationship ${rel.id || \"(no Id)\"} (${rel.type}) Target \"${rel.target}\" resolves to absent part \"${resolved}\"`,\n });\n }\n }\n\n // O5 — part present but no Override covers it and no Default covers its\n // extension. Word rejects such parts as unreadable content.\n for (const path of entries.keys()) {\n if (path === \"[Content_Types].xml\" || path.endsWith(\".rels\")) continue;\n if (contentTypes.overrides.has(path)) continue;\n const ext = extensionOf(path);\n if (ext && contentTypes.defaults.has(ext)) continue;\n issues.push({\n code: \"O5\",\n severity: \"error\",\n part: path,\n message: `part has no [Content_Types] Override and no Default covers extension \"${ext || \"(none)\"}\"`,\n });\n }\n\n // O6 — stale Override: [Content_Types] declares a part that is not in the ZIP.\n for (const partName of contentTypes.overrides.keys()) {\n if (entries.has(partName)) continue;\n issues.push({\n code: \"O6\",\n severity: \"error\",\n part: `/${partName}`,\n message: `[Content_Types] Override references absent part \"${partName}\"`,\n });\n }\n\n // O7 — duplicate relationship Id within a single .rels part.\n for (const rf of relsFiles) {\n const counts = new Map<string, number>();\n for (const rel of rf.entries) {\n if (!rel.id) continue;\n counts.set(rel.id, (counts.get(rel.id) ?? 0) + 1);\n }\n for (const [id, count] of counts) {\n if (count <= 1) continue;\n issues.push({\n code: \"O7\",\n severity: \"warn\",\n part: rf.relsPath,\n message: `duplicate relationship Id \"${id}\" appears ${count} times`,\n });\n }\n }\n\n return issues.sort((a, b) =>\n a.code === b.code ? a.part.localeCompare(b.part) : a.code.localeCompare(b.code),\n );\n}\n\nexport function summarizeOpcIssues(issues: readonly OpcIssue[]): {\n errors: number;\n warnings: number;\n} {\n let errors = 0;\n let warnings = 0;\n for (const i of issues) {\n if (i.severity === \"error\") errors++;\n else warnings++;\n }\n return { errors, warnings };\n}\n","/**\n * Declarative part registry — the machine-readable source of truth for which\n * parts each OOXML package is expected to contain.\n *\n * Consumed by {@link validateOpcConsistency} to detect two failure classes the\n * XSD single-part validator cannot see:\n * - O1 orphan part — a part present in the ZIP that no rule accounts for\n * - O2 missing part — an `always` part the ZIP lacks\n *\n * Content-type and relationship integrity (O3/O5/O6/O7) are derived directly\n * from the ZIP + `.rels` + `[Content_Types].xml`, so they need no registry.\n *\n * Presence semantics:\n * - `always` — present in *any* valid package (content-types map,\n * root rels, main part only). O2 fires when absent. Kept\n * minimal so template/round-trip packages — whose\n * `[Content_Types]` and part set are passed through from a\n * source rather than rebuilt — do not false-positive.\n * - `conditional` — emitted by a fresh `compileDocument` run but a\n * round-tripped/template package may omit it. Absence is\n * legitimate; O6 (stale Override) still catches the case\n * where its content type is declared but the part is gone.\n * - `repeated` — one per index (slides, worksheets, headers, …).\n *\n * Reference: ECMA-376 Part 2 (OPC). Content-type values mirror the per-package\n * `content-types.ts` builders; relationship `@Type` URLs mirror\n * {@link RelationshipType}.\n *\n * @module\n */\n\nexport type PartPresence =\n | { readonly kind: \"always\" }\n | { readonly kind: \"conditional\"; readonly flag: string }\n | { readonly kind: \"repeated\"; readonly countFrom: string };\n\nexport interface PartDef {\n /**\n * ZIP path template. `${i}` expands per repeated index (1-based); a template\n * without the placeholder denotes a singleton part.\n */\n path: string;\n /**\n * `[Content_Types].xml` Override value the part carries when generated.\n * `undefined` when the part relies on a `<Default>` extension mapping\n * (e.g. media, fonts, docx theme under raw-part passthrough).\n */\n contentType?: string;\n presence: PartPresence;\n}\n\nexport interface PackagePartRegistry {\n format: \"docx\" | \"pptx\" | \"xlsx\";\n parts: readonly PartDef[];\n /**\n * Path prefixes that are always legitimate even when undeclared — media,\n * fonts, embeddings, altChunks, custom XML, and `.rels` parts. Used to\n * suppress O1 false positives from round-tripped / pass-through content.\n */\n orphanWhitelist: readonly string[];\n}\n\n// ── DOCX ────────────────────────────────────────────────────────────────────\n\nexport const DOCX_PARTS = {\n format: \"docx\",\n orphanWhitelist: [\n \"word/media/\",\n \"word/fonts/\",\n \"word/embeddings/\",\n \"word/afchunks/\",\n \"customXml/\",\n \"_rels/\",\n \"word/_rels/\",\n \"docProps/\",\n \"[Content_Types].xml\",\n ],\n parts: [\n { path: \"[Content_Types].xml\", presence: { kind: \"always\" } },\n { path: \"_rels/.rels\", presence: { kind: \"always\" } },\n {\n path: \"word/document.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\",\n presence: { kind: \"always\" },\n },\n {\n path: \"word/styles.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"word/numbering.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"word/footnotes.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"word/endnotes.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"word/settings.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"word/fontTable.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"docProps/core.xml\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"docProps/app.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n // The compiler writes docProps/custom.xml unconditionally (even with an\n // empty customProperties list), so its Override is unconditional too —\n // gated on freshCompile to match the always-write behaviour. Gate it on\n // hasCustomProperties and the part would ship with no content-type.\n path: \"docProps/custom.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.custom-properties+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"word/comments.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml\",\n presence: { kind: \"conditional\", flag: \"hasComments\" },\n },\n {\n path: \"word/header${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml\",\n presence: { kind: \"repeated\", countFrom: \"headerCount\" },\n },\n {\n path: \"word/footer${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml\",\n presence: { kind: \"repeated\", countFrom: \"footerCount\" },\n },\n {\n path: \"word/charts/chart${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\",\n presence: { kind: \"repeated\", countFrom: \"chartCount\" },\n },\n {\n path: \"word/diagrams/data${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArtCount\" },\n },\n {\n path: \"word/diagrams/layout${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArtCount\" },\n },\n {\n path: \"word/diagrams/quickStyle${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArtCount\" },\n },\n {\n path: \"word/diagrams/colors${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArtCount\" },\n },\n {\n path: \"word/diagrams/drawing${i}.xml\",\n contentType: \"application/vnd.ms-office.drawingml.diagramDrawing+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArtCount\" },\n },\n {\n path: \"word/bibliography.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.bibliography+xml\",\n presence: { kind: \"conditional\", flag: \"hasBibliography\" },\n },\n {\n path: \"word/glossary/document.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.glossary+xml\",\n presence: { kind: \"conditional\", flag: \"hasGlossary\" },\n },\n {\n path: \"word/webSettings.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml\",\n presence: { kind: \"conditional\", flag: \"hasWebSettings\" },\n },\n // docx theme — fresh-compile generates a language-neutral default theme\n // (createThemeXml); round-trip passes the source theme through rawParts.\n // Declared as a theme+xml Override to match Word's own packages.\n {\n path: \"word/theme/theme1.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.theme+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n ],\n} as const satisfies PackagePartRegistry;\n\n// ── PPTX ────────────────────────────────────────────────────────────────────\n\nexport const PPTX_PARTS = {\n format: \"pptx\",\n orphanWhitelist: [\n \"ppt/media/\",\n \"ppt/embeddings/\",\n \"_rels/\",\n \"ppt/_rels/\",\n \"ppt/slideMasters/_rels/\",\n \"ppt/slideLayouts/_rels/\",\n \"ppt/slides/_rels/\",\n \"ppt/notesMasters/_rels/\",\n \"ppt/notesSlides/_rels/\",\n \"ppt/charts/_rels/\",\n \"ppt/diagrams/_rels/\",\n \"docProps/\",\n \"[Content_Types].xml\",\n ],\n parts: [\n { path: \"[Content_Types].xml\", presence: { kind: \"always\" } },\n { path: \"_rels/.rels\", presence: { kind: \"always\" } },\n {\n path: \"ppt/presentation.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml\",\n presence: { kind: \"always\" },\n },\n {\n path: \"docProps/core.xml\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"docProps/app.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n // theme1 backs the slide master (static); theme2/theme3 back the\n // notes/handout masters when present — all share the theme+xml type.\n path: \"ppt/theme/theme${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.theme+xml\",\n presence: { kind: \"repeated\", countFrom: \"masters + notes/handout masters\" },\n },\n {\n path: \"ppt/presProps.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.presProps+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"ppt/viewProps.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"ppt/tableStyles.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"ppt/slideMasters/slideMaster${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml\",\n presence: { kind: \"repeated\", countFrom: \"masters.length\" },\n },\n {\n path: \"ppt/slideLayouts/slideLayout${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml\",\n presence: { kind: \"repeated\", countFrom: \"layouts.length\" },\n },\n {\n path: \"ppt/slides/slide${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.slide+xml\",\n presence: { kind: \"repeated\", countFrom: \"slides.length\" },\n },\n {\n path: \"ppt/notesMasters/notesMaster1.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml\",\n presence: { kind: \"conditional\", flag: \"any slide has notes\" },\n },\n {\n path: \"ppt/handoutMasters/handoutMaster1.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml\",\n presence: { kind: \"conditional\", flag: \"includeHandoutMaster\" },\n },\n {\n path: \"ppt/notesSlides/notesSlide${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml\",\n presence: { kind: \"repeated\", countFrom: \"slides with notes\" },\n },\n {\n path: \"ppt/commentAuthors.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml\",\n presence: { kind: \"conditional\", flag: \"any slide has comments\" },\n },\n {\n path: \"ppt/comments/comment${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.presentationml.comments+xml\",\n presence: { kind: \"repeated\", countFrom: \"slides with comments\" },\n },\n {\n path: \"ppt/charts/chart${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\",\n presence: { kind: \"repeated\", countFrom: \"charts\" },\n },\n {\n path: \"ppt/diagrams/data${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArts\" },\n },\n {\n path: \"ppt/diagrams/layout${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArts\" },\n },\n {\n path: \"ppt/diagrams/quickStyle${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArts\" },\n },\n {\n path: \"ppt/diagrams/colors${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArts\" },\n },\n {\n path: \"ppt/diagrams/drawing${i}.xml\",\n contentType: \"application/vnd.ms-office.drawingml.diagramDrawing+xml\",\n presence: { kind: \"repeated\", countFrom: \"smartArts\" },\n },\n {\n path: \"ppt/slideSyncPr/slideSyncPr${i}.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.presentationml.slideSyncProperties+xml\",\n presence: { kind: \"repeated\", countFrom: \"slides with slideSync\" },\n },\n ],\n} as const satisfies PackagePartRegistry;\n\n// ── XLSX ────────────────────────────────────────────────────────────────────\n\nexport const XLSX_PARTS = {\n format: \"xlsx\",\n orphanWhitelist: [\n \"xl/media/\",\n \"xl/embeddings/\",\n \"_rels/\",\n \"xl/_rels/\",\n \"xl/worksheets/_rels/\",\n \"xl/chartsheets/_rels/\",\n \"xl/drawings/_rels/\",\n \"xl/pivotTables/_rels/\",\n \"xl/pivotCache/_rels/\",\n \"xl/externalLinks/_rels/\",\n \"docProps/\",\n \"[Content_Types].xml\",\n ],\n parts: [\n { path: \"[Content_Types].xml\", presence: { kind: \"always\" } },\n { path: \"_rels/.rels\", presence: { kind: \"always\" } },\n {\n path: \"xl/workbook.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\",\n presence: { kind: \"always\" },\n },\n {\n path: \"docProps/core.xml\",\n contentType: \"application/vnd.openxmlformats-package.core-properties+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"docProps/app.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.extended-properties+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"xl/styles.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n path: \"xl/theme/theme1.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.theme+xml\",\n presence: { kind: \"conditional\", flag: \"freshCompile\" },\n },\n {\n // Override is emitted unconditionally; the part file is only written\n // when the shared-strings table is non-empty — an O6 stale-Override\n // risk this registry exists to surface.\n path: \"xl/sharedStrings.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml\",\n presence: { kind: \"conditional\", flag: \"sharedStrings.count > 0\" },\n },\n {\n path: \"xl/worksheets/sheet${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\",\n presence: { kind: \"repeated\", countFrom: \"worksheets.length\" },\n },\n {\n path: \"xl/chartsheets/sheet${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml\",\n presence: { kind: \"repeated\", countFrom: \"chartsheets.length\" },\n },\n {\n path: \"xl/drawings/drawing${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawing+xml\",\n presence: { kind: \"conditional\", flag: \"worksheet has drawing\" },\n },\n {\n path: \"xl/comments${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml\",\n presence: { kind: \"conditional\", flag: \"worksheet.comments.length > 0\" },\n },\n {\n // Legacy VML drawing backing older comment anchors; relies on the `vml`\n // Default added by ContentTypes.addVmlDrawing().\n path: \"xl/drawings/vmlDrawing${i}.vml\",\n presence: { kind: \"conditional\", flag: \"worksheet.comments (legacy VML)\" },\n },\n {\n path: \"xl/charts/chart${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.drawingml.chart+xml\",\n presence: { kind: \"repeated\", countFrom: \"charts\" },\n },\n {\n path: \"xl/pivotTables/pivotTable${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml\",\n presence: { kind: \"repeated\", countFrom: \"pivotTables\" },\n },\n {\n path: \"xl/pivotCache/pivotCacheDefinition${i}.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml\",\n presence: { kind: \"repeated\", countFrom: \"pivotCaches\" },\n },\n {\n path: \"xl/pivotCache/pivotCacheRecords${i}.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml\",\n presence: { kind: \"repeated\", countFrom: \"pivotCaches\" },\n },\n {\n path: \"xl/tables/table${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml\",\n presence: { kind: \"repeated\", countFrom: \"tables\" },\n },\n {\n path: \"xl/externalLinks/externalLink${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml\",\n presence: { kind: \"repeated\", countFrom: \"externalLinks.length\" },\n },\n {\n path: \"xl/calcChain.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml\",\n presence: { kind: \"conditional\", flag: \"any formula cell\" },\n },\n {\n path: \"xl/revisionHeaders.xml\",\n contentType:\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionHeaders+xml\",\n presence: { kind: \"conditional\", flag: \"revisionLog\" },\n },\n {\n path: \"xl/revisions/revision${i}.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.revisionLog+xml\",\n presence: { kind: \"repeated\", countFrom: \"revisionLog.logs.length\" },\n },\n {\n path: \"xl/users.xml\",\n contentType: \"application/vnd.openxmlformats-officedocument.spreadsheetml.users+xml\",\n presence: { kind: \"conditional\", flag: \"revisionLog.users\" },\n },\n ],\n} as const satisfies PackagePartRegistry;\n\nexport const PART_REGISTRIES: Record<PackagePartRegistry[\"format\"], PackagePartRegistry> = {\n docx: DOCX_PARTS,\n pptx: PPTX_PARTS,\n xlsx: XLSX_PARTS,\n};\n","/**\n * Build [Content_Types].xml Override entries from a part registry.\n *\n * The per-package content-types builders previously hand-wrote every Override\n * branch (header/footer counts, the hasComments gate, …), which drifted from\n * the part registry and caused OPC mismatches (#357: a comments Override\n * declared with no part, and vice-versa). This helper drives Overrides from\n * {@link PackagePartRegistry} so the part list and its content-type\n * declarations share one source of truth.\n *\n * Only parts carrying a `contentType` produce an Override — parts that rely on\n * a `<Default>` extension mapping (`[Content_Types].xml`, `.rels`, the\n * raw-passed theme) are skipped. Dynamic parts whose count or path is\n * runtime-determined (altChunks, sub-documents) stay out of the registry and\n * are appended by the caller.\n *\n * @module\n */\n\nimport type { PackagePartRegistry } from \"./part-registry\";\n\nexport interface ContentTypeOverrideEntry {\n partName: string;\n contentType: string;\n}\n\n/** Ensure a part path carries the leading slash an Override PartName requires. */\nfunction withLeadingSlash(partPath: string): string {\n return partPath.startsWith(\"/\") ? partPath : `/${partPath}`;\n}\n\n/**\n * Derive [Content_Types].xml Override entries for every registry part present\n * under `facts`. The `facts` keys mirror the registry's `flag` / `countFrom`\n * tokens: a boolean for `conditional` parts, a count for `repeated` parts.\n * Order follows `registry.parts`; OPC does not mandate Override order.\n */\nexport function buildContentTypeOverrides(\n registry: PackagePartRegistry,\n facts: ReadonlyMap<string, boolean | number>,\n): ContentTypeOverrideEntry[] {\n const overrides: ContentTypeOverrideEntry[] = [];\n for (const part of registry.parts) {\n // Parts without a contentType rely on a <Default> extension mapping.\n if (!part.contentType) continue;\n const presence = part.presence;\n if (presence.kind === \"always\") {\n // Singletons only — an `always` template with `${i}` would be a registry bug.\n if (!part.path.includes(\"${i}\")) {\n overrides.push({ partName: withLeadingSlash(part.path), contentType: part.contentType });\n }\n } else if (presence.kind === \"conditional\") {\n if (facts.get(presence.flag)) {\n overrides.push({ partName: withLeadingSlash(part.path), contentType: part.contentType });\n }\n } else {\n const count = Number(facts.get(presence.countFrom) ?? 0);\n for (let i = 1; i <= count; i++) {\n overrides.push({\n partName: withLeadingSlash(part.path.replace(\"${i}\", String(i))),\n contentType: part.contentType,\n });\n }\n }\n }\n return overrides;\n}\n"],"mappings":";;;;;;;;;;;AAsEA,MAAa,iBAAiB,EA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AK,QAAQ,QAAQ,OAAO,CAAC,CAAC,CAAC;IAC/D,aAAa,KAAK;GACpB,CAAC;EAEL;CACF;CACA,OAAO;AACT"}
@@ -0,0 +1,24 @@
1
+ import { Buffer } from "\u0000polyfill-node.buffer";
2
+
3
+ //#region src/opc/output.d.ts
4
+ interface OutputByType {
5
+ base64: string;
6
+ string: string;
7
+ text: string;
8
+ binarystring: string;
9
+ array: readonly number[];
10
+ uint8array: Uint8Array;
11
+ arraybuffer: ArrayBuffer;
12
+ blob: Blob;
13
+ nodebuffer: Buffer;
14
+ }
15
+ type OutputType = keyof OutputByType;
16
+ declare const OoxmlMimeType: {
17
+ readonly DOCX: "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
18
+ readonly PPTX: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
19
+ readonly XLSX: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
20
+ };
21
+ declare const convertOutput: <T extends OutputType>(data: Uint8Array, type: T, mimeType?: string) => OutputByType[T];
22
+ //#endregion
23
+ export { convertOutput as i, OutputByType as n, OutputType as r, OoxmlMimeType as t };
24
+ //# sourceMappingURL=output-D_G_JR_8.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"output-D_G_JR_8.d.mts","names":[],"sources":["../src/opc/output.ts"],"mappings":";;;UAUiB,YAAA;EACf,MAAA;EACA,MAAA;EACA,IAAA;EACA,YAAA;EACA,KAAA;EACA,UAAA,EAAY,UAAA;EACZ,WAAA,EAAa,WAAA;EACb,IAAA,EAAM,IAAA;EACN,UAAA,EAAY,MAAA;AAAA;AAAA,KAGF,UAAA,SAAmB,YAAY;AAAA,cAG9B,aAAA;EAAA;;;;cAMA,aAAA,aAA2B,UAAA,EACtC,IAAA,EAAM,UAAA,EACN,IAAA,EAAM,CAAA,EACN,QAAA,cACC,YAAA,CAAa,CAAA"}
@@ -1,2 +1,2 @@
1
- import { C as XmlNamespaceConfig, S as PPTX_NS, _ as RenderedParagraphNode, a as getNextRelationshipIndex, b as createReplacer, c as createTextElementContents, d as patchSpaceAttribute, f as toJson, g as createTraverser, h as createTokenReplacer, i as appendRelationship, l as getFirstLevelElements, m as createSplitInject, n as PlaceholderDelimiters, o as appendContentType, p as TokenNotFoundError, r as applyCorePropertiesOverride, s as appendOverride, t as BasePatchOptions, u as nextNumericId, v as createRunRenderer, x as DOCX_NS, y as ReplacerConfig } from "../index-CHGFwCCQ.mjs";
2
- export { type BasePatchOptions, DOCX_NS, PPTX_NS, type PlaceholderDelimiters, type RenderedParagraphNode, type ReplacerConfig, TokenNotFoundError, type XmlNamespaceConfig, appendContentType, appendOverride, appendRelationship, applyCorePropertiesOverride, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, nextNumericId, patchSpaceAttribute, toJson };
1
+ import { C as XmlNamespaceOptions, S as PPTX_NS, _ as RenderedParagraphNode, a as getNextRelationshipIndex, b as createReplacer, c as createTextElementContents, d as patchSpaceAttribute, f as toJson, g as createTraverser, h as createTokenReplacer, i as appendRelationship, l as getFirstLevelElements, m as createSplitInject, n as PlaceholderDelimiters, o as appendContentType, p as TokenNotFoundError, r as applyCorePropertiesOverride, s as appendOverride, t as BasePatchOptions, u as nextNumericId, v as createRunRenderer, x as DOCX_NS, y as ReplacerOptions } from "../index-k8WKLXnA.mjs";
2
+ export { type BasePatchOptions, DOCX_NS, PPTX_NS, type PlaceholderDelimiters, type RenderedParagraphNode, type ReplacerOptions, TokenNotFoundError, type XmlNamespaceOptions, appendContentType, appendOverride, appendRelationship, applyCorePropertiesOverride, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, nextNumericId, patchSpaceAttribute, toJson };
@@ -1,2 +1,2 @@
1
- import { _ as DOCX_NS, a as appendOverride, c as createRunRenderer, d as createSplitInject, f as createTextElementContents, g as toJson, h as patchSpaceAttribute, i as appendContentType, l as createTokenReplacer, m as nextNumericId, n as appendRelationship, o as createReplacer, p as getFirstLevelElements, r as getNextRelationshipIndex, s as createTraverser, t as applyCorePropertiesOverride, u as TokenNotFoundError, v as PPTX_NS } from "../patch-OSbQIQAi.mjs";
1
+ import { _ as DOCX_NS, a as appendOverride, c as createRunRenderer, d as createSplitInject, f as createTextElementContents, g as toJson, h as patchSpaceAttribute, i as appendContentType, l as createTokenReplacer, m as nextNumericId, n as appendRelationship, o as createReplacer, p as getFirstLevelElements, r as getNextRelationshipIndex, s as createTraverser, t as applyCorePropertiesOverride, u as TokenNotFoundError, v as PPTX_NS } from "../patch-BmRfghOo.mjs";
2
2
  export { DOCX_NS, PPTX_NS, TokenNotFoundError, appendContentType, appendOverride, appendRelationship, applyCorePropertiesOverride, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, nextNumericId, patchSpaceAttribute, toJson };
@@ -61,34 +61,6 @@ function parseCorePropsElement(el) {
61
61
  }
62
62
  return props;
63
63
  }
64
- const CORE_PROPS_NS = Object.freeze({ _attr: Object.freeze({
65
- "xmlns:cp": "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
66
- "xmlns:dc": "http://purl.org/dc/elements/1.1/",
67
- "xmlns:dcmitype": "http://purl.org/dcmitype/",
68
- "xmlns:dcterms": "http://purl.org/dc/terms/",
69
- "xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance"
70
- }) });
71
- const W3CDTF_ATTR = Object.freeze({ _attr: Object.freeze({ "xsi:type": "dcterms:W3CDTF" }) });
72
- /**
73
- * Build a cp:coreProperties XML object from metadata.
74
- *
75
- * Shared by docx and pptx to avoid duplicating namespace declarations
76
- * and Dublin Core property construction.
77
- */
78
- function buildCorePropertiesXml(opts) {
79
- const children = [CORE_PROPS_NS];
80
- if (opts.title) children.push({ "dc:title": [opts.title] });
81
- if (opts.subject) children.push({ "dc:subject": [opts.subject] });
82
- if (opts.creator) children.push({ "dc:creator": [opts.creator] });
83
- if (opts.keywords) children.push({ "cp:keywords": [opts.keywords] });
84
- if (opts.description) children.push({ "dc:description": [opts.description] });
85
- children.push({ "cp:lastModifiedBy": [opts.lastModifiedBy || opts.creator || "Unknown"] });
86
- if (opts.revision) children.push({ "cp:revision": [String(opts.revision)] });
87
- const now = (/* @__PURE__ */ new Date()).toISOString();
88
- children.push({ "dcterms:created": [W3CDTF_ATTR, now] });
89
- children.push({ "dcterms:modified": [W3CDTF_ATTR, now] });
90
- return { "cp:coreProperties": children };
91
- }
92
64
  /**
93
65
  * Build a cp:coreProperties XML string directly (fast path).
94
66
  *
@@ -179,14 +151,12 @@ var TokenNotFoundError = class extends Error {
179
151
  function createSplitInject(ns, createTextElementContents, options) {
180
152
  const preserveSpace = options?.preserveSpace ?? true;
181
153
  const findRunElementIndexWithToken = (paragraphElement, token) => {
182
- for (let i = 0; i < (paragraphElement.elements ?? []).length; i++) {
183
- const element = paragraphElement.elements[i];
184
- if (element.type === "element" && element.name === ns.run) {
185
- const textElement = (element.elements ?? []).filter((e) => e.type === "element" && e.name === ns.text);
186
- for (const text of textElement) {
187
- if (!text.elements?.[0]) continue;
188
- if (text.elements[0].text.includes(token)) return i;
189
- }
154
+ for (const [i, element] of (paragraphElement.elements ?? []).entries()) if (element.type === "element" && element.name === ns.run) {
155
+ const textElement = (element.elements ?? []).filter((e) => e.type === "element" && e.name === ns.text);
156
+ for (const text of textElement) {
157
+ const firstChild = text.elements?.[0];
158
+ if (!firstChild) continue;
159
+ if (firstChild.text.includes(token)) return i;
190
160
  }
191
161
  }
192
162
  throw new TokenNotFoundError(token);
@@ -239,28 +209,33 @@ function createTokenReplacer(createTextElementContents, options) {
239
209
  const startIndex = renderedParagraph.text.indexOf(originalText);
240
210
  const endIndex = startIndex + originalText.length - 1;
241
211
  let replaceMode = ReplaceMode.START;
242
- for (const run of renderedParagraph.runs) for (const { text, index, start, end } of run.parts) switch (replaceMode) {
243
- case ReplaceMode.START:
244
- if (startIndex >= start && startIndex <= end) {
245
- const offsetStartIndex = startIndex - start;
246
- const offsetEndIndex = Math.min(endIndex, end) - start;
247
- const partToReplace = text.substring(offsetStartIndex, offsetEndIndex + 1);
248
- if (partToReplace === "") continue;
249
- const firstPart = text.replace(partToReplace, replacementText);
250
- patchTextElement(paragraphElement.elements[run.index].elements[index], firstPart);
251
- replaceMode = ReplaceMode.MIDDLE;
252
- continue;
212
+ for (const run of renderedParagraph.runs) {
213
+ const runChildren = paragraphElement.elements?.[run.index]?.elements;
214
+ if (!runChildren) continue;
215
+ for (const { text, index, start, end } of run.parts) {
216
+ const partElement = runChildren[index];
217
+ if (!partElement) continue;
218
+ switch (replaceMode) {
219
+ case ReplaceMode.START:
220
+ if (startIndex >= start && startIndex <= end) {
221
+ const offsetStartIndex = startIndex - start;
222
+ const offsetEndIndex = Math.min(endIndex, end) - start;
223
+ const partToReplace = text.substring(offsetStartIndex, offsetEndIndex + 1);
224
+ if (partToReplace === "") continue;
225
+ patchTextElement(partElement, text.replace(partToReplace, replacementText));
226
+ replaceMode = ReplaceMode.MIDDLE;
227
+ continue;
228
+ }
229
+ break;
230
+ case ReplaceMode.MIDDLE:
231
+ if (endIndex <= end) {
232
+ patchTextElement(partElement, text.substring(endIndex - start + 1));
233
+ runChildren[index] = preserveSpace ? patchSpaceAttribute(partElement) : partElement;
234
+ replaceMode = ReplaceMode.END;
235
+ } else patchTextElement(partElement, "");
236
+ break;
253
237
  }
254
- break;
255
- case ReplaceMode.MIDDLE:
256
- if (endIndex <= end) {
257
- const lastPart = text.substring(endIndex - start + 1);
258
- patchTextElement(paragraphElement.elements[run.index].elements[index], lastPart);
259
- const currentElement = paragraphElement.elements[run.index].elements[index];
260
- paragraphElement.elements[run.index].elements[index] = preserveSpace ? patchSpaceAttribute(currentElement) : currentElement;
261
- replaceMode = ReplaceMode.END;
262
- } else patchTextElement(paragraphElement.elements[run.index].elements[index], "");
263
- break;
238
+ }
264
239
  }
265
240
  return paragraphElement;
266
241
  };
@@ -278,13 +253,10 @@ function createRunRenderer(ns) {
278
253
  };
279
254
  let currentRunStringLength = 0;
280
255
  const runs = [];
281
- for (let i = 0; i < node.element.elements.length; i++) {
282
- const element = node.element.elements[i];
283
- if (element.name === ns.run) {
284
- const renderedRunNode = renderRunNode(element, i, currentRunStringLength);
285
- currentRunStringLength += renderedRunNode.text.length;
286
- runs.push(renderedRunNode);
287
- }
256
+ for (const [i, element] of node.element.elements.entries()) if (element.name === ns.run) {
257
+ const renderedRunNode = renderRunNode(element, i, currentRunStringLength);
258
+ currentRunStringLength += renderedRunNode.text.length;
259
+ runs.push(renderedRunNode);
288
260
  }
289
261
  const text = runs.reduce((acc, curr) => acc + curr.text, "");
290
262
  return {
@@ -304,20 +276,22 @@ function createRunRenderer(ns) {
304
276
  };
305
277
  let currentTextStringIndex = currentRunStringIndex;
306
278
  const parts = [];
307
- for (let i = 0; i < node.elements.length; i++) {
308
- const element = node.elements[i];
309
- if (element.name === ns.text && element.elements && element.elements.length > 0) {
310
- const text = element.elements[0].text ?? "";
311
- const textStr = String(text);
312
- const partStart = currentTextStringIndex;
313
- currentTextStringIndex += textStr.length;
314
- parts.push({
315
- end: currentTextStringIndex - 1,
316
- index: i,
317
- start: partStart,
318
- text: textStr
319
- });
320
- }
279
+ for (const [i, element] of node.elements.entries()) {
280
+ if (element.name !== ns.text) continue;
281
+ const textChildren = element.elements;
282
+ if (!textChildren || textChildren.length === 0) continue;
283
+ const firstChild = textChildren[0];
284
+ if (!firstChild) continue;
285
+ const text = firstChild.text ?? "";
286
+ const textStr = String(text);
287
+ const partStart = currentTextStringIndex;
288
+ currentTextStringIndex += textStr.length;
289
+ parts.push({
290
+ end: currentTextStringIndex - 1,
291
+ index: i,
292
+ start: partStart,
293
+ text: textStr
294
+ });
321
295
  }
322
296
  const text = parts.reduce((acc, curr) => acc + curr.text, "");
323
297
  return {
@@ -354,8 +328,8 @@ function createTraverser(ns) {
354
328
  index: 0,
355
329
  parent: void 0
356
330
  };
357
- for (let i = 0; i < rootChildren.length; i++) queue.push({
358
- element: rootChildren[i],
331
+ for (const [i, child] of rootChildren.entries()) queue.push({
332
+ element: child,
359
333
  index: i,
360
334
  parent: root
361
335
  });
@@ -363,10 +337,11 @@ function createTraverser(ns) {
363
337
  let qi = 0;
364
338
  while (qi < queue.length) {
365
339
  const current = queue[qi++];
340
+ if (!current) break;
366
341
  if (current.element.name === ns.paragraph) renderedParagraphs.push(renderParagraphNode(current));
367
342
  const children = current.element.elements;
368
- if (children) for (let i = 0; i < children.length; i++) queue.push({
369
- element: children[i],
343
+ if (children) for (const [i, child] of children.entries()) queue.push({
344
+ element: child,
370
345
  index: i,
371
346
  parent: current
372
347
  });
@@ -412,6 +387,7 @@ function createReplacer(config) {
412
387
  });
413
388
  const index = findRunElementIndexWithToken(paragraphElement, SPLIT_TOKEN);
414
389
  const runElementToBeReplaced = paragraphElement.elements[index];
390
+ if (!runElementToBeReplaced) break;
415
391
  const { left, right } = splitRunElement(runElementToBeReplaced, SPLIT_TOKEN);
416
392
  let newRunElements = textJson;
417
393
  let patchedRightElement = right;
@@ -445,7 +421,10 @@ const goToElementFromPath = (json, path) => {
445
421
  let element = json;
446
422
  for (let i = 1; i < path.length; i++) {
447
423
  const index = path[i];
448
- element = element.elements[index];
424
+ if (index === void 0) break;
425
+ const next = element.elements[index];
426
+ if (!next) break;
427
+ element = next;
449
428
  }
450
429
  return element;
451
430
  };
@@ -526,4 +505,6 @@ function applyCorePropertiesOverride(corePropsDoc, overrides) {
526
505
  });
527
506
  }
528
507
  //#endregion
529
- export { DOCX_NS as _, appendOverride as a, buildCorePropertiesXmlString as b, createRunRenderer as c, createSplitInject as d, createTextElementContents as f, toJson as g, patchSpaceAttribute as h, appendContentType as i, createTokenReplacer as l, nextNumericId as m, appendRelationship as n, createReplacer as o, getFirstLevelElements as p, getNextRelationshipIndex as r, createTraverser as s, applyCorePropertiesOverride as t, TokenNotFoundError as u, PPTX_NS as v, parseCorePropsElement as x, buildCorePropertiesXml as y };
508
+ export { DOCX_NS as _, appendOverride as a, parseCorePropsElement as b, createRunRenderer as c, createSplitInject as d, createTextElementContents as f, toJson as g, patchSpaceAttribute as h, appendContentType as i, createTokenReplacer as l, nextNumericId as m, appendRelationship as n, createReplacer as o, getFirstLevelElements as p, getNextRelationshipIndex as r, createTraverser as s, applyCorePropertiesOverride as t, TokenNotFoundError as u, PPTX_NS as v, buildCorePropertiesXmlString as y };
509
+
510
+ //# sourceMappingURL=patch-BmRfghOo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patch-BmRfghOo.mjs","names":[],"sources":["../src/opc/core.ts","../src/patch/xml-namespace.ts","../src/patch/xml-patch-utils.ts","../src/patch/paragraph-split-inject.ts","../src/patch/paragraph-token-replacer.ts","../src/patch/run-renderer.ts","../src/patch/xml-traverser.ts","../src/patch/xml-replacer.ts","../src/patch/content-types-manager.ts","../src/patch/relationship-manager.ts","../src/patch/core-properties-override.ts"],"sourcesContent":["import { textOf, escapeXml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * Core document properties (docProps/core.xml).\n *\n * Shared across docx/pptx/xlsx: each format's top-level Options extends this,\n * parse emits the same shape, and patch overrides it — read/write symmetry\n * (CONTRIBUTING §Property Naming). Field names follow the OPC core-properties\n * XSD element local names (`creator` = dc:creator, … — never `author`).\n */\nexport interface CorePropertiesOptions {\n title?: string;\n subject?: string;\n creator?: string;\n keywords?: string;\n description?: string;\n lastModifiedBy?: string;\n revision?: number;\n lastPrinted?: string;\n /** Creation timestamp (W3CDTF), round-tripped from dcterms:created. */\n created?: string;\n /** Last modified timestamp (W3CDTF), round-tripped from dcterms:modified. */\n modified?: string;\n}\n\nconst FIELD_MAP: Array<{ name: string; key: keyof CorePropertiesOptions }> = [\n { name: \"dc:title\", key: \"title\" },\n { name: \"dc:subject\", key: \"subject\" },\n { name: \"dc:creator\", key: \"creator\" },\n { name: \"dc:description\", key: \"description\" },\n { name: \"cp:keywords\", key: \"keywords\" },\n { name: \"cp:lastModifiedBy\", key: \"lastModifiedBy\" },\n { name: \"cp:lastPrinted\", key: \"lastPrinted\" },\n { name: \"dcterms:created\", key: \"created\" },\n { name: \"dcterms:modified\", key: \"modified\" },\n];\n\n/**\n * Parse core properties from an already-parsed XML element.\n * Shared by docx/pptx/xlsx to extract Dublin Core metadata into the unified\n * {@link CorePropertiesOptions} shape.\n */\nexport function parseCorePropsElement(el: Element | undefined): CorePropertiesOptions {\n if (!el) return {};\n\n const props: CorePropertiesOptions = {};\n\n for (const field of FIELD_MAP) {\n const child = el.elements?.find((e) => e.name === field.name);\n const value = textOf(child) || undefined;\n if (value) (props as Record<string, unknown>)[field.key] = value;\n }\n\n const revEl = el.elements?.find((e) => e.name === \"cp:revision\");\n if (revEl) {\n const rev = textOf(revEl);\n if (rev) {\n const n = Number(rev);\n if (!Number.isNaN(n)) props.revision = n;\n }\n }\n\n return props;\n}\n\n/**\n * Build a cp:coreProperties XML string directly (fast path).\n *\n * Shared by pptx and xlsx to bypass the toXml() → xml() pipeline.\n * created/modified default to now when not supplied; all other fields emit\n * only when present.\n */\nexport function buildCorePropertiesXmlString(opts: CorePropertiesOptions): string {\n const p: string[] = [\n '<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcmitype=\"http://purl.org/dcmitype/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">',\n ];\n if (opts.title) p.push(`<dc:title>${escapeXml(opts.title)}</dc:title>`);\n if (opts.subject) p.push(`<dc:subject>${escapeXml(opts.subject)}</dc:subject>`);\n if (opts.creator) p.push(`<dc:creator>${escapeXml(opts.creator)}</dc:creator>`);\n if (opts.keywords) p.push(`<cp:keywords>${escapeXml(opts.keywords)}</cp:keywords>`);\n if (opts.description) p.push(`<dc:description>${escapeXml(opts.description)}</dc:description>`);\n if (opts.lastPrinted) p.push(`<cp:lastPrinted>${escapeXml(opts.lastPrinted)}</cp:lastPrinted>`);\n p.push(\n `<cp:lastModifiedBy>${escapeXml(opts.lastModifiedBy || opts.creator || \"Unknown\")}</cp:lastModifiedBy>`,\n );\n if (opts.revision !== undefined) p.push(`<cp:revision>${opts.revision}</cp:revision>`);\n\n const now = new Date().toISOString();\n p.push(`<dcterms:created xsi:type=\"dcterms:W3CDTF\">${opts.created ?? now}</dcterms:created>`);\n p.push(`<dcterms:modified xsi:type=\"dcterms:W3CDTF\">${opts.modified ?? now}</dcterms:modified>`);\n p.push(\"</cp:coreProperties>\");\n return p.join(\"\");\n}\n","/**\n * Namespace configuration for XML patch operations.\n *\n * Parameterises element names so the same patch algorithm works for both\n * DOCX (`w:*`) and PPTX (`a:*`) documents.\n */\n\nexport interface XmlNamespaceOptions {\n paragraph: string;\n run: string;\n text: string;\n runProperties: string;\n}\n\nexport const DOCX_NS: XmlNamespaceOptions = {\n paragraph: \"w:p\",\n run: \"w:r\",\n text: \"w:t\",\n runProperties: \"w:rPr\",\n};\n\nexport const PPTX_NS: XmlNamespaceOptions = {\n paragraph: \"a:p\",\n run: \"a:r\",\n text: \"a:t\",\n runProperties: \"a:rPr\",\n};\n","/**\n * XML utility functions for patch operations.\n */\nimport { xml2js } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nexport const toJson = (xmlData: string): Element => {\n const xmlObj = xml2js(xmlData, {\n captureSpacesBetweenElements: true,\n compact: false,\n }) as Element;\n return xmlObj;\n};\n\n/**\n * Creates the inner content of a text element (`w:t` / `a:t`).\n *\n * Returns `[{ type: \"text\", text }]` for non-empty text, `[]` for empty.\n * The `xml:space` attribute is handled separately by `patchSpaceAttribute`.\n */\nexport const createTextElementContents = (text: string): Element[] =>\n text === \"\" ? [] : [{ text, type: \"text\" }];\n\nexport const patchSpaceAttribute = (element: Element): Element => ({\n ...element,\n attributes: {\n \"xml:space\": \"preserve\",\n },\n});\n\nexport const getFirstLevelElements = (relationships: Element, id: string): Element[] =>\n relationships.elements?.find((e) => e.name === id)?.elements ?? [];\n\n/**\n * Next sequential numeric id: the largest `attr` value among direct children\n * named `childName`, plus one. `seed` is the floor — e.g. PPTX `<p:sldId>`\n * values start at 255, so the first appended id is at least 256.\n *\n * Unifies the per-package `maxCommentId` / `maxSldId` / `maxSheetId` helpers.\n */\nexport const nextNumericId = (\n parent: Element | undefined,\n childName: string,\n attr: string,\n seed = 0,\n): number => {\n let maxId = seed;\n for (const child of parent?.elements ?? []) {\n if (child.name !== childName) continue;\n const id = Number(child.attributes?.[attr]);\n if (Number.isFinite(id)) maxId = Math.max(maxId, id);\n }\n return maxId + 1;\n};\n","/**\n * Paragraph split and inject utilities for run-level text replacement.\n *\n * Parameterised by `XmlNamespaceOptions` so it works for both DOCX and PPTX.\n */\nimport type { Element } from \"@office-open/xml\";\n\nimport type { XmlNamespaceOptions } from \"./xml-namespace\";\nimport { patchSpaceAttribute } from \"./xml-patch-utils\";\n\nexport class TokenNotFoundError extends Error {\n public constructor(token: string) {\n super(`Token ${token} not found`);\n this.name = \"TokenNotFoundError\";\n }\n}\n\nexport function createSplitInject(\n ns: XmlNamespaceOptions,\n createTextElementContents: (text: string) => Element[],\n options?: { readonly preserveSpace?: boolean },\n) {\n const preserveSpace = options?.preserveSpace ?? true;\n const findRunElementIndexWithToken = (paragraphElement: Element, token: string): number => {\n for (const [i, element] of (paragraphElement.elements ?? []).entries()) {\n if (element.type === \"element\" && element.name === ns.run) {\n const textElement = (element.elements ?? []).filter(\n (e) => e.type === \"element\" && e.name === ns.text,\n );\n\n for (const text of textElement) {\n const firstChild = text.elements?.[0];\n if (!firstChild) {\n continue;\n }\n\n if ((firstChild.text as string).includes(token)) {\n return i;\n }\n }\n }\n }\n\n throw new TokenNotFoundError(token);\n };\n\n const splitRunElement = (\n runElement: Element,\n token: string,\n ): { readonly left: Element; readonly right: Element } => {\n let splitIndex = -1;\n\n const splitElements =\n runElement.elements\n ?.map((e, i) => {\n if (splitIndex !== -1) {\n return e;\n }\n\n if (e.type === \"element\" && e.name === ns.text) {\n const text = (e.elements?.[0]?.text as string) ?? \"\";\n const splitText = text.split(token);\n const newElements = splitText.map((t) => ({\n ...e,\n ...(preserveSpace ? patchSpaceAttribute(e) : {}),\n elements: createTextElementContents(t),\n }));\n\n if (splitText.length > 1) {\n splitIndex = i;\n }\n\n return newElements;\n } else {\n return e;\n }\n })\n .flat() ?? [];\n\n const leftRunElement: Element = {\n ...runElement,\n elements: splitElements.slice(0, splitIndex + 1),\n };\n\n const rightRunElement: Element = {\n ...runElement,\n elements: splitElements.slice(splitIndex + 1),\n };\n\n return { left: leftRunElement, right: rightRunElement };\n };\n\n return { findRunElementIndexWithToken, splitRunElement };\n}\n","/**\n * Paragraph token replacer for substituting text within paragraph runs.\n *\n * Fully generic — operates on Element nodes without namespace-specific logic.\n */\nimport type { Element } from \"@office-open/xml\";\n\nimport type { RenderedParagraphNode } from \"./run-renderer\";\nimport { patchSpaceAttribute } from \"./xml-patch-utils\";\n\nconst ReplaceMode = {\n START: 0,\n MIDDLE: 1,\n END: 2,\n} as const;\n\nexport function createTokenReplacer(\n createTextElementContents: (text: string) => Element[],\n options?: { readonly preserveSpace?: boolean },\n) {\n const preserveSpace = options?.preserveSpace ?? true;\n\n const patchTextElement = (element: Element, text: string): Element => {\n element.elements = createTextElementContents(text);\n return element;\n };\n\n return ({\n paragraphElement,\n renderedParagraph,\n originalText,\n replacementText,\n }: {\n paragraphElement: Element;\n renderedParagraph: RenderedParagraphNode;\n originalText: string;\n replacementText: string;\n }): Element => {\n const startIndex = renderedParagraph.text.indexOf(originalText);\n const endIndex = startIndex + originalText.length - 1;\n\n let replaceMode: (typeof ReplaceMode)[keyof typeof ReplaceMode] = ReplaceMode.START;\n\n for (const run of renderedParagraph.runs) {\n const runChildren = paragraphElement.elements?.[run.index]?.elements;\n if (!runChildren) continue;\n for (const { text, index, start, end } of run.parts) {\n const partElement = runChildren[index];\n if (!partElement) continue;\n switch (replaceMode) {\n case ReplaceMode.START: {\n if (startIndex >= start && startIndex <= end) {\n const offsetStartIndex = startIndex - start;\n const offsetEndIndex = Math.min(endIndex, end) - start;\n const partToReplace = text.substring(offsetStartIndex, offsetEndIndex + 1);\n if (partToReplace === \"\") {\n continue;\n }\n\n const firstPart = text.replace(partToReplace, replacementText);\n patchTextElement(partElement, firstPart);\n replaceMode = ReplaceMode.MIDDLE;\n continue;\n }\n break;\n }\n case ReplaceMode.MIDDLE: {\n if (endIndex <= end) {\n const lastPart = text.substring(endIndex - start + 1);\n patchTextElement(partElement, lastPart);\n runChildren[index] = preserveSpace ? patchSpaceAttribute(partElement) : partElement;\n replaceMode = ReplaceMode.END;\n } else {\n patchTextElement(partElement, \"\");\n }\n break;\n }\n }\n }\n }\n\n return paragraphElement;\n };\n}\n","/**\n * Run renderer for extracting text content from OOXML paragraph structures.\n *\n * Parameterised by `XmlNamespaceOptions` so it works for both DOCX and PPTX.\n */\nimport type { Element } from \"@office-open/xml\";\n\nimport type { XmlNamespaceOptions } from \"./xml-namespace\";\n\nexport interface ElementWrapper {\n element: Element;\n index: number;\n parent: ElementWrapper | undefined;\n}\n\nexport interface RenderedParagraphNode {\n text: string;\n runs: readonly RenderedRunNode[];\n index: number;\n pathToParagraph: readonly number[];\n}\n\ninterface StartAndEnd {\n start: number;\n end: number;\n}\n\ntype IParts = {\n text: string;\n index: number;\n} & StartAndEnd;\n\nexport type RenderedRunNode = {\n text: string;\n parts: readonly IParts[];\n index: number;\n} & StartAndEnd;\n\nexport function createRunRenderer(ns: XmlNamespaceOptions) {\n const renderParagraphNode = (node: ElementWrapper): RenderedParagraphNode => {\n if (node.element.name !== ns.paragraph) {\n throw new Error(`Invalid node type: ${node.element.name}`);\n }\n\n if (!node.element.elements) {\n return {\n index: -1,\n pathToParagraph: [],\n runs: [],\n text: \"\",\n };\n }\n\n let currentRunStringLength = 0;\n\n const runs: RenderedRunNode[] = [];\n for (const [i, element] of node.element.elements.entries()) {\n if (element.name === ns.run) {\n const renderedRunNode = renderRunNode(element, i, currentRunStringLength);\n currentRunStringLength += renderedRunNode.text.length;\n runs.push(renderedRunNode);\n }\n }\n\n const text = runs.reduce((acc, curr) => acc + curr.text, \"\");\n\n return {\n index: node.index,\n pathToParagraph: buildNodePath(node),\n runs,\n text,\n };\n };\n\n const renderRunNode = (\n node: Element,\n index: number,\n currentRunStringIndex: number,\n ): RenderedRunNode => {\n if (!node.elements) {\n return {\n end: currentRunStringIndex,\n index: -1,\n parts: [],\n start: currentRunStringIndex,\n text: \"\",\n };\n }\n\n let currentTextStringIndex = currentRunStringIndex;\n\n const parts: IParts[] = [];\n for (const [i, element] of node.elements.entries()) {\n if (element.name !== ns.text) continue;\n const textChildren = element.elements;\n if (!textChildren || textChildren.length === 0) continue;\n const firstChild = textChildren[0];\n if (!firstChild) continue;\n const text = firstChild.text ?? \"\";\n const textStr = String(text);\n const partStart = currentTextStringIndex;\n currentTextStringIndex += textStr.length;\n parts.push({ end: currentTextStringIndex - 1, index: i, start: partStart, text: textStr });\n }\n\n const text = parts.reduce((acc, curr) => acc + curr.text, \"\");\n\n return {\n end: currentTextStringIndex - 1,\n index,\n parts,\n start: currentRunStringIndex,\n text,\n };\n };\n\n return renderParagraphNode;\n}\n\nconst buildNodePath = (node: ElementWrapper): readonly number[] => {\n const path: number[] = [];\n let current: ElementWrapper | undefined = node;\n while (current) {\n path.push(current.index);\n current = current.parent;\n }\n path.reverse();\n return path;\n};\n","/**\n * XML traverser for searching paragraph content in OOXML documents.\n *\n * Parameterised by `XmlNamespaceOptions` so it works for both DOCX and PPTX.\n */\nimport type { Element } from \"@office-open/xml\";\n\nimport { createRunRenderer, type ElementWrapper, type RenderedParagraphNode } from \"./run-renderer\";\nimport type { XmlNamespaceOptions } from \"./xml-namespace\";\n\nexport function createTraverser(ns: XmlNamespaceOptions) {\n const renderParagraphNode = createRunRenderer(ns);\n\n const traverse = (node: Element): readonly RenderedParagraphNode[] => {\n const renderedParagraphs: RenderedParagraphNode[] = [];\n const queue: ElementWrapper[] = [];\n\n // Seed with root as virtual wrapper so paths include the root level\n const rootChildren = node.elements;\n if (rootChildren) {\n const root: ElementWrapper = { element: node, index: 0, parent: undefined };\n for (const [i, child] of rootChildren.entries()) {\n queue.push({ element: child, index: i, parent: root });\n }\n }\n\n let qi = 0;\n while (qi < queue.length) {\n const current = queue[qi++];\n if (!current) break;\n\n if (current.element.name === ns.paragraph) {\n renderedParagraphs.push(renderParagraphNode(current));\n }\n\n const children = current.element.elements;\n if (children) {\n for (const [i, child] of children.entries()) {\n queue.push({ element: child, index: i, parent: current });\n }\n }\n }\n\n return renderedParagraphs;\n };\n\n const findLocationOfText = (node: Element, text: string): readonly RenderedParagraphNode[] =>\n traverse(node).filter((p) => p.text.includes(text));\n\n return { traverse, findLocationOfText };\n}\n","/**\n * Parameterised XML replacer for placeholder substitution in OOXML documents.\n *\n * Accepts namespace config and a format callback so both DOCX and PPTX can\n * use the same replacement algorithm.\n */\nimport type { Element } from \"@office-open/xml\";\n\nimport { createSplitInject } from \"./paragraph-split-inject\";\nimport { createTokenReplacer } from \"./paragraph-token-replacer\";\nimport type { XmlNamespaceOptions } from \"./xml-namespace\";\nimport { createTextElementContents } from \"./xml-patch-utils\";\nimport { createTraverser } from \"./xml-traverser\";\n\nexport interface ReplacerOptions {\n ns: XmlNamespaceOptions;\n formatChild: (child: unknown, context: unknown) => Element[];\n preserveSpace?: boolean;\n}\n\ninterface ReplacerResult {\n element: Element;\n didFindOccurrence: boolean;\n}\n\nconst SPLIT_TOKEN = \"\\u0275\";\n\nexport function createReplacer(config: ReplacerOptions) {\n const { ns, formatChild } = config;\n const { findLocationOfText } = createTraverser(ns);\n\n const replaceTokenInParagraphElement = createTokenReplacer(createTextElementContents, {\n preserveSpace: config.preserveSpace,\n });\n const { findRunElementIndexWithToken, splitRunElement } = createSplitInject(\n ns,\n createTextElementContents,\n { preserveSpace: config.preserveSpace },\n );\n\n const replacer = ({\n json,\n patch,\n patchText,\n context,\n keepOriginalStyles = true,\n }: {\n json: Element;\n patch: {\n type: string;\n children: readonly unknown[];\n };\n patchText: string;\n context: unknown;\n keepOriginalStyles?: boolean;\n }): ReplacerResult => {\n const renderedParagraphs = findLocationOfText(json, patchText);\n\n if (renderedParagraphs.length === 0) {\n return { didFindOccurrence: false, element: json };\n }\n\n for (const renderedParagraph of renderedParagraphs) {\n const textJson = patch.children.flatMap((c) => formatChild(c, context));\n\n switch (patch.type) {\n case \"document\": {\n const parentElement = goToParentElementFromPath(json, renderedParagraph.pathToParagraph);\n const elementIndex = getLastElementIndexFromPath(renderedParagraph.pathToParagraph);\n parentElement.elements!.splice(elementIndex, 1, ...textJson);\n break;\n }\n case \"paragraph\":\n default: {\n const paragraphElement = goToElementFromPath(json, renderedParagraph.pathToParagraph);\n replaceTokenInParagraphElement({\n originalText: patchText,\n paragraphElement,\n renderedParagraph,\n replacementText: SPLIT_TOKEN,\n });\n\n const index = findRunElementIndexWithToken(paragraphElement, SPLIT_TOKEN);\n\n const runElementToBeReplaced = paragraphElement.elements![index];\n if (!runElementToBeReplaced) break;\n const { left, right } = splitRunElement(runElementToBeReplaced, SPLIT_TOKEN);\n\n let newRunElements = textJson;\n let patchedRightElement = right;\n\n if (keepOriginalStyles) {\n const runElementNonTextualElements = runElementToBeReplaced.elements!.filter(\n (e) => e.type === \"element\" && e.name === ns.runProperties,\n );\n\n newRunElements = textJson.map((e) => {\n if (\n e.type !== \"element\" ||\n e.name !== ns.run ||\n e.elements?.some((c) => c.type === \"element\" && c.name === ns.runProperties)\n ) {\n return e;\n }\n return {\n ...e,\n elements: [...runElementNonTextualElements, ...(e.elements ?? [])],\n };\n });\n\n patchedRightElement = {\n ...right,\n elements: [...runElementNonTextualElements, ...right.elements!],\n };\n }\n\n paragraphElement.elements!.splice(index, 1, left, ...newRunElements, patchedRightElement);\n break;\n }\n }\n }\n\n return { didFindOccurrence: true, element: json };\n };\n\n return replacer;\n}\n\nconst goToElementFromPath = (json: Element, path: readonly number[]): Element => {\n let element = json;\n for (let i = 1; i < path.length; i++) {\n const index = path[i];\n if (index === undefined) break;\n const nextElements = element.elements!;\n const next = nextElements[index];\n if (!next) break;\n element = next;\n }\n return element;\n};\n\nconst goToParentElementFromPath = (json: Element, path: readonly number[]): Element =>\n goToElementFromPath(json, path.slice(0, -1));\n\n// pathToParagraph is built by the renderer and always non-empty; the `!` is a contract narrow.\nconst getLastElementIndexFromPath = (path: readonly number[]): number => path[path.length - 1]!;\n","/**\n * Content types manager for OOXML [Content_Types].xml management.\n */\nimport type { Element } from \"@office-open/xml\";\n\n/**\n * The `<Types>` child array, initialized in place when absent (so a `<Default>`\n * or `<Override>` can always be appended). Returns `undefined` if `element` has\n * no `<Types>` child (malformed `[Content_Types].xml`).\n */\nconst typesChildren = (element: Element): Element[] | undefined => {\n const types = element.elements?.find((e) => e.name === \"Types\");\n if (!types) return undefined;\n return types.elements ?? (types.elements = []);\n};\n\nexport const appendContentType = (\n element: Element,\n contentType: string,\n extension: string,\n): void => {\n const els = typesChildren(element);\n if (!els) return;\n\n // OPC Default Extension matching is case-insensitive (ECMA-376-2 §10.1.2):\n // an existing `JPG` must block a colliding `jpg`, or Word rejects the package.\n const exist = els.some(\n (el) =>\n el.type === \"element\" &&\n el.name === \"Default\" &&\n String(el?.attributes?.Extension ?? \"\").toLowerCase() === extension.toLowerCase(),\n );\n if (exist) {\n return;\n }\n\n els.push({\n attributes: {\n ContentType: contentType,\n Extension: extension,\n },\n name: \"Default\",\n type: \"element\",\n });\n};\n\n/**\n * Append an `<Override>` element to a `[Content_Types].xml` root, deduped by\n * `PartName`. Sibling to {@link appendContentType} (which handles `<Default>`):\n * unifies the per-package Override-dedup blocks in docx/pptx/xlsx patchers.\n */\nexport const appendOverride = (element: Element, partName: string, contentType: string): void => {\n const els = typesChildren(element);\n if (!els) return;\n\n // OPC Override PartName matching is case-insensitive (ECMA-376-2 §10.1.4).\n const exists = els.some(\n (el) =>\n el.type === \"element\" &&\n el.name === \"Override\" &&\n String(el?.attributes?.PartName ?? \"\").toLowerCase() === partName.toLowerCase(),\n );\n if (exists) return;\n\n els.push({\n attributes: {\n PartName: partName,\n ContentType: contentType,\n },\n name: \"Override\",\n type: \"element\",\n });\n};\n","/**\n * Relationship manager for OOXML .rels file management.\n */\nimport type { Element } from \"@office-open/xml\";\n\nimport { getFirstLevelElements } from \"./xml-patch-utils\";\n\nconst getIdFromRelationshipId = (relationshipId: string): number => {\n const output = parseInt(relationshipId.substring(3), 10);\n return isNaN(output) ? 0 : output;\n};\n\nexport const getNextRelationshipIndex = (relationships: Element): number => {\n const relationshipElements = getFirstLevelElements(relationships, \"Relationships\");\n\n return (\n relationshipElements\n .map((e) => getIdFromRelationshipId(e.attributes?.Id?.toString() ?? \"\"))\n .reduce((acc, curr) => Math.max(acc, curr), 0) + 1\n );\n};\n\nexport const appendRelationship = (\n relationships: Element,\n id: number | string,\n type: string,\n target: string,\n targetMode?: string,\n): readonly Element[] => {\n const relationshipElements = getFirstLevelElements(relationships, \"Relationships\");\n relationshipElements.push({\n attributes: {\n Id: `rId${id}`,\n Target: target,\n TargetMode: targetMode,\n Type: type,\n },\n name: \"Relationship\",\n type: \"element\",\n });\n\n return relationshipElements;\n};\n","/**\n * Merge core-properties overrides onto an existing docProps/core.xml document.\n *\n * The patch layer unzips docProps/core.xml into an xml2js document structure\n * (its `.elements` holds the `cp:coreProperties` root). This helper parses the\n * existing values, layers `overrides` on top (override wins), and returns the\n * re-serialized XML — without the XML declaration, which the caller prepends.\n */\nimport type { Element } from \"@office-open/xml\";\n\nimport { buildCorePropertiesXmlString, parseCorePropsElement } from \"../opc/core\";\nimport type { CorePropertiesOptions } from \"../opc/core\";\n\nexport function applyCorePropertiesOverride(\n corePropsDoc: Element,\n overrides: Partial<CorePropertiesOptions>,\n): string {\n const rootEl = (corePropsDoc.elements?.find((e) => e.name === \"cp:coreProperties\") ??\n corePropsDoc) as Element;\n const existing = parseCorePropsElement(rootEl);\n const merged: CorePropertiesOptions = { ...existing, ...overrides };\n return buildCorePropertiesXmlString(merged);\n}\n"],"mappings":";;AA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Aa,UAAU,MAAM,MAAM,EAAE,SAAS,mBAAmB,KAC/E,YAEgD;EAAG,GAAG;CACf,CAAC;AAC5C"}
@@ -1,2 +1,2 @@
1
- import { a as PointPropertySetOptions, c as stringifyDataModel, d as getColorXml, f as getLayoutXml, g as STYLE_CATEGORIES, h as LAYOUT_CATEGORIES, i as SmartArtData, l as stringifyConnection, m as COLOR_CATEGORIES, n as createDataModel, o as stringifyPoint, p as getStyleXml, r as SmartArtCollection, s as stringifyTransPoint, t as TreeNode, u as DEFAULT_DRAWING_XML } from "../index-CsQP7Cl4.mjs";
1
+ import { a as PointPropertySetOptions, c as stringifyDataModel, d as getColorXml, f as getLayoutXml, g as STYLE_CATEGORIES, h as LAYOUT_CATEGORIES, i as SmartArtData, l as stringifyConnection, m as COLOR_CATEGORIES, n as createDataModel, o as stringifyPoint, p as getStyleXml, r as SmartArtCollection, s as stringifyTransPoint, t as TreeNode, u as DEFAULT_DRAWING_XML } from "../index-DlPA26cw.mjs";
2
2
  export { COLOR_CATEGORIES, DEFAULT_DRAWING_XML, LAYOUT_CATEGORIES, PointPropertySetOptions, STYLE_CATEGORIES, SmartArtCollection, SmartArtData, TreeNode, createDataModel, getColorXml, getLayoutXml, getStyleXml, stringifyConnection, stringifyDataModel, stringifyPoint, stringifyTransPoint };
@@ -1,2 +1,2 @@
1
- import { a as stringifyDataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as stringifyTransPoint, l as getLayoutXml, n as SmartArtCollection, o as stringifyConnection, p as STYLE_CATEGORIES, r as stringifyPoint, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "../smartart-DCY-Vdv7.mjs";
1
+ import { a as stringifyDataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as stringifyTransPoint, l as getLayoutXml, n as SmartArtCollection, o as stringifyConnection, p as STYLE_CATEGORIES, r as stringifyPoint, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "../smartart-B7ukZ-Tw.mjs";
2
2
  export { COLOR_CATEGORIES, DEFAULT_DRAWING_XML, LAYOUT_CATEGORIES, STYLE_CATEGORIES, SmartArtCollection, createDataModel, getColorXml, getLayoutXml, getStyleXml, stringifyConnection, stringifyDataModel, stringifyPoint, stringifyTransPoint };
@@ -275,7 +275,7 @@ const createDataModel = (nodes, layout = "default", style = "simple1", color = "
275
275
  const pointStrs = [];
276
276
  const connectionStrs = [];
277
277
  pointStrs.push(stringifyDocPoint(layout, style, color));
278
- for (let i = 0; i < nodes.length; i++) {
278
+ for (const [i, node] of nodes.entries()) {
279
279
  const walk = (node, parentUuid, srcOrd) => {
280
280
  const nodeUuid = uuid();
281
281
  const parTransUuid = uuid();
@@ -293,11 +293,13 @@ const createDataModel = (nodes, layout = "default", style = "simple1", color = "
293
293
  parTransId: parTransUuid,
294
294
  sibTransId: sibTransUuid
295
295
  }));
296
- if (node.children) for (let j = 0; j < node.children.length; j++) walk(node.children[j], nodeUuid, j);
296
+ if (node.children) for (const [j, child] of node.children.entries()) walk(child, nodeUuid, j);
297
297
  };
298
- walk(nodes[i], "0", i);
298
+ walk(node, "0", i);
299
299
  }
300
300
  return stringifyDataModel(pointStrs, connectionStrs);
301
301
  };
302
302
  //#endregion
303
303
  export { stringifyDataModel as a, getColorXml as c, COLOR_CATEGORIES as d, LAYOUT_CATEGORIES as f, stringifyTransPoint as i, getLayoutXml as l, SmartArtCollection as n, stringifyConnection as o, STYLE_CATEGORIES as p, stringifyPoint as r, DEFAULT_DRAWING_XML as s, createDataModel as t, getStyleXml as u };
304
+
305
+ //# sourceMappingURL=smartart-B7ukZ-Tw.mjs.map