@cortex-js/compute-engine 0.24.1 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/compute-engine.esm.js +24046 -25451
  2. package/dist/compute-engine.js +23987 -25392
  3. package/dist/compute-engine.min.esm.js +13 -13
  4. package/dist/compute-engine.min.js +13 -13
  5. package/dist/math-json.esm.js +43 -77
  6. package/dist/math-json.js +43 -77
  7. package/dist/math-json.min.esm.js +43 -77
  8. package/dist/math-json.min.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  11. package/dist/types/common/signals.d.ts +1 -1
  12. package/dist/types/common/utils.d.ts +1 -1
  13. package/dist/types/compute-engine/assume.d.ts +1 -1
  14. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +31 -19
  15. package/dist/types/compute-engine/boxed-expression/box.d.ts +9 -9
  16. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +4 -4
  17. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -2
  18. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +2 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +9 -10
  20. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +5 -4
  21. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +2 -15
  22. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -4
  23. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
  24. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +7 -8
  25. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +6 -7
  26. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +2 -2
  27. package/dist/types/compute-engine/boxed-expression/coefficient-field.d.ts +56 -0
  28. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/factor.d.ts +11 -0
  30. package/dist/types/compute-engine/boxed-expression/match.d.ts +14 -0
  31. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +41 -0
  32. package/dist/types/compute-engine/boxed-expression/order.d.ts +6 -6
  33. package/dist/types/compute-engine/boxed-expression/public.d.ts +1983 -0
  34. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +3 -15
  35. package/dist/types/compute-engine/boxed-expression/utils.d.ts +5 -2
  36. package/dist/types/compute-engine/boxed-expression/validate.d.ts +7 -6
  37. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  38. package/dist/types/compute-engine/compile.d.ts +2 -2
  39. package/dist/types/compute-engine/compute-engine.d.ts +86 -62
  40. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  41. package/dist/types/compute-engine/domain-utils.d.ts +3 -2
  42. package/dist/types/compute-engine/function-utils.d.ts +2 -2
  43. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  44. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  45. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  46. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  47. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  48. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  49. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  50. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  51. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -3
  52. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  53. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  54. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  55. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  56. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +5 -4
  57. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  58. package/dist/types/compute-engine/latex-syntax/parse.d.ts +71 -29
  59. package/dist/types/compute-engine/latex-syntax/public.d.ts +264 -252
  60. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +9 -3
  61. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  62. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +6 -11
  63. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +3 -2
  64. package/dist/types/compute-engine/library/arithmetic-add.d.ts +5 -5
  65. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +2 -2
  66. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +5 -5
  67. package/dist/types/compute-engine/library/arithmetic-power.d.ts +2 -1
  68. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  69. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  70. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  71. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  72. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  73. package/dist/types/compute-engine/library/core.d.ts +3 -2
  74. package/dist/types/compute-engine/library/domains.d.ts +1 -1
  75. package/dist/types/compute-engine/library/library.d.ts +1 -1
  76. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  77. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  78. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  79. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  80. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -2
  81. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  82. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  83. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  84. package/dist/types/compute-engine/library/utils.d.ts +2 -2
  85. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +7 -1
  86. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  87. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  88. package/dist/types/compute-engine/numerics/numeric.d.ts +7 -17
  89. package/dist/types/compute-engine/numerics/primes.d.ts +6 -1
  90. package/dist/types/compute-engine/numerics/rationals.d.ts +4 -13
  91. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  92. package/dist/types/compute-engine/numerics/terms.d.ts +7 -4
  93. package/dist/types/compute-engine/public.d.ts +3 -1841
  94. package/dist/types/compute-engine/rules.d.ts +1 -1
  95. package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
  96. package/dist/types/compute-engine/solve.d.ts +4 -3
  97. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  98. package/dist/types/compute-engine/symbolic/expand.d.ts +2 -2
  99. package/dist/types/compute-engine/symbolic/flatten.d.ts +6 -4
  100. package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
  101. package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
  102. package/dist/types/compute-engine/symbolic/product.d.ts +4 -3
  103. package/dist/types/compute-engine/symbolic/tensor-fields.d.ts +1 -1
  104. package/dist/types/compute-engine/symbolic/tensors.d.ts +1 -1
  105. package/dist/types/compute-engine/symbolic/utils.d.ts +5 -10
  106. package/dist/types/compute-engine.d.ts +2 -2
  107. package/dist/types/math-json/math-json-format.d.ts +3 -3
  108. package/dist/types/math-json/utils.d.ts +4 -6
  109. package/dist/types/math-json.d.ts +2 -2
  110. package/package.json +10 -10
  111. package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +0 -28
  112. package/dist/types/compute-engine/numerics/factor.d.ts +0 -27
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.24.1 */
1
+ /** Compute Engine 0.25.1 */
2
2
 
