@figma/code-connect 1.4.7 → 1.4.9

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 (47) hide show
  1. package/dist/commands/connect.d.ts +3 -0
  2. package/dist/commands/connect.d.ts.map +1 -1
  3. package/dist/commands/connect.js +140 -40
  4. package/dist/commands/connect.js.map +1 -1
  5. package/dist/commands/connect_template.d.ts.map +1 -1
  6. package/dist/commands/connect_template.js +9 -0
  7. package/dist/commands/connect_template.js.map +1 -1
  8. package/dist/common/logging.d.ts.map +1 -1
  9. package/dist/common/logging.js +13 -6
  10. package/dist/common/logging.js.map +1 -1
  11. package/dist/common/updates.d.ts.map +1 -1
  12. package/dist/common/updates.js +2 -2
  13. package/dist/common/updates.js.map +1 -1
  14. package/dist/connect/api.d.ts +34 -1
  15. package/dist/connect/api.d.ts.map +1 -1
  16. package/dist/connect/api.js.map +1 -1
  17. package/dist/connect/intrinsics.d.ts +1 -0
  18. package/dist/connect/intrinsics.d.ts.map +1 -1
  19. package/dist/connect/intrinsics.js +29 -0
  20. package/dist/connect/intrinsics.js.map +1 -1
  21. package/dist/connect/migration_batch_helpers.d.ts +45 -0
  22. package/dist/connect/migration_batch_helpers.d.ts.map +1 -0
  23. package/dist/connect/migration_batch_helpers.js +439 -0
  24. package/dist/connect/migration_batch_helpers.js.map +1 -0
  25. package/dist/connect/migration_helpers.d.ts +4 -0
  26. package/dist/connect/migration_helpers.d.ts.map +1 -1
  27. package/dist/connect/migration_helpers.js +29 -5
  28. package/dist/connect/migration_helpers.js.map +1 -1
  29. package/dist/connect/parser_executables.d.ts.map +1 -1
  30. package/dist/connect/parser_executables.js +25 -13
  31. package/dist/connect/parser_executables.js.map +1 -1
  32. package/dist/connect/project.d.ts +2 -1
  33. package/dist/connect/project.d.ts.map +1 -1
  34. package/dist/connect/project.js +26 -24
  35. package/dist/connect/project.js.map +1 -1
  36. package/dist/connect/raw_templates.d.ts +10 -0
  37. package/dist/connect/raw_templates.d.ts.map +1 -1
  38. package/dist/connect/raw_templates.js +48 -14
  39. package/dist/connect/raw_templates.js.map +1 -1
  40. package/dist/connect/wizard/helpers.d.ts.map +1 -1
  41. package/dist/connect/wizard/helpers.js +7 -2
  42. package/dist/connect/wizard/helpers.js.map +1 -1
  43. package/dist/parser_scripts/get_swift_parser_dir.js +5 -5
  44. package/dist/parser_scripts/get_swift_parser_dir.js.map +1 -1
  45. package/figma-types-no-require.d.ts +229 -0
  46. package/figma-types.d.ts +12 -3
  47. package/package.json +7 -3
