From cd58dbd2d6e74b6e2dad6ce50058c293a05a83d0 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Fri, 23 Feb 2024 17:35:59 -0500 Subject: [PATCH] remove stuff --- .../src/internal/client/dom/blocks/each.js | 3 +- .../client/reactivity/computations.js | 19 ++--- packages/svelte/src/internal/client/render.js | 3 +- .../svelte/src/internal/client/runtime.js | 84 ++----------------- .../svelte/src/internal/client/transitions.js | 59 +------------ 5 files changed, 19 insertions(+), 149 deletions(-) diff --git a/packages/svelte/src/internal/client/dom/blocks/each.js b/packages/svelte/src/internal/client/dom/blocks/each.js index 72ca955d72..f7397b2b4e 100644 --- a/packages/svelte/src/internal/client/dom/blocks/each.js +++ b/packages/svelte/src/internal/client/dom/blocks/each.js @@ -23,7 +23,6 @@ import { resume_effect } from '../../reactivity/computations.js'; import { source, mutable_source } from '../../reactivity/sources.js'; -import { trigger_transitions } from '../../transitions.js'; import { is_array } from '../../utils.js'; import { BRANCH_EFFECT, EACH_ITEM_BLOCK } from '../../constants.js'; @@ -621,7 +620,7 @@ export function destroy_each_item_block( if (transitions.size === 0) { block.s = null; } else { - trigger_transitions(transitions, 'out'); + // trigger_transitions(transitions, 'out'); if (transition_block !== null) { transition_block.push(block); } diff --git a/packages/svelte/src/internal/client/reactivity/computations.js b/packages/svelte/src/internal/client/reactivity/computations.js index 01171fd214..7f01774d79 100644 --- a/packages/svelte/src/internal/client/reactivity/computations.js +++ b/packages/svelte/src/internal/client/reactivity/computations.js @@ -1,6 +1,5 @@ import { DEV } from 'esm-env'; import { - current_block, current_component_context, current_consumer, current_effect, @@ -122,7 +121,7 @@ export function user_effect(fn) { EFFECT, fn, false, - current_block, + null, !apply_component_effect_heuristics ); @@ -142,7 +141,7 @@ export function user_effect(fn) { * @returns {() => void} */ export function user_root_effect(fn) { - const effect = internal_create_effect(RENDER_EFFECT | ROOT_EFFECT, fn, true, current_block, true); + const effect = internal_create_effect(RENDER_EFFECT | ROOT_EFFECT, fn, true, null, true); return () => { destroy_effect(effect); }; @@ -153,7 +152,7 @@ export function user_root_effect(fn) { * @returns {import('../types.js').EffectSignal} */ export function effect(fn) { - return internal_create_effect(EFFECT, fn, false, current_block, true); + return internal_create_effect(EFFECT, fn, false, null, true); } /** @@ -161,7 +160,7 @@ export function effect(fn) { * @returns {import('../types.js').EffectSignal} */ export function managed_effect(fn) { - return internal_create_effect(EFFECT | MANAGED, fn, false, current_block, true); + return internal_create_effect(EFFECT | MANAGED, fn, false, null, true); } /** @@ -170,7 +169,7 @@ export function managed_effect(fn) { * @returns {import('../types.js').EffectSignal} */ export function managed_pre_effect(fn, sync) { - return internal_create_effect(PRE_EFFECT | MANAGED, fn, sync, current_block, true); + return internal_create_effect(PRE_EFFECT | MANAGED, fn, sync, null, true); } /** @@ -196,7 +195,7 @@ export function pre_effect(fn) { return val; }, sync, - current_block, + null, true ); } @@ -209,7 +208,7 @@ export function pre_effect(fn) { * @returns {import('../types.js').EffectSignal} */ export function invalidate_effect(fn) { - return internal_create_effect(PRE_EFFECT, fn, true, current_block, true); + return internal_create_effect(PRE_EFFECT, fn, true, null, true); } /** @@ -220,7 +219,7 @@ export function invalidate_effect(fn) { * @param {any} sync * @returns {import('../types.js').EffectSignal} */ -export function render_effect(fn, block = current_block, managed = false, sync = true) { +export function render_effect(fn, block = null, managed = false, sync = true) { let flags = RENDER_EFFECT; if (managed) { flags |= MANAGED; @@ -238,7 +237,7 @@ export function derived(fn) { const is_unowned = current_effect === null; const flags = is_unowned ? DERIVED | UNOWNED : DERIVED; const signal = /** @type {import('../types.js').ComputationSignal} */ ( - create_computation_signal(flags | CLEAN, UNINITIALIZED, current_block) + create_computation_signal(flags | CLEAN, UNINITIALIZED, null) ); signal.i = fn; signal.e = default_equals; diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index 7646e8988b..1aba0c4ad1 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -49,7 +49,6 @@ import { derived, pre_effect, user_effect, - pause_effect, destroy_effect } from './reactivity/computations.js'; import { @@ -69,7 +68,7 @@ import { object_assign } from './utils.js'; import { run } from '../common.js'; -import { bind_transition, trigger_transitions } from './transitions.js'; +import { bind_transition } from './transitions.js'; import { mutable_source, source } from './reactivity/sources.js'; import { safe_equal, safe_not_equal } from './reactivity/equality.js'; diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index a8437627c9..8e3c9dd6ff 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -100,11 +100,7 @@ export let inspect_fn = null; /** @type {Array} */ let inspect_captured_signals = []; -// Handle rendering tree blocks and anchors -/** @type {null | import('./types.js').Block} */ -export let current_block = null; // Handling runtime component context - /** @type {import('./types.js').ComponentContext | null} */ export let current_component_context = null; @@ -221,7 +217,6 @@ function execute_signal_fn(signal) { const previous_dependencies_index = current_dependencies_index; const previous_untracked_writes = current_untracked_writes; const previous_consumer = current_consumer; - const previous_block = current_block; const previous_component_context = current_component_context; const previous_skip_consumer = current_skip_consumer; const is_render_effect = (flags & RENDER_EFFECT) !== 0; @@ -230,7 +225,6 @@ function execute_signal_fn(signal) { current_dependencies_index = 0; current_untracked_writes = null; current_consumer = signal; - current_block = signal.b; current_component_context = signal.x; current_skip_consumer = !is_flushing_effect && (flags & UNOWNED) !== 0; current_untracking = false; @@ -238,13 +232,10 @@ function execute_signal_fn(signal) { try { let res; if (is_render_effect) { - res = - /** @type {(block: import('./types.js').Block, signal: import('./types.js').Signal) => V} */ ( - init - )( - /** @type {import('./types.js').Block} */ (signal.b), - /** @type {import('./types.js').Signal} */ (signal) - ); + res = /** @type {(block: null, signal: import('./types.js').Signal) => V} */ (init)( + null, + /** @type {import('./types.js').Signal} */ (signal) + ); } else { res = /** @type {() => V} */ (init)(); } @@ -314,7 +305,6 @@ function execute_signal_fn(signal) { current_dependencies_index = previous_dependencies_index; current_untracked_writes = previous_untracked_writes; current_consumer = previous_consumer; - current_block = previous_block; current_component_context = previous_component_context; current_skip_consumer = previous_skip_consumer; current_untracking = previous_untracking; @@ -518,7 +508,7 @@ export function schedule_effect(signal, sync) { // so we can make them inert to avoid having to find them in the // queue and remove them. if ((flags & MANAGED) === 0) { - mark_subtree_children_inert(signal, true); + // mark_subtree_children_inert(signal, true); } } else { // We need to ensure we insert the signal in the right topological order. In other words, @@ -824,70 +814,6 @@ export function mutate(source, value) { return value; } -/** - * @param {import('./types.js').ComputationSignal} signal - * @param {boolean} inert - * @param {Set} [visited_blocks] - * @returns {void} - */ -function mark_subtree_children_inert(signal, inert, visited_blocks) { - const references = signal.r; - if (references !== null) { - let i; - for (i = 0; i < references.length; i++) { - const reference = references[i]; - if ((reference.f & IS_EFFECT) !== 0) { - mark_subtree_inert(reference, inert, visited_blocks); - } - } - } -} - -/** - * @param {import('./types.js').ComputationSignal} signal - * @param {boolean} inert - * @param {Set} [visited_blocks] - * @returns {void} - */ -export function mark_subtree_inert(signal, inert, visited_blocks = new Set()) { - const flags = signal.f; - const is_already_inert = (flags & INERT) !== 0; - if (is_already_inert !== inert) { - signal.f ^= INERT; - if (!inert && (flags & IS_EFFECT) !== 0 && (flags & CLEAN) === 0) { - schedule_effect(/** @type {import('./types.js').EffectSignal} */ (signal), false); - } - // Nested if block effects - const block = signal.b; - if (block !== null && !visited_blocks.has(block)) { - visited_blocks.add(block); - const type = block.t; - if (type === IF_BLOCK) { - const condition_effect = block.e; - if (condition_effect !== null && block !== current_block) { - mark_subtree_inert(condition_effect, inert, visited_blocks); - } - const consequent_effect = block.ce; - if (consequent_effect !== null && block.v) { - mark_subtree_inert(consequent_effect, inert, visited_blocks); - } - const alternate_effect = block.ae; - if (alternate_effect !== null && !block.v) { - mark_subtree_inert(alternate_effect, inert, visited_blocks); - } - } else if (type === EACH_BLOCK) { - const items = block.v; - for (let { e: each_item_effect } of items) { - if (each_item_effect !== null) { - mark_subtree_inert(each_item_effect, inert, visited_blocks); - } - } - } - } - } - mark_subtree_children_inert(signal, inert, visited_blocks); -} - /** * @template V * @param {import('./types.js').Signal} signal diff --git a/packages/svelte/src/internal/client/transitions.js b/packages/svelte/src/internal/client/transitions.js index 5235e75272..045121e634 100644 --- a/packages/svelte/src/internal/client/transitions.js +++ b/packages/svelte/src/internal/client/transitions.js @@ -1,11 +1,8 @@ -import { noop, run_all } from '../common.js'; -import { destroy_each_item_block, get_first_element } from './dom/blocks/each.js'; -import { schedule_raf_task } from './dom/task.js'; +import { noop } from '../common.js'; import { loop } from './loop.js'; -import { append_child, empty } from './operations.js'; -import { managed_effect, managed_pre_effect, user_effect } from './reactivity/computations.js'; +import { user_effect } from './reactivity/computations.js'; import { run_transitions } from './render.js'; -import { current_effect, destroy_signal, mark_subtree_inert, untrack } from './runtime.js'; +import { current_effect, untrack } from './runtime.js'; import { raf } from './timing.js'; const active_tick_animations = new Set(); @@ -376,53 +373,3 @@ export function bind_transition(element, get_fn, get_params, direction, global) (effect.out ??= []).push(transition); } } - -/** - * @param {Set} transitions - * @param {'in' | 'out' | 'key'} target_direction - * @param {DOMRect} [from] - * @returns {void} - */ -export function trigger_transitions(transitions, target_direction, from) { - /** @type {Array<() => void>} */ - const outros = []; - for (const transition of transitions) { - const direction = transition.r; - const effect = transition.e; - if (target_direction === 'in') { - if (direction === 'in' || direction === 'both') { - transition.in(); - } else { - transition.c(); - } - transition.d.inert = false; - mark_subtree_inert(effect, false); - } else if (target_direction === 'key') { - if (direction === 'key') { - if (!transition.p) { - transition.p = transition.i(/** @type {DOMRect} */ (from)); - } - transition.in(); - } - } else { - if (direction === 'out' || direction === 'both') { - if (!transition.p) { - transition.p = transition.i(); - } - outros.push(transition.o); - } - transition.d.inert = true; - mark_subtree_inert(effect, true); - } - } - if (outros.length > 0) { - // Defer the outros to a microtask - const e = managed_pre_effect(() => { - destroy_signal(e); - const e2 = managed_effect(() => { - destroy_signal(e2); - run_all(outros); - }); - }, false); - } -}