@khanacademy/perseus 25.0.0 → 25.1.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.
- package/dist/es/index.js +36 -5
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/dist/perseus-api.d.ts +2 -0
- package/dist/perseus-types.d.ts +10 -0
- package/dist/server-item-renderer.d.ts +2 -0
- package/dist/types.d.ts +3 -0
- package/dist/widgets/expression.d.ts +12 -0
- package/dist/widgets/interactive-graphs/reducer/initialize-graph-state.d.ts +3 -2
- package/dist/widgets/label-image.d.ts +4 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export { generateTestPerseusItem, genericPerseusItemData, generateTestRadioWidge
|
|
|
71
71
|
export { getWidgetTypeByWidgetId, contentHasWidgetType, getWidgetIdsFromContent, getWidgetIdsFromContentByType, getWidgetsMapFromItemData, getWidgetFromWidgetMap, getWidgetsFromWidgetMap, } from "./widget-type-utils";
|
|
72
72
|
export { convertWidgetNameToEnum } from "./util/widget-enum-utils";
|
|
73
73
|
export { addWidget, QUESTION_WIDGETS } from "./util/snowman-utils";
|
|
74
|
+
export { getLineCoords } from "./widgets/interactive-graphs/reducer/initialize-graph-state";
|
|
74
75
|
/**
|
|
75
76
|
* Mixins
|
|
76
77
|
*/
|
package/dist/index.js
CHANGED
|
@@ -32183,6 +32183,10 @@ function getPointCoords(graph, range, step) {
|
|
|
32183
32183
|
if (coords) {
|
|
32184
32184
|
return coords;
|
|
32185
32185
|
}
|
|
32186
|
+
const startCoords = graph.startCoords?.slice();
|
|
32187
|
+
if (startCoords) {
|
|
32188
|
+
return startCoords;
|
|
32189
|
+
}
|
|
32186
32190
|
switch (numPoints) {
|
|
32187
32191
|
case 1:
|
|
32188
32192
|
// Back in the day, one point's coords were in graph.coord
|
|
@@ -32216,6 +32220,9 @@ function getSegmentCoords(graph, range, step) {
|
|
|
32216
32220
|
if (graph.coords) {
|
|
32217
32221
|
return graph.coords;
|
|
32218
32222
|
}
|
|
32223
|
+
if (graph.startCoords) {
|
|
32224
|
+
return graph.startCoords;
|
|
32225
|
+
}
|
|
32219
32226
|
const ys = n => {
|
|
32220
32227
|
switch (n) {
|
|
32221
32228
|
case 2:
|
|
@@ -32245,12 +32252,18 @@ function getLineCoords(graph, range, step) {
|
|
|
32245
32252
|
if (graph.coords) {
|
|
32246
32253
|
return graph.coords;
|
|
32247
32254
|
}
|
|
32255
|
+
if (graph.startCoords) {
|
|
32256
|
+
return graph.startCoords;
|
|
32257
|
+
}
|
|
32248
32258
|
return normalizePoints(range, step, defaultLinearCoords[0]);
|
|
32249
32259
|
}
|
|
32250
32260
|
function getLinearSystemCoords(graph, range, step) {
|
|
32251
32261
|
if (graph.coords) {
|
|
32252
32262
|
return graph.coords;
|
|
32253
32263
|
}
|
|
32264
|
+
if (graph.startCoords) {
|
|
32265
|
+
return graph.startCoords;
|
|
32266
|
+
}
|
|
32254
32267
|
return defaultLinearCoords.map(points => normalizePoints(range, step, points));
|
|
32255
32268
|
}
|
|
32256
32269
|
function getPolygonCoords(graph, range, step) {
|
|
@@ -32258,6 +32271,10 @@ function getPolygonCoords(graph, range, step) {
|
|
|
32258
32271
|
if (coords) {
|
|
32259
32272
|
return coords;
|
|
32260
32273
|
}
|
|
32274
|
+
const startCoords = graph.startCoords?.slice();
|
|
32275
|
+
if (startCoords) {
|
|
32276
|
+
return startCoords;
|
|
32277
|
+
}
|
|
32261
32278
|
const n = graph.numSides || 3;
|
|
32262
32279
|
if (n === "unlimited") {
|
|
32263
32280
|
coords = [];
|
|
@@ -32281,6 +32298,9 @@ function getSinusoidCoords(graph, range, step) {
|
|
|
32281
32298
|
if (graph.coords) {
|
|
32282
32299
|
return [graph.coords[0], graph.coords[1]];
|
|
32283
32300
|
}
|
|
32301
|
+
if (graph.startCoords) {
|
|
32302
|
+
return [graph.startCoords[0], graph.startCoords[1]];
|
|
32303
|
+
}
|
|
32284
32304
|
let coords = [[0.5, 0.5], [0.65, 0.6]];
|
|
32285
32305
|
coords = normalizePoints(range, step, coords, true);
|
|
32286
32306
|
return coords;
|
|
@@ -32289,6 +32309,9 @@ function getQuadraticCoords(graph, range, step) {
|
|
|
32289
32309
|
if (graph.coords) {
|
|
32290
32310
|
return graph.coords;
|
|
32291
32311
|
}
|
|
32312
|
+
if (graph.startCoords) {
|
|
32313
|
+
return graph.startCoords;
|
|
32314
|
+
}
|
|
32292
32315
|
const defaultCoords = [[0.25, 0.75], [0.5, 0.25], [0.75, 0.75]];
|
|
32293
32316
|
return normalizePoints(range, step, defaultCoords, true);
|
|
32294
32317
|
}
|
|
@@ -32299,6 +32322,12 @@ function getCircleCoords(graph) {
|
|
|
32299
32322
|
radiusPoint: mafs.vec.add(graph.center, [graph.radius, 0])
|
|
32300
32323
|
};
|
|
32301
32324
|
}
|
|
32325
|
+
if (graph.startCoords) {
|
|
32326
|
+
return {
|
|
32327
|
+
center: graph.startCoords,
|
|
32328
|
+
radiusPoint: mafs.vec.add(graph.startCoords, [2, 0])
|
|
32329
|
+
};
|
|
32330
|
+
}
|
|
32302
32331
|
return {
|
|
32303
32332
|
center: [0, 0],
|
|
32304
32333
|
radiusPoint: [2, 0]
|
|
@@ -33092,6 +33121,7 @@ const StatefulMafsGraph = /*#__PURE__*/React__namespace.forwardRef((props, ref)
|
|
|
33092
33121
|
const snapTo = graph.type === "polygon" ? graph.snapTo : null;
|
|
33093
33122
|
const showAngles = graph.type === "polygon" ? graph.showAngles : null;
|
|
33094
33123
|
const showSides = graph.type === "polygon" ? graph.showSides : null;
|
|
33124
|
+
const startCoords = graph.startCoords ?? null;
|
|
33095
33125
|
const originalPropsRef = React.useRef(props);
|
|
33096
33126
|
const latestPropsRef = wonderBlocksCore.useLatestRef(props);
|
|
33097
33127
|
React.useEffect(() => {
|
|
@@ -33102,7 +33132,7 @@ const StatefulMafsGraph = /*#__PURE__*/React__namespace.forwardRef((props, ref)
|
|
|
33102
33132
|
if (latestPropsRef.current !== originalPropsRef.current) {
|
|
33103
33133
|
dispatch(reinitialize(latestPropsRef.current));
|
|
33104
33134
|
}
|
|
33105
|
-
}, [graph.type, numSegments, numSides, snapTo, showAngles, showSides, latestPropsRef]);
|
|
33135
|
+
}, [graph.type, numSegments, numSides, snapTo, showAngles, showSides, startCoords, latestPropsRef, startCoords]);
|
|
33106
33136
|
return /*#__PURE__*/React__namespace.createElement(MafsGraph, _extends({}, props, {
|
|
33107
33137
|
state: state,
|
|
33108
33138
|
dispatch: dispatch
|
|
@@ -45227,7 +45257,7 @@ const init = function (options) {
|
|
|
45227
45257
|
|
|
45228
45258
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
45229
45259
|
const libName = "@khanacademy/perseus";
|
|
45230
|
-
const libVersion = "25.
|
|
45260
|
+
const libVersion = "25.1.0";
|
|
45231
45261
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
45232
45262
|
|
|
45233
45263
|
const apiVersion = {
|
|
@@ -48305,6 +48335,7 @@ exports.genericPerseusItemData = genericPerseusItemData;
|
|
|
48305
48335
|
exports.getAnswerFromUserInput = getAnswerFromUserInput;
|
|
48306
48336
|
exports.getAnswersFromWidgets = getAnswersFromWidgets;
|
|
48307
48337
|
exports.getCorrectAnswerForWidgetId = getCorrectAnswerForWidgetId;
|
|
48338
|
+
exports.getLineCoords = getLineCoords;
|
|
48308
48339
|
exports.getValidWidgetIds = getValidWidgetIds;
|
|
48309
48340
|
exports.getWidgetFromWidgetMap = getWidgetFromWidgetMap;
|
|
48310
48341
|
exports.getWidgetIdsFromContent = getWidgetIdsFromContent;
|