diff --git a/packages/svelte/src/internal/client/constants.js b/packages/svelte/src/internal/client/constants.js index 07c062adcb..cda8cf9eef 100644 --- a/packages/svelte/src/internal/client/constants.js +++ b/packages/svelte/src/internal/client/constants.js @@ -13,13 +13,5 @@ export const DESTROYED = 1 << 12; export const ROOT_EFFECT = 1 << 13; export const BRANCH_EFFECT = 1 << 14; -export const IF_BLOCK = 1; -export const EACH_BLOCK = 2; -export const EACH_ITEM_BLOCK = 3; -export const HEAD_BLOCK = 6; -export const DYNAMIC_COMPONENT_BLOCK = 7; -export const DYNAMIC_ELEMENT_BLOCK = 8; -export const SNIPPET_BLOCK = 9; - export const UNINITIALIZED = Symbol(); export const STATE_SYMBOL = Symbol('$state'); diff --git a/packages/svelte/src/internal/client/dom/blocks/each.js b/packages/svelte/src/internal/client/dom/blocks/each.js index c6212f3513..867b347d48 100644 --- a/packages/svelte/src/internal/client/dom/blocks/each.js +++ b/packages/svelte/src/internal/client/dom/blocks/each.js @@ -15,7 +15,7 @@ import { } from '../../hydration.js'; import { empty, map_get, map_set } from '../../operations.js'; import { insert, remove } from '../../reconciler.js'; -import { destroy_signal, set_signal_value } from '../../runtime.js'; +import { set_signal_value } from '../../runtime.js'; import { destroy_effect, pause_effect, @@ -24,44 +24,12 @@ import { } from '../../reactivity/computations.js'; import { source, mutable_source } from '../../reactivity/sources.js'; import { is_array } from '../../utils.js'; -import { BRANCH_EFFECT, EACH_ITEM_BLOCK } from '../../constants.js'; +import { BRANCH_EFFECT } from '../../constants.js'; const NEW_BLOCK = -1; const MOVED_BLOCK = 99999999; const LIS_BLOCK = -2; -/** - * @param {any | import('../../types.js').Signal} item - * @param {number | import('../../types.js').Signal} index - * @param {null | unknown} key - * @returns {import('../../types.js').EachItemBlock} - */ -export function create_each_item_block(item, index, key) { - return { - // animate transition - a: null, - // dom - d: null, - // effect - // @ts-expect-error - e: null, - // index - i: index, - // key - k: key, - // item - v: item, - // parent - p: null, - // transition - r: null, - // transitions - s: null, - // type - t: EACH_ITEM_BLOCK - }; -} - /** * Reconcile arrays by the equality of the elements in the array. This algorithm * is based on Ivi's reconcilation logic: @@ -580,12 +548,14 @@ function update_each_item_block(block, item, index, type) { if ((type & EACH_ITEM_REACTIVE) !== 0) { set_signal_value(block_v, item); } - const transitions = block.s; + // const transitions = block.s; + const transitions = null; const index_is_reactive = (type & EACH_INDEX_REACTIVE) !== 0; // Handle each item animations - const each_animation = block.a; + // const each_animation = block.a; + const each_animation = null; if (transitions !== null && (type & EACH_KEYED) !== 0 && each_animation !== null) { - each_animation(block, transitions); + // each_animation(block, transitions); } if (index_is_reactive) { set_signal_value(/** @type {import('../../types.js').Signal} */ (block.i), index); @@ -613,12 +583,19 @@ function each_item_block(item, key, index, render_fn, flags) { : mutable_source(item); const index_value = (flags & EACH_INDEX_REACTIVE) === 0 ? index : source(index); - const block = create_each_item_block(item_value, index_value, key); - const effect = render_effect(() => { + /** @type {import('../../types.js').EachItemBlock} */ + const block = { + // @ts-expect-error + e: null, + i: index_value, + k: key, + v: item_value + }; + + block.e = render_effect(() => { render_fn(null, block.v, block.i); }, true); - block.e = effect; return block; } diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index baf3bb4ae5..7322f75fda 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -11,8 +11,6 @@ import { import { unstate } from './proxy.js'; import { pre_effect } from './reactivity/computations.js'; import { - EACH_BLOCK, - IF_BLOCK, EFFECT, PRE_EFFECT, RENDER_EFFECT, diff --git a/packages/svelte/src/internal/client/types.d.ts b/packages/svelte/src/internal/client/types.d.ts index 3e8f3c2b8a..ffc4bbbf1c 100644 --- a/packages/svelte/src/internal/client/types.d.ts +++ b/packages/svelte/src/internal/client/types.d.ts @@ -1,18 +1,4 @@ -import { - DERIVED, - EFFECT, - RENDER_EFFECT, - SOURCE, - PRE_EFFECT, - EACH_BLOCK, - EACH_ITEM_BLOCK, - IF_BLOCK, - HEAD_BLOCK, - DYNAMIC_COMPONENT_BLOCK, - DYNAMIC_ELEMENT_BLOCK, - SNIPPET_BLOCK, - STATE_SYMBOL -} from './constants.js'; +import { DERIVED, EFFECT, RENDER_EFFECT, SOURCE, PRE_EFFECT, STATE_SYMBOL } from './constants.js'; // Put all internal types in this file. Once we convert to JSDoc, we can make this a d.ts file @@ -136,15 +122,6 @@ export type UnwrappedSignal = T extends Signal ? U : T; export type EqualsFunctions = (a: T, v: T) => boolean; -export type BlockType = - | typeof EACH_BLOCK - | typeof EACH_ITEM_BLOCK - | typeof IF_BLOCK - | typeof SNIPPET_BLOCK - | typeof HEAD_BLOCK - | typeof DYNAMIC_COMPONENT_BLOCK - | typeof DYNAMIC_ELEMENT_BLOCK; - export type TemplateNode = Text | Element | Comment; export type Transition = { @@ -170,10 +147,6 @@ export type Transition = { }; export type EachItemBlock = { - /** transition */ - a: null | ((block: EachItemBlock, transitions: Set) => void); - /** dom */ - d: null | TemplateNode | Array; /** effect */ e: ComputationSignal; /** item */ @@ -182,14 +155,6 @@ export type EachItemBlock = { i: number | Signal; /** key */ k: unknown; - /** parent */ - p: null; - /** transition */ - r: null | ((transition: Transition) => void); - /** transitions */ - s: null | Set; - /** type */ - t: typeof EACH_ITEM_BLOCK; }; export type Block = EachItemBlock;