@stacksjs/dtsx 0.9.9 → 0.9.10
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/LICENSE.md +21 -0
- package/README.md +243 -15
- package/dist/bin/cli.js +10 -22
- package/dist/branded-types.d.ts +168 -0
- package/dist/bundler.d.ts +55 -0
- package/dist/cache.d.ts +43 -0
- package/dist/checker.d.ts +107 -0
- package/dist/chunk-09zp67d8.js +6 -0
- package/dist/chunk-0kmfaaz6.js +2 -0
- package/dist/chunk-1mm3t0nr.js +3 -0
- package/dist/chunk-2f046tgr.js +2 -0
- package/dist/chunk-3g2v2ns2.js +2 -0
- package/dist/chunk-3j7r0fxz.js +2 -0
- package/dist/chunk-3mxzfgcv.js +75 -0
- package/dist/chunk-4ev1n7r7.js +3 -0
- package/dist/chunk-57agx6g8.js +3 -0
- package/dist/chunk-6ppqaypd.js +2 -0
- package/dist/chunk-6qv7p9sg.js +170 -0
- package/dist/chunk-6s7n1gt0.js +2 -0
- package/dist/chunk-74j5mydx.js +3 -0
- package/dist/chunk-7cpp6v8f.js +2 -0
- package/dist/chunk-9a3jfxnc.js +3 -0
- package/dist/chunk-9mjc7ddv.js +19 -0
- package/dist/chunk-axb2kjeq.js +2 -0
- package/dist/chunk-bn29kee5.js +102 -0
- package/dist/chunk-c18vx9sq.js +2 -0
- package/dist/chunk-d0p3jzwb.js +34 -0
- package/dist/chunk-dk2vv0np.js +15 -0
- package/dist/chunk-e3j9tecw.js +3 -0
- package/dist/chunk-f18nyrrb.js +32 -0
- package/dist/chunk-fbqcsr60.js +22 -0
- package/dist/chunk-ffqpf34b.js +3 -0
- package/dist/chunk-fw6wcdfd.js +4 -0
- package/dist/chunk-h12gdfk9.js +2 -0
- package/dist/chunk-j22v8wfe.js +33 -0
- package/dist/chunk-jm5ywn4e.js +13 -0
- package/dist/chunk-jvz9t6pq.js +2 -0
- package/dist/chunk-k5h5ppp5.js +2 -0
- package/dist/chunk-p1d09y82.js +449 -0
- package/dist/chunk-pyxbb193.js +2 -0
- package/dist/chunk-q75q4w1s.js +3 -0
- package/dist/chunk-r1m3q3dj.js +2 -0
- package/dist/chunk-r1ywapeb.js +6 -0
- package/dist/chunk-rnt0wkrk.js +23 -0
- package/dist/chunk-rrkq4k1n.js +2 -0
- package/dist/chunk-rw6j20e2.js +3 -0
- package/dist/chunk-v96rjx7x.js +134 -0
- package/dist/circular.d.ts +82 -0
- package/dist/compat.d.ts +108 -0
- package/dist/config.d.ts +33 -3
- package/dist/diff.d.ts +82 -0
- package/dist/docs.d.ts +97 -0
- package/dist/errors.d.ts +113 -0
- package/dist/extractor/builders.d.ts +38 -0
- package/dist/extractor/cache.d.ts +47 -0
- package/dist/extractor/declarations.d.ts +50 -0
- package/dist/extractor/directives.d.ts +9 -0
- package/dist/extractor/extract.d.ts +10 -0
- package/dist/extractor/hash.d.ts +1 -0
- package/dist/extractor/helpers.d.ts +39 -0
- package/dist/extractor/index.d.ts +70 -0
- package/dist/extractor/scanner.d.ts +6 -0
- package/dist/extractor.d.ts +3 -4
- package/dist/formats.d.ts +50 -0
- package/dist/formatter.d.ts +61 -0
- package/dist/generator.d.ts +12 -3
- package/dist/import-sorter.d.ts +99 -0
- package/dist/incremental.d.ts +84 -0
- package/dist/index.d.ts +54 -1
- package/dist/logger.d.ts +57 -0
- package/dist/lsp.d.ts +317 -0
- package/dist/memory.d.ts +110 -0
- package/dist/merger.d.ts +38 -0
- package/dist/optimizer.d.ts +52 -0
- package/dist/output-normalizer.d.ts +123 -0
- package/dist/parallel-processor.d.ts +63 -0
- package/dist/parser.d.ts +24 -15
- package/dist/plugins/bun.d.ts +58 -0
- package/dist/plugins/esbuild.d.ts +63 -0
- package/dist/plugins/index.d.ts +14 -0
- package/dist/plugins/tsup.d.ts +53 -0
- package/dist/plugins/vite.d.ts +49 -0
- package/dist/plugins/webpack.d.ts +66 -0
- package/dist/plugins.d.ts +83 -0
- package/dist/process-source.d.ts +11 -0
- package/dist/processor/cache.d.ts +16 -0
- package/dist/processor/comments.d.ts +7 -0
- package/dist/processor/declarations.d.ts +37 -0
- package/dist/processor/imports.d.ts +65 -0
- package/dist/processor/index.d.ts +34 -0
- package/dist/processor/type-inference.d.ts +106 -0
- package/dist/processor.d.ts +3 -43
- package/dist/profiling.d.ts +101 -0
- package/dist/security.d.ts +100 -0
- package/dist/sourcemap.d.ts +125 -0
- package/dist/src/index.js +55 -2
- package/dist/src/plugins/bun.js +2 -0
- package/dist/src/plugins/esbuild.js +2 -0
- package/dist/src/plugins/index.js +2 -0
- package/dist/src/plugins/tsup.js +2 -0
- package/dist/src/plugins/vite.js +2 -0
- package/dist/src/plugins/webpack.js +2 -0
- package/dist/tracking.d.ts +89 -0
- package/dist/transformers.d.ts +173 -0
- package/dist/tree-shaker.d.ts +69 -0
- package/dist/type-mappings.d.ts +148 -0
- package/dist/types.d.ts +137 -7
- package/dist/utils.d.ts +53 -1
- package/dist/watcher.d.ts +64 -0
- package/dist/worker.d.ts +84 -0
- package/dist/workspace.d.ts +62 -0
- package/package.json +49 -11
- package/dist/chunk-qsyn1k3w.js +0 -504
package/dist/compat.d.ts
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ChildProcess } from 'node:child_process';
|
|
2
|
+
/**
|
|
3
|
+
* Cross-runtime file handle creator
|
|
4
|
+
* Compatible with Bun.file() API
|
|
5
|
+
*/
|
|
6
|
+
export declare function file(path: string): FileHandle;
|
|
7
|
+
/**
|
|
8
|
+
* Cross-runtime file writer
|
|
9
|
+
* Compatible with Bun.write() API
|
|
10
|
+
*/
|
|
11
|
+
export declare function write(path: string, content: string | Uint8Array | ArrayBuffer): Promise<number>;
|
|
12
|
+
/**
|
|
13
|
+
* Cross-runtime process spawner
|
|
14
|
+
* Compatible with Bun.spawn() API
|
|
15
|
+
*/
|
|
16
|
+
export declare function spawnProcess(command: string | string[], options?: CompatSpawnOptions): SpawnResult;
|
|
17
|
+
/**
|
|
18
|
+
* Read a file as text with cross-runtime compatibility
|
|
19
|
+
*/
|
|
20
|
+
export declare function readTextFile(path: string): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a file exists with cross-runtime compatibility
|
|
23
|
+
*/
|
|
24
|
+
export declare function fileExists(path: string): Promise<boolean>;
|
|
25
|
+
/**
|
|
26
|
+
* Write text to a file with cross-runtime compatibility
|
|
27
|
+
*/
|
|
28
|
+
export declare function writeTextFile(path: string, content: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Get runtime information
|
|
31
|
+
*/
|
|
32
|
+
export declare function getRuntimeInfo(): RuntimeInfo;
|
|
33
|
+
/**
|
|
34
|
+
* Runtime detection
|
|
35
|
+
*/
|
|
36
|
+
export declare const isBun: boolean;
|
|
37
|
+
export declare const isNode: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Current runtime name
|
|
40
|
+
*/
|
|
41
|
+
export declare const runtime: 'bun' | 'node';
|
|
42
|
+
/**
|
|
43
|
+
* File handle interface compatible with Bun.file()
|
|
44
|
+
*/
|
|
45
|
+
export declare interface FileHandle {
|
|
46
|
+
exists: () => Promise<boolean>
|
|
47
|
+
text: () => Promise<string>
|
|
48
|
+
arrayBuffer: () => Promise<ArrayBuffer>
|
|
49
|
+
size: number
|
|
50
|
+
name: string
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Spawn result interface compatible with Bun.spawn()
|
|
54
|
+
*/
|
|
55
|
+
export declare interface SpawnResult {
|
|
56
|
+
pid: number
|
|
57
|
+
stdout: ReadableStream<Uint8Array> | NodeJS.ReadableStream
|
|
58
|
+
stderr: ReadableStream<Uint8Array> | NodeJS.ReadableStream
|
|
59
|
+
stdin: WritableStream<Uint8Array> | NodeJS.WritableStream | null
|
|
60
|
+
exited: Promise<number>
|
|
61
|
+
kill: (signal?: number) => void
|
|
62
|
+
ref: () => void
|
|
63
|
+
unref: () => void
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Spawn options compatible with Bun.spawn()
|
|
67
|
+
*/
|
|
68
|
+
export declare interface CompatSpawnOptions {
|
|
69
|
+
cwd?: string
|
|
70
|
+
env?: Record<string, string | undefined>
|
|
71
|
+
stdin?: 'inherit' | 'pipe' | 'ignore' | null
|
|
72
|
+
stdout?: 'inherit' | 'pipe' | 'ignore' | null
|
|
73
|
+
stderr?: 'inherit' | 'pipe' | 'ignore' | null
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Runtime information
|
|
77
|
+
*/
|
|
78
|
+
export declare interface RuntimeInfo {
|
|
79
|
+
name: 'bun' | 'node'
|
|
80
|
+
version: string
|
|
81
|
+
isBun: boolean
|
|
82
|
+
isNode: boolean
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Node.js implementation of Bun-like file handle
|
|
86
|
+
*/
|
|
87
|
+
declare class NodeFileHandle implements FileHandle {
|
|
88
|
+
name: string;
|
|
89
|
+
constructor(path: string);
|
|
90
|
+
exists(): Promise<boolean>;
|
|
91
|
+
text(): Promise<string>;
|
|
92
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
93
|
+
get size(): number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Node.js implementation of Bun-like spawn result
|
|
97
|
+
*/
|
|
98
|
+
declare class NodeSpawnResult implements SpawnResult {
|
|
99
|
+
pid: number;
|
|
100
|
+
stdout: NodeJS.ReadableStream;
|
|
101
|
+
stderr: NodeJS.ReadableStream;
|
|
102
|
+
stdin: NodeJS.WritableStream | null;
|
|
103
|
+
exited: Promise<number>;
|
|
104
|
+
constructor(proc: ChildProcess);
|
|
105
|
+
kill(signal?: number): void;
|
|
106
|
+
ref(): void;
|
|
107
|
+
unref(): void;
|
|
108
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import type { DtsGenerationConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the configuration, loading from config file if available
|
|
4
|
+
*/
|
|
5
|
+
export declare function getConfig(cwd?: string): Promise<DtsGenerationConfig>;
|
|
6
|
+
/**
|
|
7
|
+
* Reset the cached config (useful for testing)
|
|
8
|
+
*/
|
|
9
|
+
export declare function resetConfig(): void;
|
|
10
|
+
/*.ts'],
|
|
11
|
+
* keepComments: true,
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function defineConfig(config: Partial<DtsGenerationConfig>): DtsGenerationConfig;
|
|
16
|
+
/**
|
|
17
|
+
* Define a dtsx configuration with async support
|
|
18
|
+
* Allows loading plugins or other async dependencies
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* // dtsx.config.ts
|
|
23
|
+
* import { defineConfigAsync } from 'dtsx'
|
|
24
|
+
*
|
|
25
|
+
* export default defineConfigAsync(async () => ({
|
|
26
|
+
* root: './src',
|
|
27
|
+
* outdir: './dist',
|
|
28
|
+
* plugins: [await loadPlugin()],
|
|
29
|
+
* }))
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function defineConfigAsync(configFn: () => Promise<Partial<DtsGenerationConfig>>): () => Promise<DtsGenerationConfig>;
|
|
2
33
|
export declare const defaultConfig: DtsGenerationConfig;
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export declare const config: DtsGenerationConfig;
|
|
34
|
+
// For backwards compatibility - synchronous access with default fallback
|
|
35
|
+
export declare const config: DtsGenerationConfig;
|
package/dist/diff.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute diff between two strings
|
|
3
|
+
*/
|
|
4
|
+
export declare function computeDiff(oldContent: string, newContent: string, filePath: string, options?: DiffOptions): DiffResult;
|
|
5
|
+
/**
|
|
6
|
+
* Format diff result as unified diff string
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatUnifiedDiff(result: DiffResult): string;
|
|
9
|
+
/**
|
|
10
|
+
* Format diff with colors for terminal output
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatColoredDiff(result: DiffResult): string;
|
|
13
|
+
/**
|
|
14
|
+
* Format diff as simple summary
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatDiffSummary(result: DiffResult): string;
|
|
17
|
+
/**
|
|
18
|
+
* Compare a file against new content
|
|
19
|
+
*/
|
|
20
|
+
export declare function diffFile(filePath: string, newContent: string, options?: DiffOptions): Promise<DiffResult>;
|
|
21
|
+
/**
|
|
22
|
+
* Compare multiple files
|
|
23
|
+
*/
|
|
24
|
+
export declare function diffFiles(files: Map<string, string>, options?: DiffOptions): Promise<Map<string, DiffResult>>;
|
|
25
|
+
/**
|
|
26
|
+
* Generate a summary of all diffs
|
|
27
|
+
*/
|
|
28
|
+
export declare function summarizeDiffs(results: Map<string, DiffResult>): {
|
|
29
|
+
totalFiles: number
|
|
30
|
+
changedFiles: number
|
|
31
|
+
unchangedFiles: number
|
|
32
|
+
totalAdditions: number
|
|
33
|
+
totalDeletions: number
|
|
34
|
+
newFiles: number
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Print colored diff to console
|
|
38
|
+
*/
|
|
39
|
+
export declare function printDiff(result: DiffResult): void;
|
|
40
|
+
/**
|
|
41
|
+
* Print all diffs to console
|
|
42
|
+
*/
|
|
43
|
+
export declare function printDiffs(results: Map<string, DiffResult>, showUnchanged?: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* A single diff hunk (change)
|
|
46
|
+
*/
|
|
47
|
+
export declare interface DiffHunk {
|
|
48
|
+
operation: DiffOperation
|
|
49
|
+
lines: string[]
|
|
50
|
+
oldStart: number
|
|
51
|
+
oldCount: number
|
|
52
|
+
newStart: number
|
|
53
|
+
newCount: number
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Complete diff result
|
|
57
|
+
*/
|
|
58
|
+
export declare interface DiffResult {
|
|
59
|
+
filePath: string
|
|
60
|
+
identical: boolean
|
|
61
|
+
hunks: DiffHunk[]
|
|
62
|
+
stats: {
|
|
63
|
+
additions: number
|
|
64
|
+
deletions: number
|
|
65
|
+
unchanged: number
|
|
66
|
+
}
|
|
67
|
+
oldContent?: string
|
|
68
|
+
newContent: string
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Options for diff generation
|
|
72
|
+
*/
|
|
73
|
+
export declare interface DiffOptions {
|
|
74
|
+
context?: number
|
|
75
|
+
ignoreWhitespace?: boolean
|
|
76
|
+
ignoreBlankLines?: boolean
|
|
77
|
+
treatMissingAsEmpty?: boolean
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Diff operation type
|
|
81
|
+
*/
|
|
82
|
+
export type DiffOperation = 'add' | 'remove' | 'equal';
|
package/dist/docs.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { Declaration } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse JSDoc comments from a declaration
|
|
4
|
+
*/
|
|
5
|
+
export declare function parseJSDoc(comments: string[] | undefined): JSDocInfo;
|
|
6
|
+
/**
|
|
7
|
+
* Extract documentation from source files
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractDocumentation(files: string[], config?: Partial<DocsConfig>): Promise<Documentation>;
|
|
10
|
+
/**
|
|
11
|
+
* Generate markdown documentation
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateMarkdown(docs: Documentation, config?: Partial<DocsConfig>): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate HTML documentation
|
|
16
|
+
*/
|
|
17
|
+
export declare function generateHTML(docs: Documentation, config?: Partial<DocsConfig>): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate JSON documentation
|
|
20
|
+
*/
|
|
21
|
+
export declare function generateJSON(docs: Documentation, config?: Partial<DocsConfig>): string;
|
|
22
|
+
/**
|
|
23
|
+
* Generate documentation in TypeDoc-compatible JSON format
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateTypeDocJSON(docs: Documentation): string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate and write documentation files
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateDocs(files: string[], config: DocsConfig): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* Create a documentation generator with preset configuration
|
|
32
|
+
*/
|
|
33
|
+
export declare function createDocsGenerator(config?: Partial<DocsConfig>): {
|
|
34
|
+
extract: (files: string[]) => Promise<Documentation>
|
|
35
|
+
generateMarkdown: (docs: Documentation) => string
|
|
36
|
+
generateHTML: (docs: Documentation) => string
|
|
37
|
+
generateJSON: (docs: Documentation) => string
|
|
38
|
+
parseJSDoc: typeof parseJSDoc
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Documentation configuration
|
|
42
|
+
*/
|
|
43
|
+
export declare interface DocsConfig {
|
|
44
|
+
format: 'markdown' | 'html' | 'json'
|
|
45
|
+
outdir: string
|
|
46
|
+
includePrivate?: boolean
|
|
47
|
+
includeInternal?: boolean
|
|
48
|
+
groupByCategory?: boolean
|
|
49
|
+
title?: string
|
|
50
|
+
description?: string
|
|
51
|
+
includeSourceLinks?: boolean
|
|
52
|
+
sourceBaseUrl?: string
|
|
53
|
+
includeTypes?: boolean
|
|
54
|
+
splitByModule?: boolean
|
|
55
|
+
template?: 'default' | 'minimal' | 'detailed'
|
|
56
|
+
customCss?: string
|
|
57
|
+
includeSidebar?: boolean
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parsed JSDoc information
|
|
61
|
+
*/
|
|
62
|
+
export declare interface JSDocInfo {
|
|
63
|
+
description: string
|
|
64
|
+
params: Array<{ name: string, type?: string, description: string, optional?: boolean }>
|
|
65
|
+
returns?: { type?: string, description: string }
|
|
66
|
+
examples: string[]
|
|
67
|
+
tags: Record<string, string[]>
|
|
68
|
+
deprecated?: string
|
|
69
|
+
since?: string
|
|
70
|
+
see: string[]
|
|
71
|
+
throws: Array<{ type?: string, description: string }>
|
|
72
|
+
category?: string
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Documentation entry for a declaration
|
|
76
|
+
*/
|
|
77
|
+
export declare interface DocEntry {
|
|
78
|
+
name: string
|
|
79
|
+
kind: Declaration['kind']
|
|
80
|
+
signature: string
|
|
81
|
+
jsdoc: JSDocInfo
|
|
82
|
+
isExported: boolean
|
|
83
|
+
isDefault?: boolean
|
|
84
|
+
sourceFile?: string
|
|
85
|
+
sourceLine?: number
|
|
86
|
+
members?: DocEntry[]
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Documentation output structure
|
|
90
|
+
*/
|
|
91
|
+
export declare interface Documentation {
|
|
92
|
+
title: string
|
|
93
|
+
description?: string
|
|
94
|
+
entries: DocEntry[]
|
|
95
|
+
categories: Map<string, DocEntry[]>
|
|
96
|
+
generatedAt: Date
|
|
97
|
+
}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { DtsError, SourceLocation } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Type guards for error types
|
|
4
|
+
*/
|
|
5
|
+
export declare function isDtsxError(error: unknown): error is DtsxError;
|
|
6
|
+
export declare function isParseError(error: unknown): error is ParseError;
|
|
7
|
+
export declare function isFileError(error: unknown): error is FileError;
|
|
8
|
+
export declare function isConfigError(error: unknown): error is ConfigError;
|
|
9
|
+
/**
|
|
10
|
+
* Wrap an unknown error in a DtsxError
|
|
11
|
+
*/
|
|
12
|
+
export declare function wrapError(error: unknown, code?: ErrorCode, message?: string): DtsxError;
|
|
13
|
+
/**
|
|
14
|
+
* Calculate line and column from source code offset
|
|
15
|
+
*/
|
|
16
|
+
export declare function getLocationFromOffset(sourceCode: string, offset: number): SourceLocation;
|
|
17
|
+
/**
|
|
18
|
+
* Create a formatted error message with source location context
|
|
19
|
+
*/
|
|
20
|
+
export declare function formatErrorWithContext(sourceCode: string, location: SourceLocation, message: string, filePath?: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Create a DtsError from an exception
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDtsError(error: unknown, file: string, _sourceCode?: string): DtsError;
|
|
25
|
+
/**
|
|
26
|
+
* Format a DtsError for display
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatDtsError(error: DtsError, sourceCode?: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Aggregate multiple errors into a summary
|
|
31
|
+
*/
|
|
32
|
+
export declare function summarizeErrors(errors: DtsError[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Error codes for categorizing errors
|
|
35
|
+
*/
|
|
36
|
+
export declare const ErrorCodes: {
|
|
37
|
+
PARSE_ERROR: 'PARSE_ERROR';
|
|
38
|
+
SYNTAX_ERROR: 'SYNTAX_ERROR';
|
|
39
|
+
FILE_NOT_FOUND: 'FILE_NOT_FOUND';
|
|
40
|
+
FILE_READ_ERROR: 'FILE_READ_ERROR';
|
|
41
|
+
FILE_WRITE_ERROR: 'FILE_WRITE_ERROR';
|
|
42
|
+
TYPE_INFERENCE_ERROR: 'TYPE_INFERENCE_ERROR';
|
|
43
|
+
UNRESOLVED_TYPE: 'UNRESOLVED_TYPE';
|
|
44
|
+
EXTRACTION_ERROR: 'EXTRACTION_ERROR';
|
|
45
|
+
PROCESSING_ERROR: 'PROCESSING_ERROR';
|
|
46
|
+
VALIDATION_ERROR: 'VALIDATION_ERROR';
|
|
47
|
+
INVALID_DECLARATION: 'INVALID_DECLARATION';
|
|
48
|
+
CONFIG_ERROR: 'CONFIG_ERROR';
|
|
49
|
+
INVALID_ENTRYPOINT: 'INVALID_ENTRYPOINT';
|
|
50
|
+
CIRCULAR_DEPENDENCY: 'CIRCULAR_DEPENDENCY';
|
|
51
|
+
TIMEOUT_ERROR: 'TIMEOUT_ERROR';
|
|
52
|
+
NOT_SUPPORTED: 'NOT_SUPPORTED';
|
|
53
|
+
UNKNOWN_ERROR: 'UNKNOWN_ERROR'
|
|
54
|
+
};
|
|
55
|
+
export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
|
|
56
|
+
/**
|
|
57
|
+
* Base error class for dtsx errors
|
|
58
|
+
*/
|
|
59
|
+
export declare class DtsxError extends Error {
|
|
60
|
+
readonly code: ErrorCode;
|
|
61
|
+
readonly context?: Record<string, unknown>;
|
|
62
|
+
constructor(message: string, code?: ErrorCode, context?: Record<string, unknown>);
|
|
63
|
+
toString(): string;
|
|
64
|
+
toJSON(): Record<string, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Error during file parsing
|
|
68
|
+
*/
|
|
69
|
+
export declare class ParseError extends DtsxError {
|
|
70
|
+
readonly filePath: string;
|
|
71
|
+
readonly line?: number;
|
|
72
|
+
readonly column?: number;
|
|
73
|
+
constructor(message: string, filePath: string, options?: { line?: number, column?: number, cause?: Error });
|
|
74
|
+
get locationString(): string;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Error during declaration extraction
|
|
78
|
+
*/
|
|
79
|
+
export declare class ExtractionError extends DtsxError {
|
|
80
|
+
readonly filePath: string;
|
|
81
|
+
readonly declarationKind?: string;
|
|
82
|
+
constructor(message: string, filePath: string, declarationKind?: string, cause?: Error);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Error during type processing
|
|
86
|
+
*/
|
|
87
|
+
export declare class ProcessingError extends DtsxError {
|
|
88
|
+
readonly declarationName?: string;
|
|
89
|
+
constructor(message: string, declarationName?: string, cause?: Error);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Error during file I/O operations
|
|
93
|
+
*/
|
|
94
|
+
export declare class FileError extends DtsxError {
|
|
95
|
+
readonly filePath: string;
|
|
96
|
+
readonly operation: 'read' | 'write' | 'delete' | 'stat' | 'glob';
|
|
97
|
+
constructor(message: string, filePath: string, operation: 'read' | 'write' | 'delete' | 'stat' | 'glob', cause?: Error);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Error during configuration loading or validation
|
|
101
|
+
*/
|
|
102
|
+
export declare class ConfigError extends DtsxError {
|
|
103
|
+
readonly configPath?: string;
|
|
104
|
+
readonly invalidKey?: string;
|
|
105
|
+
constructor(message: string, options?: { configPath?: string, invalidKey?: string, cause?: Error });
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Error when circular dependency is detected
|
|
109
|
+
*/
|
|
110
|
+
export declare class CircularDependencyError extends DtsxError {
|
|
111
|
+
readonly cycle: string[];
|
|
112
|
+
constructor(cycle: string[]);
|
|
113
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ClassDeclaration, FunctionDeclaration, InterfaceDeclaration, ModuleDeclaration, SourceFile, TypeAliasDeclaration } from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Build clean function signature for DTS output
|
|
4
|
+
*/
|
|
5
|
+
export declare function buildFunctionSignature(node: FunctionDeclaration, sf: SourceFile): string;
|
|
6
|
+
/**
|
|
7
|
+
* Build clean variable declaration for DTS
|
|
8
|
+
*/
|
|
9
|
+
export declare function buildVariableDeclaration(name: string, type: string | undefined, kind: string, isExported: boolean): string;
|
|
10
|
+
/**
|
|
11
|
+
* Build clean interface declaration for DTS
|
|
12
|
+
*/
|
|
13
|
+
export declare function buildInterfaceDeclaration(node: InterfaceDeclaration, isExported: boolean, sf: SourceFile): string;
|
|
14
|
+
/**
|
|
15
|
+
* Get interface body with proper formatting
|
|
16
|
+
*/
|
|
17
|
+
export declare function getInterfaceBody(node: InterfaceDeclaration, sf: SourceFile): string;
|
|
18
|
+
/**
|
|
19
|
+
* Build clean type declaration for DTS
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildTypeDeclaration(node: TypeAliasDeclaration, isExported: boolean, sf: SourceFile): string;
|
|
22
|
+
/**
|
|
23
|
+
* Build clean class declaration for DTS
|
|
24
|
+
*/
|
|
25
|
+
export declare function buildClassDeclaration(node: ClassDeclaration, isExported: boolean, sf: SourceFile): string;
|
|
26
|
+
/**
|
|
27
|
+
* Build clean class body for DTS (signatures only, no implementations)
|
|
28
|
+
* Excludes: private fields (#field), private methods (#method), static blocks
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildClassBody(node: ClassDeclaration, sf: SourceFile): string;
|
|
31
|
+
/**
|
|
32
|
+
* Build clean module declaration for DTS
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildModuleDeclaration(node: ModuleDeclaration, isExported: boolean, sf: SourceFile): string;
|
|
35
|
+
/**
|
|
36
|
+
* Build clean module body for DTS (signatures only, no implementations)
|
|
37
|
+
*/
|
|
38
|
+
export declare function buildModuleBody(node: ModuleDeclaration, sf: SourceFile): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { hashContent } from './hash';
|
|
2
|
+
import type { SourceFile } from 'typescript';
|
|
3
|
+
/**
|
|
4
|
+
* Evict oldest entry if cache exceeds max size
|
|
5
|
+
* Uses O(n) scan instead of O(n log n) sort since we add one entry at a time
|
|
6
|
+
*/
|
|
7
|
+
export declare function evictOldestEntries(): void;
|
|
8
|
+
/**
|
|
9
|
+
* Get or create a cached SourceFile
|
|
10
|
+
* Accepts an optional pre-computed contentHash to avoid re-hashing
|
|
11
|
+
*/
|
|
12
|
+
export declare function getSourceFile(filePath: string, sourceCode: string, precomputedHash?: number | bigint): SourceFile;
|
|
13
|
+
/**
|
|
14
|
+
* Clear the SourceFile cache (useful for testing or memory management)
|
|
15
|
+
*/
|
|
16
|
+
export declare function clearSourceFileCache(): void;
|
|
17
|
+
/**
|
|
18
|
+
* Get the current cache size (useful for debugging)
|
|
19
|
+
*/
|
|
20
|
+
export declare function getSourceFileCacheSize(): number;
|
|
21
|
+
/**
|
|
22
|
+
* Async version of getSourceFile that yields to the event loop for large files
|
|
23
|
+
* Prevents blocking when processing many large files in parallel
|
|
24
|
+
*/
|
|
25
|
+
export declare function getSourceFileAsync(filePath: string, sourceCode: string, config?: AsyncParseConfig): Promise<SourceFile>;
|
|
26
|
+
/**
|
|
27
|
+
* Batch parse multiple files asynchronously with concurrency control
|
|
28
|
+
* Useful for processing many files while keeping the event loop responsive
|
|
29
|
+
*/
|
|
30
|
+
export declare function batchParseSourceFiles(files: Array<{ filePath: string, sourceCode: string }>, config?: AsyncParseConfig & { concurrency?: number }): Promise<Map<string, SourceFile>>;
|
|
31
|
+
/**
|
|
32
|
+
* Check if a file should use async parsing based on size
|
|
33
|
+
*/
|
|
34
|
+
export declare function shouldUseAsyncParsing(sourceCode: string, config?: AsyncParseConfig): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Get statistics about pending parse operations
|
|
37
|
+
*/
|
|
38
|
+
export declare function getPendingParseCount(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Configuration for async parsing
|
|
41
|
+
*/
|
|
42
|
+
export declare interface AsyncParseConfig {
|
|
43
|
+
asyncThreshold?: number
|
|
44
|
+
chunkSize?: number
|
|
45
|
+
yieldInterval?: number
|
|
46
|
+
}
|
|
47
|
+
export { hashContent } from './hash';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ClassDeclaration, EnumDeclaration, ExportAssignment, ExportDeclaration, FunctionDeclaration, ImportDeclaration, InterfaceDeclaration, ModuleDeclaration, SourceFile, TypeAliasDeclaration, VariableStatement } from 'typescript';
|
|
2
|
+
import type { Declaration } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Extract import declaration
|
|
5
|
+
*/
|
|
6
|
+
export declare function extractImportDeclaration(node: ImportDeclaration, sourceCode: string, sourceFile: SourceFile): Declaration;
|
|
7
|
+
/**
|
|
8
|
+
* Extract export declaration
|
|
9
|
+
*/
|
|
10
|
+
export declare function extractExportDeclaration(node: ExportDeclaration, sourceCode: string, sourceFile: SourceFile, keepComments?: boolean): Declaration;
|
|
11
|
+
/**
|
|
12
|
+
* Extract export assignment (export default)
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractExportAssignment(node: ExportAssignment, sourceCode: string, sourceFile: SourceFile, keepComments?: boolean): Declaration;
|
|
15
|
+
/**
|
|
16
|
+
* Extract function declaration with proper signature
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractFunctionDeclaration(node: FunctionDeclaration, _sourceCode: string, sourceFile: SourceFile, keepComments: boolean): Declaration | null;
|
|
19
|
+
/**
|
|
20
|
+
* Extract variable statement (only exported ones for DTS)
|
|
21
|
+
*/
|
|
22
|
+
export declare function extractVariableStatement(node: VariableStatement, _sourceCode: string, sourceFile: SourceFile, keepComments: boolean): Declaration[];
|
|
23
|
+
/**
|
|
24
|
+
* Extract interface declaration
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractInterfaceDeclaration(node: InterfaceDeclaration, _sourceCode: string, sourceFile: SourceFile, keepComments: boolean): Declaration;
|
|
27
|
+
/**
|
|
28
|
+
* Extract type alias declaration
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractTypeAliasDeclaration(node: TypeAliasDeclaration, _sourceCode: string, sourceFile: SourceFile, keepComments: boolean): Declaration;
|
|
31
|
+
/**
|
|
32
|
+
* Extract class declaration
|
|
33
|
+
*/
|
|
34
|
+
export declare function extractClassDeclaration(node: ClassDeclaration, _sourceCode: string, sourceFile: SourceFile, keepComments: boolean): Declaration;
|
|
35
|
+
/**
|
|
36
|
+
* Extract enum declaration
|
|
37
|
+
*/
|
|
38
|
+
export declare function extractEnumDeclaration(node: EnumDeclaration, sourceCode: string, sourceFile: SourceFile, keepComments: boolean): Declaration;
|
|
39
|
+
/**
|
|
40
|
+
* Extract module/namespace declaration
|
|
41
|
+
*/
|
|
42
|
+
export declare function extractModuleDeclaration(node: ModuleDeclaration, _sourceCode: string, sourceFile: SourceFile, keepComments: boolean): Declaration;
|
|
43
|
+
/**
|
|
44
|
+
* Find types that are referenced in declarations but not imported or declared
|
|
45
|
+
*/
|
|
46
|
+
export declare function findReferencedTypes(declarations: Declaration[], _sourceCode: string): Set<string>;
|
|
47
|
+
/**
|
|
48
|
+
* Extract declarations for referenced types by searching the entire source file
|
|
49
|
+
*/
|
|
50
|
+
export declare function extractReferencedTypeDeclarations(sourceFile: SourceFile, referencedTypes: Set<string>, sourceCode: string, keepComments?: boolean): Declaration[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triple-slash directive extraction — NO TypeScript dependency.
|
|
3
|
+
* Pure string processing for maximum startup speed.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Extract triple-slash directives from source code.
|
|
7
|
+
* These are special comments like /// <reference types="..." />
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractTripleSlashDirectives(sourceCode: string): string[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Declaration } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Extract declarations using the fast string scanner (no TS parser).
|
|
4
|
+
* Results are cached by file path + keepComments flag.
|
|
5
|
+
*/
|
|
6
|
+
export declare function extractDeclarations(sourceCode: string, filePath: string, keepComments?: boolean, isolatedDeclarations?: boolean): Declaration[];
|
|
7
|
+
/**
|
|
8
|
+
* Clear the declaration cache (for benchmarks and testing)
|
|
9
|
+
*/
|
|
10
|
+
export declare function clearDeclarationCache(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hashContent(content: string): number | bigint;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { FunctionDeclaration, Node, ParameterDeclaration, SourceFile } from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Get the text of a node from source code
|
|
4
|
+
*/
|
|
5
|
+
export declare function getNodeText(node: Node, sourceCode: string, sf?: SourceFile): string;
|
|
6
|
+
/**
|
|
7
|
+
* Extract JSDoc comments from a node
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractJSDocComments(node: Node, sourceFile: SourceFile): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Get parameter name without default values for DTS
|
|
12
|
+
*/
|
|
13
|
+
export declare function getParameterName(param: ParameterDeclaration, sf?: SourceFile): string;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a node has export modifier
|
|
16
|
+
*/
|
|
17
|
+
export declare function hasExportModifier(node: Node): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Check if a function has async modifier
|
|
20
|
+
*/
|
|
21
|
+
export declare function hasAsyncModifier(node: FunctionDeclaration): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a non-exported function should be included (e.g., if it's referenced by exported items)
|
|
24
|
+
*/
|
|
25
|
+
export declare function shouldIncludeNonExportedFunction(_functionName?: string, _sourceCode?: string): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Check if a non-exported interface should be included (e.g., if it's used by exported items)
|
|
28
|
+
*/
|
|
29
|
+
export declare function shouldIncludeNonExportedInterface(interfaceName: string, sourceCode: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Check if a type is a built-in TypeScript type
|
|
32
|
+
*/
|
|
33
|
+
export declare function isBuiltInType(typeName: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Extract type names from module/namespace text
|
|
36
|
+
*/
|
|
37
|
+
export declare function extractTypesFromModuleText(moduleText: string): string[];
|
|
38
|
+
// Re-exported from directives.ts for backward compatibility
|
|
39
|
+
export { extractTripleSlashDirectives } from './directives';
|