@khanacademy/perseus-core 3.5.0 → 3.7.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.
@@ -14,4 +14,3 @@ export * from "./record";
14
14
  export * from "./string";
15
15
  export * from "./trio";
16
16
  export * from "./union";
17
- export * from "./unknown";
@@ -6,3 +6,4 @@ export declare const anyFailure: Failure<any>;
6
6
  export declare const anySuccess: import("../result").Success<any>;
7
7
  export declare function parseFailureWith(expected: Partial<Mismatch>): Failure<Mismatch[]>;
8
8
  export declare function summonParsedValue<P extends Parser<any>>(): ParsedValue<P>;
9
+ export declare function summon<T>(): T;
@@ -0,0 +1,2 @@
1
+ export declare const parseLegacyButtonSet: import("../parser-types").Parser<"basic" | "basic+div" | "trig" | "prealgebra" | "logarithms" | "basic relations" | "advanced relations" | "scientific">;
2
+ export declare const parseLegacyButtonSets: import("../parser-types").Parser<("basic" | "basic+div" | "trig" | "prealgebra" | "logarithms" | "basic relations" | "advanced relations" | "scientific")[] | readonly ["basic", "trig", "prealgebra", "logarithms"]>;
@@ -0,0 +1,2 @@
1
+ import type { PerseusAnswerArea } from "@khanacademy/perseus-core";
2
+ export declare const parsePerseusAnswerArea: import("../parser-types").Parser<PerseusAnswerArea>;
@@ -13,4 +13,11 @@ export declare function isFailure<S, F>(result: Result<S, F>): result is Failure
13
13
  export declare function isSuccess<S, F>(result: Result<S, F>): result is Success<S>;
14
14
  export declare function assertFailure<S, F>(result: Result<S, F>): asserts result is Failure<F>;
15
15
  export declare function assertSuccess<S, F>(result: Result<S, F>): asserts result is Success<S>;
16
+ /**
17
+ * @returns a function that transforms the `detail` value of any Failure result
18
+ * passed to it, and leaves Success results unchanged. `mapFailure` is curried
19
+ * for easy composition with Array.map(), mu-lambda's pipe(), etc.
20
+ * @param f the function to apply to Failure `detail`s.
21
+ */
22
+ export declare function mapFailure<S, DetailIn, DetailOut>(f: (detail: DetailIn) => DetailOut): (result: Result<S, DetailIn>) => Result<S, DetailOut>;
16
23
  export declare function all<S, F>(results: Array<Result<S, F>>, combineFailureDetails?: (a: F, b: F) => F): Result<S[], F>;
@@ -0,0 +1,5 @@
1
+ type RNG = () => number;
2
+ export declare const seededRNG: (seed: number) => RNG;
3
+ export declare function shuffle<T>(array: ReadonlyArray<T>, randomSeed: number | RNG, ensurePermuted?: boolean): ReadonlyArray<T>;
4
+ export declare const random: RNG;
5
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { PerseusRenderer } from "../data-schema";
2
+ export default function splitPerseusItem(originalItem: PerseusRenderer): PerseusRenderer;
@@ -1,6 +1,8 @@
1
+ import type { PublicWidgetOptionsFunction } from "./logic-export.types";
1
2
  import type { Alignment } from "../types";
2
3
  export declare function isWidgetRegistered(type: string): boolean;
3
4
  export declare function getCurrentVersion(type: string): any;
5
+ export declare const getPublicWidgetOptionsFunction: (name: string) => PublicWidgetOptionsFunction;
4
6
  export declare function getWidgetOptionsUpgrades(type: string): any;
5
7
  export declare function getDefaultWidgetOptions(type: string): any;
