Skip to content

Commit c0a069c

Browse files
committed
more
1 parent a0549b4 commit c0a069c

File tree

1 file changed

+46
-48
lines changed

1 file changed

+46
-48
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 46 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/** @import { ComponentContext, Derived, Effect, Reaction, Signal, Source, Value } from '#client' */
12
import { DEV } from 'esm-env';
23
import { define_property, get_descriptors, get_prototype_of } from '../shared/utils.js';
34
import {
@@ -57,24 +58,24 @@ export function set_is_destroying_effect(value) {
5758

5859
// Handle effect queues
5960

60-
/** @type {import('#client').Effect[]} */
61+
/** @type {Effect[]} */
6162
let current_queued_root_effects = [];
6263

6364
let flush_count = 0;
6465
// Handle signal reactivity tree dependencies and reactions
6566

66-
/** @type {null | import('#client').Reaction} */
67+
/** @type {null | Reaction} */
6768
export let current_reaction = null;
6869

69-
/** @param {null | import('#client').Reaction} reaction */
70+
/** @param {null | Reaction} reaction */
7071
export function set_current_reaction(reaction) {
7172
current_reaction = reaction;
7273
}
7374

74-
/** @type {null | import('#client').Effect} */
75+
/** @type {null | Effect} */
7576
export let current_effect = null;
7677

77-
/** @param {null | import('#client').Effect} effect */
78+
/** @param {null | Effect} effect */
7879
export function set_current_effect(effect) {
7980
current_effect = effect;
8081
}
@@ -83,7 +84,7 @@ export function set_current_effect(effect) {
8384
* The dependencies of the reaction that is currently being executed. In many cases,
8485
* the dependencies are unchanged between runs, and so this will be `null` unless
8586
* and until a new dependency is accessed — we track this via `skipped_deps`
86-
* @type {null | import('#client').Value[]}
87+
* @type {null | Value[]}
8788
*/
8889
export let new_deps = null;
8990

@@ -92,11 +93,11 @@ let skipped_deps = 0;
9293
/**
9394
* Tracks writes that the effect it's executed in doesn't listen to yet,
9495
* so that the dependency can be added to the effect later on if it then reads it
95-
* @type {null | import('#client').Source[]}
96+
* @type {null | Source[]}
9697
*/
9798
export let current_untracked_writes = null;
9899

99-
/** @param {null | import('#client').Source[]} value */
100+
/** @param {null | Source[]} value */
100101
export function set_current_untracked_writes(value) {
101102
current_untracked_writes = value;
102103
}
@@ -112,10 +113,10 @@ export let is_signals_recorded = false;
112113
let captured_signals = new Set();
113114

114115
// Handling runtime component context
115-
/** @type {import('#client').ComponentContext | null} */
116+
/** @type {ComponentContext | null} */
116117
export let current_component_context = null;
117118

118-
/** @param {import('#client').ComponentContext | null} context */
119+
/** @param {ComponentContext | null} context */
119120
export function set_current_component_context(context) {
120121
current_component_context = context;
121122
}
@@ -128,11 +129,11 @@ export function set_current_component_context(context) {
128129
* <Bar /> <!-- context == Foo.svelte, function == App.svelte -->
129130
* </Foo>
130131
* ```
131-
* @type {import('#client').ComponentContext['function']}
132+
* @type {ComponentContext['function']}
132133
*/
133134
export let dev_current_component_function = null;
134135

135-
/** @param {import('#client').ComponentContext['function']} fn */
136+
/** @param {ComponentContext['function']} fn */
136137
export function set_dev_current_component_function(fn) {
137138
dev_current_component_function = fn;
138139
}
@@ -149,7 +150,7 @@ export function is_runes() {
149150
/**
150151
* Determines whether a derived or effect is dirty.
151152
* If it is MAYBE_DIRTY, will set the status to CLEAN
152-
* @param {import('#client').Reaction} reaction
153+
* @param {Reaction} reaction
153154
* @returns {boolean}
154155
*/
155156
export function check_dirtiness(reaction) {
@@ -177,8 +178,8 @@ export function check_dirtiness(reaction) {
177178
for (i = 0; i < dependencies.length; i++) {
178179
var dependency = dependencies[i];
179180

180-
if (check_dirtiness(/** @type {import('#client').Derived} */ (dependency))) {
181-
update_derived(/** @type {import('#client').Derived} */ (dependency));
181+
if (check_dirtiness(/** @type {Derived} */ (dependency))) {
182+
update_derived(/** @type {Derived} */ (dependency));
182183
}
183184

184185
if (dependency.version > reaction.version) {
@@ -205,8 +206,8 @@ export function check_dirtiness(reaction) {
205206

206207
/**
207208
* @param {Error} error
208-
* @param {import("#client").Effect} effect
209-
* @param {import("#client").ComponentContext | null} component_context
209+
* @param {Effect} effect
210+
* @param {ComponentContext | null} component_context
210211
*/
211212
function handle_error(error, effect, component_context) {
212213
// Given we don't yet have error boundaries, we will just always throw.
@@ -222,7 +223,7 @@ function handle_error(error, effect, component_context) {
222223
component_stack.push(effect_name);
223224
}
224225

225-
/** @type {import("#client").ComponentContext | null} */
226+
/** @type {ComponentContext | null} */
226227
let current_context = component_context;
227228

228229
while (current_context !== null) {
@@ -266,7 +267,7 @@ function handle_error(error, effect, component_context) {
266267

267268
/**
268269
* @template V
269-
* @param {import('#client').Reaction} reaction
270+
* @param {Reaction} reaction
270271
* @returns {V}
271272
*/
272273
export function update_reaction(reaction) {
@@ -276,7 +277,7 @@ export function update_reaction(reaction) {
276277
var previous_reaction = current_reaction;
277278
var previous_skip_reaction = current_skip_reaction;
278279

279-
new_deps = /** @type {null | import('#client').Value[]} */ (null);
280+
new_deps = /** @type {null | Value[]} */ (null);
280281
skipped_deps = 0;
281282
current_untracked_writes = null;
282283
current_reaction = (reaction.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
@@ -349,8 +350,8 @@ export function update_reaction(reaction) {
349350

350351
/**
351352
* @template V
352-
* @param {import('#client').Reaction} signal
353-
* @param {import('#client').Value<V>} dependency
353+
* @param {Reaction} signal
354+
* @param {Value<V>} dependency
354355
* @returns {void}
355356
*/
356357
function remove_reaction(signal, dependency) {
@@ -378,12 +379,12 @@ function remove_reaction(signal, dependency) {
378379
if ((dependency.f & (UNOWNED | DISCONNECTED)) === 0) {
379380
dependency.f ^= DISCONNECTED;
380381
}
381-
remove_reactions(/** @type {import('#client').Derived} **/ (dependency), 0);
382+
remove_reactions(/** @type {Derived} **/ (dependency), 0);
382383
}
383384
}
384385

385386
/**
386-
* @param {import('#client').Reaction} signal
387+
* @param {Reaction} signal
387388
* @param {number} start_index
388389
* @returns {void}
389390
*/
@@ -408,7 +409,7 @@ export function remove_reactions(signal, start_index) {
408409
}
409410

410411
/**
411-
* @param {import('#client').Reaction} signal
412+
* @param {Reaction} signal
412413
* @param {boolean} remove_dom
413414
* @returns {void}
414415
*/
@@ -424,7 +425,7 @@ export function destroy_effect_children(signal, remove_dom = false) {
424425
}
425426

426427
/**
427-
* @param {import('#client').Effect} effect
428+
* @param {Effect} effect
428429
* @returns {void}
429430
*/
430431
export function update_effect(effect) {
@@ -480,7 +481,7 @@ function infinite_loop_guard() {
480481
}
481482

482483
/**
483-
* @param {Array<import('#client').Effect>} root_effects
484+
* @param {Array<Effect>} root_effects
484485
* @returns {void}
485486
*/
486487
function flush_queued_root_effects(root_effects) {
@@ -501,7 +502,7 @@ function flush_queued_root_effects(root_effects) {
501502
if (effect.first === null && (effect.f & BRANCH_EFFECT) === 0) {
502503
flush_queued_effects([effect]);
503504
} else {
504-
/** @type {import('#client').Effect[]} */
505+
/** @type {Effect[]} */
505506
var collected_effects = [];
506507

507508
process_effects(effect, collected_effects);
@@ -514,7 +515,7 @@ function flush_queued_root_effects(root_effects) {
514515
}
515516

516517
/**
517-
* @param {Array<import('#client').Effect>} effects
518+
* @param {Array<Effect>} effects
518519
* @returns {void}
519520
*/
520521
function flush_queued_effects(effects) {
@@ -559,7 +560,7 @@ function process_deferred() {
559560
}
560561

561562
/**
562-
* @param {import('#client').Effect} signal
563+
* @param {Effect} signal
563564
* @returns {void}
564565
*/
565566
export function schedule_effect(signal) {
@@ -592,8 +593,8 @@ export function schedule_effect(signal) {
592593
* bitwise flag passed in only. The collected effects array will be populated with all the user
593594
* effects to be flushed.
594595
*
595-
* @param {import('#client').Effect} effect
596-
* @param {import('#client').Effect[]} collected_effects
596+
* @param {Effect} effect
597+
* @param {Effect[]} collected_effects
597598
* @returns {void}
598599
*/
599600
function process_effects(effect, collected_effects) {
@@ -679,7 +680,7 @@ export function flush_sync(fn) {
679680
try {
680681
infinite_loop_guard();
681682

682-
/** @type {import('#client').Effect[]} */
683+
/** @type {Effect[]} */
683684
const root_effects = [];
684685

685686
current_scheduler_mode = FLUSH_SYNC;
@@ -717,7 +718,7 @@ export async function tick() {
717718

718719
/**
719720
* @template V
720-
* @param {import('#client').Value<V>} signal
721+
* @param {Value<V>} signal
721722
* @returns {V}
722723
*/
723724
export function get(signal) {
@@ -765,7 +766,7 @@ export function get(signal) {
765766
}
766767

767768
if ((flags & DERIVED) !== 0) {
768-
var derived = /** @type {import('#client').Derived} */ (signal);
769+
var derived = /** @type {Derived} */ (signal);
769770

770771
if (check_dirtiness(derived)) {
771772
update_derived(derived);
@@ -801,7 +802,7 @@ export function invalidate_inner_signals(fn) {
801802
for (signal of captured) {
802803
// Go one level up because derived signals created as part of props in legacy mode
803804
if ((signal.f & LEGACY_DERIVED_PROP) !== 0) {
804-
for (const dep of /** @type {import('#client').Derived} */ (signal).deps || []) {
805+
for (const dep of /** @type {Derived} */ (signal).deps || []) {
805806
if ((dep.f & DERIVED) === 0) {
806807
mutate(dep, null /* doesnt matter */);
807808
}
@@ -833,7 +834,7 @@ export function untrack(fn) {
833834
const STATUS_MASK = ~(DIRTY | MAYBE_DIRTY | CLEAN);
834835

835836
/**
836-
* @param {import('#client').Signal} signal
837+
* @param {Signal} signal
837838
* @param {number} status
838839
* @returns {void}
839840
*/
@@ -843,14 +844,12 @@ export function set_signal_status(signal, status) {
843844

844845
/**
845846
* @template V
846-
* @param {V | import('#client').Value<V>} val
847-
* @returns {val is import('#client').Value<V>}
847+
* @param {V | Value<V>} val
848+
* @returns {val is Value<V>}
848849
*/
849850
export function is_signal(val) {
850851
return (
851-
typeof val === 'object' &&
852-
val !== null &&
853-
typeof (/** @type {import('#client').Value<V>} */ (val).f) === 'number'
852+
typeof val === 'object' && val !== null && typeof (/** @type {Value<V>} */ (val).f) === 'number'
854853
);
855854
}
856855

@@ -868,8 +867,7 @@ export function getContext(key) {
868867
const result = /** @type {T} */ (context_map.get(key));
869868

870869
if (DEV) {
871-
const fn = /** @type {import('#client').ComponentContext} */ (current_component_context)
872-
.function;
870+
const fn = /** @type {ComponentContext} */ (current_component_context).function;
873871
if (fn) {
874872
add_owner(result, fn, true);
875873
}
@@ -949,7 +947,7 @@ function get_or_init_context_map(name) {
949947
}
950948

951949
/**
952-
* @param {import('#client').ComponentContext} component_context
950+
* @param {ComponentContext} component_context
953951
* @returns {Map<unknown, unknown> | null}
954952
*/
955953
function get_parent_context(component_context) {
@@ -965,7 +963,7 @@ function get_parent_context(component_context) {
965963
}
966964

967965
/**
968-
* @param {import('#client').Value<number>} signal
966+
* @param {Value<number>} signal
969967
* @param {1 | -1} [d]
970968
* @returns {number}
971969
*/
@@ -976,7 +974,7 @@ export function update(signal, d = 1) {
976974
}
977975

978976
/**
979-
* @param {import('#client').Value<number>} signal
977+
* @param {Value<number>} signal
980978
* @param {1 | -1} [d]
981979
* @returns {number}
982980
*/
@@ -1156,7 +1154,7 @@ export function deep_read(value, visited = new Set()) {
11561154

11571155
/**
11581156
* @template V
1159-
* @param {V | import('#client').Value<V>} value
1157+
* @param {V | Value<V>} value
11601158
* @returns {V}
11611159
*/
11621160
export function unwrap(value) {

0 commit comments

Comments
 (0)