@khanacademy/perseus 52.0.1 → 53.1.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.
Files changed (72) hide show
  1. package/dist/components/number-input.d.ts +2 -0
  2. package/dist/components/range-input.d.ts +1 -0
  3. package/dist/components/svg-image.d.ts +2 -2
  4. package/dist/es/index.css +0 -30
  5. package/dist/es/index.js +893 -1042
  6. package/dist/es/index.js.map +1 -1
  7. package/dist/es/strings.js +42 -6
  8. package/dist/es/strings.js.map +1 -1
  9. package/dist/index.css +0 -30
  10. package/dist/index.d.ts +1 -2
  11. package/dist/index.js +913 -2263
  12. package/dist/index.js.map +1 -1
  13. package/dist/perseus-api.d.ts +0 -1
  14. package/dist/renderer.d.ts +1 -1
  15. package/dist/server-item-renderer.d.ts +0 -3
  16. package/dist/strings.d.ts +36 -0
  17. package/dist/strings.js +60 -6
  18. package/dist/strings.js.map +1 -1
  19. package/dist/styles/constants.d.ts +0 -2
  20. package/dist/types.d.ts +3 -32
  21. package/dist/util/math-utils.d.ts +1 -0
  22. package/dist/util/scoring.d.ts +0 -15
  23. package/dist/util/test-utils.d.ts +1 -1
  24. package/dist/widget-ai-utils/mock-widget/prompt-utils.d.ts +1 -1
  25. package/dist/widget-container.d.ts +1 -1
  26. package/dist/widgets/categorizer/categorizer.d.ts +0 -3
  27. package/dist/widgets/cs-program/cs-program.d.ts +2 -3
  28. package/dist/widgets/definition/definition.d.ts +0 -2
  29. package/dist/widgets/deprecated-standin/deprecated-standin.d.ts +0 -1
  30. package/dist/widgets/dropdown/dropdown.d.ts +2 -4
  31. package/dist/widgets/explanation/explanation.d.ts +0 -2
  32. package/dist/widgets/expression/expression.d.ts +1 -11
  33. package/dist/widgets/grapher/grapher.d.ts +2 -2
  34. package/dist/widgets/group/group.d.ts +0 -4
  35. package/dist/widgets/iframe/iframe.d.ts +2 -3
  36. package/dist/widgets/image/image.d.ts +0 -3
  37. package/dist/widgets/input-number/input-number.d.ts +0 -3
  38. package/dist/widgets/interaction/interaction.d.ts +0 -1
  39. package/dist/widgets/interactive-graph.d.ts +2 -3
  40. package/dist/widgets/interactive-graphs/backgrounds/axis-ticks.d.ts +1 -0
  41. package/dist/widgets/interactive-graphs/graphs/polygon.d.ts +3 -2
  42. package/dist/widgets/interactive-graphs/graphs/screenreader-text.d.ts +1 -1
  43. package/dist/widgets/interactive-graphs/graphs/utils.d.ts +16 -1
  44. package/dist/widgets/interactive-graphs/mafs-graph.d.ts +0 -2
  45. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +0 -2
  46. package/dist/widgets/label-image/label-image.d.ts +2 -2
  47. package/dist/widgets/matcher/matcher.d.ts +0 -2
  48. package/dist/widgets/matrix/matrix.d.ts +2 -4
  49. package/dist/widgets/measurer/measurer.d.ts +0 -1
  50. package/dist/widgets/mock-widgets/mock-widget-types.d.ts +0 -6
  51. package/dist/widgets/mock-widgets/mock-widget.d.ts +2 -5
  52. package/dist/widgets/molecule/molecule.d.ts +0 -1
  53. package/dist/widgets/number-line/number-line.d.ts +2 -3
  54. package/dist/widgets/numeric-input/numeric-input.d.ts +2 -3
  55. package/dist/widgets/orderer/orderer.d.ts +0 -3
  56. package/dist/widgets/passage/passage.d.ts +0 -1
  57. package/dist/widgets/passage-ref/passage-ref.d.ts +0 -2
  58. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +0 -2
  59. package/dist/widgets/plotter/plotter.d.ts +2 -3
  60. package/dist/widgets/radio/radio.d.ts +2 -4
  61. package/dist/widgets/sorter/sorter.d.ts +2 -4
  62. package/dist/widgets/table/table.d.ts +2 -3
  63. package/dist/widgets/video/video.d.ts +0 -3
  64. package/dist/widgets.d.ts +1 -32
  65. package/package.json +46 -46
  66. package/dist/renderer-util.d.ts +0 -14
  67. package/dist/widgets/__shared__/score-noop.d.ts +0 -11
  68. package/dist/widgets/group/score-group.d.ts +0 -4
  69. package/dist/widgets/group/validate-group.d.ts +0 -4
  70. package/dist/widgets/interactive-graphs/mafs-supported-graph-types.d.ts +0 -4
  71. package/dist/widgets/mock-widgets/score-mock-widget.d.ts +0 -5
  72. package/dist/widgets/mock-widgets/validate-mock-widget.d.ts +0 -4
