@fileverse-dev/dsheet 2.1.5 → 3.0.1-yjs-1

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 (116) hide show
  1. package/dist/{constants-yStXQJiK.js → constants-Cdz6oSCq.js} +5 -7
  2. package/dist/constants.js +1 -1
  3. package/dist/editor/components/api-key-modal/api-key-input.d.ts +5 -0
  4. package/dist/editor/components/api-key-modal/api-key-modal.d.ts +7 -0
  5. package/dist/editor/components/api-key-modal/rate-limit-info.d.ts +4 -0
  6. package/dist/editor/components/comments/comment-actions-dropdown.d.ts +19 -0
  7. package/dist/editor/components/comments/comment-cell-popup.d.ts +4 -0
  8. package/dist/editor/components/comments/comment-input.d.ts +4 -0
  9. package/dist/editor/components/comments/comment-item.d.ts +4 -0
  10. package/dist/editor/components/comments/comment-sidebar-empty.d.ts +4 -0
  11. package/dist/editor/components/comments/comment-sidebar.d.ts +4 -0
  12. package/dist/editor/components/comments/ens/ens-cache.d.ts +10 -0
  13. package/dist/editor/components/comments/ens/use-ens-status.d.ts +10 -0
  14. package/dist/editor/components/comments/use-comment-cell-popup.d.ts +12 -0
  15. package/dist/editor/components/comments/use-comment-permissions.d.ts +15 -0
  16. package/dist/editor/components/editor-workbook.d.ts +11 -17
  17. package/dist/editor/components/sidebar/editor-right-sidebar.d.ts +20 -0
  18. package/dist/editor/components/sidebar/right-sidebar.d.ts +14 -0
  19. package/dist/editor/components/sidebar/sidebar-context.d.ts +17 -0
  20. package/dist/editor/components/sidebar/sidebar-portal-registry.d.ts +20 -0
  21. package/dist/editor/components/sidebar/use-right-panels.d.ts +12 -0
  22. package/dist/editor/components/sidebars/conditional-format.d.ts +2 -0
  23. package/dist/editor/components/sidebars/data-verification.d.ts +2 -0
  24. package/dist/editor/components/sidebars/function/function-categories-logic.d.ts +11 -0
  25. package/dist/editor/components/sidebars/function/function-categories.d.ts +6 -0
  26. package/dist/editor/components/sidebars/function/function-metadata.d.ts +7 -0
  27. package/dist/editor/components/sidebars/function/functionList.d.ts +8 -0
  28. package/dist/editor/components/sidebars/function/types.d.ts +24 -0
  29. package/dist/editor/components/sidebars/function/use-functions.d.ts +20 -0
  30. package/dist/editor/components/sidebars/function-content.d.ts +8 -0
  31. package/dist/editor/components/sidebars/template-ui.d.ts +22 -0
  32. package/dist/editor/components/sidebars/templates.d.ts +9 -0
  33. package/dist/editor/components/smart-contract/error-toast.d.ts +11 -0
  34. package/dist/editor/components/smart-contract/modal/abi-input-section.d.ts +11 -0
  35. package/dist/editor/components/smart-contract/modal/contract-name-section.d.ts +13 -0
  36. package/dist/editor/components/smart-contract/modal/file-upload-section.d.ts +12 -0
  37. package/dist/editor/components/smart-contract/modal/import-section.d.ts +8 -0
  38. package/dist/editor/components/smart-contract/modal/modal-header.d.ts +17 -0
  39. package/dist/editor/components/smart-contract/smart-contract-list-item.d.ts +8 -0
  40. package/dist/editor/components/smart-contract/smart-contract-modal-ui.d.ts +33 -0
  41. package/dist/editor/components/smart-contract/smart-contract-modal.d.ts +12 -0
  42. package/dist/editor/components/smart-contract/smart-contract-reading-intro.d.ts +4 -0
  43. package/dist/editor/components/smart-contract/smart-contract-view-list.d.ts +6 -0
  44. package/dist/editor/components/smart-contract/use-address-validation.d.ts +5 -0
  45. package/dist/editor/components/smart-contract/use-modal-outside-click.d.ts +18 -0
  46. package/dist/editor/components/smart-contract/use-smart-contract-modal.d.ts +38 -0
  47. package/dist/editor/constants/shared-constants.d.ts +0 -2
  48. package/dist/editor/contexts/editor-context.d.ts +20 -5
  49. package/dist/editor/dsheet-editor.d.ts +1 -1
  50. package/dist/editor/hooks/live-query/use-live-query.d.ts +4 -2
  51. package/dist/editor/hooks/use-editor-data.d.ts +4 -2
  52. package/dist/editor/hooks/use-smart-contract.d.ts +26 -0
  53. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +7 -1
  54. package/dist/editor/types/comments.d.ts +134 -0
  55. package/dist/editor/types/smart-contract.d.ts +88 -0
  56. package/dist/editor/types.d.ts +39 -32
  57. package/dist/editor/utils/after-update-cell.d.ts +13 -8
  58. package/dist/editor/utils/api-key-storage.d.ts +6 -0
  59. package/dist/editor/utils/api-keys-local-storage.d.ts +19 -0
  60. package/dist/editor/utils/cell-comment-marker.d.ts +30 -0
  61. package/dist/editor/utils/comment-key-utils.d.ts +7 -0
  62. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  63. package/dist/editor/utils/csv-import.d.ts +3 -1
  64. package/dist/editor/utils/data-block-error-handler.d.ts +21 -0
  65. package/dist/editor/utils/datablock-error-utils.d.ts +1 -0
  66. package/dist/editor/utils/sheet-editor-safe.d.ts +26 -0
  67. package/dist/editor/utils/smart-contract/constants.d.ts +488 -0
  68. package/dist/editor/utils/smart-contract/error-helper.d.ts +20 -0
  69. package/dist/editor/utils/smart-contract/helpers.d.ts +4 -0
  70. package/dist/editor/utils/smart-contract/reading-utils.d.ts +34 -0
  71. package/dist/editor/utils/smart-contract/signature-utils.d.ts +9 -0
  72. package/dist/editor/utils/spreadsheet-import.d.ts +12 -0
  73. package/dist/executeStringFunction-B2qjYgmE.js +31914 -0
  74. package/dist/formula.js +1 -1
  75. package/dist/index-C7kCuqoG.js +54326 -0
  76. package/dist/index.d.ts +11 -1
  77. package/dist/index.es.js +54 -48
  78. package/dist/observability/publish-trace.d.ts +26 -0
  79. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  80. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  81. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  82. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +15 -0
  83. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  84. package/dist/sheet-engine/core/context.d.ts +5 -0
  85. package/dist/sheet-engine/core/index.d.ts +1 -1
  86. package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +53 -0
  87. package/dist/sheet-engine/core/modules/formula-eval.worker.d.ts +1 -0
  88. package/dist/sheet-engine/core/modules/formula-range-cache.d.ts +20 -0
  89. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +40 -0
  90. package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +7 -0
  91. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +17 -0
  92. package/dist/sheet-engine/core/modules/formula-worker-types.d.ts +24 -0
  93. package/dist/sheet-engine/core/modules/formula.d.ts +26 -1
  94. package/dist/sheet-engine/core/modules/index.d.ts +3 -1
  95. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  96. package/dist/sheet-engine/core/theme.d.ts +67 -0
  97. package/dist/sheet-engine/core/types.d.ts +3 -0
  98. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +10 -0
  99. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +8 -0
  100. package/dist/sheet-engine/core/utils/range-format.d.ts +43 -0
  101. package/dist/sheet-engine/react/components/SheetOverlay/Icon.d.ts +5 -4
  102. package/dist/sheet-engine/react/components/SheetOverlay/LucideIcon.d.ts +4 -4
  103. package/dist/sheet-engine/react/components/SidebarPanelPortals/index.d.ts +17 -0
  104. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  105. package/dist/sheet-engine/react/components/Workbook/index.d.ts +11 -1
  106. package/dist/sheet-engine/react/components/index.d.ts +1 -0
  107. package/dist/sheet-engine/react/utils/datepickerStyles.d.ts +1 -1
  108. package/dist/style.css +1 -1
  109. package/dist/use-xlsx-import-impl-BQsXcyKJ.js +1551 -0
  110. package/dist/{xlsx-export-impl-DP_eK3zS.js → xlsx-export-impl-BBux0CIG.js} +1106 -1106
  111. package/package.json +6 -4
  112. package/dist/executeStringFunction-BkmJj04p.js +0 -27295
  113. package/dist/index-Drl8OuI3.js +0 -52659
  114. package/dist/sheet-engine/react/components/Toolbar/conditionalFormatPortal.d.ts +0 -7
  115. package/dist/sheet-engine/react/components/Toolbar/dataVerificationPortal.d.ts +0 -6
  116. package/dist/use-xlsx-import-impl-DC_BfAcT.js +0 -1527
