@khanacademy/perseus 10.0.0 → 10.0.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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Core Perseus API (includes renderers and widgets)",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "10.0.0",
6
+ "version": "10.0.1",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@khanacademy/kas": "^0.3.1",
25
25
  "@khanacademy/kmath": "^0.1.2",
26
- "@khanacademy/math-input": "^10.0.1",
26
+ "@khanacademy/math-input": "^10.1.0",
27
27
  "@khanacademy/perseus-core": "0.2.0",
28
28
  "@khanacademy/perseus-linter": "^0.3.2",
29
29
  "@khanacademy/pure-markdown": "^0.2.4",
@@ -2,9 +2,11 @@ import * as React from "react";
2
2
 
3
3
  import AssetContext from "../asset-context";
4
4
 
5
+ import type {PerseusItem} from "../perseus-types";
5
6
  import type {WidgetExports} from "../types";
6
7
 
7
- export const mockedAssetItem = {
8
+ // @ts-expect-error - TS2322 - Type '"mocked-asset-widget"' is not assignable to type '"categorizer" | "cs-program" | "definition" | "dropdown" | "example-graphie-widget" | "example-widget" | "explanation" | "expression" | "graded-group-set" | "graded-group" | ... 29 more ... | "video"'.
9
+ export const mockedAssetItem: PerseusItem = {
8
10
  question: {
9
11
  content: "[[\u2603 mocked-asset-widget 1]]",
10
12
  images: Object.freeze({}),
@@ -27,7 +29,6 @@ export const mockedAssetItem = {
27
29
  zTable: false,
28
30
  },
29
31
  itemDataVersion: {major: 0, minor: 1},
30
- // $FlowIgnore[signature-verification-failure]
31
32
  hints: [],
32
33
  _multi: null,
33
34
  answer: null,
@@ -0,0 +1,73 @@
1
+ import {registerAllWidgetsForTesting} from "../util/register-all-widgets-for-testing";
2
+ import * as Widgets from "../widgets";
3
+
4
+ describe("Widget API support", () => {
5
+ beforeAll(() => {
6
+ registerAllWidgetsForTesting();
7
+ });
8
+
9
+ // This verifies a known list of widgets to ensure they provide the static
10
+ // validate function. Not all widgets support this function so even though
11
+ // this list looks exhaustive, it's not!
12
+ it.each([
13
+ "radio",
14
+ "input-number",
15
+ "numeric-input",
16
+ "expression",
17
+ "categorizer",
18
+ "cs-program",
19
+ "dropdown",
20
+ "explanation",
21
+ "definition",
22
+ "grapher",
23
+ "iframe",
24
+ "image",
25
+ "interaction",
26
+ "interactive-graph",
27
+ "label-image",
28
+ "matrix",
29
+ "matcher",
30
+ "measurer",
31
+ "number-line",
32
+ "orderer",
33
+ "passage",
34
+ "passage-ref",
35
+ "passage-ref-target",
36
+ "plotter",
37
+ "simulator",
38
+ "sorter",
39
+ "table",
40
+ "transformer",
41
+ "unit-input",
42
+ "video",
43
+ ])("%s widget should provide static validate function", (widgetType) => {
44
+ expect(Widgets.getWidget(widgetType)).toHaveProperty("validate");
45
+ });
46
+
47
+ // This list is mirrored in Khan Academy's webapp for the coach reports.
48
+ // If you change this, be sure to double-check that consuming applications
49
+ // agree on this list of supported widgets.
50
+ it.each([
51
+ "categorizer",
52
+ "expression",
53
+ "grapher",
54
+ "input-number",
55
+ "interactive-graph",
56
+ "numeric-input",
57
+ "radio",
58
+ ])(
59
+ "%s widget should provide static getUserInputFromProps function",
60
+ (widgetType) => {
61
+ const Widget = Widgets.getWidget(widgetType);
62
+ expect(Widget).toHaveProperty("getUserInputFromProps");
63
+ },
64
+ );
65
+
66
+ it.each(["expression", "input-number", "numeric-input"])(
67
+ "%s widget should provide static getOneCorrectAnswerFromRubric function",
68
+ (widgetType) => {
69
+ const Widget = Widgets.getWidget(widgetType);
70
+ expect(Widget).toHaveProperty("getOneCorrectAnswerFromRubric");
71
+ },
72
+ );
73
+ });
@@ -680,6 +680,19 @@ const ExpressionWithDependencies = React.forwardRef<
680
680
  return <Expression ref={ref} analytics={deps.analytics} {...props} />;
681
681
  });
682
682
 
683
+ // HACK: Propogate "static" methods onto our wrapper component.
684
+ // In the future we should adjust client apps to not depend on these static
685
+ // methods and instead adjust Peresus to provide these facilities through
686
+ // instance methods on our Renderers.
687
+ // @ts-expect-error - TS2339 - Property 'validate' does not exist on type
688
+ ExpressionWithDependencies.validate = Expression.validate;
689
+ // @ts-expect-error - TS2339 - Property 'validate' does not exist on type
690
+ ExpressionWithDependencies.getUserInputFromProps =
691
+ Expression.getUserInputFromProps;
692
+ // @ts-expect-error - TS2339 - Property 'validate' does not exist on type
693
+ ExpressionWithDependencies.getOneCorrectAnswerFromRubric =
694
+ Expression.getOneCorrectAnswerFromRubric;
695
+
683
696
  export default {
684
697
  name: "expression",
685
698
  displayName: "Expression / Equation",