@khanacademy/perseus 77.2.0 → 77.2.2

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.
Files changed (47) hide show
  1. package/dist/components/gif-image.d.ts +38 -0
  2. package/dist/components/svg-image.d.ts +12 -0
  3. package/dist/es/index.css +1 -1
  4. package/dist/es/index.css.map +1 -1
  5. package/dist/es/index.js +11 -8
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/hint-renderer.d.ts +15 -2
  8. package/dist/index.css +1 -1
  9. package/dist/index.css.map +1 -1
  10. package/dist/index.d.ts +99 -6
  11. package/dist/index.js +11 -8
  12. package/dist/index.js.map +1 -1
  13. package/dist/renderer.d.ts +3 -3
  14. package/dist/testing/test-dependencies.d.ts +0 -1
  15. package/dist/types.d.ts +2 -1
  16. package/dist/widget-ai-utils/categorizer/categorizer-ai-utils.d.ts +29 -0
  17. package/dist/widget-ai-utils/definition/definition-ai-utils.d.ts +8 -0
  18. package/dist/widget-ai-utils/dropdown/dropdown-ai-utils.d.ts +12 -0
  19. package/dist/widget-ai-utils/explanation/explanation-ai-utils.d.ts +12 -0
  20. package/dist/widget-ai-utils/expression/expression-ai-utils.d.ts +11 -0
  21. package/dist/widget-ai-utils/graded-group/graded-group-ai-utils.d.ts +15 -3
  22. package/dist/widget-ai-utils/graded-group-set/graded-group-set-ai-utils.d.ts +10 -0
  23. package/dist/widget-ai-utils/grapher/grapher-ai-utils.d.ts +35 -0
  24. package/dist/widget-ai-utils/group/group-ai-utils.d.ts +6 -0
  25. package/dist/widget-ai-utils/image/image-ai-utils.d.ts +16 -0
  26. package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +22 -0
  27. package/dist/widget-ai-utils/interactive-graph/interactive-graph-ai-utils.d.ts +50 -21
  28. package/dist/widget-ai-utils/label-image/label-image-ai-utils.d.ts +63 -0
  29. package/dist/widget-ai-utils/matcher/matcher-ai-utils.d.ts +40 -0
  30. package/dist/widget-ai-utils/matrix/matrix-ai-utils.d.ts +23 -0
  31. package/dist/widget-ai-utils/number-line/number-line-ai-utils.d.ts +52 -0
  32. package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +17 -0
  33. package/dist/widget-ai-utils/orderer/orderer-ai-utils.d.ts +23 -0
  34. package/dist/widget-ai-utils/prompt-types.d.ts +16 -2
  35. package/dist/widget-ai-utils/radio/radio-ai-utils.d.ts +38 -0
  36. package/dist/widget-ai-utils/sorter/sorter-ai-utils.d.ts +19 -0
  37. package/dist/widget-ai-utils/unsupported-widget.d.ts +6 -5
  38. package/dist/widgets/dropdown/dropdown.d.ts +1 -1
  39. package/dist/widgets/expression/expression.d.ts +2 -2
  40. package/dist/widgets/image/components/explore-image-modal-content.d.ts +1 -1
  41. package/dist/widgets/interactive-graphs/interactive-graph.d.ts +1 -1
  42. package/dist/widgets/label-image/label-image.d.ts +1 -1
  43. package/dist/widgets/mock-widgets/mock-widget.d.ts +1 -1
  44. package/dist/widgets/numeric-input/numeric-input.class.d.ts +1 -1
  45. package/dist/widgets/numeric-input/numeric-input.d.ts +1 -1
  46. package/dist/widgets/table/table.d.ts +1 -1
  47. package/package.json +9 -8
@@ -1,14 +1,66 @@
1
1
  import type numberLine from "../../widgets/number-line/number-line";
2
2
  import type React from "react";
