Skip to content

Commit d4ac394

Browse files
committed
tag_source -> tag, since it applies to deriveds as well
1 parent 245283d commit d4ac394

File tree

6 files changed

+24
-37
lines changed

6 files changed

+24
-37
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ export function CallExpression(node, context) {
5959
source_tag = `${constructor?.id?.name ?? '[class]'}.${property}`;
6060
}
6161
const call = b.call('$.state', value);
62-
return dev
63-
? b.call('$.tag_source', call, b.literal(/** @type {string} */ (source_tag)))
64-
: call;
62+
return dev ? b.call('$.tag', call, b.literal(/** @type {string} */ (source_tag))) : call;
6563
}
6664

6765
case '$derived':
@@ -88,9 +86,7 @@ export function CallExpression(node, context) {
8886
source_tag = `${constructor?.id?.name ?? '[class]'}.${property}`;
8987
}
9088
const call = b.call('$.derived', fn);
91-
return dev
92-
? b.call('$.tag_source', call, b.literal(/** @type {string} */ (source_tag)))
93-
: call;
89+
return dev ? b.call('$.tag', call, b.literal(/** @type {string} */ (source_tag))) : call;
9490
}
9591

9692
case '$state.snapshot':

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export function ClassBody(node, context) {
8080
field.key,
8181
dev
8282
? b.call(
83-
'$.tag_source',
83+
'$.tag',
8484
call,
8585
b.literal(
8686
`${/** @type {ClassDeclaration | ClassExpression} */ (context.path.at(-1))?.id?.name ?? '[class]'}.${field.key.name}`

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function VariableDeclaration(node, context) {
148148
value = b.call('$.state', value);
149149
}
150150
if (dev && is_state) {
151-
value = b.call('$.tag_source', value, b.literal(id.name));
151+
value = b.call('$.tag', value, b.literal(id.name));
152152
}
153153
return value;
154154
};
@@ -173,7 +173,7 @@ export function VariableDeclaration(node, context) {
173173
const call = b.call('$.derived', expression);
174174
return b.declarator(
175175
id,
176-
dev ? b.call('$.tag_source', call, b.literal('[$state iterable]')) : call
176+
dev ? b.call('$.tag', call, b.literal('[$state iterable]')) : call
177177
);
178178
}),
179179
...paths.map((path) => {
@@ -200,7 +200,7 @@ export function VariableDeclaration(node, context) {
200200
declarations.push(
201201
b.declarator(
202202
declarator.id,
203-
dev ? b.call('$.tag_source', call, b.literal(declarator.id.name)) : call
203+
dev ? b.call('$.tag', call, b.literal(declarator.id.name)) : call
204204
)
205205
);
206206
} else {
@@ -216,10 +216,7 @@ export function VariableDeclaration(node, context) {
216216
if (rune === '$derived') expression = b.thunk(expression);
217217
const call = b.call('$.derived', expression);
218218
declarations.push(
219-
b.declarator(
220-
id,
221-
dev ? b.call('$.tag_source', call, b.literal('[$derived iterable]')) : call
222-
)
219+
b.declarator(id, dev ? b.call('$.tag', call, b.literal('[$derived iterable]')) : call)
223220
);
224221
}
225222

@@ -232,10 +229,7 @@ export function VariableDeclaration(node, context) {
232229
const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
233230
const call = b.call('$.derived', expression);
234231
declarations.push(
235-
b.declarator(
236-
id,
237-
dev ? b.call('$.tag_source', call, b.literal('[$derived iterable]')) : call
238-
)
232+
b.declarator(id, dev ? b.call('$.tag', call, b.literal('[$derived iterable]')) : call)
239233
);
240234
}
241235

@@ -246,11 +240,7 @@ export function VariableDeclaration(node, context) {
246240
b.declarator(
247241
path.node,
248242
dev
249-
? b.call(
250-
'$.tag_source',
251-
call,
252-
b.literal(/** @type {Identifier} */ (path.node).name)
253-
)
243+
? b.call('$.tag', call, b.literal(/** @type {Identifier} */ (path.node).name))
254244
: call
255245
)
256246
);

packages/svelte/src/internal/client/dev/tracing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function log_entry(signal, entry) {
4646
const { trace_name: name } = signal;
4747
const style = dirty
4848
? 'color: CornflowerBlue; font-weight: bold'
49-
: 'color: grey; font-weight: bold';
49+
: 'color: grey; font-weight: normal';
5050
// eslint-disable-next-line no-console
5151
console.groupCollapsed(
5252
typeof name === 'string' ? `%c${name}${type}` : `%c${type}`,
@@ -185,7 +185,7 @@ export function get_stack(label) {
185185
* @param {Value} source
186186
* @param {string} name
187187
*/
188-
export function tag_source(source, name) {
188+
export function tag(source, name) {
189189
source.trace_name = name;
190190
return source;
191191
}

packages/svelte/src/internal/client/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export { add_locations } from './dev/elements.js';
77
export { hmr } from './dev/hmr.js';
88
export { create_ownership_validator } from './dev/ownership.js';
99
export { check_target, legacy_api } from './dev/legacy.js';
10-
export { trace, tag_source } from './dev/tracing.js';
10+
export { trace, tag } from './dev/tracing.js';
1111
export { inspect } from './dev/inspect.js';
1212
export { validate_snippet_args } from './dev/validation.js';
1313
export { await_block as await } from './dom/blocks/await.js';

packages/svelte/src/internal/client/proxy.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '#client/constants';
1919
import { UNINITIALIZED } from '../../constants.js';
2020
import * as e from './errors.js';
21-
import { get_stack, tag_source } from './dev/tracing.js';
21+
import { get_stack, tag } from './dev/tracing.js';
2222
import { tracing_mode_flag } from '../flags/index.js';
2323

2424
/**
@@ -55,7 +55,8 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
5555
/** @type {Map<any, Source<any>>} */
5656
var sources = new Map();
5757
var is_proxied_array = is_array(value);
58-
var version = tag_source(source(0), `${path} version`);
58+
// var version = tag(source(0), `${path} version`);
59+
var version = source(0);
5960

6061
var stack = DEV && tracing_mode_flag ? get_stack('CreatedAt') : null;
6162
var reaction = active_reaction;
@@ -89,7 +90,7 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
8990
// We need to create the length source eagerly to ensure that
9091
// mutations to the array are properly synced with our proxy
9192
const length_source = source(/** @type {any[]} */ (value).length, stack);
92-
sources.set('length', DEV ? tag_source(length_source, to_trace_name('length')) : length_source);
93+
sources.set('length', DEV ? tag(length_source, to_trace_name('length')) : length_source);
9394
}
9495

9596
return new Proxy(/** @type {any} */ (value), {
@@ -111,7 +112,7 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
111112

112113
if (s === undefined) {
113114
s = with_parent(() => source(descriptor.value, stack));
114-
s = DEV && typeof prop === 'string' ? tag_source(s, to_trace_name(prop)) : s;
115+
s = DEV && typeof prop === 'string' ? tag(s, to_trace_name(prop)) : s;
115116
sources.set(prop, s);
116117
} else {
117118
set(
@@ -129,7 +130,7 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
129130
if (s === undefined) {
130131
if (prop in target) {
131132
const s = with_parent(() => source(UNINITIALIZED, stack));
132-
sources.set(prop, DEV ? tag_source(s, to_trace_name(prop)) : s);
133+
sources.set(prop, DEV ? tag(s, to_trace_name(prop)) : s);
133134
update_version(version);
134135
}
135136
} else {
@@ -166,7 +167,7 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
166167
s = with_parent(() =>
167168
source(proxy(exists ? target[prop] : UNINITIALIZED, to_trace_name(prop)), stack)
168169
);
169-
s = DEV ? tag_source(s, to_trace_name(prop)) : s;
170+
s = DEV ? tag(s, to_trace_name(prop)) : s;
170171
sources.set(prop, s);
171172
}
172173

@@ -217,7 +218,7 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
217218
s = with_parent(() =>
218219
source(has ? proxy(target[prop], to_trace_name(prop)) : UNINITIALIZED, stack)
219220
);
220-
s = DEV ? tag_source(s, to_trace_name(prop)) : s;
221+
s = DEV ? tag(s, to_trace_name(prop)) : s;
221222
sources.set(prop, s);
222223
}
223224

@@ -233,10 +234,10 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
233234
set(target, prop, value, receiver) {
234235
if (DEV && prop === PROXY_PATH_SYMBOL) {
235236
path = value;
236-
tag_source(version, `${path} version`);
237+
// tag(version, `${path} version`);
237238
// rename all child sources and child proxies
238239
for (const [prop, source] of sources) {
239-
tag_source(source, to_trace_name(prop));
240+
tag(source, to_trace_name(prop));
240241
if (typeof source.v === 'object' && source.v !== null && PROXY_PATH_SYMBOL in source.v) {
241242
source.v[PROXY_PATH_SYMBOL] = to_trace_name(prop);
242243
}
@@ -256,7 +257,7 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
256257
// else a later read of the property would result in a source being created with
257258
// the value of the original item at that index.
258259
other_s = with_parent(() => source(UNINITIALIZED, stack));
259-
other_s = DEV ? tag_source(other_s, to_trace_name(i)) : other_s;
260+
other_s = DEV ? tag(other_s, to_trace_name(i)) : other_s;
260261
sources.set(i + '', other_s);
261262
}
262263
}
@@ -269,7 +270,7 @@ export function proxy(value, path, path_preservation = PROXY_PRESERVE_PATH) {
269270
if (s === undefined) {
270271
if (!has || get_descriptor(target, prop)?.writable) {
271272
s = with_parent(() => source(undefined, stack));
272-
s = DEV ? tag_source(s, to_trace_name(prop)) : s;
273+
s = DEV ? tag(s, to_trace_name(prop)) : s;
273274
set(
274275
s,
275276
with_parent(() => proxy(value, to_trace_name(prop), PROXY_CHANGE_PATH))

0 commit comments

Comments
 (0)