@khanacademy/perseus-core 0.0.0-PR3136-20251215233123 → 0.0.0-PR3137-20251215233157
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/es/index.item-splitting.js +1 -5
- package/dist/es/index.item-splitting.js.map +1 -1
- package/dist/es/index.js +26 -38
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.item-splitting.js +1 -5
- package/dist/index.item-splitting.js.map +1 -1
- package/dist/index.js +25 -40
- package/dist/index.js.map +1 -1
- package/dist/widgets/label-image/label-image-util.d.ts +1 -2
- package/package.json +2 -2
- package/dist/parse-perseus-json/perseus-parsers/passage-ref-widget.d.ts +0 -5
- package/dist/parse-perseus-json/perseus-parsers/passage-ref-widget.typetest.d.ts +0 -1
- package/dist/parse-perseus-json/perseus-parsers/passage-widget.d.ts +0 -7
- package/dist/parse-perseus-json/perseus-parsers/passage-widget.typetest.d.ts +0 -1
- package/dist/parse-perseus-json/regression-tests/item-data/passage-missing-footnotes-and-title.d.ts +0 -47
- package/dist/parse-perseus-json/regression-tests/item-data/passage-ref-missing-summaryText.d.ts +0 -147
- package/dist/widgets/passage/index.d.ts +0 -5
- package/dist/widgets/passage-ref/index.d.ts +0 -4
- package/dist/widgets/passage-ref/passage-ref-upgrade.d.ts +0 -7
- package/dist/widgets/passage-ref-target/index.d.ts +0 -5
package/dist/index.js
CHANGED
|
@@ -181,10 +181,6 @@ const parseMathFormat=enumeration("integer","mixed","improper","proper","decimal
|
|
|
181
181
|
|
|
182
182
|
function parseRenderer(rawValue,ctx){return parsePerseusRenderer(rawValue,ctx)}const largeToAuto=(height,ctx)=>{if(height==="large"){return ctx.success("auto")}return ctx.success(height)};const parseOrdererWidget=parseWidget(constant("orderer"),object({options:defaulted(array(parseRenderer),()=>[]),correctOptions:defaulted(array(parseRenderer),()=>[]),otherOptions:defaulted(array(parseRenderer),()=>[]),height:pipeParsers(enumeration("normal","auto","large")).then(largeToAuto).parser,layout:defaulted(enumeration("horizontal","vertical"),()=>"horizontal")}));
|
|
183
183
|
|
|
184
|
-
const parsePassageRefWidget=parseWidget(constant("passage-ref"),object({passageNumber:number,referenceNumber:number,summaryText:optional(string)}));
|
|
185
|
-
|
|
186
|
-
const parsePassageWidget=parseWidget(constant("passage"),object({footnotes:defaulted(string,()=>""),passageText:string,passageTitle:defaulted(string,()=>""),showLineNumbers:boolean,static:defaulted(boolean,()=>false)}));
|
|
187
|
-
|
|
188
184
|
const parsePhetSimulationWidget=parseWidget(constant("phet-simulation"),object({url:string,description:string}));
|
|
189
185
|
|
|
190
186
|
const parsePlotterWidget=parseWidget(constant("plotter"),object({labels:array(string),categories:array(string),type:enumeration(...plotterPlotTypes),maxY:number,scaleY:defaulted(number,()=>1),labelInterval:optional(nullable(number)),snapsPerLine:defaulted(number,()=>2),starting:array(number),correct:defaulted(array(number),()=>[]),picUrl:optional(nullable(string)),picSize:optional(nullable(number)),picBoxHeight:optional(nullable(number)),plotDimensions:defaulted(array(number),()=>[380,300])}));
|
|
@@ -203,7 +199,7 @@ const parseVideoWidget=parseWidget(constant("video"),object({location:string,sta
|
|
|
203
199
|
|
|
204
200
|
const parseStringToNonNegativeInt=(rawValue,ctx)=>{if(typeof rawValue!=="string"||!/^(0|[1-9][0-9]*)$/.test(rawValue)){return ctx.failure("a string representing a non-negative integer",rawValue)}return ctx.success(+rawValue)};const parseWidgetIdComponents=pair(string,parseStringToNonNegativeInt);
|
|
205
201
|
|
|
206
|
-
const parseWidgetsMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx.failure("PerseusWidgetsMap",rawValue)}const widgetsMap={};for(const key of Object.keys(rawValue)){const entryResult=parseWidgetsMapEntry([key,rawValue[key]],widgetsMap,ctx.forSubtree(key));if(isFailure(entryResult)){return entryResult}}return ctx.success(widgetsMap)};const parseWidgetsMapEntry=([id,widget],widgetMap,ctx)=>{const idComponentsResult=parseWidgetIdComponents(id.split(" "),ctx.forSubtree("(widget ID)"));if(isFailure(idComponentsResult)){return idComponentsResult}const[type,n]=idComponentsResult.value;function parseAndAssign(key,parse){const widgetResult=parse(widget,ctx);if(isFailure(widgetResult)){return widgetResult}widgetMap[key]=widgetResult.value;return ctx.success(undefined)}switch(type){case "categorizer":return parseAndAssign(`categorizer ${n}`,parseCategorizerWidget);case "cs-program":return parseAndAssign(`cs-program ${n}`,parseCSProgramWidget);case "definition":return parseAndAssign(`definition ${n}`,parseDefinitionWidget);case "dropdown":return parseAndAssign(`dropdown ${n}`,parseDropdownWidget);case "explanation":return parseAndAssign(`explanation ${n}`,parseExplanationWidget);case "expression":return parseAndAssign(`expression ${n}`,parseExpressionWidget);case "free-response":return parseAndAssign(`free-response ${n}`,parseFreeResponseWidget);case "grapher":return parseAndAssign(`grapher ${n}`,parseGrapherWidget);case "group":return parseAndAssign(`group ${n}`,parseGroupWidget);case "graded-group":return parseAndAssign(`graded-group ${n}`,parseGradedGroupWidget);case "graded-group-set":return parseAndAssign(`graded-group-set ${n}`,parseGradedGroupSetWidget);case "iframe":return parseAndAssign(`iframe ${n}`,parseIframeWidget);case "image":return parseAndAssign(`image ${n}`,parseImageWidget);case "input-number":return parseAndAssign(`input-number ${n}`,parseInputNumberWidget);case "interaction":return parseAndAssign(`interaction ${n}`,parseInteractionWidget);case "interactive-graph":return parseAndAssign(`interactive-graph ${n}`,parseInteractiveGraphWidget);case "label-image":return parseAndAssign(`label-image ${n}`,parseLabelImageWidget);case "matcher":return parseAndAssign(`matcher ${n}`,parseMatcherWidget);case "matrix":return parseAndAssign(`matrix ${n}`,parseMatrixWidget);case "measurer":return parseAndAssign(`measurer ${n}`,parseMeasurerWidget);case "molecule-renderer":return parseAndAssign(`molecule-renderer ${n}`,parseMoleculeRendererWidget);case "number-line":return parseAndAssign(`number-line ${n}`,parseNumberLineWidget);case "numeric-input":return parseAndAssign(`numeric-input ${n}`,parseNumericInputWidget);case "orderer":return parseAndAssign(`orderer ${n}`,parseOrdererWidget);case "
|
|
202
|
+
const parseWidgetsMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx.failure("PerseusWidgetsMap",rawValue)}const widgetsMap={};for(const key of Object.keys(rawValue)){const entryResult=parseWidgetsMapEntry([key,rawValue[key]],widgetsMap,ctx.forSubtree(key));if(isFailure(entryResult)){return entryResult}}return ctx.success(widgetsMap)};const parseWidgetsMapEntry=([id,widget],widgetMap,ctx)=>{const idComponentsResult=parseWidgetIdComponents(id.split(" "),ctx.forSubtree("(widget ID)"));if(isFailure(idComponentsResult)){return idComponentsResult}const[type,n]=idComponentsResult.value;function parseAndAssign(key,parse){const widgetResult=parse(widget,ctx);if(isFailure(widgetResult)){return widgetResult}widgetMap[key]=widgetResult.value;return ctx.success(undefined)}switch(type){case "categorizer":return parseAndAssign(`categorizer ${n}`,parseCategorizerWidget);case "cs-program":return parseAndAssign(`cs-program ${n}`,parseCSProgramWidget);case "definition":return parseAndAssign(`definition ${n}`,parseDefinitionWidget);case "dropdown":return parseAndAssign(`dropdown ${n}`,parseDropdownWidget);case "explanation":return parseAndAssign(`explanation ${n}`,parseExplanationWidget);case "expression":return parseAndAssign(`expression ${n}`,parseExpressionWidget);case "free-response":return parseAndAssign(`free-response ${n}`,parseFreeResponseWidget);case "grapher":return parseAndAssign(`grapher ${n}`,parseGrapherWidget);case "group":return parseAndAssign(`group ${n}`,parseGroupWidget);case "graded-group":return parseAndAssign(`graded-group ${n}`,parseGradedGroupWidget);case "graded-group-set":return parseAndAssign(`graded-group-set ${n}`,parseGradedGroupSetWidget);case "iframe":return parseAndAssign(`iframe ${n}`,parseIframeWidget);case "image":return parseAndAssign(`image ${n}`,parseImageWidget);case "input-number":return parseAndAssign(`input-number ${n}`,parseInputNumberWidget);case "interaction":return parseAndAssign(`interaction ${n}`,parseInteractionWidget);case "interactive-graph":return parseAndAssign(`interactive-graph ${n}`,parseInteractiveGraphWidget);case "label-image":return parseAndAssign(`label-image ${n}`,parseLabelImageWidget);case "matcher":return parseAndAssign(`matcher ${n}`,parseMatcherWidget);case "matrix":return parseAndAssign(`matrix ${n}`,parseMatrixWidget);case "measurer":return parseAndAssign(`measurer ${n}`,parseMeasurerWidget);case "molecule-renderer":return parseAndAssign(`molecule-renderer ${n}`,parseMoleculeRendererWidget);case "number-line":return parseAndAssign(`number-line ${n}`,parseNumberLineWidget);case "numeric-input":return parseAndAssign(`numeric-input ${n}`,parseNumericInputWidget);case "orderer":return parseAndAssign(`orderer ${n}`,parseOrdererWidget);case "phet-simulation":return parseAndAssign(`phet-simulation ${n}`,parsePhetSimulationWidget);case "plotter":return parseAndAssign(`plotter ${n}`,parsePlotterWidget);case "python-program":return parseAndAssign(`python-program ${n}`,parsePythonProgramWidget);case "radio":return parseAndAssign(`radio ${n}`,parseRadioWidget);case "sorter":return parseAndAssign(`sorter ${n}`,parseSorterWidget);case "table":return parseAndAssign(`table ${n}`,parseTableWidget);case "video":return parseAndAssign(`video ${n}`,parseVideoWidget);case "sequence":return parseAndAssign(`sequence ${n}`,parseDeprecatedWidget);case "lights-puzzle":return parseAndAssign(`lights-puzzle ${n}`,parseDeprecatedWidget);case "simulator":return parseAndAssign(`simulator ${n}`,parseDeprecatedWidget);case "transformer":return parseAndAssign(`transformer ${n}`,parseDeprecatedWidget);case "passage":return parseAndAssign(`passage ${n}`,parseDeprecatedWidget);case "passage-ref":return parseAndAssign(`passage-ref ${n}`,parseDeprecatedWidget);case "passage-ref-target":return parseAndAssign(`passage-ref-target ${n}`,parseDeprecatedWidget);default:return parseAndAssign(`${type} ${n}`,parseWidget(constant(type),any))}};const parseDeprecatedWidget=parseWidget((_,ctx)=>ctx.success("deprecated-standin"),object({}));
|
|
207
203
|
|
|
208
204
|
const parsePerseusRenderer=defaulted(object({content:defaulted(string,()=>""),widgets:defaulted((rawVal,ctx)=>parseWidgetsMap(rawVal,ctx),()=>({})),images:parseImages,metadata:any}),()=>({content:"",widgets:{},images:{}}));
|
|
209
205
|
|
|
@@ -269,35 +265,35 @@ const pluck=function(table,subKey){return ___default.default.object(___default.d
|
|
|
269
265
|
|
|
270
266
|
function getCategorizerPublicWidgetOptions(options){return {items:options.items,categories:options.categories,randomizeItems:options.randomizeItems,static:options.static}}
|
|
271
267
|
|
|
272
|
-
const defaultWidgetOptions$
|
|
268
|
+
const defaultWidgetOptions$t={items:[],categories:[],values:[],randomizeItems:false};const categorizerWidgetLogic={name:"categorizer",defaultWidgetOptions: defaultWidgetOptions$t,getPublicWidgetOptions:getCategorizerPublicWidgetOptions,accessible:false};
|
|
273
269
|
|
|
274
270
|
function getCSProgramPublicWidgetOptions(options){return options}
|
|
275
271
|
|
|
276
|
-
const DEFAULT_HEIGHT=400;const defaultWidgetOptions$
|
|
272
|
+
const DEFAULT_HEIGHT=400;const defaultWidgetOptions$s={programID:"",programType:null,settings:[{name:"",value:""}],showEditor:false,showButtons:false,height:DEFAULT_HEIGHT};const csProgramWidgetLogic={name:"cs-program",defaultWidgetOptions: defaultWidgetOptions$s,supportedAlignments:["block","full-width"],getPublicWidgetOptions:getCSProgramPublicWidgetOptions,accessible:false};
|
|
277
273
|
|
|
278
|
-
const defaultWidgetOptions$
|
|
274
|
+
const defaultWidgetOptions$r={togglePrompt:"",definition:""};const definitionWidgetLogic={name:"definition",defaultWidgetOptions: defaultWidgetOptions$r,defaultAlignment:"inline",accessible:true};
|
|
279
275
|
|
|
280
276
|
function getDropdownPublicWidgetOptions(options){return {choices:options.choices.map(choice=>({content:choice.content})),placeholder:options.placeholder,static:options.static,visibleLabel:options.visibleLabel,ariaLabel:options.ariaLabel}}
|
|
281
277
|
|
|
282
|
-
const defaultWidgetOptions$
|
|
278
|
+
const defaultWidgetOptions$q={placeholder:"",choices:[{content:"",correct:false}]};const dropdownWidgetLogic={name:"dropdown",defaultWidgetOptions: defaultWidgetOptions$q,defaultAlignment:"inline-block",getPublicWidgetOptions:getDropdownPublicWidgetOptions,accessible:true};
|
|
283
279
|
|
|
284
|
-
const defaultWidgetOptions$
|
|
280
|
+
const defaultWidgetOptions$p={showPrompt:"Explain",hidePrompt:"Hide explanation",explanation:"explanation goes here\n\nmore explanation",widgets:{}};const explanationWidgetLogic={name:"explanation",defaultWidgetOptions: defaultWidgetOptions$p,defaultAlignment:"inline",accessible:true};
|
|
285
281
|
|
|
286
282
|
function getExpressionPublicWidgetOptions(options){return {buttonSets:options.buttonSets,functions:options.functions,times:options.times,visibleLabel:options.visibleLabel,ariaLabel:options.ariaLabel,buttonsVisible:options.buttonsVisible,extraKeys:options.extraKeys}}
|
|
287
283
|
|
|
288
|
-
const currentVersion$
|
|
284
|
+
const currentVersion$2={major:2,minor:0};const defaultWidgetOptions$o={answerForms:[],times:false,buttonSets:["basic"],functions:["f","g","h"]};const expressionWidgetLogic={name:"expression",version:currentVersion$2,defaultWidgetOptions:defaultWidgetOptions$o,defaultAlignment:"inline-block",getPublicWidgetOptions:getExpressionPublicWidgetOptions,accessible:true};
|
|
289
285
|
|
|
290
|
-
const defaultWidgetOptions$
|
|
286
|
+
const defaultWidgetOptions$n={title:"",content:"",widgets:{},images:{},hint:null};const traverseChildWidgets$3=function(props,traverseRenderer){return {...props,...traverseRenderer(props)}};const gradedGroupWidgetLogic={name:"graded-group",defaultWidgetOptions: defaultWidgetOptions$n,accessible:true,traverseChildWidgets:traverseChildWidgets$3};
|
|
291
287
|
|
|
292
288
|
function getFreeResponsePublicWidgetOptions(options){return {allowUnlimitedCharacters:options.allowUnlimitedCharacters,characterLimit:options.characterLimit,placeholder:options.placeholder,question:options.question}}
|
|
293
289
|
|
|
294
|
-
const defaultWidgetOptions$
|
|
290
|
+
const defaultWidgetOptions$m={allowUnlimitedCharacters:false,characterLimit:500,placeholder:"Please provide response here",question:"",scoringCriteria:[{text:""}]};const freeResponseWidgetLogic={name:"free-response",defaultWidgetOptions: defaultWidgetOptions$m,getPublicWidgetOptions:getFreeResponsePublicWidgetOptions};
|
|
295
291
|
|
|
296
|
-
const defaultWidgetOptions$
|
|
292
|
+
const defaultWidgetOptions$l={gradedGroups:[]};const traverseChildWidgets$2=function(props,traverseRenderer){return {...props,...traverseRenderer(props)}};const gradedGroupSetWidgetLogic={name:"graded-group-set",defaultWidgetOptions: defaultWidgetOptions$l,accessible:true,traverseChildWidgets:traverseChildWidgets$2};
|
|
297
293
|
|
|
298
294
|
function getGrapherPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
299
295
|
|
|
300
|
-
const defaultWidgetOptions$
|
|
296
|
+
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};
|
|
301
297
|
|
|
302
298
|
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;}}
|
|
303
299
|
|
|
@@ -305,57 +301,49 @@ const deprecatedStandinWidgetLogic={name:"deprecated-standin",accessible:true};
|
|
|
305
301
|
|
|
306
302
|
function getIFramePublicWidgetOptions(options){return options}
|
|
307
303
|
|
|
308
|
-
const defaultWidgetOptions$
|
|
304
|
+
const defaultWidgetOptions$j={url:"",settings:[{name:"",value:""}],width:"400",height:"400",allowFullScreen:false,allowTopNavigation:false};const iframeWidgetLogic={name:"iframe",defaultWidgetOptions: defaultWidgetOptions$j,getPublicWidgetOptions:getIFramePublicWidgetOptions,accessible:false};
|
|
309
305
|
|
|
310
|
-
const defaultWidgetOptions$
|
|
306
|
+
const defaultWidgetOptions$i={title:"",range:[[0,10],[0,10]],box:[400,400],backgroundImage:{url:null,width:0,height:0},labels:[],alt:"",caption:""};const imageWidgetLogic={name:"image",defaultWidgetOptions: defaultWidgetOptions$i,supportedAlignments:["block","wrap-left","wrap-right","full-width"],defaultAlignment:"block",accessible:widgetOptions=>{const imageOptions=widgetOptions;const bgImage=imageOptions.backgroundImage;const hasBackgroundImage=bgImage.url!=null;const hasAltText=!!imageOptions.alt;const isDecorative=imageOptions.decorative===true;return hasBackgroundImage&&(hasAltText||isDecorative)}};
|
|
311
307
|
|
|
312
308
|
function getInputNumberPublicWidgetOptions(options){const{value:_,...publicWidgetOptions}=options;return publicWidgetOptions}
|
|
313
309
|
|
|
314
|
-
const defaultWidgetOptions$
|
|
310
|
+
const defaultWidgetOptions$h={value:0,simplify:"required",size:"normal",inexact:false,maxError:.1,answerType:"number",rightAlign:false};const inputNumberWidgetLogic={name:"input-number",defaultWidgetOptions: defaultWidgetOptions$h,defaultAlignment:"inline-block",accessible:false,getPublicWidgetOptions:getInputNumberPublicWidgetOptions};
|
|
315
311
|
|
|
316
|
-
const defaultWidgetOptions$
|
|
312
|
+
const defaultWidgetOptions$g={graph:{box:[400,400],labels:["x","y"],range:[[-10,10],[-10,10]],tickStep:[1,1],gridStep:[1,1],markings:"graph"},elements:[]};const interactionWidgetLogic={name:"interaction",defaultWidgetOptions: defaultWidgetOptions$g,accessible:false};
|
|
317
313
|
|
|
318
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);})}
|
|
319
315
|
|
|
320
316
|
function getInteractiveGraphPublicWidgetOptions(options){const{correct:_,...publicOptions}=options;return publicOptions}
|
|
321
317
|
|
|
322
|
-
const defaultWidgetOptions$
|
|
318
|
+
const defaultWidgetOptions$f={labels:["$x$","$y$"],labelLocation:"onAxis",range:[[-10,10],[-10,10]],step:[1,1],backgroundImage:{url:null},markings:"graph",showTooltips:false,showProtractor:false,graph:{type:"linear"},correct:{type:"linear",coords:null}};const interactiveGraphWidgetLogic={name:"interactive-graph",defaultWidgetOptions: defaultWidgetOptions$f,getPublicWidgetOptions:getInteractiveGraphPublicWidgetOptions,accessible:widgetOptions=>{const interactiveGraphOptions=widgetOptions;if(interactiveGraphOptions.showProtractor){return false}if(interactiveGraphOptions.backgroundImage?.url&&isLabeledSVG(interactiveGraphOptions.backgroundImage?.url)){return false}return true}};
|
|
323
319
|
|
|
324
|
-
function getLabelImagePublicWidgetOptions(options){return {...options,markers:options.markers.map(getLabelImageMarkerPublicData)}}function getLabelImageMarkerPublicData(marker){const{answers:_,...publicData}=marker;return publicData}
|
|
320
|
+
function getLabelImagePublicWidgetOptions(options){return {...options,markers:options.markers.map(getLabelImageMarkerPublicData)}}function getLabelImageMarkerPublicData(marker){const{answers:_,...publicData}=marker;return publicData}
|
|
325
321
|
|
|
326
|
-
const defaultWidgetOptions$
|
|
322
|
+
const defaultWidgetOptions$e={choices:[],imageAlt:"",imageUrl:"",imageWidth:0,imageHeight:0,markers:[],multipleAnswers:false,hideChoicesFromInstructions:false};const labelImageWidgetLogic={name:"label-image",defaultWidgetOptions: defaultWidgetOptions$e,getPublicWidgetOptions:getLabelImagePublicWidgetOptions,accessible:widgetOptions=>{const labelImageOptions=widgetOptions;if(labelImageOptions.imageUrl!==""&&labelImageOptions.imageAlt===""){return false}return true}};
|
|
327
323
|
|
|
328
324
|
const seededRNG=function(seed){let randomSeed=seed;return function(){let seed=randomSeed;seed=seed+0x7ed55d16+(seed<<12)&0xffffffff;seed=(seed^0xc761c23c^seed>>>19)&0xffffffff;seed=seed+0x165667b1+(seed<<5)&0xffffffff;seed=(seed+0xd3a2646c^seed<<9)&0xffffffff;seed=seed+0xfd7046c5+(seed<<3)&0xffffffff;seed=(seed^0xb55a4f09^seed>>>16)&0xffffffff;return (randomSeed=seed&0xfffffff)/0x10000000}};function shuffle(array,randomSeed,ensurePermuted=false){let random;if(typeof randomSeed==="function"){random=randomSeed;}else {random=seededRNG(randomSeed);}function isValidShuffle(shuffled){return ensurePermuted?!___default.default.isEqual(array,shuffled):true}return constrainedShuffle(array,random,isValidShuffle)}function constrainedShuffle(array,random,isValidShuffle){const maxIterations=100;const shuffled=[...array];if(shuffled.every(value=>___default.default.isEqual(value,shuffled[0]))){return shuffled}for(let i=0;i<maxIterations;i++){shuffleInPlace(shuffled,random);if(isValidShuffle(shuffled)){return shuffled}}throw new Error(`constrainedShuffle: constraint not met after ${maxIterations} attempts`)}function shuffleInPlace(a,random){for(let i=a.length-1;i>0;i--){const k=randomIntInRange(0,i,random);[a[k],a[i]]=[a[i],a[k]];}}function randomIntInRange(min,max,random){return Math.floor(random()*(max-min+1))+min}const random=seededRNG(new Date().getTime()&0xffffffff);
|
|
329
325
|
|
|
330
326
|
const shuffleMatcher=(options,problemNum)=>{const rng=seededRNG(problemNum);return {left:!options.orderMatters?options.left:shuffleDisplacingFirst$1(options.left,rng),right:shuffleDisplacingFirst$1(options.right,rng)}};function getMatcherPublicWidgetOptions(options){return {...options,left:options.orderMatters?sortAllButFirst$1(options.left):options.left,right:sortAllButFirst$1(options.right)}}function sortAllButFirst$1([first,...rest]){return [first,...rest.sort()]}function shuffleDisplacingFirst$1(array,rng){function isFirstElementDisplaced(shuffled){return shuffled[0]!==array[0]}return constrainedShuffle(array,rng,isFirstElementDisplaced)}
|
|
331
327
|
|
|
332
|
-
const defaultWidgetOptions$
|
|
328
|
+
const defaultWidgetOptions$d={left:["$x$","$y$","$z$"],right:["$1$","$2$","$3$"],labels:["test","label"],orderMatters:false,padding:true};const matcherWidgetLogic={name:"matcher",defaultWidgetOptions: defaultWidgetOptions$d,getPublicWidgetOptions:getMatcherPublicWidgetOptions,accessible:false};
|
|
333
329
|
|
|
334
330
|
function getMatrixPublicWidgetOptions(options){const{answers:_,...publicOptions}=options;return publicOptions}
|
|
335
331
|
|
|
336
|
-
const defaultWidgetOptions$
|
|
332
|
+
const defaultWidgetOptions$c={matrixBoardSize:[3,3],answers:[[]],prefix:"",suffix:"",cursorPosition:[0,0]};const matrixWidgetLogic={name:"matrix",defaultWidgetOptions: defaultWidgetOptions$c,getPublicWidgetOptions:getMatrixPublicWidgetOptions,accessible:false};
|
|
337
333
|
|
|
338
|
-
const currentVersion$
|
|
334
|
+
const currentVersion$1={major:1,minor:0};const defaultWidgetOptions$b={box:[480,480],image:{},showProtractor:true,showRuler:false,rulerLabel:"",rulerTicks:10,rulerPixels:40,rulerLength:10};const measurerWidgetLogic={name:"measurer",version:currentVersion$1,defaultWidgetOptions:defaultWidgetOptions$b,accessible:false};
|
|
339
335
|
|
|
340
336
|
function getNumberLinePublicWidgetOptions(options){const{correctX:_,correctRel:__,...publicOptions}=options;return publicOptions}
|
|
341
337
|
|
|
342
|
-
const defaultWidgetOptions$
|
|
338
|
+
const defaultWidgetOptions$a={range:[0,10],labelRange:[null,null],labelStyle:"decimal",labelTicks:true,divisionRange:[1,12],numDivisions:5,snapDivisions:2,tickStep:null,correctRel:"eq",correctX:null,initialX:null,showTooltips:false};const numberLineWidgetLogic={name:"number-line",defaultWidgetOptions: defaultWidgetOptions$a,getPublicWidgetOptions:getNumberLinePublicWidgetOptions,accessible:false};
|
|
343
339
|
|
|
344
340
|
function getNumericInputAnswerPublicData(answer){const{answerForms,simplify,status}=answer;return {answerForms,simplify,status}}function getNumericInputPublicWidgetOptions(options){const{answers,...publicWidgetOptions}=options;return {...publicWidgetOptions,answers:answers.map(getNumericInputAnswerPublicData)}}
|
|
345
341
|
|
|
346
|
-
const defaultWidgetOptions$
|
|
342
|
+
const defaultWidgetOptions$9={answers:[{value:null,status:"correct",message:"",simplify:"required",answerForms:[],strict:false,maxError:null}],size:"normal",coefficient:false,labelText:"",rightAlign:false};const numericInputWidgetLogic={name:"numeric-input",defaultWidgetOptions: defaultWidgetOptions$9,defaultAlignment:"inline-block",getPublicWidgetOptions:getNumericInputPublicWidgetOptions,accessible:true};
|
|
347
343
|
|
|
348
344
|
function getOrdererPublicWidgetOptions(fullOptions){const{options,height,layout}=fullOptions;return {options,height,layout}}
|
|
349
345
|
|
|
350
|
-
const defaultWidgetOptions$
|
|
351
|
-
|
|
352
|
-
const defaultWidgetOptions$a={passageTitle:"",passageText:"",footnotes:"",showLineNumbers:true};const passageWidgetLogic={name:"passage",defaultWidgetOptions: defaultWidgetOptions$a,accessible:false};
|
|
353
|
-
|
|
354
|
-
const currentVersion$1={major:0,minor:1};const defaultWidgetOptions$9={passageNumber:1,referenceNumber:1,summaryText:""};
|
|
355
|
-
|
|
356
|
-
const passageRefWidgetLogic={name:"passage-ref",version:currentVersion$1,defaultWidgetOptions:defaultWidgetOptions$9,defaultAlignment:"inline",accessible:false};
|
|
357
|
-
|
|
358
|
-
const defaultWidgetOptions$8={content:""};const passageRefTargetWidgetLogic={name:"passage-ref-target",defaultWidgetOptions: defaultWidgetOptions$8,defaultAlignment:"inline",accessible:false};
|
|
346
|
+
const defaultWidgetOptions$8={correctOptions:[{content:"$x$"}],otherOptions:[{content:"$y$"}],height:"normal",layout:"horizontal"};const ordererWidgetLogic={name:"orderer",defaultWidgetOptions: defaultWidgetOptions$8,getPublicWidgetOptions:getOrdererPublicWidgetOptions,accessible:false};
|
|
359
347
|
|
|
360
348
|
const defaultWidgetOptions$7={url:"",description:""};const phetSimulationWidgetLogic={name:"phet-simulation",defaultWidgetOptions: defaultWidgetOptions$7,accessible:true};
|
|
361
349
|
|
|
@@ -379,7 +367,7 @@ const defaultRows=4;const defaultColumns=1;const answers=new Array(defaultRows).
|
|
|
379
367
|
|
|
380
368
|
const defaultWidgetOptions$1={location:""};const videoWidgetLogic={name:"video",defaultWidgetOptions: defaultWidgetOptions$1,supportedAlignments:["block","wrap-left","wrap-right","full-width"],defaultAlignment:"block",accessible:true};
|
|
381
369
|
|
|
382
|
-
const widgets=new Registry("Core widget registry");function registerWidget(type,logic){widgets.set(type,logic);}function isWidgetRegistered(type){const widgetLogic=widgets.get(type);return Boolean(widgetLogic)}function getCurrentVersion(type){const widgetLogic=widgets.get(type);return widgetLogic?.version||{major:0,minor:0}}const getPublicWidgetOptionsFunction=type=>{return widgets.get(type)?.getPublicWidgetOptions??(i=>i)};function getDefaultWidgetOptions(type){const widgetLogic=widgets.get(type);return widgetLogic?.defaultWidgetOptions||{}}function isAccessible(type,widgetOptions){const accessible=widgets.get(type)?.accessible;return typeof accessible==="function"?accessible(widgetOptions):!!accessible}const traverseChildWidgets$1=(widgetInfo,traverseRenderer)=>{if(!traverseRenderer){throw new PerseusError("traverseRenderer must be provided, but was not",Errors.Internal)}if(!widgetInfo||!widgetInfo.type||!widgets.get(widgetInfo.type)){return widgetInfo}const widgetExports=widgets.get(widgetInfo.type);const props=widgetInfo.options;if(widgetExports?.traverseChildWidgets!=null&&props!=null){const newProps=widgetExports.traverseChildWidgets(props,traverseRenderer);return {...widgetInfo,options:newProps}}return widgetInfo};const getSupportedAlignments=type=>{const widgetLogic=widgets.get(type);if(!widgetLogic?.supportedAlignments?.[0]){return ["default"]}return widgetLogic?.supportedAlignments};const getDefaultAlignment=type=>{const widgetLogic=widgets.get(type);if(!widgetLogic?.defaultAlignment){return "block"}return widgetLogic.defaultAlignment};const getAlignmentClassName=(type,alignment)=>{switch(alignment){case "block":return " widget-block";case "inline-block":return " widget-inline-block";case "inline":return " widget-inline";case "wrap-left":return " widget-wrap-left";case "wrap-right":return " widget-wrap-right";case "full-width":return " widget-full-width";case "default":return getDefaultAlignment(type);default:return ""}};function registerCoreWidgets(){const widgets=[categorizerWidgetLogic,csProgramWidgetLogic,definitionWidgetLogic,deprecatedStandinWidgetLogic,dropdownWidgetLogic,explanationWidgetLogic,expressionWidgetLogic,gradedGroupWidgetLogic,gradedGroupSetWidgetLogic,grapherWidgetLogic,groupWidgetLogic,iframeWidgetLogic,imageWidgetLogic,inputNumberWidgetLogic,interactionWidgetLogic,interactiveGraphWidgetLogic,labelImageWidgetLogic,matcherWidgetLogic,matrixWidgetLogic,measurerWidgetLogic,numberLineWidgetLogic,numericInputWidgetLogic,ordererWidgetLogic,
|
|
370
|
+
const widgets=new Registry("Core widget registry");function registerWidget(type,logic){widgets.set(type,logic);}function isWidgetRegistered(type){const widgetLogic=widgets.get(type);return Boolean(widgetLogic)}function getCurrentVersion(type){const widgetLogic=widgets.get(type);return widgetLogic?.version||{major:0,minor:0}}const getPublicWidgetOptionsFunction=type=>{return widgets.get(type)?.getPublicWidgetOptions??(i=>i)};function getDefaultWidgetOptions(type){const widgetLogic=widgets.get(type);return widgetLogic?.defaultWidgetOptions||{}}function isAccessible(type,widgetOptions){const accessible=widgets.get(type)?.accessible;return typeof accessible==="function"?accessible(widgetOptions):!!accessible}const traverseChildWidgets$1=(widgetInfo,traverseRenderer)=>{if(!traverseRenderer){throw new PerseusError("traverseRenderer must be provided, but was not",Errors.Internal)}if(!widgetInfo||!widgetInfo.type||!widgets.get(widgetInfo.type)){return widgetInfo}const widgetExports=widgets.get(widgetInfo.type);const props=widgetInfo.options;if(widgetExports?.traverseChildWidgets!=null&&props!=null){const newProps=widgetExports.traverseChildWidgets(props,traverseRenderer);return {...widgetInfo,options:newProps}}return widgetInfo};const getSupportedAlignments=type=>{const widgetLogic=widgets.get(type);if(!widgetLogic?.supportedAlignments?.[0]){return ["default"]}return widgetLogic?.supportedAlignments};const getDefaultAlignment=type=>{const widgetLogic=widgets.get(type);if(!widgetLogic?.defaultAlignment){return "block"}return widgetLogic.defaultAlignment};const getAlignmentClassName=(type,alignment)=>{switch(alignment){case "block":return " widget-block";case "inline-block":return " widget-inline-block";case "inline":return " widget-inline";case "wrap-left":return " widget-wrap-left";case "wrap-right":return " widget-wrap-right";case "full-width":return " widget-full-width";case "default":return getDefaultAlignment(type);default:return ""}};function registerCoreWidgets(){const widgets=[categorizerWidgetLogic,csProgramWidgetLogic,definitionWidgetLogic,deprecatedStandinWidgetLogic,dropdownWidgetLogic,explanationWidgetLogic,expressionWidgetLogic,gradedGroupWidgetLogic,gradedGroupSetWidgetLogic,grapherWidgetLogic,groupWidgetLogic,iframeWidgetLogic,imageWidgetLogic,inputNumberWidgetLogic,interactionWidgetLogic,interactiveGraphWidgetLogic,labelImageWidgetLogic,matcherWidgetLogic,matrixWidgetLogic,measurerWidgetLogic,numberLineWidgetLogic,numericInputWidgetLogic,ordererWidgetLogic,phetSimulationWidgetLogic,plotterWidgetLogic,pythonProgramWidgetLogic,radioWidgetLogic,sorterWidgetLogic,tableWidgetLogic,videoWidgetLogic];widgets.forEach(w=>{registerWidget(w.name,w);});}
|
|
383
371
|
|
|
384
372
|
var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
|
|
385
373
|
__proto__: null,
|
|
@@ -562,9 +550,6 @@ exports.parseAndMigratePerseusArticle = parseAndMigratePerseusArticle;
|
|
|
562
550
|
exports.parseAndMigratePerseusItem = parseAndMigratePerseusItem;
|
|
563
551
|
exports.parseAndMigrateUserInputMap = parseAndMigrateUserInputMap;
|
|
564
552
|
exports.parsePerseusItem = parsePerseusItem;
|
|
565
|
-
exports.passageLogic = passageWidgetLogic;
|
|
566
|
-
exports.passageRefLogic = passageRefWidgetLogic;
|
|
567
|
-
exports.passageRefTargetLogic = passageRefTargetWidgetLogic;
|
|
568
553
|
exports.phetSimulationLogic = phetSimulationWidgetLogic;
|
|
569
554
|
exports.plotterLogic = plotterWidgetLogic;
|
|
570
555
|
exports.plotterPlotTypes = plotterPlotTypes;
|