desmost 0.1.0 → 0.1.2
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/LICENCE +21 -0
- package/dist/compiler/compile.d.ts +3 -26
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +5 -29
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/evaluate.d.ts +3 -14
- package/dist/compiler/evaluate.d.ts.map +1 -1
- package/dist/compiler/evaluate.js +2 -14
- package/dist/compiler/evaluate.js.map +1 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/compiler/index.js +1 -1
- package/dist/compiler/options.d.ts +0 -43
- package/dist/compiler/options.d.ts.map +1 -1
- package/dist/compiler/options.js +0 -3
- package/dist/compiler/options.js.map +1 -1
- package/dist/desmos.d.ts +0 -3
- package/dist/desmos.d.ts.map +1 -1
- package/dist/desmos.js +0 -3
- package/dist/desmos.js.map +1 -1
- package/dist/errors.d.ts +0 -19
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +0 -12
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.internal.d.ts +2 -0
- package/dist/index.internal.d.ts.map +1 -0
- package/dist/index.internal.js +2 -0
- package/dist/index.internal.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/magic/expr/index.d.ts +1 -1
- package/dist/magic/expr/index.js +3 -3
- package/dist/magic/expr/latex.d.ts +1 -1
- package/dist/magic/expr/latex.js +1 -2
- package/dist/magic/expr/latex.js.map +1 -1
- package/dist/magic/expr/text.d.ts +1 -1
- package/dist/magic/expr/text.js +1 -2
- package/dist/magic/expr/text.js.map +1 -1
- package/dist/magic/global/dark-mode.d.ts +1 -1
- package/dist/magic/global/dark-mode.js +1 -1
- package/dist/magic/global/desmos.d.ts +1 -1
- package/dist/magic/global/desmos.js +1 -1
- package/dist/magic/global/index.d.ts +1 -1
- package/dist/magic/global/index.js +4 -4
- package/dist/magic/global/viewport.d.ts +1 -1
- package/dist/magic/global/viewport.js +1 -2
- package/dist/magic/global/viewport.js.map +1 -1
- package/dist/magic/incantation.d.ts +1 -45
- package/dist/magic/incantation.d.ts.map +1 -1
- package/dist/magic/incantation.js +1 -39
- package/dist/magic/incantation.js.map +1 -1
- package/dist/magic/index.d.ts +5 -5
- package/dist/magic/index.js +4 -4
- package/dist/magic/local/anim.d.ts +1 -1
- package/dist/magic/local/anim.js +1 -2
- package/dist/magic/local/anim.js.map +1 -1
- package/dist/magic/local/colour.d.ts +2 -2
- package/dist/magic/local/colour.js +3 -3
- package/dist/magic/local/dashed.d.ts +1 -1
- package/dist/magic/local/dashed.js +1 -1
- package/dist/magic/local/fill.d.ts +1 -1
- package/dist/magic/local/fill.js +1 -1
- package/dist/magic/local/hide.d.ts +1 -1
- package/dist/magic/local/hide.js +1 -1
- package/dist/magic/local/index.d.ts +1 -1
- package/dist/magic/local/index.js +11 -11
- package/dist/magic/local/line.d.ts +1 -1
- package/dist/magic/local/line.js +1 -1
- package/dist/magic/local/no-line.d.ts +1 -1
- package/dist/magic/local/no-line.js +1 -1
- package/dist/magic/local/point.d.ts +1 -1
- package/dist/magic/local/point.js +1 -1
- package/dist/magic/local/secret.d.ts +1 -1
- package/dist/magic/local/secret.js +1 -1
- package/dist/magic/local/slider.d.ts +1 -1
- package/dist/magic/local/slider.js +1 -2
- package/dist/magic/local/slider.js.map +1 -1
- package/dist/parser/ast.d.ts +2 -11
- package/dist/parser/ast.d.ts.map +1 -1
- package/dist/parser/ast.js +2 -3
- package/dist/parser/ast.js.map +1 -1
- package/dist/parser/desmost-parser.d.ts +7 -88
- package/dist/parser/desmost-parser.d.ts.map +1 -1
- package/dist/parser/desmost-parser.js +5 -108
- package/dist/parser/desmost-parser.js.map +1 -1
- package/dist/parser/generic-parser.d.ts +1 -44
- package/dist/parser/generic-parser.d.ts.map +1 -1
- package/dist/parser/generic-parser.js +1 -47
- package/dist/parser/generic-parser.js.map +1 -1
- package/dist/parser/index.d.ts +2 -7
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +2 -7
- package/dist/parser/index.js.map +1 -1
- package/package.json +14 -8
- package/src/index.internal.ts +1 -0
- package/dist/src/compiler/compile.d.ts +0 -32
- package/dist/src/compiler/compile.d.ts.map +0 -1
- package/dist/src/compiler/compile.js +0 -101
- package/dist/src/compiler/compile.js.map +0 -1
- package/dist/src/compiler/evaluate.d.ts +0 -18
- package/dist/src/compiler/evaluate.d.ts.map +0 -1
- package/dist/src/compiler/evaluate.js +0 -83
- package/dist/src/compiler/evaluate.js.map +0 -1
- package/dist/src/compiler/index.d.ts +0 -3
- package/dist/src/compiler/index.d.ts.map +0 -1
- package/dist/src/compiler/index.js +0 -2
- package/dist/src/compiler/index.js.map +0 -1
- package/dist/src/compiler/options.d.ts +0 -54
- package/dist/src/compiler/options.d.ts.map +0 -1
- package/dist/src/compiler/options.js +0 -15
- package/dist/src/compiler/options.js.map +0 -1
- package/dist/src/desmos.d.ts +0 -12
- package/dist/src/desmos.d.ts.map +0 -1
- package/dist/src/desmos.js +0 -13
- package/dist/src/desmos.js.map +0 -1
- package/dist/src/errors.d.ts +0 -45
- package/dist/src/errors.d.ts.map +0 -1
- package/dist/src/errors.js +0 -38
- package/dist/src/errors.js.map +0 -1
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +0 -1
- package/dist/src/magic/expr/index.d.ts +0 -3
- package/dist/src/magic/expr/index.d.ts.map +0 -1
- package/dist/src/magic/expr/index.js +0 -8
- package/dist/src/magic/expr/index.js.map +0 -1
- package/dist/src/magic/expr/latex.d.ts +0 -10
- package/dist/src/magic/expr/latex.d.ts.map +0 -1
- package/dist/src/magic/expr/latex.js +0 -16
- package/dist/src/magic/expr/latex.js.map +0 -1
- package/dist/src/magic/expr/text.d.ts +0 -9
- package/dist/src/magic/expr/text.d.ts.map +0 -1
- package/dist/src/magic/expr/text.js +0 -13
- package/dist/src/magic/expr/text.js.map +0 -1
- package/dist/src/magic/global/dark-mode.d.ts +0 -7
- package/dist/src/magic/global/dark-mode.d.ts.map +0 -1
- package/dist/src/magic/global/dark-mode.js +0 -11
- package/dist/src/magic/global/dark-mode.js.map +0 -1
- package/dist/src/magic/global/desmos.d.ts +0 -9
- package/dist/src/magic/global/desmos.d.ts.map +0 -1
- package/dist/src/magic/global/desmos.js +0 -11
- package/dist/src/magic/global/desmos.js.map +0 -1
- package/dist/src/magic/global/index.d.ts +0 -3
- package/dist/src/magic/global/index.d.ts.map +0 -1
- package/dist/src/magic/global/index.js +0 -10
- package/dist/src/magic/global/index.js.map +0 -1
- package/dist/src/magic/global/viewport.d.ts +0 -16
- package/dist/src/magic/global/viewport.d.ts.map +0 -1
- package/dist/src/magic/global/viewport.js +0 -12
- package/dist/src/magic/global/viewport.js.map +0 -1
- package/dist/src/magic/incantation.d.ts +0 -74
- package/dist/src/magic/incantation.d.ts.map +0 -1
- package/dist/src/magic/incantation.js +0 -81
- package/dist/src/magic/incantation.js.map +0 -1
- package/dist/src/magic/index.d.ts +0 -6
- package/dist/src/magic/index.d.ts.map +0 -1
- package/dist/src/magic/index.js +0 -5
- package/dist/src/magic/index.js.map +0 -1
- package/dist/src/magic/local/anim.d.ts +0 -7
- package/dist/src/magic/local/anim.d.ts.map +0 -1
- package/dist/src/magic/local/anim.js +0 -11
- package/dist/src/magic/local/anim.js.map +0 -1
- package/dist/src/magic/local/colour.d.ts +0 -12
- package/dist/src/magic/local/colour.d.ts.map +0 -1
- package/dist/src/magic/local/colour.js +0 -27
- package/dist/src/magic/local/colour.js.map +0 -1
- package/dist/src/magic/local/dashed.d.ts +0 -7
- package/dist/src/magic/local/dashed.d.ts.map +0 -1
- package/dist/src/magic/local/dashed.js +0 -10
- package/dist/src/magic/local/dashed.js.map +0 -1
- package/dist/src/magic/local/fill.d.ts +0 -13
- package/dist/src/magic/local/fill.d.ts.map +0 -1
- package/dist/src/magic/local/fill.js +0 -12
- package/dist/src/magic/local/fill.js.map +0 -1
- package/dist/src/magic/local/hide.d.ts +0 -7
- package/dist/src/magic/local/hide.d.ts.map +0 -1
- package/dist/src/magic/local/hide.js +0 -10
- package/dist/src/magic/local/hide.js.map +0 -1
- package/dist/src/magic/local/index.d.ts +0 -3
- package/dist/src/magic/local/index.d.ts.map +0 -1
- package/dist/src/magic/local/index.js +0 -24
- package/dist/src/magic/local/index.js.map +0 -1
- package/dist/src/magic/local/line.d.ts +0 -15
- package/dist/src/magic/local/line.d.ts.map +0 -1
- package/dist/src/magic/local/line.js +0 -17
- package/dist/src/magic/local/line.js.map +0 -1
- package/dist/src/magic/local/no-line.d.ts +0 -7
- package/dist/src/magic/local/no-line.d.ts.map +0 -1
- package/dist/src/magic/local/no-line.js +0 -10
- package/dist/src/magic/local/no-line.js.map +0 -1
- package/dist/src/magic/local/point.d.ts +0 -15
- package/dist/src/magic/local/point.d.ts.map +0 -1
- package/dist/src/magic/local/point.js +0 -17
- package/dist/src/magic/local/point.js.map +0 -1
- package/dist/src/magic/local/secret.d.ts +0 -7
- package/dist/src/magic/local/secret.d.ts.map +0 -1
- package/dist/src/magic/local/secret.js +0 -10
- package/dist/src/magic/local/secret.js.map +0 -1
- package/dist/src/magic/local/slider.d.ts +0 -15
- package/dist/src/magic/local/slider.d.ts.map +0 -1
- package/dist/src/magic/local/slider.js +0 -13
- package/dist/src/magic/local/slider.js.map +0 -1
- package/dist/src/parser/ast.d.ts +0 -40
- package/dist/src/parser/ast.d.ts.map +0 -1
- package/dist/src/parser/ast.js +0 -13
- package/dist/src/parser/ast.js.map +0 -1
- package/dist/src/parser/desmost-parser.d.ts +0 -105
- package/dist/src/parser/desmost-parser.d.ts.map +0 -1
- package/dist/src/parser/desmost-parser.js +0 -379
- package/dist/src/parser/desmost-parser.js.map +0 -1
- package/dist/src/parser/generic-parser.d.ts +0 -62
- package/dist/src/parser/generic-parser.d.ts.map +0 -1
- package/dist/src/parser/generic-parser.js +0 -143
- package/dist/src/parser/generic-parser.js.map +0 -1
- package/dist/src/parser/index.d.ts +0 -8
- package/dist/src/parser/index.d.ts.map +0 -1
- package/dist/src/parser/index.js +0 -8
- package/dist/src/parser/index.js.map +0 -1
package/LICENCE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sup#2.0
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,29 +1,6 @@
|
|
|
1
|
-
import { type DesmostOptions } from "./options";
|
|
2
|
-
import { Ast } from "../parser";
|
|
3
|
-
|
|
4
|
-
* Compile Desmost into Desmos.
|
|
5
|
-
*
|
|
6
|
-
* This calls the Desmost compiler: parsing and evaluating `source`, then injecting the results into an existing `desmos` instance. Pass in `options` to customise compilation.
|
|
7
|
-
*
|
|
8
|
-
* ## Example
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* let calc = Desmos.GraphingCalculator();
|
|
12
|
-
*
|
|
13
|
-
* compile(calc, `/text{ sup world! }`);
|
|
14
|
-
*
|
|
15
|
-
* compile(calc, `/slider{ error! } :: t = 0`, {
|
|
16
|
-
* errors: "crash",
|
|
17
|
-
* });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function compile(
|
|
21
|
-
/** The Desmos calculator instance to compile into. */
|
|
22
|
-
desmos: Desmos.Calculator,
|
|
23
|
-
/** The Desmost source code to compile. */
|
|
24
|
-
source: string,
|
|
25
|
-
/** Compilation options. */
|
|
26
|
-
options?: DesmostOptions): void | DesmostDebug;
|
|
1
|
+
import { type DesmostOptions } from "./options.js";
|
|
2
|
+
import { Ast } from "../parser/index.js";
|
|
3
|
+
export declare function compile(desmos: Desmos.Calculator, source: string, options?: DesmostOptions): void | DesmostDebug;
|
|
27
4
|
interface DesmostDebug {
|
|
28
5
|
duration: number;
|
|
29
6
|
ast: Ast[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,WAAW,CAAC;AAGrE,OAAO,EAAiB,GAAG,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAuB,MAAM,WAAW,CAAC;AAGrE,OAAO,EAAiB,GAAG,EAAE,MAAM,WAAW,CAAC;AAqB/C,wBAAgB,OAAO,CAErB,MAAM,EAAE,MAAM,CAAC,UAAU,EAGzB,MAAM,EAAE,MAAM,EAGd,OAAO,CAAC,EAAE,cAAc,GACvB,IAAI,GAAG,YAAY,CAsFrB;AAGD,UAAU,YAAY;IAEpB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,GAAG,EAAE,CAAC;CACZ"}
|
package/dist/compiler/compile.js
CHANGED
|
@@ -1,31 +1,8 @@
|
|
|
1
|
-
import { set_default_options } from "./options";
|
|
2
|
-
import { evaluate_global_incantation, evaluate_expr, evaluate_error } from "./evaluate";
|
|
3
|
-
import { DesmostParser, Ast } from "../parser";
|
|
4
|
-
import { UnrecoverableError } from "../errors";
|
|
5
|
-
|
|
6
|
-
* Compile Desmost into Desmos.
|
|
7
|
-
*
|
|
8
|
-
* This calls the Desmost compiler: parsing and evaluating `source`, then injecting the results into an existing `desmos` instance. Pass in `options` to customise compilation.
|
|
9
|
-
*
|
|
10
|
-
* ## Example
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* let calc = Desmos.GraphingCalculator();
|
|
14
|
-
*
|
|
15
|
-
* compile(calc, `/text{ sup world! }`);
|
|
16
|
-
*
|
|
17
|
-
* compile(calc, `/slider{ error! } :: t = 0`, {
|
|
18
|
-
* errors: "crash",
|
|
19
|
-
* });
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export function compile(
|
|
23
|
-
/** The Desmos calculator instance to compile into. */
|
|
24
|
-
desmos,
|
|
25
|
-
/** The Desmost source code to compile. */
|
|
26
|
-
source,
|
|
27
|
-
/** Compilation options. */
|
|
28
|
-
options) {
|
|
1
|
+
import { set_default_options } from "./options.js";
|
|
2
|
+
import { evaluate_global_incantation, evaluate_expr, evaluate_error } from "./evaluate.js";
|
|
3
|
+
import { DesmostParser, Ast } from "../parser/index.js";
|
|
4
|
+
import { UnrecoverableError } from "../errors.js";
|
|
5
|
+
export function compile(desmos, source, options) {
|
|
29
6
|
if (desmos == undefined) {
|
|
30
7
|
console.error(`Desmost: No \`Desmos.Calculator\` instance provided, aborting compilation!`);
|
|
31
8
|
return;
|
|
@@ -38,7 +15,6 @@ options) {
|
|
|
38
15
|
let ast = [];
|
|
39
16
|
let opts = set_default_options(options);
|
|
40
17
|
let parser = new DesmostParser(source, opts);
|
|
41
|
-
/* To aggregate errors at the start, we need a target to retroactively inject errors into */
|
|
42
18
|
if (opts.place_errors === "start") {
|
|
43
19
|
desmos.setExpression({ id: "deferred-start", latex: "" });
|
|
44
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
import type { DesmostOptions } from "./options";
|
|
2
|
-
import { Ast } from "../parser";
|
|
3
|
-
import { UnrecoverableError, type Unrecoverable } from "../errors";
|
|
4
|
-
/**
|
|
5
|
-
* Evaluate arguments (if any) to a global incantation `invocation`, then apply the incantation to `desmos`.
|
|
6
|
-
*/
|
|
1
|
+
import type { DesmostOptions } from "./options.js";
|
|
2
|
+
import { Ast } from "../parser/index.js";
|
|
3
|
+
import { UnrecoverableError, type Unrecoverable } from "../errors.js";
|
|
7
4
|
export declare function evaluate_global_incantation(invocation: Ast.IncantationInvocation, desmos: Desmos.Calculator, options: Required<DesmostOptions>): Unrecoverable<void | string>;
|
|
8
|
-
/**
|
|
9
|
-
* Evaluate arguments (if any) to local incantation invocations on `expr`, then add `expr` to `desmos`.
|
|
10
|
-
*/
|
|
11
5
|
export declare function evaluate_expr(expr: Ast.Expression, desmos: Desmos.Calculator, options: Required<DesmostOptions>): Unrecoverable<void | string>;
|
|
12
|
-
/**
|
|
13
|
-
* Handle an `InvalidInvocation`, respecting the user's preferences in `options`.
|
|
14
|
-
*
|
|
15
|
-
* If the user set `place_errors: start` or `place_errors: end`, this returns the formatted error message for deferred aggregation.
|
|
16
|
-
*/
|
|
17
6
|
export declare function evaluate_error(error: UnrecoverableError, desmos: Desmos.Calculator, options: Required<DesmostOptions>): Unrecoverable<void | string>;
|
|
18
7
|
//# sourceMappingURL=evaluate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/compiler/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/compiler/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAMnE,wBAAgB,2BAA2B,CACzC,UAAU,EAAE,GAAG,CAAC,qBAAqB,EACrC,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,GAChC,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAiB9B;AAMD,wBAAgB,aAAa,CAC3B,IAAI,EAAE,GAAG,CAAC,UAAU,EACpB,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,GAChC,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAgC9B;AAQD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,GAChC,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAuB9B"}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { Ast } from "../parser";
|
|
2
|
-
import { UnrecoverableError } from "../errors";
|
|
3
|
-
/**
|
|
4
|
-
* Evaluate arguments (if any) to a global incantation `invocation`, then apply the incantation to `desmos`.
|
|
5
|
-
*/
|
|
1
|
+
import { Ast } from "../parser/index.js";
|
|
2
|
+
import { UnrecoverableError } from "../errors.js";
|
|
6
3
|
export function evaluate_global_incantation(invocation, desmos, options) {
|
|
7
4
|
let data = undefined;
|
|
8
5
|
if ("arg_raw" in invocation && invocation.arg_raw != undefined) {
|
|
@@ -18,9 +15,6 @@ export function evaluate_global_incantation(invocation, desmos, options) {
|
|
|
18
15
|
}
|
|
19
16
|
invocation.incantation.apply(desmos, data);
|
|
20
17
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Evaluate arguments (if any) to local incantation invocations on `expr`, then add `expr` to `desmos`.
|
|
23
|
-
*/
|
|
24
18
|
export function evaluate_expr(expr, desmos, options) {
|
|
25
19
|
let errors = [];
|
|
26
20
|
for (let invocation of expr.incantations) {
|
|
@@ -49,11 +43,6 @@ export function evaluate_expr(expr, desmos, options) {
|
|
|
49
43
|
}
|
|
50
44
|
desmos.setExpression(expr.data);
|
|
51
45
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Handle an `InvalidInvocation`, respecting the user's preferences in `options`.
|
|
54
|
-
*
|
|
55
|
-
* If the user set `place_errors: start` or `place_errors: end`, this returns the formatted error message for deferred aggregation.
|
|
56
|
-
*/
|
|
57
46
|
export function evaluate_error(error, desmos, options) {
|
|
58
47
|
switch (options.errors) {
|
|
59
48
|
case "crash":
|
|
@@ -78,6 +67,5 @@ function format_error(e, options) {
|
|
|
78
67
|
let prefix = options.error_prefix;
|
|
79
68
|
let sep = (prefix === "" || prefix.endsWith("\n")) ? "" : " ";
|
|
80
69
|
return `${prefix}${sep}${e.name}: ${e.message}`;
|
|
81
|
-
// TODO maybe include stack? (configurable?)
|
|
82
70
|
}
|
|
83
71
|
//# sourceMappingURL=evaluate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/compiler/evaluate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAsB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/compiler/evaluate.ts"],"names":[],"mappings":"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"}
|
package/dist/compiler/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { compile } from "./compile";
|
|
2
|
-
export type { DesmostOptions } from "./options";
|
|
1
|
+
export { compile } from "./compile.js";
|
|
2
|
+
export type { DesmostOptions } from "./options.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/compiler/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { compile } from "./compile";
|
|
1
|
+
export { compile } from "./compile.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,54 +1,11 @@
|
|
|
1
|
-
/** Options to customise Desmost compilation. */
|
|
2
1
|
export interface DesmostOptions {
|
|
3
|
-
/**
|
|
4
|
-
* How should errors be *surfaced*?
|
|
5
|
-
*
|
|
6
|
-
* Errors will always be logged to console for the developer; this setting affects how they visually reach the end user.
|
|
7
|
-
*
|
|
8
|
-
* - `surface` (default): Blocks that result in errors will become Desmos text expressions containing the error message, leaving other expressions unaffected.
|
|
9
|
-
* - `crash`: The entire compilation to Desmos will terminate with a single error message. This means you don't get any output at all, but errors are also immediately obvious.
|
|
10
|
-
* - `suppress`: Silently fail on the frontend (if you wish to give the illusion that everything is fine).
|
|
11
|
-
*/
|
|
12
2
|
errors?: "surface" | "crash" | "suppress";
|
|
13
|
-
/**
|
|
14
|
-
* Where should errors be placed?
|
|
15
|
-
*
|
|
16
|
-
* - `inline` (default): Alongside or in place of the expression that produced it.
|
|
17
|
-
* - `end`: All aggregated at the end of the Desmos expressions list.
|
|
18
|
-
* - `start`: All aggregated at the start of the Desmos expressions list.
|
|
19
|
-
*/
|
|
20
3
|
place_errors?: "inline" | "end" | "start";
|
|
21
|
-
/**
|
|
22
|
-
* The prefix to prepend to error blocks. Defaults to `[DESMOST ERROR]\n`. Provide a blank string if you wish for no prefix to be added.
|
|
23
|
-
*/
|
|
24
4
|
error_prefix?: string;
|
|
25
|
-
/**
|
|
26
|
-
* Should comments be ignored, instead of turned into text expressions?
|
|
27
|
-
*
|
|
28
|
-
* Defaults to `false`, meaning comments are kept.
|
|
29
|
-
*/
|
|
30
5
|
ignore_comments?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Should all line breaks be ignored, instead of kept as blank expressions.
|
|
33
|
-
*
|
|
34
|
-
* Defaults to `false`, meaning all blank lines are kept.
|
|
35
|
-
*/
|
|
36
6
|
ignore_line_breaks?: boolean;
|
|
37
|
-
/**
|
|
38
|
-
* Should trailing blank lines at the end of the source be ignored, instead of kept as blank expressions?
|
|
39
|
-
*
|
|
40
|
-
* Defaults to `false`, meaning trailing blank lines are kept.
|
|
41
|
-
*/
|
|
42
7
|
ignore_trailing_blanks?: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Return debug diagnostics? This includes the unevaluated AST, and performance diagnostics.
|
|
45
|
-
*
|
|
46
|
-
* Defaults to `false`.
|
|
47
|
-
*/
|
|
48
8
|
debug?: boolean;
|
|
49
9
|
}
|
|
50
|
-
/**
|
|
51
|
-
* Fill in `options` with Desmost's defaults to produce a complete `DesmostOptions` config.
|
|
52
|
-
*/
|
|
53
10
|
export declare function set_default_options(options: Partial<DesmostOptions> | undefined): Required<DesmostOptions>;
|
|
54
11
|
//# sourceMappingURL=options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,cAAc;IAW7B,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;IASzC,YAAY,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;IAKzC,YAAY,CAAC,EAAE,MAAM,CAAA;IAOrB,eAAe,CAAC,EAAE,OAAO,CAAA;IAOzB,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAO5B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAOhC,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAMD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAe1G"}
|
package/dist/compiler/options.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"AA6DA,MAAM,UAAU,mBAAmB,CAAC,OAA4C;IAE9E,OAAO,KAAK,EAAE,CAAC;IAEf,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC;IAC7B,OAAO,CAAC,YAAY,KAAK,QAAQ,CAAC;IAClC,OAAO,CAAC,YAAY,KAAK,mBAAmB,CAAC;IAE7C,OAAO,CAAC,eAAe,KAAK,KAAK,CAAC;IAClC,OAAO,CAAC,kBAAkB,KAAK,KAAK,CAAC;IACrC,OAAO,CAAC,sBAAsB,KAAK,KAAK,CAAC;IAEzC,OAAO,CAAC,KAAK,KAAK,KAAK,CAAC;IAExB,OAAO,OAAmC,CAAC;AAC7C,CAAC"}
|
package/dist/desmos.d.ts
CHANGED
package/dist/desmos.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desmos.d.ts","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"desmos.d.ts","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"AAIA,oBAAY,YAAY;IAEtB,GAAG,YAAe;IAClB,IAAI,YAAc;IAClB,KAAK,YAAa;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,KAAK,YAAa;CACnB"}
|
package/dist/desmos.js
CHANGED
package/dist/desmos.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desmos.js","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"desmos.js","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"AAIA,MAAM,CAAN,IAAY,YAQX;AARD,WAAY,YAAY;IAEtB,+BAAkB,CAAA;IAClB,gCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,kCAAkB,CAAA;IAClB,kCAAkB,CAAA;IAClB,iCAAkB,CAAA;AACpB,CAAC,EARW,YAAY,KAAZ,YAAY,QAQvB"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -1,45 +1,26 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The compiler encountered a fatal unrecoverable error, which will reach the end user.
|
|
3
|
-
*
|
|
4
|
-
* It's not *literally* unrecoverable in the sense that it will crash the compiler completely, but it means there are no further fallbacks to try.
|
|
5
|
-
*/
|
|
6
1
|
export declare class UnrecoverableError extends Error {
|
|
7
2
|
}
|
|
8
3
|
export declare namespace UnrecoverableError {
|
|
9
|
-
/** The parser unexpectedly reached the end of its entire input source code. */
|
|
10
4
|
class UnexpectedEnd extends UnrecoverableError {
|
|
11
5
|
}
|
|
12
|
-
/** The parser did not receive input that it expected. */
|
|
13
6
|
class MissingInput extends UnrecoverableError {
|
|
14
7
|
}
|
|
15
|
-
/** The parser received input that did not match what it expected. */
|
|
16
8
|
class UnexpectedInput extends UnrecoverableError {
|
|
17
9
|
}
|
|
18
|
-
/** The parser received excess input that it did not expect. */
|
|
19
10
|
class ExcessInput extends UnrecoverableError {
|
|
20
11
|
}
|
|
21
|
-
/** An incantation can't be applied here. */
|
|
22
12
|
class IllegalIncantation extends UnrecoverableError {
|
|
23
13
|
}
|
|
24
|
-
/** An incantation's argument couldn't be parsed. */
|
|
25
14
|
class InvalidArgument extends UnrecoverableError {
|
|
26
15
|
}
|
|
27
16
|
}
|
|
28
|
-
/** The compiler encountered a non-fatal recoverable failure (usually during speculative parsing), which only results in internal backtracking. */
|
|
29
17
|
export declare class RecoverableFail {
|
|
30
18
|
}
|
|
31
|
-
/** Indicates that a function may throw a `RecoverableFail`. */
|
|
32
19
|
export type Recoverable<Result> = Result | (Result & {
|
|
33
20
|
readonly __brand?: unique symbol;
|
|
34
21
|
});
|
|
35
|
-
/** Indicates that a function may throw an `UnrecoverableError`. */
|
|
36
22
|
export type Unrecoverable<Result> = Result | (Result & {
|
|
37
23
|
readonly __brand?: unique symbol;
|
|
38
24
|
});
|
|
39
|
-
/**
|
|
40
|
-
* Indicates that a function may throw either a `RecoverableFail` *or* an `UnrecoverableError`.
|
|
41
|
-
*
|
|
42
|
-
* This is used in potentially ambiguous cases. For instance, the user might have invoked an unknown incantation, in which case we might want to `RecoverableFail` and fallback to parsing it as LaTeX; on the other hand, if they invoked a valid incantation, but did not supply the required argument, that's a definite `UnrecoverableError`.
|
|
43
|
-
*/
|
|
44
25
|
export type MaybeRecoverable<Result> = Recoverable<Result> | Unrecoverable<Result>;
|
|
45
26
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,yBAAiB,kBAAkB,CACnC;IAEE,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAGxD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAGvD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAG1D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAItD,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAG7D,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;CAC3D;AAID,qBAAa,eAAe;CAAG;AAI/B,MAAM,MAAM,WAAW,CAAC,MAAM,IAAI,MAAM,IAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA,CAAC;AAGzF,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI,MAAM,IAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA,CAAC;AAO3F,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -1,37 +1,25 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The compiler encountered a fatal unrecoverable error, which will reach the end user.
|
|
3
|
-
*
|
|
4
|
-
* It's not *literally* unrecoverable in the sense that it will crash the compiler completely, but it means there are no further fallbacks to try.
|
|
5
|
-
*/
|
|
6
1
|
export class UnrecoverableError extends Error {
|
|
7
2
|
}
|
|
8
3
|
(function (UnrecoverableError) {
|
|
9
|
-
/** The parser unexpectedly reached the end of its entire input source code. */
|
|
10
4
|
class UnexpectedEnd extends UnrecoverableError {
|
|
11
5
|
}
|
|
12
6
|
UnrecoverableError.UnexpectedEnd = UnexpectedEnd;
|
|
13
|
-
/** The parser did not receive input that it expected. */
|
|
14
7
|
class MissingInput extends UnrecoverableError {
|
|
15
8
|
}
|
|
16
9
|
UnrecoverableError.MissingInput = MissingInput;
|
|
17
|
-
/** The parser received input that did not match what it expected. */
|
|
18
10
|
class UnexpectedInput extends UnrecoverableError {
|
|
19
11
|
}
|
|
20
12
|
UnrecoverableError.UnexpectedInput = UnexpectedInput;
|
|
21
|
-
/** The parser received excess input that it did not expect. */
|
|
22
13
|
class ExcessInput extends UnrecoverableError {
|
|
23
14
|
}
|
|
24
15
|
UnrecoverableError.ExcessInput = ExcessInput;
|
|
25
|
-
/** An incantation can't be applied here. */
|
|
26
16
|
class IllegalIncantation extends UnrecoverableError {
|
|
27
17
|
}
|
|
28
18
|
UnrecoverableError.IllegalIncantation = IllegalIncantation;
|
|
29
|
-
/** An incantation's argument couldn't be parsed. */
|
|
30
19
|
class InvalidArgument extends UnrecoverableError {
|
|
31
20
|
}
|
|
32
21
|
UnrecoverableError.InvalidArgument = InvalidArgument;
|
|
33
22
|
})(UnrecoverableError || (UnrecoverableError = {}));
|
|
34
|
-
/** The compiler encountered a non-fatal recoverable failure (usually during speculative parsing), which only results in internal backtracking. */
|
|
35
23
|
export class RecoverableFail {
|
|
36
24
|
}
|
|
37
25
|
;
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,WAAiB,kBAAkB;IAGjC,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAA3C,mBAAA,aAAa,gBAA8B,CAAA;IAGxD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAA1C,mBAAA,YAAY,eAA8B,CAAA;IAGvD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,mBAAA,eAAe,kBAA8B,CAAA;IAG1D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAAzC,mBAAA,WAAW,cAA8B,CAAA;IAItD,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAAhD,mBAAA,kBAAkB,qBAA8B,CAAA;IAG7D,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,mBAAA,eAAe,kBAA8B,CAAA;AAC5D,CAAC,EApBgB,kBAAkB,KAAlB,kBAAkB,QAoBlC;AAID,MAAM,OAAO,eAAe;CAAG;AAO4D,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { compile, type DesmostOptions } from "./compiler";
|
|
1
|
+
export { compile, type DesmostOptions } from "./compiler/index.js";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.internal.d.ts","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.internal.js","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { compile } from "./compiler";
|
|
1
|
+
export { compile } from "./compiler/index.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/magic/expr/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ArgIncantation } from "../incantation";
|
|
2
|
-
import { LatexIncantation } from "./latex";
|
|
3
|
-
import { TextIncantation } from "./text";
|
|
1
|
+
import { ArgIncantation } from "../incantation.js";
|
|
2
|
+
import { LatexIncantation } from "./latex.js";
|
|
3
|
+
import { TextIncantation } from "./text.js";
|
|
4
4
|
export const EXPR_INCANTATIONS = [
|
|
5
5
|
new LatexIncantation(),
|
|
6
6
|
new TextIncantation(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation, type EXPR } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation, type EXPR } from "../incantation.js";
|
|
2
2
|
export declare class LatexIncantation extends ArgIncantation<EXPR> {
|
|
3
3
|
readonly description = "Produce a LaTeX expression. This allows the input to span multiple lines.";
|
|
4
4
|
readonly identifier = "latex";
|
package/dist/magic/expr/latex.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
2
|
export class LatexIncantation extends ArgIncantation {
|
|
3
3
|
description = "Produce a LaTeX expression. This allows the input to span multiple lines.";
|
|
4
4
|
identifier = "latex";
|
|
@@ -6,7 +6,6 @@ export class LatexIncantation extends ArgIncantation {
|
|
|
6
6
|
arg_type = Incantation.ArgType.LATEX;
|
|
7
7
|
apply(target, data) {
|
|
8
8
|
target.type = "expression";
|
|
9
|
-
// @ts-expect-error: outdated types
|
|
10
9
|
target.latex = data;
|
|
11
10
|
}
|
|
12
11
|
evaluate_arg(data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"latex.js","sourceRoot":"","sources":["../../../src/magic/expr/latex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,gBAAiB,SAAQ,cAAoB;IAEtC,WAAW,GACzB,2EAA2E,CAAA;IAE7D,UAAU,GAAK,OAAO,CAAA;IACtB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;IAE1D,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEhD,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"latex.js","sourceRoot":"","sources":["../../../src/magic/expr/latex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,gBAAiB,SAAQ,cAAoB;IAEtC,WAAW,GACzB,2EAA2E,CAAA;IAE7D,UAAU,GAAK,OAAO,CAAA;IACtB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;IAE1D,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEhD,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC;QAE3B,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAEQ,YAAY,CAAC,IAAY;QAEhC,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation, type EXPR } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation, type EXPR } from "../incantation.js";
|
|
2
2
|
export declare class TextIncantation extends ArgIncantation<EXPR> {
|
|
3
3
|
readonly description = "Produce a text expression (\u201CAdd Note\u201D in the Desmos GUI).";
|
|
4
4
|
readonly identifier = "text";
|
package/dist/magic/expr/text.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
2
|
export class TextIncantation extends ArgIncantation {
|
|
3
3
|
description = "Produce a text expression (“Add Note” in the Desmos GUI).";
|
|
4
4
|
identifier = "text";
|
|
@@ -6,7 +6,6 @@ export class TextIncantation extends ArgIncantation {
|
|
|
6
6
|
arg_type = Incantation.ArgType.STRING;
|
|
7
7
|
apply(target, data) {
|
|
8
8
|
target.type = "text";
|
|
9
|
-
// @ts-expect-error: outdated types
|
|
10
9
|
target.text = data;
|
|
11
10
|
}
|
|
12
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,eAAgB,SAAQ,cAAoB;IAErC,WAAW,GACzB,2DAA2D,CAAA;IAE7C,UAAU,GAAK,MAAM,CAAA;IACrB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEzD,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,eAAgB,SAAQ,cAAoB;IAErC,WAAW,GACzB,2DAA2D,CAAA;IAE7C,UAAU,GAAK,MAAM,CAAA;IACrB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEzD,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;QAErB,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, type GLOBAL } from "../incantation";
|
|
1
|
+
import { Incantation, type GLOBAL } from "../incantation.js";
|
|
2
2
|
export declare class DarkModeIncantation extends Incantation<GLOBAL> {
|
|
3
3
|
readonly description = "Enable dark mode for the calculator, which inverts all colours.";
|
|
4
4
|
readonly identifier = "dark";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation, type GLOBAL } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation, type GLOBAL } from "../incantation.js";
|
|
2
2
|
export declare class DesmosIncantation extends ArgIncantation<GLOBAL> {
|
|
3
3
|
readonly description = "Set the configuration of the calculator via `Calculator.updateSettings()`.";
|
|
4
4
|
readonly identifier = "desmos";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
2
|
export class DesmosIncantation extends ArgIncantation {
|
|
3
3
|
description = "Set the configuration of the calculator via `Calculator.updateSettings()`.";
|
|
4
4
|
identifier = "desmos";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Incantation } from "../incantation";
|
|
2
|
-
import { DesmosIncantation } from "./desmos";
|
|
3
|
-
import { ViewportIncantation } from "./viewport";
|
|
4
|
-
import { DarkModeIncantation } from "./dark-mode";
|
|
1
|
+
import { Incantation } from "../incantation.js";
|
|
2
|
+
import { DesmosIncantation } from "./desmos.js";
|
|
3
|
+
import { ViewportIncantation } from "./viewport.js";
|
|
4
|
+
import { DarkModeIncantation } from "./dark-mode.js";
|
|
5
5
|
export const GLOBAL_INCANTATIONS = [
|
|
6
6
|
new DesmosIncantation(),
|
|
7
7
|
new ViewportIncantation(),
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { Incantation, ArgIncantation } from "../incantation";
|
|
1
|
+
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
2
|
export class ViewportIncantation extends ArgIncantation {
|
|
3
3
|
description = "Set the bounds of the viewport via `Calculator.setMathBounds()`.";
|
|
4
4
|
identifier = "viewport";
|
|
5
5
|
requires_arg = true;
|
|
6
6
|
arg_type = Incantation.ArgType.OBJECT;
|
|
7
7
|
apply(target, data) {
|
|
8
|
-
// TODO validate bounds
|
|
9
8
|
target.setMathBounds(data);
|
|
10
9
|
}
|
|
11
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAU1E,MAAM,OAAO,mBAAoB,SAAQ,cAAsB;IAE3C,WAAW,GACzB,kEAAkE,CAAA;IAEpD,UAAU,GAAK,UAAU,CAAA;IACzB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAE3D,KAAK,CAAC,MAAyB,EAAE,IAAoB;
|
|
1
|
+
{"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAU1E,MAAM,OAAO,mBAAoB,SAAQ,cAAsB;IAE3C,WAAW,GACzB,kEAAkE,CAAA;IAEpD,UAAU,GAAK,UAAU,CAAA;IACzB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAE3D,KAAK,CAAC,MAAyB,EAAE,IAAoB;QAGnD,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
|