3
3
  // src/math-json/utils.ts
4
4
  function isSymbolObject(expr) {
@@ -55,12 +55,9 @@ function isRecommendedScripts(text) {
55
55
  return recommendedScriptsRegex.test(text);
56
56
  }
57
57
  function isValidIdentifier(s) {
58
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))
59
- return true;
60
- if (ONLY_EMOJIS.test(s))
61
- return true;
62
- if (!isRecommendedScripts(s))
63
- return false;
58
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)) return true;
59
+ if (ONLY_EMOJIS.test(s)) return true;
60
+ if (!isRecommendedScripts(s)) return false;
64
61
  return /^[\p{XIDS}_]\p{XIDC}*$/u.test(s);
65
62
  }
66
63
  var VS16 = "\\u{FE0F}";
@@ -75,38 +72,27 @@ var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ}${ZWJ_ELEMENT})*`;
75
72
  var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
76
73
  var ONLY_EMOJIS = new RegExp(`^(?:${POSSIBLE_EMOJI})+$`, "u");
77
74
  function validateIdentifier(s) {
78
- if (typeof s !== "string")
79
- return "not-a-string";
80
- if (s === "")
81
- return "empty-string";
82
- if (s.normalize() !== s)
83
- return "expected-nfc";
75
+ if (typeof s !== "string") return "not-a-string";
76
+ if (s === "") return "empty-string";
77
+ if (s.normalize() !== s) return "expected-nfc";
84
78
  if (/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(s))
85
79
  return "unexpected-bidi-marker";
86
- if (ONLY_EMOJIS.test(s))
87
- return "valid";
80
+ if (ONLY_EMOJIS.test(s)) return "valid";
88
81
  if (/\p{XIDC}/u.test(s) && SOME_EMOJI.test(s))
89
82
  return "unexpected-mixed-emoji";
90
- if (!isRecommendedScripts(s))
91
- return "unexpected-script";
83
+ if (!isRecommendedScripts(s)) return "unexpected-script";
92
84
  if (!isValidIdentifier(s)) {
93
- if (!isValidIdentifier(s[0]))
94
- return "invalid-first-char";
85
+ if (!isValidIdentifier(s[0])) return "invalid-first-char";
95
86
  return "invalid-char";
96
87
  }
97
88
  return "valid";
98
89
  }
99
90
  function stringValue(expr) {
100
- if (expr === null || expr === void 0)
101
- return null;
102
- if (typeof expr === "object" && "str" in expr)
103
- return expr.str;
104
- if (typeof expr !== "string")
105
- return null;
106
- if (expr.length < 2)
107
- return null;
108
- if (expr[0] !== "'" || expr[expr.length - 1] !== "'")
109
- return null;
91
+ if (expr === null || expr === void 0) return null;
92
+ if (typeof expr === "object" && "str" in expr) return expr.str;
93
+ if (typeof expr !== "string") return null;
94
+ if (expr.length < 2) return null;
95
+ if (expr[0] !== "'" || expr[expr.length - 1] !== "'") return null;
110
96
  return expr.substring(1, expr.length - 1);
111
97
  }
112
98
  function head(expr) {
@@ -119,10 +105,8 @@ function head(expr) {
119
105
  }
120
106
  return expr[0];
121
107
  }
122
- if (expr === null || expr === void 0)
123
- return null;
124
- if (isFunctionObject(expr))
125
- return expr.fn[0];
108
+ if (expr === null || expr === void 0) return null;
109
+ if (isFunctionObject(expr)) return expr.fn[0];
126
110
  return null;
127
111
  }
128
112
  function headName(expr) {
@@ -130,21 +114,15 @@ function headName(expr) {
130
114
  return typeof h === "string" ? h : "";
131
115
  }
132
116
  function ops(expr) {
133
- if (Array.isArray(expr))
134
- return expr.slice(1);
135
- if (expr === null || expr === void 0)
136
- return null;
137
- if (isFunctionObject(expr))
138
- return expr.fn.slice(1);
117
+ if (Array.isArray(expr)) return expr.slice(1);
118
+ if (expr === null || expr === void 0) return null;
119
+ if (isFunctionObject(expr)) return expr.fn.slice(1);
139
120
  return null;
140
121
  }
141
122
  function op(expr, n) {
142
- if (Array.isArray(expr))
143
- return expr[n] ?? null;
144
- if (expr === null || expr === void 0)
145
- return null;
146
- if (isFunctionObject(expr))
147
- return expr.fn[n] ?? null;
123
+ if (Array.isArray(expr)) return expr[n] ?? null;
124
+ if (expr === null || expr === void 0) return null;
125
+ if (isFunctionObject(expr)) return expr.fn[n] ?? null;
148
126
  return null;
149
127
  }
150
128
  function op1(expr) {
@@ -154,54 +132,43 @@ function op2(expr) {
154
132
  return op(expr, 2);
155
133
  }
156
134
  function nops(expr) {
157
- if (expr === null || expr === void 0)
158
- return 0;
159
- if (Array.isArray(expr))
160
- return Math.max(0, expr.length - 1);
161
- if (isFunctionObject(expr))
162
- return Math.max(0, expr.fn.length - 1);
135
+ if (expr === null || expr === void 0) return 0;
136
+ if (Array.isArray(expr)) return Math.max(0, expr.length - 1);
137
+ if (isFunctionObject(expr)) return Math.max(0, expr.fn.length - 1);
163
138
  return 0;
164
139
  }
165
140
  function symbol(expr) {
166
141
  if (typeof expr === "string") {
167
- if (/^[+-]?[0-9\.]/.test(expr))
168
- return null;
142
+ if (/^[+-]?[0-9\.]/.test(expr)) return null;
169
143
  if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
170
144
  return null;
171
145
  return expr;
172
146
  }
173
- if (expr === null || expr === void 0)
174
- return null;
147
+ if (expr === null || expr === void 0) return null;
175
148
  const s = isSymbolObject(expr) ? expr.sym : expr;
176
- if (typeof s !== "string")
177
- return null;
149
+ if (typeof s !== "string") return null;
178
150
  return s;
179
151
  }
180
152
  function keyValuePair(expr) {
181
153
  const h = head(expr);
182
154
  if (h === "KeyValuePair" || h === "Tuple" || h === "Pair") {
183
155
  const key = stringValue(op1(expr));
184
- if (!key)
185
- return null;
156
+ if (!key) return null;
186
157
  return [key, op2(expr) ?? "Nothing"];
187
158
  }
188
159
  return null;
189
160
  }
190
161
  function dictionary(expr) {
191
- if (expr === null)
192
- return null;
193
- if (typeof expr === "object" && "dict" in expr)
194
- return expr.dict;
162
+ if (expr === null) return null;
163
+ if (typeof expr === "object" && "dict" in expr) return expr.dict;
195
164
  const kv = keyValuePair(expr);
196
- if (kv)
197
- return { [kv[0]]: kv[1] };
165
+ if (kv) return { [kv[0]]: kv[1] };
198
166
  const h = head(expr);
199
167
  if (h === "Dictionary") {
200
168
  const result = {};
201
169
  for (let i = 1; i < nops(expr); i++) {
202
170
  const kv2 = keyValuePair(op(expr, i));
203
- if (kv2)
204
- result[kv2[0]] = kv2[1];
171
+ if (kv2) result[kv2[0]] = kv2[1];
205
172
  }
206
173
  return result;
207
174
  }
@@ -210,26 +177,25 @@ function dictionary(expr) {
210
177
  function applyRecursively(expr, fn) {
211
178
  const h = head(expr);
212
179
  if (h !== null) {
213
- return [fn(h), ...(ops(expr) ?? []).map(fn)];
180
+ return [
181
+ fn(h),
182
+ ...(ops(expr) ?? []).map(fn)
183
+ ];
214
184
  }
215
185
  const dict = dictionary(expr);
216
186
  if (dict !== null) {
217
187
  const keys = Object.keys(dict);
218
188
  const result = {};
219
- for (const key of keys)
220
- result[key] = fn(dict[key]);
189
+ for (const key of keys) result[key] = fn(dict[key]);
221
190
  return { dict: result };
222
191
  }
223
192
  return fn(expr);
224
193
  }
225
194
  function mapArgs(expr, fn) {
226
195
  let args = null;
227
- if (Array.isArray(expr))
228
- args = expr;
229
- if (isFunctionObject(expr))
230
- args = expr.fn;
231
- if (args === null)
232
- return [];
196
+ if (Array.isArray(expr)) args = expr;
197
+ if (isFunctionObject(expr)) args = expr.fn;
198
+ if (args === null) return [];
233
199
  let i = 1;
234
200
  const result = [];
235
201
  while (i < args.length) {
@@ -240,7 +206,7 @@ function mapArgs(expr, fn) {
240
206
  }
241
207
 
242
208
  // src/math-json.ts
243
- var version = "0.24.1";
209
+ var version = "0.25.1";
244
210
  export {
245
211
  applyRecursively,
246
212
  dictionary as getDictionary,
package/dist/math-json.js CHANGED
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.24.1 */
1
+ /** MathJSON 0.25.1 */
2
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
3
  var MathJson = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -93,12 +93,9 @@ var MathJson = (() => {
93
93
  return recommendedScriptsRegex.test(text);
94
94
  }
95
95
  function isValidIdentifier(s) {
96
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))
97
- return true;
98
- if (ONLY_EMOJIS.test(s))
99
- return true;
100
- if (!isRecommendedScripts(s))
101
- return false;
96
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)) return true;
97
+ if (ONLY_EMOJIS.test(s)) return true;
98
+ if (!isRecommendedScripts(s)) return false;
102
99
  return /^[\p{XIDS}_]\p{XIDC}*$/u.test(s);
103
100
  }
104
101
  var VS16 = "\\u{FE0F}";
@@ -113,38 +110,27 @@ var MathJson = (() => {
113
110
  var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
114
111
  var ONLY_EMOJIS = new RegExp(`^(?:${POSSIBLE_EMOJI})+$`, "u");
115
112
  function validateIdentifier(s) {
116
- if (typeof s !== "string")
117
- return "not-a-string";
118
- if (s === "")
119
- return "empty-string";
120
- if (s.normalize() !== s)
121
- return "expected-nfc";
113
+ if (typeof s !== "string") return "not-a-string";
114
+ if (s === "") return "empty-string";
115
+ if (s.normalize() !== s) return "expected-nfc";
122
116
  if (/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(s))
123
117
  return "unexpected-bidi-marker";
124
- if (ONLY_EMOJIS.test(s))
125
- return "valid";
118
+ if (ONLY_EMOJIS.test(s)) return "valid";
126
119
  if (/\p{XIDC}/u.test(s) && SOME_EMOJI.test(s))
127
120
  return "unexpected-mixed-emoji";
128
- if (!isRecommendedScripts(s))
129
- return "unexpected-script";
121
+ if (!isRecommendedScripts(s)) return "unexpected-script";
130
122
  if (!isValidIdentifier(s)) {
131
- if (!isValidIdentifier(s[0]))
132
- return "invalid-first-char";
123
+ if (!isValidIdentifier(s[0])) return "invalid-first-char";
133
124
  return "invalid-char";
134
125
  }
135
126
  return "valid";
136
127
  }
137
128
  function stringValue(expr) {
138
- if (expr === null || expr === void 0)
139
- return null;
140
- if (typeof expr === "object" && "str" in expr)
141
- return expr.str;
142
- if (typeof expr !== "string")
143
- return null;
144
- if (expr.length < 2)
145
- return null;
146
- if (expr[0] !== "'" || expr[expr.length - 1] !== "'")
147
- return null;
129
+ if (expr === null || expr === void 0) return null;
130
+ if (typeof expr === "object" && "str" in expr) return expr.str;
131
+ if (typeof expr !== "string") return null;
132
+ if (expr.length < 2) return null;
133
+ if (expr[0] !== "'" || expr[expr.length - 1] !== "'") return null;
148
134
  return expr.substring(1, expr.length - 1);
149
135
  }
150
136
  function head(expr) {
@@ -157,10 +143,8 @@ var MathJson = (() => {
157
143
  }
158
144
  return expr[0];
159
145
  }
160
- if (expr === null || expr === void 0)
161
- return null;
162
- if (isFunctionObject(expr))
163
- return expr.fn[0];
146
+ if (expr === null || expr === void 0) return null;
147
+ if (isFunctionObject(expr)) return expr.fn[0];
164
148
  return null;
165
149
  }
166
150
  function headName(expr) {
@@ -168,21 +152,15 @@ var MathJson = (() => {
168
152
  return typeof h === "string" ? h : "";
169
153
  }
170
154
  function ops(expr) {
171
- if (Array.isArray(expr))
172
- return expr.slice(1);
173
- if (expr === null || expr === void 0)
174
- return null;
175
- if (isFunctionObject(expr))
176
- return expr.fn.slice(1);
155
+ if (Array.isArray(expr)) return expr.slice(1);
156
+ if (expr === null || expr === void 0) return null;
157
+ if (isFunctionObject(expr)) return expr.fn.slice(1);
177
158
  return null;
178
159
  }
179
160
  function op(expr, n) {
180
- if (Array.isArray(expr))
181
- return expr[n] ?? null;
182
- if (expr === null || expr === void 0)
183
- return null;
184
- if (isFunctionObject(expr))
185
- return expr.fn[n] ?? null;
161
+ if (Array.isArray(expr)) return expr[n] ?? null;
162
+ if (expr === null || expr === void 0) return null;
163
+ if (isFunctionObject(expr)) return expr.fn[n] ?? null;
186
164
  return null;
187
165
  }
188
166
  function op1(expr) {
@@ -192,54 +170,43 @@ var MathJson = (() => {
192
170
  return op(expr, 2);
193
171
  }
194
172
  function nops(expr) {
195
- if (expr === null || expr === void 0)
196
- return 0;
197
- if (Array.isArray(expr))
198
- return Math.max(0, expr.length - 1);
199
- if (isFunctionObject(expr))
200
- return Math.max(0, expr.fn.length - 1);
173
+ if (expr === null || expr === void 0) return 0;
174
+ if (Array.isArray(expr)) return Math.max(0, expr.length - 1);
175
+ if (isFunctionObject(expr)) return Math.max(0, expr.fn.length - 1);
201
176
  return 0;
202
177
  }
203
178
  function symbol(expr) {
204
179
  if (typeof expr === "string") {
205
- if (/^[+-]?[0-9\.]/.test(expr))
206
- return null;
180
+ if (/^[+-]?[0-9\.]/.test(expr)) return null;
207
181
  if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
208
182
  return null;
209
183
  return expr;
210
184
  }
211
- if (expr === null || expr === void 0)
212
- return null;
185
+ if (expr === null || expr === void 0) return null;
213
186
  const s = isSymbolObject(expr) ? expr.sym : expr;
214
- if (typeof s !== "string")
215
- return null;
187
+ if (typeof s !== "string") return null;
216
188
  return s;
217
189
  }
218
190
  function keyValuePair(expr) {
219
191
  const h = head(expr);
220
192
  if (h === "KeyValuePair" || h === "Tuple" || h === "Pair") {
221
193
  const key = stringValue(op1(expr));
222
- if (!key)
223
- return null;
194
+ if (!key) return null;
224
195
  return [key, op2(expr) ?? "Nothing"];
225
196
  }
226
197
  return null;
227
198
  }
228
199
  function dictionary(expr) {
229
- if (expr === null)
230
- return null;
231
- if (typeof expr === "object" && "dict" in expr)
232
- return expr.dict;
200
+ if (expr === null) return null;
201
+ if (typeof expr === "object" && "dict" in expr) return expr.dict;
233
202
  const kv = keyValuePair(expr);
234
- if (kv)
235
- return { [kv[0]]: kv[1] };
203
+ if (kv) return { [kv[0]]: kv[1] };
236
204
  const h = head(expr);
237
205
  if (h === "Dictionary") {
238
206
  const result = {};
239
207
  for (let i = 1; i < nops(expr); i++) {
240
208
  const kv2 = keyValuePair(op(expr, i));
241
- if (kv2)
242
- result[kv2[0]] = kv2[1];
209
+ if (kv2) result[kv2[0]] = kv2[1];
243
210
  }
244
211
  return result;
245
212
  }
@@ -248,26 +215,25 @@ var MathJson = (() => {
248
215
  function applyRecursively(expr, fn) {
249
216
  const h = head(expr);
250
217
  if (h !== null) {
251
- return [fn(h), ...(ops(expr) ?? []).map(fn)];
218
+ return [
219
+ fn(h),
220
+ ...(ops(expr) ?? []).map(fn)
221
+ ];
252
222
  }
253
223
  const dict = dictionary(expr);
254
224
  if (dict !== null) {
255
225
  const keys = Object.keys(dict);
256
226
  const result = {};
257
- for (const key of keys)
258
- result[key] = fn(dict[key]);
227
+ for (const key of keys) result[key] = fn(dict[key]);
259
228
  return { dict: result };
260
229
  }
261
230
  return fn(expr);
262
231
  }
263
232
  function mapArgs(expr, fn) {
264
233
  let args = null;
265
- if (Array.isArray(expr))
266
- args = expr;
267
- if (isFunctionObject(expr))
268
- args = expr.fn;
269
- if (args === null)
270
- return [];
234
+ if (Array.isArray(expr)) args = expr;
235
+ if (isFunctionObject(expr)) args = expr.fn;
236
+ if (args === null) return [];
271
237
  let i = 1;
272
238
  const result = [];
273
239
  while (i < args.length) {
@@ -278,7 +244,7 @@ var MathJson = (() => {
278
244
  }
279
245
 
280
246
  // src/math-json.ts
281
- var version = "0.24.1";
247
+ var version = "0.25.1";
282
248
  return __toCommonJS(math_json_exports);
283
249
  })();
284
250
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.24.1 */
1
+ /** Compute Engine 0.25.1 */
2
2
 
3
3
  // src/math-json/utils.ts
4
4
  function isSymbolObject(expr) {
@@ -55,12 +55,9 @@ function isRecommendedScripts(text) {
55
55
  return recommendedScriptsRegex.test(text);
56
56
  }
57
57
  function isValidIdentifier(s) {
58
- if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s))
59
- return true;
60
- if (ONLY_EMOJIS.test(s))
61
- return true;
62
- if (!isRecommendedScripts(s))
63
- return false;
58
+ if (/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(s)) return true;
59
+ if (ONLY_EMOJIS.test(s)) return true;
60
+ if (!isRecommendedScripts(s)) return false;
64
61
  return /^[\p{XIDS}_]\p{XIDC}*$/u.test(s);
65
62
  }
66
63
  var VS16 = "\\u{FE0F}";
@@ -75,38 +72,27 @@ var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ}${ZWJ_ELEMENT})*`;
75
72
  var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
