@khanacademy/perseus 19.1.8 → 19.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.
@@ -0,0 +1,9 @@
1
+ import WrappedPath from "./wrapped-path";
2
+ import type { Graphie } from "../util/graphie";
3
+ import type { Coord } from "@khanacademy/perseus";
4
+ export declare class Arrowhead extends WrappedPath {
5
+ private static scale;
6
+ center: Coord;
7
+ constructor(graphie: Graphie, style: any);
8
+ toCoordAtAngle(coord: Coord, angle: number): void;
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { Coord } from "@khanacademy/perseus";
2
+ export declare const getClipPoint: (graph: any, coord: Coord, angle: number) => any;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Default methods for a wrapped movable.
3
+ */
4
+ import type { Coord } from "./types";
5
+ import type { Graphie } from "../util/graphie";
6
+ export interface VisibleShape {
7
+ attr: (...args: any[]) => void;
8
+ animate: (...args: any[]) => void;
9
+ remove: () => void;
10
+ hide: () => void;
11
+ show: () => void;
12
+ }
13
+ export default abstract class WrappedDrawing {
14
+ graphie: Graphie;
15
+ abstract wrapper: HTMLDivElement;
16
+ abstract visibleShape: VisibleShape;
17
+ initialPoint: Coord;
18
+ constructor(graphie: Graphie, initialPoint: Coord);
19
+ transform(transformation: any): void;
20
+ toFront(): void;
21
+ toBack(): void;
22
+ remove(): void;
23
+ getMouseTarget(): any;
24
+ moveTo(point: any): void;
25
+ hide(): void;
26
+ show(): void;
27
+ attr(...args: any[]): void;
28
+ animate(...args: any[]): void;
29
+ }
@@ -1,3 +1,10 @@
1
+ import WrappedDrawing from "./wrapped-drawing";
1
2
  import type { Coord } from "./types";
2
- declare const WrappedEllipse: (graphie: any, center: Coord, radii: [number, number], options: any) => void;
3
+ import type { VisibleShape } from "./wrapped-drawing";
4
+ declare class WrappedEllipse extends WrappedDrawing {
5
+ initialPoint: Coord;
6
+ wrapper: HTMLDivElement;
7
+ visibleShape: VisibleShape;
8
+ constructor(graphie: any, center: Coord, radii: [number, number], options: any);
9
+ }
3
10
  export default WrappedEllipse;
@@ -1,3 +1,12 @@
1
+ import WrappedDrawing from "./wrapped-drawing";
1
2
  import type { Coord } from "./types";
2
- declare const WrappedLine: (graphie: any, start: Coord, end: Coord, options: any) => void;
3
+ import type { VisibleShape } from "./wrapped-drawing";
4
+ declare class WrappedLine extends WrappedDrawing {
5
+ initialLength: number;
6
+ wrapper: HTMLDivElement;
7
+ visibleShape: VisibleShape;
8
+ constructor(graphie: any, start: Coord, end: Coord, options: any);
9
+ getMouseTarget(): HTMLDivElement;
10
+ moveTo(start: any, end: any): void;
11
+ }
3
12
  export default WrappedLine;
@@ -1,3 +1,9 @@
1
+ import WrappedDrawing from "./wrapped-drawing";
1
2
  import type { Coord } from "./types";
2
- declare const WrappedPath: (graphie: any, points: ReadonlyArray<Coord>, options: any) => void;
3
+ import type { VisibleShape } from "./wrapped-drawing";
4
+ declare class WrappedPath extends WrappedDrawing {
5
+ wrapper: HTMLDivElement;
6
+ visibleShape: VisibleShape;
7
+ constructor(graphie: any, points: ReadonlyArray<Coord>, options: any);
8
+ }
3
9
  export default WrappedPath;
@@ -39,7 +39,7 @@ export declare const Errors: Readonly<{
39
39
  /**
40
40
  * @type {ErrorKind} The kind of error being reported
41
41
  */
42
- export type ErrorKind = typeof Errors[keyof typeof Errors];
42
+ export type ErrorKind = (typeof Errors)[keyof typeof Errors];
43
43
  export type LogErrorOptions = {
44
44
  cause?: Error | null | undefined;
45
45
  loggedMetadata?: Metadata | null | undefined;
@@ -31,7 +31,7 @@ export type PerseusImageDetail = {
31
31
  height: number;
32
32
  };
33
33
  export declare const ItemExtras: readonly ["calculator", "chi2Table", "financialCalculatorMonthlyPayment", "financialCalculatorTotalAmount", "financialCalculatorTimeToPayOff", "periodicTable", "periodicTableWithKey", "tTable", "zTable"];
34
- export type PerseusAnswerArea = Record<typeof ItemExtras[number], boolean>;
34
+ export type PerseusAnswerArea = Record<(typeof ItemExtras)[number], boolean>;
35
35
  type Widget<Type extends string, Options> = {
36
36
  type: Type;
37
37
  static?: boolean;
@@ -65,6 +65,7 @@ export type OrdererWidget = Widget<'orderer', PerseusOrdererWidgetOptions>;
65
65
  export type PassageRefWidget = Widget<'passage-ref', PerseusPassageRefWidgetOptions>;
66
66
  export type PassageWidget = Widget<'passage', PerseusPassageWidgetOptions>;
67
67
  export type PlotterWidget = Widget<'plotter', PerseusPlotterWidgetOptions>;
68
+ export type PythonProgramWidget = Widget<'python-program', PerseusPythonProgramWidgetOptions>;
68
69
  export type RadioWidget = Widget<'radio', PerseusRadioWidgetOptions>;
69
70
  export type SequenceWidget = Widget<'sequence', PerseusSequenceWidgetOptions>;
70
71
  export type SimulatorWidget = Widget<'simulator', PerseusSimulatorWidgetOptions>;
@@ -81,7 +82,7 @@ export type SimpleMarkdownTesterWidget = Widget<'simple-markdown-tester', Perseu
81
82
  export type UnitInputWidget = Widget<'unit-input', PerseusUnitInputWidgetOptions>;
82
83
  export type VideoWidget = Widget<'video', PerseusVideoWidgetOptions>;
83
84
  export type AutoCorrectWidget = Widget<'deprecated-standin', PerseusWidgetOptions>;
84
- export type PerseusWidget = CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ExampleGraphieWidget | ExampleWidget | ExplanationWidget | ExpressionWidget | GradedGroupSetWidget | GradedGroupWidget | GrapherWidget | GroupWidget | IFrameWidget | ImageWidget | InputNumberWidget | InteractionWidget | InteractiveGraphWidget | LabelImageWidget | LightsPuzzleWidget | MatcherWidget | MatrixWidget | MeasurerWidget | MoleculeRendererWidget | NumberLineWidget | NumericInputWidget | OrdererWidget | PassageRefWidget | PassageWidget | PlotterWidget | RadioWidget | ReactionDiagramWidget | RefTargetWidget | SequenceWidget | SimpleMarkdownTesterWidget | SimulatorWidget | SorterWidget | TableWidget | UnitInputWidget | VideoWidget | AutoCorrectWidget;
85
+ export type PerseusWidget = CategorizerWidget | CSProgramWidget | DefinitionWidget | DropdownWidget | ExampleGraphieWidget | ExampleWidget | ExplanationWidget | ExpressionWidget | GradedGroupSetWidget | GradedGroupWidget | GrapherWidget | GroupWidget | IFrameWidget | ImageWidget | InputNumberWidget | InteractionWidget | InteractiveGraphWidget | LabelImageWidget | LightsPuzzleWidget | MatcherWidget | MatrixWidget | MeasurerWidget | MoleculeRendererWidget | NumberLineWidget | NumericInputWidget | OrdererWidget | PassageRefWidget | PassageWidget | PlotterWidget | PythonProgramWidget | RadioWidget | ReactionDiagramWidget | RefTargetWidget | SequenceWidget | SimpleMarkdownTesterWidget | SimulatorWidget | SorterWidget | TableWidget | UnitInputWidget | VideoWidget | AutoCorrectWidget;
85
86
  export type PerseusImageBackground = {
86
87
  url: string | null | undefined;
87
88
  width?: number;
@@ -141,7 +142,7 @@ export type PerseusExpressionAnswerForm = {
141
142
  value: string;
142
143
  form: boolean;
143
144
  simplify: boolean;
144
- considered: typeof PerseusExpressionAnswerFormConsidered[number];
145
+ considered: (typeof PerseusExpressionAnswerFormConsidered)[number];
145
146
  key?: string;
146
147
  };
147
148
  export type PerseusGradedGroupWidgetOptions = {
@@ -410,7 +411,7 @@ export type PerseusPassageRefWidgetOptions = {
410
411
  summaryText: string;
411
412
  };
412
413
  export declare const plotterPlotTypes: readonly ["bar", "line", "pic", "histogram", "dotplot"];
413
- export type PlotType = typeof plotterPlotTypes[number];
414
+ export type PlotType = (typeof plotterPlotTypes)[number];
414
415
  export type PerseusPlotterWidgetOptions = {
415
416
  labels: ReadonlyArray<string>;
416
417
  categories: ReadonlyArray<string>;
@@ -636,6 +637,10 @@ export type PerseusCSProgramSetting = {
636
637
  name: string;
637
638
  value: string;
638
639
  };
640
+ export type PerseusPythonProgramWidgetOptions = {
641
+ programID: string;
642
+ height: number;
643
+ };
639
644
  export type PerseusIFrameWidgetOptions = {
640
645
  url: string;
641
646
  settings: ReadonlyArray<PerseusCSProgramSetting>;
package/dist/strings.js CHANGED
@@ -36,6 +36,7 @@ module.exports = [
36
36
  i18n._("an integer, like $6$", {}),
37
37
  i18n._("Beginning of reading passage footnotes.", {}),
38
38
  i18n._("Beginning of reading passage.", {}),
39
+ i18n._("Bring back", {}),
39
40
  i18n._("Check", {}),
40
41
  i18n._("Check your significant figures.", {}),
41
42
  i18n._("Check your units.", {}),
@@ -53,6 +54,9 @@ module.exports = [
53
54
  i18n._("Correct (but you crossed it out)", {}),
54
55
  i18n._("Correct (selected)", {}),
55
56
  i18n._("Correct!", {}),
57
+ i18n._("Cross out", {}),
58
+ i18n._("Cross out Choice %(letter)s", {}),
59
+ i18n._("Cross out option", {}),
56
60
  i18n._("Current", {}),
57
61
  i18n._("Drag handles to make graph", {}),
58
62
  i18n._("End of reading passage.", {}),
@@ -34,6 +34,9 @@ export declare class Graphie {
34
34
  #private;
35
35
  el: Element;
36
36
  raphael?: any;
37
+ mouselayer?: any;
38
+ _mouselayerWrapper?: HTMLDivElement;
39
+ _visiblelayerWrapper?: HTMLDivElement;
37
40
  isMobile: boolean;
38
41
  currentStyle: any;
39
42
  range?: [Interval, Interval];
@@ -104,19 +107,32 @@ export declare class Graphie {
104
107
  unscalePoint: (point: number | Coord) => any;
105
108
  unscaleVector: (point: number | Coord) => any;
106
109
  private processAttributes;
107
- getMouseCoord(event: Readonly<{
108
- pageX?: number;
109
- pageY?: number;
110
- }>): Coord;
111
110
  addMouseLayer(options: {
112
111
  onClick?: MouseHandler;
113
112
  onMouseMove?: MouseHandler;
114
- onMouseDown?: MouseHandler;
115
- onMouseOver?: MouseHandler;
116
- onMouseOut?: MouseHandler;
113
+ onMouseDown?: MouseHandler | null;
114
+ onMouseOver?: MouseHandler | null;
115
+ onMouseOut?: MouseHandler | null;
116
+ onMouseUp?: MouseHandler | null;
117
117
  allowScratchpad?: boolean;
118
118
  setDrawingAreaAvailable?: (available: boolean) => void;
119
119
  }): void;
120
+ addToMouseLayerWrapper(el: HTMLElement): void;
121
+ addToVisibleLayerWrapper(el: HTMLElement): void;
122
+ /**
123
+ * Get mouse coordinates in pixels
124
+ */
125
+ getMousePx(event: Readonly<{
126
+ pageX?: number;
127
+ pageY?: number;
128
+ }>): Coord;
129
+ /**
130
+ * Get mouse coordinates in graph coordinates
131
+ */
132
+ getMouseCoord(event: Readonly<{
133
+ pageX?: number;
134
+ pageY?: number;
135
+ }>): Coord;
120
136
  }
121
137
  type RangeSpecifier = [Interval, Interval] | Coord | number;
122
138
  export declare function normalizeRange(range: RangeSpecifier): [Interval, Interval];
@@ -4,6 +4,6 @@ export declare const containerSizeClass: {
4
4
  readonly LARGE: "large";
5
5
  readonly XLARGE: "xlarge";
6
6
  };
7
- export type SizeClass = typeof containerSizeClass[keyof typeof containerSizeClass];
7
+ export type SizeClass = (typeof containerSizeClass)[keyof typeof containerSizeClass];
8
8
  export declare const getClassFromWidth: (width: number) => SizeClass;
9
9
  export declare const getInteractiveBoxFromSizeClass: (sizeClass: SizeClass) => [number, number];
@@ -212,7 +212,7 @@ declare const _default: Readonly<{
212
212
  onFocus: (blurPath: import("../types").FocusPath) => void;
213
213
  times: boolean;
214
214
  value: string;
215
- }, "onChange" | "trackInteraction" | "static" | "analytics" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "keypadElement" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
215
+ }, "onChange" | "analytics" | "buttonsVisible" | "static" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
216
216
  onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
217
217
  onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
218
218
  value?: string | undefined;
@@ -401,7 +401,7 @@ declare const _default: Readonly<{
401
401
  onFocus: (blurPath: import("../types").FocusPath) => void;
402
402
  times: boolean;
403
403
  value: string;
404
- }, "onChange" | "trackInteraction" | "static" | "analytics" | "buttonsVisible" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "keypadElement" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
404
+ }, "onChange" | "analytics" | "buttonsVisible" | "static" | "containerSizeClass" | "widgetId" | "problemNum" | "questionCompleted" | "findWidgets" | "trackInteraction" | "keypadElement" | "keypadConfiguration" | "alignment" | "reviewModeRubric" | "isLastUsedWidget"> & {
405
405
  onFocus?: ((blurPath: import("../types").FocusPath) => void) | undefined;
406
406
  onBlur?: ((blurPath: import("../types").FocusPath) => void) | undefined;
407
407
  value?: string | undefined;
@@ -24,7 +24,7 @@ type DefaultProps = {
24
24
  linterContext: Props["linterContext"];
25
25
  };
26
26
  type State = {
27
- status: typeof GRADING_STATUSES[keyof typeof GRADING_STATUSES];
27
+ status: (typeof GRADING_STATUSES)[keyof typeof GRADING_STATUSES];
28
28
  showHint: boolean;
29
29
  message: string;
30
30
  answerBarState: ANSWER_BAR_STATES;
@@ -0,0 +1,33 @@
1
+ import * as React from "react";
2
+ type Props = {
3
+ programID: string;
4
+ height: number;
5
+ };
6
+ type DefaultProps = {
7
+ height: Props["height"];
8
+ };
9
+ declare class PythonProgram extends React.Component<Props> {
10
+ static defaultProps: DefaultProps;
11
+ render(): React.ReactNode;
12
+ }
13
+ declare const _default: Readonly<{
14
+ name: string;
15
+ displayName: string;
16
+ getWidget?: (() => typeof PythonProgram) | undefined;
17
+ widget: typeof PythonProgram;
18
+ accessible?: boolean | ((props: any) => boolean) | undefined;
19
+ hidden?: boolean | undefined;
20
+ version?: import("../types").Version | undefined;
21
+ supportedAlignments?: readonly import("../types").Alignment[] | undefined;
22
+ defaultAlignment?: import("../types").Alignment | undefined;
23
+ getDefaultAlignment?: (() => import("../types").Alignment) | undefined;
24
+ isLintable?: boolean | undefined;
25
+ tracking?: import("../types").Tracking | undefined;
26
+ traverseChildWidgets?: any;
27
+ transform?: import("../types").WidgetTransform | undefined;
28
+ staticTransform?: import("../types").WidgetTransform | undefined;
29
+ propUpgrades?: {
30
+ [key: string]: (arg1: any) => any;
31
+ } | undefined;
32
+ }>;
33
+ export default _default;
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": "19.1.8",
6
+ "version": "19.2.0",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -27,10 +27,10 @@
27
27
  "dependencies": {
28
28
  "@khanacademy/kas": "^0.3.8",
29
29
  "@khanacademy/kmath": "^0.1.12",
30
- "@khanacademy/math-input": "^17.0.7",
30
+ "@khanacademy/math-input": "^17.0.8",
31
31
  "@khanacademy/perseus-core": "1.4.2",
32
- "@khanacademy/perseus-linter": "^0.3.11",
33
- "@khanacademy/pure-markdown": "^0.2.14",
32
+ "@khanacademy/perseus-linter": "^0.3.12",
33
+ "@khanacademy/pure-markdown": "^0.2.15",
34
34
  "@khanacademy/simple-markdown": "^0.11.3",
35
35
  "@khanacademy/wonder-blocks-banner": "^3.0.33"
36
36
  },
@@ -1,5 +0,0 @@
1
- /**
2
- * Default methods for a wrapped movable.
3
- */
4
- declare const WrappedDefaults: any;
5
- export default WrappedDefaults;