@renr/parcel-reporter-docgen 0.1.0-beta.10 → 0.1.0-beta.12

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.
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env node
2
+ import { generateProps } from "./generate-props.mjs";
3
+ import fsSync from "fs";
4
+ import path from "path";
5
+ import { parseArgs } from "util";
6
+ //#region src/cli.ts
7
+ const origin = "@renr/parcel-reporter-docgen";
8
+ function loadParcelRcConfig(rootDir) {
9
+ const parcelRcPath = path.join(rootDir, ".parcelrc");
10
+ if (!fsSync.existsSync(parcelRcPath)) return;
11
+ try {
12
+ const raw = JSON.parse(fsSync.readFileSync(parcelRcPath, "utf-8"));
13
+ if (Array.isArray(raw.reporters)) {
14
+ for (const entry of raw.reporters) if (typeof entry === "object" && entry !== null && entry.plugin === origin && entry.config) return entry.config;
15
+ }
16
+ } catch (_unused) {}
17
+ }
18
+ function loadPackageConfig(rootDir) {
19
+ const pkgPath = path.join(rootDir, "package.json");
20
+ if (!fsSync.existsSync(pkgPath)) return;
21
+ try {
22
+ return JSON.parse(fsSync.readFileSync(pkgPath, "utf-8"));
23
+ } catch (_unused2) {
24
+ return;
25
+ }
26
+ }
27
+ async function main() {
28
+ var _ref, _ref2, _pkgConfig$origin, _ref3, _ref4, _pkgConfig$origin2, _ref5, _ref6, _pkgConfig$origin3;
29
+ const { values } = parseArgs({
30
+ options: {
31
+ source: {
32
+ type: "string",
33
+ short: "s"
34
+ },
35
+ output: {
36
+ type: "string",
37
+ short: "o"
38
+ },
39
+ tsconfig: {
40
+ type: "string",
41
+ short: "t"
42
+ },
43
+ root: {
44
+ type: "string",
45
+ short: "r"
46
+ }
47
+ },
48
+ strict: false
49
+ });
50
+ const rootDir = typeof values.root === "string" ? path.resolve(process.cwd(), values.root) : process.cwd();
51
+ const rcConfig = loadParcelRcConfig(rootDir);
52
+ const pkgConfig = loadPackageConfig(rootDir);
53
+ const source = (_ref = (_ref2 = typeof values.source === "string" ? values.source : void 0) !== null && _ref2 !== void 0 ? _ref2 : rcConfig === null || rcConfig === void 0 ? void 0 : rcConfig.source) !== null && _ref !== void 0 ? _ref : pkgConfig === null || pkgConfig === void 0 || (_pkgConfig$origin = pkgConfig[origin]) === null || _pkgConfig$origin === void 0 ? void 0 : _pkgConfig$origin.source;
54
+ const output = (_ref3 = (_ref4 = typeof values.output === "string" ? values.output : void 0) !== null && _ref4 !== void 0 ? _ref4 : rcConfig === null || rcConfig === void 0 ? void 0 : rcConfig.output) !== null && _ref3 !== void 0 ? _ref3 : pkgConfig === null || pkgConfig === void 0 || (_pkgConfig$origin2 = pkgConfig[origin]) === null || _pkgConfig$origin2 === void 0 ? void 0 : _pkgConfig$origin2.output;
55
+ const tsconfig = (_ref5 = (_ref6 = typeof values.tsconfig === "string" ? values.tsconfig : void 0) !== null && _ref6 !== void 0 ? _ref6 : rcConfig === null || rcConfig === void 0 ? void 0 : rcConfig.tsconfig) !== null && _ref5 !== void 0 ? _ref5 : pkgConfig === null || pkgConfig === void 0 || (_pkgConfig$origin3 = pkgConfig[origin]) === null || _pkgConfig$origin3 === void 0 ? void 0 : _pkgConfig$origin3.tsconfig;
56
+ if (!source) throw new Error(`No "${origin}" source found in .parcelrc or package.json.`);
57
+ await generateProps(source, rootDir, output || "docgen", (...args) => console.info(args.join(" ")), tsconfig);
58
+ }
59
+ main().catch((error) => {
60
+ console.error(error instanceof Error ? error.message : String(error));
61
+ process.exit(1);
62
+ });
63
+ //#endregion
64
+ export {};
65
+
66
+ //# sourceMappingURL=cli.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.mjs","names":["fs"],"sources":["../../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport fs from \"fs\";\nimport path from \"path\";\nimport { parseArgs } from \"util\";\nimport { generateProps } from \"./generate-props.js\";\n\nconst origin = \"@renr/parcel-reporter-docgen\";\n\ninterface DocgenPluginConfig {\n source?: string;\n output?: string;\n tsconfig?: string;\n}\n\ninterface PackageConfig {\n [origin]?: DocgenPluginConfig;\n}\n\nfunction loadParcelRcConfig(rootDir: string): DocgenPluginConfig | undefined {\n const parcelRcPath = path.join(rootDir, \".parcelrc\");\n if (!fs.existsSync(parcelRcPath)) {\n return undefined;\n }\n try {\n const raw = JSON.parse(fs.readFileSync(parcelRcPath, \"utf-8\")) as {\n reporters?: Array<\n string | { plugin?: string; config?: DocgenPluginConfig }\n >;\n };\n if (Array.isArray(raw.reporters)) {\n for (const entry of raw.reporters) {\n if (\n typeof entry === \"object\" &&\n entry !== null &&\n entry.plugin === origin &&\n entry.config\n ) {\n return entry.config;\n }\n }\n }\n } catch {\n // ignore parse errors\n }\n return undefined;\n}\n\nfunction loadPackageConfig(rootDir: string): PackageConfig | undefined {\n const pkgPath = path.join(rootDir, \"package.json\");\n if (!fs.existsSync(pkgPath)) {\n return undefined;\n }\n try {\n return JSON.parse(fs.readFileSync(pkgPath, \"utf-8\")) as PackageConfig;\n } catch {\n return undefined;\n }\n}\n\nasync function main() {\n const { values } = parseArgs({\n options: {\n source: { type: \"string\", short: \"s\" },\n output: { type: \"string\", short: \"o\" },\n tsconfig: { type: \"string\", short: \"t\" },\n root: { type: \"string\", short: \"r\" },\n },\n strict: false,\n });\n\n const rootDir =\n typeof values.root === \"string\"\n ? path.resolve(process.cwd(), values.root)\n : process.cwd();\n\n const rcConfig = loadParcelRcConfig(rootDir);\n const pkgConfig = loadPackageConfig(rootDir);\n\n const source =\n (typeof values.source === \"string\" ? values.source : undefined) ??\n rcConfig?.source ??\n pkgConfig?.[origin]?.source;\n\n const output =\n (typeof values.output === \"string\" ? values.output : undefined) ??\n rcConfig?.output ??\n pkgConfig?.[origin]?.output;\n\n const tsconfig =\n (typeof values.tsconfig === \"string\" ? values.tsconfig : undefined) ??\n rcConfig?.tsconfig ??\n pkgConfig?.[origin]?.tsconfig;\n\n if (!source) {\n throw new Error(\n `No \"${origin}\" source found in .parcelrc or package.json.`\n );\n }\n\n await generateProps(\n source,\n rootDir,\n output || \"docgen\",\n (...args) => console.info(args.join(\" \")),\n tsconfig\n );\n}\n\nmain().catch((error: unknown) => {\n console.error(error instanceof Error ? error.message : String(error));\n process.exit(1);\n});\n"],"mappings":";;;;;;AAMA,MAAM,SAAS;AAYf,SAAS,mBAAmB,SAAiD;CAC3E,MAAM,eAAe,KAAK,KAAK,SAAS,WAAW;CACnD,IAAI,CAACA,OAAG,WAAW,YAAY,GAC7B;CAEF,IAAI;EACF,MAAM,MAAM,KAAK,MAAMA,OAAG,aAAa,cAAc,OAAO,CAAC;EAK7D,IAAI,MAAM,QAAQ,IAAI,SAAS,GACxB;QAAA,MAAM,SAAS,IAAI,WACtB,IACE,OAAO,UAAU,YACjB,UAAU,QACV,MAAM,WAAW,UACjB,MAAM,QAEN,OAAO,MAAM;EAAA;CAIrB,SAAA,SAAQ,CAER;AAEF;AAEA,SAAS,kBAAkB,SAA4C;CACrE,MAAM,UAAU,KAAK,KAAK,SAAS,cAAc;CACjD,IAAI,CAACA,OAAG,WAAW,OAAO,GACxB;CAEF,IAAI;EACF,OAAO,KAAK,MAAMA,OAAG,aAAa,SAAS,OAAO,CAAC;CACrD,SAAA,UAAQ;EACN;CACF;AACF;AAEA,eAAe,OAAO;;CACpB,MAAM,EAAE,WAAW,UAAU;EAC3B,SAAS;GACP,QAAQ;IAAE,MAAM;IAAU,OAAO;GAAI;GACrC,QAAQ;IAAE,MAAM;IAAU,OAAO;GAAI;GACrC,UAAU;IAAE,MAAM;IAAU,OAAO;GAAI;GACvC,MAAM;IAAE,MAAM;IAAU,OAAO;GAAI;EACrC;EACA,QAAQ;CACV,CAAC;CAED,MAAM,UACJ,OAAO,OAAO,SAAS,WACnB,KAAK,QAAQ,QAAQ,IAAI,GAAG,OAAO,IAAI,IACvC,QAAQ,IAAI;CAElB,MAAM,WAAW,mBAAmB,OAAO;CAC3C,MAAM,YAAY,kBAAkB,OAAO;CAE3C,MAAM,UAAA,QAA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agesPattern: string, rootDir: string, outputPath?: string, log?: (...args: unknown[]) => void, customTsconfigPath?: string): Promise<void>;
4
+ //#endregion
5
+ export type { ExpandedPropType };
6
+ //# sourceMappingURL=generate-props.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-props.d.mts","names":[],"sources":["../../src/generate-props.ts"],"mappings":";;wBAuDsB,cACpB,sBACA,iBACA,qBACA,UAAS,0BACT,8BAA2B"}
@@ -1,13 +1,26 @@
1
- import path from "path";
2
- import { fileURLToPath } from "url";
1
+ import { compareStrings, expandPropType, resolveComponentPropTypes, splitTopLevelUnion, stripTopLevelUndefined } from "./type-expander.mjs";
2
+ import fsSync from "fs";
3
3
  import fs from "fs/promises";
4
- import { withCustomConfig } from "react-docgen-typescript";
4
+ import path from "path";
5
+ import { withCompilerOptions } from "react-docgen-typescript";
5
6
  import { glob } from "tinyglobby";
6
7
  import ts from "typescript";
8
+ import { fileURLToPath } from "url";
7
9
  //#region src/generate-props.ts
8
10
  const __filename = fileURLToPath(import.meta.url);
9
11
  path.dirname(__filename);
10
12
  const fileMtimeCache = /* @__PURE__ */ new Map();
