desmost 0.8.1 → 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 +16 -2
  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 +22 -4
  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,6 +1,8 @@
1
- import { UnrecoverableError } from "../../errors";
2
1
  import { Incantation, ArgIncantation, type LOCAL } from "../incantation";
3
2
 
3
+ import { UnrecoverableError } from "../../errors";
4
+ import type { DesmostOptions } from "../../options";
5
+
4
6
 
5
7
  interface LabelOptions
6
8
  {
@@ -10,6 +12,13 @@ interface LabelOptions
10
12
  pos?: keyof typeof Desmos.LabelOrientations;
11
13
  }
12
14
 
15
+ const VALID_FIELDS = ["text", "show", "size", "pos"];
16
+
17
+ const VALID_POSITIONS = [
18
+ "ABOVE", "BELOW", "LEFT", "RIGHT",
19
+ "ABOVE_LEFT", "ABOVE_RIGHT", "BELOW_LEFT", "BELOW_RIGHT",
20
+ ];
21
+
13
22
 
14
23
  export class LabelIncantation extends ArgIncantation<LOCAL>
15
24
  {
@@ -25,36 +34,56 @@ export class LabelIncantation extends ArgIncantation<LOCAL>
25
34
  super.require_expr_type(target.type, "expression");
26
35
  target.label = data.text;
27
36
  target.showLabel = data.show ?? true;
28
- // @ts-expect-error: outdated types TODO check
37
+ // @ts-expect-error: outdated types
29
38
  if (data.size != undefined) target.labelSize = data.size;
30
39
  if (data.pos != undefined) target.labelOrientation = data.pos;
31
40
  }
32
41
 
33
- override evaluate_arg(raw: string): LabelOptions
42
+ override evaluate_arg(raw: string, options: DesmostOptions): LabelOptions
34
43
  {
35
- let out = super.evaluate_arg(raw) as LabelOptions;
44
+ let out = super.evaluate_arg(raw, options) as LabelOptions;
45
+
46
+ if (options.check_args) {
47
+ super.require_nonempty(out, `/label received empty argument`, {
48
+ hint: `You can provide [${VALID_FIELDS.join(", ")}]`,
49
+ flagged_by: "check_args",
50
+ });
36
51
 
37
- if (!("text" in out)) {
38
- throw new UnrecoverableError.InvalidArgument(
39
- `/label requires a \`text\` argument, such as: \`/label{ text: "sup world!" }\``
40
- );
52
+ if (!("text" in out)) {
53
+ throw new UnrecoverableError.MissingInput(
54
+ `/label is missing label text`,
55
+ {
56
+ hint: `Provide text for the label: \`/label{text: "sup world!"}\``,
57
+ flagged_by: "check_args",
58
+ }
59
+ );
60
+ }
61
+
62
+ super.require_known(out, VALID_FIELDS);
41
63
  }
42
64
 
43
65
  if (typeof out.pos != "undefined") {
44
- let pos = out.pos.trim().toUpperCase();
45
-
46
- switch (pos) {
47
- case "ABOVE":
48
- case "BELOW":
49
- case "LEFT":
50
- case "RIGHT":
51
- out.pos = pos;
52
- break;
53
-
54
- default:
66
+ let pos = out.pos.trim().toUpperCase().replaceAll("-", "_");
67
+
68
+ if (VALID_POSITIONS.includes(pos)) {
69
+ // @ts-expect-error: validated
70
+ out.pos = pos;
71
+ }
72
+ else {
73
+ // @ts-expect-error: indexing
74
+ let orientation = Desmos.LabelOrientations[pos];
75
+
76
+ if (options.check_args && orientation == undefined) {
55
77
  throw new UnrecoverableError.InvalidArgument(
56
- `/label: Invalid label position: ${pos}`
78
+ `/label received invalid label position: ${pos}`,
79
+ {
80
+ hint: `Valid label positions are ${VALID_POSITIONS.join(", ")}`,
81
+ flagged_by: "check_args"
82
+ }
57
83
  );
84
+ }
85
+
86
+ out.pos = orientation;
58
87
  }
59
88
  }
60
89
 
@@ -1,13 +1,18 @@
1
1
  import { Incantation, ArgIncantation, type LOCAL } from "../incantation";
2
2
 
3
+ import type { DesmostOptions } from "../../options";
4
+ import { type Unrecoverable } from "../../errors";
5
+
3
6
 
4
7
  interface LineOptions
5
8
  {
6
- style?: keyof typeof Desmos.Styles; // TODO allow raw enum
9
+ style?: keyof typeof Desmos.Styles;
7
10
  width?: number;
8
11
  opacity?: number;
9
12
  }
10
13
 
14
+ const VALID_FIELDS = ["style", "width", "opacity"];
15
+
11
16
 
12
17
  export class LineIncantation extends ArgIncantation<LOCAL>
13
18
  {
@@ -22,8 +27,20 @@ export class LineIncantation extends ArgIncantation<LOCAL>
22
27
  {
23
28
  super.require_expr_type(target.type, "expression");
24
29
 
25
- if (data.style != undefined) target.lineStyle = data.style;
26
- if (data.width != undefined) target.lineWidth = data.width;
30
+ if (data.style != undefined) target.lineStyle = data.style;
31
+ if (data.width != undefined) target.lineWidth = data.width;
27
32
  if (data.opacity != undefined) target.lineOpacity = data.opacity;
28
33
  }
34
+
35
+ override evaluate_arg(raw: string, options: DesmostOptions): Unrecoverable<LineOptions>
36
+ {
37
+ let out = super.evaluate_arg(raw, options) as LineOptions;
38
+
39
+ if (options.check_args) {
40
+ super.require_nonempty(out);
41
+ super.require_known(out, VALID_FIELDS);
42
+ }
43
+
44
+ return out;
45
+ }
29
46
  }
@@ -3,8 +3,8 @@ import { Incantation, ArgIncantation, type LOCAL } from "../incantation";
3
3
 
4
4
  interface SliderBounds
5
5
  {
6
- min?: number | string;
7
- max?: number | string;
6
+ min: number | string;
7
+ max: number | string;
8
8
  step?: number | string;
9
9
  }
10
10
 
@@ -21,7 +21,6 @@ export class SliderIncantation extends ArgIncantation<LOCAL>
21
21
  override apply(target: Desmos.ExpressionState, data: SliderBounds)
22
22
  {
23
23
  super.require_expr_type(target.type, "expression");
24
- // @ts-expect-error: outdated types
25
24
  target.sliderBounds = data;
26
25
  }
27
26
  }
@@ -1,11 +1,30 @@
1
+ import { LINE } from "./utils";
2
+ import { compile } from "./compiler/compile";
3
+
4
+
1
5
  /**
2
6
  * Options to customise Desmost compilation.
3
7
  *
4
- * To customise compilation, pass in a `DesmostOptions` object as the last argument to `compile()`:
8
+ * To customise compilation, pass in a `DesmostOptions` object as the last argument to {@linkcode compile()}:
5
9
  *
6
10
  * ```ts
7
11
  * compile(calc, source, { errors: "crash" });
8
12
  * ```
13
+ *
14
+ * ## Decompilation
15
+ *
16
+ * The same options can also be applied to decompilation:
17
+ *
18
+ * ```ts
19
+ * decompile(calc, blank, { prettify: false });
20
+ * ```
21
+ *
22
+ * Here, this means “decompile into source code that would reproduce `calc`, *when compiled with these options*”. As an identity:
23
+ *
24
+ * ```ts
25
+ * let options = { ... };
26
+ * compile(_, decompile(calc, _ options), options) == calc // (value equality)
27
+ * ```
9
28
  */
10
29
  export interface DesmostOptions
11
30
  {
@@ -19,7 +38,7 @@ export interface DesmostOptions
19
38
  *
20
39
  * - `suppress`: Silently fail on the frontend (if you wish to give the illusion that everything is fine).
21
40
  */
22
- errors?: "surface" | "crash" | "suppress"
41
+ errors: "surface" | "crash" | "suppress"
23
42
 
24
43
  /**
25
44
  * Where should errors be placed?
@@ -28,7 +47,7 @@ export interface DesmostOptions
28
47
  * - `end`: All aggregated at the end of the Desmos expressions list.
29
48
  * - `start`: All aggregated at the start of the Desmos expressions list.
30
49
  */
31
- place_errors?: "inline" | "end" | "start"
50
+ place_errors: "inline" | "end" | "start"
32
51
 
33
52
  /**
34
53
  * The prefix to prepend to error blocks.
@@ -37,42 +56,69 @@ export interface DesmostOptions
37
56
  *
38
57
  * Provide a `""` blank string if you wish for no prefix to be added.
39
58
  */
40
- error_prefix?: string
59
+ error_prefix: string
60
+
61
+ /**
62
+ * Show all the available diagnostics for errors, including hints and debug information?
63
+ *
64
+ * Defaults to `true`, meaning all output is shown.
65
+ */
66
+ expand_errors: boolean
67
+
68
+ /**
69
+ * Error if an incantation receives a `{}` object argument with unknown fields?
70
+ *
71
+ * This also errors if an incantation receives an empty `{}` object.
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.
74
+ *
75
+ * 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
+ *
77
+ * Defaults to `true`, meaning arguments are checked.
78
+ */
79
+ check_args: boolean
41
80
 
42
81
  /**
43
82
  * Prettify LaTeX output so it renders nicely in the Desmos editor?
44
83
  *
45
84
  * Defaults to `true`, meaning LaTeX is prettified.
46
85
  */
47
- prettify?: boolean
86
+ prettify: boolean
87
+
88
+ /**
89
+ * Strip common indentation from `/text{}` blocks?
90
+ *
91
+ * Defaults to `true`, meaning text is dedented.
92
+ */
93
+ dedent_text: boolean
48
94
 
49
95
  /**
50
96
  * Should `%` LaTeX comments be ignored, instead of turned into text expressions (notes)?
51
97
  *
52
98
  * Defaults to `false`, meaning comments are kept.
53
99
  */
54
- ignore_comments?: boolean
100
+ ignore_comments: boolean
55
101
 
56
102
  /**
57
103
  * Should all line breaks be ignored, instead of kept as blank expressions?
58
104
  *
59
105
  * Defaults to `false`, meaning all blank lines are kept.
60
106
  */
61
- ignore_all_blanks?: boolean
107
+ ignore_all_blanks: boolean
62
108
 
63
109
  /**
64
110
  * Should trailing blank lines at the start of the source be kept as blank expressions?
65
111
  *
66
112
  * Defaults to `false`, meaning leading blank lines are ignored.
67
113
  */
68
- keep_leading_blanks?: boolean
114
+ keep_leading_blanks: boolean
69
115
 
70
116
  /**
71
117
  * Should trailing blank lines at the end of the source be kept as blank expressions?
72
118
  *
73
119
  * Defaults to `false`, meaning trailing blank lines are ignored.
74
120
  */
75
- keep_trailing_blanks?: boolean
121
+ keep_trailing_blanks: boolean
76
122
 
77
123
  /**
78
124
  * Return debug diagnostics?
@@ -81,16 +127,19 @@ export interface DesmostOptions
81
127
  *
82
128
  * Defaults to `false`, meaning `compile()` returns `void`.
83
129
  */
84
- debug?: boolean
130
+ debug: boolean
85
131
  }
86
132
 
87
133
 
88
- export const DEFAULT_OPTIONS =
134
+ export const DEFAULT_OPTIONS: DesmostOptions =
89
135
  {
90
136
  errors: "surface",
91
137
  place_errors: "inline",
92
- error_prefix: "[DESMOST ERROR]\n",
138
+ error_prefix: `[DESMOST ERROR]\n${LINE}\n`,
139
+ expand_errors: true,
93
140
  prettify: true,
141
+ dedent_text: true,
142
+ check_args: false,
94
143
  ignore_comments: false,
95
144
  ignore_all_blanks: false,
96
145
  keep_leading_blanks: false,
@@ -102,10 +151,10 @@ export const DEFAULT_OPTIONS =
102
151
  /**
103
152
  * Fill in `options` with Desmost's defaults to produce a complete `DesmostOptions` config.
104
153
  */
105
- export function fill_defaults(options: Partial<DesmostOptions> | undefined): Required<DesmostOptions>
154
+ export function fill_defaults(options: Partial<DesmostOptions> | undefined): DesmostOptions
106
155
  {
107
156
  return {
108
157
  ...DEFAULT_OPTIONS,
109
158
  ...options,
110
- } as Required<DesmostOptions>;
159
+ };
111
160
  }
@@ -1,7 +1,7 @@
1
1
  import { GenericParser } from "./generic-parser";
2
2
  import { Ast } from "./ast";
3
3
 
4
- import type { DesmostOptions } from "../compiler";
4
+ import type { DesmostOptions } from "../options";
5
5
  import { NO_MATCH, UnrecoverableError } from "../errors";
6
6
  import type { NoMatch, Unrecoverable } from "../errors";
7
7
  import * as utils from "../utils";
@@ -468,20 +468,26 @@ export class DesmostParser extends GenericParser
468
468
  }
469
469
 
470
470
  /* NOTE: Cut in by 1 on both sides to exclude {} braces */
471
- let out = utils.chars(this.source, init + 1, this.i - 1);
471
+ let raw = utils.chars(this.source, init + 1, this.i - 1);
472
472
 
473
473
  for (let [i, j] of utils.reversing(utils.paired(indices_to_insert_quotes))) {
474
474
  i -= init + 1;
475
475
  j -= init + 1;
476
476
 
477
- let value = out.slice(i, j).join("");
477
+ let value = raw.slice(i, j).join("");
478
478
  if (["true", "false", "null", "undefined"].includes(value)) continue;
479
479
 
480
- out.splice(j, 0, `"`);
481
- out.splice(i, 0, `"`);
480
+ raw.splice(j, 0, `"`);
481
+ raw.splice(i, 0, `"`);
482
482
  }
483
483
 
484
- return out.join("").trim();
484
+ let out = raw.join("");
485
+
486
+ if (arg_type !== Incantation.ArgType.STRING) {
487
+ out = out.trim();
488
+ }
489
+
490
+ return out;
485
491
  }
486
492
  }
487
493
 
@@ -48,14 +48,6 @@ export class GenericParser
48
48
  return this.source.at(this.i);
49
49
  }
50
50
 
51
- /**
52
- * Get the character *after* the current one that the parser points at.
53
- */
54
- protected next(): string | undefined
55
- {
56
- return this.source.at(this.i + 1);
57
- }
58
-
59
51
  /**
60
52
  * Peek a snippet of the upcoming source text.
61
53
  *
@@ -64,7 +56,11 @@ export class GenericParser
64
56
  public preview(idx?: number): string
65
57
  {
66
58
  idx ??= this.i;
67
- return this.source.slice(idx, idx + 20) + "...";
59
+
60
+ return (
61
+ this.source.slice(idx, idx + 20).replaceAll("\n", " ")
62
+ + (idx + 20 >= this.length ? "⏎" : "...")
63
+ );
68
64
  }
69
65
 
70
66
  /**
@@ -140,7 +136,7 @@ export class GenericParser
140
136
 
141
137
  while (this.current === raw[ii]) {
142
138
  let r = this.try_advance();
143
- if (r === NO_MATCH) return NO_MATCH;
139
+ if (r === NO_MATCH) return NO_MATCH; // FIXME?
144
140
 
145
141
  ii++;
146
142
  if (ii === raw.length) return;
@@ -167,14 +163,18 @@ export class GenericParser
167
163
  /**
168
164
  * Consume 0 or more whitespace characters.
169
165
  *
170
- * Same as `.consume_spaces()`, but allows newlines.
166
+ * Same as `.consume_spaces()`, but allows tabs and newlines.
171
167
  */
