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