@greensight/gts 1.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +68 -0
  3. package/bin/generate.cjs +12 -0
  4. package/bin/generate.js +21 -0
  5. package/bin/generate.mjs +10 -0
  6. package/bin/init.cjs +11 -0
  7. package/bin/init.js +19 -0
  8. package/bin/init.mjs +8 -0
  9. package/classes/Config/index.d.ts +13 -0
  10. package/classes/Config/index.d.ts.map +1 -0
  11. package/classes/FigmaApi/index.d.ts +16 -0
  12. package/classes/FigmaApi/index.d.ts.map +1 -0
  13. package/classes/FigmaApi/types.d.ts +7 -0
  14. package/classes/FigmaApi/types.d.ts.map +1 -0
  15. package/classes/FigmaApi/utils.d.ts +3 -0
  16. package/classes/FigmaApi/utils.d.ts.map +1 -0
  17. package/classes/FileStorage/index.d.ts +19 -0
  18. package/classes/FileStorage/index.d.ts.map +1 -0
  19. package/classes/TokenManager/index.d.ts +71 -0
  20. package/classes/TokenManager/index.d.ts.map +1 -0
  21. package/classes/TokenManager/types/ds.d.ts +25 -0
  22. package/classes/TokenManager/types/ds.d.ts.map +1 -0
  23. package/classes/TokenManager/types/figma.d.ts +82 -0
  24. package/classes/TokenManager/types/figma.d.ts.map +1 -0
  25. package/classes/TokenManager/types/index.d.ts +3 -0
  26. package/classes/TokenManager/types/index.d.ts.map +1 -0
  27. package/commands/generate/index.d.ts +2 -0
  28. package/commands/generate/index.d.ts.map +1 -0
  29. package/commands/init/index.d.ts +2 -0
  30. package/commands/init/index.d.ts.map +1 -0
  31. package/common/console.d.ts +3 -0
  32. package/common/console.d.ts.map +1 -0
  33. package/common/types.d.ts +29 -0
  34. package/common/types.d.ts.map +1 -0
  35. package/index.cjs +8 -0
  36. package/index.d.ts +6 -0
  37. package/index.d.ts.map +1 -0
  38. package/index.mjs +732 -0
  39. package/modules/colors/colorsFromStyles.d.ts +16 -0
  40. package/modules/colors/colorsFromStyles.d.ts.map +1 -0
  41. package/modules/colors/colorsFromTokenManager.d.ts +17 -0
  42. package/modules/colors/colorsFromTokenManager.d.ts.map +1 -0
  43. package/modules/colors/colorsFromVariables.d.ts +16 -0
  44. package/modules/colors/colorsFromVariables.d.ts.map +1 -0
  45. package/modules/colors/index.d.ts +4 -0
  46. package/modules/colors/index.d.ts.map +1 -0
  47. package/modules/colors/types.d.ts +6 -0
  48. package/modules/colors/types.d.ts.map +1 -0
  49. package/modules/colors/utils.d.ts +45 -0
  50. package/modules/colors/utils.d.ts.map +1 -0
  51. package/modules/index.d.ts +2 -0
  52. package/modules/index.d.ts.map +1 -0
  53. package/modules/types.d.ts +10 -0
  54. package/modules/types.d.ts.map +1 -0
  55. package/package.json +44 -0
