@stacksjs/dtsx 0.8.2 → 0.9.2
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.
- package/dist/bin/cli.js +489 -0
- package/dist/config.d.ts +3 -2
- package/dist/extractor.d.ts +6 -0
- package/dist/generator.d.ts +9 -0
- package/dist/index.d.ts +7 -6
- package/dist/parser.d.ts +52 -0
- package/dist/processor.d.ts +45 -0
- package/dist/src/index.js +483 -0
- package/dist/types.d.ts +72 -99
- package/dist/utils.d.ts +2 -3
- package/package.json +12 -24
- package/LICENSE.md +0 -21
- package/README.md +0 -192
- package/dist/cli.js +0 -389
- package/dist/extract.d.ts +0 -68
- package/dist/generate.d.ts +0 -4
- package/dist/index.js +0 -46
package/dist/config.d.ts
CHANGED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Declaration } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Extract only public API declarations from TypeScript source code
|
|
4
|
+
* This focuses on what should be in .d.ts files, not implementation details
|
|
5
|
+
*/
|
|
6
|
+
export declare function extractDeclarations(sourceCode: string, filePath: string, keepComments?: boolean): Declaration[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DtsGenerationConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Generate DTS files from TypeScript source files
|
|
4
|
+
*/
|
|
5
|
+
export declare function generate(options?: Partial<DtsGenerationConfig>): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* Process a single TypeScript file and generate its DTS
|
|
8
|
+
*/
|
|
9
|
+
export declare function processFile(filePath: string, config: DtsGenerationConfig): Promise<string>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * from './extractor';
|
|
3
|
+
export * from './generator';
|
|
4
|
+
export * from './parser';
|
|
5
|
+
export * from './processor';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './utils';
|
package/dist/parser.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove leading comments from a declaration
|
|
3
|
+
*/
|
|
4
|
+
/* eslint-disable regexp/no-super-linear-backtracking */
|
|
5
|
+
export declare function removeLeadingComments(text: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Extract leading comments from source code before a position
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractLeadingComments(source: string, position: number): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Extract trailing comments from a line
|
|
12
|
+
*/
|
|
13
|
+
export declare function extractTrailingComment(line: string): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* Format comments for output
|
|
16
|
+
*/
|
|
17
|
+
export declare function formatComments(comments: string[]): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Extract balanced content between symbols (e.g., <>, (), {})
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractBalancedSymbols(text: string, openSymbol: string, closeSymbol: string): { content: string, rest: string } | null;
|
|
22
|
+
/**
|
|
23
|
+
* Parse a function declaration
|
|
24
|
+
*/
|
|
25
|
+
export declare function parseFunctionDeclaration(text: string): FunctionSignature | null;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a line is an export statement
|
|
28
|
+
*/
|
|
29
|
+
export declare function isExportStatement(line: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a line is a type-only export
|
|
32
|
+
*/
|
|
33
|
+
export declare function isTypeOnlyExport(line: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Extract variable name and type from declaration
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseVariableDeclaration(text: string): {
|
|
38
|
+
name: string
|
|
39
|
+
kind: 'const' | 'let' | 'var'
|
|
40
|
+
typeAnnotation?: string
|
|
41
|
+
value?: string
|
|
42
|
+
} | null;
|
|
43
|
+
/**
|
|
44
|
+
* Extract function signature parts
|
|
45
|
+
*/
|
|
46
|
+
export declare interface FunctionSignature {
|
|
47
|
+
name: string
|
|
48
|
+
generics: string
|
|
49
|
+
parameters: string
|
|
50
|
+
returnType: string
|
|
51
|
+
modifiers: string[]
|
|
52
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Declaration, ProcessingContext } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Process declarations and convert them to narrow DTS format
|
|
4
|
+
*/
|
|
5
|
+
export declare function processDeclarations(declarations: Declaration[], context: ProcessingContext, keepComments?: boolean): string;
|
|
6
|
+
/**
|
|
7
|
+
* Process function declaration to DTS format
|
|
8
|
+
*/
|
|
9
|
+
export declare function processFunctionDeclaration(decl: Declaration, keepComments?: boolean): string;
|
|
10
|
+
/**
|
|
11
|
+
* Process variable declaration to DTS format
|
|
12
|
+
*/
|
|
13
|
+
export declare function processVariableDeclaration(decl: Declaration, keepComments?: boolean): string;
|
|
14
|
+
/**
|
|
15
|
+
* Process interface declaration to DTS format
|
|
16
|
+
*/
|
|
17
|
+
export declare function processInterfaceDeclaration(decl: Declaration, keepComments?: boolean): string;
|
|
18
|
+
/**
|
|
19
|
+
* Process type alias declaration to DTS format
|
|
20
|
+
*/
|
|
21
|
+
export declare function processTypeDeclaration(decl: Declaration, keepComments?: boolean): string;
|
|
22
|
+
/**
|
|
23
|
+
* Process class declaration to DTS format
|
|
24
|
+
*/
|
|
25
|
+
export declare function processClassDeclaration(decl: Declaration, keepComments?: boolean): string;
|
|
26
|
+
/**
|
|
27
|
+
* Process enum declaration to DTS format
|
|
28
|
+
*/
|
|
29
|
+
export declare function processEnumDeclaration(decl: Declaration, keepComments?: boolean): string;
|
|
30
|
+
/**
|
|
31
|
+
* Process import statement
|
|
32
|
+
*/
|
|
33
|
+
export declare function processImportDeclaration(decl: Declaration): string;
|
|
34
|
+
/**
|
|
35
|
+
* Process export statement
|
|
36
|
+
*/
|
|
37
|
+
export declare function processExportDeclaration(decl: Declaration): string;
|
|
38
|
+
/**
|
|
39
|
+
* Process module/namespace declaration to DTS format
|
|
40
|
+
*/
|
|
41
|
+
export declare function processModuleDeclaration(decl: Declaration, keepComments?: boolean): string;
|
|
42
|
+
/**
|
|
43
|
+
* Infer and narrow types from values
|
|
44
|
+
*/
|
|
45
|
+
export declare function inferNarrowType(value: any, isConst?: boolean): string;
|