svelte 5.57.2 → 5.58.0

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.
Files changed (66) hide show
  1. package/README.md +1 -1
  2. package/compiler/index.js +1 -1
  3. package/elements.d.ts +1 -2
  4. package/package.json +2 -2
  5. package/src/compiler/phases/1-parse/acorn.js +4 -14
  6. package/src/compiler/phases/1-parse/index.js +8 -1
  7. package/src/compiler/phases/1-parse/read/context.js +3 -2
  8. package/src/compiler/phases/1-parse/read/expression.js +2 -4
  9. package/src/compiler/phases/1-parse/utils/bracket.js +6 -0
  10. package/src/compiler/phases/2-analyze/css/css-prune.js +0 -8
  11. package/src/compiler/phases/2-analyze/index.js +2 -1
  12. package/src/compiler/phases/2-analyze/visitors/AwaitExpression.js +17 -15
  13. package/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +30 -5
  14. package/src/compiler/phases/3-transform/client/transform-template/index.js +27 -9
  15. package/src/compiler/phases/3-transform/client/visitors/EachBlock.js +1 -1
  16. package/src/compiler/phases/3-transform/client/visitors/Fragment.js +13 -1
  17. package/src/compiler/phases/3-transform/client/visitors/HtmlTag.js +10 -2
  18. package/src/compiler/phases/3-transform/client/visitors/RegularElement.js +11 -2
  19. package/src/compiler/phases/3-transform/client/visitors/RenderTag.js +15 -7
  20. package/src/compiler/phases/3-transform/client/visitors/SlotElement.js +19 -1
  21. package/src/compiler/phases/3-transform/client/visitors/SvelteComponent.js +0 -1
  22. package/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +1 -1
  23. package/src/compiler/phases/3-transform/client/visitors/shared/element.js +1 -1
  24. package/src/compiler/phases/3-transform/client/visitors/shared/events.js +1 -1
  25. package/src/compiler/phases/3-transform/client/visitors/shared/utils.js +1 -1
  26. package/src/compiler/phases/3-transform/server/visitors/Fragment.js +6 -1
  27. package/src/compiler/phases/3-transform/server/visitors/TitleElement.js +1 -1
  28. package/src/compiler/phases/3-transform/server/visitors/shared/element.js +2 -1
  29. package/src/compiler/phases/3-transform/server/visitors/shared/utils.js +1 -1
  30. package/src/compiler/phases/patterns.js +0 -1
  31. package/src/compiler/print/index.js +4 -16
  32. package/src/compiler/state.js +1 -1
  33. package/src/compiler/utils/builders.js +0 -1
  34. package/src/compiler/utils/mapped_code.js +1 -12
  35. package/src/constants.js +0 -8
  36. package/src/internal/client/dev/debug.js +14 -0
  37. package/src/internal/client/dev/elements.js +25 -9
  38. package/src/internal/client/dom/blocks/await.js +1 -2
  39. package/src/internal/client/dom/blocks/boundary.js +4 -7
  40. package/src/internal/client/dom/blocks/branches.js +2 -1
  41. package/src/internal/client/dom/blocks/html.js +44 -10
  42. package/src/internal/client/dom/blocks/slot.js +19 -1
  43. package/src/internal/client/dom/blocks/snippet.js +13 -0
  44. package/src/internal/client/dom/blocks/svelte-component.js +1 -1
  45. package/src/internal/client/dom/blocks/svelte-element.js +2 -1
  46. package/src/internal/client/dom/elements/attributes.js +12 -4
  47. package/src/internal/client/dom/elements/bindings/select.js +2 -1
  48. package/src/internal/client/dom/hydration.js +4 -1
  49. package/src/internal/client/dom/template.js +0 -1
  50. package/src/internal/client/proxy.js +2 -1
  51. package/src/internal/client/reactivity/async.js +2 -1
  52. package/src/internal/client/reactivity/batch.js +84 -127
  53. package/src/internal/client/reactivity/deriveds.js +2 -1
  54. package/src/internal/client/reactivity/equality.js +0 -9
  55. package/src/internal/client/reactivity/props.js +0 -1
  56. package/src/internal/client/reactivity/sources.js +5 -3
  57. package/src/internal/client/reactivity/utils.js +5 -6
  58. package/src/internal/server/errors.js +2 -2
  59. package/src/internal/server/renderer.js +52 -118
  60. package/src/internal/shared/utils.js +12 -0
  61. package/src/motion/spring.js +1 -1
  62. package/src/motion/tweened.js +1 -1
  63. package/src/reactivity/create-subscriber.js +1 -1
  64. package/src/version.js +1 -1
  65. package/types/index.d.ts +2 -2
  66. package/types/index.d.ts.map +1 -1
