@khanacademy/perseus-core 27.0.2 → 27.1.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/feature-flags.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* export const PerseusFeatureFlags = [];
|
|
10
10
|
* 4. Also update the testing/feature-flags-util.ts for testing purpose
|
|
11
11
|
*/
|
|
12
|
-
declare const PerseusFeatureFlags: readonly ["image-widget-upgrade-gif-controls", "
|
|
12
|
+
declare const PerseusFeatureFlags: readonly ["image-widget-upgrade-gif-controls", "input-number-to-numeric-input"];
|
|
13
13
|
export default PerseusFeatureFlags;
|
|
14
14
|
/**
|
|
15
15
|
* Checks if a feature flag is enabled in the given props.
|
package/dist/index.js
CHANGED
|
@@ -255,7 +255,7 @@ const parseUserInputMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx
|
|
|
255
255
|
|
|
256
256
|
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}
|
|
257
257
|
|
|
258
|
-
const libName="@khanacademy/perseus-core";const libVersion="27.0
|
|
258
|
+
const libName="@khanacademy/perseus-core";const libVersion="27.1.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
259
259
|
|
|
260
260
|
const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
|
|
261
261
|
|
|
@@ -313,9 +313,11 @@ const defaultWidgetOptions$g={graph:{box:[400,400],labels:["x","y"],range:[[-10,
|
|
|
313
313
|
|
|
314
314
|
const svgLabelsRegex=/^web\+graphie:/;const svgLocalLabelsRegex=/^file\+graphie:/;function getRealImageUrl(graphieUrl){if(isLabeledSVG(graphieUrl)){return getSvgUrl(graphieUrl)}return graphieUrl}function isLabeledSVG(graphieUrl){return svgLabelsRegex.test(graphieUrl)||svgLocalLabelsRegex.test(graphieUrl)}function getBaseUrl(graphieUrl){return graphieUrl.replace(svgLabelsRegex,"https:").replace(svgLocalLabelsRegex,"file:")}function getSvgUrl(graphieUrl){return getBaseUrl(graphieUrl)+".svg"}function getDataUrl(graphieUrl){return getBaseUrl(graphieUrl)+"-data.json"}async function getImageSizeModern(url){const image=new Image;return new Promise((resolve,reject)=>{image.onload=()=>{resolve([image.naturalWidth,image.naturalHeight]);};image.onerror=reject;image.src=getRealImageUrl(url);})}
|
|
315
315
|
|
|
316
|
+
function accessible(widgetOptions){if(widgetOptions.showProtractor){return false}if(widgetOptions.backgroundImage?.url&&isLabeledSVG(widgetOptions.backgroundImage?.url)){return false}if(widgetOptions.lockedFigures.length>0&&!widgetOptions.fullGraphAriaDescription){return false}return true}
|
|
317
|
+
|
|
316
318
|
function getInteractiveGraphPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
317
319
|
|
|
318
|
-
const defaultWidgetOptions$f={labels:["$x$","$y$"],labelLocation:"onAxis",lockedFigures:[],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showAxisArrows:{xMin:true,xMax:true,yMin:true,yMax:true},showAxisTicks:{x:true,y:true},showTooltips:false,showProtractor:false,graph:{type:"linear"},correct:{type:"linear",coords:null}};const interactiveGraphWidgetLogic={name:"interactive-graph",defaultWidgetOptions: defaultWidgetOptions$f,getPublicWidgetOptions:getInteractiveGraphPublicWidgetOptions,accessible
|
|
320
|
+
const defaultWidgetOptions$f={labels:["$x$","$y$"],labelLocation:"onAxis",lockedFigures:[],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showAxisArrows:{xMin:true,xMax:true,yMin:true,yMax:true},showAxisTicks:{x:true,y:true},showTooltips:false,showProtractor:false,graph:{type:"linear"},correct:{type:"linear",coords:null}};const interactiveGraphWidgetLogic={name:"interactive-graph",defaultWidgetOptions: defaultWidgetOptions$f,getPublicWidgetOptions:getInteractiveGraphPublicWidgetOptions,accessible};
|
|
319
321
|
|
|
320
322
|
function getLabelImagePublicWidgetOptions(options){return {...options,markers:options.markers.map(getLabelImageMarkerPublicData)}}function getLabelImageMarkerPublicData(marker){const{answers:_,...publicData}=marker;return publicData}function isLabelImageAccessible(options){const labelImageOptions=options;if(labelImageOptions.imageUrl!==""&&labelImageOptions.imageAlt===""){return false}for(const marker of labelImageOptions.markers){if(marker.label===""){return false}}return true}
|
|
321
323
|
|
|
@@ -400,7 +402,7 @@ const DEFAULT_COLOR="grayH";function getDefaultFigureForType(type){switch(type){
|
|
|
400
402
|
|
|
401
403
|
function splitPerseusItem(original){const item=deepClone(original);return {...item,question:splitPerseusRenderer(item.question),hints:original.hints.map(()=>({content:"",widgets:{},images:{},placeholder:true}))}}function splitPerseusItemJSON(data){const parseResult=parseAndMigratePerseusItem(data);if(isFailure(parseResult)){throw new SyntaxError(parseResult.detail.message)}const item=parseResult.value;return JSON.stringify(splitPerseusItem(item))}
|
|
402
404
|
|
|
403
|
-
const PerseusFeatureFlags=["image-widget-upgrade-gif-controls","
|
|
405
|
+
const PerseusFeatureFlags=["image-widget-upgrade-gif-controls","input-number-to-numeric-input"];function isFeatureOn(props,flag){return props.apiOptions?.flags?.[flag]??false}
|
|
404
406
|
|
|
405
407
|
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=___default.default.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)};
|
|
406
408
|
|