svelte 5.43.14 → 5.44.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.
- package/compiler/index.js +1 -1
- package/package.json +2 -1
- package/src/index-client.js +1 -0
- package/src/index-server.js +2 -0
- package/src/internal/client/constants.js +9 -0
- package/src/internal/client/dev/inspect.js +2 -2
- package/src/internal/client/dev/tracing.js +0 -57
- package/src/internal/client/dom/elements/attachments.js +2 -2
- package/src/internal/client/dom/elements/attributes.js +2 -2
- package/src/internal/client/errors.js +17 -16
- package/src/internal/client/hydratable.js +33 -0
- package/src/internal/client/proxy.js +3 -2
- package/src/internal/client/reactivity/batch.js +8 -9
- package/src/internal/client/reactivity/deriveds.js +3 -3
- package/src/internal/client/reactivity/effects.js +14 -1
- package/src/internal/client/reactivity/sources.js +6 -7
- package/src/internal/client/runtime.js +18 -7
- package/src/internal/client/warnings.js +12 -0
- package/src/internal/server/dev.js +10 -0
- package/src/internal/server/errors.js +66 -0
- package/src/internal/server/hydratable.js +136 -0
- package/src/internal/server/render-context.js +74 -0
- package/src/internal/server/renderer.js +76 -10
- package/src/internal/server/warnings.js +24 -1
- package/src/internal/shared/dev.js +65 -0
- package/src/internal/shared/errors.js +17 -0
- package/src/internal/shared/utils.js +1 -1
- package/src/version.js +1 -1
- package/types/index.d.ts +1 -0
- package/types/index.d.ts.map +4 -1
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "svelte",
|
|
3
3
|
"description": "Cybernetically enhanced web apps",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "5.
|
|
5
|
+
"version": "5.44.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"types": "./types/index.d.ts",
|
|
8
8
|
"engines": {
|
|
@@ -163,6 +163,7 @@
|
|
|
163
163
|
"aria-query": "^5.3.1",
|
|
164
164
|
"axobject-query": "^4.1.0",
|
|
165
165
|
"clsx": "^2.1.1",
|
|
166
|
+
"devalue": "^5.5.0",
|
|
166
167
|
"esm-env": "^1.2.1",
|
|
167
168
|
"esrap": "^2.1.0",
|
|
168
169
|
"is-reference": "^3.0.3",
|
package/src/index-client.js
CHANGED
|
@@ -249,6 +249,7 @@ export {
|
|
|
249
249
|
hasContext,
|
|
250
250
|
setContext
|
|
251
251
|
} from './internal/client/context.js';
|
|
252
|
+
export { hydratable } from './internal/client/hydratable.js';
|
|
252
253
|
export { hydrate, mount, unmount } from './internal/client/render.js';
|
|
253
254
|
export { tick, untrack, settled } from './internal/client/runtime.js';
|
|
254
255
|
export { createRawSnippet } from './internal/client/dom/blocks/snippet.js';
|
package/src/index-server.js
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
export const DERIVED = 1 << 1;
|
|
3
3
|
export const EFFECT = 1 << 2;
|
|
4
4
|
export const RENDER_EFFECT = 1 << 3;
|
|
5
|
+
/**
|
|
6
|
+
* An effect that does not destroy its child effects when it reruns.
|
|
7
|
+
* Runs as part of render effects, i.e. not eagerly as part of tree traversal or effect flushing.
|
|
8
|
+
*/
|
|
9
|
+
export const MANAGED_EFFECT = 1 << 24;
|
|
10
|
+
/**
|
|
11
|
+
* An effect that does not destroy its child effects when it reruns (like MANAGED_EFFECT).
|
|
12
|
+
* Runs eagerly as part of tree traversal or effect flushing.
|
|
13
|
+
*/
|
|
5
14
|
export const BLOCK_EFFECT = 1 << 4;
|
|
6
15
|
export const BRANCH_EFFECT = 1 << 5;
|
|
7
16
|
export const ROOT_EFFECT = 1 << 6;
|
|
@@ -2,7 +2,7 @@ import { UNINITIALIZED } from '../../../constants.js';
|
|
|
2
2
|
import { snapshot } from '../../shared/clone.js';
|
|
3
3
|
import { eager_effect, render_effect, validate_effect } from '../reactivity/effects.js';
|
|
4
4
|
import { untrack } from '../runtime.js';
|
|
5
|
-
import {
|
|
5
|
+
import { get_error } from '../../shared/dev.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @param {() => any[]} get_value
|
|
@@ -33,7 +33,7 @@ export function inspect(get_value, inspector, show_stack = false) {
|
|
|
33
33
|
inspector(...snap);
|
|
34
34
|
|
|
35
35
|
if (!initial) {
|
|
36
|
-
const stack =
|
|
36
|
+
const stack = get_error('$inspect(...)');
|
|
37
37
|
// eslint-disable-next-line no-console
|
|
38
38
|
|
|
39
39
|
if (stack) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/** @import { Derived, Reaction, Value } from '#client' */
|
|
2
2
|
import { UNINITIALIZED } from '../../../constants.js';
|
|
3
3
|
import { snapshot } from '../../shared/clone.js';
|
|
4
|
-
import { define_property } from '../../shared/utils.js';
|
|
5
4
|
import { DERIVED, ASYNC, PROXY_PATH_SYMBOL, STATE_SYMBOL } from '#client/constants';
|
|
6
5
|
import { effect_tracking } from '../reactivity/effects.js';
|
|
7
6
|
import { active_reaction, untrack } from '../runtime.js';
|
|
@@ -131,62 +130,6 @@ export function trace(label, fn) {
|
|
|
131
130
|
}
|
|
132
131
|
}
|
|
133
132
|
|
|
134
|
-
/**
|
|
135
|
-
* @param {string} label
|
|
136
|
-
* @returns {Error & { stack: string } | null}
|
|
137
|
-
*/
|
|
138
|
-
export function get_stack(label) {
|
|
139
|
-
// @ts-ignore stackTraceLimit doesn't exist everywhere
|
|
140
|
-
const limit = Error.stackTraceLimit;
|
|
141
|
-
|
|
142
|
-
// @ts-ignore
|
|
143
|
-
Error.stackTraceLimit = Infinity;
|
|
144
|
-
let error = Error();
|
|
145
|
-
|
|
146
|
-
// @ts-ignore
|
|
147
|
-
Error.stackTraceLimit = limit;
|
|
148
|
-
|
|
149
|
-
const stack = error.stack;
|
|
150
|
-
|
|
151
|
-
if (!stack) return null;
|
|
152
|
-
|
|
153
|
-
const lines = stack.split('\n');
|
|
154
|
-
const new_lines = ['\n'];
|
|
155
|
-
|
|
156
|
-
for (let i = 0; i < lines.length; i++) {
|
|
157
|
-
const line = lines[i];
|
|
158
|
-
const posixified = line.replaceAll('\\', '/');
|
|
159
|
-
|
|
160
|
-
if (line === 'Error') {
|
|
161
|
-
continue;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (line.includes('validate_each_keys')) {
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
if (posixified.includes('svelte/src/internal') || posixified.includes('node_modules/.vite')) {
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
new_lines.push(line);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
if (new_lines.length === 1) {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
define_property(error, 'stack', {
|
|
180
|
-
value: new_lines.join('\n')
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
define_property(error, 'name', {
|
|
184
|
-
value: label
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
return /** @type {Error & { stack: string }} */ (error);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
133
|
/**
|
|
191
134
|
* @param {Value} source
|
|
192
135
|
* @param {string} label
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @import { Effect } from '#client' */
|
|
2
|
-
import {
|
|
2
|
+
import { branch, effect, destroy_effect, managed } from '../../reactivity/effects.js';
|
|
3
3
|
|
|
4
4
|
// TODO in 6.0 or 7.0, when we remove legacy mode, we can simplify this by
|
|
5
5
|
// getting rid of the block/branch stuff and just letting the effect rip.
|
|
@@ -16,7 +16,7 @@ export function attach(node, get_fn) {
|
|
|
16
16
|
/** @type {Effect | null} */
|
|
17
17
|
var e;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
managed(() => {
|
|
20
20
|
if (fn !== (fn = get_fn())) {
|
|
21
21
|
if (e) {
|
|
22
22
|
destroy_effect(e);
|
|
@@ -20,7 +20,7 @@ import { clsx } from '../../../shared/attributes.js';
|
|
|
20
20
|
import { set_class } from './class.js';
|
|
21
21
|
import { set_style } from './style.js';
|
|
22
22
|
import { ATTACHMENT_KEY, NAMESPACE_HTML, UNINITIALIZED } from '../../../../constants.js';
|
|
23
|
-
import {
|
|
23
|
+
import { branch, destroy_effect, effect, managed } from '../../reactivity/effects.js';
|
|
24
24
|
import { init_select, select_option } from './bindings/select.js';
|
|
25
25
|
import { flatten } from '../../reactivity/async.js';
|
|
26
26
|
|
|
@@ -508,7 +508,7 @@ export function attribute_effect(
|
|
|
508
508
|
var is_select = element.nodeName === 'SELECT';
|
|
509
509
|
var inited = false;
|
|
510
510
|
|
|
511
|
-
|
|
511
|
+
managed(() => {
|
|
512
512
|
var next = fn(...values.map(get));
|
|
513
513
|
/** @type {Record<string | symbol, any>} */
|
|
514
514
|
var current = set_attributes(
|
|
@@ -229,22 +229,6 @@ export function effect_update_depth_exceeded() {
|
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
/**
|
|
233
|
-
* Cannot use `fork(...)` unless the `experimental.async` compiler option is `true`
|
|
234
|
-
* @returns {never}
|
|
235
|
-
*/
|
|
236
|
-
export function experimental_async_fork() {
|
|
237
|
-
if (DEV) {
|
|
238
|
-
const error = new Error(`experimental_async_fork\nCannot use \`fork(...)\` unless the \`experimental.async\` compiler option is \`true\`\nhttps://svelte.dev/e/experimental_async_fork`);
|
|
239
|
-
|
|
240
|
-
error.name = 'Svelte error';
|
|
241
|
-
|
|
242
|
-
throw error;
|
|
243
|
-
} else {
|
|
244
|
-
throw new Error(`https://svelte.dev/e/experimental_async_fork`);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
232
|
/**
|
|
249
233
|
* Cannot use `flushSync` inside an effect
|
|
250
234
|
* @returns {never}
|
|
@@ -309,6 +293,23 @@ export function get_abort_signal_outside_reaction() {
|
|
|
309
293
|
}
|
|
310
294
|
}
|
|
311
295
|
|
|
296
|
+
/**
|
|
297
|
+
* Expected to find a hydratable with key `%key%` during hydration, but did not.
|
|
298
|
+
* @param {string} key
|
|
299
|
+
* @returns {never}
|
|
300
|
+
*/
|
|
301
|
+
export function hydratable_missing_but_required(key) {
|
|
302
|
+
if (DEV) {
|
|
303
|
+
const error = new Error(`hydratable_missing_but_required\nExpected to find a hydratable with key \`${key}\` during hydration, but did not.\nhttps://svelte.dev/e/hydratable_missing_but_required`);
|
|
304
|
+
|
|
305
|
+
error.name = 'Svelte error';
|
|
306
|
+
|
|
307
|
+
throw error;
|
|
308
|
+
} else {
|
|
309
|
+
throw new Error(`https://svelte.dev/e/hydratable_missing_but_required`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
312
313
|
/**
|
|
313
314
|
* Failed to hydrate the application
|
|
314
315
|
* @returns {never}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { async_mode_flag } from '../flags/index.js';
|
|
2
|
+
import { hydrating } from './dom/hydration.js';
|
|
3
|
+
import * as w from './warnings.js';
|
|
4
|
+
import * as e from './errors.js';
|
|
5
|
+
import { DEV } from 'esm-env';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @template T
|
|
9
|
+
* @param {string} key
|
|
10
|
+
* @param {() => T} fn
|
|
11
|
+
* @returns {T}
|
|
12
|
+
*/
|
|
13
|
+
export function hydratable(key, fn) {
|
|
14
|
+
if (!async_mode_flag) {
|
|
15
|
+
e.experimental_async_required('hydratable');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (hydrating) {
|
|
19
|
+
const store = window.__svelte?.h;
|
|
20
|
+
|
|
21
|
+
if (store?.has(key)) {
|
|
22
|
+
return /** @type {T} */ (store.get(key));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (DEV) {
|
|
26
|
+
e.hydratable_missing_but_required(key);
|
|
27
|
+
} else {
|
|
28
|
+
w.hydratable_missing_but_expected(key);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return fn();
|
|
33
|
+
}
|
|
@@ -25,7 +25,8 @@ import {
|
|
|
25
25
|
import { PROXY_PATH_SYMBOL, STATE_SYMBOL } from '#client/constants';
|
|
26
26
|
import { UNINITIALIZED } from '../../constants.js';
|
|
27
27
|
import * as e from './errors.js';
|
|
28
|
-
import {
|
|
28
|
+
import { tag } from './dev/tracing.js';
|
|
29
|
+
import { get_error } from '../shared/dev.js';
|
|
29
30
|
import { tracing_mode_flag } from '../flags/index.js';
|
|
30
31
|
|
|
31
32
|
// TODO move all regexes into shared module?
|
|
@@ -53,7 +54,7 @@ export function proxy(value) {
|
|
|
53
54
|
var is_proxied_array = is_array(value);
|
|
54
55
|
var version = source(0);
|
|
55
56
|
|
|
56
|
-
var stack = DEV && tracing_mode_flag ?
|
|
57
|
+
var stack = DEV && tracing_mode_flag ? get_error('created at') : null;
|
|
57
58
|
var parent_version = update_version;
|
|
58
59
|
|
|
59
60
|
/**
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
EAGER_EFFECT,
|
|
18
18
|
HEAD_EFFECT,
|
|
19
19
|
ERROR_VALUE,
|
|
20
|
-
WAS_MARKED
|
|
20
|
+
WAS_MARKED,
|
|
21
|
+
MANAGED_EFFECT
|
|
21
22
|
} from '#client/constants';
|
|
22
23
|
import { async_mode_flag } from '../../flags/index.js';
|
|
23
24
|
import { deferred, define_property } from '../../shared/utils.js';
|
|
@@ -234,7 +235,7 @@ export class Batch {
|
|
|
234
235
|
effect.f ^= CLEAN;
|
|
235
236
|
} else if ((flags & EFFECT) !== 0) {
|
|
236
237
|
target.effects.push(effect);
|
|
237
|
-
} else if (async_mode_flag && (flags & RENDER_EFFECT) !== 0) {
|
|
238
|
+
} else if (async_mode_flag && (flags & (RENDER_EFFECT | MANAGED_EFFECT)) !== 0) {
|
|
238
239
|
target.render_effects.push(effect);
|
|
239
240
|
} else if (is_dirty(effect)) {
|
|
240
241
|
if ((effect.f & BLOCK_EFFECT) !== 0) target.block_effects.push(effect);
|
|
@@ -562,11 +563,6 @@ export class Batch {
|
|
|
562
563
|
* @returns {T}
|
|
563
564
|
*/
|
|
564
565
|
export function flushSync(fn) {
|
|
565
|
-
if (async_mode_flag && active_effect !== null) {
|
|
566
|
-
// We disallow this because it creates super-hard to reason about stack trace and because it's generally a bad idea
|
|
567
|
-
e.flush_sync_in_effect();
|
|
568
|
-
}
|
|
569
|
-
|
|
570
566
|
var was_flushing_sync = is_flushing_sync;
|
|
571
567
|
is_flushing_sync = true;
|
|
572
568
|
|
|
@@ -779,7 +775,7 @@ function mark_effects(value, sources, marked, checked) {
|
|
|
779
775
|
mark_effects(/** @type {Derived} */ (reaction), sources, marked, checked);
|
|
780
776
|
} else if (
|
|
781
777
|
(flags & (ASYNC | BLOCK_EFFECT)) !== 0 &&
|
|
782
|
-
(flags & DIRTY) === 0 &&
|
|
778
|
+
(flags & DIRTY) === 0 &&
|
|
783
779
|
depends_on(reaction, sources, checked)
|
|
784
780
|
) {
|
|
785
781
|
set_signal_status(reaction, DIRTY);
|
|
@@ -949,7 +945,7 @@ export function eager(fn) {
|
|
|
949
945
|
*/
|
|
950
946
|
export function fork(fn) {
|
|
951
947
|
if (!async_mode_flag) {
|
|
952
|
-
e.
|
|
948
|
+
e.experimental_async_required('fork');
|
|
953
949
|
}
|
|
954
950
|
|
|
955
951
|
if (current_batch !== null) {
|
|
@@ -958,12 +954,15 @@ export function fork(fn) {
|
|
|
958
954
|
|
|
959
955
|
var batch = Batch.ensure();
|
|
960
956
|
batch.is_fork = true;
|
|
957
|
+
batch_values = new Map();
|
|
961
958
|
|
|
962
959
|
var committed = false;
|
|
963
960
|
var settled = batch.settled();
|
|
964
961
|
|
|
965
962
|
flushSync(fn);
|
|
966
963
|
|
|
964
|
+
batch_values = null;
|
|
965
|
+
|
|
967
966
|
// revert state changes
|
|
968
967
|
for (var [source, value] of batch.previous) {
|
|
969
968
|
source.v = value;
|
|
@@ -29,7 +29,7 @@ import * as e from '../errors.js';
|
|
|
29
29
|
import * as w from '../warnings.js';
|
|
30
30
|
import { async_effect, destroy_effect, effect_tracking, teardown } from './effects.js';
|
|
31
31
|
import { eager_effects, internal_set, set_eager_effects, source } from './sources.js';
|
|
32
|
-
import {
|
|
32
|
+
import { get_error } from '../../shared/dev.js';
|
|
33
33
|
import { async_mode_flag, tracing_mode_flag } from '../../flags/index.js';
|
|
34
34
|
import { Boundary } from '../dom/blocks/boundary.js';
|
|
35
35
|
import { component_context } from '../context.js';
|
|
@@ -84,7 +84,7 @@ export function derived(fn) {
|
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
if (DEV && tracing_mode_flag) {
|
|
87
|
-
signal.created =
|
|
87
|
+
signal.created = get_error('created at');
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
return signal;
|
|
@@ -378,7 +378,7 @@ export function update_derived(derived) {
|
|
|
378
378
|
if (batch_values !== null) {
|
|
379
379
|
// only cache the value if we're in a tracking context, otherwise we won't
|
|
380
380
|
// clear the cache in `mark_reactions` when dependencies are updated
|
|
381
|
-
if (effect_tracking()) {
|
|
381
|
+
if (effect_tracking() || current_batch?.is_fork) {
|
|
382
382
|
batch_values.set(derived, value);
|
|
383
383
|
}
|
|
384
384
|
} else {
|
|
@@ -33,7 +33,8 @@ import {
|
|
|
33
33
|
STALE_REACTION,
|
|
34
34
|
USER_EFFECT,
|
|
35
35
|
ASYNC,
|
|
36
|
-
CONNECTED
|
|
36
|
+
CONNECTED,
|
|
37
|
+
MANAGED_EFFECT
|
|
37
38
|
} from '#client/constants';
|
|
38
39
|
import * as e from '../errors.js';
|
|
39
40
|
import { DEV } from 'esm-env';
|
|
@@ -401,6 +402,18 @@ export function block(fn, flags = 0) {
|
|
|
401
402
|
return effect;
|
|
402
403
|
}
|
|
403
404
|
|
|
405
|
+
/**
|
|
406
|
+
* @param {(() => void)} fn
|
|
407
|
+
* @param {number} flags
|
|
408
|
+
*/
|
|
409
|
+
export function managed(fn, flags = 0) {
|
|
410
|
+
var effect = create_effect(MANAGED_EFFECT | flags, fn, true);
|
|
411
|
+
if (DEV) {
|
|
412
|
+
effect.dev_stack = dev_stack;
|
|
413
|
+
}
|
|
414
|
+
return effect;
|
|
415
|
+
}
|
|
416
|
+
|
|
404
417
|
/**
|
|
405
418
|
* @param {(() => void)} fn
|
|
406
419
|
*/
|
|
@@ -34,7 +34,8 @@ import {
|
|
|
34
34
|
} from '#client/constants';
|
|
35
35
|
import * as e from '../errors.js';
|
|
36
36
|
import { legacy_mode_flag, tracing_mode_flag } from '../../flags/index.js';
|
|
37
|
-
import {
|
|
37
|
+
import { tag_proxy } from '../dev/tracing.js';
|
|
38
|
+
import { get_error } from '../../shared/dev.js';
|
|
38
39
|
import { component_context, is_runes } from '../context.js';
|
|
39
40
|
import { Batch, batch_values, eager_block_effects, schedule_effect } from './batch.js';
|
|
40
41
|
import { proxy } from '../proxy.js';
|
|
@@ -78,7 +79,7 @@ export function source(v, stack) {
|
|
|
78
79
|
};
|
|
79
80
|
|
|
80
81
|
if (DEV && tracing_mode_flag) {
|
|
81
|
-
signal.created = stack ??
|
|
82
|
+
signal.created = stack ?? get_error('created at');
|
|
82
83
|
signal.updated = null;
|
|
83
84
|
signal.set_during_effect = false;
|
|
84
85
|
signal.trace = null;
|
|
@@ -196,7 +197,7 @@ export function internal_set(source, value) {
|
|
|
196
197
|
source.updated.set('', { error: /** @type {any} */ (null), count });
|
|
197
198
|
|
|
198
199
|
if (tracing_mode_flag || count > 5) {
|
|
199
|
-
const error =
|
|
200
|
+
const error = get_error('updated at');
|
|
200
201
|
|
|
201
202
|
if (error !== null) {
|
|
202
203
|
let entry = source.updated.get(error.stack);
|
|
@@ -363,10 +364,8 @@ function mark_reactions(signal, status) {
|
|
|
363
364
|
mark_reactions(derived, MAYBE_DIRTY);
|
|
364
365
|
}
|
|
365
366
|
} else if (not_dirty) {
|
|
366
|
-
if ((flags & BLOCK_EFFECT) !== 0) {
|
|
367
|
-
|
|
368
|
-
eager_block_effects.add(/** @type {Effect} */ (reaction));
|
|
369
|
-
}
|
|
367
|
+
if ((flags & BLOCK_EFFECT) !== 0 && eager_block_effects !== null) {
|
|
368
|
+
eager_block_effects.add(/** @type {Effect} */ (reaction));
|
|
370
369
|
}
|
|
371
370
|
|
|
372
371
|
schedule_effect(/** @type {Effect} */ (reaction));
|
|
@@ -21,7 +21,8 @@ import {
|
|
|
21
21
|
REACTION_IS_UPDATING,
|
|
22
22
|
STALE_REACTION,
|
|
23
23
|
ERROR_VALUE,
|
|
24
|
-
WAS_MARKED
|
|
24
|
+
WAS_MARKED,
|
|
25
|
+
MANAGED_EFFECT
|
|
25
26
|
} from './constants.js';
|
|
26
27
|
import { old_values } from './reactivity/sources.js';
|
|
27
28
|
import {
|
|
@@ -32,7 +33,8 @@ import {
|
|
|
32
33
|
update_derived
|
|
33
34
|
} from './reactivity/deriveds.js';
|
|
34
35
|
import { async_mode_flag, tracing_mode_flag } from '../flags/index.js';
|
|
35
|
-
import { tracing_expressions
|
|
36
|
+
import { tracing_expressions } from './dev/tracing.js';
|
|
37
|
+
import { get_error } from '../shared/dev.js';
|
|
36
38
|
import {
|
|
37
39
|
component_context,
|
|
38
40
|
dev_current_component_function,
|
|
@@ -43,7 +45,13 @@ import {
|
|
|
43
45
|
set_dev_stack
|
|
44
46
|
} from './context.js';
|
|
45
47
|
import * as w from './warnings.js';
|
|
46
|
-
import {
|
|
48
|
+
import {
|
|
49
|
+
Batch,
|
|
50
|
+
batch_values,
|
|
51
|
+
current_batch,
|
|
52
|
+
flushSync,
|
|
53
|
+
schedule_effect
|
|
54
|
+
} from './reactivity/batch.js';
|
|
47
55
|
import { handle_error } from './error-handling.js';
|
|
48
56
|
import { UNINITIALIZED } from '../../constants.js';
|
|
49
57
|
import { captured_signals } from './legacy.js';
|
|
@@ -421,7 +429,7 @@ export function update_effect(effect) {
|
|
|
421
429
|
}
|
|
422
430
|
|
|
423
431
|
try {
|
|
424
|
-
if ((flags & BLOCK_EFFECT) !== 0) {
|
|
432
|
+
if ((flags & (BLOCK_EFFECT | MANAGED_EFFECT)) !== 0) {
|
|
425
433
|
destroy_block_effect_children(effect);
|
|
426
434
|
} else {
|
|
427
435
|
destroy_effect_children(effect);
|
|
@@ -547,7 +555,7 @@ export function get(signal) {
|
|
|
547
555
|
// if (!tracking && !untracking && !was_read) {
|
|
548
556
|
// w.await_reactivity_loss(/** @type {string} */ (signal.label));
|
|
549
557
|
|
|
550
|
-
// var trace =
|
|
558
|
+
// var trace = get_error('traced at');
|
|
551
559
|
// // eslint-disable-next-line no-console
|
|
552
560
|
// if (trace) console.warn(trace);
|
|
553
561
|
// }
|
|
@@ -566,7 +574,7 @@ export function get(signal) {
|
|
|
566
574
|
if (signal.trace) {
|
|
567
575
|
signal.trace();
|
|
568
576
|
} else {
|
|
569
|
-
var trace =
|
|
577
|
+
var trace = get_error('traced at');
|
|
570
578
|
|
|
571
579
|
if (trace) {
|
|
572
580
|
var entry = tracing_expressions.entries.get(signal);
|
|
@@ -611,7 +619,10 @@ export function get(signal) {
|
|
|
611
619
|
|
|
612
620
|
return value;
|
|
613
621
|
}
|
|
614
|
-
} else if (
|
|
622
|
+
} else if (
|
|
623
|
+
is_derived &&
|
|
624
|
+
(!batch_values?.has(signal) || (current_batch?.is_fork && !effect_tracking()))
|
|
625
|
+
) {
|
|
615
626
|
derived = /** @type {Derived} */ (signal);
|
|
616
627
|
|
|
617
628
|
if (is_dirty(derived)) {
|
|
@@ -87,6 +87,18 @@ export function event_handler_invalid(handler, suggestion) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Expected to find a hydratable with key `%key%` during hydration, but did not.
|
|
92
|
+
* @param {string} key
|
|
93
|
+
*/
|
|
94
|
+
export function hydratable_missing_but_expected(key) {
|
|
95
|
+
if (DEV) {
|
|
96
|
+
console.warn(`%c[svelte] hydratable_missing_but_expected\n%cExpected to find a hydratable with key \`${key}\` during hydration, but did not.\nhttps://svelte.dev/e/hydratable_missing_but_expected`, bold, normal);
|
|
97
|
+
} else {
|
|
98
|
+
console.warn(`https://svelte.dev/e/hydratable_missing_but_expected`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
90
102
|
/**
|
|
91
103
|
* The `%attribute%` attribute on `%html%` changed its value between server and client renders. The client value, `%value%`, will be ignored in favour of the server value
|
|
92
104
|
* @param {string} attribute
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
is_tag_valid_with_ancestor,
|
|
5
5
|
is_tag_valid_with_parent
|
|
6
6
|
} from '../../html-tree-validation.js';
|
|
7
|
+
import { get_stack } from '../shared/dev.js';
|
|
7
8
|
import { set_ssr_context, ssr_context } from './context.js';
|
|
8
9
|
import * as e from './errors.js';
|
|
9
10
|
import { Renderer } from './renderer.js';
|
|
@@ -98,3 +99,12 @@ export function validate_snippet_args(renderer) {
|
|
|
98
99
|
e.invalid_snippet_arguments();
|
|
99
100
|
}
|
|
100
101
|
}
|
|
102
|
+
|
|
103
|
+
export function get_user_code_location() {
|
|
104
|
+
const stack = get_stack();
|
|
105
|
+
|
|
106
|
+
return stack
|
|
107
|
+
.filter((line) => line.trim().startsWith('at '))
|
|
108
|
+
.map((line) => line.replace(/\((.*):\d+:\d+\)$/, (_, file) => `(${file})`))
|
|
109
|
+
.join('\n');
|
|
110
|
+
}
|
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
export * from '../shared/errors.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* The node API `AsyncLocalStorage` is not available, but is required to use async server rendering.
|
|
7
|
+
* @returns {never}
|
|
8
|
+
*/
|
|
9
|
+
export function async_local_storage_unavailable() {
|
|
10
|
+
const error = new Error(`async_local_storage_unavailable\nThe node API \`AsyncLocalStorage\` is not available, but is required to use async server rendering.\nhttps://svelte.dev/e/async_local_storage_unavailable`);
|
|
11
|
+
|
|
12
|
+
error.name = 'Svelte error';
|
|
13
|
+
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* Encountered asynchronous work while rendering synchronously.
|
|
7
19
|
* @returns {never}
|
|
@@ -26,6 +38,48 @@ export function html_deprecated() {
|
|
|
26
38
|
throw error;
|
|
27
39
|
}
|
|
28
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Attempted to set `hydratable` with key `%key%` twice with different values.
|
|
43
|
+
*
|
|
44
|
+
* %stack%
|
|
45
|
+
* @param {string} key
|
|
46
|
+
* @param {string} stack
|
|
47
|
+
* @returns {never}
|
|
48
|
+
*/
|
|
49
|
+
export function hydratable_clobbering(key, stack) {
|
|
50
|
+
const error = new Error(`hydratable_clobbering\nAttempted to set \`hydratable\` with key \`${key}\` twice with different values.
|
|
51
|
+
|
|
52
|
+
${stack}\nhttps://svelte.dev/e/hydratable_clobbering`);
|
|
53
|
+
|
|
54
|
+
error.name = 'Svelte error';
|
|
55
|
+
|
|
56
|
+
throw error;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Failed to serialize `hydratable` data for key `%key%`.
|
|
61
|
+
*
|
|
62
|
+
* `hydratable` can serialize anything [`uneval` from `devalue`](https://npmjs.com/package/uneval) can, plus Promises.
|
|
63
|
+
*
|
|
64
|
+
* Cause:
|
|
65
|
+
* %stack%
|
|
66
|
+
* @param {string} key
|
|
67
|
+
* @param {string} stack
|
|
68
|
+
* @returns {never}
|
|
69
|
+
*/
|
|
70
|
+
export function hydratable_serialization_failed(key, stack) {
|
|
71
|
+
const error = new Error(`hydratable_serialization_failed\nFailed to serialize \`hydratable\` data for key \`${key}\`.
|
|
72
|
+
|
|
73
|
+
\`hydratable\` can serialize anything [\`uneval\` from \`devalue\`](https://npmjs.com/package/uneval) can, plus Promises.
|
|
74
|
+
|
|
75
|
+
Cause:
|
|
76
|
+
${stack}\nhttps://svelte.dev/e/hydratable_serialization_failed`);
|
|
77
|
+
|
|
78
|
+
error.name = 'Svelte error';
|
|
79
|
+
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
|
|
29
83
|
/**
|
|
30
84
|
* `%name%(...)` is not available on the server
|
|
31
85
|
* @param {string} name
|
|
@@ -36,5 +90,17 @@ export function lifecycle_function_unavailable(name) {
|
|
|
36
90
|
|
|
37
91
|
error.name = 'Svelte error';
|
|
38
92
|
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Could not resolve `render` context.
|
|
98
|
+
* @returns {never}
|
|
99
|
+
*/
|
|
100
|
+
export function server_context_required() {
|
|
101
|
+
const error = new Error(`server_context_required\nCould not resolve \`render\` context.\nhttps://svelte.dev/e/server_context_required`);
|
|
102
|
+
|
|
103
|
+
error.name = 'Svelte error';
|
|
104
|
+
|
|
39
105
|
throw error;
|
|
40
106
|
}
|