desmost 0.10.1 → 0.11.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 (164) hide show
  1. package/README.md +5 -5
  2. package/dist/compiler/compile.d.ts +1 -1
  3. package/dist/compiler/compile.js +1 -1
  4. package/dist/compiler/compiler.d.ts.map +1 -1
  5. package/dist/compiler/compiler.js +9 -8
  6. package/dist/compiler/compiler.js.map +1 -1
  7. package/dist/compiler/format.js +1 -1
  8. package/dist/compiler/format.js.map +1 -1
  9. package/dist/decompiler/decompile.d.ts +13 -5
  10. package/dist/decompiler/decompile.d.ts.map +1 -1
  11. package/dist/decompiler/decompile.js +24 -13
  12. package/dist/decompiler/decompile.js.map +1 -1
  13. package/dist/decompiler/emit.d.ts +5 -2
  14. package/dist/decompiler/emit.d.ts.map +1 -1
  15. package/dist/decompiler/emit.js +41 -20
  16. package/dist/decompiler/emit.js.map +1 -1
  17. package/dist/decompiler/extract.d.ts +1 -9
  18. package/dist/decompiler/extract.d.ts.map +1 -1
  19. package/dist/decompiler/extract.js +24 -58
  20. package/dist/decompiler/extract.js.map +1 -1
  21. package/dist/decompiler/format.d.ts +0 -1
  22. package/dist/decompiler/format.d.ts.map +1 -1
  23. package/dist/decompiler/format.js +3 -9
  24. package/dist/decompiler/format.js.map +1 -1
  25. package/dist/errors.d.ts +14 -7
  26. package/dist/errors.d.ts.map +1 -1
  27. package/dist/errors.js +20 -2
  28. package/dist/errors.js.map +1 -1
  29. package/dist/magic/expr/index.js +6 -6
  30. package/dist/magic/expr/index.js.map +1 -1
  31. package/dist/magic/expr/latex.d.ts +5 -2
  32. package/dist/magic/expr/latex.d.ts.map +1 -1
  33. package/dist/magic/expr/latex.js +4 -2
  34. package/dist/magic/expr/latex.js.map +1 -1
  35. package/dist/magic/expr/text.d.ts +5 -2
  36. package/dist/magic/expr/text.d.ts.map +1 -1
  37. package/dist/magic/expr/text.js +4 -2
  38. package/dist/magic/expr/text.js.map +1 -1
  39. package/dist/magic/global/{dark-mode.d.ts → dark.d.ts} +6 -2
  40. package/dist/magic/global/dark.d.ts.map +1 -0
  41. package/dist/magic/global/dark.js +20 -0
  42. package/dist/magic/global/dark.js.map +1 -0
  43. package/dist/magic/global/desmos.d.ts +4 -1
  44. package/dist/magic/global/desmos.d.ts.map +1 -1
  45. package/dist/magic/global/desmos.js +23 -0
  46. package/dist/magic/global/desmos.js.map +1 -1
  47. package/dist/magic/global/index.d.ts +5 -5
  48. package/dist/magic/global/index.d.ts.map +1 -1
  49. package/dist/magic/global/index.js +8 -11
  50. package/dist/magic/global/index.js.map +1 -1
  51. package/dist/magic/global/viewport.d.ts +3 -0
  52. package/dist/magic/global/viewport.d.ts.map +1 -1
  53. package/dist/magic/global/viewport.js +20 -0
  54. package/dist/magic/global/viewport.js.map +1 -1
  55. package/dist/magic/incantation.d.ts +15 -2
  56. package/dist/magic/incantation.d.ts.map +1 -1
  57. package/dist/magic/incantation.js +8 -1
  58. package/dist/magic/incantation.js.map +1 -1
  59. package/dist/magic/local/anim.d.ts +5 -1
  60. package/dist/magic/local/anim.d.ts.map +1 -1
  61. package/dist/magic/local/anim.js +12 -1
  62. package/dist/magic/local/anim.js.map +1 -1
  63. package/dist/magic/local/colour.d.ts +7 -3
  64. package/dist/magic/local/colour.d.ts.map +1 -1
  65. package/dist/magic/local/colour.js +13 -3
  66. package/dist/magic/local/colour.js.map +1 -1
  67. package/dist/magic/local/dashed.d.ts +5 -1
  68. package/dist/magic/local/dashed.d.ts.map +1 -1
  69. package/dist/magic/local/dashed.js +12 -1
  70. package/dist/magic/local/dashed.js.map +1 -1
  71. package/dist/magic/local/fill.d.ts +5 -1
  72. package/dist/magic/local/fill.d.ts.map +1 -1
  73. package/dist/magic/local/fill.js +15 -1
  74. package/dist/magic/local/fill.js.map +1 -1
  75. package/dist/magic/local/hide.d.ts +5 -1
  76. package/dist/magic/local/hide.d.ts.map +1 -1
  77. package/dist/magic/local/hide.js +12 -1
  78. package/dist/magic/local/hide.js.map +1 -1
  79. package/dist/magic/local/index.d.ts +13 -2
  80. package/dist/magic/local/index.d.ts.map +1 -1
  81. package/dist/magic/local/index.js +24 -24
  82. package/dist/magic/local/index.js.map +1 -1
  83. package/dist/magic/local/label.d.ts +6 -2
  84. package/dist/magic/local/label.d.ts.map +1 -1
  85. package/dist/magic/local/label.js +19 -1
  86. package/dist/magic/local/label.js.map +1 -1
  87. package/dist/magic/local/line.d.ts +5 -1
  88. package/dist/magic/local/line.d.ts.map +1 -1
  89. package/dist/magic/local/line.js +19 -1
  90. package/dist/magic/local/line.js.map +1 -1
  91. package/dist/magic/local/no-line.d.ts +5 -1
  92. package/dist/magic/local/no-line.d.ts.map +1 -1
  93. package/dist/magic/local/no-line.js +12 -1
  94. package/dist/magic/local/no-line.js.map +1 -1
  95. package/dist/magic/local/point.d.ts +5 -1
  96. package/dist/magic/local/point.d.ts.map +1 -1
  97. package/dist/magic/local/point.js +19 -1
  98. package/dist/magic/local/point.js.map +1 -1
  99. package/dist/magic/local/secret.d.ts +5 -1
  100. package/dist/magic/local/secret.d.ts.map +1 -1
  101. package/dist/magic/local/secret.js +12 -1
  102. package/dist/magic/local/secret.js.map +1 -1
  103. package/dist/magic/local/slider.d.ts +5 -1
  104. package/dist/magic/local/slider.d.ts.map +1 -1
  105. package/dist/magic/local/slider.js +13 -1
  106. package/dist/magic/local/slider.js.map +1 -1
  107. package/dist/parser/ast.d.ts +9 -3
  108. package/dist/parser/ast.d.ts.map +1 -1
  109. package/dist/parser/ast.js +3 -1
  110. package/dist/parser/ast.js.map +1 -1
  111. package/dist/parser/desmost-parser.d.ts +2 -2
  112. package/dist/parser/desmost-parser.d.ts.map +1 -1
  113. package/dist/parser/desmost-parser.js +6 -4
  114. package/dist/parser/desmost-parser.js.map +1 -1
  115. package/dist/parser/errors.d.ts +11 -0
  116. package/dist/parser/errors.d.ts.map +1 -0
  117. package/dist/parser/errors.js +4 -0
  118. package/dist/parser/errors.js.map +1 -0
  119. package/dist/parser/generic-parser.d.ts +7 -5
  120. package/dist/parser/generic-parser.d.ts.map +1 -1
  121. package/dist/parser/generic-parser.js +7 -10
  122. package/dist/parser/generic-parser.js.map +1 -1
  123. package/package.json +1 -1
  124. package/src/compiler/compile.ts +1 -1
  125. package/src/compiler/compiler.ts +10 -9
  126. package/src/compiler/format.ts +1 -1
  127. package/src/decompiler/decompile.ts +30 -14
  128. package/src/decompiler/emit.ts +57 -25
  129. package/src/decompiler/extract.ts +30 -89
  130. package/src/decompiler/format.ts +3 -14
  131. package/src/decompiler/readme.md +2 -2
  132. package/src/errors.ts +13 -7
  133. package/src/magic/.template.ts +8 -0
  134. package/src/magic/expr/index.ts +6 -7
  135. package/src/magic/expr/latex.ts +8 -4
  136. package/src/magic/expr/text.ts +8 -4
  137. package/src/magic/global/dark.ts +29 -0
  138. package/src/magic/global/desmos.ts +35 -5
  139. package/src/magic/global/index.ts +8 -14
  140. package/src/magic/global/viewport.ts +29 -0
  141. package/src/magic/incantation.ts +28 -6
  142. package/src/magic/local/anim.ts +16 -3
  143. package/src/magic/local/colour.ts +18 -6
  144. package/src/magic/local/dashed.ts +16 -2
  145. package/src/magic/local/fill.ts +20 -3
  146. package/src/magic/local/hide.ts +16 -2
  147. package/src/magic/local/index.ts +24 -25
  148. package/src/magic/local/label.ts +31 -8
  149. package/src/magic/local/line.ts +25 -3
  150. package/src/magic/local/no-line.ts +16 -2
  151. package/src/magic/local/point.ts +27 -3
  152. package/src/magic/local/secret.ts +16 -2
  153. package/src/magic/local/slider.ts +18 -3
  154. package/src/parser/ast.ts +10 -7
  155. package/src/parser/desmost-parser.ts +10 -6
  156. package/src/parser/errors.ts +10 -0
  157. package/src/parser/generic-parser.ts +9 -11
  158. package/svelte/desmost.svelte +107 -107
  159. package/dist/magic/expr/index.d.ts +0 -3
  160. package/dist/magic/expr/index.d.ts.map +0 -1
  161. package/dist/magic/global/dark-mode.d.ts.map +0 -1
  162. package/dist/magic/global/dark-mode.js +0 -9
  163. package/dist/magic/global/dark-mode.js.map +0 -1
  164. package/src/magic/global/dark-mode.ts +0 -15
@@ -12,11 +12,11 @@ When this component is unmounted, it calls `.destroy()` on each calculator insta
12
12
 
13
13
  ```svelte
14
14
  <script>
15
- import Content from "./content.md";
15
+ import Content from "./content.md";
16
16
  </script>
17
17
 
18
18
  <Desmost>
19
- <Content />
19
+ <Content />
20
20
  </Desmost>
21
21
  ```
22
22
 
@@ -24,7 +24,7 @@ With compile options:
24
24
 
25
25
  ```svelte
26
26
  <Desmost options={{ errors: "crash" }}>
27
- <Content />
27
+ <Content />
28
28
  </Desmost>
29
29
  ```
30
30
 
@@ -32,7 +32,7 @@ With styling:
32
32
 
33
33
  ```svelte
34
34
  <Desmost width="100%" height="50vh">
35
- <Content />
35
+ <Content />
36
36
  </Desmost>
37
37
  ```
38
38
  -->
@@ -47,72 +47,72 @@ import { onMount, type Snippet } from "svelte";
47
47
 
48
48
  interface Props
49
49
  {
50
- children: Snippet;
51
-
52
- /** Compile options to pass to Desmost.*/
53
- options?: DesmostOptions;
54
-
55
- /**
56
- * Default settings to apply to all Desmos calculator instances.
57
- *
58
- * These are applied *before* compilation, so individual Desmost blocks can override them with `/desmos`.
59
- */
60
- settings?: Desmos.GraphConfiguration & Desmos.GraphSettings;
61
-
62
- /**
63
- * Should compilation be lazy using `IntersectionObserver`?
64
- *
65
- * ## Example
66
- *
67
- * ```svelte
68
- * <Desmost lazy />
69
- * ```
70
- */
71
- lazy?: true;
72
-
73
- /**
74
- * CSS styles to apply to each Desmos calculator's containing element.
75
- *
76
- * ## Example
77
- *
78
- * ```svelte
79
- * <Desmost style="margin: 1rem; border: 1px solid red" />
80
- * ```
81
- */
82
- style?: string;
83
-
84
- /**
85
- * Width of each Desmos calculator's containing element.
86
- *
87
- * ## Example
88
- *
89
- * ```svelte
90
- * <Desmost width="500px" />
91
- * <Desmost width="40rem" />
92
- * <Desmost width="80vw" />
93
- * ```
94
- */
95
- width?: string;
96
-
97
- /**
98
- * Height of each Desmos calculator's containing element.
99
- *
100
- * ## Example
101
- *
102
- * ```svelte
103
- * <Desmost height="500px" />
104
- * <Desmost height="40rem" />
105
- * <Desmost height="80vw" />
106
- * ```
107
- */
108
- height?: string;
50
+ children: Snippet;
51
+
52
+ /** Compile options to pass to Desmost.*/
53
+ options?: DesmostOptions;
54
+
55
+ /**
56
+ * Default settings to apply to all Desmos calculator instances.
57
+ *
58
+ * These are applied *before* compilation, so individual Desmost blocks can override them with `/desmos`.
59
+ */
60
+ settings?: Desmos.GraphConfiguration & Desmos.GraphSettings;
61
+
62
+ /**
63
+ * Should compilation be lazy using `IntersectionObserver`?
64
+ *
65
+ * ## Example
66
+ *
67
+ * ```svelte
68
+ * <Desmost lazy />
69
+ * ```
70
+ */
71
+ lazy?: true;
72
+
73
+ /**
74
+ * CSS styles to apply to each Desmos calculator's containing element.
75
+ *
76
+ * ## Example
77
+ *
78
+ * ```svelte
79
+ * <Desmost style="margin: 1rem; border: 1px solid red" />
80
+ * ```
81
+ */
82
+ style?: string;
83
+
84
+ /**
85
+ * Width of each Desmos calculator's containing element.
86
+ *
87
+ * ## Example
88
+ *
89
+ * ```svelte
90
+ * <Desmost width="500px" />
91
+ * <Desmost width="40rem" />
92
+ * <Desmost width="80vw" />
93
+ * ```
94
+ */
95
+ width?: string;
96
+
97
+ /**
98
+ * Height of each Desmos calculator's containing element.
99
+ *
100
+ * ## Example
101
+ *
102
+ * ```svelte
103
+ * <Desmost height="500px" />
104
+ * <Desmost height="40rem" />
105
+ * <Desmost height="80vw" />
106
+ * ```
107
+ */
108
+ height?: string;
109
109
  }
