@udixio/theme 1.0.0-beta.3 → 1.0.0-beta.31

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.
Files changed (97) hide show
  1. package/dist/app.container.d.ts +5 -0
  2. package/dist/app.module.d.ts +2 -2
  3. package/dist/app.service.d.ts +9 -3
  4. package/dist/color/color.interface.d.ts +1 -2
  5. package/dist/color/color.module.d.ts +2 -2
  6. package/dist/color/entities/color.entity.d.ts +6 -1
  7. package/dist/color/entities/index.d.ts +1 -0
  8. package/dist/color/index.d.ts +5 -0
  9. package/dist/color/models/default-color.model.d.ts +2 -3
  10. package/dist/color/models/index.d.ts +1 -0
  11. package/dist/color/services/color-manager.service.d.ts +18 -0
  12. package/dist/color/services/color.service.d.ts +21 -0
  13. package/dist/color/services/index.d.ts +2 -0
  14. package/dist/config/config.interface.d.ts +13 -0
  15. package/dist/config/config.module.d.ts +2 -0
  16. package/dist/config/config.service.d.ts +12 -0
  17. package/dist/config/index.d.ts +3 -0
  18. package/dist/index.d.ts +11 -0
  19. package/dist/main.d.ts +6 -1
  20. package/dist/material-color-utilities/index.d.ts +1 -0
  21. package/dist/plugin/index.d.ts +3 -0
  22. package/dist/plugin/plugin.module.d.ts +2 -0
  23. package/dist/plugin/plugin.service.d.ts +8 -0
  24. package/dist/plugin/pluginAbstract.d.ts +18 -0
  25. package/dist/plugins/font/font.plugin.d.ts +49 -0
  26. package/dist/plugins/font/index.d.ts +1 -0
  27. package/dist/plugins/tailwind/index.d.ts +3 -0
  28. package/dist/plugins/tailwind/main.d.ts +13 -0
  29. package/dist/plugins/tailwind/plugins-tailwind/font.d.ts +5 -0
  30. package/dist/plugins/tailwind/plugins-tailwind/index.d.ts +2 -0
  31. package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +4 -0
  32. package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +10 -0
  33. package/dist/plugins/tailwind/tailwind.plugin.d.ts +18 -0
  34. package/dist/theme/entities/index.d.ts +2 -0
  35. package/dist/theme/entities/variant.entity.d.ts +2 -1
  36. package/dist/theme/index.d.ts +4 -0
  37. package/dist/theme/models/index.d.ts +1 -0
  38. package/dist/theme/services/index.d.ts +3 -0
  39. package/dist/theme/services/scheme.service.d.ts +7 -2
  40. package/dist/theme/services/theme.service.d.ts +16 -7
  41. package/dist/theme/services/variant.service.d.ts +8 -2
  42. package/dist/theme/theme.module.d.ts +2 -2
  43. package/dist/theme.cjs.development.js +1418 -906
  44. package/dist/theme.cjs.development.js.map +1 -1
  45. package/dist/theme.cjs.production.min.js +1 -1
  46. package/dist/theme.cjs.production.min.js.map +1 -1
  47. package/dist/theme.esm.js +1385 -907
  48. package/dist/theme.esm.js.map +1 -1
  49. package/package.json +21 -22
  50. package/src/app.container.ts +46 -0
  51. package/src/app.module.ts +5 -8
  52. package/src/app.service.spec.ts +1 -1
  53. package/src/app.service.ts +20 -8
  54. package/src/color/color.interface.ts +1 -3
  55. package/src/color/color.module.ts +8 -10
  56. package/src/color/entities/color.entity.ts +13 -1
  57. package/src/color/entities/index.ts +1 -0
  58. package/src/color/index.ts +5 -0
  59. package/src/color/models/default-color.model.ts +205 -202
  60. package/src/color/models/index.ts +1 -0
  61. package/src/color/{color-manager.service.ts → services/color-manager.service.ts} +23 -15
  62. package/src/color/{color.service.spec.ts → services/color.service.spec.ts} +1 -1
  63. package/src/color/services/color.service.ts +75 -0
  64. package/src/color/services/index.ts +2 -0
  65. package/src/config/config.interface.ts +14 -0
  66. package/src/config/config.module.ts +7 -0
  67. package/src/config/config.service.ts +104 -0
  68. package/src/config/index.ts +3 -0
  69. package/src/index.ts +11 -0
  70. package/src/main.ts +13 -7
  71. package/src/material-color-utilities/index.ts +1 -0
  72. package/src/plugin/index.ts +3 -0
  73. package/src/plugin/plugin.module.ts +7 -0
  74. package/src/plugin/plugin.service.ts +42 -0
  75. package/src/plugin/pluginAbstract.ts +44 -0
  76. package/src/plugins/font/font.plugin.ts +203 -0
  77. package/src/plugins/font/index.ts +1 -0
  78. package/src/plugins/tailwind/index.ts +3 -0
  79. package/src/plugins/tailwind/main.ts +16 -0
  80. package/src/plugins/tailwind/plugins-tailwind/font.ts +69 -0
  81. package/src/plugins/tailwind/plugins-tailwind/index.ts +2 -0
  82. package/src/plugins/tailwind/plugins-tailwind/state.ts +88 -0
  83. package/src/plugins/tailwind/plugins-tailwind/themer.ts +137 -0
  84. package/src/plugins/tailwind/tailwind.plugin.ts +72 -0
  85. package/src/theme/entities/index.ts +2 -0
  86. package/src/theme/entities/variant.entity.ts +2 -1
  87. package/src/theme/index.ts +4 -0
  88. package/src/theme/models/index.ts +1 -0
  89. package/src/theme/models/variant.model.ts +7 -0
  90. package/src/theme/services/index.ts +3 -0
  91. package/src/theme/services/scheme.service.ts +39 -11
  92. package/src/theme/services/theme.service.ts +30 -14
  93. package/src/theme/services/variant.service.ts +40 -5
  94. package/src/theme/theme.module.ts +8 -9
  95. package/dist/color/color-manager.service.d.ts +0 -15
  96. package/dist/color/color.service.d.ts +0 -14
  97. package/src/color/color.service.ts +0 -58
