@khanacademy/perseus 37.0.1 → 38.0.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/dist/es/index.js +89 -60
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +89 -60
- package/dist/index.js.map +1 -1
- package/dist/multi-items/item-types.d.ts +4 -3
- package/dist/perseus-api.d.ts +6 -6
- package/dist/perseus-types.d.ts +31 -30
- package/dist/server-item-renderer.d.ts +6 -6
- package/dist/types.d.ts +1 -4
- package/dist/validation.types.d.ts +12 -13
- package/dist/widgets/expression/expression.d.ts +36 -36
- package/dist/widgets/grapher/grapher-types.d.ts +58 -0
- package/dist/widgets/grapher/grapher-validator.d.ts +1 -1
- package/dist/widgets/grapher/util.d.ts +16 -3
- package/dist/widgets/input-number/input-number-validator.d.ts +2 -4
- package/dist/widgets/label-image/label-image-validator.d.ts +1 -1
- package/dist/widgets/label-image/label-image.d.ts +14 -14
- package/package.json +2 -2
|
@@ -9,18 +9,19 @@
|
|
|
9
9
|
* - And the various types of nodes that compose a tree.
|
|
10
10
|
*/
|
|
11
11
|
import type { Tree, ArrayNode, ObjectNode } from "./tree-types";
|
|
12
|
-
import type {
|
|
12
|
+
import type { PerseusWidgetsMap } from "../perseus-types";
|
|
13
|
+
import type { ImageDict } from "../types";
|
|
13
14
|
export type ContentNode = {
|
|
14
15
|
__type: "content" | "item";
|
|
15
16
|
content?: string | null | undefined;
|
|
16
17
|
images?: ImageDict | null | undefined;
|
|
17
|
-
widgets?:
|
|
18
|
+
widgets?: PerseusWidgetsMap | null | undefined;
|
|
18
19
|
};
|
|
19
20
|
export type HintNode = {
|
|
20
21
|
__type: "hint";
|
|
21
22
|
content?: string | null | undefined;
|
|
22
23
|
images?: ImageDict | null | undefined;
|
|
23
|
-
widgets?:
|
|
24
|
+
widgets?: PerseusWidgetsMap | null | undefined;
|
|
24
25
|
replace?: boolean | null | undefined;
|
|
25
26
|
};
|
|
26
27
|
export type TagsNode = ReadonlyArray<string>;
|
package/dist/perseus-api.d.ts
CHANGED
|
@@ -89,18 +89,18 @@ export declare const ApiOptions: {
|
|
|
89
89
|
editorChangeDelay?: number | undefined;
|
|
90
90
|
flags?: {
|
|
91
91
|
mafs?: false | ({
|
|
92
|
-
circle?: boolean | undefined;
|
|
93
|
-
polygon?: boolean | undefined;
|
|
94
92
|
none?: boolean | undefined;
|
|
95
93
|
linear?: boolean | undefined;
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
circle?: boolean | undefined;
|
|
95
|
+
polygon?: boolean | undefined;
|
|
98
96
|
point?: boolean | undefined;
|
|
99
|
-
ray?: boolean | undefined;
|
|
100
|
-
segment?: boolean | undefined;
|
|
101
97
|
angle?: boolean | undefined;
|
|
98
|
+
segment?: boolean | undefined;
|
|
102
99
|
"linear-system"?: boolean | undefined;
|
|
100
|
+
ray?: boolean | undefined;
|
|
103
101
|
"unlimited-polygon"?: boolean | undefined;
|
|
102
|
+
quadratic?: boolean | undefined;
|
|
103
|
+
sinusoid?: boolean | undefined;
|
|
104
104
|
"unlimited-point"?: boolean | undefined;
|
|
105
105
|
} & {
|
|
106
106
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
package/dist/perseus-types.d.ts
CHANGED
|
@@ -248,38 +248,39 @@ export type GraphRange = [
|
|
|
248
248
|
x: [min: number, max: number],
|
|
249
249
|
y: [min: number, max: number]
|
|
250
250
|
];
|
|
251
|
+
export type GrapherAnswerTypes = {
|
|
252
|
+
type: "absolute_value";
|
|
253
|
+
coords: [
|
|
254
|
+
Coord,
|
|
255
|
+
Coord
|
|
256
|
+
];
|
|
257
|
+
} | {
|
|
258
|
+
type: "exponential";
|
|
259
|
+
asymptote: [Coord, Coord];
|
|
260
|
+
coords: [Coord, Coord];
|
|
261
|
+
} | {
|
|
262
|
+
type: "linear";
|
|
263
|
+
coords: [Coord, Coord];
|
|
264
|
+
} | {
|
|
265
|
+
type: "logarithm";
|
|
266
|
+
asymptote: [Coord, Coord];
|
|
267
|
+
coords: [Coord, Coord];
|
|
268
|
+
} | {
|
|
269
|
+
type: "quadratic";
|
|
270
|
+
coords: [
|
|
271
|
+
Coord,
|
|
272
|
+
Coord
|
|
273
|
+
];
|
|
274
|
+
} | {
|
|
275
|
+
type: "sinusoid";
|
|
276
|
+
coords: [Coord, Coord];
|
|
277
|
+
} | {
|
|
278
|
+
type: "tangent";
|
|
279
|
+
coords: [Coord, Coord];
|
|
280
|
+
};
|
|
251
281
|
export type PerseusGrapherWidgetOptions = {
|
|
252
282
|
availableTypes: ReadonlyArray<"absolute_value" | "exponential" | "linear" | "logarithm" | "quadratic" | "sinusoid" | "tangent">;
|
|
253
|
-
correct:
|
|
254
|
-
type: "absolute_value";
|
|
255
|
-
coords: [
|
|
256
|
-
Coord,
|
|
257
|
-
Coord
|
|
258
|
-
];
|
|
259
|
-
} | {
|
|
260
|
-
type: "exponential";
|
|
261
|
-
asymptote: [Coord, Coord];
|
|
262
|
-
coords: [Coord, Coord];
|
|
263
|
-
} | {
|
|
264
|
-
type: "linear";
|
|
265
|
-
coords: [Coord, Coord];
|
|
266
|
-
} | {
|
|
267
|
-
type: "logarithm";
|
|
268
|
-
asymptote: [Coord, Coord];
|
|
269
|
-
coords: [Coord, Coord];
|
|
270
|
-
} | {
|
|
271
|
-
type: "quadratic";
|
|
272
|
-
coords: [
|
|
273
|
-
Coord,
|
|
274
|
-
Coord
|
|
275
|
-
];
|
|
276
|
-
} | {
|
|
277
|
-
type: "sinusoid";
|
|
278
|
-
coords: [Coord, Coord];
|
|
279
|
-
} | {
|
|
280
|
-
type: "tangent";
|
|
281
|
-
coords: [Coord, Coord];
|
|
282
|
-
};
|
|
283
|
+
correct: GrapherAnswerTypes;
|
|
283
284
|
graph: {
|
|
284
285
|
backgroundImage: {
|
|
285
286
|
bottom?: number;
|
|
@@ -128,18 +128,18 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<SharedRendererProps
|
|
|
128
128
|
editorChangeDelay?: number | undefined;
|
|
129
129
|
flags?: {
|
|
130
130
|
mafs?: false | ({
|
|
131
|
-
circle?: boolean | undefined;
|
|
132
|
-
polygon?: boolean | undefined;
|
|
133
131
|
none?: boolean | undefined;
|
|
134
132
|
linear?: boolean | undefined;
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
circle?: boolean | undefined;
|
|
134
|
+
polygon?: boolean | undefined;
|
|
137
135
|
point?: boolean | undefined;
|
|
138
|
-
ray?: boolean | undefined;
|
|
139
|
-
segment?: boolean | undefined;
|
|
140
136
|
angle?: boolean | undefined;
|
|
137
|
+
segment?: boolean | undefined;
|
|
141
138
|
"linear-system"?: boolean | undefined;
|
|
139
|
+
ray?: boolean | undefined;
|
|
142
140
|
"unlimited-polygon"?: boolean | undefined;
|
|
141
|
+
quadratic?: boolean | undefined;
|
|
142
|
+
sinusoid?: boolean | undefined;
|
|
143
143
|
"unlimited-point"?: boolean | undefined;
|
|
144
144
|
} & {
|
|
145
145
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -57,9 +57,6 @@ export interface Widget {
|
|
|
57
57
|
showRationalesForCurrentlySelectedChoices?: (options?: any) => void;
|
|
58
58
|
examples?: () => ReadonlyArray<string>;
|
|
59
59
|
}
|
|
60
|
-
export type WidgetDict = {
|
|
61
|
-
[name: string]: PerseusWidget;
|
|
62
|
-
};
|
|
63
60
|
export type ImageDict = {
|
|
64
61
|
[url: string]: Dimensions;
|
|
65
62
|
};
|
|
@@ -91,7 +88,7 @@ export type ChangeHandler = (arg1: {
|
|
|
91
88
|
hints?: ReadonlyArray<Hint>;
|
|
92
89
|
replace?: boolean;
|
|
93
90
|
content?: string;
|
|
94
|
-
widgets?:
|
|
91
|
+
widgets?: PerseusWidgetsMap;
|
|
95
92
|
images?: ImageDict;
|
|
96
93
|
question?: any;
|
|
97
94
|
answerArea?: PerseusAnswerArea | null;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { PerseusDefinitionWidgetOptions, PerseusDropdownChoice, PerseusExplanationWidgetOptions, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGrapherWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusIFrameWidgetOptions, PerseusImageWidgetOptions, PerseusInputNumberWidgetOptions, PerseusInteractionWidgetOptions, PerseusLabelImageWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, PerseusNumericInputWidgetOptions, PerseusOrdererWidgetOptions, PerseusPassageRefWidgetOptions, PerseusPassageWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioWidgetOptions, PerseusSorterWidgetOptions, PerseusTableWidgetOptions, PerseusVideoWidgetOptions } from "./perseus-types";
|
|
1
|
+
import type { GrapherAnswerTypes, PerseusDefinitionWidgetOptions, PerseusDropdownChoice, PerseusExplanationWidgetOptions, PerseusExpressionAnswerForm, PerseusGradedGroupSetWidgetOptions, PerseusGradedGroupWidgetOptions, PerseusGraphType, PerseusGroupWidgetOptions, PerseusIFrameWidgetOptions, PerseusImageWidgetOptions, PerseusInteractionWidgetOptions, PerseusMatcherWidgetOptions, PerseusMatrixWidgetOptions, PerseusNumberLineWidgetOptions, PerseusNumericInputWidgetOptions, PerseusOrdererWidgetOptions, PerseusPassageRefWidgetOptions, PerseusPassageWidgetOptions, PerseusPlotterWidgetOptions, PerseusRadioWidgetOptions, PerseusSorterWidgetOptions, PerseusTableWidgetOptions, PerseusVideoWidgetOptions } from "./perseus-types";
|
|
3
2
|
import type { InteractiveMarkerType } from "./widgets/label-image/types";
|
|
4
3
|
import type { Relationship } from "./widgets/number-line/number-line";
|
|
5
4
|
export type UserInputStatus = "correct" | "incorrect" | "incomplete";
|
|
@@ -30,23 +29,23 @@ export type PerseusExpressionUserInput = string;
|
|
|
30
29
|
export type PerseusGroupRubric = PerseusGroupWidgetOptions;
|
|
31
30
|
export type PerseusGradedGroupRubric = PerseusGradedGroupWidgetOptions;
|
|
32
31
|
export type PerseusGradedGroupSetRubric = PerseusGradedGroupSetWidgetOptions;
|
|
33
|
-
export type PerseusGrapherRubric =
|
|
34
|
-
|
|
35
|
-
* TODO: this is kind of just a guess right now
|
|
36
|
-
* based off of an old comment in grapher
|
|
37
|
-
*/
|
|
38
|
-
export type PerseusGrapherUserInput = {
|
|
39
|
-
type: string;
|
|
40
|
-
asymptote: ReadonlyArray<Coord>;
|
|
41
|
-
coords: ReadonlyArray<Coord>;
|
|
32
|
+
export type PerseusGrapherRubric = {
|
|
33
|
+
correct: GrapherAnswerTypes;
|
|
42
34
|
};
|
|
35
|
+
export type PerseusGrapherUserInput = PerseusGrapherRubric["correct"];
|
|
43
36
|
export type PerseusIFrameRubric = PerseusIFrameWidgetOptions;
|
|
44
37
|
export type PerseusIFrameUserInput = {
|
|
45
38
|
status: UserInputStatus;
|
|
46
39
|
message: string | null;
|
|
47
40
|
};
|
|
48
41
|
export type PerseusImageRubric = PerseusImageWidgetOptions;
|
|
49
|
-
export type PerseusInputNumberRubric =
|
|
42
|
+
export type PerseusInputNumberRubric = {
|
|
43
|
+
answerType?: "number" | "decimal" | "integer" | "rational" | "improper" | "mixed" | "percent" | "pi";
|
|
44
|
+
inexact?: boolean;
|
|
45
|
+
maxError?: number | string;
|
|
46
|
+
simplify: "required" | "optional" | "enforced";
|
|
47
|
+
value: string | number;
|
|
48
|
+
};
|
|
50
49
|
export type PerseusInputNumberUserInput = {
|
|
51
50
|
currentValue: string;
|
|
52
51
|
};
|
|
@@ -56,7 +55,7 @@ export type PerseusInteractiveGraphRubric = {
|
|
|
56
55
|
graph: PerseusGraphType;
|
|
57
56
|
};
|
|
58
57
|
export type PerseusInteractiveGraphUserInput = PerseusGraphType;
|
|
59
|
-
export type PerseusLabelImageRubric =
|
|
58
|
+
export type PerseusLabelImageRubric = Empty;
|
|
60
59
|
export type PerseusLabelImageUserInput = {
|
|
61
60
|
markers: ReadonlyArray<InteractiveMarkerType>;
|
|
62
61
|
};
|
|
@@ -127,18 +127,18 @@ declare const _default: Readonly<{
|
|
|
127
127
|
editorChangeDelay?: number | undefined;
|
|
128
128
|
flags?: {
|
|
129
129
|
mafs?: false | ({
|
|
130
|
-
circle?: boolean | undefined;
|
|
131
|
-
polygon?: boolean | undefined;
|
|
132
130
|
none?: boolean | undefined;
|
|
133
131
|
linear?: boolean | undefined;
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
circle?: boolean | undefined;
|
|
133
|
+
polygon?: boolean | undefined;
|
|
136
134
|
point?: boolean | undefined;
|
|
137
|
-
ray?: boolean | undefined;
|
|
138
|
-
segment?: boolean | undefined;
|
|
139
135
|
angle?: boolean | undefined;
|
|
136
|
+
segment?: boolean | undefined;
|
|
140
137
|
"linear-system"?: boolean | undefined;
|
|
138
|
+
ray?: boolean | undefined;
|
|
141
139
|
"unlimited-polygon"?: boolean | undefined;
|
|
140
|
+
quadratic?: boolean | undefined;
|
|
141
|
+
sinusoid?: boolean | undefined;
|
|
142
142
|
"unlimited-point"?: boolean | undefined;
|
|
143
143
|
} & {
|
|
144
144
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
|
@@ -213,18 +213,18 @@ declare const _default: Readonly<{
|
|
|
213
213
|
editorChangeDelay?: number | undefined;
|
|
214
214
|
flags?: {
|
|
215
215
|
mafs?: false | ({
|
|
216
|
-
circle?: boolean | undefined;
|
|
217
|
-
polygon?: boolean | undefined;
|
|
218
216
|
none?: boolean | undefined;
|
|
219
217
|
linear?: boolean | undefined;
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
circle?: boolean | undefined;
|
|
219
|
+
polygon?: boolean | undefined;
|
|
222
220
|
point?: boolean | undefined;
|
|
223
|
-
ray?: boolean | undefined;
|
|
224
|
-
segment?: boolean | undefined;
|
|
225
221
|
angle?: boolean | undefined;
|
|
222
|
+
segment?: boolean | undefined;
|
|
226
223
|
"linear-system"?: boolean | undefined;
|
|
224
|
+
ray?: boolean | undefined;
|
|
227
225
|
"unlimited-polygon"?: boolean | undefined;
|
|
226
|
+
quadratic?: boolean | undefined;
|
|
227
|
+
sinusoid?: boolean | undefined;
|
|
228
228
|
"unlimited-point"?: boolean | undefined;
|
|
229
229
|
} & {
|
|
230
230
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
|
@@ -300,18 +300,18 @@ declare const _default: Readonly<{
|
|
|
300
300
|
editorChangeDelay?: number | undefined;
|
|
301
301
|
flags?: {
|
|
302
302
|
mafs?: false | ({
|
|
303
|
-
circle?: boolean | undefined;
|
|
304
|
-
polygon?: boolean | undefined;
|
|
305
303
|
none?: boolean | undefined;
|
|
306
304
|
linear?: boolean | undefined;
|
|
307
|
-
|
|
308
|
-
|
|
305
|
+
circle?: boolean | undefined;
|
|
306
|
+
polygon?: boolean | undefined;
|
|
309
307
|
point?: boolean | undefined;
|
|
310
|
-
ray?: boolean | undefined;
|
|
311
|
-
segment?: boolean | undefined;
|
|
312
308
|
angle?: boolean | undefined;
|
|
309
|
+
segment?: boolean | undefined;
|
|
313
310
|
"linear-system"?: boolean | undefined;
|
|
311
|
+
ray?: boolean | undefined;
|
|
314
312
|
"unlimited-polygon"?: boolean | undefined;
|
|
313
|
+
quadratic?: boolean | undefined;
|
|
314
|
+
sinusoid?: boolean | undefined;
|
|
315
315
|
"unlimited-point"?: boolean | undefined;
|
|
316
316
|
} & {
|
|
317
317
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
|
@@ -384,18 +384,18 @@ declare const _default: Readonly<{
|
|
|
384
384
|
editorChangeDelay?: number | undefined;
|
|
385
385
|
flags?: {
|
|
386
386
|
mafs?: false | ({
|
|
387
|
-
circle?: boolean | undefined;
|
|
388
|
-
polygon?: boolean | undefined;
|
|
389
387
|
none?: boolean | undefined;
|
|
390
388
|
linear?: boolean | undefined;
|
|
391
|
-
|
|
392
|
-
|
|
389
|
+
circle?: boolean | undefined;
|
|
390
|
+
polygon?: boolean | undefined;
|
|
393
391
|
point?: boolean | undefined;
|
|
394
|
-
ray?: boolean | undefined;
|
|
395
|
-
segment?: boolean | undefined;
|
|
396
392
|
angle?: boolean | undefined;
|
|
393
|
+
segment?: boolean | undefined;
|
|
397
394
|
"linear-system"?: boolean | undefined;
|
|
395
|
+
ray?: boolean | undefined;
|
|
398
396
|
"unlimited-polygon"?: boolean | undefined;
|
|
397
|
+
quadratic?: boolean | undefined;
|
|
398
|
+
sinusoid?: boolean | undefined;
|
|
399
399
|
"unlimited-point"?: boolean | undefined;
|
|
400
400
|
} & {
|
|
401
401
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
|
@@ -470,18 +470,18 @@ declare const _default: Readonly<{
|
|
|
470
470
|
editorChangeDelay?: number | undefined;
|
|
471
471
|
flags?: {
|
|
472
472
|
mafs?: false | ({
|
|
473
|
-
circle?: boolean | undefined;
|
|
474
|
-
polygon?: boolean | undefined;
|
|
475
473
|
none?: boolean | undefined;
|
|
476
474
|
linear?: boolean | undefined;
|
|
477
|
-
|
|
478
|
-
|
|
475
|
+
circle?: boolean | undefined;
|
|
476
|
+
polygon?: boolean | undefined;
|
|
479
477
|
point?: boolean | undefined;
|
|
480
|
-
ray?: boolean | undefined;
|
|
481
|
-
segment?: boolean | undefined;
|
|
482
478
|
angle?: boolean | undefined;
|
|
479
|
+
segment?: boolean | undefined;
|
|
483
480
|
"linear-system"?: boolean | undefined;
|
|
481
|
+
ray?: boolean | undefined;
|
|
484
482
|
"unlimited-polygon"?: boolean | undefined;
|
|
483
|
+
quadratic?: boolean | undefined;
|
|
484
|
+
sinusoid?: boolean | undefined;
|
|
485
485
|
"unlimited-point"?: boolean | undefined;
|
|
486
486
|
} & {
|
|
487
487
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
|
@@ -557,18 +557,18 @@ declare const _default: Readonly<{
|
|
|
557
557
|
editorChangeDelay?: number | undefined;
|
|
558
558
|
flags?: {
|
|
559
559
|
mafs?: false | ({
|
|
560
|
-
circle?: boolean | undefined;
|
|
561
|
-
polygon?: boolean | undefined;
|
|
562
560
|
none?: boolean | undefined;
|
|
563
561
|
linear?: boolean | undefined;
|
|
564
|
-
|
|
565
|
-
|
|
562
|
+
circle?: boolean | undefined;
|
|
563
|
+
polygon?: boolean | undefined;
|
|
566
564
|
point?: boolean | undefined;
|
|
567
|
-
ray?: boolean | undefined;
|
|
568
|
-
segment?: boolean | undefined;
|
|
569
565
|
angle?: boolean | undefined;
|
|
566
|
+
segment?: boolean | undefined;
|
|
570
567
|
"linear-system"?: boolean | undefined;
|
|
568
|
+
ray?: boolean | undefined;
|
|
571
569
|
"unlimited-polygon"?: boolean | undefined;
|
|
570
|
+
quadratic?: boolean | undefined;
|
|
571
|
+
sinusoid?: boolean | undefined;
|
|
572
572
|
"unlimited-point"?: boolean | undefined;
|
|
573
573
|
} & {
|
|
574
574
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { Coord } from "@khanacademy/perseus";
|
|
2
|
+
export type Coords = [Coord, Coord];
|
|
3
|
+
type SharedGrapherType = {
|
|
4
|
+
url: string;
|
|
5
|
+
defaultCoords: Coords;
|
|
6
|
+
getFunctionForCoeffs: (coeffs: ReadonlyArray<number>, x: number) => number;
|
|
7
|
+
getEquationString: (coords: Coords, asymptote?: Coords) => string | null;
|
|
8
|
+
areEqual: (coeffs1: ReadonlyArray<number>, coeffs2: ReadonlyArray<number>) => boolean;
|
|
9
|
+
Movable: any;
|
|
10
|
+
getCoefficients: (coords: Coords, asymptote?: Coords) => ReadonlyArray<number> | undefined;
|
|
11
|
+
};
|
|
12
|
+
type AsymptoticGraphsType = {
|
|
13
|
+
defaultAsymptote: Coords;
|
|
14
|
+
extraCoordConstraint: (newCoord: Coord, oldCoord: Coord, coords: Coords, asymptote: Coords, graph: any) => boolean | Coord;
|
|
15
|
+
extraAsymptoteConstraint: (newCoord: Coord, oldCoord: Coord, coords: Coords, asymptote: Coords, graph: any) => Coord;
|
|
16
|
+
allowReflectOverAsymptote: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type LinearType = SharedGrapherType & {
|
|
19
|
+
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
|
|
20
|
+
fn: any;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export type QuadraticType = SharedGrapherType & {
|
|
24
|
+
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
|
|
25
|
+
a: number;
|
|
26
|
+
b: number;
|
|
27
|
+
c: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type SinusoidType = SharedGrapherType & {
|
|
31
|
+
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
|
|
32
|
+
a: number;
|
|
33
|
+
b: number;
|
|
34
|
+
c: number;
|
|
35
|
+
d: number;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type TangentType = SharedGrapherType & {
|
|
39
|
+
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
|
|
40
|
+
fn: any;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
export type ExponentialType = SharedGrapherType & AsymptoticGraphsType & {
|
|
44
|
+
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
|
|
45
|
+
fn: any;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export type LogarithmType = SharedGrapherType & AsymptoticGraphsType & {
|
|
49
|
+
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
|
|
50
|
+
fn: any;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export type AbsoluteValueType = SharedGrapherType & {
|
|
54
|
+
getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
|
|
55
|
+
fn: any;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PerseusScore } from "../../types";
|
|
2
2
|
import type { PerseusGrapherRubric, PerseusGrapherUserInput } from "../../validation.types";
|
|
3
|
-
declare function grapherValidator(
|
|
3
|
+
declare function grapherValidator(userInput: PerseusGrapherUserInput, rubric: PerseusGrapherRubric): PerseusScore;
|
|
4
4
|
export default grapherValidator;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
|
+
import type { LinearType, QuadraticType, SinusoidType, TangentType, ExponentialType, LogarithmType, AbsoluteValueType } from "./grapher-types";
|
|
1
2
|
import type { Coord } from "../../interactive2/types";
|
|
2
3
|
export declare const DEFAULT_BACKGROUND_IMAGE: {
|
|
3
4
|
readonly url: null;
|
|
4
5
|
};
|
|
6
|
+
declare const functionTypeMapping: {
|
|
7
|
+
readonly linear: LinearType;
|
|
8
|
+
readonly quadratic: QuadraticType;
|
|
9
|
+
readonly sinusoid: SinusoidType;
|
|
10
|
+
readonly tangent: TangentType;
|
|
11
|
+
readonly exponential: ExponentialType;
|
|
12
|
+
readonly logarithm: LogarithmType;
|
|
13
|
+
readonly absolute_value: AbsoluteValueType;
|
|
14
|
+
};
|
|
5
15
|
export declare const allTypes: any;
|
|
6
|
-
|
|
16
|
+
type FunctionTypeMappingKeys = keyof typeof functionTypeMapping;
|
|
17
|
+
type ConditionalGraderType<T extends FunctionTypeMappingKeys> = T extends "linear" ? LinearType : T extends "quadratic" ? QuadraticType : T extends "sinusoid" ? SinusoidType : T extends "tangent" ? TangentType : T extends "exponential" ? ExponentialType : T extends "logarithm" ? LogarithmType : T extends "absolute_value" ? AbsoluteValueType : never;
|
|
18
|
+
export declare function functionForType<T extends FunctionTypeMappingKeys>(type: T): ConditionalGraderType<T>;
|
|
7
19
|
export declare const getEquationString: (props: any) => string;
|
|
8
20
|
export declare const pointsFromNormalized: (coordsList: ReadonlyArray<Coord>, range: [Coord, Coord], step: [number, number], snapStep: [number, number]) => ReadonlyArray<Coord>;
|
|
9
21
|
export declare const maybePointsFromNormalized: (coordsList: ReadonlyArray<Coord> | null | undefined, range: [Coord, Coord], step: [number, number], snapStep: [number, number]) => ReadonlyArray<Coord> | null | undefined;
|
|
10
|
-
export declare const defaultPlotProps: (type:
|
|
22
|
+
export declare const defaultPlotProps: (type: FunctionTypeMappingKeys, graph: any) => any;
|
|
11
23
|
export declare const chooseType: <T>(list: ReadonlyArray<T>) => T | undefined;
|
|
12
24
|
export declare const getGridAndSnapSteps: (options: any, boxSize: number) => {
|
|
13
25
|
gridStep: [number, number];
|
|
14
26
|
snapStep: [number, number];
|
|
15
27
|
};
|
|
16
28
|
export declare const DEFAULT_GRAPHER_PROPS: any;
|
|
17
|
-
export declare const typeToButton: (type:
|
|
29
|
+
export declare const typeToButton: (type: FunctionTypeMappingKeys) => any;
|
|
30
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PerseusStrings } from "../../strings";
|
|
2
|
-
import type { PerseusInputNumberRubric } from "../../validation.types";
|
|
2
|
+
import type { PerseusInputNumberRubric, PerseusInputNumberUserInput } from "../../validation.types";
|
|
3
3
|
import type { PerseusScore } from "@khanacademy/perseus";
|
|
4
4
|
export declare const answerTypes: {
|
|
5
5
|
readonly number: {
|
|
@@ -35,7 +35,5 @@ export declare const answerTypes: {
|
|
|
35
35
|
readonly forms: "pi";
|
|
36
36
|
};
|
|
37
37
|
};
|
|
38
|
-
declare function inputNumberValidator(
|
|
39
|
-
currentValue: string;
|
|
40
|
-
}, rubric: PerseusInputNumberRubric, strings: PerseusStrings): PerseusScore;
|
|
38
|
+
declare function inputNumberValidator(userInput: PerseusInputNumberUserInput, rubric: PerseusInputNumberRubric, strings: PerseusStrings): PerseusScore;
|
|
41
39
|
export default inputNumberValidator;
|
|
@@ -6,5 +6,5 @@ type InteractiveMarkerScore = {
|
|
|
6
6
|
isCorrect: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare function scoreMarker(marker: InteractiveMarkerType): InteractiveMarkerScore;
|
|
9
|
-
declare function labelImageValidator(
|
|
9
|
+
declare function labelImageValidator(userInput: PerseusLabelImageUserInput, rubric?: PerseusLabelImageRubric): PerseusScore;
|
|
10
10
|
export default labelImageValidator;
|
|
@@ -12,7 +12,7 @@ import type { InteractiveMarkerType } from "./types";
|
|
|
12
12
|
import type { DependencyProps } from "../../dependencies";
|
|
13
13
|
import type { ChangeableProps } from "../../mixins/changeable";
|
|
14
14
|
import type { APIOptions, Widget } from "../../types";
|
|
15
|
-
import type { PerseusLabelImageUserInput } from "../../validation.types";
|
|
15
|
+
import type { PerseusLabelImageRubric, PerseusLabelImageUserInput } from "../../validation.types";
|
|
16
16
|
export type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
|
|
17
17
|
/**
|
|
18
18
|
* Represents a direction vector.
|
|
@@ -79,7 +79,7 @@ export declare class LabelImage extends React.Component<LabelImageProps, LabelIm
|
|
|
79
79
|
componentDidMount(): void;
|
|
80
80
|
componentWillUnmount(): void;
|
|
81
81
|
getUserInput(): PerseusLabelImageUserInput;
|
|
82
|
-
showRationalesForCurrentlySelectedChoices(rubric:
|
|
82
|
+
showRationalesForCurrentlySelectedChoices(rubric: PerseusLabelImageRubric): void;
|
|
83
83
|
handleMarkerChange(index: number, marker: InteractiveMarkerType): void;
|
|
84
84
|
activateMarker(index: number, opened: boolean): void;
|
|
85
85
|
handleMarkerKeyDown(index: number, e: React.KeyboardEvent): void;
|
|
@@ -125,18 +125,18 @@ declare const _default: Readonly<{
|
|
|
125
125
|
editorChangeDelay?: number | undefined;
|
|
126
126
|
flags?: {
|
|
127
127
|
mafs?: false | ({
|
|
128
|
-
circle?: boolean | undefined;
|
|
129
|
-
polygon?: boolean | undefined;
|
|
130
128
|
none?: boolean | undefined;
|
|
131
129
|
linear?: boolean | undefined;
|
|
132
|
-
|
|
133
|
-
|
|
130
|
+
circle?: boolean | undefined;
|
|
131
|
+
polygon?: boolean | undefined;
|
|
134
132
|
point?: boolean | undefined;
|
|
135
|
-
ray?: boolean | undefined;
|
|
136
|
-
segment?: boolean | undefined;
|
|
137
133
|
angle?: boolean | undefined;
|
|
134
|
+
segment?: boolean | undefined;
|
|
138
135
|
"linear-system"?: boolean | undefined;
|
|
136
|
+
ray?: boolean | undefined;
|
|
139
137
|
"unlimited-polygon"?: boolean | undefined;
|
|
138
|
+
quadratic?: boolean | undefined;
|
|
139
|
+
sinusoid?: boolean | undefined;
|
|
140
140
|
"unlimited-point"?: boolean | undefined;
|
|
141
141
|
} & {
|
|
142
142
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
|
@@ -196,18 +196,18 @@ declare const _default: Readonly<{
|
|
|
196
196
|
editorChangeDelay?: number | undefined;
|
|
197
197
|
flags?: {
|
|
198
198
|
mafs?: false | ({
|
|
199
|
-
circle?: boolean | undefined;
|
|
200
|
-
polygon?: boolean | undefined;
|
|
201
199
|
none?: boolean | undefined;
|
|
202
200
|
linear?: boolean | undefined;
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
circle?: boolean | undefined;
|
|
202
|
+
polygon?: boolean | undefined;
|
|
205
203
|
point?: boolean | undefined;
|
|
206
|
-
ray?: boolean | undefined;
|
|
207
|
-
segment?: boolean | undefined;
|
|
208
204
|
angle?: boolean | undefined;
|
|
205
|
+
segment?: boolean | undefined;
|
|
209
206
|
"linear-system"?: boolean | undefined;
|
|
207
|
+
ray?: boolean | undefined;
|
|
210
208
|
"unlimited-polygon"?: boolean | undefined;
|
|
209
|
+
quadratic?: boolean | undefined;
|
|
210
|
+
sinusoid?: boolean | undefined;
|
|
211
211
|
"unlimited-point"?: boolean | undefined;
|
|
212
212
|
} & {
|
|
213
213
|
"interactive-graph-locked-features-labels"?: boolean | undefined;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Core Perseus API (includes renderers and widgets)",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "38.0.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@khanacademy/kas": "^0.3.
|
|
43
|
+
"@khanacademy/kas": "^0.3.15",
|
|
44
44
|
"@khanacademy/keypad-context": "^1.0.3",
|
|
45
45
|
"@khanacademy/kmath": "^0.1.15",
|
|
46
46
|
"@khanacademy/math-input": "^21.1.0",
|