Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit 4d96e4a

Browse files
committed
fix(global and root build-in-helper): Remove optionals and make async functions only at the top level.
1 parent 1f92bc4 commit 4d96e4a

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

src/core/method/global-build-in-helper.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
11
import { buildIn, isDevelopment } from '../../_internal';
22

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]>;
55
const styleSheetQueue: [string, string?][] = [];
66
let isProcessing = false;
77

88
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]) => {
1111
styleSheetQueue.push(value);
1212
resolve(value);
1313
};
1414
});
1515
}
1616

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() {
2518
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);
2821
}
2922
isProcessing = false;
3023
}
3124

32-
export function globalBuildIn(): void {
25+
export async function globalBuildIn(): Promise<void> {
3326
if (typeof globalStyleSheetPromise === 'undefined') createGlobalStyleSheetPromise();
3427
if (!isProcessing && styleSheetQueue.length > 0) {
3528
isProcessing = true;

src/core/method/root-build-in-helper.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import { buildIn, isDevelopment } from '../../_internal';
22

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]>;
55

66
function createGlobalStyleSheetPromise() {
7-
globalStyleSheetPromise = new Promise<[string, string?]>((resolve) => {
7+
globalStyleSheetPromise = new Promise<[string, string]>(resolve => {
88
resolveGlobalStyleSheet = resolve;
99
});
1010
}
1111

1212
export async function rootBuildIn(): Promise<void> {
1313
if (typeof globalStyleSheetPromise === 'undefined') createGlobalStyleSheetPromise();
1414
const [styleSheet, option] = await globalStyleSheetPromise;
15-
if (!isDevelopment && styleSheet) {
16-
if (option) buildIn(styleSheet, option);
17-
else buildIn(styleSheet);
18-
}
15+
if (!isDevelopment && styleSheet) buildIn(styleSheet, option);
1916
createGlobalStyleSheetPromise();
2017
}
2118

0 commit comments

Comments
 (0)