desmost 0.9.1 → 0.10.1
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/README.md +12 -3
- package/dist/compiler/compile.d.ts +1 -7
- package/dist/compiler/compile.d.ts.map +1 -1
- package/dist/compiler/compile.js +3 -94
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/compiler.d.ts +56 -0
- package/dist/compiler/compiler.d.ts.map +1 -0
- package/dist/compiler/compiler.js +209 -0
- package/dist/compiler/compiler.js.map +1 -0
- package/dist/compiler/format.d.ts +2 -2
- package/dist/compiler/format.d.ts.map +1 -1
- package/dist/compiler/format.js +18 -9
- package/dist/compiler/format.js.map +1 -1
- package/dist/decompiler/decompile.d.ts +1 -1
- package/dist/decompiler/decompile.d.ts.map +1 -1
- package/dist/decompiler/extract.d.ts.map +1 -1
- package/dist/decompiler/extract.js +7 -3
- package/dist/decompiler/extract.js.map +1 -1
- package/dist/errors.d.ts +35 -27
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +46 -48
- package/dist/errors.js.map +1 -1
- package/dist/index.internal.d.ts +1 -1
- package/dist/index.internal.d.ts.map +1 -1
- package/dist/magic/global/desmos.d.ts +2 -2
- package/dist/magic/global/desmos.d.ts.map +1 -1
- package/dist/magic/global/desmos.js +3 -2
- package/dist/magic/global/desmos.js.map +1 -1
- package/dist/magic/global/viewport.d.ts +2 -2
- package/dist/magic/global/viewport.d.ts.map +1 -1
- package/dist/magic/global/viewport.js +5 -5
- package/dist/magic/global/viewport.js.map +1 -1
- package/dist/magic/incantation.d.ts +4 -4
- package/dist/magic/incantation.d.ts.map +1 -1
- package/dist/magic/incantation.js +15 -8
- package/dist/magic/incantation.js.map +1 -1
- package/dist/magic/local/colour.d.ts +3 -1
- package/dist/magic/local/colour.d.ts.map +1 -1
- package/dist/magic/local/colour.js +15 -11
- package/dist/magic/local/colour.js.map +1 -1
- package/dist/magic/local/label.d.ts.map +1 -1
- package/dist/magic/local/label.js +7 -7
- package/dist/magic/local/label.js.map +1 -1
- package/dist/magic/local/line.d.ts +2 -2
- package/dist/magic/local/line.d.ts.map +1 -1
- package/dist/magic/local/line.js +0 -1
- package/dist/magic/local/line.js.map +1 -1
- package/dist/options.d.ts +57 -23
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +2 -1
- package/dist/options.js.map +1 -1
- package/dist/parser/ast.d.ts +3 -17
- package/dist/parser/ast.d.ts.map +1 -1
- package/dist/parser/ast.js +0 -2
- package/dist/parser/ast.js.map +1 -1
- package/dist/parser/desmost-parser.d.ts +33 -22
- package/dist/parser/desmost-parser.d.ts.map +1 -1
- package/dist/parser/desmost-parser.js +114 -100
- package/dist/parser/desmost-parser.js.map +1 -1
- package/dist/parser/generic-parser.d.ts +23 -14
- package/dist/parser/generic-parser.d.ts.map +1 -1
- package/dist/parser/generic-parser.js +67 -27
- package/dist/parser/generic-parser.js.map +1 -1
- package/dist/utils.d.ts +9 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +13 -2
- package/dist/utils.js.map +1 -1
- package/package.json +5 -2
- package/src/compiler/compile.ts +7 -120
- package/src/compiler/compiler.ts +275 -0
- package/src/compiler/format.ts +19 -7
- package/src/decompiler/decompile.ts +1 -1
- package/src/decompiler/extract.ts +3 -1
- package/src/errors.ts +40 -24
- package/src/index.internal.ts +1 -1
- package/src/magic/.template.ts +2 -2
- package/src/magic/global/desmos.ts +7 -9
- package/src/magic/global/viewport.ts +11 -17
- package/src/magic/incantation.ts +21 -22
- package/src/magic/local/colour.ts +23 -13
- package/src/magic/local/label.ts +11 -17
- package/src/magic/local/line.ts +2 -2
- package/src/options.ts +81 -47
- package/src/parser/ast.ts +1 -21
- package/src/parser/desmost-parser.ts +139 -143
- package/src/parser/generic-parser.ts +82 -40
- package/src/utils.ts +25 -3
- package/dist/compiler/evaluate.d.ts +0 -18
- package/dist/compiler/evaluate.d.ts.map +0 -1
- package/dist/compiler/evaluate.js +0 -93
- package/dist/compiler/evaluate.js.map +0 -1
- package/dist/desmos.d.ts +0 -16
- package/dist/desmos.d.ts.map +0 -1
- package/dist/desmos.js +0 -19
- package/dist/desmos.js.map +0 -1
- package/src/compiler/evaluate.ts +0 -128
- package/src/desmos.ts +0 -22
package/dist/errors.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Range } from "./utils.js";
|
|
1
2
|
/** The parser failed to parse something (usually during speculative parsing), which only results in internal backtracking. */
|
|
2
3
|
export declare const NO_MATCH: unique symbol;
|
|
3
4
|
/** The compiler encountered a non-fatal recoverable failure (usually during speculative parsing), which only results in internal backtracking. */
|
|
@@ -9,48 +10,55 @@ export type NoMatch = typeof NO_MATCH & {
|
|
|
9
10
|
*
|
|
10
11
|
* 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.
|
|
11
12
|
*/
|
|
12
|
-
export declare class
|
|
13
|
-
|
|
13
|
+
export declare class DesmostError extends Error {
|
|
14
|
+
data?: DesmostError.Data;
|
|
15
|
+
constructor(msg: string | undefined, name: string);
|
|
14
16
|
}
|
|
15
|
-
export declare namespace
|
|
16
|
-
interface
|
|
17
|
+
export declare namespace DesmostError {
|
|
18
|
+
interface Data {
|
|
19
|
+
msg?: string;
|
|
20
|
+
while?: string;
|
|
17
21
|
hint?: string;
|
|
18
22
|
note?: string;
|
|
19
|
-
|
|
23
|
+
debug?: string;
|
|
24
|
+
show?: {
|
|
25
|
+
text: string;
|
|
26
|
+
span?: Range;
|
|
27
|
+
};
|
|
20
28
|
}
|
|
21
|
-
/** The parser unexpectedly reached the end of its
|
|
22
|
-
class UnexpectedEnd extends
|
|
23
|
-
|
|
24
|
-
constructor(
|
|
29
|
+
/** The parser unexpectedly reached the end of its source. */
|
|
30
|
+
class UnexpectedEnd extends DesmostError {
|
|
31
|
+
data: Data;
|
|
32
|
+
constructor(data: Data);
|
|
25
33
|
}
|
|
26
34
|
/** The parser did not receive input that it expected. */
|
|
27
|
-
class MissingInput extends
|
|
28
|
-
|
|
29
|
-
constructor(
|
|
35
|
+
class MissingInput extends DesmostError {
|
|
36
|
+
data: Data;
|
|
37
|
+
constructor(data: Data);
|
|
30
38
|
}
|
|
31
39
|
/** The parser received input that did not match what it expected. */
|
|
32
|
-
class UnexpectedInput extends
|
|
33
|
-
|
|
34
|
-
constructor(
|
|
40
|
+
class UnexpectedInput extends DesmostError {
|
|
41
|
+
data: Data;
|
|
42
|
+
constructor(data: Data);
|
|
35
43
|
}
|
|
36
44
|
/** The parser received excess input that it did not expect. */
|
|
37
|
-
class ExcessInput extends
|
|
38
|
-
|
|
39
|
-
constructor(
|
|
45
|
+
class ExcessInput extends DesmostError {
|
|
46
|
+
data: Data;
|
|
47
|
+
constructor(data: Data);
|
|
40
48
|
}
|
|
41
49
|
/** An incantation can't be applied here. */
|
|
42
|
-
class IllegalIncantation extends
|
|
43
|
-
|
|
44
|
-
constructor(
|
|
50
|
+
class IllegalIncantation extends DesmostError {
|
|
51
|
+
data: Data;
|
|
52
|
+
constructor(data: Data);
|
|
45
53
|
}
|
|
46
|
-
/** An incantation's argument
|
|
47
|
-
class InvalidArgument extends
|
|
48
|
-
|
|
49
|
-
constructor(
|
|
54
|
+
/** An incantation's argument is invalid - could be a parsing, evaluation or validation failure. */
|
|
55
|
+
class InvalidArgument extends DesmostError {
|
|
56
|
+
data: Data;
|
|
57
|
+
constructor(data: Data);
|
|
50
58
|
}
|
|
51
59
|
}
|
|
52
|
-
/** Indicates that a function may throw
|
|
53
|
-
export type
|
|
60
|
+
/** Indicates that a function may throw a `DesmostError`. */
|
|
61
|
+
export type Fallible<Result> = Result | Result & {
|
|
54
62
|
readonly __brand?: unique symbol;
|
|
55
63
|
};
|
|
56
64
|
//# 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":"AAAA,8HAA8H;AAC9H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MAAa,eAAgB,SAAQ,YAAY;QAC3B,IAAI,EAAE,IAAI;oBAAV,IAAI,EAAE,IAAI;KAC/B;IAED,+DAA+D;IAC/D,MAAa,WAAY,SAAQ,YAAY;QACvB,IAAI,EAAE,IAAI;oBAAV,IAAI,EAAE,IAAI;KAC/B;IAED,4CAA4C;IAC5C,MAAa,kBAAmB,SAAQ,YAAY;QAC9B,IAAI,EAAE,IAAI;oBAAV,IAAI,EAAE,IAAI;KAC/B;IAED,mGAAmG;IACnG,MAAa,eAAgB,SAAQ,YAAY;QAC3B,IAAI,EAAE,IAAI;oBAAV,IAAI,EAAE,IAAI;KAC/B;CACD;AAED,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,CAAC,MAAM,IACxB,MAAM,GACN,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -5,69 +5,67 @@ export const NO_MATCH = Symbol("no-match");
|
|
|
5
5
|
*
|
|
6
6
|
* 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.
|
|
7
7
|
*/
|
|
8
|
-
export class
|
|
9
|
-
|
|
8
|
+
export class DesmostError extends Error {
|
|
9
|
+
data;
|
|
10
|
+
constructor(msg, name) {
|
|
11
|
+
super(msg);
|
|
12
|
+
this.name = name;
|
|
13
|
+
}
|
|
10
14
|
}
|
|
11
|
-
(function (
|
|
12
|
-
/** The parser unexpectedly reached the end of its
|
|
13
|
-
class UnexpectedEnd extends
|
|
14
|
-
|
|
15
|
-
constructor(
|
|
16
|
-
super(msg);
|
|
17
|
-
this.
|
|
18
|
-
this.name = "Unexpected End";
|
|
15
|
+
(function (DesmostError) {
|
|
16
|
+
/** The parser unexpectedly reached the end of its source. */
|
|
17
|
+
class UnexpectedEnd extends DesmostError {
|
|
18
|
+
data;
|
|
19
|
+
constructor(data) {
|
|
20
|
+
super(data.msg, "Unexpected End of Source");
|
|
21
|
+
this.data = data;
|
|
19
22
|
}
|
|
20
23
|
}
|
|
21
|
-
|
|
24
|
+
DesmostError.UnexpectedEnd = UnexpectedEnd;
|
|
22
25
|
/** The parser did not receive input that it expected. */
|
|
23
|
-
class MissingInput extends
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
26
|
-
super(msg);
|
|
27
|
-
this.
|
|
28
|
-
this.name = "Missing Input";
|
|
26
|
+
class MissingInput extends DesmostError {
|
|
27
|
+
data;
|
|
28
|
+
constructor(data) {
|
|
29
|
+
super(data.msg, "Missing Input");
|
|
30
|
+
this.data = data;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
|
-
|
|
33
|
+
DesmostError.MissingInput = MissingInput;
|
|
32
34
|
/** The parser received input that did not match what it expected. */
|
|
33
|
-
class UnexpectedInput extends
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
super(msg);
|
|
37
|
-
this.
|
|
38
|
-
this.name = "Unexpected Input";
|
|
35
|
+
class UnexpectedInput extends DesmostError {
|
|
36
|
+
data;
|
|
37
|
+
constructor(data) {
|
|
38
|
+
super(data.msg, "Unexpected Input");
|
|
39
|
+
this.data = data;
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
|
-
|
|
42
|
+
DesmostError.UnexpectedInput = UnexpectedInput;
|
|
42
43
|
/** The parser received excess input that it did not expect. */
|
|
43
|
-
class ExcessInput extends
|
|
44
|
-
|
|
45
|
-
constructor(
|
|
46
|
-
super(msg);
|
|
47
|
-
this.
|
|
48
|
-
this.name = "Excess Input";
|
|
44
|
+
class ExcessInput extends DesmostError {
|
|
45
|
+
data;
|
|
46
|
+
constructor(data) {
|
|
47
|
+
super(data.msg, "Excess Input");
|
|
48
|
+
this.data = data;
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
51
|
+
DesmostError.ExcessInput = ExcessInput;
|
|
52
52
|
/** An incantation can't be applied here. */
|
|
53
|
-
class IllegalIncantation extends
|
|
54
|
-
|
|
55
|
-
constructor(
|
|
56
|
-
super(msg);
|
|
57
|
-
this.
|
|
58
|
-
this.name = "Illegal Incantation";
|
|
53
|
+
class IllegalIncantation extends DesmostError {
|
|
54
|
+
data;
|
|
55
|
+
constructor(data) {
|
|
56
|
+
super(data.msg, "Illegal Incantation");
|
|
57
|
+
this.data = data;
|
|
59
58
|
}
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
/** An incantation's argument
|
|
63
|
-
class InvalidArgument extends
|
|
64
|
-
|
|
65
|
-
constructor(
|
|
66
|
-
super(msg);
|
|
67
|
-
this.
|
|
68
|
-
this.name = "Invalid Argument";
|
|
60
|
+
DesmostError.IllegalIncantation = IllegalIncantation;
|
|
61
|
+
/** An incantation's argument is invalid - could be a parsing, evaluation or validation failure. */
|
|
62
|
+
class InvalidArgument extends DesmostError {
|
|
63
|
+
data;
|
|
64
|
+
constructor(data) {
|
|
65
|
+
super(data.msg, "Invalid Argument");
|
|
66
|
+
this.data = data;
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
|
-
|
|
72
|
-
})(
|
|
69
|
+
DesmostError.InvalidArgument = InvalidArgument;
|
|
70
|
+
})(DesmostError || (DesmostError = {}));
|
|
73
71
|
//# sourceMappingURL=errors.js.map
|
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":"AAGA,8HAA8H;AAC9H,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;AAM3C;;;;GAIG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAEtC,IAAI,CAAqB;IAEzB,YAAY,GAAuB,EAAE,IAAY;QAChD,KAAK,CAAC,GAAG,CAAC,CAAC;QACP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACtB,CAAC;CACD;AAED,WA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AAI,CAAM;QAAyC,CAAC;KACzE;IAFY,4BAAe,kBAE3B,CAAA;AACF,CAAC,EA7CgB,YAAY,KAAZ,YAAY,QA6C5B"}
|
package/dist/index.internal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { DEFAULT_OPTIONS } from "./options.js";
|
|
2
|
-
export type { DesmostDebug } from "./compiler/
|
|
2
|
+
export type { DesmostDebug } from "./compiler/compiler.js";
|
|
3
3
|
export { Ast } from "./parser/index.js";
|
|
4
4
|
export { desmos_to_ast, ast_to_source } from "./decompiler/decompile.js";
|
|
5
5
|
//# sourceMappingURL=index.internal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.internal.d.ts","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.internal.d.ts","sourceRoot":"","sources":["../src/index.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE/B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Incantation, ArgIncantation, type GLOBAL } from "../incantation.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Fallible } from "../../errors.js";
|
|
3
3
|
import type { DesmostOptions } from "../../options.js";
|
|
4
4
|
type DesmosSettings = Desmos.GraphConfiguration & Desmos.GraphSettings;
|
|
5
5
|
export declare class DesmosIncantation extends ArgIncantation<GLOBAL> {
|
|
@@ -8,7 +8,7 @@ export declare class DesmosIncantation extends ArgIncantation<GLOBAL> {
|
|
|
8
8
|
readonly requires_arg = false;
|
|
9
9
|
readonly arg_type = Incantation.ArgType.OBJECT;
|
|
10
10
|
apply(target: Desmos.Calculator, data?: DesmosSettings): void;
|
|
11
|
-
evaluate_arg(raw: string, options: DesmostOptions):
|
|
11
|
+
evaluate_arg(raw: string, options: DesmostOptions): Fallible<DesmosSettings>;
|
|
12
12
|
}
|
|
13
13
|
export {};
|
|
14
14
|
//# sourceMappingURL=desmos.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desmos.d.ts","sourceRoot":"","sources":["../../../src/magic/global/desmos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,
|
|
1
|
+
{"version":3,"file":"desmos.d.ts","sourceRoot":"","sources":["../../../src/magic/global/desmos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,KAAK,cAAc,GAAG,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,aAAa,CAAA;AAGtE,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAE5D,SAAkB,WAAW,kEACoC;IAEjE,SAAkB,UAAU,YAAa;IACzC,SAAkB,YAAY,SAAQ;IACtC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CACb,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,IAAI,CAAC,EAAE,cAAc,GACnB,IAAI;IAOE,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;CAgBrF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DesmostError } from "../../errors.js";
|
|
3
3
|
export class DesmosIncantation extends ArgIncantation {
|
|
4
4
|
description = "Tweak calculator settings via `Calculator.updateSettings()`.";
|
|
5
5
|
identifier = "desmos";
|
|
@@ -14,7 +14,8 @@ export class DesmosIncantation extends ArgIncantation {
|
|
|
14
14
|
let out = super.evaluate_arg(raw, options);
|
|
15
15
|
if (options.check_args) {
|
|
16
16
|
if (Object.keys(out).length === 0) {
|
|
17
|
-
throw new
|
|
17
|
+
throw new DesmostError.MissingInput({
|
|
18
|
+
msg: `/desmos received empty settings`,
|
|
18
19
|
hint: `Provide settings like \`/desmos{expressionsCollapsed: true}\``,
|
|
19
20
|
note: `Use just /desmos (without \`{}\`) if you want it as an indicator`,
|
|
20
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desmos.js","sourceRoot":"","sources":["../../../src/magic/global/desmos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"desmos.js","sourceRoot":"","sources":["../../../src/magic/global/desmos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAE,YAAY,EAAiB,MAAM,cAAc,CAAC;AAO3D,MAAM,OAAO,iBAAkB,SAAQ,cAAsB;IAE1C,WAAW,GAC1B,8DAA8D,CAAA;IAE/C,UAAU,GAAK,QAAQ,CAAA;IACvB,YAAY,GAAG,KAAK,CAAA;IACpB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CACb,MAAyB,EACzB,IAAqB;QAGrB,IAAI,IAAI,IAAI,SAAS,EAAE,CAAC;YACvB,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;IAEQ,YAAY,CAAC,GAAW,EAAE,OAAuB;QAEzD,IAAI,GAAG,GAAG,KAAK,CAAC,YAAY,CAAC,GAAG,EAAE,OAAO,CAAmB,CAAC;QAE7D,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;YACxB,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACnC,MAAM,IAAI,YAAY,CAAC,YAAY,CAAC;oBACnC,GAAG,EAAG,iCAAiC;oBACvC,IAAI,EAAE,+DAA+D;oBACrE,IAAI,EAAE,kEAAkE;iBACxE,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,GAAG,CAAC;IACZ,CAAC;CACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Incantation, ArgIncantation, type GLOBAL } from "../incantation.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Fallible } from "../../errors.js";
|
|
3
3
|
import type { DesmostOptions } from "../../options.js";
|
|
4
4
|
interface ViewportBounds {
|
|
5
5
|
left?: number;
|
|
@@ -13,7 +13,7 @@ export declare class ViewportIncantation extends ArgIncantation<GLOBAL> {
|
|
|
13
13
|
readonly requires_arg = true;
|
|
14
14
|
readonly arg_type = Incantation.ArgType.OBJECT;
|
|
15
15
|
apply(target: Desmos.Calculator, data: ViewportBounds): void;
|
|
16
|
-
evaluate_arg(raw: string, options: DesmostOptions):
|
|
16
|
+
evaluate_arg(raw: string, options: DesmostOptions): Fallible<ViewportBounds>;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=viewport.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,
|
|
1
|
+
{"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE1E,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,UAAU,cAAc;IAEvB,IAAI,CAAC,EAAI,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAI,MAAM,CAAC;CAChC;AAKD,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAE9D,SAAkB,WAAW,sEACwC;IAErE,SAAkB,UAAU,cAAe;IAC3C,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,cAAc;IAcrD,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,QAAQ,CAAC,cAAc,CAAC;CA2BrF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DesmostError } from "../../errors.js";
|
|
3
3
|
const VALID_KEYS = ["left", "right", "bottom", "top"];
|
|
4
4
|
export class ViewportIncantation extends ArgIncantation {
|
|
5
5
|
description = "Set the bounds of the viewport via `Calculator.setMathBounds()`.";
|
|
@@ -15,18 +15,18 @@ export class ViewportIncantation extends ArgIncantation {
|
|
|
15
15
|
let out = super.evaluate_arg(raw, options);
|
|
16
16
|
if (options.check_args) {
|
|
17
17
|
if (Object.keys(out).length === 0) {
|
|
18
|
-
throw new
|
|
18
|
+
throw new DesmostError.InvalidArgument({
|
|
19
|
+
msg: `/${this.identifier} received empty viewport bounds`,
|
|
19
20
|
hint: `Provide bounds like \`/viewport{left: -8, right: 8}\``,
|
|
20
21
|
note: `Missing bounds are kept as their defaults`,
|
|
21
|
-
flagged_by: "check_args",
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
let invalid_keys = Object.keys(out).filter(key => !VALID_KEYS.includes(key));
|
|
25
25
|
if (invalid_keys.length > 0) {
|
|
26
26
|
let plural = invalid_keys.length > 1 ? "fields" : "field";
|
|
27
|
-
throw new
|
|
27
|
+
throw new DesmostError.InvalidArgument({
|
|
28
|
+
msg: `/${this.identifier} received invalid ${plural}: [${invalid_keys.join(", ")}]`,
|
|
28
29
|
hint: `Valid fields are: [${VALID_KEYS.join(", ")}]`,
|
|
29
|
-
flagged_by: "check_args",
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
}
|
|
@@ -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;AAE1E,OAAO,EAAE,
|
|
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;AAE1E,OAAO,EAAE,YAAY,EAAiB,MAAM,cAAc,CAAC;AAU3D,MAAM,UAAU,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;AAGtD,MAAM,OAAO,mBAAoB,SAAQ,cAAsB;IAE5C,WAAW,GAC1B,kEAAkE,CAAA;IAEnD,UAAU,GAAK,UAAU,CAAA;IACzB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAAyB,EAAE,I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CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;oBACpF,IAAI,EAAE,sBAAsB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;iBACpD,CAAC,CAAC;YACJ,CAAC;QACF,CAAC;QAED,OAAO,GAAG,CAAC;IACZ,CAAC;CACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DesmostOptions } from "../options.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DesmostError, type Fallible } from "../errors.js";
|
|
3
3
|
/**
|
|
4
4
|
* An *Incantation* is like a slash command that tells Desmost to do something - like changing the properties of an expression, or applying some settings to the calculator as a whole.
|
|
5
5
|
*
|
|
@@ -44,9 +44,9 @@ export declare abstract class ArgIncantation<Effect extends Incantation.Effect =
|
|
|
44
44
|
*
|
|
45
45
|
* Validity checks for missing or invalid values, incorrect types, and unknown fields should be performed here, so that `.apply()` can assume the data it receives is guaranteed to be valid.
|
|
46
46
|
*/
|
|
47
|
-
evaluate_arg(raw: string, options: DesmostOptions):
|
|
48
|
-
protected require_nonempty(arg: object,
|
|
49
|
-
protected require_known(arg: object, valid_fields: string[],
|
|
47
|
+
evaluate_arg(raw: string, options: DesmostOptions): Fallible<unknown>;
|
|
48
|
+
protected require_nonempty(arg: object, error_data?: DesmostError.Data): Fallible<void>;
|
|
49
|
+
protected require_known(arg: object, valid_fields: string[], error_data?: DesmostError.Data): Fallible<void>;
|
|
50
50
|
}
|
|
51
51
|
/** An incantation that affects the entire Desmos calculator state, like `/desmos` or `/viewport`. */
|
|
52
52
|
export type GLOBAL = Incantation.Effect.GLOBAL;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incantation.d.ts","sourceRoot":"","sources":["../../src/magic/incantation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"incantation.d.ts","sourceRoot":"","sources":["../../src/magic/incantation.ts"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GAAG,EAAE,MAAM,EACX,UAAU,CAAC,EAAE,YAAY,CAAC,IAAI,GAC5B,QAAQ,CAAC,IAAI,CAAC;IAUjB,SAAS,CAAC,aAAa,CACtB,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EAAE,EACtB,UAAU,CAAC,EAAE,YAAY,CAAC,IAAI,GAC5B,QAAQ,CAAC,IAAI,CAAC;CAajB;AAGD,qGAAqG;AACrG,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;AAE/C,2GAA2G;AAC3G,MAAM,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC;AAG3C,yBAAiB,WAAW,CAC5B;IACC,6HAA6H;IAC7H,KAAY,MAAM;QAEjB,qGAAqG;QACrG,MAAM,IAAA;QAEN,2GAA2G;QAC3G,KAAK,IAAA;QAEL,4EAA4E;QAC5E,IAAI,IAAA;KACJ;IAED,mFAAmF;IACnF,KAAY,OAAO;QAElB,yHAAyH;QACzH,MAAM,WAAW;QAEjB,qDAAqD;QACrD,KAAK,UAAU;QAEf,uGAAuG;QACvG,IAAI,SAAS;QAEb,oHAAoH;QACpH,MAAM,WAAW;KACjB;CACD"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Json5 from "json5";
|
|
2
2
|
import dedent from "dedent";
|
|
3
|
-
import {
|
|
3
|
+
import { DesmostError } from "../errors.js";
|
|
4
4
|
/**
|
|
5
5
|
* An *Incantation* is like a slash command that tells Desmost to do something - like changing the properties of an expression, or applying some settings to the calculator as a whole.
|
|
6
6
|
*
|
|
@@ -20,7 +20,10 @@ export class Incantation {
|
|
|
20
20
|
/** Error if the `actual` type of the given expression is not `required`. */
|
|
21
21
|
require_expr_type(actual, required) {
|
|
22
22
|
if ((actual ?? "expression") !== required) {
|
|
23
|
-
|
|
23
|
+
let req = required === "expression" ? "latex" : required;
|
|
24
|
+
throw new DesmostError.IllegalIncantation({
|
|
25
|
+
msg: `/${this.identifier} can only applied to ${req} blocks, but target block has type: ${actual}`,
|
|
26
|
+
});
|
|
24
27
|
}
|
|
25
28
|
}
|
|
26
29
|
}
|
|
@@ -53,23 +56,27 @@ export class ArgIncantation extends Incantation {
|
|
|
53
56
|
}
|
|
54
57
|
catch (e) {
|
|
55
58
|
// @ts-expect-error: fine
|
|
56
|
-
throw new
|
|
59
|
+
throw new DesmostError.InvalidArgument({ msg: e.message });
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
}
|
|
60
63
|
}
|
|
61
|
-
require_nonempty(arg,
|
|
64
|
+
require_nonempty(arg, error_data) {
|
|
62
65
|
if (Object.entries(arg).length === 0) {
|
|
63
|
-
throw new
|
|
66
|
+
throw new DesmostError.MissingInput({
|
|
67
|
+
msg: `/${this.identifier} received an empty argument {}`,
|
|
68
|
+
...error_data
|
|
69
|
+
});
|
|
64
70
|
}
|
|
65
71
|
}
|
|
66
|
-
require_known(arg, valid_fields,
|
|
72
|
+
require_known(arg, valid_fields, error_data) {
|
|
67
73
|
// TODO accumulate
|
|
68
74
|
for (let field of Object.keys(arg)) {
|
|
69
75
|
if (!valid_fields.includes(field)) {
|
|
70
|
-
throw new
|
|
76
|
+
throw new DesmostError.InvalidArgument({
|
|
77
|
+
msg: `/${this.identifier} received invalid field: ${field}`,
|
|
71
78
|
hint: `Valid fields are [${valid_fields.join(", ")}]`,
|
|
72
|
-
...
|
|
79
|
+
...error_data,
|
|
73
80
|
});
|
|
74
81
|
}
|
|
75
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incantation.js","sourceRoot":"","sources":["../../src/magic/incantation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAG5B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"inc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M,GAAN,kBAAM,KAAN,kBAAM,QAUjB;IAED,mFAAmF;IACnF,IAAY,OAaX;IAbD,WAAY,OAAO;QAElB,yHAAyH;QACzH,4BAAiB,CAAA;QAEjB,qDAAqD;QACrD,0BAAe,CAAA;QAEf,uGAAuG;QACvG,wBAAa,CAAA;QAEb,oHAAoH;QACpH,4BAAiB,CAAA;IAClB,CAAC,EAbW,OAAO,GAAP,mBAAO,KAAP,mBAAO,QAalB;AACF,CAAC,EA9BgB,WAAW,KAAX,WAAW,QA8B3B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Incantation, ArgIncantation, type LOCAL } from "../incantation.js";
|
|
2
|
-
import { DesmosColour } from "../../desmos.js";
|
|
3
2
|
import type { DesmostOptions } from "../../options.js";
|
|
3
|
+
type DesmosColourName = keyof typeof Desmos.Colors;
|
|
4
|
+
type DesmosColour = (typeof Desmos.Colors)[DesmosColourName];
|
|
4
5
|
export declare class ColourIncantation extends ArgIncantation<LOCAL> {
|
|
5
6
|
readonly description = "Change the colour of a rendered expression, such as a line, region, polygon, etc.";
|
|
6
7
|
readonly identifier = "color";
|
|
@@ -10,4 +11,5 @@ export declare class ColourIncantation extends ArgIncantation<LOCAL> {
|
|
|
10
11
|
apply(target: Desmos.ExpressionState, data: DesmosColour): void;
|
|
11
12
|
evaluate_arg(data: string, options: DesmostOptions): DesmosColour;
|
|
12
13
|
}
|
|
14
|
+
export {};
|
|
13
15
|
//# sourceMappingURL=colour.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colour.d.ts","sourceRoot":"","sources":["../../../src/magic/local/colour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"colour.d.ts","sourceRoot":"","sources":["../../../src/magic/local/colour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,KAAK,gBAAgB,GAAG,MAAM,OAAO,MAAM,CAAC,MAAM,CAAC;AACnD,KAAK,YAAY,GAAG,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,gBAAgB,CAAC,CAAC;AAK7D,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAE3D,SAAkB,WAAW,uFACyD;IAEtF,SAAkB,UAAU,WAAY;IACxC,SAAkB,KAAK,YAAkB;IACzC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,4BAA+B;IAEhD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,YAAY;IAMxD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,YAAY;CAoB1E"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { DesmostError } from "../../errors.js";
|
|
3
|
+
const VALID_COLOURS = ["RED", "BLUE", "GREEN", "PURPLE", "ORANGE", "BLACK"];
|
|
4
4
|
export class ColourIncantation extends ArgIncantation {
|
|
5
5
|
description = "Change the colour of a rendered expression, such as a line, region, polygon, etc.";
|
|
6
6
|
identifier = "color";
|
|
@@ -12,15 +12,19 @@ export class ColourIncantation extends ArgIncantation {
|
|
|
12
12
|
target.color = data;
|
|
13
13
|
}
|
|
14
14
|
evaluate_arg(data, options) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
let colour = data.trim().toUpperCase();
|
|
16
|
+
if (VALID_COLOURS.includes(colour)) {
|
|
17
|
+
return Desmos.Colors[colour];
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
let internal = Desmos.Colors[colour];
|
|
21
|
+
if (options.check_args && internal == undefined) {
|
|
22
|
+
throw new DesmostError.InvalidArgument({
|
|
23
|
+
msg: `/colour received invalid colour: \`${data}\``,
|
|
24
|
+
hint: `Valid colours are ${VALID_COLOURS.join(", ")}`,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
return internal;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colour.js","sourceRoot":"","sources":["../../../src/magic/local/colour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"colour.js","sourceRoot":"","sources":["../../../src/magic/local/colour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAO5C,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAG5E,MAAM,OAAO,iBAAkB,SAAQ,cAAqB;IAEzC,WAAW,GAC1B,mFAAmF,CAAA;IAEpE,UAAU,GAAK,OAAO,CAAA;IACtB,KAAK,GAAU,QAAQ,CAAA;IACvB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAA;IAEhD,KAAK,CAAC,MAA8B,EAAE,IAAkB;QAEhE,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACrB,CAAC;IAEQ,YAAY,CAAC,IA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,QAAQ,8BAAiC;IAElD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,YAAY;IAWxD,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,YAAY;
|
|
1
|
+
{"version":3,"file":"label.d.ts","sourceRoot":"","sources":["../../../src/magic/local/label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGpD,UAAU,YAAY;IAErB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,aAAa,GAAG,YAAY,GAAG,aAAa,CAAC;CACzG;AAUD,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAE1D,SAAkB,WAAW,iDACmB;IAEhD,SAAkB,UAAU,WAAY;IACxC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,YAAY;IAWxD,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,YAAY;CA4CzE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Incantation, ArgIncantation } from "../incantation.js";
|
|
2
|
-
import {
|
|
2
|
+
import { DesmostError } from "../../errors.js";
|
|
3
3
|
const VALID_FIELDS = ["text", "show", "size", "pos"];
|
|
4
4
|
const VALID_POSITIONS = [
|
|
5
5
|
"ABOVE", "BELOW", "LEFT", "RIGHT",
|
|
@@ -24,14 +24,14 @@ export class LabelIncantation extends ArgIncantation {
|
|
|
24
24
|
evaluate_arg(raw, options) {
|
|
25
25
|
let out = super.evaluate_arg(raw, options);
|
|
26
26
|
if (options.check_args) {
|
|
27
|
-
super.require_nonempty(out,
|
|
27
|
+
super.require_nonempty(out, {
|
|
28
|
+
msg: `/label received empty argument`,
|
|
28
29
|
hint: `You can provide [${VALID_FIELDS.join(", ")}]`,
|
|
29
|
-
flagged_by: "check_args",
|
|
30
30
|
});
|
|
31
31
|
if (!("text" in out)) {
|
|
32
|
-
throw new
|
|
32
|
+
throw new DesmostError.MissingInput({
|
|
33
|
+
msg: `/label is missing label text`,
|
|
33
34
|
hint: `Provide text for the label: \`/label{text: "sup world!"}\``,
|
|
34
|
-
flagged_by: "check_args",
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
super.require_known(out, VALID_FIELDS);
|
|
@@ -46,9 +46,9 @@ export class LabelIncantation extends ArgIncantation {
|
|
|
46
46
|
// @ts-expect-error: indexing
|
|
47
47
|
let orientation = Desmos.LabelOrientations[pos];
|
|
48
48
|
if (options.check_args && orientation == undefined) {
|
|
49
|
-
throw new
|
|
49
|
+
throw new DesmostError.InvalidArgument({
|
|
50
|
+
msg: `/label received invalid label position: ${pos}`,
|
|
50
51
|
hint: `Valid label positions are ${VALID_POSITIONS.join(", ")}`,
|
|
51
|
-
flagged_by: "check_args"
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
out.pos = orientation;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../src/magic/local/label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"label.js","sourceRoot":"","sources":["../../../src/magic/local/label.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,cAA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