13
+ function loadCompilerOptions(tsconfigPath) {
14
+ const basePath = path.dirname(tsconfigPath);
15
+ const { config, error } = ts.readConfigFile(tsconfigPath, (filename) => fsSync.readFileSync(filename, "utf8"));
16
+ if (error !== void 0) throw new Error(`Cannot load custom tsconfig.json from provided path: ${tsconfigPath}, with error code: ${error.code}, message: ${ts.flattenDiagnosticMessageText(error.messageText, "\n")}`);
17
+ const parsed = ts.parseJsonConfigFileContent(config, ts.sys, basePath, {}, tsconfigPath);
18
+ if (parsed.errors && parsed.errors.length > 0) {
19
+ const first = parsed.errors[0];
20
+ throw new Error(`TS${first.code}: ${ts.flattenDiagnosticMessageText(first.messageText, "\n")}`);
21
+ }
22
+ return parsed.options;
23
+ }
11
24
  async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log = console.log, customTsconfigPath) {
12
25
  const files = (await glob(pagesPattern, { cwd: rootDir })).sort(compareStrings);
13
26
  if (files.length === 0) {
@@ -43,11 +56,12 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
43
56
  }
44
57
  if (filesToProcess.length === 0) return;
45
58
  log(`Found ${filesToProcess.length} changed file(s) for pattern: ${pagesPattern}`);
46
- const resolvedTsconfigPath = customTsconfigPath ? path.resolve(rootDir, customTsconfigPath) : path.resolve(rootDir, "./tsconfig.json");
47
- const docgenParser = withCustomConfig(resolvedTsconfigPath, {
59
+ const compilerOptions = loadCompilerOptions(customTsconfigPath ? path.resolve(rootDir, customTsconfigPath) : path.resolve(rootDir, "./tsconfig.json"));
60
+ const docgenParser = withCompilerOptions(compilerOptions, {
48
61
  shouldExtractLiteralValuesFromEnum: true,
49
62
  shouldSortUnions: true,
50
63
  savePropValueAsString: true,
64
+ shouldIncludeExpression: true,
51
65
  propFilter: (prop) => {
52
66
  if (Array.isArray(prop.declarations) && prop.declarations[0]) {
53
67
  if (prop.declarations[0].fileName.includes("node_modules/@types/react")) {
@@ -59,7 +73,20 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
59
73
  });
60
74
  try {
61
75
  const absPaths = filesToProcess.map((f) => f.absPath);
62
- const allDocs = docgenParser.parse(absPaths);
76
+ const program = ts.createProgram(absPaths, compilerOptions);
77
+ const checker = program.getTypeChecker();
78
+ const allDocs = docgenParser.parseWithProgramProvider(absPaths, () => program);
79
+ const propTypesByDoc = /* @__PURE__ */ new WeakMap();
80
+ const getPropTypesForDoc = (doc) => {
81
+ if (!doc) return void 0;
82
+ let cached = propTypesByDoc.get(doc);
83
+ if (!cached) {
84
+ var _doc$expression;
85
+ cached = resolveComponentPropTypes((_doc$expression = doc.expression) !== null && _doc$expression !== void 0 ? _doc$expression : doc.rootExpression, checker);
86
+ propTypesByDoc.set(doc, cached);
87
+ }
88
+ return cached;
89
+ };
63
90
  const docsByFilePath = /* @__PURE__ */ new Map();
64
91
  for (const doc of allDocs) if (doc.filePath) {
65
92
  const key = path.resolve(doc.filePath);
@@ -75,11 +102,15 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
75
102
  let primaryDoc = fileDocs.find((d) => d.displayName === componentName) || (assignedInfo.baseIdentifier ? fileDocs.find((d) => d.displayName === assignedInfo.baseIdentifier) : void 0);
76
103
  if (primaryDoc) usedDocs.add(primaryDoc);
77
104
  let primaryProps = primaryDoc ? primaryDoc.props : {};
105
+ let primaryPropsDoc = primaryDoc;
78
106
  if (assignedInfo.baseIdentifier) {
79
107
  const baseDoc = fileDocs.find((d) => d.displayName === assignedInfo.baseIdentifier);
80
108
  if (baseDoc) {
81
109
  if (assignedInfo.baseIdentifier !== assignedInfo.subcomponentsMap.get("Root")) usedDocs.add(baseDoc);
82
- if (primaryDoc && Object.keys(baseDoc.props).length > Object.keys(primaryProps).length) primaryProps = baseDoc.props;
110
+ if (primaryDoc && Object.keys(baseDoc.props).length > Object.keys(primaryProps).length) {
111
+ primaryProps = baseDoc.props;
112
+ primaryPropsDoc = baseDoc;
113
+ }
83
114
  }
84
115
  }
85
116
  const subcomponents = {};
@@ -91,7 +122,7 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
91
122
  subcomponents[subName] = {
92
123
  name: `${componentName}.${subName}`,
93
124
  description: subDoc.description || void 0,
94
- props: formatProps(subDoc.props)
125
+ props: formatProps(subDoc.props, getPropTypesForDoc(subDoc), checker)
95
126
  };
96
127
  }
97
128
  }
@@ -109,7 +140,7 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
109
140
  subcomponents[subName] = {
110
141
  name: `${componentName}.${subName}`,
111
142
  description: doc.description || void 0,
112
- props: formatProps(doc.props)
143
+ props: formatProps(doc.props, getPropTypesForDoc(doc), checker)
113
144
  };
114
145
  }
115
146
  }
@@ -118,8 +149,9 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
118
149
  else if (!primaryDoc) {
119
150
  primaryDoc = fileDocs.find((d) => Object.keys(d.props).length > 0) || fileDocs[0];
120
151
  primaryProps = primaryDoc ? primaryDoc.props : {};
152
+ primaryPropsDoc = primaryDoc;
121
153
  }
122
- const formattedPrimaryProps = promotedRoot ? promotedRoot.props : formatProps(primaryProps);
154
+ const formattedPrimaryProps = promotedRoot ? promotedRoot.props : formatProps(primaryProps, getPropTypesForDoc(primaryPropsDoc), checker);
123
155
  const componentJSON = JSON.stringify({
124
156
  name: promotedRoot ? promotedRoot.name : componentName,
125
157
  description: (promotedRoot ? promotedRoot.description : primaryDoc === null || primaryDoc === void 0 ? void 0 : primaryDoc.description) || void 0,
@@ -136,7 +168,7 @@ async function generateProps(pagesPattern, rootDir, outputPath = "docgen", log =
136
168
  log(`Error generating props: ${err.message}`);
137
169
  }
138
170
  }
139
- function getShortPropType(name, type) {
171
+ function getShortPropType(name, type, expanded) {
140
172
  if (/^(on|get)[A-Z].*/.test(name)) return {
141
173
  type: "function",
142
174
  detailedType: true
@@ -153,7 +185,16 @@ function getShortPropType(name, type) {
153
185
  type: "ReactElement | function",
154
186
  detailedType: true
155
187
  };
156
- if (name.endsWith("Ref") || name === "children" || type === "boolean" || type === "string" || type === "number" || type.indexOf(" | ") === -1 || type.split("|").length < 3 && type.length < 30) return {
188
+ if ((expanded === null || expanded === void 0 ? void 0 : expanded.kind) === "mapped-union") {
189
+ var _expanded$alias;
190
+ return {
191
+ type: (_expanded$alias = expanded.alias) !== null && _expanded$alias !== void 0 ? _expanded$alias : "Union",
192
+ detailedType: true
193
+ };
194
+ }
195
+ const cleanType = stripTopLevelUndefined(type);
196
+ const topLevelParts = splitTopLevelUnion(cleanType);
197
+ if (name.endsWith("Ref") || name === "children" || cleanType === "boolean" || cleanType === "string" || cleanType === "number" || topLevelParts.length <= 1 || topLevelParts.length < 3 && cleanType.length < 30) return {
157
198
  type,
158
199
  detailedType: false
159
200
  };
@@ -162,11 +203,7 @@ function getShortPropType(name, type) {
162
203
  detailedType: true
163
204
  };
164
205
  }
165
- function compareStrings(a, b) {
166
- return a < b ? -1 : a > b ? 1 : 0;
167
- }
168
- function sortUnionString(str) {
169
- if (!str.includes("|")) return str;
206
+ function splitTopLevelCommas(str) {
170
207
  const parts = [];
171
208
  let current = "";
172
209
  let depthParen = 0;
@@ -181,7 +218,7 @@ function sortUnionString(str) {
181
218
  if (ch === inQuote && str[i - 1] !== "\\") inQuote = null;
182
219
  continue;
183
220
  }
184
- if (ch === "\"" || ch === "'") {
221
+ if (ch === "\"" || ch === "'" || ch === "`") {
185
222
  inQuote = ch;
186
223
  current += ch;
187
224
  continue;
@@ -194,13 +231,28 @@ function sortUnionString(str) {
194
231
  else if (ch === "}") depthBrace = Math.max(0, depthBrace - 1);
195
232
  else if (ch === "[") depthBracket++;
196
233
  else if (ch === "]") depthBracket = Math.max(0, depthBracket - 1);
197
- if (ch === "|" && depthParen === 0 && depthAngle === 0 && depthBrace === 0 && depthBracket === 0) {
234
+ if (ch === "," && depthParen === 0 && depthAngle === 0 && depthBrace === 0 && depthBracket === 0) {
198
235
  parts.push(current.trim());
199
236
  current = "";
200
237
  } else current += ch;
201
238
  }
202
239
  parts.push(current.trim());
203
- if (parts.length <= 1) return str;
240
+ return parts;
241
+ }
242
+ function sortGenericTypeArgs(str) {
243
+ const openIdx = str.indexOf("<");
244
+ if (openIdx === -1 || !str.endsWith(">")) return str;
245
+ const prefix = str.slice(0, openIdx);
246
+ if (!/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(prefix)) return str;
247
+ return `${prefix}<${splitTopLevelCommas(str.slice(openIdx + 1, -1)).map((arg) => sortUnionString(arg)).join(", ")}>`;
248
+ }
249
+ function sortUnionString(str) {
250
+ if (!str.includes("|")) return str;
251
+ const parts = splitTopLevelUnion(str).map((part) => sortGenericTypeArgs(part));
252
+ if (parts.length <= 1) {
253
+ var _parts$;
254
+ return (_parts$ = parts[0]) !== null && _parts$ !== void 0 ? _parts$ : str;
255
+ }
204
256
  parts.sort((a, b) => {
205
257
  if (a === "undefined" && b !== "undefined") return 1;
206
258
  if (b === "undefined" && a !== "undefined") return -1;
@@ -208,20 +260,29 @@ function sortUnionString(str) {
208
260
  });
209
261
  return parts.join(" | ");
210
262
  }
211
- function formatProps(rawProps) {
263
+ function formatProps(rawProps, propTypes, checker) {
212
264
  const props = {};
213
265
  const sortedPropNames = Object.keys(rawProps).sort(compareStrings);
214
266
  for (const propName of sortedPropNames) {
215
267
  const rawProp = rawProps[propName];
216
268
  if (!rawProp) continue;
217
- const prop = { ...rawProp };
269
+ const prop = {
270
+ ...rawProp,
271
+ type: { ...rawProp.type },
272
+ shortPropTypeName: null
273
+ };
218
274
  if (prop.type && prop.type.name) {
219
- prop.type = { ...prop.type };
275
+ var _prop$type$raw;
220
276
  if (typeof prop.type.raw === "string") prop.type.raw = sortUnionString(prop.type.raw);
221
277
  const sortedTypeName = sortUnionString(prop.type.name);
222
- const { type: shortPropTypeName, detailedType } = getShortPropType(propName, sortedTypeName);
278
+ const resolved = propTypes === null || propTypes === void 0 ? void 0 : propTypes.get(propName);
279
+ const expanded = resolved && checker ? expandPropType(resolved.type, (_prop$type$raw = prop.type.raw) !== null && _prop$type$raw !== void 0 ? _prop$type$raw : sortedTypeName, prop.type.name === "enum", checker, resolved.locationNode) : void 0;
280
+ if (expanded) prop.type.expanded = expanded;
281
+ const { type: shortPropTypeName, detailedType } = getShortPropType(propName, sortedTypeName, expanded);
223
282
  const hasExpandedType = Boolean(detailedType);
224
- prop.type.name = hasExpandedType && sortedTypeName.split("|").length > 3 ? sortedTypeName.split("|").map((line) => `| ${line}\n`).join("") : sortedTypeName;
283
+ const topLevelParts = splitTopLevelUnion(sortedTypeName);
284
+ const nonUndefTopLevelCount = topLevelParts.filter((part) => part !== "undefined").length;
285
+ prop.type.name = hasExpandedType && nonUndefTopLevelCount > 3 ? topLevelParts.map((line) => `| ${line}\n`).join("") : sortedTypeName;
225
286
  prop.shortPropTypeName = hasExpandedType ? shortPropTypeName : null;
226
287
  }
227
288
  props[propName] = prop;
@@ -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 = (\n await glob(pagesPattern, {\n cwd: rootDir,\n })\n ).sort(compareStrings);\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 shouldSortUnions: 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 compareStrings(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\nfunction sortUnionString(str: string): string {\n if (!str.includes(\"|\")) {\n return str;\n }\n\n const parts: string[] = [];\n let current = \"\";\n let depthParen = 0;\n let depthAngle = 0;\n let depthBrace = 0;\n let depthBracket = 0;\n let inQuote: string | null = null;\n\n for (let i = 0; i < str.length; i++) {\n const ch = str[i]!;\n if (inQuote) {\n current += ch;\n if (ch === inQuote && str[i - 1] !== \"\\\\\") {\n inQuote = null;\n }\n continue;\n }\n\n if (ch === '\"' || ch === \"'\") {\n inQuote = ch;\n current += ch;\n continue;\n }\n\n if (ch === \"(\") depthParen++;\n else if (ch === \")\") depthParen = Math.max(0, depthParen - 1);\n else if (ch === \"<\") depthAngle++;\n else if (ch === \">\" && str[i - 1] !== \"=\")\n depthAngle = Math.max(0, depthAngle - 1);\n else if (ch === \"{\") depthBrace++;\n else if (ch === \"}\") depthBrace = Math.max(0, depthBrace - 1);\n else if (ch === \"[\") depthBracket++;\n else if (ch === \"]\") depthBracket = Math.max(0, depthBracket - 1);\n\n if (\n ch === \"|\" &&\n depthParen === 0 &&\n depthAngle === 0 &&\n depthBrace === 0 &&\n depthBracket === 0\n ) {\n parts.push(current.trim());\n current = \"\";\n } else {\n current += ch;\n }\n }\n\n parts.push(current.trim());\n\n if (parts.length <= 1) {\n return str;\n }\n\n parts.sort((a, b) => {\n if (a === \"undefined\" && b !== \"undefined\") return 1;\n if (b === \"undefined\" && a !== \"undefined\") return -1;\n return compareStrings(a, b);\n });\n\n return parts.join(\" | \");\n}\n\nfunction formatProps(rawProps: Record<string, PropItem>) {\n const props: Record<\n string,\n PropItem & {\n shortPropTypeName: string | null;\n }\n > = {};\n\n const sortedPropNames = Object.keys(rawProps).sort(compareStrings);\n\n for (const propName of sortedPropNames) {\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 prop.type = { ...prop.type };\n\n if (typeof prop.type.raw === \"string\") {\n prop.type.raw = sortUnionString(prop.type.raw);\n }\n\n const sortedTypeName = sortUnionString(prop.type.name);\n const { type: shortPropTypeName, detailedType } = getShortPropType(\n propName,\n sortedTypeName\n );\n\n const hasExpandedType = Boolean(detailedType);\n\n prop.type.name =\n hasExpandedType && sortedTypeName.split(\"|\").length > 3\n ? sortedTypeName\n .split(\"|\")\n .map((line) => `| ${line}\\n`)\n .join(\"\")\n : sortedTypeName;\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,SACJ,MAAM,KAAK,cAAc,EACvB,KAAK,QACP,CAAC,EAAA,CACD,KAAK,cAAc;CAErB,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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IACE,IAAI,cAAc,SAAS,GAAG,WAAW,eACzC,GAAG,2BAA2B,IAAI,IAAI,GACtC;IACA,MAAM,UAAU,IAAI,KAAK,WAAW,QAAQ,UAAU;IACtD,MAAM,WAAW,IAAI,KAAK,KAAK,QAAQ,UAAU;IACjD,IAAI,YAAY,YAAY,SAAS,KAAK,QAAQ,GAAG;KACnD,MAAM,aAAa,IAAI,MAAM,QAAQ,UAAU;KAC/C,iBAAiB,IAAI,UAAU,UAAU;IAC3C;GACF;EACF;CACF,CAAC;CAED,OAAO;EAAE;EAAgB;CAAiB;AAC5C"}
1
+ {"version":3,"file":"generate-props.mjs","names":[],"sources":["../../src/generate-props.ts"],"sourcesContent":["import fsSync from \"fs\";\nimport fs from \"fs/promises\";\nimport path from \"path\";\nimport {\n type ComponentDoc,\n type PropItem,\n withCompilerOptions,\n} from \"react-docgen-typescript\";\nimport { glob } from \"tinyglobby\";\nimport ts from \"typescript\";\nimport { fileURLToPath } from \"url\";\nimport {\n compareStrings,\n expandPropType,\n resolveComponentPropTypes,\n splitTopLevelUnion,\n stripTopLevelUndefined,\n type ExpandedPropType,\n} from \"./type-expander.js\";\n\nexport type { ExpandedPropType };\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\nfunction loadCompilerOptions(tsconfigPath: string): ts.CompilerOptions {\n const basePath = path.dirname(tsconfigPath);\n const { config, error } = ts.readConfigFile(tsconfigPath, (filename) =>\n fsSync.readFileSync(filename, \"utf8\")\n );\n if (error !== undefined) {\n throw new Error(\n `Cannot load custom tsconfig.json from provided path: ${tsconfigPath}, with error code: ${error.code}, message: ${ts.flattenDiagnosticMessageText(error.messageText, \"\\n\")}`\n );\n }\n\n const parsed = ts.parseJsonConfigFileContent(\n config,\n ts.sys,\n basePath,\n {},\n tsconfigPath\n );\n if (parsed.errors && parsed.errors.length > 0) {\n const first = parsed.errors[0]!;\n throw new Error(\n `TS${first.code}: ${ts.flattenDiagnosticMessageText(first.messageText, \"\\n\")}`\n );\n }\n return parsed.options;\n}\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 = (\n await glob(pagesPattern, {\n cwd: rootDir,\n })\n ).sort(compareStrings);\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 compilerOptions = loadCompilerOptions(resolvedTsconfigPath);\n const docgenParser = withCompilerOptions(compilerOptions, {\n shouldExtractLiteralValuesFromEnum: true,\n shouldSortUnions: true,\n savePropValueAsString: true,\n shouldIncludeExpression: 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 program = ts.createProgram(absPaths, compilerOptions);\n const checker = program.getTypeChecker();\n const allDocs = docgenParser.parseWithProgramProvider(\n absPaths,\n () => program\n );\n\n const propTypesByDoc = new WeakMap<\n ComponentDoc,\n Map<string, { type: ts.Type; locationNode?: ts.Node }>\n >();\n const getPropTypesForDoc = (doc: ComponentDoc | undefined) => {\n if (!doc) return undefined;\n let cached = propTypesByDoc.get(doc);\n if (!cached) {\n cached = resolveComponentPropTypes(\n doc.expression ?? doc.rootExpression,\n checker\n );\n propTypesByDoc.set(doc, cached);\n }\n return cached;\n };\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 let primaryPropsDoc: ComponentDoc | undefined = primaryDoc;\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 primaryPropsDoc = baseDoc;\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(\n subDoc.props,\n getPropTypesForDoc(subDoc),\n checker\n ),\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, getPropTypesForDoc(doc), checker),\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 primaryPropsDoc = primaryDoc;\n }\n\n const formattedPrimaryProps = promotedRoot\n ? promotedRoot.props\n : formatProps(\n primaryProps,\n getPropTypesForDoc(primaryPropsDoc),\n checker\n );\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(\n name: string,\n type: string,\n expanded?: ExpandedPropType\n) {\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 (expanded?.kind === \"mapped-union\") {\n return {\n type: expanded.alias ?? \"Union\",\n detailedType: true,\n };\n }\n\n const cleanType = stripTopLevelUndefined(type);\n const topLevelParts = splitTopLevelUnion(cleanType);\n\n if (\n name.endsWith(\"Ref\") ||\n name === \"children\" ||\n cleanType === \"boolean\" ||\n cleanType === \"string\" ||\n cleanType === \"number\" ||\n topLevelParts.length <= 1 ||\n (topLevelParts.length < 3 && cleanType.length < 30)\n ) {\n return { type, detailedType: false };\n }\n\n return { type: \"Union\", detailedType: true };\n}\n\nfunction splitTopLevelCommas(str: string): string[] {\n const parts: string[] = [];\n let current = \"\";\n let depthParen = 0;\n let depthAngle = 0;\n let depthBrace = 0;\n let depthBracket = 0;\n let inQuote: string | null = null;\n\n for (let i = 0; i < str.length; i++) {\n const ch = str[i]!;\n if (inQuote) {\n current += ch;\n if (ch === inQuote && str[i - 1] !== \"\\\\\") {\n inQuote = null;\n }\n continue;\n }\n\n if (ch === '\"' || ch === \"'\" || ch === \"`\") {\n inQuote = ch;\n current += ch;\n continue;\n }\n\n if (ch === \"(\") depthParen++;\n else if (ch === \")\") depthParen = Math.max(0, depthParen - 1);\n else if (ch === \"<\") depthAngle++;\n else if (ch === \">\" && str[i - 1] !== \"=\")\n depthAngle = Math.max(0, depthAngle - 1);\n else if (ch === \"{\") depthBrace++;\n else if (ch === \"}\") depthBrace = Math.max(0, depthBrace - 1);\n else if (ch === \"[\") depthBracket++;\n else if (ch === \"]\") depthBracket = Math.max(0, depthBracket - 1);\n\n if (\n ch === \",\" &&\n depthParen === 0 &&\n depthAngle === 0 &&\n depthBrace === 0 &&\n depthBracket === 0\n ) {\n parts.push(current.trim());\n current = \"\";\n } else {\n current += ch;\n }\n }\n\n parts.push(current.trim());\n return parts;\n}\n\nfunction sortGenericTypeArgs(str: string): string {\n const openIdx = str.indexOf(\"<\");\n if (openIdx === -1 || !str.endsWith(\">\")) {\n return str;\n }\n\n const prefix = str.slice(0, openIdx);\n if (!/^[A-Za-z_$][A-Za-z0-9_$.]*$/.test(prefix)) {\n return str;\n }\n\n const inner = str.slice(openIdx + 1, -1);\n const args = splitTopLevelCommas(inner).map((arg) => sortUnionString(arg));\n return `${prefix}<${args.join(\", \")}>`;\n}\n\nfunction sortUnionString(str: string): string {\n if (!str.includes(\"|\")) {\n return str;\n }\n\n const parts = splitTopLevelUnion(str).map((part) =>\n sortGenericTypeArgs(part)\n );\n\n if (parts.length <= 1) {\n return parts[0] ?? str;\n }\n\n parts.sort((a, b) => {\n if (a === \"undefined\" && b !== \"undefined\") return 1;\n if (b === \"undefined\" && a !== \"undefined\") return -1;\n return compareStrings(a, b);\n });\n\n return parts.join(\" | \");\n}\n\ntype FormattedPropItem = PropItem & {\n type: PropItem[\"type\"] & {\n expanded?: ExpandedPropType;\n };\n shortPropTypeName: string | null;\n};\n\nfunction formatProps(\n rawProps: Record<string, PropItem>,\n propTypes?: Map<string, { type: ts.Type; locationNode?: ts.Node }>,\n checker?: ts.TypeChecker\n) {\n const props: Record<string, FormattedPropItem> = {};\n\n const sortedPropNames = Object.keys(rawProps).sort(compareStrings);\n\n for (const propName of sortedPropNames) {\n const rawProp = rawProps[propName];\n if (!rawProp) {\n continue;\n }\n\n const prop: FormattedPropItem = {\n ...rawProp,\n type: { ...rawProp.type },\n shortPropTypeName: null,\n };\n\n if (prop.type && prop.type.name) {\n if (typeof prop.type.raw === \"string\") {\n prop.type.raw = sortUnionString(prop.type.raw);\n }\n\n const sortedTypeName = sortUnionString(prop.type.name);\n\n const resolved = propTypes?.get(propName);\n const expanded =\n resolved && checker\n ? expandPropType(\n resolved.type,\n prop.type.raw ?? sortedTypeName,\n prop.type.name === \"enum\",\n checker,\n resolved.locationNode\n )\n : undefined;\n\n if (expanded) {\n prop.type.expanded = expanded;\n }\n\n const { type: shortPropTypeName, detailedType } = getShortPropType(\n propName,\n sortedTypeName,\n expanded\n );\n\n const hasExpandedType = Boolean(detailedType);\n const topLevelParts = splitTopLevelUnion(sortedTypeName);\n const nonUndefTopLevelCount = topLevelParts.filter(\n (part) => part !== \"undefined\"\n ).length;\n\n prop.type.name =\n hasExpandedType && nonUndefTopLevelCount > 3\n ? topLevelParts.map((line) => `| ${line}\\n`).join(\"\")\n : sortedTypeName;\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":";;;;;;;;;AAsBA,MAAM,aAAa,cAAc,YAAY,GAAG;AAC9B,KAAK,QAAQ,UAAU;AAGzC,MAAM,iCAAiB,IAAI,IAAoB;AAE/C,SAAS,oBAAoB,cAA0C;CACrE,MAAM,WAAW,KAAK,QAAQ,YAAY;CAC1C,MAAM,EAAE,QAAQ,UAAU,GAAG,eAAe,eAAe,aACzD,OAAO,aAAa,UAAU,MAAM,CACtC;CACA,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MACR,wDAAwD,aAAa,qBAAqB,MAAM,KAAK,aAAa,GAAG,6BAA6B,MAAM,aAAa,IAAI,GAC3K;CAGF,MAAM,SAAS,GAAG,2BAChB,QACA,GAAG,KACH,UACA,CAAC,GACD,YACF;CACA,IAAI,OAAO,UAAU,OAAO,OAAO,SAAS,GAAG;EAC7C,MAAM,QAAQ,O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;CAAiB;AAC5C"}
@@ -1,6 +1,3 @@
1
- import { Reporter } from "@parcel/plugin";
2
- //#region src/index.d.ts
3
- declare const _default: Reporter;
4
- //#endregion
5
- export { _default as default };
6
- //# sourceMappingURL=index.d.mts.map
1
+ import { ExpandedPropType } from "./type-expander.mjs";
2
+ import { generateProps } from "./generate-props.mjs";
3
+ export { type ExpandedPropType, generateProps };
@@ -1,71 +1,2 @@
1
1
  import { generateProps } from "./generate-props.mjs";
2
- import { name } from "./package.mjs";
3
- import ThrowableDiagnostic from "@parcel/diagnostic";
4
- import { Reporter } from "@parcel/plugin";
5
- import path from "path";
6
- import { pathToFileURL } from "url";
7
- import dedent from "dedent";
8
- //#region src/index.ts
9
- const origin = name;
10
- var src_default = new Reporter({ async report({ event, options, logger }) {
11
- if (event.type === "buildStart") {
12
- try {
13
- var _config$origin, _config$origin2, _config$origin3;
14
- const projectPackageJSON = path.join(options.projectRoot, "package.json");
15
- const config = await import(pathToFileURL(projectPackageJSON).toString(), { with: { type: "json" } }).then((mod) => mod.default);
16
- const source = (_config$origin = config[origin]) === null || _config$origin === void 0 ? void 0 : _config$origin.source;
17
- const output = (_config$origin2 = config[origin]) === null || _config$origin2 === void 0 ? void 0 : _config$origin2.output;
18
- const tsconfig = (_config$origin3 = config[origin]) === null || _config$origin3 === void 0 ? void 0 : _config$origin3.tsconfig;
19
- if (!source) throw new ThrowableDiagnostic({ diagnostic: {
20
- origin,
21
- message: dedent`No "@renr/parcel-reporter-docgen" source found in package.json.
22
- NOTE: if you are using a monorepo, you need to run parcel from the package that contains your pages rather than the project root.
23
- See https://github.com/parcel-bundler/parcel/issues/7206 for a workaround.`,
24
- hints: ["Add a \"@renr/parcel-reporter-docgen\" source to your package.json with a source e.g `../packages/ui/src/**/*.{ts,tsx}`."],
25
- codeFrames: [{
26
- codeHighlights: [{
27
- start: {
28
- line: 3,
29
- column: 2
30
- },
31
- end: {
32
- line: 7,
33
- column: 44
34
- },
35
- message: "Add a \"@renr/parcel-reporter-docgen\" source to generate docs for your UI components."
36
- }],
37
- language: "json",
38
- filePath: projectPackageJSON,
39
- code: dedent`{
40
- "@renr/parcel-reporter-docgen": {
41
- "source": "../packages/ui/src/**/*.{ts,tsx}",
42
- "output": "docs/components"
43
- }
44
- } `
45
- }]
46
- } });
47
- try {
48
- await generateProps(source, options.projectRoot, output || "docgen", (...args) => logger.info({
49
- origin,
50
- message: args.join(" ")
51
- }), tsconfig);
52
- } catch (error) {
53
- throwError(error);
54
- }
55
- } catch (error) {
56
- throwError(error);
57
- }
58
- return;
59
- }
60
- } });
61
- function throwError(error) {
62
- throw new ThrowableDiagnostic({ diagnostic: {
63
- origin,
64
- message: error.message,
65
- stack: error.stack
66
- } });
67
- }
68
- //#endregion
69
- export { src_default as default };
70
-
71
- //# sourceMappingURL=index.mjs.map
2
+ export { generateProps };
@@ -0,0 +1,15 @@
1
+ import ts from "typescript";
2
+ //#region src/type-expander.d.ts
3
+ export type ExpandedPropType = {
4
+ kind: "mapped-union";
5
+ alias?: string;
6
+ values?: string[];
7
+ valueType: string;
8
+ keys: string[];
9
+ formatted: string;
10
+ } | {
11
+ kind: "alias" | "object" | "union" | "function";
12
+ formatted: string;
13
+ };
14
+ //#endregion
15
+ //# sourceMappingURL=type-expander.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-expander.d.mts","names":[],"sources":["../../src/type-expander.ts"],"mappings":";;YAEY;EAEN;EACA;EACA;EACA;EACA;EACA;;EAGA;EACA"}
@@ -0,0 +1,443 @@
1
+ import ts from "typescript";
2
+ //#region src/type-expander.ts
3
+ const STOP_TYPE_NAMES = /* @__PURE__ */ new Set([
4
+ "ReactNode",
5
+ "ReactElement",
6
+ "ReactPortal",
7
+ "ReactFragment",
8
+ "Element",
9
+ "JSX.Element",
10
+ "CSSProperties",
11
+ "ElementType",
12
+ "ComponentType",
13
+ "ComponentProps",
14
+ "ComponentPropsWithRef",
15
+ "ComponentPropsWithoutRef",
16
+ "Ref",
17
+ "RefObject",
18
+ "MutableRefObject",
19
+ "ForwardedRef",
20
+ "LegacyRef",
21
+ "HTMLAttributes",
22
+ "SVGAttributes",
23
+ "DOMAttributes",
24
+ "SyntheticEvent",
25
+ "MouseEvent",
26
+ "KeyboardEvent",
27
+ "FocusEvent",
28
+ "ChangeEvent",
29
+ "PointerEvent",
30
+ "TouchEvent",
31
+ "UIEvent",
32
+ "Event",
33
+ "Date",
34
+ "RegExp",
35
+ "Promise",
36
+ "Map",
37
+ "Set",
38
+ "WeakMap",
39
+ "WeakSet",
40
+ "URL",
41
+ "File",
42
+ "Blob",
43
+ "FormData",
44
+ "Error"
45
+ ]);
46
+ const UTILITY_ALIAS_NAMES = /* @__PURE__ */ new Set([
47
+ "Partial",
48
+ "Required",
49
+ "Readonly",
50
+ "Record",
51
+ "Pick",
52
+ "Omit",
53
+ "NonNullable",
54
+ "Exclude",
55
+ "Extract"
56
+ ]);
57
+ const VALID_IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
58
+ const MAX_MAPPED_KEYS = 24;
59
+ const MAX_OBJECT_PROPS = 14;
60
+ const MAX_EXPAND_DEPTH = 2;
61
+ function compareStrings(a, b) {
62
+ return a < b ? -1 : a > b ? 1 : 0;
63
+ }
64
+ /**
65
+ * Splits a TypeScript type string on top-level `|` operators only,
66
+ * preserving `|` inside `<...>`, `{...}`, `(...)`, `[...]`, and string literals.
67
+ */
68
+ function splitTopLevelUnion(str) {
69
+ if (!str.includes("|")) return [str.trim()];
70
+ const parts = [];
71
+ let current = "";
72
+ let depthParen = 0;
73
+ let depthAngle = 0;
74
+ let depthBrace = 0;
75
+ let depthBracket = 0;
76
+ let inQuote = null;
77
+ for (let i = 0; i < str.length; i++) {
78
+ const ch = str[i];
79
+ if (inQuote) {
80
+ current += ch;
81
+ if (ch === inQuote && str[i - 1] !== "\\") inQuote = null;
82
+ continue;
83
+ }
84
+ if (ch === "\"" || ch === "'" || ch === "`") {
85
+ inQuote = ch;
86
+ current += ch;
87
+ continue;
88
+ }
89
+ if (ch === "(") depthParen++;
90
+ else if (ch === ")") depthParen = Math.max(0, depthParen - 1);
91
+ else if (ch === "<") depthAngle++;
92
+ else if (ch === ">" && str[i - 1] !== "=") depthAngle = Math.max(0, depthAngle - 1);
93
+ else if (ch === "{") depthBrace++;
94
+ else if (ch === "}") depthBrace = Math.max(0, depthBrace - 1);
95
+ else if (ch === "[") depthBracket++;
96
+ else if (ch === "]") depthBracket = Math.max(0, depthBracket - 1);
97
+ if (ch === "|" && depthParen === 0 && depthAngle === 0 && depthBrace === 0 && depthBracket === 0) {
98
+ parts.push(current.trim());
99
+ current = "";
100
+ } else current += ch;
101
+ }
102
+ parts.push(current.trim());
103
+ return parts.filter((part) => part.length > 0);
104
+ }
105
+ function stripTopLevelUndefined(str) {
106
+ return splitTopLevelUnion(str).filter((p) => p !== "undefined").join(" | ");
107
+ }
108
+ function sortUnionMembers(members) {
109
+ return [...members].sort((a, b) => {
110
+ if (a === "undefined" && b !== "undefined") return 1;
111
+ if (b === "undefined" && a !== "undefined") return -1;
112
+ if (a === "null" && b !== "null") return 1;
113
+ if (b === "null" && a !== "null") return -1;
114
+ return compareStrings(a, b);
115
+ });
116
+ }
117
+ function sortMappedKeys(keys) {
118
+ return [...keys].sort((a, b) => compareStrings(a.name, b.name));
119
+ }
120
+ function formatPropertyKey(name) {
121
+ return VALID_IDENTIFIER_RE.test(name) ? name : JSON.stringify(name);
122
+ }
123
+ function isDeclarationInExternalLibs(decl) {
124
+ if (!decl) return false;
125
+ const fileName = decl.getSourceFile().fileName.replace(/\\/g, "/");
126
+ return fileName.includes("/node_modules/@types/react/") || fileName.includes("/node_modules/typescript/lib/lib.");
127
+ }
128
+ function isPropertyInheritedFromExternalLibs(prop) {
129
+ const decls = prop.getDeclarations();
130
+ if (!decls || decls.length === 0) return false;
131
+ return decls.every((d) => isDeclarationInExternalLibs(d));
132
+ }
133
+ function getTypeDisplayName(type, checker) {
134
+ return checker.typeToString(type, void 0, ts.TypeFormatFlags.NoTruncation);
135
+ }
136
+ function isStopType(type, checker) {
137
+ var _type$aliasSymbol;
138
+ if (checker && (getArrayElementType(type, checker) || checker.isTupleType(type))) return false;
139
+ const aliasName = (_type$aliasSymbol = type.aliasSymbol) === null || _type$aliasSymbol === void 0 ? void 0 : _type$aliasSymbol.getName();
140
+ if (aliasName && STOP_TYPE_NAMES.has(aliasName)) return true;
141
+ const symbol = type.getSymbol();
142
+ if (symbol) {
143
+ var _symbol$valueDeclarat, _symbol$declarations;
144
+ const name = symbol.getName();
145
+ if (name === "Array" || name === "ReadonlyArray") return false;
146
+ if (STOP_TYPE_NAMES.has(name)) return true;
147
+ const decl = (_symbol$valueDeclarat = symbol.valueDeclaration) !== null && _symbol$valueDeclarat !== void 0 ? _symbol$valueDeclarat : (_symbol$declarations = symbol.declarations) === null || _symbol$declarations === void 0 ? void 0 : _symbol$declarations[0];
148
+ if (decl && isDeclarationInExternalLibs(decl) && !(aliasName && UTILITY_ALIAS_NAMES.has(aliasName)) && name !== "__type" && name !== "__object") return true;
149
+ }
150
+ return false;
151
+ }
152
+ function isPrimitiveOrIntrinsic(type) {
153
+ return Boolean(type.flags & (ts.TypeFlags.String | ts.TypeFlags.Number | ts.TypeFlags.Boolean | ts.TypeFlags.BigInt | ts.TypeFlags.ESSymbol | ts.TypeFlags.UniqueESSymbol | ts.TypeFlags.Void | ts.TypeFlags.Undefined | ts.TypeFlags.Null | ts.TypeFlags.Never | ts.TypeFlags.Any | ts.TypeFlags.Unknown | ts.TypeFlags.NonPrimitive));
154
+ }
155
+ function isLiteralType(type) {
156
+ return Boolean(type.flags & (ts.TypeFlags.StringLiteral | ts.TypeFlags.NumberLiteral | ts.TypeFlags.BigIntLiteral | ts.TypeFlags.EnumLiteral));
157
+ }
158
+ function isPlainAnonymousObject(type, checker) {
159
+ if (!(type.flags & ts.TypeFlags.Object)) return false;
160
+ if (checker.isArrayType(type) || checker.isTupleType(type)) return false;
161
+ if (type.getCallSignatures().length > 0) return false;
162
+ if (type.getConstructSignatures().length > 0) return false;
163
+ if (isStopType(type)) return false;
164
+ return true;
165
+ }
166
+ function isReadonlyArrayType(type) {
167
+ const symbol = type.getSymbol();
168
+ return (symbol === null || symbol === void 0 ? void 0 : symbol.getName()) === "ReadonlyArray";
169
+ }
170
+ function getArrayElementType(type, checker) {
171
+ if (isReadonlyArrayType(type)) {
172
+ const typeArgs = checker.getTypeArguments(type);
173
+ if (typeArgs[0]) return {
174
+ elementType: typeArgs[0],
175
+ readonly: true
176
+ };
177
+ }
178
+ if (checker.isArrayType(type)) {
179
+ const typeArgs = checker.getTypeArguments(type);
180
+ if (typeArgs[0]) return {
181
+ elementType: typeArgs[0],
182
+ readonly: false
183
+ };
184
+ }
185
+ return null;
186
+ }
187
+ /**
188
+ * Formats a list of union member types into canonical sorted strings,
189
+ * collapsing `false` + `true` boolean literals back into `boolean`.
190
+ */
191
+ function formatUnionMembersCanonical(types, checker, depth, seen) {
192
+ let hasTrue = false;
193
+ let hasFalse = false;
194
+ const rest = [];
195
+ for (const t of types) {
196
+ if (t.flags & ts.TypeFlags.Undefined) continue;
197
+ if (t.flags & ts.TypeFlags.BooleanLiteral) {
198
+ const str = checker.typeToString(t);
199
+ if (str === "true") hasTrue = true;
200
+ else if (str === "false") hasFalse = true;
201
+ else rest.push(t);
202
+ } else rest.push(t);
203
+ }
204
+ const formatted = [];
205
+ let allLiterals = true;
206
+ if (hasTrue && hasFalse) {
207
+ formatted.push("boolean");
208
+ allLiterals = false;
209
+ } else {
210
+ if (hasFalse) formatted.push("false");
211
+ if (hasTrue) formatted.push("true");
212
+ }
213
+ for (const t of rest) {
214
+ if (!isLiteralType(t)) allLiterals = false;
215
+ formatted.push(formatTypeNode(t, checker, depth, seen));
216
+ }
217
+ const unique = Array.from(new Set(formatted));
218
+ return {
219
+ members: sortUnionMembers(unique),
220
+ allLiterals: allLiterals && unique.length > 0
221
+ };
222
+ }
223
+ function getPropType(prop, checker, fallbackNode) {
224
+ var _ref, _prop$valueDeclaratio, _prop$declarations;
225
+ const decl = (_ref = (_prop$valueDeclaratio = prop.valueDeclaration) !== null && _prop$valueDeclaratio !== void 0 ? _prop$valueDeclaratio : (_prop$declarations = prop.declarations) === null || _prop$declarations === void 0 ? void 0 : _prop$declarations[0]) !== null && _ref !== void 0 ? _ref : fallbackNode;
226
+ if (decl) return checker.getTypeOfSymbolAtLocation(prop, decl);
227
+ return checker.getTypeOfSymbol(prop);
228
+ }
229
+ /**
230
+ * Detects the structural `Value | { [K in Keys]?: Value }` pattern
231
+ * (e.g. `ResponsiveValue<Value, BP>`), returning factored metadata without
232
+ * repeating `Value` for every key.
233
+ */
234
+ function detectMappedUnion(rawType, rawTypeName, checker, locationNode) {
235
+ var _rawType$aliasSymbol;
236
+ if (!rawType.isUnion()) return null;
237
+ const nonUndefined = rawType.types.filter((t) => !(t.flags & ts.TypeFlags.Undefined));
238
+ if (nonUndefined.length < 2) return null;
239
+ const plainObjects = [];
240
+ const scalars = [];
241
+ for (const member of nonUndefined) if (isPlainAnonymousObject(member, checker)) plainObjects.push(member);
242
+ else scalars.push(member);
243
+ if (plainObjects.length !== 1 || scalars.length === 0) return null;
244
+ const objType = plainObjects[0];
245
+ const objProps = checker.getPropertiesOfType(objType);
246
+ if (objProps.length === 0 || objProps.length > MAX_MAPPED_KEYS) return null;
247
+ const { members: scalarMembers, allLiterals } = formatUnionMembersCanonical(scalars, checker, 1, /* @__PURE__ */ new Set([rawType, objType]));
248
+ if (scalarMembers.length === 0) return null;
249
+ const scalarKey = scalarMembers.join(" | ");
250
+ const keyEntries = [];
251
+ for (const prop of objProps) {
252
+ const propType = getPropType(prop, checker, locationNode);
253
+ const nonUndefPropTypes = (propType.isUnion() ? propType.types : [propType]).filter((t) => !(t.flags & ts.TypeFlags.Undefined));
254
+ if (nonUndefPropTypes.length === 0) return null;
255
+ const { members: propMembers } = formatUnionMembersCanonical(nonUndefPropTypes, checker, 1, /* @__PURE__ */ new Set([rawType, objType]));
256
+ if (propMembers.join(" | ") !== scalarKey) return null;
257
+ keyEntries.push({
258
+ name: prop.getName(),
259
+ optional: (prop.flags & ts.SymbolFlags.Optional) !== 0
260
+ });
261
+ }
262
+ const orderedKeys = sortMappedKeys(keyEntries);
263
+ const valueType = scalarKey;
264
+ const cleanRaw = stripTopLevelUndefined(rawTypeName);
265
+ const aliasFromSymbol = (_rawType$aliasSymbol = rawType.aliasSymbol) === null || _rawType$aliasSymbol === void 0 ? void 0 : _rawType$aliasSymbol.getName();
266
+ const aliasMatch = /^([A-Za-z_$][A-Za-z0-9_$]*)<.+>$/.exec(cleanRaw);
267
+ const alias = aliasFromSymbol !== null && aliasFromSymbol !== void 0 ? aliasFromSymbol : aliasMatch === null || aliasMatch === void 0 ? void 0 : aliasMatch[1];
268
+ const useFactor = scalarMembers.length > 1 || valueType.length > 16;
269
+ const valueRef = useFactor ? "Value" : valueType;
270
+ const objectBlock = `{\n${orderedKeys.map(({ name, optional }) => ` ${formatPropertyKey(name)}${optional ? "?" : ""}: ${valueRef};`).join("\n")}\n}`;
271
+ const formatted = useFactor ? `type Value = ${valueType};\n\nValue | ${objectBlock}` : `${valueType} | ${objectBlock}`;
272
+ return {
273
+ kind: "mapped-union",
274
+ ...alias ? { alias } : {},
275
+ ...allLiterals ? { values: scalarMembers } : {},
276
+ valueType,
277
+ keys: orderedKeys.map((k) => k.name),
278
+ formatted
279
+ };
280
+ }
281
+ function indentBlock(str, spaces) {
282
+ const pad = " ".repeat(spaces);
283
+ return str.split("\n").map((line, i) => i === 0 ? line : `${pad}${line}`).join("\n");
284
+ }
285
+ function formatTypeNode(type, checker, depth, seen, locationNode) {
286
+ if (type.isStringLiteral()) return JSON.stringify(type.value);
287
+ if (type.isNumberLiteral()) return String(type.value);
288
+ if (type.flags & ts.TypeFlags.BigIntLiteral) return getTypeDisplayName(type, checker);
289
+ if (type.flags & ts.TypeFlags.BooleanLiteral) return checker.typeToString(type);
290
+ if (isPrimitiveOrIntrinsic(type)) return getTypeDisplayName(type, checker);
291
+ if (depth > MAX_EXPAND_DEPTH || seen.has(type)) return getTypeDisplayName(type, checker);
292
+ const nextSeen = new Set(seen);
293
+ nextSeen.add(type);
294
+ const arrayInfo = getArrayElementType(type, checker);
295
+ if (arrayInfo) {
296
+ const inner = formatTypeNode(arrayInfo.elementType, checker, depth, nextSeen, locationNode);
297
+ const wrapped = splitTopLevelUnion(inner).length > 1 || inner.includes("=>") || inner.includes(" & ") ? `(${inner})` : inner;
298
+ return arrayInfo.readonly ? `readonly ${wrapped}[]` : `${wrapped}[]`;
299
+ }
300
+ if (checker.isTupleType(type)) return `[${checker.getTypeArguments(type).map((arg) => formatTypeNode(arg, checker, depth + 1, nextSeen, locationNode)).join(", ")}]`;
301
+ if (isStopType(type, checker)) return getTypeDisplayName(type, checker);
302
+ if (type.isIntersection()) {
303
+ const str = getTypeDisplayName(type, checker);
304
+ return depth > 0 && str.includes(" & ") && !str.startsWith("(") ? `(${str})` : str;
305
+ }
306
+ if (type.isUnion()) {
307
+ if (depth > 0) {
308
+ const nestedMapped = detectMappedUnion(type, getTypeDisplayName(type, checker), checker, locationNode);
309
+ if (nestedMapped) return nestedMapped.alias ? `${nestedMapped.alias}<${nestedMapped.valueType}>` : `${nestedMapped.valueType} | { ${nestedMapped.keys.map((k) => `${formatPropertyKey(k)}?`).join(", ")} }`;
310
+ }
311
+ const { members } = formatUnionMembersCanonical(type.types, checker, depth + 1, nextSeen);
312
+ if (type.types.some((t) => (t.flags & ts.TypeFlags.Undefined) !== 0) && depth > 0) members.push("undefined");
313
+ const inline = members.join(" | ");
314
+ if (depth === 0 && (members.length > 4 || inline.length > 60)) return members.map((m) => `| ${m}`).join("\n");
315
+ return inline;
316
+ }
317
+ const callSigs = type.getCallSignatures();
318
+ if (callSigs.length > 0 && checker.getPropertiesOfType(type).length === 0) {
319
+ const sig = callSigs[0];
320
+ const params = sig.getParameters().map((param) => {
321
+ const pType = getPropType(param, checker, locationNode);
322
+ const isOptional = (param.flags & ts.SymbolFlags.Optional) !== 0;
323
+ const pTypeStr = formatTypeNode(isOptional && !isStopType(pType) ? stripUndefinedFromTsType(pType, checker) : pType, checker, depth + 1, nextSeen, locationNode);
324
+ return `${param.getName()}${isOptional ? "?" : ""}: ${pTypeStr}`;
325
+ });
326
+ const retStr = formatTypeNode(sig.getReturnType(), checker, depth + 1, nextSeen, locationNode);
327
+ return `(${params.join(", ")}) => ${retStr}`;
328
+ }
329
+ if (isPlainAnonymousObject(type, checker)) {
330
+ const allProps = checker.getPropertiesOfType(type);
331
+ if (allProps.length === 0) return getTypeDisplayName(type, checker);
332
+ const ownProps = allProps.filter((p) => !isPropertyInheritedFromExternalLibs(p));
333
+ const inheritedCount = allProps.length - ownProps.length;
334
+ if (ownProps.length === 0) return getTypeDisplayName(type, checker);
335
+ const sortedProps = [...ownProps].sort((a, b) => compareStrings(a.getName(), b.getName()));
336
+ const visibleProps = sortedProps.slice(0, MAX_OBJECT_PROPS);
337
+ const hiddenOwnCount = sortedProps.length - visibleProps.length;
338
+ const lines = visibleProps.map((prop) => {
339
+ const isOptional = (prop.flags & ts.SymbolFlags.Optional) !== 0;
340
+ const rawPType = getPropType(prop, checker, locationNode);
341
+ const indentedType = indentBlock(formatTypeNode(isOptional && rawPType.isUnion() && !isStopType(rawPType) ? stripUndefinedFromTsType(rawPType, checker) : rawPType, checker, depth + 1, nextSeen, locationNode), 2);
342
+ return ` ${formatPropertyKey(prop.getName())}${isOptional ? "?" : ""}: ${indentedType};`;
343
+ });
344
+ if (hiddenOwnCount > 0) lines.push(` // ...${hiddenOwnCount} more properties`);
345
+ if (inheritedCount > 0) lines.push(` // ...HTML attributes`);
346
+ return `{\n${lines.join("\n")}\n}`;
347
+ }
348
+ return getTypeDisplayName(type, checker);
349
+ }
350
+ function stripUndefinedFromTsType(type, checker) {
351
+ if (!type.isUnion()) return type;
352
+ const nonUndef = type.types.filter((t) => !(t.flags & ts.TypeFlags.Undefined));
353
+ if (nonUndef.length === 1) return nonUndef[0];
354
+ return checker.getNonNullableType(type);
355
+ }
356
+ function normalizeForComparison(str) {
357
+ return str.replace(/^\|\s*/gm, "").replace(/\s*\n\s*/g, " | ").replace(/\s+/g, " ").replace(/^\((.+)\)$/, "$1").trim();
358
+ }
359
+ /**
360
+ * Inspects a prop's resolved TypeScript type and returns structured expanded
361
+ * type metadata when expansion adds meaningful clarity beyond the display name.
362
+ */
363
+ function expandPropType(rawPropType, displayedTypeName, isEnum, checker, locationNode) {
364
+ var _rawPropType$getConst;
365
+ if (isEnum) return void 0;
366
+ const propType = (_rawPropType$getConst = rawPropType.getConstraint()) !== null && _rawPropType$getConst !== void 0 ? _rawPropType$getConst : rawPropType;
367
+ const mappedUnion = detectMappedUnion(propType, displayedTypeName, checker, locationNode);
368
+ if (mappedUnion) return mappedUnion;
369
+ const nonUndefMembers = propType.isUnion() ? propType.types.filter((t) => !(t.flags & ts.TypeFlags.Undefined)) : [propType];
370
+ if (nonUndefMembers.length === 0) return void 0;
371
+ const coreType = nonUndefMembers.length === 1 ? nonUndefMembers[0] : propType;
372
+ if (isPrimitiveOrIntrinsic(coreType) || isStopType(coreType, checker)) return;
373
+ const displayBase = stripTopLevelUndefined(displayedTypeName);
374
+ let formatted;
375
+ let kind;
376
+ if (nonUndefMembers.length > 1) {
377
+ const { members } = formatUnionMembersCanonical(nonUndefMembers, checker, 1, /* @__PURE__ */ new Set([propType]));
378
+ const inline = members.join(" | ");
379
+ formatted = members.length > 4 || inline.length > 60 ? members.map((m) => `| ${m}`).join("\n") : inline;
380
+ kind = "union";
381
+ } else {
382
+ formatted = formatTypeNode(coreType, checker, 0, /* @__PURE__ */ new Set(), locationNode);
383
+ if (coreType.getCallSignatures().length > 0 && checker.getPropertiesOfType(coreType).length === 0) kind = "function";
384
+ else if (isPlainAnonymousObject(coreType, checker)) kind = "object";
385
+ else kind = "alias";
386
+ }
387
+ if (normalizeForComparison(formatted) === normalizeForComparison(displayBase)) return;
388
+ if (formatted.includes("{ ...; }")) return;
389
+ return {
390
+ kind,
391
+ formatted
392
+ };
393
+ }
394
+ /**
395
+ * Resolves a map of `propName -> { type, locationNode }` for a parsed component
396
+ * expression symbol using the shared TypeScript `TypeChecker`.
397
+ */
398
+ function resolveComponentPropTypes(expression, checker) {
399
+ var _target$valueDeclarat, _target$declarations, _ref2, _propsSymbol$valueDec, _propsSymbol$declarat;
400
+ const result = /* @__PURE__ */ new Map();
401
+ if (!expression) return result;
402
+ let target = expression;
403
+ if (target.flags & ts.SymbolFlags.Alias) target = checker.getAliasedSymbol(target);
404
+ const decl = (_target$valueDeclarat = target.valueDeclaration) !== null && _target$valueDeclarat !== void 0 ? _target$valueDeclarat : (_target$declarations = target.declarations) === null || _target$declarations === void 0 ? void 0 : _target$declarations[0];
405
+ if (!decl) return result;
406
+ const compType = checker.getTypeOfSymbolAtLocation(target, decl);
407
+ let propsSymbol;
408
+ for (const sig of compType.getCallSignatures()) {
409
+ const params = sig.getParameters();
410
+ if (params.length === 0) continue;
411
+ const first = params[0];
412
+ if (first.name === "props" || params.length === 1) {
413
+ propsSymbol = first;
414
+ break;
415
+ }
416
+ }
417
+ if (!propsSymbol) for (const sig of compType.getConstructSignatures()) {
418
+ const prop = sig.getReturnType().getProperty("props");
419
+ if (prop) {
420
+ propsSymbol = prop;
421
+ break;
422
+ }
423
+ }
424
+ if (!propsSymbol) return result;
425
+ const propsDecl = (_ref2 = (_propsSymbol$valueDec = propsSymbol.valueDeclaration) !== null && _propsSymbol$valueDec !== void 0 ? _propsSymbol$valueDec : (_propsSymbol$declarat = propsSymbol.declarations) === null || _propsSymbol$declarat === void 0 ? void 0 : _propsSymbol$declarat[0]) !== null && _ref2 !== void 0 ? _ref2 : decl;
426
+ const propsType = checker.getTypeOfSymbolAtLocation(propsSymbol, propsDecl);
427
+ const propSymbols = [...propsType.getApparentProperties()];
428
+ if (propsType.isUnionOrIntersection()) for (const memberType of propsType.types) propSymbols.push(...memberType.getApparentProperties());
429
+ for (const prop of propSymbols) {
430
+ const name = prop.getName();
431
+ if (result.has(name)) continue;
432
+ const propType = checker.getTypeOfSymbolAtLocation(prop, propsDecl);
433
+ result.set(name, {
434
+ type: propType,
435
+ locationNode: propsDecl
436
+ });
437
+ }
438
+ return result;
439
+ }
440
+ //#endregion
441
+ export { compareStrings, expandPropType, resolveComponentPropTypes, splitTopLevelUnion, stripTopLevelUndefined };
442
+
443
+ //# sourceMappingURL=type-expander.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-expander.mjs","names":[],"sources":["../../src/type-expander.ts"],"sourcesContent":["import ts from \"typescript\";\n\nexport type ExpandedPropType =\n | {\n kind: \"mapped-union\";\n alias?: string;\n values?: string[];\n valueType: string;\n keys: string[];\n formatted: string;\n }\n | {\n kind: \"alias\" | \"object\" | \"union\" | \"function\";\n formatted: string;\n };\n\nconst STOP_TYPE_NAMES = new Set([\n \"ReactNode\",\n \"ReactElement\",\n \"ReactPortal\",\n \"ReactFragment\",\n \"Element\",\n \"JSX.Element\",\n \"CSSProperties\",\n \"ElementType\",\n \"ComponentType\",\n \"ComponentProps\",\n \"ComponentPropsWithRef\",\n \"ComponentPropsWithoutRef\",\n \"Ref\",\n \"RefObject\",\n \"MutableRefObject\",\n \"ForwardedRef\",\n \"LegacyRef\",\n \"HTMLAttributes\",\n \"SVGAttributes\",\n \"DOMAttributes\",\n \"SyntheticEvent\",\n \"MouseEvent\",\n \"KeyboardEvent\",\n \"FocusEvent\",\n \"ChangeEvent\",\n \"PointerEvent\",\n \"TouchEvent\",\n \"UIEvent\",\n \"Event\",\n \"Date\",\n \"RegExp\",\n \"Promise\",\n \"Map\",\n \"Set\",\n \"WeakMap\",\n \"WeakSet\",\n \"URL\",\n \"File\",\n \"Blob\",\n \"FormData\",\n \"Error\",\n]);\n\nconst UTILITY_ALIAS_NAMES = new Set([\n \"Partial\",\n \"Required\",\n \"Readonly\",\n \"Record\",\n \"Pick\",\n \"Omit\",\n \"NonNullable\",\n \"Exclude\",\n \"Extract\",\n]);\n\nconst VALID_IDENTIFIER_RE = /^[A-Za-z_$][A-Za-z0-9_$]*$/;\n\nconst MAX_MAPPED_KEYS = 24;\nconst MAX_OBJECT_PROPS = 14;\nconst MAX_EXPAND_DEPTH = 2;\n\nexport function compareStrings(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/**\n * Splits a TypeScript type string on top-level `|` operators only,\n * preserving `|` inside `<...>`, `{...}`, `(...)`, `[...]`, and string literals.\n */\nexport function splitTopLevelUnion(str: string): string[] {\n if (!str.includes(\"|\")) {\n return [str.trim()];\n }\n\n const parts: string[] = [];\n let current = \"\";\n let depthParen = 0;\n let depthAngle = 0;\n let depthBrace = 0;\n let depthBracket = 0;\n let inQuote: string | null = null;\n\n for (let i = 0; i < str.length; i++) {\n const ch = str[i]!;\n if (inQuote) {\n current += ch;\n if (ch === inQuote && str[i - 1] !== \"\\\\\") {\n inQuote = null;\n }\n continue;\n }\n\n if (ch === '\"' || ch === \"'\" || ch === \"`\") {\n inQuote = ch;\n current += ch;\n continue;\n }\n\n if (ch === \"(\") depthParen++;\n else if (ch === \")\") depthParen = Math.max(0, depthParen - 1);\n else if (ch === \"<\") depthAngle++;\n else if (ch === \">\" && str[i - 1] !== \"=\")\n depthAngle = Math.max(0, depthAngle - 1);\n else if (ch === \"{\") depthBrace++;\n else if (ch === \"}\") depthBrace = Math.max(0, depthBrace - 1);\n else if (ch === \"[\") depthBracket++;\n else if (ch === \"]\") depthBracket = Math.max(0, depthBracket - 1);\n\n if (\n ch === \"|\" &&\n depthParen === 0 &&\n depthAngle === 0 &&\n depthBrace === 0 &&\n depthBracket === 0\n ) {\n parts.push(current.trim());\n current = \"\";\n } else {\n current += ch;\n }\n }\n\n parts.push(current.trim());\n return parts.filter((part) => part.length > 0);\n}\n\nexport function stripTopLevelUndefined(str: string): string {\n const parts = splitTopLevelUnion(str).filter((p) => p !== \"undefined\");\n return parts.join(\" | \");\n}\n\nfunction sortUnionMembers(members: string[]): string[] {\n return [...members].sort((a, b) => {\n if (a === \"undefined\" && b !== \"undefined\") return 1;\n if (b === \"undefined\" && a !== \"undefined\") return -1;\n if (a === \"null\" && b !== \"null\") return 1;\n if (b === \"null\" && a !== \"null\") return -1;\n return compareStrings(a, b);\n });\n}\n\nfunction sortMappedKeys(keys: { name: string; optional: boolean }[]) {\n return [...keys].sort((a, b) => compareStrings(a.name, b.name));\n}\n\nfunction formatPropertyKey(name: string): string {\n return VALID_IDENTIFIER_RE.test(name) ? name : JSON.stringify(name);\n}\n\nfunction isDeclarationInExternalLibs(\n decl: ts.Declaration | undefined\n): boolean {\n if (!decl) return false;\n const fileName = decl.getSourceFile().fileName.replace(/\\\\/g, \"/\");\n return (\n fileName.includes(\"/node_modules/@types/react/\") ||\n fileName.includes(\"/node_modules/typescript/lib/lib.\")\n );\n}\n\nfunction isPropertyInheritedFromExternalLibs(prop: ts.Symbol): boolean {\n const decls = prop.getDeclarations();\n if (!decls || decls.length === 0) return false;\n return decls.every((d) => isDeclarationInExternalLibs(d));\n}\n\nfunction getTypeDisplayName(type: ts.Type, checker: ts.TypeChecker): string {\n return checker.typeToString(type, undefined, ts.TypeFormatFlags.NoTruncation);\n}\n\nfunction isStopType(type: ts.Type, checker?: ts.TypeChecker): boolean {\n if (\n checker &&\n (getArrayElementType(type, checker) || checker.isTupleType(type))\n ) {\n return false;\n }\n\n const aliasName = type.aliasSymbol?.getName();\n if (aliasName && STOP_TYPE_NAMES.has(aliasName)) {\n return true;\n }\n\n const symbol = type.getSymbol();\n if (symbol) {\n const name = symbol.getName();\n if (name === \"Array\" || name === \"ReadonlyArray\") {\n return false;\n }\n if (STOP_TYPE_NAMES.has(name)) {\n return true;\n }\n\n // Nominal DOM / built-in / React interfaces (e.g. HTMLElement, HTMLDivElement, SVGElement)\n const decl = symbol.valueDeclaration ?? symbol.declarations?.[0];\n if (\n decl &&\n isDeclarationInExternalLibs(decl) &&\n !(aliasName && UTILITY_ALIAS_NAMES.has(aliasName)) &&\n name !== \"__type\" &&\n name !== \"__object\"\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction isPrimitiveOrIntrinsic(type: ts.Type): boolean {\n return Boolean(\n type.flags &\n (ts.TypeFlags.String |\n ts.TypeFlags.Number |\n ts.TypeFlags.Boolean |\n ts.TypeFlags.BigInt |\n ts.TypeFlags.ESSymbol |\n ts.TypeFlags.UniqueESSymbol |\n ts.TypeFlags.Void |\n ts.TypeFlags.Undefined |\n ts.TypeFlags.Null |\n ts.TypeFlags.Never |\n ts.TypeFlags.Any |\n ts.TypeFlags.Unknown |\n ts.TypeFlags.NonPrimitive)\n );\n}\n\nfunction isLiteralType(type: ts.Type): boolean {\n return Boolean(\n type.flags &\n (ts.TypeFlags.StringLiteral |\n ts.TypeFlags.NumberLiteral |\n ts.TypeFlags.BigIntLiteral |\n ts.TypeFlags.EnumLiteral)\n );\n}\n\nfunction isPlainAnonymousObject(\n type: ts.Type,\n checker: ts.TypeChecker\n): boolean {\n if (!(type.flags & ts.TypeFlags.Object)) return false;\n if (checker.isArrayType(type) || checker.isTupleType(type)) return false;\n if (type.getCallSignatures().length > 0) return false;\n if (type.getConstructSignatures().length > 0) return false;\n if (isStopType(type)) return false;\n return true;\n}\n\nfunction isReadonlyArrayType(type: ts.Type): boolean {\n const symbol = type.getSymbol();\n return symbol?.getName() === \"ReadonlyArray\";\n}\n\nfunction getArrayElementType(\n type: ts.Type,\n checker: ts.TypeChecker\n): { elementType: ts.Type; readonly: boolean } | null {\n if (isReadonlyArrayType(type)) {\n const typeArgs = checker.getTypeArguments(type as ts.TypeReference);\n if (typeArgs[0]) {\n return { elementType: typeArgs[0], readonly: true };\n }\n }\n if (checker.isArrayType(type)) {\n const typeArgs = checker.getTypeArguments(type as ts.TypeReference);\n if (typeArgs[0]) {\n return { elementType: typeArgs[0], readonly: false };\n }\n }\n return null;\n}\n\n/**\n * Formats a list of union member types into canonical sorted strings,\n * collapsing `false` + `true` boolean literals back into `boolean`.\n */\nfunction formatUnionMembersCanonical(\n types: readonly ts.Type[],\n checker: ts.TypeChecker,\n depth: number,\n seen: Set<ts.Type>\n): { members: string[]; allLiterals: boolean } {\n let hasTrue = false;\n let hasFalse = false;\n const rest: ts.Type[] = [];\n\n for (const t of types) {\n if (t.flags & ts.TypeFlags.Undefined) continue;\n if (t.flags & ts.TypeFlags.BooleanLiteral) {\n const str = checker.typeToString(t);\n if (str === \"true\") hasTrue = true;\n else if (str === \"false\") hasFalse = true;\n else rest.push(t);\n } else {\n rest.push(t);\n }\n }\n\n const formatted: string[] = [];\n let allLiterals = true;\n\n if (hasTrue && hasFalse) {\n formatted.push(\"boolean\");\n allLiterals = false;\n } else {\n if (hasFalse) formatted.push(\"false\");\n if (hasTrue) formatted.push(\"true\");\n }\n\n for (const t of rest) {\n if (!isLiteralType(t)) {\n allLiterals = false;\n }\n formatted.push(formatTypeNode(t, checker, depth, seen));\n }\n\n const unique = Array.from(new Set(formatted));\n return {\n members: sortUnionMembers(unique),\n allLiterals: allLiterals && unique.length > 0,\n };\n}\n\nfunction getPropType(\n prop: ts.Symbol,\n checker: ts.TypeChecker,\n fallbackNode?: ts.Node\n): ts.Type {\n const decl = prop.valueDeclaration ?? prop.declarations?.[0] ?? fallbackNode;\n if (decl) {\n return checker.getTypeOfSymbolAtLocation(prop, decl);\n }\n return checker.getTypeOfSymbol(prop);\n}\n\n/**\n * Detects the structural `Value | { [K in Keys]?: Value }` pattern\n * (e.g. `ResponsiveValue<Value, BP>`), returning factored metadata without\n * repeating `Value` for every key.\n */\nfunction detectMappedUnion(\n rawType: ts.Type,\n rawTypeName: string,\n checker: ts.TypeChecker,\n locationNode?: ts.Node\n): Extract<ExpandedPropType, { kind: \"mapped-union\" }> | null {\n if (!rawType.isUnion()) return null;\n\n const nonUndefined = rawType.types.filter(\n (t) => !(t.flags & ts.TypeFlags.Undefined)\n );\n if (nonUndefined.length < 2) return null;\n\n const plainObjects: ts.Type[] = [];\n const scalars: ts.Type[] = [];\n\n for (const member of nonUndefined) {\n if (isPlainAnonymousObject(member, checker)) {\n plainObjects.push(member);\n } else {\n scalars.push(member);\n }\n }\n\n if (plainObjects.length !== 1 || scalars.length === 0) {\n return null;\n }\n\n const objType = plainObjects[0]!;\n const objProps = checker.getPropertiesOfType(objType);\n if (objProps.length === 0 || objProps.length > MAX_MAPPED_KEYS) {\n return null;\n }\n\n const { members: scalarMembers, allLiterals } = formatUnionMembersCanonical(\n scalars,\n checker,\n 1,\n new Set([rawType, objType])\n );\n if (scalarMembers.length === 0) return null;\n\n const scalarKey = scalarMembers.join(\" | \");\n const keyEntries: { name: string; optional: boolean }[] = [];\n\n for (const prop of objProps) {\n const propType = getPropType(prop, checker, locationNode);\n const propTypes = propType.isUnion() ? propType.types : [propType];\n const nonUndefPropTypes = propTypes.filter(\n (t) => !(t.flags & ts.TypeFlags.Undefined)\n );\n if (nonUndefPropTypes.length === 0) {\n return null;\n }\n\n const { members: propMembers } = formatUnionMembersCanonical(\n nonUndefPropTypes,\n checker,\n 1,\n new Set([rawType, objType])\n );\n if (propMembers.join(\" | \") !== scalarKey) {\n return null;\n }\n\n keyEntries.push({\n name: prop.getName(),\n optional: (prop.flags & ts.SymbolFlags.Optional) !== 0,\n });\n }\n\n const orderedKeys = sortMappedKeys(keyEntries);\n const valueType = scalarKey;\n\n const cleanRaw = stripTopLevelUndefined(rawTypeName);\n const aliasFromSymbol = rawType.aliasSymbol?.getName();\n const aliasMatch = /^([A-Za-z_$][A-Za-z0-9_$]*)<.+>$/.exec(cleanRaw);\n const alias = aliasFromSymbol ?? aliasMatch?.[1];\n\n const useFactor = scalarMembers.length > 1 || valueType.length > 16;\n const valueRef = useFactor ? \"Value\" : valueType;\n const objectLines = orderedKeys.map(\n ({ name, optional }) =>\n ` ${formatPropertyKey(name)}${optional ? \"?\" : \"\"}: ${valueRef};`\n );\n const objectBlock = `{\\n${objectLines.join(\"\\n\")}\\n}`;\n const formatted = useFactor\n ? `type Value = ${valueType};\\n\\nValue | ${objectBlock}`\n : `${valueType} | ${objectBlock}`;\n\n return {\n kind: \"mapped-union\",\n ...(alias ? { alias } : {}),\n ...(allLiterals ? { values: scalarMembers } : {}),\n valueType,\n keys: orderedKeys.map((k) => k.name),\n formatted,\n };\n}\n\nfunction indentBlock(str: string, spaces: number): string {\n const pad = \" \".repeat(spaces);\n return str\n .split(\"\\n\")\n .map((line, i) => (i === 0 ? line : `${pad}${line}`))\n .join(\"\\n\");\n}\n\nfunction formatTypeNode(\n type: ts.Type,\n checker: ts.TypeChecker,\n depth: number,\n seen: Set<ts.Type>,\n locationNode?: ts.Node\n): string {\n if (type.isStringLiteral()) {\n return JSON.stringify(type.value);\n }\n if (type.isNumberLiteral()) {\n return String(type.value);\n }\n if (type.flags & ts.TypeFlags.BigIntLiteral) {\n return getTypeDisplayName(type, checker);\n }\n if (type.flags & ts.TypeFlags.BooleanLiteral) {\n return checker.typeToString(type);\n }\n if (isPrimitiveOrIntrinsic(type)) {\n return getTypeDisplayName(type, checker);\n }\n\n if (depth > MAX_EXPAND_DEPTH || seen.has(type)) {\n return getTypeDisplayName(type, checker);\n }\n\n const nextSeen = new Set(seen);\n nextSeen.add(type);\n\n // Array / ReadonlyArray (must run before isStopType since Array/ReadonlyArray live in lib.es5.d.ts)\n const arrayInfo = getArrayElementType(type, checker);\n if (arrayInfo) {\n const inner = formatTypeNode(\n arrayInfo.elementType,\n checker,\n depth,\n nextSeen,\n locationNode\n );\n const needsParens =\n splitTopLevelUnion(inner).length > 1 ||\n inner.includes(\"=>\") ||\n inner.includes(\" & \");\n const wrapped = needsParens ? `(${inner})` : inner;\n return arrayInfo.readonly ? `readonly ${wrapped}[]` : `${wrapped}[]`;\n }\n\n // Tuple\n if (checker.isTupleType(type)) {\n const args = checker.getTypeArguments(type as ts.TypeReference);\n const formattedArgs = args.map((arg) =>\n formatTypeNode(arg, checker, depth + 1, nextSeen, locationNode)\n );\n return `[${formattedArgs.join(\", \")}]`;\n }\n\n if (isStopType(type, checker)) {\n return getTypeDisplayName(type, checker);\n }\n\n // Intersection\n if (type.isIntersection()) {\n const str = getTypeDisplayName(type, checker);\n return depth > 0 && str.includes(\" & \") && !str.startsWith(\"(\")\n ? `(${str})`\n : str;\n }\n\n // Union\n if (type.isUnion()) {\n if (depth > 0) {\n const nestedMapped = detectMappedUnion(\n type,\n getTypeDisplayName(type, checker),\n checker,\n locationNode\n );\n if (nestedMapped) {\n return nestedMapped.alias\n ? `${nestedMapped.alias}<${nestedMapped.valueType}>`\n : `${nestedMapped.valueType} | { ${nestedMapped.keys.map((k) => `${formatPropertyKey(k)}?`).join(\", \")} }`;\n }\n }\n\n const { members } = formatUnionMembersCanonical(\n type.types,\n checker,\n depth + 1,\n nextSeen\n );\n const hasUndefined = type.types.some(\n (t) => (t.flags & ts.TypeFlags.Undefined) !== 0\n );\n if (hasUndefined && depth > 0) {\n members.push(\"undefined\");\n }\n const inline = members.join(\" | \");\n if (depth === 0 && (members.length > 4 || inline.length > 60)) {\n return members.map((m) => `| ${m}`).join(\"\\n\");\n }\n return inline;\n }\n\n // Function type (callable without non-method properties)\n const callSigs = type.getCallSignatures();\n if (callSigs.length > 0 && checker.getPropertiesOfType(type).length === 0) {\n const sig = callSigs[0]!;\n const params = sig.getParameters().map((param) => {\n const pType = getPropType(param, checker, locationNode);\n const isOptional = (param.flags & ts.SymbolFlags.Optional) !== 0;\n const effectivePType =\n isOptional && !isStopType(pType)\n ? stripUndefinedFromTsType(pType, checker)\n : pType;\n const pTypeStr = formatTypeNode(\n effectivePType,\n checker,\n depth + 1,\n nextSeen,\n locationNode\n );\n return `${param.getName()}${isOptional ? \"?\" : \"\"}: ${pTypeStr}`;\n });\n const retStr = formatTypeNode(\n sig.getReturnType(),\n checker,\n depth + 1,\n nextSeen,\n locationNode\n );\n return `(${params.join(\", \")}) => ${retStr}`;\n }\n\n // Plain / mapped / utility object type\n if (isPlainAnonymousObject(type, checker)) {\n const allProps = checker.getPropertiesOfType(type);\n if (allProps.length === 0) {\n return getTypeDisplayName(type, checker);\n }\n\n const ownProps = allProps.filter(\n (p) => !isPropertyInheritedFromExternalLibs(p)\n );\n const inheritedCount = allProps.length - ownProps.length;\n\n // If an object consists purely of external DOM/React props, don't expand it.\n if (ownProps.length === 0) {\n return getTypeDisplayName(type, checker);\n }\n\n const sortedProps = [...ownProps].sort((a, b) =>\n compareStrings(a.getName(), b.getName())\n );\n const visibleProps = sortedProps.slice(0, MAX_OBJECT_PROPS);\n const hiddenOwnCount = sortedProps.length - visibleProps.length;\n\n const lines = visibleProps.map((prop) => {\n const isOptional = (prop.flags & ts.SymbolFlags.Optional) !== 0;\n const rawPType = getPropType(prop, checker, locationNode);\n const effectivePType =\n isOptional && rawPType.isUnion() && !isStopType(rawPType)\n ? stripUndefinedFromTsType(rawPType, checker)\n : rawPType;\n const formattedPropType = formatTypeNode(\n effectivePType,\n checker,\n depth + 1,\n nextSeen,\n locationNode\n );\n const indentedType = indentBlock(formattedPropType, 2);\n return ` ${formatPropertyKey(prop.getName())}${isOptional ? \"?\" : \"\"}: ${indentedType};`;\n });\n\n if (hiddenOwnCount > 0) {\n lines.push(` // ...${hiddenOwnCount} more properties`);\n }\n if (inheritedCount > 0) {\n lines.push(` // ...HTML attributes`);\n }\n\n return `{\\n${lines.join(\"\\n\")}\\n}`;\n }\n\n return getTypeDisplayName(type, checker);\n}\n\nfunction stripUndefinedFromTsType(\n type: ts.Type,\n checker: ts.TypeChecker\n): ts.Type {\n if (!type.isUnion()) return type;\n const nonUndef = type.types.filter(\n (t) => !(t.flags & ts.TypeFlags.Undefined)\n );\n if (nonUndef.length === 1) return nonUndef[0]!;\n return checker.getNonNullableType(type);\n}\n\nfunction normalizeForComparison(str: string): string {\n return str\n .replace(/^\\|\\s*/gm, \"\")\n .replace(/\\s*\\n\\s*/g, \" | \")\n .replace(/\\s+/g, \" \")\n .replace(/^\\((.+)\\)$/, \"$1\")\n .trim();\n}\n\n/**\n * Inspects a prop's resolved TypeScript type and returns structured expanded\n * type metadata when expansion adds meaningful clarity beyond the display name.\n */\nexport function expandPropType(\n rawPropType: ts.Type,\n displayedTypeName: string,\n isEnum: boolean,\n checker: ts.TypeChecker,\n locationNode?: ts.Node\n): ExpandedPropType | undefined {\n // Flat literal enums already carry all their values in `type.value`.\n if (isEnum) return undefined;\n\n const propType = rawPropType.getConstraint() ?? rawPropType;\n\n // 1. Structural `Value | { [K in Keys]?: Value }` (e.g. ResponsiveValue<V, BP>)\n const mappedUnion = detectMappedUnion(\n propType,\n displayedTypeName,\n checker,\n locationNode\n );\n if (mappedUnion) {\n return mappedUnion;\n }\n\n // 2. Unwrap optional `| undefined` for general expansion\n const nonUndefMembers = propType.isUnion()\n ? propType.types.filter((t) => !(t.flags & ts.TypeFlags.Undefined))\n : [propType];\n\n if (nonUndefMembers.length === 0) return undefined;\n\n const coreType =\n nonUndefMembers.length === 1 ? nonUndefMembers[0]! : propType;\n\n if (isPrimitiveOrIntrinsic(coreType) || isStopType(coreType, checker)) {\n return undefined;\n }\n\n const displayBase = stripTopLevelUndefined(displayedTypeName);\n\n // Format the resolved type\n let formatted: string;\n let kind: \"alias\" | \"object\" | \"union\" | \"function\";\n\n if (nonUndefMembers.length > 1) {\n const { members } = formatUnionMembersCanonical(\n nonUndefMembers,\n checker,\n 1,\n new Set([propType])\n );\n const inline = members.join(\" | \");\n formatted =\n members.length > 4 || inline.length > 60\n ? members.map((m) => `| ${m}`).join(\"\\n\")\n : inline;\n kind = \"union\";\n } else {\n formatted = formatTypeNode(coreType, checker, 0, new Set(), locationNode);\n if (\n coreType.getCallSignatures().length > 0 &&\n checker.getPropertiesOfType(coreType).length === 0\n ) {\n kind = \"function\";\n } else if (isPlainAnonymousObject(coreType, checker)) {\n kind = \"object\";\n } else {\n kind = \"alias\";\n }\n }\n\n // Only emit `expanded` if it genuinely adds information over `displayBase`\n if (\n normalizeForComparison(formatted) === normalizeForComparison(displayBase)\n ) {\n return undefined;\n }\n\n // Don't emit noisy expansion if formatting failed to resolve beyond `{ ...; }`\n if (formatted.includes(\"{ ...; }\")) {\n return undefined;\n }\n\n return { kind, formatted };\n}\n\n/**\n * Resolves a map of `propName -> { type, locationNode }` for a parsed component\n * expression symbol using the shared TypeScript `TypeChecker`.\n */\nexport function resolveComponentPropTypes(\n expression: ts.Symbol | undefined,\n checker: ts.TypeChecker\n): Map<string, { type: ts.Type; locationNode?: ts.Node }> {\n const result = new Map<string, { type: ts.Type; locationNode?: ts.Node }>();\n if (!expression) return result;\n\n let target = expression;\n if (target.flags & ts.SymbolFlags.Alias) {\n target = checker.getAliasedSymbol(target);\n }\n\n const decl = target.valueDeclaration ?? target.declarations?.[0];\n if (!decl) return result;\n\n const compType = checker.getTypeOfSymbolAtLocation(target, decl);\n\n // Stateless function component: first parameter of call signature\n let propsSymbol: ts.Symbol | undefined;\n for (const sig of compType.getCallSignatures()) {\n const params = sig.getParameters();\n if (params.length === 0) continue;\n const first = params[0]!;\n if (first.name === \"props\" || params.length === 1) {\n propsSymbol = first;\n break;\n }\n }\n\n // Stateful class component: `props` property on constructed instance\n if (!propsSymbol) {\n for (const sig of compType.getConstructSignatures()) {\n const prop = sig.getReturnType().getProperty(\"props\");\n if (prop) {\n propsSymbol = prop;\n break;\n }\n }\n }\n\n if (!propsSymbol) return result;\n\n const propsDecl =\n propsSymbol.valueDeclaration ?? propsSymbol.declarations?.[0] ?? decl;\n const propsType = checker.getTypeOfSymbolAtLocation(propsSymbol, propsDecl);\n\n const propSymbols: ts.Symbol[] = [...propsType.getApparentProperties()];\n if (propsType.isUnionOrIntersection()) {\n for (const memberType of propsType.types) {\n propSymbols.push(...memberType.getApparentProperties());\n }\n }\n\n for (const prop of propSymbols) {\n const name = prop.getName();\n if (result.has(name)) continue;\n const propType = checker.getTypeOfSymbolAtLocation(prop, propsDecl);\n result.set(name, { type: propType, locationNode: propsDecl });\n }\n\n return result;\n}\n"],"mappings":";;AAgBA,MAAM,kCAAkB,IAAI,IAAI;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAC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MAAM,QAAQ,OAAO;EACrB,IAAI,MAAM,SAAS,WAAW,OAAO,WAAW,GAAG;GACjD,cAAc;GACd;EACF;CACF;CAGA,IAAI,CAAC,aACH,KAAK,MAAM,OAAO,SAAS,uBAAuB,GAAG;EACnD,MAAM,OAAO,IAAI,cAAc,CAAC,CAAC,YAAY,OAAO;EACpD,IAAI,MAAM;GACR,cAAc;GACd;EACF;CACF;CAGF,IAAI,CAAC,aAAa,OAAO;CAEzB,MAAM,aAAA,SAAA,wBACJ,YAAY,sBAAA,QAAA,0BAAA,KAAA,IAAA,yBAAA,wBAAoB,YAAY,kBAAA,QAAA,0BAAA,KAAA,IAAA,KAAA,IAAA,sBAAe,QAAA,QAAA,UAAA,KAAA,IAAA,QAAM;CACnE,MAAM,YAAY,QAAQ,0BAA0B,aAAa,SAAS;CAE1E,MAAM,cAA2B,CAAC,GAAG,UAAU,sBAAsB,CAAC;CACtE,IAAI,UAAU,sBAAsB,GAClC,KAAK,MAAM,cAAc,UAAU,OACjC,YAAY,KAAK,GAAG,WAAW,sBAAsB,CAAC;CAI1D,KAAK,MAAM,QAAQ,aAAa;EAC9B,MAAM,OAAO,KAAK,QAAQ;EAC1B,IAAI,OAAO,IAAI,IAAI,GAAG;EACtB,MAAM,WAAW,QAAQ,0BAA0B,MAAM,SAAS;EAClE,OAAO,IAAI,MAAM;GAAE,MAAM;GAAU,cAAc;EAAU,CAAC;CAC9D;CAEA,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@renr/parcel-reporter-docgen",
3
- "version": "0.1.0-beta.10",
3
+ "version": "0.1.0-beta.12",
4
4
  "author": "Ren Rizzolo",
5
5
  "license": "MIT",
6
6
  "description": "Parcel reporter that generates ui docs via react-docgen-typescript",
@@ -16,8 +16,14 @@
16
16
  "main": "./dist/esm/index.mjs",
17
17
  "module": "./dist/esm/index.mjs",
18
18
  "types": "./dist/esm/index.d.mts",
19
+ "bin": {
20
+ "parcel-docgen": "./dist/esm/cli.mjs"
21
+ },
19
22
  "files": [
20
- "dist"
23
+ "dist",
24
+ "target/release/libparcel_reporter_docgen.so",
25
+ "target/release/libparcel_reporter_docgen.dylib",
26
+ "target/release/parcel_reporter_docgen.dll"
21
27
  ],
22
28
  "sideEffects": false,
23
29
  "exports": {
@@ -27,10 +33,30 @@
27
33
  "default": "./dist/esm/index.mjs"
28
34
  }
29
35
  },
36
+ "engines": {
37
+ "parcel": "^3.0.0-alpha.3"
38
+ },
39
+ "parcel": {
40
+ "abi": 1,
41
+ "artifacts": {
42
+ "aarch64-apple-darwin": "@renr/parcel-reporter-docgen-darwin-arm64",
43
+ "x86_64-apple-darwin": "@renr/parcel-reporter-docgen-darwin-x64",
44
+ "x86_64-pc-windows-msvc": "@renr/parcel-reporter-docgen-win32-x64-msvc",
45
+ "aarch64-pc-windows-msvc": "@renr/parcel-reporter-docgen-win32-arm64-msvc",
46
+ "x86_64-unknown-linux-gnu": "@renr/parcel-reporter-docgen-linux-x64-gnu",
47
+ "aarch64-unknown-linux-gnu": "@renr/parcel-reporter-docgen-linux-arm64-gnu",
48
+ "x86_64-unknown-linux-musl": "@renr/parcel-reporter-docgen-linux-x64-musl",
49
+ "aarch64-unknown-linux-musl": "@renr/parcel-reporter-docgen-linux-arm64-musl"
50
+ }
51
+ },
52
+ "scripts": {
53
+ "build": "node ../../scripts/build-rust.mjs && tsdown",
54
+ "build:rust": "node ../../scripts/build-rust.mjs",
55
+ "test:rust": "node ../../scripts/build-rust.mjs --test",
56
+ "prepack": "node ../../scripts/prepack-plugin.mjs",
57
+ "type-check": "tsc --noEmit"
58
+ },
30
59
  "dependencies": {
31
- "@parcel/diagnostic": "^2.16.4",
32
- "@parcel/plugin": "^2.16.4",
33
- "dedent": "^1.7.2",
34
60
  "react-docgen-typescript": "^2.4.0",
35
61
  "tinyglobby": "^0.2.17",
36
62
  "typescript": "npm:@typescript/typescript6@^6.0.2"
@@ -41,8 +67,14 @@
41
67
  "publishConfig": {
42
68
  "access": "public"
43
69
  },
44
- "scripts": {
45
- "build": "tsdown",
46
- "type-check": "tsc --noEmit"
70
+ "optionalDependencies": {
71
+ "@renr/parcel-reporter-docgen-darwin-arm64": "0.1.0-beta.12",
72
+ "@renr/parcel-reporter-docgen-darwin-x64": "0.1.0-beta.12",
73
+ "@renr/parcel-reporter-docgen-win32-x64-msvc": "0.1.0-beta.12",
74
+ "@renr/parcel-reporter-docgen-win32-arm64-msvc": "0.1.0-beta.12",
75
+ "@renr/parcel-reporter-docgen-linux-x64-gnu": "0.1.0-beta.12",
76
+ "@renr/parcel-reporter-docgen-linux-arm64-gnu": "0.1.0-beta.12",
77
+ "@renr/parcel-reporter-docgen-linux-x64-musl": "0.1.0-beta.12",
78
+ "@renr/parcel-reporter-docgen-linux-arm64-musl": "0.1.0-beta.12"
47
79
  }
48
- }
80
+ }
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Ren
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/index.ts"],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["packageJSON.name"],"sources":["../../src/index.ts"],"sourcesContent":["import ThrowableDiagnostic from \"@parcel/diagnostic\";\nimport { Reporter } from \"@parcel/plugin\";\nimport path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport { generateProps } from \"./generate-props.js\";\nimport packageJSON from \"../package.json\" with { type: \"json\" };\nimport dedent from \"dedent\";\n\nconst origin = packageJSON.name;\n\nexport default new Reporter({\n async report({ event, options, logger }) {\n if (event.type === \"buildStart\") {\n try {\n const projectPackageJSON = path.join(\n options.projectRoot,\n \"package.json\"\n );\n\n const fileURL = pathToFileURL(projectPackageJSON).toString();\n\n const config = (await import(fileURL, {\n with: {\n type: \"json\",\n },\n }).then((mod) => mod.default)) as {\n [origin]?: {\n source: string;\n output?: string;\n tsconfig?: string;\n };\n };\n\n const source = config[origin]?.source;\n const output = config[origin]?.output;\n const tsconfig = config[origin]?.tsconfig;\n\n if (!source) {\n throw new ThrowableDiagnostic({\n diagnostic: {\n origin,\n message: dedent`No \"@renr/parcel-reporter-docgen\" source found in package.json. \n NOTE: if you are using a monorepo, you need to run parcel from the package that contains your pages rather than the project root.\n See https://github.com/parcel-bundler/parcel/issues/7206 for a workaround.`,\n hints: [\n 'Add a \"@renr/parcel-reporter-docgen\" source to your package.json with a source e.g `../packages/ui/src/**/*.{ts,tsx}`.',\n ],\n\n codeFrames: [\n {\n codeHighlights: [\n {\n start: { line: 3, column: 2 },\n end: { line: 7, column: 44 },\n message:\n 'Add a \"@renr/parcel-reporter-docgen\" source to generate docs for your UI components.',\n },\n ],\n language: \"json\",\n filePath: projectPackageJSON,\n code: dedent`{\n \"@renr/parcel-reporter-docgen\": {\n \"source\": \"../packages/ui/src/**/*.{ts,tsx}\",\n \"output\": \"docs/components\"\n }\n } `,\n },\n ],\n },\n });\n }\n try {\n await generateProps(\n source,\n options.projectRoot,\n output || \"docgen\",\n (...args) => logger.info({ origin, message: args.join(\" \") }),\n tsconfig\n );\n } catch (error) {\n throwError(error as Error);\n }\n } catch (error) {\n throwError(error as Error);\n }\n return;\n }\n },\n});\n\nfunction throwError(error: Error) {\n throw new ThrowableDiagnostic({\n diagnostic: {\n origin,\n message: error.message,\n stack: error.stack,\n },\n });\n}\n"],"mappings":";;;;;;;;AAQA,MAAM,SAASA;AAEf,IAAA,cAAe,IAAI,SAAS,EAC1B,MAAM,OAAO,EAAE,OAAO,SAAS,UAAU;CACvC,IAAI,MAAM,SAAS,cAAc;EAC/B,IAAI;;GACF,MAAM,qBAAqB,KAAK,KAC9B,QAAQ,aACR,cACF;GAIA,MAAM,SAAU,MAAM,OAFN,cAAc,kBAAkB,CAAC,CAAC,SAEf,GAAG,EACpC,MAAM,EACJ,MAAM,OACR,EACF,EAAE,CAAC,MAAM,QAAQ,IAAI,OAAO;GAQ5B,MAAM,UAAA,iBAAS,OAAO,aAAA,QAAA,mBAAA,KAAA,IAAA,KAAA,IAAA,eAAS;GAC/B,MAAM,UAAA,kBAAS,OAAO,aAAA,QAAA,oBAAA,KAAA,IAAA,KAAA,IAAA,gBAAS;GAC/B,MAAM,YAAA,kBAAW,OAAO,aAAA,QAAA,oBAAA,KAAA,IAAA,KAAA,IAAA,gBAAS;GAEjC,IAAI,CAAC,QACH,MAAM,IAAI,oBAAoB,EAC5B,YAAY;IACV;IACA,SAAS,MAAM;;;IAGf,OAAO,CACL,0HACF;IAEA,YAAY,CACV;KACE,gBAAgB,CACd;MACE,OAAO;OAAE,MAAM;OAAG,QAAQ;MAAE;MAC5B,KAAK;OAAE,MAAM;OAAG,QAAQ;MAAG;MAC3B,SACE;KACJ,CACF;KACA,UAAU;KACV,UAAU;KACV,MAAM,MAAM;;;;;;IAMd,CACF;GACF,EACF,CAAC;GAEH,IAAI;IACF,MAAM,cACJ,QACA,QAAQ,aACR,UAAU,WACT,GAAG,SAAS,OAAO,KAAK;KAAE;KAAQ,SAAS,KAAK,KAAK,GAAG;IAAE,CAAC,GAC5D,QACF;GACF,SAAS,OAAO;IACd,WAAW,KAAc;GAC3B;EACF,SAAS,OAAO;GACd,WAAW,KAAc;EAC3B;EACA;CACF;AACF,EACF,CAAC;AAED,SAAS,WAAW,OAAc;CAChC,MAAM,IAAI,oBAAoB,EAC5B,YAAY;EACV;EACA,SAAS,MAAM;EACf,OAAO,MAAM;CACf,EACF,CAAC;AACH"}
@@ -1,6 +0,0 @@
1
- //#region package.json
2
- var name = "@renr/parcel-reporter-docgen";
3
- //#endregion
4
- export { name };
5
-
6
- //# sourceMappingURL=package.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"package.mjs","names":[],"sources":["../../package.json"],"sourcesContent":[""],"mappings":""}