diff --git a/packages/svelte/src/internal/client/dom/blocks/each.js b/packages/svelte/src/internal/client/dom/blocks/each.js index a1566d1f14c8..f76048637a0f 100644 --- a/packages/svelte/src/internal/client/dom/blocks/each.js +++ b/packages/svelte/src/internal/client/dom/blocks/each.js @@ -59,7 +59,7 @@ export function index(_, i) { * @param {EachState} state * @param {EachItem[]} items * @param {null | Node} controlled_anchor - * @param {Map} items_map + * @param {Map} items_map */ function pause_effects(state, items, controlled_anchor, items_map) { /** @type {TransitionManager[]} */ diff --git a/packages/svelte/src/internal/client/dom/blocks/if.js b/packages/svelte/src/internal/client/dom/blocks/if.js index dc3ffbd72d44..4d8e9412d3e2 100644 --- a/packages/svelte/src/internal/client/dom/blocks/if.js +++ b/packages/svelte/src/internal/client/dom/blocks/if.js @@ -1,4 +1,4 @@ -/** @import { TemplateNode } from '#client' */ +/** @import { Effect, TemplateNode } from '#client' */ import { EFFECT_TRANSPARENT } from '../../constants.js'; import { hydrate_next, @@ -14,8 +14,8 @@ import { HYDRATION_START_ELSE } from '../../../../constants.js'; /** * @param {TemplateNode} node * @param {() => boolean} get_condition - * @param {(anchor: Node) => import('#client').Dom} consequent_fn - * @param {null | ((anchor: Node) => import('#client').Dom)} [alternate_fn] + * @param {(anchor: Node) => void} consequent_fn + * @param {null | ((anchor: Node) => void)} [alternate_fn] * @param {boolean} [elseif] True if this is an `{:else if ...}` block rather than an `{#if ...}`, as that affects which transitions are considered 'local' * @returns {void} */ @@ -26,10 +26,10 @@ export function if_block(node, get_condition, consequent_fn, alternate_fn = null var anchor = node; - /** @type {import('#client').Effect | null} */ + /** @type {Effect | null} */ var consequent_effect = null; - /** @type {import('#client').Effect | null} */ + /** @type {Effect | null} */ var alternate_effect = null; /** @type {boolean | null} */ diff --git a/packages/svelte/src/internal/client/dom/elements/transitions.js b/packages/svelte/src/internal/client/dom/elements/transitions.js index 3369e263f31f..5d0005b2c125 100644 --- a/packages/svelte/src/internal/client/dom/elements/transitions.js +++ b/packages/svelte/src/internal/client/dom/elements/transitions.js @@ -1,3 +1,4 @@ +/** @import { AnimateFn, Animation, AnimationConfig, EachItem, Effect, Task, TransitionFn, TransitionManager } from '#client' */ import { noop, is_function } from '../../../shared/utils.js'; import { effect } from '../../reactivity/effects.js'; import { current_effect, untrack } from '../../runtime.js'; @@ -60,11 +61,11 @@ const linear = (t) => t; * and attaches it to the block, so that moves can be animated following reconciliation. * @template P * @param {Element} element - * @param {() => import('#client').AnimateFn

} get_fn + * @param {() => AnimateFn

} get_fn * @param {(() => P) | null} get_params */ export function animation(element, get_fn, get_params) { - var item = /** @type {import('#client').EachItem} */ (current_each_item); + var item = /** @type {EachItem} */ (current_each_item); /** @type {DOMRect} */ var from; @@ -72,7 +73,7 @@ export function animation(element, get_fn, get_params) { /** @type {DOMRect} */ var to; - /** @type {import('#client').Animation | undefined} */ + /** @type {Animation | undefined} */ var animation; /** @type {null | { position: string, width: string, height: string, transform: string }} */ @@ -167,7 +168,7 @@ export function animation(element, get_fn, get_params) { * @template P * @param {number} flags * @param {HTMLElement} element - * @param {() => import('#client').TransitionFn

} get_fn + * @param {() => TransitionFn

} get_fn * @param {(() => P) | null} get_params * @returns {void} */ @@ -180,15 +181,15 @@ export function transition(flags, element, get_fn, get_params) { /** @type {'in' | 'out' | 'both'} */ var direction = is_both ? 'both' : is_intro ? 'in' : 'out'; - /** @type {import('#client').AnimationConfig | ((opts: { direction: 'in' | 'out' }) => import('#client').AnimationConfig) | undefined} */ + /** @type {AnimationConfig | ((opts: { direction: 'in' | 'out' }) => AnimationConfig) | undefined} */ var current_options; var inert = element.inert; - /** @type {import('#client').Animation | undefined} */ + /** @type {Animation | undefined} */ var intro; - /** @type {import('#client').Animation | undefined} */ + /** @type {Animation | undefined} */ var outro; /** @type {(() => void) | undefined} */ @@ -201,7 +202,7 @@ export function transition(flags, element, get_fn, get_params) { return (current_options ??= get_fn()(element, get_params?.(), { direction })); } - /** @type {import('#client').TransitionManager} */ + /** @type {TransitionManager} */ var transition = { is_global, in() { @@ -271,7 +272,7 @@ export function transition(flags, element, get_fn, get_params) { } }; - var e = /** @type {import('#client').Effect} */ (current_effect); + var e = /** @type {Effect} */ (current_effect); (e.transitions ??= []).push(transition); @@ -282,7 +283,7 @@ export function transition(flags, element, get_fn, get_params) { let run = is_global; if (!run) { - var block = /** @type {import('#client').Effect | null} */ (e.parent); + var block = /** @type {Effect | null} */ (e.parent); // skip over transparent blocks (e.g. snippets, else-if blocks) while (block && (block.f & EFFECT_TRANSPARENT) !== 0) { @@ -305,12 +306,12 @@ export function transition(flags, element, get_fn, get_params) { /** * Animates an element, according to the provided configuration * @param {Element} element - * @param {import('#client').AnimationConfig | ((opts: { direction: 'in' | 'out' }) => import('#client').AnimationConfig)} options - * @param {import('#client').Animation | undefined} counterpart The corresponding intro/outro to this outro/intro + * @param {AnimationConfig | ((opts: { direction: 'in' | 'out' }) => AnimationConfig)} options + * @param {Animation | undefined} counterpart The corresponding intro/outro to this outro/intro * @param {number} t2 The target `t` value — `1` for intro, `0` for outro * @param {(() => void) | undefined} on_finish Called after successfully completing the animation * @param {(() => void) | undefined} on_abort Called if the animation is aborted - * @returns {import('#client').Animation} + * @returns {Animation} */ function animate(element, options, counterpart, t2, on_finish, on_abort) { var is_intro = t2 === 1; @@ -319,7 +320,7 @@ function animate(element, options, counterpart, t2, on_finish, on_abort) { // In the case of a deferred transition (such as `crossfade`), `option` will be // a function rather than an `AnimationConfig`. We need to call this function // once DOM has been updated... - /** @type {import('#client').Animation} */ + /** @type {Animation} */ var a; queue_micro_task(() => { @@ -358,10 +359,10 @@ function animate(element, options, counterpart, t2, on_finish, on_abort) { var duration = options.duration * Math.abs(delta); var end = start + duration; - /** @type {Animation} */ + /** @type {globalThis.Animation} */ var animation; - /** @type {import('#client').Task} */ + /** @type {Task} */ var task; if (css) { diff --git a/packages/svelte/src/internal/client/reactivity/deriveds.js b/packages/svelte/src/internal/client/reactivity/deriveds.js index 926c7b13f318..2b9f87dfbf32 100644 --- a/packages/svelte/src/internal/client/reactivity/deriveds.js +++ b/packages/svelte/src/internal/client/reactivity/deriveds.js @@ -1,3 +1,4 @@ +/** @import { Derived } from '#client' */ import { CLEAN, DERIVED, DESTROYED, DIRTY, MAYBE_DIRTY, UNOWNED } from '../constants.js'; import { current_reaction, @@ -16,14 +17,14 @@ export let updating_derived = false; /** * @template V * @param {() => V} fn - * @returns {import('#client').Derived} + * @returns {Derived} */ /*#__NO_SIDE_EFFECTS__*/ export function derived(fn) { let flags = DERIVED | DIRTY; if (current_effect === null) flags |= UNOWNED; - /** @type {import('#client').Derived} */ + /** @type {Derived} */ const signal = { deps: null, deriveds: null, @@ -38,7 +39,7 @@ export function derived(fn) { }; if (current_reaction !== null && (current_reaction.f & DERIVED) !== 0) { - var current_derived = /** @type {import('#client').Derived} */ (current_reaction); + var current_derived = /** @type {Derived} */ (current_reaction); if (current_derived.deriveds === null) { current_derived.deriveds = [signal]; } else { @@ -52,7 +53,7 @@ export function derived(fn) { /** * @template V * @param {() => V} fn - * @returns {import('#client').Derived} + * @returns {Derived} */ /*#__NO_SIDE_EFFECTS__*/ export function derived_safe_equal(fn) { @@ -62,7 +63,7 @@ export function derived_safe_equal(fn) { } /** - * @param {import('#client').Derived} derived + * @param {Derived} derived * @returns {void} */ function destroy_derived_children(derived) { @@ -79,7 +80,7 @@ function destroy_derived_children(derived) { } /** - * @param {import('#client').Derived} derived + * @param {Derived} derived * @returns {void} */ export function update_derived(derived) { @@ -103,7 +104,7 @@ export function update_derived(derived) { } /** - * @param {import('#client').Derived} signal + * @param {Derived} signal * @returns {void} */ export function destroy_derived(signal) { diff --git a/packages/svelte/src/internal/client/reactivity/effects.js b/packages/svelte/src/internal/client/reactivity/effects.js index fa920af20796..cf2e7cc11d82 100644 --- a/packages/svelte/src/internal/client/reactivity/effects.js +++ b/packages/svelte/src/internal/client/reactivity/effects.js @@ -1,3 +1,4 @@ +/** @import { ComponentContext, ComponentContextLegacy, Effect, Reaction, TemplateNode, TransitionManager } from '#client' */ import { check_dirtiness, current_component_context, @@ -57,8 +58,8 @@ export function validate_effect(rune) { } /** - * @param {import("#client").Effect} effect - * @param {import("#client").Reaction} parent_effect + * @param {Effect} effect + * @param {Reaction} parent_effect */ export function push_effect(effect, parent_effect) { var parent_last = parent_effect.last; @@ -76,12 +77,12 @@ export function push_effect(effect, parent_effect) { * @param {null | (() => void | (() => void))} fn * @param {boolean} sync * @param {boolean} push - * @returns {import('#client').Effect} + * @returns {Effect} */ function create_effect(type, fn, sync, push = true) { var is_root = (type & ROOT_EFFECT) !== 0; - /** @type {import('#client').Effect} */ + /** @type {Effect} */ var effect = { ctx: current_component_context, deps: null, @@ -187,7 +188,7 @@ export function user_effect(fn) { } if (defer) { - var context = /** @type {import('#client').ComponentContext} */ (current_component_context); + var context = /** @type {ComponentContext} */ (current_component_context); (context.e ??= []).push(fn); } else { var signal = effect(fn); @@ -198,7 +199,7 @@ export function user_effect(fn) { /** * Internal representation of `$effect.pre(...)` * @param {() => void | (() => void)} fn - * @returns {import('#client').Effect} + * @returns {Effect} */ export function user_pre_effect(fn) { validate_effect('$effect.pre'); @@ -229,7 +230,7 @@ export function effect_root(fn) { /** * @param {() => void | (() => void)} fn - * @returns {import('#client').Effect} + * @returns {Effect} */ export function effect(fn) { return create_effect(EFFECT, fn, false); @@ -241,9 +242,9 @@ export function effect(fn) { * @param {() => void | (() => void)} fn */ export function legacy_pre_effect(deps, fn) { - var context = /** @type {import('#client').ComponentContextLegacy} */ (current_component_context); + var context = /** @type {ComponentContextLegacy} */ (current_component_context); - /** @type {{ effect: null | import('#client').Effect, ran: boolean }} */ + /** @type {{ effect: null | Effect, ran: boolean }} */ var token = { effect: null, ran: false }; context.l.r1.push(token); @@ -261,7 +262,7 @@ export function legacy_pre_effect(deps, fn) { } export function legacy_pre_effect_reset() { - var context = /** @type {import('#client').ComponentContextLegacy} */ (current_component_context); + var context = /** @type {ComponentContextLegacy} */ (current_component_context); render_effect(() => { if (!get(context.l.r2)) return; @@ -283,7 +284,7 @@ export function legacy_pre_effect_reset() { /** * @param {() => void | (() => void)} fn - * @returns {import('#client').Effect} + * @returns {Effect} */ export function render_effect(fn) { return create_effect(RENDER_EFFECT, fn, true); @@ -291,7 +292,7 @@ export function render_effect(fn) { /** * @param {() => void | (() => void)} fn - * @returns {import('#client').Effect} + * @returns {Effect} */ export function template_effect(fn) { if (DEV) { @@ -319,7 +320,7 @@ export function branch(fn, push = true) { } /** - * @param {import("#client").Effect} effect + * @param {Effect} effect */ export function execute_effect_teardown(effect) { var teardown = effect.teardown; @@ -338,7 +339,7 @@ export function execute_effect_teardown(effect) { } /** - * @param {import('#client').Effect} effect + * @param {Effect} effect * @param {boolean} [remove_dom] * @returns {void} */ @@ -346,14 +347,13 @@ export function destroy_effect(effect, remove_dom = true) { var removed = false; if ((remove_dom || (effect.f & HEAD_EFFECT) !== 0) && effect.nodes !== null) { - /** @type {import('#client').TemplateNode | null} */ + /** @type {TemplateNode | null} */ var node = effect.nodes.start; var end = effect.nodes.end; while (node !== null) { - /** @type {import('#client').TemplateNode | null} */ - var next = - node === end ? null : /** @type {import('#client').TemplateNode} */ (node.nextSibling); + /** @type {TemplateNode | null} */ + var next = node === end ? null : /** @type {TemplateNode} */ (node.nextSibling); node.remove(); node = next; @@ -396,7 +396,7 @@ export function destroy_effect(effect, remove_dom = true) { /** * Detach an effect from the effect tree, freeing up memory and * reducing the amount of work that happens on subsequent traversals - * @param {import('#client').Effect} effect + * @param {Effect} effect */ export function unlink_effect(effect) { var parent = effect.parent; @@ -418,11 +418,11 @@ export function unlink_effect(effect) { * It stays around (in memory, and in the DOM) until outro transitions have * completed, and if the state change is reversed then we _resume_ it. * A paused effect does not update, and the DOM subtree becomes inert. - * @param {import('#client').Effect} effect + * @param {Effect} effect * @param {() => void} [callback] */ export function pause_effect(effect, callback) { - /** @type {import('#client').TransitionManager[]} */ + /** @type {TransitionManager[]} */ var transitions = []; pause_children(effect, transitions, true); @@ -434,7 +434,7 @@ export function pause_effect(effect, callback) { } /** - * @param {import('#client').TransitionManager[]} transitions + * @param {TransitionManager[]} transitions * @param {() => void} fn */ export function run_out_transitions(transitions, fn) { @@ -450,8 +450,8 @@ export function run_out_transitions(transitions, fn) { } /** - * @param {import('#client').Effect} effect - * @param {import('#client').TransitionManager[]} transitions + * @param {Effect} effect + * @param {TransitionManager[]} transitions * @param {boolean} local */ export function pause_children(effect, transitions, local) { @@ -482,14 +482,14 @@ export function pause_children(effect, transitions, local) { /** * The opposite of `pause_effect`. We call this if (for example) * `x` becomes falsy then truthy: `{#if x}...{/if}` - * @param {import('#client').Effect} effect + * @param {Effect} effect */ export function resume_effect(effect) { resume_children(effect, true); } /** - * @param {import('#client').Effect} effect + * @param {Effect} effect * @param {boolean} local */ function resume_children(effect, local) { diff --git a/packages/svelte/src/internal/client/reactivity/sources.js b/packages/svelte/src/internal/client/reactivity/sources.js index 8fa229d56fb4..86427a750906 100644 --- a/packages/svelte/src/internal/client/reactivity/sources.js +++ b/packages/svelte/src/internal/client/reactivity/sources.js @@ -1,3 +1,4 @@ +/** @import { Derived, Effect, Source, Value } from '#client' */ import { DEV } from 'esm-env'; import { current_component_context, @@ -31,7 +32,7 @@ let inspect_effects = new Set(); /** * @template V * @param {V} v - * @returns {import('#client').Source} + * @returns {Source} */ /*#__NO_SIDE_EFFECTS__*/ export function source(v) { @@ -47,7 +48,7 @@ export function source(v) { /** * @template V * @param {V} initial_value - * @returns {import('#client').Source} + * @returns {Source} */ /*#__NO_SIDE_EFFECTS__*/ export function mutable_source(initial_value) { @@ -65,7 +66,7 @@ export function mutable_source(initial_value) { /** * @template V - * @param {import('#client').Value} source + * @param {Value} source * @param {V} value */ export function mutate(source, value) { @@ -78,7 +79,7 @@ export function mutate(source, value) { /** * @template V - * @param {import('#client').Source} source + * @param {Source} source * @param {V} value * @returns {V} */ @@ -129,7 +130,7 @@ export function set(source, value) { } /** - * @param {import('#client').Value} signal + * @param {Value} signal * @param {number} status should be DIRTY or MAYBE_DIRTY * @returns {void} */ @@ -161,9 +162,9 @@ function mark_reactions(signal, status) { // If the signal a) was previously clean or b) is an unowned derived, then mark it if ((flags & (CLEAN | UNOWNED)) !== 0) { if ((flags & DERIVED) !== 0) { - mark_reactions(/** @type {import('#client').Derived} */ (reaction), MAYBE_DIRTY); + mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY); } else { - schedule_effect(/** @type {import('#client').Effect} */ (reaction)); + schedule_effect(/** @type {Effect} */ (reaction)); } } } diff --git a/packages/svelte/src/internal/server/dev.js b/packages/svelte/src/internal/server/dev.js index 045dda594883..dfffa7175b54 100644 --- a/packages/svelte/src/internal/server/dev.js +++ b/packages/svelte/src/internal/server/dev.js @@ -1,3 +1,4 @@ +/** @import { Component, Payload } from '#server' */ import { FILENAME, disallowed_paragraph_contents, @@ -33,7 +34,7 @@ function stringify(element) { } /** - * @param {import('#server').Payload} payload + * @param {Payload} payload * @param {Element} parent * @param {Element} child */ @@ -51,13 +52,13 @@ function print_error(payload, parent, child) { } /** - * @param {import('#server').Payload} payload + * @param {Payload} payload * @param {string} tag * @param {number} line * @param {number} column */ export function push_element(payload, tag, line, column) { - var filename = /** @type {import('#server').Component} */ (current_component).function[FILENAME]; + var filename = /** @type {Component} */ (current_component).function[FILENAME]; var child = { tag, parent, filename, line, column }; if (parent !== null && !is_tag_valid_with_parent(tag, parent.tag)) { diff --git a/packages/svelte/src/internal/server/index.js b/packages/svelte/src/internal/server/index.js index 8c2b7de27e60..a6d70d21de71 100644 --- a/packages/svelte/src/internal/server/index.js +++ b/packages/svelte/src/internal/server/index.js @@ -1,3 +1,4 @@ +/** @import { ComponentType, SvelteComponent } from 'svelte' */ /** @import { Component, Payload, RenderOutput } from '#server' */ /** @import { Store } from '#shared' */ export { FILENAME, HMR } from '../../constants.js'; @@ -103,7 +104,7 @@ export let on_destroy = []; * Only available on the server and when compiling with the `server` option. * Takes a component and returns an object with `body` and `head` properties on it, which you can use to populate the HTML when server-rendering your app. * @template {Record} Props - * @param {import('svelte').Component | import('svelte').ComponentType>} component + * @param {import('svelte').Component | ComponentType>} component * @param {{ props?: Omit; context?: Map }} [options] * @returns {RenderOutput} */ diff --git a/packages/svelte/src/motion/spring.js b/packages/svelte/src/motion/spring.js index ec56d354109a..c3b4177579ff 100644 --- a/packages/svelte/src/motion/spring.js +++ b/packages/svelte/src/motion/spring.js @@ -1,3 +1,6 @@ +/** @import { Task } from '#client' */ +/** @import { SpringOpts, SpringUpdateOpts, TickContext } from './private.js' */ +/** @import { Spring } from './public.js' */ import { writable } from '../store/index.js'; import { loop } from '../internal/client/loop.js'; import { raf } from '../internal/client/timing.js'; @@ -5,7 +8,7 @@ import { is_date } from './utils.js'; /** * @template T - * @param {import('./private').TickContext} ctx + * @param {TickContext} ctx * @param {T} last_value * @param {T} current_value * @param {T} target_value @@ -53,15 +56,15 @@ function tick_spring(ctx, last_value, current_value, target_value) { * https://svelte.dev/docs/svelte-motion#spring * @template [T=any] * @param {T} [value] - * @param {import('./private').SpringOpts} [opts] - * @returns {import('./public.js').Spring} + * @param {SpringOpts} [opts] + * @returns {Spring} */ export function spring(value, opts = {}) { const store = writable(value); const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts; /** @type {number} */ let last_time; - /** @type {import('../internal/client/types').Task | null} */ + /** @type {Task | null} */ let task; /** @type {object} */ let current_token; @@ -74,7 +77,7 @@ export function spring(value, opts = {}) { let cancel_task = false; /** * @param {T} new_value - * @param {import('./private').SpringUpdateOpts} opts + * @param {SpringUpdateOpts} opts * @returns {Promise} */ function set(new_value, opts = {}) { @@ -101,7 +104,7 @@ export function spring(value, opts = {}) { return false; } inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1); - /** @type {import('./private').TickContext} */ + /** @type {TickContext} */ const ctx = { inv_mass, opts: spring, @@ -120,12 +123,12 @@ export function spring(value, opts = {}) { }); } return new Promise((fulfil) => { - /** @type {import('../internal/client/types').Task} */ (task).promise.then(() => { + /** @type {Task} */ (task).promise.then(() => { if (token === current_token) fulfil(); }); }); } - /** @type {import('./public.js').Spring} */ + /** @type {Spring} */ const spring = { set, update: (fn, opts) => set(fn(/** @type {T} */ (target_value), /** @type {T} */ (value)), opts), diff --git a/packages/svelte/src/reactivity/map.js b/packages/svelte/src/reactivity/map.js index 30da04c035e0..c732806cd0b6 100644 --- a/packages/svelte/src/reactivity/map.js +++ b/packages/svelte/src/reactivity/map.js @@ -1,3 +1,4 @@ +/** @import { Source } from '#client' */ import { DEV } from 'esm-env'; import { source, set } from '../internal/client/reactivity/sources.js'; import { get } from '../internal/client/runtime.js'; @@ -9,7 +10,7 @@ import { increment } from './utils.js'; * @extends {Map} */ export class SvelteMap extends Map { - /** @type {Map>} */ + /** @type {Map>} */ #sources = new Map(); #version = source(0); #size = source(0); diff --git a/packages/svelte/src/reactivity/set.js b/packages/svelte/src/reactivity/set.js index 6206ce14ef8f..38723a0b9e05 100644 --- a/packages/svelte/src/reactivity/set.js +++ b/packages/svelte/src/reactivity/set.js @@ -1,3 +1,4 @@ +/** @import { Source } from '#client' */ import { DEV } from 'esm-env'; import { source, set } from '../internal/client/reactivity/sources.js'; import { get } from '../internal/client/runtime.js'; @@ -13,7 +14,7 @@ var inited = false; * @extends {Set} */ export class SvelteSet extends Set { - /** @type {Map>} */ + /** @type {Map>} */ #sources = new Map(); #version = source(0); #size = source(0); diff --git a/packages/svelte/src/reactivity/utils.js b/packages/svelte/src/reactivity/utils.js index 5490dae7e5a8..355a000e9dda 100644 --- a/packages/svelte/src/reactivity/utils.js +++ b/packages/svelte/src/reactivity/utils.js @@ -1,3 +1,4 @@ +/** @import { Source } from '#client' */ import { set } from '../internal/client/reactivity/sources.js'; /** @@ -30,7 +31,7 @@ function get_this() { return this; } -/** @param {import('#client').Source} source */ +/** @param {Source} source */ export function increment(source) { set(source, source.v + 1); }