@cortex-js/compute-engine 0.29.0 → 0.30.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 (150) hide show
  1. package/dist/compute-engine.esm.js +28330 -24627
  2. package/dist/compute-engine.min.esm.js +70 -68
  3. package/dist/compute-engine.min.umd.js +131 -0
  4. package/dist/{compute-engine.cjs → compute-engine.umd.js} +28330 -24627
  5. package/dist/math-json.esm.js +22 -294
  6. package/dist/math-json.min.esm.js +22 -294
  7. package/dist/math-json.min.umd.js +4 -0
  8. package/dist/math-json.umd.js +141 -0
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/configuration-change.d.ts +28 -0
  11. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/interruptible.d.ts +1 -1
  14. package/dist/types/common/one-of.d.ts +1 -1
  15. package/dist/types/common/signals.d.ts +1 -1
  16. package/dist/types/common/type/boxed-type.d.ts +20 -4
  17. package/dist/types/common/type/parse.d.ts +4 -4
  18. package/dist/types/common/type/primitive.d.ts +3 -2
  19. package/dist/types/common/type/serialize.d.ts +1 -1
  20. package/dist/types/common/type/subtype.d.ts +1 -1
  21. package/dist/types/common/type/types.d.ts +91 -25
  22. package/dist/types/common/type/utils.d.ts +2 -1
  23. package/dist/types/common/utils.d.ts +1 -1
  24. package/dist/types/compute-engine/assume.d.ts +2 -2
  25. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +72 -73
  26. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  28. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +2 -2
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +19 -1
  30. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/box.d.ts +6 -6
  32. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +42 -0
  33. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +48 -27
  34. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +17 -5
  35. package/dist/types/compute-engine/boxed-expression/{boxed-function-definition.d.ts → boxed-operator-definition.d.ts} +12 -12
  36. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +7 -8
  38. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +91 -52
  39. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +22 -25
  40. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +46 -0
  41. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +5 -0
  43. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
  44. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  46. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/hold.d.ts +2 -2
  50. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +30 -3
  53. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/product.d.ts +2 -2
  56. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +41 -1
  59. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/solve.d.ts +3 -1
  61. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/utils.d.ts +23 -23
  64. package/dist/types/compute-engine/boxed-expression/validate.d.ts +2 -1
  65. package/dist/types/compute-engine/collection-utils.d.ts +22 -57
  66. package/dist/types/compute-engine/compile.d.ts +61 -10
  67. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  68. package/dist/types/compute-engine/function-utils.d.ts +46 -29
  69. package/dist/types/compute-engine/global-types.d.ts +1432 -893
  70. package/dist/types/compute-engine/index.d.ts +154 -124
  71. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  72. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +3 -3
  85. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +21 -0
  86. package/dist/types/compute-engine/latex-syntax/parse.d.ts +14 -12
  87. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  88. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
  90. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/types.d.ts +51 -39
  92. package/dist/types/compute-engine/latex-syntax/utils.d.ts +5 -0
  93. package/dist/types/compute-engine/library/arithmetic.d.ts +2 -2
  94. package/dist/types/compute-engine/library/calculus.d.ts +2 -2
  95. package/dist/types/compute-engine/library/collections.d.ts +3 -3
  96. package/dist/types/compute-engine/library/combinatorics.d.ts +2 -0
  97. package/dist/types/compute-engine/library/complex.d.ts +2 -2
  98. package/dist/types/compute-engine/library/control-structures.d.ts +2 -2
  99. package/dist/types/compute-engine/library/core.d.ts +2 -2
  100. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  101. package/dist/types/compute-engine/library/library.d.ts +5 -5
  102. package/dist/types/compute-engine/library/linear-algebra.d.ts +2 -2
  103. package/dist/types/compute-engine/library/logic.d.ts +2 -2
  104. package/dist/types/compute-engine/library/number-theory.d.ts +2 -0
  105. package/dist/types/compute-engine/library/polynomials.d.ts +2 -2
  106. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  107. package/dist/types/compute-engine/library/relational-operator.d.ts +2 -2
  108. package/dist/types/compute-engine/library/sets.d.ts +2 -2
  109. package/dist/types/compute-engine/library/statistics.d.ts +2 -2
  110. package/dist/types/compute-engine/library/trigonometry.d.ts +2 -2
  111. package/dist/types/compute-engine/library/utils.d.ts +24 -2
  112. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +3 -4
  113. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +3 -3
  114. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +3 -4
  115. package/dist/types/compute-engine/numeric-value/types.d.ts +7 -5
  116. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  117. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  118. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  119. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +4 -19
  120. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  121. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  122. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  123. package/dist/types/compute-engine/numerics/numeric.d.ts +9 -1
  124. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  125. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  126. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  127. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  128. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  129. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  130. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  131. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +3 -0
  132. package/dist/types/compute-engine/symbolic/derivative.d.ts +2 -4
  133. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  134. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  135. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +5 -46
  136. package/dist/types/compute-engine/tensor/tensors.d.ts +4 -14
  137. package/dist/types/compute-engine/types.d.ts +2 -5
  138. package/dist/types/compute-engine.d.ts +1 -1
  139. package/dist/types/math-json/symbols.d.ts +11 -0
  140. package/dist/types/math-json/types.d.ts +19 -11
  141. package/dist/types/math-json/utils.d.ts +18 -9
  142. package/dist/types/math-json.d.ts +2 -2
  143. package/package.json +9 -11
  144. package/dist/compute-engine.min.cjs +0 -129
  145. package/dist/math-json.cjs +0 -413
  146. package/dist/math-json.min.cjs +0 -6
  147. package/dist/types/common/json5.d.ts +0 -3
  148. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +0 -64
  149. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +0 -21
  150. package/dist/types/math-json/identifiers.d.ts +0 -11