76
73
  var ONLY_EMOJIS = new RegExp(`^(?:${POSSIBLE_EMOJI})+$`, "u");
77
74
  function validateIdentifier(s) {
78
- if (typeof s !== "string")
79
- return "not-a-string";
80
- if (s === "")
81
- return "empty-string";
82
- if (s.normalize() !== s)
83
- return "expected-nfc";
75
+ if (typeof s !== "string") return "not-a-string";
76
+ if (s === "") return "empty-string";
77
+ if (s.normalize() !== s) return "expected-nfc";
84
78
  if (/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(s))
85
79
  return "unexpected-bidi-marker";
86
- if (ONLY_EMOJIS.test(s))
87
- return "valid";
80
+ if (ONLY_EMOJIS.test(s)) return "valid";
88
81
  if (/\p{XIDC}/u.test(s) && SOME_EMOJI.test(s))
89
82
  return "unexpected-mixed-emoji";
90
- if (!isRecommendedScripts(s))
91
- return "unexpected-script";
83
+ if (!isRecommendedScripts(s)) return "unexpected-script";
92
84
  if (!isValidIdentifier(s)) {
93
- if (!isValidIdentifier(s[0]))
94
- return "invalid-first-char";
85
+ if (!isValidIdentifier(s[0])) return "invalid-first-char";
95
86
  return "invalid-char";
96
87
  }
97
88
  return "valid";
98
89
  }