@@ -38,7 +38,6 @@ import { defer_effect } from './utils.js';
38
38
  import { UNINITIALIZED } from '../../../constants.js';
39
39
  import { set_signal_status } from './status.js';
40
40
  import { invariant } from '../../shared/dev.js';
41
- import { log_effect_tree } from '../dev/debug.js';
42
41
  import { OBSOLETE } from './deriveds.js';
43
42
 
44
43
  /** @type {Batch | null} */
@@ -89,8 +88,8 @@ export let legacy_updates = null;
89
88
 
90
89
  var flush_count = 0;
91
90
 
92
- /** @type {Set<Value>} */
93
- var source_stacks = new Set();
91
+ /** Sources whose DEV update counts and stack traces need resetting after the flush. @type {Set<Value>} */
92
+ export const source_stacks = new Set();
94
93
 
95
94
  let uid = 1;
96
95
 
@@ -98,15 +97,15 @@ export class Batch {
98
97
  id = uid++;
99
98
 
100
99
  /** True as soon as `#process` was called */
101
- #started = false;
100
+ started = false;
102
101
 
103
102
  linked = true;
104
103
 
105
104
  /** @type {Batch | null} */
106
- #prev = null;
105
+ prev = null;
107
106
 
108
107
  /** @type {Batch | null} */
109
- #next = null;
108
+ next = null;
110
109
 
111
110
  /** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
112
111
  async_deriveds = new Map();
@@ -114,14 +113,14 @@ export class Batch {
114
113
  /**
115
114
  * The current values of any signals that are updated in this batch.
116
115
  * Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
117
- * They keys of this map are identical to `this.#previous`
116
+ * The keys of this map are identical to `this.previous`
118
117
  * @type {Map<Value, [any, boolean]>}
119
118
  */
120
119
  current = new Map();
121
120
 
122
121
  /**
123
122
  * The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
124
- * They keys of this map are identical to `this.#current`
123
+ * The keys of this map are identical to `this.current`
125
124
  * @type {Map<Value, any>}
126
125
  */
127
126
  previous = new Map();
@@ -177,16 +176,10 @@ export class Batch {
177
176
  #new_effects = [];
178
177
 
179
178
  /**
180
- * Deferred effects (which run after async work has completed) that are DIRTY
181
- * @type {Set<Effect>}
182
- */
183
- #dirty_effects = new Set();
184
-
185
- /**
186
- * Deferred effects that are MAYBE_DIRTY
187
- * @type {Set<Effect>}
179
+ * Deferred effects (which run after async work has completed) and their status (DIRTY or MAYBE_DIRTY)
180
+ * @type {Map<Effect, number>}
188
181
  */
189
- #maybe_dirty_effects = new Set();
182
+ #dirty_reactions = new Map();
190
183
 
191
184
  /**
192
185
  * A map of branches that still exist, but will be destroyed when this batch
@@ -208,12 +201,11 @@ export class Batch {
208
201
  #decrement_queued = false;
209
202
 
210
203
  constructor() {
211
- // link batch
212
204
  if (last_batch === null) {
213
205
  first_batch = last_batch = this;
214
206
  } else {
215
- last_batch.#next = this;
216
- this.#prev = last_batch;
207
+ last_batch.next = this;
208
+ this.prev = last_batch;
217
209
  }
218
210
 
219
211
  last_batch = this;
@@ -223,19 +215,8 @@ export class Batch {
223
215
  if (this.is_fork) return true;
224
216
 
225
217
  for (const effect of this.#blocking_pending.keys()) {
226
- var e = effect;
227
- var skipped = false;
228
-
229
- while (e.parent !== null) {
230
- if (this.#skipped_branches.has(e)) {
231
- skipped = true;
232
- break;
233
- }
234
-
235
- e = e.parent;
236
- }
237
-
238
- if (!skipped) {
218
+ // pending work inside a skipped branch doesn't block, the branch is going to be destroyed
219
+ if (!this.#is_skipped(effect)) {
239
220
  return true;
240
221
  }
241
222
  }
@@ -243,6 +224,18 @@ export class Batch {
243
224
  return false;
244
225
  }
245
226
 
227
+ /**
228
+ * Whether `effect` is inside a branch that this batch skips
229
+ * @param {Effect} effect
230
+ */
231
+ #is_skipped(effect) {
232
+ for (var e = /** @type {Effect | null} */ (effect); e !== null; e = e.parent) {
233
+ if (this.#skipped_branches.has(e)) return true;
234
+ }
235
+
236
+ return false;
237
+ }
238
+
246
239
  /**
247
240
  * Add an effect to the #skipped_branches map and reset its children
248
241
  * @param {Effect} effect
@@ -327,28 +320,14 @@ export class Batch {
327
320
  }
328
321
 
329
322
  #process() {
330
- this.#started = true;
331
-
332
- if (DEV) {
333
- // track all the values that were updated during this flush,
334
- // so that they can be reset afterwards
335
- for (const value of this.current.keys()) {
336
- source_stacks.add(value);
337
- }
338
- }
323
+ this.started = true;
339
324
 
340
325
  // We always reschedule previously-deferred effects, not just when
341
326
  // #is_deferred() is true, because traversing the tree could make
342
327
  // an if block that contains the last blocking pending effect falsy,
343
328
  // causing the block to no longer be deferred.
344
- for (const e of this.#dirty_effects) {
345
- this.#maybe_dirty_effects.delete(e);
346
- set_signal_status(e, DIRTY);
347
- this.schedule(e);
348
- }
349
-
350
- for (const e of this.#maybe_dirty_effects) {
351
- set_signal_status(e, MAYBE_DIRTY);
329
+ for (const [e, status] of this.#dirty_reactions) {
330
+ set_signal_status(e, status);
352
331
  this.schedule(e);
353
332
  }
354
333
 
@@ -389,6 +368,16 @@ export class Batch {
389
368
  throw e;
390
369
  }
391
370
  }
371
+
372
+ if (this.#scheduled.length > 0) {
373
+ // A later traversal may discover effects before ones we already collected.
374
+ // Recollect them together so they are flushed in tree order, rather than
375
+ // appending earlier effects after their later siblings.
376
+ for (const effect of render_effects) this.#scheduled.push(effect);
377
+ for (const effect of effects) this.#scheduled.push(effect);
378
+ render_effects.length = 0;
379
+ effects.length = 0;
380
+ }
392
381
  }
393
382
 
394
383
  // any writes should take effect in a subsequent batch
@@ -432,8 +421,7 @@ export class Batch {
432
421
  }
433
422
 
434
423
  // clear effects. Those that are still needed will be rescheduled through unskipping the skipped branches.
435
- this.#dirty_effects.clear();
436
- this.#maybe_dirty_effects.clear();
424
+ this.#dirty_reactions.clear();
437
425
 
438
426
  // append/remove branches
439
427
  for (const fn of this.#commit_callbacks) fn(this);
@@ -462,21 +450,6 @@ export class Batch {
462
450
  }
463
451
  }
464
452
 
465
- // Edge case: During traversal new branches might create effects that run immediately and set state,
466
- // causing an effect to be scheduled again. We need to traverse the current batch
467
- // once more in that case - most of the time this will just clean up dirty branches.
468
- if (this.#scheduled.length > 0) {
469
- if (next_batch !== null) {
470
- for (const e of this.#scheduled) {
471
- next_batch.#scheduled.push(e);
472
- }
473
-
474
- this.#scheduled = [];
475
- } else {
476
- next_batch = this;
477
- }
478
- }
479
-
480
453
  if (next_batch !== null) {
481
454
  old_values.clear();
482
455
  next_batch.#process();
@@ -510,7 +483,7 @@ export class Batch {
510
483
  } else if (async_mode_flag && (flags & (RENDER_EFFECT | MANAGED_EFFECT)) !== 0) {
511
484
  render_effects.push(effect);
512
485
  } else if (is_dirty(effect)) {
513
- if ((flags & BLOCK_EFFECT) !== 0) this.#maybe_dirty_effects.add(effect);
486
+ if ((flags & BLOCK_EFFECT) !== 0) this.add_dirty_reaction(effect, MAYBE_DIRTY);
514
487
  update_effect(effect);
515
488
  }
516
489
 
@@ -536,24 +509,23 @@ export class Batch {
536
509
  }
537
510
 
538
511
  #find_earlier_batch() {
539
- var batch = this.#prev;
540
-
541
- while (batch !== null) {
542
- if (!batch.is_fork) {
543
- // if the batches are connected, break
544
- for (const [value, [, is_derived]] of this.current) {
545
- if (batch.current.has(value) && !is_derived) {
546
- return batch;
547
- }
548
- }
549
- }
550
-
551
- batch = batch.#prev;
512
+ for (var batch = this.prev; batch !== null; batch = batch.prev) {
513
+ if (!batch.is_fork && this.#intersects(batch)) return batch;
552
514
  }
553
515
 
554
516
  return null;
555
517
  }
556
518
 
519
+ /** @param {Batch} batch */
520
+ #intersects(batch) {
521
+ for (const [source, [, is_derived]] of this.current) {
522
+ if (is_derived) continue;
523
+ if (batch.current.has(source)) return true;
524
+ }
525
+
526
+ return false;
527
+ }
528
+
557
529
  /**
558
530
  * @param {Batch} batch
559
531
  */
@@ -576,7 +548,7 @@ export class Batch {
576
548
  batch.async_deriveds.clear();
577
549
 
578
550
  // Mark is not guaranteed not touch these, so we transfer them
579
- this.transfer_effects(batch.#dirty_effects, batch.#maybe_dirty_effects);
551
+ this.transfer_reactions(batch.#dirty_reactions);
580
552
 
581
553
  /**
582
554
  * mark all effects that depend on `batch.current`, except the
@@ -605,7 +577,7 @@ export class Batch {
605
577
  var effect = /** @type {Effect} */ (reaction);
606
578
 
607
579
  if (flags & (ASYNC | BLOCK_EFFECT) && !this.async_deriveds.has(effect)) {
608
- this.#maybe_dirty_effects.delete(effect);
580
+ this.#dirty_reactions.delete(effect);
609
581
  set_signal_status(effect, DIRTY);
610
582
  this.schedule(effect);
611
583
  }
@@ -629,7 +601,7 @@ export class Batch {
629
601
  */
630
602
  #defer_effects(effects) {
631
603
  for (var i = 0; i < effects.length; i += 1) {
632
- defer_effect(effects[i], this.#dirty_effects, this.#maybe_dirty_effects);
604
+ defer_effect(effects[i], this.#dirty_reactions);
633
605
  }
634
606
  }
635
607
 
@@ -667,10 +639,6 @@ export class Batch {
667
639
 
668
640
  flush() {
669
641
  try {
670
- if (DEV) {
671
- source_stacks.clear();
672
- }
673
-
674
642
  is_processing = true;
675
643
  current_batch = this;
676
644
 
@@ -691,6 +659,8 @@ export class Batch {
691
659
  for (const source of source_stacks) {
692
660
  source.updated = null;
693
661
  }
662
+
663
+ source_stacks.clear();
694
664
  }
695
665
  }
696
666
  }
@@ -719,7 +689,7 @@ export class Batch {
719
689
  // in other words, we re-run block/async effects with the newly
720
690
  // committed state, unless the batch in question has a more
721
691
  // recent value for a given source
722
- for (let batch = first_batch; batch !== null; batch = batch.#next) {
692
+ for (let batch = first_batch; batch !== null; batch = batch.next) {
723
693
  var is_earlier = batch.id < this.id;
724
694
 
725
695
  /** @type {Source[]} */
@@ -756,7 +726,7 @@ export class Batch {
756
726
  );
757
727
 
758
728
  // If not started yet or no sources to update (which is e.g. possible for the very first batch) then bail
759
- if (!batch.#started || current.length === 0) continue;
729
+ if (!batch.started || current.length === 0) continue;
760
730
 
761
731
  // Re-run async/block effects that depend on distinct values changed in both batches (ignoring deriveds)
762
732
  var others = current.filter((source) => !this.current.has(source));
@@ -818,7 +788,7 @@ export class Batch {
818
788
  set_signal_status(effect, DIRTY);
819
789
  batch.schedule(effect);
820
790
  } else {
821
- batch.#dirty_effects.add(effect);
791
+ batch.add_dirty_reaction(effect, DIRTY);
822
792
  }
823
793
  }
824
794
  }
@@ -882,20 +852,24 @@ export class Batch {
882
852
  }
883
853
 
884
854
  /**
885
- * @param {Set<Effect>} dirty_effects
886
- * @param {Set<Effect>} maybe_dirty_effects
855
+ * @param {Map<Effect, number>} dirty_reactions
887
856
  */
888
- transfer_effects(dirty_effects, maybe_dirty_effects) {
889
- for (const e of dirty_effects) {
890
- this.#dirty_effects.add(e);
857
+ transfer_reactions(dirty_reactions) {
858
+ for (const [effect, status] of dirty_reactions) {
859
+ this.add_dirty_reaction(effect, status);
891
860
  }
892
861
 
893
- for (const e of maybe_dirty_effects) {
894
- this.#maybe_dirty_effects.add(e);
895
- }
862
+ dirty_reactions.clear();
863
+ }
896
864
 
897
- dirty_effects.clear();
898
- maybe_dirty_effects.clear();
865
+ /**
866
+ * @param {Effect} effect
867
+ * @param {number} status
868
+ */
869
+ add_dirty_reaction(effect, status) {
870
+ if (status === DIRTY || this.#dirty_reactions.get(effect) !== DIRTY) {
871
+ this.#dirty_reactions.set(effect, status);
872
+ }
899
873
  }
900
874
 
901
875
  /** @param {(batch: Batch) => void} fn */
@@ -918,7 +892,7 @@ export class Batch {
918
892
 
919
893
  if (!is_processing && !is_flushing_sync) {
920
894
  queue_micro_task(() => {
921
- if (!batch.#started) {
895
+ if (!batch.started) {
922
896
  batch.flush();
923
897
  }
924
898
  });
@@ -929,7 +903,7 @@ export class Batch {
929
903
  }
930
904
 
931
905
  apply() {
932
- if (!async_mode_flag || (!this.is_fork && this.#prev === null && this.#next === null)) {
906
+ if (!async_mode_flag || (!this.is_fork && this.prev === null && this.next === null)) {
933
907
  batch_values = null;
934
908
  return;
935
909
  }
@@ -942,32 +916,15 @@ export class Batch {
942
916
  }
943
917
 
944
918
  // ...and undo changes belonging to other batches unless they intersect
945
- for (let batch = first_batch; batch !== null; batch = batch.#next) {
919
+ for (let batch = first_batch; batch !== null; batch = batch.next) {
946
920
  if (batch === this || batch.is_fork) continue;
947
921
 
948
- // If two batches intersect, the latter batch will be merged into the earlier batch,
949
- // and we should treat them as a single set of changes
950
- var intersects = false;
951
-
952
- if (batch.id < this.id) {
953
- for (const [source, [, is_derived]] of batch.current) {
954
- // Derived values don't partake in the intersection mechanism, because a derived could
955
- // be triggered in one batch already but not the other one yet, causing a false-positive
956
- if (is_derived) continue;
957
-
958
- if (this.current.has(source)) {
959
- intersects = true;
960
- break;
961
- }
962
- }
963
- }
964
-
965
922
  // Since the latter batch merges into the earlier (if it resolves before the earlier one),
966
923
  // we treat the earlier values as "already applied". This way we don't need to rerun async
967
924
  // effects of the earlier batch in case they are merged.
968
925
  // As a result you can think of batch_values as having the latest values of all intersecting
969
926
  // batches up until this batch.
970
- if (!intersects) {
927
+ if (batch.id >= this.id || !batch.#intersects(this)) {
971
928
  for (const [source, previous] of batch.previous) {
972
929
  if (!batch_values.has(source)) {
973
930
  batch_values.set(source, previous);
@@ -1003,19 +960,19 @@ export class Batch {
1003
960
  // running it multiple times to not corrupt the linked list
1004
961
  if (!this.linked) return;
1005
962
 
1006
- var prev = this.#prev;
1007
- var next = this.#next;
963
+ var prev = this.prev;
964
+ var next = this.next;
1008
965
 
1009
966
  if (prev === null) {
1010
967
  first_batch = next;
1011
968
  } else {
1012
- prev.#next = next;
969
+ prev.next = next;
1013
970
  }
1014
971
 
1015
972
  if (next === null) {
1016
973
  last_batch = prev;
1017
974
  } else {
1018
- next.#prev = prev;
975
+ next.prev = prev;
1019
976
  }
1020
977
 
1021
978
  this.linked = false;
@@ -1462,7 +1419,7 @@ export function fork(fn) {
1462
1419
  },
1463
1420
  discard: () => {
1464
1421
  // cause any MAYBE_DIRTY deriveds to update
1465
- // if they depend on things thath changed
1422
+ // if they depend on things that changed
1466
1423
  // inside the discarded fork
1467
1424
  for (var source of batch.current.keys()) {
1468
1425
  source.wv = increment_write_version();
@@ -47,6 +47,7 @@ import { batch_values, current_batch, previous_batch } from './batch.js';
47
47
  import { increment_pending, unset_context } from './async.js';
48
48
  import { deferred, includes, noop } from '../../shared/utils.js';
49
49
  import { set_signal_status, update_derived_status } from './status.js';
50
+ import { stringify_derived } from '../dev/debug.js';
50
51
 
51
52
  /**
52
53
  * This allows us to track 'reactivity loss' that occurs when signals
@@ -120,7 +121,7 @@ export function async_derived(fn, label, location) {
120
121
  var promise = /** @type {Promise<V>} */ (/** @type {unknown} */ (undefined));
121
122
  var signal = source(/** @type {V} */ (UNINITIALIZED));
122
123
 
123
- if (DEV) signal.label = label ?? fn.toString();
124
+ if (DEV) signal.label = label ?? stringify_derived(fn);
124
125
 
125
126
  // only suspend in async deriveds created on initialisation
126
127
  var should_suspend = !active_reaction;
@@ -16,15 +16,6 @@ export function safe_not_equal(a, b) {
16
16
  : a !== b || (a !== null && typeof a === 'object') || typeof a === 'function';
17
17
  }
18
18
 
19
- /**
20
- * @param {unknown} a
21
- * @param {unknown} b
22
- * @returns {boolean}
23
- */
24
- export function not_equal(a, b) {
25
- return a !== b;
26
- }
27
-
28
19
  /** @type {Equals} */
29
20
  export function safe_equals(value) {
30
21
  return !safe_not_equal(value, this.v);
@@ -22,7 +22,6 @@ import { DESTROYED, LEGACY_PROPS, STATE_SYMBOL } from '#client/constants';
22
22
  import { proxy } from '../proxy.js';
23
23
  import { capture_store_binding } from './store.js';
24
24
  import { legacy_mode_flag } from '../../flags/index.js';
25
- import { effect, render_effect } from './effects.js';
26
25
 
27
26
  /**
28
27
  * @param {((value?: number) => number)} fn
@@ -37,7 +37,8 @@ import {
37
37
  batch_values,
38
38
  eager_block_effects,
39
39
  schedule_effect,
40
- legacy_updates
40
+ legacy_updates,
41
+ source_stacks
41
42
  } from './batch.js';
42
43
  import { proxy } from '../proxy.js';
43
44
  import { execute_derived } from './deriveds.js';
@@ -70,9 +71,9 @@ export function set_eager_effects_deferred() {
70
71
  */
71
72
  // TODO rename this to `state` throughout the codebase
72
73
  export function source(v, stack) {
73
- /** @type {Value} */
74
+ /** @type {Source<V>} */
74
75
  var signal = {
75
- f: 0, // TODO ideally we could skip this altogether, but it causes type errors
76
+ f: 0,
76
77
  v,
77
78
  reactions: null,
78
79
  equals,
@@ -202,6 +203,7 @@ export function internal_set(source, value, updated_during_traversal = null) {
202
203
  if (DEV) {
203
204
  if (tracing_mode_flag || active_effect !== null) {
204
205
  source.updated ??= new Map();
206
+ source_stacks.add(source);
205
207
 
206
208
  // For performance reasons, when not using $inspect.trace, we only start collecting stack traces
207
209
  // after the same source has been updated more than 5 times in the same flush cycle.
@@ -4,14 +4,13 @@ import { set_signal_status } from './status.js';
4
4
 
5
5
  /**
6
6
  * @param {Effect} effect
7
- * @param {Set<Effect>} dirty_effects
8
- * @param {Set<Effect>} maybe_dirty_effects
7
+ * @param {Map<Effect, number>} dirty_reactions
9
8
  */
10
- export function defer_effect(effect, dirty_effects, maybe_dirty_effects) {
9
+ export function defer_effect(effect, dirty_reactions) {
11
10
  if ((effect.f & DIRTY) !== 0) {
12
- dirty_effects.add(effect);
13
- } else if ((effect.f & MAYBE_DIRTY) !== 0) {
14
- maybe_dirty_effects.add(effect);
11
+ dirty_reactions.set(effect, DIRTY);
12
+ } else if ((effect.f & MAYBE_DIRTY) !== 0 && dirty_reactions.get(effect) !== DIRTY) {
13
+ dirty_reactions.set(effect, MAYBE_DIRTY);
15
14
  }
16
15
 
17
16
  // mark as clean so they get scheduled if they depend on pending async state
@@ -72,7 +72,7 @@ ${stack}\nhttps://svelte.dev/e/hydratable_clobbering`);
72
72
  /**
73
73
  * Failed to serialize `hydratable` data for key `%key%`.
74
74
  *
75
- * `hydratable` can serialize anything [`uneval` from `devalue`](https://npmjs.com/package/uneval) can, plus Promises.
75
+ * `hydratable` can serialize anything [`uneval` from `devalue`](https://npmjs.com/package/devalue) can, plus Promises.
76
76
  *
77
77
  * Cause:
78
78
  * %stack%
@@ -83,7 +83,7 @@ ${stack}\nhttps://svelte.dev/e/hydratable_clobbering`);
83
83
  export function hydratable_serialization_failed(key, stack) {
84
84
  const error = new Error(`hydratable_serialization_failed\nFailed to serialize \`hydratable\` data for key \`${key}\`.
85
85
 
86
- \`hydratable\` can serialize anything [\`uneval\` from \`devalue\`](https://npmjs.com/package/uneval) can, plus Promises.
86
+ \`hydratable\` can serialize anything [\`uneval\` from \`devalue\`](https://npmjs.com/package/devalue) can, plus Promises.
87
87
 
88
88
  Cause:
89
89
  ${stack}\nhttps://svelte.dev/e/hydratable_serialization_failed`);