-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathbootstrap.ts
43 lines (36 loc) · 1.37 KB
/
bootstrap.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import type { Generic, LoaderCallback, RegisterOptions } from 'adopted-style-sheets';
import { register as coreRegister } from 'adopted-style-sheets';
import { setDevMode } from '../schema';
import { setCustomTagNames } from './component-names';
import { initializeI18n } from './i18n';
type Environment = 'development' | 'production';
type KoliBriOptions = RegisterOptions & {
/**
* The environment in which the application is running.
*/
environment?: Environment;
/**
* This option allows you to transform the component tag names.
*/
transformTagName?: (tagName: string) => string;
};
let initialized = false;
export const bootstrap = async (
themes:
| Generic.Theming.RegisterPatch<string, string, string>
| Generic.Theming.RegisterPatch<string, string, string>[]
| Set<Generic.Theming.RegisterPatch<string, string, string>>,
loaders: LoaderCallback | LoaderCallback[] | Set<LoaderCallback>,
options?: KoliBriOptions,
): Promise<void[]> => {
setDevMode(options?.environment === 'development');
initializeI18n(options?.translation?.name ?? 'de', options?.translations);
if (options?.transformTagName) {
setCustomTagNames(options?.transformTagName);
}
const coreRegisterReturnValue = await coreRegister(themes, loaders, options);
initialized = true;
return coreRegisterReturnValue;
};
export const register = bootstrap;
export const isInitialized = () => initialized;