@cortex-js/compute-engine 0.25.0 → 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 (110) hide show
  1. package/dist/compute-engine.esm.js +3185 -5191
  2. package/dist/compute-engine.js +3185 -5191
  3. package/dist/compute-engine.min.esm.js +10 -10
  4. package/dist/compute-engine.min.js +10 -10
  5. package/dist/math-json.esm.js +39 -76
  6. package/dist/math-json.js +39 -76
  7. package/dist/math-json.min.esm.js +39 -76
  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 +2 -1
  15. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  16. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  17. package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +1 -1
  18. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
  19. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  20. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  21. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  22. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  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 +1 -1
  25. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  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 +1 -1
  30. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  32. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/public.d.ts +54 -35
  34. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  37. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  38. package/dist/types/compute-engine/compile.d.ts +1 -1
  39. package/dist/types/compute-engine/compute-engine.d.ts +4 -3
  40. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  41. package/dist/types/compute-engine/domain-utils.d.ts +1 -1
  42. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  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 -1
  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 +1 -1
  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 +1 -1
  59. package/dist/types/compute-engine/latex-syntax/public.d.ts +1 -1
  60. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  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 +1 -1
  63. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  64. package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
  65. package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -2
  66. package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +2 -2
  67. package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -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 +1 -1
  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 -1
  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 +1 -1
  85. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -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 +1 -1
  89. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  90. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  91. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  92. package/dist/types/compute-engine/numerics/terms.d.ts +1 -1
  93. package/dist/types/compute-engine/public.d.ts +1 -1
  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 +1 -1
  97. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  98. package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
  99. package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
  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 +1 -1
  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 +2 -2
  106. package/dist/types/compute-engine.d.ts +2 -2
  107. package/dist/types/math-json/math-json-format.d.ts +1 -1
  108. package/dist/types/math-json/utils.d.ts +1 -1
  109. package/dist/types/math-json.d.ts +2 -2
  110. package/package.json +10 -10
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.25.0 */
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
  }
@@ -219,20 +186,16 @@ function applyRecursively(expr, fn) {
219
186
  if (dict !== null) {
220
187
  const keys = Object.keys(dict);
221
188
  const result = {};
222
- for (const key of keys)
223
- result[key] = fn(dict[key]);
189
+ for (const key of keys) result[key] = fn(dict[key]);
224
190
  return { dict: result };
225
191
  }
226
192
  return fn(expr);
227
193
  }
