@cortex-js/compute-engine 0.27.0 → 0.29.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 (151) hide show
  1. package/dist/{compute-engine.js → compute-engine.cjs} +24718 -24251
  2. package/dist/compute-engine.esm.js +24718 -24251
  3. package/dist/compute-engine.min.cjs +129 -0
  4. package/dist/compute-engine.min.esm.js +55 -68
  5. package/dist/math-json.cjs +413 -0
  6. package/dist/math-json.esm.js +287 -7
  7. package/dist/math-json.min.cjs +6 -0
  8. package/dist/math-json.min.esm.js +287 -7
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/fuzzy-string-match.d.ts +2 -0
  11. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  12. package/dist/types/common/interruptible.d.ts +2 -2
  13. package/dist/types/common/json5.d.ts +3 -0
  14. package/dist/types/common/one-of.d.ts +2 -1
  15. package/dist/types/common/signals.d.ts +1 -2
  16. package/dist/types/common/type/boxed-type.d.ts +14 -0
  17. package/dist/types/common/type/parse.d.ts +1 -1
  18. package/dist/types/common/type/primitive.d.ts +2 -1
  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 +121 -136
  22. package/dist/types/common/type/utils.d.ts +3 -7
  23. package/dist/types/common/utils.d.ts +1 -1
  24. package/dist/types/compute-engine/assume.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +17 -18
  26. package/dist/types/compute-engine/boxed-expression/apply.d.ts +2 -2
  27. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +5 -4
  28. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +27 -0
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +2 -2
  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 +5 -5
  32. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +20 -14
  33. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +14 -13
  34. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +8 -10
  35. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -2
  36. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +4 -5
  37. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +6 -5
  38. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +11 -11
  39. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +7 -10
  40. package/dist/types/compute-engine/boxed-expression/cache.d.ts +2 -1
  41. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  43. package/dist/types/compute-engine/boxed-expression/expand.d.ts +3 -3
  44. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -3
  46. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/hold.d.ts +3 -2
  48. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/negate.d.ts +2 -2
  50. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +3 -3
  51. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  53. package/dist/types/compute-engine/boxed-expression/product.d.ts +5 -5
  54. package/dist/types/compute-engine/boxed-expression/rules.d.ts +2 -2
  55. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -3
  56. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -2
  59. package/dist/types/compute-engine/boxed-expression/terms.d.ts +2 -2
  60. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +2 -9
  61. package/dist/types/compute-engine/boxed-expression/utils.d.ts +13 -4
  62. package/dist/types/compute-engine/boxed-expression/validate.d.ts +9 -10
  63. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  64. package/dist/types/compute-engine/compile.d.ts +2 -4
  65. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  66. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  67. package/dist/types/compute-engine/{boxed-expression/public.d.ts → global-types.d.ts} +887 -849
  68. package/dist/types/compute-engine/{compute-engine.d.ts → index.d.ts} +29 -19
  69. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  70. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  71. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  72. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +2 -2
  83. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +2 -2
  84. package/dist/types/compute-engine/latex-syntax/parse.d.ts +2 -2
  85. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +2 -2
  86. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -2
  87. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +2 -2
  88. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/{public.d.ts → types.d.ts} +13 -6
  90. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -2
  91. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  92. package/dist/types/compute-engine/library/collections.d.ts +3 -2
  93. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  94. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  95. package/dist/types/compute-engine/library/core.d.ts +1 -1
  96. package/dist/types/compute-engine/library/invisible-operator.d.ts +2 -2
  97. package/dist/types/compute-engine/library/library.d.ts +3 -3
  98. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  99. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  100. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  101. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  102. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  103. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  104. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  105. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  106. package/dist/types/compute-engine/library/utils.d.ts +3 -5
  107. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +3 -4
  108. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +3 -5
  109. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +3 -4
  110. package/dist/types/compute-engine/numeric-value/{public.d.ts → types.d.ts} +9 -5
  111. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  112. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  113. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  114. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  115. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  116. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  117. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  118. package/dist/types/compute-engine/numerics/numeric.d.ts +2 -7
  119. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  120. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -5
  121. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  122. package/dist/types/compute-engine/numerics/special-functions.d.ts +4 -4
  123. package/dist/types/compute-engine/numerics/statistics.d.ts +2 -2
  124. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  125. package/dist/types/compute-engine/numerics/types.d.ts +30 -0
  126. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  127. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  128. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  129. package/dist/types/compute-engine/{boxed-expression → tensor}/tensor-fields.d.ts +19 -18
  130. package/dist/types/compute-engine/tensor/tensors.d.ts +9 -12
  131. package/dist/types/compute-engine/types.d.ts +11 -0
  132. package/dist/types/compute-engine.d.ts +3 -5
  133. package/dist/types/math-json/identifiers.d.ts +1 -1
  134. package/dist/types/math-json/types.d.ts +9 -7
  135. package/dist/types/math-json/utils.d.ts +3 -3
  136. package/dist/types/math-json.d.ts +3 -3
  137. package/package.json +9 -9
  138. package/dist/compute-engine.min.js +0 -142
  139. package/dist/math-json.js +0 -133
  140. package/dist/math-json.min.js +0 -4
  141. package/dist/types/common/buffer.d.ts +0 -9
  142. package/dist/types/common/styled-text.d.ts +0 -28
  143. package/dist/types/common/suggest.d.ts +0 -1
  144. package/dist/types/common/syntax-highlighter.d.ts +0 -40
  145. package/dist/types/common/terminal.d.ts +0 -19
  146. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +0 -12
  147. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +0 -16
  148. package/dist/types/compute-engine/debug.d.ts +0 -3
  149. package/dist/types/compute-engine/numerics/bignum.d.ts +0 -12
  150. package/dist/types/compute-engine/private.d.ts +0 -29
  151. package/dist/types/compute-engine/public.d.ts +0 -42
