@khanacademy/perseus 25.1.0 → 25.1.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.
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import type { GraphRange } from "../../perseus-types";
3
- import type { SizeClass } from "../../util/sizing-utils";
2
+ import type { GraphRange } from "../../../perseus-types";
3
+ import type { SizeClass } from "../../../util/sizing-utils";
4
4
  import type { vec } from "mafs";
5
5
  interface GridProps {
6
6
  tickStep: vec.Vector2;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { PerseusImageBackground } from "../../perseus-types";
2
+ import type { PerseusImageBackground } from "../../../perseus-types";
3
3
  interface Props {
4
4
  box: [number, number];
5
5
  backgroundImage?: PerseusImageBackground;
@@ -4,6 +4,8 @@ import type { vec } from "mafs";
4
4
  export type LockedFunctionOptions = Omit<Partial<LockedFunctionType>, "type" | "equation">;
5
5
  export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
6
6
  declare class InteractiveGraphQuestionBuilder {
7
+ private content;
8
+ private backgroundImage?;
7
9
  private gridStep;
8
10
  private labels;
9
11
  private markings;
@@ -15,6 +17,14 @@ declare class InteractiveGraphQuestionBuilder {
15
17
  private interactiveFigureConfig;
16
18
  private lockedFigures;
17
19
  build(): PerseusRenderer;
20
+ withContent(content: string): InteractiveGraphQuestionBuilder;
21
+ withBackgroundImage(url: string, height: number, width: number, options?: {
22
+ scale?: number;
23
+ bottom?: number;
24
+ left?: number;
25
+ right?: number;
26
+ top?: number;
27
+ }): InteractiveGraphQuestionBuilder;
18
28
  withGridStep(x: number, y: number): InteractiveGraphQuestionBuilder;
19
29
  withAxisLabels(x: string, y: string): InteractiveGraphQuestionBuilder;
20
30
  withMarkings(markings: "graph" | "grid" | "none"): InteractiveGraphQuestionBuilder;
@@ -23,17 +33,69 @@ declare class InteractiveGraphQuestionBuilder {
23
33
  withSnapStep(x: number, y: number): InteractiveGraphQuestionBuilder;
24
34
  withTickStep(x: number, y: number): InteractiveGraphQuestionBuilder;
25
35
  withProtractor(): InteractiveGraphQuestionBuilder;
26
- withSegments(startCoords: CollinearTuple[]): InteractiveGraphQuestionBuilder;
27
- withNumSegments(numSegments: number): InteractiveGraphQuestionBuilder;
28
- withLinear(startCoords?: CollinearTuple): InteractiveGraphQuestionBuilder;
29
- withLinearSystem(startCoords?: CollinearTuple[]): InteractiveGraphQuestionBuilder;
30
- withRay(startCoords?: CollinearTuple): InteractiveGraphQuestionBuilder;
31
- withCircle(startCoords?: Coord): InteractiveGraphQuestionBuilder;
32
- withQuadratic(startCoords?: [Coord, Coord, Coord]): InteractiveGraphQuestionBuilder;
33
- withSinusoid(startCoords?: [Coord, Coord]): InteractiveGraphQuestionBuilder;
34
- withPolygon(snapTo: "grid" | "angles" | "sides"): InteractiveGraphQuestionBuilder;
35
- addLockedPointAt(x: number, y: number): InteractiveGraphQuestionBuilder;
36
- addLockedLine(point1: vec.Vector2, point2: vec.Vector2): InteractiveGraphQuestionBuilder;
36
+ withSegments(options?: {
37
+ numSegments?: number;
38
+ startCoords?: CollinearTuple[];
39
+ coords?: CollinearTuple[];
40
+ }): InteractiveGraphQuestionBuilder;
41
+ withLinear(options?: {
42
+ coords?: CollinearTuple;
43
+ startCoords?: CollinearTuple;
44
+ }): InteractiveGraphQuestionBuilder;
45
+ withLinearSystem(options?: {
46
+ coords?: CollinearTuple[];
47
+ startCoords?: CollinearTuple[];
48
+ }): InteractiveGraphQuestionBuilder;
49
+ withRay(options?: {
50
+ coords?: CollinearTuple;
51
+ startCoords?: CollinearTuple;
52
+ }): InteractiveGraphQuestionBuilder;
53
+ withCircle(options?: {
54
+ center?: Coord;
55
+ radius?: number;
56
+ startCoords?: Coord;
57
+ }): InteractiveGraphQuestionBuilder;
58
+ withQuadratic(options?: {
59
+ coords?: [Coord, Coord, Coord];
60
+ startCoords?: [Coord, Coord, Coord];
61
+ }): InteractiveGraphQuestionBuilder;
62
+ withSinusoid(options?: {
63
+ coords?: [Coord, Coord];
64
+ startCoords?: [Coord, Coord];
65
+ }): InteractiveGraphQuestionBuilder;
66
+ withPolygon(snapTo: "grid" | "angles" | "sides", options?: {
67
+ match?: "similar" | "congruent" | "approx";
68
+ numSides?: number | "unlimited";
69
+ showAngles?: boolean;
70
+ showSides?: boolean;
71
+ coords?: Coord[];
72
+ startCoords?: Coord[];
73
+ }): InteractiveGraphQuestionBuilder;
74
+ withPoints(numPoints: number | "unlimited", options?: {
75
+ coords?: Coord[];
76
+ startCoords?: Coord[];
77
+ }): InteractiveGraphQuestionBuilder;
78
+ withAngle(options?: {
79
+ coords?: [Coord, Coord, Coord];
80
+ startCoords?: [Coord, Coord, Coord];
81
+ showAngles?: boolean;
82
+ allowReflexAngles?: boolean;
83
+ angleOffsetDeg?: number;
84
+ snapDegrees?: number;
85
+ match?: "congruent";
86
+ }): InteractiveGraphQuestionBuilder;
87
+ addLockedPointAt(x: number, y: number, options?: {
88
+ color?: LockedFigureColor;
89
+ filled?: boolean;
90
+ }): InteractiveGraphQuestionBuilder;
91
+ addLockedLine(point1: vec.Vector2, point2: vec.Vector2, options?: {
92
+ kind?: "line" | "ray" | "segment";
93
+ lineStyle?: "solid" | "dashed";
94
+ color?: LockedFigureColor;
95
+ filled?: [boolean, boolean];
96
+ showPoint1?: boolean;
97
+ showPoint2?: boolean;
98
+ }): InteractiveGraphQuestionBuilder;
37
99
  addLockedVector(tail: vec.Vector2, tip: vec.Vector2, color?: LockedFigureColor): InteractiveGraphQuestionBuilder;
38
100
  addLockedEllipse(center: vec.Vector2, radius: [x: number, y: number], options?: {
39
101
  angle?: number;
@@ -1,55 +1,84 @@
1
1
  import type { InitializeGraphStateParams } from "./initialize-graph-state";
2
2
  import type { Interval, vec } from "mafs";
3
- export type InteractiveGraphAction = Reinitialize | MoveControlPoint | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange;
4
- export declare const REINITIALIZE = "reinitialize";
5
- export interface Reinitialize {
6
- type: typeof REINITIALIZE;
7
- params: InitializeGraphStateParams;
8
- }
9
- export declare function reinitialize(params: InitializeGraphStateParams): Reinitialize;
10
- export declare const MOVE_CONTROL_POINT = "move-control-point";
11
- export interface MoveControlPoint {
12
- type: typeof MOVE_CONTROL_POINT;
13
- itemIndex: number;
14
- pointIndex: number;
15
- destination: vec.Vector2;
16
- }
17
- export declare function moveControlPoint(pointIndex: number, destination: vec.Vector2, itemIndex: number): MoveControlPoint;
18
- export declare const MOVE_ALL = "move-all";
3
+ export type InteractiveGraphAction = Reinitialize | MovePointInFigure | MoveLine | MoveAll | MovePoint | MoveCenter | MoveRadiusPoint | ChangeSnapStep | ChangeRange;
4
+ export declare const actions: {
5
+ angle: {
6
+ movePoint: typeof movePoint;
7
+ };
8
+ circle: {
9
+ moveCenter: typeof moveCenter;
10
+ moveRadiusPoint: typeof moveRadiusPoint;
11
+ };
12
+ linear: {
13
+ moveLine: (delta: vec.Vector2) => MoveLine;
14
+ movePoint: (pointIndex: any, destination: any) => MovePointInFigure;
15
+ };
16
+ linearSystem: {
17
+ moveLine: typeof moveLine;
18
+ movePointInFigure: typeof movePointInFigure;
19
+ };
20
+ pointGraph: {
21
+ movePoint: typeof movePoint;
22
+ };
23
+ polygon: {
24
+ movePoint: typeof movePoint;
25
+ moveAll: typeof moveAll;
26
+ };
27
+ quadratic: {
28
+ movePoint: typeof movePoint;
29
+ };
30
+ ray: {
31
+ moveRay: (delta: vec.Vector2) => MoveLine;
32
+ movePoint: (pointIndex: any, destination: any) => MovePointInFigure;
33
+ };
34
+ segment: {
35
+ movePointInFigure: typeof movePointInFigure;
36
+ moveLine: typeof moveLine;
37
+ };
38
+ sinusoid: {
39
+ movePoint: typeof movePoint;
40
+ };
41
+ };
19
42
  export declare const MOVE_LINE = "move-line";
20
- interface MoveItem {
21
- delta: vec.Vector2;
22
- itemIndex?: number;
23
- }
24
- export interface MoveLine extends MoveItem {
43
+ export interface MoveLine {
25
44
  type: typeof MOVE_LINE;
45
+ itemIndex: number;
46
+ delta: vec.Vector2;
26
47
  }
27
- export interface MoveAll extends MoveItem {
48
+ declare function moveLine(itemIndex: number, delta: vec.Vector2): MoveLine;
49
+ export declare const MOVE_ALL = "move-all";
50
+ export interface MoveAll {
28
51
  type: typeof MOVE_ALL;
52
+ delta: vec.Vector2;
29
53
  }
30
- /** This action assumes the state.coords holds an array of collinear tuples that define lines */
31
- export declare function moveLine(itemIndex: number, delta: vec.Vector2): MoveLine;
32
- /** This action assumes a flat array of vectors */
33
- export declare const moveAll: (delta: vec.Vector2) => MoveAll;
54
+ declare function moveAll(delta: vec.Vector2): MoveAll;
34
55
  export declare const MOVE_POINT = "move-point";
35
56
  export interface MovePoint {
36
57
  type: typeof MOVE_POINT;
37
58
  index: number;
38
59
  destination: vec.Vector2;
39
60
  }
40
- export declare function movePoint(index: number, destination: vec.Vector2): MovePoint;
61
+ declare function movePoint(index: number, destination: vec.Vector2): MovePoint;
62
+ export declare const MOVE_POINT_IN_FIGURE = "move-point-in-figure";
63
+ export interface MovePointInFigure {
64
+ type: typeof MOVE_POINT_IN_FIGURE;
65
+ figureIndex: number;
66
+ pointIndex: number;
67
+ destination: vec.Vector2;
68
+ }
69
+ declare function movePointInFigure(figureIndex: number, pointIndex: number, destination: vec.Vector2): MovePointInFigure;
41
70
  export declare const MOVE_CENTER = "move-center";
42
71
  export interface MoveCenter {
43
72
  type: typeof MOVE_CENTER;
44
73
  destination: vec.Vector2;
45
74
  }
46
- export declare function moveCenter(destination: vec.Vector2): MoveCenter;
75
+ declare function moveCenter(destination: vec.Vector2): MoveCenter;
47
76
  export declare const MOVE_RADIUS_POINT = "MOVE_RADIUS_POINT";
48
77
  export interface MoveRadiusPoint {
49
78
  type: typeof MOVE_RADIUS_POINT;
50
79
  destination: vec.Vector2;
51
80
  }
52
- export declare function moveRadiusPoint(destination: vec.Vector2): MoveRadiusPoint;
81
+ declare function moveRadiusPoint(destination: vec.Vector2): MoveRadiusPoint;
53
82
  export declare const CHANGE_SNAP_STEP = "change-snap-step";
54
83
  export interface ChangeSnapStep {
55
84
  type: typeof CHANGE_SNAP_STEP;
@@ -62,4 +91,10 @@ export interface ChangeRange {
62
91
  range: [x: Interval, y: Interval];
63
92
  }
64
93
  export declare function changeRange(range: [x: Interval, y: Interval]): ChangeRange;
94
+ export declare const REINITIALIZE = "reinitialize";
95
+ export interface Reinitialize {
96
+ type: typeof REINITIALIZE;
97
+ params: InitializeGraphStateParams;
98
+ }
99
+ export declare function reinitialize(params: InitializeGraphStateParams): Reinitialize;
65
100
  export {};
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": "25.1.0",
6
+ "version": "25.1.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },