@devmm/puredocs-excel-formula 1.0.4 → 1.0.6

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.
package/dist/index.d.cts CHANGED
@@ -477,6 +477,15 @@ declare class FormulaParser {
477
477
  * Parses a formula string to an AST, with LRU caching.
478
478
  */
479
479
  declare function parseFormula(formula: string): FormulaNode;
480
+ /**
481
+ * Parses a formula without consulting or populating the shared AST cache.
482
+ *
483
+ * For callers that keep the AST themselves — the recalculation engine holds one
484
+ * per registered formula — the cache is pure overhead: it would evict entries
485
+ * that are still live elsewhere once a workbook has more formulas than its
486
+ * capacity, paying eviction cost and retaining memory for no hits.
487
+ */
488
+ declare function parseFormulaUncached(formula: string): FormulaNode;
480
489
  /**
481
490
  * Evaluates a formula string against a worksheet.
482
491
  * Mirrors FormulaEvaluator.Evaluate() in C#.
@@ -486,6 +495,17 @@ declare function evaluateFormula(formula: string, sheet: WorksheetLike, options?
486
495
  formulaRow?: number;
487
496
  formulaCol?: number;
488
497
  }): FormulaValue;
498
+ /**
499
+ * Evaluates an already-parsed formula. Callers that hold onto an AST — such as
500
+ * the recalculation engine, which parses each formula once when it is
501
+ * registered — should use this so repeated evaluation never depends on the
502
+ * global AST cache still holding the entry.
503
+ */
504
+ declare function evaluateAst(ast: FormulaNode, sheet: WorksheetLike, options?: {
505
+ workbook?: WorkbookLike;
506
+ formulaRow?: number;
507
+ formulaCol?: number;
508
+ }): FormulaValue;
489
509
  declare function clearAstCache(): void;
490
510
  declare function getAstCacheStats(): {
491
511
  size: number;
@@ -655,6 +675,30 @@ declare class RecalcEngine {
655
675
  recalcAll(): RecalcResult[];
656
676
  /** The precedents recorded for a formula cell (mainly for tests/inspection). */
657
677
  getPrecedents(sheet: string, ref: string): readonly PrecedentRef[];
678
+ /**
679
+ * Tells the engine rows were inserted on a sheet. Call AFTER the
680
+ * corresponding `Worksheet.insertRows` (the model must already reflect the
681
+ * edit). The dependency graph is translated in place — registrations,
682
+ * formula text and spill bookkeeping all move — and only volatile formulas
683
+ * are recomputed, because a pure translation changes no values.
684
+ *
685
+ * @example
686
+ * ws.insertRows(3, 2);
687
+ * engine.onRowsInserted('S1', 3, 2);
688
+ */
689
+ onRowsInserted(sheet: string, at: number, count?: number): RecalcResult[];
690
+ /**
691
+ * Tells the engine rows were deleted on a sheet. Call AFTER the
692
+ * corresponding `Worksheet.deleteRows`. Registrations inside the deleted
693
+ * band are dropped; the rest of the graph is translated, and only formulas
694
+ * whose precedents touched the deleted band (plus their dependents and
695
+ * volatiles) are recomputed.
696
+ */
697
+ onRowsDeleted(sheet: string, at: number, count?: number): RecalcResult[];
698
+ /** Column counterpart to {@link onRowsInserted}. */
699
+ onColumnsInserted(sheet: string, at: number, count?: number): RecalcResult[];
700
+ /** Column counterpart to {@link onRowsDeleted}. */
701
+ onColumnsDeleted(sheet: string, at: number, count?: number): RecalcResult[];
658
702
  }
659
703
 
660
704
  declare function registerMath(r: FunctionRegistry): void;
@@ -679,4 +723,4 @@ declare function registerAggregate(r: FunctionRegistry): void;
679
723
 
680
724
  declare function registerArray(r: FunctionRegistry): void;
681
725
 
682
- export { ArrayValue, BinaryOpNode, BinaryOperator, BlankNode, BooleanNode, CallNode, CellReferenceNode, ErrorNode, type ExtractResult, FormulaContext, FormulaError, FormulaException, type FormulaFunction, FormulaHelper, FormulaLexer, FormulaNode, FormulaParser, FormulaValue, type FormulaValueKind, FunctionCallNode, type FunctionDef, FunctionRegistry, ImplicitIntersectionNode, type LambdaLike, LruCache, type NameResolver, NamedRangeNode, NumberNode, type PrecedentRef, RangeReferenceNode, RecalcEngine, type RecalcModel, type RecalcResult, SheetCellReferenceNode, SheetRangeReferenceNode, SpillReferenceNode, StringNode, type Token, TokenType, UnaryOpNode, UnaryOperator, type WorkbookLike, type WorksheetLike, clearAstCache, createWorkbookRecalcModel, evaluateFormula, extractReferences, getAstCacheStats, parseFormula, refContains, registerAggregate, registerArray, registerDate, registerFinance, registerInfo, registerLogical, registerLookup, registerMath, registerMeta, registerStatistical, registerText, setAstCacheCapacity };
726
+ export { ArrayValue, BinaryOpNode, BinaryOperator, BlankNode, BooleanNode, CallNode, CellReferenceNode, ErrorNode, type ExtractResult, FormulaContext, FormulaError, FormulaException, type FormulaFunction, FormulaHelper, FormulaLexer, FormulaNode, FormulaParser, FormulaValue, type FormulaValueKind, FunctionCallNode, type FunctionDef, FunctionRegistry, ImplicitIntersectionNode, type LambdaLike, LruCache, type NameResolver, NamedRangeNode, NumberNode, type PrecedentRef, RangeReferenceNode, RecalcEngine, type RecalcModel, type RecalcResult, SheetCellReferenceNode, SheetRangeReferenceNode, SpillReferenceNode, StringNode, type Token, TokenType, UnaryOpNode, UnaryOperator, type WorkbookLike, type WorksheetLike, clearAstCache, createWorkbookRecalcModel, evaluateAst, evaluateFormula, extractReferences, getAstCacheStats, parseFormula, parseFormulaUncached, refContains, registerAggregate, registerArray, registerDate, registerFinance, registerInfo, registerLogical, registerLookup, registerMath, registerMeta, registerStatistical, registerText, setAstCacheCapacity };
package/dist/index.d.ts CHANGED
@@ -477,6 +477,15 @@ declare class FormulaParser {
477
477
  * Parses a formula string to an AST, with LRU caching.
478
478
  */
479
479
  declare function parseFormula(formula: string): FormulaNode;
480
+ /**
481
+ * Parses a formula without consulting or populating the shared AST cache.
482
+ *
483
+ * For callers that keep the AST themselves — the recalculation engine holds one
484
+ * per registered formula — the cache is pure overhead: it would evict entries
485
+ * that are still live elsewhere once a workbook has more formulas than its
486
+ * capacity, paying eviction cost and retaining memory for no hits.
487
+ */
488
+ declare function parseFormulaUncached(formula: string): FormulaNode;
480
489
  /**
481
490
  * Evaluates a formula string against a worksheet.
482
491
  * Mirrors FormulaEvaluator.Evaluate() in C#.
@@ -486,6 +495,17 @@ declare function evaluateFormula(formula: string, sheet: WorksheetLike, options?
486
495
  formulaRow?: number;
487
496
  formulaCol?: number;
488
497
  }): FormulaValue;
498
+ /**
499
+ * Evaluates an already-parsed formula. Callers that hold onto an AST — such as
500
+ * the recalculation engine, which parses each formula once when it is
501
+ * registered — should use this so repeated evaluation never depends on the
502
+ * global AST cache still holding the entry.
503
+ */
504
+ declare function evaluateAst(ast: FormulaNode, sheet: WorksheetLike, options?: {
505
+ workbook?: WorkbookLike;
506
+ formulaRow?: number;
507
+ formulaCol?: number;
508
+ }): FormulaValue;
489
509
  declare function clearAstCache(): void;
490
510
  declare function getAstCacheStats(): {
491
511
  size: number;
@@ -655,6 +675,30 @@ declare class RecalcEngine {
655
675
  recalcAll(): RecalcResult[];
656
676
  /** The precedents recorded for a formula cell (mainly for tests/inspection). */
657
677
  getPrecedents(sheet: string, ref: string): readonly PrecedentRef[];
678
+ /**
679
+ * Tells the engine rows were inserted on a sheet. Call AFTER the
680
+ * corresponding `Worksheet.insertRows` (the model must already reflect the
681
+ * edit). The dependency graph is translated in place — registrations,
682
+ * formula text and spill bookkeeping all move — and only volatile formulas
683
+ * are recomputed, because a pure translation changes no values.
684
+ *
685
+ * @example
686
+ * ws.insertRows(3, 2);
687
+ * engine.onRowsInserted('S1', 3, 2);
688
+ */
689
+ onRowsInserted(sheet: string, at: number, count?: number): RecalcResult[];
690
+ /**
691
+ * Tells the engine rows were deleted on a sheet. Call AFTER the
692
+ * corresponding `Worksheet.deleteRows`. Registrations inside the deleted
693
+ * band are dropped; the rest of the graph is translated, and only formulas
694
+ * whose precedents touched the deleted band (plus their dependents and
695
+ * volatiles) are recomputed.
696
+ */
697
+ onRowsDeleted(sheet: string, at: number, count?: number): RecalcResult[];
698
+ /** Column counterpart to {@link onRowsInserted}. */
699
+ onColumnsInserted(sheet: string, at: number, count?: number): RecalcResult[];
700
+ /** Column counterpart to {@link onRowsDeleted}. */
701
+ onColumnsDeleted(sheet: string, at: number, count?: number): RecalcResult[];
658
702
  }
659
703
 
660
704
  declare function registerMath(r: FunctionRegistry): void;
@@ -679,4 +723,4 @@ declare function registerAggregate(r: FunctionRegistry): void;
679
723
 
680
724
  declare function registerArray(r: FunctionRegistry): void;
681
725
 
682
- export { ArrayValue, BinaryOpNode, BinaryOperator, BlankNode, BooleanNode, CallNode, CellReferenceNode, ErrorNode, type ExtractResult, FormulaContext, FormulaError, FormulaException, type FormulaFunction, FormulaHelper, FormulaLexer, FormulaNode, FormulaParser, FormulaValue, type FormulaValueKind, FunctionCallNode, type FunctionDef, FunctionRegistry, ImplicitIntersectionNode, type LambdaLike, LruCache, type NameResolver, NamedRangeNode, NumberNode, type PrecedentRef, RangeReferenceNode, RecalcEngine, type RecalcModel, type RecalcResult, SheetCellReferenceNode, SheetRangeReferenceNode, SpillReferenceNode, StringNode, type Token, TokenType, UnaryOpNode, UnaryOperator, type WorkbookLike, type WorksheetLike, clearAstCache, createWorkbookRecalcModel, evaluateFormula, extractReferences, getAstCacheStats, parseFormula, refContains, registerAggregate, registerArray, registerDate, registerFinance, registerInfo, registerLogical, registerLookup, registerMath, registerMeta, registerStatistical, registerText, setAstCacheCapacity };
726
+ export { ArrayValue, BinaryOpNode, BinaryOperator, BlankNode, BooleanNode, CallNode, CellReferenceNode, ErrorNode, type ExtractResult, FormulaContext, FormulaError, FormulaException, type FormulaFunction, FormulaHelper, FormulaLexer, FormulaNode, FormulaParser, FormulaValue, type FormulaValueKind, FunctionCallNode, type FunctionDef, FunctionRegistry, ImplicitIntersectionNode, type LambdaLike, LruCache, type NameResolver, NamedRangeNode, NumberNode, type PrecedentRef, RangeReferenceNode, RecalcEngine, type RecalcModel, type RecalcResult, SheetCellReferenceNode, SheetRangeReferenceNode, SpillReferenceNode, StringNode, type Token, TokenType, UnaryOpNode, UnaryOperator, type WorkbookLike, type WorksheetLike, clearAstCache, createWorkbookRecalcModel, evaluateAst, evaluateFormula, extractReferences, getAstCacheStats, parseFormula, parseFormulaUncached, refContains, registerAggregate, registerArray, registerDate, registerFinance, registerInfo, registerLogical, registerLookup, registerMath, registerMeta, registerStatistical, registerText, setAstCacheCapacity };