@ai-matrx/office 0.8.25 → 0.8.27

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/{chunk-TRA2BTPL.js → chunk-CAWDEHVL.js} +20 -6
  3. package/dist/chunk-CAWDEHVL.js.map +1 -0
  4. package/dist/{chunk-ZDZCCOUB.cjs → chunk-IJNET5TT.cjs} +20 -6
  5. package/dist/chunk-IJNET5TT.cjs.map +1 -0
  6. package/dist/{chunk-JMVPAJJA.cjs → chunk-LHTG72LS.cjs} +20 -6
  7. package/dist/chunk-LHTG72LS.cjs.map +1 -0
  8. package/dist/{chunk-WKBWRG7N.js → chunk-RREOARR4.js} +20 -6
  9. package/dist/chunk-RREOARR4.js.map +1 -0
  10. package/dist/collab-sheets-transform.cjs +215 -14
  11. package/dist/collab-sheets-transform.cjs.map +1 -1
  12. package/dist/collab-sheets-transform.d.cts +7 -2
  13. package/dist/collab-sheets-transform.d.ts +7 -2
  14. package/dist/collab-sheets-transform.js +215 -14
  15. package/dist/collab-sheets-transform.js.map +1 -1
  16. package/dist/docs-host.cjs.map +1 -1
  17. package/dist/docs-host.d.cts +8 -0
  18. package/dist/docs-host.d.ts +8 -0
  19. package/dist/docs-host.js.map +1 -1
  20. package/dist/docs-io.cjs +6 -6
  21. package/dist/docs-io.js +1 -1
  22. package/dist/docs.cjs +36 -2
  23. package/dist/docs.cjs.map +1 -1
  24. package/dist/docs.d.cts +25 -3
  25. package/dist/docs.d.ts +25 -3
  26. package/dist/docs.js +35 -1
  27. package/dist/docs.js.map +1 -1
  28. package/dist/sheets-comment-anchors.cjs +44 -3
  29. package/dist/sheets-comment-anchors.cjs.map +1 -1
  30. package/dist/sheets-comment-anchors.js +42 -1
  31. package/dist/sheets-comment-anchors.js.map +1 -1
  32. package/dist/sheets-xlsx.cjs +6 -6
  33. package/dist/sheets-xlsx.js +1 -1
  34. package/dist/sheets.cjs +3 -3
  35. package/dist/sheets.d.cts +9 -1
  36. package/dist/sheets.d.ts +9 -1
  37. package/dist/sheets.js +1 -1
  38. package/dist/univer-collab.cjs +315 -37
  39. package/dist/univer-collab.cjs.map +1 -1
  40. package/dist/univer-collab.d.cts +9 -5
  41. package/dist/univer-collab.d.ts +9 -5
  42. package/dist/univer-collab.js +300 -18
  43. package/dist/univer-collab.js.map +1 -1
  44. package/package.json +2 -2
  45. package/dist/chunk-JMVPAJJA.cjs.map +0 -1
  46. package/dist/chunk-TRA2BTPL.js.map +0 -1
  47. package/dist/chunk-WKBWRG7N.js.map +0 -1
  48. package/dist/chunk-ZDZCCOUB.cjs.map +0 -1
package/dist/docs.d.ts CHANGED
@@ -25,6 +25,14 @@ interface DocsHostPorts {
25
25
  method: "POST";
26
26
  body: FormData;
27
27
  }): Promise<Response>;
28
+ /**
29
+ * The record's CURRENT content, including what people are typing in a live co-editing room and have not saved
30
+ * (the app folds the room; the package owns no server). Optional: a host without co-editing leaves it out and
31
+ * a copy takes the newest saved snapshot. It may throw; the copy then fails with its message, never silently.
32
+ */
33
+ readCurrentSnapshot?(documentId: string): Promise<{
34
+ snapshot: unknown | null;
35
+ }>;
28
36
  }
29
37
  declare function configureDocsHost(ports: DocsHostPorts): void;
30
38
  declare function getDocsHost(): DocsHostPorts;
@@ -145,7 +153,7 @@ type SaveDocumentSnapshotArgs = {
145
153
  };
