@cortex-js/compute-engine 0.12.2 → 0.12.4
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.
- package/README.md +2 -2
- package/dist/compute-engine.esm.js +24348 -28196
- package/dist/compute-engine.js +24523 -0
- package/dist/compute-engine.min.esm.js +24506 -2
- package/dist/compute-engine.min.js +24519 -2
- package/dist/math-json.esm.js +256 -185
- package/dist/math-json.js +283 -0
- package/dist/math-json.min.esm.js +258 -2
- package/dist/math-json.min.js +283 -2
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compute-engine/assume.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +3 -1
- package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +3 -2
- package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +3 -2
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +1 -2
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/domain-utils.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-inequalities.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +2 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +25 -16
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +15 -0
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +28 -33
- package/dist/types/compute-engine/latex-syntax/public.d.ts +62 -65
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +10 -6
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +2 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +3 -2
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +2 -2
- package/dist/types/compute-engine/library/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/library/calculus.d.ts +1 -1
- package/dist/types/compute-engine/library/collections.d.ts +1 -1
- package/dist/types/compute-engine/library/core.d.ts +1 -1
- package/dist/types/compute-engine/library/domains.d.ts +1 -1
- package/dist/types/compute-engine/library/library.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
- package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
- package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
- package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +17 -7
- package/dist/types/compute-engine/rules.d.ts +1 -1
- package/dist/types/compute-engine/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/solve.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +18 -10
- package/dist/types/compute-engine/symbolic/flatten.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/negate.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/product.d.ts +4 -1
- package/dist/types/compute-engine/symbolic/sum.d.ts +2 -1
- package/dist/types/compute-engine/symbolic/utils.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -2
- package/dist/types/math-json/math-json-format.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +4 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +5 -14
package/dist/math-json.min.js
CHANGED
|
@@ -1,2 +1,283 @@
|
|
|
1
|
-
/** MathJSON 0.12.
|
|
2
|
-
|
|
1
|
+
/** CortexJS MathJSON 0.12.4 */
|
|
2
|
+
(function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
|
|
3
|
+
var MathJson = (() => {
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/math-json.ts
|
|
23
|
+
var math_json_exports = {};
|
|
24
|
+
__export(math_json_exports, {
|
|
25
|
+
applyRecursively: () => applyRecursively,
|
|
26
|
+
getDictionary: () => dictionary,
|
|
27
|
+
getStringValue: () => stringValue,
|
|
28
|
+
head: () => head,
|
|
29
|
+
headName: () => headName,
|
|
30
|
+
isDictionaryObject: () => isDictionaryObject,
|
|
31
|
+
isFunctionObject: () => isFunctionObject,
|
|
32
|
+
isStringObject: () => isStringObject,
|
|
33
|
+
isSymbolObject: () => isSymbolObject,
|
|
34
|
+
mapArgs: () => mapArgs,
|
|
35
|
+
nops: () => nops,
|
|
36
|
+
op: () => op,
|
|
37
|
+
symbol: () => symbol,
|
|
38
|
+
version: () => version
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// src/math-json/utils.ts
|
|
42
|
+
function isSymbolObject(expr) {
|
|
43
|
+
return expr !== null && typeof expr === "object" && "sym" in expr;
|
|
44
|
+
}
|
|
45
|
+
function isStringObject(expr) {
|
|
46
|
+
return expr !== null && typeof expr === "object" && "str" in expr;
|
|
47
|
+
}
|
|
48
|
+
function isFunctionObject(expr) {
|
|
49
|
+
return expr !== null && typeof expr === "object" && "fn" in expr;
|
|
50
|
+
}
|
|
51
|
+
function isDictionaryObject(expr) {
|
|
52
|
+
return expr !== null && typeof expr === "object" && "dict" in expr;
|
|
53
|
+
}
|
|
54
|
+
var recommendedScriptsRegex;
|
|
55
|
+
function isRecommendedScripts(text) {
|
|
56
|
+
if (!recommendedScriptsRegex) {
|
|
57
|
+
const recommendedScripts = [
|
|
58
|
+
"Zyyy",
|
|
59
|
+
"Zinh",
|
|
60
|
+
"Arab",
|
|
61
|
+
"Armn",
|
|
62
|
+
"Beng",
|
|
63
|
+
"Bopo",
|
|
64
|
+
"Cyrl",
|
|
65
|
+
"Deva",
|
|
66
|
+
"Ethi",
|
|
67
|
+
"Geor",
|
|
68
|
+
"Grek",
|
|
69
|
+
"Gujr",
|
|
70
|
+
"Guru",
|
|
71
|
+
"Hang",
|
|
72
|
+
"Hani",
|
|
73
|
+
"Hebr",
|
|
74
|
+
"Hira",
|
|
75
|
+
"Kana",
|
|
76
|
+
"Knda",
|
|
77
|
+
"Khmr",
|
|
78
|
+
"Laoo",
|
|
79
|
+
"Latn",
|
|
80
|
+
"Mlym",
|
|
81
|
+
"Mymr",
|
|
82
|
+
"Orya",
|
|
83
|
+
"Sinh",
|
|
84
|
+
"Taml",
|
|
85
|
+
"Telu",
|
|
86
|
+
"Thaa",
|
|
87
|
+
"Thai",
|
|
88
|
+
"Tibt"
|
|
89
|
+
];
|
|
90
|
+
const regexPattern = `^[${recommendedScripts.map((x) => `\\p{Script=${x}}`).join("")}]*$`;
|
|
91
|
+
recommendedScriptsRegex = new RegExp(regexPattern, "u");
|
|
92
|
+
}
|
|
93
|
+
return recommendedScriptsRegex.test(text);
|
|
94
|
+
}
|
|
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;
|
|
102
|
+
return /^[\p{XIDS}_]\p{XIDC}*$/u.test(s);
|
|
103
|
+
}
|
|
104
|
+
var VS16 = "\\u{FE0F}";
|
|
105
|
+
var KEYCAP = "\\u{20E3}";
|
|
106
|
+
var ZWJ = "\\u{200D}";
|
|
107
|
+
var FLAG_SEQUENCE = "\\p{RI}\\p{RI}";
|
|
108
|
+
var TAG_MOD = `(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})`;
|
|
109
|
+
var EMOJI_MOD = `(?:\\p{EMod}|${VS16}${KEYCAP}?|${TAG_MOD})`;
|
|
110
|
+
var EMOJI_NOT_IDENTIFIER = `(?:(?=\\P{XIDC})\\p{Emoji})`;
|
|
111
|
+
var ZWJ_ELEMENT = `(?:${EMOJI_NOT_IDENTIFIER}${EMOJI_MOD}*|\\p{Emoji}${EMOJI_MOD}+|${FLAG_SEQUENCE})`;
|
|
112
|
+
var POSSIBLE_EMOJI = `(?:${ZWJ_ELEMENT})(${ZWJ}${ZWJ_ELEMENT})*`;
|
|
113
|
+
var SOME_EMOJI = new RegExp(`(?:${POSSIBLE_EMOJI})+`, "u");
|
|
114
|
+
var ONLY_EMOJIS = new RegExp(`^(?:${POSSIBLE_EMOJI})+$`, "u");
|
|
115
|
+
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";
|
|
122
|
+
if (/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(s))
|
|
123
|
+
return "unexpected-bidi-marker";
|
|
124
|
+
if (ONLY_EMOJIS.test(s))
|
|
125
|
+
return "valid";
|
|
126
|
+
if (/\p{XIDC}/u.test(s) && SOME_EMOJI.test(s))
|
|
127
|
+
return "unexpected-mixed-emoji";
|
|
128
|
+
if (!isRecommendedScripts(s))
|
|
129
|
+
return "unexpected-script";
|
|
130
|
+
if (!isValidIdentifier(s)) {
|
|
131
|
+
if (!isValidIdentifier(s[0]))
|
|
132
|
+
return "invalid-first-char";
|
|
133
|
+
return "invalid-char";
|
|
134
|
+
}
|
|
135
|
+
return "valid";
|
|
136
|
+
}
|
|
137
|
+
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;
|
|
148
|
+
return expr.substring(1, expr.length - 1);
|
|
149
|
+
}
|
|
150
|
+
function head(expr) {
|
|
151
|
+
if (expr === null || expr === void 0)
|
|
152
|
+
return null;
|
|
153
|
+
if (Array.isArray(expr)) {
|
|
154
|
+
if (typeof expr[0] === "string" && !isValidIdentifier(expr[0])) {
|
|
155
|
+
console.error(
|
|
156
|
+
`Invalid identifier "${expr[0]}": ${validateIdentifier(expr[0])}`
|
|
157
|
+
);
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
return expr[0];
|
|
161
|
+
}
|
|
162
|
+
if (isFunctionObject(expr))
|
|
163
|
+
return expr.fn[0];
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
function headName(expr) {
|
|
167
|
+
const h = head(expr);
|
|
168
|
+
return typeof h === "string" ? h : "";
|
|
169
|
+
}
|
|
170
|
+
function ops(expr) {
|
|
171
|
+
if (expr === null || expr === void 0)
|
|
172
|
+
return null;
|
|
173
|
+
if (Array.isArray(expr))
|
|
174
|
+
return expr.slice(1);
|
|
175
|
+
if (isFunctionObject(expr))
|
|
176
|
+
return expr.fn.slice(1);
|
|
177
|
+
return null;
|
|
178
|
+
}
|
|
179
|
+
function op(expr, n) {
|
|
180
|
+
if (expr === null || expr === void 0)
|
|
181
|
+
return null;
|
|
182
|
+
if (Array.isArray(expr))
|
|
183
|
+
return expr[n] ?? null;
|
|
184
|
+
if (isFunctionObject(expr))
|
|
185
|
+
return expr.fn[n] ?? null;
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
function op1(expr) {
|
|
189
|
+
return op(expr, 1);
|
|
190
|
+
}
|
|
191
|
+
function op2(expr) {
|
|
192
|
+
return op(expr, 2);
|
|
193
|
+
}
|
|
194
|
+
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);
|
|
201
|
+
return 0;
|
|
202
|
+
}
|
|
203
|
+
function symbol(expr) {
|
|
204
|
+
if (expr === null || expr === void 0)
|
|
205
|
+
return null;
|
|
206
|
+
if (typeof expr === "string") {
|
|
207
|
+
if (/^[+\-\.0-9]/.test(expr))
|
|
208
|
+
return null;
|
|
209
|
+
if (expr.length >= 2 && expr[0] === "'" && expr[expr.length - 1] === "'")
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
const s = isSymbolObject(expr) ? expr.sym : expr;
|
|
213
|
+
if (typeof s !== "string")
|
|
214
|
+
return null;
|
|
215
|
+
return s;
|
|
216
|
+
}
|
|
217
|
+
function keyValuePair(expr) {
|
|
218
|
+
const h = head(expr);
|
|
219
|
+
if (h === "KeyValuePair" || h === "Tuple" || h === "Pair") {
|
|
220
|
+
const key = stringValue(op1(expr));
|
|
221
|
+
if (!key)
|
|
222
|
+
return null;
|
|
223
|
+
return [key, op2(expr) ?? "Nothing"];
|
|
224
|
+
}
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
function dictionary(expr) {
|
|
228
|
+
if (expr === null)
|
|
229
|
+
return null;
|
|
230
|
+
if (typeof expr === "object" && "dict" in expr)
|
|
231
|
+
return expr.dict;
|
|
232
|
+
const kv = keyValuePair(expr);
|
|
233
|
+
if (kv)
|
|
234
|
+
return { [kv[0]]: kv[1] };
|
|
235
|
+
const h = head(expr);
|
|
236
|
+
if (h === "Dictionary") {
|
|
237
|
+
const result = {};
|
|
238
|
+
for (let i = 1; i < nops(expr); i++) {
|
|
239
|
+
const kv2 = keyValuePair(op(expr, i));
|
|
240
|
+
if (kv2)
|
|
241
|
+
result[kv2[0]] = kv2[1];
|
|
242
|
+
}
|
|
243
|
+
return result;
|
|
244
|
+
}
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
function applyRecursively(expr, fn) {
|
|
248
|
+
const h = head(expr);
|
|
249
|
+
if (h !== null) {
|
|
250
|
+
return [fn(h), ...(ops(expr) ?? []).map(fn)];
|
|
251
|
+
}
|
|
252
|
+
const dict = dictionary(expr);
|
|
253
|
+
if (dict !== null) {
|
|
254
|
+
const keys = Object.keys(dict);
|
|
255
|
+
const result = {};
|
|
256
|
+
for (const key of keys)
|
|
257
|
+
result[key] = fn(dict[key]);
|
|
258
|
+
return { dict: result };
|
|
259
|
+
}
|
|
260
|
+
return fn(expr);
|
|
261
|
+
}
|
|
262
|
+
function mapArgs(expr, fn) {
|
|
263
|
+
let args = null;
|
|
264
|
+
if (Array.isArray(expr))
|
|
265
|
+
args = expr;
|
|
266
|
+
if (isFunctionObject(expr))
|
|
267
|
+
args = expr.fn;
|
|
268
|
+
if (args === null)
|
|
269
|
+
return [];
|
|
270
|
+
let i = 1;
|
|
271
|
+
const result = [];
|
|
272
|
+
while (i < args.length) {
|
|
273
|
+
result.push(fn(args[i]));
|
|
274
|
+
i += 1;
|
|
275
|
+
}
|
|
276
|
+
return result;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// src/math-json.ts
|
|
280
|
+
var version = "0.12.4";
|
|
281
|
+
return __toCommonJS(math_json_exports);
|
|
282
|
+
})();
|
|
283
|
+
Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
|
|
3
3
|
export type SignalMessage = SignalCode | [SignalCode, ...any[]];
|
|
4
4
|
export type SignalOrigin = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
4
|
import { BoxedExpression, BoxedFunctionDefinition, BoxedRuleSet, BoxedSymbolDefinition, BoxedDomain, EvaluateOptions, IComputeEngine, LatexString, Metadata, NOptions, PatternMatchOptions, SemiBoxedExpression, SimplifyOptions, Substitution, RuntimeScope, DomainCompatibility, DomainLiteral, BoxedBaseDefinition, Rational, BoxedSubstitution } from '../public';
|
|
@@ -30,6 +30,8 @@ export declare abstract class AbstractBoxedExpression implements BoxedExpression
|
|
|
30
30
|
[Symbol.toPrimitive](hint: 'number' | 'string' | 'default'): number | string | null;
|
|
31
31
|
/** Called by `JSON.stringify()` when serializing to json */
|
|
32
32
|
toJSON(): Expression;
|
|
33
|
+
/** @internal */
|
|
34
|
+
get rawJson(): Expression;
|
|
33
35
|
get scope(): RuntimeScope | null;
|
|
34
36
|
/** Object.is() */
|
|
35
37
|
is(rhs: any): boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { BoxedExpression, IComputeEngine, EvaluateOptions, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, ReplaceOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, BoxedSubstitution } from '../public';
|
|
3
3
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { BoxedDomain, BoxedExpression, BoxedSubstitution, DomainCompatibility, DomainConstructor, DomainExpression, DomainLiteral, IComputeEngine, Metadata, PatternMatchOptions } from '../public';
|
|
3
3
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
4
4
|
/**
|
|
@@ -43,8 +43,9 @@ export declare class _BoxedDomain extends AbstractBoxedExpression implements Box
|
|
|
43
43
|
* Note that `boxDomain()` should only be called from `ComputeEngine`.
|
|
44
44
|
* This gives a chance for `ComputeEngine` to substitute cached objects.
|
|
45
45
|
*/
|
|
46
|
-
export declare function boxDomain(ce: IComputeEngine, dom:
|
|
46
|
+
export declare function boxDomain(ce: IComputeEngine, dom: BoxedExpression | DomainExpression, metadata?: Metadata): BoxedDomain;
|
|
47
47
|
/** Validate that `expr` is a Domain */
|
|
48
48
|
export declare function isDomain(expr: Expression | BoxedExpression | BoxedDomain | DomainExpression): expr is BoxedDomain | DomainExpression;
|
|
49
|
+
export declare function isValidDomain(expr: any): expr is BoxedDomain | DomainExpression;
|
|
49
50
|
/** Return the ancestor domain that is shared by both `a` and `b` */
|
|
50
51
|
export declare function sharedAncestorDomain(a: BoxedDomain, b: BoxedDomain): BoxedDomain;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare function makeFunctionDefinition(engine: IComputeEngine, name: string, def: FunctionDefinition | BoxedFunctionDefinition): BoxedFunctionDefinition;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
|
-
import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine,
|
|
3
|
+
import { BoxedExpression, BoxedFunctionDefinition, IComputeEngine, NOptions, BoxedRuleSet, SemiBoxedExpression, SimplifyOptions, Substitution, ReplaceOptions, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedSubstitution, EvaluateOptions } from '../public';
|
|
4
4
|
/**
|
|
5
5
|
* BoxedFunction
|
|
6
6
|
*/
|
|
@@ -29,6 +29,7 @@ export declare class BoxedFunction extends AbstractBoxedExpression {
|
|
|
29
29
|
set isCanonical(val: boolean);
|
|
30
30
|
get isPure(): boolean;
|
|
31
31
|
get json(): Expression;
|
|
32
|
+
get rawJson(): Expression;
|
|
32
33
|
get scope(): RuntimeScope | null;
|
|
33
34
|
get head(): string | BoxedExpression;
|
|
34
35
|
get ops(): BoxedExpression[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression } from '../../math-json/math-json-format';
|
|
4
4
|
import { BoxedExpression, BoxedDomain, IComputeEngine, Metadata, NOptions, PatternMatchOptions, Rational, SimplifyOptions, BoxedSubstitution } from '../public';
|
|
@@ -35,7 +35,7 @@ export declare class BoxedNumber extends AbstractBoxedExpression {
|
|
|
35
35
|
set isCanonical(val: boolean);
|
|
36
36
|
get complexity(): number;
|
|
37
37
|
get value(): BoxedExpression;
|
|
38
|
-
get numericValue(): number | Decimal | Complex | Rational
|
|
38
|
+
get numericValue(): number | Decimal | Complex | Rational;
|
|
39
39
|
get domain(): BoxedDomain;
|
|
40
40
|
get json(): Expression;
|
|
41
41
|
get sgn(): -1 | 0 | 1 | undefined | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedExpression, BoxedSubstitution, BoxedDomain, IComputeEngine, LatexString, Metadata, Pattern, PatternMatchOptions, SemiBoxedExpression, Substitution } from '../public';
|
|
4
4
|
export declare class BoxedPattern extends AbstractBoxedExpression implements Pattern {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { AbstractBoxedExpression } from './abstract-boxed-expression';
|
|
3
3
|
import { BoxedExpression, BoxedRuleSet, BoxedSymbolDefinition, IComputeEngine, EvaluateOptions, NOptions, ReplaceOptions, SimplifyOptions, Substitution, Metadata, PatternMatchOptions, BoxedDomain, RuntimeScope, BoxedFunctionDefinition, BoxedBaseDefinition, DomainExpression, BoxedSubstitution } from '../public';
|
|
4
4
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { Complex } from 'complex.js';
|
|
3
3
|
import { Expression, MathJsonNumber } from '../math-json/math-json-format';
|
|
4
4
|
import type { LibraryCategory, LatexDictionary, LatexDictionaryEntry, LatexString, NumberFormattingOptions, ParseLatexOptions, SerializeLatexOptions } from './latex-syntax/public';
|
|
@@ -282,7 +282,6 @@ export declare class ComputeEngine implements IComputeEngine {
|
|
|
282
282
|
fn(head: string, ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
283
283
|
/** @internal */
|
|
284
284
|
_fn(head: string | BoxedExpression, ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
285
|
-
error(message: ['invalid-domain', ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedDomain;
|
|
286
285
|
error(message: string | [string, ...SemiBoxedExpression[]], where?: SemiBoxedExpression): BoxedExpression;
|
|
287
286
|
hold(expr: SemiBoxedExpression): BoxedExpression;
|
|
288
287
|
add(ops: BoxedExpression[], metadata?: Metadata): BoxedExpression;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_CALCULUS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_CORE: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_INEQUALITIES: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_LOGIC: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_OTHERS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_SETS: LatexDictionary;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
|
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
/* 0.12.
|
|
1
|
+
/* 0.12.4 */
|
|
2
2
|
import { WarningSignal } from '../../../common/signals';
|
|
3
3
|
export type CommonEntry = {
|
|
4
4
|
name?: string;
|
|
5
5
|
serialize: SerializeHandler | LatexString;
|
|
6
6
|
};
|
|
7
|
-
export type
|
|
8
|
-
kind: '
|
|
7
|
+
export type IndexedIdentifierEntry = CommonEntry & {
|
|
8
|
+
kind: 'identifier';
|
|
9
9
|
precedence: number;
|
|
10
|
-
parse:
|
|
10
|
+
parse: IdentifierParseHandler;
|
|
11
11
|
};
|
|
12
|
-
|
|
12
|
+
/**
|
|
13
|
+
* A function has the following form:
|
|
14
|
+
* - a prefix such as `\mathrm` or `\operatorname`
|
|
15
|
+
* - a trigger string, such as `gcd`
|
|
16
|
+
* - some postfix operators such as `\prime`
|
|
17
|
+
* - an optional list of arguments in an enclosure (parentheses)
|
|
18
|
+
*
|
|
19
|
+
* Functions of this type are indexed in the dictionary by their trigger string.
|
|
20
|
+
*/
|
|
21
|
+
export type IndexedFunctionEntry = CommonEntry & {
|
|
13
22
|
kind: 'function';
|
|
14
23
|
parse: FunctionParseHandler;
|
|
15
24
|
};
|
|
16
|
-
export type
|
|
25
|
+
export type IndexedMatchfixEntry = CommonEntry & {
|
|
17
26
|
kind: 'matchfix';
|
|
18
27
|
openDelimiter: Delimiter | LatexToken[];
|
|
19
28
|
closeDelimiter: Delimiter | LatexToken[];
|
|
20
29
|
parse: MatchfixParseHandler;
|
|
21
30
|
};
|
|
22
|
-
export type
|
|
31
|
+
export type IndexedInfixEntry = CommonEntry & {
|
|
23
32
|
kind: 'infix';
|
|
24
33
|
associativity: 'right' | 'left' | 'non' | 'both';
|
|
25
34
|
precedence: number;
|
|
26
35
|
parse: InfixParseHandler;
|
|
27
36
|
};
|
|
28
|
-
export type
|
|
37
|
+
export type IndexedPrefixEntry = CommonEntry & {
|
|
29
38
|
kind: 'prefix';
|
|
30
39
|
precedence: number;
|
|
31
40
|
parse: PrefixParseHandler;
|
|
32
41
|
};
|
|
33
|
-
export type
|
|
42
|
+
export type IndexedPostfixEntry = CommonEntry & {
|
|
34
43
|
kind: 'postfix';
|
|
35
44
|
precedence: number;
|
|
36
45
|
parse: PostfixParseHandler;
|
|
@@ -39,16 +48,16 @@ export type EnvironmentEntry = CommonEntry & {
|
|
|
39
48
|
kind: 'environment';
|
|
40
49
|
parse: EnvironmentParseHandler;
|
|
41
50
|
};
|
|
42
|
-
export type IndexedLatexDictionaryEntry =
|
|
51
|
+
export type IndexedLatexDictionaryEntry = IndexedFunctionEntry | IndexedIdentifierEntry | IndexedMatchfixEntry | IndexedInfixEntry | IndexedPrefixEntry | IndexedPostfixEntry | EnvironmentEntry;
|
|
43
52
|
export type IndexedLatexDictionary = {
|
|
44
53
|
lookahead: number;
|
|
45
54
|
name: Map<string, IndexedLatexDictionaryEntry>;
|
|
46
|
-
function: Map<string,
|
|
47
|
-
|
|
48
|
-
prefix: (Map<LatexString,
|
|
49
|
-
infix: (Map<LatexString,
|
|
50
|
-
postfix: (Map<LatexString,
|
|
51
|
-
matchfix:
|
|
55
|
+
function: Map<string, IndexedFunctionEntry[]>;
|
|
56
|
+
identifier: (Map<LatexString, IndexedIdentifierEntry[]> | null)[];
|
|
57
|
+
prefix: (Map<LatexString, IndexedPrefixEntry[]> | null)[];
|
|
58
|
+
infix: (Map<LatexString, IndexedInfixEntry[]> | null)[];
|
|
59
|
+
postfix: (Map<LatexString, IndexedPostfixEntry[]> | null)[];
|
|
60
|
+
matchfix: IndexedMatchfixEntry[];
|
|
52
61
|
environment: Map<string, EnvironmentEntry>;
|
|
53
62
|
};
|
|
54
63
|
export declare function indexLatexDictionary(dic: readonly LatexDictionaryEntry[], onError: (sig: WarningSignal) => void): IndexedLatexDictionary;
|