1
- /** @import { TemplateNode } from '#client' */
1
+ /** @import { EachItem, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */
2
2
import {
3
3
EACH_INDEX_REACTIVE ,
4
4
EACH_IS_ANIMATED ,
@@ -36,11 +36,11 @@ import { current_effect } from '../../runtime.js';
36
36
/**
37
37
* The row of a keyed each block that is currently updating. We track this
38
38
* so that `animate:` directives have something to attach themselves to
39
- * @type {import('#client'). EachItem | null }
39
+ * @type {EachItem | null }
40
40
*/
41
41
export let current_each_item = null ;
42
42
43
- /** @param {import('#client'). EachItem | null } item */
43
+ /** @param {EachItem | null } item */
44
44
export function set_current_each_item ( item ) {
45
45
current_each_item = item ;
46
46
}
@@ -56,13 +56,13 @@ export function index(_, i) {
56
56
/**
57
57
* Pause multiple effects simultaneously, and coordinate their
58
58
* subsequent destruction. Used in each blocks
59
- * @param {import('#client'). EachState } state
60
- * @param {import('#client'). EachItem[] } items
59
+ * @param {EachState } state
60
+ * @param {EachItem[] } items
61
61
* @param {null | Node } controlled_anchor
62
62
* @param {Map<any, import("#client").EachItem> } items_map
63
63
*/
64
64
function pause_effects ( state , items , controlled_anchor , items_map ) {
65
- /** @type {import('#client'). TransitionManager[] } */
65
+ /** @type {TransitionManager[] } */
66
66
var transitions = [ ] ;
67
67
var length = items . length ;
68
68
@@ -101,14 +101,14 @@ function pause_effects(state, items, controlled_anchor, items_map) {
101
101
* @param {number } flags
102
102
* @param {() => V[] } get_collection
103
103
* @param {(value: V, index: number) => any } get_key
104
- * @param {(anchor: Node, item: import('#client'). MaybeSource<V>, index: import('#client'). MaybeSource<number>) => void } render_fn
104
+ * @param {(anchor: Node, item: MaybeSource<V>, index: MaybeSource<number>) => void } render_fn
105
105
* @param {null | ((anchor: Node) => void) } fallback_fn
106
106
* @returns {void }
107
107
*/
108
108
export function each ( node , flags , get_collection , get_key , render_fn , fallback_fn = null ) {
109
109
var anchor = node ;
110
110
111
- /** @type {import('#client'). EachState } */
111
+ /** @type {EachState } */
112
112
var state = { flags, items : new Map ( ) , first : null } ;
113
113
114
114
var is_controlled = ( flags & EACH_IS_CONTROLLED ) !== 0 ;
@@ -125,7 +125,7 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
125
125
hydrate_next ( ) ;
126
126
}
127
127
128
- /** @type {import('#client'). Effect | null } */
128
+ /** @type {Effect | null } */
129
129
var fallback = null ;
130
130
131
131
block ( ( ) => {
@@ -174,10 +174,10 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
174
174
175
175
// this is separate to the previous block because `hydrating` might change
176
176
if ( hydrating ) {
177
- /** @type {import('#client'). EachItem | null } */
177
+ /** @type {EachItem | null } */
178
178
var prev = null ;
179
179
180
- /** @type {import('#client'). EachItem } */
180
+ /** @type {EachItem } */
181
181
var item ;
182
182
183
183
for ( var i = 0 ; i < length ; i ++ ) {
@@ -239,9 +239,9 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
239
239
/**
240
240
* @template V
241
241
* @param {Array<V> } array
242
- * @param {import('#client'). EachState } state
242
+ * @param {EachState } state
243
243
* @param {Element | Comment | Text } anchor
244
- * @param {(anchor: Node, item: import('#client'). MaybeSource<V>, index: number | import('#client'). Source<number>) => void } render_fn
244
+ * @param {(anchor: Node, item: MaybeSource<V>, index: number | Source<number>) => void } render_fn
245
245
* @param {number } flags
246
246
* @param {(value: V, index: number) => any } get_key
247
247
* @returns {void }
@@ -255,19 +255,19 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
255
255
var first = state . first ;
256
256
var current = first ;
257
257
258
- /** @type {Set<import('#client'). EachItem> } */
258
+ /** @type {Set<EachItem> } */
259
259
var seen = new Set ( ) ;
260
260
261
- /** @type {import('#client'). EachItem | null } */
261
+ /** @type {EachItem | null } */
262
262
var prev = null ;
263
263
264
- /** @type {Set<import('#client'). EachItem> } */
264
+ /** @type {Set<EachItem> } */
265
265
var to_animate = new Set ( ) ;
266
266
267
- /** @type {import('#client'). EachItem[] } */
267
+ /** @type {EachItem[] } */
268
268
var matched = [ ] ;
269
269
270
- /** @type {import('#client'). EachItem[] } */
270
+ /** @type {EachItem[] } */
271
271
var stashed = [ ] ;
272
272
273
273
/** @type {V } */
@@ -276,7 +276,7 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
276
276
/** @type {any } */
277
277
var key ;
278
278
279
- /** @type {import('#client'). EachItem | undefined } */
279
+ /** @type {EachItem | undefined } */
280
280
var item ;
281
281
282
282
/** @type {number } */
@@ -301,9 +301,7 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
301
301
item = items . get ( key ) ;
302
302
303
303
if ( item === undefined ) {
304
- var child_anchor = current
305
- ? /** @type {import('#client').EffectNodes } */ ( current . e . nodes ) . start
306
- : anchor ;
304
+ var child_anchor = current ? /** @type {EffectNodes } */ ( current . e . nodes ) . start : anchor ;
307
305
308
306
prev = create_item (
309
307
child_anchor ,
@@ -436,12 +434,12 @@ function reconcile(array, state, anchor, render_fn, flags, get_key) {
436
434
} ) ;
437
435
}
438
436
439
- /** @type {import('#client'). Effect } */ ( current_effect ) . first = state . first && state . first . e ;
440
- /** @type {import('#client'). Effect } */ ( current_effect ) . last = prev && prev . e ;
437
+ /** @type {Effect } */ ( current_effect ) . first = state . first && state . first . e ;
438
+ /** @type {Effect } */ ( current_effect ) . last = prev && prev . e ;
441
439
}
442
440
443
441
/**
444
- * @param {import('#client'). EachItem } item
442
+ * @param {EachItem } item
445
443
* @param {any } value
446
444
* @param {number } index
447
445
* @param {number } type
@@ -453,7 +451,7 @@ function update_item(item, value, index, type) {
453
451
}
454
452
455
453
if ( ( type & EACH_INDEX_REACTIVE ) !== 0 ) {
456
- set ( /** @type {import('#client'). Value<number> } */ ( item . i ) , index ) ;
454
+ set ( /** @type {Value<number> } */ ( item . i ) , index ) ;
457
455
} else {
458
456
item . i = index ;
459
457
}
@@ -462,15 +460,15 @@ function update_item(item, value, index, type) {
462
460
/**
463
461
* @template V
464
462
* @param {Node } anchor
465
- * @param {import('#client'). EachState } state
466
- * @param {import('#client'). EachItem | null } prev
467
- * @param {import('#client'). EachItem | null } next
463
+ * @param {EachState } state
464
+ * @param {EachItem | null } prev
465
+ * @param {EachItem | null } next
468
466
* @param {V } value
469
467
* @param {unknown } key
470
468
* @param {number } index
471
- * @param {(anchor: Node, item: V | import('#client'). Source<V>, index: number | import('#client'). Value<number>) => void } render_fn
469
+ * @param {(anchor: Node, item: V | Source<V>, index: number | Value<number>) => void } render_fn
472
470
* @param {number } flags
473
- * @returns {import('#client'). EachItem }
471
+ * @returns {EachItem }
474
472
*/
475
473
function create_item ( anchor , state , prev , next , value , key , index , render_fn , flags ) {
476
474
var previous_each_item = current_each_item ;
@@ -482,7 +480,7 @@ function create_item(anchor, state, prev, next, value, key, index, render_fn, fl
482
480
var v = reactive ? ( mutable ? mutable_source ( value ) : source ( value ) ) : value ;
483
481
var i = ( flags & EACH_INDEX_REACTIVE ) === 0 ? index : source ( index ) ;
484
482
485
- /** @type {import('#client'). EachItem } */
483
+ /** @type {EachItem } */
486
484
var item = {
487
485
i,
488
486
v,
@@ -519,29 +517,27 @@ function create_item(anchor, state, prev, next, value, key, index, render_fn, fl
519
517
}
520
518
521
519
/**
522
- * @param {import('#client'). EachItem } item
523
- * @param {import('#client'). EachItem | null } next
520
+ * @param {EachItem } item
521
+ * @param {EachItem | null } next
524
522
* @param {Text | Element | Comment } anchor
525
523
*/
526
524
function move ( item , next , anchor ) {
527
- var end = item . next
528
- ? /** @type {import('#client').EffectNodes } */ ( item . next . e . nodes ) . start
529
- : anchor ;
525
+ var end = item . next ? /** @type {EffectNodes } */ ( item . next . e . nodes ) . start : anchor ;
530
526
531
- var dest = next ? /** @type {import('#client'). EffectNodes } */ ( next . e . nodes ) . start : anchor ;
532
- var node = /** @type {import('#client'). EffectNodes } */ ( item . e . nodes ) . start ;
527
+ var dest = next ? /** @type {EffectNodes } */ ( next . e . nodes ) . start : anchor ;
528
+ var node = /** @type {EffectNodes } */ ( item . e . nodes ) . start ;
533
529
534
530
while ( node !== end ) {
535
- var next_node = /** @type {import('#client'). TemplateNode } */ ( node . nextSibling ) ;
531
+ var next_node = /** @type {TemplateNode } */ ( node . nextSibling ) ;
536
532
dest . before ( node ) ;
537
533
node = next_node ;
538
534
}
539
535
}
540
536
541
537
/**
542
- * @param {import('#client'). EachState } state
543
- * @param {import('#client'). EachItem | null } prev
544
- * @param {import('#client'). EachItem | null } next
538
+ * @param {EachState } state
539
+ * @param {EachItem | null } prev
540
+ * @param {EachItem | null } next
545
541
*/
546
542
function link ( state , prev , next ) {
547
543
if ( prev === null ) {
0 commit comments