@spidunno/desmos-types 1.13.0 → 1.13.1
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 +15 -1
- package/internals/private.d.ts +3 -1
- package/package.json +2 -3
- package/types/abraham.d.ts +114 -23
package/README.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.0
|
|
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.0`), not npm's default caret (`^`). A caret range
|
|
14
|
+
would also accept a future `1.14.x`, which describes a different API version than the
|
|
15
|
+
`calculator.js` you load.
|
|
16
|
+
|
|
6
17
|
## Usage
|
|
7
18
|
|
|
8
19
|
Load the API as usual:
|
|
@@ -74,9 +85,12 @@ The types follow the official v1.13 documentation and were checked against the
|
|
|
74
85
|
|
|
75
86
|
Members marked `@remarks Undocumented` exist in the bundle but not in the docs. Examples are the
|
|
76
87
|
3D camera methods (`getOrientation`, `setOrientation`, `animateToOrientation`,
|
|
77
|
-
`setPerspectiveDistortion`), `LabelSizes`, the extra `LabelOrientations`,
|
|
88
|
+
`setPerspectiveDistortion`), `LabelSizes`, the extra `LabelOrientations`, and `MathQuill`.
|
|
78
89
|
They work in v1.13 but Desmos makes no promises about them.
|
|
79
90
|
|
|
91
|
+
`Abraham` follows its own [documentation page](https://www.desmos.com/api/v1.13/docs/abraham.html).
|
|
92
|
+
Desmos asks that you contact partnerships@desmos.com before using it.
|
|
93
|
+
|
|
80
94
|
Internal exports are not part of the public types. `Desmos.Private` and the calculators' internal
|
|
81
95
|
members are typed separately (see [Internals](#internals)). `Desmos.TestInternal`, `Desmos.config` and
|
|
82
96
|
`Desmos.$` aren't typed at all.
|
package/internals/private.d.ts
CHANGED
|
@@ -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.
|
|
3
|
+
"version": "1.13.1",
|
|
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
|
}
|
package/types/abraham.d.ts
CHANGED
|
@@ -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
|
-
*
|
|
6
|
-
*
|
|
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?:
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
49
|
-
|
|
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
|
-
/**
|
|
144
|
+
/** The Abraham Braille translation library. */
|
|
54
145
|
const Abraham: Abraham;
|
|
55
146
|
}
|