@khanacademy/perseus 19.3.0 → 19.4.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/components/graph.d.ts +3 -2
- package/dist/es/index.js +70 -3
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +75 -2
- package/dist/index.js.map +1 -1
- package/dist/perseus-types.d.ts +13 -2
- package/dist/util/test-utils.d.ts +12 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export { registerAllWidgetsForTesting } from "./util/register-all-widgets-for-te
|
|
|
67
67
|
export * as SizingUtils from "./util/sizing-utils";
|
|
68
68
|
export { getAnswersFromWidgets, injectWidgets, } from "./util/extract-perseus-data";
|
|
69
69
|
export { parsePerseusItem } from "./util/parse-perseus-json";
|
|
70
|
+
export { generateTestPerseusItem, genericPerseusItemData, } from "./util/test-utils";
|
|
70
71
|
/**
|
|
71
72
|
* Mixins
|
|
72
73
|
*/
|
package/dist/index.js
CHANGED
|
@@ -28227,6 +28227,33 @@ class Graph extends React__namespace.Component {
|
|
|
28227
28227
|
allowScratchpad: true,
|
|
28228
28228
|
setDrawingAreaAvailable: this.props.setDrawingAreaAvailable
|
|
28229
28229
|
});
|
|
28230
|
+
|
|
28231
|
+
// Maybe move this out later
|
|
28232
|
+
if (this.props.lockedFigures) {
|
|
28233
|
+
for (const lockedFigure of this.props.lockedFigures) {
|
|
28234
|
+
switch (lockedFigure.type) {
|
|
28235
|
+
case "point":
|
|
28236
|
+
graphie.circle(
|
|
28237
|
+
// center
|
|
28238
|
+
lockedFigure.coord,
|
|
28239
|
+
// radius
|
|
28240
|
+
0.2,
|
|
28241
|
+
// style
|
|
28242
|
+
lockedFigure.style);
|
|
28243
|
+
break;
|
|
28244
|
+
default:
|
|
28245
|
+
/**
|
|
28246
|
+
* Devlopment-time future-proofing: This `never` should
|
|
28247
|
+
* fail during type-checking if we add a new locked
|
|
28248
|
+
* shape type and forget to handle it in any other
|
|
28249
|
+
* switch case here.
|
|
28250
|
+
*/
|
|
28251
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28252
|
+
lockedFigure.type;
|
|
28253
|
+
throw new Error(`Unknown locked shape type: ${lockedFigure.type}`);
|
|
28254
|
+
}
|
|
28255
|
+
}
|
|
28256
|
+
}
|
|
28230
28257
|
this._updateProtractor();
|
|
28231
28258
|
this._updateRuler();
|
|
28232
28259
|
|
|
@@ -29556,7 +29583,8 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
29556
29583
|
onMouseDown: onMouseDown,
|
|
29557
29584
|
onGraphieUpdated: this.setGraphie,
|
|
29558
29585
|
setDrawingAreaAvailable: this.props.apiOptions.setDrawingAreaAvailable,
|
|
29559
|
-
isMobile: isMobile
|
|
29586
|
+
isMobile: isMobile,
|
|
29587
|
+
lockedFigures: this.props.lockedFigures
|
|
29560
29588
|
}));
|
|
29561
29589
|
}
|
|
29562
29590
|
static getQuadraticCoefficients(coords) {
|
|
@@ -41690,7 +41718,7 @@ const init = function (options) {
|
|
|
41690
41718
|
|
|
41691
41719
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
41692
41720
|
const libName = "@khanacademy/perseus";
|
|
41693
|
-
const libVersion = "19.
|
|
41721
|
+
const libVersion = "19.4.0";
|
|
41694
41722
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
41695
41723
|
|
|
41696
41724
|
const apiVersion = {
|
|
@@ -44678,6 +44706,49 @@ function parsePerseusItem(json) {
|
|
|
44678
44706
|
return JSON.parse(json);
|
|
44679
44707
|
}
|
|
44680
44708
|
|
|
44709
|
+
const genericPerseusItemData = {
|
|
44710
|
+
question: {
|
|
44711
|
+
content: "",
|
|
44712
|
+
images: {},
|
|
44713
|
+
widgets: {}
|
|
44714
|
+
},
|
|
44715
|
+
answerArea: {
|
|
44716
|
+
calculator: false,
|
|
44717
|
+
chi2Table: false,
|
|
44718
|
+
periodicTable: false,
|
|
44719
|
+
tTable: false,
|
|
44720
|
+
zTable: false,
|
|
44721
|
+
financialCalculatorMonthlyPayment: false,
|
|
44722
|
+
financialCalculatorTotalAmount: false,
|
|
44723
|
+
financialCalculatorTimeToPayOff: false,
|
|
44724
|
+
periodicTableWithKey: false
|
|
44725
|
+
},
|
|
44726
|
+
itemDataVersion: {
|
|
44727
|
+
major: 0,
|
|
44728
|
+
minor: 1
|
|
44729
|
+
},
|
|
44730
|
+
hints: [],
|
|
44731
|
+
_multi: null,
|
|
44732
|
+
answer: null
|
|
44733
|
+
};
|
|
44734
|
+
|
|
44735
|
+
/**
|
|
44736
|
+
* Generate a Perseus item object for testing purposes.
|
|
44737
|
+
*
|
|
44738
|
+
* In order to better type Perseus objects used in testing, this function
|
|
44739
|
+
* uses a basic Perseus object and updates it with custom values as needed.
|
|
44740
|
+
*
|
|
44741
|
+
* @param {Partial<PerseusItem>} customFields
|
|
44742
|
+
* @returns PerseusItem
|
|
44743
|
+
*/
|
|
44744
|
+
function generateTestPerseusItem() {
|
|
44745
|
+
let customFields = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
44746
|
+
return {
|
|
44747
|
+
...genericPerseusItemData,
|
|
44748
|
+
...customFields
|
|
44749
|
+
};
|
|
44750
|
+
}
|
|
44751
|
+
|
|
44681
44752
|
const EditorJsonify = {
|
|
44682
44753
|
serialize: function () {
|
|
44683
44754
|
// Omit props that get passed to all widgets
|
|
@@ -44734,6 +44805,8 @@ exports.buildMapper = buildMapper;
|
|
|
44734
44805
|
exports.components = components;
|
|
44735
44806
|
exports.constants = constants;
|
|
44736
44807
|
exports.displaySigFigs = displaySigFigs;
|
|
44808
|
+
exports.generateTestPerseusItem = generateTestPerseusItem;
|
|
44809
|
+
exports.genericPerseusItemData = genericPerseusItemData;
|
|
44737
44810
|
exports.getAnswersFromWidgets = getAnswersFromWidgets;
|
|
44738
44811
|
exports.globalConstants = globalConstants;
|
|
44739
44812
|
exports.globalStyles = globalStyles;
|