@@ -0,0 +1,16 @@
1
+ import { IModule } from '../types';
2
+ export interface IColorsFromStylesInput {
3
+ variablePaths?: string[];
4
+ }
5
+ export interface IColorsFromStylesOutput {
6
+ jsonDir: string;
7
+ stylesDir: string;
8
+ jsonFileName?: string;
9
+ cssFileName?: string;
10
+ }
11
+ export interface IColorsFromStylesParams {
12
+ input?: IColorsFromStylesInput;
13
+ output: IColorsFromStylesOutput;
14
+ }
15
+ export declare const colorsFromStyles: ({ input, output: { jsonDir, stylesDir, jsonFileName, cssFileName }, }: IColorsFromStylesParams) => IModule;
16
+ //# sourceMappingURL=colorsFromStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorsFromStyles.d.ts","sourceRoot":"","sources":["../../../src/modules/colors/colorsFromStyles.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxC,MAAM,WAAW,sBAAsB;IACnC,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,uBAAuB;IACpC,KAAK,CAAC,EAAE,sBAAsB,CAAC;IAC/B,MAAM,EAAE,uBAAuB,CAAC;CACnC;AAED,eAAO,MAAM,gBAAgB,GAAI,uEAG9B,uBAAuB,KAAG,OA4H3B,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { IModule } from '../types';
2
+ export interface IColorsFromTokenManagerInput {
3
+ includeVariables?: string[];
4
+ includeStyles?: boolean;
5
+ }
6
+ export interface IColorsFromTokenManagerOutput {
7
+ jsonDir: string;
8
+ stylesDir: string;
9
+ jsonFileName?: string;
10
+ cssFileName?: string;
11
+ }
12
+ export interface IColorsFromTokenManagerParams {
13
+ input?: IColorsFromTokenManagerInput;
14
+ output: IColorsFromTokenManagerOutput;
15
+ }
16
+ export declare const colorsFromTokenManager: ({ input, output: { jsonDir, stylesDir, jsonFileName, cssFileName }, }: IColorsFromTokenManagerParams) => IModule;
17
+ //# sourceMappingURL=colorsFromTokenManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorsFromTokenManager.d.ts","sourceRoot":"","sources":["../../../src/modules/colors/colorsFromTokenManager.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC,MAAM,WAAW,4BAA4B;IACzC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,6BAA6B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,6BAA6B;IAC1C,KAAK,CAAC,EAAE,4BAA4B,CAAC;IACrC,MAAM,EAAE,6BAA6B,CAAC;CACzC;AAiFD,eAAO,MAAM,sBAAsB,GAAI,uEAGpC,6BAA6B,KAAG,OAuEjC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { IModule } from '../types';
2
+ export interface IColorsFromVariablesInput {
3
+ variablePaths: string[];
4
+ }
5
+ export interface IColorsFromVariablesOutput {
6
+ jsonDir: string;
7
+ stylesDir: string;
8
+ jsonFileName?: string;
9
+ cssFileName?: string;
10
+ }
11
+ export interface IColorsFromVariablesParams {
12
+ input: IColorsFromVariablesInput;
13
+ output: IColorsFromVariablesOutput;
14
+ }
15
+ export declare const colorsFromVariables: ({ input: { variablePaths }, output: { jsonDir, stylesDir, jsonFileName, cssFileName }, }: IColorsFromVariablesParams) => IModule;
16
+ //# sourceMappingURL=colorsFromVariables.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colorsFromVariables.d.ts","sourceRoot":"","sources":["../../../src/modules/colors/colorsFromVariables.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAIxC,MAAM,WAAW,yBAAyB;IACtC,aAAa,EAAE,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,0BAA0B;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,0BAA0B;IACvC,KAAK,EAAE,yBAAyB,CAAC;IACjC,MAAM,EAAE,0BAA0B,CAAC;CACtC;AAED,eAAO,MAAM,mBAAmB,GAAI,0FAGjC,0BAA0B,KAAG,OA2G9B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './colorsFromStyles';
2
+ export * from './colorsFromVariables';
3
+ export * from './colorsFromTokenManager';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/modules/colors/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,6 @@
1
+ export type TColorTokenValue = string | Record<string, string>;
2
+ export interface IColorToken {
3
+ name: string;
4
+ value: TColorTokenValue;
5
+ }
6
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/modules/colors/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE/D,MAAM,WAAW,WAAW;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,CAAC;CAC3B"}
@@ -0,0 +1,45 @@
1
+ import { ColorStop, GradientPaint, Paint, Vector } from '@figma/rest-api-spec';
2
+ import { IColorToken } from './types';
3
+ export declare const rgbToHex: ({ r, g, b }: {
4
+ r: number;
5
+ g: number;
6
+ b: number;
7
+ }) => string;
8
+ export declare const getSolidColor: ({ opacity, r, g, b }: {
9
+ opacity: number;
10
+ r: number;
11
+ g: number;
12
+ b: number;
13
+ }) => string;
14
+ export declare const getAngelDeg: (gradientHandlePositions: Vector[], adjustemntDeg?: number) => number;
15
+ export declare const getMappedColors: (gradientStops: ColorStop[]) => string;
16
+ export declare const getGradientCenterCoordinates: (gradientHandlePositions: Vector[]) => {
17
+ centerX: string;
18
+ centerY: string;
19
+ };
20
+ export declare const getGradientLinerColor: (paint: GradientPaint) => string;
21
+ export declare const getGradientRadius: (gradientHandlePositions: Vector[]) => {
22
+ radiusX: string;
23
+ radiusY: string;
24
+ };
25
+ export declare const getGradientRadial: (paint: GradientPaint) => string;
26
+ export declare const getGradientAnugular: (paint: GradientPaint) => string;
27
+ export declare const paintToColorToken: (paint: Paint) => string;
28
+ export declare const formatCSSBlock: (selector: string, variables: string[]) => string;
29
+ export declare const formatModeClassName: (modeName: string) => string;
30
+ export declare const getVariableName: (name: string) => string;
31
+ export declare const getCSSVariableName: (name: string) => string;
32
+ export declare const buildCSSVariables: (colorTokens: IColorToken[]) => Record<string, string[]>;
33
+ export declare const buildCSSContent: (cssVariables: Record<string, string[]>) => string;
34
+ export declare const buildJSONContent: (colorTokens: IColorToken[]) => string;
35
+ export declare const writeColorFiles: (jsonContent: string, cssContent: string, jsonDir: string, stylesDir: string, jsonFileName: string, cssFileName: string) => Promise<void>;
36
+ interface IGenerateFilesParams {
37
+ colorTokens: IColorToken[];
38
+ jsonDir: string;
39
+ stylesDir: string;
40
+ jsonFileName: string;
41
+ cssFileName: string;
42
+ }
43
+ export declare const generateColorFiles: ({ colorTokens, jsonDir, stylesDir, jsonFileName, cssFileName, }: IGenerateFilesParams) => Promise<void>;
44
+ export {};
45
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/modules/colors/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGpF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,eAAO,MAAM,QAAQ,GAAI,aAAa;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,WAGxE,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,sBAAsB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,WAKvG,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,yBAAyB,MAAM,EAAE,EAAE,sBAAiB,WAO/E,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,eAAe,SAAS,EAAE,WAevC,CAAC;AAEpB,eA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O,MAAM,kBAAkB,GAAU,iEAMtC,oBAAoB,kBAMtB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './colors';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { FigmaAPI } from '../classes/FigmaApi';
2
+ import { TokenManager } from '../classes/TokenManager';
3
+ export interface IModule {
4
+ name: string;
5
+ executor: ({ figmaApiClient, tokenManagerClient, }: {
6
+ figmaApiClient: FigmaAPI;
7
+ tokenManagerClient: TokenManager;
8
+ }) => Promise<void>;
9
+ }
10
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/modules/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAI5D,MAAM,WAAW,OAAO;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,CAAC,EACP,cAAc,EACd,kBAAkB,GACrB,EAAE;QACC,cAAc,EAAE,QAAQ,CAAC;QACzB,kBAAkB,EAAE,YAAY,CAAC;KACpC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@greensight/gts",
3
+ "version": "1.0.0-alpha.10",
4
+ "description": "Generate design tokens from Figma",
5
+ "keywords": [
6
+ "figma",
7
+ "design-tokens",
8
+ "tokens",
9
+ "figma-api",
10
+ "design-system",
11
+ "css-variables",
12
+ "typescript"
13
+ ],
14
+ "private": false,
15
+ "engines": {
16
+ "node": ">=16.0.0"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/greensight/gts"
21
+ },
22
+ "bugs": "https://github.com/greensight/gts/issues",
23
+ "homepage": "https://github.com/greensight/gts",
24
+ "license": "MIT",
25
+ "peerDependencies": {
26
+ "lodash-es": "^4.17.23",
27
+ "rimraf": "^6.0.1",
28
+ "ts-import": "2.0.40"
29
+ },
30
+ "types": "./index.d.ts",
31
+ "main": "./index.cjs",
32
+ "module": "./index.mjs",
33
+ "exports": {
34
+ ".": {
35
+ "types": "./index.d.ts",
36
+ "import": "./index.mjs",
37
+ "require": "./index.cjs"
38
+ }
39
+ },
40
+ "bin": {
41
+ "gts-init": "./bin/init.js",
42
+ "gts-generate": "./bin/generate.js"
43
+ }
44
+ }