package/package.json CHANGED
@@ -1,11 +1,16 @@
1
1
  {
2
2
  "name": "@udixio/theme",
3
- "version": "1.0.0-beta.3",
3
+ "version": "1.0.0-beta.31",
4
4
  "license": "MIT",
5
5
  "author": "vigreux-joël",
6
- "main": "dist/index.js",
7
- "module": "dist/udixio-theme.esm.js",
8
- "typings": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/theme.esm.js",
9
+ "require": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
+ }
12
+ },
13
+ "types": "dist/index.d.ts",
9
14
  "files": [
10
15
  "dist",
11
16
  "src"
@@ -16,6 +21,7 @@
16
21
  },
17
22
  "scripts": {
18
23
  "analyze": "size-limit --why",
24
+ "prebuild": "rm ./src/**/index.ts && rm ./src/index.ts && npx ctix create -f index.ts -a src\n",
19
25
  "build": "dts build",
20
26
  "lint": "dts lint",
21
27
  "prepare": "dts build",
@@ -34,31 +40,24 @@
34
40
  },
35
41
  "size-limit": [
36
42
  {
37
- "path": "dist/udixio-theme.cjs.production.min.js",
43
+ "path": "dist/theme.cjs.production.min.js",
38
44
  "limit": "10 KB"
39
45
  },
40
46
  {
41
- "path": "dist/udixio-theme.esm.js",
47
+ "path": "dist/theme.esm.js",
42
48
  "limit": "10 KB"
43
49
  }
44
50
  ],
45
51
  "dependencies": {
46
52
  "@material/material-color-utilities": "^0.3.0",
47
- "@nestjs/common": "^10.3.10",
48
- "@nestjs/core": "^10.3.10",
49
- "@nestjs/microservices": "^10.3.10",
50
- "@nestjs/platform-express": "^10.3.10",
51
- "@nestjs/websockets": "^10.3.10",
52
53
  "@rollup/plugin-babel": "^6.0.4",
53
54
  "@rollup/plugin-commonjs": "^26.0.1",
54
- "merge-deep": "^3.0.3",
55
+ "awilix": "^10.0.2",
55
56
  "reflect-metadata": "^0.2.2",
56
- "rxjs": "^7.8.1"
57
+ "rxjs": "^7.8.1",
58
+ "tailwindcss-themer": "^4.0.0"
57
59
  },
58
60
  "devDependencies": {
59
- "@semantic-release/changelog": "^6.0.3",
60
- "@semantic-release/git": "^10.0.1",
61
- "semantic-release": "^24.0.0",
62
61
  "@babel/cli": "^7.24.8",
63
62
  "@babel/core": "^7.24.9",
64
63
  "@babel/node": "^7.24.8",
@@ -69,17 +68,16 @@
69
68
  "@babel/preset-typescript": "^7.24.7",
70
69
  "@babel/register": "^7.24.6",
71
70
  "@babel/runtime": "^7.24.8",
72
- "@nestjs/cli": "^10.4.2",
73
- "@nestjs/schematics": "^10.1.2",
74
- "@nestjs/testing": "^10.3.10",
71
+ "@semantic-release/changelog": "^6.0.3",
72
+ "@semantic-release/git": "^10.0.1",
75
73
  "@size-limit/preset-small-lib": "^11.1.4",
76
74
  "@tsconfig/recommended": "^1.0.7",
77
75
  "@types/express": "^4.17.21",
78
76
  "@types/jest": "28.1.8",
79
- "@types/merge-deep": "^3.0.3",
80
77
  "@types/node": "^16.0.0",
81
78
  "@typescript-eslint/eslint-plugin": "^5.0.0",
82
79
  "@typescript-eslint/parser": "^5.0.0",
80
+ "ctix": "^1.8.2",
83
81
  "dts-cli": "^2.0.5",
84
82
  "eslint": "^8.0.1",
85
83
  "eslint-config-prettier": "^8.3.0",
@@ -88,14 +86,15 @@
88
86
  "i": "^0.3.7",
89
87
  "jest": "28.1.3",
90
88
  "prettier": "^2.3.2",
89
+ "semantic-release": "^24.0.0",
91
90
  "size-limit": "^11.1.4",
92
91
  "source-map-support": "^0.5.20",
93
92
  "supertest": "^6.1.3",
93
+ "tailwindcss": "^3.4.7",
94
94
  "ts-jest": "28.0.8",
95
95
  "ts-loader": "^9.2.3",
96
96
  "ts-node": "^10.0.0",
97
97
  "tsconfig-paths": "4.1.0",
98
- "tslib": "^2.6.3",
99
- "typescript": "^4.7.4"
98
+ "tslib": "^2.6.3"
100
99
  }
101
100
  }
@@ -0,0 +1,46 @@
1
+ import {
2
+ AwilixContainer,
3
+ BuildResolver,
4
+ createContainer,
5
+ DisposableResolver,
6
+ InjectionMode,
7
+ } from 'awilix';
8
+ import { ColorModule } from './color/color.module';
9
+ import { ThemeModule } from './theme/theme.module';
10
+ import { AppModule } from './app.module';
11
+ import { ConfigModule } from './config/config.module';
12
+ import { PluginModule } from './plugin/plugin.module';
13
+
14
+ export type Module = Record<
15
+ string,
16
+ BuildResolver<any> & DisposableResolver<any>
17
+ >;
18
+
19
+ export function importContainer(
20
+ container: AwilixContainer,
21
+ services: Module[]
22
+ ) {
23
+ services.forEach((service) => {
24
+ Object.entries(service).forEach(([name, serviceClass]) => {
25
+ container.register(name, serviceClass);
26
+ });
27
+ });
28
+ return container;
29
+ }
30
+
31
+ const AppContainer = createContainer({
32
+ injectionMode: InjectionMode.PROXY,
33
+ });
34
+
35
+ importContainer(AppContainer, [
36
+ ConfigModule,
37
+ AppModule,
38
+ PluginModule,
39
+ ColorModule,
40
+ ThemeModule,
41
+ ]);
42
+
43
+ // AppContainer.register(ColorModule.cradle);
44
+ // AppContainer.register(ThemeModule.cradle);
45
+
46
+ export default AppContainer;
package/src/app.module.ts CHANGED
@@ -1,10 +1,7 @@
1
- import { Module } from '@nestjs/common';
1
+ import { asClass } from 'awilix';
2
2
  import { AppService } from './app.service';
3
- import { ColorModule } from './color/color.module';
4
- import { ThemeModule } from './theme/theme.module';
3
+ import { Module } from './app.container';
5
4
 
6
- @Module({
7
- imports: [ColorModule, ThemeModule],
8
- providers: [AppService],
9
- })
10
- export class AppModule {}
5
+ export const AppModule: Module = {
6
+ appService: asClass(AppService).singleton(),
7
+ };
@@ -1,6 +1,6 @@
1
1
  import { Test, TestingModule } from '@nestjs/testing';
2
2
  import { AppService } from '../src/app.service';
3
- import { AppModule } from '../src/app.module';
3
+ import { AppModule } from './app.container';
4
4
 
5
5
  describe('AppController (e2e)', () => {
6
6
  let appService: AppService;
@@ -1,11 +1,23 @@
1
- import { Injectable } from '@nestjs/common';
2
- import { ColorService } from './color/color.service';
3
- import { ThemeService } from './theme/services/theme.service';
1
+ import { ColorService } from './color';
2
+ import { ThemeService } from './theme';
3
+ import { PluginService } from './plugin/plugin.service';
4
4
 
5
- @Injectable()
6
5
  export class AppService {
7
- constructor(
8
- public colorService: ColorService,
9
- public themeService: ThemeService
10
- ) {}
6
+ public colorService: ColorService;
7
+ public themeService: ThemeService;
8
+ public pluginService: PluginService;
9
+
10
+ constructor({
11
+ colorService,
12
+ themeService,
13
+ pluginService,
14
+ }: {
15
+ colorService: ColorService;
16
+ themeService: ThemeService;
17
+ pluginService: PluginService;
18
+ }) {
19
+ this.pluginService = pluginService;
20
+ this.colorService = colorService;
21
+ this.themeService = themeService;
22
+ }
11
23
  }
@@ -9,7 +9,5 @@ export interface ColorInterface {
9
9
 
10
10
  updateColor(key: string, newColor: ColorOptions): ColorEntity;
11
11
 
12
- getAllColors(): ReadonlyMap<string, ColorEntity>;
13
-
14
- addColors(colors: Record<string, ColorOptions>): ColorEntity[];
12
+ getColors(): ReadonlyMap<string, ColorEntity>;
15
13
  }
@@ -1,11 +1,9 @@
1
- import { ColorService } from './color.service';
2
- import { Module } from '@nestjs/common';
3
- import { ColorManagerService } from './color-manager.service';
4
- import { ThemeModule } from '../theme/theme.module';
1
+ import { ColorService } from './services/color.service';
2
+ import { ColorManagerService } from './services/color-manager.service';
3
+ import { asClass } from 'awilix';
4
+ import { Module } from '../app.container';
5
5
 
6
- @Module({
7
- imports: [ThemeModule],
8
- providers: [ColorService, ColorManagerService],
9
- exports: [ColorService],
10
- })
11
- export class ColorModule {}
6
+ export const ColorModule: Module = {
7
+ colorManagerService: asClass(ColorManagerService).singleton(),
8
+ colorService: asClass(ColorService).singleton(),
9
+ };
@@ -3,7 +3,7 @@ import { SchemeEntity } from '../../theme/entities/scheme.entity';
3
3
  import { DynamicColor } from '../../material-color-utilities/dynamic_color';
4
4
  import { ContrastCurve } from '../../material-color-utilities';
5
5
  import { SchemeService } from '../../theme/services/scheme.service';
6
- import { ColorManagerService } from '../color-manager.service';
6
+ import { ColorManagerService } from '../services/color-manager.service';
7
7
 
8
8
  export interface ColorOptions {
9
9
  palette: (scheme: SchemeEntity) => TonalPalette;
@@ -21,6 +21,14 @@ export interface ColorOptions {
21
21
  };
22
22
  }
23
23
 
24
+ function argbToRgb(argb: number): { r: number; g: number; b: number } {
25
+ return {
26
+ r: (argb >> 16) & 0xff,
27
+ g: (argb >> 8) & 0xff,
28
+ b: argb & 0xff,
29
+ };
30
+ }
31
+
24
32
  export class ColorEntity {
25
33
  private dynamicColor: DynamicColor | null = null;
26
34
 
@@ -43,6 +51,10 @@ export class ColorEntity {
43
51
  return this.getDynamicColor().getArgb(this.schemeService.get());
44
52
  }
45
53
 
54
+ getRgb() {
55
+ return argbToRgb(this.getArgb());
56
+ }
57
+
46
58
  getName(): string {
47
59
  return this.option.name.replace(/([A-Z])/g, '_$1').toLowerCase();
48
60
  }
@@ -0,0 +1 @@
1
+ export * from './color.entity';
@@ -0,0 +1,5 @@
1
+ export * from './color.interface';
2
+ export * from './color.module';
3
+ export * from './entities';
4
+ export * from './models';
5
+ export * from './services';