@enact/core 3.4.9-experimental-3 → 3.4.9-experimental-7
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 +16 -0
- package/{build/dispatcher → dispatcher}/dispatcher.d.ts +0 -0
- package/dispatcher/dispatcher.js +76 -57
- package/dispatcher/listeners.js +31 -19
- package/dispatcher/tests/dispatcher-specs.js +75 -100
- package/{build/handle → handle}/handle.d.ts +0 -0
- package/handle/handle.js +260 -212
- package/handle/tests/handle-specs.js +476 -601
- package/{build/hoc → hoc}/hoc.d.ts +0 -0
- package/hoc/hoc.js +47 -33
- package/hoc/tests/hoc-specs.js +85 -126
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/index.js +1 -0
- package/{build/internal → internal}/ApiDecorator/ApiDecorator.d.ts +0 -0
- package/internal/ApiDecorator/ApiDecorator.js +107 -61
- package/internal/ApiDecorator/tests/ApiDecorator-specs.js +106 -97
- package/{build/internal → internal}/Registry/Registry.d.ts +0 -0
- package/internal/Registry/Registry.js +68 -51
- package/internal/Registry/tests/Registry-specs.js +201 -143
- package/{build/internal → internal}/deprecate/deprecate.d.ts +0 -0
- package/internal/deprecate/deprecate.js +85 -60
- package/{build/internal → internal}/prop-types/prop-types.d.ts +0 -0
- package/internal/prop-types/prop-types.js +68 -61
- package/{build/keymap → keymap}/index.d.ts +0 -0
- package/keymap/index.js +27 -15
- package/keymap/keymap.js +67 -52
- package/keymap/tests/keymap-specs.js +75 -104
- package/kind/computed.js +29 -16
- package/{build/kind → kind}/kind.d.ts +0 -0
- package/kind/kind.js +150 -114
- package/kind/styles.js +62 -47
- package/kind/tests/computed-specs.js +87 -86
- package/kind/tests/kind-specs.js +216 -214
- package/kind/tests/styles-specs.js +170 -223
- package/kind/util.js +15 -7
- package/package.json +1 -1
- package/{build/platform → platform}/platform.d.ts +0 -0
- package/platform/platform.js +263 -169
- package/platform/tests/platform-specs.js +92 -90
- package/{build/snapshot → snapshot}/snapshot.d.ts +0 -0
- package/snapshot/snapshot.js +34 -27
- package/useChainRefs/tests/useChainRefs-specs.js +46 -30
- package/{build/useChainRefs → useChainRefs}/useChainRefs.d.ts +0 -0
- package/useChainRefs/useChainRefs.js +49 -29
- package/useClass/tests/useClass-specs.js +51 -46
- package/{build/useClass → useClass}/useClass.d.ts +0 -0
- package/useClass/useClass.js +27 -9
- package/useHandlers/Handlers.js +55 -30
- package/useHandlers/tests/useHandlers-specs.js +79 -95
- package/{build/useHandlers → useHandlers}/useHandlers.d.ts +0 -0
- package/useHandlers/useHandlers.js +18 -11
- package/util/Job.js +203 -241
- package/util/tests/Job-specs.js +216 -204
- package/util/tests/util-specs.js +123 -146
- package/{build/util → util}/util.d.ts +0 -0
- package/util/util.js +146 -103
- package/build/CHANGELOG.md +0 -699
- package/build/README.md +0 -33
- package/build/dispatcher/dispatcher.js +0 -160
- package/build/dispatcher/listeners.js +0 -37
- package/build/dispatcher/package.json +0 -3
- package/build/dispatcher/tests/dispatcher-specs.js +0 -75
- package/build/handle/handle.js +0 -846
- package/build/handle/package.json +0 -3
- package/build/handle/tests/handle-specs.js +0 -476
- package/build/hoc/hoc.js +0 -102
- package/build/hoc/package.json +0 -3
- package/build/hoc/tests/hoc-specs.js +0 -90
- package/build/index.js +0 -2
- package/build/internal/ApiDecorator/ApiDecorator.js +0 -143
- package/build/internal/ApiDecorator/package.json +0 -3
- package/build/internal/ApiDecorator/tests/ApiDecorator-specs.js +0 -106
- package/build/internal/Registry/Registry.js +0 -76
- package/build/internal/Registry/package.json +0 -3
- package/build/internal/Registry/tests/Registry-specs.js +0 -201
- package/build/internal/deprecate/deprecate.js +0 -116
- package/build/internal/deprecate/package.json +0 -3
- package/build/internal/prop-types/package.json +0 -3
- package/build/internal/prop-types/prop-types.js +0 -90
- package/build/keymap/index.js +0 -54
- package/build/keymap/keymap.js +0 -201
- package/build/keymap/package.json +0 -3
- package/build/keymap/tests/keymap-specs.js +0 -75
- package/build/kind/computed.js +0 -60
- package/build/kind/kind.js +0 -266
- package/build/kind/package.json +0 -3
- package/build/kind/styles.js +0 -105
- package/build/kind/tests/computed-specs.js +0 -87
- package/build/kind/tests/kind-specs.js +0 -216
- package/build/kind/tests/styles-specs.js +0 -170
- package/build/kind/util.js +0 -17
- package/build/package-lock.json +0 -206
- package/build/package.json +0 -38
- package/build/platform/package.json +0 -3
- package/build/platform/platform.js +0 -306
- package/build/platform/tests/platform-specs.js +0 -92
- package/build/snapshot/package.json +0 -3
- package/build/snapshot/snapshot.js +0 -89
- package/build/useChainRefs/package.json +0 -3
- package/build/useChainRefs/tests/useChainRefs-specs.js +0 -57
- package/build/useChainRefs/useChainRefs.js +0 -78
- package/build/useClass/package.json +0 -3
- package/build/useClass/tests/useClass-specs.js +0 -51
- package/build/useClass/useClass.js +0 -59
- package/build/useHandlers/Handlers.js +0 -55
- package/build/useHandlers/package.json +0 -3
- package/build/useHandlers/tests/useHandlers-specs.js +0 -84
- package/build/useHandlers/useHandlers.js +0 -36
- package/build/util/Job.js +0 -211
- package/build/util/package.json +0 -3
- package/build/util/tests/Job-specs.js +0 -216
- package/build/util/tests/util-specs.js +0 -123
- package/build/util/util.js +0 -322
package/util/Job.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Job = exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _invariant = _interopRequireDefault(require("invariant"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
|
|
12
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
+
|
|
14
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
15
|
+
|
|
16
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
|
2
17
|
|
|
3
18
|
/**
|
|
4
19
|
* Provides a convenient way to manage timed execution of functions.
|
|
@@ -7,243 +22,190 @@ import invariant from 'invariant';
|
|
|
7
22
|
* @memberof core/util
|
|
8
23
|
* @public
|
|
9
24
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
time = null;
|
|
198
|
-
this.run(args);
|
|
199
|
-
window.cancelAnimationFrame(this.id);
|
|
200
|
-
this.id = null;
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
this.id = window.requestAnimationFrame(callback);
|
|
204
|
-
} else {
|
|
205
|
-
// If requestAnimationFrame is not supported just run the function immediately
|
|
206
|
-
this.run(args);
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Starts the job when `promise` resolves.
|
|
212
|
-
*
|
|
213
|
-
* The job execution is tied to the resolution of the last `Promise` passed. Like other methods
|
|
214
|
-
* on `Job`, calling `promise()` again with a new `Promise` will block execution of the job
|
|
215
|
-
* until that new `Promise` resolves. Any previous `Promise`s will still resolve normally but
|
|
216
|
-
* will not trigger job execution.
|
|
217
|
-
*
|
|
218
|
-
* Unlike other methods on `Job`, `promise()` returns a `Promise` which is the result of calling
|
|
219
|
-
* `then()` on the passed `promise`. That `Promise` resolves with either the result of job
|
|
220
|
-
* execution or `undefined` if `Promise` was superseded by a subsequent `Promise` passed as
|
|
221
|
-
* described above.
|
|
222
|
-
*
|
|
223
|
-
* @method
|
|
224
|
-
* @param {Promise} promise The promise that must resolve before the job is executed
|
|
225
|
-
*
|
|
226
|
-
* @returns {Promise}
|
|
227
|
-
* @memberof core/util.Job.prototype
|
|
228
|
-
* @public
|
|
229
|
-
*/
|
|
230
|
-
promise = (promise) => {
|
|
231
|
-
invariant(
|
|
232
|
-
promise && typeof promise.then === 'function',
|
|
233
|
-
'promise expects a thenable'
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
this.type = 'promise';
|
|
237
|
-
this.id = promise;
|
|
238
|
-
|
|
239
|
-
return promise.then(result => {
|
|
240
|
-
if (this.id === promise) {
|
|
241
|
-
this.stop();
|
|
242
|
-
return this.run([result]);
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export default Job;
|
|
249
|
-
export {Job};
|
|
25
|
+
var Job = /*#__PURE__*/function () {
|
|
26
|
+
/**
|
|
27
|
+
* @constructor
|
|
28
|
+
* @param {Function} fn Function to execute as the requested job.
|
|
29
|
+
* @param {Number} timeout The number of milliseconds to wait before starting the job.
|
|
30
|
+
*
|
|
31
|
+
* @memberof core/util.Job.prototype
|
|
32
|
+
*/
|
|
33
|
+
function Job(fn, _timeout) {
|
|
34
|
+
var _this = this;
|
|
35
|
+
|
|
36
|
+
_classCallCheck(this, Job);
|
|
37
|
+
|
|
38
|
+
this.id = null;
|
|
39
|
+
this.fn = null;
|
|
40
|
+
this.timeout = null;
|
|
41
|
+
this.type = null;
|
|
42
|
+
|
|
43
|
+
this.start = function () {
|
|
44
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
|
+
args[_key] = arguments[_key];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
_this.startAfter.apply(_this, [_this.timeout].concat(args));
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
this.startAfter = function (timeout) {
|
|
52
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
53
|
+
args[_key2 - 1] = arguments[_key2];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_this.stop();
|
|
57
|
+
|
|
58
|
+
_this.type = 'timeout';
|
|
59
|
+
_this.id = setTimeout(function () {
|
|
60
|
+
return _this.run(args);
|
|
61
|
+
}, timeout);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
this.stop = function () {
|
|
65
|
+
if (_this.id) {
|
|
66
|
+
if (_this.type === 'idle') {
|
|
67
|
+
window.cancelIdleCallback(_this.id);
|
|
68
|
+
} else if (_this.type === 'raf') {
|
|
69
|
+
window.cancelAnimationFrame(_this.id);
|
|
70
|
+
} else if (_this.type === 'timeout') {
|
|
71
|
+
clearTimeout(_this.id);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
_this.id = _this.type = null;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
this.throttle = function () {
|
|
79
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
80
|
+
args[_key3] = arguments[_key3];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
_this.throttleUntil.apply(_this, [_this.timeout].concat(args));
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
this.throttleUntil = function (timeout) {
|
|
87
|
+
if (!_this.id) {
|
|
88
|
+
_this.type = 'timeout';
|
|
89
|
+
|
|
90
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
91
|
+
args[_key4 - 1] = arguments[_key4];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
_this.run(args);
|
|
95
|
+
|
|
96
|
+
_this.id = setTimeout(_this.stop, timeout);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
this.idle = function () {
|
|
101
|
+
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
102
|
+
args[_key5] = arguments[_key5];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_this.idleUntil.apply(_this, [null].concat(args));
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
this.idleUntil = function (timeout) {
|
|
109
|
+
for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
|
|
110
|
+
args[_key6 - 1] = arguments[_key6];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (typeof window !== 'undefined' && window.requestIdleCallback) {
|
|
114
|
+
_this.stop();
|
|
115
|
+
|
|
116
|
+
_this.type = 'idle';
|
|
117
|
+
_this.id = window.requestIdleCallback(function () {
|
|
118
|
+
return _this.run(args);
|
|
119
|
+
}, {
|
|
120
|
+
timeout: timeout
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
// since we can't request an idle callback, just pass to startAfter()
|
|
124
|
+
_this.startAfter.apply(_this, [timeout].concat(args));
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
this.startRaf = function () {
|
|
129
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
130
|
+
args[_key7] = arguments[_key7];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
_this.startRafAfter.apply(_this, [_this.timeout].concat(args));
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
this.startRafAfter = function (timeout) {
|
|
137
|
+
for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {
|
|
138
|
+
args[_key8 - 1] = arguments[_key8];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
_this.type = 'raf';
|
|
142
|
+
|
|
143
|
+
if (typeof window !== 'undefined') {
|
|
144
|
+
var time = null;
|
|
145
|
+
|
|
146
|
+
var callback = function callback(timestamp) {
|
|
147
|
+
if (time === null) {
|
|
148
|
+
time = timestamp;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (timeout && timestamp - time < timeout) {
|
|
152
|
+
_this.id = window.requestAnimationFrame(callback);
|
|
153
|
+
} else {
|
|
154
|
+
time = null;
|
|
155
|
+
|
|
156
|
+
_this.run(args);
|
|
157
|
+
|
|
158
|
+
window.cancelAnimationFrame(_this.id);
|
|
159
|
+
_this.id = null;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
_this.id = window.requestAnimationFrame(callback);
|
|
164
|
+
} else {
|
|
165
|
+
// If requestAnimationFrame is not supported just run the function immediately
|
|
166
|
+
_this.run(args);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
this.promise = function (promise) {
|
|
171
|
+
!(promise && typeof promise.then === 'function') ? process.env.NODE_ENV !== "production" ? (0, _invariant["default"])(false, 'promise expects a thenable') : invariant(false) : void 0;
|
|
172
|
+
_this.type = 'promise';
|
|
173
|
+
_this.id = promise;
|
|
174
|
+
return promise.then(function (result) {
|
|
175
|
+
if (_this.id === promise) {
|
|
176
|
+
_this.stop();
|
|
177
|
+
|
|
178
|
+
return _this.run([result]);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
this.fn = fn;
|
|
184
|
+
this.timeout = _timeout;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
_createClass(Job, [{
|
|
188
|
+
key: "run",
|
|
189
|
+
value: function run(args) {
|
|
190
|
+
// don't want to inadvertently apply Job's context on `fn`
|
|
191
|
+
return this.fn.apply(null, args);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Starts the job.
|
|
195
|
+
*
|
|
196
|
+
* @method
|
|
197
|
+
* @param {...*} [args] Any args passed are forwarded to the callback
|
|
198
|
+
*
|
|
199
|
+
* @returns {undefined}
|
|
200
|
+
* @memberof core/util.Job.prototype
|
|
201
|
+
* @public
|
|
202
|
+
*/
|
|
203
|
+
|
|
204
|
+
}]);
|
|
205
|
+
|
|
206
|
+
return Job;
|
|
207
|
+
}();
|
|
208
|
+
|
|
209
|
+
exports.Job = Job;
|
|
210
|
+
var _default = Job;
|
|
211
|
+
exports["default"] = _default;
|