@fileverse-dev/dsheet 3.0.2-patch.7 → 3.0.2-patch.9

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 (40) hide show
  1. package/dist/{constants-Q8nzbvQO.js → constants-Cdz6oSCq.js} +3 -5
  2. package/dist/constants.js +1 -1
  3. package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
  4. package/dist/editor/constants/shared-constants.d.ts +0 -2
  5. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  6. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +2 -1
  7. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  8. package/dist/editor/utils/apply-comment-markers.d.ts +22 -0
  9. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  10. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  11. package/dist/editor/utils/update-ydoc.d.ts +13 -3
  12. package/dist/executeStringFunction-DVN2p-9G.js +32625 -0
  13. package/dist/formula.js +1 -1
  14. package/dist/{index-BqJw4oqU.js → index-T7U1EYEU.js} +21436 -24333
  15. package/dist/index.es.js +39 -39
  16. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  17. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  18. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  19. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  20. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  21. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +1 -0
  22. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  23. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  24. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  25. package/dist/sheet-engine/core/settings.d.ts +1 -1
  26. package/dist/sheet-engine/core/types.d.ts +3 -0
  27. package/dist/sheet-engine/core/utils/active-draft-context.d.ts +4 -0
  28. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
  29. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
  30. package/dist/sheet-engine/core/utils/merge-hydrate.d.ts +15 -0
  31. package/dist/sheet-engine/core/utils/mirror-cell-format-ranges.d.ts +17 -0
  32. package/dist/sheet-engine/core/utils/range-format.d.ts +76 -0
  33. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +46 -0
  34. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  35. package/dist/sheet-engine/react/components/Workbook/index.d.ts +5 -1
  36. package/dist/use-xlsx-import-impl-B9Uq_cFK.js +1572 -0
  37. package/dist/{xlsx-export-impl-BVnggmUo.js → xlsx-export-impl-0bnKq9JC.js} +1210 -1198
  38. package/package.json +1 -1
  39. package/dist/executeStringFunction-C5hEkx9z.js +0 -27694
  40. package/dist/use-xlsx-import-impl-OjMoKLbj.js +0 -1537
