@renr/parcel-reporter-docgen 0.1.0-beta.6 → 0.1.0-beta.8
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.
|
@@ -70,31 +70,41 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
|
|
|
70
70
|
log(`parsing file: : ${relFile}`);
|
|
71
71
|
const fileDocs = docsByFilePath.get(path.resolve(absPath)) || [];
|
|
72
72
|
const assignedInfo = getAssignedInfo(await fs.readFile(absPath, "utf-8"), componentName);
|
|
73
|
-
const
|
|
73
|
+
const usedDocs = /* @__PURE__ */ new Set();
|
|
74
|
+
let primaryDoc = fileDocs.find((d) => d.displayName === componentName) || (assignedInfo.baseIdentifier ? fileDocs.find((d) => d.displayName === assignedInfo.baseIdentifier) : void 0);
|
|
75
|
+
if (primaryDoc) usedDocs.add(primaryDoc);
|
|
74
76
|
let primaryProps = primaryDoc ? primaryDoc.props : {};
|
|
75
|
-
if (assignedInfo.baseIdentifier
|
|
77
|
+
if (assignedInfo.baseIdentifier) {
|
|
76
78
|
const baseDoc = fileDocs.find((d) => d.displayName === assignedInfo.baseIdentifier);
|
|
77
|
-
if (baseDoc
|
|
79
|
+
if (baseDoc) {
|
|
80
|
+
if (assignedInfo.baseIdentifier !== assignedInfo.subcomponentsMap.get("Root")) usedDocs.add(baseDoc);
|
|
81
|
+
if (primaryDoc && Object.keys(baseDoc.props).length > Object.keys(primaryProps).length) primaryProps = baseDoc.props;
|
|
82
|
+
}
|
|
78
83
|
}
|
|
79
|
-
const formattedPrimaryProps = formatProps(primaryProps);
|
|
80
84
|
const subcomponents = {};
|
|
81
85
|
for (const [subName, targetName] of assignedInfo.subcomponentsMap) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
if (subName === componentName) continue;
|
|
87
|
+
const subDoc = fileDocs.find((d) => d.displayName === targetName || d.displayName === `${componentName}.${subName}` || d.displayName === `${componentName}${subName}` || d.displayName === subName);
|
|
88
|
+
if (subDoc) {
|
|
89
|
+
usedDocs.add(subDoc);
|
|
90
|
+
subcomponents[subName] = {
|
|
91
|
+
name: `${componentName}.${subName}`,
|
|
92
|
+
description: subDoc.description || void 0,
|
|
93
|
+
props: formatProps(subDoc.props)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
88
96
|
}
|
|
97
|
+
const hasRoot = Boolean(subcomponents.Root) || fileDocs.some((d) => d.displayName === "Root" || d.displayName === `${componentName}Root` || d.displayName === `${componentName}.Root`);
|
|
89
98
|
for (const doc of fileDocs) {
|
|
90
|
-
if (doc
|
|
91
|
-
if (assignedInfo.baseIdentifier && doc.displayName === assignedInfo.baseIdentifier) continue;
|
|
99
|
+
if (usedDocs.has(doc)) continue;
|
|
92
100
|
let subName;
|
|
93
101
|
if (doc.displayName.startsWith(`${componentName}.`)) subName = doc.displayName.slice(componentName.length + 1);
|
|
94
|
-
else if (doc.displayName.startsWith(componentName)) subName = doc.displayName.slice(componentName.length);
|
|
95
|
-
if (
|
|
102
|
+
else if (doc.displayName.startsWith(componentName) && doc.displayName.length > componentName.length) subName = doc.displayName.slice(componentName.length);
|
|
103
|
+
else if (hasRoot) subName = doc.displayName;
|
|
104
|
+
if (subName && subName !== componentName) {
|
|
96
105
|
const existing = subcomponents[subName];
|
|
97
106
|
if (existing && Object.keys(existing.props).length >= Object.keys(doc.props).length) continue;
|
|
107
|
+
usedDocs.add(doc);
|
|
98
108
|
subcomponents[subName] = {
|
|
99
109
|
name: `${componentName}.${subName}`,
|
|
100
110
|
description: doc.description || void 0,
|
|
@@ -102,9 +112,16 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
|
|
|
102
112
|
};
|
|
103
113
|
}
|
|
104
114
|
}
|
|
115
|
+
const promotedRoot = !(Boolean(primaryDoc) && Object.keys(primaryProps).length > 0 && (primaryDoc === null || primaryDoc === void 0 ? void 0 : primaryDoc.displayName) !== "Root" && (primaryDoc === null || primaryDoc === void 0 ? void 0 : primaryDoc.displayName) !== `${componentName}Root` && (primaryDoc === null || primaryDoc === void 0 ? void 0 : primaryDoc.displayName) !== `${componentName}.Root` && assignedInfo.baseIdentifier !== assignedInfo.subcomponentsMap.get("Root")) && subcomponents.Root ? subcomponents.Root : void 0;
|
|
116
|
+
if (promotedRoot) delete subcomponents.Root;
|
|
117
|
+
else if (!primaryDoc) {
|
|
118
|
+
primaryDoc = fileDocs.find((d) => Object.keys(d.props).length > 0) || fileDocs[0];
|
|
119
|
+
primaryProps = primaryDoc ? primaryDoc.props : {};
|
|
120
|
+
}
|
|
121
|
+
const formattedPrimaryProps = promotedRoot ? promotedRoot.props : formatProps(primaryProps);
|
|
105
122
|
const componentJSON = JSON.stringify({
|
|
106
|
-
name: componentName,
|
|
107
|
-
description: (primaryDoc === null || primaryDoc === void 0 ? void 0 : primaryDoc.description) || void 0,
|
|
123
|
+
name: promotedRoot ? promotedRoot.name : componentName,
|
|
124
|
+
description: (promotedRoot ? promotedRoot.description : primaryDoc === null || primaryDoc === void 0 ? void 0 : primaryDoc.description) || void 0,
|
|
108
125
|
path: relFile.replace(/\\/g, "/"),
|
|
109
126
|
fileName: path.basename(relFile),
|
|
110
127
|
props: formattedPrimaryProps,
|
|
@@ -165,6 +182,16 @@ function getAssignedInfo(sourceText, compName) {
|
|
|
165
182
|
let baseIdentifier = null;
|
|
166
183
|
const subcomponentsMap = /* @__PURE__ */ new Map();
|
|
167
184
|
ts.forEachChild(sourceFile, (node) => {
|
|
185
|
+
if (ts.isExportDeclaration(node)) {
|
|
186
|
+
if (!node.isTypeOnly && node.exportClause && ts.isNamedExports(node.exportClause)) {
|
|
187
|
+
for (const element of node.exportClause.elements) if (!element.isTypeOnly && element.propertyName) {
|
|
188
|
+
const exportName = element.name.getText(sourceFile);
|
|
189
|
+
const localName = element.propertyName.getText(sourceFile);
|
|
190
|
+
if (exportName === compName) baseIdentifier = localName;
|
|
191
|
+
else if (/^[A-Z]/.test(exportName)) subcomponentsMap.set(exportName, localName);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
168
195
|
if (ts.isVariableStatement(node)) {
|
|
169
196
|
for (const decl of node.declarationList.declarations) if (decl.name.getText(sourceFile) === compName && decl.initializer && ts.isCallExpression(decl.initializer)) {
|
|
170
197
|
const call = decl.initializer;
|
|
@@ -173,12 +200,29 @@ function getAssignedInfo(sourceText, compName) {
|
|
|
173
200
|
const firstArg = call.arguments[0];
|
|
174
201
|
if (firstArg) baseIdentifier = firstArg.getText(sourceFile);
|
|
175
202
|
if (call.arguments.length > 1 && ts.isObjectLiteralExpression(call.arguments[1])) {
|
|
176
|
-
for (const prop of call.arguments[1].properties) if (ts.isPropertyAssignment(prop))
|
|
177
|
-
|
|
203
|
+
for (const prop of call.arguments[1].properties) if (ts.isPropertyAssignment(prop)) {
|
|
204
|
+
const propName = prop.name.getText(sourceFile);
|
|
205
|
+
const initName = prop.initializer.getText(sourceFile);
|
|
206
|
+
subcomponentsMap.set(propName, initName);
|
|
207
|
+
} else if (ts.isShorthandPropertyAssignment(prop)) {
|
|
208
|
+
const propName = prop.name.getText(sourceFile);
|
|
209
|
+
subcomponentsMap.set(propName, propName);
|
|
210
|
+
}
|
|
178
211
|
}
|
|
179
212
|
}
|
|
180
213
|
}
|
|
181
214
|
}
|
|
215
|
+
if (ts.isExpressionStatement(node) && ts.isBinaryExpression(node.expression)) {
|
|
216
|
+
const bin = node.expression;
|
|
217
|
+
if (bin.operatorToken.kind === ts.SyntaxKind.EqualsToken && ts.isPropertyAccessExpression(bin.left)) {
|
|
218
|
+
const objText = bin.left.expression.getText(sourceFile);
|
|
219
|
+
const propText = bin.left.name.getText(sourceFile);
|
|
220
|
+
if (objText === compName && /^[A-Z]/.test(propText)) {
|
|
221
|
+
const targetName = bin.right.getText(sourceFile);
|
|
222
|
+
subcomponentsMap.set(propText, targetName);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
182
226
|
});
|
|
183
227
|
return {
|
|
184
228
|
baseIdentifier,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-props.mjs","names":[],"sources":["../../src/generate-props.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport path from \"path\";\nimport { PropItem, withCustomConfig } from \"react-docgen-typescript\";\nimport { glob } from \"tinyglobby\";\nimport ts from \"typescript\";\nimport { fileURLToPath } from \"url\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// cache for watch mode across buildStart events\nconst fileMtimeCache = new Map<string, number>();\n\nexport async function generateProps(\n pagesPattern: string,\n rootDir: string,\n outputPath: string = \"docgen\",\n log: (...args: unknown[]) => void = console.log,\n customTsconfigPath?: string\n) {\n const files = await glob(pagesPattern, {\n cwd: rootDir,\n });\n\n if (files.length === 0) {\n log(`No files found for pattern: ${pagesPattern}`);\n return;\n }\n\n const resolvedOutputPath = path.resolve(rootDir, outputPath);\n await fs.mkdir(resolvedOutputPath, { recursive: true });\n\n const filesToProcess: {\n relFile: string;\n absPath: string;\n componentName: string;\n }[] = [];\n\n for (const file of files) {\n const filePath = path.resolve(rootDir, file);\n const componentName = path.basename(file, path.extname(file));\n const outputFilePath = path.join(\n resolvedOutputPath,\n `${componentName}.json`\n );\n\n try {\n const sourceStat = await fs.stat(filePath);\n const cachedMtime = fileMtimeCache.get(filePath);\n\n let isUpToDate = false;\n try {\n const outStat = await fs.stat(outputFilePath);\n if (\n (cachedMtime !== undefined && cachedMtime === sourceStat.mtimeMs) ||\n outStat.mtimeMs >= sourceStat.mtimeMs\n ) {\n isUpToDate = true;\n fileMtimeCache.set(filePath, sourceStat.mtimeMs);\n }\n } catch {\n // output file does not exist\n }\n\n if (isUpToDate) {\n continue;\n }\n\n filesToProcess.push({\n relFile: file,\n absPath: filePath,\n componentName,\n });\n fileMtimeCache.set(filePath, sourceStat.mtimeMs);\n } catch {\n // source file not accessible\n }\n }\n\n if (filesToProcess.length === 0) {\n return;\n }\n\n log(\n `Found ${filesToProcess.length} changed file(s) for pattern: ${pagesPattern}`\n );\n\n const resolvedTsconfigPath = customTsconfigPath\n ? path.resolve(rootDir, customTsconfigPath)\n : path.resolve(rootDir, \"./tsconfig.json\");\n\n const docgenParser = withCustomConfig(resolvedTsconfigPath, {\n shouldExtractLiteralValuesFromEnum: true,\n savePropValueAsString: true,\n propFilter: (prop) => {\n if (Array.isArray(prop.declarations) && prop.declarations[0]) {\n const declaration = prop.declarations[0];\n\n if (declaration.fileName.includes(\"node_modules/@types/react\")) {\n if (prop.name !== \"ref\" && prop.name !== \"className\") {\n return false;\n }\n }\n }\n return true;\n },\n });\n\n try {\n const absPaths = filesToProcess.map((f) => f.absPath);\n const allDocs = docgenParser.parse(absPaths);\n\n const docsByFilePath = new Map<string, typeof allDocs>();\n for (const doc of allDocs) {\n if (doc.filePath) {\n const key = path.resolve(doc.filePath);\n const list = docsByFilePath.get(key) || [];\n list.push(doc);\n docsByFilePath.set(key, list);\n }\n }\n\n await Promise.all(\n filesToProcess.map(async ({ relFile, absPath, componentName }) => {\n log(`parsing file: : ${relFile}`);\n\n const fileDocs = docsByFilePath.get(path.resolve(absPath)) || [];\n\n // Check if the component was composed using Object.assign(Base, { SubName: Target, ... })\n const sourceText = await fs.readFile(absPath, \"utf-8\");\n const assignedInfo = getAssignedInfo(sourceText, componentName);\n\n // 1. Identify primary component doc matching componentName or assigned base\n const primaryDoc =\n fileDocs.find((d) => d.displayName === componentName) ||\n (assignedInfo.baseIdentifier\n ? fileDocs.find(\n (d) => d.displayName === assignedInfo.baseIdentifier\n )\n : undefined) ||\n fileDocs.find((d) => Object.keys(d.props).length > 0) ||\n fileDocs[0];\n\n // If primaryDoc was created by Object.assign and lost props, recover from base\n let primaryProps = primaryDoc ? primaryDoc.props : {};\n if (\n assignedInfo.baseIdentifier &&\n primaryDoc &&\n primaryDoc.displayName === componentName\n ) {\n const baseDoc = fileDocs.find(\n (d) => d.displayName === assignedInfo.baseIdentifier\n );\n if (\n baseDoc &&\n Object.keys(baseDoc.props).length > Object.keys(primaryProps).length\n ) {\n primaryProps = baseDoc.props;\n }\n }\n\n const formattedPrimaryProps = formatProps(primaryProps);\n\n // 2. Identify subcomponents\n const subcomponents: Record<\n string,\n {\n name: string;\n description?: string;\n props: ReturnType<typeof formatProps>;\n }\n > = {};\n\n // a) Handle subcomponents explicitly assigned via Object.assign(Base, { SubName: Target })\n for (const [subName, targetName] of assignedInfo.subcomponentsMap) {\n const subDoc = fileDocs.find(\n (d) =>\n d.displayName === targetName ||\n d.displayName === `${componentName}.${subName}`\n );\n if (subDoc) {\n subcomponents[subName] = {\n name: `${componentName}.${subName}`,\n description: subDoc.description || undefined,\n props: formatProps(subDoc.props),\n };\n }\n }\n\n // b) Handle subcomponents matching standard React dot notation or component prefix\n for (const doc of fileDocs) {\n if (doc === primaryDoc) continue;\n if (\n assignedInfo.baseIdentifier &&\n doc.displayName === assignedInfo.baseIdentifier\n ) {\n continue;\n }\n\n let subName: string | undefined;\n if (doc.displayName.startsWith(`${componentName}.`)) {\n subName = doc.displayName.slice(componentName.length + 1);\n } else if (doc.displayName.startsWith(componentName)) {\n subName = doc.displayName.slice(componentName.length);\n }\n\n if (subName) {\n const existing = subcomponents[subName];\n if (\n existing &&\n Object.keys(existing.props).length >=\n Object.keys(doc.props).length\n ) {\n continue;\n }\n\n subcomponents[subName] = {\n name: `${componentName}.${subName}`,\n description: doc.description || undefined,\n props: formatProps(doc.props),\n };\n }\n }\n\n const componentJSON = JSON.stringify(\n {\n name: componentName,\n description: primaryDoc?.description || undefined,\n path: relFile.replace(/\\\\/g, \"/\"),\n fileName: path.basename(relFile),\n props: formattedPrimaryProps,\n subcomponents:\n Object.keys(subcomponents).length > 0 ? subcomponents : undefined,\n },\n null,\n 2\n );\n\n const outputFilePath = path.join(\n resolvedOutputPath,\n `${componentName}.json`\n );\n await fs.writeFile(outputFilePath, componentJSON + \"\\n\", \"utf-8\");\n\n log(`Generated props for ${componentName}`);\n })\n );\n } catch (err) {\n log(`Error generating props: ${(err as Error).message}`);\n }\n}\n\n// based on https://github.com/mui/base-ui/blob/master/docs/src/components/ReferenceTable/PropsReferenceAccordion.tsx\nfunction getShortPropType(name: string, type: string) {\n if (/^(on|get)[A-Z].*/.test(name)) {\n return { type: \"function\", detailedType: true };\n }\n\n if (type === undefined || type === null) {\n return { type: String(type), detailedType: false };\n }\n\n if (name === \"className\") {\n return { type: \"string | function\", detailedType: true };\n }\n\n if (name === \"render\") {\n return { type: \"ReactElement | function\", detailedType: true };\n }\n\n if (\n name.endsWith(\"Ref\") ||\n name === \"children\" ||\n type === \"boolean\" ||\n type === \"string\" ||\n type === \"number\" ||\n type.indexOf(\" | \") === -1 ||\n (type.split(\"|\").length < 3 && type.length < 30)\n ) {\n return { type, detailedType: false };\n }\n\n return { type: \"Union\", detailedType: true };\n}\n\nfunction formatProps(rawProps: Record<string, PropItem>) {\n const props: Record<\n string,\n PropItem & {\n shortPropTypeName: string | null;\n }\n > = {};\n\n for (const propName in rawProps) {\n const rawProp = rawProps[propName];\n if (!rawProp) {\n continue;\n }\n\n const prop = { ...rawProp } as PropItem & {\n shortPropTypeName: string | null;\n };\n\n if (prop.type && prop.type.name) {\n const { type: shortPropTypeName, detailedType } = getShortPropType(\n propName,\n prop.type.name\n );\n\n const hasExpandedType = Boolean(detailedType);\n\n prop.type.name =\n hasExpandedType && prop.type.name.split(\"|\").length > 3\n ? prop.type.name\n .split(\"|\")\n .map((line) => `| ${line}\\n`)\n .join(\"\")\n : prop.type.name;\n\n prop.shortPropTypeName = hasExpandedType ? shortPropTypeName : null;\n }\n\n props[propName] = prop;\n }\n\n return props;\n}\n\nfunction getAssignedInfo(sourceText: string, compName: string) {\n const sourceFile = ts.createSourceFile(\n \"temp.tsx\",\n sourceText,\n ts.ScriptTarget.Latest,\n true\n );\n let baseIdentifier: string | null = null;\n const subcomponentsMap = new Map<string, string>();\n\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isVariableStatement(node)) {\n for (const decl of node.declarationList.declarations) {\n if (\n decl.name.getText(sourceFile) === compName &&\n decl.initializer &&\n ts.isCallExpression(decl.initializer)\n ) {\n const call = decl.initializer;\n const exprText = call.expression.getText(sourceFile);\n if (\n (exprText === \"Object.assign\" || exprText.endsWith(\".assign\")) &&\n call.arguments.length > 0\n ) {\n const firstArg = call.arguments[0];\n if (firstArg) {\n baseIdentifier = firstArg.getText(sourceFile);\n }\n if (\n call.arguments.length > 1 &&\n ts.isObjectLiteralExpression(call.arguments[1]!)\n ) {\n for (const prop of call.arguments[1]!.properties) {\n if (ts.isPropertyAssignment(prop)) {\n subcomponentsMap.set(\n prop.name.getText(sourceFile),\n prop.initializer.getText(sourceFile)\n );\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n subcomponentsMap.set(\n prop.name.getText(sourceFile),\n prop.name.getText(sourceFile)\n );\n }\n }\n }\n }\n }\n }\n }\n });\n\n return { baseIdentifier, subcomponentsMap };\n}\n"],"mappings":";;;;;;;AAOA,MAAM,aAAa,cAAc,YAAY,GAAG;AAC9B,KAAK,QAAQ,UAAU;AAGzC,MAAM,iCAAiB,IAAI,IAAoB;AAE/C,eAAsB,cACpB,cACA,SACA,aAAqB,UACrB,MAAoC,QAAQ,KAC5C,oBACA;CACA,MAAM,QAAQ,MAAM,KAAK,cAAc,EACrC,KAAK,QACP,CAAC;CAED,IAAI,MAAM,WAAW,GAAG;EACtB,IAAI,+BAA+B,cAAc;EACjD;CACF;CAEA,MAAM,qBAAqB,KAAK,QAAQ,SAAS,UAAU;CAC3D,MAAM,GAAG,MAAM,oBAAoB,EAAE,WAAW,KAAK,CAAC;CAEtD,MAAM,iBAIA,CAAC;CAEP,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,QAAQ,SAAS,IAAI;EAC3C,MAAM,gBAAgB,KAAK,SAAS,MAAM,KAAK,QAAQ,IAAI,CAAC;EAC5D,MAAM,iBAAiB,KAAK,KAC1B,oBACA,GAAG,cAAc,MACnB;EAEA,IAAI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AAQ,UAAU;IACnD,KACG,aAAa,mBAAmB,SAAS,SAAS,SAAS,MAC5D,KAAK,UAAU,SAAS,GACxB;KACA,MAAM,WAAW,KAAK,UAAU;KAChC,IAAI,UACF,iBAAiB,SAAS,QAAQ,UAAU;KAE9C,IACE,KAAK,UAAU,SAAS,KACxB,GAAG,0BAA0B,KAAK,UAAU,EAAG,GAE1C;WAAA,MAAM,QAAQ,KAAK,UAAU,EAAE,CAAE,YACpC,IAAI,GAAG,qBAAqB,IAAI,GAC9B,iBAAiB,IACf,KAAK,KAAK,QAAQ,UAAU,GAC5B,KAAK,YAAY,QAAQ,UAAU,CACrC;WACK,IAAI,GAAG,8BAA8B,IAAI,GAC9C,iBAAiB,IACf,KAAK,KAAK,QAAQ,UAAU,GAC5B,KAAK,KAAK,QAAQ,UAAU,CAC9B;KAAA;IAIR;GACF;;CAGN,CAAC;CAED,OAAO;EAAE;EAAgB;CAAiB;AAC5C"}
|
|
1
|
+
{"version":3,"file":"generate-props.mjs","names":[],"sources":["../../src/generate-props.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport path from \"path\";\nimport { PropItem, withCustomConfig } from \"react-docgen-typescript\";\nimport { glob } from \"tinyglobby\";\nimport ts from \"typescript\";\nimport { fileURLToPath } from \"url\";\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// cache for watch mode across buildStart events\nconst fileMtimeCache = new Map<string, number>();\n\nexport async function generateProps(\n pagesPattern: string,\n rootDir: string,\n outputPath: string = \"docgen\",\n log: (...args: unknown[]) => void = console.log,\n customTsconfigPath?: string\n) {\n const files = await glob(pagesPattern, {\n cwd: rootDir,\n });\n\n if (files.length === 0) {\n log(`No files found for pattern: ${pagesPattern}`);\n return;\n }\n\n const resolvedOutputPath = path.resolve(rootDir, outputPath);\n await fs.mkdir(resolvedOutputPath, { recursive: true });\n\n const filesToProcess: {\n relFile: string;\n absPath: string;\n componentName: string;\n }[] = [];\n\n for (const file of files) {\n const filePath = path.resolve(rootDir, file);\n const componentName = path.basename(file, path.extname(file));\n const outputFilePath = path.join(\n resolvedOutputPath,\n `${componentName}.json`\n );\n\n try {\n const sourceStat = await fs.stat(filePath);\n const cachedMtime = fileMtimeCache.get(filePath);\n\n let isUpToDate = false;\n try {\n const outStat = await fs.stat(outputFilePath);\n if (\n (cachedMtime !== undefined && cachedMtime === sourceStat.mtimeMs) ||\n outStat.mtimeMs >= sourceStat.mtimeMs\n ) {\n isUpToDate = true;\n fileMtimeCache.set(filePath, sourceStat.mtimeMs);\n }\n } catch {\n // output file does not exist\n }\n\n if (isUpToDate) {\n continue;\n }\n\n filesToProcess.push({\n relFile: file,\n absPath: filePath,\n componentName,\n });\n fileMtimeCache.set(filePath, sourceStat.mtimeMs);\n } catch {\n // source file not accessible\n }\n }\n\n if (filesToProcess.length === 0) {\n return;\n }\n\n log(\n `Found ${filesToProcess.length} changed file(s) for pattern: ${pagesPattern}`\n );\n\n const resolvedTsconfigPath = customTsconfigPath\n ? path.resolve(rootDir, customTsconfigPath)\n : path.resolve(rootDir, \"./tsconfig.json\");\n\n const docgenParser = withCustomConfig(resolvedTsconfigPath, {\n shouldExtractLiteralValuesFromEnum: true,\n savePropValueAsString: true,\n propFilter: (prop) => {\n if (Array.isArray(prop.declarations) && prop.declarations[0]) {\n const declaration = prop.declarations[0];\n\n if (declaration.fileName.includes(\"node_modules/@types/react\")) {\n if (prop.name !== \"ref\" && prop.name !== \"className\") {\n return false;\n }\n }\n }\n return true;\n },\n });\n\n try {\n const absPaths = filesToProcess.map((f) => f.absPath);\n const allDocs = docgenParser.parse(absPaths);\n\n const docsByFilePath = new Map<string, typeof allDocs>();\n for (const doc of allDocs) {\n if (doc.filePath) {\n const key = path.resolve(doc.filePath);\n const list = docsByFilePath.get(key) || [];\n list.push(doc);\n docsByFilePath.set(key, list);\n }\n }\n\n await Promise.all(\n filesToProcess.map(async ({ relFile, absPath, componentName }) => {\n log(`parsing file: : ${relFile}`);\n\n const fileDocs = docsByFilePath.get(path.resolve(absPath)) || [];\n\n // Check if the component was composed using Object.assign or exports compound parts\n const sourceText = await fs.readFile(absPath, \"utf-8\");\n const assignedInfo = getAssignedInfo(sourceText, componentName);\n\n const usedDocs = new Set<(typeof fileDocs)[number]>();\n\n // 1. Identify explicit primary component doc matching componentName or assigned base\n let primaryDoc =\n fileDocs.find((d) => d.displayName === componentName) ||\n (assignedInfo.baseIdentifier\n ? fileDocs.find(\n (d) => d.displayName === assignedInfo.baseIdentifier\n )\n : undefined);\n\n if (primaryDoc) {\n usedDocs.add(primaryDoc);\n }\n\n // If primaryDoc was created by Object.assign and lost props, recover from base\n let primaryProps = primaryDoc ? primaryDoc.props : {};\n if (assignedInfo.baseIdentifier) {\n const baseDoc = fileDocs.find(\n (d) => d.displayName === assignedInfo.baseIdentifier\n );\n if (baseDoc) {\n if (\n assignedInfo.baseIdentifier !==\n assignedInfo.subcomponentsMap.get(\"Root\")\n ) {\n usedDocs.add(baseDoc);\n }\n if (\n primaryDoc &&\n Object.keys(baseDoc.props).length >\n Object.keys(primaryProps).length\n ) {\n primaryProps = baseDoc.props;\n }\n }\n }\n\n // 2. Identify subcomponents (including Root if present)\n const subcomponents: Record<\n string,\n {\n name: string;\n description?: string;\n props: ReturnType<typeof formatProps>;\n }\n > = {};\n\n // a) Handle subcomponents explicitly assigned or exported\n for (const [subName, targetName] of assignedInfo.subcomponentsMap) {\n if (subName === componentName) continue;\n const subDoc = fileDocs.find(\n (d) =>\n d.displayName === targetName ||\n d.displayName === `${componentName}.${subName}` ||\n d.displayName === `${componentName}${subName}` ||\n d.displayName === subName\n );\n if (subDoc) {\n usedDocs.add(subDoc);\n subcomponents[subName] = {\n name: `${componentName}.${subName}`,\n description: subDoc.description || undefined,\n props: formatProps(subDoc.props),\n };\n }\n }\n\n const hasRoot =\n Boolean(subcomponents.Root) ||\n fileDocs.some(\n (d) =>\n d.displayName === \"Root\" ||\n d.displayName === `${componentName}Root` ||\n d.displayName === `${componentName}.Root`\n );\n\n // b) Handle subcomponents matching standard React dot notation or component prefix\n for (const doc of fileDocs) {\n if (usedDocs.has(doc)) continue;\n\n let subName: string | undefined;\n if (doc.displayName.startsWith(`${componentName}.`)) {\n subName = doc.displayName.slice(componentName.length + 1);\n } else if (\n doc.displayName.startsWith(componentName) &&\n doc.displayName.length > componentName.length\n ) {\n subName = doc.displayName.slice(componentName.length);\n } else if (hasRoot) {\n subName = doc.displayName;\n }\n\n if (subName && subName !== componentName) {\n const existing = subcomponents[subName];\n if (\n existing &&\n Object.keys(existing.props).length >=\n Object.keys(doc.props).length\n ) {\n continue;\n }\n\n usedDocs.add(doc);\n subcomponents[subName] = {\n name: `${componentName}.${subName}`,\n description: doc.description || undefined,\n props: formatProps(doc.props),\n };\n }\n }\n\n const hasDistinctPrimary =\n Boolean(primaryDoc) &&\n Object.keys(primaryProps).length > 0 &&\n primaryDoc?.displayName !== \"Root\" &&\n primaryDoc?.displayName !== `${componentName}Root` &&\n primaryDoc?.displayName !== `${componentName}.Root` &&\n assignedInfo.baseIdentifier !==\n assignedInfo.subcomponentsMap.get(\"Root\");\n\n // Promote Root subcomponent to primary component only when no distinct primary component exists\n const promotedRoot =\n !hasDistinctPrimary && subcomponents.Root\n ? subcomponents.Root\n : undefined;\n if (promotedRoot) {\n delete subcomponents.Root;\n } else if (!primaryDoc) {\n primaryDoc =\n fileDocs.find((d) => Object.keys(d.props).length > 0) ||\n fileDocs[0];\n primaryProps = primaryDoc ? primaryDoc.props : {};\n }\n\n const formattedPrimaryProps = promotedRoot\n ? promotedRoot.props\n : formatProps(primaryProps);\n\n const componentJSON = JSON.stringify(\n {\n name: promotedRoot ? promotedRoot.name : componentName,\n description:\n (promotedRoot\n ? promotedRoot.description\n : primaryDoc?.description) || undefined,\n path: relFile.replace(/\\\\/g, \"/\"),\n fileName: path.basename(relFile),\n props: formattedPrimaryProps,\n subcomponents:\n Object.keys(subcomponents).length > 0 ? subcomponents : undefined,\n },\n null,\n 2\n );\n\n const outputFilePath = path.join(\n resolvedOutputPath,\n `${componentName}.json`\n );\n await fs.writeFile(outputFilePath, componentJSON + \"\\n\", \"utf-8\");\n\n log(`Generated props for ${componentName}`);\n })\n );\n } catch (err) {\n log(`Error generating props: ${(err as Error).message}`);\n }\n}\n\n// based on https://github.com/mui/base-ui/blob/master/docs/src/components/ReferenceTable/PropsReferenceAccordion.tsx\nfunction getShortPropType(name: string, type: string) {\n if (/^(on|get)[A-Z].*/.test(name)) {\n return { type: \"function\", detailedType: true };\n }\n\n if (type === undefined || type === null) {\n return { type: String(type), detailedType: false };\n }\n\n if (name === \"className\") {\n return { type: \"string | function\", detailedType: true };\n }\n\n if (name === \"render\") {\n return { type: \"ReactElement | function\", detailedType: true };\n }\n\n if (\n name.endsWith(\"Ref\") ||\n name === \"children\" ||\n type === \"boolean\" ||\n type === \"string\" ||\n type === \"number\" ||\n type.indexOf(\" | \") === -1 ||\n (type.split(\"|\").length < 3 && type.length < 30)\n ) {\n return { type, detailedType: false };\n }\n\n return { type: \"Union\", detailedType: true };\n}\n\nfunction formatProps(rawProps: Record<string, PropItem>) {\n const props: Record<\n string,\n PropItem & {\n shortPropTypeName: string | null;\n }\n > = {};\n\n for (const propName in rawProps) {\n const rawProp = rawProps[propName];\n if (!rawProp) {\n continue;\n }\n\n const prop = { ...rawProp } as PropItem & {\n shortPropTypeName: string | null;\n };\n\n if (prop.type && prop.type.name) {\n const { type: shortPropTypeName, detailedType } = getShortPropType(\n propName,\n prop.type.name\n );\n\n const hasExpandedType = Boolean(detailedType);\n\n prop.type.name =\n hasExpandedType && prop.type.name.split(\"|\").length > 3\n ? prop.type.name\n .split(\"|\")\n .map((line) => `| ${line}\\n`)\n .join(\"\")\n : prop.type.name;\n\n prop.shortPropTypeName = hasExpandedType ? shortPropTypeName : null;\n }\n\n props[propName] = prop;\n }\n\n return props;\n}\n\nfunction getAssignedInfo(sourceText: string, compName: string) {\n const sourceFile = ts.createSourceFile(\n \"temp.tsx\",\n sourceText,\n ts.ScriptTarget.Latest,\n true\n );\n let baseIdentifier: string | null = null;\n const subcomponentsMap = new Map<string, string>();\n\n ts.forEachChild(sourceFile, (node) => {\n // 1. export { Local as Exported, ... }\n if (ts.isExportDeclaration(node)) {\n if (\n !node.isTypeOnly &&\n node.exportClause &&\n ts.isNamedExports(node.exportClause)\n ) {\n for (const element of node.exportClause.elements) {\n if (!element.isTypeOnly && element.propertyName) {\n const exportName = element.name.getText(sourceFile);\n const localName = element.propertyName.getText(sourceFile);\n if (exportName === compName) {\n baseIdentifier = localName;\n } else if (/^[A-Z]/.test(exportName)) {\n subcomponentsMap.set(exportName, localName);\n }\n }\n }\n }\n }\n\n // 2. export const Comp = Object.assign(Base, { SubName: Target, ... })\n if (ts.isVariableStatement(node)) {\n for (const decl of node.declarationList.declarations) {\n if (\n decl.name.getText(sourceFile) === compName &&\n decl.initializer &&\n ts.isCallExpression(decl.initializer)\n ) {\n const call = decl.initializer;\n const exprText = call.expression.getText(sourceFile);\n if (\n (exprText === \"Object.assign\" || exprText.endsWith(\".assign\")) &&\n call.arguments.length > 0\n ) {\n const firstArg = call.arguments[0];\n if (firstArg) {\n baseIdentifier = firstArg.getText(sourceFile);\n }\n if (\n call.arguments.length > 1 &&\n ts.isObjectLiteralExpression(call.arguments[1]!)\n ) {\n for (const prop of call.arguments[1]!.properties) {\n if (ts.isPropertyAssignment(prop)) {\n const propName = prop.name.getText(sourceFile);\n const initName = prop.initializer.getText(sourceFile);\n subcomponentsMap.set(propName, initName);\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n const propName = prop.name.getText(sourceFile);\n subcomponentsMap.set(propName, propName);\n }\n }\n }\n }\n }\n }\n }\n\n // 3. Comp.Sub = Target\n if (\n ts.isExpressionStatement(node) &&\n ts.isBinaryExpression(node.expression)\n ) {\n const bin = node.expression;\n if (\n bin.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n ts.isPropertyAccessExpression(bin.left)\n ) {\n const objText = bin.left.expression.getText(sourceFile);\n const propText = bin.left.name.getText(sourceFile);\n if (objText === compName && /^[A-Z]/.test(propText)) {\n const targetName = bin.right.getText(sourceFile);\n subcomponentsMap.set(propText, targetName);\n }\n }\n }\n });\n\n return { baseIdentifier, subcomponentsMap };\n}\n"],"mappings":";;;;;;;AAOA,MAAM,aAAa,cAAc,YAAY,GAAG;AAC9B,KAAK,QAAQ,UAAU;AAGzC,MAAM,iCAAiB,IAAI,IAAoB;AAE/C,eAAsB,cACpB,cACA,SACA,aAAqB,UACrB,MAAoC,QAAQ,KAC5C,oBACA;CACA,MAAM,QAAQ,MAAM,KAAK,cAAc,EACrC,KAAK,QACP,CAAC;CAED,IAAI,MAAM,WAAW,GAAG;EACtB,IAAI,+BAA+B,cAAc;EACjD;CACF;CAEA,MAAM,qBAAqB,KAAK,QAAQ,SAAS,UAAU;CAC3D,MAAM,GAAG,MAAM,oBAAoB,EAAE,WAAW,KAAK,CAAC;CAEtD,MAAM,iBAIA,CAAC;CAEP,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,WAAW,KAAK,QAAQ,SAAS,IAAI;EAC3C,MAAM,gBAAgB,KAAK,SAAS,MAAM,KAAK,QAAQ,IAAI,CAAC;EAC5D,MAAM,iBAAiB,KAAK,KAC1B,oBACA,GAAG,cAAc,MACnB;EAEA,IAAI;GACF,MAAM,aAAa,MAAM,GAAG,KAAK,QAAQ;GACzC,MAAM,cAAc,eAAe,IAAI,QAAQ;GAE/C,IAAI,aAAa;GACjB,IAAI;IACF,MAAM,UAAU,MAAM,GAAG,KAAK,cAAc;IAC5C,IACG,gBAAgB,KAAA,KAAa,gBAAgB,WAAW,WACzD,QAAQ,WAAW,WAAW,SAC9B;KACA,aAAa;KACb,eAAe,IAAI,UAAU,WAAW,OAAO;IACjD;GACF,SAAA,SAAQ,CAER;GAEA,IAAI,YACF;GAGF,eAAe,KAAK;IAClB,SAAS;IACT,SAAS;IACT;GACF,CAAC;GACD,eAAe,IAAI,UAAU,WAAW,OAAO;EACjD,SAAA,UAAQ,CAER;CACF;CAEA,IA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