source: node_modules/scheduler/cjs/scheduler.native.production.js@ ba17441

Last change on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 10.6 KB
Line 
1/**
2 * @license React
3 * scheduler.native.production.js
4 *
5 * Copyright (c) Meta Platforms, Inc. and affiliates.
6 *
7 * This source code is licensed under the MIT license found in the
8 * LICENSE file in the root directory of this source tree.
9 */
10
11"use strict";
12function push(heap, node) {
13 var index = heap.length;
14 heap.push(node);
15 a: for (; 0 < index; ) {
16 var parentIndex = (index - 1) >>> 1,
17 parent = heap[parentIndex];
18 if (0 < compare(parent, node))
19 (heap[parentIndex] = node), (heap[index] = parent), (index = parentIndex);
20 else break a;
21 }
22}
23function peek(heap) {
24 return 0 === heap.length ? null : heap[0];
25}
26function pop(heap) {
27 if (0 === heap.length) return null;
28 var first = heap[0],
29 last = heap.pop();
30 if (last !== first) {
31 heap[0] = last;
32 a: for (
33 var index = 0, length = heap.length, halfLength = length >>> 1;
34 index < halfLength;
35
36 ) {
37 var leftIndex = 2 * (index + 1) - 1,
38 left = heap[leftIndex],
39 rightIndex = leftIndex + 1,
40 right = heap[rightIndex];
41 if (0 > compare(left, last))
42 rightIndex < length && 0 > compare(right, left)
43 ? ((heap[index] = right),
44 (heap[rightIndex] = last),
45 (index = rightIndex))
46 : ((heap[index] = left),
47 (heap[leftIndex] = last),
48 (index = leftIndex));
49 else if (rightIndex < length && 0 > compare(right, last))
50 (heap[index] = right), (heap[rightIndex] = last), (index = rightIndex);
51 else break a;
52 }
53 }
54 return first;
55}
56function compare(a, b) {
57 var diff = a.sortIndex - b.sortIndex;
58 return 0 !== diff ? diff : a.id - b.id;
59}
60var getCurrentTime;
61if ("object" === typeof performance && "function" === typeof performance.now) {
62 var localPerformance = performance;
63 getCurrentTime = function () {
64 return localPerformance.now();
65 };
66} else {
67 var localDate = Date,
68 initialTime = localDate.now();
69 getCurrentTime = function () {
70 return localDate.now() - initialTime;
71 };
72}
73var taskQueue = [],
74 timerQueue = [],
75 taskIdCounter = 1,
76 currentTask = null,
77 currentPriorityLevel = 3,
78 isPerformingWork = !1,
79 isHostCallbackScheduled = !1,
80 isHostTimeoutScheduled = !1,
81 needsPaint = !1,
82 localSetTimeout = "function" === typeof setTimeout ? setTimeout : null,
83 localClearTimeout = "function" === typeof clearTimeout ? clearTimeout : null,
84 localSetImmediate = "undefined" !== typeof setImmediate ? setImmediate : null;
85function advanceTimers(currentTime) {
86 for (var timer = peek(timerQueue); null !== timer; ) {
87 if (null === timer.callback) pop(timerQueue);
88 else if (timer.startTime <= currentTime)
89 pop(timerQueue),
90 (timer.sortIndex = timer.expirationTime),
91 push(taskQueue, timer);
92 else break;
93 timer = peek(timerQueue);
94 }
95}
96function handleTimeout(currentTime) {
97 isHostTimeoutScheduled = !1;
98 advanceTimers(currentTime);
99 if (!isHostCallbackScheduled)
100 if (null !== peek(taskQueue))
101 (isHostCallbackScheduled = !0),
102 isMessageLoopRunning ||
103 ((isMessageLoopRunning = !0), schedulePerformWorkUntilDeadline());
104 else {
105 var firstTimer = peek(timerQueue);
106 null !== firstTimer &&
107 requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
108 }
109}
110function unstable_scheduleCallback$1(priorityLevel, callback, options) {
111 var currentTime = getCurrentTime();
112 "object" === typeof options && null !== options
113 ? ((options = options.delay),
114 (options =
115 "number" === typeof options && 0 < options
116 ? currentTime + options
117 : currentTime))
118 : (options = currentTime);
119 switch (priorityLevel) {
120 case 1:
121 var timeout = -1;
122 break;
123 case 2:
124 timeout = 250;
125 break;
126 case 5:
127 timeout = 1073741823;
128 break;
129 case 4:
130 timeout = 1e4;
131 break;
132 default:
133 timeout = 5e3;
134 }
135 timeout = options + timeout;
136 priorityLevel = {
137 id: taskIdCounter++,
138 callback: callback,
139 priorityLevel: priorityLevel,
140 startTime: options,
141 expirationTime: timeout,
142 sortIndex: -1
143 };
144 options > currentTime
145 ? ((priorityLevel.sortIndex = options),
146 push(timerQueue, priorityLevel),
147 null === peek(taskQueue) &&
148 priorityLevel === peek(timerQueue) &&
149 (isHostTimeoutScheduled
150 ? (localClearTimeout(taskTimeoutID), (taskTimeoutID = -1))
151 : (isHostTimeoutScheduled = !0),
152 requestHostTimeout(handleTimeout, options - currentTime)))
153 : ((priorityLevel.sortIndex = timeout),
154 push(taskQueue, priorityLevel),
155 isHostCallbackScheduled ||
156 isPerformingWork ||
157 ((isHostCallbackScheduled = !0),
158 isMessageLoopRunning ||
159 ((isMessageLoopRunning = !0), schedulePerformWorkUntilDeadline())));
160 return priorityLevel;
161}
162function unstable_cancelCallback$1(task) {
163 task.callback = null;
164}
165function unstable_getCurrentPriorityLevel$1() {
166 return currentPriorityLevel;
167}
168var isMessageLoopRunning = !1,
169 taskTimeoutID = -1,
170 startTime = -1;
171function shouldYieldToHost() {
172 return needsPaint ? !0 : 5 > getCurrentTime() - startTime ? !1 : !0;
173}
174function requestPaint() {
175 needsPaint = !0;
176}
177function performWorkUntilDeadline() {
178 needsPaint = !1;
179 if (isMessageLoopRunning) {
180 var currentTime = getCurrentTime();
181 startTime = currentTime;
182 var hasMoreWork = !0;
183 try {
184 a: {
185 isHostCallbackScheduled = !1;
186 isHostTimeoutScheduled &&
187 ((isHostTimeoutScheduled = !1),
188 localClearTimeout(taskTimeoutID),
189 (taskTimeoutID = -1));
190 isPerformingWork = !0;
191 var previousPriorityLevel = currentPriorityLevel;
192 try {
193 b: {
194 advanceTimers(currentTime);
195 for (
196 currentTask = peek(taskQueue);
197 null !== currentTask &&
198 !(
199 currentTask.expirationTime > currentTime && shouldYieldToHost()
200 );
201
202 ) {
203 var callback = currentTask.callback;
204 if ("function" === typeof callback) {
205 currentTask.callback = null;
206 currentPriorityLevel = currentTask.priorityLevel;
207 var continuationCallback = callback(
208 currentTask.expirationTime <= currentTime
209 );
210 currentTime = getCurrentTime();
211 if ("function" === typeof continuationCallback) {
212 currentTask.callback = continuationCallback;
213 advanceTimers(currentTime);
214 hasMoreWork = !0;
215 break b;
216 }
217 currentTask === peek(taskQueue) && pop(taskQueue);
218 advanceTimers(currentTime);
219 } else pop(taskQueue);
220 currentTask = peek(taskQueue);
221 }
222 if (null !== currentTask) hasMoreWork = !0;
223 else {
224 var firstTimer = peek(timerQueue);
225 null !== firstTimer &&
226 requestHostTimeout(
227 handleTimeout,
228 firstTimer.startTime - currentTime
229 );
230 hasMoreWork = !1;
231 }
232 }
233 break a;
234 } finally {
235 (currentTask = null),
236 (currentPriorityLevel = previousPriorityLevel),
237 (isPerformingWork = !1);
238 }
239 hasMoreWork = void 0;
240 }
241 } finally {
242 hasMoreWork
243 ? schedulePerformWorkUntilDeadline()
244 : (isMessageLoopRunning = !1);
245 }
246 }
247}
248var schedulePerformWorkUntilDeadline;
249if ("function" === typeof localSetImmediate)
250 schedulePerformWorkUntilDeadline = function () {
251 localSetImmediate(performWorkUntilDeadline);
252 };
253else if ("undefined" !== typeof MessageChannel) {
254 var channel = new MessageChannel(),
255 port = channel.port2;
256 channel.port1.onmessage = performWorkUntilDeadline;
257 schedulePerformWorkUntilDeadline = function () {
258 port.postMessage(null);
259 };
260} else
261 schedulePerformWorkUntilDeadline = function () {
262 localSetTimeout(performWorkUntilDeadline, 0);
263 };
264function requestHostTimeout(callback, ms) {
265 taskTimeoutID = localSetTimeout(function () {
266 callback(getCurrentTime());
267 }, ms);
268}
269var unstable_UserBlockingPriority =
270 "undefined" !== typeof nativeRuntimeScheduler
271 ? nativeRuntimeScheduler.unstable_UserBlockingPriority
272 : 2,
273 unstable_NormalPriority =
274 "undefined" !== typeof nativeRuntimeScheduler
275 ? nativeRuntimeScheduler.unstable_NormalPriority
276 : 3,
277 unstable_LowPriority =
278 "undefined" !== typeof nativeRuntimeScheduler
279 ? nativeRuntimeScheduler.unstable_LowPriority
280 : 4,
281 unstable_ImmediatePriority =
282 "undefined" !== typeof nativeRuntimeScheduler
283 ? nativeRuntimeScheduler.unstable_ImmediatePriority
284 : 1,
285 unstable_scheduleCallback =
286 "undefined" !== typeof nativeRuntimeScheduler
287 ? nativeRuntimeScheduler.unstable_scheduleCallback
288 : unstable_scheduleCallback$1,
289 unstable_cancelCallback =
290 "undefined" !== typeof nativeRuntimeScheduler
291 ? nativeRuntimeScheduler.unstable_cancelCallback
292 : unstable_cancelCallback$1,
293 unstable_getCurrentPriorityLevel =
294 "undefined" !== typeof nativeRuntimeScheduler
295 ? nativeRuntimeScheduler.unstable_getCurrentPriorityLevel
296 : unstable_getCurrentPriorityLevel$1,
297 unstable_shouldYield =
298 "undefined" !== typeof nativeRuntimeScheduler
299 ? nativeRuntimeScheduler.unstable_shouldYield
300 : shouldYieldToHost,
301 unstable_requestPaint =
302 "undefined" !== typeof nativeRuntimeScheduler
303 ? nativeRuntimeScheduler.unstable_requestPaint
304 : requestPaint,
305 unstable_now =
306 "undefined" !== typeof nativeRuntimeScheduler
307 ? nativeRuntimeScheduler.unstable_now
308 : getCurrentTime;
309function throwNotImplemented() {
310 throw Error("Not implemented.");
311}
312exports.unstable_IdlePriority =
313 "undefined" !== typeof nativeRuntimeScheduler
314 ? nativeRuntimeScheduler.unstable_IdlePriority
315 : 5;
316exports.unstable_ImmediatePriority = unstable_ImmediatePriority;
317exports.unstable_LowPriority = unstable_LowPriority;
318exports.unstable_NormalPriority = unstable_NormalPriority;
319exports.unstable_Profiling = null;
320exports.unstable_UserBlockingPriority = unstable_UserBlockingPriority;
321exports.unstable_cancelCallback = unstable_cancelCallback;
322exports.unstable_forceFrameRate = throwNotImplemented;
323exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
324exports.unstable_next = throwNotImplemented;
325exports.unstable_now = unstable_now;
326exports.unstable_requestPaint = unstable_requestPaint;
327exports.unstable_runWithPriority = throwNotImplemented;
328exports.unstable_scheduleCallback = unstable_scheduleCallback;
329exports.unstable_shouldYield = unstable_shouldYield;
330exports.unstable_wrapCallback = throwNotImplemented;
Note: See TracBrowser for help on using the repository browser.