svelte 5.55.1 → 5.55.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/elements.d.ts +3 -3
- package/package.json +1 -1
- package/src/compiler/phases/1-parse/acorn.js +58 -31
- package/src/compiler/phases/1-parse/index.js +0 -10
- package/src/compiler/phases/1-parse/read/context.js +28 -34
- package/src/compiler/phases/1-parse/read/expression.js +4 -38
- package/src/compiler/phases/1-parse/read/script.js +1 -8
- package/src/compiler/phases/1-parse/state/tag.js +1 -6
- package/src/compiler/phases/2-analyze/visitors/ConstTag.js +25 -0
- package/src/compiler/phases/2-analyze/visitors/Fragment.js +1 -1
- package/src/compiler/phases/2-analyze/visitors/shared/function.js +1 -1
- package/src/compiler/phases/3-transform/client/transform-client.js +1 -1
- package/src/compiler/phases/3-transform/client/visitors/ConstTag.js +18 -33
- package/src/compiler/phases/3-transform/server/visitors/ConstTag.js +13 -12
- package/src/internal/client/constants.js +2 -0
- package/src/internal/client/dev/hmr.js +6 -3
- package/src/internal/client/dom/blocks/boundary.js +21 -5
- package/src/internal/client/dom/blocks/branches.js +8 -0
- package/src/internal/client/dom/blocks/each.js +5 -0
- package/src/internal/client/reactivity/async.js +20 -1
- package/src/internal/client/reactivity/batch.js +60 -15
- package/src/internal/client/reactivity/deriveds.js +43 -37
- package/src/internal/client/reactivity/sources.js +2 -10
- package/src/internal/client/runtime.js +12 -4
- package/src/internal/client/warnings.js +11 -0
- package/src/internal/server/errors.js +12 -0
- package/src/internal/server/renderer.js +4 -0
- package/src/reactivity/date.js +4 -0
- package/src/version.js +1 -1
- package/types/index.d.ts.map +1 -1
|
@@ -35,7 +35,7 @@ import { queue_micro_task } from '../task.js';
|
|
|
35
35
|
import * as e from '../../errors.js';
|
|
36
36
|
import * as w from '../../warnings.js';
|
|
37
37
|
import { DEV } from 'esm-env';
|
|
38
|
-
import { Batch, current_batch, schedule_effect } from '../../reactivity/batch.js';
|
|
38
|
+
import { Batch, current_batch, previous_batch, schedule_effect } from '../../reactivity/batch.js';
|
|
39
39
|
import { internal_set, source } from '../../reactivity/sources.js';
|
|
40
40
|
import { tag } from '../../dev/tracing.js';
|
|
41
41
|
import { createSubscriber } from '../../../../reactivity/create-subscriber.js';
|
|
@@ -386,15 +386,29 @@ export class Boundary {
|
|
|
386
386
|
|
|
387
387
|
/** @param {unknown} error */
|
|
388
388
|
error(error) {
|
|
389
|
-
var onerror = this.#props.onerror;
|
|
390
|
-
let failed = this.#props.failed;
|
|
391
|
-
|
|
392
389
|
// If we have nothing to capture the error, or if we hit an error while
|
|
393
390
|
// rendering the fallback, re-throw for another boundary to handle
|
|
394
|
-
if (!onerror && !failed) {
|
|
391
|
+
if (!this.#props.onerror && !this.#props.failed) {
|
|
395
392
|
throw error;
|
|
396
393
|
}
|
|
397
394
|
|
|
395
|
+
if (current_batch?.is_fork) {
|
|
396
|
+
if (this.#main_effect) current_batch.skip_effect(this.#main_effect);
|
|
397
|
+
if (this.#pending_effect) current_batch.skip_effect(this.#pending_effect);
|
|
398
|
+
if (this.#failed_effect) current_batch.skip_effect(this.#failed_effect);
|
|
399
|
+
|
|
400
|
+
current_batch.on_fork_commit(() => {
|
|
401
|
+
this.#handle_error(error);
|
|
402
|
+
});
|
|
403
|
+
} else {
|
|
404
|
+
this.#handle_error(error);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/**
|
|
409
|
+
* @param {unknown} error
|
|
410
|
+
*/
|
|
411
|
+
#handle_error(error) {
|
|
398
412
|
if (this.#main_effect) {
|
|
399
413
|
destroy_effect(this.#main_effect);
|
|
400
414
|
this.#main_effect = null;
|
|
@@ -416,6 +430,8 @@ export class Boundary {
|
|
|
416
430
|
set_hydrate_node(skip_nodes());
|
|
417
431
|
}
|
|
418
432
|
|
|
433
|
+
var onerror = this.#props.onerror;
|
|
434
|
+
let failed = this.#props.failed;
|
|
419
435
|
var did_reset = false;
|
|
420
436
|
var calling_on_error = false;
|
|
421
437
|
|
|
@@ -7,8 +7,10 @@ import {
|
|
|
7
7
|
pause_effect,
|
|
8
8
|
resume_effect
|
|
9
9
|
} from '../../reactivity/effects.js';
|
|
10
|
+
import { HMR_ANCHOR } from '../../constants.js';
|
|
10
11
|
import { hydrate_node, hydrating } from '../hydration.js';
|
|
11
12
|
import { create_text, should_defer_append } from '../operations.js';
|
|
13
|
+
import { DEV } from 'esm-env';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* @typedef {{ effect: Effect, fragment: DocumentFragment }} Branch
|
|
@@ -91,6 +93,12 @@ export class BranchManager {
|
|
|
91
93
|
this.#onscreen.set(key, offscreen.effect);
|
|
92
94
|
this.#offscreen.delete(key);
|
|
93
95
|
|
|
96
|
+
if (DEV) {
|
|
97
|
+
// Tell hmr.js about the anchor it should use for updates,
|
|
98
|
+
// since the initial one will be removed
|
|
99
|
+
/** @type {any} */ (offscreen.fragment.lastChild)[HMR_ANCHOR] = this.anchor;
|
|
100
|
+
}
|
|
101
|
+
|
|
94
102
|
// remove the anchor...
|
|
95
103
|
/** @type {TemplateNode} */ (offscreen.fragment.lastChild).remove();
|
|
96
104
|
|
|
@@ -42,6 +42,7 @@ import { DEV } from 'esm-env';
|
|
|
42
42
|
import { derived_safe_equal } from '../../reactivity/deriveds.js';
|
|
43
43
|
import { current_batch } from '../../reactivity/batch.js';
|
|
44
44
|
import * as e from '../../errors.js';
|
|
45
|
+
import { tag } from '../../dev/tracing.js';
|
|
45
46
|
|
|
46
47
|
// When making substantive changes to this file, validate them with the each block stress test:
|
|
47
48
|
// https://svelte.dev/playground/1972b2cf46564476ad8c8c6405b23b7b
|
|
@@ -205,6 +206,10 @@ export function each(node, flags, get_collection, get_key, render_fn, fallback_f
|
|
|
205
206
|
return is_array(collection) ? collection : collection == null ? [] : array_from(collection);
|
|
206
207
|
});
|
|
207
208
|
|
|
209
|
+
if (DEV) {
|
|
210
|
+
tag(each_array, '{#each ...}');
|
|
211
|
+
}
|
|
212
|
+
|
|
208
213
|
/** @type {V[]} */
|
|
209
214
|
var array;
|
|
210
215
|
|
|
@@ -164,10 +164,26 @@ export async function save(promise) {
|
|
|
164
164
|
*/
|
|
165
165
|
export async function track_reactivity_loss(promise) {
|
|
166
166
|
var previous_async_effect = reactivity_loss_tracker;
|
|
167
|
+
// Ensure that unrelated reads after an async operation is kicked off don't cause false positives
|
|
168
|
+
queueMicrotask(() => {
|
|
169
|
+
if (reactivity_loss_tracker === previous_async_effect) {
|
|
170
|
+
set_reactivity_loss_tracker(null);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
167
174
|
var value = await promise;
|
|
168
175
|
|
|
169
176
|
return () => {
|
|
170
177
|
set_reactivity_loss_tracker(previous_async_effect);
|
|
178
|
+
// While this can result in false negatives it also guards against the more important
|
|
179
|
+
// false positives that would occur if this is the last in a chain of async operations,
|
|
180
|
+
// and the reactivity_loss_tracker would then stay around until the next async operation happens.
|
|
181
|
+
queueMicrotask(() => {
|
|
182
|
+
if (reactivity_loss_tracker === previous_async_effect) {
|
|
183
|
+
set_reactivity_loss_tracker(null);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
|
|
171
187
|
return value;
|
|
172
188
|
};
|
|
173
189
|
}
|
|
@@ -206,7 +222,9 @@ export async function* for_await_track_reactivity_loss(iterable) {
|
|
|
206
222
|
normal_completion = true;
|
|
207
223
|
break;
|
|
208
224
|
}
|
|
225
|
+
var prev = reactivity_loss_tracker;
|
|
209
226
|
yield value;
|
|
227
|
+
set_reactivity_loss_tracker(prev);
|
|
210
228
|
}
|
|
211
229
|
} finally {
|
|
212
230
|
// If the iterator had an abrupt completion and `return` is defined on the iterator, call it and return the value
|
|
@@ -265,6 +283,8 @@ export function run(thunks) {
|
|
|
265
283
|
for (const fn of thunks.slice(1)) {
|
|
266
284
|
promise = promise
|
|
267
285
|
.then(() => {
|
|
286
|
+
restore();
|
|
287
|
+
|
|
268
288
|
if (errored) {
|
|
269
289
|
throw errored.error;
|
|
270
290
|
}
|
|
@@ -273,7 +293,6 @@ export function run(thunks) {
|
|
|
273
293
|
throw STALE_REACTION;
|
|
274
294
|
}
|
|
275
295
|
|
|
276
|
-
restore();
|
|
277
296
|
return fn();
|
|
278
297
|
})
|
|
279
298
|
.catch(handle_error);
|
|
@@ -120,6 +120,12 @@ export class Batch {
|
|
|
120
120
|
*/
|
|
121
121
|
#discard_callbacks = new Set();
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Callbacks that should run only when a fork is committed.
|
|
125
|
+
* @type {Set<(batch: Batch) => void>}
|
|
126
|
+
*/
|
|
127
|
+
#fork_commit_callbacks = new Set();
|
|
128
|
+
|
|
123
129
|
/**
|
|
124
130
|
* Async effects that are currently in flight
|
|
125
131
|
* @type {Map<Effect, number>}
|
|
@@ -172,6 +178,12 @@ export class Batch {
|
|
|
172
178
|
*/
|
|
173
179
|
#skipped_branches = new Map();
|
|
174
180
|
|
|
181
|
+
/**
|
|
182
|
+
* Inverse of #skipped_branches which we need to tell prior batches to unskip them when committing
|
|
183
|
+
* @type {Set<Effect>}
|
|
184
|
+
*/
|
|
185
|
+
#unskipped_branches = new Set();
|
|
186
|
+
|
|
175
187
|
is_fork = false;
|
|
176
188
|
|
|
177
189
|
#decrement_queued = false;
|
|
@@ -215,28 +227,31 @@ export class Batch {
|
|
|
215
227
|
if (!this.#skipped_branches.has(effect)) {
|
|
216
228
|
this.#skipped_branches.set(effect, { d: [], m: [] });
|
|
217
229
|
}
|
|
230
|
+
this.#unskipped_branches.delete(effect);
|
|
218
231
|
}
|
|
219
232
|
|
|
220
233
|
/**
|
|
221
234
|
* Remove an effect from the #skipped_branches map and reschedule
|
|
222
235
|
* any tracked dirty/maybe_dirty child effects
|
|
223
236
|
* @param {Effect} effect
|
|
237
|
+
* @param {(e: Effect) => void} callback
|
|
224
238
|
*/
|
|
225
|
-
unskip_effect(effect) {
|
|
239
|
+
unskip_effect(effect, callback = (e) => this.schedule(e)) {
|
|
226
240
|
var tracked = this.#skipped_branches.get(effect);
|
|
227
241
|
if (tracked) {
|
|
228
242
|
this.#skipped_branches.delete(effect);
|
|
229
243
|
|
|
230
244
|
for (var e of tracked.d) {
|
|
231
245
|
set_signal_status(e, DIRTY);
|
|
232
|
-
|
|
246
|
+
callback(e);
|
|
233
247
|
}
|
|
234
248
|
|
|
235
249
|
for (e of tracked.m) {
|
|
236
250
|
set_signal_status(e, MAYBE_DIRTY);
|
|
237
|
-
|
|
251
|
+
callback(e);
|
|
238
252
|
}
|
|
239
253
|
}
|
|
254
|
+
this.#unskipped_branches.add(effect);
|
|
240
255
|
}
|
|
241
256
|
|
|
242
257
|
#process() {
|
|
@@ -349,7 +364,9 @@ export class Batch {
|
|
|
349
364
|
next_batch.#process();
|
|
350
365
|
}
|
|
351
366
|
|
|
352
|
-
|
|
367
|
+
// In sync mode flushSync can cause #commit to wrongfully think that there needs to be a rebase, so we only do it in async mode
|
|
368
|
+
// TODO fix the underlying cause, otherwise this will likely regress when non-async mode is removed
|
|
369
|
+
if (async_mode_flag && !batches.has(this)) {
|
|
353
370
|
this.#commit();
|
|
354
371
|
}
|
|
355
372
|
}
|
|
@@ -419,18 +436,22 @@ export class Batch {
|
|
|
419
436
|
* Associate a change to a given source with the current
|
|
420
437
|
* batch, noting its previous and current values
|
|
421
438
|
* @param {Value} source
|
|
422
|
-
* @param {any}
|
|
439
|
+
* @param {any} value
|
|
423
440
|
* @param {boolean} [is_derived]
|
|
424
441
|
*/
|
|
425
|
-
capture(source,
|
|
426
|
-
if (
|
|
427
|
-
this.previous.set(source,
|
|
442
|
+
capture(source, value, is_derived = false) {
|
|
443
|
+
if (source.v !== UNINITIALIZED && !this.previous.has(source)) {
|
|
444
|
+
this.previous.set(source, source.v);
|
|
428
445
|
}
|
|
429
446
|
|
|
430
447
|
// Don't save errors in `batch_values`, or they won't be thrown in `runtime.js#get`
|
|
431
448
|
if ((source.f & ERROR_VALUE) === 0) {
|
|
432
|
-
this.current.set(source, [
|
|
433
|
-
batch_values?.set(source,
|
|
449
|
+
this.current.set(source, [value, is_derived]);
|
|
450
|
+
batch_values?.set(source, value);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if (!this.is_fork) {
|
|
454
|
+
source.v = value;
|
|
434
455
|
}
|
|
435
456
|
}
|
|
436
457
|
|
|
@@ -474,6 +495,7 @@ export class Batch {
|
|
|
474
495
|
discard() {
|
|
475
496
|
for (const fn of this.#discard_callbacks) fn(this);
|
|
476
497
|
this.#discard_callbacks.clear();
|
|
498
|
+
this.#fork_commit_callbacks.clear();
|
|
477
499
|
|
|
478
500
|
batches.delete(this);
|
|
479
501
|
}
|
|
@@ -526,6 +548,19 @@ export class Batch {
|
|
|
526
548
|
invariant(batch.#roots.length === 0, 'Batch has scheduled roots');
|
|
527
549
|
}
|
|
528
550
|
|
|
551
|
+
// A batch was unskipped in a later batch -> tell prior batches to unskip it, too
|
|
552
|
+
if (is_earlier) {
|
|
553
|
+
for (const unskipped of this.#unskipped_branches) {
|
|
554
|
+
batch.unskip_effect(unskipped, (e) => {
|
|
555
|
+
if ((e.f & (BLOCK_EFFECT | ASYNC)) !== 0) {
|
|
556
|
+
batch.schedule(e);
|
|
557
|
+
} else {
|
|
558
|
+
batch.#defer_effects([e]);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
|
|
529
564
|
batch.activate();
|
|
530
565
|
|
|
531
566
|
/** @type {Set<Value>} */
|
|
@@ -658,6 +693,16 @@ export class Batch {
|
|
|
658
693
|
this.#discard_callbacks.add(fn);
|
|
659
694
|
}
|
|
660
695
|
|
|
696
|
+
/** @param {(batch: Batch) => void} fn */
|
|
697
|
+
on_fork_commit(fn) {
|
|
698
|
+
this.#fork_commit_callbacks.add(fn);
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
run_fork_commit_callbacks() {
|
|
702
|
+
for (const fn of this.#fork_commit_callbacks) fn(this);
|
|
703
|
+
this.#fork_commit_callbacks.clear();
|
|
704
|
+
}
|
|
705
|
+
|
|
661
706
|
settled() {
|
|
662
707
|
return (this.#deferred ??= deferred()).promise;
|
|
663
708
|
}
|
|
@@ -787,6 +832,7 @@ export class Batch {
|
|
|
787
832
|
}
|
|
788
833
|
}
|
|
789
834
|
|
|
835
|
+
// TODO Svelte@6 think about removing the callback argument.
|
|
790
836
|
/**
|
|
791
837
|
* Synchronously flush any pending updates.
|
|
792
838
|
* Returns void if no callback is provided, otherwise returns the result of calling the callback.
|
|
@@ -1162,11 +1208,6 @@ export function fork(fn) {
|
|
|
1162
1208
|
|
|
1163
1209
|
flushSync(fn);
|
|
1164
1210
|
|
|
1165
|
-
// revert state changes
|
|
1166
|
-
for (var [source, value] of batch.previous) {
|
|
1167
|
-
source.v = value;
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
1211
|
return {
|
|
1171
1212
|
commit: async () => {
|
|
1172
1213
|
if (committed) {
|
|
@@ -1188,6 +1229,10 @@ export function fork(fn) {
|
|
|
1188
1229
|
source.wv = increment_write_version();
|
|
1189
1230
|
}
|
|
1190
1231
|
|
|
1232
|
+
batch.activate();
|
|
1233
|
+
batch.run_fork_commit_callbacks();
|
|
1234
|
+
batch.deactivate();
|
|
1235
|
+
|
|
1191
1236
|
// trigger any `$state.eager(...)` expressions with the new state.
|
|
1192
1237
|
// eager effects don't get scheduled like other effects, so we
|
|
1193
1238
|
// can't just encounter them during traversal, we need to
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @import { Derived, Effect, Source } from '#client' */
|
|
1
|
+
/** @import { Derived, Effect, Reaction, Source, Value } from '#client' */
|
|
2
2
|
/** @import { Batch } from './batch.js'; */
|
|
3
3
|
/** @import { Boundary } from '../dom/blocks/boundary.js'; */
|
|
4
4
|
import { DEV } from 'esm-env';
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
WAS_MARKED,
|
|
13
13
|
DESTROYED,
|
|
14
14
|
CLEAN,
|
|
15
|
-
REACTION_RAN
|
|
15
|
+
REACTION_RAN,
|
|
16
|
+
INERT
|
|
16
17
|
} from '#client/constants';
|
|
17
18
|
import {
|
|
18
19
|
active_reaction,
|
|
@@ -23,7 +24,9 @@ import {
|
|
|
23
24
|
push_reaction_value,
|
|
24
25
|
is_destroying_effect,
|
|
25
26
|
update_effect,
|
|
26
|
-
remove_reactions
|
|
27
|
+
remove_reactions,
|
|
28
|
+
skipped_deps,
|
|
29
|
+
new_deps
|
|
27
30
|
} from '../runtime.js';
|
|
28
31
|
import { equals, safe_equals } from './equality.js';
|
|
29
32
|
import * as e from '../errors.js';
|
|
@@ -48,11 +51,11 @@ import { set_signal_status, update_derived_status } from './status.js';
|
|
|
48
51
|
/**
|
|
49
52
|
* This allows us to track 'reactivity loss' that occurs when signals
|
|
50
53
|
* are read after a non-context-restoring `await`. Dev-only
|
|
51
|
-
* @type {{ effect: Effect, warned: boolean } | null}
|
|
54
|
+
* @type {{ effect: Effect, effect_deps: Set<Value>, warned: boolean } | null}
|
|
52
55
|
*/
|
|
53
56
|
export let reactivity_loss_tracker = null;
|
|
54
57
|
|
|
55
|
-
/** @param {{ effect: Effect, warned: boolean } | null} v */
|
|
58
|
+
/** @param {{ effect: Effect, effect_deps: Set<Value>, warned: boolean } | null} v */
|
|
56
59
|
export function set_reactivity_loss_tracker(v) {
|
|
57
60
|
reactivity_loss_tracker = v;
|
|
58
61
|
}
|
|
@@ -67,10 +70,6 @@ export const recent_async_deriveds = new Set();
|
|
|
67
70
|
/*#__NO_SIDE_EFFECTS__*/
|
|
68
71
|
export function derived(fn) {
|
|
69
72
|
var flags = DERIVED | DIRTY;
|
|
70
|
-
var parent_derived =
|
|
71
|
-
active_reaction !== null && (active_reaction.f & DERIVED) !== 0
|
|
72
|
-
? /** @type {Derived} */ (active_reaction)
|
|
73
|
-
: null;
|
|
74
73
|
|
|
75
74
|
if (active_effect !== null) {
|
|
76
75
|
// Since deriveds are evaluated lazily, any effects created inside them are
|
|
@@ -90,7 +89,7 @@ export function derived(fn) {
|
|
|
90
89
|
rv: 0,
|
|
91
90
|
v: /** @type {V} */ (UNINITIALIZED),
|
|
92
91
|
wv: 0,
|
|
93
|
-
parent:
|
|
92
|
+
parent: active_effect,
|
|
94
93
|
ac: null
|
|
95
94
|
};
|
|
96
95
|
|
|
@@ -128,15 +127,12 @@ export function async_derived(fn, label, location) {
|
|
|
128
127
|
var deferreds = new Map();
|
|
129
128
|
|
|
130
129
|
async_effect(() => {
|
|
130
|
+
var effect = /** @type {Effect} */ (active_effect);
|
|
131
|
+
|
|
131
132
|
if (DEV) {
|
|
132
|
-
reactivity_loss_tracker = {
|
|
133
|
-
effect: /** @type {Effect} */ (active_effect),
|
|
134
|
-
warned: false
|
|
135
|
-
};
|
|
133
|
+
reactivity_loss_tracker = { effect, effect_deps: new Set(), warned: false };
|
|
136
134
|
}
|
|
137
135
|
|
|
138
|
-
var effect = /** @type {Effect} */ (active_effect);
|
|
139
|
-
|
|
140
136
|
/** @type {ReturnType<typeof deferred<V>>} */
|
|
141
137
|
var d = deferred();
|
|
142
138
|
promise = d.promise;
|
|
@@ -152,6 +148,24 @@ export function async_derived(fn, label, location) {
|
|
|
152
148
|
}
|
|
153
149
|
|
|
154
150
|
if (DEV) {
|
|
151
|
+
if (reactivity_loss_tracker) {
|
|
152
|
+
// Reused deps from previous run (indices 0 to skipped_deps-1)
|
|
153
|
+
// We deliberately only track direct dependencies of the async expression to encourage
|
|
154
|
+
// dependencies being directly visible at the point of the expression
|
|
155
|
+
if (effect.deps !== null) {
|
|
156
|
+
for (let i = 0; i < skipped_deps; i += 1) {
|
|
157
|
+
reactivity_loss_tracker.effect_deps.add(effect.deps[i]);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// New deps discovered this run
|
|
162
|
+
if (new_deps !== null) {
|
|
163
|
+
for (let i = 0; i < new_deps.length; i += 1) {
|
|
164
|
+
reactivity_loss_tracker.effect_deps.add(new_deps[i]);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
155
169
|
reactivity_loss_tracker = null;
|
|
156
170
|
}
|
|
157
171
|
|
|
@@ -320,23 +334,6 @@ export function destroy_derived_effects(derived) {
|
|
|
320
334
|
*/
|
|
321
335
|
let stack = [];
|
|
322
336
|
|
|
323
|
-
/**
|
|
324
|
-
* @param {Derived} derived
|
|
325
|
-
* @returns {Effect | null}
|
|
326
|
-
*/
|
|
327
|
-
function get_derived_parent_effect(derived) {
|
|
328
|
-
var parent = derived.parent;
|
|
329
|
-
while (parent !== null) {
|
|
330
|
-
if ((parent.f & DERIVED) === 0) {
|
|
331
|
-
// The original parent effect might've been destroyed but the derived
|
|
332
|
-
// is used elsewhere now - do not return the destroyed effect in that case
|
|
333
|
-
return (parent.f & DESTROYED) === 0 ? /** @type {Effect} */ (parent) : null;
|
|
334
|
-
}
|
|
335
|
-
parent = parent.parent;
|
|
336
|
-
}
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
337
|
/**
|
|
341
338
|
* @template T
|
|
342
339
|
* @param {Derived} derived
|
|
@@ -345,8 +342,15 @@ function get_derived_parent_effect(derived) {
|
|
|
345
342
|
export function execute_derived(derived) {
|
|
346
343
|
var value;
|
|
347
344
|
var prev_active_effect = active_effect;
|
|
345
|
+
var parent = derived.parent;
|
|
348
346
|
|
|
349
|
-
|
|
347
|
+
if (!is_destroying_effect && parent !== null && (parent.f & (DESTROYED | INERT)) !== 0) {
|
|
348
|
+
w.derived_inert();
|
|
349
|
+
|
|
350
|
+
return derived.v;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
set_active_effect(parent);
|
|
350
354
|
|
|
351
355
|
if (DEV) {
|
|
352
356
|
let prev_eager_effects = eager_effects;
|
|
@@ -384,7 +388,6 @@ export function execute_derived(derived) {
|
|
|
384
388
|
* @returns {void}
|
|
385
389
|
*/
|
|
386
390
|
export function update_derived(derived) {
|
|
387
|
-
var old_value = derived.v;
|
|
388
391
|
var value = execute_derived(derived);
|
|
389
392
|
|
|
390
393
|
if (!derived.equals(value)) {
|
|
@@ -395,8 +398,11 @@ export function update_derived(derived) {
|
|
|
395
398
|
// otherwise, the next time we get here after a 'real world' state
|
|
396
399
|
// change, `derived.equals` may incorrectly return `true`
|
|
397
400
|
if (!current_batch?.is_fork || derived.deps === null) {
|
|
398
|
-
|
|
399
|
-
|
|
401
|
+
if (current_batch !== null) {
|
|
402
|
+
current_batch.capture(derived, value, true);
|
|
403
|
+
} else {
|
|
404
|
+
derived.v = value;
|
|
405
|
+
}
|
|
400
406
|
|
|
401
407
|
// deriveds without dependencies should never be recomputed
|
|
402
408
|
if (derived.deps === null) {
|
|
@@ -180,18 +180,10 @@ export function set(source, value, should_proxy = false) {
|
|
|
180
180
|
*/
|
|
181
181
|
export function internal_set(source, value, updated_during_traversal = null) {
|
|
182
182
|
if (!source.equals(value)) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (is_destroying_effect) {
|
|
186
|
-
old_values.set(source, value);
|
|
187
|
-
} else {
|
|
188
|
-
old_values.set(source, old_value);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
source.v = value;
|
|
183
|
+
old_values.set(source, is_destroying_effect ? value : source.v);
|
|
192
184
|
|
|
193
185
|
var batch = Batch.ensure();
|
|
194
|
-
batch.capture(source,
|
|
186
|
+
batch.capture(source, value);
|
|
195
187
|
|
|
196
188
|
if (DEV) {
|
|
197
189
|
if (tracing_mode_flag || active_effect !== null) {
|
|
@@ -111,9 +111,9 @@ export function push_reaction_value(value) {
|
|
|
111
111
|
* and until a new dependency is accessed — we track this via `skipped_deps`
|
|
112
112
|
* @type {null | Value[]}
|
|
113
113
|
*/
|
|
114
|
-
let new_deps = null;
|
|
114
|
+
export let new_deps = null;
|
|
115
115
|
|
|
116
|
-
let skipped_deps = 0;
|
|
116
|
+
export let skipped_deps = 0;
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* Tracks writes that the effect it's executed in doesn't listen to yet,
|
|
@@ -399,7 +399,14 @@ function remove_reaction(signal, dependency) {
|
|
|
399
399
|
derived.f &= ~WAS_MARKED;
|
|
400
400
|
}
|
|
401
401
|
|
|
402
|
-
|
|
402
|
+
// In a fork it's possible that a derived is executed and gets reactions, then commits, but is
|
|
403
|
+
// never re-executed. This is possible when the derived is only executed once in the context
|
|
404
|
+
// of a new branch which happens before fork.commit() runs. In this case, the derived still has
|
|
405
|
+
// UNINITIALIZED as its value, and then when it's loosing its reactions we need to ensure it stays
|
|
406
|
+
// DIRTY so it is reexecuted once someone wants its value again.
|
|
407
|
+
if (derived.v !== UNINITIALIZED) {
|
|
408
|
+
update_derived_status(derived);
|
|
409
|
+
}
|
|
403
410
|
|
|
404
411
|
// freeze any effects inside this derived
|
|
405
412
|
freeze_derived_effects(derived);
|
|
@@ -573,7 +580,8 @@ export function get(signal) {
|
|
|
573
580
|
!untracking &&
|
|
574
581
|
reactivity_loss_tracker &&
|
|
575
582
|
!reactivity_loss_tracker.warned &&
|
|
576
|
-
(reactivity_loss_tracker.effect.f & REACTION_IS_UPDATING) === 0
|
|
583
|
+
(reactivity_loss_tracker.effect.f & REACTION_IS_UPDATING) === 0 &&
|
|
584
|
+
!reactivity_loss_tracker.effect_deps.has(signal)
|
|
577
585
|
) {
|
|
578
586
|
reactivity_loss_tracker.warned = true;
|
|
579
587
|
|
|
@@ -74,6 +74,17 @@ export function console_log_state(method) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Reading a derived belonging to a now-destroyed effect may result in stale values
|
|
79
|
+
*/
|
|
80
|
+
export function derived_inert() {
|
|
81
|
+
if (DEV) {
|
|
82
|
+
console.warn(`%c[svelte] derived_inert\n%cReading a derived belonging to a now-destroyed effect may result in stale values\nhttps://svelte.dev/e/derived_inert`, bold, normal);
|
|
83
|
+
} else {
|
|
84
|
+
console.warn(`https://svelte.dev/e/derived_inert`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
77
88
|
/**
|
|
78
89
|
* %handler% should be a function. Did you mean to %suggestion%?
|
|
79
90
|
* @param {string} handler
|
|
@@ -105,6 +105,18 @@ export function invalid_csp() {
|
|
|
105
105
|
throw error;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
+
/**
|
|
109
|
+
* The `idPrefix` option cannot include `--`.
|
|
110
|
+
* @returns {never}
|
|
111
|
+
*/
|
|
112
|
+
export function invalid_id_prefix() {
|
|
113
|
+
const error = new Error(`invalid_id_prefix\nThe \`idPrefix\` option cannot include \`--\`.\nhttps://svelte.dev/e/invalid_id_prefix`);
|
|
114
|
+
|
|
115
|
+
error.name = 'Svelte error';
|
|
116
|
+
|
|
117
|
+
throw error;
|
|
118
|
+
}
|
|
119
|
+
|
|
108
120
|
/**
|
|
109
121
|
* `%name%(...)` is not available on the server
|
|
110
122
|
* @param {string} name
|
package/src/reactivity/date.js
CHANGED
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;;;;;;;;;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