Skip to content

Commit 888fc31

Browse files
committed
is_async -> has_await
1 parent fcbb54d commit 888fc31

File tree

20 files changed

+67
-62
lines changed

20 files changed

+67
-62
lines changed

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,14 @@ function js(script, root, allow_reactive_declarations, parent) {
203203
body: []
204204
};
205205

206-
const { scope, scopes, is_async } = create_scopes(ast, root, allow_reactive_declarations, parent);
206+
const { scope, scopes, has_await } = create_scopes(
207+
ast,
208+
root,
209+
allow_reactive_declarations,
210+
parent
211+
);
207212

208-
return { ast, scope, scopes, is_async };
213+
return { ast, scope, scopes, has_await };
209214
}
210215

211216
/**
@@ -230,7 +235,7 @@ const RESERVED = ['$$props', '$$restProps', '$$slots'];
230235
* @returns {Analysis}
231236
*/
232237
export function analyze_module(ast, options) {
233-
const { scope, scopes, is_async } = create_scopes(ast, new ScopeRoot(), false, null);
238+
const { scope, scopes, has_await } = create_scopes(ast, new ScopeRoot(), false, null);
234239

235240
for (const [name, references] of scope.references) {
236241
if (name[0] !== '$' || RESERVED.includes(name)) continue;
@@ -247,7 +252,7 @@ export function analyze_module(ast, options) {
247252

248253
/** @type {Analysis} */
249254
const analysis = {
250-
module: { ast, scope, scopes, is_async },
255+
module: { ast, scope, scopes, has_await },
251256
name: options.filename,
252257
accessors: false,
253258
runes: true,
@@ -293,7 +298,7 @@ export function analyze_component(root, source, options) {
293298
const module = js(root.module, scope_root, false, null);
294299
const instance = js(root.instance, scope_root, true, module.scope);
295300

296-
const { scope, scopes, is_async } = create_scopes(
301+
const { scope, scopes, has_await } = create_scopes(
297302
root.fragment,
298303
scope_root,
299304
false,
@@ -408,7 +413,7 @@ export function analyze_component(root, source, options) {
408413

409414
const runes =
410415
options.runes ??
411-
(is_async || instance.is_async || Array.from(module.scope.references.keys()).some(is_rune));
416+
(has_await || instance.has_await || Array.from(module.scope.references.keys()).some(is_rune));
412417

413418
if (!runes) {
414419
for (let check of synthetic_stores_legacy_check) {

packages/svelte/src/compiler/phases/2-analyze/visitors/AwaitExpression.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function AwaitExpression(node, context) {
1212
let preserve_context = tla;
1313

1414
if (context.state.expression) {
15-
context.state.expression.is_async = true;
15+
context.state.expression.has_await = true;
1616
suspend = true;
1717

1818
// wrap the expression in `(await $.save(...)).restore()` if necessary,

packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export function CallExpression(node, context) {
242242
expression
243243
});
244244

245-
if (expression.is_async) {
245+
if (expression.has_await) {
246246
context.state.analysis.async_deriveds.add(node);
247247
}
248248
} else if (rune === '$inspect') {

packages/svelte/src/compiler/phases/2-analyze/visitors/StyleDirective.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export function StyleDirective(node, context) {
3232

3333
node.metadata.expression.has_state ||= chunk.metadata.expression.has_state;
3434
node.metadata.expression.has_call ||= chunk.metadata.expression.has_call;
35-
node.metadata.expression.is_async ||= chunk.metadata.expression.is_async;
35+
node.metadata.expression.has_await ||= chunk.metadata.expression.has_await;
3636
}
3737
}
3838
}

packages/svelte/src/compiler/phases/3-transform/client/transform-client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ export function client_component(analysis, options) {
369369
: b.stmt(b.call('$.init', analysis.immutable ? b.true : undefined))
370370
]);
371371

372-
if (analysis.instance.is_async) {
372+
if (analysis.instance.has_await) {
373373
const body = b.function_declaration(
374374
b.id('$$body'),
375375
[b.id('$$anchor'), b.id('$$props')],
@@ -379,9 +379,9 @@ export function client_component(analysis, options) {
379379
b.if(b.call('$.aborted'), b.return()),
380380
.../** @type {ESTree.Statement[]} */ (template.body),
381381
b.stmt(b.call('$$unsuspend'))
382-
])
382+
]),
383+
true
383384
);
384-
body.async = true;
385385

386386
state.hoisted.push(body);
387387

packages/svelte/src/compiler/phases/3-transform/client/visitors/BlockStatement.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** @import { ArrowFunctionExpression, BlockStatement, CallExpression, Expression, FunctionDeclaration, FunctionExpression, Statement } from 'estree' */
1+
/** @import { ArrowFunctionExpression, BlockStatement, Expression, FunctionDeclaration, FunctionExpression, Statement } from 'estree' */
22
/** @import { ComponentContext } from '../types' */
33
import { add_state_transformers } from './shared/declarations.js';
44
import * as b from '../../../../utils/builders.js';

packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ export function EachBlock(node, context) {
293293
);
294294
}
295295

296-
const { is_async } = node.metadata.expression;
296+
const { has_await } = node.metadata.expression;
297297

298-
const thunk = b.thunk(collection, is_async);
298+
const thunk = b.thunk(collection, has_await);
299299

300300
const render_args = [b.id('$$anchor'), item];
301301
if (uses_index || collection_id) render_args.push(index);
@@ -305,7 +305,7 @@ export function EachBlock(node, context) {
305305
const args = [
306306
context.state.node,
307307
b.literal(flags),
308-
is_async ? b.thunk(b.call('$.get', b.id('$$collection'))) : thunk,
308+
has_await ? b.thunk(b.call('$.get', b.id('$$collection'))) : thunk,
309309
key_function,
310310
b.arrow(render_args, b.block(declarations.concat(block.body)))
311311
];
@@ -316,7 +316,7 @@ export function EachBlock(node, context) {
316316
);
317317
}
318318

319-
if (is_async) {
319+
if (has_await) {
320320
context.state.init.push(
321321
b.stmt(
322322
b.call(

packages/svelte/src/compiler/phases/3-transform/client/visitors/HtmlTag.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import * as b from '../../../../utils/builders.js';
1111
export function HtmlTag(node, context) {
1212
context.state.template.push('<!>');
1313

14-
const { is_async } = node.metadata.expression;
14+
const { has_await } = node.metadata.expression;
1515

1616
const expression = /** @type {Expression} */ (context.visit(node.expression));
17-
const html = is_async ? b.call('$.get', b.id('$$html')) : expression;
17+
const html = has_await ? b.call('$.get', b.id('$$html')) : expression;
1818

1919
const is_svg = context.state.metadata.namespace === 'svg';
2020
const is_mathml = context.state.metadata.namespace === 'mathml';
@@ -31,7 +31,7 @@ export function HtmlTag(node, context) {
3131
);
3232

3333
// push into init, so that bindings run afterwards, which might trigger another run and override hydration
34-
if (node.metadata.expression.is_async) {
34+
if (node.metadata.expression.has_await) {
3535
context.state.init.push(
3636
b.stmt(
3737
b.call(

packages/svelte/src/compiler/phases/3-transform/client/visitors/IfBlock.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ export function IfBlock(node, context) {
2424
statements.push(b.var(b.id(alternate_id), b.arrow([b.id('$$anchor')], alternate)));
2525
}
2626

27-
const { is_async } = node.metadata.expression;
27+
const { has_await } = node.metadata.expression;
2828

2929
const expression = /** @type {Expression} */ (context.visit(node.test));
30-
const test = is_async ? b.call('$.get', b.id('$$condition')) : expression;
30+
const test = has_await ? b.call('$.get', b.id('$$condition')) : expression;
3131

3232
/** @type {Expression[]} */
3333
const args = [
@@ -79,7 +79,7 @@ export function IfBlock(node, context) {
7979

8080
statements.push(b.stmt(b.call('$.if', ...args)));
8181

82-
if (is_async) {
82+
if (has_await) {
8383
context.state.init.push(
8484
b.stmt(
8585
b.call(

packages/svelte/src/compiler/phases/3-transform/client/visitors/KeyBlock.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function KeyBlock(node, context) {
1313
const key = /** @type {Expression} */ (context.visit(node.expression));
1414
const body = /** @type {Expression} */ (context.visit(node.fragment));
1515

16-
if (node.metadata.expression.is_async) {
16+
if (node.metadata.expression.has_await) {
1717
context.state.init.push(
1818
b.stmt(
1919
b.call(

0 commit comments

Comments
 (0)