@greensight/gts 1.0.0-alpha.9 → 1.0.0-beta.1
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/README.md +55 -28
- package/classes/TokenManager/index.d.ts +19 -4
- package/classes/TokenManager/index.d.ts.map +1 -1
- package/classes/TokenManager/types/ds.d.ts +23 -12
- package/classes/TokenManager/types/ds.d.ts.map +1 -1
- package/classes/TokenManager/types/figma.d.ts +11 -3
- package/classes/TokenManager/types/figma.d.ts.map +1 -1
- package/commands/generate/index.d.ts.map +1 -1
- package/common/lodash.d.ts +8 -0
- package/common/lodash.d.ts.map +1 -0
- package/index.cjs +96 -5
- package/index.mjs +1039 -493
- package/modules/breakpoints/breakpointsFromTokenManager/index.d.ts +2 -0
- package/modules/breakpoints/breakpointsFromTokenManager/index.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsFromTokenManager/module.d.ts +13 -0
- package/modules/breakpoints/breakpointsFromTokenManager/module.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsFromTokenManager/utils.d.ts +8 -0
- package/modules/breakpoints/breakpointsFromTokenManager/utils.d.ts.map +1 -0
- package/modules/breakpoints/index.d.ts +3 -0
- package/modules/breakpoints/index.d.ts.map +1 -0
- package/modules/breakpoints/types.d.ts +6 -0
- package/modules/breakpoints/types.d.ts.map +1 -0
- package/modules/breakpoints/utils.d.ts +16 -0
- package/modules/breakpoints/utils.d.ts.map +1 -0
- package/modules/colors/colorsFromTokenManager/index.d.ts +2 -0
- package/modules/colors/colorsFromTokenManager/index.d.ts.map +1 -0
- package/modules/colors/{colorsFromTokenManager.d.ts → colorsFromTokenManager/module.d.ts} +4 -7
- package/modules/colors/colorsFromTokenManager/module.d.ts.map +1 -0
- package/modules/colors/colorsFromTokenManager/utils.d.ts +3 -0
- package/modules/colors/colorsFromTokenManager/utils.d.ts.map +1 -0
- package/modules/colors/index.d.ts +0 -2
- package/modules/colors/index.d.ts.map +1 -1
- package/modules/colors/utils.d.ts +8 -33
- package/modules/colors/utils.d.ts.map +1 -1
- package/modules/container/containerFromTokenManager/index.d.ts +2 -0
- package/modules/container/containerFromTokenManager/index.d.ts.map +1 -0
- package/modules/container/containerFromTokenManager/module.d.ts +13 -0
- package/modules/container/containerFromTokenManager/module.d.ts.map +1 -0
- package/modules/container/index.d.ts +3 -0
- package/modules/container/index.d.ts.map +1 -0
- package/modules/container/types.d.ts +5 -0
- package/modules/container/types.d.ts.map +1 -0
- package/modules/container/utils.d.ts +12 -0
- package/modules/container/utils.d.ts.map +1 -0
- package/modules/index.d.ts +5 -0
- package/modules/index.d.ts.map +1 -1
- package/modules/shadows/index.d.ts +3 -0
- package/modules/shadows/index.d.ts.map +1 -0
- package/modules/shadows/shadowsFromTokenManager.d.ts +13 -0
- package/modules/shadows/shadowsFromTokenManager.d.ts.map +1 -0
- package/modules/shadows/types.d.ts +6 -0
- package/modules/shadows/types.d.ts.map +1 -0
- package/modules/shadows/utils.d.ts +22 -0
- package/modules/shadows/utils.d.ts.map +1 -0
- package/modules/typography/index.d.ts +2 -0
- package/modules/typography/index.d.ts.map +1 -0
- package/modules/typography/types.d.ts +10 -0
- package/modules/typography/types.d.ts.map +1 -0
- package/modules/typography/typographyFromTokenManager/index.d.ts +2 -0
- package/modules/typography/typographyFromTokenManager/index.d.ts.map +1 -0
- package/modules/typography/typographyFromTokenManager/module.d.ts +19 -0
- package/modules/typography/typographyFromTokenManager/module.d.ts.map +1 -0
- package/modules/typography/utils.d.ts +56 -0
- package/modules/typography/utils.d.ts.map +1 -0
- package/modules/utilities/index.d.ts +4 -0
- package/modules/utilities/index.d.ts.map +1 -0
- package/modules/utilities/types.d.ts +48 -0
- package/modules/utilities/types.d.ts.map +1 -0
- package/modules/utilities/utilitiesFromTokenManager/index.d.ts +2 -0
- package/modules/utilities/utilitiesFromTokenManager/index.d.ts.map +1 -0
- package/modules/utilities/utilitiesFromTokenManager/module.d.ts +4 -0
- package/modules/utilities/utilitiesFromTokenManager/module.d.ts.map +1 -0
- package/modules/utilities/utils.d.ts +80 -0
- package/modules/utilities/utils.d.ts.map +1 -0
- package/package.json +1 -2
- package/temporarilyUnnecessary/colorsFromStyles.d.ts +1 -0
- package/temporarilyUnnecessary/colorsFromStyles.d.ts.map +1 -0
- package/temporarilyUnnecessary/colorsFromVariables.d.ts +1 -0
- package/temporarilyUnnecessary/colorsFromVariables.d.ts.map +1 -0
- package/temporarilyUnnecessary/utils.d.ts +1 -0
- package/temporarilyUnnecessary/utils.d.ts.map +1 -0
- package/modules/colors/colorsFromStyles.d.ts +0 -16
- package/modules/colors/colorsFromStyles.d.ts.map +0 -1
- package/modules/colors/colorsFromTokenManager.d.ts.map +0 -1
- package/modules/colors/colorsFromVariables.d.ts +0 -16
- package/modules/colors/colorsFromVariables.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,68 +1,95 @@
|
|
|
1
1
|
# Greensight Token System
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Генерация дизайн-токенов из JSON-файлов, описанных в `manifest.json` (экспорт из Figma / JSON в духе DTCG), с загрузкой через `TokenManager`.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Ожидаемая структура экспорта соответствует плагину Figma **[Design Tokens Manager](https://www.figma.com/community/plugin/1263743870981744253/design-tokens-manager)**.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
**Полная документация:** [docs/README.md](docs/README.md)
|
|
8
|
+
|
|
9
|
+
## Установка
|
|
10
|
+
|
|
11
|
+
Как dev-зависимость:
|
|
8
12
|
|
|
9
13
|
```bash
|
|
10
14
|
npm install --save-dev @greensight/gts
|
|
11
|
-
#
|
|
15
|
+
# или
|
|
12
16
|
pnpm add -D @greensight/gts
|
|
13
|
-
#
|
|
17
|
+
# или
|
|
14
18
|
yarn add --dev @greensight/gts
|
|
15
19
|
```
|
|
16
20
|
|
|
17
|
-
##
|
|
21
|
+
## Использование
|
|
18
22
|
|
|
19
|
-
###
|
|
23
|
+
### Инициализация конфигурации
|
|
20
24
|
|
|
21
25
|
```bash
|
|
22
26
|
npx gts-init
|
|
23
27
|
```
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
Создаёт пустой `gts.config.ts` в корне проекта.
|
|
26
30
|
|
|
27
|
-
###
|
|
31
|
+
### Генерация токенов
|
|
28
32
|
|
|
29
33
|
```bash
|
|
30
34
|
npx gts-generate
|
|
31
35
|
```
|
|
32
36
|
|
|
33
|
-
|
|
37
|
+
Читает `gts.config.ts`, загружает токены из каталога, указанного в `manifest` (в нём должен быть `manifest.json`), и запускает настроенные модули.
|
|
38
|
+
|
|
39
|
+
## Конфигурация
|
|
34
40
|
|
|
35
|
-
|
|
41
|
+
Создайте `gts.config.ts` в корне проекта. Укажите в `manifest` папку с `manifest.json` и добавьте модули из `@greensight/gts`:
|
|
36
42
|
|
|
37
43
|
```typescript
|
|
38
|
-
import {
|
|
44
|
+
import {
|
|
45
|
+
breakpointsFromTokenManager,
|
|
46
|
+
colorsFromTokenManager,
|
|
47
|
+
containerFromTokenManager,
|
|
48
|
+
shadowsFromTokenManager,
|
|
49
|
+
typographyFromTokenManager,
|
|
50
|
+
utilitiesFromTokenManager,
|
|
51
|
+
} from '@greensight/gts';
|
|
39
52
|
|
|
40
53
|
export default {
|
|
41
54
|
figmaToken: 'your-figma-token',
|
|
42
55
|
fileId: 'your-figma-file-id',
|
|
56
|
+
manifest: './path/to/tokens-dir',
|
|
43
57
|
modules: [
|
|
44
|
-
|
|
45
|
-
input: {
|
|
46
|
-
output: {
|
|
58
|
+
colorsFromTokenManager({
|
|
59
|
+
input: { includeStyles: true },
|
|
60
|
+
output: { dir: './dist/colors' },
|
|
61
|
+
}),
|
|
62
|
+
breakpointsFromTokenManager({
|
|
63
|
+
output: { dir: './dist/breakpoints' },
|
|
64
|
+
}),
|
|
65
|
+
containerFromTokenManager({
|
|
66
|
+
output: { dir: './dist/container' },
|
|
67
|
+
}),
|
|
68
|
+
shadowsFromTokenManager({
|
|
69
|
+
output: { dir: './dist/shadows' },
|
|
47
70
|
}),
|
|
48
|
-
|
|
49
|
-
input: {
|
|
50
|
-
|
|
71
|
+
typographyFromTokenManager({
|
|
72
|
+
input: {
|
|
73
|
+
breakpoints: { sm: 'mobile', md: 'tablet', lg: 'desktop' },
|
|
74
|
+
fluid: true,
|
|
75
|
+
},
|
|
76
|
+
output: { dir: './dist/typography' },
|
|
77
|
+
}),
|
|
78
|
+
utilitiesFromTokenManager({
|
|
79
|
+
input: {
|
|
80
|
+
variablePath: 'radius',
|
|
81
|
+
breakpoints: { sm: 'mobile', md: 'tablet', lg: 'desktop' },
|
|
82
|
+
},
|
|
83
|
+
output: { dir: './dist/utilities' },
|
|
51
84
|
}),
|
|
52
85
|
],
|
|
53
86
|
};
|
|
54
87
|
```
|
|
55
88
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Generates color tokens from Figma styles. Fetches styles from Figma API and processes them.
|
|
61
|
-
|
|
62
|
-
### colorsFromVariables
|
|
63
|
-
|
|
64
|
-
Generates color tokens directly from variable files (JSON format).
|
|
89
|
+
- **Справка по полям конфига:** [docs/configuration.md](docs/configuration.md)
|
|
90
|
+
- **Архитектура и поток данных:** [docs/architecture.md](docs/architecture.md)
|
|
91
|
+
- **API модулей (таблицы input/output):** [docs/modules/](docs/modules/)
|
|
65
92
|
|
|
66
|
-
##
|
|
93
|
+
## Лицензия
|
|
67
94
|
|
|
68
95
|
MIT
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IDSTokenFile, IDSTokenVariable, IDSTokenVariableValue } from './types';
|
|
2
2
|
export declare class TokenManager {
|
|
3
3
|
private tokensDir;
|
|
4
4
|
private manifestPath;
|
|
@@ -45,11 +45,11 @@ export declare class TokenManager {
|
|
|
45
45
|
/**
|
|
46
46
|
* Get all variables (flattened tokens from collections)
|
|
47
47
|
*/
|
|
48
|
-
getVariables():
|
|
48
|
+
getVariables(): IDSTokenFile['variables'];
|
|
49
49
|
/**
|
|
50
50
|
* Get resolved styles
|
|
51
51
|
*/
|
|
52
|
-
getStyles():
|
|
52
|
+
getStyles(): IDSTokenFile['styles'];
|
|
53
53
|
/**
|
|
54
54
|
* Checks if a value is a variable reference path
|
|
55
55
|
* @param value - Value to check
|
|
@@ -62,10 +62,25 @@ export declare class TokenManager {
|
|
|
62
62
|
* @returns variable path if value is a valid reference, undefined otherwise
|
|
63
63
|
*/
|
|
64
64
|
getVariablePath(value: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* Resolves a variable reference by validating, parsing and getting the token
|
|
67
|
+
* @param value - Value to resolve (should be a variable reference like "{variable.path}")
|
|
68
|
+
* @param mode - Mode name to get value for (optional)
|
|
69
|
+
* @returns resolved token variable or undefined if not found or invalid
|
|
70
|
+
*/
|
|
71
|
+
resolveVariableValue(value: IDSTokenVariable['value']): IDSTokenVariable['value'] | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* Resolves a variable reference by validating, parsing and getting the token
|
|
74
|
+
* @param value - Value to resolve (should be a variable reference like "{variable.path}")
|
|
75
|
+
* @param mode - Mode name to get value for (optional)
|
|
76
|
+
* @returns resolved token variable or undefined if not found or invalid
|
|
77
|
+
*/
|
|
78
|
+
resolveVariableValueString(value: string, mode?: string): IDSTokenVariableValue | undefined;
|
|
65
79
|
/**
|
|
66
80
|
* Gets a nested token value by path, similar to lodash.get
|
|
67
81
|
* @param variablePath - Dot-separated string path or array of path segments
|
|
82
|
+
* @param mode - Mode name to get value for (optional)
|
|
68
83
|
*/
|
|
69
|
-
getToken(variablePath: string
|
|
84
|
+
getToken(variablePath: string, mode?: string): string | undefined;
|
|
70
85
|
}
|
|
71
86
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/classes/TokenManager/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/class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MAAM,GAAG,qBAAqB,GAAG,SAAS;IASlG;;;;OAIG;IACI,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAkB3E"}
|
|
@@ -2,24 +2,35 @@ import { TFigmaToken, TFigmaTokenType } from './figma';
|
|
|
2
2
|
export type TDSTokenValue<T extends TFigmaTokenType> = Extract<TFigmaToken, {
|
|
3
3
|
$type: T;
|
|
4
4
|
}>['$value'];
|
|
5
|
-
export type
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
export type IDSTokenVariableValue = string;
|
|
6
|
+
export type TDSTokenVariableValueWithModes = Record<string, IDSTokenVariableValue>;
|
|
7
|
+
export interface IBaseToken<V, T> {
|
|
8
|
+
type: T;
|
|
9
|
+
value: V;
|
|
9
10
|
description?: string;
|
|
10
11
|
}
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
export interface IDSTokenVariable extends IBaseToken<TDSTokenVariableValueWithModes, 'color' | 'dimension' | 'string'> {
|
|
13
|
+
}
|
|
14
|
+
export interface IDSTokenStyleColor extends IBaseToken<TDSTokenValue<'color'>, 'color'> {
|
|
15
|
+
}
|
|
16
|
+
export interface IDSTokenStyleShadow extends IBaseToken<TDSTokenValue<'shadow'>, 'shadow'> {
|
|
17
|
+
}
|
|
18
|
+
export interface IDSTokenStyleTypography extends IBaseToken<TDSTokenValue<'typography'>, 'typography'> {
|
|
19
|
+
}
|
|
20
|
+
export interface IDSTokenStyleGrid extends IBaseToken<TDSTokenValue<'grid'>, 'grid'> {
|
|
21
|
+
}
|
|
22
|
+
export type TDSTokenVariablesValue<TTokenValue> = Record<string, TTokenValue> | TTokenValue;
|
|
23
|
+
export interface IDSTokens<V> {
|
|
24
|
+
[group: string]: V | IDSTokens<V>;
|
|
14
25
|
}
|
|
15
26
|
export interface IDSStyles {
|
|
16
|
-
|
|
17
|
-
effect
|
|
18
|
-
|
|
19
|
-
grid
|
|
27
|
+
color: IDSTokens<IDSTokenStyleColor>;
|
|
28
|
+
effect: IDSTokens<IDSTokenStyleShadow>;
|
|
29
|
+
text: IDSTokens<IDSTokenStyleTypography>;
|
|
30
|
+
grid: IDSTokens<IDSTokenStyleGrid>;
|
|
20
31
|
}
|
|
21
32
|
export interface IDSTokenFile {
|
|
22
|
-
variables: IDSTokens
|
|
33
|
+
variables: IDSTokens<IDSTokenVariable>;
|
|
23
34
|
styles: IDSStyles;
|
|
24
35
|
}
|
|
25
36
|
//# sourceMappingURL=ds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ds.d.ts","sourceRoot":"","sources":["../../../../src/classes/TokenManager/types/ds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"ds.d.ts","sourceRoot":"","sources":["../../../../src/classes/TokenManager/types/ds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE5D,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,eAAe,IAAI,OAAO,CAAC,WAAW,EAAE;IAAE,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEpG,MAAM,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,8BAA8B,GAAG,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC;AAEnF,MAAM,WAAW,UAAU,CAAC,CAAC,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC;IACR,KAAK,EAAE,CAAC,CAAC;IACT,WAAW,CAA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'linear' | 'conic';
|
|
9
|
+
angle: number;
|
|
10
|
+
stops: {
|
|
11
|
+
color: string;
|
|
12
|
+
position: number;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
7
15
|
export interface IColorFigmaToken extends IBaseFigmaToken {
|
|
8
16
|
$type: 'color';
|
|
9
|
-
$value: string;
|
|
17
|
+
$value: string | IColorFigmaGradientValue;
|
|
10
18
|
}
|
|
11
19
|
export interface IDimensionFigmaToken extends IBaseFigmaToken {
|
|
12
20
|
$type: 'dimension';
|
|
@@ -25,7 +33,7 @@ export interface ITypographyValue {
|
|
|
25
33
|
textTransform: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
26
34
|
textDecoration: 'none' | 'underline' | 'line-through';
|
|
27
35
|
}
|
|
28
|
-
export interface
|
|
36
|
+
export interface ITypographyFigmaToken extends IBaseFigmaToken {
|
|
29
37
|
$type: 'typography';
|
|
30
38
|
$value: ITypographyValue;
|
|
31
39
|
}
|
|
@@ -55,7 +63,7 @@ export interface IGridFigmaToken extends IBaseFigmaToken {
|
|
|
55
63
|
$value: IGridValue[];
|
|
56
64
|
}
|
|
57
65
|
export type TFigmaTokenValue = string | ITokenFile | TFigmaToken | ITypographyValue | IShadowValue[] | IGridValue[];
|
|
58
|
-
export type TFigmaToken = IColorFigmaToken | IDimensionFigmaToken |
|
|
66
|
+
export type TFigmaToken = IColorFigmaToken | IDimensionFigmaToken | ITypographyFigmaToken | IShadowFigmaToken | IGridFigmaToken | IStringFigmaToken;
|
|
59
67
|
export interface IModeFiles {
|
|
60
68
|
[modeName: string]: string[];
|
|
61
69
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figma.d.ts","sourceRoot":"","sources":["../../../../src/classes/TokenManager/types/figma.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,WAAW,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,CAAC;AAElG,MAAM,WAAW,eAA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B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IACzB,CAAC,cAAc,EAAE,MAAM,GAAG,WAAW,CAAC;CACzC;AAED,MAAM,WAAW,YAAY;IACzB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,YAAY,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;CACzB;AAGD,MAAM,WAAW,UAAU;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC;CAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/generate/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/generate/index.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,qBAgBpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const get: (obj: any, path: string | string[]) => any;
|
|
2
|
+
export declare const merge: (target: any, source: any) => any;
|
|
3
|
+
/**
|
|
4
|
+
* Performs a deep comparison between two values to determine if they are equivalent.
|
|
5
|
+
* Similar to lodash.isEqual
|
|
6
|
+
*/
|
|
7
|
+
export declare function isEqual(value: any, other: any): boolean;
|
|
8
|
+
//# sourceMappingURL=lodash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lodash.d.ts","sourceRoot":"","sources":["../../src/common/lodash.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,GAAG,GAAI,KAAK,GAAG,EAAE,MAAM,MAAM,GAAG,MAAM,EAAE,KAAG,GAQvD,CAAC;AAEF,eAAO,MAAM,KAAK,GAAI,QAAQ,GAAG,EAAE,QAAQ,GAAG,KAAG,GAoBhD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CA+DvD"}
|
package/index.cjs
CHANGED
|
@@ -1,8 +1,99 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`
|
|
1
|
+
"use strict";var je=Object.defineProperty;var ve=(t,e,o)=>e in t?je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var m=(t,e,o)=>ve(t,typeof e!="symbol"?e+"":e,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("path"),Me=require("ts-import"),C=require("node:fs"),w=require("node:fs/promises"),V=require("node:path"),h=class h{static resolveReadPath(e){if(!e||!e.trim())throw new Error("File path must be a non-empty string");return V.resolve(h.baseDir,e)}static resolveWritePath(e,o){const r=V.resolve(h.baseDir,o??"");return{targetDir:r,targetPath:V.resolve(r,e)}}static handleReadError(e,o){throw e.code==="ENOENT"?new Error(`File not found: ${o}`):new Error(`Failed to read file "${o}": ${e.message??String(e)}`)}static async read(e,o="utf8"){const r=h.resolveReadPath(e);try{return await w.readFile(r,{encoding:o})}catch(n){h.handleReadError(n,r)}}static async readBuffer(e){const o=h.resolveReadPath(e);try{return await w.readFile(o)}catch(r){h.handleReadError(r,o)}}static async readJson(e){const o=h.resolveReadPath(e);try{const r=await w.readFile(o,{encoding:"utf8"});try{return JSON.parse(r)}catch(n){throw new Error(`Failed to parse JSON from "${o}": ${n.message}`)}}catch(r){h.handleReadError(r,o)}}static async write(e,o="",r={}){const{directory:n,overwrite:s=!0}=r,{targetDir:a,targetPath:l}=h.resolveWritePath(e,n);if(!s&&C.existsSync(l))throw new Error(`File ${l} already exists`);return await w.mkdir(a,{recursive:!0}),await w.writeFile(l,o,{encoding:"utf8"}),l}static async writeWithExtension(e,o,r="",n){const s=o.startsWith(".")?o:`.${o}`,a=`${e}${s}`;return h.write(a,r,n)}static exists(e){const o=h.resolveReadPath(e);return C.existsSync(o)}static async delete(e,o){const{targetPath:r}=h.resolveWritePath(e,o);C.existsSync(r)&&await w.rm(r,{recursive:!0,force:!0})}};m(h,"baseDir",process.cwd());let d=h;const S=class S{static async create(){if(d.exists(S.configFileName))throw new Error("The file already exists");await d.write(S.configFileName,"",{overwrite:!1})}async load(){try{const e=await Me.tsImport.compile(`${$.resolve(process.cwd(),S.configFileName)}`);if(!e)throw new Error;return e.default}catch(e){console.error("Cannot find module gts.config.ts",e)}}};m(S,"configFileName","gts.config.ts");let v=S;const Fe=t=>{const e=new URLSearchParams;return Object.keys(t).forEach(o=>{Array.isArray(t[o])?t[o].forEach(r=>e.append(`${o}[]`,r)):e.append(o,t[o])}),e},Ce=(t,e=50)=>{const o=[];for(let r=0;r<t.length;r+=e)o.push(t.slice(r,r+e));return o};class P{constructor(e,o){m(this,"figmaToken");m(this,"fileId");m(this,"onTimeMeasureHandler");this.figmaToken=e,this.fileId=o}setOnTimeMeasureHandler(e){this.onTimeMeasureHandler=e}static async returnJSON(e){const o=await e.json();if(!e.ok){let r="Request failed";throw new Error(r)}return o}async performControlledRequest(e,{params:o={},timeout:r=3e4,abortController:n=new AbortController}={}){var g;if(!this.figmaToken||!this.fileId)throw new Error("Добавьте figmaToken и figmaId");const s=Object.entries(o).reduce((p,[b,k])=>typeof k<"u"?{...p,[b]:k}:p,{}),a=`https://api.figma.com/v1${e}${s&&Object.keys(s).length?`?${Fe(s)}`:""}`;console.log("endpoinWithParams=",a);const l=setTimeout(()=>n.abort(),r),i={"Content-Type":"application/json",...this.figmaToken&&{"X-Figma-Token":this.figmaToken}},c={method:"GET",headers:i,signal:n.signal},u=performance.now(),y=await fetch(`${a}`,c);clearTimeout(l);const f=performance.now()-u;return(g=this.onTimeMeasureHandler)==null||g.call(this,a,i,f),y}async request(e,o){var n;const r=await this.performControlledRequest(e,{...o});return(n=r.headers.get("content-type"))!=null&&n.includes("application/json")?P.returnJSON(r):r}async getComponents(){return this.request(`/files/${this.fileId}/components`)}async getStyles(){return this.request(`/files/${this.fileId}/styles`)}async getNodes(e){const o=Ce(e).map(s=>this.request(`/files/${this.fileId}/nodes`,{params:{ids:s.join(",")}})),r=await Promise.all(o);return{...r[0],nodes:r.reduce((s,a)=>({...s,...a.nodes}),{})}}}const Q=(t,e)=>{const o=Array.isArray(e)?e:e.split(".");let r=t;for(const n of o){if(r==null||typeof r!="object")return;r=r[n]}return r},Z=(t,e)=>{if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return e;const o={...t};for(const r in e)e.hasOwnProperty(r)&&(typeof e[r]=="object"&&e[r]!==null&&typeof o[r]=="object"&&o[r]!==null?o[r]=Z(o[r],e[r]):o[r]=e[r]);return o};function x(t,e){if(t===e)return!0;if(t==null||e==null)return t===e;if(typeof t!=typeof e)return!1;if(t instanceof Date&&e instanceof Date)return t.getTime()===e.getTime();if(t instanceof RegExp&&e instanceof RegExp)return t.toString()===e.toString();if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return!1;for(let o=0;o<t.length;o++)if(!x(t[o],e[o]))return!1;return!0}if(typeof t=="object"&&typeof e=="object"){const o=Object.keys(t),r=Object.keys(e);if(o.length!==r.length)return!1;for(const n of o)if(!r.includes(n)||!x(t[n],e[n]))return!1;return!0}return!1}const U={color:{},effect:{},text:{},grid:{}};class X{constructor(e){m(this,"tokensDir");m(this,"manifestPath");m(this,"variables");m(this,"styles");m(this,"loaded",!1);this.tokensDir=e||"",this.manifestPath=$.join(this.tokensDir,"manifest.json")}isLoaded(){return this.loaded&&!!this.variables&&!!this.styles}normalizeKey(e){const o=e.trim();return o&&o.replace(/[-_\s]+/g," ").split(" ").filter(r=>r.length).map((r,n)=>{const s=r.charAt(0),a=r.slice(1);return n===0?r.toLowerCase():s.toUpperCase()+a}).join("")}parseVariableString(e){if(typeof e!="string")return e;const o=/^\{(.+)\}$/,r=e.match(o);if(r){const n=r[1].trim();return`{${this.normalizeKey(n)}}`}return e}createVariableFileList(e){return Object.entries(e).flatMap(([o,r])=>Object.entries(r.modes).flatMap(([n,s])=>s.map(a=>({fileName:a,modeName:this.normalizeKey(n.trim()),collectionName:o}))))}parseValue(e){return e&&(typeof e=="string"?this.parseVariableString(e):typeof e!="object"?e:Array.isArray(e)?e.map(o=>this.parseValue(o)):Object.entries(e).reduce((o,[r,n])=>({...o,[r]:this.parseValue(n)}),{}))}getTokensFromFile(e,o){return Object.entries(e).reduce((r,[n,s])=>"$type"in s&&"$value"in s?{...r,[this.normalizeKey(n)]:{type:s.$type,description:s.$description,value:o?{[this.normalizeKey(o)]:this.parseValue(s.$value)}:this.parseValue(s.$value)}}:{...r,[this.normalizeKey(n)]:this.getTokensFromFile(s,o)},{})}processTokensFile(e,o,r){const n=this.normalizeKey(r),s=this.getTokensFromFile(e,o);return{[n]:s}}async loadVariableFiles(e){return Promise.all(e.map(async({fileName:o,modeName:r,collectionName:n})=>{try{const s=$.join(this.tokensDir,o),a=await d.readJson(s);return this.processTokensFile(a,r,n)}catch(s){return console.warn(`Failed to load variable file: ${$.join(this.tokensDir,o)}`,s),{}}}))}mergeVariables(e){return e.reduce((o,r)=>Z(o,r),{})}async loadTokenVariables(e){try{const o=this.createVariableFileList(e),r=await this.loadVariableFiles(o);return this.mergeVariables(r)}catch(o){throw new Error(`Failed to load token variables from ${this.tokensDir}: ${o}`)}}createStyleFileList(e){return Object.entries(e).flatMap(([o,r])=>(r==null?void 0:r.map(n=>({styleType:o,fileName:n})))||[])}async loadStyleFiles(e){return(await Promise.all(e.map(async({styleType:r,fileName:n})=>{try{const s=$.join(this.tokensDir,n),a=await d.readJson(s);return{styleType:r,styleTokens:a}}catch(s){return console.warn(`Failed to load style file: ${$.join(this.tokensDir,n)}`,s),{styleType:r,styleTokens:{}}}}))).reduce((r,n)=>({...r,[n.styleType]:this.getTokensFromFile(n.styleTokens,"")}),{...U})}async loadStyles(e){if(!e)return{...U};const o=this.createStyleFileList(e);return await this.loadStyleFiles(o)}async load(){if(this.loaded)return;const e=await d.readJson(this.manifestPath);if(!e)throw new Error(`Failed to load manifest file from: ${this.manifestPath}`);this.variables=await this.loadTokenVariables(e.collections),this.styles=await this.loadStyles(e.styles),this.loaded=!0}getVariables(){if(!this.loaded||!this.variables)throw new Error("Tokens not loaded. Call load() first.");return this.variables}getStyles(){if(!this.loaded||!this.styles)throw new Error("Tokens not loaded. Call load() first.");return this.styles}isVariableReference(e){return typeof e!="string"?!1:/^\{.+\}$/.test(e)}getVariablePath(e){return e.slice(1,-1)}resolveVariableValue(e){if(typeof e=="object")return Object.keys(e).reduce((o,r)=>{const n=e[r],s=this.resolveVariableValueString(n,r);return s&&(o[r]=s),o},{})}resolveVariableValueString(e,o){if(!this.isVariableReference(e))return e;const r=this.getVariablePath(e),n=this.getToken(r,o);if(n)return this.resolveVariableValueString(n,o)}getToken(e,o){if(!this.loaded||!this.variables)throw new Error("Tokens not loaded. Call load() first.");for(const r of Object.values(this.variables)){const n=Q(r,e);if(n!=null&&n.value&&typeof n.value=="object"){if(o)return n.value[o];{const s=Object.keys(n.value)[0];return n.value[s]}}}}}const Ve=async()=>{const e=await new v().load();if(!e)throw new Error("Заполнить ошибку через нейронку");const{figmaToken:o,fileId:r,modules:n,manifest:s}=e,a=new P(o,r),l=new X(s);s&&d.exists(s)&&await l.load(),await Promise.all(n.map(i=>i.executor({figmaApiClient:a,tokenManagerClient:l})))},Ne=async()=>{await v.create(),console.log("\x1B[32m%s\x1B[0m","✔️ Configuration file created gts.config.ts")},Y=["xxxl","xxl","xl","lg","md","sm","xs","xxs","xxxs"],xe=t=>parseInt(t.value,10),Oe=t=>t.reduce((e,o)=>({...e,[o.name]:xe(o)}),{}),Pe=async(t,e)=>{await d.delete(t,e)},Ee=async(t,e,o)=>{await d.write(t,e,{directory:o})},N=async(t,e,o)=>{await Pe(t,o),await Ee(t,e,o)},Be=t=>{const e=t.map(({name:o,value:r})=>` --${o}: ${r};`);return e.length?`.breakpoint-variables {
|
|
2
|
+
${e.join(`
|
|
3
|
+
`)}
|
|
4
|
+
}
|
|
5
|
+
`:""},Re=t=>{var r;const e=t.map(({name:n,value:s})=>` ${n}: ${s}`),o=(r=t.at(-1))==null?void 0:r.name;return!e.length||!o?"":`$breakpointList: (
|
|
6
|
+
${e.join(`,
|
|
7
|
+
`)}
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
$defaultBreakpoint: '${o}';
|
|
11
|
+
`},Ae=t=>[`const breakpoints = ${JSON.stringify(t,null,4)} as const;`,"","const BREAKPOINTS_NAMES = Object.keys(breakpoints);","","type BreakpointsKeysType = keyof typeof breakpoints;","type AllowMedia = 'all' | BreakpointsKeysType;","","export { breakpoints, BREAKPOINTS_NAMES };","export type { BreakpointsKeysType, AllowMedia };",""].join(`
|
|
12
|
+
`),Ue=async({breakpointTokens:t,dir:e})=>{const o=Oe(t),r=Be(t),n=Re(t),s=Ae(o);await Promise.all([N("styles.css",r,e),N("styles.scss",n,e),N("index.ts",s,e)])},De=(t,e)=>{const o=Object.keys(t).filter(s=>!isNaN(Number(s))).sort((s,a)=>Number(s)-Number(a));if(o.length>e.length)throw new Error(`Not enough breakpoint names provided. Found ${o.length} breakpoints in data, but only ${e.length} names specified: ${e.join(", ")}`);const n=Object.keys(t).filter(s=>isNaN(Number(s)));if(n.length>0)throw new Error(`Found non-numeric breakpoint keys in grid data: ${n.join(", ")}. All breakpoint keys must be numeric values.`);return o.map((s,a)=>({name:e[e.length-1-a]||`bp-${s}`,value:s}))},Ke=({input:t={},output:{dir:e}})=>({name:"breakpoints/tokenManager",executor:async({tokenManagerClient:o})=>{try{console.log("[breakpoints/tokenManager] Generating breakpoints from TokenManager...");const{names:r=Y}=t;if(!o.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const n=o.getStyles();if(!n.grid)throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");console.log("[breakpoints/tokenManager] Extracting breakpoints from grid styles...");const s=De(n.grid,r);if(!s.length){console.warn("[breakpoints/tokenManager] No breakpoints found in grid styles.");return}console.log(`[breakpoints/tokenManager] Found ${s.length} breakpoints: ${s.map(a=>a.name).join(", ")}`),console.log(`[breakpoints/tokenManager] Writing files to ${e}...`),await Ue({breakpointTokens:s,dir:e}),console.log("[breakpoints/tokenManager] ✅ Successfully generated breakpoint files")}catch(r){const n=r instanceof Error?r.message:String(r);throw console.error("[breakpoints/tokenManager] ❌ Failed to generate breakpoints:",n),r instanceof Error&&r.stack&&console.error("[breakpoints/tokenManager] Stack trace:",r.stack),r}}}),Le="styles.css",Ie="index.ts",D=(t,e)=>{if(!e.length)return"";const o=e.map(r=>` ${r}`).join(`
|
|
13
|
+
`);return`${t} {
|
|
14
|
+
${o}
|
|
15
|
+
}`},ze=t=>`.${t.replace(/\s+/g,"-").toLowerCase()}`,_=t=>`--cl-${t}`,We=t=>t.reduce((e,o)=>{const r=_(o.name);return typeof o.value=="object"?Object.entries(o.value).forEach(([n,s])=>{e[n]||(e[n]=[]),e[n].push(`${r}: ${s};`)}):e.root.push(`${r}: ${o.value};`),e},{root:[]}),Ge=t=>{const e=D(".color-variables",t.root),o=Object.entries(t).reduce((r,[n,s])=>{if(n==="root"||!s.length)return r;const a=D(ze(`${n}-color-variables`),s);return a&&r.push(a),r},[]).join(`
|
|
16
|
+
|
|
17
|
+
`);return[e,o].filter(Boolean).join(`
|
|
18
|
+
|
|
19
|
+
`)},qe=t=>`${`const colors = {
|
|
20
|
+
${t.map(r=>` '${r.name}': 'var(${_(r.name)})'`).join(`,
|
|
21
|
+
`)}
|
|
22
|
+
} as const;`}
|
|
23
|
+
|
|
24
|
+
type ColorsKeysType = keyof typeof colors;
|
|
25
|
+
|
|
26
|
+
export { colors, type ColorsKeysType };
|
|
27
|
+
`,Je=async({tsContent:t,cssContent:e,dir:o})=>{await d.delete(o);const r=d.write(Ie,t,{directory:o}),n=d.write(Le,e,{directory:o});await Promise.all([r,n])},He=async({colorTokens:t,dir:e})=>{const o=We(t),r=Ge(o),n=qe(t);await Je({tsContent:n,cssContent:r,dir:e})},M=t=>t.reduce((e,o)=>{const r=Number((o.position*100).toFixed(1));return[...e,`${o.color}${r>0&&r<100?` ${r}%`:""}`]},[]).join(", "),Qe=t=>{const e=M(t.stops);return`linear-gradient(${t.angle}deg, ${e})`},Ze=t=>`radial-gradient(circle, ${M(t.stops)})`,Xe=t=>{const e=M(t.stops);return`conic-gradient(from ${t.angle}deg, ${e})`},Ye=t=>{const e=M(t.stops);return`linear-gradient(${t.angle}deg, ${e})`},K=t=>typeof t=="string"?t:t.type==="linear"?Qe(t):t.type==="radial"?Ze(t):t.type==="conic"?Xe(t):t.type==="diamond"?Ye(t):"",ee=(t,e)=>Object.keys(t).reduce((o,r)=>{const n=t[r],s=e?`${e}-${r}`:r;if(n&&typeof n=="object"&&"type"in n&&"value"in n){const l=Object.keys(n.value),i=l.length>1?n.value:n.value[l[0]],c=typeof i=="object"?Object.keys(i).reduce((y,f)=>({...y,[f]:K(i[f])}),{}):K(i),u={[s]:c};return{...o,...u}}const a=ee(n,s);return{...o,...a}},{}),te=(t,e)=>Object.keys(t).reduce((o,r)=>{const n=t[r];if(n.type&&n.type!=="color")return o;if(n.type&&n.value){const a=typeof n.value=="string"?e.resolveVariableValueString(n.value,r):e.resolveVariableValue(n.value);return a?{...o,[r]:{...n,value:a}}:o}const s=te(n,e);return s?{...o,[r]:s}:o},{}),_e=({input:t={},output:{dir:e}})=>({name:"colors/tokenManager",executor:async({tokenManagerClient:o})=>{try{console.log("[colors/tokenManager] Generating colors from TokenManager...");const{includeVariables:r,includeStyles:n=!0}=t;if(!(r!=null&&r.length)&&!n)throw new Error("Either includeVariables or includeStyles must be enabled");if(!o.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const s=[],a=o.getVariables();if(n){const i=o.getStyles();console.log("[colors/tokenManager] Processing styles for colors..."),i.color&&s.push(i.color)}if(r!=null&&r.length){console.log(`[colors/tokenManager] Processing ${r.length} variable groups...`);const i=r.map(c=>a[c]).filter(Boolean);s.push(...i)}const l=s.map(i=>te(i,o)).flatMap(i=>Object.entries(ee(i,"")).reduce((c,[u,y])=>[...c,{name:u,value:y}],[]));if(l.length===0){console.warn("[colors/tokenManager] No color tokens generated");return}console.log(`[colors/tokenManager] Generated ${l.length} color tokens`),console.log(`[colors/tokenManager] Writing files to ${e}...`),await He({colorTokens:l,dir:e}),console.log("[colors/tokenManager] ✅ Successfully generated color files")}catch(r){const n=r instanceof Error?r.message:String(r);throw console.error("[colors/tokenManager] ❌ Failed to generate colors:",n),r instanceof Error&&r.stack&&console.error("[colors/tokenManager] Stack trace:",r.stack),r}}}),et=t=>` @media (width <= ${t.breakpoint}px) {
|
|
28
|
+
.container {
|
|
29
|
+
padding-left: ${t.offset};
|
|
30
|
+
padding-right: ${t.offset};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.containerTablet {
|
|
34
|
+
padding-left: ${t.offset};
|
|
35
|
+
padding-right: ${t.offset};
|
|
36
|
+
}
|
|
37
|
+
}`,tt=(t,e)=>{const o=e||"components",r=t.map(n=>et(n)).join(`
|
|
38
|
+
|
|
39
|
+
`);return`@layer ${o} {
|
|
3
40
|
${r}
|
|
4
|
-
}`},
|
|
41
|
+
}`},rt=()=>`import styles from './styles.module.css';
|
|
42
|
+
|
|
43
|
+
export const conatinerClassName = styles.container;
|
|
44
|
+
export const conatinerTabletClassName = styles.containerTablet;
|
|
45
|
+
`,L=async(t,e,o)=>{await d.delete(t,o),await d.write(t,e,{directory:o})},ot=async({containerTokens:t,dir:e,layer:o})=>{const r=tt(t,o),n=rt();await L("styles.module.css",r,e),await L("index.ts",n,e)},nt=t=>{const e=t.trim().toLowerCase();return e==="0"||e==="0px"},st=(t,e)=>Object.keys(t).filter(s=>!isNaN(Number(s))).sort((s,a)=>Number(a)-Number(s)).reduce((s,a)=>{const l=t[a];if(!l||!("value"in l)||!Array.isArray(l.value))return s;const i=l.value.find(u=>u.pattern==="columns");if(!(i!=null&&i.offset))return s;const c=e.resolveVariableValueString(i.offset);return!c||typeof c!="string"||nt(c)?s:[...s,{breakpoint:Number(a),offset:c}]},[]).reduce((s,a)=>{const l=s[s.length-1];return l&&x(l.offset,a.offset)||s.push(a),s},[]),at=({input:t={},output:{dir:e}})=>({name:"container/tokenManager",executor:async({tokenManagerClient:o})=>{try{console.log("[container/tokenManager] Generating container styles...");const{layer:r}=t;if(!o.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");console.log("[container/tokenManager] Extracting container tokens...");const n=o.getStyles();if(!n.grid)throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");const s=st(n.grid,o);if(!s.length){console.warn("[container/tokenManager] No container tokens found.");return}console.log(`[container/tokenManager] Found ${s.length} container tokens: ${s.map(a=>a.breakpoint).join(", ")}`),console.log(`[container/tokenManager] Writing files to ${e}...`),await ot({containerTokens:s,dir:e,layer:r}),console.log("[container/tokenManager] ✅ Successfully generated container files")}catch(r){const n=r instanceof Error?r.message:String(r);throw console.error("[container/tokenManager] ❌ Failed to generate container:",n),r instanceof Error&&r.stack&&console.error("[container/tokenManager] Stack trace:",r.stack),r}}}),it="styles.css",lt="index.ts",I=(t,e)=>{if(!e.length)return"";const o=e.map(r=>` ${r}`).join(`
|
|
46
|
+
`);return`${t} {
|
|
47
|
+
${o}
|
|
48
|
+
}`},ct=t=>`.${t.replace(/\s+/g,"-").toLowerCase()}`,re=t=>`--${t}`,ut=({offsetX:t,offsetY:e,blur:o,spread:r,color:n})=>`${t} ${e} ${o} ${r} ${n}`,dt=t=>t.reduce((e,o)=>{const r=re(o.name);return typeof o.value!="object"?(e.root.push(`${r}: ${o.value};`),e):Object.entries(o.value).reduce((n,[s,a])=>{const l=n[s]??[];return{...n,[s]:[...l,`${r}: ${a};`]}},e)},{root:[]}),yt=t=>{const e=I(".shadow-variables",t.root),o=Object.entries(t).reduce((r,[n,s])=>{if(n==="root"||!s.length)return r;const a=I(ct(`${n}-shadow-variables`),s);return a&&r.push(a),r},[]).join(`
|
|
49
|
+
|
|
50
|
+
`);return[e,o].filter(Boolean).join(`
|
|
51
|
+
|
|
52
|
+
`)},ft=t=>`${`const shadows = {
|
|
53
|
+
${t.map(r=>` '${r.name}': 'var(${re(r.name)})'`).join(`,
|
|
54
|
+
`)}
|
|
55
|
+
} as const;`}
|
|
56
|
+
|
|
57
|
+
type ShadowsKeysType = keyof typeof shadows;
|
|
58
|
+
|
|
59
|
+
export { shadows, type ShadowsKeysType };
|
|
60
|
+
`,gt=async({tsContent:t,cssContent:e,dir:o})=>{await d.delete(o);const r=d.write(lt,t,{directory:o}),n=d.write(it,e,{directory:o});await Promise.all([r,n])},pt=async({shadowTokens:t,dir:e})=>{const o=dt(t),r=yt(o),n=ft(t);await gt({tsContent:n,cssContent:r,dir:e})},oe=(t,e)=>Object.keys(t).reduce((o,r)=>{const n=t[r],s=e?`${e}-${r}`:r;if(n&&typeof n=="object"&&"type"in n&&"value"in n){const l={[s]:n.value.map(ut).join(", ")};return{...o,...l}}const a=oe(n,s);return{...o,...a}},{}),ht=({input:t={},output:{dir:e}})=>({name:"shadows/tokenManager",executor:async({tokenManagerClient:o})=>{try{console.log("[shadows/tokenManager] Generating shadows from TokenManager...");const{includeStyles:r=!0}=t;if(!r)throw new Error("includeStyles must be enabled for shadows generation");if(!o.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const n=[];if(r){const a=o.getStyles();console.log("[shadows/tokenManager] Processing styles for shadows..."),a.effect&&n.push(a.effect)}const s=n.flatMap(a=>Object.entries(oe(a,"")).reduce((l,[i,c])=>[...l,{name:i,value:c}],[]));if(s.length===0){console.warn("[shadows/tokenManager] No shadow tokens generated");return}console.log(`[shadows/tokenManager] Generated ${s.length} shadow tokens`),console.log(`[shadows/tokenManager] Writing files to ${e}...`),await pt({shadowTokens:s,dir:e}),console.log("[shadows/tokenManager] ✅ Successfully generated shadow files")}catch(r){const n=r instanceof Error?r.message:String(r);throw console.error("[shadows/tokenManager] ❌ Failed to generate shadows:",n),r instanceof Error&&r.stack&&console.error("[shadows/tokenManager] Stack trace:",r.stack),r}}}),bt="styles.module.css",mt="index.ts",kt="typography.ts",z="sans-serif",W=(t,e)=>{if(!e.length)return"";const o=e.map(r=>` ${r}`).join(`
|
|
61
|
+
`);return`${t} {
|
|
62
|
+
${o}
|
|
63
|
+
}`},ne=(t,e)=>{if(typeof t!="string")return t;const o=e[t]??t;return o.trim().toLowerCase().endsWith(z)?o:`${o}, ${z}`},G=(t,e)=>typeof t.fontFamily!="string"?t:{...t,fontFamily:ne(t.fontFamily,e)},T=(t,e)=>{const o={};return Object.entries(t).forEach(([r,n])=>{const s=r==="fontFamily"?ne(n,e):n,a=r.replace(/([A-Z])/g,"-$1").toLowerCase();o[a]=s}),o},wt=(t,e,o)=>{const r=Object.keys(t.breakpoints),n=T(t.base,o);return r.reduce((s,a,l)=>{const i=T(t.breakpoints[a],o);return l?[...s,{breakpoint:Number(e[a]),css:i}]:[{breakpoint:null,css:{...n,...i}}]},[{breakpoint:null,css:n}])},se=()=>({base:{},breakpoints:{}}),O=(t,e,o,r)=>{Object.keys(r).length&&(t.breakpoints[e]||(t.breakpoints[e]={}),t.breakpoints[e][o]={...t.breakpoints[e][o],...r})},j=(t,e,o,r)=>{wt(e.value,o,r).forEach(({breakpoint:s,css:a})=>{if(s===null){t.base[e.name]=a;return}O(t,s,e.name,a)})},ae=t=>{const e=q(t.base),o=Object.keys(t.breakpoints).map(Number).sort((r,n)=>n-r).reduce((r,n)=>{const s=t.breakpoints[n];return r+`@media (max-width: ${n}px) { ${q(s)} }`},"");return e+o},$t=(t,e,o)=>{const r=t.reduce((n,s)=>(j(n,s,e,o),n),se());return ae(r)},q=t=>Object.keys(t).reduce((e,o)=>{const r=t[o],n=Object.keys(r).map(s=>`${s}: ${r[s]}`).join(";");return e+`.typo-${o} { ${n} }`},""),J=t=>{if(typeof t=="number")return Number.isFinite(t)?t:null;const e=Number.parseFloat(t);return Number.isFinite(e)?e:null},H=t=>{if(typeof t=="number")return t/16;const e=t.trim().toLowerCase();if(e.endsWith("rem"))return J(e);if(e.endsWith("px")){const o=J(e);return o===null?null:o/16}return null},St=t=>{const{minValueRem:e,maxValueRem:o,minVwRem:r,maxVwRem:n}=t,s=o-e;return`calc(${e}rem + ((100vw - ${r}rem) / (${n}rem - ${r}rem)) * ${s}rem)`},Tt=(t,e,o,r)=>{const n=["font-size","line-height"],s=Object.entries(e.value.breakpoints).map(([p,b])=>{const k=Number.parseInt(o[p],10);return{breakpointName:p,width:k,typography:b}}).filter(p=>Number.isFinite(p.width)).sort((p,b)=>b.width-p.width);if(s.length<2){j(t,e,o,r);return}const a=s[0],l=s[s.length-1];if(a.width<=l.width){j(t,e,o,r);return}const i=T(e.value.base,r),c=T(a.typography,r),u=T(l.typography,r),y=a.width/16,f=l.width/16;if(y===f){j(t,e,o,r);return}t.base[e.name]={...i,...c};const g=n.reduce((p,b)=>{const k=c[b],F=u[b];if(k===void 0||F===void 0||k===F)return p;const R=H(k),A=H(F);return R===null||A===null?p:{...p,[b]:St({minValueRem:A,maxValueRem:R,minVwRem:f,maxVwRem:y})}},{});O(t,a.width,e.name,g),O(t,l.width,e.name,u)},jt=(t,e,o,r)=>{if(!r)return $t(t,e,o);const n=t.reduce((s,a)=>(Tt(s,a,e,o),s),se());return ae(n)},vt=t=>t.length?`import styles from './styles.module.css';
|
|
64
|
+
import { typography } from './typography';
|
|
65
|
+
|
|
66
|
+
type TypographyKeysType = keyof typeof typography;
|
|
67
|
+
|
|
68
|
+
const getTypographyClass = (typographyKey: TypographyKeysType) => styles[\`typo-\${typographyKey}\`];
|
|
69
|
+
|
|
70
|
+
export { typography, getTypographyClass, type TypographyKeysType };
|
|
71
|
+
`:"",Mt=(t,e)=>t.length?`const typography = {
|
|
72
|
+
${t.map(r=>{const n=G(r.value.base,e),s=Object.entries(r.value.breakpoints).reduce((a,[l,i])=>({...a,[l]:G(i,e)}),{});return` '${r.name}': {
|
|
73
|
+
base: ${JSON.stringify(n,null,8).replace(/\n/g,`
|
|
74
|
+
`)},
|
|
75
|
+
breakpoints: ${JSON.stringify(s,null,8).replace(/\n/g,`
|
|
76
|
+
`)}
|
|
77
|
+
}`}).join(`,
|
|
78
|
+
`)}
|
|
79
|
+
} as const;
|
|
80
|
+
|
|
81
|
+
export { typography };
|
|
82
|
+
`:"",Ft=async({indexTSContent:t,typographyTSContent:e,cssContent:o,dir:r})=>{await d.delete(r);const n=d.write(mt,t,{directory:r}),s=d.write(kt,e,{directory:r}),a=d.write(bt,o,{directory:r});await Promise.all([n,s,a])},Ct=async({typographyTokens:t,dir:e,breakpoints:o,fontFamily:r,fluid:n})=>{const s=jt(t,o,r,n),a=Mt(t,r),l=vt(t);await Ft({indexTSContent:l,typographyTSContent:a,cssContent:s,dir:e})},ie=(t,e,o)=>Object.keys(t).reduce((r,n)=>{const s=t[n];if(typeof s!="object"||Array.isArray(s))return r;if(!("type"in s)||!("value"in s))return{...r,[n]:ie(s,e,o)};if(s.type!=="typography")return r;const a=s.value,l=Object.entries(a).reduce((i,[c,u])=>{const y=Object.keys(o.breakpoints);if(y.length)y.forEach(f=>{const g=e.resolveVariableValueString(u,f);g&&(g===u?i.base={...i.base,[c]:g}:i.breakpoints[f]={...i.breakpoints[f],[c]:g})});else{const f=e.resolveVariableValueString(u);f&&(i.base={...i.base,[c]:f})}return i},{base:{},breakpoints:{}});return{...r,[n]:{type:"typography",value:l}}},{}),le=(t,e)=>Object.keys(t).reduce((o,r)=>{const n=e?`${e}-${r}`:r,s=t[r];if(!("type"in s)||!("value"in s))return{...o,...le(s,n)};const a=s.value;return{...o,[n]:a}},{}),Vt=({input:t,output:{dir:e}})=>({name:"typography/tokenManager",executor:async({tokenManagerClient:o})=>{try{console.log("[typography/tokenManager] Generating typography from TokenManager...");const{breakpoints:r,fontFamily:n}=t,s=t.fluid??!0;if(!o.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const a=[],l=o.getStyles();console.log("[typography/tokenManager] Processing styles for typography..."),l.text&&a.push(l.text);const i=a.reduce((u,y)=>({...u,...ie(y,o,{breakpoints:t.breakpoints})}),{}),c=Object.entries(le(i)).map(([u,y])=>({name:u,value:y}));if(c.length===0){console.warn("[typography/tokenManager] No typography tokens generated");return}console.log(`[typography/tokenManager] Generated ${c.length} typography tokens`),console.log(`[typography/tokenManager] Writing files to ${e}...`),await Ct({typographyTokens:c,dir:e,breakpoints:r,fontFamily:n||{},fluid:s}),console.log("[typography/tokenManager] ✅ Successfully generated typography files")}catch(r){const n=r instanceof Error?r.message:String(r);throw console.error("[typography/tokenManager] ❌ Failed to generate typography:",n),r instanceof Error&&r.stack&&console.error("[typography/tokenManager] Stack trace:",r.stack),r}}}),Nt=t=>typeof t=="object"&&t!==null&&"type"in t&&"value"in t,xt=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),ce=t=>t.trim().split(".").map(e=>e.trim()).filter(Boolean),ue=(t,e)=>{const o=ce(e);if(!o.length)throw new Error("variablePath must contain at least one segment");const r=Q(t,o);if(r===void 0)throw new Error(`Variables subtree not found at path: ${o.join(".")}`);return r},de=(t,e,o)=>{if(!t)return[];if(Nt(t)){if(t.type!=="dimension")return[];const r=t.value,n=Object.keys(r).reduce((s,a)=>{const l=r[a],i=o.resolveVariableValueString(l,a);return{...s,[a]:i??l}},{});return[{flatName:e,resolvedByMode:n}]}return xt(t)?Object.keys(t).flatMap(r=>{const n=t[r],s=e?`${e}-${r}`:r;return de(n,s,o)}):[]},ye=(t,e)=>de(t,"",e),fe=(t,e)=>typeof e=="string"?t===e:e.test(t),ge=(t,e)=>e!=null&&e.length?t.filter(o=>e.some(r=>fe(o.flatName,r))):t,E=t=>Object.keys(t).map(e=>({mode:e,widthPx:Number.parseInt(t[e],10)})).filter(e=>Number.isFinite(e.widthPx)).sort((e,o)=>o.widthPx-e.widthPx),pe=t=>{const e=ce(t);if(!e.length)throw new Error("variablePath must contain at least one segment");const o=e[e.length-1];return{variablesClassName:`${o}-variables`,variableNamePrefix:o}},B=t=>{const e=pe(t.variablePath),o=t.variableNamePrefix??e.variableNamePrefix,r=t.variablesClassName??`${o}-variables`;return{variableNamePrefix:o,variablesClassName:r}},he=(t,e)=>t?`--${t}-${e}`:`--${e}`,Ot=(t,e)=>Object.keys(e).reduce((o,r)=>{const n=Number(r);return{...o,[n]:{...o[n],...e[n]}}},{...t}),be=(t,e,o)=>{const r=he(o,t.flatName),n=E(e);if(Object.keys(e).length===0||n.length===0){const i=Object.values(t.resolvedByMode)[0]??"";return{base:{[r]:i},byBreakpoint:{}}}const s=n.filter(i=>i.mode in t.resolvedByMode);if(s.length===0){const i=Object.values(t.resolvedByMode)[0]??"";return{base:{[r]:i},byBreakpoint:{}}}if(s.length===1){const i=s[0],c=t.resolvedByMode[i.mode]??"";return{base:{[r]:c},byBreakpoint:{}}}const a=t.resolvedByMode[s[0].mode]??"",l=s.slice(1).reduce((i,c,u)=>{const y=s[u].mode,f=t.resolvedByMode[y],g=t.resolvedByMode[c.mode];if(g===void 0||g===f)return i;const p=c.widthPx,b=i[p]??{};return{...i,[p]:{...b,[r]:g}}},{});return{base:{[r]:a},byBreakpoint:l}},Pt=(t,e,o)=>t.reduce((r,n)=>{const{base:s,byBreakpoint:a}=be(n,e,o);return{base:{...r.base,...s},breakpoints:Ot(r.breakpoints,a)}},{base:{},breakpoints:{}}),me=(t,e)=>{if(!t.length)return"";const{breakpoints:o}=e,{variablesClassName:r,variableNamePrefix:n}=B(e),s=Pt(t,o,n),a=Object.keys(s.base).map(c=>` ${c}: ${s.base[c]};`),l=W(`.${r}`,a),i=Object.keys(s.breakpoints).map(Number).sort((c,u)=>u-c).map(c=>{const u=s.breakpoints[c],y=Object.keys(u).map(g=>` ${g}: ${u[g]};`),f=W(`.${r}`,y);return`@media (max-width: ${c}px) {
|
|
83
|
+
${f}
|
|
84
|
+
}`}).filter(Boolean).join(`
|
|
85
|
+
|
|
86
|
+
`);return i?`${l}
|
|
87
|
+
|
|
88
|
+
${i}`:l},ke=(t,e)=>{const o=t.resolvedByMode,r=E(e),n=Object.keys(e).length>0&&r.length>0;return{breakpoints:(()=>{if(!n)return Object.keys(o);const l=[],i=new Set;return r.forEach(({mode:c})=>{c in o&&(l.push(c),i.add(c))}),Object.keys(o).forEach(c=>{i.has(c)||(l.push(c),i.add(c))}),l})().reduce((l,i)=>{const c=o[i];return c===void 0?l:{...l,[i]:c}},{})}},we=(t,e)=>{const{breakpoints:o}=e;return t.length?`const utilities = {
|
|
89
|
+
${t.map(n=>{const s=ke(n,o),a=JSON.stringify(s,null,8);return` '${n.flatName}': ${a.replace(/\n/g,`
|
|
90
|
+
`)}`}).join(`,
|
|
91
|
+
`)}
|
|
92
|
+
} as const;
|
|
5
93
|
|
|
6
|
-
|
|
94
|
+
export { utilities };
|
|
95
|
+
`:`const utilities = {} as const;
|
|
7
96
|
|
|
8
|
-
|
|
97
|
+
export { utilities };
|
|
98
|
+
`},$e=t=>{const{variableNamePrefix:e}=B(t);return["import { utilities } from './utilities';","","type UtilitiesKeysType = keyof typeof utilities;","",`const utilityVariableNamePrefix = ${JSON.stringify(e)};`,"","const getUtilityCssVariableName = (key: UtilitiesKeysType): string =>"," utilityVariableNamePrefix"," ? `--${utilityVariableNamePrefix}-${String(key)}`"," : `--${String(key)}`;","","const getUtilityCssVar = (key: UtilitiesKeysType): string =>"," `var(${getUtilityCssVariableName(key)})`;","","export {"," utilities,"," getUtilityCssVariableName,"," getUtilityCssVar,"," type UtilitiesKeysType,","};",""].join(`
|
|
99
|
+
`)},Et="styles.css",Bt="utilities.ts",Rt="index.ts",Se=async({dir:t,globalCss:e,utilitiesTs:o,indexTs:r})=>{await d.delete(t),await Promise.all([d.write(Et,e,{directory:t}),d.write(Bt,o,{directory:t}),d.write(Rt,r,{directory:t})])},Te=async({tokens:t,input:e,output:o})=>{const{dir:r}=o,n=me(t,e),s=we(t,e),a=$e(e);await Se({dir:r,globalCss:n,utilitiesTs:s,indexTs:a})},At=({input:t,output:e})=>({name:"utilities/tokenManager",executor:async({tokenManagerClient:o})=>{var r;try{if(console.log("[utilities/tokenManager] Generating utility classes from TokenManager..."),!o.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const n=o.getVariables(),s=ue(n,t.variablePath),a=ye(s,o),l=ge(a,t.include);if(!l.length){a.length&&((r=t.include)!=null&&r.length)?console.warn(`[utilities/tokenManager] No tokens left after include filter (${a.length} at path "${t.variablePath}")`):console.warn(`[utilities/tokenManager] No dimension tokens found at path "${t.variablePath}"`);return}console.log(`[utilities/tokenManager] Resolved ${l.length} utility token(s)`),console.log(`[utilities/tokenManager] Writing files to ${e.dir}...`),await Te({tokens:l,input:t,output:e}),console.log("[utilities/tokenManager] ✅ Successfully generated utility files")}catch(n){const s=n instanceof Error?n.message:String(n);throw console.error("[utilities/tokenManager] ❌ Failed to generate utilities:",s),n instanceof Error&&n.stack&&console.error("[utilities/tokenManager] Stack trace:",n.stack),n}}});exports.BREAKPOINTS_NAMES=Y;exports.TokenManager=X;exports.breakpointsFromTokenManager=Ke;exports.buildUtilitiesDataTSContent=we;exports.buildUtilitiesGlobalStylesCSS=me;exports.buildUtilitiesIndexTSContent=$e;exports.colorsFromTokenManager=_e;exports.containerFromTokenManager=at;exports.deriveUtilityNamingFromVariablePath=pe;exports.filterResolvedUtilitiesByInclude=ge;exports.generate=Ve;exports.generateUtilitiesFiles=Te;exports.getSortedBreakpointModes=E;exports.getUtilityCssVariableName=he;exports.getVariablesSubtree=ue;exports.init=Ne;exports.resolveUtilitiesSubtree=ye;exports.resolveUtilityNaming=B;exports.shadowsFromTokenManager=ht;exports.splitUtilityTokenForMedia=be;exports.typographyFromTokenManager=Vt;exports.utilitiesFromTokenManager=At;exports.utilityFlatNameMatchesIncludePattern=fe;exports.utilityTokenToSerializableData=ke;exports.writeUtilitiesFiles=Se;
|