Skip to content

Commit 579058a

Browse files
committed
rename
1 parent 0b019e7 commit 579058a

File tree

6 files changed

+14
-19
lines changed

6 files changed

+14
-19
lines changed

packages/svelte/src/compiler/phases/2-analyze/visitors/Identifier.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** @import { Expression, Identifier } from 'estree' */
22
/** @import { Context } from '../types' */
33
import is_reference from 'is-reference';
4-
import { should_proxy_or_freeze } from '../../3-transform/client/utils.js';
4+
import { should_proxy } from '../../3-transform/client/utils.js';
55
import * as e from '../../../errors.js';
66
import * as w from '../../../warnings.js';
77
import { is_rune } from '../../../../utils.js';
@@ -136,7 +136,7 @@ export function Identifier(node, context) {
136136
(binding.initial?.type === 'CallExpression' &&
137137
binding.initial.arguments.length === 1 &&
138138
binding.initial.arguments[0].type !== 'SpreadElement' &&
139-
!should_proxy_or_freeze(binding.initial.arguments[0], context.state.scope)))) ||
139+
!should_proxy(binding.initial.arguments[0], context.state.scope)))) ||
140140
binding.kind === 'raw_state' ||
141141
binding.kind === 'derived') &&
142142
// We're only concerned with reads here

packages/svelte/src/compiler/phases/3-transform/client/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export function is_prop_source(binding, state) {
238238
* @param {Expression} node
239239
* @param {Scope | null} scope
240240
*/
241-
export function should_proxy_or_freeze(node, scope) {
241+
export function should_proxy(node, scope) {
242242
if (
243243
!node ||
244244
node.type === 'Literal' ||
@@ -263,7 +263,7 @@ export function should_proxy_or_freeze(node, scope) {
263263
binding.initial.type !== 'ImportDeclaration' &&
264264
binding.initial.type !== 'EachBlock'
265265
) {
266-
return should_proxy_or_freeze(binding.initial, null);
266+
return should_proxy(binding.initial, null);
267267
}
268268
}
269269
return true;

packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as b from '../../../../utils/builders.js';
44
import { build_assignment_value } from '../../../../utils/ast.js';
55
import { is_ignored } from '../../../../state.js';
6-
import { build_proxy_reassignment, should_proxy_or_freeze } from '../utils.js';
6+
import { build_proxy_reassignment, should_proxy } from '../utils.js';
77
import { visit_assignment_expression } from '../../shared/assignments.js';
88

99
/**
@@ -37,7 +37,7 @@ export function build_assignment(operator, left, right, context) {
3737
context.visit(build_assignment_value(operator, left, right))
3838
);
3939

40-
if (should_proxy_or_freeze(value, context.state.scope)) {
40+
if (should_proxy(value, context.state.scope)) {
4141
transformed = true;
4242
value =
4343
private_state.kind === 'raw_state'
@@ -54,7 +54,7 @@ export function build_assignment(operator, left, right, context) {
5454
} else if (left.property.type === 'Identifier' && context.state.in_constructor) {
5555
const public_state = context.state.public_state.get(left.property.name);
5656

57-
if (public_state !== undefined && should_proxy_or_freeze(right, context.state.scope)) {
57+
if (public_state !== undefined && should_proxy(right, context.state.scope)) {
5858
const value = /** @type {Expression} */ (context.visit(right));
5959

6060
return b.assignment(
@@ -100,7 +100,7 @@ export function build_assignment(operator, left, right, context) {
100100
!is_primitive &&
101101
binding.kind !== 'prop' &&
102102
context.state.analysis.runes &&
103-
should_proxy_or_freeze(value, context.state.scope)
103+
should_proxy(value, context.state.scope)
104104
) {
105105
value = binding.kind === 'raw_state' ? value : build_proxy_reassignment(value, object.name);
106106
}

packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { dev, is_ignored } from '../../../../state.js';
55
import * as b from '../../../../utils/builders.js';
66
import { regex_invalid_identifier_chars } from '../../../patterns.js';
77
import { get_rune } from '../../../scope.js';
8-
import { build_proxy_reassignment, should_proxy_or_freeze } from '../utils.js';
8+
import { build_proxy_reassignment, should_proxy } from '../utils.js';
99

1010
/**
1111
* @param {ClassBody} node
@@ -114,7 +114,7 @@ export function ClassBody(node, context) {
114114
field.kind === 'state'
115115
? b.call(
116116
'$.source',
117-
should_proxy_or_freeze(init, context.state.scope) ? b.call('$.proxy', init) : init
117+
should_proxy(init, context.state.scope) ? b.call('$.proxy', init) : init
118118
)
119119
: field.kind === 'raw_state'
120120
? b.call('$.source', init)

packages/svelte/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@ import { extract_paths } from '../../../../utils/ast.js';
77
import * as b from '../../../../utils/builders.js';
88
import * as assert from '../../../../utils/assert.js';
99
import { get_rune } from '../../../scope.js';
10-
import {
11-
get_prop_source,
12-
is_prop_source,
13-
is_state_source,
14-
should_proxy_or_freeze
15-
} from '../utils.js';
10+
import { get_prop_source, is_prop_source, is_state_source, should_proxy } from '../utils.js';
1611
import { is_hoisted_function } from '../../utils.js';
1712

1813
/**
@@ -86,7 +81,7 @@ export function VariableDeclaration(node, context) {
8681
if (
8782
initial &&
8883
binding.kind === 'bindable_prop' &&
89-
should_proxy_or_freeze(initial, context.state.scope)
84+
should_proxy(initial, context.state.scope)
9085
) {
9186
initial = b.call('$.proxy', initial);
9287
}
@@ -128,7 +123,7 @@ export function VariableDeclaration(node, context) {
128123
const binding = /** @type {import('#compiler').Binding} */ (
129124
context.state.scope.get(id.name)
130125
);
131-
if (rune === '$state' && should_proxy_or_freeze(value, context.state.scope)) {
126+
if (rune === '$state' && should_proxy(value, context.state.scope)) {
132127
value = b.call('$.proxy', value);
133128
}
134129
if (is_state_source(binding, context.state)) {

packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/declarations.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** @import { BinaryOperator, Expression, Identifier } from 'estree' */
22
/** @import { ComponentContext, Context } from '../../types' */
3-
import { build_proxy_reassignment, is_state_source, should_proxy_or_freeze } from '../../utils.js';
3+
import { build_proxy_reassignment, is_state_source, should_proxy } from '../../utils.js';
44
import * as b from '../../../../../utils/builders.js';
55

66
/**

0 commit comments

Comments
 (0)