@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** LatexSyntax 0.
|
|
1
|
+
/** LatexSyntax 0.57.0 */
|
|
2
2
|
(function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LatexSyntax = {}));})(this, (function (exports) { 'use strict';
|
|
3
3
|
var LatexSyntax = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1190,6 +1190,7 @@ var LatexSyntax = (() => {
|
|
|
1190
1190
|
];
|
|
1191
1191
|
var VALUE_TYPES = [
|
|
1192
1192
|
"value",
|
|
1193
|
+
"color",
|
|
1193
1194
|
...COLLECTION_TYPES,
|
|
1194
1195
|
...SCALAR_TYPES
|
|
1195
1196
|
];
|
|
@@ -2841,6 +2842,7 @@ var LatexSyntax = (() => {
|
|
|
2841
2842
|
symbol: [],
|
|
2842
2843
|
boolean: [],
|
|
2843
2844
|
string: [],
|
|
2845
|
+
color: [],
|
|
2844
2846
|
expression: EXPRESSION_TYPES
|
|
2845
2847
|
};
|
|
2846
2848
|
function isPrimitiveSubtype(lhs, rhs) {
|
|
@@ -3723,6 +3725,64 @@ var LatexSyntax = (() => {
|
|
|
3723
3725
|
}
|
|
3724
3726
|
|
|
3725
3727
|
// src/compute-engine/latex-syntax/dictionary/definitions-core.ts
|
|
3728
|
+
var COMPONENT_ACCESS_HEADS = {
|
|
3729
|
+
x: "First",
|
|
3730
|
+
y: "Second",
|
|
3731
|
+
z: "Third",
|
|
3732
|
+
real: "Real",
|
|
3733
|
+
re: "Real",
|
|
3734
|
+
imag: "Imaginary",
|
|
3735
|
+
im: "Imaginary",
|
|
3736
|
+
count: "Length",
|
|
3737
|
+
total: "Sum",
|
|
3738
|
+
max: "Max",
|
|
3739
|
+
min: "Min"
|
|
3740
|
+
};
|
|
3741
|
+
function memberHead(name) {
|
|
3742
|
+
return COMPONENT_ACCESS_HEADS[name] ?? null;
|
|
3743
|
+
}
|
|
3744
|
+
function parseComponentAccess(parser, lhs) {
|
|
3745
|
+
parser.skipVisualSpace();
|
|
3746
|
+
if (parser.match("\\operatorname")) {
|
|
3747
|
+
const name = parser.parseStringGroup();
|
|
3748
|
+
if (name === null) return null;
|
|
3749
|
+
const head = memberHead(name.trim());
|
|
3750
|
+
if (head === null) return null;
|
|
3751
|
+
return [head, lhs];
|
|
3752
|
+
}
|
|
3753
|
+
const tok = parser.peek;
|
|
3754
|
+
if (typeof tok === "string" && tok.startsWith("\\")) {
|
|
3755
|
+
const bare = tok.slice(1);
|
|
3756
|
+
const head = memberHead(bare);
|
|
3757
|
+
if (head !== null) {
|
|
3758
|
+
parser.nextToken();
|
|
3759
|
+
return [head, lhs];
|
|
3760
|
+
}
|
|
3761
|
+
return null;
|
|
3762
|
+
}
|
|
3763
|
+
if (typeof tok === "string" && /^[a-zA-Z]$/.test(tok)) {
|
|
3764
|
+
const head = memberHead(tok);
|
|
3765
|
+
if (head === null) return null;
|
|
3766
|
+
parser.nextToken();
|
|
3767
|
+
return [head, lhs];
|
|
3768
|
+
}
|
|
3769
|
+
return null;
|
|
3770
|
+
}
|
|
3771
|
+
function parseWhenRestriction(parser, lhs, close) {
|
|
3772
|
+
parser.addBoundary(close);
|
|
3773
|
+
parser.skipVisualSpace();
|
|
3774
|
+
const cond = parser.parseExpression({ minPrec: 0 });
|
|
3775
|
+
if (cond === null) {
|
|
3776
|
+
parser.removeBoundary();
|
|
3777
|
+
return null;
|
|
3778
|
+
}
|
|
3779
|
+
parser.skipVisualSpace();
|
|
3780
|
+
if (!parser.matchBoundary()) {
|
|
3781
|
+
parser.removeBoundary();
|
|
3782
|
+
return null;
|
|
3783
|
+
}
|
|
3784
|
+
return ["When", lhs, cond];
|
|
3785
|
+
}
|
|
3726
3786
|
function parseSequence(parser, terminator, lhs, prec, sep) {
|
|
3727
3787
|
if (terminator && terminator.minPrec >= prec) return null;
|
|
3728
3788
|
const result = lhs ? [lhs] : ["Nothing"];
|
|
@@ -4194,6 +4254,15 @@ var LatexSyntax = (() => {
|
|
|
4194
4254
|
}
|
|
4195
4255
|
},
|
|
4196
4256
|
{ name: "LatexTokens", serialize: serializeLatexTokens },
|
|
4257
|
+
// Component-access postfix: expr.member (C3)
|
|
4258
|
+
// The '.' trigger is consumed before the parse function is called.
|
|
4259
|
+
// Precedence 850 > 810 (At/indexing) so .x chains tightly.
|
|
4260
|
+
{
|
|
4261
|
+
kind: "postfix",
|
|
4262
|
+
precedence: 850,
|
|
4263
|
+
latexTrigger: ["."],
|
|
4264
|
+
parse: parseComponentAccess
|
|
4265
|
+
},
|
|
4197
4266
|
{
|
|
4198
4267
|
name: "At",
|
|
4199
4268
|
kind: "postfix",
|
|
@@ -4214,6 +4283,29 @@ var LatexSyntax = (() => {
|
|
|
4214
4283
|
latexTrigger: ["\\left", "\\lbrack"],
|
|
4215
4284
|
parse: parseAt("\\right", "\\rbrack")
|
|
4216
4285
|
},
|
|
4286
|
+
// When-restriction: `expr\left\{cond\right\}` → `When(expr, cond)` (D3)
|
|
4287
|
+
{
|
|
4288
|
+
name: "When",
|
|
4289
|
+
kind: "postfix",
|
|
4290
|
+
precedence: 800,
|
|
4291
|
+
latexTrigger: ["\\left", "\\{"],
|
|
4292
|
+
parse: (parser, lhs) => parseWhenRestriction(parser, lhs, ["\\right", "\\}"]),
|
|
4293
|
+
serialize: (serializer, expr) => {
|
|
4294
|
+
const e = operand(expr, 1);
|
|
4295
|
+
const cond = operand(expr, 2);
|
|
4296
|
+
if (!e || !cond) return "";
|
|
4297
|
+
const clauses = operator(cond) === "And" ? operands(cond) ?? [] : [cond];
|
|
4298
|
+
const inner = clauses.map((c) => `\\left\\{${serializer.serialize(c)}\\right\\}`).join("");
|
|
4299
|
+
return `${serializer.serialize(e)}${inner}`;
|
|
4300
|
+
}
|
|
4301
|
+
},
|
|
4302
|
+
// When-restriction: bare `expr\{cond\}` → `When(expr, cond)`
|
|
4303
|
+
{
|
|
4304
|
+
kind: "postfix",
|
|
4305
|
+
precedence: 800,
|
|
4306
|
+
latexTrigger: ["\\{"],
|
|
4307
|
+
parse: (parser, lhs) => parseWhenRestriction(parser, lhs, ["\\}"])
|
|
4308
|
+
},
|
|
4217
4309
|
{
|
|
4218
4310
|
kind: "postfix",
|
|
4219
4311
|
latexTrigger: ["_"],
|
|
@@ -4296,6 +4388,29 @@ var LatexSyntax = (() => {
|
|
|
4296
4388
|
return "";
|
|
4297
4389
|
}
|
|
4298
4390
|
},
|
|
4391
|
+
// Additional triggers for Range: `...`, `\ldots`, and `\dots` are
|
|
4392
|
+
// equivalent to `..` when used as infix operators (e.g. `[1...9]`).
|
|
4393
|
+
// No `name` field here — names must be unique per the dictionary rules;
|
|
4394
|
+
// the first Range entry owns the name. When there is no LHS the symbol
|
|
4395
|
+
// entries near the top of the file still fire (ContinuationPlaceholder).
|
|
4396
|
+
{
|
|
4397
|
+
latexTrigger: [".", ".", "."],
|
|
4398
|
+
kind: "infix",
|
|
4399
|
+
precedence: 800,
|
|
4400
|
+
parse: parseRange
|
|
4401
|
+
},
|
|
4402
|
+
{
|
|
4403
|
+
latexTrigger: ["\\ldots"],
|
|
4404
|
+
kind: "infix",
|
|
4405
|
+
precedence: 800,
|
|
4406
|
+
parse: parseRange
|
|
4407
|
+
},
|
|
4408
|
+
{
|
|
4409
|
+
latexTrigger: ["\\dots"],
|
|
4410
|
+
kind: "infix",
|
|
4411
|
+
precedence: 800,
|
|
4412
|
+
parse: parseRange
|
|
4413
|
+
},
|
|
4299
4414
|
{
|
|
4300
4415
|
latexTrigger: [";"],
|
|
4301
4416
|
kind: "infix",
|
|
@@ -4480,13 +4595,24 @@ var LatexSyntax = (() => {
|
|
|
4480
4595
|
const args = operands(expr);
|
|
4481
4596
|
if (!args || args.length < 2) return "";
|
|
4482
4597
|
const body = args[0];
|
|
4483
|
-
const
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4598
|
+
const elements = args.slice(1);
|
|
4599
|
+
const allElements = elements.every((e) => operator(e) === "Element");
|
|
4600
|
+
if (!allElements) {
|
|
4601
|
+
return joinLatex([
|
|
4602
|
+
"\\operatorname{Loop}(",
|
|
4603
|
+
serializer.serialize(body),
|
|
4604
|
+
", ",
|
|
4605
|
+
serializer.serialize(elements[0]),
|
|
4606
|
+
")"
|
|
4607
|
+
]);
|
|
4608
|
+
}
|
|
4609
|
+
if (elements.length === 1) {
|
|
4610
|
+
const elem = elements[0];
|
|
4611
|
+
const index = operand(elem, 1);
|
|
4612
|
+
const coll = operand(elem, 2);
|
|
4613
|
+
if (operator(coll) === "Range") {
|
|
4614
|
+
const lo = operand(coll, 1);
|
|
4615
|
+
const hi = operand(coll, 2);
|
|
4490
4616
|
return joinLatex([
|
|
4491
4617
|
"\\text{for }",
|
|
4492
4618
|
serializer.serialize(index),
|
|
@@ -4498,13 +4624,27 @@ var LatexSyntax = (() => {
|
|
|
4498
4624
|
serializer.serialize(body)
|
|
4499
4625
|
]);
|
|
4500
4626
|
}
|
|
4627
|
+
return joinLatex([
|
|
4628
|
+
serializer.serialize(body),
|
|
4629
|
+
" \\operatorname{for} ",
|
|
4630
|
+
serializer.serialize(index),
|
|
4631
|
+
" = ",
|
|
4632
|
+
serializer.serialize(coll)
|
|
4633
|
+
]);
|
|
4501
4634
|
}
|
|
4635
|
+
const bindings = elements.map((elem) => {
|
|
4636
|
+
const name = operand(elem, 1);
|
|
4637
|
+
const coll = operand(elem, 2);
|
|
4638
|
+
return joinLatex([
|
|
4639
|
+
serializer.serialize(name),
|
|
4640
|
+
" = ",
|
|
4641
|
+
serializer.serialize(coll)
|
|
4642
|
+
]);
|
|
4643
|
+
}).join(", ");
|
|
4502
4644
|
return joinLatex([
|
|
4503
|
-
"\\operatorname{Loop}(",
|
|
4504
4645
|
serializer.serialize(body),
|
|
4505
|
-
"
|
|
4506
|
-
|
|
4507
|
-
")"
|
|
4646
|
+
" \\operatorname{for} ",
|
|
4647
|
+
bindings
|
|
4508
4648
|
]);
|
|
4509
4649
|
}
|
|
4510
4650
|
},
|
|
@@ -4537,6 +4677,18 @@ var LatexSyntax = (() => {
|
|
|
4537
4677
|
precedence: 245,
|
|
4538
4678
|
parse: (parser, until) => parseForExpression(parser, until)
|
|
4539
4679
|
},
|
|
4680
|
+
// \operatorname{for} as postfix infix (list comprehension):
|
|
4681
|
+
// `body \operatorname{for} x = L_1, y = L_2`
|
|
4682
|
+
// Precedence 19 — just below comma (20) so the body is allowed to use
|
|
4683
|
+
// any operator (including comma sequencing) up to the keyword, and the
|
|
4684
|
+
// bindings can be comma-separated below us.
|
|
4685
|
+
{
|
|
4686
|
+
symbolTrigger: "for",
|
|
4687
|
+
kind: "infix",
|
|
4688
|
+
associativity: "none",
|
|
4689
|
+
precedence: 19,
|
|
4690
|
+
parse: (parser, lhs, until) => parseForComprehension(parser, lhs, until)
|
|
4691
|
+
},
|
|
4540
4692
|
// \operatorname{break}
|
|
4541
4693
|
{
|
|
4542
4694
|
symbolTrigger: "break",
|
|
@@ -4741,7 +4893,10 @@ var LatexSyntax = (() => {
|
|
|
4741
4893
|
if (!sym || !parser.getSymbolType(sym).matches("function")) return null;
|
|
4742
4894
|
parser.addBoundary([")"]);
|
|
4743
4895
|
const expr = parser.parseExpression(until);
|
|
4744
|
-
if (!parser.matchBoundary())
|
|
4896
|
+
if (!parser.matchBoundary()) {
|
|
4897
|
+
parser.removeBoundary();
|
|
4898
|
+
return null;
|
|
4899
|
+
}
|
|
4745
4900
|
if (!parser.match("<}>")) return null;
|
|
4746
4901
|
return ["Derivative", lhs, expr];
|
|
4747
4902
|
}
|
|
@@ -5182,7 +5337,12 @@ var LatexSyntax = (() => {
|
|
|
5182
5337
|
if (isEmptySequence(body)) return ["List"];
|
|
5183
5338
|
const h = operator(body);
|
|
5184
5339
|
if (h === "Range" || h === "Linspace") return body;
|
|
5185
|
-
if (h === "Sequence")
|
|
5340
|
+
if (h === "Sequence") {
|
|
5341
|
+
const elems = operands(body);
|
|
5342
|
+
const inferred = tryInferRangeFromElements(elems, parser);
|
|
5343
|
+
if (inferred) return inferred;
|
|
5344
|
+
return ["List", ...elems];
|
|
5345
|
+
}
|
|
5186
5346
|
if (h === "Delimiter") {
|
|
5187
5347
|
const delim = stringValue(operand(body, 2)) ?? "...";
|
|
5188
5348
|
if (delim === ";" || delim === ".;.") {
|
|
@@ -5195,12 +5355,37 @@ var LatexSyntax = (() => {
|
|
|
5195
5355
|
}
|
|
5196
5356
|
if (delim === "," || delim === ".,.") {
|
|
5197
5357
|
body = operand(body, 1);
|
|
5198
|
-
if (operator(body) === "Sequence")
|
|
5358
|
+
if (operator(body) === "Sequence") {
|
|
5359
|
+
const elems = operands(body);
|
|
5360
|
+
const inferred = tryInferRangeFromElements(elems, parser);
|
|
5361
|
+
if (inferred) return inferred;
|
|
5362
|
+
return ["List", ...elems];
|
|
5363
|
+
}
|
|
5199
5364
|
return ["List", body ?? "Nothing"];
|
|
5200
5365
|
}
|
|
5201
5366
|
}
|
|
5202
5367
|
return ["List", body];
|
|
5203
5368
|
}
|
|
5369
|
+
function tryInferRangeFromElements(elems, parser) {
|
|
5370
|
+
if (elems.length < 4) return null;
|
|
5371
|
+
const penultimate = elems[elems.length - 2];
|
|
5372
|
+
if (symbol(penultimate) !== "ContinuationPlaceholder") return null;
|
|
5373
|
+
const samples = elems.slice(0, -2);
|
|
5374
|
+
const endExpr = elems[elems.length - 1];
|
|
5375
|
+
if (samples.length < 2) return null;
|
|
5376
|
+
const sampleNums = samples.map(machineValue);
|
|
5377
|
+
if (sampleNums.some((n) => n === null)) return null;
|
|
5378
|
+
const nums = sampleNums;
|
|
5379
|
+
const step = nums[nums.length - 1] - nums[nums.length - 2];
|
|
5380
|
+
const tol = parser.options.tolerance;
|
|
5381
|
+
if (Math.abs(step) < tol)
|
|
5382
|
+
return parser.error("degenerate-range-step", parser.index);
|
|
5383
|
+
for (let i = 1; i < nums.length; i++) {
|
|
5384
|
+
if (Math.abs(nums[i] - nums[i - 1] - step) > tol)
|
|
5385
|
+
return parser.error("inconsistent-range-samples", parser.index);
|
|
5386
|
+
}
|
|
5387
|
+
return ["Range", nums[0], endExpr, step];
|
|
5388
|
+
}
|
|
5204
5389
|
function serializeList(serializer, expr) {
|
|
5205
5390
|
if (nops(expr) > 1 && operands(expr).every((x) => {
|
|
5206
5391
|
const op = operator(x);
|
|
@@ -5452,6 +5637,35 @@ var LatexSyntax = (() => {
|
|
|
5452
5637
|
["Element", index, ["Range", lower, upper]]
|
|
5453
5638
|
];
|
|
5454
5639
|
}
|
|
5640
|
+
function parseForComprehension(parser, lhs, until) {
|
|
5641
|
+
const bindingTerminator = {
|
|
5642
|
+
minPrec: 21,
|
|
5643
|
+
// Above comma (20) and ; (19), so `x = L_1` is captured whole
|
|
5644
|
+
condition: (p) => {
|
|
5645
|
+
if (until?.condition?.(p)) return true;
|
|
5646
|
+
const saved = p.index;
|
|
5647
|
+
p.skipVisualSpace();
|
|
5648
|
+
const isComma = p.peek === ",";
|
|
5649
|
+
p.index = saved;
|
|
5650
|
+
return isComma;
|
|
5651
|
+
}
|
|
5652
|
+
};
|
|
5653
|
+
const elements = [];
|
|
5654
|
+
do {
|
|
5655
|
+
parser.skipVisualSpace();
|
|
5656
|
+
const binding = parser.parseExpression(bindingTerminator);
|
|
5657
|
+
if (binding === null) break;
|
|
5658
|
+
const op = operator(binding);
|
|
5659
|
+
if (op !== "Equal" && op !== "Assign") return null;
|
|
5660
|
+
const name = operand(binding, 1);
|
|
5661
|
+
const list = operand(binding, 2);
|
|
5662
|
+
if (!name || !list) return null;
|
|
5663
|
+
elements.push(["Element", name, list]);
|
|
5664
|
+
parser.skipVisualSpace();
|
|
5665
|
+
} while (parser.match(","));
|
|
5666
|
+
if (elements.length === 0) return null;
|
|
5667
|
+
return ["Loop", lhs, ...elements];
|
|
5668
|
+
}
|
|
5455
5669
|
function parseWhereExpression(parser, lhs, until) {
|
|
5456
5670
|
const bindingTerminator = {
|
|
5457
5671
|
minPrec: 21,
|
|
@@ -7370,6 +7584,8 @@ var LatexSyntax = (() => {
|
|
|
7370
7584
|
precedence: DIVISION_PRECEDENCE,
|
|
7371
7585
|
parse: "Mod"
|
|
7372
7586
|
},
|
|
7587
|
+
// Function-style alias: `\operatorname{mod}(a, b)`
|
|
7588
|
+
{ latexTrigger: "\\operatorname{mod}", parse: "Mod" },
|
|
7373
7589
|
{
|
|
7374
7590
|
latexTrigger: "\\pmod",
|
|
7375
7591
|
kind: "prefix",
|
|
@@ -7610,6 +7826,13 @@ var LatexSyntax = (() => {
|
|
|
7610
7826
|
const rhs = serializer.wrap(operand(expr, 2), ADDITION_PRECEDENCE + 3);
|
|
7611
7827
|
return joinLatex([lhs, "-", rhs]);
|
|
7612
7828
|
}
|
|
7829
|
+
},
|
|
7830
|
+
// Euclidean distance between two points (tuples of numbers).
|
|
7831
|
+
{
|
|
7832
|
+
name: "Distance",
|
|
7833
|
+
latexTrigger: ["\\operatorname{distance}"],
|
|
7834
|
+
kind: "function",
|
|
7835
|
+
serialize: (serializer, expr) => "\\operatorname{distance}" + serializer.wrapArguments(expr)
|
|
7613
7836
|
}
|
|
7614
7837
|
];
|
|
7615
7838
|
function getIndexAssignment(expr, upper) {
|
|
@@ -9034,7 +9257,9 @@ var LatexSyntax = (() => {
|
|
|
9034
9257
|
if (!expr || !symbol(expr)) return null;
|
|
9035
9258
|
return ["Mean", expr];
|
|
9036
9259
|
}
|
|
9037
|
-
}
|
|
9260
|
+
},
|
|
9261
|
+
// Function-style alias: `\operatorname{var}(...)`
|
|
9262
|
+
{ latexTrigger: "\\operatorname{var}", parse: "Variance" }
|
|
9038
9263
|
];
|
|
9039
9264
|
|
|
9040
9265
|
// src/compute-engine/numerics/unit-data.ts
|
|
@@ -10042,7 +10267,7 @@ var LatexSyntax = (() => {
|
|
|
10042
10267
|
36: "\\qquad"
|
|
10043
10268
|
}[v] ?? "";
|
|
10044
10269
|
}
|
|
10045
|
-
}
|
|
10270
|
+
},
|
|
10046
10271
|
// if (
|
|
10047
10272
|
// [
|
|
10048
10273
|
// '\\!',
|
|
@@ -10066,6 +10291,121 @@ var LatexSyntax = (() => {
|
|
|
10066
10291
|
// name: '',
|
|
10067
10292
|
// trigger: '\\check',
|
|
10068
10293
|
// },
|
|
10294
|
+
// ---------------------------------------------------------------------------
|
|
10295
|
+
// Function-style aliases for collection / random operators that some
|
|
10296
|
+
// notations write in lowercase (e.g. `\operatorname{shuffle}(L)`).
|
|
10297
|
+
// The capitalized library entries already exist; these are pure parse
|
|
10298
|
+
// aliases so the lowercase names don't land in `unsupported-operator`.
|
|
10299
|
+
// ---------------------------------------------------------------------------
|
|
10300
|
+
{ latexTrigger: "\\operatorname{random}", parse: "Random" },
|
|
10301
|
+
{ latexTrigger: "\\operatorname{shuffle}", parse: "Shuffle" },
|
|
10302
|
+
{ latexTrigger: "\\operatorname{repeat}", parse: "Repeat" },
|
|
10303
|
+
{ latexTrigger: "\\operatorname{join}", parse: "Join" },
|
|
10304
|
+
// ---------------------------------------------------------------------------
|
|
10305
|
+
// Geometric primitive heads. Registered as known typed heads so consumers
|
|
10306
|
+
// can branch on the operator name; CE itself doesn't render them. The
|
|
10307
|
+
// library entries (with no evaluator) live in `library/core.ts`.
|
|
10308
|
+
// ---------------------------------------------------------------------------
|
|
10309
|
+
{
|
|
10310
|
+
name: "Triangle",
|
|
10311
|
+
latexTrigger: ["\\operatorname{triangle}"],
|
|
10312
|
+
kind: "function",
|
|
10313
|
+
serialize: (serializer, expr) => "\\operatorname{triangle}" + serializer.wrapArguments(expr)
|
|
10314
|
+
},
|
|
10315
|
+
// Desmos's geometric `vector(p1, p2)` — a directed segment between two
|
|
10316
|
+
// points. Routed to a dedicated head (not the existing column-vector
|
|
10317
|
+
// `Vector`, which has a narrower `(number+) -> vector` signature).
|
|
10318
|
+
{
|
|
10319
|
+
name: "GeometricVector",
|
|
10320
|
+
latexTrigger: ["\\operatorname{vector}"],
|
|
10321
|
+
kind: "function",
|
|
10322
|
+
serialize: (serializer, expr) => "\\operatorname{vector}" + serializer.wrapArguments(expr)
|
|
10323
|
+
},
|
|
10324
|
+
{
|
|
10325
|
+
name: "Sphere",
|
|
10326
|
+
latexTrigger: ["\\operatorname{sphere}"],
|
|
10327
|
+
kind: "function",
|
|
10328
|
+
serialize: (serializer, expr) => "\\operatorname{sphere}" + serializer.wrapArguments(expr)
|
|
10329
|
+
},
|
|
10330
|
+
{
|
|
10331
|
+
name: "Segment",
|
|
10332
|
+
latexTrigger: ["\\operatorname{segment}"],
|
|
10333
|
+
kind: "function",
|
|
10334
|
+
serialize: (serializer, expr) => "\\operatorname{segment}" + serializer.wrapArguments(expr)
|
|
10335
|
+
}
|
|
10336
|
+
];
|
|
10337
|
+
|
|
10338
|
+
// src/compute-engine/latex-syntax/dictionary/definitions-colors.ts
|
|
10339
|
+
var DEFINITIONS_COLORS = [
|
|
10340
|
+
// Color constructors (one per colorspace, preserves space on evaluation)
|
|
10341
|
+
{
|
|
10342
|
+
name: "Rgb",
|
|
10343
|
+
latexTrigger: ["\\operatorname{rgb}"],
|
|
10344
|
+
kind: "function",
|
|
10345
|
+
serialize: (serializer, expr) => "\\operatorname{rgb}" + serializer.wrapArguments(expr)
|
|
10346
|
+
},
|
|
10347
|
+
{
|
|
10348
|
+
name: "Hsv",
|
|
10349
|
+
latexTrigger: ["\\operatorname{hsv}"],
|
|
10350
|
+
kind: "function",
|
|
10351
|
+
serialize: (serializer, expr) => "\\operatorname{hsv}" + serializer.wrapArguments(expr)
|
|
10352
|
+
},
|
|
10353
|
+
{
|
|
10354
|
+
name: "Hsl",
|
|
10355
|
+
latexTrigger: ["\\operatorname{hsl}"],
|
|
10356
|
+
kind: "function",
|
|
10357
|
+
serialize: (serializer, expr) => "\\operatorname{hsl}" + serializer.wrapArguments(expr)
|
|
10358
|
+
},
|
|
10359
|
+
{
|
|
10360
|
+
name: "Oklab",
|
|
10361
|
+
latexTrigger: ["\\operatorname{oklab}"],
|
|
10362
|
+
kind: "function",
|
|
10363
|
+
serialize: (serializer, expr) => "\\operatorname{oklab}" + serializer.wrapArguments(expr)
|
|
10364
|
+
},
|
|
10365
|
+
{
|
|
10366
|
+
name: "Oklch",
|
|
10367
|
+
latexTrigger: ["\\operatorname{oklch}"],
|
|
10368
|
+
kind: "function",
|
|
10369
|
+
serialize: (serializer, expr) => "\\operatorname{oklch}" + serializer.wrapArguments(expr)
|
|
10370
|
+
},
|
|
10371
|
+
// Conversion functions (color → color in the named space)
|
|
10372
|
+
{
|
|
10373
|
+
name: "AsRgb",
|
|
10374
|
+
latexTrigger: ["\\operatorname{asRgb}"],
|
|
10375
|
+
kind: "function",
|
|
10376
|
+
serialize: (serializer, expr) => "\\operatorname{asRgb}" + serializer.wrapArguments(expr)
|
|
10377
|
+
},
|
|
10378
|
+
{
|
|
10379
|
+
name: "AsHsv",
|
|
10380
|
+
latexTrigger: ["\\operatorname{asHsv}"],
|
|
10381
|
+
kind: "function",
|
|
10382
|
+
serialize: (serializer, expr) => "\\operatorname{asHsv}" + serializer.wrapArguments(expr)
|
|
10383
|
+
},
|
|
10384
|
+
{
|
|
10385
|
+
name: "AsHsl",
|
|
10386
|
+
latexTrigger: ["\\operatorname{asHsl}"],
|
|
10387
|
+
kind: "function",
|
|
10388
|
+
serialize: (serializer, expr) => "\\operatorname{asHsl}" + serializer.wrapArguments(expr)
|
|
10389
|
+
},
|
|
10390
|
+
{
|
|
10391
|
+
name: "AsOklab",
|
|
10392
|
+
latexTrigger: ["\\operatorname{asOklab}"],
|
|
10393
|
+
kind: "function",
|
|
10394
|
+
serialize: (serializer, expr) => "\\operatorname{asOklab}" + serializer.wrapArguments(expr)
|
|
10395
|
+
},
|
|
10396
|
+
{
|
|
10397
|
+
name: "AsOklch",
|
|
10398
|
+
latexTrigger: ["\\operatorname{asOklch}"],
|
|
10399
|
+
kind: "function",
|
|
10400
|
+
serialize: (serializer, expr) => "\\operatorname{asOklch}" + serializer.wrapArguments(expr)
|
|
10401
|
+
},
|
|
10402
|
+
// Perceptual difference (returns a scalar in [0, ~1])
|
|
10403
|
+
{
|
|
10404
|
+
name: "ColorDelta",
|
|
10405
|
+
latexTrigger: ["\\operatorname{colorDelta}"],
|
|
10406
|
+
kind: "function",
|
|
10407
|
+
serialize: (serializer, expr) => "\\operatorname{colorDelta}" + serializer.wrapArguments(expr)
|
|
10408
|
+
}
|
|
10069
10409
|
];
|
|
10070
10410
|
|
|
10071
10411
|
// src/compute-engine/latex-syntax/dictionary/default-dictionary.ts
|
|
@@ -10096,7 +10436,8 @@ var LatexSyntax = (() => {
|
|
|
10096
10436
|
...DEFINITIONS_STATISTICS,
|
|
10097
10437
|
...DEFINITIONS_UNITS,
|
|
10098
10438
|
...DEFINITIONS_OTHERS,
|
|
10099
|
-
...DEFINITIONS_PHYSICS
|
|
10439
|
+
...DEFINITIONS_PHYSICS,
|
|
10440
|
+
...DEFINITIONS_COLORS
|
|
10100
10441
|
];
|
|
10101
10442
|
|
|
10102
10443
|
// src/math-json/symbols.ts
|
|
@@ -10261,6 +10602,17 @@ var LatexSyntax = (() => {
|
|
|
10261
10602
|
} else if (Array.isArray(openTrigger) && openTrigger.length > 0) {
|
|
10262
10603
|
openTokens.push(openTrigger[0]);
|
|
10263
10604
|
}
|
|
10605
|
+
const closeTrigger = indexedEntry.closeTrigger;
|
|
10606
|
+
const closeTokens = /* @__PURE__ */ new Set();
|
|
10607
|
+
if (typeof closeTrigger === "string") {
|
|
10608
|
+
const variants = DELIMITER_SHORTHAND[closeTrigger];
|
|
10609
|
+
if (variants) for (const v of variants) closeTokens.add(v);
|
|
10610
|
+
else closeTokens.add(closeTrigger);
|
|
10611
|
+
if (closeTrigger === "||") closeTokens.add("|");
|
|
10612
|
+
} else if (Array.isArray(closeTrigger) && closeTrigger.length > 0) {
|
|
10613
|
+
closeTokens.add(closeTrigger[0]);
|
|
10614
|
+
}
|
|
10615
|
+
indexedEntry.closeTokens = closeTokens;
|
|
10264
10616
|
for (const token of openTokens) {
|
|
10265
10617
|
const existing = result.matchfixByOpen.get(token);
|
|
10266
10618
|
if (existing) {
|
|
@@ -10452,11 +10804,7 @@ var LatexSyntax = (() => {
|
|
|
10452
10804
|
if (style === "scaled")
|
|
10453
10805
|
return joinLatex([`\\left${openDelim}`, inner, `\\right${closeDelim}`]);
|
|
10454
10806
|
if (style === "big")
|
|
10455
|
-
return joinLatex([
|
|
10456
|
-
`\\Bigl${openDelim}`,
|
|
10457
|
-
inner,
|
|
10458
|
-
`\\Bigr${closeDelim}`
|
|
10459
|
-
]);
|
|
10807
|
+
return joinLatex([`\\Bigl${openDelim}`, inner, `\\Bigr${closeDelim}`]);
|
|
10460
10808
|
return joinLatex([openDelim, inner, closeDelim]);
|
|
10461
10809
|
};
|
|
10462
10810
|
}
|
|
@@ -13185,7 +13533,7 @@ var LatexSyntax = (() => {
|
|
|
13185
13533
|
}
|
|
13186
13534
|
if (this.match("\\hskip") || this.match("\\kern")) {
|
|
13187
13535
|
this.skipSpace();
|
|
13188
|
-
this.match("-")
|
|
13536
|
+
if (!this.match("-")) this.match("+");
|
|
13189
13537
|
while (/^[\d.]$/.test(this.peek)) this.nextToken();
|
|
13190
13538
|
for (const unit of [
|
|
13191
13539
|
"pt",
|
|
@@ -13699,6 +14047,19 @@ var LatexSyntax = (() => {
|
|
|
13699
14047
|
}
|
|
13700
14048
|
for (const def of defs) {
|
|
13701
14049
|
this.index = start;
|
|
14050
|
+
if (def.closeTokens.size > 0) {
|
|
14051
|
+
let found = false;
|
|
14052
|
+
const tokens = this._tokens;
|
|
14053
|
+
for (let i = start; i < tokens.length; i++) {
|
|
14054
|
+
if (def.closeTokens.has(tokens[i])) {
|
|
14055
|
+
found = true;
|
|
14056
|
+
break;
|
|
14057
|
+
}
|
|
14058
|
+
}
|
|
14059
|
+
if (!found) continue;
|
|
14060
|
+
}
|
|
14061
|
+
if (typeof def.openTrigger === "string" && def.openTrigger === "." && !OPEN_DELIMITER_PREFIX[currentToken])
|
|
14062
|
+
continue;
|
|
13702
14063
|
const matched = this.matchDelimiter(def.openTrigger, def.closeTrigger);
|
|
13703
14064
|
if (!matched) continue;
|
|
13704
14065
|
const bodyStart = this.index;
|
|
@@ -14361,6 +14722,19 @@ var LatexSyntax = (() => {
|
|
|
14361
14722
|
} while (postfix !== null);
|
|
14362
14723
|
}
|
|
14363
14724
|
if (result !== null) result = this.parseSupsub(result);
|
|
14725
|
+
if (result !== null) {
|
|
14726
|
+
let postfix = null;
|
|
14727
|
+
let index = this.index;
|
|
14728
|
+
do {
|
|
14729
|
+
postfix = this.parsePostfixOperator(result, until);
|
|
14730
|
+
result = postfix ?? result;
|
|
14731
|
+
if (this.index === index && postfix !== null) {
|
|
14732
|
+
console.assert(this.index !== index, "No token consumed");
|
|
14733
|
+
break;
|
|
14734
|
+
}
|
|
14735
|
+
index = this.index;
|
|
14736
|
+
} while (postfix !== null);
|
|
14737
|
+
}
|
|
14364
14738
|
if (result === null) {
|
|
14365
14739
|
result = this.options.parseUnexpectedToken?.(null, this) ?? null;
|
|
14366
14740
|
if (result === null && this.peek.startsWith("\\")) {
|
|
@@ -14869,6 +15243,28 @@ var LatexSyntax = (() => {
|
|
|
14869
15243
|
}
|
|
14870
15244
|
|
|
14871
15245
|
// src/compute-engine/latex-syntax/serializer.ts
|
|
15246
|
+
var DOT_NOTATION_MAP = {
|
|
15247
|
+
First: ".x",
|
|
15248
|
+
Second: ".y",
|
|
15249
|
+
Third: ".z",
|
|
15250
|
+
Real: ".\\operatorname{real}",
|
|
15251
|
+
Imaginary: ".\\operatorname{imag}",
|
|
15252
|
+
Length: ".\\operatorname{count}",
|
|
15253
|
+
Sum: ".\\operatorname{total}",
|
|
15254
|
+
Max: ".\\max",
|
|
15255
|
+
Min: ".\\min"
|
|
15256
|
+
};
|
|
15257
|
+
function trySerializeDotNotation(serializer, expr) {
|
|
15258
|
+
if (!serializer.options.dotNotation) return null;
|
|
15259
|
+
const ops = operands(expr);
|
|
15260
|
+
if (!ops || ops.length !== 1) return null;
|
|
15261
|
+
const head = operator(expr);
|
|
15262
|
+
if (!head) return null;
|
|
15263
|
+
const suffix = DOT_NOTATION_MAP[head];
|
|
15264
|
+
if (suffix === void 0) return null;
|
|
15265
|
+
const lhs = serializer.wrap(ops[0], 810);
|
|
15266
|
+
return `${lhs}${suffix}`;
|
|
15267
|
+
}
|
|
14872
15268
|
var ACCENT_MODIFIERS = {
|
|
14873
15269
|
deg: (s) => `${s}\\degree`,
|
|
14874
15270
|
prime: (s) => `${s}^{\\prime}`,
|
|
@@ -14912,6 +15308,7 @@ var LatexSyntax = (() => {
|
|
|
14912
15308
|
constructor(dictionary, options) {
|
|
14913
15309
|
this.dictionary = dictionary;
|
|
14914
15310
|
this.options = {
|
|
15311
|
+
dotNotation: false,
|
|
14915
15312
|
dmsFormat: false,
|
|
14916
15313
|
angleNormalization: "none",
|
|
14917
15314
|
...options
|
|
@@ -15010,6 +15407,8 @@ var LatexSyntax = (() => {
|
|
|
15010
15407
|
return def?.serialize?.(this, expr) ?? serializeSymbol(symbol(expr)) ?? "";
|
|
15011
15408
|
}
|
|
15012
15409
|
serializeFunction(expr, def) {
|
|
15410
|
+
const dotResult = trySerializeDotNotation(this, expr);
|
|
15411
|
+
if (dotResult !== null) return dotResult;
|
|
15013
15412
|
if (def?.serialize) return def.serialize(this, expr);
|
|
15014
15413
|
const h = operator(expr);
|
|
15015
15414
|
return serializeSymbol(h, "auto") + this.wrapArguments(expr);
|
|
@@ -15252,6 +15651,8 @@ var LatexSyntax = (() => {
|
|
|
15252
15651
|
preserveLatex: opts.preserveLatex ?? false,
|
|
15253
15652
|
quantifierScope: opts.quantifierScope ?? "tight",
|
|
15254
15653
|
timeDerivativeVariable: opts.timeDerivativeVariable ?? "t",
|
|
15654
|
+
// Standalone mode has no engine; use the same default as ComputeEngine
|
|
15655
|
+
tolerance: 1e-7,
|
|
15255
15656
|
// Callbacks -- standalone mode has no engine, so these are stubs
|
|
15256
15657
|
getSymbolType: (_id) => BoxedType.unknown,
|
|
15257
15658
|
hasSubscriptEvaluate: (_id) => false,
|
|
@@ -15284,6 +15685,7 @@ var LatexSyntax = (() => {
|
|
|
15284
15685
|
invisiblePlus: "",
|
|
15285
15686
|
multiply: "\\times",
|
|
15286
15687
|
missingSymbol: "\\blacksquare",
|
|
15688
|
+
dotNotation: false,
|
|
15287
15689
|
dmsFormat: false,
|
|
15288
15690
|
angleNormalization: "none",
|
|
15289
15691
|
// Style callbacks -- use same defaults as the engine
|
|
@@ -15352,7 +15754,7 @@ var LatexSyntax = (() => {
|
|
|
15352
15754
|
}
|
|
15353
15755
|
|
|
15354
15756
|
// src/latex-syntax.ts
|
|
15355
|
-
var version = "0.
|
|
15757
|
+
var version = "0.57.0";
|
|
15356
15758
|
return __toCommonJS(latex_syntax_exports);
|
|
15357
15759
|
})();
|
|
15358
15760
|
Object.assign(exports, LatexSyntax); Object.defineProperty(exports, '__esModule', { value: true });}));
|
package/dist/math-json.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
|
function isNumberObject(expr) {
|
|
@@ -115,7 +115,7 @@ function expressionToDictionaryValue(expr) {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
// src/math-json.ts
|
|
118
|
-
var version = "0.
|
|
118
|
+
var version = "0.57.0";
|
|
119
119
|
export {
|
|
120
120
|
dictionaryFromExpression,
|
|
121
121
|
isFunctionObject,
|