3
+ /**
4
+ * JSON describing a number-line widget. Intended for consumption by AI tools.
5
+ * A number-line widget displays a horizontal number line with a draggable
6
+ * point. The learner positions the point to answer a question, optionally
7
+ * selecting an inequality relationship (e.g. ≤, ≥) when the widget is in
8
+ * inequality mode.
9
+ */
3
10
  export type NumberLinePromptJSON = {
4
11
  type: "number-line";
12
+ /**
13
+ * The configuration of the widget, set by the content creator.
14
+ */
5
15
  options: {
16
+ /**
17
+ * The numeric values of the left and right endpoints of the number
18
+ * line, e.g. `[-5, 5]`. These bounds also constrain where the learner
19
+ * can place the point.
20
+ */
6
21
  range: ReadonlyArray<number>;
22
+ /**
23
+ * The number of sub-intervals between adjacent tick marks into which
24
+ * the point can snap. Higher values allow finer-grained placement.
25
+ * For example, a value of `4` means the point snaps to quarter-tick
26
+ * increments.
27
+ */
7
28
  snapDivisions: number;
8
29
  };
30
+ /**
31
+ * The current state of the widget user interface. Usually represents a
32
+ * learner's attempt to answer a question.
33
+ */
9
34
  userInput: {
35
+ /**
36
+ * The numeric axis value where the learner has placed the point,
37
+ * e.g. `3.5` on a `[-5, 5]` number line. Clamped to `options.range`
38
+ * and snapped to the nearest tick increment.
39
+ */
10
40
  numLinePosition: number;
41
+ /**
42
+ * The number of tick-mark divisions currently shown on the number
43
+ * line. When the widget's `isTickCtrl` option is enabled, the learner
44
+ * can adjust this value; otherwise it is set by the content author.
45
+ */
11
46
  numDivisions: number;
47
+ /**
48
+ * The number line widget can represent a set of real numbers that is
49
+ * greater than, greater than or equal to, less than, or less than or
50
+ * equal to some number. Visually, the portion of the number line
51
+ * included in this set is shaded. The `rel` property describes the
52
+ * inequality relation the learner has selected.
53
+ *
54
+ * Possible values:
55
+ * - `"eq"` – equals (standard point, no inequality shading)
56
+ * - `"lt"` – less than
57
+ * - `"gt"` – greater than
58
+ * - `"le"` – less than or equal to
59
+ * - `"ge"` – greater than or equal to
60
+ *
61
+ * Only meaningful when the widget is configured for inequality mode;
62
+ * otherwise always `"eq"`.
63
+ */
12
64
  rel: string;
13
65
  };
14
66
  };
@@ -1,9 +1,26 @@
1
1
  import type numericInput from "../../widgets/numeric-input/numeric-input.class";
2
2
  import type React from "react";
3
+ /**
4
+ * JSON describing a numeric-input widget. Intended for consumption by AI tools.
5
+ * A numeric-input widget displays a single text field where the learner types
6
+ * a numeric answer (integer, decimal, fraction, etc.).
7
+ */
3
8
  export type NumericInputPromptJSON = {
4
9
  type: "numeric-input";
10
+ /**
11
+ * Accessible label for the input field, set by the content creator.
12
+ * Shown to learners using screen readers to describe what value should
13
+ * be entered.
14
+ */
5
15
  label: string;
16
+ /**
17
+ * The current state of the widget user interface. Usually represents a
18
+ * learner's attempt to answer a question.
19
+ */
6
20
  userInput: {
21
+ /**
22
+ * The text currently entered in the input field by the learner.
23
+ */
7
24
  value: string;
8
25
  };
9
26
  };
@@ -1,11 +1,34 @@
1
1
  import type orderer from "../../widgets/orderer/orderer";
2
2
  import type React from "react";
3
+ /**
4
+ * JSON describing an orderer widget. Intended for consumption by AI tools.
5
+ * An orderer presents a set of cards that the learner must arrange into the
6
+ * correct sequence. Cards can be dragged and dropped to reorder them. The
7
+ * same card may appear multiple times in the correct answer but is displayed
8
+ * only once in the card bank.
9
+ */
3
10
  export type OrdererPromptJSON = {
4
11
  type: "orderer";
12
+ /**
13
+ * The configuration of the widget, set by the content creator.
14
+ */
5
15
  options: {
16
+ /**
17
+ * All of the cards available to the learner. Each string is the
18
+ * rendered content of one card (may include TeX or Markdown).
19
+ */
6
20
  options: ReadonlyArray<string>;
7
21
  };
22
+ /**
23
+ * The current state of the widget user interface. Usually represents a
24
+ * learner's attempt to answer a question.
25
+ */
8
26
  userInput: {
27
+ /**
28
+ * The cards in their current order as arranged by the learner. Each
29
+ * string is the content of a card. An empty array means the learner
30
+ * has not yet placed any cards.
31
+ */
9
32
  values: ReadonlyArray<string>;
10
33
  };
11
34
  };
@@ -21,12 +21,26 @@ import type { SorterPromptJSON } from "./sorter/sorter-ai-utils";
21
21
  import type { UnsupportedWidgetPromptJSON } from "./unsupported-widget";
22
22
  export type UnsupportedWidget = "cs-program" | "iframe" | "interaction" | "interactive-graph-unsupported" | "measurer" | "phet-simulation" | "plotter" | "python-program" | "video";
