diff --git a/packages/svelte/src/internal/client/dom/blocks/each.js b/packages/svelte/src/internal/client/dom/blocks/each.js index 867b347d48..61fa587081 100644 --- a/packages/svelte/src/internal/client/dom/blocks/each.js +++ b/packages/svelte/src/internal/client/dom/blocks/each.js @@ -310,10 +310,10 @@ export function each_indexed(anchor_node, collection, flags, render_fn, fallback let length = 0; - /** @type {Array} */ + /** @type {Array} */ let effects = []; - /** @type {import('../../types.js').ComputationSignal | null} */ + /** @type {import('../../types.js').Computation | null} */ let alternate; function truncate() { diff --git a/packages/svelte/src/internal/client/dom/blocks/svelte-component.js b/packages/svelte/src/internal/client/dom/blocks/svelte-component.js index 29c4a4d651..5017d7d922 100644 --- a/packages/svelte/src/internal/client/dom/blocks/svelte-component.js +++ b/packages/svelte/src/internal/client/dom/blocks/svelte-component.js @@ -15,7 +15,7 @@ export function component(anchor_node, component_fn, render_fn) { /** @type {C | null} */ let Component = null; - /** @type {import('../../types.js').ComputationSignal | null} */ + /** @type {import('../../types.js').Computation | null} */ let effect = null; render_effect(() => { diff --git a/packages/svelte/src/internal/client/reactivity/computations.js b/packages/svelte/src/internal/client/reactivity/computations.js index f92db2fcf6..3eab02bf91 100644 --- a/packages/svelte/src/internal/client/reactivity/computations.js +++ b/packages/svelte/src/internal/client/reactivity/computations.js @@ -30,7 +30,7 @@ import { * @param {V} value */ function create_computation_signal(flags, value) { - /** @type {import('../types.js').ComputationSignal} */ + /** @type {import('../types.js').Computation} */ const signal = { c: null, d: null, @@ -55,8 +55,8 @@ function create_computation_signal(flags, value) { } /** - * @param {import('../types.js').ComputationSignal} target_signal - * @param {import('../types.js').ComputationSignal} ref_signal + * @param {import('../types.js').Computation} target_signal + * @param {import('../types.js').Computation} ref_signal * @returns {void} */ export function push_reference(target_signal, ref_signal) { @@ -218,13 +218,13 @@ export function render_effect(fn, managed = false, sync = true) { /** * @template V * @param {() => V} fn - * @returns {import('../types.js').ComputationSignal} + * @returns {import('../types.js').Computation} */ /*#__NO_SIDE_EFFECTS__*/ export function derived(fn) { const is_unowned = current_effect === null; const flags = is_unowned ? DERIVED | UNOWNED : DERIVED; - const signal = /** @type {import('../types.js').ComputationSignal} */ ( + const signal = /** @type {import('../types.js').Computation} */ ( create_computation_signal(flags | CLEAN, UNINITIALIZED) ); signal.i = fn; @@ -238,7 +238,7 @@ export function derived(fn) { /** * @template V * @param {() => V} fn - * @returns {import('../types.js').ComputationSignal} + * @returns {import('../types.js').Computation} */ /*#__NO_SIDE_EFFECTS__*/ export function derived_safe_equal(fn) { @@ -248,7 +248,7 @@ export function derived_safe_equal(fn) { } /** - * @param {import('../types.js').ComputationSignal} effect + * @param {import('../types.js').Computation} effect * @param {() => void} done */ export function pause_effect(effect, done) { diff --git a/packages/svelte/src/internal/client/reactivity/sources.js b/packages/svelte/src/internal/client/reactivity/sources.js index d0b6de7cba..66ef4a64e9 100644 --- a/packages/svelte/src/internal/client/reactivity/sources.js +++ b/packages/svelte/src/internal/client/reactivity/sources.js @@ -6,7 +6,7 @@ import { CLEAN, SOURCE } from '../constants.js'; /** * @template V * @param {V} initial_value - * @returns {import('../types.js').SourceSignal} + * @returns {import('../types.js').Source} */ /*#__NO_SIDE_EFFECTS__*/ export function source(initial_value) { @@ -16,7 +16,7 @@ export function source(initial_value) { /** * @template V * @param {V} initial_value - * @returns {import('../types.js').SourceSignal} + * @returns {import('../types.js').Source} */ /*#__NO_SIDE_EFFECTS__*/ export function mutable_source(initial_value) { @@ -36,7 +36,7 @@ export function mutable_source(initial_value) { * @template V * @param {import('../types.js').SignalFlags} flags * @param {V} value - * @returns {import('../types.js').SourceSignal | import('../types.js').SourceSignal & import('../types.js').SourceSignalDebug} + * @returns {import('../types.js').Source | import('../types.js').Source & import('../types.js').SourceDebug} */ function create_source_signal(flags, value) { if (DEV) { diff --git a/packages/svelte/src/internal/client/reactivity/store.js b/packages/svelte/src/internal/client/reactivity/store.js index 3680b95052..1014098819 100644 --- a/packages/svelte/src/internal/client/reactivity/store.js +++ b/packages/svelte/src/internal/client/reactivity/store.js @@ -50,7 +50,7 @@ export function store_get(store, store_name, stores) { /** * @template V * @param {import('../types.js').Store | null | undefined} store - * @param {import('../types.js').SourceSignal} source + * @param {import('../types.js').Source} source */ function connect_store_to_signal(store, source) { if (store == null) { diff --git a/packages/svelte/src/internal/client/render.js b/packages/svelte/src/internal/client/render.js index 4981915717..0da2bedf86 100644 --- a/packages/svelte/src/internal/client/render.js +++ b/packages/svelte/src/internal/client/render.js @@ -718,7 +718,7 @@ export function bind_playback_rate(media, get_value, update) { // Needs to happen after the element is inserted into the dom, else playback will be set back to 1 by the browser. // For hydration we could do it immediately but the additional code is not worth the lost microtask. - /** @type {import('./types.js').ComputationSignal | undefined} */ + /** @type {import('./types.js').Computation | undefined} */ let render; let destroyed = false; const effect = managed_effect(() => { diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index 7322f75fda..1bf3a5fa7b 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -54,7 +54,7 @@ let current_queued_effects = []; let flush_count = 0; // Handle signal reactivity tree dependencies and consumer -/** @type {null | import('./types.js').ComputationSignal} */ +/** @type {null | import('./types.js').Computation} */ export let current_consumer = null; /** @type {null | import('./types.js').EffectSignal} */ @@ -161,7 +161,7 @@ function is_signal_dirty(signal) { return true; } if ((flags & MAYBE_DIRTY) !== 0) { - const dependencies = /** @type {import('./types.js').ComputationSignal} **/ (signal).d; + const dependencies = /** @type {import('./types.js').Computation} **/ (signal).d; if (dependencies !== null) { const length = dependencies.length; let i; @@ -174,10 +174,7 @@ function is_signal_dirty(signal) { // The flags can be marked as dirty from the above is_signal_dirty call. if ((dependency.f & DIRTY) !== 0) { if ((dependency.f & DERIVED) !== 0) { - update_derived( - /** @type {import('./types.js').ComputationSignal} **/ (dependency), - true - ); + update_derived(/** @type {import('./types.js').Computation} **/ (dependency), true); // Might have been mutated from above get. if ((signal.f & DIRTY) !== 0) { return true; @@ -205,7 +202,7 @@ function is_signal_dirty(signal) { /** * @template V - * @param {import('./types.js').ComputationSignal} signal + * @param {import('./types.js').Computation} signal * @returns {V} */ function execute_signal_fn(signal) { @@ -311,7 +308,7 @@ function execute_signal_fn(signal) { /** * @template V - * @param {import('./types.js').ComputationSignal} signal + * @param {import('./types.js').Computation} signal * @param {import('./types.js').Signal} dependency * @returns {void} */ @@ -334,13 +331,13 @@ function remove_consumer(signal, dependency) { if (consumers_length === 0 && (dependency.f & UNOWNED) !== 0) { // If the signal is unowned then we need to make sure to change it to dirty. set_signal_status(dependency, DIRTY); - remove_consumers(/** @type {import('./types.js').ComputationSignal} **/ (dependency), 0); + remove_consumers(/** @type {import('./types.js').Computation} **/ (dependency), 0); } } /** * @template V - * @param {import('./types.js').ComputationSignal} signal + * @param {import('./types.js').Computation} signal * @param {number} start_index * @returns {void} */ @@ -361,7 +358,7 @@ function remove_consumers(signal, start_index) { /** * @template V - * @param {import('./types.js').ComputationSignal} signal + * @param {import('./types.js').Computation} signal * @returns {void} */ function destroy_references(signal) { @@ -654,7 +651,7 @@ export async function tick() { /** * @template V - * @param {import('./types.js').ComputationSignal} signal + * @param {import('./types.js').Computation} signal * @param {boolean} force_schedule * @returns {void} */ @@ -741,10 +738,10 @@ export function get(signal) { // we want to avoid tracking indirect dependencies const previous_inspect_fn = inspect_fn; inspect_fn = null; - update_derived(/** @type {import('./types.js').ComputationSignal} **/ (signal), false); + update_derived(/** @type {import('./types.js').Computation} **/ (signal), false); inspect_fn = previous_inspect_fn; } else { - update_derived(/** @type {import('./types.js').ComputationSignal} **/ (signal), false); + update_derived(/** @type {import('./types.js').Computation} **/ (signal), false); } } return signal.v; @@ -924,7 +921,7 @@ export function set_signal_value(signal, value) { /** * @template V - * @param {import('./types.js').ComputationSignal} signal + * @param {import('./types.js').Computation} signal * @returns {void} */ export function destroy_signal(signal) { @@ -968,7 +965,7 @@ export function untrack(fn) { /** * @template V - * @param {import('./types.js').ComputationSignal} signal + * @param {import('./types.js').Computation} signal * @param {() => void} destroy_fn * @returns {void} */ diff --git a/packages/svelte/src/internal/client/types.d.ts b/packages/svelte/src/internal/client/types.d.ts index ffc4bbbf1c..0ce3bd28f2 100644 --- a/packages/svelte/src/internal/client/types.d.ts +++ b/packages/svelte/src/internal/client/types.d.ts @@ -55,9 +55,9 @@ export type ComponentContext = { // (effects and derived signals). Thus we can improve the memory profile at the slight cost // of some runtime performance. -export type SourceSignal = { +export type Source = { /** consumers: Signals that read from the current signal */ - c: null | ComputationSignal[]; + c: null | Computation[]; /** equals: For value equality */ e: null | EqualsFunctions; /** flags: The types that the signal represent, as a bitwise value */ @@ -68,14 +68,14 @@ export type SourceSignal = { w: number; }; -export type SourceSignalDebug = { +export type SourceDebug = { /** This is DEV only */ inspect: Set; }; -export type ComputationSignal = { +export type Computation = { /** consumers: Signals that read from the current signal */ - c: null | ComputationSignal[]; + c: null | Computation[]; /** context: The associated component if this signal is an effect/computed */ x: null | ComponentContext; /** dependencies: Signals that this signal reads from */ @@ -93,7 +93,7 @@ export type ComputationSignal = { | (() => void | (() => void)) | ((b: Block, s: Signal) => void | (() => void)); /** references: Anything that a signal owns */ - r: null | ComputationSignal[]; + r: null | Computation[]; /** value: The latest value for this signal, doubles as the teardown for effects */ v: V; /** level: the depth from the root signal, used for ordering render/pre-effects topologically **/ @@ -103,18 +103,18 @@ export type ComputationSignal = { parent: Signal | null; }; -export type BlockEffect = ComputationSignal & { +export type BlockEffect = Computation & { in?: TransitionObject[]; out?: TransitionObject[]; dom?: TemplateNode | Array; ran?: boolean; }; -export type Signal = SourceSignal | ComputationSignal; +export type Signal = Source | Computation; -export type SignalDebug = SourceSignalDebug & Signal; +export type SignalDebug = SourceDebug & Signal; -export type EffectSignal = ComputationSignal void)>; +export type EffectSignal = Computation void)>; export type MaybeSignal = T | Signal; @@ -148,7 +148,7 @@ export type Transition = { export type EachItemBlock = { /** effect */ - e: ComputationSignal; + e: Computation; /** item */ v: any | Signal; /** index */ @@ -219,9 +219,9 @@ export type TaskEntry = { c: TaskCallback; f: () => void }; export interface ProxyMetadata> { /** A map of signals associated to the properties that are reactive */ - s: Map>; + s: Map>; /** A version counter, used within the proxy to signal changes in places where there's no other way to signal an update */ - v: SourceSignal; + v: Source; /** `true` if the proxified object is an array */ a: boolean; /** Immutable: Whether to use a source or mutable source under the hood */ diff --git a/packages/svelte/tests/signals/test.ts b/packages/svelte/tests/signals/test.ts index 7c885f597f..5fdd77596f 100644 --- a/packages/svelte/tests/signals/test.ts +++ b/packages/svelte/tests/signals/test.ts @@ -7,7 +7,7 @@ import { user_effect } from '../../src/internal/client/reactivity/computations'; import { source } from '../../src/internal/client/reactivity/sources'; -import type { ComputationSignal } from '../../src/internal/client/types'; +import type { Computation } from '../../src/internal/client/types'; /** * @param runes runes mode @@ -208,7 +208,7 @@ describe('signals', () => { test('correctly cleanup onowned nested derived values', () => { return () => { - const nested: ComputationSignal[] = []; + const nested: Computation[] = []; const a = source(0); const b = source(0);