|
|
@ -9,7 +9,6 @@ import { get_rune } from '../../../scope.js';
|
|
|
|
import { get_prop_source, is_prop_source, is_state_source, should_proxy } from '../utils.js';
|
|
|
|
import { get_prop_source, is_prop_source, is_state_source, should_proxy } from '../utils.js';
|
|
|
|
import { is_hoisted_function } from '../../utils.js';
|
|
|
|
import { is_hoisted_function } from '../../utils.js';
|
|
|
|
import { get_value } from './shared/declarations.js';
|
|
|
|
import { get_value } from './shared/declarations.js';
|
|
|
|
import { PROXY_REMOVE_PATH } from '#client/constants';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param {VariableDeclaration} node
|
|
|
|
* @param {VariableDeclaration} node
|
|
|
@ -90,12 +89,7 @@ export function VariableDeclaration(node, context) {
|
|
|
|
binding.kind === 'bindable_prop' &&
|
|
|
|
binding.kind === 'bindable_prop' &&
|
|
|
|
should_proxy(initial, context.state.scope)
|
|
|
|
should_proxy(initial, context.state.scope)
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
initial = b.call(
|
|
|
|
initial = b.call('$.proxy', initial, dev ? b.literal(id.name) : undefined);
|
|
|
|
'$.proxy',
|
|
|
|
|
|
|
|
initial,
|
|
|
|
|
|
|
|
dev ? b.literal(id.name) : undefined,
|
|
|
|
|
|
|
|
dev ? b.literal(PROXY_REMOVE_PATH) : undefined
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (is_prop_source(binding, context.state)) {
|
|
|
|
if (is_prop_source(binding, context.state)) {
|
|
|
@ -136,20 +130,19 @@ export function VariableDeclaration(node, context) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
const is_state = is_state_source(binding, context.state.analysis);
|
|
|
|
const is_state = is_state_source(binding, context.state.analysis);
|
|
|
|
const is_proxy = should_proxy(value, context.state.scope);
|
|
|
|
const is_proxy = should_proxy(value, context.state.scope);
|
|
|
|
|
|
|
|
|
|
|
|
if (rune === '$state' && is_proxy) {
|
|
|
|
if (rune === '$state' && is_proxy) {
|
|
|
|
value = b.call(
|
|
|
|
value = b.call('$.proxy', value, dev ? b.literal(id.name) : undefined);
|
|
|
|
'$.proxy',
|
|
|
|
|
|
|
|
value,
|
|
|
|
|
|
|
|
dev ? b.literal(id.name) : undefined,
|
|
|
|
|
|
|
|
dev ? b.literal(PROXY_REMOVE_PATH) : undefined
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (is_state) {
|
|
|
|
if (is_state) {
|
|
|
|
value = b.call('$.state', value);
|
|
|
|
value = b.call('$.state', value);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev) {
|
|
|
|
|
|
|
|
value = b.call('$.tag', value, b.literal(id.name));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dev && is_state) {
|
|
|
|
|
|
|
|
value = b.call('$.tag', value, b.literal(id.name));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
return value;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|