@gridsheet/engine 3.3.0

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 (119) hide show
  1. package/LICENSE +190 -0
  2. package/README.md +50 -0
  3. package/dist/constants.d.ts +21 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/formula/evaluator.d.ts +135 -0
  6. package/dist/formula/evaluator.d.ts.map +1 -0
  7. package/dist/formula/formula-error.d.ts +10 -0
  8. package/dist/formula/formula-error.d.ts.map +1 -0
  9. package/dist/formula/functions/__async.d.ts +67 -0
  10. package/dist/formula/functions/__async.d.ts.map +1 -0
  11. package/dist/formula/functions/__base.d.ts +120 -0
  12. package/dist/formula/functions/__base.d.ts.map +1 -0
  13. package/dist/formula/functions/__utils.d.ts +30 -0
  14. package/dist/formula/functions/__utils.d.ts.map +1 -0
  15. package/dist/formula/functions/abs.d.ts +9 -0
  16. package/dist/formula/functions/abs.d.ts.map +1 -0
  17. package/dist/formula/functions/add.d.ts +10 -0
  18. package/dist/formula/functions/add.d.ts.map +1 -0
  19. package/dist/formula/functions/and.d.ts +9 -0
  20. package/dist/formula/functions/and.d.ts.map +1 -0
  21. package/dist/formula/functions/arrayformula.d.ts +12 -0
  22. package/dist/formula/functions/arrayformula.d.ts.map +1 -0
  23. package/dist/formula/functions/average.d.ts +9 -0
  24. package/dist/formula/functions/average.d.ts.map +1 -0
  25. package/dist/formula/functions/concat.d.ts +9 -0
  26. package/dist/formula/functions/concat.d.ts.map +1 -0
  27. package/dist/formula/functions/count.d.ts +9 -0
  28. package/dist/formula/functions/count.d.ts.map +1 -0
  29. package/dist/formula/functions/counta.d.ts +9 -0
  30. package/dist/formula/functions/counta.d.ts.map +1 -0
  31. package/dist/formula/functions/divide.d.ts +10 -0
  32. package/dist/formula/functions/divide.d.ts.map +1 -0
  33. package/dist/formula/functions/eq.d.ts +9 -0
  34. package/dist/formula/functions/eq.d.ts.map +1 -0
  35. package/dist/formula/functions/gt.d.ts +9 -0
  36. package/dist/formula/functions/gt.d.ts.map +1 -0
  37. package/dist/formula/functions/gte.d.ts +9 -0
  38. package/dist/formula/functions/gte.d.ts.map +1 -0
  39. package/dist/formula/functions/if.d.ts +9 -0
  40. package/dist/formula/functions/if.d.ts.map +1 -0
  41. package/dist/formula/functions/iferror.d.ts +10 -0
  42. package/dist/formula/functions/iferror.d.ts.map +1 -0
  43. package/dist/formula/functions/len.d.ts +9 -0
  44. package/dist/formula/functions/len.d.ts.map +1 -0
  45. package/dist/formula/functions/lt.d.ts +9 -0
  46. package/dist/formula/functions/lt.d.ts.map +1 -0
  47. package/dist/formula/functions/lte.d.ts +9 -0
  48. package/dist/formula/functions/lte.d.ts.map +1 -0
  49. package/dist/formula/functions/max.d.ts +9 -0
  50. package/dist/formula/functions/max.d.ts.map +1 -0
  51. package/dist/formula/functions/min.d.ts +9 -0
  52. package/dist/formula/functions/min.d.ts.map +1 -0
  53. package/dist/formula/functions/minus.d.ts +10 -0
  54. package/dist/formula/functions/minus.d.ts.map +1 -0
  55. package/dist/formula/functions/multiply.d.ts +9 -0
  56. package/dist/formula/functions/multiply.d.ts.map +1 -0
  57. package/dist/formula/functions/ne.d.ts +9 -0
  58. package/dist/formula/functions/ne.d.ts.map +1 -0
  59. package/dist/formula/functions/not.d.ts +9 -0
  60. package/dist/formula/functions/not.d.ts.map +1 -0
  61. package/dist/formula/functions/now.d.ts +9 -0
  62. package/dist/formula/functions/now.d.ts.map +1 -0
  63. package/dist/formula/functions/or.d.ts +9 -0
  64. package/dist/formula/functions/or.d.ts.map +1 -0
  65. package/dist/formula/functions/power.d.ts +9 -0
  66. package/dist/formula/functions/power.d.ts.map +1 -0
  67. package/dist/formula/functions/sum.d.ts +9 -0
  68. package/dist/formula/functions/sum.d.ts.map +1 -0
  69. package/dist/formula/functions/uminus.d.ts +9 -0
  70. package/dist/formula/functions/uminus.d.ts.map +1 -0
  71. package/dist/formula/mapping.d.ts +11 -0
  72. package/dist/formula/mapping.d.ts.map +1 -0
  73. package/dist/formula/solver.d.ts +39 -0
  74. package/dist/formula/solver.d.ts.map +1 -0
  75. package/dist/index.d.ts +31 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +4888 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/lib/autofill.d.ts +22 -0
  80. package/dist/lib/autofill.d.ts.map +1 -0
  81. package/dist/lib/book.d.ts +141 -0
  82. package/dist/lib/book.d.ts.map +1 -0
  83. package/dist/lib/cell.d.ts +17 -0
  84. package/dist/lib/cell.d.ts.map +1 -0
  85. package/dist/lib/coords.d.ts +22 -0
  86. package/dist/lib/coords.d.ts.map +1 -0
  87. package/dist/lib/date.d.ts +2 -0
  88. package/dist/lib/date.d.ts.map +1 -0
  89. package/dist/lib/filter.d.ts +7 -0
  90. package/dist/lib/filter.d.ts.map +1 -0
  91. package/dist/lib/label.d.ts +4 -0
  92. package/dist/lib/label.d.ts.map +1 -0
  93. package/dist/lib/operation.d.ts +31 -0
  94. package/dist/lib/operation.d.ts.map +1 -0
  95. package/dist/lib/palette.d.ts +2 -0
  96. package/dist/lib/palette.d.ts.map +1 -0
  97. package/dist/lib/reference.d.ts +19 -0
  98. package/dist/lib/reference.d.ts.map +1 -0
  99. package/dist/lib/sheet.d.ts +626 -0
  100. package/dist/lib/sheet.d.ts.map +1 -0
  101. package/dist/lib/sheet_utils.d.ts +52 -0
  102. package/dist/lib/sheet_utils.d.ts.map +1 -0
  103. package/dist/lib/spatial.d.ts +79 -0
  104. package/dist/lib/spatial.d.ts.map +1 -0
  105. package/dist/lib/time.d.ts +29 -0
  106. package/dist/lib/time.d.ts.map +1 -0
  107. package/dist/policy/core.d.ts +161 -0
  108. package/dist/policy/core.d.ts.map +1 -0
  109. package/dist/policy/percentage.d.ts +3 -0
  110. package/dist/policy/percentage.d.ts.map +1 -0
  111. package/dist/policy/thousand_separator.d.ts +4 -0
  112. package/dist/policy/thousand_separator.d.ts.map +1 -0
  113. package/dist/sentinels.d.ts +41 -0
  114. package/dist/sentinels.d.ts.map +1 -0
  115. package/dist/types.d.ts +313 -0
  116. package/dist/types.d.ts.map +1 -0
  117. package/dist/utils.d.ts +2 -0
  118. package/dist/utils.d.ts.map +1 -0
  119. package/package.json +63 -0
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2020 righ
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # @gridsheet/engine
2
+
3
+ The **headless** spreadsheet model + formula resolution engine that powers
4
+ [gridsheet](https://gridsheet.walkframe.com/). It has **zero React/DOM
5
+ dependency** and can be imported on its own from a CLI, a VS Code extension
6
+ host, a CI job, or a backend to resolve formulas — including **async** ones
7
+ (e.g. `=AI(...)`) — without rendering anything.
8
+
9
+ `@gridsheet/web` (and the React/Vue/Svelte/Preact bindings built on it) depend
10
+ on this package; the dependency is one-directional (`web → engine`).
11
+
12
+ ## What it provides
13
+
14
+ - **Parse + evaluate**: `Lexer` / `FormulaParser`, sync evaluation.
15
+ - **Explicit resolution** (no render side-effect): `Sheet.resolveFormulas()`,
16
+ `Sheet.resolveAll()`, `Sheet.waitForPending()`.
17
+ - **Injectable async resolvers**: register any async function via
18
+ `createRegistry({ additionalFunctions })` using `BaseFunctionAsync`. The
19
+ interface is generic — `=AI()` is just one such function; the engine never
20
+ hardcodes who resolves it.
21
+ - **Materialize values** headlessly: `toValueMatrix()` / `toValueObject()` etc.
22
+
23
+ ## Headless example
24
+
25
+ ```ts
26
+ import { Sheet, createRegistry, toValueMatrix, BaseFunctionAsync } from '@gridsheet/engine';
27
+
28
+ // Caller decides HOW an async function resolves (local agent / vscode.lm / cache / backend).
29
+ class AiFunction extends BaseFunctionAsync {
30
+ main(prompt: any) {
31
+ return myResolver(prompt); // returns a Promise
32
+ }
33
+ }
34
+
35
+ const registry = createRegistry({ additionalFunctions: { ai: AiFunction } });
36
+ const sheet = new Sheet({ name: 'Sheet1', registry, eager: true });
37
+ sheet.initialize({ A1: { value: 'summarize' }, B1: { value: '=AI(A1)' } });
38
+ registry.contextsBySheetId[sheet.id] = { store: { sheetReactive: { current: sheet } }, dispatch: () => {} };
39
+ sheet.resolveFormulas();
40
+
41
+ sheet.resolveAll(); // fire async formulas explicitly (no render)
42
+ await sheet.waitForPending(); // await completion
43
+
44
+ const matrix = toValueMatrix(sheet, { area: { top: 1, left: 1, bottom: 1, right: 2 } });
45
+ // matrix holds the materialized values, including the resolved =AI(A1).
46
+ ```
47
+
48
+ ## License
49
+
50
+ Apache-2.0
@@ -0,0 +1,21 @@
1
+ import { ZoneType } from './types';
2
+ export declare const DEFAULT_HISTORY_LIMIT = 20;
3
+ export declare const DEFAULT_HEIGHT = 24;
4
+ export declare const DEFAULT_WIDTH = 90;
5
+ export declare const SHEET_HEIGHT = 500;
6
+ export declare const SHEET_WIDTH = 1000;
7
+ export declare const HEADER_HEIGHT = 24;
8
+ export declare const HEADER_WIDTH = 50;
9
+ export declare const MIN_WIDTH = 5;
10
+ export declare const MIN_HEIGHT = 5;
11
+ export declare const OVERSCAN_X = 5;
12
+ export declare const OVERSCAN_Y = 10;
13
+ export declare const DEFAULT_ALPHABET_CACHE_SIZE = 1000;
14
+ export declare const SECONDS_IN_DAY = 86400;
15
+ export declare const FULLDATE_FORMAT_UTC = "YYYY-MM-DDTHH:mm:ss.SSSZ";
16
+ export declare const RESET_ZONE: ZoneType;
17
+ export declare const BASE_DATE: Date;
18
+ export declare const DEFAULT_KEY = "default";
19
+ export declare const DEFAULT_COL_KEY = "defaultCol";
20
+ export declare const DEFAULT_ROW_KEY = "defaultRow";
21
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,aAAa,KAAK,CAAC;AAEhC,eAAO,MAAM,YAAY,MAAM,CAAC;AAChC,eAAO,MAAM,WAAW,OAAO,CAAC;AAEhC,eAAO,MAAM,aAAa,KAAK,CAAC;AAChC,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B,eAAO,MAAM,SAAS,IAAI,CAAC;AAC3B,eAAO,MAAM,UAAU,IAAI,CAAC;AAE5B,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,eAAO,MAAM,UAAU,KAAK,CAAC;AAE7B,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,mBAAmB,6BAA6B,CAAC;AAE9D,eAAO,MAAM,UAAU,EAAE,QAKxB,CAAC;AAGF,eAAO,MAAM,SAAS,MAAuB,CAAC;AAE9C,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,eAAe,eAAe,CAAC"}
@@ -0,0 +1,135 @@
1
+ import { Sheet } from '../lib/sheet';
2
+ import { Id } from '../types';
3
+ type EvaluateProps = {
4
+ sheet: Sheet;
5
+ };
6
+ type IdentityBaseProps = {
7
+ slideY?: number;
8
+ slideX?: number;
9
+ operation?: 'move' | 'removeRows' | 'removeCols';
10
+ dependency: Id;
11
+ };
12
+ export type ProcessFormulaProps = IdentityBaseProps & {
13
+ idMap?: {
14
+ [id: string]: string;
15
+ };
16
+ };
17
+ export type IdentifyProps = IdentityBaseProps & {
18
+ sheet: Sheet;
19
+ };
20
+ export type DisplayProps = {
21
+ sheet: Sheet;
22
+ slideY?: number;
23
+ slideX?: number;
24
+ };
25
+ declare class Entity<T = any> {
26
+ value: T;
27
+ ids: string[];
28
+ constructor(value: T);
29
+ }
30
+ export declare class ValueEntity extends Entity {
31
+ evaluate(): any;
32
+ }
33
+ export declare class UnreferencedEntity extends Entity {
34
+ evaluate(): void;
35
+ }
36
+ export declare class InvalidRefEntity extends Entity<string> {
37
+ evaluate(): void;
38
+ }
39
+ export declare class RefEntity extends Entity<string> {
40
+ constructor(value: string);
41
+ stringify(): string;
42
+ evaluate({ sheet }: EvaluateProps): Sheet;
43
+ identify(props: IdentifyProps): string;
44
+ }
45
+ export declare class RangeEntity extends Entity<string> {
46
+ stringify(): string;
47
+ evaluate({ sheet }: EvaluateProps): Sheet;
48
+ identify(props: IdentifyProps): string;
49
+ }
50
+ export declare class IdEntity extends Entity<string> {
51
+ private parse;
52
+ evaluate({ sheet }: EvaluateProps): Sheet;
53
+ display({ sheet, slideY, slideX }: DisplayProps): string;
54
+ identify(props: IdentifyProps): string;
55
+ }
56
+ export declare class IdRangeEntity extends Entity<string> {
57
+ private parse;
58
+ evaluate({ sheet }: EvaluateProps): Sheet;
59
+ display({ sheet, slideY, slideX }: DisplayProps): string;
60
+ identify(props: IdentifyProps): string;
61
+ }
62
+ export declare class FunctionEntity {
63
+ args: Expression[];
64
+ name: string;
65
+ precedence: number;
66
+ private at?;
67
+ constructor(name: string, precedence?: number, args?: Expression[], at?: Id);
68
+ evaluate({ sheet }: EvaluateProps): any;
69
+ }
70
+ export type Expression = ValueEntity | RefEntity | RangeEntity | IdEntity | IdRangeEntity | FunctionEntity | UnreferencedEntity | InvalidRefEntity;
71
+ export type TokenType = 'VALUE' | 'REF' | 'RANGE' | 'ID' | 'ID_RANGE' | 'FUNCTION' | 'PREFIX_OPERATOR' | 'INFIX_OPERATOR' | 'POSTFIX_OPERATOR' | 'OPEN' | 'CLOSE' | 'COMMA' | 'SPACE' | 'UNREFERENCED' | 'INVALID_REF';
72
+ export declare class Token {
73
+ type: TokenType;
74
+ entity: any;
75
+ precedence: number;
76
+ closed: boolean;
77
+ raw?: string;
78
+ private at?;
79
+ constructor(type: TokenType, entity: any, precedence?: number, at?: Id, closed?: boolean);
80
+ length(): number;
81
+ stringify(): string;
82
+ convert(): ValueEntity | UnreferencedEntity | InvalidRefEntity | RefEntity | RangeEntity | IdEntity | IdRangeEntity | FunctionEntity | undefined;
83
+ }
84
+ type LexerOption = {
85
+ at?: Id;
86
+ };
87
+ export declare class Lexer {
88
+ private index;
89
+ private formula;
90
+ tokens: Token[];
91
+ foreign: boolean;
92
+ identifiedFormula: string;
93
+ dependencyIds: string[];
94
+ private at?;
95
+ constructor(formula: string, options?: LexerOption);
96
+ private isWhiteSpace;
97
+ private next;
98
+ private get;
99
+ private getToken;
100
+ getTokenIndexByCharPosition(pos: number): [number, boolean];
101
+ getTokenPositionRange(index: number, slide?: number): [number, number];
102
+ stringify(): string;
103
+ identify(props: IdentifyProps): void;
104
+ display({ sheet }: DisplayProps): string;
105
+ tokenize(idMap?: {
106
+ [id: Id]: Id;
107
+ }): void;
108
+ private skipSpaces;
109
+ private getString;
110
+ }
111
+ export declare class Parser {
112
+ index: number;
113
+ depth: number;
114
+ tokens: Token[];
115
+ constructor(tokens: Token[]);
116
+ build(): Expression | undefined;
117
+ private parse;
118
+ }
119
+ /** Alias for Parser, exported for external tooling (e.g. Debugger). */
120
+ export declare const FormulaParser: typeof Parser;
121
+ export declare const stripSheetName: (sheetName: string) => string;
122
+ export declare function splitRef(ref: string): {
123
+ sheetName: string | undefined;
124
+ addresses: string[];
125
+ };
126
+ export declare const parseRef: (ref: string, { sheet, operation, dependency }: IdentifyProps) => {
127
+ sheet: Sheet;
128
+ sheetId?: number;
129
+ formula?: string;
130
+ sheetName?: string;
131
+ addresses: string[];
132
+ ids: string[];
133
+ };
134
+ export {};
135
+ //# sourceMappingURL=evaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/formula/evaluator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,EAAE,EAAa,MAAM,UAAU,CAAC;AAGzC,KAAK,aAAa,GAAG;IACnB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY,GAAG,YAAY,CAAC;IACjD,UAAU,EAAE,EAAE,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,iBAAiB,GAAG;IACpD,KAAK,CAAC,EAAE;Q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O,MAAM,cAAc,GAAI,WAAW,MAAM,WAQ/C,CAAC;AAEF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAA;CAAE,CA0C5F;AAED,eAAO,MAAM,QAAQ,GACnB,KAAK,MAAM,EACX,kCAAkC,aAAa,KAC9C;IACD,KAAK,EAAE,KAAK,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,EAAE,MAAM,EAAE,CAAC;CA2Cf,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare class FormulaError {
2
+ code: string;
3
+ message: string;
4
+ error?: Error;
5
+ readonly __gsType: "FormulaError";
6
+ constructor(code: string, message: string, error?: Error);
7
+ static is(obj: any): obj is FormulaError;
8
+ toString(): string;
9
+ }
10
+ //# sourceMappingURL=formula-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formula-error.d.ts","sourceRoot":"","sources":["../../src/formula/formula-error.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAY;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,KAAK,CAAC;IACrB,SAAgB,QAAQ,EAAG,cAAc,CAAU;gBACvC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK;IAKxD,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,YAAY;IAGxC,QAAQ;CAGT"}
@@ -0,0 +1,67 @@
1
+ import { Pending, Sentinel } from '../../sentinels';
2
+ import { Registry } from '../../lib/book';
3
+ import { Id, PointType } from '../../types';
4
+ /**
5
+ * Sentinel value to distinguish cache miss from user-returned undefined/null.
6
+ * Since user functions can return undefined or null, we need a special marker
7
+ * to indicate "no cache entry found" vs "cache entry is undefined".
8
+ */
9
+ export declare const asyncCacheMiss: Sentinel;
10
+ /** Returns true if any element of `args` is a Pending sentinel. */
11
+ export declare const hasPendingArg: (args: any[]) => boolean;
12
+ /**
13
+ * Recursively check whether any value in the structure is a Pending sentinel.
14
+ * Handles flat values, nested arrays, and Sheet objects (via getFieldMatrix).
15
+ */
16
+ export declare const hasDeepPending: (values: any[], at: Id) => boolean;
17
+ /**
18
+ * Build a cache key from function name + hashed serialised arguments.
19
+ *
20
+ * Format: `funcName:length:hash1-hash2-...`
21
+ * - length: byte length of the JSON-serialised args
22
+ * - hash: cyrb53 hash of the JSON string, repeated hashPrecision times with different seeds
23
+ *
24
+ * When a Sheet appears as an argument its trimmed area is converted to a
25
+ * value matrix (`any[][]`) via `getFieldMatrix()` so the key reflects the
26
+ * actual cell values the function will operate on.
27
+ */
28
+ export declare const buildAsyncCacheKey: (funcName: string, args: any[], hashPrecision?: number) => string;
29
+ /**
30
+ * Try to retrieve a cached or pending async result for the given cache key.
31
+ *
32
+ * Returns:
33
+ * - Cached value if present, valid, and not expired
34
+ * - Pending if there is an in-flight promise for this cell
35
+ * - asyncCacheMiss if no cache/pending exists (distinguishes from user-returned undefined/null)
36
+ */
37
+ export declare const getAsyncCache: (sheet: {
38
+ registry: Registry;
39
+ getId: (p: PointType) => string;
40
+ }, id: Id, key: string, useInflight?: boolean) => any;
41
+ /**
42
+ * Handle an async (Promise) result returned by BaseFunction.main().
43
+ *
44
+ * Cache is stored per-cell in cell.asyncCache.
45
+ * In-flight tracking uses Binding.asyncPending (keyed by cell ID).
46
+ * If useInflight is true, also tracks by cache key in Binding.asyncInflight.
47
+ *
48
+ * Flow:
49
+ * 1. If cell has asyncCache and the key matches (inputs unchanged) and not expired → return cached value
50
+ * 2. If there is already an in-flight promise for this cell → return its Pending
51
+ * 3. If useInflight is true and there is an in-flight promise for this key → return its Pending
52
+ * 4. Otherwise start the async work, return a new Pending, and on completion
53
+ * write the result into cell.asyncCache and trigger a re-render.
54
+ *
55
+ * @param ttlMilliseconds - Cache time-to-live in **milliseconds**. undefined = never expires.
56
+ * @param useInflight - If true, reuse the same promise for matching cache keys across different cells.
57
+ */
58
+ export declare const awaitAndSave: (promise: Promise<any>, sheet: {
59
+ registry: Registry;
60
+ getId: (p: PointType) => string;
61
+ }, id: Id, key: string, ttlMilliseconds?: number, useInflight?: boolean) => Pending;
62
+ /**
63
+ * Create a Pending sentinel that resolves immediately.
64
+ * Used when an argument is already pending — the result is propagated.
65
+ */
66
+ export declare const createPropagatedPending: () => Pending;
67
+ //# sourceMappingURL=__async.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__async.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/__async.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAY,MAAM,iBAAiB,CAAC;AAG9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAY,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI3D;;;;GAIG;AACH,eAAO,MAAM,cAAc,UAAiC,CAAC;AAE7D,mEAAmE;AACnE,eAAO,MAAM,aAAa,GAAI,MAAM,GAAG,EAAE,KAAG,OAE3C,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,GAAG,EAAE,EAAE,IAAI,EAAE,KAAG,OAsBtD,CAAC;AAqBF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,MAAM,GAAG,EAAE,EAAE,gBAAe,MAAU,KAAG,MAY7F,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,GACxB,OAAO;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,MAAM,CAAA;CAAE,EAC9D,IAAI,EAAE,EACN,KAAK,MAAM,EACX,cAAa,OAAe,KAC3B,GA6DF,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,YAAY,GACvB,SAAS,OAAO,CAAC,GAAG,CAAC,EACrB,OAAO;IAAE,QAAQ,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,CAAC,CAAC,EAAE,SAAS,KAAK,MAAM,CAAA;CAAE,EAC9D,IAAI,EAAE,EACN,KAAK,MAAM,EACX,kBAAkB,MAAM,EACxB,cAAa,OAAe,KAC3B,OAmDF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAO,OAE1C,CAAC"}
@@ -0,0 +1,120 @@
1
+ import { Sheet } from '../../lib/sheet';
2
+ import { Id } from '../../types';
3
+ import { Expression } from '../evaluator';
4
+ /** Duck-type check for Sheet instances (avoids runtime import cycle). */
5
+ export declare const isSheet: (v: any) => v is Sheet;
6
+ export type FunctionCategory = 'math' | 'statistics' | 'text' | 'time' | 'lookup' | 'information' | 'finance' | 'engineering' | 'logical' | 'other';
7
+ export type FunctionProps = {
8
+ args: Expression[];
9
+ sheet: Sheet;
10
+ at?: Id;
11
+ };
12
+ export type FunctionArgumentType = 'number' | 'string' | 'boolean' | 'date' | 'time' | 'matrix' | 'reference' | 'any';
13
+ export type FunctionArgumentDefinition = {
14
+ name: string;
15
+ description: string;
16
+ optional?: boolean;
17
+ nullable?: boolean;
18
+ variadic?: boolean;
19
+ errorTolerant?: boolean;
20
+ acceptedTypes?: FunctionArgumentType[];
21
+ /** When true, this argument takes a range/matrix value — broadcasting is suppressed for it. */
22
+ takesMatrix?: boolean;
23
+ };
24
+ export declare const conditionArg: FunctionArgumentDefinition;
25
+ /**
26
+ * Check if a value is a "matrix" (Sheet, Spilling, or 2D array).
27
+ */
28
+ export declare const isMatrix: (value: any) => boolean;
29
+ /**
30
+ * Extract the scalar from a 1×1 matrix (Sheet, Spilling, or plain 2D array).
31
+ * Returns the value unchanged if it is not a matrix.
32
+ */
33
+ export declare const stripMatrix: (value: any, at: Id) => any;
34
+ /**
35
+ * Check if a value is a matrix that is larger than 1×1.
36
+ */
37
+ export declare const isMultiCell: (value: any) => boolean;
38
+ export declare class BaseFunction {
39
+ defs: FunctionArgumentDefinition[];
40
+ example: string | undefined;
41
+ description: string;
42
+ category: FunctionCategory;
43
+ /** Indicates if this function is async. Override in subclass or use BaseFunctionAsync. */
44
+ protected isAsync: boolean;
45
+ /** Cache TTL in milliseconds. Override in subclass to set expiry. undefined = never expires. */
46
+ protected ttlMilliseconds?: number;
47
+ /** Hash precision for cache key generation. Higher values reduce collision risk. Default: 1 */
48
+ protected hashPrecision: number;
49
+ /** If true, reuse the same in-flight promise for matching cache keys across different cells. */
50
+ protected useInflight: boolean;
51
+ /** If true, broadcasting is unconditionally disabled for this function. */
52
+ protected broadcastDisabled: boolean;
53
+ protected args: any[];
54
+ protected autoSpilling: boolean;
55
+ sheet: Sheet;
56
+ at: Id;
57
+ static __name: string;
58
+ /**
59
+ * Static async marker, readable from the class without instantiating it
60
+ * (e.g. `registry.functions[name].isAsync`). Lets the formula indexer decide
61
+ * whether a cell needs eager resolution. Kept in sync with the instance
62
+ * `isAsync`; `BaseFunctionAsync` flips both to true.
63
+ */
64
+ static isAsync: boolean;
65
+ constructor({ args, sheet, at }: FunctionProps);
66
+ private _main;
67
+ /**
68
+ * Validate and normalise arguments before `main()` is called.
69
+ *
70
+ * Checks:
71
+ * 1. Argument count satisfies defs (respecting optional / variadic).
72
+ * 2. Each argument's runtime type matches the corresponding def's `type` list.
73
+ *
74
+ * Subclasses may override for additional coercion / spreading.
75
+ */
76
+ protected validate(args: any[]): any[];
77
+ eachMatrix: (value: any, callback: (v: any) => void) => void;
78
+ /**
79
+ * Extract a 2D array from a matrix value (Spilling, Sheet, or nested array).
80
+ * Default behavior for Sheet is value.solve(). Functions like COL can override
81
+ * this to preserve Sheet metadata per cell.
82
+ */
83
+ protected toMatrix(value: any): any[][];
84
+ /**
85
+ * Collapse a 1×1 matrix value (Sheet, Spilling, or 2D array) to a scalar.
86
+ * Non-matrix values pass through unchanged.
87
+ *
88
+ * Override in sub-classes that need the original Sheet / reference
89
+ * metadata (e.g. COL, ROW) — for instance, to extract position
90
+ * information before collapsing.
91
+ */
92
+ protected toScalar(value: any): any;
93
+ call(): any;
94
+ /**
95
+ * If any broadcastable argument is a matrix (multi-cell), expand the call
96
+ * across all element positions and return a Spilling.
97
+ * Returns `undefined` when no broadcast is necessary.
98
+ *
99
+ * Rules:
100
+ * - broadcastDisabled = true → never broadcast
101
+ * - An arg is broadcastable when its corresponding args[].takesMatrix is not true
102
+ * - A Sheet/Spilling/2D-array whose size is (1,1) is treated as a scalar
103
+ * (not broadcast); only multi-cell matrices trigger broadcast
104
+ * - For variadic args, extra args are assigned round-robin
105
+ * across the variadic helpArg positions
106
+ */
107
+ private broadcast;
108
+ }
109
+ /**
110
+ * Base class for async functions.
111
+ * Extend this class to create async functions that support caching.
112
+ */
113
+ export declare class BaseFunctionAsync extends BaseFunction {
114
+ protected isAsync: boolean;
115
+ static isAsync: boolean;
116
+ }
117
+ export type FunctionMapping = {
118
+ [functionName: string]: typeof BaseFunction;
119
+ };
120
+ //# sourceMappingURL=__base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__base.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/__base.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAE7C,yEAAyE;AACzE,eAAO,MAAM,OAAO,GAAI,GAAG,GAAG,KAAG,CAAC,IAAI,KAAgC,CAAC;AAIvE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAGtC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAa/C,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,YAAY,GACZ,MAAM,GACN,MAAM,GACN,QAAQ,GAC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(left: any, right: any) => boolean;
4
+ export declare const gte: (left: any, right: any) => boolean;
5
+ export declare const lt: (left: any, right: any) => boolean;
6
+ export declare const lte: (left: any, right: any) => boolean;
7
+ export declare const eq: (left: any, right: any) => boolean;
8
+ export declare const ne: (left: any, right: any) => boolean;
9
+ export type EnsureNumberOptions = {
10
+ alternative?: number;
11
+ ignore?: boolean;
12
+ };
13
+ export type EnsureBooleanOptions = {
14
+ alternative?: boolean;
15
+ ignore?: boolean;
16
+ };
17
+ export declare const isPercentage: (value: any) => value is string;
18
+ export declare const isNumeric: (value: any) => boolean;
19
+ export declare const ensureNumber: (value: any, options?: EnsureNumberOptions) => number;
20
+ export declare const ensureString: (value: any) => string;
21
+ export declare const ensureBoolean: (value: any, options?: EnsureBooleanOptions) => boolean;
22
+ /**
23
+ * Converts a value to a Date object.
24
+ * Accepts: Date, number (ms since epoch), string (parseable date string).
25
+ */
26
+ export declare function ensureDate(value: any): Date;
27
+ export declare const check: (value: any, condition: string) => boolean;
28
+ export declare const eachMatrix: (value: any, callback: (v: any, relativePoint: PointType) => void, at: Id) => void;
29
+ export declare const createBooleanMask: (sheets: Sheet[], conditions: string[], at: Id) => boolean[][];
30
+ //# sourceMappingURL=__utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"__utils.d.ts","sourceRoot":"","sources":["../../../src/formula/functions/__utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAKxC,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGjD,eAAO,MAAM,EAAE,GAAI,MAAM,GAAG,EAAE,OAAO,GAAG,KAAG,OAS1C,CAAC;AAEF,eAAO,MAAM,GAAG,GAAI,MAAM,GAAG,EAAE,OAAO,GAAG,KAAG,OAS3C,CAAC;AAEF,eAAO,MAAM,EAAE,GAAI,MAAM,GAAG,EAAE,OAAO,GAAG,KAAG,OAE1C,CAAC;AAEF,eAAO,MAAM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