|
|
@ -424,8 +424,7 @@ function infinite_loop_guard() {
|
|
|
|
function flush_queued_root_effects(root_effects) {
|
|
|
|
function flush_queued_root_effects(root_effects) {
|
|
|
|
for (var i = 0; i < root_effects.length; i++) {
|
|
|
|
for (var i = 0; i < root_effects.length; i++) {
|
|
|
|
var signal = root_effects[i];
|
|
|
|
var signal = root_effects[i];
|
|
|
|
var effects = get_nested_effects(signal, RENDER_EFFECT | EFFECT);
|
|
|
|
flush_nested_effects(signal, RENDER_EFFECT | EFFECT);
|
|
|
|
flush_queued_effects(effects);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -438,24 +437,13 @@ function flush_queued_effects(effects) {
|
|
|
|
if (length === 0) return;
|
|
|
|
if (length === 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
infinite_loop_guard();
|
|
|
|
infinite_loop_guard();
|
|
|
|
var previously_flushing_effect = is_flushing_effect;
|
|
|
|
|
|
|
|
is_flushing_effect = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
for (var i = 0; i < length; i++) {
|
|
|
|
var signal = effects[i];
|
|
|
|
var effect = effects[i];
|
|
|
|
|
|
|
|
|
|
|
|
if ((signal.f & (DESTROYED | INERT)) === 0) {
|
|
|
|
if ((effect.f & (DESTROYED | INERT)) === 0 && check_dirtiness(effect)) {
|
|
|
|
if (check_dirtiness(signal)) {
|
|
|
|
execute_effect(effect);
|
|
|
|
execute_effect(signal);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
is_flushing_effect = previously_flushing_effect;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
effects.length = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function process_microtask() {
|
|
|
|
function process_microtask() {
|
|
|
@ -512,69 +500,49 @@ export function schedule_effect(signal) {
|
|
|
|
* @param {import('./types.js').Effect} effect
|
|
|
|
* @param {import('./types.js').Effect} effect
|
|
|
|
* @param {number} filter_flags
|
|
|
|
* @param {number} filter_flags
|
|
|
|
* @param {boolean} shallow
|
|
|
|
* @param {boolean} shallow
|
|
|
|
* @param {import('./types.js').Effect[]} collected_render
|
|
|
|
|
|
|
|
* @param {import('./types.js').Effect[]} collected_user
|
|
|
|
* @param {import('./types.js').Effect[]} collected_user
|
|
|
|
* @returns {void}
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function recursively_collect_effects(
|
|
|
|
function recursively_process_effects(effect, filter_flags, shallow, collected_user) {
|
|
|
|
effect,
|
|
|
|
|
|
|
|
filter_flags,
|
|
|
|
|
|
|
|
shallow,
|
|
|
|
|
|
|
|
collected_render,
|
|
|
|
|
|
|
|
collected_user
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
var effects = effect.effects;
|
|
|
|
var effects = effect.effects;
|
|
|
|
if (effects === null) return;
|
|
|
|
if (effects === null) return;
|
|
|
|
|
|
|
|
|
|
|
|
var render = [];
|
|
|
|
|
|
|
|
var user = [];
|
|
|
|
var user = [];
|
|
|
|
|
|
|
|
|
|
|
|
for (var i = 0; i < effects.length; i++) {
|
|
|
|
for (var i = 0; i < effects.length; i++) {
|
|
|
|
var child = effects[i];
|
|
|
|
var child = effects[i];
|
|
|
|
var flags = child.f;
|
|
|
|
var flags = child.f;
|
|
|
|
|
|
|
|
var is_inactive = (flags & (DESTROYED | INERT)) !== 0;
|
|
|
|
|
|
|
|
if (is_inactive) continue;
|
|
|
|
var is_branch = flags & BRANCH_EFFECT;
|
|
|
|
var is_branch = flags & BRANCH_EFFECT;
|
|
|
|
|
|
|
|
var is_clean = (flags & CLEAN) !== 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (is_branch) {
|
|
|
|
if (is_branch) {
|
|
|
|
// Skip this branch if it's clean
|
|
|
|
// Skip this branch if it's clean
|
|
|
|
if ((flags & CLEAN) !== 0) continue;
|
|
|
|
if (is_clean) continue;
|
|
|
|
set_signal_status(child, CLEAN);
|
|
|
|
set_signal_status(child, CLEAN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ((flags & RENDER_EFFECT) !== 0) {
|
|
|
|
if ((flags & RENDER_EFFECT) !== 0) {
|
|
|
|
if (is_branch) {
|
|
|
|
if (is_branch) {
|
|
|
|
if (shallow) continue;
|
|
|
|
if (shallow) continue;
|
|
|
|
recursively_collect_effects(child, filter_flags, false, collected_render, collected_user);
|
|
|
|
recursively_process_effects(child, filter_flags, false, collected_user);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
render.push(child);
|
|
|
|
if (check_dirtiness(child)) {
|
|
|
|
|
|
|
|
execute_effect(child);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
recursively_process_effects(child, filter_flags, false, collected_user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ((flags & EFFECT) !== 0) {
|
|
|
|
} else if ((flags & EFFECT) !== 0) {
|
|
|
|
if (is_branch) {
|
|
|
|
if (is_branch || is_clean) {
|
|
|
|
if (shallow) continue;
|
|
|
|
if (shallow) continue;
|
|
|
|
recursively_collect_effects(child, filter_flags, false, collected_render, collected_user);
|
|
|
|
recursively_process_effects(child, filter_flags, false, collected_user);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
user.push(child);
|
|
|
|
user.push(child);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (render.length > 0) {
|
|
|
|
|
|
|
|
if ((filter_flags & RENDER_EFFECT) !== 0) {
|
|
|
|
|
|
|
|
collected_render.push(...render);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!shallow) {
|
|
|
|
|
|
|
|
for (i = 0; i < render.length; i++) {
|
|
|
|
|
|
|
|
recursively_collect_effects(
|
|
|
|
|
|
|
|
render[i],
|
|
|
|
|
|
|
|
filter_flags,
|
|
|
|
|
|
|
|
false,
|
|
|
|
|
|
|
|
collected_render,
|
|
|
|
|
|
|
|
collected_user
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (user.length > 0) {
|
|
|
|
if (user.length > 0) {
|
|
|
|
if ((filter_flags & EFFECT) !== 0) {
|
|
|
|
if ((filter_flags & EFFECT) !== 0) {
|
|
|
|
collected_user.push(...user);
|
|
|
|
collected_user.push(...user);
|
|
|
@ -582,7 +550,7 @@ function recursively_collect_effects(
|
|
|
|
|
|
|
|
|
|
|
|
if (!shallow) {
|
|
|
|
if (!shallow) {
|
|
|
|
for (i = 0; i < user.length; i++) {
|
|
|
|
for (i = 0; i < user.length; i++) {
|
|
|
|
recursively_collect_effects(user[i], filter_flags, false, collected_render, collected_user);
|
|
|
|
recursively_process_effects(user[i], filter_flags, false, collected_user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -597,23 +565,26 @@ function recursively_collect_effects(
|
|
|
|
* @param {import('./types.js').Effect} effect
|
|
|
|
* @param {import('./types.js').Effect} effect
|
|
|
|
* @param {number} filter_flags
|
|
|
|
* @param {number} filter_flags
|
|
|
|
* @param {boolean} [shallow]
|
|
|
|
* @param {boolean} [shallow]
|
|
|
|
* @returns {import('./types.js').Effect[]}
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
|
|
|
|
function get_nested_effects(effect, filter_flags, shallow = false) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @type {import("./types.js").Effect[]}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
var render_effects = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @type {import("./types.js").Effect[]}
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
function flush_nested_effects(effect, filter_flags, shallow = false) {
|
|
|
|
|
|
|
|
/** @type {import('#client').Effect[]} */
|
|
|
|
var user_effects = [];
|
|
|
|
var user_effects = [];
|
|
|
|
// When working with custom-elements, the root effects might not have a root
|
|
|
|
|
|
|
|
|
|
|
|
var previously_flushing_effect = is_flushing_effect;
|
|
|
|
|
|
|
|
is_flushing_effect = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
// When working with custom elements, the root effects might not have a root
|
|
|
|
if (effect.effects === null && (effect.f & BRANCH_EFFECT) === 0) {
|
|
|
|
if (effect.effects === null && (effect.f & BRANCH_EFFECT) === 0) {
|
|
|
|
return [effect];
|
|
|
|
flush_queued_effects([effect]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
recursively_process_effects(effect, filter_flags, shallow, user_effects);
|
|
|
|
|
|
|
|
flush_queued_effects(user_effects);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
is_flushing_effect = previously_flushing_effect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
recursively_collect_effects(effect, filter_flags, shallow, render_effects, user_effects);
|
|
|
|
|
|
|
|
return [...render_effects, ...user_effects];
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
@ -621,11 +592,9 @@ function get_nested_effects(effect, filter_flags, shallow = false) {
|
|
|
|
* @returns {void}
|
|
|
|
* @returns {void}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function flush_local_render_effects(effect) {
|
|
|
|
export function flush_local_render_effects(effect) {
|
|
|
|
/**
|
|
|
|
// We are entering a new flush sequence, so ensure counter is reset.
|
|
|
|
* @type {import("./types.js").Effect[]}
|
|
|
|
flush_count = 0;
|
|
|
|
*/
|
|
|
|
flush_nested_effects(effect, RENDER_EFFECT, true);
|
|
|
|
var render_effects = get_nested_effects(effect, RENDER_EFFECT, true);
|
|
|
|
|
|
|
|
flush_queued_effects(render_effects);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|