@khanacademy/perseus-core 19.2.0 → 19.3.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
@@ -7,6 +7,8 @@ export type { Coords } from "./utils/grapher-types";
7
7
  export type * from "./validation.types";
8
8
  export { default as getMatrixSize } from "./utils/get-matrix-size";
9
9
  export { default as getDecimalSeparator } from "./utils/get-decimal-separator";
10
+ export { getDivideSymbol } from "./utils/get-divide-symbol";
11
+ export { getDivideSymbolForTex } from "./utils/get-divide-symbol";
10
12
  export { approximateEqual, approximateDeepEqual } from "./utils/equality";
11
13
  export { addWidget, getWidgetIdsFromContent, getWidgetIdsFromContentByType, } from "./utils/widget-id-utils";
12
14
  export { default as deepClone } from "./utils/deep-clone";
package/dist/index.js CHANGED
@@ -35,6 +35,8 @@ function getMatrixSize(matrix){const matrixSize=[1,1];matrix.forEach((matrixRow,
35
35
 
36
36
  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]??"."}};
37
37
 
38
+ const localesThatUseColon=["az","bg","cs","da","de","hu","hy","id","it","ky","lt","lv","nb","nl","pl","pt-pt","ro","sv","uk","vi","ro","ru"];const getDivideSymbol=locale=>{if(localesThatUseColon.includes(locale)){return ":"}return "/"};const getDivideSymbolForTex=locale=>{const divideSymbol=getDivideSymbol(locale);return divideSymbol==="/"?"\\div":divideSymbol};
39
+
38
40
  function approximateEqual(x,y){if(typeof x==="number"&&typeof y==="number"){return Math.abs(x-y)<1e-9}return x===y}function approximateDeepEqual(x,y){if(Array.isArray(x)&&Array.isArray(y)){if(x.length!==y.length){return false}for(let i=0;i<x.length;i++){if(!approximateDeepEqual(x[i],y[i])){return false}}return true}if(Array.isArray(x)||Array.isArray(y)){return false}if(typeof x==="function"&&typeof y==="function"){return approximateEqual(x,y)}if(typeof x==="function"||typeof y==="function"){return false}if(typeof x==="object"&&typeof y==="object"&&!!x&&!!y){return x===y||___default.default.all(x,function(v,k){return approximateDeepEqual(y[k],v)})&&___default.default.all(y,function(v,k){return approximateDeepEqual(x[k],v)})}if(typeof x==="object"&&!!x||typeof y==="object"&&!!y){return false}return approximateEqual(x,y)}
39
41
 
40
42
  function addWidget(id){return `[[☃ ${id}]]`}function getWidgetRegex(){return /\[\[☃ ([A-Za-z0-9- ]+)\]\]/g}function getWidgetIdsFromContent(content){const widgets=[];const localWidgetRegex=getWidgetRegex();let match=localWidgetRegex.exec(content);while(match!==null){widgets.push(match[1]);match=localWidgetRegex.exec(content);}return widgets}function getWidgetIdsFromContentByType(type,content,widgetMap){const rv=[];const widgetIdsInContent=getWidgetIdsFromContent(content);widgetIdsInContent.forEach(widgetId=>{const widget=widgetMap[widgetId];if(widget?.type===type){rv.push(widgetId);}});return rv}
@@ -252,7 +254,7 @@ const parseUserInputMap=(rawValue,ctx)=>{if(!isPlainObject(rawValue)){return ctx
252
254
 
253
255
  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.")}}
254
256
 
255
- const libName="@khanacademy/perseus-core";const libVersion="19.2.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
257
+ const libName="@khanacademy/perseus-core";const libVersion="19.3.0";perseusUtils.addLibraryVersionToPerseusDebug(libName,libVersion);
256
258
 
257
259
  const Errors=Object.freeze({Unknown:"Unknown",Internal:"Internal",InvalidInput:"InvalidInput",NotAllowed:"NotAllowed",TransientService:"TransientService",Service:"Service"});
258
260
 
@@ -443,6 +445,8 @@ exports.getCategorizerPublicWidgetOptions = getCategorizerPublicWidgetOptions;
443
445
  exports.getDataUrl = getDataUrl;
444
446
  exports.getDecimalSeparator = getDecimalSeparator;
445
447
  exports.getDefaultAnswerArea = getDefaultAnswerArea;
448
+ exports.getDivideSymbol = getDivideSymbol;
449
+ exports.getDivideSymbolForTex = getDivideSymbolForTex;
446
450
  exports.getDropdownPublicWidgetOptions = getDropdownPublicWidgetOptions;
447
451
  exports.getExpressionPublicWidgetOptions = getExpressionPublicWidgetOptions;
448
452
  exports.getFreeResponsePublicWidgetOptions = getFreeResponsePublicWidgetOptions;