@khanacademy/perseus-core 41.0.0 → 41.2.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/dist/data-schema.d.ts +21 -12
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/utils/remove-orphaned-widgets.d.ts +1 -1
- package/package.json +1 -1
package/dist/data-schema.d.ts
CHANGED
|
@@ -1456,6 +1456,7 @@ export type PerseusNumericInputAnswer = {
|
|
|
1456
1456
|
/** How unsimplified responses should be handled. */
|
|
1457
1457
|
simplify: PerseusNumericInputSimplify;
|
|
1458
1458
|
};
|
|
1459
|
+
export type PerseusNumberLineLabelStyle = "decimal" | "improper" | "mixed" | "non-reduced";
|
|
1459
1460
|
/** Options for the number-line widget. A draggable point on a number line. */
|
|
1460
1461
|
export type PerseusNumberLineWidgetOptions = {
|
|
1461
1462
|
/**
|
|
@@ -1473,18 +1474,28 @@ export type PerseusNumberLineWidgetOptions = {
|
|
|
1473
1474
|
* This controls the styling of the labels for the two main labels as well
|
|
1474
1475
|
* as all the tick mark labels, if applicable.
|
|
1475
1476
|
*/
|
|
1476
|
-
labelStyle:
|
|
1477
|
+
labelStyle: PerseusNumberLineLabelStyle;
|
|
1477
1478
|
/** Show label ticks */
|
|
1478
1479
|
labelTicks: boolean;
|
|
1479
|
-
/**
|
|
1480
|
+
/**
|
|
1481
|
+
* Whether the learner should be able to set the number of divisions.
|
|
1482
|
+
*/
|
|
1480
1483
|
isTickCtrl: boolean;
|
|
1481
1484
|
isInequality: boolean;
|
|
1482
|
-
/**
|
|
1485
|
+
/**
|
|
1486
|
+
* The range of possible values for numDivisions, in the format [min, max].
|
|
1487
|
+
*/
|
|
1483
1488
|
divisionRange: number[];
|
|
1484
1489
|
/**
|
|
1485
|
-
*
|
|
1486
|
-
*
|
|
1487
|
-
*
|
|
1490
|
+
* The number of divisions of the number line. Divisions are the spaces
|
|
1491
|
+
* between tick marks.
|
|
1492
|
+
*
|
|
1493
|
+
* When `isTickCtrl` is true, the learner can change the number of
|
|
1494
|
+
* divisions, constrained by `divisionRange`. In that case, `numDivisions`
|
|
1495
|
+
* specifies the initial value.
|
|
1496
|
+
*
|
|
1497
|
+
* Exactly one of tickStep and numDivisions must be set; the missing value
|
|
1498
|
+
* will be calculated from the other.
|
|
1488
1499
|
*/
|
|
1489
1500
|
numDivisions?: number | null;
|
|
1490
1501
|
/**
|
|
@@ -1494,12 +1505,10 @@ export type PerseusNumberLineWidgetOptions = {
|
|
|
1494
1505
|
*/
|
|
1495
1506
|
snapDivisions: number;
|
|
1496
1507
|
/**
|
|
1497
|
-
*
|
|
1498
|
-
*
|
|
1499
|
-
*
|
|
1500
|
-
*
|
|
1501
|
-
* see if labels coordinate with the tick marks, which may be confusing for
|
|
1502
|
-
* users if the blue labels and black ticks are off-step.
|
|
1508
|
+
* The distance between tick marks on the number line.
|
|
1509
|
+
*
|
|
1510
|
+
* Exactly one of tickStep and numDivisions must be set; the missing value
|
|
1511
|
+
* will be calculated from the other.
|
|
1503
1512
|
*/
|
|
1504
1513
|
tickStep?: number | null;
|
|
1505
1514
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ export { itemHasRationales } from "./utils/item-has-rationales";
|
|
|
35
35
|
export { itemHasHints } from "./utils/item-has-hints";
|
|
36
36
|
/** @hidden */
|
|
37
37
|
export { makeSafeUrl } from "./utils/make-safe-url";
|
|
38
|
-
export { removeOrphanedWidgetsFromPerseusItem } from "./utils/remove-orphaned-widgets";
|
|
38
|
+
export { removeOrphanedWidgetsFromPerseusItem, removeOrphanedWidgetsFromPerseusRenderer, } from "./utils/remove-orphaned-widgets";
|
|
39
39
|
export { parseAndMigratePerseusItem, parseAndMigratePerseusArticle, } from "./parse-perseus-json";
|
|
40
40
|
/** @hidden */
|
|
41
41
|
export { parseAndMigrateUserInputMap, parseAndMigratePerseusRenderer, type ParseFailureDetail, } from "./parse-perseus-json";
|
package/dist/index.js
CHANGED
|
@@ -36,7 +36,7 @@ const itemHasHints=item=>{return item.hints.length>0};
|
|
|
36
36
|
|
|
37
37
|
const makeSafeUrl=(urlString,locale,expectedOrigin)=>{let url;try{url=new URL(urlString);}catch{return null}if(url.origin!==expectedOrigin){return null}url.searchParams.set("locale",locale);return url};
|
|
38
38
|
|
|
39
|
-
function removeOrphanedWidgetsFromPerseusItem(item){return {...item,question:
|
|
39
|
+
function removeOrphanedWidgetsFromPerseusItem(item){return {...item,question:removeOrphanedWidgetsFromPerseusRenderer(item.question),hints:item.hints.map(removeOrphanedWidgetsFromPerseusRenderer)}}function removeOrphanedWidgetsFromPerseusRenderer(renderer){const referencedWidgetIds=getWidgetIdsFromContent(renderer.content);const referencedWidgets={};for(const id of referencedWidgetIds){if(renderer.widgets[id]){referencedWidgets[id]=renderer.widgets[id];}}return {...renderer,widgets:referencedWidgets}}
|
|
40
40
|
|
|
41
41
|
function success(value){return {type:"success",value}}function failure(detail){return {type:"failure",detail}}function isFailure(result){return result.type==="failure"}function isSuccess(result){return result.type==="success"}function all(results,combineFailureDetails=a=>a){const values=[];const failureDetails=[];for(const result of results){if(result.type==="success"){values.push(result.value);}else {failureDetails.push(result.detail);}}if(failureDetails.length>0){return failure(failureDetails.reduce(combineFailureDetails))}return success(values)}
|
|
42
42
|
|
|
@@ -232,7 +232,7 @@ const parseUserInputMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx
|
|
|
232
232
|
|
|
233
233
|
function parseAndMigratePerseusItem(data){const object=typeof data==="string"?JSON.parse(data):data;const result=parse(object,parsePerseusItem);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}function parseAndMigratePerseusArticle(data){const object=typeof data==="string"?JSON.parse(data):data;const result=parse(object,parsePerseusArticle);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}function parseAndMigrateUserInputMap(data){const object=typeof data==="string"?JSON.parse(data):data;const result=parse(object,parseUserInputMap);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}function parseAndMigratePerseusRenderer(data){const object=typeof data==="string"?JSON.parse(data):data;const result=parse(object,parsePerseusRenderer);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}
|
|
234
234
|
|
|
235
|
-
const libName="@khanacademy/perseus-core";const libVersion="41.
|
|
235
|
+
const libName="@khanacademy/perseus-core";const libVersion="41.2.0";addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
236
236
|
|
|
237
237
|
const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
|
|
238
238
|
|
|
@@ -464,5 +464,5 @@ const denylist=["key","ref","containerSizeClass","widgetId","onChange","problemN
|
|
|
464
464
|
|
|
465
465
|
registerCoreWidgets();
|
|
466
466
|
|
|
467
|
-
export { coreWidgetRegistry as CoreWidgetRegistry, ErrorCodes, Errors, grapherUtil as GrapherUtil, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusFeatureFlags, Registry, SORTER_MAX_CARDS, SORTER_MAX_HORIZONTAL_CARDS, addWidget, applyDefaultsToWidget, applyDefaultsToWidgets, approximateDeepEqual, approximateEqual, blankWidgetLogic as blankLogic, categorizerWidgetLogic as categorizerLogic, convertGrapherOptionsToInteractiveGraph, convertGrapherUserInputToInteractiveGraph, convertInteractiveGraphUserInputToGrapher, csProgramWidgetLogic as csProgramLogic, deepClone, definitionWidgetLogic as definitionLogic, deriveExtraKeys, deriveNumCorrect, dropdownWidgetLogic as dropdownLogic, exceedsCardLimit, excludeDenylistKeys, explanationWidgetLogic as explanationLogic, expressionWidgetLogic as expressionLogic, fillInTheBlankWidgetLogic as fillInTheBlankLogic, freeResponseWidgetLogic as freeResponseLogic, generateAnswerTile, generateBlankOptions, generateBlankWidget, generateCategorizerOptions, generateCategorizerWidget, generateDefinitionOptions, generateDefinitionWidget, generateDropdownOptions, generateDropdownWidget, generateExplanationOptions, generateExplanationWidget, generateExpressionAnswerForm, generateExpressionOptions, generateExpressionWidget, generateFillInTheBlankOptions, generateFillInTheBlankWidget, generateFreeResponseOptions, generateFreeResponseWidget, generateGradedGroupOptions, generateGradedGroupSetWidget, generateGradedGroupWidget, generateGrapherWidgetOptions, generateGroupOptions, generateGroupWidget, generateIGAbsoluteValueGraph, generateIGAngleGraph, generateIGCircleGraph, generateIGExponentialGraph, generateIGLinearGraph, generateIGLinearSystemGraph, generateIGLockedEllipse, generateIGLockedFunction, generateIGLockedLabel, generateIGLockedLine, generateIGLockedPoint, generateIGLockedPolygon, generateIGLockedVector, generateIGLogarithmGraph, generateIGNoneGraph, generateIGPointGraph, generateIGPolygonGraph, generateIGQuadraticGraph, generateIGRayGraph, generateIGSegmentGraph, generateIGSinusoidGraph, generateIGTangentGraph, generateIGVectorGraph, generateImageOptions, generateImageWidget, generateInputNumberAnswer, generateInputNumberOptions, generateInputNumberWidget, generateInteractiveGraphOptions, generateInteractiveGraphQuestion, generateInteractiveGraphWidget, generateLabelImageOptions, generateLabelImageWidget, generateMatcherOptions, generateMatcherWidget, generateMatrixOptions, generateMatrixWidget, generateMeasurerOptions, generateMeasurerWidget, generateNumberLineOptions, generateNumberLineWidget, generateNumericInputAnswer, generateNumericInputOptions, generateNumericInputWidget, generateOrdererOption, generateOrdererOptions, generateOrdererWidget, generatePhetSimulationOptions, generatePhetSimulationWidget, generatePlotterOptions, generatePlotterWidget, generateRadioChoice, generateRadioOptions, generateRadioWidget, generateSimpleRadioItem, generateSimpleRadioQuestion, generateSorterOptions, generateSorterWidget, generateTableOptions, generateTestPerseusItem, generateTestPerseusRenderer, generateVideoWidget, getAnswersFromWidgets, getBaseUrl, getCSProgramPublicWidgetOptions, getCategorizerPublicWidgetOptions, getDataUrl, getDecimalSeparator, getDefaultAnswerArea, getDefaultFigureForType, getDivideSymbol, getDivideSymbolForTex, getDropdownPublicWidgetOptions, getExpressionPublicWidgetOptions, getFreeResponsePublicWidgetOptions, getGrapherPublicWidgetOptions, getGroupPublicWidgetOptions, getIFramePublicWidgetOptions, getImageSizeModern, getInteractiveGraphPublicWidgetOptions, getLabelImagePublicWidgetOptions, getMatcherPublicWidgetOptions, getMatrixPublicWidgetOptions, getMatrixSize, getNumberLinePublicWidgetOptions, getNumericInputPublicWidgetOptions, getOrdererPublicWidgetOptions, getPerseusAIData, getPlotterPublicWidgetOptions, getRadioPublicWidgetOptions, getRealImageUrl, getSorterPublicWidgetOptions, getSvgUrl, getTablePublicWidgetOptions, getWidgetIdsFromContent, getWidgetIdsFromContentByType, gradedGroupWidgetLogic as gradedGroupLogic, gradedGroupSetWidgetLogic as gradedGroupSetLogic, grapherWidgetLogic as grapherLogic, groupWidgetLogic as groupLogic, iframeWidgetLogic as iframeLogic, imageWidgetLogic as imageLogic, injectWidgets, inputNumberWidgetLogic as inputNumberLogic, interactionWidgetLogic as interactionLogic, interactiveGraphWidgetLogic as interactiveGraphLogic, isFailure, isFeatureOn, isItemAccessible, isLabeledSVG, isSuccess, itemHasHints, itemHasRationales, labelImageWidgetLogic as labelImageLogic, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, makeSafeUrl, mapObject, matcherWidgetLogic as matcherLogic, matrixWidgetLogic as matrixLogic, measurerWidgetLogic as measurerLogic, mergeCards, numberLineWidgetLogic as numberLineLogic, numericInputWidgetLogic as numericInputLogic, ordererWidgetLogic as ordererLogic, parseAndMigratePerseusArticle, parseAndMigratePerseusItem, parseAndMigratePerseusRenderer, parseAndMigrateUserInputMap, phetSimulationWidgetLogic as phetSimulationLogic, plotterWidgetLogic as plotterLogic, plotterPlotTypes, pluck, pythonProgramWidgetLogic as pythonProgramLogic, radioWidgetLogic as radioLogic, random, removeOrphanedWidgetsFromPerseusItem, seededRNG, shuffle, shuffleMatcher, shuffleSorter, sorterWidgetLogic as sorterLogic, splitPerseusItem, splitPerseusItemJSON, tableWidgetLogic as tableLogic, toCard, traverse, usesNumCorrect, videoWidgetLogic as videoLogic };
|
|
467
|
+
export { coreWidgetRegistry as CoreWidgetRegistry, ErrorCodes, Errors, grapherUtil as GrapherUtil, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusFeatureFlags, Registry, SORTER_MAX_CARDS, SORTER_MAX_HORIZONTAL_CARDS, addWidget, applyDefaultsToWidget, applyDefaultsToWidgets, approximateDeepEqual, approximateEqual, blankWidgetLogic as blankLogic, categorizerWidgetLogic as categorizerLogic, convertGrapherOptionsToInteractiveGraph, convertGrapherUserInputToInteractiveGraph, convertInteractiveGraphUserInputToGrapher, csProgramWidgetLogic as csProgramLogic, deepClone, definitionWidgetLogic as definitionLogic, deriveExtraKeys, deriveNumCorrect, dropdownWidgetLogic as dropdownLogic, exceedsCardLimit, excludeDenylistKeys, explanationWidgetLogic as explanationLogic, expressionWidgetLogic as expressionLogic, fillInTheBlankWidgetLogic as fillInTheBlankLogic, freeResponseWidgetLogic as freeResponseLogic, generateAnswerTile, generateBlankOptions, generateBlankWidget, generateCategorizerOptions, generateCategorizerWidget, generateDefinitionOptions, generateDefinitionWidget, generateDropdownOptions, generateDropdownWidget, generateExplanationOptions, generateExplanationWidget, generateExpressionAnswerForm, generateExpressionOptions, generateExpressionWidget, generateFillInTheBlankOptions, generateFillInTheBlankWidget, generateFreeResponseOptions, generateFreeResponseWidget, generateGradedGroupOptions, generateGradedGroupSetWidget, generateGradedGroupWidget, generateGrapherWidgetOptions, generateGroupOptions, generateGroupWidget, generateIGAbsoluteValueGraph, generateIGAngleGraph, generateIGCircleGraph, generateIGExponentialGraph, generateIGLinearGraph, generateIGLinearSystemGraph, generateIGLockedEllipse, generateIGLockedFunction, generateIGLockedLabel, generateIGLockedLine, generateIGLockedPoint, generateIGLockedPolygon, generateIGLockedVector, generateIGLogarithmGraph, generateIGNoneGraph, generateIGPointGraph, generateIGPolygonGraph, generateIGQuadraticGraph, generateIGRayGraph, generateIGSegmentGraph, generateIGSinusoidGraph, generateIGTangentGraph, generateIGVectorGraph, generateImageOptions, generateImageWidget, generateInputNumberAnswer, generateInputNumberOptions, generateInputNumberWidget, generateInteractiveGraphOptions, generateInteractiveGraphQuestion, generateInteractiveGraphWidget, generateLabelImageOptions, generateLabelImageWidget, generateMatcherOptions, generateMatcherWidget, generateMatrixOptions, generateMatrixWidget, generateMeasurerOptions, generateMeasurerWidget, generateNumberLineOptions, generateNumberLineWidget, generateNumericInputAnswer, generateNumericInputOptions, generateNumericInputWidget, generateOrdererOption, generateOrdererOptions, generateOrdererWidget, generatePhetSimulationOptions, generatePhetSimulationWidget, generatePlotterOptions, generatePlotterWidget, generateRadioChoice, generateRadioOptions, generateRadioWidget, generateSimpleRadioItem, generateSimpleRadioQuestion, generateSorterOptions, generateSorterWidget, generateTableOptions, generateTestPerseusItem, generateTestPerseusRenderer, generateVideoWidget, getAnswersFromWidgets, getBaseUrl, getCSProgramPublicWidgetOptions, getCategorizerPublicWidgetOptions, getDataUrl, getDecimalSeparator, getDefaultAnswerArea, getDefaultFigureForType, getDivideSymbol, getDivideSymbolForTex, getDropdownPublicWidgetOptions, getExpressionPublicWidgetOptions, getFreeResponsePublicWidgetOptions, getGrapherPublicWidgetOptions, getGroupPublicWidgetOptions, getIFramePublicWidgetOptions, getImageSizeModern, getInteractiveGraphPublicWidgetOptions, getLabelImagePublicWidgetOptions, getMatcherPublicWidgetOptions, getMatrixPublicWidgetOptions, getMatrixSize, getNumberLinePublicWidgetOptions, getNumericInputPublicWidgetOptions, getOrdererPublicWidgetOptions, getPerseusAIData, getPlotterPublicWidgetOptions, getRadioPublicWidgetOptions, getRealImageUrl, getSorterPublicWidgetOptions, getSvgUrl, getTablePublicWidgetOptions, getWidgetIdsFromContent, getWidgetIdsFromContentByType, gradedGroupWidgetLogic as gradedGroupLogic, gradedGroupSetWidgetLogic as gradedGroupSetLogic, grapherWidgetLogic as grapherLogic, groupWidgetLogic as groupLogic, iframeWidgetLogic as iframeLogic, imageWidgetLogic as imageLogic, injectWidgets, inputNumberWidgetLogic as inputNumberLogic, interactionWidgetLogic as interactionLogic, interactiveGraphWidgetLogic as interactiveGraphLogic, isFailure, isFeatureOn, isItemAccessible, isLabeledSVG, isSuccess, itemHasHints, itemHasRationales, labelImageWidgetLogic as labelImageLogic, libVersion, lockedFigureColorNames, lockedFigureColors, lockedFigureFillStyles, makeSafeUrl, mapObject, matcherWidgetLogic as matcherLogic, matrixWidgetLogic as matrixLogic, measurerWidgetLogic as measurerLogic, mergeCards, numberLineWidgetLogic as numberLineLogic, numericInputWidgetLogic as numericInputLogic, ordererWidgetLogic as ordererLogic, parseAndMigratePerseusArticle, parseAndMigratePerseusItem, parseAndMigratePerseusRenderer, parseAndMigrateUserInputMap, phetSimulationWidgetLogic as phetSimulationLogic, plotterWidgetLogic as plotterLogic, plotterPlotTypes, pluck, pythonProgramWidgetLogic as pythonProgramLogic, radioWidgetLogic as radioLogic, random, removeOrphanedWidgetsFromPerseusItem, removeOrphanedWidgetsFromPerseusRenderer, seededRNG, shuffle, shuffleMatcher, shuffleSorter, sorterWidgetLogic as sorterLogic, splitPerseusItem, splitPerseusItemJSON, tableWidgetLogic as tableLogic, toCard, traverse, usesNumCorrect, videoWidgetLogic as videoLogic };
|
|
468
468
|
//# sourceMappingURL=index.js.map
|