@@ -1,4 +1,275 @@
1
- /** Compute Engine 0.27.0 */
1
+ /** Compute Engine 0.29.0 */
2
+
3
+ // src/common/json5.ts
4
+ var JSON5 = class {
5
+ static parse(input) {
6
+ const parser = new JSON5Parser(input);
7
+ const value = parser.parseValue();
8
+ parser.skipWhitespace();
9
+ if (!parser.isAtEnd()) {
10
+ throw parser.error(
11
+ `Unexpected token '${parser.currentChar()}' after parsing complete value`
12
+ );
13
+ }
14
+ return value;
15
+ }
16
+ };
17
+ var JSON5Parser = class {
18
+ constructor(input) {
19
+ this.index = 0;
20
+ this.text = input;
21
+ }
22
+ parseValue() {
23
+ this.skipWhitespace();
24
+ if (this.isAtEnd()) {
25
+ throw this.error("Unexpected end of input");
26
+ }
27
+ const ch = this.currentChar();
28
+ if (ch === "{") return this.parseObject();
29
+ if (ch === "[") return this.parseArray();
30
+ if (ch === '"' || ch === "'") return this.parseString();
31
+ if (ch === "-" || ch === "+" || ch >= "0" && ch <= "9" || ch === ".")
32
+ return this.parseNumber();
33
+ return this.parseIdentifier();
34
+ }
35
+ parseObject() {
36
+ const obj = {};
37
+ this.expectChar("{");
38
+ this.skipWhitespace();
39
+ if (this.currentChar() === "}") {
40
+ this.index++;
41
+ return obj;
42
+ }
43
+ while (true) {
44
+ this.skipWhitespace();
45
+ let key;
46
+ const ch = this.currentChar();
47
+ if (ch === '"' || ch === "'") {
48
+ key = this.parseString();
49
+ } else {
50
+ key = this.parseIdentifier();
51
+ }
52
+ this.skipWhitespace();
53
+ this.expectChar(":");
54
+ this.skipWhitespace();
55
+ const value = this.parseValue();
56
+ obj[key] = value;
57
+ this.skipWhitespace();
58
+ if (this.currentChar() === ",") {
59
+ this.index++;
60
+ this.skipWhitespace();
61
+ if (this.currentChar() === "}") {
62
+ this.index++;
63
+ break;
64
+ }
65
+ } else if (this.currentChar() === "}") {
66
+ this.index++;
67
+ break;
68
+ } else {
69
+ throw this.error(
70
+ `Expected ',' or '}' in object but found '${this.currentChar()}'`
71
+ );
72
+ }
73
+ }
74
+ return obj;
75
+ }
76
+ parseArray() {
77
+ const arr = [];
78
+ this.expectChar("[");
79
+ this.skipWhitespace();
80
+ if (this.currentChar() === "]") {
81
+ this.index++;
82
+ return arr;
83
+ }
84
+ while (true) {
85
+ this.skipWhitespace();
86
+ arr.push(this.parseValue());
87
+ this.skipWhitespace();
88
+ if (this.currentChar() === ",") {
89
+ this.index++;
90
+ this.skipWhitespace();
91
+ if (this.currentChar() === "]") {
92
+ this.index++;
93
+ break;
94
+ }
95
+ } else if (this.currentChar() === "]") {
96
+ this.index++;
97
+ break;
98
+ } else {
99
+ throw this.error(
100
+ `Expected ',' or ']' in array but found '${this.currentChar()}'`
101
+ );
102
+ }
103
+ }
104
+ return arr;
105
+ }
106
+ parseString() {
107
+ const quote = this.currentChar();
108
+ if (quote !== '"' && quote !== "'") {
109
+ throw this.error(`String should start with a quote, got '${quote}'`);
110
+ }
111
+ this.index++;
112
+ let result = "";
113
+ while (!this.isAtEnd()) {
114
+ const ch = this.currentChar();
115
+ if (ch === quote) {
116
+ this.index++;
117
+ return result;
118
+ }
119
+ if (ch === "\\") {
120
+ this.index++;
121
+ if (this.isAtEnd()) {
122
+ throw this.error("Unterminated escape sequence in string");
123
+ }
124
+ const esc = this.currentChar();
125
+ switch (esc) {
126
+ case "b":
127
+ result += "\b";
128
+ break;
129
+ case "f":
130
+ result += "\f";
131
+ break;
132
+ case "n":
133
+ result += "\n";
134
+ break;
135
+ case "r":
136
+ result += "\r";
137
+ break;
138
+ case "t":
139
+ result += " ";
140
+ break;
141
+ case "v":
142
+ result += "\v";
143
+ break;
144
+ case "\\":
145
+ result += "\\";
146
+ break;
147
+ case "'":
148
+ result += "'";
149
+ break;
150
+ case '"':
151
+ result += '"';
152
+ break;
153
+ case "0":
154
+ result += "\0";
155
+ break;
156
+ case "u": {
157
+ this.index++;
158
+ const hex = this.text.substr(this.index, 4);
159
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
160
+ throw this.error(`Invalid Unicode escape sequence: \\u${hex}`);
161
+ }
162
+ result += String.fromCharCode(parseInt(hex, 16));
163
+ this.index += 3;
164
+ break;
165
+ }
166
+ default:
167
+ result += esc;
168
+ }
169
+ this.index++;
170
+ } else {
171
+ result += ch;
172
+ this.index++;
173
+ }
174
+ }
175
+ throw this.error("Unterminated string literal");
176
+ }
177
+ parseNumber() {
178
+ const start = this.index;
179
+ if (this.text.startsWith("-Infinity", this.index)) {
180
+ this.index += "-Infinity".length;
181
+ return -Infinity;
182
+ }
183
+ if (this.text.startsWith("+Infinity", this.index)) {
184
+ this.index += "+Infinity".length;
185
+ return Infinity;
186
+ }
187
+ if (this.text.startsWith("Infinity", this.index)) {
188
+ this.index += "Infinity".length;
189
+ return Infinity;
190
+ }
191
+ while (!this.isAtEnd() && /[0-9+\-_.eE]/.test(this.currentChar())) {
192
+ this.index++;
193
+ }
194
+ const token = this.text.slice(start, this.index);
195
+ const normalized = token.replace(/_/g, "");
196
+ const num = Number(normalized);
197
+ if (isNaN(num)) {
198
+ throw this.error(`Invalid number: ${token}`);
199
+ }
200
+ return num;
201
+ }
202
+ parseIdentifier() {
203
+ const start = this.index;
204
+ const firstChar = this.currentChar();
205
+ if (!/[a-zA-Z$_]/.test(firstChar)) {
206
+ throw this.error(`Unexpected token '${firstChar}'`);
207
+ }
208
+ this.index++;
209
+ while (!this.isAtEnd()) {
210
+ const ch = this.currentChar();
211
+ if (!/[a-zA-Z0-9$_]/.test(ch)) break;
212
+ this.index++;
213
+ }
214
+ const token = this.text.slice(start, this.index);
215
+ if (token === "true") return true;
216
+ if (token === "false") return false;
217
+ if (token === "null") return null;
218
+ if (token === "Infinity") return Infinity;
219
+ if (token === "NaN") return NaN;
220
+ return token;
221
+ }
222
+ skipWhitespace() {
223
+ while (!this.isAtEnd()) {
224
+ const ch = this.currentChar();
225
+ if (/\s/.test(ch)) {
226
+ this.index++;
227
+ continue;
228
+ }
229
+ if (ch === "/") {
230
+ const next = this.peekChar(1);
231
+ if (next === "/") {
232
+ this.index += 2;
233
+ while (!this.isAtEnd() && this.currentChar() !== "\n") {
234
+ this.index++;
235
+ }
236
+ continue;
237
+ } else if (next === "*") {
238
+ this.index += 2;
239
+ while (!this.isAtEnd() && !(this.currentChar() === "*" && this.peekChar(1) === "/")) {
240
+ this.index++;
241
+ }
242
+ if (this.isAtEnd()) {
243
+ throw this.error("Unterminated multi-line comment");
244
+ }
245
+ this.index += 2;
246
+ continue;
247
+ }
248
+ }
249
+ break;
250
+ }
251
+ }
252
+ expectChar(expected) {
253
+ if (this.currentChar() !== expected) {
254
+ throw this.error(
255
+ `Expected '${expected}' but found '${this.currentChar()}'`
256
+ );
257
+ }
258
+ this.index++;
259
+ }
260
+ currentChar() {
261
+ return this.text[this.index];
262
+ }
263
+ peekChar(offset) {
264
+ return this.text[this.index + offset];
265
+ }
266
+ isAtEnd() {
267
+ return this.index >= this.text.length;
268
+ }
269
+ error(message) {
270
+ return new Error(`${message} at position ${this.index}`);
271
+ }
272
+ };
2
273
 
