@a3s-lab/office 0.2.2 → 0.4.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/COLLABORATION_ROADMAP.md +426 -0
- package/README.md +649 -10
- package/dist/0~1403.js +1 -1
- package/dist/0~2805.js +1279 -0
- package/dist/{0~use-office-draft.js → 0~345.js} +30 -1
- package/dist/0~3539.js +1 -1
- package/dist/0~3557.js +1 -1
- package/dist/0~3635.js +1 -1
- package/dist/0~4595.js +123 -12
- package/dist/0~4980.js +154 -0
- package/dist/0~5050.js +124 -113
- package/dist/{0~9512.js → 0~6090.js} +540 -3
- package/dist/0~7048.js +92 -66
- package/dist/0~7614.js +2 -1
- package/dist/0~7754.js +5653 -0
- package/dist/0~9445.js +1 -1
- package/dist/0~document-editor.js +4992 -3323
- package/dist/0~markdown-editor.js +250 -44
- package/dist/0~pdf-viewer.js +1016 -24
- package/dist/0~presentation-editor.js +179 -8
- package/dist/0~spreadsheet-editor.js +3371 -578
- package/dist/0~work-docx-export.js +6801 -658
- package/dist/0~work-docx-import.js +1388 -795
- package/dist/0~work-office-diagnostics.js +524 -30
- package/dist/0~work-pptx-export.js +2 -1
- package/dist/0~work-pptx-import.js +1 -2
- package/dist/0~work-presentation-charts.js +1 -1
- package/dist/2591.js +197 -0
- package/dist/3818.js +1090 -0
- package/dist/4104.js +970 -60
- package/dist/432.js +171 -14
- package/dist/4476.js +2008 -0
- package/dist/4560.js +674 -0
- package/dist/4650.js +70 -0
- package/dist/{1134.js → 5184.js} +183 -1
- package/dist/6489.js +18 -18
- package/dist/7060.js +132 -0
- package/dist/8715.js +2 -136
- package/dist/8928.js +16778 -0
- package/dist/9787.js +209 -0
- package/dist/core.d.ts +29 -9
- package/dist/core.js +10 -2
- package/dist/index.js +13 -3
- package/dist/internal/collaboration/office-collaboration-flat-json.d.ts +13 -0
- package/dist/internal/collaboration/office-collaboration-json.d.ts +4 -0
- package/dist/internal/collaboration/office-collaboration-presence.d.ts +86 -0
- package/dist/internal/collaboration/office-collaboration-transport.d.ts +42 -0
- package/dist/internal/collaboration/office-collaboration.d.ts +85 -0
- package/dist/internal/collaboration/office-document-collaboration-bibliography.d.ts +7 -0
- package/dist/internal/collaboration/office-document-collaboration-claims.d.ts +9 -0
- package/dist/internal/collaboration/office-document-collaboration-comments.d.ts +7 -0
- package/dist/internal/collaboration/office-document-collaboration-sidecar-utils.d.ts +27 -0
- package/dist/internal/collaboration/office-document-collaboration-sidecars.d.ts +16 -0
- package/dist/internal/collaboration/office-document-collaboration.d.ts +45 -0
- package/dist/internal/collaboration/office-markdown-collaboration.d.ts +31 -0
- package/dist/internal/collaboration/office-pdf-collaboration-claims.d.ts +4 -0
- package/dist/internal/collaboration/office-pdf-collaboration-conflicts.d.ts +2 -0
- package/dist/internal/collaboration/office-pdf-collaboration-model.d.ts +26 -0
- package/dist/internal/collaboration/office-pdf-collaboration-records.d.ts +21 -0
- package/dist/internal/collaboration/office-pdf-collaboration-types.d.ts +91 -0
- package/dist/internal/collaboration/office-pdf-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-pdf-collaboration.d.ts +35 -0
- package/dist/internal/collaboration/office-presentation-collaboration-model.d.ts +25 -0
- package/dist/internal/collaboration/office-presentation-collaboration-records.d.ts +22 -0
- package/dist/internal/collaboration/office-presentation-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-presentation-collaboration.d.ts +32 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-cells.d.ts +13 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-claims.d.ts +4 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-conflicts.d.ts +2 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-flat-json.d.ts +10 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-model.d.ts +31 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-records.d.ts +17 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration-validation.d.ts +4 -0
- package/dist/internal/collaboration/office-spreadsheet-collaboration.d.ts +32 -0
- package/dist/internal/design-system/primitives/navigation/tabs.d.ts +3 -1
- package/dist/internal/features/work/components/work-document-page-border.d.ts +6 -0
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +536 -0
- package/dist/internal/features/work/editors/document-editor-focus.d.ts +1 -1
- package/dist/internal/features/work/editors/document-editor-support.d.ts +7 -3
- package/dist/internal/features/work/editors/document-editor.d.ts +8 -2
- package/dist/internal/features/work/editors/document-external-content.d.ts +14 -0
- package/dist/internal/features/work/editors/document-format-clipboard.d.ts +6 -0
- package/dist/internal/features/work/editors/document-format-tools.d.ts +4 -0
- package/dist/internal/features/work/editors/document-layout-panel.d.ts +4 -1
- package/dist/internal/features/work/editors/document-page-chrome-wps-shortcuts.d.ts +2 -0
- package/dist/internal/features/work/editors/document-page-layout-ribbon.d.ts +14 -0
- package/dist/internal/features/work/editors/document-page-stack.d.ts +10 -1
- package/dist/internal/features/work/editors/document-page-thumbnail.d.ts +2 -0
- package/dist/internal/features/work/editors/document-pagination-run-coordinator.d.ts +26 -0
- package/dist/internal/features/work/editors/document-picture-properties-dialog-model.d.ts +20 -1
- package/dist/internal/features/work/editors/document-review-navigation.d.ts +9 -0
- package/dist/internal/features/work/editors/document-statistics-dialog.d.ts +7 -0
- package/dist/internal/features/work/editors/document-status-bar.d.ts +2 -1
- package/dist/internal/features/work/editors/document-table-properties-dialog-model.d.ts +4 -1
- package/dist/internal/features/work/editors/document-toolbar.d.ts +19 -42
- package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +12 -0
- package/dist/internal/features/work/editors/document-zoom.d.ts +17 -0
- package/dist/internal/features/work/editors/markdown-editor-focus.d.ts +1 -1
- package/dist/internal/features/work/editors/markdown-editor.d.ts +5 -1
- package/dist/internal/features/work/editors/markdown-toolbar.d.ts +2 -1
- package/dist/internal/features/work/editors/office-collaboration-participants.d.ts +3 -0
- package/dist/internal/features/work/editors/office-collaboration-presence-context.d.ts +17 -0
- package/dist/internal/features/work/editors/office-collaboration-presence-ui.d.ts +25 -0
- package/dist/internal/features/work/editors/office-editor-focus-handoff.d.ts +27 -0
- package/dist/internal/features/work/editors/pdf-annotation-controller.d.ts +5 -0
- package/dist/internal/features/work/editors/pdf-collaboration-presence.d.ts +3 -0
- package/dist/internal/features/work/editors/pdf-collaboration-projection.d.ts +10 -0
- package/dist/internal/features/work/editors/pdf-evidence-contract.d.ts +36 -0
- package/dist/internal/features/work/editors/pdf-evidence-overlay.d.ts +37 -0
- package/dist/internal/features/work/editors/pdf-toolbar.d.ts +2 -1
- package/dist/internal/features/work/editors/pdf-viewer-controller.d.ts +7 -1
- package/dist/internal/features/work/editors/pdf-viewer.d.ts +11 -1
- package/dist/internal/features/work/editors/presentation-collaboration-presence.d.ts +5 -0
- package/dist/internal/features/work/editors/presentation-editor-focus.d.ts +3 -2
- package/dist/internal/features/work/editors/presentation-editor-types.d.ts +3 -0
- package/dist/internal/features/work/editors/presentation-editor.d.ts +1 -1
- package/dist/internal/features/work/editors/spreadsheet-auto-filter.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-clear.d.ts +3 -0
- package/dist/internal/features/work/editors/spreadsheet-cell-merge.d.ts +12 -0
- package/dist/internal/features/work/editors/spreadsheet-clipboard-shortcuts.d.ts +3 -7
- package/dist/internal/features/work/editors/spreadsheet-collaboration-presence.d.ts +9 -0
- package/dist/internal/features/work/editors/spreadsheet-command-catalog.d.ts +464 -0
- package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +45 -9
- package/dist/internal/features/work/editors/spreadsheet-context-menu.d.ts +2 -0
- package/dist/internal/features/work/editors/spreadsheet-editor-ribbon.d.ts +9 -28
- package/dist/internal/features/work/editors/spreadsheet-editor.d.ts +8 -2
- package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +27 -0
- package/dist/internal/features/work/editors/spreadsheet-freeze-panes.d.ts +14 -0
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +3 -2
- package/dist/internal/features/work/editors/use-document-pagination.d.ts +6 -1
- package/dist/internal/features/work/editors/use-document-review-conflicts.d.ts +28 -0
- package/dist/internal/features/work/editors/use-spreadsheet-auto-filter.d.ts +21 -0
- package/dist/internal/features/work/editors/use-spreadsheet-collaboration.d.ts +27 -0
- package/dist/internal/features/work/editors/use-spreadsheet-format-painter.d.ts +18 -0
- package/dist/internal/features/work/editors/work-office-chrome.d.ts +22 -3
- package/dist/internal/features/work/editors/work-office-ribbon-overflow.d.ts +2 -0
- package/dist/internal/features/work/work-document-bookmark-references.d.ts +37 -0
- package/dist/internal/features/work/work-document-bookmarks.d.ts +29 -0
- package/dist/internal/features/work/work-document-caption-nodes.d.ts +4 -1
- package/dist/internal/features/work/work-document-comments.d.ts +1 -1
- package/dist/internal/features/work/work-document-equations.d.ts +513 -0
- package/dist/internal/features/work/work-document-extensions.d.ts +1 -0
- package/dist/internal/features/work/work-document-field-identity.d.ts +2 -0
- package/dist/internal/features/work/work-document-field-node.d.ts +2 -2
- package/dist/internal/features/work/work-document-fields.d.ts +7 -0
- package/dist/internal/features/work/work-document-image-identity.d.ts +30 -0
- package/dist/internal/features/work/work-document-image-layout.d.ts +46 -1
- package/dist/internal/features/work/work-document-image-wrap-contour.d.ts +16 -0
- package/dist/internal/features/work/work-document-incremental-layout.d.ts +2 -2
- package/dist/internal/features/work/work-document-model-codec.d.ts +4 -1
- package/dist/internal/features/work/work-document-note-integrity.d.ts +2 -0
- package/dist/internal/features/work/work-document-page-borders.d.ts +25 -0
- package/dist/internal/features/work/work-document-page-capture.d.ts +8 -0
- package/dist/internal/features/work/work-document-page-frames.d.ts +15 -0
- package/dist/internal/features/work/work-document-page-margins.d.ts +56 -0
- package/dist/internal/features/work/work-document-page-size.d.ts +47 -0
- package/dist/internal/features/work/work-document-pagination-measurement.d.ts +1 -2
- package/dist/internal/features/work/work-document-pagination-types.d.ts +7 -2
- package/dist/internal/features/work/work-document-pagination.d.ts +2 -2
- package/dist/internal/features/work/work-document-paragraph-borders.d.ts +32 -0
- package/dist/internal/features/work/work-document-paragraph-identity.d.ts +26 -0
- package/dist/internal/features/work/work-document-paragraph-shading.d.ts +18 -0
- package/dist/internal/features/work/work-document-review-conflicts.d.ts +35 -0
- package/dist/internal/features/work/work-document-section.d.ts +4 -0
- package/dist/internal/features/work/work-document-snapshot.d.ts +19 -0
- package/dist/internal/features/work/work-document-source.d.ts +23 -0
- package/dist/internal/features/work/work-document-table-column-widths.d.ts +7 -0
- package/dist/internal/features/work/work-document-table-property-changes.d.ts +3 -0
- package/dist/internal/features/work/work-document-table-row-identity.d.ts +15 -0
- package/dist/internal/features/work/work-document-table-sizing.d.ts +3 -0
- package/dist/internal/features/work/work-document-text-layout.d.ts +3 -1
- package/dist/internal/features/work/work-document-word-line-metrics.d.ts +2 -0
- package/dist/internal/features/work/work-docx-bookmark-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-bookmark-import.d.ts +24 -0
- package/dist/internal/features/work/work-docx-bookmarks.d.ts +17 -0
- package/dist/internal/features/work/work-docx-comment-durable-id-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-comment-export.d.ts +3 -0
- package/dist/internal/features/work/work-docx-comment-metadata.d.ts +2 -0
- package/dist/internal/features/work/work-docx-drawing-extension-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-equation-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-equation-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-equation-import.d.ts +30 -0
- package/dist/internal/features/work/work-docx-equation-story.d.ts +9 -0
- package/dist/internal/features/work/work-docx-export-formatting.d.ts +3 -1
- package/dist/internal/features/work/work-docx-export-image.d.ts +5 -1
- package/dist/internal/features/work/work-docx-export.d.ts +1 -1
- package/dist/internal/features/work/work-docx-field-instructions.d.ts +8 -0
- package/dist/internal/features/work/work-docx-font-table-preservation.d.ts +3 -0
- package/dist/internal/features/work/work-docx-ignorable-extension-preservation.d.ts +15 -0
- package/dist/internal/features/work/work-docx-image-crop.d.ts +12 -0
- package/dist/internal/features/work/work-docx-image-identity.d.ts +17 -0
- package/dist/internal/features/work/work-docx-image-layer.d.ts +12 -0
- package/dist/internal/features/work/work-docx-image-layout-import.d.ts +14 -2
- package/dist/internal/features/work/work-docx-image-wrap.d.ts +15 -0
- package/dist/internal/features/work/work-docx-import.d.ts +13 -3
- package/dist/internal/features/work/work-docx-list-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-list-import.d.ts +14 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-block-preservation.d.ts +18 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-model.d.ts +47 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-properties.d.ts +17 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-table-model.d.ts +17 -0
- package/dist/internal/features/work/work-docx-note-comment-content-control-xml.d.ts +14 -0
- package/dist/internal/features/work/work-docx-note-comment-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-content.d.ts +40 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-preservation.d.ts +5 -0
- package/dist/internal/features/work/work-docx-note-comment-hyperlink-relationships.d.ts +35 -0
- package/dist/internal/features/work/work-docx-note-comment-identity.d.ts +15 -0
- package/dist/internal/features/work/work-docx-note-comment-run-preservation.d.ts +4 -0
- package/dist/internal/features/work/work-docx-note-comment-run-properties.d.ts +2 -0
- package/dist/internal/features/work/work-docx-note-image-import.d.ts +12 -0
- package/dist/internal/features/work/work-docx-note-image-relationships.d.ts +1 -0
- package/dist/internal/features/work/work-docx-numbering-extension-preservation.d.ts +6 -0
- package/dist/internal/features/work/work-docx-numbering.d.ts +1 -0
- package/dist/internal/features/work/work-docx-page-borders-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-borders-import.d.ts +10 -0
- package/dist/internal/features/work/work-docx-page-margins-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-page-margins-import.d.ts +18 -0
- package/dist/internal/features/work/work-docx-page-size-diagnostics.d.ts +2 -0
- package/dist/internal/features/work/work-docx-page-size-import.d.ts +17 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-export.d.ts +18 -0
- package/dist/internal/features/work/work-docx-paragraph-borders-import.d.ts +24 -0
- package/dist/internal/features/work/work-docx-paragraph-default-collapsed.d.ts +19 -0
- package/dist/internal/features/work/work-docx-paragraph-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-paragraph-identity-import.d.ts +10 -0
- package/dist/internal/features/work/work-docx-paragraph-identity.d.ts +18 -0
- package/dist/internal/features/work/work-docx-paragraph-pagination-import.d.ts +6 -1
- package/dist/internal/features/work/work-docx-paragraph-shading-diagnostics.d.ts +3 -0
- package/dist/internal/features/work/work-docx-paragraph-shading-export.d.ts +5 -0
- package/dist/internal/features/work/work-docx-paragraph-shading-import.d.ts +18 -0
- package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +3 -0
- package/dist/internal/features/work/work-docx-settings-preservation.d.ts +10 -0
- package/dist/internal/features/work/work-docx-settings-xml.d.ts +16 -0
- package/dist/internal/features/work/work-docx-style-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-cell-export.d.ts +2 -1
- package/dist/internal/features/work/work-docx-table-cell-import.d.ts +3 -0
- package/dist/internal/features/work/work-docx-table-extension-preservation.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-row-import.d.ts +2 -0
- package/dist/internal/features/work/work-docx-table-sizing-import.d.ts +1 -0
- package/dist/internal/features/work/work-docx-theme-reference.d.ts +23 -0
- package/dist/internal/features/work/work-docx-theme.d.ts +4 -1
- package/dist/internal/features/work/work-docx-twips.d.ts +12 -0
- package/dist/internal/features/work/work-file-contract.d.ts +1 -0
- package/dist/internal/features/work/work-file-io.d.ts +1 -1
- package/dist/internal/features/work/work-markdown-extensions.d.ts +4 -1
- package/dist/internal/features/work/work-ooxml-package-preservation.d.ts +12 -0
- package/dist/internal/features/work/work-ooxml-package-security.d.ts +6 -0
- package/dist/internal/features/work/work-ooxml-relationship-preservation.d.ts +10 -0
- package/dist/internal/features/work/work-ooxml-xml.d.ts +2 -0
- package/dist/internal/features/work/work-pdf-export.d.ts +10 -0
- package/dist/internal/features/work/work-repository.d.ts +2 -0
- package/dist/internal/features/work/work-types.d.ts +15 -2
- package/dist/internal/kernel/office-kernel-client-types.d.ts +1 -0
- package/dist/internal/kernel/office-kernel-protocol.d.ts +7 -0
- package/dist/internal/kernel/office-kernel-version.d.ts +1 -1
- package/dist/office-kernel.wasm +0 -0
- package/dist/office-kernel.worker.js +93 -41
- package/dist/react.d.ts +18 -12
- package/dist/react.js +1 -1
- package/dist/styles.css +1367 -16
- package/dist/vue.d.ts +48 -5
- package/dist/vue.js +42 -3
- package/dist/web-component.d.ts +24 -2
- package/dist/web-component.js +101 -2
- package/docs/latest/en/browser-editor-architecture.md +262 -47
- package/package.json +29 -4
- package/dist/0~152.js +0 -94
- package/dist/0~2582.js +0 -485
- package/dist/0~4750.js +0 -939
- package/dist/0~5861.js +0 -596
- package/dist/0~work-document-extensions.js +0 -3045
- package/dist/0~work-document-model-codec.js +0 -42
- package/dist/0~work-docx-bibliography.js +0 -347
- package/dist/0~work-docx-page-color.js +0 -42
- package/dist/2881.js +0 -1455
- package/dist/8728.js +0 -723
package/dist/4650.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { OfficeCollaborationError as WorkOfficeCollaborationError } from "./9787.js";
|
|
2
|
+
function cloneWorkOfficeCollaborationJson(value, seen = new WeakSet()) {
|
|
3
|
+
if (null === value || 'string' == typeof value || 'boolean' == typeof value) return value;
|
|
4
|
+
if ('number' == typeof value && Number.isFinite(value)) return value;
|
|
5
|
+
if (Array.isArray(value)) {
|
|
6
|
+
if (seen.has(value)) invalidCollaborationJson('acyclic JSON values');
|
|
7
|
+
seen.add(value);
|
|
8
|
+
const clone = value.map((item)=>cloneWorkOfficeCollaborationJson(item, seen));
|
|
9
|
+
seen.delete(value);
|
|
10
|
+
return clone;
|
|
11
|
+
}
|
|
12
|
+
if (isWorkOfficeCollaborationRecord(value)) {
|
|
13
|
+
if (!isPlainJsonRecord(value)) invalidCollaborationJson('plain JSON objects');
|
|
14
|
+
if (seen.has(value)) invalidCollaborationJson('acyclic JSON values');
|
|
15
|
+
seen.add(value);
|
|
16
|
+
const clone = {};
|
|
17
|
+
for (const [key, item] of Object.entries(value)){
|
|
18
|
+
if (isUnsafeJsonKey(key)) invalidCollaborationJson('objects without prototype keys');
|
|
19
|
+
if (void 0 !== item) Object.defineProperty(clone, key, {
|
|
20
|
+
configurable: true,
|
|
21
|
+
enumerable: true,
|
|
22
|
+
value: cloneWorkOfficeCollaborationJson(item, seen),
|
|
23
|
+
writable: true
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
seen.delete(value);
|
|
27
|
+
return clone;
|
|
28
|
+
}
|
|
29
|
+
invalidCollaborationJson('JSON-compatible values');
|
|
30
|
+
}
|
|
31
|
+
function workOfficeCollaborationJsonEqual(left, right) {
|
|
32
|
+
if (Object.is(left, right)) return true;
|
|
33
|
+
if (Array.isArray(left) && Array.isArray(right)) return left.length === right.length && left.every((value, index)=>workOfficeCollaborationJsonEqual(value, right[index]));
|
|
34
|
+
if (isWorkOfficeCollaborationRecord(left) && isWorkOfficeCollaborationRecord(right)) {
|
|
35
|
+
if (!isPlainJsonRecord(left) || !isPlainJsonRecord(right)) return false;
|
|
36
|
+
const leftKeys = Object.keys(left).filter((key)=>void 0 !== left[key]);
|
|
37
|
+
const rightKeys = Object.keys(right).filter((key)=>void 0 !== right[key]);
|
|
38
|
+
return leftKeys.length === rightKeys.length && leftKeys.every((key)=>Object.hasOwn(right, key) && workOfficeCollaborationJsonEqual(left[key], right[key]));
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function canonicalWorkOfficeCollaborationJson(value) {
|
|
43
|
+
return JSON.stringify(canonicalJsonValue(cloneWorkOfficeCollaborationJson(value)));
|
|
44
|
+
}
|
|
45
|
+
function isWorkOfficeCollaborationRecord(value) {
|
|
46
|
+
return 'object' == typeof value && null !== value && !Array.isArray(value);
|
|
47
|
+
}
|
|
48
|
+
function canonicalJsonValue(value) {
|
|
49
|
+
if (Array.isArray(value)) return value.map(canonicalJsonValue);
|
|
50
|
+
if (!isWorkOfficeCollaborationRecord(value)) return value;
|
|
51
|
+
const result = {};
|
|
52
|
+
for (const key of Object.keys(value).sort())Object.defineProperty(result, key, {
|
|
53
|
+
configurable: true,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
value: canonicalJsonValue(value[key]),
|
|
56
|
+
writable: true
|
|
57
|
+
});
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
function isPlainJsonRecord(value) {
|
|
61
|
+
const prototype = Object.getPrototypeOf(value);
|
|
62
|
+
return prototype === Object.prototype || null === prototype;
|
|
63
|
+
}
|
|
64
|
+
function isUnsafeJsonKey(key) {
|
|
65
|
+
return '__proto__' === key || 'constructor' === key || 'prototype' === key;
|
|
66
|
+
}
|
|
67
|
+
function invalidCollaborationJson(expected) {
|
|
68
|
+
throw new WorkOfficeCollaborationError('office.collaboration.content_invalid', `Office collaboration requires ${expected}.`);
|
|
69
|
+
}
|
|
70
|
+
export { canonicalWorkOfficeCollaborationJson, cloneWorkOfficeCollaborationJson, isWorkOfficeCollaborationRecord, workOfficeCollaborationJsonEqual };
|
package/dist/{1134.js → 5184.js}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import jszip from "jszip";
|
|
1
2
|
const WORK_TEMPLATES = [
|
|
2
3
|
{
|
|
3
4
|
id: 'blank-document',
|
|
@@ -442,4 +443,185 @@ function strategyPresentation() {
|
|
|
442
443
|
slides
|
|
443
444
|
};
|
|
444
445
|
}
|
|
445
|
-
|
|
446
|
+
function decodeXmlBytes(bytes, label) {
|
|
447
|
+
let encoding = 'utf-8';
|
|
448
|
+
let offset = 0;
|
|
449
|
+
if (0xef === bytes[0] && 0xbb === bytes[1] && 0xbf === bytes[2]) offset = 3;
|
|
450
|
+
else if (0xff === bytes[0] && 0xfe === bytes[1]) {
|
|
451
|
+
encoding = 'utf-16le';
|
|
452
|
+
offset = 2;
|
|
453
|
+
} else if (0xfe === bytes[0] && 0xff === bytes[1]) {
|
|
454
|
+
encoding = 'utf-16be';
|
|
455
|
+
offset = 2;
|
|
456
|
+
} else if (0x3c === bytes[0] && 0 === bytes[1] && 0x3f === bytes[2] && 0 === bytes[3]) encoding = 'utf-16le';
|
|
457
|
+
else if (0 === bytes[0] && 0x3c === bytes[1] && 0 === bytes[2] && 0x3f === bytes[3]) encoding = 'utf-16be';
|
|
458
|
+
try {
|
|
459
|
+
return new TextDecoder(encoding, {
|
|
460
|
+
fatal: true
|
|
461
|
+
}).decode(bytes.subarray(offset));
|
|
462
|
+
} catch {
|
|
463
|
+
throw new Error(`${label} uses an invalid ${encoding} XML encoding.`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function serializeUtf8Xml(document) {
|
|
467
|
+
const serialized = new XMLSerializer().serializeToString(document);
|
|
468
|
+
const body = serialized.replace(/^\s*<\?xml[^?]*\?>\s*/i, '');
|
|
469
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>${body}`;
|
|
470
|
+
}
|
|
471
|
+
class OoxmlPackage {
|
|
472
|
+
zip;
|
|
473
|
+
constructor(zip){
|
|
474
|
+
this.zip = zip;
|
|
475
|
+
}
|
|
476
|
+
static async load(buffer) {
|
|
477
|
+
return new OoxmlPackage(await jszip.loadAsync(buffer));
|
|
478
|
+
}
|
|
479
|
+
has(partPath) {
|
|
480
|
+
return Boolean(this.zip.file(partPath));
|
|
481
|
+
}
|
|
482
|
+
paths(prefix) {
|
|
483
|
+
return Object.keys(this.zip.files).filter((path)=>path.startsWith(prefix) && !this.zip.files[path]?.dir);
|
|
484
|
+
}
|
|
485
|
+
async text(partPath) {
|
|
486
|
+
const entry = this.zip.file(partPath);
|
|
487
|
+
if (!entry) throw new Error(`Office package part is missing: ${partPath}`);
|
|
488
|
+
return decodeXmlBytes(await entry.async('uint8array'), partPath);
|
|
489
|
+
}
|
|
490
|
+
async xml(partPath) {
|
|
491
|
+
return parseXml(await this.text(partPath), partPath);
|
|
492
|
+
}
|
|
493
|
+
async bytes(partPath) {
|
|
494
|
+
const entry = this.zip.file(partPath);
|
|
495
|
+
if (!entry) throw new Error(`Office package part is missing: ${partPath}`);
|
|
496
|
+
return entry.async('uint8array');
|
|
497
|
+
}
|
|
498
|
+
async relationships(sourcePart) {
|
|
499
|
+
const partPath = relationshipsPartPath(sourcePart);
|
|
500
|
+
if (!this.has(partPath)) return new Map();
|
|
501
|
+
const document = await this.xml(partPath);
|
|
502
|
+
return new Map(descendants(document, 'Relationship').map((element)=>{
|
|
503
|
+
const relationship = {
|
|
504
|
+
id: attribute(element, 'Id') ?? '',
|
|
505
|
+
target: resolvePartTarget(sourcePart, attribute(element, 'Target') ?? ''),
|
|
506
|
+
type: attribute(element, 'Type') ?? '',
|
|
507
|
+
targetMode: attribute(element, 'TargetMode') ?? void 0
|
|
508
|
+
};
|
|
509
|
+
return [
|
|
510
|
+
relationship.id,
|
|
511
|
+
relationship
|
|
512
|
+
];
|
|
513
|
+
}));
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
function parseXml(source, label = 'Office XML') {
|
|
517
|
+
const document = new DOMParser().parseFromString(source, 'application/xml');
|
|
518
|
+
const error = descendants(document, 'parsererror')[0];
|
|
519
|
+
if (error) throw new Error(`${label} is not valid XML: ${error.textContent?.trim() || 'parse error'}`);
|
|
520
|
+
return document;
|
|
521
|
+
}
|
|
522
|
+
function attribute(element, name) {
|
|
523
|
+
const direct = element.getAttribute(name);
|
|
524
|
+
if (null !== direct) return direct;
|
|
525
|
+
const localName = name.includes(':') ? name.slice(name.indexOf(':') + 1) : name;
|
|
526
|
+
return Array.from(element.attributes).find((item)=>{
|
|
527
|
+
const itemLocalName = item.localName.includes(':') ? item.localName.slice(item.localName.indexOf(':') + 1) : item.localName;
|
|
528
|
+
return itemLocalName === localName && (!name.includes(':') || item.name === name);
|
|
529
|
+
})?.value ?? null;
|
|
530
|
+
}
|
|
531
|
+
function xmlNamespacePrefix(element, namespace) {
|
|
532
|
+
if (!namespace) return element.prefix;
|
|
533
|
+
if ('function' == typeof element.lookupPrefix) {
|
|
534
|
+
const prefix = element.lookupPrefix(namespace);
|
|
535
|
+
if (prefix) return prefix;
|
|
536
|
+
}
|
|
537
|
+
let current = element;
|
|
538
|
+
while(current){
|
|
539
|
+
if (current.namespaceURI === namespace && current.prefix) return current.prefix;
|
|
540
|
+
const declaration = Array.from(current.attributes).find((item)=>item.value === namespace && ('xmlns' === item.name || item.name.startsWith('xmlns:')));
|
|
541
|
+
if (declaration?.name.startsWith('xmlns:')) return declaration.name.slice(6);
|
|
542
|
+
current = current.parentElement;
|
|
543
|
+
}
|
|
544
|
+
return null;
|
|
545
|
+
}
|
|
546
|
+
function directChildren(parent, localName) {
|
|
547
|
+
return Array.from(parent.children).filter((element)=>!localName || element.localName === localName);
|
|
548
|
+
}
|
|
549
|
+
function directChild(parent, localName) {
|
|
550
|
+
return directChildren(parent, localName)[0];
|
|
551
|
+
}
|
|
552
|
+
function descendants(parent, localName) {
|
|
553
|
+
return Array.from(parent.querySelectorAll('*')).filter((element)=>element.localName === localName);
|
|
554
|
+
}
|
|
555
|
+
function firstDescendant(parent, localName) {
|
|
556
|
+
if (!parent) return;
|
|
557
|
+
return descendants(parent, localName)[0];
|
|
558
|
+
}
|
|
559
|
+
function childPath(parent, ...localNames) {
|
|
560
|
+
let current = parent;
|
|
561
|
+
for (const name of localNames){
|
|
562
|
+
if (!current) return;
|
|
563
|
+
current = directChild(current, name);
|
|
564
|
+
}
|
|
565
|
+
return current instanceof Element ? current : void 0;
|
|
566
|
+
}
|
|
567
|
+
function resolvePartTarget(sourcePart, target) {
|
|
568
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(target)) return target;
|
|
569
|
+
const segments = target.startsWith('/') ? [] : sourcePart.split('/').slice(0, -1);
|
|
570
|
+
for (const segment of target.replace(/^\/+/, '').split('/'))if (segment && '.' !== segment) if ('..' === segment) segments.pop();
|
|
571
|
+
else segments.push(segment);
|
|
572
|
+
return segments.join('/');
|
|
573
|
+
}
|
|
574
|
+
function contentTypeForPart(partPath) {
|
|
575
|
+
const extension = partPath.split('.').pop()?.toLowerCase();
|
|
576
|
+
const types = {
|
|
577
|
+
apng: 'image/apng',
|
|
578
|
+
bmp: 'image/bmp',
|
|
579
|
+
emf: 'image/emf',
|
|
580
|
+
gif: 'image/gif',
|
|
581
|
+
jpeg: 'image/jpeg',
|
|
582
|
+
jpg: 'image/jpeg',
|
|
583
|
+
png: 'image/png',
|
|
584
|
+
svg: 'image/svg+xml',
|
|
585
|
+
tif: 'image/tiff',
|
|
586
|
+
tiff: 'image/tiff',
|
|
587
|
+
webp: 'image/webp',
|
|
588
|
+
wmf: 'image/wmf'
|
|
589
|
+
};
|
|
590
|
+
return types[extension ?? ''] ?? 'application/octet-stream';
|
|
591
|
+
}
|
|
592
|
+
function bytesToDataUrl(bytes, contentType) {
|
|
593
|
+
let binary = '';
|
|
594
|
+
const chunkSize = 32768;
|
|
595
|
+
for(let offset = 0; offset < bytes.length; offset += chunkSize)binary += String.fromCharCode(...bytes.subarray(offset, offset + chunkSize));
|
|
596
|
+
return `data:${contentType};base64,${btoa(binary)}`;
|
|
597
|
+
}
|
|
598
|
+
function relationshipsPartPath(sourcePart) {
|
|
599
|
+
const separator = sourcePart.lastIndexOf('/');
|
|
600
|
+
const directory = separator >= 0 ? sourcePart.slice(0, separator + 1) : '';
|
|
601
|
+
const fileName = separator >= 0 ? sourcePart.slice(separator + 1) : sourcePart;
|
|
602
|
+
return `${directory}_rels/${fileName}.rels`;
|
|
603
|
+
}
|
|
604
|
+
const OFFICE_KERNEL_SPREADSHEET_MAX_ROWS = 1048576;
|
|
605
|
+
const spreadsheetErrors = new Set([
|
|
606
|
+
'#BLOCKED!',
|
|
607
|
+
'#BUSY!',
|
|
608
|
+
'#CALC!',
|
|
609
|
+
'#CONNECT!',
|
|
610
|
+
'#DIV/0!',
|
|
611
|
+
'#FIELD!',
|
|
612
|
+
'#GETTING_DATA',
|
|
613
|
+
'#N/A',
|
|
614
|
+
'#NAME?',
|
|
615
|
+
'#NULL!',
|
|
616
|
+
'#NUM!',
|
|
617
|
+
'#PYTHON!',
|
|
618
|
+
'#REF!',
|
|
619
|
+
'#SPILL!',
|
|
620
|
+
'#UNKNOWN!',
|
|
621
|
+
'#VALUE!'
|
|
622
|
+
]);
|
|
623
|
+
new TextEncoder();
|
|
624
|
+
function isOfficeKernelSpreadsheetError(value) {
|
|
625
|
+
return 'string' == typeof value && spreadsheetErrors.has(value);
|
|
626
|
+
}
|
|
627
|
+
export { OFFICE_KERNEL_SPREADSHEET_MAX_ROWS, OoxmlPackage, WORK_TEMPLATES as officeTemplates, attribute, bytesToDataUrl, childPath, contentTypeForPart, createWorkArtifact as createArtifact, createWorkId as createOfficeId, decodeXmlBytes, descendants, directChild, directChildren, firstDescendant, isOfficeKernelSpreadsheetError, parseXml, resolvePartTarget, serializeUtf8Xml, xmlNamespacePrefix };
|
package/dist/6489.js
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
const OFFICE_NOTIFICATION_EVENT = 'a3s-office:notify';
|
|
2
|
-
function showToast(message, tone = 'info') {
|
|
3
|
-
if ("u" < typeof window) return;
|
|
4
|
-
window.dispatchEvent(new CustomEvent(OFFICE_NOTIFICATION_EVENT, {
|
|
5
|
-
detail: {
|
|
6
|
-
message,
|
|
7
|
-
tone
|
|
8
|
-
}
|
|
9
|
-
}));
|
|
10
|
-
}
|
|
11
|
-
function subscribeOfficeNotifications(listener) {
|
|
12
|
-
if ("u" < typeof window) return ()=>void 0;
|
|
13
|
-
const receive = (event)=>{
|
|
14
|
-
if (event instanceof CustomEvent) listener(event.detail);
|
|
15
|
-
};
|
|
16
|
-
window.addEventListener(OFFICE_NOTIFICATION_EVENT, receive);
|
|
17
|
-
return ()=>window.removeEventListener(OFFICE_NOTIFICATION_EVENT, receive);
|
|
18
|
-
}
|
|
19
1
|
const WORK_AGENT_PROPOSAL_PROTOCOL = 'a3s-work-proposal/v1';
|
|
20
2
|
const maximumProposalTargets = 200;
|
|
21
3
|
const maximumTargetSourceLength = 12000;
|
|
@@ -179,4 +161,22 @@ function createProposalId() {
|
|
|
179
161
|
function isRecord(value) {
|
|
180
162
|
return Boolean(value) && 'object' == typeof value && !Array.isArray(value);
|
|
181
163
|
}
|
|
164
|
+
const OFFICE_NOTIFICATION_EVENT = 'a3s-office:notify';
|
|
165
|
+
function showToast(message, tone = 'info') {
|
|
166
|
+
if ("u" < typeof window) return;
|
|
167
|
+
window.dispatchEvent(new CustomEvent(OFFICE_NOTIFICATION_EVENT, {
|
|
168
|
+
detail: {
|
|
169
|
+
message,
|
|
170
|
+
tone
|
|
171
|
+
}
|
|
172
|
+
}));
|
|
173
|
+
}
|
|
174
|
+
function subscribeOfficeNotifications(listener) {
|
|
175
|
+
if ("u" < typeof window) return ()=>void 0;
|
|
176
|
+
const receive = (event)=>{
|
|
177
|
+
if (event instanceof CustomEvent) listener(event.detail);
|
|
178
|
+
};
|
|
179
|
+
window.addEventListener(OFFICE_NOTIFICATION_EVENT, receive);
|
|
180
|
+
return ()=>window.removeEventListener(OFFICE_NOTIFICATION_EVENT, receive);
|
|
181
|
+
}
|
|
182
182
|
export { OFFICE_NOTIFICATION_EVENT, WORK_AGENT_PROPOSAL_PROTOCOL as AGENT_PROPOSAL_PROTOCOL, createWorkAgentProposalRequest as createAgentProposalRequest, showToast, subscribeOfficeNotifications, workAgentProposalInstruction as createAgentProposalInstruction, workAgentProposalStatus as getAgentProposalStatus };
|
package/dist/7060.js
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { workOfficeCollaborationJsonEqual, isWorkOfficeCollaborationRecord, cloneWorkOfficeCollaborationJson } from "./4650.js";
|
|
2
|
+
import { OfficeCollaborationError as WorkOfficeCollaborationError } from "./9787.js";
|
|
3
|
+
import * as __rspack_external_yjs from "yjs";
|
|
4
|
+
function patchWorkOfficeCollaborationFlatJsonMap(target, previous, next, label) {
|
|
5
|
+
const before = flattenRecord(previous ?? {});
|
|
6
|
+
const after = flattenRecord(next ?? {});
|
|
7
|
+
const keys = new Set([
|
|
8
|
+
...before.keys(),
|
|
9
|
+
...after.keys()
|
|
10
|
+
]);
|
|
11
|
+
for (const key of keys){
|
|
12
|
+
const beforeValue = before.get(key);
|
|
13
|
+
const afterValue = after.get(key);
|
|
14
|
+
const hadBefore = before.has(key);
|
|
15
|
+
const hasAfter = after.has(key);
|
|
16
|
+
if (!(hadBefore && hasAfter && workOfficeCollaborationJsonEqual(beforeValue, afterValue))) if (hasAfter) target.set(key, cloneWorkOfficeCollaborationJson(afterValue));
|
|
17
|
+
else {
|
|
18
|
+
if (hadBefore && !workOfficeCollaborationJsonEqual(target.get(key), beforeValue)) throw new WorkOfficeCollaborationError('office.collaboration.content_invalid', `The ${label} changed before one of its fields was removed. Refresh the shared snapshot before retrying.`);
|
|
19
|
+
target.delete(key);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function readWorkOfficeCollaborationFlatJsonMap(target, label, invalidShared) {
|
|
24
|
+
const entries = [];
|
|
25
|
+
for (const [encoded, value] of target.entries()){
|
|
26
|
+
if (value instanceof __rspack_external_yjs.AbstractType) invalidShared(`${label} field '${encoded}'`);
|
|
27
|
+
entries.push(decodedEntry(encoded, value, label, invalidShared));
|
|
28
|
+
}
|
|
29
|
+
entries.sort((left, right)=>{
|
|
30
|
+
const depth = left.path.length - right.path.length;
|
|
31
|
+
if (0 !== depth) return depth;
|
|
32
|
+
if (left.kind === right.kind) return 0;
|
|
33
|
+
return 'object' === left.kind ? -1 : 1;
|
|
34
|
+
});
|
|
35
|
+
const result = {};
|
|
36
|
+
const objectPaths = new Set();
|
|
37
|
+
for (const entry of entries){
|
|
38
|
+
const identity = JSON.stringify(entry.path);
|
|
39
|
+
if ('object' === entry.kind) {
|
|
40
|
+
if (true !== entry.value || 0 === entry.path.length) invalidShared(`${label} object marker`);
|
|
41
|
+
const existing = valueAtPath(result, entry.path);
|
|
42
|
+
if (void 0 !== existing && !isWorkOfficeCollaborationRecord(existing)) invalidShared(`${label} object/value overlap`);
|
|
43
|
+
ensureObjectPath(result, entry.path, label, invalidShared);
|
|
44
|
+
objectPaths.add(identity);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (0 === entry.path.length) invalidShared(`${label} root value`);
|
|
48
|
+
setValueAtPath(result, entry.path, cloneWorkOfficeCollaborationJson(entry.value), label, invalidShared);
|
|
49
|
+
}
|
|
50
|
+
for (const entry of entries)for(let depth = 1; depth < entry.path.length; depth += 1)if (!objectPaths.has(JSON.stringify(entry.path.slice(0, depth)))) invalidShared(`${label} missing object marker`);
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
function flattenRecord(value) {
|
|
54
|
+
const result = new Map();
|
|
55
|
+
for (const [key, child] of Object.entries(value))flattenValue(result, [
|
|
56
|
+
key
|
|
57
|
+
], child);
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
function flattenValue(result, path, value) {
|
|
61
|
+
assertSafePath(path, 'Office collaboration field');
|
|
62
|
+
if (isWorkOfficeCollaborationRecord(value)) {
|
|
63
|
+
result.set(encodedEntry('object', path), true);
|
|
64
|
+
for (const [key, child] of Object.entries(value))flattenValue(result, [
|
|
65
|
+
...path,
|
|
66
|
+
key
|
|
67
|
+
], child);
|
|
68
|
+
} else result.set(encodedEntry('value', path), cloneWorkOfficeCollaborationJson(value));
|
|
69
|
+
}
|
|
70
|
+
function encodedEntry(kind, path) {
|
|
71
|
+
return JSON.stringify([
|
|
72
|
+
kind,
|
|
73
|
+
...path
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
function decodedEntry(encoded, value, label, invalidShared) {
|
|
77
|
+
let identity;
|
|
78
|
+
try {
|
|
79
|
+
identity = JSON.parse(encoded);
|
|
80
|
+
} catch {
|
|
81
|
+
invalidShared(`${label} field identity`);
|
|
82
|
+
}
|
|
83
|
+
if (!Array.isArray(identity) || identity.length < 2 || 'object' !== identity[0] && 'value' !== identity[0] || identity.slice(1).some((part)=>'string' != typeof part) || encodedEntry(identity[0], identity.slice(1)) !== encoded) invalidShared(`${label} field identity`);
|
|
84
|
+
assertSafePath(identity.slice(1), label);
|
|
85
|
+
return {
|
|
86
|
+
kind: identity[0],
|
|
87
|
+
path: identity.slice(1),
|
|
88
|
+
value
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function assertSafePath(path, label) {
|
|
92
|
+
if (path.some((part)=>!part || '__proto__' === part || 'constructor' === part || 'prototype' === part)) throw new WorkOfficeCollaborationError('office.collaboration.content_invalid', `${label} paths must not contain empty or prototype keys.`);
|
|
93
|
+
}
|
|
94
|
+
function valueAtPath(root, path) {
|
|
95
|
+
let current = root;
|
|
96
|
+
for (const part of path){
|
|
97
|
+
if (!isWorkOfficeCollaborationRecord(current) || !Object.hasOwn(current, part)) return;
|
|
98
|
+
current = current[part];
|
|
99
|
+
}
|
|
100
|
+
return current;
|
|
101
|
+
}
|
|
102
|
+
function ensureObjectPath(root, path, label, invalidShared) {
|
|
103
|
+
let current = root;
|
|
104
|
+
for (const part of path){
|
|
105
|
+
const existing = current[part];
|
|
106
|
+
if (void 0 === existing) {
|
|
107
|
+
defineJsonProperty(current, part, {});
|
|
108
|
+
current = current[part];
|
|
109
|
+
} else if (isWorkOfficeCollaborationRecord(existing)) current = existing;
|
|
110
|
+
else invalidShared(`${label} object/value overlap`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function setValueAtPath(root, path, value, label, invalidShared) {
|
|
114
|
+
let current = root;
|
|
115
|
+
for (const part of path.slice(0, -1)){
|
|
116
|
+
const existing = current[part];
|
|
117
|
+
if (!isWorkOfficeCollaborationRecord(existing)) invalidShared(`${label} value without object parent`);
|
|
118
|
+
current = existing;
|
|
119
|
+
}
|
|
120
|
+
const key = path.at(-1);
|
|
121
|
+
if (Object.hasOwn(current, key)) invalidShared(`${label} duplicate object/value field`);
|
|
122
|
+
defineJsonProperty(current, key, value);
|
|
123
|
+
}
|
|
124
|
+
function defineJsonProperty(target, key, value) {
|
|
125
|
+
Object.defineProperty(target, key, {
|
|
126
|
+
configurable: true,
|
|
127
|
+
enumerable: true,
|
|
128
|
+
value,
|
|
129
|
+
writable: true
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
export { patchWorkOfficeCollaborationFlatJsonMap, readWorkOfficeCollaborationFlatJsonMap };
|
package/dist/8715.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { createOfficeId as createWorkId } from "./1134.js";
|
|
1
|
+
import { createOfficeId as createWorkId, directChild, attribute } from "./5184.js";
|
|
3
2
|
function normalizeWorkSpreadsheetDoughnutHoleSize(value) {
|
|
4
3
|
const size = Number(value);
|
|
5
4
|
if (!Number.isFinite(size)) return 50;
|
|
@@ -1060,139 +1059,6 @@ function invalid(code, message) {
|
|
|
1060
1059
|
message
|
|
1061
1060
|
};
|
|
1062
1061
|
}
|
|
1063
|
-
class OoxmlPackage {
|
|
1064
|
-
zip;
|
|
1065
|
-
constructor(zip){
|
|
1066
|
-
this.zip = zip;
|
|
1067
|
-
}
|
|
1068
|
-
static async load(buffer) {
|
|
1069
|
-
return new OoxmlPackage(await jszip.loadAsync(buffer));
|
|
1070
|
-
}
|
|
1071
|
-
has(partPath) {
|
|
1072
|
-
return Boolean(this.zip.file(partPath));
|
|
1073
|
-
}
|
|
1074
|
-
paths(prefix) {
|
|
1075
|
-
return Object.keys(this.zip.files).filter((path)=>path.startsWith(prefix) && !this.zip.files[path]?.dir);
|
|
1076
|
-
}
|
|
1077
|
-
async text(partPath) {
|
|
1078
|
-
const entry = this.zip.file(partPath);
|
|
1079
|
-
if (!entry) throw new Error(`Office package part is missing: ${partPath}`);
|
|
1080
|
-
return entry.async('text');
|
|
1081
|
-
}
|
|
1082
|
-
async xml(partPath) {
|
|
1083
|
-
return parseXml(await this.text(partPath), partPath);
|
|
1084
|
-
}
|
|
1085
|
-
async bytes(partPath) {
|
|
1086
|
-
const entry = this.zip.file(partPath);
|
|
1087
|
-
if (!entry) throw new Error(`Office package part is missing: ${partPath}`);
|
|
1088
|
-
return entry.async('uint8array');
|
|
1089
|
-
}
|
|
1090
|
-
async relationships(sourcePart) {
|
|
1091
|
-
const partPath = relationshipsPartPath(sourcePart);
|
|
1092
|
-
if (!this.has(partPath)) return new Map();
|
|
1093
|
-
const document = await this.xml(partPath);
|
|
1094
|
-
return new Map(descendants(document, 'Relationship').map((element)=>{
|
|
1095
|
-
const relationship = {
|
|
1096
|
-
id: attribute(element, 'Id') ?? '',
|
|
1097
|
-
target: resolvePartTarget(sourcePart, attribute(element, 'Target') ?? ''),
|
|
1098
|
-
type: attribute(element, 'Type') ?? '',
|
|
1099
|
-
targetMode: attribute(element, 'TargetMode') ?? void 0
|
|
1100
|
-
};
|
|
1101
|
-
return [
|
|
1102
|
-
relationship.id,
|
|
1103
|
-
relationship
|
|
1104
|
-
];
|
|
1105
|
-
}));
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
function parseXml(source, label = 'Office XML') {
|
|
1109
|
-
const document = new DOMParser().parseFromString(source, 'application/xml');
|
|
1110
|
-
const error = descendants(document, 'parsererror')[0];
|
|
1111
|
-
if (error) throw new Error(`${label} is not valid XML: ${error.textContent?.trim() || 'parse error'}`);
|
|
1112
|
-
return document;
|
|
1113
|
-
}
|
|
1114
|
-
function attribute(element, name) {
|
|
1115
|
-
const direct = element.getAttribute(name);
|
|
1116
|
-
if (null !== direct) return direct;
|
|
1117
|
-
const localName = name.includes(':') ? name.slice(name.indexOf(':') + 1) : name;
|
|
1118
|
-
return Array.from(element.attributes).find((item)=>{
|
|
1119
|
-
const itemLocalName = item.localName.includes(':') ? item.localName.slice(item.localName.indexOf(':') + 1) : item.localName;
|
|
1120
|
-
return itemLocalName === localName && (!name.includes(':') || item.name === name);
|
|
1121
|
-
})?.value ?? null;
|
|
1122
|
-
}
|
|
1123
|
-
function xmlNamespacePrefix(element, namespace) {
|
|
1124
|
-
if (!namespace) return element.prefix;
|
|
1125
|
-
if ('function' == typeof element.lookupPrefix) {
|
|
1126
|
-
const prefix = element.lookupPrefix(namespace);
|
|
1127
|
-
if (prefix) return prefix;
|
|
1128
|
-
}
|
|
1129
|
-
let current = element;
|
|
1130
|
-
while(current){
|
|
1131
|
-
if (current.namespaceURI === namespace && current.prefix) return current.prefix;
|
|
1132
|
-
const declaration = Array.from(current.attributes).find((item)=>item.value === namespace && ('xmlns' === item.name || item.name.startsWith('xmlns:')));
|
|
1133
|
-
if (declaration?.name.startsWith('xmlns:')) return declaration.name.slice(6);
|
|
1134
|
-
current = current.parentElement;
|
|
1135
|
-
}
|
|
1136
|
-
return null;
|
|
1137
|
-
}
|
|
1138
|
-
function directChildren(parent, localName) {
|
|
1139
|
-
return Array.from(parent.children).filter((element)=>!localName || element.localName === localName);
|
|
1140
|
-
}
|
|
1141
|
-
function directChild(parent, localName) {
|
|
1142
|
-
return directChildren(parent, localName)[0];
|
|
1143
|
-
}
|
|
1144
|
-
function descendants(parent, localName) {
|
|
1145
|
-
return Array.from(parent.querySelectorAll('*')).filter((element)=>element.localName === localName);
|
|
1146
|
-
}
|
|
1147
|
-
function firstDescendant(parent, localName) {
|
|
1148
|
-
if (!parent) return;
|
|
1149
|
-
return descendants(parent, localName)[0];
|
|
1150
|
-
}
|
|
1151
|
-
function childPath(parent, ...localNames) {
|
|
1152
|
-
let current = parent;
|
|
1153
|
-
for (const name of localNames){
|
|
1154
|
-
if (!current) return;
|
|
1155
|
-
current = directChild(current, name);
|
|
1156
|
-
}
|
|
1157
|
-
return current instanceof Element ? current : void 0;
|
|
1158
|
-
}
|
|
1159
|
-
function resolvePartTarget(sourcePart, target) {
|
|
1160
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(target)) return target;
|
|
1161
|
-
const segments = target.startsWith('/') ? [] : sourcePart.split('/').slice(0, -1);
|
|
1162
|
-
for (const segment of target.replace(/^\/+/, '').split('/'))if (segment && '.' !== segment) if ('..' === segment) segments.pop();
|
|
1163
|
-
else segments.push(segment);
|
|
1164
|
-
return segments.join('/');
|
|
1165
|
-
}
|
|
1166
|
-
function contentTypeForPart(partPath) {
|
|
1167
|
-
const extension = partPath.split('.').pop()?.toLowerCase();
|
|
1168
|
-
const types = {
|
|
1169
|
-
apng: 'image/apng',
|
|
1170
|
-
bmp: 'image/bmp',
|
|
1171
|
-
emf: 'image/emf',
|
|
1172
|
-
gif: 'image/gif',
|
|
1173
|
-
jpeg: 'image/jpeg',
|
|
1174
|
-
jpg: 'image/jpeg',
|
|
1175
|
-
png: 'image/png',
|
|
1176
|
-
svg: 'image/svg+xml',
|
|
1177
|
-
tif: 'image/tiff',
|
|
1178
|
-
tiff: 'image/tiff',
|
|
1179
|
-
webp: 'image/webp',
|
|
1180
|
-
wmf: 'image/wmf'
|
|
1181
|
-
};
|
|
1182
|
-
return types[extension ?? ''] ?? 'application/octet-stream';
|
|
1183
|
-
}
|
|
1184
|
-
function bytesToDataUrl(bytes, contentType) {
|
|
1185
|
-
let binary = '';
|
|
1186
|
-
const chunkSize = 32768;
|
|
1187
|
-
for(let offset = 0; offset < bytes.length; offset += chunkSize)binary += String.fromCharCode(...bytes.subarray(offset, offset + chunkSize));
|
|
1188
|
-
return `data:${contentType};base64,${btoa(binary)}`;
|
|
1189
|
-
}
|
|
1190
|
-
function relationshipsPartPath(sourcePart) {
|
|
1191
|
-
const separator = sourcePart.lastIndexOf('/');
|
|
1192
|
-
const directory = separator >= 0 ? sourcePart.slice(0, separator + 1) : '';
|
|
1193
|
-
const fileName = separator >= 0 ? sourcePart.slice(separator + 1) : sourcePart;
|
|
1194
|
-
return `${directory}_rels/${fileName}.rels`;
|
|
1195
|
-
}
|
|
1196
1062
|
const WORK_SPREADSHEET_CHART_COLORS = [
|
|
1197
1063
|
'#4f6bed',
|
|
1198
1064
|
'#e66c37',
|
|
@@ -3956,4 +3822,4 @@ function positiveNumber(value, fallback) {
|
|
|
3956
3822
|
function transformFormulaOutsideStrings(formula, transform) {
|
|
3957
3823
|
return formula.split(/("(?:[^"]|"")*")/).map((segment, index)=>index % 2 ? segment : transform(segment)).join('');
|
|
3958
3824
|
}
|
|
3959
|
-
export {
|
|
3825
|
+
export { createSpreadsheetChartFromSelection, createSpreadsheetPivotFromSelection, defaultPivotValueCaption, defaultWorkSpreadsheetChartSeriesStyle, deleteSpreadsheetPivotTable, editableSpreadsheetFormula, effectiveSpreadsheetCalculationSettings, errorBarSourceValues, fitSpreadsheetTrendline, formatSpreadsheetCellRanges, formatSpreadsheetChartAxisNumber, formulaHasExternalReference, formulaHasStructuredReference, isValidSpreadsheetDefinedName, normalizeSpreadsheetPrintArea, normalizeSpreadsheetPrintTitleColumns, normalizeSpreadsheetPrintTitleRows, normalizeWorkSpreadsheetBubbleScale, normalizeWorkSpreadsheetBubbleSizeRepresents, normalizeWorkSpreadsheetChartAxes, normalizeWorkSpreadsheetChartAxisGroup, normalizeWorkSpreadsheetChartColor, normalizeWorkSpreadsheetChartGapWidth, normalizeWorkSpreadsheetChartGrouping, normalizeWorkSpreadsheetChartLayout, normalizeWorkSpreadsheetChartLegendOverlay, normalizeWorkSpreadsheetChartLegendPosition, normalizeWorkSpreadsheetChartOverlap, normalizeWorkSpreadsheetChartSeriesStyle, normalizeWorkSpreadsheetChartSmoothLines, normalizeWorkSpreadsheetCombinationSeriesType, normalizeWorkSpreadsheetDataLabelPosition, normalizeWorkSpreadsheetDataLabels, normalizeWorkSpreadsheetDoughnutHoleSize, normalizeWorkSpreadsheetErrorBars, normalizeWorkSpreadsheetRadarStyle, normalizeWorkSpreadsheetScatterStyle, normalizeWorkSpreadsheetTrendline, normalizeWorkSpreadsheetTrendlineType, parseSpreadsheetCellRanges, parseSpreadsheetChartReference, parseSpreadsheetPrintTitles, qualifySpreadsheetRange, readXlsxDrawingAnchor, reconcileSpreadsheetChartPreviews, reconcileSpreadsheetPivots, refreshSpreadsheetPivotTables, resolveSpreadsheetChart, roundChartNumber, spreadsheetCellAddress, spreadsheetChartAxisGridlinesVisible, spreadsheetChartAxisLabelLayout, spreadsheetChartAxisScale, spreadsheetChartAxisValueRatio, spreadsheetChartBarGeometry, spreadsheetChartCategoryLabelVisible, spreadsheetChartCategoryVisualIndex, spreadsheetChartCount, spreadsheetChartSeriesFillStyle, spreadsheetChartSeriesLayout, spreadsheetChartSeriesLegendColor, spreadsheetChartSeriesLineStyle, spreadsheetChartSeriesStyleContext, spreadsheetErrorBarAmounts, spreadsheetFormulaForXlsx, spreadsheetFormulaFunctions, spreadsheetFormulaRangeConflict, spreadsheetFormulaRangeForCell, spreadsheetFormulaRangesForSelection, spreadsheetPivotAggregationLabel, spreadsheetPivotCount, spreadsheetPivotFields, spreadsheetPivotFilterItems, spreadsheetPivotFilterValueKey, spreadsheetPivotIntersects, spreadsheetPivotOutputContains, spreadsheetPivotValidation, spreadsheetSheetsWithChartPreviews, stripSpreadsheetSheetQualifier, volatileSpreadsheetFormulaFunctions, workSpreadsheetChartAxisDefaultLabelPosition, workSpreadsheetChartAxisIsCategoryAxis, workSpreadsheetChartAxisIsValueAxis, workSpreadsheetChartAxisLabelPositionLabel, workSpreadsheetChartAxisPositionLabel, workSpreadsheetChartAxisShowsMajorGridlinesByDefault, workSpreadsheetChartAxisTickMarkLabel, workSpreadsheetChartGroupingIsStacked, workSpreadsheetChartGroupingLabel, workSpreadsheetChartLegendPositionLabel, workSpreadsheetChartSupportsAxes, workSpreadsheetChartSupportsBarSpacing, workSpreadsheetChartSupportsErrorBars, workSpreadsheetChartSupportsGrouping, workSpreadsheetChartSupportsSeriesAnalysis, workSpreadsheetChartSupportsSmoothLines, workSpreadsheetChartSupportsTrendlines, workSpreadsheetChartTypeLabel, workSpreadsheetChartUsesNumericXAxis, workSpreadsheetCombinationSeriesTypeLabel, workSpreadsheetDataLabelPositionLabel, workSpreadsheetErrorBarTypeLabel, workSpreadsheetErrorBarValueTypeLabel, workSpreadsheetTrendlineTypeLabel, xlsxDrawingAnchorToBounds, xlsxTwoCellAnchorMarkers };
|