@@ -4,7 +4,6 @@ import * as path from 'node:path'
4
4
import {
5
5
concatMap ,
6
6
defer ,
7
- firstValueFrom ,
8
7
from ,
9
8
merge ,
10
9
mergeMap ,
@@ -26,6 +25,11 @@ import { compileResource } from './compile-resource'
26
25
export function registerRccLiveExecution$ ( {
27
26
extensionUri,
28
27
} : RegisterRccLiveExecutionArgs ) {
28
+ const enabled$ = getLiveExecutionEnabledFromConfig$ ( {
29
+ tool : 'rcc' ,
30
+ resource : undefined ,
31
+ } )
32
+
29
33
const glob$ = getLiveExecutionGlobFromConfig$ ( {
30
34
tool : 'rcc' ,
31
35
resource : undefined ,
@@ -39,27 +43,21 @@ export function registerRccLiveExecution$({
39
43
40
44
const watcher$ = glob$ . pipe ( switchMap ( glob => getWatcher$ ( glob ) ) )
41
45
42
- return merge ( qrcFiles$ , watcher$ ) . pipe (
43
- concatMap (
44
- async qrcUri =>
45
- [
46
- await firstValueFrom (
47
- getLiveExecutionEnabledFromConfig$ ( {
48
- tool : 'rcc' ,
49
- resource : qrcUri ,
50
- } ) ,
51
- ) ,
52
- qrcUri ,
53
- ] as const ,
46
+ const onQrcFileChange$ = merge ( qrcFiles$ , watcher$ ) . pipe (
47
+ mergeMap ( qrcUri =>
48
+ registerResourcesLiveExecution$ ( { extensionUri, qrcUri } ) ,
54
49
) ,
55
- mergeMap ( ( [ enabled , qrcUri ] ) => {
50
+ )
51
+
52
+ return enabled$ . pipe (
53
+ switchMap ( enabled => {
56
54
if ( ! enabled )
57
55
return of ( {
58
56
kind : 'Success' ,
59
57
value : 'Live execution disabled' ,
60
58
} as const )
61
59
62
- return registerResourcesLiveExecution$ ( { extensionUri , qrcUri } )
60
+ return onQrcFileChange$
63
61
} ) ,
64
62
)
65
63
}
@@ -80,22 +78,7 @@ function registerResourcesLiveExecution$({
80
78
...result . value . map ( uri => getWatcher$ ( new RelativePattern ( uri , '*' ) ) ) ,
81
79
) . pipe (
82
80
startWith ( undefined ) , // Trigger compilation on resource file changes
83
- concatMap ( ( ) =>
84
- firstValueFrom (
85
- getLiveExecutionEnabledFromConfig$ ( {
86
- tool : 'rcc' ,
87
- resource : qrcUri ,
88
- } ) ,
89
- ) ,
90
- ) ,
91
- concatMap ( async enabled => {
92
- if ( ! enabled )
93
- return {
94
- kind : 'Success' ,
95
- value : 'Live execution disabled' ,
96
- } as const
97
- return compileResource ( { extensionUri } , qrcUri )
98
- } ) ,
81
+ concatMap ( async ( ) => compileResource ( { extensionUri } , qrcUri ) ) ,
99
82
)
100
83
} ) ,
101
84
)
0 commit comments