@khanacademy/perseus-core 0.0.0-PR3089-20251204205743 → 0.0.0-PR3089-20251210151846

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.
@@ -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
+ };
@@ -0,0 +1,3 @@
1
+ import type { DefinitionWidget, PerseusDefinitionWidgetOptions } from "../../data-schema";
2
+ export declare function generateDefinitionOptions(options?: Partial<PerseusDefinitionWidgetOptions>): PerseusDefinitionWidgetOptions;
3
+ export declare function generateDefinitionWidget(definitionWidgetProperties?: Partial<Omit<DefinitionWidget, "type">>): DefinitionWidget;
@@ -0,0 +1,3 @@
1
+ import type { DropdownWidget, PerseusDropdownWidgetOptions } from "../../data-schema";
2
+ export declare function generateDropdownOptions(options?: Partial<PerseusDropdownWidgetOptions>): PerseusDropdownWidgetOptions;
3
+ export declare function generateDropdownWidget(dropdownWidgetProperties?: Partial<Omit<DropdownWidget, "type">>): DropdownWidget;
@@ -0,0 +1,3 @@
1
+ import type { ExplanationWidget, PerseusExplanationWidgetOptions } from "../../data-schema";
2
+ export declare function generateExplanationOptions(options?: Partial<PerseusExplanationWidgetOptions>): PerseusExplanationWidgetOptions;
3
+ export declare function generateExplanationWidget(explanationWidgetProperties?: Partial<Omit<ExplanationWidget, "type">>): ExplanationWidget;
@@ -0,0 +1,4 @@
1
+ import type { PerseusExpressionWidgetOptions, ExpressionWidget, PerseusExpressionAnswerForm } from "../../data-schema";
2
+ export declare function generateExpressionOptions(options?: Partial<PerseusExpressionWidgetOptions>): PerseusExpressionWidgetOptions;
3
+ export declare function generateExpressionAnswerForm(answerFormOptions?: Partial<PerseusExpressionAnswerForm>): PerseusExpressionAnswerForm;
4
+ export declare function generateExpressionWidget(expressionWidgetProperties?: Partial<Omit<ExpressionWidget, "type">>): ExpressionWidget;
@@ -0,0 +1,3 @@
1
+ import type { PerseusFreeResponseWidgetOptions, FreeResponseWidget } from "../../data-schema";
2
+ export declare function generateFreeResponseOptions(options?: Partial<PerseusFreeResponseWidgetOptions>): PerseusFreeResponseWidgetOptions;
3
+ export declare function generateFreeResponseWidget(freeResponseWidgetProperties?: Partial<Omit<FreeResponseWidget, "type">>): FreeResponseWidget;
@@ -0,0 +1,4 @@
1
+ import type { PerseusNumericInputWidgetOptions, NumericInputWidget, PerseusNumericInputAnswer } from "../../data-schema";
2
+ export declare function generateNumericInputOptions(options?: Partial<PerseusNumericInputWidgetOptions>): PerseusNumericInputWidgetOptions;
3
+ export declare function generateNumericInputAnswer(answerOptions?: Partial<PerseusNumericInputAnswer>): PerseusNumericInputAnswer;
4
+ export declare function generateNumericInputWidget(numericInputWidgetProperties?: Partial<Omit<NumericInputWidget, "type">>): NumericInputWidget;
@@ -0,0 +1,9 @@
1
+ import { type LockedEllipseType, type LockedFigure, type LockedFigureType, type LockedFunctionType, type LockedLabelType, type LockedLineType, type LockedPointType, type LockedPolygonType, type LockedVectorType } from "../data-schema";
2
+ export declare function getDefaultFigureForType(type: "point"): LockedPointType;
3
+ export declare function getDefaultFigureForType(type: "line"): LockedLineType;
4
+ export declare function getDefaultFigureForType(type: "vector"): LockedVectorType;
5
+ export declare function getDefaultFigureForType(type: "ellipse"): LockedEllipseType;
6
+ export declare function getDefaultFigureForType(type: "polygon"): LockedPolygonType;
7
+ export declare function getDefaultFigureForType(type: "function"): LockedFunctionType;
8
+ export declare function getDefaultFigureForType(type: "label"): LockedLabelType;
9
+ export declare function getDefaultFigureForType(type: LockedFigureType): LockedFigure;
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-PR3089-20251204205743",
6
+ "version": "0.0.0-PR3089-20251210151846",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },