@khanacademy/perseus 41.1.1 → 41.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.
- package/dist/es/index.js +61 -69
- package/dist/es/index.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +62 -70
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts +1 -8
- package/dist/widgets/interactive-graphs/utils.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -84,7 +84,6 @@ export { default as WIDGET_PROP_DENYLIST } from "./mixins/widget-prop-denylist";
|
|
|
84
84
|
/**
|
|
85
85
|
* Types
|
|
86
86
|
*/
|
|
87
|
-
export type { PerseusOptions } from "./init";
|
|
88
87
|
export type { ILogger, LogErrorOptions } from "./logging/log";
|
|
89
88
|
export type { ServerItemRenderer as ServerItemRendererComponent } from "./server-item-renderer";
|
|
90
89
|
export type { Alignment, APIOptions, APIOptionsWithDefaults, ChangeHandler, DeviceType, DomInsertCheckFn, EditorMode, FocusPath, ImageDict, ImageUploader, JiptLabelStore, JiptRenderer, PerseusDependencies, PerseusDependenciesV2, PerseusScore, Version, VideoData, VideoKind, WidgetExports, SharedRendererProps, } from "./types";
|
package/dist/index.js
CHANGED
|
@@ -31906,6 +31906,64 @@ const lockedFigureFillStyles = {
|
|
|
31906
31906
|
|
|
31907
31907
|
const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
|
|
31908
31908
|
|
|
31909
|
+
/**
|
|
31910
|
+
* 44 is touch best practice and AAA compliant for WCAG
|
|
31911
|
+
* https://www.w3.org/WAI/WCAG21/Understanding/target-size.html
|
|
31912
|
+
*/
|
|
31913
|
+
const TARGET_SIZE = 44;
|
|
31914
|
+
const REMOVE_BUTTON_ID = "perseus_mafs_remove_button";
|
|
31915
|
+
|
|
31916
|
+
// same as pointsFromNormalized in interactive-graph.tsx
|
|
31917
|
+
const normalizePoints = (range, step, coordsList, noSnap) => coordsList.map(coords =>
|
|
31918
|
+
// maps over [x, y]
|
|
31919
|
+
coords.map((coord, i) => {
|
|
31920
|
+
const axisRange = range[i];
|
|
31921
|
+
if (noSnap) {
|
|
31922
|
+
return axisRange[MIN] + size(axisRange) * coord;
|
|
31923
|
+
}
|
|
31924
|
+
const axisStep = step[i];
|
|
31925
|
+
const nSteps = Math.floor(size(axisRange) / axisStep);
|
|
31926
|
+
const tick = Math.round(coord * nSteps);
|
|
31927
|
+
return axisRange[MIN] + axisStep * tick;
|
|
31928
|
+
}));
|
|
31929
|
+
|
|
31930
|
+
// same as normalizeCoords in interactive-graph.tsx
|
|
31931
|
+
const normalizeCoords = (coordsList, ranges) => coordsList.map(coords => coords.map((coord, i) => {
|
|
31932
|
+
return (coord + ranges[i][1]) / size(ranges[i]);
|
|
31933
|
+
}));
|
|
31934
|
+
|
|
31935
|
+
// Returns the closest point to the given `point` that is within the graph
|
|
31936
|
+
// bounds given in `state`.
|
|
31937
|
+
function bound$1(_ref) {
|
|
31938
|
+
let {
|
|
31939
|
+
snapStep,
|
|
31940
|
+
range,
|
|
31941
|
+
point
|
|
31942
|
+
} = _ref;
|
|
31943
|
+
const boundingBox = inset(snapStep, range);
|
|
31944
|
+
return clampToBox(boundingBox, point);
|
|
31945
|
+
}
|
|
31946
|
+
function isUnlimitedGraphState(state) {
|
|
31947
|
+
return state.type === "point" && state.numPoints === "unlimited" || state.type === "polygon" && state.numSides === "unlimited";
|
|
31948
|
+
}
|
|
31949
|
+
|
|
31950
|
+
/**
|
|
31951
|
+
* Replace all text outside of the $ TeX blocks with `\\text{...}`
|
|
31952
|
+
* This way, the entire resulting string can be rendered within <TeX>
|
|
31953
|
+
* and the text outside of the $ blocks will be non-TeX text.
|
|
31954
|
+
*/
|
|
31955
|
+
function replaceOutsideTeX(mathString) {
|
|
31956
|
+
let currentlyTeX = mathString[0] === "$";
|
|
31957
|
+
let result = "";
|
|
31958
|
+
const splitString = mathString.split("$").filter(part => part !== "");
|
|
31959
|
+
for (let i = 0; i < splitString.length; i++) {
|
|
31960
|
+
const part = splitString[i];
|
|
31961
|
+
result += currentlyTeX ? part : `\\text{${part}}`;
|
|
31962
|
+
currentlyTeX = !currentlyTeX;
|
|
31963
|
+
}
|
|
31964
|
+
return result;
|
|
31965
|
+
}
|
|
31966
|
+
|
|
31909
31967
|
function LockedLabel(props) {
|
|
31910
31968
|
const {
|
|
31911
31969
|
coord,
|
|
@@ -31918,7 +31976,7 @@ function LockedLabel(props) {
|
|
|
31918
31976
|
TeX
|
|
31919
31977
|
} = getDependencies();
|
|
31920
31978
|
|
|
31921
|
-
//
|
|
31979
|
+
// Note: The TeX component cannot be rendered within an SVG
|
|
31922
31980
|
return /*#__PURE__*/React__namespace.createElement("span", {
|
|
31923
31981
|
className: "locked-label",
|
|
31924
31982
|
style: {
|
|
@@ -31930,7 +31988,7 @@ function LockedLabel(props) {
|
|
|
31930
31988
|
backgroundColor: "rgba(255, 255, 255, 0.8)"
|
|
31931
31989
|
},
|
|
31932
31990
|
"aria-hidden": true
|
|
31933
|
-
}, /*#__PURE__*/React__namespace.createElement(TeX, null, text));
|
|
31991
|
+
}, /*#__PURE__*/React__namespace.createElement(TeX, null, replaceOutsideTeX(text)));
|
|
31934
31992
|
}
|
|
31935
31993
|
|
|
31936
31994
|
function GraphLockedLabelsLayer(props) {
|
|
@@ -32850,47 +32908,6 @@ function calculateBisectorPoint(point1, point2, vertex, isReflex, allowReflex, a
|
|
|
32850
32908
|
return scaledBisector;
|
|
32851
32909
|
}
|
|
32852
32910
|
|
|
32853
|
-
/**
|
|
32854
|
-
* 44 is touch best practice and AAA compliant for WCAG
|
|
32855
|
-
* https://www.w3.org/WAI/WCAG21/Understanding/target-size.html
|
|
32856
|
-
*/
|
|
32857
|
-
const TARGET_SIZE = 44;
|
|
32858
|
-
const REMOVE_BUTTON_ID = "perseus_mafs_remove_button";
|
|
32859
|
-
|
|
32860
|
-
// same as pointsFromNormalized in interactive-graph.tsx
|
|
32861
|
-
const normalizePoints = (range, step, coordsList, noSnap) => coordsList.map(coords =>
|
|
32862
|
-
// maps over [x, y]
|
|
32863
|
-
coords.map((coord, i) => {
|
|
32864
|
-
const axisRange = range[i];
|
|
32865
|
-
if (noSnap) {
|
|
32866
|
-
return axisRange[MIN] + size(axisRange) * coord;
|
|
32867
|
-
}
|
|
32868
|
-
const axisStep = step[i];
|
|
32869
|
-
const nSteps = Math.floor(size(axisRange) / axisStep);
|
|
32870
|
-
const tick = Math.round(coord * nSteps);
|
|
32871
|
-
return axisRange[MIN] + axisStep * tick;
|
|
32872
|
-
}));
|
|
32873
|
-
|
|
32874
|
-
// same as normalizeCoords in interactive-graph.tsx
|
|
32875
|
-
const normalizeCoords = (coordsList, ranges) => coordsList.map(coords => coords.map((coord, i) => {
|
|
32876
|
-
return (coord + ranges[i][1]) / size(ranges[i]);
|
|
32877
|
-
}));
|
|
32878
|
-
|
|
32879
|
-
// Returns the closest point to the given `point` that is within the graph
|
|
32880
|
-
// bounds given in `state`.
|
|
32881
|
-
function bound$1(_ref) {
|
|
32882
|
-
let {
|
|
32883
|
-
snapStep,
|
|
32884
|
-
range,
|
|
32885
|
-
point
|
|
32886
|
-
} = _ref;
|
|
32887
|
-
const boundingBox = inset(snapStep, range);
|
|
32888
|
-
return clampToBox(boundingBox, point);
|
|
32889
|
-
}
|
|
32890
|
-
function isUnlimitedGraphState(state) {
|
|
32891
|
-
return state.type === "point" && state.numPoints === "unlimited" || state.type === "polygon" && state.numSides === "unlimited";
|
|
32892
|
-
}
|
|
32893
|
-
|
|
32894
32911
|
var isProduction = process.env.NODE_ENV === 'production';
|
|
32895
32912
|
var prefix = 'Invariant failed';
|
|
32896
32913
|
function invariant(condition, message) {
|
|
@@ -44364,41 +44381,16 @@ var extraWidgets = [Categorizer$1, CSProgram$1, Dropdown$1, Explanation$1, Defin
|
|
|
44364
44381
|
* This should be called by all clients, specifying whether extra widgets are
|
|
44365
44382
|
* needed via `loadExtraWidgets`. It is idempotent, so it's not a problem to
|
|
44366
44383
|
* call it multiple times.
|
|
44367
|
-
*
|
|
44368
|
-
* skipMathJax:
|
|
44369
|
-
* If false/undefined, MathJax will be configured, and the
|
|
44370
|
-
* promise will wait for MathJax to load (if it hasn't already).
|
|
44371
44384
|
*/
|
|
44372
|
-
const init = function (
|
|
44385
|
+
const init = function () {
|
|
44373
44386
|
registerWidgets(basicWidgets);
|
|
44374
44387
|
registerWidgets(extraWidgets);
|
|
44375
44388
|
replaceDeprecatedWidgets();
|
|
44376
|
-
|
|
44377
|
-
// Pass skipMathJax: true if MathJax is already loaded and configured.
|
|
44378
|
-
const skipMathJax = options.skipMathJax;
|
|
44379
|
-
if (skipMathJax) {
|
|
44380
|
-
// @ts-expect-error - TS2322 - Type 'Promise<void>' is not assignable to type 'Promise<undefined>'.
|
|
44381
|
-
return Promise.resolve();
|
|
44382
|
-
}
|
|
44383
|
-
return new Promise((resolve, reject) => {
|
|
44384
|
-
MathJax.Hub.Config({
|
|
44385
|
-
messageStyle: "none",
|
|
44386
|
-
skipStartupTypeset: "none",
|
|
44387
|
-
"HTML-CSS": {
|
|
44388
|
-
availableFonts: ["TeX"],
|
|
44389
|
-
imageFont: null,
|
|
44390
|
-
scale: 100,
|
|
44391
|
-
showMathMenu: false
|
|
44392
|
-
}
|
|
44393
|
-
});
|
|
44394
|
-
MathJax.Hub.Configured();
|
|
44395
|
-
MathJax.Hub.Queue(resolve);
|
|
44396
|
-
});
|
|
44397
44389
|
};
|
|
44398
44390
|
|
|
44399
44391
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
44400
44392
|
const libName = "@khanacademy/perseus";
|
|
44401
|
-
const libVersion = "41.
|
|
44393
|
+
const libVersion = "41.2.0";
|
|
44402
44394
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
44403
44395
|
|
|
44404
44396
|
const apiVersion = {
|