@greensight/gts 1.0.0-alpha.13 → 1.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +5 -0
- package/common/lodash.d.ts.map +1 -1
- package/index.cjs +30 -5
- package/index.mjs +847 -460
- 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 +18 -0
- package/modules/breakpoints/breakpointsFromTokenManager/module.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsFromTokenManager/utils.d.ts +22 -0
- package/modules/breakpoints/breakpointsFromTokenManager/utils.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsListFromTokenManager/index.d.ts +2 -0
- package/modules/breakpoints/breakpointsListFromTokenManager/index.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsListFromTokenManager/module.d.ts +14 -0
- package/modules/breakpoints/breakpointsListFromTokenManager/module.d.ts.map +1 -0
- package/modules/breakpoints/breakpointsListFromTokenManager/utils.d.ts +9 -0
- package/modules/breakpoints/breakpointsListFromTokenManager/utils.d.ts.map +1 -0
- package/modules/breakpoints/index.d.ts +4 -0
- package/modules/breakpoints/index.d.ts.map +1 -0
- package/modules/breakpoints/types.d.ts +11 -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} +2 -2
- 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 +0 -26
- 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 +16 -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 +16 -0
- package/modules/container/types.d.ts.map +1 -0
- package/modules/container/utils.d.ts +16 -0
- package/modules/container/utils.d.ts.map +1 -0
- package/modules/index.d.ts +4 -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 +17 -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 +21 -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 +20 -0
- package/modules/typography/typographyFromTokenManager/module.d.ts.map +1 -0
- package/modules/typography/utils.d.ts +52 -0
- package/modules/typography/utils.d.ts.map +1 -0
- package/package.json +1 -1
- 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
|
@@ -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/classes/TokenManager/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAGR,YAAY,EACZ,gBAAgB,EAChB,qBAAqB,EAKxB,MAAM,SAAS,CAAC;AAoBjB,qBAAa,YAAY;IAErB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,YAAY,CAAS;IAG7B,OAAO,CAAC,SAAS,CAAC,CAA4B;IAC9C,OAAO,CAAC,MAAM,CAAC,CAAyB;IAGxC,OAAO,CAAC,MAAM,CAAS;gBAEX,SAAS,CAAC,EAAE,MAAM;IAKvB,QAAQ,IAAI,OAAO;IAI1B,mBAAmB;IACnB,OAAO,CAAC,YAAY;IAkBpB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAe3B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAY9B,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,iBAAiB;IAkBzB,OAAO,CAAC,iBAAiB;IAQzB;;OAEG;YACW,iBAAiB;IAiB/B,OAAO,CAAC,cAAc;IAItB;;OAEG;YACW,kBAAkB;IAYhC;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAU3B;;OAEG;YACW,cAAc;IAqB5B;;OAEG;YACW,UAAU;IAQX,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAalC;;OAEG;IACI,YAAY,IAAI,YAAY,CAAC,WAAW,CAAC;IAOhD;;OAEG;IACI,SAAS,IAAI,YAAY,CAAC,QAAQ,CAAC;IAO1C;;;;OAIG;IACI,mBAAmB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM;IAKvD;;;;OAIG;IACI,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI7C;;;;;OAKG;IACI,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,gBAAgB,CAAC,OAAO,CAAC,GAAG,SAAS;IAWpG;;;;;OAKG;IACI,0BAA0B,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,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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aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAAG;AAEvF,MAAM,MAAM,sBAAsB,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,WAAW,CAAC;AAC5F,MAAM,WAAW,SAAS,CAAC,CAAC;IACxB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,SAAS;IACtB,KAAK,EAAE,SAAS,CAAC,kBAAkB,CAAC,CAAC;IACrC,MAAM,EAAE,SAAS,CAAC,mBAAmB,CAAC,CAAC;IACvC,IAAI,EAAE,SAAS,CAAC,uBAAuB,CAAC,CAAC;IACzC,IAAI,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,YAAY;IACzB,SAAS,EAAE,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACvC,MAAM,EAAE,SAAS,CAAC;CACrB"}
|
|
@@ -4,9 +4,17 @@ export interface IBaseFigmaToken {
|
|
|
4
4
|
$value: unknown;
|
|
5
5
|
$description?: string;
|
|
6
6
|
}
|
|
7
|
+
export interface IColorFigmaGradientValue {
|
|
8
|
+
type: 'radial' | '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,eAAe;IAC5B,KAAK,EAAE,eAAe,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAGD,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACrD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;
|
|
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,eAAe;IAC5B,KAAK,EAAE,eAAe,CAAC;IACvB,M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AY,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":"AAwEA,eAAO,MAAM,QAAQ,qBAwFpB,CAAC"}
|
package/common/lodash.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
export declare const get: (obj: any, path: string | string[]) => any;
|
|
2
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;
|
|
3
8
|
//# sourceMappingURL=lodash.d.ts.map
|
package/common/lodash.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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,33 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
`);return`${
|
|
1
|
+
"use strict";var z=Object.defineProperty;var K=(n,e,t)=>e in n?z(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var y=(n,e,t)=>K(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("path"),D=require("ts-import"),j=require("node:fs"),m=require("node:fs/promises"),M=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 M.resolve(h.baseDir,e)}static resolveWritePath(e,t){const r=M.resolve(h.baseDir,t??"");return{targetDir:r,targetPath:M.resolve(r,e)}}static handleReadError(e,t){throw e.code==="ENOENT"?new Error(`File not found: ${t}`):new Error(`Failed to read file "${t}": ${e.message??String(e)}`)}static async read(e,t="utf8"){const r=h.resolveReadPath(e);try{return await m.readFile(r,{encoding:t})}catch(o){h.handleReadError(o,r)}}static async readBuffer(e){const t=h.resolveReadPath(e);try{return await m.readFile(t)}catch(r){h.handleReadError(r,t)}}static async readJson(e){const t=h.resolveReadPath(e);try{const r=await m.readFile(t,{encoding:"utf8"});try{return JSON.parse(r)}catch(o){throw new Error(`Failed to parse JSON from "${t}": ${o.message}`)}}catch(r){h.handleReadError(r,t)}}static async write(e,t="",r={}){const{directory:o,overwrite:s=!0}=r,{targetDir:a,targetPath:i}=h.resolveWritePath(e,o);if(!s&&j.existsSync(i))throw new Error(`File ${i} already exists`);return await m.mkdir(a,{recursive:!0}),await m.writeFile(i,t,{encoding:"utf8"}),i}static async writeWithExtension(e,t,r="",o){const s=t.startsWith(".")?t:`.${t}`,a=`${e}${s}`;return h.write(a,r,o)}static exists(e){const t=h.resolveReadPath(e);return j.existsSync(t)}static async delete(e,t){const{targetPath:r}=h.resolveWritePath(e,t);j.existsSync(r)&&await m.rm(r,{force:!0})}};y(h,"baseDir",process.cwd());let d=h;const k=class k{static async create(){if(d.exists(k.configFileName))throw new Error("The file already exists");await d.write(k.configFileName,"",{overwrite:!1})}async load(){try{const e=await D.tsImport.compile(`${b.resolve(process.cwd(),k.configFileName)}`);if(!e)throw new Error;return e.default}catch(e){console.error("Cannot find module gts.config.ts",e)}}};y(k,"configFileName","gts.config.ts");let S=k;const H=n=>{const e=new URLSearchParams;return Object.keys(n).forEach(t=>{Array.isArray(n[t])?n[t].forEach(r=>e.append(`${t}[]`,r)):e.append(t,n[t])}),e},U=(n,e=50)=>{const t=[];for(let r=0;r<n.length;r+=e)t.push(n.slice(r,r+e));return t};class E{constructor(e,t){y(this,"figmaToken");y(this,"fileId");y(this,"onTimeMeasureHandler");this.figmaToken=e,this.fileId=t}setOnTimeMeasureHandler(e){this.onTimeMeasureHandler=e}static async returnJSON(e){const t=await e.json();if(!e.ok){let r="Request failed";throw new Error(r)}return t}async performControlledRequest(e,{params:t={},timeout:r=3e4,abortController:o=new AbortController}={}){var p;if(!this.figmaToken||!this.fileId)throw new Error("Добавьте figmaToken и figmaId");const s=Object.entries(t).reduce((w,[q,C])=>typeof C<"u"?{...w,[q]:C}:w,{}),a=`https://api.figma.com/v1${e}${s&&Object.keys(s).length?`?${H(s)}`:""}`;console.log("endpoinWithParams=",a);const i=setTimeout(()=>o.abort(),r),l={"Content-Type":"application/json",...this.figmaToken&&{"X-Figma-Token":this.figmaToken}},c={method:"GET",headers:l,signal:o.signal},u=performance.now(),f=await fetch(`${a}`,c);clearTimeout(i);const g=performance.now()-u;return(p=this.onTimeMeasureHandler)==null||p.call(this,a,l,g),f}async request(e,t){var o;const r=await this.performControlledRequest(e,{...t});return(o=r.headers.get("content-type"))!=null&&o.includes("application/json")?E.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 t=U(e).map(s=>this.request(`/files/${this.fileId}/nodes`,{params:{ids:s.join(",")}})),r=await Promise.all(t);return{...r[0],nodes:r.reduce((s,a)=>({...s,...a.nodes}),{})}}}const Q=(n,e)=>{const t=Array.isArray(e)?e:e.split(".");let r=n;for(const o of t){if(r==null||typeof r!="object")return;r=r[o]}return r},B=(n,e)=>{if(!e||typeof e!="object")return n;if(!n||typeof n!="object")return e;const t={...n};for(const r in e)e.hasOwnProperty(r)&&(typeof e[r]=="object"&&e[r]!==null&&typeof t[r]=="object"&&t[r]!==null?t[r]=B(t[r],e[r]):t[r]=e[r]);return t};function F(n,e){if(n===e)return!0;if(n==null||e==null)return n===e;if(typeof n!=typeof e)return!1;if(n instanceof Date&&e instanceof Date)return n.getTime()===e.getTime();if(n instanceof RegExp&&e instanceof RegExp)return n.toString()===e.toString();if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!F(n[t],e[t]))return!1;return!0}if(typeof n=="object"&&typeof e=="object"){const t=Object.keys(n),r=Object.keys(e);if(t.length!==r.length)return!1;for(const o of t)if(!r.includes(o)||!F(n[o],e[o]))return!1;return!0}return!1}const O={color:{},effect:{},text:{},grid:{}};class L{constructor(e){y(this,"tokensDir");y(this,"manifestPath");y(this,"variables");y(this,"styles");y(this,"loaded",!1);this.tokensDir=e||"",this.manifestPath=b.join(this.tokensDir,"manifest.json")}isLoaded(){return this.loaded&&!!this.variables&&!!this.styles}normalizeKey(e){const t=e.trim();return t&&t.replace(/[-_\s]+/g," ").split(" ").filter(r=>r.length).map((r,o)=>{const s=r.charAt(0),a=r.slice(1);return o===0?r.toLowerCase():s.toUpperCase()+a}).join("")}parseVariableString(e){if(typeof e!="string")return e;const t=/^\{(.+)\}$/,r=e.match(t);if(r){const o=r[1].trim();return`{${this.normalizeKey(o)}}`}return e}createVariableFileList(e){return Object.entries(e).flatMap(([t,r])=>Object.entries(r.modes).flatMap(([o,s])=>s.map(a=>({fileName:a,modeName:this.normalizeKey(o.trim()),collectionName:t}))))}parseValue(e){return e&&(typeof e=="string"?this.parseVariableString(e):typeof e!="object"?e:Array.isArray(e)?e.map(t=>this.parseValue(t)):Object.entries(e).reduce((t,[r,o])=>({...t,[r]:this.parseValue(o)}),{}))}getTokensFromFile(e,t){return Object.entries(e).reduce((r,[o,s])=>"$type"in s&&"$value"in s?{...r,[this.normalizeKey(o)]:{type:s.$type,description:s.$description,value:t?{[this.normalizeKey(t)]:this.parseValue(s.$value)}:this.parseValue(s.$value)}}:{...r,[this.normalizeKey(o)]:this.getTokensFromFile(s,t)},{})}processTokensFile(e,t,r){const o=this.normalizeKey(r),s=this.getTokensFromFile(e,t);return{[o]:s}}async loadVariableFiles(e){return Promise.all(e.map(async({fileName:t,modeName:r,collectionName:o})=>{try{const s=b.join(this.tokensDir,t),a=await d.readJson(s);return this.processTokensFile(a,r,o)}catch(s){return console.warn(`Failed to load variable file: ${b.join(this.tokensDir,t)}`,s),{}}}))}mergeVariables(e){return e.reduce((t,r)=>B(t,r),{})}async loadTokenVariables(e){try{const t=this.createVariableFileList(e),r=await this.loadVariableFiles(t);return this.mergeVariables(r)}catch(t){throw new Error(`Failed to load token variables from ${this.tokensDir}: ${t}`)}}createStyleFileList(e){return Object.entries(e).flatMap(([t,r])=>(r==null?void 0:r.map(o=>({styleType:t,fileName:o})))||[])}async loadStyleFiles(e){return(await Promise.all(e.map(async({styleType:r,fileName:o})=>{try{const s=b.join(this.tokensDir,o),a=await d.readJson(s);return{styleType:r,styleTokens:a}}catch(s){return console.warn(`Failed to load style file: ${b.join(this.tokensDir,o)}`,s),{styleType:r,styleTokens:{}}}}))).reduce((r,o)=>({...r,[o.styleType]:this.getTokensFromFile(o.styleTokens,"")}),{...O})}async loadStyles(e){if(!e)return{...O};const t=this.createStyleFileList(e);return await this.loadStyleFiles(t)}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((t,r)=>{const o=e[r],s=this.resolveVariableValueString(o,r);return s&&(t[r]=s),t},{})}resolveVariableValueString(e,t){if(!this.isVariableReference(e))return e;const r=this.getVariablePath(e),o=this.getToken(r,t);if(o)return this.resolveVariableValueString(o,t)}getToken(e,t){if(!this.loaded||!this.variables)throw new Error("Tokens not loaded. Call load() first.");for(const r of Object.values(this.variables)){const o=Q(r,e);if(o!=null&&o.value&&typeof o.value=="object"){if(t)return o.value[t];{const s=Object.keys(o.value)[0];return o.value[s]}}}}}const X=async()=>{const e=await new S().load();if(!e)throw new Error("Заполнить ошибку через нейронку");const{figmaToken:t,fileId:r,modules:o,manifest:s}=e,a=new E(t,r),i=new L(s);s&&d.exists(s)&&await i.load(),await Promise.all(o.map(l=>l.executor({figmaApiClient:a,tokenManagerClient:i})))},Y=async()=>{await S.create(),console.log("\x1B[32m%s\x1B[0m","✔️ Configuration file created gts.config.ts")},v=["xxxl","xxl","xl","lg","md","sm","xs","xxs","xxxs"],Z=n=>parseInt(n.value,10),A=n=>n.reduce((e,t)=>({...e,[t.name]:Z(t)}),{}),_=async(n,e)=>{await d.delete(n,e)},ee=async(n,e,t)=>{await d.write(n,e,{directory:t})},$=async(n,e,t)=>{await _(n,t),await ee(n,e,t)},te=(n,e)=>{if(!e.length)return"";const t=e.map(r=>` ${r}`).join(`
|
|
2
|
+
`);return`${n} {
|
|
3
|
+
${t}
|
|
4
|
+
}`},re=n=>n.length?n.join(`
|
|
5
|
+
`):"",ne=n=>`--${n}`,oe=n=>`$${n}`,se=n=>n.map(e=>`${ne(e.name)}: ${e.value}px;`),ae=n=>n.map(e=>`${oe(e.name)}: ${e.value}px;`),ie=n=>te(":root",n),le=n=>re(n),ce=n=>{const e=A(n);return JSON.stringify(e)},ue=async(n,e,t,r,o,s,a,i)=>{const l=[];l.push($(s,n,r)),a&&e&&l.push($(a,e,o)),i&&t&&l.push($(i,t,o)),await Promise.all(l)},de=async({breakpointTokens:n,jsonDir:e,stylesDir:t,jsonFileName:r,stylesFileName:o,extensions:s})=>{const a=se(n),i=ae(n),l=s.includes("css")?ie(a):null,c=s.includes("scss")?le(i):null,u=s.includes("css")?`${o}.css`:null,f=s.includes("scss")?`${o}.scss`:null,g=ce(n);await ue(g,l,c,e,t,r,u,f)},ge=(n,e)=>{const t=Object.keys(n).filter(s=>!isNaN(Number(s))).sort((s,a)=>Number(s)-Number(a));if(t.length>e.length)throw new Error(`Not enough breakpoint names provided. Found ${t.length} breakpoints in data, but only ${e.length} names specified: ${e.join(", ")}`);const o=Object.keys(n).filter(s=>isNaN(Number(s)));if(o.length>0)throw new Error(`Found non-numeric breakpoint keys in grid data: ${o.join(", ")}. All breakpoint keys must be numeric values.`);return t.map((s,a)=>({name:e[e.length-1-a]||`bp-${s}`,value:s}))},fe=({input:n={},output:{jsonDir:e,stylesDir:t,jsonFileName:r="breakpoints.json",stylesFileName:o="breakpoints"}})=>({name:"breakpoints/tokenManager",executor:async({tokenManagerClient:s})=>{try{console.log("[breakpoints/tokenManager] Generating breakpoints from TokenManager...");const{extensions:a=["css"],names:i=v}=n;if(!s.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const l=s.getStyles();if(!l.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 c=ge(l.grid,i);if(!c.length){console.warn("[breakpoints/tokenManager] No breakpoints found in grid styles.");return}console.log(`[breakpoints/tokenManager] Found ${c.length} breakpoints: ${c.map(u=>u.name).join(", ")}`),await de({breakpointTokens:c,jsonDir:e,stylesDir:t,jsonFileName:r,stylesFileName:o,extensions:a}),console.log("[breakpoints/tokenManager] Breakpoints generated successfully.")}catch(a){throw console.error("[breakpoints/tokenManager] Error:",a),a}}}),pe=n=>{const e=A(n),t=Object.entries(e).map(([o,s])=>` ${o}: ${s}`).join(`,
|
|
6
|
+
`),r=n.length>0?n[n.length-1].name:"xxxl";return`$breakpointList: (
|
|
7
|
+
${t}
|
|
8
|
+
);
|
|
9
|
+
$defaultBreakpoint: '${r}';`},he=async(n,e,t)=>{await $(t,n,e)},ye=async({breakpointTokens:n,stylesDir:e,fileName:t})=>{const r=pe(n);await he(r,e,`${t}.scss`)},me=(n,e)=>{const t=Object.keys(n).filter(r=>!isNaN(Number(r))).sort((r,o)=>Number(r)-Number(o));if(t.length>e.length)throw new Error(`Not enough breakpoint names provided. Found ${t.length} breakpoints in data, but only ${e.length} names specified: ${e.join(", ")}`);return t.map((r,o)=>({name:e[e.length-1-o]||`bp-${r}`,value:r}))},be=({input:n={},output:{stylesDir:e,fileName:t="breakpointList"}})=>({name:"breakpointsList/tokenManager",executor:async({tokenManagerClient:r})=>{try{console.log("[breakpointsList/tokenManager] Generating SCSS breakpoint map...");const{names:o=v}=n;if(!r.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const s=r.getStyles();if(!s.grid)throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");console.log("[breakpointsList/tokenManager] Extracting breakpoints for SCSS map...");const a=me(s.grid,o);if(!a.length){console.warn("[breakpointsList/tokenManager] No breakpoints found in grid styles.");return}console.log(`[breakpointsList/tokenManager] Found ${a.length} breakpoints for map: ${a.map(i=>i.name).join(", ")}`),await ye({breakpointTokens:a,stylesDir:e,fileName:t}),console.log("[breakpointsList/tokenManager] SCSS breakpoint map generated successfully.")}catch(o){throw console.error("[breakpointsList/tokenManager] Error:",o),o}}}),V=(n,e)=>{if(!e.length)return"";const t=e.map(r=>` ${r}`).join(`
|
|
10
|
+
`);return`${n} {
|
|
11
|
+
${t}
|
|
12
|
+
}`},ke=n=>`.${n.replace(/\s+/g,"-").toLowerCase()}`,we=n=>`--${n}`,$e=n=>n.reduce((e,t)=>{const r=we(t.name);return typeof t.value=="object"?Object.entries(t.value).forEach(([o,s])=>{e[o]||(e[o]=[]),e[o].push(`${r}: ${s};`)}):e.root.push(`${r}: ${t.value};`),e},{root:[]}),Se=n=>{const e=V(":root",n.root),t=Object.entries(n).reduce((r,[o,s])=>{if(o==="root"||!s.length)return r;const a=V(ke(o),s);return a&&r.push(a),r},[]).join(`
|
|
13
|
+
|
|
14
|
+
`);return[e,t].filter(Boolean).join(`
|
|
15
|
+
|
|
16
|
+
`)},Te=n=>{const e=n.reduce((t,r)=>({...t,[r.name]:r.value}),{});return JSON.stringify(e)},je=async(n,e,t,r,o,s)=>{await Promise.all([d.delete(o,t),d.delete(s,r)]);const a=d.write(o,n,{directory:t}),i=d.write(s,e,{directory:r});await Promise.all([a,i])},Me=async({colorTokens:n,jsonDir:e,stylesDir:t,jsonFileName:r,cssFileName:o})=>{const s=$e(n),a=Se(s),i=Te(n);await je(i,a,e,t,r,o)},T=n=>n.reduce((e,t)=>{const r=Number((t.position*100).toFixed(1));return[...e,`${t.color}${r>0&&r<100?` ${r}%`:""}`]},[]).join(", "),Fe=n=>{const e=T(n.stops);return`linear-gradient(${n.angle}deg, ${e})`},Ee=n=>`radial-gradient(circle, ${T(n.stops)})`,ve=n=>{const e=T(n.stops);return`conic-gradient(from ${n.angle}deg, ${e})`},Ce=n=>{const e=T(n.stops);return`linear-gradient(${n.angle}deg, ${e})`},Oe=n=>typeof n=="string"?n:n.type==="linear"?Fe(n):n.type==="radial"?Ee(n):n.type==="conic"?ve(n):n.type==="diamond"?Ce(n):"",R=(n,e)=>Object.keys(n).reduce((t,r)=>{const o=n[r],s=e?`${e}-${r}`:r;if(o&&typeof o=="object"&&"type"in o&&"value"in o){const i=Object.keys(o.value),l=i.length>1?o.value:o.value[i[0]],c={[s]:Oe(l)};return{...t,...c}}const a=R(o,s);return{...t,...a}},{}),Ve=n=>`cl-${n}`,G=(n,e)=>Object.keys(n).reduce((t,r)=>{const o=n[r];if(o.type&&o.value){const a=typeof o.value=="string"?e.resolveVariableValueString(o.value,r):e.resolveVariableValue(o.value);return a?{...t,[r]:{...o,value:a}}:t}const s=G(o,e);return s?{...t,[r]:s}:t},{}),Pe=({input:n={},output:{jsonDir:e,stylesDir:t,jsonFileName:r="colors.json",cssFileName:o="colors.css"}})=>({name:"colors/tokenManager",executor:async({tokenManagerClient:s})=>{try{console.log("[colors/tokenManager] Generating colors from TokenManager...");const{includeVariables:a,includeStyles:i=!0}=n;if(!(a!=null&&a.length)&&!i)throw new Error("Either includeVariables or includeStyles must be enabled");if(!s.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const l=[],c=s.getVariables();if(i){const f=s.getStyles();console.log("[colors/tokenManager] Processing styles for colors..."),f.color&&l.push(f.color)}if(a!=null&&a.length){console.log(`[colors/tokenManager] Processing ${a.length} variable groups...`);const f=a.map(g=>{const p=c[g];if(p.type==="color")return p}).filter(Boolean);l.push(...f)}const u=l.map(f=>G(f,s)).flatMap(f=>Object.entries(R(f,"")).reduce((g,[p,w])=>[...g,{name:Ve(p),value:w}],[]));if(u.length===0){console.warn("[colors/tokenManager] No color tokens generated");return}console.log(`[colors/tokenManager] Generated ${u.length} color tokens`),console.log(`[colors/tokenManager] Writing files to ${e} and ${t}...`),await Me({colorTokens:u,jsonDir:e,stylesDir:t,jsonFileName:r,cssFileName:o}),console.log("[colors/tokenManager] ✅ Successfully generated color files")}catch(a){const i=a instanceof Error?a.message:String(a);throw console.error("[colors/tokenManager] ❌ Failed to generate colors:",i),a instanceof Error&&a.stack&&console.error("[colors/tokenManager] Stack trace:",a.stack),a}}}),xe=(n,e)=>{if(!e.length)return"";const t=e.map(r=>` ${r}`).join(`
|
|
17
|
+
`);return`${n} {
|
|
18
|
+
${t}
|
|
19
|
+
}`},Ne=(n,e)=>{if(!e.length)return"";const t=n-1,r=e.map(o=>` ${o}`).join(`
|
|
20
|
+
`);return`@media (max-width: ${t}px) {
|
|
3
21
|
${r}
|
|
4
|
-
}`},
|
|
22
|
+
}`},Be=(n,e)=>{const t=[];n.forEach((a,i)=>{const l=parseInt(a.name.split("_")[0]),c=[],u=i>0?n[i-1]:null;if(a.value.alignment==="center"&&a.value.width&&(c.push(`max-width: ${a.value.width};`),c.push("margin-left: auto;"),c.push("margin-right: auto;"),u&&u.value.alignment!=="center"&&(c.push("padding-left: 0;"),c.push("padding-right: 0;"))),a.value.alignment==="stretch"&&u&&u.value.alignment!=="stretch"&&(c.push("max-width: none;"),c.push("margin-left: 0;"),c.push("margin-right: 0;")),a.value.alignment==="stretch"&&(c.push(`padding-left: ${a.value.margin};`),c.push(`padding-right: ${a.value.margin};`)),c.length>0){const g=xe(".container",c);if(i===0)t.push(g);else{const p=Ne(l,[g]);t.push(p)}}});const o=t.filter(Boolean).join(`
|
|
23
|
+
|
|
24
|
+
`).replace(/^/gm," ");return`@layer ${e||"components"} {
|
|
25
|
+
${o}
|
|
26
|
+
}`},Le=async(n,e,t)=>{await Ae(t,n,e)},Ae=async(n,e,t)=>{await d.delete(n,t),await d.write(n,e,{directory:t})},Re=async({containerTokens:n,stylesDir:e,fileName:t,layer:r,isModule:o=!0})=>{const s=Be(n,r),a=`${t}${o?".module":""}.css`;await Le(s,e,a)},Ge=(n,e,t)=>{const r=[];return Object.keys(n).forEach(a=>{const i=n[a];i&&i.value&&Array.isArray(i.value)&&i.value.filter(c=>c.pattern==="columns"&&(c.alignment==="center"||c.alignment==="stretch")).forEach(c=>{if(c.alignment==="center"&&r.push({name:a,value:{alignment:"center",width:t.width,margin:"auto"}}),c.alignment==="stretch"){const u=e.resolveVariableValueString(c.offset);if(!u)return;r.push({name:a,value:{alignment:"stretch",margin:u}})}})}),r.sort((a,i)=>{const l=parseInt(a.name);return parseInt(i.name)-l}).reduce((a,i)=>{const l=a[a.length-1];return l&&F(l.value,i.value)||a.push(i),a},[])},Ie=({input:n={},output:{stylesDir:e,fileName:t="container"}})=>({name:"container/tokenManager",executor:async({tokenManagerClient:r})=>{try{console.log("[container/tokenManager] Generating container styles...");const{containerWidth:o=1440,layer:s,isModule:a=!0}=n;if(!r.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");console.log("[container/tokenManager] Extracting container tokens...");const i=r.getStyles();if(!i.grid)throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");const l=Ge(i.grid,r,{width:o});if(!l.length){console.warn("[container/tokenManager] No container tokens found.");return}console.log(`[container/tokenManager] Found ${l.length} container tokens: ${l.map(c=>c.name).join(", ")}`),await Re({containerTokens:l,stylesDir:e,fileName:t,layer:s,isModule:a}),console.log("[container/tokenManager] Container styles generated successfully.")}catch(o){throw console.error("[container/tokenManager] Error:",o),o}}}),P=(n,e)=>{if(!e.length)return"";const t=e.map(r=>` ${r}`).join(`
|
|
27
|
+
`);return`${n} {
|
|
28
|
+
${t}
|
|
29
|
+
}`},Je=n=>`.${n.replace(/\s+/g,"-").toLowerCase()}`,We=n=>`--${n}`,qe=({offsetX:n,offsetY:e,blur:t,spread:r,color:o})=>`${n} ${e} ${t} ${r} ${o}`,ze=n=>n.reduce((e,t)=>{const r=We(t.name);return typeof t.value=="object"?Object.entries(t.value).forEach(([o,s])=>{e[o]||(e[o]=[]),e[o].push(`${r}: ${s};`)}):e.root.push(`${r}: ${t.value};`),e},{root:[]}),Ke=n=>{const e=P(":root",n.root),t=Object.entries(n).reduce((r,[o,s])=>{if(o==="root"||!s.length)return r;const a=P(Je(o),s);return a&&r.push(a),r},[]).join(`
|
|
5
30
|
|
|
6
|
-
`);return[e,
|
|
31
|
+
`);return[e,t].filter(Boolean).join(`
|
|
7
32
|
|
|
8
|
-
`)},
|
|
33
|
+
`)},De=n=>{const e=n.reduce((t,r)=>({...t,[r.name]:r.value}),{});return JSON.stringify(e)},He=async(n,e,t,r,o,s)=>{await Promise.all([d.delete(o,t),d.delete(s,r)]);const a=d.write(o,n,{directory:t}),i=d.write(s,e,{directory:r});await Promise.all([a,i])},Ue=async({shadowTokens:n,jsonDir:e,stylesDir:t,jsonFileName:r,cssFileName:o})=>{const s=ze(n),a=Ke(s),i=De(n);await He(i,a,e,t,r,o)},I=(n,e)=>Object.keys(n).reduce((t,r)=>{const o=n[r],s=e?`${e}-${r}`:r;if(o&&typeof o=="object"&&"type"in o&&"value"in o){const i={[s]:o.value.map(qe).join(", ")};return{...t,...i}}const a=I(o,s);return{...t,...a}},{}),Qe=n=>`sh-${n}`,Xe=({input:n={},output:{jsonDir:e,stylesDir:t,jsonFileName:r="shadows.json",cssFileName:o="shadows.css"}})=>({name:"shadows/tokenManager",executor:async({tokenManagerClient:s})=>{try{console.log("[shadows/tokenManager] Generating shadows from TokenManager...");const{includeVariables:a,includeStyles:i=!0}=n;if(!(a!=null&&a.length)&&!i)throw new Error("Either includeVariables or includeStyles must be enabled");if(!s.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const l=[];if(i){const u=s.getStyles();console.log("[shadows/tokenManager] Processing styles for shadows..."),u.effect&&l.push(u.effect)}const c=l.flatMap(u=>Object.entries(I(u,"")).reduce((f,[g,p])=>[...f,{name:Qe(g),value:p}],[]));if(console.log("shadowTokens=",c),c.length===0){console.warn("[shadows/tokenManager] No shadow tokens generated");return}console.log(`[shadows/tokenManager] Generated ${c.length} shadow tokens`),console.log(`[shadows/tokenManager] Writing files to ${e} and ${t}...`),await Ue({shadowTokens:c,jsonDir:e,stylesDir:t,jsonFileName:r,cssFileName:o}),console.log("[shadows/tokenManager] ✅ Successfully generated shadow files")}catch(a){const i=a instanceof Error?a.message:String(a);throw console.error("[shadows/tokenManager] ❌ Failed to generate shadows:",i),a instanceof Error&&a.stack&&console.error("[shadows/tokenManager] Stack trace:",a.stack),a}}}),x=n=>{const e={};return Object.entries(n).forEach(([t,r])=>{const o=t.replace(/([A-Z])/g,"-$1").toLowerCase();e[o]=r}),e},Ye=(n,e)=>{const t=Object.keys(n.breakpoints),r=x(n.base);return t.reduce((o,s,a)=>{const i=x(n.breakpoints[s]);return a?[...o,{breakpoint:Number(e[s]),css:i}]:[{breakpoint:null,css:{...r,...i}}]},[{breakpoint:null,css:r}])},N=n=>Object.keys(n).reduce((e,t)=>{const r=n[t],o=Object.keys(r).map(s=>`${s}: ${r[s]}`).join(";");return e+`.${t}Typography { ${o} }`},""),Ze=(n,e)=>{const t=n.reduce((s,a)=>(Ye(a.value,e).forEach(({breakpoint:l,css:c})=>{l?(s.breakpoints[l]||(s.breakpoints[l]={}),s.breakpoints[l][a.name]=c):s.base[a.name]=c}),s),{base:{},breakpoints:{}}),r=N(t.base),o=Object.keys(t.breakpoints).reduce((s,a)=>{const i=t.breakpoints[a];return s+`@media (max-width: ${a}px) { ${N(i)} }`},"");return r+o},_e=n=>{const e=n.reduce((t,r)=>({...t,[r.name]:r.value}),{});return JSON.stringify(e)},et=async(n,e,t,r,o,s)=>{await Promise.all([d.delete(o,t),d.delete(s,r)]);const a=d.write(o,n,{directory:t}),i=d.write(s,e,{directory:r});await Promise.all([a,i])},tt=async({typographyTokens:n,jsonDir:e,stylesDir:t,jsonFileName:r,cssFileName:o,breakpoints:s,isModule:a})=>{const i=Ze(n,s),l=_e(n),c=`${o}${a?".module":""}.css`,u=`${r}.json`;await et(l,i,e,t,u,c)},J=(n,e,t)=>Object.keys(n).reduce((r,o)=>{const s=n[o];if(typeof s!="object"||Array.isArray(s))return r;if(!("type"in s)||!("value"in s))return{...r,[o]:J(s,e,t)};if(s.type!=="typography")return r;const a=s.value,i=Object.entries(a).reduce((l,[c,u])=>{const f=Object.keys(t.breakpoints);if(f.length)f.forEach(g=>{const p=e.resolveVariableValueString(u,g);p&&(p===u?l.base={...l.base,[c]:p}:l.breakpoints[g]={...l.breakpoints[g],[c]:p})});else{const g=e.resolveVariableValueString(u);g&&(l.base={...l.base,[c]:g})}return l},{base:{},breakpoints:{}});return{...r,[o]:{type:"typography",value:i}}},{}),W=(n,e)=>Object.keys(n).reduce((t,r)=>{const o=e?`${e}-${r}`:r,s=n[r];if(!("type"in s)||!("value"in s))return{...t,...W(s,o)};const a=s.value;return{...t,[o]:a}},{}),rt=({input:n,output:{jsonDir:e,stylesDir:t,jsonFileName:r="typography",cssFileName:o="typography"}})=>({name:"typography/tokenManager",executor:async({tokenManagerClient:s})=>{try{console.log("[typography/tokenManager] Generating typography from TokenManager...");const{breakpoints:a,isModule:i}=n;if(!s.isLoaded())throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");const l=[],c=s.getStyles();console.log("[typography/tokenManager] Processing styles for typography..."),c.text&&l.push(c.text);const u=l.reduce((g,p)=>({...g,...J(p,s,{breakpoints:n.breakpoints})}),{}),f=Object.entries(W(u)).map(([g,p])=>({name:g,value:p}));if(f.length===0){console.warn("[typography/tokenManager] No typography tokens generated");return}console.log(`[typography/tokenManager] Generated ${f.length} typography tokens`),console.log(`[typography/tokenManager] Writing files to ${e} and ${t}...`),await tt({typographyTokens:f,jsonDir:e,stylesDir:t,jsonFileName:r,cssFileName:o,breakpoints:a,isModule:i}),console.log("[typography/tokenManager] ✅ Successfully generated typography files")}catch(a){const i=a instanceof Error?a.message:String(a);throw console.error("[typography/tokenManager] ❌ Failed to generate typography:",i),a instanceof Error&&a.stack&&console.error("[typography/tokenManager] Stack trace:",a.stack),a}}});exports.BREAKPOINTS_NAMES=v;exports.TokenManager=L;exports.breakpointsFromTokenManager=fe;exports.breakpointsListFromTokenManager=be;exports.colorsFromTokenManager=Pe;exports.containerFromTokenManager=Ie;exports.generate=X;exports.init=Y;exports.shadowsFromTokenManager=Xe;exports.typographyFromTokenManager=rt;
|