@@ -67,13 +67,6 @@ export function proxy(value) {
67
67
/** Used in dev for $inspect.trace() */
68
68
var path = '' ;
69
69
70
- /** @param {string | symbol } prop */
71
- function to_trace_name ( prop ) {
72
- if ( typeof prop === 'symbol' ) return `${ path } [Symbol(${ prop . description ?? '' } )]` ;
73
- if ( regex_is_valid_identifier . test ( prop ) ) return `${ path } .${ prop } ` ;
74
- return / ^ \d + $ / . test ( prop ) ? `${ path } [${ prop } ]` : `${ path } ['${ prop } ']` ;
75
- }
76
-
77
70
/** @param {string } new_path */
78
71
function update_path ( new_path ) {
79
72
path = new_path ;
@@ -82,7 +75,7 @@ export function proxy(value) {
82
75
83
76
// rename all child sources and child proxies
84
77
for ( const [ prop , source ] of sources ) {
85
- var label = to_trace_name ( prop ) ;
78
+ var label = get_label ( path , prop ) ;
86
79
87
80
tag ( source , label ) ;
88
81
tag_proxy ( source . v , label ) ;
@@ -111,14 +104,14 @@ export function proxy(value) {
111
104
sources . set ( prop , s ) ;
112
105
113
106
if ( DEV && typeof prop === 'string' ) {
114
- tag ( s , to_trace_name ( prop ) ) ;
107
+ tag ( s , get_label ( path , prop ) ) ;
115
108
}
116
109
} else {
117
110
var p = with_parent ( ( ) => proxy ( descriptor . value ) ) ;
118
111
set ( s , p ) ;
119
112
120
113
if ( DEV ) {
121
- tag_proxy ( p , to_trace_name ( prop ) ) ;
114
+ tag_proxy ( p , get_label ( path , prop ) ) ;
122
115
}
123
116
}
124
117
@@ -135,7 +128,7 @@ export function proxy(value) {
135
128
update_version ( version ) ;
136
129
137
130
if ( DEV ) {
138
- tag ( s , to_trace_name ( prop ) ) ;
131
+ tag ( s , get_label ( path , prop ) ) ;
139
132
}
140
133
}
141
134
} else {
@@ -175,7 +168,7 @@ export function proxy(value) {
175
168
var s = source ( p , stack ) ;
176
169
177
170
if ( DEV ) {
178
- var label = to_trace_name ( prop ) ;
171
+ var label = get_label ( path , prop ) ;
179
172
tag ( s , label ) ;
180
173
tag_proxy ( p , label ) ;
181
174
}
@@ -235,7 +228,7 @@ export function proxy(value) {
235
228
var s = source ( p , stack ) ;
236
229
237
230
if ( DEV ) {
238
- var label = to_trace_name ( prop ) ;
231
+ var label = get_label ( path , prop ) ;
239
232
tag ( s , label ) ;
240
233
tag_proxy ( p , label ) ;
241
234
}
@@ -270,8 +263,11 @@ export function proxy(value) {
270
263
// else a later read of the property would result in a source being created with
271
264
// the value of the original item at that index.
272
265
other_s = with_parent ( ( ) => source ( UNINITIALIZED , stack ) ) ;
273
- other_s = DEV ? tag ( other_s , to_trace_name ( i ) ) : other_s ;
274
266
sources . set ( i + '' , other_s ) ;
267
+
268
+ if ( DEV ) {
269
+ tag ( other_s , get_label ( path , i ) ) ;
270
+ }
275
271
}
276
272
}
277
273
}
@@ -286,7 +282,7 @@ export function proxy(value) {
286
282
var p = with_parent ( ( ) => proxy ( value ) ) ;
287
283
288
284
if ( DEV ) {
289
- var label = to_trace_name ( prop ) ;
285
+ var label = get_label ( path , prop ) ;
290
286
tag ( s , label ) ;
291
287
tag_proxy ( p , label ) ;
292
288
}
@@ -300,7 +296,7 @@ export function proxy(value) {
300
296
p = with_parent ( ( ) => proxy ( value ) ) ;
301
297
302
298
if ( DEV ) {
303
- tag_proxy ( p , to_trace_name ( prop ) ) ;
299
+ tag_proxy ( p , get_label ( path , prop ) ) ;
304
300
}
305
301
306
302
set ( s , p ) ;
@@ -356,6 +352,16 @@ export function proxy(value) {
356
352
} ) ;
357
353
}
358
354
355
+ /**
356
+ * @param {string } path
357
+ * @param {string | symbol } prop
358
+ */
359
+ function get_label ( path , prop ) {
360
+ if ( typeof prop === 'symbol' ) return `${ path } [Symbol(${ prop . description ?? '' } )]` ;
361
+ if ( regex_is_valid_identifier . test ( prop ) ) return `${ path } .${ prop } ` ;
362
+ return / ^ \d + $ / . test ( prop ) ? `${ path } [${ prop } ]` : `${ path } ['${ prop } ']` ;
363
+ }
364
+
359
365
/**
360
366
* @param {Source<number> } signal
361
367
* @param {1 | -1 } [d]
0 commit comments