@khanacademy/perseus-core 7.0.2 → 7.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 +5 -3
- package/dist/es/index.js.map +1 -1
- package/dist/feature-flags.d.ts +12 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/parse-perseus-json/perseus-parsers/dropdown-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/dropdown-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/expression-user-input.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/expression-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/interactive-graph-user-input.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/interactive-graph-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/interactive-graph-widget.d.ts +2 -1
- package/dist/parse-perseus-json/perseus-parsers/numeric-input-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/numeric-input-user-input.typetest.d.ts +1 -0
- package/dist/parse-perseus-json/perseus-parsers/radio-user-input.d.ts +3 -0
- package/dist/parse-perseus-json/perseus-parsers/radio-user-input.typetest.d.ts +1 -0
- package/dist/validation.types.d.ts +282 -0
- package/dist/validation.typetest.d.ts +1 -0
- package/dist/widgets/categorizer/categorizer-util.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IMPORTANT:
|
|
3
|
+
* 1. Do not delete this file or the variable below.
|
|
4
|
+
* This will be the definition of the active feature flags in Perseus
|
|
5
|
+
* that will hide features/changes under development. This will be used
|
|
6
|
+
* by flags of APIOptions type.
|
|
7
|
+
* 2. Do cleanup unused feature flags
|
|
8
|
+
* 3. When no active feature flag is available value will be:
|
|
9
|
+
* export const PerseusFeatureFlags = [];
|
|
10
|
+
*/
|
|
11
|
+
declare const PerseusFeatureFlags: string[];
|
|
12
|
+
export default PerseusFeatureFlags;
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type { KeypadKey, KeypadConfiguration, KeypadContextRendererInterface, }
|
|
|
4
4
|
export type { ErrorKind } from "./error/errors";
|
|
5
5
|
export type { FunctionTypeMappingKeys } from "./utils/grapher-util";
|
|
6
6
|
export type { Coords } from "./utils/grapher-types";
|
|
7
|
+
export type * from "./validation.types";
|
|
7
8
|
export { default as getMatrixSize } from "./utils/get-matrix-size";
|
|
8
9
|
export { default as getDecimalSeparator } from "./utils/get-decimal-separator";
|
|
9
10
|
export { approximateEqual, approximateDeepEqual } from "./utils/equality";
|
|
@@ -89,6 +90,7 @@ export type * from "./widgets/logic-export.types";
|
|
|
89
90
|
export * as CoreWidgetRegistry from "./widgets/core-widget-registry";
|
|
90
91
|
export { default as getOrdererPublicWidgetOptions } from "./widgets/orderer/orderer-util";
|
|
91
92
|
export { default as getCategorizerPublicWidgetOptions } from "./widgets/categorizer/categorizer-util";
|
|
93
|
+
export type { CategorizerPublicWidgetOptions } from "./widgets/categorizer/categorizer-util";
|
|
92
94
|
export { default as getCSProgramPublicWidgetOptions } from "./widgets/cs-program/cs-program-util";
|
|
93
95
|
export { default as getExpressionPublicWidgetOptions } from "./widgets/expression/expression-util";
|
|
94
96
|
export type { ExpressionPublicWidgetOptions } from "./widgets/expression/expression-util";
|
|
@@ -108,3 +110,4 @@ export { default as getMatrixPublicWidgetOptions } from "./widgets/matrix/matrix
|
|
|
108
110
|
export { default as getPlotterPublicWidgetOptions } from "./widgets/plotter/plotter-util";
|
|
109
111
|
export { default as getMatcherPublicWidgetOptions, shuffleMatcher, } from "./widgets/matcher/matcher-util";
|
|
110
112
|
export { shuffle, seededRNG, random } from "./utils/random-util";
|
|
113
|
+
export { default as PerseusFeatureFlags } from "./feature-flags";
|
package/dist/index.js
CHANGED
|
@@ -174,7 +174,7 @@ const parsePythonProgramWidget=parseWidget(constant("python-program"),object({pr
|
|
|
174
174
|
|
|
175
175
|
const currentVersion$3={major:2,minor:0};function deriveNumCorrect(options){const{choices,numCorrect}=options;return numCorrect??choices.filter(c=>c.correct).length}const widgetOptionsUpgrades$2={"2":v1props=>{const upgraded={...v1props,numCorrect:deriveNumCorrect(v1props)};return upgraded},"1":v0props=>{const{noneOfTheAbove,...rest}=v0props;if(noneOfTheAbove){throw new Error("radio widget v0 no longer supports auto noneOfTheAbove")}return {...rest,hasNoneOfTheAbove:false}}};const defaultWidgetOptions$v={choices:[{},{},{},{}],displayCount:null,randomize:false,hasNoneOfTheAbove:false,multipleSelect:false,countChoices:false,deselectEnabled:false};
|
|
176
176
|
|
|
177
|
-
const version2=optional(object({major:constant(2),minor:number}));const parseRadioWidgetV2=parseWidgetWithVersion(version2,constant("radio"),object({numCorrect:optional(number),choices:array(object({content:defaulted(string,()=>""),clue:optional(string),correct:optional(boolean),isNoneOfTheAbove:optional(boolean),widgets:
|
|
177
|
+
const parseWidgetsMapOrUndefined=defaulted((rawVal,ctx)=>parseWidgetsMap(rawVal,ctx),()=>undefined);const version2=optional(object({major:constant(2),minor:number}));const parseRadioWidgetV2=parseWidgetWithVersion(version2,constant("radio"),object({numCorrect:optional(number),choices:array(object({content:defaulted(string,()=>""),clue:optional(string),correct:optional(boolean),isNoneOfTheAbove:optional(boolean),widgets:parseWidgetsMapOrUndefined})),hasNoneOfTheAbove:optional(boolean),countChoices:optional(boolean),randomize:optional(boolean),multipleSelect:optional(boolean),deselectEnabled:optional(boolean),onePerLine:optional(boolean),displayCount:optional(any),noneOfTheAbove:optional(constant(false))}));const version1=optional(object({major:constant(1),minor:number}));const parseRadioWidgetV1=parseWidgetWithVersion(version1,constant("radio"),object({choices:array(object({content:defaulted(string,()=>""),clue:optional(string),correct:optional(boolean),isNoneOfTheAbove:optional(boolean),widgets:parseWidgetsMapOrUndefined})),hasNoneOfTheAbove:optional(boolean),countChoices:optional(boolean),randomize:optional(boolean),multipleSelect:optional(boolean),deselectEnabled:optional(boolean),onePerLine:optional(boolean),displayCount:optional(any),noneOfTheAbove:optional(constant(false))}));function migrateV1ToV2(widget){const{options}=widget;return {...widget,version:{major:2,minor:0},options:{...options,numCorrect:deriveNumCorrect(options)}}}const version0=optional(object({major:constant(0),minor:number}));const parseRadioWidgetV0=parseWidgetWithVersion(version0,constant("radio"),object({choices:array(object({content:defaulted(string,()=>""),clue:optional(string),correct:optional(boolean),isNoneOfTheAbove:optional(boolean),widgets:parseWidgetsMapOrUndefined})),hasNoneOfTheAbove:optional(boolean),countChoices:optional(boolean),randomize:optional(boolean),multipleSelect:optional(boolean),deselectEnabled:optional(boolean),onePerLine:optional(boolean),displayCount:optional(any),noneOfTheAbove:optional(constant(false))}));function migrateV0ToV1(widget){const{options}=widget;const{noneOfTheAbove:_,...rest}=options;return {...widget,version:{major:1,minor:0},options:{...rest,hasNoneOfTheAbove:false}}}const parseRadioWidget=versionedWidgetOptions(2,parseRadioWidgetV2).withMigrationFrom(1,parseRadioWidgetV1,migrateV1ToV2).withMigrationFrom(0,parseRadioWidgetV0,migrateV0ToV1).parser;
|
|
178
178
|
|
|
179
179
|
const parseSorterWidget=parseWidget(constant("sorter"),object({correct:array(string),padding:boolean,layout:enumeration("horizontal","vertical")}));
|
|
180
180
|
|
|
@@ -196,7 +196,7 @@ const parsePerseusItem$1=object({question:parsePerseusRenderer,hints:defaulted(a
|
|
|
196
196
|
|
|
197
197
|
function parsePerseusItem(json){if(isRealJSONParse(JSON.parse)){return JSON.parse(json)}throw new Error("Something went wrong.")}function parseAndMigratePerseusItem(json){throwErrorIfCheatingDetected();const object=JSON.parse(json);const result=parse(object,parsePerseusItem$1);if(isFailure(result)){return failure({message:result.detail,invalidObject:object})}return result}function parseAndMigratePerseusArticle(json){throwErrorIfCheatingDetected();const object=JSON.parse(json);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.")}}
|
|
198
198
|
|
|
199
|
-
const libName="@khanacademy/perseus-core";const libVersion="7.
|
|
199
|
+
const libName="@khanacademy/perseus-core";const libVersion="7.1.1";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
|
|
200
200
|
|
|
201
201
|
const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
|
|
202
202
|
|
|
@@ -327,12 +327,15 @@ const DEFAULT_STATIC=false;const upgradeWidgetInfoToLatestVersion=oldWidgetInfo=
|
|
|
327
327
|
|
|
328
328
|
function splitPerseusItem(originalItem){const item=___default.default.clone(originalItem);const originalWidgets=item.widgets??{};const upgradedWidgets=getUpgradedWidgetOptions(originalWidgets);const splitWidgets={};for(const[id,widget]of Object.entries(upgradedWidgets)){const publicWidgetOptionsFun=getPublicWidgetOptionsFunction(widget.type);splitWidgets[id]={...widget,options:publicWidgetOptionsFun(widget.options)};}return {...item,widgets:splitWidgets}}
|
|
329
329
|
|
|
330
|
+
const PerseusFeatureFlags=["new-radio-widget"];
|
|
331
|
+
|
|
330
332
|
exports.CoreWidgetRegistry = coreWidgetRegistry;
|
|
331
333
|
exports.Errors = Errors;
|
|
332
334
|
exports.GrapherUtil = grapherUtil;
|
|
333
335
|
exports.ItemExtras = ItemExtras;
|
|
334
336
|
exports.PerseusError = PerseusError;
|
|
335
337
|
exports.PerseusExpressionAnswerFormConsidered = PerseusExpressionAnswerFormConsidered;
|
|
338
|
+
exports.PerseusFeatureFlags = PerseusFeatureFlags;
|
|
336
339
|
exports.addWidget = addWidget;
|
|
337
340
|
exports.approximateDeepEqual = approximateDeepEqual;
|
|
338
341
|
exports.approximateEqual = approximateEqual;
|