@khanacademy/perseus 28.2.0 → 30.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.
@@ -1,6 +1,6 @@
1
1
  import WrappedPath from "./wrapped-path";
2
+ import type { Coord } from "./types";
2
3
  import type { Graphie } from "../util/graphie";
3
- import type { Coord } from "@khanacademy/perseus";
4
4
  export declare class Arrowhead extends WrappedPath {
5
5
  private static scale;
6
6
  center: Coord;
@@ -1,2 +1,2 @@
1
- import type { Coord } from "@khanacademy/perseus";
1
+ import type { Coord } from "./types";
2
2
  export declare const getClipPoint: (graph: any, coord: Coord, angle: number) => any;
@@ -1,7 +1,6 @@
1
1
  import type { Movable } from "./movable";
2
- import type { Constraint, ConstraintCallbacks } from "./types";
2
+ import type { Constraint, ConstraintCallbacks, Coord } from "./types";
3
3
  import type { Graphie } from "../util/graphie";
4
- import type { Coord } from "@khanacademy/perseus";
5
4
  type State = {
6
5
  add: unknown[];
7
6
  added: boolean;
@@ -96,13 +96,13 @@ export declare const ApiOptions: {
96
96
  circle?: boolean | undefined;
97
97
  polygon?: boolean | undefined;
98
98
  linear?: boolean | undefined;
99
- point?: boolean | undefined;
100
99
  quadratic?: boolean | undefined;
101
100
  sinusoid?: boolean | undefined;
102
- angle?: boolean | undefined;
103
- "linear-system"?: boolean | undefined;
101
+ point?: boolean | undefined;
104
102
  ray?: boolean | undefined;
105
103
  segment?: boolean | undefined;
104
+ angle?: boolean | undefined;
105
+ "linear-system"?: boolean | undefined;
106
106
  } & {
107
107
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
108
108
  } & {
@@ -75,14 +75,28 @@ export type PerseusWidgetsMap = {
75
75
  } & {
76
76
  [key in `video ${number}`]: VideoWidget;
77
77
  };
78
+ /**
79
+ * A "PerseusItem" is a classic Perseus item. It is rendered by the
80
+ * `ServerItemRenderer` and the layout is pre-set.
81
+ *
82
+ * To render more complex Perseus items, see the `Item` type in the multi item
83
+ * area.
84
+ */
78
85
  export type PerseusItem = {
79
86
  question: PerseusRenderer;
80
87
  hints: ReadonlyArray<Hint>;
81
88
  answerArea: PerseusAnswerArea | null | undefined;
82
- _multi: any;
83
89
  itemDataVersion: Version;
84
90
  answer: any;
85
91
  };
92
+ /**
93
+ * A "MultiItem" is an advanced Perseus item. It is rendered by the
94
+ * `MultiRenderer` and you can control the layout of individual parts of the
95
+ * item.
96
+ */
97
+ export type MultiItem = {
98
+ _multi: any;
99
+ };
86
100
  export type PerseusArticle = ReadonlyArray<PerseusRenderer>;
87
101
  export type Version = {
88
102
  major: number;
@@ -105,7 +105,8 @@ 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, "problemNum" | "keypadElement" | "showSolutions" | "reviewMode" | "item" | "dependencies" | "hintsVisible"> & {
108
+ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps, "item" | "problemNum" | "showSolutions" | "reviewMode" | "keypadElement" | "hintsVisible" | "dependencies"> & {
109
+ linterContext?: PerseusLinter.LinterContextProps | undefined;
109
110
  apiOptions?: Readonly<{
110
111
  isArticle?: boolean | undefined;
111
112
  onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
@@ -143,13 +144,13 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
143
144
  circle?: boolean | undefined;
144
145
  polygon?: boolean | undefined;
145
146
  linear?: boolean | undefined;
146
- point?: boolean | undefined;
147
147
  quadratic?: boolean | undefined;
148
148
  sinusoid?: boolean | undefined;
149
- angle?: boolean | undefined;
150
- "linear-system"?: boolean | undefined;
149
+ point?: boolean | undefined;
151
150
  ray?: boolean | undefined;
152
151
  segment?: boolean | undefined;
152
+ angle?: boolean | undefined;
153
+ "linear-system"?: boolean | undefined;
153
154
  } & {
154
155
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
155
156
  } & {
@@ -162,7 +163,6 @@ declare const ref: React.ForwardRefExoticComponent<Omit<Pick<OwnProps & HOCProps
162
163
  } | undefined;
163
164
  onWidgetStartProps?: ((widgets: import("./perseus-types").PerseusWidgetsMap) => void) | undefined;
164
165
  }> | undefined;
165
- linterContext?: PerseusLinter.LinterContextProps | undefined;
166
166
  onRendered?: ((isRendered: boolean) => void) | undefined;
167
167
  } & {}, "onRendered"> & React.RefAttributes<ServerItemRenderer>>;
168
168
  export default ref;
@@ -1,2 +1,3 @@
1
- declare const FixPassageRefs: (itemData: any) => any;
2
- export default FixPassageRefs;
1
+ import type { MultiItem, PerseusItem } from "../perseus-types";
2
+ declare const fixPassageRefs: (itemData: PerseusItem | MultiItem) => any;
3
+ export default fixPassageRefs;
@@ -142,13 +142,13 @@ declare const _default: Readonly<{
142
142
  circle?: boolean | undefined;
143
143
  polygon?: boolean | undefined;
144
144
  linear?: boolean | undefined;
145
- point?: boolean | undefined;
146
145
  quadratic?: boolean | undefined;
147
146
  sinusoid?: boolean | undefined;
148
- angle?: boolean | undefined;
149
- "linear-system"?: boolean | undefined;
147
+ point?: boolean | undefined;
150
148
  ray?: boolean | undefined;
151
149
  segment?: boolean | undefined;
150
+ angle?: boolean | undefined;
151
+ "linear-system"?: boolean | undefined;
152
152
  } & {
153
153
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
154
154
  } & {
@@ -226,13 +226,13 @@ declare const _default: Readonly<{
226
226
  circle?: boolean | undefined;
227
227
  polygon?: boolean | undefined;
228
228
  linear?: boolean | undefined;
229
- point?: boolean | undefined;
230
229
  quadratic?: boolean | undefined;
231
230
  sinusoid?: boolean | undefined;
232
- angle?: boolean | undefined;
233
- "linear-system"?: boolean | undefined;
231
+ point?: boolean | undefined;
234
232
  ray?: boolean | undefined;
235
233
  segment?: boolean | undefined;
234
+ angle?: boolean | undefined;
235
+ "linear-system"?: boolean | undefined;
236
236
  } & {
237
237
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
238
238
  } & {
@@ -270,11 +270,9 @@ declare const _default: Readonly<{
270
270
  visibleLabel: string | undefined;
271
271
  ariaLabel: string | undefined;
272
272
  value: string;
273
- }, "static" | "analytics" | "onChange" | "ariaLabel" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "visibleLabel" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
273
+ }, "ariaLabel" | "trackInteraction" | "static" | "onChange" | "analytics" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "findWidgets" | "visibleLabel" | "keypadConfiguration" | "reviewModeRubric" | "isLastUsedWidget"> & {
274
274
  value?: string | undefined;
275
- buttonSets?: import("../perseus-types").LegacyButtonSets | undefined;
276
- onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
277
- onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
275
+ linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
278
276
  apiOptions?: Readonly<Readonly<{
279
277
  isArticle?: boolean | undefined;
280
278
  onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
@@ -312,13 +310,13 @@ declare const _default: Readonly<{
312
310
  circle?: boolean | undefined;
313
311
  polygon?: boolean | undefined;
314
312
  linear?: boolean | undefined;
315
- point?: boolean | undefined;
316
313
  quadratic?: boolean | undefined;
317
314
  sinusoid?: boolean | undefined;
318
- angle?: boolean | undefined;
319
- "linear-system"?: boolean | undefined;
315
+ point?: boolean | undefined;
320
316
  ray?: boolean | undefined;
321
317
  segment?: boolean | undefined;
318
+ angle?: boolean | undefined;
319
+ "linear-system"?: boolean | undefined;
322
320
  } & {
323
321
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
324
322
  } & {
@@ -347,9 +345,11 @@ declare const _default: Readonly<{
347
345
  setDrawingAreaAvailable: (arg1: boolean) => unknown;
348
346
  showAlignmentOptions: NonNullable<boolean | undefined>;
349
347
  }> | undefined;
348
+ buttonSets?: import("../perseus-types").LegacyButtonSets | undefined;
349
+ onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
350
+ onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
350
351
  functions?: readonly string[] | undefined;
351
352
  times?: boolean | undefined;
352
- linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
353
353
  } & {}, "analytics"> & React.RefAttributes<Expression>>) | undefined;
354
354
  widget: React.ForwardRefExoticComponent<Omit<Pick<RenderProps & {
355
355
  widgetId: string;
@@ -393,13 +393,13 @@ declare const _default: Readonly<{
393
393
  circle?: boolean | undefined;
394
394
  polygon?: boolean | undefined;
395
395
  linear?: boolean | undefined;
396
- point?: boolean | undefined;
397
396
  quadratic?: boolean | undefined;
398
397
  sinusoid?: boolean | undefined;
399
- angle?: boolean | undefined;
400
- "linear-system"?: boolean | undefined;
398
+ point?: boolean | undefined;
401
399
  ray?: boolean | undefined;
402
400
  segment?: boolean | undefined;
401
+ angle?: boolean | undefined;
402
+ "linear-system"?: boolean | undefined;
403
403
  } & {
404
404
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
405
405
  } & {
@@ -477,13 +477,13 @@ declare const _default: Readonly<{
477
477
  circle?: boolean | undefined;
478
478
  polygon?: boolean | undefined;
479
479
  linear?: boolean | undefined;
480
- point?: boolean | undefined;
481
480
  quadratic?: boolean | undefined;
482
481
  sinusoid?: boolean | undefined;
483
- angle?: boolean | undefined;
484
- "linear-system"?: boolean | undefined;
482
+ point?: boolean | undefined;
485
483
  ray?: boolean | undefined;
486
484
  segment?: boolean | undefined;
485
+ angle?: boolean | undefined;
486
+ "linear-system"?: boolean | undefined;
487
487
  } & {
488
488
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
489
489
  } & {
@@ -521,11 +521,9 @@ declare const _default: Readonly<{
521
521
  visibleLabel: string | undefined;
522
522
  ariaLabel: string | undefined;
523
523
  value: string;
524
- }, "static" | "analytics" | "onChange" | "ariaLabel" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "visibleLabel" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
524
+ }, "ariaLabel" | "trackInteraction" | "static" | "onChange" | "analytics" | "problemNum" | "questionCompleted" | "keypadElement" | "alignment" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "findWidgets" | "visibleLabel" | "keypadConfiguration" | "reviewModeRubric" | "isLastUsedWidget"> & {
525
525
  value?: string | undefined;
526
- buttonSets?: import("../perseus-types").LegacyButtonSets | undefined;
527
- onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
528
- onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
526
+ linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
529
527
  apiOptions?: Readonly<Readonly<{
530
528
  isArticle?: boolean | undefined;
531
529
  onInputError?: ((widgetId: any, value: string, message?: string | null | undefined) => unknown) | undefined;
@@ -563,13 +561,13 @@ declare const _default: Readonly<{
563
561
  circle?: boolean | undefined;
564
562
  polygon?: boolean | undefined;
565
563
  linear?: boolean | undefined;
566
- point?: boolean | undefined;
567
564
  quadratic?: boolean | undefined;
568
565
  sinusoid?: boolean | undefined;
569
- angle?: boolean | undefined;
570
- "linear-system"?: boolean | undefined;
566
+ point?: boolean | undefined;
571
567
  ray?: boolean | undefined;
572
568
  segment?: boolean | undefined;
569
+ angle?: boolean | undefined;
570
+ "linear-system"?: boolean | undefined;
573
571
  } & {
574
572
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
575
573
  } & {
@@ -598,9 +596,11 @@ declare const _default: Readonly<{
598
596
  setDrawingAreaAvailable: (arg1: boolean) => unknown;
599
597
  showAlignmentOptions: NonNullable<boolean | undefined>;
600
598
  }> | undefined;
599
+ buttonSets?: import("../perseus-types").LegacyButtonSets | undefined;
600
+ onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
601
+ onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
601
602
  functions?: readonly string[] | undefined;
602
603
  times?: boolean | undefined;
603
- linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
604
604
  } & {}, "analytics"> & React.RefAttributes<Expression>>;
605
605
  accessible?: boolean | ((props: any) => boolean) | undefined;
606
606
  hidden?: boolean | undefined;
@@ -1,5 +1,5 @@
1
+ import type { Coord } from "../../interactive2/types";
1
2
  import type { CollinearTuple, LockedFigureColor, LockedFigureFillType, LockedFunctionType, PerseusRenderer } from "../../perseus-types";
2
- import type { Coord } from "@khanacademy/perseus";
3
3
  import type { vec } from "mafs";
4
4
  export type LockedFunctionOptions = Omit<Partial<LockedFunctionType>, "type" | "equation">;
5
5
  export declare function interactiveGraphQuestionBuilder(): InteractiveGraphQuestionBuilder;
@@ -1,6 +1,6 @@
1
+ import type { Coord } from "../../../interactive2/types";
1
2
  import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypeCircle, PerseusGraphTypeLinear, PerseusGraphTypeLinearSystem, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeQuadratic, PerseusGraphTypeRay, PerseusGraphTypeSegment, PerseusGraphTypeSinusoid } from "../../../perseus-types";
2
3
  import type { InteractiveGraphState, PairOfPoints } from "../types";
3
- import type { Coord } from "@khanacademy/perseus";
4
4
  import type { Interval } from "mafs";
5
5
  export type InitializeGraphStateParams = {
6
6
  range: [x: Interval, y: Interval];
@@ -1,5 +1,5 @@
1
+ import type { PerseusGraphType } from "../../../perseus-types";
1
2
  import type { CircleGraphState, InteractiveGraphState } from "../types";
2
- import type { PerseusGraphType } from "@khanacademy/perseus";
3
3
  export declare function getGradableGraph(state: InteractiveGraphState, initialGraph: PerseusGraphType): PerseusGraphType;
4
4
  /**
5
5
  * determine radius of a circle graph
@@ -1,7 +1,7 @@
1
1
  import * as React from "react";
2
2
  import type { InteractiveGraphProps } from "./types";
3
+ import type { PerseusGraphType } from "../../perseus-types";
3
4
  import type { Widget } from "../../renderer";
4
- import type { PerseusGraphType } from "@khanacademy/perseus";
5
5
  export type StatefulMafsGraphProps = {
6
6
  box: [number, number];
7
7
  backgroundImage?: InteractiveGraphProps["backgroundImage"];
@@ -1,7 +1,7 @@
1
1
  import type { InteractiveGraphAction } from "./reducer/interactive-graph-action";
2
+ import type { Coord } from "../../interactive2/types";
2
3
  import type { PerseusInteractiveGraphWidgetOptions } from "../../perseus-types";
3
4
  import type { WidgetProps } from "../../types";
4
- import type { Coord } from "@khanacademy/perseus";
5
5
  import type { Interval, vec } from "mafs";
6
6
  export type InteractiveGraphProps = WidgetProps<PerseusInteractiveGraphWidgetOptions, PerseusInteractiveGraphWidgetOptions>;
7
7
  export type MafsGraphProps<T extends InteractiveGraphState> = {
@@ -134,13 +134,13 @@ declare const _default: Readonly<{
134
134
  circle?: boolean | undefined;
135
135
  polygon?: boolean | undefined;
136
136
  linear?: boolean | undefined;
137
- point?: boolean | undefined;
138
137
  quadratic?: boolean | undefined;
139
138
  sinusoid?: boolean | undefined;
140
- angle?: boolean | undefined;
141
- "linear-system"?: boolean | undefined;
139
+ point?: boolean | undefined;
142
140
  ray?: boolean | undefined;
143
141
  segment?: boolean | undefined;
142
+ angle?: boolean | undefined;
143
+ "linear-system"?: boolean | undefined;
144
144
  } & {
145
145
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
146
146
  } & {
@@ -202,13 +202,13 @@ declare const _default: Readonly<{
202
202
  circle?: boolean | undefined;
203
203
  polygon?: boolean | undefined;
204
204
  linear?: boolean | undefined;
205
- point?: boolean | undefined;
206
205
  quadratic?: boolean | undefined;
207
206
  sinusoid?: boolean | undefined;
208
- angle?: boolean | undefined;
209
- "linear-system"?: boolean | undefined;
207
+ point?: boolean | undefined;
210
208
  ray?: boolean | undefined;
211
209
  segment?: boolean | undefined;
210
+ angle?: boolean | undefined;
211
+ "linear-system"?: boolean | undefined;
212
212
  } & {
213
213
  "interactive-graph-locked-features-m2b"?: boolean | undefined;
214
214
  } & {
@@ -5,10 +5,10 @@ declare const _default: Readonly<{
5
5
  widget: any;
6
6
  accessible?: boolean | ((props: any) => boolean) | undefined;
7
7
  hidden?: boolean | undefined;
8
- version?: import("@khanacademy/perseus").Version | undefined;
9
- supportedAlignments?: readonly import("@khanacademy/perseus").Alignment[] | undefined;
10
- defaultAlignment?: import("@khanacademy/perseus").Alignment | undefined;
11
- getDefaultAlignment?: (() => import("@khanacademy/perseus").Alignment) | undefined;
8
+ version?: import("../types").Version | undefined;
9
+ supportedAlignments?: readonly import("../types").Alignment[] | undefined;
10
+ defaultAlignment?: import("../types").Alignment | undefined;
11
+ getDefaultAlignment?: (() => import("../types").Alignment) | undefined;
12
12
  isLintable?: boolean | undefined;
13
13
  tracking?: import("../types").Tracking | undefined;
14
14
  traverseChildWidgets?: any;
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": "28.2.0",
6
+ "version": "30.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,3 +0,0 @@
1
- /**
2
- * Sets up the basic environment for running Perseus in.
3
- */