@udixio/theme 1.0.0-beta.12 → 1.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/config.service.d.ts +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/plugins/tailwind/main.d.ts +1 -1
- package/dist/theme.cjs.development.js +77 -460
- package/dist/theme.cjs.development.js.map +1 -1
- package/dist/theme.cjs.production.min.js +1 -1
- package/dist/theme.cjs.production.min.js.map +1 -1
- package/dist/theme.esm.js +77 -460
- package/dist/theme.esm.js.map +1 -1
- package/package.json +7 -3
- package/src/config/config.service.ts +20 -5
- package/src/main.ts +2 -2
- package/src/plugins/tailwind/main.ts +2 -2
package/package.json
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@udixio/theme",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.14",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "vigreux-joël",
|
|
6
|
-
"
|
|
7
|
-
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/theme.esm.js",
|
|
9
|
+
"require": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
8
12
|
"typings": "dist/index.d.ts",
|
|
9
13
|
"files": [
|
|
10
14
|
"dist",
|
|
@@ -4,6 +4,7 @@ import { resolve } from 'path';
|
|
|
4
4
|
import { defaultColors } from '../color';
|
|
5
5
|
import { VariantModel } from '../theme';
|
|
6
6
|
import { AppService } from '../app.service';
|
|
7
|
+
import { existsSync } from 'node:fs';
|
|
7
8
|
|
|
8
9
|
export function defineConfig(configObject: ConfigInterface): ConfigInterface {
|
|
9
10
|
if (!configObject || typeof configObject !== 'object') {
|
|
@@ -24,7 +25,7 @@ export class ConfigService {
|
|
|
24
25
|
this.appService = appService;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
public
|
|
28
|
+
public loadConfig(): void {
|
|
28
29
|
const { themeService, colorService, pluginService } = this.appService;
|
|
29
30
|
const {
|
|
30
31
|
sourceColor,
|
|
@@ -35,7 +36,7 @@ export class ConfigService {
|
|
|
35
36
|
colors,
|
|
36
37
|
useDefaultColors = true,
|
|
37
38
|
plugins,
|
|
38
|
-
} =
|
|
39
|
+
} = this.getConfig();
|
|
39
40
|
themeService.create({
|
|
40
41
|
contrastLevel: contrastLevel,
|
|
41
42
|
isDark: isDark,
|
|
@@ -65,9 +66,23 @@ export class ConfigService {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
private
|
|
69
|
-
const
|
|
70
|
-
const
|
|
69
|
+
private getConfig(): ConfigInterface {
|
|
70
|
+
const base = resolve(this.configPath);
|
|
71
|
+
const extensions = ['.js', '.ts', '.jms', '.jcs'];
|
|
72
|
+
let configImport = null;
|
|
73
|
+
|
|
74
|
+
for (const ext of extensions) {
|
|
75
|
+
const path = base + ext;
|
|
76
|
+
if (existsSync(path)) {
|
|
77
|
+
configImport = require(path);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!configImport) {
|
|
83
|
+
throw new Error('Configuration file not found');
|
|
84
|
+
}
|
|
85
|
+
|
|
71
86
|
const config: unknown = configImport.default;
|
|
72
87
|
return config as ConfigInterface;
|
|
73
88
|
}
|
package/src/main.ts
CHANGED
|
@@ -6,9 +6,9 @@ export function bootstrap(): AppService {
|
|
|
6
6
|
return AppContainer.resolve<AppService>('appService');
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export function bootstrapFromConfig(path?: string): AppService {
|
|
10
10
|
const configService = AppContainer.resolve<ConfigService>('configService');
|
|
11
11
|
if (path) configService.configPath = path;
|
|
12
|
-
|
|
12
|
+
configService.loadConfig();
|
|
13
13
|
return AppContainer.resolve<AppService>('appService');
|
|
14
14
|
}
|
|
@@ -8,8 +8,8 @@ export type Theme = {
|
|
|
8
8
|
plugins: Partial<PluginsConfig>;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
export const createTheme =
|
|
12
|
-
const app =
|
|
11
|
+
export const createTheme = (): Theme => {
|
|
12
|
+
const app = bootstrapFromConfig();
|
|
13
13
|
const plugin = app.pluginService.getPlugin(TailwindPlugin);
|
|
14
14
|
if (!plugin) {
|
|
15
15
|
throw new Error('Tailwind plugin not found');
|