@cortex-js/compute-engine 0.27.0 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/compute-engine.esm.js +2055 -964
  2. package/dist/compute-engine.js +2055 -964
  3. package/dist/compute-engine.min.esm.js +54 -51
  4. package/dist/compute-engine.min.js +54 -51
  5. package/dist/math-json.esm.js +287 -7
  6. package/dist/math-json.js +287 -7
  7. package/dist/math-json.min.esm.js +287 -7
  8. package/dist/math-json.min.js +4 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/buffer.d.ts +1 -1
  11. package/dist/types/common/fuzzy-string-match.d.ts +2 -0
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/interruptible.d.ts +2 -2
  14. package/dist/types/common/json5.d.ts +3 -0
  15. package/dist/types/common/one-of.d.ts +1 -1
  16. package/dist/types/common/signals.d.ts +1 -1
  17. package/dist/types/common/styled-text.d.ts +1 -1
  18. package/dist/types/common/syntax-highlighter.d.ts +1 -1
  19. package/dist/types/common/terminal.d.ts +1 -1
  20. package/dist/types/common/type/boxed-type.d.ts +13 -0
  21. package/dist/types/common/type/parse.d.ts +1 -1
  22. package/dist/types/common/type/primitive.d.ts +2 -1
  23. package/dist/types/common/type/serialize.d.ts +1 -1
  24. package/dist/types/common/type/subtype.d.ts +1 -1
  25. package/dist/types/common/type/types.d.ts +39 -49
  26. package/dist/types/common/type/utils.d.ts +3 -7
  27. package/dist/types/common/utils.d.ts +1 -1
  28. package/dist/types/compute-engine/assume.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +10 -8
  30. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +3 -2
  32. package/dist/types/compute-engine/boxed-expression/arithmetic-divide.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/arithmetic-multiply.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/boxed-function-definition.d.ts +10 -3
  38. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +11 -7
  39. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +3 -3
  40. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  41. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +3 -3
  42. package/dist/types/compute-engine/boxed-expression/boxed-symbol-definition.d.ts +5 -4
  43. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +6 -5
  44. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +3 -3
  45. package/dist/types/compute-engine/boxed-expression/cache.d.ts +2 -1
  46. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/hold.d.ts +3 -2
  53. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/public.d.ts +64 -54
  60. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  65. package/dist/types/compute-engine/boxed-expression/tensor-fields.d.ts +1 -1
  66. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  67. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  68. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  69. package/dist/types/compute-engine/boxed-expression/validate.d.ts +2 -2
  70. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  71. package/dist/types/compute-engine/compile.d.ts +1 -1
  72. package/dist/types/compute-engine/compute-engine.d.ts +25 -12
  73. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  74. package/dist/types/compute-engine/debug.d.ts +1 -1
  75. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  85. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  86. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  87. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  88. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  90. package/dist/types/compute-engine/latex-syntax/parse-identifier.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/public.d.ts +11 -6
  93. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  94. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  95. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  96. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  97. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  98. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  99. package/dist/types/compute-engine/library/collections.d.ts +3 -2
  100. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  101. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  102. package/dist/types/compute-engine/library/core.d.ts +1 -1
  103. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  104. package/dist/types/compute-engine/library/library.d.ts +1 -1
  105. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  106. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  107. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  108. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  109. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  110. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  111. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  112. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  113. package/dist/types/compute-engine/library/utils.d.ts +3 -5
  114. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  115. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  116. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  117. package/dist/types/compute-engine/numeric-value/public.d.ts +1 -1
  118. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  119. package/dist/types/compute-engine/numerics/bignum.d.ts +1 -1
  120. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  121. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  122. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  123. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  124. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  125. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  126. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  127. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  128. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  129. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  130. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  131. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  132. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  133. package/dist/types/compute-engine/private.d.ts +1 -1
  134. package/dist/types/compute-engine/public.d.ts +1 -1
  135. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  136. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  137. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  138. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  139. package/dist/types/compute-engine.d.ts +3 -2
  140. package/dist/types/math-json/identifiers.d.ts +1 -1
  141. package/dist/types/math-json/types.d.ts +6 -6
  142. package/dist/types/math-json/utils.d.ts +3 -3
  143. package/dist/types/math-json.d.ts +3 -3
  144. package/package.json +3 -3
  145. package/dist/types/common/suggest.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import type { Expression, MathJsonNumber, MathJsonString, MathJsonSymbol, MathJsonFunction, MathJsonIdentifier } from '../../math-json';
