This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstate.ts
237 lines (219 loc) · 5.54 KB
/
state.ts
1
2
3
4
5
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/**
* Reference sources:
* - core/types/*
* - graphing-calc/models/*
* - core/graphing-calc/json/*
* - core/graphing-calc/migrations/*
* - main/graph_settings
* - https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/desmos/index.d.ts
*/
export interface GraphState {
version: 9;
randomSeed?: string;
graph: GrapherState;
expressions: {
list: ItemState[];
ticker?: Ticker;
};
}
export interface Ticker {
handlerLatex?: Latex;
minStepLatex?: Latex;
open?: boolean;
playing?: boolean;
}
export type ArrowMode = "NONE" | "POSITIVE" | "BOTH";
export interface GrapherState {
viewport: {
xmin: number;
ymin: number;
xmax: number;
ymax: number;
};
// {x,y}AxisMinorSubdivisions appears to be either 5 or 0 (disabled)
// but Desmos accepts other subdivisions
xAxisMinorSubdivisions?: number;
yAxisMinorSubdivisions?: number;
degreeMode?: boolean;
showGrid?: boolean;
showXAxis?: boolean;
showYAxis?: boolean;
// the UI appears to only have xAxisNumbers = yAxisNumbers = polarNumbers
xAxisNumbers?: boolean;
yAxisNumbers?: boolean;
polarNumbers?: boolean;
// {x,y}AxisStep are interesting. The user can put any LaTeX, but the result is stored as a
// number and displayed as a number or multiple of pi
xAxisStep?: number;
yAxisStep?: number;
xAxisArrowMode?: ArrowMode;
yAxisArrowMode?: ArrowMode;
xAxisLabel?: string;
yAxisLabel?: string;
squareAxes?: boolean;
restrictGridToFirstQuadrant?: boolean;
polarMode?: boolean;
userLockedViewport?: boolean;
}
type Latex = string;
type ID = string;
export type ItemState = NonFolderState | FolderState;
export type NonFolderState =
| ExpressionState
| ImageState
| TableState
| TextState;
interface BaseItemState {
id: ID;
secret?: boolean;
}
interface BaseNonFolderState extends BaseItemState {
folderId?: ID;
}
export type LineStyle = "SOLID" | "DASHED" | "DOTTED";
export type PointStyle = "POINT" | "OPEN" | "CROSS";
export type DragMode = "NONE" | "X" | "Y" | "XY" | "AUTO";
export type LabelSize = "SMALL" | "MEDIUM" | "LARGE" | Latex;
export type LabelOrientation =
| "default"
| "center"
| "center_auto"
| "auto_center"
| "above"
| "above_left"
| "above_right"
| "above_auto"
| "below"
| "below_left"
| "below_right"
| "below_auto"
| "left"
| "auto_left"
| "right"
| "auto_right";
export interface Domain {
min: Latex;
max: Latex;
}
export interface BaseClickable {
enabled?: boolean;
// description is the screen reader label
description?: string;
latex?: Latex;
}
interface ExpressionStateWithoutColumn extends BaseNonFolderState {
type: "expression";
showLabel?: boolean;
fill?: boolean;
fillOpacity?: Latex;
label?: string;
labelSize?: LabelSize;
labelOrientation?: LabelOrientation;
labelAngle?: Latex;
suppressTextOutline?: boolean;
// interactiveLabel is show-on-hover
interactiveLabel?: boolean;
editableLabelMode?: "MATH" | "TEXT";
residualVariable?: Latex;
regressionParameters?: {
// key should be Latex, but type aliases are not allowed as keys
[key: string]: number;
};
isLogModeRegression?: boolean;
displayEvaluationAsFraction?: boolean;
slider?: {
hardMin?: boolean;
hardMax?: boolean;
animationPeriod?: number;
loopMode?:
| "LOOP_FORWARD_REVERSE"
| "LOOP_FORWARD"
| "PLAY_ONCE"
| "PLAY_INDEFINITELY";
playDirection?: 1 | -1;
isPlaying?: boolean;
min?: Latex;
max?: Latex;
step?: Latex;
};
polarDomain?: Domain;
parametricDomain?: Domain;
// seems like `domain` may be the same as `parametricDomain`
domain?: Domain;
cdf?: {
show: boolean;
min?: Latex;
max?: Latex;
};
vizProps?: {
// -- Applies to boxplot only:
// axisOffset=offset and breadth=height (boxplots only)
breadth?: Latex;
axisOffset?: Latex;
alignedAxis?: "x" | "y";
showBoxplotOutliers?: boolean;
// -- Applies to dotplot only:
// the string "binned" is never actually checked,
// just inferred by the absence of "exact"
dotplotXMode?: "exact" | "binned";
// -- applies to dotplot and histogram only:
binAlignment?: "left" | "center";
// -- applies to histogram only:
// the string "count" is never actually checked,
// just inferred by the absence of "relative" and "density"
histogramMode?: "count" | "relative" | "density";
};
clickableInfo?: BaseClickable;
}
export type ExpressionState = ExpressionStateWithoutColumn &
ColumnExpressionShared;
export interface ImageState extends BaseNonFolderState {
type: "image";
image_url: string;
name?: string;
width?: Latex;
height?: Latex;
hidden?: boolean;
center?: Latex;
angle?: Latex;
opacity?: Latex;
foreground?: boolean;
draggable?: boolean;
clickableInfo?: BaseClickable & {
hoveredImage?: string;
depressedImage?: string;
};
}
export type TableColumn = {
id: ID;
values: Latex[];
} & ColumnExpressionShared;
export interface ColumnExpressionShared {
color: string;
latex?: Latex;
hidden?: boolean;
points?: boolean;
lines?: boolean;
dragMode?: DragMode;
lineStyle?: LineStyle;
pointStyle?: PointStyle;
colorLatex?: Latex;
lineOpacity?: Latex;
lineWidth?: Latex;
pointSize?: Latex;
pointOpacity?: Latex;
}
export interface TableState extends BaseNonFolderState {
type: "table";
columns: TableColumn[];
}
export interface FolderState extends BaseItemState {
type: "folder";
hidden?: boolean;
collapsed?: boolean;
title?: string;
}
export interface TextState extends BaseNonFolderState {
type: "text";
text?: string;
}