package/dist/types.d.ts CHANGED
@@ -3,9 +3,9 @@ import type { PerseusStrings } from "./strings";
3
3
  import type { SizeClass } from "./util/sizing-utils";
4
4
  import type { WidgetPromptJSON } from "./widget-ai-utils/prompt-types";
5
5
  import type { KeypadAPI } from "@khanacademy/math-input";
6
- import type { Hint, PerseusAnswerArea, PerseusGraphType, PerseusWidget, PerseusWidgetsMap, AnalyticsEventHandlerFn, Version, WidgetOptionsUpgradeMap, getOrdererPublicWidgetOptions, getCategorizerPublicWidgetOptions, getExpressionPublicWidgetOptions } from "@khanacademy/perseus-core";
6
+ import type { getGrapherPublicWidgetOptions, getInteractiveGraphPublicWidgetOptions, getLabelImagePublicWidgetOptions, Hint, PerseusAnswerArea, PerseusGraphType, PerseusWidget, PerseusWidgetsMap, AnalyticsEventHandlerFn, Version, WidgetOptionsUpgradeMap, getOrdererPublicWidgetOptions, getCategorizerPublicWidgetOptions, getCSProgramPublicWidgetOptions, getExpressionPublicWidgetOptions, getSorterPublicWidgetOptions, getDropdownPublicWidgetOptions, getNumericInputPublicWidgetOptions, getNumberLinePublicWidgetOptions, getRadioPublicWidgetOptions, getTablePublicWidgetOptions, getIFramePublicWidgetOptions, getMatrixPublicWidgetOptions, getPlotterPublicWidgetOptions } from "@khanacademy/perseus-core";
7
7
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
8
- import type { PerseusScore, Rubric, UserInput, UserInputArray, UserInputMap, ValidationData, ValidationResult } from "@khanacademy/perseus-score";
8
+ import type { Rubric, UserInput, UserInputArray, UserInputMap } from "@khanacademy/perseus-score";
9
9
  import type { Result } from "@khanacademy/wonder-blocks-data";
10
10
  import type * as React from "react";
11
11
  export type FocusPath = ReadonlyArray<string> | null | undefined;
@@ -100,7 +100,6 @@ type TrackInteractionArgs = {
100
100
  id: string;
101
101
  correct?: boolean;
102
102
  } & Partial<TrackingGradedGroupExtraArguments> & Partial<TrackingSequenceExtraArguments>;
103
- export declare const MafsGraphTypeFlags: readonly ["angle", "segment", "linear", "linear-system", "ray", "polygon", "unlimited-polygon", "circle", "quadratic", "sinusoid", "point", "unlimited-point", "none"];
104
103
  /**
105
104
  * APIOptions provides different ways to customize the behaviour of Perseus.
106
105
  *
@@ -220,17 +219,6 @@ export type APIOptions = Readonly<{
220
219
  * only after a good few seconds.
221
220
  */
222
221
  editorChangeDelay?: number;
223
- /** Feature flags that can be passed from consuming application. */
224
- flags?: {
225
- /**
226
- * Flags related to the interactive-graph Mafs migration.
227
- *
228
- * Add values to the relevant array to create new flags.
229
- */
230
- mafs?: false | {
231
- [Key in (typeof MafsGraphTypeFlags)[number]]?: boolean;
232
- };
233
- };
234
222
  /**
235
223
  * This is a callback function that returns all of the Widget props
236
224
  * after they have been transformed by the widget's transform function.
@@ -347,7 +335,6 @@ export type TrackingGradedGroupExtraArguments = {
347
335
  type TrackingSequenceExtraArguments = {
348
336
  visible: number;
349
337
  };
350
- export type Alignment = "default" | "block" | "inline-block" | "inline" | "float-left" | "float-right" | "full-width";
351
338
  type WidgetOptions = any;
352
339
  /**
353
340
  * A transform that maps the WidgetOptions (sometimes referred to as
@@ -355,12 +342,10 @@ type WidgetOptions = any;
355
342
  * identity transform.
356
343
  */
357
344
  export type WidgetTransform = (arg1: WidgetOptions, strings: PerseusStrings, problemNumber?: number) => any;
358
- export type WidgetValidatorFunction = (userInput: UserInput, validationData: ValidationData, strings: PerseusStrings, locale: string) => ValidationResult;
359
- export type WidgetScorerFunction = (userInput: UserInput, rubric: Rubric, string?: PerseusStrings, locale?: string) => PerseusScore;
360
345
  /**
361
346
  * A union type of all the functions that provide public widget options.
362
347
  */
363
- export type PublicWidgetOptionsFunction = typeof getCategorizerPublicWidgetOptions | typeof getOrdererPublicWidgetOptions | typeof getExpressionPublicWidgetOptions;
348
+ export type PublicWidgetOptionsFunction = typeof getPlotterPublicWidgetOptions | typeof getIFramePublicWidgetOptions | typeof getRadioPublicWidgetOptions | typeof getNumericInputPublicWidgetOptions | typeof getDropdownPublicWidgetOptions | typeof getCategorizerPublicWidgetOptions | typeof getOrdererPublicWidgetOptions | typeof getExpressionPublicWidgetOptions | typeof getInteractiveGraphPublicWidgetOptions | typeof getLabelImagePublicWidgetOptions | typeof getSorterPublicWidgetOptions | typeof getCSProgramPublicWidgetOptions | typeof getNumberLinePublicWidgetOptions | typeof getTablePublicWidgetOptions | typeof getGrapherPublicWidgetOptions | typeof getMatrixPublicWidgetOptions;
364
349
  export type WidgetExports<T extends React.ComponentType<any> & Widget = React.ComponentType<any>> = Readonly<{
365
350
  name: string;
366
351
  displayName: string;
@@ -378,9 +363,6 @@ export type WidgetExports<T extends React.ComponentType<any> & Widget = React.Co
378
363
  * This key defaults to `{major: 0, minor: 0}` if not provided.
379
364
  */
380
365
  version?: Version;
381
- supportedAlignments?: ReadonlyArray<Alignment>;
382
- defaultAlignment?: Alignment;
383
- getDefaultAlignment?: () => Alignment;
384
366
  isLintable?: boolean;
385
367
  tracking?: Tracking;
386
368
  traverseChildWidgets?: any;
@@ -393,17 +375,6 @@ export type WidgetExports<T extends React.ComponentType<any> & Widget = React.Co
393
375
  * static renders.
394
376
  */
395
377
  staticTransform?: WidgetTransform;
396
- /**
397
- * Validates the learner's guess to check if it's sufficient for scoring.
398
- * Typically, this is basically an "emptiness" check, but for some widgets
399
- * such as `interactive-graph` it is a check that the learner has made any
400
- * edits (ie. the widget is not in it's origin state).
401
- */
402
- validator?: WidgetValidatorFunction;
403
- /**
404
- * A function that scores user input (the guess) for the widget.
405
- */
406
- scorer?: WidgetScorerFunction;
407
378
  /**
408
379
  * A function that provides a public version of the widget options that can
409
380
  * be shared with the client.
@@ -0,0 +1 @@
1
+ export declare function isPiMultiple(value: number): boolean;
@@ -1,19 +1,4 @@
1
1
  import type { KEScore } from "@khanacademy/perseus-core";
2
2
  import type { PerseusScore, UserInputArray } from "@khanacademy/perseus-score";
3
- /**
4
- * If a widget says that it is empty once it is graded.
5
- * Trying to encapsulate references to the score format.
6
- */
7
- export declare function scoreIsEmpty(score: PerseusScore): boolean;
8
- /**
9
- * Combine two score objects.
10
- *
11
- * Given two score objects for two different widgets, combine them so that
12
- * if one is wrong, the total score is wrong, etc.
13
- */
14
- export declare function combineScores(scoreA: PerseusScore, scoreB: PerseusScore): PerseusScore;
15
- export declare function flattenScores(widgetScoreMap: {
16
- [widgetId: string]: PerseusScore;
17
- }): PerseusScore;
18
3
  export declare function isCorrect(score: PerseusScore): boolean;
19
4
  export declare function keScoreFromPerseusScore(score: PerseusScore, guess: UserInputArray | [UserInputArray, []], state: any): KEScore;
@@ -1,5 +1,5 @@
1
+ import { type PerseusScore, type UserInputMap } from "@khanacademy/perseus-score";
1
2
  import type { CategorizerWidget, ExpressionWidget, InteractiveGraphWidget, NumericInputWidget, PerseusItem, PerseusRenderer, RadioWidget } from "@khanacademy/perseus-core";
2
- import type { PerseusScore, UserInputMap } from "@khanacademy/perseus-score";
3
3
  export declare const genericPerseusItemData: PerseusItem;
4
4
  /**
5
5
  * Thin wrapper around scorePerseusItem for internal testing
@@ -1,5 +1,5 @@
1
1
  import type mockWidget from "../../widgets/mock-widgets/mock-widget";
2
- import type { PerseusMockWidgetUserInput } from "../../widgets/mock-widgets/mock-widget-types";
2
+ import type { PerseusMockWidgetUserInput } from "@khanacademy/perseus-score";
3
3
  import type React from "react";
4
4
  export type MockWidgetPromptJSON = {
5
5
  type: "mock-widget";
@@ -1,6 +1,6 @@
1
+ import { type PerseusWidgetOptions } from "@khanacademy/perseus-core";
1
2
  import * as React from "react";
2
3
  import type { WidgetProps } from "./types";
3
- import type { PerseusWidgetOptions } from "@khanacademy/perseus-core";
4
4
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
5
5
  type Props = {
6
6
  shouldHighlight: boolean;
@@ -1,5 +1,4 @@
1
1
  import { type PerseusCategorizerWidgetOptions, getCategorizerPublicWidgetOptions } from "@khanacademy/perseus-core";
2
- import { scoreCategorizer, validateCategorizer } from "@khanacademy/perseus-score";
3
2
  import * as React from "react";
4
3
  import { PerseusI18nContext } from "../../components/i18n-context";
5
4
  import type { Widget, WidgetProps } from "../../types";
@@ -43,8 +42,6 @@ declare const _default: {
43
42
  transform: (widgetOptions: PerseusCategorizerWidgetOptions) => RenderProps;
44
43
  staticTransform: (editorProps: PerseusCategorizerWidgetOptions) => RenderProps;
45
44
  isLintable: true;
46
- scorer: typeof scoreCategorizer;
47
- validator: typeof validateCategorizer;
48
45
  getPublicWidgetOptions: typeof getCategorizerPublicWidgetOptions;
49
46
  };
50
47
  export default _default;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This widget is for embedding Khan Academy CS programs.
3
3
  */
4
- import { scoreCSProgram } from "@khanacademy/perseus-score";
4
+ import { getCSProgramPublicWidgetOptions } from "@khanacademy/perseus-core";
5
5
  import * as React from "react";
6
6
  import type { Widget, WidgetProps } from "../../types";
7
7
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
@@ -28,9 +28,8 @@ declare class CSProgram extends React.Component<Props> implements Widget {
28
28
  declare const _default: {
29
29
  name: string;
30
30
  displayName: string;
31
- supportedAlignments: ("block" | "full-width")[];
32
31
  widget: typeof CSProgram;
33
32
  hidden: true;
34
- scorer: typeof scoreCSProgram;
33
+ getPublicWidgetOptions: typeof getCSProgramPublicWidgetOptions;
35
34
  };
36
35
  export default _default;
@@ -23,9 +23,7 @@ declare const _default: {
23
23
  name: string;
24
24
  displayName: string;
25
25
  accessible: true;
26
- defaultAlignment: "inline";
27
26
  widget: typeof Definition;
28
27
  transform: (x: any) => any;
29
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
30
28
  };
31
29
  export default _default;
@@ -13,6 +13,5 @@ declare const _default: {
13
13
  displayName: string;
14
14
  widget: typeof DeprecatedStandin;
15
15
  hidden: true;
16
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
17
16
  };
18
17
  export default _default;
@@ -1,4 +1,4 @@
1
- import { scoreDropdown, validateDropdown } from "@khanacademy/perseus-score";
1
+ import { getDropdownPublicWidgetOptions } from "@khanacademy/perseus-core";
2
2
  import * as React from "react";
3
3
  import { PerseusI18nContext } from "../../components/i18n-context";
4
4
  import type { Widget, WidgetProps } from "../../types";
@@ -34,11 +34,9 @@ type RenderProps = {
34
34
  declare const _default: {
35
35
  name: string;
36
36
  displayName: string;
37
- defaultAlignment: "inline-block";
38
37
  accessible: true;
39
38
  widget: typeof Dropdown;
40
39
  transform: (arg1: PerseusDropdownWidgetOptions) => RenderProps;
41
- scorer: typeof scoreDropdown;
42
- validator: typeof validateDropdown;
40
+ getPublicWidgetOptions: typeof getDropdownPublicWidgetOptions;
43
41
  };
44
42
  export default _default;
@@ -33,10 +33,8 @@ declare const _default: {
33
33
  name: string;
34
34
  displayName: string;
35
35
  accessible: true;
36
- defaultAlignment: "inline";
37
36
  widget: typeof Explanation;
38
37
  transform: <T>(value: T) => T;
39
38
  isLintable: true;
40
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
41
39
  };
42
40
  export default _default;
@@ -1,5 +1,4 @@
1
1
  import { type PerseusExpressionWidgetOptions, getExpressionPublicWidgetOptions } from "@khanacademy/perseus-core";
2
- import { scoreExpression, validateExpression } from "@khanacademy/perseus-score";
3
2
  import * as React from "react";
4
3
  import { PerseusI18nContext } from "../../components/i18n-context";
5
4
  import type { DependenciesContext } from "../../dependencies";
@@ -89,7 +88,6 @@ declare const _default: {
89
88
  name: string;
90
89
  displayName: string;
91
90
  accessible: true;
92
- defaultAlignment: "inline-block";
93
91
  widget: React.ForwardRefExoticComponent<Omit<Pick<RenderProps & {
94
92
  widgetId: string;
95
93
  alignment: string | null | undefined;
@@ -128,9 +126,6 @@ declare const _default: {
128
126
  canScrollPage?: boolean;
129
127
  crossOutEnabled?: boolean;
130
128
  editorChangeDelay?: number;
131
- flags?: {
132
- mafs?: false | { [Key in typeof import("../../types").MafsGraphTypeFlags[number]]?: boolean; };
133
- };
134
129
  onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
135
130
  }> & {
136
131
  GroupMetadataEditor: NonNullable<import("../..").APIOptions["GroupMetadataEditor"]>;
@@ -169,7 +164,7 @@ declare const _default: {
169
164
  visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
170
165
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
171
166
  value: string;
172
- }, "static" | "containerSizeClass" | "widgetId" | "onChange" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "ariaLabel" | "alignment" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "reviewModeRubric" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
167
+ }, "static" | "containerSizeClass" | "widgetId" | "onChange" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "ariaLabel" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "alignment" | "reviewModeRubric" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
173
168
  value?: string | undefined;
174
169
  apiOptions?: Readonly<Readonly<{
175
170
  isArticle?: boolean;
@@ -204,9 +199,6 @@ declare const _default: {
204
199
  canScrollPage?: boolean;
205
200
  crossOutEnabled?: boolean;
206
201
  editorChangeDelay?: number;
207
- flags?: {
208
- mafs?: false | { [Key in typeof import("../../types").MafsGraphTypeFlags[number]]?: boolean; };
209
- };
210
202
  onWidgetStartProps?: (widgets: import("@khanacademy/perseus-core").PerseusWidgetsMap) => void;
211
203
  }> & {
212
204
  GroupMetadataEditor: NonNullable<import("../..").APIOptions["GroupMetadataEditor"]>;
@@ -233,8 +225,6 @@ declare const _default: {
233
225
  version: import("@khanacademy/perseus-core").Version | undefined;
234
226
  propUpgrades: import("@khanacademy/perseus-core").WidgetOptionsUpgradeMap | undefined;
235
227
  isLintable: true;
236
- scorer: typeof scoreExpression;
237
- validator: typeof validateExpression;
238
228
  getPublicWidgetOptions: typeof getExpressionPublicWidgetOptions;
239
229
  getOneCorrectAnswerFromRubric(rubric: PerseusExpressionRubric): string | null | undefined;
240
230
  };
@@ -1,4 +1,4 @@
1
- import { scoreGrapher } from "@khanacademy/perseus-score";
1
+ import { getGrapherPublicWidgetOptions } from "@khanacademy/perseus-core";
2
2
  import * as React from "react";
3
3
  import Graphie from "../../components/graphie";
4
4
  import type { Coord } from "../../interactive2/types";
@@ -47,6 +47,6 @@ declare const _default: {
47
47
  widget: typeof Grapher;
48
48
  transform: (arg1: PerseusGrapherWidgetOptions) => RenderProps;
49
49
  staticTransform: (arg1: PerseusGrapherWidgetOptions) => RenderProps;
50
- scorer: typeof scoreGrapher;
50
+ getPublicWidgetOptions: typeof getGrapherPublicWidgetOptions;
51
51
  };
52
52
  export default _default;
@@ -1,8 +1,6 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import Renderer from "../../renderer";
4
- import scoreGroup from "./score-group";
5
- import validateGroup from "./validate-group";
6
4
  import type { ChangeFn, FocusPath, Widget, WidgetProps } from "../../types";
7
5
  import type { GroupPromptJSON } from "../../widget-ai-utils/group/group-ai-utils";
8
6
  import type { PerseusGroupWidgetOptions } from "@khanacademy/perseus-core";
@@ -43,8 +41,6 @@ declare const _default: {
43
41
  displayName: string;
44
42
  widget: typeof Group;
45
43
  traverseChildWidgets: (props: any, traverseRenderer: any) => any;
46
- scorer: typeof scoreGroup;
47
- validator: typeof validateGroup;
48
44
  hidden: true;
49
45
  isLintable: true;
50
46
  };
@@ -6,11 +6,10 @@
6
6
  * It's particularly well suited for embedding our ProcessingJS programs,
7
7
  * but could also be used for embedding viz's hosted elsewhere.
8
8
  */
9
- import { scoreIframe } from "@khanacademy/perseus-score";
9
+ import { type PerseusIFrameWidgetOptions, getIFramePublicWidgetOptions } from "@khanacademy/perseus-core";
10
10
  import * as React from "react";
11
11
  import type { WidgetProps, Widget } from "../../types";
12
12
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
13
- import type { PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
14
13
  import type { PerseusIFrameUserInput, UserInputStatus } from "@khanacademy/perseus-score";
15
14
  type RenderProps = PerseusIFrameWidgetOptions & {
16
15
  status: UserInputStatus;
@@ -40,6 +39,6 @@ declare const _default: {
40
39
  displayName: string;
41
40
  widget: typeof Iframe;
42
41
  hidden: true;
43
- scorer: typeof scoreIframe;
42
+ getPublicWidgetOptions: typeof getIFramePublicWidgetOptions;
44
43
  };
45
44
  export default _default;
@@ -39,11 +39,8 @@ declare class ImageWidget extends React.Component<Props> implements Widget {
39
39
  declare const _default: {
40
40
  name: string;
41
41
  accessible: (widgetOptions: PerseusImageWidgetOptions) => boolean;
42
- defaultAlignment: "block";
43
- supportedAlignments: readonly ["block", "full-width"];
44
42
  displayName: string;
45
43
  widget: typeof ImageWidget;
46
44
  isLintable: true;
47
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
48
45
  };
49
46
  export default _default;
@@ -1,4 +1,3 @@
1
- import { scoreInputNumber } from "@khanacademy/perseus-score";
2
1
  import * as React from "react";
3
2
  import { PerseusI18nContext } from "../../components/i18n-context";
4
3
  import type { Path, Widget, WidgetProps } from "../../types";
@@ -52,12 +51,10 @@ declare class InputNumber extends React.Component<Props> implements Widget {
52
51
  declare const _default: {
53
52
  name: string;
54
53
  displayName: string;
55
- defaultAlignment: "inline-block";
56
54
  hidden: true;
57
55
  widget: typeof InputNumber;
58
56
  transform: (widgetOptions: PerseusInputNumberWidgetOptions) => RenderProps;
59
57
  isLintable: true;
60
- scorer: typeof scoreInputNumber;
61
58
  getOneCorrectAnswerFromRubric(rubric: any): string | null | undefined;
62
59
  };
63
60
  export default _default;
@@ -33,6 +33,5 @@ declare const _default: {
33
33
  widget: typeof Interaction;
34
34
  transform: <T>(value: T) => T;
35
35
  hidden: true;
36
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
37
36
  };
38
37
  export default _default;
@@ -1,4 +1,4 @@
1
- import { scoreInteractiveGraph } from "@khanacademy/perseus-score";
1
+ import { getInteractiveGraphPublicWidgetOptions } from "@khanacademy/perseus-core";
2
2
  import * as React from "react";
3
3
  import { PerseusI18nContext } from "../components/i18n-context";
4
4
  import type { StatefulMafsGraphType } from "./interactive-graphs/stateful-mafs-graph";
@@ -255,12 +255,11 @@ declare class InteractiveGraph extends React.Component<Props, State> {
255
255
  static getAngleEquationString(props: Props): string;
256
256
  static getUserInputFromProps(props: Props): PerseusGraphType;
257
257
  }
258
- export declare function shouldUseMafs(mafsFlags: Record<string, boolean> | undefined | boolean, graph: PerseusGraphType): boolean;
259
258
  declare const _default: {
260
259
  name: string;
261
260
  displayName: string;
262
261
  widget: typeof InteractiveGraph;
263
262
  staticTransform: <T>(value: T) => T;
264
- scorer: typeof scoreInteractiveGraph;
263
+ getPublicWidgetOptions: typeof getInteractiveGraphPublicWidgetOptions;
265
264
  };
266
265
  export default _default;
@@ -3,4 +3,5 @@ import type { Interval } from "mafs";
3
3
  export declare const shouldShowLabel: (currentTick: number, range: [Interval, Interval], tickStep: number) => boolean;
4
4
  export declare function generateTickLocations(tickStep: number, min: number, max: number): number[];
5
5
  export declare const countSignificantDecimals: (number: number) => number;
6
+ export declare function divideByAndShowPi(value: number): string;
6
7
  export declare const AxisTicks: () => React.JSX.Element;
@@ -1,3 +1,4 @@
1
- import type { Dispatch, InteractiveGraphElementSuite, PolygonGraphState } from "../types";
2
- export declare function renderPolygonGraph(state: PolygonGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
1
+ import { type I18nContextType } from "../../../components/i18n-context";
2
+ import type { Dispatch, InteractiveGraphElementSuite, InteractiveGraphProps, PolygonGraphState } from "../types";
3
+ export declare function renderPolygonGraph(state: PolygonGraphState, dispatch: Dispatch, i18n: I18nContextType, markings: InteractiveGraphProps["markings"]): InteractiveGraphElementSuite;
3
4
  export declare const hasFocusVisible: (element: Element | null | undefined) => boolean;
@@ -1 +1 @@
1
- export declare function srFormatNumber(a: number, locale: string): string;
1
+ export declare function srFormatNumber(a: number, locale: string, maximumFractionDigits?: number): string;
@@ -1,7 +1,8 @@
1
+ import { vec } from "mafs";
1
2
  import type { PerseusStrings } from "../../../strings";
2
3
  import type { PairOfPoints } from "../types";
3
4
  import type { Coord } from "@khanacademy/perseus";
4
- import type { Interval, vec } from "mafs";
5
+ import type { Interval } from "mafs";
5
6
  /**
6
7
  * Given a ray and a rectangular box, find the point where the ray intersects
7
8
  * the edge of the box. Assumes the `initialPoint` is inside the box.
@@ -18,4 +19,18 @@ export declare function getCoordQuadrant(coord: Coord): GraphLocations;
18
19
  export declare function getQuadraticVertexString(vertex: Coord, strings: PerseusStrings): string;
19
20
  export declare function getQuadraticPointString(pointNumber: any, coord: Coord, strings: PerseusStrings, locale: string): string;
20
21
  export declare function getQuadraticXIntercepts(a: number, b: number, c: number): number[];
22
+ /**
23
+ * Given a list of points, return the angle made by the point at index i
24
+ * with the points at indices i - 1 and i + 1.
25
+ */
26
+ export declare function getAngleFromPoints(points: Coord[], i: number): number | null;
27
+ export declare function getSideLengthsFromPoints(points: Coord[], i: number, isPolygonOpen?: boolean): Array<{
28
+ pointIndex: number;
29
+ sideLength: number;
30
+ }>;
31
+ /**
32
+ * Determine whether to determine the string with the
33
+ * exact side length or the approximate side length.
34
+ */
35
+ export declare function getPolygonSideString(sideLength: number, pointIndex: number, strings: PerseusStrings, locale: string): string;
21
36
  export {};
@@ -1,12 +1,10 @@
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 { APIOptions } from "../../types";
5
4
  import type { vec } from "mafs";
6
5
  import "mafs/core.css";
7
6
  import "./mafs-styles.css";
8
7
  export type MafsGraphProps = {
9
- flags?: APIOptions["flags"];
10
8
  box: [number, number];
11
9
  backgroundImage?: InteractiveGraphProps["backgroundImage"];
12
10
  lockedFigures?: InteractiveGraphProps["lockedFigures"];
@@ -1,10 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { InteractiveGraphProps } from "./types";
3
- import type { APIOptions } from "../../types";
4
3
  import type { PerseusGraphType } from "@khanacademy/perseus-core";
5
4
  import type { PerseusInteractiveGraphUserInput } from "@khanacademy/perseus-score";
6
5
  export type StatefulMafsGraphProps = {
7
- flags?: APIOptions["flags"];
8
6
  box: [number, number];
9
7
  backgroundImage?: InteractiveGraphProps["backgroundImage"];
10
8
  graph: PerseusGraphType;
@@ -5,7 +5,7 @@
5
5
  * that involve the use of images, and enable learners to demonstrate their
6
6
  * knowledge by directly interacting with the image.
7
7
  */
8
- import { scoreLabelImage } from "@khanacademy/perseus-score";
8
+ import { getLabelImagePublicWidgetOptions } from "@khanacademy/perseus-core";
9
9
  import * as React from "react";
10
10
  import { PerseusI18nContext } from "../../components/i18n-context";
11
11
  import Marker from "./marker";
@@ -92,6 +92,6 @@ declare const _default: {
92
92
  }, keyof import("../..").PerseusDependenciesV2> & React.RefAttributes<LabelImage>>;
93
93
  accessible: true;
94
94
  isLintable: true;
95
- scorer: typeof scoreLabelImage;
95
+ getPublicWidgetOptions: typeof getLabelImagePublicWidgetOptions;
96
96
  };
97
97
  export default _default;
@@ -1,4 +1,3 @@
1
- import { scoreMatcher } from "@khanacademy/perseus-score";
2
1
  import * as React from "react";
3
2
  import { PerseusI18nContext } from "../../components/i18n-context";
4
3
  import type { SortableOption } from "../../components/sortable";
@@ -42,6 +41,5 @@ declare const _default: {
42
41
  displayName: string;
43
42
  widget: typeof Matcher;
44
43
  isLintable: true;
45
- scorer: typeof scoreMatcher;
46
44
  };
47
45
  export default _default;
@@ -1,5 +1,4 @@
1
- import { type PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
2
- import { scoreMatrix, validateMatrix } from "@khanacademy/perseus-score";
1
+ import { getMatrixPublicWidgetOptions, type PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
3
2
  import * as React from "react";
4
3
  import { PerseusI18nContext } from "../../components/i18n-context";
5
4
  import type { FocusPath, Widget, WidgetProps } from "../../types";
@@ -61,7 +60,6 @@ declare const _default: {
61
60
  transform: (arg1: any) => any;
62
61
  staticTransform: (arg1: any) => any;
63
62
  isLintable: true;
64
- scorer: typeof scoreMatrix;
65
- validator: typeof validateMatrix;
63
+ getPublicWidgetOptions: typeof getMatrixPublicWidgetOptions;
66
64
  };
67
65
  export default _default;
@@ -37,6 +37,5 @@ declare const _default: {
37
37
  widget: typeof Measurer;
38
38
  version: import("@khanacademy/perseus-core").Version | undefined;
39
39
  propUpgrades: import("@khanacademy/perseus-core").WidgetOptionsUpgradeMap | undefined;
40
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
41
40
  };
42
41
  export default _default;
@@ -4,12 +4,6 @@ export type MockWidgetOptions = {
4
4
  static?: boolean;
5
5
  value: string;
6
6
  };
7
- export type PerseusMockWidgetRubric = {
8
- value: string;
9
- };
10
- export type PerseusMockWidgetUserInput = {
11
- currentValue: string;
12
- };
13
7
  declare module "@khanacademy/perseus-core" {
14
8
  interface PerseusWidgetTypes {
15
9
  "mock-widget": MockWidget;
@@ -1,9 +1,8 @@
1
1
  import * as React from "react";
2
- import scoreMockWidget from "./score-mock-widget";
3
- import validateMockWidget from "./validate-mock-widget";
4
- import type { MockWidgetOptions, PerseusMockWidgetRubric, PerseusMockWidgetUserInput } from "./mock-widget-types";
2
+ import type { MockWidgetOptions } from "./mock-widget-types";
5
3
  import type { WidgetProps, Widget, FocusPath } from "../../types";
6
4
  import type { MockWidgetPromptJSON } from "../../widget-ai-utils/mock-widget/prompt-utils";
5
+ import type { PerseusMockWidgetRubric, PerseusMockWidgetUserInput } from "@khanacademy/perseus-score";
7
6
  type ExternalProps = WidgetProps<MockWidgetOptions, PerseusMockWidgetRubric>;
8
7
  type DefaultProps = {
9
8
  currentValue: Props["currentValue"];
@@ -42,7 +41,5 @@ declare const _default: {
42
41
  displayName: string;
43
42
  widget: typeof MockWidgetComponent;
44
43
  isLintable: true;
45
- scorer: typeof scoreMockWidget;
46
- validator: typeof validateMockWidget;
47
44
  };
48
45
  export default _default;
@@ -19,6 +19,5 @@ declare const _default: {
19
19
  displayName: string;
20
20
  hidden: true;
21
21
  widget: typeof MoleculeWidget;
22
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
23
22
  };
24
23
  export default _default;
@@ -1,4 +1,4 @@
1
- import { scoreNumberLine, validateNumberLine } from "@khanacademy/perseus-score";
1
+ import { getNumberLinePublicWidgetOptions } from "@khanacademy/perseus-core";
2
2
  import * as React from "react";
3
3
  import { PerseusI18nContext } from "../../components/i18n-context";
4
4
  import type { ChangeableProps } from "../../mixins/changeable";
@@ -79,7 +79,6 @@ declare const _default: {
79
79
  widget: typeof NumberLine;
80
80
  transform: (arg1: any) => any;
81
81
  staticTransform: (arg1: any) => any;
82
- scorer: typeof scoreNumberLine;
83
- validator: typeof validateNumberLine;
82
+ getPublicWidgetOptions: typeof getNumberLinePublicWidgetOptions;
84
83
  };
85
84
  export default _default;
@@ -1,4 +1,4 @@
1
- import { scoreNumericInput } from "@khanacademy/perseus-score";
1
+ import { getNumericInputPublicWidgetOptions } from "@khanacademy/perseus-core";
2
2
  import * as React from "react";
3
3
  import { PerseusI18nContext } from "../../components/i18n-context";
4
4
  import InputWithExamples from "../../components/input-with-examples";
@@ -72,12 +72,11 @@ type RenderProps = {
72
72
  declare const _default: {
73
73
  name: string;
74
74
  displayName: string;
75
- defaultAlignment: "inline-block";
76
75
  accessible: true;
77
76
  widget: typeof NumericInput;
78
77
  transform: (widgetOptions: PerseusNumericInputWidgetOptions) => RenderProps;
79
78
  isLintable: true;
80
- scorer: typeof scoreNumericInput;
79
+ getPublicWidgetOptions: typeof getNumericInputPublicWidgetOptions;
81
80
  getOneCorrectAnswerFromRubric(rubric: PerseusNumericInputRubric): string | null | undefined;
82
81
  };
83
82
  export default _default;
@@ -1,5 +1,4 @@
1
1
  import { getOrdererPublicWidgetOptions } from "@khanacademy/perseus-core";
2
- import { scoreOrderer, validateOrderer } from "@khanacademy/perseus-score";
3
2
  import * as React from "react";
4
3
  import type { Widget, WidgetProps } from "../../types";
5
4
  import type { OrdererPromptJSON } from "../../widget-ai-utils/orderer/orderer-ai-utils";
@@ -56,8 +55,6 @@ declare const _default: {
56
55
  hidden: true;
57
56
  widget: typeof Orderer;
58
57
  isLintable: true;
59
- scorer: typeof scoreOrderer;
60
- validator: typeof validateOrderer;
61
58
  getPublicWidgetOptions: typeof getOrdererPublicWidgetOptions;
62
59
  };
63
60
  export default _default;
@@ -105,6 +105,5 @@ declare const _default: {
105
105
  widget: typeof Passage;
106
106
  transform: (editorProps: any) => RenderProps;
107
107
  isLintable: true;
108
- scorer: () => import("@khanacademy/perseus-score").PerseusScore;
109
108
  };
110
109
  export default _default;