@udixio/theme 1.0.0-beta.9 → 1.1.0
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/.eslintrc.mjs +22 -0
- package/CHANGELOG.md +186 -0
- package/README.md +6 -68
- package/dist/API.d.ts +14 -0
- package/dist/API.d.ts.map +1 -0
- package/dist/LICENSE +202 -0
- package/dist/adapter/adapter.abstract.d.ts +10 -0
- package/dist/adapter/adapter.abstract.d.ts.map +1 -0
- package/dist/{config → adapter}/config.interface.d.ts +6 -5
- package/dist/adapter/config.interface.d.ts.map +1 -0
- package/dist/adapter/define-config.d.ts +3 -0
- package/dist/adapter/define-config.d.ts.map +1 -0
- package/dist/adapter/file-adapter.mixin.d.ts +18 -0
- package/dist/adapter/file-adapter.mixin.d.ts.map +1 -0
- package/dist/adapter/index.d.ts +4 -0
- package/dist/adapter/index.d.ts.map +1 -0
- package/dist/adapters/index.d.ts +3 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/node.adapter.d.ts +7 -0
- package/dist/adapters/node.adapter.d.ts.map +1 -0
- package/dist/adapters/vite.adapter.d.ts +3 -0
- package/dist/adapters/vite.adapter.d.ts.map +1 -0
- package/dist/app.container.d.ts +5 -5
- package/dist/app.container.d.ts.map +1 -0
- package/dist/app.module.d.ts +1 -0
- package/dist/app.module.d.ts.map +1 -0
- package/dist/bootstrap.d.ts +3 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/color/color.api.d.ts +39 -0
- package/dist/color/color.api.d.ts.map +1 -0
- package/dist/color/color.manager.d.ts +24 -0
- package/dist/color/color.manager.d.ts.map +1 -0
- package/dist/color/color.module.d.ts +1 -0
- package/dist/color/color.module.d.ts.map +1 -0
- package/dist/color/color.utils.d.ts +8 -0
- package/dist/color/color.utils.d.ts.map +1 -0
- package/dist/color/configurable-color.d.ts +31 -0
- package/dist/color/configurable-color.d.ts.map +1 -0
- package/dist/color/default-color.d.ts +3 -0
- package/dist/color/default-color.d.ts.map +1 -0
- package/dist/color/index.d.ts +5 -4
- package/dist/color/index.d.ts.map +1 -0
- package/dist/index.cjs +3224 -0
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3183 -7
- package/dist/material-color-utilities/contrastCurve.d.ts +1 -0
- package/dist/material-color-utilities/contrastCurve.d.ts.map +1 -0
- package/dist/material-color-utilities/dynamic_color.d.ts +89 -76
- package/dist/material-color-utilities/dynamic_color.d.ts.map +1 -0
- package/dist/material-color-utilities/hct_solver.d.ts +131 -0
- package/dist/material-color-utilities/hct_solver.d.ts.map +1 -0
- package/dist/material-color-utilities/htc.d.ts +77 -0
- package/dist/material-color-utilities/htc.d.ts.map +1 -0
- package/dist/material-color-utilities/index.d.ts +1 -0
- package/dist/material-color-utilities/index.d.ts.map +1 -0
- package/dist/material-color-utilities/toneDeltaPair.d.ts +19 -25
- package/dist/material-color-utilities/toneDeltaPair.d.ts.map +1 -0
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.d.ts.map +1 -0
- package/dist/plugin/plugin.abstract.d.ts +19 -5
- package/dist/plugin/plugin.abstract.d.ts.map +1 -0
- package/dist/plugin/plugin.api.d.ts +10 -0
- package/dist/plugin/plugin.api.d.ts.map +1 -0
- package/dist/plugin/plugin.module.d.ts +1 -0
- package/dist/plugin/plugin.module.d.ts.map +1 -0
- package/dist/plugins/font/font.plugin.d.ts +50 -0
- package/dist/plugins/font/font.plugin.d.ts.map +1 -0
- package/dist/plugins/font/index.d.ts +2 -0
- package/dist/plugins/font/index.d.ts.map +1 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/theme/index.d.ts +7 -3
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/scheme.d.ts +20 -0
- package/dist/theme/scheme.d.ts.map +1 -0
- package/dist/theme/scheme.manager.d.ts +31 -0
- package/dist/theme/scheme.manager.d.ts.map +1 -0
- package/dist/theme/theme.api.d.ts +23 -0
- package/dist/theme/theme.api.d.ts.map +1 -0
- package/dist/theme/theme.module.d.ts +1 -0
- package/dist/theme/theme.module.d.ts.map +1 -0
- package/dist/theme/variant.d.ts +36 -0
- package/dist/theme/variant.d.ts.map +1 -0
- package/dist/theme/variant.manager.d.ts +14 -0
- package/dist/theme/variant.manager.d.ts.map +1 -0
- package/dist/theme/variants/expressive.variant.d.ts +3 -0
- package/dist/theme/variants/expressive.variant.d.ts.map +1 -0
- package/dist/theme/variants/index.d.ts +11 -0
- package/dist/theme/variants/index.d.ts.map +1 -0
- package/dist/theme/variants/neutral.variant.d.ts +3 -0
- package/dist/theme/variants/neutral.variant.d.ts.map +1 -0
- package/dist/theme/variants/tonal-spot.variant.d.ts +3 -0
- package/dist/theme/variants/tonal-spot.variant.d.ts.map +1 -0
- package/dist/theme/variants/vibrant.variant.d.ts +3 -0
- package/dist/theme/variants/vibrant.variant.d.ts.map +1 -0
- package/package.json +26 -87
- package/src/API.ts +23 -0
- package/src/adapter/adapter.abstract.ts +64 -0
- package/src/{config → adapter}/config.interface.ts +5 -5
- package/src/adapter/define-config.ts +11 -0
- package/src/adapter/file-adapter.mixin.ts +72 -0
- package/src/adapter/index.ts +3 -0
- package/src/adapters/index.ts +2 -0
- package/src/adapters/node.adapter.ts +57 -0
- package/src/adapters/vite.adapter.ts +79 -0
- package/src/app.container.ts +12 -36
- package/src/app.module.ts +2 -2
- package/src/bootstrap.ts +6 -0
- package/src/color/color.api.ts +75 -0
- package/src/color/color.manager.ts +213 -0
- package/src/color/color.module.ts +4 -4
- package/src/color/color.utils.ts +126 -0
- package/src/color/configurable-color.ts +67 -0
- package/src/color/default-color.ts +832 -0
- package/src/color/index.ts +4 -4
- package/src/index.test.ts +5 -0
- package/src/index.ts +6 -4
- package/src/material-color-utilities/dynamic_color.ts +286 -222
- package/src/material-color-utilities/hct_solver.ts +536 -0
- package/src/material-color-utilities/htc.ts +198 -0
- package/src/material-color-utilities/toneDeltaPair.ts +29 -11
- package/src/plugin/index.ts +3 -0
- package/src/plugin/plugin.abstract.ts +45 -5
- package/src/plugin/plugin.api.ts +51 -0
- package/src/plugin/plugin.module.ts +2 -2
- package/src/plugins/font/font.plugin.ts +203 -0
- package/src/plugins/font/index.ts +1 -0
- package/src/plugins/index.ts +1 -0
- package/src/theme/index.ts +6 -3
- package/src/theme/{services/scheme.service.ts → scheme.manager.ts} +39 -19
- package/src/theme/{entities/scheme.entity.ts → scheme.ts} +20 -4
- package/src/theme/{services/theme.service.ts → theme.api.ts} +23 -19
- package/src/theme/theme.module.ts +6 -4
- package/src/theme/variant.manager.ts +58 -0
- package/src/theme/variant.ts +53 -0
- package/src/theme/variants/expressive.variant.ts +81 -0
- package/src/theme/variants/index.ts +16 -0
- package/src/theme/variants/neutral.variant.ts +45 -0
- package/src/theme/variants/tonal-spot.variant.ts +35 -0
- package/src/theme/variants/vibrant.variant.ts +72 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +33 -0
- package/tsconfig.spec.json +36 -0
- package/vite.config.ts +54 -0
- package/LICENSE +0 -21
- package/dist/app.service.d.ts +0 -13
- package/dist/color/color.interface.d.ts +0 -8
- package/dist/color/entities/color.entity.d.ts +0 -42
- package/dist/color/entities/index.d.ts +0 -1
- package/dist/color/models/default-color.model.d.ts +0 -3
- package/dist/color/models/index.d.ts +0 -1
- package/dist/color/services/color-manager.service.d.ts +0 -18
- package/dist/color/services/color.service.d.ts +0 -21
- package/dist/color/services/index.d.ts +0 -2
- package/dist/config/config.module.d.ts +0 -2
- package/dist/config/config.service.d.ts +0 -12
- package/dist/config/index.d.ts +0 -2
- package/dist/main.d.ts +0 -3
- package/dist/plugin/plugin.service.d.ts +0 -10
- package/dist/plugins/tailwind/Tailwind.plugin.d.ts +0 -14
- package/dist/plugins/tailwind/main.d.ts +0 -10
- package/dist/plugins/tailwind/plugins-tailwind/state.d.ts +0 -4
- package/dist/plugins/tailwind/plugins-tailwind/themer.d.ts +0 -4
- package/dist/theme/entities/index.d.ts +0 -2
- package/dist/theme/entities/scheme.entity.d.ts +0 -15
- package/dist/theme/entities/variant.entity.d.ts +0 -7
- package/dist/theme/models/index.d.ts +0 -1
- package/dist/theme/models/variant.model.d.ts +0 -8
- package/dist/theme/services/index.d.ts +0 -3
- package/dist/theme/services/scheme.service.d.ts +0 -17
- package/dist/theme/services/theme.service.d.ts +0 -22
- package/dist/theme/services/variant.service.d.ts +0 -13
- package/dist/theme.cjs.development.js +0 -1983
- package/dist/theme.cjs.development.js.map +0 -1
- package/dist/theme.cjs.production.min.js +0 -2
- package/dist/theme.cjs.production.min.js.map +0 -1
- package/dist/theme.esm.js +0 -1955
- package/dist/theme.esm.js.map +0 -1
- package/src/app.service.spec.ts +0 -15
- package/src/app.service.ts +0 -23
- package/src/color/color.interface.ts +0 -13
- package/src/color/entities/color.entity.ts +0 -71
- package/src/color/entities/index.ts +0 -1
- package/src/color/models/default-color.model.ts +0 -300
- package/src/color/models/index.ts +0 -1
- package/src/color/services/color-manager.service.ts +0 -191
- package/src/color/services/color.service.spec.ts +0 -28
- package/src/color/services/color.service.ts +0 -75
- package/src/color/services/index.ts +0 -2
- package/src/config/config.module.ts +0 -7
- package/src/config/config.service.ts +0 -74
- package/src/config/index.ts +0 -2
- package/src/main.ts +0 -14
- package/src/plugin/plugin.service.ts +0 -30
- package/src/plugins/tailwind/Tailwind.plugin.ts +0 -53
- package/src/plugins/tailwind/main.ts +0 -18
- package/src/plugins/tailwind/plugins-tailwind/state.ts +0 -88
- package/src/plugins/tailwind/plugins-tailwind/themer.ts +0 -53
- package/src/theme/entities/index.ts +0 -2
- package/src/theme/entities/variant.entity.ts +0 -39
- package/src/theme/models/index.ts +0 -1
- package/src/theme/models/variant.model.ts +0 -63
- package/src/theme/services/index.ts +0 -3
- package/src/theme/services/variant.service.ts +0 -52
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PluginAbstract, PluginImplAbstract } from '../../plugin';
|
|
2
|
+
export declare enum FontFamily {
|
|
3
|
+
Expressive = "expressive",
|
|
4
|
+
Neutral = "neutral"
|
|
5
|
+
}
|
|
6
|
+
export type FontStyle = {
|
|
7
|
+
fontSize: number;
|
|
8
|
+
lineHeight: number;
|
|
9
|
+
fontWeight: number;
|
|
10
|
+
letterSpacing?: number;
|
|
11
|
+
fontFamily: FontFamily;
|
|
12
|
+
};
|
|
13
|
+
export type FontRole = 'display' | 'headline' | 'title' | 'label' | 'body';
|
|
14
|
+
export type FontSize = 'large' | 'medium' | 'small';
|
|
15
|
+
interface FontPluginOptions {
|
|
16
|
+
fontFamily?: {
|
|
17
|
+
expressive?: string[];
|
|
18
|
+
neutral?: string[];
|
|
19
|
+
};
|
|
20
|
+
fontStyles?: Partial<Record<FontRole, Record<FontSize, Partial<FontStyle>>>>;
|
|
21
|
+
}
|
|
22
|
+
export declare class FontPlugin extends PluginAbstract<FontPluginImpl, FontPluginOptions> {
|
|
23
|
+
dependencies: never[];
|
|
24
|
+
name: string;
|
|
25
|
+
pluginClass: typeof FontPluginImpl;
|
|
26
|
+
}
|
|
27
|
+
declare class FontPluginImpl extends PluginImplAbstract<FontPluginOptions> {
|
|
28
|
+
private _fontFamily;
|
|
29
|
+
get fontFamily(): {
|
|
30
|
+
expressive: string[];
|
|
31
|
+
neutral: string[];
|
|
32
|
+
};
|
|
33
|
+
set fontFamily(value: {
|
|
34
|
+
expressive: string[];
|
|
35
|
+
neutral: string[];
|
|
36
|
+
} | undefined);
|
|
37
|
+
private _fontStyles;
|
|
38
|
+
get fontStyles(): Record<FontRole, Record<FontSize, FontStyle>>;
|
|
39
|
+
set fontStyles(value: Record<FontRole, Record<FontSize, FontStyle>> | undefined);
|
|
40
|
+
getFonts(): {
|
|
41
|
+
fontStyles: Record<FontRole, Record<FontSize, FontStyle>>;
|
|
42
|
+
fontFamily: {
|
|
43
|
+
expressive: string[];
|
|
44
|
+
neutral: string[];
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
onInit(): void;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=font.plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"font.plugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/font/font.plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElE,oBAAY,UAAU;IACpB,UAAU,eAAe;IACzB,OAAO,YAAY;CACpB;AACD,MAAM,MAAM,SAAS,GAAG;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AACpD,UAAU,iBAAiB;IACzB,UAAU,CAAC,EAAE;QACX,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;IACF,UAAU,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9E;AAED,qBAAa,UAAW,SAAQ,cAAc,CAC5C,cAAc,EACd,iBAAiB,CAClB;IACC,YAAY,UAAM;IAClB,IAAI,SAAU;IACd,WAAW,wBAAkB;CAC9B;AAED,cAAM,cAAe,SAAQ,kBAAkB,CAAC,iBAAiB,CAAC;IAChE,OAAO,CAAC,WAAW,CAA0D;IAE7E,IAAI,UAAU,IAAI;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,CAG5D;IAED,IAAI,UAAU,CACZ,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,EAG/D;IAED,OAAO,CAAC,WAAW,CAEL;IAEd,IAAI,UAAU,IAAI,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAG9D;IAED,IAAI,UAAU,CACZ,KAAK,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,GAAG,SAAS,EAGjE;IAED,QAAQ;;;wBA1BwB,MAAM,EAAE;qBAAW,MAAM,EAAE;;;IAiC3D,MAAM,IAAI,IAAI;CAsIf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/font/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export * from './entities';
|
|
2
|
-
export * from './models';
|
|
3
|
-
export * from './services';
|
|
4
1
|
export * from './theme.module';
|
|
2
|
+
export * from './variants';
|
|
3
|
+
export * from './scheme.manager';
|
|
4
|
+
export * from './scheme';
|
|
5
|
+
export * from './theme.api';
|
|
6
|
+
export * from './variant';
|
|
7
|
+
export * from './variant.manager';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { TonalPalette } from '@material/material-color-utilities';
|
|
2
|
+
import { Hct } from '../material-color-utilities/htc';
|
|
3
|
+
import { Variant } from './variant';
|
|
4
|
+
export interface SchemeOptions {
|
|
5
|
+
sourceColorArgb: number;
|
|
6
|
+
contrastLevel: number;
|
|
7
|
+
isDark: boolean;
|
|
8
|
+
palettes: Map<string, TonalPalette>;
|
|
9
|
+
variant: Variant;
|
|
10
|
+
}
|
|
11
|
+
export declare class Scheme {
|
|
12
|
+
readonly options: SchemeOptions;
|
|
13
|
+
constructor(options: SchemeOptions);
|
|
14
|
+
get variant(): 'expressive' | 'neutral' | 'tonalSpot' | 'vibrant' | string;
|
|
15
|
+
get contrastLevel(): number;
|
|
16
|
+
get isDark(): boolean;
|
|
17
|
+
get sourceColorHct(): Hct;
|
|
18
|
+
getPalette(key: 'primary' | 'secondary' | 'tertiary' | 'neutral' | 'neutralVariant' | 'error' | string): TonalPalette;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=scheme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheme.d.ts","sourceRoot":"","sources":["../../src/theme/scheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,MAAM;IACL,QAAQ,CAAC,OAAO,EAAE,aAAa;gBAAtB,OAAO,EAAE,aAAa;IAE3C,IAAI,OAAO,IAAI,YAAY,GAAG,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,MAAM,CAEzE;IAED,IAAI,aAAa,WAKhB;IAED,IAAI,MAAM,YAKT;IAED,IAAI,cAAc,QAKjB;IAED,UAAU,CACR,GAAG,EACC,SAAS,GACT,WAAW,GACX,UAAU,GACV,SAAS,GACT,gBAAgB,GAChB,OAAO,GACP,MAAM,GACT,YAAY;CAUhB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Scheme, SchemeOptions } from './scheme';
|
|
2
|
+
import { TonalPalette } from '@material/material-color-utilities';
|
|
3
|
+
import { Hct } from '../material-color-utilities/htc';
|
|
4
|
+
export type SchemeServiceOptions = Omit<SchemeOptions, 'palettes' | 'sourceColorArgb'> & {
|
|
5
|
+
sourcesColorHex: Record<string, string> & {
|
|
6
|
+
primary?: string;
|
|
7
|
+
};
|
|
8
|
+
palettes: Record<string, {
|
|
9
|
+
sourceColorkey: string;
|
|
10
|
+
tonalPalette: CustomPaletteFunction;
|
|
11
|
+
} | {
|
|
12
|
+
sourceColorkey?: never;
|
|
13
|
+
tonalPalette: PaletteFunction;
|
|
14
|
+
}>;
|
|
15
|
+
};
|
|
16
|
+
type PaletteFunctionArgs = {
|
|
17
|
+
isDark: boolean;
|
|
18
|
+
sourceColorHct: Hct;
|
|
19
|
+
};
|
|
20
|
+
export type PaletteFunction = (args: PaletteFunctionArgs) => TonalPalette;
|
|
21
|
+
export type CustomPaletteFunction = (args: PaletteFunctionArgs & {
|
|
22
|
+
colorHct: Hct;
|
|
23
|
+
}) => TonalPalette;
|
|
24
|
+
export declare class SchemeManager {
|
|
25
|
+
private schemeEntity?;
|
|
26
|
+
private options?;
|
|
27
|
+
createOrUpdate(options: Partial<SchemeServiceOptions>): void;
|
|
28
|
+
get(): Scheme;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=scheme.manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheme.manager.d.ts","sourceRoot":"","sources":["../../src/theme/scheme.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAe,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AAEtD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACrC,aAAa,EACb,UAAU,GAAG,iBAAiB,CAC/B,GAAG;IACF,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;QAAE,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC/D,QAAQ,EAAE,MAAM,CACd,MAAM,EACJ;QACE,cAAc,EAAE,MAAM,CAAC;QACvB,YAAY,EAAE,qBAAqB,CAAC;KACrC,GACD;QACE,cAAc,CAAC,EAAE,KAAK,CAAC;QACvB,YAAY,EAAE,eAAe,CAAC;KAC/B,CACJ,CAAC;CACH,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,GAAG,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE,mBAAmB,KAAK,YAAY,CAAC;AAC1E,MAAM,MAAM,qBAAqB,GAAG,CAClC,IAAI,EAAE,mBAAmB,GAAG;IAC1B,QAAQ,EAAE,GAAG,CAAC;CACf,KACE,YAAY,CAAC;AAElB,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAAC,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAC,CAAuB;IAEvC,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,oBAAoB,CAAC;IAuDrD,GAAG,IAAI,MAAM;CAMd"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SchemeManager, SchemeServiceOptions } from './scheme.manager';
|
|
2
|
+
import { VariantManager } from './variant.manager';
|
|
3
|
+
import { Variant } from './variant';
|
|
4
|
+
type ThemeOptions = Omit<SchemeServiceOptions, 'palettes' | 'sourcesColorHex'> & {
|
|
5
|
+
sourceColorHex: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class ThemeApi {
|
|
8
|
+
private readonly schemeManager;
|
|
9
|
+
private readonly variantManager;
|
|
10
|
+
constructor({ schemeManager, variantManager, }: {
|
|
11
|
+
schemeManager: SchemeManager;
|
|
12
|
+
variantManager: VariantManager;
|
|
13
|
+
});
|
|
14
|
+
create(options: ThemeOptions & {
|
|
15
|
+
variant: Variant;
|
|
16
|
+
}): void;
|
|
17
|
+
update(options: Partial<ThemeOptions> & {
|
|
18
|
+
variant?: Variant;
|
|
19
|
+
}): void;
|
|
20
|
+
addCustomPalette(key: string, colorHex: string): void;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=theme.api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.api.d.ts","sourceRoot":"","sources":["../../src/theme/theme.api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,KAAK,YAAY,GAAG,IAAI,CACtB,oBAAoB,EACpB,UAAU,GAAG,iBAAiB,CAC/B,GAAG;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC;AAQ/B,qBAAa,QAAQ;IACnB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAiB;gBAEpC,EACV,aAAa,EACb,cAAc,GACf,EAAE;QACD,aAAa,EAAE,aAAa,CAAC;QAC7B,cAAc,EAAE,cAAc,CAAC;KAChC;IA4BD,MAAM,CAAC,OAAO,EAAE,YAAY,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE;IAQnD,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;IAQ7D,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAO/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.module.d.ts","sourceRoot":"","sources":["../../src/theme/theme.module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAK1C,eAAO,MAAM,WAAW,EAAE,MAIzB,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { TonalPalette } from '@material/material-color-utilities';
|
|
2
|
+
import { Hct } from '../material-color-utilities/htc';
|
|
3
|
+
import { AddColors } from '../color';
|
|
4
|
+
export declare const getPiecewiseHue: (sourceColorHct: Hct, hueBreakpoints: number[], hues: number[]) => number;
|
|
5
|
+
export declare const getRotatedHue: (sourceColorHct: Hct, hueBreakpoints: number[], rotations: number[]) => number;
|
|
6
|
+
export declare class Variant {
|
|
7
|
+
palettes: Record<string, (args: {
|
|
8
|
+
sourceColorHct: Hct;
|
|
9
|
+
isDark: boolean;
|
|
10
|
+
}) => TonalPalette>;
|
|
11
|
+
name: string;
|
|
12
|
+
customPalettes?: ((args: {
|
|
13
|
+
isDark: boolean;
|
|
14
|
+
sourceColorHct: Hct;
|
|
15
|
+
colorHct: Hct;
|
|
16
|
+
}) => TonalPalette) | undefined;
|
|
17
|
+
/** TODO
|
|
18
|
+
* Defines color modifications through variation.
|
|
19
|
+
* Allows customization of specific colors in the theme.
|
|
20
|
+
*/
|
|
21
|
+
colors?: AddColors['colors'];
|
|
22
|
+
constructor(palettes: Record<string, (args: {
|
|
23
|
+
sourceColorHct: Hct;
|
|
24
|
+
isDark: boolean;
|
|
25
|
+
}) => TonalPalette> | undefined, name: string, customPalettes?: ((args: {
|
|
26
|
+
isDark: boolean;
|
|
27
|
+
sourceColorHct: Hct;
|
|
28
|
+
colorHct: Hct;
|
|
29
|
+
}) => TonalPalette) | undefined,
|
|
30
|
+
/** TODO
|
|
31
|
+
* Defines color modifications through variation.
|
|
32
|
+
* Allows customization of specific colors in the theme.
|
|
33
|
+
*/
|
|
34
|
+
colors?: AddColors['colors']);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=variant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant.d.ts","sourceRoot":"","sources":["../../src/theme/variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACb,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,iCAAiC,CAAC;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,eAAO,MAAM,eAAe,GAC1B,gBAAgB,GAAG,EACnB,gBAAgB,MAAM,EAAE,EACxB,MAAM,MAAM,EAAE,KACb,MASF,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,gBAAgB,GAAG,EACnB,gBAAgB,MAAM,EAAE,EACxB,WAAW,MAAM,EAAE,KAClB,MAMF,CAAC;AAEF,qBAAa,OAAO;IAET,QAAQ,EAAE,MAAM,CACrB,MAAM,EACN,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,KAAK,YAAY,CACjE;IACM,IAAI,EAAE,MAAM;IACZ,cAAc,CAAC,GAAE,CAAC,IAAI,EAAE;QAC7B,MAAM,EAAE,OAAO,CAAC;QAChB,cAAc,EAAE,GAAG,CAAC;QACpB,QAAQ,EAAE,GAAG,CAAC;KACf,KAAK,YAAY;IAClB;;;OAGG;IACI,MAAM,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC;gBAd5B,QAAQ,EAAE,MAAM,CACrB,MAAM,EACN,CAAC,IAAI,EAAE;QAAE,cAAc,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,KAAK,YAAY,CACjE,YAAK,EACC,IAAI,EAAE,MAAM,EACZ,cAAc,CAAC,GAAE,CAAC,IAAI,EAAE;QAC7B,MAAM,EAAE,OAAO,CAAC;QAChB,cAAc,EAAE,GAAG,CAAC;QACpB,QAAQ,EAAE,GAAG,CAAC;KACf,KAAK,YAAY,aAAA;IAClB;;;OAGG;IACI,MAAM,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC;CAEtC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SchemeManager } from './scheme.manager';
|
|
2
|
+
import { Variant } from './variant';
|
|
3
|
+
export declare class VariantManager {
|
|
4
|
+
customPalettes: Record<string, string>;
|
|
5
|
+
private variantEntity?;
|
|
6
|
+
private readonly schemeManager;
|
|
7
|
+
constructor({ schemeManager }: {
|
|
8
|
+
schemeManager: SchemeManager;
|
|
9
|
+
});
|
|
10
|
+
addCustomPalette(key: string, colorHex: string): void;
|
|
11
|
+
set(variantEntity: Variant): void;
|
|
12
|
+
private update;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=variant.manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variant.manager.d.ts","sourceRoot":"","sources":["../../src/theme/variant.manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,aAAa,EACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,qBAAa,cAAc;IAClB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IACnD,OAAO,CAAC,aAAa,CAAC,CAAU;IAEhC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;gBAElC,EAAE,aAAa,EAAE,EAAE;QAAE,aAAa,EAAE,aAAa,CAAA;KAAE;IAI/D,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAK9C,GAAG,CAAC,aAAa,EAAE,OAAO;IAK1B,OAAO,CAAC,MAAM;CA8Bf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expressive.variant.d.ts","sourceRoot":"","sources":["../../../src/theme/variants/expressive.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,OAAO,EAAE,MAAM,YAAY,CAAC;AAoBrE,eAAO,MAAM,iBAAiB,EAAE,OA4D/B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './tonal-spot.variant';
|
|
2
|
+
export * from './vibrant.variant';
|
|
3
|
+
export * from './expressive.variant';
|
|
4
|
+
export * from './neutral.variant';
|
|
5
|
+
export declare const Variants: {
|
|
6
|
+
Expressive: import('..').Variant;
|
|
7
|
+
Neutral: import('..').Variant;
|
|
8
|
+
TonalSpot: import('..').Variant;
|
|
9
|
+
Vibrant: import('..').Variant;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/theme/variants/index.ts"],"names":[],"mappings":"AAKA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAElC,eAAO,MAAM,QAAQ;;;;;CAKpB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"neutral.variant.d.ts","sourceRoot":"","sources":["../../../src/theme/variants/neutral.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,OAAO,EAAE,MAAM,YAAY,CAAC;AAIrE,eAAO,MAAM,cAAc,EAAE,OAwC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tonal-spot.variant.d.ts","sourceRoot":"","sources":["../../../src/theme/variants/tonal-spot.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,OAAO,EAAE,MAAM,YAAY,CAAC;AAGrE,eAAO,MAAM,gBAAgB,EAAE,OA+B9B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vibrant.variant.d.ts","sourceRoot":"","sources":["../../../src/theme/variants/vibrant.variant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,OAAO,EAAE,MAAM,YAAY,CAAC;AAiBrE,eAAO,MAAM,cAAc,EAAE,OAsD5B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,95 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@udixio/theme",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"analyze": "size-limit --why",
|
|
19
|
-
"prebuild": "rm ./src/**/index.ts && rm ./src/index.ts && npx ctix create -f index.ts -a src\n",
|
|
20
|
-
"build": "dts build",
|
|
21
|
-
"lint": "dts lint",
|
|
22
|
-
"prepare": "dts build",
|
|
23
|
-
"size": "size-limit",
|
|
24
|
-
"start": "dts watch",
|
|
25
|
-
"test": "dts test",
|
|
26
|
-
"semantic-release": "semantic-release"
|
|
27
|
-
},
|
|
28
|
-
"husky": {
|
|
29
|
-
"hooks": {
|
|
30
|
-
"pre-commit": "dts lint"
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"./package.json": "./package.json",
|
|
10
|
+
".": {
|
|
11
|
+
"development": "./src/index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"require": "./dist/index.cjs",
|
|
15
|
+
"default": "./dist/index.js"
|
|
31
16
|
}
|
|
32
17
|
},
|
|
33
|
-
"engines": {
|
|
34
|
-
"node": ">=12"
|
|
35
|
-
},
|
|
36
|
-
"size-limit": [
|
|
37
|
-
{
|
|
38
|
-
"path": "dist/theme.cjs.production.min.js",
|
|
39
|
-
"limit": "10 KB"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"path": "dist/theme.esm.js",
|
|
43
|
-
"limit": "10 KB"
|
|
44
|
-
}
|
|
45
|
-
],
|
|
46
18
|
"dependencies": {
|
|
19
|
+
"pathe": "^2.0.3",
|
|
20
|
+
"jiti": "^2.5.1",
|
|
21
|
+
"awilix": "^12.0.5",
|
|
47
22
|
"@material/material-color-utilities": "^0.3.0",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
"
|
|
23
|
+
"replace-in-file": "^8.3.0",
|
|
24
|
+
"tailwindcss": "^4.1.11"
|
|
25
|
+
},
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "https://github.com/Udixio/UI.git"
|
|
53
29
|
},
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"@babel/node": "^7.24.8",
|
|
58
|
-
"@babel/plugin-proposal-decorators": "^7.24.7",
|
|
59
|
-
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
|
|
60
|
-
"@babel/plugin-transform-runtime": "^7.24.7",
|
|
61
|
-
"@babel/preset-env": "^7.24.8",
|
|
62
|
-
"@babel/preset-typescript": "^7.24.7",
|
|
63
|
-
"@babel/register": "^7.24.6",
|
|
64
|
-
"@babel/runtime": "^7.24.8",
|
|
65
|
-
"@semantic-release/changelog": "^6.0.3",
|
|
66
|
-
"@semantic-release/git": "^10.0.1",
|
|
67
|
-
"@size-limit/preset-small-lib": "^11.1.4",
|
|
68
|
-
"@tsconfig/recommended": "^1.0.7",
|
|
69
|
-
"@types/express": "^4.17.21",
|
|
70
|
-
"@types/jest": "28.1.8",
|
|
71
|
-
"@types/node": "^16.0.0",
|
|
72
|
-
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
73
|
-
"@typescript-eslint/parser": "^5.0.0",
|
|
74
|
-
"ctix": "^1.8.2",
|
|
75
|
-
"dts-cli": "^2.0.5",
|
|
76
|
-
"eslint": "^8.0.1",
|
|
77
|
-
"eslint-config-prettier": "^8.3.0",
|
|
78
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
79
|
-
"husky": "^9.0.11",
|
|
80
|
-
"i": "^0.3.7",
|
|
81
|
-
"jest": "28.1.3",
|
|
82
|
-
"prettier": "^2.3.2",
|
|
83
|
-
"semantic-release": "^24.0.0",
|
|
84
|
-
"size-limit": "^11.1.4",
|
|
85
|
-
"source-map-support": "^0.5.20",
|
|
86
|
-
"supertest": "^6.1.3",
|
|
87
|
-
"tailwindcss": "^3.4.7",
|
|
88
|
-
"tailwindcss-themer": "^4.0.0",
|
|
89
|
-
"ts-jest": "28.0.8",
|
|
90
|
-
"ts-loader": "^9.2.3",
|
|
91
|
-
"ts-node": "^10.0.0",
|
|
92
|
-
"tsconfig-paths": "4.1.0",
|
|
93
|
-
"tslib": "^2.6.3"
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"access": "public"
|
|
94
33
|
}
|
|
95
|
-
}
|
|
34
|
+
}
|
package/src/API.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ColorApi } from './color';
|
|
2
|
+
import { ThemeApi } from './theme';
|
|
3
|
+
import { PluginApi } from './plugin';
|
|
4
|
+
|
|
5
|
+
export class API {
|
|
6
|
+
public colors: ColorApi;
|
|
7
|
+
public themes: ThemeApi;
|
|
8
|
+
public plugins: PluginApi;
|
|
9
|
+
|
|
10
|
+
constructor({
|
|
11
|
+
colorApi,
|
|
12
|
+
themeApi,
|
|
13
|
+
pluginApi,
|
|
14
|
+
}: {
|
|
15
|
+
colorApi: ColorApi;
|
|
16
|
+
themeApi: ThemeApi;
|
|
17
|
+
pluginApi: PluginApi;
|
|
18
|
+
}) {
|
|
19
|
+
this.plugins = pluginApi;
|
|
20
|
+
this.colors = colorApi;
|
|
21
|
+
this.themes = themeApi;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ConfigInterface } from './config.interface';
|
|
2
|
+
import { tonalSpotVariant } from '../theme';
|
|
3
|
+
import { defaultColors } from '../color';
|
|
4
|
+
import { bootstrap } from '../bootstrap';
|
|
5
|
+
import { API } from '../API';
|
|
6
|
+
import { registerModule } from '../app.container';
|
|
7
|
+
import { asValue } from 'awilix';
|
|
8
|
+
|
|
9
|
+
export abstract class AdapterAbstract {
|
|
10
|
+
public api: API;
|
|
11
|
+
|
|
12
|
+
protected constructor() {
|
|
13
|
+
this.api = bootstrap();
|
|
14
|
+
registerModule({
|
|
15
|
+
adapter: asValue(this),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
abstract getConfig(): Promise<ConfigInterface>;
|
|
20
|
+
|
|
21
|
+
public async init(): Promise<void> {
|
|
22
|
+
const config = await this.getConfig();
|
|
23
|
+
if (config == null) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const {
|
|
27
|
+
sourceColor,
|
|
28
|
+
contrastLevel = 0,
|
|
29
|
+
isDark = false,
|
|
30
|
+
variant = tonalSpotVariant,
|
|
31
|
+
palettes,
|
|
32
|
+
colors,
|
|
33
|
+
useDefaultColors = true,
|
|
34
|
+
plugins,
|
|
35
|
+
} = config;
|
|
36
|
+
this.api.themes.create({
|
|
37
|
+
contrastLevel: contrastLevel,
|
|
38
|
+
isDark: isDark,
|
|
39
|
+
sourceColorHex: sourceColor,
|
|
40
|
+
variant: variant,
|
|
41
|
+
});
|
|
42
|
+
if (palettes) {
|
|
43
|
+
Object.entries(palettes).forEach(([key, value]) =>
|
|
44
|
+
this.api.themes.addCustomPalette(key, value),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (useDefaultColors) {
|
|
48
|
+
this.api.colors.addColors(defaultColors);
|
|
49
|
+
}
|
|
50
|
+
if (colors) {
|
|
51
|
+
this.api.colors.addColors(colors);
|
|
52
|
+
}
|
|
53
|
+
if (plugins) {
|
|
54
|
+
plugins.forEach((plugin) => {
|
|
55
|
+
this.api.plugins.addPlugin(plugin);
|
|
56
|
+
});
|
|
57
|
+
this.api.plugins.initPlugins(this.api);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public load() {
|
|
62
|
+
this.api.plugins.loadPlugins();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { VariantEntity } from '../theme';
|
|
2
1
|
import { AddColorsOptions } from '../color';
|
|
3
|
-
import {
|
|
2
|
+
import { Variant } from '../theme';
|
|
3
|
+
import { PluginAbstract } from '../plugin';
|
|
4
4
|
|
|
5
5
|
export interface ConfigInterface {
|
|
6
6
|
sourceColor: string;
|
|
7
|
-
contrastLevel?:
|
|
7
|
+
contrastLevel?: number;
|
|
8
8
|
isDark?: boolean;
|
|
9
|
-
variant?:
|
|
9
|
+
variant?: Variant;
|
|
10
10
|
colors?: AddColorsOptions | AddColorsOptions[];
|
|
11
11
|
useDefaultColors?: boolean;
|
|
12
12
|
palettes?: Record<string, string>;
|
|
13
|
-
plugins?:
|
|
13
|
+
plugins?: PluginAbstract<any, any>[];
|
|
14
14
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConfigInterface } from './config.interface';
|
|
2
|
+
|
|
3
|
+
export function defineConfig(configObject: ConfigInterface): ConfigInterface {
|
|
4
|
+
if (!configObject || typeof configObject !== 'object') {
|
|
5
|
+
throw new Error('The configuration is missing or not an object');
|
|
6
|
+
}
|
|
7
|
+
if (!('sourceColor' in configObject)) {
|
|
8
|
+
throw new Error('Invalid configuration');
|
|
9
|
+
}
|
|
10
|
+
return configObject as ConfigInterface;
|
|
11
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { AdapterAbstract } from './adapter.abstract';
|
|
4
|
+
import { ConfigInterface } from './config.interface';
|
|
5
|
+
import { Constructor } from 'type-fest';
|
|
6
|
+
|
|
7
|
+
export function FileAdapterMixin<
|
|
8
|
+
TBase extends Constructor<AdapterAbstract> &
|
|
9
|
+
Constructor<{
|
|
10
|
+
getConfig: () => Promise<ConfigInterface>;
|
|
11
|
+
}>,
|
|
12
|
+
>(Base: TBase) {
|
|
13
|
+
return class extends Base {
|
|
14
|
+
constructor(...args: any[]) {
|
|
15
|
+
super(...args); // Appel du constructeur de la classe Base avec les arguments transmis
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async ensureOutDir(dirPath: string): Promise<void> {
|
|
19
|
+
try {
|
|
20
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
21
|
+
console.log(`Répertoire vérifié/créé avec succès : ${dirPath}`);
|
|
22
|
+
} catch (error) {
|
|
23
|
+
console.error(
|
|
24
|
+
`Erreur lors de la création du répertoire : ${dirPath}`,
|
|
25
|
+
error,
|
|
26
|
+
);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async writeFile(filePath: string, content: string): Promise<void> {
|
|
32
|
+
try {
|
|
33
|
+
const dirPath = path.dirname(filePath); // Extraction du répertoire cible
|
|
34
|
+
await this.ensureOutDir(dirPath); // S'assurer que le répertoire existe
|
|
35
|
+
await fs.writeFile(filePath, content, 'utf-8');
|
|
36
|
+
console.log(`Fichier écrit avec succès : ${filePath}`);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(
|
|
39
|
+
`Erreur lors de l'écriture du fichier : ${filePath}`,
|
|
40
|
+
error,
|
|
41
|
+
);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async readFile(filePath: string): Promise<string> {
|
|
47
|
+
try {
|
|
48
|
+
const data = await fs.readFile(filePath, 'utf-8');
|
|
49
|
+
return data;
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error(
|
|
52
|
+
`Erreur lors de la lecture du fichier : ${filePath}`,
|
|
53
|
+
error,
|
|
54
|
+
);
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async deleteFile(filePath: string): Promise<void> {
|
|
60
|
+
try {
|
|
61
|
+
await fs.unlink(filePath);
|
|
62
|
+
console.log(`Fichier supprimé avec succès : ${filePath}`);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error(
|
|
65
|
+
`Erreur lors de la suppression du fichier : ${filePath}`,
|
|
66
|
+
error,
|
|
67
|
+
);
|
|
68
|
+
throw error;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|