|
|
@ -171,19 +171,14 @@ export function VariableDeclaration(node, context) {
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
context.state.transform[id.name] = { read: get_value };
|
|
|
|
|
|
|
|
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
|
|
|
|
const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
|
|
|
|
const call = b.call('$.derived', expression);
|
|
|
|
let call = b.call('$.derived', expression);
|
|
|
|
return b.declarator(
|
|
|
|
|
|
|
|
id,
|
|
|
|
if (dev) {
|
|
|
|
dev
|
|
|
|
const label = `[$state ${declarator.id.type === 'ArrayPattern' ? 'iterable' : 'object'}]`;
|
|
|
|
? b.call(
|
|
|
|
call = b.call('$.tag', call, b.literal(label));
|
|
|
|
'$.tag',
|
|
|
|
}
|
|
|
|
call,
|
|
|
|
|
|
|
|
b.literal(
|
|
|
|
return b.declarator(id, call);
|
|
|
|
`[$state ${declarator.id.type === 'ArrayPattern' ? 'iterable' : 'object'}]`
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: call
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
...paths.map((path) => {
|
|
|
|
...paths.map((path) => {
|
|
|
|
const value = /** @type {Expression} */ (context.visit(path.expression));
|
|
|
|
const value = /** @type {Expression} */ (context.visit(path.expression));
|
|
|
@ -242,12 +237,15 @@ export function VariableDeclaration(node, context) {
|
|
|
|
in_derived: rune === '$derived'
|
|
|
|
in_derived: rune === '$derived'
|
|
|
|
})
|
|
|
|
})
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
let rhs = value;
|
|
|
|
let rhs = value;
|
|
|
|
|
|
|
|
|
|
|
|
if (rune !== '$derived' || init.arguments[0].type !== 'Identifier') {
|
|
|
|
if (rune !== '$derived' || init.arguments[0].type !== 'Identifier') {
|
|
|
|
const id = b.id(context.state.scope.generate('$$d'));
|
|
|
|
const id = b.id(context.state.scope.generate('$$d'));
|
|
|
|
rhs = b.call('$.get', id);
|
|
|
|
|
|
|
|
let call = b.call('$.derived', rune === '$derived' ? b.thunk(expression) : expression);
|
|
|
|
let call = b.call('$.derived', rune === '$derived' ? b.thunk(expression) : expression);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rhs = b.call('$.get', id);
|
|
|
|
|
|
|
|
|
|
|
|
if (is_async) {
|
|
|
|
if (is_async) {
|
|
|
|
const location = dev && !is_ignored(init, 'await_waterfall') && locate_node(init);
|
|
|
|
const location = dev && !is_ignored(init, 'await_waterfall') && locate_node(init);
|
|
|
|
call = b.call(
|
|
|
|
call = b.call(
|
|
|
@ -257,15 +255,12 @@ export function VariableDeclaration(node, context) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
call = b.call(b.await(b.call('$.save', call)));
|
|
|
|
call = b.call(b.await(b.call('$.save', call)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (dev) {
|
|
|
|
if (dev) {
|
|
|
|
call = b.call(
|
|
|
|
const label = `[$derived ${declarator.id.type === 'ArrayPattern' ? 'iterable' : 'object'}]`;
|
|
|
|
'$.tag',
|
|
|
|
call = b.call('$.tag', call, b.literal(label));
|
|
|
|
call,
|
|
|
|
|
|
|
|
b.literal(
|
|
|
|
|
|
|
|
`[$derived ${declarator.id.type === 'ArrayPattern' ? 'iterable' : 'object'}]`
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
declarations.push(b.declarator(id, call));
|
|
|
|
declarations.push(b.declarator(id, call));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|