|
|
@ -959,6 +959,23 @@ function serialize_bind_this(bind_this, context, node) {
|
|
|
|
return b.call('$.bind_this', ...args);
|
|
|
|
return b.call('$.bind_this', ...args);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param {import('../types.js').SourceLocation[]} locations
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
function serialize_locations(locations) {
|
|
|
|
|
|
|
|
return b.array(
|
|
|
|
|
|
|
|
locations.map((loc) => {
|
|
|
|
|
|
|
|
const expression = b.array([b.literal(loc[0]), b.literal(loc[1])]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (loc.length === 3) {
|
|
|
|
|
|
|
|
expression.elements.push(serialize_locations(loc[2]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return expression;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Creates a new block which looks roughly like this:
|
|
|
|
* Creates a new block which looks roughly like this:
|
|
|
|
* ```js
|
|
|
|
* ```js
|
|
|
@ -1014,6 +1031,7 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
update: [],
|
|
|
|
update: [],
|
|
|
|
after_update: [],
|
|
|
|
after_update: [],
|
|
|
|
template: [],
|
|
|
|
template: [],
|
|
|
|
|
|
|
|
locations: [],
|
|
|
|
metadata: {
|
|
|
|
metadata: {
|
|
|
|
context: {
|
|
|
|
context: {
|
|
|
|
template_needs_import_node: false,
|
|
|
|
template_needs_import_node: false,
|
|
|
@ -1028,6 +1046,24 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
context.visit(node, state);
|
|
|
|
context.visit(node, state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @param {import('estree').Identifier} template_name
|
|
|
|
|
|
|
|
* @param {import('estree').Expression[]} args
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
const add_template = (template_name, args) => {
|
|
|
|
|
|
|
|
let call = b.call(get_template_function(namespace, state), ...args);
|
|
|
|
|
|
|
|
if (context.state.options.dev) {
|
|
|
|
|
|
|
|
call = b.call(
|
|
|
|
|
|
|
|
'$.add_locations',
|
|
|
|
|
|
|
|
call,
|
|
|
|
|
|
|
|
b.member(b.id(context.state.analysis.name), b.id('filename')),
|
|
|
|
|
|
|
|
serialize_locations(state.locations)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context.state.hoisted.push(b.var(template_name, call));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (is_single_element) {
|
|
|
|
if (is_single_element) {
|
|
|
|
const element = /** @type {import('#compiler').RegularElement} */ (trimmed[0]);
|
|
|
|
const element = /** @type {import('#compiler').RegularElement} */ (trimmed[0]);
|
|
|
|
|
|
|
|
|
|
|
@ -1045,9 +1081,7 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
args.push(b.literal(TEMPLATE_USE_IMPORT_NODE));
|
|
|
|
args.push(b.literal(TEMPLATE_USE_IMPORT_NODE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
context.state.hoisted.push(
|
|
|
|
add_template(template_name, args);
|
|
|
|
b.var(template_name, b.call(get_template_function(namespace, state), ...args))
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
body.push(b.var(id, b.call(template_name)), ...state.before_init, ...state.init);
|
|
|
|
body.push(b.var(id, b.call(template_name)), ...state.before_init, ...state.init);
|
|
|
|
close = b.stmt(b.call('$.append', b.id('$$anchor'), id));
|
|
|
|
close = b.stmt(b.call('$.append', b.id('$$anchor'), id));
|
|
|
@ -1091,16 +1125,10 @@ function create_block(parent, name, nodes, context) {
|
|
|
|
flags |= TEMPLATE_USE_IMPORT_NODE;
|
|
|
|
flags |= TEMPLATE_USE_IMPORT_NODE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
state.hoisted.push(
|
|
|
|
add_template(template_name, [
|
|
|
|
b.var(
|
|
|
|
b.template([b.quasi(state.template.join(''), true)], []),
|
|
|
|
template_name,
|
|
|
|
b.literal(flags)
|
|
|
|
b.call(
|
|
|
|
]);
|
|
|
|
get_template_function(namespace, state),
|
|
|
|
|
|
|
|
b.template([b.quasi(state.template.join(''), true)], []),
|
|
|
|
|
|
|
|
b.literal(flags)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
body.push(b.var(id, b.call(template_name)));
|
|
|
|
body.push(b.var(id, b.call(template_name)));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1809,6 +1837,18 @@ export const template_visitors = {
|
|
|
|
state.init.push(b.stmt(b.call('$.transition', ...args)));
|
|
|
|
state.init.push(b.stmt(b.call('$.transition', ...args)));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
RegularElement(node, context) {
|
|
|
|
RegularElement(node, context) {
|
|
|
|
|
|
|
|
/** @type {import('../types.js').SourceLocation} */
|
|
|
|
|
|
|
|
let location = [-1, -1];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (context.state.options.dev) {
|
|
|
|
|
|
|
|
const loc = context.state.source_locator(node.start);
|
|
|
|
|
|
|
|
if (loc) {
|
|
|
|
|
|
|
|
location[0] = loc.line;
|
|
|
|
|
|
|
|
location[1] = loc.column;
|
|
|
|
|
|
|
|
context.state.locations.push(location);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (node.name === 'noscript') {
|
|
|
|
if (node.name === 'noscript') {
|
|
|
|
context.state.template.push('<!>');
|
|
|
|
context.state.template.push('<!>');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -1993,10 +2033,14 @@ export const template_visitors = {
|
|
|
|
|
|
|
|
|
|
|
|
context.state.template.push('>');
|
|
|
|
context.state.template.push('>');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {import('../types.js').SourceLocation[]} */
|
|
|
|
|
|
|
|
const child_locations = [];
|
|
|
|
|
|
|
|
|
|
|
|
/** @type {import('../types').ComponentClientTransformState} */
|
|
|
|
/** @type {import('../types').ComponentClientTransformState} */
|
|
|
|
const state = {
|
|
|
|
const state = {
|
|
|
|
...context.state,
|
|
|
|
...context.state,
|
|
|
|
metadata: child_metadata,
|
|
|
|
metadata: child_metadata,
|
|
|
|
|
|
|
|
locations: child_locations,
|
|
|
|
scope: /** @type {import('../../../scope').Scope} */ (
|
|
|
|
scope: /** @type {import('../../../scope').Scope} */ (
|
|
|
|
context.state.scopes.get(node.fragment)
|
|
|
|
context.state.scopes.get(node.fragment)
|
|
|
|
),
|
|
|
|
),
|
|
|
@ -2032,6 +2076,11 @@ export const template_visitors = {
|
|
|
|
{ ...context, state }
|
|
|
|
{ ...context, state }
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (child_locations.length > 0) {
|
|
|
|
|
|
|
|
// @ts-expect-error
|
|
|
|
|
|
|
|
location.push(child_locations);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!VoidElements.includes(node.name)) {
|
|
|
|
if (!VoidElements.includes(node.name)) {
|
|
|
|
context.state.template.push(`</${node.name}>`);
|
|
|
|
context.state.template.push(`</${node.name}>`);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2131,19 +2180,21 @@ export const template_visitors = {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const args = [
|
|
|
|
const location = context.state.options.dev && context.state.source_locator(node.start);
|
|
|
|
context.state.node,
|
|
|
|
|
|
|
|
get_tag,
|
|
|
|
context.state.init.push(
|
|
|
|
node.metadata.svg || node.metadata.mathml ? b.true : b.false
|
|
|
|
b.stmt(
|
|
|
|
];
|
|
|
|
b.call(
|
|
|
|
if (inner.length > 0) {
|
|
|
|
'$.element',
|
|
|
|
args.push(b.arrow([element_id, b.id('$$anchor')], b.block(inner)));
|
|
|
|
context.state.node,
|
|
|
|
}
|
|
|
|
get_tag,
|
|
|
|
if (dynamic_namespace) {
|
|
|
|
node.metadata.svg || node.metadata.mathml ? b.true : b.false,
|
|
|
|
if (inner.length === 0) args.push(b.id('undefined'));
|
|
|
|
inner.length > 0 && b.arrow([element_id, b.id('$$anchor')], b.block(inner)),
|
|
|
|
args.push(b.thunk(serialize_attribute_value(dynamic_namespace, context)[1]));
|
|
|
|
dynamic_namespace && b.thunk(serialize_attribute_value(dynamic_namespace, context)[1]),
|
|
|
|
}
|
|
|
|
location && b.array([b.literal(location.line), b.literal(location.column)])
|
|
|
|
context.state.init.push(b.stmt(b.call('$.element', ...args)));
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
EachBlock(node, context) {
|
|
|
|
EachBlock(node, context) {
|
|
|
|
const each_node_meta = node.metadata;
|
|
|
|
const each_node_meta = node.metadata;
|
|
|
|