@khanacademy/perseus-core 5.4.2 → 7.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/es/index.js CHANGED
@@ -12,6 +12,7 @@ function getMatrixSize(matrix) {
12
12
  _(matrix).each((matrixRow, row) => {
13
13
  let rowWidth = 0;
14
14
  _(matrixRow).each((matrixCol, col) => {
15
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
15
16
  if (matrixCol != null && matrixCol.toString().length) {
16
17
  rowWidth = col + 1;
17
18
  }
@@ -459,6 +460,7 @@ const Exponential = _.extend({}, PlotDefaults, {
459
460
  return a * Math.exp(b * x) + c;
460
461
  },
461
462
  getEquationString: function (coords, asymptote) {
463
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
462
464
  if (!asymptote) {
463
465
  return null;
464
466
  }
@@ -516,6 +518,7 @@ const Logarithm = _.extend({}, PlotDefaults, {
516
518
  return a * Math.log(b * x + c);
517
519
  },
518
520
  getEquationString: function (coords, asymptote) {
521
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
519
522
  if (!asymptote) {
520
523
  return null;
521
524
  }
@@ -666,8 +669,6 @@ function buildTestData(testObject) {
666
669
  return `{"data":{"assessmentItem":{"__typename":"AssessmentItemOrError","error":null,"item":{"__typename":"AssessmentItem","id":"x890b3c70f3e8f4a6","itemData":"${testObject}","problemType":"Type 1","sha":"c7284a3ad65214b4e62bccce236d92f7f5d35941"}}}}`;
667
670
  }
668
671
 
669
- process.env.NODE_ENV === 'production';
670
-
671
672
  function success(value) {
672
673
  return {
673
674
  type: "success",
@@ -1146,6 +1147,7 @@ function deriveExtraKeys(widgetOptions) {
1146
1147
  const extraVariables = Object.keys(uniqueExtraVariables).sort();
1147
1148
  const extraConstants = Object.keys(uniqueExtraConstants).sort();
1148
1149
  const extraKeys = [...extraVariables, ...extraConstants];
1150
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
1149
1151
  if (!extraKeys.length) {
1150
1152
  return defaultKeys;
1151
1153
  }
@@ -2819,8 +2821,11 @@ function throwErrorIfCheatingDetected() {
2819
2821
  }
2820
2822
 
2821
2823
  // This file is processed by a Rollup plugin (replace) to inject the production
2824
+ // version number during the release build.
2825
+ // In dev, you'll never see the version number.
2826
+
2822
2827
  const libName = "@khanacademy/perseus-core";
2823
- const libVersion = "5.4.2";
2828
+ const libVersion = "7.0.0";
2824
2829
  addLibraryVersionToPerseusDebug(libName, libVersion);
2825
2830
 
2826
2831
  /**
@@ -2879,6 +2884,7 @@ class PerseusError extends Error {
2879
2884
  * _ utilities for objects
2880
2885
  */
2881
2886
 
2887
+
2882
2888
  /**
2883
2889
  * Does a pluck on keys inside objects in an object
2884
2890
  *
@@ -3300,6 +3306,7 @@ const labelImageWidgetLogic = {
3300
3306
  /* Note(tamara): Brought over from the perseus package packages/perseus/src/util.ts file.
3301
3307
  May be useful to bring other perseus package utilities here. Contains utility functions
3302
3308
  and types used across multiple widgets for randomization and shuffling. */
3309
+
3303
3310
  const seededRNG = function seededRNG(seed) {
3304
3311
  let randomSeed = seed;
3305
3312
  return function () {
@@ -3323,7 +3330,9 @@ function shuffle(array, randomSeed, ensurePermuted = false) {
3323
3330
  const shuffled = _.clone(array);
3324
3331
 
3325
3332
  // Handle edge cases (input array is empty or uniform)
3326
- if (!shuffled.length || _.all(shuffled, function (value) {
3333
+ if (
3334
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3335
+ !shuffled.length || _.all(shuffled, function (value) {
3327
3336
  return _.isEqual(value, shuffled[0]);
3328
3337
  })) {
3329
3338
  return shuffled;
@@ -3738,6 +3747,7 @@ function getRadioPublicWidgetOptions(options) {
3738
3747
  countChoices
3739
3748
  } = options;
3740
3749
  return _extends({}, options, {
3750
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3741
3751
  numCorrect: usesNumCorrect(multipleSelect, countChoices, numCorrect) ? numCorrect : undefined,
3742
3752
  choices: choices.map(getRadioChoicePublicData)
3743
3753
  });
@@ -3924,13 +3934,13 @@ registerWidget("video", videoWidgetLogic);
3924
3934
 
3925
3935
  var coreWidgetRegistry = /*#__PURE__*/Object.freeze({
3926
3936
  __proto__: null,
3927
- isWidgetRegistered: isWidgetRegistered,
3928
3937
  getCurrentVersion: getCurrentVersion,
3929
- getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
3930
- getWidgetOptionsUpgrades: getWidgetOptionsUpgrades,
3938
+ getDefaultAlignment: getDefaultAlignment,
3931
3939
  getDefaultWidgetOptions: getDefaultWidgetOptions,
3940
+ getPublicWidgetOptionsFunction: getPublicWidgetOptionsFunction,
3932
3941
  getSupportedAlignments: getSupportedAlignments,
3933
- getDefaultAlignment: getDefaultAlignment
3942
+ getWidgetOptionsUpgrades: getWidgetOptionsUpgrades,
3943
+ isWidgetRegistered: isWidgetRegistered
3934
3944
  });
3935
3945
 
3936
3946
  const DEFAULT_STATIC = false;
@@ -3966,6 +3976,7 @@ const upgradeWidgetInfoToLatestVersion = oldWidgetInfo => {
3966
3976
  // We do a clone here so that it's safe to mutate the input parameter
3967
3977
  // in propUpgrades functions (which I will probably accidentally do at
3968
3978
  // some point, and we would like to not break when that happens).
3979
+ // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
3969
3980
  let newEditorOptions = _.clone(oldWidgetInfo.options) || {};
3970
3981
  const upgradePropsMap = getWidgetOptionsUpgrades(type);
3971
3982