172
168
  protected consume_whitespace(): void
173
169
  {
174
170
  /* NOTE: Callers should be able to assume this is safe to call even when at end of input, since it should just match 0 characters */
175
171
  if (this.i >= this.length) return;
176
172
 
177
- while (this.current === " " || this.current === "\n") {
173
+ while (
174
+ this.current === " "
175
+ || this.current === "\n"
176
+ || this.current === "\t"
177
+ ) {
178
178
  this.advance();
179
179
  }
180
180
  }
@@ -11,6 +11,8 @@ The parser is split into `DesmostParser` and `GenericParser`.
11
11
 
12
12
  The parser is stateful, tracking its current position in the source text with its `.i` field.
13
13
 
14
+ `parse_next()` is the only method consumers need to be aware of, the rest is implementation detail. Would love to make them `private`, unfortunately we need them public for unit testing ;)
15
+
14
16
 
15
17
  ## Backtracking
16
18
 
package/src/utils.ts CHANGED
@@ -1,3 +1,6 @@
1
+ export const LINE = '—'.repeat(10);
2
+
3
+
1
4
  export function* reversing<T>(items: ArrayLike<T>): Generator<T>
2
5
  {
3
6
  for (let i = items.length - 1; i >= 0; i--) {
@@ -141,9 +141,11 @@ onMount(() =>
141
141
  inject(el_desmos, source.textContent);
142
142
  }
143
143
  else {
144
- let observer = new IntersectionObserver(() => {
145
- inject(el_desmos, source.textContent);
146
- observer.disconnect();
144
+ let observer = new IntersectionObserver(([entry]) => {
145
+ if (entry.isIntersecting) {
146
+ inject(el_desmos, source.textContent);
147
+ observer.disconnect();
148
+ }
147
149
  });
148
150
  observer.observe(el_desmos);
149
151
  lazy_observers.push(observer);
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,WAAW,cAAc;IAE9B;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,UAAU,CAAA;IAEzC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAAA;IAEzC;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAE7B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAE9B;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;CACf;AAGD,eAAO,MAAM,eAAe;;;;;;;;;;CAW3B,CAAC;AAGF;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAMpG"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["../../src/compiler/options.ts"],"names":[],"mappings":"AAuFA,MAAM,CAAC,MAAM,eAAe,GAC5B;IACG,MAAM,EAAE,SAAS;IACjB,YAAY,EAAE,QAAQ;IACtB,YAAY,EAAE,mBAAmB;IACjC,QAAQ,EAAE,IAAI;IACd,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;KACgB,CAAC;AACjC,CAAC"}