@sudosandwich/limps-radix 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +255 -0
  3. package/dist/cache/index.d.ts +110 -0
  4. package/dist/cache/index.d.ts.map +1 -0
  5. package/dist/cache/index.js +176 -0
  6. package/dist/cache/index.js.map +1 -0
  7. package/dist/cache/storage.d.ts +73 -0
  8. package/dist/cache/storage.d.ts.map +1 -0
  9. package/dist/cache/storage.js +176 -0
  10. package/dist/cache/storage.js.map +1 -0
  11. package/dist/cache/ttl.d.ts +62 -0
  12. package/dist/cache/ttl.d.ts.map +1 -0
  13. package/dist/cache/ttl.js +96 -0
  14. package/dist/cache/ttl.js.map +1 -0
  15. package/dist/extractor/classifier.d.ts +30 -0
  16. package/dist/extractor/classifier.d.ts.map +1 -0
  17. package/dist/extractor/classifier.js +150 -0
  18. package/dist/extractor/classifier.js.map +1 -0
  19. package/dist/extractor/forward-ref.d.ts +28 -0
  20. package/dist/extractor/forward-ref.d.ts.map +1 -0
  21. package/dist/extractor/forward-ref.js +134 -0
  22. package/dist/extractor/forward-ref.js.map +1 -0
  23. package/dist/extractor/index.d.ts +25 -0
  24. package/dist/extractor/index.d.ts.map +1 -0
  25. package/dist/extractor/index.js +43 -0
  26. package/dist/extractor/index.js.map +1 -0
  27. package/dist/extractor/interface.d.ts +40 -0
  28. package/dist/extractor/interface.d.ts.map +1 -0
  29. package/dist/extractor/interface.js +233 -0
  30. package/dist/extractor/interface.js.map +1 -0
  31. package/dist/extractor/jsdoc.d.ts +24 -0
  32. package/dist/extractor/jsdoc.d.ts.map +1 -0
  33. package/dist/extractor/jsdoc.js +74 -0
  34. package/dist/extractor/jsdoc.js.map +1 -0
  35. package/dist/extractor/project.d.ts +17 -0
  36. package/dist/extractor/project.d.ts.map +1 -0
  37. package/dist/extractor/project.js +33 -0
  38. package/dist/extractor/project.js.map +1 -0
  39. package/dist/extractor/props.d.ts +24 -0
  40. package/dist/extractor/props.d.ts.map +1 -0
  41. package/dist/extractor/props.js +78 -0
  42. package/dist/extractor/props.js.map +1 -0
  43. package/dist/extractor/type-resolver.d.ts +32 -0
  44. package/dist/extractor/type-resolver.d.ts.map +1 -0
  45. package/dist/extractor/type-resolver.js +129 -0
  46. package/dist/extractor/type-resolver.js.map +1 -0
  47. package/dist/fetcher/index.d.ts +7 -0
  48. package/dist/fetcher/index.d.ts.map +1 -0
  49. package/dist/fetcher/index.js +7 -0
  50. package/dist/fetcher/index.js.map +1 -0
  51. package/dist/fetcher/npm-registry.d.ts +45 -0
  52. package/dist/fetcher/npm-registry.d.ts.map +1 -0
  53. package/dist/fetcher/npm-registry.js +217 -0
  54. package/dist/fetcher/npm-registry.js.map +1 -0
  55. package/dist/fetcher/unified-package.d.ts +27 -0
  56. package/dist/fetcher/unified-package.d.ts.map +1 -0
  57. package/dist/fetcher/unified-package.js +99 -0
  58. package/dist/fetcher/unified-package.js.map +1 -0
  59. package/dist/fetcher/unpkg.d.ts +20 -0
  60. package/dist/fetcher/unpkg.d.ts.map +1 -0
  61. package/dist/fetcher/unpkg.js +57 -0
  62. package/dist/fetcher/unpkg.js.map +1 -0
  63. package/dist/index.d.ts +11 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +23 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/signatures/disambiguation.d.ts +30 -0
  68. package/dist/signatures/disambiguation.d.ts.map +1 -0
  69. package/dist/signatures/disambiguation.js +99 -0
  70. package/dist/signatures/disambiguation.js.map +1 -0
  71. package/dist/signatures/distinguishing.d.ts +29 -0
  72. package/dist/signatures/distinguishing.d.ts.map +1 -0
  73. package/dist/signatures/distinguishing.js +108 -0
  74. package/dist/signatures/distinguishing.js.map +1 -0
  75. package/dist/signatures/generator.d.ts +20 -0
  76. package/dist/signatures/generator.d.ts.map +1 -0
  77. package/dist/signatures/generator.js +147 -0
  78. package/dist/signatures/generator.js.map +1 -0
  79. package/dist/signatures/index.d.ts +10 -0
  80. package/dist/signatures/index.d.ts.map +1 -0
  81. package/dist/signatures/index.js +10 -0
  82. package/dist/signatures/index.js.map +1 -0
  83. package/dist/signatures/inference.d.ts +37 -0
  84. package/dist/signatures/inference.d.ts.map +1 -0
  85. package/dist/signatures/inference.js +132 -0
  86. package/dist/signatures/inference.js.map +1 -0
  87. package/dist/tools/extract-primitive.d.ts +49 -0
  88. package/dist/tools/extract-primitive.d.ts.map +1 -0
  89. package/dist/tools/extract-primitive.js +103 -0
  90. package/dist/tools/extract-primitive.js.map +1 -0
  91. package/dist/tools/index.d.ts +6 -0
  92. package/dist/tools/index.d.ts.map +1 -0
  93. package/dist/tools/index.js +6 -0
  94. package/dist/tools/index.js.map +1 -0
  95. package/dist/tools/list-primitives.d.ts +40 -0
  96. package/dist/tools/list-primitives.d.ts.map +1 -0
  97. package/dist/tools/list-primitives.js +53 -0
  98. package/dist/tools/list-primitives.js.map +1 -0
  99. package/dist/types/index.d.ts +83 -0
  100. package/dist/types/index.d.ts.map +1 -0
  101. package/dist/types/index.js +5 -0
  102. package/dist/types/index.js.map +1 -0
  103. package/package.json +46 -0