99
90
  function stringValue(expr) {
100
- if (expr === null || expr === void 0)
101
- return null;
102
- if (typeof expr === "object" && "str" in expr)
103
- return expr.str;
104
- if (typeof expr !== "string")
105
- return null;
106
- if (expr.length < 2)
107
- return null;
108
- if (expr[0] !== "'" || expr[expr.length - 1] !== "'")
109
- return null;
91
+ if (expr === null || expr === void 0) return null;
92
+ if (typeof expr === "object" && "str" in expr) return expr.str;
93
+ if (typeof expr !== "string") return null;
94
+ if (expr.length < 2) return null;
95
+ if (expr[0] !== "'" || expr[expr.length - 1] !== "'") return null;
110
96
  return expr.substring(1, expr.length - 1);
111
97
  }
112
98
  function head(expr) {
@@ -119,10 +105,8 @@ function head(expr) {
119
105
  }
120
106
  return expr[0];
121
107
  }
122
- if (expr === null || expr === void 0)
123
- return null;
124
- if (isFunctionObject(expr))
125
- return expr.fn[0];
108
+ if (expr === null || expr === void 0) return null;
109
+ if (isFunctionObject(expr)) return expr.fn[0];
126
110
  return null;
127
111
  }
128
112
  function headName(expr) {
@@ -130,21 +114,15 @@ function headName(expr) {
130
114
  return typeof h === "string" ? h : "";
131
115
  }
132
116
  function ops(expr) {
133
- if (Array.isArray(expr))
134
- return expr.slice(1);
135
- if (expr === null || expr === void 0)
136
- return null;
137
- if (isFunctionObject(expr))
138
- return expr.fn.slice(1);
117
+ if (Array.isArray(expr)) return expr.slice(1);
118
+ if (expr === null || expr === void 0) return null;
119
+ if (isFunctionObject(expr)) return expr.fn.slice(1);
139
120
  return null;
140
121
  }
141
122
  function op(expr, n) {
142
- if (Array.isArray(expr))
143
- return expr[n] ?? null;
144
- if (expr === null || expr === void 0)
145
- return null;
146
- if (isFunctionObject(expr))
147
- return expr.fn[n] ?? null;
123
+ if (Array.isArray(expr)) return expr[n] ?? null;
124
+ if (expr === null || expr === void 0) return null;
125
+ if (isFunctionObject(expr)) return expr.fn[n] ?? null;
148
126
  return null;
149
127
  }
150
128
  function op1(expr) {
@@ -154,54 +132,43 @@ function op2(expr) {
154
132
  return op(expr, 2);
155
133
  }
156
134
  function nops(expr) {
157
- if (expr === null || expr === void 0)
158
- return 0;
159
- if (Array.isArray(expr))
160
- return Math.max(0, expr.length - 1);
161
- if (isFunctionObject(expr))
162
- return Math.max(0, expr.fn.length - 1);
135
+ if (expr === null || expr === void 0) return 0;
136
+ if (Array.isArray(expr)) return Math.max(0, expr.length - 1);
137
+ if (isFunctionObject(expr)) return Math.max(0, expr.fn.length - 1);
163
138
  return 0;
164
139
  }
165
140
  function symbol(expr) {
166
141
  if (typeof expr === "string") {
167
- if (/^[+-]?[0-9\.]/.test(expr))
168
- return null;
142
+ if (/^[+-]?[0-9\.]/.test(expr)) return null;
169
143
  if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
170
144
  return null;
171
145
  return expr;
172
146
  }
173
- if (expr === null || expr === void 0)
174
- return null;
147
+ if (expr === null || expr === void 0) return null;
175
148
  const s = isSymbolObject(expr) ? expr.sym : expr;
176
- if (typeof s !== "string")
177
- return null;
149
+ if (typeof s !== "string") return null;
178
150
  return s;
179
151
  }
180
152
  function keyValuePair(expr) {
181
153
  const h = head(expr);
182
154
  if (h === "KeyValuePair" || h === "Tuple" || h === "Pair") {
183
155
  const key = stringValue(op1(expr));
184
- if (!key)
185
- return null;
156
+ if (!key) return null;
186
157
  return [key, op2(expr) ?? "Nothing"];
187
158
  }
188
159
  return null;
189
160
  }
190
161
  function dictionary(expr) {
191
- if (expr === null)
192
- return null;
193
- if (typeof expr === "object" && "dict" in expr)
194
- return expr.dict;
162
+ if (expr === null) return null;
163
+ if (typeof expr === "object" && "dict" in expr) return expr.dict;
195
164
  const kv = keyValuePair(expr);
196
- if (kv)
197
- return { [kv[0]]: kv[1] };
165
+ if (kv) return { [kv[0]]: kv[1] };
198
166
  const h = head(expr);
199
167
  if (h === "Dictionary") {
200
168
  const result = {};
201
169
  for (let i = 1; i < nops(expr); i++) {
202
170
  const kv2 = keyValuePair(op(expr, i));
203
- if (kv2)
204
- result[kv2[0]] = kv2[1];
171
+ if (kv2) result[kv2[0]] = kv2[1];
205
172
  }
206
173
  return result;
207
174
  }
@@ -210,26 +177,25 @@ function dictionary(expr) {
210
177
  function applyRecursively(expr, fn) {
211
178
  const h = head(expr);
212
179
  if (h !== null) {
213
- return [fn(h), ...(ops(expr) ?? []).map(fn)];
180
+ return [
181
+ fn(h),
182
+ ...(ops(expr) ?? []).map(fn)
183
+ ];
214
184
  }
215
185
  const dict = dictionary(expr);
216
186
  if (dict !== null) {
217
187
  const keys = Object.keys(dict);
218
188
  const result = {};
219
- for (const key of keys)
220
- result[key] = fn(dict[key]);
189
+ for (const key of keys) result[key] = fn(dict[key]);
221
190
  return { dict: result };
222
191
  }
223
192
  return fn(expr);
224
193
  }
225
194
  function mapArgs(expr, fn) {
226
195
  let args = null;
227
- if (Array.isArray(expr))
228
- args = expr;
229
- if (isFunctionObject(expr))
230
- args = expr.fn;
231
- if (args === null)
232
- return [];
196
+ if (Array.isArray(expr)) args = expr;
197
+ if (isFunctionObject(expr)) args = expr.fn;
198
+ if (args === null) return [];
233
199
  let i = 1;
234
200
  const result = [];
235
201
  while (i < args.length) {
@@ -240,7 +206,7 @@ function mapArgs(expr, fn) {
240
206
  }
241
207
 
242
208
  // src/math-json.ts
243
- var version = "0.24.1";
209
+ var version = "0.25.1";
244
210
  export {
245
211
  applyRecursively,
246
212
  dictionary as getDictionary,