File tree Expand file tree Collapse file tree 4 files changed +29
-73
lines changed
inspect-trace-reassignment Expand file tree Collapse file tree 4 files changed +29
-73
lines changed Original file line number Diff line number Diff line change @@ -192,3 +192,28 @@ if (typeof window !== 'undefined') {
192
192
}
193
193
194
194
export const fragments = /** @type {'html' | 'tree' } */ ( process . env . FRAGMENTS ) ?? 'html' ;
195
+
196
+ /**
197
+ * @param {any[] } logs
198
+ */
199
+ export function normalise_trace_logs ( logs ) {
200
+ let normalised = [ ] ;
201
+ for ( let i = 0 ; i < logs . length ; i ++ ) {
202
+ const log = logs [ i ] ;
203
+
204
+ if ( typeof log === 'string' && log . includes ( '%c' ) ) {
205
+ const split = log . split ( '%c' ) ;
206
+ console . log ( { split } ) ;
207
+ normalised . push ( {
208
+ log : ( split [ 0 ] . length !== 0 ? split [ 0 ] : split [ 1 ] ) . trim ( ) ,
209
+ highlighted : logs [ i + 1 ] === 'color: CornflowerBlue; font-weight: bold'
210
+ } ) ;
211
+ i ++ ;
212
+ } else if ( log instanceof Error ) {
213
+ continue ;
214
+ } else {
215
+ normalised . push ( { log } ) ;
216
+ }
217
+ }
218
+ return normalised ;
219
+ }
Original file line number Diff line number Diff line change 1
1
import { flushSync } from 'svelte' ;
2
2
import { test } from '../../test' ;
3
-
4
- /**
5
- * @param {any[] } logs
6
- */
7
- function normalise_trace_logs ( logs ) {
8
- let normalised = [ ] ;
9
- for ( let i = 0 ; i < logs . length ; i ++ ) {
10
- const log = logs [ i ] ;
11
-
12
- if ( typeof log === 'string' && log . includes ( '%c' ) ) {
13
- const split = log . split ( '%c' ) ;
14
- normalised . push ( {
15
- log : ( split [ 0 ] . length !== 0 ? split [ 0 ] : split [ 1 ] ) . trim ( ) ,
16
- highlighted : logs [ i + 1 ] === 'color: CornflowerBlue; font-weight: bold'
17
- } ) ;
18
- i ++ ;
19
- } else if ( log instanceof Error ) {
20
- continue ;
21
- } else {
22
- normalised . push ( { log } ) ;
23
- }
24
- }
25
- return normalised ;
26
- }
3
+ import { normalise_trace_logs } from '../../../helpers.js' ;
27
4
28
5
export default test ( {
29
6
compileOptions : {
Original file line number Diff line number Diff line change 1
1
import { flushSync } from 'svelte' ;
2
2
import { test } from '../../test' ;
3
-
4
- /**
5
- * @param {any[] } logs
6
- */
7
- function normalise_trace_logs ( logs ) {
8
- let normalised = [ ] ;
9
- for ( let i = 0 ; i < logs . length ; i ++ ) {
10
- const log = logs [ i ] ;
11
-
12
- if ( typeof log === 'string' && log . includes ( '%c' ) ) {
13
- const split = log . split ( '%c' ) ;
14
- normalised . push ( {
15
- log : ( split [ 0 ] . length !== 0 ? split [ 0 ] : split [ 1 ] ) . trim ( ) ,
16
- highlighted : logs [ i + 1 ] === 'color: CornflowerBlue; font-weight: bold'
17
- } ) ;
18
- i ++ ;
19
- } else if ( log instanceof Error ) {
20
- continue ;
21
- } else {
22
- normalised . push ( { log } ) ;
23
- }
24
- }
25
- return normalised ;
26
- }
3
+ import { normalise_trace_logs } from '../../../helpers.js' ;
27
4
28
5
export default test ( {
29
6
compileOptions : {
Original file line number Diff line number Diff line change 1
1
import { flushSync } from 'svelte' ;
2
2
import { test } from '../../test' ;
3
-
4
- /**
5
- * @param {any[] } logs
6
- */
7
- function normalise_trace_logs ( logs ) {
8
- let normalised = [ ] ;
9
- for ( let i = 0 ; i < logs . length ; i ++ ) {
10
- const log = logs [ i ] ;
11
-
12
- if ( typeof log === 'string' && log . includes ( '%c' ) ) {
13
- const split = log . split ( '%c' ) ;
14
- normalised . push ( {
15
- log : ( split [ 0 ] . length !== 0 ? split [ 0 ] : split [ 1 ] ) . trim ( ) ,
16
- highlighted : logs [ i + 1 ] === 'color: CornflowerBlue; font-weight: bold'
17
- } ) ;
18
- i ++ ;
19
- } else if ( log instanceof Error ) {
20
- continue ;
21
- } else {
22
- normalised . push ( { log } ) ;
23
- }
24
- }
25
- return normalised ;
26
- }
3
+ import { normalise_trace_logs } from '../../../helpers.js' ;
27
4
28
5
export default test ( {
29
6
compileOptions : {
@@ -35,7 +12,7 @@ export default test({
35
12
36
13
assert . deepEqual ( normalise_trace_logs ( logs ) , [
37
14
{ log : 'effect' , highlighted : false } ,
38
- { log : 'double — $derived' , highlighted : true } ,
15
+ { log : '$derived' , highlighted : true } ,
39
16
{ log : 0 } ,
40
17
{ log : 'count — $state' , highlighted : true } ,
41
18
{ log : 0 } ,
You can’t perform that action at this time.
0 commit comments