|
|
@ -38,6 +38,7 @@ let current_scheduler_mode = FLUSH_MICROTASK;
|
|
|
|
// Used for handling scheduling
|
|
|
|
// Used for handling scheduling
|
|
|
|
let is_micro_task_queued = false;
|
|
|
|
let is_micro_task_queued = false;
|
|
|
|
let is_task_queued = false;
|
|
|
|
let is_task_queued = false;
|
|
|
|
|
|
|
|
let is_raf_queued = false;
|
|
|
|
// Used for $inspect
|
|
|
|
// Used for $inspect
|
|
|
|
export let is_batching_effect = false;
|
|
|
|
export let is_batching_effect = false;
|
|
|
|
|
|
|
|
|
|
|
@ -52,7 +53,7 @@ let current_queued_effects = [];
|
|
|
|
/** @type {Array<() => void>} */
|
|
|
|
/** @type {Array<() => void>} */
|
|
|
|
let current_queued_tasks = [];
|
|
|
|
let current_queued_tasks = [];
|
|
|
|
/** @type {Array<() => void>} */
|
|
|
|
/** @type {Array<() => void>} */
|
|
|
|
let current_queued_microtasks = [];
|
|
|
|
let current_raf_tasks = [];
|
|
|
|
let flush_count = 0;
|
|
|
|
let flush_count = 0;
|
|
|
|
// Handle signal reactivity tree dependencies and consumer
|
|
|
|
// Handle signal reactivity tree dependencies and consumer
|
|
|
|
|
|
|
|
|
|
|
@ -586,11 +587,6 @@ function flush_queued_effects(effects) {
|
|
|
|
|
|
|
|
|
|
|
|
function process_microtask() {
|
|
|
|
function process_microtask() {
|
|
|
|
is_micro_task_queued = false;
|
|
|
|
is_micro_task_queued = false;
|
|
|
|
if (current_queued_microtasks.length > 0) {
|
|
|
|
|
|
|
|
const tasks = current_queued_microtasks.slice();
|
|
|
|
|
|
|
|
current_queued_microtasks = [];
|
|
|
|
|
|
|
|
run_all(tasks);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flush_count > 101) {
|
|
|
|
if (flush_count > 101) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -637,6 +633,13 @@ function process_task() {
|
|
|
|
run_all(tasks);
|
|
|
|
run_all(tasks);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function process_raf_task() {
|
|
|
|
|
|
|
|
is_raf_queued = false;
|
|
|
|
|
|
|
|
const tasks = current_raf_tasks.slice();
|
|
|
|
|
|
|
|
current_raf_tasks = [];
|
|
|
|
|
|
|
|
run_all(tasks);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {() => void} fn
|
|
|
|
* @param {() => void} fn
|
|
|
|
* @returns {void}
|
|
|
|
* @returns {void}
|
|
|
@ -653,12 +656,12 @@ export function schedule_task(fn) {
|
|
|
|
* @param {() => void} fn
|
|
|
|
* @param {() => void} fn
|
|
|
|
* @returns {void}
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function schedule_microtask(fn) {
|
|
|
|
export function schedule_raf_task(fn) {
|
|
|
|
if (!is_micro_task_queued) {
|
|
|
|
if (!is_raf_queued) {
|
|
|
|
is_micro_task_queued = true;
|
|
|
|
is_raf_queued = true;
|
|
|
|
queueMicrotask(process_microtask);
|
|
|
|
requestAnimationFrame(process_raf_task);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
current_queued_microtasks.push(fn);
|
|
|
|
current_raf_tasks.push(fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -721,8 +724,8 @@ export function flushSync(fn) {
|
|
|
|
if (current_queued_pre_and_render_effects.length > 0 || effects.length > 0) {
|
|
|
|
if (current_queued_pre_and_render_effects.length > 0 || effects.length > 0) {
|
|
|
|
flushSync();
|
|
|
|
flushSync();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_micro_task_queued) {
|
|
|
|
if (is_raf_queued) {
|
|
|
|
process_microtask();
|
|
|
|
process_raf_task();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (is_task_queued) {
|
|
|
|
if (is_task_queued) {
|
|
|
|
process_task();
|
|
|
|
process_task();
|
|
|
|