146
154
  declare function saveDocumentSnapshot(args: SaveDocumentSnapshotArgs): Promise<ServiceResult<DocumentSnapshot>>;
147
155
  /**
148
- * An independent copy of a document: its own row, with the latest snapshot copied over, so editing the copy never
156
+ * An independent copy of a document: its own row, with the CURRENT content copied over (the live room when people are co-editing), so editing the copy never
149
157
  * touches the original. The copy lives in the original's organization and project. Used by a board-template use.
150
158
  */
151
159
  declare function copyDocument(documentId: string, name?: string): Promise<ServiceResult<DocumentRow>>;
@@ -808,8 +816,15 @@ declare const COMMENT_ANCHOR_LABEL_MAX = 200;
808
816
  /** A fresh anchor id: 16 random base-36 characters (custom-range ids are plain strings). */
809
817
  declare function newCommentAnchorId(): string;
810
818
  declare function commentAnchorPartKey(anchorId: string): string;
811
- /** The anchor id a `part_anchor` names, or null when it is not one of ours. */
819
+ /**
820
+ * The anchor id a thread's `anchor` names, or null when it is not one of ours. A new thread is a `part_anchor` keyed
821
+ * `anchor:<id>`. At each save the door projects the live anchor onto the thread (COLLAB-DESIGN §8): a sheet thread's key
822
+ * becomes `cell:<sheetId>!R<r>C<c>` and a docs thread becomes a `text_anchor` holding the quoted text; both keep the id in
823
+ * `anchor_id`, so the thread stays joined to its anchor after the rewrite.
824
+ */
812
825
  declare function anchorIdOfPartAnchor(anchor: unknown): string | null;
826
+ /** The quoted text a thread carries: a new thread's label, or the frozen `exact` of a projected docs thread. */
827
+ declare function quoteOfCommentAnchor(anchor: unknown): string;
813
828
  /** The `part_anchor` a new thread on this anchor carries. */
