@@ -67,13 +67,6 @@ export function proxy(value) {
6767 /** Used in dev for $inspect.trace() */
6868 var path = '' ;
6969
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-
7770 /** @param {string } new_path */
7871 function update_path ( new_path ) {
7972 path = new_path ;
@@ -82,7 +75,7 @@ export function proxy(value) {
8275
8376 // rename all child sources and child proxies
8477 for ( const [ prop , source ] of sources ) {
85- var label = to_trace_name ( prop ) ;
78+ var label = get_label ( path , prop ) ;
8679
8780 tag ( source , label ) ;
8881 tag_proxy ( source . v , label ) ;
@@ -111,14 +104,14 @@ export function proxy(value) {
111104 sources . set ( prop , s ) ;
112105
113106 if ( DEV && typeof prop === 'string' ) {
114- tag ( s , to_trace_name ( prop ) ) ;
107+ tag ( s , get_label ( path , prop ) ) ;
115108 }
116109 } else {
117110 var p = with_parent ( ( ) => proxy ( descriptor . value ) ) ;
118111 set ( s , p ) ;
119112
120113 if ( DEV ) {
121- tag_proxy ( p , to_trace_name ( prop ) ) ;
114+ tag_proxy ( p , get_label ( path , prop ) ) ;
122115 }
123116 }
124117
@@ -135,7 +128,7 @@ export function proxy(value) {
135128 update_version ( version ) ;
136129
137130 if ( DEV ) {
138- tag ( s , to_trace_name ( prop ) ) ;
131+ tag ( s , get_label ( path , prop ) ) ;
139132 }
140133 }
141134 } else {
@@ -175,7 +168,7 @@ export function proxy(value) {
175168 var s = source ( p , stack ) ;
176169
177170 if ( DEV ) {
178- var label = to_trace_name ( prop ) ;
171+ var label = get_label ( path , prop ) ;
179172 tag ( s , label ) ;
180173 tag_proxy ( p , label ) ;
181174 }
@@ -235,7 +228,7 @@ export function proxy(value) {
235228 var s = source ( p , stack ) ;
236229
237230 if ( DEV ) {
238- var label = to_trace_name ( prop ) ;
231+ var label = get_label ( path , prop ) ;
239232 tag ( s , label ) ;
240233 tag_proxy ( p , label ) ;
241234 }
@@ -270,8 +263,11 @@ export function proxy(value) {
270263 // else a later read of the property would result in a source being created with
271264 // the value of the original item at that index.
272265 other_s = with_parent ( ( ) => source ( UNINITIALIZED , stack ) ) ;
273- other_s = DEV ? tag ( other_s , to_trace_name ( i ) ) : other_s ;
274266 sources . set ( i + '' , other_s ) ;
267+
268+ if ( DEV ) {
269+ tag ( other_s , get_label ( path , i ) ) ;
270+ }
275271 }
276272 }
277273 }
@@ -286,7 +282,7 @@ export function proxy(value) {
286282 var p = with_parent ( ( ) => proxy ( value ) ) ;
287283
288284 if ( DEV ) {
289- var label = to_trace_name ( prop ) ;
285+ var label = get_label ( path , prop ) ;
290286 tag ( s , label ) ;
291287 tag_proxy ( p , label ) ;
292288 }
@@ -300,7 +296,7 @@ export function proxy(value) {
300296 p = with_parent ( ( ) => proxy ( value ) ) ;
301297
302298 if ( DEV ) {
303- tag_proxy ( p , to_trace_name ( prop ) ) ;
299+ tag_proxy ( p , get_label ( path , prop ) ) ;
304300 }
305301
306302 set ( s , p ) ;
@@ -356,6 +352,16 @@ export function proxy(value) {
356352 } ) ;
357353}
358354
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+
359365/**
360366 * @param {Source<number> } signal
361367 * @param {1 | -1 } [d]
0 commit comments