ooxml-core 1.37.0 → 1.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/automation/index.cjs +207 -207
- package/dist/automation/index.mjs +207 -207
- package/dist/{chunk-M2DFN3SP.mjs → chunk-XBIZIBTJ.mjs} +507 -10
- package/dist/collab/merge-values.d.ts +14 -0
- package/dist/collab/merge-values.d.ts.map +1 -0
- package/dist/docx/embedded.cjs +476 -474
- package/dist/docx/embedded.mjs +476 -474
- package/dist/docx/index.cjs +1075 -719
- package/dist/docx/index.d.ts +1 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +1075 -720
- package/dist/docx/layout/index.cjs +4 -0
- package/dist/docx/layout/index.mjs +4 -0
- package/dist/docx/load/index.cjs +164 -164
- package/dist/docx/load/index.mjs +164 -164
- package/dist/docx/merge-snapshots.d.ts +9 -0
- package/dist/docx/merge-snapshots.d.ts.map +1 -0
- package/dist/docx/ui/index.cjs +155 -155
- package/dist/docx/ui/index.mjs +155 -155
- package/dist/embedding/index.cjs +207 -0
- package/dist/embedding/index.d.ts +3 -0
- package/dist/embedding/index.d.ts.map +1 -1
- package/dist/embedding/index.mjs +205 -1
- package/dist/embedding/onedrive/client.d.ts +4 -0
- package/dist/embedding/onedrive/client.d.ts.map +1 -0
- package/dist/embedding/onedrive/index.cjs +617 -0
- package/dist/embedding/onedrive/index.d.ts +6 -0
- package/dist/embedding/onedrive/index.d.ts.map +1 -0
- package/dist/embedding/onedrive/index.mjs +611 -0
- package/dist/embedding/onedrive/metadata.d.ts +6 -0
- package/dist/embedding/onedrive/metadata.d.ts.map +1 -0
- package/dist/embedding/onedrive/requests.d.ts +8 -0
- package/dist/embedding/onedrive/requests.d.ts.map +1 -0
- package/dist/embedding/onedrive/session.d.ts +4 -0
- package/dist/embedding/onedrive/session.d.ts.map +1 -0
- package/dist/embedding/onedrive/transport.d.ts +9 -0
- package/dist/embedding/onedrive/transport.d.ts.map +1 -0
- package/dist/embedding/onedrive/types.d.ts +86 -0
- package/dist/embedding/onedrive/types.d.ts.map +1 -0
- package/dist/embedding/onedrive/upload.d.ts +3 -0
- package/dist/embedding/onedrive/upload.d.ts.map +1 -0
- package/dist/embedding/storage-merge.d.ts +8 -0
- package/dist/embedding/storage-merge.d.ts.map +1 -0
- package/dist/embedding/storage-session.d.ts +7 -0
- package/dist/embedding/storage-session.d.ts.map +1 -0
- package/dist/embedding/versioned-storage.d.ts +67 -0
- package/dist/embedding/versioned-storage.d.ts.map +1 -0
- package/dist/index.cjs +1013 -340
- package/dist/index.mjs +1013 -340
- package/dist/opc/index.cjs +680 -216
- package/dist/opc/index.d.ts +1 -0
- package/dist/opc/index.d.ts.map +1 -1
- package/dist/opc/index.mjs +680 -217
- package/dist/opc/merge-snapshots.d.ts +26 -0
- package/dist/opc/merge-snapshots.d.ts.map +1 -0
- package/dist/pptx/automation/index.cjs +20 -6
- package/dist/pptx/automation/index.d.ts +8 -17
- package/dist/pptx/automation/index.d.ts.map +1 -1
- package/dist/pptx/automation/index.mjs +1 -1
- package/dist/pptx/automation/schemas/chart-formatting-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/chart-formatting-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/chart-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/chart-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/chart-user-shape-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/chart-user-shape-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/element-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/element-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/export-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/export-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/geometry-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/geometry-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/hyperlink-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/hyperlink-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/index.d.ts +1 -3
- package/dist/pptx/automation/schemas/index.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/json-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/json-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/layout-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/layout-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/lock-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/lock-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/metadata-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/metadata-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/ole-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/ole-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/presentation-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/presentation-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/section-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/section-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/slide-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/slide-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/smartart-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/smartart-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/table-style-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/table-style-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/template-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/template-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/theme-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/theme-schemas.d.ts.map +1 -1
- package/dist/pptx/automation/schemas/validation-schemas.d.ts +1 -3
- package/dist/pptx/automation/schemas/validation-schemas.d.ts.map +1 -1
- package/dist/pptx/chunks/{collaboration-text-codec-Du_XeE_i.d.ts → collaboration-text-codec-1VmwD3yq.d.ts} +1 -3
- package/dist/pptx/chunks/collaboration-text-codec-1VmwD3yq.d.ts.map +1 -0
- package/dist/pptx/chunks/{collaboration-text-merge-DWWWdT_t.d.ts → collaboration-text-merge-B-tth-0W.d.ts} +2 -4
- package/dist/pptx/chunks/collaboration-text-merge-B-tth-0W.d.ts.map +1 -0
- package/dist/pptx/chunks/{collaboration-text-positions-MMT3GkZi.d.ts → collaboration-text-positions-D-1Jo1Fz.d.ts} +1 -3
- package/dist/pptx/chunks/collaboration-text-positions-D-1Jo1Fz.d.ts.map +1 -0
- package/dist/pptx/chunks/{collaboration-text-session-D0NOLQk7.d.ts → collaboration-text-session-CWHTaWF4.d.ts} +4 -6
- package/dist/pptx/chunks/collaboration-text-session-CWHTaWF4.d.ts.map +1 -0
- package/dist/pptx/chunks/{collaboration-text-session-delta-CzJGrTKJ.d.ts → collaboration-text-session-delta-Dxzybssp.d.ts} +2 -4
- package/dist/pptx/chunks/collaboration-text-session-delta-Dxzybssp.d.ts.map +1 -0
- package/dist/pptx/chunks/{color-ref-DT599vEx.d.ts → color-ref-CwUQoKPJ.d.ts} +1 -3
- package/dist/pptx/chunks/color-ref-CwUQoKPJ.d.ts.map +1 -0
- package/dist/pptx/chunks/{elements-f3UbFph-.d.ts → elements-DheCTwi0.d.ts} +4 -54
- package/dist/pptx/chunks/elements-DheCTwi0.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-Bp-1pGo1.d.ts → index-B4ofjG6_.d.ts} +6 -384
- package/dist/pptx/chunks/index-B4ofjG6_.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-BnH2QjYm.d.ts → index-Jcce8TlI.d.ts} +5 -37
- package/dist/pptx/chunks/index-Jcce8TlI.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-pLLN4OTz.d.ts → index-bgj0Ztnq.d.ts} +23 -543
- package/dist/pptx/chunks/index-bgj0Ztnq.d.ts.map +1 -0
- package/dist/pptx/chunks/{inspection-status-DjiWd_Aa.d.ts → inspection-status-TKac7eqb.d.ts} +1 -13
- package/dist/pptx/chunks/inspection-status-TKac7eqb.d.ts.map +1 -0
- package/dist/pptx/chunks/{schemas-fuDGetRe.d.ts → schemas-LHsDbVOw.d.ts} +1 -29
- package/dist/pptx/chunks/schemas-LHsDbVOw.d.ts.map +1 -0
- package/dist/pptx/chunks/{smart-art-CmOrPLLQ.d.ts → smart-art-DB37AsFP.d.ts} +2 -46
- package/dist/pptx/chunks/smart-art-DB37AsFP.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-operations-D5sgspO6.d.ts → text-operations-CdgEnFuK.d.ts} +4 -32
- package/dist/pptx/chunks/text-operations-CdgEnFuK.d.ts.map +1 -0
- package/dist/pptx/chunks/{text-P9xVnXXf.d.ts → text-t_wJ2OwM.d.ts} +2 -12
- package/dist/pptx/chunks/text-t_wJ2OwM.d.ts.map +1 -0
- package/dist/pptx/cli/index.cjs +20 -6
- package/dist/pptx/cli/index.d.ts +1 -3
- package/dist/pptx/cli/index.d.ts.map +1 -1
- package/dist/pptx/converter/index.cjs +7 -0
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/editor/ai/table-merge.d.ts +0 -2
- package/dist/pptx/editor/ai/table-merge.d.ts.map +1 -1
- package/dist/pptx/editor/loader/element-patch-walker.d.ts +0 -2
- package/dist/pptx/editor/loader/element-patch-walker.d.ts.map +1 -1
- package/dist/pptx/editor/loader/is-external-url.d.ts +0 -2
- package/dist/pptx/editor/loader/is-external-url.d.ts.map +1 -1
- package/dist/pptx/editor/loader/lazy-image-resolution.d.ts +0 -2
- package/dist/pptx/editor/loader/lazy-image-resolution.d.ts.map +1 -1
- package/dist/pptx/editor/loader/load-content-helpers.d.ts +0 -2
- package/dist/pptx/editor/loader/load-content-helpers.d.ts.map +1 -1
- package/dist/pptx/editor/loader/table-style-image-paths.d.ts +0 -2
- package/dist/pptx/editor/loader/table-style-image-paths.d.ts.map +1 -1
- package/dist/pptx/editor/loader/text-fill-image-paths.d.ts +0 -2
- package/dist/pptx/editor/loader/text-fill-image-paths.d.ts.map +1 -1
- package/dist/pptx/editor/render/bullet-list.d.ts +0 -2
- package/dist/pptx/editor/render/bullet-list.d.ts.map +1 -1
- package/dist/pptx/editor/render/bullet-toggle.d.ts +0 -2
- package/dist/pptx/editor/render/bullet-toggle.d.ts.map +1 -1
- package/dist/pptx/editor/render/chart-user-shape-edit.d.ts +0 -2
- package/dist/pptx/editor/render/chart-user-shape-edit.d.ts.map +1 -1
- package/dist/pptx/editor/render/clone.d.ts +0 -2
- package/dist/pptx/editor/render/clone.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-active-session.d.ts +0 -2
- package/dist/pptx/editor/render/collaboration-active-session.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-departure.d.ts +0 -2
- package/dist/pptx/editor/render/collaboration-departure.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-live-patch-target.d.ts +0 -2
- package/dist/pptx/editor/render/collaboration-live-patch-target.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-load-origin.d.ts +0 -2
- package/dist/pptx/editor/render/collaboration-load-origin.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-reconcile.d.ts +0 -2
- package/dist/pptx/editor/render/collaboration-reconcile.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-sync.d.ts +4 -8
- package/dist/pptx/editor/render/collaboration-sync.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-text-codec.d.ts +1 -1
- package/dist/pptx/editor/render/collaboration-text-lease.d.ts +0 -2
- package/dist/pptx/editor/render/collaboration-text-lease.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-text-merge.d.ts +1 -1
- package/dist/pptx/editor/render/collaboration-text-native-edit.d.ts +2 -4
- package/dist/pptx/editor/render/collaboration-text-native-edit.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-text-positions.d.ts +1 -1
- package/dist/pptx/editor/render/collaboration-text-projection.d.ts +1 -3
- package/dist/pptx/editor/render/collaboration-text-projection.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-text-session-apply.d.ts +3 -5
- package/dist/pptx/editor/render/collaboration-text-session-apply.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-text-session-delta.d.ts +1 -1
- package/dist/pptx/editor/render/collaboration-text-session-paragraph.d.ts +1 -3
- package/dist/pptx/editor/render/collaboration-text-session-paragraph.d.ts.map +1 -1
- package/dist/pptx/editor/render/collaboration-text-session.d.ts +1 -1
- package/dist/pptx/editor/render/collaboration-text-snapshot-positions.d.ts +2 -4
- package/dist/pptx/editor/render/collaboration-text-snapshot-positions.d.ts.map +1 -1
- package/dist/pptx/editor/render/custom-show-operations.d.ts +0 -2
- package/dist/pptx/editor/render/custom-show-operations.d.ts.map +1 -1
- package/dist/pptx/editor/render/deck-save-encryption.d.ts +0 -2
- package/dist/pptx/editor/render/deck-save-encryption.d.ts.map +1 -1
- package/dist/pptx/editor/render/editor-history.d.ts +0 -2
- package/dist/pptx/editor/render/editor-history.d.ts.map +1 -1
- package/dist/pptx/editor/render/editor-mutations.d.ts +0 -2
- package/dist/pptx/editor/render/editor-mutations.d.ts.map +1 -1
- package/dist/pptx/editor/render/element-locks.d.ts +0 -2
- package/dist/pptx/editor/render/element-locks.d.ts.map +1 -1
- package/dist/pptx/editor/render/element-operations.d.ts +0 -2
- package/dist/pptx/editor/render/element-operations.d.ts.map +1 -1
- package/dist/pptx/editor/render/element.d.ts +0 -2
- package/dist/pptx/editor/render/element.d.ts.map +1 -1
- package/dist/pptx/editor/render/find-replace.d.ts +2 -4
- package/dist/pptx/editor/render/find-replace.d.ts.map +1 -1
- package/dist/pptx/editor/render/font-family-update.d.ts +1 -3
- package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -1
- package/dist/pptx/editor/render/group-drill.d.ts +0 -2
- package/dist/pptx/editor/render/group-drill.d.ts.map +1 -1
- package/dist/pptx/editor/render/inline-list-body.d.ts +0 -2
- package/dist/pptx/editor/render/inline-list-body.d.ts.map +1 -1
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +1 -3
- package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -1
- package/dist/pptx/editor/render/remap-empty-paragraph.d.ts +0 -2
- package/dist/pptx/editor/render/remap-empty-paragraph.d.ts.map +1 -1
- package/dist/pptx/editor/render/remap-paragraph-sources.d.ts +0 -2
- package/dist/pptx/editor/render/remap-paragraph-sources.d.ts.map +1 -1
- package/dist/pptx/editor/render/remap-text-bullets.d.ts +0 -2
- package/dist/pptx/editor/render/remap-text-bullets.d.ts.map +1 -1
- package/dist/pptx/editor/render/remap-text.d.ts +0 -2
- package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
- package/dist/pptx/editor/render/schema-label-keys.d.ts +0 -2
- package/dist/pptx/editor/render/schema-label-keys.d.ts.map +1 -1
- package/dist/pptx/editor/render/section-operations.d.ts +0 -2
- package/dist/pptx/editor/render/section-operations.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-background-patch.d.ts +0 -2
- package/dist/pptx/editor/render/slide-background-patch.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-operations.d.ts +0 -2
- package/dist/pptx/editor/render/slide-operations.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-search.d.ts +0 -2
- package/dist/pptx/editor/render/slide-search.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-size-rescale.d.ts +0 -2
- package/dist/pptx/editor/render/slide-size-rescale.d.ts.map +1 -1
- package/dist/pptx/editor/render/slide-transition-edits.d.ts +0 -2
- package/dist/pptx/editor/render/slide-transition-edits.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-cell-edit.d.ts +0 -2
- package/dist/pptx/editor/render/table-cell-edit.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-cell-merge.d.ts +0 -2
- package/dist/pptx/editor/render/table-cell-merge.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-data-grid-ops.d.ts +0 -2
- package/dist/pptx/editor/render/table-data-grid-ops.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-layout.d.ts +0 -2
- package/dist/pptx/editor/render/table-layout.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-merge.d.ts +0 -2
- package/dist/pptx/editor/render/table-merge.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-style-editor-descriptor.d.ts +0 -2
- package/dist/pptx/editor/render/table-style-editor-descriptor.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-style-editor-edit.d.ts +0 -2
- package/dist/pptx/editor/render/table-style-editor-edit.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-style-editor-parts.d.ts +0 -2
- package/dist/pptx/editor/render/table-style-editor-parts.d.ts.map +1 -1
- package/dist/pptx/editor/render/table-style-map-edits.d.ts +0 -2
- package/dist/pptx/editor/render/table-style-map-edits.d.ts.map +1 -1
- package/dist/pptx/editor/render/template-editing.d.ts +0 -2
- package/dist/pptx/editor/render/template-editing.d.ts.map +1 -1
- package/dist/pptx/editor/render/text-content-style.d.ts +1 -3
- package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -1
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts +2 -4
- package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -1
- package/dist/pptx/editor/render/text-segment-paragraph-break.d.ts +0 -2
- package/dist/pptx/editor/render/text-segment-paragraph-break.d.ts.map +1 -1
- package/dist/pptx/editor/render/text-style-scope.d.ts +2 -4
- package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -1
- package/dist/pptx/editor/render/text-theme.d.ts +0 -2
- package/dist/pptx/editor/render/text-theme.d.ts.map +1 -1
- package/dist/pptx/editor/render/theme-editor-model.d.ts +0 -2
- package/dist/pptx/editor/render/theme-editor-model.d.ts.map +1 -1
- package/dist/pptx/editor/render/theme-editor-presets.d.ts +0 -2
- package/dist/pptx/editor/render/theme-editor-presets.d.ts.map +1 -1
- package/dist/pptx/editor/render/update-text-segment-style.d.ts +1 -3
- package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -1
- package/dist/pptx/index.cjs +1687 -1159
- package/dist/pptx/index.d.ts +10 -10
- package/dist/pptx/index.mjs +1 -1
- package/dist/pptx/node/index.d.ts +1 -3
- package/dist/pptx/node/index.d.ts.map +1 -1
- package/dist/pptx/signature-node/index.d.ts +1 -21
- package/dist/pptx/signature-node/index.d.ts.map +1 -1
- package/dist/pptx/smartart-layouts/index.d.ts +1 -7
- package/dist/pptx/smartart-layouts/index.d.ts.map +1 -1
- package/dist/pptx/ui/index.d.ts +1 -9
- package/dist/pptx/ui/index.d.ts.map +1 -1
- package/dist/teams/index.cjs +215 -201
- package/dist/teams/index.mjs +215 -201
- package/dist/text/index.cjs +193 -0
- package/dist/text/index.d.ts +1 -0
- package/dist/text/index.d.ts.map +1 -1
- package/dist/text/index.mjs +193 -1
- package/dist/text/merge-three-way.d.ts +9 -0
- package/dist/text/merge-three-way.d.ts.map +1 -0
- package/dist/visio/collab/index.cjs +226 -7
- package/dist/visio/collab/index.d.ts +1 -0
- package/dist/visio/collab/index.d.ts.map +1 -1
- package/dist/visio/collab/index.mjs +225 -7
- package/dist/visio/collab/merge-snapshots.d.ts +14 -0
- package/dist/visio/collab/merge-snapshots.d.ts.map +1 -0
- package/dist/visio/index.cjs +9 -9
- package/dist/visio/index.mjs +9 -9
- package/dist/visio/ui/index.cjs +9 -9
- package/dist/visio/ui/index.mjs +9 -9
- package/dist/xlsx/collab/index.cjs +49966 -507
- package/dist/xlsx/collab/index.d.ts +1 -0
- package/dist/xlsx/collab/index.d.ts.map +1 -1
- package/dist/xlsx/collab/index.mjs +49961 -507
- package/dist/xlsx/collab/merge-residual.d.ts +16 -0
- package/dist/xlsx/collab/merge-residual.d.ts.map +1 -0
- package/dist/xlsx/collab/merge-snapshots.d.ts +8 -0
- package/dist/xlsx/collab/merge-snapshots.d.ts.map +1 -0
- package/dist/xlsx/index.cjs +202 -202
- package/dist/xlsx/index.mjs +202 -202
- package/dist/xlsx/load/index.cjs +155 -155
- package/dist/xlsx/load/index.mjs +155 -155
- package/dist/xlsx/ui/index.cjs +202 -202
- package/dist/xlsx/ui/index.mjs +202 -202
- package/dist/xml/index.cjs +390 -22
- package/dist/xml/index.d.ts +1 -0
- package/dist/xml/index.d.ts.map +1 -1
- package/dist/xml/index.mjs +390 -23
- package/dist/xml/merge-three-way.d.ts +16 -0
- package/dist/xml/merge-three-way.d.ts.map +1 -0
- package/package.json +13 -8
- package/dist/pptx/chunks/collaboration-text-codec-Du_XeE_i.d.ts.map +0 -1
- package/dist/pptx/chunks/collaboration-text-merge-DWWWdT_t.d.ts.map +0 -1
- package/dist/pptx/chunks/collaboration-text-positions-MMT3GkZi.d.ts.map +0 -1
- package/dist/pptx/chunks/collaboration-text-session-D0NOLQk7.d.ts.map +0 -1
- package/dist/pptx/chunks/collaboration-text-session-delta-CzJGrTKJ.d.ts.map +0 -1
- package/dist/pptx/chunks/color-ref-DT599vEx.d.ts.map +0 -1
- package/dist/pptx/chunks/elements-f3UbFph-.d.ts.map +0 -1
- package/dist/pptx/chunks/index-BnH2QjYm.d.ts.map +0 -1
- package/dist/pptx/chunks/index-Bp-1pGo1.d.ts.map +0 -1
- package/dist/pptx/chunks/index-pLLN4OTz.d.ts.map +0 -1
- package/dist/pptx/chunks/inspection-status-DjiWd_Aa.d.ts.map +0 -1
- package/dist/pptx/chunks/schemas-fuDGetRe.d.ts.map +0 -1
- package/dist/pptx/chunks/smart-art-CmOrPLLQ.d.ts.map +0 -1
- package/dist/pptx/chunks/text-P9xVnXXf.d.ts.map +0 -1
- package/dist/pptx/chunks/text-operations-D5sgspO6.d.ts.map +0 -1
package/dist/opc/index.cjs
CHANGED
|
@@ -158,28 +158,28 @@ var MARKUP_SKIPS = [
|
|
|
158
158
|
["<![CDATA[", "]]>"],
|
|
159
159
|
["<?", "?>"]
|
|
160
160
|
];
|
|
161
|
-
function checkXmlLimits(
|
|
161
|
+
function checkXmlLimits(xml2, label, limits = {}) {
|
|
162
162
|
const maxDepth = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
163
163
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
164
164
|
let depth = 0;
|
|
165
165
|
let nodes = 0;
|
|
166
|
-
let at =
|
|
166
|
+
let at = xml2.indexOf("<");
|
|
167
167
|
while (at !== -1) {
|
|
168
|
-
const skip = MARKUP_SKIPS.find(([open]) =>
|
|
168
|
+
const skip = MARKUP_SKIPS.find(([open]) => xml2.startsWith(open, at));
|
|
169
169
|
if (skip) {
|
|
170
|
-
const end =
|
|
170
|
+
const end = xml2.indexOf(skip[1], at + skip[0].length);
|
|
171
171
|
if (end === -1) return;
|
|
172
|
-
at =
|
|
172
|
+
at = xml2.indexOf("<", end + skip[1].length);
|
|
173
173
|
continue;
|
|
174
174
|
}
|
|
175
175
|
TAG_RE.lastIndex = at;
|
|
176
|
-
const match = TAG_RE.exec(
|
|
176
|
+
const match = TAG_RE.exec(xml2);
|
|
177
177
|
if (!match) {
|
|
178
|
-
at =
|
|
178
|
+
at = xml2.indexOf("<", at + 1);
|
|
179
179
|
continue;
|
|
180
180
|
}
|
|
181
181
|
const [, closing, , selfClosing] = match;
|
|
182
|
-
at =
|
|
182
|
+
at = xml2.indexOf("<", at + match[0].length);
|
|
183
183
|
if (closing) {
|
|
184
184
|
depth--;
|
|
185
185
|
continue;
|
|
@@ -201,11 +201,11 @@ function checkXmlLimits(xml, label, limits = {}) {
|
|
|
201
201
|
}
|
|
202
202
|
var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
|
|
203
203
|
var crlfDeclarations = /* @__PURE__ */ new WeakSet();
|
|
204
|
-
function parseXml(
|
|
204
|
+
function parseXml(xml2, options = {}) {
|
|
205
205
|
const label = options.label ?? "OOXML";
|
|
206
|
-
if (/<!DOCTYPE|<!ENTITY/i.test(
|
|
206
|
+
if (/<!DOCTYPE|<!ENTITY/i.test(xml2))
|
|
207
207
|
throw new Error(`${label} XML with DTD or entity declarations is not supported`);
|
|
208
|
-
checkXmlLimits(
|
|
208
|
+
checkXmlLimits(xml2, label, options.limits);
|
|
209
209
|
let parseError = "";
|
|
210
210
|
let parsed;
|
|
211
211
|
try {
|
|
@@ -213,7 +213,7 @@ function parseXml(xml, options = {}) {
|
|
|
213
213
|
onError: (level, message) => {
|
|
214
214
|
if (level !== "warning" || options.warningsAsErrors) parseError = message;
|
|
215
215
|
}
|
|
216
|
-
}).parseFromString(
|
|
216
|
+
}).parseFromString(xml2, "application/xml");
|
|
217
217
|
} catch (error) {
|
|
218
218
|
throw new Error(
|
|
219
219
|
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -222,12 +222,12 @@ function parseXml(xml, options = {}) {
|
|
|
222
222
|
}
|
|
223
223
|
if (parseError || !parsed.documentElement)
|
|
224
224
|
throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
|
|
225
|
-
if (CRLF_DECLARATION.test(
|
|
225
|
+
if (CRLF_DECLARATION.test(xml2)) crlfDeclarations.add(parsed);
|
|
226
226
|
return parsed;
|
|
227
227
|
}
|
|
228
228
|
var buildXml = (node) => {
|
|
229
|
-
const
|
|
230
|
-
return crlfDeclarations.has(node) ?
|
|
229
|
+
const xml2 = new xmldom.XMLSerializer().serializeToString(node);
|
|
230
|
+
return crlfDeclarations.has(node) ? xml2.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml2;
|
|
231
231
|
};
|
|
232
232
|
var isElement = (node) => node.nodeType === 1;
|
|
233
233
|
var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
|
|
@@ -242,11 +242,378 @@ function attr(element, local, ns, prefix) {
|
|
|
242
242
|
}
|
|
243
243
|
var relAttr = (element, local) => attr(element, local, NS.r, "r");
|
|
244
244
|
|
|
245
|
+
// text/text-diff.ts
|
|
246
|
+
var isLowSurrogate = (text, at) => {
|
|
247
|
+
const code = text.charCodeAt(at);
|
|
248
|
+
return code >= 56320 && code <= 57343;
|
|
249
|
+
};
|
|
250
|
+
function shortestEdit(n, m, same2, maxEdits) {
|
|
251
|
+
const max = Math.min(n + m, maxEdits);
|
|
252
|
+
const offset = max + 1;
|
|
253
|
+
const v = new Int32Array(2 * max + 3);
|
|
254
|
+
const trace = [];
|
|
255
|
+
for (let d = 0; d <= max; d++) {
|
|
256
|
+
for (let k = -d; k <= d; k += 2) {
|
|
257
|
+
const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
|
|
258
|
+
let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
|
|
259
|
+
let y = x - k;
|
|
260
|
+
while (x < n && y < m && same2(x, y)) {
|
|
261
|
+
x++;
|
|
262
|
+
y++;
|
|
263
|
+
}
|
|
264
|
+
v[offset + k] = x;
|
|
265
|
+
if (x >= n && y >= m) return backtrack(trace, n, m, d);
|
|
266
|
+
}
|
|
267
|
+
trace.push(v.slice(offset - d, offset + d + 1));
|
|
268
|
+
}
|
|
269
|
+
return void 0;
|
|
270
|
+
}
|
|
271
|
+
function backtrack(trace, n, m, d) {
|
|
272
|
+
const edits = [];
|
|
273
|
+
let x = n;
|
|
274
|
+
let y = m;
|
|
275
|
+
for (let step = d; step > 0; step--) {
|
|
276
|
+
const previous = trace[step - 1];
|
|
277
|
+
const at = (k2) => previous[k2 + step - 1];
|
|
278
|
+
const k = x - y;
|
|
279
|
+
const down = k === -step || k !== step && at(k - 1) < at(k + 1);
|
|
280
|
+
const before = down ? k + 1 : k - 1;
|
|
281
|
+
const startX = at(before);
|
|
282
|
+
const startY = startX - before;
|
|
283
|
+
edits.push(down ? [startX, startY, true] : [startX, startY, false]);
|
|
284
|
+
x = startX;
|
|
285
|
+
y = startY;
|
|
286
|
+
}
|
|
287
|
+
return edits.reverse();
|
|
288
|
+
}
|
|
289
|
+
function changesOf(edits) {
|
|
290
|
+
const changes = [];
|
|
291
|
+
for (const [x, y, inserts] of edits) {
|
|
292
|
+
const last = changes.at(-1);
|
|
293
|
+
if (last && last.fromEnd === x && last.toEnd === y) {
|
|
294
|
+
if (inserts) last.toEnd++;
|
|
295
|
+
else last.fromEnd++;
|
|
296
|
+
} else
|
|
297
|
+
changes.push({
|
|
298
|
+
fromStart: x,
|
|
299
|
+
fromEnd: inserts ? x : x + 1,
|
|
300
|
+
toStart: y,
|
|
301
|
+
toEnd: inserts ? y + 1 : y
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return changes;
|
|
305
|
+
}
|
|
306
|
+
function characterChanges(a, b, maxEdits) {
|
|
307
|
+
const edits = shortestEdit(
|
|
308
|
+
a.length,
|
|
309
|
+
b.length,
|
|
310
|
+
(x, y) => a.charCodeAt(x) === b.charCodeAt(y),
|
|
311
|
+
maxEdits
|
|
312
|
+
);
|
|
313
|
+
return edits && changesOf(edits);
|
|
314
|
+
}
|
|
315
|
+
var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
|
|
316
|
+
function tokensOf(text, ids) {
|
|
317
|
+
const tokens = [];
|
|
318
|
+
const starts = [];
|
|
319
|
+
for (const match of text.matchAll(TOKEN)) {
|
|
320
|
+
let id = ids.get(match[0]);
|
|
321
|
+
if (id === void 0) ids.set(match[0], id = ids.size);
|
|
322
|
+
tokens.push(id);
|
|
323
|
+
starts.push(match.index);
|
|
324
|
+
}
|
|
325
|
+
starts.push(text.length);
|
|
326
|
+
return { tokens, starts };
|
|
327
|
+
}
|
|
328
|
+
function tokenChanges(a, b, maxEdits) {
|
|
329
|
+
const ids = /* @__PURE__ */ new Map();
|
|
330
|
+
const from = tokensOf(a, ids);
|
|
331
|
+
const to = tokensOf(b, ids);
|
|
332
|
+
const edits = shortestEdit(
|
|
333
|
+
from.tokens.length,
|
|
334
|
+
to.tokens.length,
|
|
335
|
+
(x, y) => from.tokens[x] === to.tokens[y],
|
|
336
|
+
maxEdits
|
|
337
|
+
);
|
|
338
|
+
if (!edits) return void 0;
|
|
339
|
+
let budget = maxEdits;
|
|
340
|
+
return changesOf(edits).flatMap((stretch) => {
|
|
341
|
+
const change = {
|
|
342
|
+
fromStart: from.starts[stretch.fromStart],
|
|
343
|
+
fromEnd: from.starts[stretch.fromEnd],
|
|
344
|
+
toStart: to.starts[stretch.toStart],
|
|
345
|
+
toEnd: to.starts[stretch.toEnd]
|
|
346
|
+
};
|
|
347
|
+
const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
|
|
348
|
+
a.slice(change.fromStart, change.fromEnd),
|
|
349
|
+
b.slice(change.toStart, change.toEnd),
|
|
350
|
+
budget
|
|
351
|
+
) : void 0;
|
|
352
|
+
if (!inner) return [change];
|
|
353
|
+
for (const found of inner)
|
|
354
|
+
budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
|
|
355
|
+
return inner.map((found) => ({
|
|
356
|
+
fromStart: found.fromStart + change.fromStart,
|
|
357
|
+
fromEnd: found.fromEnd + change.fromStart,
|
|
358
|
+
toStart: found.toStart + change.toStart,
|
|
359
|
+
toEnd: found.toEnd + change.toStart
|
|
360
|
+
}));
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function diffText(from, to, maxEdits = 500) {
|
|
364
|
+
let start = 0;
|
|
365
|
+
while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
|
|
366
|
+
start++;
|
|
367
|
+
let end = 0;
|
|
368
|
+
while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
|
|
369
|
+
end++;
|
|
370
|
+
const a = from.slice(start, from.length - end);
|
|
371
|
+
const b = to.slice(start, to.length - end);
|
|
372
|
+
if (!a.length && !b.length) return [];
|
|
373
|
+
const found = a.length && b.length ? characterChanges(a, b, maxEdits) ?? tokenChanges(a, b, maxEdits) : void 0;
|
|
374
|
+
const changes = found ?? [{ fromStart: 0, fromEnd: a.length, toStart: 0, toEnd: b.length }];
|
|
375
|
+
const result = [];
|
|
376
|
+
for (const change of changes) {
|
|
377
|
+
const placed = {
|
|
378
|
+
fromStart: change.fromStart + start,
|
|
379
|
+
fromEnd: change.fromEnd + start,
|
|
380
|
+
toStart: change.toStart + start,
|
|
381
|
+
toEnd: change.toEnd + start
|
|
382
|
+
};
|
|
383
|
+
if (placed.fromStart > 0 && placed.toStart > 0 && (isLowSurrogate(from, placed.fromStart) || isLowSurrogate(to, placed.toStart))) {
|
|
384
|
+
placed.fromStart--;
|
|
385
|
+
placed.toStart--;
|
|
386
|
+
}
|
|
387
|
+
if (isLowSurrogate(from, placed.fromEnd) || isLowSurrogate(to, placed.toEnd)) {
|
|
388
|
+
placed.fromEnd++;
|
|
389
|
+
placed.toEnd++;
|
|
390
|
+
}
|
|
391
|
+
const last = result.at(-1);
|
|
392
|
+
if (last && placed.fromStart <= last.fromEnd) {
|
|
393
|
+
last.fromEnd = Math.max(last.fromEnd, placed.fromEnd);
|
|
394
|
+
last.toEnd = Math.max(last.toEnd, placed.toEnd);
|
|
395
|
+
} else result.push(placed);
|
|
396
|
+
}
|
|
397
|
+
return result;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// text/merge-three-way.ts
|
|
401
|
+
function mergeTextThreeWay(base, local, remote) {
|
|
402
|
+
if (local === remote || base === remote) return { status: "merged", text: local };
|
|
403
|
+
if (base === local) return { status: "merged", text: remote };
|
|
404
|
+
if (Math.max(base.length, local.length, remote.length) > 1e6)
|
|
405
|
+
return { status: "unresolved" };
|
|
406
|
+
const changes = (value) => diffText(base, value).map((change) => ({
|
|
407
|
+
start: change.fromStart,
|
|
408
|
+
end: change.fromEnd,
|
|
409
|
+
text: value.slice(change.toStart, change.toEnd)
|
|
410
|
+
}));
|
|
411
|
+
const edits = changes(local);
|
|
412
|
+
for (const next of changes(remote)) {
|
|
413
|
+
if (edits.some(
|
|
414
|
+
(edit) => edit.start === next.start && edit.end === next.end && edit.text === next.text
|
|
415
|
+
))
|
|
416
|
+
continue;
|
|
417
|
+
if (edits.some((edit) => {
|
|
418
|
+
if (edit.start === edit.end && next.start === next.end) return false;
|
|
419
|
+
if (edit.start === edit.end) return edit.start > next.start && edit.start < next.end;
|
|
420
|
+
if (next.start === next.end) return next.start > edit.start && next.start < edit.end;
|
|
421
|
+
return edit.start < next.end && next.start < edit.end;
|
|
422
|
+
}))
|
|
423
|
+
return { status: "unresolved" };
|
|
424
|
+
edits.push(next);
|
|
425
|
+
}
|
|
426
|
+
edits.sort(
|
|
427
|
+
(a, b) => a.start - b.start || a.end - b.end || (a.text < b.text ? -1 : a.text > b.text ? 1 : 0)
|
|
428
|
+
);
|
|
429
|
+
let text = "", cursor = 0;
|
|
430
|
+
for (const edit of edits) {
|
|
431
|
+
text += base.slice(cursor, edit.start) + edit.text;
|
|
432
|
+
cursor = edit.end;
|
|
433
|
+
}
|
|
434
|
+
return { status: "merged", text: text + base.slice(cursor) };
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// xml/merge-three-way.ts
|
|
438
|
+
var tag = (node) => `${node.namespaceURI ?? ""}|${node.localName ?? node.tagName}`;
|
|
439
|
+
var xml = (node) => node ? buildXml(node) : void 0;
|
|
440
|
+
function childrenByKey(parent, options, repeated) {
|
|
441
|
+
const result = /* @__PURE__ */ new Map();
|
|
442
|
+
const counts = /* @__PURE__ */ new Map();
|
|
443
|
+
for (const child of elements(parent)) {
|
|
444
|
+
const name = tag(child), explicit = options.keyElement?.(child, parent);
|
|
445
|
+
const index = counts.get(name) ?? 0;
|
|
446
|
+
counts.set(name, index + 1);
|
|
447
|
+
if (!explicit && repeated.has(name) && !options.allowPositional?.(parent))
|
|
448
|
+
throw new Error("Ambiguous repeated elements");
|
|
449
|
+
const key = explicit ? `${name}@${explicit}` : `${name}#${index}`;
|
|
450
|
+
if (result.has(key)) throw new Error("Duplicate element identity");
|
|
451
|
+
result.set(key, child);
|
|
452
|
+
}
|
|
453
|
+
return result;
|
|
454
|
+
}
|
|
455
|
+
function orderKeys(base, local, remote) {
|
|
456
|
+
const same2 = (a, b) => a.length === b.length && a.every((key, index) => key === b[index]);
|
|
457
|
+
if (same2(base, local)) return [...remote];
|
|
458
|
+
if (same2(base, remote) || same2(local, remote)) return [...local];
|
|
459
|
+
const keys = [.../* @__PURE__ */ new Set([...remote, ...local])].sort();
|
|
460
|
+
const edges = new Map(keys.map((key) => [key, /* @__PURE__ */ new Set()]));
|
|
461
|
+
const degree = new Map(keys.map((key) => [key, 0]));
|
|
462
|
+
for (const sequence of [local, remote])
|
|
463
|
+
for (let i = 1; i < sequence.length; i++) {
|
|
464
|
+
const previous = sequence[i - 1], next = sequence[i];
|
|
465
|
+
if (!edges.get(previous).has(next)) {
|
|
466
|
+
edges.get(previous).add(next);
|
|
467
|
+
degree.set(next, degree.get(next) + 1);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
const out = [];
|
|
471
|
+
const ready = keys.filter((key) => degree.get(key) === 0);
|
|
472
|
+
while (ready.length) {
|
|
473
|
+
const next = ready.sort().shift();
|
|
474
|
+
out.push(next);
|
|
475
|
+
for (const key of edges.get(next)) {
|
|
476
|
+
degree.set(key, degree.get(key) - 1);
|
|
477
|
+
if (degree.get(key) === 0) ready.push(key);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
return out.length === keys.length ? out : void 0;
|
|
481
|
+
}
|
|
482
|
+
function mergeXmlThreeWay(baseXml, localXml, remoteXml, options = {}) {
|
|
483
|
+
if (localXml === remoteXml || baseXml === remoteXml) return { status: "merged", xml: localXml };
|
|
484
|
+
if (baseXml === localXml) return { status: "merged", xml: remoteXml };
|
|
485
|
+
const issues = [];
|
|
486
|
+
try {
|
|
487
|
+
let merge2 = function(b, l, r, path) {
|
|
488
|
+
const bx = xml(b), lx = xml(l), rx = xml(r);
|
|
489
|
+
if (lx === rx || bx === rx) return l ? copy(l) : void 0;
|
|
490
|
+
if (bx === lx) return r ? copy(r) : void 0;
|
|
491
|
+
if (!b && l && r && tag(l) === tag(r) && !elements(l).length && !elements(r).length) {
|
|
492
|
+
const resolved = options.resolveText?.(r, l, r);
|
|
493
|
+
if (resolved !== void 0) {
|
|
494
|
+
const node = copy(r);
|
|
495
|
+
node.textContent = resolved;
|
|
496
|
+
return node;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
if (!b || !l || !r || tag(b) !== tag(l) || tag(b) !== tag(r)) {
|
|
500
|
+
issues.push(`${path}: overlapping structural changes`);
|
|
501
|
+
return void 0;
|
|
502
|
+
}
|
|
503
|
+
const out = remote.createElementNS(r.namespaceURI, r.tagName);
|
|
504
|
+
const attrs = (node) => new Map(
|
|
505
|
+
Array.from(node.attributes).map((a) => [
|
|
506
|
+
`${a.namespaceURI ?? ""}|${a.localName ?? a.name}`,
|
|
507
|
+
a
|
|
508
|
+
])
|
|
509
|
+
);
|
|
510
|
+
const ba = attrs(b), la = attrs(l), ra = attrs(r);
|
|
511
|
+
for (const key of /* @__PURE__ */ new Set([...ba.keys(), ...la.keys(), ...ra.keys()])) {
|
|
512
|
+
const old = ba.get(key)?.value, left = la.get(key)?.value, right = ra.get(key)?.value;
|
|
513
|
+
const value = left === right || right === old ? left : left === old ? right : void 0;
|
|
514
|
+
if (left !== right && left !== old && right !== old) {
|
|
515
|
+
issues.push(`${path}: overlapping attribute ${key}`);
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
const source = ra.get(key) ?? la.get(key) ?? ba.get(key);
|
|
519
|
+
if (value !== void 0) out.setAttributeNS(source.namespaceURI, source.name, value);
|
|
520
|
+
}
|
|
521
|
+
const lists = [b, l, r].map(elements);
|
|
522
|
+
if (lists.every((list) => list.length === 0)) {
|
|
523
|
+
if ([b, l, r].some(
|
|
524
|
+
(node) => Array.from(node.childNodes).some(
|
|
525
|
+
(child) => child.nodeType !== 3 && child.nodeType !== 4
|
|
526
|
+
)
|
|
527
|
+
)) {
|
|
528
|
+
issues.push(`${path}: non-text leaf content requires explicit preservation`);
|
|
529
|
+
return void 0;
|
|
530
|
+
}
|
|
531
|
+
const texts = [b, l, r].map((node) => node.textContent ?? "");
|
|
532
|
+
const override = options.resolveText?.(b, l, r);
|
|
533
|
+
const value = override !== void 0 ? { status: "merged", text: override } : texts[1] === texts[2] || texts[0] === texts[2] ? { status: "merged", text: texts[1] } : texts[0] === texts[1] ? { status: "merged", text: texts[2] } : options.allowText?.(b) ? mergeTextThreeWay(texts[0], texts[1], texts[2]) : { status: "unresolved" };
|
|
534
|
+
if (value.status !== "merged") issues.push(`${path}: overlapping text changes`);
|
|
535
|
+
else if (value.text) out.appendChild(remote.createTextNode(value.text));
|
|
536
|
+
return out;
|
|
537
|
+
}
|
|
538
|
+
if ([b, l, r].some(
|
|
539
|
+
(node) => Array.from(node.childNodes).some(
|
|
540
|
+
(child) => child.nodeType !== 1 && (child.nodeType !== 3 || Boolean(child.textContent?.trim()))
|
|
541
|
+
)
|
|
542
|
+
)) {
|
|
543
|
+
issues.push(`${path}: mixed content cannot be matched safely`);
|
|
544
|
+
return void 0;
|
|
545
|
+
}
|
|
546
|
+
const repeated = /* @__PURE__ */ new Set();
|
|
547
|
+
const groups = lists.map((list) => {
|
|
548
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
549
|
+
for (const child of list) {
|
|
550
|
+
const name = tag(child), group = grouped.get(name) ?? [];
|
|
551
|
+
group.push(child);
|
|
552
|
+
grouped.set(name, group);
|
|
553
|
+
if (group.length > 1) repeated.add(name);
|
|
554
|
+
}
|
|
555
|
+
return grouped;
|
|
556
|
+
});
|
|
557
|
+
for (const name of repeated) {
|
|
558
|
+
const rows = groups.map((group) => group.get(name) ?? []);
|
|
559
|
+
if (rows.some((row) => row.some((child) => options.keyElement?.(child, b) !== void 0)))
|
|
560
|
+
continue;
|
|
561
|
+
if (rows.some((row) => row.length !== rows[0].length)) {
|
|
562
|
+
issues.push(`${path}: unkeyed structural changes`);
|
|
563
|
+
return void 0;
|
|
564
|
+
}
|
|
565
|
+
const before = rows[0].map((child) => buildXml(child));
|
|
566
|
+
const known = new Set(before);
|
|
567
|
+
for (const row of rows.slice(1))
|
|
568
|
+
if (row.some((child, i) => {
|
|
569
|
+
const value = buildXml(child);
|
|
570
|
+
return before[i] !== value && known.has(value);
|
|
571
|
+
})) {
|
|
572
|
+
issues.push(`${path}: reordered unkeyed elements`);
|
|
573
|
+
return void 0;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
let maps;
|
|
577
|
+
try {
|
|
578
|
+
maps = [b, l, r].map((parent) => childrenByKey(parent, options, repeated));
|
|
579
|
+
} catch {
|
|
580
|
+
issues.push(`${path}: ambiguous element identities`);
|
|
581
|
+
return void 0;
|
|
582
|
+
}
|
|
583
|
+
const [bm, lm, rm] = maps;
|
|
584
|
+
const merged = /* @__PURE__ */ new Map();
|
|
585
|
+
for (const key of /* @__PURE__ */ new Set([...bm.keys(), ...lm.keys(), ...rm.keys()])) {
|
|
586
|
+
const node = merge2(bm.get(key), lm.get(key), rm.get(key), `${path}/${key}`);
|
|
587
|
+
if (node) merged.set(key, node);
|
|
588
|
+
}
|
|
589
|
+
const surviving = (map) => [...map.keys()].filter((key) => merged.has(key));
|
|
590
|
+
const order = orderKeys(surviving(bm), surviving(lm), surviving(rm));
|
|
591
|
+
if (!order) {
|
|
592
|
+
issues.push(`${path}: incompatible element order`);
|
|
593
|
+
return void 0;
|
|
594
|
+
}
|
|
595
|
+
for (const key of order) out.appendChild(merged.get(key));
|
|
596
|
+
return out;
|
|
597
|
+
};
|
|
598
|
+
var merge = merge2;
|
|
599
|
+
const base = parseXml(baseXml, { warningsAsErrors: true });
|
|
600
|
+
const local = parseXml(localXml, { warningsAsErrors: true });
|
|
601
|
+
const remote = parseXml(remoteXml, { warningsAsErrors: true });
|
|
602
|
+
const copy = (node) => remote.importNode(node, true);
|
|
603
|
+
const root = merge2(base.documentElement, local.documentElement, remote.documentElement, "root");
|
|
604
|
+
if (!root || issues.length) return { status: "unresolved", issues };
|
|
605
|
+
remote.replaceChild(root, remote.documentElement);
|
|
606
|
+
return { status: "merged", xml: buildXml(remote) };
|
|
607
|
+
} catch {
|
|
608
|
+
return { status: "unresolved", issues: ["Invalid or unsupported XML input"] };
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
245
612
|
// opc/relationships.ts
|
|
246
|
-
function parseRelationships(
|
|
613
|
+
function parseRelationships(xml2) {
|
|
247
614
|
const map = /* @__PURE__ */ new Map();
|
|
248
|
-
if (!
|
|
249
|
-
const root = parseXml(
|
|
615
|
+
if (!xml2) return map;
|
|
616
|
+
const root = parseXml(xml2).documentElement;
|
|
250
617
|
for (const node of elements(root)) {
|
|
251
618
|
if (node.localName !== "Relationship") continue;
|
|
252
619
|
const id = node.getAttribute("Id");
|
|
@@ -293,11 +660,11 @@ var getRelationshipId = (element) => relAttr(element, "id") || void 0;
|
|
|
293
660
|
|
|
294
661
|
// opc/content-types.ts
|
|
295
662
|
var escapeAttr2 = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
296
|
-
function parseContentTypes(
|
|
663
|
+
function parseContentTypes(xml2) {
|
|
297
664
|
const defaults = /* @__PURE__ */ new Map();
|
|
298
665
|
const overrides = /* @__PURE__ */ new Map();
|
|
299
|
-
if (!
|
|
300
|
-
for (const node of elements(parseXml(
|
|
666
|
+
if (!xml2) return { defaults, overrides };
|
|
667
|
+
for (const node of elements(parseXml(xml2).documentElement)) {
|
|
301
668
|
const contentType = node.getAttribute("ContentType");
|
|
302
669
|
if (!contentType) continue;
|
|
303
670
|
if (node.localName === "Default") {
|
|
@@ -326,9 +693,9 @@ function buildContentTypesXml(types) {
|
|
|
326
693
|
).join("");
|
|
327
694
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${NS.contentTypes}">${defaults}${overrides}</Types>`;
|
|
328
695
|
}
|
|
329
|
-
function ensureContentTypeDefault(
|
|
330
|
-
const types = parseContentTypes(
|
|
331
|
-
if (types.defaults.has(extension.toLowerCase())) return
|
|
696
|
+
function ensureContentTypeDefault(xml2, extension, contentType) {
|
|
697
|
+
const types = parseContentTypes(xml2);
|
|
698
|
+
if (types.defaults.has(extension.toLowerCase())) return xml2 ?? buildContentTypesXml(types);
|
|
332
699
|
types.defaults.set(extension.toLowerCase(), contentType);
|
|
333
700
|
return buildContentTypesXml(types);
|
|
334
701
|
}
|
|
@@ -338,35 +705,35 @@ var CONTENT_TYPES_PATH = "[Content_Types].xml";
|
|
|
338
705
|
var XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
339
706
|
var EMPTY_TYPES = `${XML_DECLARATION}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>`;
|
|
340
707
|
var EMPTY_RELS = `${XML_DECLARATION}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;
|
|
341
|
-
function attr2(
|
|
708
|
+
function attr2(tag2, name) {
|
|
342
709
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
343
|
-
const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(
|
|
710
|
+
const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag2);
|
|
344
711
|
return match ? match[1] ?? match[2] : void 0;
|
|
345
712
|
}
|
|
346
713
|
async function ensureContentTypeOverride(zip, partName, contentType) {
|
|
347
|
-
const
|
|
714
|
+
const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
|
|
348
715
|
const target = `/${partName}`;
|
|
349
|
-
for (const
|
|
350
|
-
if (attr2(
|
|
716
|
+
for (const tag2 of xml2.match(/<Override\b[^>]*\/>/g) ?? [])
|
|
717
|
+
if (attr2(tag2, "PartName") === target) return;
|
|
351
718
|
const insertion = `<Override PartName="${target}" ContentType="${contentType}"/>`;
|
|
352
|
-
zip.file(CONTENT_TYPES_PATH,
|
|
719
|
+
zip.file(CONTENT_TYPES_PATH, xml2.replace("</Types>", `${insertion}</Types>`));
|
|
353
720
|
}
|
|
354
721
|
async function removeContentTypeOverride(zip, partName) {
|
|
355
|
-
const
|
|
356
|
-
if (!
|
|
722
|
+
const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string");
|
|
723
|
+
if (!xml2) return;
|
|
357
724
|
const target = `/${partName}`;
|
|
358
|
-
const
|
|
725
|
+
const tag2 = (xml2.match(/<Override\b[^>]*\/>/g) ?? []).find(
|
|
359
726
|
(candidate) => attr2(candidate, "PartName") === target
|
|
360
727
|
);
|
|
361
|
-
if (
|
|
728
|
+
if (tag2) zip.file(CONTENT_TYPES_PATH, xml2.replace(tag2, ""));
|
|
362
729
|
}
|
|
363
730
|
async function ensureRelationship(zip, relsPath, type, target) {
|
|
364
|
-
const
|
|
731
|
+
const xml2 = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
|
|
365
732
|
const used = /* @__PURE__ */ new Set();
|
|
366
|
-
for (const
|
|
367
|
-
const id2 = attr2(
|
|
733
|
+
for (const tag2 of xml2.match(/<Relationship\b[^>]*\/>/g) ?? []) {
|
|
734
|
+
const id2 = attr2(tag2, "Id");
|
|
368
735
|
if (id2) used.add(id2);
|
|
369
|
-
if (id2 && attr2(
|
|
736
|
+
if (id2 && attr2(tag2, "Type") === type && attr2(tag2, "Target") === target) return id2;
|
|
370
737
|
}
|
|
371
738
|
const highest = Math.max(
|
|
372
739
|
0,
|
|
@@ -375,128 +742,15 @@ async function ensureRelationship(zip, relsPath, type, target) {
|
|
|
375
742
|
let id = `rId${highest + 1}`;
|
|
376
743
|
if (used.has(id)) id = nextRelationshipId(used);
|
|
377
744
|
const insertion = `<Relationship Id="${id}" Type="${type}" Target="${target}"/>`;
|
|
378
|
-
zip.file(relsPath,
|
|
745
|
+
zip.file(relsPath, xml2.replace("</Relationships>", `${insertion}</Relationships>`));
|
|
379
746
|
return id;
|
|
380
747
|
}
|
|
381
748
|
async function findOfficeDocumentPart(zip) {
|
|
382
|
-
const
|
|
383
|
-
for (const
|
|
384
|
-
if (attr2(
|
|
749
|
+
const xml2 = await zip.file("_rels/.rels")?.async("string");
|
|
750
|
+
for (const tag2 of xml2?.match(/<Relationship\b[^>]*\/>/g) ?? [])
|
|
751
|
+
if (attr2(tag2, "Type") === RELATIONSHIP_TYPES.officeDocument) return attr2(tag2, "Target");
|
|
385
752
|
return void 0;
|
|
386
753
|
}
|
|
387
|
-
|
|
388
|
-
// opc/clone-part-graph.ts
|
|
389
|
-
function relativePartTarget(basePart, targetPart) {
|
|
390
|
-
const base = basePart.split("/").slice(0, -1);
|
|
391
|
-
const target = targetPart.split("/");
|
|
392
|
-
while (base.length > 0 && base[0] === target[0]) {
|
|
393
|
-
base.shift();
|
|
394
|
-
target.shift();
|
|
395
|
-
}
|
|
396
|
-
return [...base.map(() => ".."), ...target].join("/");
|
|
397
|
-
}
|
|
398
|
-
async function clonePartGraph(options) {
|
|
399
|
-
const { zip, sourcePart, targetPart, shouldClone } = options;
|
|
400
|
-
const sourceZip = options.sourceZip ?? zip;
|
|
401
|
-
const copies = options.copies ?? /* @__PURE__ */ new Map();
|
|
402
|
-
copies.set(sourcePart, targetPart);
|
|
403
|
-
const types = parseContentTypes(await sourceZip.file("[Content_Types].xml")?.async("string"));
|
|
404
|
-
const reserved = new Set(Object.keys(zip.files));
|
|
405
|
-
reserved.add(targetPart);
|
|
406
|
-
for (const target of copies.values()) reserved.add(target);
|
|
407
|
-
const allocate = (source) => {
|
|
408
|
-
const match = /^(?<stem>.*?)(?:\d+)?(?<extension>\.[^/.]+)$/u.exec(source);
|
|
409
|
-
const stem = match?.groups?.stem ?? source;
|
|
410
|
-
const extension = match?.groups?.extension ?? "";
|
|
411
|
-
let index = 1;
|
|
412
|
-
while (reserved.has(`${stem}${index}${extension}`)) index += 1;
|
|
413
|
-
const path = `${stem}${index}${extension}`;
|
|
414
|
-
reserved.add(path);
|
|
415
|
-
return path;
|
|
416
|
-
};
|
|
417
|
-
const copyRelationships = async (source, destination) => {
|
|
418
|
-
const contentType = contentTypeForPart(types, source);
|
|
419
|
-
if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
|
|
420
|
-
const xml = await sourceZip.file(relationshipsPartFor(source))?.async("string");
|
|
421
|
-
if (!xml) return;
|
|
422
|
-
const relationships = parseRelationships(xml);
|
|
423
|
-
for (const relationship of relationships.values()) {
|
|
424
|
-
if (relationship.mode === "External") continue;
|
|
425
|
-
const originalTarget = resolvePartPath(source, relationship.target);
|
|
426
|
-
let newTarget = copies.get(originalTarget);
|
|
427
|
-
if (!newTarget && shouldClone(relationship, originalTarget)) {
|
|
428
|
-
const file = sourceZip.file(originalTarget);
|
|
429
|
-
if (!file) throw new Error(`Cannot clone missing package part: ${originalTarget}`);
|
|
430
|
-
newTarget = allocate(originalTarget);
|
|
431
|
-
copies.set(originalTarget, newTarget);
|
|
432
|
-
zip.file(newTarget, await file.async("uint8array"));
|
|
433
|
-
await copyRelationships(originalTarget, newTarget);
|
|
434
|
-
}
|
|
435
|
-
relationship.target = relativePartTarget(destination, newTarget ?? originalTarget);
|
|
436
|
-
}
|
|
437
|
-
zip.file(relationshipsPartFor(destination), buildRelationshipsXml(relationships));
|
|
438
|
-
};
|
|
439
|
-
await copyRelationships(sourcePart, targetPart);
|
|
440
|
-
return copies;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
// opc/safe-href.ts
|
|
444
|
-
var SAFE_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
|
|
445
|
-
function isSafeHyperlinkHref(href) {
|
|
446
|
-
const scheme = /^([a-z][a-z0-9+.-]*:)/i.exec(href.trim())?.[1];
|
|
447
|
-
return scheme !== void 0 && SAFE_SCHEMES.has(scheme.toLowerCase());
|
|
448
|
-
}
|
|
449
|
-
var OPEN_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
|
|
450
|
-
var STORE_SCHEMES = /* @__PURE__ */ new Set([...OPEN_SCHEMES, "ftp", "file"]);
|
|
451
|
-
var SCRIPT_SCHEMES = /* @__PURE__ */ new Set([
|
|
452
|
-
"javascript",
|
|
453
|
-
"vbscript",
|
|
454
|
-
"livescript",
|
|
455
|
-
"jscript",
|
|
456
|
-
"mocha",
|
|
457
|
-
"data",
|
|
458
|
-
"mhtml",
|
|
459
|
-
"ms-its",
|
|
460
|
-
"mk",
|
|
461
|
-
"x-javascript",
|
|
462
|
-
"blob"
|
|
463
|
-
]);
|
|
464
|
-
var IGNORABLE = new RegExp(
|
|
465
|
-
"[\\u0000-\\u0020\\u007f\\u00ad\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\ufeff]",
|
|
466
|
-
"gu"
|
|
467
|
-
);
|
|
468
|
-
var CONTROL = new RegExp("[\\u0000-\\u001f\\u007f]", "u");
|
|
469
|
-
var SCHEME = /^([a-z][a-z0-9+.-]*):/;
|
|
470
|
-
var STORE_ONLY = { store: true, open: false, reason: "not-openable" };
|
|
471
|
-
var reject = (reason) => ({
|
|
472
|
-
store: false,
|
|
473
|
-
open: false,
|
|
474
|
-
reason
|
|
475
|
-
});
|
|
476
|
-
function hyperlinkPolicy(href, options = {}) {
|
|
477
|
-
if (typeof href !== "string") return reject("empty");
|
|
478
|
-
const trimmed = href.trim();
|
|
479
|
-
const normalized = trimmed.replace(IGNORABLE, "").toLowerCase();
|
|
480
|
-
if (normalized.length === 0) return reject("empty");
|
|
481
|
-
const scheme = SCHEME.exec(normalized)?.[1];
|
|
482
|
-
if (scheme !== void 0 && SCRIPT_SCHEMES.has(scheme)) return reject("script-scheme");
|
|
483
|
-
if (scheme !== void 0 && !trimmed.toLowerCase().startsWith(`${scheme}:`))
|
|
484
|
-
return reject("obfuscated-scheme");
|
|
485
|
-
if (CONTROL.test(trimmed)) return reject("control-characters");
|
|
486
|
-
if (scheme === void 0) return options.openRelative ? { store: true, open: true } : STORE_ONLY;
|
|
487
|
-
if (scheme.length === 1) return STORE_ONLY;
|
|
488
|
-
if (OPEN_SCHEMES.has(scheme)) return { store: true, open: true };
|
|
489
|
-
if (options.additionalOpenSchemes?.some((allowed) => allowed.toLowerCase() === scheme))
|
|
490
|
-
return { store: true, open: true };
|
|
491
|
-
if (STORE_SCHEMES.has(scheme)) return STORE_ONLY;
|
|
492
|
-
return reject("unsupported-scheme");
|
|
493
|
-
}
|
|
494
|
-
function isStorableHyperlinkHref(href, options) {
|
|
495
|
-
return hyperlinkPolicy(href, options).store;
|
|
496
|
-
}
|
|
497
|
-
function isOpenableHyperlinkHref(href, options) {
|
|
498
|
-
return hyperlinkPolicy(href, options).open;
|
|
499
|
-
}
|
|
500
754
|
var DEFAULT_ZIP_LIMITS = {
|
|
501
755
|
maxInputBytes: 100 * 1024 * 1024,
|
|
502
756
|
maxEntries: 1e4,
|
|
@@ -719,6 +973,215 @@ async function openZip(input, limits = {}) {
|
|
|
719
973
|
return guardZip(await JSZip__default.default.loadAsync(bytes), limits);
|
|
720
974
|
}
|
|
721
975
|
|
|
976
|
+
// opc/merge-snapshots.ts
|
|
977
|
+
var equal = (a, b) => a === b || Boolean(a && b && a.length === b.length && a.every((value, index) => value === b[index]));
|
|
978
|
+
var decoder = new TextDecoder("utf-8", { fatal: true });
|
|
979
|
+
var encoder = new TextEncoder();
|
|
980
|
+
function mergeManifest(input) {
|
|
981
|
+
const { path, base, local, remote } = input;
|
|
982
|
+
if (!base || !local || !remote) return void 0;
|
|
983
|
+
if (!path.endsWith(".rels") && path !== "[Content_Types].xml" && path !== "docProps/core.xml")
|
|
984
|
+
return void 0;
|
|
985
|
+
try {
|
|
986
|
+
const result = mergeXmlThreeWay(
|
|
987
|
+
decoder.decode(base),
|
|
988
|
+
decoder.decode(local),
|
|
989
|
+
decoder.decode(remote),
|
|
990
|
+
{
|
|
991
|
+
keyElement: (element) => {
|
|
992
|
+
const attribute = element.localName === "Relationship" ? "Id" : element.localName === "Override" ? "PartName" : element.localName === "Default" ? "Extension" : void 0;
|
|
993
|
+
return attribute ? element.getAttribute(attribute) ?? void 0 : void 0;
|
|
994
|
+
},
|
|
995
|
+
resolveText: (_b, _l, r) => path === "docProps/core.xml" && (r.namespaceURI === "http://purl.org/dc/terms/" && r.localName === "modified" || r.namespaceURI === "http://schemas.openxmlformats.org/package/2006/metadata/core-properties" && r.localName === "lastModifiedBy") ? r.textContent ?? "" : void 0
|
|
996
|
+
}
|
|
997
|
+
);
|
|
998
|
+
return result.status === "merged" ? { status: "merged", bytes: encoder.encode(result.xml) } : result;
|
|
999
|
+
} catch {
|
|
1000
|
+
return { status: "unresolved", issues: [`${path}: invalid metadata XML`] };
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
async function mergeOpcSnapshots(baseBytes, localBytes, remoteBytes, options = {}) {
|
|
1004
|
+
if (equal(localBytes, remoteBytes) || equal(baseBytes, remoteBytes))
|
|
1005
|
+
return { status: "merged", bytes: localBytes.slice() };
|
|
1006
|
+
if (equal(baseBytes, localBytes)) return { status: "merged", bytes: remoteBytes.slice() };
|
|
1007
|
+
try {
|
|
1008
|
+
const [base, local, remote] = await Promise.all([
|
|
1009
|
+
openZip(baseBytes, { label: "Merge" }),
|
|
1010
|
+
openZip(localBytes, { label: "Merge" }),
|
|
1011
|
+
openZip(remoteBytes, { label: "Merge" })
|
|
1012
|
+
]);
|
|
1013
|
+
const paths = [
|
|
1014
|
+
...new Set(
|
|
1015
|
+
[base, local, remote].flatMap(
|
|
1016
|
+
(zip) => Object.keys(zip.files).filter((path) => !zip.files[path].dir)
|
|
1017
|
+
)
|
|
1018
|
+
)
|
|
1019
|
+
].sort();
|
|
1020
|
+
if (paths.some((path) => path.startsWith("_xmlsignatures/")))
|
|
1021
|
+
return {
|
|
1022
|
+
status: "unresolved",
|
|
1023
|
+
issues: ["Signed packages require explicit signature handling before merging"]
|
|
1024
|
+
};
|
|
1025
|
+
const issues = [];
|
|
1026
|
+
for (const path of paths) {
|
|
1027
|
+
const [b, l, r] = await Promise.all(
|
|
1028
|
+
[base, local, remote].map((zip) => zip.file(path)?.async("uint8array"))
|
|
1029
|
+
);
|
|
1030
|
+
let chosen;
|
|
1031
|
+
if (equal(l, r) || equal(b, r)) chosen = l;
|
|
1032
|
+
else if (equal(b, l)) chosen = r;
|
|
1033
|
+
else {
|
|
1034
|
+
const input = {
|
|
1035
|
+
path,
|
|
1036
|
+
...b ? { base: b } : {},
|
|
1037
|
+
...l ? { local: l } : {},
|
|
1038
|
+
...r ? { remote: r } : {}
|
|
1039
|
+
};
|
|
1040
|
+
const result = mergeManifest(input) ?? await options.mergePart?.(input);
|
|
1041
|
+
if (!result || result.status === "unresolved") {
|
|
1042
|
+
issues.push(...result?.issues ?? [`${path}: both versions changed the same part`]);
|
|
1043
|
+
continue;
|
|
1044
|
+
}
|
|
1045
|
+
chosen = result.bytes;
|
|
1046
|
+
}
|
|
1047
|
+
if (chosen) remote.file(path, chosen);
|
|
1048
|
+
else remote.remove(path);
|
|
1049
|
+
}
|
|
1050
|
+
if (issues.length) return { status: "unresolved", issues };
|
|
1051
|
+
for (const path of Object.keys(remote.files).filter((name) => name.endsWith(".rels"))) {
|
|
1052
|
+
const source = path === "_rels/.rels" ? "" : path.replace(/(^|\/)_rels\/([^/]+)\.rels$/u, "$1$2");
|
|
1053
|
+
for (const relation of parseRelationships(
|
|
1054
|
+
await remote.file(path).async("string")
|
|
1055
|
+
).values()) {
|
|
1056
|
+
if (relation.mode === "External") continue;
|
|
1057
|
+
const target = resolvePartPath(source, relation.target.split("#")[0] ?? "");
|
|
1058
|
+
if (!remote.file(target) && !remote.file(decodeURIComponent(target)))
|
|
1059
|
+
issues.push(`${path}: merged relationship target is missing`);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
if (issues.length) return { status: "unresolved", issues };
|
|
1063
|
+
return {
|
|
1064
|
+
status: "merged",
|
|
1065
|
+
bytes: await remote.generateAsync({ type: "uint8array", compression: "DEFLATE" })
|
|
1066
|
+
};
|
|
1067
|
+
} catch {
|
|
1068
|
+
return { status: "unresolved", issues: ["Invalid or oversized Office package"] };
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
// opc/clone-part-graph.ts
|
|
1073
|
+
function relativePartTarget(basePart, targetPart) {
|
|
1074
|
+
const base = basePart.split("/").slice(0, -1);
|
|
1075
|
+
const target = targetPart.split("/");
|
|
1076
|
+
while (base.length > 0 && base[0] === target[0]) {
|
|
1077
|
+
base.shift();
|
|
1078
|
+
target.shift();
|
|
1079
|
+
}
|
|
1080
|
+
return [...base.map(() => ".."), ...target].join("/");
|
|
1081
|
+
}
|
|
1082
|
+
async function clonePartGraph(options) {
|
|
1083
|
+
const { zip, sourcePart, targetPart, shouldClone } = options;
|
|
1084
|
+
const sourceZip = options.sourceZip ?? zip;
|
|
1085
|
+
const copies = options.copies ?? /* @__PURE__ */ new Map();
|
|
1086
|
+
copies.set(sourcePart, targetPart);
|
|
1087
|
+
const types = parseContentTypes(await sourceZip.file("[Content_Types].xml")?.async("string"));
|
|
1088
|
+
const reserved = new Set(Object.keys(zip.files));
|
|
1089
|
+
reserved.add(targetPart);
|
|
1090
|
+
for (const target of copies.values()) reserved.add(target);
|
|
1091
|
+
const allocate = (source) => {
|
|
1092
|
+
const match = /^(?<stem>.*?)(?:\d+)?(?<extension>\.[^/.]+)$/u.exec(source);
|
|
1093
|
+
const stem = match?.groups?.stem ?? source;
|
|
1094
|
+
const extension = match?.groups?.extension ?? "";
|
|
1095
|
+
let index = 1;
|
|
1096
|
+
while (reserved.has(`${stem}${index}${extension}`)) index += 1;
|
|
1097
|
+
const path = `${stem}${index}${extension}`;
|
|
1098
|
+
reserved.add(path);
|
|
1099
|
+
return path;
|
|
1100
|
+
};
|
|
1101
|
+
const copyRelationships = async (source, destination) => {
|
|
1102
|
+
const contentType = contentTypeForPart(types, source);
|
|
1103
|
+
if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
|
|
1104
|
+
const xml2 = await sourceZip.file(relationshipsPartFor(source))?.async("string");
|
|
1105
|
+
if (!xml2) return;
|
|
1106
|
+
const relationships = parseRelationships(xml2);
|
|
1107
|
+
for (const relationship of relationships.values()) {
|
|
1108
|
+
if (relationship.mode === "External") continue;
|
|
1109
|
+
const originalTarget = resolvePartPath(source, relationship.target);
|
|
1110
|
+
let newTarget = copies.get(originalTarget);
|
|
1111
|
+
if (!newTarget && shouldClone(relationship, originalTarget)) {
|
|
1112
|
+
const file = sourceZip.file(originalTarget);
|
|
1113
|
+
if (!file) throw new Error(`Cannot clone missing package part: ${originalTarget}`);
|
|
1114
|
+
newTarget = allocate(originalTarget);
|
|
1115
|
+
copies.set(originalTarget, newTarget);
|
|
1116
|
+
zip.file(newTarget, await file.async("uint8array"));
|
|
1117
|
+
await copyRelationships(originalTarget, newTarget);
|
|
1118
|
+
}
|
|
1119
|
+
relationship.target = relativePartTarget(destination, newTarget ?? originalTarget);
|
|
1120
|
+
}
|
|
1121
|
+
zip.file(relationshipsPartFor(destination), buildRelationshipsXml(relationships));
|
|
1122
|
+
};
|
|
1123
|
+
await copyRelationships(sourcePart, targetPart);
|
|
1124
|
+
return copies;
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
// opc/safe-href.ts
|
|
1128
|
+
var SAFE_SCHEMES = /* @__PURE__ */ new Set(["http:", "https:", "mailto:"]);
|
|
1129
|
+
function isSafeHyperlinkHref(href) {
|
|
1130
|
+
const scheme = /^([a-z][a-z0-9+.-]*:)/i.exec(href.trim())?.[1];
|
|
1131
|
+
return scheme !== void 0 && SAFE_SCHEMES.has(scheme.toLowerCase());
|
|
1132
|
+
}
|
|
1133
|
+
var OPEN_SCHEMES = /* @__PURE__ */ new Set(["http", "https", "mailto"]);
|
|
1134
|
+
var STORE_SCHEMES = /* @__PURE__ */ new Set([...OPEN_SCHEMES, "ftp", "file"]);
|
|
1135
|
+
var SCRIPT_SCHEMES = /* @__PURE__ */ new Set([
|
|
1136
|
+
"javascript",
|
|
1137
|
+
"vbscript",
|
|
1138
|
+
"livescript",
|
|
1139
|
+
"jscript",
|
|
1140
|
+
"mocha",
|
|
1141
|
+
"data",
|
|
1142
|
+
"mhtml",
|
|
1143
|
+
"ms-its",
|
|
1144
|
+
"mk",
|
|
1145
|
+
"x-javascript",
|
|
1146
|
+
"blob"
|
|
1147
|
+
]);
|
|
1148
|
+
var IGNORABLE = new RegExp(
|
|
1149
|
+
"[\\u0000-\\u0020\\u007f\\u00ad\\u200b-\\u200f\\u202a-\\u202e\\u2060-\\u2064\\ufeff]",
|
|
1150
|
+
"gu"
|
|
1151
|
+
);
|
|
1152
|
+
var CONTROL = new RegExp("[\\u0000-\\u001f\\u007f]", "u");
|
|
1153
|
+
var SCHEME = /^([a-z][a-z0-9+.-]*):/;
|
|
1154
|
+
var STORE_ONLY = { store: true, open: false, reason: "not-openable" };
|
|
1155
|
+
var reject = (reason) => ({
|
|
1156
|
+
store: false,
|
|
1157
|
+
open: false,
|
|
1158
|
+
reason
|
|
1159
|
+
});
|
|
1160
|
+
function hyperlinkPolicy(href, options = {}) {
|
|
1161
|
+
if (typeof href !== "string") return reject("empty");
|
|
1162
|
+
const trimmed = href.trim();
|
|
1163
|
+
const normalized = trimmed.replace(IGNORABLE, "").toLowerCase();
|
|
1164
|
+
if (normalized.length === 0) return reject("empty");
|
|
1165
|
+
const scheme = SCHEME.exec(normalized)?.[1];
|
|
1166
|
+
if (scheme !== void 0 && SCRIPT_SCHEMES.has(scheme)) return reject("script-scheme");
|
|
1167
|
+
if (scheme !== void 0 && !trimmed.toLowerCase().startsWith(`${scheme}:`))
|
|
1168
|
+
return reject("obfuscated-scheme");
|
|
1169
|
+
if (CONTROL.test(trimmed)) return reject("control-characters");
|
|
1170
|
+
if (scheme === void 0) return options.openRelative ? { store: true, open: true } : STORE_ONLY;
|
|
1171
|
+
if (scheme.length === 1) return STORE_ONLY;
|
|
1172
|
+
if (OPEN_SCHEMES.has(scheme)) return { store: true, open: true };
|
|
1173
|
+
if (options.additionalOpenSchemes?.some((allowed) => allowed.toLowerCase() === scheme))
|
|
1174
|
+
return { store: true, open: true };
|
|
1175
|
+
if (STORE_SCHEMES.has(scheme)) return STORE_ONLY;
|
|
1176
|
+
return reject("unsupported-scheme");
|
|
1177
|
+
}
|
|
1178
|
+
function isStorableHyperlinkHref(href, options) {
|
|
1179
|
+
return hyperlinkPolicy(href, options).store;
|
|
1180
|
+
}
|
|
1181
|
+
function isOpenableHyperlinkHref(href, options) {
|
|
1182
|
+
return hyperlinkPolicy(href, options).open;
|
|
1183
|
+
}
|
|
1184
|
+
|
|
722
1185
|
// opc/embedded-packages.ts
|
|
723
1186
|
var EMBEDDED_ZIP_LIMITS = {
|
|
724
1187
|
label: "Embedded",
|
|
@@ -771,10 +1234,10 @@ var PROPERTY_CONTENT_TYPES = {
|
|
|
771
1234
|
|
|
772
1235
|
// opc/properties/patch.ts
|
|
773
1236
|
var XMLNS = "http://www.w3.org/2000/xmlns/";
|
|
774
|
-
function tagEnd(
|
|
1237
|
+
function tagEnd(xml2, from) {
|
|
775
1238
|
let quote = "";
|
|
776
|
-
for (let i = from + 1; i <
|
|
777
|
-
const ch =
|
|
1239
|
+
for (let i = from + 1; i < xml2.length; i++) {
|
|
1240
|
+
const ch = xml2[i];
|
|
778
1241
|
if (quote) {
|
|
779
1242
|
if (ch === quote) quote = "";
|
|
780
1243
|
} else if (ch === '"' || ch === "'") quote = ch;
|
|
@@ -782,24 +1245,24 @@ function tagEnd(xml, from) {
|
|
|
782
1245
|
}
|
|
783
1246
|
throw new Error("Unterminated tag in property part");
|
|
784
1247
|
}
|
|
785
|
-
function skipMarkup(
|
|
786
|
-
if (
|
|
787
|
-
if (
|
|
788
|
-
if (
|
|
1248
|
+
function skipMarkup(xml2, at) {
|
|
1249
|
+
if (xml2.startsWith("<!--", at)) return xml2.indexOf("-->", at) + 3;
|
|
1250
|
+
if (xml2.startsWith("<![CDATA[", at)) return xml2.indexOf("]]>", at) + 3;
|
|
1251
|
+
if (xml2.startsWith("<?", at)) return xml2.indexOf("?>", at) + 2;
|
|
789
1252
|
return void 0;
|
|
790
1253
|
}
|
|
791
|
-
function scan(
|
|
1254
|
+
function scan(xml2) {
|
|
792
1255
|
let i = 0;
|
|
793
1256
|
let rootStart = -1;
|
|
794
1257
|
while (rootStart < 0) {
|
|
795
|
-
const lt =
|
|
1258
|
+
const lt = xml2.indexOf("<", i);
|
|
796
1259
|
if (lt < 0) throw new Error("Property part has no root element");
|
|
797
|
-
const skipped = skipMarkup(
|
|
1260
|
+
const skipped = skipMarkup(xml2, lt);
|
|
798
1261
|
if (skipped !== void 0) i = skipped;
|
|
799
1262
|
else rootStart = lt;
|
|
800
1263
|
}
|
|
801
|
-
const openEnd = tagEnd(
|
|
802
|
-
if (
|
|
1264
|
+
const openEnd = tagEnd(xml2, rootStart);
|
|
1265
|
+
if (xml2[openEnd - 2] === "/") {
|
|
803
1266
|
const root = {
|
|
804
1267
|
start: rootStart,
|
|
805
1268
|
openEnd,
|
|
@@ -814,16 +1277,16 @@ function scan(xml) {
|
|
|
814
1277
|
let child;
|
|
815
1278
|
i = openEnd;
|
|
816
1279
|
for (; ; ) {
|
|
817
|
-
const lt =
|
|
1280
|
+
const lt = xml2.indexOf("<", i);
|
|
818
1281
|
if (lt < 0) throw new Error("Property part root is not closed");
|
|
819
|
-
const skipped = skipMarkup(
|
|
1282
|
+
const skipped = skipMarkup(xml2, lt);
|
|
820
1283
|
if (skipped !== void 0) {
|
|
821
1284
|
i = skipped;
|
|
822
1285
|
continue;
|
|
823
1286
|
}
|
|
824
|
-
const end = tagEnd(
|
|
1287
|
+
const end = tagEnd(xml2, lt);
|
|
825
1288
|
i = end;
|
|
826
|
-
if (
|
|
1289
|
+
if (xml2[lt + 1] === "/") {
|
|
827
1290
|
if (depth === 0) {
|
|
828
1291
|
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
829
1292
|
return { root, children: children2 };
|
|
@@ -831,7 +1294,7 @@ function scan(xml) {
|
|
|
831
1294
|
depth--;
|
|
832
1295
|
if (depth === 0 && child)
|
|
833
1296
|
children2.push({ ...child, closeStart: lt, end, selfClosing: false });
|
|
834
|
-
} else if (
|
|
1297
|
+
} else if (xml2[end - 2] === "/") {
|
|
835
1298
|
if (depth === 0)
|
|
836
1299
|
children2.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
837
1300
|
} else {
|
|
@@ -841,11 +1304,11 @@ function scan(xml) {
|
|
|
841
1304
|
}
|
|
842
1305
|
}
|
|
843
1306
|
var escapeText = (text) => text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
844
|
-
var qualifiedName = (
|
|
1307
|
+
var qualifiedName = (xml2, span) => /^<([^\s/>]+)/.exec(xml2.slice(span.start, span.openEnd))?.[1] ?? "";
|
|
845
1308
|
var PartPatch = class {
|
|
846
|
-
constructor(
|
|
847
|
-
this.xml =
|
|
848
|
-
const { root, children: children2 } = scan(
|
|
1309
|
+
constructor(xml2, rootElement) {
|
|
1310
|
+
this.xml = xml2;
|
|
1311
|
+
const { root, children: children2 } = scan(xml2);
|
|
849
1312
|
const kids = elements(rootElement);
|
|
850
1313
|
if (kids.length !== children2.length) throw new Error("Property part markup is not supported");
|
|
851
1314
|
kids.forEach((kid, index) => this.spans.set(kid, children2[index]));
|
|
@@ -960,10 +1423,10 @@ var FIELDS = [
|
|
|
960
1423
|
var CORE_PROPERTY_FIELDS = FIELDS.map(([field]) => field);
|
|
961
1424
|
var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
962
1425
|
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
963
|
-
function parseCoreProperties(
|
|
1426
|
+
function parseCoreProperties(xml2) {
|
|
964
1427
|
const out = {};
|
|
965
|
-
if (!
|
|
966
|
-
const root = parseXml(
|
|
1428
|
+
if (!xml2) return out;
|
|
1429
|
+
const root = parseXml(xml2, { label: "core properties" }).documentElement;
|
|
967
1430
|
for (const [field, prefix] of FIELDS) {
|
|
968
1431
|
const text = first(root, field, NS[prefix])?.textContent ?? "";
|
|
969
1432
|
if (text !== "") out[field] = text;
|
|
@@ -972,9 +1435,9 @@ function parseCoreProperties(xml) {
|
|
|
972
1435
|
}
|
|
973
1436
|
var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
974
1437
|
function writeCoreProperties(props, sourceXml) {
|
|
975
|
-
const
|
|
976
|
-
const root = parseXml(
|
|
977
|
-
const patch = new PartPatch(
|
|
1438
|
+
const xml2 = sourceXml ?? EMPTY_CORE;
|
|
1439
|
+
const root = parseXml(xml2, { label: "core properties" }).documentElement;
|
|
1440
|
+
const patch = new PartPatch(xml2, root);
|
|
978
1441
|
for (const [field, prefix, isDate] of FIELDS) {
|
|
979
1442
|
const ns = NS[prefix];
|
|
980
1443
|
const value = props[field];
|
|
@@ -1072,9 +1535,9 @@ function readKnown(root, ns) {
|
|
|
1072
1535
|
}
|
|
1073
1536
|
return out;
|
|
1074
1537
|
}
|
|
1075
|
-
function parseAppProperties(
|
|
1076
|
-
if (!
|
|
1077
|
-
const root = parseXml(
|
|
1538
|
+
function parseAppProperties(xml2) {
|
|
1539
|
+
if (!xml2) return {};
|
|
1540
|
+
const root = parseXml(xml2, { label: "app properties" }).documentElement;
|
|
1078
1541
|
const ns = namespacesOf(root);
|
|
1079
1542
|
return ns ? readKnown(root, ns) : {};
|
|
1080
1543
|
}
|
|
@@ -1092,11 +1555,11 @@ function content(kind, value, vt) {
|
|
|
1092
1555
|
return `<${vt}:vector size="${items.length}" baseType="${baseType}">${items.join("")}</${vt}:vector>`;
|
|
1093
1556
|
}
|
|
1094
1557
|
function writeAppProperties(props, sourceXml) {
|
|
1095
|
-
const
|
|
1096
|
-
const root = parseXml(
|
|
1558
|
+
const xml2 = sourceXml ?? EMPTY_APP;
|
|
1559
|
+
const root = parseXml(xml2, { label: "app properties" }).documentElement;
|
|
1097
1560
|
const ns = namespacesOf(root);
|
|
1098
1561
|
if (!ns) throw new Error("app properties root is not an extended-properties element");
|
|
1099
|
-
const patch = new PartPatch(
|
|
1562
|
+
const patch = new PartPatch(xml2, root);
|
|
1100
1563
|
const prior = readKnown(root, ns);
|
|
1101
1564
|
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
1102
1565
|
FIELDS2.forEach(([field, local, kind], index) => {
|
|
@@ -1147,9 +1610,9 @@ function readValue(variant) {
|
|
|
1147
1610
|
return void 0;
|
|
1148
1611
|
}
|
|
1149
1612
|
}
|
|
1150
|
-
function parseCustomProperties(
|
|
1151
|
-
if (!
|
|
1152
|
-
const root = parseXml(
|
|
1613
|
+
function parseCustomProperties(xml2) {
|
|
1614
|
+
if (!xml2) return [];
|
|
1615
|
+
const root = parseXml(xml2, { label: "custom properties" }).documentElement;
|
|
1153
1616
|
const out = [];
|
|
1154
1617
|
for (const property of children(root, "property", NS.customProperties)) {
|
|
1155
1618
|
const name = property.getAttribute("name") ?? "";
|
|
@@ -1215,9 +1678,9 @@ function writeCustomProperties(properties) {
|
|
|
1215
1678
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1216
1679
|
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
1217
1680
|
}
|
|
1218
|
-
function parseCustomPropertyTexts(
|
|
1219
|
-
if (!
|
|
1220
|
-
const root = parseXml(
|
|
1681
|
+
function parseCustomPropertyTexts(xml2) {
|
|
1682
|
+
if (!xml2) return [];
|
|
1683
|
+
const root = parseXml(xml2, { label: "custom properties" }).documentElement;
|
|
1221
1684
|
const out = [];
|
|
1222
1685
|
for (const property of children(root, "property", NS.customProperties)) {
|
|
1223
1686
|
const name = property.getAttribute("name") ?? "";
|
|
@@ -1555,63 +2018,63 @@ function escapeXmlText(value) {
|
|
|
1555
2018
|
function isValidBase64(value) {
|
|
1556
2019
|
return typeof value === "string" && value.length > 0 && /^[A-Za-z0-9+/=\s]+$/.test(value);
|
|
1557
2020
|
}
|
|
1558
|
-
function extractTagAttribute(
|
|
2021
|
+
function extractTagAttribute(xml2, tagName, attributeName) {
|
|
1559
2022
|
const pattern = new RegExp(
|
|
1560
2023
|
`<${tagName}\\b[^>]*\\b${attributeName}="(?<attributeValue>[^"]+)"`,
|
|
1561
2024
|
"i"
|
|
1562
2025
|
);
|
|
1563
|
-
const match =
|
|
2026
|
+
const match = xml2.match(pattern);
|
|
1564
2027
|
return match?.groups?.["attributeValue"]?.trim();
|
|
1565
2028
|
}
|
|
1566
2029
|
var isNameChar = (c) => c !== void 0 && /[\w.-]/.test(c);
|
|
1567
2030
|
var isWordChar = (c) => c !== void 0 && /\w/.test(c);
|
|
1568
|
-
function matchName(
|
|
2031
|
+
function matchName(xml2, lowerXml, from, lname) {
|
|
1569
2032
|
let pos = from;
|
|
1570
2033
|
if (!lowerXml.startsWith(lname, pos)) {
|
|
1571
2034
|
let end = pos;
|
|
1572
|
-
while (isNameChar(
|
|
1573
|
-
if (end === pos ||
|
|
2035
|
+
while (isNameChar(xml2[end])) end++;
|
|
2036
|
+
if (end === pos || xml2[end] !== ":") return -1;
|
|
1574
2037
|
pos = end + 1;
|
|
1575
2038
|
if (!lowerXml.startsWith(lname, pos)) return -1;
|
|
1576
2039
|
}
|
|
1577
2040
|
return pos + lname.length;
|
|
1578
2041
|
}
|
|
1579
|
-
function findTagText(
|
|
1580
|
-
let lt =
|
|
2042
|
+
function findTagText(xml2, lowerXml, lname, from) {
|
|
2043
|
+
let lt = xml2.indexOf("<", from);
|
|
1581
2044
|
while (lt !== -1) {
|
|
1582
|
-
const afterName = matchName(
|
|
1583
|
-
if (afterName !== -1 && !isWordChar(
|
|
1584
|
-
const gt =
|
|
2045
|
+
const afterName = matchName(xml2, lowerXml, lt + 1, lname);
|
|
2046
|
+
if (afterName !== -1 && !isWordChar(xml2[afterName])) {
|
|
2047
|
+
const gt = xml2.indexOf(">", afterName);
|
|
1585
2048
|
if (gt === -1) return null;
|
|
1586
|
-
let close =
|
|
2049
|
+
let close = xml2.indexOf("</", gt + 1);
|
|
1587
2050
|
while (close !== -1) {
|
|
1588
|
-
const closeEnd = matchName(
|
|
1589
|
-
if (closeEnd !== -1 &&
|
|
1590
|
-
return { text:
|
|
2051
|
+
const closeEnd = matchName(xml2, lowerXml, close + 2, lname);
|
|
2052
|
+
if (closeEnd !== -1 && xml2[closeEnd] === ">") {
|
|
2053
|
+
return { text: xml2.slice(gt + 1, close), end: closeEnd + 1 };
|
|
1591
2054
|
}
|
|
1592
|
-
close =
|
|
2055
|
+
close = xml2.indexOf("</", close + 2);
|
|
1593
2056
|
}
|
|
1594
2057
|
return null;
|
|
1595
2058
|
}
|
|
1596
|
-
lt =
|
|
2059
|
+
lt = xml2.indexOf("<", lt + 1);
|
|
1597
2060
|
}
|
|
1598
2061
|
return null;
|
|
1599
2062
|
}
|
|
1600
|
-
function extractFirstTagText(
|
|
1601
|
-
const found = findTagText(
|
|
2063
|
+
function extractFirstTagText(xml2, localName) {
|
|
2064
|
+
const found = findTagText(xml2, xml2.toLowerCase(), localName.toLowerCase(), 0);
|
|
1602
2065
|
return found?.text.replace(/\s+/g, "").trim() || void 0;
|
|
1603
2066
|
}
|
|
1604
|
-
function extractAllTagText(
|
|
2067
|
+
function extractAllTagText(xml2, localName) {
|
|
1605
2068
|
const result = [];
|
|
1606
|
-
const lowerXml =
|
|
2069
|
+
const lowerXml = xml2.toLowerCase();
|
|
1607
2070
|
const lname = localName.toLowerCase();
|
|
1608
|
-
let found = findTagText(
|
|
2071
|
+
let found = findTagText(xml2, lowerXml, lname, 0);
|
|
1609
2072
|
while (found) {
|
|
1610
2073
|
const value = found.text.replace(/\s+/g, "").trim();
|
|
1611
2074
|
if (value) {
|
|
1612
2075
|
result.push(value);
|
|
1613
2076
|
}
|
|
1614
|
-
found = findTagText(
|
|
2077
|
+
found = findTagText(xml2, lowerXml, lname, found.end);
|
|
1615
2078
|
}
|
|
1616
2079
|
return result;
|
|
1617
2080
|
}
|
|
@@ -1812,6 +2275,7 @@ exports.isSafeHyperlinkHref = isSafeHyperlinkHref;
|
|
|
1812
2275
|
exports.isSafePartName = isSafePartName;
|
|
1813
2276
|
exports.isStorableHyperlinkHref = isStorableHyperlinkHref;
|
|
1814
2277
|
exports.listEmbeddedPackages = listEmbeddedPackages;
|
|
2278
|
+
exports.mergeOpcSnapshots = mergeOpcSnapshots;
|
|
1815
2279
|
exports.nextRelationshipId = nextRelationshipId;
|
|
1816
2280
|
exports.openZip = openZip;
|
|
1817
2281
|
exports.parseAppProperties = parseAppProperties;
|