@enact/core 4.7.0 → 4.7.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  The following is a curated list of changes in the Enact core module, newest changes on the top.
4
4
 
5
+ ## [4.7.1] - 2023-06-02
6
+
7
+ No significant changes.
8
+
9
+ ## [4.5.3] - 2023-04-06
10
+
11
+ No significant changes.
12
+
5
13
  ## [4.7.0] - 2023-04-25
6
14
 
7
15
  ### Deprecated
package/README.md CHANGED
@@ -14,7 +14,7 @@ npm install --save @enact/core
14
14
 
15
15
  ## Test
16
16
 
17
- Tests are implemented in mocha and are run with the Karma runner.
17
+ Unit tests are implemented in Testing Library and are run with Jest. To execute them:
18
18
 
19
19
  ```
20
20
  npm test
@@ -7,6 +7,8 @@ var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
7
7
  var _Registry = _interopRequireDefault(require("../Registry"));
8
8
  var _jsxRuntime = require("react/jsx-runtime");
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
10
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
13
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
14
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -116,19 +118,21 @@ describe('Registry', function () {
116
118
  return HandlesNotification;
117
119
  }(_react.Component);
118
120
  HandlesNotification.contextType = SomeContext;
119
- test('should increment child on click', function () {
121
+ test('should increment child on click', /*#__PURE__*/_asyncToGenerator(function* () {
122
+ var user = _userEvent["default"].setup();
120
123
  (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
121
124
  "data-testid": "a-btn",
122
125
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
123
126
  "data-testid": "a"
124
127
  })
125
128
  }));
126
- _userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
129
+ yield user.click(_react2.screen.getByTestId('a-btn'));
127
130
  var expected = '1';
128
131
  var child = _react2.screen.getByTestId('a');
129
132
  expect(child).toHaveTextContent(expected);
130
- });
131
- test('should increment both children on top click', function () {
133
+ }));
134
+ test('should increment both children on top click', /*#__PURE__*/_asyncToGenerator(function* () {
135
+ var user = _userEvent["default"].setup();
132
136
  (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
133
137
  "data-testid": "a-btn",
134
138
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
@@ -140,14 +144,15 @@ describe('Registry', function () {
140
144
  })
141
145
  })]
142
146
  }));
143
- _userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
147
+ yield user.click(_react2.screen.getByTestId('a-btn'));
144
148
  var expected = '1';
145
149
  var childA = _react2.screen.getByTestId('a');
146
150
  var childB = _react2.screen.getByTestId('b');
147
151
  expect(childA).toHaveTextContent(expected);
148
152
  expect(childB).toHaveTextContent(expected);
149
- });
150
- test('should increment the deepest child when we click child button', function () {
153
+ }));
154
+ test('should increment the deepest child when we click child button', /*#__PURE__*/_asyncToGenerator(function* () {
155
+ var user = _userEvent["default"].setup();
151
156
  (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
152
157
  "data-testid": "a-btn",
153
158
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
@@ -159,15 +164,16 @@ describe('Registry', function () {
159
164
  })
160
165
  })]
161
166
  }));
162
- _userEvent["default"].click(_react2.screen.getByTestId('b-btn'));
167
+ yield user.click(_react2.screen.getByTestId('b-btn'));
163
168
  var expectedA = '0';
164
169
  var expectedB = '1';
165
170
  var childA = _react2.screen.getByTestId('a');
166
171
  var childB = _react2.screen.getByTestId('b');
167
172
  expect(childA).toHaveTextContent(expectedA);
168
173
  expect(childB).toHaveTextContent(expectedB);
169
- });
170
- test('should support removing children without error', function () {
174
+ }));
175
+ test('should support removing children without error', /*#__PURE__*/_asyncToGenerator(function* () {
176
+ var user = _userEvent["default"].setup();
171
177
  var _render = (0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsxs)(NotifiesTree, {
172
178
  "data-testid": "a-btn",
173
179
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(HandlesNotification, {
@@ -177,7 +183,7 @@ describe('Registry', function () {
177
183
  })]
178
184
  })),
179
185
  rerender = _render.rerender;
180
- _userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
186
+ yield user.click(_react2.screen.getByTestId('a-btn'));
181
187
 
182
188
  // changing children should be safe and not throw errors when notifying instances
183
189
  rerender( /*#__PURE__*/(0, _jsxRuntime.jsx)(NotifiesTree, {
@@ -186,9 +192,9 @@ describe('Registry', function () {
186
192
  "data-testid": "c"
187
193
  })
188
194
  }));
189
- _userEvent["default"].click(_react2.screen.getByTestId('a-btn'));
195
+ yield user.click(_react2.screen.getByTestId('a-btn'));
190
196
  var expectedC = '1';
191
197
  var childC = _react2.screen.getByTestId('c');
192
198
  expect(childC).toHaveTextContent(expectedC);
193
- });
199
+ }));
194
200
  });
@@ -15,6 +15,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
15
15
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
16
16
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
19
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
18
20
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
21
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
22
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -119,18 +121,19 @@ describe('kind', function () {
119
121
  var kindDiv = _react.screen.getByTitle('Label');
120
122
  expect(kindDiv).toHaveTextContent(expected);
121
123
  });
122
- test('should support contextType in handlers', function () {
124
+ test('should support contextType in handlers', /*#__PURE__*/_asyncToGenerator(function* () {
123
125
  var onClick = jest.fn();
126
+ var user = _userEvent["default"].setup();
124
127
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
125
128
  onClick: onClick,
126
129
  prop: 1
127
130
  }));
128
131
  var kindDiv = _react.screen.getByTitle('Label');
129
- _userEvent["default"].click(kindDiv);
132
+ yield user.click(kindDiv);
130
133
  var expected = 'initial';
131
134
  var actual = onClick.mock.calls[0][0];
132
135
  expect(actual).toBe(expected);
133
- });
136
+ }));
134
137
  test('should support contextType in computed', function () {
135
138
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Kind, {
136
139
  prop: 1
@@ -139,7 +142,8 @@ describe('kind', function () {
139
142
  var kindDiv = _react.screen.getByTitle('Label');
140
143
  expect(kindDiv).toHaveAttribute('data-context', expected);
141
144
  });
142
- test('support using hooks within kind instances', function () {
145
+ test('support using hooks within kind instances', /*#__PURE__*/_asyncToGenerator(function* () {
146
+ var user = _userEvent["default"].setup();
143
147
  var Comp = (0, _kind["default"])({
144
148
  name: 'Comp',
145
149
  functional: true,
@@ -160,10 +164,10 @@ describe('kind', function () {
160
164
  });
161
165
  (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(Comp, {}));
162
166
  var button = _react.screen.getByTestId('button');
163
- _userEvent["default"].click(button);
167
+ yield user.click(button);
164
168
  var expected = '1';
165
169
  expect(button).toHaveTextContent(expected);
166
- });
170
+ }));
167
171
  describe('inline', function () {
168
172
  test('should support a minimal kind', function () {
169
173
  var Minimal = (0, _kind["default"])({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enact/core",
3
- "version": "4.7.0",
3
+ "version": "4.7.1",
4
4
  "description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,7 +34,7 @@
34
34
  "classnames": "^2.3.2",
35
35
  "invariant": "^2.2.4",
36
36
  "prop-types": "^15.8.1",
37
- "ramda": "^0.28.0",
37
+ "ramda": "^0.29.0",
38
38
  "react": "^18.2.0",
39
39
  "react-dom": "^18.2.0",
40
40
  "react-is": "^18.2.0",
package/util/Job.js CHANGED
@@ -33,126 +33,6 @@ var Job = /*#__PURE__*/function () {
33
33
  this.fn = null;
34
34
  this.timeout = null;
35
35
  this.type = null;
36
- this.start = function () {
37
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
38
- args[_key] = arguments[_key];
39
- }
40
- _this.startAfter.apply(_this, [_this.timeout].concat(args));
41
- };
42
- this.startAfter = function (timeout) {
43
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
44
- args[_key2 - 1] = arguments[_key2];
45
- }
46
- _this.stop();
47
- _this.type = 'timeout';
48
- _this.id = setTimeout(function () {
49
- return _this.run(args);
50
- }, timeout);
51
- };
52
- this.stop = function () {
53
- if (_this.id) {
54
- if (_this.type === 'idle') {
55
- window.cancelIdleCallback(_this.id);
56
- } else if (_this.type === 'raf') {
57
- window.cancelAnimationFrame(_this.id);
58
- } else if (_this.type === 'timeout') {
59
- clearTimeout(_this.id);
60
- }
61
- _this.id = _this.type = null;
62
- }
63
- };
64
- this.throttle = function () {
65
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
66
- args[_key3] = arguments[_key3];
67
- }
68
- _this.throttleUntil.apply(_this, [_this.timeout].concat(args));
69
- };
70
- this.throttleUntil = function (timeout) {
71
- if (!_this.id) {
72
- _this.type = 'timeout';
73
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
74
- args[_key4 - 1] = arguments[_key4];
75
- }
76
- _this.run(args);
77
- _this.id = setTimeout(_this.stop, timeout);
78
- }
79
- };
80
- this.idle = function () {
81
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
82
- args[_key5] = arguments[_key5];
83
- }
84
- _this.idleUntil.apply(_this, [null].concat(args));
85
- };
86
- this.idleUntil = function (timeout) {
87
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
88
- args[_key6 - 1] = arguments[_key6];
89
- }
90
- if (typeof window !== 'undefined' && window.requestIdleCallback) {
91
- _this.stop();
92
- _this.type = 'idle';
93
- _this.id = window.requestIdleCallback(function () {
94
- return _this.run(args);
95
- }, {
96
- timeout: timeout
97
- });
98
- } else {
99
- // since we can't request an idle callback, just pass to startAfter()
100
- _this.startAfter.apply(_this, [timeout].concat(args));
101
- }
102
- };
103
- this.startRaf = function () {
104
- for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
105
- args[_key7] = arguments[_key7];
106
- }
107
- _this.startRafAfter.apply(_this, [_this.timeout].concat(args));
108
- };
109
- this.startRafAfter = function (timeout) {
110
- for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
111
- args[_key8 - 1] = arguments[_key8];
112
- }
113
- _this.type = 'raf';
114
- if (typeof window !== 'undefined') {
115
- var time = null;
116
- var callback = function callback(timestamp) {
117
- if (time === null) {
118
- time = timestamp;
119
- }
120
- if (timeout && timestamp - time < timeout) {
121
- _this.id = window.requestAnimationFrame(callback);
122
- } else {
123
- time = null;
124
- _this.run(args);
125
- window.cancelAnimationFrame(_this.id);
126
- _this.id = null;
127
- }
128
- };
129
- _this.id = window.requestAnimationFrame(callback);
130
- } else {
131
- // If requestAnimationFrame is not supported just run the function immediately
132
- _this.run(args);
133
- }
134
- };
135
- this.promise = function (promise) {
136
- !(promise && typeof promise.then === 'function') ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'promise expects a thenable') : (0, _invariant["default"])(false) : void 0;
137
- _this.type = 'promise';
138
- _this.id = promise;
139
- return promise.then(function (result) {
140
- if (_this.id === promise) {
141
- _this.stop();
142
- return _this.run([result]);
143
- }
144
- });
145
- };
146
- this.fn = fn;
147
- this.timeout = _timeout;
148
- }
149
- _createClass(Job, [{
150
- key: "run",
151
- value: function run(args) {
152
- // don't want to inadvertently apply Job's context on `fn`
153
- return this.fn.apply(null, args);
154
- }
155
-
156
36
  /**
157
37
  * Starts the job.
158
38
  *
@@ -163,7 +43,12 @@ var Job = /*#__PURE__*/function () {
163
43
  * @memberof core/util.Job.prototype
164
44
  * @public
165
45
  */
166
-
46
+ this.start = function () {
47
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
48
+ args[_key] = arguments[_key];
49
+ }
50
+ _this.startAfter.apply(_this, [_this.timeout].concat(args));
51
+ };
167
52
  /**
168
53
  * Starts the job in `timeout` milliseconds
169
54
  *
@@ -176,7 +61,16 @@ var Job = /*#__PURE__*/function () {
176
61
  * @memberof core/util.Job.prototype
177
62
  * @public
178
63
  */
179
-
64
+ this.startAfter = function (timeout) {
65
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
66
+ args[_key2 - 1] = arguments[_key2];
67
+ }
68
+ _this.stop();
69
+ _this.type = 'timeout';
70
+ _this.id = setTimeout(function () {
71
+ return _this.run(args);
72
+ }, timeout);
73
+ };
180
74
  /**
181
75
  * Stops the job.
182
76
  *
@@ -186,7 +80,18 @@ var Job = /*#__PURE__*/function () {
186
80
  * @memberof core/util.Job.prototype
187
81
  * @public
188
82
  */
189
-
83
+ this.stop = function () {
84
+ if (_this.id) {
85
+ if (_this.type === 'idle') {
86
+ window.cancelIdleCallback(_this.id);
87
+ } else if (_this.type === 'raf') {
88
+ window.cancelAnimationFrame(_this.id);
89
+ } else if (_this.type === 'timeout') {
90
+ clearTimeout(_this.id);
91
+ }
92
+ _this.id = _this.type = null;
93
+ }
94
+ };
190
95
  /**
191
96
  * Executes the job immediately, then prevents any other calls to `throttle()` from running
192
97
  * until the `timeout` configured at construction passes.
@@ -198,7 +103,12 @@ var Job = /*#__PURE__*/function () {
198
103
  * @memberof core/util.Job.prototype
199
104
  * @public
200
105
  */
201
-
106
+ this.throttle = function () {
107
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
108
+ args[_key3] = arguments[_key3];
109
+ }
110
+ _this.throttleUntil.apply(_this, [_this.timeout].concat(args));
111
+ };
202
112
  /**
203
113
  * Executes the job immediately, then prevents any other calls to `throttle()` from running for
204
114
  * `timeout` milliseconds.
@@ -212,7 +122,16 @@ var Job = /*#__PURE__*/function () {
212
122
  * @memberof core/util.Job.prototype
213
123
  * @public
214
124
  */
215
-
125
+ this.throttleUntil = function (timeout) {
126
+ if (!_this.id) {
127
+ _this.type = 'timeout';
128
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
129
+ args[_key4 - 1] = arguments[_key4];
130
+ }
131
+ _this.run(args);
132
+ _this.id = setTimeout(_this.stop, timeout);
133
+ }
134
+ };
216
135
  /**
217
136
  * Executes job when the CPU is idle.
218
137
  *
@@ -223,7 +142,12 @@ var Job = /*#__PURE__*/function () {
223
142
  * @memberof core/util.Job.prototype
224
143
  * @public
225
144
  */
226
-
145
+ this.idle = function () {
146
+ for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
147
+ args[_key5] = arguments[_key5];
148
+ }
149
+ _this.idleUntil.apply(_this, [null].concat(args));
150
+ };
227
151
  /**
228
152
  * Executes job when the CPU is idle, or when the timeout is reached, whichever occurs first.
229
153
  *
@@ -237,7 +161,23 @@ var Job = /*#__PURE__*/function () {
237
161
  * @memberof core/util.Job.prototype
238
162
  * @public
239
163
  */
240
-
164
+ this.idleUntil = function (timeout) {
165
+ for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
166
+ args[_key6 - 1] = arguments[_key6];
167
+ }
168
+ if (typeof window !== 'undefined' && window.requestIdleCallback) {
169
+ _this.stop();
170
+ _this.type = 'idle';
171
+ _this.id = window.requestIdleCallback(function () {
172
+ return _this.run(args);
173
+ }, {
174
+ timeout: timeout
175
+ });
176
+ } else {
177
+ // since we can't request an idle callback, just pass to startAfter()
178
+ _this.startAfter.apply(_this, [timeout].concat(args));
179
+ }
180
+ };
241
181
  /**
242
182
  * Executes job before the next repaint.
243
183
  *
@@ -248,7 +188,12 @@ var Job = /*#__PURE__*/function () {
248
188
  * @memberof core/util.Job.prototype
249
189
  * @public
250
190
  */
251
-
191
+ this.startRaf = function () {
192
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
193
+ args[_key7] = arguments[_key7];
194
+ }
195
+ _this.startRafAfter.apply(_this, [_this.timeout].concat(args));
196
+ };
252
197
  /**
253
198
  * Executes job before the next repaint after a given amount of timeout.
254
199
  *
@@ -260,7 +205,32 @@ var Job = /*#__PURE__*/function () {
260
205
  * @memberof core/util.Job.prototype
261
206
  * @public
262
207
  */
263
-
208
+ this.startRafAfter = function (timeout) {
209
+ for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
210
+ args[_key8 - 1] = arguments[_key8];
211
+ }
212
+ _this.type = 'raf';
213
+ if (typeof window !== 'undefined') {
214
+ var time = null;
215
+ var callback = function callback(timestamp) {
216
+ if (time === null) {
217
+ time = timestamp;
218
+ }
219
+ if (timeout && timestamp - time < timeout) {
220
+ _this.id = window.requestAnimationFrame(callback);
221
+ } else {
222
+ time = null;
223
+ _this.run(args);
224
+ window.cancelAnimationFrame(_this.id);
225
+ _this.id = null;
226
+ }
227
+ };
228
+ _this.id = window.requestAnimationFrame(callback);
229
+ } else {
230
+ // If requestAnimationFrame is not supported just run the function immediately
231
+ _this.run(args);
232
+ }
233
+ };
264
234
  /**
265
235
  * Starts the job when `promise` resolves.
266
236
  *
@@ -281,6 +251,26 @@ var Job = /*#__PURE__*/function () {
281
251
  * @memberof core/util.Job.prototype
282
252
  * @public
283
253
  */
254
+ this.promise = function (promise) {
255
+ !(promise && typeof promise.then === 'function') ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'promise expects a thenable') : (0, _invariant["default"])(false) : void 0;
256
+ _this.type = 'promise';
257
+ _this.id = promise;
258
+ return promise.then(function (result) {
259
+ if (_this.id === promise) {
260
+ _this.stop();
261
+ return _this.run([result]);
262
+ }
263
+ });
264
+ };
265
+ this.fn = fn;
266
+ this.timeout = _timeout;
267
+ }
268
+ _createClass(Job, [{
269
+ key: "run",
270
+ value: function run(args) {
271
+ // don't want to inadvertently apply Job's context on `fn`
272
+ return this.fn.apply(null, args);
273
+ }
284
274
  }]);
285
275
  return Job;
286
276
  }();