@pie-framework/math-validation 1.4.2 → 2.0.0-next.20261110063142

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 (71) hide show
  1. package/LICENSE +233 -0
  2. package/README.md +41 -110
  3. package/dist/conversion/ast-to-mathjs.d.ts +3 -0
  4. package/dist/conversion/error.d.ts +4 -0
  5. package/dist/conversion/flatten.d.ts +1 -0
  6. package/{lib → dist}/conversion/latex-to-ast.d.ts +14 -13
  7. package/{lib → dist}/conversion/lexer.d.ts +7 -7
  8. package/dist/difference.d.ts +1 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +1594 -0
  11. package/dist/latex-equal.d.ts +2 -0
  12. package/dist/literal/index.d.ts +3 -0
  13. package/dist/log.d.ts +1 -0
  14. package/dist/mathjs.d.ts +11 -0
  15. package/{lib → dist}/node-sort.d.ts +1 -1
  16. package/dist/options.d.ts +13 -0
  17. package/{lib → dist}/symbolic/compare-compound-inequations.d.ts +4 -4
  18. package/{lib → dist}/symbolic/compare-equations.d.ts +1 -1
  19. package/dist/symbolic/index.d.ts +1 -0
  20. package/dist/symbolic/simplify.d.ts +2 -0
  21. package/{lib → dist}/symbolic/utils.d.ts +8 -4
  22. package/dist/value.d.ts +6 -0
  23. package/package.json +32 -53
  24. package/lib/conversion/ast-to-mathjs.d.ts +0 -12
  25. package/lib/conversion/ast-to-mathjs.js +0 -329
  26. package/lib/conversion/ast-to-mathjs.js.map +0 -1
  27. package/lib/conversion/error.d.ts +0 -5
  28. package/lib/conversion/error.js +0 -13
  29. package/lib/conversion/error.js.map +0 -1
  30. package/lib/conversion/flatten.d.ts +0 -12
  31. package/lib/conversion/flatten.js +0 -103
  32. package/lib/conversion/flatten.js.map +0 -1
  33. package/lib/conversion/latex-to-ast.js +0 -1479
  34. package/lib/conversion/latex-to-ast.js.map +0 -1
  35. package/lib/conversion/lexer.js +0 -135
  36. package/lib/conversion/lexer.js.map +0 -1
  37. package/lib/conversion/util.d.ts +0 -3
  38. package/lib/conversion/util.js +0 -36
  39. package/lib/conversion/util.js.map +0 -1
  40. package/lib/demo.d.ts +0 -4
  41. package/lib/demo.js +0 -173
  42. package/lib/demo.js.map +0 -1
  43. package/lib/difference.d.ts +0 -2
  44. package/lib/difference.js +0 -24
  45. package/lib/difference.js.map +0 -1
  46. package/lib/index.d.ts +0 -5
  47. package/lib/index.js +0 -9
  48. package/lib/index.js.map +0 -1
  49. package/lib/latex-equal.d.ts +0 -10
  50. package/lib/latex-equal.js +0 -41
  51. package/lib/latex-equal.js.map +0 -1
  52. package/lib/literal/index.d.ts +0 -10
  53. package/lib/literal/index.js +0 -22
  54. package/lib/literal/index.js.map +0 -1
  55. package/lib/log.d.ts +0 -1
  56. package/lib/log.js +0 -14
  57. package/lib/log.js.map +0 -1
  58. package/lib/mathjs.d.ts +0 -3
  59. package/lib/mathjs.js +0 -9
  60. package/lib/mathjs.js.map +0 -1
  61. package/lib/node-sort.js +0 -236
  62. package/lib/node-sort.js.map +0 -1
  63. package/lib/symbolic/compare-compound-inequations.js +0 -68
  64. package/lib/symbolic/compare-compound-inequations.js.map +0 -1
  65. package/lib/symbolic/compare-equations.js +0 -108
  66. package/lib/symbolic/compare-equations.js.map +0 -1
  67. package/lib/symbolic/index.d.ts +0 -4
  68. package/lib/symbolic/index.js +0 -215
  69. package/lib/symbolic/index.js.map +0 -1
  70. package/lib/symbolic/utils.js +0 -207
  71. package/lib/symbolic/utils.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,233 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 PIE Framework contributors
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.
22
+
23
+ ---
24
+
25
+ Portions of this software are ported from pie-elements
26
+ (https://github.com/pie-framework/pie-elements), pie-lib
27
+ (https://github.com/pie-framework/pie-lib) and math-validation
28
+ (https://github.com/pie-framework/math-validation), distributed under this
29
+ license:
30
+
31
+ ISC License
32
+
33
+ Copyright 2019 CoreSpring Inc
34
+
35
+ Permission to use, copy, modify, and/or distribute this software for any
36
+ purpose with or without fee is hereby granted, provided that the above
37
+ copyright notice and this permission notice appear in all copies.
38
+
39
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
40
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
41
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
42
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
43
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
44
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
45
+ PERFORMANCE OF THIS SOFTWARE.
46
+
47
+ ---
48
+
49
+ The LaTeX parser and its conversion to mathjs (src/conversion/latex-to-ast.ts,
50
+ src/conversion/ast-to-mathjs.ts, src/conversion/lexer.ts and
51
+ src/conversion/flatten.ts, bundled into dist/index.js) are derived from release
52
+ 2.0.0-alpha26 of math-expressions (https://github.com/kisonecat/math-expressions),
53
+ Copyright 2014-2017 by Jim Fowler <kisonecat@gmail.com> and Duane Nykamp
54
+ <nykamp@umn.edu>, which is licensed under GPL-3.0 or Apache-2.0. They are used
55
+ under the Apache License, Version 2.0, below, and have been changed for this
56
+ package.
57
+
58
+ Apache License
59
+ Version 2.0, January 2004
60
+ https://www.apache.org/licenses/
61
+
62
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
63
+
64
+ 1. Definitions.
65
+
66
+ "License" shall mean the terms and conditions for use, reproduction,
67
+ and distribution as defined by Sections 1 through 9 of this document.
68
+
69
+ "Licensor" shall mean the copyright owner or entity authorized by
70
+ the copyright owner that is granting the License.
71
+
72
+ "Legal Entity" shall mean the union of the acting entity and all
73
+ other entities that control, are controlled by, or are under common
74
+ control with that entity. For the purposes of this definition,
75
+ "control" means (i) the power, direct or indirect, to cause the
76
+ direction or management of such entity, whether by contract or
77
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
78
+ outstanding shares, or (iii) beneficial ownership of such entity.
79
+
80
+ "You" (or "Your") shall mean an individual or Legal Entity
81
+ exercising permissions granted by this License.
82
+
83
+ "Source" form shall mean the preferred form for making modifications,
84
+ including but not limited to software source code, documentation
85
+ source, and configuration files.
86
+
87
+ "Object" form shall mean any form resulting from mechanical
88
+ transformation or translation of a Source form, including but
89
+ not limited to compiled object code, generated documentation,
90
+ and conversions to other media types.
91
+
92
+ "Work" shall mean the work of authorship, whether in Source or
93
+ Object form, made available under the License, as indicated by a
94
+ copyright notice that is included in or attached to the work
95
+ (an example is provided in the Appendix below).
96
+
97
+ "Derivative Works" shall mean any work, whether in Source or Object
98
+ form, that is based on (or derived from) the Work and for which the
99
+ editorial revisions, annotations, elaborations, or other modifications
100
+ represent, as a whole, an original work of authorship. For the purposes
101
+ of this License, Derivative Works shall not include works that remain
102
+ separable from, or merely link (or bind by name) to the interfaces of,
103
+ the Work and Derivative Works thereof.
104
+
105
+ "Contribution" shall mean any work of authorship, including
106
+ the original version of the Work and any modifications or additions
107
+ to that Work or Derivative Works thereof, that is intentionally
108
+ submitted to Licensor for inclusion in the Work by the copyright owner
109
+ or by an individual or Legal Entity authorized to submit on behalf of
110
+ the copyright owner. For the purposes of this definition, "submitted"
111
+ means any form of electronic, verbal, or written communication sent
112
+ to the Licensor or its representatives, including but not limited to
113
+ communication on electronic mailing lists, source code control systems,
114
+ and issue tracking systems that are managed by, or on behalf of, the
115
+ Licensor for the purpose of discussing and improving the Work, but
116
+ excluding communication that is conspicuously marked or otherwise
117
+ designated in writing by the copyright owner as "Not a Contribution."
118
+
119
+ "Contributor" shall mean Licensor and any individual or Legal Entity
120
+ on behalf of whom a Contribution has been received by Licensor and
121
+ subsequently incorporated within the Work.
122
+
123
+ 2. Grant of Copyright License. Subject to the terms and conditions of
124
+ this License, each Contributor hereby grants to You a perpetual,
125
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
126
+ copyright license to reproduce, prepare Derivative Works of,
127
+ publicly display, publicly perform, sublicense, and distribute the
128
+ Work and such Derivative Works in Source or Object form.
129
+
130
+ 3. Grant of Patent License. Subject to the terms and conditions of
131
+ this License, each Contributor hereby grants to You a perpetual,
132
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
133
+ (except as stated in this section) patent license to make, have made,
134
+ use, offer to sell, sell, import, and otherwise transfer the Work,
135
+ where such license applies only to those patent claims licensable
136
+ by such Contributor that are necessarily infringed by their
137
+ Contribution(s) alone or by combination of their Contribution(s)
138
+ with the Work to which such Contribution(s) was submitted. If You
139
+ institute patent litigation against any entity (including a
140
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
141
+ or a Contribution incorporated within the Work constitutes direct
142
+ or contributory patent infringement, then any patent licenses
143
+ granted to You under this License for that Work shall terminate
144
+ as of the date such litigation is filed.
145
+
146
+ 4. Redistribution. You may reproduce and distribute copies of the
147
+ Work or Derivative Works thereof in any medium, with or without
148
+ modifications, and in Source or Object form, provided that You
149
+ meet the following conditions:
150
+
151
+ (a) You must give any other recipients of the Work or
152
+ Derivative Works a copy of this License; and
153
+
154
+ (b) You must cause any modified files to carry prominent notices
155
+ stating that You changed the files; and
156
+
157
+ (c) You must retain, in the Source form of any Derivative Works
158
+ that You distribute, all copyright, patent, trademark, and
159
+ attribution notices from the Source form of the Work,
160
+ excluding those notices that do not pertain to any part of
161
+ the Derivative Works; and
162
+
163
+ (d) If the Work includes a "NOTICE" text file as part of its
164
+ distribution, then any Derivative Works that You distribute must
165
+ include a readable copy of the attribution notices contained
166
+ within such NOTICE file, excluding those notices that do not
167
+ pertain to any part of the Derivative Works, in at least one
168
+ of the following places: within a NOTICE text file distributed
169
+ as part of the Derivative Works; within the Source form or
170
+ documentation, if provided along with the Derivative Works; or,
171
+ within a display generated by the Derivative Works, if and
172
+ wherever such third-party notices normally appear. The contents
173
+ of the NOTICE file are for informational purposes only and
174
+ do not modify the License. You may add Your own attribution
175
+ notices within Derivative Works that You distribute, alongside
176
+ or as an addendum to the NOTICE text from the Work, provided
177
+ that such additional attribution notices cannot be construed
178
+ as modifying the License.
179
+
180
+ You may add Your own copyright statement to Your modifications and
181
+ may provide additional or different license terms and conditions
182
+ for use, reproduction, or distribution of Your modifications, or
183
+ for any such Derivative Works as a whole, provided Your use,
184
+ reproduction, and distribution of the Work otherwise complies with
185
+ the conditions stated in this License.
186
+
187
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
188
+ any Contribution intentionally submitted for inclusion in the Work
189
+ by You to the Licensor shall be under the terms and conditions of
190
+ this License, without any additional terms or conditions.
191
+ Notwithstanding the above, nothing herein shall supersede or modify
192
+ the terms of any separate license agreement you may have executed
193
+ with Licensor regarding such Contributions.
194
+
195
+ 6. Trademarks. This License does not grant permission to use the trade
196
+ names, trademarks, service marks, or product names of the Licensor,
197
+ except as required for reasonable and customary use in describing the
198
+ origin of the Work and reproducing the content of the NOTICE file.
199
+
200
+ 7. Disclaimer of Warranty. Unless required by applicable law or
201
+ agreed to in writing, Licensor provides the Work (and each
202
+ Contributor provides its Contributions) on an "AS IS" BASIS,
203
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
204
+ implied, including, without limitation, any warranties or conditions
205
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
206
+ PARTICULAR PURPOSE. You are solely responsible for determining the
207
+ appropriateness of using or redistributing the Work and assume any
208
+ risks associated with Your exercise of permissions under this License.
209
+
210
+ 8. Limitation of Liability. In no event and under no legal theory,
211
+ whether in tort (including negligence), contract, or otherwise,
212
+ unless required by applicable law (such as deliberate and grossly
213
+ negligent acts) or agreed to in writing, shall any Contributor be
214
+ liable to You for damages, including any direct, indirect, special,
215
+ incidental, or consequential damages of any character arising as a
216
+ result of this License or out of the use or inability to use the
217
+ Work (including but not limited to damages for loss of goodwill,
218
+ work stoppage, computer failure or malfunction, or any and all
219
+ other commercial damages or losses), even if such Contributor
220
+ has been advised of the possibility of such damages.
221
+
222
+ 9. Accepting Warranty or Additional Liability. While redistributing
223
+ the Work or Derivative Works thereof, You may choose to offer,
224
+ and charge a fee for, acceptance of support, warranty, indemnity,
225
+ or other liability obligations and/or rights consistent with this
226
+ License. However, in accepting such obligations, You may act only
227
+ on Your own behalf and on Your sole responsibility, not on behalf
228
+ of any other Contributor, and only if You agree to indemnify,
229
+ defend, and hold each Contributor harmless for any liability
230
+ incurred by, or claims asserted against, such Contributor by reason
231
+ of your accepting any such warranty or additional liability.
232
+
233
+ END OF TERMS AND CONDITIONS
package/README.md CHANGED
@@ -1,134 +1,65 @@
1
- # math-validation
1
+ # @pie-framework/math-validation
2
2
 
3
- - an api
4
- - a large set of test data
5
- - aims to determine if two mathematical expressions are equal, either having the same form or not
6
- - have a public website where you can add some math and check if it works - also the link should be shareable
3
+ Decides whether two LaTeX expressions are equal, literally or symbolically. The math-inline and math-templated controllers score responses with it.
7
4
 
5
+ ```ts
6
+ import { latexEqual } from '@pie-framework/math-validation';
8
7
 
9
- ## demo
10
-
11
- ```shell
12
- yarn demo
13
- ```
14
-
15
- Then go to `http://localhost:$PORT/demo`
16
-
17
-
18
- ## Tests
19
-
20
- ```shell
21
- yarn jest
22
- ```
23
-
24
- Runs all the tests
25
-
26
- There is one test that runs fixture data located here: `src/fixtures/latex-equal/*.ts`. To filter the fixtures you run here you can use the `-t` flag:
27
-
28
- ```shell
29
- yarn jest src/__tests__/latex-equal.spec.ts -t src/fixtures/latex-equal/7119.ts --reporters default
8
+ latexEqual('\\frac{4}{6}', '\\frac{2}{3}', { mode: 'symbolic' }); // true
9
+ latexEqual('a+7+b', '7+a+b', { mode: 'literal', literal: { ignoreOrder: true } }); // true
30
10
  ```
31
11
 
32
-
33
- ## Next Steps
34
-
35
- * Check that api we expose will support what is needed.
36
- * Do triage on the test failures, add a note to failing test so we can build a picture of the work needed
37
-
38
-
39
- ## Test failure triage
40
-
41
- | theme | notes |
42
- |----------------------------|------------------------------------------------------------------------|
43
- | latex parsing | seems like we aren't able to parse all the inputs in the test cases |
44
- | math evaluation | math.js is not seeing things as being equal - need more detail on that |
45
- | incomplete literal support | we haven't really set up literal options support yet |
46
- | incorrect test data | sometimes the test data is not quite right |
47
-
48
-
49
- ## Goals
50
-
51
- * we parse from latex -> ast -> mathjs
52
- * clean up symbolic evaluation (in progress)
53
- * avoid the use of string manipulation/regex (in progress)
54
- * more advanced literal validation (todo)
55
- * block input that is clearly too large/unrelated (eg: a user can type in gobbledy-gook - we should just abort if we see that)
56
-
57
-
58
- ## Capabilities
59
-
60
- It can determine mathematical equivalence between:
61
-
62
- - linear equations in one variable
63
- - linear equations in two variables
64
- - quadratic equations
65
- - 2-way inequalities in one or two variables
66
- - compound inequalities in one variable
67
- - trigonometric identities and functions
68
- - inverse trigonometric functions
69
- - similar notation for logarithms and based logarithms
70
-
71
- It can also handle degrees, radians and gradians
72
-
73
-
74
- ### things that'd be great (but we may have to park until we have more time)
75
-
76
- * a faster latex parser
77
- * faster math evaluation
78
-
12
+ The package is ES modules only. LaTeX is parsed into an AST (`src/conversion/latex-to-ast.ts`), converted to a mathjs expression tree (`src/conversion/ast-to-mathjs.ts`), and compared there. Both converters derive from the math-expressions library and are used under its Apache-2.0 license; `LICENSE` holds the terms.
79
13
 
80
14
  ## Modes
81
15
 
82
- There are 2 modes - literal and symbolic
83
-
84
- Literal: is at its most basic a tuned version of a string validation
85
-
86
- By default - ignores spaces and parentheses as long as they do not change the meaning of operations (ex. “a+7 +b” will validate against “ ((a) + (7))+b ”)
87
- - ignores leading zeros: “0.1” will validate against “.1”
88
- - accepts commas for decimal marks. For example “1,000” will be equivalent with 1000
16
+ **Literal** compares the form of the expressions. It ignores spaces and parentheses that do not change the meaning, so `a+7 +b` matches `((a) + (7))+b`, and it ignores leading zeros (`0.1` matches `.1`) and thousands separators (`1,000` matches `1000`). Three options under `literal` widen it:
89
17
 
90
- Literal Validation offers two configuration options that can be used to validate some variety of forms for an expression:
18
+ - `allowTrailingZeros`: `4.5` matches `4.50000`.
19
+ - `ignoreOrder`: the order of terms and factors stops mattering, so `a+7+b*c` matches `7+a+bc`, though not `ac+7+b`.
20
+ - `compareNumbersByValue`: a single number matches only a single number of equal value. A number is an integer, decimal, fraction (`\frac{2}{3}` or `2/3`) or mixed number (`2\frac{1}{2}`), with at most one sign and optionally in parentheses. `4/6` matches `2/3` and `2.5` matches `2\frac{1}{2}`, but `3+3` does not match `6`: any operation, constant (`\pi`), unit or percentage makes a side a non-number. When neither side is a number, the literal comparison decides.
91
21
 
92
- Ignore trailing zeros option; allows the evaluation to accept zeros to the right of the decimal place “4.5” will validate against “4.50000000000000”
93
- Ignore order option; makes validation indifferent to the variables order, as long as it does not change operations meaning. In this case “a+7 +b*c” will validate against “7 + a+bc”, but not against “ac+7+b”; without it “a+7 +b” will not validate against “7 + a+b”
22
+ **Symbolic** decides mathematical equivalence. It normalises both sides (distributing coefficients, combining like terms, sorting) and, where that is not enough, solves or samples them. It takes no options; the literal options do not apply to it. It handles:
94
23
 
95
- Symbolic: attempts to decide if expressions are mathematically equivalent or not
24
+ - linear equations in one or two variables, and quadratic equations
25
+ - two-way inequalities in one or two variables, and compound inequalities in one variable
26
+ - trigonometric and inverse trigonometric functions and identities, with angles in radians or in degrees written `°` or `\degree`
27
+ - the product, quotient and power rules for logarithms, and `\log` as `\log_{10}`
96
28
 
97
- By default, it offers all configurations presented for literal validation, exceeding it by quite a lot
98
- In order to check equivalence between 2 expressions, we have to reduce both expressions to the simplest one. Then distribute all coefficients, combine any like terms on each side of the expression, and arrange them in the same order.
29
+ ## Demo
99
30
 
31
+ ```shell
32
+ bun run demo
33
+ ```
100
34
 
101
- ### Notes
35
+ Serves a page that compares two expressions in either mode; the URL records the comparison, so it can be shared. `bun run build:demo` type-checks the page and writes it to `demo/dist`.
102
36
 
103
- * `@babel/runtime` is a devDependency if you ever need to link this repo to another package for testing
37
+ ## Tests
104
38
 
105
- ## TODO
106
- * set up api that is compatible w/ ui component options
107
- * derivatives kind of work and kind of not - how to use?
39
+ ```shell
40
+ bun run test
41
+ ```
108
42
 
109
- ### CI
43
+ `src/__tests__/latex-equal.test.ts` runs the fixtures under `src/fixtures/latex-equal/literal` and `src/fixtures/latex-equal/symbolic`, one suite per fixture file named by its path. Narrow a run with Vitest's `-t` filter:
110
44
 
111
- We use circleci - see .circleci/config.yml
45
+ ```shell
46
+ bunx vitest run src/__tests__/latex-equal.test.ts -t src/fixtures/latex-equal/literal/PD-303.ts
47
+ ```
112
48
 
113
- ### debugging tests
49
+ To debug in VS Code, add an attach configuration to `launch.json`:
114
50
 
115
- #### vscode
116
- add the following to `configurations` array in launch.json
117
51
  ```json
118
- {
119
- "name": "Attach",
120
- "port": 9229,
121
- "request": "attach",
122
- "skipFiles": [
123
- "<node_internals>/**"
124
- ],
125
- "type": "pwa-node"
126
- }
52
+ {
53
+ "name": "Attach",
54
+ "port": 9229,
55
+ "request": "attach",
56
+ "skipFiles": ["<node_internals>/**"],
57
+ "type": "node"
58
+ }
127
59
  ```
128
60
 
129
- ```shell
130
- node --inspect-brk ./node_modules/.bin/jest --runInBand #and any other flags you want
131
- ```
132
- The launch debug using 'Attach' command above.
61
+ Start the tests with `bunx vitest run --inspect-brk --no-file-parallelism`, then run the Attach configuration.
62
+
63
+ ## Release
133
64
 
134
- [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
65
+ The package builds, tests and releases with the rest of [pie-elements-ng](https://github.com/pie-framework/pie-elements-ng); see `docs/PUBLISHING.md` there.
@@ -0,0 +1,3 @@
1
+ export declare class AstToMathJs {
2
+ convert(tree: any): any;
3
+ }
@@ -0,0 +1,4 @@
1
+ export declare class ParseError extends Error {
2
+ location?: number;
3
+ constructor(message: string, location?: number);
4
+ }
@@ -0,0 +1 @@
1
+ export declare function flatten(expr: any): any;
@@ -1,22 +1,23 @@
1
- import { Token } from "./lexer";
1
+ import { type Token } from './lexer.js';
2
2
  export declare const whitespace_rule = "\\s|\\\\,|\\\\!|\\\\ |\\\\>|\\\\;|\\\\:|\\\\quad\\b|\\\\qquad\\b";
3
3
  export declare const latex_rules: string[][];
4
- export declare type Opts = {
4
+ export type Opts = {
5
5
  allowSimplifiedFunctionApplication: boolean;
6
6
  allowedLatexSymbols: string[];
7
7
  appliedFunctionSymbols: string[];
8
8
  functionSymbols: string[];
9
9
  parseLeibnizNotation: boolean;
10
10
  missingFactor: (token: Token, e: Error) => number | string;
11
- unknownCommandBehavior: "error" | "passthrough";
11
+ unknownCommandBehavior: 'error' | 'passthrough';
12
+ /** Keep a mixed number such as `2\\frac{1}{2}` as `["mixed", 2, ["/", 1, 2]]` instead of a sum. */
13
+ keepMixedNumbers: boolean;
12
14
  };
13
15
  export declare const DEFAULT_OPTS: Opts;
14
16
  export declare class LatexToAst {
15
- private unknownCommandBehavior;
16
17
  private lexer;
17
18
  private token;
18
19
  private opts;
19
- constructor(opts?: Opts);
20
+ constructor(opts?: Partial<Opts>);
20
21
  advance(params?: any): void;
21
22
  return_state(): {
22
23
  lexer_state: {
@@ -26,8 +27,8 @@ export declare class LatexToAst {
26
27
  token: Token;
27
28
  };
28
29
  set_state(state: any): void;
29
- convert(input: any, pars?: any): any;
30
- statement_list(pars?: any): any[];
30
+ convert(input: string, pars?: any): any;
31
+ statement_list(pars?: any): any;
31
32
  statement(opts?: {
32
33
  parse_absolute_value?: boolean;
33
34
  inside_absolute_value?: number;
@@ -40,17 +41,17 @@ export declare class LatexToAst {
40
41
  term(params: any): any;
41
42
  factor(params: any): any;
42
43
  nonMinusFactor(params: any): any;
43
- fraction({ inside_absolute_value, parse_absolute_value, allow_absolute_value_closing, unknownCommands, }: {
44
+ fraction({ parse_absolute_value, unknownCommands, }: {
44
45
  inside_absolute_value?: number;
45
46
  parse_absolute_value?: boolean;
46
47
  allow_absolute_value_closing?: boolean;
47
48
  unknownCommands?: string;
48
- }): string | any[];
49
+ }): any;
49
50
  baseFactor({ inside_absolute_value, parse_absolute_value, allow_absolute_value_closing, unknownCommands, }?: {
50
- inside_absolute_value?: number;
51
- parse_absolute_value?: boolean;
52
- allow_absolute_value_closing?: boolean;
53
- unknownCommands?: string;
51
+ inside_absolute_value?: number | undefined;
52
+ parse_absolute_value?: boolean | undefined;
53
+ allow_absolute_value_closing?: boolean | undefined;
54
+ unknownCommands?: string | undefined;
54
55
  }): any;
55
56
  leibniz_notation(): string | false;
56
57
  }
@@ -1,5 +1,5 @@
1
- export declare type TokenRule = [RegExp, string, string?];
2
- export declare type Token = {
1
+ export type TokenRule = [RegExp, string, string?];
2
+ export type Token = {
3
3
  token_type: string;
4
4
  token_text: string;
5
5
  original_text: string;
@@ -10,18 +10,18 @@ declare class lexer {
10
10
  private rules;
11
11
  private whitespace;
12
12
  constructor(rawRules: string[][], ws?: string);
13
- set_input(input: any): void;
13
+ set_input(input: string): void;
14
14
  return_state(): {
15
15
  input: string;
16
16
  location: number;
17
17
  };
18
18
  set_state({ input, location }?: {
19
- input?: any;
20
- location?: number;
19
+ input?: null | undefined;
20
+ location?: number | undefined;
21
21
  }): void;
22
22
  advance({ remove_initial_space }?: {
23
- remove_initial_space?: boolean;
23
+ remove_initial_space?: boolean | undefined;
24
24
  }): Token;
25
- unput(string: any): void;
25
+ unput(string: string): void;
26
26
  }
27
27
  export default lexer;
@@ -0,0 +1 @@
1
+ export declare const differenceIsTooGreat: (a: unknown[], b: unknown[]) => boolean;
@@ -0,0 +1,2 @@
1
+ export { latexEqual } from './latex-equal.js';
2
+ export type { Latex, LiteralOpts, Mode, Opts } from './options.js';