@khanacademy/perseus 19.1.6 → 19.1.8
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 +0 -1
- package/dist/components/graphie.d.ts +0 -1
- package/dist/es/index.js +545 -591
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +564 -601
- package/dist/index.js.map +1 -1
- package/dist/interactive2/movable-point.d.ts +195 -1
- package/dist/interactive2/movable.d.ts +1 -1
- package/dist/interactive2/types.d.ts +4 -2
- package/dist/interactive2.d.ts +2 -1
- package/dist/server-item-renderer.d.ts +2 -2
- package/dist/util/graphie.d.ts +12 -2
- package/dist/widgets/expression.d.ts +6 -6
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -284,7 +284,11 @@ class MathInput extends React__namespace.Component {
|
|
|
284
284
|
display: "flex",
|
|
285
285
|
padding: 1
|
|
286
286
|
},
|
|
287
|
-
onClick:
|
|
287
|
+
onClick: e => {
|
|
288
|
+
// Prevent the click into the input from registering
|
|
289
|
+
// so that the keypad popover doesn't close when
|
|
290
|
+
// switching focus to the input.
|
|
291
|
+
e.stopPropagation();
|
|
288
292
|
const mathField = this.mathField();
|
|
289
293
|
if (!mathField) {
|
|
290
294
|
return;
|
|
@@ -3999,10 +4003,10 @@ class FixedToResponsive extends React__namespace.Component {
|
|
|
3999
4003
|
|
|
4000
4004
|
/* Local helper methods. */
|
|
4001
4005
|
|
|
4002
|
-
function getKey$
|
|
4006
|
+
function getKey$2(eventName, id) {
|
|
4003
4007
|
return eventName + ":" + id;
|
|
4004
4008
|
}
|
|
4005
|
-
function getEventName$
|
|
4009
|
+
function getEventName$2(key) {
|
|
4006
4010
|
return key.split(":")[0];
|
|
4007
4011
|
}
|
|
4008
4012
|
const MovableHelperMethods = {
|
|
@@ -4083,7 +4087,7 @@ const MovableHelperMethods = {
|
|
|
4083
4087
|
|
|
4084
4088
|
// If there's an existing handler, replace it by using its index in
|
|
4085
4089
|
// `this.state[eventName]`; otherwise, add this handler to the end
|
|
4086
|
-
const key = getKey$
|
|
4090
|
+
const key = getKey$2(eventName, id);
|
|
4087
4091
|
const index = this._listenerMap[key] = this._listenerMap[key] || this.state[eventName].length;
|
|
4088
4092
|
this.state[eventName][index] = func;
|
|
4089
4093
|
},
|
|
@@ -4095,7 +4099,7 @@ const MovableHelperMethods = {
|
|
|
4095
4099
|
*/
|
|
4096
4100
|
unlisten: function (eventName, id) {
|
|
4097
4101
|
this._listenerMap = this._listenerMap || {};
|
|
4098
|
-
const key = getKey$
|
|
4102
|
+
const key = getKey$2(eventName, id);
|
|
4099
4103
|
const index = this._listenerMap[key];
|
|
4100
4104
|
if (index !== undefined) {
|
|
4101
4105
|
// Remove handler from list of event handlers and listenerMap
|
|
@@ -4105,7 +4109,7 @@ const MovableHelperMethods = {
|
|
|
4105
4109
|
// Re-index existing events: if they occur after `index`, decrement
|
|
4106
4110
|
const keys = ___default["default"].keys(this._listenerMap);
|
|
4107
4111
|
___default["default"].each(keys, function (key) {
|
|
4108
|
-
if (getEventName$
|
|
4112
|
+
if (getEventName$2(key) === eventName &&
|
|
4109
4113
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
4110
4114
|
this._listenerMap[key] > index) {
|
|
4111
4115
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
@@ -4233,22 +4237,13 @@ const InteractiveUtil = {
|
|
|
4233
4237
|
}
|
|
4234
4238
|
};
|
|
4235
4239
|
|
|
4236
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4237
|
-
|
|
4238
|
-
function getDefaultExportFromCjs (x) {
|
|
4239
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
4240
|
-
}
|
|
4241
|
-
|
|
4242
|
-
var raphael = {exports: {}};
|
|
4243
|
-
|
|
4244
4240
|
/*!
|
|
4245
4241
|
* Raphael 1.5.2 - JavaScript Vector Library
|
|
4246
4242
|
*
|
|
4247
4243
|
* Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
|
|
4248
4244
|
* Licensed under the MIT (http://raphaeljs.com/license.html) license.
|
|
4249
4245
|
*/
|
|
4250
|
-
|
|
4251
|
-
(function () {
|
|
4246
|
+
var Raphael$1 = (function () {
|
|
4252
4247
|
var setAttr;
|
|
4253
4248
|
if ("".trim) {
|
|
4254
4249
|
setAttr = function (node, att, value) {
|
|
@@ -8425,7 +8420,7 @@ var raphael = {exports: {}};
|
|
|
8425
8420
|
};
|
|
8426
8421
|
R.el = elproto;
|
|
8427
8422
|
R.st = Set[proto];
|
|
8428
|
-
|
|
8423
|
+
return R;
|
|
8429
8424
|
})();
|
|
8430
8425
|
|
|
8431
8426
|
/**
|
|
@@ -8713,7 +8708,7 @@ class Graphie$1 {
|
|
|
8713
8708
|
constructor(el) {
|
|
8714
8709
|
this.el = el;
|
|
8715
8710
|
$__default["default"](el).css("position", "relative");
|
|
8716
|
-
this.raphael =
|
|
8711
|
+
this.raphael = Raphael$1(el);
|
|
8717
8712
|
|
|
8718
8713
|
// For a sometimes-reproducible IE8 bug; doesn't affect SVG browsers at all
|
|
8719
8714
|
$__default["default"](el).children("div").css("position", "absolute");
|
|
@@ -9072,7 +9067,7 @@ class Graphie$1 {
|
|
|
9072
9067
|
// wrapper.setAttribute("data-graphie-type", "ellipse");
|
|
9073
9068
|
|
|
9074
9069
|
// Create Raphael canvas
|
|
9075
|
-
const localRaphael =
|
|
9070
|
+
const localRaphael = Raphael$1(wrapper, width, height);
|
|
9076
9071
|
const visibleShape = localRaphael.ellipse(width / 2, height / 2, scaledRadii[0], scaledRadii[1]);
|
|
9077
9072
|
return {
|
|
9078
9073
|
wrapper: wrapper,
|
|
@@ -9139,7 +9134,7 @@ class Graphie$1 {
|
|
|
9139
9134
|
});
|
|
9140
9135
|
|
|
9141
9136
|
// Create Raphael canvas
|
|
9142
|
-
const localRaphael =
|
|
9137
|
+
const localRaphael = Raphael$1(wrapper, width, height);
|
|
9143
9138
|
|
|
9144
9139
|
// Calculate path
|
|
9145
9140
|
const visibleShape = localRaphael.path(createPath(points));
|
|
@@ -9202,7 +9197,7 @@ class Graphie$1 {
|
|
|
9202
9197
|
});
|
|
9203
9198
|
|
|
9204
9199
|
// Create Raphael canvas
|
|
9205
|
-
const localRaphael =
|
|
9200
|
+
const localRaphael = Raphael$1(wrapper, width, height);
|
|
9206
9201
|
|
|
9207
9202
|
// Calculate path
|
|
9208
9203
|
const path = "M" + start[0] + " " + start[1] + " " + "L" + end[0] + " " + end[1];
|
|
@@ -9426,7 +9421,7 @@ class Graphie$1 {
|
|
|
9426
9421
|
postprocessDrawingResult(result) {
|
|
9427
9422
|
// Bad heuristic for recognizing Raphael elements and sets
|
|
9428
9423
|
const type = result.constructor.prototype;
|
|
9429
|
-
if (type ===
|
|
9424
|
+
if (type === Raphael$1.el || type === Raphael$1.st) {
|
|
9430
9425
|
result.attr(this.currentStyle);
|
|
9431
9426
|
if (this.currentStyle.arrows) {
|
|
9432
9427
|
result = this.addArrowheads(result);
|
|
@@ -9444,7 +9439,7 @@ class Graphie$1 {
|
|
|
9444
9439
|
}
|
|
9445
9440
|
addArrowheads(path) {
|
|
9446
9441
|
const type = path.constructor.prototype;
|
|
9447
|
-
if (type ===
|
|
9442
|
+
if (type === Raphael$1.el) {
|
|
9448
9443
|
if (path.type === "path" && typeof path.arrowheadsDrawn === "undefined") {
|
|
9449
9444
|
const w = path.attr("stroke-width");
|
|
9450
9445
|
const s = 0.6 + 0.4 * w;
|
|
@@ -9472,7 +9467,7 @@ class Graphie$1 {
|
|
|
9472
9467
|
set.push(head);
|
|
9473
9468
|
return set;
|
|
9474
9469
|
}
|
|
9475
|
-
} else if (type ===
|
|
9470
|
+
} else if (type === Raphael$1.st) {
|
|
9476
9471
|
for (let i = 0, l = path.items.length; i < l; i++) {
|
|
9477
9472
|
this.addArrowheads(path.items[i]);
|
|
9478
9473
|
}
|
|
@@ -9546,6 +9541,9 @@ class Graphie$1 {
|
|
|
9546
9541
|
getMouseCoord(event) {
|
|
9547
9542
|
throw new Error("getMouseCoord is a stub, and is not implemented");
|
|
9548
9543
|
}
|
|
9544
|
+
|
|
9545
|
+
// This is a stub that's overridden in interactive.ts
|
|
9546
|
+
addMouseLayer(options) {}
|
|
9549
9547
|
}
|
|
9550
9548
|
const labelDirections = {
|
|
9551
9549
|
center: [-0.5, -0.5],
|
|
@@ -10657,7 +10655,7 @@ ___default["default"].extend(GraphUtils.Graphie.prototype, {
|
|
|
10657
10655
|
setDrawingAreaAvailable: function () {}
|
|
10658
10656
|
}, options);
|
|
10659
10657
|
const mouselayerZIndex = 2;
|
|
10660
|
-
graph.mouselayer =
|
|
10658
|
+
graph.mouselayer = Raphael$1(graph.raphael.canvas.parentNode, graph.xpixels, graph.ypixels);
|
|
10661
10659
|
$__default["default"](graph.mouselayer.canvas).css("z-index", mouselayerZIndex);
|
|
10662
10660
|
if (options.onClick || options.onMouseDown || options.onMouseMove || options.onMouseOver || options.onMouseOut) {
|
|
10663
10661
|
const canvasClickTarget = graph.mouselayer.rect(0, 0, graph.xpixels, graph.ypixels).attr({
|
|
@@ -14019,7 +14017,7 @@ class Movable {
|
|
|
14019
14017
|
|
|
14020
14018
|
// If there's an existing handler, replace it by using its index in
|
|
14021
14019
|
// `this.state[eventName]`; otherwise, add this handler to the end
|
|
14022
|
-
const key = getKey(eventName, id);
|
|
14020
|
+
const key = getKey$1(eventName, id);
|
|
14023
14021
|
const index = this._listenerMap[key] = this._listenerMap[key] || this.state[eventName].length;
|
|
14024
14022
|
this.state[eventName][index] = func;
|
|
14025
14023
|
}
|
|
@@ -14032,7 +14030,7 @@ class Movable {
|
|
|
14032
14030
|
*/
|
|
14033
14031
|
unlisten(eventName, id) {
|
|
14034
14032
|
this._listenerMap = this._listenerMap || {};
|
|
14035
|
-
const key = getKey(eventName, id);
|
|
14033
|
+
const key = getKey$1(eventName, id);
|
|
14036
14034
|
const index = this._listenerMap[key];
|
|
14037
14035
|
if (index !== undefined) {
|
|
14038
14036
|
// Remove handler from list of event handlers and listenerMap
|
|
@@ -14042,7 +14040,7 @@ class Movable {
|
|
|
14042
14040
|
// Re-index existing events: if they occur after `index`, decrement
|
|
14043
14041
|
const keys = ___default["default"].keys(this._listenerMap);
|
|
14044
14042
|
keys.forEach(key => {
|
|
14045
|
-
if (getEventName(key) === eventName && this._listenerMap[key] > index) {
|
|
14043
|
+
if (getEventName$1(key) === eventName && this._listenerMap[key] > index) {
|
|
14046
14044
|
this._listenerMap[key]--;
|
|
14047
14045
|
}
|
|
14048
14046
|
});
|
|
@@ -14076,10 +14074,10 @@ class Movable {
|
|
|
14076
14074
|
return this.state.mouseTarget;
|
|
14077
14075
|
}
|
|
14078
14076
|
}
|
|
14079
|
-
function getKey(eventName, id) {
|
|
14077
|
+
function getKey$1(eventName, id) {
|
|
14080
14078
|
return eventName + ":" + id;
|
|
14081
14079
|
}
|
|
14082
|
-
function getEventName(key) {
|
|
14080
|
+
function getEventName$1(key) {
|
|
14083
14081
|
return key.split(":")[0];
|
|
14084
14082
|
}
|
|
14085
14083
|
|
|
@@ -15032,103 +15030,53 @@ const DEFAULT_STATE$1 = {
|
|
|
15032
15030
|
mouseTarget: null,
|
|
15033
15031
|
touchOffset: null
|
|
15034
15032
|
};
|
|
15033
|
+
// TODO(benchristel): this is a memory leak. We add items to
|
|
15034
|
+
// tooltipResetFunctions, but never remove them.
|
|
15035
15035
|
const tooltipResetFunctions = [];
|
|
15036
|
-
|
|
15037
|
-
// @ts-expect-error -
|
|
15038
|
-
___default["default"].extend(this, {
|
|
15039
|
-
graphie,
|
|
15040
|
-
movable,
|
|
15041
|
-
state: {
|
|
15042
|
-
// Set here because this must be unique for each instance
|
|
15043
|
-
id: ___default["default"].uniqueId("movablePoint")
|
|
15044
|
-
}
|
|
15045
|
-
});
|
|
15036
|
+
class MovablePoint$5 {
|
|
15037
|
+
// @ts-expect-error - TS2564: Property 'prevState' has no initializer and is not definitely assigned in the constructor.
|
|
15046
15038
|
|
|
15047
|
-
|
|
15048
|
-
|
|
15049
|
-
|
|
15050
|
-
|
|
15051
|
-
|
|
15052
|
-
|
|
15053
|
-
|
|
15054
|
-
|
|
15055
|
-
|
|
15056
|
-
|
|
15057
|
-
|
|
15058
|
-
|
|
15059
|
-
|
|
15060
|
-
|
|
15061
|
-
}, normalizeOptions$1(
|
|
15062
|
-
// Defaults are copied from MovablePointOptions.*.standard
|
|
15063
|
-
// These defaults are set here instead of DEFAULT_PROPS/STATE
|
|
15064
|
-
// because they:
|
|
15065
|
-
// - are objects, not primitives (and need a deeper copy)
|
|
15066
|
-
// - they don't need getters created for them
|
|
15067
|
-
// TODO(jack): Consider "default" once we es3ify perseus
|
|
15068
|
-
objective_.pluck(MovablePointOptions, "standard")
|
|
15069
|
-
|
|
15070
|
-
// We only update props here, because we want things on state to
|
|
15071
|
-
// be persistent, and updated appropriately in modify()
|
|
15072
|
-
), DEFAULT_PROPS$1);
|
|
15073
|
-
},
|
|
15074
|
-
/**
|
|
15075
|
-
* Resets the object to its state as if it were constructed with
|
|
15076
|
-
* `options` originally. state not on DEFAULT_PROPS is maintained.
|
|
15077
|
-
*
|
|
15078
|
-
* Analogous to React.js's replaceProps
|
|
15079
|
-
*/
|
|
15080
|
-
modify: function (options) {
|
|
15039
|
+
_listenerMap = {};
|
|
15040
|
+
constructor(graphie, movable, options) {
|
|
15041
|
+
this.graphie = graphie;
|
|
15042
|
+
this.movable = movable;
|
|
15043
|
+
// @ts-expect-error - TS2740: Type '{ id: string; }' is missing the following properties from type 'State': add, added, constraints, coord, and 19 more.
|
|
15044
|
+
this.state = {
|
|
15045
|
+
id: ___default["default"].uniqueId("movablePoint")
|
|
15046
|
+
};
|
|
15047
|
+
this.modify({
|
|
15048
|
+
...DEFAULT_STATE$1,
|
|
15049
|
+
...options
|
|
15050
|
+
});
|
|
15051
|
+
}
|
|
15052
|
+
modify(options) {
|
|
15081
15053
|
this.update(___default["default"].extend(this._createDefaultState(), options));
|
|
15082
|
-
}
|
|
15083
|
-
|
|
15084
|
-
|
|
15085
|
-
|
|
15086
|
-
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
|
|
15092
|
-
|
|
15093
|
-
|
|
15094
|
-
|
|
15095
|
-
|
|
15096
|
-
|
|
15054
|
+
}
|
|
15055
|
+
_createDefaultState() {
|
|
15056
|
+
return {
|
|
15057
|
+
id: this.state.id,
|
|
15058
|
+
...normalizeOptions$1(
|
|
15059
|
+
// Defaults are copied from MovablePointOptions.*.standard
|
|
15060
|
+
// These defaults are set here instead of DEFAULT_PROPS/STATE
|
|
15061
|
+
// because they:
|
|
15062
|
+
// - are objects, not primitives (and need a deeper copy)
|
|
15063
|
+
// - they don't need getters created for them
|
|
15064
|
+
// TODO(jack): Consider "default" once we es3ify perseus
|
|
15065
|
+
objective_.pluck(MovablePointOptions, "standard")
|
|
15066
|
+
// We only update props here, because we want things on state to
|
|
15067
|
+
// be persistent, and updated appropriately in modify()
|
|
15068
|
+
),
|
|
15097
15069
|
|
|
15098
|
-
|
|
15099
|
-
|
|
15100
|
-
|
|
15101
|
-
|
|
15102
|
-
|
|
15103
|
-
|
|
15104
|
-
|
|
15105
|
-
}
|
|
15106
|
-
|
|
15107
|
-
|
|
15108
|
-
}
|
|
15109
|
-
this.state.visibleShape.wrapper.className = "tooltip visible";
|
|
15110
|
-
this._tooltip.appendChild(document.createElement("span"));
|
|
15111
|
-
if (typeof contents === "string") {
|
|
15112
|
-
processMath(this._tooltip.firstChild, contents, false);
|
|
15113
|
-
} else if (typeof contents === "function") {
|
|
15114
|
-
contents(this._tooltip.firstChild);
|
|
15115
|
-
} else {
|
|
15116
|
-
this._tooltip.firstChild.appendChild(contents);
|
|
15117
|
-
}
|
|
15118
|
-
},
|
|
15119
|
-
_hideTooltip: function () {
|
|
15120
|
-
if (this._tooltip) {
|
|
15121
|
-
// Without the visible class, tooltips have display: none set
|
|
15122
|
-
this.state.visibleShape.wrapper.className = "tooltip";
|
|
15123
|
-
}
|
|
15124
|
-
},
|
|
15125
|
-
/**
|
|
15126
|
-
* Adjusts constructor parameters without changing previous settings
|
|
15127
|
-
* for any option not specified
|
|
15128
|
-
*
|
|
15129
|
-
* Analogous to React.js's setProps
|
|
15130
|
-
*/
|
|
15131
|
-
update: function (options) {
|
|
15070
|
+
...DEFAULT_PROPS$1
|
|
15071
|
+
};
|
|
15072
|
+
}
|
|
15073
|
+
cloneState() {
|
|
15074
|
+
return {
|
|
15075
|
+
...this.movable.cloneState(),
|
|
15076
|
+
...this.state
|
|
15077
|
+
};
|
|
15078
|
+
}
|
|
15079
|
+
update(options) {
|
|
15132
15080
|
const self = this;
|
|
15133
15081
|
const graphie = self.graphie;
|
|
15134
15082
|
const state = ___default["default"].extend(self.state, normalizeOptions$1(options));
|
|
@@ -15278,11 +15226,15 @@ ___default["default"].extend(MovablePoint$5.prototype, {
|
|
|
15278
15226
|
showTrashTooltip();
|
|
15279
15227
|
const content = svgElem.getElementsByClassName("tooltip-content")[0];
|
|
15280
15228
|
content.style.filter = "none";
|
|
15229
|
+
|
|
15230
|
+
// @ts-expect-error - this._tooltip.firstChild is possibly null
|
|
15281
15231
|
this._tooltip.firstChild.addEventListener("touchstart", e => {
|
|
15282
15232
|
// Prevent creation of a new point when the event is
|
|
15283
15233
|
// propagated up the DOM.
|
|
15284
15234
|
e.stopPropagation();
|
|
15285
15235
|
}, true);
|
|
15236
|
+
|
|
15237
|
+
// @ts-expect-error - this._tooltip.firstChild is possibly null
|
|
15286
15238
|
this._tooltip.firstChild.addEventListener("touchend", e => {
|
|
15287
15239
|
// Remove the point and prevent creation of a
|
|
15288
15240
|
// new point.
|
|
@@ -15304,6 +15256,7 @@ ___default["default"].extend(MovablePoint$5.prototype, {
|
|
|
15304
15256
|
|
|
15305
15257
|
// Trigger an add event if this hasn't been added before
|
|
15306
15258
|
if (!state.added) {
|
|
15259
|
+
// @ts-expect-error - type {} is missing properties from State
|
|
15307
15260
|
self.prevState = {};
|
|
15308
15261
|
self._fireEvent(state.add, self.cloneState(), self.prevState);
|
|
15309
15262
|
state.added = true;
|
|
@@ -15315,38 +15268,191 @@ ___default["default"].extend(MovablePoint$5.prototype, {
|
|
|
15315
15268
|
|
|
15316
15269
|
// Trigger a modify event
|
|
15317
15270
|
self._fireEvent(state.modify, self.cloneState(), self.prevState);
|
|
15318
|
-
}
|
|
15319
|
-
|
|
15320
|
-
|
|
15321
|
-
this._fireEvent(this.state.
|
|
15322
|
-
|
|
15323
|
-
|
|
15324
|
-
|
|
15325
|
-
// TODO(jack): This should really be moved off of
|
|
15326
|
-
// movablePoint.state and only kept on movable.state
|
|
15327
|
-
this.state.mouseTarget = null;
|
|
15328
|
-
},
|
|
15329
|
-
constrain: function () {
|
|
15271
|
+
}
|
|
15272
|
+
draw() {
|
|
15273
|
+
const currState = this.cloneState();
|
|
15274
|
+
this._fireEvent(this.state.draw, currState, this.prevState);
|
|
15275
|
+
this.prevState = currState;
|
|
15276
|
+
}
|
|
15277
|
+
constrain() {
|
|
15330
15278
|
const result = this._applyConstraints(this.coord(), this.coord());
|
|
15331
15279
|
if (kmath.point.is(result)) {
|
|
15332
15280
|
this.setCoord(result);
|
|
15333
15281
|
}
|
|
15334
15282
|
return result !== false;
|
|
15335
|
-
}
|
|
15336
|
-
|
|
15283
|
+
}
|
|
15284
|
+
|
|
15285
|
+
/**
|
|
15286
|
+
* Fire an onSomething type event to all functions in listeners
|
|
15287
|
+
*/
|
|
15288
|
+
_fireEvent(listeners) {
|
|
15289
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
15290
|
+
args[_key - 1] = arguments[_key];
|
|
15291
|
+
}
|
|
15292
|
+
for (const listener of listeners) {
|
|
15293
|
+
listener.call(this, ...args);
|
|
15294
|
+
}
|
|
15295
|
+
}
|
|
15296
|
+
|
|
15297
|
+
/**
|
|
15298
|
+
* Combine the array of constraints functions
|
|
15299
|
+
* Returns either an [x, y] coordinate or false
|
|
15300
|
+
*/
|
|
15301
|
+
_applyConstraints(current, previous, extraOptions) {
|
|
15302
|
+
let skipRemaining = false;
|
|
15303
|
+
return this.state.constraints.reduce((memo, constraint) => {
|
|
15304
|
+
// A move that has been cancelled won't be propagated to later
|
|
15305
|
+
// constraints calls
|
|
15306
|
+
if (memo === false) {
|
|
15307
|
+
return false;
|
|
15308
|
+
}
|
|
15309
|
+
if (skipRemaining) {
|
|
15310
|
+
return memo;
|
|
15311
|
+
}
|
|
15312
|
+
const result = constraint.call(this, memo, previous, {
|
|
15313
|
+
onSkipRemaining: () => {
|
|
15314
|
+
skipRemaining = true;
|
|
15315
|
+
},
|
|
15316
|
+
...extraOptions
|
|
15317
|
+
});
|
|
15318
|
+
if (result === false) {
|
|
15319
|
+
// Returning false cancels the move
|
|
15320
|
+
return false;
|
|
15321
|
+
}
|
|
15322
|
+
if (kmath.point.is(result, 2)) {
|
|
15323
|
+
// Returning a coord from constraints overrides the move
|
|
15324
|
+
return result;
|
|
15325
|
+
}
|
|
15326
|
+
if (result === true || result == null) {
|
|
15327
|
+
// Returning true or undefined allow the move to occur
|
|
15328
|
+
return memo;
|
|
15329
|
+
}
|
|
15330
|
+
// Anything else is an error
|
|
15331
|
+
throw new PerseusError("Constraint returned invalid result: " + result, Errors.Internal);
|
|
15332
|
+
}, current);
|
|
15333
|
+
}
|
|
15334
|
+
|
|
15335
|
+
/**
|
|
15336
|
+
* Displays a tooltip above the point, replacing any previous contents. If
|
|
15337
|
+
* there is no tooltip initialized, adds the tooltip.
|
|
15338
|
+
*
|
|
15339
|
+
* If the type of contents is string, the contents will be rendered with
|
|
15340
|
+
* KaTeX. Otherwise, the content will be assumed to be a DOM node and will
|
|
15341
|
+
* be appended inside the tooltip.
|
|
15342
|
+
*/
|
|
15343
|
+
_showTooltip(contents) {
|
|
15344
|
+
if (!this._tooltip) {
|
|
15345
|
+
this._tooltip = document.createElement("div");
|
|
15346
|
+
this._tooltip.className = "tooltip-content";
|
|
15347
|
+
this.state.visibleShape.wrapper.className = "tooltip";
|
|
15348
|
+
this.state.visibleShape.wrapper.appendChild(this._tooltip);
|
|
15349
|
+
|
|
15350
|
+
// Only one tooltip should be displayed at a time, so store a list
|
|
15351
|
+
// of all the tooltips initialized.
|
|
15352
|
+
tooltipResetFunctions.push(() => {
|
|
15353
|
+
if (this.state.added) {
|
|
15354
|
+
this._hideTooltip();
|
|
15355
|
+
}
|
|
15356
|
+
});
|
|
15357
|
+
}
|
|
15358
|
+
if (this._tooltip.firstChild) {
|
|
15359
|
+
this._tooltip.removeChild(this._tooltip.firstChild);
|
|
15360
|
+
}
|
|
15361
|
+
this.state.visibleShape.wrapper.className = "tooltip visible";
|
|
15362
|
+
this._tooltip.appendChild(document.createElement("span"));
|
|
15363
|
+
if (typeof contents === "string") {
|
|
15364
|
+
// @ts-expect-error - this._tooltip.firstChild is possibly 'null'.
|
|
15365
|
+
processMath(this._tooltip.firstChild, contents, false);
|
|
15366
|
+
} else if (typeof contents === "function") {
|
|
15367
|
+
contents(this._tooltip.firstChild);
|
|
15368
|
+
} else {
|
|
15369
|
+
// @ts-expect-error - this._tooltip.firstChild is possibly 'null'.
|
|
15370
|
+
this._tooltip.firstChild.appendChild(contents);
|
|
15371
|
+
}
|
|
15372
|
+
}
|
|
15373
|
+
_hideTooltip() {
|
|
15374
|
+
if (this._tooltip) {
|
|
15375
|
+
// Without the visible class, tooltips have display: none set
|
|
15376
|
+
this.state.visibleShape.wrapper.className = "tooltip";
|
|
15377
|
+
}
|
|
15378
|
+
}
|
|
15379
|
+
coord() {
|
|
15380
|
+
return this.state.coord;
|
|
15381
|
+
}
|
|
15382
|
+
setCoord(coord) {
|
|
15337
15383
|
assert$6(kmath.point.is(coord, 2));
|
|
15338
15384
|
this.state.coord = ___default["default"].clone(coord);
|
|
15339
15385
|
this.draw();
|
|
15340
|
-
}
|
|
15341
|
-
setCoordConstrained
|
|
15386
|
+
}
|
|
15387
|
+
setCoordConstrained(coord) {
|
|
15342
15388
|
assert$6(kmath.point.is(coord, 2));
|
|
15343
15389
|
const result = this._applyConstraints(coord, this.coord());
|
|
15344
15390
|
if (result !== false) {
|
|
15345
15391
|
this.state.coord = ___default["default"].clone(result);
|
|
15346
15392
|
this.draw();
|
|
15347
15393
|
}
|
|
15348
|
-
}
|
|
15349
|
-
|
|
15394
|
+
}
|
|
15395
|
+
|
|
15396
|
+
/**
|
|
15397
|
+
* Add a listener to any event: startMove, constraints, onMove, onMoveEnd,
|
|
15398
|
+
* etc. If a listener is already bound to the given eventName and id, then
|
|
15399
|
+
* it is overwritten by func.
|
|
15400
|
+
*
|
|
15401
|
+
* eventName: the string name of the event to listen to. one of:
|
|
15402
|
+
* "onMoveStart", "onMove", "onMoveEnd", "draw", "remove"
|
|
15403
|
+
*
|
|
15404
|
+
* id: a string id that can be used to remove this event at a later time
|
|
15405
|
+
* note: adding multiple listeners with the same id is undefined behavior
|
|
15406
|
+
*
|
|
15407
|
+
* func: the function to call when the event happens, which is called
|
|
15408
|
+
* with the event's standard parameters [usually (coord, prevCoord) or
|
|
15409
|
+
* (state, prevState)]
|
|
15410
|
+
*/
|
|
15411
|
+
// TODO(benchristel): listen() is duplicated in movable.ts
|
|
15412
|
+
listen(eventName, id, func) {
|
|
15413
|
+
this._listenerMap = this._listenerMap || {};
|
|
15414
|
+
|
|
15415
|
+
// If there's an existing handler, replace it by using its index in
|
|
15416
|
+
// `this.state[eventName]`; otherwise, add this handler to the end
|
|
15417
|
+
const key = getKey(eventName, id);
|
|
15418
|
+
const index = this._listenerMap[key] = this._listenerMap[key] || this.state[eventName].length;
|
|
15419
|
+
this.state[eventName][index] = func;
|
|
15420
|
+
}
|
|
15421
|
+
|
|
15422
|
+
/**
|
|
15423
|
+
* Remove a previously added listener, by the id specified in the
|
|
15424
|
+
* corresponding listen() call
|
|
15425
|
+
*
|
|
15426
|
+
* If the given id has not been registered already, this is a no-op
|
|
15427
|
+
*/
|
|
15428
|
+
// TODO(benchristel): I don't think unlisten is used. Delete it?
|
|
15429
|
+
// TODO(benchristel): unlisten is duplicated in movable.ts
|
|
15430
|
+
unlisten(eventName, id) {
|
|
15431
|
+
this._listenerMap = this._listenerMap || {};
|
|
15432
|
+
const key = getKey(eventName, id);
|
|
15433
|
+
const index = this._listenerMap[key];
|
|
15434
|
+
if (index !== undefined) {
|
|
15435
|
+
// Remove handler from list of event handlers and listenerMap
|
|
15436
|
+
this.state[eventName].splice(index, 1);
|
|
15437
|
+
delete this._listenerMap[key];
|
|
15438
|
+
|
|
15439
|
+
// Re-index existing events: if they occur after `index`, decrement
|
|
15440
|
+
const keys = ___default["default"].keys(this._listenerMap);
|
|
15441
|
+
___default["default"].each(keys, key => {
|
|
15442
|
+
if (getEventName(key) === eventName && this._listenerMap[key] > index) {
|
|
15443
|
+
this._listenerMap[key]--;
|
|
15444
|
+
}
|
|
15445
|
+
}, this);
|
|
15446
|
+
}
|
|
15447
|
+
}
|
|
15448
|
+
grab(coord) {
|
|
15449
|
+
// Provide an explicit touchOffset override, so that we track the user's
|
|
15450
|
+
// finger when a point has been grabbed.
|
|
15451
|
+
this.state.touchOffset = [0, 0];
|
|
15452
|
+
this.movable.grab(coord);
|
|
15453
|
+
this.moveTo(coord);
|
|
15454
|
+
}
|
|
15455
|
+
moveTo(coord) {
|
|
15350
15456
|
// The caller has the option of adding an onMove() method to the
|
|
15351
15457
|
// movablePoint object we return as a sort of event handler
|
|
15352
15458
|
// By returning false from onMove(), the move can be vetoed,
|
|
@@ -15358,8 +15464,11 @@ ___default["default"].extend(MovablePoint$5.prototype, {
|
|
|
15358
15464
|
const result = this._applyConstraints(coord, state.coord, state.onRemove ? {
|
|
15359
15465
|
onOutOfBounds: () => {
|
|
15360
15466
|
this.state.outOfBounds = true;
|
|
15361
|
-
}
|
|
15362
|
-
|
|
15467
|
+
},
|
|
15468
|
+
onSkipRemaining: () => {}
|
|
15469
|
+
} : {
|
|
15470
|
+
onSkipRemaining: () => {}
|
|
15471
|
+
});
|
|
15363
15472
|
if (result === false) {
|
|
15364
15473
|
return;
|
|
15365
15474
|
}
|
|
@@ -15373,49 +15482,98 @@ ___default["default"].extend(MovablePoint$5.prototype, {
|
|
|
15373
15482
|
this._fireEvent(state.onMove, state.coord, prevCoord);
|
|
15374
15483
|
this.draw();
|
|
15375
15484
|
}
|
|
15376
|
-
}
|
|
15377
|
-
|
|
15378
|
-
|
|
15379
|
-
|
|
15380
|
-
|
|
15381
|
-
|
|
15382
|
-
|
|
15383
|
-
|
|
15384
|
-
|
|
15485
|
+
}
|
|
15486
|
+
remove() {
|
|
15487
|
+
this.state.added = false;
|
|
15488
|
+
this._fireEvent(this.state.remove);
|
|
15489
|
+
if (this.movable) {
|
|
15490
|
+
this.movable.remove();
|
|
15491
|
+
}
|
|
15492
|
+
// TODO(jack): This should really be moved off of
|
|
15493
|
+
// movablePoint.state and only kept on movable.state
|
|
15494
|
+
this.state.mouseTarget = null;
|
|
15495
|
+
}
|
|
15496
|
+
pointSize() {
|
|
15497
|
+
return this.state.pointSize;
|
|
15498
|
+
}
|
|
15499
|
+
static() {
|
|
15500
|
+
return this.state.static;
|
|
15501
|
+
}
|
|
15502
|
+
cursor() {
|
|
15503
|
+
return this.state.cursor;
|
|
15504
|
+
}
|
|
15505
|
+
normalStyle() {
|
|
15506
|
+
return this.state.normalStyle;
|
|
15507
|
+
}
|
|
15508
|
+
highlightStyle() {
|
|
15509
|
+
return this.state.highlightStyle;
|
|
15510
|
+
}
|
|
15511
|
+
shadow() {
|
|
15512
|
+
return this.state.shadow;
|
|
15513
|
+
}
|
|
15514
|
+
tooltip() {
|
|
15515
|
+
return this.state.tooltip;
|
|
15516
|
+
}
|
|
15517
|
+
added() {
|
|
15518
|
+
return this.state.added;
|
|
15519
|
+
}
|
|
15520
|
+
hasMoved() {
|
|
15521
|
+
return this.state.hasMoved;
|
|
15522
|
+
}
|
|
15523
|
+
visibleShape() {
|
|
15524
|
+
return this.state.visibleShape;
|
|
15525
|
+
}
|
|
15526
|
+
outOfBounds() {
|
|
15527
|
+
return this.state.outOfBounds;
|
|
15528
|
+
}
|
|
15529
|
+
mouseTarget() {
|
|
15530
|
+
return this.state.mouseTarget;
|
|
15531
|
+
}
|
|
15532
|
+
touchOffset() {
|
|
15533
|
+
return this.state.touchOffset;
|
|
15534
|
+
}
|
|
15535
|
+
|
|
15536
|
+
/**
|
|
15537
|
+
* Forwarding methods to this.movable:
|
|
15538
|
+
*/
|
|
15539
|
+
isHovering() {
|
|
15540
|
+
return this.movable.isHovering();
|
|
15541
|
+
}
|
|
15542
|
+
isDragging() {
|
|
15543
|
+
return this.movable.isDragging();
|
|
15544
|
+
}
|
|
15545
|
+
|
|
15385
15546
|
// Change z-order to back
|
|
15386
|
-
toBack
|
|
15547
|
+
toBack() {
|
|
15387
15548
|
this.movable.toBack();
|
|
15388
15549
|
if (this.state.visibleShape) {
|
|
15389
15550
|
this.state.visibleShape.toBack();
|
|
15390
15551
|
}
|
|
15391
|
-
}
|
|
15552
|
+
}
|
|
15553
|
+
|
|
15392
15554
|
// Change z-order to front
|
|
15393
|
-
toFront
|
|
15555
|
+
toFront() {
|
|
15394
15556
|
if (this.state.visibleShape) {
|
|
15395
15557
|
this.state.visibleShape.toFront();
|
|
15396
15558
|
}
|
|
15397
15559
|
this.movable.toFront();
|
|
15398
|
-
},
|
|
15399
|
-
/**
|
|
15400
|
-
* Forwarding methods to this.movable:
|
|
15401
|
-
*/
|
|
15402
|
-
isHovering: function () {
|
|
15403
|
-
return this.movable.isHovering();
|
|
15404
|
-
},
|
|
15405
|
-
isDragging: function () {
|
|
15406
|
-
return this.movable.isDragging();
|
|
15407
|
-
},
|
|
15408
|
-
mouseTarget: function () {
|
|
15409
|
-
return this.movable.mouseTarget();
|
|
15410
|
-
},
|
|
15411
|
-
grab: function (coord) {
|
|
15412
|
-
// Provide an explicit touchOffset override, so that we track the user's
|
|
15413
|
-
// finger when a point has been grabbed.
|
|
15414
|
-
this.state.touchOffset = [0, 0];
|
|
15415
|
-
this.movable.grab(coord);
|
|
15416
|
-
this.moveTo(coord);
|
|
15417
15560
|
}
|
|
15418
|
-
|
|
15561
|
+
static add = MovablePointOptions.add;
|
|
15562
|
+
static modify = MovablePointOptions.modify;
|
|
15563
|
+
static draw = MovablePointOptions.draw;
|
|
15564
|
+
static remove = MovablePointOptions.remove;
|
|
15565
|
+
static onMoveStart = MovablePointOptions.onMoveStart;
|
|
15566
|
+
static constraints = MovablePointOptions.constraints;
|
|
15567
|
+
static onMove = MovablePointOptions.onMove;
|
|
15568
|
+
static onMoveEnd = MovablePointOptions.onMoveEnd;
|
|
15569
|
+
static onClick = MovablePointOptions.onClick;
|
|
15570
|
+
}
|
|
15571
|
+
function getKey(eventName, id) {
|
|
15572
|
+
return eventName + ":" + id;
|
|
15573
|
+
}
|
|
15574
|
+
function getEventName(key) {
|
|
15575
|
+
return key.split(":")[0];
|
|
15576
|
+
}
|
|
15419
15577
|
|
|
15420
15578
|
/* eslint-disable @babel/no-invalid-this */
|
|
15421
15579
|
function sum(array) {
|
|
@@ -16391,11 +16549,9 @@ class Graphie extends React__namespace.Component {
|
|
|
16391
16549
|
});
|
|
16392
16550
|
// Only add the mouselayer if we actually want one.
|
|
16393
16551
|
if (this.props.addMouseLayer) {
|
|
16394
|
-
// @ts-expect-error - TS2339: Property 'addMouseLayer' does not exist on type 'Graphie'.
|
|
16395
16552
|
graphie.addMouseLayer({
|
|
16396
16553
|
onClick: this.props.onClick,
|
|
16397
16554
|
onMouseDown: this.props.onMouseDown,
|
|
16398
|
-
onMouseUp: this.props.onMouseUp,
|
|
16399
16555
|
onMouseMove: this.props.onMouseMove,
|
|
16400
16556
|
setDrawingAreaAvailable: this.props.setDrawingAreaAvailable
|
|
16401
16557
|
});
|
|
@@ -26430,11 +26586,7 @@ class FunctionGrapher extends React__namespace.Component {
|
|
|
26430
26586
|
key: i,
|
|
26431
26587
|
coord: coord,
|
|
26432
26588
|
static: this.props.static,
|
|
26433
|
-
constraints: [
|
|
26434
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
26435
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
26436
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
26437
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
26589
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
26438
26590
|
// Always enforce that this is a function
|
|
26439
26591
|
const isFunction = ___default["default"].all(this._coords(), (otherCoord, j) => {
|
|
26440
26592
|
return i === j || !otherCoord || !kmath.number.equal(coord[0], otherCoord[0]);
|
|
@@ -28122,22 +28274,20 @@ class Graph extends React__namespace.Component {
|
|
|
28122
28274
|
// @ts-expect-error - TS2683 - 'this' implicitly has type 'any' because it does not have a type annotation.
|
|
28123
28275
|
// eslint-disable-next-line @babel/no-invalid-this
|
|
28124
28276
|
this.props.onMouseDown(coord);
|
|
28125
|
-
}, this) :
|
|
28277
|
+
}, this) : undefined;
|
|
28126
28278
|
const onMouseOver = $instructionsWrapper ? function () {
|
|
28127
28279
|
$instructionsWrapper && $instructionsWrapper.css("opacity", invisible);
|
|
28128
|
-
} :
|
|
28280
|
+
} : undefined;
|
|
28129
28281
|
const onMouseOut = $instructionsWrapper ? function () {
|
|
28130
28282
|
$instructionsWrapper && $instructionsWrapper.css("opacity", visible);
|
|
28131
|
-
} :
|
|
28283
|
+
} : undefined;
|
|
28132
28284
|
/* eslint-enable indent */
|
|
28133
28285
|
|
|
28134
|
-
// @ts-expect-error - Property 'addMouseLayer' does not exist on type 'Graphie'.
|
|
28135
28286
|
graphie.addMouseLayer({
|
|
28136
28287
|
onClick: this.props.onClick,
|
|
28137
28288
|
onMouseDown: onMouseDown,
|
|
28138
28289
|
onMouseOver: onMouseOver,
|
|
28139
28290
|
onMouseOut: onMouseOut,
|
|
28140
|
-
onMouseUp: this.props.onMouseUp,
|
|
28141
28291
|
onMouseMove: this.props.onMouseMove,
|
|
28142
28292
|
allowScratchpad: true,
|
|
28143
28293
|
setDrawingAreaAvailable: this.props.setDrawingAreaAvailable
|
|
@@ -28500,11 +28650,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
28500
28650
|
const points = self.points = ___default["default"].map(coords, coord => {
|
|
28501
28651
|
return Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28502
28652
|
coord: coord,
|
|
28503
|
-
constraints: [
|
|
28504
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28505
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28506
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28507
|
-
Interactive2.MovablePoint.constraints.snap()],
|
|
28653
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap()],
|
|
28508
28654
|
onMove: () => {
|
|
28509
28655
|
const graph = ___default["default"].extend({}, self.props.graph, {
|
|
28510
28656
|
coords: ___default["default"].invoke(points, "coord")
|
|
@@ -28575,11 +28721,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
28575
28721
|
let pointA = null;
|
|
28576
28722
|
pointA = this.pointA = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28577
28723
|
coord: coords[0],
|
|
28578
|
-
constraints: [
|
|
28579
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28580
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28581
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28582
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28724
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28583
28725
|
return !pointA ||
|
|
28584
28726
|
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
28585
28727
|
coord[0] !== pointB.coord()[0] &&
|
|
@@ -28595,11 +28737,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
28595
28737
|
let pointB = null;
|
|
28596
28738
|
pointB = this.pointB = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28597
28739
|
coord: coords[1],
|
|
28598
|
-
constraints: [
|
|
28599
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28600
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28601
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28602
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28740
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28603
28741
|
return !pointB ||
|
|
28604
28742
|
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
28605
28743
|
coord[0] !== pointA.coord()[0] &&
|
|
@@ -28615,11 +28753,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
28615
28753
|
let pointC = null;
|
|
28616
28754
|
pointC = this.pointC = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28617
28755
|
coord: coords[2],
|
|
28618
|
-
constraints: [
|
|
28619
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28620
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28621
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28622
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28756
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28623
28757
|
return !pointC ||
|
|
28624
28758
|
// @ts-expect-error - TS2531 - Object is possibly 'null'.
|
|
28625
28759
|
coord[0] !== pointA.coord()[0] &&
|
|
@@ -28690,22 +28824,14 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
28690
28824
|
let pointA = null;
|
|
28691
28825
|
pointA = this.pointA = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28692
28826
|
coord: coords[0],
|
|
28693
|
-
constraints: [
|
|
28694
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28695
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28696
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28697
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28827
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28698
28828
|
return !pointA || coord[0] !== pointB.coord()[0];
|
|
28699
28829
|
}],
|
|
28700
28830
|
onMove: onMoveHandler
|
|
28701
28831
|
});
|
|
28702
28832
|
const pointB = this.pointB = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28703
28833
|
coord: coords[1],
|
|
28704
|
-
constraints: [
|
|
28705
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28706
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28707
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28708
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28834
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28709
28835
|
// @ts-expect-error - TS2339 - Property 'coord' does not exist on type 'never'.
|
|
28710
28836
|
return !pointA || coord[0] !== pointA.coord()[0];
|
|
28711
28837
|
}],
|
|
@@ -28786,11 +28912,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
28786
28912
|
const coord = segmentCoords[i];
|
|
28787
28913
|
segmentPoints.push(Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28788
28914
|
coord: coord,
|
|
28789
|
-
constraints: [
|
|
28790
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28791
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28792
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28793
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28915
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
28794
28916
|
const otherSegment = segmentPoints[1 - i];
|
|
28795
28917
|
if (!otherSegment) {
|
|
28796
28918
|
// segment hasn't been defined yet
|
|
@@ -28865,11 +28987,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
28865
28987
|
let point = null;
|
|
28866
28988
|
point = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
28867
28989
|
coord: coord,
|
|
28868
|
-
constraints: [
|
|
28869
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28870
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
28871
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
28872
|
-
Interactive2.MovablePoint.constraints.snap(), function (coord) {
|
|
28990
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), function (coord) {
|
|
28873
28991
|
// TODO(jack): There ought to be a
|
|
28874
28992
|
// MovablePoint.constraints.avoid
|
|
28875
28993
|
// default that lets you do things like this
|
|
@@ -29144,11 +29262,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
29144
29262
|
};
|
|
29145
29263
|
const point = Interactive2.addMaybeMobileMovablePoint(this, {
|
|
29146
29264
|
coord: coord,
|
|
29147
|
-
constraints: [
|
|
29148
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
29149
|
-
Interactive2.MovablePoint.constraints.bound(), snapToGrid ?
|
|
29150
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
29151
|
-
Interactive2.MovablePoint.constraints.snap() : null, graphConstraint],
|
|
29265
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), snapToGrid ? Interactive2.MovablePoint.constraints.snap() : null, graphConstraint],
|
|
29152
29266
|
onMoveStart: () => {
|
|
29153
29267
|
if (this.isClickToAddPoints()) {
|
|
29154
29268
|
this.setTrashCanVisibility(1);
|
|
@@ -29240,11 +29354,7 @@ class InteractiveGraph extends React__namespace.Component {
|
|
|
29240
29354
|
const coord = segment[i];
|
|
29241
29355
|
points.push(createPoint({
|
|
29242
29356
|
coord: coord,
|
|
29243
|
-
constraints: [
|
|
29244
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
29245
|
-
Interactive2.MovablePoint.constraints.bound(),
|
|
29246
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
29247
|
-
Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
29357
|
+
constraints: [Interactive2.MovablePoint.constraints.bound(), Interactive2.MovablePoint.constraints.snap(), coord => {
|
|
29248
29358
|
const otherPoint = points[1 - i];
|
|
29249
29359
|
if (!otherPoint) {
|
|
29250
29360
|
// point hasn't been defined yet
|
|
@@ -33938,7 +34048,6 @@ const Measurer = createReactClass__default["default"]({
|
|
|
33938
34048
|
range: range,
|
|
33939
34049
|
scale: scale
|
|
33940
34050
|
});
|
|
33941
|
-
// @ts-expect-error - Property 'addMouseLayer' does not exist on type 'Graphie'.
|
|
33942
34051
|
graphie.addMouseLayer({
|
|
33943
34052
|
allowScratchpad: true,
|
|
33944
34053
|
setDrawingAreaAvailable: this.props.apiOptions.setDrawingAreaAvailable
|
|
@@ -38481,7 +38590,6 @@ class Plotter extends React__namespace.Component {
|
|
|
38481
38590
|
scale: c.scale,
|
|
38482
38591
|
isMobile: this.props.apiOptions.isMobile
|
|
38483
38592
|
});
|
|
38484
|
-
// @ts-expect-error - Property 'addMouseLayer' does not exist on type 'Graphie'.
|
|
38485
38593
|
graphie.addMouseLayer({
|
|
38486
38594
|
allowScratchpad: true,
|
|
38487
38595
|
setDrawingAreaAvailable: this.props.apiOptions.setDrawingAreaAvailable
|
|
@@ -38894,7 +39002,6 @@ class Plotter extends React__namespace.Component {
|
|
|
38894
39002
|
if (i > 0) {
|
|
38895
39003
|
c.graph.lines[i] = Interactive2.addMovableLine(graphie, {
|
|
38896
39004
|
points: [c.graph.points[i - 1], c.graph.points[i]],
|
|
38897
|
-
// @ts-expect-error - TS2339 - Property 'constraints' does not exist on type '(graphie: any, movable: any, options: any) => void'.
|
|
38898
39005
|
constraints: Interactive2.MovablePoint.constraints.fixed(),
|
|
38899
39006
|
normalStyle: {
|
|
38900
39007
|
stroke: KhanColors.BLUE_C,
|
|
@@ -40481,366 +40588,222 @@ var Table$1 = {
|
|
|
40481
40588
|
isLintable: true
|
|
40482
40589
|
};
|
|
40483
40590
|
|
|
40484
|
-
var
|
|
40485
|
-
|
|
40486
|
-
|
|
40487
|
-
|
|
40488
|
-
|
|
40489
|
-
|
|
40490
|
-
|
|
40491
|
-
|
|
40492
|
-
|
|
40493
|
-
|
|
40494
|
-
|
|
40495
|
-
|
|
40496
|
-
|
|
40497
|
-
|
|
40498
|
-
|
|
40499
|
-
|
|
40500
|
-
|
|
40501
|
-
|
|
40502
|
-
|
|
40503
|
-
|
|
40504
|
-
|
|
40505
|
-
|
|
40506
|
-
|
|
40507
|
-
|
|
40508
|
-
|
|
40509
|
-
|
|
40510
|
-
|
|
40511
|
-
|
|
40512
|
-
|
|
40513
|
-
|
|
40514
|
-
|
|
40515
|
-
|
|
40516
|
-
|
|
40517
|
-
|
|
40518
|
-
|
|
40519
|
-
|
|
40520
|
-
|
|
40521
|
-
|
|
40522
|
-
|
|
40523
|
-
|
|
40524
|
-
|
|
40525
|
-
|
|
40526
|
-
|
|
40527
|
-
|
|
40528
|
-
|
|
40529
|
-
|
|
40530
|
-
|
|
40531
|
-
|
|
40532
|
-
|
|
40533
|
-
|
|
40534
|
-
|
|
40535
|
-
|
|
40536
|
-
|
|
40537
|
-
|
|
40538
|
-
|
|
40539
|
-
|
|
40540
|
-
|
|
40541
|
-
|
|
40542
|
-
|
|
40543
|
-
|
|
40544
|
-
|
|
40545
|
-
|
|
40546
|
-
|
|
40547
|
-
|
|
40548
|
-
|
|
40549
|
-
|
|
40550
|
-
|
|
40551
|
-
|
|
40552
|
-
|
|
40553
|
-
|
|
40554
|
-
|
|
40555
|
-
|
|
40556
|
-
|
|
40557
|
-
|
|
40558
|
-
|
|
40559
|
-
|
|
40560
|
-
|
|
40561
|
-
|
|
40562
|
-
|
|
40563
|
-
|
|
40564
|
-
|
|
40565
|
-
|
|
40566
|
-
|
|
40567
|
-
|
|
40568
|
-
|
|
40569
|
-
|
|
40570
|
-
|
|
40571
|
-
|
|
40572
|
-
|
|
40573
|
-
|
|
40574
|
-
|
|
40575
|
-
|
|
40576
|
-
|
|
40577
|
-
|
|
40578
|
-
|
|
40579
|
-
|
|
40580
|
-
|
|
40581
|
-
|
|
40582
|
-
|
|
40583
|
-
|
|
40584
|
-
|
|
40585
|
-
|
|
40586
|
-
|
|
40587
|
-
|
|
40588
|
-
|
|
40589
|
-
|
|
40590
|
-
|
|
40591
|
-
|
|
40592
|
-
|
|
40593
|
-
|
|
40594
|
-
|
|
40595
|
-
|
|
40596
|
-
|
|
40597
|
-
|
|
40598
|
-
|
|
40599
|
-
|
|
40600
|
-
|
|
40601
|
-
|
|
40602
|
-
|
|
40603
|
-
|
|
40604
|
-
|
|
40605
|
-
|
|
40606
|
-
|
|
40607
|
-
|
|
40608
|
-
|
|
40609
|
-
|
|
40610
|
-
|
|
40611
|
-
|
|
40612
|
-
|
|
40613
|
-
|
|
40614
|
-
|
|
40615
|
-
|
|
40616
|
-
|
|
40617
|
-
|
|
40618
|
-
|
|
40619
|
-
|
|
40620
|
-
|
|
40621
|
-
|
|
40622
|
-
|
|
40623
|
-
|
|
40624
|
-
|
|
40625
|
-
|
|
40626
|
-
|
|
40627
|
-
|
|
40628
|
-
|
|
40629
|
-
|
|
40630
|
-
|
|
40631
|
-
|
|
40632
|
-
|
|
40633
|
-
|
|
40634
|
-
|
|
40635
|
-
|
|
40636
|
-
|
|
40637
|
-
|
|
40638
|
-
|
|
40639
|
-
|
|
40640
|
-
|
|
40641
|
-
|
|
40642
|
-
|
|
40643
|
-
|
|
40644
|
-
|
|
40645
|
-
|
|
40646
|
-
|
|
40647
|
-
|
|
40648
|
-
|
|
40649
|
-
|
|
40650
|
-
|
|
40651
|
-
|
|
40652
|
-
|
|
40653
|
-
|
|
40654
|
-
|
|
40655
|
-
|
|
40656
|
-
|
|
40657
|
-
|
|
40658
|
-
|
|
40659
|
-
|
|
40660
|
-
|
|
40661
|
-
|
|
40662
|
-
|
|
40663
|
-
|
|
40664
|
-
|
|
40665
|
-
|
|
40666
|
-
|
|
40667
|
-
|
|
40668
|
-
|
|
40669
|
-
|
|
40670
|
-
|
|
40671
|
-
|
|
40672
|
-
|
|
40673
|
-
|
|
40674
|
-
|
|
40675
|
-
|
|
40676
|
-
|
|
40677
|
-
|
|
40678
|
-
|
|
40679
|
-
|
|
40680
|
-
|
|
40681
|
-
|
|
40682
|
-
|
|
40683
|
-
|
|
40684
|
-
|
|
40685
|
-
|
|
40686
|
-
|
|
40687
|
-
|
|
40688
|
-
|
|
40689
|
-
|
|
40690
|
-
|
|
40691
|
-
|
|
40692
|
-
|
|
40693
|
-
|
|
40694
|
-
|
|
40695
|
-
|
|
40696
|
-
|
|
40697
|
-
|
|
40698
|
-
|
|
40699
|
-
|
|
40700
|
-
lens.prototype.merge = function (lensArr, props) {
|
|
40701
|
-
this._wrapped = lens(this._wrapped).mod(lensArr, function (oldProps) {
|
|
40702
|
-
return merge(oldProps, props);
|
|
40703
|
-
}).freeze();
|
|
40704
|
-
return this;
|
|
40705
|
-
};
|
|
40706
|
-
|
|
40707
|
-
// Lens must have length >= 1 or there would be nothing to return
|
|
40708
|
-
lens.prototype.del = function (lensArr) {
|
|
40709
|
-
var obj = this._wrapped;
|
|
40710
|
-
var ops = dispatch(obj);
|
|
40711
|
-
if (lensArr.length === 1) {
|
|
40712
|
-
this._wrapped = ops.del(obj, lensArr[0]);
|
|
40713
|
-
} else {
|
|
40714
|
-
var monocle = lensArr[0];
|
|
40715
|
-
var shortLens = lensArr.slice(1);
|
|
40716
|
-
var newObj = clone(obj);
|
|
40717
|
-
newObj[monocle] = lens(obj[monocle]).del(shortLens).freeze();
|
|
40718
|
-
this._wrapped = newObj;
|
|
40719
|
-
}
|
|
40720
|
-
return this;
|
|
40721
|
-
};
|
|
40722
|
-
lens.prototype.set = function (lensArr, set) {
|
|
40723
|
-
return this.mod(lensArr, function () {
|
|
40724
|
-
return set;
|
|
40725
|
-
});
|
|
40726
|
-
};
|
|
40727
|
-
module.exports = lens;
|
|
40728
|
-
|
|
40729
|
-
/***/
|
|
40730
|
-
}, /* 2 */
|
|
40731
|
-
/***/function (module, exports) {
|
|
40732
|
-
var get = function (arr, monocle) {
|
|
40733
|
-
return arr[monocle];
|
|
40734
|
-
};
|
|
40735
|
-
var set = function (arr, monocle, val) {
|
|
40736
|
-
var newArr = arr.splice();
|
|
40737
|
-
newArr[monocle] = val;
|
|
40738
|
-
return newArr;
|
|
40739
|
-
};
|
|
40740
|
-
var mod = function (arr, monocle, f) {
|
|
40741
|
-
var newArr = arr.slice();
|
|
40742
|
-
newArr[monocle] = f(arr[monocle]);
|
|
40743
|
-
return newArr;
|
|
40744
|
-
};
|
|
40745
|
-
var del = function (arr, monocle) {
|
|
40746
|
-
var newArr = arr.slice();
|
|
40747
|
-
newArr.splice(monocle, 1);
|
|
40748
|
-
return newArr;
|
|
40749
|
-
};
|
|
40750
|
-
|
|
40751
|
-
/*
|
|
40752
|
-
// Lens must point to a member of an array. We'll insert into that array.
|
|
40753
|
-
lens.prototype.insertAt = function(lensArr, toInsert) {
|
|
40754
|
-
var obj = this._wrapped;
|
|
40755
|
-
|
|
40756
|
-
var arrLens = lensArr.slice(0, -1);
|
|
40757
|
-
var arr = lens(obj).get(arrLens).slice(); // slice to copy
|
|
40758
|
-
|
|
40759
|
-
var arrIdx = lensArr[lensArr.length-1];
|
|
40760
|
-
arr.splice(arrIdx, 0, toInsert);
|
|
40761
|
-
return lens(obj).set(arrLens, arr);
|
|
40762
|
-
};
|
|
40763
|
-
|
|
40764
|
-
lens.prototype.insertBefore = lens.prototype.insertAt;
|
|
40765
|
-
lens.prototype.insertAfter = function(lensArr, toInsert) {
|
|
40766
|
-
var newLens = lensArr.slice();
|
|
40767
|
-
newLens[newLens.length-1] += 1;
|
|
40768
|
-
return lens(this._wrapped).insertAt(newLens, toInsert);
|
|
40769
|
-
};
|
|
40770
|
-
*/
|
|
40771
|
-
|
|
40772
|
-
module.exports = {
|
|
40773
|
-
get: get,
|
|
40774
|
-
set: set,
|
|
40775
|
-
mod: mod,
|
|
40776
|
-
del: del
|
|
40777
|
-
};
|
|
40778
|
-
|
|
40779
|
-
/***/
|
|
40780
|
-
}, /* 3 */
|
|
40781
|
-
/***/function (module, exports, __webpack_require__) {
|
|
40782
|
-
var clone = __webpack_require__(0).clone;
|
|
40783
|
-
var get = function (obj, monocle) {
|
|
40784
|
-
return obj[monocle];
|
|
40785
|
-
};
|
|
40786
|
-
var set = function (obj, monocle, val) {
|
|
40787
|
-
var newObj = clone(obj);
|
|
40788
|
-
newObj[monocle] = val;
|
|
40789
|
-
return newObj;
|
|
40790
|
-
};
|
|
40791
|
-
var mod = function (obj, monocle, f) {
|
|
40792
|
-
var newObj = clone(obj);
|
|
40793
|
-
newObj[monocle] = f(obj[monocle]);
|
|
40794
|
-
return newObj;
|
|
40795
|
-
};
|
|
40796
|
-
var del = function (obj, monocle) {
|
|
40797
|
-
var newObj = clone(obj);
|
|
40798
|
-
delete newObj[monocle];
|
|
40799
|
-
return newObj;
|
|
40800
|
-
};
|
|
40801
|
-
module.exports = {
|
|
40802
|
-
get: get,
|
|
40803
|
-
set: set,
|
|
40804
|
-
mod: mod,
|
|
40805
|
-
del: del
|
|
40806
|
-
};
|
|
40807
|
-
|
|
40808
|
-
/***/
|
|
40809
|
-
}, /* 4 */
|
|
40810
|
-
/***/function (module, exports) {
|
|
40811
|
-
var get = function (arr, monocle) {
|
|
40812
|
-
return arr[monocle];
|
|
40813
|
-
};
|
|
40814
|
-
var set = function (arr, monocle, val) {
|
|
40815
|
-
var newArr = arr.splice();
|
|
40816
|
-
newArr[monocle] = val;
|
|
40817
|
-
return newArr;
|
|
40818
|
-
};
|
|
40819
|
-
var mod = function (arr, monocle, f) {
|
|
40820
|
-
var newArr = arr.splice();
|
|
40821
|
-
newArr[monocle] = f(arr[monocle]);
|
|
40822
|
-
return newArr;
|
|
40823
|
-
};
|
|
40824
|
-
var del = function (arr, monocle) {
|
|
40825
|
-
var newArr = arr.slice();
|
|
40826
|
-
newArr.splice(monocle);
|
|
40827
|
-
return newArr;
|
|
40828
|
-
};
|
|
40829
|
-
module.exports = {
|
|
40830
|
-
get: get,
|
|
40831
|
-
set: set,
|
|
40832
|
-
mod: mod,
|
|
40833
|
-
del: del
|
|
40834
|
-
};
|
|
40835
|
-
|
|
40836
|
-
/***/
|
|
40837
|
-
}
|
|
40838
|
-
/******/])
|
|
40839
|
-
);
|
|
40840
|
-
});
|
|
40841
|
-
} (hubble));
|
|
40842
|
-
|
|
40843
|
-
var lens = /*@__PURE__*/getDefaultExportFromCjs(hubble.exports);
|
|
40591
|
+
var isObject = function (obj) {
|
|
40592
|
+
return obj === Object(obj);
|
|
40593
|
+
};
|
|
40594
|
+
var merge = function () {
|
|
40595
|
+
var obj = {};
|
|
40596
|
+
for (var i = 0; i < arguments.length; i++) {
|
|
40597
|
+
var source = arguments[i];
|
|
40598
|
+
if (source) {
|
|
40599
|
+
for (var prop in source) {
|
|
40600
|
+
obj[prop] = source[prop];
|
|
40601
|
+
}
|
|
40602
|
+
}
|
|
40603
|
+
}
|
|
40604
|
+
return obj;
|
|
40605
|
+
};
|
|
40606
|
+
var clone = function (obj) {
|
|
40607
|
+
if (!isObject(obj)) {
|
|
40608
|
+
return obj;
|
|
40609
|
+
}
|
|
40610
|
+
return Array.isArray(obj) ? obj.slice() : merge(obj);
|
|
40611
|
+
};
|
|
40612
|
+
|
|
40613
|
+
/* TODO batch *all* mutations
|
|
40614
|
+
* idea: freeze / thaw implementations for all types
|
|
40615
|
+
* lens constructor thaws, freeze delegates to type's freeze
|
|
40616
|
+
*/
|
|
40617
|
+
|
|
40618
|
+
// equivalents, without requiring it
|
|
40619
|
+
// find the implementation to use for a given object
|
|
40620
|
+
var dispatch = function (x) {
|
|
40621
|
+
if (Array.isArray(x)) {
|
|
40622
|
+
return arr;
|
|
40623
|
+
} else if (isObject(x)) {
|
|
40624
|
+
return obj;
|
|
40625
|
+
} else if (typeof x === "string") {
|
|
40626
|
+
return str;
|
|
40627
|
+
}
|
|
40628
|
+
};
|
|
40629
|
+
|
|
40630
|
+
// This is underscore with a different name
|
|
40631
|
+
var lens = function (obj) {
|
|
40632
|
+
if (obj instanceof lens) {
|
|
40633
|
+
return obj;
|
|
40634
|
+
}
|
|
40635
|
+
if (!(this instanceof lens)) {
|
|
40636
|
+
return new lens(obj);
|
|
40637
|
+
}
|
|
40638
|
+
var ops = dispatch(obj);
|
|
40639
|
+
this._wrapped = ops.thaw ? ops.thaw(obj) : obj;
|
|
40640
|
+
};
|
|
40641
|
+
lens.prototype.freeze = function () {
|
|
40642
|
+
var obj = this._wrapped;
|
|
40643
|
+
var ops = dispatch(obj);
|
|
40644
|
+
return ops.freeze ? ops.freeze(obj) : obj;
|
|
40645
|
+
};
|
|
40646
|
+
lens.prototype.zoom = function (lensArr) {
|
|
40647
|
+
if (this._zoomStack === undefined) {
|
|
40648
|
+
this._zoomStack = [];
|
|
40649
|
+
}
|
|
40650
|
+
this._zoomStack.push({
|
|
40651
|
+
zoom: lensArr,
|
|
40652
|
+
wrapped: this._wrapped
|
|
40653
|
+
});
|
|
40654
|
+
this._wrapped = lens(this._wrapped).get(lensArr);
|
|
40655
|
+
return this;
|
|
40656
|
+
};
|
|
40657
|
+
lens.prototype.deZoom = function () {
|
|
40658
|
+
var frame = this._zoomStack.pop();
|
|
40659
|
+
this._wrapped = lens(frame.wrapped).set(frame.zoom, this._wrapped).freeze();
|
|
40660
|
+
return this;
|
|
40661
|
+
};
|
|
40662
|
+
lens.prototype.get = function (lensArr) {
|
|
40663
|
+
var obj = this._wrapped;
|
|
40664
|
+
for (var i = 0; i < lensArr.length; i++) {
|
|
40665
|
+
obj = dispatch(obj).get(obj, lensArr[i]);
|
|
40666
|
+
}
|
|
40667
|
+
return obj;
|
|
40668
|
+
};
|
|
40669
|
+
lens.prototype.mod = function (lensArr, f) {
|
|
40670
|
+
var obj = this._wrapped;
|
|
40671
|
+
var newObj = clone(obj);
|
|
40672
|
+
var ops = dispatch(obj);
|
|
40673
|
+
if (lensArr.length === 0) {
|
|
40674
|
+
this._wrapped = f(this._wrapped);
|
|
40675
|
+
} else if (lensArr.length === 1) {
|
|
40676
|
+
this._wrapped = ops.mod(newObj, lensArr[0], f);
|
|
40677
|
+
} else {
|
|
40678
|
+
var monocle = lensArr[0];
|
|
40679
|
+
var shortLens = lensArr.slice(1);
|
|
40680
|
+
|
|
40681
|
+
// newObj = ops.mod(obj[monocle], shortLens, f);
|
|
40682
|
+
|
|
40683
|
+
newObj[monocle] = lens(obj[monocle]).mod(shortLens, f).freeze();
|
|
40684
|
+
this._wrapped = newObj;
|
|
40685
|
+
}
|
|
40686
|
+
return this;
|
|
40687
|
+
};
|
|
40688
|
+
|
|
40689
|
+
// TODO - move to individual files
|
|
40690
|
+
lens.prototype.merge = function (lensArr, props) {
|
|
40691
|
+
this._wrapped = lens(this._wrapped).mod(lensArr, function (oldProps) {
|
|
40692
|
+
return merge(oldProps, props);
|
|
40693
|
+
}).freeze();
|
|
40694
|
+
return this;
|
|
40695
|
+
};
|
|
40696
|
+
|
|
40697
|
+
// Lens must have length >= 1 or there would be nothing to return
|
|
40698
|
+
lens.prototype.del = function (lensArr) {
|
|
40699
|
+
var obj = this._wrapped;
|
|
40700
|
+
var ops = dispatch(obj);
|
|
40701
|
+
if (lensArr.length === 1) {
|
|
40702
|
+
this._wrapped = ops.del(obj, lensArr[0]);
|
|
40703
|
+
} else {
|
|
40704
|
+
var monocle = lensArr[0];
|
|
40705
|
+
var shortLens = lensArr.slice(1);
|
|
40706
|
+
var newObj = clone(obj);
|
|
40707
|
+
newObj[monocle] = lens(obj[monocle]).del(shortLens).freeze();
|
|
40708
|
+
this._wrapped = newObj;
|
|
40709
|
+
}
|
|
40710
|
+
return this;
|
|
40711
|
+
};
|
|
40712
|
+
lens.prototype.set = function (lensArr, set) {
|
|
40713
|
+
return this.mod(lensArr, function () {
|
|
40714
|
+
return set;
|
|
40715
|
+
});
|
|
40716
|
+
};
|
|
40717
|
+
|
|
40718
|
+
// ARRAY FUNCTIONS
|
|
40719
|
+
|
|
40720
|
+
const arr = {
|
|
40721
|
+
get: function (arr, monocle) {
|
|
40722
|
+
return arr[monocle];
|
|
40723
|
+
},
|
|
40724
|
+
set: function (arr, monocle, val) {
|
|
40725
|
+
var newArr = arr.splice();
|
|
40726
|
+
newArr[monocle] = val;
|
|
40727
|
+
return newArr;
|
|
40728
|
+
},
|
|
40729
|
+
mod: function (arr, monocle, f) {
|
|
40730
|
+
var newArr = arr.slice();
|
|
40731
|
+
newArr[monocle] = f(arr[monocle]);
|
|
40732
|
+
return newArr;
|
|
40733
|
+
},
|
|
40734
|
+
del: function (arr, monocle) {
|
|
40735
|
+
var newArr = arr.slice();
|
|
40736
|
+
newArr.splice(monocle, 1);
|
|
40737
|
+
return newArr;
|
|
40738
|
+
}
|
|
40739
|
+
};
|
|
40740
|
+
|
|
40741
|
+
/*
|
|
40742
|
+
// Lens must point to a member of an array. We'll insert into that array.
|
|
40743
|
+
lens.prototype.insertAt = function(lensArr, toInsert) {
|
|
40744
|
+
var obj = this._wrapped;
|
|
40745
|
+
|
|
40746
|
+
var arrLens = lensArr.slice(0, -1);
|
|
40747
|
+
var arr = lens(obj).get(arrLens).slice(); // slice to copy
|
|
40748
|
+
|
|
40749
|
+
var arrIdx = lensArr[lensArr.length-1];
|
|
40750
|
+
arr.splice(arrIdx, 0, toInsert);
|
|
40751
|
+
return lens(obj).set(arrLens, arr);
|
|
40752
|
+
};
|
|
40753
|
+
|
|
40754
|
+
lens.prototype.insertBefore = lens.prototype.insertAt;
|
|
40755
|
+
lens.prototype.insertAfter = function(lensArr, toInsert) {
|
|
40756
|
+
var newLens = lensArr.slice();
|
|
40757
|
+
newLens[newLens.length-1] += 1;
|
|
40758
|
+
return lens(this._wrapped).insertAt(newLens, toInsert);
|
|
40759
|
+
};
|
|
40760
|
+
*/
|
|
40761
|
+
|
|
40762
|
+
// OBJECT FUNCTIONS
|
|
40763
|
+
|
|
40764
|
+
const obj = {
|
|
40765
|
+
get: function (obj, monocle) {
|
|
40766
|
+
return obj[monocle];
|
|
40767
|
+
},
|
|
40768
|
+
set: function (obj, monocle, val) {
|
|
40769
|
+
var newObj = clone(obj);
|
|
40770
|
+
newObj[monocle] = val;
|
|
40771
|
+
return newObj;
|
|
40772
|
+
},
|
|
40773
|
+
mod: function (obj, monocle, f) {
|
|
40774
|
+
var newObj = clone(obj);
|
|
40775
|
+
newObj[monocle] = f(obj[monocle]);
|
|
40776
|
+
return newObj;
|
|
40777
|
+
},
|
|
40778
|
+
del: function (obj, monocle) {
|
|
40779
|
+
var newObj = clone(obj);
|
|
40780
|
+
delete newObj[monocle];
|
|
40781
|
+
return newObj;
|
|
40782
|
+
}
|
|
40783
|
+
};
|
|
40784
|
+
|
|
40785
|
+
// STRING FUNCTIONS
|
|
40786
|
+
|
|
40787
|
+
const str = {
|
|
40788
|
+
get: function (arr, monocle) {
|
|
40789
|
+
return arr[monocle];
|
|
40790
|
+
},
|
|
40791
|
+
set: function (arr, monocle, val) {
|
|
40792
|
+
var newArr = arr.splice();
|
|
40793
|
+
newArr[monocle] = val;
|
|
40794
|
+
return newArr;
|
|
40795
|
+
},
|
|
40796
|
+
mod: function (arr, monocle, f) {
|
|
40797
|
+
var newArr = arr.splice();
|
|
40798
|
+
newArr[monocle] = f(arr[monocle]);
|
|
40799
|
+
return newArr;
|
|
40800
|
+
},
|
|
40801
|
+
del: function (arr, monocle) {
|
|
40802
|
+
var newArr = arr.slice();
|
|
40803
|
+
newArr.splice(monocle);
|
|
40804
|
+
return newArr;
|
|
40805
|
+
}
|
|
40806
|
+
};
|
|
40844
40807
|
|
|
40845
40808
|
/* eslint-disable eqeqeq, @typescript-eslint/no-unused-vars */
|
|
40846
40809
|
/*
|
|
@@ -41746,7 +41709,7 @@ const init = function (options) {
|
|
|
41746
41709
|
|
|
41747
41710
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
41748
41711
|
const libName = "@khanacademy/perseus";
|
|
41749
|
-
const libVersion = "19.1.
|
|
41712
|
+
const libVersion = "19.1.8";
|
|
41750
41713
|
perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
41751
41714
|
|
|
41752
41715
|
const apiVersion = {
|