@khanacademy/perseus 24.2.0 → 24.3.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.css +7 -0
- package/dist/es/index.js +654 -130
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +7 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +677 -141
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +1 -0
- package/dist/perseus-types.d.ts +17 -2
- package/dist/server-item-renderer.d.ts +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/widgets/expression.d.ts +6 -0
- package/dist/widgets/interactive-graph.d.ts +1 -1
- package/dist/widgets/interactive-graphs/graphs/angle.d.ts +5 -0
- package/dist/widgets/interactive-graphs/graphs/components/{angle.d.ts → angle-indicators.d.ts} +12 -2
- package/dist/widgets/interactive-graphs/graphs/components/movable-line.d.ts +11 -0
- package/dist/widgets/interactive-graphs/graphs/components/text-label.d.ts +1 -1
- package/dist/widgets/interactive-graphs/graphs/index.d.ts +1 -0
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +3 -1
- package/dist/widgets/interactive-graphs/locked-figures/locked-function.d.ts +4 -0
- package/dist/widgets/interactive-graphs/mafs-supported-graph-types.d.ts +1 -1
- package/dist/widgets/interactive-graphs/math/angles.d.ts +3 -0
- package/dist/widgets/interactive-graphs/math/box.d.ts +4 -0
- package/dist/widgets/interactive-graphs/math/clamp.d.ts +1 -0
- package/dist/widgets/interactive-graphs/math/coordinates.d.ts +2 -0
- package/dist/widgets/interactive-graphs/math/index.d.ts +6 -0
- package/dist/widgets/interactive-graphs/math/interval.d.ts +5 -0
- package/dist/widgets/interactive-graphs/math/snap.d.ts +2 -0
- package/dist/widgets/interactive-graphs/types.d.ts +9 -1
- package/dist/widgets/interactive-graphs/utils.d.ts +0 -2
- package/dist/widgets/label-image.d.ts +2 -0
- package/package.json +2 -2
package/dist/perseus-api.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export declare const ApiOptions: {
|
|
|
99
99
|
point?: boolean | undefined;
|
|
100
100
|
quadratic?: boolean | undefined;
|
|
101
101
|
sinusoid?: boolean | undefined;
|
|
102
|
+
angle?: boolean | undefined;
|
|
102
103
|
"linear-system"?: boolean | undefined;
|
|
103
104
|
ray?: boolean | undefined;
|
|
104
105
|
segment?: boolean | undefined;
|
package/dist/perseus-types.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Coord } from "./interactive2/types";
|
|
2
2
|
import type { Interval, vec } from "mafs";
|
|
3
3
|
export type Range = Interval;
|
|
4
|
+
export type Domain = {
|
|
5
|
+
min?: number;
|
|
6
|
+
max?: number;
|
|
7
|
+
};
|
|
4
8
|
export type Size = [number, number];
|
|
5
9
|
export type CollinearTuple = [vec.Vector2, vec.Vector2];
|
|
6
10
|
export type ShowSolutions = "all" | "selected" | "none";
|
|
@@ -349,7 +353,7 @@ export type PerseusInteractiveGraphWidgetOptions = {
|
|
|
349
353
|
declare const lockedFigureColorNames: readonly ["blue", "green", "grayH", "purple", "pink", "orange", "red"];
|
|
350
354
|
export type LockedFigureColor = (typeof lockedFigureColorNames)[number];
|
|
351
355
|
export declare const lockedFigureColors: Record<LockedFigureColor, string>;
|
|
352
|
-
export type LockedFigure = LockedPointType | LockedLineType | LockedVectorType | LockedEllipseType | LockedPolygonType;
|
|
356
|
+
export type LockedFigure = LockedPointType | LockedLineType | LockedVectorType | LockedEllipseType | LockedPolygonType | LockedFunctionType;
|
|
353
357
|
export type LockedFigureType = LockedFigure["type"];
|
|
354
358
|
export type LockedPointType = {
|
|
355
359
|
type: "point";
|
|
@@ -390,6 +394,17 @@ export type LockedPolygonType = {
|
|
|
390
394
|
fillStyle: LockedFigureFillType;
|
|
391
395
|
strokeStyle: "solid" | "dashed";
|
|
392
396
|
};
|
|
397
|
+
export type LockedFunctionType = {
|
|
398
|
+
type: "function";
|
|
399
|
+
color: LockedFigureColor;
|
|
400
|
+
strokeStyle: "solid" | "dashed";
|
|
401
|
+
equation: string;
|
|
402
|
+
equationParsed?: {
|
|
403
|
+
[k: string]: any;
|
|
404
|
+
};
|
|
405
|
+
directionalAxis: "x" | "y";
|
|
406
|
+
domain?: Domain;
|
|
407
|
+
};
|
|
393
408
|
export type PerseusGraphType = PerseusGraphTypeAngle | PerseusGraphTypeCircle | PerseusGraphTypeLinear | PerseusGraphTypeLinearSystem | PerseusGraphTypePoint | PerseusGraphTypePolygon | PerseusGraphTypeQuadratic | PerseusGraphTypeRay | PerseusGraphTypeSegment | PerseusGraphTypeSinusoid;
|
|
394
409
|
export type PerseusGraphTypeCommon = {
|
|
395
410
|
coord?: Coord;
|
|
@@ -401,7 +416,7 @@ export type PerseusGraphTypeAngle = {
|
|
|
401
416
|
angleOffsetDeg?: number;
|
|
402
417
|
snapDegrees?: number;
|
|
403
418
|
match?: "congruent";
|
|
404
|
-
coords?:
|
|
419
|
+
coords?: [Coord, Coord, Coord];
|
|
405
420
|
};
|
|
406
421
|
export type PerseusGraphTypeCircle = {
|
|
407
422
|
type: "circle";
|
|
@@ -146,6 +146,7 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
|
|
|
146
146
|
point?: boolean | undefined;
|
|
147
147
|
quadratic?: boolean | undefined;
|
|
148
148
|
sinusoid?: boolean | undefined;
|
|
149
|
+
angle?: boolean | undefined;
|
|
149
150
|
"linear-system"?: boolean | undefined;
|
|
150
151
|
ray?: boolean | undefined;
|
|
151
152
|
segment?: boolean | undefined;
|
package/dist/types.d.ts
CHANGED
|
@@ -77,7 +77,7 @@ 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", "sinusoid", "point"];
|
|
80
|
+
export declare const MafsGraphTypeFlags: readonly ["angle", "segment", "linear", "linear-system", "ray", "polygon", "circle", "quadratic", "sinusoid", "point"];
|
|
81
81
|
export declare const InteractiveGraphLockedFeaturesFlags: readonly ["interactive-graph-locked-features-m2", "interactive-graph-locked-features-m2b"];
|
|
82
82
|
/**
|
|
83
83
|
* APIOptions provides different ways to customize the behaviour of Perseus.
|
|
@@ -140,6 +140,7 @@ declare const _default: Readonly<{
|
|
|
140
140
|
point?: boolean | undefined;
|
|
141
141
|
quadratic?: boolean | undefined;
|
|
142
142
|
sinusoid?: boolean | undefined;
|
|
143
|
+
angle?: boolean | undefined;
|
|
143
144
|
"linear-system"?: boolean | undefined;
|
|
144
145
|
ray?: boolean | undefined;
|
|
145
146
|
segment?: boolean | undefined;
|
|
@@ -218,6 +219,7 @@ declare const _default: Readonly<{
|
|
|
218
219
|
point?: boolean | undefined;
|
|
219
220
|
quadratic?: boolean | undefined;
|
|
220
221
|
sinusoid?: boolean | undefined;
|
|
222
|
+
angle?: boolean | undefined;
|
|
221
223
|
"linear-system"?: boolean | undefined;
|
|
222
224
|
ray?: boolean | undefined;
|
|
223
225
|
segment?: boolean | undefined;
|
|
@@ -296,6 +298,7 @@ declare const _default: Readonly<{
|
|
|
296
298
|
point?: boolean | undefined;
|
|
297
299
|
quadratic?: boolean | undefined;
|
|
298
300
|
sinusoid?: boolean | undefined;
|
|
301
|
+
angle?: boolean | undefined;
|
|
299
302
|
"linear-system"?: boolean | undefined;
|
|
300
303
|
ray?: boolean | undefined;
|
|
301
304
|
segment?: boolean | undefined;
|
|
@@ -371,6 +374,7 @@ declare const _default: Readonly<{
|
|
|
371
374
|
point?: boolean | undefined;
|
|
372
375
|
quadratic?: boolean | undefined;
|
|
373
376
|
sinusoid?: boolean | undefined;
|
|
377
|
+
angle?: boolean | undefined;
|
|
374
378
|
"linear-system"?: boolean | undefined;
|
|
375
379
|
ray?: boolean | undefined;
|
|
376
380
|
segment?: boolean | undefined;
|
|
@@ -449,6 +453,7 @@ declare const _default: Readonly<{
|
|
|
449
453
|
point?: boolean | undefined;
|
|
450
454
|
quadratic?: boolean | undefined;
|
|
451
455
|
sinusoid?: boolean | undefined;
|
|
456
|
+
angle?: boolean | undefined;
|
|
452
457
|
"linear-system"?: boolean | undefined;
|
|
453
458
|
ray?: boolean | undefined;
|
|
454
459
|
segment?: boolean | undefined;
|
|
@@ -527,6 +532,7 @@ declare const _default: Readonly<{
|
|
|
527
532
|
point?: boolean | undefined;
|
|
528
533
|
quadratic?: boolean | undefined;
|
|
529
534
|
sinusoid?: boolean | undefined;
|
|
535
|
+
angle?: boolean | undefined;
|
|
530
536
|
"linear-system"?: boolean | undefined;
|
|
531
537
|
ray?: boolean | undefined;
|
|
532
538
|
segment?: boolean | undefined;
|
|
@@ -147,7 +147,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
|
|
|
147
147
|
* @param {object} graph Like props.graph or props.correct
|
|
148
148
|
* @param {object} props of an InteractiveGraph instance
|
|
149
149
|
*/
|
|
150
|
-
static getAngleCoords(graph: PerseusGraphTypeAngle, props: Props):
|
|
150
|
+
static getAngleCoords(graph: PerseusGraphTypeAngle, props: Props): [Coord, Coord, Coord];
|
|
151
151
|
static normalizeCoords(coordsList: ReadonlyArray<Coord>, ranges: [Range, Range]): ReadonlyArray<Coord>;
|
|
152
152
|
static getEquationString(props: Props): string;
|
|
153
153
|
static pointsFromNormalized(props: Props, coordsList: ReadonlyArray<Coord>, noSnap?: boolean): ReadonlyArray<Coord>;
|
package/dist/widgets/interactive-graphs/graphs/components/{angle.d.ts → angle-indicators.d.ts}
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { vec } from "mafs";
|
|
3
3
|
import type { CollinearTuple } from "../../../../perseus-types";
|
|
4
4
|
import type { Interval } from "mafs";
|
|
5
|
-
interface
|
|
5
|
+
interface PolygonAngleProps {
|
|
6
6
|
centerPoint: vec.Vector2;
|
|
7
7
|
endPoints: [vec.Vector2, vec.Vector2];
|
|
8
8
|
polygonLines: readonly CollinearTuple[];
|
|
@@ -11,7 +11,17 @@ interface Props {
|
|
|
11
11
|
showAngles: boolean;
|
|
12
12
|
snapTo: "grid" | "angles" | "sides";
|
|
13
13
|
}
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const PolygonAngle: ({ centerPoint, endPoints, range, polygonLines, showAngles, snapTo, }: PolygonAngleProps) => JSX.Element | null;
|
|
15
|
+
interface AngleProps {
|
|
16
|
+
vertex: vec.Vector2;
|
|
17
|
+
coords: [vec.Vector2, vec.Vector2];
|
|
18
|
+
showAngles: boolean;
|
|
19
|
+
allowReflexAngles: boolean;
|
|
20
|
+
angleOffsetDeg: number;
|
|
21
|
+
snapDegrees: number;
|
|
22
|
+
range: [Interval, Interval];
|
|
23
|
+
}
|
|
24
|
+
export declare const Angle: ({ vertex, coords, showAngles, allowReflexAngles, range, }: AngleProps) => JSX.Element;
|
|
15
25
|
/**
|
|
16
26
|
* Determines if an angle is an inside (false) or outside (true) angle.
|
|
17
27
|
* They way, we know to flip the `largeArc` and `sweepArc` flags.
|
|
@@ -12,5 +12,16 @@ type Props = {
|
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
14
|
export declare const MovableLine: (props: Props) => JSX.Element;
|
|
15
|
+
type LineProps = {
|
|
16
|
+
start: vec.Vector2;
|
|
17
|
+
end: vec.Vector2;
|
|
18
|
+
onMove: (delta: vec.Vector2) => unknown;
|
|
19
|
+
stroke?: string | undefined;
|
|
20
|
+
extend?: undefined | {
|
|
21
|
+
start: boolean;
|
|
22
|
+
end: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const Line: (props: LineProps) => JSX.Element;
|
|
15
26
|
export declare function trimRange(range: [Interval, Interval], graphDimensionsInPixels: vec.Vector2): [Interval, Interval];
|
|
16
27
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { TextProps } from "mafs";
|
|
2
2
|
import type { PropsWithChildren } from "react";
|
|
3
|
-
type Props = PropsWithChildren<Pick<TextProps, "x" | "y" | "attach" | "attachDistance">>;
|
|
3
|
+
type Props = PropsWithChildren<Pick<TextProps, "x" | "y" | "attach" | "attachDistance" | "color">>;
|
|
4
4
|
export declare const TextLabel: ({ children, ...rest }: Props) => JSX.Element;
|
|
5
5
|
export declare const SvgDefs: () => JSX.Element;
|
|
6
6
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedFunctionType, PerseusRenderer } from "../../perseus-types";
|
|
2
2
|
import type { Coord } from "@khanacademy/perseus";
|
|
3
3
|
import type { vec } from "mafs";
|
|
4
|
+
export type LockedFunctionOptions = Omit<Partial<LockedFunctionType>, "type" | "equation">;
|
|
4
5
|
export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
|
|
5
6
|
declare class InteractiveGraphQuestionBuilder {
|
|
6
7
|
private gridStep;
|
|
@@ -46,6 +47,7 @@ declare class InteractiveGraphQuestionBuilder {
|
|
|
46
47
|
fillStyle?: LockedFigureFillType;
|
|
47
48
|
strokeStyle?: "solid" | "dashed";
|
|
48
49
|
}): InteractiveGraphQuestionBuilder;
|
|
50
|
+
addLockedFunction(equation: string, options?: LockedFunctionOptions): this;
|
|
49
51
|
private createLockedPoint;
|
|
50
52
|
private addLockedFigure;
|
|
51
53
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const mafsSupportedGraphTypes: readonly ["segment", "linear", "linear-system", "ray", "polygon", "point", "circle", "quadratic", "sinusoid"];
|
|
1
|
+
export declare const mafsSupportedGraphTypes: readonly ["angle", "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>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
@@ -8,7 +8,7 @@ export type MafsGraphProps<T extends InteractiveGraphState> = {
|
|
|
8
8
|
graphState: T;
|
|
9
9
|
dispatch: (action: InteractiveGraphAction) => unknown;
|
|
10
10
|
};
|
|
11
|
-
export type InteractiveGraphState = SegmentGraphState | LinearSystemGraphState | LinearGraphState | RayGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState | SinusoidGraphState;
|
|
11
|
+
export type InteractiveGraphState = AngleGraphState | SegmentGraphState | LinearSystemGraphState | LinearGraphState | RayGraphState | PolygonGraphState | PointGraphState | CircleGraphState | QuadraticGraphState | SinusoidGraphState;
|
|
12
12
|
export interface InteractiveGraphStateCommon {
|
|
13
13
|
hasBeenInteractedWith: boolean;
|
|
14
14
|
range: [xRange: Interval, yRange: Interval];
|
|
@@ -54,6 +54,14 @@ export interface SinusoidGraphState extends InteractiveGraphStateCommon {
|
|
|
54
54
|
type: "sinusoid";
|
|
55
55
|
coords: [vec.Vector2, vec.Vector2];
|
|
56
56
|
}
|
|
57
|
+
export interface AngleGraphState extends InteractiveGraphStateCommon {
|
|
58
|
+
type: "angle";
|
|
59
|
+
showAngles?: boolean;
|
|
60
|
+
allowReflexAngles?: boolean;
|
|
61
|
+
angleOffsetDeg?: number;
|
|
62
|
+
snapDegrees?: number;
|
|
63
|
+
coords: [Coord, Coord, Coord];
|
|
64
|
+
}
|
|
57
65
|
export type PairOfPoints = [Coord, Coord];
|
|
58
66
|
export type GraphDimensions = {
|
|
59
67
|
range: [Interval, Interval];
|
|
@@ -8,10 +8,8 @@ import type { Interval, vec } from "mafs";
|
|
|
8
8
|
export declare const TARGET_SIZE = 44;
|
|
9
9
|
export declare const normalizePoints: <A extends Coord[]>(range: PerseusInteractiveGraphWidgetOptions["range"], step: PerseusInteractiveGraphWidgetOptions["step"], coordsList: A, noSnap?: boolean) => A;
|
|
10
10
|
export declare const normalizeCoords: <A extends Coord[]>(coordsList: A, ranges: PerseusInteractiveGraphWidgetOptions["range"]) => A;
|
|
11
|
-
export declare function snap(snapStep: vec.Vector2, point: vec.Vector2): vec.Vector2;
|
|
12
11
|
export declare function bound({ snapStep, range, point, }: {
|
|
13
12
|
snapStep: vec.Vector2;
|
|
14
13
|
range: [Interval, Interval];
|
|
15
14
|
point: vec.Vector2;
|
|
16
15
|
}): vec.Vector2;
|
|
17
|
-
export declare function clamp(value: number, min: number, max: number): number;
|
|
@@ -134,6 +134,7 @@ declare const _default: Readonly<{
|
|
|
134
134
|
point?: boolean | undefined;
|
|
135
135
|
quadratic?: boolean | undefined;
|
|
136
136
|
sinusoid?: boolean | undefined;
|
|
137
|
+
angle?: boolean | undefined;
|
|
137
138
|
"linear-system"?: boolean | undefined;
|
|
138
139
|
ray?: boolean | undefined;
|
|
139
140
|
segment?: boolean | undefined;
|
|
@@ -196,6 +197,7 @@ declare const _default: Readonly<{
|
|
|
196
197
|
point?: boolean | undefined;
|
|
197
198
|
quadratic?: boolean | undefined;
|
|
198
199
|
sinusoid?: boolean | undefined;
|
|
200
|
+
angle?: boolean | undefined;
|
|
199
201
|
"linear-system"?: boolean | undefined;
|
|
200
202
|
ray?: boolean | undefined;
|
|
201
203
|
segment?: 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": "24.
|
|
6
|
+
"version": "24.3.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"@khanacademy/kas": "^0.3.9",
|
|
43
43
|
"@khanacademy/kmath": "^0.1.12",
|
|
44
|
-
"@khanacademy/math-input": "^19.
|
|
44
|
+
"@khanacademy/math-input": "^19.2.0",
|
|
45
45
|
"@khanacademy/perseus-core": "1.4.2",
|
|
46
46
|
"@khanacademy/perseus-linter": "^0.4.0",
|
|
47
47
|
"@khanacademy/pure-markdown": "^0.3.5",
|