@cortex-js/compute-engine 0.55.5 → 0.56.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/dist/compile.esm.js +912 -770
- package/dist/compile.min.esm.js +300 -523
- package/dist/compile.min.umd.cjs +301 -524
- package/dist/compile.umd.cjs +912 -770
- package/dist/compute-engine.esm.js +1517 -902
- package/dist/compute-engine.min.esm.js +300 -522
- package/dist/compute-engine.min.umd.cjs +300 -522
- package/dist/compute-engine.umd.cjs +1517 -902
- package/dist/core.esm.js +1516 -901
- package/dist/core.min.esm.js +299 -521
- package/dist/core.min.umd.cjs +299 -521
- package/dist/core.umd.cjs +1516 -901
- package/dist/interval.esm.js +268 -63
- package/dist/interval.min.esm.js +7 -7
- package/dist/interval.min.umd.cjs +7 -7
- package/dist/interval.umd.cjs +268 -63
- package/dist/latex-syntax.esm.js +371 -77
- package/dist/latex-syntax.min.esm.js +7 -6
- package/dist/latex-syntax.min.umd.cjs +7 -6
- package/dist/latex-syntax.umd.cjs +371 -77
- package/dist/math-json.esm.js +2 -2
- package/dist/math-json.min.esm.js +2 -2
- package/dist/math-json.min.umd.cjs +2 -2
- package/dist/math-json.umd.cjs +2 -2
- package/dist/numerics.esm.js +4 -2
- package/dist/numerics.min.esm.js +3 -3
- package/dist/numerics.min.umd.cjs +3 -3
- package/dist/numerics.umd.cjs +4 -2
- package/dist/types/big-decimal/big-decimal.d.ts +1 -1
- package/dist/types/big-decimal/index.d.ts +1 -1
- package/dist/types/big-decimal/transcendentals.d.ts +1 -1
- package/dist/types/big-decimal/utils.d.ts +1 -1
- package/dist/types/common/ansi-codes.d.ts +1 -1
- package/dist/types/common/configuration-change.d.ts +1 -1
- package/dist/types/common/fuzzy-string-match.d.ts +1 -1
- package/dist/types/common/grapheme-splitter.d.ts +1 -1
- package/dist/types/common/interruptible.d.ts +1 -1
- package/dist/types/common/one-of.d.ts +1 -1
- package/dist/types/common/signals.d.ts +1 -1
- package/dist/types/common/type/ast-nodes.d.ts +1 -1
- package/dist/types/common/type/boxed-type.d.ts +1 -1
- package/dist/types/common/type/lexer.d.ts +1 -1
- package/dist/types/common/type/parse.d.ts +1 -1
- package/dist/types/common/type/parser.d.ts +1 -1
- package/dist/types/common/type/primitive.d.ts +1 -1
- package/dist/types/common/type/reduce.d.ts +1 -1
- package/dist/types/common/type/serialize.d.ts +1 -1
- package/dist/types/common/type/subtype.d.ts +1 -1
- package/dist/types/common/type/type-builder.d.ts +1 -1
- package/dist/types/common/type/types.d.ts +2 -2
- package/dist/types/common/type/utils.d.ts +1 -1
- package/dist/types/common/utils.d.ts +1 -1
- package/dist/types/compile.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 +1 -1
- package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -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-function.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
- 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.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/constants.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/inequality-bounds.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/init-lazy-refs.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/invisible-operator.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/pattern-utils.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomial-degree.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/predicates.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve-linear-system.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/stochastic-equal.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/boxed-expression/type-guards.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/collection-utils.d.ts +1 -1
- package/dist/types/compute-engine/compilation/base-compiler.d.ts +1 -1
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +2 -3
- package/dist/types/compute-engine/compilation/constant-folding.d.ts +1 -1
- package/dist/types/compute-engine/compilation/glsl-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/gpu-target.d.ts +15 -58
- package/dist/types/compute-engine/compilation/interval-javascript-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/javascript-target.d.ts +25 -3
- package/dist/types/compute-engine/compilation/python-target.d.ts +1 -1
- package/dist/types/compute-engine/compilation/types.d.ts +1 -67
- package/dist/types/compute-engine/compilation/wgsl-target.d.ts +1 -1
- package/dist/types/compute-engine/cost-function.d.ts +1 -1
- package/dist/types/compute-engine/engine-assumptions.d.ts +1 -1
- package/dist/types/compute-engine/engine-cache.d.ts +1 -1
- package/dist/types/compute-engine/engine-common-symbols.d.ts +1 -1
- package/dist/types/compute-engine/engine-compilation-targets.d.ts +1 -1
- package/dist/types/compute-engine/engine-configuration-lifecycle.d.ts +1 -1
- package/dist/types/compute-engine/engine-declarations.d.ts +1 -1
- package/dist/types/compute-engine/engine-expression-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/engine-extension-contracts.d.ts +1 -1
- package/dist/types/compute-engine/engine-library-bootstrap.d.ts +1 -1
- package/dist/types/compute-engine/engine-numeric-configuration.d.ts +1 -1
- package/dist/types/compute-engine/engine-runtime-state.d.ts +1 -1
- package/dist/types/compute-engine/engine-scope.d.ts +1 -1
- package/dist/types/compute-engine/engine-sequences.d.ts +1 -1
- package/dist/types/compute-engine/engine-simplification-rules.d.ts +1 -1
- package/dist/types/compute-engine/engine-startup-coordinator.d.ts +1 -1
- package/dist/types/compute-engine/engine-type-resolver.d.ts +1 -1
- package/dist/types/compute-engine/engine-validation-entrypoints.d.ts +1 -1
- package/dist/types/compute-engine/free-functions.d.ts +1 -1
- package/dist/types/compute-engine/function-utils.d.ts +1 -1
- package/dist/types/compute-engine/global-types.d.ts +1 -1
- package/dist/types/compute-engine/index.d.ts +23 -3
- package/dist/types/compute-engine/interval/arithmetic.d.ts +1 -1
- package/dist/types/compute-engine/interval/comparison.d.ts +1 -1
- package/dist/types/compute-engine/interval/elementary.d.ts +1 -1
- package/dist/types/compute-engine/interval/index.d.ts +1 -1
- package/dist/types/compute-engine/interval/trigonometric.d.ts +1 -1
- package/dist/types/compute-engine/interval/types.d.ts +1 -1
- package/dist/types/compute-engine/interval/util.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/default-dictionary.d.ts +4 -3
- 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-colors.d.ts +10 -0
- 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-units.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/dictionary/indexed-types.d.ts +9 -1
- package/dist/types/compute-engine/latex-syntax/latex-syntax.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-number.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/serialize-dms.d.ts +1 -1
- 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 +4 -2
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/utils.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/colors.d.ts +1 -1
- package/dist/types/compute-engine/library/combinatorics.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/fractals.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-analysis.d.ts +1 -1
- package/dist/types/compute-engine/library/logic.d.ts +1 -1
- package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
- package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
- package/dist/types/compute-engine/library/quantity-arithmetic.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/statistics.d.ts +1 -1
- package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
- package/dist/types/compute-engine/library/type-handlers.d.ts +1 -1
- package/dist/types/compute-engine/library/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/library/units.d.ts +1 -1
- package/dist/types/compute-engine/library/utils.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
- package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
- package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
- package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
- package/dist/types/compute-engine/numerics/linear-algebra.d.ts +1 -1
- package/dist/types/compute-engine/numerics/monte-carlo.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/numerics/richardson.d.ts +1 -1
- package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
- package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
- package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
- package/dist/types/compute-engine/numerics/types.d.ts +1 -1
- package/dist/types/compute-engine/numerics/unit-data.d.ts +1 -1
- package/dist/types/compute-engine/oeis.d.ts +1 -1
- package/dist/types/compute-engine/sequence.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-cost.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu-transforms.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/fu.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/logic-utils.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-abs.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-divide.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-factorial.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-hyperbolic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-infinity.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-log.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-logic.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-power.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-product.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-sum.d.ts +1 -1
- package/dist/types/compute-engine/symbolic/simplify-trig.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
- package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
- package/dist/types/compute-engine/types-definitions.d.ts +1 -1
- package/dist/types/compute-engine/types-engine.d.ts +6 -2
- package/dist/types/compute-engine/types-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-expression.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-evaluation.d.ts +1 -1
- package/dist/types/compute-engine/types-kernel-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types-serialization.d.ts +1 -1
- package/dist/types/compute-engine/types.d.ts +1 -1
- package/dist/types/compute-engine.d.ts +2 -3
- package/dist/types/core.d.ts +1 -1
- package/dist/types/interval.d.ts +1 -1
- package/dist/types/latex-syntax.d.ts +2 -2
- package/dist/types/math-json/symbols.d.ts +1 -1
- package/dist/types/math-json/types.d.ts +1 -1
- package/dist/types/math-json/utils.d.ts +1 -1
- package/dist/types/math-json.d.ts +2 -2
- package/dist/types/numerics.d.ts +1 -1
- package/package.json +2 -2
- package/dist/types/compute-engine/compilation/fractal-orbit.d.ts +0 -19
package/dist/latex-syntax.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.
|
|
1
|
+
/** Compute Engine 0.56.0 */
|
|
2
2
|
|
|
3
3
|
// src/math-json/utils.ts
|
|
4
4
|
var MISSING = ["Error", "'missing'"];
|
|
@@ -1146,6 +1146,7 @@ var SCALAR_TYPES = [
|
|
|
1146
1146
|
];
|
|
1147
1147
|
var VALUE_TYPES = [
|
|
1148
1148
|
"value",
|
|
1149
|
+
"color",
|
|
1149
1150
|
...COLLECTION_TYPES,
|
|
1150
1151
|
...SCALAR_TYPES
|
|
1151
1152
|
];
|
|
@@ -2797,6 +2798,7 @@ var PRIMITIVE_SUBTYPES = {
|
|
|
2797
2798
|
symbol: [],
|
|
2798
2799
|
boolean: [],
|
|
2799
2800
|
string: [],
|
|
2801
|
+
color: [],
|
|
2800
2802
|
expression: EXPRESSION_TYPES
|
|
2801
2803
|
};
|
|
2802
2804
|
function isPrimitiveSubtype(lhs, rhs) {
|
|
@@ -4743,10 +4745,6 @@ var DEFINITIONS_CORE = [
|
|
|
4743
4745
|
// Lagrange notation
|
|
4744
4746
|
{
|
|
4745
4747
|
name: "Derivative",
|
|
4746
|
-
// @todo: Leibniz notation: {% latex " \\frac{d^n}{dx^n} f(x)" %}
|
|
4747
|
-
// @todo: Euler modified notation: This notation is used by Mathematica. The Euler notation uses `D` instead of
|
|
4748
|
-
// `\partial`: `\partial_{x} f`, `\partial_{x,y} f`
|
|
4749
|
-
// Newton notation (\dot{v}, \ddot{v}) is implemented below
|
|
4750
4748
|
serialize: (serializer, expr) => {
|
|
4751
4749
|
const degree = machineValue(operand(expr, 2)) ?? 1;
|
|
4752
4750
|
const base = serializer.serialize(operand(expr, 1));
|
|
@@ -5784,14 +5782,18 @@ var DEFINITIONS_SETS = [
|
|
|
5784
5782
|
return ["Complement", lhs];
|
|
5785
5783
|
}
|
|
5786
5784
|
// precedence: 240,
|
|
5787
|
-
// @todo: serialize for the multiple argument case
|
|
5788
5785
|
},
|
|
5789
5786
|
{
|
|
5790
5787
|
name: "Complement",
|
|
5791
5788
|
latexTrigger: ["^", "<{>", "\\complement", "<}>"],
|
|
5792
|
-
kind: "postfix"
|
|
5789
|
+
kind: "postfix",
|
|
5793
5790
|
// precedence: 240,
|
|
5794
|
-
|
|
5791
|
+
serialize: (serializer, expr) => {
|
|
5792
|
+
return joinLatex([
|
|
5793
|
+
serializer.serialize(operand(expr, 1)),
|
|
5794
|
+
"^\\complement"
|
|
5795
|
+
]);
|
|
5796
|
+
}
|
|
5795
5797
|
},
|
|
5796
5798
|
{
|
|
5797
5799
|
name: "Intersection",
|
|
@@ -5878,7 +5880,6 @@ var DEFINITIONS_SETS = [
|
|
|
5878
5880
|
// commands like \rbrack a, b \rbrack which are unambiguous.
|
|
5879
5881
|
{
|
|
5880
5882
|
name: "Multiple",
|
|
5881
|
-
// @todo: parse
|
|
5882
5883
|
serialize: serializeSet
|
|
5883
5884
|
},
|
|
5884
5885
|
{
|
|
@@ -5887,14 +5888,28 @@ var DEFINITIONS_SETS = [
|
|
|
5887
5888
|
kind: "infix",
|
|
5888
5889
|
precedence: 350
|
|
5889
5890
|
},
|
|
5891
|
+
// \mid as a separator/operator (used in set-builder notation: {x \mid x > 0})
|
|
5892
|
+
// Low precedence so it binds loosely — everything on each side is parsed first
|
|
5893
|
+
{
|
|
5894
|
+
name: "Divides",
|
|
5895
|
+
latexTrigger: ["\\mid"],
|
|
5896
|
+
kind: "infix",
|
|
5897
|
+
precedence: 160
|
|
5898
|
+
},
|
|
5890
5899
|
{
|
|
5891
5900
|
name: "Set",
|
|
5892
5901
|
kind: "matchfix",
|
|
5893
5902
|
openTrigger: "{",
|
|
5894
5903
|
closeTrigger: "}",
|
|
5895
|
-
// @todo: the set syntax can also include conditions...
|
|
5896
5904
|
parse: (_parser, body) => {
|
|
5897
5905
|
if (isEmptySequence(body)) return "EmptySet";
|
|
5906
|
+
const h = operator(body);
|
|
5907
|
+
if (h === "Divides" || h === "Colon") {
|
|
5908
|
+
const expr = operand(body, 1);
|
|
5909
|
+
const condition = operand(body, 2);
|
|
5910
|
+
if (expr !== null && condition !== null)
|
|
5911
|
+
return ["Set", expr, ["Condition", condition]];
|
|
5912
|
+
}
|
|
5898
5913
|
if (operator(body) == "Delimiter" && stringValue(operand(body, 2)) === ",") {
|
|
5899
5914
|
body = operand(body, 1);
|
|
5900
5915
|
}
|
|
@@ -5902,6 +5917,17 @@ var DEFINITIONS_SETS = [
|
|
|
5902
5917
|
return ["Set", ...operands(body)];
|
|
5903
5918
|
},
|
|
5904
5919
|
serialize: (serializer, expr) => {
|
|
5920
|
+
if (nops(expr) === 2 && operator(operand(expr, 2)) === "Condition") {
|
|
5921
|
+
const condition = operand(expr, 2);
|
|
5922
|
+
return joinLatex([
|
|
5923
|
+
"\\lbrace",
|
|
5924
|
+
serializer.serialize(operand(expr, 1)),
|
|
5925
|
+
"\\mid",
|
|
5926
|
+
// Serialize the inner expression of the Condition wrapper
|
|
5927
|
+
serializer.serialize(operand(condition, 1)),
|
|
5928
|
+
"\\rbrace"
|
|
5929
|
+
]);
|
|
5930
|
+
}
|
|
5905
5931
|
return joinLatex([
|
|
5906
5932
|
"\\lbrace",
|
|
5907
5933
|
operands(expr).map((x) => serializer.serialize(x)).join(", "),
|
|
@@ -6068,23 +6094,6 @@ function serializeSet(serializer, expr) {
|
|
|
6068
6094
|
if (expr === null) return "";
|
|
6069
6095
|
const h = operator(expr);
|
|
6070
6096
|
if (!h) return "";
|
|
6071
|
-
if (h === "Set") {
|
|
6072
|
-
if (nops(expr) === 0) return "\\emptyset";
|
|
6073
|
-
if (nops(expr) === 2 && operator(operand(expr, 2)) === "Condition") {
|
|
6074
|
-
return joinLatex([
|
|
6075
|
-
"\\left\\lbrace",
|
|
6076
|
-
serializer.serialize(operand(expr, 1)),
|
|
6077
|
-
"\\middle\\mid",
|
|
6078
|
-
serializer.serialize(operand(expr, 2)),
|
|
6079
|
-
"\\right\\rbrace"
|
|
6080
|
-
]);
|
|
6081
|
-
}
|
|
6082
|
-
return joinLatex([
|
|
6083
|
-
"\\left\\lbrace",
|
|
6084
|
-
...operands(expr).map((x) => serializer.serialize(x) + " ,"),
|
|
6085
|
-
"\\right\\rbrace"
|
|
6086
|
-
]);
|
|
6087
|
-
}
|
|
6088
6097
|
if (h === "Multiple") {
|
|
6089
6098
|
}
|
|
6090
6099
|
if (h === "Range") {
|
|
@@ -7232,11 +7241,13 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
7232
7241
|
if (!parser.match("_")) return null;
|
|
7233
7242
|
const base = parser.parseGroup();
|
|
7234
7243
|
if (operator(base) !== "To") return null;
|
|
7235
|
-
const expr = parser.
|
|
7244
|
+
const expr = parser.parseExpression({
|
|
7245
|
+
minPrec: MULTIPLICATION_PRECEDENCE
|
|
7246
|
+
});
|
|
7236
7247
|
if (!expr) return null;
|
|
7237
7248
|
return [
|
|
7238
7249
|
"Limit",
|
|
7239
|
-
["Function", expr
|
|
7250
|
+
["Function", expr, operand(base, 1)],
|
|
7240
7251
|
operand(base, 2)
|
|
7241
7252
|
];
|
|
7242
7253
|
},
|
|
@@ -7317,6 +7328,8 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
7317
7328
|
precedence: DIVISION_PRECEDENCE,
|
|
7318
7329
|
parse: "Mod"
|
|
7319
7330
|
},
|
|
7331
|
+
// Function-style alias: `\operatorname{mod}(a, b)`
|
|
7332
|
+
{ latexTrigger: "\\operatorname{mod}", parse: "Mod" },
|
|
7320
7333
|
{
|
|
7321
7334
|
latexTrigger: "\\pmod",
|
|
7322
7335
|
kind: "prefix",
|
|
@@ -7557,6 +7570,13 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
7557
7570
|
const rhs = serializer.wrap(operand(expr, 2), ADDITION_PRECEDENCE + 3);
|
|
7558
7571
|
return joinLatex([lhs, "-", rhs]);
|
|
7559
7572
|
}
|
|
7573
|
+
},
|
|
7574
|
+
// Euclidean distance between two points (tuples of numbers).
|
|
7575
|
+
{
|
|
7576
|
+
name: "Distance",
|
|
7577
|
+
latexTrigger: ["\\operatorname{distance}"],
|
|
7578
|
+
kind: "function",
|
|
7579
|
+
serialize: (serializer, expr) => "\\operatorname{distance}" + serializer.wrapArguments(expr)
|
|
7560
7580
|
}
|
|
7561
7581
|
];
|
|
7562
7582
|
function getIndexAssignment(expr, upper) {
|
|
@@ -8981,7 +9001,9 @@ var DEFINITIONS_STATISTICS = [
|
|
|
8981
9001
|
if (!expr || !symbol(expr)) return null;
|
|
8982
9002
|
return ["Mean", expr];
|
|
8983
9003
|
}
|
|
8984
|
-
}
|
|
9004
|
+
},
|
|
9005
|
+
// Function-style alias: `\operatorname{var}(...)`
|
|
9006
|
+
{ latexTrigger: "\\operatorname{var}", parse: "Variance" }
|
|
8985
9007
|
];
|
|
8986
9008
|
|
|
8987
9009
|
// src/compute-engine/numerics/unit-data.ts
|
|
@@ -9440,12 +9462,52 @@ var DEFINITIONS_UNITS = [
|
|
|
9440
9462
|
];
|
|
9441
9463
|
|
|
9442
9464
|
// src/compute-engine/latex-syntax/dictionary/definitions-other.ts
|
|
9465
|
+
var TEX_UNITS = [
|
|
9466
|
+
"pt",
|
|
9467
|
+
"em",
|
|
9468
|
+
"mu",
|
|
9469
|
+
"ex",
|
|
9470
|
+
"mm",
|
|
9471
|
+
"cm",
|
|
9472
|
+
"in",
|
|
9473
|
+
"bp",
|
|
9474
|
+
"sp",
|
|
9475
|
+
"dd",
|
|
9476
|
+
"cc",
|
|
9477
|
+
"pc",
|
|
9478
|
+
"nc",
|
|
9479
|
+
"nd"
|
|
9480
|
+
];
|
|
9481
|
+
function skipTexDimension(parser) {
|
|
9482
|
+
parser.skipSpace();
|
|
9483
|
+
if (parser.peek === "-" || parser.peek === "+") parser.nextToken();
|
|
9484
|
+
while (/^[\d.]$/.test(parser.peek)) parser.nextToken();
|
|
9485
|
+
for (const unit of TEX_UNITS) {
|
|
9486
|
+
if (parser.matchAll([...unit])) return;
|
|
9487
|
+
}
|
|
9488
|
+
}
|
|
9443
9489
|
function parseSingleArg(cmd) {
|
|
9444
9490
|
return (parser) => {
|
|
9445
9491
|
const arg = parser.parseGroup();
|
|
9446
9492
|
return arg === null ? [cmd] : [cmd, arg];
|
|
9447
9493
|
};
|
|
9448
9494
|
}
|
|
9495
|
+
function parseMathStyleSwitch(mathStyle) {
|
|
9496
|
+
return (parser) => {
|
|
9497
|
+
const body = parser.parseExpression();
|
|
9498
|
+
if (body !== null && !isEmptySequence(body))
|
|
9499
|
+
return ["Annotated", body, { dict: { mathStyle } }];
|
|
9500
|
+
return "Nothing";
|
|
9501
|
+
};
|
|
9502
|
+
}
|
|
9503
|
+
function parseSizeSwitch(size) {
|
|
9504
|
+
return (parser) => {
|
|
9505
|
+
const body = parser.parseExpression();
|
|
9506
|
+
if (body !== null && !isEmptySequence(body))
|
|
9507
|
+
return ["Annotated", body, { dict: { size } }];
|
|
9508
|
+
return "Nothing";
|
|
9509
|
+
};
|
|
9510
|
+
}
|
|
9449
9511
|
var DEFINITIONS_OTHERS = [
|
|
9450
9512
|
{
|
|
9451
9513
|
name: "Overscript",
|
|
@@ -9685,80 +9747,71 @@ var DEFINITIONS_OTHERS = [
|
|
|
9685
9747
|
},
|
|
9686
9748
|
{
|
|
9687
9749
|
latexTrigger: ["\\displaystyle"],
|
|
9688
|
-
parse: (
|
|
9689
|
-
// @todo: parse as ['Annotated'...]
|
|
9750
|
+
parse: parseMathStyleSwitch("normal")
|
|
9690
9751
|
},
|
|
9691
9752
|
{
|
|
9692
9753
|
latexTrigger: ["\\textstyle"],
|
|
9693
|
-
parse: (
|
|
9694
|
-
// @todo: parse as ['Annotated'...]
|
|
9754
|
+
parse: parseMathStyleSwitch("compact")
|
|
9695
9755
|
},
|
|
9696
9756
|
{
|
|
9697
9757
|
latexTrigger: ["\\scriptstyle"],
|
|
9698
|
-
parse: (
|
|
9699
|
-
// @todo: parse as ['Annotated'...]
|
|
9758
|
+
parse: parseMathStyleSwitch("script")
|
|
9700
9759
|
},
|
|
9701
9760
|
{
|
|
9702
9761
|
latexTrigger: ["\\scriptscriptstyle"],
|
|
9703
|
-
parse: (
|
|
9704
|
-
// @todo: parse as ['Annotated'...]
|
|
9762
|
+
parse: parseMathStyleSwitch("scriptscript")
|
|
9705
9763
|
},
|
|
9706
9764
|
{
|
|
9707
9765
|
latexTrigger: ["\\color"],
|
|
9708
9766
|
parse: (parser) => {
|
|
9709
|
-
parser.
|
|
9767
|
+
const color = parser.parseStringGroup();
|
|
9768
|
+
if (color !== null) {
|
|
9769
|
+
const body = parser.parseExpression();
|
|
9770
|
+
if (body !== null && !isEmptySequence(body))
|
|
9771
|
+
return ["Annotated", body, { dict: { color } }];
|
|
9772
|
+
}
|
|
9710
9773
|
return "Nothing";
|
|
9711
9774
|
}
|
|
9712
9775
|
},
|
|
9713
9776
|
{
|
|
9714
9777
|
latexTrigger: ["\\tiny"],
|
|
9715
|
-
parse: ()
|
|
9716
|
-
// @todo: parse as ['Annotated'...]
|
|
9778
|
+
parse: parseSizeSwitch(1)
|
|
9717
9779
|
},
|
|
9718
9780
|
{
|
|
9719
9781
|
latexTrigger: ["\\scriptsize"],
|
|
9720
|
-
parse: ()
|
|
9721
|
-
// @todo: parse as ['Annotated'...]
|
|
9782
|
+
parse: parseSizeSwitch(2)
|
|
9722
9783
|
},
|
|
9723
9784
|
{
|
|
9724
9785
|
latexTrigger: ["\\footnotesize"],
|
|
9725
|
-
parse: ()
|
|
9726
|
-
// @todo: parse as ['Annotated'...]
|
|
9786
|
+
parse: parseSizeSwitch(3)
|
|
9727
9787
|
},
|
|
9728
9788
|
{
|
|
9729
9789
|
latexTrigger: ["\\small"],
|
|
9730
|
-
parse: ()
|
|
9731
|
-
// @todo: parse as ['Annotated'...]
|
|
9790
|
+
parse: parseSizeSwitch(4)
|
|
9732
9791
|
},
|
|
9733
9792
|
{
|
|
9734
9793
|
latexTrigger: ["\\normalsize"],
|
|
9735
|
-
parse: ()
|
|
9736
|
-
// @todo: parse as ['Annotated'...]
|
|
9794
|
+
parse: parseSizeSwitch(5)
|
|
9737
9795
|
},
|
|
9738
9796
|
{
|
|
9739
9797
|
latexTrigger: ["\\large"],
|
|
9740
|
-
parse: ()
|
|
9741
|
-
// @todo: parse as ['Annotated'...]
|
|
9798
|
+
parse: parseSizeSwitch(6)
|
|
9742
9799
|
},
|
|
9743
9800
|
{
|
|
9744
9801
|
latexTrigger: ["\\Large"],
|
|
9745
|
-
parse: ()
|
|
9746
|
-
// @todo: parse as ['Annotated'...]
|
|
9802
|
+
parse: parseSizeSwitch(7)
|
|
9747
9803
|
},
|
|
9748
9804
|
{
|
|
9749
9805
|
latexTrigger: ["\\LARGE"],
|
|
9750
|
-
parse: ()
|
|
9751
|
-
// @todo: parse as ['Annotated'...]
|
|
9806
|
+
parse: parseSizeSwitch(8)
|
|
9752
9807
|
},
|
|
9753
9808
|
{
|
|
9754
9809
|
latexTrigger: ["\\huge"],
|
|
9755
|
-
parse: ()
|
|
9756
|
-
// @todo: parse as ['Annotated'...]
|
|
9810
|
+
parse: parseSizeSwitch(9)
|
|
9757
9811
|
},
|
|
9758
9812
|
{
|
|
9759
9813
|
latexTrigger: ["\\Huge"],
|
|
9760
|
-
parse: ()
|
|
9761
|
-
// @todo: parse as ['Annotated'...]
|
|
9814
|
+
parse: parseSizeSwitch(10)
|
|
9762
9815
|
},
|
|
9763
9816
|
{
|
|
9764
9817
|
name: "Annotated",
|
|
@@ -9770,6 +9823,10 @@ var DEFINITIONS_OTHERS = [
|
|
|
9770
9823
|
result = joinLatex(["{\\displaystyle", result, "}"]);
|
|
9771
9824
|
else if (dict.dict.mathStyle === "compact")
|
|
9772
9825
|
result = joinLatex(["{\\textstyle", result, "}"]);
|
|
9826
|
+
else if (dict.dict.mathStyle === "script")
|
|
9827
|
+
result = joinLatex(["{\\scriptstyle", result, "}"]);
|
|
9828
|
+
else if (dict.dict.mathStyle === "scriptscript")
|
|
9829
|
+
result = joinLatex(["{\\scriptscriptstyle", result, "}"]);
|
|
9773
9830
|
const v = dict.dict.size;
|
|
9774
9831
|
if (v !== null && v >= 1 && v <= 10) {
|
|
9775
9832
|
result = joinLatex([
|
|
@@ -9857,6 +9914,28 @@ var DEFINITIONS_OTHERS = [
|
|
|
9857
9914
|
latexTrigger: ["\\enspace"],
|
|
9858
9915
|
parse: () => ["HorizontalSpacing", 9]
|
|
9859
9916
|
},
|
|
9917
|
+
{
|
|
9918
|
+
latexTrigger: ["\\hspace"],
|
|
9919
|
+
parse: (parser) => {
|
|
9920
|
+
if (parser.peek === "*") parser.nextToken();
|
|
9921
|
+
parser.parseStringGroup();
|
|
9922
|
+
return ["HorizontalSpacing", 0];
|
|
9923
|
+
}
|
|
9924
|
+
},
|
|
9925
|
+
{
|
|
9926
|
+
latexTrigger: ["\\hskip"],
|
|
9927
|
+
parse: (parser) => {
|
|
9928
|
+
skipTexDimension(parser);
|
|
9929
|
+
return ["HorizontalSpacing", 0];
|
|
9930
|
+
}
|
|
9931
|
+
},
|
|
9932
|
+
{
|
|
9933
|
+
latexTrigger: ["\\kern"],
|
|
9934
|
+
parse: (parser) => {
|
|
9935
|
+
skipTexDimension(parser);
|
|
9936
|
+
return ["HorizontalSpacing", 0];
|
|
9937
|
+
}
|
|
9938
|
+
},
|
|
9860
9939
|
{
|
|
9861
9940
|
latexTrigger: ["\\phantom"],
|
|
9862
9941
|
parse: (parser) => {
|
|
@@ -9907,7 +9986,17 @@ var DEFINITIONS_OTHERS = [
|
|
|
9907
9986
|
// `["HorizontalSpacing", expr, 'op'|'bin'|rel]` -> indicate a spacing around and expression, i.e. `\mathbin{x}`, etc...
|
|
9908
9987
|
serialize: (serializer, expr) => {
|
|
9909
9988
|
if (operand(expr, 2) !== null) {
|
|
9910
|
-
|
|
9989
|
+
const cls = stringValue(operand(expr, 2));
|
|
9990
|
+
const inner = serializer.serialize(operand(expr, 1));
|
|
9991
|
+
if (cls === "bin") return `\\mathbin{${inner}}`;
|
|
9992
|
+
if (cls === "op") return `\\mathop{${inner}}`;
|
|
9993
|
+
if (cls === "rel") return `\\mathrel{${inner}}`;
|
|
9994
|
+
if (cls === "ord") return `\\mathord{${inner}}`;
|
|
9995
|
+
if (cls === "open") return `\\mathopen{${inner}}`;
|
|
9996
|
+
if (cls === "close") return `\\mathclose{${inner}}`;
|
|
9997
|
+
if (cls === "punct") return `\\mathpunct{${inner}}`;
|
|
9998
|
+
if (cls === "inner") return `\\mathinner{${inner}}`;
|
|
9999
|
+
return inner;
|
|
9911
10000
|
}
|
|
9912
10001
|
const v = machineValue(operand(expr, 1));
|
|
9913
10002
|
if (v === null) return "";
|
|
@@ -9922,7 +10011,7 @@ var DEFINITIONS_OTHERS = [
|
|
|
9922
10011
|
36: "\\qquad"
|
|
9923
10012
|
}[v] ?? "";
|
|
9924
10013
|
}
|
|
9925
|
-
}
|
|
10014
|
+
},
|
|
9926
10015
|
// if (
|
|
9927
10016
|
// [
|
|
9928
10017
|
// '\\!',
|
|
@@ -9946,6 +10035,121 @@ var DEFINITIONS_OTHERS = [
|
|
|
9946
10035
|
// name: '',
|
|
9947
10036
|
// trigger: '\\check',
|
|
9948
10037
|
// },
|
|
10038
|
+
// ---------------------------------------------------------------------------
|
|
10039
|
+
// Function-style aliases for collection / random operators that some
|
|
10040
|
+
// notations write in lowercase (e.g. `\operatorname{shuffle}(L)`).
|
|
10041
|
+
// The capitalized library entries already exist; these are pure parse
|
|
10042
|
+
// aliases so the lowercase names don't land in `unsupported-operator`.
|
|
10043
|
+
// ---------------------------------------------------------------------------
|
|
10044
|
+
{ latexTrigger: "\\operatorname{random}", parse: "Random" },
|
|
10045
|
+
{ latexTrigger: "\\operatorname{shuffle}", parse: "Shuffle" },
|
|
10046
|
+
{ latexTrigger: "\\operatorname{repeat}", parse: "Repeat" },
|
|
10047
|
+
{ latexTrigger: "\\operatorname{join}", parse: "Join" },
|
|
10048
|
+
// ---------------------------------------------------------------------------
|
|
10049
|
+
// Geometric primitive heads. Registered as known typed heads so consumers
|
|
10050
|
+
// can branch on the operator name; CE itself doesn't render them. The
|
|
10051
|
+
// library entries (with no evaluator) live in `library/core.ts`.
|
|
10052
|
+
// ---------------------------------------------------------------------------
|
|
10053
|
+
{
|
|
10054
|
+
name: "Triangle",
|
|
10055
|
+
latexTrigger: ["\\operatorname{triangle}"],
|
|
10056
|
+
kind: "function",
|
|
10057
|
+
serialize: (serializer, expr) => "\\operatorname{triangle}" + serializer.wrapArguments(expr)
|
|
10058
|
+
},
|
|
10059
|
+
// Desmos's geometric `vector(p1, p2)` — a directed segment between two
|
|
10060
|
+
// points. Routed to a dedicated head (not the existing column-vector
|
|
10061
|
+
// `Vector`, which has a narrower `(number+) -> vector` signature).
|
|
10062
|
+
{
|
|
10063
|
+
name: "GeometricVector",
|
|
10064
|
+
latexTrigger: ["\\operatorname{vector}"],
|
|
10065
|
+
kind: "function",
|
|
10066
|
+
serialize: (serializer, expr) => "\\operatorname{vector}" + serializer.wrapArguments(expr)
|
|
10067
|
+
},
|
|
10068
|
+
{
|
|
10069
|
+
name: "Sphere",
|
|
10070
|
+
latexTrigger: ["\\operatorname{sphere}"],
|
|
10071
|
+
kind: "function",
|
|
10072
|
+
serialize: (serializer, expr) => "\\operatorname{sphere}" + serializer.wrapArguments(expr)
|
|
10073
|
+
},
|
|
10074
|
+
{
|
|
10075
|
+
name: "Segment",
|
|
10076
|
+
latexTrigger: ["\\operatorname{segment}"],
|
|
10077
|
+
kind: "function",
|
|
10078
|
+
serialize: (serializer, expr) => "\\operatorname{segment}" + serializer.wrapArguments(expr)
|
|
10079
|
+
}
|
|
10080
|
+
];
|
|
10081
|
+
|
|
10082
|
+
// src/compute-engine/latex-syntax/dictionary/definitions-colors.ts
|
|
10083
|
+
var DEFINITIONS_COLORS = [
|
|
10084
|
+
// Color constructors (one per colorspace, preserves space on evaluation)
|
|
10085
|
+
{
|
|
10086
|
+
name: "Rgb",
|
|
10087
|
+
latexTrigger: ["\\operatorname{rgb}"],
|
|
10088
|
+
kind: "function",
|
|
10089
|
+
serialize: (serializer, expr) => "\\operatorname{rgb}" + serializer.wrapArguments(expr)
|
|
10090
|
+
},
|
|
10091
|
+
{
|
|
10092
|
+
name: "Hsv",
|
|
10093
|
+
latexTrigger: ["\\operatorname{hsv}"],
|
|
10094
|
+
kind: "function",
|
|
10095
|
+
serialize: (serializer, expr) => "\\operatorname{hsv}" + serializer.wrapArguments(expr)
|
|
10096
|
+
},
|
|
10097
|
+
{
|
|
10098
|
+
name: "Hsl",
|
|
10099
|
+
latexTrigger: ["\\operatorname{hsl}"],
|
|
10100
|
+
kind: "function",
|
|
10101
|
+
serialize: (serializer, expr) => "\\operatorname{hsl}" + serializer.wrapArguments(expr)
|
|
10102
|
+
},
|
|
10103
|
+
{
|
|
10104
|
+
name: "Oklab",
|
|
10105
|
+
latexTrigger: ["\\operatorname{oklab}"],
|
|
10106
|
+
kind: "function",
|
|
10107
|
+
serialize: (serializer, expr) => "\\operatorname{oklab}" + serializer.wrapArguments(expr)
|
|
10108
|
+
},
|
|
10109
|
+
{
|
|
10110
|
+
name: "Oklch",
|
|
10111
|
+
latexTrigger: ["\\operatorname{oklch}"],
|
|
10112
|
+
kind: "function",
|
|
10113
|
+
serialize: (serializer, expr) => "\\operatorname{oklch}" + serializer.wrapArguments(expr)
|
|
10114
|
+
},
|
|
10115
|
+
// Conversion functions (color → color in the named space)
|
|
10116
|
+
{
|
|
10117
|
+
name: "AsRgb",
|
|
10118
|
+
latexTrigger: ["\\operatorname{asRgb}"],
|
|
10119
|
+
kind: "function",
|
|
10120
|
+
serialize: (serializer, expr) => "\\operatorname{asRgb}" + serializer.wrapArguments(expr)
|
|
10121
|
+
},
|
|
10122
|
+
{
|
|
10123
|
+
name: "AsHsv",
|
|
10124
|
+
latexTrigger: ["\\operatorname{asHsv}"],
|
|
10125
|
+
kind: "function",
|
|
10126
|
+
serialize: (serializer, expr) => "\\operatorname{asHsv}" + serializer.wrapArguments(expr)
|
|
10127
|
+
},
|
|
10128
|
+
{
|
|
10129
|
+
name: "AsHsl",
|
|
10130
|
+
latexTrigger: ["\\operatorname{asHsl}"],
|
|
10131
|
+
kind: "function",
|
|
10132
|
+
serialize: (serializer, expr) => "\\operatorname{asHsl}" + serializer.wrapArguments(expr)
|
|
10133
|
+
},
|
|
10134
|
+
{
|
|
10135
|
+
name: "AsOklab",
|
|
10136
|
+
latexTrigger: ["\\operatorname{asOklab}"],
|
|
10137
|
+
kind: "function",
|
|
10138
|
+
serialize: (serializer, expr) => "\\operatorname{asOklab}" + serializer.wrapArguments(expr)
|
|
10139
|
+
},
|
|
10140
|
+
{
|
|
10141
|
+
name: "AsOklch",
|
|
10142
|
+
latexTrigger: ["\\operatorname{asOklch}"],
|
|
10143
|
+
kind: "function",
|
|
10144
|
+
serialize: (serializer, expr) => "\\operatorname{asOklch}" + serializer.wrapArguments(expr)
|
|
10145
|
+
},
|
|
10146
|
+
// Perceptual difference (returns a scalar in [0, ~1])
|
|
10147
|
+
{
|
|
10148
|
+
name: "ColorDelta",
|
|
10149
|
+
latexTrigger: ["\\operatorname{colorDelta}"],
|
|
10150
|
+
kind: "function",
|
|
10151
|
+
serialize: (serializer, expr) => "\\operatorname{colorDelta}" + serializer.wrapArguments(expr)
|
|
10152
|
+
}
|
|
9949
10153
|
];
|
|
9950
10154
|
|
|
9951
10155
|
// src/compute-engine/latex-syntax/dictionary/default-dictionary.ts
|
|
@@ -9976,7 +10180,8 @@ var LATEX_DICTIONARY = [
|
|
|
9976
10180
|
...DEFINITIONS_STATISTICS,
|
|
9977
10181
|
...DEFINITIONS_UNITS,
|
|
9978
10182
|
...DEFINITIONS_OTHERS,
|
|
9979
|
-
...DEFINITIONS_PHYSICS
|
|
10183
|
+
...DEFINITIONS_PHYSICS,
|
|
10184
|
+
...DEFINITIONS_COLORS
|
|
9980
10185
|
];
|
|
9981
10186
|
|
|
9982
10187
|
// src/math-json/symbols.ts
|
|
@@ -10141,6 +10346,17 @@ function addEntry(result, entry, onError) {
|
|
|
10141
10346
|
} else if (Array.isArray(openTrigger) && openTrigger.length > 0) {
|
|
10142
10347
|
openTokens.push(openTrigger[0]);
|
|
10143
10348
|
}
|
|
10349
|
+
const closeTrigger = indexedEntry.closeTrigger;
|
|
10350
|
+
const closeTokens = /* @__PURE__ */ new Set();
|
|
10351
|
+
if (typeof closeTrigger === "string") {
|
|
10352
|
+
const variants = DELIMITER_SHORTHAND[closeTrigger];
|
|
10353
|
+
if (variants) for (const v of variants) closeTokens.add(v);
|
|
10354
|
+
else closeTokens.add(closeTrigger);
|
|
10355
|
+
if (closeTrigger === "||") closeTokens.add("|");
|
|
10356
|
+
} else if (Array.isArray(closeTrigger) && closeTrigger.length > 0) {
|
|
10357
|
+
closeTokens.add(closeTrigger[0]);
|
|
10358
|
+
}
|
|
10359
|
+
indexedEntry.closeTokens = closeTokens;
|
|
10144
10360
|
for (const token of openTokens) {
|
|
10145
10361
|
const existing = result.matchfixByOpen.get(token);
|
|
10146
10362
|
if (existing) {
|
|
@@ -10298,25 +10514,43 @@ function makeIndexedEntry(entry, onError) {
|
|
|
10298
10514
|
result.arguments = entry.arguments;
|
|
10299
10515
|
return result;
|
|
10300
10516
|
}
|
|
10517
|
+
function serializeTabularBody(serializer, body) {
|
|
10518
|
+
if (!body) return "";
|
|
10519
|
+
if (operator(body) !== "List") return serializer.serialize(body);
|
|
10520
|
+
const rows = operands(body);
|
|
10521
|
+
if (rows.length === 0) return "";
|
|
10522
|
+
if (!rows.every((row) => operator(row) === "List"))
|
|
10523
|
+
return serializer.serialize(body);
|
|
10524
|
+
return rows.map(
|
|
10525
|
+
(row) => operands(row).map((cell) => serializer.serialize(cell)).join(" & ")
|
|
10526
|
+
).join(" \\\\\n");
|
|
10527
|
+
}
|
|
10301
10528
|
function makeSerializeHandler(entry, latexTrigger, idTrigger) {
|
|
10302
10529
|
if (typeof entry.serialize === "function") return entry.serialize;
|
|
10303
10530
|
const kind = entry["kind"] ?? "expression";
|
|
10304
10531
|
if (kind === "environment") {
|
|
10305
10532
|
const envName = entry["symbolTrigger"] ?? entry.name ?? "unknown";
|
|
10306
|
-
return (serializer, expr) =>
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10533
|
+
return (serializer, expr) => {
|
|
10534
|
+
const body = operand(expr, 1);
|
|
10535
|
+
return joinLatex([
|
|
10536
|
+
`\\begin{${envName}}`,
|
|
10537
|
+
serializeTabularBody(serializer, body),
|
|
10538
|
+
`\\end{${envName}}`
|
|
10539
|
+
]);
|
|
10540
|
+
};
|
|
10311
10541
|
}
|
|
10312
10542
|
if (isMatchfixEntry(entry)) {
|
|
10313
10543
|
const openDelim = typeof entry.openTrigger === "string" ? DEFAULT_DELIMITER[entry.openTrigger] : tokensToString(entry.openTrigger);
|
|
10314
10544
|
const closeDelim = typeof entry.closeTrigger === "string" ? DEFAULT_DELIMITER[entry.closeTrigger] : tokensToString(entry.closeTrigger);
|
|
10315
|
-
return (serializer, expr) =>
|
|
10316
|
-
|
|
10317
|
-
serializer.serialize(operand(expr, 1))
|
|
10318
|
-
|
|
10319
|
-
|
|
10545
|
+
return (serializer, expr) => {
|
|
10546
|
+
const style = serializer.groupStyle(expr, serializer.level + 1);
|
|
10547
|
+
const inner = serializer.serialize(operand(expr, 1));
|
|
10548
|
+
if (style === "scaled")
|
|
10549
|
+
return joinLatex([`\\left${openDelim}`, inner, `\\right${closeDelim}`]);
|
|
10550
|
+
if (style === "big")
|
|
10551
|
+
return joinLatex([`\\Bigl${openDelim}`, inner, `\\Bigr${closeDelim}`]);
|
|
10552
|
+
return joinLatex([openDelim, inner, closeDelim]);
|
|
10553
|
+
};
|
|
10320
10554
|
}
|
|
10321
10555
|
let latex = entry.serialize;
|
|
10322
10556
|
if (latex === void 0 && latexTrigger) latex = tokensToString(latexTrigger);
|
|
@@ -12579,6 +12813,16 @@ function parseNumber(parser, fmt) {
|
|
|
12579
12813
|
}
|
|
12580
12814
|
|
|
12581
12815
|
// src/compute-engine/latex-syntax/parse.ts
|
|
12816
|
+
var _symbolToUnicode = null;
|
|
12817
|
+
function getSymbolToUnicode() {
|
|
12818
|
+
if (!_symbolToUnicode) {
|
|
12819
|
+
_symbolToUnicode = /* @__PURE__ */ new Map();
|
|
12820
|
+
for (const [, latex, codepoint] of SYMBOLS) {
|
|
12821
|
+
_symbolToUnicode.set(latex, String.fromCodePoint(codepoint));
|
|
12822
|
+
}
|
|
12823
|
+
}
|
|
12824
|
+
return _symbolToUnicode;
|
|
12825
|
+
}
|
|
12582
12826
|
var DELIMITER_SHORTHAND2 = {
|
|
12583
12827
|
"(": ["\\lparen", "("],
|
|
12584
12828
|
")": ["\\rparen", ")"],
|
|
@@ -13026,6 +13270,35 @@ var _Parser = class __Parser {
|
|
|
13026
13270
|
this.nextToken();
|
|
13027
13271
|
this.skipVisualSpace();
|
|
13028
13272
|
}
|
|
13273
|
+
if (this.match("\\hspace")) {
|
|
13274
|
+
this.match("*");
|
|
13275
|
+
this.parseStringGroup();
|
|
13276
|
+
this.skipVisualSpace();
|
|
13277
|
+
}
|
|
13278
|
+
if (this.match("\\hskip") || this.match("\\kern")) {
|
|
13279
|
+
this.skipSpace();
|
|
13280
|
+
if (!this.match("-")) this.match("+");
|
|
13281
|
+
while (/^[\d.]$/.test(this.peek)) this.nextToken();
|
|
13282
|
+
for (const unit of [
|
|
13283
|
+
"pt",
|
|
13284
|
+
"em",
|
|
13285
|
+
"mu",
|
|
13286
|
+
"ex",
|
|
13287
|
+
"mm",
|
|
13288
|
+
"cm",
|
|
13289
|
+
"in",
|
|
13290
|
+
"bp",
|
|
13291
|
+
"sp",
|
|
13292
|
+
"dd",
|
|
13293
|
+
"cc",
|
|
13294
|
+
"pc",
|
|
13295
|
+
"nc",
|
|
13296
|
+
"nd"
|
|
13297
|
+
]) {
|
|
13298
|
+
if (this.matchAll([...unit])) break;
|
|
13299
|
+
}
|
|
13300
|
+
this.skipVisualSpace();
|
|
13301
|
+
}
|
|
13029
13302
|
this.skipSpace();
|
|
13030
13303
|
}
|
|
13031
13304
|
match(token) {
|
|
@@ -13363,7 +13636,8 @@ var _Parser = class __Parser {
|
|
|
13363
13636
|
} else if (token === "<space>") {
|
|
13364
13637
|
result += " ";
|
|
13365
13638
|
} else if (token[0] === "\\") {
|
|
13366
|
-
|
|
13639
|
+
const unicode = getSymbolToUnicode().get(token);
|
|
13640
|
+
result += unicode ?? token;
|
|
13367
13641
|
} else {
|
|
13368
13642
|
result += token;
|
|
13369
13643
|
}
|
|
@@ -13517,6 +13791,19 @@ var _Parser = class __Parser {
|
|
|
13517
13791
|
}
|
|
13518
13792
|
for (const def of defs) {
|
|
13519
13793
|
this.index = start;
|
|
13794
|
+
if (def.closeTokens.size > 0) {
|
|
13795
|
+
let found = false;
|
|
13796
|
+
const tokens = this._tokens;
|
|
13797
|
+
for (let i = start; i < tokens.length; i++) {
|
|
13798
|
+
if (def.closeTokens.has(tokens[i])) {
|
|
13799
|
+
found = true;
|
|
13800
|
+
break;
|
|
13801
|
+
}
|
|
13802
|
+
}
|
|
13803
|
+
if (!found) continue;
|
|
13804
|
+
}
|
|
13805
|
+
if (typeof def.openTrigger === "string" && def.openTrigger === "." && !OPEN_DELIMITER_PREFIX[currentToken])
|
|
13806
|
+
continue;
|
|
13520
13807
|
const matched = this.matchDelimiter(def.openTrigger, def.closeTrigger);
|
|
13521
13808
|
if (!matched) continue;
|
|
13522
13809
|
const bodyStart = this.index;
|
|
@@ -14723,7 +15010,7 @@ var STYLE_MODIFIERS = {
|
|
|
14723
15010
|
sansserif: (s) => `\\mathsf{${s}}`,
|
|
14724
15011
|
monospace: (s) => `\\mathtt{${s}}`
|
|
14725
15012
|
};
|
|
14726
|
-
var
|
|
15013
|
+
var Serializer5 = class {
|
|
14727
15014
|
options;
|
|
14728
15015
|
dictionary;
|
|
14729
15016
|
level = -1;
|
|
@@ -14738,11 +15025,18 @@ var Serializer4 = class {
|
|
|
14738
15025
|
/**
|
|
14739
15026
|
* Serialize the expression, and if the expression is an operator
|
|
14740
15027
|
* of precedence less than or equal to prec, wrap it in some parens.
|
|
14741
|
-
*
|
|
15028
|
+
*
|
|
15029
|
+
* Skip wrapping for matchfix operators (Abs, Floor, Ceil, Norm, etc.)
|
|
15030
|
+
* and Delimiter since they already have visible delimiters.
|
|
14742
15031
|
*/
|
|
14743
15032
|
wrap(expr, prec) {
|
|
14744
15033
|
if (expr === null || expr === void 0) return "";
|
|
14745
15034
|
if (prec === void 0) {
|
|
15035
|
+
const name2 = operator(expr);
|
|
15036
|
+
if (name2) {
|
|
15037
|
+
const def = this.dictionary.ids.get(name2);
|
|
15038
|
+
if (def?.kind === "matchfix") return this.serialize(expr);
|
|
15039
|
+
}
|
|
14746
15040
|
return this.wrapString(
|
|
14747
15041
|
this.serialize(expr),
|
|
14748
15042
|
this.options.groupStyle(expr, this.level + 1)
|
|
@@ -15036,7 +15330,7 @@ function serializeSymbol(s, style = "auto") {
|
|
|
15036
15330
|
return body;
|
|
15037
15331
|
}
|
|
15038
15332
|
function serializeLatex(expr, dict, options) {
|
|
15039
|
-
const serializer = new
|
|
15333
|
+
const serializer = new Serializer5(dict, options);
|
|
15040
15334
|
return serializer.serialize(expr);
|
|
15041
15335
|
}
|
|
15042
15336
|
|
|
@@ -15163,7 +15457,7 @@ function serialize(expr) {
|
|
|
15163
15457
|
}
|
|
15164
15458
|
|
|
15165
15459
|
// src/latex-syntax.ts
|
|
15166
|
-
var version = "0.
|
|
15460
|
+
var version = "0.56.0";
|
|
15167
15461
|
export {
|
|
15168
15462
|
DEFINITIONS_ALGEBRA as ALGEBRA_DICTIONARY,
|
|
15169
15463
|
DEFINITIONS_ARITHMETIC as ARITHMETIC_DICTIONARY,
|