@@ -4,7 +4,6 @@ import * as path from 'node:path'
44import {
55 concatMap ,
66 defer ,
7- firstValueFrom ,
87 from ,
98 merge ,
109 mergeMap ,
@@ -26,6 +25,11 @@ import { compileResource } from './compile-resource'
2625export function registerRccLiveExecution$ ( {
2726 extensionUri,
2827} : RegisterRccLiveExecutionArgs ) {
28+ const enabled$ = getLiveExecutionEnabledFromConfig$ ( {
29+ tool : 'rcc' ,
30+ resource : undefined ,
31+ } )
32+
2933 const glob$ = getLiveExecutionGlobFromConfig$ ( {
3034 tool : 'rcc' ,
3135 resource : undefined ,
@@ -39,27 +43,21 @@ export function registerRccLiveExecution$({
3943
4044 const watcher$ = glob$ . pipe ( switchMap ( glob => getWatcher$ ( glob ) ) )
4145
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 } ) ,
5449 ) ,
55- mergeMap ( ( [ enabled , qrcUri ] ) => {
50+ )
51+
52+ return enabled$ . pipe (
53+ switchMap ( enabled => {
5654 if ( ! enabled )
5755 return of ( {
5856 kind : 'Success' ,
5957 value : 'Live execution disabled' ,
6058 } as const )
6159
62- return registerResourcesLiveExecution$ ( { extensionUri , qrcUri } )
60+ return onQrcFileChange$
6361 } ) ,
6462 )
6563}
@@ -80,22 +78,7 @@ function registerResourcesLiveExecution$({
8078 ...result . value . map ( uri => getWatcher$ ( new RelativePattern ( uri , '*' ) ) ) ,
8179 ) . pipe (
8280 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 ) ) ,
9982 )
10083 } ) ,
10184 )
0 commit comments