@khanacademy/perseus 88.0.0 → 89.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.
@@ -14,7 +14,7 @@ import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FindWidgetsFu
14
14
  import type { HandleUserInputCallback, InitializeUserInputCallback } from "./user-input-manager";
15
15
  import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
16
16
  import type { KeypadAPI } from "@khanacademy/math-input";
17
- import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
17
+ import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, RendererInterface, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
18
18
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
19
19
  import type { ASTNode, SingleASTNode } from "@khanacademy/simple-markdown";
20
20
  import "./styles/perseus-renderer.new.css";
@@ -64,7 +64,7 @@ type State = {
64
64
  jiptContent: string | null;
65
65
  };
66
66
  type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExternalWidgets" | "images" | "linterContext" | "onRender" | "showSolutions" | "reviewMode" | "widgets">>;
67
- declare class Renderer extends React.Component<Props, State> implements GetPromptJSONInterface {
67
+ declare class Renderer extends React.Component<Props, State> implements RendererInterface, GetPromptJSONInterface {
68
68
  static contextType: React.Context<import("./components/i18n-context").I18nContextType>;
69
69
  context: React.ContextType<typeof PerseusI18nContext>;
70
70
  _currentFocus: FocusPath | null | undefined;
@@ -14,7 +14,7 @@ import type { APIOptions, APIOptionsWithDefaults, FilterCriterion, FindWidgetsFu
14
14
  import type { HandleUserInputCallback, InitializeUserInputCallback } from "./user-input-manager";
15
15
  import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
16
16
  import type { KeypadAPI } from "@khanacademy/math-input";
17
- import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
17
+ import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, RendererInterface, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
18
18
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
19
19
  import type { ASTNode, SingleASTNode } from "@khanacademy/simple-markdown";
20
20
  import "./styles/perseus-renderer.css";
@@ -75,7 +75,7 @@ type DefaultProps = Required<Pick<Props, "alwaysUpdate" | "content" | "findExter
75
75
  */
76
76
  export type DifferentQuestionPartialProps = Pick<Props, "content" | "widgets" | "problemNum">;
77
77
  export declare function isDifferentQuestion(propsA: DifferentQuestionPartialProps, propsB: DifferentQuestionPartialProps): boolean;
78
- declare class Renderer extends React.Component<Props, State> implements GetPromptJSONInterface {
78
+ declare class Renderer extends React.Component<Props, State> implements RendererInterface, GetPromptJSONInterface {
79
79
  static contextType: React.Context<import("./components/i18n-context").I18nContextType>;
80
80
  context: React.ContextType<typeof PerseusI18nContext>;
81
81
  _currentFocus: FocusPath | null | undefined;
@@ -8,10 +8,9 @@ import * as PerseusLinter from "@khanacademy/perseus-linter";
8
8
  * This component is compatible with server-rendering of a perseus exercise.
9
9
  */
10
10
  import * as React from "react";
11
- import { PerseusI18nContext } from "./components/i18n-context";
12
11
  import Renderer from "./renderer";
13
12
  import type { FocusPath, PerseusDependenciesV2, SharedRendererProps } from "./types";
14
- import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-utils/prompt-types";
13
+ import type { GetPromptJSONInterface } from "./widget-ai-utils/prompt-types";
15
14
  import type { KeypadAPI } from "@khanacademy/math-input";
16
15
  import type { PerseusItem, ShowSolutions, KeypadContextRendererInterface, RendererInterface, UserInputMap } from "@khanacademy/perseus-core";
17
16
  type OwnProps = {
@@ -26,8 +25,6 @@ type OwnProps = {
26
25
  type HOCProps = {
27
26
  onRendered: (isRendered: boolean) => void;
28
27
  };
29
- type Props = SharedRendererProps & OwnProps & HOCProps;
30
- type DefaultProps = Required<Pick<Props, "apiOptions" | "onRendered" | "linterContext">>;
31
28
  /**
32
29
  * @deprecated and likely a very broken API
33
30
  * [LEMS-3185] do not trust serializedState
@@ -36,69 +33,19 @@ type SerializedState = {
36
33
  question: any;
37
34
  hints: any;
38
35
  };
39
- export declare class ServerItemRenderer extends React.Component<Props> implements RendererInterface, KeypadContextRendererInterface, GetPromptJSONInterface {
40
- static contextType: React.Context<import("./components/i18n-context").I18nContextType>;
41
- context: React.ContextType<typeof PerseusI18nContext>;
42
- questionRenderer: Renderer;
43
- hintsRenderer: any;
44
- _currentFocus: FocusPath;
45
- _fullyRendered: boolean;
46
- /**
47
- * Tracks whether each asset rendered below us (images, math, anything else
48
- * that takes extra passes to settle) has finished rendering.
49
- *
50
- * This is deliberately not React state: assets register themselves in
51
- * their constructors, while we're still rendering, and a state update
52
- * from there isn't visible to us until a later render pass — by which point we'd
53
- * already have called `onRendered()` under the assumption
54
- * there were no assets to wait for.
55
- */
56
- _assetStatuses: {
57
- [assetKey: string]: boolean;
58
- };
59
- blurTimeoutID: number | null | undefined;
60
- userInput: UserInputMap;
61
- static defaultProps: DefaultProps;
62
- constructor(props: Props);
63
- componentDidMount(): void;
64
- componentWillUnmount(): void;
65
- /**
66
- * Reports that we've finished rendering, if every asset has settled.
67
- *
68
- * Called once we've mounted (to cover content with no assets at all) and
69
- * again on every status change, so it doesn't depend on a render pass
70
- * happening at the right moment. Only ever reports once.
71
- */
72
- maybeCallOnRendered(): void;
73
- _handleFocusChange: (newFocus: FocusPath, oldFocus: FocusPath) => void;
74
- _setCurrentFocus(newFocus: FocusPath): void;
75
- _onRendererBlur(blurPath: FocusPath): void;
76
- focusPath(path: FocusPath): void;
77
- blurPath(path: FocusPath): void;
78
- getDOMNodeForPath(path: FocusPath): Element | Text | null | undefined;
79
- getInputPaths(): ReadonlyArray<FocusPath>;
80
- focus(): boolean | null | undefined;
81
- blur(): void;
82
- getNumHints(): number;
83
- getPromptJSON(): RendererPromptJSON;
84
- /**
85
- * Returns an object of the widget `.getUserInput()` results
86
- */
36
+ export interface ServerItemRendererHandle extends RendererInterface, KeypadContextRendererInterface, GetPromptJSONInterface {
87
37
  getUserInput(): UserInputMap;
88
- /**
89
- * Returns an array of all widget IDs in the order they occur in
90
- * the question content.
91
- */
92
38
  getWidgetIds(): ReadonlyArray<string>;
93
39
  /**
94
- * Get a representation of the current state of the item.
40
+ * @deprecated and likely very broken API
41
+ * [LEMS-3185] do not trust serializedState
95
42
  */
43
+ getSerializedState(): SerializedState;
96
44
  /**
97
- * @deprecated - do not use in new code.
45
+ * @deprecated do not reach into inner
46
+ * class component properties
98
47
  */
99
- getSerializedState(): SerializedState;
100
- setAssetStatus: (assetKey: string, status: boolean) => void;
101
- render(): React.ReactNode;
48
+ readonly questionRenderer: Renderer;
102
49
  }
103
50
  declare const _default: React.ForwardRefExoticComponent<Omit<Pick<SharedRendererProps & OwnProps & HOCProps, keyof OwnProps> & {
104
51
  apiOptions?: Readonly<{
@@ -133,5 +80,5 @@ declare const _default: React.ForwardRefExoticComponent<Omit<Pick<SharedRenderer
133
80
  }> | undefined;
134
81
  linterContext?: PerseusLinter.LinterContextProps | undefined;
135
82
  onRendered?: ((isRendered: boolean) => void) | undefined;
136
- } & {}, "onRendered"> & React.RefAttributes<ServerItemRenderer>>;
83
+ } & {}, "onRendered"> & React.RefAttributes<ServerItemRendererHandle>>;
137
84
  export default _default;
@@ -1,12 +1,12 @@
1
1
  import * as React from "react";
2
- import type { ServerItemRenderer } from "../server-item-renderer";
2
+ import type { ServerItemRendererHandle } from "../server-item-renderer";
3
3
  import type { APIOptions } from "../types";
4
4
  import type { PerseusItem, ShowSolutions } from "@khanacademy/perseus-core";
5
5
  /**
6
6
  * Custom hook to manage the Server Item Renderer With Debug UI state
7
7
  */
8
8
  export declare const useItemRenderer: (item: PerseusItem, apiOptions?: APIOptions, reviewMode?: boolean, showSolutions?: ShowSolutions) => {
9
- ref: React.RefObject<ServerItemRenderer>;
9
+ ref: React.RefObject<ServerItemRendererHandle>;
10
10
  state: import("./item-renderer-reducer").ItemRendererState;
11
11
  options: {
12
12
  isMobile: boolean;
package/dist/testing.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a7 as registerAllWidgetsForTesting } from './chunk-register-all-widgets-for-testing-BNeHl_tg.js';
1
+ import { a7 as registerAllWidgetsForTesting } from './chunk-register-all-widgets-for-testing-CIrzECVC.js';
2
2
  import 'react';
3
3
  import '@khanacademy/keypad-context';
4
4
  import '@khanacademy/math-input';
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": "88.0.0",
6
+ "version": "89.0.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -35,12 +35,12 @@
35
35
  "tiny-invariant": "1.3.1",
36
36
  "uuid": "^10.0.0",
37
37
  "@khanacademy/kas": "3.0.0",
38
- "@khanacademy/keypad-context": "5.0.0",
39
- "@khanacademy/kmath": "3.0.0",
40
- "@khanacademy/math-input": "29.0.0",
41
- "@khanacademy/perseus-core": "40.0.0",
42
- "@khanacademy/perseus-linter": "6.0.0",
43
- "@khanacademy/perseus-score": "9.0.0",
38
+ "@khanacademy/keypad-context": "6.0.0",
39
+ "@khanacademy/kmath": "3.0.1",
40
+ "@khanacademy/math-input": "30.0.0",
41
+ "@khanacademy/perseus-core": "40.0.1",
42
+ "@khanacademy/perseus-linter": "6.0.1",
43
+ "@khanacademy/perseus-score": "9.0.1",
44
44
  "@khanacademy/perseus-utils": "3.0.0",
45
45
  "@khanacademy/pure-markdown": "3.0.0",
46
46
  "@khanacademy/simple-markdown": "4.0.0"