@@ -2,36 +2,18 @@ import { buildIn, isDevelopment } from '../../_internal';
22
33let resolveGlobalStyleSheet : ( value : [ string , string ?] ) => void ;
44let globalStyleSheetPromise : Promise < [ string , string ?] > ;
5- const styleSheetQueue : [ string , string ?] [ ] = [ ] ;
6- let isProcessing = false ;
75
86function createGlobalStyleSheetPromise ( ) {
97 globalStyleSheetPromise = new Promise < [ string , string ?] > ( resolve => {
10- resolveGlobalStyleSheet = ( value : [ string , string ?] ) => {
11- styleSheetQueue . push ( value ) ;
12- resolve ( value ) ;
13- } ;
8+ resolveGlobalStyleSheet = resolve ;
149 } ) ;
1510}
1611
17- async function executeBuildIn ( styleSheet : string , option ?: string ) : Promise < void > {
18- if ( ! isDevelopment && styleSheet ) buildIn ( styleSheet , option ) ;
19- }
20-
21- async function processStyleSheets ( ) {
22- while ( styleSheetQueue . length > 0 ) {
23- const [ styleSheet , option ] = styleSheetQueue . shift ( ) as [ string , string ?] ;
24- await executeBuildIn ( styleSheet , option ) ;
25- }
26- isProcessing = false ;
27- }
28-
29- export function globalBuildIn ( ) : void {
12+ export async function globalBuildIn ( ) : Promise < void > {
3013 if ( typeof globalStyleSheetPromise === 'undefined' ) createGlobalStyleSheetPromise ( ) ;
31- if ( ! isProcessing && styleSheetQueue . length > 0 ) {
32- isProcessing = true ;
33- processStyleSheets ( ) ;
34- }
14+ const [ styleSheet , option ] = await globalStyleSheetPromise ;
15+ if ( ! isDevelopment && styleSheet ) buildIn ( styleSheet , option ) ;
16+ createGlobalStyleSheetPromise ( ) ;
3517}
3618
3719export { resolveGlobalStyleSheet , globalStyleSheetPromise , createGlobalStyleSheetPromise } ;
0 commit comments