@khanacademy/perseus 6.3.1 → 6.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @khanacademy/perseus
2
2
 
3
+ ## 6.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 1f3fdc6c: Introduce analytics API
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [1f3fdc6c]
12
+ - Updated dependencies [d609230e]
13
+ - Updated dependencies [0b37940d]
14
+ - Updated dependencies [bfe68075]
15
+ - Updated dependencies [1bad1cbe]
16
+ - Updated dependencies [1f3fdc6c]
17
+ - Updated dependencies [5f71cd01]
18
+ - @khanacademy/perseus-core@0.0.1
19
+ - @khanacademy/math-input@5.0.0
20
+
21
+ ## 6.3.2
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [bec7c91c]
26
+ - @khanacademy/math-input@4.3.1
27
+
3
28
  ## 6.3.1
4
29
 
5
30
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -2424,6 +2424,16 @@ const KhanAnswerTypes = {
2424
2424
  }
2425
2425
  };
2426
2426
 
2427
+ const sendExpressionEvaluatedEvent = result => {
2428
+ getDependencies().analytics({
2429
+ type: "perseus:expression-evaluated",
2430
+ payload: {
2431
+ virtualKeypadVersion: "PERSEUS_MATH_INPUT",
2432
+ // STOPSHIP: Or do we push that onto host application?
2433
+ result
2434
+ }
2435
+ });
2436
+ };
2427
2437
  const ERROR_MESSAGE = i18n._("Sorry, I don't understand that!");
