-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dfdf3cc
commit cf0928f
Showing
4 changed files
with
313 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
/** | ||
* DtsGenerationConfig | ||
* | ||
* This is the configuration object for the DTS generation process. | ||
*/ | ||
export interface DtsGenerationConfig { | ||
cwd: string | ||
root: string | ||
entrypoints: string[] | ||
outdir: string | ||
keepComments: boolean | ||
clean: boolean | ||
tsconfigPath: string | ||
verbose: boolean | ||
} | ||
|
||
/** | ||
* DtsGenerationOption | ||
* | ||
* This is the configuration object for the DTS generation process. | ||
*/ | ||
export type DtsGenerationOption = Partial<DtsGenerationConfig> | ||
|
||
/** | ||
* DtsGenerationOptions | ||
* | ||
* This is the configuration object for the DTS generation process. | ||
*/ | ||
export type DtsGenerationOptions = DtsGenerationOption | DtsGenerationOption[] | ||
|
||
/** | ||
* Regular expression patterns used throughout the module | ||
*/ | ||
export interface RegexPatterns { | ||
/** Import type declarations */ | ||
readonly typeImport: RegExp | ||
/** Regular import declarations */ | ||
readonly regularImport: RegExp | ||
/** Opening brackets and braces */ | ||
readonly bracketOpen: RegExp | ||
/** Closing brackets and braces */ | ||
readonly bracketClose: RegExp | ||
/** Function return statements */ | ||
readonly functionReturn: RegExp | ||
/** Type annotation patterns */ | ||
readonly typeAnnotation: RegExp | ||
/** Async function declarations */ | ||
readonly asyncFunction: RegExp | ||
/** Generic type parameters */ | ||
readonly genericParams: RegExp | ||
/** Function parameter block */ | ||
readonly functionParams: RegExp | ||
/** Return type declaration */ | ||
readonly functionReturnType: RegExp | ||
/** Destructured parameters */ | ||
readonly destructuredParams: RegExp | ||
/** Type pattern matching */ | ||
readonly typePattern: RegExp | ||
/** Value reference pattern */ | ||
readonly valueReference: RegExp | ||
/** Type reference pattern */ | ||
readonly typeReference: RegExp | ||
/** Function name extraction */ | ||
readonly functionName: RegExp | ||
/** Export statement cleanup */ | ||
readonly exportCleanup: RegExp | ||
/** Default export */ | ||
readonly defaultExport: RegExp | ||
/** Named export */ | ||
readonly complexType: RegExp | ||
/** Union and intersection types */ | ||
readonly unionIntersection: RegExp | ||
/** Conditional types */ | ||
readonly mappedType: RegExp | ||
/** Conditional types */ | ||
readonly conditionalType: RegExp | ||
/** Generic constraints */ | ||
readonly genericConstraints: RegExp | ||
/** Function overload */ | ||
readonly functionOverload: RegExp | ||
/** Module declaration pattern */ | ||
readonly moduleDeclaration: RegExp | ||
/** Module augmentation pattern */ | ||
readonly moduleAugmentation: RegExp | ||
} | ||
|
||
export interface ImportTrackingState { | ||
typeImports: Map<string, Set<string>> // module -> Set of type names | ||
valueImports: Map<string, Set<string>> // module -> Set of value names | ||
usedTypes: Set<string> // All used type names | ||
usedValues: Set<string> // All used value names | ||
exportedTypes: Set<string> // Types that are exported | ||
exportedValues: Set<string> // Values that are exported | ||
valueAliases: Map<string, string> // alias -> original name mapping | ||
importSources: Map<string, string> // name -> module mapping | ||
typeExportSources: Map<string, string> // type name -> source module for type exports | ||
defaultExportValue?: string // The value being default exported | ||
} | ||
|
||
export interface ProcessingState { | ||
dtsLines: string[] | ||
imports: string[] | ||
usedTypes: Set<string> | ||
typeSources: Map<string, string> | ||
defaultExport: string | null | ||
exportAllStatements: string[] | ||
currentDeclaration: string | ||
lastCommentBlock: string | ||
bracketCount: number | ||
isMultiLineDeclaration: boolean | ||
moduleImports: Map<string, ImportInfo> | ||
availableTypes: Map<string, string> | ||
availableValues: Map<string, string> | ||
currentIndentation: string | ||
declarationBuffer: { | ||
type: 'interface' | 'type' | 'const' | 'function' | 'import' | 'export' | ||
indent: string | ||
lines: string[] | ||
comments: string[] | ||
} | null | ||
importTracking: ImportTrackingState | ||
defaultExports: Set<string> | ||
currentScope: 'top' | 'function' | ||
} | ||
|
||
export interface MethodSignature { | ||
name: string | ||
async: boolean | ||
generics: string | ||
params: string | ||
returnType: string | ||
} | ||
|
||
/** | ||
* Represents property type information with support for nested structures | ||
*/ | ||
export interface PropertyInfo { | ||
/** Property identifier */ | ||
key: string | ||
/** Original source value */ | ||
value: string | ||
/** Inferred TypeScript type */ | ||
type: string | ||
/** Nested property definitions */ | ||
nested?: PropertyInfo[] | ||
method?: MethodSignature | ||
} | ||
|
||
/** | ||
* Import statement metadata and tracking | ||
*/ | ||
export interface ImportInfo { | ||
/** Import kind: type, value, or mixed */ | ||
kind: 'type' | 'value' | 'mixed' | ||
/** Set of used type imports */ | ||
usedTypes: Set<string> | ||
/** Set of used value imports */ | ||
usedValues: Set<string> | ||
/** Source module path */ | ||
source: string | ||
} | ||
|
||
/** | ||
* Function signature components | ||
*/ | ||
export interface FunctionSignature { | ||
name: string | ||
params: string | ||
returnType: string | ||
generics: string | ||
} | ||
|
||
export interface ProcessedMethod { | ||
name: string | ||
signature: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
export declare interface DtsGenerationConfig { | ||
cwd: string | ||
root: string | ||
entrypoints: string[] | ||
outdir: string | ||
keepComments: boolean | ||
clean: boolean | ||
tsconfigPath: string | ||
verbose: boolean | ||
} | ||
export declare type DtsGenerationOption = Partial<DtsGenerationConfig> | ||
export declare type DtsGenerationOptions = DtsGenerationOption | DtsGenerationOption[] | ||
export declare interface RegexPatterns { | ||
readonly typeImport: RegExp | ||
readonly regularImport: RegExp | ||
readonly bracketOpen: RegExp | ||
readonly bracketClose: RegExp | ||
readonly functionReturn: RegExp | ||
readonly typeAnnotation: RegExp | ||
readonly asyncFunction: RegExp | ||
readonly genericParams: RegExp | ||
readonly functionParams: RegExp | ||
readonly functionReturnType: RegExp | ||
readonly destructuredParams: RegExp | ||
readonly typePattern: RegExp | ||
readonly valueReference: RegExp | ||
readonly typeReference: RegExp | ||
readonly functionName: RegExp | ||
readonly exportCleanup: RegExp | ||
readonly defaultExport: RegExp | ||
readonly complexType: RegExp | ||
readonly unionIntersection: RegExp | ||
readonly mappedType: RegExp | ||
readonly conditionalType: RegExp | ||
readonly genericConstraints: RegExp | ||
readonly functionOverload: RegExp | ||
readonly moduleDeclaration: RegExp | ||
readonly moduleAugmentation: RegExp | ||
} | ||
export declare interface ImportTrackingState { | ||
typeImports: Map<string, Set<string>> | ||
valueImports: Map<string, Set<string>> | ||
usedTypes: Set<string> | ||
usedValues: Set<string> | ||
exportedTypes: Set<string> | ||
exportedValues: Set<string> | ||
valueAliases: Map<string, string> | ||
importSources: Map<string, string> | ||
typeExportSources: Map<string, string> | ||
defaultExportValue?: string | ||
} | ||
export declare interface ProcessingState { | ||
dtsLines: string[] | ||
imports: string[] | ||
usedTypes: Set<string> | ||
typeSources: Map<string, string> | ||
defaultExport: string | null | ||
exportAllStatements: string[] | ||
currentDeclaration: string | ||
lastCommentBlock: string | ||
bracketCount: number | ||
isMultiLineDeclaration: boolean | ||
moduleImports: Map<string, ImportInfo> | ||
availableTypes: Map<string, string> | ||
availableValues: Map<string, string> | ||
currentIndentation: string | ||
declarationBuffer: { | ||
type: 'interface' | 'type' | 'const' | 'function' | 'import' | 'export' | ||
indent: string | ||
lines: string[] | ||
comments: string[] | ||
} | null | ||
importTracking: ImportTrackingState | ||
defaultExports: Set<string> | ||
currentScope: 'top' | 'function' | ||
} | ||
export declare interface MethodSignature { | ||
name: string | ||
async: boolean | ||
generics: string | ||
params: string | ||
returnType: string | ||
} | ||
export declare interface PropertyInfo { | ||
key: string | ||
value: string | ||
type: string | ||
nested?: PropertyInfo[] | ||
method?: MethodSignature | ||
} | ||
export declare interface ImportInfo { | ||
kind: 'type' | 'value' | 'mixed' | ||
usedTypes: Set<string> | ||
usedValues: Set<string> | ||
source: string | ||
} | ||
export declare interface FunctionSignature { | ||
name: string | ||
params: string | ||
returnType: string | ||
generics: string | ||
} | ||
export declare interface ProcessedMethod { | ||
name: string | ||
signature: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.