@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 CHANGED
@@ -31598,6 +31598,63 @@ const lockedFigureFillStyles = {
31598
31598
 
31599
31599
  const plotterPlotTypes = ["bar", "line", "pic", "histogram", "dotplot"];
31600
31600
 
31601
+ /**
31602
+ * 44 is touch best practice and AAA compliant for WCAG
31603
+ * https://www.w3.org/WAI/WCAG21/Understanding/target-size.html
31604
+ */
31605
+ const TARGET_SIZE = 44;
31606
+ const REMOVE_BUTTON_ID = "perseus_mafs_remove_button";
31607
+
31608
+ // same as pointsFromNormalized in interactive-graph.tsx
31609
+ const normalizePoints = (range, step, coordsList, noSnap) => coordsList.map(coords =>
31610
+ // maps over [x, y]
31611
+ coords.map((coord, i) => {
31612
+ const axisRange = range[i];
31613
+ if (noSnap) {
31614
+ return axisRange[MIN] + size(axisRange) * coord;
31615
+ }
31616
+ const axisStep = step[i];
31617
+ const nSteps = Math.floor(size(axisRange) / axisStep);
31618
+ const tick = Math.round(coord * nSteps);
31619
+ return axisRange[MIN] + axisStep * tick;
31620
+ }));
31621
+
31622
+ // same as normalizeCoords in interactive-graph.tsx
31623
+ const normalizeCoords = (coordsList, ranges) => coordsList.map(coords => coords.map((coord, i) => {
31624
+ return (coord + ranges[i][1]) / size(ranges[i]);
31625
+ }));
31626
+
31627
+ // Returns the closest point to the given `point` that is within the graph
31628
+ // bounds given in `state`.
31629
+ function bound$1({
31630
+ snapStep,
31631
+ range,
31632
+ point
31633
+ }) {
31634
+ const boundingBox = inset(snapStep, range);
31635
+ return clampToBox(boundingBox, point);
31636
+ }
31637
+ function isUnlimitedGraphState(state) {
31638
+ return state.type === "point" && state.numPoints === "unlimited" || state.type === "polygon" && state.numSides === "unlimited";
31639
+ }
31640
+
31641
+ /**
31642
+ * Replace all text outside of the $ TeX blocks with `\\text{...}`
31643
+ * This way, the entire resulting string can be rendered within <TeX>
31644
+ * and the text outside of the $ blocks will be non-TeX text.
31645
+ */
31646
+ function replaceOutsideTeX(mathString) {
31647
+ let currentlyTeX = mathString[0] === "$";
31648
+ let result = "";
31649
+ const splitString = mathString.split("$").filter(part => part !== "");
31650
+ for (let i = 0; i < splitString.length; i++) {
31651
+ const part = splitString[i];
31652
+ result += currentlyTeX ? part : `\\text{${part}}`;
31653
+ currentlyTeX = !currentlyTeX;
31654
+ }
31655
+ return result;
31656
+ }
31657
+
31601
31658
  function LockedLabel(props) {
31602
31659
  const {
31603
31660
  coord,
@@ -31610,7 +31667,7 @@ function LockedLabel(props) {
31610
31667
  TeX
31611
31668
  } = getDependencies();
31612
31669
 
31613
- // Move this all outside the SVG element
31670
+ // Note: The TeX component cannot be rendered within an SVG
31614
31671
  return /*#__PURE__*/React.createElement("span", {
31615
31672
  className: "locked-label",
31616
31673
  style: {
@@ -31622,7 +31679,7 @@ function LockedLabel(props) {
31622
31679
  backgroundColor: "rgba(255, 255, 255, 0.8)"
31623
31680
  },
31624
31681
  "aria-hidden": true
31625
- }, /*#__PURE__*/React.createElement(TeX, null, text));
31682
+ }, /*#__PURE__*/React.createElement(TeX, null, replaceOutsideTeX(text)));
31626
31683
  }
31627
31684
 
31628
31685
  function GraphLockedLabelsLayer(props) {
@@ -32542,46 +32599,6 @@ function calculateBisectorPoint(point1, point2, vertex, isReflex, allowReflex, a
32542
32599
  return scaledBisector;
32543
32600
  }
32544
32601
 
32545
- /**
32546
- * 44 is touch best practice and AAA compliant for WCAG
32547
- * https://www.w3.org/WAI/WCAG21/Understanding/target-size.html
32548
- */
32549
- const TARGET_SIZE = 44;
32550
- const REMOVE_BUTTON_ID = "perseus_mafs_remove_button";
32551
-
32552
- // same as pointsFromNormalized in interactive-graph.tsx
32553
- const normalizePoints = (range, step, coordsList, noSnap) => coordsList.map(coords =>
32554
- // maps over [x, y]
32555
- coords.map((coord, i) => {
32556
- const axisRange = range[i];
32557
- if (noSnap) {
32558
- return axisRange[MIN] + size(axisRange) * coord;
32559
- }
32560
- const axisStep = step[i];
32561
- const nSteps = Math.floor(size(axisRange) / axisStep);
32562
- const tick = Math.round(coord * nSteps);
32563
- return axisRange[MIN] + axisStep * tick;
32564
- }));
32565
-
32566
- // same as normalizeCoords in interactive-graph.tsx
32567
- const normalizeCoords = (coordsList, ranges) => coordsList.map(coords => coords.map((coord, i) => {
32568
- return (coord + ranges[i][1]) / size(ranges[i]);
32569
- }));
32570
-
32571
- // Returns the closest point to the given `point` that is within the graph
32572
- // bounds given in `state`.
32573
- function bound$1({
32574
- snapStep,
32575
- range,
32576
- point
32577
- }) {
32578
- const boundingBox = inset(snapStep, range);
32579
- return clampToBox(boundingBox, point);
32580
- }
32581
- function isUnlimitedGraphState(state) {
32582
- return state.type === "point" && state.numPoints === "unlimited" || state.type === "polygon" && state.numSides === "unlimited";
32583
- }
32584
-
32585
32602
  var isProduction = process.env.NODE_ENV === 'production';
32586
32603
  var prefix = 'Invariant failed';
32587
32604
  function invariant(condition, message) {
@@ -43996,41 +44013,16 @@ var extraWidgets = [Categorizer$1, CSProgram$1, Dropdown$1, Explanation$1, Defin
43996
44013
  * This should be called by all clients, specifying whether extra widgets are
43997
44014
  * needed via `loadExtraWidgets`. It is idempotent, so it's not a problem to
43998
44015
  * call it multiple times.
43999
- *
44000
- * skipMathJax:
44001
- * If false/undefined, MathJax will be configured, and the
44002
- * promise will wait for MathJax to load (if it hasn't already).
44003
44016
  */
44004
- const init = function init(options) {
44017
+ const init = function init() {
44005
44018
  registerWidgets(basicWidgets);
44006
44019
  registerWidgets(extraWidgets);
44007
44020
  replaceDeprecatedWidgets();
44008
-
44009
- // Pass skipMathJax: true if MathJax is already loaded and configured.
44010
- const skipMathJax = options.skipMathJax;
44011
- if (skipMathJax) {
44012
- // @ts-expect-error - TS2322 - Type 'Promise<void>' is not assignable to type 'Promise<undefined>'.
44013
- return Promise.resolve();
44014
- }
44015
- return new Promise((resolve, reject) => {
44016
- MathJax.Hub.Config({
44017
- messageStyle: "none",
44018
- skipStartupTypeset: "none",
44019
- "HTML-CSS": {
44020
- availableFonts: ["TeX"],
44021
- imageFont: null,
44022
- scale: 100,
44023
- showMathMenu: false
44024
- }
44025
- });
44026
- MathJax.Hub.Configured();
44027
- MathJax.Hub.Queue(resolve);
44028
- });
44029
44021
  };
44030
44022
 
44031
44023
  // This file is processed by a Rollup plugin (replace) to inject the production
44032
44024
  const libName = "@khanacademy/perseus";
44033
- const libVersion = "41.1.1";
44025
+ const libVersion = "41.2.0";
44034
44026
  addLibraryVersionToPerseusDebug(libName, libVersion);
44035
44027
 
44036
44028
  const apiVersion = {