desmost 0.1.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 (281) hide show
  1. package/dist/compiler/compile.d.ts +32 -0
  2. package/dist/compiler/compile.d.ts.map +1 -0
  3. package/dist/compiler/compile.js +101 -0
  4. package/dist/compiler/compile.js.map +1 -0
  5. package/dist/compiler/evaluate.d.ts +18 -0
  6. package/dist/compiler/evaluate.d.ts.map +1 -0
  7. package/dist/compiler/evaluate.js +83 -0
  8. package/dist/compiler/evaluate.js.map +1 -0
  9. package/dist/compiler/index.d.ts +3 -0
  10. package/dist/compiler/index.d.ts.map +1 -0
  11. package/dist/compiler/index.js +2 -0
  12. package/dist/compiler/index.js.map +1 -0
  13. package/dist/compiler/options.d.ts +54 -0
  14. package/dist/compiler/options.d.ts.map +1 -0
  15. package/dist/compiler/options.js +15 -0
  16. package/dist/compiler/options.js.map +1 -0
  17. package/dist/desmos.d.ts +12 -0
  18. package/dist/desmos.d.ts.map +1 -0
  19. package/dist/desmos.js +13 -0
  20. package/dist/desmos.js.map +1 -0
  21. package/dist/errors.d.ts +45 -0
  22. package/dist/errors.d.ts.map +1 -0
  23. package/dist/errors.js +38 -0
  24. package/dist/errors.js.map +1 -0
  25. package/dist/index.d.ts +2 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +2 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/magic/expr/index.d.ts +3 -0
  30. package/dist/magic/expr/index.d.ts.map +1 -0
  31. package/dist/magic/expr/index.js +8 -0
  32. package/dist/magic/expr/index.js.map +1 -0
  33. package/dist/magic/expr/latex.d.ts +10 -0
  34. package/dist/magic/expr/latex.d.ts.map +1 -0
  35. package/dist/magic/expr/latex.js +16 -0
  36. package/dist/magic/expr/latex.js.map +1 -0
  37. package/dist/magic/expr/text.d.ts +9 -0
  38. package/dist/magic/expr/text.d.ts.map +1 -0
  39. package/dist/magic/expr/text.js +13 -0
  40. package/dist/magic/expr/text.js.map +1 -0
  41. package/dist/magic/global/dark-mode.d.ts +7 -0
  42. package/dist/magic/global/dark-mode.d.ts.map +1 -0
  43. package/dist/magic/global/dark-mode.js +11 -0
  44. package/dist/magic/global/dark-mode.js.map +1 -0
  45. package/dist/magic/global/desmos.d.ts +9 -0
  46. package/dist/magic/global/desmos.d.ts.map +1 -0
  47. package/dist/magic/global/desmos.js +11 -0
  48. package/dist/magic/global/desmos.js.map +1 -0
  49. package/dist/magic/global/index.d.ts +3 -0
  50. package/dist/magic/global/index.d.ts.map +1 -0
  51. package/dist/magic/global/index.js +10 -0
  52. package/dist/magic/global/index.js.map +1 -0
  53. package/dist/magic/global/viewport.d.ts +16 -0
  54. package/dist/magic/global/viewport.d.ts.map +1 -0
  55. package/dist/magic/global/viewport.js +12 -0
  56. package/dist/magic/global/viewport.js.map +1 -0
  57. package/dist/magic/incantation.d.ts +74 -0
  58. package/dist/magic/incantation.d.ts.map +1 -0
  59. package/dist/magic/incantation.js +81 -0
  60. package/dist/magic/incantation.js.map +1 -0
  61. package/dist/magic/index.d.ts +6 -0
  62. package/dist/magic/index.d.ts.map +1 -0
  63. package/dist/magic/index.js +5 -0
  64. package/dist/magic/index.js.map +1 -0
  65. package/dist/magic/local/anim.d.ts +7 -0
  66. package/dist/magic/local/anim.d.ts.map +1 -0
  67. package/dist/magic/local/anim.js +11 -0
  68. package/dist/magic/local/anim.js.map +1 -0
  69. package/dist/magic/local/colour.d.ts +12 -0
  70. package/dist/magic/local/colour.d.ts.map +1 -0
  71. package/dist/magic/local/colour.js +27 -0
  72. package/dist/magic/local/colour.js.map +1 -0
  73. package/dist/magic/local/dashed.d.ts +7 -0
  74. package/dist/magic/local/dashed.d.ts.map +1 -0
  75. package/dist/magic/local/dashed.js +10 -0
  76. package/dist/magic/local/dashed.js.map +1 -0
  77. package/dist/magic/local/fill.d.ts +13 -0
  78. package/dist/magic/local/fill.d.ts.map +1 -0
  79. package/dist/magic/local/fill.js +12 -0
  80. package/dist/magic/local/fill.js.map +1 -0
  81. package/dist/magic/local/hide.d.ts +7 -0
  82. package/dist/magic/local/hide.d.ts.map +1 -0
  83. package/dist/magic/local/hide.js +10 -0
  84. package/dist/magic/local/hide.js.map +1 -0
  85. package/dist/magic/local/index.d.ts +3 -0
  86. package/dist/magic/local/index.d.ts.map +1 -0
  87. package/dist/magic/local/index.js +24 -0
  88. package/dist/magic/local/index.js.map +1 -0
  89. package/dist/magic/local/line.d.ts +15 -0
  90. package/dist/magic/local/line.d.ts.map +1 -0
  91. package/dist/magic/local/line.js +17 -0
  92. package/dist/magic/local/line.js.map +1 -0
  93. package/dist/magic/local/no-line.d.ts +7 -0
  94. package/dist/magic/local/no-line.d.ts.map +1 -0
  95. package/dist/magic/local/no-line.js +10 -0
  96. package/dist/magic/local/no-line.js.map +1 -0
  97. package/dist/magic/local/point.d.ts +15 -0
  98. package/dist/magic/local/point.d.ts.map +1 -0
  99. package/dist/magic/local/point.js +17 -0
  100. package/dist/magic/local/point.js.map +1 -0
  101. package/dist/magic/local/secret.d.ts +7 -0
  102. package/dist/magic/local/secret.d.ts.map +1 -0
  103. package/dist/magic/local/secret.js +10 -0
  104. package/dist/magic/local/secret.js.map +1 -0
  105. package/dist/magic/local/slider.d.ts +15 -0
  106. package/dist/magic/local/slider.d.ts.map +1 -0
  107. package/dist/magic/local/slider.js +13 -0
  108. package/dist/magic/local/slider.js.map +1 -0
  109. package/dist/parser/ast.d.ts +40 -0
  110. package/dist/parser/ast.d.ts.map +1 -0
  111. package/dist/parser/ast.js +13 -0
  112. package/dist/parser/ast.js.map +1 -0
  113. package/dist/parser/desmost-parser.d.ts +105 -0
  114. package/dist/parser/desmost-parser.d.ts.map +1 -0
  115. package/dist/parser/desmost-parser.js +379 -0
  116. package/dist/parser/desmost-parser.js.map +1 -0
  117. package/dist/parser/generic-parser.d.ts +62 -0
  118. package/dist/parser/generic-parser.d.ts.map +1 -0
  119. package/dist/parser/generic-parser.js +143 -0
  120. package/dist/parser/generic-parser.js.map +1 -0
  121. package/dist/parser/index.d.ts +8 -0
  122. package/dist/parser/index.d.ts.map +1 -0
  123. package/dist/parser/index.js +8 -0
  124. package/dist/parser/index.js.map +1 -0
  125. package/dist/src/compiler/compile.d.ts +32 -0
  126. package/dist/src/compiler/compile.d.ts.map +1 -0
  127. package/dist/src/compiler/compile.js +101 -0
  128. package/dist/src/compiler/compile.js.map +1 -0
  129. package/dist/src/compiler/evaluate.d.ts +18 -0
  130. package/dist/src/compiler/evaluate.d.ts.map +1 -0
  131. package/dist/src/compiler/evaluate.js +83 -0
  132. package/dist/src/compiler/evaluate.js.map +1 -0
  133. package/dist/src/compiler/index.d.ts +3 -0
  134. package/dist/src/compiler/index.d.ts.map +1 -0
  135. package/dist/src/compiler/index.js +2 -0
  136. package/dist/src/compiler/index.js.map +1 -0
  137. package/dist/src/compiler/options.d.ts +54 -0
  138. package/dist/src/compiler/options.d.ts.map +1 -0
  139. package/dist/src/compiler/options.js +15 -0
  140. package/dist/src/compiler/options.js.map +1 -0
  141. package/dist/src/desmos.d.ts +12 -0
  142. package/dist/src/desmos.d.ts.map +1 -0
  143. package/dist/src/desmos.js +13 -0
  144. package/dist/src/desmos.js.map +1 -0
  145. package/dist/src/errors.d.ts +45 -0
  146. package/dist/src/errors.d.ts.map +1 -0
  147. package/dist/src/errors.js +38 -0
  148. package/dist/src/errors.js.map +1 -0
  149. package/dist/src/index.d.ts +2 -0
  150. package/dist/src/index.d.ts.map +1 -0
  151. package/dist/src/index.js +2 -0
  152. package/dist/src/index.js.map +1 -0
  153. package/dist/src/magic/expr/index.d.ts +3 -0
  154. package/dist/src/magic/expr/index.d.ts.map +1 -0
  155. package/dist/src/magic/expr/index.js +8 -0
  156. package/dist/src/magic/expr/index.js.map +1 -0
  157. package/dist/src/magic/expr/latex.d.ts +10 -0
  158. package/dist/src/magic/expr/latex.d.ts.map +1 -0
  159. package/dist/src/magic/expr/latex.js +16 -0
  160. package/dist/src/magic/expr/latex.js.map +1 -0
  161. package/dist/src/magic/expr/text.d.ts +9 -0
  162. package/dist/src/magic/expr/text.d.ts.map +1 -0
  163. package/dist/src/magic/expr/text.js +13 -0
  164. package/dist/src/magic/expr/text.js.map +1 -0
  165. package/dist/src/magic/global/dark-mode.d.ts +7 -0
  166. package/dist/src/magic/global/dark-mode.d.ts.map +1 -0
  167. package/dist/src/magic/global/dark-mode.js +11 -0
  168. package/dist/src/magic/global/dark-mode.js.map +1 -0
  169. package/dist/src/magic/global/desmos.d.ts +9 -0
  170. package/dist/src/magic/global/desmos.d.ts.map +1 -0
  171. package/dist/src/magic/global/desmos.js +11 -0
  172. package/dist/src/magic/global/desmos.js.map +1 -0
  173. package/dist/src/magic/global/index.d.ts +3 -0
  174. package/dist/src/magic/global/index.d.ts.map +1 -0
  175. package/dist/src/magic/global/index.js +10 -0
  176. package/dist/src/magic/global/index.js.map +1 -0
  177. package/dist/src/magic/global/viewport.d.ts +16 -0
  178. package/dist/src/magic/global/viewport.d.ts.map +1 -0
  179. package/dist/src/magic/global/viewport.js +12 -0
  180. package/dist/src/magic/global/viewport.js.map +1 -0
  181. package/dist/src/magic/incantation.d.ts +74 -0
  182. package/dist/src/magic/incantation.d.ts.map +1 -0
  183. package/dist/src/magic/incantation.js +81 -0
  184. package/dist/src/magic/incantation.js.map +1 -0
  185. package/dist/src/magic/index.d.ts +6 -0
  186. package/dist/src/magic/index.d.ts.map +1 -0
  187. package/dist/src/magic/index.js +5 -0
  188. package/dist/src/magic/index.js.map +1 -0
  189. package/dist/src/magic/local/anim.d.ts +7 -0
  190. package/dist/src/magic/local/anim.d.ts.map +1 -0
  191. package/dist/src/magic/local/anim.js +11 -0
  192. package/dist/src/magic/local/anim.js.map +1 -0
  193. package/dist/src/magic/local/colour.d.ts +12 -0
  194. package/dist/src/magic/local/colour.d.ts.map +1 -0
  195. package/dist/src/magic/local/colour.js +27 -0
  196. package/dist/src/magic/local/colour.js.map +1 -0
  197. package/dist/src/magic/local/dashed.d.ts +7 -0
  198. package/dist/src/magic/local/dashed.d.ts.map +1 -0
  199. package/dist/src/magic/local/dashed.js +10 -0
  200. package/dist/src/magic/local/dashed.js.map +1 -0
  201. package/dist/src/magic/local/fill.d.ts +13 -0
  202. package/dist/src/magic/local/fill.d.ts.map +1 -0
  203. package/dist/src/magic/local/fill.js +12 -0
  204. package/dist/src/magic/local/fill.js.map +1 -0
  205. package/dist/src/magic/local/hide.d.ts +7 -0
  206. package/dist/src/magic/local/hide.d.ts.map +1 -0
  207. package/dist/src/magic/local/hide.js +10 -0
  208. package/dist/src/magic/local/hide.js.map +1 -0
  209. package/dist/src/magic/local/index.d.ts +3 -0
  210. package/dist/src/magic/local/index.d.ts.map +1 -0
  211. package/dist/src/magic/local/index.js +24 -0
  212. package/dist/src/magic/local/index.js.map +1 -0
  213. package/dist/src/magic/local/line.d.ts +15 -0
  214. package/dist/src/magic/local/line.d.ts.map +1 -0
  215. package/dist/src/magic/local/line.js +17 -0
  216. package/dist/src/magic/local/line.js.map +1 -0
  217. package/dist/src/magic/local/no-line.d.ts +7 -0
  218. package/dist/src/magic/local/no-line.d.ts.map +1 -0
  219. package/dist/src/magic/local/no-line.js +10 -0
  220. package/dist/src/magic/local/no-line.js.map +1 -0
  221. package/dist/src/magic/local/point.d.ts +15 -0
  222. package/dist/src/magic/local/point.d.ts.map +1 -0
  223. package/dist/src/magic/local/point.js +17 -0
  224. package/dist/src/magic/local/point.js.map +1 -0
  225. package/dist/src/magic/local/secret.d.ts +7 -0
  226. package/dist/src/magic/local/secret.d.ts.map +1 -0
  227. package/dist/src/magic/local/secret.js +10 -0
  228. package/dist/src/magic/local/secret.js.map +1 -0
  229. package/dist/src/magic/local/slider.d.ts +15 -0
  230. package/dist/src/magic/local/slider.d.ts.map +1 -0
  231. package/dist/src/magic/local/slider.js +13 -0
  232. package/dist/src/magic/local/slider.js.map +1 -0
  233. package/dist/src/parser/ast.d.ts +40 -0
  234. package/dist/src/parser/ast.d.ts.map +1 -0
  235. package/dist/src/parser/ast.js +13 -0
  236. package/dist/src/parser/ast.js.map +1 -0
  237. package/dist/src/parser/desmost-parser.d.ts +105 -0
  238. package/dist/src/parser/desmost-parser.d.ts.map +1 -0
  239. package/dist/src/parser/desmost-parser.js +379 -0
  240. package/dist/src/parser/desmost-parser.js.map +1 -0
  241. package/dist/src/parser/generic-parser.d.ts +62 -0
  242. package/dist/src/parser/generic-parser.d.ts.map +1 -0
  243. package/dist/src/parser/generic-parser.js +143 -0
  244. package/dist/src/parser/generic-parser.js.map +1 -0
  245. package/dist/src/parser/index.d.ts +8 -0
  246. package/dist/src/parser/index.d.ts.map +1 -0
  247. package/dist/src/parser/index.js +8 -0
  248. package/dist/src/parser/index.js.map +1 -0
  249. package/package.json +58 -0
  250. package/src/compiler/compile.ts +127 -0
  251. package/src/compiler/evaluate.ts +121 -0
  252. package/src/compiler/index.ts +2 -0
  253. package/src/compiler/options.ts +77 -0
  254. package/src/desmos.ts +13 -0
  255. package/src/errors.ts +46 -0
  256. package/src/index.ts +1 -0
  257. package/src/magic/.template.ts +22 -0
  258. package/src/magic/expr/index.ts +11 -0
  259. package/src/magic/expr/latex.ts +24 -0
  260. package/src/magic/expr/text.ts +19 -0
  261. package/src/magic/global/dark-mode.ts +17 -0
  262. package/src/magic/global/desmos.ts +20 -0
  263. package/src/magic/global/index.ts +13 -0
  264. package/src/magic/global/viewport.ts +25 -0
  265. package/src/magic/incantation.ts +142 -0
  266. package/src/magic/index.ts +6 -0
  267. package/src/magic/local/anim.ts +17 -0
  268. package/src/magic/local/colour.ts +38 -0
  269. package/src/magic/local/dashed.ts +16 -0
  270. package/src/magic/local/fill.ts +24 -0
  271. package/src/magic/local/hide.ts +16 -0
  272. package/src/magic/local/index.ts +27 -0
  273. package/src/magic/local/line.ts +29 -0
  274. package/src/magic/local/no-line.ts +16 -0
  275. package/src/magic/local/point.ts +29 -0
  276. package/src/magic/local/secret.ts +16 -0
  277. package/src/magic/local/slider.ts +27 -0
  278. package/src/parser/ast.ts +60 -0
  279. package/src/parser/desmost-parser.ts +486 -0
  280. package/src/parser/generic-parser.ts +191 -0
  281. package/src/parser/index.ts +8 -0
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The compiler encountered a fatal unrecoverable error, which will reach the end user.
3
+ *
4
+ * 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.
5
+ */
6
+ export declare class UnrecoverableError extends Error {
7
+ }
8
+ export declare namespace UnrecoverableError {
9
+ /** The parser unexpectedly reached the end of its entire input source code. */
10
+ class UnexpectedEnd extends UnrecoverableError {
11
+ }
12
+ /** The parser did not receive input that it expected. */
13
+ class MissingInput extends UnrecoverableError {
14
+ }
15
+ /** The parser received input that did not match what it expected. */
16
+ class UnexpectedInput extends UnrecoverableError {
17
+ }
18
+ /** The parser received excess input that it did not expect. */
19
+ class ExcessInput extends UnrecoverableError {
20
+ }
21
+ /** An incantation can't be applied here. */
22
+ class IllegalIncantation extends UnrecoverableError {
23
+ }
24
+ /** An incantation's argument couldn't be parsed. */
25
+ class InvalidArgument extends UnrecoverableError {
26
+ }
27
+ }
28
+ /** The compiler encountered a non-fatal recoverable failure (usually during speculative parsing), which only results in internal backtracking. */
29
+ export declare class RecoverableFail {
30
+ }
31
+ /** Indicates that a function may throw a `RecoverableFail`. */
32
+ export type Recoverable<Result> = Result | (Result & {
33
+ readonly __brand?: unique symbol;
34
+ });
35
+ /** Indicates that a function may throw an `UnrecoverableError`. */
36
+ export type Unrecoverable<Result> = Result | (Result & {
37
+ readonly __brand?: unique symbol;
38
+ });
39
+ /**
40
+ * Indicates that a function may throw either a `RecoverableFail` *or* an `UnrecoverableError`.
41
+ *
42
+ * This is used in potentially ambiguous cases. For instance, the user might have invoked an unknown incantation, in which case we might want to `RecoverableFail` and fallback to parsing it as LaTeX; on the other hand, if they invoked a valid incantation, but did not supply the required argument, that's a definite `UnrecoverableError`.
43
+ */
44
+ export type MaybeRecoverable<Result> = Recoverable<Result> | Unrecoverable<Result>;
45
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,yBAAiB,kBAAkB,CACnC;IACE,+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;CAC3D;AAGD,kJAAkJ;AAClJ,qBAAa,eAAe;CAAG;AAG/B,+DAA+D;AAC/D,MAAM,MAAM,WAAW,CAAC,MAAM,IAAI,MAAM,IAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA,CAAC;AAEzF,mEAAmE;AACnE,MAAM,MAAM,aAAa,CAAC,MAAM,IAAI,MAAM,IAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA,CAAC;AAE3F;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The compiler encountered a fatal unrecoverable error, which will reach the end user.
3
+ *
4
+ * 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.
5
+ */
6
+ export class UnrecoverableError extends Error {
7
+ }
8
+ (function (UnrecoverableError) {
9
+ /** The parser unexpectedly reached the end of its entire input source code. */
10
+ class UnexpectedEnd extends UnrecoverableError {
11
+ }
12
+ UnrecoverableError.UnexpectedEnd = UnexpectedEnd;
13
+ /** The parser did not receive input that it expected. */
14
+ class MissingInput extends UnrecoverableError {
15
+ }
16
+ UnrecoverableError.MissingInput = MissingInput;
17
+ /** The parser received input that did not match what it expected. */
18
+ class UnexpectedInput extends UnrecoverableError {
19
+ }
20
+ UnrecoverableError.UnexpectedInput = UnexpectedInput;
21
+ /** The parser received excess input that it did not expect. */
22
+ class ExcessInput extends UnrecoverableError {
23
+ }
24
+ UnrecoverableError.ExcessInput = ExcessInput;
25
+ /** An incantation can't be applied here. */
26
+ class IllegalIncantation extends UnrecoverableError {
27
+ }
28
+ UnrecoverableError.IllegalIncantation = IllegalIncantation;
29
+ /** An incantation's argument couldn't be parsed. */
30
+ class InvalidArgument extends UnrecoverableError {
31
+ }
32
+ UnrecoverableError.InvalidArgument = InvalidArgument;
33
+ })(UnrecoverableError || (UnrecoverableError = {}));
34
+ /** The compiler encountered a non-fatal recoverable failure (usually during speculative parsing), which only results in internal backtracking. */
35
+ export class RecoverableFail {
36
+ }
37
+ ;
38
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,WAAiB,kBAAkB;IAEjC,+EAA+E;IAC/E,MAAa,aAAc,SAAQ,kBAAkB;KAAG;IAA3C,mBAAA,aAAa,gBAA8B,CAAA;IAExD,yDAAyD;IACzD,MAAa,YAAa,SAAQ,kBAAkB;KAAG;IAA1C,mBAAA,YAAY,eAA8B,CAAA;IAEvD,qEAAqE;IACrE,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,mBAAA,eAAe,kBAA8B,CAAA;IAE1D,+DAA+D;IAC/D,MAAa,WAAY,SAAQ,kBAAkB;KAAG;IAAzC,mBAAA,WAAW,cAA8B,CAAA;IAGtD,4CAA4C;IAC5C,MAAa,kBAAmB,SAAQ,kBAAkB;KAAG;IAAhD,mBAAA,kBAAkB,qBAA8B,CAAA;IAE7D,oDAAoD;IACpD,MAAa,eAAgB,SAAQ,kBAAkB;KAAG;IAA7C,mBAAA,eAAe,kBAA8B,CAAA;AAC5D,CAAC,EApBgB,kBAAkB,KAAlB,kBAAkB,QAoBlC;AAGD,kJAAkJ;AAClJ,MAAM,OAAO,eAAe;CAAG;AAO4D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { compile, type DesmostOptions } from "./compiler";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { compile } from "./compiler";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { ArgIncantation, type EXPR } from "../incantation";
2
+ export declare const EXPR_INCANTATIONS: ArgIncantation<EXPR>[];
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,8 @@
1
+ import { ArgIncantation } from "../incantation";
2
+ import { LatexIncantation } from "./latex";
3
+ import { TextIncantation } from "./text";
4
+ export const EXPR_INCANTATIONS = [
5
+ new LatexIncantation(),
6
+ new TextIncantation(),
7
+ ];
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/magic/expr/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAGzC,MAAM,CAAC,MAAM,iBAAiB,GAC9B;IACE,IAAI,gBAAgB,EAAE;IACtB,IAAI,eAAe,EAAE;CACtB,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Incantation, ArgIncantation, type EXPR } from "../incantation";
2
+ export declare class LatexIncantation extends ArgIncantation<EXPR> {
3
+ readonly description = "Produce a LaTeX expression. This allows the input to span multiple lines.";
4
+ readonly identifier = "latex";
5
+ readonly requires_arg = true;
6
+ readonly arg_type = Incantation.ArgType.LATEX;
7
+ apply(target: Desmos.ExpressionState, data: string): void;
8
+ evaluate_arg(data: string): string;
9
+ }
10
+ //# sourceMappingURL=latex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latex.d.ts","sourceRoot":"","sources":["../../../../src/magic/expr/latex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGxE,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,IAAI,CAAC;IAExD,SAAkB,WAAW,+EACkD;IAE/E,SAAkB,UAAU,WAAY;IACxC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,6BAAgC;IAE1D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAKxD;IAEQ,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG1C;CACF"}
@@ -0,0 +1,16 @@
1
+ import { Incantation, ArgIncantation } from "../incantation";
2
+ export class LatexIncantation extends ArgIncantation {
3
+ description = "Produce a LaTeX expression. This allows the input to span multiple lines.";
4
+ identifier = "latex";
5
+ requires_arg = true;
6
+ arg_type = Incantation.ArgType.LATEX;
7
+ apply(target, data) {
8
+ target.type = "expression";
9
+ // @ts-expect-error: outdated types
10
+ target.latex = data;
11
+ }
12
+ evaluate_arg(data) {
13
+ return data;
14
+ }
15
+ }
16
+ //# sourceMappingURL=latex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latex.js","sourceRoot":"","sources":["../../../../src/magic/expr/latex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,gBAAiB,SAAQ,cAAoB;IAEtC,WAAW,GACzB,2EAA2E,CAAA;IAE7D,UAAU,GAAK,OAAO,CAAA;IACtB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,KAAK,CAAA;IAE1D,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEhD,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC;QAC3B,mCAAmC;QACnC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAEQ,YAAY,CAAC,IAAY;QAEhC,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import { Incantation, ArgIncantation, type EXPR } from "../incantation";
2
+ export declare class TextIncantation extends ArgIncantation<EXPR> {
3
+ readonly description = "Produce a text expression (\u201CAdd Note\u201D in the Desmos GUI).";
4
+ readonly identifier = "text";
5
+ readonly requires_arg = true;
6
+ readonly arg_type = Incantation.ArgType.STRING;
7
+ apply(target: Desmos.ExpressionState, data: string): void;
8
+ }
9
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAGxE,qBAAa,eAAgB,SAAQ,cAAc,CAAC,IAAI,CAAC;IAEvD,SAAkB,WAAW,yEACkC;IAE/D,SAAkB,UAAU,UAAW;IACvC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,QAK1D;CACF"}
@@ -0,0 +1,13 @@
1
+ import { Incantation, ArgIncantation } from "../incantation";
2
+ export class TextIncantation extends ArgIncantation {
3
+ description = "Produce a text expression (“Add Note” in the Desmos GUI).";
4
+ identifier = "text";
5
+ requires_arg = true;
6
+ arg_type = Incantation.ArgType.STRING;
7
+ apply(target, data) {
8
+ target.type = "text";
9
+ // @ts-expect-error: outdated types
10
+ target.text = data;
11
+ }
12
+ }
13
+ //# sourceMappingURL=text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../../../src/magic/expr/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAa,MAAM,gBAAgB,CAAC;AAGxE,MAAM,OAAO,eAAgB,SAAQ,cAAoB;IAErC,WAAW,GACzB,2DAA2D,CAAA;IAE7C,UAAU,GAAK,MAAM,CAAA;IACrB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CAAC,MAA8B,EAAE,IAAY;QAEzD,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;QACrB,mCAAmC;QACnC,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import { Incantation, type GLOBAL } from "../incantation";
2
+ export declare class DarkModeIncantation extends Incantation<GLOBAL> {
3
+ readonly description = "Enable dark mode for the calculator, which inverts all colours.";
4
+ readonly identifier = "dark";
5
+ apply(target: Desmos.Calculator): void;
6
+ }
7
+ //# sourceMappingURL=dark-mode.d.ts.map
@@ -0,0 +1 @@
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;IAE1D,SAAkB,WAAW,qEACwC;IAErE,SAAkB,UAAU,UAAS;IAErC,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,QAK9B;CACF"}
@@ -0,0 +1,11 @@
1
+ import { Incantation } from "../incantation";
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({
7
+ invertedColors: true,
8
+ });
9
+ }
10
+ }
11
+ //# sourceMappingURL=dark-mode.js.map
@@ -0,0 +1 @@
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;IAExC,WAAW,GACzB,iEAAiE,CAAA;IAEnD,UAAU,GAAG,MAAM,CAAA;IAErC,KAAK,CAAC,MAAyB;QAE7B,MAAM,CAAC,cAAc,CAAC;YACpB,cAAc,EAAE,IAAI;SACrB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import { Incantation, ArgIncantation, type GLOBAL } from "../incantation";
2
+ export declare class DesmosIncantation extends ArgIncantation<GLOBAL> {
3
+ readonly description = "Set the configuration of the calculator via `Calculator.updateSettings()`.";
4
+ readonly identifier = "desmos";
5
+ readonly requires_arg = false;
6
+ readonly arg_type = Incantation.ArgType.OBJECT;
7
+ apply(target: Desmos.Calculator, data: Desmos.GraphConfiguration & Desmos.GraphSettings): void;
8
+ }
9
+ //# sourceMappingURL=desmos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"desmos.d.ts","sourceRoot":"","sources":["../../../../src/magic/global/desmos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1E,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAE3D,SAAkB,WAAW,gFACmD;IAEhF,SAAkB,UAAU,YAAa;IACzC,SAAkB,YAAY,SAAQ;IACtC,SAAkB,QAAQ,8BAAiC;IAElD,KAAK,CACZ,MAAM,EAAE,MAAM,CAAC,UAAU,EACzB,IAAI,EAAE,MAAM,CAAC,kBAAkB,GAAG,MAAM,CAAC,aAAa,GACrD,IAAI,CAGN;CACF"}
@@ -0,0 +1,11 @@
1
+ import { Incantation, ArgIncantation } from "../incantation";
2
+ export class DesmosIncantation extends ArgIncantation {
3
+ description = "Set the configuration of the calculator via `Calculator.updateSettings()`.";
4
+ identifier = "desmos";
5
+ requires_arg = false;
6
+ arg_type = Incantation.ArgType.OBJECT;
7
+ apply(target, data) {
8
+ target.updateSettings(data);
9
+ }
10
+ }
11
+ //# sourceMappingURL=desmos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"desmos.js","sourceRoot":"","sources":["../../../../src/magic/global/desmos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAG1E,MAAM,OAAO,iBAAkB,SAAQ,cAAsB;IAEzC,WAAW,GACzB,4EAA4E,CAAA;IAE9D,UAAU,GAAK,QAAQ,CAAA;IACvB,YAAY,GAAG,KAAK,CAAA;IACpB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAElD,KAAK,CACZ,MAAyB,EACzB,IAAsD;QAGtD,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ import { Incantation, type GLOBAL } from "../incantation";
2
+ export declare const GLOBAL_INCANTATIONS: Incantation<GLOBAL>[];
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/magic/global/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAO1D,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,CAAC,EAKpD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { Incantation } from "../incantation";
2
+ import { DesmosIncantation } from "./desmos";
3
+ import { ViewportIncantation } from "./viewport";
4
+ import { DarkModeIncantation } from "./dark-mode";
5
+ export const GLOBAL_INCANTATIONS = [
6
+ new DesmosIncantation(),
7
+ new ViewportIncantation(),
8
+ new DarkModeIncantation(),
9
+ ];
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/magic/global/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAGlD,MAAM,CAAC,MAAM,mBAAmB,GAChC;IACE,IAAI,iBAAiB,EAAE;IACvB,IAAI,mBAAmB,EAAE;IACzB,IAAI,mBAAmB,EAAE;CAC1B,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { Incantation, ArgIncantation, type GLOBAL } from "../incantation";
2
+ interface ViewportBounds {
3
+ left: number;
4
+ right: number;
5
+ bottom: number;
6
+ top: number;
7
+ }
8
+ export declare class ViewportIncantation extends ArgIncantation<GLOBAL> {
9
+ readonly description = "Set the bounds of the viewport via `Calculator.setMathBounds()`.";
10
+ readonly identifier = "viewport";
11
+ readonly requires_arg = true;
12
+ readonly arg_type = Incantation.ArgType.OBJECT;
13
+ apply(target: Desmos.Calculator, data: ViewportBounds): void;
14
+ }
15
+ export {};
16
+ //# sourceMappingURL=viewport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport.d.ts","sourceRoot":"","sources":["../../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAG1E,UAAU,cAAc;IAEtB,IAAI,EAAI,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAI,MAAM,CAAC;CAC/B;AAGD,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,MAAM,CAAC;IAE7D,SAAkB,WAAW,sEACyC;IAEtE,SAAkB,UAAU,cAAe;IAC3C,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,8BAAiC;IAE3D,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,EAAE,cAAc,QAIpD;CACF"}
@@ -0,0 +1,12 @@
1
+ import { Incantation, ArgIncantation } from "../incantation";
2
+ export class ViewportIncantation extends ArgIncantation {
3
+ description = "Set the bounds of the viewport via `Calculator.setMathBounds()`.";
4
+ identifier = "viewport";
5
+ requires_arg = true;
6
+ arg_type = Incantation.ArgType.OBJECT;
7
+ apply(target, data) {
8
+ // TODO validate bounds
9
+ target.setMathBounds(data);
10
+ }
11
+ }
12
+ //# sourceMappingURL=viewport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewport.js","sourceRoot":"","sources":["../../../../src/magic/global/viewport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAe,MAAM,gBAAgB,CAAC;AAU1E,MAAM,OAAO,mBAAoB,SAAQ,cAAsB;IAE3C,WAAW,GACzB,kEAAkE,CAAA;IAEpD,UAAU,GAAK,UAAU,CAAA;IACzB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,MAAM,CAAA;IAE3D,KAAK,CAAC,MAAyB,EAAE,IAAoB;QAEnD,uBAAuB;QACvB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF"}
@@ -0,0 +1,74 @@
1
+ import { type Unrecoverable } from "../errors";
2
+ /**
3
+ * An *Incantation* is like a slash command that tells Desmost to do something - like changing the properties of an expression, or applying some settings to the calculator as a whole.
4
+ *
5
+ * Incantations must be prefixed by a `/`. They look like this:
6
+ *
7
+ * ```math
8
+ * /viewport{ left: -1, right: 1 }
9
+ * /hidden :: x = 69
10
+ * /text :: Never gonna give you up
11
+ * ```
12
+ *
13
+ * Incantations that accept an argument derive from `ArgIncantation`.
14
+ */
15
+ export declare abstract class Incantation<Effect extends Incantation.Effect = Incantation.Effect> {
16
+ /** Short user-facing description of what the incantation does. */
17
+ abstract readonly description: string;
18
+ /** The raw text sequence that matches this incantation, such as `viewport` or `hidden`. */
19
+ abstract readonly identifier: string;
20
+ /** An alternative `.identifier`, strictly for localisation purposes only. */
21
+ readonly alias?: string;
22
+ /** Apply this incantation's effect to `target`, using the provided `data` if required. */
23
+ abstract apply(target: Effect extends GLOBAL ? Desmos.Calculator : Desmos.ExpressionState, data?: unknown): void;
24
+ /** Error if the `actual` type of the given expression is not `required`. */
25
+ protected require_expr_type<T extends Desmos.ExpressionState["type"]>(actual: unknown, required: T): asserts actual is T;
26
+ }
27
+ /**
28
+ * An incantation that accepts an argument.
29
+ */
30
+ export declare abstract class ArgIncantation<Effect extends Incantation.Effect = Incantation.Effect> extends Incantation<Effect> {
31
+ /** Does this incantation always require an argument to be passed? */
32
+ readonly requires_arg: boolean;
33
+ /** What type of argument does this incantation accept? */
34
+ abstract readonly arg_type: Incantation.ArgType;
35
+ /**
36
+ * Evaluate the argument provided to this incantation, throwing if an error is encountered.
37
+ *
38
+ * For instance, for `/viewport{ left: -1, right: 1 }`, this returns the POJO `{ left: -1, right: 1 }`.
39
+ *
40
+ * ## Notes
41
+ *
42
+ * Child incantation classes should override this method, though the defaults should cover most cases (except `ArgType.ENUM`).
43
+ */
44
+ evaluate_arg(raw: string): Unrecoverable<unknown>;
45
+ }
46
+ export declare namespace Incantation {
47
+ /** The kind of effect an incantation produces - it either modifies only one block, or modifies the calculator as a whole. */
48
+ enum Effect {
49
+ /** An incantation that affects the entire Desmos calculator state, like `/desmos` or `/viewport`. */
50
+ GLOBAL = 0,
51
+ /** An incantation that affects only the expression immediately following it, like `/hide` or `/slider`. */
52
+ LOCAL = 1,
53
+ /** An incantation that produces an expression, like `/latex` or `/text`. */
54
+ EXPR = 2
55
+ }
56
+ /** The type of argument an incantation accepts, which affects how it is parsed. */
57
+ enum ArgType {
58
+ /** Any arbitrary user text content, where characters like `"` and `'` don't have semantic meaning and can be ignored. */
59
+ STRING = "String",
60
+ /** LaTeX, which should have balanced `{}` braces. */
61
+ LATEX = "LaTeX",
62
+ /** Specific value from an allowed set of values, which will map to an enum value in the Desmos API. */
63
+ ENUM = "Enum",
64
+ /** JavaScript object fields, where characters like `{}` and `"` all have semantic meaning, and must be balanced. */
65
+ OBJECT = "Object"
66
+ }
67
+ }
68
+ /** An incantation that affects the entire Desmos calculator state, like `/desmos` or `/viewport`. */
69
+ export type GLOBAL = Incantation.Effect.GLOBAL;
70
+ /** An incantation that affects only the expression immediately following it, like `/hide` or `/slider`. */
71
+ export type LOCAL = Incantation.Effect.LOCAL;
72
+ /** An incantation that produces an expression, like `/latex` or `/text`. */
73
+ export type EXPR = Incantation.Effect.EXPR;
74
+ //# sourceMappingURL=incantation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incantation.d.ts","sourceRoot":"","sources":["../../../src/magic/incantation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,WAAW,CAAC;AAGnE;;;;;;;;;;;;GAYG;AACH,8BAAsB,WAAW,CAC/B,MAAM,SAAS,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM;IAGtD,kEAAkE;IAClE,kBAAyB,WAAW,EAAE,MAAM,CAAA;IAE5C,2FAA2F;IAC3F,kBAAyB,UAAU,EAAE,MAAM,CAAA;IAE3C,6EAA6E;IAC7E,SAAgB,KAAK,CAAC,EAAE,MAAM,CAAA;IAG9B,0FAA0F;IAC1F,SAAgB,KAAK,CACnB,MAAM,EAAE,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC,eAAe,EAC1E,IAAI,CAAC,EAAE,OAAO,GACb,IAAI,CAAA;IAEP,4EAA4E;IAC5E,SAAS,CAAC,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,EAClE,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,CAAC,GACV,OAAO,CAAC,MAAM,IAAI,CAAC,CAQrB;CACF;AAGD;;GAEG;AACH,8BAAsB,cAAc,CAClC,MAAM,SAAS,WAAW,CAAC,MAAM,GAAG,WAAW,CAAC,MAAM,CAEtD,SAAQ,WAAW,CAAC,MAAM,CAAC;IAE3B,qEAAqE;IACrE,SAAgB,YAAY,EAAE,OAAO,CAAO;IAE5C,0DAA0D;IAC1D,kBAAyB,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAA;IAGtD;;;;;;;;OAQG;IACI,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAgBvD;CACF;AAGD,yBAAiB,WAAW,CAC5B;IACE,6HAA6H;IAC7H,KAAY,MAAM;QAEhB,qGAAqG;QACrG,MAAM,IAAA;QAEN,2GAA2G;QAC3G,KAAK,IAAA;QAEL,4EAA4E;QAC5E,IAAI,IAAA;KACL;IAED,mFAAmF;IACnF,KAAY,OAAO;QAEjB,yHAAyH;QACzH,MAAM,WAAW;QAEjB,qDAAqD;QACrD,KAAK,UAAU;QAEf,uGAAuG;QACvG,IAAI,SAAS;QAEb,oHAAoH;QACpH,MAAM,WAAW;KAClB;CACF;AAKD,qGAAqG;AACrG,MAAM,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;AAE/C,2GAA2G;AAC3G,MAAM,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC"}
@@ -0,0 +1,81 @@
1
+ import Json5 from "json5";
2
+ import { UnrecoverableError } from "../errors";
3
+ /**
4
+ * An *Incantation* is like a slash command that tells Desmost to do something - like changing the properties of an expression, or applying some settings to the calculator as a whole.
5
+ *
6
+ * Incantations must be prefixed by a `/`. They look like this:
7
+ *
8
+ * ```math
9
+ * /viewport{ left: -1, right: 1 }
10
+ * /hidden :: x = 69
11
+ * /text :: Never gonna give you up
12
+ * ```
13
+ *
14
+ * Incantations that accept an argument derive from `ArgIncantation`.
15
+ */
16
+ export class Incantation {
17
+ /** An alternative `.identifier`, strictly for localisation purposes only. */
18
+ alias;
19
+ /** Error if the `actual` type of the given expression is not `required`. */
20
+ require_expr_type(actual, required) {
21
+ if ((actual ?? "expression") !== required) {
22
+ throw new UnrecoverableError.IllegalIncantation(`/${this.identifier} can only applied to ${required === "expression" ? "latex" : required} expressions, but target block has type: ${actual}`);
23
+ }
24
+ }
25
+ }
26
+ /**
27
+ * An incantation that accepts an argument.
28
+ */
29
+ export class ArgIncantation extends Incantation {
30
+ /** Does this incantation always require an argument to be passed? */
31
+ requires_arg = true;
32
+ /**
33
+ * Evaluate the argument provided to this incantation, throwing if an error is encountered.
34
+ *
35
+ * For instance, for `/viewport{ left: -1, right: 1 }`, this returns the POJO `{ left: -1, right: 1 }`.
36
+ *
37
+ * ## Notes
38
+ *
39
+ * Child incantation classes should override this method, though the defaults should cover most cases (except `ArgType.ENUM`).
40
+ */
41
+ evaluate_arg(raw) {
42
+ switch (this.arg_type) {
43
+ case Incantation.ArgType.STRING: return raw;
44
+ case Incantation.ArgType.LATEX: return raw;
45
+ case Incantation.ArgType.ENUM: return raw;
46
+ case Incantation.ArgType.OBJECT:
47
+ try {
48
+ return Json5.parse(`{${raw}}`);
49
+ }
50
+ catch (e) {
51
+ // @ts-expect-error: fine
52
+ throw new UnrecoverableError.InvalidArgument(e.message);
53
+ }
54
+ }
55
+ }
56
+ }
57
+ (function (Incantation) {
58
+ /** The kind of effect an incantation produces - it either modifies only one block, or modifies the calculator as a whole. */
59
+ let Effect;
60
+ (function (Effect) {
61
+ /** An incantation that affects the entire Desmos calculator state, like `/desmos` or `/viewport`. */
62
+ Effect[Effect["GLOBAL"] = 0] = "GLOBAL";
63
+ /** An incantation that affects only the expression immediately following it, like `/hide` or `/slider`. */
64
+ Effect[Effect["LOCAL"] = 1] = "LOCAL";
65
+ /** An incantation that produces an expression, like `/latex` or `/text`. */
66
+ Effect[Effect["EXPR"] = 2] = "EXPR";
67
+ })(Effect = Incantation.Effect || (Incantation.Effect = {}));
68
+ /** The type of argument an incantation accepts, which affects how it is parsed. */
69
+ let ArgType;
70
+ (function (ArgType) {
71
+ /** Any arbitrary user text content, where characters like `"` and `'` don't have semantic meaning and can be ignored. */
72
+ ArgType["STRING"] = "String";
73
+ /** LaTeX, which should have balanced `{}` braces. */
74
+ ArgType["LATEX"] = "LaTeX";
75
+ /** Specific value from an allowed set of values, which will map to an enum value in the Desmos API. */
76
+ ArgType["ENUM"] = "Enum";
77
+ /** JavaScript object fields, where characters like `{}` and `"` all have semantic meaning, and must be balanced. */
78
+ ArgType["OBJECT"] = "Object";
79
+ })(ArgType = Incantation.ArgType || (Incantation.ArgType = {}));
80
+ })(Incantation || (Incantation = {}));
81
+ //# sourceMappingURL=incantation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incantation.js","sourceRoot":"","sources":["../../../src/magic/incantation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,kBAAkB,EAAsB,MAAM,WAAW,CAAC;AAGnE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAgB,WAAW;IAU/B,6EAA6E;IAC7D,KAAK,CAAS;IAS9B,4EAA4E;IAClE,iBAAiB,CACzB,MAAe,EACf,QAAW;QAGX,IAAI,CAAC,MAAM,IAAI,YAAY,CAAC,KAAK,QAAQ,EACzC,CAAC;YACC,MAAM,IAAI,kBAAkB,CAAC,kBAAkB,CAC7C,IAAI,IAAI,CAAC,UAAU,wBAAwB,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,4CAA4C,MAAM,EAAE,CAC9I,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAGD;;GAEG;AACH,MAAM,OAAgB,cAGpB,SAAQ,WAAmB;IAE3B,qEAAqE;IACrD,YAAY,GAAY,IAAI,CAAA;IAM5C;;;;;;;;OAQG;IACI,YAAY,CAAC,GAAW;QAE7B,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;YACtB,KAAK,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,GAAG,CAAC;YAC5C,KAAK,WAAW,CAAC,OAAO,CAAC,KAAK,EAAG,OAAO,GAAG,CAAC;YAC5C,KAAK,WAAW,CAAC,OAAO,CAAC,IAAI,EAAI,OAAO,GAAG,CAAC;YAE5C,KAAK,WAAW,CAAC,OAAO,CAAC,MAAM;gBAC7B,IAAI,CAAC;oBACH,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;gBACjC,CAAC;gBACD,OAAO,CAAC,EAAE,CAAC;oBACT,yBAAyB;oBACzB,MAAM,IAAI,kBAAkB,CAAC,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;gBAC1D,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAGD,WAAiB,WAAW;IAE1B,6HAA6H;IAC7H,IAAY,MAUX;IAVD,WAAY,MAAM;QAEhB,qGAAqG;QACrG,uCAAM,CAAA;QAEN,2GAA2G;QAC3G,qCAAK,CAAA;QAEL,4EAA4E;QAC5E,mCAAI,CAAA;IACN,CAAC,EAVW,MAAM,GAAN,YAAA,MAAM,KAAN,YAAA,MAAM,QAUjB;IAED,mFAAmF;IACnF,IAAY,OAaX;IAbD,WAAY,OAAO;QAEjB,yHAAyH;QACzH,4BAAiB,CAAA;QAEjB,qDAAqD;QACrD,0BAAe,CAAA;QAEf,uGAAuG;QACvG,wBAAa,CAAA;QAEb,oHAAoH;QACpH,4BAAiB,CAAA;IACnB,CAAC,EAbW,OAAO,GAAP,YAAA,OAAO,KAAP,YAAA,OAAO,QAalB;AACH,CAAC,EA9BgB,WAAW,KAAX,WAAW,QA8B3B"}
@@ -0,0 +1,6 @@
1
+ export { Incantation, ArgIncantation } from "./incantation";
2
+ export type { GLOBAL, LOCAL, EXPR } from "./incantation";
3
+ export { GLOBAL_INCANTATIONS } from "./global";
4
+ export { LOCAL_INCANTATIONS } from "./local";
5
+ export { EXPR_INCANTATIONS } from "./expr";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/magic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAEzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { Incantation, ArgIncantation } from "./incantation";
2
+ export { GLOBAL_INCANTATIONS } from "./global";
3
+ export { LOCAL_INCANTATIONS } from "./local";
4
+ export { EXPR_INCANTATIONS } from "./expr";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/magic/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { Incantation, type LOCAL } from "../incantation";
2
+ export declare class AnimIncantation extends Incantation<LOCAL> {
3
+ readonly description = "Animates the slider of a block.";
4
+ readonly identifier = "anim";
5
+ apply(target: Desmos.ExpressionState): void;
6
+ }
7
+ //# sourceMappingURL=anim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anim.d.ts","sourceRoot":"","sources":["../../../../src/magic/local/anim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,eAAgB,SAAQ,WAAW,CAAC,KAAK,CAAC;IAErD,SAAkB,WAAW,qCACQ;IAErC,SAAkB,UAAU,UAAS;IAE5B,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,QAK5C;CACF"}
@@ -0,0 +1,11 @@
1
+ import { Incantation } from "../incantation";
2
+ export class AnimIncantation extends Incantation {
3
+ description = "Animates the slider of a block.";
4
+ identifier = "anim";
5
+ apply(target) {
6
+ super.require_expr_type(target.type, "expression");
7
+ // @ts-expect-error: outdated types
8
+ target.playing = true;
9
+ }
10
+ }
11
+ //# sourceMappingURL=anim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anim.js","sourceRoot":"","sources":["../../../../src/magic/local/anim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,gBAAgB,CAAC;AAGzD,MAAM,OAAO,eAAgB,SAAQ,WAAkB;IAEnC,WAAW,GACzB,iCAAiC,CAAA;IAEnB,UAAU,GAAG,MAAM,CAAA;IAE5B,KAAK,CAAC,MAA8B;QAE3C,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACnD,mCAAmC;QACnC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ import { Incantation, ArgIncantation, type LOCAL } from "../incantation";
2
+ import { DesmosColour } from "../../desmos";
3
+ export declare class ColourIncantation extends ArgIncantation<LOCAL> {
4
+ readonly description = "";
5
+ readonly identifier = "color";
6
+ readonly alias = "colour";
7
+ readonly requires_arg = true;
8
+ readonly arg_type = Incantation.ArgType.ENUM;
9
+ apply(target: Desmos.ExpressionState, data: DesmosColour): void;
10
+ evaluate_arg(data: string): DesmosColour;
11
+ }
12
+ //# sourceMappingURL=colour.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colour.d.ts","sourceRoot":"","sources":["../../../../src/magic/local/colour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGzE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,KAAK,CAAC;IAE1D,SAAkB,WAAW,MACvB;IAEN,SAAkB,UAAU,WAAY;IACxC,SAAkB,KAAK,YAAkB;IACzC,SAAkB,YAAY,QAAO;IACrC,SAAkB,QAAQ,4BAA+B;IAEhD,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,YAAY,QAIhE;IAEQ,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,YAAY,CAchD;CACF"}
@@ -0,0 +1,27 @@
1
+ import { Incantation, ArgIncantation } from "../incantation";
2
+ import { UnrecoverableError } from "../../errors";
3
+ import { DesmosColour } from "../../desmos";
4
+ export class ColourIncantation extends ArgIncantation {
5
+ description = "";
6
+ identifier = "color";
7
+ alias = "colour";
8
+ requires_arg = true;
9
+ arg_type = Incantation.ArgType.ENUM;
10
+ apply(target, data) {
11
+ super.require_expr_type(target.type, "expression");
12
+ target.color = data;
13
+ }
14
+ evaluate_arg(data) {
15
+ switch (data.trim()) {
16
+ case "RED": return DesmosColour.RED;
17
+ case "BLUE": return DesmosColour.BLUE;
18
+ case "GREEN": return DesmosColour.GREEN;
19
+ case "PURPLE": return DesmosColour.PURPLE;
20
+ case "ORANGE": return DesmosColour.ORANGE;
21
+ case "BLACK": return DesmosColour.BLACK;
22
+ default:
23
+ throw new UnrecoverableError(`Invalid colour: \`${data}\``);
24
+ }
25
+ }
26
+ }
27
+ //# sourceMappingURL=colour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colour.js","sourceRoot":"","sources":["../../../../src/magic/local/colour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAc,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,MAAM,OAAO,iBAAkB,SAAQ,cAAqB;IAExC,WAAW,GACzB,EAAE,CAAA;IAEY,UAAU,GAAK,OAAO,CAAA;IACtB,KAAK,GAAU,QAAQ,CAAA;IACvB,YAAY,GAAG,IAAI,CAAA;IACnB,QAAQ,GAAO,WAAW,CAAC,OAAO,CAAC,IAAI,CAAA;IAEhD,KAAK,CAAC,MAA8B,EAAE,IAAkB;QAE/D,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACtB,CAAC;IAEQ,YAAY,CAAC,IAAY;QAEhC,QAAQ,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;YACpB,KAAK,KAAK,EAAK,OAAO,YAAY,CAAC,GAAG,CAAC;YACvC,KAAK,MAAM,EAAI,OAAO,YAAY,CAAC,IAAI,CAAC;YACxC,KAAK,OAAO,EAAG,OAAO,YAAY,CAAC,KAAK,CAAC;YACzC,KAAK,QAAQ,EAAE,OAAO,YAAY,CAAC,MAAM,CAAC;YAC1C,KAAK,QAAQ,EAAE,OAAO,YAAY,CAAC,MAAM,CAAC;YAC1C,KAAK,OAAO,EAAG,OAAO,YAAY,CAAC,KAAK,CAAC;YACzC;gBACE,MAAM,IAAI,kBAAkB,CAC1B,qBAAqB,IAAI,IAAI,CAC9B,CAAC;QACN,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,7 @@
1
+ import { Incantation, type LOCAL } from "../incantation";
2
+ export declare class DashedIncantation extends Incantation<LOCAL> {
3
+ readonly description = "Render a block as a dashed line.";
4
+ readonly identifier = "dashed";
5
+ apply(target: Desmos.ExpressionState): void;
6
+ }
7
+ //# sourceMappingURL=dashed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashed.d.ts","sourceRoot":"","sources":["../../../../src/magic/local/dashed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGzD,qBAAa,iBAAkB,SAAQ,WAAW,CAAC,KAAK,CAAC;IAEvD,SAAkB,WAAW,sCACS;IAEtC,SAAkB,UAAU,YAAW;IAE9B,KAAK,CAAC,MAAM,EAAE,MAAM,CAAC,eAAe,QAI5C;CACF"}