@figma/code-connect 1.4.8 → 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 (60) 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 +94 -26
  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 +34 -1
  22. package/dist/connect/api.d.ts.map +1 -1
  23. package/dist/connect/api.js.map +1 -1
  24. package/dist/connect/batch_templates.d.ts +1 -1
  25. package/dist/connect/batch_templates.d.ts.map +1 -1
  26. package/dist/connect/batch_templates.js +2 -2
  27. package/dist/connect/batch_templates.js.map +1 -1
  28. package/dist/connect/intrinsics.d.ts +1 -0
  29. package/dist/connect/intrinsics.d.ts.map +1 -1
  30. package/dist/connect/intrinsics.js +29 -0
  31. package/dist/connect/intrinsics.js.map +1 -1
  32. package/dist/connect/migration_batch_helpers.d.ts.map +1 -1
  33. package/dist/connect/migration_batch_helpers.js +1 -15
  34. package/dist/connect/migration_batch_helpers.js.map +1 -1
  35. package/dist/connect/migration_helpers.d.ts +6 -0
  36. package/dist/connect/migration_helpers.d.ts.map +1 -1
  37. package/dist/connect/migration_helpers.js +66 -0
  38. package/dist/connect/migration_helpers.js.map +1 -1
  39. package/dist/connect/parser_executables.d.ts.map +1 -1
  40. package/dist/connect/parser_executables.js +25 -13
  41. package/dist/connect/parser_executables.js.map +1 -1
  42. package/dist/connect/property_combinations.d.ts +69 -0
  43. package/dist/connect/property_combinations.d.ts.map +1 -0
  44. package/dist/connect/property_combinations.js +172 -0
  45. package/dist/connect/property_combinations.js.map +1 -0
  46. package/dist/connect/raw_template_bundler.d.ts +13 -0
  47. package/dist/connect/raw_template_bundler.d.ts.map +1 -0
  48. package/dist/connect/raw_template_bundler.js +178 -0
  49. package/dist/connect/raw_template_bundler.js.map +1 -0
  50. package/dist/connect/raw_templates.d.ts +1 -1
  51. package/dist/connect/raw_templates.d.ts.map +1 -1
  52. package/dist/connect/raw_templates.js +85 -24
  53. package/dist/connect/raw_templates.js.map +1 -1
  54. package/dist/parser_scripts/get_swift_parser_dir.js +5 -5
  55. package/dist/parser_scripts/get_swift_parser_dir.js.map +1 -1
  56. package/dist/react/parser.d.ts.map +1 -1
  57. package/dist/react/parser.js.map +1 -1
  58. package/figma-types-no-require.d.ts +231 -0
  59. package/figma-types.d.ts +19 -8
  60. package/package.json +8 -4
