@khanacademy/perseus-core 30.0.2 → 30.1.1

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.
@@ -47,6 +47,19 @@ export type PerseusAnalyticsEvent = {
47
47
  } | {
48
48
  type: "perseus:label-image:choiced-interacted-with:ti";
49
49
  payload: null;
50
+ } | {
51
+ type: "perseus:image:explore-modal-opened:ti";
52
+ payload: {
53
+ widgetSubType: string;
54
+ widgetId: string;
55
+ };
56
+ } | {
57
+ type: "perseus:image:explore-modal-closed:ti";
58
+ payload: {
59
+ durationMs: number;
60
+ widgetSubType: string;
61
+ widgetId: string;
62
+ };
50
63
  } | {
51
64
  type: "math-input:keypad-closed";
52
65
  payload: {
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="30.0.2";addLibraryVersionToPerseusDebug(libName,libVersion);
231
+ const libName="@khanacademy/perseus-core";const libVersion="30.1.1";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
 
@@ -268,7 +268,7 @@ const defaultWidgetOptions$l={gradedGroups:[]};const traverseChildWidgets$2=func
268
268
 
269
269
  function getGrapherPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
270
270
 
271
- 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:false};
271
+ 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"};
272
272
 
273
273
  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;}}
274
274
 
@@ -377,7 +377,7 @@ const DEFAULT_COLOR="grayH";function getDefaultFigureForType(type){switch(type){
377
377
 
378
378
  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))}
379
379
 
380
- const PerseusFeatureFlags=["input-number-to-numeric-input","perseus-renderer-upgrade","grapher-to-interactive-graph","desmos-calculator","perseus-enable-point-label-field"];function isFeatureOn(props,flag){return props.apiOptions?.flags?.[flag]??false}
380
+ const PerseusFeatureFlags=["perseus-renderer-upgrade","desmos-calculator","perseus-enable-point-label-field"];function isFeatureOn(props,flag){return props.apiOptions?.flags?.[flag]??false}
381
381
 
382
382
  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)};
383
383