@khanacademy/perseus 24.2.0 → 25.0.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 +845 -377
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +7 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +927 -449
- package/dist/index.js.map +1 -1
- package/dist/logging/log.d.ts +1 -41
- package/dist/perseus-api.d.ts +1 -0
- package/dist/perseus-types.d.ts +17 -2
- package/dist/server-item-renderer.d.ts +2 -1
- package/dist/types.d.ts +1 -1
- package/dist/widgets/expression.d.ts +8 -2
- 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/graphs/utils.d.ts +0 -3
- package/dist/widgets/interactive-graphs/index.d.ts +1 -1
- 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-graph.d.ts +0 -19
- package/dist/widgets/interactive-graphs/mafs-supported-graph-types.d.ts +1 -1
- package/dist/widgets/interactive-graphs/math/angles.d.ts +5 -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/geometry.d.ts +3 -0
- package/dist/widgets/interactive-graphs/math/index.d.ts +8 -0
- package/dist/widgets/interactive-graphs/math/interpolation.d.ts +1 -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/stateful-mafs-graph.d.ts +21 -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 +8 -8
- package/dist/perseus-error.d.ts +0 -11
package/dist/logging/log.d.ts
CHANGED
|
@@ -1,45 +1,5 @@
|
|
|
1
|
+
import type { ErrorKind } from "@khanacademy/perseus-core";
|
|
1
2
|
import type { Metadata } from "@khanacademy/wonder-stuff-core";
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {Object} Errors utility for referencing the Perseus error taxonomy.
|
|
4
|
-
*/
|
|
5
|
-
export declare const Errors: Readonly<{
|
|
6
|
-
/**
|
|
7
|
-
* @property {ErrorKind} Unknown The kind of error is not known.
|
|
8
|
-
*/
|
|
9
|
-
Unknown: "Unknown";
|
|
10
|
-
/**
|
|
11
|
-
* @property {ErrorKind} Internal The error is internal to the executing code.
|
|
12
|
-
*/
|
|
13
|
-
Internal: "Internal";
|
|
14
|
-
/**
|
|
15
|
-
* @property {ErrorKind} InvalidInput There was a problem with the provided
|
|
16
|
-
* input, such as the wrong format or a null value.
|
|
17
|
-
*/
|
|
18
|
-
InvalidInput: "InvalidInput";
|
|
19
|
-
/**
|
|
20
|
-
* @property {ErrorKind} NotAllowed There was a problem due to the state of
|
|
21
|
-
* the system not matching the requested operation or input. For example,
|
|
22
|
-
* trying to create a username that is valid, but is already taken by
|
|
23
|
-
* another user. Use {@link InvalidInput} instead when the input isn't
|
|
24
|
-
* valid regardless of the state of the system. Use {@link NotFound} when
|
|
25
|
-
* the failure is due to not being able to find a resource.
|
|
26
|
-
*/
|
|
27
|
-
NotAllowed: "NotAllowed";
|
|
28
|
-
/**
|
|
29
|
-
* @property {ErrorKind} TransientService There was a problem when making a
|
|
30
|
-
* request to a service.
|
|
31
|
-
*/
|
|
32
|
-
TransientService: "TransientService";
|
|
33
|
-
/**
|
|
34
|
-
* @property {ErrorKind} Service There was a non-transient problem when
|
|
35
|
-
* making a request to service.
|
|
36
|
-
*/
|
|
37
|
-
Service: "Service";
|
|
38
|
-
}>;
|
|
39
|
-
/**
|
|
40
|
-
* @type {ErrorKind} The kind of error being reported
|
|
41
|
-
*/
|
|
42
|
-
export type ErrorKind = (typeof Errors)[keyof typeof Errors];
|
|
43
3
|
export type LogErrorOptions = {
|
|
44
4
|
cause?: Error | null | undefined;
|
|
45
5
|
loggedMetadata?: Metadata | null | undefined;
|
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";
|
|
@@ -105,7 +105,7 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
|
|
|
105
105
|
setAssetStatus: (assetKey: string, status: boolean) => void;
|
|
106
106
|
render(): React.ReactNode;
|
|
107
107
|
}
|
|
108
|
-
declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps, "
|
|
108
|
+
declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps, "problemNum" | "keypadElement" | "showSolutions" | "reviewMode" | "item" | "dependencies" | "hintsVisible"> & {
|
|
109
109
|
apiOptions?: Readonly<{
|
|
110
110
|
isArticle?: boolean | undefined;
|
|
111
111
|
onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
|
|
@@ -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;
|
|
@@ -252,9 +254,9 @@ declare const _default: Readonly<{
|
|
|
252
254
|
times: boolean;
|
|
253
255
|
value: string;
|
|
254
256
|
}, "onChange" | "analytics" | "buttonsVisible" | "static" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
|
|
257
|
+
value?: string | undefined;
|
|
255
258
|
onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
256
259
|
onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
257
|
-
value?: string | undefined;
|
|
258
260
|
buttonSets?: import("../perseus-types").LegacyButtonSets | undefined;
|
|
259
261
|
apiOptions?: Readonly<Readonly<{
|
|
260
262
|
isArticle?: 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;
|
|
@@ -483,9 +488,9 @@ declare const _default: Readonly<{
|
|
|
483
488
|
times: boolean;
|
|
484
489
|
value: string;
|
|
485
490
|
}, "onChange" | "analytics" | "buttonsVisible" | "static" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
|
|
491
|
+
value?: string | undefined;
|
|
486
492
|
onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
487
493
|
onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
|
|
488
|
-
value?: string | undefined;
|
|
489
494
|
buttonSets?: import("../perseus-types").LegacyButtonSets | undefined;
|
|
490
495
|
apiOptions?: Readonly<Readonly<{
|
|
491
496
|
isArticle?: 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,4 @@
|
|
|
1
|
-
import type { CollinearTuple } from "../../../perseus-types";
|
|
2
1
|
import type { Interval, vec } from "mafs";
|
|
3
|
-
export declare function calculateAngleInDegrees([x, y]: vec.Vector2): number;
|
|
4
2
|
/**
|
|
5
3
|
* Given a ray and a rectangular box, find the point where the ray intersects
|
|
6
4
|
* the edge of the box. Assumes the `initialPoint` is inside the box.
|
|
@@ -9,4 +7,3 @@ export declare function calculateAngleInDegrees([x, y]: vec.Vector2): number;
|
|
|
9
7
|
* @param box - The box with which to intersect the ray, in the form [[xMin, xMax], [yMin, yMax]]
|
|
10
8
|
*/
|
|
11
9
|
export declare const getIntersectionOfRayWithBox: (initialPoint: vec.Vector2, throughPoint: vec.Vector2, box: [x: Interval, y: Interval]) => [number, number];
|
|
12
|
-
export declare const getLines: (points: readonly vec.Vector2[]) => CollinearTuple[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { StatefulMafsGraph } from "./mafs-graph";
|
|
1
|
+
export { StatefulMafsGraph } from "./stateful-mafs-graph";
|
|
@@ -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,27 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type InteractiveGraphAction } from "./reducer/interactive-graph-action";
|
|
3
3
|
import type { InteractiveGraphState, InteractiveGraphProps } from "./types";
|
|
4
|
-
import type { PerseusGraphType } from "../../perseus-types";
|
|
5
|
-
import type { Widget } from "../../renderer";
|
|
6
4
|
import "mafs/core.css";
|
|
7
5
|
import "./mafs-styles.css";
|
|
8
|
-
export type StatefulMafsGraphProps = {
|
|
9
|
-
box: [number, number];
|
|
10
|
-
backgroundImage?: InteractiveGraphProps["backgroundImage"];
|
|
11
|
-
graph: PerseusGraphType;
|
|
12
|
-
lockedFigures?: InteractiveGraphProps["lockedFigures"];
|
|
13
|
-
range: InteractiveGraphProps["range"];
|
|
14
|
-
snapStep: InteractiveGraphProps["snapStep"];
|
|
15
|
-
step: InteractiveGraphProps["step"];
|
|
16
|
-
gridStep: InteractiveGraphProps["gridStep"];
|
|
17
|
-
containerSizeClass: InteractiveGraphProps["containerSizeClass"];
|
|
18
|
-
markings: InteractiveGraphProps["markings"];
|
|
19
|
-
onChange: InteractiveGraphProps["onChange"];
|
|
20
|
-
showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
|
|
21
|
-
showProtractor: boolean;
|
|
22
|
-
labels: InteractiveGraphProps["labels"];
|
|
23
|
-
};
|
|
24
|
-
export declare const StatefulMafsGraph: React.ForwardRefExoticComponent<StatefulMafsGraphProps & React.RefAttributes<Partial<Widget>>>;
|
|
25
6
|
export type MafsGraphProps = {
|
|
26
7
|
box: [number, number];
|
|
27
8
|
backgroundImage?: InteractiveGraphProps["backgroundImage"];
|
|
@@ -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,5 @@
|
|
|
1
|
+
import type { vec } from "mafs";
|
|
2
|
+
export declare function convertDegreesToRadians(degrees: number): number;
|
|
3
|
+
export declare function calculateAngleInDegrees([x, y]: vec.Vector2): number;
|
|
4
|
+
export declare function polar(r: number | vec.Vector2, th: number): vec.Vector2;
|
|
5
|
+
export declare const findAngle: (point1: vec.Vector2, point2: vec.Vector2, vertex?: vec.Vector2) => number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { clamp } from "./clamp";
|
|
2
|
+
export { snap } from "./snap";
|
|
3
|
+
export { inset, clampToBox } from "./box";
|
|
4
|
+
export { X, Y } from "./coordinates";
|
|
5
|
+
export { MIN, MAX, size } from "./interval";
|
|
6
|
+
export { lerp } from "./interpolation";
|
|
7
|
+
export { segmentsIntersect } from "./geometry";
|
|
8
|
+
export { calculateAngleInDegrees, convertDegreesToRadians, findAngle, polar, } from "./angles";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function lerp(a: number, b: number, fraction: number): number;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { InteractiveGraphProps } from "./types";
|
|
3
|
+
import type { Widget } from "../../renderer";
|
|
4
|
+
import type { PerseusGraphType } from "@khanacademy/perseus";
|
|
5
|
+
export type StatefulMafsGraphProps = {
|
|
6
|
+
box: [number, number];
|
|
7
|
+
backgroundImage?: InteractiveGraphProps["backgroundImage"];
|
|
8
|
+
graph: PerseusGraphType;
|
|
9
|
+
lockedFigures?: InteractiveGraphProps["lockedFigures"];
|
|
10
|
+
range: InteractiveGraphProps["range"];
|
|
11
|
+
snapStep: InteractiveGraphProps["snapStep"];
|
|
12
|
+
step: InteractiveGraphProps["step"];
|
|
13
|
+
gridStep: InteractiveGraphProps["gridStep"];
|
|
14
|
+
containerSizeClass: InteractiveGraphProps["containerSizeClass"];
|
|
15
|
+
markings: InteractiveGraphProps["markings"];
|
|
16
|
+
onChange: InteractiveGraphProps["onChange"];
|
|
17
|
+
showTooltips: Required<InteractiveGraphProps["showTooltips"]>;
|
|
18
|
+
showProtractor: boolean;
|
|
19
|
+
labels: InteractiveGraphProps["labels"];
|
|
20
|
+
};
|
|
21
|
+
export declare const StatefulMafsGraph: React.ForwardRefExoticComponent<StatefulMafsGraphProps & React.RefAttributes<Partial<Widget>>>;
|
|
@@ -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": "
|
|
6
|
+
"version": "25.0.0",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@khanacademy/kas": "^0.3.
|
|
43
|
-
"@khanacademy/kmath": "^0.1.
|
|
44
|
-
"@khanacademy/math-input": "^19.1
|
|
45
|
-
"@khanacademy/perseus-core": "1.
|
|
46
|
-
"@khanacademy/perseus-linter": "^0.
|
|
47
|
-
"@khanacademy/pure-markdown": "^0.3.
|
|
48
|
-
"@khanacademy/simple-markdown": "^0.12.
|
|
42
|
+
"@khanacademy/kas": "^0.3.10",
|
|
43
|
+
"@khanacademy/kmath": "^0.1.13",
|
|
44
|
+
"@khanacademy/math-input": "^19.2.1",
|
|
45
|
+
"@khanacademy/perseus-core": "1.5.0",
|
|
46
|
+
"@khanacademy/perseus-linter": "^1.0.0",
|
|
47
|
+
"@khanacademy/pure-markdown": "^0.3.6",
|
|
48
|
+
"@khanacademy/simple-markdown": "^0.12.1",
|
|
49
49
|
"@use-gesture/react": "^10.2.27",
|
|
50
50
|
"mafs": "0.18.7"
|
|
51
51
|
},
|
package/dist/perseus-error.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ErrorKind } from "./logging/log";
|
|
2
|
-
import type { Metadata } from "@khanacademy/wonder-stuff-core";
|
|
3
|
-
type Options = {
|
|
4
|
-
metadata?: Metadata | null | undefined;
|
|
5
|
-
};
|
|
6
|
-
export declare class PerseusError extends Error {
|
|
7
|
-
kind: ErrorKind;
|
|
8
|
-
metadata: Metadata | null | undefined;
|
|
9
|
-
constructor(message: string, kind: ErrorKind, options?: Options);
|
|
10
|
-
}
|
|
11
|
-
export {};
|