@figma/code-connect 1.5.1 → 1.5.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/commands/connect.d.ts +1 -0
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +6 -1
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/preview_collapse.d.ts +7 -0
- package/dist/commands/preview_collapse.d.ts.map +1 -0
- package/dist/commands/preview_collapse.js +31 -0
- package/dist/commands/preview_collapse.js.map +1 -0
- package/dist/commands/preview_utils.d.ts +9 -0
- package/dist/commands/preview_utils.d.ts.map +1 -1
- package/dist/commands/preview_utils.js +26 -7
- package/dist/commands/preview_utils.js.map +1 -1
- package/dist/connect/raw_templates.d.ts.map +1 -1
- package/dist/connect/raw_templates.js +19 -15
- package/dist/connect/raw_templates.js.map +1 -1
- package/dist/react/parser.d.ts.map +1 -1
- package/dist/react/parser.js +6 -9
- package/dist/react/parser.js.map +1 -1
- package/figma-types-no-require.d.ts +1 -0
- package/figma-types.d.ts +1 -0
- package/package.json +1 -1
package/dist/react/parser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/react/parser.ts"],"names":[],"mappings":";;;;;AA0CA,wCAQC;AAiED,sDAaC;AAsFD,wDA+GC;AAYD,sEA6LC;AAYD,wDA8CC;AAMD,4DAoEC;AAED,0DA+BC;AA+LD,gDAKC;AAED,sCAiIC;AA1/BD,4DAA2B;AAC3B,gDAM2B;AAC3B,8EAA2E;AAC3E,+CAA0C;AAC1C,qDAO+B;AAC/B,gDAAkE;AAClE,sDAA0F;AAE1F,uEAA0E;AAC1E,4DAaiC;AAEjC;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,IAAa;IAEb,IAAI,oBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,oBAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,oBAAE,CAAC,uB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S,EAAE,QAAQ,EAAE,SAAS;QAC9B,MAAM,EAAE,QAAQ,EAAE,MAAM;YACtB,CAAC,CAAC,IAAA,0BAAgB,EAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC;YACjF,CAAC,CAAC,EAAE;QACN,cAAc,EAAE,QAAQ,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QACrF,OAAO;QACP,QAAQ;QACR,YAAY,EAAE;YACZ,qEAAqE;YACrE,uDAAuD;YACvD,KAAK;YACL,OAAO,EAAE,aAAa;YACtB,wEAAwE;YACxE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;SAC1C;QACD,KAAK;QACL,QAAQ,EAAE;YACR,UAAU,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO;SAClD;KACF,CAAA;AACH,CAAC","sourcesContent":["import ts from 'typescript'\nimport {\n CodeConnectParser,\n DEFAULT_LABEL_PER_PARSER,\n getRemoteFileUrl,\n mapImportPath,\n mapImportSpecifier,\n} from '../connect/project'\nimport { SyntaxHighlightLanguage } from '../connect/label_language_mapping'\nimport { logger } from '../common/logging'\nimport {\n bfsFindNode,\n getTagName,\n stripQuotesFromNode,\n parsePropertyOfType,\n parseFunctionArgument,\n isOneOf,\n} from '../typescript/compiler'\nimport { applyDocumentUrlSubstitutions } from '../connect/helpers'\nimport { FIGMA_CONNECT_CALL, PropMappings, parsePropsObject } from '../connect/intrinsics'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { getParsedTemplateHelpersString } from './parser_template_helpers'\nimport {\n getPositionInSourceFile,\n InternalError,\n makeCreatePropPlaceholder,\n ParserContext,\n ParserError,\n visitPropReferencingNode,\n getReferencedPropsForTemplate,\n findDescendants,\n parseLinks,\n parseVariant,\n parseImports,\n ParseOptions,\n} from '../connect/parser_common'\n\n/**\n * Traverses the AST and returns the first JSX element it finds\n * @param node AST node\n * @returns\n */\nexport function findJSXElement(\n node: ts.Node,\n): ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment | undefined {\n if (ts.isJsxElement(node) || ts.isJsxFragment(node) || ts.isJsxSelfClosingElement(node)) {\n return node\n } else {\n return ts.forEachChild(node, findJSXElement)\n }\n}\n\nfunction findBlock(node: ts.Node): ts.Block | undefined {\n if (ts.isBlock(node)) {\n return node\n } else {\n return ts.forEachChild(node, findBlock)\n }\n}\n\n/**\n * Walks up the AST from an assignment to find the import declaration\n */\nfunction findParentImportDeclaration(\n declaration: ts.Declaration,\n): ts.ImportDeclaration | undefined {\n let current = declaration\n while (current) {\n if (ts.isImportDeclaration(current)) {\n return current\n }\n current = current.parent as ts.Declaration\n }\n}\n\nfunction getImportsOfModule(sourceFile: ts.SourceFile): ts.ImportDeclaration[] {\n const imports: ts.ImportDeclaration[] = []\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node)) {\n imports.push(node)\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n return imports\n}\n\nfunction resolveModuleSpecifier(\n program: ts.Program,\n sourceFile: ts.SourceFile,\n importSpecifier: string,\n): string | undefined {\n const compilerHost = ts.createCompilerHost(program.getCompilerOptions())\n const moduleResolutionHost: ts.ModuleResolutionHost = {\n fileExists: compilerHost.fileExists,\n readFile: compilerHost.readFile,\n directoryExists: compilerHost.directoryExists,\n getCurrentDirectory: compilerHost.getCurrentDirectory,\n getDirectories: compilerHost.getDirectories,\n }\n\n const resolvedModule = ts.resolveModuleName(\n importSpecifier,\n sourceFile.fileName,\n program.getCompilerOptions(),\n moduleResolutionHost,\n )\n\n return resolvedModule.resolvedModule?.resolvedFileName\n}\n\n// Traverse the source file and resolve imports\nexport function findAndResolveImports(program: ts.Program, sourceFile: ts.SourceFile) {\n const importSpecifierToFilePath: Record<string, string> = {}\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isImportDeclaration(node)) {\n const importSpecifier = (node.moduleSpecifier as ts.StringLiteral).text\n const resolvedFileName = resolveModuleSpecifier(program, sourceFile, importSpecifier)\n\n if (resolvedFileName) {\n importSpecifierToFilePath[importSpecifier] = resolvedFileName\n }\n }\n })\n return importSpecifierToFilePath\n}\n\n/**\n * Finds all import statements in a file that matches the given identifiers\n *\n * @param parserContext Parser context\n * @param identifiers List of identifiers to find imports for\n * @returns\n */\nfunction getSourceFilesOfImportedIdentifiers(parserContext: ParserContext, _identifiers: string[]) {\n const { sourceFile, resolvedImports } = parserContext\n const importDeclarations = getImportsOfModule(sourceFile)\n const imports: {\n statement: string\n file: string\n moduleSpecifier: string\n }[] = []\n\n const identifiers = _identifiers.map((identifier) => identifier.split('.')[0])\n\n for (const declaration of importDeclarations) {\n let statement = declaration.getText()\n // remove the quotation marks around the module specifier\n const moduleSpecifier = declaration.moduleSpecifier.getText().slice(1, -1)\n\n if (declaration.importClause) {\n // Default imports\n if (declaration.importClause.name) {\n const identifier = declaration.importClause.name.text\n\n if (identifiers.includes(identifier)) {\n imports.push({\n statement,\n file: resolvedImports[moduleSpecifier],\n moduleSpecifier,\n })\n }\n }\n\n if (declaration.importClause.namedBindings) {\n const namedBindings = declaration.importClause.namedBindings\n\n if (ts.isNamedImports(namedBindings)) {\n // Named imports (import { x, y } from 'module')\n // filter out any unused imports from the statement the identifier belongs to\n const elements = namedBindings.elements\n .map((specifier) => specifier.name.text)\n .filter((name) => identifiers.includes(name))\n\n if (elements.length > 0) {\n imports.push({\n statement: statement.replace(/{.*}/s, `{ ${elements.join(', ')} }`),\n file: resolvedImports[moduleSpecifier],\n moduleSpecifier,\n })\n }\n } else if (ts.isNamespaceImport(namedBindings)) {\n // Namespace import (import * as name from 'module')\n const identifier = namedBindings.name.text\n if (identifiers.includes(identifier)) {\n imports.push({\n statement,\n file: resolvedImports[moduleSpecifier],\n moduleSpecifier,\n })\n }\n }\n }\n }\n }\n\n return imports\n}\n\nexport type ComponentTypeSignature = Record<string, string>\n\n/**\n * Extract metadata about the referenced React component. Used by both the\n * Code Connect and Storybook commands.\n *\n * @param parserContext Parser context\n * @param componentSymbol The ts.Symbol from the metadata referencing the\n * component being documented\n * @param node The node being parsed. Used for error logging.\n * @returns Metadata object\n */\nexport async function parseComponentMetadata(\n node: ts.PropertyAccessExpression | ts.Identifier | ts.Expression,\n parserContext: ParserContext,\n silent?: boolean,\n) {\n const { checker, sourceFile } = parserContext\n let componentSymbol = checker.getSymbolAtLocation(node)\n let componentSourceFile = sourceFile\n let component = ''\n let componentDeclaration\n\n // Hacky fix for namespaced components, this probably doesn't work for storybook\n if (ts.isPropertyAccessExpression(node)) {\n componentSymbol = checker.getSymbolAtLocation(node.expression)\n if (!componentSymbol) {\n throw new ParserError(`Could not find symbol for component ${node.expression.getText()}`, {\n sourceFile,\n node,\n })\n }\n }\n\n // Component declared in a different file\n if (\n componentSymbol &&\n componentSymbol.declarations &&\n (ts.isImportSpecifier(componentSymbol.declarations[0]) ||\n ts.isImportClause(componentSymbol.declarations[0]))\n ) {\n let importDeclaration = findParentImportDeclaration(componentSymbol.declarations[0])\n if (!importDeclaration) {\n throw new ParserError(\n 'No import statement found for component, make sure the component is imported',\n {\n sourceFile,\n node,\n },\n )\n }\n\n // The component should be imported from another file, we need to follow the\n // aliased symbol to get the correct function definition\n if (componentSymbol.flags & ts.SymbolFlags.Alias) {\n componentSymbol = checker.getAliasedSymbol(componentSymbol)\n }\n\n if (!componentSymbol || !componentSymbol.declarations) {\n if (!silent) {\n logger.warn(\n `Import for ${node.getText()} could not be resolved, make sure that your \\`include\\` globs in \\`figma.config.json\\` matches the component source file (in addition to the Code Connect file). If you're using path aliases, make sure to include the same aliases in \\`figma.config.json\\` with the \\`paths\\` option.`,\n )\n }\n return {\n source: '',\n line: 0,\n component: node.getText(),\n }\n }\n\n // If we haven't found the component declaration by now, it's likely because it's\n // assigned to an object/namespace, for example: `export const Button = { Primary: () => <button /> }`,\n // so we need to find the function declaration by traversing the AST in that file.\n if (!ts.isFunctionDeclaration(componentSymbol.declarations[0])) {\n const sourceFile = componentSymbol.declarations[0].getSourceFile()\n bfsFindNode(sourceFile, sourceFile, (node) => {\n if (\n (ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node)) &&\n node.name &&\n componentSymbol?.name &&\n node.name.getText() === componentSymbol.name\n ) {\n componentSymbol = checker.getSymbolAtLocation(node.name)\n return true\n }\n return false\n })\n }\n\n componentDeclaration = componentSymbol.declarations[0]\n componentSourceFile = componentDeclaration.getSourceFile()\n } else {\n componentDeclaration = componentSymbol?.declarations?.[0]\n }\n\n const source = componentSourceFile.fileName\n\n if (!source) {\n throw new InternalError(\n `Could not find source file for component ${component} - is this file included in the directory passed to \\`figma connect <dir>\\`?`,\n )\n }\n\n if (!componentDeclaration) {\n throw new ParserError(`Could not find declaration for component ${component}`, {\n sourceFile,\n node,\n })\n }\n\n const line = getPositionInSourceFile(componentDeclaration, componentSourceFile).line\n if (line === undefined) {\n throw new InternalError(\n `Could not determine line number for component ${componentDeclaration.getStart(sourceFile)}`,\n )\n }\n\n return {\n source,\n line,\n component: node.getText(),\n }\n}\n\n/**\n * Parses a render function and ouputs a template string, extracting the code and\n * any import statements matching the JSX elements used in the function body\n *\n * @param exp A function or arrow function expression\n * @param parserContext Parser context\n * @param propMappings Prop mappings object as returned by parseProps\n *\n * @returns The code of the render function and a list of imports\n */\nexport function parseRenderFunctionExpression(\n exp: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n parserContext: ParserContext,\n propMappings?: PropMappings,\n) {\n const { sourceFile } = parserContext\n\n let renderFunctionCode: string\n\n if (exp.parameters.length > 1) {\n throw new ParserError(\n `Expected a single props parameter for the render function, got ${exp.parameters.length} parameters`,\n { sourceFile, node: exp },\n )\n }\n\n const propsParameter = exp.parameters[0]\n\n // Keep track of any props which are referenced in the example\n const referencedProps = new Set<string>()\n\n const createPropPlaceholder = makeCreatePropPlaceholder({\n propMappings,\n referencedProps,\n sourceFile,\n })\n\n // Find all property access expressions in the function body and replace them\n // with a function call like `__PROP__(\"propName\")`, so that we can easily\n // find them in the next step to convert them into\n // `${_fcc_renderReactProp(...)` in the template string.\n //\n // Doing it this way means we can normalize the different ways in which props\n // can be accessed using the compiler API, which is much easier than using a\n // regex, then in the next step we can use a simple regex to convert that into\n // the template string.\n if (propsParameter) {\n exp = ts.transform(exp, [\n (context) => (rootNode) => {\n function visit(node: ts.Node): ts.Node {\n const visitResult = visitPropReferencingNode({\n propsParameter,\n node,\n createPropPlaceholder,\n useJsx: true,\n })\n\n if (visitResult) {\n return visitResult\n }\n\n // object assignment using destructured reference, e.g `prop={{ key: value }}`\n // (`{{ key: props.value }}` syntax will be captured by the `props.` notation branch above)\n if (\n ts.isObjectBindingPattern(propsParameter.name) &&\n ts.isPropertyAssignment(node) &&\n ts.isIdentifier(node.initializer) &&\n propsParameter.name.elements.find((el) =>\n node.initializer.getText().startsWith(el.name.getText()),\n )\n ) {\n return ts.factory.createPropertyAssignment(\n node.name,\n createPropPlaceholder({ name: node.initializer.getText(), node }),\n )\n }\n // object assignment using destructured reference as a shorthand, e.g `prop={{ value }}`\n if (\n ts.isObjectBindingPattern(propsParameter.name) &&\n ts.isShorthandPropertyAssignment(node) &&\n propsParameter.name.elements.find((el) =>\n node.name.getText().startsWith(el.name.getText()),\n )\n ) {\n return ts.factory.createPropertyAssignment(\n node.name,\n createPropPlaceholder({ name: node.name.getText(), node }),\n )\n }\n\n // Replaces {...props} with all the prop mapped props we know about,\n // e.g. <Button {...props} /> becomes:\n // <Button prop1={__PROP__(\"prop1\")} prop2={__PROP__(\"prop2\")} />.\n if (\n ts.isJsxSpreadAttribute(node) &&\n ts.isIdentifier(node.expression) &&\n // example: (props) => (...)\n (node.expression.getText() === propsParameter.name.getText() ||\n // example: ({ prop1, prop2 ...props }) => (...)\n (ts.isObjectBindingPattern(propsParameter.name) &&\n propsParameter.name.elements.find(\n (el) => el.dotDotDotToken && el.name.getText() === node.expression?.getText(),\n )))\n ) {\n // if we have an object binding pattern ({ prop1, prop2 ...props }),\n // exclude the props that are already destructured (prop1, prop2)\n const propsToExclude = ts.isObjectBindingPattern(propsParameter.name)\n ? propsParameter.name.elements\n .filter((el) => !el.dotDotDotToken)\n .map((el) => el.name.getText())\n : []\n const props = propMappings\n ? Object.keys(propMappings)\n .filter((prop) => !propsToExclude.includes(prop))\n .map((prop) => {\n return ts.factory.createJsxAttribute(\n ts.factory.createIdentifier(prop),\n createPropPlaceholder({\n name: prop,\n node,\n wrapInJsxExpression: true,\n }) as ts.JsxExpression,\n )\n })\n : []\n\n if (propMappings) {\n for (const key of Object.keys(propMappings)) {\n referencedProps.add(key)\n }\n }\n\n return props as any\n }\n\n return ts.visitEachChild(node, visit, context)\n }\n return ts.visitNode(rootNode, visit) as\n ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration\n },\n ]).transformed[0] as typeof exp\n }\n\n const printer = ts.createPrinter()\n const block = findBlock(exp)\n let nestable = false\n let jsx = findJSXElement(exp)\n\n if (jsx && (!block || (block && block.statements.length <= 1))) {\n // The function body is a single JSX element\n renderFunctionCode = printer.printNode(ts.EmitHint.Unspecified, jsx, sourceFile)\n nestable = true\n } else if (block) {\n // The function body has more stuff in it, so we wrap the body in a function\n // expression. Why not just print the exact function passed to `render`?\n // Because the parameters to that function are not actually referenced in\n // the rendered code snippet in Figma - they're mapped to values on the\n // Figma instance.\n const functionName = 'Example'\n const functionExpression = ts.factory.createFunctionExpression(\n undefined,\n undefined,\n ts.factory.createIdentifier(functionName),\n [],\n undefined,\n undefined,\n block,\n )\n const printer = ts.createPrinter()\n renderFunctionCode = printer.printNode(ts.EmitHint.Unspecified, functionExpression, sourceFile)\n } else {\n throw new ParserError(\n `Expected a single JSX element or a block statement in the render function, got ${exp.getText()}`,\n { sourceFile, node: exp },\n )\n }\n\n renderFunctionCode = replacePropPlaceholders(renderFunctionCode)\n\n // Escape backticks from the example code, as otherwise those would terminate the `figma.tsx` template literal\n renderFunctionCode = renderFunctionCode.replace(/`/g, '\\\\`')\n\n // Finally, output the render function as a figma.tsx call\n const figmaTsxCall = `figma.tsx\\`${renderFunctionCode}\\``\n\n // Find all JSX elements in the function body and extract their import\n // statements\n const jsxTags = findDescendants(\n exp,\n (element) => ts.isJsxElement(element) || ts.isJsxSelfClosingElement(element),\n ) as (ts.JsxElement | ts.JsxSelfClosingElement)[]\n const imports = getSourceFilesOfImportedIdentifiers(parserContext, jsxTags.map(getTagName))\n\n return {\n code: figmaTsxCall,\n imports,\n nestable,\n referencedProps,\n }\n}\n\n/**\n * Parses the render function passed to `figma.connect()`, extracting the code and\n * any import statements matching the JSX elements used in the function body\n *\n * @param exp A function or arrow function expression\n * @param parserContext Parser context\n * @param propMappings Prop mappings object as returned by parseProps\n *\n * @returns The code of the render function and a list of imports\n */\nexport function parseJSXRenderFunction(\n exp: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n parserContext: ParserContext,\n propMappings?: PropMappings,\n isForMigration?: boolean,\n) {\n const { sourceFile } = parserContext\n\n const { code, imports, nestable, referencedProps } = parseRenderFunctionExpression(\n exp,\n parserContext,\n propMappings,\n )\n\n let templateCode = ''\n\n // Generate the template code\n // Inject React-specific template helper functions\n if (!isForMigration) {\n templateCode = getParsedTemplateHelpersString() + '\\n\\n'\n }\n\n // Require the template API\n templateCode += `const figma = require('figma')\\n\\n`\n\n // Then we output `const propName = figma.properties.<kind>('propName')` calls\n // for each referenced prop, so these are accessible to the template code.\n templateCode += getReferencedPropsForTemplate({\n propMappings,\n exp,\n sourceFile,\n isForMigration,\n })\n\n const includeMetadata = propMappings && Object.keys(propMappings).length > 0\n\n // Finally, output the example code\n templateCode += includeMetadata\n ? `export default { ...${code}, metadata: { __props } }\\n`\n : `export default ${code}\\n`\n\n return {\n code: templateCode,\n imports,\n nestable,\n }\n}\n\n/**\n * Parses the render function for a value (i.e. example which returns a string or React\n * component reference, not JSX) passed to `figma.connect()`\n */\nexport function parseValueRenderFunction(\n exp: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n parserContext: ParserContext,\n propMappings?: PropMappings,\n isForMigration?: boolean,\n) {\n const { sourceFile } = parserContext\n const printer = ts.createPrinter()\n if (!exp.body) {\n throw new ParserError('Expected a function body', {\n sourceFile: parserContext.sourceFile,\n node: exp,\n })\n }\n\n let exampleCode = printer.printNode(ts.EmitHint.Unspecified, exp.body, sourceFile)\n const nestable = true\n\n let templateCode = ''\n // Generate the template code\n // Inject React-specific template helper functions\n if (!isForMigration) {\n templateCode = getParsedTemplateHelpersString() + '\\n\\n'\n }\n\n // Require the template API\n templateCode += `const figma = require('figma')\\n\\n`\n\n // Then we output `const propName = figma.properties.<kind>('propName')` calls\n // for each referenced prop, so these are accessible to the template code.\n templateCode += getReferencedPropsForTemplate({\n propMappings,\n exp,\n sourceFile,\n isForMigration,\n })\n\n // Escape backticks from the example code\n exampleCode = exampleCode.replace(/`/g, '\\\\`')\n\n let imports: {\n statement: string\n file: string\n moduleSpecifier: string\n }[] = []\n\n const includeMetadata = propMappings && Object.keys(propMappings).length > 0\n\n if (ts.isStringLiteral(exp.body)) {\n // The value is a string, which is already wrapped in quotes\n templateCode += includeMetadata\n ? `export default { ...figma.value(${exampleCode}), metadata: { __props } }\\n`\n : `export default figma.value(${exampleCode})\\n`\n } else if (ts.isIdentifier(exp.body)) {\n // The value is an identifier, i.e. a React component reference\n const value = `_fcc_reactComponent(\"${exp.body.getText()}\")`\n const preview = `_fcc_renderPropValue(${value})`\n templateCode += includeMetadata\n ? `export default { ...figma.value(${value}, ${preview}), metadata: { __props } }\\n`\n : `export default figma.value(${value}, ${preview})\\n`\n imports = getSourceFilesOfImportedIdentifiers(parserContext, [exp.body.getText()])\n }\n\n return {\n code: templateCode,\n imports,\n nestable,\n }\n}\n\nexport function replacePropPlaceholders(exampleCode: string) {\n // Replace React prop placeholders we inserted above (like\n // `reactPropName={__PROP__(\"figmaPropName\")}`) with calls to\n // _fcc_renderReactProp, which renders them correctly (see\n // parser_template_helpers.ts)\n exampleCode = exampleCode.replace(\n // match \" reactPropName={__PROP__(\"figmaPropName\")}\" and extract the names\n // We allow hyphens in prop names (unlike React) to support rendering HTML attributes\n / ([A-Za-z0-9\\-]+)=\\{__PROP__\\(\"([A-Za-z0-9_\\.]+)\"\\)\\}/g,\n (_match, reactPropName, figmaPropName) => {\n return `\\${_fcc_renderReactProp('${reactPropName}', ${figmaPropName})}`\n },\n )\n\n // Replace React children placeholders like `${__PROP__(\"propName\")}` with\n // calls to _fcc_renderReactChildren, which renders them correctly (see\n // parser_template_helpers.ts)\n exampleCode = exampleCode.replace(\n /\\{__PROP__\\(\"([A-Za-z0-9_\\.]+)\"\\)\\}/g,\n (_match, figmaPropName) => {\n return `\\${_fcc_renderReactChildren(${figmaPropName})}`\n },\n )\n\n // Assume any remaining placeholders are values, e.g.\n // - { prop: __PROP__(\"propName\") }\n // - useState(__PROP__(\"propName\"))\n // These never need special treatment based on their type.\n return exampleCode.replace(/__PROP__\\(\"([A-Za-z0-9_\\.]+)\"\\)/g, (_match, figmaPropName) => {\n return `\\${_fcc_renderPropValue(${figmaPropName})}`\n })\n}\n\nfunction followIdentifierToStringLiteralDeclaration(\n node: ts.Identifier | ts.StringLiteral,\n parserContext: ParserContext,\n errMessage: string,\n) {\n const { checker } = parserContext\n let result = node\n\n if (node && ts.isIdentifier(node)) {\n const symbol = checker.getSymbolAtLocation(node)\n if (symbol) {\n const decl = symbol.valueDeclaration\n if (\n decl &&\n ts.isVariableDeclaration(decl) &&\n decl.initializer &&\n ts.isStringLiteral(decl.initializer)\n ) {\n result = decl.initializer\n }\n }\n }\n\n // If we followed the identifier to its declaration and it's not a string literal,\n // throw an error\n if (!result || !ts.isStringLiteral(result)) {\n throw new ParserError(errMessage, {\n node: result,\n sourceFile: parserContext.sourceFile,\n })\n }\n\n return result\n}\n\nfunction parseFigmaConnectArgs(node: ts.CallExpression, parserContext: ParserContext) {\n const required = true\n const first = parseFunctionArgument(\n node,\n parserContext,\n 0,\n isOneOf([ts.isIdentifier, ts.isPropertyAccessExpression, ts.isStringLiteral]),\n required,\n `\\`${FIGMA_CONNECT_CALL}\\` must be called with a reference to a Component or a Figma Component URL as the first argument. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1')\\``,\n )!\n\n let figmaNodeUrlArg: ts.StringLiteral\n let componentArg: ts.Identifier | ts.PropertyAccessExpression | undefined\n let configObjArgIndex\n\n // This function has two signatures. If the first arg is a string literal, it's the Figma node URL, and\n // it won't have a component reference.\n if (ts.isStringLiteral(first)) {\n figmaNodeUrlArg = first\n componentArg = undefined\n configObjArgIndex = 1\n } else {\n // If the first argument is not a string literal, it must be a component reference,\n // and the second argument must be the Figma node URL\n componentArg = first\n configObjArgIndex = 2\n\n const invalidTypeErrorMsg = `The second argument to ${FIGMA_CONNECT_CALL}() must be a string literal (the URL of the Figma node). Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1')\\``\n\n let arg = parseFunctionArgument(\n node,\n parserContext,\n 1,\n isOneOf([ts.isIdentifier, ts.isStringLiteral]),\n required,\n invalidTypeErrorMsg,\n )!\n\n figmaNodeUrlArg = followIdentifierToStringLiteralDeclaration(\n arg,\n parserContext,\n invalidTypeErrorMsg,\n )\n }\n\n const configObjArg = parseFunctionArgument(\n node,\n parserContext,\n configObjArgIndex,\n ts.isObjectLiteralExpression,\n false /* not required */,\n `The third argument to ${FIGMA_CONNECT_CALL}() must be an object literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', { render: () => <Button /> })\\``,\n )\n\n return {\n componentArg,\n figmaNodeUrlArg,\n configObjArg,\n }\n}\n\nfunction parseConfigObjectArg(\n configArg: ts.ObjectLiteralExpression | undefined,\n parserContext: ParserContext,\n) {\n if (!configArg) {\n return {\n propsArg: undefined,\n exampleArg: undefined,\n variantArg: undefined,\n importsArg: undefined,\n linksArg: undefined,\n }\n }\n\n const propsArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'props',\n predicate: ts.isObjectLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'props' property must be an object literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n props: {\n disabled: figma.boolean('Disabled'),\n text: figma.string('TextContent'),\n }\n })\\``,\n })\n\n const exampleArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'example',\n predicate: isOneOf([ts.isArrowFunction, ts.isFunctionExpression]),\n parserContext,\n required: false,\n errorMessage: `The 'example' property must be an inline function or arrow function. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n example: () => <Button />\n })\\``,\n })\n\n const variantArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'variant',\n predicate: ts.isObjectLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'variant' property must be an object literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n variant: {\n \"Has Icon\": true\n }\n })\\``,\n })\n\n const linksArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'links',\n predicate: ts.isArrayLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'links' property must be an array literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n links: [\n { name: 'Storybook', url: 'https://storybook.com' }\n ]\n })\\``,\n })\n\n const importsArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'imports',\n predicate: ts.isArrayLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'imports' property must be an array literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n imports: ['import { Button } from \"./Button\"']\n })\\``,\n })\n\n return {\n propsArg,\n exampleArg,\n variantArg,\n linksArg,\n importsArg,\n }\n}\n\nexport function getDefaultTemplate(\n componentMetadata: Awaited<ReturnType<typeof parseComponentMetadata>>,\n) {\n const example = `<${componentMetadata.component} />`\n return `const figma = require(\"figma\")\\n\\nexport default figma.tsx\\`${example}\\``\n}\n\nexport async function parseReactDoc(\n node: ts.CallExpression,\n parserContext: ParserContext,\n { repoUrl, silent, isForMigration }: ParseOptions,\n): Promise<CodeConnectJSON> {\n const { checker, sourceFile, config } = parserContext\n\n // Parse the arguments to the `figma.connect()` call\n const { componentArg, figmaNodeUrlArg, configObjArg } = parseFigmaConnectArgs(node, parserContext)\n\n const { propsArg, exampleArg, variantArg, linksArg, importsArg } = parseConfigObjectArg(\n configObjArg,\n parserContext,\n )\n\n let figmaNode = stripQuotesFromNode(figmaNodeUrlArg)\n // TODO This logic is duplicated in connect.ts transformDocFromParser due to some type issues\n if (config.documentUrlSubstitutions) {\n figmaNode = applyDocumentUrlSubstitutions(figmaNode as string, config.documentUrlSubstitutions)\n }\n const metadata = componentArg\n ? await parseComponentMetadata(componentArg, parserContext, silent)\n : undefined\n\n const props = propsArg ? parsePropsObject(propsArg, parserContext) : undefined\n const render = exampleArg\n ? findJSXElement(exampleArg)\n ? parseJSXRenderFunction(exampleArg, parserContext, props, isForMigration)\n : parseValueRenderFunction(exampleArg, parserContext, props, isForMigration)\n : undefined\n const variant = variantArg ? parseVariant(variantArg, sourceFile, checker) : undefined\n const links = linksArg ? parseLinks(linksArg, parserContext) : undefined\n\n let mappedImports: string[]\n if (importsArg) {\n mappedImports = parseImports(importsArg, parserContext)\n } else {\n // If no template function was provided, construct one and add the import\n // statement for the component\n let imports = render?.imports\n ? render.imports\n : metadata !== undefined\n ? getSourceFilesOfImportedIdentifiers(parserContext, [metadata.component])\n : []\n\n if (imports.length === 0 && metadata?.component) {\n // If no imports were found, it might mean that the component is not imported, or\n // that the `figma.connect` call is in the same file as the component. In the latter\n // case - we'll want to generate one\n const fileName = metadata.source.split('/').pop()?.split('.')[0]\n const relativeImportPath = `./${fileName}`\n imports = [\n {\n statement: `import { ${metadata.component} } from '${relativeImportPath}'`,\n file: sourceFile.fileName,\n moduleSpecifier: relativeImportPath,\n },\n ]\n }\n\n mappedImports = [\n ...new Set(\n imports.map((imp) => {\n if (config) {\n // First try to map the original import specifier directly (preserves user's intent)\n // e.g., '@/AlertTitle' -> '@acme/package/AlertTitle'\n if (typeof imp.moduleSpecifier === 'string') {\n const mappedFromSpecifier = mapImportSpecifier(imp.moduleSpecifier, config)\n if (mappedFromSpecifier) {\n return imp.statement.replace(\n /['\"]([@\\.\\/a-zA-Z0-9_-]*)['\"]/,\n `'${mappedFromSpecifier}'`,\n )\n }\n }\n // Fall back to mapping based on resolved file path (for relative imports)\n const mappedPath = mapImportPath(imp.file, config)\n if (mappedPath) {\n return imp.statement.replace(/['\"]([@\\.\\/a-zA-Z0-9_-]*)['\"]/, `'${mappedPath}'`)\n }\n }\n return imp.statement\n }),\n ),\n ]\n }\n\n if (mappedImports.length === 0 && metadata?.component) {\n logger.warn(\n `The import statement for ${metadata.component} could not be automatically resolved, make sure the component is imported (if not colocating) and that the path mappings are correct in your figma.config.json`,\n )\n }\n\n let template\n if (render?.code) {\n template = render.code\n } else if (metadata) {\n template = getDefaultTemplate(metadata)\n } else {\n throw new ParserError(\n `${FIGMA_CONNECT_CALL}() requires either a component argument or an example function`,\n { sourceFile, node },\n )\n }\n\n return {\n figmaNode,\n label: DEFAULT_LABEL_PER_PARSER.react!,\n language: SyntaxHighlightLanguage.TypeScript,\n component: metadata?.component,\n source: metadata?.source\n ? getRemoteFileUrl(metadata.source, repoUrl, parserContext.config?.defaultBranch)\n : '',\n sourceLocation: metadata?.line !== undefined ? { line: metadata.line } : { line: -1 },\n variant,\n template,\n templateData: {\n // TODO: `props` here is currently only used for validation purposes,\n // we should eventually remove it from the JSON payload\n props,\n imports: mappedImports,\n // If there's no render function, the default example is always nestable\n nestable: render ? render.nestable : true,\n },\n links,\n metadata: {\n cliVersion: require('../../package.json').version,\n },\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../../src/react/parser.ts"],"names":[],"mappings":";;;;;AA0CA,wCAQC;AAyDD,sDAaC;AAsFD,wDA+GC;AAYD,sEAkMC;AAYD,wDA8CC;AAMD,4DAoEC;AAED,0DA+BC;AA+LD,gDAKC;AAED,sCAiIC;AAv/BD,4DAA2B;AAC3B,gDAM2B;AAC3B,8EAA2E;AAC3E,+CAA0C;AAC1C,qDAO+B;AAC/B,gDAAkE;AAClE,sDAA0F;AAE1F,uEAA0E;AAC1E,4DAaiC;AAEjC;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,IAAa;IAEb,IAAI,oBAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,oBAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,oBAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;QACxF,OAAO,IAAI,CAAA;IACb,CAAC;SAAM,CAAC;QACN,OAAO,oBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,cAAc,CAAC,CAAA;IAC9C,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,2BAA2B,CAClC,WAA2B;IAE3B,IAAI,OAAO,GAAG,WAAW,CAAA;IACzB,OAAO,OAAO,EAAE,CAAC;QACf,IAAI,oBAAE,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,CAAC;YACpC,OAAO,OAAO,CAAA;QAChB,CAAC;QACD,OAAO,GAAG,OAAO,CAAC,MAAwB,CAAA;IAC5C,CAAC;AACH,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAyB;IACnD,MAAM,OAAO,GAA2B,EAAE,CAAA;IAE1C,SAAS,KAAK,CAAC,IAAa;QAC1B,IAAI,oBAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CAAC,IAAI,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cesContent":["import ts from 'typescript'\nimport {\n CodeConnectParser,\n DEFAULT_LABEL_PER_PARSER,\n getRemoteFileUrl,\n mapImportPath,\n mapImportSpecifier,\n} from '../connect/project'\nimport { SyntaxHighlightLanguage } from '../connect/label_language_mapping'\nimport { logger } from '../common/logging'\nimport {\n bfsFindNode,\n getTagName,\n stripQuotesFromNode,\n parsePropertyOfType,\n parseFunctionArgument,\n isOneOf,\n} from '../typescript/compiler'\nimport { applyDocumentUrlSubstitutions } from '../connect/helpers'\nimport { FIGMA_CONNECT_CALL, PropMappings, parsePropsObject } from '../connect/intrinsics'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { getParsedTemplateHelpersString } from './parser_template_helpers'\nimport {\n getPositionInSourceFile,\n InternalError,\n makeCreatePropPlaceholder,\n ParserContext,\n ParserError,\n visitPropReferencingNode,\n getReferencedPropsForTemplate,\n findDescendants,\n parseLinks,\n parseVariant,\n parseImports,\n ParseOptions,\n} from '../connect/parser_common'\n\n/**\n * Traverses the AST and returns the first JSX element it finds\n * @param node AST node\n * @returns\n */\nexport function findJSXElement(\n node: ts.Node,\n): ts.JsxElement | ts.JsxSelfClosingElement | ts.JsxFragment | undefined {\n if (ts.isJsxElement(node) || ts.isJsxFragment(node) || ts.isJsxSelfClosingElement(node)) {\n return node\n } else {\n return ts.forEachChild(node, findJSXElement)\n }\n}\n\n/**\n * Walks up the AST from an assignment to find the import declaration\n */\nfunction findParentImportDeclaration(\n declaration: ts.Declaration,\n): ts.ImportDeclaration | undefined {\n let current = declaration\n while (current) {\n if (ts.isImportDeclaration(current)) {\n return current\n }\n current = current.parent as ts.Declaration\n }\n}\n\nfunction getImportsOfModule(sourceFile: ts.SourceFile): ts.ImportDeclaration[] {\n const imports: ts.ImportDeclaration[] = []\n\n function visit(node: ts.Node) {\n if (ts.isImportDeclaration(node)) {\n imports.push(node)\n }\n ts.forEachChild(node, visit)\n }\n\n visit(sourceFile)\n\n return imports\n}\n\nfunction resolveModuleSpecifier(\n program: ts.Program,\n sourceFile: ts.SourceFile,\n importSpecifier: string,\n): string | undefined {\n const compilerHost = ts.createCompilerHost(program.getCompilerOptions())\n const moduleResolutionHost: ts.ModuleResolutionHost = {\n fileExists: compilerHost.fileExists,\n readFile: compilerHost.readFile,\n directoryExists: compilerHost.directoryExists,\n getCurrentDirectory: compilerHost.getCurrentDirectory,\n getDirectories: compilerHost.getDirectories,\n }\n\n const resolvedModule = ts.resolveModuleName(\n importSpecifier,\n sourceFile.fileName,\n program.getCompilerOptions(),\n moduleResolutionHost,\n )\n\n return resolvedModule.resolvedModule?.resolvedFileName\n}\n\n// Traverse the source file and resolve imports\nexport function findAndResolveImports(program: ts.Program, sourceFile: ts.SourceFile) {\n const importSpecifierToFilePath: Record<string, string> = {}\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isImportDeclaration(node)) {\n const importSpecifier = (node.moduleSpecifier as ts.StringLiteral).text\n const resolvedFileName = resolveModuleSpecifier(program, sourceFile, importSpecifier)\n\n if (resolvedFileName) {\n importSpecifierToFilePath[importSpecifier] = resolvedFileName\n }\n }\n })\n return importSpecifierToFilePath\n}\n\n/**\n * Finds all import statements in a file that matches the given identifiers\n *\n * @param parserContext Parser context\n * @param identifiers List of identifiers to find imports for\n * @returns\n */\nfunction getSourceFilesOfImportedIdentifiers(parserContext: ParserContext, _identifiers: string[]) {\n const { sourceFile, resolvedImports } = parserContext\n const importDeclarations = getImportsOfModule(sourceFile)\n const imports: {\n statement: string\n file: string\n moduleSpecifier: string\n }[] = []\n\n const identifiers = _identifiers.map((identifier) => identifier.split('.')[0])\n\n for (const declaration of importDeclarations) {\n let statement = declaration.getText()\n // remove the quotation marks around the module specifier\n const moduleSpecifier = declaration.moduleSpecifier.getText().slice(1, -1)\n\n if (declaration.importClause) {\n // Default imports\n if (declaration.importClause.name) {\n const identifier = declaration.importClause.name.text\n\n if (identifiers.includes(identifier)) {\n imports.push({\n statement,\n file: resolvedImports[moduleSpecifier],\n moduleSpecifier,\n })\n }\n }\n\n if (declaration.importClause.namedBindings) {\n const namedBindings = declaration.importClause.namedBindings\n\n if (ts.isNamedImports(namedBindings)) {\n // Named imports (import { x, y } from 'module')\n // filter out any unused imports from the statement the identifier belongs to\n const elements = namedBindings.elements\n .map((specifier) => specifier.name.text)\n .filter((name) => identifiers.includes(name))\n\n if (elements.length > 0) {\n imports.push({\n statement: statement.replace(/{.*}/s, `{ ${elements.join(', ')} }`),\n file: resolvedImports[moduleSpecifier],\n moduleSpecifier,\n })\n }\n } else if (ts.isNamespaceImport(namedBindings)) {\n // Namespace import (import * as name from 'module')\n const identifier = namedBindings.name.text\n if (identifiers.includes(identifier)) {\n imports.push({\n statement,\n file: resolvedImports[moduleSpecifier],\n moduleSpecifier,\n })\n }\n }\n }\n }\n }\n\n return imports\n}\n\nexport type ComponentTypeSignature = Record<string, string>\n\n/**\n * Extract metadata about the referenced React component. Used by both the\n * Code Connect and Storybook commands.\n *\n * @param parserContext Parser context\n * @param componentSymbol The ts.Symbol from the metadata referencing the\n * component being documented\n * @param node The node being parsed. Used for error logging.\n * @returns Metadata object\n */\nexport async function parseComponentMetadata(\n node: ts.PropertyAccessExpression | ts.Identifier | ts.Expression,\n parserContext: ParserContext,\n silent?: boolean,\n) {\n const { checker, sourceFile } = parserContext\n let componentSymbol = checker.getSymbolAtLocation(node)\n let componentSourceFile = sourceFile\n let component = ''\n let componentDeclaration\n\n // Hacky fix for namespaced components, this probably doesn't work for storybook\n if (ts.isPropertyAccessExpression(node)) {\n componentSymbol = checker.getSymbolAtLocation(node.expression)\n if (!componentSymbol) {\n throw new ParserError(`Could not find symbol for component ${node.expression.getText()}`, {\n sourceFile,\n node,\n })\n }\n }\n\n // Component declared in a different file\n if (\n componentSymbol &&\n componentSymbol.declarations &&\n (ts.isImportSpecifier(componentSymbol.declarations[0]) ||\n ts.isImportClause(componentSymbol.declarations[0]))\n ) {\n let importDeclaration = findParentImportDeclaration(componentSymbol.declarations[0])\n if (!importDeclaration) {\n throw new ParserError(\n 'No import statement found for component, make sure the component is imported',\n {\n sourceFile,\n node,\n },\n )\n }\n\n // The component should be imported from another file, we need to follow the\n // aliased symbol to get the correct function definition\n if (componentSymbol.flags & ts.SymbolFlags.Alias) {\n componentSymbol = checker.getAliasedSymbol(componentSymbol)\n }\n\n if (!componentSymbol || !componentSymbol.declarations) {\n if (!silent) {\n logger.warn(\n `Import for ${node.getText()} could not be resolved, make sure that your \\`include\\` globs in \\`figma.config.json\\` matches the component source file (in addition to the Code Connect file). If you're using path aliases, make sure to include the same aliases in \\`figma.config.json\\` with the \\`paths\\` option.`,\n )\n }\n return {\n source: '',\n line: 0,\n component: node.getText(),\n }\n }\n\n // If we haven't found the component declaration by now, it's likely because it's\n // assigned to an object/namespace, for example: `export const Button = { Primary: () => <button /> }`,\n // so we need to find the function declaration by traversing the AST in that file.\n if (!ts.isFunctionDeclaration(componentSymbol.declarations[0])) {\n const sourceFile = componentSymbol.declarations[0].getSourceFile()\n bfsFindNode(sourceFile, sourceFile, (node) => {\n if (\n (ts.isFunctionDeclaration(node) || ts.isVariableDeclaration(node)) &&\n node.name &&\n componentSymbol?.name &&\n node.name.getText() === componentSymbol.name\n ) {\n componentSymbol = checker.getSymbolAtLocation(node.name)\n return true\n }\n return false\n })\n }\n\n componentDeclaration = componentSymbol.declarations[0]\n componentSourceFile = componentDeclaration.getSourceFile()\n } else {\n componentDeclaration = componentSymbol?.declarations?.[0]\n }\n\n const source = componentSourceFile.fileName\n\n if (!source) {\n throw new InternalError(\n `Could not find source file for component ${component} - is this file included in the directory passed to \\`figma connect <dir>\\`?`,\n )\n }\n\n if (!componentDeclaration) {\n throw new ParserError(`Could not find declaration for component ${component}`, {\n sourceFile,\n node,\n })\n }\n\n const line = getPositionInSourceFile(componentDeclaration, componentSourceFile).line\n if (line === undefined) {\n throw new InternalError(\n `Could not determine line number for component ${componentDeclaration.getStart(sourceFile)}`,\n )\n }\n\n return {\n source,\n line,\n component: node.getText(),\n }\n}\n\n/**\n * Parses a render function and ouputs a template string, extracting the code and\n * any import statements matching the JSX elements used in the function body\n *\n * @param exp A function or arrow function expression\n * @param parserContext Parser context\n * @param propMappings Prop mappings object as returned by parseProps\n *\n * @returns The code of the render function and a list of imports\n */\nexport function parseRenderFunctionExpression(\n exp: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n parserContext: ParserContext,\n propMappings?: PropMappings,\n) {\n const { sourceFile } = parserContext\n\n let renderFunctionCode: string\n\n if (exp.parameters.length > 1) {\n throw new ParserError(\n `Expected a single props parameter for the render function, got ${exp.parameters.length} parameters`,\n { sourceFile, node: exp },\n )\n }\n\n const propsParameter = exp.parameters[0]\n\n // Keep track of any props which are referenced in the example\n const referencedProps = new Set<string>()\n\n const createPropPlaceholder = makeCreatePropPlaceholder({\n propMappings,\n referencedProps,\n sourceFile,\n })\n\n // Find all property access expressions in the function body and replace them\n // with a function call like `__PROP__(\"propName\")`, so that we can easily\n // find them in the next step to convert them into\n // `${_fcc_renderReactProp(...)` in the template string.\n //\n // Doing it this way means we can normalize the different ways in which props\n // can be accessed using the compiler API, which is much easier than using a\n // regex, then in the next step we can use a simple regex to convert that into\n // the template string.\n if (propsParameter) {\n exp = ts.transform(exp, [\n (context) => (rootNode) => {\n function visit(node: ts.Node): ts.Node {\n const visitResult = visitPropReferencingNode({\n propsParameter,\n node,\n createPropPlaceholder,\n useJsx: true,\n })\n\n if (visitResult) {\n return visitResult\n }\n\n // object assignment using destructured reference, e.g `prop={{ key: value }}`\n // (`{{ key: props.value }}` syntax will be captured by the `props.` notation branch above)\n if (\n ts.isObjectBindingPattern(propsParameter.name) &&\n ts.isPropertyAssignment(node) &&\n ts.isIdentifier(node.initializer) &&\n propsParameter.name.elements.find((el) =>\n node.initializer.getText().startsWith(el.name.getText()),\n )\n ) {\n return ts.factory.createPropertyAssignment(\n node.name,\n createPropPlaceholder({ name: node.initializer.getText(), node }),\n )\n }\n // object assignment using destructured reference as a shorthand, e.g `prop={{ value }}`\n if (\n ts.isObjectBindingPattern(propsParameter.name) &&\n ts.isShorthandPropertyAssignment(node) &&\n propsParameter.name.elements.find((el) =>\n node.name.getText().startsWith(el.name.getText()),\n )\n ) {\n return ts.factory.createPropertyAssignment(\n node.name,\n createPropPlaceholder({ name: node.name.getText(), node }),\n )\n }\n\n // Replaces {...props} with all the prop mapped props we know about,\n // e.g. <Button {...props} /> becomes:\n // <Button prop1={__PROP__(\"prop1\")} prop2={__PROP__(\"prop2\")} />.\n if (\n ts.isJsxSpreadAttribute(node) &&\n ts.isIdentifier(node.expression) &&\n // example: (props) => (...)\n (node.expression.getText() === propsParameter.name.getText() ||\n // example: ({ prop1, prop2 ...props }) => (...)\n (ts.isObjectBindingPattern(propsParameter.name) &&\n propsParameter.name.elements.find(\n (el) => el.dotDotDotToken && el.name.getText() === node.expression?.getText(),\n )))\n ) {\n // if we have an object binding pattern ({ prop1, prop2 ...props }),\n // exclude the props that are already destructured (prop1, prop2)\n const propsToExclude = ts.isObjectBindingPattern(propsParameter.name)\n ? propsParameter.name.elements\n .filter((el) => !el.dotDotDotToken)\n .map((el) => el.name.getText())\n : []\n const props = propMappings\n ? Object.keys(propMappings)\n .filter((prop) => !propsToExclude.includes(prop))\n .map((prop) => {\n return ts.factory.createJsxAttribute(\n ts.factory.createIdentifier(prop),\n createPropPlaceholder({\n name: prop,\n node,\n wrapInJsxExpression: true,\n }) as ts.JsxExpression,\n )\n })\n : []\n\n if (propMappings) {\n for (const key of Object.keys(propMappings)) {\n referencedProps.add(key)\n }\n }\n\n return props as any\n }\n\n return ts.visitEachChild(node, visit, context)\n }\n return ts.visitNode(rootNode, visit) as\n ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration\n },\n ]).transformed[0] as typeof exp\n }\n\n const printer = ts.createPrinter()\n // Only consider the render function's *own* body block, not any block nested\n // deeper in the tree. Using a tree-walking search here would incorrectly pick\n // up blocks belonging to nested functions (e.g. an event handler passed as a\n // JSX prop like `onValidateFile={file => { ... }}`), causing us to render that\n // handler's body instead of the returned JSX.\n const block = exp.body && ts.isBlock(exp.body) ? exp.body : undefined\n let nestable = false\n let jsx = findJSXElement(exp)\n\n if (jsx && (!block || (block && block.statements.length <= 1))) {\n // The function body is a single JSX element\n renderFunctionCode = printer.printNode(ts.EmitHint.Unspecified, jsx, sourceFile)\n nestable = true\n } else if (block) {\n // The function body has more stuff in it, so we wrap the body in a function\n // expression. Why not just print the exact function passed to `render`?\n // Because the parameters to that function are not actually referenced in\n // the rendered code snippet in Figma - they're mapped to values on the\n // Figma instance.\n const functionName = 'Example'\n const functionExpression = ts.factory.createFunctionExpression(\n undefined,\n undefined,\n ts.factory.createIdentifier(functionName),\n [],\n undefined,\n undefined,\n block,\n )\n const printer = ts.createPrinter()\n renderFunctionCode = printer.printNode(ts.EmitHint.Unspecified, functionExpression, sourceFile)\n } else {\n throw new ParserError(\n `Expected a single JSX element or a block statement in the render function, got ${exp.getText()}`,\n { sourceFile, node: exp },\n )\n }\n\n renderFunctionCode = replacePropPlaceholders(renderFunctionCode)\n\n // Escape backticks from the example code, as otherwise those would terminate the `figma.tsx` template literal\n renderFunctionCode = renderFunctionCode.replace(/`/g, '\\\\`')\n\n // Finally, output the render function as a figma.tsx call\n const figmaTsxCall = `figma.tsx\\`${renderFunctionCode}\\``\n\n // Find all JSX elements in the function body and extract their import\n // statements\n const jsxTags = findDescendants(\n exp,\n (element) => ts.isJsxElement(element) || ts.isJsxSelfClosingElement(element),\n ) as (ts.JsxElement | ts.JsxSelfClosingElement)[]\n const imports = getSourceFilesOfImportedIdentifiers(parserContext, jsxTags.map(getTagName))\n\n return {\n code: figmaTsxCall,\n imports,\n nestable,\n referencedProps,\n }\n}\n\n/**\n * Parses the render function passed to `figma.connect()`, extracting the code and\n * any import statements matching the JSX elements used in the function body\n *\n * @param exp A function or arrow function expression\n * @param parserContext Parser context\n * @param propMappings Prop mappings object as returned by parseProps\n *\n * @returns The code of the render function and a list of imports\n */\nexport function parseJSXRenderFunction(\n exp: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n parserContext: ParserContext,\n propMappings?: PropMappings,\n isForMigration?: boolean,\n) {\n const { sourceFile } = parserContext\n\n const { code, imports, nestable, referencedProps } = parseRenderFunctionExpression(\n exp,\n parserContext,\n propMappings,\n )\n\n let templateCode = ''\n\n // Generate the template code\n // Inject React-specific template helper functions\n if (!isForMigration) {\n templateCode = getParsedTemplateHelpersString() + '\\n\\n'\n }\n\n // Require the template API\n templateCode += `const figma = require('figma')\\n\\n`\n\n // Then we output `const propName = figma.properties.<kind>('propName')` calls\n // for each referenced prop, so these are accessible to the template code.\n templateCode += getReferencedPropsForTemplate({\n propMappings,\n exp,\n sourceFile,\n isForMigration,\n })\n\n const includeMetadata = propMappings && Object.keys(propMappings).length > 0\n\n // Finally, output the example code\n templateCode += includeMetadata\n ? `export default { ...${code}, metadata: { __props } }\\n`\n : `export default ${code}\\n`\n\n return {\n code: templateCode,\n imports,\n nestable,\n }\n}\n\n/**\n * Parses the render function for a value (i.e. example which returns a string or React\n * component reference, not JSX) passed to `figma.connect()`\n */\nexport function parseValueRenderFunction(\n exp: ts.ArrowFunction | ts.FunctionExpression | ts.FunctionDeclaration,\n parserContext: ParserContext,\n propMappings?: PropMappings,\n isForMigration?: boolean,\n) {\n const { sourceFile } = parserContext\n const printer = ts.createPrinter()\n if (!exp.body) {\n throw new ParserError('Expected a function body', {\n sourceFile: parserContext.sourceFile,\n node: exp,\n })\n }\n\n let exampleCode = printer.printNode(ts.EmitHint.Unspecified, exp.body, sourceFile)\n const nestable = true\n\n let templateCode = ''\n // Generate the template code\n // Inject React-specific template helper functions\n if (!isForMigration) {\n templateCode = getParsedTemplateHelpersString() + '\\n\\n'\n }\n\n // Require the template API\n templateCode += `const figma = require('figma')\\n\\n`\n\n // Then we output `const propName = figma.properties.<kind>('propName')` calls\n // for each referenced prop, so these are accessible to the template code.\n templateCode += getReferencedPropsForTemplate({\n propMappings,\n exp,\n sourceFile,\n isForMigration,\n })\n\n // Escape backticks from the example code\n exampleCode = exampleCode.replace(/`/g, '\\\\`')\n\n let imports: {\n statement: string\n file: string\n moduleSpecifier: string\n }[] = []\n\n const includeMetadata = propMappings && Object.keys(propMappings).length > 0\n\n if (ts.isStringLiteral(exp.body)) {\n // The value is a string, which is already wrapped in quotes\n templateCode += includeMetadata\n ? `export default { ...figma.value(${exampleCode}), metadata: { __props } }\\n`\n : `export default figma.value(${exampleCode})\\n`\n } else if (ts.isIdentifier(exp.body)) {\n // The value is an identifier, i.e. a React component reference\n const value = `_fcc_reactComponent(\"${exp.body.getText()}\")`\n const preview = `_fcc_renderPropValue(${value})`\n templateCode += includeMetadata\n ? `export default { ...figma.value(${value}, ${preview}), metadata: { __props } }\\n`\n : `export default figma.value(${value}, ${preview})\\n`\n imports = getSourceFilesOfImportedIdentifiers(parserContext, [exp.body.getText()])\n }\n\n return {\n code: templateCode,\n imports,\n nestable,\n }\n}\n\nexport function replacePropPlaceholders(exampleCode: string) {\n // Replace React prop placeholders we inserted above (like\n // `reactPropName={__PROP__(\"figmaPropName\")}`) with calls to\n // _fcc_renderReactProp, which renders them correctly (see\n // parser_template_helpers.ts)\n exampleCode = exampleCode.replace(\n // match \" reactPropName={__PROP__(\"figmaPropName\")}\" and extract the names\n // We allow hyphens in prop names (unlike React) to support rendering HTML attributes\n / ([A-Za-z0-9\\-]+)=\\{__PROP__\\(\"([A-Za-z0-9_\\.]+)\"\\)\\}/g,\n (_match, reactPropName, figmaPropName) => {\n return `\\${_fcc_renderReactProp('${reactPropName}', ${figmaPropName})}`\n },\n )\n\n // Replace React children placeholders like `${__PROP__(\"propName\")}` with\n // calls to _fcc_renderReactChildren, which renders them correctly (see\n // parser_template_helpers.ts)\n exampleCode = exampleCode.replace(\n /\\{__PROP__\\(\"([A-Za-z0-9_\\.]+)\"\\)\\}/g,\n (_match, figmaPropName) => {\n return `\\${_fcc_renderReactChildren(${figmaPropName})}`\n },\n )\n\n // Assume any remaining placeholders are values, e.g.\n // - { prop: __PROP__(\"propName\") }\n // - useState(__PROP__(\"propName\"))\n // These never need special treatment based on their type.\n return exampleCode.replace(/__PROP__\\(\"([A-Za-z0-9_\\.]+)\"\\)/g, (_match, figmaPropName) => {\n return `\\${_fcc_renderPropValue(${figmaPropName})}`\n })\n}\n\nfunction followIdentifierToStringLiteralDeclaration(\n node: ts.Identifier | ts.StringLiteral,\n parserContext: ParserContext,\n errMessage: string,\n) {\n const { checker } = parserContext\n let result = node\n\n if (node && ts.isIdentifier(node)) {\n const symbol = checker.getSymbolAtLocation(node)\n if (symbol) {\n const decl = symbol.valueDeclaration\n if (\n decl &&\n ts.isVariableDeclaration(decl) &&\n decl.initializer &&\n ts.isStringLiteral(decl.initializer)\n ) {\n result = decl.initializer\n }\n }\n }\n\n // If we followed the identifier to its declaration and it's not a string literal,\n // throw an error\n if (!result || !ts.isStringLiteral(result)) {\n throw new ParserError(errMessage, {\n node: result,\n sourceFile: parserContext.sourceFile,\n })\n }\n\n return result\n}\n\nfunction parseFigmaConnectArgs(node: ts.CallExpression, parserContext: ParserContext) {\n const required = true\n const first = parseFunctionArgument(\n node,\n parserContext,\n 0,\n isOneOf([ts.isIdentifier, ts.isPropertyAccessExpression, ts.isStringLiteral]),\n required,\n `\\`${FIGMA_CONNECT_CALL}\\` must be called with a reference to a Component or a Figma Component URL as the first argument. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1')\\``,\n )!\n\n let figmaNodeUrlArg: ts.StringLiteral\n let componentArg: ts.Identifier | ts.PropertyAccessExpression | undefined\n let configObjArgIndex\n\n // This function has two signatures. If the first arg is a string literal, it's the Figma node URL, and\n // it won't have a component reference.\n if (ts.isStringLiteral(first)) {\n figmaNodeUrlArg = first\n componentArg = undefined\n configObjArgIndex = 1\n } else {\n // If the first argument is not a string literal, it must be a component reference,\n // and the second argument must be the Figma node URL\n componentArg = first\n configObjArgIndex = 2\n\n const invalidTypeErrorMsg = `The second argument to ${FIGMA_CONNECT_CALL}() must be a string literal (the URL of the Figma node). Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1')\\``\n\n let arg = parseFunctionArgument(\n node,\n parserContext,\n 1,\n isOneOf([ts.isIdentifier, ts.isStringLiteral]),\n required,\n invalidTypeErrorMsg,\n )!\n\n figmaNodeUrlArg = followIdentifierToStringLiteralDeclaration(\n arg,\n parserContext,\n invalidTypeErrorMsg,\n )\n }\n\n const configObjArg = parseFunctionArgument(\n node,\n parserContext,\n configObjArgIndex,\n ts.isObjectLiteralExpression,\n false /* not required */,\n `The third argument to ${FIGMA_CONNECT_CALL}() must be an object literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', { render: () => <Button /> })\\``,\n )\n\n return {\n componentArg,\n figmaNodeUrlArg,\n configObjArg,\n }\n}\n\nfunction parseConfigObjectArg(\n configArg: ts.ObjectLiteralExpression | undefined,\n parserContext: ParserContext,\n) {\n if (!configArg) {\n return {\n propsArg: undefined,\n exampleArg: undefined,\n variantArg: undefined,\n importsArg: undefined,\n linksArg: undefined,\n }\n }\n\n const propsArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'props',\n predicate: ts.isObjectLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'props' property must be an object literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n props: {\n disabled: figma.boolean('Disabled'),\n text: figma.string('TextContent'),\n }\n })\\``,\n })\n\n const exampleArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'example',\n predicate: isOneOf([ts.isArrowFunction, ts.isFunctionExpression]),\n parserContext,\n required: false,\n errorMessage: `The 'example' property must be an inline function or arrow function. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n example: () => <Button />\n })\\``,\n })\n\n const variantArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'variant',\n predicate: ts.isObjectLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'variant' property must be an object literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n variant: {\n \"Has Icon\": true\n }\n })\\``,\n })\n\n const linksArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'links',\n predicate: ts.isArrayLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'links' property must be an array literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n links: [\n { name: 'Storybook', url: 'https://storybook.com' }\n ]\n })\\``,\n })\n\n const importsArg = parsePropertyOfType({\n objectLiteralNode: configArg,\n propertyName: 'imports',\n predicate: ts.isArrayLiteralExpression,\n parserContext,\n required: false,\n errorMessage: `The 'imports' property must be an array literal. Example usage:\n \\`${FIGMA_CONNECT_CALL}(Button, 'https://www.figma.com/file/123?node-id=1-1', {\n imports: ['import { Button } from \"./Button\"']\n })\\``,\n })\n\n return {\n propsArg,\n exampleArg,\n variantArg,\n linksArg,\n importsArg,\n }\n}\n\nexport function getDefaultTemplate(\n componentMetadata: Awaited<ReturnType<typeof parseComponentMetadata>>,\n) {\n const example = `<${componentMetadata.component} />`\n return `const figma = require(\"figma\")\\n\\nexport default figma.tsx\\`${example}\\``\n}\n\nexport async function parseReactDoc(\n node: ts.CallExpression,\n parserContext: ParserContext,\n { repoUrl, silent, isForMigration }: ParseOptions,\n): Promise<CodeConnectJSON> {\n const { checker, sourceFile, config } = parserContext\n\n // Parse the arguments to the `figma.connect()` call\n const { componentArg, figmaNodeUrlArg, configObjArg } = parseFigmaConnectArgs(node, parserContext)\n\n const { propsArg, exampleArg, variantArg, linksArg, importsArg } = parseConfigObjectArg(\n configObjArg,\n parserContext,\n )\n\n let figmaNode = stripQuotesFromNode(figmaNodeUrlArg)\n // TODO This logic is duplicated in connect.ts transformDocFromParser due to some type issues\n if (config.documentUrlSubstitutions) {\n figmaNode = applyDocumentUrlSubstitutions(figmaNode as string, config.documentUrlSubstitutions)\n }\n const metadata = componentArg\n ? await parseComponentMetadata(componentArg, parserContext, silent)\n : undefined\n\n const props = propsArg ? parsePropsObject(propsArg, parserContext) : undefined\n const render = exampleArg\n ? findJSXElement(exampleArg)\n ? parseJSXRenderFunction(exampleArg, parserContext, props, isForMigration)\n : parseValueRenderFunction(exampleArg, parserContext, props, isForMigration)\n : undefined\n const variant = variantArg ? parseVariant(variantArg, sourceFile, checker) : undefined\n const links = linksArg ? parseLinks(linksArg, parserContext) : undefined\n\n let mappedImports: string[]\n if (importsArg) {\n mappedImports = parseImports(importsArg, parserContext)\n } else {\n // If no template function was provided, construct one and add the import\n // statement for the component\n let imports = render?.imports\n ? render.imports\n : metadata !== undefined\n ? getSourceFilesOfImportedIdentifiers(parserContext, [metadata.component])\n : []\n\n if (imports.length === 0 && metadata?.component) {\n // If no imports were found, it might mean that the component is not imported, or\n // that the `figma.connect` call is in the same file as the component. In the latter\n // case - we'll want to generate one\n const fileName = metadata.source.split('/').pop()?.split('.')[0]\n const relativeImportPath = `./${fileName}`\n imports = [\n {\n statement: `import { ${metadata.component} } from '${relativeImportPath}'`,\n file: sourceFile.fileName,\n moduleSpecifier: relativeImportPath,\n },\n ]\n }\n\n mappedImports = [\n ...new Set(\n imports.map((imp) => {\n if (config) {\n // First try to map the original import specifier directly (preserves user's intent)\n // e.g., '@/AlertTitle' -> '@acme/package/AlertTitle'\n if (typeof imp.moduleSpecifier === 'string') {\n const mappedFromSpecifier = mapImportSpecifier(imp.moduleSpecifier, config)\n if (mappedFromSpecifier) {\n return imp.statement.replace(\n /['\"]([@\\.\\/a-zA-Z0-9_-]*)['\"]/,\n `'${mappedFromSpecifier}'`,\n )\n }\n }\n // Fall back to mapping based on resolved file path (for relative imports)\n const mappedPath = mapImportPath(imp.file, config)\n if (mappedPath) {\n return imp.statement.replace(/['\"]([@\\.\\/a-zA-Z0-9_-]*)['\"]/, `'${mappedPath}'`)\n }\n }\n return imp.statement\n }),\n ),\n ]\n }\n\n if (mappedImports.length === 0 && metadata?.component) {\n logger.warn(\n `The import statement for ${metadata.component} could not be automatically resolved, make sure the component is imported (if not colocating) and that the path mappings are correct in your figma.config.json`,\n )\n }\n\n let template\n if (render?.code) {\n template = render.code\n } else if (metadata) {\n template = getDefaultTemplate(metadata)\n } else {\n throw new ParserError(\n `${FIGMA_CONNECT_CALL}() requires either a component argument or an example function`,\n { sourceFile, node },\n )\n }\n\n return {\n figmaNode,\n label: DEFAULT_LABEL_PER_PARSER.react!,\n language: SyntaxHighlightLanguage.TypeScript,\n component: metadata?.component,\n source: metadata?.source\n ? getRemoteFileUrl(metadata.source, repoUrl, parserContext.config?.defaultBranch)\n : '',\n sourceLocation: metadata?.line !== undefined ? { line: metadata.line } : { line: -1 },\n variant,\n template,\n templateData: {\n // TODO: `props` here is currently only used for validation purposes,\n // we should eventually remove it from the JSON payload\n props,\n imports: mappedImports,\n // If there's no render function, the default example is always nestable\n nestable: render ? render.nestable : true,\n },\n links,\n metadata: {\n cliVersion: require('../../package.json').version,\n },\n }\n}\n"]}
|
package/figma-types.d.ts
CHANGED