@khanacademy/perseus-core 30.0.2 → 30.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 ["
|
|
12
|
+
declare const PerseusFeatureFlags: readonly ["perseus-renderer-upgrade", "desmos-calculator", "perseus-enable-point-label-field"];
|
|
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
|
@@ -256,7 +256,7 @@ const parseUserInputMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx
|
|
|
256
256
|
|
|
257
257
|
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}
|
|
258
258
|
|
|
259
|
-
const libName="@khanacademy/perseus-core";const libVersion="30.0
|
|
259
|
+
const libName="@khanacademy/perseus-core";const libVersion="30.1.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
260
260
|
|
|
261
261
|
const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
|
|
262
262
|
|
|
@@ -296,7 +296,7 @@ const defaultWidgetOptions$l={gradedGroups:[]};const traverseChildWidgets$2=func
|
|
|
296
296
|
|
|
297
297
|
function getGrapherPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
298
298
|
|
|
299
|
-
const defaultWidgetOptions$k={graph:{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",rulerLabel:"",rulerTicks:10,valid:true,showTooltips:false},correct:{type:"linear",coords:null},availableTypes:["linear"]};const grapherWidgetLogic={name:"grapher",defaultWidgetOptions: defaultWidgetOptions$k,getPublicWidgetOptions:getGrapherPublicWidgetOptions,accessible:
|
|
299
|
+
const defaultWidgetOptions$k={graph:{labels:["x","y"],range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",rulerLabel:"",rulerTicks:10,valid:true,showTooltips:false},correct:{type:"linear",coords:null},availableTypes:["linear"]};const grapherWidgetLogic={name:"grapher",defaultWidgetOptions: defaultWidgetOptions$k,getPublicWidgetOptions:getGrapherPublicWidgetOptions,accessible:options=>!options.graph.backgroundImage.url&&options.availableTypes.length===1&&options.availableTypes[0]!=="quadratic"};
|
|
300
300
|
|
|
301
301
|
class Registry{throwIfUnregistered(){if(!this.anythingRegistered){throw new Error(`${this.name} accessed before initialization!`)}}has(key){this.throwIfUnregistered();return Object.prototype.hasOwnProperty.call(this.contents,key)}get(key){this.throwIfUnregistered();return this.contents[key]}keys(){this.throwIfUnregistered();return Object.keys(this.contents)}entries(){this.throwIfUnregistered();return Object.entries(this.contents)}set(key,value){this.anythingRegistered=true;this.contents[key]=value;}constructor(name="Registry"){this.contents={};this.anythingRegistered=false;this.name=name;}}
|
|
302
302
|
|
|
@@ -405,7 +405,7 @@ const DEFAULT_COLOR="grayH";function getDefaultFigureForType(type){switch(type){
|
|
|
405
405
|
|
|
406
406
|
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))}
|
|
407
407
|
|
|
408
|
-
const PerseusFeatureFlags=["
|
|
408
|
+
const PerseusFeatureFlags=["perseus-renderer-upgrade","desmos-calculator","perseus-enable-point-label-field"];function isFeatureOn(props,flag){return props.apiOptions?.flags?.[flag]??false}
|
|
409
409
|
|
|
410
410
|
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)};
|
|
411
411
|
|