@khanacademy/perseus 72.0.0 → 72.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.
package/dist/util.d.ts CHANGED
@@ -167,7 +167,6 @@ declare const Util: {
167
167
  readonly rTypeFromWidgetId: RegExp;
168
168
  readonly rWidgetParts: RegExp;
169
169
  readonly snowman: "☃";
170
- readonly split: (str: string, r: RegExp) => ReadonlyArray<string>;
171
170
  readonly firstNumericalParse: typeof firstNumericalParse;
172
171
  readonly stringArrayOfSize: typeof stringArrayOfSize;
173
172
  readonly stringArrayOfSize2D: typeof stringArrayOfSize2D;
@@ -1,11 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { Widget, WidgetProps } from "../../types";
3
+ import type { PerseusDependenciesV2, Widget, WidgetProps } from "../../types";
4
4
  import type { CategorizerPromptJSON } from "../../widget-ai-utils/categorizer/categorizer-ai-utils";
5
5
  import type { PerseusCategorizerWidgetOptions, PerseusCategorizerUserInput } from "@khanacademy/perseus-core";
6
6
  type ExternalProps = WidgetProps<PerseusCategorizerWidgetOptions, PerseusCategorizerUserInput>;
7
7
  type Props = ExternalProps & {
8
8
  linterContext: NonNullable<ExternalProps["linterContext"]>;
9
+ dependencies: PerseusDependenciesV2;
9
10
  };
10
11
  type DefaultProps = Pick<Props, "items" | "categories" | "linterContext" | "userInput">;
11
12
  type State = {
@@ -16,6 +17,7 @@ export declare class Categorizer extends React.Component<Props, State> implement
16
17
  context: React.ContextType<typeof PerseusI18nContext>;
17
18
  static defaultProps: DefaultProps;
18
19
  state: State;
20
+ componentDidMount(): void;
19
21
  /**
20
22
  * @deprecated and likely very broken API
21
23
  * [LEMS-3185] do not trust serializedState
@@ -40,7 +42,7 @@ declare const _default: {
40
42
  name: string;
41
43
  displayName: string;
42
44
  hidden: true;
43
- widget: typeof Categorizer;
45
+ widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
44
46
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
45
47
  getCorrectUserInput: typeof getCorrectUserInput;
46
48
  getStartUserInput: typeof getStartUserInput;
@@ -1,26 +1,13 @@
1
1
  import * as React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { Widget, WidgetProps } from "../../types";
4
- import type { DefinitionPromptJSON } from "../../widget-ai-utils/definition/definition-ai-utils";
2
+ import type { PerseusDependenciesV2, WidgetProps } from "../../types";
5
3
  import type { PerseusDefinitionWidgetOptions, PerseusRenderer } from "@khanacademy/perseus-core";
6
4
  type DefinitionProps = WidgetProps<PerseusDefinitionWidgetOptions> & {
7
5
  widgets: PerseusRenderer["widgets"];
6
+ dependencies: PerseusDependenciesV2;
8
7
  };
9
- type DefaultProps = {
10
- togglePrompt: string;
11
- definition: string;
12
- };
13
- declare class Definition extends React.Component<DefinitionProps> implements Widget {
14
- static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
15
- context: React.ContextType<typeof PerseusI18nContext>;
16
- static defaultProps: DefaultProps;
17
- isWidget: true;
18
- getPromptJSON(): DefinitionPromptJSON;
19
- render(): React.ReactNode;
20
- }
21
8
  declare const _default: {
22
9
  name: string;
23
10
  displayName: string;
24
- widget: typeof Definition;
11
+ widget: React.ForwardRefExoticComponent<Omit<DefinitionProps, "dependencies"> & React.RefAttributes<any>>;
25
12
  };
26
13
  export default _default;
@@ -1,30 +1,9 @@
1
1
  import * as React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { Widget, WidgetProps } from "../../types";
4
- import type { DropdownPromptJSON } from "../../widget-ai-utils/dropdown/dropdown-ai-utils";
2
+ import type { PerseusDependenciesV2, WidgetProps } from "../../types";
5
3
  import type { PerseusDropdownUserInput, PerseusDropdownWidgetOptions } from "@khanacademy/perseus-core";
6
- type Props = WidgetProps<PerseusDropdownWidgetOptions, PerseusDropdownUserInput>;
7
- type DefaultProps = {
8
- choices: Props["choices"];
9
- placeholder: Props["placeholder"];
10
- apiOptions: Props["apiOptions"];
11
- userInput: Props["userInput"];
4
+ type Props = WidgetProps<PerseusDropdownWidgetOptions, PerseusDropdownUserInput> & {
5
+ dependencies: PerseusDependenciesV2;
12
6
  };
13
- declare class Dropdown extends React.Component<Props> implements Widget {
14
- static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
15
- context: React.ContextType<typeof PerseusI18nContext>;
16
- static defaultProps: DefaultProps;
17
- focus: () => boolean;
18
- _handleChangeEvent: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
19
- _handleChange: (arg1: number) => void;
20
- getPromptJSON(): DropdownPromptJSON;
21
- /**
22
- * @deprecated and likely very broken API
23
- * [LEMS-3185] do not trust serializedState
24
- */
25
- getSerializedState(): any;
26
- render(): React.ReactNode;
27
- }
28
7
  /**
29
8
  * @deprecated and likely a very broken API
30
9
  * [LEMS-3185] do not trust serializedState
@@ -35,7 +14,7 @@ declare function getCorrectUserInput(options: PerseusDropdownWidgetOptions): Per
35
14
  declare const _default: {
36
15
  name: string;
37
16
  displayName: string;
38
- widget: typeof Dropdown;
17
+ widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
39
18
  getStartUserInput: typeof getStartUserInput;
40
19
  getCorrectUserInput: typeof getCorrectUserInput;
41
20
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -1,36 +1,13 @@
1
1
  import * as React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { Widget, WidgetProps } from "../../types";
4
- import type { ExplanationPromptJSON } from "../../widget-ai-utils/explanation/explanation-ai-utils";
2
+ import type { PerseusDependenciesV2, WidgetProps } from "../../types";
5
3
  import type { PerseusExplanationWidgetOptions } from "@khanacademy/perseus-core";
6
- type Props = WidgetProps<PerseusExplanationWidgetOptions>;
7
- type DefaultProps = {
8
- showPrompt: Props["showPrompt"];
9
- hidePrompt: Props["hidePrompt"];
10
- explanation: Props["explanation"];
11
- widgets: Props["widgets"];
12
- linterContext: Props["linterContext"];
4
+ type Props = WidgetProps<PerseusExplanationWidgetOptions> & {
5
+ dependencies: PerseusDependenciesV2;
13
6
  };
14
- type State = {
15
- expanded: boolean;
16
- };
17
- declare class Explanation extends React.Component<Props, State> implements Widget {
18
- static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
19
- context: React.ContextType<typeof PerseusI18nContext>;
20
- static defaultProps: DefaultProps;
21
- isWidget: true;
22
- state: State;
23
- _mounted: boolean;
24
- componentDidMount(): void;
25
- componentWillUnmount(): void;
26
- _onClick: () => void;
27
- getPromptJSON(): ExplanationPromptJSON;
28
- render(): React.ReactNode;
29
- }
30
7
  declare const _default: {
31
8
  name: string;
32
9
  displayName: string;
33
- widget: typeof Explanation;
10
+ widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
34
11
  isLintable: true;
35
12
  };
36
13
  export default _default;
@@ -1,7 +1,5 @@
1
1
  import * as React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { Path, Widget, WidgetProps } from "../../types";
4
- import type { InputNumberPromptJSON } from "../../widget-ai-utils/input-number/input-number-ai-utils";
2
+ import type { PerseusDependenciesV2, WidgetProps } from "../../types";
5
3
  import type { PerseusInputNumberWidgetOptions, PerseusInputNumberUserInput } from "@khanacademy/perseus-core";
6
4
  type ExternalProps = WidgetProps<PerseusInputNumberWidgetOptions, PerseusInputNumberUserInput>;
7
5
  type Props = ExternalProps & {
@@ -10,29 +8,8 @@ type Props = ExternalProps & {
10
8
  rightAlign: NonNullable<ExternalProps["rightAlign"]>;
11
9
  size: NonNullable<ExternalProps["size"]>;
12
10
  answerType: NonNullable<ExternalProps["answerType"]>;
11
+ dependencies: PerseusDependenciesV2;
13
12
  };
14
- type DefaultProps = Pick<Props, "answerType" | "apiOptions" | "linterContext" | "rightAlign" | "size" | "userInput">;
15
- declare class InputNumber extends React.Component<Props> implements Widget {
16
- static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
17
- context: React.ContextType<typeof PerseusI18nContext>;
18
- static defaultProps: DefaultProps;
19
- shouldShowExamples: () => boolean;
20
- handleChange: (arg1: string, arg2: () => void) => void;
21
- _handleFocus: () => void;
22
- _handleBlur: () => void;
23
- focus: () => boolean;
24
- focusInputPath: (arg1: Path) => void;
25
- blurInputPath: (arg1: Path) => void;
26
- getInputPaths: () => ReadonlyArray<Path>;
27
- getPromptJSON(): InputNumberPromptJSON;
28
- examples(): ReadonlyArray<string>;
29
- /**
30
- * @deprecated and likely very broken API
31
- * [LEMS-3185] do not trust serializedState
32
- */
33
- getSerializedState(): any;
34
- render(): React.ReactNode;
35
- }
36
13
  declare function getOneCorrectAnswerFromRubric(rubric: any): string | undefined;
