|
|
|
@ -1,5 +1,4 @@
|
|
|
|
|
/** @import { Location } from 'locate-character' */
|
|
|
|
|
/** @import { AssignmentExpression, AssignmentOperator, Expression, Identifier, Literal, MemberExpression, Pattern } from 'estree' */
|
|
|
|
|
/** @import { AssignmentExpression, AssignmentOperator, Expression, Identifier, Pattern } from 'estree' */
|
|
|
|
|
/** @import { AST } from '#compiler' */
|
|
|
|
|
/** @import { Context } from '../types.js' */
|
|
|
|
|
import * as b from '../../../../utils/builders.js';
|
|
|
|
@ -8,8 +7,8 @@ import {
|
|
|
|
|
get_attribute_expression,
|
|
|
|
|
is_event_attribute
|
|
|
|
|
} from '../../../../utils/ast.js';
|
|
|
|
|
import { dev, filename, is_ignored, locate_node, locator } from '../../../../state.js';
|
|
|
|
|
import { build_proxy_reassignment, should_proxy } from '../utils.js';
|
|
|
|
|
import { dev, is_ignored, locate_node } from '../../../../state.js';
|
|
|
|
|
import { should_proxy } from '../utils.js';
|
|
|
|
|
import { visit_assignment_expression } from '../../shared/assignments.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -65,21 +64,12 @@ function build_assignment(operator, left, right, context) {
|
|
|
|
|
context.visit(build_assignment_value(operator, left, right))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
const needs_proxy =
|
|
|
|
|
private_state.kind === 'state' &&
|
|
|
|
|
is_non_coercive_operator(operator) &&
|
|
|
|
|
should_proxy(value, context.state.scope)
|
|
|
|
|
) {
|
|
|
|
|
value = build_proxy_reassignment(value, b.member(b.this, private_state.id));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (context.state.in_constructor) {
|
|
|
|
|
// inside the constructor, we can assign to `this.#foo.v` rather than using `$.set`,
|
|
|
|
|
// since nothing is tracking the signal at this point
|
|
|
|
|
return b.assignment(operator, /** @type {Pattern} */ (context.visit(left)), value);
|
|
|
|
|
}
|
|
|
|
|
should_proxy(value, context.state.scope);
|
|
|
|
|
|
|
|
|
|
return b.call('$.set', left, value);
|
|
|
|
|
return b.call('$.set', left, value, needs_proxy && b.true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -113,20 +103,18 @@ function build_assignment(operator, left, right, context) {
|
|
|
|
|
context.visit(build_assignment_value(operator, left, right))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
|
return transform.assign(
|
|
|
|
|
object,
|
|
|
|
|
value,
|
|
|
|
|
!is_primitive &&
|
|
|
|
|
binding.kind !== 'prop' &&
|
|
|
|
|
binding.kind !== 'bindable_prop' &&
|
|
|
|
|
binding.kind !== 'raw_state' &&
|
|
|
|
|
binding.kind !== 'store_sub' &&
|
|
|
|
|
context.state.analysis.runes &&
|
|
|
|
|
should_proxy(right, context.state.scope) &&
|
|
|
|
|
is_non_coercive_operator(operator)
|
|
|
|
|
) {
|
|
|
|
|
value = build_proxy_reassignment(value, object);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return transform.assign(object, value);
|
|
|
|
|
binding.kind !== 'prop' &&
|
|
|
|
|
binding.kind !== 'bindable_prop' &&
|
|
|
|
|
binding.kind !== 'raw_state' &&
|
|
|
|
|
binding.kind !== 'store_sub' &&
|
|
|
|
|
context.state.analysis.runes &&
|
|
|
|
|
should_proxy(right, context.state.scope) &&
|
|
|
|
|
is_non_coercive_operator(operator)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mutation
|
|
|
|
|