desmost 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/compiler/compile.d.ts +7 -3
  2. package/dist/compiler/compile.d.ts.map +1 -1
  3. package/dist/compiler/compile.js +7 -3
  4. package/dist/compiler/compile.js.map +1 -1
  5. package/dist/compiler/evaluate.d.ts +5 -5
  6. package/dist/compiler/evaluate.d.ts.map +1 -1
  7. package/dist/compiler/evaluate.js +16 -8
  8. package/dist/compiler/evaluate.js.map +1 -1
  9. package/dist/compiler/format.d.ts +2 -2
  10. package/dist/compiler/format.d.ts.map +1 -1
  11. package/dist/compiler/format.js +14 -1
  12. package/dist/compiler/format.js.map +1 -1
  13. package/dist/compiler/index.d.ts +0 -1
  14. package/dist/compiler/index.d.ts.map +1 -1
  15. package/dist/decompiler/decompile.d.ts +13 -2
  16. package/dist/decompiler/decompile.d.ts.map +1 -1
  17. package/dist/decompiler/decompile.js +17 -3
  18. package/dist/decompiler/decompile.js.map +1 -1
  19. package/dist/decompiler/emit.d.ts.map +1 -1
  20. package/dist/decompiler/emit.js +13 -6
  21. package/dist/decompiler/emit.js.map +1 -1
  22. package/dist/decompiler/extract.d.ts.map +1 -1
  23. package/dist/decompiler/extract.js +3 -2
  24. package/dist/decompiler/extract.js.map +1 -1
  25. package/dist/decompiler/format.d.ts.map +1 -1
  26. package/dist/decompiler/format.js +2 -1
  27. package/dist/decompiler/format.js.map +1 -1
  28. package/dist/desmos.d.ts +4 -0
  29. package/dist/desmos.d.ts.map +1 -1
  30. package/dist/desmos.js +6 -0
  31. package/dist/desmos.js.map +1 -1
  32. package/dist/errors.d.ts +18 -0
  33. package/dist/errors.d.ts.map +1 -1
  34. package/dist/errors.js +37 -0
  35. package/dist/errors.js.map +1 -1
  36. package/dist/index.d.ts +2 -2
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.internal.d.ts +1 -1
  39. package/dist/index.internal.d.ts.map +1 -1
  40. package/dist/index.internal.js +1 -1
  41. package/dist/index.internal.js.map +1 -1
  42. package/dist/index.js +0 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/magic/expr/latex.d.ts +1 -2
  45. package/dist/magic/expr/latex.d.ts.map +1 -1
  46. package/dist/magic/expr/latex.js +1 -4
  47. package/dist/magic/expr/latex.js.map +1 -1
  48. package/dist/magic/expr/text.d.ts +1 -1
  49. package/dist/magic/expr/text.d.ts.map +1 -1
  50. package/dist/magic/expr/text.js +1 -1
  51. package/dist/magic/expr/text.js.map +1 -1
  52. package/dist/magic/global/dark-mode.d.ts.map +1 -1
  53. package/dist/magic/global/dark-mode.js +1 -3
  54. package/dist/magic/global/dark-mode.js.map +1 -1
  55. package/dist/magic/global/desmos.d.ts +4 -1
  56. package/dist/magic/global/desmos.d.ts.map +1 -1
  57. package/dist/magic/global/desmos.js +14 -1
  58. package/dist/magic/global/desmos.js.map +1 -1
  59. package/dist/magic/global/viewport.d.ts +3 -0
  60. package/dist/magic/global/viewport.d.ts.map +1 -1
  61. package/dist/magic/global/viewport.js +23 -0
  62. package/dist/magic/global/viewport.js.map +1 -1
  63. package/dist/magic/incantation.d.ts +13 -8
  64. package/dist/magic/incantation.d.ts.map +1 -1
  65. package/dist/magic/incantation.js +23 -3
  66. package/dist/magic/incantation.js.map +1 -1
  67. package/dist/magic/local/anim.d.ts.map +1 -1
  68. package/dist/magic/local/anim.js +0 -1
  69. package/dist/magic/local/anim.js.map +1 -1
  70. package/dist/magic/local/colour.d.ts +3 -2
  71. package/dist/magic/local/colour.d.ts.map +1 -1
  72. package/dist/magic/local/colour.js +3 -3
  73. package/dist/magic/local/colour.js.map +1 -1
  74. package/dist/magic/local/label.d.ts +2 -1
  75. package/dist/magic/local/label.d.ts.map +1 -1
  76. package/dist/magic/local/label.js +36 -16
  77. package/dist/magic/local/label.js.map +1 -1
  78. package/dist/magic/local/line.d.ts +3 -0
  79. package/dist/magic/local/line.d.ts.map +1 -1
  80. package/dist/magic/local/line.js +10 -0
  81. package/dist/magic/local/line.js.map +1 -1
  82. package/dist/magic/local/slider.d.ts +2 -2
  83. package/dist/magic/local/slider.d.ts.map +1 -1
  84. package/dist/magic/local/slider.js +0 -1
  85. package/dist/magic/local/slider.js.map +1 -1
  86. package/dist/{compiler/options.d.ts → options.d.ts} +51 -22
  87. package/dist/options.d.ts.map +1 -0
  88. package/dist/{compiler/options.js → options.js} +6 -1
  89. package/dist/options.js.map +1 -0
  90. package/dist/parser/desmost-parser.d.ts +1 -1
  91. package/dist/parser/desmost-parser.d.ts.map +1 -1
  92. package/dist/parser/desmost-parser.js +9 -5
  93. package/dist/parser/desmost-parser.js.map +1 -1
  94. package/dist/parser/generic-parser.d.ts +1 -5
  95. package/dist/parser/generic-parser.d.ts.map +1 -1
  96. package/dist/parser/generic-parser.js +7 -10
  97. package/dist/parser/generic-parser.js.map +1 -1
  98. package/dist/utils.d.ts +1 -0
  99. package/dist/utils.d.ts.map +1 -1
  100. package/dist/utils.js +1 -0
  101. package/dist/utils.js.map +1 -1
  102. package/package.json +8 -3
  103. package/src/compiler/compile.ts +8 -4
  104. package/src/compiler/evaluate.ts +22 -13
  105. package/src/compiler/format.ts +16 -3
  106. package/src/compiler/index.ts +0 -1
  107. package/src/decompiler/decompile.ts +25 -3
  108. package/src/decompiler/emit.ts +15 -6
  109. package/src/decompiler/extract.ts +3 -2
  110. package/src/decompiler/format.ts +2 -1
  111. package/src/decompiler/readme.md +9 -1
  112. package/src/desmos.ts +9 -0
  113. package/src/errors.ts +29 -8
  114. package/src/index.internal.ts +1 -1
  115. package/src/index.ts +2 -2
  116. package/src/magic/.template.ts +25 -16
  117. package/src/magic/expr/latex.ts +2 -7
  118. package/src/magic/expr/text.ts +2 -2
  119. package/src/magic/global/dark-mode.ts +1 -3
  120. package/src/magic/global/desmos.ts +23 -1
  121. package/src/magic/global/viewport.ts +40 -1
  122. package/src/magic/incantation.ts +59 -22
  123. package/src/magic/local/anim.ts +0 -1
  124. package/src/magic/local/colour.ts +4 -3
  125. package/src/magic/local/label.ts +49 -20
  126. package/src/magic/local/line.ts +20 -3
  127. package/src/magic/local/slider.ts +2 -3
  128. package/src/{compiler/options.ts → options.ts} +63 -14
  129. package/src/parser/desmost-parser.ts +12 -6
  130. package/src/parser/generic-parser.ts +12 -12
  131. package/src/parser/readme.md +2 -0
  132. package/src/utils.ts +3 -0
  133. package/svelte/desmost.svelte +5 -3
  134. package/dist/compiler/options.d.ts.map +0 -1
  135. package/dist/compiler/options.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { type DesmostOptions } from "./options.js";
1
+ import { type DesmostOptions } from "../options.js";
2
2
  import { Ast } from "../parser/index.js";
3
3
  /** Debug diagnostics returned from `compile()`. */
4
4
  export interface DesmostDebug {
@@ -28,6 +28,10 @@ export declare function compile(
28
28
  desmos: Desmos.Calculator,
29
29
  /** The Desmost source code to compile. */
30
30
  source: string,
31
- /** Compilation options. */
32
- options?: DesmostOptions): void | DesmostDebug;
31
+ /**
32
+ * Compilation options.
33
+ *
34
+ * See {@linkcode DesmostOptions} for the options available.
35
+ */
36
+ options?: Partial<DesmostOptions>): void | DesmostDebug;
33
37
  //# sourceMappingURL=compile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,WAAW,CAAC;AAG/D,OAAO,EAAiB,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/C,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAE5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,GAAG,EAAE,CAAC;CACX;AAGD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO;AACtB,sDAAsD;AACtD,MAAM,EAAE,MAAM,CAAC,UAAU;AAEzB,0CAA0C;AAC1C,MAAM,EAAE,MAAM;AAEd,2BAA2B;AAC3B,OAAO,CAAC,EAAE,cAAc,GACtB,IAAI,GAAG,YAAY,CAkHrB"}
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAiB,MAAM,YAAY,CAAC;AAChE,OAAO,EAAiB,GAAG,EAAE,MAAM,WAAW,CAAC;AAG/C,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAE5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,GAAG,EAAE,CAAC;CACX;AAGD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO;AACtB,sDAAsD;AACtD,MAAM,EAAE,MAAM,CAAC,UAAU;AAEzB,0CAA0C;AAC1C,MAAM,EAAE,MAAM;AAEd;;;;EAIE;AACF,OAAO,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAC/B,IAAI,GAAG,YAAY,CAkHrB"}
@@ -1,5 +1,5 @@
1
- import { fill_defaults } from "./options.js";
2
1
  import { evaluate_global_incantation, evaluate_expr, evaluate_error } from "./evaluate.js";
2
+ import { fill_defaults } from "../options.js";
3
3
  import { DesmostParser, Ast } from "../parser/index.js";
4
4
  /**
5
5
  * Compile Desmost into Desmos.
@@ -23,7 +23,11 @@ export function compile(
23
23
  desmos,
24
24
  /** The Desmost source code to compile. */
25
25
  source,