@@ -1 +1 @@
1
- {"version":3,"file":"preview_utils.js","sourceRoot":"","sources":["../../src/commands/preview_utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,sDA0FC;AAKD,0DAWC;AAiBD,oDAqBC;AAMD,kDAcC;AAMD,sCAsBC;AAKD,wCAqCC;AAiMD,sCA0FC;AAtiBD,4CAAmB;AACnB,gDAAuB;AACvB,mDAAoC;AACpC,uCAAkG;AAClG,+CAAyD;AAEzD,sDAAsD;AACtD,gDAAmD;AACnD,8DAAiE;AACjE,2CAAuD;AAoBvD;;;GAGG;AACI,KAAK,UAAU,qBAAqB,CACzC,KAAe,EACf,qBAAwC,EACxC,GAAW,EACX,GAAgB;IAEhB,MAAM,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EAAE,CAAC;gBACrC,MAAM,gBAAgB,GAAG,MAAM,aAAa,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAA;gBAC7E,OAAO,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAA;YACjD,CAAC;YACD,OAAO,MAAM,CAAA;QACf,CAAC,CAAC,CACH,CAAA;QACD,cAAc,CAAC,gBAAgB,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport * as prettier from 'prettier'\nimport { BaseCommand, getCodeConnectObjects, getAccessTokenOrExit, setupHandler } from './connect'\nimport { exitWithError, logger } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { parseFigmaNode } from '../connect/validation'\nimport { getProjectInfo } from '../connect/project'\nimport { getApiUrl, getHeaders } from '../connect/figma_rest_api'\nimport { request, isFetchError } from '../common/fetch'\n\nexport interface NodeToPreview {\n fileKey: string\n nodeId: string\n url: string\n filePath: string\n}\n\nexport interface PreviewResult {\n url: string\n nodeId: string\n filePath: string\n success: boolean\n snippet?: string\n language?: string\n component?: string\n error?: string\n}\n\n/**\n * Collect nodes to preview from file arguments.\n * Matches by exact path first, then by basename.\n */\nexport async function collectNodesToPreview(\n files: string[],\n allCodeConnectObjects: CodeConnectJSON[],\n dir: string,\n cmd: BaseCommand,\n): Promise<NodeToPreview[]> {\n const nodesToPreview: NodeToPreview[] = []\n\n for (const filePath of files) {\n const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(dir, filePath)\n\n // Try exact path first\n if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {\n const docs = allCodeConnectObjects.filter(\n (d) => path.resolve(d._codeConnectFilePath || '') === resolvedPath,\n )\n if (docs.length > 0) {\n if (docs.length === 1) {\n logger.info(`Found: ${filePath}`)\n } else {\n logger.info(`Found ${docs.length} component definition(s) in ${filePath}`)\n }\n for (const doc of docs) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n } else {\n logger.error(`Failed to parse figmaNode from file: ${filePath}`)\n }\n }\n } else {\n logger.error(`Not a valid Code Connect file: ${filePath}`)\n }\n continue\n }\n\n // Fall back to basename matching\n const fileName = path.basename(filePath)\n if (cmd.verbose) {\n logger.debug(`Searching for files matching: ${fileName}`)\n logger.debug(`Total Code Connect objects: ${allCodeConnectObjects.length}`)\n }\n\n const matches = allCodeConnectObjects.filter(\n (d) => path.basename(d._codeConnectFilePath || '') === fileName,\n )\n\n if (matches.length === 0) {\n logger.error(`No files found matching: ${filePath}`)\n continue\n }\n\n if (matches.length === 1) {\n logger.info(`Found: ${matches[0]._codeConnectFilePath}`)\n } else {\n const uniqueFiles = new Set(matches.map((d) => d._codeConnectFilePath))\n if (uniqueFiles.size === 1) {\n logger.info(\n `Found ${matches.length} component definition(s) in ${path.relative(dir, Array.from(uniqueFiles)[0] || '')}`,\n )\n } else {\n logger.info(`Found ${matches.length} component definition(s) in ${uniqueFiles.size} files:`)\n for (const fp of uniqueFiles) {\n const count = matches.filter((d) => d._codeConnectFilePath === fp).length\n logger.info(\n ` - ${path.relative(dir, fp || '')} (${count} definition${count > 1 ? 's' : ''})`,\n )\n }\n }\n }\n\n for (const doc of matches) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n }\n\n return nodesToPreview\n}\n\n/**\n * Filter templates to only those matching the requested node IDs.\n */\nexport function filterTemplatesForNodes(\n nodeIds: string[],\n allTemplates: CodeConnectJSON[],\n): CodeConnectJSON[] {\n return allTemplates.filter((template) => {\n if (!template.figmaNode) return false\n const nodeIdMatch = template.figmaNode.match(/node-id=([^&\\s]+)/)\n if (!nodeIdMatch?.[1]) return false\n const templateNodeId = nodeIdMatch[1].replace(/-/g, ':')\n return nodeIds.includes(templateNodeId)\n })\n}\n\n/**\n * Aliases for Code Connect labels that don't directly match a Prettier language name.\n */\nconst CC_LABEL_ALIASES: Record<string, string> = {\n react: 'typescript',\n code: 'typescript',\n}\n\n/**\n * Map from Code Connect language labels to Prettier parser names,\n * built lazily from Prettier's getSupportInfo() on first access.\n * Lazy to avoid triggering plugin loading at module import time.\n */\nlet _prettierParserMap: Record<string, string> | null = null\n\nexport function getPrettierParserMap(): Record<string, string> {\n if (_prettierParserMap) return _prettierParserMap\n\n const info = prettier.getSupportInfo() as {\n languages: Array<{ name: string; parsers?: string[] }>\n }\n _prettierParserMap = {}\n\n for (const lang of info.languages) {\n if (lang.parsers?.[0]) {\n _prettierParserMap[lang.name.toLowerCase()] = lang.parsers[0]\n }\n }\n\n for (const [alias, target] of Object.entries(CC_LABEL_ALIASES)) {\n if (_prettierParserMap[target]) {\n _prettierParserMap[alias] = _prettierParserMap[target]\n }\n }\n\n return _prettierParserMap\n}\n\n/**\n * Check if a snippet can be parsed by Prettier.\n * Returns true for languages without a Prettier parser (nothing to validate).\n */\nexport async function isPrettierParseable(snippet: string, language?: string): Promise<boolean> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return true\n }\n\n try {\n await prettier.format(snippet, { parser })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Format snippet with Prettier.\n * Returns the snippet unmodified for languages Prettier doesn't support.\n */\nexport async function formatSnippet(snippet: string, language?: string): Promise<string> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return snippet\n }\n\n try {\n let formatted = await prettier.format(snippet, {\n parser,\n semi: false,\n singleQuote: true,\n printWidth: 80,\n tabWidth: 2,\n })\n formatted = formatted.replace(/^;\\s*/, '')\n return formatted\n } catch {\n logger.info(`Autoformatting couldn't be applied: language not supported or code is malformed`)\n return snippet\n }\n}\n\n/**\n * Display results with terminal colors\n */\nexport function displayResults(results: PreviewResult[]): void {\n console.log('')\n const successCount = results.filter((r) => r.success).length\n const errorCount = results.filter((r) => !r.success).length\n\n const purple = '\\x1b[38;5;93m'\n const red = '\\x1b[38;5;196m'\n const gray = '\\x1b[38;5;243m'\n const reset = '\\x1b[0m'\n const bold = '\\x1b[1m'\n\n for (const result of results) {\n if (result.success && result.snippet) {\n const componentInfo = result.component ? ` ${gray}→ ${result.component}${reset}` : ''\n console.log(`${purple}●${reset} ${bold}${result.filePath}${reset}${componentInfo}`)\n console.log(` ${gray}${result.url}${reset}`)\n console.log('')\n\n const indentedSnippet = result.snippet\n .trim()\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n console.log(indentedSnippet)\n console.log('')\n } else {\n const componentInfo = result.component ? ` ${gray}(${result.component})${reset}` : ''\n console.log(`${red}✕${reset} ${bold}${result.filePath}${reset}${componentInfo}`)\n console.log(` ${gray}${result.url}${reset}`)\n console.log(` ${red}Error:${reset} ${result.error}`)\n console.log('')\n }\n }\n\n console.log(\n `${bold}Summary:${reset} ${purple}${successCount} succeeded${reset}, ${errorCount > 0 ? `${red}${errorCount} failed${reset}` : `${gray}${errorCount} failed${reset}`}`,\n )\n}\n\n// The server caps inbound request bodies at 5MB. The figmaDocs payload\n// (one Code Connect template per requested component) dominates the body size,\n// so for projects with many components we split into smaller chunks and send\n// them in parallel rather than risking a 413.\nconst PREVIEW_CHUNK_SIZE = 50\n// Bound the number of chunks in flight at once. Without this cap, large\n// libraries (~1k+ components) trigger N parallel preview requests, which\n// overwhelms upstream token validation and causes spurious 403 \"Invalid\n// token\" responses for the chunks that queue up too long.\nconst PREVIEW_MAX_CONCURRENCY = 5\n\ntype PreviewResponseData = {\n status: number\n error: boolean\n meta: {\n results: Array<{\n nodeId: string\n nodeUrl: string\n snippet?: string\n language?: string\n component?: string\n error?: string\n }>\n }\n}\n\ntype ChunkOutcome = {\n chunkNodeIds: string[]\n response: Awaited<ReturnType<typeof request.post<PreviewResponseData>>> | null\n error: unknown\n}\n\nfunction chunkArray<T>(arr: T[], size: number): T[][] {\n const chunks: T[][] = []\n for (let i = 0; i < arr.length; i += size) {\n chunks.push(arr.slice(i, i + size))\n }\n return chunks\n}\n\nasync function runInWaves<T, R>(\n items: T[],\n fn: (item: T) => Promise<R>,\n maxConcurrency: number,\n): Promise<R[]> {\n const out: R[] = []\n for (let i = 0; i < items.length; i += maxConcurrency) {\n const wave = items.slice(i, i + maxConcurrency)\n const settled = await Promise.all(wave.map(fn))\n out.push(...settled)\n }\n return out\n}\n\nfunction sendPreviewChunk({\n chunkNodeIds,\n requiredTemplates,\n baseApiUrl,\n fileKey,\n accessToken,\n}: {\n chunkNodeIds: string[]\n requiredTemplates: CodeConnectJSON[]\n baseApiUrl: string\n fileKey: string\n accessToken: string\n}): Promise<ChunkOutcome> {\n const chunkTemplates = filterTemplatesForNodes(chunkNodeIds, requiredTemplates)\n return request\n .post<PreviewResponseData>(\n `${baseApiUrl}/code_connect/preview_snippets?file_key=${fileKey}`,\n { nodeIds: chunkNodeIds, figmaDocs: { all: chunkTemplates } },\n { headers: getHeaders(accessToken) },\n )\n .then((response) => ({ chunkNodeIds, response, error: null as unknown }))\n .catch((err: unknown) => ({ chunkNodeIds, response: null, error: err }))\n}\n\nfunction chunkOutcomeToResults(\n outcome: ChunkOutcome,\n nodes: NodeToPreview[],\n fileKey: string,\n): PreviewResult[] {\n const { chunkNodeIds, response, error } = outcome\n const results: PreviewResult[] = []\n\n if (error) {\n const errorMsg = isFetchError(error)\n ? error.data?.message || error.response.statusText\n : String(error)\n // 503 means the server-side killswitch is on — surface the server's\n // message directly without the per-file/per-node noise so the user\n // sees a single clear line during an incident.\n if (isFetchError(error) && error.response.status === 503) {\n exitWithError(errorMsg)\n } else {\n logger.error(`Failed to preview components in file ${fileKey}: ${errorMsg}`)\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error: errorMsg,\n })\n }\n }\n }\n return results\n }\n\n if (response!.response.status === 200 && response!.data.meta?.results) {\n // Track match index per nodeId so duplicate node IDs get the correct file attribution.\n // The server returns results in the same order as the templates we sent. Each chunk's\n // nodeIds are disjoint (we dedupe before chunking), so per-chunk indexing is correct.\n const nodeMatchIndex: Record<string, number> = {}\n for (const result of response!.data.meta.results) {\n const idx = nodeMatchIndex[result.nodeId] ?? 0\n const matchingNodes = nodes.filter((n) => n.nodeId === result.nodeId)\n const node = matchingNodes[idx] || matchingNodes[0]\n nodeMatchIndex[result.nodeId] = idx + 1\n results.push({\n url: node?.url || result.nodeUrl,\n nodeId: result.nodeId,\n filePath: node?.filePath || '',\n success: !result.error && !!result.snippet,\n snippet: result.snippet,\n language: result.language,\n component: result.component,\n error: result.error || (!result.snippet ? 'No snippet returned by server' : undefined),\n })\n }\n return results\n }\n\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error: `API request failed with status ${response!.response.status}`,\n })\n }\n }\n return results\n}\n\nasync function previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n}: {\n fileKey: string\n nodes: NodeToPreview[]\n baseApiUrl: string\n accessToken: string\n dir: string\n allCodeConnectObjects: CodeConnectJSON[]\n}): Promise<PreviewResult[]> {\n const allNodeIds = nodes.map((n) => n.nodeId)\n // Deduplicate — multiple figma.connect() calls may share the same nodeId;\n // the individual templates are sent in figmaDocs and the server iterates per-template.\n const nodeIds = [...new Set(allNodeIds)]\n\n // Only send templates from the requested files — other files' templates\n // for the same nodeId exist on the server and shouldn't be rendered individually.\n const requestedFilePaths = new Set(nodes.map((n) => path.resolve(dir, n.filePath)))\n const requiredTemplates = filterTemplatesForNodes(allNodeIds, allCodeConnectObjects).filter((t) =>\n requestedFilePaths.has(path.resolve(t._codeConnectFilePath || '')),\n )\n\n const chunks = chunkArray(nodeIds, PREVIEW_CHUNK_SIZE)\n const outcomes = await runInWaves(\n chunks,\n (chunkNodeIds) =>\n sendPreviewChunk({ chunkNodeIds, requiredTemplates, baseApiUrl, fileKey, accessToken }),\n PREVIEW_MAX_CONCURRENCY,\n )\n\n return outcomes.flatMap((outcome) => chunkOutcomeToResults(outcome, nodes, fileKey))\n}\n\n/**\n * Handle the preview command\n */\nexport async function handlePreview(files: string[], cmd: BaseCommand & { output?: string }) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = await getProjectInfo(dir, cmd.config)\n const accessToken = getAccessTokenOrExit(cmd)\n const outputFormat = cmd.output || 'table'\n\n const allCodeConnectObjects = await getCodeConnectObjects(cmd, projectInfo, true)\n\n let nodesToCheck: NodeToPreview[]\n\n if (files && files.length > 0) {\n nodesToCheck = await collectNodesToPreview(files, allCodeConnectObjects, dir, cmd)\n } else {\n logger.info('Previewing all local Code Connect files...')\n nodesToCheck = []\n for (const doc of allCodeConnectObjects) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToCheck.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n }\n\n if (nodesToCheck.length === 0) {\n exitWithError('No valid Code Connect files found to preview')\n }\n\n logger.info(`Previewing ${nodesToCheck.length} component(s)...`)\n\n // Group nodes by fileKey for batching\n const nodesByFileKey: Record<string, NodeToPreview[]> = {}\n for (const node of nodesToCheck) {\n if (!nodesByFileKey[node.fileKey]) {\n nodesByFileKey[node.fileKey] = []\n }\n nodesByFileKey[node.fileKey].push(node)\n }\n\n const results: PreviewResult[] = []\n\n for (const [fileKey, nodes] of Object.entries(nodesByFileKey)) {\n const baseApiUrl = getApiUrl(nodes[0].url, cmd.apiUrl || projectInfo.config.apiUrl)\n const fileResults = await previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n })\n results.push(...fileResults)\n }\n\n // Validate snippet syntax\n for (const result of results) {\n if (result.success && result.snippet) {\n const prettierValid = await isPrettierParseable(result.snippet, result.language)\n if (!prettierValid) {\n // Prettier can parse this language but failed — mark as error\n result.success = false\n result.error = 'Snippet has syntax errors and may not be valid code'\n }\n }\n }\n\n if (outputFormat === 'json') {\n console.log(JSON.stringify(results, null, 2))\n } else {\n const formattedResults: PreviewResult[] = await Promise.all(\n results.map(async (result) => {\n if (result.success && result.snippet) {\n const formattedSnippet = await formatSnippet(result.snippet, result.language)\n return { ...result, snippet: formattedSnippet }\n }\n return result\n }),\n )\n displayResults(formattedResults)\n }\n\n if (results.every((r) => !r.success)) {\n process.exit(1)\n }\n}\n"]}
1
+ {"version":3,"file":"preview_utils.js","sourceRoot":"","sources":["../../src/commands/preview_utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,sDA0FC;AAqED,8EAqBC;AA0BD,sCAmBC;AAKD,0DAWC;AAiBD,oDAqBC;AAMD,kDAcC;AAMD,sCAsBC;AAUD,wCA0DC;AAgBD,0DAYC;AA6CD,wDA4BC;AA8DD,oDAKC;AAkBD,sDAmGC;AAsTD,sCAoEC;AA1lCD,4CAAmB;AACnB,gDAAuB;AACvB,kDAAyB;AACzB,mDAAoC;AACpC,uCAAkG;AAClG,+CAAyD;AAEzD,sDAAsD;AACtD,gDAAmD;AACnD,8DAA+E;AAC/E,2CAAuD;AACvD,+D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AAC,YAAY,CAAC,CAAA;IAExD,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAChB,MAAM,aAAa,CAAC;YAClB,cAAc;YACd,gBAAgB;YAChB,WAAW;YACX,YAAY;SACb,CAAC,CAAA;QACF,OAAM;IACR,CAAC;IAED,sBAAsB,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,eAAe,GAAG,uBAAuB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IACpE,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAEnE,MAAM,OAAO,GAAoB,EAAE,CAAA;IACnC,KAAK,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;QAC9D,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC;YAC5C,OAAO;YACP,KAAK;YACL,gBAAgB;YAChB,WAAW;YACX,GAAG;YACH,qBAAqB;YACrB,0BAA0B,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,UAAU;YACnD,UAAU;YACV,eAAe;SAChB,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAA;IAC9B,CAAC;IAED,MAAM,wBAAwB,CAAC,OAAO,CAAC,CAAA;IACvC,MAAM,oBAAoB,CAAC,OAAO,EAAE,YAAY,CAAC,CAAA;IAEjD,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC;QACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC","sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport chalk from 'chalk'\nimport * as prettier from 'prettier'\nimport { BaseCommand, getCodeConnectObjects, getAccessTokenOrExit, setupHandler } from './connect'\nimport { exitWithError, logger } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { parseFigmaNode } from '../connect/validation'\nimport { getProjectInfo } from '../connect/project'\nimport { getApiUrl, getHeaders, FigmaRestApi } from '../connect/figma_rest_api'\nimport { request, isFetchError } from '../common/fetch'\nimport { displayPropertyList, type PropertyListItem } from './property_list_table'\nimport {\n enumeratePropertyCombinations,\n buildPropertyCombinationFromProps,\n toAvailableProperties,\n type PropertyCombination,\n type AvailableProperty,\n} from '../connect/property_combinations'\n\ntype PreviewCommand = BaseCommand & { output?: string }\n\nexport interface NodeToPreview {\n fileKey: string\n nodeId: string\n url: string\n filePath: string\n}\n\nexport interface PreviewResult {\n url: string\n nodeId: string\n filePath: string\n success: boolean\n snippet?: string\n language?: string\n component?: string\n error?: string\n /** Present when this result is one property combination of an expanded (--all) render. */\n propertyCombinationLabel?: string\n /** `kind: \"transport\"` marks a server/network failure, in which case no property vocabulary is attached. */\n errorDetails?: {\n kind?: string\n missingProperty?: string\n availableProperties?: AvailableProperty[]\n }\n /** Nested instances/slots that rendered as placeholders. Not an error — the snippet still rendered. */\n unresolvedInstances?: Array<{ guid: string; name?: string; kind: 'instance' | 'slot' }>\n}\n\ntype NodesByFileKey = Record<string, NodeToPreview[]>\n\n/**\n * Collect nodes to preview from file arguments.\n * Matches by exact path first, then by basename.\n */\nexport async function collectNodesToPreview(\n files: string[],\n allCodeConnectObjects: CodeConnectJSON[],\n dir: string,\n cmd: BaseCommand,\n): Promise<NodeToPreview[]> {\n const nodesToPreview: NodeToPreview[] = []\n\n for (const filePath of files) {\n const resolvedPath = path.isAbsolute(filePath) ? filePath : path.resolve(dir, filePath)\n\n // Try exact path first\n if (fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile()) {\n const docs = allCodeConnectObjects.filter(\n (d) => path.resolve(d._codeConnectFilePath || '') === resolvedPath,\n )\n if (docs.length > 0) {\n if (docs.length === 1) {\n logger.info(`Found: ${filePath}`)\n } else {\n logger.info(`Found ${docs.length} component definition(s) in ${filePath}`)\n }\n for (const doc of docs) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n } else {\n logger.error(`Failed to parse figmaNode from file: ${filePath}`)\n }\n }\n } else {\n logger.error(`Not a valid Code Connect file: ${filePath}`)\n }\n continue\n }\n\n // Fall back to basename matching\n const fileName = path.basename(filePath)\n if (cmd.verbose) {\n logger.debug(`Searching for files matching: ${fileName}`)\n logger.debug(`Total Code Connect objects: ${allCodeConnectObjects.length}`)\n }\n\n const matches = allCodeConnectObjects.filter(\n (d) => path.basename(d._codeConnectFilePath || '') === fileName,\n )\n\n if (matches.length === 0) {\n logger.error(`No files found matching: ${filePath}`)\n continue\n }\n\n if (matches.length === 1) {\n logger.info(`Found: ${matches[0]._codeConnectFilePath}`)\n } else {\n const uniqueFiles = new Set(matches.map((d) => d._codeConnectFilePath))\n if (uniqueFiles.size === 1) {\n logger.info(\n `Found ${matches.length} component definition(s) in ${path.relative(dir, Array.from(uniqueFiles)[0] || '')}`,\n )\n } else {\n logger.info(`Found ${matches.length} component definition(s) in ${uniqueFiles.size} files:`)\n for (const fp of uniqueFiles) {\n const count = matches.filter((d) => d._codeConnectFilePath === fp).length\n logger.info(\n ` - ${path.relative(dir, fp || '')} (${count} definition${count > 1 ? 's' : ''})`,\n )\n }\n }\n }\n\n for (const doc of matches) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToPreview.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n }\n\n return nodesToPreview\n}\n\n/**\n * Outcome of fetching a component's property definitions.\n * - `ok`: definitions were found (includes VARIANT axes).\n * - `empty`: the node was fetched successfully but exposes no properties/variants\n * (e.g. a component with no variant axes or component properties, or a plain\n * frame). This is not an error — there is simply nothing to vary.\n * - `error`: the fetch failed (network / non-200), e.g. the token is missing a\n * required scope (Code Connect: Write and File content: Read).\n */\nexport type ComponentPropertyDefinitionsResult =\n | { status: 'ok'; defs: Record<string, FigmaRestApi.ComponentPropertyDefinition> }\n | { status: 'empty' }\n | { status: 'error' }\n\n/** A single node's schema plus its parent COMPONENT_SET id (set only for a variant child). */\ntype NodeSchemaResult =\n | {\n status: 'ok'\n defs: Record<string, FigmaRestApi.ComponentPropertyDefinition>\n componentSetId?: string\n }\n | { status: 'empty'; componentSetId?: string }\n | { status: 'error' }\n\n/**\n * Fetch one node's property definitions from the REST `files/:key/nodes` endpoint.\n */\nasync function fetchNodeSchema(\n baseApiUrl: string,\n fileKey: string,\n nodeId: string,\n accessToken: string,\n): Promise<NodeSchemaResult> {\n try {\n const nodesUrl = `${baseApiUrl}/files/${fileKey}/nodes?ids=${nodeId}`\n const resp = await request.get<{\n nodes: Record<\n string,\n {\n document?: {\n componentPropertyDefinitions?: Record<string, FigmaRestApi.ComponentPropertyDefinition>\n }\n // Per-node component metadata; a variant member carries its parent set id here.\n components?: Record<string, { componentSetId?: string }>\n }\n >\n }>(nodesUrl, { headers: getHeaders(accessToken) })\n if (resp.response.status !== 200) {\n logger.debug(`files/nodes returned ${resp.response.status} for ${nodeId}`)\n return { status: 'error' }\n }\n const node = resp.data.nodes?.[nodeId]\n const componentSetId = node?.components?.[nodeId]?.componentSetId || undefined\n const defs = node?.document?.componentPropertyDefinitions\n if (defs && Object.keys(defs).length > 0) return { status: 'ok', defs, componentSetId }\n logger.debug(`files/nodes returned no componentPropertyDefinitions for ${nodeId}`)\n return { status: 'empty', componentSetId }\n } catch (err) {\n const detail = isFetchError(err) ? `status ${err.response?.status}` : String(err)\n logger.debug(`files/nodes fetch failed for ${nodeId} (${detail})`)\n return { status: 'error' }\n }\n}\n\n/**\n * Fetch a component's property definitions from the REST `files/:key/nodes` endpoint.\n */\nexport async function fetchComponentPropertyDefinitions(\n baseApiUrl: string,\n fileKey: string,\n nodeId: string,\n accessToken: string,\n): Promise<ComponentPropertyDefinitionsResult> {\n const node = await fetchNodeSchema(baseApiUrl, fileKey, nodeId, accessToken)\n if (node.status === 'error') return { status: 'error' }\n\n // Variant child → resolve to the parent COMPONENT_SET (whose schema carries the\n // variant axes). Fall back to the variant's own defs if the set can't be fetched.\n if (node.componentSetId) {\n const set = await fetchNodeSchema(baseApiUrl, fileKey, node.componentSetId, accessToken)\n if (set.status === 'ok') return { status: 'ok', defs: set.defs }\n logger.debug(\n `Component set ${node.componentSetId} for variant ${nodeId} had no usable schema ` +\n `(${set.status}); using the variant's own definitions`,\n )\n }\n\n return node.status === 'ok' ? { status: 'ok', defs: node.defs } : { status: 'empty' }\n}\n\n/** Case-insensitive lookup of a `ComponentPropertyType` from a `--props` prefix token. */\nfunction parsePropertyTypePrefix(token: string): FigmaRestApi.ComponentPropertyType | undefined {\n const upper = token.trim().toUpperCase()\n return (Object.values(FigmaRestApi.ComponentPropertyType) as string[]).includes(upper)\n ? (upper as FigmaRestApi.ComponentPropertyType)\n : undefined\n}\n\ntype ParsedPropertyPair = {\n name: string\n value: string\n type?: FigmaRestApi.ComponentPropertyType\n}\n\n/**\n * Parse a single `--props` argument into a name/value pair, with an optional\n * `TYPE:` prefix to disambiguate properties that share a name but differ in\n * type (e.g. a BOOLEAN and a TEXT property both named `textMsg`).\n * Example: --props Variant=Primary \"Has Icon=true\" \"BOOLEAN:textMsg=false\"\n *\n * The prefix is only recognized when the token before the first `:` matches a\n * known property type (case-insensitive); otherwise the whole name-part is kept\n * as the property name, so real names containing `:` are preserved.\n */\nexport function parsePropsArg(props: string[]): ParsedPropertyPair[] {\n return props\n .flatMap((arg) => arg.split(','))\n .map((pair) => pair.trim())\n .filter((pair) => pair.length > 0)\n .map((pair) => {\n const eq = pair.indexOf('=')\n const namePart = (eq === -1 ? pair : pair.slice(0, eq)).trim()\n const value = eq === -1 ? '' : pair.slice(eq + 1).trim()\n\n const colon = namePart.indexOf(':')\n if (colon !== -1) {\n const type = parsePropertyTypePrefix(namePart.slice(0, colon))\n if (type) {\n return { name: namePart.slice(colon + 1).trim(), value, type }\n }\n }\n return { name: namePart, value }\n })\n}\n\n/**\n * Filter templates to only those matching the requested node IDs.\n */\nexport function filterTemplatesForNodes(\n nodeIds: string[],\n allTemplates: CodeConnectJSON[],\n): CodeConnectJSON[] {\n return allTemplates.filter((template) => {\n if (!template.figmaNode) return false\n const nodeIdMatch = template.figmaNode.match(/node-id=([^&\\s]+)/)\n if (!nodeIdMatch?.[1]) return false\n const templateNodeId = nodeIdMatch[1].replace(/-/g, ':')\n return nodeIds.includes(templateNodeId)\n })\n}\n\n/**\n * Aliases for Code Connect labels that don't directly match a Prettier language name.\n */\nconst CC_LABEL_ALIASES: Record<string, string> = {\n react: 'typescript',\n code: 'typescript',\n}\n\n/**\n * Map from Code Connect language labels to Prettier parser names,\n * built lazily from Prettier's getSupportInfo() on first access.\n * Lazy to avoid triggering plugin loading at module import time.\n */\nlet _prettierParserMap: Record<string, string> | null = null\n\nexport function getPrettierParserMap(): Record<string, string> {\n if (_prettierParserMap) return _prettierParserMap\n\n const info = prettier.getSupportInfo() as {\n languages: Array<{ name: string; parsers?: string[] }>\n }\n _prettierParserMap = {}\n\n for (const lang of info.languages) {\n if (lang.parsers?.[0]) {\n _prettierParserMap[lang.name.toLowerCase()] = lang.parsers[0]\n }\n }\n\n for (const [alias, target] of Object.entries(CC_LABEL_ALIASES)) {\n if (_prettierParserMap[target]) {\n _prettierParserMap[alias] = _prettierParserMap[target]\n }\n }\n\n return _prettierParserMap\n}\n\n/**\n * Check if a snippet can be parsed by Prettier.\n * Returns true for languages without a Prettier parser (nothing to validate).\n */\nexport async function isPrettierParseable(snippet: string, language?: string): Promise<boolean> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return true\n }\n\n try {\n await prettier.format(snippet, { parser })\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Format snippet with Prettier.\n * Returns the snippet unmodified for languages Prettier doesn't support.\n */\nexport async function formatSnippet(snippet: string, language?: string): Promise<string> {\n const lang = language?.toLowerCase()\n const parser = lang ? getPrettierParserMap()[lang] : 'typescript'\n\n if (!parser) {\n return snippet\n }\n\n try {\n let formatted = await prettier.format(snippet, {\n parser,\n semi: false,\n singleQuote: true,\n printWidth: 80,\n tabWidth: 2,\n })\n formatted = formatted.replace(/^;\\s*/, '')\n return formatted\n } catch {\n logger.info(`Autoformatting couldn't be applied: language not supported or code is malformed`)\n return snippet\n }\n}\n\n/**\n * Display results with terminal colors\n */\nconst purple = chalk.ansi256(93)\nconst red = chalk.ansi256(196)\nconst gray = chalk.ansi256(243)\nconst yellow = chalk.ansi256(179)\n\nexport function displayResults(results: PreviewResult[]): void {\n console.log('')\n const successCount = results.filter((r) => r.success).length\n const errorCount = results.filter((r) => !r.success).length\n\n // A muted note when nested children rendered as placeholders (not an error).\n const printUnresolved = (result: PreviewResult) => {\n if (!result.unresolvedInstances?.length) return\n const names = result.unresolvedInstances.map((u) => u.name || u.guid).join(', ')\n console.log(\n ` ${yellow(`⚠ ${result.unresolvedInstances.length} nested instance(s) not Code Connected: ${names}`)}`,\n )\n }\n\n for (const result of results) {\n // When expanding property combinations, label the header with the specific combination.\n const combinationSuffix = result.propertyCombinationLabel\n ? ` ${gray(`— ${result.propertyCombinationLabel}`)}`\n : ''\n if (result.success && result.snippet) {\n const componentInfo = result.component ? ` ${gray(`→ ${result.component}`)}` : ''\n console.log(\n `${purple('●')} ${chalk.bold(result.filePath)}${componentInfo}${combinationSuffix}`,\n )\n console.log(` ${gray(result.url)}`)\n console.log('')\n\n const indentedSnippet = result.snippet\n .trim()\n .split('\\n')\n .map((line) => ' ' + line)\n .join('\\n')\n console.log(indentedSnippet)\n printUnresolved(result)\n console.log('')\n } else {\n const componentInfo = result.component ? ` ${gray(`(${result.component})`)}` : ''\n console.log(`${red('✕')} ${chalk.bold(result.filePath)}${componentInfo}${combinationSuffix}`)\n console.log(` ${gray(result.url)}`)\n console.log(` ${red('Error:')} ${result.error}`)\n // One-line repair hint: the offending property and the real vocabulary.\n // (Transport errors carry no vocabulary — nothing to hint.)\n const available = result.errorDetails?.availableProperties?.map((p) => p.name).join(', ')\n const missingProperty = result.errorDetails?.missingProperty\n if (missingProperty && available) {\n console.log(\n ` ${gray(`property \"${missingProperty}\" not found — available: ${available}`)}`,\n )\n } else if (available) {\n console.log(` ${gray(`available properties: ${available}`)}`)\n }\n printUnresolved(result)\n console.log('')\n }\n }\n\n const failed = errorCount > 0 ? red(`${errorCount} failed`) : gray(`${errorCount} failed`)\n console.log(`${chalk.bold('Summary:')} ${purple(`${successCount} succeeded`)}, ${failed}`)\n}\n\n// The server caps inbound request bodies at 5MB. The figmaDocs payload\n// (one Code Connect template per requested component) dominates the body size,\n// so for projects with many components we split into smaller chunks and send\n// them in parallel rather than risking a 413.\nconst PREVIEW_CHUNK_SIZE = 50\n// Bound the number of chunks in flight at once. Without this cap, large\n// libraries (~1k+ components) trigger N parallel preview requests, which\n// overwhelms upstream token validation and causes spurious 403 \"Invalid\n// token\" responses for the chunks that queue up too long.\nconst PREVIEW_MAX_CONCURRENCY = 5\n// Mirrors MAX_PROPERTY_COMBINATIONS_PER_REQUEST in pixie/code_connect_preview_handler.ts.\n// `--all` caps enumeration here and warns rather than sending a request that fails wholesale.\nconst MAX_PROPERTY_COMBINATIONS = 500\n\nexport function parseMaxCombinationsArg(value: string | undefined): number {\n if (value === undefined) {\n return MAX_PROPERTY_COMBINATIONS\n }\n const parsed = Number(value)\n if (!Number.isInteger(parsed) || parsed < 1) {\n exitWithError('--max-combinations must be a positive integer')\n }\n if (parsed > MAX_PROPERTY_COMBINATIONS) {\n exitWithError(`--max-combinations cannot exceed ${MAX_PROPERTY_COMBINATIONS}`)\n }\n return parsed\n}\n\ntype PreviewResponseData = {\n status: number\n error: boolean\n meta: {\n results: Array<{\n nodeId: string\n nodeUrl: string\n snippet?: string\n language?: string\n component?: string\n error?: string\n propertyCombinationLabel?: string\n errorKind?: string\n unresolvedInstances?: Array<{ guid: string; name?: string; kind: 'instance' | 'slot' }>\n }>\n }\n}\n\ntype ChunkOutcome = {\n chunkNodeIds: string[]\n response: Awaited<ReturnType<typeof request.post<PreviewResponseData>>> | null\n error: unknown\n}\n\nfunction chunkArray<T>(arr: T[], size: number): T[][] {\n const chunks: T[][] = []\n for (let i = 0; i < arr.length; i += size) {\n chunks.push(arr.slice(i, i + size))\n }\n return chunks\n}\n\n/**\n * Split node IDs into request chunks that respect BOTH the node-count cap\n * (PREVIEW_CHUNK_SIZE) and, when rendering property combinations, the server's\n * per-request combination cap (MAX_PROPERTY_COMBINATIONS).\n *\n * The server sums combinations across every node in a request and rejects the\n * whole request if the total exceeds the cap, so bundling by node count alone\n * can push several individually-valid nodes over the limit and fail them all.\n * Each node is already truncated to <= MAX_PROPERTY_COMBINATIONS upstream, so a\n * single node always fits (worst case: one node per chunk).\n */\nexport function chunkNodeIdsForPreview(\n nodeIds: string[],\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>,\n): string[][] {\n if (!propertyCombinationsByNodeId) {\n return chunkArray(nodeIds, PREVIEW_CHUNK_SIZE)\n }\n\n const chunks: string[][] = []\n let current: string[] = []\n let currentCombinations = 0\n for (const nodeId of nodeIds) {\n const count = propertyCombinationsByNodeId[nodeId]?.length ?? 0\n // Close the current chunk before adding this node would breach either cap.\n if (\n current.length > 0 &&\n (current.length >= PREVIEW_CHUNK_SIZE ||\n currentCombinations + count > MAX_PROPERTY_COMBINATIONS)\n ) {\n chunks.push(current)\n current = []\n currentCombinations = 0\n }\n current.push(nodeId)\n currentCombinations += count\n }\n if (current.length > 0) chunks.push(current)\n return chunks\n}\n\nasync function runInWaves<T, R>(\n items: T[],\n fn: (item: T) => Promise<R>,\n maxConcurrency: number,\n): Promise<R[]> {\n const out: R[] = []\n for (let i = 0; i < items.length; i += maxConcurrency) {\n const wave = items.slice(i, i + maxConcurrency)\n const settled = await Promise.all(wave.map(fn))\n out.push(...settled)\n }\n return out\n}\n\nfunction sendPreviewChunk({\n chunkNodeIds,\n requiredTemplates,\n baseApiUrl,\n fileKey,\n accessToken,\n propertyCombinationsByNodeId,\n}: {\n chunkNodeIds: string[]\n requiredTemplates: CodeConnectJSON[]\n baseApiUrl: string\n fileKey: string\n accessToken: string\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n}): Promise<ChunkOutcome> {\n const chunkTemplates = filterTemplatesForNodes(chunkNodeIds, requiredTemplates)\n // Only include property combinations for the node IDs in this chunk.\n let renderCombinations: Record<string, PropertyCombination[]> | undefined\n if (propertyCombinationsByNodeId) {\n renderCombinations = {}\n for (const nodeId of chunkNodeIds) {\n if (propertyCombinationsByNodeId[nodeId]) {\n renderCombinations[nodeId] = propertyCombinationsByNodeId[nodeId]\n }\n }\n }\n return request\n .post<PreviewResponseData>(\n `${baseApiUrl}/code_connect/preview_snippets?file_key=${fileKey}`,\n {\n nodeIds: chunkNodeIds,\n figmaDocs: { all: chunkTemplates },\n ...(renderCombinations && Object.keys(renderCombinations).length > 0\n ? { renderCombinations }\n : {}),\n },\n { headers: getHeaders(accessToken) },\n )\n .then((response) => ({ chunkNodeIds, response, error: null as unknown }))\n .catch((err: unknown) => ({ chunkNodeIds, response: null, error: err }))\n}\n\n/**\n * Parse the offending property name out of a \"property not found\" render error,\n * e.g. `PropertyNotFoundError: property 'Varient' not found` -> `Varient`.\n */\nexport function parseMissingProperty(error?: string): string | undefined {\n if (!error) return undefined\n const match =\n error.match(/propert(?:y|ies)[^'\"`]*['\"`]([^'\"`]+)['\"`]/i) ?? error.match(/['\"`]([^'\"`]+)['\"`]/)\n return match?.[1]\n}\n\n/** Build `errorDetails` for a failed result. Undefined when there's no property context (not --all). */\nfunction buildErrorDetails(\n error: string | undefined,\n errorKind: string | undefined,\n availableProperties: AvailableProperty[] | undefined,\n): PreviewResult['errorDetails'] {\n // Transport failure: network/backend problem, not a bad property — carry only the kind.\n if (errorKind === 'transport') return { kind: 'transport' }\n if (!availableProperties) return undefined\n const details: NonNullable<PreviewResult['errorDetails']> = { availableProperties }\n if (errorKind) details.kind = errorKind\n const missingProperty = parseMissingProperty(error)\n if (missingProperty) details.missingProperty = missingProperty\n return details\n}\n\nexport function chunkOutcomeToResults(\n outcome: ChunkOutcome,\n nodes: NodeToPreview[],\n fileKey: string,\n availablePropsByNodeId?: Record<string, AvailableProperty[]>,\n): PreviewResult[] {\n const { chunkNodeIds, response, error } = outcome\n const results: PreviewResult[] = []\n\n if (error) {\n const errorMsg = isFetchError(error)\n ? error.data?.message || error.response.statusText\n : String(error)\n // 503 means the server-side killswitch is on — surface the server's\n // message directly without the per-file/per-node noise so the user\n // sees a single clear line during an incident.\n if (isFetchError(error) && error.response.status === 503) {\n exitWithError(errorMsg)\n } else {\n logger.error(`Failed to preview components in file ${fileKey}: ${errorMsg}`)\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error: errorMsg,\n // Chunk-level failure is a server/network error, not a template problem.\n errorDetails: { kind: 'transport' },\n })\n }\n }\n }\n return results\n }\n\n if (response!.response.status === 200 && response!.data.meta?.results) {\n // Track match index per nodeId so duplicate node IDs get the correct file attribution.\n // The server returns results in the same order as the templates we sent. Each chunk's\n // nodeIds are disjoint (we dedupe before chunking), so per-chunk indexing is correct.\n // Property-combination results are expanded renders of one node, not one result per\n // matching template, so they should not consume this per-template index.\n const nodeMatchIndex: Record<string, number> = {}\n for (const result of response!.data.meta.results) {\n const idx = nodeMatchIndex[result.nodeId] ?? 0\n const matchingNodes = nodes.filter((n) => n.nodeId === result.nodeId)\n const node = result.propertyCombinationLabel\n ? matchingNodes[0]\n : matchingNodes[idx] || matchingNodes[0]\n if (!result.propertyCombinationLabel) {\n nodeMatchIndex[result.nodeId] = idx + 1\n }\n const error = result.error || (!result.snippet ? 'No snippet returned by server' : undefined)\n const success = !result.error && !!result.snippet\n results.push({\n url: node?.url || result.nodeUrl,\n nodeId: result.nodeId,\n filePath: node?.filePath || '',\n success,\n snippet: result.snippet,\n language: result.language,\n component: result.component,\n error,\n ...(result.propertyCombinationLabel\n ? { propertyCombinationLabel: result.propertyCombinationLabel }\n : {}),\n ...(result.unresolvedInstances?.length\n ? { unresolvedInstances: result.unresolvedInstances }\n : {}),\n ...(success\n ? {}\n : {\n errorDetails: buildErrorDetails(\n error,\n result.errorKind,\n availablePropsByNodeId?.[result.nodeId],\n ),\n }),\n })\n }\n return results\n }\n\n for (const nodeId of chunkNodeIds) {\n for (const node of nodes.filter((n) => n.nodeId === nodeId)) {\n const error = `API request failed with status ${response!.response.status}`\n results.push({\n url: node.url,\n nodeId: node.nodeId,\n filePath: node.filePath,\n success: false,\n error,\n // Non-2xx from the endpoint is a transport-level failure, not a template problem.\n errorDetails: { kind: 'transport' },\n })\n }\n }\n return results\n}\n\nasync function previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n propertyCombinationsByNodeId,\n availablePropsByNodeId,\n}: {\n fileKey: string\n nodes: NodeToPreview[]\n baseApiUrl: string\n accessToken: string\n dir: string\n allCodeConnectObjects: CodeConnectJSON[]\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n availablePropsByNodeId?: Record<string, AvailableProperty[]>\n}): Promise<PreviewResult[]> {\n const allNodeIds = nodes.map((n) => n.nodeId)\n // Deduplicate — multiple figma.connect() calls may share the same nodeId;\n // the individual templates are sent in figmaDocs and the server iterates per-template.\n const nodeIds = [...new Set(allNodeIds)]\n\n // Only send templates from the requested files — other files' templates\n // for the same nodeId exist on the server and shouldn't be rendered individually.\n const requestedFilePaths = new Set(nodes.map((n) => path.resolve(dir, n.filePath)))\n const requiredTemplates = filterTemplatesForNodes(allNodeIds, allCodeConnectObjects).filter((t) =>\n requestedFilePaths.has(path.resolve(t._codeConnectFilePath || '')),\n )\n\n const chunks = chunkNodeIdsForPreview(nodeIds, propertyCombinationsByNodeId)\n const outcomes = await runInWaves(\n chunks,\n (chunkNodeIds) =>\n sendPreviewChunk({\n chunkNodeIds,\n requiredTemplates,\n baseApiUrl,\n fileKey,\n accessToken,\n propertyCombinationsByNodeId,\n }),\n PREVIEW_MAX_CONCURRENCY,\n )\n\n return outcomes.flatMap((outcome) =>\n chunkOutcomeToResults(outcome, nodes, fileKey, availablePropsByNodeId),\n )\n}\n\nfunction collectAllLocalNodesToPreview(\n allCodeConnectObjects: CodeConnectJSON[],\n dir: string,\n cmd: BaseCommand,\n): NodeToPreview[] {\n const nodesToCheck: NodeToPreview[] = []\n for (const doc of allCodeConnectObjects) {\n const parsed = parseFigmaNode(cmd.verbose, doc, true)\n if (parsed) {\n nodesToCheck.push({\n fileKey: parsed.fileKey,\n nodeId: parsed.nodeId,\n url: doc.figmaNode,\n filePath: path.relative(dir, doc._codeConnectFilePath || ''),\n })\n }\n }\n return nodesToCheck\n}\n\nfunction groupNodesByFileKey(nodes: NodeToPreview[]): NodesByFileKey {\n const nodesByFileKey: NodesByFileKey = {}\n for (const node of nodes) {\n nodesByFileKey[node.fileKey] ??= []\n nodesByFileKey[node.fileKey].push(node)\n }\n return nodesByFileKey\n}\n\nasync function handleInspect({\n nodesByFileKey,\n configuredApiUrl,\n accessToken,\n outputFormat,\n}: {\n nodesByFileKey: NodesByFileKey\n configuredApiUrl?: string\n accessToken: string\n outputFormat: string\n}): Promise<void> {\n const items: PropertyListItem[] = []\n const seen = new Set<string>()\n for (const [fileKey, nodes] of Object.entries(nodesByFileKey)) {\n const baseApiUrl = getApiUrl(nodes[0].url, configuredApiUrl)\n for (const node of nodes) {\n const dedupeKey = `${node.filePath}::${node.nodeId}`\n if (seen.has(dedupeKey)) continue\n seen.add(dedupeKey)\n const result = await fetchComponentPropertyDefinitions(\n baseApiUrl,\n fileKey,\n node.nodeId,\n accessToken,\n )\n if (result.status === 'error') {\n logger.warn(`Couldn't fetch property definitions for node ${node.nodeId}`)\n } else if (result.status === 'empty') {\n logger.info(`Node ${node.nodeId} has no component properties or variants.`)\n }\n items.push({\n filePath: node.filePath,\n nodeId: node.nodeId,\n availableProperties: result.status === 'ok' ? toAvailableProperties(result.defs) : [],\n })\n }\n }\n\n if (outputFormat === 'json') {\n console.log(JSON.stringify(items, null, 2))\n } else {\n displayPropertyList(items)\n }\n}\n\nfunction validatePreviewOptions(cmd: PreviewCommand): void {\n if (cmd.all && cmd.props) {\n exitWithError('Cannot combine --props and --all; use one or the other')\n }\n\n if (cmd.maxCombinations !== undefined && !cmd.all) {\n exitWithError('--max-combinations can only be used with --all')\n }\n}\n\nasync function buildPropertyPreviewInputs({\n enabled,\n baseApiUrl,\n fileKey,\n nodes,\n accessToken,\n propsPairs,\n maxCombinations,\n}: {\n enabled: boolean\n baseApiUrl: string\n fileKey: string\n nodes: NodeToPreview[]\n accessToken: string\n propsPairs?: ParsedPropertyPair[]\n maxCombinations: number\n}): Promise<{\n propertyCombinationsByNodeId?: Record<string, PropertyCombination[]>\n availablePropsByNodeId?: Record<string, AvailableProperty[]>\n}> {\n if (!enabled) return {}\n\n const propertyCombinationsByNodeId: Record<string, PropertyCombination[]> = {}\n const availablePropsByNodeId: Record<string, AvailableProperty[]> = {}\n for (const nodeId of [...new Set(nodes.map((n) => n.nodeId))]) {\n const result = await fetchComponentPropertyDefinitions(baseApiUrl, fileKey, nodeId, accessToken)\n if (result.status === 'error') {\n logger.warn(\n `Couldn't fetch property definitions for node ${nodeId} (ensure your token has the ` +\n `Code Connect: Write and File content: Read scopes); rendering its default property combination only`,\n )\n continue\n }\n if (result.status === 'empty') {\n // Not an error: the component simply has no properties or variants to vary.\n if (propsPairs) {\n logger.warn(\n `Node ${nodeId} has no component properties or variants, so --props ` +\n `(${propsPairs.map((p) => p.name).join(', ')}) has no effect; rendering its only property combination.`,\n )\n } else {\n logger.info(\n `Node ${nodeId} has no component properties or variants to vary; rendering its only property combination.`,\n )\n }\n continue\n }\n\n const defs = result.defs\n if (propsPairs) {\n const { propertyCombination, availableProperties, unknown, invalid, ambiguous } =\n buildPropertyCombinationFromProps(defs, propsPairs)\n if (unknown.length > 0) {\n logger.warn(\n `Unknown propert${unknown.length > 1 ? 'ies' : 'y'} for node ${nodeId}: ${unknown.join(', ')}. ` +\n `Available: ${availableProperties.map((p) => p.name).join(', ')}`,\n )\n }\n for (const { name, value, options } of invalid) {\n logger.warn(\n `\"${value}\" is not a valid value for ${name} on node ${nodeId}. Options: ${options.join(', ')}`,\n )\n }\n for (const { name, types } of ambiguous) {\n logger.warn(\n `Property \"${name}\" on node ${nodeId} matches multiple types (${types.join(', ')}); ` +\n `prefix the value with a type to disambiguate, e.g. ${types[0]}:${name}=... . Skipping.`,\n )\n }\n availablePropsByNodeId[nodeId] = availableProperties\n propertyCombinationsByNodeId[nodeId] = [propertyCombination]\n } else {\n const { propertyCombinations, availableProperties, truncated } =\n enumeratePropertyCombinations(defs, {\n maxCombinations,\n })\n availablePropsByNodeId[nodeId] = availableProperties\n if (truncated) {\n logger.warn(\n `Node ${nodeId} has ${truncated.total} property combinations, exceeding the ${truncated.cap}-combination ` +\n `preview limit; rendering the first ${truncated.cap}. Use --props to preview a ` +\n `specific property combination.`,\n )\n }\n if (propertyCombinations.length > 0) {\n propertyCombinationsByNodeId[nodeId] = propertyCombinations\n }\n }\n }\n\n return { propertyCombinationsByNodeId, availablePropsByNodeId }\n}\n\nasync function previewNodesForFile({\n fileKey,\n nodes,\n configuredApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n renderPropertyCombinations,\n propsPairs,\n maxCombinations,\n}: {\n fileKey: string\n nodes: NodeToPreview[]\n configuredApiUrl?: string\n accessToken: string\n dir: string\n allCodeConnectObjects: CodeConnectJSON[]\n renderPropertyCombinations: boolean\n propsPairs?: ParsedPropertyPair[]\n maxCombinations: number\n}): Promise<PreviewResult[]> {\n const baseApiUrl = getApiUrl(nodes[0].url, configuredApiUrl)\n const { propertyCombinationsByNodeId, availablePropsByNodeId } = await buildPropertyPreviewInputs(\n {\n enabled: renderPropertyCombinations,\n baseApiUrl,\n fileKey,\n nodes,\n accessToken,\n propsPairs,\n maxCombinations,\n },\n )\n\n return previewFile({\n fileKey,\n nodes,\n baseApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n propertyCombinationsByNodeId,\n availablePropsByNodeId,\n })\n}\n\nasync function validateRenderedSnippets(results: PreviewResult[]): Promise<void> {\n for (const result of results) {\n if (result.success && result.snippet) {\n const prettierValid = await isPrettierParseable(result.snippet, result.language)\n if (!prettierValid) {\n // Prettier can parse this language but failed — mark as error\n result.success = false\n result.error = 'Snippet has syntax errors and may not be valid code'\n }\n }\n }\n}\n\nasync function outputPreviewResults(results: PreviewResult[], outputFormat: string): Promise<void> {\n if (outputFormat === 'json') {\n console.log(JSON.stringify(results, null, 2))\n return\n }\n\n const formattedResults: PreviewResult[] = await Promise.all(\n results.map(async (result) => {\n if (result.success && result.snippet) {\n const formattedSnippet = await formatSnippet(result.snippet, result.language)\n return { ...result, snippet: formattedSnippet }\n }\n return result\n }),\n )\n displayResults(formattedResults)\n}\n\n/**\n * Handle the preview command\n */\nexport async function handlePreview(files: string[], cmd: PreviewCommand) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = await getProjectInfo(dir, cmd.config)\n const accessToken = getAccessTokenOrExit(cmd)\n const outputFormat = cmd.output || 'table'\n const configuredApiUrl = cmd.apiUrl || projectInfo.config.apiUrl\n\n if (cmd.all && (!files || files.length === 0)) {\n exitWithError(\n '--all requires a specific component, e.g. `figma connect preview Button.figma.ts --all`',\n )\n }\n\n const allCodeConnectObjects = await getCodeConnectObjects(cmd, projectInfo, true)\n\n const nodesToCheck =\n files && files.length > 0\n ? await collectNodesToPreview(files, allCodeConnectObjects, dir, cmd)\n : collectAllLocalNodesToPreview(allCodeConnectObjects, dir, cmd)\n if (!files || files.length === 0) {\n logger.info('Previewing all local Code Connect files...')\n }\n\n if (nodesToCheck.length === 0) {\n exitWithError('No valid Code Connect files found to preview')\n }\n\n logger.info(`Previewing ${nodesToCheck.length} component(s)...`)\n const nodesByFileKey = groupNodesByFileKey(nodesToCheck)\n\n if (cmd.inspect) {\n await handleInspect({\n nodesByFileKey,\n configuredApiUrl,\n accessToken,\n outputFormat,\n })\n return\n }\n\n validatePreviewOptions(cmd)\n const maxCombinations = parseMaxCombinationsArg(cmd.maxCombinations)\n const propsPairs = cmd.props ? parsePropsArg(cmd.props) : undefined\n\n const results: PreviewResult[] = []\n for (const [fileKey, nodes] of Object.entries(nodesByFileKey)) {\n const fileResults = await previewNodesForFile({\n fileKey,\n nodes,\n configuredApiUrl,\n accessToken,\n dir,\n allCodeConnectObjects,\n renderPropertyCombinations: cmd.all || !!propsPairs,\n propsPairs,\n maxCombinations,\n })\n results.push(...fileResults)\n }\n\n await validateRenderedSnippets(results)\n await outputPreviewResults(results, outputFormat)\n\n if (results.every((r) => !r.success)) {\n process.exit(1)\n }\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { AvailableProperty } from '../connect/property_combinations';
2
+ export interface PropertyListItem {
3
+ filePath: string;
4
+ nodeId: string;
5
+ availableProperties: AvailableProperty[];
6
+ }
7
+ /**
8
+ * Print each component's property vocabulary (name, type, options, default).
9
+ */
10
+ export declare function displayPropertyList(items: PropertyListItem[]): void;
11
+ //# sourceMappingURL=property_list_table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property_list_table.d.ts","sourceRoot":"","sources":["../../src/commands/property_list_table.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AAKzE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,mBAAmB,EAAE,iBAAiB,EAAE,CAAA;CACzC;AA4BD;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAsCnE"}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.displayPropertyList = displayPropertyList;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const purple = chalk_1.default.ansi256(93);
9
+ const gray = chalk_1.default.ansi256(243);
10
+ function formatPropertyType(type) {
11
+ switch (type) {
12
+ case 'BOOLEAN':
13
+ return 'Boolean';
14
+ case 'INSTANCE_SWAP':
15
+ return 'Instance Swap';
16
+ case 'TEXT':
17
+ return 'Text';
18
+ case 'VARIANT':
19
+ return 'Variant';
20
+ default:
21
+ return type;
22
+ }
23
+ }
24
+ function optionsOf(property) {
25
+ if (property.variantOptions?.length)
26
+ return property.variantOptions.join(' | ');
27
+ if (property.type === 'BOOLEAN')
28
+ return 'true | false';
29
+ return '';
30
+ }
31
+ function defaultValueOf(property) {
32
+ if (property.default === undefined)
33
+ return '';
34
+ return typeof property.default === 'string' ? `"${property.default}"` : String(property.default);
35
+ }
36
+ /**
37
+ * Print each component's property vocabulary (name, type, options, default).
38
+ */
39
+ function displayPropertyList(items) {
40
+ for (const { filePath, nodeId, availableProperties } of items) {
41
+ console.log('');
42
+ console.log(`${purple('●')} ${chalk_1.default.bold(filePath)} ${gray(`(${nodeId})`)}`);
43
+ if (availableProperties.length === 0) {
44
+ console.log(` ${gray('(no properties found)')}`);
45
+ continue;
46
+ }
47
+ const rows = availableProperties.map((property) => ({
48
+ name: property.name,
49
+ type: formatPropertyType(property.type),
50
+ options: optionsOf(property),
51
+ defaultValue: defaultValueOf(property),
52
+ }));
53
+ const nameW = Math.max('Name'.length, ...rows.map((property) => property.name.length));
54
+ const typeW = Math.max('Type'.length, ...rows.map((property) => property.type.length));
55
+ const optsW = Math.max('Options'.length, ...rows.map((property) => property.options.length));
56
+ const defaultW = Math.max('Default'.length, ...rows.map((property) => property.defaultValue.length));
57
+ console.log(` ${chalk_1.default.bold('Name'.padEnd(nameW))} ${chalk_1.default.bold('Type'.padEnd(typeW))} ` +
58
+ `${chalk_1.default.bold('Options'.padEnd(optsW))} ${chalk_1.default.bold('Default'.padEnd(defaultW))}`);
59
+ console.log(` ${gray('-'.repeat(nameW))} ${gray('-'.repeat(typeW))} ` +
60
+ `${gray('-'.repeat(optsW))} ${gray('-'.repeat(defaultW))}`);
61
+ for (const row of rows) {
62
+ console.log(` ${chalk_1.default.bold(row.name.padEnd(nameW))} ${gray(row.type.padEnd(typeW))} ` +
63
+ `${row.options.padEnd(optsW)} ${row.defaultValue.padEnd(defaultW)}`);
64
+ }
65
+ }
66
+ }
67
+ //# sourceMappingURL=property_list_table.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property_list_table.js","sourceRoot":"","sources":["../../src/commands/property_list_table.ts"],"names":[],"mappings":";;;;;AA0CA,kDAsCC;AAhFD,kDAAyB;AAIzB,MAAM,MAAM,GAAG,eAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;AAChC,MAAM,IAAI,GAAG,eAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;AAQ/B,SAAS,kBAAkB,CAAC,IAAwC;IAClE,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAClB,KAAK,eAAe;YAClB,OAAO,eAAe,CAAA;QACxB,KAAK,MAAM;YACT,OAAO,MAAM,CAAA;QACf,KAAK,SAAS;YACZ,OAAO,SAAS,CAAA;QAClB;YACE,OAAO,IAAI,CAAA;IACf,CAAC;AACH,CAAC;AAED,SAAS,SAAS,CAAC,QAA2B;IAC5C,IAAI,QAAQ,CAAC,cAAc,EAAE,MAAM;QAAE,OAAO,QAAQ,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC/E,IAAI,QAAQ,CAAC,IAAI,KAAK,SAAS;QAAE,OA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CAAC,QAAQ,CAAC,CAAC,EAAE,CAC9D,CAAA;QACD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CACT,KAAK,eAAK,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI;gBAC1E,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CACvE,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import chalk from 'chalk'\nimport { FigmaRestApi } from '../connect/figma_rest_api'\nimport type { AvailableProperty } from '../connect/property_combinations'\n\nconst purple = chalk.ansi256(93)\nconst gray = chalk.ansi256(243)\n\nexport interface PropertyListItem {\n filePath: string\n nodeId: string\n availableProperties: AvailableProperty[]\n}\n\nfunction formatPropertyType(type: FigmaRestApi.ComponentPropertyType): string {\n switch (type) {\n case 'BOOLEAN':\n return 'Boolean'\n case 'INSTANCE_SWAP':\n return 'Instance Swap'\n case 'TEXT':\n return 'Text'\n case 'VARIANT':\n return 'Variant'\n default:\n return type\n }\n}\n\nfunction optionsOf(property: AvailableProperty): string {\n if (property.variantOptions?.length) return property.variantOptions.join(' | ')\n if (property.type === 'BOOLEAN') return 'true | false'\n return ''\n}\n\nfunction defaultValueOf(property: AvailableProperty): string {\n if (property.default === undefined) return ''\n return typeof property.default === 'string' ? `\"${property.default}\"` : String(property.default)\n}\n\n/**\n * Print each component's property vocabulary (name, type, options, default).\n */\nexport function displayPropertyList(items: PropertyListItem[]): void {\n for (const { filePath, nodeId, availableProperties } of items) {\n console.log('')\n console.log(`${purple('●')} ${chalk.bold(filePath)} ${gray(`(${nodeId})`)}`)\n if (availableProperties.length === 0) {\n console.log(` ${gray('(no properties found)')}`)\n continue\n }\n\n const rows = availableProperties.map((property) => ({\n name: property.name,\n type: formatPropertyType(property.type),\n options: optionsOf(property),\n defaultValue: defaultValueOf(property),\n }))\n const nameW = Math.max('Name'.length, ...rows.map((property) => property.name.length))\n const typeW = Math.max('Type'.length, ...rows.map((property) => property.type.length))\n const optsW = Math.max('Options'.length, ...rows.map((property) => property.options.length))\n const defaultW = Math.max(\n 'Default'.length,\n ...rows.map((property) => property.defaultValue.length),\n )\n\n console.log(\n ` ${chalk.bold('Name'.padEnd(nameW))} ${chalk.bold('Type'.padEnd(typeW))} ` +\n `${chalk.bold('Options'.padEnd(optsW))} ${chalk.bold('Default'.padEnd(defaultW))}`,\n )\n console.log(\n ` ${gray('-'.repeat(nameW))} ${gray('-'.repeat(typeW))} ` +\n `${gray('-'.repeat(optsW))} ${gray('-'.repeat(defaultW))}`,\n )\n for (const row of rows) {\n console.log(\n ` ${chalk.bold(row.name.padEnd(nameW))} ${gray(row.type.padEnd(typeW))} ` +\n `${row.options.padEnd(optsW)} ${row.defaultValue.padEnd(defaultW)}`,\n )\n }\n }\n}\n"]}
@@ -1,7 +1,10 @@
1
1
  import { BaseCommand } from '../commands/connect';
2
2
  import { Command } from 'commander';
3
+ export declare function flagParserBasedCodeConnect(): void;
3
4
  type CommandArgs<T extends BaseCommand> = [...any[], T, Command];
4
- export declare function withUpdateCheck<T extends BaseCommand>(fn: (...args: any[]) => void | Promise<void>): (...args: CommandArgs<T>) => void | Promise<void>;
5
+ export declare function withVersionWarnings<T extends BaseCommand>(fn: (...args: any[]) => void | Promise<void>, { hideDeprecationWarning }?: {
6
+ hideDeprecationWarning?: boolean;
7
+ }): (...args: CommandArgs<T>) => void | Promise<void>;
5
8
  export declare function exitWithUpdateCheck(errorCode?: number): never;
6
9
  export declare function updateCli(): void;
7
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,KAAK,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAA;AAIhE,wBAAgB,eAAe,CAAC,CAAC,SAAS,WAAW,EAGnD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAEpC,GAAG,MAAM,WAAW,CAAC,CAAC,CAAC,0BAmBhC;AAyCD,wBAAgB,mBAAmB,CAAC,SAAS,SAAI,GAAG,KAAK,CAGxD;AAkBD,wBAAgB,SAAS,SAGxB"}
1
+ {"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAWnC,wBAAgB,0BAA0B,SAEzC;AAID,KAAK,WAAW,CAAC,CAAC,SAAS,WAAW,IAAI,CAAC,GAAG,GAAG,EAAE,EAAE,CAAC,EAAE,OAAO,CAAC,CAAA;AAIhE,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,WAAW,EAGvD,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC5C,EAAE,sBAA8B,EAAE,GAAE;IAAE,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAO,IAErE,GAAG,MAAM,WAAW,CAAC,CAAC,CAAC,0BAsBhC;AAyCD,wBAAgB,mBAAmB,CAAC,SAAS,SAAI,GAAG,KAAK,CAKxD;AA6BD,wBAAgB,SAAS,SAGxB"}
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withUpdateCheck = withUpdateCheck;
6
+ exports.flagParserBasedCodeConnect = flagParserBasedCodeConnect;
7
+ exports.withVersionWarnings = withVersionWarnings;
7
8
  exports.exitWithUpdateCheck = exitWithUpdateCheck;
8
9
  exports.updateCli = updateCli;
9
10
  const chalk_1 = __importDefault(require("chalk"));
@@ -12,18 +13,28 @@ const compare_versions_1 = require("compare-versions");
12
13
  const fetch_1 = require("./fetch");
13
14
  let updatedVersionAvailable = undefined;
14
15
  let message = undefined;
16
+ let parserBasedCodeConnectFound = false;
17
+ let deprecationWarningHidden = false;
18
+ let skipUpdateCheck = false;
19
+ // Called when the native parser has actually produced Code Connect docs, which
20
+ // is the only definitive signal that a project still uses the legacy parsers.
21
+ function flagParserBasedCodeConnect() {
22
+ parserBasedCodeConnectFound = true;
23
+ }
15
24
  // Wrap action handlers to check for updates or a message, and output a message
16
25
  // after the action if any are available
17
- function withUpdateCheck(
26
+ function withVersionWarnings(
18
27
  // The second to last argument is always the command args, but I couldn't work
19
28
  // out how to model this with Typescript here
20
- fn) {
29
+ fn, { hideDeprecationWarning = false } = {}) {
21
30
  return (...args) => {
22
31
  // Get the args passed at the command line (the second to last argument)
23
32
  const commandArgs = args[args.length - 2];
24
33
  // Anything before that is a regular arg
25
34
  const restArgs = args.slice(0, -2);
26
- if (commandArgs.skipUpdateCheck) {
35
+ skipUpdateCheck = !!commandArgs.skipUpdateCheck;
36
+ deprecationWarningHidden = hideDeprecationWarning;
37
+ if (skipUpdateCheck) {
27
38
  return fn(...restArgs, commandArgs);
28
39
  }
29
40
  startUpdateCheck();
@@ -73,13 +84,23 @@ async function waitAndCheckForUpdates() {
73
84
  // complete, so if the request has not completed yet, nothing will be shown.
74
85
  // This is to avoid confusion about when the process _actually_ exits.
75
86
  function exitWithUpdateCheck(errorCode = 1) {
76
- maybeShowUpdateMessage();
87
+ if (!skipUpdateCheck) {
88
+ maybeShowUpdateMessage();
89
+ }
77
90
  process.exit(errorCode);
78
91
  }
79
92
  function getUpdateCommand() {
80
93
  return 'npm update -g @figma/code-connect';
81
94
  }
95
+ // Keep in sync with the deprecation notices in figmadoc/README.md and
96
+ // figmadoc/CHANGELOG.md, which repeat this date.
97
+ const PARSER_DEPRECATION_DATE = 'August 17th, 2026';
98
+ const DEPRECATION_NOTICE = `
99
+ ${chalk_1.default.yellow('⚠')} ${chalk_1.default.bold(`We've detected framework-specific Code Connect in your project. Starting ${PARSER_DEPRECATION_DATE} Code Connect users should use the new templates format for Code Connect.`)} You may continue publishing, but we recommend following our migration guide to update your Code Connect: https://developers.figma.com/docs/code-connect/templates-migration-guide/`;
82
100
  function maybeShowUpdateMessage() {
101
+ if (parserBasedCodeConnectFound && !deprecationWarningHidden) {
102
+ logging_1.logger.warn(DEPRECATION_NOTICE);
103
+ }
83
104
  if (updatedVersionAvailable) {
84
105
  logging_1.logger.warn(`\nA new version of the Figma CLI is available. v${require('../../package.json').version} is currently installed, and the latest version available is v${updatedVersionAvailable}.
85
106
 
@@ -1 +1 @@
1
- {"version":3,"file":"updates.js","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":";;;;;AAgBA,0CAwBC;AAyCD,kDAGC;AAkBD,8BAGC;AAzGD,kDAAyB;AACzB,uCAAkC;AAClC,uDAAkD;AAGlD,mCAAiC;AAEjC,IAAI,uBAAuB,GAA+B,SAAS,CAAA;AACnE,IAAI,OAAO,GAAuB,SAAS,CAAA;AAM3C,+EAA+E;AAC/E,wCAAwC;AACxC,SAAgB,eAAe;AAC7B,8EAA8E;AAC9E,6CAA6C;AAC7C,EAA4C;IAE5C,OAAO,CAAC,GAAG,IAAoB,EAAE,EAAE;QACjC,wEAAwE;QACxE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACzC,wCAAwC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,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AAK,SAAS,EAAE,CAAC;YAC1C,MAAK;QACP,CAAC;QACD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAA;IAC1D,CAAC;IAED,sBAAsB,EAAE,CAAA;AAC1B,CAAC;AAED,+EAA+E;AAC/E,4EAA4E;AAC5E,4EAA4E;AAC5E,sEAAsE;AACtE,SAAgB,mBAAmB,CAAC,SAAS,GAAG,CAAC;IAC/C,sBAAsB,EAAE,CAAA;IACxB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACzB,CAAC;AAED,SAAS,gBAAgB;IACvB,OAAO,mCAAmC,CAAA;AAC5C,CAAC;AAED,SAAS,sBAAsB;IAC7B,IAAI,uBAAuB,EAAE,CAAC;QAC5B,gBAAM,CAAC,IAAI,CAAC,mDAAmD,OAAO,CAAC,oBAAoB,CAAC,CAAC,OAAO,iEAAiE,uBAAuB;;iBAE/K,eAAK,CAAC,WAAW,CAAC,wCAAwC,CAAC,0BAA0B,eAAK,CAAC,WAAW,CAAC,2CAA2C,CAAC,sEAAsE,CAAC,CAAA;IACzO,CAAC;IAED,IAAI,OAAO,EAAE,CAAC;QACZ,gBAAM,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,SAAgB,SAAS;IACvB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC7C,QAAQ,CAAC,gBAAgB,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;AACpD,CAAC","sourcesContent":["import chalk from 'chalk'\nimport { logger } from './logging'\nimport { compareVersions } from 'compare-versions'\nimport { BaseCommand } from '../commands/connect'\nimport { Command } from 'commander'\nimport { request } from './fetch'\n\nlet updatedVersionAvailable: string | false | undefined = undefined\nlet message: string | undefined = undefined\n\n// The type of the arguments passed to a command handler:\n// any arguments, then the command arguments, then the Command object\ntype CommandArgs<T extends BaseCommand> = [...any[], T, Command]\n\n// Wrap action handlers to check for updates or a message, and output a message\n// after the action if any are available\nexport function withUpdateCheck<T extends BaseCommand>(\n // The second to last argument is always the command args, but I couldn't work\n // out how to model this with Typescript here\n fn: (...args: any[]) => void | Promise<void>,\n) {\n return (...args: CommandArgs<T>) => {\n // Get the args passed at the command line (the second to last argument)\n const commandArgs = args[args.length - 2]\n // Anything before that is a regular arg\n const restArgs = args.slice(0, -2)\n\n if (commandArgs.skipUpdateCheck) {\n return fn(...restArgs, commandArgs)\n }\n\n startUpdateCheck()\n\n const result = fn(...restArgs, commandArgs)\n if (result instanceof Promise) {\n result.finally(waitAndCheckForUpdates)\n } else {\n waitAndCheckForUpdates()\n }\n }\n}\n\n// Start checking for updates in the background. We don't wait for this before\n// running the action, as we will show the result at the end\nfunction startUpdateCheck() {\n request\n .get<{ tag_name: string }>('https://api.github.com/repos/figma/code-connect/releases/latest')\n .then((response) => {\n const latestVersion = response.data.tag_name.replace(/^v/, '')\n const currentVersion = require('../../package.json').version\n\n if (compareVersions(latestVersion, currentVersion) === 1) {\n updatedVersionAvailable = latestVersion\n } else {\n updatedVersionAvailable = false\n }\n })\n .catch(() => {\n // Silently fail if we can't check for updates\n updatedVersionAvailable = false\n })\n}\n\n// Wait for up to 1 second for the result of update checking to be available,\n// and output a message if there is an update or a message. If there is no\n// result after the timeout, the app will exit.\nasync function waitAndCheckForUpdates() {\n for (let i = 0; i < 10; i++) {\n if (updatedVersionAvailable !== undefined) {\n break\n }\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n\n maybeShowUpdateMessage()\n}\n\n// Exit the process, first checking if there is an update or message available.\n// Unlike waitAndCheckForUpdates, this will not wait for the update check to\n// complete, so if the request has not completed yet, nothing will be shown.\n// This is to avoid confusion about when the process _actually_ exits.\nexport function exitWithUpdateCheck(errorCode = 1): never {\n maybeShowUpdateMessage()\n process.exit(errorCode)\n}\n\nfunction getUpdateCommand() {\n return 'npm update -g @figma/code-connect'\n}\n\nfunction maybeShowUpdateMessage() {\n if (updatedVersionAvailable) {\n logger.warn(`\\nA new version of the Figma CLI is available. v${require('../../package.json').version} is currently installed, and the latest version available is v${updatedVersionAvailable}.\n\nTo update, run ${chalk.whiteBright('npm install @figma/code-connect@latest')} for React or HTML, or ${chalk.whiteBright('npm install -g @figma/code-connect@latest')} for other targets (or if you have Code Connect installed globally).`)\n }\n\n if (message) {\n logger.warn(`\\n${message}`)\n }\n}\n\nexport function updateCli() {\n const { execSync } = require('child_process')\n execSync(getUpdateCommand(), { stdio: 'inherit' })\n}\n"]}
1
+ {"version":3,"file":"updates.js","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":";;;;;AAeA,gEAEC;AAQD,kDA4BC;AAyCD,kDAKC;AA6BD,8BAGC;AAnID,kDAAyB;AACzB,uCAAkC;AAClC,uDAAkD;AAGlD,mCAAiC;AAEjC,IAAI,uBAAuB,GAA+B,SAAS,CAAA;AACnE,IAAI,OAAO,GAAuB,SAAS,CAAA;AAC3C,IAAI,2BAA2B,GAAG,KAAK,CAAA;AACvC,IAAI,wBAAwB,GAAG,KAAK,CAAA;AACpC,IAAI,eAAe,GAAG,KAAK,CAAA;AAE3B,+EAA+E;AAC/E,8EAA8E;AAC9E,SAAgB,0BAA0B;IACxC,2BAA2B,GAAG,IAAI,CAAA;AACpC,CAAC;AAMD,+EAA+E;AAC/E,wCAAwC;AACxC,SAAgB,mBAAmB;AACjC,8EAA8E;AAC9E,6CAA6C;AAC7C,EAA4C,EAC5C,EAAE,sBAAsB,GAAG,KAAK,KAA2C,EAAE;IAE7E,OAAO,CAAC,GAAG,IAAoB,EAAE,EAAE;QACjC,wEAAwE;QACxE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;QACzC,wCAAwC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAA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C,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAA;IAC7B,CAAC;AACH,CAAC;AAED,SAAgB,SAAS;IACvB,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAC7C,QAAQ,CAAC,gBAAgB,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAA;AACpD,CAAC","sourcesContent":["import chalk from 'chalk'\nimport { logger } from './logging'\nimport { compareVersions } from 'compare-versions'\nimport { BaseCommand } from '../commands/connect'\nimport { Command } from 'commander'\nimport { request } from './fetch'\n\nlet updatedVersionAvailable: string | false | undefined = undefined\nlet message: string | undefined = undefined\nlet parserBasedCodeConnectFound = false\nlet deprecationWarningHidden = false\nlet skipUpdateCheck = false\n\n// Called when the native parser has actually produced Code Connect docs, which\n// is the only definitive signal that a project still uses the legacy parsers.\nexport function flagParserBasedCodeConnect() {\n parserBasedCodeConnectFound = true\n}\n\n// The type of the arguments passed to a command handler:\n// any arguments, then the command arguments, then the Command object\ntype CommandArgs<T extends BaseCommand> = [...any[], T, Command]\n\n// Wrap action handlers to check for updates or a message, and output a message\n// after the action if any are available\nexport function withVersionWarnings<T extends BaseCommand>(\n // The second to last argument is always the command args, but I couldn't work\n // out how to model this with Typescript here\n fn: (...args: any[]) => void | Promise<void>,\n { hideDeprecationWarning = false }: { hideDeprecationWarning?: boolean } = {},\n) {\n return (...args: CommandArgs<T>) => {\n // Get the args passed at the command line (the second to last argument)\n const commandArgs = args[args.length - 2]\n // Anything before that is a regular arg\n const restArgs = args.slice(0, -2)\n\n skipUpdateCheck = !!commandArgs.skipUpdateCheck\n deprecationWarningHidden = hideDeprecationWarning\n\n if (skipUpdateCheck) {\n return fn(...restArgs, commandArgs)\n }\n\n startUpdateCheck()\n\n const result = fn(...restArgs, commandArgs)\n if (result instanceof Promise) {\n result.finally(waitAndCheckForUpdates)\n } else {\n waitAndCheckForUpdates()\n }\n }\n}\n\n// Start checking for updates in the background. We don't wait for this before\n// running the action, as we will show the result at the end\nfunction startUpdateCheck() {\n request\n .get<{ tag_name: string }>('https://api.github.com/repos/figma/code-connect/releases/latest')\n .then((response) => {\n const latestVersion = response.data.tag_name.replace(/^v/, '')\n const currentVersion = require('../../package.json').version\n\n if (compareVersions(latestVersion, currentVersion) === 1) {\n updatedVersionAvailable = latestVersion\n } else {\n updatedVersionAvailable = false\n }\n })\n .catch(() => {\n // Silently fail if we can't check for updates\n updatedVersionAvailable = false\n })\n}\n\n// Wait for up to 1 second for the result of update checking to be available,\n// and output a message if there is an update or a message. If there is no\n// result after the timeout, the app will exit.\nasync function waitAndCheckForUpdates() {\n for (let i = 0; i < 10; i++) {\n if (updatedVersionAvailable !== undefined) {\n break\n }\n await new Promise((resolve) => setTimeout(resolve, 100))\n }\n\n maybeShowUpdateMessage()\n}\n\n// Exit the process, first checking if there is an update or message available.\n// Unlike waitAndCheckForUpdates, this will not wait for the update check to\n// complete, so if the request has not completed yet, nothing will be shown.\n// This is to avoid confusion about when the process _actually_ exits.\nexport function exitWithUpdateCheck(errorCode = 1): never {\n if (!skipUpdateCheck) {\n maybeShowUpdateMessage()\n }\n process.exit(errorCode)\n}\n\nfunction getUpdateCommand() {\n return 'npm update -g @figma/code-connect'\n}\n\n// Keep in sync with the deprecation notices in figmadoc/README.md and\n// figmadoc/CHANGELOG.md, which repeat this date.\nconst PARSER_DEPRECATION_DATE = 'August 17th, 2026'\n\nconst DEPRECATION_NOTICE = `\n${chalk.yellow('⚠')} ${chalk.bold(`We've detected framework-specific Code Connect in your project. Starting ${PARSER_DEPRECATION_DATE} Code Connect users should use the new templates format for Code Connect.`)} You may continue publishing, but we recommend following our migration guide to update your Code Connect: https://developers.figma.com/docs/code-connect/templates-migration-guide/`\n\nfunction maybeShowUpdateMessage() {\n if (parserBasedCodeConnectFound && !deprecationWarningHidden) {\n logger.warn(DEPRECATION_NOTICE)\n }\n\n if (updatedVersionAvailable) {\n logger.warn(`\\nA new version of the Figma CLI is available. v${require('../../package.json').version} is currently installed, and the latest version available is v${updatedVersionAvailable}.\n\nTo update, run ${chalk.whiteBright('npm install @figma/code-connect@latest')} for React or HTML, or ${chalk.whiteBright('npm install -g @figma/code-connect@latest')} for other targets (or if you have Code Connect installed globally).`)\n }\n\n if (message) {\n logger.warn(`\\n${message}`)\n }\n}\n\nexport function updateCli() {\n const { execSync } = require('child_process')\n execSync(getUpdateCommand(), { stdio: 'inherit' })\n}\n"]}
@@ -31,6 +31,31 @@ export interface ConnectedComponent {
31
31
  */
32
32
  render<T = unknown>(renderFunction: (props: T) => React.ReactElement): React.ReactElement;
33
33
  }
34
+ /**
35
+ * The value returned by `figma.slot(...)`. It can be used directly as a slot
36
+ * prop (rendering the slot placeholder, exactly as before), and additionally
37
+ * exposes `connectedInstances` to render the code-connected instances placed in
38
+ * the slot, like `figma.children`. For example:
39
+ * ```ts
40
+ * figma.connect(Component, {
41
+ * props: {
42
+ * // Renders the connected instances of the "Content" slot, like figma.children
43
+ * content: figma.slot('Content').connectedInstances,
44
+ * },
45
+ * })
46
+ * ```
47
+ *
48
+ * `InstanceChildrenT` is the platform's slot/instance type (so the bare value
49
+ * keeps behaving as it did before), and `ChildrenT` is the platform's children
50
+ * type, matching the return type of `figma.children`.
51
+ */
52
+ export type SlotValue<InstanceChildrenT, ChildrenT> = InstanceChildrenT & {
53
+ /**
54
+ * The code-connected instances placed in this slot, rendered like
55
+ * `figma.children`.
56
+ */
57
+ connectedInstances: ChildrenT;
58
+ };
34
59
  export interface FigmaConnectAPI<InstanceChildrenT, ChildrenT> {
35
60
  /**
36
61
  * Maps a Figma Variant property to a set if values for the connected component. This prop is replaced
@@ -85,9 +110,17 @@ export interface FigmaConnectAPI<InstanceChildrenT, ChildrenT> {
85
110
  * ```
86
111
  * Would show the "Menu" slot layer connected as an instance property in Figma.
87
112
  *
113
+ * The returned value also exposes `connectedInstances`, which renders the
114
+ * code-connected instances placed in the slot like `figma.children`:
115
+ * ```ts
116
+ * props: {
117
+ * Menu: figma.slot('Menu').connectedInstances,
118
+ * }
119
+ * ```
120
+ *
88
121
  * @param figmaPropName The name of the property on the Figma component
89
122
  */
90
- slot<T = InstanceChildrenT>(figmaPropName: string): T;
123
+ slot<T = SlotValue<InstanceChildrenT, ChildrenT>>(figmaPropName: string): T;
91
124
  /**
92
125
  * Maps a Figma instance layer to a nested code example. For example:
93
126
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/connect/api.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GACjB,MAAM,GACN,OAAO,GACP,MAAM,GACN,MAAM,GACN,SAAS,GACT,KAAK,CAAC,YAAY,GAClB,QAAQ,GACR,MAAM,CAAA;AAEV;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,CAAC,GAAG,GAAG,KAAK,CAAC,CAAA;IACtB;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,cAAc,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC,YAAY,GAAG,KAAK,CAAC,YAAY,CAAA;CAC1F;AASD,MAAM,WAAW,eAAe,CAAC,iBAAiB,EAAE,SAAS;IAC3D;;;;;;;;;;;;;;;OAeG;IACH,IAAI,CAAC,CAAC,SAAS,SAAS,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;IAEpF;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAAA;IAErC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,CAAC,GAAG,iBAAiB,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC,CAAA;IAEzD;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,CAAC,GAAG,iBAAiB,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC,CAAA;IAErD;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IAEpD;;;;;;;;;;;OAWG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CACnC;AAED,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAEnC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;KAC1B,GAAG,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC;CACzB,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;CACZ;AAKD,MAAM,WAAW,gBAAgB,CAC/B,MAAM,GAAG,EAAE,EACX,cAAc,GAAG,EAAE,EACnB,gBAAgB,GAAG,OAAO,EAC1B,aAAa,GAAG,KAAK;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC,CAAA;IAEnD;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;;;;OAKG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,cAAc,KAAK,gBAAgB,CAAC,GAAG,aAAa,CAAA;IAEvE;;OAEG;IACH,KAAK,CAAC,EAAE,gBAAgB,EAAE,CAAA;CAC3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/connect/api.ts"],"names":[],"mappings":"","sourcesContent":["export type EnumValue =\n | string\n | boolean\n | number\n | symbol\n | undefined\n | React.ReactElement\n | Function\n | Object\n\n/**\n * These types are intended to be returned by figma helper functions for exposing the\n * supported output modifiers for that type. There's no implementation for these types,\n * they are resolved to primitive types when the `props` object is passed to `example`.\n */\nexport interface ConnectedComponent {\n /**\n * Returns the resolved props of the connected component. This is useful for accessing\n * the `props` object of a child in a parent context. For example:\n * ```ts\n * figma.connect(\"parent\", {\n * props: {\n * iconProps: figma.instance(\"Icon\").getProps(),\n * },\n * example: (iconProps) => <IconButton iconId={iconProps.iconId} />,\n * }\n */\n getProps<T = any>(): T\n /**\n * Renders the instance with the provided render function. The function is passed the resolved\n * `props` of the nested connected component. This is useful for dynamically rendering a child\n * component depending on parent context. For example:\n * ```ts\n * figma.connect(\"parent\", {\n * props: {\n * icon: figma.instance(\"Icon\").render(({ iconId }) => <Button.Icon iconId={iconId} />),\n * },\n * example: ({ icon }) => <Button icon={icon}/>,\n * }\n */\n render<T = unknown>(renderFunction: (props: T) => React.ReactElement): React.ReactElement\n}\n\n// This contains the base API interface for figma.connect calls across React and\n// HTML. Any parts which are platform-specific (either the function signature or\n// its docblock) are specified in the individual index_<platform> and added to\n// this using union typing.\n//\n// To override a docblock, all signatures of that function must be moved into\n// the platform-specific index file.\nexport interface FigmaConnectAPI<InstanceChildrenT, ChildrenT> {\n /**\n * Maps a Figma Variant property to a set if values for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * type: figma.enum('Type', {\n * Primary: 'primary',\n * Secondary: 'secondary',\n * }),\n * }\n * ```\n * Would output \"primary\" if the Type Variant in Figma is set to \"Primary\".\n *\n * @param figmaPropName The name of the property on the Figma component\n * @param valueMapping A mapping of values for the Figma Variant\n */\n enum<V extends EnumValue>(figmaPropName: string, valueMapping: Record<string, V>): V\n\n /**\n * Maps a Figma property to a string value for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * text: figma.string('Text'),\n * }\n * ```\n * Would replace `text` with the text content from the Figma property \"Text\".\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n string(figmaPropName: string): string\n\n /**\n * Maps a Figma instance property for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * icon: figma.instance('Icon'),\n * }\n * ```\n * Would show the nested examples for the component passed to the \"Icon\" property in Figma.\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n instance<T = InstanceChildrenT>(figmaPropName: string): T\n\n /**\n * Maps a Figma instance property for the connected slot layer. This prop is replaced\n * with values from the Figma slot layer when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * Menu: figma.slot('Menu'),\n * }\n * ```\n * Would show the \"Menu\" slot layer connected as an instance property in Figma.\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n slot<T = InstanceChildrenT>(figmaPropName: string): T\n\n /**\n * Maps a Figma instance layer to a nested code example. For example:\n * ```ts\n * props: {\n * icon: figma.children('Icon')\n * }\n * ```\n * Would show the nested code example for the child instance named 'Icon'. This also supports\n * an array: `tabs: figma.children(['Tab 1', 'Tab 2'])` to map multiple nested examples.\n *\n * You can pass a single wildcard '*' character to match partial names. For example:\n * ```ts\n * props: {\n * icon: figma.children('Icon*')\n * }\n * ```\n * Would show the nested code example for any child instance which name starts with \"Icon\"\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n children(layerNames: string | string[]): ChildrenT\n\n /**\n * Creates a className string by joining an array of strings. The argument supports both\n * string literals and nested functions like `figma.enum` and `figma.boolean` that return\n * a string. For example:\n * ```ts\n * props: {\n * className: figma.className([\n * 'btn-base',\n * figma.enum('Size', { Large: 'btn-large' }),\n * figma.boolean('Disabled', { true: 'btn-disabled', false: '' }),\n * ]),\n * }\n *\n * @param className\n */\n className(className: (string | undefined)[]): string\n\n /**\n * Maps a Figma text layer to a string value representing the text content of that layer.\n * This function takes the layer name within the original component as its parameter.\n * For example:\n * ```ts\n * props: {\n * text: figma.textContent('Text Layer')\n * }\n * ```\n *\n * @param layer The name of the text layer in the Figma component\n */\n textContent(layer: string): string\n}\n\nexport type ValueOf<T> = T[keyof T]\n\nexport type PropMapping<T> = {\n [key in keyof T]: T[key]\n}\n\nexport interface FigmaConnectLink {\n name: string\n url: string\n}\n\n// ExampleFnReturnT is the return type of an example function.\n// ExtraExampleT allows us to pass in an extra type to the `example` property,\n// so that in Storybook, we can use strings to refer to non-hoisted functions\nexport interface FigmaConnectMeta<\n PropsT = {},\n ResolvedPropsT = {},\n ExampleFnReturnT = unknown,\n ExtraExampleT = never,\n> {\n /**\n * Restricts this figma connect to any variants that fullfill the given filter.\n * The filter is a map of Figma variant names to values. Example:\n * ```ts\n * {\n * variant: { \"Has Icon\": true }\n * }\n */\n variant?: Record<string, string | boolean | number>\n\n /**\n * Prop mappings for the connected component. This is used to map the values of the component's props\n * to the values that are used in Figma, using helper functions like `figma.boolean`. For example:\n * ```ts\n * props: {\n * disabled: figma.boolean('Disabled'),\n * text: figma.string('Text'),\n * size: figma.enum('Size', {\n * slim: 'slim',\n * medium: 'medium',\n * large: 'large',\n * }),\n * }\n */\n props?: PropsT\n\n /**\n * The code example to display in Figma. Any mapped `props` are passed to the component,\n * where those values will be replaced with the mapped value when inspecting that instance in Figma.\n * @param props\n * @returns\n */\n example?: ((props: ResolvedPropsT) => ExampleFnReturnT) | ExtraExampleT\n\n /**\n * A list of links that will display in Figma along with the examples\n */\n links?: FigmaConnectLink[]\n}\n"]}
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/connect/api.ts"],"names":[],"mappings":"","sourcesContent":["export type EnumValue =\n string | boolean | number | symbol | undefined | React.ReactElement | Function | Object\n\n/**\n * These types are intended to be returned by figma helper functions for exposing the\n * supported output modifiers for that type. There's no implementation for these types,\n * they are resolved to primitive types when the `props` object is passed to `example`.\n */\nexport interface ConnectedComponent {\n /**\n * Returns the resolved props of the connected component. This is useful for accessing\n * the `props` object of a child in a parent context. For example:\n * ```ts\n * figma.connect(\"parent\", {\n * props: {\n * iconProps: figma.instance(\"Icon\").getProps(),\n * },\n * example: (iconProps) => <IconButton iconId={iconProps.iconId} />,\n * }\n */\n getProps<T = any>(): T\n /**\n * Renders the instance with the provided render function. The function is passed the resolved\n * `props` of the nested connected component. This is useful for dynamically rendering a child\n * component depending on parent context. For example:\n * ```ts\n * figma.connect(\"parent\", {\n * props: {\n * icon: figma.instance(\"Icon\").render(({ iconId }) => <Button.Icon iconId={iconId} />),\n * },\n * example: ({ icon }) => <Button icon={icon}/>,\n * }\n */\n render<T = unknown>(renderFunction: (props: T) => React.ReactElement): React.ReactElement\n}\n\n/**\n * The value returned by `figma.slot(...)`. It can be used directly as a slot\n * prop (rendering the slot placeholder, exactly as before), and additionally\n * exposes `connectedInstances` to render the code-connected instances placed in\n * the slot, like `figma.children`. For example:\n * ```ts\n * figma.connect(Component, {\n * props: {\n * // Renders the connected instances of the \"Content\" slot, like figma.children\n * content: figma.slot('Content').connectedInstances,\n * },\n * })\n * ```\n *\n * `InstanceChildrenT` is the platform's slot/instance type (so the bare value\n * keeps behaving as it did before), and `ChildrenT` is the platform's children\n * type, matching the return type of `figma.children`.\n */\nexport type SlotValue<InstanceChildrenT, ChildrenT> = InstanceChildrenT & {\n /**\n * The code-connected instances placed in this slot, rendered like\n * `figma.children`.\n */\n connectedInstances: ChildrenT\n}\n\n// This contains the base API interface for figma.connect calls across React and\n// HTML. Any parts which are platform-specific (either the function signature or\n// its docblock) are specified in the individual index_<platform> and added to\n// this using union typing.\n//\n// To override a docblock, all signatures of that function must be moved into\n// the platform-specific index file.\nexport interface FigmaConnectAPI<InstanceChildrenT, ChildrenT> {\n /**\n * Maps a Figma Variant property to a set if values for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * type: figma.enum('Type', {\n * Primary: 'primary',\n * Secondary: 'secondary',\n * }),\n * }\n * ```\n * Would output \"primary\" if the Type Variant in Figma is set to \"Primary\".\n *\n * @param figmaPropName The name of the property on the Figma component\n * @param valueMapping A mapping of values for the Figma Variant\n */\n enum<V extends EnumValue>(figmaPropName: string, valueMapping: Record<string, V>): V\n\n /**\n * Maps a Figma property to a string value for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * text: figma.string('Text'),\n * }\n * ```\n * Would replace `text` with the text content from the Figma property \"Text\".\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n string(figmaPropName: string): string\n\n /**\n * Maps a Figma instance property for the connected component. This prop is replaced\n * with values from the Figma instance when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * icon: figma.instance('Icon'),\n * }\n * ```\n * Would show the nested examples for the component passed to the \"Icon\" property in Figma.\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n instance<T = InstanceChildrenT>(figmaPropName: string): T\n\n /**\n * Maps a Figma instance property for the connected slot layer. This prop is replaced\n * with values from the Figma slot layer when viewed in Dev Mode. For example:\n * ```ts\n * props: {\n * Menu: figma.slot('Menu'),\n * }\n * ```\n * Would show the \"Menu\" slot layer connected as an instance property in Figma.\n *\n * The returned value also exposes `connectedInstances`, which renders the\n * code-connected instances placed in the slot like `figma.children`:\n * ```ts\n * props: {\n * Menu: figma.slot('Menu').connectedInstances,\n * }\n * ```\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n slot<T = SlotValue<InstanceChildrenT, ChildrenT>>(figmaPropName: string): T\n\n /**\n * Maps a Figma instance layer to a nested code example. For example:\n * ```ts\n * props: {\n * icon: figma.children('Icon')\n * }\n * ```\n * Would show the nested code example for the child instance named 'Icon'. This also supports\n * an array: `tabs: figma.children(['Tab 1', 'Tab 2'])` to map multiple nested examples.\n *\n * You can pass a single wildcard '*' character to match partial names. For example:\n * ```ts\n * props: {\n * icon: figma.children('Icon*')\n * }\n * ```\n * Would show the nested code example for any child instance which name starts with \"Icon\"\n *\n * @param figmaPropName The name of the property on the Figma component\n */\n children(layerNames: string | string[]): ChildrenT\n\n /**\n * Creates a className string by joining an array of strings. The argument supports both\n * string literals and nested functions like `figma.enum` and `figma.boolean` that return\n * a string. For example:\n * ```ts\n * props: {\n * className: figma.className([\n * 'btn-base',\n * figma.enum('Size', { Large: 'btn-large' }),\n * figma.boolean('Disabled', { true: 'btn-disabled', false: '' }),\n * ]),\n * }\n *\n * @param className\n */\n className(className: (string | undefined)[]): string\n\n /**\n * Maps a Figma text layer to a string value representing the text content of that layer.\n * This function takes the layer name within the original component as its parameter.\n * For example:\n * ```ts\n * props: {\n * text: figma.textContent('Text Layer')\n * }\n * ```\n *\n * @param layer The name of the text layer in the Figma component\n */\n textContent(layer: string): string\n}\n\nexport type ValueOf<T> = T[keyof T]\n\nexport type PropMapping<T> = {\n [key in keyof T]: T[key]\n}\n\nexport interface FigmaConnectLink {\n name: string\n url: string\n}\n\n// ExampleFnReturnT is the return type of an example function.\n// ExtraExampleT allows us to pass in an extra type to the `example` property,\n// so that in Storybook, we can use strings to refer to non-hoisted functions\nexport interface FigmaConnectMeta<\n PropsT = {},\n ResolvedPropsT = {},\n ExampleFnReturnT = unknown,\n ExtraExampleT = never,\n> {\n /**\n * Restricts this figma connect to any variants that fullfill the given filter.\n * The filter is a map of Figma variant names to values. Example:\n * ```ts\n * {\n * variant: { \"Has Icon\": true }\n * }\n */\n variant?: Record<string, string | boolean | number>\n\n /**\n * Prop mappings for the connected component. This is used to map the values of the component's props\n * to the values that are used in Figma, using helper functions like `figma.boolean`. For example:\n * ```ts\n * props: {\n * disabled: figma.boolean('Disabled'),\n * text: figma.string('Text'),\n * size: figma.enum('Size', {\n * slim: 'slim',\n * medium: 'medium',\n * large: 'large',\n * }),\n * }\n */\n props?: PropsT\n\n /**\n * The code example to display in Figma. Any mapped `props` are passed to the component,\n * where those values will be replaced with the mapped value when inspecting that instance in Figma.\n * @param props\n * @returns\n */\n example?: ((props: ResolvedPropsT) => ExampleFnReturnT) | ExtraExampleT\n\n /**\n * A list of links that will display in Figma along with the examples\n */\n links?: FigmaConnectLink[]\n}\n"]}
@@ -7,5 +7,5 @@ import { CodeConnectConfig } from './project';
7
7
  * that prepend `window['__FIGMA_BATCH'] = <data>` to the template. The figma
8
8
  * runtime exposes this as `figma.batch`.
9
9
  */
10
- export declare function parseBatchFile(filePath: string, label: string | undefined, config?: CodeConnectConfig, dir?: string): CodeConnectJSON[];
10
+ export declare function parseBatchFile(filePath: string, label: string | undefined, config?: CodeConnectConfig, dir?: string): Promise<CodeConnectJSON[]>;
11
11
  //# sourceMappingURL=batch_templates.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"batch_templates.d.ts","sourceRoot":"","sources":["../../src/connect/batch_templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAuC7C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,GAAG,CAAC,EAAE,MAAM,GACX,eAAe,EAAE,CA8CnB"}
1
+ {"version":3,"file":"batch_templates.d.ts","sourceRoot":"","sources":["../../src/connect/batch_templates.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAuC7C;;;;;;GAMG;AACH,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,MAAM,CAAC,EAAE,iBAAiB,EAC1B,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,eAAe,EAAE,CAAC,CA8C5B"}