svelte 5.57.2 → 5.57.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/visitors/shared/a11y/index.js +30 -5
- package/src/internal/client/dev/debug.js +14 -0
- package/src/internal/client/dom/blocks/boundary.js +4 -7
- package/src/internal/client/dom/elements/attributes.js +10 -2
- package/src/internal/client/proxy.js +2 -1
- package/src/internal/client/reactivity/batch.js +70 -112
- package/src/internal/client/reactivity/deriveds.js +2 -1
- package/src/internal/client/reactivity/sources.js +2 -2
- package/src/internal/client/reactivity/utils.js +5 -6
- package/src/internal/server/errors.js +2 -2
- package/src/version.js +1 -1
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -40,7 +40,8 @@ import {
|
|
|
40
40
|
regex_not_whitespace,
|
|
41
41
|
regex_redundant_img_alt,
|
|
42
42
|
regex_starts_with_vowel,
|
|
43
|
-
regex_whitespaces
|
|
43
|
+
regex_whitespaces,
|
|
44
|
+
regex_whitespaces_strict
|
|
44
45
|
} from '../../../../patterns.js';
|
|
45
46
|
import { is_event_attribute, is_text_attribute } from '../../../../../utils/ast.js';
|
|
46
47
|
import { list } from '../../../../../utils/string.js';
|
|
@@ -158,9 +159,7 @@ export function check_element(node, context) {
|
|
|
158
159
|
if (typeof value !== 'string') {
|
|
159
160
|
break;
|
|
160
161
|
}
|
|
161
|
-
for (const
|
|
162
|
-
const current_role = /** @type {ARIARoleDefinitionKey} current_role */ (c_r);
|
|
163
|
-
|
|
162
|
+
for (const current_role of get_role_tokens(value)) {
|
|
164
163
|
if (current_role && is_abstract_role(current_role)) {
|
|
165
164
|
w.a11y_no_abstract_role(attribute, current_role);
|
|
166
165
|
} else if (current_role && !aria_roles.includes(current_role)) {
|
|
@@ -286,7 +285,9 @@ export function check_element(node, context) {
|
|
|
286
285
|
}
|
|
287
286
|
|
|
288
287
|
const role = attribute_map.get('role');
|
|
289
|
-
const role_static_value = /** @type {ARIARoleDefinitionKey} */ (
|
|
288
|
+
const role_static_value = /** @type {ARIARoleDefinitionKey} */ (
|
|
289
|
+
get_effective_role(get_static_text_value(role))
|
|
290
|
+
);
|
|
290
291
|
|
|
291
292
|
// click-events-have-key-events
|
|
292
293
|
if (handlers.has('click')) {
|
|
@@ -778,6 +779,30 @@ function is_abstract_role(role) {
|
|
|
778
779
|
return abstract_roles.includes(role);
|
|
779
780
|
}
|
|
780
781
|
|
|
782
|
+
/**
|
|
783
|
+
* Role tokens use ASCII whitespace and ASCII case-insensitive matching.
|
|
784
|
+
* @param {string} value
|
|
785
|
+
*/
|
|
786
|
+
function get_role_tokens(value) {
|
|
787
|
+
return /** @type {ARIARoleDefinitionKey[]} */ (
|
|
788
|
+
// we use this instead of value.toLowerCase() to avoid lowercasing non-ASCII characters
|
|
789
|
+
value.replace(/[A-Z]/g, (char) => char.toLowerCase()).split(regex_whitespaces_strict)
|
|
790
|
+
);
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
/**
|
|
794
|
+
* The `role` attribute can list fallback roles, in which case the element
|
|
795
|
+
* gets the first one that is a known, non-abstract role. Preserve the original
|
|
796
|
+
* value if none match, so invalid roles retain their existing diagnostics.
|
|
797
|
+
* @param {string | null} value
|
|
798
|
+
*/
|
|
799
|
+
function get_effective_role(value) {
|
|
800
|
+
if (value === null) return null;
|
|
801
|
+
const roles = get_role_tokens(value);
|
|
802
|
+
// we return the whole value here in case there's no known, non-abstract role in the list
|
|
803
|
+
return roles.find((role) => aria_roles.includes(role) && !is_abstract_role(role)) ?? value;
|
|
804
|
+
}
|
|
805
|
+
|
|
781
806
|
/**
|
|
782
807
|
* @param {AST.Attribute | undefined} attribute
|
|
783
808
|
*/
|
|
@@ -514,3 +514,17 @@ export function log_inconsistent_branches(effect) {
|
|
|
514
514
|
|
|
515
515
|
return true;
|
|
516
516
|
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Stringify a derived function, removing `$.track_reactivity_loss` and `$.get` etc
|
|
520
|
+
* @param {Function} fn
|
|
521
|
+
*/
|
|
522
|
+
export function stringify_derived(fn) {
|
|
523
|
+
return `{${fn
|
|
524
|
+
.toString()
|
|
525
|
+
.replace(/^async \(\) => /, '')
|
|
526
|
+
.replace(/^\(/, '')
|
|
527
|
+
.replace(/\$\.get\((.+?)\)/g, (_, name) => name)
|
|
528
|
+
.replace(/\$\.track_reactivity_loss\((.+?)\)\(\)/g, (_, name) => name)
|
|
529
|
+
.replace(/\)$/, '')}}`;
|
|
530
|
+
}
|
|
@@ -112,11 +112,8 @@ export class Boundary {
|
|
|
112
112
|
#pending_count = 0;
|
|
113
113
|
#pending_count_update_queued = false;
|
|
114
114
|
|
|
115
|
-
/** @type {
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
/** @type {Set<Effect>} */
|
|
119
|
-
#maybe_dirty_effects = new Set();
|
|
115
|
+
/** @type {Map<Effect, number>} */
|
|
116
|
+
#dirty_reactions = new Map();
|
|
120
117
|
|
|
121
118
|
/**
|
|
122
119
|
* A source containing the number of pending async deriveds/expressions.
|
|
@@ -358,7 +355,7 @@ export class Boundary {
|
|
|
358
355
|
|
|
359
356
|
// any effects that were previously deferred should be transferred
|
|
360
357
|
// to the batch, which will flush in the next microtask
|
|
361
|
-
batch.
|
|
358
|
+
batch.transfer_reactions(this.#dirty_reactions);
|
|
362
359
|
}
|
|
363
360
|
|
|
364
361
|
/**
|
|
@@ -366,7 +363,7 @@ export class Boundary {
|
|
|
366
363
|
* @param {Effect} effect
|
|
367
364
|
*/
|
|
368
365
|
defer_effect(effect) {
|
|
369
|
-
defer_effect(effect, this.#
|
|
366
|
+
defer_effect(effect, this.#dirty_reactions);
|
|
370
367
|
}
|
|
371
368
|
|
|
372
369
|
/**
|
|
@@ -178,7 +178,8 @@ export function set_attribute(element, attribute, value, skip_warning) {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
var previous = attributes[attribute];
|
|
182
|
+
if (previous === (attributes[attribute] = value)) return;
|
|
182
183
|
|
|
183
184
|
if (attribute === 'loading') {
|
|
184
185
|
// @ts-expect-error
|
|
@@ -190,7 +191,14 @@ export function set_attribute(element, attribute, value, skip_warning) {
|
|
|
190
191
|
} else if (typeof value !== 'string' && get_setters(element).has(attribute)) {
|
|
191
192
|
// @ts-ignore
|
|
192
193
|
element[attribute] = value;
|
|
193
|
-
} else
|
|
194
|
+
} else if (
|
|
195
|
+
// while hydrating, skip a number or boolean whose string the server already rendered
|
|
196
|
+
!(
|
|
197
|
+
hydrating &&
|
|
198
|
+
(typeof value === 'number' || typeof value === 'boolean') &&
|
|
199
|
+
previous === String(value)
|
|
200
|
+
)
|
|
201
|
+
) {
|
|
194
202
|
element.setAttribute(attribute, value);
|
|
195
203
|
}
|
|
196
204
|
}
|
|
@@ -241,7 +241,8 @@ export function proxy(value) {
|
|
|
241
241
|
|
|
242
242
|
if (
|
|
243
243
|
s !== undefined ||
|
|
244
|
-
(active_effect !== null
|
|
244
|
+
((active_effect !== null || active_reaction !== null) &&
|
|
245
|
+
(!has || get_descriptor(target, prop)?.writable))
|
|
245
246
|
) {
|
|
246
247
|
if (s === undefined) {
|
|
247
248
|
s = with_parent(() => {
|
|
@@ -98,15 +98,15 @@ export class Batch {
|
|
|
98
98
|
id = uid++;
|
|
99
99
|
|
|
100
100
|
/** True as soon as `#process` was called */
|
|
101
|
-
|
|
101
|
+
started = false;
|
|
102
102
|
|
|
103
103
|
linked = true;
|
|
104
104
|
|
|
105
105
|
/** @type {Batch | null} */
|
|
106
|
-
|
|
106
|
+
prev = null;
|
|
107
107
|
|
|
108
108
|
/** @type {Batch | null} */
|
|
109
|
-
|
|
109
|
+
next = null;
|
|
110
110
|
|
|
111
111
|
/** @type {Map<Effect, ReturnType<typeof deferred<any>>>} */
|
|
112
112
|
async_deriveds = new Map();
|
|
@@ -114,14 +114,14 @@ export class Batch {
|
|
|
114
114
|
/**
|
|
115
115
|
* The current values of any signals that are updated in this batch.
|
|
116
116
|
* Tuple format: [value, is_derived] (note: is_derived is false for deriveds, too, if they were overridden via assignment)
|
|
117
|
-
*
|
|
117
|
+
* The keys of this map are identical to `this.previous`
|
|
118
118
|
* @type {Map<Value, [any, boolean]>}
|
|
119
119
|
*/
|
|
120
120
|
current = new Map();
|
|
121
121
|
|
|
122
122
|
/**
|
|
123
123
|
* The values of any signals (sources and deriveds) that are updated in this batch _before_ those updates took place.
|
|
124
|
-
*
|
|
124
|
+
* The keys of this map are identical to `this.current`
|
|
125
125
|
* @type {Map<Value, any>}
|
|
126
126
|
*/
|
|
127
127
|
previous = new Map();
|
|
@@ -177,16 +177,10 @@ export class Batch {
|
|
|
177
177
|
#new_effects = [];
|
|
178
178
|
|
|
179
179
|
/**
|
|
180
|
-
* Deferred effects (which run after async work has completed)
|
|
181
|
-
* @type {
|
|
182
|
-
*/
|
|
183
|
-
#dirty_effects = new Set();
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Deferred effects that are MAYBE_DIRTY
|
|
187
|
-
* @type {Set<Effect>}
|
|
180
|
+
* Deferred effects (which run after async work has completed) and their status (DIRTY or MAYBE_DIRTY)
|
|
181
|
+
* @type {Map<Effect, number>}
|
|
188
182
|
*/
|
|
189
|
-
#
|
|
183
|
+
#dirty_reactions = new Map();
|
|
190
184
|
|
|
191
185
|
/**
|
|
192
186
|
* A map of branches that still exist, but will be destroyed when this batch
|
|
@@ -208,12 +202,11 @@ export class Batch {
|
|
|
208
202
|
#decrement_queued = false;
|
|
209
203
|
|
|
210
204
|
constructor() {
|
|
211
|
-
// link batch
|
|
212
205
|
if (last_batch === null) {
|
|
213
206
|
first_batch = last_batch = this;
|
|
214
207
|
} else {
|
|
215
|
-
last_batch
|
|
216
|
-
this
|
|
208
|
+
last_batch.next = this;
|
|
209
|
+
this.prev = last_batch;
|
|
217
210
|
}
|
|
218
211
|
|
|
219
212
|
last_batch = this;
|
|
@@ -223,19 +216,8 @@ export class Batch {
|
|
|
223
216
|
if (this.is_fork) return true;
|
|
224
217
|
|
|
225
218
|
for (const effect of this.#blocking_pending.keys()) {
|
|
226
|
-
|
|
227
|
-
|
|
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) {
|
|
219
|
+
// pending work inside a skipped branch doesn't block, the branch is going to be destroyed
|
|
220
|
+
if (!this.#is_skipped(effect)) {
|
|
239
221
|
return true;
|
|
240
222
|
}
|
|
241
223
|
}
|
|
@@ -243,6 +225,18 @@ export class Batch {
|
|
|
243
225
|
return false;
|
|
244
226
|
}
|
|
245
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Whether `effect` is inside a branch that this batch skips
|
|
230
|
+
* @param {Effect} effect
|
|
231
|
+
*/
|
|
232
|
+
#is_skipped(effect) {
|
|
233
|
+
for (var e = /** @type {Effect | null} */ (effect); e !== null; e = e.parent) {
|
|
234
|
+
if (this.#skipped_branches.has(e)) return true;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
|
|
246
240
|
/**
|
|
247
241
|
* Add an effect to the #skipped_branches map and reset its children
|
|
248
242
|
* @param {Effect} effect
|
|
@@ -327,7 +321,7 @@ export class Batch {
|
|
|
327
321
|
}
|
|
328
322
|
|
|
329
323
|
#process() {
|
|
330
|
-
this
|
|
324
|
+
this.started = true;
|
|
331
325
|
|
|
332
326
|
if (DEV) {
|
|
333
327
|
// track all the values that were updated during this flush,
|
|
@@ -341,14 +335,8 @@ export class Batch {
|
|
|
341
335
|
// #is_deferred() is true, because traversing the tree could make
|
|
342
336
|
// an if block that contains the last blocking pending effect falsy,
|
|
343
337
|
// causing the block to no longer be deferred.
|
|
344
|
-
for (const e of this.#
|
|
345
|
-
|
|
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);
|
|
338
|
+
for (const [e, status] of this.#dirty_reactions) {
|
|
339
|
+
set_signal_status(e, status);
|
|
352
340
|
this.schedule(e);
|
|
353
341
|
}
|
|
354
342
|
|
|
@@ -432,8 +420,7 @@ export class Batch {
|
|
|
432
420
|
}
|
|
433
421
|
|
|
434
422
|
// clear effects. Those that are still needed will be rescheduled through unskipping the skipped branches.
|
|
435
|
-
this.#
|
|
436
|
-
this.#maybe_dirty_effects.clear();
|
|
423
|
+
this.#dirty_reactions.clear();
|
|
437
424
|
|
|
438
425
|
// append/remove branches
|
|
439
426
|
for (const fn of this.#commit_callbacks) fn(this);
|
|
@@ -462,21 +449,6 @@ export class Batch {
|
|
|
462
449
|
}
|
|
463
450
|
}
|
|
464
451
|
|
|
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
452
|
if (next_batch !== null) {
|
|
481
453
|
old_values.clear();
|
|
482
454
|
next_batch.#process();
|
|
@@ -510,7 +482,7 @@ export class Batch {
|
|
|
510
482
|
} else if (async_mode_flag && (flags & (RENDER_EFFECT | MANAGED_EFFECT)) !== 0) {
|
|
511
483
|
render_effects.push(effect);
|
|
512
484
|
} else if (is_dirty(effect)) {
|
|
513
|
-
if ((flags & BLOCK_EFFECT) !== 0) this
|
|
485
|
+
if ((flags & BLOCK_EFFECT) !== 0) this.add_dirty_reaction(effect, MAYBE_DIRTY);
|
|
514
486
|
update_effect(effect);
|
|
515
487
|
}
|
|
516
488
|
|
|
@@ -536,24 +508,23 @@ export class Batch {
|
|
|
536
508
|
}
|
|
537
509
|
|
|
538
510
|
#find_earlier_batch() {
|
|
539
|
-
var batch = this
|
|
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;
|
|
511
|
+
for (var batch = this.prev; batch !== null; batch = batch.prev) {
|
|
512
|
+
if (!batch.is_fork && this.#intersects(batch)) return batch;
|
|
552
513
|
}
|
|
553
514
|
|
|
554
515
|
return null;
|
|
555
516
|
}
|
|
556
517
|
|
|
518
|
+
/** @param {Batch} batch */
|
|
519
|
+
#intersects(batch) {
|
|
520
|
+
for (const [source, [, is_derived]] of this.current) {
|
|
521
|
+
if (is_derived) continue;
|
|
522
|
+
if (batch.current.has(source)) return true;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
|
|
557
528
|
/**
|
|
558
529
|
* @param {Batch} batch
|
|
559
530
|
*/
|
|
@@ -576,7 +547,7 @@ export class Batch {
|
|
|
576
547
|
batch.async_deriveds.clear();
|
|
577
548
|
|
|
578
549
|
// Mark is not guaranteed not touch these, so we transfer them
|
|
579
|
-
this.
|
|
550
|
+
this.transfer_reactions(batch.#dirty_reactions);
|
|
580
551
|
|
|
581
552
|
/**
|
|
582
553
|
* mark all effects that depend on `batch.current`, except the
|
|
@@ -605,7 +576,7 @@ export class Batch {
|
|
|
605
576
|
var effect = /** @type {Effect} */ (reaction);
|
|
606
577
|
|
|
607
578
|
if (flags & (ASYNC | BLOCK_EFFECT) && !this.async_deriveds.has(effect)) {
|
|
608
|
-
this.#
|
|
579
|
+
this.#dirty_reactions.delete(effect);
|
|
609
580
|
set_signal_status(effect, DIRTY);
|
|
610
581
|
this.schedule(effect);
|
|
611
582
|
}
|
|
@@ -629,7 +600,7 @@ export class Batch {
|
|
|
629
600
|
*/
|
|
630
601
|
#defer_effects(effects) {
|
|
631
602
|
for (var i = 0; i < effects.length; i += 1) {
|
|
632
|
-
defer_effect(effects[i], this.#
|
|
603
|
+
defer_effect(effects[i], this.#dirty_reactions);
|
|
633
604
|
}
|
|
634
605
|
}
|
|
635
606
|
|
|
@@ -719,7 +690,7 @@ export class Batch {
|
|
|
719
690
|
// in other words, we re-run block/async effects with the newly
|
|
720
691
|
// committed state, unless the batch in question has a more
|
|
721
692
|
// recent value for a given source
|
|
722
|
-
for (let batch = first_batch; batch !== null; batch = batch
|
|
693
|
+
for (let batch = first_batch; batch !== null; batch = batch.next) {
|
|
723
694
|
var is_earlier = batch.id < this.id;
|
|
724
695
|
|
|
725
696
|
/** @type {Source[]} */
|
|
@@ -756,7 +727,7 @@ export class Batch {
|
|
|
756
727
|
);
|
|
757
728
|
|
|
758
729
|
// If not started yet or no sources to update (which is e.g. possible for the very first batch) then bail
|
|
759
|
-
if (!batch
|
|
730
|
+
if (!batch.started || current.length === 0) continue;
|
|
760
731
|
|
|
761
732
|
// Re-run async/block effects that depend on distinct values changed in both batches (ignoring deriveds)
|
|
762
733
|
var others = current.filter((source) => !this.current.has(source));
|
|
@@ -818,7 +789,7 @@ export class Batch {
|
|
|
818
789
|
set_signal_status(effect, DIRTY);
|
|
819
790
|
batch.schedule(effect);
|
|
820
791
|
} else {
|
|
821
|
-
batch
|
|
792
|
+
batch.add_dirty_reaction(effect, DIRTY);
|
|
822
793
|
}
|
|
823
794
|
}
|
|
824
795
|
}
|
|
@@ -882,20 +853,24 @@ export class Batch {
|
|
|
882
853
|
}
|
|
883
854
|
|
|
884
855
|
/**
|
|
885
|
-
* @param {
|
|
886
|
-
* @param {Set<Effect>} maybe_dirty_effects
|
|
856
|
+
* @param {Map<Effect, number>} dirty_reactions
|
|
887
857
|
*/
|
|
888
|
-
|
|
889
|
-
for (const
|
|
890
|
-
this
|
|
858
|
+
transfer_reactions(dirty_reactions) {
|
|
859
|
+
for (const [effect, status] of dirty_reactions) {
|
|
860
|
+
this.add_dirty_reaction(effect, status);
|
|
891
861
|
}
|
|
892
862
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
}
|
|
863
|
+
dirty_reactions.clear();
|
|
864
|
+
}
|
|
896
865
|
|
|
897
|
-
|
|
898
|
-
|
|
866
|
+
/**
|
|
867
|
+
* @param {Effect} effect
|
|
868
|
+
* @param {number} status
|
|
869
|
+
*/
|
|
870
|
+
add_dirty_reaction(effect, status) {
|
|
871
|
+
if (status === DIRTY || this.#dirty_reactions.get(effect) !== DIRTY) {
|
|
872
|
+
this.#dirty_reactions.set(effect, status);
|
|
873
|
+
}
|
|
899
874
|
}
|
|
900
875
|
|
|
901
876
|
/** @param {(batch: Batch) => void} fn */
|
|
@@ -918,7 +893,7 @@ export class Batch {
|
|
|
918
893
|
|
|
919
894
|
if (!is_processing && !is_flushing_sync) {
|
|
920
895
|
queue_micro_task(() => {
|
|
921
|
-
if (!batch
|
|
896
|
+
if (!batch.started) {
|
|
922
897
|
batch.flush();
|
|
923
898
|
}
|
|
924
899
|
});
|
|
@@ -929,7 +904,7 @@ export class Batch {
|
|
|
929
904
|
}
|
|
930
905
|
|
|
931
906
|
apply() {
|
|
932
|
-
if (!async_mode_flag || (!this.is_fork && this
|
|
907
|
+
if (!async_mode_flag || (!this.is_fork && this.prev === null && this.next === null)) {
|
|
933
908
|
batch_values = null;
|
|
934
909
|
return;
|
|
935
910
|
}
|
|
@@ -942,32 +917,15 @@ export class Batch {
|
|
|
942
917
|
}
|
|
943
918
|
|
|
944
919
|
// ...and undo changes belonging to other batches unless they intersect
|
|
945
|
-
for (let batch = first_batch; batch !== null; batch = batch
|
|
920
|
+
for (let batch = first_batch; batch !== null; batch = batch.next) {
|
|
946
921
|
if (batch === this || batch.is_fork) continue;
|
|
947
922
|
|
|
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
923
|
// Since the latter batch merges into the earlier (if it resolves before the earlier one),
|
|
966
924
|
// we treat the earlier values as "already applied". This way we don't need to rerun async
|
|
967
925
|
// effects of the earlier batch in case they are merged.
|
|
968
926
|
// As a result you can think of batch_values as having the latest values of all intersecting
|
|
969
927
|
// batches up until this batch.
|
|
970
|
-
if (!intersects) {
|
|
928
|
+
if (batch.id >= this.id || !batch.#intersects(this)) {
|
|
971
929
|
for (const [source, previous] of batch.previous) {
|
|
972
930
|
if (!batch_values.has(source)) {
|
|
973
931
|
batch_values.set(source, previous);
|
|
@@ -1003,19 +961,19 @@ export class Batch {
|
|
|
1003
961
|
// running it multiple times to not corrupt the linked list
|
|
1004
962
|
if (!this.linked) return;
|
|
1005
963
|
|
|
1006
|
-
var prev = this
|
|
1007
|
-
var next = this
|
|
964
|
+
var prev = this.prev;
|
|
965
|
+
var next = this.next;
|
|
1008
966
|
|
|
1009
967
|
if (prev === null) {
|
|
1010
968
|
first_batch = next;
|
|
1011
969
|
} else {
|
|
1012
|
-
prev
|
|
970
|
+
prev.next = next;
|
|
1013
971
|
}
|
|
1014
972
|
|
|
1015
973
|
if (next === null) {
|
|
1016
974
|
last_batch = prev;
|
|
1017
975
|
} else {
|
|
1018
|
-
next
|
|
976
|
+
next.prev = prev;
|
|
1019
977
|
}
|
|
1020
978
|
|
|
1021
979
|
this.linked = false;
|
|
@@ -1462,7 +1420,7 @@ export function fork(fn) {
|
|
|
1462
1420
|
},
|
|
1463
1421
|
discard: () => {
|
|
1464
1422
|
// cause any MAYBE_DIRTY deriveds to update
|
|
1465
|
-
// if they depend on things
|
|
1423
|
+
// if they depend on things that changed
|
|
1466
1424
|
// inside the discarded fork
|
|
1467
1425
|
for (var source of batch.current.keys()) {
|
|
1468
1426
|
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
|
|
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;
|
|
@@ -70,9 +70,9 @@ export function set_eager_effects_deferred() {
|
|
|
70
70
|
*/
|
|
71
71
|
// TODO rename this to `state` throughout the codebase
|
|
72
72
|
export function source(v, stack) {
|
|
73
|
-
/** @type {
|
|
73
|
+
/** @type {Source<V>} */
|
|
74
74
|
var signal = {
|
|
75
|
-
f: 0,
|
|
75
|
+
f: 0,
|
|
76
76
|
v,
|
|
77
77
|
reactions: null,
|
|
78
78
|
equals,
|
|
@@ -4,14 +4,13 @@ import { set_signal_status } from './status.js';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @param {Effect} effect
|
|
7
|
-
* @param {
|
|
8
|
-
* @param {Set<Effect>} maybe_dirty_effects
|
|
7
|
+
* @param {Map<Effect, number>} dirty_reactions
|
|
9
8
|
*/
|
|
10
|
-
export function defer_effect(effect,
|
|
9
|
+
export function defer_effect(effect, dirty_reactions) {
|
|
11
10
|
if ((effect.f & DIRTY) !== 0) {
|
|
12
|
-
|
|
13
|
-
} else if ((effect.f & MAYBE_DIRTY) !== 0) {
|
|
14
|
-
|
|
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/
|
|
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/
|
|
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`);
|
package/src/version.js
CHANGED
package/types/index.d.ts.map
CHANGED
|
@@ -273,6 +273,6 @@
|
|
|
273
273
|
null,
|
|
274
274
|
null
|
|
275
275
|
],
|
|
276
|
-
"mappings": ";;;;;;;;;kBAUiBA,2BAA2BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAmC/BC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAwEhBC,kBAAkBA;;;;;;;;;;;;;;;;;;;;;;;;kBAwBbC,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCbC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;aAwBrBC,eAAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAiCfC,cAAcA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6BdC,aAAaA;;;;;;;;;;;;;;;;;;;;;;;kBAuBRC,OAAOA;;;;;;;;;;;;;;;;kBAgBPC,eAAeA;;;;;;;;;;;;;;;;aAgBpBC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA+CPC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCzSLC,cAAcA;;;;;;;;;;;;iBAsBdC,OAAOA;;;;;;;;iBAwBPC,SAASA;;;;;;;;;;;;;;;;;;;;;;iBA0CTC,qBAAqBA;;;;;;;;;;iBA2CrBC,YAAYA;;;;;;;;;;iBAuBZC,WAAWA;iBClNXC,UAAUA;;;;iBC4DVC,gBAAgBA;;;;;MCvEpBC,WAAWA;;;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