@khanacademy/perseus-core 3.7.0 → 5.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/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright 2022 Khan Academy
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to use,
6
+ copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
7
+ Software, and to permit persons to whom the Software is furnished to do so, subject
8
+ to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17
+ AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -26,6 +26,7 @@
26
26
  * b) the parsing code (`util/parse-perseus-json/`) is updated to handle
27
27
  * the new format _as well as_ the old format.
28
28
  */
29
+ import type { KeypadKey } from "./keypad";
29
30
  export type Coord = [x: number, y: number];
30
31
  export type Interval = [min: number, max: number];
31
32
  export type Vector2 = Coord;
@@ -365,6 +366,7 @@ export type PerseusExpressionWidgetOptions = {
365
366
  buttonSets: LegacyButtonSets;
366
367
  functions: ReadonlyArray<string>;
367
368
  times: boolean;
369
+ extraKeys?: ReadonlyArray<KeypadKey>;
368
370
  visibleLabel?: string;
369
371
  ariaLabel?: string;
370
372
  buttonsVisible?: "always" | "never" | "focused";
@@ -565,9 +567,20 @@ export type LockedFunctionType = {
565
567
  type: "function";
566
568
  color: LockedFigureColor;
567
569
  strokeStyle: LockedLineStyle;
570
+ /**
571
+ * This is the user-defined equation (as it was typed)
572
+ */
568
573
  equation: string;
574
+ /**
575
+ * The independent variable of this function
576
+ */
569
577
  directionalAxis: "x" | "y";
570
- domain?: [min: number | null, max: number | null];
578
+ /**
579
+ * The minimum and maximum values along the `directionalAxis` at which
580
+ * this function should be graphed. Values of -Infinity and Infinity are
581
+ * allowed. Note that infinite values are serialized as `null` in JSON.
582
+ */
583
+ domain: [min: number, max: number];
571
584
  labels?: LockedLabelType[];
572
585
  ariaLabel?: string;
573
586
  };
@@ -745,9 +758,10 @@ export type PerseusMeasurerWidgetOptions = {
745
758
  };
746
759
  export type MathFormat = "integer" | "mixed" | "improper" | "proper" | "decimal" | "percent" | "pi";
747
760
  export type PerseusNumericInputAnswerForm = {
748
- simplify: "required" | "correct" | "enforced" | "optional" | null | undefined;
761
+ simplify: PerseusNumericInputSimplify | null | undefined;
749
762
  name: MathFormat;
750
763
  };
764
+ export type PerseusNumericInputSimplify = "required" | "correct" | "enforced" | "optional";
751
765
  export type PerseusNumericInputWidgetOptions = {
752
766
  answers: ReadonlyArray<PerseusNumericInputAnswer>;
753
767
  labelText?: string | undefined;
@@ -755,7 +769,6 @@ export type PerseusNumericInputWidgetOptions = {
755
769
  coefficient: boolean;
756
770
  rightAlign?: boolean;
757
771
  static: boolean;
758
- answerForms?: ReadonlyArray<PerseusNumericInputAnswerForm>;
759
772
  };
760
773
  export type PerseusNumericInputAnswer = {
761
774
  message: string;
@@ -764,7 +777,7 @@ export type PerseusNumericInputAnswer = {
764
777
  answerForms?: ReadonlyArray<MathFormat>;
765
778
  strict: boolean;
766
779
  maxError: number | null | undefined;
767
- simplify: string | null | undefined;
780
+ simplify: PerseusNumericInputSimplify | null | undefined;
768
781
  };
769
782
  export type PerseusNumberLineWidgetOptions = {
770
783
  range: ReadonlyArray<number>;
@@ -822,6 +835,7 @@ export type PerseusRadioWidgetOptions = {
822
835
  choices: ReadonlyArray<PerseusRadioChoice>;
823
836
  hasNoneOfTheAbove?: boolean;
824
837
  countChoices?: boolean;
838
+ numCorrect?: number;
825
839
  randomize?: boolean;
826
840
  multipleSelect?: boolean;
827
841
  deselectEnabled?: boolean;