@khanacademy/perseus-core 3.6.0 → 4.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.
@@ -226,7 +226,14 @@ export type PerseusRenderer = {
226
226
  * field.
227
227
  */
228
228
  widgets: PerseusWidgetsMap;
229
- metadata?: ReadonlyArray<string>;
229
+ /**
230
+ * Formerly used in the PerseusGradedGroup widget. A list of "tags" that
231
+ * are keys that represent other content in the system. Not rendered to
232
+ * the user. NOTE: perseus_data.go says this is required even though it
233
+ * isn't necessary.
234
+ * @deprecated
235
+ */
236
+ metadata?: any;
230
237
  /**
231
238
  * A dictionary of {[imageUrl]: PerseusImageDetail}.
232
239
  */
@@ -258,7 +265,7 @@ export type WidgetOptions<Type extends string, Options> = {
258
265
  graded?: boolean;
259
266
  alignment?: string;
260
267
  options: Options;
261
- key?: number;
268
+ key?: number | null;
262
269
  version?: Version;
263
270
  };
264
271
  export type CategorizerWidget = WidgetOptions<'categorizer', PerseusCategorizerWidgetOptions>;
@@ -304,7 +311,7 @@ export type PerseusImageBackground = {
304
311
  height?: number;
305
312
  top?: number;
306
313
  left?: number;
307
- scale?: number | string;
314
+ scale?: number;
308
315
  bottom?: number;
309
316
  };
310
317
  /**
@@ -558,9 +565,20 @@ export type LockedFunctionType = {
558
565
  type: "function";
559
566
  color: LockedFigureColor;
560
567
  strokeStyle: LockedLineStyle;
568
+ /**
569
+ * This is the user-defined equation (as it was typed)
570
+ */
561
571
  equation: string;
572
+ /**
573
+ * The independent variable of this function
574
+ */
562
575
  directionalAxis: "x" | "y";
563
- domain?: [min: number | null, max: number | null];
576
+ /**
577
+ * The minimum and maximum values along the `directionalAxis` at which
578
+ * this function should be graphed. Values of -Infinity and Infinity are
579
+ * allowed. Note that infinite values are serialized as `null` in JSON.
580
+ */
581
+ domain: [min: number, max: number];
564
582
  labels?: LockedLabelType[];
565
583
  ariaLabel?: string;
566
584
  };
@@ -738,9 +756,10 @@ export type PerseusMeasurerWidgetOptions = {
738
756
  };
739
757
  export type MathFormat = "integer" | "mixed" | "improper" | "proper" | "decimal" | "percent" | "pi";
740
758
  export type PerseusNumericInputAnswerForm = {
741
- simplify: "required" | "correct" | "enforced" | "optional" | null | undefined;
759
+ simplify: PerseusNumericInputSimplify | null | undefined;
742
760
  name: MathFormat;
743
761
  };
762
+ export type PerseusNumericInputSimplify = "required" | "correct" | "enforced" | "optional";
744
763
  export type PerseusNumericInputWidgetOptions = {
745
764
  answers: ReadonlyArray<PerseusNumericInputAnswer>;
746
765
  labelText?: string | undefined;
@@ -748,7 +767,6 @@ export type PerseusNumericInputWidgetOptions = {
748
767
  coefficient: boolean;
749
768
  rightAlign?: boolean;
750
769
  static: boolean;
751
- answerForms?: ReadonlyArray<PerseusNumericInputAnswerForm>;
752
770
  };
753
771
  export type PerseusNumericInputAnswer = {
754
772
  message: string;
@@ -757,7 +775,7 @@ export type PerseusNumericInputAnswer = {
757
775
  answerForms?: ReadonlyArray<MathFormat>;
758
776
  strict: boolean;
759
777
  maxError: number | null | undefined;
760
- simplify: string | null | undefined;
778
+ simplify: PerseusNumericInputSimplify | null | undefined;
761
779
  };
762
780
  export type PerseusNumberLineWidgetOptions = {
763
781
  range: ReadonlyArray<number>;