@khanacademy/perseus 50.0.0 → 51.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.
Files changed (117) hide show
  1. package/dist/es/index.js +597 -2403
  2. package/dist/es/index.js.map +1 -1
  3. package/dist/es/strings.js +58 -11
  4. package/dist/es/strings.js.map +1 -1
  5. package/dist/index.d.ts +3 -8
  6. package/dist/index.js +537 -2320
  7. package/dist/index.js.map +1 -1
  8. package/dist/renderer-util.d.ts +1 -2
  9. package/dist/renderer.d.ts +2 -2
  10. package/dist/server-item-renderer.d.ts +1 -1
  11. package/dist/strings.d.ts +204 -13
  12. package/dist/strings.js +75 -10
  13. package/dist/strings.js.map +1 -1
  14. package/dist/types.d.ts +11 -14
  15. package/dist/util/scoring.d.ts +1 -2
  16. package/dist/util/test-utils.d.ts +1 -2
  17. package/dist/util.d.ts +0 -14
  18. package/dist/widget-ai-utils/categorizer/categorizer-ai-utils.d.ts +1 -1
  19. package/dist/widget-ai-utils/dropdown/dropdown-ai-utils.d.ts +1 -1
  20. package/dist/widget-ai-utils/expression/expression-ai-utils.d.ts +1 -1
  21. package/dist/widget-ai-utils/grapher/grapher-ai-utils.d.ts +1 -1
  22. package/dist/widget-ai-utils/input-number/input-number-ai-utils.d.ts +1 -1
  23. package/dist/widget-ai-utils/label-image/label-image-ai-utils.d.ts +1 -1
  24. package/dist/widget-ai-utils/matcher/matcher-ai-utils.d.ts +1 -1
  25. package/dist/widget-ai-utils/matrix/matrix-ai-utils.d.ts +1 -1
  26. package/dist/widget-ai-utils/mock-widget/prompt-utils.d.ts +1 -1
  27. package/dist/widget-ai-utils/number-line/number-line-ai-utils.d.ts +1 -1
  28. package/dist/widget-ai-utils/numeric-input/prompt-utils.d.ts +1 -1
  29. package/dist/widget-ai-utils/orderer/orderer-ai-utils.d.ts +1 -1
  30. package/dist/widget-ai-utils/radio/radio-ai-utils.d.ts +1 -1
  31. package/dist/widget-ai-utils/sorter/sorter-ai-utils.d.ts +1 -1
  32. package/dist/widgets/__shared__/score-noop.d.ts +1 -1
  33. package/dist/widgets/categorizer/categorizer.d.ts +4 -2
  34. package/dist/widgets/categorizer/categorizer.util.d.ts +17 -0
  35. package/dist/widgets/cs-program/cs-program.d.ts +1 -2
  36. package/dist/widgets/definition/definition.d.ts +1 -1
  37. package/dist/widgets/deprecated-standin/deprecated-standin.d.ts +1 -1
  38. package/dist/widgets/dropdown/dropdown.d.ts +2 -2
  39. package/dist/widgets/explanation/explanation.d.ts +1 -1
  40. package/dist/widgets/expression/expression.d.ts +5 -6
  41. package/dist/widgets/graded-group/graded-group.d.ts +1 -1
  42. package/dist/widgets/graded-group-set/graded-group-set.d.ts +1 -1
  43. package/dist/widgets/grapher/grapher.d.ts +1 -2
  44. package/dist/widgets/grapher/util.d.ts +5 -13
  45. package/dist/widgets/group/group.d.ts +2 -2
  46. package/dist/widgets/group/score-group.d.ts +1 -2
  47. package/dist/widgets/iframe/iframe.d.ts +1 -2
  48. package/dist/widgets/image/image.d.ts +1 -1
  49. package/dist/widgets/input-number/input-number.d.ts +1 -2
  50. package/dist/widgets/interaction/interaction.d.ts +1 -1
  51. package/dist/widgets/interactive-graph.d.ts +2 -3
  52. package/dist/widgets/interactive-graphs/graphs/linear-system.d.ts +2 -0
  53. package/dist/widgets/interactive-graphs/graphs/quadratic.d.ts +1 -3
  54. package/dist/widgets/interactive-graphs/graphs/ray.d.ts +2 -0
  55. package/dist/widgets/interactive-graphs/graphs/sinusoid.d.ts +4 -9
  56. package/dist/widgets/interactive-graphs/graphs/utils.d.ts +4 -0
  57. package/dist/widgets/interactive-graphs/math/index.d.ts +0 -1
  58. package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +1 -1
  59. package/dist/widgets/interactive-graphs/types.d.ts +2 -1
  60. package/dist/widgets/label-image/label-image.d.ts +2 -4
  61. package/dist/widgets/label-image/marker.d.ts +1 -2
  62. package/dist/widgets/matcher/matcher.d.ts +1 -2
  63. package/dist/widgets/matrix/matrix.d.ts +2 -4
  64. package/dist/widgets/measurer/measurer.d.ts +1 -1
  65. package/dist/widgets/mock-widgets/mock-widget.d.ts +1 -1
  66. package/dist/widgets/mock-widgets/score-mock-widget.d.ts +1 -2
  67. package/dist/widgets/molecule/molecule.d.ts +1 -1
  68. package/dist/widgets/number-line/number-line.d.ts +2 -3
  69. package/dist/widgets/numeric-input/numeric-input.d.ts +1 -2
  70. package/dist/widgets/orderer/orderer.d.ts +1 -2
  71. package/dist/widgets/passage/passage.d.ts +1 -1
  72. package/dist/widgets/passage-ref/passage-ref.d.ts +1 -1
  73. package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +1 -1
  74. package/dist/widgets/plotter/plotter.d.ts +1 -2
  75. package/dist/widgets/radio/radio-component.d.ts +1 -1
  76. package/dist/widgets/radio/radio.d.ts +1 -1
  77. package/dist/widgets/sorter/sorter.d.ts +1 -2
  78. package/dist/widgets/table/table.d.ts +1 -2
  79. package/dist/widgets/video/video.d.ts +1 -1
  80. package/dist/widgets.d.ts +2 -1
  81. package/package.json +11 -11
  82. package/dist/tex-wrangler.d.ts +0 -7
  83. package/dist/util/geometry.d.ts +0 -28
  84. package/dist/validation.types.d.ts +0 -166
  85. package/dist/widgets/categorizer/score-categorizer.d.ts +0 -5
  86. package/dist/widgets/categorizer/validate-categorizer.d.ts +0 -13
  87. package/dist/widgets/cs-program/score-cs-program.d.ts +0 -4
  88. package/dist/widgets/dropdown/score-dropdown.d.ts +0 -4
  89. package/dist/widgets/dropdown/validate-dropdown.d.ts +0 -8
  90. package/dist/widgets/expression/get-decimal-separator.d.ts +0 -5
  91. package/dist/widgets/expression/score-expression.d.ts +0 -5
  92. package/dist/widgets/expression/validate-expression.d.ts +0 -12
  93. package/dist/widgets/grapher/grapher-types.d.ts +0 -58
  94. package/dist/widgets/grapher/score-grapher.d.ts +0 -4
  95. package/dist/widgets/iframe/score-iframe.d.ts +0 -3
  96. package/dist/widgets/input-number/score-input-number.d.ts +0 -39
  97. package/dist/widgets/interactive-graphs/math/angles.d.ts +0 -7
  98. package/dist/widgets/interactive-graphs/score-interactive-graph.d.ts +0 -4
  99. package/dist/widgets/label-image/score-label-image.d.ts +0 -10
  100. package/dist/widgets/label-image/types.d.ts +0 -11
  101. package/dist/widgets/matcher/score-matcher.d.ts +0 -4
  102. package/dist/widgets/matrix/score-matrix.d.ts +0 -5
  103. package/dist/widgets/matrix/validate-matrix.d.ts +0 -13
  104. package/dist/widgets/number-line/score-number-line.d.ts +0 -4
  105. package/dist/widgets/number-line/validate-number-line.d.ts +0 -12
  106. package/dist/widgets/numeric-input/score-numeric-input.d.ts +0 -6
  107. package/dist/widgets/orderer/score-orderer.d.ts +0 -3
  108. package/dist/widgets/orderer/validate-orderer.d.ts +0 -10
  109. package/dist/widgets/plotter/score-plotter.d.ts +0 -4
  110. package/dist/widgets/plotter/validate-plotter.d.ts +0 -10
  111. package/dist/widgets/radio/score-radio.d.ts +0 -5
  112. package/dist/widgets/radio/validate-radio.d.ts +0 -12
  113. package/dist/widgets/sorter/score-sorter.d.ts +0 -4
  114. package/dist/widgets/sorter/validate-sorter.d.ts +0 -11
  115. package/dist/widgets/table/score-table.d.ts +0 -5
  116. package/dist/widgets/table/utils.d.ts +0 -7
  117. package/dist/widgets/table/validate-table.d.ts +0 -4
