|
|
@ -49,6 +49,19 @@ export let batch_deriveds = null;
|
|
|
|
/** @type {Set<() => void>} */
|
|
|
|
/** @type {Set<() => void>} */
|
|
|
|
export let effect_pending_updates = new Set();
|
|
|
|
export let effect_pending_updates = new Set();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {Array<() => void>} */
|
|
|
|
|
|
|
|
let tasks = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dequeue() {
|
|
|
|
|
|
|
|
const task = /** @type {() => void} */ (tasks.shift());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (tasks.length > 0) {
|
|
|
|
|
|
|
|
queueMicrotask(dequeue);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
task();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {Effect[]} */
|
|
|
|
/** @type {Effect[]} */
|
|
|
|
let queued_root_effects = [];
|
|
|
|
let queued_root_effects = [];
|
|
|
|
|
|
|
|
|
|
|
@ -438,7 +451,7 @@ export class Batch {
|
|
|
|
batches.add(current_batch);
|
|
|
|
batches.add(current_batch);
|
|
|
|
|
|
|
|
|
|
|
|
if (autoflush) {
|
|
|
|
if (autoflush) {
|
|
|
|
queueMicrotask(() => {
|
|
|
|
Batch.enqueue(() => {
|
|
|
|
if (current_batch !== batch) {
|
|
|
|
if (current_batch !== batch) {
|
|
|
|
// a flushSync happened in the meantime
|
|
|
|
// a flushSync happened in the meantime
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -451,6 +464,15 @@ export class Batch {
|
|
|
|
|
|
|
|
|
|
|
|
return current_batch;
|
|
|
|
return current_batch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @param {() => void} task */
|
|
|
|
|
|
|
|
static enqueue(task) {
|
|
|
|
|
|
|
|
if (tasks.length === 0) {
|
|
|
|
|
|
|
|
queueMicrotask(dequeue);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tasks.unshift(task);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -593,7 +615,11 @@ export function suspend() {
|
|
|
|
|
|
|
|
|
|
|
|
return function unsuspend() {
|
|
|
|
return function unsuspend() {
|
|
|
|
boundary.update_pending_count(-1);
|
|
|
|
boundary.update_pending_count(-1);
|
|
|
|
if (!pending) batch.decrement();
|
|
|
|
|
|
|
|
|
|
|
|
if (!pending) {
|
|
|
|
|
|
|
|
batch.activate();
|
|
|
|
|
|
|
|
batch.decrement();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unset_context();
|
|
|
|
unset_context();
|
|
|
|
};
|
|
|
|
};
|
|
|
|