37
14
  /**
38
15
  * @deprecated and likely a very broken API
@@ -45,7 +22,7 @@ declare const _default: {
45
22
  name: string;
46
23
  displayName: string;
47
24
  hidden: true;
48
- widget: typeof InputNumber;
25
+ widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
49
26
  isLintable: true;
50
27
  getOneCorrectAnswerFromRubric: typeof getOneCorrectAnswerFromRubric;
51
28
  getStartUserInput: typeof getStartUserInput;
@@ -1,10 +1,12 @@
1
1
  import * as React from "react";
2
2
  import { PerseusI18nContext } from "../../components/i18n-context";
3
3
  import type { SortableOption } from "../../components/sortable";
4
- import type { WidgetProps, Widget } from "../../types";
4
+ import type { WidgetProps, Widget, PerseusDependenciesV2 } from "../../types";
5
5
  import type { MatcherPromptJSON } from "../../widget-ai-utils/matcher/matcher-ai-utils";
6
6
  import type { PerseusMatcherWidgetOptions, PerseusMatcherUserInput, MatcherPublicWidgetOptions } from "@khanacademy/perseus-core";
7
- type Props = WidgetProps<PerseusMatcherWidgetOptions, PerseusMatcherUserInput>;
7
+ type Props = WidgetProps<PerseusMatcherWidgetOptions, PerseusMatcherUserInput> & {
8
+ dependencies: PerseusDependenciesV2;
9
+ };
8
10
  type DefaultProps = {
9
11
  labels: Props["labels"];
10
12
  orderMatters: Props["orderMatters"];
@@ -23,6 +25,7 @@ export declare class Matcher extends React.Component<Props, State> implements Wi
23
25
  context: React.ContextType<typeof PerseusI18nContext>;
24
26
  static defaultProps: DefaultProps;
25
27
  state: State;
28
+ componentDidMount(): void;
26
29
  changeAndTrack: () => void;
27
30
  onMeasureLeft: (arg1: any) => void;
28
31
  onMeasureRight: (arg1: any) => void;
@@ -41,7 +44,7 @@ declare function getUserInputFromSerializedState(serializedState: any): PerseusM
41
44
  declare const _default: {
42
45
  name: string;
43
46
  displayName: string;
44
- widget: typeof Matcher;
47
+ widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
45
48
  isLintable: true;
46
49
  getStartUserInput: typeof getStartUserInput;
47
50
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -1,88 +1,12 @@
1
1
  import * as React from "react";
2
- import { PerseusI18nContext } from "../../components/i18n-context";
3
- import type { FocusPath, Widget, WidgetProps } from "../../types";
4
- import type { NumberLinePromptJSON } from "../../widget-ai-utils/number-line/number-line-ai-utils";
2
+ import type { WidgetProps, PerseusDependenciesV2 } from "../../types";
5
3
  import type { PerseusNumberLineUserInput, PerseusNumberLineWidgetOptions, NumberLinePublicWidgetOptions } from "@khanacademy/perseus-core";
6
4
  /**
7
5
  * The type of `this.props` inside the NumberLine widget.
8
6
  */
