@fileverse-dev/dsheet 2.1.5 → 3.0.1-formula-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 (132) 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-sync.d.ts +1 -1
  17. package/dist/editor/components/editor-workbook.d.ts +11 -17
  18. package/dist/editor/components/sidebar/editor-right-sidebar.d.ts +20 -0
  19. package/dist/editor/components/sidebar/right-sidebar.d.ts +14 -0
  20. package/dist/editor/components/sidebar/sidebar-context.d.ts +17 -0
  21. package/dist/editor/components/sidebar/sidebar-portal-registry.d.ts +20 -0
  22. package/dist/editor/components/sidebar/use-right-panels.d.ts +12 -0
  23. package/dist/editor/components/sidebars/conditional-format.d.ts +2 -0
  24. package/dist/editor/components/sidebars/data-verification.d.ts +2 -0
  25. package/dist/editor/components/sidebars/function/function-categories-logic.d.ts +11 -0
  26. package/dist/editor/components/sidebars/function/function-categories.d.ts +6 -0
  27. package/dist/editor/components/sidebars/function/function-metadata.d.ts +7 -0
  28. package/dist/editor/components/sidebars/function/functionList.d.ts +8 -0
  29. package/dist/editor/components/sidebars/function/types.d.ts +24 -0
  30. package/dist/editor/components/sidebars/function/use-functions.d.ts +20 -0
  31. package/dist/editor/components/sidebars/function-content.d.ts +8 -0
  32. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  33. package/dist/editor/components/sidebars/template-ui.d.ts +22 -0
  34. package/dist/editor/components/sidebars/templates.d.ts +9 -0
  35. package/dist/editor/components/smart-contract/error-toast.d.ts +11 -0
  36. package/dist/editor/components/smart-contract/modal/abi-input-section.d.ts +11 -0
  37. package/dist/editor/components/smart-contract/modal/contract-name-section.d.ts +13 -0
  38. package/dist/editor/components/smart-contract/modal/file-upload-section.d.ts +12 -0
  39. package/dist/editor/components/smart-contract/modal/import-section.d.ts +8 -0
  40. package/dist/editor/components/smart-contract/modal/modal-header.d.ts +17 -0
  41. package/dist/editor/components/smart-contract/smart-contract-list-item.d.ts +8 -0
  42. package/dist/editor/components/smart-contract/smart-contract-modal-ui.d.ts +33 -0
  43. package/dist/editor/components/smart-contract/smart-contract-modal.d.ts +12 -0
  44. package/dist/editor/components/smart-contract/smart-contract-reading-intro.d.ts +4 -0
  45. package/dist/editor/components/smart-contract/smart-contract-view-list.d.ts +6 -0
  46. package/dist/editor/components/smart-contract/use-address-validation.d.ts +5 -0
  47. package/dist/editor/components/smart-contract/use-modal-outside-click.d.ts +18 -0
  48. package/dist/editor/components/smart-contract/use-smart-contract-modal.d.ts +38 -0
  49. package/dist/editor/constants/shared-constants.d.ts +0 -2
  50. package/dist/editor/contexts/editor-context.d.ts +20 -5
  51. package/dist/editor/dsheet-editor.d.ts +1 -1
  52. package/dist/editor/hooks/live-query/use-live-query.d.ts +4 -2
  53. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  54. package/dist/editor/hooks/use-editor-data.d.ts +4 -2
  55. package/dist/editor/hooks/use-smart-contract.d.ts +26 -0
  56. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +8 -1
  57. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  58. package/dist/editor/types/comments.d.ts +134 -0
  59. package/dist/editor/types/smart-contract.d.ts +88 -0
  60. package/dist/editor/types.d.ts +39 -32
  61. package/dist/editor/utils/after-update-cell.d.ts +13 -8
  62. package/dist/editor/utils/api-key-storage.d.ts +6 -0
  63. package/dist/editor/utils/api-keys-local-storage.d.ts +19 -0
  64. package/dist/editor/utils/cell-comment-marker.d.ts +30 -0
  65. package/dist/editor/utils/comment-key-utils.d.ts +7 -0
  66. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  67. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  68. package/dist/editor/utils/csv-import.d.ts +3 -1
  69. package/dist/editor/utils/data-block-error-handler.d.ts +21 -0
  70. package/dist/editor/utils/datablock-error-utils.d.ts +1 -0
  71. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  72. package/dist/editor/utils/sheet-editor-safe.d.ts +26 -0
  73. package/dist/editor/utils/smart-contract/constants.d.ts +488 -0
  74. package/dist/editor/utils/smart-contract/error-helper.d.ts +20 -0
  75. package/dist/editor/utils/smart-contract/helpers.d.ts +4 -0
  76. package/dist/editor/utils/smart-contract/reading-utils.d.ts +34 -0
  77. package/dist/editor/utils/smart-contract/signature-utils.d.ts +9 -0
  78. package/dist/editor/utils/spreadsheet-import.d.ts +12 -0
  79. package/dist/editor/utils/update-ydoc.d.ts +2 -2
  80. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  81. package/dist/executeStringFunction-DMPoSj5F.js +32826 -0
  82. package/dist/formula.js +1 -1
  83. package/dist/index-DAVuAF9T.js +55303 -0
  84. package/dist/index.d.ts +11 -1
  85. package/dist/index.es.js +55 -49
  86. package/dist/jszip.min-CEyB-71x.js +2319 -0
  87. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  88. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  89. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  90. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  91. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  92. package/dist/sheet-engine/core/context.d.ts +8 -1
  93. package/dist/sheet-engine/core/index.d.ts +2 -2
  94. package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +53 -0
  95. package/dist/sheet-engine/core/modules/formula-eval.worker.d.ts +1 -0
  96. package/dist/sheet-engine/core/modules/formula-range-cache.d.ts +20 -0
  97. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +51 -0
  98. package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +7 -0
  99. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +17 -0
  100. package/dist/sheet-engine/core/modules/formula-worker-types.d.ts +24 -0
  101. package/dist/sheet-engine/core/modules/formula.d.ts +53 -1
  102. package/dist/sheet-engine/core/modules/index.d.ts +5 -2
  103. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  104. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  105. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  106. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  107. package/dist/sheet-engine/core/settings.d.ts +3 -1
  108. package/dist/sheet-engine/core/theme.d.ts +67 -0
  109. package/dist/sheet-engine/core/types.d.ts +20 -0
  110. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
  111. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
  112. package/dist/sheet-engine/core/utils/range-format.d.ts +71 -0
  113. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +40 -0
  114. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  115. package/dist/sheet-engine/react/components/SheetOverlay/Icon.d.ts +5 -4
  116. package/dist/sheet-engine/react/components/SheetOverlay/LucideIcon.d.ts +4 -4
  117. package/dist/sheet-engine/react/components/SidebarPanelPortals/index.d.ts +17 -0
  118. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  119. package/dist/sheet-engine/react/components/Workbook/index.d.ts +11 -1
  120. package/dist/sheet-engine/react/components/index.d.ts +1 -0
  121. package/dist/sheet-engine/react/utils/datepickerStyles.d.ts +1 -1
  122. package/dist/style.css +1 -1
  123. package/dist/use-xlsx-import-impl-DzthrhwA.js +1595 -0
  124. package/dist/xlsx-defined-names-D2KoICbm.js +117 -0
  125. package/dist/xlsx-export-impl-b2z4De4f.js +818 -0
  126. package/package.json +6 -4
  127. package/dist/executeStringFunction-BkmJj04p.js +0 -27295
  128. package/dist/index-Drl8OuI3.js +0 -52659
  129. package/dist/sheet-engine/react/components/Toolbar/conditionalFormatPortal.d.ts +0 -7
  130. package/dist/sheet-engine/react/components/Toolbar/dataVerificationPortal.d.ts +0 -6
  131. package/dist/use-xlsx-import-impl-DC_BfAcT.js +0 -1527
  132. package/dist/xlsx-export-impl-DP_eK3zS.js +0 -3126