@@ -1,13 +1,11 @@
1
- import { E as n, S as a } from "./crypto-constants-CqpCRs86.js";
2
- const E = n, d = a, f = [
1
+ import { E as a, S as n } from "./crypto-constants-CqpCRs86.js";
2
+ const E = a, d = n, f = [
3
3
  {
4
4
  id: "0",
5
5
  name: "Sheet1",
6
6
  celldata: [],
7
7
  config: {},
8
- order: 0,
9
- row: 500,
10
- column: 26
8
+ order: 0
11
9
  }
12
10
  ], m = [
13
11
  "undo",
package/dist/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as R, c as _, E as C, S as a, p as s } from "./constants-Q8nzbvQO.js";
1
+ import { a as R, c as _, E as C, S as a, p as s } from "./constants-Cdz6oSCq.js";
2
2
  export {
3
3
  R as COLLAB_PRESENCE_COLORS,
4
4
  _ as ENS_PRESENCE_COLOR,
@@ -19,5 +19,5 @@ export declare const createAfterOrderChangesHandler: ({ sheetEditorRef, ydocRef,
19
19
  export declare const createAfterColorChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
20
20
  export declare const createAfterHideChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
21
21
  export declare const createAfterColRowChangesHandler: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext) => () => void;
22
- export declare const updateAllCell: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext, subSheetId: string) => void;
22
+ export declare const updateAllCell: ({ sheetEditorRef, ydocRef, dsheetId, handleOnChangePortalUpdate, }: SyncContext, subSheetId: string, caller?: string) => void;
23
23
  export {};
@@ -8,8 +8,6 @@ export declare const DEFAULT_SHEET_DATA: {
8
8
  celldata: never[];
9
9
  config: {};
10
10
  order: number;
11
- row: number;
12
- column: number;
13
11
  }[];
14
12
  export declare const TOOL_BAR_ITEMS: string[];
15
13
  export declare const CELL_CONTEXT_MENU_ITEMS: string[];
@@ -0,0 +1,23 @@
1
+ import { MutableRefObject, RefObject } from 'react';
2
+ import { WorkbookInstance, Sheet } from '../../sheet-engine/react';
3
+
4
+ import type * as Y from 'yjs';
5
+ type UseCelldataCompactionArgs = {
6
+ dsheetId: string;
7
+ ydocRef: RefObject<Y.Doc | null>;
8
+ sheetEditorRef: RefObject<WorkbookInstance | null>;
9
+ currentDataRef: MutableRefObject<Sheet[]>;
10
+ handleOnChangePortalUpdate: () => void;
11
+ syncStatus: 'initializing' | 'syncing' | 'synced' | 'error';
12
+ isDataLoaded: boolean;
13
+ isReadOnly: boolean;
14
+ remoteUpdateRef: MutableRefObject<boolean>;
15
+ collabSyncing: boolean;
16
+ };
17
+ /**
18
+ * One-shot background compaction: remove committed celldata entries that copy/paste
19
+ * would never write (`shouldPersistCelldataCell` === false). Runs once per dsheetId
20
+ * after the editor is synced and idle so it does not compete with load or edits.
21
+ */
22
+ export declare function useCelldataCompaction({ dsheetId, ydocRef, sheetEditorRef, currentDataRef, handleOnChangePortalUpdate, syncStatus, isDataLoaded, isReadOnly, remoteUpdateRef, collabSyncing, }: UseCelldataCompactionArgs): void;
23
+ export {};
@@ -11,6 +11,7 @@ export type XlsxImportRuntimeDeps = {
11
11
  updateDocumentTitle?: (title: string) => void;
12
12
  filterToastShown: boolean;
13
13
  setFilterToastShown: React.Dispatch<React.SetStateAction<boolean>>;
14
+ handleContentPortal?: () => void;
14
15
  };
15
16
  export type XlsxImportOptions = {
16
17
  headless?: boolean;
@@ -19,4 +20,4 @@ export type XlsxImportOptions = {
19
20
  generateSheetId?: () => string;
20
21
  };
21
22
  /** Full XLSX import pipeline; loaded only when user imports a file. */
22
- export declare function runXlsxFileUpload({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, filterToastShown, setFilterToastShown, }: XlsxImportRuntimeDeps, event: React.ChangeEvent<HTMLInputElement> | undefined, fileArg: File, importType?: 'new-dsheet' | 'merge-current-dsheet' | 'new-current-dsheet', options?: XlsxImportOptions): Promise<void>;
23
+ export declare function runXlsxFileUpload({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, filterToastShown, setFilterToastShown, handleContentPortal, }: XlsxImportRuntimeDeps, event: React.ChangeEvent<HTMLInputElement> | undefined, fileArg: File, importType?: 'new-dsheet' | 'merge-current-dsheet' | 'new-current-dsheet', options?: XlsxImportOptions): Promise<void>;
@@ -7,13 +7,14 @@ type ImportType = 'new-dsheet' | 'merge-current-dsheet' | 'new-current-dsheet';
7
7
  * XLSX import: keeps ~100k+ LOC (SSF, hyperlink helpers, exceljs/luckyexcel orchestration)
8
8
  * in a separate chunk until the user actually imports a file.
9
9
  */
10
- export declare const useXLSXImport: ({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, }: {
10
+ export declare const useXLSXImport: ({ sheetEditorRef, ydocRef, setForceSheetRender, dsheetId, currentDataRef, updateDocumentTitle, handleContentPortal, }: {
11
11
  sheetEditorRef: RefObject<WorkbookInstance | null>;
12
12
  ydocRef: RefObject<Y.Doc | null>;
13
13
  setForceSheetRender: Dispatch<SetStateAction<number>>;
14
14
  dsheetId: string;
15
15
  currentDataRef: MutableRefObject<object | null>;
16
16
  updateDocumentTitle?: (title: string) => void;
17
+ handleContentPortal?: () => void;
17
18
  }) => {
18
19
  handleXLSXUpload: (event: ChangeEvent<HTMLInputElement> | undefined, fileArg: File, importType?: ImportType) => Promise<void>;
19
20
  };
@@ -0,0 +1,22 @@
1
+ type CommentData = object | null | undefined;
2
+ /**
3
+ * Stamps the in-cell comment marker (`cell.ps`) onto sheet data, derived from
4
+ * the consumer-provided `commentData`.
5
+ *
6
+ * `ps` is a per-client, permission-gated *view overlay* — it is NOT persisted in
7
+ * ydoc. Every path that rebuilds sheet data from ydoc (portal load, collab sync
8
+ * remount, remote cell edits) produces cells WITHOUT `ps`, so this must run on
9
+ * each such snapshot or the red-triangle indicator vanishes. Because it is
10
+ * gated on the local `allowComments` permission, it must never be written back
11
+ * to shared ydoc state — doing so would let one viewer wipe markers for all.
12
+ *
13
+ * Handles both shapes:
14
+ * - Dense `sheet.data` (the live active sheet in `luckysheetfile`).
15
+ * - Sparse `sheet.celldata` (plain snapshots from `ySheetArrayToPlain`, and
16
+ * inactive sheets). `initSheetData()` converts celldata → data on activation,
17
+ * so `ps` set on celldata carries through.
18
+ *
19
+ * Mutates in place and returns the same array.
20
+ */
21
+ export declare const applyCommentMarkers: <T>(sheets: T | null | undefined, commentData: CommentData, allowComments: boolean | undefined) => T | null | undefined;
22
+ export {};
@@ -0,0 +1,28 @@
1
+ import { CellMatrix, CellWithRowAndCol, Sheet } from '../../sheet-engine/core/types';
2
+ import { SheetChangePath } from './update-ydoc';
3
+ import * as Y from 'yjs';
4
+ export declare const CELLDATA_COMPACT_STORAGE_KEY_PREFIX = "dsheet-celldata-compact-v1:";
5
+ export type CelldataCompactionResult = {
6
+ removedFromYdoc: number;
7
+ clearedInMemory: number;
8
+ changes: SheetChangePath[];
9
+ };
10
+ export declare function celldataCompactStorageKey(dsheetId: string): string;
11
+ export declare function hasCelldataCompactionCompleted(dsheetId: string): boolean;
12
+ export declare function markCelldataCompactionCompleted(dsheetId: string): void;
13
+ /** Collect Yjs celldata keys that should not be persisted (format-only / empty ghosts). */
14
+ export declare function collectStaleCelldataKeys(celldataMap: Y.Map<unknown> | Record<string, unknown> | null | undefined): string[];
15
+ export declare function buildCelldataDeleteChanges(sheetId: string, keys: string[]): SheetChangePath[];
16
+ /** Null out dense-grid cells that should not be persisted. */
17
+ export declare function compactSheetDataMatrix(data: CellMatrix | null | undefined): number;
18
+ /** Drop sparse celldata entries that should not be persisted. */
19
+ export declare function compactSheetCelldataArray(celldata: CellWithRowAndCol[] | null | undefined): {
20
+ next: CellWithRowAndCol[];
21
+ removed: number;
22
+ };
23
+ export declare function compactInMemorySheets(sheets: Sheet[] | null | undefined): number;
24
+ /**
25
+ * Scan Y.Doc for committed celldata ghosts. Does not mutate — caller applies
26
+ * `changes` via `updateYdocSheetData`.
27
+ */
28
+ export declare function planYdocCelldataCompaction(ydoc: Y.Doc, dsheetId: string): CelldataCompactionResult;
@@ -0,0 +1,20 @@
1
+ import { WorkbookInstance } from '../../sheet-engine/react';
2
+ import { SheetChangePath } from './update-ydoc';
3
+
4
+ import * as Y from 'yjs';
5
+ /** Diff top-level config sub-keys and emit granular Yjs updates. */
6
+ export declare function buildConfigSubKeyChanges({ sheetId, oldConfig, newConfig, }: {
7
+ sheetId: string;
8
+ oldConfig: Record<string, any>;
9
+ newConfig: Record<string, any>;
10
+ }): SheetChangePath[];
11
+ /**
12
+ * Sync active sheet config sub-keys to Yjs (borderInfo, merge, rowlen, …).
13
+ * Replaces whole-config writes so only changed sub-keys are broadcast.
14
+ */
15
+ export declare const configYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal, }: {
16
+ sheetEditorRef: React.RefObject<WorkbookInstance | null>;
17
+ ydocRef: React.RefObject<Y.Doc | null>;
18
+ dsheetId: string;
19
+ handleContentPortal?: any;
20
+ }) => void;
@@ -1,11 +1,21 @@
1
1
  import { Sheet } from '../../sheet-engine/react';
2
- import * as Y from 'yjs';
2
+ import { CellFormatRange } from '../../sheet-engine/core/utils/range-format';
3
+ import * as Y from "yjs";
3
4
  export type SheetChangePath = {
4
5
  sheetId: string;
5
6
  path: string[];
6
7
  key?: string;
7
8
  value: any;
8
- type?: 'update' | 'delete';
9
+ type?: "update" | "delete";
10
+ /**
11
+ * Compaction deletes planned earlier may race with edits across idle chunks.
12
+ * When set, skip the delete if the live celldata entry is now persistable.
13
+ * Do not set on intentional clears — those must always remove the key.
14
+ */
15
+ skipIfPersistable?: boolean;
9
16
  };
10
- export declare const updateYdocSheetData: (ydoc: Y.Doc | null, dsheetId: string, changes: SheetChangePath[], handleContentPortal: any) => void;
17
+ export declare const updateYdocSheetData: (ydoc: Y.Doc | null, dsheetId: string, changes: SheetChangePath[], handleContentPortal: any, onCellFormatRangesCommitted?: (commits: Array<{
18
+ sheetId: string;
19
+ ranges: CellFormatRange[];
20
+ }>) => void) => void;
11
21
  export declare function ySheetArrayToPlain(sheetArray: Y.Array<Y.Map>): Sheet[];