9
- type Props = WidgetProps<PerseusNumberLineWidgetOptions, PerseusNumberLineUserInput>;
10
- type CalculatedProps = Props & {
11
- tickStep: number;
7
+ type Props = WidgetProps<PerseusNumberLineWidgetOptions, PerseusNumberLineUserInput> & {
8
+ dependencies: PerseusDependenciesV2;
12
9
  };
13
- type DefaultProps = {
14
- range: Props["range"];
15
- labelStyle: Props["labelStyle"];
16
- labelRange: Props["labelRange"];
17
- divisionRange: Props["divisionRange"];
18
- labelTicks: Props["labelTicks"];
19
- isTickCtrl: Props["isTickCtrl"];
20
- isInequality: Props["isInequality"];
21
- snapDivisions: Props["snapDivisions"];
22
- showTooltips: Props["showTooltips"];
23
- apiOptions: Props["apiOptions"];
24
- };
25
- type State = {
26
- numDivisionsEmpty: boolean;
27
- };
28
- declare class NumberLine extends React.Component<Props, State> implements Widget {
29
- static contextType: React.Context<import("../../components/i18n-context").I18nContextType>;
30
- context: React.ContextType<typeof PerseusI18nContext>;
31
- static defaultProps: DefaultProps;
32
- state: any;
33
- /**
34
- * isTickCtrl seems like it can be null
35
- * but default props only work with undefined,
36
- * so this handles both null/undefined
37
- */
38
- getIsTickCtrl(): boolean;
39
- /**
40
- * snapDivisions seems like it can be null
41
- * but default props only work with undefined,
42
- * so this handles both null/undefined
43
- */
44
- getSnapDivisions(): number;
45
- isValid: () => boolean;
46
- onNumDivisionsChange: (arg1: number, arg2: any) => void;
47
- _handleTickCtrlFocus: () => void;
48
- _handleTickCtrlBlur: () => void;
49
- focus(): boolean;
50
- focusInputPath: (arg1: any) => void;
51
- blurInputPath: (arg1: any) => void;
52
- getInputPaths: () => ReadonlyArray<ReadonlyArray<string>>;
53
- getDOMNodeForPath(inputPath: FocusPath): Element | Text | null;
54
- _renderGraphie: () => React.ReactElement;
55
- snapNumLinePosition: (arg1: any, arg2: number) => number;
56
- movePosition: (arg1: number) => void;
57
- _renderNumberLinePoint: (arg1: CalculatedProps) => React.ReactElement;
58
- handleReverse: () => void;
59
- handleToggleStrict: () => void;
60
- _getInequalityEndpoint(props: CalculatedProps): [number, number];
61
- _renderInequality(props: CalculatedProps): React.ReactElement | null;
62
- _setupGraphie: (arg1: any, arg2: any) => void;
63
- getPromptJSON(): NumberLinePromptJSON;
64
- /**
65
- * @deprecated and likely very broken API
66
- * [LEMS-3185] do not trust serializedState
67
- */
68
- getSerializedState(): {
69
- alignment: string | null | undefined;
70
- static: boolean;
71
- range: number[];
72
- labelRange: (number | null)[];
73
- labelStyle: string;
74
- labelTicks: boolean;
75
- divisionRange: number[];
76
- snapDivisions: number;
77
- isInequality: boolean;
78
- showTooltips: boolean | undefined;
79
- isTickCtrl: boolean;
80
- numDivisions: number;
81
- numLinePosition: number;
82
- rel: string;
83
- };
84
- render(): React.ReactNode;
85
- }
86
10
  /**
87
11
  * @deprecated and likely a very broken API
88
12
  * [LEMS-3185] do not trust serializedState
@@ -93,7 +17,7 @@ declare function getStartUserInput(options: NumberLinePublicWidgetOptions): Pers
93
17
  declare const _default: {
94
18
  name: string;
95
19
  displayName: string;
96
- widget: typeof NumberLine;
20
+ widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
97
21
  getCorrectUserInput: typeof getCorrectUserInput;
98
22
  getStartUserInput: typeof getStartUserInput;
99
23
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
@@ -1,37 +1,9 @@
1
1
  import * as React from "react";
2
- import type { SortableOption } from "../../components/sortable";
3
- import type { Widget, WidgetProps } from "../../types";
4
- import type { SorterPromptJSON } from "../../widget-ai-utils/sorter/sorter-ai-utils";
2
+ import type { PerseusDependenciesV2, WidgetProps } from "../../types";
5
3
  import type { PerseusSorterWidgetOptions, PerseusSorterUserInput, SorterPublicWidgetOptions } from "@khanacademy/perseus-core";
6
- type Props = WidgetProps<PerseusSorterWidgetOptions, PerseusSorterUserInput>;
7
- type DefaultProps = {
8
- correct: Props["correct"];
9
- layout: Props["layout"];
10
- padding: Props["padding"];
11
- problemNum: Props["problemNum"];
12
- linterContext: Props["linterContext"];
4
+ type Props = WidgetProps<PerseusSorterWidgetOptions, PerseusSorterUserInput> & {
5
+ dependencies: PerseusDependenciesV2;
13
6
  };
14
- declare class Sorter extends React.Component<Props> implements Widget {
15
- _isMounted: boolean;
16
- static defaultProps: DefaultProps;
17
- componentDidMount(): void;
18
- componentWillUnmount(): void;
19
- handleChange: (arg1: React.ChangeEvent<HTMLInputElement>) => void;
20
- /**
21
- * This is kind of a problem. Sortable maintains an internal state
22
- * but we also want the user input state to include the same state.
23
- * This is to help keep the two in sync for now.
24
- */
25
- _getOptionsFromSortable(): string[];
26
- getPromptJSON(): SorterPromptJSON;
27
- moveOptionToIndex: (option: SortableOption, index: number) => void;
28
- /**
29
- * @deprecated and likely very broken API
30
- * [LEMS-3185] do not trust serializedState
31
- */
32
- getSerializedState(): any;
33
- render(): React.ReactNode;
34
- }
35
7
  declare function getStartUserInput(options: SorterPublicWidgetOptions, problemNum: number): PerseusSorterUserInput;
36
8
  /**
37
9
  * @deprecated and likely a very broken API
@@ -41,7 +13,7 @@ declare function getUserInputFromSerializedState(serializedState: any): PerseusS
41
13
  declare const _default: {
42
14
  name: string;
43
15
  displayName: string;
44
- widget: typeof Sorter;
16
+ widget: React.ForwardRefExoticComponent<Omit<Props, "dependencies"> & React.RefAttributes<any>>;
45
17
  isLintable: true;
46
18
  getStartUserInput: typeof getStartUserInput;
47
19
  getUserInputFromSerializedState: typeof getUserInputFromSerializedState;
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": "72.0.0",
6
+ "version": "72.1.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -41,16 +41,16 @@
41
41
  "mafs": "0.19.0",
42
42
  "tiny-invariant": "1.3.1",
43
43
  "uuid": "^10.0.0",
44
- "@khanacademy/kas": "2.1.3",
45
- "@khanacademy/keypad-context": "3.2.15",
46
- "@khanacademy/kmath": "2.2.15",
47
- "@khanacademy/perseus-core": "20.1.3",
48
- "@khanacademy/math-input": "26.2.17",
49
- "@khanacademy/perseus-linter": "4.4.5",
50
- "@khanacademy/perseus-score": "8.0.4",
51
- "@khanacademy/perseus-utils": "2.1.1",
52
- "@khanacademy/pure-markdown": "2.2.1",
53
- "@khanacademy/simple-markdown": "2.1.1"
44
+ "@khanacademy/kas": "2.1.4",
45
+ "@khanacademy/keypad-context": "3.2.16",
46
+ "@khanacademy/kmath": "2.2.16",
47
+ "@khanacademy/math-input": "26.2.18",
48
+ "@khanacademy/perseus-core": "20.1.4",
49
+ "@khanacademy/perseus-linter": "4.4.6",
50
+ "@khanacademy/perseus-score": "8.0.5",
51
+ "@khanacademy/perseus-utils": "2.1.2",
52
+ "@khanacademy/pure-markdown": "2.2.2",
53
+ "@khanacademy/simple-markdown": "2.1.2"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@khanacademy/wonder-blocks-announcer": "1.0.4",