@figma/code-connect 1.0.5 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -595
- package/dist/cli.js +2 -0
- package/dist/cli.js.map +1 -1
- package/dist/client/figma_client.d.ts +1 -1
- package/dist/client/figma_client.js +9 -7
- package/dist/client/figma_client.js.map +1 -1
- package/dist/commands/connect.d.ts +4 -2
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +97 -49
- package/dist/commands/connect.js.map +1 -1
- package/dist/connect/api.d.ts +143 -0
- package/dist/connect/api.d.ts.map +1 -0
- package/dist/connect/api.js +3 -0
- package/dist/connect/api.js.map +1 -0
- package/dist/connect/create.d.ts.map +1 -1
- package/dist/connect/create.js +4 -0
- package/dist/connect/create.js.map +1 -1
- package/dist/connect/create_common.d.ts +7 -0
- package/dist/connect/create_common.d.ts.map +1 -0
- package/dist/connect/create_common.js +19 -0
- package/dist/connect/create_common.js.map +1 -0
- package/dist/connect/external_types.d.ts +8 -0
- package/dist/connect/external_types.d.ts.map +1 -0
- package/dist/connect/external_types.js +31 -0
- package/dist/connect/external_types.js.map +1 -0
- package/dist/connect/figma_connect.d.ts +26 -0
- package/dist/connect/figma_connect.d.ts.map +1 -0
- package/dist/connect/figma_connect.js +3 -0
- package/dist/connect/figma_connect.js.map +1 -0
- package/dist/connect/figma_rest_api.d.ts +7 -0
- package/dist/connect/figma_rest_api.d.ts.map +1 -1
- package/dist/connect/figma_rest_api.js.map +1 -1
- package/dist/connect/index_common.d.ts +3 -0
- package/dist/connect/index_common.d.ts.map +1 -0
- package/dist/connect/index_common.js +23 -0
- package/dist/connect/index_common.js.map +1 -0
- package/dist/connect/intrinsics.d.ts +94 -0
- package/dist/connect/intrinsics.d.ts.map +1 -0
- package/dist/connect/intrinsics.js +401 -0
- package/dist/connect/intrinsics.js.map +1 -0
- package/dist/connect/parser_common.d.ts +144 -0
- package/dist/connect/parser_common.d.ts.map +1 -0
- package/dist/connect/parser_common.js +297 -0
- package/dist/connect/parser_common.js.map +1 -0
- package/dist/connect/parser_executable_types.d.ts +20 -23
- package/dist/connect/parser_executable_types.d.ts.map +1 -1
- package/dist/connect/parser_executable_types.js.map +1 -1
- package/dist/connect/parser_executables.js +1 -1
- package/dist/connect/parser_executables.js.map +1 -1
- package/dist/connect/project.d.ts +20 -5
- package/dist/connect/project.d.ts.map +1 -1
- package/dist/connect/project.js +79 -16
- package/dist/connect/project.js.map +1 -1
- package/dist/connect/upload.d.ts +1 -1
- package/dist/connect/upload.d.ts.map +1 -1
- package/dist/connect/validation.d.ts +1 -1
- package/dist/connect/validation.d.ts.map +1 -1
- package/dist/connect/wizard/helpers.d.ts +1 -0
- package/dist/connect/wizard/helpers.d.ts.map +1 -1
- package/dist/connect/wizard/helpers.js +27 -15
- package/dist/connect/wizard/helpers.js.map +1 -1
- package/dist/connect/wizard/prop_mapping.d.ts +12 -7
- package/dist/connect/wizard/prop_mapping.d.ts.map +1 -1
- package/dist/connect/wizard/prop_mapping.js +88 -89
- package/dist/connect/wizard/prop_mapping.js.map +1 -1
- package/dist/connect/wizard/run_wizard.d.ts.map +1 -1
- package/dist/connect/wizard/run_wizard.js +8 -3
- package/dist/connect/wizard/run_wizard.js.map +1 -1
- package/dist/connect/wizard/signature_extraction.d.ts +7 -0
- package/dist/connect/wizard/signature_extraction.d.ts.map +1 -0
- package/dist/connect/wizard/signature_extraction.js +46 -0
- package/dist/connect/wizard/signature_extraction.js.map +1 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.js +9 -0
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.js +9 -0
- package/dist/html/__test__/parser/examples/NoExample.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.js +33 -0
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.js +15 -0
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.js.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.d.ts +2 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.d.ts.map +1 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.js +15 -0
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.js.map +1 -0
- package/dist/html/__test__/parser/parser.test.d.ts +2 -0
- package/dist/html/__test__/parser/parser.test.d.ts.map +1 -0
- package/dist/html/__test__/parser/parser.test.js +50 -0
- package/dist/html/__test__/parser/parser.test.js.map +1 -0
- package/dist/html/create.d.ts +4 -0
- package/dist/html/create.d.ts.map +1 -0
- package/dist/html/create.js +81 -0
- package/dist/html/create.js.map +1 -0
- package/dist/html/external.d.ts +8 -0
- package/dist/html/external.d.ts.map +1 -0
- package/dist/html/external.js +25 -0
- package/dist/html/external.js.map +1 -0
- package/dist/html/index_html.d.ts +77 -0
- package/dist/html/index_html.d.ts.map +1 -0
- package/dist/html/index_html.js +42 -0
- package/dist/html/index_html.js.map +1 -0
- package/dist/html/parser.d.ts +19 -0
- package/dist/html/parser.d.ts.map +1 -0
- package/dist/html/parser.js +487 -0
- package/dist/html/parser.js.map +1 -0
- package/dist/html/parser_template_helpers.d.ts +2 -0
- package/dist/html/parser_template_helpers.d.ts.map +1 -0
- package/dist/html/parser_template_helpers.js +68 -0
- package/dist/html/parser_template_helpers.js.map +1 -0
- package/dist/html/template_literal.d.ts +5 -0
- package/dist/html/template_literal.d.ts.map +1 -0
- package/dist/html/template_literal.js +8 -0
- package/dist/html/template_literal.js.map +1 -0
- package/dist/parser_scripts/get_swift_parser_dir.d.ts +1 -1
- package/dist/parser_scripts/get_swift_parser_dir.d.ts.map +1 -1
- package/dist/parser_scripts/get_swift_parser_dir.js +38 -10
- package/dist/parser_scripts/get_swift_parser_dir.js.map +1 -1
- package/dist/react/create.d.ts +5 -0
- package/dist/react/create.d.ts.map +1 -1
- package/dist/react/create.js +144 -42
- package/dist/react/create.js.map +1 -1
- package/dist/react/external.d.ts +9 -0
- package/dist/react/external.d.ts.map +1 -0
- package/dist/react/external.js +45 -0
- package/dist/react/external.js.map +1 -0
- package/dist/react/index_react.d.ts +94 -0
- package/dist/react/index_react.d.ts.map +1 -0
- package/dist/react/index_react.js +39 -0
- package/dist/react/index_react.js.map +1 -0
- package/dist/react/parser.d.ts +6 -38
- package/dist/react/parser.d.ts.map +1 -1
- package/dist/react/parser.js +141 -298
- package/dist/react/parser.js.map +1 -1
- package/dist/react/parser_template_helpers.d.ts +15 -15
- package/dist/react/parser_template_helpers.d.ts.map +1 -1
- package/dist/react/parser_template_helpers.js +51 -35
- package/dist/react/parser_template_helpers.js.map +1 -1
- package/dist/storybook/convert.d.ts +1 -1
- package/dist/storybook/convert.d.ts.map +1 -1
- package/dist/storybook/convert.js +6 -4
- package/dist/storybook/convert.js.map +1 -1
- package/dist/storybook/external.d.ts +1 -1
- package/dist/storybook/external.d.ts.map +1 -1
- package/dist/typescript/compiler.d.ts +2 -2
- package/dist/typescript/compiler.d.ts.map +1 -1
- package/dist/typescript/compiler.js +51 -24
- package/dist/typescript/compiler.js.map +1 -1
- package/package.json +28 -8
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.getSwiftParserDir = void 0;
|
|
4
7
|
const child_process_1 = require("child_process");
|
|
5
8
|
const logging_1 = require("../common/logging");
|
|
6
9
|
const get_file_if_exists_1 = require("./get_file_if_exists");
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
7
11
|
// Find the location of the Code Connect Swift package on disk, so that we can
|
|
8
12
|
// call `swift run figma-swift` from the correct location. This requires parsing
|
|
9
13
|
// the output of xcodebuild for .xcodeproj projects, or parsing Package.swift
|
|
@@ -12,20 +16,35 @@ const get_file_if_exists_1 = require("./get_file_if_exists");
|
|
|
12
16
|
// As this is a first party parser, we do this in TypeScript and call it as part
|
|
13
17
|
// of our code. For third party parsers, logic like this would need to be
|
|
14
18
|
// implemented in a script/binary which the user points Code Connect to.
|
|
15
|
-
async function getSwiftParserDir(cwd, xcodeprojPath) {
|
|
19
|
+
async function getSwiftParserDir(cwd, xcodeprojPath, swiftPackagePath) {
|
|
16
20
|
let figmaPackageDir;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (
|
|
21
|
+
let xcodeprojFile;
|
|
22
|
+
let packageSwiftFile;
|
|
23
|
+
// // Check for the supported project types giving precedence top the user provided path
|
|
24
|
+
if (xcodeprojPath) {
|
|
25
|
+
xcodeprojFile = xcodeprojPath.replace(/\s/g, '\\ ');
|
|
26
|
+
}
|
|
27
|
+
else if (swiftPackagePath) {
|
|
28
|
+
packageSwiftFile = path_1.default.dirname(swiftPackagePath).replace(/\s/g, '\\ ');
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
xcodeprojFile = (0, get_file_if_exists_1.getFileIfExists)(cwd, '*.xcodeproj').replace(/\s/g, '\\ ');
|
|
32
|
+
packageSwiftFile = (0, get_file_if_exists_1.getFileIfExists)(cwd, 'Package.swift').replace(/\s/g, '\\ ');
|
|
33
|
+
}
|
|
34
|
+
if (!(xcodeprojFile || packageSwiftFile)) {
|
|
21
35
|
(0, logging_1.exitWithError)('No supported project found. Supported project types are .xcodeproj or Package.swift. You can specify the location of your .xcodeproj file with the `xcodeprojPath` config option.');
|
|
22
36
|
}
|
|
23
|
-
if (
|
|
37
|
+
if (xcodeprojFile) {
|
|
24
38
|
// Use xcodebuild to get the build settings, so we can find where the Code
|
|
25
39
|
// Connect Swift package is installed
|
|
26
|
-
const
|
|
40
|
+
const result = (0, child_process_1.spawnSync)('xcodebuild', ['-project', xcodeprojFile, '-showBuildSettings'], {
|
|
27
41
|
cwd,
|
|
28
|
-
|
|
42
|
+
encoding: 'utf-8',
|
|
43
|
+
});
|
|
44
|
+
if (result.error) {
|
|
45
|
+
throw result.error;
|
|
46
|
+
}
|
|
47
|
+
const buildSettings = result.stdout;
|
|
29
48
|
// Extract the source and version of the Code Connect Swift package from the
|
|
30
49
|
// xcodebuild output, which can be in any of the following formats depending
|
|
31
50
|
// on how it is installed:
|
|
@@ -61,9 +80,18 @@ async function getSwiftParserDir(cwd, xcodeprojPath) {
|
|
|
61
80
|
}
|
|
62
81
|
}
|
|
63
82
|
else if (packageSwiftFile) {
|
|
83
|
+
const swiftPackageDir = swiftPackagePath ? path_1.default.dirname(swiftPackagePath) : undefined;
|
|
84
|
+
const packageDir = swiftPackageDir || cwd;
|
|
64
85
|
// Use the Swift command to determine if the package is installed locally or from Git
|
|
65
86
|
try {
|
|
66
|
-
const
|
|
87
|
+
const result = (0, child_process_1.spawnSync)('swift', ['package', '--package-path', packageDir, 'describe', '--type', 'json'], {
|
|
88
|
+
cwd,
|
|
89
|
+
encoding: 'utf-8',
|
|
90
|
+
});
|
|
91
|
+
if (result.error) {
|
|
92
|
+
throw result.error;
|
|
93
|
+
}
|
|
94
|
+
const packageInfo = JSON.parse(result.stdout);
|
|
67
95
|
const codeConnectPackage = packageInfo.dependencies.find((p) => p.identity === 'code-connect') ??
|
|
68
96
|
// Our local directory is called figmadoc, so this is what swift outputs as the identity
|
|
69
97
|
packageInfo.dependencies.find((p) => p.identity === 'figmadoc');
|
|
@@ -71,7 +99,7 @@ async function getSwiftParserDir(cwd, xcodeprojPath) {
|
|
|
71
99
|
(0, logging_1.exitWithError)('Code Connect Swift package not found in Package.swift. Please add a dependency to https://github.com/figma/code-connect to your Package.swift file.');
|
|
72
100
|
}
|
|
73
101
|
// We can run directly from the directory of the package swift file
|
|
74
|
-
figmaPackageDir =
|
|
102
|
+
figmaPackageDir = packageDir;
|
|
75
103
|
}
|
|
76
104
|
catch (e) {
|
|
77
105
|
(0, logging_1.exitWithError)(`Error calling Swift command: ${e}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get_swift_parser_dir.js","sourceRoot":"","sources":["../../src/parser_scripts/get_swift_parser_dir.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get_swift_parser_dir.js","sourceRoot":"","sources":["../../src/parser_scripts/get_swift_parser_dir.ts"],"names":[],"mappings":";;;;;;AAAA,iDAAmD;AACnD,+CAAyD;AACzD,6DAAsD;AACtD,gDAAuB;AAEvB,8EAA8E;AAC9E,gFAAgF;AAChF,6EAA6E;AAC7E,oBAAoB;AACpB,EAAE;AACF,gFAAgF;AAChF,yEAAyE;AACzE,wEAAwE;AACjE,KAAK,UAAU,iBAAiB,CACrC,GAAW,EACX,aAAsB,EACtB,gBAAyB;IAEzB,IAAI,eAAmC,CAAA;IACvC,IAAI,aAAiC,CAAA;IACrC,IAAI,gBAAoC,CAAA;IAExC,wFAAwF;IACxF,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,GAAG,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;IACrD,CAAC;SAAM,IAAI,gBAAgB,EAAE,CAAC;QAC5B,gBAAgB,GAAG,cAAI,CAAC,OA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F;gBACxF,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,UAAU,CAAC,CAAA;YAEtE,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACxB,IAAA,uBAAa,EACX,qJAAqJ,CACtJ,CAAA;YACH,CAAC;YAED,mEAAmE;YACnE,eAAe,GAAG,UAAU,CAAA;QAC9B,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAA,uBAAa,EAAC,gCAAgC,CAAC,EAAE,CAAC,CAAA;QACpD,CAAC;IACH,CAAC;IAED,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,IAAA,uBAAa,EAAC,kCAAkC,CAAC,CAAA;IACnD,CAAC;IAED,gBAAM,CAAC,IAAI,CACT,uCAAuC,eAAe,0GAA0G,CACjK,CAAA;IAED,OAAO,eAAe,CAAA;AACxB,CAAC;AA1HD,8CA0HC"}
|
package/dist/react/create.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
import { CreateRequestPayload, CreateResponsePayload } from '../connect/parser_executable_types';
|
|
3
|
+
import { Intrinsic } from '../connect/intrinsics';
|
|
4
|
+
export declare function isBooleanKind(propValue: string): boolean;
|
|
5
|
+
export declare function generateExpressionFromIntrinsic({ kind, args }: Intrinsic): string | never;
|
|
6
|
+
export declare function getSetOfAllPropsReferencedInPropMapping(obj: Object): Set<string>;
|
|
7
|
+
export declare function generateProps(component: CreateRequestPayload['component']): string;
|
|
3
8
|
export declare function createReactCodeConnect(payload: CreateRequestPayload): Promise<z.infer<typeof CreateResponsePayload>>;
|
|
4
9
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/react/create.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/react/create.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,EAEL,oBAAoB,EACpB,qBAAqB,EAEtB,MAAM,oCAAoC,CAAA;AAG3C,OAAO,EAAE,SAAS,EAAmC,MAAM,uBAAuB,CAAA;AAGlF,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,WAU9C;AA8CD,wBAAgB,+BAA+B,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,SAAS,GAAG,MAAM,GAAG,KAAK,CAqBzF;AAgCD,wBAAgB,uCAAuC,CAAC,GAAG,EAAE,MAAM,eAWlE;AA2CD,wBAAgB,aAAa,CAAC,SAAS,EAAE,oBAAoB,CAAC,WAAW,CAAC,UAkBzE;AAkCD,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC,CA0EhD"}
|
package/dist/react/create.js
CHANGED
|
@@ -26,12 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createReactCodeConnect = void 0;
|
|
29
|
+
exports.createReactCodeConnect = exports.generateProps = exports.getSetOfAllPropsReferencedInPropMapping = exports.generateExpressionFromIntrinsic = exports.isBooleanKind = void 0;
|
|
30
30
|
const lodash_1 = require("lodash");
|
|
31
31
|
const prettier = __importStar(require("prettier"));
|
|
32
32
|
const fs_1 = __importDefault(require("fs"));
|
|
33
33
|
const path_1 = __importDefault(require("path"));
|
|
34
34
|
const create_1 = require("../connect/create");
|
|
35
|
+
const intrinsics_1 = require("../connect/intrinsics");
|
|
36
|
+
const create_common_1 = require("../connect/create_common");
|
|
35
37
|
function isBooleanKind(propValue) {
|
|
36
38
|
const normalized = propValue.toLowerCase();
|
|
37
39
|
return (normalized === 'true' ||
|
|
@@ -41,62 +43,153 @@ function isBooleanKind(propValue) {
|
|
|
41
43
|
normalized === 'on' ||
|
|
42
44
|
normalized === 'off');
|
|
43
45
|
}
|
|
46
|
+
exports.isBooleanKind = isBooleanKind;
|
|
44
47
|
function normalizePropName(name) {
|
|
45
48
|
return name.replace(/#[0-9:]*/g, '');
|
|
46
49
|
}
|
|
47
50
|
function generateCodePropName(name) {
|
|
48
|
-
|
|
51
|
+
const cleanedName = name
|
|
52
|
+
// Remove any #node:id from the end of the string
|
|
53
|
+
.replace(/#[0-9:]+$/g, '')
|
|
54
|
+
// Remove any special characters
|
|
55
|
+
.replace(/[^a-zA-Z0-9\s]/g, '');
|
|
56
|
+
return (0, lodash_1.camelCase)(cleanedName);
|
|
49
57
|
}
|
|
50
58
|
function normalizePropValue(name) {
|
|
51
59
|
// Convert the string to kebab-case
|
|
52
60
|
return name.replace(/[^a-zA-Z0-9]/g, '-').toLowerCase();
|
|
53
61
|
}
|
|
54
|
-
function
|
|
62
|
+
function generateExpressionValueMappingKind(valueMappingKind) {
|
|
63
|
+
if (valueMappingKind && typeof valueMappingKind === 'object' && 'kind' in valueMappingKind) {
|
|
64
|
+
return generateExpressionFromIntrinsic(valueMappingKind);
|
|
65
|
+
}
|
|
66
|
+
if (typeof valueMappingKind === 'string') {
|
|
67
|
+
return `"${valueMappingKind}"`;
|
|
68
|
+
}
|
|
69
|
+
if (typeof valueMappingKind === 'number' ||
|
|
70
|
+
typeof valueMappingKind === 'boolean' ||
|
|
71
|
+
typeof valueMappingKind === 'undefined') {
|
|
72
|
+
return `${valueMappingKind}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function generateExpressionValueMapping(valueMapping) {
|
|
76
|
+
return `{
|
|
77
|
+
${Object.entries(valueMapping)
|
|
78
|
+
.map(([k, v]) => `"${k}": ${generateExpressionValueMappingKind(v)}`)
|
|
79
|
+
.join(`,\n`)}
|
|
80
|
+
}`;
|
|
81
|
+
}
|
|
82
|
+
// Not an exhaustive list of intrinsics but can add others as/when they're supported in prop mapping gen
|
|
83
|
+
function generateExpressionFromIntrinsic({ kind, args }) {
|
|
84
|
+
if (kind === intrinsics_1.IntrinsicKind.String) {
|
|
85
|
+
return `figma.string("${args.figmaPropName}")`;
|
|
86
|
+
}
|
|
87
|
+
if (kind === intrinsics_1.IntrinsicKind.Boolean) {
|
|
88
|
+
return `figma.boolean("${args.figmaPropName}"${args.valueMapping ? `, ${generateExpressionValueMapping(args.valueMapping)}` : ''})`;
|
|
89
|
+
}
|
|
90
|
+
if (kind === intrinsics_1.IntrinsicKind.Enum) {
|
|
91
|
+
return `figma.enum("${args.figmaPropName}"${args.valueMapping ? `, ${generateExpressionValueMapping(args.valueMapping)}` : ''})`;
|
|
92
|
+
}
|
|
93
|
+
if (kind === intrinsics_1.IntrinsicKind.Instance) {
|
|
94
|
+
return `figma.instance("${args.figmaPropName}")`;
|
|
95
|
+
}
|
|
96
|
+
if (kind === intrinsics_1.IntrinsicKind.Children) {
|
|
97
|
+
return `figma.children(${args.layers.length > 1 ? `[${args.layers.map((layer) => `"${layer}"`).join(', ')}]` : `"${args.layers[0]}"`})`;
|
|
98
|
+
}
|
|
99
|
+
if (kind === intrinsics_1.IntrinsicKind.TextContent) {
|
|
100
|
+
return `figma.textContent("${args.layer}")`;
|
|
101
|
+
}
|
|
102
|
+
// should never reach here as we create prop mappings.
|
|
103
|
+
throw new Error(`kind ${kind} not supported for prop mapping`);
|
|
104
|
+
}
|
|
105
|
+
exports.generateExpressionFromIntrinsic = generateExpressionFromIntrinsic;
|
|
106
|
+
function generateSinglePropMappingFromFigmaProp(propName, propDef) {
|
|
107
|
+
const codePropName = generateCodePropName(propName);
|
|
108
|
+
const figmaPropName = normalizePropName(propName);
|
|
109
|
+
if (propDef.type === 'BOOLEAN') {
|
|
110
|
+
return `"${codePropName}": figma.boolean('${figmaPropName}')`;
|
|
111
|
+
}
|
|
112
|
+
if (propDef.type === 'TEXT') {
|
|
113
|
+
return `"${codePropName}": figma.string('${figmaPropName}')`;
|
|
114
|
+
}
|
|
115
|
+
if (propDef.type === 'VARIANT') {
|
|
116
|
+
const isBooleanVariant = propDef.variantOptions?.length === 2 && propDef.variantOptions.every(isBooleanKind);
|
|
117
|
+
if (isBooleanVariant) {
|
|
118
|
+
return `"${codePropName}": figma.boolean('${figmaPropName}')`;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
return `"${codePropName}": figma.enum('${figmaPropName}', { \n${propDef.variantOptions
|
|
122
|
+
?.map((value) => ` "${value}": "${normalizePropValue(value)}"`)
|
|
123
|
+
.join(',\n')}})`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (propDef.type === 'INSTANCE_SWAP') {
|
|
127
|
+
return `"${codePropName}": figma.instance('${figmaPropName}')`;
|
|
128
|
+
}
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
function getSetOfAllPropsReferencedInPropMapping(obj) {
|
|
132
|
+
const mappedProps = [];
|
|
133
|
+
Object.entries(obj).forEach(([k, v]) => {
|
|
134
|
+
if (k === 'figmaPropName') {
|
|
135
|
+
mappedProps.push(v);
|
|
136
|
+
}
|
|
137
|
+
if (typeof v === 'object') {
|
|
138
|
+
mappedProps.push(...getSetOfAllPropsReferencedInPropMapping(v));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
return new Set(mappedProps);
|
|
142
|
+
}
|
|
143
|
+
exports.getSetOfAllPropsReferencedInPropMapping = getSetOfAllPropsReferencedInPropMapping;
|
|
144
|
+
function generatePropsFromMapping(component, propMapping) {
|
|
145
|
+
const mappedProps = [];
|
|
146
|
+
const unmappedProps = [];
|
|
147
|
+
for (const [propName, intrinsic] of Object.entries(propMapping)) {
|
|
148
|
+
const expr = generateExpressionFromIntrinsic(intrinsic);
|
|
149
|
+
if (expr) {
|
|
150
|
+
mappedProps.push(`"${propName}": ${expr}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const usedFigmaPropsSet = getSetOfAllPropsReferencedInPropMapping(propMapping);
|
|
154
|
+
for (const [propName, propDef] of Object.entries(component.componentPropertyDefinitions)) {
|
|
155
|
+
if (!usedFigmaPropsSet.has(propName)) {
|
|
156
|
+
const propMapping = generateSinglePropMappingFromFigmaProp(propName, propDef);
|
|
157
|
+
if (propMapping) {
|
|
158
|
+
unmappedProps.push(propMapping);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return `{
|
|
163
|
+
// These props were automatically mapped based on your linked code:
|
|
164
|
+
${mappedProps.join(',\n')},
|
|
165
|
+
${unmappedProps.length
|
|
166
|
+
? `// No matching props could be found for these Figma properties:
|
|
167
|
+
${unmappedProps
|
|
168
|
+
.map((prop) => {
|
|
169
|
+
// Comment out to make clear these are suggested. Singly-commented out lines for ease of uncommenting
|
|
170
|
+
return `// ${prop}`;
|
|
171
|
+
})
|
|
172
|
+
.join(',\n')}`
|
|
173
|
+
: ''}
|
|
174
|
+
}`;
|
|
175
|
+
}
|
|
176
|
+
function generateProps(component) {
|
|
55
177
|
const props = [];
|
|
56
178
|
if (!component.componentPropertyDefinitions ||
|
|
57
179
|
Object.keys(component.componentPropertyDefinitions).length === 0) {
|
|
58
180
|
return `{}`;
|
|
59
181
|
}
|
|
60
182
|
for (const [propName, propDef] of Object.entries(component.componentPropertyDefinitions)) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const figmaPropName = normalizePropName(propName);
|
|
65
|
-
if (type === 'BOOLEAN') {
|
|
66
|
-
props.push(`"${codePropName}": figma.boolean('${figmaPropName}')`);
|
|
67
|
-
}
|
|
68
|
-
if (type === 'TEXT') {
|
|
69
|
-
props.push(`"${codePropName}": figma.string('${figmaPropName}')`);
|
|
70
|
-
}
|
|
71
|
-
if (type === 'VARIANT') {
|
|
72
|
-
const isBooleanVariant = propDef.variantOptions?.length === 2 && propDef.variantOptions.every(isBooleanKind);
|
|
73
|
-
if (isBooleanVariant) {
|
|
74
|
-
props.push(`"${codePropName}": figma.boolean('${figmaPropName}')`);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
props.push(`"${codePropName}": figma.enum('${figmaPropName}', { \n${propDef.variantOptions
|
|
78
|
-
?.map((value) => ` "${value}": "${normalizePropValue(value)}"`)
|
|
79
|
-
.join(',\n')}})`);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
if (type === 'INSTANCE_SWAP') {
|
|
83
|
-
props.push(`"${codePropName}": figma.instance('${figmaPropName}')`);
|
|
183
|
+
const propMapping = generateSinglePropMappingFromFigmaProp(propName, propDef);
|
|
184
|
+
if (propMapping) {
|
|
185
|
+
props.push(propMapping);
|
|
84
186
|
}
|
|
85
187
|
}
|
|
86
188
|
return `{
|
|
87
189
|
${props.join(',\n ')}
|
|
88
190
|
}`;
|
|
89
191
|
}
|
|
90
|
-
|
|
91
|
-
if (outFile) {
|
|
92
|
-
return outFile;
|
|
93
|
-
}
|
|
94
|
-
const baseName = `${sourceFilename}.figma.tsx`;
|
|
95
|
-
if (outDir) {
|
|
96
|
-
return path_1.default.join(outDir, baseName);
|
|
97
|
-
}
|
|
98
|
-
return path_1.default.join(process.env.INIT_CWD ?? process.cwd(), baseName);
|
|
99
|
-
}
|
|
192
|
+
exports.generateProps = generateProps;
|
|
100
193
|
// returns ES-style import path from given system path
|
|
101
194
|
function formatImportPath(systemPath) {
|
|
102
195
|
// use forward slashes for import paths
|
|
@@ -122,16 +215,18 @@ async function createReactCodeConnect(payload) {
|
|
|
122
215
|
const sourceFilename = sourceFilepath
|
|
123
216
|
? path_1.default.parse(sourceFilepath).name.split('.')[0]
|
|
124
217
|
: normalizedName;
|
|
125
|
-
const filePath = getOutFileName({
|
|
218
|
+
const filePath = (0, create_common_1.getOutFileName)({
|
|
126
219
|
outFile: destinationFile,
|
|
127
220
|
outDir: destinationDir,
|
|
128
221
|
sourceFilename,
|
|
222
|
+
extension: 'tsx',
|
|
129
223
|
});
|
|
130
224
|
const importsPath = getImportsPath({
|
|
131
225
|
codeConnectFilePath: filePath,
|
|
132
226
|
sourceFilepath,
|
|
133
227
|
normalizedName,
|
|
134
228
|
});
|
|
229
|
+
const hasPropMapping = propMapping && Object.keys(propMapping).length > 0;
|
|
135
230
|
const importName = sourceFilepath && sourceExport
|
|
136
231
|
? sourceExport === 'default'
|
|
137
232
|
? (0, create_1.normalizeComponentName)(sourceFilename)
|
|
@@ -142,20 +237,27 @@ import React from 'react'
|
|
|
142
237
|
import ${sourceExport === 'default' ? importName : `{ ${importName} }`} from '${importsPath}'
|
|
143
238
|
import figma from '@figma/code-connect'
|
|
144
239
|
|
|
145
|
-
|
|
146
|
-
|
|
240
|
+
${hasPropMapping
|
|
241
|
+
? `/**
|
|
242
|
+
* -- This file was auto-generated by Code Connect --
|
|
243
|
+
* \`props\` includes a mapping from your code props to Figma properties.
|
|
244
|
+
* You should check this is correct, and update the \`example\` function
|
|
245
|
+
* to return the code example you'd like to see in Figma
|
|
246
|
+
*/`
|
|
247
|
+
: `/**
|
|
248
|
+
* -- This file was auto-generated by Code Connect --
|
|
147
249
|
* \`props\` includes a mapping from Figma properties and variants to
|
|
148
250
|
* suggested values. You should update this to match the props of your
|
|
149
251
|
* code component, and update the \`example\` function to return the
|
|
150
252
|
* code example you'd like to see in Figma
|
|
151
|
-
|
|
253
|
+
*/`}
|
|
152
254
|
|
|
153
255
|
figma.connect(${importName}, "${figmaNodeUrl}", {
|
|
154
|
-
props: ${
|
|
256
|
+
props: ${hasPropMapping ? generatePropsFromMapping(component, propMapping) : generateProps(component)},
|
|
155
257
|
example: (props) => <${importName} />
|
|
156
258
|
})
|
|
157
259
|
`;
|
|
158
|
-
let formatted =
|
|
260
|
+
let formatted = prettier.format(codeConnect, {
|
|
159
261
|
parser: 'typescript',
|
|
160
262
|
semi: false,
|
|
161
263
|
trailingComma: 'all',
|
package/dist/react/create.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/react/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAClC,mDAAoC;AACpC,4CAAmB;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/react/create.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAkC;AAClC,mDAAoC;AACpC,4CAAmB;AAQnB,gDAAuB;AACvB,8CAA0D;AAC1D,sDAAkF;AAClF,4DAAyD;AAEzD,SAAgB,aAAa,CAAC,SAAiB;IAC7C,MAAM,UAAU,GAAG,SAAS,CAAC,WAAW,EAAE,CAAA;IAC1C,OAAO,CACL,UAAU,KAAK,MAAM;QACrB,UAAU,KAAK,OAAO;QACtB,UAAU,KAAK,KAAK;QACpB,UAAU,KAAK,IAAI;QACnB,UAAU,KAAK,IAAI;QACnB,UAAU,KAAK,KAAK,CACrB,CAAA;AACH,CAAC;AAVD,sCAUC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AACtC,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY;IACxC,MAAM,WAAW,GAAG,IAAI;QACtB,iDAAiD;SAChD,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;QAC1B,gCAAgC;SAC/B,OAAO,CAAC,iBAAiB,EAAE,EAAE,CAAC,CAAA;IAEjC,OAAO,IAAA,kBAAS,EAAC,WAAW,CAAC,CAAA;AAC/B,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,mCAAmC;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAA;AACzD,CAAC;AAED,SAAS,kCAAkC,CAAC,gBAAkC;IAC5E,IAAI,gBAAgB,IAAI,OAAO,gBAAgB,KAAK,QAAQ,IA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,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE;QAC3C,MAAM,EAAE,YAAY;QACpB,IAAI,EAAE,KAAK;QACX,aAAa,EAAE,KAAK;KACrB,CAAC,CAAA;IAEF,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO;YACL,YAAY,EAAE,EAAE;YAChB,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,QAAQ,QAAQ,oCAAoC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;SAC9F,CAAA;IACH,CAAC;IACD,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IACzD,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;IAErC,OAAO,EAAE,YAAY,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AACvD,CAAC;AA5ED,wDA4EC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FigmaConnectMeta } from '../connect/api';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { booleanType, enumType, stringType, nestedPropsType, classNameType, textContentType } from '../connect/external_types';
|
|
4
|
+
declare function connectType<P = {}>(_figmaNodeUrl: string, _meta?: FigmaConnectMeta<P>): void;
|
|
5
|
+
declare function connectType<P = {}>(_component: any, _figmaNodeUrl: string, _meta?: FigmaConnectMeta<P>): void;
|
|
6
|
+
declare function instanceType(_figmaPropName: string): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
7
|
+
declare function childrenType(_layers: string | string[]): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
8
|
+
export { booleanType as boolean, enumType as enum, stringType as string, nestedPropsType as nestedProps, classNameType as className, textContentType as textContent, connectType as connect, instanceType as instance, childrenType as children, };
|
|
9
|
+
//# sourceMappingURL=external.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/react/external.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,gBAAgB,CAAA;AAClF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAElC,iBAAS,WAAW,CAAC,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;AACtF,iBAAS,WAAW,CAAC,CAAC,GAAG,EAAE,EACzB,UAAU,EAAE,GAAG,EACf,aAAa,EAAE,MAAM,EACrB,KAAK,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAC1B,IAAI,CAAA;AAGP,iBAAS,YAAY,CAAC,cAAc,EAAE,MAAM,kFAE3C;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,kFAE/C;AAED,OAAO,EACL,WAAW,IAAI,OAAO,EACtB,QAAQ,IAAI,IAAI,EAChB,UAAU,IAAI,MAAM,EACpB,eAAe,IAAI,WAAW,EAC9B,aAAa,IAAI,SAAS,EAC1B,eAAe,IAAI,WAAW,EAC9B,WAAW,IAAI,OAAO,EACtB,YAAY,IAAI,QAAQ,EACxB,YAAY,IAAI,QAAQ,GACzB,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.children = exports.instance = exports.connect = exports.textContent = exports.className = exports.nestedProps = exports.string = exports.enum = exports.boolean = void 0;
|
|
27
|
+
const React = __importStar(require("react"));
|
|
28
|
+
const external_types_1 = require("../connect/external_types");
|
|
29
|
+
Object.defineProperty(exports, "boolean", { enumerable: true, get: function () { return external_types_1.booleanType; } });
|
|
30
|
+
Object.defineProperty(exports, "enum", { enumerable: true, get: function () { return external_types_1.enumType; } });
|
|
31
|
+
Object.defineProperty(exports, "string", { enumerable: true, get: function () { return external_types_1.stringType; } });
|
|
32
|
+
Object.defineProperty(exports, "nestedProps", { enumerable: true, get: function () { return external_types_1.nestedPropsType; } });
|
|
33
|
+
Object.defineProperty(exports, "className", { enumerable: true, get: function () { return external_types_1.classNameType; } });
|
|
34
|
+
Object.defineProperty(exports, "textContent", { enumerable: true, get: function () { return external_types_1.textContentType; } });
|
|
35
|
+
function connectType(_component, _figmaNodeUrl, _meta) { }
|
|
36
|
+
exports.connect = connectType;
|
|
37
|
+
function instanceType(_figmaPropName) {
|
|
38
|
+
return React.createElement('div');
|
|
39
|
+
}
|
|
40
|
+
exports.instance = instanceType;
|
|
41
|
+
function childrenType(_layers) {
|
|
42
|
+
return React.createElement('div');
|
|
43
|
+
}
|
|
44
|
+
exports.children = childrenType;
|
|
45
|
+
//# sourceMappingURL=external.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/react/external.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,6CAA8B;AAC9B,8DAOkC;AAmBjB,wFAzBf,4BAAW,OAyBW;AACV,qFAzBZ,yBAAQ,OAyBQ;AACF,uFAzBd,2BAAU,OAyBU;AACD,4FAzBnB,gCAAe,OAyBe;AACb,0FAzBjB,8BAAa,OAyBa;AACP,4FAzBnB,gCAAe,OAyBe;AAhBhC,SAAS,WAAW,CAAC,UAAmB,EAAE,aAAsB,EAAE,KAAe,IAAS,CAAC;AAiB1E,8BAAO;AAfxB,SAAS,YAAY,CAAC,cAAsB;IAC1C,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACnC,CAAC;AAciB,gCAAQ;AAZ1B,SAAS,YAAY,CAAC,OAA0B;IAC9C,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACnC,CAAC;AAWiB,gCAAQ"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { EnumValue, FigmaConnectAPI, FigmaConnectMeta, ValueOf } from '../connect/api';
|
|
3
|
+
import * as StorybookTypes from '../storybook/external';
|
|
4
|
+
import { FigmaConnectClient } from '../client/figma_client';
|
|
5
|
+
declare const _client: FigmaConnectClient;
|
|
6
|
+
declare const _figma: FigmaConnectAPI<JSX.Element> & {
|
|
7
|
+
/**
|
|
8
|
+
* Defines a code snippet that displays in Figma when a component is selected. This function has two signatures:
|
|
9
|
+
* - When called with a component reference as the first argument, it will infer metadata such as the import statement
|
|
10
|
+
* and location in source file from the component reference
|
|
11
|
+
* - When called only with a Figma node URL, this metadata will not be included. This is useful when you want to display a code snippet
|
|
12
|
+
* for something that isn't a React component, such as a `<button>` element
|
|
13
|
+
*
|
|
14
|
+
* @param component A reference to the React component
|
|
15
|
+
* @param figmaNodeUrl A link to the node in Figma, for example:`https://www.figma.com/file/123abc/My-Component?node-id=123:456`
|
|
16
|
+
* @param meta {@link FigmaConnectMeta}
|
|
17
|
+
*/
|
|
18
|
+
connect<P = {}>(component: any, figmaNodeUrl: string, meta?: FigmaConnectMeta<P, React.Component | JSX.Element>): void;
|
|
19
|
+
/**
|
|
20
|
+
* Defines a code snippet that displays in Figma when a component is selected. This function has two signatures:
|
|
21
|
+
* - When called with a component reference as the first argument, it will infer metadata such as the import statement
|
|
22
|
+
* and location in source file from the component reference
|
|
23
|
+
* - When called only with a Figma node URL, this metadata will not be included. This is useful when you want to display a code snippet
|
|
24
|
+
* for something that isn't a React component, such as a `<button>` element
|
|
25
|
+
*
|
|
26
|
+
* @param figmaNodeUrl A link to the node in Figma, for example:`https://www.figma.com/file/123abc/My-Component?node-id=123:456`
|
|
27
|
+
* @param meta {@link FigmaConnectMeta}
|
|
28
|
+
*/
|
|
29
|
+
connect<P = {}>(figmaNodeUrl: string, meta?: FigmaConnectMeta<P, React.Component | JSX.Element>): void;
|
|
30
|
+
/**
|
|
31
|
+
* Maps a Figma property to a boolean value for the connected component. This prop is replaced
|
|
32
|
+
* with values from the Figma instance when viewed in Dev Mode. For example:
|
|
33
|
+
* ```ts
|
|
34
|
+
* props: {
|
|
35
|
+
* disabled: figma.boolean('Disabled'),
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
* Would show the `disabled` property if the Figma property "Disabled" is true.
|
|
39
|
+
*
|
|
40
|
+
* @param figmaPropName The name of the property on the Figma component
|
|
41
|
+
*/
|
|
42
|
+
boolean(figmaPropName: string): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Maps a Figma boolean property to a set of values for the connected component, providing
|
|
45
|
+
* a value mapping for `true` and `false`. This prop is replaced with values from the
|
|
46
|
+
* Figma instance when viewed in Dev Mode. Example:
|
|
47
|
+
* ```ts
|
|
48
|
+
* props: {
|
|
49
|
+
* label: figma.boolean('Disabled', {
|
|
50
|
+
* true: <Label />,
|
|
51
|
+
* false: <HiddenLabel />
|
|
52
|
+
* }),
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
* Would replace `label` with `<Label />` if the Figma property "Disabled" is true.
|
|
56
|
+
*
|
|
57
|
+
* @param figmaPropName The name of the property on the Figma component
|
|
58
|
+
* @param valueMapping A mapping of values for `true` and `false`
|
|
59
|
+
*/
|
|
60
|
+
boolean<TrueT extends EnumValue, FalseT extends EnumValue>(figmaPropName: string, valueMapping?: {
|
|
61
|
+
true?: TrueT;
|
|
62
|
+
false?: FalseT;
|
|
63
|
+
}): ValueOf<Record<'true' | 'false', TrueT | FalseT>>;
|
|
64
|
+
/**
|
|
65
|
+
* Maps nested properties from a Figma instance layer. The first argument
|
|
66
|
+
* should be the layer name of the nested instance. The mapping object passed
|
|
67
|
+
* in is in the same format as the `props` object in the `connect` function.
|
|
68
|
+
* For example:
|
|
69
|
+
* ```ts
|
|
70
|
+
* props: {
|
|
71
|
+
* nested: figma.nestedProps('Nested', {
|
|
72
|
+
* label: figma.string('Text'),
|
|
73
|
+
* icon: figma.instance('Icon'),
|
|
74
|
+
* }),
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* Which would then allow you to access the nested properties in the `example` function like so:
|
|
79
|
+
* ```ts
|
|
80
|
+
* (props) => <Button label={props.nested.label} icon={props.nested.icon} />
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
nestedProps<V>(layer: string, input: V): V;
|
|
84
|
+
/**
|
|
85
|
+
* A list of import statements that will render in the Code Snippet in Figma.
|
|
86
|
+
* This overrides the auto-generated imports for the component. When this is specified,
|
|
87
|
+
* the `importPaths` option in the config file is also ignored.
|
|
88
|
+
*/
|
|
89
|
+
imports?: string[];
|
|
90
|
+
};
|
|
91
|
+
export { _figma as figma, _client as client };
|
|
92
|
+
export default _figma;
|
|
93
|
+
export type StoryParameters<T = {}> = StorybookTypes.StoryParameters<T>;
|
|
94
|
+
//# sourceMappingURL=index_react.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_react.d.ts","sourceRoot":"","sources":["../../src/react/index_react.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAEtF,OAAO,KAAK,cAAc,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAG3D,QAAA,MAAM,OAAO,EAAE,kBAAgC,CAAA;AAC/C,QAAA,MAAM,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG;IAC3C;;;;;;;;;;OAUG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,EACZ,SAAS,EAAE,GAAG,EACd,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GACxD,IAAI,CAAA;IAEP;;;;;;;;;OASG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,EACZ,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GACxD,IAAI,CAAA;IAEP;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAA;IAEvC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,KAAK,SAAS,SAAS,EAAE,MAAM,SAAS,SAAS,EACvD,aAAa,EAAE,MAAM,EACrB,YAAY,CAAC,EAAE;QACb,IAAI,CAAC,EAAE,KAAK,CAAA;QACZ,KAAK,CAAC,EAAE,MAAM,CAAA;KACf,GACA,OAAO,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,EAAE,KAAK,GAAG,MAAM,CAAC,CAAC,CAAA;IAEpD;;;;;;;;;;;;;;;;;;OAkBG;IACH,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;IAE1C;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACX,CAAA;AAET,OAAO,EAAE,MAAM,IAAI,KAAK,EAAE,OAAO,IAAI,MAAM,EAAE,CAAA;AAC7C,eAAe,MAAM,CAAA;AAErB,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,EAAE,IAAI,cAAc,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// IMPORTANT: be careful to ensure you don't accidentally add code which has a
|
|
3
|
+
// dependency on Node.js-only modules here, as it will break co-located
|
|
4
|
+
// components. We don't have a test for this yet. Any such code should be
|
|
5
|
+
// conditionally required - see `client` for an example. Reach out in
|
|
6
|
+
// #feat-code-connect if you're unsure.
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
24
|
+
if (mod && mod.__esModule) return mod;
|
|
25
|
+
var result = {};
|
|
26
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
27
|
+
__setModuleDefault(result, mod);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.client = exports.figma = void 0;
|
|
32
|
+
const figma = __importStar(require("./external"));
|
|
33
|
+
const index_common_1 = require("../connect/index_common");
|
|
34
|
+
const _client = (0, index_common_1.getClient)();
|
|
35
|
+
exports.client = _client;
|
|
36
|
+
const _figma = figma;
|
|
37
|
+
exports.figma = _figma;
|
|
38
|
+
exports.default = _figma;
|
|
39
|
+
//# sourceMappingURL=index_react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index_react.js","sourceRoot":"","sources":["../../src/react/index_react.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,uEAAuE;AACvE,yEAAyE;AACzE,qEAAqE;AACrE,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvC,kDAAmC;AAGnC,0DAAmD;AAEnD,MAAM,OAAO,GAAuB,IAAA,wBAAS,GAAE,CAAA;AAsGV,yBAAM;AArG3C,MAAM,MAAM,GAmGR,KAAK,CAAA;AAEU,uBAAK;AACxB,kBAAe,MAAM,CAAA"}
|