110
110
 
111
111
  let {
112
- children,
113
- options, settings,
114
- lazy,
115
- style, width, height,
112
+ children,
113
+ options, settings,
114
+ lazy,
115
+ style, width, height,
116
116
  }: Props = $props();
117
117
 
118
118
 
@@ -123,56 +123,56 @@ let lazy_observers: IntersectionObserver[] = [];
123
123
 
124
124
  onMount(() =>
125
125
  {
126
- let sources = root.querySelectorAll("pre[lang='desmos'], pre.language-desmos");
127
-
128
- for (let source of sources.values()) {
129
- source.style.display = "none";
130
-
131
- let el_desmos = source.parentNode!.insertBefore(
132
- document.createElement("div"),
133
- source.nextSibling,
134
- );
135
-
136
- if (width != undefined) el_desmos.style.width = width;
137
- if (height != undefined) el_desmos.style.height = height;
138
- if (style != undefined) el_desmos.style.cssText += style;
139
-
140
- if (!lazy) {
141
- inject(el_desmos, source.textContent);
142
- }
143
- else {
144
- let observer = new IntersectionObserver(([entry]) => {
145
- if (entry.isIntersecting) {
146
- inject(el_desmos, source.textContent);
147
- observer.disconnect();
148
- }
149
- });
150
- observer.observe(el_desmos);
151
- lazy_observers.push(observer);
152
- }
153
- }
154
-
155
- return () => {
156
- desmos_instances.forEach(d => d.destroy());
157
- lazy_observers.forEach(o => o.disconnect());
158
- };
126
+ let sources = root.querySelectorAll("pre[lang='desmos'], pre.language-desmos");
127
+
128
+ for (let source of sources.values()) {
129
+ source.style.display = "none";
130
+
131
+ let el_desmos = source.parentNode!.insertBefore(
132
+ document.createElement("div"),
133
+ source.nextSibling,
134
+ );
135
+
136
+ if (width != undefined) el_desmos.style.width = width;
137
+ if (height != undefined) el_desmos.style.height = height;
138
+ if (style != undefined) el_desmos.style.cssText += style;
139
+
140
+ if (!lazy) {
141
+ inject(el_desmos, source.textContent);
142
+ }
143
+ else {
144
+ let observer = new IntersectionObserver(([entry]) => {
145
+ if (entry.isIntersecting) {
146
+ inject(el_desmos, source.textContent);
147
+ observer.disconnect();
148
+ }
149
+ });
150
+ observer.observe(el_desmos);
151
+ lazy_observers.push(observer);
152
+ }
153
+ }
154
+
155
+ return () => {
156
+ desmos_instances.forEach(d => d.destroy());
157
+ lazy_observers.forEach(o => o.disconnect());
158
+ };
159
159
  });
160
160
 
161
161
  function inject(el_desmos: HTMLElement, source: string)
162
162
  {
163
- let desmos = Desmos.GraphingCalculator(el_desmos);
163
+ let desmos = Desmos.GraphingCalculator(el_desmos);
164
164
 
165
- if (settings != undefined) {
166
- desmos.updateSettings(settings);
167
- }
165
+ if (settings != undefined) {
166
+ desmos.updateSettings(settings);
167
+ }
168
168
 
169
- desmos_instances.push(desmos);
170
- compile(desmos, source, options);
169
+ desmos_instances.push(desmos);
170
+ compile(desmos, source, options);
171
171
  }
172
172
 
173
173
  </script>
174
174
 
175
175
 
176
176
  <div bind:this={root} style:display="contents">
177
- {@render children?.()}
177
+ {@render children?.()}
178
178
  </div>
@@ -1,3 +0,0 @@
1
- import { ArgIncantation, type EXPR } from "../incantation.js";
2
- export declare const EXPR_INCANTATIONS: ArgIncantation<EXPR>[];
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/magic/expr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAM3D,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,IAAI,CAAC,EAInD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dark-mode.d.ts","sourceRoot":"","sources":["../../../src/magic/global/dark-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1D,qBAAa,mBAAoB,SAAQ,WAAW,CAAC,MAAM,CAAC;IAE3D,SAAkB,WAAW,qEACuC;IAEpE,SAAkB,UAAU,UAAS;IAErC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU;CAI/B"}
@@ -1,9 +0,0 @@
1
- import { Incantation } from "../incantation.js";
2
- export class DarkModeIncantation extends Incantation {
3
- description = "Enable dark mode for the calculator, which inverts all colours.";
4
- identifier = "dark";
5
- apply(target) {
6
- target.updateSettings({ invertedColors: true });
7
- }
8
- }
9
- //# sourceMappingURL=dark-mode.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dark-mode.js","sourceRoot":"","sources":["../../../src/magic/global/dark-mode.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAG1D,MAAM,OAAO,mBAAoB,SAAQ,WAAmB;IAEzC,WAAW,GAC1B,iEAAiE,CAAA;IAElD,UAAU,GAAG,MAAM,CAAA;IAErC,KAAK,CAAC,MAAyB;QAE9B,MAAM,CAAC,cAAc,CAAC,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;CACD"}
@@ -1,15 +0,0 @@
1
- import { Incantation, type GLOBAL } from "../incantation";
2
-
3
-
4
- export class DarkModeIncantation extends Incantation<GLOBAL>
5
- {
6
- override readonly description
7
- = "Enable dark mode for the calculator, which inverts all colours."
8
-
9
- override readonly identifier = "dark"
10
-
11
- apply(target: Desmos.Calculator)
12
- {
13
- target.updateSettings({ invertedColors: true });
14
- }
15
- }