@figma/code-connect 1.4.9 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +3 -0
  2. package/dist/commands/connect.d.ts +5 -0
  3. package/dist/commands/connect.d.ts.map +1 -1
  4. package/dist/commands/connect.js +55 -10
  5. package/dist/commands/connect.js.map +1 -1
  6. package/dist/commands/connect_template.d.ts.map +1 -1
  7. package/dist/commands/connect_template.js +2 -2
  8. package/dist/commands/connect_template.js.map +1 -1
  9. package/dist/commands/preview_utils.d.ts +103 -5
  10. package/dist/commands/preview_utils.d.ts.map +1 -1
  11. package/dist/commands/preview_utils.js +453 -76
  12. package/dist/commands/preview_utils.js.map +1 -1
  13. package/dist/commands/property_list_table.d.ts +11 -0
  14. package/dist/commands/property_list_table.d.ts.map +1 -0
  15. package/dist/commands/property_list_table.js +67 -0
  16. package/dist/commands/property_list_table.js.map +1 -0
  17. package/dist/common/updates.d.ts +4 -1
  18. package/dist/common/updates.d.ts.map +1 -1
  19. package/dist/common/updates.js +26 -5
  20. package/dist/common/updates.js.map +1 -1
  21. package/dist/connect/api.d.ts.map +1 -1
  22. package/dist/connect/api.js.map +1 -1
  23. package/dist/connect/batch_templates.d.ts +1 -1
  24. package/dist/connect/batch_templates.d.ts.map +1 -1
  25. package/dist/connect/batch_templates.js +2 -2
  26. package/dist/connect/batch_templates.js.map +1 -1
  27. package/dist/connect/migration_batch_helpers.d.ts.map +1 -1
  28. package/dist/connect/migration_batch_helpers.js +1 -15
  29. package/dist/connect/migration_batch_helpers.js.map +1 -1
  30. package/dist/connect/migration_helpers.d.ts +6 -0
  31. package/dist/connect/migration_helpers.d.ts.map +1 -1
  32. package/dist/connect/migration_helpers.js +66 -0
  33. package/dist/connect/migration_helpers.js.map +1 -1
  34. package/dist/connect/property_combinations.d.ts +69 -0
  35. package/dist/connect/property_combinations.d.ts.map +1 -0
  36. package/dist/connect/property_combinations.js +172 -0
  37. package/dist/connect/property_combinations.js.map +1 -0
  38. package/dist/connect/raw_template_bundler.d.ts +13 -0
  39. package/dist/connect/raw_template_bundler.d.ts.map +1 -0
  40. package/dist/connect/raw_template_bundler.js +178 -0
  41. package/dist/connect/raw_template_bundler.js.map +1 -0
  42. package/dist/connect/raw_templates.d.ts +1 -1
  43. package/dist/connect/raw_templates.d.ts.map +1 -1
  44. package/dist/connect/raw_templates.js +85 -24
  45. package/dist/connect/raw_templates.js.map +1 -1
  46. package/dist/react/parser.d.ts.map +1 -1
  47. package/dist/react/parser.js.map +1 -1
  48. package/figma-types-no-require.d.ts +8 -6
  49. package/figma-types.d.ts +8 -6
  50. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"raw_templates.js","sourceRoot":"","sources":["../../src/connect/raw_templates.ts"],"names":[],"mappings":";;;;;;AA2BA,sCAaC;AA8FD,oCAsGC;AA5OD,4CAAmB;AACnB,4DAA2B;AAG3B,qEAAsF;AACtF,uCAAyD;AAEzD;;;;;;GAMG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AALD,kDAKC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,OAAe;IAC3C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;QAC3B,IAAI,OAAO,KAAK,EAAE,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YAC/C,IAAI,iCAAiC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gBACpD,OAAO,IAAI,CAAA;YACb,CAAC;YACD,SAAQ;QACV,CAAC;QACD,mGAAmG;QACnG,MAAK;IACP,CAAC;IACD,OAAO,KAAK,C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AAE,IAAI,EAAE,CAAC,CAAC,EAAE;QAC5B,QAAQ,EAAE;YACR,UAAU,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO;SAClD;KACF,CAAA;AACH,CAAC","sourcesContent":["import fs from 'fs'\nimport ts from 'typescript'\nimport { CodeConnectJSON } from './figma_connect'\nimport { CodeConnectConfig } from './project'\nimport { CodeConnectLabel, getInferredLanguageForRaw } from './label_language_mapping'\nimport { applyDocumentUrlSubstitutions } from './helpers'\n\n/**\n * Thrown when a raw template file has no `// url=` directive but contains the\n * string `codeProperties`. These files (e.g. Make's code component property\n * definitions) are not Code Connect, so callers skip them with a log instead of\n * failing. Every other file is handled exactly as before — a missing url is\n * still a hard error.\n */\nexport class CodePropertiesError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'CodePropertiesError'\n }\n}\n\n/**\n * Returns true if the file content looks like a raw template file, i.e. its\n * leading comment block contains a `// url=`, `// component=`, or `// source=`\n * directive. Used to distinguish raw `.figma.ts` templates from React/HTML\n * Code Connect files that share the same extension.\n */\nexport function isRawTemplate(content: string): boolean {\n for (const line of content.split('\\n')) {\n const trimmed = line.trim()\n if (trimmed === '' || trimmed.startsWith('//')) {\n if (/^\\/\\/\\s*(url|component|source)=/.test(trimmed)) {\n return true\n }\n continue\n }\n // First non-comment, non-blank line reached without finding a known directive — not a raw template\n break\n }\n return false\n}\n\n// Convert ESM import of 'figma' to require syntax. Supports: import figma from 'figma'\nconst figmaImportRegex = /^import\\s+figma\\s+from\\s+['\"]figma['\"]\\s*;?\\s*$/m\n\n/**\n * Throws if the file imports from anything other than 'figma'. Type-only imports\n * (`import type`) are erased by the TS compiler and are fine; the `figma` default\n * import is the one supported module (no bundling in Phase 1). This runs BEFORE\n * the `codeProperties` skip guard so an unsupported import is always a hard error,\n * even in a file that would otherwise be skipped.\n */\nfunction assertOnlyFigmaImports(filePath: string, fileContent: string): void {\n // Ignore the supported `import figma from 'figma'` form before scanning.\n const withoutFigmaImport = fileContent.replace(figmaImportRegex, '')\n const importRegex = /^import\\s+(?!type\\s)/m\n if (importRegex.test(withoutFigmaImport)) {\n const match = withoutFigmaImport.match(/^(import\\s+.+)$/m)\n const importLine = match ? match[1] : 'import ...'\n throw new Error(\n `TypeScript template files only support importing from 'figma'.\\n` +\n `Found in ${filePath}:\\n` +\n ` ${importLine}\\n\\n` +\n `Use \"const figma = require('figma')\" or \"import figma from 'figma'\" to access the Figma API.\\n` +\n `Other module imports will be supported in a future version.`,\n )\n }\n}\n\nfunction transpileTypeScriptTemplate(filePath: string, fileContent: string): string {\n if (figmaImportRegex.test(fileContent)) {\n fileContent = fileContent.replace(figmaImportRegex, \"const figma = require('figma')\")\n }\n\n const result = ts.transpileModule(fileContent, {\n compilerOptions: {\n module: ts.ModuleKind.ESNext,\n target: ts.ScriptTarget.ES2021,\n removeComments: false,\n },\n })\n\n return result.outputText\n}\n\n/**\n * Extracts metadata fields (url, component, source) from the leading comments\n * of a raw template file. This must be done before transpilation because\n * TypeScript can remove comments that appear before type-only imports.\n */\nfunction extractMetadataFields(fileContent: string): {\n fields: { url?: string; component?: string; source?: string }\n templateStartLine: number\n} {\n const lines = fileContent.split('\\n')\n const fields: { url?: string; component?: string; source?: string } = {}\n let templateStartLine = 0\n\n // Parse consecutive comment lines at the start of the file\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trim()\n // Match pattern: // fieldName=value\n const match = line.match(/^\\/\\/\\s*(\\w+)=(.+)$/)\n if (match) {\n const [, fieldName, fieldValue] = match\n const normalizedFieldName = fieldName.toLowerCase()\n if (\n normalizedFieldName === 'url' ||\n normalizedFieldName === 'component' ||\n normalizedFieldName === 'source'\n ) {\n fields[normalizedFieldName] = fieldValue.trim()\n }\n templateStartLine = i + 1\n } else if (line === '' || line.startsWith('//')) {\n // Allow blank lines or other comments, but don't increment template start\n continue\n } else {\n // First non-comment line found\n break\n }\n }\n\n return { fields, templateStartLine }\n}\n\nexport interface BatchOverrides {\n url: string\n source?: string\n component?: string\n batchData: Record<string, any>\n batchFilePath: string\n}\n\nexport function parseRawFile(\n filePath: string,\n label: string | undefined,\n config?: CodeConnectConfig,\n dir?: string,\n batchOverrides?: BatchOverrides,\n): CodeConnectJSON {\n let fileContent = fs.readFileSync(filePath, 'utf-8')\n\n // Extract metadata fields BEFORE transpilation to avoid losing comments\n // that appear before type-only imports (which TypeScript erases)\n const { fields, templateStartLine } = extractMetadataFields(fileContent)\n\n const figmaUrl = batchOverrides?.url || fields.url\n\n // An unsupported (non-figma) import is always a hard error, even in a file that\n // would otherwise be skipped as a `codeProperties` file below. Checked first so\n // an import mistake is never silently swallowed by the skip guard.\n if (filePath.endsWith('.ts')) {\n assertOnlyFigmaImports(filePath, fileContent)\n }\n\n // A file with no // url= directive that contains the string `codeProperties`\n // is not Code Connect (e.g. Make's code component property definitions). Skip\n // it (callers log and continue) instead of failing. Every other file is\n // handled exactly as before.\n if (!figmaUrl && fileContent.includes('codeProperties')) {\n throw new CodePropertiesError(\n `Skipping ${filePath}: file has no // url= directive and contains \"codeProperties\", so it is not treated as a Code Connect file.`,\n )\n }\n\n if (filePath.endsWith('.ts')) {\n fileContent = transpileTypeScriptTemplate(filePath, fileContent)\n }\n\n // For batch templates, metadata comes from the batch entry instead of comments\n const component = batchOverrides?.component || fields.component\n const source = batchOverrides?.source || fields.source || ''\n\n if (!figmaUrl) {\n throw new Error(\n batchOverrides\n ? `Missing required \"url\" field in ${batchOverrides.batchFilePath}. Please add \"url\" to each entry in your .figma.batch.json file.`\n : `Missing required url field in ${filePath}. Please add a // url=... comment to the top of the file.`,\n )\n }\n let figmaNodeUrl = figmaUrl\n\n // Extract template from the transpiled content, starting at the line\n // where the metadata comments ended in the original source\n const transpiledLines = fileContent.split('\\n')\n let templateStartIndex = 0\n\n // Skip lines until we've passed the original metadata comment section\n for (let i = 0; i < transpiledLines.length; i++) {\n const line = transpiledLines[i].trim()\n // Skip blank lines and comments at the start\n if (line === '' || line.startsWith('//')) {\n continue\n }\n // First non-comment line in transpiled output\n templateStartIndex = i\n break\n }\n\n let template = transpiledLines.slice(templateStartIndex).join('\\n')\n\n // For batch templates, set globalThis['__FIGMA_BATCH'] so the runtime exposes it as\n // figma.batch. Using globalThis rather than a const so it's accessible from\n // __FIGMA_CODE_CONNECT_REQUIRE's closure regardless of where require('figma') is called.\n // (globalThis works in both browser and Node.js, unlike window.)\n if (batchOverrides) {\n template = `globalThis['__FIGMA_BATCH'] = ${JSON.stringify(batchOverrides.batchData)}\\n${template}`\n }\n\n // Apply documentUrlSubstitutions if provided\n if (config?.documentUrlSubstitutions) {\n figmaNodeUrl = applyDocumentUrlSubstitutions(figmaNodeUrl, config.documentUrlSubstitutions)\n }\n\n // Determine effective label from parameter, config, or default\n const effectiveLabel = label || config?.label || CodeConnectLabel.Code\n\n const language = config?.language || getInferredLanguageForRaw(effectiveLabel)\n\n return {\n figmaNode: figmaNodeUrl,\n component,\n template,\n // nestable by default unless user specifies in template\n // (templateData.nestable AND template.metadata.nestable need to\n // be true for instance to be nested)\n templateData: { nestable: true, isParserless: true },\n language,\n label: effectiveLabel,\n source,\n sourceLocation: { line: -1 },\n metadata: {\n cliVersion: require('../../package.json').version,\n },\n }\n}\n"]}
1
+ {"version":3,"file":"raw_templates.js","sourceRoot":"","sources":["../../src/connect/raw_templates.ts"],"names":[],"mappings":";;;;;;AAoCA,sCAaC;AAmKD,oCAqHC;AAzUD,4CAAmB;AACnB,gDAAuB;AACvB,4DAA2B;AAG3B,qEAAsF;AACtF,uCAAyD;AACzD,iEAO+B;AAE/B;;;;;;GAMG;AACH,MAAa,mBAAoB,SAAQ,KAAK;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AALD,kDAKC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,OAAe;IAC3C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE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E,6EAA6E;IAC7E,6BAA6B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEjD,6CAA6C;IAC7C,IAAI,MAAM,EAAE,wBAAwB,EAAE,CAAC;QACrC,YAAY,GAAG,IAAA,uCAA6B,EAAC,YAAY,EAAE,MAAM,CAAC,wBAAwB,CAAC,CAAA;IAC7F,CAAC;IAED,+DAA+D;IAC/D,MAAM,cAAc,GAAG,KAAK,IAAI,MAAM,EAAE,KAAK,IAAI,yCAAgB,CAAC,IAAI,CAAA;IAEtE,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,IAAI,IAAA,kDAAyB,EAAC,cAAc,CAAC,CAAA;IAE9E,OAAO;QACL,SAAS,EAAE,YAAY;QACvB,SAAS;QACT,QAAQ;QACR,wDAAwD;QACxD,gEAAgE;QAChE,qCAAqC;QACrC,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE;QACpD,QAAQ;QACR,KAAK,EAAE,cAAc;QACrB,MAAM;QACN,cAAc,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE;QAC5B,QAAQ,EAAE;YACR,UAAU,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO;SAClD;KACF,CAAA;AACH,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport ts from 'typescript'\nimport { CodeConnectJSON } from './figma_connect'\nimport { CodeConnectConfig } from './project'\nimport { CodeConnectLabel, getInferredLanguageForRaw } from './label_language_mapping'\nimport { applyDocumentUrlSubstitutions } from './helpers'\nimport {\n bundleTemplateWithHelpers,\n allowedHelperExtensions,\n isRelativeImportPath,\n unsupportedImportError,\n relativeRequireError,\n getRequireCallRequest,\n} from './raw_template_bundler'\n\n/**\n * Thrown when a raw template file has no `// url=` directive but contains the\n * string `codeProperties`. These files (e.g. Make's code component property\n * definitions) are not Code Connect, so callers skip them with a log instead of\n * failing. Every other file is handled exactly as before — a missing url is\n * still a hard error.\n */\nexport class CodePropertiesError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'CodePropertiesError'\n }\n}\n\n/**\n * Returns true if the file content looks like a raw template file, i.e. its\n * leading comment block contains a `// url=`, `// component=`, or `// source=`\n * directive. Used to distinguish raw `.figma.ts` templates from React/HTML\n * Code Connect files that share the same extension.\n */\nexport function isRawTemplate(content: string): boolean {\n for (const line of content.split('\\n')) {\n const trimmed = line.trim()\n if (trimmed === '' || trimmed.startsWith('//')) {\n if (/^\\/\\/\\s*(url|component|source)=/.test(trimmed)) {\n return true\n }\n continue\n }\n // First non-comment, non-blank line reached without finding a known directive — not a raw template\n break\n }\n return false\n}\n\n// Convert ESM import of 'figma' to require syntax. Supports: import figma from 'figma'\nconst figmaImportRegex = /^import\\s+figma\\s+from\\s+['\"]figma['\"]\\s*;?\\s*$/m\n\n// Matches the backend's max template size; we fail here rather than let the\n// server reject the publish request.\nconst MAX_TEMPLATE_SIZE_MB = 1\n\nfunction assertTemplateWithinSizeLimit(filePath: string, template: string): void {\n const sizeMb = Buffer.byteLength(template, 'utf-8') / (1024 * 1024)\n if (sizeMb > MAX_TEMPLATE_SIZE_MB) {\n throw new Error(\n `Template \"${filePath}\" is ${sizeMb.toFixed(2)}mb, which exceeds the ` +\n `${MAX_TEMPLATE_SIZE_MB}mb maximum template size. ` +\n `Reduce the template size, for example by removing unneeded helper imports.`,\n )\n }\n}\n\ninterface TypeScriptImportValidationResult {\n hasRelativeHelperImports: boolean\n}\n\n// Parserless entry templates may be authored in TypeScript or JavaScript.\nfunction isRawTemplateSourceFile(filePath: string): boolean {\n return allowedHelperExtensions.some((ext) => filePath.endsWith(ext))\n}\n\n/**\n * Validates a template entry's imports: only the default `figma` import,\n * type-only imports and relative helper imports are allowed. Returns whether\n * the entry imports helpers, so the caller knows whether to bundle.\n */\nfunction validateTypeScriptTemplateImports(\n filePath: string,\n fileContent: string,\n): TypeScriptImportValidationResult {\n const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true)\n let hasRelativeHelperImports = false\n\n for (const statement of sourceFile.statements) {\n if (ts.isImportDeclaration(statement)) {\n if (statement.importClause?.isTypeOnly) {\n continue\n }\n\n const moduleSpecifierText = ts.isStringLiteral(statement.moduleSpecifier)\n ? statement.moduleSpecifier.text\n : ''\n const importLine = statement.getText(sourceFile).split('\\n')[0]?.trim() ?? 'import ...'\n\n if (moduleSpecifierText === 'figma') {\n const hasDefaultImport = !!statement.importClause?.name\n const hasNamedOrNamespaceImport = !!statement.importClause?.namedBindings\n if (!hasDefaultImport || hasNamedOrNamespaceImport) {\n throw unsupportedImportError(filePath, importLine)\n }\n continue\n }\n\n if (isRelativeImportPath(moduleSpecifierText)) {\n hasRelativeHelperImports = true\n continue\n }\n\n throw unsupportedImportError(filePath, importLine)\n }\n\n // Re-exports aren't supported: the runtime only reads the default export.\n if (ts.isExportDeclaration(statement) && statement.moduleSpecifier && !statement.isTypeOnly) {\n const exportLine = statement.getText(sourceFile).split('\\n')[0]?.trim() ?? 'export ...'\n throw new Error(\n `Template files do not support re-exports ('export ... from ...').\\n` +\n `Found in ${filePath}:\\n` +\n ` ${exportLine}\\n\\n` +\n `Import the helper instead (for example: import { helper } from './helpers').`,\n )\n }\n }\n\n // `require` is for the Figma API only: a pure ESM graph is what lets the\n // bundler emit a flat, tree-shaken template. Walking the AST (not the raw\n // text) keeps a `require(...)` inside an emitted snippet from matching.\n const visitRequire = (node: ts.Node): void => {\n const request = getRequireCallRequest(node)\n if (request && request !== 'figma') {\n throw isRelativeImportPath(request)\n ? relativeRequireError(filePath, request)\n : unsupportedImportError(filePath, `require('${request}')`)\n }\n ts.forEachChild(node, visitRequire)\n }\n visitRequire(sourceFile)\n\n return { hasRelativeHelperImports }\n}\n\nfunction transpileTypeScriptTemplate(filePath: string, fileContent: string): string {\n if (figmaImportRegex.test(fileContent)) {\n fileContent = fileContent.replace(figmaImportRegex, \"const figma = require('figma')\")\n }\n\n const result = ts.transpileModule(fileContent, {\n compilerOptions: {\n module: ts.ModuleKind.ESNext,\n target: ts.ScriptTarget.ES2021,\n removeComments: false,\n },\n })\n\n return result.outputText\n}\n\n/**\n * Extracts metadata fields (url, component, source) from the leading comments\n * of a raw template file. This must be done before transpilation because\n * TypeScript can remove comments that appear before type-only imports.\n */\nfunction extractMetadataFields(fileContent: string): {\n fields: { url?: string; component?: string; source?: string }\n templateStartLine: number\n} {\n const lines = fileContent.split('\\n')\n const fields: { url?: string; component?: string; source?: string } = {}\n let templateStartLine = 0\n\n // Parse consecutive comment lines at the start of the file\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i].trim()\n // Match pattern: // fieldName=value\n const match = line.match(/^\\/\\/\\s*(\\w+)=(.+)$/)\n if (match) {\n const [, fieldName, fieldValue] = match\n const normalizedFieldName = fieldName.toLowerCase()\n if (\n normalizedFieldName === 'url' ||\n normalizedFieldName === 'component' ||\n normalizedFieldName === 'source'\n ) {\n fields[normalizedFieldName] = fieldValue.trim()\n }\n templateStartLine = i + 1\n } else if (line === '' || line.startsWith('//')) {\n // Allow blank lines or other comments, but don't increment template start\n continue\n } else {\n // First non-comment line found\n break\n }\n }\n\n return { fields, templateStartLine }\n}\n\nexport interface BatchOverrides {\n url: string\n source?: string\n component?: string\n batchData: Record<string, any>\n batchFilePath: string\n}\n\nexport async function parseRawFile(\n filePath: string,\n label: string | undefined,\n config?: CodeConnectConfig,\n dir?: string,\n batchOverrides?: BatchOverrides,\n): Promise<CodeConnectJSON> {\n let fileContent = fs.readFileSync(filePath, 'utf-8')\n let shouldBundleTypeScriptTemplate = false\n\n // Extract metadata fields BEFORE transpilation to avoid losing comments\n // that appear before type-only imports (which TypeScript erases)\n const { fields, templateStartLine } = extractMetadataFields(fileContent)\n\n const figmaUrl = batchOverrides?.url || fields.url\n\n // Validate imports first, before the `codeProperties` skip guard below, so an\n // unsupported import is always a hard error rather than silently swallowed.\n if (isRawTemplateSourceFile(filePath)) {\n shouldBundleTypeScriptTemplate = validateTypeScriptTemplateImports(\n filePath,\n fileContent,\n ).hasRelativeHelperImports\n }\n\n // A file with no // url= directive that contains the string `codeProperties`\n // is not Code Connect (e.g. Make's code component property definitions). Skip\n // it (callers log and continue) instead of failing. Every other file is\n // handled exactly as before.\n if (!figmaUrl && fileContent.includes('codeProperties')) {\n throw new CodePropertiesError(\n `Skipping ${filePath}: file has no // url= directive and contains \"codeProperties\", so it is not treated as a Code Connect file.`,\n )\n }\n\n // Bundle when helpers are present; otherwise transpile TS and emit JS verbatim.\n // Bundling takes some extra time.\n if (shouldBundleTypeScriptTemplate) {\n // Confining resolution to the project dir\n const projectRoot = dir ? path.resolve(dir) : path.dirname(path.resolve(filePath))\n fileContent = await bundleTemplateWithHelpers(filePath, projectRoot)\n } else if (filePath.endsWith('.ts')) {\n fileContent = transpileTypeScriptTemplate(filePath, fileContent)\n }\n\n // For batch templates, metadata comes from the batch entry instead of comments\n const component = batchOverrides?.component || fields.component\n const source = batchOverrides?.source || fields.source || ''\n\n if (!figmaUrl) {\n throw new Error(\n batchOverrides\n ? `Missing required \"url\" field in ${batchOverrides.batchFilePath}. Please add \"url\" to each entry in your .figma.batch.json file.`\n : `Missing required url field in ${filePath}. Please add a // url=... comment to the top of the file.`,\n )\n }\n let figmaNodeUrl = figmaUrl\n\n // Extract template from the transpiled content, starting at the line\n // where the metadata comments ended in the original source\n const transpiledLines = fileContent.split('\\n')\n let templateStartIndex = 0\n\n // Skip lines until we've passed the original metadata comment section\n for (let i = 0; i < transpiledLines.length; i++) {\n const line = transpiledLines[i].trim()\n // Skip blank lines and comments at the start\n if (line === '' || line.startsWith('//')) {\n continue\n }\n // First non-comment line in transpiled output\n templateStartIndex = i\n break\n }\n\n let template = transpiledLines.slice(templateStartIndex).join('\\n')\n\n // For batch templates, set globalThis['__FIGMA_BATCH'] so the runtime exposes it as\n // figma.batch. Using globalThis rather than a const so it's accessible from\n // __FIGMA_CODE_CONNECT_REQUIRE's closure regardless of where require('figma') is called.\n // (globalThis works in both browser and Node.js, unlike window.)\n if (batchOverrides) {\n template = `globalThis['__FIGMA_BATCH'] = ${JSON.stringify(\n batchOverrides.batchData,\n )}\\n${template}`\n }\n\n // Check the final template (incl. any bundled helpers and batch data) against\n // the backend's size cap so an oversized template fails here, not on upload.\n assertTemplateWithinSizeLimit(filePath, template)\n\n // Apply documentUrlSubstitutions if provided\n if (config?.documentUrlSubstitutions) {\n figmaNodeUrl = applyDocumentUrlSubstitutions(figmaNodeUrl, config.documentUrlSubstitutions)\n }\n\n // Determine effective label from parameter, config, or default\n const effectiveLabel = label || config?.label || CodeConnectLabel.Code\n\n const language = config?.language || getInferredLanguageForRaw(effectiveLabel)\n\n return {\n figmaNode: figmaNodeUrl,\n component,\n template,\n // nestable by default unless user specifies in template\n // (templateData.nestable AND template.metadata.nestable need to\n // be true for instance to be nested)\n templateData: { nestable: true, isParserless: true },\n language,\n label: effectiveLabel,\n source,\n sourceLocation: { line: -1 },\n metadata: {\n cliVersion: require('../../package.json').version,\n },\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/react/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAA;AAmB3B,OAAO,EAAsB,YAAY,EAAoB,MAAM,uBAAuB,CAAA;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,OAAO,EAIL,aAAa,EAQb,YAAY,EACb,MAAM,0BAA0B,CAAA;AAEjC;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,EAAE,CAAC,IAAI,GACZ,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,qBAAqB,GAAG,EAAE,CAAC,WAAW,GAAG,SAAS,CAMvE;AAiED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,0BAanF;AA0ED,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA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tC,QAAQ,EAAE,gDAAuB,CAAC,UAAU;QAC5C,SAAS,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\n | ts.FunctionExpression\n | 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;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,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,SAAS,SAAS,CAAC,IAAa;IAC9B,IAAI,oBAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,IAAI,CAAA;IACb,CAAC;SAAM,CAAC;QACN,OAAO,oBAAE,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IACzC,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,C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;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"]}
@@ -23,6 +23,7 @@ declare module 'figma' {
23
23
  export type SlotSection = { type: 'SLOT'; guid?: string; propertyName: string }
24
24
  export type ErrorSection = { type: 'ERROR'; message: string; errorObject?: unknown }
25
25
  export type ResultSection = CodeSection | InstanceSection | SlotSection | ErrorSection
26
+ export type ResultSectionList = Array<ResultSection | ResultSectionList>
26
27
 
27
28
  export interface TemplateStringResult {
28
29
  sections: ResultSection[]
@@ -99,6 +100,7 @@ declare module 'figma' {
99
100
  name: string
100
101
  }): InstanceHandle | TextHandle | ErrorHandle | null
101
102
  __getPropertyValue__(name: string): string | boolean | ErrorHandle
103
+ __getPropertyValueByType__(name: string, type: string): string | boolean | ErrorHandle
102
104
  __render__(): ResultSection[]
103
105
  __getProps__(): ResultSection[] | Record<string, unknown> | undefined
104
106
  __renderWithFn__(
@@ -192,12 +194,12 @@ declare module 'figma' {
192
194
 
193
195
  helpers: {
194
196
  react: {
195
- renderProp(name: string, prop: FCCValue | ResultSection[]): TemplateStringResult | string
197
+ renderProp(name: string, prop: FCCValue | ResultSectionList): TemplateStringResult | string
196
198
  renderChildren(
197
- prop: FCCValue | ResultSection[],
199
+ prop: FCCValue | ResultSectionList,
198
200
  ): ResultSection[] | string | number | boolean | TemplateStringResult
199
201
  renderPropValue(
200
- prop: FCCValue | ResultSection[],
202
+ prop: FCCValue | ResultSectionList,
201
203
  ): string | number | boolean | ResultSection[]
202
204
  stringifyObject(obj: unknown): string
203
205
  jsxElement(value: string): { $value: string; $type: 'jsx-element' }
@@ -207,17 +209,17 @@ declare module 'figma' {
207
209
  templateString(value: string): { $value: string; $type: 'template-string' }
208
210
  reactComponent(value: string): { $value: string; $type: 'react-component' }
209
211
  array(value: FCCValue[]): { $value: FCCValue[]; $type: 'array' }
210
- isReactComponentArray(prop: unknown): boolean
212
+ isReactComponentArray(prop: unknown): prop is ResultSectionList
211
213
  }
212
214
  swift: {
213
215
  renderChildren(
214
- children: ResultSection[] | string | undefined,
216
+ children: ResultSectionList | string | undefined,
215
217
  prefix: string,
216
218
  ): ResultSection[]
217
219
  }
218
220
  kotlin: {
219
221
  renderChildren(
220
- children: ResultSection[] | string | undefined,
222
+ children: ResultSectionList | string | undefined,
221
223
  prefix: string,
222
224
  ): ResultSection[]
223
225
  }
package/figma-types.d.ts CHANGED
@@ -20,6 +20,7 @@ declare module 'figma' {
20
20
  export type SlotSection = { type: 'SLOT'; guid?: string; propertyName: string }
21
21
  export type ErrorSection = { type: 'ERROR'; message: string; errorObject?: unknown }
22
22
  export type ResultSection = CodeSection | InstanceSection | SlotSection | ErrorSection
23
+ export type ResultSectionList = Array<ResultSection | ResultSectionList>
23
24
 
24
25
  export interface TemplateStringResult {
25
26
  sections: ResultSection[]
@@ -96,6 +97,7 @@ declare module 'figma' {
96
97
  name: string
97
98
  }): InstanceHandle | TextHandle | ErrorHandle | null
98
99
  __getPropertyValue__(name: string): string | boolean | ErrorHandle
100
+ __getPropertyValueByType__(name: string, type: string): string | boolean | ErrorHandle
99
101
  __render__(): ResultSection[]
100
102
  __getProps__(): ResultSection[] | Record<string, unknown> | undefined
101
103
  __renderWithFn__(
@@ -189,12 +191,12 @@ declare module 'figma' {
189
191
 
190
192
  helpers: {
191
193
  react: {
192
- renderProp(name: string, prop: FCCValue | ResultSection[]): TemplateStringResult | string
194
+ renderProp(name: string, prop: FCCValue | ResultSectionList): TemplateStringResult | string
193
195
  renderChildren(
194
- prop: FCCValue | ResultSection[],
196
+ prop: FCCValue | ResultSectionList,
195
197
  ): ResultSection[] | string | number | boolean | TemplateStringResult
196
198
  renderPropValue(
197
- prop: FCCValue | ResultSection[],
199
+ prop: FCCValue | ResultSectionList,
198
200
  ): string | number | boolean | ResultSection[]
199
201
  stringifyObject(obj: unknown): string
200
202
  jsxElement(value: string): { $value: string; $type: 'jsx-element' }
@@ -204,17 +206,17 @@ declare module 'figma' {
204
206
  templateString(value: string): { $value: string; $type: 'template-string' }
205
207
  reactComponent(value: string): { $value: string; $type: 'react-component' }
206
208
  array(value: FCCValue[]): { $value: FCCValue[]; $type: 'array' }
207
- isReactComponentArray(prop: unknown): boolean
209
+ isReactComponentArray(prop: unknown): prop is ResultSectionList
208
210
  }
209
211
  swift: {
210
212
  renderChildren(
211
- children: ResultSection[] | string | undefined,
213
+ children: ResultSectionList | string | undefined,
212
214
  prefix: string,
213
215
  ): ResultSection[]
214
216
  }
215
217
  kotlin: {
216
218
  renderChildren(
217
- children: ResultSection[] | string | undefined,
219
+ children: ResultSectionList | string | undefined,
218
220
  prefix: string,
219
221
  ): ResultSection[]
220
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@figma/code-connect",
3
- "version": "1.4.9",
3
+ "version": "1.5.0",
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",
@@ -81,7 +81,6 @@
81
81
  "@babel/types": "7.28.5",
82
82
 
83
83
 
84
-
85
84
  "@storybook/csf-tools": "8.5.1",
86
85
  "@types/cross-spawn": "^6.0.6",
87
86
  "@types/jest": "^29.5.13",
@@ -110,6 +109,7 @@
110
109
  "compare-versions": "^6.1.0",
111
110
  "cross-spawn": "^7.0.3",
112
111
  "dotenv": "^16.3.1",
112
+ "esbuild-wasm": "0.27.3",
113
113
  "fast-fuzzy": "^1.12.0",
114
114
  "find-up": "^5.0.0",
115
115
  "glob": "^11.0.4",