@khanacademy/perseus 19.1.1 → 19.1.3
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/CHANGELOG.md +24 -0
- package/dist/all-widgets.d.ts +1 -1
- package/dist/basic-widgets.d.ts +1 -1
- package/dist/components/graph.d.ts +7 -6
- package/dist/components/graphie.d.ts +8 -1
- package/dist/es/index.js +49 -51
- package/dist/es/index.js.map +1 -1
- package/dist/extra-widgets.d.ts +1 -1
- package/dist/index.js +48 -49
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +3 -3
- package/dist/types.d.ts +1 -1
- package/dist/util/graphie.d.ts +13 -6
- package/dist/widgets/categorizer.d.ts +1 -1
- package/dist/widgets/cs-program.d.ts +1 -1
- package/dist/widgets/definition.d.ts +1 -1
- package/dist/widgets/deprecated-standin/index.d.ts +1 -1
- package/dist/widgets/dropdown.d.ts +1 -1
- package/dist/widgets/explanation.d.ts +1 -1
- package/dist/widgets/expression.d.ts +14 -14
- package/dist/widgets/graded-group-set.d.ts +1 -1
- package/dist/widgets/graded-group.d.ts +1 -1
- package/dist/widgets/grapher.d.ts +1 -1
- package/dist/widgets/group.d.ts +1 -1
- package/dist/widgets/iframe.d.ts +1 -1
- package/dist/widgets/image.d.ts +1 -1
- package/dist/widgets/input-number.d.ts +1 -1
- package/dist/widgets/interaction.d.ts +1 -1
- package/dist/widgets/interactive-graph.d.ts +1 -1
- package/dist/widgets/label-image.d.ts +14 -14
- package/dist/widgets/lights-puzzle.d.ts +1 -1
- package/dist/widgets/matcher.d.ts +1 -1
- package/dist/widgets/matrix.d.ts +1 -1
- package/dist/widgets/measurer.d.ts +5 -5
- package/dist/widgets/molecule.d.ts +1 -1
- package/dist/widgets/number-line.d.ts +1 -1
- package/dist/widgets/numeric-input.d.ts +1 -1
- package/dist/widgets/orderer.d.ts +1 -1
- package/dist/widgets/passage-ref-target.d.ts +1 -1
- package/dist/widgets/passage-ref.d.ts +1 -1
- package/dist/widgets/passage.d.ts +1 -1
- package/dist/widgets/plotter.d.ts +1 -1
- package/dist/widgets/radio.d.ts +1 -1
- package/dist/widgets/reaction-diagram.d.ts +1 -1
- package/dist/widgets/sequence.d.ts +1 -1
- package/dist/widgets/simulator.d.ts +1 -1
- package/dist/widgets/sorter.d.ts +1 -1
- package/dist/widgets/table.d.ts +1 -1
- package/dist/widgets/unit.d.ts +1 -1
- package/dist/widgets/video.d.ts +1 -1
- package/package.json +3 -3
- package/src/__tests__/init.test.ts +10 -0
- package/src/__tests__/widgets.test.ts +2 -3
- package/src/components/graph.tsx +25 -20
- package/src/components/graphie.tsx +19 -14
- package/src/init.ts +1 -4
- package/src/perseus-types.ts +3 -3
- package/src/types.ts +4 -2
- package/src/util/graphie.test.ts +1 -15
- package/src/util/graphie.ts +14 -24
- package/src/util/interactive.ts +2 -2
- package/src/widgets/__tests__/__snapshots__/input-number.test.ts.snap +1 -1
- package/src/widgets/__tests__/__snapshots__/numeric-input.test.ts.snap +1 -1
- package/src/widgets/label-image/marker.tsx +4 -0
- package/src/widgets/label-image.tsx +2 -7
- package/src/widgets/measurer.tsx +8 -2
- package/src/widgets/plotter.tsx +2 -0
- package/src/widgets.ts +9 -4
- package/tsconfig-build.tsbuildinfo +1 -1
package/src/widgets/measurer.tsx
CHANGED
|
@@ -11,6 +11,8 @@ import {ApiOptions} from "../perseus-api";
|
|
|
11
11
|
import GraphUtils from "../util/graph-utils";
|
|
12
12
|
|
|
13
13
|
import type {WidgetExports} from "../types";
|
|
14
|
+
import type {Interval} from "../util/interval";
|
|
15
|
+
import type {Coord} from "@khanacademy/perseus";
|
|
14
16
|
|
|
15
17
|
const defaultImage = {
|
|
16
18
|
url: null,
|
|
@@ -121,10 +123,11 @@ const Measurer: any = createReactClass({
|
|
|
121
123
|
const graphieDiv = ReactDOM.findDOMNode(this.refs.graphieDiv);
|
|
122
124
|
// @ts-expect-error - TS2769 - No overload matches this call. | TS2339 - Property 'empty' does not exist on type 'JQueryStatic'.
|
|
123
125
|
$(graphieDiv).empty();
|
|
126
|
+
// @ts-expect-error - Argument of type 'Element | Text | null' is not assignable to parameter of type 'HTMLElement'.
|
|
124
127
|
const graphie = (this.graphie = GraphUtils.createGraphie(graphieDiv));
|
|
125
128
|
|
|
126
|
-
const scale = [40, 40];
|
|
127
|
-
const range = [
|
|
129
|
+
const scale: Coord = [40, 40];
|
|
130
|
+
const range: [Interval, Interval] = [
|
|
128
131
|
[0, this.props.box[0] / scale[0]],
|
|
129
132
|
[0, this.props.box[1] / scale[1]],
|
|
130
133
|
];
|
|
@@ -132,6 +135,7 @@ const Measurer: any = createReactClass({
|
|
|
132
135
|
range: range,
|
|
133
136
|
scale: scale,
|
|
134
137
|
});
|
|
138
|
+
// @ts-expect-error - Property 'addMouseLayer' does not exist on type 'Graphie'.
|
|
135
139
|
graphie.addMouseLayer({
|
|
136
140
|
allowScratchpad: true,
|
|
137
141
|
setDrawingAreaAvailable:
|
|
@@ -143,6 +147,7 @@ const Measurer: any = createReactClass({
|
|
|
143
147
|
}
|
|
144
148
|
|
|
145
149
|
if (this.props.showProtractor) {
|
|
150
|
+
// @ts-expect-error - Property 'protractor' does not exist on type 'Graphie'.
|
|
146
151
|
this.protractor = graphie.protractor([
|
|
147
152
|
this.props.protractorX,
|
|
148
153
|
this.props.protractorY,
|
|
@@ -154,6 +159,7 @@ const Measurer: any = createReactClass({
|
|
|
154
159
|
}
|
|
155
160
|
|
|
156
161
|
if (this.props.showRuler) {
|
|
162
|
+
// @ts-expect-error - Property 'ruler' does not exist on type 'Graphie'.
|
|
157
163
|
this.ruler = graphie.ruler({
|
|
158
164
|
center: [
|
|
159
165
|
(range[0][0] + range[0][1]) / 2,
|
package/src/widgets/plotter.tsx
CHANGED
|
@@ -145,6 +145,7 @@ export class Plotter extends React.Component<Props, State> {
|
|
|
145
145
|
const graphieDiv = ReactDOM.findDOMNode(self.refs.graphieDiv);
|
|
146
146
|
// @ts-expect-error - TS2769 - No overload matches this call. | TS2339 - Property 'empty' does not exist on type 'JQueryStatic'.
|
|
147
147
|
$(graphieDiv).empty();
|
|
148
|
+
// @ts-expect-error - Argument of type 'Element | Text | null' is not assignable to parameter of type 'HTMLElement'.
|
|
148
149
|
const graphie = GraphUtils.createGraphie(graphieDiv);
|
|
149
150
|
|
|
150
151
|
// TODO(jakesandlund): It's not the react way to hang
|
|
@@ -278,6 +279,7 @@ export class Plotter extends React.Component<Props, State> {
|
|
|
278
279
|
scale: c.scale,
|
|
279
280
|
isMobile: this.props.apiOptions.isMobile,
|
|
280
281
|
});
|
|
282
|
+
// @ts-expect-error - Property 'addMouseLayer' does not exist on type 'Graphie'.
|
|
281
283
|
graphie.addMouseLayer({
|
|
282
284
|
allowScratchpad: true,
|
|
283
285
|
setDrawingAreaAvailable:
|
package/src/widgets.ts
CHANGED
|
@@ -54,10 +54,12 @@ export const registerWidgets = (widgets: ReadonlyArray<WidgetExports>) => {
|
|
|
54
54
|
export const replaceWidget = (name: string, replacementName: string) => {
|
|
55
55
|
const substituteWidget = widgets[replacementName];
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
// If the replacement widget isn't found, we need to throw. Otherwise after
|
|
58
|
+
// removing the deprecated widget, we'll have data asking for a widget type
|
|
59
|
+
// that doesn't exist at all.
|
|
60
|
+
if (!substituteWidget) {
|
|
58
61
|
const errorMsg = `Failed to replace ${name} with ${replacementName}`;
|
|
59
|
-
|
|
60
|
-
return;
|
|
62
|
+
throw new PerseusError(errorMsg, Errors.Internal);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
registerWidget(name, substituteWidget);
|
|
@@ -168,7 +170,10 @@ export const upgradeWidgetInfoToLatestVersion = (
|
|
|
168
170
|
oldWidgetInfo: PerseusWidget,
|
|
169
171
|
): PerseusWidget => {
|
|
170
172
|
const type = oldWidgetInfo.type;
|
|
171
|
-
//
|
|
173
|
+
// NOTE(jeremy): This looks like it could be replaced by fixing types so
|
|
174
|
+
// that `type` is non-optional. But we're seeing this in Sentry today so I
|
|
175
|
+
// suspect we have legacy data (potentially unpublished) and we should
|
|
176
|
+
// figure that out before depending solely on types.
|
|
172
177
|
if (!_.isString(type)) {
|
|
173
178
|
throw new PerseusError(
|
|
174
179
|
"widget type must be a string, but was: " + type,
|