@khanacademy/perseus-core 25.0.0 → 26.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/dist/accessibility.d.ts
CHANGED
|
@@ -3,20 +3,6 @@
|
|
|
3
3
|
* or screen, based on the widgets it contains.
|
|
4
4
|
*/
|
|
5
5
|
import type { PerseusItem } from "./data-schema";
|
|
6
|
-
/**
|
|
7
|
-
* Returns a list of widget types that cause a given Perseus item to require
|
|
8
|
-
* the use of a screen or mouse.
|
|
9
|
-
*
|
|
10
|
-
* For now we'll just check the `accessible` field on each of the widgets
|
|
11
|
-
* in the item data, but in the future we may specify accessibility on
|
|
12
|
-
* each widget with higher granularity.
|
|
13
|
-
*
|
|
14
|
-
* @deprecated This function returns a list of widget _types_ that violate our
|
|
15
|
-
* accessibility requirements which is not very accurate given that some
|
|
16
|
-
* instances _could_ be accessible and some not based on their widget options.
|
|
17
|
-
* In most cases, you should use {@link isItemAccessible} instead.
|
|
18
|
-
*/
|
|
19
|
-
export declare function violatingWidgets(itemData: PerseusItem): Array<string>;
|
|
20
6
|
/**
|
|
21
7
|
* Returns true if the given Perseus item is accessible (i.e., does not contain
|
|
22
8
|
* any widgets that violate our accessibility requirements).
|
package/dist/es/index.js
CHANGED
|
@@ -228,7 +228,7 @@ const parseUserInputMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx
|
|
|
228
228
|
|
|
229
229
|
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}
|
|
230
230
|
|
|
231
|
-
const libName="@khanacademy/perseus-core";const libVersion="
|
|
231
|
+
const libName="@khanacademy/perseus-core";const libVersion="26.0.0";addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
232
232
|
|
|
233
233
|
const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
|
|
234
234
|
|
|
@@ -375,7 +375,7 @@ const PerseusFeatureFlags=["new-radio-widget","image-widget-upgrade-gif-controls
|
|
|
375
375
|
|
|
376
376
|
const noop=function(){};const deepCallbackFor=function(contentCallback,widgetCallback,optionsCallback){const deepCallback=function(widgetInfo,widgetId){const newWidgetInfo=traverseChildWidgets$1(widgetInfo,rendererOptions=>{return traverseRenderer(rendererOptions,contentCallback,deepCallback,optionsCallback)});const userWidgetInfo=widgetCallback(newWidgetInfo,widgetId);if(userWidgetInfo!==undefined){return userWidgetInfo}return newWidgetInfo};return deepCallback};const traverseRenderer=function(rendererOptions,contentCallback,deepWidgetCallback,optionsCallback){let newContent=rendererOptions.content;if(rendererOptions.content!=null){const modifiedContent=contentCallback(rendererOptions.content);if(modifiedContent!==undefined){newContent=modifiedContent;}}const newWidgets=mapObject(rendererOptions.widgets||{},function(widgetInfo,widgetId){if(widgetInfo==null||widgetInfo.type==null){return widgetInfo}return deepWidgetCallback(widgetInfo,widgetId)});const newOptions=_.extend({},rendererOptions,{content:newContent,widgets:newWidgets});const userOptions=optionsCallback(newOptions);if(userOptions!==undefined){return userOptions}return newOptions};const traverse=function(rendererOptions,contentCallback,widgetCallback,optionsCallback){contentCallback=contentCallback||noop;widgetCallback=widgetCallback||noop;optionsCallback=optionsCallback||noop;return traverseRenderer(rendererOptions,contentCallback,deepCallbackFor(contentCallback,widgetCallback,optionsCallback),optionsCallback)};
|
|
377
377
|
|
|
378
|
-
function
|
|
378
|
+
function isItemAccessible(itemData){const ast=parse$1(itemData.question.content);const widgetIdsInUse=getWidgetIdsFromContent(itemData.question.content);let hasInaccessibleImage=false;traverseContent(ast,node=>{if(node.type==="image"&&(node.alt==null||node.alt==="")){hasInaccessibleImage=true;}});if(hasInaccessibleImage){return false}const itemDataWithOnlyActiveWidgets={...itemData,question:{...itemData.question,widgets:Object.fromEntries(Object.entries(itemData.question.widgets).filter(([id])=>widgetIdsInUse.includes(id)))},hints:itemData.hints.map(hint=>{const hintWidgetIdsInUse=getWidgetIdsFromContent(hint.content);return {...hint,widgets:Object.fromEntries(Object.entries(hint.widgets).filter(([id])=>hintWidgetIdsInUse.includes(id)))}})};let hasInaccessibleWidget=false;const checkAccessibility=info=>{if(info.type&&!isAccessible(info.type,info.options)){hasInaccessibleWidget=true;}};traverse(itemDataWithOnlyActiveWidgets.question,null,checkAccessibility);for(const hint of itemDataWithOnlyActiveWidgets.hints){traverse(hint,null,checkAccessibility);}return !hasInaccessibleWidget}
|
|
379
379
|
|
|
380
380
|
function generateDefinitionOptions(options){return {...definitionWidgetLogic.defaultWidgetOptions,...options}}function generateDefinitionWidget(definitionWidgetProperties){return {type:"definition",graded:false,version:{major:0,minor:0},static:false,alignment:"default",options:generateDefinitionOptions(),...definitionWidgetProperties}}
|
|
381
381
|
|
|
@@ -395,7 +395,9 @@ function generateGroupOptions(options){return {...groupWidgetLogic.defaultWidget
|
|
|
395
395
|
|
|
396
396
|
function generateImageOptions(options){const defaultImageOptions={backgroundImage:{}};return {...defaultImageOptions,...options}}function generateImageWidget(imageWidgetProperties){return {type:"image",graded:false,version:{major:0,minor:0},static:false,alignment:"default",options:generateImageOptions({}),...imageWidgetProperties}}
|
|
397
397
|
|
|
398
|
-
function
|
|
398
|
+
function generateLabelImageOptions(options){return {...labelImageWidgetLogic.defaultWidgetOptions,...options}}function generateLabelImageWidget(labelImageWidgetProperties){return {type:"label-image",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:generateLabelImageOptions(),...labelImageWidgetProperties}}
|
|
399
|
+
|
|
400
|
+
function generateInteractiveGraphWidget(interactiveGraphWidgetProperties){return {type:"interactive-graph",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:generateInteractiveGraphOptions(),...interactiveGraphWidgetProperties}}function generateInteractiveGraphOptions(options){return {...interactiveGraphWidgetLogic.defaultWidgetOptions,...options}}function generateIGAngleGraph(options){return {type:"angle",...options}}function generateIGCircleGraph(options){return {type:"circle",...options}}function generateIGLinearGraph(options){return {type:"linear",...options}}function generateIGLinearSystemGraph(options){return {type:"linear-system",...options}}function generateIGLogarithmGraph(options){return {type:"logarithm",...options}}function generateIGNoneGraph(){return {type:"none"}}function generateIGPointGraph(options){return {type:"point",...options}}function generateIGPolygonGraph(options){return {type:"polygon",...options}}function generateIGQuadraticGraph(options){return {type:"quadratic",...options}}function generateIGRayGraph(options){return {type:"ray",...options}}function generateIGSegmentGraph(options){return {type:"segment",...options}}function generateIGSinusoidGraph(options){return {type:"sinusoid",...options}}function generateIGTangentGraph(options){return {type:"tangent",...options}}function generateIGVectorGraph(options){return {type:"vector",...options}}function generateIGLockedPoint(options){return {...getDefaultFigureForType("point"),...options}}function generateIGLockedLine(options){return {...getDefaultFigureForType("line"),...options}}function generateIGLockedVector(options){return {...getDefaultFigureForType("vector"),...options}}function generateIGLockedEllipse(options){return {...getDefaultFigureForType("ellipse"),...options}}function generateIGLockedPolygon(options){return {...getDefaultFigureForType("polygon"),...options}}function generateIGLockedFunction(options){return {...getDefaultFigureForType("function"),...options}}function generateIGLockedLabel(options){return {...getDefaultFigureForType("label"),...options}}function generateIGExponentialGraph(options){return {type:"exponential",...options}}function generateIGAbsoluteValueGraph(options){return {type:"absolute-value",...options}}function generateInteractiveGraphQuestion(options){const{content,isStatic,...widgetOptions}=options??{};if(widgetOptions.correct&&!widgetOptions.graph){const{coords:_,coord:__,center:___,radius:____,asymptote:_____,match:______,...graphConfig}=widgetOptions.correct;widgetOptions.graph=graphConfig;}const optionsWithDefaults={gridStep:[1,1],snapStep:[.5,.5],...widgetOptions};return generateTestPerseusRenderer({content:content??"[[☃ interactive-graph 1]]",widgets:{"interactive-graph 1":generateInteractiveGraphWidget({static:isStatic??false,options:generateInteractiveGraphOptions(optionsWithDefaults)})}})}
|
|
399
401
|
|
|
400
402
|
function generateNumericInputOptions(options){return {...numericInputWidgetLogic.defaultWidgetOptions,static:false,...options}}function generateNumericInputAnswer(answerOptions){return {...numericInputWidgetLogic.defaultWidgetOptions.answers[0],...answerOptions}}function generateNumericInputWidget(numericInputWidgetProperties){return {type:"numeric-input",graded:true,version:{major:0,minor:0},static:false,alignment:"default",options:generateNumericInputOptions(),...numericInputWidgetProperties}}
|
|
401
403
|
|
|
@@ -413,5 +415,5 @@ ${table}`);}break;case "numeric-input":case "input-number":case "expression":con
|
|
|
413
415
|
|
|
414
416
|
registerCoreWidgets();
|
|
415
417
|
|
|
416
|
-
export { coreWidgetRegistry as CoreWidgetRegistry, ErrorCodes, Errors, grapherUtil as GrapherUtil, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusFeatureFlags, Registry, addWidget, applyDefaultsToWidget, applyDefaultsToWidgets, approximateDeepEqual, approximateEqual, categorizerWidgetLogic as categorizerLogic, csProgramWidgetLogic as csProgramLogic, deepClone, definitionWidgetLogic as definitionLogic, deriveExtraKeys, deriveNumCorrect, dropdownWidgetLogic as dropdownLogic, explanationWidgetLogic as explanationLogic, expressionWidgetLogic as expressionLogic, freeResponseWidgetLogic as freeResponseLogic, generateDefinitionOptions, generateDefinitionWidget, generateDropdownOptions, generateDropdownWidget, generateExplanationOptions, generateExplanationWidget, generateExpressionAnswerForm, generateExpressionOptions, generateExpressionWidget, generateFreeResponseOptions, generateFreeResponseWidget, generateGradedGroupOptions, generateGradedGroupSetWidget, generateGradedGroupWidget, generateGroupOptions, generateGroupWidget, generateIGAngleGraph, generateIGCircleGraph, generateIGLinearGraph, generateIGLinearSystemGraph, generateIGLockedEllipse, generateIGLockedFunction, generateIGLockedLabel, generateIGLockedLine, generateIGLockedPoint, generateIGLockedPolygon, generateIGLockedVector, generateIGLogarithmGraph, generateIGNoneGraph, generateIGPointGraph, generateIGPolygonGraph, generateIGQuadraticGraph, generateIGRayGraph, generateIGSegmentGraph, generateIGSinusoidGraph, generateIGTangentGraph, generateIGVectorGraph, generateImageOptions, generateImageWidget, generateInteractiveGraphOptions, generateInteractiveGraphWidget, generateNumericInputAnswer, generateNumericInputOptions, generateNumericInputWidget, generateRadioChoice, generateRadioOptions, generateRadioWidget, generateSimpleRadioItem, generateSimpleRadioQuestion, 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, 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, traverse, usesNumCorrect, videoWidgetLogic as videoLogic
|
|
418
|
+
export { coreWidgetRegistry as CoreWidgetRegistry, ErrorCodes, Errors, grapherUtil as GrapherUtil, ItemExtras, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusFeatureFlags, Registry, addWidget, applyDefaultsToWidget, applyDefaultsToWidgets, approximateDeepEqual, approximateEqual, categorizerWidgetLogic as categorizerLogic, csProgramWidgetLogic as csProgramLogic, deepClone, definitionWidgetLogic as definitionLogic, deriveExtraKeys, deriveNumCorrect, dropdownWidgetLogic as dropdownLogic, explanationWidgetLogic as explanationLogic, expressionWidgetLogic as expressionLogic, freeResponseWidgetLogic as freeResponseLogic, generateDefinitionOptions, generateDefinitionWidget, generateDropdownOptions, generateDropdownWidget, generateExplanationOptions, generateExplanationWidget, generateExpressionAnswerForm, generateExpressionOptions, generateExpressionWidget, generateFreeResponseOptions, generateFreeResponseWidget, generateGradedGroupOptions, generateGradedGroupSetWidget, generateGradedGroupWidget, 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, generateInteractiveGraphOptions, generateInteractiveGraphQuestion, generateInteractiveGraphWidget, generateLabelImageOptions, generateLabelImageWidget, generateNumericInputAnswer, generateNumericInputOptions, generateNumericInputWidget, generateRadioChoice, generateRadioOptions, generateRadioWidget, generateSimpleRadioItem, generateSimpleRadioQuestion, 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, 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, traverse, usesNumCorrect, videoWidgetLogic as videoLogic };
|
|
417
419
|
//# sourceMappingURL=index.js.map
|