814
829
  declare function commentPartAnchor(anchorId: string, quote: string): {
815
830
  __kind: "part_anchor";
@@ -835,5 +850,12 @@ declare function addCommentAnchorActions(body: unknown, start: number, end: numb
835
850
  * its text. Null when the anchor is not there.
836
851
  */
837
852
  declare function removeCommentAnchorActions(documentDataModel: unknown, anchorId: string): unknown[] | null;
853
+ /**
854
+ * A Docs op that only ADDS comment anchors: `["body", { et: "text-x", e: [...] }]` whose every component is a plain
855
+ * retain, carrying (when it carries a body) nothing but COMMENT custom ranges. No insert, no delete, no text, no style,
856
+ * no other range type. A seat that may comment but not edit sends exactly these; the door `content.collab_append`
857
+ * checks the same rule. Taking a range out is NOT included: it reads the same as removing a link, so it is an edit.
858
+ */
859
+ declare function isDocsAnchorOnlyOp(op: unknown): boolean;
838
860
 
839
- export { type BodyEdit, type BodyText, CARET_HEARTBEAT_MS, CARET_MAX_RANGES, CARET_STALE_MS, COMMENT_ANCHOR_LABEL_MAX, COMMENT_ANCHOR_PART_PREFIX, COMMENT_ANCHOR_RANGE_TYPE, type CaretRange, type CommentAnchorSpan, type CreateDocumentArgs, DOCUMENT_BODY_MAX_LENGTH, DOCUMENT_DESCRIPTION_MAX_LENGTH, DOCUMENT_NAME_MAX_LENGTH, DOCUMENT_SAVE_DELAY_MS, type DocsHostPorts, type DocsSupabase, type DocumentAwareness, type DocumentBodyPort, type DocumentBodyWriteHandler, type DocumentCollabBase, type DocumentCollabFactory, type DocumentCollabHandle, DocumentModel, type DocumentModelDeps, type DocumentOtFactory, type DocumentOtHandle, type DocumentSnapshotData, type DocumentViewPort, EMOJI_GROUPS, type Glyph, MIN_FIT_ZOOM, type ParkedDocumentEditor, type PublishedCaret, type RemoteCaret, RemoteCaretBook, SPECIAL_GROUPS, type SaveDocumentSnapshotArgs, addCommentAnchorActions, anchorIdOfPartAnchor, bodyTextOf, commentAnchorPartKey, commentAnchorsOf, commentPartAnchor, configureDocsHost, copyDocument, createDocument, deleteDocument, discardFailedDocument, documentBodyWriteHandler, documentSourceLabel, fitZoomRatio, getDocsHost, getDocument, getLatestDocumentSnapshot, listAccessibleDocuments, listDocumentSnapshots, listTrashedDocuments, moveDocument, movePeerRangesThroughBodyEdit, moveRangesThroughBodyEdit, newCommentAnchorId, planBodyEdit, publishedCaretFromSelection, removeCommentAnchorActions, renameDocument, restoreDocument, sanitizeUniverDocSnapshot, saveDocumentSnapshot, searchSymbols, updateDocumentDescription, validateDocumentBody, validateDocumentDescription, validateDocumentName, writeBodyText };
861
+ export { type BodyEdit, type BodyText, CARET_HEARTBEAT_MS, CARET_MAX_RANGES, CARET_STALE_MS, COMMENT_ANCHOR_LABEL_MAX, COMMENT_ANCHOR_PART_PREFIX, COMMENT_ANCHOR_RANGE_TYPE, type CaretRange, type CommentAnchorSpan, type CreateDocumentArgs, DOCUMENT_BODY_MAX_LENGTH, DOCUMENT_DESCRIPTION_MAX_LENGTH, DOCUMENT_NAME_MAX_LENGTH, DOCUMENT_SAVE_DELAY_MS, type DocsHostPorts, type DocsSupabase, type DocumentAwareness, type DocumentBodyPort, type DocumentBodyWriteHandler, type DocumentCollabBase, type DocumentCollabFactory, type DocumentCollabHandle, DocumentModel, type DocumentModelDeps, type DocumentOtFactory, type DocumentOtHandle, type DocumentSnapshotData, type DocumentViewPort, EMOJI_GROUPS, type Glyph, MIN_FIT_ZOOM, type ParkedDocumentEditor, type PublishedCaret, type RemoteCaret, RemoteCaretBook, SPECIAL_GROUPS, type SaveDocumentSnapshotArgs, addCommentAnchorActions, anchorIdOfPartAnchor, bodyTextOf, commentAnchorPartKey, commentAnchorsOf, commentPartAnchor, configureDocsHost, copyDocument, createDocument, deleteDocument, discardFailedDocument, documentBodyWriteHandler, documentSourceLabel, fitZoomRatio, getDocsHost, getDocument, getLatestDocumentSnapshot, isDocsAnchorOnlyOp, listAccessibleDocuments, listDocumentSnapshots, listTrashedDocuments, moveDocument, movePeerRangesThroughBodyEdit, moveRangesThroughBodyEdit, newCommentAnchorId, planBodyEdit, publishedCaretFromSelection, quoteOfCommentAnchor, removeCommentAnchorActions, renameDocument, restoreDocument, sanitizeUniverDocSnapshot, saveDocumentSnapshot, searchSymbols, updateDocumentDescription, validateDocumentBody, validateDocumentDescription, validateDocumentName, writeBodyText };
package/dist/docs.js CHANGED
@@ -16,7 +16,7 @@ import {
16
16
  sanitizeUniverDocSnapshot,
17
17
  saveDocumentSnapshot,
18
18
  updateDocumentDescription
19
- } from "./chunk-TRA2BTPL.js";
19
+ } from "./chunk-CAWDEHVL.js";
20
20
  import {
21
21
  looksLikeMarkdown
22
22
  } from "./chunk-DY5TGHBI.js";
@@ -979,11 +979,17 @@ function commentAnchorPartKey(anchorId) {
979
979
  function anchorIdOfPartAnchor(anchor) {
980
980
  if (!anchor || typeof anchor !== "object") return null;
981
981
  const a = anchor;
982
+ if ((a.__kind === "part_anchor" || a.__kind === "text_anchor") && typeof a.anchor_id === "string" && a.anchor_id.length > 0) return a.anchor_id;
982
983
  if (a.__kind !== "part_anchor" || typeof a.part_key !== "string") return null;
983
984
  if (!a.part_key.startsWith(COMMENT_ANCHOR_PART_PREFIX)) return null;
984
985
  const id = a.part_key.slice(COMMENT_ANCHOR_PART_PREFIX.length);
985
986
  return id.length > 0 ? id : null;
986
987
  }
988
+ function quoteOfCommentAnchor(anchor) {
989
+ if (!anchor || typeof anchor !== "object") return "";
990
+ const a = anchor;
991
+ return typeof a.label === "string" ? a.label : typeof a.exact === "string" ? a.exact : "";
992
+ }
987
993
  function commentPartAnchor(anchorId, quote) {
988
994
  const label = quote.replace(/\s+/g, " ").trim().slice(0, COMMENT_ANCHOR_LABEL_MAX);
989
995
  return { __kind: "part_anchor", part_key: commentAnchorPartKey(anchorId), ...label ? { label } : {} };
@@ -1022,6 +1028,32 @@ function removeCommentAnchorActions(documentDataModel, anchorId) {
1022
1028
  if (!textX) return null;
1023
1029
  return JSONX.getInstance().editOp(textX.serialize(), ["body"]);
1024
1030
  }
1031
+ var RETAIN_KEYS = /* @__PURE__ */ new Set(["t", "len", "body", "coverType"]);
1032
+ var RANGE_KEYS = /* @__PURE__ */ new Set(["rangeId", "rangeType", "startIndex", "endIndex", "properties"]);
1033
+ var isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
1034
+ var keysOf = (o) => Object.keys(o).filter((k) => o[k] !== void 0);
1035
+ function isDocsAnchorOnlyOp(op) {
1036
+ if (!Array.isArray(op) || op.length !== 2 || op[0] !== "body") return false;
1037
+ const x = op[1];
1038
+ if (!isObj(x) || x.et !== "text-x" || !Array.isArray(x.e) || x.e.length === 0) return false;
1039
+ if (keysOf(x).some((k) => k !== "et" && k !== "e")) return false;
1040
+ for (const c of x.e) {
1041
+ if (!isObj(c) || c.t !== "r" || typeof c.len !== "number") return false;
1042
+ if (keysOf(c).some((k) => !RETAIN_KEYS.has(k))) return false;
1043
+ if ("coverType" in c && typeof c.coverType !== "number") return false;
1044
+ if ("body" in c) {
1045
+ const b = c.body;
1046
+ if (!isObj(b) || keysOf(b).some((k) => k !== "dataStream" && k !== "customRanges")) return false;
1047
+ if (b.dataStream !== void 0 && b.dataStream !== "") return false;
1048
+ if (!Array.isArray(b.customRanges) || b.customRanges.length === 0) return false;
1049
+ for (const r of b.customRanges) {
1050
+ if (!isObj(r) || r.rangeType !== COMMENT_ANCHOR_RANGE_TYPE) return false;
1051
+ if (keysOf(r).some((k) => !RANGE_KEYS.has(k))) return false;
1052
+ }
1053
+ }
1054
+ }
1055
+ return true;
1056
+ }
1025
1057
  export {
1026
1058
  CARET_HEARTBEAT_MS,
1027
1059
  CARET_MAX_RANGES,
@@ -1055,6 +1087,7 @@ export {
1055
1087
  getDocsHost,
1056
1088
  getDocument,
1057
1089
  getLatestDocumentSnapshot,
1090
+ isDocsAnchorOnlyOp,
1058
1091
  listAccessibleDocuments,
1059
1092
  listDocumentSnapshots,
1060
1093
  listTrashedDocuments,
@@ -1064,6 +1097,7 @@ export {
1064
1097
  newCommentAnchorId,
1065
1098
  planBodyEdit,
1066
1099
  publishedCaretFromSelection,
1100
+ quoteOfCommentAnchor,
1067
1101
  removeCommentAnchorActions,
1068
1102
  renameDocument,
1069
1103
  restoreDocument,