@khanacademy/perseus-core 19.5.0 → 20.0.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/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export type { PerseusAnalyticsEvent, AnalyticsEventHandlerFn } from "./analytics
2
2
  export type { KEScore, RendererInterface, MarkerType, InteractiveMarkerType, Relationship, Alignment, RecursiveReadonly, } from "./types";
3
3
  export type { KeypadKey, KeypadConfiguration, KeypadContextRendererInterface, } from "./keypad";
4
4
  export type { ErrorKind } from "./error/errors";
5
+ export { default as ErrorCodes, type ErrorCode } from "./error-codes";
5
6
  export type { FunctionTypeMappingKeys } from "./utils/grapher-util";
6
7
  export type { Coords } from "./utils/grapher-types";
7
8
  export type * from "./validation.types";
package/dist/index.js CHANGED
@@ -31,6 +31,8 @@ function _interopNamespaceCompat(e) {
31
31
  var ___default = /*#__PURE__*/_interopDefaultCompat(_);
32
32
  var KAS__namespace = /*#__PURE__*/_interopNamespaceCompat(KAS);
33
33
 
34
+ const APPROXIMATED_PI_ERROR="APPROXIMATED_PI_ERROR";const CHOOSE_CORRECT_NUM_ERROR="CHOOSE_CORRECT_NUM_ERROR";const EXTRA_SYMBOLS_ERROR="EXTRA_SYMBOLS_ERROR";const FILL_ALL_CELLS_ERROR="FILL_ALL_CELLS_ERROR";const INVALID_CHOICE_SELECTION="INVALID_CHOICE_SELECTION";const INVALID_SELECTION_ERROR="INVALID_SELECTION_ERROR";const MISSING_PERCENT_ERROR="MISSING_PERCENT_ERROR";const MULTIPLICATION_SIGN_ERROR="MULTIPLICATION_SIGN_ERROR";const NEEDS_TO_BE_SIMPLIFIED_ERROR="NEEDS_TO_BE_SIMPLIFIED_ERROR";const NOT_NONE_ABOVE_ERROR="NOT_NONE_ABOVE_ERROR";const USER_INPUT_EMPTY="USER_INPUT_EMPTY";const USER_INPUT_TOO_LONG="USER_INPUT_TOO_LONG";const WRONG_CASE_ERROR="WRONG_CASE_ERROR";const WRONG_LETTER_ERROR="WRONG_LETTER_ERROR";const ErrorCodes={APPROXIMATED_PI_ERROR,CHOOSE_CORRECT_NUM_ERROR,EXTRA_SYMBOLS_ERROR,FILL_ALL_CELLS_ERROR,INVALID_CHOICE_SELECTION,INVALID_SELECTION_ERROR,MISSING_PERCENT_ERROR,MULTIPLICATION_SIGN_ERROR,NEEDS_TO_BE_SIMPLIFIED_ERROR,NOT_NONE_ABOVE_ERROR,USER_INPUT_EMPTY,USER_INPUT_TOO_LONG,WRONG_CASE_ERROR,WRONG_LETTER_ERROR};
35
+
34
36
  function getMatrixSize(matrix){const matrixSize=[1,1];matrix.forEach((matrixRow,row)=>{let rowWidth=0;matrixRow.forEach((matrixCol,col)=>{if(matrixCol!=null&&matrixCol.toString().length){rowWidth=col+1;}});matrixSize[1]=Math.max(matrixSize[1],rowWidth);if(rowWidth>0){matrixSize[0]=Math.max(matrixSize[0],row+1);}});return matrixSize}
35
37
 
36
38
  const getDecimalSeparator=locale=>{switch(locale){case "ka":return ",";default:const numberWithDecimalSeparator=1.1;const match=new Intl.NumberFormat(locale).format(numberWithDecimalSeparator).match(/[^\d\u0661\u06F1\u0967\u09e7]/);return match?.[0]??"."}};
@@ -254,7 +256,7 @@ const parseUserInputMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx
254
256
 
255
257
  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 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 throwErrorIfCheatingDetected(){if(!isRealJSONParse(JSON.parse)){throw new Error("Something went wrong.")}}
256
258
 
257
- const libName="@khanacademy/perseus-core";const libVersion="19.5.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
259
+ const libName="@khanacademy/perseus-core";const libVersion="20.0.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
258
260
 
259
261
  const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
260
262
 
@@ -413,6 +415,7 @@ function generateImageOptions(options){const defaultImageOptions={backgroundImag
413
415
  registerCoreWidgets();
414
416
 
415
417
  exports.CoreWidgetRegistry = coreWidgetRegistry;
418
+ exports.ErrorCodes = ErrorCodes;
416
419
  exports.Errors = Errors;
417
420
  exports.GrapherUtil = grapherUtil;
418
421
  exports.ItemExtras = ItemExtras;