svelte 5.58.0 → 5.58.1
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/3-transform/client/utils.js +3 -2
- package/src/compiler/phases/3-transform/server/visitors/ExpressionStatement.js +8 -0
- package/src/compiler/print/index.js +45 -57
- package/src/index-client.js +3 -3
- package/src/internal/client/constants.js +8 -1
- package/src/internal/client/dev/debug.js +6 -6
- package/src/internal/client/dev/tracing.js +67 -11
- package/src/internal/client/dom/blocks/async.js +2 -1
- package/src/internal/client/dom/blocks/await.js +108 -18
- package/src/internal/client/dom/blocks/boundary.js +107 -70
- package/src/internal/client/dom/blocks/branches.js +15 -22
- package/src/internal/client/dom/blocks/each.js +88 -13
- package/src/internal/client/dom/elements/attributes.js +2 -1
- package/src/internal/client/dom/elements/bindings/input.js +19 -10
- package/src/internal/client/dom/elements/bindings/select.js +2 -7
- package/src/internal/client/dom/elements/events.js +27 -2
- package/src/internal/client/dom/operations.js +2 -3
- package/src/internal/client/error-handling.js +4 -12
- package/src/internal/client/errors.js +18 -2
- package/src/internal/client/index.js +0 -1
- package/src/internal/client/reactivity/async.js +247 -122
- package/src/internal/client/reactivity/batch.js +1102 -530
- package/src/internal/client/reactivity/deriveds.js +281 -177
- package/src/internal/client/reactivity/effects.js +44 -28
- package/src/internal/client/reactivity/sources.js +30 -124
- package/src/internal/client/reactivity/status.js +1 -1
- package/src/internal/client/render.js +11 -0
- package/src/internal/client/runtime.js +925 -152
- package/src/internal/client/validate.js +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/src/internal/client/reactivity/utils.js +0 -18
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/** @import {
|
|
1
|
+
/** @import { ComponentContext, ComponentContextLegacy, Derived, Effect, TemplateNode, TransitionManager } from '#client' */
|
|
2
|
+
/** @import { Blocker } from './async.js' */
|
|
2
3
|
import {
|
|
3
4
|
is_dirty,
|
|
4
5
|
active_effect,
|
|
@@ -9,9 +10,11 @@ import {
|
|
|
9
10
|
remove_reactions,
|
|
10
11
|
set_active_reaction,
|
|
11
12
|
set_is_destroying_effect,
|
|
13
|
+
teardown_version,
|
|
12
14
|
untrack,
|
|
13
15
|
untracking,
|
|
14
|
-
set_active_effect
|
|
16
|
+
set_active_effect,
|
|
17
|
+
abort_all
|
|
15
18
|
} from '../runtime.js';
|
|
16
19
|
import {
|
|
17
20
|
DIRTY,
|
|
@@ -29,7 +32,6 @@ import {
|
|
|
29
32
|
HEAD_EFFECT,
|
|
30
33
|
MAYBE_DIRTY,
|
|
31
34
|
EFFECT_PRESERVED,
|
|
32
|
-
STALE_REACTION,
|
|
33
35
|
USER_EFFECT,
|
|
34
36
|
ASYNC,
|
|
35
37
|
CONNECTED,
|
|
@@ -43,9 +45,8 @@ import { DEV } from 'esm-env';
|
|
|
43
45
|
import { define_property } from '../../shared/utils.js';
|
|
44
46
|
import { get_next_sibling } from '../dom/operations.js';
|
|
45
47
|
import { component_context, dev_current_component_function, dev_stack } from '../context.js';
|
|
46
|
-
import { Batch, collected_effects,
|
|
48
|
+
import { Batch, collected_effects, set_teardown_context, teardown_context } from './batch.js';
|
|
47
49
|
import { flatten } from './async.js';
|
|
48
|
-
import { without_reactive_context } from '../dom/elements/bindings/shared.js';
|
|
49
50
|
import { set_signal_status } from './status.js';
|
|
50
51
|
|
|
51
52
|
/**
|
|
@@ -103,6 +104,8 @@ function create_effect(type, fn) {
|
|
|
103
104
|
var effect = {
|
|
104
105
|
ctx: component_context,
|
|
105
106
|
deps: null,
|
|
107
|
+
dv: null,
|
|
108
|
+
edges: null,
|
|
106
109
|
nodes: null,
|
|
107
110
|
f: type | DIRTY | CONNECTED,
|
|
108
111
|
first: null,
|
|
@@ -121,8 +124,6 @@ function create_effect(type, fn) {
|
|
|
121
124
|
effect.component_function = dev_current_component_function;
|
|
122
125
|
}
|
|
123
126
|
|
|
124
|
-
current_batch?.register_created_effect(effect);
|
|
125
|
-
|
|
126
127
|
/** @type {Effect | null} */
|
|
127
128
|
var e = effect;
|
|
128
129
|
|
|
@@ -132,7 +133,7 @@ function create_effect(type, fn) {
|
|
|
132
133
|
collected_effects.push(effect);
|
|
133
134
|
} else {
|
|
134
135
|
// schedule for later
|
|
135
|
-
Batch.ensure().schedule(effect);
|
|
136
|
+
Batch.ensure().schedule(effect, DIRTY);
|
|
136
137
|
}
|
|
137
138
|
} else if (fn !== null) {
|
|
138
139
|
try {
|
|
@@ -146,7 +147,7 @@ function create_effect(type, fn) {
|
|
|
146
147
|
// won't re-run, has no DOM, and has no teardown etc)
|
|
147
148
|
// then we skip it and go to its child (if any)
|
|
148
149
|
if (
|
|
149
|
-
e.
|
|
150
|
+
e.edges === null &&
|
|
150
151
|
e.teardown === null &&
|
|
151
152
|
e.nodes === null &&
|
|
152
153
|
e.first === e.last && // either `null`, or a singular child
|
|
@@ -352,7 +353,7 @@ export function legacy_pre_effect_reset() {
|
|
|
352
353
|
|
|
353
354
|
// If the effect is CLEAN, then make it MAYBE_DIRTY. This ensures we traverse through
|
|
354
355
|
// the effects dependencies and correctly ensure each dependency is up-to-date.
|
|
355
|
-
if ((effect.f & CLEAN) !== 0 && effect.
|
|
356
|
+
if ((effect.f & CLEAN) !== 0 && effect.edges !== null) {
|
|
356
357
|
set_signal_status(effect, MAYBE_DIRTY);
|
|
357
358
|
}
|
|
358
359
|
|
|
@@ -446,6 +447,8 @@ export function execute_effect_teardown(effect) {
|
|
|
446
447
|
var teardown = effect.teardown;
|
|
447
448
|
if (teardown !== null) {
|
|
448
449
|
const previously_destroying_effect = is_destroying_effect;
|
|
450
|
+
const previous_teardown_version = teardown_version;
|
|
451
|
+
const previous_teardown_context = teardown_context;
|
|
449
452
|
const previous_reaction = active_reaction;
|
|
450
453
|
set_is_destroying_effect(true);
|
|
451
454
|
set_active_reaction(null);
|
|
@@ -457,7 +460,8 @@ export function execute_effect_teardown(effect) {
|
|
|
457
460
|
// themselves mid-teardown are skipped by invoke_error_boundary.
|
|
458
461
|
invoke_error_boundary(error, effect.parent);
|
|
459
462
|
} finally {
|
|
460
|
-
set_is_destroying_effect(previously_destroying_effect);
|
|
463
|
+
set_is_destroying_effect(previously_destroying_effect, previous_teardown_version);
|
|
464
|
+
set_teardown_context(previous_teardown_context);
|
|
461
465
|
set_active_reaction(previous_reaction);
|
|
462
466
|
}
|
|
463
467
|
}
|
|
@@ -473,13 +477,7 @@ export function destroy_effect_children(signal, remove_dom = false) {
|
|
|
473
477
|
signal.first = signal.last = null;
|
|
474
478
|
|
|
475
479
|
while (effect !== null) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
if (controller !== null) {
|
|
479
|
-
without_reactive_context(() => {
|
|
480
|
-
controller.abort(STALE_REACTION);
|
|
481
|
-
});
|
|
482
|
-
}
|
|
480
|
+
abort_all(effect);
|
|
483
481
|
|
|
484
482
|
var next = effect.next;
|
|
485
483
|
|
|
@@ -529,7 +527,7 @@ export function destroy_effect(effect, remove_dom = true) {
|
|
|
529
527
|
|
|
530
528
|
effect.f |= DESTROYING;
|
|
531
529
|
destroy_effect_children(effect, remove_dom && !removed);
|
|
532
|
-
remove_reactions(effect
|
|
530
|
+
remove_reactions(effect);
|
|
533
531
|
|
|
534
532
|
var transitions = effect.nodes && effect.nodes.t;
|
|
535
533
|
|
|
@@ -562,6 +560,8 @@ export function destroy_effect(effect, remove_dom = true) {
|
|
|
562
560
|
effect.teardown =
|
|
563
561
|
effect.ctx =
|
|
564
562
|
effect.deps =
|
|
563
|
+
effect.dv =
|
|
564
|
+
effect.edges =
|
|
565
565
|
effect.fn =
|
|
566
566
|
effect.nodes =
|
|
567
567
|
effect.ac =
|
|
@@ -626,8 +626,28 @@ export function pause_effect(effect, callback, destroy = true) {
|
|
|
626
626
|
};
|
|
627
627
|
|
|
628
628
|
var remaining = transitions.length;
|
|
629
|
+
|
|
629
630
|
if (remaining > 0) {
|
|
630
|
-
var
|
|
631
|
+
var context = teardown_context;
|
|
632
|
+
|
|
633
|
+
var check = () => {
|
|
634
|
+
if (!--remaining) {
|
|
635
|
+
var previous_context = teardown_context;
|
|
636
|
+
|
|
637
|
+
try {
|
|
638
|
+
if (context) {
|
|
639
|
+
// Other outros can share this context, and state may have changed
|
|
640
|
+
// since its derived values were cached.
|
|
641
|
+
context.derived_cache.clear();
|
|
642
|
+
set_teardown_context(context);
|
|
643
|
+
}
|
|
644
|
+
fn();
|
|
645
|
+
} finally {
|
|
646
|
+
if (context) set_teardown_context(previous_context);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
|
|
631
651
|
for (var transition of transitions) {
|
|
632
652
|
transition.out(check);
|
|
633
653
|
}
|
|
@@ -701,13 +721,13 @@ function resume_children(effect, local) {
|
|
|
701
721
|
if ((effect.f & INERT) === 0) return;
|
|
702
722
|
effect.f ^= INERT;
|
|
703
723
|
|
|
704
|
-
// If a dependency of this effect changed while it was paused,
|
|
724
|
+
// If a dependency of this effect may have changed while it was paused,
|
|
705
725
|
// schedule the effect to update. we don't use `is_dirty`
|
|
706
726
|
// here because we don't want to eagerly recompute a derived like
|
|
707
|
-
// `{#if foo}{foo.bar()}{/if}` if `foo` is now `undefined
|
|
727
|
+
// `{#if foo}{foo.bar()}{/if}` if `foo` is now `undefined`.
|
|
708
728
|
if ((effect.f & CLEAN) === 0) {
|
|
709
|
-
|
|
710
|
-
Batch.ensure().schedule(effect);
|
|
729
|
+
// Assumption: This happens during the commit phase of the batch, causing another flush, but it's safe
|
|
730
|
+
Batch.ensure().schedule(effect, MAYBE_DIRTY);
|
|
711
731
|
}
|
|
712
732
|
|
|
713
733
|
var child = effect.first;
|
|
@@ -733,10 +753,6 @@ function resume_children(effect, local) {
|
|
|
733
753
|
}
|
|
734
754
|
}
|
|
735
755
|
|
|
736
|
-
export function aborted(effect = /** @type {Effect} */ (active_effect)) {
|
|
737
|
-
return (effect.f & DESTROYED) !== 0;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
756
|
/**
|
|
741
757
|
* @param {Effect} effect
|
|
742
758
|
* @param {DocumentFragment} fragment
|
|
@@ -7,13 +7,12 @@ import {
|
|
|
7
7
|
get,
|
|
8
8
|
set_untracked_writes,
|
|
9
9
|
untrack,
|
|
10
|
-
increment_write_version,
|
|
11
10
|
update_effect,
|
|
12
11
|
current_sources,
|
|
13
12
|
is_dirty,
|
|
14
13
|
untracking,
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
push_reaction_value,
|
|
15
|
+
is_destroying_effect
|
|
17
16
|
} from '../runtime.js';
|
|
18
17
|
import { equals, safe_equals } from './equality.js';
|
|
19
18
|
import {
|
|
@@ -25,7 +24,9 @@ import {
|
|
|
25
24
|
MAYBE_DIRTY,
|
|
26
25
|
BLOCK_EFFECT,
|
|
27
26
|
ROOT_EFFECT,
|
|
28
|
-
ASYNC
|
|
27
|
+
ASYNC,
|
|
28
|
+
ASSIGNED,
|
|
29
|
+
ERROR_VALUE
|
|
29
30
|
} from '#client/constants';
|
|
30
31
|
import * as e from '../errors.js';
|
|
31
32
|
import { legacy_mode_flag, tracing_mode_flag } from '../../flags/index.js';
|
|
@@ -35,21 +36,18 @@ import { component_context, is_runes } from '../context.js';
|
|
|
35
36
|
import {
|
|
36
37
|
Batch,
|
|
37
38
|
batch_values,
|
|
38
|
-
eager_block_effects,
|
|
39
|
-
schedule_effect,
|
|
40
39
|
legacy_updates,
|
|
40
|
+
in_real_world,
|
|
41
|
+
teardown_write,
|
|
41
42
|
source_stacks
|
|
42
43
|
} from './batch.js';
|
|
43
44
|
import { proxy } from '../proxy.js';
|
|
44
45
|
import { execute_derived } from './deriveds.js';
|
|
45
|
-
import { set_signal_status
|
|
46
|
+
import { set_signal_status } from './status.js';
|
|
46
47
|
|
|
47
48
|
/** @type {Set<Effect>} */
|
|
48
49
|
export let eager_effects = new Set();
|
|
49
50
|
|
|
50
|
-
/** @type {Map<Value, any>} */
|
|
51
|
-
export const old_values = new Map();
|
|
52
|
-
|
|
53
51
|
/**
|
|
54
52
|
* @param {Set<any>} v
|
|
55
53
|
*/
|
|
@@ -57,7 +55,7 @@ export function set_eager_effects(v) {
|
|
|
57
55
|
eager_effects = v;
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
let eager_effects_deferred = false;
|
|
58
|
+
export let eager_effects_deferred = false;
|
|
61
59
|
|
|
62
60
|
export function set_eager_effects_deferred() {
|
|
63
61
|
eager_effects_deferred = true;
|
|
@@ -169,17 +167,6 @@ export function set(source, value, should_proxy = false) {
|
|
|
169
167
|
return internal_set(source, new_value, legacy_updates);
|
|
170
168
|
}
|
|
171
169
|
|
|
172
|
-
/**
|
|
173
|
-
* A set of signals we have already seen while traversing in mark_reactions.
|
|
174
|
-
* Not always set to balance the common case of sources only having a couple
|
|
175
|
-
* of (transitive) dependencies (where always creating a Set would be bad for perf)
|
|
176
|
-
* with the edge case of extremely deep or wide dependency arrays with cycles.
|
|
177
|
-
* @type {Set<any> | null}
|
|
178
|
-
*/
|
|
179
|
-
var seen = null;
|
|
180
|
-
/** Number of transitive dependencies, see {@link seen} for more info */
|
|
181
|
-
var count_deps = 0;
|
|
182
|
-
|
|
183
170
|
/**
|
|
184
171
|
* @template V
|
|
185
172
|
* @param {Value<V>} source
|
|
@@ -188,17 +175,21 @@ var count_deps = 0;
|
|
|
188
175
|
* @returns {V}
|
|
189
176
|
*/
|
|
190
177
|
export function internal_set(source, value, updated_during_traversal = null) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
old_values.set(source, value);
|
|
194
|
-
} else if (!old_values.has(source)) {
|
|
195
|
-
// only record the value from before the first write in this flush, otherwise a
|
|
196
|
-
// teardown would see the value from before whichever write happened to be last
|
|
197
|
-
old_values.set(source, source.v);
|
|
198
|
-
}
|
|
178
|
+
var same = source.equals(value) && (source.f & ERROR_VALUE) === 0;
|
|
179
|
+
var entry = batch_values?.get(source);
|
|
199
180
|
|
|
181
|
+
// A value that equals the real one may still overwrite a different value in the active view.
|
|
182
|
+
if (!same || (entry !== undefined && (entry.e || !source.equals.call(entry, value)))) {
|
|
200
183
|
var batch = Batch.ensure();
|
|
201
|
-
|
|
184
|
+
|
|
185
|
+
// If we are assigning to a dirty derived we eagerly execute it to track the dependencies. (Not if
|
|
186
|
+
// it's assigned already: it tracks them, and its flags don't tell whether the assignment still holds,
|
|
187
|
+
// which is what other views see when they undo this one — see `is_dirty`)
|
|
188
|
+
if ((source.f & (DERIVED | DIRTY | ASSIGNED)) === (DERIVED | DIRTY)) {
|
|
189
|
+
execute_derived(/** @type {Derived} */ (source));
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
batch.capture(source, value, same, false, updated_during_traversal);
|
|
202
193
|
|
|
203
194
|
if (DEV) {
|
|
204
195
|
if (tracing_mode_flag || active_effect !== null) {
|
|
@@ -231,30 +222,6 @@ export function internal_set(source, value, updated_during_traversal = null) {
|
|
|
231
222
|
}
|
|
232
223
|
}
|
|
233
224
|
|
|
234
|
-
if ((source.f & DERIVED) !== 0) {
|
|
235
|
-
const derived = /** @type {Derived} */ (source);
|
|
236
|
-
|
|
237
|
-
// if we are assigning to a dirty derived we set it to clean/maybe dirty but we also eagerly execute it to track the dependencies
|
|
238
|
-
if ((source.f & DIRTY) !== 0) {
|
|
239
|
-
execute_derived(derived);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// During time traveling we don't want to reset the status so that
|
|
243
|
-
// traversal of the graph in the other batches still happens
|
|
244
|
-
if (batch_values === null) {
|
|
245
|
-
update_derived_status(derived);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
source.wv = increment_write_version();
|
|
250
|
-
|
|
251
|
-
// For debugging, in case you want to know which reactions are being scheduled:
|
|
252
|
-
// log_reactions(source);
|
|
253
|
-
seen = null;
|
|
254
|
-
count_deps = 0;
|
|
255
|
-
mark_reactions(source, DIRTY, updated_during_traversal);
|
|
256
|
-
seen = null;
|
|
257
|
-
|
|
258
225
|
// It's possible that the current reaction might not have up-to-date dependencies
|
|
259
226
|
// whilst it's actively running. So in the case of ensuring it registers the reaction
|
|
260
227
|
// properly for itself, we need to ensure the current effect actually gets
|
|
@@ -271,10 +238,9 @@ export function internal_set(source, value, updated_during_traversal = null) {
|
|
|
271
238
|
untracked_writes.push(source);
|
|
272
239
|
}
|
|
273
240
|
}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
241
|
+
} else if (is_destroying_effect) {
|
|
242
|
+
// not a change, but the teardown no longer sees a reverted value
|
|
243
|
+
teardown_write(source);
|
|
278
244
|
}
|
|
279
245
|
|
|
280
246
|
return value;
|
|
@@ -283,6 +249,11 @@ export function internal_set(source, value, updated_during_traversal = null) {
|
|
|
283
249
|
export function flush_eager_effects() {
|
|
284
250
|
eager_effects_deferred = false;
|
|
285
251
|
|
|
252
|
+
// eager effects run in the real world, not in the view of a batch
|
|
253
|
+
in_real_world(run_eager_effects);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function run_eager_effects() {
|
|
286
257
|
for (const effect of eager_effects) {
|
|
287
258
|
// Mark clean inspect-effects as maybe dirty and then check their dirtiness
|
|
288
259
|
// instead of just updating the effects - this way we avoid overfiring.
|
|
@@ -346,68 +317,3 @@ export function update_pre(source, d = 1) {
|
|
|
346
317
|
export function increment(source) {
|
|
347
318
|
set(source, source.v + 1);
|
|
348
319
|
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* @param {Value} signal
|
|
352
|
-
* @param {number} status should be DIRTY or MAYBE_DIRTY
|
|
353
|
-
* @param {Effect[] | null} updated_during_traversal
|
|
354
|
-
* @returns {void}
|
|
355
|
-
*/
|
|
356
|
-
function mark_reactions(signal, status, updated_during_traversal) {
|
|
357
|
-
var reactions = signal.reactions;
|
|
358
|
-
if (reactions === null) return;
|
|
359
|
-
|
|
360
|
-
var runes = is_runes();
|
|
361
|
-
var length = reactions.length;
|
|
362
|
-
|
|
363
|
-
count_deps += length;
|
|
364
|
-
// Activate the `seen` Set if we think from the unusually high number of deps that
|
|
365
|
-
// there might be cycles in the graph, to avoid repeated lookups for reactions
|
|
366
|
-
// Example: https://github.com/sveltejs/svelte/issues/16658 has a graph with one source
|
|
367
|
-
// reaching ~10000 distinct deriveds/effects each, resulting in 65 million walks through repeated visits.
|
|
368
|
-
if (count_deps > 100000 && seen === null) seen = new Set();
|
|
369
|
-
|
|
370
|
-
if (seen !== null) {
|
|
371
|
-
if (seen.has(signal)) return;
|
|
372
|
-
seen.add(signal);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
for (var i = 0; i < length; i++) {
|
|
376
|
-
var reaction = reactions[i];
|
|
377
|
-
var flags = reaction.f;
|
|
378
|
-
|
|
379
|
-
// In legacy mode, skip the current effect to prevent infinite loops
|
|
380
|
-
if (!runes && reaction === active_effect) continue;
|
|
381
|
-
|
|
382
|
-
var not_dirty = (flags & DIRTY) === 0;
|
|
383
|
-
|
|
384
|
-
// don't set a DIRTY reaction to MAYBE_DIRTY
|
|
385
|
-
if (not_dirty) {
|
|
386
|
-
set_signal_status(reaction, status);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
if ((flags & EAGER_EFFECT) !== 0) {
|
|
390
|
-
// Eager effects need to run immediately:
|
|
391
|
-
// - for $inspect so that the stack trace makes sense
|
|
392
|
-
// - for $state.eager because they might be without an effect parent
|
|
393
|
-
eager_effects.add(/** @type {Effect} */ (reaction));
|
|
394
|
-
} else if ((flags & DERIVED) !== 0) {
|
|
395
|
-
var derived = /** @type {Derived} */ (reaction);
|
|
396
|
-
|
|
397
|
-
batch_values?.delete(derived);
|
|
398
|
-
mark_reactions(derived, MAYBE_DIRTY, updated_during_traversal);
|
|
399
|
-
} else if (not_dirty) {
|
|
400
|
-
var effect = /** @type {Effect} */ (reaction);
|
|
401
|
-
|
|
402
|
-
if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
|
|
403
|
-
eager_block_effects.add(effect);
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
if (updated_during_traversal !== null) {
|
|
407
|
-
updated_during_traversal.push(effect);
|
|
408
|
-
} else {
|
|
409
|
-
schedule_effect(effect);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
}
|
|
@@ -17,7 +17,7 @@ export function set_signal_status(signal, status) {
|
|
|
17
17
|
*/
|
|
18
18
|
export function update_derived_status(derived) {
|
|
19
19
|
// Only mark as MAYBE_DIRTY if disconnected and has dependencies.
|
|
20
|
-
if ((derived.f & CONNECTED) !== 0 || derived.
|
|
20
|
+
if ((derived.f & CONNECTED) !== 0 || derived.edges === null) {
|
|
21
21
|
set_signal_status(derived, CLEAN);
|
|
22
22
|
} else {
|
|
23
23
|
set_signal_status(derived, MAYBE_DIRTY);
|
|
@@ -25,6 +25,8 @@ import { assign_nodes } from './dom/template.js';
|
|
|
25
25
|
import { is_passive_event } from '../../utils.js';
|
|
26
26
|
import { COMMENT_NODE, TEXT_CACHE } from './constants.js';
|
|
27
27
|
import { boundary } from './dom/blocks/boundary.js';
|
|
28
|
+
import { current_batch } from './reactivity/batch.js';
|
|
29
|
+
import { async_mode_flag } from '../flags/index.js';
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* This is normally true — block effects should run their intro transitions —
|
|
@@ -118,6 +120,15 @@ export function hydrate(component, options) {
|
|
|
118
120
|
|
|
119
121
|
const instance = _mount(component, { ...options, anchor });
|
|
120
122
|
|
|
123
|
+
// The server rendered the hydrated DOM with the state that hydration ran with (set before `hydrate()`,
|
|
124
|
+
// or while hydrating, e.g. by lazily initialized state), so that state is the real world from now on.
|
|
125
|
+
// This is what happens when mounting, too, where the batch commits right away because the root boundary
|
|
126
|
+
// is pending. Otherwise, while the hydration batch waits for async work, other batches' views would undo
|
|
127
|
+
// those writes — e.g. that of a pending boundary's content, which renders in a batch of its own
|
|
128
|
+
if (async_mode_flag && current_batch !== null) {
|
|
129
|
+
current_batch.commit_writes();
|
|
130
|
+
}
|
|
131
|
+
|
|
121
132
|
set_hydrating(false);
|
|
122
133
|
|
|
123
134
|
return /** @type {Exports} */ (instance);
|