@khanacademy/perseus-core 3.4.0 → 3.6.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"]>;
@@ -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,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
  /**
@@ -0,0 +1,4 @@
1
+ import type { PerseusGrapherWidgetOptions } from "../../data-schema";
2
+ type GrapherPublicWidgetOptions = Pick<PerseusGrapherWidgetOptions, "availableTypes" | "graph">;
3
+ export default function getGrapherPublicWidgetOptions(options: PerseusGrapherWidgetOptions): GrapherPublicWidgetOptions;
4
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { PerseusIFrameWidgetOptions } from "../../data-schema";
2
+ export default function getIFramePublicWidgetOptions(options: PerseusIFrameWidgetOptions): PerseusIFrameWidgetOptions;
@@ -0,0 +1,4 @@
1
+ import type { PerseusInteractiveGraphWidgetOptions } from "@khanacademy/perseus-core";
2
+ type InteractiveGraphPublicWidgetOptions = Pick<PerseusInteractiveGraphWidgetOptions, "step" | "gridStep" | "snapStep" | "backgroundImage" | "markings" | "labels" | "showProtractor" | "showRuler" | "showTooltips" | "rulerLabel" | "rulerTicks" | "range" | "graph" | "lockedFigures" | "fullGraphAriaLabel" | "fullGraphAriaDescription">;
3
+ export default function getInteractiveGraphPublicWidgetOptions(options: PerseusInteractiveGraphWidgetOptions): InteractiveGraphPublicWidgetOptions;
4
+ export {};
@@ -1,8 +1,31 @@
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 getMatrixPublicWidgetOptions from "./matrix/matrix-util";
10
+ import type getNumberLinePublicWidgetOptions from "./number-line/number-line-util";
11
+ import type getNumericInputPublicWidgetOptions from "./numeric-input/numeric-input-util";
12
+ import type getOrdererPublicWidgetOptions from "./orderer/orderer-util";
13
+ import type getPlotterPublicWidgetOptions from "./plotter/plotter-util";
14
+ import type getRadioPublicWidgetOptions from "./radio/radio-util";
15
+ import type getSorterPublicWidgetOptions from "./sorter/sorter-util";
16
+ import type getTablePublicWidgetOptions from "./table/table-util";
1
17
  import type { Version } from "../data-schema";
2
18
  import type { Alignment } from "../types";
3
19
  export type WidgetOptionsUpgradeMap = {
4
20
  [targetMajorVersion: string]: (arg1: any) => any;
5
21
  };
22
+ /**
23
+ * A union type of all the functions that provide public widget options.
24
+ *
25
+ * TODO(LEMS-2870): figure out how to make this generic so we don't need to be
26
+ * so reliant on a set group of widgets
27
+ */
28
+ export type PublicWidgetOptionsFunction = 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
29
  export type WidgetLogic = {
7
30
  name: string;
8
31
  version?: Version;
@@ -10,4 +33,9 @@ export type WidgetLogic = {
10
33
  defaultWidgetOptions?: any;
11
34
  supportedAlignments?: ReadonlyArray<Alignment>;
12
35
  defaultAlignment?: Alignment;
36
+ /**
37
+ * A function that provides a public version of the widget options that can
38
+ * be shared with the client.
39
+ */
40
+ getPublicWidgetOptions?: PublicWidgetOptionsFunction;
13
41
  };
@@ -0,0 +1,4 @@
1
+ import type { PerseusMatrixWidgetOptions } from "@khanacademy/perseus-core";
2
+ type MatrixPublicWidgetOptions = Pick<PerseusMatrixWidgetOptions, "prefix" | "suffix" | "cursorPosition" | "matrixBoardSize" | "static">;
3
+ export default function getMatrixPublicWidgetOptions(options: PerseusMatrixWidgetOptions): MatrixPublicWidgetOptions;
4
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { PerseusPlotterWidgetOptions } from "@khanacademy/perseus-core";
2
+ /**
3
+ * For details on the individual options, see the
4
+ * PerseusPlotterWidgetOptions type
5
+ */
6
+ type PlotterPublicWidgetOptions = Omit<PerseusPlotterWidgetOptions, "correct">;
7
+ /**
8
+ * Given a PerseusPlotterWidgetOptions object, return a new object with only
9
+ * the public options that should be exposed to the client.
10
+ */
11
+ declare function getPlotterPublicWidgetOptions(options: PerseusPlotterWidgetOptions): PlotterPublicWidgetOptions;
12
+ export default getPlotterPublicWidgetOptions;
@@ -0,0 +1,26 @@
1
+ import type { PerseusRadioChoice, PerseusRadioWidgetOptions } from "@khanacademy/perseus-core";
2
+ /**
3
+ * For details on the individual options, see the
4
+ * PerseusRadioWidgetOptions type
5
+ */
6
+ type RadioPublicWidgetOptions = {
7
+ choices: ReadonlyArray<RadioChoicePublicData>;
8
+ hasNoneOfTheAbove?: PerseusRadioWidgetOptions["hasNoneOfTheAbove"];
9
+ countChoices?: PerseusRadioWidgetOptions["countChoices"];
10
+ randomize?: PerseusRadioWidgetOptions["randomize"];
11
+ multipleSelect?: PerseusRadioWidgetOptions["multipleSelect"];
12
+ deselectEnabled?: PerseusRadioWidgetOptions["deselectEnabled"];
13
+ onePerLine?: PerseusRadioWidgetOptions["onePerLine"];
14
+ displayCount?: PerseusRadioWidgetOptions["displayCount"];
15
+ noneOfTheAbove?: PerseusRadioWidgetOptions["noneOfTheAbove"];
16
+ };
17
+ /**
18
+ * Only the options from each Radio choice that should be exposed to the client.
19
+ */
20
+ type RadioChoicePublicData = Pick<PerseusRadioChoice, "content" | "isNoneOfTheAbove" | "widgets">;
21
+ /**
22
+ * Given a PerseusRadioWidgetOptions object, return a new object with only
23
+ * the public options that should be exposed to the client.
24
+ */
25
+ declare function getRadioPublicWidgetOptions(options: PerseusRadioWidgetOptions): RadioPublicWidgetOptions;
26
+ export default getRadioPublicWidgetOptions;
@@ -0,0 +1,4 @@
1
+ import type { PerseusTableWidgetOptions } from "@khanacademy/perseus-core";
2
+ type TablePublicWidgetOptions = Pick<PerseusTableWidgetOptions, "headers" | "rows" | "columns">;
3
+ export default function getTablePublicWidgetOptions(options: PerseusTableWidgetOptions): TablePublicWidgetOptions;
4
+ 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.4.0",
6
+ "version": "3.6.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>;