missed a spot

pull/15820/head
Rich Harris 4 months ago
parent 4edebbcfb1
commit 1e0f423cd2

@ -163,7 +163,7 @@ export function client_component(analysis, options) {
}, },
events: new Set(), events: new Set(),
preserve_whitespace: options.preserveWhitespace, preserve_whitespace: options.preserveWhitespace,
class_analysis: null, class_transformer: null,
transform: {}, transform: {},
in_constructor: false, in_constructor: false,
instance_level_snippets: [], instance_level_snippets: [],
@ -672,7 +672,7 @@ export function client_module(analysis, options) {
scopes: analysis.module.scopes, scopes: analysis.module.scopes,
transform: {}, transform: {},
in_constructor: false, in_constructor: false,
class_analysis: null class_transformer: null
}; };
const module = /** @type {ESTree.Program} */ ( const module = /** @type {ESTree.Program} */ (

@ -15,7 +15,7 @@ import type { SourceLocation } from '#shared';
import type { ClassTransformer } from '../shared/types.js'; import type { ClassTransformer } from '../shared/types.js';
export interface ClientTransformState extends TransformState { export interface ClientTransformState extends TransformState {
readonly class_analysis: ClassTransformer<Context> | null; readonly class_transformer: ClassTransformer<Context> | null;
/** /**
* `true` if the current lexical scope belongs to a class constructor. this allows * `true` if the current lexical scope belongs to a class constructor. this allows

@ -17,7 +17,7 @@ import { validate_mutation } from './shared/utils.js';
* @param {Context} context * @param {Context} context
*/ */
export function AssignmentExpression(node, context) { export function AssignmentExpression(node, context) {
const stripped_node = context.state.class_analysis?.generate_assignment(node, context); const stripped_node = context.state.class_transformer?.generate_assignment(node, context);
if (stripped_node) { if (stripped_node) {
return stripped_node; return stripped_node;
} }
@ -61,7 +61,7 @@ function build_assignment(operator, left, right, context) {
left.type === 'MemberExpression' && left.type === 'MemberExpression' &&
left.property.type === 'PrivateIdentifier' left.property.type === 'PrivateIdentifier'
) { ) {
const private_state = context.state.class_analysis?.get_field(left.property.name, true); const private_state = context.state.class_transformer?.get_field(left.property.name, true);
if (private_state !== undefined) { if (private_state !== undefined) {
let value = /** @type {Expression} */ ( let value = /** @type {Expression} */ (

@ -9,7 +9,7 @@ import * as b from '#compiler/builders';
export function MemberExpression(node, context) { export function MemberExpression(node, context) {
// rewrite `this.#foo` as `this.#foo.v` inside a constructor // rewrite `this.#foo` as `this.#foo.v` inside a constructor
if (node.property.type === 'PrivateIdentifier') { if (node.property.type === 'PrivateIdentifier') {
const field = context.state.class_analysis?.get_field(node.property.name, true); const field = context.state.class_transformer?.get_field(node.property.name, true);
if (field) { if (field) {
return context.state.in_constructor && return context.state.in_constructor &&
(field.kind === '$state.raw' || field.kind === '$state') (field.kind === '$state.raw' || field.kind === '$state')

@ -15,7 +15,7 @@ export function UpdateExpression(node, context) {
argument.type === 'MemberExpression' && argument.type === 'MemberExpression' &&
argument.object.type === 'ThisExpression' && argument.object.type === 'ThisExpression' &&
argument.property.type === 'PrivateIdentifier' && argument.property.type === 'PrivateIdentifier' &&
context.state.class_analysis?.get_field(argument.property.name, true) context.state.class_transformer?.get_field(argument.property.name, true)
) { ) {
let fn = '$.update'; let fn = '$.update';
if (node.prefix) fn += '_pre'; if (node.prefix) fn += '_pre';

@ -99,7 +99,7 @@ export function server_component(analysis, options) {
template: /** @type {any} */ (null), template: /** @type {any} */ (null),
namespace: options.namespace, namespace: options.namespace,
preserve_whitespace: options.preserveWhitespace, preserve_whitespace: options.preserveWhitespace,
class_analysis: null, class_transformer: null,
skip_hydration_boundaries: false skip_hydration_boundaries: false
}; };
@ -395,7 +395,7 @@ export function server_module(analysis, options) {
// to be present for `javascript_visitors_legacy` and so is included in module // to be present for `javascript_visitors_legacy` and so is included in module
// transform state as well as component transform state // transform state as well as component transform state
legacy_reactive_statements: new Map(), legacy_reactive_statements: new Map(),
class_analysis: null class_transformer: null
}; };
const module = /** @type {Program} */ ( const module = /** @type {Program} */ (

@ -7,7 +7,7 @@ import type { ClassTransformer } from '../shared/types.js';
export interface ServerTransformState extends TransformState { export interface ServerTransformState extends TransformState {
/** The $: calls, which will be ordered in the end */ /** The $: calls, which will be ordered in the end */
readonly legacy_reactive_statements: Map<LabeledStatement, Statement>; readonly legacy_reactive_statements: Map<LabeledStatement, Statement>;
readonly class_analysis: ClassTransformer<Context> | null; readonly class_transformer: ClassTransformer<Context> | null;
} }
export interface ComponentServerTransformState extends ServerTransformState { export interface ComponentServerTransformState extends ServerTransformState {

@ -10,7 +10,7 @@ import { visit_assignment_expression } from '../../shared/assignments.js';
* @param {Context} context * @param {Context} context
*/ */
export function AssignmentExpression(node, context) { export function AssignmentExpression(node, context) {
const stripped_node = context.state.class_analysis?.generate_assignment(node, context); const stripped_node = context.state.class_transformer?.generate_assignment(node, context);
if (stripped_node) { if (stripped_node) {
return stripped_node; return stripped_node;
} }

@ -12,7 +12,7 @@ export function MemberExpression(node, context) {
node.object.type === 'ThisExpression' && node.object.type === 'ThisExpression' &&
node.property.type === 'PrivateIdentifier' node.property.type === 'PrivateIdentifier'
) { ) {
const field = context.state.class_analysis?.get_field(node.property.name, true, [ const field = context.state.class_transformer?.get_field(node.property.name, true, [
'$derived', '$derived',
'$derived.by' '$derived.by'
]); ]);

Loading…
Cancel
Save