@khanacademy/perseus-core 3.0.5 → 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/data-schema.d.ts +981 -0
- package/dist/es/index.js +2819 -2
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +2831 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/utils/deep-clone.d.ts +3 -0
- package/dist/utils/equality.d.ts +9 -0
- package/dist/utils/get-decimal-separator.d.ts +5 -0
- package/dist/utils/get-matrix-size.d.ts +2 -0
- package/dist/utils/grapher-types.d.ts +58 -0
- package/dist/utils/grapher-util.d.ts +20 -0
- package/dist/utils/objective_.d.ts +30 -0
- package/package.json +1 -1
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,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,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 {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* _ utilities for objects
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Does a pluck on keys inside objects in an object
|
|
6
|
+
*
|
|
7
|
+
* Ex:
|
|
8
|
+
* tools = {
|
|
9
|
+
* translation: {
|
|
10
|
+
* enabled: true
|
|
11
|
+
* },
|
|
12
|
+
* rotation: {
|
|
13
|
+
* enabled: false
|
|
14
|
+
* }
|
|
15
|
+
* };
|
|
16
|
+
* pluckObject(tools, "enabled") returns {
|
|
17
|
+
* translation: true
|
|
18
|
+
* rotation: false
|
|
19
|
+
* }
|
|
20
|
+
*/
|
|
21
|
+
export declare const pluck: (table: any, subKey: string) => any;
|
|
22
|
+
/**
|
|
23
|
+
* Maps an object to an object
|
|
24
|
+
*
|
|
25
|
+
* > mapObject({a: '1', b: '2'}, (value, key) => {
|
|
26
|
+
* return value + 1;
|
|
27
|
+
* });
|
|
28
|
+
* {a: 2, b: 3}
|
|
29
|
+
*/
|
|
30
|
+
export declare const mapObject: <K extends string, V, U>(obj: Record<K, V>, lambda: (arg1: V, arg2: K) => U) => Record<K, U>;
|