23
23
  export type WidgetPromptJSON = CategorizerPromptJSON | DefinitionPromptJSON | DropdownPromptJSON | ExplanationPromptJSON | ExpressionPromptJSON | GradedGroupPromptJSON | GradedGroupSetPromptJSON | GrapherPromptJSON | GroupPromptJSON | ImagePromptJSON | InputNumberPromptJSON | LabelImagePromptJSON | MatcherPromptJSON | MatrixPromptJSON | MockWidgetPromptJSON | NumberLinePromptJSON | NumericInputPromptJSON | OrdererPromptJSON | RadioPromptJSON | SorterPromptJSON | UnsupportedWidgetPromptJSON;
24
- export type RendererPromptJSON = {
24
+ /**
25
+ * JSON describing a Perseus renderer. Intended for consumption by AI tools.
26
+ * A "renderer" is essentially a Markdown document with embedded interactive
27
+ * widgets.
28
+ */
29
+ export interface RendererPromptJSON {
30
+ /**
31
+ * Markdown content of the document. Widgets are represented by
32
+ * placeholders containing a Unicode snowman symbol, e.g.
33
+ * `[[☃ radio 1]]`. May contain TeX delimited by dollar signs, e.g.
34
+ * `$\dfrac{1}{2}$`. Literal dollar signs are escaped by backslashes.
35
+ */
25
36
  content: string;
37
+ /**
38
+ * Information about the configuration and UI state of each widget.
39
+ */
26
40
  widgets: {
27
41
  [widgetId: string]: WidgetPromptJSON;
28
42
  };
29
- };
43
+ }
30
44
  export interface GetPromptJSONInterface {
31
45
  getPromptJSON(): RendererPromptJSON;
32
46
  }
@@ -1,16 +1,54 @@
1
1
  import type radio from "../../widgets/radio";
2
2
  import type { PerseusRadioUserInput, RecursiveReadonly } from "@khanacademy/perseus-core";
3
3
  import type React from "react";
4
+ /**
5
+ * A single answer choice in a radio widget.
6
+ */
4
7
  type BasicOption = {
8
+ /**
9
+ * The label displayed for this choice.
10
+ */
5
11
  value: string;
12
+ /**
13
+ * An opaque string that uniquely identifies this choice within the radio
14
+ * widget. The format is subject to change.
15
+ */
6
16
  id: string;
17
+ /**
18
+ * Rationale for why this answer is correct or incorrect. Shown to the
19
+ * learner when they select an incorrect answer. Only present when the
20
+ * content creator supplied one.
21
+ */
7
22
  rationale?: string;
8
23
  };
24
+ /**
25
+ * JSON describing a radio (multiple-choice) widget. Intended for consumption
26
+ * by AI tools. A radio widget presents a list of answer choices and asks the
27
+ * learner to select one (or, when multiple-select is enabled, one or more).
28
+ */
9
29
  export type RadioPromptJSON = {
10
30
  type: "radio";
31
+ /**
32
+ * Whether the widget includes a "None of the above" option. When true,
33
+ * the last entry in `options` represents that special choice.
34
+ */
11
35
  hasNoneOfTheAbove: boolean;
36
+ /**
37
+ * The answer choices presented to the learner, in the order they appear
38
+ * on screen. The first choice is labeled "A", the second is "B", and so
39
+ * on.
40
+ */
12
41
  options: BasicOption[];
42
+ /**
43
+ * The current state of the widget user interface. Usually represents a
44
+ * learner's attempt to answer a question.
45
+ */
13
46
  userInput: {
47
+ /**
48
+ * The IDs of the choices the learner has selected. Each entry
49
+ * corresponds to a choice's `id` field in `options`. Order is
50
+ * insignificant — scoring uses set membership, not position.
51
+ */
14
52
  selectedOptions: ReadonlyArray<string>;
15
53
  };
16
54
  };
@@ -1,8 +1,27 @@
1
1
  import type { PerseusSorterUserInput } from "@khanacademy/perseus-core";
2
+ /**
3
+ * JSON describing a sorter widget. Intended for consumption by AI tools.
4
+ * A sorter presents a list of cards that the learner must arrange into the
5
+ * correct order by dragging them. The cards are initially displayed in a
6
+ * randomized order.
7
+ */
2
8
  export type SorterPromptJSON = {
3
9
  type: "sorter";
10
+ /**
11
+ * The current state of the widget user interface. Usually represents a
12
+ * learner's attempt to answer a question.
13
+ */
4
14
  userInput: {
15
+ /**
16
+ * The content strings of the sortable cards in the learner's current
17
+ * order.
18
+ */
5
19
  values: ReadonlyArray<string>;
20
+ /**
21
+ * Whether the learner has moved any cards from their initial
22
+ * randomized order. The widget is considered empty (invalid) until
23
+ * this is true.
24
+ */
6
25
  changed: boolean;
7
26
  };
8
27
  };
