@@ -14,7 +14,7 @@ import { locator } from '../../../../../state.js';
14
14
* @param {Array<AST.Text | AST.ExpressionTag> } values
15
15
* @param {(node: AST.SvelteNode, state: any) => any } visit
16
16
* @param {ComponentClientTransformState } state
17
- * @returns {{ value: Expression, has_state: boolean, has_call: boolean } }
17
+ * @returns {{ value: Expression, has_state: boolean, has_call: boolean, is_async: boolean } }
18
18
*/
19
19
export function build_template_chunk ( values , visit , state ) {
20
20
/** @type {Expression[] } */
@@ -25,6 +25,7 @@ export function build_template_chunk(values, visit, state) {
25
25
26
26
let has_call = false ;
27
27
let has_state = false ;
28
+ let is_async = false ;
28
29
let contains_multiple_call_expression = false ;
29
30
30
31
for ( const node of values ) {
@@ -34,6 +35,7 @@ export function build_template_chunk(values, visit, state) {
34
35
contains_multiple_call_expression ||= has_call && metadata . has_call ;
35
36
has_call ||= metadata . has_call ;
36
37
has_state ||= metadata . has_state ;
38
+ is_async ||= metadata . is_async ;
37
39
}
38
40
}
39
41
@@ -68,7 +70,7 @@ export function build_template_chunk(values, visit, state) {
68
70
} else if ( values . length === 1 ) {
69
71
// If we have a single expression, then pass that in directly to possibly avoid doing
70
72
// extra work in the template_effect (instead we do the work in set_text).
71
- return { value : visit ( node . expression , state ) , has_state, has_call } ;
73
+ return { value : visit ( node . expression , state ) , has_state, has_call, is_async } ;
72
74
} else {
73
75
expressions . push ( b . logical ( '??' , visit ( node . expression , state ) , b . literal ( '' ) ) ) ;
74
76
}
@@ -84,17 +86,18 @@ export function build_template_chunk(values, visit, state) {
84
86
85
87
const value = b . template ( quasis , expressions ) ;
86
88
87
- return { value, has_state, has_call } ;
89
+ return { value, has_state, has_call, is_async } ;
88
90
}
89
91
90
92
/**
91
93
* @param {Statement } statement
94
+ * @param {boolean } is_async
92
95
*/
93
- export function build_update ( statement ) {
96
+ export function build_update ( statement , is_async ) {
94
97
const body =
95
98
statement . type === 'ExpressionStatement' ? statement . expression : b . block ( [ statement ] ) ;
96
99
97
- return b . stmt ( b . call ( '$.template_effect' , b . thunk ( body ) ) ) ;
100
+ return b . stmt ( b . call ( '$.template_effect' , b . thunk ( body , is_async ) ) ) ;
98
101
}
99
102
100
103
/**
0 commit comments