|
|
|
@ -42,11 +42,11 @@ export function Program(_, context) {
|
|
|
|
|
|
|
|
|
|
|
|
for (const [name, binding] of context.state.scope.declarations) {
|
|
|
|
for (const [name, binding] of context.state.scope.declarations) {
|
|
|
|
if (binding.kind === 'store_sub') {
|
|
|
|
if (binding.kind === 'store_sub') {
|
|
|
|
const store = /** @type {Expression} */ (context.visit(b.id(name.slice(1))));
|
|
|
|
const get_store = () => /** @type {Expression} */ (context.visit(b.id(name.slice(1))));
|
|
|
|
|
|
|
|
|
|
|
|
context.state.transform[name] = {
|
|
|
|
context.state.transform[name] = {
|
|
|
|
read: b.call,
|
|
|
|
read: b.call,
|
|
|
|
assign: (_, value) => b.call('$.store_set', store, value),
|
|
|
|
assign: (_, value) => b.call('$.store_set', get_store(), value),
|
|
|
|
mutate: (node, mutation) => {
|
|
|
|
mutate: (node, mutation) => {
|
|
|
|
// We need to untrack the store read, for consistency with Svelte 4
|
|
|
|
// We need to untrack the store read, for consistency with Svelte 4
|
|
|
|
const untracked = b.call('$.untrack', node);
|
|
|
|
const untracked = b.call('$.untrack', node);
|
|
|
|
@ -70,7 +70,7 @@ export function Program(_, context) {
|
|
|
|
|
|
|
|
|
|
|
|
return b.call(
|
|
|
|
return b.call(
|
|
|
|
'$.store_mutate',
|
|
|
|
'$.store_mutate',
|
|
|
|
store,
|
|
|
|
get_store(),
|
|
|
|
b.assignment(
|
|
|
|
b.assignment(
|
|
|
|
mutation.operator,
|
|
|
|
mutation.operator,
|
|
|
|
/** @type {MemberExpression} */ (
|
|
|
|
/** @type {MemberExpression} */ (
|
|
|
|
|