remove more stuff

blockless
Rich Harris 2 years ago
parent 4052310fa5
commit c431330fcb

@ -13,13 +13,5 @@ export const DESTROYED = 1 << 12;
export const ROOT_EFFECT = 1 << 13; export const ROOT_EFFECT = 1 << 13;
export const BRANCH_EFFECT = 1 << 14; 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 UNINITIALIZED = Symbol();
export const STATE_SYMBOL = Symbol('$state'); export const STATE_SYMBOL = Symbol('$state');

@ -15,7 +15,7 @@ import {
} from '../../hydration.js'; } from '../../hydration.js';
import { empty, map_get, map_set } from '../../operations.js'; import { empty, map_get, map_set } from '../../operations.js';
import { insert, remove } from '../../reconciler.js'; import { insert, remove } from '../../reconciler.js';
import { destroy_signal, set_signal_value } from '../../runtime.js'; import { set_signal_value } from '../../runtime.js';
import { import {
destroy_effect, destroy_effect,
pause_effect, pause_effect,
@ -24,44 +24,12 @@ import {
} from '../../reactivity/computations.js'; } from '../../reactivity/computations.js';
import { source, mutable_source } from '../../reactivity/sources.js'; import { source, mutable_source } from '../../reactivity/sources.js';
import { is_array } from '../../utils.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 NEW_BLOCK = -1;
const MOVED_BLOCK = 99999999; const MOVED_BLOCK = 99999999;
const LIS_BLOCK = -2; const LIS_BLOCK = -2;
/**
* @param {any | import('../../types.js').Signal<any>} item
* @param {number | import('../../types.js').Signal<number>} 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 * Reconcile arrays by the equality of the elements in the array. This algorithm
* is based on Ivi's reconcilation logic: * 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) { if ((type & EACH_ITEM_REACTIVE) !== 0) {
set_signal_value(block_v, item); 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; const index_is_reactive = (type & EACH_INDEX_REACTIVE) !== 0;
// Handle each item animations // 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) { if (transitions !== null && (type & EACH_KEYED) !== 0 && each_animation !== null) {
each_animation(block, transitions); // each_animation(block, transitions);
} }
if (index_is_reactive) { if (index_is_reactive) {
set_signal_value(/** @type {import('../../types.js').Signal<number>} */ (block.i), index); set_signal_value(/** @type {import('../../types.js').Signal<number>} */ (block.i), index);
@ -613,12 +583,19 @@ function each_item_block(item, key, index, render_fn, flags) {
: mutable_source(item); : mutable_source(item);
const index_value = (flags & EACH_INDEX_REACTIVE) === 0 ? index : source(index); 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); render_fn(null, block.v, block.i);
}, true); }, true);
block.e = effect;
return block; return block;
} }

@ -11,8 +11,6 @@ import {
import { unstate } from './proxy.js'; import { unstate } from './proxy.js';
import { pre_effect } from './reactivity/computations.js'; import { pre_effect } from './reactivity/computations.js';
import { import {
EACH_BLOCK,
IF_BLOCK,
EFFECT, EFFECT,
PRE_EFFECT, PRE_EFFECT,
RENDER_EFFECT, RENDER_EFFECT,

@ -1,18 +1,4 @@
import { import { DERIVED, EFFECT, RENDER_EFFECT, SOURCE, PRE_EFFECT, STATE_SYMBOL } from './constants.js';
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';
// Put all internal types in this file. Once we convert to JSDoc, we can make this a d.ts file // 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> = T extends Signal<infer U> ? U : T;
export type EqualsFunctions<T = any> = (a: T, v: T) => boolean; export type EqualsFunctions<T = any> = (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 TemplateNode = Text | Element | Comment;
export type Transition = { export type Transition = {
@ -170,10 +147,6 @@ export type Transition = {
}; };
export type EachItemBlock = { export type EachItemBlock = {
/** transition */
a: null | ((block: EachItemBlock, transitions: Set<Transition>) => void);
/** dom */
d: null | TemplateNode | Array<TemplateNode>;
/** effect */ /** effect */
e: ComputationSignal; e: ComputationSignal;
/** item */ /** item */
@ -182,14 +155,6 @@ export type EachItemBlock = {
i: number | Signal<number>; i: number | Signal<number>;
/** key */ /** key */
k: unknown; k: unknown;
/** parent */
p: null;
/** transition */
r: null | ((transition: Transition) => void);
/** transitions */
s: null | Set<Transition>;
/** type */
t: typeof EACH_ITEM_BLOCK;
}; };
export type Block = EachItemBlock; export type Block = EachItemBlock;

Loading…
Cancel
Save