svelte 5.44.0 → 5.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiler/index.js +1 -1
- package/package.json +1 -1
- package/src/compiler/migrate/index.js +2 -2
- package/src/compiler/phases/3-transform/client/visitors/ConstTag.js +11 -5
- package/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +1 -1
- package/src/compiler/phases/3-transform/server/visitors/ConstTag.js +8 -1
- package/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js +1 -1
- package/src/compiler/phases/3-transform/shared/transform-async.js +15 -16
- package/src/internal/client/dev/debug.js +25 -2
- package/src/internal/client/dom/blocks/each.js +14 -2
- package/src/internal/client/dom/elements/bindings/this.js +1 -1
- package/src/internal/client/dom/elements/misc.js +1 -1
- package/src/version.js +1 -1
package/package.json
CHANGED
|
@@ -604,7 +604,7 @@ const instance_script = {
|
|
|
604
604
|
'Encountered an export declaration pattern that is not supported for automigration.'
|
|
605
605
|
);
|
|
606
606
|
// Turn export let into props. It's really really weird because export let { x: foo, z: [bar]} = ..
|
|
607
|
-
// means that foo and bar are the props (i.e. the
|
|
607
|
+
// means that foo and bar are the props (i.e. the leaves are the prop names), not x and z.
|
|
608
608
|
// const tmp = b.id(state.scope.generate('tmp'));
|
|
609
609
|
// const paths = extract_paths(declarator.id, tmp);
|
|
610
610
|
// state.props_pre.push(
|
|
@@ -1812,7 +1812,7 @@ function handle_events(element, state) {
|
|
|
1812
1812
|
}
|
|
1813
1813
|
|
|
1814
1814
|
/**
|
|
1815
|
-
* Returns start and end of the node. If the start is
|
|
1815
|
+
* Returns start and end of the node. If the start is preceded with white-space-only before a line break,
|
|
1816
1816
|
* the start will be the start of the line.
|
|
1817
1817
|
* @param {string} source
|
|
1818
1818
|
* @param {LabeledStatement} node
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @import { Pattern } from 'estree' */
|
|
2
2
|
/** @import { AST } from '#compiler' */
|
|
3
3
|
/** @import { ComponentContext } from '../types' */
|
|
4
|
+
/** @import { ExpressionMetadata } from '../../../nodes.js' */
|
|
4
5
|
import { dev } from '../../../../state.js';
|
|
5
6
|
import { extract_identifiers } from '../../../../utils/ast.js';
|
|
6
7
|
import * as b from '#compiler/builders';
|
|
@@ -30,7 +31,7 @@ export function ConstTag(node, context) {
|
|
|
30
31
|
context.state,
|
|
31
32
|
declaration.id,
|
|
32
33
|
expression,
|
|
33
|
-
node.metadata.expression
|
|
34
|
+
node.metadata.expression,
|
|
34
35
|
context.state.scope.get_bindings(declaration)
|
|
35
36
|
);
|
|
36
37
|
} else {
|
|
@@ -73,7 +74,7 @@ export function ConstTag(node, context) {
|
|
|
73
74
|
context.state,
|
|
74
75
|
tmp,
|
|
75
76
|
expression,
|
|
76
|
-
node.metadata.expression
|
|
77
|
+
node.metadata.expression,
|
|
77
78
|
context.state.scope.get_bindings(declaration)
|
|
78
79
|
);
|
|
79
80
|
|
|
@@ -89,15 +90,18 @@ export function ConstTag(node, context) {
|
|
|
89
90
|
* @param {ComponentContext['state']} state
|
|
90
91
|
* @param {import('estree').Identifier} id
|
|
91
92
|
* @param {import('estree').Expression} expression
|
|
92
|
-
* @param {
|
|
93
|
+
* @param {ExpressionMetadata} metadata
|
|
93
94
|
* @param {import('#compiler').Binding[]} bindings
|
|
94
95
|
*/
|
|
95
|
-
function add_const_declaration(state, id, expression,
|
|
96
|
+
function add_const_declaration(state, id, expression, metadata, bindings) {
|
|
96
97
|
// we need to eagerly evaluate the expression in order to hit any
|
|
97
98
|
// 'Cannot access x before initialization' errors
|
|
98
99
|
const after = dev ? [b.stmt(b.call('$.get', id))] : [];
|
|
99
100
|
|
|
100
|
-
|
|
101
|
+
const has_await = metadata.has_await;
|
|
102
|
+
const blockers = [...metadata.dependencies].map((dep) => dep.blocker).filter((b) => b !== null);
|
|
103
|
+
|
|
104
|
+
if (has_await || state.async_consts || blockers.length > 0) {
|
|
101
105
|
const run = (state.async_consts ??= {
|
|
102
106
|
id: b.id(state.scope.generate('promises')),
|
|
103
107
|
thunks: []
|
|
@@ -108,6 +112,8 @@ function add_const_declaration(state, id, expression, has_await, bindings) {
|
|
|
108
112
|
const assignment = b.assignment('=', id, expression);
|
|
109
113
|
const body = after.length === 0 ? assignment : b.block([b.stmt(assignment), ...after]);
|
|
110
114
|
|
|
115
|
+
if (blockers.length > 0) run.thunks.push(b.thunk(b.call('Promise.all', b.array(blockers))));
|
|
116
|
+
|
|
111
117
|
run.thunks.push(b.thunk(body, has_await));
|
|
112
118
|
|
|
113
119
|
const blocker = b.member(run.id, b.literal(run.thunks.length - 1), true);
|
|
@@ -305,7 +305,7 @@ export function VariableDeclaration(node, context) {
|
|
|
305
305
|
if (has_props) {
|
|
306
306
|
if (declarator.id.type !== 'Identifier') {
|
|
307
307
|
// Turn export let into props. It's really really weird because export let { x: foo, z: [bar]} = ..
|
|
308
|
-
// means that foo and bar are the props (i.e. the
|
|
308
|
+
// means that foo and bar are the props (i.e. the leaves are the prop names), not x and z.
|
|
309
309
|
const tmp = b.id(context.state.scope.generate('tmp'));
|
|
310
310
|
const { inserts, paths } = extract_paths(declarator.id, tmp);
|
|
311
311
|
|
|
@@ -13,8 +13,11 @@ export function ConstTag(node, context) {
|
|
|
13
13
|
const id = /** @type {Pattern} */ (context.visit(declaration.id));
|
|
14
14
|
const init = /** @type {Expression} */ (context.visit(declaration.init));
|
|
15
15
|
const has_await = node.metadata.expression.has_await;
|
|
16
|
+
const blockers = [...node.metadata.expression.dependencies]
|
|
17
|
+
.map((dep) => dep.blocker)
|
|
18
|
+
.filter((b) => b !== null);
|
|
16
19
|
|
|
17
|
-
if (has_await || context.state.async_consts) {
|
|
20
|
+
if (has_await || context.state.async_consts || blockers.length > 0) {
|
|
18
21
|
const run = (context.state.async_consts ??= {
|
|
19
22
|
id: b.id(context.state.scope.generate('promises')),
|
|
20
23
|
thunks: []
|
|
@@ -27,6 +30,10 @@ export function ConstTag(node, context) {
|
|
|
27
30
|
context.state.init.push(b.let(identifier.name));
|
|
28
31
|
}
|
|
29
32
|
|
|
33
|
+
if (blockers.length > 0) {
|
|
34
|
+
run.thunks.push(b.thunk(b.call('Promise.all', b.array(blockers))));
|
|
35
|
+
}
|
|
36
|
+
|
|
30
37
|
const assignment = b.assignment('=', id, init);
|
|
31
38
|
run.thunks.push(b.thunk(b.block([b.stmt(assignment)]), has_await));
|
|
32
39
|
|
|
@@ -119,7 +119,7 @@ export function VariableDeclaration(node, context) {
|
|
|
119
119
|
if (has_props) {
|
|
120
120
|
if (declarator.id.type !== 'Identifier') {
|
|
121
121
|
// Turn export let into props. It's really really weird because export let { x: foo, z: [bar]} = ..
|
|
122
|
-
// means that foo and bar are the props (i.e. the
|
|
122
|
+
// means that foo and bar are the props (i.e. the leaves are the prop names), not x and z.
|
|
123
123
|
const tmp = b.id(context.state.scope.generate('tmp'));
|
|
124
124
|
const { inserts, paths } = extract_paths(declarator.id, tmp);
|
|
125
125
|
|
|
@@ -35,7 +35,7 @@ export function transform_body(instance_body, runner, transform) {
|
|
|
35
35
|
(node) => /** @type {ESTree.Statement | ESTree.VariableDeclaration} */ (transform(node))
|
|
36
36
|
);
|
|
37
37
|
|
|
38
|
-
// Declarations for the await expressions (they will
|
|
38
|
+
// Declarations for the await expressions (they will assign to them; need to be hoisted to be available in whole instance scope)
|
|
39
39
|
if (instance_body.declarations.length > 0) {
|
|
40
40
|
statements.push(
|
|
41
41
|
b.declaration(
|
|
@@ -53,23 +53,22 @@ export function transform_body(instance_body, runner, transform) {
|
|
|
53
53
|
transform(b.var(s.node.id, s.node.init))
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
const statements = visited.declarations.map((node) => {
|
|
57
|
+
if (node.id.type === 'Identifier' && node.id.name.startsWith('$$d')) {
|
|
58
|
+
// this is an intermediate declaration created in VariableDeclaration.js;
|
|
59
|
+
// subsequent statements depend on it
|
|
60
|
+
return b.var(node.id, node.init);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return b.stmt(b.assignment('=', node.id, node.init ?? b.void0));
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (statements.length === 1) {
|
|
67
|
+
const statement = /** @type {ESTree.ExpressionStatement} */ (statements[0]);
|
|
68
|
+
return b.thunk(statement.expression, s.has_await);
|
|
61
69
|
}
|
|
62
70
|
|
|
63
|
-
|
|
64
|
-
return b.thunk(
|
|
65
|
-
b.block([
|
|
66
|
-
b.var(visited.declarations[0].id, visited.declarations[0].init),
|
|
67
|
-
...visited.declarations
|
|
68
|
-
.slice(1)
|
|
69
|
-
.map((d) => b.stmt(b.assignment('=', d.id, d.init ?? b.void0)))
|
|
70
|
-
]),
|
|
71
|
-
s.has_await
|
|
72
|
-
);
|
|
71
|
+
return b.thunk(b.block(statements), s.has_await);
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
if (s.node.type === 'ClassDeclaration') {
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
RENDER_EFFECT,
|
|
13
13
|
ROOT_EFFECT
|
|
14
14
|
} from '#client/constants';
|
|
15
|
+
import { snapshot } from '../../shared/clone.js';
|
|
16
|
+
import { untrack } from '../runtime.js';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
*
|
|
@@ -84,6 +86,16 @@ export function log_effect_tree(effect, depth = 0) {
|
|
|
84
86
|
console.groupEnd();
|
|
85
87
|
}
|
|
86
88
|
|
|
89
|
+
if (effect.nodes_start && effect.nodes_end) {
|
|
90
|
+
// eslint-disable-next-line no-console
|
|
91
|
+
console.log(effect.nodes_start);
|
|
92
|
+
|
|
93
|
+
if (effect.nodes_start !== effect.nodes_end) {
|
|
94
|
+
// eslint-disable-next-line no-console
|
|
95
|
+
console.log(effect.nodes_end);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
87
99
|
let child = effect.first;
|
|
88
100
|
while (child !== null) {
|
|
89
101
|
log_effect_tree(child, depth + 1);
|
|
@@ -103,7 +115,13 @@ function log_dep(dep) {
|
|
|
103
115
|
const derived = /** @type {Derived} */ (dep);
|
|
104
116
|
|
|
105
117
|
// eslint-disable-next-line no-console
|
|
106
|
-
console.groupCollapsed(
|
|
118
|
+
console.groupCollapsed(
|
|
119
|
+
`%c$derived %c${dep.label ?? '<unknown>'}`,
|
|
120
|
+
'font-weight: bold; color: CornflowerBlue',
|
|
121
|
+
'font-weight: normal',
|
|
122
|
+
untrack(() => snapshot(derived.v))
|
|
123
|
+
);
|
|
124
|
+
|
|
107
125
|
if (derived.deps) {
|
|
108
126
|
for (const d of derived.deps) {
|
|
109
127
|
log_dep(d);
|
|
@@ -114,6 +132,11 @@ function log_dep(dep) {
|
|
|
114
132
|
console.groupEnd();
|
|
115
133
|
} else {
|
|
116
134
|
// eslint-disable-next-line no-console
|
|
117
|
-
console.log(
|
|
135
|
+
console.log(
|
|
136
|
+
`%c$state %c${dep.label ?? '<unknown>'}`,
|
|
137
|
+
'font-weight: bold; color: CornflowerBlue',
|
|
138
|
+
'font-weight: normal',
|
|
139
|
+
untrack(() => snapshot(dep.v))
|
|
140
|
+
);
|
|
118
141
|
}
|
|
119
142
|
}
|
|
@@ -394,8 +394,12 @@ function reconcile(state, array, anchor, flags, get_key) {
|
|
|
394
394
|
key = get_key(value, i);
|
|
395
395
|
item = /** @type {EachItem} */ (items.get(key));
|
|
396
396
|
|
|
397
|
-
|
|
398
|
-
|
|
397
|
+
// offscreen == coming in now, no animation in that case,
|
|
398
|
+
// else this would happen https://github.com/sveltejs/svelte/issues/17181
|
|
399
|
+
if (item.o) {
|
|
400
|
+
item.a?.measure();
|
|
401
|
+
(to_animate ??= new Set()).add(item);
|
|
402
|
+
}
|
|
399
403
|
}
|
|
400
404
|
}
|
|
401
405
|
|
|
@@ -637,6 +641,10 @@ function link(state, prev, next) {
|
|
|
637
641
|
state.first = next;
|
|
638
642
|
state.effect.first = next && next.e;
|
|
639
643
|
} else {
|
|
644
|
+
if (prev.e === state.effect.last && next !== null) {
|
|
645
|
+
state.effect.last = next.e;
|
|
646
|
+
}
|
|
647
|
+
|
|
640
648
|
if (prev.e.next) {
|
|
641
649
|
prev.e.next.prev = null;
|
|
642
650
|
}
|
|
@@ -648,6 +656,10 @@ function link(state, prev, next) {
|
|
|
648
656
|
if (next === null) {
|
|
649
657
|
state.effect.last = prev && prev.e;
|
|
650
658
|
} else {
|
|
659
|
+
if (next.e === state.effect.last && prev === null) {
|
|
660
|
+
state.effect.last = next.e.prev;
|
|
661
|
+
}
|
|
662
|
+
|
|
651
663
|
if (next.e.prev) {
|
|
652
664
|
next.e.prev.next = null;
|
|
653
665
|
}
|
|
@@ -38,7 +38,7 @@ export function bind_this(element_or_component = {}, update, get_value, get_part
|
|
|
38
38
|
untrack(() => {
|
|
39
39
|
if (element_or_component !== get_value(...parts)) {
|
|
40
40
|
update(element_or_component, ...parts);
|
|
41
|
-
// If this is an effect rerun (cause: each block context changes), then
|
|
41
|
+
// If this is an effect rerun (cause: each block context changes), then nullify the binding at
|
|
42
42
|
// the previous position if it isn't already taken over by a different effect.
|
|
43
43
|
if (old_parts && is_bound_this(get_value(...old_parts), element_or_component)) {
|
|
44
44
|
update(null, ...old_parts);
|
|
@@ -51,7 +51,7 @@ export function add_form_reset_listener() {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
|
-
// In the capture phase to guarantee we get noticed of it (no
|
|
54
|
+
// In the capture phase to guarantee we get noticed of it (no possibility of stopPropagation)
|
|
55
55
|
{ capture: true }
|
|
56
56
|
);
|
|
57
57
|
}
|
package/src/version.js
CHANGED