@@ -0,0 +1,134 @@
1
+ /**
2
+ * ForwardRefExoticComponent extraction for complex .d.ts files.
3
+ * Handles patterns like: React.ForwardRefExoticComponent<Props & React.RefAttributes<Element>>
4
+ */
5
+ import { extractPropsFromInterface } from './props.js';
6
+ /**
7
+ * Find all ForwardRefExoticComponent variable declarations in a source file.
8
+ */
9
+ export function findForwardRefDeclarations(sourceFile) {
10
+ const results = [];
11
+ for (const statement of sourceFile.getVariableStatements()) {
12
+ for (const decl of statement.getDeclarations()) {
13
+ const typeNode = decl.getTypeNode();
14
+ if (!typeNode)
15
+ continue;
16
+ const typeText = typeNode.getText();
17
+ if (typeText.includes('ForwardRefExoticComponent')) {
18
+ const name = decl.getName();
19
+ const propsTypeName = extractPropsTypeFromForwardRef(typeNode);
20
+ results.push({
21
+ name,
22
+ declaration: decl,
23
+ propsTypeName,
24
+ });
25
+ }
26
+ }
27
+ }
28
+ return results;
29
+ }
30
+ /**
31
+ * Extract the props type name from a ForwardRefExoticComponent type.
32
+ * Handles: ForwardRefExoticComponent<DialogRootProps & React.RefAttributes<...>>
33
+ */
34
+ function extractPropsTypeFromForwardRef(typeNode) {
35
+ const typeText = typeNode.getText();
36
+ // Match pattern: ForwardRefExoticComponent<TypeName & ...>
37
+ // or ForwardRefExoticComponent<TypeName>
38
+ const match = typeText.match(/ForwardRefExoticComponent<\s*(\w+)(?:\s*&|>)/);
39
+ if (match) {
40
+ return match[1];
41
+ }
42
+ return null;
43
+ }
44
+ /**
45
+ * Extract props from a ForwardRef declaration by resolving its type parameter.
46
+ */
47
+ export function extractPropsFromForwardRef(sourceFile, decl) {
48
+ const { propsTypeName, declaration } = decl;
49
+ // Try to find the props interface directly
50
+ if (propsTypeName) {
51
+ const propsInterface = sourceFile.getInterface(propsTypeName);
52
+ if (propsInterface) {
53
+ const props = extractPropsFromInterface(propsInterface);
54
+ return filterRefAttributes(props);
55
+ }
56
+ }
57
+ // Fallback: try to extract from the type directly using ts-morph's type system
58
+ const typeNode = declaration.getTypeNode();
59
+ if (!typeNode)
60
+ return null;
61
+ const props = extractPropsFromTypeNode(sourceFile, typeNode);
62
+ return filterRefAttributes(props);
63
+ }
64
+ /**
65
+ * Extract props from a TypeNode (for inline type definitions).
66
+ */
67
+ function extractPropsFromTypeNode(_sourceFile, typeNode) {
68
+ const props = [];
69
+ // Get the type from the type checker
70
+ const type = typeNode.getType();
71
+ // For ForwardRefExoticComponent, we need the first type argument
72
+ const typeArgs = type.getTypeArguments();
73
+ if (typeArgs.length === 0)
74
+ return props;
75
+ const propsType = typeArgs[0];
76
+ // Get all properties from the type (resolves intersections)
77
+ for (const prop of propsType.getProperties()) {
78
+ const name = prop.getName();
79
+ const declarations = prop.getDeclarations();
80
+ const propDecl = declarations[0];
81
+ if (!propDecl)
82
+ continue;
83
+ // Get the type from the property
84
+ const propType = prop.getTypeAtLocation(propDecl);
85
+ const typeText = propType.getText();
86
+ // Check if optional (has question token or is union with undefined)
87
+ const isOptional = propDecl.getKindName() === 'PropertySignature'
88
+ ? propDecl.hasQuestionToken?.() ?? false
89
+ : typeText.includes('undefined');
90
+ props.push({
91
+ name,
92
+ type: simplifyTypeText(typeText),
93
+ required: !isOptional,
94
+ });
95
+ }
96
+ return props;
97
+ }
98
+ /**
99
+ * Filter out React.RefAttributes props (ref).
100
+ */
101
+ function filterRefAttributes(props) {
102
+ const refAttributeProps = ['ref'];
103
+ return props.filter((p) => !refAttributeProps.includes(p.name));
104
+ }
105
+ /**
106
+ * Simplify complex type text for readability.
107
+ */
108
+ function simplifyTypeText(text) {
109
+ return text
110
+ .replace(/React\.ReactNode/g, 'ReactNode')
111
+ .replace(/React\.ReactElement/g, 'ReactElement')
112
+ .replace(/React\.CSSProperties/g, 'CSSProperties')
113
+ .replace(/React\.HTMLAttributes<.*?>/g, 'HTMLAttributes')
114
+ .replace(/React\.ComponentPropsWithoutRef<.*?>/g, 'ComponentProps')
115
+ .replace(/React\.Ref<.*?>/g, 'Ref')
116
+ .replace(/React\.RefAttributes<.*?>/g, 'RefAttributes')
117
+ .replace(/import\(".*?"\)\./g, '');
118
+ }
119
+ /**
120
+ * Get the sub-component suffix from a component name.
121
+ * @example "DialogContent" with primitive "Dialog" -> "Content"
122
+ */
123
+ export function getSubComponentSuffix(componentName, primitiveName) {
124
+ if (!componentName.startsWith(primitiveName))
125
+ return null;
126
+ const suffix = componentName.slice(primitiveName.length);
127
+ if (!suffix)
128
+ return null;
129
+ // Ensure suffix starts with uppercase (valid sub-component)
130
+ if (!/^[A-Z]/.test(suffix))
131
+ return null;
132
+ return suffix;
133
+ }
134
+ //# sourceMappingURL=forward-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forward-ref.js","sourceRoot":"","sources":["../../src/extractor/forward-ref.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EAAE,yBAAyB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AAC;QAAE,OAAO,IAAI,CAAC;IAE1D,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzD,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAEzB,4DAA4D;IAC5D,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAExC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Type extractor module for parsing Radix type definitions.
3
+ */
4
+ import type { ExtractedPrimitive, PropDefinition, RawProp } from '../types/index.js';
5
+ export { createProject, createSourceFile, parseTypes } from './project.js';
6
+ export { findInterfaces, findPropsInterfaces, extractSubComponents, extractSubComponentsEnhanced, findExports, detectContextUsage, extractContextShape, extractPrimitiveFromSource, } from './interface.js';
7
+ export { findForwardRefDeclarations, extractPropsFromForwardRef, getSubComponentSuffix, } from './forward-ref.js';
8
+ export { resolveTypeAlias, mergeIntersectionTypes, filterReactInternals, resolveTypeReference, } from './type-resolver.js';
9
+ export { extractPropsFromInterface, extractProp, isPropsInterface, componentNameFromProps, } from './props.js';
10
+ export { extractJsDoc, extractDefaultFromComment } from './jsdoc.js';
11
+ export { classifyProp, isStateControl, isEventHandler, isComposition, isConfiguration, getPropCategory, } from './classifier.js';
12
+ /**
13
+ * Extract primitive information from type content.
14
+ *
15
+ * @param typeContent - The .d.ts file content
16
+ * @param primitiveName - The primitive name (e.g., "Dialog")
17
+ * @param version - The package version
18
+ * @returns ExtractedPrimitive with full type information
19
+ */
20
+ export declare function extractPrimitive(typeContent: string, primitiveName: string, version?: string, packageName?: string): ExtractedPrimitive;
21
+ /**
22
+ * Classify an array of raw props into full PropDefinitions.
23
+ */
24
+ export declare function classifyProps(rawProps: RawProp[]): PropDefinition[];
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extractor/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAMrF,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,WAAW,EACX,kBAAkB,EAClB,mBAAmB,EACnB,0BAA0B,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,gBAAgB,EAChB,sBAAsB,GACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,YAAY,CAAC;AACrE,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,aAAa,EACb,eAAe,EACf,eAAe,GAChB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,MAAkB,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB,CAWpB;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,cAAc,EAAE,CAcnE"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Type extractor module for parsing Radix type definitions.
3
+ */
4
+ import { parseTypes } from './project.js';
5
+ import { extractPrimitiveFromSource } from './interface.js';
6
+ import { primitiveToPackage } from '../fetcher/npm-registry.js';
7
+ // Re-export utilities
8
+ export { createProject, createSourceFile, parseTypes } from './project.js';
9
+ export { findInterfaces, findPropsInterfaces, extractSubComponents, extractSubComponentsEnhanced, findExports, detectContextUsage, extractContextShape, extractPrimitiveFromSource, } from './interface.js';
10
+ export { findForwardRefDeclarations, extractPropsFromForwardRef, getSubComponentSuffix, } from './forward-ref.js';
11
+ export { resolveTypeAlias, mergeIntersectionTypes, filterReactInternals, resolveTypeReference, } from './type-resolver.js';
12
+ export { extractPropsFromInterface, extractProp, isPropsInterface, componentNameFromProps, } from './props.js';
13
+ export { extractJsDoc, extractDefaultFromComment } from './jsdoc.js';
14
+ export { classifyProp, isStateControl, isEventHandler, isComposition, isConfiguration, getPropCategory, } from './classifier.js';
15
+ /**
16
+ * Extract primitive information from type content.
17
+ *
18
+ * @param typeContent - The .d.ts file content
19
+ * @param primitiveName - The primitive name (e.g., "Dialog")
20
+ * @param version - The package version
21
+ * @returns ExtractedPrimitive with full type information
22
+ */
23
+ export function extractPrimitive(typeContent, primitiveName, version = 'unknown', packageName) {
24
+ const sourceFile = parseTypes(typeContent);
25
+ const resolvedPackageName = packageName ?? primitiveToPackage(primitiveName.toLowerCase());
26
+ return extractPrimitiveFromSource(sourceFile, primitiveName, resolvedPackageName, version);
27
+ }
28
+ /**
29
+ * Classify an array of raw props into full PropDefinitions.
30
+ */
31
+ export function classifyProps(rawProps) {
32
+ return rawProps.map((raw) => ({
33
+ ...raw,
34
+ isStateControl: raw.name === 'open' ||
35
+ raw.name === 'value' ||
36
+ raw.name === 'checked' ||
37
+ raw.name.startsWith('default'),
38
+ isEventHandler: /^on[A-Z]/.test(raw.name),
39
+ isConfiguration: ['modal', 'orientation', 'side', 'align'].includes(raw.name),
40
+ isComposition: raw.name === 'asChild' || raw.name === 'children',
41
+ }));
42
+ }
43
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/extractor/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,UAAU,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AG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC5B,GAAG,GAAG;QACN,cAAc,EACZ,GAAG,CAAC,IAAI,KAAK,MAAM;YACnB,GAAG,CAAC,IAAI,KAAK,OAAO;YACpB,GAAG,CAAC,IAAI,KAAK,SAAS;YACtB,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC;QAChC,cAAc,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC;QACzC,eAAe,EAAE,CAAC,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CACjE,GAAG,CAAC,IAAI,CACT;QACD,aAAa,EAAE,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,UAAU;KACjE,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Interface extraction from TypeScript source files.
3
+ */
4
+ import type { SourceFile, InterfaceDeclaration } from 'ts-morph';
5
+ import type { SubComponentDefinition, ExtractedPrimitive, PropDefinition } from '../types/index.js';
6
+ /**
7
+ * Find all interfaces in a source file.
8
+ */
9
+ export declare function findInterfaces(sourceFile: SourceFile): InterfaceDeclaration[];
10
+ /**
11
+ * Find props interfaces (names ending with "Props").
12
+ */
13
+ export declare function findPropsInterfaces(sourceFile: SourceFile): InterfaceDeclaration[];
14
+ /**
15
+ * Extract sub-components from props interfaces.
16
+ */
17
+ export declare function extractSubComponents(sourceFile: SourceFile, primitiveName: string): SubComponentDefinition[];
18
+ /**
19
+ * Enhanced sub-component extraction that also handles ForwardRefExoticComponent.
20
+ * This function combines interface-based extraction with ForwardRef detection.
21
+ */
22
+ export declare function extractSubComponentsEnhanced(sourceFile: SourceFile, primitiveName: string): SubComponentDefinition[];
23
+ /**
24
+ * Find exported names from a source file.
25
+ */
26
+ export declare function findExports(sourceFile: SourceFile): string[];
27
+ /**
28
+ * Check if the primitive uses React Context.
29
+ */
30
+ export declare function detectContextUsage(sourceFile: SourceFile): boolean;
31
+ /**
32
+ * Extract context shape if present.
33
+ */
34
+ export declare function extractContextShape(sourceFile: SourceFile, primitiveName: string): PropDefinition[] | undefined;
35
+ /**
36
+ * Extract a complete primitive from a source file.
37
+ * Uses enhanced extraction with ForwardRef support for real .d.ts files.
38
+ */
39
+ export declare function extractPrimitiveFromSource(sourceFile: SourceFile, primitiveName: string, packageName: string, version: string): ExtractedPrimitive;
40
+ //# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../src/extractor/interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,KAAK,EACV,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACf,MAAM,mBAAmB,CAAC;AA+B3B;;GAEG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,UAAU,GAAG,oBAAoB,EAAE,CAE7E;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,GACrB,oBAAoB,EAAE,CAExB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,GACpB,sBAAsB,EAAE,CAkC1B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,GACpB,sBAAsB,EAAE,CA4D1B;AAqCD;;GAEG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,UAAU,GAAG,MAAM,EAAE,CA6B5D;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAOlE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,GACpB,cAAc,EAAE,GAAG,SAAS,CAY9B;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,GACd,kBAAkB,CAwBpB"}
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Interface extraction from TypeScript source files.
3
+ */
4
+ import { extractPropsFromInterface, isPropsInterface } from './props.js';
5
+ import { classifyProp } from './classifier.js';
6
+ import { findForwardRefDeclarations, extractPropsFromForwardRef, getSubComponentSuffix, } from './forward-ref.js';
7
+ import { filterReactInternals } from './type-resolver.js';
8
+ /**
9
+ * Pattern for Radix sub-component naming.
10
+ * @example "DialogRoot", "DialogContent", "DialogTrigger"
11
+ */
12
+ const SUB_COMPONENT_PATTERN = /^([A-Z][a-z]+)(Root|Trigger|Content|Title|Description|Close|Overlay|Portal|Arrow|Item|Indicator|Thumb|Track|Range|Viewport|Scrollbar|Corner|Action|Cancel|Group|Label|Separator|Sub|List|Value|Icon|Image|Fallback)Props$/;
13
+ /**
14
+ * Required sub-components by primitive type.
15
+ */
16
+ const REQUIRED_SUB_COMPONENTS = {
17
+ Dialog: ['Root', 'Trigger', 'Content'],
18
+ AlertDialog: ['Root', 'Trigger', 'Content', 'Action', 'Cancel'],
19
+ Popover: ['Root', 'Trigger', 'Content'],
20
+ Tooltip: ['Root', 'Trigger', 'Content'],
21
+ DropdownMenu: ['Root', 'Trigger', 'Content'],
22
+ ContextMenu: ['Root', 'Trigger', 'Content'],
23
+ Select: ['Root', 'Trigger', 'Value', 'Content'],
24
+ Tabs: ['Root', 'List', 'Trigger', 'Content'],
25
+ Accordion: ['Root', 'Item', 'Trigger', 'Content'],
26
+ };
27
+ /**
28
+ * Find all interfaces in a source file.
29
+ */
30
+ export function findInterfaces(sourceFile) {
31
+ return sourceFile.getInterfaces();
32
+ }
33
+ /**
34
+ * Find props interfaces (names ending with "Props").
35
+ */
36
+ export function findPropsInterfaces(sourceFile) {
37
+ return sourceFile.getInterfaces().filter((i) => isPropsInterface(i.getName()));
38
+ }
39
+ /**
40
+ * Extract sub-components from props interfaces.
41
+ */
42
+ export function extractSubComponents(sourceFile, primitiveName) {
43
+ const subComponents = [];
44
+ const interfaces = findPropsInterfaces(sourceFile);
45
+ const requiredSubs = REQUIRED_SUB_COMPONENTS[primitiveName] || [];
46
+ for (const iface of interfaces) {
47
+ const name = iface.getName();
48
+ // Check if it matches the sub-component pattern
49
+ const match = name.match(SUB_COMPONENT_PATTERN);
50
+ if (match && match[1] === primitiveName) {
51
+ const subName = match[2];
52
+ const rawProps = extractPropsFromInterface(iface);
53
+ const props = rawProps.map(classifyProp);
54
+ subComponents.push({
55
+ name: subName,
56
+ props,
57
+ isRequired: requiredSubs.includes(subName),
58
+ });
59
+ }
60
+ else if (name === `${primitiveName}Props`) {
61
+ // Root component props
62
+ const rawProps = extractPropsFromInterface(iface);
63
+ const props = rawProps.map(classifyProp);
64
+ subComponents.push({
65
+ name: 'Root',
66
+ props,
67
+ isRequired: true,
68
+ });
69
+ }
70
+ }
71
+ return subComponents;
72
+ }
73
+ /**
74
+ * Enhanced sub-component extraction that also handles ForwardRefExoticComponent.
75
+ * This function combines interface-based extraction with ForwardRef detection.
76
+ */
77
+ export function extractSubComponentsEnhanced(sourceFile, primitiveName) {
78
+ const subComponents = [];
79
+ const seenNames = new Set();
80
+ const requiredSubs = REQUIRED_SUB_COMPONENTS[primitiveName] || [];
81
+ // First, try ForwardRef declarations (more common in real .d.ts files)
82
+ const forwardRefDecls = findForwardRefDeclarations(sourceFile);
83
+ for (const decl of forwardRefDecls) {
84
+ const suffix = getSubComponentSuffix(decl.name, primitiveName);
85
+ if (!suffix && decl.name !== primitiveName)
86
+ continue;
87
+ const subName = suffix || 'Root';
88
+ if (seenNames.has(subName))
89
+ continue;
90
+ seenNames.add(subName);
91
+ const rawProps = extractPropsFromForwardRef(sourceFile, decl);
92
+ const filteredProps = rawProps ? filterReactInternals(rawProps) : [];
93
+ const props = filteredProps.map(classifyProp);
94
+ subComponents.push({
95
+ name: subName,
96
+ props,
97
+ isRequired: requiredSubs.includes(subName),
98
+ });
99
+ }
100
+ // Also check for React.FC exports (like DialogPortal)
101
+ const fcDecls = findFCDeclarations(sourceFile, primitiveName);
102
+ for (const { name, propsTypeName } of fcDecls) {
103
+ const suffix = getSubComponentSuffix(name, primitiveName);
104
+ if (!suffix && name !== primitiveName)
105
+ continue;
106
+ const subName = suffix || 'Root';
107
+ if (seenNames.has(subName))
108
+ continue;
109
+ seenNames.add(subName);
110
+ // Try to get props from the interface
111
+ let props = [];
112
+ if (propsTypeName) {
113
+ const propsInterface = sourceFile.getInterface(propsTypeName);
114
+ if (propsInterface) {
115
+ const rawProps = extractPropsFromInterface(propsInterface);
116
+ props = filterReactInternals(rawProps).map(classifyProp);
117
+ }
118
+ }
119
+ subComponents.push({
120
+ name: subName,
121
+ props,
122
+ isRequired: requiredSubs.includes(subName),
123
+ });
124
+ }
125
+ // Fallback: use interface-based extraction if no ForwardRef found
126
+ if (subComponents.length === 0) {
127
+ return extractSubComponents(sourceFile, primitiveName);
128
+ }
129
+ return subComponents;
130
+ }
131
+ /**
132
+ * Find React.FC variable declarations for a primitive.
133
+ */
134
+ function findFCDeclarations(sourceFile, primitiveName) {
135
+ const results = [];
136
+ for (const statement of sourceFile.getVariableStatements()) {
137
+ for (const decl of statement.getDeclarations()) {
138
+ const typeNode = decl.getTypeNode();
139
+ if (!typeNode)
140
+ continue;
141
+ const typeText = typeNode.getText();
142
+ const name = decl.getName();
143
+ // Check if it's React.FC and matches our primitive
144
+ if ((typeText.includes('React.FC') || typeText.includes('FC<')) &&
145
+ name.startsWith(primitiveName)) {
146
+ // Extract props type from FC<PropsType>
147
+ const match = typeText.match(/(?:React\.)?FC<(\w+)>/);
148
+ results.push({
149
+ name,
150
+ propsTypeName: match ? match[1] : null,
151
+ });
152
+ }
153
+ }
154
+ }
155
+ return results;
156
+ }
157
+ /**
158
+ * Find exported names from a source file.
159
+ */
160
+ export function findExports(sourceFile) {
161
+ const exports = [];
162
+ // Get export declarations
163
+ for (const exportDecl of sourceFile.getExportDeclarations()) {
164
+ for (const named of exportDecl.getNamedExports()) {
165
+ exports.push(named.getName());
166
+ }
167
+ }
168
+ // Get export assignments (export default)
169
+ const defaultExport = sourceFile.getDefaultExportSymbol();
170
+ if (defaultExport) {
171
+ exports.push('default');
172
+ }
173
+ // Get directly exported declarations
174
+ for (const stmt of sourceFile.getStatements()) {
175
+ if (stmt.getText().startsWith('export ')) {
176
+ // Try to extract the name
177
+ const text = stmt.getText();
178
+ const match = text.match(/export\s+(?:const|let|var|function|class|interface|type)\s+(\w+)/);
179
+ if (match) {
180
+ exports.push(match[1]);
181
+ }
182
+ }
183
+ }
184
+ return [...new Set(exports)];
185
+ }
186
+ /**
187
+ * Check if the primitive uses React Context.
188
+ */
189
+ export function detectContextUsage(sourceFile) {
190
+ const text = sourceFile.getFullText();
191
+ return (text.includes('createContext') ||
192
+ text.includes('useContext') ||
193
+ text.includes('Provider'));
194
+ }
195
+ /**
196
+ * Extract context shape if present.
197
+ */
198
+ export function extractContextShape(sourceFile, primitiveName) {
199
+ // Look for *ContextValue interface
200
+ const contextInterface = sourceFile.getInterface(`${primitiveName}ContextValue`);
201
+ if (contextInterface) {
202
+ const rawProps = extractPropsFromInterface(contextInterface);
203
+ return rawProps.map(classifyProp);
204
+ }
205
+ return undefined;
206
+ }
207
+ /**
208
+ * Extract a complete primitive from a source file.
209
+ * Uses enhanced extraction with ForwardRef support for real .d.ts files.
210
+ */
211
+ export function extractPrimitiveFromSource(sourceFile, primitiveName, packageName, version) {
212
+ // Try enhanced extraction first (handles ForwardRefExoticComponent)
213
+ let subComponents = extractSubComponentsEnhanced(sourceFile, primitiveName);
214
+ // Fallback to standard extraction if enhanced returns empty
215
+ if (subComponents.length === 0) {
216
+ subComponents = extractSubComponents(sourceFile, primitiveName);
217
+ }
218
+ // Find root props (either from XxxProps or from Root sub-component)
219
+ const rootSubComponent = subComponents.find((s) => s.name === 'Root');
220
+ const rootProps = rootSubComponent?.props || [];
221
+ return {
222
+ name: primitiveName,
223
+ package: packageName,
224
+ version,
225
+ extractedAt: new Date().toISOString(),
226
+ rootProps,
227
+ subComponents,
228
+ exports: findExports(sourceFile),
229
+ usesContext: detectContextUsage(sourceFile),
230
+ contextShape: extractContextShape(sourceFile, primitiveName),
231
+ };
232
+ }
233
+ //# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interface.js","sourceRoot":"","sources":["../../src/extractor/interface.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;GAGG;AACH,MAAM,qBAAqB,GAAG,2NAA2N,CAAC;AAE1P;;GAEG;AACH,MAAM,uBAAuB,GAA6B;IACxD,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;IACtC,WAAW,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,CAAC;IAC/D,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;IACvC,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;IACvC,YAAY,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;IAC5C,WAAW,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC;IAC3C,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC;IAC/C,IAAI,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,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,QAAQ,GAAG,yBAAyB,CAAC,gBAAgB,CAAC,CAAC;QAC7D,OAAO,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACpC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0BAA0B,CACxC,UAAsB,EACtB,aAAqB,EACrB,WAAmB,EACnB,OAAe;IAEf,oEAAoE;IACpE,IAAI,aAAa,GAAG,4BAA4B,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAE5E,4DAA4D;IAC5D,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,aAAa,GAAG,oBAAoB,CAAC,UAAU,EAAE,aAAa,CAAC,CAAC;IAClE,CAAC;IAED,oEAAoE;IACpE,MAAM,gBAAgB,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,gBAAgB,EAAE,KAAK,IAAI,EAAE,CAAC;IAEhD,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,WAAW;QACpB,OAAO;QACP,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACrC,SAAS;QACT,aAAa;QACb,OAAO,EAAE,WAAW,CAAC,UAAU,CAAC;QAChC,WAAW,EAAE,kBAAkB,CAAC,UAAU,CAAC;QAC3C,YAAY,EAAE,mBAAmB,CAAC,UAAU,EAAE,aAAa,CAAC;KAC7D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * JSDoc extraction utilities.
3
+ */
4
+ import type { JSDoc, PropertySignature } from 'ts-morph';
5
+ export interface JsDocInfo {
6
+ description?: string;
7
+ defaultValue?: string;
8
+ deprecated?: boolean;
9
+ see?: string[];
10
+ example?: string;
11
+ }
12
+ /**
13
+ * Extract JSDoc information from a property.
14
+ */
15
+ export declare function extractJsDoc(prop: PropertySignature): JsDocInfo;
16
+ /**
17
+ * Extract @default value from JSDoc comment text.
18
+ * Handles formats like:
19
+ * - @default "value"
20
+ * - @default `value`
21
+ * - @default value
22
+ */
23
+ export declare function extractDefaultFromComment(jsDocs: JSDoc[]): string | undefined;
24
+ //# sourceMappingURL=jsdoc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsdoc.d.ts","sourceRoot":"","sources":["../../src/extractor/jsdoc.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEzD,MAAM,WAAW,SAAS;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,CAuC/D;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,KAAK,EAAE,GACd,MAAM,GAAG,SAAS,CAUpB"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * JSDoc extraction utilities.
3
+ */
4
+ /**
5
+ * Extract JSDoc information from a property.
6
+ */
7
+ export function extractJsDoc(prop) {
8
+ const jsDocs = prop.getJsDocs();
9
+ if (jsDocs.length === 0) {
10
+ return {};
11
+ }
12
+ const result = {};
13
+ const doc = jsDocs[0];
14
+ // Get main description
15
+ const description = doc.getDescription();
16
+ if (description) {
17
+ result.description = description.trim();
18
+ }
19
+ // Parse tags
20
+ for (const tag of doc.getTags()) {
21
+ const tagName = tag.getTagName();
22
+ const text = tag.getText();
23
+ switch (tagName) {
24
+ case 'default':
25
+ case 'defaultValue':
26
+ result.defaultValue = extractTagValue(text);
27
+ break;
28
+ case 'deprecated':
29
+ result.deprecated = true;
30
+ break;
31
+ case 'see':
32
+ result.see = result.see || [];
33
+ result.see.push(extractTagValue(text));
34
+ break;
35
+ case 'example':
36
+ result.example = extractTagValue(text);
37
+ break;
38
+ }
39
+ }
40
+ return result;
41
+ }
42
+ /**
43
+ * Extract @default value from JSDoc comment text.
44
+ * Handles formats like:
45
+ * - @default "value"
46
+ * - @default `value`
47
+ * - @default value
48
+ */
49
+ export function extractDefaultFromComment(jsDocs) {
50
+ for (const doc of jsDocs) {
51
+ for (const tag of doc.getTags()) {
52
+ const tagName = tag.getTagName();
53
+ if (tagName === 'default' || tagName === 'defaultValue') {
54
+ return extractTagValue(tag.getText());
55
+ }
56
+ }
57
+ }
58
+ return undefined;
59
+ }
60
+ /**
61
+ * Extract the value from a JSDoc tag text.
62
+ */
63
+ function extractTagValue(text) {
64
+ // Remove the @tagName part
65
+ const value = text.replace(/^@\w+\s*/, '').trim();
66
+ // Remove surrounding quotes or backticks
67
+ if ((value.startsWith('"') && value.endsWith('"')) ||
68
+ (value.startsWith("'") && value.endsWith("'")) ||
69
+ (value.startsWith('`') && value.endsWith('`'))) {
70
+ return value.slice(1, -1);
71
+ }
72
+ return value;
73
+ }
74
+ //# sourceMappingURL=jsdoc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsdoc.js","sourceRoot":"","sources":["../../src/extractor/jsdoc.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAuB;IAClD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAc,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAEtB,uBAAuB;IACvB,MAAM,WAAW,GAAG,GAAG,CAAC,cAAc,EAA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AAO,SAAS,CAAC;AACnB,CAAC;AAED;;GAEG;AACH,SAAS,eAAe,CAAC,IAAY;IACnC,2BAA2B;IAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAElD,yCAAyC;IACzC,IACE,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAC9C,CAAC;QACD,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ts-morph project setup for parsing type definitions.
3
+ */
4
+ import { Project, SourceFile } from 'ts-morph';
5
+ /**
6
+ * Create a ts-morph Project with in-memory file system.
7
+ */
8
+ export declare function createProject(): Project;
9
+ /**
10
+ * Create a source file from type content.
11
+ */
12
+ export declare function createSourceFile(project: Project, content: string, fileName?: string): SourceFile;
13
+ /**
14
+ * Parse type content and return a source file.
15
+ */
16
+ export declare function parseTypes(content: string): SourceFile;
17
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/extractor/project.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE/C;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAWvC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,OAAO,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,MAAqB,GAC9B,UAAU,CAEZ;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAGtD"}