@cortex-js/compute-engine 0.23.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/compute-engine.esm.js +13001 -12744
- package/dist/compute-engine.js +13001 -12744
- package/dist/compute-engine.min.esm.js +10 -10
- package/dist/compute-engine.min.js +10 -10
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.js +2 -2
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/signals.d.ts +12 -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 +4 -4
- package/dist/types/compute-engine/boxed-expression/box.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +8 -4
- package/dist/types/compute-engine/boxed-expression/boxed-domain.d.ts +6 -3
- 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 +8 -4
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +5 -3
- package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +17 -22
- package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +7 -3
- package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +2 -2
- package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +7 -4
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +7 -3
- package/dist/types/compute-engine/boxed-expression/canonical.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 +2 -9
- package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
- package/dist/types/compute-engine/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compile.d.ts +1 -1
- package/dist/types/compute-engine/compute-engine.d.ts +39 -23
- 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/function-utils.d.ts +4 -4
- 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-complex.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-linear-algebra.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-relational-operators.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-statistics.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -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 +1 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +5 -3
- package/dist/types/compute-engine/latex-syntax/public.d.ts +154 -18
- package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +2 -2
- package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-divide.d.ts +1 -1
- package/dist/types/compute-engine/library/arithmetic-multiply.d.ts +1 -1
- 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/complex.d.ts +1 -1
- package/dist/types/compute-engine/library/control-structures.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/linear-algebra.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 +2 -1
- package/dist/types/compute-engine/library/sets.d.ts +1 -1
- package/dist/types/compute-engine/library/statistics.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/factor.d.ts +1 -1
- package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +2 -2
- 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/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/terms.d.ts +1 -1
- package/dist/types/compute-engine/public.d.ts +156 -54
- package/dist/types/compute-engine/rules.d.ts +2 -2
- 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/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/expand.d.ts +1 -1
- 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 +1 -1
- package/dist/types/compute-engine/symbolic/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/tensors.d.ts +4 -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 +10 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/package.json +8 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
import { Expression } from '../../math-json/math-json-format';
|
|
3
3
|
import type { IComputeEngine } from '../public';
|
|
4
4
|
/**
|
|
@@ -7,21 +7,27 @@ import type { IComputeEngine } from '../public';
|
|
|
7
7
|
* It can be one of the indicated tokens, or a string that starts with a
|
|
8
8
|
* `\` for LaTeX commands, or a LaTeX character which includes digits,
|
|
9
9
|
* letters and punctuation.
|
|
10
|
+
* @category Latex Parsing and Serialization
|
|
10
11
|
*/
|
|
11
12
|
export type LatexToken = string | '<{>' | '<}>' | '<space>' | '<$>' | '<$$>';
|
|
12
13
|
/** A LatexString is a regular string of LaTeX, for example:
|
|
13
14
|
* `\frac{\pi}{2}`
|
|
15
|
+
* @category Latex Parsing and Serialization
|
|
14
16
|
*/
|
|
15
17
|
export type LatexString = string;
|
|
16
18
|
/**
|
|
17
|
-
* Open and close delimiters that can be used with {@
|
|
19
|
+
* Open and close delimiters that can be used with {@linkcode MatchfixEntry}
|
|
18
20
|
* record to define new LaTeX dictionary entries.
|
|
21
|
+
* @category Latex Parsing and Serialization
|
|
19
22
|
*/
|
|
20
23
|
export type Delimiter = ')' | '(' | ']' | '[' | '{' /** \lbrace */ | '}' /** \rbrace */ | '<' /** \langle */ | '>' /** \rangle */ | '|' | '||' | '\\lceil' | '\\rceil' | '\\lfloor' | '\\rfloor';
|
|
24
|
+
/**
|
|
25
|
+
* @category Latex Parsing and Serialization
|
|
26
|
+
*/
|
|
21
27
|
export type LibraryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'collections' | 'control-structures' | 'combinatorics' | 'complex' | 'core' | 'data-structures' | 'dimensions' | 'domains' | 'linear-algebra' | 'logic' | 'numeric' | 'other' | 'physics' | 'polynomials' | 'relop' | 'sets' | 'statistics' | 'styling' | 'symbols' | 'trigonometry' | 'units';
|
|
22
28
|
/**
|
|
23
29
|
*
|
|
24
|
-
*
|
|
30
|
+
* :::info[THEORY OF OPERATIONS]
|
|
25
31
|
*
|
|
26
32
|
* The precedence of an operator is a number that indicates the order in which
|
|
27
33
|
* operators are applied.
|
|
@@ -57,27 +63,41 @@ export type LibraryCategory = 'algebra' | 'arithmetic' | 'calculus' | 'collectio
|
|
|
57
63
|
* Some constants are defined below for common precedence values.
|
|
58
64
|
*
|
|
59
65
|
*
|
|
60
|
-
* Note
|
|
61
|
-
*
|
|
62
|
-
*
|
|
66
|
+
* **Note**: MathML defines
|
|
67
|
+
* [some operator precedence](https://www.w3.org/TR/2009/WD-MathML3-20090924/appendixc.html),
|
|
68
|
+
* but it has some issues and inconsistencies. However,
|
|
69
|
+
* whenever possible we adopted the MathML precedence.
|
|
70
|
+
*
|
|
71
|
+
* The JavaScript operator precedence is documented
|
|
72
|
+
* [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_precedence).
|
|
63
73
|
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
74
|
+
* :::
|
|
75
|
+
*
|
|
76
|
+
* @category Latex Parsing and Serialization
|
|
66
77
|
*/
|
|
67
78
|
export type Precedence = number;
|
|
79
|
+
/** @hidden */
|
|
68
80
|
export declare const COMPARISON_PRECEDENCE: Precedence;
|
|
81
|
+
/** @hidden */
|
|
69
82
|
export declare const ASSIGNMENT_PRECEDENCE: Precedence;
|
|
83
|
+
/** @hidden */
|
|
70
84
|
export declare const ARROW_PRECEDENCE: Precedence;
|
|
85
|
+
/** @hidden */
|
|
71
86
|
export declare const ADDITION_PRECEDENCE: Precedence;
|
|
87
|
+
/** @hidden */
|
|
72
88
|
export declare const MULTIPLICATION_PRECEDENCE: Precedence;
|
|
89
|
+
/** @hidden */
|
|
73
90
|
export declare const DIVISION_PRECEDENCE: Precedence;
|
|
91
|
+
/** @hidden */
|
|
74
92
|
export declare const EXPONENTIATION_PRECEDENCE: Precedence;
|
|
93
|
+
/** @hidden */
|
|
75
94
|
export declare const POSTFIX_PRECEDENCE: Precedence;
|
|
76
95
|
/**
|
|
77
96
|
* This indicates a condition under which parsing should stop:
|
|
78
97
|
* - an operator of a precedence higher than specified has been encountered
|
|
79
98
|
* - the last token has been reached
|
|
80
99
|
* - or if a condition is provided, the condition returns true;
|
|
100
|
+
* @category Latex Parsing and Serialization
|
|
81
101
|
*/
|
|
82
102
|
export type Terminator = {
|
|
83
103
|
minPrec: Precedence;
|
|
@@ -103,15 +123,40 @@ export type Terminator = {
|
|
|
103
123
|
* (didn't match the syntax that was expected). The matching expression
|
|
104
124
|
* otherwise.
|
|
105
125
|
*
|
|
126
|
+
* @category Latex Parsing and Serialization
|
|
106
127
|
*/
|
|
107
128
|
export type ExpressionParseHandler = (parser: Parser, until?: Readonly<Terminator>) => Expression | null;
|
|
129
|
+
/**
|
|
130
|
+
* @category Latex Parsing and Serialization
|
|
131
|
+
*/
|
|
108
132
|
export type PrefixParseHandler = (parser: Parser, until?: Readonly<Terminator>) => Expression | null;
|
|
133
|
+
/**
|
|
134
|
+
* @category Latex Parsing and Serialization
|
|
135
|
+
*/
|
|
109
136
|
export type SymbolParseHandler = (parser: Parser, until?: Readonly<Terminator>) => Expression | null;
|
|
137
|
+
/**
|
|
138
|
+
* @category Latex Parsing and Serialization
|
|
139
|
+
*/
|
|
110
140
|
export type FunctionParseHandler = (parser: Parser, until?: Readonly<Terminator>) => Expression | null;
|
|
141
|
+
/**
|
|
142
|
+
* @category Latex Parsing and Serialization
|
|
143
|
+
*/
|
|
111
144
|
export type EnvironmentParseHandler = (parser: Parser, until?: Readonly<Terminator>) => Expression | null;
|
|
145
|
+
/**
|
|
146
|
+
* @category Latex Parsing and Serialization
|
|
147
|
+
*/
|
|
112
148
|
export type PostfixParseHandler = (parser: Parser, lhs: Expression, until?: Readonly<Terminator>) => Expression | null;
|
|
149
|
+
/**
|
|
150
|
+
* @category Latex Parsing and Serialization
|
|
151
|
+
*/
|
|
113
152
|
export type InfixParseHandler = (parser: Parser, lhs: Expression, until: Readonly<Terminator>) => Expression | null;
|
|
153
|
+
/**
|
|
154
|
+
* @category Latex Parsing and Serialization
|
|
155
|
+
*/
|
|
114
156
|
export type MatchfixParseHandler = (parser: Parser, body: Expression) => Expression | null;
|
|
157
|
+
/**
|
|
158
|
+
* @category Latex Parsing and Serialization
|
|
159
|
+
*/
|
|
115
160
|
export type LatexArgumentType = '{expression}' /** A required math mode expression */ | '[expression]' /** An optional math mode expression */ | '{text}' /** A required expression in text mode */ | '[text]' /** An optional expression in text mode */ | '{unit}' /** A required unit expression, e.g. `3em` */ | '[unit]' /** An optional unit expression, e.g. `3em` */ | '{glue}' /** A required glue expression, e.g. `25 mu plus 3em ` */ | '[glue]' /** An optional glue expression, e.g. `25 mu plus 3em ` */ | '{string}' /** A required text string, terminated by a non-literal token */ | '[string]' /** An optional text string, terminated by a non-literal token */ | '{color}' /** A required color expression, e.g. `red` or `#00ff00` */ | '[color]'; /** An optional color expression, e.g. `red` or `#00ff00` */
|
|
116
161
|
/**
|
|
117
162
|
* The trigger is the set of tokens that will make this record eligible to
|
|
@@ -126,6 +171,7 @@ export type LatexArgumentType = '{expression}' /** A required math mode expressi
|
|
|
126
171
|
*
|
|
127
172
|
* `matchfix` operators use `openTrigger` and `closeTrigger` instead.
|
|
128
173
|
*
|
|
174
|
+
* @category Latex Parsing and Serialization
|
|
129
175
|
*/
|
|
130
176
|
export type Trigger = {
|
|
131
177
|
latexTrigger?: LatexString | LatexToken[];
|
|
@@ -133,7 +179,7 @@ export type Trigger = {
|
|
|
133
179
|
};
|
|
134
180
|
/**
|
|
135
181
|
* Maps a string of LaTeX tokens to a function or symbol and vice-versa.
|
|
136
|
-
*
|
|
182
|
+
* @category Latex Parsing and Serialization
|
|
137
183
|
*/
|
|
138
184
|
export type BaseEntry = {
|
|
139
185
|
/**
|
|
@@ -157,14 +203,23 @@ export type BaseEntry = {
|
|
|
157
203
|
*/
|
|
158
204
|
serialize?: LatexString | SerializeHandler;
|
|
159
205
|
};
|
|
206
|
+
/**
|
|
207
|
+
* @category Latex Parsing and Serialization
|
|
208
|
+
*/
|
|
160
209
|
export type DefaultEntry = BaseEntry & Trigger & {
|
|
161
210
|
parse: Expression | ExpressionParseHandler;
|
|
162
211
|
};
|
|
212
|
+
/**
|
|
213
|
+
* @category Latex Parsing and Serialization
|
|
214
|
+
*/
|
|
163
215
|
export type ExpressionEntry = BaseEntry & Trigger & {
|
|
164
216
|
kind: 'expression';
|
|
165
217
|
parse: Expression | ExpressionParseHandler;
|
|
166
218
|
precedence?: Precedence;
|
|
167
219
|
};
|
|
220
|
+
/**
|
|
221
|
+
* @category Latex Parsing and Serialization
|
|
222
|
+
*/
|
|
168
223
|
export type MatchfixEntry = BaseEntry & {
|
|
169
224
|
kind: 'matchfix';
|
|
170
225
|
/**
|
|
@@ -179,6 +234,9 @@ export type MatchfixEntry = BaseEntry & {
|
|
|
179
234
|
*/
|
|
180
235
|
parse?: MatchfixParseHandler;
|
|
181
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* @category Latex Parsing and Serialization
|
|
239
|
+
*/
|
|
182
240
|
export type InfixEntry = BaseEntry & Trigger & {
|
|
183
241
|
/**
|
|
184
242
|
* Infix position, with an operand before and an operand after: `a ⊛ b`.
|
|
@@ -200,6 +258,9 @@ export type InfixEntry = BaseEntry & Trigger & {
|
|
|
200
258
|
precedence?: Precedence;
|
|
201
259
|
parse?: string | InfixParseHandler;
|
|
202
260
|
};
|
|
261
|
+
/**
|
|
262
|
+
* @category Latex Parsing and Serialization
|
|
263
|
+
*/
|
|
203
264
|
export type PostfixEntry = BaseEntry & Trigger & {
|
|
204
265
|
/**
|
|
205
266
|
* Postfix position, with an operand before: `a ⊛`
|
|
@@ -208,8 +269,11 @@ export type PostfixEntry = BaseEntry & Trigger & {
|
|
|
208
269
|
*/
|
|
209
270
|
kind: 'postfix';
|
|
210
271
|
precedence?: Precedence;
|
|
211
|
-
parse?: PostfixParseHandler;
|
|
272
|
+
parse?: string | PostfixParseHandler;
|
|
212
273
|
};
|
|
274
|
+
/**
|
|
275
|
+
* @category Latex Parsing and Serialization
|
|
276
|
+
*/
|
|
213
277
|
export type PrefixEntry = BaseEntry & Trigger & {
|
|
214
278
|
/**
|
|
215
279
|
* Prefix position, with an operand after: `⊛ a`
|
|
@@ -218,17 +282,21 @@ export type PrefixEntry = BaseEntry & Trigger & {
|
|
|
218
282
|
*/
|
|
219
283
|
kind: 'prefix';
|
|
220
284
|
precedence: Precedence;
|
|
221
|
-
parse?: PrefixParseHandler;
|
|
285
|
+
parse?: string | PrefixParseHandler;
|
|
222
286
|
};
|
|
223
287
|
/**
|
|
224
288
|
* A LaTeX dictionary entry for an environment, that is a LaTeX
|
|
225
289
|
* construct using `\begin{...}...\end{...}`.
|
|
290
|
+
* @category Latex Parsing and Serialization
|
|
226
291
|
*/
|
|
227
292
|
export type EnvironmentEntry = BaseEntry & {
|
|
228
293
|
kind: 'environment';
|
|
229
294
|
parse: EnvironmentParseHandler;
|
|
230
295
|
identifierTrigger: string;
|
|
231
296
|
};
|
|
297
|
+
/**
|
|
298
|
+
* @category Latex Parsing and Serialization
|
|
299
|
+
*/
|
|
232
300
|
export type SymbolEntry = BaseEntry & Trigger & {
|
|
233
301
|
kind: 'symbol';
|
|
234
302
|
/** Used for appropriate wrapping (i.e. when to surround it with parens) */
|
|
@@ -243,11 +311,23 @@ export type SymbolEntry = BaseEntry & Trigger & {
|
|
|
243
311
|
* For more complex situations, for example implicit arguments or
|
|
244
312
|
* inverse functions postfix (i.e. ^{-1}), use a custom parse handler with a
|
|
245
313
|
* entry of kind `expression`.
|
|
314
|
+
* @category Latex Parsing and Serialization
|
|
246
315
|
*/
|
|
247
316
|
export type FunctionEntry = BaseEntry & Trigger & {
|
|
248
317
|
kind: 'function';
|
|
249
318
|
parse?: Expression | FunctionParseHandler;
|
|
250
319
|
};
|
|
320
|
+
/**
|
|
321
|
+
*
|
|
322
|
+
* A dictionary entry is a record that maps a LaTeX token or string of tokens
|
|
323
|
+
* to a MathJSON expression or to a parsing handler.
|
|
324
|
+
*
|
|
325
|
+
* Set the {@linkcode ComputeEngine.latexDictionary} property to an array of
|
|
326
|
+
* dictionary entries to define custom LaTeX parsing and serialization.
|
|
327
|
+
*
|
|
328
|
+
* @category Latex Parsing and Serialization
|
|
329
|
+
*
|
|
330
|
+
*/
|
|
251
331
|
export type LatexDictionaryEntry = DefaultEntry | ExpressionEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | FunctionEntry | EnvironmentEntry;
|
|
252
332
|
/** @internal */
|
|
253
333
|
export declare function isExpressionEntry(entry: LatexDictionaryEntry): entry is ExpressionEntry;
|
|
@@ -265,7 +345,19 @@ export declare function isPrefixEntry(entry: LatexDictionaryEntry): entry is Pre
|
|
|
265
345
|
export declare function isPostfixEntry(entry: LatexDictionaryEntry): entry is PostfixEntry;
|
|
266
346
|
/** @internal */
|
|
267
347
|
export declare function isEnvironmentEntry(entry: LatexDictionaryEntry): entry is EnvironmentEntry;
|
|
268
|
-
|
|
348
|
+
/**
|
|
349
|
+
*
|
|
350
|
+
* @category Latex Parsing and Serialization
|
|
351
|
+
* @internal
|
|
352
|
+
*/
|
|
353
|
+
export type LatexDictionary = Array<Partial<LatexDictionaryEntry>>;
|
|
354
|
+
/**
|
|
355
|
+
*
|
|
356
|
+
* The LaTeX parsing options can be set using the
|
|
357
|
+
* {@linkcode ComputeEngine.latexOptions} property.
|
|
358
|
+
*
|
|
359
|
+
* @category Latex Parsing and Serialization
|
|
360
|
+
*/
|
|
269
361
|
export type ParseLatexOptions = {
|
|
270
362
|
/**
|
|
271
363
|
* If true, ignore space characters in math mode.
|
|
@@ -305,9 +397,7 @@ export type ParseLatexOptions = {
|
|
|
305
397
|
* This handler is invoked when the parser encounters an identifier
|
|
306
398
|
* that does not have a corresponding entry in the dictionary.
|
|
307
399
|
*
|
|
308
|
-
* The `identifier` argument is a valid identifier
|
|
309
|
-
* (see https://cortexjs.io/math-json/#identifiers for the definition of a
|
|
310
|
-
* valid identifier).
|
|
400
|
+
* The `identifier` argument is a (valid identifier)[/math-json/#identifiers].
|
|
311
401
|
*
|
|
312
402
|
* The handler can return:
|
|
313
403
|
*
|
|
@@ -334,7 +424,15 @@ export type ParseLatexOptions = {
|
|
|
334
424
|
*/
|
|
335
425
|
preserveLatex: boolean;
|
|
336
426
|
};
|
|
427
|
+
/** @category Latex Parsing and Serialization */
|
|
337
428
|
export type DelimiterScale = 'normal' | 'scaled' | 'big' | 'none';
|
|
429
|
+
/**
|
|
430
|
+
*
|
|
431
|
+
* The LaTeX serialization options can be set using the
|
|
432
|
+
* {@linkcode ComputeEngine.latexOptions} property.
|
|
433
|
+
*
|
|
434
|
+
* @category Latex Parsing and Serialization
|
|
435
|
+
*/
|
|
338
436
|
export type SerializeLatexOptions = {
|
|
339
437
|
/**
|
|
340
438
|
* LaTeX string used to render an invisible multiply, e.g. in '2x'.
|
|
@@ -377,6 +475,13 @@ export type SerializeLatexOptions = {
|
|
|
377
475
|
powerStyle: (expr: Expression, level: number) => 'root' | 'solidus' | 'quotient';
|
|
378
476
|
numericSetStyle: (expr: Expression, level: number) => 'compact' | 'regular' | 'interval' | 'set-builder';
|
|
379
477
|
};
|
|
478
|
+
/**
|
|
479
|
+
*
|
|
480
|
+
* The options to format numbers can be set using the
|
|
481
|
+
* {@linkcode ComputeEngine.latexOptions} property.
|
|
482
|
+
*
|
|
483
|
+
* @category Latex Parsing and Serialization
|
|
484
|
+
*/
|
|
380
485
|
export type NumberFormattingOptions = {
|
|
381
486
|
precision: number;
|
|
382
487
|
positiveInfinity: LatexString;
|
|
@@ -417,13 +522,19 @@ export type NumberFormattingOptions = {
|
|
|
417
522
|
avoidExponentsInRange: undefined | null | [negativeExponent: number, positiveExponent: number];
|
|
418
523
|
};
|
|
419
524
|
/**
|
|
420
|
-
*
|
|
421
|
-
*
|
|
525
|
+
* The {@linkcode ComputeEngine.latexSyntax} property is an instance of
|
|
526
|
+
* `LatexSyntax` that can be used to parse and serialize LaTeX strings.
|
|
527
|
+
*
|
|
528
|
+
* Its methods are exposed with `ce.parse`, `ce.serialize` and
|
|
529
|
+
* `ce.getLatexDictionary`.
|
|
530
|
+
*
|
|
531
|
+
* @category Latex Parsing and Serialization
|
|
532
|
+
* @internal
|
|
422
533
|
*/
|
|
423
534
|
export declare class LatexSyntax {
|
|
424
535
|
/**
|
|
425
536
|
*
|
|
426
|
-
* @param onError - Called when a non-fatal error is encountered. When parsing,
|
|
537
|
+
* @param options.onError - Called when a non-fatal error is encountered. When parsing,
|
|
427
538
|
* the parser will attempt to recover and continue.
|
|
428
539
|
*
|
|
429
540
|
*/
|
|
@@ -452,9 +563,18 @@ export declare class LatexSyntax {
|
|
|
452
563
|
* constructor.
|
|
453
564
|
*/
|
|
454
565
|
static getDictionary(domain?: LibraryCategory | 'all'): Readonly<LatexDictionary>;
|
|
566
|
+
/** Parse a */
|
|
455
567
|
parse(latex: LatexString): Expression;
|
|
456
568
|
serialize(expr: Expression): LatexString;
|
|
457
569
|
}
|
|
570
|
+
/**
|
|
571
|
+
*
|
|
572
|
+
* An instance of `Serializer` is provided to the `serialize` handlers of custom
|
|
573
|
+
* LaTeX dictionary entries.
|
|
574
|
+
*
|
|
575
|
+
* @category Latex Parsing and Serialization
|
|
576
|
+
*
|
|
577
|
+
*/
|
|
458
578
|
export interface Serializer {
|
|
459
579
|
readonly onError: WarningSignalHandler;
|
|
460
580
|
readonly options: Required<SerializeLatexOptions>;
|
|
@@ -504,7 +624,19 @@ export interface Serializer {
|
|
|
504
624
|
serializeFunction(expr: Expression): LatexString;
|
|
505
625
|
serializeSymbol(expr: Expression): LatexString;
|
|
506
626
|
}
|
|
627
|
+
/** The `serialize` handler of a custom LaTeX dictionary entry can be
|
|
628
|
+
* a function of this type.
|
|
629
|
+
*
|
|
630
|
+
* @category Latex Parsing and Serialization
|
|
631
|
+
*
|
|
632
|
+
*/
|
|
507
633
|
export type SerializeHandler = (serializer: Serializer, expr: Expression) => string;
|
|
634
|
+
/**
|
|
635
|
+
* An instance of `Parser` is provided to the `parse` handlers of custom
|
|
636
|
+
* LaTeX dictionary entries.
|
|
637
|
+
*
|
|
638
|
+
* @category Latex Parsing and Serialization
|
|
639
|
+
*/
|
|
508
640
|
export interface Parser {
|
|
509
641
|
readonly options: Required<ParseLatexOptions>;
|
|
510
642
|
readonly computeEngine?: IComputeEngine;
|
|
@@ -651,6 +783,10 @@ export interface Parser {
|
|
|
651
783
|
* `until` is `{ minPrec:0 }` by default.
|
|
652
784
|
*/
|
|
653
785
|
parseExpression(until?: Partial<Terminator>): Expression | null;
|
|
786
|
+
/**
|
|
787
|
+
* Parse a number.
|
|
788
|
+
*/
|
|
789
|
+
parseNumber(): Expression | null;
|
|
654
790
|
/**
|
|
655
791
|
* Boundaries are used to detect the end of an expression.
|
|
656
792
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { DelimiterScale } from './public
|
|
1
|
+
/* 0.24.0 */
|
|
2
|
+
import { DelimiterScale } from './public';
|
|
3
3
|
export declare function getApplyFunctionStyle(_expr: Expression, _level: number): DelimiterScale;
|
|
4
4
|
export declare function getGroupStyle(_expr: Expression, _level: number): DelimiterScale;
|
|
5
5
|
export declare function getRootStyle(_expr: Expression | null, level: number): 'radical' | 'quotient' | 'solidus';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
import { WarningSignalHandler } from '../../common/signals';
|
|
3
3
|
import { NumberFormattingOptions, LatexString, SerializeLatexOptions, DelimiterScale } from './public';
|
|
4
4
|
import { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const CALCULUS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const COMPLEX_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const CONTROL_STRUCTURES_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
import { FunctionDefinition, IComputeEngine, IdentifierDefinitions, SymbolDefinition } from '../public';
|
|
3
3
|
export declare function getStandardLibrary(categories: LibraryCategory[] | LibraryCategory | 'all'): readonly IdentifierDefinitions[];
|
|
4
4
|
export declare const LIBRARIES: {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const LINEAR_ALGEBRA_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const LOGIC_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const POLYNOMIALS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare function randomExpression(level?: number): Expression;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const SETS_LIBRARY: IdentifierDefinitions;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const STATISTICS_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare const TRIGONOMETRY_LIBRARY: IdentifierDefinitions[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/* 0.
|
|
2
|
-
import { Expression } from '../../math-json
|
|
1
|
+
/* 0.24.0 */
|
|
2
|
+
import { Expression } from '../../math-json';
|
|
3
3
|
export declare function bigintValue(expr: Expression | null | undefined): bigint | null;
|
|
4
4
|
export declare function bigint(a: Decimal | number | bigint | string): bigint;
|
|
5
5
|
export declare function gcd(a: bigint, b: bigint): bigint;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/* 0.
|
|
1
|
+
/* 0.24.0 */
|
|
2
2
|
export declare function isPrime(n: number): boolean | undefined;
|