26
- /** Compilation options. */
26
+ /**
27
+ * Compilation options.
28
+ *
29
+ * See {@linkcode DesmostOptions} for the options available.
30
+ */
27
31
  options) {
28
32
  if (desmos == undefined) {
29
33
  console.error(`Desmost: No \`Desmos.Calculator\` instance provided, aborting compilation!`);
@@ -67,7 +71,7 @@ options) {
67
71
  defer = evaluate_global_incantation(r, desmos, opts);
68
72
  break;
69
73
  case Ast.Kind.EXPRESSION:
70
- // @ts-expect-error: outdated types
74
+ // @ts-expect-error: check type-narrows
71
75
  if (r.data.latex === " ") {
72
76
  if (opts.ignore_all_blanks)
73
77
  break;
@@ -1 +1 @@
1
- {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/compiler/compile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAExF,OAAO,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAY/C;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,OAAO;AACtB,sDAAsD;AACtD,MAAyB;AAEzB,0CAA0C;AAC1C,MAAc;AAEd,2BAA2B;AAC3B,OAAwB;IAGxB,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,4EAA4E,CAAC,CAAC;QAC5F,OAAO;IACR,CAAC;IAED,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,yDAAyD,CAAC,CAAC;QACzE,OAAO;IACR,CAAC;IAED,IAAI,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAElC,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QAChB,IAAI,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAC/B,IAAI,UAAU,GAAG,CAAC,CAAC;QACnB,IAAI,GAAG,GAAU,EAAE,CAAC;IACrB,CAAC;IAED,IAAI,MAAM,GAAG,IAAI,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAE7C,IAAI,MAAM,GAAa,EAAE,CAAC;IAE1B,4FAA4F;IAC5F,IAAI,IAAI,CAAC,YAAY,KAAK,OAAO,EAAE,CAAC;QACnC,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,gBAAgB,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAE,4BAA4B;IAC1F,CAAC;IAED,qGAAqG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GAAG,EAAE,CAAC,CAAC;IACtC,CAAC;AACF,CAAC"}
@@ -1,18 +1,18 @@
1
- import type { DesmostOptions } from "./options.js";
1
+ import type { DesmostOptions } from "../options.js";
2
2
  import { Ast } from "../parser/index.js";
3
3
  import { UnrecoverableError, type Unrecoverable } from "../errors.js";
4
4
  /**
5
5
  * Evaluate arguments (if any) to a global incantation `invocation`, then apply the incantation to `desmos`.
6
6
  */
7
- export declare function evaluate_global_incantation(invocation: Ast.IncantationInvocation, desmos: Desmos.Calculator, options: Required<DesmostOptions>): Unrecoverable<void | string>;
7
+ export declare function evaluate_global_incantation(invocation: Ast.IncantationInvocation, desmos: Desmos.Calculator, options: DesmostOptions): Unrecoverable<void | string>;
8
8
  /**
9
- * Evaluate arguments (if any) to local incantation invocations on `expr`, then add `expr` to `desmos`.
9
+ * Evaluate local incantation invocations on `expr`, then add `expr` to `desmos`.
10
10
  */
11
- export declare function evaluate_expr(expr: Ast.Expression, desmos: Desmos.Calculator, options: Required<DesmostOptions>): Unrecoverable<void | string>;
11
+ export declare function evaluate_expr(expr: Ast.Expression, desmos: Desmos.Calculator, options: DesmostOptions): Unrecoverable<void | string>;
12
12
  /**
13
13
  * Handle an `InvalidInvocation`, respecting the user's preferences in `options`.
14
14
  *
15
15
  * If the user set `place_errors: start` or `place_errors: end`, this returns the formatted error message for deferred aggregation.
16
16
  */
17
- export declare function evaluate_error(error: UnrecoverableError, desmos: Desmos.Calculator, options: Required<DesmostOptions>): Unrecoverable<void | string>;
17
+ export declare function evaluate_error(error: UnrecoverableError, desmos: Desmos.Calculator, options: DesmostOptions): Unrecoverable<void | string>;
18
18
  //# sourceMappingURL=evaluate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.d.ts","sourceRoot":"","sources":["../../src/compiler/evaluate.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;A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c,GACrB,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAkD9B;AAGD;;;;GAIG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,kBAAkB,EACzB,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,OAAO,EAAE,cAAc,GACrB,aAAa,CAAC,IAAI,GAAG,MAAM,CAAC,CAuB9B"}
@@ -1,6 +1,8 @@
1
+ import dedent from "dedent";
1
2
  import { format_error, normalise_latex, prettify_latex } from "./format.js";
2
3
  import { Ast } from "../parser/index.js";
3
4
  import { UnrecoverableError } from "../errors.js";
5
+ import { is_latex } from "../desmos.js";
4
6
  /**
5
7
  * Evaluate arguments (if any) to a global incantation `invocation`, then apply the incantation to `desmos`.
6
8
  */
@@ -8,7 +10,7 @@ export function evaluate_global_incantation(invocation, desmos, options) {
8
10
  let data = undefined;
9
11
  if ("arg_raw" in invocation && invocation.arg_raw != undefined) {
10
12
  try {
11
- data = invocation.incantation.evaluate_arg(invocation.arg_raw);
13
+ data = invocation.incantation.evaluate_arg(invocation.arg_raw, options);
12
14
  }
13
15
  catch (e) {
14
16
  let msg = evaluate_error(e, desmos, options);
@@ -18,7 +20,7 @@ export function evaluate_global_incantation(invocation, desmos, options) {
18
20
  invocation.incantation.apply(desmos, data);
19
21
  }
20
22
  /**
21
- * Evaluate arguments (if any) to local incantation invocations on `expr`, then add `expr` to `desmos`.
23
+ * Evaluate local incantation invocations on `expr`, then add `expr` to `desmos`.
22
24
  */
23
25
  export function evaluate_expr(expr, desmos, options) {
24
26
  let errors = [];
@@ -33,28 +35,34 @@ export function evaluate_expr(expr, desmos, options) {
33
35
  let data = undefined;
34
36
  if ("arg_raw" in invocation && invocation.arg_raw != undefined) {
35
37
  try {
36
- data = invocation.incantation.evaluate_arg(invocation.arg_raw);
38
+ data = invocation.incantation.evaluate_arg(invocation.arg_raw, options);
37
39
  }
38
40
  catch (e) {
39
41
  errors.push(format_error(e, options));
42
+ // if it needs the arg, then we can't press on
40
43
  if (invocation.incantation.requires_arg)
41
44
  continue;
42
45
  }
43
46
  }
44
- invocation.incantation.apply(expr.data, data);
47
+ try {
48
+ invocation.incantation.apply(expr.data, data);
49
+ }
50
+ catch (e) {
51
+ errors.push(format_error(e, options));
52
+ }
45
53
  }
46
54
  if (errors.length > 0) {
47
55
  desmos.setExpression({ type: "text", text: errors.join("\n\n") });
48
56
  }
49
- // @ts-expect-error: outdated types
50
- if (expr.data.latex != undefined) {
51
- // @ts-expect-error: outdated types
57
+ if (is_latex(expr.data)) {
52
58
  expr.data.latex = normalise_latex(expr.data.latex);
53
59
  if (options.prettify) {
54
- // @ts-expect-error: outdated types
55
60
  expr.data.latex = prettify_latex(expr.data.latex);
56
61
  }
57
62
  }
63
+ else if (expr.data.type === "text" && options.dedent_text) {
64
+ expr.data.text = dedent(expr.data.text ?? "");
65
+ }
58
66
  desmos.setExpression(expr.data);
59
67
  }
60
68
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate.js","sourceRoot":"","sources":["../../src/compiler/evaluate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAGzE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,kBAAkB,EAAsB,MAAM,WAAW,CAAC;AAGnE;;GAEG;AACH,MAAM,UAAU,2BAA2B,CAC1C,UAAqC,EACrC,MAAyB,EACzB,OAAiC;IAGjC,IAAI,IAAI,GAAG,SAAS,CAAC;IAErB,IAAI,SAAS,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,IAAI,SAAS,EAAE,CAAC;QAChE,IAAI,CAAC;YACJ,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,CAAC,EAAE,CAAC;YACV,IAAI,GAAG,GAAG,cAAc,CAAC,CAAU,EAAE,MAAM,EAAE,OAAO,CAAC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I,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC;IACF,CAAC;SACI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QAC3D,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAGD;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC7B,KAAyB,EACzB,MAAyB,EACzB,OAAuB;IAGvB,QAAQ,OAAO,CAAC,MAAM,EAAE,CAAC;QACxB,KAAK,OAAO;YACX,MAAM,KAAK,CAAC;QAEb,KAAK,UAAU;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,MAAM;QAEP,OAAO,CAAC,CAAC,QAAQ,OAAO,CAAC,YAAY,EAAE,CAAC;YACvC,KAAK,KAAK,CAAC;YACX,KAAK,OAAO;gBACX,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAErC;gBACC,MAAM,CAAC,aAAa,CAAC;oBACpB,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC;iBAClC,CAAC,CAAC;gBACH,MAAM;QACR,CAAC;IACF,CAAC;AACF,CAAC"}
@@ -1,6 +1,6 @@
1
- import type { DesmostOptions } from "./options.js";
1
+ import type { DesmostOptions } from "../options.js";
2
2
  import { UnrecoverableError } from "../errors.js";
3
- export declare function format_error(e: UnrecoverableError, options: Required<DesmostOptions>): string;
3
+ export declare function format_error(e: UnrecoverableError, options: DesmostOptions): string;
4
4
  /**
5
5
  * Remove line breaks from `latex` so Desmos can properly consume it.
6
6
  */
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/compiler/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG/C,wBAAgB,YAAY,CAC3B,CAAC,EAAE,kBAAkB,EACrB,OAAO,EAAE,QAAQ,CAAC,cAAc,CAAC,GAC/B,MAAM,CAOR;AAGD;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrD;AAGD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAiBpD"}
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../src/compiler/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAI/C,wBAAgB,YAAY,CAC3B,CAAC,EAAE,kBAAkB,EACrB,OAAO,EAAE,cAAc,GACrB,MAAM,CAiBR;AAGD;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIrD;AAGD;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAmBpD"}
@@ -1,9 +1,20 @@
1
1
  import { UnrecoverableError } from "../errors.js";
2
+ import { LINE } from "../utils.js";
2
3
  export function format_error(e, options) {
3
4
  let prefix = options.error_prefix;
4
5
  let sep = (prefix === "" || prefix.endsWith("\n")) ? "" : " ";
5
- return `${prefix}${sep}${e.name}: ${e.message}`;
6
6
  // TODO maybe include stack? (configurable?)
7
+ let display = `${prefix}${sep}${e.name}: ${e.message}`;
8
+ if (e.info != undefined && options.expand_errors) {
9
+ display += `\n${LINE}`;
10
+ if (e.info.hint != undefined)
11
+ display += `\nHint: ${e.info.hint}`;
12
+ if (e.info.note != undefined)
13
+ display += `\n${LINE}\nNote: ${e.info.note}`;
14
+ if (e.info.flagged_by != undefined)
15
+ display += `\n${LINE}\nFlagged by: \`${e.info.flagged_by}\``;
16
+ }
17
+ return display;
7
18
  }
8
19
  /**
9
20
  * Remove line breaks from `latex` so Desmos can properly consume it.
@@ -22,7 +33,9 @@ export function normalise_latex(latex) {
22
33
  */
23
34
  export function prettify_latex(latex) {
24
35
  latex = latex.replaceAll(/(?<!\\left)(\(|\[|\\\{)/g, "\\left$1");
36
+ latex = latex.replaceAll(/(?:\\left\s?)+/g, "\\left");
25
37
  latex = latex.replaceAll(/(?<!\\right)(\)|\]|\\\})/g, "\\right$1");
38
+ latex = latex.replaceAll(/(?:\\right\s?)+/g, "\\right");
26
39
  latex = latex.replaceAll(/(:|,)(?!\\ ) */g, "$1\\ ");
27
40
  latex = latex.replaceAll(/(?<=[^\w]|^)\\?(length|mean|median|count|total|repeat|join|sort|shuffle|unique|mod|ceil|floor|round|sign) ?(?=\(|\\left\()/g, "\\operatorname{$1}");
28
41
  latex = latex.replaceAll(/\s(and|or)\s/g, "\\operatorname{$1}");
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/compiler/format.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG/C,MAAM,UAAU,YAAY,CAC3B,CAAqB,EACrB,OAAiC;IAGjC,IAAI,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAClC,IAAI,GAAG,GAAG,CAAC,MAAM,KAAK,EAAE,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC;IAE9D,OAAO,GAAG,MAAM,GAAG,GAAG,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;IAChD,4CAA4C;AAC7C,CAAC;AAGD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAa;I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 +1,2 @@
1
1
  export { compile } from "./compile.js";
2
- export type { DesmostOptions } from "./options.js";
3
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compiler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/compiler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC"}
@@ -1,4 +1,5 @@
1
1
  import { Ast } from "../parser/index.js";
2
+ import type { DesmostOptions } from "../options.js";
2
3
  export interface SemiStructuredAst {
3
4
  globals: Ast.IncantationInvocation[];
4
5
  locals: Ast.Expression[];
@@ -8,11 +9,21 @@ export interface SemiStructuredAst {
8
9
  *
9
10
  * The caller must also supply a `blank` calculator instance. This is used as a reference for default field values, so that emitted incantations like `/desmos{}` don't get filled with a huge amount of noise.
10
11
  */
11
- export declare function decompile(desmos: Desmos.Calculator, blank: Desmos.Calculator): string;
12
+ export declare function decompile(
13
+ /** The Desmos calculator instance to decompile. */
14
+ desmos: Desmos.Calculator,
15
+ /**
16
+ * The default blank Desmos calculator instance to use as a baseline.
17
+ *
18
+ * It is **highly recommended** to include this, otherwise your decompiled source will have a bunch of unnecessary incantations!
19
+ *
20
+ * This is used in deciding what settings are noise that can be omitted. For instance, most of your calculator settings are probably set to their default values, so there's no need to include *every single one of them* in `/desmos{}`.
21
+ */
22
+ blank?: Desmos.Calculator, options?: Partial<DesmostOptions>): string;
12
23
  /**
13
24
  * Decompile `desmos` into a semi-structured AST.
14
25
  */
15
- export declare function desmos_to_ast(desmos: Desmos.Calculator, blank: Desmos.Calculator): SemiStructuredAst;
26
+ export declare function desmos_to_ast(desmos: Desmos.Calculator, blank: Desmos.Calculator, options: DesmostOptions): SemiStructuredAst;
16
27
  /**
17
28
  * Emit the Desmost source code representation of `ast`.
18
29
  */
@@ -1 +1 @@
1
- {"version":3,"file":"decompile.d.ts","sourceRoot":"","sources":["../../src/decompiler/decompile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhC,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,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,UAAU,GAAG,MAAM,CAGrF;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
+ {"version":3,"file":"decompile.d.ts","sourceRoot":"","sources":["../../src/decompiler/decompile.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjD,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,CAIR;AAED;;GAEG;AACH,wBAAgB,aAAa,CAC5B,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,KAAK,EAAE,MAAM,CAAC,UAAU,EACxB,OAAO,EAAE,cAAc,GACrB,iBAAiB,CASnB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAO5D"}
@@ -1,18 +1,32 @@
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";
3
4
  import { Ast } from "../parser/index.js";
4
5
  /**
5
6
  * Decompile Desmos into raw Desmost source code.
6
7
  *
7
8
  * The caller must also supply a `blank` calculator instance. This is used as a reference for default field values, so that emitted incantations like `/desmos{}` don't get filled with a huge amount of noise.
8
9
  */
9
- export function decompile(desmos, blank) {
10
- return ast_to_source(desmos_to_ast(desmos, blank));
10
+ export function decompile(
11
+ /** The Desmos calculator instance to decompile. */
12
+ desmos,
13
+ /**
14
+ * The default blank Desmos calculator instance to use as a baseline.
15
+ *
16
+ * It is **highly recommended** to include this, otherwise your decompiled source will have a bunch of unnecessary incantations!
17
+ *
18
+ * This is used in deciding what settings are noise that can be omitted. For instance, most of your calculator settings are probably set to their default values, so there's no need to include *every single one of them* in `/desmos{}`.
19
+ */
20
+ blank,
21
+ // TODO doc
22
+ options) {
23
+ let opts = fill_defaults(options);
24
+ return ast_to_source(desmos_to_ast(desmos, blank ?? desmos));
11
25
  }
12
26
  /**
13
27
  * Decompile `desmos` into a semi-structured AST.
14
28
  */
15
- export function desmos_to_ast(desmos, blank) {
29
+ export function desmos_to_ast(desmos, blank, options) {
16
30
  return {
17
31
  globals: [
18
32
  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,kBAAk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zB;;;;;;GAMG;AACH,KAAyB;AAEzB,WAAW;AACX,OAAiC;IAGjC,IAAI,IAAI,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,aAAa,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,IAAI,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAC5B,MAAyB,EACzB,KAAwB,EACxB,OAAuB;IAGvB,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":"emit.d.ts","sourceRoot":"","sources":["../../src/decompiler/emit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrC;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,qBAAqB,GAAG,MAAM,CAQtF;AAGD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,GAAG,MAAM,CA0B7D"}
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/decompiler/emit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGrC;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,CAAC,EAAE,GAAG,CAAC,qBAAqB,GAAG,MAAM,CAQtF;AAGD;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,UAAU,GAAG,MAAM,CAmC7D"}
@@ -20,16 +20,23 @@ export function emit_expression(expr) {
20
20
  let content;
21
21
  switch (expr.data.type) {
22
22
  case "text":
23
- content = `/text{ ${expr.data.text} }`;
23
+ expr.data.text ??= "";
24
+ if (expr.data.text.includes("\n")) {
25
+ content = `/text{\n${expr.data.text}\n}`;
26
+ }
27
+ else {
28
+ content = `% ${expr.data.text}`;
29
+ }
30
+ break;
31
+ case "table":
32
+ content = "[tables are currently unsupported]";
24
33
  break;
25
34
  default:
26
- // @ts-expect-error: outdated types
27
- if (expr.data.latex?.trim() === "") {
28
- content = "";
35
+ if (expr.data.latex?.trim() !== "") {
36
+ content = expr.data.latex ?? "[unsupported]";
29
37
  }
30
38
  else {
31
- // @ts-expect-error: outdated types
32
- content = expr.data.latex ?? "?";
39
+ content = "";
33
40
  }
34
41
  }
35
42
  return `${locals.join(" ")}${sep}${content}`;
@@ -1 +1 @@
1
- {"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/decompiler/emit.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,UAAsC;IAE7E,IAAI,UAAU,IAAI,SAAS;QAAE,OAAO,EAAE,CAAC;IAErC,IAAI,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC;IAC9C,IAAI,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC;IAEjC,OAAO,IAAI,KAAK,QAAQ,OAAO,KAAK,CAAC;AACxC,CAAC;AAGD;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAqB;IAEpD,IAAI,IA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qB,GAAG,IAAI,CAuBlC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC7B,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,KAAK,EAAE,MAAM,CAAC,UAAU,GACxB,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAkBlC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,eAAe,GAAG,GAAG,CAAC,UAAU,CAuBrF"}
1
+ {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../src/decompiler/extract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAMhC;;GAEG;AACH,wBAAgB,gBAAgB,CAC7B,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,KAAK,EAAE,MAAM,CAAC,UAAU,GACxB,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAuBlC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC7B,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,KAAK,EAAE,MAAM,CAAC,UAAU,GACxB,GAAG,CAAC,qBAAqB,GAAG,IAAI,CAkBlC;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,eAAe,GAAG,GAAG,CAAC,UAAU,CAuBrF"}
@@ -1,5 +1,6 @@
1
1
  import { stringify_json5, prettify_source } from "./format.js";
2
2
  import { Ast } from "../parser/index.js";
3
+ import { is_latex } from "../desmos.js";
3
4
  import { DesmosIncantation, ViewportIncantation } from "../magic/global/index.js";
4
5
  /**
5
6
  * Extract a `/desmos` incantation from the settings of `desmos`.
@@ -39,7 +40,7 @@ export function extract_viewport(desmos, blank) {
39
40
  */
40
41
  export function extract_expression(expression) {
41
42
  let data;
42
- // @ts-expect-error: outdated types
43
+ // @ts-expect-error: check type-narrows
43
44
  if (expression.latex?.trim() === "") {
44
45
  data = { latex: ` ` };
45
46
  }
@@ -47,7 +48,7 @@ export function extract_expression(expression) {
47
48
  data = Object.fromEntries(Object.entries(expression)
48
49
  .filter(([key, value]) => !is_insignificant(key, value)));
49
50
  }
50
- if ("latex" in data) {
51
+ if (is_latex(expression)) {
51
52
  data.latex = prettify_source(data.latex);
52
53
  }
53
54
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","sourceRoot":"","sources":["../../src/decompiler/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE5D,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGzE;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC7B,MAAyB,EACzB,KAAwB;IAGxB,IAAI,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAE9B,IAAI,OAAO,GAAG,eAAe,CAC1B,MAAM,CAAC,QAAQ,EACf,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CACJ,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC;WACjB,CAAC,KAAK,aAAa;WACnB,CAAC,KAAK,MAAM;WACZ,CAAC,KAAK,YAAY;WAClB,CAAC,KAAK,QAAQ,CACnB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EACjB,IAAI,CACN,CAAC;IAEF,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,IAAI,CAAC;IAEzC,OAAO;QACN,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,sBAAsB;QACrC,WAAW,EAAE,IAAI,iBAAiB,EAAE;QACpC,OAAO;KACP,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAC7B,MAAyB,EACzB,KAAwB;IAGxB,IAAI,QAAQ,GAAG,KAAK,CAAC,gBAAgB,CAAC,eAAe,CAAC;IACxD,IAAI,EAAE,IAAI,EAAE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,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5C,CAAC;IAEH,OAAO;QACN,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,UAAU;QACzB,IAAI;QACJ,YAAY,EAAE,EAAE,EAAG,OAAO;KAC1B,CAAC;AACH,CAAC;AAGD,SAAS,gBAAgB,CAAC,GAAW,EAAE,KAAU;IAE9C,OAAO,CACD,KAAK,KAAK,EAAE;WACZ,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAC3E,CAAC;AACL,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,CAKtD"}
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,CAMtD"}
@@ -1,6 +1,6 @@
1
1
  export const stringify_json5 = (data, replacer, space) => {
2
2
  return (
3
- /// @ts-expect-error: random `null`??
3
+ // @ts-expect-error: random `null`??
4
4
  JSON.stringify(data, replacer, space)
5
5
  .slice(1, -1) // strip surrounding {}
6
6
  .trim()
@@ -9,6 +9,7 @@ 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, "} \\");
12
13
  return source;
13
14
  }
14
15
  //# 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,qCAAqC;IACrC,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"}
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;IACzD,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;IAE3C,OAAO,MAAM,CAAC;AACjB,CAAC"}
package/dist/desmos.d.ts CHANGED
@@ -9,4 +9,8 @@ export declare enum DesmosColour {
9
9
  ORANGE = "#fa7e19",
10
10
  BLACK = "#000000"
11
11
  }
12
+ /**
13
+ * Is `expr` a Desmos LaTeX expression (as opposed to a note or table)?
14
+ */
15
+ export declare function is_latex(expr: Desmos.ExpressionState): expr is Desmos.Expression;
12
16
  //# sourceMappingURL=desmos.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"desmos.d.ts","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,YAAY;IAEvB,GAAG,YAAe;IAClB,IAAI,YAAc;IAClB,KAAK,YAAa;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,KAAK,YAAa;CAClB"}
1
+ {"version":3,"file":"desmos.d.ts","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,oBAAY,YAAY;IAEvB,GAAG,YAAe;IAClB,IAAI,YAAc;IAClB,KAAK,YAAa;IAClB,MAAM,YAAY;IAClB,MAAM,YAAY;IAClB,KAAK,YAAa;CAClB;AAGD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,eAAe,GAAG,IAAI,IAAI,MAAM,CAAC,UAAU,CAGhF"}
package/dist/desmos.js CHANGED
@@ -10,4 +10,10 @@ export var DesmosColour;
10
10
  DesmosColour["ORANGE"] = "#fa7e19";
11
11
  DesmosColour["BLACK"] = "#000000";
12
12
  })(DesmosColour || (DesmosColour = {}));
13
+ /**
14
+ * Is `expr` a Desmos LaTeX expression (as opposed to a note or table)?
15
+ */
16
+ export function is_latex(expr) {
17
+ return (expr.type === undefined || expr.type === "expression");
18
+ }
13
19
  //# sourceMappingURL=desmos.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"desmos.js","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,YAQX;AARD,WAAY,YAAY;IAEvB,+BAAkB,CAAA;IAClB,gCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,kCAAkB,CAAA;IAClB,kCAAkB,CAAA;IAClB,iCAAkB,CAAA;AACnB,CAAC,EARW,YAAY,KAAZ,YAAY,QAQvB"}
1
+ {"version":3,"file":"desmos.js","sourceRoot":"","sources":["../src/desmos.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,YAQX;AARD,WAAY,YAAY;IAEvB,+BAAkB,CAAA;IAClB,gCAAkB,CAAA;IAClB,iCAAkB,CAAA;IAClB,kCAAkB,CAAA;IAClB,kCAAkB,CAAA;IAClB,iCAAkB,CAAA;AACnB,CAAC,EARW,YAAY,KAAZ,YAAY,QAQvB;AAGD;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,IAA4B;IAEpD,OAAO,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC;AAChE,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -10,25 +10,43 @@ export type NoMatch = typeof NO_MATCH & {
10
10
  * 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
11
  */
12
12
  export declare class UnrecoverableError extends Error {
13
+ info?: UnrecoverableError.Info;
13
14
  }
14
15
  export declare namespace UnrecoverableError {
16
+ interface Info {
17
+ hint?: string;
18
+ note?: string;
19
+ flagged_by?: string;
20
+ }
15
21
  /** The parser unexpectedly reached the end of its entire input source code. */
16
22
  class UnexpectedEnd extends UnrecoverableError {
23
+ info?: Info | undefined;
24
+ constructor(msg: string, info?: Info | undefined);
17
25
  }
18
26
  /** The parser did not receive input that it expected. */
19
27
  class MissingInput extends UnrecoverableError {
28
+ info?: Info | undefined;
29
+ constructor(msg: string, info?: Info | undefined);
20
30
  }
21
31
  /** The parser received input that did not match what it expected. */
22
32
  class UnexpectedInput extends UnrecoverableError {
33
+ info?: Info | undefined;
34
+ constructor(msg: string, info?: Info | undefined);
23
35
  }
24
36
  /** The parser received excess input that it did not expect. */
25
37
  class ExcessInput extends UnrecoverableError {
38
+ info?: Info | undefined;
39
+ constructor(msg: string, info?: Info | undefined);
26
40
  }
27
41
  /** An incantation can't be applied here. */
28
42
  class IllegalIncantation extends UnrecoverableError {
43
+ info?: Info | undefined;
44
+ constructor(msg: string, info?: Info | undefined);
29
45
  }
30
46
  /** An incantation's argument couldn't be parsed. */
31
47
  class InvalidArgument extends UnrecoverableError {
48
+ info?: Info | undefined;
49
+ constructor(msg: string, info?: Info | undefined);
32
50
  }
33
51
  }
34
52
  /** Indicates that a function may throw an `UnrecoverableError`. */
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAC9H,eAAO,MAAM,QAAQ,eAAqB,CAAC;AAE3C,kJAAkJ;AAClJ,MAAM,MAAM,OAAO,GAAG,OAAO,QAAQ,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAG7E;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,yBAAiB,kBAAkB,CACnC;IACC,+EAA+E;IAC/E,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAExD,yDAAyD;IACzD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAEvD,qEAAqE;IACrE,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAE1D,+DAA+D;IAC/D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAGtD,4CAA4C;IAC5C,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAE7D,oDAAoD;IACpD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;CAC1D;AAGD,mEAAmE;AACnE,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,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I;oBAAjC,GAAG,EAAE,MAAM,EAAW,IAAI,CAAC,EAAE,IAAI,YAAA;KAC7C;IAED,oDAAoD;IACpD,MAAa,eAAgB,SAAQ,kBAAkB;QACpB,IAAI,CAAC,EAAE,IAAI;oBAAjC,GAAG,EAAE,MAAM,EAAW,IAAI,CAAC,EAAE,IAAI,YAAA;KAC7C;CACD;AAGD,mEAAmE;AACnE,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI,MAAM,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC"}
package/dist/errors.js CHANGED
@@ -6,30 +6,67 @@ export const NO_MATCH = Symbol("no-match");
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
8
  export class UnrecoverableError extends Error {
9
+ info;
9
10
  }
10
11
  (function (UnrecoverableError) {
11
12
  /** The parser unexpectedly reached the end of its entire input source code. */
12
13
  class UnexpectedEnd extends UnrecoverableError {
14
+ info;
15
+ constructor(msg, info) {
16
+ super(msg);
17
+ this.info = info;
18
+ this.name = "Unexpected End";
19
+ }
13
20
  }
14
21
  UnrecoverableError.UnexpectedEnd = UnexpectedEnd;
15
22
  /** The parser did not receive input that it expected. */
16
23
  class MissingInput extends UnrecoverableError {
24
+ info;
25
+ constructor(msg, info) {
26
+ super(msg);
27
+ this.info = info;
28
+ this.name = "Missing Input";
29
+ }
17
30
  }
18
31
  UnrecoverableError.MissingInput = MissingInput;
19
32
  /** The parser received input that did not match what it expected. */
20
33
  class UnexpectedInput extends UnrecoverableError {
34
+ info;
35
+ constructor(msg, info) {
36
+ super(msg);
37
+ this.info = info;
38
+ this.name = "Unexpected Input";
39
+ }
21
40
  }
22
41
  UnrecoverableError.UnexpectedInput = UnexpectedInput;
23
42
  /** The parser received excess input that it did not expect. */
24
43
  class ExcessInput extends UnrecoverableError {
44
+ info;
45
+ constructor(msg, info) {
46
+ super(msg);
47
+ this.info = info;
48
+ this.name = "Excess Input";
49
+ }
25
50
  }
26
51
  UnrecoverableError.ExcessInput = ExcessInput;
27
52
  /** An incantation can't be applied here. */
28
53
  class IllegalIncantation extends UnrecoverableError {
54
+ info;
55
+ constructor(msg, info) {
56
+ super(msg);
57
+ this.info = info;
58
+ this.name = "Illegal Incantation";
59
+ }
29
60
  }
30
61
  UnrecoverableError.IllegalIncantation = IllegalIncantation;
31
62
  /** An incantation's argument couldn't be parsed. */
32
63
  class InvalidArgument extends UnrecoverableError {
64
+ info;
65
+ constructor(msg, info) {
66
+ super(msg);
67
+ this.info = info;
68
+ this.name = "Invalid Argument";
69
+ }
33
70
  }
34
71
  UnrecoverableError.InvalidArgument = InvalidArgument;
35
72
  })(UnrecoverableError || (UnrecoverableError = {}));