package/dist/index.d.ts CHANGED
@@ -4,12 +4,22 @@ export { formulaResponseUiSync } from './editor/utils/formula-ui-sync';
4
4
  export { executeStringFunction } from './editor/utils/executeStringFunction';
5
5
  export { FLVURL } from '@fileverse-dev/formulajs';
6
6
  export { loadLocale } from './sheet-engine/core';
7
- export type { ErrorMessageHandlerReturnType } from './editor/types';
7
+ export type { ErrorMessageHandlerReturnType, DataBlockEvent, DataBlockEventType, ApiKeyStorage } from './editor/types';
8
+ export type { PanelConfig, PanelId, BuiltInPanelType } from './editor/types';
9
+ export type { CommentThread, CommentReply, CommentActionParams, CommentsConfig, } from './editor/types/comments';
10
+ export { CommentAction } from './editor/types/comments';
11
+ export { CommentsContent } from './editor/components/comments/comment-sidebar';
12
+ export { CommentCellUI } from './editor/components/comments/comment-cell-popup';
13
+ export { useEnsStatus } from './editor/components/comments/ens/use-ens-status';
14
+ export type { EnsStatus } from './editor/components/comments/ens/ens-cache';
15
+ export type { SmartContractConfig, SmartContractEvent, SmartContractEventType, ContractConfig, ContractRegistry, NewContractInput, } from './editor/types/smart-contract';
16
+ export { SupportedChain } from './editor/types/smart-contract';
8
17
  export type { WorkbookInstance } from './sheet-engine/react';
9
18
  export type { CollaborationProps, CollabConnectionConfig, CollabSessionMeta, CollabServices, CollabCallbacks, CollabState, CollabStatus, CollabError, CollabErrorCode, CollabUser, } from './sync-local/types';
10
19
  export { ERROR_MESSAGES_FLAG, SERVICES_API_KEY, } from './editor/constants/shared-constants';
11
20
  export { TEMPLATES } from '@fileverse-dev/dsheets-templates/template-metadata-list';
12
21
  export { handleCSVUpload } from './editor/utils/csv-import';
22
+ export { importSpreadsheetFile, type ImportSpreadsheetFileOptions, type ImportSpreadsheetFileResult, type SpreadsheetImportFileType, } from './editor/utils/spreadsheet-import';
13
23
  export { handleExportToXLSX } from './editor/utils/xlsx-export';
14
24
  export { handleExportToCSV } from './editor/utils/csv-export';
15
25
  export { handleExportToJSON } from './editor/utils/json-export';
