svelte 5.41.1 → 5.41.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/index.js +1 -1
- package/package.json +1 -1
- package/src/compiler/phases/2-analyze/index.js +3 -3
- package/src/compiler/phases/2-analyze/visitors/AwaitExpression.js +13 -6
- package/src/compiler/phases/2-analyze/visitors/CallExpression.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/ConstTag.js +3 -1
- package/src/compiler/phases/2-analyze/visitors/VariableDeclarator.js +0 -6
- package/src/compiler/phases/3-transform/client/visitors/CallExpression.js +21 -3
- package/src/compiler/phases/3-transform/server/visitors/CallExpression.js +10 -4
- package/src/compiler/phases/3-transform/utils.js +14 -25
- package/src/internal/client/constants.js +13 -2
- package/src/internal/client/dev/inspect.js +14 -4
- package/src/internal/client/dev/tracing.js +14 -1
- package/src/internal/client/dom/blocks/async.js +5 -0
- package/src/internal/client/dom/blocks/boundary.js +0 -7
- package/src/internal/client/reactivity/async.js +3 -8
- package/src/internal/client/reactivity/batch.js +160 -75
- package/src/internal/client/reactivity/deriveds.js +23 -11
- package/src/internal/client/reactivity/sources.js +7 -3
- package/src/internal/client/runtime.js +6 -1
- package/src/internal/server/index.js +0 -9
- package/src/version.js +1 -1
- package/types/index.d.ts.map +1 -1
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
RENDER_EFFECT,
|
|
12
12
|
ROOT_EFFECT,
|
|
13
13
|
MAYBE_DIRTY,
|
|
14
|
-
DERIVED
|
|
14
|
+
DERIVED,
|
|
15
|
+
BOUNDARY_EFFECT
|
|
15
16
|
} from '#client/constants';
|
|
16
17
|
import { async_mode_flag } from '../../flags/index.js';
|
|
17
18
|
import { deferred, define_property } from '../../shared/utils.js';
|
|
@@ -31,6 +32,16 @@ import { invoke_error_boundary } from '../error-handling.js';
|
|
|
31
32
|
import { old_values, source, update } from './sources.js';
|
|
32
33
|
import { inspect_effect, unlink_effect } from './effects.js';
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {{
|
|
37
|
+
* parent: EffectTarget | null;
|
|
38
|
+
* effect: Effect | null;
|
|
39
|
+
* effects: Effect[];
|
|
40
|
+
* render_effects: Effect[];
|
|
41
|
+
* block_effects: Effect[];
|
|
42
|
+
* }} EffectTarget
|
|
43
|
+
*/
|
|
44
|
+
|
|
34
45
|
/** @type {Set<Batch>} */
|
|
35
46
|
const batches = new Set();
|
|
36
47
|
|
|
@@ -65,6 +76,8 @@ let is_flushing = false;
|
|
|
65
76
|
export let is_flushing_sync = false;
|
|
66
77
|
|
|
67
78
|
export class Batch {
|
|
79
|
+
committed = false;
|
|
80
|
+
|
|
68
81
|
/**
|
|
69
82
|
* The current values of any sources that are updated in this batch
|
|
70
83
|
* They keys of this map are identical to `this.#previous`
|
|
@@ -91,6 +104,11 @@ export class Batch {
|
|
|
91
104
|
*/
|
|
92
105
|
#pending = 0;
|
|
93
106
|
|
|
107
|
+
/**
|
|
108
|
+
* The number of async effects that are currently in flight, _not_ inside a pending boundary
|
|
109
|
+
*/
|
|
110
|
+
#blocking_pending = 0;
|
|
111
|
+
|
|
94
112
|
/**
|
|
95
113
|
* A deferred that resolves when the batch is committed, used with `settled()`
|
|
96
114
|
* TODO replace with Promise.withResolvers once supported widely enough
|
|
@@ -98,26 +116,6 @@ export class Batch {
|
|
|
98
116
|
*/
|
|
99
117
|
#deferred = null;
|
|
100
118
|
|
|
101
|
-
/**
|
|
102
|
-
* Template effects and `$effect.pre` effects, which run when
|
|
103
|
-
* a batch is committed
|
|
104
|
-
* @type {Effect[]}
|
|
105
|
-
*/
|
|
106
|
-
#render_effects = [];
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* The same as `#render_effects`, but for `$effect` (which runs after)
|
|
110
|
-
* @type {Effect[]}
|
|
111
|
-
*/
|
|
112
|
-
#effects = [];
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Block effects, which may need to re-run on subsequent flushes
|
|
116
|
-
* in order to update internal sources (e.g. each block items)
|
|
117
|
-
* @type {Effect[]}
|
|
118
|
-
*/
|
|
119
|
-
#block_effects = [];
|
|
120
|
-
|
|
121
119
|
/**
|
|
122
120
|
* Deferred effects (which run after async work has completed) that are DIRTY
|
|
123
121
|
* @type {Effect[]}
|
|
@@ -148,41 +146,37 @@ export class Batch {
|
|
|
148
146
|
|
|
149
147
|
this.apply();
|
|
150
148
|
|
|
149
|
+
/** @type {EffectTarget} */
|
|
150
|
+
var target = {
|
|
151
|
+
parent: null,
|
|
152
|
+
effect: null,
|
|
153
|
+
effects: [],
|
|
154
|
+
render_effects: [],
|
|
155
|
+
block_effects: []
|
|
156
|
+
};
|
|
157
|
+
|
|
151
158
|
for (const root of root_effects) {
|
|
152
|
-
this.#traverse_effect_tree(root);
|
|
159
|
+
this.#traverse_effect_tree(root, target);
|
|
153
160
|
}
|
|
154
161
|
|
|
155
|
-
|
|
156
|
-
if (this.#pending === 0) {
|
|
157
|
-
// TODO we need this because we commit _then_ flush effects...
|
|
158
|
-
// maybe there's a way we can reverse the order?
|
|
159
|
-
var previous_batch_sources = batch_values;
|
|
160
|
-
|
|
161
|
-
this.#commit();
|
|
162
|
+
this.#resolve();
|
|
162
163
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.#
|
|
167
|
-
|
|
168
|
-
|
|
164
|
+
if (this.#blocking_pending > 0) {
|
|
165
|
+
this.#defer_effects(target.effects);
|
|
166
|
+
this.#defer_effects(target.render_effects);
|
|
167
|
+
this.#defer_effects(target.block_effects);
|
|
168
|
+
} else {
|
|
169
|
+
// TODO append/detach blocks here, not in #commit
|
|
169
170
|
|
|
170
171
|
// If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
|
|
171
172
|
// newly updated sources, which could lead to infinite loops when effects run over and over again.
|
|
172
173
|
previous_batch = this;
|
|
173
174
|
current_batch = null;
|
|
174
175
|
|
|
175
|
-
|
|
176
|
-
flush_queued_effects(
|
|
177
|
-
flush_queued_effects(effects);
|
|
176
|
+
flush_queued_effects(target.render_effects);
|
|
177
|
+
flush_queued_effects(target.effects);
|
|
178
178
|
|
|
179
179
|
previous_batch = null;
|
|
180
|
-
|
|
181
|
-
this.#deferred?.resolve();
|
|
182
|
-
} else {
|
|
183
|
-
this.#defer_effects(this.#render_effects);
|
|
184
|
-
this.#defer_effects(this.#effects);
|
|
185
|
-
this.#defer_effects(this.#block_effects);
|
|
186
180
|
}
|
|
187
181
|
|
|
188
182
|
batch_values = null;
|
|
@@ -192,8 +186,9 @@ export class Batch {
|
|
|
192
186
|
* Traverse the effect tree, executing effects or stashing
|
|
193
187
|
* them for later execution as appropriate
|
|
194
188
|
* @param {Effect} root
|
|
189
|
+
* @param {EffectTarget} target
|
|
195
190
|
*/
|
|
196
|
-
#traverse_effect_tree(root) {
|
|
191
|
+
#traverse_effect_tree(root, target) {
|
|
197
192
|
root.f ^= CLEAN;
|
|
198
193
|
|
|
199
194
|
var effect = root.first;
|
|
@@ -205,15 +200,25 @@ export class Batch {
|
|
|
205
200
|
|
|
206
201
|
var skip = is_skippable_branch || (flags & INERT) !== 0 || this.skipped_effects.has(effect);
|
|
207
202
|
|
|
203
|
+
if ((effect.f & BOUNDARY_EFFECT) !== 0 && effect.b?.is_pending()) {
|
|
204
|
+
target = {
|
|
205
|
+
parent: target,
|
|
206
|
+
effect,
|
|
207
|
+
effects: [],
|
|
208
|
+
render_effects: [],
|
|
209
|
+
block_effects: []
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
208
213
|
if (!skip && effect.fn !== null) {
|
|
209
214
|
if (is_branch) {
|
|
210
215
|
effect.f ^= CLEAN;
|
|
211
216
|
} else if ((flags & EFFECT) !== 0) {
|
|
212
|
-
|
|
217
|
+
target.effects.push(effect);
|
|
213
218
|
} else if (async_mode_flag && (flags & RENDER_EFFECT) !== 0) {
|
|
214
|
-
|
|
219
|
+
target.render_effects.push(effect);
|
|
215
220
|
} else if (is_dirty(effect)) {
|
|
216
|
-
if ((effect.f & BLOCK_EFFECT) !== 0)
|
|
221
|
+
if ((effect.f & BLOCK_EFFECT) !== 0) target.block_effects.push(effect);
|
|
217
222
|
update_effect(effect);
|
|
218
223
|
}
|
|
219
224
|
|
|
@@ -229,6 +234,17 @@ export class Batch {
|
|
|
229
234
|
effect = effect.next;
|
|
230
235
|
|
|
231
236
|
while (effect === null && parent !== null) {
|
|
237
|
+
if (parent === target.effect) {
|
|
238
|
+
// TODO rather than traversing into pending boundaries and deferring the effects,
|
|
239
|
+
// could we just attach the effects _to_ the pending boundary and schedule them
|
|
240
|
+
// once the boundary is ready?
|
|
241
|
+
this.#defer_effects(target.effects);
|
|
242
|
+
this.#defer_effects(target.render_effects);
|
|
243
|
+
this.#defer_effects(target.block_effects);
|
|
244
|
+
|
|
245
|
+
target = /** @type {EffectTarget} */ (target.parent);
|
|
246
|
+
}
|
|
247
|
+
|
|
232
248
|
effect = parent.next;
|
|
233
249
|
parent = parent.parent;
|
|
234
250
|
}
|
|
@@ -246,8 +262,6 @@ export class Batch {
|
|
|
246
262
|
// mark as clean so they get scheduled if they depend on pending async state
|
|
247
263
|
set_signal_status(e, CLEAN);
|
|
248
264
|
}
|
|
249
|
-
|
|
250
|
-
effects.length = 0;
|
|
251
265
|
}
|
|
252
266
|
|
|
253
267
|
/**
|
|
@@ -283,8 +297,8 @@ export class Batch {
|
|
|
283
297
|
// this can happen if a new batch was created during `flush_effects()`
|
|
284
298
|
return;
|
|
285
299
|
}
|
|
286
|
-
} else
|
|
287
|
-
this.#
|
|
300
|
+
} else {
|
|
301
|
+
this.#resolve();
|
|
288
302
|
}
|
|
289
303
|
|
|
290
304
|
this.deactivate();
|
|
@@ -300,16 +314,19 @@ export class Batch {
|
|
|
300
314
|
}
|
|
301
315
|
}
|
|
302
316
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
fn();
|
|
317
|
+
#resolve() {
|
|
318
|
+
if (this.#blocking_pending === 0) {
|
|
319
|
+
// append/remove branches
|
|
320
|
+
for (const fn of this.#callbacks) fn();
|
|
321
|
+
this.#callbacks.clear();
|
|
309
322
|
}
|
|
310
323
|
|
|
311
|
-
this.#
|
|
324
|
+
if (this.#pending === 0) {
|
|
325
|
+
this.#commit();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
312
328
|
|
|
329
|
+
#commit() {
|
|
313
330
|
// If there are other pending batches, they now need to be 'rebased' —
|
|
314
331
|
// in other words, we re-run block/async effects with the newly
|
|
315
332
|
// committed state, unless the batch in question has a more
|
|
@@ -317,7 +334,17 @@ export class Batch {
|
|
|
317
334
|
if (batches.size > 1) {
|
|
318
335
|
this.#previous.clear();
|
|
319
336
|
|
|
320
|
-
|
|
337
|
+
var previous_batch_values = batch_values;
|
|
338
|
+
var is_earlier = true;
|
|
339
|
+
|
|
340
|
+
/** @type {EffectTarget} */
|
|
341
|
+
var dummy_target = {
|
|
342
|
+
parent: null,
|
|
343
|
+
effect: null,
|
|
344
|
+
effects: [],
|
|
345
|
+
render_effects: [],
|
|
346
|
+
block_effects: []
|
|
347
|
+
};
|
|
321
348
|
|
|
322
349
|
for (const batch of batches) {
|
|
323
350
|
if (batch === this) {
|
|
@@ -350,8 +377,12 @@ export class Batch {
|
|
|
350
377
|
// Re-run async/block effects that depend on distinct values changed in both batches
|
|
351
378
|
const others = [...batch.current.keys()].filter((s) => !this.current.has(s));
|
|
352
379
|
if (others.length > 0) {
|
|
380
|
+
/** @type {Set<Value>} */
|
|
381
|
+
const marked = new Set();
|
|
382
|
+
/** @type {Map<Reaction, boolean>} */
|
|
383
|
+
const checked = new Map();
|
|
353
384
|
for (const source of sources) {
|
|
354
|
-
mark_effects(source, others);
|
|
385
|
+
mark_effects(source, others, marked, checked);
|
|
355
386
|
}
|
|
356
387
|
|
|
357
388
|
if (queued_root_effects.length > 0) {
|
|
@@ -359,9 +390,11 @@ export class Batch {
|
|
|
359
390
|
batch.apply();
|
|
360
391
|
|
|
361
392
|
for (const root of queued_root_effects) {
|
|
362
|
-
batch.#traverse_effect_tree(root);
|
|
393
|
+
batch.#traverse_effect_tree(root, dummy_target);
|
|
363
394
|
}
|
|
364
395
|
|
|
396
|
+
// TODO do we need to do anything with `target`? defer block effects?
|
|
397
|
+
|
|
365
398
|
queued_root_effects = [];
|
|
366
399
|
batch.deactivate();
|
|
367
400
|
}
|
|
@@ -369,17 +402,31 @@ export class Batch {
|
|
|
369
402
|
}
|
|
370
403
|
|
|
371
404
|
current_batch = null;
|
|
405
|
+
batch_values = previous_batch_values;
|
|
372
406
|
}
|
|
373
407
|
|
|
408
|
+
this.committed = true;
|
|
374
409
|
batches.delete(this);
|
|
410
|
+
|
|
411
|
+
this.#deferred?.resolve();
|
|
375
412
|
}
|
|
376
413
|
|
|
377
|
-
|
|
414
|
+
/**
|
|
415
|
+
*
|
|
416
|
+
* @param {boolean} blocking
|
|
417
|
+
*/
|
|
418
|
+
increment(blocking) {
|
|
378
419
|
this.#pending += 1;
|
|
420
|
+
if (blocking) this.#blocking_pending += 1;
|
|
379
421
|
}
|
|
380
422
|
|
|
381
|
-
|
|
423
|
+
/**
|
|
424
|
+
*
|
|
425
|
+
* @param {boolean} blocking
|
|
426
|
+
*/
|
|
427
|
+
decrement(blocking) {
|
|
382
428
|
this.#pending -= 1;
|
|
429
|
+
if (blocking) this.#blocking_pending -= 1;
|
|
383
430
|
|
|
384
431
|
for (const e of this.#dirty_effects) {
|
|
385
432
|
set_signal_status(e, DIRTY);
|
|
@@ -391,6 +438,9 @@ export class Batch {
|
|
|
391
438
|
schedule_effect(e);
|
|
392
439
|
}
|
|
393
440
|
|
|
441
|
+
this.#dirty_effects = [];
|
|
442
|
+
this.#maybe_dirty_effects = [];
|
|
443
|
+
|
|
394
444
|
this.flush();
|
|
395
445
|
}
|
|
396
446
|
|
|
@@ -561,7 +611,7 @@ function infinite_loop_guard() {
|
|
|
561
611
|
}
|
|
562
612
|
}
|
|
563
613
|
|
|
564
|
-
/** @type {Effect
|
|
614
|
+
/** @type {Set<Effect> | null} */
|
|
565
615
|
export let eager_block_effects = null;
|
|
566
616
|
|
|
567
617
|
/**
|
|
@@ -578,7 +628,7 @@ function flush_queued_effects(effects) {
|
|
|
578
628
|
var effect = effects[i++];
|
|
579
629
|
|
|
580
630
|
if ((effect.f & (DESTROYED | INERT)) === 0 && is_dirty(effect)) {
|
|
581
|
-
eager_block_effects =
|
|
631
|
+
eager_block_effects = new Set();
|
|
582
632
|
|
|
583
633
|
update_effect(effect);
|
|
584
634
|
|
|
@@ -601,15 +651,34 @@ function flush_queued_effects(effects) {
|
|
|
601
651
|
|
|
602
652
|
// If update_effect() has a flushSync() in it, we may have flushed another flush_queued_effects(),
|
|
603
653
|
// which already handled this logic and did set eager_block_effects to null.
|
|
604
|
-
if (eager_block_effects?.
|
|
605
|
-
// TODO this feels incorrect! it gets the tests passing
|
|
654
|
+
if (eager_block_effects?.size > 0) {
|
|
606
655
|
old_values.clear();
|
|
607
656
|
|
|
608
657
|
for (const e of eager_block_effects) {
|
|
609
|
-
|
|
658
|
+
// Skip eager effects that have already been unmounted
|
|
659
|
+
if ((e.f & (DESTROYED | INERT)) !== 0) continue;
|
|
660
|
+
|
|
661
|
+
// Run effects in order from ancestor to descendant, else we could run into nullpointers
|
|
662
|
+
/** @type {Effect[]} */
|
|
663
|
+
const ordered_effects = [e];
|
|
664
|
+
let ancestor = e.parent;
|
|
665
|
+
while (ancestor !== null) {
|
|
666
|
+
if (eager_block_effects.has(ancestor)) {
|
|
667
|
+
eager_block_effects.delete(ancestor);
|
|
668
|
+
ordered_effects.push(ancestor);
|
|
669
|
+
}
|
|
670
|
+
ancestor = ancestor.parent;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
for (let j = ordered_effects.length - 1; j >= 0; j--) {
|
|
674
|
+
const e = ordered_effects[j];
|
|
675
|
+
// Skip eager effects that have already been unmounted
|
|
676
|
+
if ((e.f & (DESTROYED | INERT)) !== 0) continue;
|
|
677
|
+
update_effect(e);
|
|
678
|
+
}
|
|
610
679
|
}
|
|
611
680
|
|
|
612
|
-
eager_block_effects
|
|
681
|
+
eager_block_effects.clear();
|
|
613
682
|
}
|
|
614
683
|
}
|
|
615
684
|
}
|
|
@@ -623,15 +692,24 @@ function flush_queued_effects(effects) {
|
|
|
623
692
|
* these effects can re-run after another batch has been committed
|
|
624
693
|
* @param {Value} value
|
|
625
694
|
* @param {Source[]} sources
|
|
695
|
+
* @param {Set<Value>} marked
|
|
696
|
+
* @param {Map<Reaction, boolean>} checked
|
|
626
697
|
*/
|
|
627
|
-
function mark_effects(value, sources) {
|
|
698
|
+
function mark_effects(value, sources, marked, checked) {
|
|
699
|
+
if (marked.has(value)) return;
|
|
700
|
+
marked.add(value);
|
|
701
|
+
|
|
628
702
|
if (value.reactions !== null) {
|
|
629
703
|
for (const reaction of value.reactions) {
|
|
630
704
|
const flags = reaction.f;
|
|
631
705
|
|
|
632
706
|
if ((flags & DERIVED) !== 0) {
|
|
633
|
-
mark_effects(/** @type {Derived} */ (reaction), sources);
|
|
634
|
-
} else if (
|
|
707
|
+
mark_effects(/** @type {Derived} */ (reaction), sources, marked, checked);
|
|
708
|
+
} else if (
|
|
709
|
+
(flags & (ASYNC | BLOCK_EFFECT)) !== 0 &&
|
|
710
|
+
(flags & DIRTY) === 0 && // we may have scheduled this one already
|
|
711
|
+
depends_on(reaction, sources, checked)
|
|
712
|
+
) {
|
|
635
713
|
set_signal_status(reaction, DIRTY);
|
|
636
714
|
schedule_effect(/** @type {Effect} */ (reaction));
|
|
637
715
|
}
|
|
@@ -642,20 +720,27 @@ function mark_effects(value, sources) {
|
|
|
642
720
|
/**
|
|
643
721
|
* @param {Reaction} reaction
|
|
644
722
|
* @param {Source[]} sources
|
|
723
|
+
* @param {Map<Reaction, boolean>} checked
|
|
645
724
|
*/
|
|
646
|
-
function depends_on(reaction, sources) {
|
|
725
|
+
function depends_on(reaction, sources, checked) {
|
|
726
|
+
const depends = checked.get(reaction);
|
|
727
|
+
if (depends !== undefined) return depends;
|
|
728
|
+
|
|
647
729
|
if (reaction.deps !== null) {
|
|
648
730
|
for (const dep of reaction.deps) {
|
|
649
731
|
if (sources.includes(dep)) {
|
|
650
732
|
return true;
|
|
651
733
|
}
|
|
652
734
|
|
|
653
|
-
if ((dep.f & DERIVED) !== 0 && depends_on(/** @type {Derived} */ (dep), sources)) {
|
|
735
|
+
if ((dep.f & DERIVED) !== 0 && depends_on(/** @type {Derived} */ (dep), sources, checked)) {
|
|
736
|
+
checked.set(/** @type {Derived} */ (dep), true);
|
|
654
737
|
return true;
|
|
655
738
|
}
|
|
656
739
|
}
|
|
657
740
|
}
|
|
658
741
|
|
|
742
|
+
checked.set(reaction, false);
|
|
743
|
+
|
|
659
744
|
return false;
|
|
660
745
|
}
|
|
661
746
|
|
|
@@ -10,7 +10,8 @@ import {
|
|
|
10
10
|
MAYBE_DIRTY,
|
|
11
11
|
STALE_REACTION,
|
|
12
12
|
UNOWNED,
|
|
13
|
-
ASYNC
|
|
13
|
+
ASYNC,
|
|
14
|
+
WAS_MARKED
|
|
14
15
|
} from '#client/constants';
|
|
15
16
|
import {
|
|
16
17
|
active_reaction,
|
|
@@ -127,7 +128,17 @@ export function async_derived(fn, location) {
|
|
|
127
128
|
// If this code is changed at some point, make sure to still access the then property
|
|
128
129
|
// of fn() to read any signals it might access, so that we track them as dependencies.
|
|
129
130
|
// We call `unset_context` to undo any `save` calls that happen inside `fn()`
|
|
130
|
-
Promise.resolve(fn())
|
|
131
|
+
Promise.resolve(fn())
|
|
132
|
+
.then(d.resolve, d.reject)
|
|
133
|
+
.then(() => {
|
|
134
|
+
if (batch === current_batch && batch.committed) {
|
|
135
|
+
// if the batch was rejected as stale, we need to cleanup
|
|
136
|
+
// after any `$.save(...)` calls inside `fn()`
|
|
137
|
+
batch.deactivate();
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
unset_context();
|
|
141
|
+
});
|
|
131
142
|
} catch (error) {
|
|
132
143
|
d.reject(error);
|
|
133
144
|
unset_context();
|
|
@@ -136,17 +147,16 @@ export function async_derived(fn, location) {
|
|
|
136
147
|
if (DEV) current_async_effect = null;
|
|
137
148
|
|
|
138
149
|
var batch = /** @type {Batch} */ (current_batch);
|
|
139
|
-
var pending = boundary.is_pending();
|
|
140
150
|
|
|
141
151
|
if (should_suspend) {
|
|
152
|
+
var blocking = !boundary.is_pending();
|
|
153
|
+
|
|
142
154
|
boundary.update_pending_count(1);
|
|
143
|
-
|
|
144
|
-
batch.increment();
|
|
155
|
+
batch.increment(blocking);
|
|
145
156
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
157
|
+
deferreds.get(batch)?.reject(STALE_REACTION);
|
|
158
|
+
deferreds.delete(batch); // delete to ensure correct order in Map iteration below
|
|
159
|
+
deferreds.set(batch, d);
|
|
150
160
|
}
|
|
151
161
|
|
|
152
162
|
/**
|
|
@@ -156,7 +166,7 @@ export function async_derived(fn, location) {
|
|
|
156
166
|
const handler = (value, error = undefined) => {
|
|
157
167
|
current_async_effect = null;
|
|
158
168
|
|
|
159
|
-
|
|
169
|
+
batch.activate();
|
|
160
170
|
|
|
161
171
|
if (error) {
|
|
162
172
|
if (error !== STALE_REACTION) {
|
|
@@ -193,7 +203,7 @@ export function async_derived(fn, location) {
|
|
|
193
203
|
|
|
194
204
|
if (should_suspend) {
|
|
195
205
|
boundary.update_pending_count(-1);
|
|
196
|
-
|
|
206
|
+
batch.decrement(blocking);
|
|
197
207
|
}
|
|
198
208
|
};
|
|
199
209
|
|
|
@@ -317,6 +327,7 @@ export function execute_derived(derived) {
|
|
|
317
327
|
|
|
318
328
|
stack.push(derived);
|
|
319
329
|
|
|
330
|
+
derived.f &= ~WAS_MARKED;
|
|
320
331
|
destroy_derived_effects(derived);
|
|
321
332
|
value = update_reaction(derived);
|
|
322
333
|
} finally {
|
|
@@ -326,6 +337,7 @@ export function execute_derived(derived) {
|
|
|
326
337
|
}
|
|
327
338
|
} else {
|
|
328
339
|
try {
|
|
340
|
+
derived.f &= ~WAS_MARKED;
|
|
329
341
|
destroy_derived_effects(derived);
|
|
330
342
|
value = update_reaction(derived);
|
|
331
343
|
} finally {
|
|
@@ -27,7 +27,8 @@ import {
|
|
|
27
27
|
MAYBE_DIRTY,
|
|
28
28
|
BLOCK_EFFECT,
|
|
29
29
|
ROOT_EFFECT,
|
|
30
|
-
ASYNC
|
|
30
|
+
ASYNC,
|
|
31
|
+
WAS_MARKED
|
|
31
32
|
} from '#client/constants';
|
|
32
33
|
import * as e from '../errors.js';
|
|
33
34
|
import { legacy_mode_flag, tracing_mode_flag } from '../../flags/index.js';
|
|
@@ -332,11 +333,14 @@ function mark_reactions(signal, status) {
|
|
|
332
333
|
}
|
|
333
334
|
|
|
334
335
|
if ((flags & DERIVED) !== 0) {
|
|
335
|
-
|
|
336
|
+
if ((flags & WAS_MARKED) === 0) {
|
|
337
|
+
reaction.f |= WAS_MARKED;
|
|
338
|
+
mark_reactions(/** @type {Derived} */ (reaction), MAYBE_DIRTY);
|
|
339
|
+
}
|
|
336
340
|
} else if (not_dirty) {
|
|
337
341
|
if ((flags & BLOCK_EFFECT) !== 0) {
|
|
338
342
|
if (eager_block_effects !== null) {
|
|
339
|
-
eager_block_effects.
|
|
343
|
+
eager_block_effects.add(/** @type {Effect} */ (reaction));
|
|
340
344
|
}
|
|
341
345
|
}
|
|
342
346
|
|
|
@@ -20,7 +20,8 @@ import {
|
|
|
20
20
|
DISCONNECTED,
|
|
21
21
|
REACTION_IS_UPDATING,
|
|
22
22
|
STALE_REACTION,
|
|
23
|
-
ERROR_VALUE
|
|
23
|
+
ERROR_VALUE,
|
|
24
|
+
WAS_MARKED
|
|
24
25
|
} from './constants.js';
|
|
25
26
|
import { old_values } from './reactivity/sources.js';
|
|
26
27
|
import {
|
|
@@ -161,6 +162,10 @@ export function is_dirty(reaction) {
|
|
|
161
162
|
var dependencies = reaction.deps;
|
|
162
163
|
var is_unowned = (flags & UNOWNED) !== 0;
|
|
163
164
|
|
|
165
|
+
if (flags & DERIVED) {
|
|
166
|
+
reaction.f &= ~WAS_MARKED;
|
|
167
|
+
}
|
|
168
|
+
|
|
164
169
|
if (dependencies !== null) {
|
|
165
170
|
var i;
|
|
166
171
|
var dependency;
|
|
@@ -418,15 +418,6 @@ export function ensure_array_like(array_like_or_iterator) {
|
|
|
418
418
|
return [];
|
|
419
419
|
}
|
|
420
420
|
|
|
421
|
-
/**
|
|
422
|
-
* @param {any[]} args
|
|
423
|
-
* @param {Function} [inspect]
|
|
424
|
-
*/
|
|
425
|
-
// eslint-disable-next-line no-console
|
|
426
|
-
export function inspect(args, inspect = console.log) {
|
|
427
|
-
inspect('init', ...args);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
421
|
/**
|
|
431
422
|
* @template V
|
|
432
423
|
* @param {() => V} get_value
|
package/src/version.js
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -261,6 +261,6 @@
|
|
|
261
261
|
null,
|
|
262
262
|
null
|
|
263
263
|
],
|
|
264
|
-
"mappings": ";;;;;;;kBAUiBA,2BAA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAkC/BC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAwEhBC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;kBAwBbC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCbC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;aAwBrBC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCfC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BdC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;kBAuBRC,OAAOA;;;;;;;;;;;;;;;;kBAgBPC,eAAeA;;;;;;;;;;;;;;;;aAgBpBC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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