@khanacademy/perseus-core 13.0.0 → 14.0.1
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/accessibility.d.ts +26 -0
- package/dist/es/index.js +48 -37
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +56 -36
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/expression-widget.d.ts +1 -1
- package/dist/parse-perseus-json/perseus-parsers/group-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/group-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/user-input-map.d.ts +17 -0
- package/dist/parse-perseus-json/perseus-parsers/widget-id-components.d.ts +27 -0
- package/dist/traversal.d.ts +16 -0
- package/dist/utils/util.graphie.d.ts +6 -0
- package/dist/validation.types.d.ts +1 -0
- package/dist/widgets/core-widget-registry.d.ts +5 -1
- package/dist/widgets/logic-export.types.d.ts +3 -1
- package/package.json +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const parseExpressionWidget: import("../parser-types").Parser<import("../..").WidgetOptions<"expression", import("../general-purpose-parsers/object-types").OptionalizeProperties<{
|
|
2
2
|
answerForms: {
|
|
3
3
|
value: string;
|
|
4
|
-
form: boolean;
|
|
5
4
|
simplify: boolean;
|
|
5
|
+
form: boolean;
|
|
6
6
|
considered: "correct" | "wrong" | "ungraded";
|
|
7
7
|
key?: string | undefined;
|
|
8
8
|
}[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UserInputMap } from "../../validation.types";
|
|
2
|
+
import type { Parser } from "../parser-types";
|
|
3
|
+
/**
|
|
4
|
+
* Parses a UserInputMap, which is a map of widget IDs to their corresponding user input data.
|
|
5
|
+
*
|
|
6
|
+
* A UserInputMap maps widget IDs (like "radio 1", "dropdown 2") to the user input data
|
|
7
|
+
* for each widget. This is used by Group widgets and other contexts where multiple
|
|
8
|
+
* widgets need to be tracked together.
|
|
9
|
+
*
|
|
10
|
+
* The parser handles recursive structures since Group widgets can contain other Group
|
|
11
|
+
* widgets, each with their own UserInputMap.
|
|
12
|
+
*
|
|
13
|
+
* @param rawValue - The raw value to parse, expected to be a plain object
|
|
14
|
+
* @param ctx - The parse context for error reporting and tracking
|
|
15
|
+
* @returns A ParseResult containing either the parsed UserInputMap or an error
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseUserInputMap: Parser<UserInputMap>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Parser } from "../parser-types";
|
|
2
|
+
/**
|
|
3
|
+
* Parses a string representation of a non-negative integer.
|
|
4
|
+
*
|
|
5
|
+
* This parser is used for the numeric part of widget IDs (e.g., the "1" in "radio 1").
|
|
6
|
+
* It accepts string representations of non-negative integers, including "0".
|
|
7
|
+
*
|
|
8
|
+
* Note: The article renderer allows widget IDs with 0 (at least for image widgets),
|
|
9
|
+
* but if widget IDs in an exercise contain 0, the exercise renderer may have issues.
|
|
10
|
+
* We allow 0 here for compatibility with articles.
|
|
11
|
+
*
|
|
12
|
+
* @param rawValue - The raw value to parse, expected to be a string
|
|
13
|
+
* @param ctx - The parse context for error reporting
|
|
14
|
+
* @returns A ParseResult containing either the parsed number or an error
|
|
15
|
+
*/
|
|
16
|
+
export declare const parseStringToNonNegativeInt: Parser<number>;
|
|
17
|
+
/**
|
|
18
|
+
* Parses widget ID components into a [type, number] tuple.
|
|
19
|
+
*
|
|
20
|
+
* Widget IDs in Perseus follow the format "{type} {number}" (e.g., "radio 1", "dropdown 2").
|
|
21
|
+
* This parser takes the components of a widget ID (after splitting on spaces) and
|
|
22
|
+
* validates that it consists of exactly two parts: a widget type string and a
|
|
23
|
+
* non-negative integer.
|
|
24
|
+
*
|
|
25
|
+
* @type {Parser<[string, number]>} A parser that returns a tuple of [widgetType, widgetNumber]
|
|
26
|
+
*/
|
|
27
|
+
export declare const parseWidgetIdComponents: Parser<[string, number]>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Traverses a {content, widgets, images} renderer props object,
|
|
3
|
+
* such as `itemData.question`
|
|
4
|
+
*
|
|
5
|
+
* This traversal is deep and handles some widget prop upgrades
|
|
6
|
+
* (TODO(aria): Handle minor prop upgrades :) )
|
|
7
|
+
*
|
|
8
|
+
* This is the right way to traverse itemData.
|
|
9
|
+
*
|
|
10
|
+
* NOTE: We should not expose this on the perseus API yet. Instead,
|
|
11
|
+
* build the traversal method you want inside perseus, and use this
|
|
12
|
+
* from that. We might eventually expose this, but I'd like to be
|
|
13
|
+
* more confident in the interface provided first.
|
|
14
|
+
*/
|
|
15
|
+
import type { PerseusRenderer } from "./data-schema";
|
|
16
|
+
export declare const traverse: (rendererOptions: PerseusRenderer, contentCallback?: ((arg1: any) => any) | null, widgetCallback?: ((widgetInfo: any, widgetId: string) => any) | null, optionsCallback?: (arg1: any) => void) => any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function getRealImageUrl(graphieUrl: string): string;
|
|
2
|
+
export declare function isLabeledSVG(graphieUrl: string): boolean;
|
|
3
|
+
export declare function getBaseUrl(graphieUrl: string): string;
|
|
4
|
+
export declare function getSvgUrl(graphieUrl: string): string;
|
|
5
|
+
export declare function getDataUrl(graphieUrl: string): string;
|
|
6
|
+
export declare function getImageSizeModern(url: string): Promise<[number, number]>;
|
|
@@ -168,6 +168,7 @@ export type PerseusPlotterValidationData = {
|
|
|
168
168
|
export type PerseusPlotterUserInput = number[];
|
|
169
169
|
export type PerseusRadioRubric = {
|
|
170
170
|
choices: PerseusRadioChoice[];
|
|
171
|
+
countChoices?: boolean;
|
|
171
172
|
};
|
|
172
173
|
export type PerseusRadioUserInput = {
|
|
173
174
|
choicesSelected: boolean[];
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type { PublicWidgetOptionsFunction } from "./logic-export.types";
|
|
1
|
+
import type { PublicWidgetOptionsFunction, WidgetLogic } from "./logic-export.types";
|
|
2
|
+
import type { PerseusWidgetOptions, PerseusWidget } from "../data-schema";
|
|
2
3
|
import type { Alignment } from "../types";
|
|
4
|
+
export declare function registerWidget(type: string, logic: WidgetLogic): void;
|
|
3
5
|
export declare function isWidgetRegistered(type: string): boolean;
|
|
4
6
|
export declare function getCurrentVersion(type: string): import("..").Version;
|
|
5
7
|
export declare const getPublicWidgetOptionsFunction: (type: string) => PublicWidgetOptionsFunction;
|
|
6
8
|
export declare function getDefaultWidgetOptions(type: string): any;
|
|
9
|
+
export declare function isAccessible(type: string, widgetOptions: PerseusWidgetOptions): boolean;
|
|
10
|
+
export declare const traverseChildWidgets: (widgetInfo: PerseusWidget, traverseRenderer: any) => PerseusWidget;
|
|
7
11
|
/**
|
|
8
12
|
* Handling for the optional alignments for widgets
|
|
9
13
|
* See widget-container.jsx for details on how alignments are implemented.
|
|
@@ -18,7 +18,7 @@ import type getPlotterPublicWidgetOptions from "./plotter/plotter-util";
|
|
|
18
18
|
import type getRadioPublicWidgetOptions from "./radio/radio-util";
|
|
19
19
|
import type getSorterPublicWidgetOptions from "./sorter/sorter-util";
|
|
20
20
|
import type getTablePublicWidgetOptions from "./table/table-util";
|
|
21
|
-
import type { Version } from "../data-schema";
|
|
21
|
+
import type { PerseusWidgetOptions, Version } from "../data-schema";
|
|
22
22
|
import type { Alignment } from "../types";
|
|
23
23
|
export type WidgetOptionsUpgradeMap = {
|
|
24
24
|
[targetMajorVersion: string]: (arg1: any) => any;
|
|
@@ -36,6 +36,8 @@ export type WidgetLogic = {
|
|
|
36
36
|
defaultWidgetOptions?: any;
|
|
37
37
|
supportedAlignments?: ReadonlyArray<Alignment>;
|
|
38
38
|
defaultAlignment?: Alignment;
|
|
39
|
+
accessible?: boolean | ((options: PerseusWidgetOptions) => boolean);
|
|
40
|
+
traverseChildWidgets?: (props: any, traverseRenderer: any) => any;
|
|
39
41
|
/**
|
|
40
42
|
* A function that provides a public version of the widget options that can
|
|
41
43
|
* be shared with the client.
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Shared Perseus infrastructure",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "14.0.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"tiny-invariant": "1.3.1",
|
|
26
|
-
"@khanacademy/kas": "2.0.
|
|
26
|
+
"@khanacademy/kas": "2.0.6",
|
|
27
27
|
"@khanacademy/perseus-utils": "2.0.4"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@khanacademy/wonder-stuff-core": "1.5.4",
|
|
31
31
|
"underscore": "1.4.4",
|
|
32
|
-
"perseus-build-settings": "0.
|
|
32
|
+
"perseus-build-settings": "0.7.0"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@khanacademy/wonder-stuff-core": "^1.5.4",
|