@fileverse-dev/dsheet 4.0.4 → 4.0.5

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 (37) hide show
  1. package/dist/editor/components/sidebar/use-right-panels.d.ts +1 -1
  2. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  3. package/dist/editor/hooks/use-celldata-compaction.d.ts +2 -3
  4. package/dist/editor/utils/compact-committed-celldata.d.ts +11 -10
  5. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  6. package/dist/editor/utils/import-compaction.d.ts +25 -0
  7. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  8. package/dist/editor/utils/xlsx-import-pipeline.d.ts +28 -0
  9. package/dist/{executeStringFunction-CsLQk-dm.js → executeStringFunction-B6fhDKyN.js} +6985 -6477
  10. package/dist/formula.js +1 -1
  11. package/dist/{index-DvwJ-8x8.js → index-BqGOKo9u.js} +14197 -13462
  12. package/dist/index.es.js +21 -21
  13. package/dist/sheet-engine/core/api/common.d.ts +1 -0
  14. package/dist/sheet-engine/core/context.d.ts +3 -1
  15. package/dist/sheet-engine/core/index.d.ts +2 -2
  16. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +11 -0
  17. package/dist/sheet-engine/core/modules/formula.d.ts +27 -0
  18. package/dist/sheet-engine/core/modules/index.d.ts +3 -2
  19. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  20. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +2 -0
  21. package/dist/sheet-engine/core/settings.d.ts +2 -0
  22. package/dist/sheet-engine/core/types.d.ts +21 -0
  23. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  24. package/dist/sheet-engine/react/components/Workbook/api.d.ts +1 -0
  25. package/dist/sheet-engine/react/components/Workbook/index.d.ts +1 -0
  26. package/dist/style.css +1 -1
  27. package/dist/use-xlsx-import-impl-Bddlxx23.js +1898 -0
  28. package/dist/worker/dsheet-worker-client.d.ts +14 -0
  29. package/dist/worker/dsheet-worker.d.ts +14 -0
  30. package/dist/xlsx-defined-names-DsWdNZw-.js +117 -0
  31. package/dist/xlsx-export-impl-DJiXCevi.js +831 -0
  32. package/dist/xlsx-hyperlink-inline-CTg4_gg1.js +2512 -0
  33. package/package.json +2 -1
  34. package/dist/use-xlsx-import-impl-I69dMglI.js +0 -1549
  35. package/dist/xlsx-export-impl-Bg7Suzh-.js +0 -3138
  36. package/dist/xlsx-hyperlink-inline-DzewAypN.js +0 -71
  37. package/dist/xlsx-image-utils-Cvg0qxRA.js +0 -126
@@ -1,4 +1,4 @@
1
- export type BuiltInPanelType = 'templates' | 'comments' | 'functions' | 'data-verification' | 'conditional-format';
1
+ export type BuiltInPanelType = 'templates' | 'comments' | 'functions' | 'data-verification' | 'conditional-format' | 'named-ranges';
2
2
  export type PanelId = BuiltInPanelType | string;
3
3
  interface UseRightPanelsReturn {
4
4
  activePanel: PanelId | null;
@@ -0,0 +1,2 @@
1
+ declare const NamedRanges: () => import("react/jsx-runtime").JSX.Element;
2
+ export { NamedRanges };
@@ -15,9 +15,8 @@ type UseCelldataCompactionArgs = {
15
15
  collabSyncing: boolean;
16
16
  };
17
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.
18
+ * One-shot background compaction (celldata + borderInfo). Completion is stored
19
+ * on the anchor sheet's config in Yjs so it syncs across devices.
21
20
  */
22
21
  export declare function useCelldataCompaction({ dsheetId, ydocRef, sheetEditorRef, currentDataRef, handleOnChangePortalUpdate, syncStatus, isDataLoaded, isReadOnly, remoteUpdateRef, collabSyncing, }: UseCelldataCompactionArgs): void;
23
22
  export {};
@@ -1,15 +1,19 @@
1
1
  import { CellMatrix, CellWithRowAndCol, Sheet } from '../../sheet-engine/core/types';
2
2
  import { SheetChangePath } from './update-ydoc';
3
3
  import * as Y from 'yjs';
4
- export declare const CELLDATA_COMPACT_STORAGE_KEY_PREFIX = "dsheet-celldata-compact-v1:";
5
- export type CelldataCompactionResult = {
4
+ /** Celldata + borderInfo compaction; bump when rules change. */
5
+ export declare const SHEET_COMPACTION_REV = 2;
6
+ export declare const SHEET_COMPACTION_CONFIG_KEY = "sheetCompactionRev";
7
+ export type SheetCompactionResult = {
6
8
  removedFromYdoc: number;
7
9
  clearedInMemory: number;
8
10
  changes: SheetChangePath[];
9
11
  };
10
- export declare function celldataCompactStorageKey(dsheetId: string): string;
11
- export declare function hasCelldataCompactionCompleted(dsheetId: string): boolean;
12
- export declare function markCelldataCompactionCompleted(dsheetId: string): void;
12
+ export declare function readSheetCompactionRev(config: unknown): number;
13
+ export declare function getAnchorSheet(sheets: Sheet[] | null | undefined): Sheet | null;
14
+ export declare function hasSheetCompactionCompleted(ydoc: Y.Doc, dsheetId: string): boolean;
15
+ export declare function buildCompactionRevChange(ydoc: Y.Doc, dsheetId: string): SheetChangePath | null;
16
+ export declare function markCompactionRevInMemory(sheets: Sheet[] | null | undefined): void;
13
17
  /** Collect Yjs celldata keys that should not be persisted (format-only / empty ghosts). */
14
18
  export declare function collectStaleCelldataKeys(celldataMap: Y.Map<unknown> | Record<string, unknown> | null | undefined): string[];
15
19
  export declare function buildCelldataDeleteChanges(sheetId: string, keys: string[]): SheetChangePath[];
@@ -21,8 +25,5 @@ export declare function compactSheetCelldataArray(celldata: CellWithRowAndCol[]
21
25
  removed: number;
22
26
  };
23
27
  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;
28
+ /** Scan Y.Doc for committed ghosts. Does not mutate — caller applies `changes`. */
29
+ export declare function planYdocCompaction(ydoc: Y.Doc, dsheetId: string): SheetCompactionResult;
@@ -0,0 +1,31 @@
1
+ import { WorkbookInstance } from '../../sheet-engine/react';
2
+ import { DefinedName } from '../../sheet-engine/core/types';
3
+ import { RefObject } from 'react';
4
+
5
+ import * as Y from 'yjs';
6
+ /** Sibling share key on the same Y.Doc as the sheet array. */
7
+ export declare function getDefinedNamesMapKey(dsheetId: string): string;
8
+ export declare function getDefinedNamesYMap(ydoc: Y.Doc, dsheetId: string): Y.Map<DefinedName>;
9
+ /** Read workbook-level named ranges from Yjs (stable name order). */
10
+ export declare function readDefinedNamesFromYdoc(ydoc: Y.Doc, dsheetId: string): DefinedName[];
11
+ /**
12
+ * Prefer the sheet `Y.Array` share key when a doc has sibling maps
13
+ * (e.g. `${dsheetId}:definedNames`).
14
+ */
15
+ export declare function resolveSheetArrayShareKey(doc: Y.Doc, preferredKey?: string): string | null;
16
+ /**
17
+ * Diff Context definedNames against the Y.Map and apply set/delete by id.
18
+ */
19
+ export declare function syncDefinedNamesToYdoc({ ydoc, dsheetId, definedNames, handleContentPortal, }: {
20
+ ydoc: Y.Doc;
21
+ dsheetId: string;
22
+ definedNames: DefinedName[];
23
+ handleContentPortal?: () => void;
24
+ }): void;
25
+ /** Push current workbook definedNames into Yjs (editor hook target). */
26
+ export declare const definedNamesYdocUpdate: ({ sheetEditorRef, ydocRef, dsheetId, handleContentPortal, }: {
27
+ sheetEditorRef: RefObject<WorkbookInstance | null>;
28
+ ydocRef: RefObject<Y.Doc | null>;
29
+ dsheetId: string;
30
+ handleContentPortal?: () => void;
31
+ }) => void;
@@ -0,0 +1,25 @@
1
+ import { Sheet } from '../../sheet-engine/react';
2
+
3
+ /**
4
+ * XLSX imports (Google Sheets exports especially) materialize every
5
+ * styled-but-empty cell. Move those into config.cellFormatRanges — the same
6
+ * sparse representation the editor uses — so they never inflate celldata/Yjs.
7
+ * Cells with content, merges, hyperlinks, notes or masks are kept verbatim.
8
+ */
9
+ export declare function compactImportedSheetFormatting(sheet: Sheet): void;
10
+ /**
11
+ * Imported validations repeat the full option list + per-option color string
12
+ * on every covered cell (whole-column dropdowns → thousands of copies). Store
13
+ * each unique entry once in dataVerificationDefs and keep numeric refs in the
14
+ * per-cell map; expandSheetDataVerification restores objects for the engine.
15
+ */
16
+ export declare function internImportedDataVerification(sheet: Sheet): void;
17
+ /**
18
+ * Resolve interned dataVerification refs back to shared entry objects before
19
+ * the sheet reaches the engine or the XLSX exporter. No-op (and no mutation)
20
+ * when the map already holds objects, so live workbook sheets pass through.
21
+ */
22
+ export declare function expandSheetDataVerification<T extends {
23
+ dataVerification?: unknown;
24
+ dataVerificationDefs?: unknown;
25
+ }>(sheet: T): T;
@@ -0,0 +1,41 @@
1
+ import { DefinedName } from '../../sheet-engine/core/types';
2
+
3
+ export type ExcelDefinedNameEntry = {
4
+ name: string;
5
+ ranges: string[];
6
+ localSheetId?: number;
7
+ };
8
+ export declare function isExcelSystemDefinedName(name: string): boolean;
9
+ /** Build Excel loc string: `Sheet1!$A$1:$C$2` (or single cell). */
10
+ export declare function encodeDefinedNameExcelRef(sheetName: string, range: DefinedName['range']): string;
11
+ /**
12
+ * Parse `Sheet1!$A$1:$B$2` / `'My Sheet'!$A$1` into sheet name + 0-based range.
13
+ */
14
+ export declare function parseExcelDefinedNameRef(ref: string): {
15
+ sheetName: string;
16
+ range: {
17
+ row: [number, number];
18
+ column: [number, number];
19
+ };
20
+ } | null;
21
+ /**
22
+ * Convert Excel defined-name entries into our DefinedName list.
23
+ * `sheets` must already have stable ids and names (Excel order).
24
+ */
25
+ export declare function excelEntriesToDefinedNames(entries: ExcelDefinedNameEntry[], sheets: Array<{
26
+ id?: string;
27
+ name?: string;
28
+ }>): DefinedName[];
29
+ /** Write defined names onto an ExcelJS workbook (Pass 2). */
30
+ export declare function applyDefinedNamesToExcelWorkbook(excelWorkbook: {
31
+ definedNames: {
32
+ add: (loc: string, name: string) => void;
33
+ };
34
+ }, definedNames: DefinedName[] | undefined, sheets: Array<{
35
+ id?: string;
36
+ name?: string;
37
+ }>): void;
38
+ /**
39
+ * Parse `<definedNames>` from xl/workbook.xml (keeps localSheetId).
40
+ */
41
+ export declare function parseDefinedNamesFromXlsxBuffer(arrayBuffer: ArrayBuffer): Promise<ExcelDefinedNameEntry[]>;
@@ -0,0 +1,28 @@
1
+ import { Sheet } from '../../sheet-engine/react';
2
+ import { ExcelDefinedNameEntry } from './xlsx-defined-names';
3
+
4
+ export declare function generateImportSheetId(): string;
5
+ export type XlsxImportWarning = {
6
+ code: 'tables-unsupported';
7
+ } | {
8
+ code: 'filters-unsupported';
9
+ };
10
+ export type XlsxParseSettings = {
11
+ /** Workbook default column width in px (from the live workbook settings, if any). */
12
+ workbookDefaultColWidth?: number;
13
+ /** Workbook default row height in px (from the live workbook settings, if any). */
14
+ workbookDefaultRowHeight?: number;
15
+ };
16
+ export type XlsxParsedWorkbook = {
17
+ /** Decorated + compacted sheets, ready for the ydoc write. */
18
+ sheets: Sheet[];
19
+ /** Workbook name from luckyexcel info (extension not yet stripped). */
20
+ workbookName: string;
21
+ /** UI warnings to replay on the main thread (toasts/onWarning). */
22
+ warnings: XlsxImportWarning[];
23
+ /** Sheet ids this pipeline generated — the caller may remap them with a custom generator. */
24
+ generatedSheetIds: string[];
25
+ /** Named ranges from xl/workbook.xml — synced to Yjs on the main thread. */
26
+ definedNameEntries: ExcelDefinedNameEntry[];
27
+ };
28
+ export declare function parseXlsxWorkbook(file: File, settings?: XlsxParseSettings): Promise<XlsxParsedWorkbook>;