@figma/code-connect 1.1.2 → 1.1.3
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/dist/connect/api.d.ts +3 -3
- package/dist/connect/api.d.ts.map +1 -1
- package/dist/html/external.d.ts +2 -2
- package/dist/html/external.d.ts.map +1 -1
- package/dist/html/external.js.map +1 -1
- package/dist/html/index_html.d.ts +3 -2
- package/dist/html/index_html.d.ts.map +1 -1
- package/dist/html/index_html.js.map +1 -1
- package/dist/html/parser.js +1 -1
- package/dist/html/types.d.ts +9 -0
- package/dist/html/types.d.ts.map +1 -0
- package/dist/html/types.js +3 -0
- package/dist/html/types.js.map +1 -0
- package/dist/react/external.d.ts +3 -3
- package/dist/react/external.d.ts.map +1 -1
- package/dist/react/external.js.map +1 -1
- package/dist/react/index_react.d.ts +4 -9
- package/dist/react/index_react.d.ts.map +1 -1
- package/dist/react/index_react.js.map +1 -1
- package/dist/react/parser.js +1 -1
- package/dist/react/types.d.ts +11 -0
- package/dist/react/types.d.ts.map +1 -0
- package/dist/react/types.js +3 -0
- package/dist/react/types.js.map +1 -0
- package/dist/storybook/external.d.ts +2 -2
- package/dist/storybook/external.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.d.ts +0 -2
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.d.ts.map +0 -1
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.js +0 -9
- package/dist/html/__test__/parser/examples/NoConfigObject.figma.js.map +0 -1
- package/dist/html/__test__/parser/examples/NoExample.figma.d.ts +0 -2
- package/dist/html/__test__/parser/examples/NoExample.figma.d.ts.map +0 -1
- package/dist/html/__test__/parser/examples/NoExample.figma.js +0 -9
- package/dist/html/__test__/parser/examples/NoExample.figma.js.map +0 -1
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.d.ts +0 -2
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.d.ts.map +0 -1
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.js +0 -33
- package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.js.map +0 -1
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.d.ts +0 -2
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.d.ts.map +0 -1
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.js +0 -15
- package/dist/html/__test__/parser/examples/WrongSignatureJsx.figma.js.map +0 -1
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.d.ts +0 -2
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.d.ts.map +0 -1
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.js +0 -15
- package/dist/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.js.map +0 -1
- package/dist/html/__test__/parser/parser.test.d.ts +0 -2
- package/dist/html/__test__/parser/parser.test.d.ts.map +0 -1
- package/dist/html/__test__/parser/parser.test.js +0 -50
- package/dist/html/__test__/parser/parser.test.js.map +0 -1
package/dist/connect/api.d.ts
CHANGED
|
@@ -103,7 +103,7 @@ export interface FigmaConnectLink {
|
|
|
103
103
|
name: string;
|
|
104
104
|
url: string;
|
|
105
105
|
}
|
|
106
|
-
export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
|
|
106
|
+
export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown, ExtraExampleT = never> {
|
|
107
107
|
/**
|
|
108
108
|
* Restricts this figma connect to any variants that fullfill the given filter.
|
|
109
109
|
* The filter is a map of Figma variant names to values. Example:
|
|
@@ -115,7 +115,7 @@ export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
|
|
|
115
115
|
variant?: Record<string, string | boolean | number>;
|
|
116
116
|
/**
|
|
117
117
|
* Prop mappings for the connected component. This is used to map the values of the component's props
|
|
118
|
-
* to the values that are used in Figma, using helper functions like `
|
|
118
|
+
* to the values that are used in Figma, using helper functions like `figma.boolean`. For example:
|
|
119
119
|
* ```ts
|
|
120
120
|
* props: {
|
|
121
121
|
* disabled: figma.boolean('Disabled'),
|
|
@@ -134,7 +134,7 @@ export interface FigmaConnectMeta<T = {}, ExampleFnReturnT = unknown> {
|
|
|
134
134
|
* @param props
|
|
135
135
|
* @returns
|
|
136
136
|
*/
|
|
137
|
-
example?: (props: T) => ExampleFnReturnT;
|
|
137
|
+
example?: ((props: T) => ExampleFnReturnT) | ExtraExampleT;
|
|
138
138
|
/**
|
|
139
139
|
* A list of links that will display in Figma along with the examples
|
|
140
140
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/connect/api.ts"],"names":[],"mappings":";AAAA,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,GAAG,CAAC,OAAO,GACX,QAAQ,GACR,MAAM,CAAA;AASV,MAAM,WAAW,eAAe,CAAC,iBAAiB;IAChD;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;IAEpF;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;IAErC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,iBAAiB,CAAA;IAElD;;;;;;;;;;;;;;;;;;;OAmBG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,iBAAiB,CAAA;IAE1D;;;;;;;;;;;;;;OAcG;IACH,SAAS,CAAC,SAAS,EAAE,CAAC,MAAM,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,CAAA;IAEpD;;;;;;;;;;;OAWG;IACH,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O,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;CACzB,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAKD,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,EAAE,EAAE,gBAAgB,GAAG,OAAO,EAAE,aAAa,GAAG,KAAK;IACzF;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,CAAA;IAEnD;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,EAAE,CAAC,CAAA;IAET;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,gBAAgB,CAAC,GAAG,aAAa,CAAA;IAE1D;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAC3B"}
|
package/dist/html/external.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { FigmaConnectMeta } from '../connect/api';
|
|
2
1
|
import { booleanType, enumType, stringType, nestedPropsType, classNameType, textContentType } from '../connect/external_types';
|
|
3
2
|
import { HtmlTemplateString } from './template_literal';
|
|
4
|
-
|
|
3
|
+
import { HtmlMeta } from './types';
|
|
4
|
+
declare function connectType<P = {}>(_figmaNodeUrl: string, _meta?: HtmlMeta<P>): void;
|
|
5
5
|
declare function instanceType(_figmaPropName: string): HtmlTemplateString;
|
|
6
6
|
declare function childrenType(_layers: string | string[]): HtmlTemplateString;
|
|
7
7
|
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, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/html/external.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/html/external.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAElC,iBAAS,WAAW,CAAC,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAG;AAEjF,iBAAS,YAAY,CAAC,cAAc,EAAE,MAAM,GAAG,kBAAkB,CAIhE;AAED,iBAAS,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,kBAAkB,CAIpE;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/html/external.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/html/external.ts"],"names":[],"mappings":";;;AAAA,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;AApBhC,SAAS,WAAW,CAAS,aAAqB,EAAE,KAAmB,IAAS,CAAC;AAqBhE,8BAAO;AAnBxB,SAAS,YAAY,CAAC,cAAsB;IAC1C,OAAO;QACL,KAAK,EAAE,oBAAoB;KAC5B,CAAA;AACH,CAAC;AAgBiB,gCAAQ;AAd1B,SAAS,YAAY,CAAC,OAA0B;IAC9C,OAAO;QACL,KAAK,EAAE,oBAAoB;KAC5B,CAAA;AACH,CAAC;AAWiB,gCAAQ"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { EnumValue, FigmaConnectAPI,
|
|
1
|
+
import { EnumValue, FigmaConnectAPI, ValueOf } from '../connect/api';
|
|
2
2
|
import { FigmaConnectClient } from '../client/figma_client';
|
|
3
3
|
import { html, HtmlTemplateString } from './template_literal';
|
|
4
|
+
import { HtmlMeta } from './types';
|
|
4
5
|
declare const _client: FigmaConnectClient;
|
|
5
6
|
declare const _figma: FigmaConnectAPI<HtmlTemplateString> & {
|
|
6
7
|
/**
|
|
@@ -9,7 +10,7 @@ declare const _figma: FigmaConnectAPI<HtmlTemplateString> & {
|
|
|
9
10
|
* @param figmaNodeUrl A link to the node in Figma, for example:`https://www.figma.com/file/123abc/My-Component?node-id=123:456`
|
|
10
11
|
* @param meta {@link FigmaConnectMeta}
|
|
11
12
|
*/
|
|
12
|
-
connect<P = {}>(figmaNodeUrl: string, meta:
|
|
13
|
+
connect<P = {}>(figmaNodeUrl: string, meta: HtmlMeta<P>): void;
|
|
13
14
|
/**
|
|
14
15
|
* Maps a Figma property to a boolean value for the connected component. This prop is replaced
|
|
15
16
|
* with values from the Figma instance when viewed in Dev Mode. For example:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index_html.d.ts","sourceRoot":"","sources":["../../src/html/index_html.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"index_html.d.ts","source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E,CAAA;AAC5D,eAAe,MAAM,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index_html.js","sourceRoot":"","sources":["../../src/html/index_html.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,uEAAuE;AACvE,yEAAyE;AACzE,qEAAqE;AACrE,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvC,kDAAmC;AAEnC,yDAA6D;AAC7D,0DAAmD;
|
|
1
|
+
{"version":3,"file":"index_html.js","sourceRoot":"","sources":["../../src/html/index_html.ts"],"names":[],"mappings":";AAAA,8EAA8E;AAC9E,uEAAuE;AACvE,yEAAyE;AACzE,qEAAqE;AACrE,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;AAGvC,kDAAmC;AAEnC,yDAA6D;AAC7D,0DAAmD;AAGnD,MAAM,OAAO,GAAuB,IAAA,wBAAS,GAAE,CAAA;AA+EV,yBAAM;AA9E3C,MAAM,MAAM,GA2ER,KAAK,CAAA;AAGU,uBAAK;AAFxB,MAAM,KAAK,GAAG,uBAAI,CAAA;AAEoC,qBAAI;AAC1D,kBAAe,MAAM,CAAA"}
|
package/dist/html/parser.js
CHANGED
|
@@ -433,7 +433,7 @@ function parseConfigObjectArg(configArg, parserContext) {
|
|
|
433
433
|
}
|
|
434
434
|
async function parseHtmlDoc(node, parserContext, { repoUrl, silent }) {
|
|
435
435
|
const { checker, sourceFile, config } = parserContext;
|
|
436
|
-
// Parse the arguments to the `
|
|
436
|
+
// Parse the arguments to the `figma.connect()` call
|
|
437
437
|
const { figmaNodeUrlArg, configObjArg } = parseFigmaConnectArgs(node, parserContext);
|
|
438
438
|
const { propsArg, exampleArg, variantArg, linksArg, importsArg } = parseConfigObjectArg(configObjArg, parserContext);
|
|
439
439
|
let figmaNode = (0, compiler_1.stripQuotesFromNode)(figmaNodeUrlArg);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FigmaConnectMeta } from '../connect/api';
|
|
2
|
+
import { HtmlTemplateString } from './template_literal';
|
|
3
|
+
export type HtmlMeta<P> = Required<Pick<FigmaConnectMeta<P, HtmlTemplateString>, 'example'>> & FigmaConnectMeta<P, HtmlTemplateString> & {
|
|
4
|
+
/**
|
|
5
|
+
* A list of import statements that will render in the Code Snippet in Figma.
|
|
6
|
+
*/
|
|
7
|
+
imports?: string[];
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/html/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,CAAC,EAAE,SAAS,CAAC,CAAC,GAC1F,gBAAgB,CAAC,CAAC,EAAE,kBAAkB,CAAC,GAAG;IACxC;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/html/types.ts"],"names":[],"mappings":""}
|
package/dist/react/external.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { FigmaConnectMeta } from '../connect/api';
|
|
2
1
|
import * as React from 'react';
|
|
3
2
|
import { booleanType, enumType, stringType, nestedPropsType, classNameType, textContentType } from '../connect/external_types';
|
|
4
|
-
|
|
5
|
-
declare function connectType<P = {}>(
|
|
3
|
+
import { ReactMeta } from './types';
|
|
4
|
+
declare function connectType<P = {}>(_figmaNodeUrl: string, _meta?: ReactMeta<P>): void;
|
|
5
|
+
declare function connectType<P = {}>(_component: any, _figmaNodeUrl: string, _meta?: ReactMeta<P>): void;
|
|
6
6
|
declare function instanceType(_figmaPropName: string): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
7
7
|
declare function childrenType(_layers: string | string[]): React.DetailedReactHTMLElement<React.HTMLAttributes<HTMLElement>, HTMLElement>;
|
|
8
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, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/react/external.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/react/external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,WAAW,EACX,QAAQ,EACR,UAAU,EACV,eAAe,EACf,aAAa,EACb,eAAe,EAChB,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAEnC,iBAAS,WAAW,CAAC,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;AAC/E,iBAAS,WAAW,CAAC,CAAC,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;AAGhG,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/react/external.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../../src/react/external.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8B;AAC9B,8DAOkC;AAgBjB,wFAtBf,4BAAW,OAsBW;AACV,qFAtBZ,yBAAQ,OAsBQ;AACF,uFAtBd,2BAAU,OAsBU;AACD,4FAtBnB,gCAAe,OAsBe;AACb,0FAtBjB,8BAAa,OAsBa;AACP,4FAtBnB,gCAAe,OAsBe;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"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { EnumValue, FigmaConnectAPI,
|
|
2
|
+
import { EnumValue, FigmaConnectAPI, ValueOf } from '../connect/api';
|
|
3
3
|
import * as StorybookTypes from '../storybook/external';
|
|
4
4
|
import { FigmaConnectClient } from '../client/figma_client';
|
|
5
|
+
import { ReactMeta } from './types';
|
|
5
6
|
declare const _client: FigmaConnectClient;
|
|
6
7
|
declare const _figma: FigmaConnectAPI<JSX.Element> & {
|
|
7
8
|
/**
|
|
@@ -15,7 +16,7 @@ declare const _figma: FigmaConnectAPI<JSX.Element> & {
|
|
|
15
16
|
* @param figmaNodeUrl A link to the node in Figma, for example:`https://www.figma.com/file/123abc/My-Component?node-id=123:456`
|
|
16
17
|
* @param meta {@link FigmaConnectMeta}
|
|
17
18
|
*/
|
|
18
|
-
connect<P = {}>(component: any, figmaNodeUrl: string, meta?:
|
|
19
|
+
connect<P = {}>(component: any, figmaNodeUrl: string, meta?: ReactMeta<P>): void;
|
|
19
20
|
/**
|
|
20
21
|
* Defines a code snippet that displays in Figma when a component is selected. This function has two signatures:
|
|
21
22
|
* - When called with a component reference as the first argument, it will infer metadata such as the import statement
|
|
@@ -26,7 +27,7 @@ declare const _figma: FigmaConnectAPI<JSX.Element> & {
|
|
|
26
27
|
* @param figmaNodeUrl A link to the node in Figma, for example:`https://www.figma.com/file/123abc/My-Component?node-id=123:456`
|
|
27
28
|
* @param meta {@link FigmaConnectMeta}
|
|
28
29
|
*/
|
|
29
|
-
connect<P = {}>(figmaNodeUrl: string, meta?:
|
|
30
|
+
connect<P = {}>(figmaNodeUrl: string, meta?: ReactMeta<P>): void;
|
|
30
31
|
/**
|
|
31
32
|
* Maps a Figma property to a boolean value for the connected component. This prop is replaced
|
|
32
33
|
* with values from the Figma instance when viewed in Dev Mode. For example:
|
|
@@ -81,12 +82,6 @@ declare const _figma: FigmaConnectAPI<JSX.Element> & {
|
|
|
81
82
|
* ```
|
|
82
83
|
*/
|
|
83
84
|
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
85
|
};
|
|
91
86
|
export { _figma as figma, _client as client };
|
|
92
87
|
export default _figma;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index_react.d.ts","sourceRoot":"","sources":["../../src/react/index_react.ts"],"names":[],"mappings":";AAMA,OAAO,EAAE,SAAS,EAAE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E,CAAC,GAAG,CAAC,CAAA;CACnC,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"}
|
|
@@ -1 +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;
|
|
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;AAGnD,MAAM,OAAO,GAAuB,IAAA,wBAAS,GAAE,CAAA;AAwFV,yBAAM;AAvF3C,MAAM,MAAM,GAqFR,KAAK,CAAA;AAEU,uBAAK;AACxB,kBAAe,MAAM,CAAA"}
|
package/dist/react/parser.js
CHANGED
|
@@ -731,7 +731,7 @@ function getDefaultTemplate(componentMetadata) {
|
|
|
731
731
|
exports.getDefaultTemplate = getDefaultTemplate;
|
|
732
732
|
async function parseReactDoc(node, parserContext, { repoUrl, silent }) {
|
|
733
733
|
const { checker, sourceFile, config } = parserContext;
|
|
734
|
-
// Parse the arguments to the `
|
|
734
|
+
// Parse the arguments to the `figma.connect()` call
|
|
735
735
|
const { componentArg, figmaNodeUrlArg, configObjArg } = parseFigmaConnectArgs(node, parserContext);
|
|
736
736
|
const { propsArg, exampleArg, variantArg, linksArg, importsArg } = parseConfigObjectArg(configObjArg, parserContext);
|
|
737
737
|
let figmaNode = (0, compiler_1.stripQuotesFromNode)(figmaNodeUrlArg);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FigmaConnectMeta } from '../connect/api';
|
|
3
|
+
export type ReactMeta<P> = FigmaConnectMeta<P, React.Component | JSX.Element> & {
|
|
4
|
+
/**
|
|
5
|
+
* A list of import statements that will render in the Code Snippet in Figma.
|
|
6
|
+
* This overrides the auto-generated imports for the component. When this is specified,
|
|
7
|
+
* the `importPaths` option in the config file is also ignored.
|
|
8
|
+
*/
|
|
9
|
+
imports?: string[];
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/react/types.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG;IAC9E;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;CACnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/react/types.ts"],"names":[],"mappings":""}
|
|
@@ -10,7 +10,7 @@ import { FigmaConnectMeta } from '../connect/api';
|
|
|
10
10
|
* } satisfies StoryParameters,
|
|
11
11
|
* }
|
|
12
12
|
*/
|
|
13
|
-
export type StoryParameters<T
|
|
13
|
+
export type StoryParameters<T> = {
|
|
14
14
|
design: {
|
|
15
15
|
type: 'figma';
|
|
16
16
|
/**
|
|
@@ -24,7 +24,7 @@ export type StoryParameters<T = {}> = {
|
|
|
24
24
|
examples?: (FigmaConnectMeta<T>['example'] | string | ExampleObject<T>)[];
|
|
25
25
|
} & Pick<FigmaConnectMeta, 'props' | 'links'>;
|
|
26
26
|
};
|
|
27
|
-
type ExampleObject<T> = FigmaConnectMeta<T, string> & {
|
|
27
|
+
type ExampleObject<T> = FigmaConnectMeta<T, unknown, string> & {
|
|
28
28
|
variant?: FigmaConnectMeta['variant'];
|
|
29
29
|
links?: FigmaConnectMeta['links'];
|
|
30
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/storybook/external.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../src/storybook/external.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI;IAC/B,MAAM,EAAE;QACN,IAAI,EAAE,OAAO,CAAA;QACb;;WAEG;QACH,GAAG,EAAE,MAAM,CAAA;QACX;;;WAGG;QACH,QAAQ,CAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;KAC1E,GAAG,IAAI,CAAC,gBAAgB,EAAE,OAAO,GAAG,OAAO,CAAC,CAAA;CAC9C,CAAA;AAED,KAAK,aAAa,CAAC,CAAC,IAAI,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,GAAG;IAC7D,OAAO,CAAC,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAA;IACrC,KAAK,CAAC,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAA;CAClC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@figma/code-connect",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "A tool for connecting your design system components in code with your design system in Figma",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Figma",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
|
38
38
|
"dev": "tsx src/cli.ts",
|
|
39
|
-
"build": "tsc",
|
|
39
|
+
"build": "rm -rf dist && npm run typecheck && tsc",
|
|
40
40
|
"build:web": "pnpm build",
|
|
41
41
|
"build:webpack": "webpack --mode production",
|
|
42
42
|
"test": "npm run test:no-coverage -- --coverage",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"bundle:cli:mac:arm64": "npm run bundle:cli -- -o bundle-cli/figma-mac-arm64 --target node18-mac-arm64",
|
|
58
58
|
"bundle:cli:win": "npm run bundle:cli -- -o bundle-cli/figma-win --target node18-win-x64",
|
|
59
59
|
"publish:npm": "npm install && npm run build && npm run bundle:npm-readme:prepare && npm publish --access public; npm run bundle:npm-readme:restore",
|
|
60
|
-
"typecheck": "tsc --noEmit"
|
|
60
|
+
"typecheck": "tsc --noEmit -p tsconfig-typecheck.json"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/cross-spawn": "^6.0.6",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoConfigObject.figma.d.ts","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/NoConfigObject.figma.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const index_html_1 = __importDefault(require("../../../index_html"));
|
|
7
|
-
// @ts-expect-error
|
|
8
|
-
index_html_1.default.connect('');
|
|
9
|
-
//# sourceMappingURL=NoConfigObject.figma.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoConfigObject.figma.js","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/NoConfigObject.figma.ts"],"names":[],"mappings":";;;;;AAAA,qEAAiD;AAEjD,mBAAmB;AACnB,oBAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoExample.figma.d.ts","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/NoExample.figma.ts"],"names":[],"mappings":""}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const index_html_1 = __importDefault(require("../../../index_html"));
|
|
7
|
-
// @ts-expect-error
|
|
8
|
-
index_html_1.default.connect('', {});
|
|
9
|
-
//# sourceMappingURL=NoExample.figma.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoExample.figma.js","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/NoExample.figma.ts"],"names":[],"mappings":";;;;;AAAA,qEAAiD;AAEjD,mBAAmB;AACnB,oBAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA"}
|
package/dist/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RegularFunctionExampleWithExtraCode.figma.d.ts","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.ts"],"names":[],"mappings":""}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
const index_html_1 = __importStar(require("../../../index_html"));
|
|
27
|
-
index_html_1.default.connect('', {
|
|
28
|
-
example: () => {
|
|
29
|
-
const x = 1;
|
|
30
|
-
return (0, index_html_1.html) `<div></div>`;
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
//# sourceMappingURL=RegularFunctionExampleWithExtraCode.figma.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RegularFunctionExampleWithExtraCode.figma.js","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/RegularFunctionExampleWithExtraCode.figma.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAAiD;AAEjD,oBAAK,CAAC,OAAO,CAAC,EAAE,EAAE;IAChB,OAAO,EAAE,GAAG,EAAE;QACZ,MAAM,CAAC,GAAG,CAAC,CAAA;QACX,OAAO,IAAA,iBAAI,EAAA,aAAa,CAAA;IAC1B,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrongSignatureJsx.figma.d.ts","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/WrongSignatureJsx.figma.tsx"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const index_html_1 = __importDefault(require("../../../index_html"));
|
|
7
|
-
index_html_1.default.connect('', {
|
|
8
|
-
props: {
|
|
9
|
-
visible: index_html_1.default.boolean('Visible'),
|
|
10
|
-
label: index_html_1.default.string('Label'),
|
|
11
|
-
},
|
|
12
|
-
// @ts-expect-error
|
|
13
|
-
example: (props) => React.createElement("div", null),
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=WrongSignatureJsx.figma.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrongSignatureJsx.figma.js","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/WrongSignatureJsx.figma.tsx"],"names":[],"mappings":";;;;;AAAA,qEAAiD;AAEjD,oBAAK,CAAC,OAAO,CAAC,EAAE,EAAE;IAChB,KAAK,EAAE;QACL,OAAO,EAAE,oBAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QACjC,KAAK,EAAE,oBAAK,CAAC,MAAM,CAAC,OAAO,CAAC;KAC7B;IACD,mBAAmB;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,gCAAO;CAC5B,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrongSignatureNoHtmlTag.figma.d.ts","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const index_html_1 = __importDefault(require("../../../index_html"));
|
|
7
|
-
index_html_1.default.connect('', {
|
|
8
|
-
props: {
|
|
9
|
-
visible: index_html_1.default.boolean('Visible'),
|
|
10
|
-
label: index_html_1.default.string('Label'),
|
|
11
|
-
},
|
|
12
|
-
// @ts-expect-error
|
|
13
|
-
example: (props) => `<my-component visible=${props.visible}>${props.label}</my-component>`,
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=WrongSignatureNoHtmlTag.figma.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"WrongSignatureNoHtmlTag.figma.js","sourceRoot":"","sources":["../../../../../src/html/__test__/parser/examples/WrongSignatureNoHtmlTag.figma.ts"],"names":[],"mappings":";;;;;AAAA,qEAAiD;AAEjD,oBAAK,CAAC,OAAO,CAAC,EAAE,EAAE;IAChB,KAAK,EAAE;QACL,OAAO,EAAE,oBAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QACjC,KAAK,EAAE,oBAAK,CAAC,MAAM,CAAC,OAAO,CAAC;KAC7B;IACD,mBAAmB;IACnB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,yBAAyB,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,KAAK,iBAAiB;CAC3F,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.test.d.ts","sourceRoot":"","sources":["../../../../src/html/__test__/parser/parser.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const parser_common_1 = require("../../../connect/parser_common");
|
|
9
|
-
const parser_1 = require("../../parser");
|
|
10
|
-
async function testParse(file, extraFiles = [], config) {
|
|
11
|
-
const program = typescript_1.default.createProgram([
|
|
12
|
-
path_1.default.join(__dirname, 'examples', file),
|
|
13
|
-
...extraFiles.map((file) => path_1.default.join(__dirname, file)),
|
|
14
|
-
], {});
|
|
15
|
-
return await (0, parser_common_1.parseCodeConnect)({
|
|
16
|
-
program,
|
|
17
|
-
file: path_1.default.join(__dirname, 'examples', file),
|
|
18
|
-
config: { ...config, parser: 'html' },
|
|
19
|
-
parseFn: parser_1.parseHtmlDoc,
|
|
20
|
-
absPath: __dirname,
|
|
21
|
-
parseOptions: {
|
|
22
|
-
repoUrl: 'git@github.com:figma/code-connect.git',
|
|
23
|
-
debug: false,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
describe('HTML Parser', () => {
|
|
28
|
-
it('throws an error if there is no config object', async () => {
|
|
29
|
-
expect(async () => await testParse('NoConfigObject.figma.ts')).rejects.toThrow(`The second argument to figma.connect() must be an object literal. Example usage:
|
|
30
|
-
\`figma.connect('https://www.figma.com/file/123?node-id=1-1', {
|
|
31
|
-
example: () => html\`<button />\`
|
|
32
|
-
})\``);
|
|
33
|
-
});
|
|
34
|
-
it('throws an error if there is no example', async () => {
|
|
35
|
-
expect(async () => await testParse('NoExample.figma.ts')).rejects.toThrow(`The 'example' property must be an arrow function which returns a html tagged template string. Example usage:
|
|
36
|
-
\`figma.connect('https://www.figma.com/file/123?node-id=1-1', {
|
|
37
|
-
example: (props) => html\`<my-button />\`
|
|
38
|
-
})\``);
|
|
39
|
-
});
|
|
40
|
-
it('throws an error if the example function returns a plain tagged template', async () => {
|
|
41
|
-
expect(async () => await testParse('WrongSignatureNoHtmlTag.figma.ts')).rejects.toThrow('Expected only a tagged template literal as the body of the render function');
|
|
42
|
-
});
|
|
43
|
-
it('throws an error if the example function returns JSX', async () => {
|
|
44
|
-
expect(async () => await testParse('WrongSignatureJsx.figma.tsx')).rejects.toThrow('Expected only a tagged template literal as the body of the render function');
|
|
45
|
-
});
|
|
46
|
-
it('throws an error if the example function is a regular function with extra code', async () => {
|
|
47
|
-
expect(async () => await testParse('RegularFunctionExampleWithExtraCode.figma.ts')).rejects.toThrow('Expected only a tagged template literal as the body of the render function');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=parser.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.test.js","sourceRoot":"","sources":["../../../../src/html/__test__/parser/parser.test.ts"],"names":[],"mappings":";;;;;AACA,4DAA2B;AAC3B,gDAAuB;AACvB,kEAAiE;AACjE,yCAA2C;AAE3C,KAAK,UAAU,SAAS,CACtB,IAAY,EACZ,aAAuB,EAAE,EACzB,MAA8C;IAE9C,MAAM,OAAO,GAAG,oBAAE,CAAC,aAAa,CAC9B;QACE,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC;QACtC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;KACxD,EACD,EAAE,CACH,CAAA;IACD,OAAO,MAAM,IAAA,gCAAgB,EAAC;QAC5B,OAAO;QACP,IAAI,EAAE,cAAI,CAA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