scheduler 0.13.4 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-info.json +5 -5
- package/cjs/scheduler-tracing.development.js +23 -1
- package/cjs/scheduler-tracing.production.min.js +1 -1
- package/cjs/scheduler-tracing.profiling.min.js +1 -1
- package/cjs/scheduler-unstable_mock.development.js +565 -0
- package/cjs/scheduler-unstable_mock.production.min.js +19 -0
- package/cjs/scheduler.development.js +297 -325
- package/cjs/scheduler.production.min.js +12 -13
- package/package.json +2 -1
- package/unstable_mock.js +7 -0
package/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"branch": "
|
|
3
|
-
"buildNumber": "
|
|
4
|
-
"checksum": "
|
|
5
|
-
"commit": "
|
|
2
|
+
"branch": "master",
|
|
3
|
+
"buildNumber": "14388",
|
|
4
|
+
"checksum": "def61f1",
|
|
5
|
+
"commit": "a9eff329c",
|
|
6
6
|
"environment": "ci",
|
|
7
|
-
"reactVersion": "16.8.
|
|
7
|
+
"reactVersion": "16.8.6-canary-a9eff329c"
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.
|
|
1
|
+
/** @license React v0.14.0
|
|
2
2
|
* scheduler-tracing.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -48,6 +48,12 @@ var enableSchedulerTracing = true;
|
|
|
48
48
|
// Only used in www builds.
|
|
49
49
|
|
|
50
50
|
|
|
51
|
+
// Disable javascript: URL strings in href for XSS protection.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
// Disables yielding during render in Concurrent Mode. Used for debugging only.
|
|
55
|
+
|
|
56
|
+
|
|
51
57
|
// React Fire: prevent the value and checked attributes from syncing
|
|
52
58
|
// with their related DOM properties
|
|
53
59
|
|
|
@@ -55,6 +61,22 @@ var enableSchedulerTracing = true;
|
|
|
55
61
|
// These APIs will no longer be "unstable" in the upcoming 16.7 release,
|
|
56
62
|
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
|
|
57
63
|
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
|
|
68
|
+
// This is a flag so we can fix warnings in RN core before turning it on
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// Experimental React Events support. Only used in www builds for now.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// Enables rewritten version of ReactFiberScheduler. Added in case we need to
|
|
75
|
+
// quickly revert it.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
|
79
|
+
|
|
58
80
|
var DEFAULT_THREAD_ID = 0;
|
|
59
81
|
|
|
60
82
|
// Counters used to generate unique IDs.
|
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
/** @license React v0.14.0
|
|
2
|
+
* scheduler-unstable_mock.development.js
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if (process.env.NODE_ENV !== "production") {
|
|
15
|
+
(function() {
|
|
16
|
+
'use strict';
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
19
|
+
|
|
20
|
+
var enableSchedulerDebugging = false;
|
|
21
|
+
|
|
22
|
+
var currentTime = 0;
|
|
23
|
+
var scheduledCallback = null;
|
|
24
|
+
var scheduledCallbackExpiration = -1;
|
|
25
|
+
var yieldedValues = null;
|
|
26
|
+
var expectedNumberOfYields = -1;
|
|
27
|
+
var didStop = false;
|
|
28
|
+
var isFlushing = false;
|
|
29
|
+
|
|
30
|
+
function requestHostCallback(callback, expiration) {
|
|
31
|
+
scheduledCallback = callback;
|
|
32
|
+
scheduledCallbackExpiration = expiration;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function cancelHostCallback() {
|
|
36
|
+
scheduledCallback = null;
|
|
37
|
+
scheduledCallbackExpiration = -1;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function shouldYieldToHost() {
|
|
41
|
+
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) {
|
|
42
|
+
// We yielded at least as many values as expected. Stop flushing.
|
|
43
|
+
didStop = true;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getCurrentTime() {
|
|
50
|
+
return currentTime;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
// Should only be used via an assertion helper that inspects the yielded values.
|
|
56
|
+
function unstable_flushNumberOfYields(count) {
|
|
57
|
+
if (isFlushing) {
|
|
58
|
+
throw new Error('Already flushing work.');
|
|
59
|
+
}
|
|
60
|
+
expectedNumberOfYields = count;
|
|
61
|
+
isFlushing = true;
|
|
62
|
+
try {
|
|
63
|
+
while (scheduledCallback !== null && !didStop) {
|
|
64
|
+
var cb = scheduledCallback;
|
|
65
|
+
scheduledCallback = null;
|
|
66
|
+
var didTimeout = scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime;
|
|
67
|
+
cb(didTimeout);
|
|
68
|
+
}
|
|
69
|
+
} finally {
|
|
70
|
+
expectedNumberOfYields = -1;
|
|
71
|
+
didStop = false;
|
|
72
|
+
isFlushing = false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function unstable_flushExpired() {
|
|
77
|
+
if (isFlushing) {
|
|
78
|
+
throw new Error('Already flushing work.');
|
|
79
|
+
}
|
|
80
|
+
if (scheduledCallback !== null) {
|
|
81
|
+
var cb = scheduledCallback;
|
|
82
|
+
scheduledCallback = null;
|
|
83
|
+
isFlushing = true;
|
|
84
|
+
try {
|
|
85
|
+
cb(true);
|
|
86
|
+
} finally {
|
|
87
|
+
isFlushing = false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function unstable_flushWithoutYielding() {
|
|
93
|
+
if (isFlushing) {
|
|
94
|
+
throw new Error('Already flushing work.');
|
|
95
|
+
}
|
|
96
|
+
isFlushing = true;
|
|
97
|
+
try {
|
|
98
|
+
while (scheduledCallback !== null) {
|
|
99
|
+
var cb = scheduledCallback;
|
|
100
|
+
scheduledCallback = null;
|
|
101
|
+
var didTimeout = scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime;
|
|
102
|
+
cb(didTimeout);
|
|
103
|
+
}
|
|
104
|
+
} finally {
|
|
105
|
+
expectedNumberOfYields = -1;
|
|
106
|
+
didStop = false;
|
|
107
|
+
isFlushing = false;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function unstable_clearYields() {
|
|
112
|
+
if (yieldedValues === null) {
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
var values = yieldedValues;
|
|
116
|
+
yieldedValues = null;
|
|
117
|
+
return values;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function flushAll() {
|
|
121
|
+
if (yieldedValues !== null) {
|
|
122
|
+
throw new Error('Log is not empty. Assert on the log of yielded values before ' + 'flushing additional work.');
|
|
123
|
+
}
|
|
124
|
+
unstable_flushWithoutYielding();
|
|
125
|
+
if (yieldedValues !== null) {
|
|
126
|
+
throw new Error('While flushing work, something yielded a value. Use an ' + 'assertion helper to assert on the log of yielded values, e.g. ' + 'expect(Scheduler).toFlushAndYield([...])');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function yieldValue(value) {
|
|
131
|
+
if (yieldedValues === null) {
|
|
132
|
+
yieldedValues = [value];
|
|
133
|
+
} else {
|
|
134
|
+
yieldedValues.push(value);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function advanceTime(ms) {
|
|
139
|
+
currentTime += ms;
|
|
140
|
+
// If the host callback timed out, flush the expired work.
|
|
141
|
+
if (!isFlushing && scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) {
|
|
142
|
+
unstable_flushExpired();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/* eslint-disable no-var */
|
|
147
|
+
|
|
148
|
+
// TODO: Use symbols?
|
|
149
|
+
var ImmediatePriority = 1;
|
|
150
|
+
var UserBlockingPriority = 2;
|
|
151
|
+
var NormalPriority = 3;
|
|
152
|
+
var LowPriority = 4;
|
|
153
|
+
var IdlePriority = 5;
|
|
154
|
+
|
|
155
|
+
// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
|
|
156
|
+
// Math.pow(2, 30) - 1
|
|
157
|
+
// 0b111111111111111111111111111111
|
|
158
|
+
var maxSigned31BitInt = 1073741823;
|
|
159
|
+
|
|
160
|
+
// Times out immediately
|
|
161
|
+
var IMMEDIATE_PRIORITY_TIMEOUT = -1;
|
|
162
|
+
// Eventually times out
|
|
163
|
+
var USER_BLOCKING_PRIORITY = 250;
|
|
164
|
+
var NORMAL_PRIORITY_TIMEOUT = 5000;
|
|
165
|
+
var LOW_PRIORITY_TIMEOUT = 10000;
|
|
166
|
+
// Never times out
|
|
167
|
+
var IDLE_PRIORITY = maxSigned31BitInt;
|
|
168
|
+
|
|
169
|
+
// Callbacks are stored as a circular, doubly linked list.
|
|
170
|
+
var firstCallbackNode = null;
|
|
171
|
+
|
|
172
|
+
var currentHostCallbackDidTimeout = false;
|
|
173
|
+
// Pausing the scheduler is useful for debugging.
|
|
174
|
+
var isSchedulerPaused = false;
|
|
175
|
+
|
|
176
|
+
var currentPriorityLevel = NormalPriority;
|
|
177
|
+
var currentEventStartTime = -1;
|
|
178
|
+
var currentExpirationTime = -1;
|
|
179
|
+
|
|
180
|
+
// This is set while performing work, to prevent re-entrancy.
|
|
181
|
+
var isPerformingWork = false;
|
|
182
|
+
|
|
183
|
+
var isHostCallbackScheduled = false;
|
|
184
|
+
|
|
185
|
+
function scheduleHostCallbackIfNeeded() {
|
|
186
|
+
if (isPerformingWork) {
|
|
187
|
+
// Don't schedule work yet; wait until the next time we yield.
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (firstCallbackNode !== null) {
|
|
191
|
+
// Schedule the host callback using the earliest expiration in the list.
|
|
192
|
+
var expirationTime = firstCallbackNode.expirationTime;
|
|
193
|
+
if (isHostCallbackScheduled) {
|
|
194
|
+
// Cancel the existing host callback.
|
|
195
|
+
cancelHostCallback();
|
|
196
|
+
} else {
|
|
197
|
+
isHostCallbackScheduled = true;
|
|
198
|
+
}
|
|
199
|
+
requestHostCallback(flushWork, expirationTime);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function flushFirstCallback() {
|
|
204
|
+
var currentlyFlushingCallback = firstCallbackNode;
|
|
205
|
+
|
|
206
|
+
// Remove the node from the list before calling the callback. That way the
|
|
207
|
+
// list is in a consistent state even if the callback throws.
|
|
208
|
+
var next = firstCallbackNode.next;
|
|
209
|
+
if (firstCallbackNode === next) {
|
|
210
|
+
// This is the last callback in the list.
|
|
211
|
+
firstCallbackNode = null;
|
|
212
|
+
next = null;
|
|
213
|
+
} else {
|
|
214
|
+
var lastCallbackNode = firstCallbackNode.previous;
|
|
215
|
+
firstCallbackNode = lastCallbackNode.next = next;
|
|
216
|
+
next.previous = lastCallbackNode;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
currentlyFlushingCallback.next = currentlyFlushingCallback.previous = null;
|
|
220
|
+
|
|
221
|
+
// Now it's safe to call the callback.
|
|
222
|
+
var callback = currentlyFlushingCallback.callback;
|
|
223
|
+
var expirationTime = currentlyFlushingCallback.expirationTime;
|
|
224
|
+
var priorityLevel = currentlyFlushingCallback.priorityLevel;
|
|
225
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
226
|
+
var previousExpirationTime = currentExpirationTime;
|
|
227
|
+
currentPriorityLevel = priorityLevel;
|
|
228
|
+
currentExpirationTime = expirationTime;
|
|
229
|
+
var continuationCallback;
|
|
230
|
+
try {
|
|
231
|
+
var didUserCallbackTimeout = currentHostCallbackDidTimeout ||
|
|
232
|
+
// Immediate priority callbacks are always called as if they timed out
|
|
233
|
+
priorityLevel === ImmediatePriority;
|
|
234
|
+
continuationCallback = callback(didUserCallbackTimeout);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
throw error;
|
|
237
|
+
} finally {
|
|
238
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
239
|
+
currentExpirationTime = previousExpirationTime;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// A callback may return a continuation. The continuation should be scheduled
|
|
243
|
+
// with the same priority and expiration as the just-finished callback.
|
|
244
|
+
if (typeof continuationCallback === 'function') {
|
|
245
|
+
var continuationNode = {
|
|
246
|
+
callback: continuationCallback,
|
|
247
|
+
priorityLevel: priorityLevel,
|
|
248
|
+
expirationTime: expirationTime,
|
|
249
|
+
next: null,
|
|
250
|
+
previous: null
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// Insert the new callback into the list, sorted by its expiration. This is
|
|
254
|
+
// almost the same as the code in `scheduleCallback`, except the callback
|
|
255
|
+
// is inserted into the list *before* callbacks of equal expiration instead
|
|
256
|
+
// of after.
|
|
257
|
+
if (firstCallbackNode === null) {
|
|
258
|
+
// This is the first callback in the list.
|
|
259
|
+
firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
|
|
260
|
+
} else {
|
|
261
|
+
var nextAfterContinuation = null;
|
|
262
|
+
var node = firstCallbackNode;
|
|
263
|
+
do {
|
|
264
|
+
if (node.expirationTime >= expirationTime) {
|
|
265
|
+
// This callback expires at or after the continuation. We will insert
|
|
266
|
+
// the continuation *before* this callback.
|
|
267
|
+
nextAfterContinuation = node;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
node = node.next;
|
|
271
|
+
} while (node !== firstCallbackNode);
|
|
272
|
+
|
|
273
|
+
if (nextAfterContinuation === null) {
|
|
274
|
+
// No equal or lower priority callback was found, which means the new
|
|
275
|
+
// callback is the lowest priority callback in the list.
|
|
276
|
+
nextAfterContinuation = firstCallbackNode;
|
|
277
|
+
} else if (nextAfterContinuation === firstCallbackNode) {
|
|
278
|
+
// The new callback is the highest priority callback in the list.
|
|
279
|
+
firstCallbackNode = continuationNode;
|
|
280
|
+
scheduleHostCallbackIfNeeded();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
var previous = nextAfterContinuation.previous;
|
|
284
|
+
previous.next = nextAfterContinuation.previous = continuationNode;
|
|
285
|
+
continuationNode.next = nextAfterContinuation;
|
|
286
|
+
continuationNode.previous = previous;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function flushWork(didUserCallbackTimeout) {
|
|
292
|
+
// Exit right away if we're currently paused
|
|
293
|
+
if (enableSchedulerDebugging && isSchedulerPaused) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// We'll need a new host callback the next time work is scheduled.
|
|
298
|
+
isHostCallbackScheduled = false;
|
|
299
|
+
|
|
300
|
+
isPerformingWork = true;
|
|
301
|
+
var previousDidTimeout = currentHostCallbackDidTimeout;
|
|
302
|
+
currentHostCallbackDidTimeout = didUserCallbackTimeout;
|
|
303
|
+
try {
|
|
304
|
+
if (didUserCallbackTimeout) {
|
|
305
|
+
// Flush all the expired callbacks without yielding.
|
|
306
|
+
while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {
|
|
307
|
+
// TODO Wrap in feature flag
|
|
308
|
+
// Read the current time. Flush all the callbacks that expire at or
|
|
309
|
+
// earlier than that time. Then read the current time again and repeat.
|
|
310
|
+
// This optimizes for as few performance.now calls as possible.
|
|
311
|
+
var currentTime = getCurrentTime();
|
|
312
|
+
if (firstCallbackNode.expirationTime <= currentTime) {
|
|
313
|
+
do {
|
|
314
|
+
flushFirstCallback();
|
|
315
|
+
} while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused));
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
// Keep flushing callbacks until we run out of time in the frame.
|
|
322
|
+
if (firstCallbackNode !== null) {
|
|
323
|
+
do {
|
|
324
|
+
if (enableSchedulerDebugging && isSchedulerPaused) {
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
flushFirstCallback();
|
|
328
|
+
} while (firstCallbackNode !== null && !shouldYieldToHost());
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
} finally {
|
|
332
|
+
isPerformingWork = false;
|
|
333
|
+
currentHostCallbackDidTimeout = previousDidTimeout;
|
|
334
|
+
// There's still work remaining. Request another callback.
|
|
335
|
+
scheduleHostCallbackIfNeeded();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function unstable_runWithPriority(priorityLevel, eventHandler) {
|
|
340
|
+
switch (priorityLevel) {
|
|
341
|
+
case ImmediatePriority:
|
|
342
|
+
case UserBlockingPriority:
|
|
343
|
+
case NormalPriority:
|
|
344
|
+
case LowPriority:
|
|
345
|
+
case IdlePriority:
|
|
346
|
+
break;
|
|
347
|
+
default:
|
|
348
|
+
priorityLevel = NormalPriority;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
352
|
+
var previousEventStartTime = currentEventStartTime;
|
|
353
|
+
currentPriorityLevel = priorityLevel;
|
|
354
|
+
currentEventStartTime = getCurrentTime();
|
|
355
|
+
|
|
356
|
+
try {
|
|
357
|
+
return eventHandler();
|
|
358
|
+
} catch (error) {
|
|
359
|
+
// There's still work remaining. Request another callback.
|
|
360
|
+
scheduleHostCallbackIfNeeded();
|
|
361
|
+
throw error;
|
|
362
|
+
} finally {
|
|
363
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
364
|
+
currentEventStartTime = previousEventStartTime;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
function unstable_next(eventHandler) {
|
|
369
|
+
var priorityLevel = void 0;
|
|
370
|
+
switch (currentPriorityLevel) {
|
|
371
|
+
case ImmediatePriority:
|
|
372
|
+
case UserBlockingPriority:
|
|
373
|
+
case NormalPriority:
|
|
374
|
+
// Shift down to normal priority
|
|
375
|
+
priorityLevel = NormalPriority;
|
|
376
|
+
break;
|
|
377
|
+
default:
|
|
378
|
+
// Anything lower than normal priority should remain at the current level.
|
|
379
|
+
priorityLevel = currentPriorityLevel;
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
384
|
+
var previousEventStartTime = currentEventStartTime;
|
|
385
|
+
currentPriorityLevel = priorityLevel;
|
|
386
|
+
currentEventStartTime = getCurrentTime();
|
|
387
|
+
|
|
388
|
+
try {
|
|
389
|
+
return eventHandler();
|
|
390
|
+
} catch (error) {
|
|
391
|
+
// There's still work remaining. Request another callback.
|
|
392
|
+
scheduleHostCallbackIfNeeded();
|
|
393
|
+
throw error;
|
|
394
|
+
} finally {
|
|
395
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
396
|
+
currentEventStartTime = previousEventStartTime;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
function unstable_wrapCallback(callback) {
|
|
401
|
+
var parentPriorityLevel = currentPriorityLevel;
|
|
402
|
+
return function () {
|
|
403
|
+
// This is a fork of runWithPriority, inlined for performance.
|
|
404
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
405
|
+
var previousEventStartTime = currentEventStartTime;
|
|
406
|
+
currentPriorityLevel = parentPriorityLevel;
|
|
407
|
+
currentEventStartTime = getCurrentTime();
|
|
408
|
+
|
|
409
|
+
try {
|
|
410
|
+
return callback.apply(this, arguments);
|
|
411
|
+
} catch (error) {
|
|
412
|
+
// There's still work remaining. Request another callback.
|
|
413
|
+
scheduleHostCallbackIfNeeded();
|
|
414
|
+
throw error;
|
|
415
|
+
} finally {
|
|
416
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
417
|
+
currentEventStartTime = previousEventStartTime;
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) {
|
|
423
|
+
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
|
|
424
|
+
|
|
425
|
+
var expirationTime;
|
|
426
|
+
if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
|
|
427
|
+
// FIXME: Remove this branch once we lift expiration times out of React.
|
|
428
|
+
expirationTime = startTime + deprecated_options.timeout;
|
|
429
|
+
} else {
|
|
430
|
+
switch (priorityLevel) {
|
|
431
|
+
case ImmediatePriority:
|
|
432
|
+
expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
|
|
433
|
+
break;
|
|
434
|
+
case UserBlockingPriority:
|
|
435
|
+
expirationTime = startTime + USER_BLOCKING_PRIORITY;
|
|
436
|
+
break;
|
|
437
|
+
case IdlePriority:
|
|
438
|
+
expirationTime = startTime + IDLE_PRIORITY;
|
|
439
|
+
break;
|
|
440
|
+
case LowPriority:
|
|
441
|
+
expirationTime = startTime + LOW_PRIORITY_TIMEOUT;
|
|
442
|
+
break;
|
|
443
|
+
case NormalPriority:
|
|
444
|
+
default:
|
|
445
|
+
expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
var newNode = {
|
|
450
|
+
callback: callback,
|
|
451
|
+
priorityLevel: priorityLevel,
|
|
452
|
+
expirationTime: expirationTime,
|
|
453
|
+
next: null,
|
|
454
|
+
previous: null
|
|
455
|
+
};
|
|
456
|
+
|
|
457
|
+
// Insert the new callback into the list, ordered first by expiration, then
|
|
458
|
+
// by insertion. So the new callback is inserted any other callback with
|
|
459
|
+
// equal expiration.
|
|
460
|
+
if (firstCallbackNode === null) {
|
|
461
|
+
// This is the first callback in the list.
|
|
462
|
+
firstCallbackNode = newNode.next = newNode.previous = newNode;
|
|
463
|
+
scheduleHostCallbackIfNeeded();
|
|
464
|
+
} else {
|
|
465
|
+
var next = null;
|
|
466
|
+
var node = firstCallbackNode;
|
|
467
|
+
do {
|
|
468
|
+
if (node.expirationTime > expirationTime) {
|
|
469
|
+
// The new callback expires before this one.
|
|
470
|
+
next = node;
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
node = node.next;
|
|
474
|
+
} while (node !== firstCallbackNode);
|
|
475
|
+
|
|
476
|
+
if (next === null) {
|
|
477
|
+
// No callback with a later expiration was found, which means the new
|
|
478
|
+
// callback has the latest expiration in the list.
|
|
479
|
+
next = firstCallbackNode;
|
|
480
|
+
} else if (next === firstCallbackNode) {
|
|
481
|
+
// The new callback has the earliest expiration in the entire list.
|
|
482
|
+
firstCallbackNode = newNode;
|
|
483
|
+
scheduleHostCallbackIfNeeded();
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
var previous = next.previous;
|
|
487
|
+
previous.next = next.previous = newNode;
|
|
488
|
+
newNode.next = next;
|
|
489
|
+
newNode.previous = previous;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
return newNode;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
function unstable_pauseExecution() {
|
|
496
|
+
isSchedulerPaused = true;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function unstable_continueExecution() {
|
|
500
|
+
isSchedulerPaused = false;
|
|
501
|
+
if (firstCallbackNode !== null) {
|
|
502
|
+
scheduleHostCallbackIfNeeded();
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
function unstable_getFirstCallbackNode() {
|
|
507
|
+
return firstCallbackNode;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
function unstable_cancelCallback(callbackNode) {
|
|
511
|
+
var next = callbackNode.next;
|
|
512
|
+
if (next === null) {
|
|
513
|
+
// Already cancelled.
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
if (next === callbackNode) {
|
|
518
|
+
// This is the only scheduled callback. Clear the list.
|
|
519
|
+
firstCallbackNode = null;
|
|
520
|
+
} else {
|
|
521
|
+
// Remove the callback from its position in the list.
|
|
522
|
+
if (callbackNode === firstCallbackNode) {
|
|
523
|
+
firstCallbackNode = next;
|
|
524
|
+
}
|
|
525
|
+
var previous = callbackNode.previous;
|
|
526
|
+
previous.next = next;
|
|
527
|
+
next.previous = previous;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
callbackNode.next = callbackNode.previous = null;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
function unstable_getCurrentPriorityLevel() {
|
|
534
|
+
return currentPriorityLevel;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
function unstable_shouldYield() {
|
|
538
|
+
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
exports.unstable_flushWithoutYielding = unstable_flushWithoutYielding;
|
|
542
|
+
exports.unstable_flushNumberOfYields = unstable_flushNumberOfYields;
|
|
543
|
+
exports.unstable_flushExpired = unstable_flushExpired;
|
|
544
|
+
exports.unstable_clearYields = unstable_clearYields;
|
|
545
|
+
exports.flushAll = flushAll;
|
|
546
|
+
exports.yieldValue = yieldValue;
|
|
547
|
+
exports.advanceTime = advanceTime;
|
|
548
|
+
exports.unstable_ImmediatePriority = ImmediatePriority;
|
|
549
|
+
exports.unstable_UserBlockingPriority = UserBlockingPriority;
|
|
550
|
+
exports.unstable_NormalPriority = NormalPriority;
|
|
551
|
+
exports.unstable_IdlePriority = IdlePriority;
|
|
552
|
+
exports.unstable_LowPriority = LowPriority;
|
|
553
|
+
exports.unstable_runWithPriority = unstable_runWithPriority;
|
|
554
|
+
exports.unstable_next = unstable_next;
|
|
555
|
+
exports.unstable_scheduleCallback = unstable_scheduleCallback;
|
|
556
|
+
exports.unstable_cancelCallback = unstable_cancelCallback;
|
|
557
|
+
exports.unstable_wrapCallback = unstable_wrapCallback;
|
|
558
|
+
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
|
|
559
|
+
exports.unstable_shouldYield = unstable_shouldYield;
|
|
560
|
+
exports.unstable_continueExecution = unstable_continueExecution;
|
|
561
|
+
exports.unstable_pauseExecution = unstable_pauseExecution;
|
|
562
|
+
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
|
|
563
|
+
exports.unstable_now = getCurrentTime;
|
|
564
|
+
})();
|
|
565
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @license React v0.14.0
|
|
2
|
+
* scheduler-unstable_mock.production.min.js
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var c=0,f=null,g=-1,h=null,k=-1,l=!1,m=!1;function n(){return-1!==k&&null!==h&&h.length>=k||-1!==g&&g<=c?l=!0:!1}function q(){if(m)throw Error("Already flushing work.");if(null!==f){var a=f;f=null;m=!0;try{a(!0)}finally{m=!1}}}function t(){if(m)throw Error("Already flushing work.");m=!0;try{for(;null!==f;){var a=f;f=null;a(-1!==g&&g<=c)}}finally{k=-1,m=l=!1}}var u=null,v=!1,w=3,x=-1,y=-1,z=!1,A=!1;
|
|
11
|
+
function B(){if(!z&&null!==u){var a=u.expirationTime;A?(f=null,g=-1):A=!0;f=C;g=a}}
|
|
12
|
+
function D(){var a=u,d=u.next;if(u===d)u=null;else{var b=u.previous;u=b.next=d;d.previous=b}a.next=a.previous=null;b=a.callback;d=a.expirationTime;a=a.priorityLevel;var e=w,r=y;w=a;y=d;try{var p=b(v||1===a)}catch(E){throw E;}finally{w=e,y=r}if("function"===typeof p)if(p={callback:p,priorityLevel:a,expirationTime:d,next:null,previous:null},null===u)u=p.next=p.previous=p;else{b=null;a=u;do{if(a.expirationTime>=d){b=a;break}a=a.next}while(a!==u);null===b?b=u:b===u&&(u=p,B());d=b.previous;d.next=b.previous=
|
|
13
|
+
p;p.next=b;p.previous=d}}function C(a){A=!1;z=!0;var d=v;v=a;try{if(a)for(;null!==u;)if(a=c,u.expirationTime<=a){do D();while(null!==u&&u.expirationTime<=a)}else break;else if(null!==u){do D();while(null!==u&&!n())}}finally{z=!1,v=d,B()}}exports.unstable_flushWithoutYielding=t;exports.unstable_flushNumberOfYields=function(a){if(m)throw Error("Already flushing work.");k=a;m=!0;try{for(;null!==f&&!l;)a=f,f=null,a(-1!==g&&g<=c)}finally{k=-1,m=l=!1}};exports.unstable_flushExpired=q;
|
|
14
|
+
exports.unstable_clearYields=function(){if(null===h)return[];var a=h;h=null;return a};exports.flushAll=function(){if(null!==h)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");t();if(null!==h)throw Error("While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])");};exports.yieldValue=function(a){null===h?h=[a]:h.push(a)};
|
|
15
|
+
exports.advanceTime=function(a){c+=a;!m&&-1!==g&&g<=c&&q()};exports.unstable_ImmediatePriority=1;exports.unstable_UserBlockingPriority=2;exports.unstable_NormalPriority=3;exports.unstable_IdlePriority=5;exports.unstable_LowPriority=4;exports.unstable_runWithPriority=function(a,d){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var b=w,e=x;w=a;x=c;try{return d()}catch(r){throw B(),r;}finally{w=b,x=e}};
|
|
16
|
+
exports.unstable_next=function(a){switch(w){case 1:case 2:case 3:var d=3;break;default:d=w}var b=w,e=x;w=d;x=c;try{return a()}catch(r){throw B(),r;}finally{w=b,x=e}};
|
|
17
|
+
exports.unstable_scheduleCallback=function(a,d,b){var e=-1!==x?x:c;if("object"===typeof b&&null!==b&&"number"===typeof b.timeout)b=e+b.timeout;else switch(a){case 1:b=e+-1;break;case 2:b=e+250;break;case 5:b=e+1073741823;break;case 4:b=e+1E4;break;default:b=e+5E3}a={callback:d,priorityLevel:a,expirationTime:b,next:null,previous:null};if(null===u)u=a.next=a.previous=a,B();else{d=null;e=u;do{if(e.expirationTime>b){d=e;break}e=e.next}while(e!==u);null===d?d=u:d===u&&(u=a,B());b=d.previous;b.next=d.previous=
|
|
18
|
+
a;a.next=d;a.previous=b}return a};exports.unstable_cancelCallback=function(a){var d=a.next;if(null!==d){if(d===a)u=null;else{a===u&&(u=d);var b=a.previous;b.next=d;d.previous=b}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var d=w;return function(){var b=w,e=x;w=d;x=c;try{return a.apply(this,arguments)}catch(r){throw B(),r;}finally{w=b,x=e}}};exports.unstable_getCurrentPriorityLevel=function(){return w};
|
|
19
|
+
exports.unstable_shouldYield=function(){return!v&&(null!==u&&u.expirationTime<y||n())};exports.unstable_continueExecution=function(){null!==u&&B()};exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return u};exports.unstable_now=function(){return c};
|