@@ -1,11 +1,12 @@
1
1
  import type { UnsupportedWidget } from "./prompt-types";
2
+ /**
3
+ * A placeholder in prompt JSON for a widget that doesn't support AI tooling.
4
+ */
2
5
  export type UnsupportedWidgetPromptJSON = {
3
6
  type: UnsupportedWidget;
7
+ /** Always empty; not used. */
4
8
  message?: string;
9
+ /** Always false. */
5
10
  isSupported: boolean;
6
11
  };
7
- export declare const getUnsupportedPromptJSON: (widgetType: UnsupportedWidget, message?: string) => {
8
- type: UnsupportedWidget;
9
- isSupported: boolean;
10
- message: string;
11
- };
12
+ export declare const getUnsupportedPromptJSON: (widgetType: UnsupportedWidget, message?: string) => UnsupportedWidgetPromptJSON;
@@ -68,7 +68,7 @@ declare const _default: {
68
68
  keypadElement?: any;
69
69
  onFocus: (blurPath: import("../..").FocusPath) => void;
70
70
  onBlur: (blurPath: import("../..").FocusPath) => void;
71
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
71
+ findWidgets: import("../../types").FindWidgetsFunction;
72
72
  reviewMode: boolean;
73
73
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
74
74
  handleUserInput: (newUserInput: PerseusDropdownUserInput, cb?: () => void, silent?: boolean) => void;
@@ -58,7 +58,7 @@ export declare const Expression: React.ForwardRefExoticComponent<PerseusExpressi
58
58
  keypadElement?: any;
59
59
  onFocus: (blurPath: FocusPath) => void;
60
60
  onBlur: (blurPath: FocusPath) => void;
61
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
61
+ findWidgets: import("../../types").FindWidgetsFunction;
62
62
  reviewMode: boolean;
63
63
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
64
64
  handleUserInput: (newUserInput: string, cb?: () => void, silent?: boolean) => void;
@@ -137,7 +137,7 @@ declare const _default: {
137
137
  keypadElement?: any;
138
138
  onFocus: (blurPath: FocusPath) => void;
139
139
  onBlur: (blurPath: FocusPath) => void;
140
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
140
+ findWidgets: import("../../types").FindWidgetsFunction;
141
141
  reviewMode: boolean;
142
142
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
143
143
  handleUserInput: (newUserInput: string, cb?: () => void, silent?: boolean) => void;
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
2
  import type { CommonImageProps, ZoomProps, GifProps } from "./image-info-area";
3
3
  type Props = CommonImageProps & ZoomProps & GifProps;
4
- export default function ExploreImageModalContent({ backgroundImage, scale: contentScale, caption, alt, longDescription, linterContext, apiOptions, box, labels, range, zoomSize, isGifPlaying, setIsGifPlaying, }: Props): React.JSX.Element | null;
4
+ export default function ExploreImageModalContent({ backgroundImage, scale: contentScale, caption, alt, longDescription, linterContext, apiOptions, box, labels, range, zoomSize, }: Props): React.JSX.Element | null;
5
5
  export {};
@@ -210,7 +210,7 @@ declare class InteractiveGraph extends React.Component<Props, State> {
210
210
  keypadElement?: any;
211
211
  onFocus: (blurPath: import("../..").FocusPath) => void;
212
212
  onBlur: (blurPath: import("../..").FocusPath) => void;
213
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<import("../../types").Widget>;
213
+ findWidgets: import("../../types").FindWidgetsFunction;
214
214
  reviewMode: boolean;
215
215
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
216
216
  handleUserInput: (newUserInput: PerseusGraphType, cb?: () => void, silent?: boolean) => void;
@@ -167,7 +167,7 @@ declare const _default: {
167
167
  keypadElement?: any;
168
168
  onFocus: (blurPath: import("../..").FocusPath) => void;
169
169
  onBlur: (blurPath: import("../..").FocusPath) => void;
170
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
170
+ findWidgets: import("../../types").FindWidgetsFunction;
171
171
  reviewMode: boolean;
172
172
  showSolutions?: ShowSolutions;
173
173
  handleUserInput: (newUserInput: PerseusLabelImageUserInput, cb?: () => void, silent?: boolean) => void;
@@ -91,7 +91,7 @@ declare class MockWidgetComponent extends React.Component<Props> implements Widg
91
91
  keypadElement?: any;
92
92
  onFocus: (blurPath: import("../..").FocusPath) => void;
93
93
  onBlur: (blurPath: import("../..").FocusPath) => void;
94
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
94
+ findWidgets: import("../../types").FindWidgetsFunction;
95
95
  reviewMode: boolean;
96
96
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
97
97
  handleUserInput: (newUserInput: PerseusMockWidgetUserInput, cb?: () => void, silent?: boolean) => void;
@@ -98,7 +98,7 @@ export declare class NumericInput extends React.Component<NumericInputProps> imp
98
98
  keypadElement?: any;
99
99
  onFocus: (blurPath: import("../..").FocusPath) => void;
100
100
  onBlur: (blurPath: import("../..").FocusPath) => void;
101
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
101
+ findWidgets: import("../../types").FindWidgetsFunction;
102
102
  reviewMode: boolean;
103
103
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
104
104
  handleUserInput: (newUserInput: PerseusNumericInputUserInput, cb?: () => void, silent?: boolean) => void;
@@ -61,7 +61,7 @@ export declare const NumericInputComponent: React.ForwardRefExoticComponent<impo
61
61
  keypadElement?: any;
62
62
  onFocus: (blurPath: import("../..").FocusPath) => void;
63
63
  onBlur: (blurPath: import("../..").FocusPath) => void;
64
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<import("../../types").Widget>;
64
+ findWidgets: import("../../types").FindWidgetsFunction;
65
65
  reviewMode: boolean;
66
66
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
67
67
  handleUserInput: (newUserInput: import("@khanacademy/perseus-core").PerseusNumericInputUserInput, cb?: () => void, silent?: boolean) => void;
@@ -99,7 +99,7 @@ declare class Table extends React.Component<Props> implements Widget {
99
99
  keypadElement?: any;
100
100
  onFocus: (blurPath: FocusPath) => void;
101
101
  onBlur: (blurPath: FocusPath) => void;
102
- findWidgets: (criterion: import("../../types").FilterCriterion) => ReadonlyArray<Widget>;
102
+ findWidgets: import("../../types").FindWidgetsFunction;
103
103
  reviewMode: boolean;
104
104
  showSolutions?: import("@khanacademy/perseus-core").ShowSolutions;
105
105
  handleUserInput: (newUserInput: PerseusTableUserInput, cb?: () => void, silent?: boolean) => void;
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": "77.2.0",
6
+ "version": "77.2.2",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -38,16 +38,17 @@
38
38
  ],
39
39
  "dependencies": {
40
40
  "@use-gesture/react": "^10.2.27",
41
+ "gifuct-js": "^2.1.2",
41
42
  "mafs": "0.19.0",
42
43
  "tiny-invariant": "1.3.1",
43
44
  "uuid": "^10.0.0",
44
45
  "@khanacademy/kas": "2.2.1",
45
- "@khanacademy/keypad-context": "3.2.42",
46
- "@khanacademy/kmath": "2.4.0",
47
- "@khanacademy/math-input": "26.4.13",
48
- "@khanacademy/perseus-core": "24.1.0",
49
- "@khanacademy/perseus-linter": "4.9.2",
50
- "@khanacademy/perseus-score": "8.6.0",
46
+ "@khanacademy/keypad-context": "3.2.43",
47
+ "@khanacademy/kmath": "2.4.1",
48
+ "@khanacademy/math-input": "26.4.14",
49
+ "@khanacademy/perseus-core": "24.1.1",
50
+ "@khanacademy/perseus-linter": "4.9.4",
51
+ "@khanacademy/perseus-score": "8.6.1",
51
52
  "@khanacademy/perseus-utils": "2.1.5",
52
53
  "@khanacademy/pure-markdown": "2.2.7",
53
54
  "@khanacademy/simple-markdown": "2.2.2"
@@ -61,8 +62,8 @@
61
62
  "@khanacademy/wonder-blocks-data": "15.0.1",
62
63
  "@khanacademy/wonder-blocks-dropdown": "10.8.3",
63
64
  "@khanacademy/wonder-blocks-form": "7.5.6",
64
- "@khanacademy/wonder-blocks-icon-button": "11.1.6",
65
65
  "@khanacademy/wonder-blocks-icon": "5.3.9",
66
+ "@khanacademy/wonder-blocks-icon-button": "11.1.6",
66
67
  "@khanacademy/wonder-blocks-labeled-field": "4.0.16",
67
68
  "@khanacademy/wonder-blocks-layout": "3.1.46",
68
69
  "@khanacademy/wonder-blocks-link": "10.1.7",