@@ -1 +1 @@
1
- {"version":3,"file":"connect_template.js","sourceRoot":"","sources":["../../src/commands/connect_template.ts"],"names":[],"mappings":";;;;;AAqUA,0EAyHC;AA1bD,4CAAmB;AACnB,8CAA0C;AAC1C,sDAAoD;AACpD,gDAAgE;AAChE,+CAAuF;AAEvF,wDAAoD;AACpD,gDAA4D;AAC5D,4DAAsE;AACtE,gEAA2D;AAC3D,+DAA+D;AAC/D,gEAAqE;AAmBrE,SAAS,oBAAoB,CAAC,GAAgB;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;IACvB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAA,uBAAa,EACX,GAAG,CAAC,QAAQ;YACV,CAAC,CAAC,4DAA4D;YAC9D,CAAC,CAAC,4FAA4F,CACjG,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,YAAY,CAAC,GAAgB;IACpC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAChB,gBAAM,CAAC,WAAW,CAAC,kBAAQ,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,GAAgB;IAC9B,OAAO,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;AACjC,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,qBAAqB,CAClC,GAAqC,EACrC,WAAwB,EACxB,MAAM,GAAG,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EACT,oGAAoG;QAClG,oJAAoJ;QACpJ,sIAAsI,CACzI;SACE,MAAM,CAAC,mBAAmB,EAAE,sCAAsC,CAAC;SACnE,MAAM,CAAC,oBAAoB,EAAE,uCAAuC,CAAC;SACrE,MAAM,CACL,8BAA8B,EAC9B,sJAAsJ,CACvJ;SACA,MAAM,CACL,SAAS,EACT,qGAAqG,CACtG;SACA,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAErC,OAAO,CACL,cAAc,EACd,WAAW,EACX,mFAAmF;QACjF,oJAAoJ;QACpJ,uIAAuI;QACvI,8EAA8E,CACjF;SACE,MAAM,CACL,uBAAuB,EACvB,6EAA6E,CAC9E;SACA,MAAM,CAAC,oBAAoB,EAAE,wBAAwB,CAAC;SACtD,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;IAEvC,OAAO,CACL,cAAc,EACd,OAAO,EACP,2HAA2H,CAC5H;SACE,MAAM,CAAC,oBAAoB,EAAE,oCAAoC,CAAC;SAClE,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;IAEnC,OAAO,CACL,cAAc,EACd,QAAQ,EACR,6FAA6F,CAC9F;SACE,QAAQ,CAAC,kBAAkB,EAAE,qDAAqD,CAAC;SACnF,MAAM,CAAC,CAAC,OAAe,EAAE,OAAgB,EAAE,GAAsB,EAAE,EAAE,CACpE,WAAW,CAAc,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CACxF,CAAA;AACL,CAAC","sourcesContent":["/**\n * Slim Code Connect entry point template-files-only support.\n */\nimport * as commander from 'commander'\nimport fs from 'fs'\nimport { upload } from '../connect/upload'\nimport { validateDocs } from '../connect/validation'\nimport { ProjectInfo, getProjectInfo } from '../connect/project'\nimport { LogLevel, exitWithError, highlight, logger, success } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { delete_docs } from '../connect/delete_docs'\nimport { exitWithFeedbackMessage } from '../connect/helpers'\nimport { isRawTemplate, parseRawFile } from '../connect/raw_templates'\nimport { parseBatchFile } from '../connect/batch_templates'\nimport { filterProjectInfoByFile } from './filter_project_info'\nimport { createCodeConnectFromUrl } from '../connect/create_template'\n\nexport type BaseCommand = commander.Command & {\n token: string\n useOAuth: boolean\n verbose: boolean\n outFile: string\n outDir: string\n config: string\n dryRun: boolean\n dir: string\n file: string[]\n jsonFile: string\n skipUpdateCheck: boolean\n exitOnUnreadableFiles: boolean\n apiUrl?: string\n includeProps?: boolean\n}\n\nfunction getAccessTokenOrExit(cmd: BaseCommand): string {\n const token = cmd.token\n if (!token) {\n exitWithError(\n cmd.useOAuth\n ? `Couldn't find a Figma OAuth token. Please re-authenticate.`\n : `Couldn't find a Figma access token. Please set the FIGMA_ACCESS_TOKEN environment variable`,\n )\n }\n return token\n}\n\nfunction setupHandler(cmd: BaseCommand) {\n if (cmd.verbose) {\n logger.setLogLevel(LogLevel.Debug)\n }\n}\n\nfunction getDir(cmd: BaseCommand) {\n return cmd.dir ?? process.cwd()\n}\n\n/**\n * Returns Code Connect objects from template files (.figma.ts / .figma.js)\n * only. Native parser paths (react, html, executable) are intentionally\n * omitted — this entry point is for parserless/template-file workflows.\n */\nasync function getCodeConnectObjects(\n cmd: BaseCommand & { label?: string },\n projectInfo: ProjectInfo,\n silent = false,\n): Promise<CodeConnectJSON[]> {\n const rawTemplateFiles = projectInfo.files.filter((f: string) => {\n const isPotentialRawTemplate =\n f.endsWith('.figma.js') ||\n f.endsWith('.figma.template.js') ||\n f.endsWith('.figma.ts') ||\n f.endsWith('.figma.template.ts')\n if (!isPotentialRawTemplate) return false\n try {\n return isRawTemplate(fs.readFileSync(f, 'utf-8'))\n } catch {\n return false\n }\n })\n\n let codeConnectObjects: CodeConnectJSON[] = []\n\n if (rawTemplateFiles.length > 0) {\n const resolvedLabel = cmd.label || projectInfo.config.label\n const rawTemplateDocs: CodeConnectJSON[] = []\n for (const file of rawTemplateFiles) {\n try {\n const doc = parseRawFile(file, resolvedLabel, projectInfo.config, projectInfo.absPath)\n doc._codeConnectFilePath = file\n if (!silent || cmd.verbose) {\n logger.info(success(file))\n }\n rawTemplateDocs.push(doc)\n } catch (e) {\n if (!silent || cmd.verbose) {\n logger.error(`❌ ${file}`)\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(e instanceof Error ? e.message : String(e))\n }\n }\n if (cmd.exitOnUnreadableFiles) {\n logger.info('Exiting due to unreadable files')\n process.exit(1)\n }\n }\n }\n codeConnectObjects = codeConnectObjects.concat(rawTemplateDocs)\n }\n\n // Process batch files (.figma.batch.json)\n const batchFiles = projectInfo.files.filter((f: string) => f.endsWith('.figma.batch.json'))\n\n if (batchFiles.length > 0) {\n const resolvedLabel = cmd.label || projectInfo.config.label\n\n for (const file of batchFiles) {\n try {\n const docs = parseBatchFile(file, resolvedLabel, projectInfo.config, projectInfo.absPath)\n docs.forEach((doc) => {\n doc._codeConnectFilePath = file\n })\n codeConnectObjects = codeConnectObjects.concat(docs)\n if (!silent || cmd.verbose) {\n logger.info(success(`${file} (${docs.length} components)`))\n }\n } catch (e) {\n logger.error(`${file}: ${e}`)\n if (cmd.exitOnUnreadableFiles) {\n process.exit(1)\n }\n }\n }\n }\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label \"${cmd.label || projectInfo.config.label}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.label = cmd.label || projectInfo.config.label || doc.label\n })\n }\n\n if (projectInfo.config.language) {\n logger.info(`Using language \"${projectInfo.config.language}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.language = projectInfo.config.language || doc.language\n })\n }\n\n return codeConnectObjects\n}\n\nasync function handlePublish(\n cmd: BaseCommand & {\n skipValidation: boolean\n label: string\n batchSize: string\n force?: boolean\n },\n) {\n setupHandler(cmd)\n\n let dir = getDir(cmd)\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config, true), cmd.file)\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (codeConnectObjects.length === 0) {\n logger.warn(\n `No Code Connect files found in ${dir} - Make sure you have configured \\`include\\` and \\`exclude\\` in your figma.config.json file correctly, or that you are running in a directory that contains Code Connect files.`,\n )\n process.exit(0)\n }\n\n if (cmd.dryRun) {\n logger.info(`Files that would be published:`)\n logger.info(codeConnectObjects.map((o) => `- ${o.component} (${o.figmaNode})`).join('\\n'))\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n if (cmd.skipValidation) {\n logger.info('Validation skipped')\n } else {\n logger.info('Validating Code Connect files...')\n const start = new Date().getTime()\n const valid = await validateDocs(\n cmd,\n accessToken,\n codeConnectObjects,\n cmd.apiUrl || projectInfo.config.apiUrl,\n cmd.useOAuth,\n )\n if (!valid) {\n exitWithFeedbackMessage(1)\n } else {\n const end = new Date().getTime()\n const time = end - start\n logger.info(`All Code Connect files are valid (${time}ms)`)\n }\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n let batchSize\n if (cmd.batchSize) {\n batchSize = parseInt(cmd.batchSize, 10)\n if (isNaN(batchSize)) {\n logger.error('Error: failed to parse batch-size. batch-size passed must be a number')\n exitWithFeedbackMessage(1)\n }\n }\n\n upload({\n accessToken,\n useOAuth: cmd.useOAuth,\n docs: codeConnectObjects,\n batchSize,\n verbose: cmd.verbose,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n force: cmd.force,\n })\n}\n\nasync function handleUnpublish(cmd: BaseCommand & { node: string; label: string }) {\n setupHandler(cmd)\n\n let dir = getDir(cmd)\n\n if (cmd.dryRun) {\n logger.info(`Files that would be unpublished:`)\n }\n\n let nodesToDeleteRelevantInfo\n\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config, true), cmd.file)\n\n if (cmd.node) {\n if (!cmd.label) {\n exitWithError('Label is required when specifying a node')\n }\n nodesToDeleteRelevantInfo = [{ figmaNode: cmd.node, label: cmd.label }]\n } else {\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n nodesToDeleteRelevantInfo = codeConnectObjects.map((doc) => ({\n figmaNode: doc.figmaNode,\n label: cmd.label || projectInfo.config.label || doc.label,\n }))\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label ${cmd.label || projectInfo.config.label}`)\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n delete_docs({\n accessToken,\n useOAuth: cmd.useOAuth,\n docs: nodesToDeleteRelevantInfo,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n })\n}\n\nasync function handleParse(cmd: BaseCommand & { label: string }) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config, true), cmd.file)\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n if (cmd.outFile) {\n fs.writeFileSync(cmd.outFile, JSON.stringify(codeConnectObjects, null, 2))\n logger.info(`Wrote Code Connect JSON to ${highlight(cmd.outFile)}`)\n } else {\n console.log(JSON.stringify(codeConnectObjects, undefined, 2))\n }\n}\n\nasync function handleCreate(nodeUrl: string, cmd: BaseCommand) {\n setupHandler(cmd)\n\n const dir = getDir(cmd)\n const projectInfo = await getProjectInfo(dir, cmd.config, true)\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n return createCodeConnectFromUrl({\n accessToken,\n figmaNodeUrl: nodeUrl.replace(/\\\\/g, ''),\n outFile: cmd.outFile,\n outDir: cmd.outDir,\n projectInfo,\n cmd,\n })\n}\n\ninterface ProgramOptions {\n /** Override how the auth token is retrieved. Return undefined to fall back to FIGMA_ACCESS_TOKEN. */\n getToken?: () => string | undefined\n}\n\n/**\n * Registers Code Connect commands on a commander program, restricted to\n * template-file workflows only. Intended for use by CLIs that support\n * Code Connect during a migration period but do not need native parsers.\n *\n * Note: does NOT use addBaseCommand internally because that function registers\n * both `-o --outFile` and `-o --outDir` with the same `-o` short flag.\n * commander@12+ (used by @figma/cli) throws a conflict error on duplicate flags.\n */\nexport function addCodeConnectCommandsToProgram(\n program: commander.Command,\n programOptions: ProgramOptions = {},\n) {\n function addBase(parent: commander.Command, name: string, description: string) {\n return parent\n .command(name)\n .description(description)\n .usage('[options]')\n .option('-r --dir <dir>', 'directory to parse')\n .option(\n '-f --file <file...>',\n 'paths to one or more Code Connect files to process (space-separated)',\n )\n .option('--outFile <file>', 'specify a file to output generated Code Connect')\n .option('--outDir <dir>', 'specify a directory to output generated Code Connect')\n .option('-c --config <path>', 'path to a figma config file')\n .option(\n '--exit-on-unreadable-files',\n 'exit if any Code Connect files cannot be parsed. We recommend using this option for CI/CD.',\n )\n .option('--dry-run', 'tests publishing without actually publishing')\n .addHelpText(\n 'before',\n 'For feedback or bugs, please raise an issue: https://github.com/figma/code-connect/issues',\n )\n }\n\n function wrapHandler<T extends BaseCommand>(handler: (cmd: T) => Promise<void>) {\n return (options: unknown, cmd: commander.Command) => {\n const globalOpts = cmd.optsWithGlobals<{ logLevel?: string; apiBaseUrl?: string }>()\n\n // Attempt to get a token from the provided getter (e.g. OAuth store).\n // If it returns undefined or throws (e.g. no OAuth token stored in CI),\n // fall back to FIGMA_ACCESS_TOKEN and use PAT headers.\n let oauthToken: string | undefined\n try {\n oauthToken = programOptions.getToken?.()\n } catch {\n // getToken threw (e.g. no OAuth token stored); fall back to PAT below\n }\n const token = oauthToken ?? process.env.FIGMA_ACCESS_TOKEN\n const useOAuth = oauthToken !== undefined\n\n return handler({\n ...(options as object),\n token,\n useOAuth,\n verbose: globalOpts.logLevel === 'debug',\n apiUrl: globalOpts.apiBaseUrl,\n } as unknown as T).catch((err: Error) => {\n // Commander v12 catches rejected action promises internally and exits 0.\n // Commander v11 left them as unhandled rejections, and Node.js 15+ would\n // exit 1 for those — so exit code 1 on handler errors was previously\n // accidental. This catch makes it explicit and version-independent.\n logger.error(err.message)\n process.exitCode = 1\n })\n }\n }\n\n const connectCommand = program\n .command('connect')\n .description('Code Connect commands')\n .addHelpText(\n 'before',\n 'For feedback or bugs, please raise an issue: https://github.com/figma/code-connect/issues',\n )\n connectCommand.action(() => connectCommand.help())\n\n addBase(\n connectCommand,\n 'publish',\n 'Run Code Connect locally to find any files that have figma connections and publish them to Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse.',\n )\n .option('--skip-validation', 'skip validation of Code Connect docs')\n .option('-l --label <label>', 'label to apply to the published files')\n .option(\n '-b --batch-size <batch_size>',\n 'optional batch size (in number of documents) to use when uploading. Use this if you hit \"request too large\" errors. See README for more information.',\n )\n .option(\n '--force',\n 'overwrite existing UI-created Code Connect mappings if they conflict with the files being published',\n )\n .action(wrapHandler(handlePublish))\n\n addBase(\n connectCommand,\n 'unpublish',\n 'Run to find any files that have figma connections and unpublish them from Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse. ' +\n 'Alternatively, use `--node` and `--label` to unpublish a specific component.',\n )\n .option(\n '--node <link_to_node>',\n 'specify the node to unpublish. This will unpublish for the specified label.',\n )\n .option('-l --label <label>', 'label to unpublish for')\n .action(wrapHandler(handleUnpublish))\n\n addBase(\n connectCommand,\n 'parse',\n 'Run Code Connect locally to find any files that have figma connections, then converts them to JSON and outputs to stdout.',\n )\n .option('-l --label <label>', 'label to apply to the parsed files')\n .action(wrapHandler(handleParse))\n\n addBase(\n connectCommand,\n 'create',\n 'Generate a Code Connect file with boilerplate in the current directory for a Figma node URL',\n )\n .argument('<figma-node-url>', 'Figma node URL to create the Code Connect file from')\n .action((nodeUrl: string, options: unknown, cmd: commander.Command) =>\n wrapHandler<BaseCommand>((mergedCmd) => handleCreate(nodeUrl, mergedCmd))(options, cmd),\n )\n}\n"]}
1
+ {"version":3,"file":"connect_template.js","sourceRoot":"","sources":["../../src/commands/connect_template.ts"],"names":[],"mappings":";;;;;AA8UA,0EAyHC;AAncD,4CAAmB;AACnB,8CAA0C;AAC1C,sDAAoD;AACpD,gDAAgE;AAChE,+CAAuF;AAEvF,wDAAoD;AACpD,gDAA4D;AAC5D,4DAA2F;AAC3F,gEAA2D;AAC3D,+DAA+D;AAC/D,gEAAqE;AAmBrE,SAAS,oBAAoB,CAAC,GAAgB;IAC5C,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAA;IACvB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,IAAA,uBAAa,EACX,GAAG,CAAC,QAAQ;YACV,CAAC,CAAC,4DAA4D;YAC9D,CAAC,CAAC,4FAA4F,CACjG,CAAA;IACH,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED,SAAS,YAAY,CAAC,GAAgB;IACpC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;QAChB,gBAAM,CAAC,WAAW,CAAC,kBAAQ,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAC,GAAgB;IAC9B,OAAO,GAAG,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;AACjC,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,qBAAqB,CAClC,GAAqC,EACrC,WAAwB,EACxB,MAAM,GAAG,KAAK;IAEd,MAAM,gBAAgB,GAAG,WAAW,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAS,EAAE,EAAE;QAC9D,MAAM,sBAAsB,GAC1B,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;YACvB,CAAC,CAAC,QAAQ,CAAC,oBAAoB,CAAC;YAChC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC;YACvB,CAAC,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oGAAoG;QAClG,oJAAoJ;QACpJ,sIAAsI,CACzI;SACE,MAAM,CAAC,mBAAmB,EAAE,sCAAsC,CAAC;SACnE,MAAM,CAAC,oBAAoB,EAAE,uCAAuC,CAAC;SACrE,MAAM,CACL,8BAA8B,EAC9B,sJAAsJ,CACvJ;SACA,MAAM,CACL,SAAS,EACT,qGAAqG,CACtG;SACA,MAAM,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,CAAA;IAErC,OAAO,CACL,cAAc,EACd,WAAW,EACX,mFAAmF;QACjF,oJAAoJ;QACpJ,uIAAuI;QACvI,8EAA8E,CACjF;SACE,MAAM,CACL,uBAAuB,EACvB,6EAA6E,CAC9E;SACA,MAAM,CAAC,oBAAoB,EAAE,wBAAwB,CAAC;SACtD,MAAM,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC,CAAA;IAEvC,OAAO,CACL,cAAc,EACd,OAAO,EACP,2HAA2H,CAC5H;SACE,MAAM,CAAC,oBAAoB,EAAE,oCAAoC,CAAC;SAClE,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAA;IAEnC,OAAO,CACL,cAAc,EACd,QAAQ,EACR,6FAA6F,CAC9F;SACE,QAAQ,CAAC,kBAAkB,EAAE,qDAAqD,CAAC;SACnF,MAAM,CAAC,CAAC,OAAe,EAAE,OAAgB,EAAE,GAAsB,EAAE,EAAE,CACpE,WAAW,CAAc,CAAC,SAAS,EAAE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,CAAC,CACxF,CAAA;AACL,CAAC","sourcesContent":["/**\n * Slim Code Connect entry point template-files-only support.\n */\nimport * as commander from 'commander'\nimport fs from 'fs'\nimport { upload } from '../connect/upload'\nimport { validateDocs } from '../connect/validation'\nimport { ProjectInfo, getProjectInfo } from '../connect/project'\nimport { LogLevel, exitWithError, highlight, logger, success } from '../common/logging'\nimport { CodeConnectJSON } from '../connect/figma_connect'\nimport { delete_docs } from '../connect/delete_docs'\nimport { exitWithFeedbackMessage } from '../connect/helpers'\nimport { CodePropertiesError, isRawTemplate, parseRawFile } from '../connect/raw_templates'\nimport { parseBatchFile } from '../connect/batch_templates'\nimport { filterProjectInfoByFile } from './filter_project_info'\nimport { createCodeConnectFromUrl } from '../connect/create_template'\n\nexport type BaseCommand = commander.Command & {\n token: string\n useOAuth: boolean\n verbose: boolean\n outFile: string\n outDir: string\n config: string\n dryRun: boolean\n dir: string\n file: string[]\n jsonFile: string\n skipUpdateCheck: boolean\n exitOnUnreadableFiles: boolean\n apiUrl?: string\n includeProps?: boolean\n}\n\nfunction getAccessTokenOrExit(cmd: BaseCommand): string {\n const token = cmd.token\n if (!token) {\n exitWithError(\n cmd.useOAuth\n ? `Couldn't find a Figma OAuth token. Please re-authenticate.`\n : `Couldn't find a Figma access token. Please set the FIGMA_ACCESS_TOKEN environment variable`,\n )\n }\n return token\n}\n\nfunction setupHandler(cmd: BaseCommand) {\n if (cmd.verbose) {\n logger.setLogLevel(LogLevel.Debug)\n }\n}\n\nfunction getDir(cmd: BaseCommand) {\n return cmd.dir ?? process.cwd()\n}\n\n/**\n * Returns Code Connect objects from template files (.figma.ts / .figma.js)\n * only. Native parser paths (react, html, executable) are intentionally\n * omitted — this entry point is for parserless/template-file workflows.\n */\nasync function getCodeConnectObjects(\n cmd: BaseCommand & { label?: string },\n projectInfo: ProjectInfo,\n silent = false,\n): Promise<CodeConnectJSON[]> {\n const rawTemplateFiles = projectInfo.files.filter((f: string) => {\n const isPotentialRawTemplate =\n f.endsWith('.figma.js') ||\n f.endsWith('.figma.template.js') ||\n f.endsWith('.figma.ts') ||\n f.endsWith('.figma.template.ts')\n if (!isPotentialRawTemplate) return false\n try {\n return isRawTemplate(fs.readFileSync(f, 'utf-8'))\n } catch {\n return false\n }\n })\n\n let codeConnectObjects: CodeConnectJSON[] = []\n\n if (rawTemplateFiles.length > 0) {\n const resolvedLabel = cmd.label || projectInfo.config.label\n const rawTemplateDocs: CodeConnectJSON[] = []\n for (const file of rawTemplateFiles) {\n try {\n const doc = parseRawFile(file, resolvedLabel, projectInfo.config, projectInfo.absPath)\n doc._codeConnectFilePath = file\n if (!silent || cmd.verbose) {\n logger.info(success(file))\n }\n rawTemplateDocs.push(doc)\n } catch (e) {\n // A url-less file containing `codeProperties` is not Code Connect (e.g.\n // Make's code component property definitions). Log and skip it instead\n // of failing — never exit, not even with --exit-on-unreadable-files.\n if (e instanceof CodePropertiesError) {\n if (!silent || cmd.verbose) {\n logger.info(e.message)\n }\n continue\n }\n if (!silent || cmd.verbose) {\n logger.error(`❌ ${file}`)\n if (cmd.verbose) {\n console.trace(e)\n } else {\n logger.error(e instanceof Error ? e.message : String(e))\n }\n }\n if (cmd.exitOnUnreadableFiles) {\n logger.info('Exiting due to unreadable files')\n process.exit(1)\n }\n }\n }\n codeConnectObjects = codeConnectObjects.concat(rawTemplateDocs)\n }\n\n // Process batch files (.figma.batch.json)\n const batchFiles = projectInfo.files.filter((f: string) => f.endsWith('.figma.batch.json'))\n\n if (batchFiles.length > 0) {\n const resolvedLabel = cmd.label || projectInfo.config.label\n\n for (const file of batchFiles) {\n try {\n const docs = parseBatchFile(file, resolvedLabel, projectInfo.config, projectInfo.absPath)\n docs.forEach((doc) => {\n doc._codeConnectFilePath = file\n })\n codeConnectObjects = codeConnectObjects.concat(docs)\n if (!silent || cmd.verbose) {\n logger.info(success(`${file} (${docs.length} components)`))\n }\n } catch (e) {\n logger.error(`${file}: ${e}`)\n if (cmd.exitOnUnreadableFiles) {\n process.exit(1)\n }\n }\n }\n }\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label \"${cmd.label || projectInfo.config.label}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.label = cmd.label || projectInfo.config.label || doc.label\n })\n }\n\n if (projectInfo.config.language) {\n logger.info(`Using language \"${projectInfo.config.language}\"`)\n codeConnectObjects.forEach((doc) => {\n doc.language = projectInfo.config.language || doc.language\n })\n }\n\n return codeConnectObjects\n}\n\nasync function handlePublish(\n cmd: BaseCommand & {\n skipValidation: boolean\n label: string\n batchSize: string\n force?: boolean\n },\n) {\n setupHandler(cmd)\n\n let dir = getDir(cmd)\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config, true), cmd.file)\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (codeConnectObjects.length === 0) {\n logger.warn(\n `No Code Connect files found in ${dir} - Make sure you have configured \\`include\\` and \\`exclude\\` in your figma.config.json file correctly, or that you are running in a directory that contains Code Connect files.`,\n )\n process.exit(0)\n }\n\n if (cmd.dryRun) {\n logger.info(`Files that would be published:`)\n logger.info(codeConnectObjects.map((o) => `- ${o.component} (${o.figmaNode})`).join('\\n'))\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n if (cmd.skipValidation) {\n logger.info('Validation skipped')\n } else {\n logger.info('Validating Code Connect files...')\n const start = new Date().getTime()\n const valid = await validateDocs(\n cmd,\n accessToken,\n codeConnectObjects,\n cmd.apiUrl || projectInfo.config.apiUrl,\n cmd.useOAuth,\n )\n if (!valid) {\n exitWithFeedbackMessage(1)\n } else {\n const end = new Date().getTime()\n const time = end - start\n logger.info(`All Code Connect files are valid (${time}ms)`)\n }\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n let batchSize\n if (cmd.batchSize) {\n batchSize = parseInt(cmd.batchSize, 10)\n if (isNaN(batchSize)) {\n logger.error('Error: failed to parse batch-size. batch-size passed must be a number')\n exitWithFeedbackMessage(1)\n }\n }\n\n upload({\n accessToken,\n useOAuth: cmd.useOAuth,\n docs: codeConnectObjects,\n batchSize,\n verbose: cmd.verbose,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n force: cmd.force,\n })\n}\n\nasync function handleUnpublish(cmd: BaseCommand & { node: string; label: string }) {\n setupHandler(cmd)\n\n let dir = getDir(cmd)\n\n if (cmd.dryRun) {\n logger.info(`Files that would be unpublished:`)\n }\n\n let nodesToDeleteRelevantInfo\n\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config, true), cmd.file)\n\n if (cmd.node) {\n if (!cmd.label) {\n exitWithError('Label is required when specifying a node')\n }\n nodesToDeleteRelevantInfo = [{ figmaNode: cmd.node, label: cmd.label }]\n } else {\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n nodesToDeleteRelevantInfo = codeConnectObjects.map((doc) => ({\n figmaNode: doc.figmaNode,\n label: cmd.label || projectInfo.config.label || doc.label,\n }))\n\n if (cmd.label || projectInfo.config.label) {\n logger.info(`Using label ${cmd.label || projectInfo.config.label}`)\n }\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n }\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n delete_docs({\n accessToken,\n useOAuth: cmd.useOAuth,\n docs: nodesToDeleteRelevantInfo,\n apiUrl: cmd.apiUrl || projectInfo.config.apiUrl,\n })\n}\n\nasync function handleParse(cmd: BaseCommand & { label: string }) {\n setupHandler(cmd)\n\n const dir = cmd.dir ?? process.cwd()\n const projectInfo = filterProjectInfoByFile(await getProjectInfo(dir, cmd.config, true), cmd.file)\n const codeConnectObjects = await getCodeConnectObjects(cmd, projectInfo)\n\n if (cmd.dryRun) {\n logger.info(`Dry run complete`)\n process.exit(0)\n }\n\n if (cmd.outFile) {\n fs.writeFileSync(cmd.outFile, JSON.stringify(codeConnectObjects, null, 2))\n logger.info(`Wrote Code Connect JSON to ${highlight(cmd.outFile)}`)\n } else {\n console.log(JSON.stringify(codeConnectObjects, undefined, 2))\n }\n}\n\nasync function handleCreate(nodeUrl: string, cmd: BaseCommand) {\n setupHandler(cmd)\n\n const dir = getDir(cmd)\n const projectInfo = await getProjectInfo(dir, cmd.config, true)\n\n const accessToken = getAccessTokenOrExit(cmd)\n\n return createCodeConnectFromUrl({\n accessToken,\n figmaNodeUrl: nodeUrl.replace(/\\\\/g, ''),\n outFile: cmd.outFile,\n outDir: cmd.outDir,\n projectInfo,\n cmd,\n })\n}\n\ninterface ProgramOptions {\n /** Override how the auth token is retrieved. Return undefined to fall back to FIGMA_ACCESS_TOKEN. */\n getToken?: () => string | undefined\n}\n\n/**\n * Registers Code Connect commands on a commander program, restricted to\n * template-file workflows only. Intended for use by CLIs that support\n * Code Connect during a migration period but do not need native parsers.\n *\n * Note: does NOT use addBaseCommand internally because that function registers\n * both `-o --outFile` and `-o --outDir` with the same `-o` short flag.\n * commander@12+ (used by @figma/cli) throws a conflict error on duplicate flags.\n */\nexport function addCodeConnectCommandsToProgram(\n program: commander.Command,\n programOptions: ProgramOptions = {},\n) {\n function addBase(parent: commander.Command, name: string, description: string) {\n return parent\n .command(name)\n .description(description)\n .usage('[options]')\n .option('-r --dir <dir>', 'directory to parse')\n .option(\n '-f --file <file...>',\n 'paths to one or more Code Connect files to process (space-separated)',\n )\n .option('--outFile <file>', 'specify a file to output generated Code Connect')\n .option('--outDir <dir>', 'specify a directory to output generated Code Connect')\n .option('-c --config <path>', 'path to a figma config file')\n .option(\n '--exit-on-unreadable-files',\n 'exit if any Code Connect files cannot be parsed. We recommend using this option for CI/CD.',\n )\n .option('--dry-run', 'tests publishing without actually publishing')\n .addHelpText(\n 'before',\n 'For feedback or bugs, please raise an issue: https://github.com/figma/code-connect/issues',\n )\n }\n\n function wrapHandler<T extends BaseCommand>(handler: (cmd: T) => Promise<void>) {\n return (options: unknown, cmd: commander.Command) => {\n const globalOpts = cmd.optsWithGlobals<{ logLevel?: string; apiBaseUrl?: string }>()\n\n // Attempt to get a token from the provided getter (e.g. OAuth store).\n // If it returns undefined or throws (e.g. no OAuth token stored in CI),\n // fall back to FIGMA_ACCESS_TOKEN and use PAT headers.\n let oauthToken: string | undefined\n try {\n oauthToken = programOptions.getToken?.()\n } catch {\n // getToken threw (e.g. no OAuth token stored); fall back to PAT below\n }\n const token = oauthToken ?? process.env.FIGMA_ACCESS_TOKEN\n const useOAuth = oauthToken !== undefined\n\n return handler({\n ...(options as object),\n token,\n useOAuth,\n verbose: globalOpts.logLevel === 'debug',\n apiUrl: globalOpts.apiBaseUrl,\n } as unknown as T).catch((err: Error) => {\n // Commander v12 catches rejected action promises internally and exits 0.\n // Commander v11 left them as unhandled rejections, and Node.js 15+ would\n // exit 1 for those — so exit code 1 on handler errors was previously\n // accidental. This catch makes it explicit and version-independent.\n logger.error(err.message)\n process.exitCode = 1\n })\n }\n }\n\n const connectCommand = program\n .command('connect')\n .description('Code Connect commands')\n .addHelpText(\n 'before',\n 'For feedback or bugs, please raise an issue: https://github.com/figma/code-connect/issues',\n )\n connectCommand.action(() => connectCommand.help())\n\n addBase(\n connectCommand,\n 'publish',\n 'Run Code Connect locally to find any files that have figma connections and publish them to Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse.',\n )\n .option('--skip-validation', 'skip validation of Code Connect docs')\n .option('-l --label <label>', 'label to apply to the published files')\n .option(\n '-b --batch-size <batch_size>',\n 'optional batch size (in number of documents) to use when uploading. Use this if you hit \"request too large\" errors. See README for more information.',\n )\n .option(\n '--force',\n 'overwrite existing UI-created Code Connect mappings if they conflict with the files being published',\n )\n .action(wrapHandler(handlePublish))\n\n addBase(\n connectCommand,\n 'unpublish',\n 'Run to find any files that have figma connections and unpublish them from Figma. ' +\n 'By default this looks for a config file named \"figma.config.json\", and uses the `include` and `exclude` fields to determine which files to parse. ' +\n 'If no config file is found, this parses the current directory. An optional `--dir` flag can be used to specify a directory to parse. ' +\n 'Alternatively, use `--node` and `--label` to unpublish a specific component.',\n )\n .option(\n '--node <link_to_node>',\n 'specify the node to unpublish. This will unpublish for the specified label.',\n )\n .option('-l --label <label>', 'label to unpublish for')\n .action(wrapHandler(handleUnpublish))\n\n addBase(\n connectCommand,\n 'parse',\n 'Run Code Connect locally to find any files that have figma connections, then converts them to JSON and outputs to stdout.',\n )\n .option('-l --label <label>', 'label to apply to the parsed files')\n .action(wrapHandler(handleParse))\n\n addBase(\n connectCommand,\n 'create',\n 'Generate a Code Connect file with boilerplate in the current directory for a Figma node URL',\n )\n .argument('<figma-node-url>', 'Figma node URL to create the Code Connect file from')\n .action((nodeUrl: string, options: unknown, cmd: commander.Command) =>\n wrapHandler<BaseCommand>((mergedCmd) => handleCreate(nodeUrl, mergedCmd))(options, cmd),\n )\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/common/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAQzB,eAAO,MAAM,KAAK,aAAY,CAAA;AAC9B,eAAO,MAAM,OAAO,aAAc,CAAA;AAClC,eAAO,MAAM,IAAI,aAAc,CAAA;AAC/B,eAAO,MAAM,IAAI,aAAe,CAAA;AAChC,eAAO,MAAM,KAAK,aAAa,CAAA;AAC/B,eAAO,MAAM,OAAO,aAAa,CAAA;AACjC,eAAO,MAAM,SAAS,aAAa,CAAA;AACnC,eAAO,MAAM,KAAK,aAAc,CAAA;AAChC,eAAO,MAAM,SAAS,aAAkB,CAAA;AAExC,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAID,eAAO,MAAM,MAAM;yBACI,QAAQ;qBAGZ,OAAO,EAAE;oBAGV,OAAO,EAAE;oBAGT,OAAO,EAAE;yBAGJ,OAAO,EAAE;qBAGb,OAAO,EAAE;CAG3B,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,KAAK,CAG/D"}
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/common/logging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAczB,eAAO,MAAM,KAAK,aAAY,CAAA;AAC9B,eAAO,MAAM,OAAO,aAAc,CAAA;AAClC,eAAO,MAAM,IAAI,aAAc,CAAA;AAC/B,eAAO,MAAM,IAAI,aAAe,CAAA;AAChC,eAAO,MAAM,KAAK,aAAa,CAAA;AAC/B,eAAO,MAAM,OAAO,aAAa,CAAA;AACjC,eAAO,MAAM,SAAS,aAAa,CAAA;AACnC,eAAO,MAAM,KAAK,aAAc,CAAA;AAChC,eAAO,MAAM,SAAS,aAAkB,CAAA;AAExC,oBAAY,QAAQ;IAClB,OAAO,IAAI;IACX,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;CACV;AAID,eAAO,MAAM,MAAM;yBACI,QAAQ;qBAGZ,OAAO,EAAE;oBAGV,OAAO,EAAE;oBAGT,OAAO,EAAE;yBAGJ,OAAO,EAAE;qBAGb,OAAO,EAAE;CAG3B,CAAA;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,SAAI,GAAG,KAAK,CAO/D"}
@@ -6,11 +6,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.logger = exports.LogLevel = exports.underline = exports.reset = exports.highlight = exports.verbose = exports.debug = exports.warn = exports.info = exports.success = exports.error = void 0;
7
7
  exports.exitWithError = exitWithError;
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
- const console_1 = require("console");
10
- const updates_1 = require("./updates");
11
- // Redirect all console output to stderr, so that JSON output to stdout in parse
12
- // mode can be piped to other commands
13
- const console = new console_1.Console(process.stderr);
9
+ // Get console instance - use stderr in Node.js CLI contexts, fall back to global console in browser
10
+ function getConsole() {
11
+ if (typeof process !== 'undefined' && process.stderr) {
12
+ const { Console } = require('console');
13
+ return new Console(process.stderr);
14
+ }
15
+ return console;
16
+ }
17
+ // Redirect all console output to stderr in CLI contexts, use global console in browser
18
+ const console = getConsole();
14
19
  exports.error = chalk_1.default.red;
15
20
  exports.success = chalk_1.default.green;
16
21
  exports.info = chalk_1.default.white;
@@ -62,6 +67,8 @@ exports.logger = {
62
67
  */
63
68
  function exitWithError(msg, errorCode = 1) {
64
69
  exports.logger.error(msg);
65
- (0, updates_1.exitWithUpdateCheck)(errorCode);
70
+ const { exitWithUpdateCheck, } = require('./updates');
71
+ exitWithUpdateCheck(errorCode);
72
+ throw new Error('unreachable');
66
73
  }
67
74
  //# sourceMappingURL=logging.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/common/logging.ts"],"names":[],"mappings":";;;;;;AAwDA,sCAGC;AA3DD,kDAAyB;AACzB,qCAAiC;AACjC,uCAA+C;AAE/C,gFAAgF;AAChF,sCAAsC;AACtC,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;AAE9B,QAAA,KAAK,GAAG,eAAK,CAAC,GAAG,CAAA;AACjB,QAAA,OAAO,GAAG,eAAK,CAAC,KAAK,CAAA;AACrB,QAAA,IAAI,GAAG,eAAK,CAAC,KAAK,CAAA;AAClB,QAAA,IAAI,GAAG,eAAK,CAAC,MAAM,CAAA;AACnB,QAAA,KAAK,GAAG,eAAK,CAAC,IAAI,CAAA;AAClB,QAAA,OAAO,GAAG,eAAK,CAAC,IAAI,CAAA;AACpB,QAAA,SAAS,GAAG,eAAK,CAAC,IAAI,CAAA;AACtB,QAAA,KAAK,GAAG,eAAK,CAAC,KAAK,CAAA;AACnB,QAAA,SAAS,GAAG,eAAK,CAAC,SAAS,CAAA;AAExC,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,6CAAW,CAAA;IACX,yCAAS,CAAA;IACT,uCAAQ,CAAA;IACR,uCAAQ,CAAA;IACR,yCAAS,CAAA;AACX,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB;AAED,IAAI,QAAQ,GAAa,QAAQ,CAAC,IAAI,CAAA;AAEzB,QAAA,MAAM,GAAG;IACpB,WAAW,EAAE,CAAC,KAAe,EAAE,EAAE;QAC/B,QAAQ,GAAG,KAAK,CAAA;IAClB,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,IAAA,aAAK,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC/D,CAAC;IACD,IAAI,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAC3B,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,IAAA,YAAI,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5D,CAAC;IACD,IAAI,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAC3B,IAAI,QAAQ,IAAI,QAAQ,CAAC,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,IAAA,YAAI,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5D,CAAC;IACD,SAAS,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,IAAA,YAAI,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7B,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,IAAA,aAAK,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC/D,CAAC;CACF,CAAA;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,GAAW,EAAE,SAAS,GAAG,CAAC;IACtD,cAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACjB,IAAA,6BAAmB,EAAC,SAAS,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import chalk from 'chalk'\nimport { Console } from 'console'\nimport { exitWithUpdateCheck } from './updates'\n\n// Redirect all console output to stderr, so that JSON output to stdout in parse\n// mode can be piped to other commands\nconst console = new Console(process.stderr)\n\nexport const error = chalk.red\nexport const success = chalk.green\nexport const info = chalk.white\nexport const warn = chalk.yellow\nexport const debug = chalk.gray\nexport const verbose = chalk.cyan\nexport const highlight = chalk.bold\nexport const reset = chalk.reset\nexport const underline = chalk.underline\n\nexport enum LogLevel {\n Nothing = 0,\n Error = 1,\n Warn = 2,\n Info = 3,\n Debug = 4,\n}\n\nlet logLevel: LogLevel = LogLevel.Info\n\nexport const logger = {\n setLogLevel: (level: LogLevel) => {\n logLevel = level\n },\n error: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Error) console.error(error(...msgs))\n },\n warn: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Warn) console.warn(warn(...msgs))\n },\n info: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Info) console.info(info(...msgs))\n },\n infoForce: (...msgs: unknown[]) => {\n console.info(info(...msgs))\n },\n debug: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Debug) console.debug(debug(...msgs))\n },\n}\n\n/**\n * Exit the process with an error message. The `never` type tells TypeScript\n * that code after this will not be executed.\n *\n * @param msg Error message\n * @param errorCode Optional command exit code, defaults to 1\n */\nexport function exitWithError(msg: string, errorCode = 1): never {\n logger.error(msg)\n exitWithUpdateCheck(errorCode)\n}\n"]}
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/common/logging.ts"],"names":[],"mappings":";;;;;;AA8DA,sCAOC;AArED,kDAAyB;AAEzB,oGAAoG;AACpG,SAAS,UAAU;IACjB,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACrD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;QACtC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACpC,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,uFAAuF;AACvF,MAAM,OAAO,GAAY,UAAU,EAAE,CAAA;AAExB,QAAA,KAAK,GAAG,eAA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IAAA,YAAI,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC5D,CAAC;IACD,SAAS,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAChC,OAAO,CAAC,IAAI,CAAC,IAAA,YAAI,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC7B,CAAC;IACD,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,IAAI,QAAQ,IAAI,QAAQ,CAAC,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,IAAA,aAAK,EAAC,GAAG,IAAI,CAAC,CAAC,CAAA;IAC/D,CAAC;CACF,CAAA;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,GAAW,EAAE,SAAS,GAAG,CAAC;IACtD,cAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACjB,MAAM,EACJ,mBAAmB,GACpB,GAA2D,OAAO,CAAC,WAAW,CAAC,CAAA;IAChF,mBAAmB,CAAC,SAAS,CAAC,CAAA;IAC9B,MAAM,IAAI,KAAK,CAAC,aAAa,CAAC,CAAA;AAChC,CAAC","sourcesContent":["import chalk from 'chalk'\n\n// Get console instance - use stderr in Node.js CLI contexts, fall back to global console in browser\nfunction getConsole(): Console {\n if (typeof process !== 'undefined' && process.stderr) {\n const { Console } = require('console')\n return new Console(process.stderr)\n }\n return console\n}\n\n// Redirect all console output to stderr in CLI contexts, use global console in browser\nconst console: Console = getConsole()\n\nexport const error = chalk.red\nexport const success = chalk.green\nexport const info = chalk.white\nexport const warn = chalk.yellow\nexport const debug = chalk.gray\nexport const verbose = chalk.cyan\nexport const highlight = chalk.bold\nexport const reset = chalk.reset\nexport const underline = chalk.underline\n\nexport enum LogLevel {\n Nothing = 0,\n Error = 1,\n Warn = 2,\n Info = 3,\n Debug = 4,\n}\n\nlet logLevel: LogLevel = LogLevel.Info\n\nexport const logger = {\n setLogLevel: (level: LogLevel) => {\n logLevel = level\n },\n error: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Error) console.error(error(...msgs))\n },\n warn: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Warn) console.warn(warn(...msgs))\n },\n info: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Info) console.info(info(...msgs))\n },\n infoForce: (...msgs: unknown[]) => {\n console.info(info(...msgs))\n },\n debug: (...msgs: unknown[]) => {\n if (logLevel >= LogLevel.Debug) console.debug(debug(...msgs))\n },\n}\n\n/**\n * Exit the process with an error message. The `never` type tells TypeScript\n * that code after this will not be executed.\n *\n * @param msg Error message\n * @param errorCode Optional command exit code, defaults to 1\n */\nexport function exitWithError(msg: string, errorCode = 1): never {\n logger.error(msg)\n const {\n exitWithUpdateCheck,\n }: { exitWithUpdateCheck: (errorCode?: number) => never } = require('./updates')\n exitWithUpdateCheck(errorCode)\n throw new Error('unreachable')\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"updates.d.ts","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":"AAIA,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,SAExB"}
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"}
@@ -8,7 +8,6 @@ exports.exitWithUpdateCheck = exitWithUpdateCheck;
8
8
  exports.updateCli = updateCli;
9
9
  const chalk_1 = __importDefault(require("chalk"));
10
10
  const logging_1 = require("./logging");
11
- const child_process_1 = require("child_process");
12
11
  const compare_versions_1 = require("compare-versions");
13
12
  const fetch_1 = require("./fetch");
14
13
  let updatedVersionAvailable = undefined;
@@ -91,6 +90,7 @@ To update, run ${chalk_1.default.whiteBright('npm install @figma/code-connect@la
91
90
  }
92
91
  }
93
92
  function updateCli() {
94
- (0, child_process_1.execSync)(getUpdateCommand(), { stdio: 'inherit' });
93
+ const { execSync } = require('child_process');
94
+ execSync(getUpdateCommand(), { stdio: 'inherit' });
95
95
  }
96
96
  //# sourceMappingURL=updates.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"updates.js","sourceRoot":"","sources":["../../src/common/updates.ts"],"names":[],"mappings":";;;;;AAiBA,0CAwBC;AAyCD,kDAGC;AAkBD,8BAEC;AAzGD,kDAAyB;AACzB,uCAAkC;AAClC,iDAAwC;AACxC,uDAAkD;AAGlD,mCAAiC;AAEjC,IAAI,uBAAuB,GAA+B,SAAS,CAAA;AACnE,IAAI,OAAO,GAAuB,SAAS,CAAA;AAM3C,+EAA+E;AAC/E,wCAAwC;AACxC,SA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CAAC","sourcesContent":["import chalk from 'chalk'\nimport { logger } from './logging'\nimport { execSync } from 'child_process'\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 execSync(getUpdateCommand(), { stdio: 'inherit' })\n}\n"]}
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,CAAC,CAAC,CAAC,CAAA;QAElC,IAAI,WAAW,CAAC,eAAe,EAAE,CAAC;YAChC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AAC,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"]}
@@ -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,aA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,CAAC,EAAE,GAAG,MAAM,CAAA;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\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/**\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"]}
@@ -77,6 +77,7 @@ export interface FigmaSlot extends IntrinsicBase {
77
77
  kind: IntrinsicKind.Slot;
78
78
  args: {
79
79
  figmaPropName: string;
80
+ connectedInstances?: boolean;
80
81
  };
81
82
  }
82
83
  export type Intrinsic = FigmaBoolean | FigmaEnum | FigmaString | FigmaInstance | FigmaSlot | FigmaChildren | FigmaNestedProps | FigmaClassName | FigmaText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zC,UAAU,CAAC,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,OAAO,GACvB,MAAM,CAqFR;AAiED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,EAAE,CAAC,uBAAuB,EACzC,aAAa,EAAE,aAAa,GAC3B,YAAY,CAYd;AA4BD,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA"}
@@ -399,6 +399,13 @@ function intrinsicToString({ kind, args, modifiers = [] }, childLayer, isForMigr
399
399
  return `${selector}.__properties__.enum('${args.figmaPropName}', ${mappingString})`;
400
400
  }
401
401
  case IntrinsicKind.Slot: {
402
+ if (args.connectedInstances) {
403
+ // `slot()` is undefined when the slot has no value, so guard before reading connectedInstances.
404
+ return `(function () {
405
+ const slot = ${selector}.__properties__.slot('${args.figmaPropName}')
406
+ return slot ? slot.connectedInstances.map((instance) => instance.__render__()).flat() : []
407
+ })()`;
408
+ }
402
409
  return `${selector}.__properties__.slot('${args.figmaPropName}')`;
403
410
  }
404
411
  case IntrinsicKind.Children: {
@@ -503,7 +510,29 @@ function parsePropsObject(objectLiteral, parserContext) {
503
510
  if (ts.isCallExpression(valueNode)) {
504
511
  return parseIntrinsic(valueNode, parserContext);
505
512
  }
513
+ const slotConnectedInstances = parseSlotConnectedInstances(valueNode, parserContext);
514
+ if (slotConnectedInstances) {
515
+ return slotConnectedInstances;
516
+ }
506
517
  return expressionToFccEnumValue(valueNode, parserContext);
507
518
  });
508
519
  }
520
+ // Matches `figma.slot('Prop').connectedInstances` (a property access, so it never reaches parseIntrinsic) and parses it as a Slot intrinsic flagged to render the connected instances.
521
+ function parseSlotConnectedInstances(valueNode, parserContext) {
522
+ if (!ts.isPropertyAccessExpression(valueNode) ||
523
+ valueNode.name.text !== 'connectedInstances' ||
524
+ !ts.isCallExpression(valueNode.expression)) {
525
+ return undefined;
526
+ }
527
+ const slotCall = valueNode.expression;
528
+ const slotIntrinsic = Intrinsics[`${exports.API_PREFIX}.slot`];
529
+ if (!slotIntrinsic || !slotIntrinsic.match(slotCall)) {
530
+ return undefined;
531
+ }
532
+ const intrinsic = slotIntrinsic.parse(slotCall, parserContext);
533
+ return {
534
+ ...intrinsic,
535
+ args: { ...intrinsic.args, connectedInstances: true },
536
+ };
537
+ }
509
538
  //# sourceMappingURL=intrinsics.js.map