@supernovaio/cli 2.0.38 → 2.0.40

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 (172) hide show
  1. package/README.md +1 -0
  2. package/dist/code-analyzer/analyzers/component-usage.d.ts +6 -0
  3. package/dist/code-analyzer/analyzers/component-usage.d.ts.map +1 -0
  4. package/dist/code-analyzer/analyzers/component-usage.js +344 -0
  5. package/dist/code-analyzer/analyzers/component-usage.js.map +1 -0
  6. package/dist/code-analyzer/analyzers/helpers.d.ts +11 -0
  7. package/dist/code-analyzer/analyzers/helpers.d.ts.map +1 -0
  8. package/dist/code-analyzer/analyzers/helpers.js +59 -0
  9. package/dist/code-analyzer/analyzers/helpers.js.map +1 -0
  10. package/dist/code-analyzer/analyzers/index.d.ts +8 -0
  11. package/dist/code-analyzer/analyzers/index.d.ts.map +1 -0
  12. package/dist/code-analyzer/analyzers/index.js +11 -0
  13. package/dist/code-analyzer/analyzers/index.js.map +1 -0
  14. package/dist/code-analyzer/analyzers/jsdoc.d.ts +3 -0
  15. package/dist/code-analyzer/analyzers/jsdoc.d.ts.map +1 -0
  16. package/dist/code-analyzer/analyzers/jsdoc.js +7 -0
  17. package/dist/code-analyzer/analyzers/jsdoc.js.map +1 -0
  18. package/dist/code-analyzer/analyzers/static-components.d.ts +3 -0
  19. package/dist/code-analyzer/analyzers/static-components.d.ts.map +1 -0
  20. package/dist/code-analyzer/analyzers/static-components.js +399 -0
  21. package/dist/code-analyzer/analyzers/static-components.js.map +1 -0
  22. package/dist/code-analyzer/analyzers/storybook-docs.d.ts +3 -0
  23. package/dist/code-analyzer/analyzers/storybook-docs.d.ts.map +1 -0
  24. package/dist/code-analyzer/analyzers/storybook-docs.js +163 -0
  25. package/dist/code-analyzer/analyzers/storybook-docs.js.map +1 -0
  26. package/dist/code-analyzer/analyzers/storybook-stories.d.ts +3 -0
  27. package/dist/code-analyzer/analyzers/storybook-stories.d.ts.map +1 -0
  28. package/dist/code-analyzer/analyzers/storybook-stories.js +91 -0
  29. package/dist/code-analyzer/analyzers/storybook-stories.js.map +1 -0
  30. package/dist/code-analyzer/analyzers/types.d.ts +88 -0
  31. package/dist/code-analyzer/analyzers/types.d.ts.map +1 -0
  32. package/dist/code-analyzer/analyzers/types.js +12 -0
  33. package/dist/code-analyzer/analyzers/types.js.map +1 -0
  34. package/dist/code-analyzer/analyzers/typescript-api.d.ts +3 -0
  35. package/dist/code-analyzer/analyzers/typescript-api.d.ts.map +1 -0
  36. package/dist/code-analyzer/analyzers/typescript-api.js +7 -0
  37. package/dist/code-analyzer/analyzers/typescript-api.js.map +1 -0
  38. package/dist/code-analyzer/components/analyze.d.ts +8 -0
  39. package/dist/code-analyzer/components/analyze.d.ts.map +1 -0
  40. package/dist/code-analyzer/components/analyze.js +38 -0
  41. package/dist/code-analyzer/components/analyze.js.map +1 -0
  42. package/dist/code-analyzer/components/mappers/component.d.ts +4 -0
  43. package/dist/code-analyzer/components/mappers/component.d.ts.map +1 -0
  44. package/dist/code-analyzer/components/mappers/component.js +20 -0
  45. package/dist/code-analyzer/components/mappers/component.js.map +1 -0
  46. package/dist/code-analyzer/components/mappers/property.d.ts +4 -0
  47. package/dist/code-analyzer/components/mappers/property.d.ts.map +1 -0
  48. package/dist/code-analyzer/components/mappers/property.js +19 -0
  49. package/dist/code-analyzer/components/mappers/property.js.map +1 -0
  50. package/dist/code-analyzer/components/parser/index.d.ts +6 -0
  51. package/dist/code-analyzer/components/parser/index.d.ts.map +1 -0
  52. package/dist/code-analyzer/components/parser/index.js +9 -0
  53. package/dist/code-analyzer/components/parser/index.js.map +1 -0
  54. package/dist/code-analyzer/components/parser/module-parser.d.ts +12 -0
  55. package/dist/code-analyzer/components/parser/module-parser.d.ts.map +1 -0
  56. package/dist/code-analyzer/components/parser/module-parser.js +116 -0
  57. package/dist/code-analyzer/components/parser/module-parser.js.map +1 -0
  58. package/dist/code-analyzer/components/parser/parser.d.ts +46 -0
  59. package/dist/code-analyzer/components/parser/parser.d.ts.map +1 -0
  60. package/dist/code-analyzer/components/parser/parser.js +904 -0
  61. package/dist/code-analyzer/components/parser/parser.js.map +1 -0
  62. package/dist/code-analyzer/components/parser/types.d.ts +123 -0
  63. package/dist/code-analyzer/components/parser/types.d.ts.map +1 -0
  64. package/dist/code-analyzer/components/parser/types.js +21 -0
  65. package/dist/code-analyzer/components/parser/types.js.map +1 -0
  66. package/dist/code-analyzer/components/parser/utils/build-filter.d.ts +3 -0
  67. package/dist/code-analyzer/components/parser/utils/build-filter.d.ts.map +1 -0
  68. package/dist/code-analyzer/components/parser/utils/build-filter.js +31 -0
  69. package/dist/code-analyzer/components/parser/utils/build-filter.js.map +1 -0
  70. package/dist/code-analyzer/components/parser/utils/filter-duplicates.d.ts +3 -0
  71. package/dist/code-analyzer/components/parser/utils/filter-duplicates.d.ts.map +1 -0
  72. package/dist/code-analyzer/components/parser/utils/filter-duplicates.js +17 -0
  73. package/dist/code-analyzer/components/parser/utils/filter-duplicates.js.map +1 -0
  74. package/dist/code-analyzer/components/parser/utils/is-react-component.d.ts +4 -0
  75. package/dist/code-analyzer/components/parser/utils/is-react-component.d.ts.map +1 -0
  76. package/dist/code-analyzer/components/parser/utils/is-react-component.js +43 -0
  77. package/dist/code-analyzer/components/parser/utils/is-react-component.js.map +1 -0
  78. package/dist/code-analyzer/components/parser/utils/trim-file-name.d.ts +2 -0
  79. package/dist/code-analyzer/components/parser/utils/trim-file-name.d.ts.map +1 -0
  80. package/dist/code-analyzer/components/parser/utils/trim-file-name.js +22 -0
  81. package/dist/code-analyzer/components/parser/utils/trim-file-name.js.map +1 -0
  82. package/dist/code-analyzer/components/types.d.ts +18 -0
  83. package/dist/code-analyzer/components/types.d.ts.map +1 -0
  84. package/dist/code-analyzer/components/types.js +5 -0
  85. package/dist/code-analyzer/components/types.js.map +1 -0
  86. package/dist/code-analyzer/components/utils/get-module-exports-path.d.ts +2 -0
  87. package/dist/code-analyzer/components/utils/get-module-exports-path.d.ts.map +1 -0
  88. package/dist/code-analyzer/components/utils/get-module-exports-path.js +60 -0
  89. package/dist/code-analyzer/components/utils/get-module-exports-path.js.map +1 -0
  90. package/dist/code-analyzer/index.d.ts +5 -0
  91. package/dist/code-analyzer/index.d.ts.map +1 -0
  92. package/dist/code-analyzer/index.js +8 -0
  93. package/dist/code-analyzer/index.js.map +1 -0
  94. package/dist/code-analyzer/orchestrator/index.d.ts +2 -0
  95. package/dist/code-analyzer/orchestrator/index.d.ts.map +1 -0
  96. package/dist/code-analyzer/orchestrator/index.js +5 -0
  97. package/dist/code-analyzer/orchestrator/index.js.map +1 -0
  98. package/dist/code-analyzer/orchestrator/run-analysis.d.ts +19 -0
  99. package/dist/code-analyzer/orchestrator/run-analysis.d.ts.map +1 -0
  100. package/dist/code-analyzer/orchestrator/run-analysis.js +109 -0
  101. package/dist/code-analyzer/orchestrator/run-analysis.js.map +1 -0
  102. package/dist/code-analyzer/snapshot/index.d.ts +2 -0
  103. package/dist/code-analyzer/snapshot/index.d.ts.map +1 -0
  104. package/dist/code-analyzer/snapshot/index.js +5 -0
  105. package/dist/code-analyzer/snapshot/index.js.map +1 -0
  106. package/dist/code-analyzer/snapshot/write-snapshot.d.ts +17 -0
  107. package/dist/code-analyzer/snapshot/write-snapshot.d.ts.map +1 -0
  108. package/dist/code-analyzer/snapshot/write-snapshot.js +60 -0
  109. package/dist/code-analyzer/snapshot/write-snapshot.js.map +1 -0
  110. package/dist/commands/analyze/adoption.d.ts +15 -0
  111. package/dist/commands/analyze/adoption.d.ts.map +1 -0
  112. package/dist/commands/analyze/adoption.js +34 -0
  113. package/dist/commands/analyze/adoption.js.map +1 -0
  114. package/dist/commands/analyze/components.d.ts +15 -0
  115. package/dist/commands/analyze/components.d.ts.map +1 -0
  116. package/dist/commands/analyze/components.js +34 -0
  117. package/dist/commands/analyze/components.js.map +1 -0
  118. package/dist/commands/analyze/status.d.ts +24 -0
  119. package/dist/commands/analyze/status.d.ts.map +1 -0
  120. package/dist/commands/analyze/status.js +54 -0
  121. package/dist/commands/analyze/status.js.map +1 -0
  122. package/dist/commands/analyze.d.ts +15 -0
  123. package/dist/commands/analyze.d.ts.map +1 -0
  124. package/dist/commands/analyze.js +34 -0
  125. package/dist/commands/analyze.js.map +1 -0
  126. package/dist/commands/components-import.d.ts +3 -3
  127. package/dist/commands/components-import.d.ts.map +1 -1
  128. package/dist/commands/components-import.js +9 -3
  129. package/dist/commands/components-import.js.map +1 -1
  130. package/dist/commands/publish-documentation.d.ts +2 -2
  131. package/dist/commands/run-local-exporter.js +2 -2
  132. package/dist/commands/run-local-exporter.js.map +1 -1
  133. package/dist/commands/storybook-import.d.ts +2 -2
  134. package/dist/commands/template-upload.d.ts.map +1 -1
  135. package/dist/commands/template-upload.js +10 -12
  136. package/dist/commands/template-upload.js.map +1 -1
  137. package/dist/types/config.d.ts +41 -5
  138. package/dist/types/config.d.ts.map +1 -1
  139. package/dist/types/config.js +9 -2
  140. package/dist/types/config.js.map +1 -1
  141. package/dist/types/types.js +2 -2
  142. package/dist/types/types.js.map +1 -1
  143. package/dist/utils/analyze-command.d.ts +42 -0
  144. package/dist/utils/analyze-command.d.ts.map +1 -0
  145. package/dist/utils/analyze-command.js +606 -0
  146. package/dist/utils/analyze-command.js.map +1 -0
  147. package/dist/utils/analyze-status.d.ts +7 -0
  148. package/dist/utils/analyze-status.d.ts.map +1 -0
  149. package/dist/utils/analyze-status.js +94 -0
  150. package/dist/utils/analyze-status.js.map +1 -0
  151. package/dist/utils/config.service.d.ts +1 -2
  152. package/dist/utils/config.service.d.ts.map +1 -1
  153. package/dist/utils/config.service.js +5 -7
  154. package/dist/utils/config.service.js.map +1 -1
  155. package/dist/utils/discover.d.ts +2 -2
  156. package/dist/utils/discover.d.ts.map +1 -1
  157. package/dist/utils/discover.js +25 -23
  158. package/dist/utils/discover.js.map +1 -1
  159. package/dist/utils/figma-tokens-data-loader.js +2 -2
  160. package/dist/utils/figma-tokens-data-loader.js.map +1 -1
  161. package/dist/utils/http-client.d.ts +4 -0
  162. package/dist/utils/http-client.d.ts.map +1 -0
  163. package/dist/utils/http-client.js +18 -0
  164. package/dist/utils/http-client.js.map +1 -0
  165. package/dist/utils/run-exporter/exporter-utils.js +2 -2
  166. package/dist/utils/run-exporter/exporter-utils.js.map +1 -1
  167. package/dist/utils/validate-templates.d.ts +1 -1
  168. package/dist/utils/validate-templates.d.ts.map +1 -1
  169. package/dist/utils/validate-templates.js +4 -4
  170. package/dist/utils/validate-templates.js.map +1 -1
  171. package/oclif.manifest.json +216 -1
  172. package/package.json +12 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook-docs.js","sources":["../../../src/code-analyzer/analyzers/storybook-docs.ts"],"sourceRoot":"","sourcesContent":["import { readFile } from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport { collectFiles, toRelative } from \"./helpers.js\"\nimport { ComponentDescriptor, DocRecord } from \"./types.js\"\n\nconst docsPattern = \"**/*.{md,mdx}\"\nconst snippetWindowBefore = 3\nconst snippetWindowAfter = 8\nconst maxReferenceSnippetsPerFile = 3\n\nfunction extractTitle(content: string): string | undefined {\n const headingMatch = content.match(/^#\\s+(.+)$/m)\n if (headingMatch?.[1]) {\n return headingMatch[1].trim()\n }\n\n const metaMatch = content.match(/<Meta\\s+title=[\"']([^\"']+)[\"']/)\n return metaMatch?.[1]?.trim()\n}\n\nfunction escapeRegex(input: string): string {\n return input.replaceAll(/[.*+?^${}()|[\\]\\\\]/g, String.raw`\\$&`)\n}\n\nfunction toPosix(input: string): string {\n return input.split(path.sep).join(\"/\")\n}\n\nfunction lineAt(content: string, index: number): number {\n return content.slice(0, index).split(\"\\n\").length\n}\n\nfunction normalizeLine(input: string): string {\n return input.replaceAll(/\\s+/g, \" \").trim().toLowerCase()\n}\n\nfunction createSnippet(content: string, line: number): { lineEnd: number; lineStart: number; snippet: string } {\n const lines = content.split(\"\\n\")\n const lineIndex = Math.max(0, Math.min(lines.length - 1, line - 1))\n\n let lineStart = Math.max(1, line - snippetWindowBefore)\n let lineEnd = Math.min(lines.length, line + snippetWindowAfter)\n\n for (let i = lineIndex; i >= lineStart - 1; i -= 1) {\n if (lines[i]?.trim() === \"\") {\n lineStart = i + 2\n break\n }\n }\n\n for (let i = lineIndex; i <= lineEnd - 1; i += 1) {\n if (lines[i]?.trim() === \"\") {\n lineEnd = i\n break\n }\n }\n\n if (lineStart > lineEnd) {\n lineStart = line\n lineEnd = line\n }\n\n const snippet = lines.slice(lineStart - 1, lineEnd).join(\"\\n\").trimEnd()\n return { lineEnd, lineStart, snippet }\n}\n\nfunction classifyDocRecord(\n relativePath: string,\n component: ComponentDescriptor,\n content: string,\n): { kind: \"doc\" | \"reference\"; score: number } {\n const normalizedPath = toPosix(relativePath).toLowerCase()\n const componentPath = toPosix(component.componentPath).toLowerCase()\n const componentDir = path.posix.dirname(componentPath)\n const fileName = path.posix.basename(normalizedPath)\n const exportName = component.exportName.toLowerCase()\n const title = extractTitle(content)\n const normalizedTitle = title ? normalizeLine(title) : \"\"\n const componentToken = normalizeLine(component.exportName)\n\n const inComponentDir = normalizedPath.startsWith(`${componentDir}/`)\n const isReadme = fileName === \"readme.md\" || fileName === \"readme.mdx\"\n const isDocsLike = fileName.startsWith(\"docs.\") || fileName.endsWith(\".docs.md\") || fileName.endsWith(\".docs.mdx\")\n const fileContainsName = fileName.includes(exportName)\n const titleContainsName = normalizedTitle.includes(componentToken)\n\n if (inComponentDir && isReadme) {\n return { kind: \"doc\", score: 100 }\n }\n\n if (inComponentDir && isDocsLike) {\n return { kind: \"doc\", score: 95 }\n }\n\n if (inComponentDir) {\n return { kind: \"doc\", score: 90 }\n }\n\n if (fileContainsName || titleContainsName) {\n return { kind: \"doc\", score: 80 }\n }\n\n if (normalizedPath.includes(\"/docs/\") || normalizedPath.includes(\"/documentation/\")) {\n return { kind: \"reference\", score: 40 }\n }\n\n if (normalizedPath.includes(\"/storybook/\") || normalizedPath.includes(\".stories.\")) {\n return { kind: \"reference\", score: 35 }\n }\n\n return { kind: \"reference\", score: 20 }\n}\n\nexport async function analyzeStorybookDocs(\n projectRoot: string,\n components: ComponentDescriptor[],\n excludePaths: string[] = [],\n): Promise<Record<string, DocRecord[]>> {\n const files = await collectFiles({\n excludePaths,\n pattern: docsPattern,\n projectRoot,\n })\n const records: Record<string, DocRecord[]> = {}\n\n for (const file of files) {\n const content = await readFile(file, \"utf8\")\n const title = extractTitle(content)\n const relativePath = toRelative(projectRoot, file)\n\n for (const component of components) {\n const classification = classifyDocRecord(relativePath, component, content)\n const componentPattern = new RegExp(`\\\\b${escapeRegex(component.exportName)}\\\\b`, \"gm\")\n const matches = [...content.matchAll(componentPattern)]\n\n const isFullDoc = classification.kind === \"doc\"\n\n if (!isFullDoc && matches.length === 0) {\n continue\n }\n\n if (!records[component.componentKey]) {\n records[component.componentKey] = []\n }\n\n if (isFullDoc) {\n const firstMatchIndex = typeof matches[0]?.index === \"number\" ? matches[0].index : 0\n const line = lineAt(content, firstMatchIndex)\n records[component.componentKey].push({\n content,\n docPath: relativePath,\n kind: \"doc\",\n lineEnd: line,\n lineStart: line,\n score: classification.score,\n title,\n })\n continue\n }\n\n const snippetMatches = matches.slice(0, maxReferenceSnippetsPerFile)\n for (const match of snippetMatches) {\n if (typeof match.index !== \"number\") {\n continue\n }\n\n const matchLine = lineAt(content, match.index)\n const snippet = createSnippet(content, matchLine)\n records[component.componentKey].push({\n docPath: relativePath,\n kind: \"reference\",\n lineEnd: snippet.lineEnd,\n lineStart: snippet.lineStart,\n score: classification.score,\n snippet: snippet.snippet,\n title,\n })\n }\n }\n }\n\n for (const componentKey of Object.keys(records)) {\n records[componentKey] = records[componentKey].sort((a, b) => {\n if (a.score !== b.score) {\n return b.score - a.score\n }\n\n if (a.kind !== b.kind) {\n return a.kind === \"doc\" ? -1 : 1\n }\n\n if (a.docPath === b.docPath) {\n if (a.lineStart === b.lineStart) {\n return a.lineEnd - b.lineEnd\n }\n\n return a.lineStart - b.lineStart\n }\n\n return a.docPath.localeCompare(b.docPath)\n })\n }\n\n return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AC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;YAClC,CAAC;YAED,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC;gBAC5B,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;oBAChC,OAAO,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAA;gBAC9B,CAAC;gBAED,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAA;YAClC,CAAC;YAED,OAAO,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC,CAAA;QAC3C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","debug_id":"0ce14f9a-c743-50b2-959b-559515b5fa6c"}
@@ -0,0 +1,3 @@
1
+ import { ComponentDescriptor, StoryRecord } from "./types.js";
2
+ export declare function analyzeStorybookStories(projectRoot: string, components: ComponentDescriptor[], excludePaths?: string[]): Promise<Record<string, StoryRecord[]>>;
3
+ //# sourceMappingURL=storybook-stories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook-stories.d.ts","sourceRoot":"","sources":["../../../src/code-analyzer/analyzers/storybook-stories.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAoD7D,wBAAsB,uBAAuB,CAC3C,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,mBAAmB,EAAE,EACjC,YAAY,GAAE,MAAM,EAAO,GAC1B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,CAqDxC"}
@@ -0,0 +1,91 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4689362b-19c7-5ab6-9737-f981273ed47f")}catch(e){}}();
3
+ import { readFile } from "node:fs/promises";
4
+ import path from "node:path";
5
+ import { collectFiles, toRelative, uniqueSorted } from "./helpers.js";
6
+ const storiesPattern = "**/*.stories.{ts,tsx,js,jsx,mdx}";
7
+ function inferCandidatesFromFile(storyPath) {
8
+ const fileName = path.basename(storyPath);
9
+ const [baseName] = fileName.split(".stories");
10
+ return uniqueSorted([baseName, baseName.replaceAll(/[-_]+(.)/g, (_, c) => c.toUpperCase())]);
11
+ }
12
+ function inferCandidatesFromMeta(content) {
13
+ const titleMatch = content.match(/title\s*:\s*["']([^"']+)["']/);
14
+ if (!titleMatch?.[1]) {
15
+ return [];
16
+ }
17
+ const parts = titleMatch[1].split("/").filter(Boolean);
18
+ const maybeComponent = parts.at(-1);
19
+ if (!maybeComponent) {
20
+ return [];
21
+ }
22
+ return [maybeComponent];
23
+ }
24
+ function lineAt(content, index) {
25
+ return content.slice(0, index).split("\n").length;
26
+ }
27
+ function extractStoryExports(content) {
28
+ const exports = [...content.matchAll(/export\s+(?:const|function)\s+([A-Za-z0-9_]+)/g)].filter(match => match[1] !== "default");
29
+ return exports
30
+ .map((match, index) => {
31
+ const storyName = match[1];
32
+ const start = match.index ?? 0;
33
+ const nextStart = exports[index + 1]?.index;
34
+ const endExclusive = typeof nextStart === "number" ? nextStart : content.length;
35
+ const snippet = content.slice(start, endExclusive).trim();
36
+ return {
37
+ lineEnd: lineAt(content, Math.max(start, endExclusive - 1)),
38
+ lineStart: lineAt(content, start),
39
+ snippet,
40
+ storyName,
41
+ };
42
+ })
43
+ .sort((a, b) => a.storyName.localeCompare(b.storyName));
44
+ }
45
+ export async function analyzeStorybookStories(projectRoot, components, excludePaths = []) {
46
+ const files = await collectFiles({
47
+ excludePaths,
48
+ pattern: storiesPattern,
49
+ projectRoot,
50
+ });
51
+ const byExportName = new Map(components.map(component => [component.exportName.toLowerCase(), component]));
52
+ const records = {};
53
+ for (const file of files) {
54
+ const content = await readFile(file, "utf8");
55
+ const stories = extractStoryExports(content);
56
+ if (stories.length === 0) {
57
+ continue;
58
+ }
59
+ const relativePath = toRelative(projectRoot, file);
60
+ const candidates = uniqueSorted([...inferCandidatesFromFile(relativePath), ...inferCandidatesFromMeta(content)]);
61
+ for (const candidate of candidates) {
62
+ const component = byExportName.get(candidate.toLowerCase());
63
+ if (!component) {
64
+ continue;
65
+ }
66
+ if (!records[component.componentKey]) {
67
+ records[component.componentKey] = [];
68
+ }
69
+ for (const story of stories) {
70
+ records[component.componentKey].push({
71
+ lineEnd: story.lineEnd,
72
+ lineStart: story.lineStart,
73
+ snippet: story.snippet,
74
+ storyName: story.storyName,
75
+ storyPath: relativePath,
76
+ });
77
+ }
78
+ }
79
+ }
80
+ for (const componentKey of Object.keys(records)) {
81
+ records[componentKey] = records[componentKey].sort((a, b) => {
82
+ if (a.storyPath === b.storyPath) {
83
+ return a.lineStart - b.lineStart;
84
+ }
85
+ return a.storyPath.localeCompare(b.storyPath);
86
+ });
87
+ }
88
+ return records;
89
+ }
90
+ //# sourceMappingURL=storybook-stories.js.map
91
+ //# debugId=4689362b-19c7-5ab6-9737-f981273ed47f
@@ -0,0 +1 @@
1
+ {"version":3,"file":"storybook-stories.js","sources":["../../../src/code-analyzer/analyzers/storybook-stories.ts"],"sourceRoot":"","sourcesContent":["import { readFile } from \"node:fs/promises\"\nimport path from \"node:path\"\n\nimport { collectFiles, toRelative, uniqueSorted } from \"./helpers.js\"\nimport { ComponentDescriptor, StoryRecord } from \"./types.js\"\n\nconst storiesPattern = \"**/*.stories.{ts,tsx,js,jsx,mdx}\"\n\nfunction inferCandidatesFromFile(storyPath: string): string[] {\n const fileName = path.basename(storyPath)\n const [baseName] = fileName.split(\".stories\")\n return uniqueSorted([baseName, baseName.replaceAll(/[-_]+(.)/g, (_, c: string) => c.toUpperCase())])\n}\n\nfunction inferCandidatesFromMeta(content: string): string[] {\n const titleMatch = content.match(/title\\s*:\\s*[\"']([^\"']+)[\"']/)\n if (!titleMatch?.[1]) {\n return []\n }\n\n const parts = titleMatch[1].split(\"/\").filter(Boolean)\n const maybeComponent = parts.at(-1)\n if (!maybeComponent) {\n return []\n }\n\n return [maybeComponent]\n}\n\nfunction lineAt(content: string, index: number): number {\n return content.slice(0, index).split(\"\\n\").length\n}\n\nfunction extractStoryExports(content: string): Array<{ lineEnd: number; lineStart: number; snippet: string; storyName: string }> {\n const exports = [...content.matchAll(/export\\s+(?:const|function)\\s+([A-Za-z0-9_]+)/g)].filter(\n match => match[1] !== \"default\",\n )\n\n return exports\n .map((match, index) => {\n const storyName = match[1]\n const start = match.index ?? 0\n const nextStart = exports[index + 1]?.index\n const endExclusive = typeof nextStart === \"number\" ? nextStart : content.length\n const snippet = content.slice(start, endExclusive).trim()\n\n return {\n lineEnd: lineAt(content, Math.max(start, endExclusive - 1)),\n lineStart: lineAt(content, start),\n snippet,\n storyName,\n }\n })\n .sort((a, b) => a.storyName.localeCompare(b.storyName))\n}\n\nexport async function analyzeStorybookStories(\n projectRoot: string,\n components: ComponentDescriptor[],\n excludePaths: string[] = [],\n): Promise<Record<string, StoryRecord[]>> {\n const files = await collectFiles({\n excludePaths,\n pattern: storiesPattern,\n projectRoot,\n })\n const byExportName = new Map(components.map(component => [component.exportName.toLowerCase(), component]))\n const records: Record<string, StoryRecord[]> = {}\n\n for (const file of files) {\n const content = await readFile(file, \"utf8\")\n const stories = extractStoryExports(content)\n\n if (stories.length === 0) {\n continue\n }\n\n const relativePath = toRelative(projectRoot, file)\n const candidates = uniqueSorted([...inferCandidatesFromFile(relativePath), ...inferCandidatesFromMeta(content)])\n\n for (const candidate of candidates) {\n const component = byExportName.get(candidate.toLowerCase())\n if (!component) {\n continue\n }\n\n if (!records[component.componentKey]) {\n records[component.componentKey] = []\n }\n\n for (const story of stories) {\n records[component.componentKey].push({\n lineEnd: story.lineEnd,\n lineStart: story.lineStart,\n snippet: story.snippet,\n storyName: story.storyName,\n storyPath: relativePath,\n })\n }\n }\n }\n\n for (const componentKey of Object.keys(records)) {\n records[componentKey] = records[componentKey].sort((a, b) => {\n if (a.storyPath === b.storyPath) {\n return a.lineStart - b.lineStart\n }\n\n return a.storyPath.localeCompare(b.storyPath)\n })\n }\n\n return records\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAGrE,MAAM,cAAc,GAAG,kCAAkC,CAAA;AAEzD,SAAS,uBAAuB,CAAC,SAAiB;IAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;IACzC,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAC7C,OAAO,YAAY,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAA;AACtG,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;IAChE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrB,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACtD,MAAM,cAAc,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;IACnC,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,EAAE,CAAA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C;YAED,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;gBAC5B,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC;oBACnC,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;oBACtB,SAAS,EAAE,KAAK,CAAC,SAAS;oBAC1B,SAAS,EAAE,YAAY;iBACxB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,MAAM,YAAY,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAChD,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;YAC1D,IAAI,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,EAAE,CAAC;gBAChC,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,SAAS,CAAA;YAClC,CAAC;YAED,OAAO,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC","debug_id":"4689362b-19c7-5ab6-9737-f981273ed47f"}
@@ -0,0 +1,88 @@
1
+ export declare const analyzerNames: readonly ["static-components", "typescript-api", "storybook-stories", "storybook-docs", "jsdoc", "component-usage"];
2
+ export type AnalyzerName = (typeof analyzerNames)[number];
3
+ export type AnalyzerStatus = "done" | "warning" | "skipped" | "failed";
4
+ export type ComponentDescriptor = {
5
+ componentKey: string;
6
+ componentPath: string;
7
+ exportName: string;
8
+ };
9
+ export type ComponentApiProperty = {
10
+ name: string;
11
+ required: boolean;
12
+ type: string;
13
+ };
14
+ export type LinkedTypeRecord = {
15
+ definition: string;
16
+ lineEnd: number;
17
+ lineStart: number;
18
+ name: string;
19
+ sourcePath: string;
20
+ };
21
+ export type ComponentApiRecord = {
22
+ linkedTypes?: LinkedTypeRecord[];
23
+ props: ComponentApiProperty[];
24
+ sourcePath: string;
25
+ };
26
+ export type StoryRecord = {
27
+ lineEnd: number;
28
+ lineStart: number;
29
+ snippet: string;
30
+ storyName: string;
31
+ storyPath: string;
32
+ };
33
+ export type DocRecord = {
34
+ content?: string;
35
+ docPath: string;
36
+ kind: "doc" | "reference";
37
+ lineEnd: number;
38
+ lineStart: number;
39
+ score: number;
40
+ snippet?: string;
41
+ title?: string;
42
+ };
43
+ export type JsDocRecord = {
44
+ description: string;
45
+ sourcePath: string;
46
+ };
47
+ export type UsageSnippet = {
48
+ lineEnd: number;
49
+ lineStart: number;
50
+ sourcePath: string;
51
+ snippet: string;
52
+ };
53
+ export type PropValueUsage = {
54
+ count: number;
55
+ value: string;
56
+ };
57
+ export type PropUsageRecord = {
58
+ count: number;
59
+ values: PropValueUsage[];
60
+ };
61
+ export type UsageRecord = {
62
+ count: number;
63
+ files: string[];
64
+ propUsage?: Record<string, PropUsageRecord>;
65
+ snippets: UsageSnippet[];
66
+ };
67
+ export type StaticComponentAnalyzerResult = {
68
+ components: ComponentDescriptor[];
69
+ jsdocByComponentKey: Record<string, JsDocRecord>;
70
+ typescriptApiByComponentKey: Record<string, ComponentApiRecord>;
71
+ };
72
+ export type AnalyzerArtifacts = {
73
+ componentUsage: Record<string, UsageRecord>;
74
+ jsdoc: Record<string, JsDocRecord>;
75
+ staticComponents: ComponentDescriptor[];
76
+ storybookDocs: Record<string, DocRecord[]>;
77
+ storybookStories: Record<string, StoryRecord[]>;
78
+ typescriptApi: Record<string, ComponentApiRecord>;
79
+ };
80
+ export type AnalyzerRun = {
81
+ analyzer: AnalyzerName;
82
+ durationMs: number;
83
+ finishedAt: string;
84
+ message?: string;
85
+ startedAt: string;
86
+ status: AnalyzerStatus;
87
+ };
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
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,EAAE,CAAA;IACvC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAA;IAC1C,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAA;IAC/C,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAA;CAClD,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,YAAY,CAAA;IACtB,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,cAAc,CAAA;CACvB,CAAA"}
@@ -0,0 +1,12 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e36afcef-a73e-5ed3-adab-f3ac7ee84e87")}catch(e){}}();
3
+ export const analyzerNames = [
4
+ "static-components",
5
+ "typescript-api",
6
+ "storybook-stories",
7
+ "storybook-docs",
8
+ "jsdoc",
9
+ "component-usage",
10
+ ];
11
+ //# sourceMappingURL=types.js.map
12
+ //# debugId=e36afcef-a73e-5ed3-adab-f3ac7ee84e87
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sources":["../../../src/code-analyzer/analyzers/types.ts"],"sourceRoot":"","sourcesContent":["export const analyzerNames = [\n \"static-components\",\n \"typescript-api\",\n \"storybook-stories\",\n \"storybook-docs\",\n \"jsdoc\",\n \"component-usage\",\n] as const\n\nexport type AnalyzerName = (typeof analyzerNames)[number]\n\nexport type AnalyzerStatus = \"done\" | \"warning\" | \"skipped\" | \"failed\"\n\nexport type ComponentDescriptor = {\n componentKey: string\n componentPath: string\n exportName: string\n}\n\nexport type ComponentApiProperty = {\n name: string\n required: boolean\n type: string\n}\n\nexport type LinkedTypeRecord = {\n definition: string\n lineEnd: number\n lineStart: number\n name: string\n sourcePath: string\n}\n\nexport type ComponentApiRecord = {\n linkedTypes?: LinkedTypeRecord[]\n props: ComponentApiProperty[]\n sourcePath: string\n}\n\nexport type StoryRecord = {\n lineEnd: number\n lineStart: number\n snippet: string\n storyName: string\n storyPath: string\n}\n\nexport type DocRecord = {\n content?: string\n docPath: string\n kind: \"doc\" | \"reference\"\n lineEnd: number\n lineStart: number\n score: number\n snippet?: string\n title?: string\n}\n\nexport type JsDocRecord = {\n description: string\n sourcePath: string\n}\n\nexport type UsageSnippet = {\n lineEnd: number\n lineStart: number\n sourcePath: string\n snippet: string\n}\n\nexport type PropValueUsage = {\n count: number\n value: string\n}\n\nexport type PropUsageRecord = {\n count: number\n values: PropValueUsage[]\n}\n\nexport type UsageRecord = {\n count: number\n files: string[]\n propUsage?: Record<string, PropUsageRecord>\n snippets: UsageSnippet[]\n}\n\nexport type StaticComponentAnalyzerResult = {\n components: ComponentDescriptor[]\n jsdocByComponentKey: Record<string, JsDocRecord>\n typescriptApiByComponentKey: Record<string, ComponentApiRecord>\n}\n\nexport type AnalyzerArtifacts = {\n componentUsage: Record<string, UsageRecord>\n jsdoc: Record<string, JsDocRecord>\n staticComponents: ComponentDescriptor[]\n storybookDocs: Record<string, DocRecord[]>\n storybookStories: Record<string, StoryRecord[]>\n typescriptApi: Record<string, ComponentApiRecord>\n}\n\nexport type AnalyzerRun = {\n analyzer: AnalyzerName\n durationMs: number\n finishedAt: string\n message?: string\n startedAt: string\n status: AnalyzerStatus\n}\n"],"names":[],"mappings":";;AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,mBAAmB;IACnB,gBAAgB;IAChB,mBAAmB;IACnB,gBAAgB;IAChB,OAAO;IACP,iBAAiB;CACT,CAAA","debug_id":"e36afcef-a73e-5ed3-adab-f3ac7ee84e87"}
@@ -0,0 +1,3 @@
1
+ import { ComponentApiRecord, StaticComponentAnalyzerResult } from "./types.js";
2
+ export declare function analyzeTypescriptApi(staticComponentsResult: StaticComponentAnalyzerResult): Promise<Record<string, ComponentApiRecord>>;
3
+ //# sourceMappingURL=typescript-api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-api.d.ts","sourceRoot":"","sources":["../../../src/code-analyzer/analyzers/typescript-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,YAAY,CAAA;AAE9E,wBAAsB,oBAAoB,CACxC,sBAAsB,EAAE,6BAA6B,GACpD,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAE7C"}
@@ -0,0 +1,7 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ee0feb56-41c1-5764-bbe2-8aaa2d9cee89")}catch(e){}}();
3
+ export async function analyzeTypescriptApi(staticComponentsResult) {
4
+ return staticComponentsResult.typescriptApiByComponentKey;
5
+ }
6
+ //# sourceMappingURL=typescript-api.js.map
7
+ //# debugId=ee0feb56-41c1-5764-bbe2-8aaa2d9cee89
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-api.js","sources":["../../../src/code-analyzer/analyzers/typescript-api.ts"],"sourceRoot":"","sourcesContent":["import { ComponentApiRecord, StaticComponentAnalyzerResult } from \"./types.js\"\n\nexport async function analyzeTypescriptApi(\n staticComponentsResult: StaticComponentAnalyzerResult,\n): Promise<Record<string, ComponentApiRecord>> {\n return staticComponentsResult.typescriptApiByComponentKey\n}\n"],"names":[],"mappings":";;AAEA,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,sBAAqD;IAErD,OAAO,sBAAsB,CAAC,2BAA2B,CAAA;AAC3D,CAAC","debug_id":"ee0feb56-41c1-5764-bbe2-8aaa2d9cee89"}
@@ -0,0 +1,8 @@
1
+ import { Component } from "./types.js";
2
+ type Input = {
3
+ importFrom: string;
4
+ rootDir: string;
5
+ };
6
+ export declare function analyzeComponents(input: Input): Promise<Component[]>;
7
+ export {};
8
+ //# sourceMappingURL=analyze.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze.d.ts","sourceRoot":"","sources":["../../../src/code-analyzer/components/analyze.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAGtC,KAAK,KAAK,GAAG;IAIX,UAAU,EAAE,MAAM,CAAA;IAKlB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAyBD,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAqB1E"}
@@ -0,0 +1,38 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="704550dc-53b0-515d-9357-8888cdbe85bf")}catch(e){}}();
3
+ import { globSync } from "glob";
4
+ import path from "node:path";
5
+ import * as ts from "typescript";
6
+ import { mapToSupernovaComponent } from "./mappers/component.js";
7
+ import { defaultOptions, ModuleParser } from "./parser/index.js";
8
+ import { getModuleEntryPath } from "./utils/get-module-exports-path.js";
9
+ function findAndParseTsConfig(directory) {
10
+ const tsconfigPath = path.join(directory, "tsconfig.json");
11
+ const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
12
+ if (configFile.error) {
13
+ return undefined;
14
+ }
15
+ return ts.parseJsonConfigFileContent(configFile.config, ts.sys, directory, undefined, tsconfigPath);
16
+ }
17
+ async function getDefaultFiles(rootDir) {
18
+ return globSync("**/*.{ts,tsx}", {
19
+ absolute: true,
20
+ cwd: rootDir,
21
+ ignore: ["dist", "build", "node_modules"],
22
+ });
23
+ }
24
+ export async function analyzeComponents(input) {
25
+ const entryFilePath = await getModuleEntryPath(input.rootDir, input.importFrom);
26
+ const tsConfig = findAndParseTsConfig(input.rootDir);
27
+ const isNodeModuleImport = entryFilePath.includes("/node_modules/");
28
+ const discoveredTsFiles = tsConfig?.fileNames.length && !isNodeModuleImport
29
+ ? tsConfig.fileNames
30
+ : await getDefaultFiles(isNodeModuleImport ? `${input.rootDir}/node_modules` : input.rootDir);
31
+ const tsFiles = discoveredTsFiles.includes(entryFilePath) ? discoveredTsFiles : [entryFilePath, ...discoveredTsFiles];
32
+ const program = ts.createProgram(tsFiles, tsConfig?.options ?? defaultOptions);
33
+ const moduleParser = new ModuleParser(program, entryFilePath);
34
+ const moduleComponentsInfo = moduleParser.parseModule();
35
+ return moduleComponentsInfo.map(componentInfo => mapToSupernovaComponent(componentInfo, path.dirname(entryFilePath)));
36
+ }
37
+ //# sourceMappingURL=analyze.js.map
38
+ //# debugId=704550dc-53b0-515d-9357-8888cdbe85bf
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyze.js","sources":["../../../src/code-analyzer/components/analyze.ts"],"sourceRoot":"","sourcesContent":["import { globSync } from \"glob\"\nimport path from \"node:path\"\nimport * as ts from \"typescript\"\n\nimport { mapToSupernovaComponent } from \"./mappers/component.js\"\nimport { defaultOptions, ModuleParser } from \"./parser/index.js\"\nimport { Component } from \"./types.js\"\nimport { getModuleEntryPath } from \"./utils/get-module-exports-path.js\"\n\ntype Input = {\n /**\n * Where to import components from within the package\n */\n importFrom: string\n\n /**\n * Root directory of the package where the import should resolve from\n */\n rootDir: string\n}\n\n/**\n * Finds and parses a tsconfig.json file from a specific directory\n */\nfunction findAndParseTsConfig(directory: string): ts.ParsedCommandLine | undefined {\n const tsconfigPath = path.join(directory, \"tsconfig.json\")\n\n const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile)\n\n if (configFile.error) {\n return undefined\n }\n\n return ts.parseJsonConfigFileContent(configFile.config, ts.sys, directory, undefined, tsconfigPath)\n}\n\nasync function getDefaultFiles(rootDir: string) {\n return globSync(\"**/*.{ts,tsx}\", {\n absolute: true,\n cwd: rootDir,\n ignore: [\"dist\", \"build\", \"node_modules\"],\n })\n}\n\nexport async function analyzeComponents(input: Input): Promise<Component[]> {\n // Construct the module path\n const entryFilePath = await getModuleEntryPath(input.rootDir, input.importFrom)\n\n const tsConfig = findAndParseTsConfig(input.rootDir)\n\n const isNodeModuleImport = entryFilePath.includes(\"/node_modules/\")\n\n // inlcude ts files defined in tsConfig. If not, include all ts and tsx files in the root dir\n const discoveredTsFiles =\n tsConfig?.fileNames.length && !isNodeModuleImport\n ? tsConfig.fileNames\n : await getDefaultFiles(isNodeModuleImport ? `${input.rootDir}/node_modules` : input.rootDir)\n const tsFiles = discoveredTsFiles.includes(entryFilePath) ? discoveredTsFiles : [entryFilePath, ...discoveredTsFiles]\n\n const program = ts.createProgram(tsFiles, tsConfig?.options ?? defaultOptions)\n\n const moduleParser = new ModuleParser(program, entryFilePath)\n const moduleComponentsInfo = moduleParser.parseModule()\n\n return moduleComponentsInfo.map(componentInfo => mapToSupernovaComponent(componentInfo, path.dirname(entryFilePath)))\n}\n"],"names":[],"mappings":";;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAEhC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA;AAiBvE,SAAS,oBAAoB,CAAC,SAAiB;IAC7C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,CAAA;IAE1D,MAAM,UAAU,GAAG,EAAE,CAAC,cAAc,CAAC,YAAY,EAAE,E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,EAAE,QAAQ,EAAE,OAAO,IAAI,cAAc,CAAC,CAAA;IAE9E,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,OAAO,EAAE,aAAa,CAAC,CAAA;IAC7D,MAAM,oBAAoB,GAAG,YAAY,CAAC,WAAW,EAAE,CAAA;IAEvD,OAAO,oBAAoB,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,uBAAuB,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAA;AACvH,CAAC","debug_id":"704550dc-53b0-515d-9357-8888cdbe85bf"}
@@ -0,0 +1,4 @@
1
+ import { ComponentDoc } from "../parser/types.js";
2
+ import { Component } from "../types.js";
3
+ export declare function mapToSupernovaComponent(component: ComponentDoc, entryPath: string): Component;
4
+ //# sourceMappingURL=component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../../src/code-analyzer/components/mappers/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,SAAS,EAAqB,MAAM,aAAa,CAAA;AAO1D,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAkB7F"}
@@ -0,0 +1,20 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="566e4b83-5d2e-5906-b97d-7d50b06c7e23")}catch(e){}}();
3
+ import { mapToSupernovaProperty } from "./property.js";
4
+ import path from "node:path";
5
+ export function mapToSupernovaComponent(component, entryPath) {
6
+ return {
7
+ exportName: component.exportName,
8
+ description: component.description,
9
+ tags: component.tags ?? null,
10
+ componentPath: path.relative(entryPath, component.filePath),
11
+ properties: Object.entries(component.props).reduce((acc, [name, property]) => {
12
+ if (property.name !== "key") {
13
+ acc[name] = mapToSupernovaProperty(property, entryPath);
14
+ }
15
+ return acc;
16
+ }, {}),
17
+ };
18
+ }
19
+ //# sourceMappingURL=component.js.map
20
+ //# debugId=566e4b83-5d2e-5906-b97d-7d50b06c7e23
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component.js","sources":["../../../../src/code-analyzer/components/mappers/component.ts"],"sourceRoot":"","sourcesContent":["import { ComponentDoc } from \"../parser/types.js\"\nimport { Component, ComponentProperty } from \"../types.js\"\nimport { mapToSupernovaProperty } from \"./property.js\"\nimport path from \"node:path\"\n\n/**\n * Maps docgen results to supernova component\n */\nexport function mapToSupernovaComponent(component: ComponentDoc, entryPath: string): Component {\n return {\n exportName: component.exportName,\n description: component.description,\n tags: component.tags ?? null,\n componentPath: path.relative(entryPath, component.filePath),\n properties: Object.entries(component.props).reduce(\n (acc, [name, property]) => {\n if (property.name !== \"key\") {\n // skip react key prop\n acc[name] = mapToSupernovaProperty(property, entryPath)\n }\n\n return acc\n },\n {} as Record<string, ComponentProperty>,\n ),\n }\n}\n"],"names":[],"mappings":";;AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,IAAI,MAAM,WAAW,CAAA;AAK5B,MAAM,UAAU,uBAAuB,CAAC,SAAuB,EAAE,SAAiB;IAChF,OAAO;QACL,UAAU,EAAE,SAAS,CAAC,UAAU;QAChC,WAAW,EAAE,SAAS,CAAC,WAAW;QAClC,IAAI,EAAE,SAAS,CAAC,IAAI,IAAI,IAAI;QAC5B,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,QAAQ,CAAC;QAC3D,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,MAAM,CAChD,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE;YACxB,IAAI,QAAQ,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;gBAE5B,GAAG,CAAC,IAAI,CAAC,GAAG,sBAAsB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;YACzD,CAAC;YAED,OAAO,GAAG,CAAA;QACZ,CAAC,EACD,EAAuC,CACxC;KACF,CAAA;AACH,CAAC","debug_id":"566e4b83-5d2e-5906-b97d-7d50b06c7e23"}
@@ -0,0 +1,4 @@
1
+ import { PropItem } from "../parser/types.js";
2
+ import { ComponentProperty } from "../types.js";
3
+ export declare function mapToSupernovaProperty(property: PropItem, entryPath: string): ComponentProperty;
4
+ //# sourceMappingURL=property.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.d.ts","sourceRoot":"","sources":["../../../../src/code-analyzer/components/mappers/property.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/C,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,GAAG,iBAAiB,CAa/F"}
@@ -0,0 +1,19 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4509b925-b6a0-5733-bc8b-ff7b6007813f")}catch(e){}}();
3
+ import path from "node:path";
4
+ export function mapToSupernovaProperty(property, entryPath) {
5
+ return {
6
+ defaultValue: property.defaultValue?.value,
7
+ name: property.name,
8
+ required: property.required,
9
+ description: property.description,
10
+ type: property.resolvedType,
11
+ tags: property.tags,
12
+ declarations: property.declarations?.map(declaration => ({
13
+ ...declaration,
14
+ fileName: path.relative(entryPath, declaration.fileName),
15
+ })),
16
+ };
17
+ }
18
+ //# sourceMappingURL=property.js.map
19
+ //# debugId=4509b925-b6a0-5733-bc8b-ff7b6007813f
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property.js","sources":["../../../../src/code-analyzer/components/mappers/property.ts"],"sourceRoot":"","sourcesContent":["import path from \"node:path\"\nimport { PropItem } from \"../parser/types.js\"\nimport { ComponentProperty } from \"../types.js\"\n\nexport function mapToSupernovaProperty(property: PropItem, entryPath: string): ComponentProperty {\n return {\n defaultValue: property.defaultValue?.value,\n name: property.name,\n required: property.required,\n description: property.description,\n type: property.resolvedType,\n tags: property.tags,\n declarations: property.declarations?.map(declaration => ({\n ...declaration,\n fileName: path.relative(entryPath, declaration.fileName),\n })),\n }\n}\n"],"names":[],"mappings":";;AAAA,OAAO,IAAI,MAAM,WAAW,CAAA;AAI5B,MAAM,UAAU,sBAAsB,CAAC,QAAkB,EAAE,SAAiB;IAC1E,OAAO;QACL,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,KAAK;QAC1C,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,WAAW,EAAE,QAAQ,CAAC,WAAW;QACjC,IAAI,EAAE,QAAQ,CAAC,YAAY;QAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,YAAY,EAAE,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YACvD,GAAG,WAAW;YACd,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,QAAQ,CAAC;SACzD,CAAC,CAAC;KACJ,CAAA;AACH,CAAC","debug_id":"4509b925-b6a0-5733-bc8b-ff7b6007813f"}
@@ -0,0 +1,6 @@
1
+ export * from "./module-parser.js";
2
+ export * from "./parser.js";
3
+ export * from "./types.js";
4
+ export * from "./utils/filter-duplicates.js";
5
+ export * from "./utils/is-react-component.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/code-analyzer/components/parser/index.ts"],"names":[],"mappings":"AAKA,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAE3B,cAAc,YAAY,CAAA;AAE1B,cAAc,8BAA8B,CAAA;AAE5C,cAAc,+BAA+B,CAAA"}
@@ -0,0 +1,9 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bb8db7f1-b961-5eca-a419-07bf2ed174d7")}catch(e){}}();
3
+ export * from "./module-parser.js";
4
+ export * from "./parser.js";
5
+ export * from "./types.js";
6
+ export * from "./utils/filter-duplicates.js";
7
+ export * from "./utils/is-react-component.js";
8
+ //# sourceMappingURL=index.js.map
9
+ //# debugId=bb8db7f1-b961-5eca-a419-07bf2ed174d7
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/code-analyzer/components/parser/index.ts"],"sourceRoot":"","sourcesContent":["/**\n * These files were adapted from https://github.com/styleguidist/react-docgen-typescript\n * with adjustments and additions for our specific needs.\n */\n\nexport * from \"./module-parser.js\"\nexport * from \"./parser.js\"\n\nexport * from \"./types.js\"\n\nexport * from \"./utils/filter-duplicates.js\"\n\nexport * from \"./utils/is-react-component.js\"\n"],"names":[],"mappings":";;AAKA,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAE3B,cAAc,YAAY,CAAA;AAE1B,cAAc,8BAA8B,CAAA;AAE5C,cAAc,+BAA+B,CAAA","debug_id":"bb8db7f1-b961-5eca-a419-07bf2ed174d7"}
@@ -0,0 +1,12 @@
1
+ import * as ts from "typescript";
2
+ import { ComponentDoc } from "./types.js";
3
+ export declare class ModuleParser {
4
+ private checker;
5
+ private entryFilePath;
6
+ private parser;
7
+ private program;
8
+ constructor(program: ts.Program, entryFilePath: string);
9
+ parseModule(): ComponentDoc[];
10
+ private parseFile;
11
+ }
12
+ //# sourceMappingURL=module-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-parser.d.ts","sourceRoot":"","sources":["../../../../src/code-analyzer/components/parser/module-parser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAA;AAGhC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAqCzC,qBAAa,YAAY;IACvB,OAAO,CAAC,OAAO,CAAgB;IAC/B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,OAAO,CAAY;gBAEf,OAAO,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM;IAO/C,WAAW,IAAI,YAAY,EAAE;IAWpC,OAAO,CAAC,SAAS;CAmFlB"}
@@ -0,0 +1,116 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7d3a3281-a8cb-50f9-a44c-29a0855836d6")}catch(e){}}();
3
+ import * as fs from "node:fs";
4
+ import path from "node:path";
5
+ import * as ts from "typescript";
6
+ import { Parser } from "./parser.js";
7
+ import { filterDuplicates } from "./utils/filter-duplicates.js";
8
+ function resolveModulePath(basePath, modulePath) {
9
+ const resolvedPath = path.resolve(path.dirname(basePath), modulePath);
10
+ if (fs.existsSync(resolvedPath)) {
11
+ const stats = fs.statSync(resolvedPath);
12
+ if (stats.isDirectory()) {
13
+ const dirContents = fs.readdirSync(resolvedPath);
14
+ const indexFile = dirContents.find(file => file.startsWith("index."));
15
+ if (indexFile) {
16
+ return path.join(resolvedPath, indexFile);
17
+ }
18
+ return null;
19
+ }
20
+ }
21
+ const dir = path.dirname(resolvedPath);
22
+ const basename = path.basename(resolvedPath);
23
+ if (fs.existsSync(dir)) {
24
+ const dirContents = fs.readdirSync(dir);
25
+ const matchingFile = dirContents.find(file => file.match(new RegExp(`^${basename}.tsx?$`)));
26
+ if (matchingFile) {
27
+ return path.join(dir, matchingFile);
28
+ }
29
+ }
30
+ return null;
31
+ }
32
+ export class ModuleParser {
33
+ checker;
34
+ entryFilePath;
35
+ parser;
36
+ program;
37
+ constructor(program, entryFilePath) {
38
+ this.program = program;
39
+ this.parser = new Parser(program, {});
40
+ this.entryFilePath = entryFilePath;
41
+ this.checker = program.getTypeChecker();
42
+ }
43
+ parseModule() {
44
+ const sourceFile = this.program.getSourceFile(this.entryFilePath);
45
+ if (!sourceFile) {
46
+ throw new Error(`Could not find source file for path ${this.entryFilePath}`);
47
+ }
48
+ const componentsInfo = this.parseFile(sourceFile);
49
+ return filterDuplicates(componentsInfo);
50
+ }
51
+ parseFile(scannedSource) {
52
+ const componentsInfo = [];
53
+ const moduleSymbol = this.checker.getSymbolAtLocation(scannedSource);
54
+ if (!moduleSymbol) {
55
+ throw new Error(`Could not find module symbol for source file: ${scannedSource.fileName}`);
56
+ }
57
+ ts.forEachChild(scannedSource, node => {
58
+ if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {
59
+ for (const exportSpecifier of node.exportClause.elements) {
60
+ const symbol = this.checker.getSymbolAtLocation(exportSpecifier.name);
61
+ if (symbol) {
62
+ componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource));
63
+ }
64
+ }
65
+ return;
66
+ }
67
+ if ((ts.isClassDeclaration(node) || ts.isFunctionDeclaration(node)) && hasExportModifier(node)) {
68
+ const symbol = node.name ? this.checker.getSymbolAtLocation(node.name) : undefined;
69
+ if (symbol) {
70
+ componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource));
71
+ }
72
+ return;
73
+ }
74
+ if (ts.isVariableStatement(node) && hasExportModifier(node)) {
75
+ for (const declaration of node.declarationList.declarations) {
76
+ if (ts.isIdentifier(declaration.name)) {
77
+ const symbol = this.checker.getSymbolAtLocation(declaration.name);
78
+ if (symbol) {
79
+ componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource));
80
+ }
81
+ }
82
+ }
83
+ return;
84
+ }
85
+ if (ts.isExportAssignment(node)) {
86
+ const symbol = this.checker.getSymbolAtLocation(node.expression);
87
+ if (symbol) {
88
+ componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource));
89
+ }
90
+ return;
91
+ }
92
+ if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {
93
+ const modulePath = node.moduleSpecifier.text;
94
+ const isStarExport = !node.exportClause || ts.isNamespaceExport(node.exportClause);
95
+ if (!isStarExport) {
96
+ return;
97
+ }
98
+ const resolvedPath = resolveModulePath(scannedSource.fileName, modulePath);
99
+ if (!resolvedPath || !fs.existsSync(resolvedPath)) {
100
+ return;
101
+ }
102
+ const newScannedSource = this.program.getSourceFile(resolvedPath);
103
+ if (newScannedSource) {
104
+ const newComponents = this.parseFile(newScannedSource);
105
+ componentsInfo.push(...newComponents);
106
+ }
107
+ }
108
+ });
109
+ return componentsInfo;
110
+ }
111
+ }
112
+ function hasExportModifier(node) {
113
+ return (ts.canHaveModifiers(node) && node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword)) || false;
114
+ }
115
+ //# sourceMappingURL=module-parser.js.map
116
+ //# debugId=7d3a3281-a8cb-50f9-a44c-29a0855836d6
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-parser.js","sources":["../../../../src/code-analyzer/components/parser/module-parser.ts"],"sourceRoot":"","sourcesContent":["import * as fs from \"node:fs\"\nimport path from \"node:path\"\nimport * as ts from \"typescript\"\n\nimport { Parser } from \"./parser.js\"\nimport { ComponentDoc } from \"./types.js\"\nimport { filterDuplicates } from \"./utils/filter-duplicates.js\"\n\n/**\n * resolve module path from the import whenever it is file or submodule\n */\nfunction resolveModulePath(basePath: string, modulePath: string) {\n const resolvedPath = path.resolve(path.dirname(basePath), modulePath)\n\n if (fs.existsSync(resolvedPath)) {\n const stats = fs.statSync(resolvedPath)\n if (stats.isDirectory()) {\n // Find index file in directory\n const dirContents = fs.readdirSync(resolvedPath)\n const indexFile = dirContents.find(file => file.startsWith(\"index.\"))\n if (indexFile) {\n return path.join(resolvedPath, indexFile)\n }\n\n return null\n }\n }\n\n // Find file with matching name but different extension\n const dir = path.dirname(resolvedPath)\n const basename = path.basename(resolvedPath)\n if (fs.existsSync(dir)) {\n const dirContents = fs.readdirSync(dir)\n const matchingFile = dirContents.find(file => file.match(new RegExp(`^${basename}.tsx?$`)))\n if (matchingFile) {\n return path.join(dir, matchingFile)\n }\n }\n\n return null\n}\n\nexport class ModuleParser {\n private checker: ts.TypeChecker\n private entryFilePath: string\n private parser: Parser\n private program: ts.Program\n\n constructor(program: ts.Program, entryFilePath: string) {\n this.program = program\n this.parser = new Parser(program, {})\n this.entryFilePath = entryFilePath\n this.checker = program.getTypeChecker()\n }\n\n public parseModule(): ComponentDoc[] {\n const sourceFile = this.program.getSourceFile(this.entryFilePath)\n\n if (!sourceFile) {\n throw new Error(`Could not find source file for path ${this.entryFilePath}`)\n }\n\n const componentsInfo = this.parseFile(sourceFile)\n return filterDuplicates(componentsInfo)\n }\n\n private parseFile(scannedSource: ts.SourceFile): ComponentDoc[] {\n const componentsInfo: ComponentDoc[] = []\n\n const moduleSymbol = this.checker.getSymbolAtLocation(scannedSource)\n if (!moduleSymbol) {\n throw new Error(`Could not find module symbol for source file: ${scannedSource.fileName}`)\n }\n\n // iterate through file symbols. We cannot use just getModuleExports. It don't show all exports. This is more reliable.\n ts.forEachChild(scannedSource, node => {\n // Handle named exports (export { X })\n if (ts.isExportDeclaration(node) && node.exportClause && ts.isNamedExports(node.exportClause)) {\n for (const exportSpecifier of node.exportClause.elements) {\n const symbol = this.checker.getSymbolAtLocation(exportSpecifier.name)\n if (symbol) {\n componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource))\n }\n }\n\n return\n }\n\n // Handle direct exports of functions and classes (export class X, export const X, etc)\n if ((ts.isClassDeclaration(node) || ts.isFunctionDeclaration(node)) && hasExportModifier(node)) {\n const symbol = node.name ? this.checker.getSymbolAtLocation(node.name) : undefined\n if (symbol) {\n componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource))\n }\n\n return\n }\n\n // handle direct export of variables, e.g. export const X\n if (ts.isVariableStatement(node) && hasExportModifier(node)) {\n for (const declaration of node.declarationList.declarations) {\n if (ts.isIdentifier(declaration.name)) {\n const symbol = this.checker.getSymbolAtLocation(declaration.name)\n if (symbol) {\n componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource))\n }\n }\n }\n\n return\n }\n\n // Handle default exports (export default X)\n if (ts.isExportAssignment(node)) {\n const symbol = this.checker.getSymbolAtLocation(node.expression)\n if (symbol) {\n componentsInfo.push(...this.parser.parseExportSymbol(symbol, scannedSource))\n }\n\n return\n }\n\n // Handle re-exports (export * from 'module')\n if (ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)) {\n const modulePath = node.moduleSpecifier.text\n\n // star export = export * from 'module'\n const isStarExport = !node.exportClause || ts.isNamespaceExport(node.exportClause)\n\n if (!isStarExport) {\n return\n }\n\n const resolvedPath = resolveModulePath(scannedSource.fileName, modulePath)\n if (!resolvedPath || !fs.existsSync(resolvedPath)) {\n // ignore star export if module path does not exist\n return\n }\n\n const newScannedSource = this.program.getSourceFile(resolvedPath)\n if (newScannedSource) {\n const newComponents = this.parseFile(newScannedSource)\n componentsInfo.push(...newComponents)\n }\n }\n })\n\n return componentsInfo\n }\n}\n\n// Helper function to check if node has export modifier\nfunction hasExportModifier(node: ts.Node): boolean {\n return (ts.canHaveModifiers(node) && node.modifiers?.some(mod => mod.kind === ts.SyntaxKind.ExportKeyword)) || false\n}\n"],"names":[],"mappings":";;AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAA;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,O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