6
8
  /**
@@ -1,5 +1,5 @@
1
1
  import type { PerseusGroupWidgetOptions } from "../../data-schema";
2
2
  import type { WidgetLogic } from "../logic-export.types";
3
- export type GroupDefaultWidgetOptions = Pick<PerseusGroupWidgetOptions, "content" | "widgets" | "images" | "metadata">;
3
+ export type GroupDefaultWidgetOptions = Pick<PerseusGroupWidgetOptions, "content" | "widgets" | "images">;
4
4
  declare const groupWidgetLogic: WidgetLogic;
5
5
  export default groupWidgetLogic;
@@ -1,8 +1,32 @@
1
+ import type getCategorizerPublicWidgetOptions from "./categorizer/categorizer-util";
2
+ import type getCSProgramPublicWidgetOptions from "./cs-program/cs-program-util";
3
+ import type getDropdownPublicWidgetOptions from "./dropdown/dropdown-util";
4
+ import type getExpressionPublicWidgetOptions from "./expression/expression-util";
5
+ import type getGrapherPublicWidgetOptions from "./grapher/grapher-util";
6
+ import type getIFramePublicWidgetOptions from "./iframe/iframe-util";
7
+ import type getInteractiveGraphPublicWidgetOptions from "./interactive-graph/interactive-graph-util";
8
+ import type getLabelImagePublicWidgetOptions from "./label-image/label-image-util";
9
+ import type getMatcherPublicWidgetOptions from "./matcher/matcher-util";
10
+ import type getMatrixPublicWidgetOptions from "./matrix/matrix-util";
11
+ import type getNumberLinePublicWidgetOptions from "./number-line/number-line-util";
12
+ import type getNumericInputPublicWidgetOptions from "./numeric-input/numeric-input-util";
13
+ import type getOrdererPublicWidgetOptions from "./orderer/orderer-util";
14
+ import type getPlotterPublicWidgetOptions from "./plotter/plotter-util";
15
+ import type getRadioPublicWidgetOptions from "./radio/radio-util";
16
+ import type getSorterPublicWidgetOptions from "./sorter/sorter-util";
17
+ import type getTablePublicWidgetOptions from "./table/table-util";
1
18
  import type { Version } from "../data-schema";
2
19
  import type { Alignment } from "../types";
3
20
  export type WidgetOptionsUpgradeMap = {
4
21
  [targetMajorVersion: string]: (arg1: any) => any;
5
22
  };
23
+ /**
24
+ * A union type of all the functions that provide public widget options.
25
+ *
26
+ * TODO(LEMS-2870): figure out how to make this generic so we don't need to be
27
+ * so reliant on a set group of widgets
28
+ */
29
+ export type PublicWidgetOptionsFunction = typeof getMatcherPublicWidgetOptions | typeof getPlotterPublicWidgetOptions | typeof getIFramePublicWidgetOptions | typeof getRadioPublicWidgetOptions | typeof getNumericInputPublicWidgetOptions | typeof getDropdownPublicWidgetOptions | typeof getCategorizerPublicWidgetOptions | typeof getOrdererPublicWidgetOptions | typeof getExpressionPublicWidgetOptions | typeof getInteractiveGraphPublicWidgetOptions | typeof getLabelImagePublicWidgetOptions | typeof getSorterPublicWidgetOptions | typeof getCSProgramPublicWidgetOptions | typeof getNumberLinePublicWidgetOptions | typeof getTablePublicWidgetOptions | typeof getGrapherPublicWidgetOptions | typeof getMatrixPublicWidgetOptions;
6
30
  export type WidgetLogic = {
7
31
  name: string;
8
32
  version?: Version;
@@ -10,4 +34,9 @@ export type WidgetLogic = {
10
34
  defaultWidgetOptions?: any;
11
35
  supportedAlignments?: ReadonlyArray<Alignment>;
12
36
  defaultAlignment?: Alignment;
37
+ /**
38
+ * A function that provides a public version of the widget options that can
39
+ * be shared with the client.
40
+ */
41
+ getPublicWidgetOptions?: PublicWidgetOptionsFunction;
13
42
  };
@@ -0,0 +1,28 @@
1
+ import type { PerseusMatcherWidgetOptions } from "@khanacademy/perseus-core";
2
+ type MatcherInfo = {
3
+ left: ReadonlyArray<string>;
4
+ right: ReadonlyArray<string>;
5
+ orderMatters: boolean;
6
+ problemNum: number | null | undefined;
7
+ };
8
+ export declare const shuffleMatcher: (props: MatcherInfo) => {
9
+ left: ReadonlyArray<string>;
10
+ right: ReadonlyArray<string>;
11
+ };
12
+ /**
13
+ * For details on the individual options, see the
14
+ * PerseusMatcherWidgetOptions type
15
+ */
16
+ type MatcherPublicWidgetOptions = {
17
+ labels: PerseusMatcherWidgetOptions["labels"];
18
+ left: PerseusMatcherWidgetOptions["left"];
19
+ right: PerseusMatcherWidgetOptions["right"];
20
+ orderMatters: PerseusMatcherWidgetOptions["orderMatters"];
21
+ padding: PerseusMatcherWidgetOptions["padding"];
22
+ };
23
+ /**
24
+ * Given a PerseusMatcherWidgetOptions object, return a new object with only
25
+ * the public options that should be exposed to the client.
26
+ */
27
+ declare function getMatcherPublicWidgetOptions(options: PerseusMatcherWidgetOptions): MatcherPublicWidgetOptions;
28
+ export default getMatcherPublicWidgetOptions;
@@ -7,6 +7,7 @@ type SorterPublicWidgetOptions = {
7
7
  correct: PerseusSorterWidgetOptions["correct"];
8
8
  padding: PerseusSorterWidgetOptions["padding"];
9
9
  layout: PerseusSorterWidgetOptions["layout"];
10
+ isCorrectShuffled: boolean;
10
11
  };
11
12
  /**
12
13
  * Given a PerseusSorterWidgetOptions object, return a new object with only
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.5.0",
6
+ "version": "3.7.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -1,2 +0,0 @@
1
- import type { Parser } from "../parser-types";
2
- export declare const unknown: Parser<unknown>;