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/index.mjs
CHANGED
|
@@ -2576,6 +2576,7 @@ __export(xml_exports, {
|
|
|
2576
2576
|
isElement: () => isElement,
|
|
2577
2577
|
liteChildElements: () => liteChildElements,
|
|
2578
2578
|
makeNS: () => makeNS,
|
|
2579
|
+
mergeXmlThreeWay: () => mergeXmlThreeWay,
|
|
2579
2580
|
named: () => named,
|
|
2580
2581
|
parseLiteFragment: () => parseLiteFragment,
|
|
2581
2582
|
parseXml: () => parseXml,
|
|
@@ -2676,28 +2677,28 @@ var MARKUP_SKIPS = [
|
|
|
2676
2677
|
["<![CDATA[", "]]>"],
|
|
2677
2678
|
["<?", "?>"]
|
|
2678
2679
|
];
|
|
2679
|
-
function checkXmlLimits(
|
|
2680
|
+
function checkXmlLimits(xml2, label, limits = {}) {
|
|
2680
2681
|
const maxDepth2 = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
2681
2682
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
2682
2683
|
let depth = 0;
|
|
2683
2684
|
let nodes = 0;
|
|
2684
|
-
let at2 =
|
|
2685
|
+
let at2 = xml2.indexOf("<");
|
|
2685
2686
|
while (at2 !== -1) {
|
|
2686
|
-
const skip = MARKUP_SKIPS.find(([open]) =>
|
|
2687
|
+
const skip = MARKUP_SKIPS.find(([open]) => xml2.startsWith(open, at2));
|
|
2687
2688
|
if (skip) {
|
|
2688
|
-
const end =
|
|
2689
|
+
const end = xml2.indexOf(skip[1], at2 + skip[0].length);
|
|
2689
2690
|
if (end === -1) return;
|
|
2690
|
-
at2 =
|
|
2691
|
+
at2 = xml2.indexOf("<", end + skip[1].length);
|
|
2691
2692
|
continue;
|
|
2692
2693
|
}
|
|
2693
2694
|
TAG_RE.lastIndex = at2;
|
|
2694
|
-
const match = TAG_RE.exec(
|
|
2695
|
+
const match = TAG_RE.exec(xml2);
|
|
2695
2696
|
if (!match) {
|
|
2696
|
-
at2 =
|
|
2697
|
+
at2 = xml2.indexOf("<", at2 + 1);
|
|
2697
2698
|
continue;
|
|
2698
2699
|
}
|
|
2699
2700
|
const [, closing, , selfClosing] = match;
|
|
2700
|
-
at2 =
|
|
2701
|
+
at2 = xml2.indexOf("<", at2 + match[0].length);
|
|
2701
2702
|
if (closing) {
|
|
2702
2703
|
depth--;
|
|
2703
2704
|
continue;
|
|
@@ -2719,11 +2720,11 @@ function checkXmlLimits(xml, label, limits = {}) {
|
|
|
2719
2720
|
}
|
|
2720
2721
|
var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
|
|
2721
2722
|
var crlfDeclarations = /* @__PURE__ */ new WeakSet();
|
|
2722
|
-
function parseXml(
|
|
2723
|
+
function parseXml(xml2, options2 = {}) {
|
|
2723
2724
|
const label = options2.label ?? "OOXML";
|
|
2724
|
-
if (/<!DOCTYPE|<!ENTITY/i.test(
|
|
2725
|
+
if (/<!DOCTYPE|<!ENTITY/i.test(xml2))
|
|
2725
2726
|
throw new Error(`${label} XML with DTD or entity declarations is not supported`);
|
|
2726
|
-
checkXmlLimits(
|
|
2727
|
+
checkXmlLimits(xml2, label, options2.limits);
|
|
2727
2728
|
let parseError = "";
|
|
2728
2729
|
let parsed;
|
|
2729
2730
|
try {
|
|
@@ -2731,7 +2732,7 @@ function parseXml(xml, options2 = {}) {
|
|
|
2731
2732
|
onError: (level4, message) => {
|
|
2732
2733
|
if (level4 !== "warning" || options2.warningsAsErrors) parseError = message;
|
|
2733
2734
|
}
|
|
2734
|
-
}).parseFromString(
|
|
2735
|
+
}).parseFromString(xml2, "application/xml");
|
|
2735
2736
|
} catch (error) {
|
|
2736
2737
|
throw new Error(
|
|
2737
2738
|
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -2740,12 +2741,12 @@ function parseXml(xml, options2 = {}) {
|
|
|
2740
2741
|
}
|
|
2741
2742
|
if (parseError || !parsed.documentElement)
|
|
2742
2743
|
throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
|
|
2743
|
-
if (CRLF_DECLARATION.test(
|
|
2744
|
+
if (CRLF_DECLARATION.test(xml2)) crlfDeclarations.add(parsed);
|
|
2744
2745
|
return parsed;
|
|
2745
2746
|
}
|
|
2746
2747
|
var buildXml = (node) => {
|
|
2747
|
-
const
|
|
2748
|
-
return crlfDeclarations.has(node) ?
|
|
2748
|
+
const xml2 = new XMLSerializer().serializeToString(node);
|
|
2749
|
+
return crlfDeclarations.has(node) ? xml2.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml2;
|
|
2749
2750
|
};
|
|
2750
2751
|
var isElement = (node) => node.nodeType === 1;
|
|
2751
2752
|
var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
|
|
@@ -2762,6 +2763,373 @@ function attr(element4, local, ns, prefix) {
|
|
|
2762
2763
|
}
|
|
2763
2764
|
var relAttr = (element4, local) => attr(element4, local, NS.r, "r");
|
|
2764
2765
|
|
|
2766
|
+
// text/text-diff.ts
|
|
2767
|
+
var isLowSurrogate = (text3, at2) => {
|
|
2768
|
+
const code = text3.charCodeAt(at2);
|
|
2769
|
+
return code >= 56320 && code <= 57343;
|
|
2770
|
+
};
|
|
2771
|
+
function shortestEdit(n2, m, same5, maxEdits) {
|
|
2772
|
+
const max = Math.min(n2 + m, maxEdits);
|
|
2773
|
+
const offset = max + 1;
|
|
2774
|
+
const v = new Int32Array(2 * max + 3);
|
|
2775
|
+
const trace = [];
|
|
2776
|
+
for (let d = 0; d <= max; d++) {
|
|
2777
|
+
for (let k = -d; k <= d; k += 2) {
|
|
2778
|
+
const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
|
|
2779
|
+
let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
|
|
2780
|
+
let y = x - k;
|
|
2781
|
+
while (x < n2 && y < m && same5(x, y)) {
|
|
2782
|
+
x++;
|
|
2783
|
+
y++;
|
|
2784
|
+
}
|
|
2785
|
+
v[offset + k] = x;
|
|
2786
|
+
if (x >= n2 && y >= m) return backtrack(trace, n2, m, d);
|
|
2787
|
+
}
|
|
2788
|
+
trace.push(v.slice(offset - d, offset + d + 1));
|
|
2789
|
+
}
|
|
2790
|
+
return void 0;
|
|
2791
|
+
}
|
|
2792
|
+
function backtrack(trace, n2, m, d) {
|
|
2793
|
+
const edits = [];
|
|
2794
|
+
let x = n2;
|
|
2795
|
+
let y = m;
|
|
2796
|
+
for (let step = d; step > 0; step--) {
|
|
2797
|
+
const previous = trace[step - 1];
|
|
2798
|
+
const at2 = (k2) => previous[k2 + step - 1];
|
|
2799
|
+
const k = x - y;
|
|
2800
|
+
const down = k === -step || k !== step && at2(k - 1) < at2(k + 1);
|
|
2801
|
+
const before = down ? k + 1 : k - 1;
|
|
2802
|
+
const startX = at2(before);
|
|
2803
|
+
const startY = startX - before;
|
|
2804
|
+
edits.push(down ? [startX, startY, true] : [startX, startY, false]);
|
|
2805
|
+
x = startX;
|
|
2806
|
+
y = startY;
|
|
2807
|
+
}
|
|
2808
|
+
return edits.reverse();
|
|
2809
|
+
}
|
|
2810
|
+
function changesOf(edits) {
|
|
2811
|
+
const changes = [];
|
|
2812
|
+
for (const [x, y, inserts] of edits) {
|
|
2813
|
+
const last = changes.at(-1);
|
|
2814
|
+
if (last && last.fromEnd === x && last.toEnd === y) {
|
|
2815
|
+
if (inserts) last.toEnd++;
|
|
2816
|
+
else last.fromEnd++;
|
|
2817
|
+
} else
|
|
2818
|
+
changes.push({
|
|
2819
|
+
fromStart: x,
|
|
2820
|
+
fromEnd: inserts ? x : x + 1,
|
|
2821
|
+
toStart: y,
|
|
2822
|
+
toEnd: inserts ? y + 1 : y
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
return changes;
|
|
2826
|
+
}
|
|
2827
|
+
function characterChanges(a2, b, maxEdits) {
|
|
2828
|
+
const edits = shortestEdit(
|
|
2829
|
+
a2.length,
|
|
2830
|
+
b.length,
|
|
2831
|
+
(x, y) => a2.charCodeAt(x) === b.charCodeAt(y),
|
|
2832
|
+
maxEdits
|
|
2833
|
+
);
|
|
2834
|
+
return edits && changesOf(edits);
|
|
2835
|
+
}
|
|
2836
|
+
var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
|
|
2837
|
+
function tokensOf(text3, ids) {
|
|
2838
|
+
const tokens = [];
|
|
2839
|
+
const starts = [];
|
|
2840
|
+
for (const match of text3.matchAll(TOKEN)) {
|
|
2841
|
+
let id = ids.get(match[0]);
|
|
2842
|
+
if (id === void 0) ids.set(match[0], id = ids.size);
|
|
2843
|
+
tokens.push(id);
|
|
2844
|
+
starts.push(match.index);
|
|
2845
|
+
}
|
|
2846
|
+
starts.push(text3.length);
|
|
2847
|
+
return { tokens, starts };
|
|
2848
|
+
}
|
|
2849
|
+
function tokenChanges(a2, b, maxEdits) {
|
|
2850
|
+
const ids = /* @__PURE__ */ new Map();
|
|
2851
|
+
const from = tokensOf(a2, ids);
|
|
2852
|
+
const to = tokensOf(b, ids);
|
|
2853
|
+
const edits = shortestEdit(
|
|
2854
|
+
from.tokens.length,
|
|
2855
|
+
to.tokens.length,
|
|
2856
|
+
(x, y) => from.tokens[x] === to.tokens[y],
|
|
2857
|
+
maxEdits
|
|
2858
|
+
);
|
|
2859
|
+
if (!edits) return void 0;
|
|
2860
|
+
let budget = maxEdits;
|
|
2861
|
+
return changesOf(edits).flatMap((stretch) => {
|
|
2862
|
+
const change = {
|
|
2863
|
+
fromStart: from.starts[stretch.fromStart],
|
|
2864
|
+
fromEnd: from.starts[stretch.fromEnd],
|
|
2865
|
+
toStart: to.starts[stretch.toStart],
|
|
2866
|
+
toEnd: to.starts[stretch.toEnd]
|
|
2867
|
+
};
|
|
2868
|
+
const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
|
|
2869
|
+
a2.slice(change.fromStart, change.fromEnd),
|
|
2870
|
+
b.slice(change.toStart, change.toEnd),
|
|
2871
|
+
budget
|
|
2872
|
+
) : void 0;
|
|
2873
|
+
if (!inner) return [change];
|
|
2874
|
+
for (const found of inner)
|
|
2875
|
+
budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
|
|
2876
|
+
return inner.map((found) => ({
|
|
2877
|
+
fromStart: found.fromStart + change.fromStart,
|
|
2878
|
+
fromEnd: found.fromEnd + change.fromStart,
|
|
2879
|
+
toStart: found.toStart + change.toStart,
|
|
2880
|
+
toEnd: found.toEnd + change.toStart
|
|
2881
|
+
}));
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
function diffText(from, to, maxEdits = 500) {
|
|
2885
|
+
let start = 0;
|
|
2886
|
+
while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
|
|
2887
|
+
start++;
|
|
2888
|
+
let end = 0;
|
|
2889
|
+
while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
|
|
2890
|
+
end++;
|
|
2891
|
+
const a2 = from.slice(start, from.length - end);
|
|
2892
|
+
const b = to.slice(start, to.length - end);
|
|
2893
|
+
if (!a2.length && !b.length) return [];
|
|
2894
|
+
const found = a2.length && b.length ? characterChanges(a2, b, maxEdits) ?? tokenChanges(a2, b, maxEdits) : void 0;
|
|
2895
|
+
const changes = found ?? [{ fromStart: 0, fromEnd: a2.length, toStart: 0, toEnd: b.length }];
|
|
2896
|
+
const result = [];
|
|
2897
|
+
for (const change of changes) {
|
|
2898
|
+
const placed2 = {
|
|
2899
|
+
fromStart: change.fromStart + start,
|
|
2900
|
+
fromEnd: change.fromEnd + start,
|
|
2901
|
+
toStart: change.toStart + start,
|
|
2902
|
+
toEnd: change.toEnd + start
|
|
2903
|
+
};
|
|
2904
|
+
if (placed2.fromStart > 0 && placed2.toStart > 0 && (isLowSurrogate(from, placed2.fromStart) || isLowSurrogate(to, placed2.toStart))) {
|
|
2905
|
+
placed2.fromStart--;
|
|
2906
|
+
placed2.toStart--;
|
|
2907
|
+
}
|
|
2908
|
+
if (isLowSurrogate(from, placed2.fromEnd) || isLowSurrogate(to, placed2.toEnd)) {
|
|
2909
|
+
placed2.fromEnd++;
|
|
2910
|
+
placed2.toEnd++;
|
|
2911
|
+
}
|
|
2912
|
+
const last = result.at(-1);
|
|
2913
|
+
if (last && placed2.fromStart <= last.fromEnd) {
|
|
2914
|
+
last.fromEnd = Math.max(last.fromEnd, placed2.fromEnd);
|
|
2915
|
+
last.toEnd = Math.max(last.toEnd, placed2.toEnd);
|
|
2916
|
+
} else result.push(placed2);
|
|
2917
|
+
}
|
|
2918
|
+
return result;
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
// text/merge-three-way.ts
|
|
2922
|
+
function mergeTextThreeWay(base, local, remote) {
|
|
2923
|
+
if (local === remote || base === remote) return { status: "merged", text: local };
|
|
2924
|
+
if (base === local) return { status: "merged", text: remote };
|
|
2925
|
+
if (Math.max(base.length, local.length, remote.length) > 1e6)
|
|
2926
|
+
return { status: "unresolved" };
|
|
2927
|
+
const changes = (value) => diffText(base, value).map((change) => ({
|
|
2928
|
+
start: change.fromStart,
|
|
2929
|
+
end: change.fromEnd,
|
|
2930
|
+
text: value.slice(change.toStart, change.toEnd)
|
|
2931
|
+
}));
|
|
2932
|
+
const edits = changes(local);
|
|
2933
|
+
for (const next of changes(remote)) {
|
|
2934
|
+
if (edits.some(
|
|
2935
|
+
(edit) => edit.start === next.start && edit.end === next.end && edit.text === next.text
|
|
2936
|
+
))
|
|
2937
|
+
continue;
|
|
2938
|
+
if (edits.some((edit) => {
|
|
2939
|
+
if (edit.start === edit.end && next.start === next.end) return false;
|
|
2940
|
+
if (edit.start === edit.end) return edit.start > next.start && edit.start < next.end;
|
|
2941
|
+
if (next.start === next.end) return next.start > edit.start && next.start < edit.end;
|
|
2942
|
+
return edit.start < next.end && next.start < edit.end;
|
|
2943
|
+
}))
|
|
2944
|
+
return { status: "unresolved" };
|
|
2945
|
+
edits.push(next);
|
|
2946
|
+
}
|
|
2947
|
+
edits.sort(
|
|
2948
|
+
(a2, b) => a2.start - b.start || a2.end - b.end || (a2.text < b.text ? -1 : a2.text > b.text ? 1 : 0)
|
|
2949
|
+
);
|
|
2950
|
+
let text3 = "", cursor = 0;
|
|
2951
|
+
for (const edit of edits) {
|
|
2952
|
+
text3 += base.slice(cursor, edit.start) + edit.text;
|
|
2953
|
+
cursor = edit.end;
|
|
2954
|
+
}
|
|
2955
|
+
return { status: "merged", text: text3 + base.slice(cursor) };
|
|
2956
|
+
}
|
|
2957
|
+
|
|
2958
|
+
// xml/merge-three-way.ts
|
|
2959
|
+
var tag = (node) => `${node.namespaceURI ?? ""}|${node.localName ?? node.tagName}`;
|
|
2960
|
+
var xml = (node) => node ? buildXml(node) : void 0;
|
|
2961
|
+
function childrenByKey(parent, options2, repeated) {
|
|
2962
|
+
const result = /* @__PURE__ */ new Map();
|
|
2963
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2964
|
+
for (const child6 of elements(parent)) {
|
|
2965
|
+
const name = tag(child6), explicit = options2.keyElement?.(child6, parent);
|
|
2966
|
+
const index = counts.get(name) ?? 0;
|
|
2967
|
+
counts.set(name, index + 1);
|
|
2968
|
+
if (!explicit && repeated.has(name) && !options2.allowPositional?.(parent))
|
|
2969
|
+
throw new Error("Ambiguous repeated elements");
|
|
2970
|
+
const key = explicit ? `${name}@${explicit}` : `${name}#${index}`;
|
|
2971
|
+
if (result.has(key)) throw new Error("Duplicate element identity");
|
|
2972
|
+
result.set(key, child6);
|
|
2973
|
+
}
|
|
2974
|
+
return result;
|
|
2975
|
+
}
|
|
2976
|
+
function orderKeys(base, local, remote) {
|
|
2977
|
+
const same5 = (a2, b) => a2.length === b.length && a2.every((key, index) => key === b[index]);
|
|
2978
|
+
if (same5(base, local)) return [...remote];
|
|
2979
|
+
if (same5(base, remote) || same5(local, remote)) return [...local];
|
|
2980
|
+
const keys = [.../* @__PURE__ */ new Set([...remote, ...local])].sort();
|
|
2981
|
+
const edges = new Map(keys.map((key) => [key, /* @__PURE__ */ new Set()]));
|
|
2982
|
+
const degree = new Map(keys.map((key) => [key, 0]));
|
|
2983
|
+
for (const sequence of [local, remote])
|
|
2984
|
+
for (let i2 = 1; i2 < sequence.length; i2++) {
|
|
2985
|
+
const previous = sequence[i2 - 1], next = sequence[i2];
|
|
2986
|
+
if (!edges.get(previous).has(next)) {
|
|
2987
|
+
edges.get(previous).add(next);
|
|
2988
|
+
degree.set(next, degree.get(next) + 1);
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
const out = [];
|
|
2992
|
+
const ready = keys.filter((key) => degree.get(key) === 0);
|
|
2993
|
+
while (ready.length) {
|
|
2994
|
+
const next = ready.sort().shift();
|
|
2995
|
+
out.push(next);
|
|
2996
|
+
for (const key of edges.get(next)) {
|
|
2997
|
+
degree.set(key, degree.get(key) - 1);
|
|
2998
|
+
if (degree.get(key) === 0) ready.push(key);
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
return out.length === keys.length ? out : void 0;
|
|
3002
|
+
}
|
|
3003
|
+
function mergeXmlThreeWay(baseXml, localXml, remoteXml, options2 = {}) {
|
|
3004
|
+
if (localXml === remoteXml || baseXml === remoteXml) return { status: "merged", xml: localXml };
|
|
3005
|
+
if (baseXml === localXml) return { status: "merged", xml: remoteXml };
|
|
3006
|
+
const issues = [];
|
|
3007
|
+
try {
|
|
3008
|
+
let merge2 = function(b, l, r, path3) {
|
|
3009
|
+
const bx = xml(b), lx = xml(l), rx = xml(r);
|
|
3010
|
+
if (lx === rx || bx === rx) return l ? copy(l) : void 0;
|
|
3011
|
+
if (bx === lx) return r ? copy(r) : void 0;
|
|
3012
|
+
if (!b && l && r && tag(l) === tag(r) && !elements(l).length && !elements(r).length) {
|
|
3013
|
+
const resolved = options2.resolveText?.(r, l, r);
|
|
3014
|
+
if (resolved !== void 0) {
|
|
3015
|
+
const node = copy(r);
|
|
3016
|
+
node.textContent = resolved;
|
|
3017
|
+
return node;
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
if (!b || !l || !r || tag(b) !== tag(l) || tag(b) !== tag(r)) {
|
|
3021
|
+
issues.push(`${path3}: overlapping structural changes`);
|
|
3022
|
+
return void 0;
|
|
3023
|
+
}
|
|
3024
|
+
const out = remote.createElementNS(r.namespaceURI, r.tagName);
|
|
3025
|
+
const attrs2 = (node) => new Map(
|
|
3026
|
+
Array.from(node.attributes).map((a2) => [
|
|
3027
|
+
`${a2.namespaceURI ?? ""}|${a2.localName ?? a2.name}`,
|
|
3028
|
+
a2
|
|
3029
|
+
])
|
|
3030
|
+
);
|
|
3031
|
+
const ba = attrs2(b), la = attrs2(l), ra = attrs2(r);
|
|
3032
|
+
for (const key of /* @__PURE__ */ new Set([...ba.keys(), ...la.keys(), ...ra.keys()])) {
|
|
3033
|
+
const old = ba.get(key)?.value, left = la.get(key)?.value, right = ra.get(key)?.value;
|
|
3034
|
+
const value = left === right || right === old ? left : left === old ? right : void 0;
|
|
3035
|
+
if (left !== right && left !== old && right !== old) {
|
|
3036
|
+
issues.push(`${path3}: overlapping attribute ${key}`);
|
|
3037
|
+
continue;
|
|
3038
|
+
}
|
|
3039
|
+
const source2 = ra.get(key) ?? la.get(key) ?? ba.get(key);
|
|
3040
|
+
if (value !== void 0) out.setAttributeNS(source2.namespaceURI, source2.name, value);
|
|
3041
|
+
}
|
|
3042
|
+
const lists = [b, l, r].map(elements);
|
|
3043
|
+
if (lists.every((list2) => list2.length === 0)) {
|
|
3044
|
+
if ([b, l, r].some(
|
|
3045
|
+
(node) => Array.from(node.childNodes).some(
|
|
3046
|
+
(child6) => child6.nodeType !== 3 && child6.nodeType !== 4
|
|
3047
|
+
)
|
|
3048
|
+
)) {
|
|
3049
|
+
issues.push(`${path3}: non-text leaf content requires explicit preservation`);
|
|
3050
|
+
return void 0;
|
|
3051
|
+
}
|
|
3052
|
+
const texts = [b, l, r].map((node) => node.textContent ?? "");
|
|
3053
|
+
const override = options2.resolveText?.(b, l, r);
|
|
3054
|
+
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] } : options2.allowText?.(b) ? mergeTextThreeWay(texts[0], texts[1], texts[2]) : { status: "unresolved" };
|
|
3055
|
+
if (value.status !== "merged") issues.push(`${path3}: overlapping text changes`);
|
|
3056
|
+
else if (value.text) out.appendChild(remote.createTextNode(value.text));
|
|
3057
|
+
return out;
|
|
3058
|
+
}
|
|
3059
|
+
if ([b, l, r].some(
|
|
3060
|
+
(node) => Array.from(node.childNodes).some(
|
|
3061
|
+
(child6) => child6.nodeType !== 1 && (child6.nodeType !== 3 || Boolean(child6.textContent?.trim()))
|
|
3062
|
+
)
|
|
3063
|
+
)) {
|
|
3064
|
+
issues.push(`${path3}: mixed content cannot be matched safely`);
|
|
3065
|
+
return void 0;
|
|
3066
|
+
}
|
|
3067
|
+
const repeated = /* @__PURE__ */ new Set();
|
|
3068
|
+
const groups = lists.map((list2) => {
|
|
3069
|
+
const grouped2 = /* @__PURE__ */ new Map();
|
|
3070
|
+
for (const child6 of list2) {
|
|
3071
|
+
const name = tag(child6), group2 = grouped2.get(name) ?? [];
|
|
3072
|
+
group2.push(child6);
|
|
3073
|
+
grouped2.set(name, group2);
|
|
3074
|
+
if (group2.length > 1) repeated.add(name);
|
|
3075
|
+
}
|
|
3076
|
+
return grouped2;
|
|
3077
|
+
});
|
|
3078
|
+
for (const name of repeated) {
|
|
3079
|
+
const rows2 = groups.map((group2) => group2.get(name) ?? []);
|
|
3080
|
+
if (rows2.some((row2) => row2.some((child6) => options2.keyElement?.(child6, b) !== void 0)))
|
|
3081
|
+
continue;
|
|
3082
|
+
if (rows2.some((row2) => row2.length !== rows2[0].length)) {
|
|
3083
|
+
issues.push(`${path3}: unkeyed structural changes`);
|
|
3084
|
+
return void 0;
|
|
3085
|
+
}
|
|
3086
|
+
const before = rows2[0].map((child6) => buildXml(child6));
|
|
3087
|
+
const known = new Set(before);
|
|
3088
|
+
for (const row2 of rows2.slice(1))
|
|
3089
|
+
if (row2.some((child6, i2) => {
|
|
3090
|
+
const value = buildXml(child6);
|
|
3091
|
+
return before[i2] !== value && known.has(value);
|
|
3092
|
+
})) {
|
|
3093
|
+
issues.push(`${path3}: reordered unkeyed elements`);
|
|
3094
|
+
return void 0;
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
let maps;
|
|
3098
|
+
try {
|
|
3099
|
+
maps = [b, l, r].map((parent) => childrenByKey(parent, options2, repeated));
|
|
3100
|
+
} catch {
|
|
3101
|
+
issues.push(`${path3}: ambiguous element identities`);
|
|
3102
|
+
return void 0;
|
|
3103
|
+
}
|
|
3104
|
+
const [bm, lm, rm] = maps;
|
|
3105
|
+
const merged = /* @__PURE__ */ new Map();
|
|
3106
|
+
for (const key of /* @__PURE__ */ new Set([...bm.keys(), ...lm.keys(), ...rm.keys()])) {
|
|
3107
|
+
const node = merge2(bm.get(key), lm.get(key), rm.get(key), `${path3}/${key}`);
|
|
3108
|
+
if (node) merged.set(key, node);
|
|
3109
|
+
}
|
|
3110
|
+
const surviving = (map) => [...map.keys()].filter((key) => merged.has(key));
|
|
3111
|
+
const order = orderKeys(surviving(bm), surviving(lm), surviving(rm));
|
|
3112
|
+
if (!order) {
|
|
3113
|
+
issues.push(`${path3}: incompatible element order`);
|
|
3114
|
+
return void 0;
|
|
3115
|
+
}
|
|
3116
|
+
for (const key of order) out.appendChild(merged.get(key));
|
|
3117
|
+
return out;
|
|
3118
|
+
};
|
|
3119
|
+
var merge = merge2;
|
|
3120
|
+
const base = parseXml(baseXml, { warningsAsErrors: true });
|
|
3121
|
+
const local = parseXml(localXml, { warningsAsErrors: true });
|
|
3122
|
+
const remote = parseXml(remoteXml, { warningsAsErrors: true });
|
|
3123
|
+
const copy = (node) => remote.importNode(node, true);
|
|
3124
|
+
const root = merge2(base.documentElement, local.documentElement, remote.documentElement, "root");
|
|
3125
|
+
if (!root || issues.length) return { status: "unresolved", issues };
|
|
3126
|
+
remote.replaceChild(root, remote.documentElement);
|
|
3127
|
+
return { status: "merged", xml: buildXml(remote) };
|
|
3128
|
+
} catch {
|
|
3129
|
+
return { status: "unresolved", issues: ["Invalid or unsupported XML input"] };
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
|
|
2765
3133
|
// xml/lite.ts
|
|
2766
3134
|
var LiteElement = class {
|
|
2767
3135
|
constructor(tagName, localName2, namespaceURI) {
|
|
@@ -2829,22 +3197,22 @@ function decode(text3) {
|
|
|
2829
3197
|
return ampersands === found ? out : void 0;
|
|
2830
3198
|
}
|
|
2831
3199
|
var isSpace = (code) => code === 32 || code === 9 || code === 10 || code === 13;
|
|
2832
|
-
var hasLineEnds = (
|
|
3200
|
+
var hasLineEnds = (xml2) => xml2.includes("\r") || xml2.includes("\x85") || xml2.includes("\u2028") || xml2.includes("\u2029");
|
|
2833
3201
|
var LiteDeclinedError = class extends Error {
|
|
2834
3202
|
constructor() {
|
|
2835
3203
|
super("The XML fragment needs the full parser");
|
|
2836
3204
|
this.name = "LiteDeclinedError";
|
|
2837
3205
|
}
|
|
2838
3206
|
};
|
|
2839
|
-
function parseLiteFragment(
|
|
2840
|
-
const nodes = topLevelNodes(
|
|
3207
|
+
function parseLiteFragment(xml2, container, namespaces) {
|
|
3208
|
+
const nodes = topLevelNodes(xml2, namespaces);
|
|
2841
3209
|
for (let next = nodes.next(); ; next = nodes.next()) {
|
|
2842
3210
|
if (next.done) return next.value ? container : void 0;
|
|
2843
3211
|
container.childNodes.push(next.value);
|
|
2844
3212
|
}
|
|
2845
3213
|
}
|
|
2846
|
-
function* liteChildElements(
|
|
2847
|
-
const nodes = topLevelNodes(
|
|
3214
|
+
function* liteChildElements(xml2, namespaces) {
|
|
3215
|
+
const nodes = topLevelNodes(xml2, namespaces);
|
|
2848
3216
|
for (let next = nodes.next(); ; next = nodes.next()) {
|
|
2849
3217
|
if (next.done) {
|
|
2850
3218
|
if (next.value) return;
|
|
@@ -2853,8 +3221,8 @@ function* liteChildElements(xml, namespaces) {
|
|
|
2853
3221
|
if (typeof next.value !== "string") yield next.value.asElement();
|
|
2854
3222
|
}
|
|
2855
3223
|
}
|
|
2856
|
-
function* topLevelNodes(
|
|
2857
|
-
const source2 = hasLineEnds(
|
|
3224
|
+
function* topLevelNodes(xml2, namespaces) {
|
|
3225
|
+
const source2 = hasLineEnds(xml2) ? xml2.replace(/\r[\n\u0085]/g, "\n").replace(/[\r\u0085\u2028\u2029]/g, "\n") : xml2;
|
|
2858
3226
|
const root = new LiteElement("", "", null);
|
|
2859
3227
|
const level4 = root.childNodes;
|
|
2860
3228
|
const stack = [root];
|
|
@@ -3342,8 +3710,8 @@ function chartPaletteColors(palette, n2, scheme2) {
|
|
|
3342
3710
|
var CHART_COLOR_STYLE_NS = "http://schemas.microsoft.com/office/drawing/2012/chartStyle";
|
|
3343
3711
|
var CHART_COLOR_STYLE_REL = "http://schemas.microsoft.com/office/2011/relationships/chartColorStyle";
|
|
3344
3712
|
var CHART_COLOR_STYLE_CONTENT_TYPE = "application/vnd.ms-office.chartcolorstyle+xml";
|
|
3345
|
-
function chartColorStyleId(
|
|
3346
|
-
const root = parseXml(
|
|
3713
|
+
function chartColorStyleId(xml2) {
|
|
3714
|
+
const root = parseXml(xml2).documentElement;
|
|
3347
3715
|
if (root.localName !== "colorStyle" || root.namespaceURI !== CHART_COLOR_STYLE_NS)
|
|
3348
3716
|
return void 0;
|
|
3349
3717
|
const value = root.getAttribute("id");
|
|
@@ -4250,11 +4618,11 @@ function entry(node) {
|
|
|
4250
4618
|
}
|
|
4251
4619
|
return out;
|
|
4252
4620
|
}
|
|
4253
|
-
function readChartStyle(
|
|
4254
|
-
const root = parseXml(
|
|
4621
|
+
function readChartStyle(xml2) {
|
|
4622
|
+
const root = parseXml(xml2, { label: "Office chart style" }).documentElement;
|
|
4255
4623
|
if (root.namespaceURI !== CHART_COLOR_STYLE_NS || root.localName !== "chartStyle")
|
|
4256
4624
|
return void 0;
|
|
4257
|
-
const out = { entries: {}, sourceXml:
|
|
4625
|
+
const out = { entries: {}, sourceXml: xml2 };
|
|
4258
4626
|
const id = root.getAttribute("id");
|
|
4259
4627
|
if (id && /^\d+$/.test(id) && Number.isSafeInteger(Number(id))) out.id = Number(id);
|
|
4260
4628
|
out.entries = Object.fromEntries(
|
|
@@ -4382,22 +4750,22 @@ function readChartManualLayoutValues(value) {
|
|
|
4382
4750
|
};
|
|
4383
4751
|
const target = enumeration("layoutTarget", ["inner", "outer"]);
|
|
4384
4752
|
if (target) result.layoutTarget = target;
|
|
4385
|
-
for (const [
|
|
4753
|
+
for (const [xml2, key] of [
|
|
4386
4754
|
["xMode", "xMode"],
|
|
4387
4755
|
["yMode", "yMode"],
|
|
4388
4756
|
["wMode", "widthMode"],
|
|
4389
4757
|
["hMode", "heightMode"]
|
|
4390
4758
|
]) {
|
|
4391
|
-
const mode = enumeration(
|
|
4759
|
+
const mode = enumeration(xml2, ["edge", "factor"]);
|
|
4392
4760
|
if (mode) result[key] = mode;
|
|
4393
4761
|
}
|
|
4394
|
-
for (const [
|
|
4762
|
+
for (const [xml2, key] of [
|
|
4395
4763
|
["x", "x"],
|
|
4396
4764
|
["y", "y"],
|
|
4397
4765
|
["w", "width"],
|
|
4398
4766
|
["h", "height"]
|
|
4399
4767
|
]) {
|
|
4400
|
-
const raw2 = value(
|
|
4768
|
+
const raw2 = value(xml2);
|
|
4401
4769
|
if (typeof raw2 !== "string" && typeof raw2 !== "number" || typeof raw2 === "string" && !raw2.trim())
|
|
4402
4770
|
continue;
|
|
4403
4771
|
const number2 = Number(raw2);
|
|
@@ -4573,24 +4941,24 @@ function drawingPatternPictureXml(fill) {
|
|
|
4573
4941
|
if (!fill.preset && !fill.sourceXml) throw new Error("A DrawingML pattern needs a preset");
|
|
4574
4942
|
if (before?.kind !== "pattern" || before.preset !== fill.preset)
|
|
4575
4943
|
root.setAttribute("prst", fill.preset);
|
|
4576
|
-
for (const [key,
|
|
4944
|
+
for (const [key, tag3] of [
|
|
4577
4945
|
["foreground", "fgClr"],
|
|
4578
4946
|
["background", "bgClr"]
|
|
4579
4947
|
]) {
|
|
4580
4948
|
const color2 = fill[key];
|
|
4581
4949
|
if (before?.kind === "pattern" && JSON.stringify(before[key]) === JSON.stringify(color2))
|
|
4582
4950
|
continue;
|
|
4583
|
-
const old = first(root,
|
|
4951
|
+
const old = first(root, tag3, NS.a);
|
|
4584
4952
|
if (!color2) {
|
|
4585
4953
|
if (old) root.removeChild(old);
|
|
4586
4954
|
continue;
|
|
4587
4955
|
}
|
|
4588
|
-
const node = old ?? doc.createElementNS(NS.a, `a:${
|
|
4956
|
+
const node = old ?? doc.createElementNS(NS.a, `a:${tag3}`);
|
|
4589
4957
|
patchDrawingColorIn(node, color2);
|
|
4590
4958
|
if (!old)
|
|
4591
4959
|
root.insertBefore(
|
|
4592
4960
|
node,
|
|
4593
|
-
|
|
4961
|
+
tag3 === "fgClr" ? first(root, "bgClr", NS.a) ?? root.firstChild : first(root, "extLst", NS.a) ?? null
|
|
4594
4962
|
);
|
|
4595
4963
|
}
|
|
4596
4964
|
} else {
|
|
@@ -4629,9 +4997,9 @@ function drawingPatternPictureXml(fill) {
|
|
|
4629
4997
|
}
|
|
4630
4998
|
|
|
4631
4999
|
// drawingml/write-fill.ts
|
|
4632
|
-
function setDrawingFillXml(properties,
|
|
5000
|
+
function setDrawingFillXml(properties, xml2) {
|
|
4633
5001
|
const doc = properties.ownerDocument;
|
|
4634
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${
|
|
5002
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
|
|
4635
5003
|
const fill = elements(wrapper.documentElement)[0];
|
|
4636
5004
|
const names = ["solidFill", "gradFill", "pattFill", "blipFill", "grpFill", "noFill"];
|
|
4637
5005
|
if (elements(wrapper.documentElement).length !== 1 || !fill || fill.namespaceURI !== NS.a || !names.includes(fill.localName))
|
|
@@ -4659,7 +5027,7 @@ function drawingFillXml(fill) {
|
|
|
4659
5027
|
const root = doc.documentElement;
|
|
4660
5028
|
if (root.namespaceURI !== NS.a || root.localName !== "gradFill")
|
|
4661
5029
|
throw new Error("Invalid gradient source XML");
|
|
4662
|
-
const fragment3 = (
|
|
5030
|
+
const fragment3 = (xml2) => doc.importNode(elements(parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`).documentElement)[0], true);
|
|
4663
5031
|
let list2 = first(root, "gsLst", NS.a);
|
|
4664
5032
|
if (!list2) {
|
|
4665
5033
|
list2 = doc.createElementNS(NS.a, "a:gsLst");
|
|
@@ -4733,8 +5101,8 @@ function writeChartFillFormatting(root, formatting) {
|
|
|
4733
5101
|
if (!node || !fill) continue;
|
|
4734
5102
|
let properties = first(node, "spPr", NS.c);
|
|
4735
5103
|
if (JSON.stringify(parseDrawingFill(properties)) === JSON.stringify(fill)) continue;
|
|
4736
|
-
const
|
|
4737
|
-
if (
|
|
5104
|
+
const xml2 = drawingFillXml(fill);
|
|
5105
|
+
if (xml2 === void 0) continue;
|
|
4738
5106
|
if (!properties) {
|
|
4739
5107
|
properties = root.ownerDocument.createElementNS(NS.c, "c:spPr");
|
|
4740
5108
|
const successors = [
|
|
@@ -4761,7 +5129,7 @@ function writeChartFillFormatting(root, formatting) {
|
|
|
4761
5129
|
) ?? null
|
|
4762
5130
|
);
|
|
4763
5131
|
}
|
|
4764
|
-
setDrawingFillXml(properties,
|
|
5132
|
+
setDrawingFillXml(properties, xml2);
|
|
4765
5133
|
changed = true;
|
|
4766
5134
|
}
|
|
4767
5135
|
return changed;
|
|
@@ -5044,63 +5412,63 @@ function escapeXmlText(value) {
|
|
|
5044
5412
|
function isValidBase64(value) {
|
|
5045
5413
|
return typeof value === "string" && value.length > 0 && /^[A-Za-z0-9+/=\s]+$/.test(value);
|
|
5046
5414
|
}
|
|
5047
|
-
function extractTagAttribute(
|
|
5415
|
+
function extractTagAttribute(xml2, tagName, attributeName) {
|
|
5048
5416
|
const pattern = new RegExp(
|
|
5049
5417
|
`<${tagName}\\b[^>]*\\b${attributeName}="(?<attributeValue>[^"]+)"`,
|
|
5050
5418
|
"i"
|
|
5051
5419
|
);
|
|
5052
|
-
const match =
|
|
5420
|
+
const match = xml2.match(pattern);
|
|
5053
5421
|
return match?.groups?.["attributeValue"]?.trim();
|
|
5054
5422
|
}
|
|
5055
5423
|
var isNameChar = (c2) => c2 !== void 0 && /[\w.-]/.test(c2);
|
|
5056
5424
|
var isWordChar = (c2) => c2 !== void 0 && /\w/.test(c2);
|
|
5057
|
-
function matchName(
|
|
5425
|
+
function matchName(xml2, lowerXml, from, lname) {
|
|
5058
5426
|
let pos = from;
|
|
5059
5427
|
if (!lowerXml.startsWith(lname, pos)) {
|
|
5060
5428
|
let end = pos;
|
|
5061
|
-
while (isNameChar(
|
|
5062
|
-
if (end === pos ||
|
|
5429
|
+
while (isNameChar(xml2[end])) end++;
|
|
5430
|
+
if (end === pos || xml2[end] !== ":") return -1;
|
|
5063
5431
|
pos = end + 1;
|
|
5064
5432
|
if (!lowerXml.startsWith(lname, pos)) return -1;
|
|
5065
5433
|
}
|
|
5066
5434
|
return pos + lname.length;
|
|
5067
5435
|
}
|
|
5068
|
-
function findTagText(
|
|
5069
|
-
let lt =
|
|
5436
|
+
function findTagText(xml2, lowerXml, lname, from) {
|
|
5437
|
+
let lt = xml2.indexOf("<", from);
|
|
5070
5438
|
while (lt !== -1) {
|
|
5071
|
-
const afterName = matchName(
|
|
5072
|
-
if (afterName !== -1 && !isWordChar(
|
|
5073
|
-
const gt =
|
|
5439
|
+
const afterName = matchName(xml2, lowerXml, lt + 1, lname);
|
|
5440
|
+
if (afterName !== -1 && !isWordChar(xml2[afterName])) {
|
|
5441
|
+
const gt = xml2.indexOf(">", afterName);
|
|
5074
5442
|
if (gt === -1) return null;
|
|
5075
|
-
let close =
|
|
5443
|
+
let close = xml2.indexOf("</", gt + 1);
|
|
5076
5444
|
while (close !== -1) {
|
|
5077
|
-
const closeEnd = matchName(
|
|
5078
|
-
if (closeEnd !== -1 &&
|
|
5079
|
-
return { text:
|
|
5445
|
+
const closeEnd = matchName(xml2, lowerXml, close + 2, lname);
|
|
5446
|
+
if (closeEnd !== -1 && xml2[closeEnd] === ">") {
|
|
5447
|
+
return { text: xml2.slice(gt + 1, close), end: closeEnd + 1 };
|
|
5080
5448
|
}
|
|
5081
|
-
close =
|
|
5449
|
+
close = xml2.indexOf("</", close + 2);
|
|
5082
5450
|
}
|
|
5083
5451
|
return null;
|
|
5084
5452
|
}
|
|
5085
|
-
lt =
|
|
5453
|
+
lt = xml2.indexOf("<", lt + 1);
|
|
5086
5454
|
}
|
|
5087
5455
|
return null;
|
|
5088
5456
|
}
|
|
5089
|
-
function extractFirstTagText(
|
|
5090
|
-
const found = findTagText(
|
|
5457
|
+
function extractFirstTagText(xml2, localName2) {
|
|
5458
|
+
const found = findTagText(xml2, xml2.toLowerCase(), localName2.toLowerCase(), 0);
|
|
5091
5459
|
return found?.text.replace(/\s+/g, "").trim() || void 0;
|
|
5092
5460
|
}
|
|
5093
|
-
function extractAllTagText(
|
|
5461
|
+
function extractAllTagText(xml2, localName2) {
|
|
5094
5462
|
const result = [];
|
|
5095
|
-
const lowerXml =
|
|
5463
|
+
const lowerXml = xml2.toLowerCase();
|
|
5096
5464
|
const lname = localName2.toLowerCase();
|
|
5097
|
-
let found = findTagText(
|
|
5465
|
+
let found = findTagText(xml2, lowerXml, lname, 0);
|
|
5098
5466
|
while (found) {
|
|
5099
5467
|
const value = found.text.replace(/\s+/g, "").trim();
|
|
5100
5468
|
if (value) {
|
|
5101
5469
|
result.push(value);
|
|
5102
5470
|
}
|
|
5103
|
-
found = findTagText(
|
|
5471
|
+
found = findTagText(xml2, lowerXml, lname, found.end);
|
|
5104
5472
|
}
|
|
5105
5473
|
return result;
|
|
5106
5474
|
}
|
|
@@ -5144,9 +5512,9 @@ function writeChartLayoutFormatting(root, formatting) {
|
|
|
5144
5512
|
let changed = false;
|
|
5145
5513
|
for (const part of ["title", "plotArea", "legend"]) {
|
|
5146
5514
|
const target = nodes[part];
|
|
5147
|
-
const
|
|
5148
|
-
if (!target || !
|
|
5149
|
-
const source2 = parseXml(
|
|
5515
|
+
const xml2 = formatting.entries[part]?.sourceXml;
|
|
5516
|
+
if (!target || !xml2?.trimStart().startsWith("<")) continue;
|
|
5517
|
+
const source2 = parseXml(xml2).documentElement;
|
|
5150
5518
|
for (const name of ["layout", "overlay"]) {
|
|
5151
5519
|
const property = first(source2, name, NS.c);
|
|
5152
5520
|
if (!property) continue;
|
|
@@ -5222,12 +5590,12 @@ var CHART_ROOT_BINDINGS = /* @__PURE__ */ new Map([
|
|
|
5222
5590
|
["r", NS.r]
|
|
5223
5591
|
]);
|
|
5224
5592
|
var DECLARATION = / xmlns:([A-Za-z_][\w.-]*)="([^"]*)"/g;
|
|
5225
|
-
function stripDeclarations(
|
|
5593
|
+
function stripDeclarations(xml2, bindings) {
|
|
5226
5594
|
const conflicting = /* @__PURE__ */ new Set();
|
|
5227
|
-
for (const [, prefix, uri] of
|
|
5595
|
+
for (const [, prefix, uri] of xml2.matchAll(DECLARATION))
|
|
5228
5596
|
if (prefix !== void 0 && bindings.has(prefix) && bindings.get(prefix) !== uri)
|
|
5229
5597
|
conflicting.add(prefix);
|
|
5230
|
-
return
|
|
5598
|
+
return xml2.replace(
|
|
5231
5599
|
DECLARATION,
|
|
5232
5600
|
(match, prefix, uri) => bindings.get(prefix) === uri && !conflicting.has(prefix) ? "" : match
|
|
5233
5601
|
);
|
|
@@ -5600,7 +5968,7 @@ function valXml(local, value) {
|
|
|
5600
5968
|
return `<c:${local} val="${text3}"/>`;
|
|
5601
5969
|
}
|
|
5602
5970
|
var elementXml = (local, content2, attributes2 = "") => content2 ? `<c:${local}${attributes2}>${content2}</c:${local}>` : `<c:${local}${attributes2}/>`;
|
|
5603
|
-
var raw = (context,
|
|
5971
|
+
var raw = (context, xml2) => xml2 ? stripDeclarations(xml2, context.bindings) : "";
|
|
5604
5972
|
function sameValue(left, right) {
|
|
5605
5973
|
if (left === right) return true;
|
|
5606
5974
|
if (typeof left !== "object" || typeof right !== "object" || !left || !right) return false;
|
|
@@ -6254,8 +6622,8 @@ var ORDER = [
|
|
|
6254
6622
|
"extLst"
|
|
6255
6623
|
];
|
|
6256
6624
|
var same = (a2, b) => JSON.stringify(a2) === JSON.stringify(b);
|
|
6257
|
-
function importXml(host,
|
|
6258
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${
|
|
6625
|
+
function importXml(host, xml2) {
|
|
6626
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
|
|
6259
6627
|
return host.ownerDocument.importNode(elements(wrapper.documentElement)[0], true);
|
|
6260
6628
|
}
|
|
6261
6629
|
function dropDrawingDeclarations(node) {
|
|
@@ -6296,10 +6664,10 @@ function patchDrawingLine(ln, line4) {
|
|
|
6296
6664
|
const solid = first(ln, "solidFill", NS.a);
|
|
6297
6665
|
if (solid && line4.fill?.kind === "solid") patchDrawingColorIn(solid, line4.fill.color);
|
|
6298
6666
|
else {
|
|
6299
|
-
const
|
|
6300
|
-
if (
|
|
6301
|
-
if (
|
|
6302
|
-
const child6 = importXml(ln,
|
|
6667
|
+
const xml2 = line4.fill && drawingFillXml(line4.fill);
|
|
6668
|
+
if (xml2 || !line4.fill) remove(ln, FILLS);
|
|
6669
|
+
if (xml2) {
|
|
6670
|
+
const child6 = importXml(ln, xml2);
|
|
6303
6671
|
dropDrawingDeclarations(child6);
|
|
6304
6672
|
insert(ln, child6);
|
|
6305
6673
|
}
|
|
@@ -6420,7 +6788,7 @@ function writeTextBody(body) {
|
|
|
6420
6788
|
|
|
6421
6789
|
// chart/write-shape.ts
|
|
6422
6790
|
var ROOT_DECLARATIONS = [...CHART_ROOT_BINDINGS].map(([prefix, uri]) => ` xmlns:${prefix}="${uri}"`).join("");
|
|
6423
|
-
var wrap = (local,
|
|
6791
|
+
var wrap = (local, xml2) => parseXml(`<c:${local}${ROOT_DECLARATIONS}>${xml2}</c:${local}>`, { label: "Chart" }).documentElement;
|
|
6424
6792
|
function chartFillXml(fill) {
|
|
6425
6793
|
return drawingFillXml(fill);
|
|
6426
6794
|
}
|
|
@@ -6430,8 +6798,8 @@ var firstOf = (parent, names) => elements(parent).find((node) => node.namespaceU
|
|
|
6430
6798
|
function patchShape(root, shape, read) {
|
|
6431
6799
|
const doc = root.ownerDocument;
|
|
6432
6800
|
if (!sameValue(read.fill, shape.fill)) {
|
|
6433
|
-
const
|
|
6434
|
-
if (
|
|
6801
|
+
const xml2 = shape.fill && chartFillXml(shape.fill);
|
|
6802
|
+
if (xml2) setDrawingFillXml(root, xml2);
|
|
6435
6803
|
else if (!shape.fill)
|
|
6436
6804
|
for (let fill = fillElementOf(root); fill; fill = fillElementOf(root)) root.removeChild(fill);
|
|
6437
6805
|
}
|
|
@@ -6516,12 +6884,12 @@ function numberFormatXml(format) {
|
|
|
6516
6884
|
const linked = format.sourceLinked === void 0 ? "" : ` sourceLinked="${format.sourceLinked ? 1 : 0}"`;
|
|
6517
6885
|
return `<c:numFmt formatCode="${escapeAttribute(format.formatCode)}"${linked}/>`;
|
|
6518
6886
|
}
|
|
6519
|
-
function chartTextBodyFromXml(
|
|
6520
|
-
const body = parseDrawingTextBody(wrap("rich",
|
|
6887
|
+
function chartTextBodyFromXml(xml2) {
|
|
6888
|
+
const body = parseDrawingTextBody(wrap("rich", xml2)) ?? {
|
|
6521
6889
|
paragraphs: [],
|
|
6522
6890
|
text: ""
|
|
6523
6891
|
};
|
|
6524
|
-
body.sourceXml =
|
|
6892
|
+
body.sourceXml = xml2;
|
|
6525
6893
|
return body;
|
|
6526
6894
|
}
|
|
6527
6895
|
|
|
@@ -7661,9 +8029,9 @@ var CHART_EX_ROOT_DECLARATIONS = [
|
|
|
7661
8029
|
{ prefix: "a", uri: NS.a },
|
|
7662
8030
|
{ prefix: "r", uri: NS.r }
|
|
7663
8031
|
];
|
|
7664
|
-
function chartExWriteOptionsOf(
|
|
7665
|
-
const declarationBreak = /^<\?xml[^>]*\?>(\r\n|\n)?/.exec(
|
|
7666
|
-
return { declarationBreak, .../<[^<>]*\s\/>/.test(
|
|
8032
|
+
function chartExWriteOptionsOf(xml2) {
|
|
8033
|
+
const declarationBreak = /^<\?xml[^>]*\?>(\r\n|\n)?/.exec(xml2)?.[1] ?? "";
|
|
8034
|
+
return { declarationBreak, .../<[^<>]*\s\/>/.test(xml2) ? { emptyElementSpace: true } : {} };
|
|
7667
8035
|
}
|
|
7668
8036
|
function writeChartExSpace(space3, options2 = {}) {
|
|
7669
8037
|
const bindings = /* @__PURE__ */ new Map();
|
|
@@ -7702,9 +8070,9 @@ function writeChartExSpace(space3, options2 = {}) {
|
|
|
7702
8070
|
);
|
|
7703
8071
|
const userShapes = space3.userShapesRelId === void 0 ? "" : `<c:userShapes${attributes([["r:id", space3.userShapesRelId]])}/>`;
|
|
7704
8072
|
const body = chartDataXml(context, space3.chartData) + chart + shapeXml(context, space3.spPr) + textBodyXml2(context, space3.txPr) + raw(context, space3.colorMapOverrideXml) + raw(context, space3.formatOverridesXml) + raw(context, space3.printSettingsXml) + userShapes + raw(context, space3.extLst);
|
|
7705
|
-
let
|
|
7706
|
-
if (options2.emptyElementSpace)
|
|
7707
|
-
return
|
|
8073
|
+
let xml2 = `${DECLARATION3}${options2.declarationBreak ?? ""}<cx:chartSpace${declarations}>${body}</cx:chartSpace>`;
|
|
8074
|
+
if (options2.emptyElementSpace) xml2 = xml2.replace(/\/>/g, " />");
|
|
8075
|
+
return xml2;
|
|
7708
8076
|
}
|
|
7709
8077
|
|
|
7710
8078
|
// chart/data-sheet.ts
|
|
@@ -9051,10 +9419,10 @@ async function openZip(input, limits = {}) {
|
|
|
9051
9419
|
}
|
|
9052
9420
|
|
|
9053
9421
|
// opc/relationships.ts
|
|
9054
|
-
function parseRelationships(
|
|
9422
|
+
function parseRelationships(xml2) {
|
|
9055
9423
|
const map = /* @__PURE__ */ new Map();
|
|
9056
|
-
if (!
|
|
9057
|
-
const root = parseXml(
|
|
9424
|
+
if (!xml2) return map;
|
|
9425
|
+
const root = parseXml(xml2).documentElement;
|
|
9058
9426
|
for (const node of elements(root)) {
|
|
9059
9427
|
if (node.localName !== "Relationship") continue;
|
|
9060
9428
|
const id = node.getAttribute("Id");
|
|
@@ -9283,17 +9651,17 @@ async function syncWorksheetTables(zip, sheetPath, doc, writes, shared) {
|
|
|
9283
9651
|
for (const rel of rels.values()) {
|
|
9284
9652
|
if (rel.mode === "External" || !rel.type.endsWith("/table")) continue;
|
|
9285
9653
|
const path3 = resolvePartPath(sheetPath, rel.target);
|
|
9286
|
-
const
|
|
9287
|
-
if (!
|
|
9288
|
-
const tableDoc = parseXml(
|
|
9654
|
+
const xml2 = await zip.file(path3)?.async("string");
|
|
9655
|
+
if (!xml2) continue;
|
|
9656
|
+
const tableDoc = parseXml(xml2, { label: "Table" });
|
|
9289
9657
|
const table = tableDoc.documentElement;
|
|
9290
9658
|
if (table && syncTable(table, doc, values, shared)) zip.file(path3, buildXml(tableDoc));
|
|
9291
9659
|
}
|
|
9292
9660
|
}
|
|
9293
9661
|
async function sharedStringTexts(zip) {
|
|
9294
|
-
const
|
|
9295
|
-
if (!
|
|
9296
|
-
return childrenNamed(parseXml(
|
|
9662
|
+
const xml2 = await zip.file("xl/sharedStrings.xml")?.async("string");
|
|
9663
|
+
if (!xml2) return [];
|
|
9664
|
+
return childrenNamed(parseXml(xml2).documentElement ?? void 0, "si").map((item2) => {
|
|
9297
9665
|
const direct = childNamed(item2, "t");
|
|
9298
9666
|
if (direct) return direct.textContent ?? "";
|
|
9299
9667
|
return childrenNamed(item2, "r").map((run2) => childNamed(run2, "t")?.textContent ?? "").join("");
|
|
@@ -9371,8 +9739,8 @@ async function validateAtomicChartWorkbookWrites(zip, paths, writes, requireCurr
|
|
|
9371
9739
|
unsupported("rich worksheet strings require source-workbook editing");
|
|
9372
9740
|
if (requireCurrentValues) {
|
|
9373
9741
|
const current = text3 ? childNamed(text3, "t")?.textContent ?? void 0 : childNamed(cell2, "v")?.textContent ?? void 0;
|
|
9374
|
-
const
|
|
9375
|
-
if (!
|
|
9742
|
+
const equal3 = write.isNumeric ? current !== void 0 && Number(current) === Number(value) : current === value;
|
|
9743
|
+
if (!equal3) unsupported("the workbook and chart caches disagree");
|
|
9376
9744
|
}
|
|
9377
9745
|
if (write.isNumeric && !Number.isFinite(Number(value)))
|
|
9378
9746
|
unsupported("a numeric cache value is not finite");
|
|
@@ -9575,9 +9943,9 @@ async function appendChartWorkbookSheet(bytes, rowsForName, options2 = {}) {
|
|
|
9575
9943
|
// chart/ex/workbook.ts
|
|
9576
9944
|
async function appendChartExWorkbookData(bytes, before, after) {
|
|
9577
9945
|
const zip = await openEmbeddedPackage(bytes);
|
|
9578
|
-
const
|
|
9579
|
-
if (!
|
|
9580
|
-
const root = parseXml(
|
|
9946
|
+
const xml2 = await zip.file("xl/workbook.xml")?.async("string");
|
|
9947
|
+
if (!xml2) throw new Error("The chart workbook is missing.");
|
|
9948
|
+
const root = parseXml(xml2).documentElement;
|
|
9581
9949
|
const defined = first(root, "definedNames", NS.x);
|
|
9582
9950
|
const names = defined ? children(defined, "definedName", NS.x) : [];
|
|
9583
9951
|
const resolve = (name) => names.find(
|
|
@@ -10176,7 +10544,7 @@ var KINDS = {
|
|
|
10176
10544
|
reflection: "reflection",
|
|
10177
10545
|
fillOverlay: "fillOverlay"
|
|
10178
10546
|
};
|
|
10179
|
-
var TAGS = Object.fromEntries(Object.entries(KINDS).map(([
|
|
10547
|
+
var TAGS = Object.fromEntries(Object.entries(KINDS).map(([tag3, kind]) => [kind, tag3]));
|
|
10180
10548
|
var GEOMETRY = { blurRadiusEmu: "blurRad", distanceEmu: "dist", directionAngle: "dir" };
|
|
10181
10549
|
var TRANSFORM = { scaleX: "sx", scaleY: "sy", skewXAngle: "kx", skewYAngle: "ky" };
|
|
10182
10550
|
var NUMBERS = {
|
|
@@ -10210,8 +10578,8 @@ var BOOLEANS = {
|
|
|
10210
10578
|
};
|
|
10211
10579
|
var COLORED = /* @__PURE__ */ new Set(["outerShadow", "innerShadow", "presetShadow", "glow"]);
|
|
10212
10580
|
var same3 = (a2, b) => JSON.stringify(a2) === JSON.stringify(b);
|
|
10213
|
-
function fragment(
|
|
10214
|
-
return elements(parseXml(`<w xmlns:a="${NS.a}">${
|
|
10581
|
+
function fragment(xml2) {
|
|
10582
|
+
return elements(parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`).documentElement)[0];
|
|
10215
10583
|
}
|
|
10216
10584
|
function parseDrawingEffect(node) {
|
|
10217
10585
|
const sourceXml = buildXml(node);
|
|
@@ -10285,12 +10653,12 @@ function drawingEffectXml(effect) {
|
|
|
10285
10653
|
}
|
|
10286
10654
|
}
|
|
10287
10655
|
if (effect.kind === "fillOverlay" && changed("fill")) {
|
|
10288
|
-
const
|
|
10289
|
-
if (effect.fill && !
|
|
10290
|
-
if (
|
|
10656
|
+
const xml2 = effect.fill && drawingFillXml(effect.fill);
|
|
10657
|
+
if (effect.fill && !xml2) throw new Error("Cannot author this DrawingML effect fill");
|
|
10658
|
+
if (xml2 || !effect.fill) {
|
|
10291
10659
|
const fill = fillElementOf(root);
|
|
10292
10660
|
if (fill) root.removeChild(fill);
|
|
10293
|
-
if (
|
|
10661
|
+
if (xml2) root.insertBefore(doc.importNode(fragment(xml2), true), root.firstChild);
|
|
10294
10662
|
}
|
|
10295
10663
|
}
|
|
10296
10664
|
return buildXml(doc);
|
|
@@ -10347,8 +10715,8 @@ function resolveDrawingOuterShadow(effect, theme) {
|
|
|
10347
10715
|
dy: Math.sin(angle) * distance
|
|
10348
10716
|
};
|
|
10349
10717
|
}
|
|
10350
|
-
function resolveDrawingShadowXml(
|
|
10351
|
-
return
|
|
10718
|
+
function resolveDrawingShadowXml(xml2, theme) {
|
|
10719
|
+
return xml2 ? resolveDrawingShadow(parseXml(xml2).documentElement, theme) : void 0;
|
|
10352
10720
|
}
|
|
10353
10721
|
function svgDropShadowElement(s2, format) {
|
|
10354
10722
|
const num2 = format.number;
|
|
@@ -10770,12 +11138,12 @@ function fillXml(style) {
|
|
|
10770
11138
|
return buildXml(node);
|
|
10771
11139
|
}
|
|
10772
11140
|
}
|
|
10773
|
-
const
|
|
10774
|
-
if (!
|
|
11141
|
+
const xml2 = drawingFillXml(style.fill);
|
|
11142
|
+
if (!xml2) {
|
|
10775
11143
|
if (style.sourceXml) return style.sourceXml;
|
|
10776
11144
|
throw new Error("Cannot author this DrawingML theme fill");
|
|
10777
11145
|
}
|
|
10778
|
-
return
|
|
11146
|
+
return xml2;
|
|
10779
11147
|
}
|
|
10780
11148
|
function effectXml(style) {
|
|
10781
11149
|
const doc = parseXml(style.sourceXml ?? `<a:effectStyle xmlns:a="${NS.a}"/>`);
|
|
@@ -10818,8 +11186,8 @@ function drawingThemeFormatSchemeXml(scheme2) {
|
|
|
10818
11186
|
const old = elements(list2).filter(
|
|
10819
11187
|
(node) => node.namespaceURI === NS.a && (!local || node.localName === local)
|
|
10820
11188
|
);
|
|
10821
|
-
values.forEach((
|
|
10822
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${
|
|
11189
|
+
values.forEach((xml2, offset) => {
|
|
11190
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
|
|
10823
11191
|
const node = doc.importNode(elements(wrapper.documentElement)[0], true);
|
|
10824
11192
|
if (old[offset]) list2.replaceChild(node, old[offset]);
|
|
10825
11193
|
else list2.appendChild(node);
|
|
@@ -10980,8 +11348,8 @@ function parseTheme(source2) {
|
|
|
10980
11348
|
if (name) theme.name = name;
|
|
10981
11349
|
return theme;
|
|
10982
11350
|
}
|
|
10983
|
-
function parseThemeXml(
|
|
10984
|
-
return parseTheme(parseXml(
|
|
11351
|
+
function parseThemeXml(xml2, label = "DrawingML theme") {
|
|
11352
|
+
return parseTheme(parseXml(xml2, { label }));
|
|
10985
11353
|
}
|
|
10986
11354
|
function parseThemeColorMap(element4) {
|
|
10987
11355
|
const map = {};
|
|
@@ -13025,9 +13393,9 @@ function parseDrawingGeometry(spPr) {
|
|
|
13025
13393
|
}
|
|
13026
13394
|
|
|
13027
13395
|
// drawingml/write-theme.ts
|
|
13028
|
-
function fragment2(host,
|
|
13396
|
+
function fragment2(host, xml2, namespaces) {
|
|
13029
13397
|
const declarations = Object.entries({ a: NS.a, ...namespaces }).map(([prefix, uri]) => ` xmlns:${prefix}="${uri}"`).join("");
|
|
13030
|
-
const wrapper = parseXml(`<w${declarations}>${
|
|
13398
|
+
const wrapper = parseXml(`<w${declarations}>${xml2}</w>`, { label: "DrawingML theme fragment" });
|
|
13031
13399
|
return elements(wrapper.documentElement).map(
|
|
13032
13400
|
(node) => host.ownerDocument.importNode(node, true)
|
|
13033
13401
|
);
|
|
@@ -13037,10 +13405,10 @@ function extensionList3(parent, extensions, namespaces) {
|
|
|
13037
13405
|
if (!entries.length) return;
|
|
13038
13406
|
const doc = parent.ownerDocument;
|
|
13039
13407
|
const list2 = doc.createElementNS(NS.a, "a:extLst");
|
|
13040
|
-
for (const [uri,
|
|
13408
|
+
for (const [uri, xml2] of entries) {
|
|
13041
13409
|
const ext = doc.createElementNS(NS.a, "a:ext");
|
|
13042
13410
|
ext.setAttribute("uri", uri);
|
|
13043
|
-
for (const node of fragment2(ext,
|
|
13411
|
+
for (const node of fragment2(ext, xml2, namespaces)) ext.appendChild(node);
|
|
13044
13412
|
list2.appendChild(ext);
|
|
13045
13413
|
}
|
|
13046
13414
|
parent.appendChild(list2);
|
|
@@ -14025,20 +14393,20 @@ function dropRedundantDeclarations(element4) {
|
|
|
14025
14393
|
if (element4.getAttribute("xmlns:r") === NS.r) element4.removeAttribute("xmlns:r");
|
|
14026
14394
|
for (const child6 of elements(element4)) dropRedundantDeclarations(child6);
|
|
14027
14395
|
}
|
|
14028
|
-
function importDrawingXml(doc,
|
|
14029
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}" xmlns:r="${NS.r}">${
|
|
14396
|
+
function importDrawingXml(doc, xml2) {
|
|
14397
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}" xmlns:r="${NS.r}">${xml2}</w>`).documentElement;
|
|
14030
14398
|
const node = elements(wrapper)[0];
|
|
14031
14399
|
if (!node) throw new Error("Empty DrawingML fragment");
|
|
14032
14400
|
const imported = doc.importNode(node, true);
|
|
14033
14401
|
dropRedundantDeclarations(imported);
|
|
14034
14402
|
return imported;
|
|
14035
14403
|
}
|
|
14036
|
-
function keptChildName(
|
|
14037
|
-
const match = /^\s*<(?:[\w.-]+:)?([\w.-]+)/u.exec(
|
|
14404
|
+
function keptChildName(xml2) {
|
|
14405
|
+
const match = /^\s*<(?:[\w.-]+:)?([\w.-]+)/u.exec(xml2);
|
|
14038
14406
|
return match?.[1] ?? "";
|
|
14039
14407
|
}
|
|
14040
|
-
function keptChildren(doc,
|
|
14041
|
-
return (
|
|
14408
|
+
function keptChildren(doc, xml2) {
|
|
14409
|
+
return (xml2 ?? []).map((value) => ({
|
|
14042
14410
|
name: keptChildName(value),
|
|
14043
14411
|
node: importDrawingXml(doc, value)
|
|
14044
14412
|
}));
|
|
@@ -14105,7 +14473,7 @@ function writeHyperlink(doc, local, link) {
|
|
|
14105
14473
|
setBoolean(element4, "history", link.history);
|
|
14106
14474
|
setBoolean(element4, "highlightClick", link.highlightClick);
|
|
14107
14475
|
setBoolean(element4, "endSnd", link.endSound);
|
|
14108
|
-
for (const
|
|
14476
|
+
for (const xml2 of link.extraXml ?? []) element4.appendChild(importDrawingXml(doc, xml2));
|
|
14109
14477
|
return element4;
|
|
14110
14478
|
}
|
|
14111
14479
|
function setAttributes(element4, value) {
|
|
@@ -14130,9 +14498,9 @@ function setAttributes(element4, value) {
|
|
|
14130
14498
|
setValue(element4, "bmk", value.bookmark);
|
|
14131
14499
|
}
|
|
14132
14500
|
function fillChild(doc, fill) {
|
|
14133
|
-
const
|
|
14134
|
-
if (!
|
|
14135
|
-
const node = importDrawingXml(doc,
|
|
14501
|
+
const xml2 = fill ? drawingFillXml(fill) : void 0;
|
|
14502
|
+
if (!xml2) return void 0;
|
|
14503
|
+
const node = importDrawingXml(doc, xml2);
|
|
14136
14504
|
return { name: node.localName, node };
|
|
14137
14505
|
}
|
|
14138
14506
|
function modelledChildren(doc, value) {
|
|
@@ -14361,9 +14729,9 @@ function semantics(value) {
|
|
|
14361
14729
|
Object.fromEntries(Object.entries(value).filter(([key]) => key !== "sourceXml"))
|
|
14362
14730
|
);
|
|
14363
14731
|
}
|
|
14364
|
-
function source(doc, name,
|
|
14365
|
-
if (!
|
|
14366
|
-
const element4 = parseXml(
|
|
14732
|
+
function source(doc, name, xml2) {
|
|
14733
|
+
if (!xml2) return doc.createElementNS(NS.a, `a:${name}`);
|
|
14734
|
+
const element4 = parseXml(xml2).documentElement;
|
|
14367
14735
|
if (element4.namespaceURI !== NS.a || element4.localName !== name)
|
|
14368
14736
|
throw new Error(`Invalid ${name} source`);
|
|
14369
14737
|
return doc.importNode(element4, true);
|
|
@@ -14980,9 +15348,9 @@ function schemaPosition(node, end) {
|
|
|
14980
15348
|
}
|
|
14981
15349
|
return end === "mid" ? { kind: "percent", value: 50 } : { kind: end };
|
|
14982
15350
|
}
|
|
14983
|
-
function parseRegionValueColorPositions(
|
|
14984
|
-
if (!
|
|
14985
|
-
const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${
|
|
15351
|
+
function parseRegionValueColorPositions(xml2) {
|
|
15352
|
+
if (!xml2) return void 0;
|
|
15353
|
+
const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${xml2}</cx:root>`).documentElement;
|
|
14986
15354
|
const positions = first(root, "valueColorPositions", NS.cx);
|
|
14987
15355
|
if (!positions) return void 0;
|
|
14988
15356
|
const count = positions.getAttribute("count");
|
|
@@ -15008,8 +15376,8 @@ function parseRegionValueColorPositions(xml) {
|
|
|
15008
15376
|
// chart/region-map/value-colors.ts
|
|
15009
15377
|
function resolveRegionValueColors(options2, color2) {
|
|
15010
15378
|
const result = { ...options2 };
|
|
15011
|
-
const
|
|
15012
|
-
const root = parseXml(
|
|
15379
|
+
const xml2 = `<cx:root xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">${options2.valueColorsXml ?? ""}${options2.valueColorPositionsXml ?? ""}</cx:root>`;
|
|
15380
|
+
const root = parseXml(xml2).documentElement;
|
|
15013
15381
|
if (options2.valueColorsXml) {
|
|
15014
15382
|
const colors = Array.from(root.getElementsByTagName("*")).flatMap((node) => {
|
|
15015
15383
|
const c2 = color2(parseDrawingColorIn(node));
|
|
@@ -16759,14 +17127,14 @@ function inflateGeoCache(binary, maxOutputBytes = LIMIT) {
|
|
|
16759
17127
|
}
|
|
16760
17128
|
return new TextDecoder("utf-8", { fatal: true }).decode(out);
|
|
16761
17129
|
}
|
|
16762
|
-
function readGeographyCache(
|
|
17130
|
+
function readGeographyCache(xml2, pointLimit = 1e6) {
|
|
16763
17131
|
const result = { regions: [], issues: [] };
|
|
16764
|
-
if (!
|
|
17132
|
+
if (!xml2) return result;
|
|
16765
17133
|
try {
|
|
16766
17134
|
if (!Number.isSafeInteger(pointLimit) || pointLimit < 1 || pointLimit > 1e6)
|
|
16767
17135
|
throw new Error("Invalid geography point limit.");
|
|
16768
|
-
if (
|
|
16769
|
-
let root = parseXml(`<cx:root xmlns:cx="${CX}">${
|
|
17136
|
+
if (xml2.length > LIMIT) throw new Error("Geography cache input limit exceeded.");
|
|
17137
|
+
let root = parseXml(`<cx:root xmlns:cx="${CX}">${xml2}</cx:root>`).documentElement;
|
|
16770
17138
|
const binary = elements2(root, "binary")[0];
|
|
16771
17139
|
if (binary) root = parseXml(inflateGeoCache(binary.textContent ?? "")).documentElement;
|
|
16772
17140
|
let points2 = 0;
|
|
@@ -18769,8 +19137,8 @@ var ORDER2 = [
|
|
|
18769
19137
|
"softEdge"
|
|
18770
19138
|
];
|
|
18771
19139
|
function chartTargetEffects(space3, target) {
|
|
18772
|
-
const
|
|
18773
|
-
return
|
|
19140
|
+
const xml2 = chartTargetShape(space3, target)?.effectsXml;
|
|
19141
|
+
return xml2 ? parseDrawingEffects(parseXml(xml2).documentElement) : void 0;
|
|
18774
19142
|
}
|
|
18775
19143
|
function editChartEffectList(list2, edit) {
|
|
18776
19144
|
const next = structuredClone(list2 ?? { effects: [] });
|
|
@@ -19267,11 +19635,11 @@ function patchRun(node, edit) {
|
|
|
19267
19635
|
if (edit.fillTransparency !== void 0) {
|
|
19268
19636
|
const fill = parseDrawingFill(node);
|
|
19269
19637
|
if (fill?.kind === "solid") {
|
|
19270
|
-
const
|
|
19638
|
+
const xml2 = drawingFillXml({
|
|
19271
19639
|
...fill,
|
|
19272
19640
|
color: withDrawingColorTransparency(fill.color, edit.fillTransparency)
|
|
19273
19641
|
});
|
|
19274
|
-
if (
|
|
19642
|
+
if (xml2) setDrawingFillXml(node, xml2);
|
|
19275
19643
|
}
|
|
19276
19644
|
}
|
|
19277
19645
|
if (edit.lineTransparency !== void 0) {
|
|
@@ -19294,9 +19662,9 @@ function patchRun(node, edit) {
|
|
|
19294
19662
|
))
|
|
19295
19663
|
node.removeChild(old);
|
|
19296
19664
|
} else {
|
|
19297
|
-
const
|
|
19298
|
-
if (!
|
|
19299
|
-
setDrawingFillXml(node,
|
|
19665
|
+
const xml2 = drawingFillXml(edit.fill);
|
|
19666
|
+
if (!xml2) throw new RangeError("Unsupported chart text fill");
|
|
19667
|
+
setDrawingFillXml(node, xml2);
|
|
19300
19668
|
}
|
|
19301
19669
|
}
|
|
19302
19670
|
if (edit.line !== void 0) {
|
|
@@ -19335,16 +19703,16 @@ function patchRun(node, edit) {
|
|
|
19335
19703
|
typeof value === "boolean" ? value ? "1" : "0" : String(Math.round(value * 100))
|
|
19336
19704
|
);
|
|
19337
19705
|
}
|
|
19338
|
-
for (const [key,
|
|
19706
|
+
for (const [key, tag3] of [
|
|
19339
19707
|
["typeface", "latin"],
|
|
19340
19708
|
["eastAsiaTypeface", "ea"]
|
|
19341
19709
|
])
|
|
19342
19710
|
if (edit[key] !== void 0) {
|
|
19343
|
-
const old = first(node,
|
|
19711
|
+
const old = first(node, tag3, NS.a);
|
|
19344
19712
|
if (edit[key] === null) {
|
|
19345
19713
|
if (old) node.removeChild(old);
|
|
19346
19714
|
} else {
|
|
19347
|
-
const latin = old ?? node.ownerDocument.createElementNS(NS.a, `a:${
|
|
19715
|
+
const latin = old ?? node.ownerDocument.createElementNS(NS.a, `a:${tag3}`);
|
|
19348
19716
|
latin.setAttribute("typeface", edit[key]);
|
|
19349
19717
|
if (!old) node.appendChild(latin);
|
|
19350
19718
|
}
|
|
@@ -19548,9 +19916,9 @@ function setChartDataLabels(space3, edit, target = {}) {
|
|
|
19548
19916
|
// chart/edit/label-range.ts
|
|
19549
19917
|
var C15 = "http://schemas.microsoft.com/office/drawing/2012/chart";
|
|
19550
19918
|
var URI = "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}";
|
|
19551
|
-
function extensionRoot(
|
|
19919
|
+
function extensionRoot(xml2) {
|
|
19552
19920
|
return parseXml(
|
|
19553
|
-
`<c:wrapper xmlns:c="${NS.c}" xmlns:c15="${C15}">${
|
|
19921
|
+
`<c:wrapper xmlns:c="${NS.c}" xmlns:c15="${C15}">${xml2 ?? "<c:extLst/>"}</c:wrapper>`
|
|
19554
19922
|
).documentElement.getElementsByTagNameNS(NS.c, "extLst")[0];
|
|
19555
19923
|
}
|
|
19556
19924
|
function chartDataLabelsRange(labels2) {
|
|
@@ -20630,11 +20998,11 @@ function chartTargetThreeD(space3, target) {
|
|
|
20630
20998
|
editChartShapeXml({ ...shape }, (root) => {
|
|
20631
20999
|
const sp3d = first(root, "sp3d", NS.a);
|
|
20632
21000
|
if (sp3d) {
|
|
20633
|
-
for (const [key,
|
|
21001
|
+
for (const [key, tag3] of [
|
|
20634
21002
|
["bevelTop", "bevelT"],
|
|
20635
21003
|
["bevelBottom", "bevelB"]
|
|
20636
21004
|
]) {
|
|
20637
|
-
const node = first(sp3d,
|
|
21005
|
+
const node = first(sp3d, tag3, NS.a);
|
|
20638
21006
|
if (!node) continue;
|
|
20639
21007
|
const widthEmu = Number(node.getAttribute("w") ?? 0);
|
|
20640
21008
|
const heightEmu = Number(node.getAttribute("h") ?? 0);
|
|
@@ -20648,11 +21016,11 @@ function chartTargetThreeD(space3, target) {
|
|
|
20648
21016
|
const value = sp3d.getAttribute(attr4);
|
|
20649
21017
|
if (value !== null && Number.isFinite(Number(value))) result[key] = Number(value);
|
|
20650
21018
|
}
|
|
20651
|
-
for (const [key,
|
|
21019
|
+
for (const [key, tag3] of [
|
|
20652
21020
|
["depthColor", "extrusionClr"],
|
|
20653
21021
|
["contourColor", "contourClr"]
|
|
20654
21022
|
]) {
|
|
20655
|
-
const color2 = parseDrawingColorIn(first(sp3d,
|
|
21023
|
+
const color2 = parseDrawingColorIn(first(sp3d, tag3, NS.a));
|
|
20656
21024
|
if (color2) result[key] = color2;
|
|
20657
21025
|
}
|
|
20658
21026
|
const material = sp3d.getAttribute("prstMaterial");
|
|
@@ -20672,21 +21040,21 @@ function setChartTargetThreeD(space3, target, edit) {
|
|
|
20672
21040
|
for (const shape of chartTargetDraftShapes(draft, target))
|
|
20673
21041
|
editChartShapeXml(shape, (root) => {
|
|
20674
21042
|
const sp3d = child3(root, "sp3d");
|
|
20675
|
-
for (const [key,
|
|
21043
|
+
for (const [key, tag3] of [
|
|
20676
21044
|
["bevelTop", "bevelT"],
|
|
20677
21045
|
["bevelBottom", "bevelB"]
|
|
20678
21046
|
]) {
|
|
20679
21047
|
const bevel2 = edit[key];
|
|
20680
21048
|
if (bevel2 === void 0) continue;
|
|
20681
21049
|
if (bevel2 === null) {
|
|
20682
|
-
remove3(sp3d,
|
|
21050
|
+
remove3(sp3d, tag3);
|
|
20683
21051
|
continue;
|
|
20684
21052
|
}
|
|
20685
21053
|
if (![bevel2.widthEmu, bevel2.heightEmu].every(
|
|
20686
21054
|
(value) => Number.isFinite(value) && value >= 0
|
|
20687
21055
|
) || !bevel2.preset)
|
|
20688
21056
|
throw new RangeError("Invalid chart bevel");
|
|
20689
|
-
const node = child3(sp3d,
|
|
21057
|
+
const node = child3(sp3d, tag3);
|
|
20690
21058
|
node.setAttribute("prst", bevel2.preset);
|
|
20691
21059
|
node.setAttribute("w", String(Math.round(bevel2.widthEmu)));
|
|
20692
21060
|
node.setAttribute("h", String(Math.round(bevel2.heightEmu)));
|
|
@@ -20703,14 +21071,14 @@ function setChartTargetThreeD(space3, target, edit) {
|
|
|
20703
21071
|
sp3d.setAttribute(attribute2, String(Math.round(value)));
|
|
20704
21072
|
}
|
|
20705
21073
|
}
|
|
20706
|
-
for (const [key,
|
|
21074
|
+
for (const [key, tag3] of [
|
|
20707
21075
|
["depthColor", "extrusionClr"],
|
|
20708
21076
|
["contourColor", "contourClr"]
|
|
20709
21077
|
]) {
|
|
20710
21078
|
const color2 = edit[key];
|
|
20711
21079
|
if (color2 === void 0) continue;
|
|
20712
|
-
if (color2 === null) remove3(sp3d,
|
|
20713
|
-
else patchDrawingColorIn(child3(sp3d,
|
|
21080
|
+
if (color2 === null) remove3(sp3d, tag3);
|
|
21081
|
+
else patchDrawingColorIn(child3(sp3d, tag3), color2);
|
|
20714
21082
|
}
|
|
20715
21083
|
if (edit.material !== void 0) {
|
|
20716
21084
|
if (edit.material === null) sp3d.removeAttribute("prstMaterial");
|
|
@@ -21540,15 +21908,15 @@ function editChartLayout(current, value) {
|
|
|
21540
21908
|
root.insertBefore(manual, root.firstChild);
|
|
21541
21909
|
}
|
|
21542
21910
|
if (manual) {
|
|
21543
|
-
const previous = new Map(FIELDS.map(([,
|
|
21544
|
-
for (const [,
|
|
21545
|
-
const old = first(manual,
|
|
21911
|
+
const previous = new Map(FIELDS.map(([, tag3]) => [tag3, first(manual, tag3, NS.c)]));
|
|
21912
|
+
for (const [, tag3] of FIELDS) {
|
|
21913
|
+
const old = first(manual, tag3, NS.c);
|
|
21546
21914
|
if (old) manual.removeChild(old);
|
|
21547
21915
|
}
|
|
21548
21916
|
const before = manual.firstChild;
|
|
21549
|
-
for (const [key,
|
|
21917
|
+
for (const [key, tag3] of FIELDS) {
|
|
21550
21918
|
if (value?.[key] === void 0) continue;
|
|
21551
|
-
const node = previous.get(
|
|
21919
|
+
const node = previous.get(tag3) ?? root.ownerDocument.createElementNS(NS.c, `c:${tag3}`);
|
|
21552
21920
|
node.setAttribute("val", String(value[key]));
|
|
21553
21921
|
manual.insertBefore(node, before);
|
|
21554
21922
|
}
|
|
@@ -22123,6 +22491,7 @@ __export(text_exports, {
|
|
|
22123
22491
|
hasDesignAdvances: () => hasDesignAdvances,
|
|
22124
22492
|
hasDirectSubstitution: () => hasDirectSubstitution,
|
|
22125
22493
|
hasDistinctScriptFonts: () => hasDistinctScriptFonts,
|
|
22494
|
+
mergeTextThreeWay: () => mergeTextThreeWay,
|
|
22126
22495
|
metricFontFamily: () => metricFontFamily,
|
|
22127
22496
|
parseLocaleNumber: () => parseLocaleNumber,
|
|
22128
22497
|
parsePanoseBytes: () => parsePanoseBytes,
|
|
@@ -22989,7 +23358,7 @@ function segmentByFont(text3, fonts) {
|
|
|
22989
23358
|
var u16 = (v, o) => o + 2 <= v.byteLength ? v.getUint16(o) : 0;
|
|
22990
23359
|
var i16 = (v, o) => o + 2 <= v.byteLength ? v.getInt16(o) : 0;
|
|
22991
23360
|
var u32 = (v, o) => o + 4 <= v.byteLength ? v.getUint32(o) : 0;
|
|
22992
|
-
var
|
|
23361
|
+
var tag2 = (v, o) => String.fromCharCode(v.getUint8(o), v.getUint8(o + 1), v.getUint8(o + 2), v.getUint8(o + 3));
|
|
22993
23362
|
function format4(view, at2) {
|
|
22994
23363
|
const segments = u16(view, at2 + 6) / 2;
|
|
22995
23364
|
const ends = at2 + 14;
|
|
@@ -23048,9 +23417,9 @@ function characterMap(view, table) {
|
|
|
23048
23417
|
function parseTrueType(data) {
|
|
23049
23418
|
if (data.length < 12) return void 0;
|
|
23050
23419
|
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
23051
|
-
const base =
|
|
23420
|
+
const base = tag2(view, 0) === "ttcf" ? u32(view, 12) : 0;
|
|
23052
23421
|
if (base + 12 > data.length) return void 0;
|
|
23053
|
-
if (u32(view, base) !== 65536 &&
|
|
23422
|
+
if (u32(view, base) !== 65536 && tag2(view, base) !== "true") return void 0;
|
|
23054
23423
|
const count = u16(view, base + 4);
|
|
23055
23424
|
const tables = /* @__PURE__ */ new Map();
|
|
23056
23425
|
for (let index = 0; index < count; index++) {
|
|
@@ -23059,7 +23428,7 @@ function parseTrueType(data) {
|
|
|
23059
23428
|
const offset = u32(view, entry3 + 8);
|
|
23060
23429
|
const length = u32(view, entry3 + 12);
|
|
23061
23430
|
if (offset + length > data.length) return void 0;
|
|
23062
|
-
tables.set(
|
|
23431
|
+
tables.set(tag2(view, entry3), { offset, length });
|
|
23063
23432
|
}
|
|
23064
23433
|
const head = tables.get("head");
|
|
23065
23434
|
const hhea = tables.get("hhea");
|
|
@@ -23246,7 +23615,7 @@ function normalizeLocale(input, supported, fallback, options2 = {}) {
|
|
|
23246
23615
|
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
23247
23616
|
const language = parts[0];
|
|
23248
23617
|
if (!language) return fallback;
|
|
23249
|
-
const find = (
|
|
23618
|
+
const find = (tag3) => supported.find((item2) => item2.toLowerCase() === tag3);
|
|
23250
23619
|
const exact = find(parts.join("-"));
|
|
23251
23620
|
if (exact) return exact;
|
|
23252
23621
|
const base = find(language);
|
|
@@ -23603,8 +23972,11 @@ var embedding_exports = {};
|
|
|
23603
23972
|
__export(embedding_exports, {
|
|
23604
23973
|
EDITOR_CAPABILITY_IDS: () => EDITOR_CAPABILITY_IDS,
|
|
23605
23974
|
FILE_COMMAND_EVENT: () => FILE_COMMAND_EVENT,
|
|
23975
|
+
StorageConflictError: () => StorageConflictError,
|
|
23606
23976
|
acceptedHostBackstagePages: () => acceptedHostBackstagePages,
|
|
23607
23977
|
capabilityHiddenActions: () => capabilityHiddenActions,
|
|
23978
|
+
createStorageMerger: () => createStorageMerger,
|
|
23979
|
+
createStorageSession: () => createStorageSession,
|
|
23608
23980
|
disabledCapabilities: () => disabledCapabilities,
|
|
23609
23981
|
documentMimeType: () => documentMimeType,
|
|
23610
23982
|
documentSaveMeta: () => documentSaveMeta,
|
|
@@ -23830,6 +24202,210 @@ function sameItems(a2, b) {
|
|
|
23830
24202
|
return a2 === b || a2.length === b.length && a2.every((item2, index) => Object.is(item2, b[index]));
|
|
23831
24203
|
}
|
|
23832
24204
|
|
|
24205
|
+
// embedding/versioned-storage.ts
|
|
24206
|
+
var StorageConflictError = class extends Error {
|
|
24207
|
+
constructor(conflict) {
|
|
24208
|
+
super(
|
|
24209
|
+
"The changes could not be combined automatically. Your edits are retained for resolution."
|
|
24210
|
+
);
|
|
24211
|
+
this.conflict = conflict;
|
|
24212
|
+
this.name = "StorageConflictError";
|
|
24213
|
+
}
|
|
24214
|
+
conflict;
|
|
24215
|
+
};
|
|
24216
|
+
|
|
24217
|
+
// embedding/storage-merge.ts
|
|
24218
|
+
function createStorageMerger(handlers, options2 = {}) {
|
|
24219
|
+
const registry = new Map(Object.entries(handlers));
|
|
24220
|
+
return (input) => {
|
|
24221
|
+
input.signal?.throwIfAborted();
|
|
24222
|
+
const handler = registry.has(input.kind) ? registry.get(input.kind) : options2.fallback;
|
|
24223
|
+
return handler ? runStorageMerge(handler, input) : {
|
|
24224
|
+
status: "unresolved",
|
|
24225
|
+
issues: [`unsupported-merge-kind:${input.kind}`]
|
|
24226
|
+
};
|
|
24227
|
+
};
|
|
24228
|
+
}
|
|
24229
|
+
async function runStorageMerge(merge, input) {
|
|
24230
|
+
const { signal } = input;
|
|
24231
|
+
signal?.throwIfAborted();
|
|
24232
|
+
if (!signal) return merge(input);
|
|
24233
|
+
let abort = () => {
|
|
24234
|
+
};
|
|
24235
|
+
try {
|
|
24236
|
+
return await Promise.race([
|
|
24237
|
+
merge(input),
|
|
24238
|
+
new Promise((_, reject2) => {
|
|
24239
|
+
abort = () => reject2(signal.reason);
|
|
24240
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
24241
|
+
if (signal.aborted) abort();
|
|
24242
|
+
})
|
|
24243
|
+
]);
|
|
24244
|
+
} finally {
|
|
24245
|
+
signal.removeEventListener("abort", abort);
|
|
24246
|
+
}
|
|
24247
|
+
}
|
|
24248
|
+
|
|
24249
|
+
// embedding/storage-session.ts
|
|
24250
|
+
function createStorageSession(client, opened, settings = {}) {
|
|
24251
|
+
const cloneFile = settings.cloneFile ?? ((file) => structuredClone(file));
|
|
24252
|
+
const clone2 = (value) => ({
|
|
24253
|
+
file: cloneFile(value.file),
|
|
24254
|
+
bytes: value.bytes.slice()
|
|
24255
|
+
});
|
|
24256
|
+
const equal3 = (a2, b) => a2.length === b.length && a2.every((value, index) => value === b[index]);
|
|
24257
|
+
const cloneConflict = (value) => ({
|
|
24258
|
+
base: clone2(value.base),
|
|
24259
|
+
local: value.local.slice(),
|
|
24260
|
+
remote: clone2(value.remote),
|
|
24261
|
+
...value.issues ? { issues: [...value.issues] } : {}
|
|
24262
|
+
});
|
|
24263
|
+
const merge = settings.merge;
|
|
24264
|
+
const maxRebases = settings.maxMergeAttempts ?? (merge ? 3 : 1);
|
|
24265
|
+
if (!Number.isInteger(maxRebases) || maxRebases < 1 || maxRebases > 10)
|
|
24266
|
+
throw new RangeError("Storage merge attempts must be an integer from 1 to 10.");
|
|
24267
|
+
let base = clone2(opened);
|
|
24268
|
+
let acknowledgedLocal = opened.bytes.slice();
|
|
24269
|
+
let local = opened.bytes.slice();
|
|
24270
|
+
let conflict = null;
|
|
24271
|
+
let pending = Promise.resolve();
|
|
24272
|
+
function enqueue(run2) {
|
|
24273
|
+
const result = pending.then(run2);
|
|
24274
|
+
pending = result.catch(() => {
|
|
24275
|
+
});
|
|
24276
|
+
return result;
|
|
24277
|
+
}
|
|
24278
|
+
function adopt(next, submitted = next.bytes) {
|
|
24279
|
+
base = clone2(next);
|
|
24280
|
+
acknowledgedLocal = submitted.slice();
|
|
24281
|
+
local = next.bytes.slice();
|
|
24282
|
+
conflict = null;
|
|
24283
|
+
}
|
|
24284
|
+
async function save(snapshot2, options2) {
|
|
24285
|
+
local = snapshot2.slice();
|
|
24286
|
+
conflict = null;
|
|
24287
|
+
let ancestor = clone2(base);
|
|
24288
|
+
let candidate = snapshot2.slice();
|
|
24289
|
+
let rebases = 0;
|
|
24290
|
+
if (merge && !equal3(acknowledgedLocal, base.bytes)) {
|
|
24291
|
+
conflict = {
|
|
24292
|
+
base: { file: cloneFile(base.file), bytes: acknowledgedLocal.slice() },
|
|
24293
|
+
local: candidate.slice(),
|
|
24294
|
+
remote: clone2(base)
|
|
24295
|
+
};
|
|
24296
|
+
candidate = await mergeConflict(conflict, options2);
|
|
24297
|
+
local = candidate.slice();
|
|
24298
|
+
}
|
|
24299
|
+
while (true) {
|
|
24300
|
+
options2?.signal?.throwIfAborted();
|
|
24301
|
+
try {
|
|
24302
|
+
const file = await client.save(ancestor.file, candidate, options2);
|
|
24303
|
+
adopt({ file, bytes: candidate }, snapshot2);
|
|
24304
|
+
return cloneFile(file);
|
|
24305
|
+
} catch (error) {
|
|
24306
|
+
if (!client.isConflict(error)) throw error;
|
|
24307
|
+
}
|
|
24308
|
+
const remote = await client.read(ancestor.file, options2);
|
|
24309
|
+
if (remote.file.kind !== ancestor.file.kind) {
|
|
24310
|
+
conflict = {
|
|
24311
|
+
base: clone2(ancestor),
|
|
24312
|
+
local: candidate.slice(),
|
|
24313
|
+
remote: clone2(remote),
|
|
24314
|
+
issues: ["file-format-changed"]
|
|
24315
|
+
};
|
|
24316
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
24317
|
+
cloneConflict(conflict)
|
|
24318
|
+
);
|
|
24319
|
+
}
|
|
24320
|
+
if (equal3(candidate, remote.bytes)) {
|
|
24321
|
+
adopt(remote, snapshot2);
|
|
24322
|
+
return cloneFile(remote.file);
|
|
24323
|
+
}
|
|
24324
|
+
conflict = { base: clone2(ancestor), local: candidate.slice(), remote: clone2(remote) };
|
|
24325
|
+
if (rebases >= maxRebases) {
|
|
24326
|
+
conflict.issues = ["remote-keeps-changing"];
|
|
24327
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
24328
|
+
cloneConflict(conflict)
|
|
24329
|
+
);
|
|
24330
|
+
}
|
|
24331
|
+
rebases++;
|
|
24332
|
+
if (!equal3(ancestor.bytes, remote.bytes)) {
|
|
24333
|
+
if (!merge)
|
|
24334
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
24335
|
+
cloneConflict(conflict)
|
|
24336
|
+
);
|
|
24337
|
+
candidate = await mergeConflict(conflict, options2);
|
|
24338
|
+
local = candidate.slice();
|
|
24339
|
+
}
|
|
24340
|
+
ancestor = clone2(remote);
|
|
24341
|
+
}
|
|
24342
|
+
}
|
|
24343
|
+
async function mergeConflict(value, options2) {
|
|
24344
|
+
let result;
|
|
24345
|
+
try {
|
|
24346
|
+
result = await runStorageMerge(merge, {
|
|
24347
|
+
...cloneConflict(value),
|
|
24348
|
+
kind: value.base.file.kind,
|
|
24349
|
+
...options2?.signal ? { signal: options2.signal } : {}
|
|
24350
|
+
});
|
|
24351
|
+
} catch {
|
|
24352
|
+
options2?.signal?.throwIfAborted();
|
|
24353
|
+
value.issues = ["merge-failed"];
|
|
24354
|
+
throw (settings.conflictError ?? ((value2) => new StorageConflictError(value2)))(
|
|
24355
|
+
cloneConflict(value)
|
|
24356
|
+
);
|
|
24357
|
+
}
|
|
24358
|
+
options2?.signal?.throwIfAborted();
|
|
24359
|
+
if (!result || result.status !== "merged" || !(result.bytes instanceof Uint8Array) || !result.bytes.length) {
|
|
24360
|
+
value.issues = result?.status === "unresolved" && Array.isArray(result.issues) ? result.issues.filter((issue) => typeof issue === "string") : ["invalid-merge-result"];
|
|
24361
|
+
throw (settings.conflictError ?? ((value2) => new StorageConflictError(value2)))(
|
|
24362
|
+
cloneConflict(value)
|
|
24363
|
+
);
|
|
24364
|
+
}
|
|
24365
|
+
return result.bytes.slice();
|
|
24366
|
+
}
|
|
24367
|
+
const session = {
|
|
24368
|
+
getSnapshot: () => ({
|
|
24369
|
+
file: cloneFile(base.file),
|
|
24370
|
+
baseBytes: base.bytes.slice(),
|
|
24371
|
+
conflict: conflict ? cloneConflict(conflict) : null
|
|
24372
|
+
}),
|
|
24373
|
+
save(bytes, options2) {
|
|
24374
|
+
const snapshot2 = bytes.slice();
|
|
24375
|
+
return enqueue(() => save(snapshot2, options2));
|
|
24376
|
+
},
|
|
24377
|
+
reload(options2) {
|
|
24378
|
+
return enqueue(async () => {
|
|
24379
|
+
const next = await client.read(base.file, options2);
|
|
24380
|
+
adopt(next);
|
|
24381
|
+
return clone2(next);
|
|
24382
|
+
});
|
|
24383
|
+
},
|
|
24384
|
+
saveCopy(bytes, name, options2) {
|
|
24385
|
+
const snapshot2 = bytes?.slice();
|
|
24386
|
+
return enqueue(async () => {
|
|
24387
|
+
if (!client.saveCopy)
|
|
24388
|
+
throw new Error("This storage provider does not support saving copies.");
|
|
24389
|
+
const next = await client.saveCopy(base.file, snapshot2 ?? local, name, options2);
|
|
24390
|
+
adopt(next);
|
|
24391
|
+
return clone2(next);
|
|
24392
|
+
});
|
|
24393
|
+
},
|
|
24394
|
+
storage: {
|
|
24395
|
+
async save(bytes, meta) {
|
|
24396
|
+
settings.validateSave?.(meta, cloneFile(base.file));
|
|
24397
|
+
if (meta.reason === "saveAs") {
|
|
24398
|
+
const result2 = await session.saveCopy(bytes, meta.fileName);
|
|
24399
|
+
return { fileName: result2.file.name };
|
|
24400
|
+
}
|
|
24401
|
+
const result = await session.save(bytes);
|
|
24402
|
+
return { fileName: result.name };
|
|
24403
|
+
}
|
|
24404
|
+
}
|
|
24405
|
+
};
|
|
24406
|
+
return session;
|
|
24407
|
+
}
|
|
24408
|
+
|
|
23833
24409
|
// diagram/index.ts
|
|
23834
24410
|
var diagram_exports = {};
|
|
23835
24411
|
__export(diagram_exports, {
|
|
@@ -24251,10 +24827,10 @@ function parseAttributes(source2) {
|
|
|
24251
24827
|
}
|
|
24252
24828
|
return attrs2;
|
|
24253
24829
|
}
|
|
24254
|
-
function tagEnd(
|
|
24830
|
+
function tagEnd(xml2, from) {
|
|
24255
24831
|
let quote = "";
|
|
24256
|
-
for (let i2 = from; i2 <
|
|
24257
|
-
const ch =
|
|
24832
|
+
for (let i2 = from; i2 < xml2.length; i2++) {
|
|
24833
|
+
const ch = xml2[i2];
|
|
24258
24834
|
if (quote) {
|
|
24259
24835
|
if (ch === quote) {
|
|
24260
24836
|
quote = "";
|
|
@@ -24267,27 +24843,27 @@ function tagEnd(xml, from) {
|
|
|
24267
24843
|
}
|
|
24268
24844
|
return -1;
|
|
24269
24845
|
}
|
|
24270
|
-
function parseOrderedXml(
|
|
24846
|
+
function parseOrderedXml(xml2) {
|
|
24271
24847
|
const root = { name: "#document", attrs: {}, children: [] };
|
|
24272
24848
|
const stack = [root];
|
|
24273
|
-
let i2 =
|
|
24274
|
-
while (i2 >= 0 && i2 <
|
|
24275
|
-
if (
|
|
24276
|
-
const close =
|
|
24277
|
-
i2 = close < 0 ? -1 :
|
|
24849
|
+
let i2 = xml2.indexOf("<");
|
|
24850
|
+
while (i2 >= 0 && i2 < xml2.length) {
|
|
24851
|
+
if (xml2.startsWith("<!--", i2)) {
|
|
24852
|
+
const close = xml2.indexOf("-->", i2 + 4);
|
|
24853
|
+
i2 = close < 0 ? -1 : xml2.indexOf("<", close + 3);
|
|
24278
24854
|
continue;
|
|
24279
24855
|
}
|
|
24280
|
-
if (
|
|
24281
|
-
const close =
|
|
24282
|
-
i2 = close < 0 ? -1 :
|
|
24856
|
+
if (xml2.startsWith("<![CDATA[", i2)) {
|
|
24857
|
+
const close = xml2.indexOf("]]>", i2 + 9);
|
|
24858
|
+
i2 = close < 0 ? -1 : xml2.indexOf("<", close + 3);
|
|
24283
24859
|
continue;
|
|
24284
24860
|
}
|
|
24285
|
-
const end = tagEnd(
|
|
24861
|
+
const end = tagEnd(xml2, i2 + 1);
|
|
24286
24862
|
if (end < 0) {
|
|
24287
24863
|
break;
|
|
24288
24864
|
}
|
|
24289
|
-
const next =
|
|
24290
|
-
const first2 =
|
|
24865
|
+
const next = xml2.indexOf("<", end + 1);
|
|
24866
|
+
const first2 = xml2[i2 + 1];
|
|
24291
24867
|
if (first2 === "?" || first2 === "!") {
|
|
24292
24868
|
i2 = next;
|
|
24293
24869
|
continue;
|
|
@@ -24295,11 +24871,11 @@ function parseOrderedXml(xml) {
|
|
|
24295
24871
|
const closing = first2 === "/";
|
|
24296
24872
|
let cursor = closing ? i2 + 2 : i2 + 1;
|
|
24297
24873
|
const nameStart = cursor;
|
|
24298
|
-
while (cursor < end && isNameChar2(
|
|
24874
|
+
while (cursor < end && isNameChar2(xml2[cursor])) {
|
|
24299
24875
|
cursor++;
|
|
24300
24876
|
}
|
|
24301
|
-
const
|
|
24302
|
-
if (!
|
|
24877
|
+
const tag3 = xml2.slice(nameStart, cursor);
|
|
24878
|
+
if (!tag3) {
|
|
24303
24879
|
i2 = next;
|
|
24304
24880
|
continue;
|
|
24305
24881
|
}
|
|
@@ -24310,10 +24886,10 @@ function parseOrderedXml(xml) {
|
|
|
24310
24886
|
i2 = next;
|
|
24311
24887
|
continue;
|
|
24312
24888
|
}
|
|
24313
|
-
const selfClosing =
|
|
24889
|
+
const selfClosing = xml2[end - 1] === "/";
|
|
24314
24890
|
const element4 = {
|
|
24315
|
-
name: localName(
|
|
24316
|
-
attrs: parseAttributes(
|
|
24891
|
+
name: localName(tag3),
|
|
24892
|
+
attrs: parseAttributes(xml2.slice(cursor, selfClosing ? end - 1 : end)),
|
|
24317
24893
|
children: []
|
|
24318
24894
|
};
|
|
24319
24895
|
stack[stack.length - 1].children.push(element4);
|
|
@@ -24523,8 +25099,8 @@ function parseStatement(element4, state) {
|
|
|
24523
25099
|
return void 0;
|
|
24524
25100
|
}
|
|
24525
25101
|
}
|
|
24526
|
-
function parseLayoutDefinitionXml(
|
|
24527
|
-
const document = parseOrderedXml(
|
|
25102
|
+
function parseLayoutDefinitionXml(xml2) {
|
|
25103
|
+
const document = parseOrderedXml(xml2);
|
|
24528
25104
|
const layoutDef = document?.name === "layoutDef" ? document : findOrderedDescendant(document, "layoutDef");
|
|
24529
25105
|
const rootElement = layoutDef?.children.find((child6) => child6.name === "layoutNode");
|
|
24530
25106
|
if (!layoutDef || !rootElement) {
|
|
@@ -47838,9 +48414,9 @@ function dataModelExtXml(drawingRelId) {
|
|
|
47838
48414
|
}
|
|
47839
48415
|
return `<dgm:extLst><a:ext uri="${DSP_DATA_MODEL_EXT_URI}"><dsp:dataModelExt xmlns:dsp="${DSP_DATA_MODEL_EXT_URI}" relId="${escapeDiagramXml(drawingRelId)}" minVer="http://schemas.openxmlformats.org/drawingml/2006/diagram"/></a:ext></dgm:extLst>`;
|
|
47840
48416
|
}
|
|
47841
|
-
function withDiagramXmlProlog(
|
|
47842
|
-
return /^\s*<\?xml\b/u.test(
|
|
47843
|
-
${
|
|
48417
|
+
function withDiagramXmlProlog(xml2) {
|
|
48418
|
+
return /^\s*<\?xml\b/u.test(xml2) ? xml2 : `${DIAGRAM_XML_PROLOG}\r
|
|
48419
|
+
${xml2}`;
|
|
47844
48420
|
}
|
|
47845
48421
|
|
|
47846
48422
|
// diagram/write/fabricated-styles.ts
|
|
@@ -48089,12 +48665,12 @@ function writeDiagramFormatDefinition(source2, change) {
|
|
|
48089
48665
|
return buildXml(doc);
|
|
48090
48666
|
}
|
|
48091
48667
|
function formatDiagramSource(source2, change) {
|
|
48092
|
-
const
|
|
48668
|
+
const xml2 = writeDiagramFormatDefinition(
|
|
48093
48669
|
change.kind === "colors" ? source2?.colorsXml : source2?.quickStyleXml,
|
|
48094
48670
|
change
|
|
48095
48671
|
);
|
|
48096
48672
|
const id = `urn:ooxml-core/${change.kind}/${change.value}`;
|
|
48097
|
-
return change.kind === "colors" ? { source: { ...source2, colorsXml:
|
|
48673
|
+
return change.kind === "colors" ? { source: { ...source2, colorsXml: xml2 }, colorsId: id } : { source: { ...source2, quickStyleXml: xml2 }, quickStyleId: id };
|
|
48098
48674
|
}
|
|
48099
48675
|
|
|
48100
48676
|
// diagram/write/data-edit.ts
|
|
@@ -48200,9 +48776,9 @@ function dropDrawingExtension(model) {
|
|
|
48200
48776
|
if (ext.getAttribute("uri") === DSP_EXT_URI) extLst.removeChild(ext);
|
|
48201
48777
|
if (elements(extLst).length === 0) model.removeChild(extLst);
|
|
48202
48778
|
}
|
|
48203
|
-
function writeEditedDiagramData(
|
|
48779
|
+
function writeEditedDiagramData(xml2, nodes, options2 = {}) {
|
|
48204
48780
|
const createModelId = options2.createModelId ?? createOfficeGuid;
|
|
48205
|
-
const doc = parseXml(
|
|
48781
|
+
const doc = parseXml(xml2, { label: "diagram data" });
|
|
48206
48782
|
const model = doc.documentElement;
|
|
48207
48783
|
const ptLst = child4(model, "ptLst");
|
|
48208
48784
|
if (!ptLst) throw new Error("The diagram data part has no point list.");
|
|
@@ -48640,8 +49216,8 @@ function sha256(data) {
|
|
|
48640
49216
|
// diagram/cache-metadata.ts
|
|
48641
49217
|
var GENERATED_DIAGRAM_CACHE_NS = "urn:ooxml-core:diagram:generated-cache";
|
|
48642
49218
|
var GENERATED_DIAGRAM_CACHE_NOTICE = "Generated SmartArt preview; not native Office layout.";
|
|
48643
|
-
var generatedDrawingDigest = (
|
|
48644
|
-
sha256(new TextEncoder().encode(
|
|
49219
|
+
var generatedDrawingDigest = (xml2) => Array.from(
|
|
49220
|
+
sha256(new TextEncoder().encode(xml2)),
|
|
48645
49221
|
(byte) => byte.toString(16).padStart(2, "0")
|
|
48646
49222
|
).join("");
|
|
48647
49223
|
var DEFAULT_GENERATED_DIAGRAM_SCHEME = {
|
|
@@ -49076,6 +49652,7 @@ __export(opc_exports, {
|
|
|
49076
49652
|
isSafePartName: () => isSafePartName,
|
|
49077
49653
|
isStorableHyperlinkHref: () => isStorableHyperlinkHref,
|
|
49078
49654
|
listEmbeddedPackages: () => listEmbeddedPackages,
|
|
49655
|
+
mergeOpcSnapshots: () => mergeOpcSnapshots,
|
|
49079
49656
|
nextRelationshipId: () => nextRelationshipId,
|
|
49080
49657
|
openZip: () => openZip,
|
|
49081
49658
|
parseAppProperties: () => parseAppProperties,
|
|
@@ -49153,11 +49730,11 @@ var RELATIONSHIP_TYPES = {
|
|
|
49153
49730
|
|
|
49154
49731
|
// opc/content-types.ts
|
|
49155
49732
|
var escapeAttr2 = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
49156
|
-
function parseContentTypes(
|
|
49733
|
+
function parseContentTypes(xml2) {
|
|
49157
49734
|
const defaults = /* @__PURE__ */ new Map();
|
|
49158
49735
|
const overrides = /* @__PURE__ */ new Map();
|
|
49159
|
-
if (!
|
|
49160
|
-
for (const node of elements(parseXml(
|
|
49736
|
+
if (!xml2) return { defaults, overrides };
|
|
49737
|
+
for (const node of elements(parseXml(xml2).documentElement)) {
|
|
49161
49738
|
const contentType = node.getAttribute("ContentType");
|
|
49162
49739
|
if (!contentType) continue;
|
|
49163
49740
|
if (node.localName === "Default") {
|
|
@@ -49186,9 +49763,9 @@ function buildContentTypesXml(types) {
|
|
|
49186
49763
|
).join("");
|
|
49187
49764
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${NS.contentTypes}">${defaults}${overrides}</Types>`;
|
|
49188
49765
|
}
|
|
49189
|
-
function ensureContentTypeDefault(
|
|
49190
|
-
const types = parseContentTypes(
|
|
49191
|
-
if (types.defaults.has(extension.toLowerCase())) return
|
|
49766
|
+
function ensureContentTypeDefault(xml2, extension, contentType) {
|
|
49767
|
+
const types = parseContentTypes(xml2);
|
|
49768
|
+
if (types.defaults.has(extension.toLowerCase())) return xml2 ?? buildContentTypesXml(types);
|
|
49192
49769
|
types.defaults.set(extension.toLowerCase(), contentType);
|
|
49193
49770
|
return buildContentTypesXml(types);
|
|
49194
49771
|
}
|
|
@@ -49198,35 +49775,35 @@ var CONTENT_TYPES_PATH = "[Content_Types].xml";
|
|
|
49198
49775
|
var XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
49199
49776
|
var EMPTY_TYPES = `${XML_DECLARATION}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>`;
|
|
49200
49777
|
var EMPTY_RELS = `${XML_DECLARATION}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;
|
|
49201
|
-
function attr2(
|
|
49778
|
+
function attr2(tag3, name) {
|
|
49202
49779
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
49203
|
-
const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(
|
|
49780
|
+
const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag3);
|
|
49204
49781
|
return match ? match[1] ?? match[2] : void 0;
|
|
49205
49782
|
}
|
|
49206
49783
|
async function ensureContentTypeOverride(zip, partName, contentType) {
|
|
49207
|
-
const
|
|
49784
|
+
const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
|
|
49208
49785
|
const target = `/${partName}`;
|
|
49209
|
-
for (const
|
|
49210
|
-
if (attr2(
|
|
49786
|
+
for (const tag3 of xml2.match(/<Override\b[^>]*\/>/g) ?? [])
|
|
49787
|
+
if (attr2(tag3, "PartName") === target) return;
|
|
49211
49788
|
const insertion = `<Override PartName="${target}" ContentType="${contentType}"/>`;
|
|
49212
|
-
zip.file(CONTENT_TYPES_PATH,
|
|
49789
|
+
zip.file(CONTENT_TYPES_PATH, xml2.replace("</Types>", `${insertion}</Types>`));
|
|
49213
49790
|
}
|
|
49214
49791
|
async function removeContentTypeOverride(zip, partName) {
|
|
49215
|
-
const
|
|
49216
|
-
if (!
|
|
49792
|
+
const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string");
|
|
49793
|
+
if (!xml2) return;
|
|
49217
49794
|
const target = `/${partName}`;
|
|
49218
|
-
const
|
|
49795
|
+
const tag3 = (xml2.match(/<Override\b[^>]*\/>/g) ?? []).find(
|
|
49219
49796
|
(candidate) => attr2(candidate, "PartName") === target
|
|
49220
49797
|
);
|
|
49221
|
-
if (
|
|
49798
|
+
if (tag3) zip.file(CONTENT_TYPES_PATH, xml2.replace(tag3, ""));
|
|
49222
49799
|
}
|
|
49223
49800
|
async function ensureRelationship(zip, relsPath, type, target) {
|
|
49224
|
-
const
|
|
49801
|
+
const xml2 = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
|
|
49225
49802
|
const used = /* @__PURE__ */ new Set();
|
|
49226
|
-
for (const
|
|
49227
|
-
const id2 = attr2(
|
|
49803
|
+
for (const tag3 of xml2.match(/<Relationship\b[^>]*\/>/g) ?? []) {
|
|
49804
|
+
const id2 = attr2(tag3, "Id");
|
|
49228
49805
|
if (id2) used.add(id2);
|
|
49229
|
-
if (id2 && attr2(
|
|
49806
|
+
if (id2 && attr2(tag3, "Type") === type && attr2(tag3, "Target") === target) return id2;
|
|
49230
49807
|
}
|
|
49231
49808
|
const highest = Math.max(
|
|
49232
49809
|
0,
|
|
@@ -49235,16 +49812,112 @@ async function ensureRelationship(zip, relsPath, type, target) {
|
|
|
49235
49812
|
let id = `rId${highest + 1}`;
|
|
49236
49813
|
if (used.has(id)) id = nextRelationshipId(used);
|
|
49237
49814
|
const insertion = `<Relationship Id="${id}" Type="${type}" Target="${target}"/>`;
|
|
49238
|
-
zip.file(relsPath,
|
|
49815
|
+
zip.file(relsPath, xml2.replace("</Relationships>", `${insertion}</Relationships>`));
|
|
49239
49816
|
return id;
|
|
49240
49817
|
}
|
|
49241
49818
|
async function findOfficeDocumentPart(zip) {
|
|
49242
|
-
const
|
|
49243
|
-
for (const
|
|
49244
|
-
if (attr2(
|
|
49819
|
+
const xml2 = await zip.file("_rels/.rels")?.async("string");
|
|
49820
|
+
for (const tag3 of xml2?.match(/<Relationship\b[^>]*\/>/g) ?? [])
|
|
49821
|
+
if (attr2(tag3, "Type") === RELATIONSHIP_TYPES.officeDocument) return attr2(tag3, "Target");
|
|
49245
49822
|
return void 0;
|
|
49246
49823
|
}
|
|
49247
49824
|
|
|
49825
|
+
// opc/merge-snapshots.ts
|
|
49826
|
+
var equal2 = (a2, b) => a2 === b || Boolean(a2 && b && a2.length === b.length && a2.every((value, index) => value === b[index]));
|
|
49827
|
+
var decoder = new TextDecoder("utf-8", { fatal: true });
|
|
49828
|
+
var encoder = new TextEncoder();
|
|
49829
|
+
function mergeManifest(input) {
|
|
49830
|
+
const { path: path3, base, local, remote } = input;
|
|
49831
|
+
if (!base || !local || !remote) return void 0;
|
|
49832
|
+
if (!path3.endsWith(".rels") && path3 !== "[Content_Types].xml" && path3 !== "docProps/core.xml")
|
|
49833
|
+
return void 0;
|
|
49834
|
+
try {
|
|
49835
|
+
const result = mergeXmlThreeWay(
|
|
49836
|
+
decoder.decode(base),
|
|
49837
|
+
decoder.decode(local),
|
|
49838
|
+
decoder.decode(remote),
|
|
49839
|
+
{
|
|
49840
|
+
keyElement: (element4) => {
|
|
49841
|
+
const attribute2 = element4.localName === "Relationship" ? "Id" : element4.localName === "Override" ? "PartName" : element4.localName === "Default" ? "Extension" : void 0;
|
|
49842
|
+
return attribute2 ? element4.getAttribute(attribute2) ?? void 0 : void 0;
|
|
49843
|
+
},
|
|
49844
|
+
resolveText: (_b, _l, r) => path3 === "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
|
|
49845
|
+
}
|
|
49846
|
+
);
|
|
49847
|
+
return result.status === "merged" ? { status: "merged", bytes: encoder.encode(result.xml) } : result;
|
|
49848
|
+
} catch {
|
|
49849
|
+
return { status: "unresolved", issues: [`${path3}: invalid metadata XML`] };
|
|
49850
|
+
}
|
|
49851
|
+
}
|
|
49852
|
+
async function mergeOpcSnapshots(baseBytes, localBytes, remoteBytes, options2 = {}) {
|
|
49853
|
+
if (equal2(localBytes, remoteBytes) || equal2(baseBytes, remoteBytes))
|
|
49854
|
+
return { status: "merged", bytes: localBytes.slice() };
|
|
49855
|
+
if (equal2(baseBytes, localBytes)) return { status: "merged", bytes: remoteBytes.slice() };
|
|
49856
|
+
try {
|
|
49857
|
+
const [base, local, remote] = await Promise.all([
|
|
49858
|
+
openZip(baseBytes, { label: "Merge" }),
|
|
49859
|
+
openZip(localBytes, { label: "Merge" }),
|
|
49860
|
+
openZip(remoteBytes, { label: "Merge" })
|
|
49861
|
+
]);
|
|
49862
|
+
const paths = [
|
|
49863
|
+
...new Set(
|
|
49864
|
+
[base, local, remote].flatMap(
|
|
49865
|
+
(zip) => Object.keys(zip.files).filter((path3) => !zip.files[path3].dir)
|
|
49866
|
+
)
|
|
49867
|
+
)
|
|
49868
|
+
].sort();
|
|
49869
|
+
if (paths.some((path3) => path3.startsWith("_xmlsignatures/")))
|
|
49870
|
+
return {
|
|
49871
|
+
status: "unresolved",
|
|
49872
|
+
issues: ["Signed packages require explicit signature handling before merging"]
|
|
49873
|
+
};
|
|
49874
|
+
const issues = [];
|
|
49875
|
+
for (const path3 of paths) {
|
|
49876
|
+
const [b, l, r] = await Promise.all(
|
|
49877
|
+
[base, local, remote].map((zip) => zip.file(path3)?.async("uint8array"))
|
|
49878
|
+
);
|
|
49879
|
+
let chosen;
|
|
49880
|
+
if (equal2(l, r) || equal2(b, r)) chosen = l;
|
|
49881
|
+
else if (equal2(b, l)) chosen = r;
|
|
49882
|
+
else {
|
|
49883
|
+
const input = {
|
|
49884
|
+
path: path3,
|
|
49885
|
+
...b ? { base: b } : {},
|
|
49886
|
+
...l ? { local: l } : {},
|
|
49887
|
+
...r ? { remote: r } : {}
|
|
49888
|
+
};
|
|
49889
|
+
const result = mergeManifest(input) ?? await options2.mergePart?.(input);
|
|
49890
|
+
if (!result || result.status === "unresolved") {
|
|
49891
|
+
issues.push(...result?.issues ?? [`${path3}: both versions changed the same part`]);
|
|
49892
|
+
continue;
|
|
49893
|
+
}
|
|
49894
|
+
chosen = result.bytes;
|
|
49895
|
+
}
|
|
49896
|
+
if (chosen) remote.file(path3, chosen);
|
|
49897
|
+
else remote.remove(path3);
|
|
49898
|
+
}
|
|
49899
|
+
if (issues.length) return { status: "unresolved", issues };
|
|
49900
|
+
for (const path3 of Object.keys(remote.files).filter((name) => name.endsWith(".rels"))) {
|
|
49901
|
+
const source2 = path3 === "_rels/.rels" ? "" : path3.replace(/(^|\/)_rels\/([^/]+)\.rels$/u, "$1$2");
|
|
49902
|
+
for (const relation2 of parseRelationships(
|
|
49903
|
+
await remote.file(path3).async("string")
|
|
49904
|
+
).values()) {
|
|
49905
|
+
if (relation2.mode === "External") continue;
|
|
49906
|
+
const target = resolvePartPath(source2, relation2.target.split("#")[0] ?? "");
|
|
49907
|
+
if (!remote.file(target) && !remote.file(decodeURIComponent(target)))
|
|
49908
|
+
issues.push(`${path3}: merged relationship target is missing`);
|
|
49909
|
+
}
|
|
49910
|
+
}
|
|
49911
|
+
if (issues.length) return { status: "unresolved", issues };
|
|
49912
|
+
return {
|
|
49913
|
+
status: "merged",
|
|
49914
|
+
bytes: await remote.generateAsync({ type: "uint8array", compression: "DEFLATE" })
|
|
49915
|
+
};
|
|
49916
|
+
} catch {
|
|
49917
|
+
return { status: "unresolved", issues: ["Invalid or oversized Office package"] };
|
|
49918
|
+
}
|
|
49919
|
+
}
|
|
49920
|
+
|
|
49248
49921
|
// opc/clone-part-graph.ts
|
|
49249
49922
|
function relativePartTarget(basePart, targetPart) {
|
|
49250
49923
|
const base = basePart.split("/").slice(0, -1);
|
|
@@ -49277,9 +49950,9 @@ async function clonePartGraph(options2) {
|
|
|
49277
49950
|
const copyRelationships = async (source2, destination) => {
|
|
49278
49951
|
const contentType = contentTypeForPart(types, source2);
|
|
49279
49952
|
if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
|
|
49280
|
-
const
|
|
49281
|
-
if (!
|
|
49282
|
-
const relationships = parseRelationships(
|
|
49953
|
+
const xml2 = await sourceZip.file(relationshipsPartFor(source2))?.async("string");
|
|
49954
|
+
if (!xml2) return;
|
|
49955
|
+
const relationships = parseRelationships(xml2);
|
|
49283
49956
|
for (const relationship2 of relationships.values()) {
|
|
49284
49957
|
if (relationship2.mode === "External") continue;
|
|
49285
49958
|
const originalTarget = resolvePartPath(source2, relationship2.target);
|
|
@@ -49410,10 +50083,10 @@ var PROPERTY_CONTENT_TYPES = {
|
|
|
49410
50083
|
|
|
49411
50084
|
// opc/properties/patch.ts
|
|
49412
50085
|
var XMLNS = "http://www.w3.org/2000/xmlns/";
|
|
49413
|
-
function tagEnd2(
|
|
50086
|
+
function tagEnd2(xml2, from) {
|
|
49414
50087
|
let quote = "";
|
|
49415
|
-
for (let i2 = from + 1; i2 <
|
|
49416
|
-
const ch =
|
|
50088
|
+
for (let i2 = from + 1; i2 < xml2.length; i2++) {
|
|
50089
|
+
const ch = xml2[i2];
|
|
49417
50090
|
if (quote) {
|
|
49418
50091
|
if (ch === quote) quote = "";
|
|
49419
50092
|
} else if (ch === '"' || ch === "'") quote = ch;
|
|
@@ -49421,24 +50094,24 @@ function tagEnd2(xml, from) {
|
|
|
49421
50094
|
}
|
|
49422
50095
|
throw new Error("Unterminated tag in property part");
|
|
49423
50096
|
}
|
|
49424
|
-
function skipMarkup(
|
|
49425
|
-
if (
|
|
49426
|
-
if (
|
|
49427
|
-
if (
|
|
50097
|
+
function skipMarkup(xml2, at2) {
|
|
50098
|
+
if (xml2.startsWith("<!--", at2)) return xml2.indexOf("-->", at2) + 3;
|
|
50099
|
+
if (xml2.startsWith("<![CDATA[", at2)) return xml2.indexOf("]]>", at2) + 3;
|
|
50100
|
+
if (xml2.startsWith("<?", at2)) return xml2.indexOf("?>", at2) + 2;
|
|
49428
50101
|
return void 0;
|
|
49429
50102
|
}
|
|
49430
|
-
function scan(
|
|
50103
|
+
function scan(xml2) {
|
|
49431
50104
|
let i2 = 0;
|
|
49432
50105
|
let rootStart = -1;
|
|
49433
50106
|
while (rootStart < 0) {
|
|
49434
|
-
const lt =
|
|
50107
|
+
const lt = xml2.indexOf("<", i2);
|
|
49435
50108
|
if (lt < 0) throw new Error("Property part has no root element");
|
|
49436
|
-
const skipped = skipMarkup(
|
|
50109
|
+
const skipped = skipMarkup(xml2, lt);
|
|
49437
50110
|
if (skipped !== void 0) i2 = skipped;
|
|
49438
50111
|
else rootStart = lt;
|
|
49439
50112
|
}
|
|
49440
|
-
const openEnd = tagEnd2(
|
|
49441
|
-
if (
|
|
50113
|
+
const openEnd = tagEnd2(xml2, rootStart);
|
|
50114
|
+
if (xml2[openEnd - 2] === "/") {
|
|
49442
50115
|
const root = {
|
|
49443
50116
|
start: rootStart,
|
|
49444
50117
|
openEnd,
|
|
@@ -49453,16 +50126,16 @@ function scan(xml) {
|
|
|
49453
50126
|
let child6;
|
|
49454
50127
|
i2 = openEnd;
|
|
49455
50128
|
for (; ; ) {
|
|
49456
|
-
const lt =
|
|
50129
|
+
const lt = xml2.indexOf("<", i2);
|
|
49457
50130
|
if (lt < 0) throw new Error("Property part root is not closed");
|
|
49458
|
-
const skipped = skipMarkup(
|
|
50131
|
+
const skipped = skipMarkup(xml2, lt);
|
|
49459
50132
|
if (skipped !== void 0) {
|
|
49460
50133
|
i2 = skipped;
|
|
49461
50134
|
continue;
|
|
49462
50135
|
}
|
|
49463
|
-
const end = tagEnd2(
|
|
50136
|
+
const end = tagEnd2(xml2, lt);
|
|
49464
50137
|
i2 = end;
|
|
49465
|
-
if (
|
|
50138
|
+
if (xml2[lt + 1] === "/") {
|
|
49466
50139
|
if (depth === 0) {
|
|
49467
50140
|
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
49468
50141
|
return { root, children: children2 };
|
|
@@ -49470,7 +50143,7 @@ function scan(xml) {
|
|
|
49470
50143
|
depth--;
|
|
49471
50144
|
if (depth === 0 && child6)
|
|
49472
50145
|
children2.push({ ...child6, closeStart: lt, end, selfClosing: false });
|
|
49473
|
-
} else if (
|
|
50146
|
+
} else if (xml2[end - 2] === "/") {
|
|
49474
50147
|
if (depth === 0)
|
|
49475
50148
|
children2.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
49476
50149
|
} else {
|
|
@@ -49480,11 +50153,11 @@ function scan(xml) {
|
|
|
49480
50153
|
}
|
|
49481
50154
|
}
|
|
49482
50155
|
var escapeText2 = (text3) => text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
49483
|
-
var qualifiedName = (
|
|
50156
|
+
var qualifiedName = (xml2, span) => /^<([^\s/>]+)/.exec(xml2.slice(span.start, span.openEnd))?.[1] ?? "";
|
|
49484
50157
|
var PartPatch = class {
|
|
49485
|
-
constructor(
|
|
49486
|
-
this.xml =
|
|
49487
|
-
const { root, children: children2 } = scan(
|
|
50158
|
+
constructor(xml2, rootElement) {
|
|
50159
|
+
this.xml = xml2;
|
|
50160
|
+
const { root, children: children2 } = scan(xml2);
|
|
49488
50161
|
const kids = elements(rootElement);
|
|
49489
50162
|
if (kids.length !== children2.length) throw new Error("Property part markup is not supported");
|
|
49490
50163
|
kids.forEach((kid, index) => this.spans.set(kid, children2[index]));
|
|
@@ -49599,10 +50272,10 @@ var FIELDS2 = [
|
|
|
49599
50272
|
var CORE_PROPERTY_FIELDS = FIELDS2.map(([field]) => field);
|
|
49600
50273
|
var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
49601
50274
|
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
49602
|
-
function parseCoreProperties(
|
|
50275
|
+
function parseCoreProperties(xml2) {
|
|
49603
50276
|
const out = {};
|
|
49604
|
-
if (!
|
|
49605
|
-
const root = parseXml(
|
|
50277
|
+
if (!xml2) return out;
|
|
50278
|
+
const root = parseXml(xml2, { label: "core properties" }).documentElement;
|
|
49606
50279
|
for (const [field, prefix] of FIELDS2) {
|
|
49607
50280
|
const text3 = first(root, field, NS[prefix])?.textContent ?? "";
|
|
49608
50281
|
if (text3 !== "") out[field] = text3;
|
|
@@ -49611,9 +50284,9 @@ function parseCoreProperties(xml) {
|
|
|
49611
50284
|
}
|
|
49612
50285
|
var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
49613
50286
|
function writeCoreProperties(props, sourceXml) {
|
|
49614
|
-
const
|
|
49615
|
-
const root = parseXml(
|
|
49616
|
-
const patch = new PartPatch(
|
|
50287
|
+
const xml2 = sourceXml ?? EMPTY_CORE;
|
|
50288
|
+
const root = parseXml(xml2, { label: "core properties" }).documentElement;
|
|
50289
|
+
const patch = new PartPatch(xml2, root);
|
|
49617
50290
|
for (const [field, prefix, isDate] of FIELDS2) {
|
|
49618
50291
|
const ns = NS[prefix];
|
|
49619
50292
|
const value = props[field];
|
|
@@ -49711,9 +50384,9 @@ function readKnown(root, ns) {
|
|
|
49711
50384
|
}
|
|
49712
50385
|
return out;
|
|
49713
50386
|
}
|
|
49714
|
-
function parseAppProperties(
|
|
49715
|
-
if (!
|
|
49716
|
-
const root = parseXml(
|
|
50387
|
+
function parseAppProperties(xml2) {
|
|
50388
|
+
if (!xml2) return {};
|
|
50389
|
+
const root = parseXml(xml2, { label: "app properties" }).documentElement;
|
|
49717
50390
|
const ns = namespacesOf(root);
|
|
49718
50391
|
return ns ? readKnown(root, ns) : {};
|
|
49719
50392
|
}
|
|
@@ -49731,11 +50404,11 @@ function content(kind, value, vt) {
|
|
|
49731
50404
|
return `<${vt}:vector size="${items.length}" baseType="${baseType}">${items.join("")}</${vt}:vector>`;
|
|
49732
50405
|
}
|
|
49733
50406
|
function writeAppProperties(props, sourceXml) {
|
|
49734
|
-
const
|
|
49735
|
-
const root = parseXml(
|
|
50407
|
+
const xml2 = sourceXml ?? EMPTY_APP;
|
|
50408
|
+
const root = parseXml(xml2, { label: "app properties" }).documentElement;
|
|
49736
50409
|
const ns = namespacesOf(root);
|
|
49737
50410
|
if (!ns) throw new Error("app properties root is not an extended-properties element");
|
|
49738
|
-
const patch = new PartPatch(
|
|
50411
|
+
const patch = new PartPatch(xml2, root);
|
|
49739
50412
|
const prior = readKnown(root, ns);
|
|
49740
50413
|
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
49741
50414
|
FIELDS3.forEach(([field, local, kind], index) => {
|
|
@@ -49786,9 +50459,9 @@ function readValue(variant) {
|
|
|
49786
50459
|
return void 0;
|
|
49787
50460
|
}
|
|
49788
50461
|
}
|
|
49789
|
-
function parseCustomProperties(
|
|
49790
|
-
if (!
|
|
49791
|
-
const root = parseXml(
|
|
50462
|
+
function parseCustomProperties(xml2) {
|
|
50463
|
+
if (!xml2) return [];
|
|
50464
|
+
const root = parseXml(xml2, { label: "custom properties" }).documentElement;
|
|
49792
50465
|
const out = [];
|
|
49793
50466
|
for (const property of children(root, "property", NS.customProperties)) {
|
|
49794
50467
|
const name = property.getAttribute("name") ?? "";
|
|
@@ -49854,9 +50527,9 @@ function writeCustomProperties(properties) {
|
|
|
49854
50527
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
49855
50528
|
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
49856
50529
|
}
|
|
49857
|
-
function parseCustomPropertyTexts(
|
|
49858
|
-
if (!
|
|
49859
|
-
const root = parseXml(
|
|
50530
|
+
function parseCustomPropertyTexts(xml2) {
|
|
50531
|
+
if (!xml2) return [];
|
|
50532
|
+
const root = parseXml(xml2, { label: "custom properties" }).documentElement;
|
|
49860
50533
|
const out = [];
|
|
49861
50534
|
for (const property of children(root, "property", NS.customProperties)) {
|
|
49862
50535
|
const name = property.getAttribute("name") ?? "";
|
|
@@ -50599,26 +51272,26 @@ function diagramLayoutData(input) {
|
|
|
50599
51272
|
const branch = first(vars, "hierBranch", NS.dgm)?.getAttribute("val");
|
|
50600
51273
|
if (branch === "std" || branch === "init" || branch === "l" || branch === "r" || branch === "hang")
|
|
50601
51274
|
values.hierarchyBranch = branch;
|
|
50602
|
-
for (const [
|
|
51275
|
+
for (const [tag3, key] of [
|
|
50603
51276
|
["chMax", "childMax"],
|
|
50604
51277
|
["chPref", "childPreferred"]
|
|
50605
51278
|
]) {
|
|
50606
|
-
const raw2 = first(vars,
|
|
51279
|
+
const raw2 = first(vars, tag3, NS.dgm)?.getAttribute("val");
|
|
50607
51280
|
if (raw2 && Number.isFinite(Number(raw2))) values[key] = Number(raw2);
|
|
50608
51281
|
}
|
|
50609
|
-
for (const [
|
|
51282
|
+
for (const [tag3, key] of [
|
|
50610
51283
|
["orgChart", "orgChart"],
|
|
50611
51284
|
["bulletEnabled", "bulletEnabled"]
|
|
50612
51285
|
]) {
|
|
50613
|
-
const raw2 = first(vars,
|
|
51286
|
+
const raw2 = first(vars, tag3, NS.dgm)?.getAttribute("val");
|
|
50614
51287
|
if (raw2) values[key] = raw2 === "1" || raw2 === "true";
|
|
50615
51288
|
}
|
|
50616
|
-
for (const [
|
|
51289
|
+
for (const [tag3, key] of [
|
|
50617
51290
|
["animLvl", "animationLevel"],
|
|
50618
51291
|
["animOne", "animateOne"],
|
|
50619
51292
|
["resizeHandles", "resizeHandles"]
|
|
50620
51293
|
]) {
|
|
50621
|
-
const raw2 = first(vars,
|
|
51294
|
+
const raw2 = first(vars, tag3, NS.dgm)?.getAttribute("val");
|
|
50622
51295
|
if (raw2) values[key] = raw2;
|
|
50623
51296
|
}
|
|
50624
51297
|
data.presLayoutVars = values;
|
|
@@ -50795,8 +51468,8 @@ function add(parent, namespace, name, attrs2 = {}) {
|
|
|
50795
51468
|
parent.appendChild(child6);
|
|
50796
51469
|
return child6;
|
|
50797
51470
|
}
|
|
50798
|
-
function withDiagramDrawingRelationship(
|
|
50799
|
-
const doc = parseXml(
|
|
51471
|
+
function withDiagramDrawingRelationship(xml2, relationshipId) {
|
|
51472
|
+
const doc = parseXml(xml2);
|
|
50800
51473
|
const model = doc.documentElement;
|
|
50801
51474
|
let extension = descendants(model, "dataModelExt").find((node) => node.namespaceURI === DSP2);
|
|
50802
51475
|
if (!extension) {
|
|
@@ -51769,8 +52442,8 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51769
52442
|
const part = paths[name];
|
|
51770
52443
|
if (!part) return void 0;
|
|
51771
52444
|
try {
|
|
51772
|
-
const
|
|
51773
|
-
if (
|
|
52445
|
+
const xml2 = await host.readText(part);
|
|
52446
|
+
if (xml2 === void 0) {
|
|
51774
52447
|
issues.push({
|
|
51775
52448
|
code: "DIAGRAM_PART_MISSING",
|
|
51776
52449
|
message: `Part ${part} is not in the package.`,
|
|
@@ -51778,11 +52451,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51778
52451
|
});
|
|
51779
52452
|
return void 0;
|
|
51780
52453
|
}
|
|
51781
|
-
if (name === "layout") layoutSource.layoutXml =
|
|
51782
|
-
if (name === "data") layoutSource.dataXml =
|
|
51783
|
-
if (name === "colors") layoutSource.colorsXml =
|
|
51784
|
-
if (name === "quickStyle") layoutSource.quickStyleXml =
|
|
51785
|
-
return parse(
|
|
52454
|
+
if (name === "layout") layoutSource.layoutXml = xml2;
|
|
52455
|
+
if (name === "data") layoutSource.dataXml = xml2;
|
|
52456
|
+
if (name === "colors") layoutSource.colorsXml = xml2;
|
|
52457
|
+
if (name === "quickStyle") layoutSource.quickStyleXml = xml2;
|
|
52458
|
+
return parse(xml2, part);
|
|
51786
52459
|
} catch (error) {
|
|
51787
52460
|
issues.push({
|
|
51788
52461
|
code: "DIAGRAM_PART_UNREADABLE",
|
|
@@ -51792,11 +52465,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51792
52465
|
return void 0;
|
|
51793
52466
|
}
|
|
51794
52467
|
};
|
|
51795
|
-
const data = await read("data", (
|
|
52468
|
+
const data = await read("data", (xml2, part) => parseDiagramDataModel(xml2, part));
|
|
51796
52469
|
if (data) issues.push(...data.issues);
|
|
51797
|
-
const layout = await read("layout", (
|
|
51798
|
-
const colors = await read("colors", (
|
|
51799
|
-
const quickStyle = await read("quickStyle", (
|
|
52470
|
+
const layout = await read("layout", (xml2) => parseDiagramLayoutSummary(xml2));
|
|
52471
|
+
const colors = await read("colors", (xml2) => parseDiagramColors(xml2));
|
|
52472
|
+
const quickStyle = await read("quickStyle", (xml2) => parseDiagramQuickStyle(xml2));
|
|
51800
52473
|
let drawingResolution;
|
|
51801
52474
|
try {
|
|
51802
52475
|
drawingResolution = await resolveDiagramDrawingPart(
|
|
@@ -51815,11 +52488,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51815
52488
|
let generatedCache = false;
|
|
51816
52489
|
if (drawingResolution) {
|
|
51817
52490
|
paths.drawing = drawingResolution.path;
|
|
51818
|
-
drawing = await read("drawing", (
|
|
52491
|
+
drawing = await read("drawing", (xml2, part) => {
|
|
51819
52492
|
generatedCache = Boolean(
|
|
51820
|
-
data?.generatedCacheDigest && data.generatedCacheDigest === generatedDrawingDigest(
|
|
52493
|
+
data?.generatedCacheDigest && data.generatedCacheDigest === generatedDrawingDigest(xml2)
|
|
51821
52494
|
);
|
|
51822
|
-
return parseDiagramDrawing(
|
|
52495
|
+
return parseDiagramDrawing(xml2, part);
|
|
51823
52496
|
});
|
|
51824
52497
|
if (drawing) {
|
|
51825
52498
|
try {
|
|
@@ -61371,12 +62044,12 @@ function tokenize2(latex) {
|
|
|
61371
62044
|
function isGroupedByTag(tags) {
|
|
61372
62045
|
const seen = /* @__PURE__ */ new Set();
|
|
61373
62046
|
let previous = "";
|
|
61374
|
-
for (const
|
|
61375
|
-
if (
|
|
62047
|
+
for (const tag3 of tags) {
|
|
62048
|
+
if (tag3 !== previous && seen.has(tag3)) {
|
|
61376
62049
|
return false;
|
|
61377
62050
|
}
|
|
61378
|
-
seen.add(
|
|
61379
|
-
previous =
|
|
62051
|
+
seen.add(tag3);
|
|
62052
|
+
previous = tag3;
|
|
61380
62053
|
}
|
|
61381
62054
|
return true;
|
|
61382
62055
|
}
|
|
@@ -61968,11 +62641,11 @@ function parseGroupChr(ctx, chr, pos) {
|
|
|
61968
62641
|
}
|
|
61969
62642
|
return applyScripts(ctx, group2, args);
|
|
61970
62643
|
}
|
|
61971
|
-
function parseUnderOverset(ctx,
|
|
62644
|
+
function parseUnderOverset(ctx, tag3) {
|
|
61972
62645
|
const lim = ctx.parseSingleOrGroup();
|
|
61973
62646
|
const base = ctx.parseSingleOrGroup();
|
|
61974
62647
|
const limit = { "m:e": ctx.wrapE(base), "m:lim": ctx.wrapE(lim) };
|
|
61975
|
-
return
|
|
62648
|
+
return tag3 === "m:limLow" ? { "m:limLow": limit } : { "m:limUpp": limit };
|
|
61976
62649
|
}
|
|
61977
62650
|
function parseBoxed(ctx) {
|
|
61978
62651
|
return { "m:borderBox": { "m:e": ctx.wrapE(ctx.parseSingleOrGroup()) } };
|
|
@@ -62190,8 +62863,8 @@ function contentKeys(node) {
|
|
|
62190
62863
|
if (key.startsWith("@_") || key === "#text") {
|
|
62191
62864
|
return false;
|
|
62192
62865
|
}
|
|
62193
|
-
const
|
|
62194
|
-
return !
|
|
62866
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
62867
|
+
return !tag3.endsWith("Pr") && tag3 !== "m:t";
|
|
62195
62868
|
});
|
|
62196
62869
|
}
|
|
62197
62870
|
function soleChild(container) {
|
|
@@ -62261,12 +62934,12 @@ function collectText(node) {
|
|
|
62261
62934
|
if (key.startsWith("@_")) {
|
|
62262
62935
|
continue;
|
|
62263
62936
|
}
|
|
62264
|
-
const
|
|
62265
|
-
if (
|
|
62937
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
62938
|
+
if (tag3 === "m:t") {
|
|
62266
62939
|
out += escapeMathText(readRunText(record));
|
|
62267
|
-
} else if (
|
|
62940
|
+
} else if (tag3 === "#text") {
|
|
62268
62941
|
out += escapeMathText(String(value));
|
|
62269
|
-
} else if (!
|
|
62942
|
+
} else if (!tag3.endsWith("Pr")) {
|
|
62270
62943
|
out += collectText(value);
|
|
62271
62944
|
}
|
|
62272
62945
|
}
|
|
@@ -62359,9 +63032,9 @@ function childrenToLatex(node) {
|
|
|
62359
63032
|
}
|
|
62360
63033
|
const parts = [];
|
|
62361
63034
|
for (const key of contentKeys(node)) {
|
|
62362
|
-
const
|
|
63035
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
62363
63036
|
for (const item2 of ensureArr(node[key])) {
|
|
62364
|
-
parts.push(elementToLatex(
|
|
63037
|
+
parts.push(elementToLatex(tag3, item2));
|
|
62365
63038
|
}
|
|
62366
63039
|
}
|
|
62367
63040
|
return parts.join("");
|
|
@@ -62447,16 +63120,16 @@ function groupChrToLatex(node, label = "") {
|
|
|
62447
63120
|
const wrapped = `\\${top ? "overset" : "underset"}{${escapeMathText(chr)}}{${base}}`;
|
|
62448
63121
|
return label ? `\\${top ? "overset" : "underset"}{${label}}{${wrapped}}` : wrapped;
|
|
62449
63122
|
}
|
|
62450
|
-
function limitToLatex(node,
|
|
63123
|
+
function limitToLatex(node, tag3) {
|
|
62451
63124
|
const lim = arg(node, "m:lim");
|
|
62452
63125
|
const sole = soleChild(childNode(node, "m:e"));
|
|
62453
63126
|
if (sole?.tag === "m:groupChr") {
|
|
62454
63127
|
const top = attrVal(childNode(childNode(sole.node, "m:groupChrPr"), "m:pos")) === "top";
|
|
62455
|
-
if (top === (
|
|
63128
|
+
if (top === (tag3 === "m:limUpp")) {
|
|
62456
63129
|
return groupChrToLatex(sole.node, lim);
|
|
62457
63130
|
}
|
|
62458
63131
|
}
|
|
62459
|
-
return `\\${
|
|
63132
|
+
return `\\${tag3 === "m:limLow" ? "underset" : "overset"}{${lim}}{${arg(node, "m:e")}}`;
|
|
62460
63133
|
}
|
|
62461
63134
|
function phantomToLatex(node) {
|
|
62462
63135
|
const phantPr = childNode(node, "m:phantPr");
|
|
@@ -62469,8 +63142,8 @@ function phantomToLatex(node) {
|
|
|
62469
63142
|
}
|
|
62470
63143
|
return `\\phantom{${base}}`;
|
|
62471
63144
|
}
|
|
62472
|
-
function elementToLatex(
|
|
62473
|
-
switch (
|
|
63145
|
+
function elementToLatex(tag3, node) {
|
|
63146
|
+
switch (tag3) {
|
|
62474
63147
|
case "m:r":
|
|
62475
63148
|
return runToLatex(node);
|
|
62476
63149
|
case "m:f":
|
|
@@ -62501,7 +63174,7 @@ function elementToLatex(tag2, node) {
|
|
|
62501
63174
|
return `\\${attrVal(childNode(childNode(node, "m:barPr"), "m:pos")) === "bot" ? "underline" : "overline"}{${arg(node, "m:e")}}`;
|
|
62502
63175
|
case "m:limLow":
|
|
62503
63176
|
case "m:limUpp":
|
|
62504
|
-
return limitToLatex(node,
|
|
63177
|
+
return limitToLatex(node, tag3);
|
|
62505
63178
|
case "m:groupChr":
|
|
62506
63179
|
return groupChrToLatex(node);
|
|
62507
63180
|
case "m:borderBox":
|
|
@@ -62906,26 +63579,26 @@ var DELIM_END_MAP = {
|
|
|
62906
63579
|
// math/omml-to-xml.ts
|
|
62907
63580
|
var OMML_NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/math";
|
|
62908
63581
|
var escapeAttribute2 = (value) => escapeXml(value).replace(/"/g, """);
|
|
62909
|
-
function element3(
|
|
63582
|
+
function element3(tag3, value) {
|
|
62910
63583
|
if (value === void 0 || value === null) return "";
|
|
62911
|
-
if (Array.isArray(value)) return value.map((item2) => element3(
|
|
63584
|
+
if (Array.isArray(value)) return value.map((item2) => element3(tag3, item2)).join("");
|
|
62912
63585
|
if (typeof value !== "object") {
|
|
62913
63586
|
const text3 = String(value);
|
|
62914
|
-
const space3 =
|
|
62915
|
-
return `<${
|
|
63587
|
+
const space3 = tag3 === "m:t" && /^\s|\s$/.test(text3) ? ' xml:space="preserve"' : "";
|
|
63588
|
+
return `<${tag3}${space3}>${escapeXml(text3)}</${tag3}>`;
|
|
62916
63589
|
}
|
|
62917
63590
|
const node = value;
|
|
62918
63591
|
let attributes2 = "";
|
|
62919
63592
|
let content2 = "";
|
|
62920
63593
|
for (const key of Object.keys(node)) {
|
|
62921
63594
|
if (key.startsWith("@_")) {
|
|
62922
|
-
attributes2 += ` ${
|
|
63595
|
+
attributes2 += ` ${tag3 === "m:t" ? "" : "m:"}${key.slice(2)}="${escapeAttribute2(String(node[key]))}"`;
|
|
62923
63596
|
} else if (key === "#text") {
|
|
62924
63597
|
content2 += escapeXml(String(node[key]));
|
|
62925
63598
|
} else content2 += element3(stripXmlOrderSuffix(key), node[key]);
|
|
62926
63599
|
}
|
|
62927
|
-
if (
|
|
62928
|
-
return content2 ? `<${
|
|
63600
|
+
if (tag3 === "m:t" && /^\s|\s$/.test(content2) && !attributes2) attributes2 = ' xml:space="preserve"';
|
|
63601
|
+
return content2 ? `<${tag3}${attributes2}>${content2}</${tag3}>` : `<${tag3}${attributes2}/>`;
|
|
62929
63602
|
}
|
|
62930
63603
|
function ommlToXml(tree) {
|
|
62931
63604
|
const markup = Object.keys(tree).map((key) => element3(stripXmlOrderSuffix(key), tree[key])).join("");
|
|
@@ -63235,10 +63908,10 @@ function radical(node, style, ctx) {
|
|
|
63235
63908
|
if (degree) box.prims.push(...shifted(degree.prims, 0, top + height * 0.35 - degree.descent));
|
|
63236
63909
|
return box;
|
|
63237
63910
|
}
|
|
63238
|
-
function layoutStructure(
|
|
63911
|
+
function layoutStructure(tag3, node, style, ctx) {
|
|
63239
63912
|
const arg2 = (name, next = style) => ctx.layout(child5(node, name), next);
|
|
63240
63913
|
const small = () => ctx.script(style);
|
|
63241
|
-
switch (
|
|
63914
|
+
switch (tag3) {
|
|
63242
63915
|
case "m:f":
|
|
63243
63916
|
return fraction(node, style, ctx);
|
|
63244
63917
|
case "m:rad":
|
|
@@ -63406,20 +64079,20 @@ function layoutChildren(node, style) {
|
|
|
63406
64079
|
let last = "";
|
|
63407
64080
|
for (const key of Object.keys(node)) {
|
|
63408
64081
|
if (key.startsWith("@_") || key === "#text") continue;
|
|
63409
|
-
const
|
|
64082
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
63410
64083
|
for (const item2 of ensureArray(node[key])) {
|
|
63411
64084
|
const atStart = boxes.length === 0 || last !== "" && isUnaryContext(last);
|
|
63412
|
-
boxes.push(layoutElement(
|
|
63413
|
-
last =
|
|
64085
|
+
boxes.push(layoutElement(tag3, item2, style, atStart));
|
|
64086
|
+
last = tag3 === "m:r" ? lastCharOf(item2) : "";
|
|
63414
64087
|
}
|
|
63415
64088
|
}
|
|
63416
64089
|
return row(boxes);
|
|
63417
64090
|
}
|
|
63418
|
-
function layoutElement(
|
|
63419
|
-
if (
|
|
63420
|
-
if (
|
|
63421
|
-
if (/Pr$/.test(
|
|
63422
|
-
return layoutStructure(
|
|
64091
|
+
function layoutElement(tag3, node, style, atStart) {
|
|
64092
|
+
if (tag3 === "m:r") return layoutRun(node, style, atStart);
|
|
64093
|
+
if (tag3 === "m:oMath" || tag3 === "m:oMathPara") return layoutChildren(node, style);
|
|
64094
|
+
if (/Pr$/.test(tag3) || tag3 === "m:ctrlPr") return emptyBox();
|
|
64095
|
+
return layoutStructure(tag3, node, style, { layout: layoutChildren, script: scriptStyle });
|
|
63423
64096
|
}
|
|
63424
64097
|
function layoutEquation(root, sizePx, options2 = {}) {
|
|
63425
64098
|
const box = layoutChildren(root, { level: 0, size: sizePx, display: Boolean(options2.display) });
|
|
@@ -63458,8 +64131,8 @@ function ommlFromElement(element4) {
|
|
|
63458
64131
|
};
|
|
63459
64132
|
return visit(element4, 1);
|
|
63460
64133
|
}
|
|
63461
|
-
function parseOmml(
|
|
63462
|
-
return ommlFromElement(parseXml(
|
|
64134
|
+
function parseOmml(xml2) {
|
|
64135
|
+
return ommlFromElement(parseXml(xml2, { label: "OMML" }).documentElement);
|
|
63463
64136
|
}
|
|
63464
64137
|
|
|
63465
64138
|
// math/omml-svg.ts
|
|
@@ -63765,13 +64438,13 @@ function convertChildren(node) {
|
|
|
63765
64438
|
if (key.startsWith("@_")) {
|
|
63766
64439
|
continue;
|
|
63767
64440
|
}
|
|
63768
|
-
const
|
|
63769
|
-
if (
|
|
64441
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
64442
|
+
if (tag3 === "m:oMathPara") {
|
|
63770
64443
|
continue;
|
|
63771
64444
|
}
|
|
63772
64445
|
const items = ensureArray(node[key]);
|
|
63773
64446
|
for (const item2 of items) {
|
|
63774
|
-
const result = convertElement(
|
|
64447
|
+
const result = convertElement(tag3, item2);
|
|
63775
64448
|
if (result) {
|
|
63776
64449
|
parts.push(result);
|
|
63777
64450
|
}
|
|
@@ -63779,8 +64452,8 @@ function convertChildren(node) {
|
|
|
63779
64452
|
}
|
|
63780
64453
|
return parts.join("");
|
|
63781
64454
|
}
|
|
63782
|
-
function convertElement(
|
|
63783
|
-
switch (
|
|
64455
|
+
function convertElement(tag3, node) {
|
|
64456
|
+
switch (tag3) {
|
|
63784
64457
|
case "m:r":
|
|
63785
64458
|
return convertRun(node);
|
|
63786
64459
|
case "m:f":
|