@@ -1,12 +1,11 @@
1
+ import { type PerseusExpressionWidgetOptions } from "@khanacademy/perseus-core";
2
+ import { scoreExpression, type PerseusExpressionRubric, type PerseusExpressionUserInput } from "@khanacademy/perseus-score";
1
3
  import * as React from "react";
2
4
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import scoreExpression from "./score-expression";
4
5
  import type { DependenciesContext } from "../../dependencies";
5
6
  import type { FocusPath, Widget, WidgetProps } from "../../types";
6
- import type { PerseusExpressionRubric, PerseusExpressionUserInput } from "../../validation.types";
7
7
  import type { ExpressionPromptJSON } from "../../widget-ai-utils/expression/expression-ai-utils";
8
8
  import type { Keys as Key, KeypadConfiguration } from "@khanacademy/math-input";
9
- import type { PerseusExpressionWidgetOptions } from "@khanacademy/perseus-core";
10
9
  type InputPath = ReadonlyArray<string>;
11
10
  type RenderProps = {
12
11
  buttonSets: PerseusExpressionWidgetOptions["buttonSets"];
@@ -169,10 +168,8 @@ declare const _default: {
169
168
  visibleLabel: PerseusExpressionWidgetOptions["visibleLabel"];
170
169
  ariaLabel: PerseusExpressionWidgetOptions["ariaLabel"];
171
170
  value: string;
172
- }, "ariaLabel" | "static" | "onChange" | "keypadElement" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "alignment" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "reviewModeRubric" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
171
+ }, "static" | "containerSizeClass" | "widgetId" | "onChange" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "ariaLabel" | "alignment" | "reviewMode" | keyof import("../..").PerseusDependenciesV2 | "reviewModeRubric" | "isLastUsedWidget" | "visibleLabel" | "buttonsVisible" | "keypadConfiguration"> & {
173
172
  value?: string | undefined;
174
- onFocus?: ((blurPath: FocusPath) => void) | undefined;
175
- onBlur?: ((blurPath: FocusPath) => void) | undefined;
176
173
  apiOptions?: Readonly<Readonly<{
177
174
  isArticle?: boolean;
178
175
  onFocusChange?: (newFocusPath: FocusPath, oldFocusPath: FocusPath, keypadHeight?: number, focusedElement?: HTMLElement) => unknown;
@@ -224,6 +221,8 @@ declare const _default: {
224
221
  setDrawingAreaAvailable: NonNullable<import("../..").APIOptions["setDrawingAreaAvailable"]>;
225
222
  showAlignmentOptions: NonNullable<import("../..").APIOptions["showAlignmentOptions"]>;
226
223
  }> | undefined;
224
+ onBlur?: ((blurPath: FocusPath) => void) | undefined;
225
+ onFocus?: ((blurPath: FocusPath) => void) | undefined;
227
226
  linterContext?: import("@khanacademy/perseus-linter").LinterContextProps | undefined;
228
227
  buttonSets?: import("@khanacademy/perseus-core").LegacyButtonSets | undefined;
229
228
  functions?: readonly string[] | undefined;
@@ -3,9 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import Renderer from "../../renderer";
4
4
  import type { ANSWER_BAR_STATES } from "./graded-group-answer-bar";
5
5
  import type { FocusPath, TrackingGradedGroupExtraArguments, Widget, WidgetProps } from "../../types";
6
- import type { PerseusGradedGroupRubric } from "../../validation.types";
7
6
  import type { GradedGroupPromptJSON } from "../../widget-ai-utils/graded-group/graded-group-ai-utils";
8
7
  import type { PerseusGradedGroupWidgetOptions } from "@khanacademy/perseus-core";
8
+ import type { PerseusGradedGroupRubric } from "@khanacademy/perseus-score";
9
9
  declare const GRADING_STATUSES: {
10
10
  readonly ungraded: "ungraded";
11
11
  readonly correct: "correct";
@@ -2,9 +2,9 @@ import * as React from "react";
2
2
  import * as Changeable from "../../mixins/changeable";
3
3
  import { GradedGroup } from "../graded-group/graded-group";
4
4
  import type { FocusPath, Widget, WidgetProps } from "../../types";
5
- import type { PerseusGradedGroupSetRubric } from "../../validation.types";
6
5
  import type { GradedGroupSetPromptJSON } from "../../widget-ai-utils/graded-group-set/graded-group-set-ai-utils";
7
6
  import type { PerseusGradedGroupSetWidgetOptions } from "@khanacademy/perseus-core";
7
+ import type { PerseusGradedGroupSetRubric } from "@khanacademy/perseus-score";
8
8
  type RenderProps = PerseusGradedGroupSetWidgetOptions;
9
9
  type Props = Changeable.ChangeableProps & WidgetProps<RenderProps, PerseusGradedGroupSetRubric> & {
10
10
  trackInteraction: () => void;
@@ -1,10 +1,9 @@
1
+ import { scoreGrapher, type PerseusGrapherRubric, type PerseusGrapherUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import Graphie from "../../components/graphie";
3
- import scoreGrapher from "./score-grapher";
4
4
  import type { Coord } from "../../interactive2/types";
5
5
  import type { Widget, WidgetProps } from "../../types";
6
6
  import type { GridDimensions } from "../../util";
7
- import type { PerseusGrapherRubric, PerseusGrapherUserInput } from "../../validation.types";
8
7
  import type { GrapherPromptJSON } from "../../widget-ai-utils/grapher/grapher-ai-utils";
9
8
  import type { MarkingsType, PerseusGrapherWidgetOptions } from "@khanacademy/perseus-core";
10
9
  import type { PropsFor } from "@khanacademy/wonder-blocks-core";
@@ -1,18 +1,10 @@
1
- import type { LinearType, QuadraticType, SinusoidType, TangentType, ExponentialType, LogarithmType, AbsoluteValueType } from "./grapher-types";
1
+ import { GrapherUtil } from "@khanacademy/perseus-core";
2
2
  import type { Coord } from "../../interactive2/types";
3
- declare const functionTypeMapping: {
4
- readonly linear: LinearType;
5
- readonly quadratic: QuadraticType;
6
- readonly sinusoid: SinusoidType;
7
- readonly tangent: TangentType;
8
- readonly exponential: ExponentialType;
9
- readonly logarithm: LogarithmType;
10
- readonly absolute_value: AbsoluteValueType;
3
+ import type { FunctionTypeMappingKeys } from "@khanacademy/perseus-core";
4
+ type MovableMap = {
5
+ [K in keyof typeof GrapherUtil.MOVABLES]: any;
11
6
  };
12
- export declare const allTypes: any;
13
- type FunctionTypeMappingKeys = keyof typeof functionTypeMapping;
14
- type ConditionalGraderType<T extends FunctionTypeMappingKeys> = T extends "linear" ? LinearType : T extends "quadratic" ? QuadraticType : T extends "sinusoid" ? SinusoidType : T extends "tangent" ? TangentType : T extends "exponential" ? ExponentialType : T extends "logarithm" ? LogarithmType : T extends "absolute_value" ? AbsoluteValueType : never;
15
- export declare function functionForType<T extends FunctionTypeMappingKeys>(type: T): ConditionalGraderType<T>;
7
+ export declare const movableTypeToComponent: MovableMap;
16
8
  export declare const getEquationString: (props: any) => string;
17
9
  export declare const maybePointsFromNormalized: (coordsList: ReadonlyArray<Coord> | null | undefined, range: [Coord, Coord], step: [number, number], snapStep: [number, number]) => ReadonlyArray<Coord> | null | undefined;
18
10
  export declare const defaultPlotProps: (type: FunctionTypeMappingKeys, graph: any) => any;
@@ -3,9 +3,9 @@ import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import Renderer from "../../renderer";
4
4
  import scoreGroup from "./score-group";
5
5
  import type { ChangeFn, FocusPath, Widget, WidgetProps } from "../../types";
6
- import type { PerseusGroupRubric, UserInputArray } from "../../validation.types";
7
6
  import type { GroupPromptJSON } from "../../widget-ai-utils/group/group-ai-utils";
8
7
  import type { PerseusGroupWidgetOptions } from "@khanacademy/perseus-core";
8
+ import type { PerseusGroupRubric, UserInputArray } from "@khanacademy/perseus-score";
9
9
  type RenderProps = PerseusGroupWidgetOptions;
10
10
  type Props = WidgetProps<RenderProps, PerseusGroupRubric>;
11
11
  type DefaultProps = {
@@ -21,7 +21,7 @@ declare class Group extends React.Component<Props> implements Widget {
21
21
  static defaultProps: DefaultProps;
22
22
  componentDidMount(): void;
23
23
  change: ChangeFn;
24
- getUserInputMap(): import("../..").UserInputMap | undefined;
24
+ getUserInputMap(): import("@khanacademy/perseus-score").UserInputMap | undefined;
25
25
  /**
26
26
  * @deprecated getUserInputMap should be used for Groups
27
27
  */
@@ -1,5 +1,4 @@
1
1
  import type { PerseusStrings } from "../../strings";
2
- import type { PerseusScore } from "../../types";
3
- import type { PerseusGroupRubric, PerseusGroupUserInput } from "../../validation.types";
2
+ import type { PerseusScore, PerseusGroupRubric, PerseusGroupUserInput } from "@khanacademy/perseus-score";
4
3
  declare function scoreGroup(userInput: PerseusGroupUserInput, options: PerseusGroupRubric, strings: PerseusStrings, locale: string): PerseusScore;
5
4
  export default scoreGroup;
@@ -6,10 +6,9 @@
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, type PerseusIFrameRubric, type PerseusIFrameUserInput, type UserInputStatus } from "@khanacademy/perseus-score";
9
10
  import * as React from "react";
10
- import { scoreIframe } from "./score-iframe";
11
11
  import type { WidgetProps, Widget } from "../../types";
12
- import type { PerseusIFrameRubric, PerseusIFrameUserInput, UserInputStatus } from "../../validation.types";
13
12
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
14
13
  import type { PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
15
14
  type RenderProps = PerseusIFrameWidgetOptions & {
@@ -44,6 +44,6 @@ declare const _default: {
44
44
  displayName: string;
45
45
  widget: typeof ImageWidget;
46
46
  isLintable: true;
47
- scorer: () => import("../..").PerseusScore;
47
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
48
48
  };
49
49
  export default _default;
@@ -1,8 +1,7 @@
1
+ import { scoreInputNumber, type PerseusInputNumberRubric, type PerseusInputNumberUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import scoreInputNumber from "./score-input-number";
4
4
  import type { Path, Widget, WidgetProps } from "../../types";
5
- import type { PerseusInputNumberRubric, PerseusInputNumberUserInput } from "../../validation.types";
6
5
  import type { InputNumberPromptJSON } from "../../widget-ai-utils/input-number/input-number-ai-utils";
7
6
  import type { PerseusInputNumberWidgetOptions } from "@khanacademy/perseus-core";
8
7
  type RenderProps = {
@@ -33,6 +33,6 @@ declare const _default: {
33
33
  widget: typeof Interaction;
34
34
  transform: <T>(value: T) => T;
35
35
  hidden: true;
36
- scorer: () => import("../..").PerseusScore;
36
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
37
37
  };
38
38
  export default _default;
@@ -1,14 +1,13 @@
1
+ import { scoreInteractiveGraph, type PerseusInteractiveGraphRubric, type PerseusInteractiveGraphUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../components/i18n-context";
3
- import scoreInteractiveGraph from "./interactive-graphs/score-interactive-graph";
4
4
  import type { StatefulMafsGraphType } from "./interactive-graphs/stateful-mafs-graph";
5
5
  import type { QuadraticGraphState } from "./interactive-graphs/types";
6
6
  import type { Coord } from "../interactive2/types";
7
7
  import type { ChangeHandler, WidgetProps } from "../types";
8
- import type { QuadraticCoefficient, Range, SineCoefficient } from "../util/geometry";
9
- import type { PerseusInteractiveGraphRubric, PerseusInteractiveGraphUserInput } from "../validation.types";
10
8
  import type { InteractiveGraphPromptJSON } from "../widget-ai-utils/interactive-graph/interactive-graph-ai-utils";
11
9
  import type { UnsupportedWidgetPromptJSON } from "../widget-ai-utils/unsupported-widget";
10
+ import type { QuadraticCoefficient, SineCoefficient, Range } from "@khanacademy/kmath";
12
11
  import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeSegment, GraphRange, LockedFigure, PerseusImageBackground, MarkingsType } from "@khanacademy/perseus-core";
13
12
  type RenderProps = {
14
13
  /**
@@ -1,2 +1,4 @@
1
+ import type { I18nContextType } from "../../../components/i18n-context";
1
2
  import type { LinearSystemGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
2
3
  export declare function renderLinearSystemGraph(state: LinearSystemGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
4
+ export declare function describeLinearSystemGraph(state: LinearSystemGraphState, i18n: I18nContextType): string;
@@ -1,6 +1,4 @@
1
1
  import type { QuadraticGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
2
+ import type { QuadraticCoefficient, QuadraticCoords } from "@khanacademy/kmath";
2
3
  export declare function renderQuadraticGraph(state: QuadraticGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
3
- type QuadraticCoefficient = [number, number, number];
4
- export type QuadraticCoords = QuadraticGraphState["coords"];
5
4
  export declare const getQuadraticCoefficients: (coords: QuadraticCoords) => QuadraticCoefficient | undefined;
6
- export {};
@@ -1,2 +1,4 @@
1
+ import type { I18nContextType } from "../../../components/i18n-context";
1
2
  import type { Dispatch, InteractiveGraphElementSuite, RayGraphState } from "../types";
2
3
  export declare function renderRayGraph(state: RayGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
4
+ export declare function describeRayGraph(state: RayGraphState, i18n: I18nContextType): Record<string, string>;
@@ -1,11 +1,6 @@
1
- import type { Coord } from "../../../interactive2/types";
2
1
  import type { SinusoidGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
2
+ import type { NamedSineCoefficient } from "@khanacademy/kmath";
3
+ import type { Coord } from "@khanacademy/perseus-core";
3
4
  export declare function renderSinusoidGraph(state: SinusoidGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
4
- export type SineCoefficient = {
5
- amplitude: number;
6
- angularFrequency: number;
7
- phase: number;
8
- verticalOffset: number;
9
- };
10
- export declare const computeSine: (x: number, sinusoidCoefficients: SineCoefficient) => number;
11
- export declare const getSinusoidCoefficients: (coords: ReadonlyArray<Coord>) => SineCoefficient | undefined;
5
+ export declare const computeSine: (x: number, sinusoidCoefficients: NamedSineCoefficient) => number;
6
+ export declare const getSinusoidCoefficients: (coords: ReadonlyArray<Coord>) => NamedSineCoefficient | undefined;
@@ -1,3 +1,5 @@
1
+ import type { PerseusStrings } from "../../../strings";
2
+ import type { PairOfPoints } from "../types";
1
3
  import type { Coord } from "@khanacademy/perseus";
2
4
  import type { Interval, vec } from "mafs";
3
5
  /**
@@ -9,3 +11,5 @@ import type { Interval, vec } from "mafs";
9
11
  */
10
12
  export declare const getIntersectionOfRayWithBox: (initialPoint: vec.Vector2, throughPoint: vec.Vector2, box: [x: Interval, y: Interval]) => [number, number];
11
13
  export declare function getArrayWithoutDuplicates(array: Array<Coord>): Array<Coord>;
14
+ export declare function getSlopeStringForLine(line: PairOfPoints, strings: PerseusStrings): string;
15
+ export declare function getInterceptStringForLine(line: PairOfPoints, strings: PerseusStrings, locale: string): string;
@@ -5,4 +5,3 @@ export { X, Y } from "./coordinates";
5
5
  export { MIN, MAX, size } from "./interval";
6
6
  export { lerp } from "./interpolation";
7
7
  export { segmentsIntersect } from "./geometry";
8
- export { calculateAngleInDegrees, convertDegreesToRadians, getClockwiseAngle, getAngleFromVertex, polar, } from "./angles";
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
2
  import type { InteractiveGraphProps } from "./types";
3
3
  import type { APIOptions } from "../../types";
4
- import type { PerseusInteractiveGraphUserInput } from "../../validation.types";
5
4
  import type { PerseusGraphType } from "@khanacademy/perseus-core";
5
+ import type { PerseusInteractiveGraphUserInput } from "@khanacademy/perseus-score";
6
6
  export type StatefulMafsGraphProps = {
7
7
  flags?: APIOptions["flags"];
8
8
  box: [number, number];
@@ -1,6 +1,7 @@
1
1
  import type { InteractiveGraphAction } from "./reducer/interactive-graph-action";
2
2
  import type { Coord } from "../../interactive2/types";
3
3
  import type { WidgetProps } from "../../types";
4
+ import type { QuadraticCoords } from "@khanacademy/kmath";
4
5
  import type { PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core";
5
6
  import type { Interval, vec } from "mafs";
6
7
  import type { ReactNode } from "react";
@@ -70,7 +71,7 @@ export interface CircleGraphState extends InteractiveGraphStateCommon {
70
71
  }
71
72
  export interface QuadraticGraphState extends InteractiveGraphStateCommon {
72
73
  type: "quadratic";
73
- coords: [Coord, Coord, Coord];
74
+ coords: QuadraticCoords;
74
75
  }
75
76
  export interface SinusoidGraphState extends InteractiveGraphStateCommon {
76
77
  type: "sinusoid";
@@ -5,17 +5,15 @@
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, type PerseusLabelImageRubric, type PerseusLabelImageUserInput } from "@khanacademy/perseus-score";
8
9
  import * as React from "react";
9
10
  import { PerseusI18nContext } from "../../components/i18n-context";
10
11
  import Marker from "./marker";
11
- import scoreLabelImage from "./score-label-image";
12
- import type { InteractiveMarkerType } from "./types";
13
12
  import type { DependencyProps } from "../../dependencies";
14
13
  import type { ChangeableProps } from "../../mixins/changeable";
15
14
  import type { APIOptions, Widget } from "../../types";
16
- import type { PerseusLabelImageRubric, PerseusLabelImageUserInput } from "../../validation.types";
17
15
  import type { LabelImagePromptJSON } from "../../widget-ai-utils/label-image/label-image-ai-utils";
18
- import type { PerseusLabelImageWidgetOptions } from "@khanacademy/perseus-core";
16
+ import type { InteractiveMarkerType, PerseusLabelImageWidgetOptions } from "@khanacademy/perseus-core";
19
17
  export type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
20
18
  /**
21
19
  * Represents a direction vector.
@@ -5,8 +5,7 @@
5
5
  */
6
6
  import * as React from "react";
7
7
  import { PerseusI18nContext } from "../../components/i18n-context";
8
- import type { InteractiveMarkerType } from "./types";
9
- import type { AnalyticsEventHandlerFn } from "@khanacademy/perseus-core";
8
+ import type { AnalyticsEventHandlerFn, InteractiveMarkerType } from "@khanacademy/perseus-core";
10
9
  import type { CSSProperties } from "aphrodite";
11
10
  type Props = InteractiveMarkerType & {
12
11
  showSelected: boolean;
@@ -1,9 +1,8 @@
1
+ import { scoreMatcher, type PerseusMatcherRubric, type PerseusMatcherUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import scoreMatcher from "./score-matcher";
4
4
  import type { SortableOption } from "../../components/sortable";
5
5
  import type { WidgetProps, Widget } from "../../types";
6
- import type { PerseusMatcherRubric, PerseusMatcherUserInput } from "../../validation.types";
7
6
  import type { MatcherPromptJSON } from "../../widget-ai-utils/matcher/matcher-ai-utils";
8
7
  import type { PerseusMatcherWidgetOptions } from "@khanacademy/perseus-core";
9
8
  type RenderProps = PerseusMatcherWidgetOptions;
@@ -1,11 +1,9 @@
1
+ import { type PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
2
+ import { scoreMatrix, type PerseusMatrixRubric, type PerseusMatrixUserInput } from "@khanacademy/perseus-score";
1
3
  import * as React from "react";
2
4
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import scoreMatrix from "./score-matrix";
4
5
  import type { WidgetProps, Widget, FocusPath } from "../../types";
5
- import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "../../validation.types";
6
6
  import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
7
- import type { PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
8
- export declare function getMatrixSize(matrix: ReadonlyArray<ReadonlyArray<number>>): number[];
9
7
  type ExternalProps = WidgetProps<{
10
8
  prefix: string;
11
9
  suffix: string;
@@ -42,6 +42,6 @@ declare const _default: {
42
42
  propUpgrades: {
43
43
  readonly "1": (v0props: any) => PerseusMeasurerWidgetOptions;
44
44
  };
45
- scorer: () => import("../..").PerseusScore;
45
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
46
46
  };
47
47
  export default _default;
@@ -1,9 +1,9 @@
1
1
  import * as React from "react";
2
2
  import scoreMockWidget from "./score-mock-widget";
3
3
  import type { WidgetProps, Widget, FocusPath } from "../../types";
4
- import type { PerseusMockWidgetRubric, PerseusMockWidgetUserInput } from "../../validation.types";
5
4
  import type { MockWidgetPromptJSON } from "../../widget-ai-utils/mock-widget/prompt-utils";
6
5
  import type { MockWidgetOptions } from "@khanacademy/perseus-core";
6
+ import type { PerseusMockWidgetRubric, PerseusMockWidgetUserInput } from "@khanacademy/perseus-score";
7
7
  type ExternalProps = WidgetProps<MockWidgetOptions, PerseusMockWidgetRubric>;
8
8
  type DefaultProps = {
9
9
  currentValue: Props["currentValue"];
@@ -1,5 +1,4 @@
1
1
  import type { PerseusStrings } from "../../strings";
2
- import type { PerseusMockWidgetUserInput, PerseusMockWidgetRubric } from "../../validation.types";
3
- import type { PerseusScore } from "@khanacademy/perseus";
2
+ import type { PerseusMockWidgetUserInput, PerseusMockWidgetRubric, PerseusScore } from "@khanacademy/perseus-score";
4
3
  declare function scoreMockWidget(userInput: PerseusMockWidgetUserInput, rubric: PerseusMockWidgetRubric, strings: PerseusStrings): PerseusScore;
5
4
  export default scoreMockWidget;
@@ -19,6 +19,6 @@ declare const _default: {
19
19
  displayName: string;
20
20
  hidden: true;
21
21
  widget: typeof MoleculeWidget;
22
- scorer: () => import("../..").PerseusScore;
22
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
23
23
  };
24
24
  export default _default;
@@ -1,11 +1,10 @@
1
+ import { scoreNumberLine, type PerseusNumberLineUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import scoreNumberLine from "./score-number-line";
4
4
  import type { ChangeableProps } from "../../mixins/changeable";
5
5
  import type { APIOptions, FocusPath, Widget } from "../../types";
6
- import type { PerseusNumberLineUserInput } from "../../validation.types";
7
6
  import type { NumberLinePromptJSON } from "../../widget-ai-utils/number-line/number-line-ai-utils";
8
- export type Relationship = "lt" | "gt" | "le" | "ge";
7
+ import type { Relationship } from "@khanacademy/perseus-core";
9
8
  type Props = ChangeableProps & {
10
9
  range: [number, number];
11
10
  labelRange: ReadonlyArray<number | null>;
@@ -1,10 +1,9 @@
1
+ import { scoreNumericInput, type PerseusNumericInputRubric, type PerseusNumericInputUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
4
  import InputWithExamples from "../../components/input-with-examples";
4
5
  import SimpleKeypadInput from "../../components/simple-keypad-input";
5
- import scoreNumericInput from "./score-numeric-input";
6
6
  import type { FocusPath, Widget, WidgetProps } from "../../types";
7
- import type { PerseusNumericInputRubric, PerseusNumericInputUserInput } from "../../validation.types";
8
7
  import type { NumericInputPromptJSON } from "../../widget-ai-utils/numeric-input/prompt-utils";
9
8
  import type { PerseusNumericInputWidgetOptions, PerseusNumericInputAnswerForm } from "@khanacademy/perseus-core";
10
9
  type ExternalProps = WidgetProps<PerseusNumericInputWidgetOptions, PerseusNumericInputRubric>;
@@ -1,7 +1,6 @@
1
+ import { scoreOrderer, type PerseusOrdererRubric, type PerseusOrdererUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
- import { scoreOrderer } from "./score-orderer";
3
3
  import type { WidgetProps, Widget } from "../../types";
4
- import type { PerseusOrdererRubric, PerseusOrdererUserInput } from "../../validation.types";
5
4
  import type { OrdererPromptJSON } from "../../widget-ai-utils/orderer/orderer-ai-utils";
6
5
  import type { PerseusOrdererWidgetOptions } from "@khanacademy/perseus-core";
7
6
  type Position = {
@@ -105,6 +105,6 @@ declare const _default: {
105
105
  widget: typeof Passage;
106
106
  transform: (editorProps: any) => RenderProps;
107
107
  isLintable: true;
108
- scorer: () => import("../..").PerseusScore;
108
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
109
109
  };
110
110
  export default _default;
@@ -52,6 +52,6 @@ declare const _default: {
52
52
  major: number;
53
53
  minor: number;
54
54
  };
55
- scorer: () => import("../..").PerseusScore;
55
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
56
56
  };
57
57
  export default _default;
@@ -33,6 +33,6 @@ declare const _default: {
33
33
  minor: number;
34
34
  };
35
35
  isLintable: true;
36
- scorer: () => import("../..").PerseusScore;
36
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
37
37
  };
38
38
  export default _default;
@@ -1,8 +1,7 @@
1
+ import { scorePlotter, type PerseusPlotterScoringData, type PerseusPlotterUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import scorePlotter from "./score-plotter";
4
4
  import type { Widget, WidgetProps } from "../../types";
5
- import type { PerseusPlotterScoringData, PerseusPlotterUserInput } from "../../validation.types";
6
5
  import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
7
6
  import type { PerseusPlotterWidgetOptions } from "@khanacademy/perseus-core";
8
7
  type RenderProps = PerseusPlotterWidgetOptions;
@@ -1,8 +1,8 @@
1
+ import { type PerseusRadioRubric, type PerseusRadioUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
4
  import type { FocusFunction } from "./base-radio";
4
5
  import type { WidgetProps, ChoiceState, Widget } from "../../types";
5
- import type { PerseusRadioRubric, PerseusRadioUserInput } from "../../validation.types";
6
6
  import type { RadioPromptJSON } from "../../widget-ai-utils/radio/radio-ai-utils";
7
7
  import type { PerseusRadioChoice, PerseusRadioWidgetOptions, ShowSolutions } from "@khanacademy/perseus-core";
8
8
  export type RenderProps = {
@@ -1,5 +1,5 @@
1
+ import { scoreRadio } from "@khanacademy/perseus-score";
1
2
  import Radio from "./radio-component";
2
- import scoreRadio from "./score-radio";
3
3
  import type { RenderProps } from "./radio-component";
4
4
  import type { PerseusStrings } from "../../strings";
5
5
  import type { PerseusRadioWidgetOptions } from "@khanacademy/perseus-core";
@@ -1,8 +1,7 @@
1
+ import { scoreSorter, type PerseusSorterRubric, type PerseusSorterUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
- import scoreSorter from "./score-sorter";
3
3
  import type { SortableOption } from "../../components/sortable";
4
4
  import type { Widget, WidgetProps } from "../../types";
5
- import type { PerseusSorterRubric, PerseusSorterUserInput } from "../../validation.types";
6
5
  import type { SorterPromptJSON } from "../../widget-ai-utils/sorter/sorter-ai-utils";
7
6
  import type { PerseusSorterWidgetOptions } from "@khanacademy/perseus-core";
8
7
  type RenderProps = PerseusSorterWidgetOptions;
@@ -1,9 +1,8 @@
1
+ import { scoreTable, type PerseusTableRubric, type PerseusTableUserInput } from "@khanacademy/perseus-score";
1
2
  import * as React from "react";
2
3
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import scoreTable from "./score-table";
4
4
  import type { ChangeableProps } from "../../mixins/changeable";
5
5
  import type { Widget, WidgetProps } from "../../types";
6
- import type { PerseusTableRubric, PerseusTableUserInput } from "../../validation.types";
7
6
  import type { PerseusTableWidgetOptions } from "@khanacademy/perseus-core";
8
7
  type RenderProps = PerseusTableWidgetOptions & {
9
8
  editableHeaders: boolean;
@@ -27,6 +27,6 @@ declare const _default: {
27
27
  defaultAlignment: "block";
28
28
  supportedAlignments: ("block" | "full-width" | "float-left" | "float-right")[];
29
29
  widget: typeof Video;
30
- scorer: () => import("../..").PerseusScore;
30
+ scorer: () => import("@khanacademy/perseus-score").PerseusScore;
31
31
  };
32
32
  export default _default;
package/dist/widgets.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { PerseusStrings } from "./strings";
2
- import type { Alignment, Tracking, Version, WidgetExports, WidgetTransform, WidgetScorerFunction } from "./types";
2
+ import type { Alignment, Tracking, Version, WidgetExports, WidgetTransform, WidgetScorerFunction, PublicWidgetOptionsFunction } from "./types";
3
3
  import type { PerseusWidget } from "@khanacademy/perseus-core";
4
4
  import type * as React from "react";
5
5
  type Editor = any;
@@ -29,6 +29,7 @@ export declare const replaceDeprecatedEditors: () => void;
29
29
  export declare const getWidget: (name: string) => React.ComponentType<any> | null | undefined;
30
30
  export declare const getWidgetExport: (name: string) => WidgetExports | null;
31
31
  export declare const getWidgetScorer: (name: string) => WidgetScorerFunction | null;
32
+ export declare const getPublicWidgetOptionsFunction: (name: string) => PublicWidgetOptionsFunction;
32
33
  export declare const getEditor: (name: string) => Editor | null | undefined;
33
34
  export declare const getTransform: (name: string) => WidgetTransform | null | undefined;
34
35
  export declare const getVersion: (name: string) => Version | undefined;
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": "50.0.0",
6
+ "version": "51.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -41,15 +41,15 @@
41
41
  "test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
42
42
  },
43
43
  "dependencies": {
44
- "@khanacademy/kas": "^0.4.10",
45
- "@khanacademy/keypad-context": "^1.0.13",
46
- "@khanacademy/kmath": "^0.2.0",
47
- "@khanacademy/math-input": "^22.1.2",
48
- "@khanacademy/perseus-core": "3.1.0",
49
- "@khanacademy/perseus-linter": "^1.2.12",
50
- "@khanacademy/perseus-score": "^1.0.0",
51
- "@khanacademy/pure-markdown": "^0.3.21",
52
- "@khanacademy/simple-markdown": "^0.13.14",
44
+ "@khanacademy/kas": "^0.4.11",
45
+ "@khanacademy/keypad-context": "^1.0.14",
46
+ "@khanacademy/kmath": "^0.3.0",
47
+ "@khanacademy/math-input": "^22.2.1",
48
+ "@khanacademy/perseus-core": "3.2.0",
49
+ "@khanacademy/perseus-linter": "^1.2.13",
50
+ "@khanacademy/perseus-score": "^1.1.0",
51
+ "@khanacademy/pure-markdown": "^0.3.22",
52
+ "@khanacademy/simple-markdown": "^0.13.15",
53
53
  "@types/classnames": "2.2.0",
54
54
  "@use-gesture/react": "^10.2.27",
55
55
  "mafs": "0.19.0",
@@ -124,4 +124,4 @@
124
124
  "underscore": "^1.4.4"
125
125
  },
126
126
  "keywords": []
127
- }
127
+ }
@@ -1,7 +0,0 @@
1
- declare function modifyTex(tex: string): string;
2
- declare function parseTex(tex: string): string;
3
- declare const _default: {
4
- parseTex: typeof parseTex;
5
- modifyTex: typeof modifyTex;
6
- };
7
- export default _default;
@@ -1,28 +0,0 @@
1
- /**
2
- * A collection of geomtry-related utility functions
3
- */
4
- import type { Coord, Line } from "../interactive2/types";
5
- export type Range = [number, number];
6
- export type SineCoefficient = [
7
- number,
8
- number,
9
- number,
10
- number
11
- ];
12
- export type QuadraticCoefficient = [number, number, number];
13
- export declare function sign(val: number): 0 | 1 | -1;
14
- export declare function ccw(a: Coord, b: Coord, c: Coord): number;
15
- export declare function collinear(a: Coord, b: Coord, c: Coord): boolean;
16
- export declare function intersects(ab: Line, cd: Line): boolean;
17
- export declare function polygonSidesIntersect(vertices: Coord[]): boolean;
18
- export declare function vector(a: any, b: any): number[];
19
- export declare function reverseVector(vector: Coord): Coord;
20
- export declare function clockwise(points: Coord[]): boolean;
21
- export declare function magnitude(v: ReadonlyArray<Coord>): number;
22
- export declare function angleMeasures(coords: ReadonlyArray<Coord>): ReadonlyArray<number>;
23
- export declare function similar(coords1: ReadonlyArray<Coord>, coords2: ReadonlyArray<Coord>, tolerance: number): boolean;
24
- export declare function lawOfCosines(a: number, b: number, c: number): number;
25
- export declare function canonicalSineCoefficients([amplitude, angularFrequency, phase, verticalOffset,]: [any, any, any, any]): any[];
26
- export declare function rotate<T>(array: ReadonlyArray<T>, n?: number): ReadonlyArray<T>;
27
- export declare function getLineEquation(first: Coord, second: Coord): string;
28
- export declare function getLineIntersection(firstPoints: ReadonlyArray<Coord>, secondPoints: ReadonlyArray<Coord>): string;