@@ -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,17 @@
1
+ import { Context } from '../context';
2
+
3
+ /** Drop cached dense-sheet set (e.g. after structural workbook changes). */
4
+ export declare function invalidateSheetsRequiredDenseCache(): void;
5
+ /**
6
+ * Sheets that must keep dense `data` while `activeSheetId` is active:
7
+ * the active tab, tabs its formulas read, and tabs with formulas that read it.
8
+ */
9
+ export declare function getSheetsRequiredDense(ctx: Context, activeSheetId: string): Set<string>;
10
+ /** Sheets the formula worker needs dense — active refs plus any tab with formulas. */
11
+ export declare function getSheetsNeededForWorkerSnapshot(ctx: Context): Set<string>;
12
+ export declare function demoteSheetToCelldata(ctx: Context, sheetId: string): void;
13
+ /**
14
+ * On tab switch: persist outgoing config, demote tabs not needed dense,
15
+ * hydrate active tab + cross-sheet references.
16
+ */
17
+ 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
- import { SheetConfig, Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError } from './types';
1
+ import { SheetConfig, Sheet, Selection, Cell, CommentBox, Rect, Image, Presence, LinkCardProps, FilterOptions, RangeDialogProps, DataRegulationProps, ConditionRulesProps, GlobalCache, CellError, DefinedName } 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> {
@@ -115,6 +116,8 @@ export type Context = {
115
116
  currentSheetId: string;
116
117
  calculateSheetId: string;
117
118
  config: SheetConfig;
119
+ /** Workbook-level named ranges (synced via Yjs `${dsheetId}:definedNames`). */
120
+ definedNames: DefinedName[];
118
121
  visibledatarow: number[];
119
122
  visibledatacolumn: number[];
120
123
  ch_width: number;
@@ -239,6 +242,10 @@ export type Context = {
239
242
  luckysheetPaintSingle: boolean;
240
243
  defaultCell: Cell;
241
244
  groupValuesRefreshData: any[];
245
+ /** Chunked async formula recalc queue (Step 1 perf). Cleared when job completes. */
246
+ formulaAsyncEval?: FormulaAsyncEvalJob | null;
247
+ /** True while `formulaAsyncEval` is draining on the main thread in chunks. */
248
+ isFormulaCalculating?: boolean;
242
249
  /**
243
250
  * Incremented when formula `func_selectedrange` moves via keyboard (`rangeOfFormula`)
244
251
  * so React re-renders — `FormulaCache` is a class and Immer does not track it.
@@ -7,11 +7,11 @@ 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, ensureFormulaRangeToSheet, shouldPreserveFormulaEditOnSheetSwitch, activateSheetForNavigation, returnToFormulaOriginSheet, 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, refreshFormulasUsingDefinedNames, checkCF, getComputeMap, isValidDefinedNameIdentifier, getDefinedNameDisplayRange, findDefinedNameForSelection, findDefinedNameByName, resolveDefinedNameForFormula, addDefinedName, updateDefinedName, deleteDefinedName, selectDefinedName, openNamedRangesSidebar, scheduleDefinedNamesSync, shiftDefinedNamesOnInsert, shiftDefinedNamesOnDelete, removeDefinedNamesForSheet, 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';
14
- export type { Op, Cell, CellWithRowAndCol, CellMatrix, HyperlinkEntry, Selection, Presence, Sheet, GlobalCache, SingleRange, Range, SearchResult, LinkCardProps, LiveQueryData, Freezen, } from './types';
14
+ export type { Op, Cell, CellWithRowAndCol, CellMatrix, HyperlinkEntry, Selection, Presence, Sheet, GlobalCache, SingleRange, Range, SearchResult, LinkCardProps, LiveQueryData, Freezen, DefinedName, } from './types';
15
15
  export type { RemoveDuplicatesColumnOption, RemoveDuplicatesError, RemoveDuplicatesOptions, RemoveDuplicatesPreview, RemoveDuplicatesResult, } from './modules';
16
16
  export type { CheckModes, HyperlinkMap, FindSearchScope, ReplaceScope, SearchHiddenConfig, SearchNextResult, ReplaceAllResult, } from './modules/searchReplace';
17
17
  export { cellFadeAnimator, markCellChanged } from './animate';
@@ -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,51 @@
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
+ /** Workbook-level named ranges for VARIABLE resolution. */
32
+ definedNames?: Array<{
33
+ name: string;
34
+ sheetId: string;
35
+ range: {
36
+ row: [number, number];
37
+ column: [number, number];
38
+ };
39
+ scope?: 'workbook' | 'sheet';
40
+ localSheetId?: string;
41
+ }>;
42
+ };
43
+ export type SnapshotEvalOutput = {
44
+ execFunctionGlobalData: Record<string, {
45
+ v: unknown;
46
+ f: unknown;
47
+ }>;
48
+ results: SnapshotFormulaResult[];
49
+ };
50
+ /** Worker-safe formula evaluation against plain sheet snapshots (no React/immer). */
51
+ 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;
@@ -28,6 +31,11 @@ export declare class FormulaCache {
28
31
  /** True after arrow/Shift+arrow moved `func_selectedrange` without updating yellow selection. */
29
32
  formulaKeyboardRefSync?: boolean;
30
33
  formulaEditorOwner?: 'cell' | 'fx' | null;
34
+ /**
35
+ * Set when switching sheets while a formula edit stays open so InputBox/Fx
36
+ * can restore focus/caret for continued keyboard ref picking.
37
+ */
38
+ refocusFormulaEditorAfterSheetSwitch?: boolean;
31
39
  functionRangeIndex?: number[];
32
40
  functionRangeGlobalOffset?: number | null;
33
41
  functionlistMap: any;
@@ -37,6 +45,12 @@ export declare class FormulaCache {
37
45
  depsByCell: Map<string, Set<string>>;
38
46
  /** Reverse dependency graph: referenced cell -> dependent formula cells. */
39
47
  revDepsByCell: Map<string, Set<string>>;
48
+ /**
49
+ * Formulas that referenced a range too large to fully expand into `revDepsByCell`.
50
+ * These must be included on incremental recalcs because a single-cell edit may
51
+ * affect them even when no precise reverse edge exists.
52
+ */
53
+ formulasWithWideRangeDeps: Set<string>;
40
54
  /**
41
55
  * Dependency collection state for the currently-parsed formula, set by `execfunction`.
42
56
  * When null, dependency recording is disabled.
@@ -44,8 +58,20 @@ export declare class FormulaCache {
44
58
  activeDepCollection: null | {
45
59
  originKey: string;
46
60
  deps: Set<string>;
61
+ hasWideRangeDep: boolean;
62
+ };
63
+ /** Step 2: per execFunctionGroup pass cache for materialized range reads. */
64
+ rangeValuePassCache?: Map<string, RangePassCacheEntry>;
65
+ rangeValuePassCacheStats?: {
66
+ hits: number;
67
+ misses: number;
47
68
  };
48
69
  constructor();
70
+ materializeFullRangeFragment(context: Context, sheetId: string, flowdata: CellMatrix | null | undefined, startRow: number, endRow: number, startCol: number, endCol: number): {
71
+ fragment: any[][];
72
+ cryptoDenomination: string;
73
+ cryptoDecimal: number;
74
+ };
49
75
  tryGetCellAsNumber(cell: Cell): string | number | boolean | undefined;
50
76
  }
51
77
  export declare function iscelldata(txt: string): boolean;
@@ -55,6 +81,15 @@ export declare function delFunctionGroup(ctx: Context, r: number, c: number, id?
55
81
  export declare function insertUpdateFunctionGroup(ctx: Context, r: number, c: number, id?: string, calcChainSet?: Set<string>): void;
56
82
  export declare function execfunction(ctx: Context, txt: string, r: number, c: number, id?: string, calcChainSet?: Set<string>, isrefresh?: boolean, notInsertFunc?: boolean): any[];
57
83
  export declare function groupValuesRefresh(ctx: Context): void;
84
+ /** Apply worker chunk output onto the live context (main thread only). */
85
+ export declare function applyWorkerFormulaChunkResults(ctx: Context, output: SnapshotEvalOutput, impactedByCircular: Set<string>, cycleNodes: Set<string>, calcChainKeys?: string[], data?: CellMatrix | null): void;
86
+ /** Run up to `chunkSize` formulas from an async job. Returns true when job is complete. */
87
+ export declare function runFormulaEvalChunk(ctx: Context, job: FormulaAsyncEvalJob, chunkSize?: number): boolean;
88
+ /**
89
+ * Re-evaluate formula cells that reference the given defined names
90
+ * (e.g. after a named range was edited, shifted, or deleted).
91
+ */
92
+ export declare function refreshFormulasUsingDefinedNames(ctx: Context, names: string[]): void;
58
93
  export declare function execFunctionGroup(ctx: Context, origin_r: number, origin_c: number, value: any, id?: string, data?: any, isForce?: boolean): void;
59
94
  /**
60
95
  * Before the first `moveHighlightCell/Range(..., "rangeOfFormula")` while editing
@@ -77,6 +112,23 @@ export declare function getLastFormulaRangeIndex($editor: HTMLDivElement): numbe
77
112
  export declare function getFormulaRangeIndexAtCaret($editor: HTMLDivElement): number | null;
78
113
  export declare function setFormulaEditorOwner(ctx: Context, owner: 'cell' | 'fx' | null): void;
79
114
  export declare function getFormulaEditorOwner(ctx: Context): 'cell' | 'fx' | null;
115
+ /**
116
+ * Record the sheet where the formula edit started so cross-sheet picks can emit
117
+ * `SheetName!A1` via `rangeSetValue` / `getRangetxt`.
118
+ */
119
+ export declare function ensureFormulaRangeToSheet(ctx: Context): void;
120
+ /** True while an in-cell / fx formula edit should survive sheet-tab switches. */
121
+ export declare function shouldPreserveFormulaEditOnSheetSwitch(ctx: Context): boolean;
122
+ /**
123
+ * Activate another sheet from tab click or Alt/Option+Arrow navigation.
124
+ * Returns whether the sheet changed and whether formula edit was preserved.
125
+ */
126
+ export declare function activateSheetForNavigation(ctx: Context, targetSheetId: string): 'preserved-formula' | 'cancel-edit' | false;
127
+ /**
128
+ * Switch back to the formula's origin sheet (and restore its scroll/selection)
129
+ * before commit or cancel. Returns true when a switch happened.
130
+ */
131
+ export declare function returnToFormulaOriginSheet(ctx: Context): boolean;
80
132
  /**
81
133
  * True when the formula text looks like a truncated A1-style range: LHS has a row
82
134
  * number but RHS after ":" is only column letters (e.g. =A1:A after deleting the
@@ -4,7 +4,9 @@ export { default as clipboard } from './clipboard';
4
4
  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
- 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';
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, ensureFormulaRangeToSheet, shouldPreserveFormulaEditOnSheetSwitch, activateSheetForNavigation, returnToFormulaOriginSheet, } 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,7 @@ 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, refreshFormulasUsingDefinedNames, runFormulaEvalChunk, applyWorkerFormulaChunkResults, insertUpdateFunctionGroup, functionCopy, } from './formula';
44
46
  export { checkCF, getComputeMap } from './ConditionFormat';
47
+ export { isValidDefinedNameIdentifier, getDefinedNameDisplayRange, findDefinedNameForSelection, findDefinedNameByName, resolveDefinedNameForFormula, addDefinedName, updateDefinedName, deleteDefinedName, selectDefinedName, openNamedRangesSidebar, scheduleDefinedNamesSync, shiftDefinedNamesOnInsert, shiftDefinedNamesOnDelete, removeDefinedNamesForSheet, } from './namedRanges';
45
48
  export { getdatabyselection, getQKBorder } from './cell';
@@ -0,0 +1,53 @@
1
+ import { Context } from '../context';
2
+ import { DefinedName, SingleRange } from '../types';
3
+
4
+ /** Excel/Google: names must start with letter/underscore; no spaces; not a cell ref. */
5
+ export declare function isValidDefinedNameIdentifier(name: string): boolean;
6
+ export declare function getDefinedNameDisplayRange(ctx: Context, dn: DefinedName): string;
7
+ export declare function findDefinedNameForSelection(ctx: Context): DefinedName | null;
8
+ export declare function findDefinedNameByName(ctx: Context, name: string, excludeId?: string): DefinedName | null;
9
+ /**
10
+ * Resolve a formula VARIABLE (e.g. `=SUM(Custom)`) to a defined name.
11
+ * Prefers sheet-scoped names matching `formulaSheetId`, then workbook-scoped.
12
+ */
13
+ export declare function resolveDefinedNameForFormula(definedNames: DefinedName[] | undefined | null, name: string, formulaSheetId?: string): DefinedName | null;
14
+ export declare function addDefinedName(ctx: Context, input: {
15
+ name: string;
16
+ sheetId: string;
17
+ range: SingleRange;
18
+ scope?: DefinedName['scope'];
19
+ localSheetId?: string;
20
+ }): {
21
+ ok: true;
22
+ namedRange: DefinedName;
23
+ } | {
24
+ ok: false;
25
+ error: string;
26
+ };
27
+ export declare function updateDefinedName(ctx: Context, id: string, patch: {
28
+ name?: string;
29
+ sheetId?: string;
30
+ range?: SingleRange;
31
+ }): {
32
+ ok: true;
33
+ namedRange: DefinedName;
34
+ } | {
35
+ ok: false;
36
+ error: string;
37
+ };
38
+ export declare function deleteDefinedName(ctx: Context, id: string): boolean;
39
+ /** Jump to a named range (switch sheet if needed) and select its cells. */
40
+ export declare function selectDefinedName(ctx: Context, id: string): boolean;
41
+ export declare function openNamedRangesSidebar(): void;
42
+ /**
43
+ * Defer Yjs sync until after Immer applies the draft (same pattern as
44
+ * sheet-metadata-hooks). Capture the hook fn — not `ctx.hooks` — so the
45
+ * draft proxy is not read after revoke.
46
+ */
47
+ export declare function scheduleDefinedNamesSync(ctx: Context): void;
48
+ /** Shift named ranges on the given sheet after row/col insert. Returns affected names. */
49
+ export declare function shiftDefinedNamesOnInsert(ctx: Context, sheetId: string, type: 'row' | 'column', index: number, count: number, direction: 'lefttop' | 'rightbottom'): string[];
50
+ /** Shift/remove named ranges on the given sheet after row/col delete. */
51
+ export declare function shiftDefinedNamesOnDelete(ctx: Context, sheetId: string, type: 'row' | 'column', start: number, end: number): string[];
52
+ /** Drop named ranges that pointed at a deleted sheet. */
53
+ export declare function removeDefinedNamesForSheet(ctx: Context, deletedSheetId: string): string[];
@@ -3,5 +3,9 @@ import { Context } from '../context';
3
3
  /**
4
4
  * Defer sheet-level metadata hooks until after React applies Immer updates, so
5
5
  * getSheet() / Yjs diff see dataVerification, CF rules, and hyperlinks from paste/cut.
6
+ *
7
+ * Capture the hook fns themselves (not `ctx.hooks`): paste runs inside produce,
8
+ * and reading a draft `hooks` proxy after it is revoked throws
9
+ * "Cannot perform 'get' on a proxy that has been revoked".
6
10
  */
7
11
  export declare function scheduleSheetMetadataSyncHooks(ctx: Context): void;
@@ -1,7 +1,23 @@
1
1
  import { Context } from '../context';
2
2
  import { Settings } from '../settings';
3
- import { CellMatrix, Sheet } from '../types';
3
+ import { CellMatrix, Sheet, SheetConfig } from '../types';
4
+ import { CellFormatRange } from '../utils/range-format';
4
5
 
6
+ /**
7
+ * Persist active ctx.config onto ONE sheet file only.
8
+ * If Immer wrote keys (e.g. cellFormatRanges) on file.config but not ctx.config,
9
+ * keep those instead of wiping them with a blind replace.
10
+ * Never touches other sheets.
11
+ */
12
+ export declare function assignActiveConfigToSheetFile(file: Sheet, activeConfig: SheetConfig | undefined): void;
13
+ /**
14
+ * Promote format-only cells in a rectangle into cellFormatRanges.
15
+ * Scans only [r1..r2]×[c1..c2]. Returns new ranges if anything changed.
16
+ *
17
+ * Writes through luckysheetfile[i].config (same as toolbar) so Immer undo
18
+ * history tracks the change and peers get the reverse via afterConfigChanges.
19
+ */
20
+ export declare function syncFormatOnlyRectIntoRanges(ctx: Context, cfg: SheetConfig | undefined, data: CellMatrix | null | undefined, r1: number, r2: number, c1: number, c2: number): CellFormatRange[] | null;
5
21
  export declare function storeSheetParamALL(ctx: Context): void;
6
22
  export declare function changeSheet(ctx: Context, id: string, isPivotInitial?: boolean, isNewSheet?: boolean, isCopySheet?: boolean): void;
7
23
  export declare function addSheet(ctx: Context, settings?: Required<Settings>, newSheetID?: string | undefined, // if action is from websocket, there will be a new sheetID
@@ -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;
@@ -22,8 +22,10 @@ export type Hooks = {
22
22
  filterChange?: () => void;
23
23
  cellDataChange?: () => void;
24
24
  hyperlinkChange?: () => void;
25
+ /** Workbook-level named ranges (definedNames) changed — sync to Yjs. */
26
+ definedNamesChange?: () => void;
25
27
  updateCellYdoc?: (changes: SheetChangePath[]) => void;
26
- updateAllCell?: (sheetId: string) => void;
28
+ updateAllCell?: (sheetId: string, caller?: string) => void;
27
29
  beforeUpdateCell?: (r: number, c: number, value: any) => boolean;
28
30
  /** Clears RTC remote-apply lock so local edits can run data-block formulas. */
29
31
  onLocalCellEdit?: () => void;