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
|
@@ -0,0 +1,617 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// embedding/onedrive/types.ts
|
|
4
|
+
var OneDriveError = class extends Error {
|
|
5
|
+
constructor(code, message, status) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.name = "OneDriveError";
|
|
10
|
+
}
|
|
11
|
+
code;
|
|
12
|
+
status;
|
|
13
|
+
};
|
|
14
|
+
var OneDriveConflictError = class extends OneDriveError {
|
|
15
|
+
constructor(conflict) {
|
|
16
|
+
super(
|
|
17
|
+
"conflict",
|
|
18
|
+
"The changes could not be combined automatically. Your edits are retained for resolution."
|
|
19
|
+
);
|
|
20
|
+
this.conflict = conflict;
|
|
21
|
+
this.name = "OneDriveConflictError";
|
|
22
|
+
}
|
|
23
|
+
conflict;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// embedding/onedrive/metadata.ts
|
|
27
|
+
function officeKind(name) {
|
|
28
|
+
const extension = /\.(docx|xlsx|pptx|vsdx)$/iu.exec(name)?.[1]?.toLowerCase();
|
|
29
|
+
if (!extension)
|
|
30
|
+
throw new OneDriveError("unsupported", "Choose a .docx, .xlsx, .pptx or .vsdx file.");
|
|
31
|
+
return extension;
|
|
32
|
+
}
|
|
33
|
+
function fileFromMetadata(data, previous) {
|
|
34
|
+
const parent = data.parentReference;
|
|
35
|
+
const driveId = parent?.driveId ?? previous?.driveId;
|
|
36
|
+
const parentId = parent?.id ?? previous?.parentId;
|
|
37
|
+
const { id: itemId, name, eTag } = data;
|
|
38
|
+
const webUrl = data.webUrl ?? previous?.webUrl;
|
|
39
|
+
if (![driveId, itemId, name, eTag].every((value) => typeof value === "string" && value.length > 0))
|
|
40
|
+
throw new OneDriveError(
|
|
41
|
+
"invalid-response",
|
|
42
|
+
"OneDrive did not return a complete file identity."
|
|
43
|
+
);
|
|
44
|
+
if (data.folder || data.package || data.remoteItem)
|
|
45
|
+
throw new OneDriveError(
|
|
46
|
+
"unsupported",
|
|
47
|
+
"Use a sharing link to an Office file, rather than a folder or shortcut."
|
|
48
|
+
);
|
|
49
|
+
let url;
|
|
50
|
+
if (webUrl !== void 0) {
|
|
51
|
+
try {
|
|
52
|
+
url = new URL(String(webUrl));
|
|
53
|
+
} catch {
|
|
54
|
+
throw new OneDriveError("invalid-response", "OneDrive returned an invalid file address.");
|
|
55
|
+
}
|
|
56
|
+
if (url.protocol !== "https:" || url.username || url.password)
|
|
57
|
+
throw new OneDriveError("invalid-response", "OneDrive returned an invalid file address.");
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
driveId,
|
|
61
|
+
itemId,
|
|
62
|
+
name,
|
|
63
|
+
kind: officeKind(name),
|
|
64
|
+
eTag,
|
|
65
|
+
access: "unknown",
|
|
66
|
+
...url ? { webUrl: url.href } : {},
|
|
67
|
+
...typeof parentId === "string" && parentId ? { parentId } : {}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function validateFile(file) {
|
|
71
|
+
const checked = fileFromMetadata({
|
|
72
|
+
id: file.itemId,
|
|
73
|
+
name: file.name,
|
|
74
|
+
eTag: file.eTag,
|
|
75
|
+
webUrl: file.webUrl,
|
|
76
|
+
parentReference: { driveId: file.driveId }
|
|
77
|
+
});
|
|
78
|
+
if (file.kind !== checked.kind)
|
|
79
|
+
throw new OneDriveError("unsupported", "The file format does not match its identity.");
|
|
80
|
+
}
|
|
81
|
+
function copyName(file, name) {
|
|
82
|
+
const candidate = name ?? file.name.replace(/(\.[^.]+)$/u, " (copy)$1");
|
|
83
|
+
if (!candidate || /[\\/:*?"<>|\u0000-\u001f]/u.test(candidate) || candidate.endsWith(".") || candidate.endsWith(" ") || candidate.length > 255 || officeKind(candidate) !== file.kind)
|
|
84
|
+
throw new OneDriveError(
|
|
85
|
+
"unsupported",
|
|
86
|
+
"Use a valid copy filename with the same Office extension."
|
|
87
|
+
);
|
|
88
|
+
return candidate;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// embedding/onedrive/requests.ts
|
|
92
|
+
function encodeOneDriveSharingUrl(raw) {
|
|
93
|
+
let url;
|
|
94
|
+
try {
|
|
95
|
+
url = new URL(raw.trim());
|
|
96
|
+
} catch {
|
|
97
|
+
throw new OneDriveError("invalid-link", "Enter a valid OneDrive or SharePoint sharing link.");
|
|
98
|
+
}
|
|
99
|
+
const host = url.hostname.toLowerCase();
|
|
100
|
+
const allowed = host === "1drv.ms" || host === "onedrive.live.com" || host.endsWith(".sharepoint.com");
|
|
101
|
+
if (!allowed || url.protocol !== "https:" || url.username || url.password || url.port) {
|
|
102
|
+
throw new OneDriveError("invalid-link", "Use an HTTPS OneDrive or SharePoint sharing link.");
|
|
103
|
+
}
|
|
104
|
+
url.hash = "";
|
|
105
|
+
const bytes = new TextEncoder().encode(url.href);
|
|
106
|
+
let binary = "";
|
|
107
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
108
|
+
return "u!" + btoa(binary).replace(/=/gu, "").replace(/\+/gu, "-").replace(/\//gu, "_");
|
|
109
|
+
}
|
|
110
|
+
function secureTransferUrl(value) {
|
|
111
|
+
try {
|
|
112
|
+
const url = new URL(String(value));
|
|
113
|
+
if (url.protocol === "https:" && !url.username && !url.password) return url.href;
|
|
114
|
+
} catch {
|
|
115
|
+
}
|
|
116
|
+
throw new OneDriveError("invalid-response", "OneDrive returned an invalid transfer URL.");
|
|
117
|
+
}
|
|
118
|
+
function checkResponse(response) {
|
|
119
|
+
if (response.ok) return response;
|
|
120
|
+
const status = response.status;
|
|
121
|
+
if (status === 401)
|
|
122
|
+
throw new OneDriveError("authentication", "Sign in to Microsoft again.", status);
|
|
123
|
+
if (status === 403)
|
|
124
|
+
throw new OneDriveError("access-denied", "Your account cannot access this file.", status);
|
|
125
|
+
if (status === 409 || status === 412)
|
|
126
|
+
throw new OneDriveError(
|
|
127
|
+
"conflict",
|
|
128
|
+
"The OneDrive file changed. Reopen it before saving.",
|
|
129
|
+
status
|
|
130
|
+
);
|
|
131
|
+
if (status === 423)
|
|
132
|
+
throw new OneDriveError(
|
|
133
|
+
"locked",
|
|
134
|
+
"The OneDrive file is locked. Keep your edits and try again later.",
|
|
135
|
+
status
|
|
136
|
+
);
|
|
137
|
+
throw new OneDriveError("network", "The OneDrive request failed. Try again.", status);
|
|
138
|
+
}
|
|
139
|
+
async function readBytes(response, limit) {
|
|
140
|
+
if (Number(response.headers.get("Content-Length")) > limit) {
|
|
141
|
+
await response.body?.cancel();
|
|
142
|
+
throw new OneDriveError("too-large", "The file exceeds the configured size limit.");
|
|
143
|
+
}
|
|
144
|
+
const reader = response.body?.getReader();
|
|
145
|
+
if (!reader) throw new OneDriveError("invalid-response", "OneDrive returned an empty response.");
|
|
146
|
+
const chunks = [];
|
|
147
|
+
let size = 0;
|
|
148
|
+
try {
|
|
149
|
+
while (true) {
|
|
150
|
+
const { value, done } = await reader.read();
|
|
151
|
+
if (done) break;
|
|
152
|
+
size += value.byteLength;
|
|
153
|
+
if (size > limit) {
|
|
154
|
+
await reader.cancel();
|
|
155
|
+
throw new OneDriveError("too-large", "The file exceeds the configured size limit.");
|
|
156
|
+
}
|
|
157
|
+
chunks.push(value);
|
|
158
|
+
}
|
|
159
|
+
} finally {
|
|
160
|
+
reader.releaseLock();
|
|
161
|
+
}
|
|
162
|
+
const result = new Uint8Array(size);
|
|
163
|
+
let offset = 0;
|
|
164
|
+
for (const chunk of chunks) {
|
|
165
|
+
result.set(chunk, offset);
|
|
166
|
+
offset += chunk.length;
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
async function readJson(response) {
|
|
171
|
+
try {
|
|
172
|
+
const data = JSON.parse(
|
|
173
|
+
new TextDecoder().decode(await readBytes(response, 1024 * 1024))
|
|
174
|
+
);
|
|
175
|
+
if (data && typeof data === "object" && !Array.isArray(data))
|
|
176
|
+
return data;
|
|
177
|
+
} catch (error) {
|
|
178
|
+
if (error instanceof OneDriveError) throw error;
|
|
179
|
+
}
|
|
180
|
+
throw new OneDriveError("invalid-response", "OneDrive returned invalid file metadata.");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
// embedding/onedrive/transport.ts
|
|
184
|
+
var GRAPH = "https://graph.microsoft.com/v1.0";
|
|
185
|
+
function createTransport(options) {
|
|
186
|
+
const fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
187
|
+
const maxBytes = options.maxBytes ?? 32 * 1024 * 1024;
|
|
188
|
+
const timeoutMs = options.timeoutMs ?? 6e4;
|
|
189
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0 || !Number.isFinite(timeoutMs) || timeoutMs <= 0)
|
|
190
|
+
throw new RangeError("OneDrive limits must be positive.");
|
|
191
|
+
async function operation(input, run) {
|
|
192
|
+
const signal = AbortSignal.any([
|
|
193
|
+
AbortSignal.timeout(timeoutMs),
|
|
194
|
+
...input?.signal ? [input.signal] : []
|
|
195
|
+
]);
|
|
196
|
+
signal.throwIfAborted();
|
|
197
|
+
let abort = () => {
|
|
198
|
+
};
|
|
199
|
+
try {
|
|
200
|
+
return await Promise.race([
|
|
201
|
+
run(signal),
|
|
202
|
+
new Promise((_, reject) => {
|
|
203
|
+
abort = () => reject(signal.reason);
|
|
204
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
205
|
+
if (signal.aborted) abort();
|
|
206
|
+
})
|
|
207
|
+
]);
|
|
208
|
+
} catch (error) {
|
|
209
|
+
if (signal.aborted) throw signal.reason;
|
|
210
|
+
if (error instanceof OneDriveError) throw error;
|
|
211
|
+
throw new OneDriveError(
|
|
212
|
+
"network",
|
|
213
|
+
"Could not connect to OneDrive. Your edits are still available."
|
|
214
|
+
);
|
|
215
|
+
} finally {
|
|
216
|
+
signal.removeEventListener("abort", abort);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
async function graph(path, signal, init = {}) {
|
|
220
|
+
let token;
|
|
221
|
+
try {
|
|
222
|
+
token = await options.getAccessToken();
|
|
223
|
+
} catch {
|
|
224
|
+
throw new OneDriveError("authentication", "Sign in to Microsoft to access this file.");
|
|
225
|
+
}
|
|
226
|
+
signal.throwIfAborted();
|
|
227
|
+
if (!token)
|
|
228
|
+
throw new OneDriveError("authentication", "Sign in to Microsoft to access this file.");
|
|
229
|
+
const headers = new Headers(init.headers);
|
|
230
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
231
|
+
return checkResponse(
|
|
232
|
+
await fetcher(GRAPH + path, {
|
|
233
|
+
...init,
|
|
234
|
+
headers,
|
|
235
|
+
signal,
|
|
236
|
+
credentials: "omit",
|
|
237
|
+
redirect: "error",
|
|
238
|
+
referrerPolicy: "no-referrer"
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
return { operation, graph, maxBytes, fetcher };
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// embedding/onedrive/upload.ts
|
|
246
|
+
var CHUNK_SIZE = 5 * 1024 * 1024;
|
|
247
|
+
async function uploadBytes(transport, path, bytes, signal, eTag) {
|
|
248
|
+
if (!bytes.length || bytes.length > transport.maxBytes)
|
|
249
|
+
throw new OneDriveError(
|
|
250
|
+
"too-large",
|
|
251
|
+
"Choose nonempty Office file bytes within the configured size limit."
|
|
252
|
+
);
|
|
253
|
+
const session = await readJson(
|
|
254
|
+
await transport.graph(path + "/createUploadSession", signal, {
|
|
255
|
+
method: "POST",
|
|
256
|
+
headers: { "Content-Type": "application/json", ...eTag ? { "If-Match": eTag } : {} },
|
|
257
|
+
body: JSON.stringify({
|
|
258
|
+
item: { "@microsoft.graph.conflictBehavior": eTag ? "fail" : "rename" }
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
);
|
|
262
|
+
const uploadUrl = secureTransferUrl(session.uploadUrl);
|
|
263
|
+
for (let start = 0; start < bytes.length; start += CHUNK_SIZE) {
|
|
264
|
+
const end = Math.min(start + CHUNK_SIZE, bytes.length);
|
|
265
|
+
const response = checkResponse(
|
|
266
|
+
await transport.fetcher(uploadUrl, {
|
|
267
|
+
method: "PUT",
|
|
268
|
+
signal,
|
|
269
|
+
credentials: "omit",
|
|
270
|
+
referrerPolicy: "no-referrer",
|
|
271
|
+
headers: { "Content-Range": `bytes ${start}-${end - 1}/${bytes.length}` },
|
|
272
|
+
body: new Uint8Array(bytes.subarray(start, end))
|
|
273
|
+
})
|
|
274
|
+
);
|
|
275
|
+
const data = await readJson(response);
|
|
276
|
+
if (end === bytes.length) {
|
|
277
|
+
if (response.status === 200 || response.status === 201) return data;
|
|
278
|
+
throw new OneDriveError("invalid-response", "OneDrive did not confirm the completed upload.");
|
|
279
|
+
}
|
|
280
|
+
if (response.status !== 202 || !Array.isArray(data.nextExpectedRanges) || data.nextExpectedRanges[0] !== `${end}-`)
|
|
281
|
+
throw new OneDriveError("invalid-response", "OneDrive requested an unexpected upload range.");
|
|
282
|
+
}
|
|
283
|
+
throw new OneDriveError("invalid-response", "OneDrive did not complete the upload.");
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// embedding/onedrive/client.ts
|
|
287
|
+
var itemPath = (file) => `/drives/${encodeURIComponent(file.driveId)}/items/${encodeURIComponent(file.itemId)}`;
|
|
288
|
+
function createOneDriveClient(options) {
|
|
289
|
+
const transport = createTransport(options);
|
|
290
|
+
const { operation, graph } = transport;
|
|
291
|
+
async function access(file) {
|
|
292
|
+
if (options.canWrite)
|
|
293
|
+
file.access = await options.canWrite(Object.freeze({ ...file })) ? "write" : "read";
|
|
294
|
+
return file;
|
|
295
|
+
}
|
|
296
|
+
async function writable(file) {
|
|
297
|
+
validateFile(file);
|
|
298
|
+
if (file.access !== "write" || !await options.canWrite?.(Object.freeze({ ...file })))
|
|
299
|
+
throw new OneDriveError(
|
|
300
|
+
"access-denied",
|
|
301
|
+
"This file is read-only. Keep or download your edits instead."
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
async function download(data, signal) {
|
|
305
|
+
const file = await access(fileFromMetadata(data));
|
|
306
|
+
if (typeof data.size === "number" && data.size > transport.maxBytes)
|
|
307
|
+
throw new OneDriveError("too-large", "The file exceeds the configured size limit.");
|
|
308
|
+
const url = secureTransferUrl(data["@microsoft.graph.downloadUrl"]);
|
|
309
|
+
const response = checkResponse(
|
|
310
|
+
await transport.fetcher(url, { signal, credentials: "omit", referrerPolicy: "no-referrer" })
|
|
311
|
+
);
|
|
312
|
+
const bytes = await readBytes(response, transport.maxBytes);
|
|
313
|
+
if (!bytes.length) throw new OneDriveError("unsupported", "The Office file is empty.");
|
|
314
|
+
return { file, bytes };
|
|
315
|
+
}
|
|
316
|
+
return {
|
|
317
|
+
open(shareUrl, input) {
|
|
318
|
+
const encoded = encodeOneDriveSharingUrl(shareUrl);
|
|
319
|
+
return operation(
|
|
320
|
+
input,
|
|
321
|
+
async (signal) => download(await readJson(await graph(`/shares/${encoded}/driveItem`, signal)), signal)
|
|
322
|
+
);
|
|
323
|
+
},
|
|
324
|
+
read(file, input) {
|
|
325
|
+
const target = { ...file };
|
|
326
|
+
return operation(input, async (signal) => {
|
|
327
|
+
validateFile(target);
|
|
328
|
+
const opened = await download(
|
|
329
|
+
await readJson(await graph(itemPath(target), signal)),
|
|
330
|
+
signal
|
|
331
|
+
);
|
|
332
|
+
if (opened.file.driveId !== target.driveId || opened.file.itemId !== target.itemId || opened.file.kind !== target.kind)
|
|
333
|
+
throw new OneDriveError("invalid-response", "OneDrive returned a different file.");
|
|
334
|
+
return opened;
|
|
335
|
+
});
|
|
336
|
+
},
|
|
337
|
+
save(file, bytes, input) {
|
|
338
|
+
const target = { ...file };
|
|
339
|
+
const snapshot = bytes.slice();
|
|
340
|
+
return operation(input, async (signal) => {
|
|
341
|
+
await writable(target);
|
|
342
|
+
const updated = fileFromMetadata(
|
|
343
|
+
await uploadBytes(transport, itemPath(target), snapshot, signal, target.eTag),
|
|
344
|
+
target
|
|
345
|
+
);
|
|
346
|
+
if (updated.itemId !== target.itemId || updated.driveId !== target.driveId || updated.kind !== target.kind)
|
|
347
|
+
throw new OneDriveError(
|
|
348
|
+
"invalid-response",
|
|
349
|
+
"OneDrive returned a different file after saving."
|
|
350
|
+
);
|
|
351
|
+
return access(updated);
|
|
352
|
+
});
|
|
353
|
+
},
|
|
354
|
+
saveCopy(file, bytes, name, input) {
|
|
355
|
+
const target = { ...file };
|
|
356
|
+
const snapshot = bytes.slice();
|
|
357
|
+
const candidate = copyName(target, name);
|
|
358
|
+
return operation(input, async (signal) => {
|
|
359
|
+
await writable(target);
|
|
360
|
+
if (!target.parentId)
|
|
361
|
+
throw new OneDriveError(
|
|
362
|
+
"unsupported",
|
|
363
|
+
"Reopen this file to obtain its folder before saving a cloud copy."
|
|
364
|
+
);
|
|
365
|
+
const path = `/drives/${encodeURIComponent(target.driveId)}/items/${encodeURIComponent(target.parentId)}:/${encodeURIComponent(candidate)}:`;
|
|
366
|
+
const updated = fileFromMetadata(await uploadBytes(transport, path, snapshot, signal));
|
|
367
|
+
if (updated.itemId === target.itemId || updated.driveId !== target.driveId || updated.kind !== target.kind)
|
|
368
|
+
throw new OneDriveError("invalid-response", "OneDrive did not create a separate copy.");
|
|
369
|
+
return { file: await access(updated), bytes: snapshot };
|
|
370
|
+
});
|
|
371
|
+
},
|
|
372
|
+
share(file, link, input) {
|
|
373
|
+
const target = { ...file };
|
|
374
|
+
const requested = { ...link };
|
|
375
|
+
return operation(input, async (signal) => {
|
|
376
|
+
await writable(target);
|
|
377
|
+
if (!["view", "edit"].includes(requested.type) || !["anonymous", "organization", "users"].includes(requested.scope))
|
|
378
|
+
throw new OneDriveError(
|
|
379
|
+
"unsupported",
|
|
380
|
+
"Choose an explicit sharing permission and audience."
|
|
381
|
+
);
|
|
382
|
+
const data = await readJson(
|
|
383
|
+
await graph(itemPath(target) + "/createLink", signal, {
|
|
384
|
+
method: "POST",
|
|
385
|
+
headers: { "Content-Type": "application/json" },
|
|
386
|
+
body: JSON.stringify(requested)
|
|
387
|
+
})
|
|
388
|
+
);
|
|
389
|
+
const result = data.link;
|
|
390
|
+
return secureTransferUrl(result?.webUrl);
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// embedding/storage-merge.ts
|
|
397
|
+
async function runStorageMerge(merge, input) {
|
|
398
|
+
const { signal } = input;
|
|
399
|
+
signal?.throwIfAborted();
|
|
400
|
+
if (!signal) return merge(input);
|
|
401
|
+
let abort = () => {
|
|
402
|
+
};
|
|
403
|
+
try {
|
|
404
|
+
return await Promise.race([
|
|
405
|
+
merge(input),
|
|
406
|
+
new Promise((_, reject) => {
|
|
407
|
+
abort = () => reject(signal.reason);
|
|
408
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
409
|
+
if (signal.aborted) abort();
|
|
410
|
+
})
|
|
411
|
+
]);
|
|
412
|
+
} finally {
|
|
413
|
+
signal.removeEventListener("abort", abort);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// embedding/versioned-storage.ts
|
|
418
|
+
var StorageConflictError = class extends Error {
|
|
419
|
+
constructor(conflict) {
|
|
420
|
+
super(
|
|
421
|
+
"The changes could not be combined automatically. Your edits are retained for resolution."
|
|
422
|
+
);
|
|
423
|
+
this.conflict = conflict;
|
|
424
|
+
this.name = "StorageConflictError";
|
|
425
|
+
}
|
|
426
|
+
conflict;
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
// embedding/storage-session.ts
|
|
430
|
+
function createStorageSession(client, opened, settings = {}) {
|
|
431
|
+
const cloneFile = settings.cloneFile ?? ((file) => structuredClone(file));
|
|
432
|
+
const clone = (value) => ({
|
|
433
|
+
file: cloneFile(value.file),
|
|
434
|
+
bytes: value.bytes.slice()
|
|
435
|
+
});
|
|
436
|
+
const equal = (a, b) => a.length === b.length && a.every((value, index) => value === b[index]);
|
|
437
|
+
const cloneConflict = (value) => ({
|
|
438
|
+
base: clone(value.base),
|
|
439
|
+
local: value.local.slice(),
|
|
440
|
+
remote: clone(value.remote),
|
|
441
|
+
...value.issues ? { issues: [...value.issues] } : {}
|
|
442
|
+
});
|
|
443
|
+
const merge = settings.merge;
|
|
444
|
+
const maxRebases = settings.maxMergeAttempts ?? (merge ? 3 : 1);
|
|
445
|
+
if (!Number.isInteger(maxRebases) || maxRebases < 1 || maxRebases > 10)
|
|
446
|
+
throw new RangeError("Storage merge attempts must be an integer from 1 to 10.");
|
|
447
|
+
let base = clone(opened);
|
|
448
|
+
let acknowledgedLocal = opened.bytes.slice();
|
|
449
|
+
let local = opened.bytes.slice();
|
|
450
|
+
let conflict = null;
|
|
451
|
+
let pending = Promise.resolve();
|
|
452
|
+
function enqueue(run) {
|
|
453
|
+
const result = pending.then(run);
|
|
454
|
+
pending = result.catch(() => {
|
|
455
|
+
});
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
function adopt(next, submitted = next.bytes) {
|
|
459
|
+
base = clone(next);
|
|
460
|
+
acknowledgedLocal = submitted.slice();
|
|
461
|
+
local = next.bytes.slice();
|
|
462
|
+
conflict = null;
|
|
463
|
+
}
|
|
464
|
+
async function save(snapshot, options) {
|
|
465
|
+
local = snapshot.slice();
|
|
466
|
+
conflict = null;
|
|
467
|
+
let ancestor = clone(base);
|
|
468
|
+
let candidate = snapshot.slice();
|
|
469
|
+
let rebases = 0;
|
|
470
|
+
if (merge && !equal(acknowledgedLocal, base.bytes)) {
|
|
471
|
+
conflict = {
|
|
472
|
+
base: { file: cloneFile(base.file), bytes: acknowledgedLocal.slice() },
|
|
473
|
+
local: candidate.slice(),
|
|
474
|
+
remote: clone(base)
|
|
475
|
+
};
|
|
476
|
+
candidate = await mergeConflict(conflict, options);
|
|
477
|
+
local = candidate.slice();
|
|
478
|
+
}
|
|
479
|
+
while (true) {
|
|
480
|
+
options?.signal?.throwIfAborted();
|
|
481
|
+
try {
|
|
482
|
+
const file = await client.save(ancestor.file, candidate, options);
|
|
483
|
+
adopt({ file, bytes: candidate }, snapshot);
|
|
484
|
+
return cloneFile(file);
|
|
485
|
+
} catch (error) {
|
|
486
|
+
if (!client.isConflict(error)) throw error;
|
|
487
|
+
}
|
|
488
|
+
const remote = await client.read(ancestor.file, options);
|
|
489
|
+
if (remote.file.kind !== ancestor.file.kind) {
|
|
490
|
+
conflict = {
|
|
491
|
+
base: clone(ancestor),
|
|
492
|
+
local: candidate.slice(),
|
|
493
|
+
remote: clone(remote),
|
|
494
|
+
issues: ["file-format-changed"]
|
|
495
|
+
};
|
|
496
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
497
|
+
cloneConflict(conflict)
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
if (equal(candidate, remote.bytes)) {
|
|
501
|
+
adopt(remote, snapshot);
|
|
502
|
+
return cloneFile(remote.file);
|
|
503
|
+
}
|
|
504
|
+
conflict = { base: clone(ancestor), local: candidate.slice(), remote: clone(remote) };
|
|
505
|
+
if (rebases >= maxRebases) {
|
|
506
|
+
conflict.issues = ["remote-keeps-changing"];
|
|
507
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
508
|
+
cloneConflict(conflict)
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
rebases++;
|
|
512
|
+
if (!equal(ancestor.bytes, remote.bytes)) {
|
|
513
|
+
if (!merge)
|
|
514
|
+
throw (settings.conflictError ?? ((value) => new StorageConflictError(value)))(
|
|
515
|
+
cloneConflict(conflict)
|
|
516
|
+
);
|
|
517
|
+
candidate = await mergeConflict(conflict, options);
|
|
518
|
+
local = candidate.slice();
|
|
519
|
+
}
|
|
520
|
+
ancestor = clone(remote);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
async function mergeConflict(value, options) {
|
|
524
|
+
let result;
|
|
525
|
+
try {
|
|
526
|
+
result = await runStorageMerge(merge, {
|
|
527
|
+
...cloneConflict(value),
|
|
528
|
+
kind: value.base.file.kind,
|
|
529
|
+
...options?.signal ? { signal: options.signal } : {}
|
|
530
|
+
});
|
|
531
|
+
} catch {
|
|
532
|
+
options?.signal?.throwIfAborted();
|
|
533
|
+
value.issues = ["merge-failed"];
|
|
534
|
+
throw (settings.conflictError ?? ((value2) => new StorageConflictError(value2)))(
|
|
535
|
+
cloneConflict(value)
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
options?.signal?.throwIfAborted();
|
|
539
|
+
if (!result || result.status !== "merged" || !(result.bytes instanceof Uint8Array) || !result.bytes.length) {
|
|
540
|
+
value.issues = result?.status === "unresolved" && Array.isArray(result.issues) ? result.issues.filter((issue) => typeof issue === "string") : ["invalid-merge-result"];
|
|
541
|
+
throw (settings.conflictError ?? ((value2) => new StorageConflictError(value2)))(
|
|
542
|
+
cloneConflict(value)
|
|
543
|
+
);
|
|
544
|
+
}
|
|
545
|
+
return result.bytes.slice();
|
|
546
|
+
}
|
|
547
|
+
const session = {
|
|
548
|
+
getSnapshot: () => ({
|
|
549
|
+
file: cloneFile(base.file),
|
|
550
|
+
baseBytes: base.bytes.slice(),
|
|
551
|
+
conflict: conflict ? cloneConflict(conflict) : null
|
|
552
|
+
}),
|
|
553
|
+
save(bytes, options) {
|
|
554
|
+
const snapshot = bytes.slice();
|
|
555
|
+
return enqueue(() => save(snapshot, options));
|
|
556
|
+
},
|
|
557
|
+
reload(options) {
|
|
558
|
+
return enqueue(async () => {
|
|
559
|
+
const next = await client.read(base.file, options);
|
|
560
|
+
adopt(next);
|
|
561
|
+
return clone(next);
|
|
562
|
+
});
|
|
563
|
+
},
|
|
564
|
+
saveCopy(bytes, name, options) {
|
|
565
|
+
const snapshot = bytes?.slice();
|
|
566
|
+
return enqueue(async () => {
|
|
567
|
+
if (!client.saveCopy)
|
|
568
|
+
throw new Error("This storage provider does not support saving copies.");
|
|
569
|
+
const next = await client.saveCopy(base.file, snapshot ?? local, name, options);
|
|
570
|
+
adopt(next);
|
|
571
|
+
return clone(next);
|
|
572
|
+
});
|
|
573
|
+
},
|
|
574
|
+
storage: {
|
|
575
|
+
async save(bytes, meta) {
|
|
576
|
+
settings.validateSave?.(meta, cloneFile(base.file));
|
|
577
|
+
if (meta.reason === "saveAs") {
|
|
578
|
+
const result2 = await session.saveCopy(bytes, meta.fileName);
|
|
579
|
+
return { fileName: result2.file.name };
|
|
580
|
+
}
|
|
581
|
+
const result = await session.save(bytes);
|
|
582
|
+
return { fileName: result.name };
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
};
|
|
586
|
+
return session;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// embedding/onedrive/session.ts
|
|
590
|
+
function createOneDriveSession(client, opened, settings = {}) {
|
|
591
|
+
return createStorageSession(
|
|
592
|
+
{
|
|
593
|
+
read: (file, options) => client.read(file, options),
|
|
594
|
+
save: (file, bytes, options) => client.save(file, bytes, options),
|
|
595
|
+
saveCopy: (file, bytes, name, options) => client.saveCopy(file, bytes, name, options),
|
|
596
|
+
isConflict: (error) => error instanceof OneDriveError && error.code === "conflict"
|
|
597
|
+
},
|
|
598
|
+
opened,
|
|
599
|
+
{
|
|
600
|
+
...settings,
|
|
601
|
+
conflictError: (value) => new OneDriveConflictError(value),
|
|
602
|
+
validateSave(meta, file) {
|
|
603
|
+
if (officeKind(meta.fileName) !== file.kind)
|
|
604
|
+
throw new OneDriveError(
|
|
605
|
+
"unsupported",
|
|
606
|
+
"A different Office format needs a separate export destination."
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
exports.OneDriveConflictError = OneDriveConflictError;
|
|
614
|
+
exports.OneDriveError = OneDriveError;
|
|
615
|
+
exports.createOneDriveClient = createOneDriveClient;
|
|
616
|
+
exports.createOneDriveSession = createOneDriveSession;
|
|
617
|
+
exports.encodeOneDriveSharingUrl = encodeOneDriveSharingUrl;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createOneDriveClient } from './client.js';
|
|
2
|
+
export { createOneDriveSession } from './session.js';
|
|
3
|
+
export { encodeOneDriveSharingUrl } from './requests.js';
|
|
4
|
+
export { OneDriveError, OneDriveConflictError } from './types.js';
|
|
5
|
+
export type { OneDriveClient, OneDriveClientOptions, OneDriveFile, OneDriveKind, OneDriveOpened, OneDriveRequestOptions, OneDriveShareOptions, OneDriveErrorCode, OneDriveConflict, OneDriveSession, OneDriveSessionSnapshot, OneDriveMergeInput, OneDriveMergeResult, OneDriveSessionOptions, } from './types.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../embedding/onedrive/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAClD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC/D,YAAY,EACX,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACtB,MAAM,SAAS,CAAC"}
|