@cortex-js/compute-engine 0.55.6 → 0.57.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 +1224 -179
- package/dist/compile.min.esm.js +290 -91
- package/dist/compile.min.umd.cjs +291 -92
- package/dist/compile.umd.cjs +1224 -179
- package/dist/compute-engine.esm.js +1973 -306
- package/dist/compute-engine.min.esm.js +301 -102
- package/dist/compute-engine.min.umd.cjs +301 -102
- package/dist/compute-engine.umd.cjs +1973 -306
- package/dist/core.esm.js +1972 -305
- package/dist/core.min.esm.js +300 -101
- package/dist/core.min.umd.cjs +300 -101
- package/dist/core.umd.cjs +1972 -305
- package/dist/interval.esm.js +360 -19
- package/dist/interval.min.esm.js +6 -6
- package/dist/interval.min.umd.cjs +6 -6
- package/dist/interval.umd.cjs +360 -19
- package/dist/latex-syntax.esm.js +427 -25
- package/dist/latex-syntax.min.esm.js +7 -7
- package/dist/latex-syntax.min.umd.cjs +7 -7
- package/dist/latex-syntax.umd.cjs +427 -25
- 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 +6 -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 +55 -6
- package/dist/types/compute-engine/compilation/compile-expression.d.ts +1 -1
- 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 -5
- 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 -1
- 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 +24 -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 +1 -1
- package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
- package/dist/types/compute-engine/latex-syntax/types.d.ts +40 -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 +5 -3
- 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 +23 -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 +1 -2
- 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/latex-syntax.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Compute Engine 0.
|
|
1
|
+
/** Compute Engine 0.57.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) {
|
|
@@ -3679,6 +3681,64 @@ function parseQuantifier(kind) {
|
|
|
3679
3681
|
}
|
|
3680
3682
|
|
|
3681
3683
|
// src/compute-engine/latex-syntax/dictionary/definitions-core.ts
|
|
3684
|
+
var COMPONENT_ACCESS_HEADS = {
|
|
3685
|
+
x: "First",
|
|
3686
|
+
y: "Second",
|
|
3687
|
+
z: "Third",
|
|
3688
|
+
real: "Real",
|
|
3689
|
+
re: "Real",
|
|
3690
|
+
imag: "Imaginary",
|
|
3691
|
+
im: "Imaginary",
|
|
3692
|
+
count: "Length",
|
|
3693
|
+
total: "Sum",
|
|
3694
|
+
max: "Max",
|
|
3695
|
+
min: "Min"
|
|
3696
|
+
};
|
|
3697
|
+
function memberHead(name) {
|
|
3698
|
+
return COMPONENT_ACCESS_HEADS[name] ?? null;
|
|
3699
|
+
}
|
|
3700
|
+
function parseComponentAccess(parser, lhs) {
|
|
3701
|
+
parser.skipVisualSpace();
|
|
3702
|
+
if (parser.match("\\operatorname")) {
|
|
3703
|
+
const name = parser.parseStringGroup();
|
|
3704
|
+
if (name === null) return null;
|
|
3705
|
+
const head = memberHead(name.trim());
|
|
3706
|
+
if (head === null) return null;
|
|
3707
|
+
return [head, lhs];
|
|
3708
|
+
}
|
|
3709
|
+
const tok = parser.peek;
|
|
3710
|
+
if (typeof tok === "string" && tok.startsWith("\\")) {
|
|
3711
|
+
const bare = tok.slice(1);
|
|
3712
|
+
const head = memberHead(bare);
|
|
3713
|
+
if (head !== null) {
|
|
3714
|
+
parser.nextToken();
|
|
3715
|
+
return [head, lhs];
|
|
3716
|
+
}
|
|
3717
|
+
return null;
|
|
3718
|
+
}
|
|
3719
|
+
if (typeof tok === "string" && /^[a-zA-Z]$/.test(tok)) {
|
|
3720
|
+
const head = memberHead(tok);
|
|
3721
|
+
if (head === null) return null;
|
|
3722
|
+
parser.nextToken();
|
|
3723
|
+
return [head, lhs];
|
|
3724
|
+
}
|
|
3725
|
+
return null;
|
|
3726
|
+
}
|
|
3727
|
+
function parseWhenRestriction(parser, lhs, close) {
|
|
3728
|
+
parser.addBoundary(close);
|
|
3729
|
+
parser.skipVisualSpace();
|
|
3730
|
+
const cond = parser.parseExpression({ minPrec: 0 });
|
|
3731
|
+
if (cond === null) {
|
|
3732
|
+
parser.removeBoundary();
|
|
3733
|
+
return null;
|
|
3734
|
+
}
|
|
3735
|
+
parser.skipVisualSpace();
|
|
3736
|
+
if (!parser.matchBoundary()) {
|
|
3737
|
+
parser.removeBoundary();
|
|
3738
|
+
return null;
|
|
3739
|
+
}
|
|
3740
|
+
return ["When", lhs, cond];
|
|
3741
|
+
}
|
|
3682
3742
|
function parseSequence(parser, terminator, lhs, prec, sep) {
|
|
3683
3743
|
if (terminator && terminator.minPrec >= prec) return null;
|
|
3684
3744
|
const result = lhs ? [lhs] : ["Nothing"];
|
|
@@ -4150,6 +4210,15 @@ var DEFINITIONS_CORE = [
|
|
|
4150
4210
|
}
|
|
4151
4211
|
},
|
|
4152
4212
|
{ name: "LatexTokens", serialize: serializeLatexTokens },
|
|
4213
|
+
// Component-access postfix: expr.member (C3)
|
|
4214
|
+
// The '.' trigger is consumed before the parse function is called.
|
|
4215
|
+
// Precedence 850 > 810 (At/indexing) so .x chains tightly.
|
|
4216
|
+
{
|
|
4217
|
+
kind: "postfix",
|
|
4218
|
+
precedence: 850,
|
|
4219
|
+
latexTrigger: ["."],
|
|
4220
|
+
parse: parseComponentAccess
|
|
4221
|
+
},
|
|
4153
4222
|
{
|
|
4154
4223
|
name: "At",
|
|
4155
4224
|
kind: "postfix",
|
|
@@ -4170,6 +4239,29 @@ var DEFINITIONS_CORE = [
|
|
|
4170
4239
|
latexTrigger: ["\\left", "\\lbrack"],
|
|
4171
4240
|
parse: parseAt("\\right", "\\rbrack")
|
|
4172
4241
|
},
|
|
4242
|
+
// When-restriction: `expr\left\{cond\right\}` → `When(expr, cond)` (D3)
|
|
4243
|
+
{
|
|
4244
|
+
name: "When",
|
|
4245
|
+
kind: "postfix",
|
|
4246
|
+
precedence: 800,
|
|
4247
|
+
latexTrigger: ["\\left", "\\{"],
|
|
4248
|
+
parse: (parser, lhs) => parseWhenRestriction(parser, lhs, ["\\right", "\\}"]),
|
|
4249
|
+
serialize: (serializer, expr) => {
|
|
4250
|
+
const e = operand(expr, 1);
|
|
4251
|
+
const cond = operand(expr, 2);
|
|
4252
|
+
if (!e || !cond) return "";
|
|
4253
|
+
const clauses = operator(cond) === "And" ? operands(cond) ?? [] : [cond];
|
|
4254
|
+
const inner = clauses.map((c) => `\\left\\{${serializer.serialize(c)}\\right\\}`).join("");
|
|
4255
|
+
return `${serializer.serialize(e)}${inner}`;
|
|
4256
|
+
}
|
|
4257
|
+
},
|
|
4258
|
+
// When-restriction: bare `expr\{cond\}` → `When(expr, cond)`
|
|
4259
|
+
{
|
|
4260
|
+
kind: "postfix",
|
|
4261
|
+
precedence: 800,
|
|
4262
|
+
latexTrigger: ["\\{"],
|
|
4263
|
+
parse: (parser, lhs) => parseWhenRestriction(parser, lhs, ["\\}"])
|
|
4264
|
+
},
|
|
4173
4265
|
{
|
|
4174
4266
|
kind: "postfix",
|
|
4175
4267
|
latexTrigger: ["_"],
|
|
@@ -4252,6 +4344,29 @@ var DEFINITIONS_CORE = [
|
|
|
4252
4344
|
return "";
|
|
4253
4345
|
}
|
|
4254
4346
|
},
|
|
4347
|
+
// Additional triggers for Range: `...`, `\ldots`, and `\dots` are
|
|
4348
|
+
// equivalent to `..` when used as infix operators (e.g. `[1...9]`).
|
|
4349
|
+
// No `name` field here — names must be unique per the dictionary rules;
|
|
4350
|
+
// the first Range entry owns the name. When there is no LHS the symbol
|
|
4351
|
+
// entries near the top of the file still fire (ContinuationPlaceholder).
|
|
4352
|
+
{
|
|
4353
|
+
latexTrigger: [".", ".", "."],
|
|
4354
|
+
kind: "infix",
|
|
4355
|
+
precedence: 800,
|
|
4356
|
+
parse: parseRange
|
|
4357
|
+
},
|
|
4358
|
+
{
|
|
4359
|
+
latexTrigger: ["\\ldots"],
|
|
4360
|
+
kind: "infix",
|
|
4361
|
+
precedence: 800,
|
|
4362
|
+
parse: parseRange
|
|
4363
|
+
},
|
|
4364
|
+
{
|
|
4365
|
+
latexTrigger: ["\\dots"],
|
|
4366
|
+
kind: "infix",
|
|
4367
|
+
precedence: 800,
|
|
4368
|
+
parse: parseRange
|
|
4369
|
+
},
|
|
4255
4370
|
{
|
|
4256
4371
|
latexTrigger: [";"],
|
|
4257
4372
|
kind: "infix",
|
|
@@ -4436,13 +4551,24 @@ var DEFINITIONS_CORE = [
|
|
|
4436
4551
|
const args = operands(expr);
|
|
4437
4552
|
if (!args || args.length < 2) return "";
|
|
4438
4553
|
const body = args[0];
|
|
4439
|
-
const
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4554
|
+
const elements = args.slice(1);
|
|
4555
|
+
const allElements = elements.every((e) => operator(e) === "Element");
|
|
4556
|
+
if (!allElements) {
|
|
4557
|
+
return joinLatex([
|
|
4558
|
+
"\\operatorname{Loop}(",
|
|
4559
|
+
serializer.serialize(body),
|
|
4560
|
+
", ",
|
|
4561
|
+
serializer.serialize(elements[0]),
|
|
4562
|
+
")"
|
|
4563
|
+
]);
|
|
4564
|
+
}
|
|
4565
|
+
if (elements.length === 1) {
|
|
4566
|
+
const elem = elements[0];
|
|
4567
|
+
const index = operand(elem, 1);
|
|
4568
|
+
const coll = operand(elem, 2);
|
|
4569
|
+
if (operator(coll) === "Range") {
|
|
4570
|
+
const lo = operand(coll, 1);
|
|
4571
|
+
const hi = operand(coll, 2);
|
|
4446
4572
|
return joinLatex([
|
|
4447
4573
|
"\\text{for }",
|
|
4448
4574
|
serializer.serialize(index),
|
|
@@ -4454,13 +4580,27 @@ var DEFINITIONS_CORE = [
|
|
|
4454
4580
|
serializer.serialize(body)
|
|
4455
4581
|
]);
|
|
4456
4582
|
}
|
|
4583
|
+
return joinLatex([
|
|
4584
|
+
serializer.serialize(body),
|
|
4585
|
+
" \\operatorname{for} ",
|
|
4586
|
+
serializer.serialize(index),
|
|
4587
|
+
" = ",
|
|
4588
|
+
serializer.serialize(coll)
|
|
4589
|
+
]);
|
|
4457
4590
|
}
|
|
4591
|
+
const bindings = elements.map((elem) => {
|
|
4592
|
+
const name = operand(elem, 1);
|
|
4593
|
+
const coll = operand(elem, 2);
|
|
4594
|
+
return joinLatex([
|
|
4595
|
+
serializer.serialize(name),
|
|
4596
|
+
" = ",
|
|
4597
|
+
serializer.serialize(coll)
|
|
4598
|
+
]);
|
|
4599
|
+
}).join(", ");
|
|
4458
4600
|
return joinLatex([
|
|
4459
|
-
"\\operatorname{Loop}(",
|
|
4460
4601
|
serializer.serialize(body),
|
|
4461
|
-
"
|
|
4462
|
-
|
|
4463
|
-
")"
|
|
4602
|
+
" \\operatorname{for} ",
|
|
4603
|
+
bindings
|
|
4464
4604
|
]);
|
|
4465
4605
|
}
|
|
4466
4606
|
},
|
|
@@ -4493,6 +4633,18 @@ var DEFINITIONS_CORE = [
|
|
|
4493
4633
|
precedence: 245,
|
|
4494
4634
|
parse: (parser, until) => parseForExpression(parser, until)
|
|
4495
4635
|
},
|
|
4636
|
+
// \operatorname{for} as postfix infix (list comprehension):
|
|
4637
|
+
// `body \operatorname{for} x = L_1, y = L_2`
|
|
4638
|
+
// Precedence 19 — just below comma (20) so the body is allowed to use
|
|
4639
|
+
// any operator (including comma sequencing) up to the keyword, and the
|
|
4640
|
+
// bindings can be comma-separated below us.
|
|
4641
|
+
{
|
|
4642
|
+
symbolTrigger: "for",
|
|
4643
|
+
kind: "infix",
|
|
4644
|
+
associativity: "none",
|
|
4645
|
+
precedence: 19,
|
|
4646
|
+
parse: (parser, lhs, until) => parseForComprehension(parser, lhs, until)
|
|
4647
|
+
},
|
|
4496
4648
|
// \operatorname{break}
|
|
4497
4649
|
{
|
|
4498
4650
|
symbolTrigger: "break",
|
|
@@ -4697,7 +4849,10 @@ var DEFINITIONS_CORE = [
|
|
|
4697
4849
|
if (!sym || !parser.getSymbolType(sym).matches("function")) return null;
|
|
4698
4850
|
parser.addBoundary([")"]);
|
|
4699
4851
|
const expr = parser.parseExpression(until);
|
|
4700
|
-
if (!parser.matchBoundary())
|
|
4852
|
+
if (!parser.matchBoundary()) {
|
|
4853
|
+
parser.removeBoundary();
|
|
4854
|
+
return null;
|
|
4855
|
+
}
|
|
4701
4856
|
if (!parser.match("<}>")) return null;
|
|
4702
4857
|
return ["Derivative", lhs, expr];
|
|
4703
4858
|
}
|
|
@@ -5138,7 +5293,12 @@ function parseBrackets(parser, body) {
|
|
|
5138
5293
|
if (isEmptySequence(body)) return ["List"];
|
|
5139
5294
|
const h = operator(body);
|
|
5140
5295
|
if (h === "Range" || h === "Linspace") return body;
|
|
5141
|
-
if (h === "Sequence")
|
|
5296
|
+
if (h === "Sequence") {
|
|
5297
|
+
const elems = operands(body);
|
|
5298
|
+
const inferred = tryInferRangeFromElements(elems, parser);
|
|
5299
|
+
if (inferred) return inferred;
|
|
5300
|
+
return ["List", ...elems];
|
|
5301
|
+
}
|
|
5142
5302
|
if (h === "Delimiter") {
|
|
5143
5303
|
const delim = stringValue(operand(body, 2)) ?? "...";
|
|
5144
5304
|
if (delim === ";" || delim === ".;.") {
|
|
@@ -5151,12 +5311,37 @@ function parseBrackets(parser, body) {
|
|
|
5151
5311
|
}
|
|
5152
5312
|
if (delim === "," || delim === ".,.") {
|
|
5153
5313
|
body = operand(body, 1);
|
|
5154
|
-
if (operator(body) === "Sequence")
|
|
5314
|
+
if (operator(body) === "Sequence") {
|
|
5315
|
+
const elems = operands(body);
|
|
5316
|
+
const inferred = tryInferRangeFromElements(elems, parser);
|
|
5317
|
+
if (inferred) return inferred;
|
|
5318
|
+
return ["List", ...elems];
|
|
5319
|
+
}
|
|
5155
5320
|
return ["List", body ?? "Nothing"];
|
|
5156
5321
|
}
|
|
5157
5322
|
}
|
|
5158
5323
|
return ["List", body];
|
|
5159
5324
|
}
|
|
5325
|
+
function tryInferRangeFromElements(elems, parser) {
|
|
5326
|
+
if (elems.length < 4) return null;
|
|
5327
|
+
const penultimate = elems[elems.length - 2];
|
|
5328
|
+
if (symbol(penultimate) !== "ContinuationPlaceholder") return null;
|
|
5329
|
+
const samples = elems.slice(0, -2);
|
|
5330
|
+
const endExpr = elems[elems.length - 1];
|
|
5331
|
+
if (samples.length < 2) return null;
|
|
5332
|
+
const sampleNums = samples.map(machineValue);
|
|
5333
|
+
if (sampleNums.some((n) => n === null)) return null;
|
|
5334
|
+
const nums = sampleNums;
|
|
5335
|
+
const step = nums[nums.length - 1] - nums[nums.length - 2];
|
|
5336
|
+
const tol = parser.options.tolerance;
|
|
5337
|
+
if (Math.abs(step) < tol)
|
|
5338
|
+
return parser.error("degenerate-range-step", parser.index);
|
|
5339
|
+
for (let i = 1; i < nums.length; i++) {
|
|
5340
|
+
if (Math.abs(nums[i] - nums[i - 1] - step) > tol)
|
|
5341
|
+
return parser.error("inconsistent-range-samples", parser.index);
|
|
5342
|
+
}
|
|
5343
|
+
return ["Range", nums[0], endExpr, step];
|
|
5344
|
+
}
|
|
5160
5345
|
function serializeList(serializer, expr) {
|
|
5161
5346
|
if (nops(expr) > 1 && operands(expr).every((x) => {
|
|
5162
5347
|
const op = operator(x);
|
|
@@ -5408,6 +5593,35 @@ function parseForExpression(parser, until) {
|
|
|
5408
5593
|
["Element", index, ["Range", lower, upper]]
|
|
5409
5594
|
];
|
|
5410
5595
|
}
|
|
5596
|
+
function parseForComprehension(parser, lhs, until) {
|
|
5597
|
+
const bindingTerminator = {
|
|
5598
|
+
minPrec: 21,
|
|
5599
|
+
// Above comma (20) and ; (19), so `x = L_1` is captured whole
|
|
5600
|
+
condition: (p) => {
|
|
5601
|
+
if (until?.condition?.(p)) return true;
|
|
5602
|
+
const saved = p.index;
|
|
5603
|
+
p.skipVisualSpace();
|
|
5604
|
+
const isComma = p.peek === ",";
|
|
5605
|
+
p.index = saved;
|
|
5606
|
+
return isComma;
|
|
5607
|
+
}
|
|
5608
|
+
};
|
|
5609
|
+
const elements = [];
|
|
5610
|
+
do {
|
|
5611
|
+
parser.skipVisualSpace();
|
|
5612
|
+
const binding = parser.parseExpression(bindingTerminator);
|
|
5613
|
+
if (binding === null) break;
|
|
5614
|
+
const op = operator(binding);
|
|
5615
|
+
if (op !== "Equal" && op !== "Assign") return null;
|
|
5616
|
+
const name = operand(binding, 1);
|
|
5617
|
+
const list = operand(binding, 2);
|
|
5618
|
+
if (!name || !list) return null;
|
|
5619
|
+
elements.push(["Element", name, list]);
|
|
5620
|
+
parser.skipVisualSpace();
|
|
5621
|
+
} while (parser.match(","));
|
|
5622
|
+
if (elements.length === 0) return null;
|
|
5623
|
+
return ["Loop", lhs, ...elements];
|
|
5624
|
+
}
|
|
5411
5625
|
function parseWhereExpression(parser, lhs, until) {
|
|
5412
5626
|
const bindingTerminator = {
|
|
5413
5627
|
minPrec: 21,
|
|
@@ -7326,6 +7540,8 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
7326
7540
|
precedence: DIVISION_PRECEDENCE,
|
|
7327
7541
|
parse: "Mod"
|
|
7328
7542
|
},
|
|
7543
|
+
// Function-style alias: `\operatorname{mod}(a, b)`
|
|
7544
|
+
{ latexTrigger: "\\operatorname{mod}", parse: "Mod" },
|
|
7329
7545
|
{
|
|
7330
7546
|
latexTrigger: "\\pmod",
|
|
7331
7547
|
kind: "prefix",
|
|
@@ -7566,6 +7782,13 @@ var DEFINITIONS_ARITHMETIC = [
|
|
|
7566
7782
|
const rhs = serializer.wrap(operand(expr, 2), ADDITION_PRECEDENCE + 3);
|
|
7567
7783
|
return joinLatex([lhs, "-", rhs]);
|
|
7568
7784
|
}
|
|
7785
|
+
},
|
|
7786
|
+
// Euclidean distance between two points (tuples of numbers).
|
|
7787
|
+
{
|
|
7788
|
+
name: "Distance",
|
|
7789
|
+
latexTrigger: ["\\operatorname{distance}"],
|
|
7790
|
+
kind: "function",
|
|
7791
|
+
serialize: (serializer, expr) => "\\operatorname{distance}" + serializer.wrapArguments(expr)
|
|
7569
7792
|
}
|
|
7570
7793
|
];
|
|
7571
7794
|
function getIndexAssignment(expr, upper) {
|
|
@@ -8990,7 +9213,9 @@ var DEFINITIONS_STATISTICS = [
|
|
|
8990
9213
|
if (!expr || !symbol(expr)) return null;
|
|
8991
9214
|
return ["Mean", expr];
|
|
8992
9215
|
}
|
|
8993
|
-
}
|
|
9216
|
+
},
|
|
9217
|
+
// Function-style alias: `\operatorname{var}(...)`
|
|
9218
|
+
{ latexTrigger: "\\operatorname{var}", parse: "Variance" }
|
|
8994
9219
|
];
|
|
8995
9220
|
|
|
8996
9221
|
// src/compute-engine/numerics/unit-data.ts
|
|
@@ -9998,7 +10223,7 @@ var DEFINITIONS_OTHERS = [
|
|
|
9998
10223
|
36: "\\qquad"
|
|
9999
10224
|
}[v] ?? "";
|
|
10000
10225
|
}
|
|
10001
|
-
}
|
|
10226
|
+
},
|
|
10002
10227
|
// if (
|
|
10003
10228
|
// [
|
|
10004
10229
|
// '\\!',
|
|
@@ -10022,6 +10247,121 @@ var DEFINITIONS_OTHERS = [
|
|
|
10022
10247
|
// name: '',
|
|
10023
10248
|
// trigger: '\\check',
|
|
10024
10249
|
// },
|
|
10250
|
+
// ---------------------------------------------------------------------------
|
|
10251
|
+
// Function-style aliases for collection / random operators that some
|
|
10252
|
+
// notations write in lowercase (e.g. `\operatorname{shuffle}(L)`).
|
|
10253
|
+
// The capitalized library entries already exist; these are pure parse
|
|
10254
|
+
// aliases so the lowercase names don't land in `unsupported-operator`.
|
|
10255
|
+
// ---------------------------------------------------------------------------
|
|
10256
|
+
{ latexTrigger: "\\operatorname{random}", parse: "Random" },
|
|
10257
|
+
{ latexTrigger: "\\operatorname{shuffle}", parse: "Shuffle" },
|
|
10258
|
+
{ latexTrigger: "\\operatorname{repeat}", parse: "Repeat" },
|
|
10259
|
+
{ latexTrigger: "\\operatorname{join}", parse: "Join" },
|
|
10260
|
+
// ---------------------------------------------------------------------------
|
|
10261
|
+
// Geometric primitive heads. Registered as known typed heads so consumers
|
|
10262
|
+
// can branch on the operator name; CE itself doesn't render them. The
|
|
10263
|
+
// library entries (with no evaluator) live in `library/core.ts`.
|
|
10264
|
+
// ---------------------------------------------------------------------------
|
|
10265
|
+
{
|
|
10266
|
+
name: "Triangle",
|
|
10267
|
+
latexTrigger: ["\\operatorname{triangle}"],
|
|
10268
|
+
kind: "function",
|
|
10269
|
+
serialize: (serializer, expr) => "\\operatorname{triangle}" + serializer.wrapArguments(expr)
|
|
10270
|
+
},
|
|
10271
|
+
// Desmos's geometric `vector(p1, p2)` — a directed segment between two
|
|
10272
|
+
// points. Routed to a dedicated head (not the existing column-vector
|
|
10273
|
+
// `Vector`, which has a narrower `(number+) -> vector` signature).
|
|
10274
|
+
{
|
|
10275
|
+
name: "GeometricVector",
|
|
10276
|
+
latexTrigger: ["\\operatorname{vector}"],
|
|
10277
|
+
kind: "function",
|
|
10278
|
+
serialize: (serializer, expr) => "\\operatorname{vector}" + serializer.wrapArguments(expr)
|
|
10279
|
+
},
|
|
10280
|
+
{
|
|
10281
|
+
name: "Sphere",
|
|
10282
|
+
latexTrigger: ["\\operatorname{sphere}"],
|
|
10283
|
+
kind: "function",
|
|
10284
|
+
serialize: (serializer, expr) => "\\operatorname{sphere}" + serializer.wrapArguments(expr)
|
|
10285
|
+
},
|
|
10286
|
+
{
|
|
10287
|
+
name: "Segment",
|
|
10288
|
+
latexTrigger: ["\\operatorname{segment}"],
|
|
10289
|
+
kind: "function",
|
|
10290
|
+
serialize: (serializer, expr) => "\\operatorname{segment}" + serializer.wrapArguments(expr)
|
|
10291
|
+
}
|
|
10292
|
+
];
|
|
10293
|
+
|
|
10294
|
+
// src/compute-engine/latex-syntax/dictionary/definitions-colors.ts
|
|
10295
|
+
var DEFINITIONS_COLORS = [
|
|
10296
|
+
// Color constructors (one per colorspace, preserves space on evaluation)
|
|
10297
|
+
{
|
|
10298
|
+
name: "Rgb",
|
|
10299
|
+
latexTrigger: ["\\operatorname{rgb}"],
|
|
10300
|
+
kind: "function",
|
|
10301
|
+
serialize: (serializer, expr) => "\\operatorname{rgb}" + serializer.wrapArguments(expr)
|
|
10302
|
+
},
|
|
10303
|
+
{
|
|
10304
|
+
name: "Hsv",
|
|
10305
|
+
latexTrigger: ["\\operatorname{hsv}"],
|
|
10306
|
+
kind: "function",
|
|
10307
|
+
serialize: (serializer, expr) => "\\operatorname{hsv}" + serializer.wrapArguments(expr)
|
|
10308
|
+
},
|
|
10309
|
+
{
|
|
10310
|
+
name: "Hsl",
|
|
10311
|
+
latexTrigger: ["\\operatorname{hsl}"],
|
|
10312
|
+
kind: "function",
|
|
10313
|
+
serialize: (serializer, expr) => "\\operatorname{hsl}" + serializer.wrapArguments(expr)
|
|
10314
|
+
},
|
|
10315
|
+
{
|
|
10316
|
+
name: "Oklab",
|
|
10317
|
+
latexTrigger: ["\\operatorname{oklab}"],
|
|
10318
|
+
kind: "function",
|
|
10319
|
+
serialize: (serializer, expr) => "\\operatorname{oklab}" + serializer.wrapArguments(expr)
|
|
10320
|
+
},
|
|
10321
|
+
{
|
|
10322
|
+
name: "Oklch",
|
|
10323
|
+
latexTrigger: ["\\operatorname{oklch}"],
|
|
10324
|
+
kind: "function",
|
|
10325
|
+
serialize: (serializer, expr) => "\\operatorname{oklch}" + serializer.wrapArguments(expr)
|
|
10326
|
+
},
|
|
10327
|
+
// Conversion functions (color → color in the named space)
|
|
10328
|
+
{
|
|
10329
|
+
name: "AsRgb",
|
|
10330
|
+
latexTrigger: ["\\operatorname{asRgb}"],
|
|
10331
|
+
kind: "function",
|
|
10332
|
+
serialize: (serializer, expr) => "\\operatorname{asRgb}" + serializer.wrapArguments(expr)
|
|
10333
|
+
},
|
|
10334
|
+
{
|
|
10335
|
+
name: "AsHsv",
|
|
10336
|
+
latexTrigger: ["\\operatorname{asHsv}"],
|
|
10337
|
+
kind: "function",
|
|
10338
|
+
serialize: (serializer, expr) => "\\operatorname{asHsv}" + serializer.wrapArguments(expr)
|
|
10339
|
+
},
|
|
10340
|
+
{
|
|
10341
|
+
name: "AsHsl",
|
|
10342
|
+
latexTrigger: ["\\operatorname{asHsl}"],
|
|
10343
|
+
kind: "function",
|
|
10344
|
+
serialize: (serializer, expr) => "\\operatorname{asHsl}" + serializer.wrapArguments(expr)
|
|
10345
|
+
},
|
|
10346
|
+
{
|
|
10347
|
+
name: "AsOklab",
|
|
10348
|
+
latexTrigger: ["\\operatorname{asOklab}"],
|
|
10349
|
+
kind: "function",
|
|
10350
|
+
serialize: (serializer, expr) => "\\operatorname{asOklab}" + serializer.wrapArguments(expr)
|
|
10351
|
+
},
|
|
10352
|
+
{
|
|
10353
|
+
name: "AsOklch",
|
|
10354
|
+
latexTrigger: ["\\operatorname{asOklch}"],
|
|
10355
|
+
kind: "function",
|
|
10356
|
+
serialize: (serializer, expr) => "\\operatorname{asOklch}" + serializer.wrapArguments(expr)
|
|
10357
|
+
},
|
|
10358
|
+
// Perceptual difference (returns a scalar in [0, ~1])
|
|
10359
|
+
{
|
|
10360
|
+
name: "ColorDelta",
|
|
10361
|
+
latexTrigger: ["\\operatorname{colorDelta}"],
|
|
10362
|
+
kind: "function",
|
|
10363
|
+
serialize: (serializer, expr) => "\\operatorname{colorDelta}" + serializer.wrapArguments(expr)
|
|
10364
|
+
}
|
|
10025
10365
|
];
|
|
10026
10366
|
|
|
10027
10367
|
// src/compute-engine/latex-syntax/dictionary/default-dictionary.ts
|
|
@@ -10052,7 +10392,8 @@ var LATEX_DICTIONARY = [
|
|
|
10052
10392
|
...DEFINITIONS_STATISTICS,
|
|
10053
10393
|
...DEFINITIONS_UNITS,
|
|
10054
10394
|
...DEFINITIONS_OTHERS,
|
|
10055
|
-
...DEFINITIONS_PHYSICS
|
|
10395
|
+
...DEFINITIONS_PHYSICS,
|
|
10396
|
+
...DEFINITIONS_COLORS
|
|
10056
10397
|
];
|
|
10057
10398
|
|
|
10058
10399
|
// src/math-json/symbols.ts
|
|
@@ -10217,6 +10558,17 @@ function addEntry(result, entry, onError) {
|
|
|
10217
10558
|
} else if (Array.isArray(openTrigger) && openTrigger.length > 0) {
|
|
10218
10559
|
openTokens.push(openTrigger[0]);
|
|
10219
10560
|
}
|
|
10561
|
+
const closeTrigger = indexedEntry.closeTrigger;
|
|
10562
|
+
const closeTokens = /* @__PURE__ */ new Set();
|
|
10563
|
+
if (typeof closeTrigger === "string") {
|
|
10564
|
+
const variants = DELIMITER_SHORTHAND[closeTrigger];
|
|
10565
|
+
if (variants) for (const v of variants) closeTokens.add(v);
|
|
10566
|
+
else closeTokens.add(closeTrigger);
|
|
10567
|
+
if (closeTrigger === "||") closeTokens.add("|");
|
|
10568
|
+
} else if (Array.isArray(closeTrigger) && closeTrigger.length > 0) {
|
|
10569
|
+
closeTokens.add(closeTrigger[0]);
|
|
10570
|
+
}
|
|
10571
|
+
indexedEntry.closeTokens = closeTokens;
|
|
10220
10572
|
for (const token of openTokens) {
|
|
10221
10573
|
const existing = result.matchfixByOpen.get(token);
|
|
10222
10574
|
if (existing) {
|
|
@@ -10408,11 +10760,7 @@ function makeSerializeHandler(entry, latexTrigger, idTrigger) {
|
|
|
10408
10760
|
if (style === "scaled")
|
|
10409
10761
|
return joinLatex([`\\left${openDelim}`, inner, `\\right${closeDelim}`]);
|
|
10410
10762
|
if (style === "big")
|
|
10411
|
-
return joinLatex([
|
|
10412
|
-
`\\Bigl${openDelim}`,
|
|
10413
|
-
inner,
|
|
10414
|
-
`\\Bigr${closeDelim}`
|
|
10415
|
-
]);
|
|
10763
|
+
return joinLatex([`\\Bigl${openDelim}`, inner, `\\Bigr${closeDelim}`]);
|
|
10416
10764
|
return joinLatex([openDelim, inner, closeDelim]);
|
|
10417
10765
|
};
|
|
10418
10766
|
}
|
|
@@ -13141,7 +13489,7 @@ var _Parser = class __Parser {
|
|
|
13141
13489
|
}
|
|
13142
13490
|
if (this.match("\\hskip") || this.match("\\kern")) {
|
|
13143
13491
|
this.skipSpace();
|
|
13144
|
-
this.match("-")
|
|
13492
|
+
if (!this.match("-")) this.match("+");
|
|
13145
13493
|
while (/^[\d.]$/.test(this.peek)) this.nextToken();
|
|
13146
13494
|
for (const unit of [
|
|
13147
13495
|
"pt",
|
|
@@ -13655,6 +14003,19 @@ var _Parser = class __Parser {
|
|
|
13655
14003
|
}
|
|
13656
14004
|
for (const def of defs) {
|
|
13657
14005
|
this.index = start;
|
|
14006
|
+
if (def.closeTokens.size > 0) {
|
|
14007
|
+
let found = false;
|
|
14008
|
+
const tokens = this._tokens;
|
|
14009
|
+
for (let i = start; i < tokens.length; i++) {
|
|
14010
|
+
if (def.closeTokens.has(tokens[i])) {
|
|
14011
|
+
found = true;
|
|
14012
|
+
break;
|
|
14013
|
+
}
|
|
14014
|
+
}
|
|
14015
|
+
if (!found) continue;
|
|
14016
|
+
}
|
|
14017
|
+
if (typeof def.openTrigger === "string" && def.openTrigger === "." && !OPEN_DELIMITER_PREFIX[currentToken])
|
|
14018
|
+
continue;
|
|
13658
14019
|
const matched = this.matchDelimiter(def.openTrigger, def.closeTrigger);
|
|
13659
14020
|
if (!matched) continue;
|
|
13660
14021
|
const bodyStart = this.index;
|
|
@@ -14317,6 +14678,19 @@ var _Parser = class __Parser {
|
|
|
14317
14678
|
} while (postfix !== null);
|
|
14318
14679
|
}
|
|
14319
14680
|
if (result !== null) result = this.parseSupsub(result);
|
|
14681
|
+
if (result !== null) {
|
|
14682
|
+
let postfix = null;
|
|
14683
|
+
let index = this.index;
|
|
14684
|
+
do {
|
|
14685
|
+
postfix = this.parsePostfixOperator(result, until);
|
|
14686
|
+
result = postfix ?? result;
|
|
14687
|
+
if (this.index === index && postfix !== null) {
|
|
14688
|
+
console.assert(this.index !== index, "No token consumed");
|
|
14689
|
+
break;
|
|
14690
|
+
}
|
|
14691
|
+
index = this.index;
|
|
14692
|
+
} while (postfix !== null);
|
|
14693
|
+
}
|
|
14320
14694
|
if (result === null) {
|
|
14321
14695
|
result = this.options.parseUnexpectedToken?.(null, this) ?? null;
|
|
14322
14696
|
if (result === null && this.peek.startsWith("\\")) {
|
|
@@ -14825,6 +15199,28 @@ function toDecimalNumber(wholePart, fractionalPart, exp) {
|
|
|
14825
15199
|
}
|
|
14826
15200
|
|
|
14827
15201
|
// src/compute-engine/latex-syntax/serializer.ts
|
|
15202
|
+
var DOT_NOTATION_MAP = {
|
|
15203
|
+
First: ".x",
|
|
15204
|
+
Second: ".y",
|
|
15205
|
+
Third: ".z",
|
|
15206
|
+
Real: ".\\operatorname{real}",
|
|
15207
|
+
Imaginary: ".\\operatorname{imag}",
|
|
15208
|
+
Length: ".\\operatorname{count}",
|
|
15209
|
+
Sum: ".\\operatorname{total}",
|
|
15210
|
+
Max: ".\\max",
|
|
15211
|
+
Min: ".\\min"
|
|
15212
|
+
};
|
|
15213
|
+
function trySerializeDotNotation(serializer, expr) {
|
|
15214
|
+
if (!serializer.options.dotNotation) return null;
|
|
15215
|
+
const ops = operands(expr);
|
|
15216
|
+
if (!ops || ops.length !== 1) return null;
|
|
15217
|
+
const head = operator(expr);
|
|
15218
|
+
if (!head) return null;
|
|
15219
|
+
const suffix = DOT_NOTATION_MAP[head];
|
|
15220
|
+
if (suffix === void 0) return null;
|
|
15221
|
+
const lhs = serializer.wrap(ops[0], 810);
|
|
15222
|
+
return `${lhs}${suffix}`;
|
|
15223
|
+
}
|
|
14828
15224
|
var ACCENT_MODIFIERS = {
|
|
14829
15225
|
deg: (s) => `${s}\\degree`,
|
|
14830
15226
|
prime: (s) => `${s}^{\\prime}`,
|
|
@@ -14868,6 +15264,7 @@ var Serializer5 = class {
|
|
|
14868
15264
|
constructor(dictionary, options) {
|
|
14869
15265
|
this.dictionary = dictionary;
|
|
14870
15266
|
this.options = {
|
|
15267
|
+
dotNotation: false,
|
|
14871
15268
|
dmsFormat: false,
|
|
14872
15269
|
angleNormalization: "none",
|
|
14873
15270
|
...options
|
|
@@ -14966,6 +15363,8 @@ var Serializer5 = class {
|
|
|
14966
15363
|
return def?.serialize?.(this, expr) ?? serializeSymbol(symbol(expr)) ?? "";
|
|
14967
15364
|
}
|
|
14968
15365
|
serializeFunction(expr, def) {
|
|
15366
|
+
const dotResult = trySerializeDotNotation(this, expr);
|
|
15367
|
+
if (dotResult !== null) return dotResult;
|
|
14969
15368
|
if (def?.serialize) return def.serialize(this, expr);
|
|
14970
15369
|
const h = operator(expr);
|
|
14971
15370
|
return serializeSymbol(h, "auto") + this.wrapArguments(expr);
|
|
@@ -15208,6 +15607,8 @@ function defaultParseOptions(opts) {
|
|
|
15208
15607
|
preserveLatex: opts.preserveLatex ?? false,
|
|
15209
15608
|
quantifierScope: opts.quantifierScope ?? "tight",
|
|
15210
15609
|
timeDerivativeVariable: opts.timeDerivativeVariable ?? "t",
|
|
15610
|
+
// Standalone mode has no engine; use the same default as ComputeEngine
|
|
15611
|
+
tolerance: 1e-7,
|
|
15211
15612
|
// Callbacks -- standalone mode has no engine, so these are stubs
|
|
15212
15613
|
getSymbolType: (_id) => BoxedType.unknown,
|
|
15213
15614
|
hasSubscriptEvaluate: (_id) => false,
|
|
@@ -15240,6 +15641,7 @@ function defaultSerializeOptions(opts) {
|
|
|
15240
15641
|
invisiblePlus: "",
|
|
15241
15642
|
multiply: "\\times",
|
|
15242
15643
|
missingSymbol: "\\blacksquare",
|
|
15644
|
+
dotNotation: false,
|
|
15243
15645
|
dmsFormat: false,
|
|
15244
15646
|
angleNormalization: "none",
|
|
15245
15647
|
// Style callbacks -- use same defaults as the engine
|
|
@@ -15308,7 +15710,7 @@ function serialize(expr) {
|
|
|
15308
15710
|
}
|
|
15309
15711
|
|
|
15310
15712
|
// src/latex-syntax.ts
|
|
15311
|
-
var version = "0.
|
|
15713
|
+
var version = "0.57.0";
|
|
15312
15714
|
export {
|
|
15313
15715
|
DEFINITIONS_ALGEBRA as ALGEBRA_DICTIONARY,
|
|
15314
15716
|
DEFINITIONS_ARITHMETIC as ARITHMETIC_DICTIONARY,
|