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.cjs
CHANGED
|
@@ -2601,6 +2601,7 @@ __export(xml_exports, {
|
|
|
2601
2601
|
isElement: () => isElement,
|
|
2602
2602
|
liteChildElements: () => liteChildElements,
|
|
2603
2603
|
makeNS: () => makeNS,
|
|
2604
|
+
mergeXmlThreeWay: () => mergeXmlThreeWay,
|
|
2604
2605
|
named: () => named,
|
|
2605
2606
|
parseLiteFragment: () => parseLiteFragment,
|
|
2606
2607
|
parseXml: () => parseXml,
|
|
@@ -2701,28 +2702,28 @@ var MARKUP_SKIPS = [
|
|
|
2701
2702
|
["<![CDATA[", "]]>"],
|
|
2702
2703
|
["<?", "?>"]
|
|
2703
2704
|
];
|
|
2704
|
-
function checkXmlLimits(
|
|
2705
|
+
function checkXmlLimits(xml2, label, limits = {}) {
|
|
2705
2706
|
const maxDepth2 = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
2706
2707
|
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
2707
2708
|
let depth = 0;
|
|
2708
2709
|
let nodes = 0;
|
|
2709
|
-
let at2 =
|
|
2710
|
+
let at2 = xml2.indexOf("<");
|
|
2710
2711
|
while (at2 !== -1) {
|
|
2711
|
-
const skip = MARKUP_SKIPS.find(([open]) =>
|
|
2712
|
+
const skip = MARKUP_SKIPS.find(([open]) => xml2.startsWith(open, at2));
|
|
2712
2713
|
if (skip) {
|
|
2713
|
-
const end =
|
|
2714
|
+
const end = xml2.indexOf(skip[1], at2 + skip[0].length);
|
|
2714
2715
|
if (end === -1) return;
|
|
2715
|
-
at2 =
|
|
2716
|
+
at2 = xml2.indexOf("<", end + skip[1].length);
|
|
2716
2717
|
continue;
|
|
2717
2718
|
}
|
|
2718
2719
|
TAG_RE.lastIndex = at2;
|
|
2719
|
-
const match = TAG_RE.exec(
|
|
2720
|
+
const match = TAG_RE.exec(xml2);
|
|
2720
2721
|
if (!match) {
|
|
2721
|
-
at2 =
|
|
2722
|
+
at2 = xml2.indexOf("<", at2 + 1);
|
|
2722
2723
|
continue;
|
|
2723
2724
|
}
|
|
2724
2725
|
const [, closing, , selfClosing] = match;
|
|
2725
|
-
at2 =
|
|
2726
|
+
at2 = xml2.indexOf("<", at2 + match[0].length);
|
|
2726
2727
|
if (closing) {
|
|
2727
2728
|
depth--;
|
|
2728
2729
|
continue;
|
|
@@ -2744,11 +2745,11 @@ function checkXmlLimits(xml, label, limits = {}) {
|
|
|
2744
2745
|
}
|
|
2745
2746
|
var CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
|
|
2746
2747
|
var crlfDeclarations = /* @__PURE__ */ new WeakSet();
|
|
2747
|
-
function parseXml(
|
|
2748
|
+
function parseXml(xml2, options2 = {}) {
|
|
2748
2749
|
const label = options2.label ?? "OOXML";
|
|
2749
|
-
if (/<!DOCTYPE|<!ENTITY/i.test(
|
|
2750
|
+
if (/<!DOCTYPE|<!ENTITY/i.test(xml2))
|
|
2750
2751
|
throw new Error(`${label} XML with DTD or entity declarations is not supported`);
|
|
2751
|
-
checkXmlLimits(
|
|
2752
|
+
checkXmlLimits(xml2, label, options2.limits);
|
|
2752
2753
|
let parseError = "";
|
|
2753
2754
|
let parsed;
|
|
2754
2755
|
try {
|
|
@@ -2756,7 +2757,7 @@ function parseXml(xml, options2 = {}) {
|
|
|
2756
2757
|
onError: (level4, message) => {
|
|
2757
2758
|
if (level4 !== "warning" || options2.warningsAsErrors) parseError = message;
|
|
2758
2759
|
}
|
|
2759
|
-
}).parseFromString(
|
|
2760
|
+
}).parseFromString(xml2, "application/xml");
|
|
2760
2761
|
} catch (error) {
|
|
2761
2762
|
throw new Error(
|
|
2762
2763
|
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -2765,12 +2766,12 @@ function parseXml(xml, options2 = {}) {
|
|
|
2765
2766
|
}
|
|
2766
2767
|
if (parseError || !parsed.documentElement)
|
|
2767
2768
|
throw new Error(`Invalid ${label} XML: ${parseError || "missing root element"}`);
|
|
2768
|
-
if (CRLF_DECLARATION.test(
|
|
2769
|
+
if (CRLF_DECLARATION.test(xml2)) crlfDeclarations.add(parsed);
|
|
2769
2770
|
return parsed;
|
|
2770
2771
|
}
|
|
2771
2772
|
var buildXml = (node) => {
|
|
2772
|
-
const
|
|
2773
|
-
return crlfDeclarations.has(node) ?
|
|
2773
|
+
const xml2 = new xmldom.XMLSerializer().serializeToString(node);
|
|
2774
|
+
return crlfDeclarations.has(node) ? xml2.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml2;
|
|
2774
2775
|
};
|
|
2775
2776
|
var isElement = (node) => node.nodeType === 1;
|
|
2776
2777
|
var elements = (parent) => Array.from(parent.childNodes).filter(isElement);
|
|
@@ -2787,6 +2788,373 @@ function attr(element4, local, ns, prefix) {
|
|
|
2787
2788
|
}
|
|
2788
2789
|
var relAttr = (element4, local) => attr(element4, local, NS.r, "r");
|
|
2789
2790
|
|
|
2791
|
+
// text/text-diff.ts
|
|
2792
|
+
var isLowSurrogate = (text3, at2) => {
|
|
2793
|
+
const code = text3.charCodeAt(at2);
|
|
2794
|
+
return code >= 56320 && code <= 57343;
|
|
2795
|
+
};
|
|
2796
|
+
function shortestEdit(n2, m, same5, maxEdits) {
|
|
2797
|
+
const max = Math.min(n2 + m, maxEdits);
|
|
2798
|
+
const offset = max + 1;
|
|
2799
|
+
const v = new Int32Array(2 * max + 3);
|
|
2800
|
+
const trace = [];
|
|
2801
|
+
for (let d = 0; d <= max; d++) {
|
|
2802
|
+
for (let k = -d; k <= d; k += 2) {
|
|
2803
|
+
const down = k === -d || k !== d && v[offset + k - 1] < v[offset + k + 1];
|
|
2804
|
+
let x = down ? v[offset + k + 1] : v[offset + k - 1] + 1;
|
|
2805
|
+
let y = x - k;
|
|
2806
|
+
while (x < n2 && y < m && same5(x, y)) {
|
|
2807
|
+
x++;
|
|
2808
|
+
y++;
|
|
2809
|
+
}
|
|
2810
|
+
v[offset + k] = x;
|
|
2811
|
+
if (x >= n2 && y >= m) return backtrack(trace, n2, m, d);
|
|
2812
|
+
}
|
|
2813
|
+
trace.push(v.slice(offset - d, offset + d + 1));
|
|
2814
|
+
}
|
|
2815
|
+
return void 0;
|
|
2816
|
+
}
|
|
2817
|
+
function backtrack(trace, n2, m, d) {
|
|
2818
|
+
const edits = [];
|
|
2819
|
+
let x = n2;
|
|
2820
|
+
let y = m;
|
|
2821
|
+
for (let step = d; step > 0; step--) {
|
|
2822
|
+
const previous = trace[step - 1];
|
|
2823
|
+
const at2 = (k2) => previous[k2 + step - 1];
|
|
2824
|
+
const k = x - y;
|
|
2825
|
+
const down = k === -step || k !== step && at2(k - 1) < at2(k + 1);
|
|
2826
|
+
const before = down ? k + 1 : k - 1;
|
|
2827
|
+
const startX = at2(before);
|
|
2828
|
+
const startY = startX - before;
|
|
2829
|
+
edits.push(down ? [startX, startY, true] : [startX, startY, false]);
|
|
2830
|
+
x = startX;
|
|
2831
|
+
y = startY;
|
|
2832
|
+
}
|
|
2833
|
+
return edits.reverse();
|
|
2834
|
+
}
|
|
2835
|
+
function changesOf(edits) {
|
|
2836
|
+
const changes = [];
|
|
2837
|
+
for (const [x, y, inserts] of edits) {
|
|
2838
|
+
const last = changes.at(-1);
|
|
2839
|
+
if (last && last.fromEnd === x && last.toEnd === y) {
|
|
2840
|
+
if (inserts) last.toEnd++;
|
|
2841
|
+
else last.fromEnd++;
|
|
2842
|
+
} else
|
|
2843
|
+
changes.push({
|
|
2844
|
+
fromStart: x,
|
|
2845
|
+
fromEnd: inserts ? x : x + 1,
|
|
2846
|
+
toStart: y,
|
|
2847
|
+
toEnd: inserts ? y + 1 : y
|
|
2848
|
+
});
|
|
2849
|
+
}
|
|
2850
|
+
return changes;
|
|
2851
|
+
}
|
|
2852
|
+
function characterChanges(a2, b, maxEdits) {
|
|
2853
|
+
const edits = shortestEdit(
|
|
2854
|
+
a2.length,
|
|
2855
|
+
b.length,
|
|
2856
|
+
(x, y) => a2.charCodeAt(x) === b.charCodeAt(y),
|
|
2857
|
+
maxEdits
|
|
2858
|
+
);
|
|
2859
|
+
return edits && changesOf(edits);
|
|
2860
|
+
}
|
|
2861
|
+
var TOKEN = /[\p{L}\p{N}\p{M}]+|\s+|[\s\S]/gu;
|
|
2862
|
+
function tokensOf(text3, ids) {
|
|
2863
|
+
const tokens = [];
|
|
2864
|
+
const starts = [];
|
|
2865
|
+
for (const match of text3.matchAll(TOKEN)) {
|
|
2866
|
+
let id = ids.get(match[0]);
|
|
2867
|
+
if (id === void 0) ids.set(match[0], id = ids.size);
|
|
2868
|
+
tokens.push(id);
|
|
2869
|
+
starts.push(match.index);
|
|
2870
|
+
}
|
|
2871
|
+
starts.push(text3.length);
|
|
2872
|
+
return { tokens, starts };
|
|
2873
|
+
}
|
|
2874
|
+
function tokenChanges(a2, b, maxEdits) {
|
|
2875
|
+
const ids = /* @__PURE__ */ new Map();
|
|
2876
|
+
const from = tokensOf(a2, ids);
|
|
2877
|
+
const to = tokensOf(b, ids);
|
|
2878
|
+
const edits = shortestEdit(
|
|
2879
|
+
from.tokens.length,
|
|
2880
|
+
to.tokens.length,
|
|
2881
|
+
(x, y) => from.tokens[x] === to.tokens[y],
|
|
2882
|
+
maxEdits
|
|
2883
|
+
);
|
|
2884
|
+
if (!edits) return void 0;
|
|
2885
|
+
let budget = maxEdits;
|
|
2886
|
+
return changesOf(edits).flatMap((stretch) => {
|
|
2887
|
+
const change = {
|
|
2888
|
+
fromStart: from.starts[stretch.fromStart],
|
|
2889
|
+
fromEnd: from.starts[stretch.fromEnd],
|
|
2890
|
+
toStart: to.starts[stretch.toStart],
|
|
2891
|
+
toEnd: to.starts[stretch.toEnd]
|
|
2892
|
+
};
|
|
2893
|
+
const inner = change.fromEnd > change.fromStart && change.toEnd > change.toStart ? characterChanges(
|
|
2894
|
+
a2.slice(change.fromStart, change.fromEnd),
|
|
2895
|
+
b.slice(change.toStart, change.toEnd),
|
|
2896
|
+
budget
|
|
2897
|
+
) : void 0;
|
|
2898
|
+
if (!inner) return [change];
|
|
2899
|
+
for (const found of inner)
|
|
2900
|
+
budget -= found.fromEnd - found.fromStart + found.toEnd - found.toStart;
|
|
2901
|
+
return inner.map((found) => ({
|
|
2902
|
+
fromStart: found.fromStart + change.fromStart,
|
|
2903
|
+
fromEnd: found.fromEnd + change.fromStart,
|
|
2904
|
+
toStart: found.toStart + change.toStart,
|
|
2905
|
+
toEnd: found.toEnd + change.toStart
|
|
2906
|
+
}));
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
function diffText(from, to, maxEdits = 500) {
|
|
2910
|
+
let start = 0;
|
|
2911
|
+
while (start < from.length && start < to.length && from.charCodeAt(start) === to.charCodeAt(start))
|
|
2912
|
+
start++;
|
|
2913
|
+
let end = 0;
|
|
2914
|
+
while (end < from.length - start && end < to.length - start && from.charCodeAt(from.length - 1 - end) === to.charCodeAt(to.length - 1 - end))
|
|
2915
|
+
end++;
|
|
2916
|
+
const a2 = from.slice(start, from.length - end);
|
|
2917
|
+
const b = to.slice(start, to.length - end);
|
|
2918
|
+
if (!a2.length && !b.length) return [];
|
|
2919
|
+
const found = a2.length && b.length ? characterChanges(a2, b, maxEdits) ?? tokenChanges(a2, b, maxEdits) : void 0;
|
|
2920
|
+
const changes = found ?? [{ fromStart: 0, fromEnd: a2.length, toStart: 0, toEnd: b.length }];
|
|
2921
|
+
const result = [];
|
|
2922
|
+
for (const change of changes) {
|
|
2923
|
+
const placed2 = {
|
|
2924
|
+
fromStart: change.fromStart + start,
|
|
2925
|
+
fromEnd: change.fromEnd + start,
|
|
2926
|
+
toStart: change.toStart + start,
|
|
2927
|
+
toEnd: change.toEnd + start
|
|
2928
|
+
};
|
|
2929
|
+
if (placed2.fromStart > 0 && placed2.toStart > 0 && (isLowSurrogate(from, placed2.fromStart) || isLowSurrogate(to, placed2.toStart))) {
|
|
2930
|
+
placed2.fromStart--;
|
|
2931
|
+
placed2.toStart--;
|
|
2932
|
+
}
|
|
2933
|
+
if (isLowSurrogate(from, placed2.fromEnd) || isLowSurrogate(to, placed2.toEnd)) {
|
|
2934
|
+
placed2.fromEnd++;
|
|
2935
|
+
placed2.toEnd++;
|
|
2936
|
+
}
|
|
2937
|
+
const last = result.at(-1);
|
|
2938
|
+
if (last && placed2.fromStart <= last.fromEnd) {
|
|
2939
|
+
last.fromEnd = Math.max(last.fromEnd, placed2.fromEnd);
|
|
2940
|
+
last.toEnd = Math.max(last.toEnd, placed2.toEnd);
|
|
2941
|
+
} else result.push(placed2);
|
|
2942
|
+
}
|
|
2943
|
+
return result;
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
// text/merge-three-way.ts
|
|
2947
|
+
function mergeTextThreeWay(base, local, remote) {
|
|
2948
|
+
if (local === remote || base === remote) return { status: "merged", text: local };
|
|
2949
|
+
if (base === local) return { status: "merged", text: remote };
|
|
2950
|
+
if (Math.max(base.length, local.length, remote.length) > 1e6)
|
|
2951
|
+
return { status: "unresolved" };
|
|
2952
|
+
const changes = (value) => diffText(base, value).map((change) => ({
|
|
2953
|
+
start: change.fromStart,
|
|
2954
|
+
end: change.fromEnd,
|
|
2955
|
+
text: value.slice(change.toStart, change.toEnd)
|
|
2956
|
+
}));
|
|
2957
|
+
const edits = changes(local);
|
|
2958
|
+
for (const next of changes(remote)) {
|
|
2959
|
+
if (edits.some(
|
|
2960
|
+
(edit) => edit.start === next.start && edit.end === next.end && edit.text === next.text
|
|
2961
|
+
))
|
|
2962
|
+
continue;
|
|
2963
|
+
if (edits.some((edit) => {
|
|
2964
|
+
if (edit.start === edit.end && next.start === next.end) return false;
|
|
2965
|
+
if (edit.start === edit.end) return edit.start > next.start && edit.start < next.end;
|
|
2966
|
+
if (next.start === next.end) return next.start > edit.start && next.start < edit.end;
|
|
2967
|
+
return edit.start < next.end && next.start < edit.end;
|
|
2968
|
+
}))
|
|
2969
|
+
return { status: "unresolved" };
|
|
2970
|
+
edits.push(next);
|
|
2971
|
+
}
|
|
2972
|
+
edits.sort(
|
|
2973
|
+
(a2, b) => a2.start - b.start || a2.end - b.end || (a2.text < b.text ? -1 : a2.text > b.text ? 1 : 0)
|
|
2974
|
+
);
|
|
2975
|
+
let text3 = "", cursor = 0;
|
|
2976
|
+
for (const edit of edits) {
|
|
2977
|
+
text3 += base.slice(cursor, edit.start) + edit.text;
|
|
2978
|
+
cursor = edit.end;
|
|
2979
|
+
}
|
|
2980
|
+
return { status: "merged", text: text3 + base.slice(cursor) };
|
|
2981
|
+
}
|
|
2982
|
+
|
|
2983
|
+
// xml/merge-three-way.ts
|
|
2984
|
+
var tag = (node) => `${node.namespaceURI ?? ""}|${node.localName ?? node.tagName}`;
|
|
2985
|
+
var xml = (node) => node ? buildXml(node) : void 0;
|
|
2986
|
+
function childrenByKey(parent, options2, repeated) {
|
|
2987
|
+
const result = /* @__PURE__ */ new Map();
|
|
2988
|
+
const counts = /* @__PURE__ */ new Map();
|
|
2989
|
+
for (const child6 of elements(parent)) {
|
|
2990
|
+
const name = tag(child6), explicit = options2.keyElement?.(child6, parent);
|
|
2991
|
+
const index = counts.get(name) ?? 0;
|
|
2992
|
+
counts.set(name, index + 1);
|
|
2993
|
+
if (!explicit && repeated.has(name) && !options2.allowPositional?.(parent))
|
|
2994
|
+
throw new Error("Ambiguous repeated elements");
|
|
2995
|
+
const key = explicit ? `${name}@${explicit}` : `${name}#${index}`;
|
|
2996
|
+
if (result.has(key)) throw new Error("Duplicate element identity");
|
|
2997
|
+
result.set(key, child6);
|
|
2998
|
+
}
|
|
2999
|
+
return result;
|
|
3000
|
+
}
|
|
3001
|
+
function orderKeys(base, local, remote) {
|
|
3002
|
+
const same5 = (a2, b) => a2.length === b.length && a2.every((key, index) => key === b[index]);
|
|
3003
|
+
if (same5(base, local)) return [...remote];
|
|
3004
|
+
if (same5(base, remote) || same5(local, remote)) return [...local];
|
|
3005
|
+
const keys = [.../* @__PURE__ */ new Set([...remote, ...local])].sort();
|
|
3006
|
+
const edges = new Map(keys.map((key) => [key, /* @__PURE__ */ new Set()]));
|
|
3007
|
+
const degree = new Map(keys.map((key) => [key, 0]));
|
|
3008
|
+
for (const sequence of [local, remote])
|
|
3009
|
+
for (let i2 = 1; i2 < sequence.length; i2++) {
|
|
3010
|
+
const previous = sequence[i2 - 1], next = sequence[i2];
|
|
3011
|
+
if (!edges.get(previous).has(next)) {
|
|
3012
|
+
edges.get(previous).add(next);
|
|
3013
|
+
degree.set(next, degree.get(next) + 1);
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
const out = [];
|
|
3017
|
+
const ready = keys.filter((key) => degree.get(key) === 0);
|
|
3018
|
+
while (ready.length) {
|
|
3019
|
+
const next = ready.sort().shift();
|
|
3020
|
+
out.push(next);
|
|
3021
|
+
for (const key of edges.get(next)) {
|
|
3022
|
+
degree.set(key, degree.get(key) - 1);
|
|
3023
|
+
if (degree.get(key) === 0) ready.push(key);
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
return out.length === keys.length ? out : void 0;
|
|
3027
|
+
}
|
|
3028
|
+
function mergeXmlThreeWay(baseXml, localXml, remoteXml, options2 = {}) {
|
|
3029
|
+
if (localXml === remoteXml || baseXml === remoteXml) return { status: "merged", xml: localXml };
|
|
3030
|
+
if (baseXml === localXml) return { status: "merged", xml: remoteXml };
|
|
3031
|
+
const issues = [];
|
|
3032
|
+
try {
|
|
3033
|
+
let merge2 = function(b, l, r, path3) {
|
|
3034
|
+
const bx = xml(b), lx = xml(l), rx = xml(r);
|
|
3035
|
+
if (lx === rx || bx === rx) return l ? copy(l) : void 0;
|
|
3036
|
+
if (bx === lx) return r ? copy(r) : void 0;
|
|
3037
|
+
if (!b && l && r && tag(l) === tag(r) && !elements(l).length && !elements(r).length) {
|
|
3038
|
+
const resolved = options2.resolveText?.(r, l, r);
|
|
3039
|
+
if (resolved !== void 0) {
|
|
3040
|
+
const node = copy(r);
|
|
3041
|
+
node.textContent = resolved;
|
|
3042
|
+
return node;
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
if (!b || !l || !r || tag(b) !== tag(l) || tag(b) !== tag(r)) {
|
|
3046
|
+
issues.push(`${path3}: overlapping structural changes`);
|
|
3047
|
+
return void 0;
|
|
3048
|
+
}
|
|
3049
|
+
const out = remote.createElementNS(r.namespaceURI, r.tagName);
|
|
3050
|
+
const attrs2 = (node) => new Map(
|
|
3051
|
+
Array.from(node.attributes).map((a2) => [
|
|
3052
|
+
`${a2.namespaceURI ?? ""}|${a2.localName ?? a2.name}`,
|
|
3053
|
+
a2
|
|
3054
|
+
])
|
|
3055
|
+
);
|
|
3056
|
+
const ba = attrs2(b), la = attrs2(l), ra = attrs2(r);
|
|
3057
|
+
for (const key of /* @__PURE__ */ new Set([...ba.keys(), ...la.keys(), ...ra.keys()])) {
|
|
3058
|
+
const old = ba.get(key)?.value, left = la.get(key)?.value, right = ra.get(key)?.value;
|
|
3059
|
+
const value = left === right || right === old ? left : left === old ? right : void 0;
|
|
3060
|
+
if (left !== right && left !== old && right !== old) {
|
|
3061
|
+
issues.push(`${path3}: overlapping attribute ${key}`);
|
|
3062
|
+
continue;
|
|
3063
|
+
}
|
|
3064
|
+
const source2 = ra.get(key) ?? la.get(key) ?? ba.get(key);
|
|
3065
|
+
if (value !== void 0) out.setAttributeNS(source2.namespaceURI, source2.name, value);
|
|
3066
|
+
}
|
|
3067
|
+
const lists = [b, l, r].map(elements);
|
|
3068
|
+
if (lists.every((list2) => list2.length === 0)) {
|
|
3069
|
+
if ([b, l, r].some(
|
|
3070
|
+
(node) => Array.from(node.childNodes).some(
|
|
3071
|
+
(child6) => child6.nodeType !== 3 && child6.nodeType !== 4
|
|
3072
|
+
)
|
|
3073
|
+
)) {
|
|
3074
|
+
issues.push(`${path3}: non-text leaf content requires explicit preservation`);
|
|
3075
|
+
return void 0;
|
|
3076
|
+
}
|
|
3077
|
+
const texts = [b, l, r].map((node) => node.textContent ?? "");
|
|
3078
|
+
const override = options2.resolveText?.(b, l, r);
|
|
3079
|
+
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" };
|
|
3080
|
+
if (value.status !== "merged") issues.push(`${path3}: overlapping text changes`);
|
|
3081
|
+
else if (value.text) out.appendChild(remote.createTextNode(value.text));
|
|
3082
|
+
return out;
|
|
3083
|
+
}
|
|
3084
|
+
if ([b, l, r].some(
|
|
3085
|
+
(node) => Array.from(node.childNodes).some(
|
|
3086
|
+
(child6) => child6.nodeType !== 1 && (child6.nodeType !== 3 || Boolean(child6.textContent?.trim()))
|
|
3087
|
+
)
|
|
3088
|
+
)) {
|
|
3089
|
+
issues.push(`${path3}: mixed content cannot be matched safely`);
|
|
3090
|
+
return void 0;
|
|
3091
|
+
}
|
|
3092
|
+
const repeated = /* @__PURE__ */ new Set();
|
|
3093
|
+
const groups = lists.map((list2) => {
|
|
3094
|
+
const grouped2 = /* @__PURE__ */ new Map();
|
|
3095
|
+
for (const child6 of list2) {
|
|
3096
|
+
const name = tag(child6), group2 = grouped2.get(name) ?? [];
|
|
3097
|
+
group2.push(child6);
|
|
3098
|
+
grouped2.set(name, group2);
|
|
3099
|
+
if (group2.length > 1) repeated.add(name);
|
|
3100
|
+
}
|
|
3101
|
+
return grouped2;
|
|
3102
|
+
});
|
|
3103
|
+
for (const name of repeated) {
|
|
3104
|
+
const rows2 = groups.map((group2) => group2.get(name) ?? []);
|
|
3105
|
+
if (rows2.some((row2) => row2.some((child6) => options2.keyElement?.(child6, b) !== void 0)))
|
|
3106
|
+
continue;
|
|
3107
|
+
if (rows2.some((row2) => row2.length !== rows2[0].length)) {
|
|
3108
|
+
issues.push(`${path3}: unkeyed structural changes`);
|
|
3109
|
+
return void 0;
|
|
3110
|
+
}
|
|
3111
|
+
const before = rows2[0].map((child6) => buildXml(child6));
|
|
3112
|
+
const known = new Set(before);
|
|
3113
|
+
for (const row2 of rows2.slice(1))
|
|
3114
|
+
if (row2.some((child6, i2) => {
|
|
3115
|
+
const value = buildXml(child6);
|
|
3116
|
+
return before[i2] !== value && known.has(value);
|
|
3117
|
+
})) {
|
|
3118
|
+
issues.push(`${path3}: reordered unkeyed elements`);
|
|
3119
|
+
return void 0;
|
|
3120
|
+
}
|
|
3121
|
+
}
|
|
3122
|
+
let maps;
|
|
3123
|
+
try {
|
|
3124
|
+
maps = [b, l, r].map((parent) => childrenByKey(parent, options2, repeated));
|
|
3125
|
+
} catch {
|
|
3126
|
+
issues.push(`${path3}: ambiguous element identities`);
|
|
3127
|
+
return void 0;
|
|
3128
|
+
}
|
|
3129
|
+
const [bm, lm, rm] = maps;
|
|
3130
|
+
const merged = /* @__PURE__ */ new Map();
|
|
3131
|
+
for (const key of /* @__PURE__ */ new Set([...bm.keys(), ...lm.keys(), ...rm.keys()])) {
|
|
3132
|
+
const node = merge2(bm.get(key), lm.get(key), rm.get(key), `${path3}/${key}`);
|
|
3133
|
+
if (node) merged.set(key, node);
|
|
3134
|
+
}
|
|
3135
|
+
const surviving = (map) => [...map.keys()].filter((key) => merged.has(key));
|
|
3136
|
+
const order = orderKeys(surviving(bm), surviving(lm), surviving(rm));
|
|
3137
|
+
if (!order) {
|
|
3138
|
+
issues.push(`${path3}: incompatible element order`);
|
|
3139
|
+
return void 0;
|
|
3140
|
+
}
|
|
3141
|
+
for (const key of order) out.appendChild(merged.get(key));
|
|
3142
|
+
return out;
|
|
3143
|
+
};
|
|
3144
|
+
var merge = merge2;
|
|
3145
|
+
const base = parseXml(baseXml, { warningsAsErrors: true });
|
|
3146
|
+
const local = parseXml(localXml, { warningsAsErrors: true });
|
|
3147
|
+
const remote = parseXml(remoteXml, { warningsAsErrors: true });
|
|
3148
|
+
const copy = (node) => remote.importNode(node, true);
|
|
3149
|
+
const root = merge2(base.documentElement, local.documentElement, remote.documentElement, "root");
|
|
3150
|
+
if (!root || issues.length) return { status: "unresolved", issues };
|
|
3151
|
+
remote.replaceChild(root, remote.documentElement);
|
|
3152
|
+
return { status: "merged", xml: buildXml(remote) };
|
|
3153
|
+
} catch {
|
|
3154
|
+
return { status: "unresolved", issues: ["Invalid or unsupported XML input"] };
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
|
|
2790
3158
|
// xml/lite.ts
|
|
2791
3159
|
var LiteElement = class {
|
|
2792
3160
|
constructor(tagName, localName2, namespaceURI) {
|
|
@@ -2854,22 +3222,22 @@ function decode(text3) {
|
|
|
2854
3222
|
return ampersands === found ? out : void 0;
|
|
2855
3223
|
}
|
|
2856
3224
|
var isSpace = (code) => code === 32 || code === 9 || code === 10 || code === 13;
|
|
2857
|
-
var hasLineEnds = (
|
|
3225
|
+
var hasLineEnds = (xml2) => xml2.includes("\r") || xml2.includes("\x85") || xml2.includes("\u2028") || xml2.includes("\u2029");
|
|
2858
3226
|
var LiteDeclinedError = class extends Error {
|
|
2859
3227
|
constructor() {
|
|
2860
3228
|
super("The XML fragment needs the full parser");
|
|
2861
3229
|
this.name = "LiteDeclinedError";
|
|
2862
3230
|
}
|
|
2863
3231
|
};
|
|
2864
|
-
function parseLiteFragment(
|
|
2865
|
-
const nodes = topLevelNodes(
|
|
3232
|
+
function parseLiteFragment(xml2, container, namespaces) {
|
|
3233
|
+
const nodes = topLevelNodes(xml2, namespaces);
|
|
2866
3234
|
for (let next = nodes.next(); ; next = nodes.next()) {
|
|
2867
3235
|
if (next.done) return next.value ? container : void 0;
|
|
2868
3236
|
container.childNodes.push(next.value);
|
|
2869
3237
|
}
|
|
2870
3238
|
}
|
|
2871
|
-
function* liteChildElements(
|
|
2872
|
-
const nodes = topLevelNodes(
|
|
3239
|
+
function* liteChildElements(xml2, namespaces) {
|
|
3240
|
+
const nodes = topLevelNodes(xml2, namespaces);
|
|
2873
3241
|
for (let next = nodes.next(); ; next = nodes.next()) {
|
|
2874
3242
|
if (next.done) {
|
|
2875
3243
|
if (next.value) return;
|
|
@@ -2878,8 +3246,8 @@ function* liteChildElements(xml, namespaces) {
|
|
|
2878
3246
|
if (typeof next.value !== "string") yield next.value.asElement();
|
|
2879
3247
|
}
|
|
2880
3248
|
}
|
|
2881
|
-
function* topLevelNodes(
|
|
2882
|
-
const source2 = hasLineEnds(
|
|
3249
|
+
function* topLevelNodes(xml2, namespaces) {
|
|
3250
|
+
const source2 = hasLineEnds(xml2) ? xml2.replace(/\r[\n\u0085]/g, "\n").replace(/[\r\u0085\u2028\u2029]/g, "\n") : xml2;
|
|
2883
3251
|
const root = new LiteElement("", "", null);
|
|
2884
3252
|
const level4 = root.childNodes;
|
|
2885
3253
|
const stack = [root];
|
|
@@ -3367,8 +3735,8 @@ function chartPaletteColors(palette, n2, scheme2) {
|
|
|
3367
3735
|
var CHART_COLOR_STYLE_NS = "http://schemas.microsoft.com/office/drawing/2012/chartStyle";
|
|
3368
3736
|
var CHART_COLOR_STYLE_REL = "http://schemas.microsoft.com/office/2011/relationships/chartColorStyle";
|
|
3369
3737
|
var CHART_COLOR_STYLE_CONTENT_TYPE = "application/vnd.ms-office.chartcolorstyle+xml";
|
|
3370
|
-
function chartColorStyleId(
|
|
3371
|
-
const root = parseXml(
|
|
3738
|
+
function chartColorStyleId(xml2) {
|
|
3739
|
+
const root = parseXml(xml2).documentElement;
|
|
3372
3740
|
if (root.localName !== "colorStyle" || root.namespaceURI !== CHART_COLOR_STYLE_NS)
|
|
3373
3741
|
return void 0;
|
|
3374
3742
|
const value = root.getAttribute("id");
|
|
@@ -4275,11 +4643,11 @@ function entry(node) {
|
|
|
4275
4643
|
}
|
|
4276
4644
|
return out;
|
|
4277
4645
|
}
|
|
4278
|
-
function readChartStyle(
|
|
4279
|
-
const root = parseXml(
|
|
4646
|
+
function readChartStyle(xml2) {
|
|
4647
|
+
const root = parseXml(xml2, { label: "Office chart style" }).documentElement;
|
|
4280
4648
|
if (root.namespaceURI !== CHART_COLOR_STYLE_NS || root.localName !== "chartStyle")
|
|
4281
4649
|
return void 0;
|
|
4282
|
-
const out = { entries: {}, sourceXml:
|
|
4650
|
+
const out = { entries: {}, sourceXml: xml2 };
|
|
4283
4651
|
const id = root.getAttribute("id");
|
|
4284
4652
|
if (id && /^\d+$/.test(id) && Number.isSafeInteger(Number(id))) out.id = Number(id);
|
|
4285
4653
|
out.entries = Object.fromEntries(
|
|
@@ -4407,22 +4775,22 @@ function readChartManualLayoutValues(value) {
|
|
|
4407
4775
|
};
|
|
4408
4776
|
const target = enumeration("layoutTarget", ["inner", "outer"]);
|
|
4409
4777
|
if (target) result.layoutTarget = target;
|
|
4410
|
-
for (const [
|
|
4778
|
+
for (const [xml2, key] of [
|
|
4411
4779
|
["xMode", "xMode"],
|
|
4412
4780
|
["yMode", "yMode"],
|
|
4413
4781
|
["wMode", "widthMode"],
|
|
4414
4782
|
["hMode", "heightMode"]
|
|
4415
4783
|
]) {
|
|
4416
|
-
const mode = enumeration(
|
|
4784
|
+
const mode = enumeration(xml2, ["edge", "factor"]);
|
|
4417
4785
|
if (mode) result[key] = mode;
|
|
4418
4786
|
}
|
|
4419
|
-
for (const [
|
|
4787
|
+
for (const [xml2, key] of [
|
|
4420
4788
|
["x", "x"],
|
|
4421
4789
|
["y", "y"],
|
|
4422
4790
|
["w", "width"],
|
|
4423
4791
|
["h", "height"]
|
|
4424
4792
|
]) {
|
|
4425
|
-
const raw2 = value(
|
|
4793
|
+
const raw2 = value(xml2);
|
|
4426
4794
|
if (typeof raw2 !== "string" && typeof raw2 !== "number" || typeof raw2 === "string" && !raw2.trim())
|
|
4427
4795
|
continue;
|
|
4428
4796
|
const number2 = Number(raw2);
|
|
@@ -4598,24 +4966,24 @@ function drawingPatternPictureXml(fill) {
|
|
|
4598
4966
|
if (!fill.preset && !fill.sourceXml) throw new Error("A DrawingML pattern needs a preset");
|
|
4599
4967
|
if (before?.kind !== "pattern" || before.preset !== fill.preset)
|
|
4600
4968
|
root.setAttribute("prst", fill.preset);
|
|
4601
|
-
for (const [key,
|
|
4969
|
+
for (const [key, tag3] of [
|
|
4602
4970
|
["foreground", "fgClr"],
|
|
4603
4971
|
["background", "bgClr"]
|
|
4604
4972
|
]) {
|
|
4605
4973
|
const color2 = fill[key];
|
|
4606
4974
|
if (before?.kind === "pattern" && JSON.stringify(before[key]) === JSON.stringify(color2))
|
|
4607
4975
|
continue;
|
|
4608
|
-
const old = first(root,
|
|
4976
|
+
const old = first(root, tag3, NS.a);
|
|
4609
4977
|
if (!color2) {
|
|
4610
4978
|
if (old) root.removeChild(old);
|
|
4611
4979
|
continue;
|
|
4612
4980
|
}
|
|
4613
|
-
const node = old ?? doc.createElementNS(NS.a, `a:${
|
|
4981
|
+
const node = old ?? doc.createElementNS(NS.a, `a:${tag3}`);
|
|
4614
4982
|
patchDrawingColorIn(node, color2);
|
|
4615
4983
|
if (!old)
|
|
4616
4984
|
root.insertBefore(
|
|
4617
4985
|
node,
|
|
4618
|
-
|
|
4986
|
+
tag3 === "fgClr" ? first(root, "bgClr", NS.a) ?? root.firstChild : first(root, "extLst", NS.a) ?? null
|
|
4619
4987
|
);
|
|
4620
4988
|
}
|
|
4621
4989
|
} else {
|
|
@@ -4654,9 +5022,9 @@ function drawingPatternPictureXml(fill) {
|
|
|
4654
5022
|
}
|
|
4655
5023
|
|
|
4656
5024
|
// drawingml/write-fill.ts
|
|
4657
|
-
function setDrawingFillXml(properties,
|
|
5025
|
+
function setDrawingFillXml(properties, xml2) {
|
|
4658
5026
|
const doc = properties.ownerDocument;
|
|
4659
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${
|
|
5027
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
|
|
4660
5028
|
const fill = elements(wrapper.documentElement)[0];
|
|
4661
5029
|
const names = ["solidFill", "gradFill", "pattFill", "blipFill", "grpFill", "noFill"];
|
|
4662
5030
|
if (elements(wrapper.documentElement).length !== 1 || !fill || fill.namespaceURI !== NS.a || !names.includes(fill.localName))
|
|
@@ -4684,7 +5052,7 @@ function drawingFillXml(fill) {
|
|
|
4684
5052
|
const root = doc.documentElement;
|
|
4685
5053
|
if (root.namespaceURI !== NS.a || root.localName !== "gradFill")
|
|
4686
5054
|
throw new Error("Invalid gradient source XML");
|
|
4687
|
-
const fragment3 = (
|
|
5055
|
+
const fragment3 = (xml2) => doc.importNode(elements(parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`).documentElement)[0], true);
|
|
4688
5056
|
let list2 = first(root, "gsLst", NS.a);
|
|
4689
5057
|
if (!list2) {
|
|
4690
5058
|
list2 = doc.createElementNS(NS.a, "a:gsLst");
|
|
@@ -4758,8 +5126,8 @@ function writeChartFillFormatting(root, formatting) {
|
|
|
4758
5126
|
if (!node || !fill) continue;
|
|
4759
5127
|
let properties = first(node, "spPr", NS.c);
|
|
4760
5128
|
if (JSON.stringify(parseDrawingFill(properties)) === JSON.stringify(fill)) continue;
|
|
4761
|
-
const
|
|
4762
|
-
if (
|
|
5129
|
+
const xml2 = drawingFillXml(fill);
|
|
5130
|
+
if (xml2 === void 0) continue;
|
|
4763
5131
|
if (!properties) {
|
|
4764
5132
|
properties = root.ownerDocument.createElementNS(NS.c, "c:spPr");
|
|
4765
5133
|
const successors = [
|
|
@@ -4786,7 +5154,7 @@ function writeChartFillFormatting(root, formatting) {
|
|
|
4786
5154
|
) ?? null
|
|
4787
5155
|
);
|
|
4788
5156
|
}
|
|
4789
|
-
setDrawingFillXml(properties,
|
|
5157
|
+
setDrawingFillXml(properties, xml2);
|
|
4790
5158
|
changed = true;
|
|
4791
5159
|
}
|
|
4792
5160
|
return changed;
|
|
@@ -5069,63 +5437,63 @@ function escapeXmlText(value) {
|
|
|
5069
5437
|
function isValidBase64(value) {
|
|
5070
5438
|
return typeof value === "string" && value.length > 0 && /^[A-Za-z0-9+/=\s]+$/.test(value);
|
|
5071
5439
|
}
|
|
5072
|
-
function extractTagAttribute(
|
|
5440
|
+
function extractTagAttribute(xml2, tagName, attributeName) {
|
|
5073
5441
|
const pattern = new RegExp(
|
|
5074
5442
|
`<${tagName}\\b[^>]*\\b${attributeName}="(?<attributeValue>[^"]+)"`,
|
|
5075
5443
|
"i"
|
|
5076
5444
|
);
|
|
5077
|
-
const match =
|
|
5445
|
+
const match = xml2.match(pattern);
|
|
5078
5446
|
return match?.groups?.["attributeValue"]?.trim();
|
|
5079
5447
|
}
|
|
5080
5448
|
var isNameChar = (c2) => c2 !== void 0 && /[\w.-]/.test(c2);
|
|
5081
5449
|
var isWordChar = (c2) => c2 !== void 0 && /\w/.test(c2);
|
|
5082
|
-
function matchName(
|
|
5450
|
+
function matchName(xml2, lowerXml, from, lname) {
|
|
5083
5451
|
let pos = from;
|
|
5084
5452
|
if (!lowerXml.startsWith(lname, pos)) {
|
|
5085
5453
|
let end = pos;
|
|
5086
|
-
while (isNameChar(
|
|
5087
|
-
if (end === pos ||
|
|
5454
|
+
while (isNameChar(xml2[end])) end++;
|
|
5455
|
+
if (end === pos || xml2[end] !== ":") return -1;
|
|
5088
5456
|
pos = end + 1;
|
|
5089
5457
|
if (!lowerXml.startsWith(lname, pos)) return -1;
|
|
5090
5458
|
}
|
|
5091
5459
|
return pos + lname.length;
|
|
5092
5460
|
}
|
|
5093
|
-
function findTagText(
|
|
5094
|
-
let lt =
|
|
5461
|
+
function findTagText(xml2, lowerXml, lname, from) {
|
|
5462
|
+
let lt = xml2.indexOf("<", from);
|
|
5095
5463
|
while (lt !== -1) {
|
|
5096
|
-
const afterName = matchName(
|
|
5097
|
-
if (afterName !== -1 && !isWordChar(
|
|
5098
|
-
const gt =
|
|
5464
|
+
const afterName = matchName(xml2, lowerXml, lt + 1, lname);
|
|
5465
|
+
if (afterName !== -1 && !isWordChar(xml2[afterName])) {
|
|
5466
|
+
const gt = xml2.indexOf(">", afterName);
|
|
5099
5467
|
if (gt === -1) return null;
|
|
5100
|
-
let close =
|
|
5468
|
+
let close = xml2.indexOf("</", gt + 1);
|
|
5101
5469
|
while (close !== -1) {
|
|
5102
|
-
const closeEnd = matchName(
|
|
5103
|
-
if (closeEnd !== -1 &&
|
|
5104
|
-
return { text:
|
|
5470
|
+
const closeEnd = matchName(xml2, lowerXml, close + 2, lname);
|
|
5471
|
+
if (closeEnd !== -1 && xml2[closeEnd] === ">") {
|
|
5472
|
+
return { text: xml2.slice(gt + 1, close), end: closeEnd + 1 };
|
|
5105
5473
|
}
|
|
5106
|
-
close =
|
|
5474
|
+
close = xml2.indexOf("</", close + 2);
|
|
5107
5475
|
}
|
|
5108
5476
|
return null;
|
|
5109
5477
|
}
|
|
5110
|
-
lt =
|
|
5478
|
+
lt = xml2.indexOf("<", lt + 1);
|
|
5111
5479
|
}
|
|
5112
5480
|
return null;
|
|
5113
5481
|
}
|
|
5114
|
-
function extractFirstTagText(
|
|
5115
|
-
const found = findTagText(
|
|
5482
|
+
function extractFirstTagText(xml2, localName2) {
|
|
5483
|
+
const found = findTagText(xml2, xml2.toLowerCase(), localName2.toLowerCase(), 0);
|
|
5116
5484
|
return found?.text.replace(/\s+/g, "").trim() || void 0;
|
|
5117
5485
|
}
|
|
5118
|
-
function extractAllTagText(
|
|
5486
|
+
function extractAllTagText(xml2, localName2) {
|
|
5119
5487
|
const result = [];
|
|
5120
|
-
const lowerXml =
|
|
5488
|
+
const lowerXml = xml2.toLowerCase();
|
|
5121
5489
|
const lname = localName2.toLowerCase();
|
|
5122
|
-
let found = findTagText(
|
|
5490
|
+
let found = findTagText(xml2, lowerXml, lname, 0);
|
|
5123
5491
|
while (found) {
|
|
5124
5492
|
const value = found.text.replace(/\s+/g, "").trim();
|
|
5125
5493
|
if (value) {
|
|
5126
5494
|
result.push(value);
|
|
5127
5495
|
}
|
|
5128
|
-
found = findTagText(
|
|
5496
|
+
found = findTagText(xml2, lowerXml, lname, found.end);
|
|
5129
5497
|
}
|
|
5130
5498
|
return result;
|
|
5131
5499
|
}
|
|
@@ -5169,9 +5537,9 @@ function writeChartLayoutFormatting(root, formatting) {
|
|
|
5169
5537
|
let changed = false;
|
|
5170
5538
|
for (const part of ["title", "plotArea", "legend"]) {
|
|
5171
5539
|
const target = nodes[part];
|
|
5172
|
-
const
|
|
5173
|
-
if (!target || !
|
|
5174
|
-
const source2 = parseXml(
|
|
5540
|
+
const xml2 = formatting.entries[part]?.sourceXml;
|
|
5541
|
+
if (!target || !xml2?.trimStart().startsWith("<")) continue;
|
|
5542
|
+
const source2 = parseXml(xml2).documentElement;
|
|
5175
5543
|
for (const name of ["layout", "overlay"]) {
|
|
5176
5544
|
const property = first(source2, name, NS.c);
|
|
5177
5545
|
if (!property) continue;
|
|
@@ -5247,12 +5615,12 @@ var CHART_ROOT_BINDINGS = /* @__PURE__ */ new Map([
|
|
|
5247
5615
|
["r", NS.r]
|
|
5248
5616
|
]);
|
|
5249
5617
|
var DECLARATION = / xmlns:([A-Za-z_][\w.-]*)="([^"]*)"/g;
|
|
5250
|
-
function stripDeclarations(
|
|
5618
|
+
function stripDeclarations(xml2, bindings) {
|
|
5251
5619
|
const conflicting = /* @__PURE__ */ new Set();
|
|
5252
|
-
for (const [, prefix, uri] of
|
|
5620
|
+
for (const [, prefix, uri] of xml2.matchAll(DECLARATION))
|
|
5253
5621
|
if (prefix !== void 0 && bindings.has(prefix) && bindings.get(prefix) !== uri)
|
|
5254
5622
|
conflicting.add(prefix);
|
|
5255
|
-
return
|
|
5623
|
+
return xml2.replace(
|
|
5256
5624
|
DECLARATION,
|
|
5257
5625
|
(match, prefix, uri) => bindings.get(prefix) === uri && !conflicting.has(prefix) ? "" : match
|
|
5258
5626
|
);
|
|
@@ -5625,7 +5993,7 @@ function valXml(local, value) {
|
|
|
5625
5993
|
return `<c:${local} val="${text3}"/>`;
|
|
5626
5994
|
}
|
|
5627
5995
|
var elementXml = (local, content2, attributes2 = "") => content2 ? `<c:${local}${attributes2}>${content2}</c:${local}>` : `<c:${local}${attributes2}/>`;
|
|
5628
|
-
var raw = (context,
|
|
5996
|
+
var raw = (context, xml2) => xml2 ? stripDeclarations(xml2, context.bindings) : "";
|
|
5629
5997
|
function sameValue(left, right) {
|
|
5630
5998
|
if (left === right) return true;
|
|
5631
5999
|
if (typeof left !== "object" || typeof right !== "object" || !left || !right) return false;
|
|
@@ -6279,8 +6647,8 @@ var ORDER = [
|
|
|
6279
6647
|
"extLst"
|
|
6280
6648
|
];
|
|
6281
6649
|
var same = (a2, b) => JSON.stringify(a2) === JSON.stringify(b);
|
|
6282
|
-
function importXml(host,
|
|
6283
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${
|
|
6650
|
+
function importXml(host, xml2) {
|
|
6651
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
|
|
6284
6652
|
return host.ownerDocument.importNode(elements(wrapper.documentElement)[0], true);
|
|
6285
6653
|
}
|
|
6286
6654
|
function dropDrawingDeclarations(node) {
|
|
@@ -6321,10 +6689,10 @@ function patchDrawingLine(ln, line4) {
|
|
|
6321
6689
|
const solid = first(ln, "solidFill", NS.a);
|
|
6322
6690
|
if (solid && line4.fill?.kind === "solid") patchDrawingColorIn(solid, line4.fill.color);
|
|
6323
6691
|
else {
|
|
6324
|
-
const
|
|
6325
|
-
if (
|
|
6326
|
-
if (
|
|
6327
|
-
const child6 = importXml(ln,
|
|
6692
|
+
const xml2 = line4.fill && drawingFillXml(line4.fill);
|
|
6693
|
+
if (xml2 || !line4.fill) remove(ln, FILLS);
|
|
6694
|
+
if (xml2) {
|
|
6695
|
+
const child6 = importXml(ln, xml2);
|
|
6328
6696
|
dropDrawingDeclarations(child6);
|
|
6329
6697
|
insert(ln, child6);
|
|
6330
6698
|
}
|
|
@@ -6445,7 +6813,7 @@ function writeTextBody(body) {
|
|
|
6445
6813
|
|
|
6446
6814
|
// chart/write-shape.ts
|
|
6447
6815
|
var ROOT_DECLARATIONS = [...CHART_ROOT_BINDINGS].map(([prefix, uri]) => ` xmlns:${prefix}="${uri}"`).join("");
|
|
6448
|
-
var wrap = (local,
|
|
6816
|
+
var wrap = (local, xml2) => parseXml(`<c:${local}${ROOT_DECLARATIONS}>${xml2}</c:${local}>`, { label: "Chart" }).documentElement;
|
|
6449
6817
|
function chartFillXml(fill) {
|
|
6450
6818
|
return drawingFillXml(fill);
|
|
6451
6819
|
}
|
|
@@ -6455,8 +6823,8 @@ var firstOf = (parent, names) => elements(parent).find((node) => node.namespaceU
|
|
|
6455
6823
|
function patchShape(root, shape, read) {
|
|
6456
6824
|
const doc = root.ownerDocument;
|
|
6457
6825
|
if (!sameValue(read.fill, shape.fill)) {
|
|
6458
|
-
const
|
|
6459
|
-
if (
|
|
6826
|
+
const xml2 = shape.fill && chartFillXml(shape.fill);
|
|
6827
|
+
if (xml2) setDrawingFillXml(root, xml2);
|
|
6460
6828
|
else if (!shape.fill)
|
|
6461
6829
|
for (let fill = fillElementOf(root); fill; fill = fillElementOf(root)) root.removeChild(fill);
|
|
6462
6830
|
}
|
|
@@ -6541,12 +6909,12 @@ function numberFormatXml(format) {
|
|
|
6541
6909
|
const linked = format.sourceLinked === void 0 ? "" : ` sourceLinked="${format.sourceLinked ? 1 : 0}"`;
|
|
6542
6910
|
return `<c:numFmt formatCode="${escapeAttribute(format.formatCode)}"${linked}/>`;
|
|
6543
6911
|
}
|
|
6544
|
-
function chartTextBodyFromXml(
|
|
6545
|
-
const body = parseDrawingTextBody(wrap("rich",
|
|
6912
|
+
function chartTextBodyFromXml(xml2) {
|
|
6913
|
+
const body = parseDrawingTextBody(wrap("rich", xml2)) ?? {
|
|
6546
6914
|
paragraphs: [],
|
|
6547
6915
|
text: ""
|
|
6548
6916
|
};
|
|
6549
|
-
body.sourceXml =
|
|
6917
|
+
body.sourceXml = xml2;
|
|
6550
6918
|
return body;
|
|
6551
6919
|
}
|
|
6552
6920
|
|
|
@@ -7686,9 +8054,9 @@ var CHART_EX_ROOT_DECLARATIONS = [
|
|
|
7686
8054
|
{ prefix: "a", uri: NS.a },
|
|
7687
8055
|
{ prefix: "r", uri: NS.r }
|
|
7688
8056
|
];
|
|
7689
|
-
function chartExWriteOptionsOf(
|
|
7690
|
-
const declarationBreak = /^<\?xml[^>]*\?>(\r\n|\n)?/.exec(
|
|
7691
|
-
return { declarationBreak, .../<[^<>]*\s\/>/.test(
|
|
8057
|
+
function chartExWriteOptionsOf(xml2) {
|
|
8058
|
+
const declarationBreak = /^<\?xml[^>]*\?>(\r\n|\n)?/.exec(xml2)?.[1] ?? "";
|
|
8059
|
+
return { declarationBreak, .../<[^<>]*\s\/>/.test(xml2) ? { emptyElementSpace: true } : {} };
|
|
7692
8060
|
}
|
|
7693
8061
|
function writeChartExSpace(space3, options2 = {}) {
|
|
7694
8062
|
const bindings = /* @__PURE__ */ new Map();
|
|
@@ -7727,9 +8095,9 @@ function writeChartExSpace(space3, options2 = {}) {
|
|
|
7727
8095
|
);
|
|
7728
8096
|
const userShapes = space3.userShapesRelId === void 0 ? "" : `<c:userShapes${attributes([["r:id", space3.userShapesRelId]])}/>`;
|
|
7729
8097
|
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);
|
|
7730
|
-
let
|
|
7731
|
-
if (options2.emptyElementSpace)
|
|
7732
|
-
return
|
|
8098
|
+
let xml2 = `${DECLARATION3}${options2.declarationBreak ?? ""}<cx:chartSpace${declarations}>${body}</cx:chartSpace>`;
|
|
8099
|
+
if (options2.emptyElementSpace) xml2 = xml2.replace(/\/>/g, " />");
|
|
8100
|
+
return xml2;
|
|
7733
8101
|
}
|
|
7734
8102
|
|
|
7735
8103
|
// chart/data-sheet.ts
|
|
@@ -9076,10 +9444,10 @@ async function openZip(input, limits = {}) {
|
|
|
9076
9444
|
}
|
|
9077
9445
|
|
|
9078
9446
|
// opc/relationships.ts
|
|
9079
|
-
function parseRelationships(
|
|
9447
|
+
function parseRelationships(xml2) {
|
|
9080
9448
|
const map = /* @__PURE__ */ new Map();
|
|
9081
|
-
if (!
|
|
9082
|
-
const root = parseXml(
|
|
9449
|
+
if (!xml2) return map;
|
|
9450
|
+
const root = parseXml(xml2).documentElement;
|
|
9083
9451
|
for (const node of elements(root)) {
|
|
9084
9452
|
if (node.localName !== "Relationship") continue;
|
|
9085
9453
|
const id = node.getAttribute("Id");
|
|
@@ -9308,17 +9676,17 @@ async function syncWorksheetTables(zip, sheetPath, doc, writes, shared) {
|
|
|
9308
9676
|
for (const rel of rels.values()) {
|
|
9309
9677
|
if (rel.mode === "External" || !rel.type.endsWith("/table")) continue;
|
|
9310
9678
|
const path3 = resolvePartPath(sheetPath, rel.target);
|
|
9311
|
-
const
|
|
9312
|
-
if (!
|
|
9313
|
-
const tableDoc = parseXml(
|
|
9679
|
+
const xml2 = await zip.file(path3)?.async("string");
|
|
9680
|
+
if (!xml2) continue;
|
|
9681
|
+
const tableDoc = parseXml(xml2, { label: "Table" });
|
|
9314
9682
|
const table = tableDoc.documentElement;
|
|
9315
9683
|
if (table && syncTable(table, doc, values, shared)) zip.file(path3, buildXml(tableDoc));
|
|
9316
9684
|
}
|
|
9317
9685
|
}
|
|
9318
9686
|
async function sharedStringTexts(zip) {
|
|
9319
|
-
const
|
|
9320
|
-
if (!
|
|
9321
|
-
return childrenNamed(parseXml(
|
|
9687
|
+
const xml2 = await zip.file("xl/sharedStrings.xml")?.async("string");
|
|
9688
|
+
if (!xml2) return [];
|
|
9689
|
+
return childrenNamed(parseXml(xml2).documentElement ?? void 0, "si").map((item2) => {
|
|
9322
9690
|
const direct = childNamed(item2, "t");
|
|
9323
9691
|
if (direct) return direct.textContent ?? "";
|
|
9324
9692
|
return childrenNamed(item2, "r").map((run2) => childNamed(run2, "t")?.textContent ?? "").join("");
|
|
@@ -9396,8 +9764,8 @@ async function validateAtomicChartWorkbookWrites(zip, paths, writes, requireCurr
|
|
|
9396
9764
|
unsupported("rich worksheet strings require source-workbook editing");
|
|
9397
9765
|
if (requireCurrentValues) {
|
|
9398
9766
|
const current = text3 ? childNamed(text3, "t")?.textContent ?? void 0 : childNamed(cell2, "v")?.textContent ?? void 0;
|
|
9399
|
-
const
|
|
9400
|
-
if (!
|
|
9767
|
+
const equal3 = write.isNumeric ? current !== void 0 && Number(current) === Number(value) : current === value;
|
|
9768
|
+
if (!equal3) unsupported("the workbook and chart caches disagree");
|
|
9401
9769
|
}
|
|
9402
9770
|
if (write.isNumeric && !Number.isFinite(Number(value)))
|
|
9403
9771
|
unsupported("a numeric cache value is not finite");
|
|
@@ -9600,9 +9968,9 @@ async function appendChartWorkbookSheet(bytes, rowsForName, options2 = {}) {
|
|
|
9600
9968
|
// chart/ex/workbook.ts
|
|
9601
9969
|
async function appendChartExWorkbookData(bytes, before, after) {
|
|
9602
9970
|
const zip = await openEmbeddedPackage(bytes);
|
|
9603
|
-
const
|
|
9604
|
-
if (!
|
|
9605
|
-
const root = parseXml(
|
|
9971
|
+
const xml2 = await zip.file("xl/workbook.xml")?.async("string");
|
|
9972
|
+
if (!xml2) throw new Error("The chart workbook is missing.");
|
|
9973
|
+
const root = parseXml(xml2).documentElement;
|
|
9606
9974
|
const defined = first(root, "definedNames", NS.x);
|
|
9607
9975
|
const names = defined ? children(defined, "definedName", NS.x) : [];
|
|
9608
9976
|
const resolve = (name) => names.find(
|
|
@@ -10201,7 +10569,7 @@ var KINDS = {
|
|
|
10201
10569
|
reflection: "reflection",
|
|
10202
10570
|
fillOverlay: "fillOverlay"
|
|
10203
10571
|
};
|
|
10204
|
-
var TAGS = Object.fromEntries(Object.entries(KINDS).map(([
|
|
10572
|
+
var TAGS = Object.fromEntries(Object.entries(KINDS).map(([tag3, kind]) => [kind, tag3]));
|
|
10205
10573
|
var GEOMETRY = { blurRadiusEmu: "blurRad", distanceEmu: "dist", directionAngle: "dir" };
|
|
10206
10574
|
var TRANSFORM = { scaleX: "sx", scaleY: "sy", skewXAngle: "kx", skewYAngle: "ky" };
|
|
10207
10575
|
var NUMBERS = {
|
|
@@ -10235,8 +10603,8 @@ var BOOLEANS = {
|
|
|
10235
10603
|
};
|
|
10236
10604
|
var COLORED = /* @__PURE__ */ new Set(["outerShadow", "innerShadow", "presetShadow", "glow"]);
|
|
10237
10605
|
var same3 = (a2, b) => JSON.stringify(a2) === JSON.stringify(b);
|
|
10238
|
-
function fragment(
|
|
10239
|
-
return elements(parseXml(`<w xmlns:a="${NS.a}">${
|
|
10606
|
+
function fragment(xml2) {
|
|
10607
|
+
return elements(parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`).documentElement)[0];
|
|
10240
10608
|
}
|
|
10241
10609
|
function parseDrawingEffect(node) {
|
|
10242
10610
|
const sourceXml = buildXml(node);
|
|
@@ -10310,12 +10678,12 @@ function drawingEffectXml(effect) {
|
|
|
10310
10678
|
}
|
|
10311
10679
|
}
|
|
10312
10680
|
if (effect.kind === "fillOverlay" && changed("fill")) {
|
|
10313
|
-
const
|
|
10314
|
-
if (effect.fill && !
|
|
10315
|
-
if (
|
|
10681
|
+
const xml2 = effect.fill && drawingFillXml(effect.fill);
|
|
10682
|
+
if (effect.fill && !xml2) throw new Error("Cannot author this DrawingML effect fill");
|
|
10683
|
+
if (xml2 || !effect.fill) {
|
|
10316
10684
|
const fill = fillElementOf(root);
|
|
10317
10685
|
if (fill) root.removeChild(fill);
|
|
10318
|
-
if (
|
|
10686
|
+
if (xml2) root.insertBefore(doc.importNode(fragment(xml2), true), root.firstChild);
|
|
10319
10687
|
}
|
|
10320
10688
|
}
|
|
10321
10689
|
return buildXml(doc);
|
|
@@ -10372,8 +10740,8 @@ function resolveDrawingOuterShadow(effect, theme) {
|
|
|
10372
10740
|
dy: Math.sin(angle) * distance
|
|
10373
10741
|
};
|
|
10374
10742
|
}
|
|
10375
|
-
function resolveDrawingShadowXml(
|
|
10376
|
-
return
|
|
10743
|
+
function resolveDrawingShadowXml(xml2, theme) {
|
|
10744
|
+
return xml2 ? resolveDrawingShadow(parseXml(xml2).documentElement, theme) : void 0;
|
|
10377
10745
|
}
|
|
10378
10746
|
function svgDropShadowElement(s2, format) {
|
|
10379
10747
|
const num2 = format.number;
|
|
@@ -10795,12 +11163,12 @@ function fillXml(style) {
|
|
|
10795
11163
|
return buildXml(node);
|
|
10796
11164
|
}
|
|
10797
11165
|
}
|
|
10798
|
-
const
|
|
10799
|
-
if (!
|
|
11166
|
+
const xml2 = drawingFillXml(style.fill);
|
|
11167
|
+
if (!xml2) {
|
|
10800
11168
|
if (style.sourceXml) return style.sourceXml;
|
|
10801
11169
|
throw new Error("Cannot author this DrawingML theme fill");
|
|
10802
11170
|
}
|
|
10803
|
-
return
|
|
11171
|
+
return xml2;
|
|
10804
11172
|
}
|
|
10805
11173
|
function effectXml(style) {
|
|
10806
11174
|
const doc = parseXml(style.sourceXml ?? `<a:effectStyle xmlns:a="${NS.a}"/>`);
|
|
@@ -10843,8 +11211,8 @@ function drawingThemeFormatSchemeXml(scheme2) {
|
|
|
10843
11211
|
const old = elements(list2).filter(
|
|
10844
11212
|
(node) => node.namespaceURI === NS.a && (!local || node.localName === local)
|
|
10845
11213
|
);
|
|
10846
|
-
values.forEach((
|
|
10847
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${
|
|
11214
|
+
values.forEach((xml2, offset) => {
|
|
11215
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}">${xml2}</w>`);
|
|
10848
11216
|
const node = doc.importNode(elements(wrapper.documentElement)[0], true);
|
|
10849
11217
|
if (old[offset]) list2.replaceChild(node, old[offset]);
|
|
10850
11218
|
else list2.appendChild(node);
|
|
@@ -11005,8 +11373,8 @@ function parseTheme(source2) {
|
|
|
11005
11373
|
if (name) theme.name = name;
|
|
11006
11374
|
return theme;
|
|
11007
11375
|
}
|
|
11008
|
-
function parseThemeXml(
|
|
11009
|
-
return parseTheme(parseXml(
|
|
11376
|
+
function parseThemeXml(xml2, label = "DrawingML theme") {
|
|
11377
|
+
return parseTheme(parseXml(xml2, { label }));
|
|
11010
11378
|
}
|
|
11011
11379
|
function parseThemeColorMap(element4) {
|
|
11012
11380
|
const map = {};
|
|
@@ -13050,9 +13418,9 @@ function parseDrawingGeometry(spPr) {
|
|
|
13050
13418
|
}
|
|
13051
13419
|
|
|
13052
13420
|
// drawingml/write-theme.ts
|
|
13053
|
-
function fragment2(host,
|
|
13421
|
+
function fragment2(host, xml2, namespaces) {
|
|
13054
13422
|
const declarations = Object.entries({ a: NS.a, ...namespaces }).map(([prefix, uri]) => ` xmlns:${prefix}="${uri}"`).join("");
|
|
13055
|
-
const wrapper = parseXml(`<w${declarations}>${
|
|
13423
|
+
const wrapper = parseXml(`<w${declarations}>${xml2}</w>`, { label: "DrawingML theme fragment" });
|
|
13056
13424
|
return elements(wrapper.documentElement).map(
|
|
13057
13425
|
(node) => host.ownerDocument.importNode(node, true)
|
|
13058
13426
|
);
|
|
@@ -13062,10 +13430,10 @@ function extensionList3(parent, extensions, namespaces) {
|
|
|
13062
13430
|
if (!entries.length) return;
|
|
13063
13431
|
const doc = parent.ownerDocument;
|
|
13064
13432
|
const list2 = doc.createElementNS(NS.a, "a:extLst");
|
|
13065
|
-
for (const [uri,
|
|
13433
|
+
for (const [uri, xml2] of entries) {
|
|
13066
13434
|
const ext = doc.createElementNS(NS.a, "a:ext");
|
|
13067
13435
|
ext.setAttribute("uri", uri);
|
|
13068
|
-
for (const node of fragment2(ext,
|
|
13436
|
+
for (const node of fragment2(ext, xml2, namespaces)) ext.appendChild(node);
|
|
13069
13437
|
list2.appendChild(ext);
|
|
13070
13438
|
}
|
|
13071
13439
|
parent.appendChild(list2);
|
|
@@ -14050,20 +14418,20 @@ function dropRedundantDeclarations(element4) {
|
|
|
14050
14418
|
if (element4.getAttribute("xmlns:r") === NS.r) element4.removeAttribute("xmlns:r");
|
|
14051
14419
|
for (const child6 of elements(element4)) dropRedundantDeclarations(child6);
|
|
14052
14420
|
}
|
|
14053
|
-
function importDrawingXml(doc,
|
|
14054
|
-
const wrapper = parseXml(`<w xmlns:a="${NS.a}" xmlns:r="${NS.r}">${
|
|
14421
|
+
function importDrawingXml(doc, xml2) {
|
|
14422
|
+
const wrapper = parseXml(`<w xmlns:a="${NS.a}" xmlns:r="${NS.r}">${xml2}</w>`).documentElement;
|
|
14055
14423
|
const node = elements(wrapper)[0];
|
|
14056
14424
|
if (!node) throw new Error("Empty DrawingML fragment");
|
|
14057
14425
|
const imported = doc.importNode(node, true);
|
|
14058
14426
|
dropRedundantDeclarations(imported);
|
|
14059
14427
|
return imported;
|
|
14060
14428
|
}
|
|
14061
|
-
function keptChildName(
|
|
14062
|
-
const match = /^\s*<(?:[\w.-]+:)?([\w.-]+)/u.exec(
|
|
14429
|
+
function keptChildName(xml2) {
|
|
14430
|
+
const match = /^\s*<(?:[\w.-]+:)?([\w.-]+)/u.exec(xml2);
|
|
14063
14431
|
return match?.[1] ?? "";
|
|
14064
14432
|
}
|
|
14065
|
-
function keptChildren(doc,
|
|
14066
|
-
return (
|
|
14433
|
+
function keptChildren(doc, xml2) {
|
|
14434
|
+
return (xml2 ?? []).map((value) => ({
|
|
14067
14435
|
name: keptChildName(value),
|
|
14068
14436
|
node: importDrawingXml(doc, value)
|
|
14069
14437
|
}));
|
|
@@ -14130,7 +14498,7 @@ function writeHyperlink(doc, local, link) {
|
|
|
14130
14498
|
setBoolean(element4, "history", link.history);
|
|
14131
14499
|
setBoolean(element4, "highlightClick", link.highlightClick);
|
|
14132
14500
|
setBoolean(element4, "endSnd", link.endSound);
|
|
14133
|
-
for (const
|
|
14501
|
+
for (const xml2 of link.extraXml ?? []) element4.appendChild(importDrawingXml(doc, xml2));
|
|
14134
14502
|
return element4;
|
|
14135
14503
|
}
|
|
14136
14504
|
function setAttributes(element4, value) {
|
|
@@ -14155,9 +14523,9 @@ function setAttributes(element4, value) {
|
|
|
14155
14523
|
setValue(element4, "bmk", value.bookmark);
|
|
14156
14524
|
}
|
|
14157
14525
|
function fillChild(doc, fill) {
|
|
14158
|
-
const
|
|
14159
|
-
if (!
|
|
14160
|
-
const node = importDrawingXml(doc,
|
|
14526
|
+
const xml2 = fill ? drawingFillXml(fill) : void 0;
|
|
14527
|
+
if (!xml2) return void 0;
|
|
14528
|
+
const node = importDrawingXml(doc, xml2);
|
|
14161
14529
|
return { name: node.localName, node };
|
|
14162
14530
|
}
|
|
14163
14531
|
function modelledChildren(doc, value) {
|
|
@@ -14386,9 +14754,9 @@ function semantics(value) {
|
|
|
14386
14754
|
Object.fromEntries(Object.entries(value).filter(([key]) => key !== "sourceXml"))
|
|
14387
14755
|
);
|
|
14388
14756
|
}
|
|
14389
|
-
function source(doc, name,
|
|
14390
|
-
if (!
|
|
14391
|
-
const element4 = parseXml(
|
|
14757
|
+
function source(doc, name, xml2) {
|
|
14758
|
+
if (!xml2) return doc.createElementNS(NS.a, `a:${name}`);
|
|
14759
|
+
const element4 = parseXml(xml2).documentElement;
|
|
14392
14760
|
if (element4.namespaceURI !== NS.a || element4.localName !== name)
|
|
14393
14761
|
throw new Error(`Invalid ${name} source`);
|
|
14394
14762
|
return doc.importNode(element4, true);
|
|
@@ -15005,9 +15373,9 @@ function schemaPosition(node, end) {
|
|
|
15005
15373
|
}
|
|
15006
15374
|
return end === "mid" ? { kind: "percent", value: 50 } : { kind: end };
|
|
15007
15375
|
}
|
|
15008
|
-
function parseRegionValueColorPositions(
|
|
15009
|
-
if (!
|
|
15010
|
-
const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${
|
|
15376
|
+
function parseRegionValueColorPositions(xml2) {
|
|
15377
|
+
if (!xml2) return void 0;
|
|
15378
|
+
const root = parseXml(`<cx:root xmlns:cx="${NS.cx}">${xml2}</cx:root>`).documentElement;
|
|
15011
15379
|
const positions = first(root, "valueColorPositions", NS.cx);
|
|
15012
15380
|
if (!positions) return void 0;
|
|
15013
15381
|
const count = positions.getAttribute("count");
|
|
@@ -15033,8 +15401,8 @@ function parseRegionValueColorPositions(xml) {
|
|
|
15033
15401
|
// chart/region-map/value-colors.ts
|
|
15034
15402
|
function resolveRegionValueColors(options2, color2) {
|
|
15035
15403
|
const result = { ...options2 };
|
|
15036
|
-
const
|
|
15037
|
-
const root = parseXml(
|
|
15404
|
+
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>`;
|
|
15405
|
+
const root = parseXml(xml2).documentElement;
|
|
15038
15406
|
if (options2.valueColorsXml) {
|
|
15039
15407
|
const colors = Array.from(root.getElementsByTagName("*")).flatMap((node) => {
|
|
15040
15408
|
const c2 = color2(parseDrawingColorIn(node));
|
|
@@ -16784,14 +17152,14 @@ function inflateGeoCache(binary, maxOutputBytes = LIMIT) {
|
|
|
16784
17152
|
}
|
|
16785
17153
|
return new TextDecoder("utf-8", { fatal: true }).decode(out);
|
|
16786
17154
|
}
|
|
16787
|
-
function readGeographyCache(
|
|
17155
|
+
function readGeographyCache(xml2, pointLimit = 1e6) {
|
|
16788
17156
|
const result = { regions: [], issues: [] };
|
|
16789
|
-
if (!
|
|
17157
|
+
if (!xml2) return result;
|
|
16790
17158
|
try {
|
|
16791
17159
|
if (!Number.isSafeInteger(pointLimit) || pointLimit < 1 || pointLimit > 1e6)
|
|
16792
17160
|
throw new Error("Invalid geography point limit.");
|
|
16793
|
-
if (
|
|
16794
|
-
let root = parseXml(`<cx:root xmlns:cx="${CX}">${
|
|
17161
|
+
if (xml2.length > LIMIT) throw new Error("Geography cache input limit exceeded.");
|
|
17162
|
+
let root = parseXml(`<cx:root xmlns:cx="${CX}">${xml2}</cx:root>`).documentElement;
|
|
16795
17163
|
const binary = elements2(root, "binary")[0];
|
|
16796
17164
|
if (binary) root = parseXml(inflateGeoCache(binary.textContent ?? "")).documentElement;
|
|
16797
17165
|
let points2 = 0;
|
|
@@ -18794,8 +19162,8 @@ var ORDER2 = [
|
|
|
18794
19162
|
"softEdge"
|
|
18795
19163
|
];
|
|
18796
19164
|
function chartTargetEffects(space3, target) {
|
|
18797
|
-
const
|
|
18798
|
-
return
|
|
19165
|
+
const xml2 = chartTargetShape(space3, target)?.effectsXml;
|
|
19166
|
+
return xml2 ? parseDrawingEffects(parseXml(xml2).documentElement) : void 0;
|
|
18799
19167
|
}
|
|
18800
19168
|
function editChartEffectList(list2, edit) {
|
|
18801
19169
|
const next = structuredClone(list2 ?? { effects: [] });
|
|
@@ -19292,11 +19660,11 @@ function patchRun(node, edit) {
|
|
|
19292
19660
|
if (edit.fillTransparency !== void 0) {
|
|
19293
19661
|
const fill = parseDrawingFill(node);
|
|
19294
19662
|
if (fill?.kind === "solid") {
|
|
19295
|
-
const
|
|
19663
|
+
const xml2 = drawingFillXml({
|
|
19296
19664
|
...fill,
|
|
19297
19665
|
color: withDrawingColorTransparency(fill.color, edit.fillTransparency)
|
|
19298
19666
|
});
|
|
19299
|
-
if (
|
|
19667
|
+
if (xml2) setDrawingFillXml(node, xml2);
|
|
19300
19668
|
}
|
|
19301
19669
|
}
|
|
19302
19670
|
if (edit.lineTransparency !== void 0) {
|
|
@@ -19319,9 +19687,9 @@ function patchRun(node, edit) {
|
|
|
19319
19687
|
))
|
|
19320
19688
|
node.removeChild(old);
|
|
19321
19689
|
} else {
|
|
19322
|
-
const
|
|
19323
|
-
if (!
|
|
19324
|
-
setDrawingFillXml(node,
|
|
19690
|
+
const xml2 = drawingFillXml(edit.fill);
|
|
19691
|
+
if (!xml2) throw new RangeError("Unsupported chart text fill");
|
|
19692
|
+
setDrawingFillXml(node, xml2);
|
|
19325
19693
|
}
|
|
19326
19694
|
}
|
|
19327
19695
|
if (edit.line !== void 0) {
|
|
@@ -19360,16 +19728,16 @@ function patchRun(node, edit) {
|
|
|
19360
19728
|
typeof value === "boolean" ? value ? "1" : "0" : String(Math.round(value * 100))
|
|
19361
19729
|
);
|
|
19362
19730
|
}
|
|
19363
|
-
for (const [key,
|
|
19731
|
+
for (const [key, tag3] of [
|
|
19364
19732
|
["typeface", "latin"],
|
|
19365
19733
|
["eastAsiaTypeface", "ea"]
|
|
19366
19734
|
])
|
|
19367
19735
|
if (edit[key] !== void 0) {
|
|
19368
|
-
const old = first(node,
|
|
19736
|
+
const old = first(node, tag3, NS.a);
|
|
19369
19737
|
if (edit[key] === null) {
|
|
19370
19738
|
if (old) node.removeChild(old);
|
|
19371
19739
|
} else {
|
|
19372
|
-
const latin = old ?? node.ownerDocument.createElementNS(NS.a, `a:${
|
|
19740
|
+
const latin = old ?? node.ownerDocument.createElementNS(NS.a, `a:${tag3}`);
|
|
19373
19741
|
latin.setAttribute("typeface", edit[key]);
|
|
19374
19742
|
if (!old) node.appendChild(latin);
|
|
19375
19743
|
}
|
|
@@ -19573,9 +19941,9 @@ function setChartDataLabels(space3, edit, target = {}) {
|
|
|
19573
19941
|
// chart/edit/label-range.ts
|
|
19574
19942
|
var C15 = "http://schemas.microsoft.com/office/drawing/2012/chart";
|
|
19575
19943
|
var URI = "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}";
|
|
19576
|
-
function extensionRoot(
|
|
19944
|
+
function extensionRoot(xml2) {
|
|
19577
19945
|
return parseXml(
|
|
19578
|
-
`<c:wrapper xmlns:c="${NS.c}" xmlns:c15="${C15}">${
|
|
19946
|
+
`<c:wrapper xmlns:c="${NS.c}" xmlns:c15="${C15}">${xml2 ?? "<c:extLst/>"}</c:wrapper>`
|
|
19579
19947
|
).documentElement.getElementsByTagNameNS(NS.c, "extLst")[0];
|
|
19580
19948
|
}
|
|
19581
19949
|
function chartDataLabelsRange(labels2) {
|
|
@@ -20655,11 +21023,11 @@ function chartTargetThreeD(space3, target) {
|
|
|
20655
21023
|
editChartShapeXml({ ...shape }, (root) => {
|
|
20656
21024
|
const sp3d = first(root, "sp3d", NS.a);
|
|
20657
21025
|
if (sp3d) {
|
|
20658
|
-
for (const [key,
|
|
21026
|
+
for (const [key, tag3] of [
|
|
20659
21027
|
["bevelTop", "bevelT"],
|
|
20660
21028
|
["bevelBottom", "bevelB"]
|
|
20661
21029
|
]) {
|
|
20662
|
-
const node = first(sp3d,
|
|
21030
|
+
const node = first(sp3d, tag3, NS.a);
|
|
20663
21031
|
if (!node) continue;
|
|
20664
21032
|
const widthEmu = Number(node.getAttribute("w") ?? 0);
|
|
20665
21033
|
const heightEmu = Number(node.getAttribute("h") ?? 0);
|
|
@@ -20673,11 +21041,11 @@ function chartTargetThreeD(space3, target) {
|
|
|
20673
21041
|
const value = sp3d.getAttribute(attr4);
|
|
20674
21042
|
if (value !== null && Number.isFinite(Number(value))) result[key] = Number(value);
|
|
20675
21043
|
}
|
|
20676
|
-
for (const [key,
|
|
21044
|
+
for (const [key, tag3] of [
|
|
20677
21045
|
["depthColor", "extrusionClr"],
|
|
20678
21046
|
["contourColor", "contourClr"]
|
|
20679
21047
|
]) {
|
|
20680
|
-
const color2 = parseDrawingColorIn(first(sp3d,
|
|
21048
|
+
const color2 = parseDrawingColorIn(first(sp3d, tag3, NS.a));
|
|
20681
21049
|
if (color2) result[key] = color2;
|
|
20682
21050
|
}
|
|
20683
21051
|
const material = sp3d.getAttribute("prstMaterial");
|
|
@@ -20697,21 +21065,21 @@ function setChartTargetThreeD(space3, target, edit) {
|
|
|
20697
21065
|
for (const shape of chartTargetDraftShapes(draft, target))
|
|
20698
21066
|
editChartShapeXml(shape, (root) => {
|
|
20699
21067
|
const sp3d = child3(root, "sp3d");
|
|
20700
|
-
for (const [key,
|
|
21068
|
+
for (const [key, tag3] of [
|
|
20701
21069
|
["bevelTop", "bevelT"],
|
|
20702
21070
|
["bevelBottom", "bevelB"]
|
|
20703
21071
|
]) {
|
|
20704
21072
|
const bevel2 = edit[key];
|
|
20705
21073
|
if (bevel2 === void 0) continue;
|
|
20706
21074
|
if (bevel2 === null) {
|
|
20707
|
-
remove3(sp3d,
|
|
21075
|
+
remove3(sp3d, tag3);
|
|
20708
21076
|
continue;
|
|
20709
21077
|
}
|
|
20710
21078
|
if (![bevel2.widthEmu, bevel2.heightEmu].every(
|
|
20711
21079
|
(value) => Number.isFinite(value) && value >= 0
|
|
20712
21080
|
) || !bevel2.preset)
|
|
20713
21081
|
throw new RangeError("Invalid chart bevel");
|
|
20714
|
-
const node = child3(sp3d,
|
|
21082
|
+
const node = child3(sp3d, tag3);
|
|
20715
21083
|
node.setAttribute("prst", bevel2.preset);
|
|
20716
21084
|
node.setAttribute("w", String(Math.round(bevel2.widthEmu)));
|
|
20717
21085
|
node.setAttribute("h", String(Math.round(bevel2.heightEmu)));
|
|
@@ -20728,14 +21096,14 @@ function setChartTargetThreeD(space3, target, edit) {
|
|
|
20728
21096
|
sp3d.setAttribute(attribute2, String(Math.round(value)));
|
|
20729
21097
|
}
|
|
20730
21098
|
}
|
|
20731
|
-
for (const [key,
|
|
21099
|
+
for (const [key, tag3] of [
|
|
20732
21100
|
["depthColor", "extrusionClr"],
|
|
20733
21101
|
["contourColor", "contourClr"]
|
|
20734
21102
|
]) {
|
|
20735
21103
|
const color2 = edit[key];
|
|
20736
21104
|
if (color2 === void 0) continue;
|
|
20737
|
-
if (color2 === null) remove3(sp3d,
|
|
20738
|
-
else patchDrawingColorIn(child3(sp3d,
|
|
21105
|
+
if (color2 === null) remove3(sp3d, tag3);
|
|
21106
|
+
else patchDrawingColorIn(child3(sp3d, tag3), color2);
|
|
20739
21107
|
}
|
|
20740
21108
|
if (edit.material !== void 0) {
|
|
20741
21109
|
if (edit.material === null) sp3d.removeAttribute("prstMaterial");
|
|
@@ -21565,15 +21933,15 @@ function editChartLayout(current, value) {
|
|
|
21565
21933
|
root.insertBefore(manual, root.firstChild);
|
|
21566
21934
|
}
|
|
21567
21935
|
if (manual) {
|
|
21568
|
-
const previous = new Map(FIELDS.map(([,
|
|
21569
|
-
for (const [,
|
|
21570
|
-
const old = first(manual,
|
|
21936
|
+
const previous = new Map(FIELDS.map(([, tag3]) => [tag3, first(manual, tag3, NS.c)]));
|
|
21937
|
+
for (const [, tag3] of FIELDS) {
|
|
21938
|
+
const old = first(manual, tag3, NS.c);
|
|
21571
21939
|
if (old) manual.removeChild(old);
|
|
21572
21940
|
}
|
|
21573
21941
|
const before = manual.firstChild;
|
|
21574
|
-
for (const [key,
|
|
21942
|
+
for (const [key, tag3] of FIELDS) {
|
|
21575
21943
|
if (value?.[key] === void 0) continue;
|
|
21576
|
-
const node = previous.get(
|
|
21944
|
+
const node = previous.get(tag3) ?? root.ownerDocument.createElementNS(NS.c, `c:${tag3}`);
|
|
21577
21945
|
node.setAttribute("val", String(value[key]));
|
|
21578
21946
|
manual.insertBefore(node, before);
|
|
21579
21947
|
}
|
|
@@ -22148,6 +22516,7 @@ __export(text_exports, {
|
|
|
22148
22516
|
hasDesignAdvances: () => hasDesignAdvances,
|
|
22149
22517
|
hasDirectSubstitution: () => hasDirectSubstitution,
|
|
22150
22518
|
hasDistinctScriptFonts: () => hasDistinctScriptFonts,
|
|
22519
|
+
mergeTextThreeWay: () => mergeTextThreeWay,
|
|
22151
22520
|
metricFontFamily: () => metricFontFamily,
|
|
22152
22521
|
parseLocaleNumber: () => parseLocaleNumber,
|
|
22153
22522
|
parsePanoseBytes: () => parsePanoseBytes,
|
|
@@ -23014,7 +23383,7 @@ function segmentByFont(text3, fonts) {
|
|
|
23014
23383
|
var u16 = (v, o) => o + 2 <= v.byteLength ? v.getUint16(o) : 0;
|
|
23015
23384
|
var i16 = (v, o) => o + 2 <= v.byteLength ? v.getInt16(o) : 0;
|
|
23016
23385
|
var u32 = (v, o) => o + 4 <= v.byteLength ? v.getUint32(o) : 0;
|
|
23017
|
-
var
|
|
23386
|
+
var tag2 = (v, o) => String.fromCharCode(v.getUint8(o), v.getUint8(o + 1), v.getUint8(o + 2), v.getUint8(o + 3));
|
|
23018
23387
|
function format4(view, at2) {
|
|
23019
23388
|
const segments = u16(view, at2 + 6) / 2;
|
|
23020
23389
|
const ends = at2 + 14;
|
|
@@ -23073,9 +23442,9 @@ function characterMap(view, table) {
|
|
|
23073
23442
|
function parseTrueType(data) {
|
|
23074
23443
|
if (data.length < 12) return void 0;
|
|
23075
23444
|
const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
|
|
23076
|
-
const base =
|
|
23445
|
+
const base = tag2(view, 0) === "ttcf" ? u32(view, 12) : 0;
|
|
23077
23446
|
if (base + 12 > data.length) return void 0;
|
|
23078
|
-
if (u32(view, base) !== 65536 &&
|
|
23447
|
+
if (u32(view, base) !== 65536 && tag2(view, base) !== "true") return void 0;
|
|
23079
23448
|
const count = u16(view, base + 4);
|
|
23080
23449
|
const tables = /* @__PURE__ */ new Map();
|
|
23081
23450
|
for (let index = 0; index < count; index++) {
|
|
@@ -23084,7 +23453,7 @@ function parseTrueType(data) {
|
|
|
23084
23453
|
const offset = u32(view, entry3 + 8);
|
|
23085
23454
|
const length = u32(view, entry3 + 12);
|
|
23086
23455
|
if (offset + length > data.length) return void 0;
|
|
23087
|
-
tables.set(
|
|
23456
|
+
tables.set(tag2(view, entry3), { offset, length });
|
|
23088
23457
|
}
|
|
23089
23458
|
const head = tables.get("head");
|
|
23090
23459
|
const hhea = tables.get("hhea");
|
|
@@ -23271,7 +23640,7 @@ function normalizeLocale(input, supported, fallback, options2 = {}) {
|
|
|
23271
23640
|
const parts = (input ?? "").trim().toLowerCase().split(/[-_]/).filter(Boolean);
|
|
23272
23641
|
const language = parts[0];
|
|
23273
23642
|
if (!language) return fallback;
|
|
23274
|
-
const find = (
|
|
23643
|
+
const find = (tag3) => supported.find((item2) => item2.toLowerCase() === tag3);
|
|
23275
23644
|
const exact = find(parts.join("-"));
|
|
23276
23645
|
if (exact) return exact;
|
|
23277
23646
|
const base = find(language);
|
|
@@ -23628,8 +23997,11 @@ var embedding_exports = {};
|
|
|
23628
23997
|
__export(embedding_exports, {
|
|
23629
23998
|
EDITOR_CAPABILITY_IDS: () => EDITOR_CAPABILITY_IDS,
|
|
23630
23999
|
FILE_COMMAND_EVENT: () => FILE_COMMAND_EVENT,
|
|
24000
|
+
StorageConflictError: () => StorageConflictError,
|
|
23631
24001
|
acceptedHostBackstagePages: () => acceptedHostBackstagePages,
|
|
23632
24002
|
capabilityHiddenActions: () => capabilityHiddenActions,
|
|
24003
|
+
createStorageMerger: () => createStorageMerger,
|
|
24004
|
+
createStorageSession: () => createStorageSession,
|
|
23633
24005
|
disabledCapabilities: () => disabledCapabilities,
|
|
23634
24006
|
documentMimeType: () => documentMimeType,
|
|
23635
24007
|
documentSaveMeta: () => documentSaveMeta,
|
|
@@ -23855,6 +24227,210 @@ function sameItems(a2, b) {
|
|
|
23855
24227
|
return a2 === b || a2.length === b.length && a2.every((item2, index) => Object.is(item2, b[index]));
|
|
23856
24228
|
}
|
|
23857
24229
|
|
|
24230
|
+
// embedding/versioned-storage.ts
|
|
24231
|
+
var StorageConflictError = class extends Error {
|
|
24232
|
+
constructor(conflict) {
|
|
24233
|
+
super(
|
|
24234
|
+
"The changes could not be combined automatically. Your edits are retained for resolution."
|
|
24235
|
+
);
|
|
24236
|
+
this.conflict = conflict;
|
|
24237
|
+
this.name = "StorageConflictError";
|
|
24238
|
+
}
|
|
24239
|
+
conflict;
|
|
24240
|
+
};
|
|
24241
|
+
|
|
24242
|
+
// embedding/storage-merge.ts
|
|
24243
|
+
function createStorageMerger(handlers, options2 = {}) {
|
|
24244
|
+
const registry = new Map(Object.entries(handlers));
|
|
24245
|
+
return (input) => {
|
|
24246
|
+
input.signal?.throwIfAborted();
|
|
24247
|
+
const handler = registry.has(input.kind) ? registry.get(input.kind) : options2.fallback;
|
|
24248
|
+
return handler ? runStorageMerge(handler, input) : {
|
|
24249
|
+
status: "unresolved",
|
|
24250
|
+
issues: [`unsupported-merge-kind:${input.kind}`]
|
|
24251
|
+
};
|
|
24252
|
+
};
|
|
24253
|
+
}
|
|
24254
|
+
async function runStorageMerge(merge, input) {
|
|
24255
|
+
const { signal } = input;
|
|
24256
|
+
signal?.throwIfAborted();
|
|
24257
|
+
if (!signal) return merge(input);
|
|
24258
|
+
let abort = () => {
|
|
24259
|
+
};
|
|
24260
|
+
try {
|
|
24261
|
+
return await Promise.race([
|
|
24262
|
+
merge(input),
|
|
24263
|
+
new Promise((_, reject2) => {
|
|
24264
|
+
abort = () => reject2(signal.reason);
|
|
24265
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
24266
|
+
if (signal.aborted) abort();
|
|
24267
|
+
})
|
|
24268
|
+
]);
|
|
24269
|
+
} finally {
|
|
24270
|
+
signal.removeEventListener("abort", abort);
|
|
24271
|
+
}
|
|
24272
|
+
}
|
|
24273
|
+
|
|
24274
|
+
// embedding/storage-session.ts
|
|
24275
|
+
function createStorageSession(client, opened, settings = {}) {
|
|
24276
|
+
const cloneFile = settings.cloneFile ?? ((file) => structuredClone(file));
|
|
24277
|
+
const clone2 = (value) => ({
|
|
24278
|
+
file: cloneFile(value.file),
|
|
24279
|
+
bytes: value.bytes.slice()
|
|
24280
|
+
});
|
|
24281
|
+
const equal3 = (a2, b) => a2.length === b.length && a2.every((value, index) => value === b[index]);
|
|
24282
|
+
const cloneConflict = (value) => ({
|
|
24283
|
+
base: clone2(value.base),
|
|
24284
|
+
local: value.local.slice(),
|
|
24285
|
+
remote: clone2(value.remote),
|
|
24286
|
+
...value.issues ? { issues: [...value.issues] } : {}
|
|
24287
|
+
});
|
|
24288
|
+
const merge = settings.merge;
|
|
24289
|
+
const maxRebases = settings.maxMergeAttempts ?? (merge ? 3 : 1);
|
|
24290
|
+
if (!Number.isInteger(maxRebases) || maxRebases < 1 || maxRebases > 10)
|
|
24291
|
+
throw new RangeError("Storage merge attempts must be an integer from 1 to 10.");
|
|
24292
|
+
let base = clone2(opened);
|
|
24293
|
+
let acknowledgedLocal = opened.bytes.slice();
|
|
24294
|
+
let local = opened.bytes.slice();
|
|
24295
|
+
let conflict = null;
|
|
24296
|
+
let pending = Promise.resolve();
|
|
24297
|
+
function enqueue(run2) {
|
|
24298
|
+
const result = pending.then(run2);
|
|
24299
|
+
pending = result.catch(() => {
|
|
24300
|
+
});
|
|
24301
|
+
return result;
|
|
24302
|
+
}
|
|
24303
|
+
function adopt(next, submitted = next.bytes) {
|
|
24304
|
+
base = clone2(next);
|
|
24305
|
+
acknowledgedLocal = submitted.slice();
|
|
24306
|
+
local = next.bytes.slice();
|
|
24307
|
+
conflict = null;
|
|
24308
|
+
}
|
|
24309
|
+
async function save(snapshot2, options2) {
|
|
24310
|
+
local = snapshot2.slice();
|
|
24311
|
+
conflict = null;
|
|
24312
|
+
let ancestor = clone2(base);
|
|
24313
|
+
let candidate = snapshot2.slice();
|
|
24314
|
+
let rebases = 0;
|
|
24315
|
+
if (merge && !equal3(acknowledgedLocal, base.bytes)) {
|
|
24316
|
+
conflict = {
|
|
24317
|
+
base: { file: cloneFile(base.file), bytes: acknowledgedLocal.slice() },
|
|
24318
|
+
local: candidate.slice(),
|
|
24319
|
+
remote: clone2(base)
|
|
24320
|
+
};
|
|
24321
|
+
candidate = await mergeConflict(conflict, options2);
|
|
24322
|
+
local = candidate.slice();
|
|
24323
|
+
}
|
|
24324
|
+
while (true) {
|
|
24325
|
+
options2?.signal?.throwIfAborted();
|
|
24326
|
+
try {
|
|
24327
|
+
const file = await client.save(ancestor.file, candidate, options2);
|
|
24328
|
+
adopt({ file, bytes: candidate }, snapshot2);
|
|
24329
|
+
return cloneFile(file);
|
|
24330
|
+
} catch (error) {
|
|
24331
|
+
if (!client.isConflict(error)) throw error;
|
|
24332
|
+
}
|
|
24333
|
+
const remote = await client.read(ancestor.file, options2);
|
|
24334
|
+
if (remote.file.kind !== ancestor.file.kind) {
|
|
24335
|
+
conflict = {
|
|
24336
|
+
base: clone2(ancestor),
|
|
24337
|
+
local: candidate.slice(),
|
|
24338
|
+
remote: clone2(remote),
|
|
24339
|
+
issues: ["file-format-changed"]
|
|
24340
|
+
};
|
|
24341
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
24342
|
+
cloneConflict(conflict)
|
|
24343
|
+
);
|
|
24344
|
+
}
|
|
24345
|
+
if (equal3(candidate, remote.bytes)) {
|
|
24346
|
+
adopt(remote, snapshot2);
|
|
24347
|
+
return cloneFile(remote.file);
|
|
24348
|
+
}
|
|
24349
|
+
conflict = { base: clone2(ancestor), local: candidate.slice(), remote: clone2(remote) };
|
|
24350
|
+
if (rebases >= maxRebases) {
|
|
24351
|
+
conflict.issues = ["remote-keeps-changing"];
|
|
24352
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
24353
|
+
cloneConflict(conflict)
|
|
24354
|
+
);
|
|
24355
|
+
}
|
|
24356
|
+
rebases++;
|
|
24357
|
+
if (!equal3(ancestor.bytes, remote.bytes)) {
|
|
24358
|
+
if (!merge)
|
|
24359
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
24360
|
+
cloneConflict(conflict)
|
|
24361
|
+
);
|
|
24362
|
+
candidate = await mergeConflict(conflict, options2);
|
|
24363
|
+
local = candidate.slice();
|
|
24364
|
+
}
|
|
24365
|
+
ancestor = clone2(remote);
|
|
24366
|
+
}
|
|
24367
|
+
}
|
|
24368
|
+
async function mergeConflict(value, options2) {
|
|
24369
|
+
let result;
|
|
24370
|
+
try {
|
|
24371
|
+
result = await runStorageMerge(merge, {
|
|
24372
|
+
...cloneConflict(value),
|
|
24373
|
+
kind: value.base.file.kind,
|
|
24374
|
+
...options2?.signal ? { signal: options2.signal } : {}
|
|
24375
|
+
});
|
|
24376
|
+
} catch {
|
|
24377
|
+
options2?.signal?.throwIfAborted();
|
|
24378
|
+
value.issues = ["merge-failed"];
|
|
24379
|
+
throw (settings.conflictError ?? ((value2) => new StorageConflictError(value2)))(
|
|
24380
|
+
cloneConflict(value)
|
|
24381
|
+
);
|
|
24382
|
+
}
|
|
24383
|
+
options2?.signal?.throwIfAborted();
|
|
24384
|
+
if (!result || result.status !== "merged" || !(result.bytes instanceof Uint8Array) || !result.bytes.length) {
|
|
24385
|
+
value.issues = result?.status === "unresolved" && Array.isArray(result.issues) ? result.issues.filter((issue) => typeof issue === "string") : ["invalid-merge-result"];
|
|
24386
|
+
throw (settings.conflictError ?? ((value2) => new StorageConflictError(value2)))(
|
|
24387
|
+
cloneConflict(value)
|
|
24388
|
+
);
|
|
24389
|
+
}
|
|
24390
|
+
return result.bytes.slice();
|
|
24391
|
+
}
|
|
24392
|
+
const session = {
|
|
24393
|
+
getSnapshot: () => ({
|
|
24394
|
+
file: cloneFile(base.file),
|
|
24395
|
+
baseBytes: base.bytes.slice(),
|
|
24396
|
+
conflict: conflict ? cloneConflict(conflict) : null
|
|
24397
|
+
}),
|
|
24398
|
+
save(bytes, options2) {
|
|
24399
|
+
const snapshot2 = bytes.slice();
|
|
24400
|
+
return enqueue(() => save(snapshot2, options2));
|
|
24401
|
+
},
|
|
24402
|
+
reload(options2) {
|
|
24403
|
+
return enqueue(async () => {
|
|
24404
|
+
const next = await client.read(base.file, options2);
|
|
24405
|
+
adopt(next);
|
|
24406
|
+
return clone2(next);
|
|
24407
|
+
});
|
|
24408
|
+
},
|
|
24409
|
+
saveCopy(bytes, name, options2) {
|
|
24410
|
+
const snapshot2 = bytes?.slice();
|
|
24411
|
+
return enqueue(async () => {
|
|
24412
|
+
if (!client.saveCopy)
|
|
24413
|
+
throw new Error("This storage provider does not support saving copies.");
|
|
24414
|
+
const next = await client.saveCopy(base.file, snapshot2 ?? local, name, options2);
|
|
24415
|
+
adopt(next);
|
|
24416
|
+
return clone2(next);
|
|
24417
|
+
});
|
|
24418
|
+
},
|
|
24419
|
+
storage: {
|
|
24420
|
+
async save(bytes, meta) {
|
|
24421
|
+
settings.validateSave?.(meta, cloneFile(base.file));
|
|
24422
|
+
if (meta.reason === "saveAs") {
|
|
24423
|
+
const result2 = await session.saveCopy(bytes, meta.fileName);
|
|
24424
|
+
return { fileName: result2.file.name };
|
|
24425
|
+
}
|
|
24426
|
+
const result = await session.save(bytes);
|
|
24427
|
+
return { fileName: result.name };
|
|
24428
|
+
}
|
|
24429
|
+
}
|
|
24430
|
+
};
|
|
24431
|
+
return session;
|
|
24432
|
+
}
|
|
24433
|
+
|
|
23858
24434
|
// diagram/index.ts
|
|
23859
24435
|
var diagram_exports = {};
|
|
23860
24436
|
__export(diagram_exports, {
|
|
@@ -24276,10 +24852,10 @@ function parseAttributes(source2) {
|
|
|
24276
24852
|
}
|
|
24277
24853
|
return attrs2;
|
|
24278
24854
|
}
|
|
24279
|
-
function tagEnd(
|
|
24855
|
+
function tagEnd(xml2, from) {
|
|
24280
24856
|
let quote = "";
|
|
24281
|
-
for (let i2 = from; i2 <
|
|
24282
|
-
const ch =
|
|
24857
|
+
for (let i2 = from; i2 < xml2.length; i2++) {
|
|
24858
|
+
const ch = xml2[i2];
|
|
24283
24859
|
if (quote) {
|
|
24284
24860
|
if (ch === quote) {
|
|
24285
24861
|
quote = "";
|
|
@@ -24292,27 +24868,27 @@ function tagEnd(xml, from) {
|
|
|
24292
24868
|
}
|
|
24293
24869
|
return -1;
|
|
24294
24870
|
}
|
|
24295
|
-
function parseOrderedXml(
|
|
24871
|
+
function parseOrderedXml(xml2) {
|
|
24296
24872
|
const root = { name: "#document", attrs: {}, children: [] };
|
|
24297
24873
|
const stack = [root];
|
|
24298
|
-
let i2 =
|
|
24299
|
-
while (i2 >= 0 && i2 <
|
|
24300
|
-
if (
|
|
24301
|
-
const close =
|
|
24302
|
-
i2 = close < 0 ? -1 :
|
|
24874
|
+
let i2 = xml2.indexOf("<");
|
|
24875
|
+
while (i2 >= 0 && i2 < xml2.length) {
|
|
24876
|
+
if (xml2.startsWith("<!--", i2)) {
|
|
24877
|
+
const close = xml2.indexOf("-->", i2 + 4);
|
|
24878
|
+
i2 = close < 0 ? -1 : xml2.indexOf("<", close + 3);
|
|
24303
24879
|
continue;
|
|
24304
24880
|
}
|
|
24305
|
-
if (
|
|
24306
|
-
const close =
|
|
24307
|
-
i2 = close < 0 ? -1 :
|
|
24881
|
+
if (xml2.startsWith("<![CDATA[", i2)) {
|
|
24882
|
+
const close = xml2.indexOf("]]>", i2 + 9);
|
|
24883
|
+
i2 = close < 0 ? -1 : xml2.indexOf("<", close + 3);
|
|
24308
24884
|
continue;
|
|
24309
24885
|
}
|
|
24310
|
-
const end = tagEnd(
|
|
24886
|
+
const end = tagEnd(xml2, i2 + 1);
|
|
24311
24887
|
if (end < 0) {
|
|
24312
24888
|
break;
|
|
24313
24889
|
}
|
|
24314
|
-
const next =
|
|
24315
|
-
const first2 =
|
|
24890
|
+
const next = xml2.indexOf("<", end + 1);
|
|
24891
|
+
const first2 = xml2[i2 + 1];
|
|
24316
24892
|
if (first2 === "?" || first2 === "!") {
|
|
24317
24893
|
i2 = next;
|
|
24318
24894
|
continue;
|
|
@@ -24320,11 +24896,11 @@ function parseOrderedXml(xml) {
|
|
|
24320
24896
|
const closing = first2 === "/";
|
|
24321
24897
|
let cursor = closing ? i2 + 2 : i2 + 1;
|
|
24322
24898
|
const nameStart = cursor;
|
|
24323
|
-
while (cursor < end && isNameChar2(
|
|
24899
|
+
while (cursor < end && isNameChar2(xml2[cursor])) {
|
|
24324
24900
|
cursor++;
|
|
24325
24901
|
}
|
|
24326
|
-
const
|
|
24327
|
-
if (!
|
|
24902
|
+
const tag3 = xml2.slice(nameStart, cursor);
|
|
24903
|
+
if (!tag3) {
|
|
24328
24904
|
i2 = next;
|
|
24329
24905
|
continue;
|
|
24330
24906
|
}
|
|
@@ -24335,10 +24911,10 @@ function parseOrderedXml(xml) {
|
|
|
24335
24911
|
i2 = next;
|
|
24336
24912
|
continue;
|
|
24337
24913
|
}
|
|
24338
|
-
const selfClosing =
|
|
24914
|
+
const selfClosing = xml2[end - 1] === "/";
|
|
24339
24915
|
const element4 = {
|
|
24340
|
-
name: localName(
|
|
24341
|
-
attrs: parseAttributes(
|
|
24916
|
+
name: localName(tag3),
|
|
24917
|
+
attrs: parseAttributes(xml2.slice(cursor, selfClosing ? end - 1 : end)),
|
|
24342
24918
|
children: []
|
|
24343
24919
|
};
|
|
24344
24920
|
stack[stack.length - 1].children.push(element4);
|
|
@@ -24548,8 +25124,8 @@ function parseStatement(element4, state) {
|
|
|
24548
25124
|
return void 0;
|
|
24549
25125
|
}
|
|
24550
25126
|
}
|
|
24551
|
-
function parseLayoutDefinitionXml(
|
|
24552
|
-
const document = parseOrderedXml(
|
|
25127
|
+
function parseLayoutDefinitionXml(xml2) {
|
|
25128
|
+
const document = parseOrderedXml(xml2);
|
|
24553
25129
|
const layoutDef = document?.name === "layoutDef" ? document : findOrderedDescendant(document, "layoutDef");
|
|
24554
25130
|
const rootElement = layoutDef?.children.find((child6) => child6.name === "layoutNode");
|
|
24555
25131
|
if (!layoutDef || !rootElement) {
|
|
@@ -47863,9 +48439,9 @@ function dataModelExtXml(drawingRelId) {
|
|
|
47863
48439
|
}
|
|
47864
48440
|
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>`;
|
|
47865
48441
|
}
|
|
47866
|
-
function withDiagramXmlProlog(
|
|
47867
|
-
return /^\s*<\?xml\b/u.test(
|
|
47868
|
-
${
|
|
48442
|
+
function withDiagramXmlProlog(xml2) {
|
|
48443
|
+
return /^\s*<\?xml\b/u.test(xml2) ? xml2 : `${DIAGRAM_XML_PROLOG}\r
|
|
48444
|
+
${xml2}`;
|
|
47869
48445
|
}
|
|
47870
48446
|
|
|
47871
48447
|
// diagram/write/fabricated-styles.ts
|
|
@@ -48114,12 +48690,12 @@ function writeDiagramFormatDefinition(source2, change) {
|
|
|
48114
48690
|
return buildXml(doc);
|
|
48115
48691
|
}
|
|
48116
48692
|
function formatDiagramSource(source2, change) {
|
|
48117
|
-
const
|
|
48693
|
+
const xml2 = writeDiagramFormatDefinition(
|
|
48118
48694
|
change.kind === "colors" ? source2?.colorsXml : source2?.quickStyleXml,
|
|
48119
48695
|
change
|
|
48120
48696
|
);
|
|
48121
48697
|
const id = `urn:ooxml-core/${change.kind}/${change.value}`;
|
|
48122
|
-
return change.kind === "colors" ? { source: { ...source2, colorsXml:
|
|
48698
|
+
return change.kind === "colors" ? { source: { ...source2, colorsXml: xml2 }, colorsId: id } : { source: { ...source2, quickStyleXml: xml2 }, quickStyleId: id };
|
|
48123
48699
|
}
|
|
48124
48700
|
|
|
48125
48701
|
// diagram/write/data-edit.ts
|
|
@@ -48225,9 +48801,9 @@ function dropDrawingExtension(model) {
|
|
|
48225
48801
|
if (ext.getAttribute("uri") === DSP_EXT_URI) extLst.removeChild(ext);
|
|
48226
48802
|
if (elements(extLst).length === 0) model.removeChild(extLst);
|
|
48227
48803
|
}
|
|
48228
|
-
function writeEditedDiagramData(
|
|
48804
|
+
function writeEditedDiagramData(xml2, nodes, options2 = {}) {
|
|
48229
48805
|
const createModelId = options2.createModelId ?? createOfficeGuid;
|
|
48230
|
-
const doc = parseXml(
|
|
48806
|
+
const doc = parseXml(xml2, { label: "diagram data" });
|
|
48231
48807
|
const model = doc.documentElement;
|
|
48232
48808
|
const ptLst = child4(model, "ptLst");
|
|
48233
48809
|
if (!ptLst) throw new Error("The diagram data part has no point list.");
|
|
@@ -48665,8 +49241,8 @@ function sha256(data) {
|
|
|
48665
49241
|
// diagram/cache-metadata.ts
|
|
48666
49242
|
var GENERATED_DIAGRAM_CACHE_NS = "urn:ooxml-core:diagram:generated-cache";
|
|
48667
49243
|
var GENERATED_DIAGRAM_CACHE_NOTICE = "Generated SmartArt preview; not native Office layout.";
|
|
48668
|
-
var generatedDrawingDigest = (
|
|
48669
|
-
sha256(new TextEncoder().encode(
|
|
49244
|
+
var generatedDrawingDigest = (xml2) => Array.from(
|
|
49245
|
+
sha256(new TextEncoder().encode(xml2)),
|
|
48670
49246
|
(byte) => byte.toString(16).padStart(2, "0")
|
|
48671
49247
|
).join("");
|
|
48672
49248
|
var DEFAULT_GENERATED_DIAGRAM_SCHEME = {
|
|
@@ -49101,6 +49677,7 @@ __export(opc_exports, {
|
|
|
49101
49677
|
isSafePartName: () => isSafePartName,
|
|
49102
49678
|
isStorableHyperlinkHref: () => isStorableHyperlinkHref,
|
|
49103
49679
|
listEmbeddedPackages: () => listEmbeddedPackages,
|
|
49680
|
+
mergeOpcSnapshots: () => mergeOpcSnapshots,
|
|
49104
49681
|
nextRelationshipId: () => nextRelationshipId,
|
|
49105
49682
|
openZip: () => openZip,
|
|
49106
49683
|
parseAppProperties: () => parseAppProperties,
|
|
@@ -49178,11 +49755,11 @@ var RELATIONSHIP_TYPES = {
|
|
|
49178
49755
|
|
|
49179
49756
|
// opc/content-types.ts
|
|
49180
49757
|
var escapeAttr2 = (value) => value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
49181
|
-
function parseContentTypes(
|
|
49758
|
+
function parseContentTypes(xml2) {
|
|
49182
49759
|
const defaults = /* @__PURE__ */ new Map();
|
|
49183
49760
|
const overrides = /* @__PURE__ */ new Map();
|
|
49184
|
-
if (!
|
|
49185
|
-
for (const node of elements(parseXml(
|
|
49761
|
+
if (!xml2) return { defaults, overrides };
|
|
49762
|
+
for (const node of elements(parseXml(xml2).documentElement)) {
|
|
49186
49763
|
const contentType = node.getAttribute("ContentType");
|
|
49187
49764
|
if (!contentType) continue;
|
|
49188
49765
|
if (node.localName === "Default") {
|
|
@@ -49211,9 +49788,9 @@ function buildContentTypesXml(types) {
|
|
|
49211
49788
|
).join("");
|
|
49212
49789
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="${NS.contentTypes}">${defaults}${overrides}</Types>`;
|
|
49213
49790
|
}
|
|
49214
|
-
function ensureContentTypeDefault(
|
|
49215
|
-
const types = parseContentTypes(
|
|
49216
|
-
if (types.defaults.has(extension.toLowerCase())) return
|
|
49791
|
+
function ensureContentTypeDefault(xml2, extension, contentType) {
|
|
49792
|
+
const types = parseContentTypes(xml2);
|
|
49793
|
+
if (types.defaults.has(extension.toLowerCase())) return xml2 ?? buildContentTypesXml(types);
|
|
49217
49794
|
types.defaults.set(extension.toLowerCase(), contentType);
|
|
49218
49795
|
return buildContentTypesXml(types);
|
|
49219
49796
|
}
|
|
@@ -49223,35 +49800,35 @@ var CONTENT_TYPES_PATH = "[Content_Types].xml";
|
|
|
49223
49800
|
var XML_DECLARATION = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
|
|
49224
49801
|
var EMPTY_TYPES = `${XML_DECLARATION}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"></Types>`;
|
|
49225
49802
|
var EMPTY_RELS = `${XML_DECLARATION}<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>`;
|
|
49226
|
-
function attr2(
|
|
49803
|
+
function attr2(tag3, name) {
|
|
49227
49804
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
49228
|
-
const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(
|
|
49805
|
+
const match = new RegExp(`(?<=[\\s<])${escaped}\\s*=\\s*(?:"([^"]*)"|'([^']*)')`).exec(tag3);
|
|
49229
49806
|
return match ? match[1] ?? match[2] : void 0;
|
|
49230
49807
|
}
|
|
49231
49808
|
async function ensureContentTypeOverride(zip, partName, contentType) {
|
|
49232
|
-
const
|
|
49809
|
+
const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string") ?? EMPTY_TYPES;
|
|
49233
49810
|
const target = `/${partName}`;
|
|
49234
|
-
for (const
|
|
49235
|
-
if (attr2(
|
|
49811
|
+
for (const tag3 of xml2.match(/<Override\b[^>]*\/>/g) ?? [])
|
|
49812
|
+
if (attr2(tag3, "PartName") === target) return;
|
|
49236
49813
|
const insertion = `<Override PartName="${target}" ContentType="${contentType}"/>`;
|
|
49237
|
-
zip.file(CONTENT_TYPES_PATH,
|
|
49814
|
+
zip.file(CONTENT_TYPES_PATH, xml2.replace("</Types>", `${insertion}</Types>`));
|
|
49238
49815
|
}
|
|
49239
49816
|
async function removeContentTypeOverride(zip, partName) {
|
|
49240
|
-
const
|
|
49241
|
-
if (!
|
|
49817
|
+
const xml2 = await zip.file(CONTENT_TYPES_PATH)?.async("string");
|
|
49818
|
+
if (!xml2) return;
|
|
49242
49819
|
const target = `/${partName}`;
|
|
49243
|
-
const
|
|
49820
|
+
const tag3 = (xml2.match(/<Override\b[^>]*\/>/g) ?? []).find(
|
|
49244
49821
|
(candidate) => attr2(candidate, "PartName") === target
|
|
49245
49822
|
);
|
|
49246
|
-
if (
|
|
49823
|
+
if (tag3) zip.file(CONTENT_TYPES_PATH, xml2.replace(tag3, ""));
|
|
49247
49824
|
}
|
|
49248
49825
|
async function ensureRelationship(zip, relsPath, type, target) {
|
|
49249
|
-
const
|
|
49826
|
+
const xml2 = await zip.file(relsPath)?.async("string") ?? EMPTY_RELS;
|
|
49250
49827
|
const used = /* @__PURE__ */ new Set();
|
|
49251
|
-
for (const
|
|
49252
|
-
const id2 = attr2(
|
|
49828
|
+
for (const tag3 of xml2.match(/<Relationship\b[^>]*\/>/g) ?? []) {
|
|
49829
|
+
const id2 = attr2(tag3, "Id");
|
|
49253
49830
|
if (id2) used.add(id2);
|
|
49254
|
-
if (id2 && attr2(
|
|
49831
|
+
if (id2 && attr2(tag3, "Type") === type && attr2(tag3, "Target") === target) return id2;
|
|
49255
49832
|
}
|
|
49256
49833
|
const highest = Math.max(
|
|
49257
49834
|
0,
|
|
@@ -49260,16 +49837,112 @@ async function ensureRelationship(zip, relsPath, type, target) {
|
|
|
49260
49837
|
let id = `rId${highest + 1}`;
|
|
49261
49838
|
if (used.has(id)) id = nextRelationshipId(used);
|
|
49262
49839
|
const insertion = `<Relationship Id="${id}" Type="${type}" Target="${target}"/>`;
|
|
49263
|
-
zip.file(relsPath,
|
|
49840
|
+
zip.file(relsPath, xml2.replace("</Relationships>", `${insertion}</Relationships>`));
|
|
49264
49841
|
return id;
|
|
49265
49842
|
}
|
|
49266
49843
|
async function findOfficeDocumentPart(zip) {
|
|
49267
|
-
const
|
|
49268
|
-
for (const
|
|
49269
|
-
if (attr2(
|
|
49844
|
+
const xml2 = await zip.file("_rels/.rels")?.async("string");
|
|
49845
|
+
for (const tag3 of xml2?.match(/<Relationship\b[^>]*\/>/g) ?? [])
|
|
49846
|
+
if (attr2(tag3, "Type") === RELATIONSHIP_TYPES.officeDocument) return attr2(tag3, "Target");
|
|
49270
49847
|
return void 0;
|
|
49271
49848
|
}
|
|
49272
49849
|
|
|
49850
|
+
// opc/merge-snapshots.ts
|
|
49851
|
+
var equal2 = (a2, b) => a2 === b || Boolean(a2 && b && a2.length === b.length && a2.every((value, index) => value === b[index]));
|
|
49852
|
+
var decoder = new TextDecoder("utf-8", { fatal: true });
|
|
49853
|
+
var encoder = new TextEncoder();
|
|
49854
|
+
function mergeManifest(input) {
|
|
49855
|
+
const { path: path3, base, local, remote } = input;
|
|
49856
|
+
if (!base || !local || !remote) return void 0;
|
|
49857
|
+
if (!path3.endsWith(".rels") && path3 !== "[Content_Types].xml" && path3 !== "docProps/core.xml")
|
|
49858
|
+
return void 0;
|
|
49859
|
+
try {
|
|
49860
|
+
const result = mergeXmlThreeWay(
|
|
49861
|
+
decoder.decode(base),
|
|
49862
|
+
decoder.decode(local),
|
|
49863
|
+
decoder.decode(remote),
|
|
49864
|
+
{
|
|
49865
|
+
keyElement: (element4) => {
|
|
49866
|
+
const attribute2 = element4.localName === "Relationship" ? "Id" : element4.localName === "Override" ? "PartName" : element4.localName === "Default" ? "Extension" : void 0;
|
|
49867
|
+
return attribute2 ? element4.getAttribute(attribute2) ?? void 0 : void 0;
|
|
49868
|
+
},
|
|
49869
|
+
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
|
|
49870
|
+
}
|
|
49871
|
+
);
|
|
49872
|
+
return result.status === "merged" ? { status: "merged", bytes: encoder.encode(result.xml) } : result;
|
|
49873
|
+
} catch {
|
|
49874
|
+
return { status: "unresolved", issues: [`${path3}: invalid metadata XML`] };
|
|
49875
|
+
}
|
|
49876
|
+
}
|
|
49877
|
+
async function mergeOpcSnapshots(baseBytes, localBytes, remoteBytes, options2 = {}) {
|
|
49878
|
+
if (equal2(localBytes, remoteBytes) || equal2(baseBytes, remoteBytes))
|
|
49879
|
+
return { status: "merged", bytes: localBytes.slice() };
|
|
49880
|
+
if (equal2(baseBytes, localBytes)) return { status: "merged", bytes: remoteBytes.slice() };
|
|
49881
|
+
try {
|
|
49882
|
+
const [base, local, remote] = await Promise.all([
|
|
49883
|
+
openZip(baseBytes, { label: "Merge" }),
|
|
49884
|
+
openZip(localBytes, { label: "Merge" }),
|
|
49885
|
+
openZip(remoteBytes, { label: "Merge" })
|
|
49886
|
+
]);
|
|
49887
|
+
const paths = [
|
|
49888
|
+
...new Set(
|
|
49889
|
+
[base, local, remote].flatMap(
|
|
49890
|
+
(zip) => Object.keys(zip.files).filter((path3) => !zip.files[path3].dir)
|
|
49891
|
+
)
|
|
49892
|
+
)
|
|
49893
|
+
].sort();
|
|
49894
|
+
if (paths.some((path3) => path3.startsWith("_xmlsignatures/")))
|
|
49895
|
+
return {
|
|
49896
|
+
status: "unresolved",
|
|
49897
|
+
issues: ["Signed packages require explicit signature handling before merging"]
|
|
49898
|
+
};
|
|
49899
|
+
const issues = [];
|
|
49900
|
+
for (const path3 of paths) {
|
|
49901
|
+
const [b, l, r] = await Promise.all(
|
|
49902
|
+
[base, local, remote].map((zip) => zip.file(path3)?.async("uint8array"))
|
|
49903
|
+
);
|
|
49904
|
+
let chosen;
|
|
49905
|
+
if (equal2(l, r) || equal2(b, r)) chosen = l;
|
|
49906
|
+
else if (equal2(b, l)) chosen = r;
|
|
49907
|
+
else {
|
|
49908
|
+
const input = {
|
|
49909
|
+
path: path3,
|
|
49910
|
+
...b ? { base: b } : {},
|
|
49911
|
+
...l ? { local: l } : {},
|
|
49912
|
+
...r ? { remote: r } : {}
|
|
49913
|
+
};
|
|
49914
|
+
const result = mergeManifest(input) ?? await options2.mergePart?.(input);
|
|
49915
|
+
if (!result || result.status === "unresolved") {
|
|
49916
|
+
issues.push(...result?.issues ?? [`${path3}: both versions changed the same part`]);
|
|
49917
|
+
continue;
|
|
49918
|
+
}
|
|
49919
|
+
chosen = result.bytes;
|
|
49920
|
+
}
|
|
49921
|
+
if (chosen) remote.file(path3, chosen);
|
|
49922
|
+
else remote.remove(path3);
|
|
49923
|
+
}
|
|
49924
|
+
if (issues.length) return { status: "unresolved", issues };
|
|
49925
|
+
for (const path3 of Object.keys(remote.files).filter((name) => name.endsWith(".rels"))) {
|
|
49926
|
+
const source2 = path3 === "_rels/.rels" ? "" : path3.replace(/(^|\/)_rels\/([^/]+)\.rels$/u, "$1$2");
|
|
49927
|
+
for (const relation2 of parseRelationships(
|
|
49928
|
+
await remote.file(path3).async("string")
|
|
49929
|
+
).values()) {
|
|
49930
|
+
if (relation2.mode === "External") continue;
|
|
49931
|
+
const target = resolvePartPath(source2, relation2.target.split("#")[0] ?? "");
|
|
49932
|
+
if (!remote.file(target) && !remote.file(decodeURIComponent(target)))
|
|
49933
|
+
issues.push(`${path3}: merged relationship target is missing`);
|
|
49934
|
+
}
|
|
49935
|
+
}
|
|
49936
|
+
if (issues.length) return { status: "unresolved", issues };
|
|
49937
|
+
return {
|
|
49938
|
+
status: "merged",
|
|
49939
|
+
bytes: await remote.generateAsync({ type: "uint8array", compression: "DEFLATE" })
|
|
49940
|
+
};
|
|
49941
|
+
} catch {
|
|
49942
|
+
return { status: "unresolved", issues: ["Invalid or oversized Office package"] };
|
|
49943
|
+
}
|
|
49944
|
+
}
|
|
49945
|
+
|
|
49273
49946
|
// opc/clone-part-graph.ts
|
|
49274
49947
|
function relativePartTarget(basePart, targetPart) {
|
|
49275
49948
|
const base = basePart.split("/").slice(0, -1);
|
|
@@ -49302,9 +49975,9 @@ async function clonePartGraph(options2) {
|
|
|
49302
49975
|
const copyRelationships = async (source2, destination) => {
|
|
49303
49976
|
const contentType = contentTypeForPart(types, source2);
|
|
49304
49977
|
if (contentType) await ensureContentTypeOverride(zip, destination, contentType);
|
|
49305
|
-
const
|
|
49306
|
-
if (!
|
|
49307
|
-
const relationships = parseRelationships(
|
|
49978
|
+
const xml2 = await sourceZip.file(relationshipsPartFor(source2))?.async("string");
|
|
49979
|
+
if (!xml2) return;
|
|
49980
|
+
const relationships = parseRelationships(xml2);
|
|
49308
49981
|
for (const relationship2 of relationships.values()) {
|
|
49309
49982
|
if (relationship2.mode === "External") continue;
|
|
49310
49983
|
const originalTarget = resolvePartPath(source2, relationship2.target);
|
|
@@ -49435,10 +50108,10 @@ var PROPERTY_CONTENT_TYPES = {
|
|
|
49435
50108
|
|
|
49436
50109
|
// opc/properties/patch.ts
|
|
49437
50110
|
var XMLNS = "http://www.w3.org/2000/xmlns/";
|
|
49438
|
-
function tagEnd2(
|
|
50111
|
+
function tagEnd2(xml2, from) {
|
|
49439
50112
|
let quote = "";
|
|
49440
|
-
for (let i2 = from + 1; i2 <
|
|
49441
|
-
const ch =
|
|
50113
|
+
for (let i2 = from + 1; i2 < xml2.length; i2++) {
|
|
50114
|
+
const ch = xml2[i2];
|
|
49442
50115
|
if (quote) {
|
|
49443
50116
|
if (ch === quote) quote = "";
|
|
49444
50117
|
} else if (ch === '"' || ch === "'") quote = ch;
|
|
@@ -49446,24 +50119,24 @@ function tagEnd2(xml, from) {
|
|
|
49446
50119
|
}
|
|
49447
50120
|
throw new Error("Unterminated tag in property part");
|
|
49448
50121
|
}
|
|
49449
|
-
function skipMarkup(
|
|
49450
|
-
if (
|
|
49451
|
-
if (
|
|
49452
|
-
if (
|
|
50122
|
+
function skipMarkup(xml2, at2) {
|
|
50123
|
+
if (xml2.startsWith("<!--", at2)) return xml2.indexOf("-->", at2) + 3;
|
|
50124
|
+
if (xml2.startsWith("<![CDATA[", at2)) return xml2.indexOf("]]>", at2) + 3;
|
|
50125
|
+
if (xml2.startsWith("<?", at2)) return xml2.indexOf("?>", at2) + 2;
|
|
49453
50126
|
return void 0;
|
|
49454
50127
|
}
|
|
49455
|
-
function scan(
|
|
50128
|
+
function scan(xml2) {
|
|
49456
50129
|
let i2 = 0;
|
|
49457
50130
|
let rootStart = -1;
|
|
49458
50131
|
while (rootStart < 0) {
|
|
49459
|
-
const lt =
|
|
50132
|
+
const lt = xml2.indexOf("<", i2);
|
|
49460
50133
|
if (lt < 0) throw new Error("Property part has no root element");
|
|
49461
|
-
const skipped = skipMarkup(
|
|
50134
|
+
const skipped = skipMarkup(xml2, lt);
|
|
49462
50135
|
if (skipped !== void 0) i2 = skipped;
|
|
49463
50136
|
else rootStart = lt;
|
|
49464
50137
|
}
|
|
49465
|
-
const openEnd = tagEnd2(
|
|
49466
|
-
if (
|
|
50138
|
+
const openEnd = tagEnd2(xml2, rootStart);
|
|
50139
|
+
if (xml2[openEnd - 2] === "/") {
|
|
49467
50140
|
const root = {
|
|
49468
50141
|
start: rootStart,
|
|
49469
50142
|
openEnd,
|
|
@@ -49478,16 +50151,16 @@ function scan(xml) {
|
|
|
49478
50151
|
let child6;
|
|
49479
50152
|
i2 = openEnd;
|
|
49480
50153
|
for (; ; ) {
|
|
49481
|
-
const lt =
|
|
50154
|
+
const lt = xml2.indexOf("<", i2);
|
|
49482
50155
|
if (lt < 0) throw new Error("Property part root is not closed");
|
|
49483
|
-
const skipped = skipMarkup(
|
|
50156
|
+
const skipped = skipMarkup(xml2, lt);
|
|
49484
50157
|
if (skipped !== void 0) {
|
|
49485
50158
|
i2 = skipped;
|
|
49486
50159
|
continue;
|
|
49487
50160
|
}
|
|
49488
|
-
const end = tagEnd2(
|
|
50161
|
+
const end = tagEnd2(xml2, lt);
|
|
49489
50162
|
i2 = end;
|
|
49490
|
-
if (
|
|
50163
|
+
if (xml2[lt + 1] === "/") {
|
|
49491
50164
|
if (depth === 0) {
|
|
49492
50165
|
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
49493
50166
|
return { root, children: children2 };
|
|
@@ -49495,7 +50168,7 @@ function scan(xml) {
|
|
|
49495
50168
|
depth--;
|
|
49496
50169
|
if (depth === 0 && child6)
|
|
49497
50170
|
children2.push({ ...child6, closeStart: lt, end, selfClosing: false });
|
|
49498
|
-
} else if (
|
|
50171
|
+
} else if (xml2[end - 2] === "/") {
|
|
49499
50172
|
if (depth === 0)
|
|
49500
50173
|
children2.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
49501
50174
|
} else {
|
|
@@ -49505,11 +50178,11 @@ function scan(xml) {
|
|
|
49505
50178
|
}
|
|
49506
50179
|
}
|
|
49507
50180
|
var escapeText2 = (text3) => text3.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
49508
|
-
var qualifiedName = (
|
|
50181
|
+
var qualifiedName = (xml2, span) => /^<([^\s/>]+)/.exec(xml2.slice(span.start, span.openEnd))?.[1] ?? "";
|
|
49509
50182
|
var PartPatch = class {
|
|
49510
|
-
constructor(
|
|
49511
|
-
this.xml =
|
|
49512
|
-
const { root, children: children2 } = scan(
|
|
50183
|
+
constructor(xml2, rootElement) {
|
|
50184
|
+
this.xml = xml2;
|
|
50185
|
+
const { root, children: children2 } = scan(xml2);
|
|
49513
50186
|
const kids = elements(rootElement);
|
|
49514
50187
|
if (kids.length !== children2.length) throw new Error("Property part markup is not supported");
|
|
49515
50188
|
kids.forEach((kid, index) => this.spans.set(kid, children2[index]));
|
|
@@ -49624,10 +50297,10 @@ var FIELDS2 = [
|
|
|
49624
50297
|
var CORE_PROPERTY_FIELDS = FIELDS2.map(([field]) => field);
|
|
49625
50298
|
var EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
49626
50299
|
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
49627
|
-
function parseCoreProperties(
|
|
50300
|
+
function parseCoreProperties(xml2) {
|
|
49628
50301
|
const out = {};
|
|
49629
|
-
if (!
|
|
49630
|
-
const root = parseXml(
|
|
50302
|
+
if (!xml2) return out;
|
|
50303
|
+
const root = parseXml(xml2, { label: "core properties" }).documentElement;
|
|
49631
50304
|
for (const [field, prefix] of FIELDS2) {
|
|
49632
50305
|
const text3 = first(root, field, NS[prefix])?.textContent ?? "";
|
|
49633
50306
|
if (text3 !== "") out[field] = text3;
|
|
@@ -49636,9 +50309,9 @@ function parseCoreProperties(xml) {
|
|
|
49636
50309
|
}
|
|
49637
50310
|
var formatW3cdtf = (date) => date.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
49638
50311
|
function writeCoreProperties(props, sourceXml) {
|
|
49639
|
-
const
|
|
49640
|
-
const root = parseXml(
|
|
49641
|
-
const patch = new PartPatch(
|
|
50312
|
+
const xml2 = sourceXml ?? EMPTY_CORE;
|
|
50313
|
+
const root = parseXml(xml2, { label: "core properties" }).documentElement;
|
|
50314
|
+
const patch = new PartPatch(xml2, root);
|
|
49642
50315
|
for (const [field, prefix, isDate] of FIELDS2) {
|
|
49643
50316
|
const ns = NS[prefix];
|
|
49644
50317
|
const value = props[field];
|
|
@@ -49736,9 +50409,9 @@ function readKnown(root, ns) {
|
|
|
49736
50409
|
}
|
|
49737
50410
|
return out;
|
|
49738
50411
|
}
|
|
49739
|
-
function parseAppProperties(
|
|
49740
|
-
if (!
|
|
49741
|
-
const root = parseXml(
|
|
50412
|
+
function parseAppProperties(xml2) {
|
|
50413
|
+
if (!xml2) return {};
|
|
50414
|
+
const root = parseXml(xml2, { label: "app properties" }).documentElement;
|
|
49742
50415
|
const ns = namespacesOf(root);
|
|
49743
50416
|
return ns ? readKnown(root, ns) : {};
|
|
49744
50417
|
}
|
|
@@ -49756,11 +50429,11 @@ function content(kind, value, vt) {
|
|
|
49756
50429
|
return `<${vt}:vector size="${items.length}" baseType="${baseType}">${items.join("")}</${vt}:vector>`;
|
|
49757
50430
|
}
|
|
49758
50431
|
function writeAppProperties(props, sourceXml) {
|
|
49759
|
-
const
|
|
49760
|
-
const root = parseXml(
|
|
50432
|
+
const xml2 = sourceXml ?? EMPTY_APP;
|
|
50433
|
+
const root = parseXml(xml2, { label: "app properties" }).documentElement;
|
|
49761
50434
|
const ns = namespacesOf(root);
|
|
49762
50435
|
if (!ns) throw new Error("app properties root is not an extended-properties element");
|
|
49763
|
-
const patch = new PartPatch(
|
|
50436
|
+
const patch = new PartPatch(xml2, root);
|
|
49764
50437
|
const prior = readKnown(root, ns);
|
|
49765
50438
|
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
49766
50439
|
FIELDS3.forEach(([field, local, kind], index) => {
|
|
@@ -49811,9 +50484,9 @@ function readValue(variant) {
|
|
|
49811
50484
|
return void 0;
|
|
49812
50485
|
}
|
|
49813
50486
|
}
|
|
49814
|
-
function parseCustomProperties(
|
|
49815
|
-
if (!
|
|
49816
|
-
const root = parseXml(
|
|
50487
|
+
function parseCustomProperties(xml2) {
|
|
50488
|
+
if (!xml2) return [];
|
|
50489
|
+
const root = parseXml(xml2, { label: "custom properties" }).documentElement;
|
|
49817
50490
|
const out = [];
|
|
49818
50491
|
for (const property of children(root, "property", NS.customProperties)) {
|
|
49819
50492
|
const name = property.getAttribute("name") ?? "";
|
|
@@ -49879,9 +50552,9 @@ function writeCustomProperties(properties) {
|
|
|
49879
50552
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
49880
50553
|
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
49881
50554
|
}
|
|
49882
|
-
function parseCustomPropertyTexts(
|
|
49883
|
-
if (!
|
|
49884
|
-
const root = parseXml(
|
|
50555
|
+
function parseCustomPropertyTexts(xml2) {
|
|
50556
|
+
if (!xml2) return [];
|
|
50557
|
+
const root = parseXml(xml2, { label: "custom properties" }).documentElement;
|
|
49885
50558
|
const out = [];
|
|
49886
50559
|
for (const property of children(root, "property", NS.customProperties)) {
|
|
49887
50560
|
const name = property.getAttribute("name") ?? "";
|
|
@@ -50624,26 +51297,26 @@ function diagramLayoutData(input) {
|
|
|
50624
51297
|
const branch = first(vars, "hierBranch", NS.dgm)?.getAttribute("val");
|
|
50625
51298
|
if (branch === "std" || branch === "init" || branch === "l" || branch === "r" || branch === "hang")
|
|
50626
51299
|
values.hierarchyBranch = branch;
|
|
50627
|
-
for (const [
|
|
51300
|
+
for (const [tag3, key] of [
|
|
50628
51301
|
["chMax", "childMax"],
|
|
50629
51302
|
["chPref", "childPreferred"]
|
|
50630
51303
|
]) {
|
|
50631
|
-
const raw2 = first(vars,
|
|
51304
|
+
const raw2 = first(vars, tag3, NS.dgm)?.getAttribute("val");
|
|
50632
51305
|
if (raw2 && Number.isFinite(Number(raw2))) values[key] = Number(raw2);
|
|
50633
51306
|
}
|
|
50634
|
-
for (const [
|
|
51307
|
+
for (const [tag3, key] of [
|
|
50635
51308
|
["orgChart", "orgChart"],
|
|
50636
51309
|
["bulletEnabled", "bulletEnabled"]
|
|
50637
51310
|
]) {
|
|
50638
|
-
const raw2 = first(vars,
|
|
51311
|
+
const raw2 = first(vars, tag3, NS.dgm)?.getAttribute("val");
|
|
50639
51312
|
if (raw2) values[key] = raw2 === "1" || raw2 === "true";
|
|
50640
51313
|
}
|
|
50641
|
-
for (const [
|
|
51314
|
+
for (const [tag3, key] of [
|
|
50642
51315
|
["animLvl", "animationLevel"],
|
|
50643
51316
|
["animOne", "animateOne"],
|
|
50644
51317
|
["resizeHandles", "resizeHandles"]
|
|
50645
51318
|
]) {
|
|
50646
|
-
const raw2 = first(vars,
|
|
51319
|
+
const raw2 = first(vars, tag3, NS.dgm)?.getAttribute("val");
|
|
50647
51320
|
if (raw2) values[key] = raw2;
|
|
50648
51321
|
}
|
|
50649
51322
|
data.presLayoutVars = values;
|
|
@@ -50820,8 +51493,8 @@ function add(parent, namespace, name, attrs2 = {}) {
|
|
|
50820
51493
|
parent.appendChild(child6);
|
|
50821
51494
|
return child6;
|
|
50822
51495
|
}
|
|
50823
|
-
function withDiagramDrawingRelationship(
|
|
50824
|
-
const doc = parseXml(
|
|
51496
|
+
function withDiagramDrawingRelationship(xml2, relationshipId) {
|
|
51497
|
+
const doc = parseXml(xml2);
|
|
50825
51498
|
const model = doc.documentElement;
|
|
50826
51499
|
let extension = descendants(model, "dataModelExt").find((node) => node.namespaceURI === DSP2);
|
|
50827
51500
|
if (!extension) {
|
|
@@ -51794,8 +52467,8 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51794
52467
|
const part = paths[name];
|
|
51795
52468
|
if (!part) return void 0;
|
|
51796
52469
|
try {
|
|
51797
|
-
const
|
|
51798
|
-
if (
|
|
52470
|
+
const xml2 = await host.readText(part);
|
|
52471
|
+
if (xml2 === void 0) {
|
|
51799
52472
|
issues.push({
|
|
51800
52473
|
code: "DIAGRAM_PART_MISSING",
|
|
51801
52474
|
message: `Part ${part} is not in the package.`,
|
|
@@ -51803,11 +52476,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51803
52476
|
});
|
|
51804
52477
|
return void 0;
|
|
51805
52478
|
}
|
|
51806
|
-
if (name === "layout") layoutSource.layoutXml =
|
|
51807
|
-
if (name === "data") layoutSource.dataXml =
|
|
51808
|
-
if (name === "colors") layoutSource.colorsXml =
|
|
51809
|
-
if (name === "quickStyle") layoutSource.quickStyleXml =
|
|
51810
|
-
return parse(
|
|
52479
|
+
if (name === "layout") layoutSource.layoutXml = xml2;
|
|
52480
|
+
if (name === "data") layoutSource.dataXml = xml2;
|
|
52481
|
+
if (name === "colors") layoutSource.colorsXml = xml2;
|
|
52482
|
+
if (name === "quickStyle") layoutSource.quickStyleXml = xml2;
|
|
52483
|
+
return parse(xml2, part);
|
|
51811
52484
|
} catch (error) {
|
|
51812
52485
|
issues.push({
|
|
51813
52486
|
code: "DIAGRAM_PART_UNREADABLE",
|
|
@@ -51817,11 +52490,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51817
52490
|
return void 0;
|
|
51818
52491
|
}
|
|
51819
52492
|
};
|
|
51820
|
-
const data = await read("data", (
|
|
52493
|
+
const data = await read("data", (xml2, part) => parseDiagramDataModel(xml2, part));
|
|
51821
52494
|
if (data) issues.push(...data.issues);
|
|
51822
|
-
const layout = await read("layout", (
|
|
51823
|
-
const colors = await read("colors", (
|
|
51824
|
-
const quickStyle = await read("quickStyle", (
|
|
52495
|
+
const layout = await read("layout", (xml2) => parseDiagramLayoutSummary(xml2));
|
|
52496
|
+
const colors = await read("colors", (xml2) => parseDiagramColors(xml2));
|
|
52497
|
+
const quickStyle = await read("quickStyle", (xml2) => parseDiagramQuickStyle(xml2));
|
|
51825
52498
|
let drawingResolution;
|
|
51826
52499
|
try {
|
|
51827
52500
|
drawingResolution = await resolveDiagramDrawingPart(
|
|
@@ -51840,11 +52513,11 @@ async function loadDiagram(hostPart, relationshipIds, host) {
|
|
|
51840
52513
|
let generatedCache = false;
|
|
51841
52514
|
if (drawingResolution) {
|
|
51842
52515
|
paths.drawing = drawingResolution.path;
|
|
51843
|
-
drawing = await read("drawing", (
|
|
52516
|
+
drawing = await read("drawing", (xml2, part) => {
|
|
51844
52517
|
generatedCache = Boolean(
|
|
51845
|
-
data?.generatedCacheDigest && data.generatedCacheDigest === generatedDrawingDigest(
|
|
52518
|
+
data?.generatedCacheDigest && data.generatedCacheDigest === generatedDrawingDigest(xml2)
|
|
51846
52519
|
);
|
|
51847
|
-
return parseDiagramDrawing(
|
|
52520
|
+
return parseDiagramDrawing(xml2, part);
|
|
51848
52521
|
});
|
|
51849
52522
|
if (drawing) {
|
|
51850
52523
|
try {
|
|
@@ -61396,12 +62069,12 @@ function tokenize2(latex) {
|
|
|
61396
62069
|
function isGroupedByTag(tags) {
|
|
61397
62070
|
const seen = /* @__PURE__ */ new Set();
|
|
61398
62071
|
let previous = "";
|
|
61399
|
-
for (const
|
|
61400
|
-
if (
|
|
62072
|
+
for (const tag3 of tags) {
|
|
62073
|
+
if (tag3 !== previous && seen.has(tag3)) {
|
|
61401
62074
|
return false;
|
|
61402
62075
|
}
|
|
61403
|
-
seen.add(
|
|
61404
|
-
previous =
|
|
62076
|
+
seen.add(tag3);
|
|
62077
|
+
previous = tag3;
|
|
61405
62078
|
}
|
|
61406
62079
|
return true;
|
|
61407
62080
|
}
|
|
@@ -61993,11 +62666,11 @@ function parseGroupChr(ctx, chr, pos) {
|
|
|
61993
62666
|
}
|
|
61994
62667
|
return applyScripts(ctx, group2, args);
|
|
61995
62668
|
}
|
|
61996
|
-
function parseUnderOverset(ctx,
|
|
62669
|
+
function parseUnderOverset(ctx, tag3) {
|
|
61997
62670
|
const lim = ctx.parseSingleOrGroup();
|
|
61998
62671
|
const base = ctx.parseSingleOrGroup();
|
|
61999
62672
|
const limit = { "m:e": ctx.wrapE(base), "m:lim": ctx.wrapE(lim) };
|
|
62000
|
-
return
|
|
62673
|
+
return tag3 === "m:limLow" ? { "m:limLow": limit } : { "m:limUpp": limit };
|
|
62001
62674
|
}
|
|
62002
62675
|
function parseBoxed(ctx) {
|
|
62003
62676
|
return { "m:borderBox": { "m:e": ctx.wrapE(ctx.parseSingleOrGroup()) } };
|
|
@@ -62215,8 +62888,8 @@ function contentKeys(node) {
|
|
|
62215
62888
|
if (key.startsWith("@_") || key === "#text") {
|
|
62216
62889
|
return false;
|
|
62217
62890
|
}
|
|
62218
|
-
const
|
|
62219
|
-
return !
|
|
62891
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
62892
|
+
return !tag3.endsWith("Pr") && tag3 !== "m:t";
|
|
62220
62893
|
});
|
|
62221
62894
|
}
|
|
62222
62895
|
function soleChild(container) {
|
|
@@ -62286,12 +62959,12 @@ function collectText(node) {
|
|
|
62286
62959
|
if (key.startsWith("@_")) {
|
|
62287
62960
|
continue;
|
|
62288
62961
|
}
|
|
62289
|
-
const
|
|
62290
|
-
if (
|
|
62962
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
62963
|
+
if (tag3 === "m:t") {
|
|
62291
62964
|
out += escapeMathText(readRunText(record));
|
|
62292
|
-
} else if (
|
|
62965
|
+
} else if (tag3 === "#text") {
|
|
62293
62966
|
out += escapeMathText(String(value));
|
|
62294
|
-
} else if (!
|
|
62967
|
+
} else if (!tag3.endsWith("Pr")) {
|
|
62295
62968
|
out += collectText(value);
|
|
62296
62969
|
}
|
|
62297
62970
|
}
|
|
@@ -62384,9 +63057,9 @@ function childrenToLatex(node) {
|
|
|
62384
63057
|
}
|
|
62385
63058
|
const parts = [];
|
|
62386
63059
|
for (const key of contentKeys(node)) {
|
|
62387
|
-
const
|
|
63060
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
62388
63061
|
for (const item2 of ensureArr(node[key])) {
|
|
62389
|
-
parts.push(elementToLatex(
|
|
63062
|
+
parts.push(elementToLatex(tag3, item2));
|
|
62390
63063
|
}
|
|
62391
63064
|
}
|
|
62392
63065
|
return parts.join("");
|
|
@@ -62472,16 +63145,16 @@ function groupChrToLatex(node, label = "") {
|
|
|
62472
63145
|
const wrapped = `\\${top ? "overset" : "underset"}{${escapeMathText(chr)}}{${base}}`;
|
|
62473
63146
|
return label ? `\\${top ? "overset" : "underset"}{${label}}{${wrapped}}` : wrapped;
|
|
62474
63147
|
}
|
|
62475
|
-
function limitToLatex(node,
|
|
63148
|
+
function limitToLatex(node, tag3) {
|
|
62476
63149
|
const lim = arg(node, "m:lim");
|
|
62477
63150
|
const sole = soleChild(childNode(node, "m:e"));
|
|
62478
63151
|
if (sole?.tag === "m:groupChr") {
|
|
62479
63152
|
const top = attrVal(childNode(childNode(sole.node, "m:groupChrPr"), "m:pos")) === "top";
|
|
62480
|
-
if (top === (
|
|
63153
|
+
if (top === (tag3 === "m:limUpp")) {
|
|
62481
63154
|
return groupChrToLatex(sole.node, lim);
|
|
62482
63155
|
}
|
|
62483
63156
|
}
|
|
62484
|
-
return `\\${
|
|
63157
|
+
return `\\${tag3 === "m:limLow" ? "underset" : "overset"}{${lim}}{${arg(node, "m:e")}}`;
|
|
62485
63158
|
}
|
|
62486
63159
|
function phantomToLatex(node) {
|
|
62487
63160
|
const phantPr = childNode(node, "m:phantPr");
|
|
@@ -62494,8 +63167,8 @@ function phantomToLatex(node) {
|
|
|
62494
63167
|
}
|
|
62495
63168
|
return `\\phantom{${base}}`;
|
|
62496
63169
|
}
|
|
62497
|
-
function elementToLatex(
|
|
62498
|
-
switch (
|
|
63170
|
+
function elementToLatex(tag3, node) {
|
|
63171
|
+
switch (tag3) {
|
|
62499
63172
|
case "m:r":
|
|
62500
63173
|
return runToLatex(node);
|
|
62501
63174
|
case "m:f":
|
|
@@ -62526,7 +63199,7 @@ function elementToLatex(tag2, node) {
|
|
|
62526
63199
|
return `\\${attrVal(childNode(childNode(node, "m:barPr"), "m:pos")) === "bot" ? "underline" : "overline"}{${arg(node, "m:e")}}`;
|
|
62527
63200
|
case "m:limLow":
|
|
62528
63201
|
case "m:limUpp":
|
|
62529
|
-
return limitToLatex(node,
|
|
63202
|
+
return limitToLatex(node, tag3);
|
|
62530
63203
|
case "m:groupChr":
|
|
62531
63204
|
return groupChrToLatex(node);
|
|
62532
63205
|
case "m:borderBox":
|
|
@@ -62931,26 +63604,26 @@ var DELIM_END_MAP = {
|
|
|
62931
63604
|
// math/omml-to-xml.ts
|
|
62932
63605
|
var OMML_NAMESPACE = "http://schemas.openxmlformats.org/officeDocument/2006/math";
|
|
62933
63606
|
var escapeAttribute2 = (value) => escapeXml(value).replace(/"/g, """);
|
|
62934
|
-
function element3(
|
|
63607
|
+
function element3(tag3, value) {
|
|
62935
63608
|
if (value === void 0 || value === null) return "";
|
|
62936
|
-
if (Array.isArray(value)) return value.map((item2) => element3(
|
|
63609
|
+
if (Array.isArray(value)) return value.map((item2) => element3(tag3, item2)).join("");
|
|
62937
63610
|
if (typeof value !== "object") {
|
|
62938
63611
|
const text3 = String(value);
|
|
62939
|
-
const space3 =
|
|
62940
|
-
return `<${
|
|
63612
|
+
const space3 = tag3 === "m:t" && /^\s|\s$/.test(text3) ? ' xml:space="preserve"' : "";
|
|
63613
|
+
return `<${tag3}${space3}>${escapeXml(text3)}</${tag3}>`;
|
|
62941
63614
|
}
|
|
62942
63615
|
const node = value;
|
|
62943
63616
|
let attributes2 = "";
|
|
62944
63617
|
let content2 = "";
|
|
62945
63618
|
for (const key of Object.keys(node)) {
|
|
62946
63619
|
if (key.startsWith("@_")) {
|
|
62947
|
-
attributes2 += ` ${
|
|
63620
|
+
attributes2 += ` ${tag3 === "m:t" ? "" : "m:"}${key.slice(2)}="${escapeAttribute2(String(node[key]))}"`;
|
|
62948
63621
|
} else if (key === "#text") {
|
|
62949
63622
|
content2 += escapeXml(String(node[key]));
|
|
62950
63623
|
} else content2 += element3(stripXmlOrderSuffix(key), node[key]);
|
|
62951
63624
|
}
|
|
62952
|
-
if (
|
|
62953
|
-
return content2 ? `<${
|
|
63625
|
+
if (tag3 === "m:t" && /^\s|\s$/.test(content2) && !attributes2) attributes2 = ' xml:space="preserve"';
|
|
63626
|
+
return content2 ? `<${tag3}${attributes2}>${content2}</${tag3}>` : `<${tag3}${attributes2}/>`;
|
|
62954
63627
|
}
|
|
62955
63628
|
function ommlToXml(tree) {
|
|
62956
63629
|
const markup = Object.keys(tree).map((key) => element3(stripXmlOrderSuffix(key), tree[key])).join("");
|
|
@@ -63260,10 +63933,10 @@ function radical(node, style, ctx) {
|
|
|
63260
63933
|
if (degree) box.prims.push(...shifted(degree.prims, 0, top + height * 0.35 - degree.descent));
|
|
63261
63934
|
return box;
|
|
63262
63935
|
}
|
|
63263
|
-
function layoutStructure(
|
|
63936
|
+
function layoutStructure(tag3, node, style, ctx) {
|
|
63264
63937
|
const arg2 = (name, next = style) => ctx.layout(child5(node, name), next);
|
|
63265
63938
|
const small = () => ctx.script(style);
|
|
63266
|
-
switch (
|
|
63939
|
+
switch (tag3) {
|
|
63267
63940
|
case "m:f":
|
|
63268
63941
|
return fraction(node, style, ctx);
|
|
63269
63942
|
case "m:rad":
|
|
@@ -63431,20 +64104,20 @@ function layoutChildren(node, style) {
|
|
|
63431
64104
|
let last = "";
|
|
63432
64105
|
for (const key of Object.keys(node)) {
|
|
63433
64106
|
if (key.startsWith("@_") || key === "#text") continue;
|
|
63434
|
-
const
|
|
64107
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
63435
64108
|
for (const item2 of ensureArray(node[key])) {
|
|
63436
64109
|
const atStart = boxes.length === 0 || last !== "" && isUnaryContext(last);
|
|
63437
|
-
boxes.push(layoutElement(
|
|
63438
|
-
last =
|
|
64110
|
+
boxes.push(layoutElement(tag3, item2, style, atStart));
|
|
64111
|
+
last = tag3 === "m:r" ? lastCharOf(item2) : "";
|
|
63439
64112
|
}
|
|
63440
64113
|
}
|
|
63441
64114
|
return row(boxes);
|
|
63442
64115
|
}
|
|
63443
|
-
function layoutElement(
|
|
63444
|
-
if (
|
|
63445
|
-
if (
|
|
63446
|
-
if (/Pr$/.test(
|
|
63447
|
-
return layoutStructure(
|
|
64116
|
+
function layoutElement(tag3, node, style, atStart) {
|
|
64117
|
+
if (tag3 === "m:r") return layoutRun(node, style, atStart);
|
|
64118
|
+
if (tag3 === "m:oMath" || tag3 === "m:oMathPara") return layoutChildren(node, style);
|
|
64119
|
+
if (/Pr$/.test(tag3) || tag3 === "m:ctrlPr") return emptyBox();
|
|
64120
|
+
return layoutStructure(tag3, node, style, { layout: layoutChildren, script: scriptStyle });
|
|
63448
64121
|
}
|
|
63449
64122
|
function layoutEquation(root, sizePx, options2 = {}) {
|
|
63450
64123
|
const box = layoutChildren(root, { level: 0, size: sizePx, display: Boolean(options2.display) });
|
|
@@ -63483,8 +64156,8 @@ function ommlFromElement(element4) {
|
|
|
63483
64156
|
};
|
|
63484
64157
|
return visit(element4, 1);
|
|
63485
64158
|
}
|
|
63486
|
-
function parseOmml(
|
|
63487
|
-
return ommlFromElement(parseXml(
|
|
64159
|
+
function parseOmml(xml2) {
|
|
64160
|
+
return ommlFromElement(parseXml(xml2, { label: "OMML" }).documentElement);
|
|
63488
64161
|
}
|
|
63489
64162
|
|
|
63490
64163
|
// math/omml-svg.ts
|
|
@@ -63790,13 +64463,13 @@ function convertChildren(node) {
|
|
|
63790
64463
|
if (key.startsWith("@_")) {
|
|
63791
64464
|
continue;
|
|
63792
64465
|
}
|
|
63793
|
-
const
|
|
63794
|
-
if (
|
|
64466
|
+
const tag3 = stripXmlOrderSuffix(key);
|
|
64467
|
+
if (tag3 === "m:oMathPara") {
|
|
63795
64468
|
continue;
|
|
63796
64469
|
}
|
|
63797
64470
|
const items = ensureArray(node[key]);
|
|
63798
64471
|
for (const item2 of items) {
|
|
63799
|
-
const result = convertElement(
|
|
64472
|
+
const result = convertElement(tag3, item2);
|
|
63800
64473
|
if (result) {
|
|
63801
64474
|
parts.push(result);
|
|
63802
64475
|
}
|
|
@@ -63804,8 +64477,8 @@ function convertChildren(node) {
|
|
|
63804
64477
|
}
|
|
63805
64478
|
return parts.join("");
|
|
63806
64479
|
}
|
|
63807
|
-
function convertElement(
|
|
63808
|
-
switch (
|
|
64480
|
+
function convertElement(tag3, node) {
|
|
64481
|
+
switch (tag3) {
|
|
63809
64482
|
case "m:r":
|
|
63810
64483
|
return convertRun(node);
|
|
63811
64484
|
case "m:f":
|