@khanacademy/perseus 20.0.0 → 20.0.2

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/index.js CHANGED
@@ -29,7 +29,7 @@ var Button = require('@khanacademy/wonder-blocks-button');
29
29
  var wonderBlocksLayout = require('@khanacademy/wonder-blocks-layout');
30
30
  var Banner = require('@khanacademy/wonder-blocks-banner');
31
31
  var wonderBlocksDropdown = require('@khanacademy/wonder-blocks-dropdown');
32
- var debounce = require('lodash.debounce');
32
+ var debounce$1 = require('lodash.debounce');
33
33
  var mafs = require('mafs');
34
34
  var createReactClass = require('create-react-class');
35
35
  var Switch = require('@khanacademy/wonder-blocks-switch');
@@ -77,7 +77,7 @@ var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
77
77
  var SimpleMarkdown__default = /*#__PURE__*/_interopDefaultLegacy(SimpleMarkdown);
78
78
  var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
79
79
  var Banner__default = /*#__PURE__*/_interopDefaultLegacy(Banner);
80
- var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
80
+ var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce$1);
81
81
  var createReactClass__default = /*#__PURE__*/_interopDefaultLegacy(createReactClass);
82
82
  var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
83
83
  var Pill__default = /*#__PURE__*/_interopDefaultLegacy(Pill);
@@ -98,6 +98,21 @@ function _extends() {
98
98
  return _extends.apply(this, arguments);
99
99
  }
100
100
 
101
+ const debounce = (func, delay) => {
102
+ let timer = null;
103
+ return function () {
104
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
105
+ args[_key] = arguments[_key];
106
+ }
107
+ if (timer) {
108
+ clearTimeout(timer);
109
+ }
110
+ timer = window.setTimeout(() => {
111
+ func(...args);
112
+ }, delay);
113
+ };
114
+ };
115
+
101
116
  const customKeyTranslator = {
102
117
  ...mathInput.keyTranslator,
103
118
  // If there's something in the input that can become part of a
@@ -173,7 +188,7 @@ class MathInput extends React__namespace.Component {
173
188
  this.__mathField = mathInput.createMathField(this.__mathFieldWrapperRef, baseConfig => ({
174
189
  ...baseConfig,
175
190
  handlers: {
176
- edit: mathField => {
191
+ edit: debounce(mathField => {
177
192
  // This handler is guaranteed to be called on change, but
178
193
  // unlike React it sometimes generates false positives.
179
194
  // One of these is on initialization (with an empty string
@@ -209,7 +224,7 @@ class MathInput extends React__namespace.Component {
209
224
  this.setState({
210
225
  cursorContext: mathInput.getCursorContext(mathField)
211
226
  });
212
- },
227
+ }, 100),
213
228
  enter: () => {
214
229
  // NOTE(kevinb): This isn't how answers to exercises are
215
230
  // submitted. The actual mechanism for this can be found
@@ -41296,7 +41311,7 @@ const init = function (options) {
41296
41311
 
41297
41312
  // This file is processed by a Rollup plugin (replace) to inject the production
41298
41313
  const libName = "@khanacademy/perseus";
41299
- const libVersion = "20.0.0";
41314
+ const libVersion = "20.0.2";
41300
41315
  perseusCore.addLibraryVersionToPerseusDebug(libName, libVersion);
41301
41316
 
41302
41317
  const apiVersion = {