228
194
  function mapArgs(expr, fn) {
229
195
  let args = null;
230
- if (Array.isArray(expr))
231
- args = expr;
232
- if (isFunctionObject(expr))
233
- args = expr.fn;
234
- if (args === null)
235
- return [];
196
+ if (Array.isArray(expr)) args = expr;
197
+ if (isFunctionObject(expr)) args = expr.fn;
198
+ if (args === null) return [];
236
199
  let i = 1;
237
200
  const result = [];
238
201
  while (i < args.length) {
@@ -243,7 +206,7 @@ function mapArgs(expr, fn) {
243
206
  }
244
207
 
245
208
  // src/math-json.ts
246
- var version = "0.25.0";
209
+ var version = "0.25.1";
247
210
  export {
248
211
  applyRecursively,
249
212
  dictionary as getDictionary,
package/dist/math-json.js CHANGED
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.25.0 */
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
  }
@@ -257,20 +224,16 @@ var MathJson = (() => {
257
224
  if (dict !== null) {
258
225
  const keys = Object.keys(dict);
259
226
  const result = {};
260
- for (const key of keys)
261
- result[key] = fn(dict[key]);
227
+ for (const key of keys) result[key] = fn(dict[key]);
262
228
  return { dict: result };
263
229
  }
264
230
  return fn(expr);
265
231
  }
266
232
  function mapArgs(expr, fn) {
267
233
  let args = null;
268
- if (Array.isArray(expr))
269
- args = expr;
270
- if (isFunctionObject(expr))
271
- args = expr.fn;
272
- if (args === null)
273
- return [];
234
+ if (Array.isArray(expr)) args = expr;
235
+ if (isFunctionObject(expr)) args = expr.fn;
236
+ if (args === null) return [];
274
237
  let i = 1;
275
238
  const result = [];
276
239
  while (i < args.length) {
@@ -281,7 +244,7 @@ var MathJson = (() => {
281
244
  }
282
245
 
283
246
  // src/math-json.ts
284
- var version = "0.25.0";
247
+ var version = "0.25.1";
285
248
  return __toCommonJS(math_json_exports);
286
249
  })();
287
250
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.25.0 */
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
  }
@@ -219,20 +186,16 @@ function applyRecursively(expr, fn) {
219
186
  if (dict !== null) {
220
187
  const keys = Object.keys(dict);
221
188
  const result = {};
222
- for (const key of keys)
223
- result[key] = fn(dict[key]);
189
+ for (const key of keys) result[key] = fn(dict[key]);
224
190
  return { dict: result };
225
191
  }
226
192
  return fn(expr);
227
193
  }
228
194
  function mapArgs(expr, fn) {
229
195
  let args = null;
230
- if (Array.isArray(expr))
231
- args = expr;
232
- if (isFunctionObject(expr))
233
- args = expr.fn;
234
- if (args === null)
235
- return [];
196
+ if (Array.isArray(expr)) args = expr;
197
+ if (isFunctionObject(expr)) args = expr.fn;
198
+ if (args === null) return [];
236
199
  let i = 1;
237
200
  const result = [];
238
201
  while (i < args.length) {
@@ -243,7 +206,7 @@ function mapArgs(expr, fn) {
243
206
  }
244
207
 
245
208
  // src/math-json.ts
246
- var version = "0.25.0";
209
+ var version = "0.25.1";
247
210
  export {
248
211
  applyRecursively,
249
212
  dictionary as getDictionary,
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.25.0 */
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
- var MathJson=(()=>{var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var D=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},F=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!k.call(n,r)&&r!==e&&f(n,r,{get:()=>t[r],enumerable:!(i=T(t,r))||i.enumerable});return n};var R=n=>F(f({},"__esModule",{value:!0}),n);var z={};D(z,{applyRecursively:()=>A,getDictionary:()=>y,getStringValue:()=>m,head:()=>l,headName:()=>j,isDictionaryObject:()=>S,isFunctionObject:()=>u,isStringObject:()=>M,isSymbolObject:()=>d,mapArgs:()=>$,nops:()=>E,op:()=>s,symbol:()=>O,version:()=>X});function d(n){return n!==null&&typeof n=="object"&&"sym"in n}function M(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function S(n){return n!==null&&typeof n=="object"&&"dict"in n}var c;function I(n){if(!c){let e=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;c=new RegExp(e,"u")}return c.test(n)}function a(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||N.test(n)?!0:I(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}var _="\\u{FE0F}",V="\\u{20E3}",L="\\u{200D}",P="\\p{RI}\\p{RI}",w="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",b=`(?:\\p{EMod}|${_}${V}?|${w})`,C="(?:(?=\\P{XIDC})\\p{Emoji})",h=`(?:${C}${b}*|\\p{Emoji}${b}+|${P})`,J=`(?:${h})(${L}${h})*`,G=new RegExp(`(?:${J})+`,"u"),N=new RegExp(`^(?:${J})+$`,"u");function q(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":N.test(n)?"valid":/\p{XIDC}/u.test(n)&&G.test(n)?"unexpected-mixed-emoji":I(n)?a(n)?"valid":a(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}function m(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n[0]!=="'"||n[n.length-1]!=="'"?null:n.substring(1,n.length-1)}function l(n){return Array.isArray(n)?typeof n[0]=="string"&&!a(n[0])?(console.error(`Invalid identifier "${n[0]}": ${q(n[0])}`),null):n[0]:n==null?null:u(n)?n.fn[0]:null}function j(n){let t=l(n);return typeof t=="string"?t:""}function H(n){return Array.isArray(n)?n.slice(1):n==null?null:u(n)?n.fn.slice(1):null}function s(n,t){return Array.isArray(n)?n[t]??null:n==null?null:u(n)?n.fn[t]??null:null}function K(n){return s(n,1)}function Z(n){return s(n,2)}function E(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 O(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=d(n)?n.sym:n;return typeof t!="string"?null:t}function p(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let e=m(K(n));return e?[e,Z(n)??"Nothing"]:null}return null}function y(n){if(n===null)return null;if(typeof n=="object"&&"dict"in n)return n.dict;let t=p(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={};for(let r=1;r<E(n);r++){let o=p(s(n,r));o&&(i[o[0]]=o[1])}return i}return null}function A(n,t){let e=l(n);if(e!==null)return[t(e),...(H(n)??[]).map(t)];let i=y(n);if(i!==null){let r=Object.keys(i),o={};for(let g of r)o[g]=t(i[g]);return{dict:o}}return t(n)}function $(n,t){let e=null;if(Array.isArray(n)&&(e=n),u(n)&&(e=n.fn),e===null)return[];let i=1,r=[];for(;i<e.length;)r.push(t(e[i])),i+=1;return r}var X="0.25.0";return R(z);})();
3
+ var MathJson=(()=>{var f=Object.defineProperty;var T=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var D=(n,t)=>{for(var e in t)f(n,e,{get:t[e],enumerable:!0})},F=(n,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of v(t))!k.call(n,r)&&r!==e&&f(n,r,{get:()=>t[r],enumerable:!(i=T(t,r))||i.enumerable});return n};var R=n=>F(f({},"__esModule",{value:!0}),n);var z={};D(z,{applyRecursively:()=>A,getDictionary:()=>y,getStringValue:()=>m,head:()=>l,headName:()=>j,isDictionaryObject:()=>S,isFunctionObject:()=>u,isStringObject:()=>M,isSymbolObject:()=>d,mapArgs:()=>$,nops:()=>E,op:()=>s,symbol:()=>O,version:()=>X});function d(n){return n!==null&&typeof n=="object"&&"sym"in n}function M(n){return n!==null&&typeof n=="object"&&"str"in n}function u(n){return n!==null&&typeof n=="object"&&"fn"in n}function S(n){return n!==null&&typeof n=="object"&&"dict"in n}var c;function I(n){if(!c){let e=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;c=new RegExp(e,"u")}return c.test(n)}function a(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||N.test(n)?!0:I(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}var _="\\u{FE0F}",V="\\u{20E3}",L="\\u{200D}",P="\\p{RI}\\p{RI}",w="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",b=`(?:\\p{EMod}|${_}${V}?|${w})`,C="(?:(?=\\P{XIDC})\\p{Emoji})",h=`(?:${C}${b}*|\\p{Emoji}${b}+|${P})`,J=`(?:${h})(${L}${h})*`,G=new RegExp(`(?:${J})+`,"u"),N=new RegExp(`^(?:${J})+$`,"u");function q(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":N.test(n)?"valid":/\p{XIDC}/u.test(n)&&G.test(n)?"unexpected-mixed-emoji":I(n)?a(n)?"valid":a(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}function m(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"||n.length<2||n[0]!=="'"||n[n.length-1]!=="'"?null:n.substring(1,n.length-1)}function l(n){return Array.isArray(n)?typeof n[0]=="string"&&!a(n[0])?(console.error(`Invalid identifier "${n[0]}": ${q(n[0])}`),null):n[0]:n==null?null:u(n)?n.fn[0]:null}function j(n){let t=l(n);return typeof t=="string"?t:""}function H(n){return Array.isArray(n)?n.slice(1):n==null?null:u(n)?n.fn.slice(1):null}function s(n,t){return Array.isArray(n)?n[t]??null:n==null?null:u(n)?n.fn[t]??null:null}function K(n){return s(n,1)}function Z(n){return s(n,2)}function E(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 O(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=d(n)?n.sym:n;return typeof t!="string"?null:t}function p(n){let t=l(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let e=m(K(n));return e?[e,Z(n)??"Nothing"]:null}return null}function y(n){if(n===null)return null;if(typeof n=="object"&&"dict"in n)return n.dict;let t=p(n);if(t)return{[t[0]]:t[1]};if(l(n)==="Dictionary"){let i={};for(let r=1;r<E(n);r++){let o=p(s(n,r));o&&(i[o[0]]=o[1])}return i}return null}function A(n,t){let e=l(n);if(e!==null)return[t(e),...(H(n)??[]).map(t)];let i=y(n);if(i!==null){let r=Object.keys(i),o={};for(let g of r)o[g]=t(i[g]);return{dict:o}}return t(n)}function $(n,t){let e=null;if(Array.isArray(n)&&(e=n),u(n)&&(e=n.fn),e===null)return[];let i=1,r=[];for(;i<e.length;)r.push(t(e[i])),i+=1;return r}var X="0.25.1";return R(z);})();
4
4
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  export declare const BLACK = "\u001B[30;1m${s}";
3
3
  export declare const GREY = "\u001B[30;1m${s}";
4
4
  export declare const GREEN = "\u001B[32;1m";
@@ -1,4 +1,4 @@
1
- /* 0.25.0 */
1
+ /* 0.25.1 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *