@khanacademy/perseus-core 3.1.0 → 3.2.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/types.d.ts CHANGED
@@ -17,4 +17,16 @@ export type KEScore = {
17
17
  guess: any;
18
18
  state: any;
19
19
  };
20
+ export type MarkerType = {
21
+ answers: ReadonlyArray<string>;
22
+ label: string;
23
+ x: number;
24
+ y: number;
25
+ };
26
+ export type InteractiveMarkerType = MarkerType & {
27
+ selected?: ReadonlyArray<string>;
28
+ showCorrectness?: "correct" | "incorrect";
29
+ focused?: boolean;
30
+ };
31
+ export type Relationship = "lt" | "gt" | "le" | "ge";
20
32
  export {};
@@ -0,0 +1,3 @@
1
+ type Cloneable = null | undefined | boolean | string | number | Cloneable[] | readonly Cloneable[];
2
+ declare function deepClone<T extends Cloneable>(obj: T): T;
3
+ export default deepClone;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * APPROXIMATE equality on numbers and primitives.
3
+ */
4
+ export declare function approximateEqual<T>(x: T, y: T): boolean;
5
+ /**
6
+ * Deep APPROXIMATE equality on primitives, numbers, arrays, and objects.
7
+ * Recursive.
8
+ */
9
+ export declare function approximateDeepEqual<T>(x: T, y: T): boolean;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Get the character used for separating decimals.
3
+ */
4
+ declare const getDecimalSeparator: (locale: string) => string;
5
+ export default getDecimalSeparator;
@@ -0,0 +1,2 @@
1
+ declare function getMatrixSize(matrix: ReadonlyArray<ReadonlyArray<number>>): number[];
2
+ export default getMatrixSize;
@@ -0,0 +1,58 @@
1
+ import type { Coord } from "../data-schema";
2
+ export type Coords = [Coord, Coord];
3
+ type SharedGrapherType = {
4
+ url: string;
5
+ defaultCoords: Coords;
6
+ getFunctionForCoeffs: (coeffs: ReadonlyArray<number>, x: number) => number;
7
+ getEquationString: (coords: Coords, asymptote?: Coords) => string | null;
8
+ areEqual: (coeffs1: ReadonlyArray<number>, coeffs2: ReadonlyArray<number>) => boolean;
9
+ Movable: any;
10
+ getCoefficients: (coords: Coords, asymptote?: Coords) => ReadonlyArray<number> | undefined;
11
+ };
12
+ type AsymptoticGraphsType = {
13
+ defaultAsymptote: Coords;
14
+ extraCoordConstraint: (newCoord: Coord, oldCoord: Coord, coords: Coords, asymptote: Coords, graph: any) => boolean | Coord;
15
+ extraAsymptoteConstraint: (newCoord: Coord, oldCoord: Coord, coords: Coords, asymptote: Coords, graph: any) => Coord;
16
+ allowReflectOverAsymptote: boolean;
17
+ };
18
+ export type LinearType = SharedGrapherType & {
19
+ getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
20
+ fn: any;
21
+ };
22
+ };
23
+ export type QuadraticType = SharedGrapherType & {
24
+ getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
25
+ a: number;
26
+ b: number;
27
+ c: number;
28
+ };
29
+ };
30
+ export type SinusoidType = SharedGrapherType & {
31
+ getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
32
+ a: number;
33
+ b: number;
34
+ c: number;
35
+ d: number;
36
+ };
37
+ };
38
+ export type TangentType = SharedGrapherType & {
39
+ getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
40
+ fn: any;
41
+ };
42
+ };
43
+ export type ExponentialType = SharedGrapherType & AsymptoticGraphsType & {
44
+ getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
45
+ fn: any;
46
+ };
47
+ };
48
+ export type LogarithmType = SharedGrapherType & AsymptoticGraphsType & {
49
+ getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
50
+ fn: any;
51
+ };
52
+ };
53
+ export type AbsoluteValueType = SharedGrapherType & {
54
+ getPropsForCoeffs: (coeffs: ReadonlyArray<number>) => {
55
+ fn: any;
56
+ };
57
+ };
58
+ export {};
@@ -0,0 +1,20 @@
1
+ import type { LinearType, QuadraticType, SinusoidType, TangentType, ExponentialType, LogarithmType, AbsoluteValueType } from "./grapher-types";
2
+ export declare const MOVABLES: {
3
+ PLOT: string;
4
+ PARABOLA: string;
5
+ SINUSOID: string;
6
+ };
7
+ declare const functionTypeMapping: {
8
+ readonly linear: LinearType;
9
+ readonly quadratic: QuadraticType;
10
+ readonly sinusoid: SinusoidType;
11
+ readonly tangent: TangentType;
12
+ readonly exponential: ExponentialType;
13
+ readonly logarithm: LogarithmType;
14
+ readonly absolute_value: AbsoluteValueType;
15
+ };
16
+ export declare const allTypes: any;
17
+ export type FunctionTypeMappingKeys = keyof typeof functionTypeMapping;
18
+ type ConditionalGraderType<T extends FunctionTypeMappingKeys> = T extends "linear" ? LinearType : T extends "quadratic" ? QuadraticType : T extends "sinusoid" ? SinusoidType : T extends "tangent" ? TangentType : T extends "exponential" ? ExponentialType : T extends "logarithm" ? LogarithmType : T extends "absolute_value" ? AbsoluteValueType : never;
19
+ export declare function functionForType<T extends FunctionTypeMappingKeys>(type: T): ConditionalGraderType<T>;
20
+ export {};
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Shared Perseus infrastructure",
4
4
  "author": "Khan Academy",
5
5
  "license": "MIT",
6
- "version": "3.1.0",
6
+ "version": "3.2.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },