@khanacademy/perseus-core 16.1.0 → 16.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.
- package/dist/es/index.js +3 -3
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/number-line-user-input.d.ts +0 -2
- package/dist/types.d.ts +6 -1
- package/dist/validation.types.d.ts +8 -8
- package/dist/widgets/matcher/matcher-util.d.ts +2 -10
- package/dist/widgets/sorter/sorter-util.d.ts +2 -5
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -108,6 +108,7 @@ export { default as getGroupPublicWidgetOptions } from "./widgets/group/group-ut
|
|
|
108
108
|
export { default as getInteractiveGraphPublicWidgetOptions, type InteractiveGraphPublicWidgetOptions, } from "./widgets/interactive-graph/interactive-graph-util";
|
|
109
109
|
export { default as getLabelImagePublicWidgetOptions } from "./widgets/label-image/label-image-util";
|
|
110
110
|
export { default as getSorterPublicWidgetOptions, shuffleSorter, } from "./widgets/sorter/sorter-util";
|
|
111
|
+
export type { SorterPublicWidgetOptions } from "./widgets/sorter/sorter-util";
|
|
111
112
|
export type { LabelImagePublicWidgetOptions } from "./widgets/label-image/label-image-util";
|
|
112
113
|
export type { LabelImageMarkerPublicData } from "./widgets/label-image/label-image-util";
|
|
113
114
|
export { default as getDropdownPublicWidgetOptions } from "./widgets/dropdown/dropdown-util";
|
package/dist/index.js
CHANGED
|
@@ -209,7 +209,7 @@ const parsePerseusItem$1=object({question:parsePerseusRenderer,hints:defaulted(a
|
|
|
209
209
|
|
|
210
210
|
function parsePerseusItem(json){if(isRealJSONParse(JSON.parse)){return JSON.parse(json)}throw new Error("Something went wrong.")}function parseAndMigratePerseusItem(data){throwErrorIfCheatingDetected();const object=typeof data==="string"?JSON.parse(data):data;const result=parse(object,parsePerseusItem$1);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}function parseAndMigratePerseusArticle(data){throwErrorIfCheatingDetected();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 throwErrorIfCheatingDetected(){if(!isRealJSONParse(JSON.parse)){throw new Error("Something went wrong.")}}
|
|
211
211
|
|
|
212
|
-
const libName="@khanacademy/perseus-core";const libVersion="16.1.
|
|
212
|
+
const libName="@khanacademy/perseus-core";const libVersion="16.1.1";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
213
213
|
|
|
214
214
|
const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
|
|
215
215
|
|
|
@@ -275,7 +275,7 @@ const defaultWidgetOptions$h={choices:[],imageAlt:"",imageUrl:"",imageWidth:0,im
|
|
|
275
275
|
|
|
276
276
|
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);
|
|
277
277
|
|
|
278
|
-
const shuffleMatcher=
|
|
278
|
+
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)}
|
|
279
279
|
|
|
280
280
|
const defaultWidgetOptions$g={left:["$x$","$y$","$z$"],right:["$1$","$2$","$3$"],labels:["test","label"],orderMatters:false,padding:true};const matcherWidgetLogic={name:"matcher",defaultWidgetOptions: defaultWidgetOptions$g,getPublicWidgetOptions:getMatcherPublicWidgetOptions,accessible:false};
|
|
281
281
|
|
|
@@ -317,7 +317,7 @@ function getRadioChoicePublicData(choice){const{content,isNoneOfTheAbove}=choice
|
|
|
317
317
|
|
|
318
318
|
const currentVersion={major:2,minor:0};const defaultWidgetOptions$4={choices:[{},{},{},{}],randomize:false,hasNoneOfTheAbove:false,multipleSelect:false,countChoices:false,deselectEnabled:false};const radioWidgetLogic={name:"radio",version:currentVersion,defaultWidgetOptions:defaultWidgetOptions$4,getPublicWidgetOptions:getRadioPublicWidgetOptions,accessible:true};
|
|
319
319
|
|
|
320
|
-
function getSorterPublicWidgetOptions(options){return {...options,correct:sortAllButFirst(options.correct)}}function shuffleSorter(
|
|
320
|
+
function getSorterPublicWidgetOptions(options){return {...options,correct:sortAllButFirst(options.correct)}}function shuffleSorter(options,problemNum){const{correct}=options;const rng=seededRNG(problemNum??0);return shuffleDisplacingFirst(correct,rng)}function sortAllButFirst([first,...rest]){return [first,...rest.sort()]}function shuffleDisplacingFirst(array,rng){function isFirstElementDisplaced(shuffled){return shuffled[0]!==array[0]}return constrainedShuffle(array,rng,isFirstElementDisplaced)}
|
|
321
321
|
|
|
322
322
|
const defaultWidgetOptions$3={correct:["$x$","$y$","$z$"],layout:"horizontal",padding:true};const sorterWidgetLogic={name:"sorter",defaultWidgetOptions: defaultWidgetOptions$3,getPublicWidgetOptions:getSorterPublicWidgetOptions,accessible:false};
|
|
323
323
|
|