@khanacademy/perseus 23.0.0 → 23.1.0
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 +133 -48
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +135 -47
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +2 -0
- package/dist/perseus-types.d.ts +9 -1
- package/dist/server-item-renderer.d.ts +2 -0
- package/dist/types.d.ts +2 -2
- package/dist/widgets/expression.d.ts +12 -0
- package/dist/widgets/interactive-graphs/graphs/index.d.ts +1 -0
- package/dist/widgets/interactive-graphs/graphs/sinusoid.d.ts +14 -0
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +6 -1
- package/dist/widgets/interactive-graphs/locked-circle.d.ts +4 -0
- package/dist/widgets/interactive-graphs/mafs-supported-graph-types.d.ts +1 -1
- package/dist/widgets/interactive-graphs/types.d.ts +5 -1
- package/dist/widgets/label-image.d.ts +4 -0
- package/package.json +1 -1
package/dist/perseus-api.d.ts
CHANGED
|
@@ -97,11 +97,13 @@ export declare const ApiOptions: {
|
|
|
97
97
|
polygon?: boolean | undefined;
|
|
98
98
|
linear?: boolean | undefined;
|
|
99
99
|
quadratic?: boolean | undefined;
|
|
100
|
+
sinusoid?: boolean | undefined;
|
|
100
101
|
segment?: boolean | undefined;
|
|
101
102
|
"linear-system"?: boolean | undefined;
|
|
102
103
|
ray?: boolean | undefined;
|
|
103
104
|
} & {
|
|
104
105
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
106
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
105
107
|
}) | undefined;
|
|
106
108
|
} | undefined;
|
|
107
109
|
onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
|
package/dist/perseus-types.d.ts
CHANGED
|
@@ -349,7 +349,7 @@ export type PerseusInteractiveGraphWidgetOptions = {
|
|
|
349
349
|
declare const lockedFigureColorNames: readonly ["green", "grayH", "purple", "pink", "red"];
|
|
350
350
|
export type LockedFigureColor = (typeof lockedFigureColorNames)[number];
|
|
351
351
|
export declare const lockedFigureColors: Record<LockedFigureColor, string>;
|
|
352
|
-
export type LockedFigure = LockedPointType | LockedLineType;
|
|
352
|
+
export type LockedFigure = LockedPointType | LockedLineType | LockedCircleType;
|
|
353
353
|
export type LockedFigureType = LockedFigure["type"];
|
|
354
354
|
export type LockedPointType = {
|
|
355
355
|
type: "point";
|
|
@@ -366,6 +366,14 @@ export type LockedLineType = {
|
|
|
366
366
|
showPoint1: boolean;
|
|
367
367
|
showPoint2: boolean;
|
|
368
368
|
};
|
|
369
|
+
export type LockedCircleType = {
|
|
370
|
+
type: "circle";
|
|
371
|
+
center: Coord;
|
|
372
|
+
radius: number;
|
|
373
|
+
color: LockedFigureColor;
|
|
374
|
+
fillStyle: "none" | "solid" | "translucent";
|
|
375
|
+
strokeStyle: "solid" | "dashed";
|
|
376
|
+
};
|
|
369
377
|
export type PerseusGraphType = PerseusGraphTypeAngle | PerseusGraphTypeCircle | PerseusGraphTypeLinear | PerseusGraphTypeLinearSystem | PerseusGraphTypePoint | PerseusGraphTypePolygon | PerseusGraphTypeQuadratic | PerseusGraphTypeRay | PerseusGraphTypeSegment | PerseusGraphTypeSinusoid;
|
|
370
378
|
export type PerseusGraphTypeCommon = {
|
|
371
379
|
coord?: Coord;
|
|
@@ -144,11 +144,13 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
|
|
|
144
144
|
polygon?: boolean | undefined;
|
|
145
145
|
linear?: boolean | undefined;
|
|
146
146
|
quadratic?: boolean | undefined;
|
|
147
|
+
sinusoid?: boolean | undefined;
|
|
147
148
|
segment?: boolean | undefined;
|
|
148
149
|
"linear-system"?: boolean | undefined;
|
|
149
150
|
ray?: boolean | undefined;
|
|
150
151
|
} & {
|
|
151
152
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
153
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
152
154
|
}) | undefined;
|
|
153
155
|
} | undefined;
|
|
154
156
|
onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -77,8 +77,8 @@ type TrackInteractionArgs = {
|
|
|
77
77
|
id: string;
|
|
78
78
|
correct?: boolean;
|
|
79
79
|
} & Partial<TrackingGradedGroupExtraArguments> & Partial<TrackingSequenceExtraArguments>;
|
|
80
|
-
export declare const MafsGraphTypeFlags: readonly ["segment", "linear", "linear-system", "ray", "polygon", "circle", "quadratic"];
|
|
81
|
-
export declare const InteractiveGraphLockedFeaturesFlags: readonly ["interactive-graph-locked-features-m1"];
|
|
80
|
+
export declare const MafsGraphTypeFlags: readonly ["segment", "linear", "linear-system", "ray", "polygon", "circle", "quadratic", "sinusoid"];
|
|
81
|
+
export declare const InteractiveGraphLockedFeaturesFlags: readonly ["interactive-graph-locked-features-m1", "interactive-graph-locked-features-m2"];
|
|
82
82
|
/**
|
|
83
83
|
* APIOptions provides different ways to customize the behaviour of Perseus.
|
|
84
84
|
*
|
|
@@ -138,11 +138,13 @@ declare const _default: Readonly<{
|
|
|
138
138
|
polygon?: boolean | undefined;
|
|
139
139
|
linear?: boolean | undefined;
|
|
140
140
|
quadratic?: boolean | undefined;
|
|
141
|
+
sinusoid?: boolean | undefined;
|
|
141
142
|
segment?: boolean | undefined;
|
|
142
143
|
"linear-system"?: boolean | undefined;
|
|
143
144
|
ray?: boolean | undefined;
|
|
144
145
|
} & {
|
|
145
146
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
147
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
146
148
|
}) | undefined;
|
|
147
149
|
} | undefined;
|
|
148
150
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
@@ -213,11 +215,13 @@ declare const _default: Readonly<{
|
|
|
213
215
|
polygon?: boolean | undefined;
|
|
214
216
|
linear?: boolean | undefined;
|
|
215
217
|
quadratic?: boolean | undefined;
|
|
218
|
+
sinusoid?: boolean | undefined;
|
|
216
219
|
segment?: boolean | undefined;
|
|
217
220
|
"linear-system"?: boolean | undefined;
|
|
218
221
|
ray?: boolean | undefined;
|
|
219
222
|
} & {
|
|
220
223
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
224
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
221
225
|
}) | undefined;
|
|
222
226
|
} | undefined;
|
|
223
227
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
@@ -288,11 +292,13 @@ declare const _default: Readonly<{
|
|
|
288
292
|
polygon?: boolean | undefined;
|
|
289
293
|
linear?: boolean | undefined;
|
|
290
294
|
quadratic?: boolean | undefined;
|
|
295
|
+
sinusoid?: boolean | undefined;
|
|
291
296
|
segment?: boolean | undefined;
|
|
292
297
|
"linear-system"?: boolean | undefined;
|
|
293
298
|
ray?: boolean | undefined;
|
|
294
299
|
} & {
|
|
295
300
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
301
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
296
302
|
}) | undefined;
|
|
297
303
|
} | undefined;
|
|
298
304
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
@@ -360,11 +366,13 @@ declare const _default: Readonly<{
|
|
|
360
366
|
polygon?: boolean | undefined;
|
|
361
367
|
linear?: boolean | undefined;
|
|
362
368
|
quadratic?: boolean | undefined;
|
|
369
|
+
sinusoid?: boolean | undefined;
|
|
363
370
|
segment?: boolean | undefined;
|
|
364
371
|
"linear-system"?: boolean | undefined;
|
|
365
372
|
ray?: boolean | undefined;
|
|
366
373
|
} & {
|
|
367
374
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
375
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
368
376
|
}) | undefined;
|
|
369
377
|
} | undefined;
|
|
370
378
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
@@ -435,11 +443,13 @@ declare const _default: Readonly<{
|
|
|
435
443
|
polygon?: boolean | undefined;
|
|
436
444
|
linear?: boolean | undefined;
|
|
437
445
|
quadratic?: boolean | undefined;
|
|
446
|
+
sinusoid?: boolean | undefined;
|
|
438
447
|
segment?: boolean | undefined;
|
|
439
448
|
"linear-system"?: boolean | undefined;
|
|
440
449
|
ray?: boolean | undefined;
|
|
441
450
|
} & {
|
|
442
451
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
452
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
443
453
|
}) | undefined;
|
|
444
454
|
} | undefined;
|
|
445
455
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
@@ -510,11 +520,13 @@ declare const _default: Readonly<{
|
|
|
510
520
|
polygon?: boolean | undefined;
|
|
511
521
|
linear?: boolean | undefined;
|
|
512
522
|
quadratic?: boolean | undefined;
|
|
523
|
+
sinusoid?: boolean | undefined;
|
|
513
524
|
segment?: boolean | undefined;
|
|
514
525
|
"linear-system"?: boolean | undefined;
|
|
515
526
|
ray?: boolean | undefined;
|
|
516
527
|
} & {
|
|
517
528
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
529
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
518
530
|
}) | undefined;
|
|
519
531
|
} | undefined;
|
|
520
532
|
onWidgetStartProps?: ((widgets: import("../perseus-types").PerseusWidgetsMap) => void) | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Coord } from "../../../interactive2/types";
|
|
3
|
+
import type { SinusoidGraphState, MafsGraphProps } from "../types";
|
|
4
|
+
type SinusoidGraphProps = MafsGraphProps<SinusoidGraphState>;
|
|
5
|
+
export type SineCoefficient = {
|
|
6
|
+
amplitude: number;
|
|
7
|
+
angularFrequency: number;
|
|
8
|
+
phase: number;
|
|
9
|
+
verticalOffset: number;
|
|
10
|
+
};
|
|
11
|
+
export declare function SinusoidGraph(props: SinusoidGraphProps): JSX.Element;
|
|
12
|
+
export declare const computeSine: (x: number, sinusoidCoefficients: SineCoefficient) => number;
|
|
13
|
+
export declare const getSinusoidCoefficients: (coords: ReadonlyArray<Coord>) => SineCoefficient;
|
|
14
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PerseusRenderer } from "../../perseus-types";
|
|
1
|
+
import type { LockedFigureColor, PerseusRenderer } from "../../perseus-types";
|
|
2
2
|
import type { vec } from "mafs";
|
|
3
3
|
export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
|
|
4
4
|
declare class InteractiveGraphQuestionBuilder {
|
|
@@ -23,6 +23,11 @@ declare class InteractiveGraphQuestionBuilder {
|
|
|
23
23
|
withCircle(): InteractiveGraphQuestionBuilder;
|
|
24
24
|
addLockedPointAt(x: number, y: number): InteractiveGraphQuestionBuilder;
|
|
25
25
|
addLockedLine(point1: vec.Vector2, point2: vec.Vector2): InteractiveGraphQuestionBuilder;
|
|
26
|
+
addLockedCircle(center: vec.Vector2, radius: number, options?: {
|
|
27
|
+
color?: LockedFigureColor;
|
|
28
|
+
fillStyle?: "none" | "solid" | "translucent";
|
|
29
|
+
strokeStyle?: "solid" | "dashed";
|
|
30
|
+
}): InteractiveGraphQuestionBuilder;
|
|
26
31
|
private createLockedPoint;
|
|
27
32
|
private addLockedFigure;
|
|
28
33
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const mafsSupportedGraphTypes: readonly ["segment", "linear", "linear-system", "ray", "polygon", "point", "circle", "quadratic"];
|
|
1
|
+
export declare const mafsSupportedGraphTypes: readonly ["segment", "linear", "linear-system", "ray", "polygon", "point", "circle", "quadratic", "sinusoid"];
|
|
2
2
|
export type MafsSupportedGraphType = (typeof mafsSupportedGraphTypes)[number];
|
|
3
3
|
export declare const trueForAllMafsSupportedGraphTypes: Record<MafsSupportedGraphType, true>;
|
|
@@ -13,7 +13,7 @@ export interface InitializeGraphStateParams<T extends PerseusGraphType> {
|
|
|
13
13
|
range: [Interval, Interval];
|
|
14
14
|
step: vec.Vector2;
|
|
15
15
|
}
|
|
16
|
-
export type InteractiveGraphState = SegmentGraphState | LinearGraphState | RayGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState;
|
|
16
|
+
export type InteractiveGraphState = SegmentGraphState | LinearGraphState | RayGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState | SinusoidGraphState;
|
|
17
17
|
export interface InteractiveGraphStateCommon {
|
|
18
18
|
hasBeenInteractedWith: boolean;
|
|
19
19
|
range: [xRange: Interval, yRange: Interval];
|
|
@@ -50,6 +50,10 @@ export interface QuadraticGraphState extends InteractiveGraphStateCommon {
|
|
|
50
50
|
type: "quadratic";
|
|
51
51
|
coords: [Coord, Coord, Coord];
|
|
52
52
|
}
|
|
53
|
+
export interface SinusoidGraphState extends InteractiveGraphStateCommon {
|
|
54
|
+
type: "sinusoid";
|
|
55
|
+
coords: [vec.Vector2, vec.Vector2];
|
|
56
|
+
}
|
|
53
57
|
export type PairOfPoints = [Coord, Coord];
|
|
54
58
|
export type GraphDimensions = {
|
|
55
59
|
range: [Interval, Interval];
|
|
@@ -132,11 +132,13 @@ declare const _default: Readonly<{
|
|
|
132
132
|
polygon?: boolean | undefined;
|
|
133
133
|
linear?: boolean | undefined;
|
|
134
134
|
quadratic?: boolean | undefined;
|
|
135
|
+
sinusoid?: boolean | undefined;
|
|
135
136
|
segment?: boolean | undefined;
|
|
136
137
|
"linear-system"?: boolean | undefined;
|
|
137
138
|
ray?: boolean | undefined;
|
|
138
139
|
} & {
|
|
139
140
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
141
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
140
142
|
}) | undefined;
|
|
141
143
|
} | undefined;
|
|
142
144
|
onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => void) | undefined;
|
|
@@ -191,11 +193,13 @@ declare const _default: Readonly<{
|
|
|
191
193
|
polygon?: boolean | undefined;
|
|
192
194
|
linear?: boolean | undefined;
|
|
193
195
|
quadratic?: boolean | undefined;
|
|
196
|
+
sinusoid?: boolean | undefined;
|
|
194
197
|
segment?: boolean | undefined;
|
|
195
198
|
"linear-system"?: boolean | undefined;
|
|
196
199
|
ray?: boolean | undefined;
|
|
197
200
|
} & {
|
|
198
201
|
"interactive-graph-locked-features-m1"?: boolean | undefined;
|
|
202
|
+
"interactive-graph-locked-features-m2"?: boolean | undefined;
|
|
199
203
|
}) | undefined;
|
|
200
204
|
} | undefined;
|
|
201
205
|
onWidgetStartProps?: ((widgets: import("..").PerseusWidgetsMap) => void) | undefined;
|