|
|
@ -359,22 +359,38 @@ export function client_component(analysis, options) {
|
|
|
|
if (dev) push_args.push(b.id(analysis.name));
|
|
|
|
if (dev) push_args.push(b.id(analysis.name));
|
|
|
|
|
|
|
|
|
|
|
|
let component_block = b.block([
|
|
|
|
let component_block = b.block([
|
|
|
|
|
|
|
|
store_init,
|
|
|
|
...store_setup,
|
|
|
|
...store_setup,
|
|
|
|
...legacy_reactive_declarations,
|
|
|
|
...legacy_reactive_declarations,
|
|
|
|
...group_binding_declarations,
|
|
|
|
...group_binding_declarations,
|
|
|
|
...state.instance_level_snippets,
|
|
|
|
...state.instance_level_snippets
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (analysis.instance.has_await) {
|
|
|
|
|
|
|
|
const body = b.block([
|
|
|
|
.../** @type {ESTree.Statement[]} */ (instance.body),
|
|
|
|
.../** @type {ESTree.Statement[]} */ (instance.body),
|
|
|
|
analysis.runes || !analysis.needs_context
|
|
|
|
b.if(b.call('$.aborted'), b.return()),
|
|
|
|
? b.empty
|
|
|
|
.../** @type {ESTree.Statement[]} */ (template.body)
|
|
|
|
: b.stmt(b.call('$.init', analysis.immutable ? b.true : undefined))
|
|
|
|
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
component_block.body.push(b.stmt(b.call(`$.async_body`, b.arrow([], body, true))));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
component_block.body.push(
|
|
|
|
|
|
|
|
.../** @type {ESTree.Statement[]} */ (instance.body),
|
|
|
|
|
|
|
|
.../** @type {ESTree.Statement[]} */ (template.body)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (analysis.needs_mutation_validation) {
|
|
|
|
if (analysis.needs_mutation_validation) {
|
|
|
|
component_block.body.unshift(
|
|
|
|
component_block.body.unshift(
|
|
|
|
b.var('$$ownership_validator', b.call('$.create_ownership_validator', b.id('$$props')))
|
|
|
|
b.var('$$ownership_validator', b.call('$.create_ownership_validator', b.id('$$props')))
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!analysis.runes && analysis.needs_context) {
|
|
|
|
|
|
|
|
component_block.body.push(b.stmt(b.call('$.init', analysis.immutable ? b.true : undefined)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const should_inject_context =
|
|
|
|
const should_inject_context =
|
|
|
|
dev ||
|
|
|
|
dev ||
|
|
|
|
analysis.needs_context ||
|
|
|
|
analysis.needs_context ||
|
|
|
@ -389,52 +405,6 @@ export function client_component(analysis, options) {
|
|
|
|
analysis.uses_slots ||
|
|
|
|
analysis.uses_slots ||
|
|
|
|
analysis.slot_names.size > 0;
|
|
|
|
analysis.slot_names.size > 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (analysis.instance.has_await) {
|
|
|
|
|
|
|
|
const params = [b.id('$$anchor')];
|
|
|
|
|
|
|
|
if (should_inject_props) {
|
|
|
|
|
|
|
|
params.push(b.id('$$props'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (store_setup.length > 0) {
|
|
|
|
|
|
|
|
params.push(b.id('$$stores'));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const body = b.function_declaration(
|
|
|
|
|
|
|
|
b.id('$$body'),
|
|
|
|
|
|
|
|
params,
|
|
|
|
|
|
|
|
b.block([
|
|
|
|
|
|
|
|
b.var('$$unsuspend', b.call('$.suspend')),
|
|
|
|
|
|
|
|
b.var('$$active', b.id('$.active_effect')),
|
|
|
|
|
|
|
|
b.try_catch(
|
|
|
|
|
|
|
|
b.block([
|
|
|
|
|
|
|
|
...component_block.body,
|
|
|
|
|
|
|
|
b.if(b.call('$.aborted'), b.return()),
|
|
|
|
|
|
|
|
.../** @type {ESTree.Statement[]} */ (template.body)
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
b.block([
|
|
|
|
|
|
|
|
b.if(
|
|
|
|
|
|
|
|
b.unary('!', b.call('$.aborted', b.id('$$active'))),
|
|
|
|
|
|
|
|
b.stmt(b.call('$.invoke_error_boundary', b.id('$$error'), b.id('$$active')))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
])
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
b.stmt(b.call('$$unsuspend'))
|
|
|
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
state.hoisted.push(body);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
component_block = b.block([
|
|
|
|
|
|
|
|
b.var('fragment', b.call('$.comment')),
|
|
|
|
|
|
|
|
b.var('node', b.call('$.first_child', b.id('fragment'))),
|
|
|
|
|
|
|
|
store_init,
|
|
|
|
|
|
|
|
b.stmt(b.call(body.id, b.id('node'), ...params.slice(1))),
|
|
|
|
|
|
|
|
b.stmt(b.call('$.append', b.id('$$anchor'), b.id('fragment')))
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
component_block.body.unshift(store_init);
|
|
|
|
|
|
|
|
component_block.body.push(.../** @type {ESTree.Statement[]} */ (template.body));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// trick esrap into including comments
|
|
|
|
// trick esrap into including comments
|
|
|
|
component_block.loc = instance.loc;
|
|
|
|
component_block.loc = instance.loc;
|
|
|
|
|
|
|
|
|
|
|
|