@@ -1,413 +0,0 @@
1
- /** MathJSON 0.29.0 */
2
- (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
3
- var MathJson = (() => {
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
-
22
- // src/math-json.ts
23
- var math_json_exports = {};
24
- __export(math_json_exports, {
25
- dictionaryFromExpression: () => dictionaryFromExpression,
26
- isFunctionObject: () => isFunctionObject,
27
- isStringObject: () => isStringObject,
28
- isSymbolObject: () => isSymbolObject,
29
- mapArgs: () => mapArgs,
30
- operand: () => operand,
31
- operator: () => operator,
32
- stringValue: () => stringValue,
33
- symbol: () => symbol,
34
- version: () => version
35
- });
36
-
37
- // src/common/json5.ts
38
- var JSON5 = class {
39
- static parse(input) {
40
- const parser = new JSON5Parser(input);
41
- const value = parser.parseValue();
42
- parser.skipWhitespace();
43
- if (!parser.isAtEnd()) {
44
- throw parser.error(
45
- `Unexpected token '${parser.currentChar()}' after parsing complete value`
46
- );
47
- }
48
- return value;
49
- }
50
- };
51
- var JSON5Parser = class {
52
- constructor(input) {
53
- this.index = 0;
54
- this.text = input;
55
- }
56
- parseValue() {
57
- this.skipWhitespace();
58
- if (this.isAtEnd()) {
59
- throw this.error("Unexpected end of input");
60
- }
61
- const ch = this.currentChar();
62
- if (ch === "{") return this.parseObject();
63
- if (ch === "[") return this.parseArray();
64
- if (ch === '"' || ch === "'") return this.parseString();
65
- if (ch === "-" || ch === "+" || ch >= "0" && ch <= "9" || ch === ".")
66
- return this.parseNumber();
67
- return this.parseIdentifier();
68
- }
69
- parseObject() {
70
- const obj = {};
71
- this.expectChar("{");
72
- this.skipWhitespace();
73
- if (this.currentChar() === "}") {
74
- this.index++;
75
- return obj;
76
- }
77
- while (true) {
78
- this.skipWhitespace();
79
- let key;
80
- const ch = this.currentChar();
81
- if (ch === '"' || ch === "'") {
82
- key = this.parseString();
83
- } else {
84
- key = this.parseIdentifier();
85
- }
86
- this.skipWhitespace();
87
- this.expectChar(":");
88
- this.skipWhitespace();
89
- const value = this.parseValue();
90
- obj[key] = value;
91
- this.skipWhitespace();
92
- if (this.currentChar() === ",") {
93
- this.index++;
94
- this.skipWhitespace();
95
- if (this.currentChar() === "}") {
96
- this.index++;
97
- break;
98
- }
99
- } else if (this.currentChar() === "}") {
100
- this.index++;
101
- break;
102
- } else {
103
- throw this.error(
104
- `Expected ',' or '}' in object but found '${this.currentChar()}'`
105
- );
106
- }
107
- }
108
- return obj;
109
- }
110
- parseArray() {
111
- const arr = [];
112
- this.expectChar("[");
113
- this.skipWhitespace();
114
- if (this.currentChar() === "]") {
115
- this.index++;
116
- return arr;
117
- }
118
- while (true) {
119
- this.skipWhitespace();
120
- arr.push(this.parseValue());
121
- this.skipWhitespace();
122
- if (this.currentChar() === ",") {
123
- this.index++;
124
- this.skipWhitespace();
125
- if (this.currentChar() === "]") {
126
- this.index++;
127
- break;
128
- }
129
- } else if (this.currentChar() === "]") {
130
- this.index++;
131
- break;
132
- } else {
133
- throw this.error(
134
- `Expected ',' or ']' in array but found '${this.currentChar()}'`
135
- );
136
- }
137
- }
138
- return arr;
139
- }
140
- parseString() {
141
- const quote = this.currentChar();
142
- if (quote !== '"' && quote !== "'") {
143
- throw this.error(`String should start with a quote, got '${quote}'`);
144
- }
145
- this.index++;
146
- let result = "";
147
- while (!this.isAtEnd()) {
148
- const ch = this.currentChar();
149
- if (ch === quote) {
150
- this.index++;
151
- return result;
152
- }
153
- if (ch === "\\") {
154
- this.index++;
155
- if (this.isAtEnd()) {
156
- throw this.error("Unterminated escape sequence in string");
157
- }
158
- const esc = this.currentChar();
159
- switch (esc) {
160
- case "b":
161
- result += "\b";
162
- break;
163
- case "f":
164
- result += "\f";
165
- break;
166
- case "n":
167
- result += "\n";
168
- break;
169
- case "r":
170
- result += "\r";
171
- break;
172
- case "t":
173
- result += " ";
174
- break;
175
- case "v":
176
- result += "\v";
177
- break;
178
- case "\\":
179
- result += "\\";
180
- break;
181
- case "'":
182
- result += "'";
183
- break;
184
- case '"':
185
- result += '"';
186
- break;
187
- case "0":
188
- result += "\0";
189
- break;
190
- case "u": {
191
- this.index++;
192
- const hex = this.text.substr(this.index, 4);
193
- if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
194
- throw this.error(`Invalid Unicode escape sequence: \\u${hex}`);
195
- }
196
- result += String.fromCharCode(parseInt(hex, 16));
197
- this.index += 3;
198
- break;
199
- }
200
- default:
201
- result += esc;
202
- }
203
- this.index++;
204
- } else {
205
- result += ch;
206
- this.index++;
207
- }
208
- }
209
- throw this.error("Unterminated string literal");
210
- }
211
- parseNumber() {
212
- const start = this.index;
213
- if (this.text.startsWith("-Infinity", this.index)) {
214
- this.index += "-Infinity".length;
215
- return -Infinity;
216
- }
217
- if (this.text.startsWith("+Infinity", this.index)) {
218
- this.index += "+Infinity".length;
219
- return Infinity;
220
- }
221
- if (this.text.startsWith("Infinity", this.index)) {
222
- this.index += "Infinity".length;
223
- return Infinity;
224
- }
225
- while (!this.isAtEnd() && /[0-9+\-_.eE]/.test(this.currentChar())) {
226
- this.index++;
227
- }
228
- const token = this.text.slice(start, this.index);
229
- const normalized = token.replace(/_/g, "");
230
- const num = Number(normalized);
231
- if (isNaN(num)) {
232
- throw this.error(`Invalid number: ${token}`);
233
- }
234
- return num;
235
- }
236
- parseIdentifier() {
237
- const start = this.index;
238
- const firstChar = this.currentChar();
239
- if (!/[a-zA-Z$_]/.test(firstChar)) {
240
- throw this.error(`Unexpected token '${firstChar}'`);
241
- }
242
- this.index++;
243
- while (!this.isAtEnd()) {
244
- const ch = this.currentChar();
245
- if (!/[a-zA-Z0-9$_]/.test(ch)) break;
246
- this.index++;
247
- }
248
- const token = this.text.slice(start, this.index);
249
- if (token === "true") return true;
250
- if (token === "false") return false;
251
- if (token === "null") return null;
252
- if (token === "Infinity") return Infinity;
253
- if (token === "NaN") return NaN;
254
- return token;
255
- }
256
- skipWhitespace() {
257
- while (!this.isAtEnd()) {
258
- const ch = this.currentChar();
259
- if (/\s/.test(ch)) {
260
- this.index++;
261
- continue;
262
- }
263
- if (ch === "/") {
264
- const next = this.peekChar(1);
265
- if (next === "/") {
266
- this.index += 2;
267
- while (!this.isAtEnd() && this.currentChar() !== "\n") {
268
- this.index++;
269
- }
270
- continue;
271
- } else if (next === "*") {
272
- this.index += 2;
273
- while (!this.isAtEnd() && !(this.currentChar() === "*" && this.peekChar(1) === "/")) {
274
- this.index++;
275
- }
276
- if (this.isAtEnd()) {
277
- throw this.error("Unterminated multi-line comment");
278
- }
279
- this.index += 2;
280
- continue;
281
- }
282
- }
283
- break;
284
- }
285
- }
286
- expectChar(expected) {
287
- if (this.currentChar() !== expected) {
288
- throw this.error(
289
- `Expected '${expected}' but found '${this.currentChar()}'`
290
- );
291
- }
292
- this.index++;
293
- }
294
- currentChar() {
295
- return this.text[this.index];
296
- }
297
- peekChar(offset) {
298
- return this.text[this.index + offset];
299
- }
300
- isAtEnd() {
301
- return this.index >= this.text.length;
302
- }
303
- error(message) {
304
- return new Error(`${message} at position ${this.index}`);
305
- }
306
- };
307
-
308
- // src/math-json/utils.ts
309
- function isSymbolObject(expr) {
310
- return expr !== null && typeof expr === "object" && "sym" in expr;
311
- }
312
- function isStringObject(expr) {
313
- return expr !== null && typeof expr === "object" && "str" in expr;
314
- }
315
- function isFunctionObject(expr) {
316
- return expr !== null && typeof expr === "object" && "fn" in expr;
317
- }
318
- function stringValue(expr) {
319
- if (expr === null || expr === void 0) return null;
320
- if (typeof expr === "object" && "str" in expr) return expr.str;
321
- if (typeof expr !== "string") return null;
322
- if (expr.length < 2) return null;
323
- if (expr.at(0) !== "'" || expr.at(-1) !== "'") return null;
324
- return expr.substring(1, expr.length - 1);
325
- }
326
- function operator(expr) {
327
- if (Array.isArray(expr)) return expr[0];
328
- if (expr === null || expr === void 0) return "";
329
- if (isFunctionObject(expr)) return expr.fn[0];
330
- return "";
331
- }
332
- function operands(expr) {
333
- if (Array.isArray(expr)) return expr.slice(1);
334
- if (expr !== void 0 && isFunctionObject(expr)) return expr.fn.slice(1);
335
- return [];
336
- }
337
- function operand(expr, n) {
338
- if (Array.isArray(expr)) return expr[n] ?? null;
339
- if (expr === null || !isFunctionObject(expr)) return null;
340
- return expr.fn[n] ?? null;
341
- }
342
- function nops(expr) {
343
- if (expr === null || expr === void 0) return 0;
344
- if (Array.isArray(expr)) return Math.max(0, expr.length - 1);
345
- if (isFunctionObject(expr)) return Math.max(0, expr.fn.length - 1);
346
- return 0;
347
- }
348
- function symbol(expr) {
349
- if (typeof expr === "string") {
350
- if (/^[+-]?[0-9\.]/.test(expr)) return null;
351
- if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
352
- return null;
353
- return expr;
354
- }
355
- if (expr === null || expr === void 0) return null;
356
- const s = isSymbolObject(expr) ? expr.sym : expr;
357
- if (typeof s !== "string") return null;
358
- return s;
359
- }
360
- function keyValuePair(expr) {
361
- const h = operator(expr);
362
- if (h === "KeyValuePair" || h === "Tuple" || h === "Pair") {
363
- const [k, v] = operands(expr);
364
- const key = stringValue(k);
365
- if (!key) return null;
366
- return [key, v ?? "Nothing"];
367
- }
368
- return null;
369
- }
370
- function dictionaryFromExpression(expr) {
371
- if (expr === null) return null;
372
- if (typeof expr === "object" && !("sym" in expr) && !("num" in expr) && !("str" in expr) && !("fn" in expr)) {
373
- return expr;
374
- }
375
- if (typeof expr === "string" && expr[0] === "{" && expr[expr.length - 1] === "}") {
376
- try {
377
- return JSON5.parse(expr);
378
- } catch {
379
- return null;
380
- }
381
- }
382
- const kv = keyValuePair(expr);
383
- if (kv) return { [kv[0]]: kv[1] };
384
- if (operator(expr) === "Dictionary") {
385
- const result = {};
386
- const ops = operands(expr);
387
- for (let i = 1; i < nops(expr); i++) {
388
- const kv2 = keyValuePair(ops[i]);
389
- if (kv2) result[kv2[0]] = kv2[1];
390
- }
391
- return result;
392
- }
393
- return null;
394
- }
395
- function mapArgs(expr, fn) {
396
- let args = null;
397
- if (Array.isArray(expr)) args = expr;
398
- if (isFunctionObject(expr)) args = expr.fn;
399
- if (args === null) return [];
400
- let i = 1;
401
- const result = [];
402
- while (i < args.length) {
403
- result.push(fn(args[i]));
404
- i += 1;
405
- }
406
- return result;
407
- }
408
-
409
- // src/math-json.ts
410
- var version = "{{SDK_VERSION}}";
411
- return __toCommonJS(math_json_exports);
412
- })();
413
- Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,6 +0,0 @@
1
- /** MathJSON 0.29.0 */
2
- (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
3
- var MathJson=(()=>{var a=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var A=(n,t)=>{for(var i in t)a(n,i,{get:t[i],enumerable:!0})},w=(n,t,i,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of C(t))!x.call(n,r)&&r!==i&&a(n,r,{get:()=>t[r],enumerable:!(e=k(t,r))||e.enumerable});return n};var I=n=>w(a({},"__esModule",{value:!0}),n);var S={};A(S,{dictionaryFromExpression:()=>g,isFunctionObject:()=>u,isStringObject:()=>y,isSymbolObject:()=>f,mapArgs:()=>E,operand:()=>b,operator:()=>l,stringValue:()=>c,symbol:()=>m,version:()=>v});var o=class{static parse(t){let i=new h(t),e=i.parseValue();if(i.skipWhitespace(),!i.isAtEnd())throw i.error(`Unexpected token '${i.currentChar()}' after parsing complete value`);return e}},h=class{constructor(t){this.index=0;this.text=t}parseValue(){if(this.skipWhitespace(),this.isAtEnd())throw this.error("Unexpected end of input");let t=this.currentChar();return t==="{"?this.parseObject():t==="["?this.parseArray():t==='"'||t==="'"?this.parseString():t==="-"||t==="+"||t>="0"&&t<="9"||t==="."?this.parseNumber():this.parseIdentifier()}parseObject(){let t={};if(this.expectChar("{"),this.skipWhitespace(),this.currentChar()==="}")return this.index++,t;for(;;){this.skipWhitespace();let i,e=this.currentChar();e==='"'||e==="'"?i=this.parseString():i=this.parseIdentifier(),this.skipWhitespace(),this.expectChar(":"),this.skipWhitespace();let r=this.parseValue();if(t[i]=r,this.skipWhitespace(),this.currentChar()===","){if(this.index++,this.skipWhitespace(),this.currentChar()==="}"){this.index++;break}}else if(this.currentChar()==="}"){this.index++;break}else throw this.error(`Expected ',' or '}' in object but found '${this.currentChar()}'`)}return t}parseArray(){let t=[];if(this.expectChar("["),this.skipWhitespace(),this.currentChar()==="]")return this.index++,t;for(;;)if(this.skipWhitespace(),t.push(this.parseValue()),this.skipWhitespace(),this.currentChar()===","){if(this.index++,this.skipWhitespace(),this.currentChar()==="]"){this.index++;break}}else if(this.currentChar()==="]"){this.index++;break}else throw this.error(`Expected ',' or ']' in array but found '${this.currentChar()}'`);return t}parseString(){let t=this.currentChar();if(t!=='"'&&t!=="'")throw this.error(`String should start with a quote, got '${t}'`);this.index++;let i="";for(;!this.isAtEnd();){let e=this.currentChar();if(e===t)return this.index++,i;if(e==="\\"){if(this.index++,this.isAtEnd())throw this.error("Unterminated escape sequence in string");let r=this.currentChar();switch(r){case"b":i+="\b";break;case"f":i+="\f";break;case"n":i+=`
4
- `;break;case"r":i+="\r";break;case"t":i+=" ";break;case"v":i+="\v";break;case"\\":i+="\\";break;case"'":i+="'";break;case'"':i+='"';break;case"0":i+="\0";break;case"u":{this.index++;let s=this.text.substr(this.index,4);if(!/^[0-9a-fA-F]{4}$/.test(s))throw this.error(`Invalid Unicode escape sequence: \\u${s}`);i+=String.fromCharCode(parseInt(s,16)),this.index+=3;break}default:i+=r}this.index++}else i+=e,this.index++}throw this.error("Unterminated string literal")}parseNumber(){let t=this.index;if(this.text.startsWith("-Infinity",this.index))return this.index+=9,-1/0;if(this.text.startsWith("+Infinity",this.index))return this.index+=9,1/0;if(this.text.startsWith("Infinity",this.index))return this.index+=8,1/0;for(;!this.isAtEnd()&&/[0-9+\-_.eE]/.test(this.currentChar());)this.index++;let i=this.text.slice(t,this.index),e=i.replace(/_/g,""),r=Number(e);if(isNaN(r))throw this.error(`Invalid number: ${i}`);return r}parseIdentifier(){let t=this.index,i=this.currentChar();if(!/[a-zA-Z$_]/.test(i))throw this.error(`Unexpected token '${i}'`);for(this.index++;!this.isAtEnd();){let r=this.currentChar();if(!/[a-zA-Z0-9$_]/.test(r))break;this.index++}let e=this.text.slice(t,this.index);return e==="true"?!0:e==="false"?!1:e==="null"?null:e==="Infinity"?1/0:e==="NaN"?NaN:e}skipWhitespace(){for(;!this.isAtEnd();){let t=this.currentChar();if(/\s/.test(t)){this.index++;continue}if(t==="/"){let i=this.peekChar(1);if(i==="/"){for(this.index+=2;!this.isAtEnd()&&this.currentChar()!==`
5
- `;)this.index++;continue}else if(i==="*"){for(this.index+=2;!this.isAtEnd()&&!(this.currentChar()==="*"&&this.peekChar(1)==="/");)this.index++;if(this.isAtEnd())throw this.error("Unterminated multi-line comment");this.index+=2;continue}}break}}expectChar(t){if(this.currentChar()!==t)throw this.error(`Expected '${t}' but found '${this.currentChar()}'`);this.index++}currentChar(){return this.text[this.index]}peekChar(t){return this.text[this.index+t]}isAtEnd(){return this.index>=this.text.length}error(t){return new Error(`${t} at position ${this.index}`)}};function f(n){return n!==null&&typeof n=="object"&&"sym"in n}function y(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n.at(0)!=="'"||n.at(-1)!=="'"?null:n.substring(1,n.length-1)}function l(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function p(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function b(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function N(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function m(n){if(typeof n=="string")return/^[+-]?[0-9\.]/.test(n)||n.length>=2&&n[0]==="'"&&n[n.length-1]==="'"?null:n;if(n==null)return null;let t=f(n)?n.sym:n;return typeof t!="string"?null:t}function d(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,e]=p(n),r=c(i);return r?[r,e??"Nothing"]:null}return null}function g(n){if(n===null)return null;if(typeof n=="object"&&!("sym"in n)&&!("num"in n)&&!("str"in n)&&!("fn"in n))return n;if(typeof n=="string"&&n[0]==="{"&&n[n.length-1]==="}")try{return o.parse(n)}catch{return null}let t=d(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={},e=p(n);for(let r=1;r<N(n);r++){let s=d(e[r]);s&&(i[s[0]]=s[1])}return i}return null}function E(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let e=1,r=[];for(;e<i.length;)r.push(t(i[e])),e+=1;return r}var v="{{SDK_VERSION}}";return I(S);})();
6
- Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,3 +0,0 @@
1
- /* 0.29.0 */
2
- static parse(input: string): any;
3
- }
@@ -1,64 +0,0 @@
1
- /* 0.29.0 */
2
- import { Type, TypeString } from '../../common/type/types';
3
- import { BoxedType } from '../../common/type/boxed-type';
4
- /**
5
- * ### THEORY OF OPERATIONS
6
- *
7
- * - The value or type of a constant cannot be changed.
8
- *
9
- * - If set explicitly, the value is the source of truth: it overrides any
10
- * flags.
11
- *
12
- * - Once the type has been set, it can only be changed from a numeric type
13
- * to another numeric type (some expressions may have been validated with
14
- * assumptions that the just a number).
15
- *
16
- * - When the type is changed, the value is preserved if it is compatible
17
- * with the new type, otherwise it is reset to no value. Flags are adjusted
18
- * to match the type (discarded if not a numeric type).
19
- *
20
- * - When the value is changed, the type is unaffected. If the value is not
21
- * compatible with the type (setting a def with a numeric type to a value
22
- * of `True` for example), the value is discarded.
23
- *
24
- * - When getting a flag, if a value is available, it is the source of truth.
25
- * Otherwise, the stored flags are (the stored flags are also set when the
26
- * type is changed)
27
- *
28
- */
29
- export declare class _BoxedSymbolDefinition implements BoxedSymbolDefinition {
30
- readonly name: string;
31
- wikidata?: string;
32
- description?: string | string[];
33
- url?: string;
34
- private _engine;
35
- readonly scope: RuntimeScope | undefined;
36
- private _defValue?;
37
- private _value;
38
- private _type;
39
- inferredType: boolean;
40
- constant: boolean;
41
- holdUntil: 'never' | 'evaluate' | 'N';
42
- private _flags;
43
- eq?: (a: BoxedExpression) => boolean | undefined;
44
- neq?: (a: BoxedExpression) => boolean | undefined;
45
- cmp?: (a: BoxedExpression) => '=' | '>' | '<' | undefined;
46
- collection?: Partial<CollectionHandlers>;
47
- constructor(ce: ComputeEngine, name: string, def: SymbolDefinition);
48
- get isFunction(): boolean;
49
- get isConstant(): boolean;
50
- /** The symbol was previously inferred, but now it has a declaration. Update the def accordingly (we can't replace defs, as other expressions may be referencing them) */
51
- update(def: SymbolDefinition): void;
52
- reset(): void;
53
- get value(): BoxedExpression | undefined;
54
- set value(val: SemiBoxedExpression | number | undefined);
55
- get type(): BoxedType;
56
- set type(type: Type | TypeString | BoxedType);
57
- get sgn(): Sign | undefined;
58
- set sgn(val: Sign | undefined);
59
- get even(): boolean | undefined;
60
- set even(val: boolean | undefined);
61
- get odd(): boolean | undefined;
62
- set odd(val: boolean | undefined);
63
- updateFlags(flags: Partial<NumericFlags>): void;
64
- }
@@ -1,21 +0,0 @@
1
- /* 0.29.0 */
2
- import { Parser } from './types';
3
- /** For error handling, if we have a identifier prefix, assume
4
- * the identifier is invalid (it would have been captured by
5
- * `matchIdentifier()` otherwise) and return an error expression */
6
- export declare function parseInvalidIdentifier(parser: Parser): Expression | null;
7
- /**
8
- * Match an identifier.
9
- *
10
- * It can be:
11
- * - a sequence of emojis: `👍🏻👍🏻👍🏻`
12
- * - a single-letter: `a`
13
- * - some LaTeX commands: `\alpha`
14
- * - a multi-letter id with a prefix: `\operatorname{speed}`
15
- * - an id with multiple prefixes:
16
- * `\mathbin{\mathsf{T}}`
17
- * - an id with modifiers:
18
- * - `\mathrm{\alpha_{12}}` or
19
- * - `\mathit{speed\unicode{"2012}of\unicode{"2012}sound}`
20
- */
21
- export declare function parseIdentifier(parser: Parser): MathJsonIdentifier | null;
@@ -1,11 +0,0 @@
1
- /* 0.29.0 */
2
- * Return true if the string is a valid identifier.
3
- *
4
- * Check for identifiers matching a profile of [Unicode UAX31](https://unicode.org/reports/tr31/)
5
- *
6
- * See https://cortexjs.io/math-json/#identifiers for a full definition of the
7
- * profile.
8
- */
9
- export declare function isValidIdentifier(s: string): boolean;
10
- export declare const EMOJIS: RegExp;
11
- export declare function validateIdentifier(s: unknown): 'valid' | 'not-a-string' | 'empty-string' | 'expected-nfc' | 'unexpected-mixed-emoji' | 'unexpected-bidi-marker' | 'unexpected-script' | 'invalid-first-char' | 'invalid-char';