delete delete delete

pull/10798/head
Rich Harris 2 years ago
parent 43e6e9d8ce
commit fbf8308b80

@ -11,16 +11,6 @@ export const INERT = 1 << 11;
export const DESTROYED = 1 << 12;
export const IS_ELSEIF = 1 << 13;
export const ROOT_BLOCK = 0;
export const IF_BLOCK = 1;
export const EACH_BLOCK = 2;
export const EACH_ITEM_BLOCK = 3;
export const AWAIT_BLOCK = 4;
export const HEAD_BLOCK = 6;
export const DYNAMIC_COMPONENT_BLOCK = 7;
export const DYNAMIC_ELEMENT_BLOCK = 8;
export const SNIPPET_BLOCK = 9;
export const TRANSITION_IN = 1 << 1;
export const TRANSITION_OUT = 1 << 2;
export const TRANSITION_GLOBAL = 1 << 3;

@ -4,7 +4,7 @@ import { remove } from '../reconciler.js';
import { current_block, execute_effect, flushSync } from '../../runtime.js';
import { destroy_effect, render_effect } from '../../reactivity/effects.js';
import { trigger_transitions } from '../elements/transitions.js';
import { AWAIT_BLOCK, UNINITIALIZED } from '../../constants.js';
import { UNINITIALIZED } from '../../constants.js';
/** @returns {import('../../types.js').AwaitBlock} */
export function create_await_block() {
@ -16,11 +16,7 @@ export function create_await_block() {
// parent
p: /** @type {import('../../types.js').Block} */ (current_block),
// pending
n: true,
// transition
r: null,
// type
t: AWAIT_BLOCK
n: true
};
}
@ -49,31 +45,7 @@ export function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
/** @type {unknown} */
let error = UNINITIALIZED;
let pending = false;
block.r =
/**
* @param {import('../../types.js').Transition} transition
* @returns {void}
*/
(transition) => {
const render = /** @type {import('../../types.js').Render} */ (current_render);
const transitions = render.s;
transitions.add(transition);
transition.f(() => {
transitions.delete(transition);
if (transitions.size === 0) {
// If the current render has changed since, then we can remove the old render
// effect as it's stale.
if (current_render !== render && render.e !== null) {
if (render.d !== null) {
remove(render.d);
render.d = null;
}
destroy_effect(render.e);
render.e = null;
}
}
});
};
const create_render_effect = () => {
/** @type {import('../../types.js').Render} */
const render = {

@ -26,7 +26,7 @@ import {
import { source, mutable_source, set } from '../../reactivity/sources.js';
import { trigger_transitions } from '../elements/transitions.js';
import { is_array, is_frozen, map_get, map_set } from '../../utils.js';
import { EACH_BLOCK, EACH_ITEM_BLOCK, STATE_SYMBOL } from '../../constants.js';
import { STATE_SYMBOL } from '../../constants.js';
const NEW_BLOCK = -1;
const MOVED_BLOCK = 99999999;
@ -58,13 +58,7 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
v: [],
// effect
e: null,
p: /** @type {import('#client').Block} */ (current_block),
// transition
r: null,
// transitions
s: [],
// type
t: EACH_BLOCK
p: /** @type {import('#client').Block} */ (current_block)
};
hydrate_block_anchor(anchor_node, is_controlled);
@ -759,7 +753,7 @@ export function destroy_each_item_block(
) {
const transitions = block.s;
if (apply_transitions && transitions !== null) {
if (apply_transitions && transitions != null) {
// We might have pending key transitions, if so remove them first
for (let other of transitions) {
if (other.r === 'key') {
@ -817,13 +811,7 @@ function each_item_block(item, key, index, render_fn, flags) {
// item
v: item_value,
// parent
p: /** @type {import('#client').EachBlock} */ (current_block),
// transition
r: null,
// transitions
s: null,
// type
t: EACH_ITEM_BLOCK
p: /** @type {import('#client').EachBlock} */ (current_block)
};
block.e = render_effect(

@ -1,4 +1,4 @@
import { IF_BLOCK, IS_ELSEIF, UNINITIALIZED } from '../../constants.js';
import { IS_ELSEIF } from '../../constants.js';
import {
current_hydration_fragment,
hydrate_block_anchor,
@ -23,10 +23,6 @@ function create_if_block() {
e: null,
// parent
p: /** @type {import('#client').Block} */ (current_block),
// transition
r: null,
// type
t: IF_BLOCK,
// value
v: false
};

@ -1,4 +1,3 @@
import { SNIPPET_BLOCK } from '../../constants.js';
import { render_effect } from '../../reactivity/effects.js';
import { remove } from '../reconciler.js';
import { current_block, untrack } from '../../runtime.js';
@ -17,11 +16,7 @@ export function snippet(get_snippet, node, ...args) {
// parent
p: /** @type {import('#client').Block} */ (current_block),
// effect
e: null,
// transition
r: null,
// type
t: SNIPPET_BLOCK
e: null
};
render_effect(() => {

@ -1,4 +1,3 @@
import { DYNAMIC_COMPONENT_BLOCK } from '../../constants.js';
import { hydrate_block_anchor } from '../hydration.js';
import { destroy_effect, render_effect } from '../../reactivity/effects.js';
import { remove } from '../reconciler.js';
@ -20,11 +19,7 @@ export function component(anchor_node, component_fn, render_fn) {
// effect
e: null,
// parent
p: /** @type {import('#client').Block} */ (current_block),
// transition
r: null,
// type
t: DYNAMIC_COMPONENT_BLOCK
p: /** @type {import('#client').Block} */ (current_block)
};
/** @type {null | import('#client').Render} */
@ -34,32 +29,6 @@ export function component(anchor_node, component_fn, render_fn) {
/** @type {null | ((props: P) => void)} */
let component = null;
block.r =
/**
* @param {import('#client').Transition} transition
* @returns {void}
*/
(transition) => {
const render = /** @type {import('#client').Render} */ (current_render);
const transitions = render.s;
transitions.add(transition);
transition.f(() => {
transitions.delete(transition);
if (transitions.size === 0) {
// If the current render has changed since, then we can remove the old render
// effect as it's stale.
if (current_render !== render && render.e !== null) {
if (render.d !== null) {
remove(render.d);
render.d = null;
}
destroy_effect(render.e);
render.e = null;
}
}
});
};
const create_render_effect = () => {
/** @type {import('#client').Render} */
const render = {

@ -1,5 +1,4 @@
import { namespace_svg } from '../../../../constants.js';
import { DYNAMIC_ELEMENT_BLOCK } from '../../constants.js';
import { current_hydration_fragment, hydrate_block_anchor, hydrating } from '../hydration.js';
import { empty } from '../operations.js';
import { destroy_effect, render_effect } from '../../reactivity/effects.js';
@ -42,11 +41,7 @@ export function element(anchor_node, tag_fn, is_svg, render_fn) {
// effect
e: null,
// parent
p: /** @type {import('#client').Block} */ (current_block),
// transition
r: null,
// type
t: DYNAMIC_ELEMENT_BLOCK
p: /** @type {import('#client').Block} */ (current_block)
};
hydrate_block_anchor(anchor_node);

@ -1,4 +1,3 @@
import { HEAD_BLOCK } from '../../constants.js';
import {
current_hydration_fragment,
get_hydration_fragment,
@ -22,11 +21,7 @@ export function head(render_fn) {
// effect
e: null,
// parent
p: /** @type {import('#client').Block} */ (current_block),
// transition
r: null,
// type
t: HEAD_BLOCK
p: /** @type {import('#client').Block} */ (current_block)
};
// The head function may be called after the first hydration pass and ssr comment nodes may still be present,

@ -12,7 +12,6 @@ import {
set_current_hydration_fragment
} from './dom/hydration.js';
import { array_from } from './utils.js';
import { ROOT_BLOCK } from './constants.js';
import { handle_event_propagation } from './dom/elements/events.js';
/** @type {Set<string>} */
@ -211,11 +210,7 @@ function _mount(Component, options) {
// intro
i: options.intro || false,
// parent
p: null,
// transition
r: null,
// type
t: ROOT_BLOCK
p: null
};
/** @type {Exports} */

@ -1,15 +1,4 @@
import {
ROOT_BLOCK,
EACH_BLOCK,
EACH_ITEM_BLOCK,
IF_BLOCK,
AWAIT_BLOCK,
HEAD_BLOCK,
DYNAMIC_COMPONENT_BLOCK,
DYNAMIC_ELEMENT_BLOCK,
SNIPPET_BLOCK,
STATE_SYMBOL
} from './constants.js';
import { STATE_SYMBOL } from './constants.js';
import type { Effect, Source, Value } from './reactivity/types.js';
type EventCallback = (event: Event) => boolean;
@ -58,17 +47,6 @@ export type ComponentContext = {
export type Equals = (this: Value, value: unknown) => boolean;
export type BlockType =
| typeof ROOT_BLOCK
| typeof EACH_BLOCK
| typeof EACH_ITEM_BLOCK
| typeof IF_BLOCK
| typeof AWAIT_BLOCK
| typeof SNIPPET_BLOCK
| typeof HEAD_BLOCK
| typeof DYNAMIC_COMPONENT_BLOCK
| typeof DYNAMIC_ELEMENT_BLOCK;
export type TemplateNode = Text | Element | Comment;
export type Transition = {
@ -102,10 +80,6 @@ export type RootBlock = {
i: boolean;
/** parent */
p: null;
/** transition */
r: null | ((transition: Transition) => void);
/** type */
t: typeof ROOT_BLOCK;
};
export type IfBlock = {
@ -117,10 +91,6 @@ export type IfBlock = {
e: null | Effect;
/** parent */
p: Block;
/** transition */
r: null | ((transition: Transition) => void);
/** type */
t: typeof IF_BLOCK;
};
export type HeadBlock = {
@ -130,10 +100,6 @@ export type HeadBlock = {
e: null | Effect;
/** parent */
p: Block;
/** transition */
r: null | ((transition: Transition) => void);
/** type */
t: typeof HEAD_BLOCK;
};
export type DynamicElementBlock = {
@ -143,10 +109,6 @@ export type DynamicElementBlock = {
e: null | Effect;
/** parent */
p: Block;
/** transition */
r: null | ((transition: Transition) => void);
/** type */
t: typeof DYNAMIC_ELEMENT_BLOCK;
};
export type DynamicComponentBlock = {
@ -156,10 +118,6 @@ export type DynamicComponentBlock = {
e: null | Effect;
/** parent */
p: Block;
/** transition */
r: null | ((transition: Transition) => void);
/** type */
t: typeof DYNAMIC_COMPONENT_BLOCK;
};
export type AwaitBlock = {
@ -171,10 +129,6 @@ export type AwaitBlock = {
p: Block;
/** pending */
n: boolean;
/** transition */
r: null | ((transition: Transition) => void);
/** type */
t: typeof AWAIT_BLOCK;
};
export type EachBlock = {
@ -190,12 +144,6 @@ export type EachBlock = {
e: null | Effect;
/** parent */
p: Block;
/** transition */
r: null | ((transition: Transition) => void);
/** transitions */
s: Array<EachItemBlock>;
/** type */
t: typeof EACH_BLOCK;
};
export type EachItemBlock = {
@ -213,12 +161,6 @@ export type EachItemBlock = {
k: unknown;
/** parent */
p: EachBlock;
/** transition */
r: null | ((transition: Transition) => void);
/** transitions */
s: null | Set<Transition>;
/** type */
t: typeof EACH_ITEM_BLOCK;
};
export type SnippetBlock = {
@ -228,10 +170,6 @@ export type SnippetBlock = {
p: Block;
/** effect */
e: null | Effect;
/** transition */
r: null;
/** type */
t: typeof SNIPPET_BLOCK;
};
export type Block =

Loading…
Cancel
Save