@figma/code-connect 0.1.0 → 0.1.2
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 +21 -15
- package/dist/commands/connect.js +21 -21
- package/dist/commands/connect.js.map +1 -1
- package/dist/common/api.d.ts +29 -5
- package/dist/common/api.d.ts.map +1 -1
- package/dist/common/external.d.ts +1 -0
- package/dist/common/external.d.ts.map +1 -1
- package/dist/common/external.js.map +1 -1
- package/dist/common/figma_connect.d.ts +2 -2
- package/dist/common/figma_connect.d.ts.map +1 -1
- package/dist/common/intrinsics.d.ts +1 -1
- package/dist/common/intrinsics.d.ts.map +1 -1
- package/dist/common/intrinsics.js +10 -6
- package/dist/common/intrinsics.js.map +1 -1
- package/dist/common/project.d.ts +36 -21
- package/dist/common/project.d.ts.map +1 -1
- package/dist/common/project.js +30 -3
- package/dist/common/project.js.map +1 -1
- package/dist/connect/create.d.ts +1 -1
- package/dist/connect/create.d.ts.map +1 -1
- package/dist/connect/create.js +6 -5
- package/dist/connect/create.js.map +1 -1
- package/dist/connect/helpers.d.ts.map +1 -1
- package/dist/connect/helpers.js +11 -6
- package/dist/connect/helpers.js.map +1 -1
- package/dist/connect/upload.d.ts +2 -2
- package/dist/connect/upload.d.ts.map +1 -1
- package/dist/connect/upload.js +3 -3
- package/dist/connect/upload.js.map +1 -1
- package/dist/connect/validation.d.ts +2 -2
- package/dist/connect/validation.d.ts.map +1 -1
- package/dist/connect/validation.js +3 -3
- package/dist/connect/validation.js.map +1 -1
- package/dist/{common → react}/parser.d.ts +8 -8
- package/dist/react/parser.d.ts.map +1 -0
- package/dist/{common → react}/parser.js +240 -139
- package/dist/react/parser.js.map +1 -0
- package/dist/react/parser_template_helpers.d.ts.map +1 -0
- package/dist/{common → react}/parser_template_helpers.js +10 -1
- package/dist/react/parser_template_helpers.js.map +1 -0
- package/dist/storybook/convert.d.ts +4 -4
- package/dist/storybook/convert.d.ts.map +1 -1
- package/dist/storybook/convert.js +16 -14
- package/dist/storybook/convert.js.map +1 -1
- package/dist/{common → typescript}/compiler.d.ts +1 -1
- package/dist/typescript/compiler.d.ts.map +1 -0
- package/dist/{common → typescript}/compiler.js +21 -2
- package/dist/typescript/compiler.js.map +1 -0
- package/package.json +4 -2
- package/dist/common/compiler.d.ts.map +0 -1
- package/dist/common/compiler.js.map +0 -1
- package/dist/common/parser.d.ts.map +0 -1
- package/dist/common/parser.js.map +0 -1
- package/dist/common/parser_template_helpers.d.ts.map +0 -1
- package/dist/common/parser_template_helpers.js.map +0 -1
- /package/dist/{common → react}/parser_template_helpers.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Code Connect (React)
|
|
2
2
|
|
|
3
|
-
For more information about Code Connect as well as guides for other platforms and frameworks, please [go here](
|
|
3
|
+
For more information about Code Connect as well as guides for other platforms and frameworks, please [go here](../../README.md).
|
|
4
4
|
|
|
5
5
|
This documentation will help you connect your React components with Figma components using Code Connect. We'll cover basic setup to display your first connected code snippet, followed by making snippets dynamic by using property mappings. Code Connect for React works as both a standalone implementation and as an integration with existing Storybook files to enable easily maintaining both systems in parallel.
|
|
6
6
|
|
|
@@ -14,20 +14,20 @@ npm install @figma/code-connect
|
|
|
14
14
|
|
|
15
15
|
## Basic setup
|
|
16
16
|
|
|
17
|
-
To connect your first component go to Dev Mode in Figma and right-click on the component you want to connect, then choose `Copy link to selection` from the menu. Make sure you are copying the link to a main component and not an instance of the component. The main component will typically be located in a centralized design system library file. Using this link, run `figma connect create`.
|
|
17
|
+
To connect your first component go to Dev Mode in Figma and right-click on the component you want to connect, then choose `Copy link to selection` from the menu. Make sure you are copying the link to a main component and not an instance of the component. The main component will typically be located in a centralized design system library file. Using this link, run `figma connect create`. Note that depending on what terminal software you're using, you might need to wrap the URL in quotes.
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
-
npx figma connect create https://... --token <auth token>
|
|
20
|
+
npx figma connect create "https://..." --token <auth token>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
This will create a Code Connect file with some basic scaffolding for the component you want to connect. By default this file will be called `<component-name>.figma.tsx` based on the name of the component in Figma. However, you may rename this file as you see fit. The scaffolding that is generated is based on the interface of the component in Figma. Depending on how closely this matches your code component you'll need to make some edits to this file before you publish it.
|
|
24
24
|
|
|
25
|
-
Some CLI commands, like `create`, require a valid [authentication token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) with write permission for the Code Connect scope. You can either pass this via the `--token` flag, or set the `FIGMA_ACCESS_TOKEN` environment variable
|
|
25
|
+
Some CLI commands, like `create`, require a valid [authentication token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens) with write permission for the Code Connect scope as well as the read permission for the File content scope. You can either pass this via the `--token` flag, or set the `FIGMA_ACCESS_TOKEN` environment variable. The Figma CLI reads this from a `.env` file in the same folder, if it exists.
|
|
26
26
|
|
|
27
27
|
To keep things simple, we're going to start by replacing the contents of the generated file with the most basic Code Connect configuration possible to make sure everything is set up and working as expected. Replace the contents of the file with the following, replacing the `Button` reference with a reference to whatever component you are trying to connect. The object called by `figma.connect` is your Code Connect doc.
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
|
-
import
|
|
30
|
+
import figma from '@figma/code-connect'
|
|
31
31
|
import { Button } from 'src/components'
|
|
32
32
|
|
|
33
33
|
figma.connect(Button, 'https://...', {
|
|
@@ -109,14 +109,14 @@ In addition to the [general configuration](../README.md) for the CLI there is Re
|
|
|
109
109
|
"exclude": ["test/**", "docs/**", "build/**"],
|
|
110
110
|
|
|
111
111
|
"react": {
|
|
112
|
-
importPaths: {
|
|
112
|
+
"importPaths": {
|
|
113
113
|
"src/components/*": "@ui/components"
|
|
114
114
|
},
|
|
115
115
|
|
|
116
|
-
paths: {
|
|
116
|
+
"paths": {
|
|
117
117
|
"@ui/components/*": ["src/components/*"]
|
|
118
|
-
}
|
|
119
|
-
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
```
|
|
@@ -138,9 +138,15 @@ You can use `importPaths` by specifying where `Button` lives in your repo and ma
|
|
|
138
138
|
consider the full absolute path of the source file `Button.tsx`.
|
|
139
139
|
|
|
140
140
|
```
|
|
141
|
-
|
|
142
|
-
"
|
|
143
|
-
|
|
141
|
+
{
|
|
142
|
+
"codeConnect": {
|
|
143
|
+
"react": {
|
|
144
|
+
"importPaths": {
|
|
145
|
+
"src/components/*": "@ui/components"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
144
150
|
```
|
|
145
151
|
|
|
146
152
|
Which will end up changing your connected code snippet in Figma to
|
|
@@ -162,7 +168,7 @@ To ensure the connected code snippet accurately reflects the design, we need to
|
|
|
162
168
|
Here is a simple example for a button with a `label`, `disabled`, and `type` property.
|
|
163
169
|
|
|
164
170
|
```tsx
|
|
165
|
-
import
|
|
171
|
+
import figma from '@figma/code-connect'
|
|
166
172
|
|
|
167
173
|
figma.connect(Button, 'https://...', {
|
|
168
174
|
props: {
|
|
@@ -186,7 +192,7 @@ figma.connect(Button, 'https://...', {
|
|
|
186
192
|
And this is how we would achieve the same thing using the Storybook integration. Notice how this works well with existing `args` configuration you may already be using in Storybook.
|
|
187
193
|
|
|
188
194
|
```tsx
|
|
189
|
-
import
|
|
195
|
+
import figma from "@figma/code-connect"
|
|
190
196
|
|
|
191
197
|
export default {
|
|
192
198
|
component: Button,
|
|
@@ -436,7 +442,7 @@ jobs:
|
|
|
436
442
|
By default Code Connect creates a new file which lives alongside the components you want to connect to Figma. However, Code Connect may also be co-located with the component it is connecting in code. To do this, simply move the contents of the `<component-name>.figma.tsx` file into your component definition file.
|
|
437
443
|
|
|
438
444
|
```tsx
|
|
439
|
-
import
|
|
445
|
+
import figma from "@figma/code-connect"
|
|
440
446
|
|
|
441
447
|
interface ButtonProps { ... }
|
|
442
448
|
export function Button(props: ButtonProps) { ... }
|
package/dist/commands/connect.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.addConnectCommandToProgram = void 0;
|
|
7
|
-
const parser_1 = require("../
|
|
7
|
+
const parser_1 = require("../react/parser");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const upload_1 = require("../connect/upload");
|
|
10
10
|
const validation_1 = require("../connect/validation");
|
|
@@ -20,7 +20,7 @@ function addBaseCommand(command, name, description) {
|
|
|
20
20
|
.usage('[options]')
|
|
21
21
|
.option('-r --dir <dir>', 'directory to parse')
|
|
22
22
|
.option('-t --token <token>', 'figma access token')
|
|
23
|
-
.option('-
|
|
23
|
+
.option('-v --verbose', 'enable verbose logging for debugging')
|
|
24
24
|
.option('-o --outfile <file>', 'output to JSON file')
|
|
25
25
|
.option('-c --config <path>', 'path to a figma config file')
|
|
26
26
|
.option('--dry-run', 'tests publishing without actually publishing');
|
|
@@ -49,27 +49,27 @@ function getAccessToken(cmd) {
|
|
|
49
49
|
return cmd.token ?? process.env.FIGMA_ACCESS_TOKEN;
|
|
50
50
|
}
|
|
51
51
|
function setupHandler(cmd) {
|
|
52
|
-
if (cmd.
|
|
52
|
+
if (cmd.verbose) {
|
|
53
53
|
logging_1.logger.setLogLevel(logging_1.LogLevel.Debug);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
async function
|
|
57
|
-
const
|
|
56
|
+
async function getCodeConnectObjects(dir, cmd, projectInfo) {
|
|
57
|
+
const codeConnectObjects = [];
|
|
58
58
|
const { files, remoteUrl, config, tsProgram } = projectInfo;
|
|
59
59
|
const figmaNodeToFile = new Map();
|
|
60
60
|
for (const file of files.filter((f) => (0, parser_1.isFigmaConnectFile)(tsProgram, f))) {
|
|
61
61
|
try {
|
|
62
|
-
const docs = await (0, parser_1.parse)(tsProgram, file, remoteUrl, config, cmd.
|
|
62
|
+
const docs = await (0, parser_1.parse)(tsProgram, file, remoteUrl, config, cmd.verbose);
|
|
63
63
|
for (const doc of docs) {
|
|
64
64
|
figmaNodeToFile.set(doc.figmaNode, file);
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
codeConnectObjects.push(...docs);
|
|
67
67
|
logging_1.logger.info((0, logging_1.success)(file));
|
|
68
68
|
}
|
|
69
69
|
catch (e) {
|
|
70
70
|
logging_1.logger.error(`❌ ${file}`);
|
|
71
71
|
if (e instanceof parser_1.ParserError) {
|
|
72
|
-
if (cmd.
|
|
72
|
+
if (cmd.verbose) {
|
|
73
73
|
console.trace(e);
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
@@ -77,7 +77,7 @@ async function getFigmadocs(dir, cmd, projectInfo) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
|
-
if (cmd.
|
|
80
|
+
if (cmd.verbose) {
|
|
81
81
|
console.trace(e);
|
|
82
82
|
}
|
|
83
83
|
else {
|
|
@@ -86,7 +86,7 @@ async function getFigmadocs(dir, cmd, projectInfo) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
return
|
|
89
|
+
return codeConnectObjects;
|
|
90
90
|
}
|
|
91
91
|
async function handlePublish(cmd) {
|
|
92
92
|
setupHandler(cmd);
|
|
@@ -95,11 +95,11 @@ async function handlePublish(cmd) {
|
|
|
95
95
|
if (cmd.dryRun) {
|
|
96
96
|
logging_1.logger.info(`Files that would be published:`);
|
|
97
97
|
}
|
|
98
|
-
const
|
|
99
|
-
const
|
|
98
|
+
const codeConnectObjects = await getCodeConnectObjects(dir, cmd, projectInfo);
|
|
99
|
+
const storybookCodeConnectObjects = await (0, convert_1.convertStorybookFiles)({
|
|
100
100
|
projectInfo,
|
|
101
101
|
});
|
|
102
|
-
const allCodeConnectFiles =
|
|
102
|
+
const allCodeConnectFiles = codeConnectObjects.concat(storybookCodeConnectObjects);
|
|
103
103
|
if (allCodeConnectFiles.length === 0) {
|
|
104
104
|
logging_1.logger.warn(`No Code Connect files found in ${dir} - Make sure you have configured \`include\` and \`exclude\` in your figma.config.json file correctly, or that you are running in a directory that contains Code Connect files.`);
|
|
105
105
|
process.exit(0);
|
|
@@ -146,11 +146,11 @@ async function handleUnpublish(cmd) {
|
|
|
146
146
|
}
|
|
147
147
|
else {
|
|
148
148
|
const projectInfo = (0, project_1.getProjectInfo)(dir, cmd.config);
|
|
149
|
-
const
|
|
150
|
-
const
|
|
149
|
+
const codeConnectObjects = await getCodeConnectObjects(dir, cmd, projectInfo);
|
|
150
|
+
const storybookCodeConnectObjects = await (0, convert_1.convertStorybookFiles)({
|
|
151
151
|
projectInfo,
|
|
152
152
|
});
|
|
153
|
-
const allCodeConnectFiles =
|
|
153
|
+
const allCodeConnectFiles = codeConnectObjects.concat(storybookCodeConnectObjects);
|
|
154
154
|
nodesToDeleteRelevantInfo = allCodeConnectFiles.map((doc) => ({
|
|
155
155
|
figmaNode: doc.figmaNode,
|
|
156
156
|
label: doc.label,
|
|
@@ -174,17 +174,17 @@ async function handleParse(cmd) {
|
|
|
174
174
|
}
|
|
175
175
|
let dir = cmd.dir ?? process.cwd();
|
|
176
176
|
const projectInfo = (0, project_1.getProjectInfo)(dir, cmd.config);
|
|
177
|
-
const
|
|
178
|
-
const
|
|
177
|
+
const codeConnectObjects = await getCodeConnectObjects(dir, cmd, projectInfo);
|
|
178
|
+
const storybookCodeConnectObjects = await (0, convert_1.convertStorybookFiles)({
|
|
179
179
|
projectInfo,
|
|
180
180
|
});
|
|
181
|
-
const allCodeConnectFiles =
|
|
181
|
+
const allCodeConnectFiles = codeConnectObjects.concat(storybookCodeConnectObjects);
|
|
182
182
|
if (cmd.dryRun) {
|
|
183
183
|
logging_1.logger.info(`Dry run complete`);
|
|
184
184
|
process.exit(0);
|
|
185
185
|
}
|
|
186
186
|
if (cmd.outfile) {
|
|
187
|
-
fs_1.default.writeFileSync(cmd.outfile, JSON.stringify(
|
|
187
|
+
fs_1.default.writeFileSync(cmd.outfile, JSON.stringify(codeConnectObjects, null, 2));
|
|
188
188
|
logging_1.logger.info(`Wrote Code Connect JSON to ${(0, logging_1.highlight)(cmd.outfile)}`);
|
|
189
189
|
}
|
|
190
190
|
else {
|
|
@@ -202,7 +202,7 @@ function handleCreate(nodeUrl, cmd) {
|
|
|
202
202
|
logging_1.logger.error(`Couldn't find a Figma access token. Please provide one with \`--token <access_token>\` or set the FIGMA_ACCESS_TOKEN environment variable`);
|
|
203
203
|
process.exit(1);
|
|
204
204
|
}
|
|
205
|
-
return (0, create_1.
|
|
205
|
+
return (0, create_1.createCodeConnectFromUrl)({
|
|
206
206
|
accessToken,
|
|
207
207
|
// We remove \s to allow users to paste URLs inside quotes - the terminal
|
|
208
208
|
// paste will add backslashes, which the quotes preserve, but expected user
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":";;;;;;AACA,
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":";;;;;;AACA,4CAAuF;AACvF,4CAAmB;AACnB,8CAA0C;AAC1C,sDAAoD;AACpD,8CAA4D;AAC5D,+CAA+D;AAC/D,+CAA+E;AAE/E,kDAA4D;AAC5D,wDAAoD;AAWpD,SAAS,cAAc,CAAC,OAA0B,EAAE,IAAY,EAAE,WAAmB;IACnF,OAAO,OAAO;SACX,OAAO,CAAC,IAAI,CAAC;SACb,WAAW,CAAC,WAAW,CAAC;SACxB,KAAK,CAAC,WAAW,CAAC;SAClB,MAAM,CAAC,gBAAgB,EAAE,oBAAoB,CAAC;SAC9C,MAAM,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;SAClD,MAAM,CAAC,cAAc,EAAE,sCAAsC,CAAC;SAC9D,MAAM,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;SACpD,MAAM,CAAC,oBAAoB,EAAE,6BAA6B,CAAC;SAC3D,MAAM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2EAA2E;QAC3E,yCAAyC;QACzC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;QACxC,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/common/api.d.ts
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
type EnumValue = string | boolean | number | symbol | undefined | JSX.Element;
|
|
2
3
|
export interface FigmaConnectAPI {
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Defines a code snippet that displays in Figma when a component is selected. This function has two signatures:
|
|
6
|
+
* - When called with a component reference as the first argument, it will infer metadata such as the import statement
|
|
7
|
+
* and location in source file from the component reference
|
|
8
|
+
* - 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
|
|
9
|
+
* for something that isn't a React component, such as a `<button>` element
|
|
7
10
|
*
|
|
8
11
|
* @param component A reference to the React component
|
|
9
12
|
* @param figmaNodeUrl A link to the node in Figma, for example:`https://www.figma.com/file/123abc/My-Component?node-id=123:456`
|
|
10
13
|
* @param meta {@link FigmaConnectMeta}
|
|
11
14
|
*/
|
|
12
15
|
connect<P = {}>(component: any, figmaNodeUrl: string, meta?: FigmaConnectMeta<P>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Defines a code snippet that displays in Figma when a component is selected. This function has two signatures:
|
|
18
|
+
* - When called with a component reference as the first argument, it will infer metadata such as the import statement
|
|
19
|
+
* and location in source file from the component reference
|
|
20
|
+
* - 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
|
|
21
|
+
* for something that isn't a React component, such as a `<button>` element
|
|
22
|
+
*
|
|
23
|
+
* @param figmaNodeUrl A link to the node in Figma, for example:`https://www.figma.com/file/123abc/My-Component?node-id=123:456`
|
|
24
|
+
* @param meta {@link FigmaConnectMeta}
|
|
25
|
+
*/
|
|
26
|
+
connect<P = {}>(figmaNodeUrl: string, meta?: FigmaConnectMeta<P>): void;
|
|
13
27
|
/**
|
|
14
28
|
* Maps a Figma property to a boolean value for the connected component. This prop is replaced
|
|
15
29
|
* with values from the Figma instance when viewed in Dev Mode. For example:
|
|
@@ -40,7 +54,10 @@ export interface FigmaConnectAPI {
|
|
|
40
54
|
* @param figmaPropName The name of the property on the Figma component
|
|
41
55
|
* @param valueMapping A mapping of values for `true` and `false`
|
|
42
56
|
*/
|
|
43
|
-
boolean<
|
|
57
|
+
boolean<TrueT extends EnumValue, FalseT extends EnumValue>(figmaPropName: string, valueMapping?: {
|
|
58
|
+
true?: TrueT;
|
|
59
|
+
false?: FalseT;
|
|
60
|
+
}): ValueOf<Record<'true' | 'false', TrueT | FalseT>>;
|
|
44
61
|
/**
|
|
45
62
|
* Maps a Figma Variant property to a set if values for the connected component. This prop is replaced
|
|
46
63
|
* with values from the Figma instance when viewed in Dev Mode. For example:
|
|
@@ -57,7 +74,7 @@ export interface FigmaConnectAPI {
|
|
|
57
74
|
* @param figmaPropName The name of the property on the Figma component
|
|
58
75
|
* @param valueMapping A mapping of values for the Figma Variant
|
|
59
76
|
*/
|
|
60
|
-
enum<V extends
|
|
77
|
+
enum<V extends EnumValue>(figmaPropName: string, valueMapping: PropMapping<Record<string, V>>): ValueOf<Record<string, V>>;
|
|
61
78
|
/**
|
|
62
79
|
* Maps a Figma property to a string value for the connected component. This prop is replaced
|
|
63
80
|
* with values from the Figma instance when viewed in Dev Mode. For example:
|
|
@@ -138,9 +155,16 @@ export interface FigmaConnectMeta<T = {}, ExtraExampleT = never> {
|
|
|
138
155
|
* @returns
|
|
139
156
|
*/
|
|
140
157
|
example?: ((props: T) => React.Component | JSX.Element) | ExtraExampleT;
|
|
158
|
+
/**
|
|
159
|
+
* A list of import statements that will render in the Code Snippet in Figma.
|
|
160
|
+
* This overrides the auto-generated imports for the component. When this is specified,
|
|
161
|
+
* the `importPaths` option in the config file is also ignored.
|
|
162
|
+
*/
|
|
163
|
+
imports?: string[];
|
|
141
164
|
/**
|
|
142
165
|
* A list of links that will display in Figma along with the examples
|
|
143
166
|
*/
|
|
144
167
|
links?: FigmaConnectLink[];
|
|
145
168
|
}
|
|
169
|
+
export {};
|
|
146
170
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/common/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/common/api.ts"],"names":[],"mappings":";AAAA,MAAM,WAAW,eAAe;IAC9B
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/common/api.ts"],"names":[],"mappings":";AAAA,KAAK,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,GAAG,CAAC,OAAO,CAAA;AAE7E,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAEvF;;;;;;;;;OASG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IAEvE;;;;;;;;;;;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,CA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E,MAAM,EAAE,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAC3B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FigmaConnectMeta, PropMapping, ValueOf } from './api';
|
|
2
2
|
import * as React from 'react';
|
|
3
|
+
declare function connectType<P = {}>(_figmaNodeUrl: string, _meta?: FigmaConnectMeta<P>): void;
|
|
3
4
|
declare function connectType<P = {}>(_component: any, _figmaNodeUrl: string, _meta?: FigmaConnectMeta<P>): void;
|
|
4
5
|
declare function booleanType(_figmaPropName: string): boolean;
|
|
5
6
|
declare function enumType<V extends string | boolean | number | symbol | undefined | JSX.Element>(_figmaPropName: string, _valueMapping: PropMapping<Record<string, V>>): ValueOf<Record<string, V>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/common/external.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,iBAAS,WAAW,CAAC,CAAC,GAAG,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/common/external.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC9D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,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,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAA;AAWrD,iBAAS,QAAQ,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,GAAG,CAAC,OAAO,EACtF,cAAc,EAAE,MAAM,EACtB,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAC5C,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAE5B;AAED,iBAAS,UAAU,CAAC,cAAc,EAAE,MAAM,UAEzC;AAED,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,WAAW,IAAI,OAAO,EACtB,QAAQ,IAAI,IAAI,EAChB,UAAU,IAAI,MAAM,EACpB,YAAY,IAAI,QAAQ,EACxB,YAAY,IAAI,QAAQ,GACzB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/common/external.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA8B;
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/common/external.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA8B;AAQ9B,SAAS,WAAW,CAAC,UAAmB,EAAE,aAAsB,EAAE,KAAe,IAAS,CAAC;AAiC1E,8BAAO;AA9BxB,SAAS,WAAW,CAClB,cAAsB,EACtB,aAA2C;IAE3C,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,QAAQ,CAAI,cAAc,EAAE,aAAa,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAuBgB,8BAAO;AArBxB,SAAS,QAAQ,CACf,cAAsB,EACtB,aAA6C;IAE7C,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAA+B,CAAA;AACtE,CAAC;AAiBa,wBAAI;AAflB,SAAS,UAAU,CAAC,cAAsB;IACxC,OAAO,EAAE,CAAA;AACX,CAAC;AAce,4BAAM;AAZtB,SAAS,YAAY,CAAC,cAAsB;IAC1C,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACnC,CAAC;AAWiB,gCAAQ;AAT1B,SAAS,YAAY,CAAC,OAA0B;IAC9C,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;AACnC,CAAC;AAQiB,gCAAQ"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FigmaConnectLink } from './api';
|
|
2
2
|
import { Intrinsic } from './intrinsics';
|
|
3
|
-
export interface
|
|
3
|
+
export interface CodeConnectJSON {
|
|
4
4
|
figmaNode: string;
|
|
5
|
-
component
|
|
5
|
+
component?: string;
|
|
6
6
|
variant?: Record<string, any>;
|
|
7
7
|
source: string;
|
|
8
8
|
sourceLocation: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"figma_connect.d.ts","sourceRoot":"","sources":["../../src/common/figma_connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"figma_connect.d.ts","sourceRoot":"","sources":["../../src/common/figma_connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE;QACZ,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,SAAS,CAAA;QAC5C,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;QAClB,QAAQ,CAAC,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,QAAQ,EAAE,YAAY,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAA;IAC1B,QAAQ,EAAE;QACR,UAAU,EAAE,MAAM,CAAA;KACnB,CAAA;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import * as ts from 'typescript';
|
|
3
|
-
import { ParserContext } from '
|
|
3
|
+
import { ParserContext } from '../react/parser';
|
|
4
4
|
export declare const API_PREFIX = "figma";
|
|
5
5
|
export declare const FIGMA_CONNECT_CALL = "figma.connect";
|
|
6
6
|
export declare enum IntrinsicKind {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intrinsics.d.ts","sourceRoot":"","sources":["../../src/common/intrinsics.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,EAAiB,aAAa,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"intrinsics.d.ts","sourceRoot":"","sources":["../../src/common/intrinsics.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAChC,OAAO,EAAiB,aAAa,EAAe,MAAM,iBAAiB,CAAA;AAM3E,eAAO,MAAM,UAAU,UAAU,CAAA;AACjC,eAAO,MAAM,kBAAkB,kBAA0B,CAAA;AAEzD,oBAAY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S,GAAG,WAAW,GAAG,aAAa,GAAG,aAAa,CAAA;AA+K9F;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,EAAE,CAAC,cAAc,EAAE,aAAa,EAAE,aAAa,GAAG,SAAS,CAW9F;AAED,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,MAAM,CAuB3F;AAED,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,SAAS,GAAG,MAAM,CA+BnE"}
|
|
@@ -25,10 +25,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.intrinsicToString = exports.valueMappingToString = exports.parseIntrinsic = exports.IntrinsicKind = exports.FIGMA_CONNECT_CALL = exports.API_PREFIX = void 0;
|
|
27
27
|
const ts = __importStar(require("typescript"));
|
|
28
|
-
const parser_1 = require("
|
|
29
|
-
const compiler_1 = require("
|
|
30
|
-
const compiler_2 = require("
|
|
31
|
-
const compiler_3 = require("
|
|
28
|
+
const parser_1 = require("../react/parser");
|
|
29
|
+
const compiler_1 = require("../typescript/compiler");
|
|
30
|
+
const compiler_2 = require("../typescript/compiler");
|
|
31
|
+
const compiler_3 = require("../typescript/compiler");
|
|
32
32
|
exports.API_PREFIX = 'figma';
|
|
33
33
|
exports.FIGMA_CONNECT_CALL = `${exports.API_PREFIX}.connect`;
|
|
34
34
|
var IntrinsicKind;
|
|
@@ -53,7 +53,9 @@ const Intrinsics = {};
|
|
|
53
53
|
function makeIntrinsic(intrinsicName, obj) {
|
|
54
54
|
const name = `${exports.API_PREFIX}.${intrinsicName}`;
|
|
55
55
|
Intrinsics[name] = {
|
|
56
|
-
match: (exp) =>
|
|
56
|
+
match: (exp) => {
|
|
57
|
+
return ts.isCallExpression(exp) && exp.getText().startsWith(name);
|
|
58
|
+
},
|
|
57
59
|
...obj(name),
|
|
58
60
|
};
|
|
59
61
|
}
|
|
@@ -193,7 +195,9 @@ function valueMappingToString(valueMapping) {
|
|
|
193
195
|
// Mappings can be nested, e.g. an enum value can be figma.instance(...)
|
|
194
196
|
return `"${key}": ${intrinsicToString(value)}`;
|
|
195
197
|
}
|
|
196
|
-
else if (typeof value === 'boolean' ||
|
|
198
|
+
else if (typeof value === 'boolean' ||
|
|
199
|
+
typeof value === 'number' ||
|
|
200
|
+
typeof value === 'undefined') {
|
|
197
201
|
return `"${key}": ${value}`;
|
|
198
202
|
}
|
|
199
203
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intrinsics.js","sourceRoot":"","sources":["../../src/common/intrinsics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"intrinsics.js","sourceRoot":"","sources":["../../src/common/intrinsics.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,4CAA2E;AAC3E,qDAA2E;AAC3E,qDAAiE;AACjE,qDAAwE;AAG3D,QAAA,UAAU,GAAG,OAAO,CAAA;AACpB,QAAA,kBAAkB,GAAG,GAAG,kBAAU,UAAU,CAAA;AAEzD,IAAY,aAMX;AAND,WAAY,aAAa;IACvB,8BAAa,CAAA;IACb,kCAAiB,CAAA;IACjB,oCAAmB,CAAA;IACnB,sCAAqB,CAAA;IACrB,sCAAqB,CAAA;AACvB,CAAC,EANW,aAAa,6BAAb,aAAa,QAMxB;AAgDD,MAAM,UAAU,GAKZ,EAAE,CAAA;AAEN;;;;;;;;;GASG;AACH,SAAS,aAAa,CACpB,aAAgB,EAChB,GAA0B;IAE1B,MAAM,IAAI,GAAG,GAAG,kBAAU,IAAI,aAAa,EAAE,CAAA;IAC7C,UAAU,CAAC,IAAI,CAAC,GAAG;QACjB,KAAK,EAAE,CAAC,GAAsB,EAAE,EAAE;YAChC,OAAO,EAAE,CAAC,gBA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M,aAAa,GAAG,CAAA;QAC3E,CAAC;QACD,KAAK,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC5B,gFAAgF;YAChF,OAAO,8BAA8B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,IAAI,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAA;QACrG,CAAC;QACD;YACE,MAAM,IAAI,sBAAa,CAAC,sBAAsB,IAAI,EAAE,CAAC,CAAA;IACzD,CAAC;AACH,CAAC;AA/BD,8CA+BC"}
|
package/dist/common/project.d.ts
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
1
|
import ts from 'typescript';
|
|
2
|
-
export interface
|
|
3
|
-
/**
|
|
4
|
-
* Maps imports from their path on disk to the specified path.
|
|
5
|
-
* This will rewrite the imports in generated code examples, so it works with
|
|
6
|
-
* relative imports such as `import { Button } from "./"`.
|
|
7
|
-
*
|
|
8
|
-
* Example: { "src/components/*": "@ui/components" }
|
|
9
|
-
* Would rewrite imports for components located in `src/components` to `@ui/components` in
|
|
10
|
-
* generated code examples.
|
|
11
|
-
* `import { Button } from "./"` -> `import { Button } from "@ui/components/Button"`
|
|
12
|
-
*/
|
|
13
|
-
importPaths?: Record<string, string>;
|
|
14
|
-
/**
|
|
15
|
-
* For import resolution - this is a temporary solution to support projects that use
|
|
16
|
-
* pnpm workspaces, as the compiler doesn't seem to be able to resolve imports when
|
|
17
|
-
* the package in node_modules is a symlink. Need to look into this more and find a
|
|
18
|
-
* better solution.
|
|
19
|
-
*/
|
|
20
|
-
paths?: Record<string, string[]>;
|
|
2
|
+
export interface CodeConnectConfig {
|
|
21
3
|
/**
|
|
22
4
|
* Specify glob patterns for files (relative to the project root) to be
|
|
23
5
|
* included when looking for source files. If not specified, all files
|
|
@@ -36,6 +18,38 @@ export interface FigmaConnectConfig {
|
|
|
36
18
|
* staging URL). Not publicly documented.
|
|
37
19
|
*/
|
|
38
20
|
documentUrlSubstitutions?: Record<string, string>;
|
|
21
|
+
/**
|
|
22
|
+
* React specific configuration
|
|
23
|
+
*/
|
|
24
|
+
react?: {
|
|
25
|
+
/**
|
|
26
|
+
* Maps imports from their path on disk to the specified path.
|
|
27
|
+
* This will rewrite the imports in generated code examples, so it works with
|
|
28
|
+
* relative imports such as `import { Button } from "./"`.
|
|
29
|
+
*
|
|
30
|
+
* Example: { "src/components/*": "@ui/components" }
|
|
31
|
+
* Would rewrite imports for components located in `src/components` to `@ui/components` in
|
|
32
|
+
* generated code examples.
|
|
33
|
+
* `import { Button } from "./"` -> `import { Button } from "@ui/components/Button"`
|
|
34
|
+
*/
|
|
35
|
+
importPaths?: Record<string, string>;
|
|
36
|
+
/**
|
|
37
|
+
* For import resolution - this is a temporary solution to support projects that use
|
|
38
|
+
* pnpm workspaces, as the compiler doesn't seem to be able to resolve imports when
|
|
39
|
+
* the package in node_modules is a symlink. Need to look into this more and find a
|
|
40
|
+
* better solution.
|
|
41
|
+
*/
|
|
42
|
+
paths?: Record<string, string[]>;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Storybook specific configuration
|
|
46
|
+
*/
|
|
47
|
+
storybook?: {
|
|
48
|
+
/**
|
|
49
|
+
* The URL of the Storybook instance for the project
|
|
50
|
+
*/
|
|
51
|
+
url: string;
|
|
52
|
+
};
|
|
39
53
|
}
|
|
40
54
|
export declare function getGitRemoteURL(repoPath: string): string;
|
|
41
55
|
/**
|
|
@@ -45,6 +59,7 @@ export declare function getGitRemoteURL(repoPath: string): string;
|
|
|
45
59
|
* @returns
|
|
46
60
|
*/
|
|
47
61
|
export declare function getRemoteFileUrl(filePath: string, repoURL?: string): string;
|
|
62
|
+
export declare function getStorybookUrl(filePath: string, storybookUrl: string): string;
|
|
48
63
|
export interface ProjectInfo {
|
|
49
64
|
/**
|
|
50
65
|
* Absolute path of the project directory
|
|
@@ -61,7 +76,7 @@ export interface ProjectInfo {
|
|
|
61
76
|
/**
|
|
62
77
|
* The parsed Code Connect config file
|
|
63
78
|
*/
|
|
64
|
-
config?:
|
|
79
|
+
config?: CodeConnectConfig;
|
|
65
80
|
/**
|
|
66
81
|
* TS program containing all tsx files in the project
|
|
67
82
|
*/
|
|
@@ -75,5 +90,5 @@ export interface ProjectInfo {
|
|
|
75
90
|
* @returns Object containing information about the project
|
|
76
91
|
*/
|
|
77
92
|
export declare function getProjectInfo(dir: string, configPath?: string): ProjectInfo;
|
|
78
|
-
export declare function resolveImportPath(filePath: string, config:
|
|
93
|
+
export declare function resolveImportPath(filePath: string, config: CodeConnectConfig): string | null;
|
|
79
94
|
//# sourceMappingURL=project.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/common/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,YAAY,CAAA;AAI3B,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/common/project.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,YAAY,CAAA;AAI3B,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACjD;;OAEG;IACH,KAAK,CAAC,EAAE;QACN;;;;;;;;;WASG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACpC;;;;;WAKG;QACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;KACjC,CAAA;IACD;;OAEG;IACH,SAAS,CAAC,EAAE;QACV;;WAEG;QACH,GAAG,EAAE,MAAM,CAAA;KACZ,CAAA;CACF;AAqBD,wBAAgB,eAAe,C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