|
|
@ -103,11 +103,9 @@ function is_statement(node) {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {Array<Statement | Expression>} template
|
|
|
|
* @param {Array<Statement | Expression>} template
|
|
|
|
* @param {Identifier} out
|
|
|
|
|
|
|
|
* @param {AssignmentOperator | 'push'} operator
|
|
|
|
|
|
|
|
* @returns {Statement[]}
|
|
|
|
* @returns {Statement[]}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export function build_template(template, out = b.id('$$payload'), operator = 'push') {
|
|
|
|
export function build_template(template) {
|
|
|
|
/** @type {string[]} */
|
|
|
|
/** @type {string[]} */
|
|
|
|
let strings = [];
|
|
|
|
let strings = [];
|
|
|
|
|
|
|
|
|
|
|
@ -118,11 +116,10 @@ export function build_template(template, out = b.id('$$payload'), operator = 'pu
|
|
|
|
const statements = [];
|
|
|
|
const statements = [];
|
|
|
|
|
|
|
|
|
|
|
|
const flush = () => {
|
|
|
|
const flush = () => {
|
|
|
|
if (operator === 'push') {
|
|
|
|
|
|
|
|
statements.push(
|
|
|
|
statements.push(
|
|
|
|
b.stmt(
|
|
|
|
b.stmt(
|
|
|
|
b.call(
|
|
|
|
b.call(
|
|
|
|
b.member(out, b.id('push')),
|
|
|
|
b.id('$$payload.push'),
|
|
|
|
b.template(
|
|
|
|
b.template(
|
|
|
|
strings.map((cooked, i) => b.quasi(cooked, i === strings.length - 1)),
|
|
|
|
strings.map((cooked, i) => b.quasi(cooked, i === strings.length - 1)),
|
|
|
|
expressions
|
|
|
|
expressions
|
|
|
@ -130,20 +127,7 @@ export function build_template(template, out = b.id('$$payload'), operator = 'pu
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
statements.push(
|
|
|
|
|
|
|
|
b.stmt(
|
|
|
|
|
|
|
|
b.assignment(
|
|
|
|
|
|
|
|
operator,
|
|
|
|
|
|
|
|
out,
|
|
|
|
|
|
|
|
b.template(
|
|
|
|
|
|
|
|
strings.map((cooked, i) => b.quasi(cooked, i === strings.length - 1)),
|
|
|
|
|
|
|
|
expressions
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
strings = [];
|
|
|
|
strings = [];
|
|
|
|
expressions = [];
|
|
|
|
expressions = [];
|
|
|
|
};
|
|
|
|
};
|
|
|
|