desmost 0.9.0 → 0.9.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 +80 -13
- package/dist/decompiler/decompile.d.ts +2 -2
- package/dist/decompiler/decompile.d.ts.map +1 -1
- package/dist/decompiler/decompile.js +1 -3
- package/dist/decompiler/decompile.js.map +1 -1
- package/dist/decompiler/format.d.ts.map +1 -1
- package/dist/decompiler/format.js +0 -1
- package/dist/decompiler/format.js.map +1 -1
- package/dist/magic/local/label.d.ts +2 -2
- package/dist/magic/local/label.d.ts.map +1 -1
- package/dist/magic/local/label.js +1 -0
- package/dist/magic/local/label.js.map +1 -1
- package/dist/options.d.ts +3 -5
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js.map +1 -1
- package/package.json +2 -4
- package/src/decompiler/decompile.ts +2 -8
- package/src/decompiler/format.ts +0 -1
- package/src/magic/local/label.ts +3 -2
- package/src/options.ts +3 -5
package/README.md
CHANGED
|
@@ -1,28 +1,95 @@
|
|
|
1
1
|
# Desmost
|
|
2
2
|
|
|
3
|
-
[**Docs**](https://github.com/Sup2point0/desmost/tree/main/docs)  ·  [**Changelog**](https://github.com/Sup2point0/desmost/blob/main/CHANGELOG.md)  ·  [**Playground**](https://sup2point0.github.io/desmost)
|
|
3
|
+
[**Docs**](https://github.com/Sup2point0/desmost/tree/main/docs)  ·  [**Changelog**](https://github.com/Sup2point0/desmost/blob/main/CHANGELOG.md)  ·  [**Learn**](https://github.com/Sup2point0/desmost/blob/main/docs/writing/learn-x-in-y.md)  ·  [**Playground**](https://sup2point0.github.io/desmost)
|
|
4
4
|
|
|
5
5
|
A tiny DSL for compiling LaTeX to Desmos.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
<table>
|
|
8
|
+
<tr></tr>
|
|
9
|
+
<tr>
|
|
10
|
+
<th> You write this: </th>
|
|
11
|
+
<th> and Desmost gives you this: </th>
|
|
12
|
+
</tr>
|
|
13
|
+
<tr>
|
|
14
|
+
<td>
|
|
15
|
+
<pre lang="hs"><code>
|
|
16
|
+
/viewport{left: -5, right: 5}
|
|
17
|
+
<br>
|
|
11
18
|
% Drag the slider!
|
|
12
|
-
|
|
13
19
|
A = 1
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/label{
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
f(x) = A \sin(x-t)
|
|
21
|
+
<br>
|
|
22
|
+
/label{
|
|
23
|
+
text: "we love Desmos(t)!"
|
|
24
|
+
} :: (0, f(0))
|
|
25
|
+
<br>
|
|
26
|
+
/anim
|
|
27
|
+
/slider{min: -10, max: 10}
|
|
19
28
|
:: t = 0
|
|
20
|
-
|
|
29
|
+
</code></pre>
|
|
30
|
+
</td>
|
|
31
|
+
<td>
|
|
32
|
+
<a href="https://sup2point0.github.io/desmost">
|
|
33
|
+
<img
|
|
34
|
+
width="600"
|
|
35
|
+
src=".assets/demo.png"
|
|
36
|
+
alt="“Desmos(t) is awesome!”, but in a fully-fledged Desmos graphing calculator embed"
|
|
37
|
+
/>
|
|
38
|
+
</a>
|
|
39
|
+
</td>
|
|
40
|
+
</tr>
|
|
41
|
+
</table>
|
|
21
42
|
|
|
22
|
-
|
|
43
|
+
In other words, it’s like HTML+CSS but for Desmos. Write your content in LaTeX (alongside your Markdown!) with Desmost syntax where you need it, and Desmost will turn it into a Desmos calculator embed for you.
|
|
23
44
|
|
|
24
45
|
|
|
25
46
|
## Requirements
|
|
26
47
|
|
|
27
48
|
- Desmos API v1.12
|
|
28
49
|
- Desmost only works **in the browser**, because the Desmos API can only be included via a `<script>` tag
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Usage
|
|
53
|
+
|
|
54
|
+
### Compile
|
|
55
|
+
```ts
|
|
56
|
+
import { compile } from "desmost";
|
|
57
|
+
|
|
58
|
+
let calc = Desmos.GraphingCalculator(...);
|
|
59
|
+
compile(calc, "f(x) = x^2");
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Pass in [options](https://github.com/Sup2point0/desmost/blob/main/docs/compiling/compiler-options.md) to customise compilation:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
compile(calc, "/text{ sup world! }", {
|
|
66
|
+
errors: "crash",
|
|
67
|
+
ignore_blank_lines: true,
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Render
|
|
72
|
+
Left up to you, in your framework of choice!
|
|
73
|
+
|
|
74
|
+
But if you enjoy nice things, Desmost provides a [Svelte<sup>↗</sup>](https://svelte.dev) component for mass-compiling Desmost, intended to be used in conjunction with [MDsveX<sup>↗</sup>](https://mdsvex.pngwn.io/):
|
|
75
|
+
|
|
76
|
+
```svelte
|
|
77
|
+
<script>
|
|
78
|
+
import Content from "./intro.md";
|
|
79
|
+
import { Desmost } from "desmost/svelte";
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<Desmost>
|
|
83
|
+
<Content />
|
|
84
|
+
</Desmost>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This will replace all ` ```desmos ` blocks from your Markdown source with Desmos calculator embeds.
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
<br>
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
<a href="https://brainmade.org">
|
|
94
|
+
<img align="right" height="80" src=".github/brainmade-black.svg" />
|
|
95
|
+
</a>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Ast } from "../parser/index.js";
|
|
2
|
-
import type { DesmostOptions } from "../
|
|
2
|
+
import type { DesmostOptions } from "../compiler/index.js";
|
|
3
3
|
export interface SemiStructuredAst {
|
|
4
4
|
globals: Ast.IncantationInvocation[];
|
|
5
5
|
locals: Ast.Expression[];
|
|
@@ -23,7 +23,7 @@ blank?: Desmos.Calculator, options?: Partial<DesmostOptions>): string;
|
|
|
23
23
|
/**
|
|
24
24
|
* Decompile `desmos` into a semi-structured AST.
|
|
25
25
|
*/
|
|
26
|
-
export declare function desmos_to_ast(desmos: Desmos.Calculator, blank: Desmos.Calculator
|
|
26
|
+
export declare function desmos_to_ast(desmos: Desmos.Calculator, blank: Desmos.Calculator): SemiStructuredAst;
|
|
27
27
|
/**
|
|
28
28
|
* Emit the Desmost source code representation of `ast`.
|
|
29
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompile.d.ts","sourceRoot":"","sources":["../../src/decompiler/decompile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decompile.d.ts","sourceRoot":"","sources":["../../src/decompiler/decompile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,WAAW,iBAAiB;IAE/B,OAAO,EAAE,GAAG,CAAC,qBAAqB,EAAE,CAAC;IACvC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,CAAC;CACzB;AAGD;;;;GAIG;AACH,wBAAgB,SAAS;AACxB,mDAAmD;AACnD,MAAM,EAAE,MAAM,CAAC,UAAU;AAEzB;;;;;;GAMG;AACH,KAAK,CAAC,EAAE,MAAM,CAAC,UAAU,EAGzB,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAC/B,MAAM,CAGR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,GAAG,iBAAiB,CASpG;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAO5D"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { emit_global_incantation, emit_expression } from "./emit.js";
|
|
2
2
|
import { extract_settings, extract_viewport, extract_expression } from "./extract.js";
|
|
3
|
-
import { fill_defaults } from "../options.js";
|
|
4
3
|
import { Ast } from "../parser/index.js";
|
|
5
4
|
/**
|
|
6
5
|
* Decompile Desmos into raw Desmost source code.
|
|
@@ -20,13 +19,12 @@ desmos,
|
|
|
20
19
|
blank,
|
|
21
20
|
// TODO doc
|
|
22
21
|
options) {
|
|
23
|
-
let opts = fill_defaults(options);
|
|
24
22
|
return ast_to_source(desmos_to_ast(desmos, blank ?? desmos));
|
|
25
23
|
}
|
|
26
24
|
/**
|
|
27
25
|
* Decompile `desmos` into a semi-structured AST.
|
|
28
26
|
*/
|
|
29
|
-
export function desmos_to_ast(desmos, blank
|
|
27
|
+
export function desmos_to_ast(desmos, blank) {
|
|
30
28
|
return {
|
|
31
29
|
globals: [
|
|
32
30
|
extract_settings(desmos, blank),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decompile.js","sourceRoot":"","sources":["../../src/decompiler/decompile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEnF,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"decompile.js","sourceRoot":"","sources":["../../src/decompiler/decompile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAEnF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAWhC;;;;GAIG;AACH,MAAM,UAAU,SAAS;AACxB,mDAAmD;AACnD,MAAyB;AAEzB;;;;;;GAMG;AACH,KAAyB;AAEzB,WAAW;AACX,OAAiC;IAGjC,OAAO,aAAa,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,MAAyB,EAAE,KAAwB;IAEhF,OAAO;QACN,OAAO,EAAE;YACR,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC;YAC/B,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC;SAC/B,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC,cAAc,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC;KACvD,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,GAAsB;IAEnD,OAAO,CACF,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;UACjD,MAAM;UACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAChD,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/decompiler/format.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,EAAE,CAAC,OAAO,IAAI,CAAC,SAAS,CAWnD,CAAA;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/decompiler/format.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,EAAE,CAAC,OAAO,IAAI,CAAC,SAAS,CAWnD,CAAA;AAGD,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKtD"}
|
|
@@ -9,7 +9,6 @@ export const stringify_json5 = (data, replacer, space) => {
|
|
|
9
9
|
};
|
|
10
10
|
export function prettify_source(source) {
|
|
11
11
|
source = source.replaceAll(/(?<=[^ ])=(?=[^ ])/g, " = ");
|
|
12
|
-
source = source.replaceAll(/\}\\/g, "} \\");
|
|
13
12
|
return source;
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=format.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/decompiler/format.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAA4B,CACrD,IAAI,EAAE,QAAQ,EAAE,KAAK,EACtB,EAAE;IAED,OAAO;IACJ,oCAAoC;IACpC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC;SACpC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,uBAAuB;SACrC,IAAI,EAAE;SACN,UAAU,CAAC,aAAa,EAAE,KAAK,CAAC,CAAE,iCAAiC;KACtE,CAAC;AACL,CAAC,CAAA;AAGD,MAAM,UAAU,eAAe,CAAC,MAAc;IAE3C,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/decompiler/format.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAA4B,CACrD,IAAI,EAAE,QAAQ,EAAE,KAAK,EACtB,EAAE;IAED,OAAO;IACJ,oCAAoC;IACpC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC;SACpC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,uBAAuB;SACrC,IAAI,EAAE;SACN,UAAU,CAAC,aAAa,EAAE,KAAK,CAAC,CAAE,iCAAiC;KACtE,CAAC;AACL,CAAC,CAAA;AAGD,MAAM,UAAU,eAAe,CAAC,MAAc;IAE3C,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,qBAAqB,EAAE,KAAK,CAAC,CAAC;IAEzD,OAAO,MAAM,CAAC;AACjB,CAAC"}
|
|
@@ -3,8 +3,8 @@ import type { DesmostOptions } from "../../options.js";
|
|
|
3
3
|
interface LabelOptions {
|
|
4
4
|
text: string;
|
|
5
5
|
show?: boolean;
|
|
6
|
-
size?: number
|
|
7
|
-
pos?:
|
|
6
|
+
size?: number;
|
|
7
|
+
pos?: "ABOVE" | "BELOW" | "LEFT" | "RIGHT" | "ABOVE_LEFT" | "ABOVE_RIGHT" | "BELOW_LEFT" | "BELOW_RIGHT";
|
|
8
8
|
}
|
|
9
9
|
export declare class LabelIncantation extends ArgIncantation<LOCAL> {
|
|
10
10
|
readonly description = "Label a block that evaluates to a point(s).";
|
|
@@ -1 +1 @@
|
|
|
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,GAAG,
|
|
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;CAkDzE"}
|
|
@@ -17,6 +17,7 @@ export class LabelIncantation extends ArgIncantation {
|
|
|
17
17
|
// @ts-expect-error: outdated types
|
|
18
18
|
if (data.size != undefined)
|
|
19
19
|
target.labelSize = data.size;
|
|
20
|
+
// @ts-expect-error: outdated types
|
|
20
21
|
if (data.pos != undefined)
|
|
21
22
|
target.labelOrientation = data.pos;
|
|
22
23
|
}
|
|
@@ -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,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAYlD,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAErD,MAAM,eAAe,GAAG;IACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO;IACjC,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa;CACxD,CAAC;AAGF,MAAM,OAAO,gBAAiB,SAAQ,cAAqB;IAExC,WAAW,GAC1B,6CAA6C,CAAA;IAE9B,UAAU,GAAK,OAAO,CAAA;IACtB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAA8B,EAAE,IAAkB;QAEhE,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,IAAI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f,CAAC;iBACI,CAAC;gBACL,6BAA6B;gBAC7B,IAAI,WAAW,GAAG,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;gBAEhD,IAAI,OAAO,CAAC,UAAU,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;oBACpD,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAC3C,2CAA2C,GAAG,EAAE,EAChD;wBACC,IAAI,EAAE,6BAA6B,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;wBAC/D,UAAU,EAAE,YAAY;qBACxB,CACD,CAAC;gBACH,CAAC;gBAED,GAAG,CAAC,GAAG,GAAG,WAAW,CAAC;YACvB,CAAC;QACF,CAAC;QAED,OAAO,GAAG,CAAC;IACZ,CAAC;CACD"}
|
package/dist/options.d.ts
CHANGED
|
@@ -57,15 +57,13 @@ export interface DesmostOptions {
|
|
|
57
57
|
*/
|
|
58
58
|
expand_errors: boolean;
|
|
59
59
|
/**
|
|
60
|
-
* Error if an incantation receives a `{}` object argument with unknown fields?
|
|
60
|
+
* Error if an incantation receives a `{}` object argument with unknown fields, or no fields at all?
|
|
61
61
|
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* For instance, `/label{position: LEFT}` is invalid; it should be `/label{pos: LEFT}`. With `check_args: false`, this silently no-ops; with `check_args: true`, it flags an error.
|
|
62
|
+
* For instance, `/label{position: LEFT}` is invalid; it should be `/label{pos: LEFT}`. With `check_args: false`, this silently no-ops.
|
|
65
63
|
*
|
|
66
64
|
* Desmost doesn’t remove unknown fields, it just passes them directly to the Desmos API. If you know what you’re doing and a field you know exists isn’t supported by Desmos, you can disable this to avoid erroring.
|
|
67
65
|
*
|
|
68
|
-
* Defaults to `true`, meaning arguments are checked.
|
|
66
|
+
* Defaults to `true`, meaning arguments are checked. The Desmos API happily accepts and ignores invalid fields, so Desmost provides a safety net for you ;)
|
|
69
67
|
*/
|
|
70
68
|
check_args: boolean;
|
|
71
69
|
/**
|
package/dist/options.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,cAAc;IAE9B;;;;;;;;;OASG;IACH,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;IAExC;;;;;;OAMG;IACH,YAAY,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;IAExC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAA;IAEtB
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,cAAc;IAE9B;;;;;;;;;OASG;IACH,MAAM,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;IAExC;;;;;;OAMG;IACH,YAAY,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;IAExC;;;;;;OAMG;IACH,YAAY,EAAE,MAAM,CAAA;IAEpB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAA;IAEtB;;;;;;;;OAQG;IACH,UAAU,EAAE,OAAO,CAAA;IAEnB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAA;IAEjB;;;;OAIG;IACH,WAAW,EAAE,OAAO,CAAA;IAEpB;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAA;IAExB;;;;OAIG;IACH,iBAAiB,EAAE,OAAO,CAAA;IAE1B;;;;OAIG;IACH,mBAAmB,EAAE,OAAO,CAAA;IAE5B;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAA;IAE7B;;;;;;OAMG;IACH,KAAK,EAAE,OAAO,CAAA;CACd;AAGD,eAAO,MAAM,eAAe,EAAE,cAc7B,CAAC;AAGF;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,cAAc,CAM1F"}
|
package/dist/options.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAkI7C,MAAM,CAAC,MAAM,eAAe,GAC5B;IACG,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,QAAQ;IACtB,YAAY,EAAE,oBAAoB,IAAI,IAAI;IAC5C,aAAa,EAAE,IAAI;IACjB,QAAQ,EAAE,IAAI;IAChB,WAAW,EAAE,IAAI;IACjB,UAAU,EAAE,KAAK;IACf,eAAe,EAAE,KAAK;IACtB,iBAAiB,EAAE,KAAK;IACxB,mBAAmB,EAAE,KAAK;IAC1B,oBAAoB,EAAE,KAAK;IAC3B,KAAK,EAAE,KAAK;CACd,CAAC;AAGF;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,OAA4C;IAEvE,OAAO;QACJ,GAAG,eAAe;QAClB,GAAG,OAAO;KACZ,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "desmost",
|
|
3
3
|
"author": "Sup#2.0",
|
|
4
|
-
"version": "0.9.
|
|
4
|
+
"version": "0.9.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
|
|
7
7
|
"description": "A tiny DSL for compiling LaTeX to Desmos",
|
|
@@ -56,9 +56,7 @@
|
|
|
56
56
|
|
|
57
57
|
"check": "npx oxlint src",
|
|
58
58
|
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
"prepublishOnly": "npm run test && npm run doc && npm run buildx"
|
|
59
|
+
"prepublishOnly": "nu build.nu pre-publish"
|
|
62
60
|
},
|
|
63
61
|
|
|
64
62
|
"dependencies":
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { emit_global_incantation, emit_expression } from "./emit";
|
|
2
2
|
import { extract_settings, extract_viewport, extract_expression } from "./extract";
|
|
3
3
|
|
|
4
|
-
import { fill_defaults } from "../options";
|
|
5
4
|
import { Ast } from "../parser";
|
|
6
|
-
import type { DesmostOptions } from "../
|
|
5
|
+
import type { DesmostOptions } from "../compiler";
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
export interface SemiStructuredAst
|
|
@@ -35,18 +34,13 @@ export function decompile(
|
|
|
35
34
|
options?: Partial<DesmostOptions>,
|
|
36
35
|
): string
|
|
37
36
|
{
|
|
38
|
-
let opts = fill_defaults(options);
|
|
39
37
|
return ast_to_source(desmos_to_ast(desmos, blank ?? desmos));
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
/**
|
|
43
41
|
* Decompile `desmos` into a semi-structured AST.
|
|
44
42
|
*/
|
|
45
|
-
export function desmos_to_ast(
|
|
46
|
-
desmos: Desmos.Calculator,
|
|
47
|
-
blank: Desmos.Calculator,
|
|
48
|
-
options: DesmostOptions,
|
|
49
|
-
): SemiStructuredAst
|
|
43
|
+
export function desmos_to_ast(desmos: Desmos.Calculator, blank: Desmos.Calculator): SemiStructuredAst
|
|
50
44
|
{
|
|
51
45
|
return {
|
|
52
46
|
globals: [
|
package/src/decompiler/format.ts
CHANGED
package/src/magic/local/label.ts
CHANGED
|
@@ -8,8 +8,8 @@ interface LabelOptions
|
|
|
8
8
|
{
|
|
9
9
|
text: string;
|
|
10
10
|
show?: boolean;
|
|
11
|
-
size?: number
|
|
12
|
-
pos?:
|
|
11
|
+
size?: number;
|
|
12
|
+
pos?: "ABOVE" | "BELOW" | "LEFT" | "RIGHT" | "ABOVE_LEFT" | "ABOVE_RIGHT" | "BELOW_LEFT" | "BELOW_RIGHT";
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const VALID_FIELDS = ["text", "show", "size", "pos"];
|
|
@@ -36,6 +36,7 @@ export class LabelIncantation extends ArgIncantation<LOCAL>
|
|
|
36
36
|
target.showLabel = data.show ?? true;
|
|
37
37
|
// @ts-expect-error: outdated types
|
|
38
38
|
if (data.size != undefined) target.labelSize = data.size;
|
|
39
|
+
// @ts-expect-error: outdated types
|
|
39
40
|
if (data.pos != undefined) target.labelOrientation = data.pos;
|
|
40
41
|
}
|
|
41
42
|
|
package/src/options.ts
CHANGED
|
@@ -66,15 +66,13 @@ export interface DesmostOptions
|
|
|
66
66
|
expand_errors: boolean
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* Error if an incantation receives a `{}` object argument with unknown fields?
|
|
69
|
+
* Error if an incantation receives a `{}` object argument with unknown fields, or no fields at all?
|
|
70
70
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
* For instance, `/label{position: LEFT}` is invalid; it should be `/label{pos: LEFT}`. With `check_args: false`, this silently no-ops; with `check_args: true`, it flags an error.
|
|
71
|
+
* For instance, `/label{position: LEFT}` is invalid; it should be `/label{pos: LEFT}`. With `check_args: false`, this silently no-ops.
|
|
74
72
|
*
|
|
75
73
|
* Desmost doesn’t remove unknown fields, it just passes them directly to the Desmos API. If you know what you’re doing and a field you know exists isn’t supported by Desmos, you can disable this to avoid erroring.
|
|
76
74
|
*
|
|
77
|
-
* Defaults to `true`, meaning arguments are checked.
|
|
75
|
+
* Defaults to `true`, meaning arguments are checked. The Desmos API happily accepts and ignores invalid fields, so Desmost provides a safety net for you ;)
|
|
78
76
|
*/
|
|
79
77
|
check_args: boolean
|
|
80
78
|
|