3
3
  import type { SerializeLatexOptions, LatexDictionaryEntry, ParseLatexOptions } from '../latex-syntax/public';
4
4
  import type { IndexedLatexDictionary } from '../latex-syntax/dictionary/definitions';
@@ -9,6 +9,7 @@ import { Type, TypeString } from '../../common/type/types';
9
9
  import { AbstractTensor } from '../tensor/tensors';
10
10
  import { OneOf } from '../../common/one-of';
11
11
  import { CompiledType, JSSource } from '../compile';
12
+ import { BoxedType } from '../../common/type/boxed-type';
12
13
  /**
13
14
  * :::info[THEORY OF OPERATIONS]
14
15
  *
@@ -900,8 +901,9 @@ export interface BoxedExpression {
900
901
  * If the type of this expression is already known, return `false`.
901
902
  *
902
903
  * If the type was not set, set it to the inferred type, return `true`
903
- * If the type was previously inferred, adjust it by widening it,
904
- * return `true`
904
+ * If the type was previously inferred, widen it and return `true`.
905
+ *
906
+ * If the type cannot be inferred, return `false`.
905
907
  *
906
908
  * @internal
907
909
  */
@@ -917,8 +919,8 @@ export interface BoxedExpression {
917
919
  *
918
920
  * Reset the cached value associated with this expression.
919
921
  *
920
- * Use when the environment has changed, for example the numeric mode
921
- * or precision, to force the expression to be re-evaluated.
922
+ * Use when the environment, for example the precision, has changed to
923
+ * force the expression to be re-evaluated.
922
924
  *
923
925
  * @internal
924
926
  */
@@ -974,6 +976,13 @@ export interface BoxedExpression {
974
976
  *
975
977
  */
976
978
  evaluate(options?: Partial<EvaluateOptions>): BoxedExpression;
979
+ /** Asynchronous version of `evaluate()`.
980
+ *
981
+ * The `options` argument can include a `signal` property, which is an
982
+ * `AbortSignal` object. If the signal is aborted, a `CancellationError` is thrown.
983
+ *
984
+ */
985
+ evaluateAsync(options?: Partial<EvaluateOptions>): Promise<BoxedExpression>;
977
986
  /** Return a numeric approximation of the canonical form of this expression.
978
987
  *
979
988
  * Any necessary calculations, including on decimal numbers (non-integers),
@@ -1010,7 +1019,7 @@ export interface BoxedExpression {
1010
1019
  vars?: Record<MathJsonIdentifier, CompiledType>;
1011
1020
  imports?: unknown[];
1012
1021
  preamble?: string;
1013
- }): ((args?: Record<string, CompiledType>) => CompiledType | undefined) | undefined;
1022
+ }): (args?: Record<string, CompiledType>) => CompiledType;
1014
1023
  /**
1015
1024
  * If this is an equation, solve the equation for the variables in vars.
1016
1025
  * Otherwise, solve the equation `this = 0` for the variables in vars.
@@ -1023,7 +1032,7 @@ export interface BoxedExpression {
1023
1032
  *
1024
1033
  *
1025
1034
  */
1026
- solve(vars: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
1035
+ solve(vars?: Iterable<string> | string | BoxedExpression | Iterable<BoxedExpression>): null | ReadonlyArray<BoxedExpression>;
1027
1036
  /**
1028
1037
  * Return a JavaScript primitive representing the value of this expression.
1029
1038
  *
@@ -1065,8 +1074,8 @@ export interface BoxedExpression {
1065
1074
  * :::
1066
1075
  *
1067
1076
  */
1068
- get type(): Type;
1069
- set type(type: Type);
1077
+ get type(): BoxedType;
1078
+ set type(type: Type | TypeString | BoxedType);
1070
1079
  /** `true` if the value of this expression is a number.
1071
1080
  *
1072
1081
  *
@@ -1434,14 +1443,14 @@ export type BoxedFunctionDefinition = BoxedBaseDefinition & FunctionDefinitionFl
1434
1443
  */
1435
1444
  inferredSignature: boolean;
1436
1445
  /** The type of the arguments and return value of this function */
1437
- signature: Type;
1446
+ signature: BoxedType;
1438
1447
  /** If present, this handler can be used to more precisely determine the
1439
1448
  * return type based on the type of the arguments. The arguments themselves
1440
1449
  * should *not* be evaluated, only their types should be used.
1441
1450
  */
1442
1451
  type?: (ops: ReadonlyArray<BoxedExpression>, options: {
1443
1452
  engine: IComputeEngine;
1444
- }) => Type | TypeString | undefined;
1453
+ }) => Type | TypeString | BoxedType | undefined;
1445
1454
  /** If present, this handler can be used to determine the sign of the
1446
1455
  * return value of the function, based on the sign and type of its
1447
1456
  * arguments.
@@ -1463,6 +1472,9 @@ export type BoxedFunctionDefinition = BoxedBaseDefinition & FunctionDefinitionFl
1463
1472
  evaluate?: (ops: ReadonlyArray<BoxedExpression>, options: Partial<EvaluateOptions> & {
1464
1473
  engine?: IComputeEngine;
1465
1474
  }) => BoxedExpression | undefined;
1475
+ evaluateAsync?: (ops: ReadonlyArray<BoxedExpression>, options?: Partial<EvaluateOptions> & {
1476
+ engine?: IComputeEngine;
1477
+ }) => Promise<BoxedExpression | undefined>;
1466
1478
  evalDimension?: (ops: ReadonlyArray<BoxedExpression>, options: {
1467
1479
  engine: IComputeEngine;
1468
1480
  }) => BoxedExpression;
@@ -1532,7 +1544,7 @@ export interface BoxedSymbolDefinition extends BoxedBaseDefinition, SymbolAttrib
1532
1544
  neq?: (a: BoxedExpression) => boolean | undefined;
1533
1545
  cmp?: (a: BoxedExpression) => '=' | '>' | '<' | undefined;
1534
1546
  inferredType: boolean;
1535
- type: Type;
1547
+ type: BoxedType;
1536
1548
  }
1537
1549
  /**
1538
1550
  * Given an expression and set of wildcards, return a new expression.
@@ -1692,6 +1704,7 @@ export type SimplifyOptions = {
1692
1704
  */
1693
1705
  export type EvaluateOptions = {
1694
1706
  numericApproximation: boolean;
1707
+ signal: AbortSignal;
1695
1708
  };
1696
1709
  /**
1697
1710
  * Metadata that can be associated with a `BoxedExpression`
@@ -1719,7 +1732,7 @@ export type ArrayValue = boolean | number | string | BigNum | BoxedExpression |
1719
1732
  /** @category Assumptions */
1720
1733
  export type AssumeResult = 'internal-error' | 'not-a-predicate' | 'contradiction' | 'tautology' | 'ok';
1721
1734
  /** @category Compute Engine */
1722
- export type AssignValue = boolean | number | string | LatexString | SemiBoxedExpression | ((args: ReadonlyArray<BoxedExpression>, options: EvaluateOptions & {
1735
+ export type AssignValue = boolean | number | SemiBoxedExpression | ((args: ReadonlyArray<BoxedExpression>, options: EvaluateOptions & {
1723
1736
  engine: IComputeEngine;
1724
1737
  }) => BoxedExpression) | undefined;
1725
1738
  /** @internal */
@@ -1761,14 +1774,30 @@ export interface IComputeEngine extends IBigNum {
1761
1774
  /** Absolute time beyond which evaluation should not proceed
1762
1775
  * @internal
1763
1776
  */
1764
- deadline?: number;
1777
+ _deadline?: number;
1778
+ /** Time remaining before _deadline */
1779
+ _timeRemaining: number;
1780
+ /** @private */
1765
1781
  generation: number;
1766
- /** @hidden */
1767
- readonly timeLimit: number;
1768
- /** @hidden */
1769
- readonly iterationLimit: number;
1770
- /** @hidden */
1771
- readonly recursionLimit: number;
1782
+ /** Throw a `CancellationError` when the duration of an evaluation exceeds
1783
+ * the time limit.
1784
+ *
1785
+ * Time in milliseconds, default 2000 ms = 2 seconds.
1786
+ *
1787
+ */
1788
+ timeLimit: number;
1789
+ /** Throw `CancellationError` `iteration-limit-exceeded` when the iteration limit
1790
+ * in a loop is exceeded. Default: no limits.
1791
+ *
1792
+ * @experimental
1793
+ */
1794
+ iterationLimit: number;
1795
+ /** Signal `recursion-depth-exceeded` when the recursion depth for this
1796
+ * scope is exceeded.
1797
+ *
1798
+ * @experimental
1799
+ */
1800
+ recursionLimit: number;
1772
1801
  chop(n: number): number;
1773
1802
  chop(n: BigNum): BigNum | 0;
1774
1803
  chop(n: number | BigNum): number | BigNum;
@@ -1809,10 +1838,11 @@ export interface IComputeEngine extends IBigNum {
1809
1838
  }): BoxedExpression;
1810
1839
  string(s: string, metadata?: Metadata): BoxedExpression;
1811
1840
  error(message: string | string[], where?: string): BoxedExpression;
1812
- typeError(expectedType: Type, actualType: undefined | Type, where?: SemiBoxedExpression): BoxedExpression;
1841
+ typeError(expectedType: Type, actualType: undefined | Type | BoxedType, where?: SemiBoxedExpression): BoxedExpression;
1813
1842
  hold(expr: SemiBoxedExpression): BoxedExpression;
1814
1843
  tuple(...elements: ReadonlyArray<number>): BoxedExpression;
1815
1844
  tuple(...elements: ReadonlyArray<BoxedExpression>): BoxedExpression;
1845
+ type(type: Type | TypeString | BoxedType): BoxedType;
1816
1846
  rules(rules: Rule | ReadonlyArray<Rule | BoxedRule> | BoxedRuleSet | undefined | null, options?: {
1817
1847
  canonical?: boolean;
1818
1848
  }): BoxedRuleSet;
@@ -1960,11 +1990,11 @@ export type LatexString = string;
1960
1990
  * value.
1961
1991
  * - `recursive`: if true, match recursively, otherwise match only the top
1962
1992
  * level.
1963
- * - `exact`: if true, only match expressions that are structurally identical.
1964
- * If false, match expressions that are structurally identical or equivalent.
1993
+ * - `useVariations`: if false, only match expressions that are structurally identical.
1994
+ * If true, match expressions that are structurally identical or equivalent.
1965
1995
  *
1966
- * For example, when false, `["Add", '_a', 2]` matches `2`, with a value of
1967
- * `_a` of `0`. If true, the expression does not match. **Default**: `true`
1996
+ * For example, when true, `["Add", '_a', 2]` matches `2`, with a value of
1997
+ * `_a` of `0`. If false, the expression does not match. **Default**: `false`
1968
1998
  *
1969
1999
  * @category Pattern Matching
1970
2000
  *
@@ -2073,34 +2103,7 @@ export type RuntimeIdentifierDefinitions = Map<string, OneOf<[BoxedSymbolDefinit
2073
2103
  *
2074
2104
  * @category Compute Engine
2075
2105
  */
2076
- export type Scope = {
2077
- /** Signal `timeout` when the execution time for this scope is exceeded.
2078
- *
2079
- * Time in seconds, default 2s.
2080
- *
2081
- * @experimental
2082
- */
2083
- timeLimit: number;
2084
- /** Signal `out-of-memory` when the memory usage for this scope is exceeded.
2085
- *
2086
- * Memory is in Megabytes, default: 1Mb.
2087
- *
2088
- * @experimental
2089
- */
2090
- memoryLimit: number;
2091
- /** Signal `recursion-depth-exceeded` when the recursion depth for this
2092
- * scope is exceeded.
2093
- *
2094
- * @experimental
2095
- */
2096
- recursionLimit: number;
2097
- /** Signal `iteration-limit-exceeded` when the iteration limit
2098
- * in a loop is exceeded. Default: no limits.
2099
- *
2100
- * @experimental
2101
- */
2102
- iterationLimit: number;
2103
- };
2106
+ export type Scope = {};
2104
2107
  /** @category Compute Engine */
2105
2108
  export type RuntimeScope = Scope & {
2106
2109
  parentScope?: RuntimeScope;
@@ -2156,7 +2159,7 @@ export type FunctionDefinition = BaseDefinition & Partial<FunctionDefinitionFlag
2156
2159
  */
2157
2160
  type?: (ops: ReadonlyArray<BoxedExpression>, options: {
2158
2161
  engine: IComputeEngine;
2159
- }) => Type | TypeString | undefined;
2162
+ }) => Type | TypeString | BoxedType | undefined;
2160
2163
  /** Return the sign of the function expression.
2161
2164
  *
2162
2165
  * If the sign cannot be determined, return `undefined`.
@@ -2264,6 +2267,13 @@ export type FunctionDefinition = BaseDefinition & Partial<FunctionDefinitionFlag
2264
2267
  evaluate?: ((ops: ReadonlyArray<BoxedExpression>, options: EvaluateOptions & {
2265
2268
  engine: IComputeEngine;
2266
2269
  }) => BoxedExpression | undefined) | BoxedExpression;
2270
+ /**
2271
+ * An option asynchronous version of `evaluate`.
2272
+ *
2273
+ */
2274
+ evaluateAsync?: (ops: ReadonlyArray<BoxedExpression>, options: EvaluateOptions & {
2275
+ engine: IComputeEngine;
2276
+ }) => Promise<BoxedExpression | undefined>;
2267
2277
  /** Dimensional analysis
2268
2278
  * @experimental
2269
2279
  */
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const ConditionParent: {
3
3
  boolean: string;
4
4
  string: string;
@@ -1,3 +1,3 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import type { BoxedExpression, IComputeEngine, JsonSerializationOptions } from '../public';
3
3
  export declare function serializeJson(ce: IComputeEngine, expr: BoxedExpression, options: Readonly<JsonSerializationOptions>): Expression;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare function sgn(expr: BoxedExpression): Sign | undefined;
3
3
  export declare function positiveSign(s: Sign | undefined): boolean | undefined;
4
4
  export declare function nonNegativeSign(s: Sign | undefined): boolean | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  type InternalSimplifyOptions = SimplifyOptions & {
3
3
  useVariations: boolean;
4
4
  };
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { Rule } from '../public';
3
3
  export declare const UNIVARIATE_ROOTS: Rule[];
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import type { BoxedExpression, IComputeEngine } from '../public';
3
3
  export type DataTypeMap = {
4
4
  float64: number;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare class Terms {
3
3
  private engine;
4
4
  private terms;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare function Fu(exp: BoxedExpression): RuleStep | undefined;
3
3
  /** Assuming x in an expression in radians, convert to current angular unit. */
4
4
  export declare function radiansToAngle(x: BoxedExpression | undefined): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { Type } from '../../common/type/types';
3
3
  export declare function isBoxedExpression(x: unknown): x is BoxedExpression;
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import type { IComputeEngine } from '../public';
3
3
  import { Type } from '../../common/type/types';
4
4
  /**
@@ -28,7 +28,7 @@ export declare function checkNumericArgs(ce: IComputeEngine, ops: ReadonlyArray<
28
28
  flatten?: string;
29
29
  }): ReadonlyArray<BoxedExpression>;
30
30
  /**
31
- * Check that an argument is of the expected domain.
31
+ * Check that an argument is of the expected type.
32
32
  *
33
33
  * Converts the arguments to canonical
34
34
  */
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  /** If a collection has fewer than this many elements, eagerly evaluate it.
3
3
  *
4
4
  * For example, evaluate the Union of two sets with 10 elements each will
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import type { BoxedExpression } from './public';
3
3
  export type CompiledType = boolean | number | string | object;
4
4
  export type JSSource = string;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import { Expression, MathJsonIdentifier, MathJsonNumber } from '../math-json/types';
4
4
  import type { LibraryCategory, LatexDictionaryEntry, LatexString, ParseLatexOptions } from './latex-syntax/public';
@@ -11,6 +11,9 @@ import { ExactNumericValueData, NumericValue, NumericValueData } from './numeric
11
11
  import { Type, TypeString } from '../common/type/types';
12
12
  import { OneOf } from '../common/one-of';
13
13
  import { BigNum } from './numerics/bignum';
14
+ import { BoxedType } from '../common/type/boxed-type';
15
+ export type * from '../common/type/types';
16
+ export * from '../common/type/subtype';
14
17
  /**
15
18
  *
16
19
  * To use the Compute Engine, create a `ComputeEngine` instance:
@@ -195,9 +198,8 @@ export declare class ComputeEngine implements IComputeEngine {
195
198
  *
196
199
  * The order of the dictionaries matter: the definitions from the later ones
197
200
  * override the definitions from earlier ones. The first dictionary should
198
- * be the `'core'` dictionary which include some basic definitions such
199
- * as domains (`Booleans`, `Numbers`, etc...) that are used by later
200
- * dictionaries.
201
+ * be the `'core'` dictionary which include basic definitions that are used
202
+ * by later dictionaries.
201
203
  *
202
204
  *
203
205
  * @param options.precision Specific how many digits of precision
@@ -212,6 +214,7 @@ export declare class ComputeEngine implements IComputeEngine {
212
214
  precision?: number | 'machine';
213
215
  tolerance?: number | 'auto';
214
216
  });
217
+ toString(): string;
215
218
  get latexDictionary(): Readonly<LatexDictionaryEntry[]>;
216
219
  set latexDictionary(dic: Readonly<LatexDictionaryEntry[]>);
217
220
  get indexedLatexDictionary(): IndexedLatexDictionary;
@@ -231,30 +234,39 @@ export declare class ComputeEngine implements IComputeEngine {
231
234
  get stats(): ComputeEngineStats;
232
235
  get precision(): number;
233
236
  /** The precision, or number of significant digits, of numeric
234
- * calculations when the numeric mode is `"auto"` or `"bignum"`.
237
+ * calculations.
235
238
  *
236
239
  * To make calculations using more digits, at the cost of expanded memory
237
240
  * usage and slower computations, set the `precision` higher.
238
241
  *
239
- * If the numeric mode is not `"auto"` or `"bignum"`, it is set to `"auto"`.
240
- *
241
242
  * Trigonometric operations are accurate for precision up to 1,000.
242
243
  *
243
244
  */
244
245
  set precision(p: number | 'machine' | 'auto');
245
246
  /**
246
- * The unit used for angles in trigonometric functions.
247
+ * The unit used for unitless angles in trigonometric functions.
248
+ *
249
+ * - `rad`: radian, $2\pi$ radians is a full circle
250
+ * - `deg`: degree, 360 degrees is a full circle
251
+ * - `grad`: gradians, 400 gradians is a full circle
252
+ * - `turn`: turn, 1 turn is a full circle
247
253
  *
248
254
  * Default is `"rad"` (radians).
249
255
  */
250
256
  get angularUnit(): AngularUnit;
251
257
  set angularUnit(u: AngularUnit);
252
- /** @experimental */
253
258
  get timeLimit(): number;
254
- /** @experimental */
259
+ set timeLimit(t: number);
260
+ private _timeLimit;
261
+ /** The time after which the time limit has been exceeded */
262
+ _deadline: number | undefined;
263
+ get _timeRemaining(): number;
255
264
  get iterationLimit(): number;
256
- /** @experimental */
265
+ set iterationLimit(t: number);
266
+ private _iterationLimit;
257
267
  get recursionLimit(): number;
268
+ set recursionLimit(t: number);
269
+ private _recursionLimit;
258
270
  get tolerance(): number;
259
271
  /**
260
272
  * Values smaller than the tolerance are considered to be zero for the
@@ -524,7 +536,7 @@ export declare class ComputeEngine implements IComputeEngine {
524
536
  * The result is canonical.
525
537
  */
526
538
  error(message: string | string[], where?: string): BoxedExpression;
527
- typeError(expected: Type, actual: undefined | Type, where?: string): BoxedExpression;
539
+ typeError(expected: Type, actual: undefined | Type | BoxedType, where?: string): BoxedExpression;
528
540
  /**
529
541
  * Add a `["Hold"]` wrapper to `expr`.
530
542
  */
@@ -535,6 +547,7 @@ export declare class ComputeEngine implements IComputeEngine {
535
547
  */
536
548
  tuple(...elements: ReadonlyArray<number>): BoxedExpression;
537
549
  tuple(...elements: ReadonlyArray<BoxedExpression>): BoxedExpression;
550
+ type(type: Type | TypeString | BoxedType): BoxedType;
538
551
  string(s: string, metadata?: Metadata): BoxedExpression;
539
552
  /** Return a boxed symbol */
540
553
  symbol(name: string, options?: {
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  /**
3
3
  * The default cost function, used to determine if a new expression is simpler
4
4
  * than the old one.
@@ -1,3 +1,3 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  /** Return a string representing the stack trace from context */
3
3
  export declare function trace(_context: RuntimeScope): string;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  /***
3
3
  * ### THEORY OF OPERATIONS
4
4
  *
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_ARITHMETIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_CALCULUS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_COMPLEX: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_CORE: LatexDictionary;
3
3
  export declare const DELIMITERS_SHORTHAND: {
4
4
  '(': string;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_LINEAR_ALGEBRA: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_LOGIC: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_OTHERS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_INEQUALITIES: LatexDictionaryEntry[];
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_SETS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_STATISTICS: LatexDictionary;
@@ -1,3 +1,3 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const SYMBOLS: [string, string, number][];
3
3
  export declare const DEFINITIONS_SYMBOLS: LatexDictionary;
@@ -1,2 +1,2 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  export declare const DEFINITIONS_TRIGONOMETRY: LatexDictionary;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { Delimiter, EnvironmentParseHandler, ExpressionParseHandler, InfixParseHandler, LatexDictionary, LatexDictionaryEntry, LatexString, LatexToken, LibraryCategory, MatchfixParseHandler, PostfixParseHandler, Precedence, SerializeHandler } from '../public';
3
3
  export type CommonEntry = {
4
4
  /** Note: a name is required if a serialize handler is provided */
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { Parser } from './public';
3
3
  /** For error handling, if we have a identifier prefix, assume
4
4
  * the identifier is invalid (it would have been captured by
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { ParseLatexOptions, LatexToken, Terminator, Parser, SymbolTable, SymbolType } from './public';
3
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry, IndexedInfixEntry, IndexedPostfixEntry, IndexedPrefixEntry, IndexedSymbolEntry, IndexedExpressionEntry, IndexedFunctionEntry } from './dictionary/definitions';
4
4
  /**
@@ -1,4 +1,5 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
+ import type { Expression, MathJsonIdentifier } from '../../math-json/types';
2
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
3
4
  export type SymbolType = 'symbol' | 'function' | 'unknown';
4
5
  export type SymbolTable = {
@@ -100,6 +101,8 @@ export declare const MULTIPLICATION_PRECEDENCE: Precedence;
100
101
  /** @hidden */
101
102
  export declare const DIVISION_PRECEDENCE: Precedence;
102
103
  /** @hidden */
104
+ export declare const INVISIBLE_OP_PRECEDENCE: Precedence;
105
+ /** @hidden */
103
106
  export declare const EXPONENTIATION_PRECEDENCE: Precedence;
104
107
  /** @hidden */
105
108
  export declare const POSTFIX_PRECEDENCE: Precedence;
@@ -220,14 +223,14 @@ export type BaseEntry = {
220
223
  * @category Latex Parsing and Serialization
221
224
  */
222
225
  export type DefaultEntry = BaseEntry & Trigger & {
223
- parse: Expression | ExpressionParseHandler;
226
+ parse?: Expression | ExpressionParseHandler;
224
227
  };
225
228
  /**
226
229
  * @category Latex Parsing and Serialization
227
230
  */
228
231
  export type ExpressionEntry = BaseEntry & Trigger & {
229
232
  kind: 'expression';
230
- parse: Expression | ExpressionParseHandler;
233
+ parse?: Expression | ExpressionParseHandler;
231
234
  precedence?: Precedence;
232
235
  };
233
236
  /**
@@ -341,7 +344,9 @@ export type FunctionEntry = BaseEntry & Trigger & {
341
344
  * @category Latex Parsing and Serialization
342
345
  *
343
346
  */
344
- export type LatexDictionaryEntry = DefaultEntry | ExpressionEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | FunctionEntry | EnvironmentEntry;
347
+ export type LatexDictionaryEntry = OneOf<[
348
+ ExpressionEntry | MatchfixEntry | InfixEntry | PostfixEntry | PrefixEntry | SymbolEntry | FunctionEntry | EnvironmentEntry | DefaultEntry
349
+ ]>;
345
350
  /** @internal */
346
351
  export declare function isExpressionEntry(entry: LatexDictionaryEntry): entry is ExpressionEntry;
347
352
  /** @internal */
@@ -475,7 +480,7 @@ export type ParseLatexOptions = NumberFormat & {
475
480
  * This handler is invoked when the parser encounters an identifier
476
481
  * that has not yet been declared.
477
482
  *
478
- * The `identifier` argument is a (valid identifier)[/math-json/#identifiers].
483
+ * The `identifier` argument is a [valid identifier](/math-json/#identifiers).
479
484
  *
480
485
  * The handler can return:
481
486
  *
@@ -575,7 +580,7 @@ export interface Parser {
575
580
  */
576
581
  matchChar(): string | null;
577
582
  /**
578
- * Parse an expression in aLaTeX group enclosed in curly brackets `{}`.
583
+ * Parse an expression in a LaTeX group enclosed in curly brackets `{}`.
579
584
  * These are often used as arguments to LaTeX commands, for example
580
585
  * `\frac{1}{2}`.
581
586
  *
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { NumberSerializationFormat } from './public';
3
3
  /**
4
4
  * @param expr - A number, can be represented as a string
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
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;
@@ -1,4 +1,4 @@
1
- /* 0.27.0 */
1
+ /* 0.28.0 */
2
2
  import { LatexString, SerializeLatexOptions, DelimiterScale } from './public';
3
3
  import type { IndexedLatexDictionary, IndexedLatexDictionaryEntry } from './dictionary/definitions';
4
4
  export declare class Serializer {