@khanacademy/perseus 44.0.0 → 45.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,8 +1,10 @@
1
- import type { PerseusWidgetsMap } from "./perseus-types";
1
+ import type { PerseusRenderer, PerseusWidgetsMap } from "./perseus-types";
2
2
  import type { PerseusStrings } from "./strings";
3
3
  import type { PerseusScore } from "./types";
4
4
  import type { UserInputMap } from "./validation.types";
5
+ export declare function getUpgradedWidgetOptions(oldWidgetOptions: PerseusWidgetsMap): PerseusWidgetsMap;
5
6
  export declare function emptyWidgetsFunctional(widgets: PerseusWidgetsMap, widgetIds: Array<string>, userInputMap: UserInputMap, strings: PerseusStrings, locale: string): ReadonlyArray<string>;
6
- export declare function scoreWidgetsFunctional(widgets: PerseusWidgetsMap, widgetIds: Array<string>, userInputMap: UserInputMap, strings: PerseusStrings, locale: string): {
7
+ export declare function scorePerseusItem(perseusRenderData: PerseusRenderer, userInputMap: UserInputMap, strings: PerseusStrings, locale: string): PerseusScore;
8
+ export declare function scoreWidgetsFunctional(widgets: PerseusWidgetsMap, widgetIds: ReadonlyArray<string>, userInputMap: UserInputMap, strings: PerseusStrings, locale: string): {
7
9
  [widgetId: string]: PerseusScore;
8
10
  };
@@ -103,7 +103,6 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
103
103
  widgetInfo: State["widgetInfo"];
104
104
  widgetProps: State["widgetProps"];
105
105
  };
106
- _getAllWidgetsInfo: (props: Props) => PerseusWidgetsMap;
107
106
  _getAllWidgetsStartProps: (allWidgetInfo: PerseusWidgetsMap, props: Props) => PerseusWidgetsMap;
108
107
  _getDefaultWidgetInfo: (widgetId: string) => any;
109
108
  _getWidgetInfo: (widgetId: string) => PerseusWidget;
@@ -218,18 +217,15 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
218
217
  */
219
218
  getPromptJSON(): RendererPromptJSON;
220
219
  /**
221
- * Returns an object mapping from widget ID to perseus-style score.
222
- * The keys of this object are the values of the array returned
223
- * from `getWidgetIds`.
220
+ * Scores the content.
221
+ *
222
+ * @deprecated use scorePerseusItem
224
223
  */
225
- scoreWidgets(): {
226
- [widgetId: string]: PerseusScore;
227
- };
224
+ score(): PerseusScore;
228
225
  /**
229
- * Grades the content.
226
+ * @deprecated use scorePerseusItem
230
227
  */
231
- score(): PerseusScore;
232
- guessAndScore(): [UserInputArray, PerseusScore];
228
+ guessAndScore: () => [UserInputArray, PerseusScore];
233
229
  examples: () => ReadonlyArray<string> | null | undefined;
234
230
  handletranslationLintErrors: (lintErrors: ReadonlyArray<string>) => void;
235
231
  render(): React.ReactNode;
@@ -12,12 +12,14 @@ import { PerseusI18nContext } from "./components/i18n-context";
12
12
  import Renderer from "./renderer";
13
13
  import type { PerseusItem, ShowSolutions } from "./perseus-types";
14
14
  import type { FocusPath, PerseusDependenciesV2, SharedRendererProps } from "./types";
15
+ import type { UserInputArray, UserInputMap } from "./validation.types";
15
16
  import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
16
17
  import type { KeypadAPI } from "@khanacademy/math-input";
17
18
  import type { KeypadContextRendererInterface, RendererInterface, KEScore } from "@khanacademy/perseus-core";
