@khanacademy/perseus 87.2.1 → 87.3.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.
@@ -16,6 +16,7 @@ import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-uti
16
16
  import type { KeypadAPI } from "@khanacademy/math-input";
17
17
  import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
18
18
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
19
+ import type { ASTNode, SingleASTNode } from "@khanacademy/simple-markdown";
19
20
  import "./styles/perseus-renderer.new.css";
20
21
  type WidgetState = {
21
22
  isMobile?: boolean;
@@ -149,9 +150,9 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
149
150
  getContent: (props: Props, state: State) => any;
150
151
  shouldRenderJiptPlaceholder: (props: Props, state: State) => boolean;
151
152
  replaceJiptContent(content: string, paragraphIndex?: number): void;
152
- outputMarkdown: (ast: any, state: WidgetState) => React.ReactElement;
153
- outputNested: (ast: any, state: WidgetState) => React.ReactElement;
154
- outputNode: (node: any, nestedOutput: any, state: WidgetState) => any | null | React.ReactElement<React.ComponentProps<"div">> | React.ReactElement<React.ComponentProps<"span">> | React.ReactNode;
153
+ outputMarkdown: (ast: ASTNode, state: WidgetState) => React.ReactNode;
154
+ outputNested: (ast: ASTNode, state: WidgetState) => React.ReactNode;
155
+ outputNode: (node: SingleASTNode, nestedOutput: (ast: SingleASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactNode;
155
156
  handleRender: (prevProps: Props) => void;
156
157
  _setCurrentFocus: (path: FocusPath) => void;
157
158
  focus: () => boolean | null | undefined;
@@ -16,6 +16,7 @@ import type { GetPromptJSONInterface, RendererPromptJSON } from "./widget-ai-uti
16
16
  import type { KeypadAPI } from "@khanacademy/math-input";
17
17
  import type { PerseusRenderer, PerseusScore, PerseusWidget, PerseusWidgetOptions, PerseusWidgetsMap, ShowSolutions, UserInput, UserInputMap } from "@khanacademy/perseus-core";
18
18
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
19
+ import type { ASTNode, SingleASTNode } from "@khanacademy/simple-markdown";
19
20
  import "./styles/perseus-renderer.css";
20
21
  type WidgetState = {
21
22
  isMobile?: boolean;
@@ -160,9 +161,9 @@ declare class Renderer extends React.Component<Props, State> implements GetPromp
160
161
  getContent: (props: Props, state: State) => any;
161
162
  shouldRenderJiptPlaceholder: (props: Props, state: State) => boolean;
162
163
  replaceJiptContent(content: string, paragraphIndex?: number): void;
163
- outputMarkdown: (ast: any, state: WidgetState) => React.ReactElement;
164
- outputNested: (ast: any, state: WidgetState) => React.ReactElement;
165
- outputNode: (node: any, nestedOutput: any, state: WidgetState) => any | null | React.ReactElement<React.ComponentProps<"div">> | React.ReactElement<React.ComponentProps<"span">> | React.ReactNode;
164
+ outputMarkdown: (ast: ASTNode, state: WidgetState) => React.ReactNode;
165
+ outputNested: (ast: ASTNode, state: WidgetState) => React.ReactNode;
166
+ outputNode: (node: SingleASTNode, nestedOutput: (ast: SingleASTNode, state: WidgetState) => React.ReactNode, state: WidgetState) => React.ReactNode;
166
167
  handleRender: (prevProps: Props) => void;
167
168
  _setCurrentFocus: (path: FocusPath) => void;
168
169
  focus: () => boolean | null | undefined;
@@ -37,8 +37,6 @@ export declare const useItemRenderer: (item: PerseusItem, apiOptions?: APIOption
37
37
  hintProgressColor?: string;
38
38
  flags?: Record<"perseus-renderer-upgrade" | "desmos-calculator" | "article-extras" | "dnd-widget-fitb", boolean>;
39
39
  };
40
- toggleMobile: (isMobile: boolean) => void;
41
- toggleRtl: (isRtl: boolean) => void;
42
40
  updateJson: (json: string) => boolean;
43
41
  handleReset: () => void;
44
42
  handleSkip: () => void;
@@ -1,7 +1,5 @@
1
1
  import type { PerseusItem, ShowSolutions, PerseusScore, UserInputMap } from "@khanacademy/perseus-core";
2
2
  export type ItemRendererState = {
3
- isMobile: boolean;
4
- isRtl: boolean;
5
3
  perseusItem: PerseusItem;
6
4
  originalItem: PerseusItem;
7
5
  answerless: boolean;
@@ -14,12 +12,6 @@ export type ItemRendererState = {
14
12
  reviewMode: boolean;
15
13
  };
16
14
  export type ItemRendererAction = {
17
- type: "TOGGLE_MOBILE";
18
- payload: boolean;
19
- } | {
20
- type: "TOGGLE_RTL";
21
- payload: boolean;
22
- } | {
23
15
  type: "UPDATE_ITEM";
24
16
  payload: PerseusItem;
25
17
  } | {
@@ -43,5 +35,5 @@ export type ItemRendererAction = {
43
35
  } | {
44
36
  type: "SKIP_TO_SOLUTION";
45
37
  };
46
- export declare const createInitialState: (item: PerseusItem, isMobile?: boolean, isRtl?: boolean, reviewMode?: boolean, showSolutions?: ShowSolutions) => ItemRendererState;
38
+ export declare const createInitialState: (item: PerseusItem, reviewMode?: boolean, showSolutions?: ShowSolutions) => ItemRendererState;
47
39
  export declare const itemRendererReducer: (state: ItemRendererState, action: ItemRendererAction) => ItemRendererState;
@@ -3,7 +3,6 @@ import type { APIOptions } from "../types";
3
3
  import type { PerseusItem, ShowSolutions } from "@khanacademy/perseus-core";
4
4
  import type { LinterContextProps } from "@khanacademy/perseus-linter";
5
5
  type Props = {
6
- title?: string;
7
6
  item: PerseusItem;
8
7
  apiOptions?: APIOptions;
9
8
  linterContext?: LinterContextProps;
@@ -13,5 +12,5 @@ type Props = {
13
12
  /**
14
13
  * ServerItemRendererWithDebugUI is a component that renders a Perseus item with debug UI controls
15
14
  */
16
- export declare const ServerItemRendererWithDebugUI: ({ title, item, apiOptions, linterContext, reviewMode, showSolutions, }: Props) => React.ReactElement;
15
+ export declare const ServerItemRendererWithDebugUI: ({ item, apiOptions, linterContext, reviewMode, showSolutions, }: Props) => React.ReactElement;
17
16
  export {};
@@ -0,0 +1,7 @@
1
+ import * as React from "react";
2
+ type StorybookViewOptions = {
3
+ isMobile: boolean | undefined;
4
+ isRtl: boolean;
5
+ };
6
+ export declare const StorybookViewOptionsContext: React.Context<StorybookViewOptions>;
7
+ export {};
package/dist/util.d.ts CHANGED
@@ -42,6 +42,11 @@ declare function inputPathsEqual(a?: ReadonlyArray<string> | null, b?: ReadonlyA
42
42
  * No additional processing is done on the sibling nodes.
43
43
  */
44
44
  export declare const noParagraphForInlineWidget: (node: SingleASTNode) => boolean;
45
+ /**
46
+ * Combines adjacent text nodes in an ASTNode array into a single text node.
47
+ * Does not recurse.
48
+ */
49
+ declare function joinAdjacentTextNodes(ast: ASTNode): ASTNode;
45
50
  /**
46
51
  * Handle situations in the markdown where a block-level widget doesn't have the
47
52
  * expected double-newline characters in place. The blockRegex function in
@@ -218,5 +223,6 @@ declare const Util: {
218
223
  readonly moveCursor: typeof moveCursor;
219
224
  };
220
225
  readonly unescapeMathMode: (label: string) => string;
226
+ readonly joinAdjacentTextNodes: typeof joinAdjacentTextNodes;
221
227
  };
222
228
  export default Util;
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": "87.2.1",
6
+ "version": "87.3.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -46,12 +46,12 @@
46
46
  "tiny-invariant": "1.3.1",
47
47
  "uuid": "^10.0.0",
48
48
  "@khanacademy/kas": "2.2.6",
49
- "@khanacademy/keypad-context": "3.2.93",
50
- "@khanacademy/kmath": "2.4.52",
51
- "@khanacademy/math-input": "27.0.17",
52
- "@khanacademy/perseus-core": "39.2.1",
53
- "@khanacademy/perseus-linter": "5.4.2",
54
- "@khanacademy/perseus-score": "8.12.25",
49
+ "@khanacademy/keypad-context": "4.0.1",
50
+ "@khanacademy/kmath": "2.4.54",
51
+ "@khanacademy/math-input": "28.0.1",
52
+ "@khanacademy/perseus-core": "39.2.3",
53
+ "@khanacademy/perseus-linter": "5.4.4",
54
+ "@khanacademy/perseus-score": "8.13.0",
55
55
  "@khanacademy/perseus-utils": "2.1.5",
56
56
  "@khanacademy/pure-markdown": "2.3.2",
57
57
  "@khanacademy/simple-markdown": "3.0.1"
@@ -1,13 +0,0 @@
1
- import * as React from "react";
2
- type DebugHeaderProps = {
3
- title: string;
4
- isMobile: boolean;
5
- isRtl: boolean;
6
- onToggleMobile: (isMobile: boolean) => void;
7
- onToggleRtl: (isRtl: boolean) => void;
8
- };
9
- /**
10
- * A component that renders the header for the debug UI
11
- */
12
- export declare const DebugHeader: ({ title, isMobile, isRtl, onToggleMobile, onToggleRtl, }: DebugHeaderProps) => React.ReactElement;
13
- export {};