@spidunno/desmos-types 1.13.0 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,6 +3,16 @@
3
3
  TypeScript type definitions for the [Desmos API v1.13](https://www.desmos.com/api/v1.13/docs/index.html):
4
4
  the graphing calculator, geometry tool, 3D calculator, and the four-function and scientific calculators.
5
5
 
6
+ ## Install
7
+
8
+ ```sh
9
+ npm install --save-dev @spidunno/desmos-types@~1.13.2
10
+ ```
11
+
12
+ The package's major and minor version match the Desmos API version it describes; patch releases
13
+ are fixes to the types. Use a tilde range (`~1.13.2`), not npm's default caret (`^`), so you only
14
+ get type fixes for the API version you load.
15
+
6
16
  ## Usage
7
17
 
8
18
  Load the API as usual:
@@ -74,9 +84,12 @@ The types follow the official v1.13 documentation and were checked against the
74
84
 
75
85
  Members marked `@remarks Undocumented` exist in the bundle but not in the docs. Examples are the
76
86
  3D camera methods (`getOrientation`, `setOrientation`, `animateToOrientation`,
77
- `setPerspectiveDistortion`), `LabelSizes`, the extra `LabelOrientations`, `Abraham` and `MathQuill`.
87
+ `setPerspectiveDistortion`), `LabelSizes`, the extra `LabelOrientations`, and `MathQuill`.
78
88
  They work in v1.13 but Desmos makes no promises about them.
79
89
 
90
+ `Abraham` follows its own [documentation page](https://www.desmos.com/api/v1.13/docs/abraham.html).
91
+ Desmos asks that you contact partnerships@desmos.com before using it.
92
+
80
93
  Internal exports are not part of the public types. `Desmos.Private` and the calculators' internal
81
94
  members are typed separately (see [Internals](#internals)). `Desmos.TestInternal`, `Desmos.config` and
82
95
  `Desmos.$` aren't typed at all.
@@ -12,8 +12,10 @@ declare namespace Desmos.Internals {
12
12
  } & FragileViews &
13
13
  FragileHelpers;
14
14
 
15
- type Private = Omit<Generated.Private, 'Fragile'> & {
15
+ type Private = Omit<Generated.Private, 'Fragile' | 'Abraham'> & {
16
16
  Fragile: PrivateFragile;
17
+ /** The same object as {@link Desmos.Abraham}. */
18
+ Abraham: Desmos.Abraham;
17
19
  };
18
20
  }
19
21
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spidunno/desmos-types",
3
- "version": "1.13.0",
3
+ "version": "1.13.2",
4
4
  "description": "TypeScript type definitions for the Desmos API v1.13",
5
5
  "types": "index.d.ts",
6
6
  "publishConfig": {
@@ -33,7 +33,6 @@
33
33
  "devDependencies": {
34
34
  "acorn": "^8.14.0",
35
35
  "acorn-walk": "^8.3.4",
36
- "jsdom": "^24.1.3",
37
- "typescript": "5.6.3"
36
+ "jsdom": "^24.1.3"
38
37
  }
39
38
  }
@@ -2,54 +2,145 @@
2
2
  * Abraham: Desmos's library for translating between LaTeX and the Nemeth and
3
3
  * UEB Braille math codes, bundled into `calculator.js`.
4
4
  *
5
- * @remarks Undocumented: the docs only mention that the library exists. The
6
- * shapes below come from inspecting the v1.13 bundle and may change.
5
+ * Documented at https://www.desmos.com/api/v1.13/docs/abraham.html. Desmos
6
+ * asks that you contact partnerships@desmos.com before using it.
7
7
  */
8
8
  declare namespace Desmos {
9
+ /** A position in the translator's input. */
10
+ interface AbrahamLocation {
11
+ first_line: number;
12
+ last_line: number;
13
+ first_column: number;
14
+ last_column: number;
15
+ }
16
+
17
+ /** A place where permissive Braille→LaTeX translation inserted a missing delimiter. */
18
+ interface AbrahamWarning {
19
+ location: AbrahamLocation;
20
+ }
21
+
22
+ /** A successful LaTeX→Braille translation. */
23
+ interface AbrahamBrailleSuccess {
24
+ isError: false;
25
+ /** Six-dot Unicode Braille. */
26
+ value: string;
27
+ }
28
+
29
+ /** A successful Braille→LaTeX translation. */
30
+ interface AbrahamLatexSuccess {
31
+ isError: false;
32
+ value: Latex;
33
+ /** Where missing delimiters were inserted. Always empty with `strict: true`. */
34
+ warnings: AbrahamWarning[];
35
+ }
36
+
37
+ /** A successful translation in either direction. */
9
38
  interface AbrahamSuccess {
10
39
  isError: false;
11
40
  value: string;
12
41
  /** Present on Braille→LaTeX results. */
13
- warnings?: unknown[];
42
+ warnings?: AbrahamWarning[];
14
43
  }
15
44
 
45
+ /** A failed translation (a parse error). */
16
46
  interface AbrahamFailure {
17
47
  isError: true;
18
48
  error: {
19
- location?: {
20
- first_line: number;
21
- last_line: number;
22
- first_column: number;
23
- last_column: number;
24
- };
25
- [key: string]: unknown;
49
+ /** Where the parse error occurred. */
50
+ location: AbrahamLocation;
51
+ /** Developer diagnostics. Not part of the public API; its contents may change. */
52
+ _diagnostic?: unknown;
26
53
  };
27
54
  }
28
55
 
56
+ /** The result of `latexToNemeth` / `latexToUeb`. */
57
+ type AbrahamBrailleResult = AbrahamBrailleSuccess | AbrahamFailure;
58
+
59
+ /** The result of `nemethToLatex` / `uebToLatex`. */
60
+ type AbrahamLatexResult = AbrahamLatexSuccess | AbrahamFailure;
61
+
62
+ /** The result of any translation. */
29
63
  type AbrahamResult = AbrahamSuccess | AbrahamFailure;
30
64
 
65
+ interface AbrahamLatexToBrailleOptions {
66
+ /**
67
+ * Operator names to recognize. Neither Braille code has a convention for
68
+ * `\operatorname`, so these are written as plain letters.
69
+ * @defaultValue Desmos's built-in list (`floor`, `mean`, `normaldist`, ...)
70
+ */
71
+ operatorNames?: readonly string[];
72
+ }
73
+
74
+ interface AbrahamBrailleToLatexOptions {
75
+ /**
76
+ * Treat missing delimiters (e.g. an unclosed fraction or radical) as parse
77
+ * errors instead of inserting them and reporting `warnings`.
78
+ * @defaultValue `false`
79
+ */
80
+ strict?: boolean;
81
+ /**
82
+ * Operator names to recognize in the Braille input, e.g. `['blah']` turns
83
+ * `blah(abc)` into `\operatorname{blah}(abc)`.
84
+ * @defaultValue Desmos's built-in list (`floor`, `mean`, `normaldist`, ...)
85
+ */
86
+ operatorNames?: readonly string[];
87
+ }
88
+
31
89
  interface Abraham {
32
90
  /** Library version, e.g. `'1.0.3'`. */
33
91
  readonly version: string;
34
- /** LaTeX → Nemeth Braille (Unicode Braille cells). */
35
- latexToNemeth(latex: Latex): AbrahamResult;
36
- /** LaTeX → UEB Braille (Unicode Braille cells). */
37
- latexToUeb(latex: Latex): AbrahamResult;
38
- /** Nemeth Braille → LaTeX. */
39
- nemethToLatex(braille: string): AbrahamResult;
40
- /** UEB Braille → LaTeX. */
41
- uebToLatex(braille: string): AbrahamResult;
92
+
93
+ /**
94
+ * LaTeX → Nemeth Braille.
95
+ * @example Abraham.latexToNemeth('e_{f}^{x^{2}}') // { isError: false, value: '⠑⠰⠋⠘⠭⠘⠘⠆' }
96
+ */
97
+ latexToNemeth(latex: Latex, options?: AbrahamLatexToBrailleOptions): AbrahamBrailleResult;
98
+
99
+ /**
100
+ * LaTeX → UEB Braille.
101
+ * @example Abraham.latexToUeb('1+1') // { isError: false, value: '⠼⠁⠐⠖⠼⠁' }
102
+ */
103
+ latexToUeb(latex: Latex, options?: AbrahamLatexToBrailleOptions): AbrahamBrailleResult;
104
+
105
+ /**
106
+ * Nemeth Braille → LaTeX. `braille` must be six-dot Unicode Braille; use
107
+ * `UnicodeBraille.coerceToSixDotCells` to convert other formats first.
108
+ * Unless `strict` is set, missing delimiters are inserted and reported in `warnings`.
109
+ * @example Abraham.nemethToLatex('⠹⠂⠌⠆') // value '\\frac{1}{2}', with one warning
110
+ */
111
+ nemethToLatex(braille: string, options?: AbrahamBrailleToLatexOptions): AbrahamLatexResult;
112
+
113
+ /**
114
+ * UEB Braille → LaTeX. `braille` must be six-dot Unicode Braille; use
115
+ * `UnicodeBraille.coerceToSixDotCells` to convert other formats first.
116
+ * Unless `strict` is set, missing delimiters are inserted and reported in `warnings`.
117
+ * @example Abraham.uebToLatex('⠼⠁⠐⠖⠼⠁') // { isError: false, value: '1+1', warnings: [] }
118
+ */
119
+ uebToLatex(braille: string, options?: AbrahamBrailleToLatexOptions): AbrahamLatexResult;
120
+
42
121
  /** Conversions between Unicode Braille and Braille ASCII. */
43
122
  readonly UnicodeBraille: {
44
- /** Unicode Braille → Braille ASCII, e.g. `'⠭⠘⠆'` → `'X^2'`. */
123
+ /**
124
+ * Unicode Braille → Braille ASCII (upper case letters as a comma + letter digraph).
125
+ * @example toBrailleAscii('⠼⠁⠐⠖⠼⠁') // '#A"6#A'
126
+ */
45
127
  toBrailleAscii(braille: string): string;
46
- /** Unicode Braille → expanded (lowercase) Braille ASCII, e.g. `'⠭⠘⠆'` → `'x~2'`. */
128
+ /**
129
+ * Unicode Braille → Expanded Braille ASCII, the eight-dot encoding common
130
+ * on refreshable displays.
131
+ * @example toExpandedBrailleAscii('⠼⠁⠐⠖⠼⠁') // '#a"6#a'
132
+ */
47
133
  toExpandedBrailleAscii(braille: string): string;
48
- /** Reduce eight-dot cells to six-dot cells. */
49
- coerceToSixDotCells(braille: string): string;
134
+ /**
135
+ * Coerce input to the six-dot Unicode Braille the translators expect:
136
+ * converts Braille ASCII or Expanded Braille ASCII (ignoring case), and
137
+ * strips the bottom pair of dots from eight-dot Unicode cells.
138
+ * @example coerceToSixDotCells('#A"6#A') // '⠼⠁⠐⠖⠼⠁'
139
+ */
140
+ coerceToSixDotCells(input: string): string;
50
141
  };
51
142
  }
52
143
 
53
- /** @remarks Undocumented: may change without notice. */
144
+ /** The Abraham Braille translation library. */
54
145
  const Abraham: Abraham;
55
146
  }