2428
2438
  const insertBraces = value => {
2429
2439
  // HACK(alex): Make sure that all LaTeX super/subscripts are wrapped
@@ -2656,6 +2666,8 @@ class Expression extends React.Component {
2656
2666
  // we did, whether it's considered correct, incorrect, or ungraded
2657
2667
  if (!matchingAnswerForm) {
2658
2668
  if (firstUngradedResult) {
2669
+ sendExpressionEvaluatedEvent("invalid");
2670
+
2659
2671
  // While we didn't directly match with any answer form, we
2660
2672
  // did at some point get an "ungraded" validation result,
2661
2673
  // which might indicate e.g. a mismatch in variable casing.
@@ -2669,6 +2681,8 @@ class Expression extends React.Component {
2669
2681
  };
2670
2682
  }
2671
2683
  if (allEmpty) {
2684
+ sendExpressionEvaluatedEvent("invalid");
2685
+
2672
2686
  // If everything graded as empty, it's invalid.
2673
2687
  return {
2674
2688
  type: "invalid",
@@ -2677,6 +2691,7 @@ class Expression extends React.Component {
2677
2691
  }
2678
2692
  // We fell through all the possibilities and we're not empty,
2679
2693
  // so the answer is considered incorrect.
2694
+ sendExpressionEvaluatedEvent("incorrect");
2680
2695
  return {
2681
2696
  type: "points",
2682
2697
  earned: 0,
@@ -2689,6 +2704,7 @@ class Expression extends React.Component {
2689
2704
  const apiResult = onInputError(null,
2690
2705
  // Reserved for some widget identifier
2691
2706
  userInput, matchMessage);
2707
+ sendExpressionEvaluatedEvent("invalid");
2692
2708
  return {
2693
2709
  type: "invalid",
2694
2710
  message: apiResult === false ? null : matchMessage
@@ -2700,6 +2716,7 @@ class Expression extends React.Component {
2700
2716
  // TODO(eater): Seems silly to translate result to this
2701
2717
  // invalid/points thing and immediately translate it back in
2702
2718
  // ItemRenderer.scoreInput()
2719
+ sendExpressionEvaluatedEvent(matchingAnswerForm.considered === "correct" ? "correct" : "incorrect");
2703
2720
  return {
2704
2721
  type: "points",
2705
2722
  earned: matchingAnswerForm.considered === "correct" ? 1 : 0,
@@ -14146,8 +14163,6 @@ const DEFAULT_STATE$3 = {
14146
14163
  isDragging: false,
14147
14164
  mouseTarget: null
14148
14165
  };
14149
-
14150
- // @ts-expect-error [FEI-5003] - TS2355 - A function whose declared type is neither 'void' nor 'any' must return a value.
14151
14166
  const Movable = function Movable(graphie, options) {
14152
14167
  // @ts-expect-error [FEI-5003] - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
14153
14168
  _.extend(this, {
@@ -15759,7 +15774,6 @@ const constraints = {
15759
15774
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'standard' does not exist on type '{ readonly fixed: () => () => boolean; readonly snap: (snap: any) => (arg1: Coord) => unknown; readonly bound: (range: any, snap: any, paddingPx: number) => (arg1: Coord, arg2: Coord) => Coord; }'.
15760
15775
  constraints.standard = null;
15761
15776
  const onMove = {
15762
- // @ts-expect-error [FEI-5003] - TS2355 - A function whose declared type is neither 'void' nor 'any' must return a value.
15763
15777
  updatePoints: function (coord, prevCoord) {
15764
15778
  const actualDelta = vector$1.subtract(coord, prevCoord);
15765
15779
  // @ts-expect-error [FEI-5003] - TS2339 - Property 'state' does not exist on type '{ readonly updatePoints: (coord: Coord, prevCoord: Coord) => undefined; }'.
@@ -16067,19 +16081,16 @@ _.extend(MovablePolygon.prototype, {
16067
16081
  const Interactive2 = {
16068
16082
  MovablePoint: MovablePoint$5,
16069
16083
  addMovablePoint: function (graphie, options) {
16070
- // @ts-expect-error [FEI-5003] - TS2350 - Only a void function can be called with the 'new' keyword.
16071
16084
  const movable = new Movable(graphie, {});
16072
16085
  return new MovablePoint$5(graphie, movable, options);
16073
16086
  },
16074
16087
  MovableLine: MovableLine$4,
16075
16088
  addMovableLine: function (graphie, options) {
16076
- // @ts-expect-error [FEI-5003] - TS2350 - Only a void function can be called with the 'new' keyword.
16077
16089
  const movable = new Movable(graphie, {});
16078
16090
  return new MovableLine$4(graphie, movable, options);
16079
16091
  },
16080
16092
  MovablePolygon: MovablePolygon,
16081
16093
  addMovablePolygon: function (graphie, options) {
16082
- // @ts-expect-error [FEI-5003] - TS2350 - Only a void function can be called with the 'new' keyword.
16083
16094
  const movable = new Movable(graphie, {});
16084
16095
  return new MovablePolygon(graphie, movable, options);
16085
16096
  },
@@ -33376,15 +33387,13 @@ class Matrix extends React.Component {
33376
33387
  }
33377
33388
  };
33378
33389
  this.onValueChange = (row, column, value, cb) => {
33379
- const answers = _.map(this.props.answers, _.clone);
33390
+ const answers = this.props.answers.map(answer => [...answer]);
33380
33391
  if (!answers[row]) {
33381
33392
  answers[row] = [];
33382
33393
  }
33383
- // @ts-expect-error [FEI-5003] - TS2571 - Object is of type 'unknown'.
33384
33394
  answers[row][column] = value;
33385
- // @ts-expect-error [FEI-5003] - TS2769 - No overload matches this call.
33386
33395
  this.props.onChange({
33387
- answers: answers
33396
+ answers
33388
33397
  }, cb);
33389
33398
  this.props.trackInteraction();
33390
33399
  };
@@ -45712,6 +45721,95 @@ const context = /*#__PURE__*/React.createContext({
45712
45721
  scrollableElement: null
45713
45722
  });
45714
45723
 
45724
+ // TODO(FEI-4010): Remove `Perseus` prefix for all types here
45725
+ // TODO(FEI-4011): Use types generated by https://github.com/jaredly/generate-perseus-flowtypes
45726
+
45727
+ // TODO(FEI-5054): Figure out how to get global .d.ts files working with monorepos
45728
+
45729
+ // prettier-ignore
45730
+
45731
+ // prettier-ignore
45732
+
45733
+ // prettier-ignore
45734
+
45735
+ // prettier-ignore
45736
+
45737
+ // prettier-ignore
45738
+
45739
+ // prettier-ignore
45740
+
45741
+ // prettier-ignore
45742
+
45743
+ // prettier-ignore
45744
+
45745
+ // prettier-ignore
45746
+
45747
+ // prettier-ignore
45748
+
45749
+ // prettier-ignore
45750
+
45751
+ // prettier-ignore
45752
+
45753
+ // prettier-ignore
45754
+
45755
+ // prettier-ignore
45756
+
45757
+ // prettier-ignore
45758
+
45759
+ // prettier-ignore
45760
+
45761
+ // prettier-ignore
45762
+
45763
+ // prettier-ignore
45764
+
45765
+ // prettier-ignore
45766
+
45767
+ // prettier-ignore
45768
+
45769
+ // prettier-ignore
45770
+
45771
+ // prettier-ignore
45772
+
45773
+ // prettier-ignore
45774
+
45775
+ // prettier-ignore
45776
+
45777
+ // prettier-ignore
45778
+
45779
+ // prettier-ignore
45780
+
45781
+ // prettier-ignore
45782
+
45783
+ // prettier-ignore
45784
+
45785
+ // prettier-ignore
45786
+
45787
+ // prettier-ignore
45788
+
45789
+ // prettier-ignore
45790
+
45791
+ // prettier-ignore
45792
+
45793
+ // prettier-ignore
45794
+
45795
+ // prettier-ignore
45796
+
45797
+ // prettier-ignore
45798
+
45799
+ // prettier-ignore
45800
+
45801
+ // prettier-ignore
45802
+
45803
+ // prettier-ignore
45804
+
45805
+ // prettier-ignore
45806
+
45807
+ // prettier-ignore
45808
+
45809
+ // A background image applied to various widgets.
45810
+
45811
+ const PerseusExpressionAnswerFormConsidered = ["correct", "wrong", "ungraded"];
45812
+
45715
45813
  /**
45716
45814
  * Traverses a {content, widgets, images} renderer props object,
45717
45815
  * such as `itemData.question`
@@ -46791,5 +46889,5 @@ const EditorJsonify = {
46791
46889
  const apiVersion = version.apiVersion;
46792
46890
  const itemDataVersion = version.itemDataVersion;
46793
46891
 
46794
- export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, context as KeypadContext, KhanColors, KhanMath, context$1 as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, mediaQueries, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
46892
+ export { ApiOptions, ArrowPicker, ArticleRenderer, BaseRadio, Categorizer$1 as Categorizer, changeable as Changeable, ClassNames, ColorPicker, DashPicker, dependencies as Dependencies, EditorJsonify, ElementContainer, Errors, Expression, util as GrapherUtil, Grapher$1 as GrapherWidget, HintRenderer, HintsRenderer, InputNumber$1 as InputNumber, InteractiveGraph$1 as InteractiveGraphWidget, ItemRenderer, JiptParagraphs, context as KeypadContext, KhanColors, KhanMath, context$1 as LoadingContext, Log, Matrix$1 as MatrixWidget, MultiItems, NumericInput$1 as NumericInput, PerseusError, PerseusExpressionAnswerFormConsidered, PerseusMarkdown, Plotter$1 as PlotterWidget, Radio, Renderer, ref as ServerItemRenderer, sizingUtils as SizingUtils, Table$1 as TableWidget, Transformer$1 as TransformerWidget, Util, denylist as WIDGET_PROP_DENYLIST, WidgetJsonifyDeprecated, widgets$1 as Widgets, apiVersion, buildEmptyItemTreeForShape, buildMapper, components, constants, displaySigFigs, globalConstants, globalStyles, iconPaths as icons, init, interactiveSizes$1 as interactiveSizes, isItemRenderableByVersion, itemDataVersion, itemToTree, ItemVersion as itemVersion, mediaQueries, preprocessTex, registerAllWidgetsForTesting, shapes, traverse, violatingWidgets, allWidgets as widgets };
46795
46893
  //# sourceMappingURL=index.js.map