@ama-styling/figma-extractor 12.5.0-prerelease.51
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/LICENSE +26 -0
- package/README.md +61 -0
- package/cli/figma-extract.d.ts +3 -0
- package/cli/figma-extract.d.ts.map +1 -0
- package/cli/figma-extract.js +115 -0
- package/cli/figma-extract.js.map +1 -0
- package/collection.json +11 -0
- package/core/constants.d.ts +3 -0
- package/core/constants.d.ts.map +1 -0
- package/core/constants.js +6 -0
- package/core/constants.js.map +1 -0
- package/core/generators/generate-manifest.d.ts +38 -0
- package/core/generators/generate-manifest.d.ts.map +1 -0
- package/core/generators/generate-manifest.js +35 -0
- package/core/generators/generate-manifest.js.map +1 -0
- package/core/generators/generate-package.d.ts +19 -0
- package/core/generators/generate-package.d.ts.map +1 -0
- package/core/generators/generate-package.js +42 -0
- package/core/generators/generate-package.js.map +1 -0
- package/core/generators/generate-tokens.d.ts +26 -0
- package/core/generators/generate-tokens.d.ts.map +1 -0
- package/core/generators/generate-tokens.js +31 -0
- package/core/generators/generate-tokens.js.map +1 -0
- package/core/generators/index.d.ts +5 -0
- package/core/generators/index.d.ts.map +1 -0
- package/core/generators/index.js +8 -0
- package/core/generators/index.js.map +1 -0
- package/core/generators/styles/generate-color.d.ts +25 -0
- package/core/generators/styles/generate-color.d.ts.map +1 -0
- package/core/generators/styles/generate-color.js +53 -0
- package/core/generators/styles/generate-color.js.map +1 -0
- package/core/generators/styles/generate-effect.d.ts +26 -0
- package/core/generators/styles/generate-effect.d.ts.map +1 -0
- package/core/generators/styles/generate-effect.js +54 -0
- package/core/generators/styles/generate-effect.js.map +1 -0
- package/core/generators/styles/generate-grid.d.ts +17 -0
- package/core/generators/styles/generate-grid.d.ts.map +1 -0
- package/core/generators/styles/generate-grid.js +41 -0
- package/core/generators/styles/generate-grid.js.map +1 -0
- package/core/generators/styles/generate-text.d.ts +25 -0
- package/core/generators/styles/generate-text.d.ts.map +1 -0
- package/core/generators/styles/generate-text.js +53 -0
- package/core/generators/styles/generate-text.js.map +1 -0
- package/core/generators/styles/index.d.ts +6 -0
- package/core/generators/styles/index.d.ts.map +1 -0
- package/core/generators/styles/index.js +9 -0
- package/core/generators/styles/index.js.map +1 -0
- package/core/generators/styles/interfaces.d.ts +15 -0
- package/core/generators/styles/interfaces.d.ts.map +1 -0
- package/core/generators/styles/interfaces.js +11 -0
- package/core/generators/styles/interfaces.js.map +1 -0
- package/core/generators/tokens/token-from-local-variables.d.ts +19 -0
- package/core/generators/tokens/token-from-local-variables.d.ts.map +1 -0
- package/core/generators/tokens/token-from-local-variables.js +59 -0
- package/core/generators/tokens/token-from-local-variables.js.map +1 -0
- package/core/helpers/color-hex.helpers.d.ts +12 -0
- package/core/helpers/color-hex.helpers.d.ts.map +1 -0
- package/core/helpers/color-hex.helpers.js +22 -0
- package/core/helpers/color-hex.helpers.js.map +1 -0
- package/core/helpers/context.helpers.d.ts +12 -0
- package/core/helpers/context.helpers.d.ts.map +1 -0
- package/core/helpers/context.helpers.js +20 -0
- package/core/helpers/context.helpers.js.map +1 -0
- package/core/helpers/create-output-folder.d.ts +8 -0
- package/core/helpers/create-output-folder.d.ts.map +1 -0
- package/core/helpers/create-output-folder.js +19 -0
- package/core/helpers/create-output-folder.js.map +1 -0
- package/core/helpers/file-names.d.ts +13 -0
- package/core/helpers/file-names.d.ts.map +1 -0
- package/core/helpers/file-names.js +23 -0
- package/core/helpers/file-names.js.map +1 -0
- package/core/helpers/generate-token-tree.helpers.d.ts +11 -0
- package/core/helpers/generate-token-tree.helpers.d.ts.map +1 -0
- package/core/helpers/generate-token-tree.helpers.js +26 -0
- package/core/helpers/generate-token-tree.helpers.js.map +1 -0
- package/core/helpers/name-to-reference.d.ts +6 -0
- package/core/helpers/name-to-reference.d.ts.map +1 -0
- package/core/helpers/name-to-reference.js +13 -0
- package/core/helpers/name-to-reference.js.map +1 -0
- package/core/helpers/variable-formatter.d.ts +7 -0
- package/core/helpers/variable-formatter.d.ts.map +1 -0
- package/core/helpers/variable-formatter.js +21 -0
- package/core/helpers/variable-formatter.js.map +1 -0
- package/core/helpers/vector.d.ts +11 -0
- package/core/helpers/vector.d.ts.map +1 -0
- package/core/helpers/vector.js +16 -0
- package/core/helpers/vector.js.map +1 -0
- package/core/interfaces.d.ts +31 -0
- package/core/interfaces.d.ts.map +1 -0
- package/core/interfaces.js +3 -0
- package/core/interfaces.js.map +1 -0
- package/core/requests/get-file.request.d.ts +12 -0
- package/core/requests/get-file.request.d.ts.map +1 -0
- package/core/requests/get-file.request.js +18 -0
- package/core/requests/get-file.request.js.map +1 -0
- package/core/requests/get-text-weight.request.d.ts +14 -0
- package/core/requests/get-text-weight.request.d.ts.map +1 -0
- package/core/requests/get-text-weight.request.js +31 -0
- package/core/requests/get-text-weight.request.js.map +1 -0
- package/core/requests/get-variable.request.d.ts +14 -0
- package/core/requests/get-variable.request.d.ts.map +1 -0
- package/core/requests/get-variable.request.js +21 -0
- package/core/requests/get-variable.request.js.map +1 -0
- package/core/requests/get-versions.request.d.ts +53 -0
- package/core/requests/get-versions.request.d.ts.map +1 -0
- package/core/requests/get-versions.request.js +95 -0
- package/core/requests/get-versions.request.js.map +1 -0
- package/generate-json.d.ts +22 -0
- package/generate-json.d.ts.map +1 -0
- package/generate-json.js +77 -0
- package/generate-json.js.map +1 -0
- package/package.json +176 -0
- package/public_api.d.ts +4 -0
- package/public_api.d.ts.map +1 -0
- package/public_api.js +7 -0
- package/public_api.js.map +1 -0
- package/schematics/ng-add/index.d.ts +8 -0
- package/schematics/ng-add/index.d.ts.map +1 -0
- package/schematics/ng-add/index.js +44 -0
- package/schematics/ng-add/schema.d.ts +12 -0
- package/schematics/ng-add/schema.d.ts.map +1 -0
- package/schematics/ng-add/schema.js +3 -0
- package/schematics/ng-add/schema.json +31 -0
- package/schematics/package.json +3 -0
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.generateEffectStyles = void 0;
|
4
|
+
const figma_sdk_1 = require("@ama-styling/figma-sdk");
|
5
|
+
const color_hex_helpers_1 = require("../../helpers/color-hex.helpers");
|
6
|
+
const generate_token_tree_helpers_1 = require("../../helpers/generate-token-tree.helpers");
|
7
|
+
const variable_formatter_1 = require("../../helpers/variable-formatter");
|
8
|
+
/**
|
9
|
+
* Generate effect style tokens
|
10
|
+
* @param apiClient Api Client
|
11
|
+
* @param figmaFile Figma File information
|
12
|
+
* @param localVariablesResponse list of file variables
|
13
|
+
* @param options Options
|
14
|
+
*/
|
15
|
+
const generateEffectStyles = async (apiClient, figmaFile, localVariablesResponse, options) => {
|
16
|
+
const formatVariables = (0, variable_formatter_1.getVariablesFormatter)(await localVariablesResponse);
|
17
|
+
const filesApi = new figma_sdk_1.FilesApi(apiClient);
|
18
|
+
const styles = (await figmaFile).styles;
|
19
|
+
const ids = Object.entries(styles)
|
20
|
+
.filter(([, { styleType, remote }]) => styleType === 'EFFECT' && !remote)
|
21
|
+
.map(([id]) => id)
|
22
|
+
.join(',');
|
23
|
+
const nodes = (await filesApi.getFileNodes({ file_key: options.fileKey, ids })).nodes;
|
24
|
+
const ret = Object.values(nodes)
|
25
|
+
.filter(({ document }) => document.effects.length > 0)
|
26
|
+
.reduce((acc, { document }) => {
|
27
|
+
const doc = document;
|
28
|
+
const value = doc.effects
|
29
|
+
.map((effect) => {
|
30
|
+
switch (effect.type) {
|
31
|
+
case 'INNER_SHADOW':
|
32
|
+
case 'DROP_SHADOW': {
|
33
|
+
return {
|
34
|
+
blur: formatVariables(effect.boundVariables?.radius) || `${effect.radius}${options.defaultUnit || 'px'}` || '0',
|
35
|
+
color: formatVariables(effect.boundVariables?.color) || (0, color_hex_helpers_1.getRgbaColorHex)(effect.color) || '',
|
36
|
+
offsetX: formatVariables(effect.boundVariables?.offsetX) || `${effect.offset.x}${options.defaultUnit || 'px'}` || '0',
|
37
|
+
offsetY: formatVariables(effect.boundVariables?.offsetY) || `${effect.offset.y}${options.defaultUnit || 'px'}` || '0',
|
38
|
+
spread: formatVariables(effect.boundVariables?.spread) || `${effect.spread}${options.defaultUnit || 'px'}` || '0',
|
39
|
+
inset: effect.type === 'INNER_SHADOW'
|
40
|
+
};
|
41
|
+
}
|
42
|
+
default: {
|
43
|
+
options.logger?.warn?.(`Not supported effect type ${effect.type} for ${doc.id}`);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
})
|
47
|
+
.filter((effect) => !!effect);
|
48
|
+
acc[doc.name] = { value, description: styles[document.id].description };
|
49
|
+
return acc;
|
50
|
+
}, {});
|
51
|
+
return (0, generate_token_tree_helpers_1.generateTokenTree)(ret, 'shadow');
|
52
|
+
};
|
53
|
+
exports.generateEffectStyles = generateEffectStyles;
|
54
|
+
//# sourceMappingURL=generate-effect.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-effect.js","sourceRoot":"","sources":["../../../../src/core/generators/styles/generate-effect.ts"],"names":[],"mappings":";;;AAGA,sDAKgC;AAChC,uEAEyC;AACzC,2FAEmD;AACnD,yEAE0C;AAoB1C;;;;;;GAMG;AACI,MAAM,oBAAoB,GAAG,KAAK,EACvC,SAAoB,EACpB,SAAsC,EACtC,sBAAiE,EACjE,OAA4B,EAC5B,EAAE;IACF,MAAM,eAAe,GAAG,IAAA,0CAAqB,EAAC,MAAM,sBAAsB,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,IAAI,oBAAQ,CAAC,SAAS,CAAC,CAAC;IACzC,MAAM,MAAM,GAAG,CAAC,MAAM,SAAS,CAAC,CAAC,MAAM,CAAC;IACxC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAC/B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,SAAS,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC;SACxE,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE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CAAC,CAAC,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,EAAE,IAAI,GAAG;wBACrH,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC,cAAc,EAAE,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,EAAE,IAAI,GAAG;wBACjH,KAAK,EAAE,MAAM,CAAC,IAAI,KAAK,cAAc;qBACtC,CAAC;gBACJ,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,6BAA6B,MAAM,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;gBACnF,CAAC;YACH,CAAC;QACH,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QAClD,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QACxE,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAA+D,CAAC,CAAC;IACtE,OAAO,IAAA,+CAAiB,EAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC,CAAC;AA1CW,QAAA,oBAAoB,wBA0C/B"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { ApiClient } from '@ama-sdk/core';
|
2
|
+
import { type GetFile200Response, type GetLocalVariables200ResponseMeta } from '@ama-styling/figma-sdk';
|
3
|
+
import type { FigmaFileContext } from '../../interfaces';
|
4
|
+
/** Options to {@link generateGridStyles} */
|
5
|
+
export interface GridStylesOptions extends FigmaFileContext {
|
6
|
+
/** Default unit to apply to number when not excluded */
|
7
|
+
defaultUnit?: string;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Generate grid style tokens
|
11
|
+
* @param apiClient Api Client
|
12
|
+
* @param figmaFile Figma File information
|
13
|
+
* @param _localVariablesResponse list of file variables
|
14
|
+
* @param options Options
|
15
|
+
*/
|
16
|
+
export declare const generateGridStyles: (apiClient: ApiClient, figmaFile: Promise<GetFile200Response>, _localVariablesResponse: Promise<GetLocalVariables200ResponseMeta>, options: GridStylesOptions) => Promise<import("../../interfaces").DesignTokenTree<any>>;
|
17
|
+
//# sourceMappingURL=generate-grid.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-grid.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/styles/generate-grid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,gCAAgC,EACtC,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAY1B,4CAA4C;AAC5C,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;IACzD,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,WAAW,SAAS,EACpB,WAAW,OAAO,CAAC,kBAAkB,CAAC,EACtC,yBAAyB,OAAO,CAAC,gCAAgC,CAAC,EAClE,SAAS,iBAAiB,6DA0B3B,CAAC"}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.generateGridStyles = void 0;
|
4
|
+
const figma_sdk_1 = require("@ama-styling/figma-sdk");
|
5
|
+
const color_hex_helpers_1 = require("../../helpers/color-hex.helpers");
|
6
|
+
const generate_token_tree_helpers_1 = require("../../helpers/generate-token-tree.helpers");
|
7
|
+
/**
|
8
|
+
* Generate grid style tokens
|
9
|
+
* @param apiClient Api Client
|
10
|
+
* @param figmaFile Figma File information
|
11
|
+
* @param _localVariablesResponse list of file variables
|
12
|
+
* @param options Options
|
13
|
+
*/
|
14
|
+
const generateGridStyles = async (apiClient, figmaFile, _localVariablesResponse, options) => {
|
15
|
+
const filesApi = new figma_sdk_1.FilesApi(apiClient);
|
16
|
+
const styles = (await figmaFile).styles;
|
17
|
+
const ids = Object.entries(styles)
|
18
|
+
.filter(([, { styleType, remote }]) => styleType === 'GRID' && !remote)
|
19
|
+
.map(([id]) => id)
|
20
|
+
.join(',');
|
21
|
+
const nodes = (await filesApi.getFileNodes({ file_key: options.fileKey, ids })).nodes;
|
22
|
+
const ret = Object.values(nodes)
|
23
|
+
.filter(({ document }) => !!document.layoutGrids)
|
24
|
+
.reduce((acc, { document }) => {
|
25
|
+
const value = document.layoutGrids
|
26
|
+
?.map((layoutGrid) => ({
|
27
|
+
pattern: layoutGrid.pattern.toLowerCase(),
|
28
|
+
visible: layoutGrid.visible,
|
29
|
+
alignment: layoutGrid.alignment.toLowerCase(),
|
30
|
+
color: (0, color_hex_helpers_1.getRgbaColorHex)(layoutGrid.color),
|
31
|
+
gutterSize: `${layoutGrid.gutterSize}${options.defaultUnit || 'px'}`,
|
32
|
+
count: layoutGrid.count,
|
33
|
+
offset: `${layoutGrid.offset}${options.defaultUnit || 'px'}`
|
34
|
+
}));
|
35
|
+
acc[document.name] = { value, description: styles[document.id].description };
|
36
|
+
return acc;
|
37
|
+
}, {});
|
38
|
+
return (0, generate_token_tree_helpers_1.generateTokenTree)(ret, 'grid');
|
39
|
+
};
|
40
|
+
exports.generateGridStyles = generateGridStyles;
|
41
|
+
//# sourceMappingURL=generate-grid.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-grid.js","sourceRoot":"","sources":["../../../../src/core/generators/styles/generate-grid.ts"],"names":[],"mappings":";;;AAGA,sDAKgC;AAChC,uEAEyC;AACzC,2FAEmD;AAqBnD;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,KAAK,EACrC,SAAoB,EACpB,SAAsC,EACtC,uBA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AAE;YACpE,KAAK,EAAE,UAAU,CAAC,KAAK;YACvB,MAAM,EAAE,GAAG,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC,WAAW,IAAI,IAAI,EAAE;SAC7D,CAAC,CAAC,CAAC;QACN,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7E,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAA0D,CAAC,CAAC;IACjE,OAAO,IAAA,+CAAiB,EAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AACxC,CAAC,CAAC;AA9BW,QAAA,kBAAkB,sBA8B7B"}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { ApiClient } from '@ama-sdk/core';
|
2
|
+
import { type GetFile200Response, type GetLocalVariables200ResponseMeta } from '@ama-styling/figma-sdk';
|
3
|
+
import type { FigmaFileContext } from '../../interfaces';
|
4
|
+
interface Font {
|
5
|
+
fontFamily: string;
|
6
|
+
fontSize: string;
|
7
|
+
fontWeight: number | string;
|
8
|
+
letterSpacing: string;
|
9
|
+
lineHeight: string;
|
10
|
+
textTransform: string;
|
11
|
+
textDecoration: string;
|
12
|
+
}
|
13
|
+
/** Options to {@link generateTextStyles} */
|
14
|
+
export interface TextStylesOptions extends FigmaFileContext {
|
15
|
+
}
|
16
|
+
/**
|
17
|
+
* Generate text style tokens
|
18
|
+
* @param apiClient Api Client
|
19
|
+
* @param figmaFile Figma File information
|
20
|
+
* @param localVariablesResponse list of file variables
|
21
|
+
* @param options Options
|
22
|
+
*/
|
23
|
+
export declare const generateTextStyles: (apiClient: ApiClient, figmaFile: Promise<GetFile200Response>, localVariablesResponse: Promise<GetLocalVariables200ResponseMeta>, options: TextStylesOptions) => Promise<import("../../interfaces").DesignTokenTree<Font>>;
|
24
|
+
export {};
|
25
|
+
//# sourceMappingURL=generate-text.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-text.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/styles/generate-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACV,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,kBAAkB,EACvB,KAAK,gCAAgC,EACtC,MAAM,wBAAwB,CAAC;AAOhC,OAAO,KAAK,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAE1B,UAAU,IAAI;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,4CAA4C;AAC5C,MAAM,WAAW,iBAAkB,SAAQ,gBAAgB;CAC1D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,GAC7B,WAAW,SAAS,EACpB,WAAW,OAAO,CAAC,kBAAkB,CAAC,EACtC,wBAAwB,OAAO,CAAC,gCAAgC,CAAC,EACjE,SAAS,iBAAiB,8DAuC3B,CAAC"}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.generateTextStyles = void 0;
|
4
|
+
const figma_sdk_1 = require("@ama-styling/figma-sdk");
|
5
|
+
const generate_token_tree_helpers_1 = require("../../helpers/generate-token-tree.helpers");
|
6
|
+
const variable_formatter_1 = require("../../helpers/variable-formatter");
|
7
|
+
/**
|
8
|
+
* Generate text style tokens
|
9
|
+
* @param apiClient Api Client
|
10
|
+
* @param figmaFile Figma File information
|
11
|
+
* @param localVariablesResponse list of file variables
|
12
|
+
* @param options Options
|
13
|
+
*/
|
14
|
+
const generateTextStyles = async (apiClient, figmaFile, localVariablesResponse, options) => {
|
15
|
+
const formatVariables = (0, variable_formatter_1.getVariablesFormatter)(await localVariablesResponse);
|
16
|
+
const filesApi = new figma_sdk_1.FilesApi(apiClient);
|
17
|
+
const styles = (await figmaFile).styles;
|
18
|
+
const ids = Object.entries(styles)
|
19
|
+
.filter(([, { styleType, remote }]) => styleType === 'TEXT' && !remote)
|
20
|
+
.map(([id]) => id)
|
21
|
+
.join(',');
|
22
|
+
const nodes = (await filesApi.getFileNodes({ file_key: options.fileKey, ids })).nodes;
|
23
|
+
const ret = Object.values(nodes)
|
24
|
+
.reduce((acc, { document }) => {
|
25
|
+
const style = document.style;
|
26
|
+
const fontFamily = formatVariables(document.boundVariables?.fontFamily)
|
27
|
+
?? style?.fontFamily ?? 'none';
|
28
|
+
const fontSize = formatVariables(document.boundVariables?.fontSize)
|
29
|
+
?? style?.fontSize ?? 'none';
|
30
|
+
const fontWeight = formatVariables(document.boundVariables?.fontWeight)
|
31
|
+
?? style?.fontWeight ?? 'none';
|
32
|
+
const letterSpacing = formatVariables(document.boundVariables?.letterSpacing)
|
33
|
+
?? style?.letterSpacing ?? 'none';
|
34
|
+
const lineHeight = formatVariables(document.boundVariables?.lineHeight)
|
35
|
+
?? style?.lineHeight ?? 'none';
|
36
|
+
const textDecoration = 'none';
|
37
|
+
const textTransform = 'none';
|
38
|
+
const value = {
|
39
|
+
fontFamily,
|
40
|
+
fontSize,
|
41
|
+
fontWeight,
|
42
|
+
letterSpacing,
|
43
|
+
lineHeight,
|
44
|
+
textDecoration,
|
45
|
+
textTransform
|
46
|
+
};
|
47
|
+
acc[document.name] = { value, description: styles[document.id].description };
|
48
|
+
return acc;
|
49
|
+
}, {});
|
50
|
+
return (0, generate_token_tree_helpers_1.generateTokenTree)(ret, 'typography');
|
51
|
+
};
|
52
|
+
exports.generateTextStyles = generateTextStyles;
|
53
|
+
//# sourceMappingURL=generate-text.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-text.js","sourceRoot":"","sources":["../../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KAAK,EAAE,QAAQ,IAAI,MAAM,CAAC;QAC/B,MAAM,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC;eAClE,KAAK,EAAE,UAAU,IAAI,MAAM,CAAC;QACjC,MAAM,aAAa,GAAG,eAAe,CAAC,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;eACxE,KAAK,EAAE,aAAa,IAAI,MAAM,CAAC;QACpC,MAAM,UAAU,GAAG,eAAe,CAAC,QAAQ,CAAC,cAAc,EAAE,UAAU,CAAC;eAClE,KAAK,EAAE,UAAU,IAAI,MAAM,CAAC;QACjC,MAAM,cAAc,GAAG,MAAM,CAAC;QAC9B,MAAM,aAAa,GAAG,MAAM,CAAC;QAE7B,MAAM,KAAK,GAAG;YACZ,UAAU;YACV,QAAQ;YACR,UAAU;YACV,aAAa;YACb,UAAU;YACV,cAAc;YACd,aAAa;SACC,CAAC;QACjB,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7E,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAA2D,CAAC,CAAC;IAClE,OAAO,IAAA,+CAAiB,EAAC,GAAG,EAAE,YAAY,CAAC,CAAC;AAC9C,CAAC,CAAC;AA3CW,QAAA,kBAAkB,sBA2C7B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/styles/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const tslib_1 = require("tslib");
|
4
|
+
tslib_1.__exportStar(require("./interfaces"), exports);
|
5
|
+
tslib_1.__exportStar(require("./generate-color"), exports);
|
6
|
+
tslib_1.__exportStar(require("./generate-effect"), exports);
|
7
|
+
tslib_1.__exportStar(require("./generate-grid"), exports);
|
8
|
+
tslib_1.__exportStar(require("./generate-text"), exports);
|
9
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/generators/styles/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,2DAAiC;AACjC,4DAAkC;AAClC,0DAAgC;AAChC,0DAAgC"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { StyleType } from '@ama-styling/figma-sdk';
|
2
|
+
/** List of style files as specified in the manifest */
|
3
|
+
export interface ManifestStyle {
|
4
|
+
/** Text */
|
5
|
+
text?: string[];
|
6
|
+
/** Color */
|
7
|
+
color?: string[];
|
8
|
+
/** Effect */
|
9
|
+
effect?: string[];
|
10
|
+
/** Grid */
|
11
|
+
grid?: string[];
|
12
|
+
}
|
13
|
+
/** List of available type and their names in Design Token */
|
14
|
+
export declare const styleTypeMapping: Readonly<Record<StyleType, keyof ManifestStyle>>;
|
15
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/styles/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,YAAY;IACZ,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa;IACb,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW;IACX,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,6DAA6D;AAC7D,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,aAAa,CAAC,CAKpE,CAAC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.styleTypeMapping = void 0;
|
4
|
+
/** List of available type and their names in Design Token */
|
5
|
+
exports.styleTypeMapping = {
|
6
|
+
FILL: 'color',
|
7
|
+
TEXT: 'text',
|
8
|
+
EFFECT: 'effect',
|
9
|
+
GRID: 'grid'
|
10
|
+
};
|
11
|
+
//# sourceMappingURL=interfaces.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/core/generators/styles/interfaces.ts"],"names":[],"mappings":";;;AAgBA,6DAA6D;AAChD,QAAA,gBAAgB,GAAqD;IAChF,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;CACJ,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { type GetLocalVariables200ResponseMeta } from '@ama-styling/figma-sdk';
|
2
|
+
import type { FigmaFileContext } from '../../interfaces';
|
3
|
+
/** Options to {@link getTokensFromLocalVariables} */
|
4
|
+
export interface TokenFromVariablesOptions extends FigmaFileContext {
|
5
|
+
/** Identification of the Mode defined in Figma */
|
6
|
+
modeId: string;
|
7
|
+
/** Identification of the Collection defined in Figma */
|
8
|
+
collectionId: string;
|
9
|
+
/** Default unit to apply to number when not excluded */
|
10
|
+
defaultUnit?: string;
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* Get Design Token from Local variables
|
14
|
+
* @param localVariablesResponse List of variables response from Figma
|
15
|
+
* @param unitLessVariableIds List of variables flagged to be provided without units
|
16
|
+
* @param options Context options
|
17
|
+
*/
|
18
|
+
export declare const getTokensFromLocalVariables: (localVariablesResponse: GetLocalVariables200ResponseMeta, unitLessVariableIds: string[], options: TokenFromVariablesOptions) => any;
|
19
|
+
//# sourceMappingURL=token-from-local-variables.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"token-from-local-variables.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/tokens/token-from-local-variables.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gCAAgC,EAGtC,MAAM,wBAAwB,CAAC;AAUhC,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAE1B,qDAAqD;AACrD,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IACjE,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IAEf,yDAAyD;IACzD,YAAY,EAAE,MAAM,CAAC;IAErB,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,GACtC,wBAAwB,gCAAgC,EACxD,qBAAqB,MAAM,EAAE,EAC7B,SAAS,yBAAyB,QAiDnC,CAAC"}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getTokensFromLocalVariables = void 0;
|
4
|
+
const figma_sdk_1 = require("@ama-styling/figma-sdk");
|
5
|
+
const constants_1 = require("../../constants");
|
6
|
+
const color_hex_helpers_1 = require("../../helpers/color-hex.helpers");
|
7
|
+
const name_to_reference_1 = require("../../helpers/name-to-reference");
|
8
|
+
/**
|
9
|
+
* Get Design Token from Local variables
|
10
|
+
* @param localVariablesResponse List of variables response from Figma
|
11
|
+
* @param unitLessVariableIds List of variables flagged to be provided without units
|
12
|
+
* @param options Context options
|
13
|
+
*/
|
14
|
+
const getTokensFromLocalVariables = (localVariablesResponse, unitLessVariableIds, options) => {
|
15
|
+
const { variables, variableCollections } = localVariablesResponse;
|
16
|
+
const unitLessGroups = [
|
17
|
+
...new Set(unitLessVariableIds
|
18
|
+
.map((id) => variables[id])
|
19
|
+
.filter((variable) => !!variable)
|
20
|
+
.map(({ name }) => name.substring(0, name.lastIndexOf(constants_1.VARIABLE_NAME_PATH_SEPARATOR))))
|
21
|
+
];
|
22
|
+
const filteredVariableIds = variableCollections[options.collectionId].variableIds;
|
23
|
+
return Object.entries(variables)
|
24
|
+
.filter(([id, variable]) => filteredVariableIds.includes(id) && !variable.remote)
|
25
|
+
.reduce((acc, [, variable]) => {
|
26
|
+
const value = variable.valuesByMode[options.modeId];
|
27
|
+
const resolvedVariable = {
|
28
|
+
$value: undefined,
|
29
|
+
$description: variable.description || undefined
|
30
|
+
};
|
31
|
+
if ((0, figma_sdk_1.isRGBA)(value)) {
|
32
|
+
resolvedVariable.$type = 'color';
|
33
|
+
resolvedVariable.$value = (0, color_hex_helpers_1.getRgbaColorHex)(value);
|
34
|
+
}
|
35
|
+
else if ((0, figma_sdk_1.isVariableAlias)(value)) {
|
36
|
+
if (variables[value.id]) {
|
37
|
+
resolvedVariable.$value = `{${(0, name_to_reference_1.convertNameToReference)(variables[value.id].name)}}`;
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
options?.logger?.error?.(`Cannot resolve ${value.id} from ${variable.name}.`);
|
41
|
+
return acc;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
resolvedVariable.$type = typeof value === 'number' ? 'dimension' : 'string';
|
46
|
+
resolvedVariable.$value = resolvedVariable.$type === 'dimension' && !unitLessGroups.some((group) => variable.name.startsWith(group))
|
47
|
+
? `${value}${options?.defaultUnit || 'px'}`
|
48
|
+
: value;
|
49
|
+
}
|
50
|
+
Object.assign(variable.name.split(constants_1.VARIABLE_NAME_PATH_SEPARATOR)
|
51
|
+
.reduce((loop, part) => {
|
52
|
+
loop[part] ||= {};
|
53
|
+
return loop[part];
|
54
|
+
}, acc), resolvedVariable);
|
55
|
+
return acc;
|
56
|
+
}, {});
|
57
|
+
};
|
58
|
+
exports.getTokensFromLocalVariables = getTokensFromLocalVariables;
|
59
|
+
//# sourceMappingURL=token-from-local-variables.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"token-from-local-variables.js","sourceRoot":"","sources":["../../../../src/core/generators/tokens/token-from-local-variables.ts"],"names":[],"mappings":";;;AAAA,sDAIgC;AAChC,+CAEyB;AACzB,uEAEyC;AACzC,uEAEyC;AAkBzC;;;;;GAKG;AACI,MAAM,2BAA2B,GAAG,CACzC,sBAAwD,EACxD,mBAA6B,EAC7B,OAAkC,EAClC,EAAE;IACF,MAAM,EAAE,SAAS,EAAE,mBAAmB,EAAE,GAAG,sBAAsB,CAAC;IAClE,MAAM,cAAc,GAAG;QACrB,GAAG,IAAI,GAAG,CACR,mBAAmB;aAChB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;aAC1B,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC;aAChC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,wCAA4B,CAAC,CAAC,CAAC,CACxF;KACF,CAAC;IACF,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC;IAElF,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SAC7B,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;SAChF,MAAM,CAAC,CAAC,GAAQ,EAAE,CAAC,EAAC,QAAQ,CAAC,EAAE,EAAE;QAChC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACpD,MAAM,gBAA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,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;YACrB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,EAAE,GAAG,CAAC,EACT,gBAAgB,CACjB,CAAC;QAEF,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAE,CAAC,CAAC;AACX,CAAC,CAAC;AApDW,QAAA,2BAA2B,+BAoDtC"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { RGBA } from '@ama-styling/figma-sdk';
|
2
|
+
/**
|
3
|
+
* Converts a color numeric value to its corresponding hexadecimal color code.
|
4
|
+
* @param color value of the color composite
|
5
|
+
*/
|
6
|
+
export declare const getColorHex: (color: number) => string;
|
7
|
+
/**
|
8
|
+
* Convert RGBA to color string
|
9
|
+
* @param value RGBA base color
|
10
|
+
*/
|
11
|
+
export declare const getRgbaColorHex: (value: RGBA) => string;
|
12
|
+
//# sourceMappingURL=color-hex.helpers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"color-hex.helpers.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/color-hex.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACL,MAAM,wBAAwB,CAAC;AAEhC;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,WAMxC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,IAAI,WAAyH,CAAC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getRgbaColorHex = exports.getColorHex = void 0;
|
4
|
+
/**
|
5
|
+
* Converts a color numeric value to its corresponding hexadecimal color code.
|
6
|
+
* @param color value of the color composite
|
7
|
+
*/
|
8
|
+
const getColorHex = (color) => {
|
9
|
+
if (color < 0 || color > 1) {
|
10
|
+
throw new Error('invalid color format');
|
11
|
+
}
|
12
|
+
const colorHex = (+(color * 255).toFixed(0)).toString(16);
|
13
|
+
return colorHex.length > 1 ? colorHex : `0${colorHex}`;
|
14
|
+
};
|
15
|
+
exports.getColorHex = getColorHex;
|
16
|
+
/**
|
17
|
+
* Convert RGBA to color string
|
18
|
+
* @param value RGBA base color
|
19
|
+
*/
|
20
|
+
const getRgbaColorHex = (value) => `#${(0, exports.getColorHex)(value.r)}${(0, exports.getColorHex)(value.g)}${(0, exports.getColorHex)(value.b)}${value.a === 1 ? '' : (0, exports.getColorHex)(value.a)}`;
|
21
|
+
exports.getRgbaColorHex = getRgbaColorHex;
|
22
|
+
//# sourceMappingURL=color-hex.helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"color-hex.helpers.js","sourceRoot":"","sources":["../../../src/core/helpers/color-hex.helpers.ts"],"names":[],"mappings":";;;AAIA;;;GAGG;AACI,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE;IAC3C,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,QAAQ,EAAE,CAAC;AACzD,CAAC,CAAC;AANW,QAAA,WAAW,eAMtB;AAEF;;;GAGG;AACI,MAAM,eAAe,GAAG,CAAC,KAAW,EAAE,EAAE,CAAC,IAAI,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAA,mBAAW,EAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAAxJ,QAAA,eAAe,mBAAyI"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import type { FigmaFileContext, FigmaProjectContext } from '../interfaces';
|
2
|
+
/**
|
3
|
+
* Determine if the object contain the Figma Context
|
4
|
+
* @param context Context object to test
|
5
|
+
*/
|
6
|
+
export declare const isFigmaFileContext: <T>(context: T) => context is (T & FigmaFileContext);
|
7
|
+
/**
|
8
|
+
* Determine if the object contain the Project Context
|
9
|
+
* @param context Context object to test
|
10
|
+
*/
|
11
|
+
export declare const isFigmaProjectContext: <T>(context: T) => context is (T & FigmaProjectContext);
|
12
|
+
//# sourceMappingURL=context.helpers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"context.helpers.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/context.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,eAAe,CAAC;AAEvB;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,SAAS,CAAC,KAAG,OAAO,IAAI,CAAC,CAAC,GAAG,gBAAgB,CAElF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,CAAC,EAAE,SAAS,CAAC,KAAG,OAAO,IAAI,CAAC,CAAC,GAAG,mBAAmB,CAExF,CAAC"}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isFigmaProjectContext = exports.isFigmaFileContext = void 0;
|
4
|
+
/**
|
5
|
+
* Determine if the object contain the Figma Context
|
6
|
+
* @param context Context object to test
|
7
|
+
*/
|
8
|
+
const isFigmaFileContext = (context) => {
|
9
|
+
return typeof context === 'object' && typeof context?.fileKey === 'string';
|
10
|
+
};
|
11
|
+
exports.isFigmaFileContext = isFigmaFileContext;
|
12
|
+
/**
|
13
|
+
* Determine if the object contain the Project Context
|
14
|
+
* @param context Context object to test
|
15
|
+
*/
|
16
|
+
const isFigmaProjectContext = (context) => {
|
17
|
+
return typeof context === 'object' && typeof context?.projectKey === 'string';
|
18
|
+
};
|
19
|
+
exports.isFigmaProjectContext = isFigmaProjectContext;
|
20
|
+
//# sourceMappingURL=context.helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"context.helpers.js","sourceRoot":"","sources":["../../../src/core/helpers/context.helpers.ts"],"names":[],"mappings":";;;AAKA;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAI,OAAU,EAAqC,EAAE;IACrF,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAQ,OAAe,EAAE,OAAO,KAAK,QAAQ,CAAC;AACtF,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEF;;;GAGG;AACI,MAAM,qBAAqB,GAAG,CAAI,OAAU,EAAwC,EAAE;IAC3F,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAQ,OAAe,EAAE,UAAU,KAAK,QAAQ,CAAC;AACzF,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC"}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { FigmaFileContext } from '../interfaces';
|
2
|
+
/**
|
3
|
+
* Create output folder if it does not exist
|
4
|
+
* @param output path to the output folder
|
5
|
+
* @param options Options
|
6
|
+
*/
|
7
|
+
export declare const createOutputFolder: (output: string, options?: Pick<FigmaFileContext, "logger">) => Promise<void>;
|
8
|
+
//# sourceMappingURL=create-output-folder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-output-folder.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/create-output-folder.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,GAAU,QAAQ,MAAM,EAAE,UAAU,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,kBAMlG,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.createOutputFolder = void 0;
|
4
|
+
const promises_1 = require("node:fs/promises");
|
5
|
+
/**
|
6
|
+
* Create output folder if it does not exist
|
7
|
+
* @param output path to the output folder
|
8
|
+
* @param options Options
|
9
|
+
*/
|
10
|
+
const createOutputFolder = async (output, options) => {
|
11
|
+
try {
|
12
|
+
await (0, promises_1.mkdir)(output, { recursive: true });
|
13
|
+
}
|
14
|
+
catch (e) {
|
15
|
+
options?.logger?.debug?.(`Fail to create ${output} because it already exists`, e);
|
16
|
+
}
|
17
|
+
};
|
18
|
+
exports.createOutputFolder = createOutputFolder;
|
19
|
+
//# sourceMappingURL=create-output-folder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-output-folder.js","sourceRoot":"","sources":["../../../src/core/helpers/create-output-folder.ts"],"names":[],"mappings":";;;AAAA,+CAE0B;AAK1B;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,KAAK,EAAE,MAAc,EAAE,OAA0C,EAAE,EAAE;IACrG,IAAI,CAAC;QACH,MAAM,IAAA,gBAAK,EAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,kBAAkB,MAAM,4BAA4B,EAAE,CAAC,CAAC,CAAC;IACpF,CAAC;AACH,CAAC,CAAC;AANW,QAAA,kBAAkB,sBAM7B"}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import type { LocalVariableCollectionModesInner, StyleType } from '@ama-styling/figma-sdk';
|
2
|
+
/**
|
3
|
+
* Retrieve the name of a styling file
|
4
|
+
* @param styleType Style type
|
5
|
+
*/
|
6
|
+
export declare const getStyleFileName: (styleType: StyleType) => string;
|
7
|
+
/**
|
8
|
+
* Retrieve the name of a token collection file
|
9
|
+
* @param collectionName Name of the collection
|
10
|
+
* @param mode Selected theme mode
|
11
|
+
*/
|
12
|
+
export declare const getCollectionFileName: (collectionName: string, mode: Pick<LocalVariableCollectionModesInner, "name">) => string;
|
13
|
+
//# sourceMappingURL=file-names.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-names.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/file-names.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,EACjC,SAAS,EACV,MAAM,wBAAwB,CAAC;AAKhC;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS,WAGpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,GAAI,gBAAgB,MAAM,EAAE,MAAM,IAAI,CAAC,iCAAiC,EAAE,MAAM,CAAC,WAElH,CAAC"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getCollectionFileName = exports.getStyleFileName = void 0;
|
4
|
+
const interfaces_1 = require("../generators/styles/interfaces");
|
5
|
+
/**
|
6
|
+
* Retrieve the name of a styling file
|
7
|
+
* @param styleType Style type
|
8
|
+
*/
|
9
|
+
const getStyleFileName = (styleType) => {
|
10
|
+
const styleLabel = interfaces_1.styleTypeMapping[styleType];
|
11
|
+
return `${styleLabel}.styles.tokens.json`;
|
12
|
+
};
|
13
|
+
exports.getStyleFileName = getStyleFileName;
|
14
|
+
/**
|
15
|
+
* Retrieve the name of a token collection file
|
16
|
+
* @param collectionName Name of the collection
|
17
|
+
* @param mode Selected theme mode
|
18
|
+
*/
|
19
|
+
const getCollectionFileName = (collectionName, mode) => {
|
20
|
+
return `${collectionName.replace(/\.json5?$/, '')}.${mode.name}.tokens.json`;
|
21
|
+
};
|
22
|
+
exports.getCollectionFileName = getCollectionFileName;
|
23
|
+
//# sourceMappingURL=file-names.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-names.js","sourceRoot":"","sources":["../../../src/core/helpers/file-names.ts"],"names":[],"mappings":";;;AAIA,gEAEyC;AAEzC;;;GAGG;AACI,MAAM,gBAAgB,GAAG,CAAC,SAAoB,EAAE,EAAE;IACvD,MAAM,UAAU,GAAG,6BAAgB,CAAC,SAAS,CAAC,CAAC;IAC/C,OAAO,GAAG,UAAU,qBAAqB,CAAC;AAC5C,CAAC,CAAC;AAHW,QAAA,gBAAgB,oBAG3B;AAEF;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAAC,cAAsB,EAAE,IAAqD,EAAE,EAAE;IACrH,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,IAAI,cAAc,CAAC;AAC/E,CAAC,CAAC;AAFW,QAAA,qBAAqB,yBAEhC"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { DesignTokenTree } from '../interfaces';
|
2
|
+
/**
|
3
|
+
* Generate a Design Token tree from the given variable list based on same {@link type}
|
4
|
+
* @param variables List of variables to generate the tree from
|
5
|
+
* @param type Type of the listed variables
|
6
|
+
*/
|
7
|
+
export declare const generateTokenTree: <T>(variables: Record<string, {
|
8
|
+
value: T;
|
9
|
+
description?: string;
|
10
|
+
}>, type: string) => DesignTokenTree<T>;
|
11
|
+
//# sourceMappingURL=generate-token-tree.helpers.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-token-tree.helpers.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/generate-token-tree.helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EAChB,MAAM,eAAe,CAAC;AAEvB;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,WAAW,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,CAAC,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,MAAM,MAAM,KAAG,eAAe,CAAC,CAAC,CAcnI,CAAC"}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.generateTokenTree = void 0;
|
4
|
+
const constants_1 = require("../constants");
|
5
|
+
/**
|
6
|
+
* Generate a Design Token tree from the given variable list based on same {@link type}
|
7
|
+
* @param variables List of variables to generate the tree from
|
8
|
+
* @param type Type of the listed variables
|
9
|
+
*/
|
10
|
+
const generateTokenTree = (variables, type) => {
|
11
|
+
return Object.entries(variables)
|
12
|
+
.reduce((acc, [name, { value, description }]) => {
|
13
|
+
const splitName = name.split(constants_1.VARIABLE_NAME_PATH_SEPARATOR);
|
14
|
+
let curr = acc;
|
15
|
+
// walk through the return object to create object tree branch (if it does not exist) and point the curr variable to the latest tree item to set the shadow to
|
16
|
+
splitName.forEach((n) => curr = curr[n] ||= {});
|
17
|
+
Object.assign(curr, {
|
18
|
+
$type: type,
|
19
|
+
$description: description || undefined,
|
20
|
+
$value: value
|
21
|
+
});
|
22
|
+
return acc;
|
23
|
+
}, {});
|
24
|
+
};
|
25
|
+
exports.generateTokenTree = generateTokenTree;
|
26
|
+
//# sourceMappingURL=generate-token-tree.helpers.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"generate-token-tree.helpers.js","sourceRoot":"","sources":["../../../src/core/helpers/generate-token-tree.helpers.ts"],"names":[],"mappings":";;;AAAA,4CAEsB;AAKtB;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAAI,SAA6D,EAAE,IAAY,EAAsB,EAAE;IACtI,OAAO,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC;SAC7B,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,EAAE;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,wCAA4B,CAAC,CAAC;QAC3D,IAAI,IAAI,GAAQ,GAAG,CAAC;QACpB,8JAA8J;QAC9J,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;YAClB,KAAK,EAAE,IAAI;YACX,YAAY,EAAE,WAAW,IAAI,SAAS;YACtC,MAAM,EAAE,KAAK;SACd,CAAC,CAAC;QACH,OAAO,GAAG,CAAC;IACb,CAAC,EAAE,EAAwB,CAAC,CAAC;AACjC,CAAC,CAAC;AAdW,QAAA,iBAAiB,qBAc5B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"name-to-reference.d.ts","sourceRoot":"","sources":["../../../src/core/helpers/name-to-reference.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,WAEvC,CAAC"}
|