@affino/datagrid-formula-engine 0.1.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.
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/dist/analysis/index.d.ts +2 -0
- package/dist/analysis/index.d.ts.map +1 -0
- package/dist/analysis/index.js +1 -0
- package/dist/analysis/types.d.ts +44 -0
- package/dist/analysis/types.d.ts.map +1 -0
- package/dist/analysis/types.js +1 -0
- package/dist/contracts.d.ts +177 -0
- package/dist/contracts.d.ts.map +1 -0
- package/dist/contracts.js +140 -0
- package/dist/coreTypes.d.ts +2 -0
- package/dist/coreTypes.d.ts.map +1 -0
- package/dist/coreTypes.js +1 -0
- package/dist/dependency/index.d.ts +2 -0
- package/dist/dependency/index.d.ts.map +1 -0
- package/dist/dependency/index.js +1 -0
- package/dist/evaluators/columnar.d.ts +6 -0
- package/dist/evaluators/columnar.d.ts.map +1 -0
- package/dist/evaluators/columnar.js +39 -0
- package/dist/evaluators/index.d.ts +5 -0
- package/dist/evaluators/index.d.ts.map +1 -0
- package/dist/evaluators/index.js +4 -0
- package/dist/evaluators/interpreter.d.ts +6 -0
- package/dist/evaluators/interpreter.d.ts.map +1 -0
- package/dist/evaluators/interpreter.js +156 -0
- package/dist/evaluators/jit.d.ts +7 -0
- package/dist/evaluators/jit.d.ts.map +1 -0
- package/dist/evaluators/jit.js +158 -0
- package/dist/evaluators/shared.d.ts +36 -0
- package/dist/evaluators/shared.d.ts.map +1 -0
- package/dist/evaluators/shared.js +242 -0
- package/dist/evaluators/vector.d.ts +6 -0
- package/dist/evaluators/vector.d.ts.map +1 -0
- package/dist/evaluators/vector.js +228 -0
- package/dist/formulaEngine/compile.d.ts +2 -0
- package/dist/formulaEngine/compile.d.ts.map +1 -0
- package/dist/formulaEngine/compile.js +1 -0
- package/dist/formulaEngine/core.d.ts +2 -0
- package/dist/formulaEngine/core.d.ts.map +1 -0
- package/dist/formulaEngine/core.js +1 -0
- package/dist/formulaEngine/evaluators.d.ts +2 -0
- package/dist/formulaEngine/evaluators.d.ts.map +1 -0
- package/dist/formulaEngine/evaluators.js +1 -0
- package/dist/formulaEngine/index.d.ts +5 -0
- package/dist/formulaEngine/index.d.ts.map +1 -0
- package/dist/formulaEngine/index.js +2 -0
- package/dist/formulaExecutionPlan.d.ts +2 -0
- package/dist/formulaExecutionPlan.d.ts.map +1 -0
- package/dist/formulaExecutionPlan.js +1 -0
- package/dist/graph/executionPlan.d.ts +66 -0
- package/dist/graph/executionPlan.d.ts.map +1 -0
- package/dist/graph/executionPlan.js +534 -0
- package/dist/graph/index.d.ts +2 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +3 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/runtime/compile.d.ts +7 -0
- package/dist/runtime/compile.d.ts.map +1 -0
- package/dist/runtime/compile.js +453 -0
- package/dist/runtime/evaluators.d.ts +5 -0
- package/dist/runtime/evaluators.d.ts.map +1 -0
- package/dist/runtime/evaluators.js +6 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +2 -0
- package/dist/runtime/types.d.ts +63 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +1 -0
- package/dist/syntax/analysis.d.ts +14 -0
- package/dist/syntax/analysis.d.ts.map +1 -0
- package/dist/syntax/analysis.js +159 -0
- package/dist/syntax/ast.d.ts +18 -0
- package/dist/syntax/ast.d.ts.map +1 -0
- package/dist/syntax/ast.js +54 -0
- package/dist/syntax/core.d.ts +4 -0
- package/dist/syntax/core.d.ts.map +1 -0
- package/dist/syntax/core.js +1 -0
- package/dist/syntax/functionGroups/advancedFunctions.d.ts +2 -0
- package/dist/syntax/functionGroups/advancedFunctions.d.ts.map +1 -0
- package/dist/syntax/functionGroups/advancedFunctions.js +252 -0
- package/dist/syntax/functionGroups/dateFunctions.d.ts +2 -0
- package/dist/syntax/functionGroups/dateFunctions.d.ts.map +1 -0
- package/dist/syntax/functionGroups/dateFunctions.js +144 -0
- package/dist/syntax/functionGroups/logicFunctions.d.ts +2 -0
- package/dist/syntax/functionGroups/logicFunctions.d.ts.map +1 -0
- package/dist/syntax/functionGroups/logicFunctions.js +140 -0
- package/dist/syntax/functionGroups/numericFunctions.d.ts +2 -0
- package/dist/syntax/functionGroups/numericFunctions.d.ts.map +1 -0
- package/dist/syntax/functionGroups/numericFunctions.js +268 -0
- package/dist/syntax/functionGroups/textFunctions.d.ts +2 -0
- package/dist/syntax/functionGroups/textFunctions.d.ts.map +1 -0
- package/dist/syntax/functionGroups/textFunctions.js +118 -0
- package/dist/syntax/functionHelpers.d.ts +45 -0
- package/dist/syntax/functionHelpers.d.ts.map +1 -0
- package/dist/syntax/functionHelpers.js +553 -0
- package/dist/syntax/functions.d.ts +9 -0
- package/dist/syntax/functions.d.ts.map +1 -0
- package/dist/syntax/functions.js +139 -0
- package/dist/syntax/index.d.ts +10 -0
- package/dist/syntax/index.d.ts.map +1 -0
- package/dist/syntax/index.js +7 -0
- package/dist/syntax/legacy.d.ts +29 -0
- package/dist/syntax/legacy.d.ts.map +1 -0
- package/dist/syntax/legacy.js +188 -0
- package/dist/syntax/optimizer.d.ts +6 -0
- package/dist/syntax/optimizer.d.ts.map +1 -0
- package/dist/syntax/optimizer.js +362 -0
- package/dist/syntax/parser.d.ts +7 -0
- package/dist/syntax/parser.d.ts.map +1 -0
- package/dist/syntax/parser.js +239 -0
- package/dist/syntax/tokenizer.d.ts +14 -0
- package/dist/syntax/tokenizer.d.ts.map +1 -0
- package/dist/syntax/tokenizer.js +852 -0
- package/dist/syntax/types.d.ts +120 -0
- package/dist/syntax/types.d.ts.map +1 -0
- package/dist/syntax/types.js +1 -0
- package/dist/syntax/values.d.ts +25 -0
- package/dist/syntax/values.d.ts.map +1 -0
- package/dist/syntax/values.js +270 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +42 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 affino
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# `@affino/datagrid-formula-engine`
|
|
2
|
+
|
|
3
|
+
Community formula engine package for Affino DataGrid.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
This package establishes a dedicated formula-engine boundary without forcing a risky implementation move out of `@affino/datagrid-core` in one step.
|
|
8
|
+
|
|
9
|
+
Current state:
|
|
10
|
+
|
|
11
|
+
- community-safe formula parsing / analysis / compile APIs live here
|
|
12
|
+
- graph / execution-plan APIs live here
|
|
13
|
+
- low-level row-model integration still lives in `@affino/datagrid-core`
|
|
14
|
+
|
|
15
|
+
## Community surface
|
|
16
|
+
|
|
17
|
+
The package intentionally exposes the base formula-engine surface:
|
|
18
|
+
|
|
19
|
+
- parse / diagnose / explain
|
|
20
|
+
- compile formula field definitions and artifacts
|
|
21
|
+
- formula value utilities
|
|
22
|
+
- formula graph and execution-plan builders
|
|
23
|
+
- formula-related type contracts
|
|
24
|
+
|
|
25
|
+
## Planned enterprise surface
|
|
26
|
+
|
|
27
|
+
These are reserved as future enterprise candidates and are intentionally not split into public package entrypoints yet:
|
|
28
|
+
|
|
29
|
+
- premium worker-owned formula runtime
|
|
30
|
+
- advanced fused / vector execution tiers
|
|
31
|
+
- formula profiler / diagnostics UI
|
|
32
|
+
- collaboration / snapshot / audit tooling around formula execution
|
|
33
|
+
- premium performance policies and high-scale runtime orchestration
|
|
34
|
+
|
|
35
|
+
## Boundary rule
|
|
36
|
+
|
|
37
|
+
Use `@affino/datagrid-formula-engine` for formula APIs.
|
|
38
|
+
Keep grid row-model orchestration and snapshot integration in `@affino/datagrid-core` until the next extraction phase.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/analysis/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,gCAAgC,EAChC,sCAAsC,EACtC,gCAAgC,EAChC,0BAA0B,EAC1B,4BAA4B,EAC5B,iCAAiC,GAClC,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { DataGridComputedDependencyToken, DataGridFormulaValue } from "../coreTypes.js";
|
|
2
|
+
import type { DataGridFormulaAstNode, DataGridFormulaDiagnostic, DataGridFormulaOperator, DataGridFormulaRowSelector, DataGridFormulaSourceSpan, DataGridFormulaToken } from "../syntax/types.js";
|
|
3
|
+
export interface DataGridFormulaDiagnosticsResult {
|
|
4
|
+
ok: boolean;
|
|
5
|
+
formula: string;
|
|
6
|
+
diagnostics: readonly DataGridFormulaDiagnostic[];
|
|
7
|
+
tokens?: readonly DataGridFormulaToken[];
|
|
8
|
+
ast?: DataGridFormulaAstNode;
|
|
9
|
+
}
|
|
10
|
+
export type DataGridFormulaExplainDependencyDomain = "field" | "computed" | "meta" | "unknown";
|
|
11
|
+
export interface DataGridFormulaExplainDependency {
|
|
12
|
+
identifier: string;
|
|
13
|
+
token: DataGridComputedDependencyToken;
|
|
14
|
+
domain: DataGridFormulaExplainDependencyDomain;
|
|
15
|
+
value: string;
|
|
16
|
+
rowSelector?: DataGridFormulaRowSelector;
|
|
17
|
+
}
|
|
18
|
+
export interface DataGridFormulaExplainNode {
|
|
19
|
+
kind: DataGridFormulaAstNode["kind"];
|
|
20
|
+
label: string;
|
|
21
|
+
span: DataGridFormulaSourceSpan;
|
|
22
|
+
children: readonly DataGridFormulaExplainNode[];
|
|
23
|
+
name?: string;
|
|
24
|
+
sheetReference?: string | null;
|
|
25
|
+
referenceName?: string;
|
|
26
|
+
rangeReferenceName?: string | null;
|
|
27
|
+
rowSelector?: DataGridFormulaRowSelector;
|
|
28
|
+
operator?: DataGridFormulaOperator | "CALL";
|
|
29
|
+
value?: DataGridFormulaValue;
|
|
30
|
+
}
|
|
31
|
+
export interface DataGridFormulaExplainResult {
|
|
32
|
+
formula: string;
|
|
33
|
+
tokens: readonly DataGridFormulaToken[];
|
|
34
|
+
ast: DataGridFormulaAstNode;
|
|
35
|
+
identifiers: readonly string[];
|
|
36
|
+
dependencies: readonly DataGridFormulaExplainDependency[];
|
|
37
|
+
contextKeys: readonly string[];
|
|
38
|
+
tree: DataGridFormulaExplainNode;
|
|
39
|
+
}
|
|
40
|
+
export interface DataGridFormulaFieldExplainResult extends DataGridFormulaExplainResult {
|
|
41
|
+
name: string;
|
|
42
|
+
field: string;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -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GAAG,MAAM,CAAA;IAC3C,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,SAAS,oBAAoB,EAAE,CAAA;IACvC,GAAG,EAAE,sBAAsB,CAAA;IAC3B,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,YAAY,EAAE,SAAS,gCAAgC,EAAE,CAAA;IACzD,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;IAC9B,IAAI,EAAE,0BAA0B,CAAA;CACjC;AAED,MAAM,WAAW,iCAAkC,SAAQ,4BAA4B;IACrF,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { DataGridFormulaExecutionPlanSnapshot, DataGridFormulaGraphSnapshot } from "./graph/index.js";
|
|
2
|
+
export type DataGridRowId = string | number;
|
|
3
|
+
export type DataGridComputedDependencyToken = `field:${string}` | `computed:${string}` | `meta:${string}` | (string & {});
|
|
4
|
+
export type DataGridFormulaReferenceDomain = "field" | "computed" | "meta";
|
|
5
|
+
export type DataGridFormulaReferenceRowDomain = {
|
|
6
|
+
kind: "current";
|
|
7
|
+
} | {
|
|
8
|
+
kind: "absolute";
|
|
9
|
+
rowIndex: number;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "absolute-window";
|
|
12
|
+
startRowIndex: number;
|
|
13
|
+
endRowIndex: number;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "relative";
|
|
16
|
+
offset: number;
|
|
17
|
+
} | {
|
|
18
|
+
kind: "window";
|
|
19
|
+
startOffset: number;
|
|
20
|
+
endOffset: number;
|
|
21
|
+
};
|
|
22
|
+
export interface DataGridFormulaReferenceDescriptor {
|
|
23
|
+
domain: DataGridFormulaReferenceDomain;
|
|
24
|
+
name: string;
|
|
25
|
+
rowDomain: DataGridFormulaReferenceRowDomain;
|
|
26
|
+
}
|
|
27
|
+
export declare function serializeDataGridComputedDependencyToken(reference: DataGridFormulaReferenceDescriptor): DataGridComputedDependencyToken;
|
|
28
|
+
export declare function parseDataGridComputedDependencyToken(token: DataGridComputedDependencyToken): DataGridFormulaReferenceDescriptor | null;
|
|
29
|
+
export type DataGridFormulaMetaField = "rowId" | "rowKey" | "sourceIndex" | "originalIndex" | "kind" | "isGroup";
|
|
30
|
+
export declare const DATAGRID_FORMULA_META_FIELDS: readonly ["rowId", "rowKey", "sourceIndex", "originalIndex", "kind", "isGroup"];
|
|
31
|
+
export declare function isDataGridFormulaMetaField(value: unknown): value is DataGridFormulaMetaField;
|
|
32
|
+
export interface DataGridComputedFieldComputeContext<T = unknown> {
|
|
33
|
+
row: T;
|
|
34
|
+
rowId: DataGridRowId;
|
|
35
|
+
sourceIndex: number;
|
|
36
|
+
get: (token: DataGridComputedDependencyToken) => unknown;
|
|
37
|
+
getContextValue?: (key: string) => unknown;
|
|
38
|
+
}
|
|
39
|
+
export interface DataGridComputedFieldDefinition<T = unknown> {
|
|
40
|
+
name: string;
|
|
41
|
+
field?: string;
|
|
42
|
+
deps: readonly DataGridComputedDependencyToken[];
|
|
43
|
+
compute: (context: DataGridComputedFieldComputeContext<T>) => unknown;
|
|
44
|
+
}
|
|
45
|
+
export interface DataGridComputedFieldSnapshot {
|
|
46
|
+
name: string;
|
|
47
|
+
field: string;
|
|
48
|
+
deps: readonly DataGridComputedDependencyToken[];
|
|
49
|
+
}
|
|
50
|
+
export interface DataGridFormulaFieldDefinition {
|
|
51
|
+
name: string;
|
|
52
|
+
field?: string;
|
|
53
|
+
formula: string;
|
|
54
|
+
}
|
|
55
|
+
export interface DataGridFormulaFieldSnapshot {
|
|
56
|
+
name: string;
|
|
57
|
+
field: string;
|
|
58
|
+
formula: string;
|
|
59
|
+
deps: readonly DataGridComputedDependencyToken[];
|
|
60
|
+
contextKeys: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
export interface DataGridFormulaTableRowsSource<Row = unknown> {
|
|
63
|
+
rows: readonly Row[];
|
|
64
|
+
resolveRow?: (row: Row, index: number) => unknown;
|
|
65
|
+
}
|
|
66
|
+
export type DataGridFormulaTableSource = readonly unknown[] | DataGridFormulaTableRowsSource;
|
|
67
|
+
export interface DataGridFormulaContextRecomputeRequest {
|
|
68
|
+
contextKeys: readonly string[];
|
|
69
|
+
rowIds?: readonly DataGridRowId[];
|
|
70
|
+
}
|
|
71
|
+
export type DataGridFormulaCyclePolicy = "error" | "iterative";
|
|
72
|
+
export interface DataGridFormulaIterativeCalculationOptions {
|
|
73
|
+
maxIterations?: number;
|
|
74
|
+
epsilon?: number;
|
|
75
|
+
}
|
|
76
|
+
export type DataGridFormulaRuntimeErrorCode = "DIV_ZERO" | "FUNCTION_UNKNOWN" | "FUNCTION_ARITY" | "EVAL_ERROR";
|
|
77
|
+
export interface DataGridFormulaErrorValue {
|
|
78
|
+
kind: "error";
|
|
79
|
+
code: DataGridFormulaRuntimeErrorCode;
|
|
80
|
+
message: string;
|
|
81
|
+
}
|
|
82
|
+
export type DataGridFormulaScalarValue = number | string | boolean | Date | DataGridFormulaErrorValue | null;
|
|
83
|
+
export type DataGridFormulaArrayValue = readonly DataGridFormulaScalarValue[];
|
|
84
|
+
export type DataGridFormulaValue = DataGridFormulaScalarValue | DataGridFormulaArrayValue;
|
|
85
|
+
export interface DataGridFormulaRuntimeError {
|
|
86
|
+
code: DataGridFormulaRuntimeErrorCode;
|
|
87
|
+
message: string;
|
|
88
|
+
formulaName?: string;
|
|
89
|
+
field?: string;
|
|
90
|
+
formula?: string;
|
|
91
|
+
functionName?: string;
|
|
92
|
+
operator?: string;
|
|
93
|
+
rowId?: DataGridRowId;
|
|
94
|
+
sourceIndex?: number;
|
|
95
|
+
}
|
|
96
|
+
export interface DataGridProjectionFormulaDiagnostics {
|
|
97
|
+
recomputedFields: readonly string[];
|
|
98
|
+
runtimeErrorCount: number;
|
|
99
|
+
runtimeErrors: readonly DataGridFormulaRuntimeError[];
|
|
100
|
+
compileCache?: {
|
|
101
|
+
hits: number;
|
|
102
|
+
misses: number;
|
|
103
|
+
size: number;
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export interface DataGridFormulaDirtyCause {
|
|
107
|
+
kind: "all" | "field" | "computed" | "context";
|
|
108
|
+
value?: string;
|
|
109
|
+
rows: number;
|
|
110
|
+
}
|
|
111
|
+
export interface DataGridFormulaDirtyRowCause {
|
|
112
|
+
kind: "all" | "field" | "computed" | "context";
|
|
113
|
+
value?: string;
|
|
114
|
+
}
|
|
115
|
+
export interface DataGridFormulaRowNodeRecomputeDiagnostics {
|
|
116
|
+
name: string;
|
|
117
|
+
field: string;
|
|
118
|
+
causes: readonly DataGridFormulaDirtyRowCause[];
|
|
119
|
+
}
|
|
120
|
+
export interface DataGridFormulaRowRecomputeDiagnosticsEntry {
|
|
121
|
+
rowId: DataGridRowId;
|
|
122
|
+
sourceIndex: number;
|
|
123
|
+
nodes: readonly DataGridFormulaRowNodeRecomputeDiagnostics[];
|
|
124
|
+
}
|
|
125
|
+
export interface DataGridFormulaRowRecomputeDiagnostics {
|
|
126
|
+
rows: readonly DataGridFormulaRowRecomputeDiagnosticsEntry[];
|
|
127
|
+
}
|
|
128
|
+
export interface DataGridFormulaNodeComputeDiagnostics {
|
|
129
|
+
name: string;
|
|
130
|
+
field: string;
|
|
131
|
+
dirty: boolean;
|
|
132
|
+
touched: boolean;
|
|
133
|
+
runtimeMode?: "row" | "batch" | "columnar-ast" | "columnar-jit" | "columnar-fused" | "columnar-vector";
|
|
134
|
+
evaluations: number;
|
|
135
|
+
dirtyRows: number;
|
|
136
|
+
dirtyCauses: readonly DataGridFormulaDirtyCause[];
|
|
137
|
+
iterative?: boolean;
|
|
138
|
+
converged?: boolean;
|
|
139
|
+
iterationCount?: number;
|
|
140
|
+
cycleGroup?: readonly string[];
|
|
141
|
+
}
|
|
142
|
+
export interface DataGridFormulaComputeStageDiagnostics {
|
|
143
|
+
strategy?: "row" | "column-cache";
|
|
144
|
+
rowsTouched: number;
|
|
145
|
+
changedRows: number;
|
|
146
|
+
fieldsTouched: readonly string[];
|
|
147
|
+
evaluations: number;
|
|
148
|
+
skippedByObjectIs: number;
|
|
149
|
+
dirtyRows: number;
|
|
150
|
+
dirtyNodes: readonly string[];
|
|
151
|
+
nodes?: readonly DataGridFormulaNodeComputeDiagnostics[];
|
|
152
|
+
}
|
|
153
|
+
export interface DataGridFormulaRuntimeIntegration<T = unknown> {
|
|
154
|
+
registerComputedField?(definition: DataGridComputedFieldDefinition<T>): void;
|
|
155
|
+
getComputedFields?(): readonly DataGridComputedFieldSnapshot[];
|
|
156
|
+
recomputeComputedFields?(rowIds?: readonly DataGridRowId[]): number;
|
|
157
|
+
registerFormulaField?(definition: DataGridFormulaFieldDefinition): void;
|
|
158
|
+
getFormulaFields?(): readonly DataGridFormulaFieldSnapshot[];
|
|
159
|
+
recomputeFormulaContext?(request: DataGridFormulaContextRecomputeRequest): number;
|
|
160
|
+
setFormulaTable?(name: string, rows: readonly unknown[]): void;
|
|
161
|
+
removeFormulaTable?(name: string): boolean;
|
|
162
|
+
getFormulaTableNames?(): readonly string[];
|
|
163
|
+
registerFormulaFunction?(name: string, definition: {
|
|
164
|
+
arity?: number | {
|
|
165
|
+
min: number;
|
|
166
|
+
max?: number;
|
|
167
|
+
};
|
|
168
|
+
compute: (args: readonly DataGridFormulaValue[], context?: DataGridComputedFieldComputeContext<T>) => unknown;
|
|
169
|
+
} | ((args: readonly DataGridFormulaValue[], context?: DataGridComputedFieldComputeContext<T>) => unknown)): void;
|
|
170
|
+
unregisterFormulaFunction?(name: string): boolean;
|
|
171
|
+
getFormulaFunctionNames?(): readonly string[];
|
|
172
|
+
getFormulaExecutionPlan?(): DataGridFormulaExecutionPlanSnapshot | null;
|
|
173
|
+
getFormulaGraph?(): DataGridFormulaGraphSnapshot | null;
|
|
174
|
+
getFormulaComputeStageDiagnostics?(): DataGridFormulaComputeStageDiagnostics | null;
|
|
175
|
+
getFormulaRowRecomputeDiagnostics?(): DataGridFormulaRowRecomputeDiagnostics | null;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oCAAoC,EACpC,4BAA4B,EAC7B,MAAM,kBAAkB,CAAA;AAEzB,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,CAAA;AAE3C,MAAM,MAAM,+BAA+B,GACvC,SAAS,MAAM,EAAE,GACjB,YAAY,MAAM,EAAE,GACpB,QAAQ,MAAM,EAAE,GAChB,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAEjB,MAAM,MAAM,8BAA8B,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAA;AAE1E,MAAM,MAAM,iCAAiC,GACzC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GACvE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9D,MAAM,WAAW,kCAAkC;IACjD,MAAM,EAAE,8BAA8B,CAAA;IACtC,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,iCAAiC,CAAA;CAC7C;AAuGD,wBAAgB,wCAAwC,CACtD,SAAS,EAAE,kCAAkC,GAC5C,+BAA+B,CAQjC;AAED,wBAAgB,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SAAS,OAAO,EAAE,GAAG,IAAI,CAAA;IAC9D,kBAAkB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAC1C,oBAAoB,CAAC,IAAI,SAAS,MAAM,EAAE,CAAA;IAC1C,uBAAuB,CAAC,CACtB,IAAI,EAAE,MAAM,EACZ,UAAU,EACN;QACA,KAAK,CAAC,EAAE,MAAM,GAAG;YAAE,GAAG,EAAE,MAAM,CAAC;YAAC,GAAG,CAAC,EAAE,MAAM,CAAA;SAAE,CAAA;QAC9C,OAAO,EAAE,CAAC,IAAI,EAAE,SAAS,oBAAoB,EAAE,EAAE,OAAO,CAAC,EAAE,mCAAmC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAA;KAC9G,GACC,CAAC,CAAC,IAAI,EAAE,SAAS,oBAAoB,EAAE,EAAE,OAAO,CAAC,EAAE,mCAAmC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,GACzG,IAAI,CAAA;IACP,yBAAyB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IACjD,uBAAuB,CAAC,IAAI,SAAS,MAAM,EAAE,CAAA;IAC7C,uBAAuB,CAAC,IAAI,oCAAoC,GAAG,IAAI,CAAA;IACvE,eAAe,CAAC,IAAI,4BAA4B,GAAG,IAAI,CAAA;IACvD,iCAAiC,CAAC,IAAI,sCAAsC,GAAG,IAAI,CAAA;IACnF,iCAAiC,CAAC,IAAI,sCAAsC,GAAG,IAAI,CAAA;CACpF"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
const DATAGRID_FORMULA_ROW_TOKEN_SEPARATOR = "::row::";
|
|
2
|
+
function normalizeDataGridFormulaReferenceName(value) {
|
|
3
|
+
const normalized = value.trim();
|
|
4
|
+
if (normalized.length === 0) {
|
|
5
|
+
throw new Error("[DataGridFormula] Reference name must be non-empty.");
|
|
6
|
+
}
|
|
7
|
+
return normalized;
|
|
8
|
+
}
|
|
9
|
+
function normalizeDataGridFormulaReferenceRowDomain(rowDomain) {
|
|
10
|
+
if (!rowDomain || rowDomain.kind === "current") {
|
|
11
|
+
return { kind: "current" };
|
|
12
|
+
}
|
|
13
|
+
if (rowDomain.kind === "absolute") {
|
|
14
|
+
return { kind: "absolute", rowIndex: Math.trunc(rowDomain.rowIndex) };
|
|
15
|
+
}
|
|
16
|
+
if (rowDomain.kind === "absolute-window") {
|
|
17
|
+
return {
|
|
18
|
+
kind: "absolute-window",
|
|
19
|
+
startRowIndex: Math.trunc(rowDomain.startRowIndex),
|
|
20
|
+
endRowIndex: Math.trunc(rowDomain.endRowIndex),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (rowDomain.kind === "relative") {
|
|
24
|
+
return { kind: "relative", offset: Math.trunc(rowDomain.offset) };
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
kind: "window",
|
|
28
|
+
startOffset: Math.trunc(rowDomain.startOffset),
|
|
29
|
+
endOffset: Math.trunc(rowDomain.endOffset),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function serializeDataGridFormulaReferenceRowDomain(rowDomain) {
|
|
33
|
+
if (rowDomain.kind === "current") {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (rowDomain.kind === "absolute") {
|
|
37
|
+
return `absolute:${rowDomain.rowIndex}`;
|
|
38
|
+
}
|
|
39
|
+
if (rowDomain.kind === "absolute-window") {
|
|
40
|
+
return `absolute-window:${rowDomain.startRowIndex}:${rowDomain.endRowIndex}`;
|
|
41
|
+
}
|
|
42
|
+
if (rowDomain.kind === "relative") {
|
|
43
|
+
return `relative:${rowDomain.offset}`;
|
|
44
|
+
}
|
|
45
|
+
return `window:${rowDomain.startOffset}:${rowDomain.endOffset}`;
|
|
46
|
+
}
|
|
47
|
+
function parseDataGridFormulaReferenceRowDomain(value) {
|
|
48
|
+
const normalized = value.trim();
|
|
49
|
+
if (normalized.startsWith("absolute:")) {
|
|
50
|
+
const rowIndex = Number(normalized.slice("absolute:".length));
|
|
51
|
+
if (Number.isInteger(rowIndex)) {
|
|
52
|
+
return { kind: "absolute", rowIndex };
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
if (normalized.startsWith("relative:")) {
|
|
57
|
+
const offset = Number(normalized.slice("relative:".length));
|
|
58
|
+
if (Number.isInteger(offset)) {
|
|
59
|
+
return { kind: "relative", offset };
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
if (normalized.startsWith("absolute-window:")) {
|
|
64
|
+
const payload = normalized.slice("absolute-window:".length);
|
|
65
|
+
const separatorIndex = payload.indexOf(":");
|
|
66
|
+
if (separatorIndex <= 0) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
const startRowIndex = Number(payload.slice(0, separatorIndex));
|
|
70
|
+
const endRowIndex = Number(payload.slice(separatorIndex + 1));
|
|
71
|
+
if (Number.isInteger(startRowIndex) && Number.isInteger(endRowIndex)) {
|
|
72
|
+
return { kind: "absolute-window", startRowIndex, endRowIndex };
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (normalized.startsWith("window:")) {
|
|
77
|
+
const payload = normalized.slice("window:".length);
|
|
78
|
+
const separatorIndex = payload.indexOf(":");
|
|
79
|
+
if (separatorIndex <= 0) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const startOffset = Number(payload.slice(0, separatorIndex));
|
|
83
|
+
const endOffset = Number(payload.slice(separatorIndex + 1));
|
|
84
|
+
if (Number.isInteger(startOffset) && Number.isInteger(endOffset)) {
|
|
85
|
+
return { kind: "window", startOffset, endOffset };
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
export function serializeDataGridComputedDependencyToken(reference) {
|
|
92
|
+
const name = normalizeDataGridFormulaReferenceName(reference.name);
|
|
93
|
+
const rowDomain = normalizeDataGridFormulaReferenceRowDomain(reference.rowDomain);
|
|
94
|
+
const serializedRowDomain = serializeDataGridFormulaReferenceRowDomain(rowDomain);
|
|
95
|
+
if (!serializedRowDomain) {
|
|
96
|
+
return `${reference.domain}:${name}`;
|
|
97
|
+
}
|
|
98
|
+
return `${reference.domain}:${name}${DATAGRID_FORMULA_ROW_TOKEN_SEPARATOR}${serializedRowDomain}`;
|
|
99
|
+
}
|
|
100
|
+
export function parseDataGridComputedDependencyToken(token) {
|
|
101
|
+
if (typeof token !== "string") {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const normalized = token.trim();
|
|
105
|
+
const separatorIndex = normalized.indexOf(":");
|
|
106
|
+
if (separatorIndex <= 0) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const domain = normalized.slice(0, separatorIndex).trim();
|
|
110
|
+
if (domain !== "field" && domain !== "computed" && domain !== "meta") {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const payload = normalized.slice(separatorIndex + 1);
|
|
114
|
+
const rowSeparatorIndex = payload.indexOf(DATAGRID_FORMULA_ROW_TOKEN_SEPARATOR);
|
|
115
|
+
if (rowSeparatorIndex < 0) {
|
|
116
|
+
return {
|
|
117
|
+
domain,
|
|
118
|
+
name: normalizeDataGridFormulaReferenceName(payload),
|
|
119
|
+
rowDomain: { kind: "current" },
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const name = normalizeDataGridFormulaReferenceName(payload.slice(0, rowSeparatorIndex));
|
|
123
|
+
const rowDomain = parseDataGridFormulaReferenceRowDomain(payload.slice(rowSeparatorIndex + DATAGRID_FORMULA_ROW_TOKEN_SEPARATOR.length));
|
|
124
|
+
if (!rowDomain) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
return { domain, name, rowDomain };
|
|
128
|
+
}
|
|
129
|
+
export const DATAGRID_FORMULA_META_FIELDS = Object.freeze([
|
|
130
|
+
"rowId",
|
|
131
|
+
"rowKey",
|
|
132
|
+
"sourceIndex",
|
|
133
|
+
"originalIndex",
|
|
134
|
+
"kind",
|
|
135
|
+
"isGroup",
|
|
136
|
+
]);
|
|
137
|
+
export function isDataGridFormulaMetaField(value) {
|
|
138
|
+
return typeof value === "string"
|
|
139
|
+
&& DATAGRID_FORMULA_META_FIELDS.includes(value);
|
|
140
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { DataGridComputedDependencyToken, DataGridFormulaReferenceDescriptor, DataGridFormulaReferenceDomain, DataGridFormulaReferenceRowDomain, DataGridComputedFieldComputeContext, DataGridComputedFieldDefinition, DataGridComputedFieldSnapshot, DataGridFormulaMetaField, DataGridFormulaContextRecomputeRequest, DataGridFormulaCyclePolicy, DataGridFormulaFieldDefinition, DataGridFormulaFieldSnapshot, DataGridFormulaTableRowsSource, DataGridFormulaTableSource, DataGridFormulaArrayValue, DataGridFormulaErrorValue, DataGridFormulaIterativeCalculationOptions, DataGridFormulaScalarValue, DataGridFormulaValue, DataGridFormulaRuntimeErrorCode, DataGridFormulaRuntimeError, DataGridFormulaDirtyCause, DataGridFormulaDirtyRowCause, DataGridProjectionFormulaDiagnostics, DataGridFormulaComputeStageDiagnostics, DataGridFormulaNodeComputeDiagnostics, DataGridFormulaRowNodeRecomputeDiagnostics, DataGridFormulaRowRecomputeDiagnosticsEntry, DataGridFormulaRowRecomputeDiagnostics, DataGridFormulaRuntimeIntegration, DataGridRowId, } from "./contracts.js";
|
|
2
|
+
//# sourceMappingURL=coreTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"coreTypes.d.ts","sourceRoot":"","sources":["../src/coreTypes.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,+BAA+B,EAC/B,kCAAkC,EAClC,8BAA8B,EAC9B,iCAAiC,EACjC,mCAAmC,EACnC,+BAA+B,EAC/B,6BAA6B,EAC7B,wBAAwB,EACxB,sCAAsC,EACtC,0BAA0B,EAC1B,8BAA8B,EAC9B,4BAA4B,EAC5B,8BAA8B,EAC9B,0BAA0B,EAC1B,yBAAyB,EACzB,yBAAyB,EACzB,0CAA0C,EAC1C,0BAA0B,EAC1B,oBAAoB,EACpB,+BAA+B,EAC/B,2BAA2B,EAC3B,yBAAyB,EACzB,4BAA4B,EAC5B,oCAAoC,EACpC,sCAAsC,EACtC,qCAAqC,EACrC,0CAA0C,EAC1C,2CAA2C,EAC3C,sCAAsC,EACtC,iCAAiC,EACjC,aAAa,GACd,MAAM,gBAAgB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/dependency/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../graph/index.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DataGridFormulaColumnarBatchEvaluator } from "../runtime/types.js";
|
|
2
|
+
import { type DataGridFormulaAstNode } from "../syntax/ast.js";
|
|
3
|
+
import { type DataGridFormulaFusedColumnKernel } from "./shared.js";
|
|
4
|
+
export declare function compileFormulaAstFusedColumnKernel(root: DataGridFormulaAstNode, resolveIdentifierTokenIndex: (identifier: string) => number | undefined): DataGridFormulaFusedColumnKernel | null;
|
|
5
|
+
export declare function compileFormulaAstColumnarBatchEvaluatorFused(root: DataGridFormulaAstNode, resolveIdentifierTokenIndex: (identifier: string) => number | undefined): DataGridFormulaColumnarBatchEvaluator | null;
|
|
6
|
+
//# sourceMappingURL=columnar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columnar.d.ts","sourceRoot":"","sources":["../../src/evaluators/columnar.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAA;AAChF,OAAO,EACL,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAKL,KAAK,gCAAgC,EACtC,MAAM,aAAa,CAAA;AAEpB,wBAAgB,kCAAkC,CAChD,IAAI,EAAE,sBAAsB,EAC5B,2BAA2B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GACtE,gCAAgC,GAAG,IAAI,CAgCzC;AAED,wBAAgB,4CAA4C,CAC1D,IAAI,EAAE,sBAAsB,EAC5B,2BAA2B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GACtE,qCAAqC,GAAG,IAAI,CAM9C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {} from "../syntax/ast.js";
|
|
2
|
+
import { createFormulaBinaryColumnKernel, createFormulaConstantColumnKernel, createFormulaIdentifierColumnKernel, createFormulaUnaryColumnKernel, } from "./shared.js";
|
|
3
|
+
export function compileFormulaAstFusedColumnKernel(root, resolveIdentifierTokenIndex) {
|
|
4
|
+
if (root.kind === "number") {
|
|
5
|
+
return createFormulaConstantColumnKernel(root.value);
|
|
6
|
+
}
|
|
7
|
+
if (root.kind === "literal") {
|
|
8
|
+
return createFormulaConstantColumnKernel(root.value);
|
|
9
|
+
}
|
|
10
|
+
if (root.kind === "identifier") {
|
|
11
|
+
return createFormulaIdentifierColumnKernel(resolveIdentifierTokenIndex(root.name));
|
|
12
|
+
}
|
|
13
|
+
if (root.kind === "call") {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
if (root.kind === "unary") {
|
|
17
|
+
const valueKernel = compileFormulaAstFusedColumnKernel(root.value, resolveIdentifierTokenIndex);
|
|
18
|
+
if (!valueKernel) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return createFormulaUnaryColumnKernel(valueKernel, root.operator);
|
|
22
|
+
}
|
|
23
|
+
if (root.operator === "AND" || root.operator === "OR") {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const leftKernel = compileFormulaAstFusedColumnKernel(root.left, resolveIdentifierTokenIndex);
|
|
27
|
+
const rightKernel = compileFormulaAstFusedColumnKernel(root.right, resolveIdentifierTokenIndex);
|
|
28
|
+
if (!leftKernel || !rightKernel) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return createFormulaBinaryColumnKernel(leftKernel, rightKernel, root.operator);
|
|
32
|
+
}
|
|
33
|
+
export function compileFormulaAstColumnarBatchEvaluatorFused(root, resolveIdentifierTokenIndex) {
|
|
34
|
+
const fusedKernel = compileFormulaAstFusedColumnKernel(root, resolveIdentifierTokenIndex);
|
|
35
|
+
if (!fusedKernel) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return (contextsCount, tokenColumns) => fusedKernel(contextsCount, tokenColumns);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/evaluators/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { DataGridComputedDependencyToken } from "../coreTypes.js";
|
|
2
|
+
import type { DataGridFormulaEvaluator, DataGridFormulaFunctionRuntime, DataGridFormulaTokenIndexEvaluator } from "../runtime/types.js";
|
|
3
|
+
import { type DataGridFormulaAstNode } from "../syntax/ast.js";
|
|
4
|
+
export declare function compileFormulaAstEvaluator(root: DataGridFormulaAstNode, functionRegistry: ReadonlyMap<string, DataGridFormulaFunctionRuntime>, resolveIdentifierToken: (identifier: string) => DataGridComputedDependencyToken | undefined, getFunctionContext?: () => import("../coreTypes.js").DataGridComputedFieldComputeContext<unknown> | undefined): DataGridFormulaEvaluator;
|
|
5
|
+
export declare function compileFormulaAstTokenIndexEvaluator(root: DataGridFormulaAstNode, functionRegistry: ReadonlyMap<string, DataGridFormulaFunctionRuntime>, resolveIdentifierTokenIndex: (identifier: string) => number | undefined): DataGridFormulaTokenIndexEvaluator;
|
|
6
|
+
//# sourceMappingURL=interpreter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpreter.d.ts","sourceRoot":"","sources":["../../src/evaluators/interpreter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAA;AACtE,OAAO,KAAK,EACV,wBAAwB,EAExB,8BAA8B,EAC9B,kCAAkC,EACnC,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,KAAK,sBAAsB,EAAkC,MAAM,kBAAkB,CAAA;AAqJ9F,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,sBAAsB,EAC5B,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,8BAA8B,CAAC,EACrE,sBAAsB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,+BAA+B,GAAG,SAAS,EAC3F,kBAAkB,CAAC,EAAE,MAAM,OAAO,iBAAiB,EAAE,mCAAmC,CAAC,OAAO,CAAC,GAAG,SAAS,GAC5G,wBAAwB,CAE1B;AAED,wBAAgB,oCAAoC,CAClD,IAAI,EAAE,sBAAsB,EAC5B,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,8BAA8B,CAAC,EACrE,2BAA2B,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,GACtE,kCAAkC,CAEpC"}
|