@khanacademy/perseus 51.0.1 → 52.0.1
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/es/index.js +681 -2195
- package/dist/es/index.js.map +1 -1
- package/dist/es/strings.js +123 -15
- package/dist/es/strings.js.map +1 -1
- package/dist/index.d.ts +36 -6
- package/dist/index.js +736 -2203
- package/dist/index.js.map +1 -1
- package/dist/item-version.d.ts +1 -1
- package/dist/renderer-util.d.ts +7 -2
- package/dist/strings.d.ts +101 -1
- package/dist/strings.js +179 -26
- package/dist/strings.js.map +1 -1
- package/dist/types.d.ts +13 -12
- package/dist/widget-ai-utils/mock-widget/prompt-utils.d.ts +1 -1
- package/dist/widget-type-utils.d.ts +1 -22
- package/dist/widgets/categorizer/categorizer.d.ts +5 -5
- package/dist/widgets/cs-program/cs-program.d.ts +3 -2
- package/dist/widgets/dropdown/dropdown.d.ts +2 -1
- package/dist/widgets/expression/expression.d.ts +8 -10
- package/dist/widgets/grapher/grapher.d.ts +2 -1
- package/dist/widgets/group/group.d.ts +4 -2
- package/dist/widgets/group/score-group.d.ts +2 -2
- package/dist/widgets/group/validate-group.d.ts +4 -0
- package/dist/widgets/iframe/iframe.d.ts +3 -2
- package/dist/widgets/input-number/input-number.d.ts +2 -1
- package/dist/widgets/interactive-graph.d.ts +2 -1
- package/dist/widgets/interactive-graphs/graphs/linear.d.ts +2 -0
- package/dist/widgets/interactive-graphs/graphs/quadratic.d.ts +12 -1
- package/dist/widgets/interactive-graphs/graphs/segment.d.ts +2 -0
- package/dist/widgets/interactive-graphs/graphs/utils.d.ts +6 -0
- package/dist/widgets/label-image/label-image.d.ts +5 -4
- package/dist/widgets/matcher/matcher.d.ts +2 -1
- package/dist/widgets/matrix/matrix.d.ts +4 -2
- package/dist/widgets/measurer/measurer.d.ts +3 -8
- package/dist/widgets/mock-widgets/mock-widget-types.d.ts +17 -0
- package/dist/widgets/mock-widgets/mock-widget.d.ts +5 -4
- package/dist/widgets/mock-widgets/score-mock-widget.d.ts +2 -1
- package/dist/widgets/mock-widgets/validate-mock-widget.d.ts +4 -0
- package/dist/widgets/number-line/number-line.d.ts +3 -1
- package/dist/widgets/numeric-input/numeric-input.d.ts +2 -1
- package/dist/widgets/orderer/orderer.d.ts +6 -2
- package/dist/widgets/passage-ref/passage-ref.d.ts +2 -5
- package/dist/widgets/passage-ref-target/passage-ref-target.d.ts +0 -4
- package/dist/widgets/plotter/plotter.d.ts +4 -2
- package/dist/widgets/radio/radio-component.d.ts +1 -1
- package/dist/widgets/radio/radio.d.ts +5 -9
- package/dist/widgets/sorter/sorter.d.ts +3 -1
- package/dist/widgets/table/table.d.ts +3 -1
- package/dist/widgets.d.ts +3 -2
- package/package.json +14 -14
- package/dist/util/is-real-json-parse.d.ts +0 -1
- package/dist/util/parse-perseus-json/error-tracking-parse-context.d.ts +0 -9
- package/dist/util/parse-perseus-json/exhaustive-test-tool/index.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/any.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/array.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/array.typetest.d.ts +0 -1
- package/dist/util/parse-perseus-json/general-purpose-parsers/boolean.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/constant.d.ts +0 -4
- package/dist/util/parse-perseus-json/general-purpose-parsers/convert.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/defaulted.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/discriminated-union.d.ts +0 -21
- package/dist/util/parse-perseus-json/general-purpose-parsers/discriminated-union.typetest.d.ts +0 -1
- package/dist/util/parse-perseus-json/general-purpose-parsers/enumeration.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/enumeration.typetest.d.ts +0 -1
- package/dist/util/parse-perseus-json/general-purpose-parsers/index.d.ts +0 -17
- package/dist/util/parse-perseus-json/general-purpose-parsers/is-object.d.ts +0 -1
- package/dist/util/parse-perseus-json/general-purpose-parsers/nullable.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/number.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/object.d.ts +0 -6
- package/dist/util/parse-perseus-json/general-purpose-parsers/optional.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/pair.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/pipe-parsers.d.ts +0 -7
- package/dist/util/parse-perseus-json/general-purpose-parsers/pipe-parsers.typetest.d.ts +0 -1
- package/dist/util/parse-perseus-json/general-purpose-parsers/record.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/string-to-number.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/string.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/test-helpers.d.ts +0 -8
- package/dist/util/parse-perseus-json/general-purpose-parsers/trio.d.ts +0 -2
- package/dist/util/parse-perseus-json/general-purpose-parsers/union.d.ts +0 -7
- package/dist/util/parse-perseus-json/general-purpose-parsers/union.typetest.d.ts +0 -1
- package/dist/util/parse-perseus-json/general-purpose-parsers/unknown.d.ts +0 -2
- package/dist/util/parse-perseus-json/index.d.ts +0 -45
- package/dist/util/parse-perseus-json/object-path.d.ts +0 -2
- package/dist/util/parse-perseus-json/parse-failure-detail.d.ts +0 -2
- package/dist/util/parse-perseus-json/parse.d.ts +0 -3
- package/dist/util/parse-perseus-json/parser-types.d.ts +0 -30
- package/dist/util/parse-perseus-json/perseus-parsers/categorizer-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/cs-program-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/definition-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/dropdown-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/explanation-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/expression-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/graded-group-set-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/graded-group-widget.d.ts +0 -16
- package/dist/util/parse-perseus-json/perseus-parsers/grapher-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/group-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/hint.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/iframe-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/image-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/images-map.d.ts +0 -5
- package/dist/util/parse-perseus-json/perseus-parsers/input-number-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/interaction-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/interactive-graph-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/label-image-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/matcher-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/matrix-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/measurer-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/molecule-renderer-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/number-line-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/numeric-input-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/orderer-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/passage-ref-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/passage-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/perseus-article.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/perseus-image-background.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/perseus-item.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/perseus-renderer.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/phet-simulation-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/plotter-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/python-program-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/radio-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/sorter-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/table-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/versioned-widget-options.d.ts +0 -36
- package/dist/util/parse-perseus-json/perseus-parsers/video-widget.d.ts +0 -3
- package/dist/util/parse-perseus-json/perseus-parsers/widget.d.ts +0 -7
- package/dist/util/parse-perseus-json/perseus-parsers/widgets-map.d.ts +0 -3
- package/dist/util/parse-perseus-json/result.d.ts +0 -16
- package/dist/util/snowman-utils.d.ts +0 -17
- package/dist/widgets/categorizer/categorizer.util.d.ts +0 -17
|
@@ -6,18 +6,19 @@
|
|
|
6
6
|
* It's particularly well suited for embedding our ProcessingJS programs,
|
|
7
7
|
* but could also be used for embedding viz's hosted elsewhere.
|
|
8
8
|
*/
|
|
9
|
-
import { scoreIframe
|
|
9
|
+
import { scoreIframe } from "@khanacademy/perseus-score";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import type { WidgetProps, Widget } from "../../types";
|
|
12
12
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
13
13
|
import type { PerseusIFrameWidgetOptions } from "@khanacademy/perseus-core";
|
|
14
|
+
import type { PerseusIFrameUserInput, UserInputStatus } from "@khanacademy/perseus-score";
|
|
14
15
|
type RenderProps = PerseusIFrameWidgetOptions & {
|
|
15
16
|
status: UserInputStatus;
|
|
16
17
|
message: string | null;
|
|
17
18
|
width: string;
|
|
18
19
|
height: string;
|
|
19
20
|
};
|
|
20
|
-
type Props = WidgetProps<RenderProps
|
|
21
|
+
type Props = WidgetProps<RenderProps>;
|
|
21
22
|
type DefaultProps = {
|
|
22
23
|
status: Props["status"];
|
|
23
24
|
message: Props["message"];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { scoreInputNumber
|
|
1
|
+
import { scoreInputNumber } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
4
|
import type { Path, Widget, WidgetProps } from "../../types";
|
|
5
5
|
import type { InputNumberPromptJSON } from "../../widget-ai-utils/input-number/input-number-ai-utils";
|
|
6
6
|
import type { PerseusInputNumberWidgetOptions } from "@khanacademy/perseus-core";
|
|
7
|
+
import type { PerseusInputNumberRubric, PerseusInputNumberUserInput } from "@khanacademy/perseus-score";
|
|
7
8
|
type RenderProps = {
|
|
8
9
|
simplify: PerseusInputNumberWidgetOptions["simplify"];
|
|
9
10
|
size: PerseusInputNumberWidgetOptions["size"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { scoreInteractiveGraph
|
|
1
|
+
import { scoreInteractiveGraph } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { PerseusI18nContext } from "../components/i18n-context";
|
|
4
4
|
import type { StatefulMafsGraphType } from "./interactive-graphs/stateful-mafs-graph";
|
|
@@ -9,6 +9,7 @@ import type { InteractiveGraphPromptJSON } from "../widget-ai-utils/interactive-
|
|
|
9
9
|
import type { UnsupportedWidgetPromptJSON } from "../widget-ai-utils/unsupported-widget";
|
|
10
10
|
import type { QuadraticCoefficient, SineCoefficient, Range } from "@khanacademy/kmath";
|
|
11
11
|
import type { PerseusGraphType, PerseusGraphTypeAngle, PerseusGraphTypePoint, PerseusGraphTypePolygon, PerseusGraphTypeSegment, GraphRange, LockedFigure, PerseusImageBackground, MarkingsType } from "@khanacademy/perseus-core";
|
|
12
|
+
import type { PerseusInteractiveGraphRubric, PerseusInteractiveGraphUserInput } from "@khanacademy/perseus-score";
|
|
12
13
|
type RenderProps = {
|
|
13
14
|
/**
|
|
14
15
|
* Where the little black axis lines & labels (ticks) should render.
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { I18nContextType } from "../../../components/i18n-context";
|
|
1
2
|
import type { LinearGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
|
|
2
3
|
export declare function renderLinearGraph(state: LinearGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
|
|
4
|
+
export declare function describeLinearGraph(state: LinearGraphState, i18n: I18nContextType): Record<string, string>;
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
+
import type { I18nContextType } from "../../../components/i18n-context";
|
|
1
2
|
import type { QuadraticGraphState, Dispatch, InteractiveGraphElementSuite } from "../types";
|
|
2
3
|
import type { QuadraticCoefficient, QuadraticCoords } from "@khanacademy/kmath";
|
|
3
|
-
export declare function renderQuadraticGraph(state: QuadraticGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
|
|
4
|
+
export declare function renderQuadraticGraph(state: QuadraticGraphState, dispatch: Dispatch, i18n: I18nContextType): InteractiveGraphElementSuite;
|
|
4
5
|
export declare const getQuadraticCoefficients: (coords: QuadraticCoords) => QuadraticCoefficient | undefined;
|
|
6
|
+
type QuadraticGraphDescriptionStrings = {
|
|
7
|
+
srQuadraticGraph: string;
|
|
8
|
+
srQuadraticDirection?: string;
|
|
9
|
+
srQuadraticVertex?: string;
|
|
10
|
+
srQuadraticXIntercepts?: string;
|
|
11
|
+
srQuadraticYIntercept: string;
|
|
12
|
+
srQuadraticInteractiveElements: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function describeQuadraticGraph(state: QuadraticGraphState, i18n: I18nContextType): QuadraticGraphDescriptionStrings;
|
|
15
|
+
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
+
import type { I18nContextType } from "../../../components/i18n-context";
|
|
1
2
|
import type { Dispatch, InteractiveGraphElementSuite, SegmentGraphState } from "../types";
|
|
2
3
|
export declare function renderSegmentGraph(state: SegmentGraphState, dispatch: Dispatch): InteractiveGraphElementSuite;
|
|
4
|
+
export declare function describeSegmentGraph(state: SegmentGraphState, i18n: I18nContextType): string;
|
|
@@ -13,3 +13,9 @@ export declare const getIntersectionOfRayWithBox: (initialPoint: vec.Vector2, th
|
|
|
13
13
|
export declare function getArrayWithoutDuplicates(array: Array<Coord>): Array<Coord>;
|
|
14
14
|
export declare function getSlopeStringForLine(line: PairOfPoints, strings: PerseusStrings): string;
|
|
15
15
|
export declare function getInterceptStringForLine(line: PairOfPoints, strings: PerseusStrings, locale: string): string;
|
|
16
|
+
type GraphLocations = "origin" | "x-axis" | "y-axis" | 1 | 2 | 3 | 4;
|
|
17
|
+
export declare function getCoordQuadrant(coord: Coord): GraphLocations;
|
|
18
|
+
export declare function getQuadraticVertexString(vertex: Coord, strings: PerseusStrings): string;
|
|
19
|
+
export declare function getQuadraticPointString(pointNumber: any, coord: Coord, strings: PerseusStrings, locale: string): string;
|
|
20
|
+
export declare function getQuadraticXIntercepts(a: number, b: number, c: number): number[];
|
|
21
|
+
export {};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* that involve the use of images, and enable learners to demonstrate their
|
|
6
6
|
* knowledge by directly interacting with the image.
|
|
7
7
|
*/
|
|
8
|
-
import { scoreLabelImage
|
|
8
|
+
import { scoreLabelImage } from "@khanacademy/perseus-score";
|
|
9
9
|
import * as React from "react";
|
|
10
10
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
11
11
|
import Marker from "./marker";
|
|
@@ -14,6 +14,7 @@ import type { ChangeableProps } from "../../mixins/changeable";
|
|
|
14
14
|
import type { APIOptions, Widget } from "../../types";
|
|
15
15
|
import type { LabelImagePromptJSON } from "../../widget-ai-utils/label-image/label-image-ai-utils";
|
|
16
16
|
import type { InteractiveMarkerType, PerseusLabelImageWidgetOptions } from "@khanacademy/perseus-core";
|
|
17
|
+
import type { PerseusLabelImageUserInput } from "@khanacademy/perseus-score";
|
|
17
18
|
export type PreferredPopoverDirection = "NONE" | "UP" | "DOWN" | "LEFT" | "RIGHT";
|
|
18
19
|
/**
|
|
19
20
|
* Represents a direction vector.
|
|
@@ -65,14 +66,14 @@ export declare class LabelImage extends React.Component<LabelImageProps, LabelIm
|
|
|
65
66
|
* Given a cardinal navigation direction (in the x or y axis), return the
|
|
66
67
|
* next marker index to visit.
|
|
67
68
|
*/
|
|
68
|
-
static navigateToMarkerIndex(navigateDirection: Direction, markers:
|
|
69
|
+
static navigateToMarkerIndex(navigateDirection: Direction, markers: LabelImageProps["markers"], thisIndex: number): number;
|
|
69
70
|
constructor(props: LabelImageProps);
|
|
70
71
|
componentDidMount(): void;
|
|
71
72
|
componentWillUnmount(): void;
|
|
72
73
|
getUserInput(): PerseusLabelImageUserInput;
|
|
73
74
|
getPromptJSON(): LabelImagePromptJSON;
|
|
74
|
-
showRationalesForCurrentlySelectedChoices(
|
|
75
|
-
handleMarkerChange(index: number, marker:
|
|
75
|
+
showRationalesForCurrentlySelectedChoices(): void;
|
|
76
|
+
handleMarkerChange(index: number, marker: LabelImageProps["markers"][number]): void;
|
|
76
77
|
activateMarker(index: number, opened: boolean): void;
|
|
77
78
|
handleMarkerKeyDown(index: number, e: React.KeyboardEvent): void;
|
|
78
79
|
handleAnswerChoicesChangeForMarker(index: number, selection: ReadonlyArray<boolean>): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { scoreMatcher
|
|
1
|
+
import { scoreMatcher } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
4
|
import type { SortableOption } from "../../components/sortable";
|
|
5
5
|
import type { WidgetProps, Widget } from "../../types";
|
|
6
6
|
import type { MatcherPromptJSON } from "../../widget-ai-utils/matcher/matcher-ai-utils";
|
|
7
7
|
import type { PerseusMatcherWidgetOptions } from "@khanacademy/perseus-core";
|
|
8
|
+
import type { PerseusMatcherRubric, PerseusMatcherUserInput } from "@khanacademy/perseus-score";
|
|
8
9
|
type RenderProps = PerseusMatcherWidgetOptions;
|
|
9
10
|
type Props = WidgetProps<RenderProps, PerseusMatcherRubric>;
|
|
10
11
|
type DefaultProps = {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { type PerseusMatrixWidgetAnswers } from "@khanacademy/perseus-core";
|
|
2
|
-
import { scoreMatrix,
|
|
2
|
+
import { scoreMatrix, validateMatrix } from "@khanacademy/perseus-score";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
5
|
-
import type {
|
|
5
|
+
import type { FocusPath, Widget, WidgetProps } from "../../types";
|
|
6
6
|
import type { MatrixPromptJSON } from "../../widget-ai-utils/matrix/matrix-ai-utils";
|
|
7
|
+
import type { PerseusMatrixRubric, PerseusMatrixUserInput } from "@khanacademy/perseus-score";
|
|
7
8
|
type ExternalProps = WidgetProps<{
|
|
8
9
|
prefix: string;
|
|
9
10
|
suffix: string;
|
|
@@ -61,5 +62,6 @@ declare const _default: {
|
|
|
61
62
|
staticTransform: (arg1: any) => any;
|
|
62
63
|
isLintable: true;
|
|
63
64
|
scorer: typeof scoreMatrix;
|
|
65
|
+
validator: typeof validateMatrix;
|
|
64
66
|
};
|
|
65
67
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { type PerseusMeasurerWidgetOptions } from "@khanacademy/perseus-core";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import type { Widget, WidgetProps } from "../../types";
|
|
3
4
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
4
|
-
import type { PerseusMeasurerWidgetOptions } from "@khanacademy/perseus-core";
|
|
5
5
|
type Props = WidgetProps<PerseusMeasurerWidgetOptions, PerseusMeasurerWidgetOptions> & {
|
|
6
6
|
protractorX: number;
|
|
7
7
|
protractorY: number;
|
|
@@ -35,13 +35,8 @@ declare const _default: {
|
|
|
35
35
|
displayName: string;
|
|
36
36
|
hidden: true;
|
|
37
37
|
widget: typeof Measurer;
|
|
38
|
-
version:
|
|
39
|
-
|
|
40
|
-
minor: number;
|
|
41
|
-
};
|
|
42
|
-
propUpgrades: {
|
|
43
|
-
readonly "1": (v0props: any) => PerseusMeasurerWidgetOptions;
|
|
44
|
-
};
|
|
38
|
+
version: import("@khanacademy/perseus-core").Version | undefined;
|
|
39
|
+
propUpgrades: import("@khanacademy/perseus-core").WidgetOptionsUpgradeMap | undefined;
|
|
45
40
|
scorer: () => import("@khanacademy/perseus-score").PerseusScore;
|
|
46
41
|
};
|
|
47
42
|
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { WidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
export type MockWidget = WidgetOptions<"mock-widget", MockWidgetOptions>;
|
|
3
|
+
export type MockWidgetOptions = {
|
|
4
|
+
static?: boolean;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
export type PerseusMockWidgetRubric = {
|
|
8
|
+
value: string;
|
|
9
|
+
};
|
|
10
|
+
export type PerseusMockWidgetUserInput = {
|
|
11
|
+
currentValue: string;
|
|
12
|
+
};
|
|
13
|
+
declare module "@khanacademy/perseus-core" {
|
|
14
|
+
interface PerseusWidgetTypes {
|
|
15
|
+
"mock-widget": MockWidget;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import scoreMockWidget from "./score-mock-widget";
|
|
3
|
+
import validateMockWidget from "./validate-mock-widget";
|
|
4
|
+
import type { MockWidgetOptions, PerseusMockWidgetRubric, PerseusMockWidgetUserInput } from "./mock-widget-types";
|
|
3
5
|
import type { WidgetProps, Widget, FocusPath } from "../../types";
|
|
4
6
|
import type { MockWidgetPromptJSON } from "../../widget-ai-utils/mock-widget/prompt-utils";
|
|
5
|
-
import type { MockWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
|
-
import type { PerseusMockWidgetRubric, PerseusMockWidgetUserInput } from "@khanacademy/perseus-score";
|
|
7
7
|
type ExternalProps = WidgetProps<MockWidgetOptions, PerseusMockWidgetRubric>;
|
|
8
8
|
type DefaultProps = {
|
|
9
9
|
currentValue: Props["currentValue"];
|
|
@@ -23,7 +23,7 @@ type Props = ExternalProps & {
|
|
|
23
23
|
*
|
|
24
24
|
* You can register this widget for your tests by calling `registerWidget("mock-widget", MockWidget);`
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
declare class MockWidgetComponent extends React.Component<Props> implements Widget {
|
|
27
27
|
static defaultProps: DefaultProps;
|
|
28
28
|
inputRef: HTMLElement | null;
|
|
29
29
|
static getUserInputFromProps(props: Props): PerseusMockWidgetUserInput;
|
|
@@ -40,8 +40,9 @@ export declare class MockWidget extends React.Component<Props> implements Widget
|
|
|
40
40
|
declare const _default: {
|
|
41
41
|
name: string;
|
|
42
42
|
displayName: string;
|
|
43
|
-
widget: typeof
|
|
43
|
+
widget: typeof MockWidgetComponent;
|
|
44
44
|
isLintable: true;
|
|
45
45
|
scorer: typeof scoreMockWidget;
|
|
46
|
+
validator: typeof validateMockWidget;
|
|
46
47
|
};
|
|
47
48
|
export default _default;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { PerseusMockWidgetUserInput, PerseusMockWidgetRubric } from "./mock-widget-types";
|
|
1
2
|
import type { PerseusStrings } from "../../strings";
|
|
2
|
-
import type {
|
|
3
|
+
import type { PerseusScore } from "@khanacademy/perseus-score";
|
|
3
4
|
declare function scoreMockWidget(userInput: PerseusMockWidgetUserInput, rubric: PerseusMockWidgetRubric, strings: PerseusStrings): PerseusScore;
|
|
4
5
|
export default scoreMockWidget;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { scoreNumberLine,
|
|
1
|
+
import { scoreNumberLine, validateNumberLine } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
4
|
import type { ChangeableProps } from "../../mixins/changeable";
|
|
5
5
|
import type { APIOptions, FocusPath, Widget } from "../../types";
|
|
6
6
|
import type { NumberLinePromptJSON } from "../../widget-ai-utils/number-line/number-line-ai-utils";
|
|
7
7
|
import type { Relationship } from "@khanacademy/perseus-core";
|
|
8
|
+
import type { PerseusNumberLineUserInput } from "@khanacademy/perseus-score";
|
|
8
9
|
type Props = ChangeableProps & {
|
|
9
10
|
range: [number, number];
|
|
10
11
|
labelRange: ReadonlyArray<number | null>;
|
|
@@ -79,5 +80,6 @@ declare const _default: {
|
|
|
79
80
|
transform: (arg1: any) => any;
|
|
80
81
|
staticTransform: (arg1: any) => any;
|
|
81
82
|
scorer: typeof scoreNumberLine;
|
|
83
|
+
validator: typeof validateNumberLine;
|
|
82
84
|
};
|
|
83
85
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { scoreNumericInput
|
|
1
|
+
import { scoreNumericInput } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
4
|
import InputWithExamples from "../../components/input-with-examples";
|
|
@@ -6,6 +6,7 @@ import SimpleKeypadInput from "../../components/simple-keypad-input";
|
|
|
6
6
|
import type { FocusPath, Widget, WidgetProps } from "../../types";
|
|
7
7
|
import type { NumericInputPromptJSON } from "../../widget-ai-utils/numeric-input/prompt-utils";
|
|
8
8
|
import type { PerseusNumericInputWidgetOptions, PerseusNumericInputAnswerForm } from "@khanacademy/perseus-core";
|
|
9
|
+
import type { PerseusNumericInputRubric, PerseusNumericInputUserInput } from "@khanacademy/perseus-score";
|
|
9
10
|
type ExternalProps = WidgetProps<PerseusNumericInputWidgetOptions, PerseusNumericInputRubric>;
|
|
10
11
|
type Props = ExternalProps & {
|
|
11
12
|
size: NonNullable<ExternalProps["size"]>;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getOrdererPublicWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
import { scoreOrderer, validateOrderer } from "@khanacademy/perseus-score";
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
import type {
|
|
4
|
+
import type { Widget, WidgetProps } from "../../types";
|
|
4
5
|
import type { OrdererPromptJSON } from "../../widget-ai-utils/orderer/orderer-ai-utils";
|
|
5
6
|
import type { PerseusOrdererWidgetOptions } from "@khanacademy/perseus-core";
|
|
7
|
+
import type { PerseusOrdererRubric, PerseusOrdererUserInput } from "@khanacademy/perseus-score";
|
|
6
8
|
type Position = {
|
|
7
9
|
left: number;
|
|
8
10
|
top: number;
|
|
@@ -55,5 +57,7 @@ declare const _default: {
|
|
|
55
57
|
widget: typeof Orderer;
|
|
56
58
|
isLintable: true;
|
|
57
59
|
scorer: typeof scoreOrderer;
|
|
60
|
+
validator: typeof validateOrderer;
|
|
61
|
+
getPublicWidgetOptions: typeof getOrdererPublicWidgetOptions;
|
|
58
62
|
};
|
|
59
63
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type PerseusPassageRefWidgetOptions } from "@khanacademy/perseus-core";
|
|
1
2
|
import * as React from "react";
|
|
2
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
3
4
|
import type { ChangeFn, Widget, WidgetProps } from "../../types";
|
|
4
5
|
import type { PassageRefPromptJSON } from "../../widget-ai-utils/passage-ref/passage-ref-ai-utils";
|
|
5
|
-
import type { PerseusPassageRefWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
6
|
type RenderProps = {
|
|
7
7
|
passageNumber: PerseusPassageRefWidgetOptions["passageNumber"];
|
|
8
8
|
referenceNumber: PerseusPassageRefWidgetOptions["referenceNumber"];
|
|
@@ -48,10 +48,7 @@ declare const _default: {
|
|
|
48
48
|
referenceNumber: number;
|
|
49
49
|
summaryText: string | undefined;
|
|
50
50
|
};
|
|
51
|
-
version:
|
|
52
|
-
major: number;
|
|
53
|
-
minor: number;
|
|
54
|
-
};
|
|
51
|
+
version: import("@khanacademy/perseus-core").Version | undefined;
|
|
55
52
|
scorer: () => import("@khanacademy/perseus-score").PerseusScore;
|
|
56
53
|
};
|
|
57
54
|
export default _default;
|
|
@@ -28,10 +28,6 @@ declare const _default: {
|
|
|
28
28
|
widget: typeof PassageRefTarget;
|
|
29
29
|
hidden: true;
|
|
30
30
|
transform: (editorProps: any) => any;
|
|
31
|
-
version: {
|
|
32
|
-
major: number;
|
|
33
|
-
minor: number;
|
|
34
|
-
};
|
|
35
31
|
isLintable: true;
|
|
36
32
|
scorer: () => import("@khanacademy/perseus-score").PerseusScore;
|
|
37
33
|
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { scorePlotter,
|
|
1
|
+
import { scorePlotter, validatePlotter } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
4
|
import type { Widget, WidgetProps } from "../../types";
|
|
5
5
|
import type { UnsupportedWidgetPromptJSON } from "../../widget-ai-utils/unsupported-widget";
|
|
6
6
|
import type { PerseusPlotterWidgetOptions } from "@khanacademy/perseus-core";
|
|
7
|
+
import type { PerseusPlotterRubric, PerseusPlotterUserInput } from "@khanacademy/perseus-score";
|
|
7
8
|
type RenderProps = PerseusPlotterWidgetOptions;
|
|
8
|
-
type Props = WidgetProps<RenderProps,
|
|
9
|
+
type Props = WidgetProps<RenderProps, PerseusPlotterRubric> & {
|
|
9
10
|
labelInterval: NonNullable<PerseusPlotterWidgetOptions["labelInterval"]>;
|
|
10
11
|
picSize: NonNullable<PerseusPlotterWidgetOptions["picSize"]>;
|
|
11
12
|
};
|
|
@@ -76,5 +77,6 @@ declare const _default: {
|
|
|
76
77
|
widget: typeof Plotter;
|
|
77
78
|
staticTransform: <T>(value: T) => T;
|
|
78
79
|
scorer: typeof scorePlotter;
|
|
80
|
+
validator: typeof validatePlotter;
|
|
79
81
|
};
|
|
80
82
|
export default _default;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { type PerseusRadioRubric, type PerseusRadioUserInput } from "@khanacademy/perseus-score";
|
|
2
1
|
import * as React from "react";
|
|
3
2
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
3
|
import type { FocusFunction } from "./base-radio";
|
|
5
4
|
import type { WidgetProps, ChoiceState, Widget } from "../../types";
|
|
6
5
|
import type { RadioPromptJSON } from "../../widget-ai-utils/radio/radio-ai-utils";
|
|
7
6
|
import type { PerseusRadioChoice, PerseusRadioWidgetOptions, ShowSolutions } from "@khanacademy/perseus-core";
|
|
7
|
+
import type { PerseusRadioRubric, PerseusRadioUserInput } from "@khanacademy/perseus-score";
|
|
8
8
|
export type RenderProps = {
|
|
9
9
|
numCorrect: number;
|
|
10
10
|
hasNoneOfTheAbove?: boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type PerseusRadioWidgetOptions } from "@khanacademy/perseus-core";
|
|
2
|
+
import { scoreRadio, validateRadio } from "@khanacademy/perseus-score";
|
|
2
3
|
import Radio from "./radio-component";
|
|
3
4
|
import type { RenderProps } from "./radio-component";
|
|
4
5
|
import type { PerseusStrings } from "../../strings";
|
|
5
|
-
import type { PerseusRadioWidgetOptions } from "@khanacademy/perseus-core";
|
|
6
6
|
declare const _default: {
|
|
7
7
|
name: string;
|
|
8
8
|
displayName: string;
|
|
@@ -10,14 +10,10 @@ declare const _default: {
|
|
|
10
10
|
widget: typeof Radio;
|
|
11
11
|
transform: (widgetOptions: PerseusRadioWidgetOptions, strings: PerseusStrings, problemNum?: number | null) => RenderProps;
|
|
12
12
|
staticTransform: (widgetOptions: PerseusRadioWidgetOptions, strings: PerseusStrings, problemNum?: number | null) => RenderProps;
|
|
13
|
-
version:
|
|
14
|
-
|
|
15
|
-
minor: number;
|
|
16
|
-
};
|
|
17
|
-
propUpgrades: {
|
|
18
|
-
readonly "1": (v0props: any) => PerseusRadioWidgetOptions;
|
|
19
|
-
};
|
|
13
|
+
version: import("@khanacademy/perseus-core").Version | undefined;
|
|
14
|
+
propUpgrades: import("@khanacademy/perseus-core").WidgetOptionsUpgradeMap | undefined;
|
|
20
15
|
isLintable: true;
|
|
21
16
|
scorer: typeof scoreRadio;
|
|
17
|
+
validator: typeof validateRadio;
|
|
22
18
|
};
|
|
23
19
|
export default _default;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { scoreSorter,
|
|
1
|
+
import { scoreSorter, validateSorter } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import type { SortableOption } from "../../components/sortable";
|
|
4
4
|
import type { Widget, WidgetProps } from "../../types";
|
|
5
5
|
import type { SorterPromptJSON } from "../../widget-ai-utils/sorter/sorter-ai-utils";
|
|
6
6
|
import type { PerseusSorterWidgetOptions } from "@khanacademy/perseus-core";
|
|
7
|
+
import type { PerseusSorterRubric, PerseusSorterUserInput } from "@khanacademy/perseus-score";
|
|
7
8
|
type RenderProps = PerseusSorterWidgetOptions;
|
|
8
9
|
type Props = WidgetProps<RenderProps, PerseusSorterRubric>;
|
|
9
10
|
type DefaultProps = {
|
|
@@ -35,5 +36,6 @@ declare const _default: {
|
|
|
35
36
|
widget: typeof Sorter;
|
|
36
37
|
isLintable: true;
|
|
37
38
|
scorer: typeof scoreSorter;
|
|
39
|
+
validator: typeof validateSorter;
|
|
38
40
|
};
|
|
39
41
|
export default _default;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { scoreTable,
|
|
1
|
+
import { scoreTable, validateTable } from "@khanacademy/perseus-score";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { PerseusI18nContext } from "../../components/i18n-context";
|
|
4
4
|
import type { ChangeableProps } from "../../mixins/changeable";
|
|
5
5
|
import type { Widget, WidgetProps } from "../../types";
|
|
6
6
|
import type { PerseusTableWidgetOptions } from "@khanacademy/perseus-core";
|
|
7
|
+
import type { PerseusTableRubric, PerseusTableUserInput } from "@khanacademy/perseus-score";
|
|
7
8
|
type RenderProps = PerseusTableWidgetOptions & {
|
|
8
9
|
editableHeaders: boolean;
|
|
9
10
|
Editor: any;
|
|
@@ -46,5 +47,6 @@ declare const _default: {
|
|
|
46
47
|
hidden: true;
|
|
47
48
|
isLintable: true;
|
|
48
49
|
scorer: typeof scoreTable;
|
|
50
|
+
validator: typeof validateTable;
|
|
49
51
|
};
|
|
50
52
|
export default _default;
|
package/dist/widgets.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PerseusStrings } from "./strings";
|
|
2
|
-
import type { Alignment, Tracking,
|
|
3
|
-
import type { PerseusWidget } from "@khanacademy/perseus-core";
|
|
2
|
+
import type { Alignment, Tracking, WidgetExports, WidgetTransform, WidgetScorerFunction, WidgetValidatorFunction, PublicWidgetOptionsFunction } from "./types";
|
|
3
|
+
import type { PerseusWidget, Version } from "@khanacademy/perseus-core";
|
|
4
4
|
import type * as React from "react";
|
|
5
5
|
type Editor = any;
|
|
6
6
|
export declare const registerWidget: (name: string, widget: WidgetExports) => void;
|
|
@@ -28,6 +28,7 @@ export declare const replaceEditor: (name: string, replacementName: string) => v
|
|
|
28
28
|
export declare const replaceDeprecatedEditors: () => void;
|
|
29
29
|
export declare const getWidget: (name: string) => React.ComponentType<any> | null | undefined;
|
|
30
30
|
export declare const getWidgetExport: (name: string) => WidgetExports | null;
|
|
31
|
+
export declare const getWidgetValidator: (name: string) => WidgetValidatorFunction | null;
|
|
31
32
|
export declare const getWidgetScorer: (name: string) => WidgetScorerFunction | null;
|
|
32
33
|
export declare const getPublicWidgetOptionsFunction: (name: string) => PublicWidgetOptionsFunction;
|
|
33
34
|
export declare const getEditor: (name: string) => Editor | null | undefined;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Core Perseus API (includes renderers and widgets)",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "
|
|
6
|
+
"version": "52.0.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"test": "bash -c 'yarn --silent --cwd \"../..\" test ${@:0} $($([[ ${@: -1} = -* ]] || [[ ${@: -1} = bash ]]) && echo $PWD)'"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@khanacademy/kas": "^0.4.
|
|
45
|
-
"@khanacademy/keypad-context": "^1.0.
|
|
46
|
-
"@khanacademy/kmath": "^0.3.
|
|
47
|
-
"@khanacademy/math-input": "^22.2.
|
|
48
|
-
"@khanacademy/perseus-core": "3.
|
|
49
|
-
"@khanacademy/perseus-linter": "^1.2.
|
|
50
|
-
"@khanacademy/perseus-score": "^
|
|
51
|
-
"@khanacademy/pure-markdown": "^0.3.
|
|
52
|
-
"@khanacademy/simple-markdown": "^0.13.
|
|
44
|
+
"@khanacademy/kas": "^0.4.12",
|
|
45
|
+
"@khanacademy/keypad-context": "^1.0.15",
|
|
46
|
+
"@khanacademy/kmath": "^0.3.1",
|
|
47
|
+
"@khanacademy/math-input": "^22.2.2",
|
|
48
|
+
"@khanacademy/perseus-core": "3.3.0",
|
|
49
|
+
"@khanacademy/perseus-linter": "^1.2.14",
|
|
50
|
+
"@khanacademy/perseus-score": "^2.0.0",
|
|
51
|
+
"@khanacademy/pure-markdown": "^0.3.23",
|
|
52
|
+
"@khanacademy/simple-markdown": "^0.13.16",
|
|
53
53
|
"@types/classnames": "2.2.0",
|
|
54
54
|
"@use-gesture/react": "^10.2.27",
|
|
55
55
|
"mafs": "0.19.0",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"@khanacademy/wonder-blocks-clickable": "5.0.5",
|
|
62
62
|
"@khanacademy/wonder-blocks-core": "11.1.0",
|
|
63
63
|
"@khanacademy/wonder-blocks-data": "14.0.6",
|
|
64
|
-
"@khanacademy/wonder-blocks-dropdown": "7.0.
|
|
65
|
-
"@khanacademy/wonder-blocks-form": "6.0.
|
|
64
|
+
"@khanacademy/wonder-blocks-dropdown": "7.0.6",
|
|
65
|
+
"@khanacademy/wonder-blocks-form": "6.0.6",
|
|
66
66
|
"@khanacademy/wonder-blocks-icon": "5.0.5",
|
|
67
67
|
"@khanacademy/wonder-blocks-icon-button": "6.0.5",
|
|
68
68
|
"@khanacademy/wonder-blocks-layout": "3.0.5",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"@khanacademy/wonder-blocks-clickable": "5.0.5",
|
|
97
97
|
"@khanacademy/wonder-blocks-core": "11.1.0",
|
|
98
98
|
"@khanacademy/wonder-blocks-data": "14.0.6",
|
|
99
|
-
"@khanacademy/wonder-blocks-dropdown": "7.0.
|
|
100
|
-
"@khanacademy/wonder-blocks-form": "6.0.
|
|
99
|
+
"@khanacademy/wonder-blocks-dropdown": "7.0.6",
|
|
100
|
+
"@khanacademy/wonder-blocks-form": "6.0.6",
|
|
101
101
|
"@khanacademy/wonder-blocks-icon": "5.0.5",
|
|
102
102
|
"@khanacademy/wonder-blocks-icon-button": "6.0.5",
|
|
103
103
|
"@khanacademy/wonder-blocks-layout": "3.0.5",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isRealJSONParse(jsonParse: typeof JSON.parse): boolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ParseContext, Mismatch, PathSegment } from "./parser-types";
|
|
2
|
-
import type { Failure, Success } from "./result";
|
|
3
|
-
export declare class ErrorTrackingParseContext implements ParseContext {
|
|
4
|
-
private readonly path;
|
|
5
|
-
constructor(path: PathSegment[]);
|
|
6
|
-
failure(expected: string | string[], badValue: unknown): Failure<Mismatch[]>;
|
|
7
|
-
forSubtree(key: PathSegment): ParseContext;
|
|
8
|
-
success<T>(value: T): Success<T>;
|
|
9
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { Parser } from "../parser-types";
|
|
2
|
-
type Primitive = number | string | boolean | null | undefined;
|
|
3
|
-
/**
|
|
4
|
-
* discriminatedUnion() should be preferred over union() when parsing a
|
|
5
|
-
* discriminated union type, because discriminatedUnion() produces more
|
|
6
|
-
* understandable failure messages. It takes the discriminant as the source of
|
|
7
|
-
* truth for which variant is to be parsed, and expects the other data to match
|
|
8
|
-
* that variant.
|
|
9
|
-
*/
|
|
10
|
-
export declare function discriminatedUnionOn<DK extends string>(discriminantKey: DK): DiscriminatedUnionBuilder<DK, never>;
|
|
11
|
-
declare class DiscriminatedUnionBuilder<DK extends string, Union extends {
|
|
12
|
-
[k in DK]: Primitive;
|
|
13
|
-
}> {
|
|
14
|
-
private discriminantKey;
|
|
15
|
-
parser: Parser<Union>;
|
|
16
|
-
constructor(discriminantKey: DK, parser: Parser<Union>);
|
|
17
|
-
withBranch<Variant extends {
|
|
18
|
-
[k in DK]: Primitive;
|
|
19
|
-
}>(discriminantValue: Primitive, parseNewVariant: Parser<Variant>): DiscriminatedUnionBuilder<DK, Union | Variant>;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
package/dist/util/parse-perseus-json/general-purpose-parsers/discriminated-union.typetest.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|