package/dist/index.es.js CHANGED
@@ -1,53 +1,59 @@
1
- import { S as s, a as o, i as t, T as r, b as l, d as n, e as d, f as i, g as S, h as c, j as h, k as m, l as p, n as u, o as C, p as E, q as g, r as F, s as x, t as R, u as f, v as L, w as b, x as w, z as A, A as T, B as v, C as I, D, E as M, F as V, G as k } from "./index-Drl8OuI3.js";
2
- import { bP as z, bQ as X, bR as _, bV as y, bg as B, e as G, f as O, h as U, a as j, cf as q, aq as H, cm as J } from "./executeStringFunction-BkmJj04p.js";
3
- import { FLVURL as N } from "@fileverse-dev/formulajs";
4
- import { E as Y, S as Z } from "./constants-yStXQJiK.js";
1
+ import { C as s, a as t, b as o, S as l, d as r, i as n, e as d, T as c, f as i, g as S, h, j as m, k as p, l as C, n as u, o as E, p as g, q as F, s as x, t as R, u as f, v as A, w as L, x as w, z as I, A as T, B as v, D, E as M } from "./index-C7kCuqoG.js";
2
+ import { ce as V, cf as X, cg as b, cl as z, bd as P, e as U, f as _, l as y, a as B, cW as O, cX as Y, aY as j, cY as G, cZ as H, d1 as J, d2 as Z, d4 as q, D as K, di as N, dJ as W, aR as Q } from "./executeStringFunction-B2qjYgmE.js";
3
+ import { FLVURL as ee } from "@fileverse-dev/formulajs";
4
+ import { E as se, S as te } from "./constants-Cdz6oSCq.js";
5
5
  export {
6
- s as DSheetEditor,
7
- o as DSheetSkeleton,
8
- Y as ERROR_MESSAGES_FLAG,
9
- N as FLVURL,
10
- t as FortuneCore,
11
- Z as SERVICES_API_KEY,
12
- r as TEMPLATES,
13
- l as api,
14
- z as clearColumnsCellsFormat,
15
- n as clearFilter,
6
+ s as CommentAction,
7
+ t as CommentCellUI,
8
+ o as CommentsContent,
9
+ l as DSheetEditor,
10
+ r as DSheetSkeleton,
11
+ se as ERROR_MESSAGES_FLAG,
12
+ ee as FLVURL,
13
+ n as FortuneCore,
14
+ te as SERVICES_API_KEY,
15
+ d as SupportedChain,
16
+ c as TEMPLATES,
17
+ i as api,
18
+ V as clearColumnsCellsFormat,
19
+ S as clearFilter,
16
20
  X as clearRowsCellsFormat,
17
- _ as clearSelectedCellFormat,
18
- d as createFilter,
19
- y as deleteRowCol,
20
- B as deleteSelectedCellText,
21
- i as describeMatchedShortcut,
22
- G as executeStringFunction,
23
- O as formulaResponseUiSync,
24
- U as getFlowdata,
25
- S as getRemoveDuplicatesErrorMessage,
26
- c as getRemoveDuplicatesPreview,
27
- j as getSheetIndex,
28
- h as handleCSVUpload,
29
- m as handleCopy,
30
- p as handleExportToCSV,
31
- u as handleExportToJSON,
32
- C as handleExportToXLSX,
33
- E as handleFreeze,
34
- g as handleHorizontalAlign,
35
- F as handleLink,
36
- x as handleMerge,
21
+ b as clearSelectedCellFormat,
22
+ h as createFilter,
23
+ z as deleteRowCol,
24
+ P as deleteSelectedCellText,
25
+ m as describeMatchedShortcut,
26
+ U as executeStringFunction,
27
+ _ as formulaResponseUiSync,
28
+ y as getFlowdata,
29
+ p as getRemoveDuplicatesErrorMessage,
30
+ C as getRemoveDuplicatesPreview,
31
+ B as getSheetIndex,
32
+ u as handleCSVUpload,
33
+ E as handleCopy,
34
+ g as handleExportToCSV,
35
+ F as handleExportToJSON,
36
+ x as handleExportToXLSX,
37
+ O as handleFreeze,
38
+ Y as handleHorizontalAlign,
39
+ j as handleLink,
40
+ G as handleMerge,
37
41
  R as handlePasteByClick,
38
- f as handleSort,
39
- L as handleTextSize,
40
- b as handleVerticalAlign,
42
+ H as handleSort,
43
+ J as handleTextSize,
44
+ Z as handleVerticalAlign,
45
+ f as importSpreadsheetFile,
41
46
  q as insertRowCol,
42
- w as isBrowserZoomShortcut,
43
- A as isFormulaListShortcut,
44
- T as isOpenShortcutsModalShortcut,
45
- H as jfrefreshgrid,
46
- J as loadLocale,
47
- v as removeActiveImage,
48
- I as removeDuplicates,
49
- D as showImgChooser,
50
- M as toolbarItemClickHandler,
51
- V as updateFormat,
52
- k as useXLSXImport
47
+ A as isBrowserZoomShortcut,
48
+ L as isFormulaListShortcut,
49
+ w as isOpenShortcutsModalShortcut,
50
+ K as jfrefreshgrid,
51
+ N as loadLocale,
52
+ I as removeActiveImage,
53
+ T as removeDuplicates,
54
+ v as showImgChooser,
55
+ W as toolbarItemClickHandler,
56
+ Q as updateFormat,
57
+ D as useEnsStatus,
58
+ M as useXLSXImport
53
59
  };
@@ -0,0 +1,26 @@
1
+ export type PackagePublishTraceEvent = {
2
+ kind: 'package-onChange';
3
+ dsheetId: string;
4
+ traceId: number;
5
+ step: string;
6
+ ms: number;
7
+ heapMB: number | null;
8
+ meta?: Record<string, unknown>;
9
+ outcome?: 'complete' | 'skipped';
10
+ };
11
+ declare global {
12
+ interface Window {
13
+ __publishTraceEnabled?: () => boolean;
14
+ __publishTraceSink?: (event: PackagePublishTraceEvent) => void;
15
+ }
16
+ }
17
+ export declare class PackagePublishTrace {
18
+ private readonly dsheetId;
19
+ private last;
20
+ private traceId;
21
+ private finished;
22
+ constructor(dsheetId: string);
23
+ mark(step: string, meta?: Record<string, unknown>): void;
24
+ finish(meta?: Record<string, unknown>): void;
25
+ skip(reason: string, meta?: Record<string, unknown>): void;
26
+ }
@@ -6,26 +6,6 @@ export declare function getCellValue(ctx: Context, row: number, column: number,
6
6
  type?: keyof Cell;
7
7
  }): any;
8
8
  export declare function setCellValue(ctx: Context, row: number, column: number, value: any, cellInput: HTMLDivElement | null, options?: CommonOptions, callAfterUpdate?: boolean): void;
9
- /**
10
- * Apply a cell value coming from a remote RTC peer, verbatim.
11
- *
12
- * This differs from `setCellValue` in two important ways and must be used for
13
- * every Yjs-driven remote apply:
14
- *
15
- * 1. It NEVER runs the formula engine and NEVER fires the local-edit hooks
16
- * (`onLocalCellEdit` / `afterUpdateCell`). The peer already computed the
17
- * value, so we use the synced `v`/`m`/`f` as-is. This avoids both
18
- * recomputation divergence and an update loop back into Yjs.
19
- *
20
- * 2. It PRESERVES the formula calc list. The regular `setCellValue` object
21
- * branch calls `delFunctionGroup`, which removes the cell from `calcChain`
22
- * and strips its dependency edges. Because `execFunctionGroup` walks
23
- * `calcChain` to decide what to recompute, dropping a formula cell there
24
- * permanently breaks its reactivity on that client (even after RTC stops).
25
- * Here we instead keep formula cells registered via
26
- * `insertUpdateFunctionGroup`, so they stay reactive to future local edits
27
- * on both owner and peer.
28
- */
29
9
  export declare function applyRemoteCellValue(ctx: Context, row: number, column: number, value: any, options?: CommonOptions): void;
30
10
  export declare function clearCell(ctx: Context, row: number, column: number, options?: CommonOptions): void;
31
11
  export declare function setCellFormat(ctx: Context, row: number, column: number, attr: keyof Cell, value: any, options?: CommonOptions): void;
@@ -1,12 +1,13 @@
1
1
  import { Context } from '../context';
2
2
  import { CellMatrix, CellWithRowAndCol, Sheet } from '../types';
3
+ import { CellFormatRange } from '../utils/range-format';
3
4
 
4
5
  export type CommonOptions = {
5
6
  index?: number;
6
7
  id?: string;
7
8
  };
8
9
  export declare const dataToCelldata: (data: CellMatrix | undefined) => CellWithRowAndCol[];
9
- export declare const celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number) => CellMatrix | null;
10
+ export declare const celldataToData: (celldata: CellWithRowAndCol[], rowCount?: number, colCount?: number, cellFormatRanges?: CellFormatRange[]) => CellMatrix | null;
10
11
  export declare function getSheet(ctx: Context, options?: CommonOptions): Sheet;
11
12
  export declare function getSheetWithLatestCelldata(ctx: Context, options?: CommonOptions): {
12
13
  celldata: CellWithRowAndCol[];
@@ -7,5 +7,6 @@ export * from './rowcol';
7
7
  export * from './range';
8
8
  export * from './merge';
9
9
  export * from './sheet';
10
+ export * from './sheet-flowdata-lifecycle';
10
11
  export * from './workbook';
11
12
  export * from '../modules/error-state-helpers';
@@ -0,0 +1,15 @@
1
+ import { Context } from '../context';
2
+
3
+ /**
4
+ * Sheets that must keep dense `data` while `activeSheetId` is active:
5
+ * the active tab plus any tab referenced by its formulas (deps graph + text scan).
6
+ */
7
+ export declare function getSheetsRequiredDense(ctx: Context, activeSheetId: string): Set<string>;
8
+ /** Sheets the formula worker needs dense — active refs plus any tab with formulas. */
9
+ export declare function getSheetsNeededForWorkerSnapshot(ctx: Context): Set<string>;
10
+ export declare function demoteSheetToCelldata(ctx: Context, sheetId: string): void;
11
+ /**
12
+ * On tab switch: persist outgoing config, demote tabs not needed dense,
13
+ * hydrate active tab + cross-sheet references.
14
+ */
15
+ export declare function syncAndDemoteInactiveFlowdata(ctx: Context, activeSheetId: string, previousSheetId: string | null): Set<string>;
@@ -5,6 +5,11 @@ import { CellMatrix, Sheet } from '../types';
5
5
  export declare function getAllSheets(ctx: Context): Sheet[];
6
6
  export { getSheet };
7
7
  export declare function initSheetData(draftCtx: Context, index: number, newData: Sheet): CellMatrix | null;
8
+ /** Build dense `data` from sparse `celldata` when a sheet is activated or referenced. */
9
+ export declare function ensureSheetFlowdata(ctx: Context, options?: {
10
+ index?: number;
11
+ id?: string;
12
+ }): CellMatrix | null;
8
13
  export declare function hideSheet(ctx: Context, sheetId: string): void;
9
14
  export declare function showSheet(ctx: Context, sheetId: string): void;
10
15
  export declare function copySheet(ctx: Context, sheetId: string): void;
@@ -1,5 +1,6 @@
1
1
  import { SheetConfig, Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from './types';
2
2
  import { FormulaCache } from './modules';
3
+ import { FormulaAsyncEvalJob } from './modules/formula-async-eval';
3
4
  import { DateBaseLocale, Hooks } from './settings';
4
5
 
5
6
  interface MutableRefObject<T> {
@@ -239,6 +240,10 @@ export type Context = {
239
240
  luckysheetPaintSingle: boolean;
240
241
  defaultCell: Cell;
241
242
  groupValuesRefreshData: any[];
243
+ /** Chunked async formula recalc queue (Step 1 perf). Cleared when job completes. */
244
+ formulaAsyncEval?: FormulaAsyncEvalJob | null;
245
+ /** True while `formulaAsyncEval` is draining on the main thread in chunks. */
246
+ isFormulaCalculating?: boolean;
242
247
  /**
243
248
  * Incremented when formula `func_selectedrange` moves via keyboard (`rangeOfFormula`)
244
249
  * so React re-renders — `FormulaCache` is a class and Immer does not track it.
@@ -7,7 +7,7 @@ export { defaultSettings } from './settings';
7
7
  export type { Settings, Hooks, DateBaseLocale } from './settings';
8
8
  export { handleCopy, handleGlobalKeyDown, handlePaste, handlePasteByClick, fixPositionOnFrozenCells, handleCellAreaMouseDown, handleCellAreaDoubleClick, handleContextMenu, mouseRender, handleOverlayMouseMove, handleOverlayMouseUp, handleRowHeaderMouseDown, handleColumnHeaderMouseDown, handleColSizeHandleMouseDown, handleColSizeHandleDoubleClick, handleRowSizeHandleMouseDown, handleColFreezeHandleMouseDown, handleRowFreezeHandleMouseDown, describeMatchedShortcut, isBrowserZoomShortcut, isOpenShortcutsModalShortcut, isFormulaListShortcut, } from './events';
9
9
  export * from './locale';
10
- export { getBorderInfoComputeRange, getBorderInfoCompute, normalizedCellAttr, normalizedAttr, getCellValue, setCellValue, getRealCellValue, mergeBorder, cancelNormalSelected, updateCell, getRangetxt, getRangeByTxt, isValidRangeText, getInlineStringHTML, applyLinkToSelection, getHyperlinksFromInlineSegments, getUniformLinkFromWindowSelectionInEditor, getHyperlinkAtCaretInContentEditable, getStyleByCell, clearSelectedCellFormat, clearRowsCellsFormat, clearColumnsCellsFormat, clipboard, moveToEnd, getRangeRectsByCharacterOffset, getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, FormulaCache, groupValuesRefresh, execFunctionGroup, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, maybeRecoverDirtyRangeSelection, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, setFormulaEditorOwner, functionHTMLGenerate, suppressFormulaRangeSelectionForInitialEdit, rangeSetValue, getFormulaRangeIndexForKeyboardSync, createFormulaRangeSelect, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, initFreeze, isInlineStringCell, getInlineStringNoStyle, rowLocation, rowLocationByIndex, colLocation, colLocationByIndex, insertRowCol, deleteRowCol, hideSelected, showSelected, isShowHidenCR, getFilterHiddenRowsUnionFromFilterMap, getFilterHiddenRowsUnion, ensureManualHiddenInitialized, rebuildRowHiddenUnion, scrollToHighlightCell, selectTitlesMap, selectTitlesRange, defaultLuckysheetSelectRanges, normalizeSelection, syncPrimaryCellActiveFromSelection, selectionIsExactlyOneMergeBlock, setPrimaryCellActive, advancePrimaryCellInLastMultiSelection, snapSheetSelectionFocusToCellPreserveMultiRange, moveHighlightCell, deleteSelectedCellText, selectAll, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, calcSelectionInfo, addSheet, deleteSheet, editSheetName, changeSheet, updateFormat, autoSelectionFormula, handleBold, handleItalic, handleStrikeThrough, handleUnderline, handleHorizontalAlign, handleVerticalAlign, handleTextColor, handleTextBackground, handleBorder, handleMerge, mergeSelectionHasValues, handleSort, getRemoveDuplicatesPreview, removeDuplicates, getRemoveDuplicatesErrorMessage, handleFreeze, handleTextSize, handleSum, handleLink, captureLinkEditorOpenSnapshot, isHyperlinkCreationBlocked, toolbarItemClickHandler, toolbarItemSelectedFunc, handleScreenShot, insertImage, showImgChooser, drawArrow, setEditingComment, removeEditingComment, removeOverShowComment, newComment, editComment, deleteComment, showComments, showHideComment, showHideAllComments, onCommentBoxMoveStart, removeActiveImage, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, createDropCellRange, sortSelection, sortSheetBySelectedColumn, searchAll, searchNext, replace, replaceAll, replaceAllScoped, getSearchIndexArr, getSearchIndexArrAsync, getFindRangeOnCurrentSheet, getQuickSearchIndexArr, getQuickSearchHiddenConfig, getCellHyperlinks, getHyperlinkDisplayTextInCell, getInlineLinkPlainRange, getUniformLinkCoveringPlainRange, getUniformLinkAtPlainOffset, removeHyperlinkForLink, updateHyperlinkForLink, syncLinkCardAfterHyperlinkChange, expandCellRectForMerge, shouldQuickSearchUseAsync, runQuickSearchIndexArrAsync, QUICK_SEARCH_ASYNC_ROW_THRESHOLD, parseRangeText, getCellRowColumn, getCellHyperlink, saveHyperlink, removeHyperlink, showLinkCard, goToLink, isLinkValid, createFilterOptions, clearFilter, clearFilterForColumn, toggleViewerFilter, createFilter, applySheetFilterState, getFilterColumnValues, getFilterColumnColors, orderbydatafiler, saveFilter, onCellsMoveStart, cfSplitRange, updateMoreCell, getRegStr, getDataArr, applyLocation, getOptionValue, getSelectRange, getDropdownList, setDropdownValue, confirmMessage, setConditionRules, CF_DATE_DEFAULT_FORMAT, parseCfDateConditionForUi, formatCfDatePresetSnapshot, parseDdMmYyyyToSerial, handleOverlayTouchStart, handleOverlayTouchEnd, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, jfrefreshgrid, sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, setCellError, clearCellError, detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, iscelldata, getcellrange, cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult, execfunction, insertUpdateFunctionGroup, remapFormulaReferencesByMap, checkCF, getComputeMap, cancelPaintModel, hideCRCount, getdatabyselection, } from './modules';
10
+ export { getBorderInfoComputeRange, getBorderInfoCompute, normalizedCellAttr, normalizedAttr, getCellValue, setCellValue, getRealCellValue, mergeBorder, cancelNormalSelected, updateCell, getRangetxt, getRangeByTxt, isValidRangeText, getInlineStringHTML, applyLinkToSelection, getHyperlinksFromInlineSegments, getUniformLinkFromWindowSelectionInEditor, getHyperlinkAtCaretInContentEditable, getStyleByCell, clearSelectedCellFormat, clearRowsCellsFormat, clearColumnsCellsFormat, clipboard, moveToEnd, getRangeRectsByCharacterOffset, getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, FormulaCache, groupValuesRefresh, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, isFormulaEvalPending, FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, maybeRecoverDirtyRangeSelection, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, setFormulaEditorOwner, functionHTMLGenerate, suppressFormulaRangeSelectionForInitialEdit, rangeSetValue, getFormulaRangeIndexForKeyboardSync, createFormulaRangeSelect, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, initFreeze, isInlineStringCell, getInlineStringNoStyle, rowLocation, rowLocationByIndex, colLocation, colLocationByIndex, insertRowCol, deleteRowCol, hideSelected, showSelected, isShowHidenCR, getFilterHiddenRowsUnionFromFilterMap, getFilterHiddenRowsUnion, ensureManualHiddenInitialized, rebuildRowHiddenUnion, scrollToHighlightCell, selectTitlesMap, selectTitlesRange, defaultLuckysheetSelectRanges, normalizeSelection, syncPrimaryCellActiveFromSelection, selectionIsExactlyOneMergeBlock, setPrimaryCellActive, advancePrimaryCellInLastMultiSelection, snapSheetSelectionFocusToCellPreserveMultiRange, moveHighlightCell, deleteSelectedCellText, selectAll, fixRowStyleOverflowInFreeze, fixColumnStyleOverflowInFreeze, calcSelectionInfo, addSheet, deleteSheet, editSheetName, changeSheet, updateFormat, autoSelectionFormula, handleBold, handleItalic, handleStrikeThrough, handleUnderline, handleHorizontalAlign, handleVerticalAlign, handleTextColor, handleTextBackground, handleBorder, handleMerge, mergeSelectionHasValues, handleSort, getRemoveDuplicatesPreview, removeDuplicates, getRemoveDuplicatesErrorMessage, handleFreeze, handleTextSize, handleSum, handleLink, captureLinkEditorOpenSnapshot, isHyperlinkCreationBlocked, toolbarItemClickHandler, toolbarItemSelectedFunc, handleScreenShot, insertImage, showImgChooser, drawArrow, setEditingComment, removeEditingComment, removeOverShowComment, newComment, editComment, deleteComment, showComments, showHideComment, showHideAllComments, onCommentBoxMoveStart, removeActiveImage, cancelActiveImgItem, onImageMoveStart, onImageResizeStart, createDropCellRange, sortSelection, sortSheetBySelectedColumn, searchAll, searchNext, replace, replaceAll, replaceAllScoped, getSearchIndexArr, getSearchIndexArrAsync, getFindRangeOnCurrentSheet, getQuickSearchIndexArr, getQuickSearchHiddenConfig, getCellHyperlinks, getHyperlinkDisplayTextInCell, getInlineLinkPlainRange, getUniformLinkCoveringPlainRange, getUniformLinkAtPlainOffset, removeHyperlinkForLink, updateHyperlinkForLink, syncLinkCardAfterHyperlinkChange, expandCellRectForMerge, shouldQuickSearchUseAsync, runQuickSearchIndexArrAsync, QUICK_SEARCH_ASYNC_ROW_THRESHOLD, parseRangeText, getCellRowColumn, getCellHyperlink, saveHyperlink, removeHyperlink, showLinkCard, goToLink, isLinkValid, createFilterOptions, clearFilter, clearFilterForColumn, toggleViewerFilter, createFilter, applySheetFilterState, getFilterColumnValues, getFilterColumnColors, orderbydatafiler, saveFilter, onCellsMoveStart, cfSplitRange, updateMoreCell, getRegStr, getDataArr, applyLocation, getOptionValue, getSelectRange, getDropdownList, setDropdownValue, confirmMessage, setConditionRules, CF_DATE_DEFAULT_FORMAT, parseCfDateConditionForUi, formatCfDatePresetSnapshot, parseDdMmYyyyToSerial, handleOverlayTouchStart, handleOverlayTouchEnd, MAX_ZOOM_RATIO, MIN_ZOOM_RATIO, jfrefreshgrid, sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStart, onIframeMove, onIframeMoveEnd, onIframeResize, onIframeResizeEnd, setCellError, clearCellError, detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, iscelldata, getcellrange, cancelFunctionrangeSelected, seletedHighlistByindex, spillSortResult, execfunction, insertUpdateFunctionGroup, remapFormulaReferencesByMap, checkCF, getComputeMap, cancelPaintModel, hideCRCount, getdatabyselection, } from './modules';
11
11
  export type { FilterDate, FilterValue, FilterColor } from './modules';
12
12
  export { getFreezeState, toggleFreeze, indexToColumnChar, escapeScriptTag, escapeHTMLTag, getSheetIndex, replaceHtml, isAllowEdit, isAllowEditReadOnly, filterPatch, patchToOp, opToPatch, inverseRowColOptions, } from './utils';
13
13
  export type { PatchOptions, ChangedSheet } from './utils';
@@ -0,0 +1,53 @@
1
+ /** Minimum formula count before deferring eval to chunked async (Step 1). */
2
+ export declare const FORMULA_ASYNC_EVAL_THRESHOLD = 15;
3
+ /** Formulas evaluated per animation frame during async recalc. */
4
+ export declare const FORMULA_ASYNC_CHUNK_SIZE = 50;
5
+ /** Use a Web Worker when the async job has at least this many formulas. */
6
+ export declare const FORMULA_WORKER_THRESHOLD = 100;
7
+ /** Formulas evaluated per worker message (larger — runs off main thread). */
8
+ export declare const FORMULA_WORKER_CHUNK_SIZE = 300;
9
+ /** Maximum time to wait for a worker chunk before falling back to the real engine. */
10
+ export declare const FORMULA_WORKER_CHUNK_TIMEOUT_MS = 30000;
11
+ /** localStorage key for the optional formula execution debug panel. */
12
+ export declare const FORMULA_EXEC_DEBUG_STORAGE_KEY = "fortune-formula-execution-debug";
13
+ export declare function isFormulaExecutionDebugEnabled(): boolean;
14
+ export type FormulaEvalDebugMode = 'worker' | 'main-thread' | 'fallback';
15
+ export type FormulaEvalDebug = {
16
+ mode: FormulaEvalDebugMode;
17
+ lastChunkMs: number;
18
+ lastChunkSize: number;
19
+ completedChunks: number;
20
+ fallbackChunks: number;
21
+ workerAvailable: boolean;
22
+ unsafeFormulaCount: number;
23
+ workerFormulaCount: number;
24
+ totalWorkerFormulas: number;
25
+ totalMainThreadFormulas: number;
26
+ lastError: string | null;
27
+ };
28
+ export type FormulaAsyncEvalJob = {
29
+ formulaRunList: Array<{
30
+ r: number;
31
+ c: number;
32
+ id: string;
33
+ calc_funcStr: string;
34
+ level?: number;
35
+ }>;
36
+ calcChainKeys: string[];
37
+ impactedByCircular: string[];
38
+ cycleNodes: string[];
39
+ workerSnapshotKey: string;
40
+ nextIndex: number;
41
+ total: number;
42
+ debug?: FormulaEvalDebug;
43
+ };
44
+ export declare function isFormulaEvalPending(ctx: {
45
+ isFormulaCalculating?: boolean;
46
+ formulaAsyncEval?: FormulaAsyncEvalJob | null;
47
+ }): boolean;
48
+ /**
49
+ * The worker snapshot evaluator intentionally handles only scalar formulas that
50
+ * mirror the main engine well. Dynamic/spill/range-indirection formulas stay on
51
+ * the main thread so `spillSortResult` and special range logic remain authoritative.
52
+ */
53
+ export declare function isFormulaWorkerUnsafe(calcFuncStr: string): boolean;
@@ -0,0 +1,20 @@
1
+ export type RangePassCacheEntry = {
2
+ fragment: any[][];
3
+ cryptoDenomination: string;
4
+ cryptoDecimal: number;
5
+ globalDataKeysFingerprint: string;
6
+ };
7
+ export declare function makeRangePassCacheKey(sheetId: string, startRow: number, endRow: number, startCol: number, endCol: number): string;
8
+ export declare function collectGlobalDataKeysInRange(execFunctionGlobalData: Record<string, unknown>, sheetId: string, startRow: number, endRow: number, startCol: number, endCol: number): string;
9
+ /** Remove the formula origin cell from a full rectangular range fragment. */
10
+ export declare function sliceRangeFragmentForOrigin(full: any[][], startRow: number, startCol: number, originRow: number | null | undefined, originCol: number | null | undefined): any[][];
11
+ type RangeCacheHost = {
12
+ rangeValuePassCache?: Map<string, RangePassCacheEntry>;
13
+ rangeValuePassCacheStats?: {
14
+ hits: number;
15
+ misses: number;
16
+ };
17
+ };
18
+ export declare function beginRangeValuePassCache(cache: RangeCacheHost): void;
19
+ export declare function clearRangeValuePassCache(cache: RangeCacheHost): void;
20
+ export {};
@@ -0,0 +1,40 @@
1
+ import { CellMatrix } from '../types';
2
+
3
+ export type SnapshotSheet = {
4
+ id: string;
5
+ name: string;
6
+ data: CellMatrix | null | undefined;
7
+ };
8
+ export type SnapshotFormulaCell = {
9
+ r: number;
10
+ c: number;
11
+ id: string;
12
+ calc_funcStr: string;
13
+ };
14
+ export type SnapshotFormulaResult = {
15
+ r: number;
16
+ c: number;
17
+ id: string;
18
+ v: unknown;
19
+ f: string;
20
+ spe?: unknown;
21
+ deps: string[];
22
+ isError: boolean;
23
+ };
24
+ export type SnapshotEvalInput = {
25
+ sheets: SnapshotSheet[];
26
+ execFunctionGlobalData: Record<string, {
27
+ v: unknown;
28
+ f: unknown;
29
+ }>;
30
+ formulas: SnapshotFormulaCell[];
31
+ };
32
+ export type SnapshotEvalOutput = {
33
+ execFunctionGlobalData: Record<string, {
34
+ v: unknown;
35
+ f: unknown;
36
+ }>;
37
+ results: SnapshotFormulaResult[];
38
+ };
39
+ /** Worker-safe formula evaluation against plain sheet snapshots (no React/immer). */
40
+ export declare function evalFormulasInSnapshot(input: SnapshotEvalInput): SnapshotEvalOutput;
@@ -0,0 +1,7 @@
1
+ /** Cell / formula key format used in depsByCell and revDepsByCell. */
2
+ export declare function toFormulaDepCellKey(sheetId: string, r: number, c: number): string;
3
+ /**
4
+ * Walk revDepsByCell from a changed cell to collect every formula cell that
5
+ * must recalculate (direct + transitive dependents).
6
+ */
7
+ export declare function collectTransitiveFormulaDependents(originCellKey: string, revDepsByCell: Map<string, Set<string>>): Set<string>;
@@ -0,0 +1,17 @@
1
+ import { Context } from '../context';
2
+ import { SnapshotEvalInput, SnapshotEvalOutput, SnapshotFormulaCell, evalFormulasInSnapshot } from './formula-snapshot-eval';
3
+ import { FORMULA_WORKER_CHUNK_SIZE } from './formula-async-eval';
4
+
5
+ export declare function invalidateFormulaWorkerSnapshot(): void;
6
+ export declare function buildSnapshotEvalInput(ctx: Context, formulas: SnapshotFormulaCell[]): SnapshotEvalInput;
7
+ export declare function buildWorkerEvalInput(ctx: Context, formulas: SnapshotFormulaCell[]): Omit<SnapshotEvalInput, 'sheets'>;
8
+ export declare function initFormulaWorkerSnapshot(ctx: Context, snapshotKey: string): boolean;
9
+ /**
10
+ * Evaluate a formula chunk off the critical UI path when possible.
11
+ * Uses an inline Web Worker. Callers should fall back to the real engine on
12
+ * rejection so the worker cannot silently leave a recalculation job hanging.
13
+ */
14
+ export declare function evalFormulasInBackground(snapshotKey: string, input: Omit<SnapshotEvalInput, 'sheets'>): Promise<SnapshotEvalOutput>;
15
+ /** @deprecated Use evalFormulasInBackground */
16
+ export declare const evalFormulasInWorker: typeof evalFormulasInBackground;
17
+ export { FORMULA_WORKER_CHUNK_SIZE, evalFormulasInSnapshot };
@@ -0,0 +1,24 @@
1
+ import { SnapshotEvalInput, SnapshotEvalOutput, SnapshotSheet } from './formula-snapshot-eval';
2
+
3
+ export type WorkerInitSnapshotRequest = {
4
+ type: 'init-snapshot';
5
+ snapshotKey: string;
6
+ sheets: SnapshotSheet[];
7
+ };
8
+ export type WorkerEvalRequest = {
9
+ type: 'eval';
10
+ requestId: number;
11
+ snapshotKey: string;
12
+ input: Omit<SnapshotEvalInput, 'sheets'>;
13
+ };
14
+ export type WorkerRequest = WorkerInitSnapshotRequest | WorkerEvalRequest;
15
+ export type WorkerEvalResponse = {
16
+ type: 'eval-result';
17
+ requestId: number;
18
+ output: SnapshotEvalOutput;
19
+ };
20
+ export type WorkerEvalError = {
21
+ type: 'eval-error';
22
+ requestId: number;
23
+ message: string;
24
+ };
@@ -1,5 +1,8 @@
1
- import { Cell, Rect, Selection } from '../types';
1
+ import { Cell, CellMatrix, Rect, Selection } from '../types';
2
2
  import { Context } from '../context';
3
+ import { FormulaAsyncEvalJob } from './formula-async-eval';
4
+ import { RangePassCacheEntry } from './formula-range-cache';
5
+ import { SnapshotEvalOutput } from './formula-snapshot-eval';
3
6
 
4
7
  /** True when the formula is only numeric ops on TODAY()/NOW() (incl. unary +/−); used to display serials as dates. */
5
8
  export declare function isTodayNowPureArithmeticDateResult(formula: string, value: number): boolean;
@@ -37,6 +40,12 @@ export declare class FormulaCache {
37
40
  depsByCell: Map<string, Set<string>>;
38
41
  /** Reverse dependency graph: referenced cell -> dependent formula cells. */
39
42
  revDepsByCell: Map<string, Set<string>>;
43
+ /**
44
+ * Formulas that referenced a range too large to fully expand into `revDepsByCell`.
45
+ * These must be included on incremental recalcs because a single-cell edit may
46
+ * affect them even when no precise reverse edge exists.
47
+ */
48
+ formulasWithWideRangeDeps: Set<string>;
40
49
  /**
41
50
  * Dependency collection state for the currently-parsed formula, set by `execfunction`.
42
51
  * When null, dependency recording is disabled.
@@ -44,8 +53,20 @@ export declare class FormulaCache {
44
53
  activeDepCollection: null | {
45
54
  originKey: string;
46
55
  deps: Set<string>;
56
+ hasWideRangeDep: boolean;
57
+ };
58
+ /** Step 2: per execFunctionGroup pass cache for materialized range reads. */
59
+ rangeValuePassCache?: Map<string, RangePassCacheEntry>;
60
+ rangeValuePassCacheStats?: {
61
+ hits: number;
62
+ misses: number;
47
63
  };
48
64
  constructor();
65
+ materializeFullRangeFragment(context: Context, sheetId: string, flowdata: CellMatrix | null | undefined, startRow: number, endRow: number, startCol: number, endCol: number): {
66
+ fragment: any[][];
67
+ cryptoDenomination: string;
68
+ cryptoDecimal: number;
69
+ };
49
70
  tryGetCellAsNumber(cell: Cell): string | number | boolean | undefined;
50
71
  }
51
72
  export declare function iscelldata(txt: string): boolean;
@@ -55,6 +76,10 @@ export declare function delFunctionGroup(ctx: Context, r: number, c: number, id?
55
76
  export declare function insertUpdateFunctionGroup(ctx: Context, r: number, c: number, id?: string, calcChainSet?: Set<string>): void;
56
77
  export declare function execfunction(ctx: Context, txt: string, r: number, c: number, id?: string, calcChainSet?: Set<string>, isrefresh?: boolean, notInsertFunc?: boolean): any[];
57
78
  export declare function groupValuesRefresh(ctx: Context): void;
79
+ /** Apply worker chunk output onto the live context (main thread only). */
80
+ export declare function applyWorkerFormulaChunkResults(ctx: Context, output: SnapshotEvalOutput, impactedByCircular: Set<string>, cycleNodes: Set<string>, calcChainKeys?: string[], data?: CellMatrix | null): void;
81
+ /** Run up to `chunkSize` formulas from an async job. Returns true when job is complete. */
82
+ export declare function runFormulaEvalChunk(ctx: Context, job: FormulaAsyncEvalJob, chunkSize?: number): boolean;
58
83
  export declare function execFunctionGroup(ctx: Context, origin_r: number, origin_c: number, value: any, id?: string, data?: any, isForce?: boolean): void;
59
84
  /**
60
85
  * Before the first `moveHighlightCell/Range(..., "rangeOfFormula")` while editing
@@ -5,6 +5,8 @@ export { moveToEnd, getRangeRectsByCharacterOffset } from './cursor';
5
5
  export { getDateBaseLocale, getCanonicalDateEditFormat, getDateEditFormatForCell, isUsDateBaseLocale, normalizeDateBaseLocale, shouldPreserveDateFormatForEdit, setDateBaseLocale, } from './date-base-locale';
6
6
  export { update, is_date, valueShowEs, isTypedCurrencyDisplayFormat, isCurrencyLikeNumberFormat, buildFiatCurrencyFormat, quoteSsfLiteral, } from './format';
7
7
  export { FormulaCache, groupValuesRefresh, setCaretPosition, getrangeseleciton, getFormulaEditorOwner, rangeHightlightselected, handleFormulaInput, israngeseleciton, createRangeHightlight, createFormulaRangeSelect, maybeRecoverDirtyRangeSelection, delFunctionGroup, functionHTMLGenerate, onFormulaRangeDragEnd, rangeDrag, rangeSetValue, remapFormulaReferencesByMap, getFormulaRangeIndexAtCaret, isCaretAtValidFormulaRangeInsertionPoint, isLegacyFormulaRangeMode, markRangeSelectionDirty, getFormulaRangeIndexForKeyboardSync, isFormulaReferenceInputMode, seedFormulaFuncSelectedRangeFromLastSelection, functionStrChange, setFormulaEditorOwner, getAllFunctionGroup, suppressFormulaRangeSelectionForInitialEdit, } from './formula';
8
+ export { FORMULA_ASYNC_CHUNK_SIZE, FORMULA_ASYNC_EVAL_THRESHOLD, FORMULA_WORKER_CHUNK_SIZE, FORMULA_WORKER_THRESHOLD, isFormulaEvalPending, } from './formula-async-eval';
9
+ export type { FormulaAsyncEvalJob } from './formula-async-eval';
8
10
  export { initFreeze } from './freeze';
9
11
  export { isInlineStringCell, getInlineStringNoStyle, applyLinkToSelection, getHyperlinksFromInlineSegments, getUniformLinkFromWindowSelectionInEditor, getHyperlinkAtCaretInContentEditable, } from './inline-string';
10
12
  export { rowLocation, rowLocationByIndex, colLocation, colLocationByIndex, } from './location';
@@ -40,6 +42,6 @@ export { sanitizeDuneUrl, insertDuneChart, onIframeMoveStart, onIframeResizeStar
40
42
  export { setCellError, clearCellError, overShowError, } from './error-state-helpers';
41
43
  export { checkCellIsLocked } from './protection';
42
44
  export { detectDateFormat, isdatatypemulti, diff, isdatetime, isRealNull, isRealNum, isNumericCellType, } from './validation';
43
- export { iscelldata, getcellrange, execfunction, execFunctionGroup, insertUpdateFunctionGroup, functionCopy, } from './formula';
45
+ export { iscelldata, getcellrange, execfunction, execFunctionGroup, runFormulaEvalChunk, applyWorkerFormulaChunkResults, insertUpdateFunctionGroup, functionCopy, } from './formula';
44
46
  export { checkCF, getComputeMap } from './ConditionFormat';
45
47
  export { getdatabyselection, getQKBorder } from './cell';
@@ -0,0 +1,23 @@
1
+ export declare function isTransparentBorderColor(color: string): boolean;
2
+ export declare function isMeaningfulBorderSide(side: {
3
+ style?: number;
4
+ color?: string;
5
+ } | undefined): boolean;
6
+ export declare function filterMeaningfulBorderSides(sides: {
7
+ l?: {
8
+ style?: number;
9
+ color?: string;
10
+ };
11
+ r?: {
12
+ style?: number;
13
+ color?: string;
14
+ };
15
+ t?: {
16
+ style?: number;
17
+ color?: string;
18
+ };
19
+ b?: {
20
+ style?: number;
21
+ color?: string;
22
+ };
23
+ }): typeof sides;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Grid (canvas) theming — the single source of truth for the JS-painted grid's per-theme colors.
3
+ *
4
+ * The chrome (toolbar, sidebars, comments) themes passively via `@fileverse/ui` `.color-*`
5
+ * utilities + the `<html>` class. The canvas grid cannot read CSS variables, so `canvas.ts`
6
+ * resolves its colors from `activePalette` here. On theme change the host threads a `theme` prop
7
+ * to the engine, which calls `setActiveGridPalette` and repaints via `jfrefreshgrid`.
8
+ *
9
+ * `ThemeKey` is copied verbatim from `fileverse-ddoc` `package/types.ts` so the dsheet `theme`
10
+ * prop is type-identical to ddoc's and a host app can pass the same value to both editors.
11
+ *
12
+ * See docs/DROP-IN-PACKAGE-AND-THEMING.md §7 (Theming)
13
+ */
14
+ export type ThemeKey = 'light' | 'dark' | 'theme-sepia' | 'theme-pink' | 'theme-green';
15
+ export declare const DEFAULT_THEME: ThemeKey;
16
+ /**
17
+ * dsheet selection-accent brand color. Constant across all five themes (readable on every
18
+ * background) — intentionally NOT a per-theme palette slot. Used for the fill handle, selection
19
+ * border, and marching ants.
20
+ */
21
+ export declare const SELECTION_ACCENT = "#EFC703";
22
+ /**
23
+ * One slot per neutral grid-chrome color role painted in `canvas.ts`. User-authored cell colors
24
+ * (cell `bg`/`fc`/border, conditional-format colors) are NOT here — they render literally in every
25
+ * theme and are read straight from cell data.
26
+ */
27
+ export interface GridPalette {
28
+ /** Unset cell background + main-area canvas clear (the `!fillStyle` fallback branch). */
29
+ cellBg: string;
30
+ /** Gridlines. */
31
+ gridLine: string;
32
+ /** Default cell text (cells with no user `fc`). */
33
+ cellText: string;
34
+ /** Row/column header background. */
35
+ headerBg: string;
36
+ /** Row/column header text. */
37
+ headerText: string;
38
+ /** Secondary fill for on-canvas chips (e.g. data-verification dropdown). */
39
+ secondaryFill: string;
40
+ /** Frozen-pane divider line. */
41
+ freezeLine: string;
42
+ }
43
+ /**
44
+ * Per-theme grid palettes.
45
+ *
46
+ * `light` holds the EXACT pre-theming hex from `canvas.ts`, so the default theme renders
47
+ * pixel-identical to before this change (regression guard).
48
+ *
49
+ * [Unverified] The four non-light palettes are reasonable design-guess values derived from each
50
+ * theme's surface swatch — NOT final brand colors; they need design sign-off. The mechanism is
51
+ * independent of the exact values.
52
+ */
53
+ export declare const GRID_THEMES: Record<ThemeKey, GridPalette>;
54
+ export declare const resolveGridPalette: (theme?: ThemeKey) => GridPalette;
55
+ /**
56
+ * The palette the canvas paints from. Module-level so the imperative canvas reads it on every
57
+ * repaint without prop threading inside the engine. `canvas.ts` imports this as a live binding and
58
+ * reads `activePalette.<slot>` at paint time; reassigning it here updates every reader.
59
+ *
60
+ * NOTE: this is a module singleton — multiple workbooks with different themes on one page would
61
+ * share it. dsheet renders one editor per page (like ddoc), so this is acceptable. If multi-instance
62
+ * is ever needed, move the palette onto `sheetCtx`.
63
+ */
64
+ export declare let activePalette: GridPalette;
65
+ /** Swap the active grid palette. Returns true if it actually changed (caller decides to repaint). */
66
+ export declare const setActiveGridPalette: (theme?: ThemeKey) => boolean;
67
+ export declare const getActiveTheme: () => ThemeKey;