3
274
  // src/math-json/utils.ts
4
275
  function isSymbolObject(expr) {
@@ -62,12 +333,21 @@ function keyValuePair(expr) {
62
333
  }
63
334
  return null;
64
335
  }
65
- function dictionary(expr) {
336
+ function dictionaryFromExpression(expr) {
66
337
  if (expr === null) return null;
338
+ if (typeof expr === "object" && !("sym" in expr) && !("num" in expr) && !("str" in expr) && !("fn" in expr)) {
339
+ return expr;
340
+ }
341
+ if (typeof expr === "string" && expr[0] === "{" && expr[expr.length - 1] === "}") {
342
+ try {
343
+ return JSON5.parse(expr);
344
+ } catch {
345
+ return null;
346
+ }
347
+ }
67
348
  const kv = keyValuePair(expr);
68
349
  if (kv) return { [kv[0]]: kv[1] };
69
- const h = operator(expr);
70
- if (h === "Dictionary") {
350
+ if (operator(expr) === "Dictionary") {
71
351
  const result = {};
72
352
  const ops = operands(expr);
73
353
  for (let i = 1; i < nops(expr); i++) {
@@ -93,16 +373,16 @@ function mapArgs(expr, fn) {
93
373
  }
94
374
 
95
375
  // src/math-json.ts
96
- var version = "0.27.0";
376
+ var version = "0.29.0";
97
377
  export {
98
- dictionary as getDictionary,
99
- stringValue as getStringValue,
378
+ dictionaryFromExpression,
100
379
  isFunctionObject,
101
380
  isStringObject,
102
381
  isSymbolObject,
103
382
  mapArgs,
104
383
  operand,
105
384
  operator,
385
+ stringValue,
106
386
  symbol,
107
387
  version
108
388
  };
@@ -0,0 +1,6 @@
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,4 +1,275 @@
1
- /** Compute Engine 0.27.0 */
1
+ /** Compute Engine 0.29.0 */
2
+
3
+ // src/common/json5.ts
4
+ var JSON5 = class {
5
+ static parse(input) {
6
+ const parser = new JSON5Parser(input);
7
+ const value = parser.parseValue();
8
+ parser.skipWhitespace();
9
+ if (!parser.isAtEnd()) {
10
+ throw parser.error(
11
+ `Unexpected token '${parser.currentChar()}' after parsing complete value`
12
+ );
13
+ }
14
+ return value;
15
+ }
16
+ };
17
+ var JSON5Parser = class {
18
+ constructor(input) {
19
+ this.index = 0;
20
+ this.text = input;
21
+ }
22
+ parseValue() {
23
+ this.skipWhitespace();
24
+ if (this.isAtEnd()) {
25
+ throw this.error("Unexpected end of input");
26
+ }
27
+ const ch = this.currentChar();
28
+ if (ch === "{") return this.parseObject();
29
+ if (ch === "[") return this.parseArray();
30
+ if (ch === '"' || ch === "'") return this.parseString();
31
+ if (ch === "-" || ch === "+" || ch >= "0" && ch <= "9" || ch === ".")
32
+ return this.parseNumber();
33
+ return this.parseIdentifier();
34
+ }
35
+ parseObject() {
36
+ const obj = {};
37
+ this.expectChar("{");
38
+ this.skipWhitespace();
39
+ if (this.currentChar() === "}") {
40
+ this.index++;
41
+ return obj;
42
+ }
43
+ while (true) {
44
+ this.skipWhitespace();
45
+ let key;
46
+ const ch = this.currentChar();
47
+ if (ch === '"' || ch === "'") {
48
+ key = this.parseString();
49
+ } else {
50
+ key = this.parseIdentifier();
51
+ }
52
+ this.skipWhitespace();
53
+ this.expectChar(":");
54
+ this.skipWhitespace();
55
+ const value = this.parseValue();
56
+ obj[key] = value;
57
+ this.skipWhitespace();
58
+ if (this.currentChar() === ",") {
59
+ this.index++;
60
+ this.skipWhitespace();
61
+ if (this.currentChar() === "}") {
62
+ this.index++;
63
+ break;
64
+ }
65
+ } else if (this.currentChar() === "}") {
66
+ this.index++;
67
+ break;
68
+ } else {
69
+ throw this.error(
70
+ `Expected ',' or '}' in object but found '${this.currentChar()}'`
71
+ );
72
+ }
73
+ }
74
+ return obj;
75
+ }
76
+ parseArray() {
77
+ const arr = [];
78
+ this.expectChar("[");
79
+ this.skipWhitespace();
80
+ if (this.currentChar() === "]") {
81
+ this.index++;
82
+ return arr;
83
+ }
84
+ while (true) {
85
+ this.skipWhitespace();
86
+ arr.push(this.parseValue());
87
+ this.skipWhitespace();
88
+ if (this.currentChar() === ",") {
89
+ this.index++;
90
+ this.skipWhitespace();
91
+ if (this.currentChar() === "]") {
92
+ this.index++;
93
+ break;
94
+ }
95
+ } else if (this.currentChar() === "]") {
96
+ this.index++;
97
+ break;
98
+ } else {
99
+ throw this.error(
100
+ `Expected ',' or ']' in array but found '${this.currentChar()}'`
101
+ );
102
+ }
103
+ }
104
+ return arr;
105
+ }
106
+ parseString() {
107
+ const quote = this.currentChar();
108
+ if (quote !== '"' && quote !== "'") {
109
+ throw this.error(`String should start with a quote, got '${quote}'`);
110
+ }
111
+ this.index++;
112
+ let result = "";
113
+ while (!this.isAtEnd()) {
114
+ const ch = this.currentChar();
115
+ if (ch === quote) {
116
+ this.index++;
117
+ return result;
118
+ }
119
+ if (ch === "\\") {
120
+ this.index++;
121
+ if (this.isAtEnd()) {
122
+ throw this.error("Unterminated escape sequence in string");
123
+ }
124
+ const esc = this.currentChar();
125
+ switch (esc) {
126
+ case "b":
127
+ result += "\b";
128
+ break;
129
+ case "f":
130
+ result += "\f";
131
+ break;
132
+ case "n":
133
+ result += "\n";
134
+ break;
135
+ case "r":
136
+ result += "\r";
137
+ break;
138
+ case "t":
139
+ result += " ";
140
+ break;
141
+ case "v":
142
+ result += "\v";
143
+ break;
144
+ case "\\":
145
+ result += "\\";
146
+ break;
147
+ case "'":
148
+ result += "'";
149
+ break;
150
+ case '"':
151
+ result += '"';
152
+ break;
153
+ case "0":
154
+ result += "\0";
155
+ break;
156
+ case "u": {
157
+ this.index++;
158
+ const hex = this.text.substr(this.index, 4);
159
+ if (!/^[0-9a-fA-F]{4}$/.test(hex)) {
160
+ throw this.error(`Invalid Unicode escape sequence: \\u${hex}`);
161
+ }
162
+ result += String.fromCharCode(parseInt(hex, 16));
163
+ this.index += 3;
164
+ break;
165
+ }
166
+ default:
167
+ result += esc;
168
+ }
169
+ this.index++;
170
+ } else {
171
+ result += ch;
172
+ this.index++;
173
+ }
174
+ }
175
+ throw this.error("Unterminated string literal");
176
+ }
177
+ parseNumber() {
178
+ const start = this.index;
179
+ if (this.text.startsWith("-Infinity", this.index)) {
180
+ this.index += "-Infinity".length;
181
+ return -Infinity;
182
+ }
183
+ if (this.text.startsWith("+Infinity", this.index)) {
184
+ this.index += "+Infinity".length;
185
+ return Infinity;
186
+ }
187
+ if (this.text.startsWith("Infinity", this.index)) {
188
+ this.index += "Infinity".length;
189
+ return Infinity;
190
+ }
191
+ while (!this.isAtEnd() && /[0-9+\-_.eE]/.test(this.currentChar())) {
192
+ this.index++;
193
+ }
194
+ const token = this.text.slice(start, this.index);
195
+ const normalized = token.replace(/_/g, "");
196
+ const num = Number(normalized);
197
+ if (isNaN(num)) {
198
+ throw this.error(`Invalid number: ${token}`);
199
+ }
200
+ return num;
201
+ }
202
+ parseIdentifier() {
203
+ const start = this.index;
204
+ const firstChar = this.currentChar();
205
+ if (!/[a-zA-Z$_]/.test(firstChar)) {
206
+ throw this.error(`Unexpected token '${firstChar}'`);
207
+ }
208
+ this.index++;
209
+ while (!this.isAtEnd()) {
210
+ const ch = this.currentChar();
211
+ if (!/[a-zA-Z0-9$_]/.test(ch)) break;
212
+ this.index++;
213
+ }
214
+ const token = this.text.slice(start, this.index);
215
+ if (token === "true") return true;
216
+ if (token === "false") return false;
217
+ if (token === "null") return null;
218
+ if (token === "Infinity") return Infinity;
219
+ if (token === "NaN") return NaN;
220
+ return token;
221
+ }
222
+ skipWhitespace() {
223
+ while (!this.isAtEnd()) {
224
+ const ch = this.currentChar();
225
+ if (/\s/.test(ch)) {
226
+ this.index++;
227
+ continue;
228
+ }
229
+ if (ch === "/") {
230
+ const next = this.peekChar(1);
231
+ if (next === "/") {
232
+ this.index += 2;
233
+ while (!this.isAtEnd() && this.currentChar() !== "\n") {
234
+ this.index++;
235
+ }
236
+ continue;
237
+ } else if (next === "*") {
238
+ this.index += 2;
239
+ while (!this.isAtEnd() && !(this.currentChar() === "*" && this.peekChar(1) === "/")) {
240
+ this.index++;
241
+ }
242
+ if (this.isAtEnd()) {
243
+ throw this.error("Unterminated multi-line comment");
244
+ }
245
+ this.index += 2;
246
+ continue;
247
+ }
248
+ }
249
+ break;
250
+ }
251
+ }
252
+ expectChar(expected) {
253
+ if (this.currentChar() !== expected) {
254
+ throw this.error(
255
+ `Expected '${expected}' but found '${this.currentChar()}'`
256
+ );
257
+ }
258
+ this.index++;
259
+ }
260
+ currentChar() {
261
+ return this.text[this.index];
262
+ }
263
+ peekChar(offset) {
264
+ return this.text[this.index + offset];
265
+ }
266
+ isAtEnd() {
267
+ return this.index >= this.text.length;
268
+ }
269
+ error(message) {
270
+ return new Error(`${message} at position ${this.index}`);
271
+ }
272
+ };
2
273
 
3
274
  // src/math-json/utils.ts
4
275
  function isSymbolObject(expr) {
@@ -62,12 +333,21 @@ function keyValuePair(expr) {
62
333
  }
63
334
  return null;
64
335
  }
65
- function dictionary(expr) {
336
+ function dictionaryFromExpression(expr) {
66
337
  if (expr === null) return null;
338
+ if (typeof expr === "object" && !("sym" in expr) && !("num" in expr) && !("str" in expr) && !("fn" in expr)) {
339
+ return expr;
340
+ }
341
+ if (typeof expr === "string" && expr[0] === "{" && expr[expr.length - 1] === "}") {
342
+ try {
343
+ return JSON5.parse(expr);
344
+ } catch {
345
+ return null;
346
+ }
347
+ }
67
348
  const kv = keyValuePair(expr);
68
349
  if (kv) return { [kv[0]]: kv[1] };
69
- const h = operator(expr);
70
- if (h === "Dictionary") {
350
+ if (operator(expr) === "Dictionary") {
71
351
  const result = {};
72
352
  const ops = operands(expr);
73
353
  for (let i = 1; i < nops(expr); i++) {
@@ -93,16 +373,16 @@ function mapArgs(expr, fn) {
93
373
  }
94
374
 
95
375
  // src/math-json.ts
96
- var version = "0.27.0";
376
+ var version = "0.29.0";
97
377
  export {
98
- dictionary as getDictionary,
99
- stringValue as getStringValue,
378
+ dictionaryFromExpression,
100
379
  isFunctionObject,
101
380
  isStringObject,
102
381
  isSymbolObject,
103
382
  mapArgs,
104
383
  operand,
105
384
  operator,
385
+ stringValue,
106
386
  symbol,
107
387
  version
108
388
  };
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  export declare const DEFAULT_COLOR = "\u001B[39m";
3
3
  export declare const DEFAULT_BG = "\u001B[49m";
4
4
  export declare const WHITE_BG = "\u001B[47m";
@@ -0,0 +1,2 @@
1
+ /* 0.29.0 */
2
+ export declare function fuzzyStringMatch(invalidWord: string, validWords: string[]): string | null;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.29.0 */
2
2
  cause: unknown;
3
3
  value: T;
4
4
  constructor({ message, value, cause, }?: {
@@ -16,5 +16,5 @@
16
16
  * @returns The final value produced by the generator.
17
17
  * @throws CancellationError if the operation is canceled or times out.
18
18
  */
19
- export declare function runAsync<T>(gen: Generator<T>, timeLimitMs: number, signal: AbortSignal): Promise<T>;
19
+ export declare function runAsync<T>(gen: Generator<T>, timeLimitMs: number, signal?: AbortSignal): Promise<T>;
20
20
  export declare function run<T>(gen: Generator<T>, timeLimitMs: number): T;
@@ -0,0 +1,3 @@
1
+ /* 0.29.0 */
2
+ static parse(input: string): any;
3
+ }