@khanacademy/perseus-core 0.0.0-PR3092-20251205012045 → 0.0.0-PR3092-20251208220810
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/es/index.js +13 -2
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/extract-perseus-ai-data.d.ts +39 -0
- package/package.json +2 -2
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PerseusItem, PerseusWidgetsMap, PerseusRenderer } from "../data-schema";
|
|
2
|
+
/**
|
|
3
|
+
* This function extracts the answers from the widgets.
|
|
4
|
+
*
|
|
5
|
+
* For each widget type, we first check to make sure the path to the answer exists,
|
|
6
|
+
* then we extract the answer and add it to the list of answers.
|
|
7
|
+
*
|
|
8
|
+
* A list is returned because some widgets, like multi-select radio widgets and groups
|
|
9
|
+
* can have multiple answers.
|
|
10
|
+
*
|
|
11
|
+
* @param {PerseusRenderer["widgets"]} widgets
|
|
12
|
+
* @returns a list of strings that are the answers to the widgets
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAnswersFromWidgets(widgets: PerseusRenderer["widgets"]): ReadonlyArray<string>;
|
|
15
|
+
/**
|
|
16
|
+
* Inject a string equivalent of the widgets into the content.
|
|
17
|
+
*
|
|
18
|
+
* Content may contain Perseus widgets, that looks like this: '[[☃ Radio 1]]'.
|
|
19
|
+
* This function replaces those widgets with its equivalent string.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} content
|
|
22
|
+
* @param {PerseusRenderer["widgets"]} widgets
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function injectWidgets(content: string, widgets: PerseusRenderer["widgets"], widgetProps?: PerseusWidgetsMap): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get AI-ready data from a Perseus item for Khanmigo.
|
|
28
|
+
*
|
|
29
|
+
* This function extracts the correct answers from widgets and injects
|
|
30
|
+
* widget content into hints to provide Khanmigo with the context it needs
|
|
31
|
+
* to help students without requiring React rendering.
|
|
32
|
+
*
|
|
33
|
+
* @param {PerseusItem} perseusItem - The Perseus item containing question and hints
|
|
34
|
+
* @returns Object containing answers and processed hints
|
|
35
|
+
*/
|
|
36
|
+
export declare function getPerseusAIData(perseusItem: PerseusItem): {
|
|
37
|
+
answers: ReadonlyArray<string>;
|
|
38
|
+
hints: ReadonlyArray<string>;
|
|
39
|
+
};
|
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": "0.0.0-PR3092-
|
|
6
|
+
"version": "0.0.0-PR3092-20251208220810",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"tiny-invariant": "1.3.1",
|
|
40
|
-
"@khanacademy/kas": "2.1.6",
|
|
41
40
|
"@khanacademy/perseus-utils": "2.1.4",
|
|
41
|
+
"@khanacademy/kas": "2.1.6",
|
|
42
42
|
"@khanacademy/pure-markdown": "2.2.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|