18
19
  type OwnProps = {
19
20
  hintsVisible?: number;
20
21
  item: PerseusItem;
22
+ score?: KEScore | null;
21
23
  problemNum?: number;
22
24
  reviewMode?: boolean;
23
25
  keypadElement?: KeypadAPI | null | undefined;
@@ -30,8 +32,23 @@ type HOCProps = {
30
32
  type Props = SharedRendererProps & OwnProps & HOCProps;
31
33
  type DefaultProps = Required<Pick<Props, "apiOptions" | "onRendered" | "linterContext">>;
32
34
  type State = {
35
+ /**
36
+ * questionCompleted is used to signal that a learner has attempted
37
+ * the exercise. This is used when widgets want to show things like
38
+ * rationale or partial correctness.
39
+ */
33
40
  questionCompleted: boolean;
34
- questionHighlightedWidgets: ReadonlyArray<any>;
41
+ /**
42
+ * As far as I can tell, this is used to highlight empty widgets
43
+ * after a learner has clicked the "check" button. I don't think this could
44
+ * still be used though, because the "check" button is disabled while there
45
+ * are empty widgets.
46
+ */
47
+ questionHighlightedWidgets: ReadonlyArray<string>;
48
+ /**
49
+ * Keeps track of whether each asset (SvgImage or TeX) rendered by
50
+ * the questionRenderer has finished loading or rendering.
51
+ */
35
52
  assetStatuses: {
36
53
  [assetKey: string]: boolean;
37
54
  };
@@ -76,8 +93,22 @@ export declare class ServerItemRenderer extends React.Component<Props, State> im
76
93
  blur(): void;
77
94
  getNumHints(): number;
78
95
  getPromptJSON(): RendererPromptJSON;
96
+ /**
97
+ * Returns an array of the widget `.getUserInput()` results
98
+ *
99
+ * TODO: can we remove this? Seems to be just for backwards
100
+ * compatibility with old Perseus Chrome logging
101
+ * @deprecated use getUserInput
102
+ */
103
+ getUserInputLegacy(): UserInputArray;
104
+ /**
105
+ * Returns an object of the widget `.getUserInput()` results
106
+ */
107
+ getUserInput(): UserInputMap;
79
108
  /**
80
109
  * Grades the item.
110
+ *
111
+ * @deprecated use scorePerseusItem
81
112
  */
82
113
  scoreInput(): KEScore;
83
114
  /**
package/dist/types.d.ts CHANGED
@@ -403,6 +403,11 @@ export type WidgetProps<RenderProps, Rubric = Empty, TrackingExtraArgs = Empty>
403
403
  problemNum: number | null | undefined;
404
404
  apiOptions: APIOptionsWithDefaults;
405
405
  keypadElement?: any;
406
+ /**
407
+ * questionCompleted is used to signal that a learner has attempted
408
+ * the exercise. This is used when widgets want to show things like
409
+ * rationale or partial correctness.
410
+ */
406
411
  questionCompleted?: boolean;
407
412
  onFocus: (blurPath: FocusPath) => void;
408
413
  onBlur: (blurPath: FocusPath) => void;
@@ -172,7 +172,7 @@ declare const _default: {
172
172
  visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
173
173
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
174
174
  value: string;
175
- }, "ariaLabel" | "static" | "onChange" | "keypadElement" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "alignment" | "reviewModeRubric" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
175
+ }, "ariaLabel" | "static" | "onChange" | "keypadElement" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "alignment" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "reviewModeRubric" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
176
176
  value?: string | undefined;
177
177
  onFocus?: ((blurPath: FocusPath) => void) | undefined;
178
178
  onBlur?: ((blurPath: FocusPath) => void) | undefined;
@@ -23,7 +23,7 @@ declare class Group extends React.Component<Props> implements Widget {
23
23
  static defaultProps: DefaultProps;
24
24
  componentDidMount(): void;
25
25
  change: ChangeFn;
26
- getUserInputMap(): import("../../validation.types").UserInputMap | undefined;
26
+ getUserInputMap(): import("../..").UserInputMap | undefined;
27
27
  /**
28
28
  * @deprecated getUserInputMap should be used for Groups
29
29
  */
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": "44.0.0",
6
+ "version": "45.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },