@khanacademy/perseus-core 3.7.0 → 5.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.
- package/LICENSE +18 -0
- package/dist/data-schema.d.ts +18 -4
- package/dist/es/index.js +483 -2243
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +8 -3
- package/dist/index.js +519 -2230
- package/dist/index.js.map +1 -1
- package/dist/keypad.d.ts +12 -0
- package/dist/parse-perseus-json/perseus-parsers/interactive-graph-widget.d.ts +1 -0
- package/dist/types.d.ts +0 -3
- package/dist/widgets/dropdown/dropdown-util.d.ts +1 -1
- package/dist/widgets/expression/derive-extra-keys.d.ts +8 -0
- package/dist/widgets/expression/expression-upgrade.d.ts +1 -0
- package/dist/widgets/expression/expression-util.d.ts +2 -1
- package/dist/widgets/interactive-graph/interactive-graph-util.d.ts +1 -2
- package/dist/widgets/numeric-input/numeric-input-util.d.ts +3 -2
- package/dist/widgets/radio/radio-upgrade.d.ts +2 -0
- package/dist/widgets/radio/radio-util.d.ts +10 -0
- package/package.json +35 -32
- /package/dist/{utils → shared-utils}/add-library-version-to-perseus-debug.d.ts +0 -0
package/dist/keypad.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const KeypadKeys: readonly ["PLUS", "MINUS", "NEGATIVE", "TIMES", "DIVIDE", "DECIMAL", "PERIOD", "PERCENT", "CDOT", "EQUAL", "NEQ", "GT", "LT", "GEQ", "LEQ", "FRAC_INCLUSIVE", "FRAC_EXCLUSIVE", "FRAC", "EXP", "EXP_2", "EXP_3", "SQRT", "CUBE_ROOT", "RADICAL", "LEFT_PAREN", "RIGHT_PAREN", "LN", "LOG", "LOG_N", "SIN", "COS", "TAN", "PI", "THETA", "UP", "RIGHT", "DOWN", "LEFT", "BACKSPACE", "DISMISS", "JUMP_OUT_PARENTHESES", "JUMP_OUT_EXPONENT", "JUMP_OUT_BASE", "JUMP_INTO_NUMERATOR", "JUMP_OUT_NUMERATOR", "JUMP_OUT_DENOMINATOR", "NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4", "NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
|
|
2
|
+
export type KeypadKey = (typeof KeypadKeys)[number];
|
|
3
|
+
export type KeypadType = "FRACTION" | "EXPRESSION";
|
|
4
|
+
export type KeypadConfiguration = {
|
|
5
|
+
keypadType: KeypadType;
|
|
6
|
+
extraKeys?: ReadonlyArray<KeypadKey>;
|
|
7
|
+
times?: boolean;
|
|
8
|
+
scientific?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface KeypadContextRendererInterface {
|
|
11
|
+
blur(): void;
|
|
12
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PerseusDropdownWidgetOptions } from "@khanacademy/perseus-core";
|
|
|
3
3
|
* For details on the individual options, see the
|
|
4
4
|
* PerseusDropdownWidgetOptions type
|
|
5
5
|
*/
|
|
6
|
-
type DropdownPublicWidgetOptions = {
|
|
6
|
+
export type DropdownPublicWidgetOptions = {
|
|
7
7
|
choices: ReadonlyArray<{
|
|
8
8
|
content: string;
|
|
9
9
|
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type KeypadConfiguration } from "../../keypad";
|
|
2
|
+
import type { PerseusExpressionWidgetOptions } from "../../data-schema";
|
|
3
|
+
/**
|
|
4
|
+
* Scrape the answer forms for any variables or contants (like Pi)
|
|
5
|
+
* that need to be included as keys on the keypad.
|
|
6
|
+
*/
|
|
7
|
+
declare function deriveExtraKeys(widgetOptions: PerseusExpressionWidgetOptions): KeypadConfiguration["extraKeys"];
|
|
8
|
+
export default deriveExtraKeys;
|
|
@@ -4,6 +4,7 @@ export declare const currentVersion: {
|
|
|
4
4
|
minor: number;
|
|
5
5
|
};
|
|
6
6
|
export declare const widgetOptionsUpgrades: {
|
|
7
|
+
readonly "2": (v1options: any) => PerseusExpressionWidgetOptions;
|
|
7
8
|
readonly "1": (v0options: any) => PerseusExpressionWidgetOptions;
|
|
8
9
|
};
|
|
9
10
|
export type ExpressionDefaultWidgetOptions = Pick<PerseusExpressionWidgetOptions, "answerForms" | "times" | "buttonSets" | "functions">;
|
|
@@ -3,13 +3,14 @@ import type { PerseusExpressionWidgetOptions } from "@khanacademy/perseus-core";
|
|
|
3
3
|
* For details on the individual options, see the
|
|
4
4
|
* PerseusExpressionWidgetOptions type
|
|
5
5
|
*/
|
|
6
|
-
type ExpressionPublicWidgetOptions = {
|
|
6
|
+
export type ExpressionPublicWidgetOptions = {
|
|
7
7
|
buttonSets: PerseusExpressionWidgetOptions["buttonSets"];
|
|
8
8
|
functions: PerseusExpressionWidgetOptions["functions"];
|
|
9
9
|
times: PerseusExpressionWidgetOptions["times"];
|
|
10
10
|
visibleLabel?: PerseusExpressionWidgetOptions["visibleLabel"];
|
|
11
11
|
ariaLabel?: PerseusExpressionWidgetOptions["ariaLabel"];
|
|
12
12
|
buttonsVisible?: PerseusExpressionWidgetOptions["buttonsVisible"];
|
|
13
|
+
extraKeys?: PerseusExpressionWidgetOptions["extraKeys"];
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Given a PerseusExpressionWidgetOptions object, return a new object with only
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
-
type InteractiveGraphPublicWidgetOptions = Pick<PerseusInteractiveGraphWidgetOptions, "step" | "gridStep" | "snapStep" | "backgroundImage" | "markings" | "labels" | "showProtractor" | "showRuler" | "showTooltips" | "rulerLabel" | "rulerTicks" | "range" | "graph" | "lockedFigures" | "fullGraphAriaLabel" | "fullGraphAriaDescription">;
|
|
2
|
+
export type InteractiveGraphPublicWidgetOptions = Pick<PerseusInteractiveGraphWidgetOptions, "step" | "gridStep" | "snapStep" | "backgroundImage" | "markings" | "labels" | "showProtractor" | "showRuler" | "showTooltips" | "rulerLabel" | "rulerTicks" | "range" | "graph" | "lockedFigures" | "fullGraphAriaLabel" | "fullGraphAriaDescription">;
|
|
3
3
|
export default function getInteractiveGraphPublicWidgetOptions(options: PerseusInteractiveGraphWidgetOptions): InteractiveGraphPublicWidgetOptions;
|
|
4
|
-
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { PerseusNumericInputWidgetOptions } from "@khanacademy/perseus-core";
|
|
1
|
+
import type { PerseusNumericInputAnswer, PerseusNumericInputWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
type NumericInputAnswerPublicData = Pick<PerseusNumericInputAnswer, "answerForms" | "simplify" | "status">;
|
|
2
3
|
/**
|
|
3
4
|
* For details on the individual options, see the
|
|
4
5
|
* PerseusNumericInputWidgetOptions type
|
|
@@ -9,7 +10,7 @@ type NumericInputPublicWidgetOptions = {
|
|
|
9
10
|
coefficient: PerseusNumericInputWidgetOptions["coefficient"];
|
|
10
11
|
rightAlign?: PerseusNumericInputWidgetOptions["rightAlign"];
|
|
11
12
|
static: PerseusNumericInputWidgetOptions["static"];
|
|
12
|
-
|
|
13
|
+
answers: ReadonlyArray<NumericInputAnswerPublicData>;
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
16
|
* Given a PerseusNumericInputWidgetOptions object, return a new object with only
|
|
@@ -3,7 +3,9 @@ export declare const currentVersion: {
|
|
|
3
3
|
major: number;
|
|
4
4
|
minor: number;
|
|
5
5
|
};
|
|
6
|
+
export declare function deriveNumCorrect(options: PerseusRadioWidgetOptions): number;
|
|
6
7
|
export declare const widgetOptionsUpgrades: {
|
|
8
|
+
readonly "2": (v1props: any) => PerseusRadioWidgetOptions;
|
|
7
9
|
readonly "1": (v0props: any) => PerseusRadioWidgetOptions;
|
|
8
10
|
};
|
|
9
11
|
export type RadioDefaultWidgetOptions = Pick<PerseusRadioWidgetOptions, "choices" | "displayCount" | "randomize" | "hasNoneOfTheAbove" | "multipleSelect" | "countChoices" | "deselectEnabled">;
|
|
@@ -7,6 +7,7 @@ type RadioPublicWidgetOptions = {
|
|
|
7
7
|
choices: ReadonlyArray<RadioChoicePublicData>;
|
|
8
8
|
hasNoneOfTheAbove?: PerseusRadioWidgetOptions["hasNoneOfTheAbove"];
|
|
9
9
|
countChoices?: PerseusRadioWidgetOptions["countChoices"];
|
|
10
|
+
numCorrect?: PerseusRadioWidgetOptions["numCorrect"];
|
|
10
11
|
randomize?: PerseusRadioWidgetOptions["randomize"];
|
|
11
12
|
multipleSelect?: PerseusRadioWidgetOptions["multipleSelect"];
|
|
12
13
|
deselectEnabled?: PerseusRadioWidgetOptions["deselectEnabled"];
|
|
@@ -18,6 +19,15 @@ type RadioPublicWidgetOptions = {
|
|
|
18
19
|
* Only the options from each Radio choice that should be exposed to the client.
|
|
19
20
|
*/
|
|
20
21
|
type RadioChoicePublicData = Pick<PerseusRadioChoice, "content" | "isNoneOfTheAbove" | "widgets">;
|
|
22
|
+
/**
|
|
23
|
+
* Shared functionality to determine if numCorrect is used, because:
|
|
24
|
+
*
|
|
25
|
+
* 1. numCorrect is conditionally used for rendering pre-scoring
|
|
26
|
+
* 2. numCorrect also exposes information about answers
|
|
27
|
+
*
|
|
28
|
+
* So only include/use numCorrect when we know it's useful.
|
|
29
|
+
*/
|
|
30
|
+
export declare function usesNumCorrect(multipleSelect: PerseusRadioWidgetOptions["multipleSelect"], countChoices: PerseusRadioWidgetOptions["countChoices"], numCorrect: PerseusRadioWidgetOptions["numCorrect"]): number | false | undefined;
|
|
21
31
|
/**
|
|
22
32
|
* Given a PerseusRadioWidgetOptions object, return a new object with only
|
|
23
33
|
* the public options that should be exposed to the client.
|
package/package.json
CHANGED
|
@@ -1,34 +1,37 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"
|
|
2
|
+
"name": "@khanacademy/perseus-core",
|
|
3
|
+
"description": "Shared Perseus infrastructure",
|
|
4
|
+
"author": "Khan Academy",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"version": "5.0.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Khan/perseus.git",
|
|
13
|
+
"directory": "packages/perseus-core"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/Khan/perseus/issues"
|
|
17
|
+
},
|
|
18
|
+
"module": "dist/es/index.js",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"source": "src/index.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@khanacademy/kas": "0.5.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@khanacademy/wonder-stuff-core": "1.5.4",
|
|
29
|
+
"underscore": "^1.4.4"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@khanacademy/wonder-stuff-core": "1.5.4",
|
|
33
|
+
"underscore": "^1.4.4"
|
|
34
|
+
},
|
|
35
|
+
"keywords": [],
|
|
36
|
+
"scripts": {}
|
|
34
37
|
}
|
|
File without changes
|