@spidunno/desmos-types 1.13.3 → 1.13.4
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 +43 -4
- package/internals/generated/objects.d.ts +5 -5
- package/internals/grapher2d.d.ts +591 -0
- package/internals/index.d.ts +1 -0
- package/internals/list-model.d.ts +36 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,11 +6,11 @@ the graphing calculator, geometry tool, 3D calculator, and the four-function and
|
|
|
6
6
|
## Install
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
npm install --save-dev @spidunno/desmos-types@~1.13.
|
|
9
|
+
npm install --save-dev @spidunno/desmos-types@~1.13.4
|
|
10
10
|
```
|
|
11
11
|
|
|
12
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.
|
|
13
|
+
are fixes to the types. Use a tilde range (`~1.13.4`), not npm's default caret (`^`), so you only
|
|
14
14
|
get type fixes for the API version you load.
|
|
15
15
|
|
|
16
16
|
## Usage
|
|
@@ -134,7 +134,7 @@ Everything here is internal to Desmos and changes between builds, even within v1
|
|
|
134
134
|
|
|
135
135
|
| Layer | Files | Source |
|
|
136
136
|
| --- | --- | --- |
|
|
137
|
-
| Generated | `internals/generated/objects.d.ts` | The bundle loaded in jsdom;
|
|
137
|
+
| Generated | `internals/generated/objects.d.ts` | The bundle loaded in jsdom; 60 internal objects walked |
|
|
138
138
|
| Generated | `internals/generated/actions.d.ts` | Every `dispatch({ type })` call site and `switch (action.type)` reducer, found with acorn. Each of the 341 actions is attributed to the reducer(s) that handle it, giving three unions: `Action` (graph controller), `MathFieldAction` and `BasicCalculatorAction` |
|
|
139
139
|
| Generated | `internals/generated/views.d.ts` | Props and instance members of the 13 `Private.Fragile` views, from live instances (about 1,400 views rendered), call sites and prop reads, following `{...props}` forwarding into inner views |
|
|
140
140
|
| Hand-written | `internals/*.d.ts` | Precise types for the parts mods use, checked against the bundle source |
|
|
@@ -143,7 +143,9 @@ In the generated layer, property types come from observed values. A method's ret
|
|
|
143
143
|
static analysis of its source (nothing returned → `void`, only booleans returned → `boolean`), or from
|
|
144
144
|
calling side-effect-free getters such as `get*` and `is*`. Anything that couldn't be determined is
|
|
145
145
|
`unknown`, and parameters are `unknown` because the bundle is minified. Action payload field names are
|
|
146
|
-
reliable, but their value types are often inferred from the field name.
|
|
146
|
+
reliable, but their value types are often inferred from the field name. A property is optional if it
|
|
147
|
+
held `undefined` or was added after the calculator loaded (for example, by the first animation frame
|
|
148
|
+
or a UI interaction).
|
|
147
149
|
|
|
148
150
|
The hand-written interfaces *extend* the generated ones (`Internals.Controller extends
|
|
149
151
|
Generated.Controller`, and so on). TypeScript therefore checks every hand-written type against what
|
|
@@ -166,6 +168,10 @@ What's hand-typed:
|
|
|
166
168
|
interest (`POI`, `POITypes`), sketch labels, movable points and the grapher's sketch methods.
|
|
167
169
|
A fixture of 60 real sketches (`test/fixtures/graph-sketches.ts`) is type-checked against
|
|
168
170
|
these types.
|
|
171
|
+
- **The rest of `grapher2d`:** the projection (math ↔ pixel conversion, with linear and log axes),
|
|
172
|
+
`Viewport`, the viewport controller (jump, animate, zoom, pan), `GrapherSettings` (every graph
|
|
173
|
+
and drawing setting, with typed `observe` / `getProperty` / `setProperty`), the `'redraw'`
|
|
174
|
+
event, draw layers, graph images, screenshots and grapher state.
|
|
169
175
|
- **Dispatcher:** `register`, `unregister`, `waitFor`, generic over the action type.
|
|
170
176
|
- **Other controllers:** each math field (`mathField.controller`) and each basic calculator
|
|
171
177
|
(`calculator.controller`) has its own controller and dispatcher. Keystrokes in a math field are
|
|
@@ -291,6 +297,39 @@ sketches['1']?.getPOI().filter((poi) => poi.type === 1004).map((poi) => [poi.x,
|
|
|
291
297
|
sketches['1']?.getMovablePoints().map((p) => ({ x: p.x, y: p.y, row: p.tableInfo?.rowIndex }));
|
|
292
298
|
```
|
|
293
299
|
|
|
300
|
+
### Projection, viewport and settings
|
|
301
|
+
|
|
302
|
+
`grapher2d.getProjection()` converts between math coordinates and pixels (CSS pixels from the
|
|
303
|
+
graph paper's top-left, y down). The projection is replaced whenever you pan, zoom or resize, so
|
|
304
|
+
get a fresh one each time instead of keeping it.
|
|
305
|
+
|
|
306
|
+
```js
|
|
307
|
+
const g = Calc.controller.grapher2d;
|
|
308
|
+
|
|
309
|
+
// Math ↔ pixels
|
|
310
|
+
const p = g.getProjection();
|
|
311
|
+
p.map_pt({ x: 0, y: 0 }); // where the origin is on screen
|
|
312
|
+
p.reverse_map_pt({ x: 100, y: 100 }); // the math point under pixel (100, 100)
|
|
313
|
+
p.mathToPixels.dangerouslyGetXScaleFactor(); // pixels per unit (throws on a log axis)
|
|
314
|
+
|
|
315
|
+
// The viewport
|
|
316
|
+
g.getCurrentViewport(); // { xmin, xmax, ymin, ymax }
|
|
317
|
+
g.viewportController.animateToViewport({ xmin: -5, xmax: 5, ymin: -5, ymax: 5 });
|
|
318
|
+
g.viewportController.zoom('in'); // 'in' | 'out' | 'square' | 'default'
|
|
319
|
+
|
|
320
|
+
// Settings: graph settings plus drawing settings like labelSize and graphLineWidth
|
|
321
|
+
g.settings.observe('showGrid.myMod', (name, settings) => console.log(name, settings.showGrid));
|
|
322
|
+
g.settings.setProperty('showGrid', false);
|
|
323
|
+
g.settings.unobserve('.myMod'); // remove every observer in the myMod namespace
|
|
324
|
+
|
|
325
|
+
// Run code after each redraw (the callback gets the redraw time in ms)
|
|
326
|
+
g.events.observeEvent('redraw.myMod', (event, ms) => console.log(`redrew in ${ms}ms`));
|
|
327
|
+
g.events.unobserveEvent('.myMod');
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Moving the viewport this way doesn't add an undo step. Call
|
|
331
|
+
`g.debounceUserRequestedViewportChange()` afterwards if you want one.
|
|
332
|
+
|
|
294
333
|
### Regenerating for a new bundle
|
|
295
334
|
|
|
296
335
|
```sh
|
|
@@ -18,7 +18,7 @@ declare namespace Desmos.Internals.Generated {
|
|
|
18
18
|
bugsnagContext: string;
|
|
19
19
|
cachedGeoTokenDepths: Record<string, Array<Record<string, unknown>>>;
|
|
20
20
|
canShowKeyboardShortcuts: boolean;
|
|
21
|
-
checkSlowAnalysis
|
|
21
|
+
checkSlowAnalysis?: boolean;
|
|
22
22
|
clipboardHandlers: Record<string, (arg0?: any) => unknown>;
|
|
23
23
|
cooperativeGestureHint?: unknown;
|
|
24
24
|
cooperativeGestureHintTimeout?: unknown;
|
|
@@ -51,7 +51,7 @@ declare namespace Desmos.Internals.Generated {
|
|
|
51
51
|
isExpressionReplaceStrValidForReplace: boolean;
|
|
52
52
|
isExpressionSearchStrValidForReplace: boolean;
|
|
53
53
|
lastCursorContext?: unknown;
|
|
54
|
-
lastFrameTime
|
|
54
|
+
lastFrameTime?: number;
|
|
55
55
|
lastInfiniteScrollFirstDOM: HTMLDivElement;
|
|
56
56
|
lastInfiniteScrollLastDOM: HTMLDivElement;
|
|
57
57
|
lastParsableObjects: { abstract_item_2: Record<string, unknown>; abstract_item_3: Record<string, unknown>; abstract_item_4: Record<string, unknown>; abstract_item_5: Record<string, unknown>; abstract_item_6: Record<string, unknown>; abstract_item_7: { type: string; id: string; center: string; angle: string; width: string; height: string; opacity: string; mask: string; clickableInfo: Record<string, unknown>; description: string; draggable: boolean; moduleId?: unknown; guid: string; index: number; color: string; shouldGraph: boolean; showPoints: boolean }; abstract_item_8: { type: string; id: string; columns: Array<Record<string, unknown>>; regression?: unknown }; dcg_ticker_guid_internal: { type: string; id: string; handlerLatex: string; minStepLatex: string; shouldGraph: boolean }; dcg_viewport_statement_id_internal: { type: string; id: string; viewport: Record<string, unknown> } };
|
|
@@ -66,7 +66,7 @@ declare namespace Desmos.Internals.Generated {
|
|
|
66
66
|
pinchZoom: number;
|
|
67
67
|
progressUpdateLegendHidden: boolean;
|
|
68
68
|
raw(arg0?: unknown, arg1?: unknown): unknown;
|
|
69
|
-
requestedEvaluatorRestart
|
|
69
|
+
requestedEvaluatorRestart?: boolean;
|
|
70
70
|
rootElt: HTMLDivElement;
|
|
71
71
|
s(arg0?: unknown, arg1?: unknown): unknown;
|
|
72
72
|
sendActionToIframeConnect(): void;
|
|
@@ -1024,7 +1024,7 @@ declare namespace Desmos.Internals.Generated {
|
|
|
1024
1024
|
imageLayer: Grapher2DImageLayer;
|
|
1025
1025
|
isVisible: boolean;
|
|
1026
1026
|
lastActiveToken: { selected?: unknown; hovered?: unknown };
|
|
1027
|
-
lastTickViewport
|
|
1027
|
+
lastTickViewport?: Grapher2DLastTickViewport;
|
|
1028
1028
|
markLabelsDirty(): unknown;
|
|
1029
1029
|
movablePointsLayer: Grapher2DMovablePointsLayer;
|
|
1030
1030
|
poiController: Grapher2DPoiController;
|
|
@@ -1120,7 +1120,7 @@ declare namespace Desmos.Internals.Generated {
|
|
|
1120
1120
|
graphLineWidth: number;
|
|
1121
1121
|
guid: string;
|
|
1122
1122
|
hideCustomColors: boolean;
|
|
1123
|
-
highlight
|
|
1123
|
+
highlight?: boolean;
|
|
1124
1124
|
highlightPropertyMultipliers: Record<string, number[]>;
|
|
1125
1125
|
includeFunctionParametersInRandomSeed: boolean;
|
|
1126
1126
|
labelHangingColor: string;
|
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `calculator.controller.grapher2d`: the 2D graph paper. Owns the projection
|
|
3
|
+
* (math ↔ pixel mapping), the graph settings, the viewport controller, the
|
|
4
|
+
* draw layers and the graph sketches (see graph-sketches.d.ts).
|
|
5
|
+
*
|
|
6
|
+
* Coordinate systems:
|
|
7
|
+
* - **math**: graph coordinates, y up.
|
|
8
|
+
* - **pixel**: CSS pixels relative to the top-left of the graph paper, y down.
|
|
9
|
+
* The canvas is scaled by `devicePixelRatio` internally, so you never
|
|
10
|
+
* see physical pixels here.
|
|
11
|
+
*/
|
|
12
|
+
declare namespace Desmos.Internals {
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Geometry primitives
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
/** A point, in math or pixel coordinates depending on context. */
|
|
18
|
+
interface Point {
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Graph paper size in CSS pixels. */
|
|
24
|
+
interface Screen {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** A rectangle in math coordinates (`top > bottom`). */
|
|
30
|
+
interface MathRect {
|
|
31
|
+
left: number;
|
|
32
|
+
right: number;
|
|
33
|
+
bottom: number;
|
|
34
|
+
top: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A rectangle in pixel coordinates (`bottom > top`, since y points down). */
|
|
38
|
+
interface PixelRect {
|
|
39
|
+
left: number;
|
|
40
|
+
right: number;
|
|
41
|
+
top: number;
|
|
42
|
+
bottom: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Axis scales, as found on {@link GrapherSettings}. */
|
|
46
|
+
interface AxisScales {
|
|
47
|
+
xAxisScale: Desmos.AxisScale;
|
|
48
|
+
yAxisScale: Desmos.AxisScale;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Viewport bounds as LaTeX strings: the form stored in graph state. */
|
|
52
|
+
interface LatexViewport {
|
|
53
|
+
xmin: string;
|
|
54
|
+
xmax: string;
|
|
55
|
+
ymin: string;
|
|
56
|
+
ymax: string;
|
|
57
|
+
zmin?: string;
|
|
58
|
+
zmax?: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Viewport bounds as numbers. `zmin`/`zmax` are only set in 3D. */
|
|
62
|
+
interface ViewportObject {
|
|
63
|
+
xmin: number;
|
|
64
|
+
xmax: number;
|
|
65
|
+
ymin: number;
|
|
66
|
+
ymax: number;
|
|
67
|
+
zmin?: number;
|
|
68
|
+
zmax?: number;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// Viewport
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The visible math region. Immutable in practice: the grapher replaces the
|
|
77
|
+
* whole viewport (and projection) when you pan or zoom, so a reference you
|
|
78
|
+
* hold keeps describing the old view.
|
|
79
|
+
*/
|
|
80
|
+
interface Viewport extends Generated.Grapher2DLastTickViewport {
|
|
81
|
+
xmin: number;
|
|
82
|
+
xmax: number;
|
|
83
|
+
ymin: number;
|
|
84
|
+
ymax: number;
|
|
85
|
+
zmin?: number;
|
|
86
|
+
zmax?: number;
|
|
87
|
+
toObject(): ViewportObject;
|
|
88
|
+
/** Compares all six bounds with `===`. */
|
|
89
|
+
equals(other: ViewportObject): boolean;
|
|
90
|
+
/** `xmin < xmax`, both finite (and positive for a logarithmic axis). */
|
|
91
|
+
isXValid(scale: Desmos.AxisScale): boolean;
|
|
92
|
+
isYValid(scale: Desmos.AxisScale): boolean;
|
|
93
|
+
isZValid(): boolean;
|
|
94
|
+
isValid(scales: AxisScales): boolean;
|
|
95
|
+
/** Height over width in math units (in decades for logarithmic axes). */
|
|
96
|
+
aspectRatio(scales: AxisScales): number;
|
|
97
|
+
/** Whether one math unit is the same number of pixels on both axes (within 1px). */
|
|
98
|
+
isSquare(screen: Screen, scales: AxisScales): boolean;
|
|
99
|
+
isSquare3D(): boolean;
|
|
100
|
+
getSquaredAxisLimits(options: { axis: 'x' | 'y'; screen: Screen; settings: AxisScales }): { min: number; max: number };
|
|
101
|
+
/** Adjust `xmin`/`xmax` about their midpoint so the axes are square. */
|
|
102
|
+
squareXAxis(screen: Screen, scales: AxisScales): Viewport;
|
|
103
|
+
/** Adjust `ymin`/`ymax` about their midpoint so the axes are square. */
|
|
104
|
+
squareYAxis(screen: Screen, scales: AxisScales): Viewport;
|
|
105
|
+
/** Square the axes by shrinking whichever axis is too long. */
|
|
106
|
+
squareCrop(screen: Screen, scales: AxisScales): Viewport;
|
|
107
|
+
/** Distance from the origin to the farthest corner. */
|
|
108
|
+
largestR(): number;
|
|
109
|
+
/** Distance from the origin to the nearest visible point (0 if the origin is visible). */
|
|
110
|
+
smallestR(): number;
|
|
111
|
+
/** 1.5 × the largest absolute bound; how far the polar grid is drawn. */
|
|
112
|
+
polarDiameter(): number;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ---------------------------------------------------------------------------
|
|
116
|
+
// Projection
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* How one axis maps values:
|
|
121
|
+
* - `linear`: `s * v + t`
|
|
122
|
+
* - `logarithmic`: `s * ln(v) + t` (math → pixels on a log axis)
|
|
123
|
+
* - `exponential`: `exp(s * v + t)` (pixels → math on a log axis)
|
|
124
|
+
*/
|
|
125
|
+
type ScaleType = 'linear' | 'logarithmic' | 'exponential';
|
|
126
|
+
|
|
127
|
+
interface Scale {
|
|
128
|
+
type: ScaleType;
|
|
129
|
+
s: number;
|
|
130
|
+
t: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* A per-axis mapping between two coordinate systems. `projection.mathToPixels`
|
|
135
|
+
* and `projection.pixelsToMath` are the two directions.
|
|
136
|
+
*/
|
|
137
|
+
interface ScreenTransform {
|
|
138
|
+
xScale: Scale;
|
|
139
|
+
yScale: Scale;
|
|
140
|
+
mapX(value: number): number;
|
|
141
|
+
mapY(value: number): number;
|
|
142
|
+
mapPoint(point: Point): Point;
|
|
143
|
+
mapCoordinatePair(pair: [number, number]): [number, number];
|
|
144
|
+
mapRect(rect: MathRect | PixelRect): { left: number; right: number; bottom: number; top: number };
|
|
145
|
+
/** The reverse mapping. */
|
|
146
|
+
inverse(): ScreenTransform;
|
|
147
|
+
/** Interpolate between two values along the x axis (geometrically on a log axis). `t` runs from 0 to 1. */
|
|
148
|
+
interpolateX(from: number, to: number, t: number): number;
|
|
149
|
+
interpolateY(from: number, to: number, t: number): number;
|
|
150
|
+
/** Pixels per math unit on x. Throws unless the x axis is linear. */
|
|
151
|
+
dangerouslyGetXScaleFactor(): number;
|
|
152
|
+
/** Pixels per math unit on y (negative, since y points down). Throws unless the y axis is linear. */
|
|
153
|
+
dangerouslyGetYScaleFactor(): number;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The current mapping between math and pixel coordinates. Replaced (not
|
|
158
|
+
* mutated) whenever the viewport or screen size changes, so call
|
|
159
|
+
* `grapher2d.getProjection()` each time rather than keeping one.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* const p = Calc.controller.grapher2d.getProjection();
|
|
163
|
+
* p.map_pt({ x: 1, y: 2 }); // math → pixels
|
|
164
|
+
* p.reverse_map_pt({ x: 100, y: 50 }); // pixels → math
|
|
165
|
+
*/
|
|
166
|
+
interface Projection extends Generated.Grapher2DProjection {
|
|
167
|
+
screen: Screen;
|
|
168
|
+
viewport: Viewport;
|
|
169
|
+
settings: GrapherSettings;
|
|
170
|
+
/** The viewport as a {@link MathRect}. */
|
|
171
|
+
mathCoordinates: MathRect;
|
|
172
|
+
/** The screen as a {@link PixelRect}: `{ left: 0, top: 0, right: width, bottom: height }`. */
|
|
173
|
+
pixelCoordinates: PixelRect;
|
|
174
|
+
mathToPixels: ScreenTransform;
|
|
175
|
+
pixelsToMath: ScreenTransform;
|
|
176
|
+
/** Rebuild `mathToPixels`/`pixelsToMath` after changing the axis scales. */
|
|
177
|
+
updateScalePairs(): void;
|
|
178
|
+
/** Math x → pixel x. */
|
|
179
|
+
mapx(x: number): number;
|
|
180
|
+
/** Math y → pixel y. */
|
|
181
|
+
mapy(y: number): number;
|
|
182
|
+
/** Pixel x → math x. */
|
|
183
|
+
reverse_mapx(x: number): number;
|
|
184
|
+
/** Pixel y → math y. */
|
|
185
|
+
reverse_mapy(y: number): number;
|
|
186
|
+
mapAlongAxis(value: number, axis: 'x' | 'y'): number;
|
|
187
|
+
reverseMapAlongAxis(value: number, axis: 'x' | 'y'): number;
|
|
188
|
+
/** Math point → pixel point. */
|
|
189
|
+
map_pt(point: Point): Point;
|
|
190
|
+
/** Pixel point → math point. */
|
|
191
|
+
reverse_map_pt(point: Point): Point;
|
|
192
|
+
/** Map a flat `[x0, y0, x1, y1, …]` array from math to pixels. */
|
|
193
|
+
map_xy_pairs(flat: number[]): number[];
|
|
194
|
+
/** Whether a pixel point is within the screen, optionally extended by `margin` pixels. */
|
|
195
|
+
coordsAreOnscreen(x: number, y: number, margin?: number): boolean;
|
|
196
|
+
/** Clamp a pixel point into the screen. */
|
|
197
|
+
closestPointOnScreen(point: Point): Point;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// ---------------------------------------------------------------------------
|
|
201
|
+
// Settings
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* An object whose properties are observed by name. The internal base class
|
|
206
|
+
* of `GrapherSettings` and its `config`.
|
|
207
|
+
*
|
|
208
|
+
* Observers receive the property name and the object. Names may be
|
|
209
|
+
* namespaced (`'showGrid.myMod'`) so the observer can be removed alone,
|
|
210
|
+
* and `observe` also accepts several space-separated names.
|
|
211
|
+
*/
|
|
212
|
+
interface ObservableModel<Props> extends Desmos.Observable<Props> {
|
|
213
|
+
guid: string;
|
|
214
|
+
getProperty<K extends keyof Props>(name: K): Props[K];
|
|
215
|
+
/** Set a property and notify its observers if the value changed (deep comparison). */
|
|
216
|
+
setProperty<K extends keyof Props>(name: K, value: Props[K]): void;
|
|
217
|
+
setPropertyWithoutNotifying<K extends keyof Props>(name: K, value: Props[K]): void;
|
|
218
|
+
/** Set several properties, then notify observers of those that changed. */
|
|
219
|
+
setProperties(values: Partial<Props>): void;
|
|
220
|
+
notifyPropertyChange(name: Extract<keyof Props, string>): void;
|
|
221
|
+
observe(
|
|
222
|
+
names: Desmos.ObservableProperty<Props> | `${Extract<keyof Props, string>} ${string}`,
|
|
223
|
+
callback: Desmos.ObserverCallback<this, Props>
|
|
224
|
+
): void;
|
|
225
|
+
/** `observe`, then immediately call `callback` for each named property that exists. */
|
|
226
|
+
observeAndSync(
|
|
227
|
+
names: Desmos.ObservableProperty<Props> | `${Extract<keyof Props, string>} ${string}`,
|
|
228
|
+
callback: Desmos.ObserverCallback<this, Props>
|
|
229
|
+
): void;
|
|
230
|
+
/** Also accepts `'.namespace'` to remove that namespace from every property. */
|
|
231
|
+
unobserve(names: Desmos.ObservableProperty<Props> | `.${string}`): void;
|
|
232
|
+
unobserveAll(): void;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Graph settings that are saved in the graph state (`stateProperties`).
|
|
237
|
+
* Mostly the documented {@link Desmos.GraphSettings}, plus 3D and
|
|
238
|
+
* internal ones.
|
|
239
|
+
*/
|
|
240
|
+
interface GrapherStateSettings extends Required<Desmos.GraphSettings> {
|
|
241
|
+
complex: boolean;
|
|
242
|
+
restrictGridToFirstQuadrant: boolean;
|
|
243
|
+
userLockedViewport: boolean;
|
|
244
|
+
squareAxes: boolean;
|
|
245
|
+
product: Product;
|
|
246
|
+
includeFunctionParametersInRandomSeed: boolean;
|
|
247
|
+
hideCustomColors: boolean;
|
|
248
|
+
// 3D only
|
|
249
|
+
worldRotation3D: number[];
|
|
250
|
+
axis3D: number[];
|
|
251
|
+
speed3D: number;
|
|
252
|
+
userLockedRotation: boolean;
|
|
253
|
+
disableLighting: boolean;
|
|
254
|
+
perspectiveDistortion: number;
|
|
255
|
+
showPlane3D: boolean;
|
|
256
|
+
showNumbers3D: boolean;
|
|
257
|
+
showAxis3D: boolean;
|
|
258
|
+
showAxisLabels3D: boolean;
|
|
259
|
+
showBox3D: boolean;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Drawing settings derived from `config.projectorMode` and `highlight`.
|
|
264
|
+
* Setting them directly works until the next time those change.
|
|
265
|
+
*/
|
|
266
|
+
interface GrapherStyleSettings {
|
|
267
|
+
/** Font size of axis numbers and labels. @defaultValue `14` (`19` in projector mode) */
|
|
268
|
+
labelSize: number;
|
|
269
|
+
majorAxisOpacity: number;
|
|
270
|
+
minorAxisOpacity: number;
|
|
271
|
+
axisOpacity: number;
|
|
272
|
+
axisLineWidth: number;
|
|
273
|
+
axisLineOffset: number;
|
|
274
|
+
/** Approximate spacing between axis numbers. */
|
|
275
|
+
pixelsPerLabel: number;
|
|
276
|
+
curveOpacity: number;
|
|
277
|
+
/** Overrides every curve's color when set. */
|
|
278
|
+
globalCurveColor?: HexColor;
|
|
279
|
+
disableFill: boolean;
|
|
280
|
+
graphLineWidth: number;
|
|
281
|
+
pointLineWidth: number;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
interface GrapherSettingsProperties extends GrapherStateSettings, GrapherStyleSettings {
|
|
285
|
+
/** Draw everything thicker, as for a selected expression. Unset until first used. */
|
|
286
|
+
highlight?: boolean;
|
|
287
|
+
/** Color of hanging labels: the background mixed 40% toward the text color. */
|
|
288
|
+
labelHangingColor: HexColor;
|
|
289
|
+
/** Which axis the user last zoomed alone; decides which axis "zoom square" keeps. */
|
|
290
|
+
lastChangedAxis: 'x' | 'y';
|
|
291
|
+
/** Set on the settings copy used while drawing a screenshot. */
|
|
292
|
+
takingScreenshot?: boolean;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The calculator configuration as seen by the grapher: the constructor
|
|
297
|
+
* options (`calculator.updateSettings()` writes here), observable by name.
|
|
298
|
+
*/
|
|
299
|
+
type GrapherConfig = Desmos.GraphingCalculatorConfig & ObservableModel<Desmos.GraphingCalculatorConfig> & { [option: string]: unknown };
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* `grapher2d.settings` (also `controller.getGraphSettings()`): graph
|
|
303
|
+
* settings and derived drawing settings, observable by name. Changing a
|
|
304
|
+
* state property through `setProperty` requests a redraw.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* const s = Calc.controller.grapher2d.settings;
|
|
308
|
+
* s.observe('showGrid.myMod', () => console.log('grid', s.showGrid));
|
|
309
|
+
* s.unobserve('showGrid.myMod');
|
|
310
|
+
*/
|
|
311
|
+
interface GrapherSettings
|
|
312
|
+
// Omitted members are redeclared by the other bases; Grapher2D's
|
|
313
|
+
// `extends Generated.Grapher2D` still checks the result against the bundle.
|
|
314
|
+
extends Omit<Generated.GrapherSettings, keyof ObservableModel<{}> | keyof GrapherSettingsProperties>,
|
|
315
|
+
GrapherSettingsProperties,
|
|
316
|
+
ObservableModel<GrapherSettingsProperties> {
|
|
317
|
+
controller: Controller;
|
|
318
|
+
config: GrapherConfig;
|
|
319
|
+
/** Names of the {@link GrapherStateSettings}. */
|
|
320
|
+
stateProperties: Array<Extract<keyof GrapherStateSettings, string>>;
|
|
321
|
+
/** Properties copied when the settings are cloned (for screenshots). */
|
|
322
|
+
cloneProperties: Array<Extract<keyof GrapherSettingsProperties, string>>;
|
|
323
|
+
/** Per style property: multipliers for [normal, highlighted, projector, projector + highlighted]. */
|
|
324
|
+
highlightPropertyMultipliers: Record<string, [number, number, number, number]>;
|
|
325
|
+
getHighlightPropertyMultiplier(name: 'curveOpacity' | 'graphLineWidth' | 'pointLineWidth', highlighted: boolean): number;
|
|
326
|
+
getFillOpacityMultiplier(): number;
|
|
327
|
+
getBackgroundColor(options?: { invertWhite?: boolean }): HexColor;
|
|
328
|
+
getTextColor(options?: { invertBlack?: boolean }): HexColor;
|
|
329
|
+
getAccentColor(options?: { invertBlack?: boolean }): HexColor;
|
|
330
|
+
getConfiguredBackgroundColor(): HexColor;
|
|
331
|
+
getConfiguredTextColor(): HexColor;
|
|
332
|
+
getConfiguredAccentColor(): HexColor;
|
|
333
|
+
cloneConfig(): Desmos.GraphingCalculatorConfig;
|
|
334
|
+
/** Validate and coerce settings as `updateSettings()` does, warning about bad values. */
|
|
335
|
+
validateSettings(settings: Partial<GrapherStateSettings>): Partial<GrapherStateSettings>;
|
|
336
|
+
_validateSetting<K extends keyof GrapherStateSettings>(name: K, value: unknown): GrapherStateSettings[K];
|
|
337
|
+
addStateProperty(name: string, defaultValue: unknown): void;
|
|
338
|
+
setController(controller: Controller): void;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// ---------------------------------------------------------------------------
|
|
342
|
+
// Events, layers, drawing
|
|
343
|
+
// ---------------------------------------------------------------------------
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* `grapher2d.events`. The grapher triggers `'redraw'` after every redraw,
|
|
347
|
+
* with the time it took in milliseconds.
|
|
348
|
+
*/
|
|
349
|
+
interface GrapherEvents extends Generated.Grapher2DEvents {
|
|
350
|
+
observeEvent(event: Desmos.EventName<'redraw'>, callback: (event: 'redraw', durationMs: number) => void): void;
|
|
351
|
+
unobserveEvent(event: Desmos.EventName<'redraw'> | `.${string}`): void;
|
|
352
|
+
triggerEvent(event: 'redraw', durationMs: number): void;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/** What every layer's `redrawToCtx` receives. */
|
|
356
|
+
interface DrawContext {
|
|
357
|
+
ctx: CanvasRenderingContext2D;
|
|
358
|
+
projection: Projection;
|
|
359
|
+
transformationPreviewParentData: {
|
|
360
|
+
translationPreviewVectorParents: Set<string>;
|
|
361
|
+
translationsWithVisibleVectorParent: Set<string>;
|
|
362
|
+
rotationPreviewAngleMarkerParents: Set<string>;
|
|
363
|
+
rotationsWithVisibleAndCenteredAngle: Set<string>;
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Options accepted by the grapher's own screenshot methods. The public
|
|
369
|
+
* `asyncScreenshot` handles `mode` and `mathBounds` itself and passes the
|
|
370
|
+
* rest through.
|
|
371
|
+
*/
|
|
372
|
+
interface GrapherScreenshotOptions extends Desmos.ScreenshotOptions {
|
|
373
|
+
format?: 'png' | 'svg';
|
|
374
|
+
showLabels?: boolean;
|
|
375
|
+
transparentBackground?: boolean;
|
|
376
|
+
/** Settings to override for the screenshot only. */
|
|
377
|
+
settings?: Partial<GrapherSettingsProperties>;
|
|
378
|
+
/** Render a tactile graphic for a braille embosser instead. */
|
|
379
|
+
braille?: { embosserModel: 'vpmax8' | 'vpmax11' | 'etc8' | 'etc11' | (string & {}); brailleMode: Desmos.BrailleMode };
|
|
380
|
+
/** SVG only: embed metadata describing the graphed items. */
|
|
381
|
+
includeJIM?: boolean;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** {@link GrapherScreenshotOptions} with defaults applied. */
|
|
385
|
+
interface ParsedScreenshotOptions {
|
|
386
|
+
width: number;
|
|
387
|
+
height: number;
|
|
388
|
+
targetPixelRatio: number;
|
|
389
|
+
settings: GrapherSettings;
|
|
390
|
+
transparentBackground: boolean;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** `grapher2d.getState()`: the `graph` part of the calculator state. */
|
|
394
|
+
type GrapherState = Partial<GrapherStateSettings> & {
|
|
395
|
+
viewport: LatexViewport;
|
|
396
|
+
__viewportEvaluatedForBackMigration: ViewportObject;
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
/** Graph settings and viewport as recorded in the undo history. */
|
|
400
|
+
type GrapherUndoState = { [K in keyof GrapherStateSettings]: GrapherStateSettings[K] } & { viewport: LatexViewport };
|
|
401
|
+
|
|
402
|
+
// ---------------------------------------------------------------------------
|
|
403
|
+
// Viewport controller
|
|
404
|
+
// ---------------------------------------------------------------------------
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Pans and zooms the graph paper (mouse wheel, touch, keyboard, zoom
|
|
408
|
+
* buttons) and keeps the viewport LaTeX in sync with the numeric viewport.
|
|
409
|
+
*
|
|
410
|
+
* To move the view from a mod, use `setCurrentViewport` (immediate) or
|
|
411
|
+
* `animateToViewport`. Neither adds an undo step; call
|
|
412
|
+
* `grapher2d.debounceUserRequestedViewportChange()` afterwards for that.
|
|
413
|
+
*/
|
|
414
|
+
interface ViewportController extends Generated.Grapher2DViewportController {
|
|
415
|
+
grapher: Grapher2D;
|
|
416
|
+
controller: Controller;
|
|
417
|
+
/** Pixel position of the mouse, relative to the graph paper. */
|
|
418
|
+
mousePt: Point;
|
|
419
|
+
/** The viewport as entered (may be expressions, e.g. `'2\\pi'`). */
|
|
420
|
+
currentViewportLatex: LatexViewport;
|
|
421
|
+
/** The viewport recorded in the undo history. */
|
|
422
|
+
undoViewportLatex: LatexViewport;
|
|
423
|
+
getViewport(): Viewport;
|
|
424
|
+
getProjection(): Projection;
|
|
425
|
+
getCurrentViewportLatex(): LatexViewport;
|
|
426
|
+
getUndoViewportLatex(): LatexViewport;
|
|
427
|
+
/** Jump to a viewport. Invalid axes keep their current bounds. */
|
|
428
|
+
setCurrentViewport(viewport: ViewportObject): void;
|
|
429
|
+
setCurrentViewportLatex(viewport: LatexViewport): void;
|
|
430
|
+
setUndoViewport(viewport: ViewportObject): void;
|
|
431
|
+
setUndoViewportLatex(viewport: LatexViewport): void;
|
|
432
|
+
/** Set the numeric viewport without touching the LaTeX. Cancels any animation. */
|
|
433
|
+
setEvaluatedViewport(viewport: ViewportObject): void;
|
|
434
|
+
_setViewportWithoutCancellingAnimation(viewport: ViewportObject): void;
|
|
435
|
+
/** Animate to a viewport over 500ms. */
|
|
436
|
+
animateToViewport(viewport: ViewportObject): void;
|
|
437
|
+
cancelAnimation(): void;
|
|
438
|
+
/** The zoom buttons. `'default'` restores the default viewport. */
|
|
439
|
+
zoom(kind: 'in' | 'out' | 'square' | 'default'): void;
|
|
440
|
+
/** Animate to a viewport and announce it to screen readers. */
|
|
441
|
+
zoomCustom(viewport: ViewportObject): void;
|
|
442
|
+
zoomHomeImmediately(): void;
|
|
443
|
+
zoomSquareImmediately(): void;
|
|
444
|
+
setDefaultViewport(): void;
|
|
445
|
+
/** The current viewport with one axis adjusted so the axes are square. */
|
|
446
|
+
getSquareViewport(): Viewport;
|
|
447
|
+
/**
|
|
448
|
+
* The viewport after applying a pixel-space transform (anything with
|
|
449
|
+
* `mapRect`), e.g. a translation by the drag distance.
|
|
450
|
+
*/
|
|
451
|
+
getTransformedViewport(transform: { mapRect(rect: PixelRect): { left: number; right: number; bottom: number; top: number } }): Viewport;
|
|
452
|
+
transformViewport(transform: { mapRect(rect: PixelRect): { left: number; right: number; bottom: number; top: number } }): void;
|
|
453
|
+
/** Pan by 5 pixels, as the arrow keys do. */
|
|
454
|
+
panFromKeyboard(direction: 'Up' | 'Down' | 'Left' | 'Right'): void;
|
|
455
|
+
/** Zooming out further would exceed the limits (log axes, geometry). */
|
|
456
|
+
tooBig(viewport: ViewportObject): boolean;
|
|
457
|
+
tooSmall(viewport: ViewportObject): boolean;
|
|
458
|
+
setScreen(screen: Screen): void;
|
|
459
|
+
/** Whether zoom and pan are disabled (`lockViewport` or the user lock). */
|
|
460
|
+
isViewportLocked(): boolean;
|
|
461
|
+
isDefaultViewportRestored(): boolean;
|
|
462
|
+
/** Pixel point to scale about when dragging an axis: the origin, clamped to the screen. */
|
|
463
|
+
chooseDragScaleCenter(): Point;
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// ---------------------------------------------------------------------------
|
|
467
|
+
// Grapher2D
|
|
468
|
+
// ---------------------------------------------------------------------------
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* The rest of the 2D grapher (merged into the `Grapher2D` declared in
|
|
472
|
+
* controller.d.ts). Sketch members are in graph-sketches.d.ts.
|
|
473
|
+
*/
|
|
474
|
+
interface Grapher2D {
|
|
475
|
+
type: '2d';
|
|
476
|
+
elt: HTMLDivElement;
|
|
477
|
+
settings: GrapherSettings;
|
|
478
|
+
events: GrapherEvents;
|
|
479
|
+
viewportController: ViewportController;
|
|
480
|
+
__projection: Projection;
|
|
481
|
+
/** The viewport at the last animation frame (unset before the first one); used to detect viewport changes. */
|
|
482
|
+
lastTickViewport?: Viewport;
|
|
483
|
+
/** Image items currently drawn, keyed by id. Images are added once loaded. */
|
|
484
|
+
graphImages: Record<ExpressionId, ImageModel>;
|
|
485
|
+
/** Which geometry token (the chips in the toolbar) is hovered or selected, as an expression id. */
|
|
486
|
+
lastActiveToken: { selected?: ExpressionId; hovered?: ExpressionId };
|
|
487
|
+
/** Which axis a drag scales, from where the mouse is: near an axis, or elsewhere (`'both'`). */
|
|
488
|
+
scaleAxis?: 'x' | 'y' | 'both';
|
|
489
|
+
/** Set while the user is dragging the graph paper. */
|
|
490
|
+
isDragging?: boolean;
|
|
491
|
+
/** Draw POI dots of selected sketches. */
|
|
492
|
+
showPOIDots: boolean;
|
|
493
|
+
isVisible: boolean;
|
|
494
|
+
__redrawRequested: boolean;
|
|
495
|
+
__drawLayers: DrawLayer[];
|
|
496
|
+
/** Ids in keyboard tab order. */
|
|
497
|
+
__tabOrder: string[];
|
|
498
|
+
/** CSS class names on `elt`, keyed by who set them (see `setLayerClass`). */
|
|
499
|
+
_layerClasses: Record<string, string | undefined>;
|
|
500
|
+
_classLayers: Record<string, Set<string>>;
|
|
501
|
+
|
|
502
|
+
/** The current projection. Replaced on every pan, zoom or resize. */
|
|
503
|
+
getProjection(): Projection;
|
|
504
|
+
_setProjection(projection: Projection): void;
|
|
505
|
+
/** The current viewport as numbers. */
|
|
506
|
+
getCurrentViewport(): ViewportObject;
|
|
507
|
+
/** The viewport `setBlank()` would show. */
|
|
508
|
+
getDefaultViewport(): Viewport;
|
|
509
|
+
/** `viewport` with its y axis squared if `squareAxes` is on. */
|
|
510
|
+
computeConcreteViewport(viewport: Viewport): Viewport;
|
|
511
|
+
/** Load the viewport (and nothing else) from a state's `graph.viewport`. */
|
|
512
|
+
setViewportState(viewport: LatexViewport): void;
|
|
513
|
+
/** Record the current viewport as an undo step after 200ms without changes. */
|
|
514
|
+
debounceUserRequestedViewportChange(): void;
|
|
515
|
+
_updateScreenSize(width: number, height: number): void;
|
|
516
|
+
/** Size of the canvas in CSS pixels. */
|
|
517
|
+
size(): Screen;
|
|
518
|
+
|
|
519
|
+
/** Request a redraw on the next animation frame. */
|
|
520
|
+
redrawAllLayers(): void;
|
|
521
|
+
/** Redraw now. Fires the `'redraw'` event. */
|
|
522
|
+
redrawAllLayersSynchronously(): void;
|
|
523
|
+
_redrawAllLayers(): void;
|
|
524
|
+
_redrawGrapher(context: DrawContext | undefined): void;
|
|
525
|
+
/** Call `callback` after the pending redraw, or now if none is pending. */
|
|
526
|
+
notifyAfterRedraw(callback: () => void): void;
|
|
527
|
+
/** Runs every animation frame; redraws if requested. */
|
|
528
|
+
tick(now?: number): void;
|
|
529
|
+
/** The drawing context for the visible canvas, or `undefined` before the canvas exists. */
|
|
530
|
+
createDrawContext(): DrawContext | undefined;
|
|
531
|
+
getCanvasNode(): HTMLCanvasElement;
|
|
532
|
+
/** Read pixels from the visible canvas (physical pixels, not CSS pixels). */
|
|
533
|
+
getImageData(x: number, y: number, width: number, height: number): ImageData | undefined;
|
|
534
|
+
/** Clear the canvas. */
|
|
535
|
+
_clear(): void;
|
|
536
|
+
/** Forget all sketches and images. They come back as the evaluator updates them. */
|
|
537
|
+
clear(): void;
|
|
538
|
+
update(): void;
|
|
539
|
+
remove(): void;
|
|
540
|
+
|
|
541
|
+
getDrawLayers(): DrawLayer[];
|
|
542
|
+
/** Replace the draw layers. The controller resets them from the expression list on each update. */
|
|
543
|
+
setDrawLayers(layers: DrawLayer[]): void;
|
|
544
|
+
/** Every layer's `drawOrder`, concatenated. Layers are in list-model.d.ts. */
|
|
545
|
+
generateMergeDrawOrder(): Generator<string, void, undefined>;
|
|
546
|
+
getTabOrder(): string[];
|
|
547
|
+
setTabOrder(order: string[]): void;
|
|
548
|
+
/**
|
|
549
|
+
* Put a CSS class on the grapher element on behalf of `owner`, replacing
|
|
550
|
+
* that owner's previous class (`undefined` removes it). Used for cursors,
|
|
551
|
+
* e.g. owner `'movablePoints'` with `'dcg-mouse-over-movable-point'`.
|
|
552
|
+
*/
|
|
553
|
+
setLayerClass(owner: string, className: string | undefined): void;
|
|
554
|
+
classLayers(className: string): Set<string>;
|
|
555
|
+
|
|
556
|
+
getGraphImage(id: ExpressionId): ImageModel | undefined;
|
|
557
|
+
/** Starts drawing an image once it has loaded. */
|
|
558
|
+
addGraphImage(image: ImageModel): void;
|
|
559
|
+
removeGraphImage(id: ExpressionId): void;
|
|
560
|
+
|
|
561
|
+
setActiveToken(id: ExpressionId | undefined, kind: 'selected' | 'hovered'): void;
|
|
562
|
+
/** Pixel rectangle of the geometry box selection, or `undefined` for none. */
|
|
563
|
+
setBoxSelectRectangle(rect: PixelRect | undefined): void;
|
|
564
|
+
/** Called every frame before drawing; used while dragging points. */
|
|
565
|
+
registerMovablePointListener(listener: () => void): void;
|
|
566
|
+
deregisterMovablePointListener(): void;
|
|
567
|
+
|
|
568
|
+
/** PNG data URI. `showLabels` is ignored here; use `asyncScreenshot`. */
|
|
569
|
+
screenshot(options?: GrapherScreenshotOptions): string;
|
|
570
|
+
/** PNG data URI or SVG string, depending on `format`. */
|
|
571
|
+
asyncScreenshot(options: GrapherScreenshotOptions | undefined, callback: (data: string) => void): void;
|
|
572
|
+
screenshotToCanvas(
|
|
573
|
+
canvas: HTMLCanvasElement | { getContext(type: '2d'): CanvasRenderingContext2D; width: number; height: number },
|
|
574
|
+
options?: GrapherScreenshotOptions
|
|
575
|
+
): void;
|
|
576
|
+
makeScreenshotProjection(options?: GrapherScreenshotOptions): Projection;
|
|
577
|
+
_parseScreenshotOpts(options?: GrapherScreenshotOptions): ParsedScreenshotOptions;
|
|
578
|
+
_syncScreenshotReturnCanvas(options?: GrapherScreenshotOptions): HTMLCanvasElement;
|
|
579
|
+
|
|
580
|
+
/** The `graph` part of the calculator state. */
|
|
581
|
+
getState(options: { stripDefaults?: boolean }): GrapherState;
|
|
582
|
+
/** Load graph settings and viewport from a state. Clears sketches unless `doNotClear`. */
|
|
583
|
+
setGrapherState(state: Partial<GrapherState>, options?: { doNotClear?: boolean }): void;
|
|
584
|
+
getUndoRedoFullState(): GrapherUndoState;
|
|
585
|
+
/** Like `getUndoRedoFullState`, without `worldRotation3D` while auto-rotating. */
|
|
586
|
+
getUndoRedoDiffState(): Partial<GrapherUndoState>;
|
|
587
|
+
|
|
588
|
+
getIsVisible(): boolean;
|
|
589
|
+
_setIsVisible(visible: boolean): void;
|
|
590
|
+
}
|
|
591
|
+
}
|
package/internals/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
/// <reference path="./actions.d.ts" />
|
|
19
19
|
/// <reference path="./dispatcher.d.ts" />
|
|
20
20
|
/// <reference path="./graph-sketches.d.ts" />
|
|
21
|
+
/// <reference path="./grapher2d.d.ts" />
|
|
21
22
|
/// <reference path="./controller.d.ts" />
|
|
22
23
|
/// <reference path="./sub-controllers.d.ts" />
|
|
23
24
|
/// <reference path="./dcgview.d.ts" />
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `controller.listModel`: the expressions list, its lookup tables and
|
|
3
|
-
* selection state.
|
|
4
|
-
*/
|
|
5
|
-
declare namespace Desmos.Internals {
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `controller.listModel`: the expressions list, its lookup tables and
|
|
3
|
+
* selection state.
|
|
4
|
+
*/
|
|
5
|
+
declare namespace Desmos.Internals {
|
|
6
|
+
/**
|
|
7
|
+
* One pass of drawing. Layer `-1` holds background images (drawn under the
|
|
8
|
+
* grid), `0` everything else, and `1` folders marked "in front of
|
|
9
|
+
* everything". Layers -1 and 1 only exist when non-empty.
|
|
10
|
+
*/
|
|
11
|
+
interface DrawLayer {
|
|
12
|
+
layer: -1 | 0 | 1;
|
|
13
|
+
/** Item ids (table column ids for tables) in paint order, back to front. */
|
|
14
|
+
drawOrder: ExpressionId[];
|
|
15
|
+
drawSet: Set<ExpressionId>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ListModel extends Generated.ListModel {
|
|
19
|
+
controller: Controller;
|
|
20
|
+
/** Every item, in list order. Prefer `controller.getAllItemModels()`. */
|
|
21
|
+
__itemModelArray: ItemModel[];
|
|
22
|
+
/** Items by id. Prefer `controller.getItemModel(id)`. */
|
|
23
|
+
__itemIdToModel: Record<ExpressionId, ItemModel>;
|
|
24
|
+
/** Helper expressions by id. */
|
|
25
|
+
__helperIdToModel: Record<string, unknown>;
|
|
26
|
+
/** Ids of selected items. */
|
|
27
|
+
selectedItemMap: Record<ExpressionId, unknown>;
|
|
28
|
+
/** Item ids in keyboard tab order. */
|
|
29
|
+
tabOrder: ExpressionId[];
|
|
30
|
+
drawLayers: DrawLayer[];
|
|
31
|
+
/** Index into the palette for the next new item's color. */
|
|
32
|
+
colorIdx: number;
|
|
33
|
+
expressionAnalysis: Record<ExpressionId, ExpressionAnalysis>;
|
|
34
|
+
ticker: TickerModel;
|
|
35
|
+
}
|
|
36
|
+
}
|