@stacksjs/dtsx 0.9.9 → 0.9.11
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 +150 -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-1bav913n.js +6 -0
- package/dist/chunk-2wbhe1k8.js +2 -0
- package/dist/chunk-3d18fhrg.js +3 -0
- package/dist/chunk-3g2v2ns2.js +2 -0
- package/dist/chunk-3j7r0fxz.js +2 -0
- package/dist/chunk-4qpg9xnt.js +3 -0
- package/dist/chunk-57agx6g8.js +3 -0
- package/dist/chunk-5vqtjws2.js +2 -0
- package/dist/chunk-6mwq397e.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-9a6yn7sv.js +75 -0
- package/dist/chunk-axb2kjeq.js +2 -0
- package/dist/chunk-begk3j01.js +33 -0
- package/dist/chunk-cmenkst5.js +3 -0
- package/dist/chunk-d0p3jzwb.js +34 -0
- package/dist/chunk-f18nyrrb.js +32 -0
- package/dist/chunk-fb4c98h2.js +2 -0
- package/dist/chunk-ggmn4a8c.js +4 -0
- package/dist/chunk-hrmnrn4p.js +3 -0
- package/dist/chunk-j0y71ank.js +2 -0
- package/dist/chunk-j6aqdbc4.js +2 -0
- package/dist/chunk-jm5ywn4e.js +13 -0
- package/dist/chunk-knkfbqze.js +2 -0
- package/dist/chunk-n28rjf9h.js +3 -0
- package/dist/chunk-p1d09y82.js +449 -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-rw6j20e2.js +3 -0
- package/dist/chunk-v96rjx7x.js +134 -0
- package/dist/chunk-w9abhtgg.js +22 -0
- package/dist/chunk-wfevdmvd.js +19 -0
- package/dist/chunk-ws2dmfvj.js +2 -0
- package/dist/chunk-xnq1xw73.js +15 -0
- package/dist/chunk-xyctgc6x.js +102 -0
- package/dist/chunk-y3q50bn2.js +2 -0
- package/dist/chunk-ywd4k4hn.js +3 -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 +124 -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
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard and constructor for FilePath
|
|
3
|
+
*/
|
|
4
|
+
export declare function asFilePath(path: string): FilePath;
|
|
5
|
+
/**
|
|
6
|
+
* Type guard and constructor for DirectoryPath
|
|
7
|
+
*/
|
|
8
|
+
export declare function asDirectoryPath(path: string): DirectoryPath;
|
|
9
|
+
/**
|
|
10
|
+
* Type guard and constructor for GlobPattern
|
|
11
|
+
*/
|
|
12
|
+
export declare function asGlobPattern(pattern: string): GlobPattern;
|
|
13
|
+
/**
|
|
14
|
+
* Type guard and constructor for SourceCode
|
|
15
|
+
*/
|
|
16
|
+
export declare function asSourceCode(code: string): SourceCode;
|
|
17
|
+
/**
|
|
18
|
+
* Type guard and constructor for DtsContent
|
|
19
|
+
*/
|
|
20
|
+
export declare function asDtsContent(content: string): DtsContent;
|
|
21
|
+
/**
|
|
22
|
+
* Type guard and constructor for ModuleSpecifier
|
|
23
|
+
*/
|
|
24
|
+
export declare function asModuleSpecifier(specifier: string): ModuleSpecifier;
|
|
25
|
+
/**
|
|
26
|
+
* Type guard and constructor for TypeName
|
|
27
|
+
*/
|
|
28
|
+
export declare function asTypeName(name: string): TypeName;
|
|
29
|
+
/**
|
|
30
|
+
* Type guard and constructor for DeclarationName
|
|
31
|
+
*/
|
|
32
|
+
export declare function asDeclarationName(name: string): DeclarationName;
|
|
33
|
+
/**
|
|
34
|
+
* Type guard and constructor for AbsolutePath
|
|
35
|
+
*/
|
|
36
|
+
export declare function asAbsolutePath(path: string): AbsolutePath;
|
|
37
|
+
/**
|
|
38
|
+
* Type guard and constructor for RelativePath
|
|
39
|
+
*/
|
|
40
|
+
export declare function asRelativePath(path: string): RelativePath;
|
|
41
|
+
/**
|
|
42
|
+
* Type guard and constructor for JsonString
|
|
43
|
+
*/
|
|
44
|
+
export declare function asJsonString(json: string): JsonString;
|
|
45
|
+
/**
|
|
46
|
+
* Check if a value is a branded type of a specific brand
|
|
47
|
+
*/
|
|
48
|
+
export declare function isBranded<T, B extends string>(value: unknown, _brand: B): value is Brand<T, B>;
|
|
49
|
+
/**
|
|
50
|
+
* Unwrap a branded type to its base type
|
|
51
|
+
* Useful when you need to pass branded types to external APIs
|
|
52
|
+
*/
|
|
53
|
+
export declare function unwrap<T>(branded: Brand<T, string>): T;
|
|
54
|
+
/**
|
|
55
|
+
* Safe path operations that preserve branding
|
|
56
|
+
* @defaultValue
|
|
57
|
+
* ```ts
|
|
58
|
+
* {
|
|
59
|
+
* join: (base: DirectoryPath, ...segments: string[]) => unknown,
|
|
60
|
+
* dirname: (path: FilePath) => unknown,
|
|
61
|
+
* basename: (path: FilePath) => unknown,
|
|
62
|
+
* resolve: (...segments: string[]) => unknown,
|
|
63
|
+
* isAbsolute: (path: string) => unknown,
|
|
64
|
+
* relative: (from: DirectoryPath, to: FilePath) => unknown
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare const BrandedPath: {
|
|
69
|
+
/**
|
|
70
|
+
* Join path segments, returning appropriate branded type
|
|
71
|
+
*/
|
|
72
|
+
join: (base: DirectoryPath, ...segments: string[]) => unknown;
|
|
73
|
+
/**
|
|
74
|
+
* Get directory name from a file path
|
|
75
|
+
*/
|
|
76
|
+
dirname: (path: FilePath) => unknown;
|
|
77
|
+
/**
|
|
78
|
+
* Get base name from a file path
|
|
79
|
+
*/
|
|
80
|
+
basename: (path: FilePath) => unknown;
|
|
81
|
+
/**
|
|
82
|
+
* Resolve path to absolute
|
|
83
|
+
*/
|
|
84
|
+
resolve: (...segments: string[]) => unknown;
|
|
85
|
+
/**
|
|
86
|
+
* Check if path is absolute
|
|
87
|
+
*/
|
|
88
|
+
isAbsolute: (path: string) => unknown;
|
|
89
|
+
/**
|
|
90
|
+
* Get relative path from one path to another
|
|
91
|
+
*/
|
|
92
|
+
relative: (from: DirectoryPath, to: FilePath) => unknown
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Generic branded type creator
|
|
96
|
+
*/
|
|
97
|
+
export type Brand<T, B extends string> = T & { readonly [__brand]: B }
|
|
98
|
+
/**
|
|
99
|
+
* Branded type for file paths
|
|
100
|
+
* Ensures file paths are validated before use
|
|
101
|
+
*/
|
|
102
|
+
export type FilePath = Brand<string, 'FilePath'>;
|
|
103
|
+
/**
|
|
104
|
+
* Branded type for directory paths
|
|
105
|
+
*/
|
|
106
|
+
export type DirectoryPath = Brand<string, 'DirectoryPath'>;
|
|
107
|
+
/**
|
|
108
|
+
* Branded type for glob patterns
|
|
109
|
+
*/
|
|
110
|
+
export type GlobPattern = Brand<string, 'GlobPattern'>;
|
|
111
|
+
/**
|
|
112
|
+
* Branded type for TypeScript source code
|
|
113
|
+
*/
|
|
114
|
+
export type SourceCode = Brand<string, 'SourceCode'>;
|
|
115
|
+
/**
|
|
116
|
+
* Branded type for declaration file content
|
|
117
|
+
*/
|
|
118
|
+
export type DtsContent = Brand<string, 'DtsContent'>;
|
|
119
|
+
/**
|
|
120
|
+
* Branded type for module specifiers (import paths)
|
|
121
|
+
*/
|
|
122
|
+
export type ModuleSpecifier = Brand<string, 'ModuleSpecifier'>;
|
|
123
|
+
/**
|
|
124
|
+
* Branded type for type names
|
|
125
|
+
*/
|
|
126
|
+
export type TypeName = Brand<string, 'TypeName'>;
|
|
127
|
+
/**
|
|
128
|
+
* Branded type for declaration names
|
|
129
|
+
*/
|
|
130
|
+
export type DeclarationName = Brand<string, 'DeclarationName'>;
|
|
131
|
+
/**
|
|
132
|
+
* Branded type for validated JSON strings
|
|
133
|
+
*/
|
|
134
|
+
export type JsonString = Brand<string, 'JsonString'>;
|
|
135
|
+
/**
|
|
136
|
+
* Branded type for absolute paths
|
|
137
|
+
*/
|
|
138
|
+
export type AbsolutePath = Brand<string, 'AbsolutePath'>;
|
|
139
|
+
/**
|
|
140
|
+
* Branded type for relative paths
|
|
141
|
+
*/
|
|
142
|
+
export type RelativePath = Brand<string, 'RelativePath'>;
|
|
143
|
+
/**
|
|
144
|
+
* Type utility to extract the brand from a branded type
|
|
145
|
+
*/
|
|
146
|
+
export type ExtractBrand<T> = T extends Brand<unknown, infer B> ? B : never;
|
|
147
|
+
/**
|
|
148
|
+
* Type utility to extract the base type from a branded type
|
|
149
|
+
*/
|
|
150
|
+
export type ExtractBase<T> = T extends Brand<infer U, string> ? U : T;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DtsGenerationConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Bundle multiple TypeScript files into a single .d.ts file
|
|
4
|
+
*/
|
|
5
|
+
export declare function bundleDeclarations(files: string[], sourceContents: Map<string, string>, config: DtsGenerationConfig): Promise<BundleResult>;
|
|
6
|
+
/**
|
|
7
|
+
* Bundle multiple .d.ts files into a single file
|
|
8
|
+
*/
|
|
9
|
+
export declare function bundleDtsFiles(files: string[], config?: Partial<BundleConfig>): Promise<BundleResult>;
|
|
10
|
+
/**
|
|
11
|
+
* Bundle and write to file
|
|
12
|
+
*/
|
|
13
|
+
export declare function bundleAndWrite(files: string[], outputPath: string, config?: Partial<BundleConfig>): Promise<BundleResult>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a bundler with preset configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare function createBundler(config?: Partial<BundleConfig>): {
|
|
18
|
+
bundle: (files: string[]) => Promise<BundleResult>
|
|
19
|
+
bundleAndWrite: (files: string[], output: string) => Promise<BundleResult>
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Resolve entry files from glob patterns
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveEntryFiles(patterns: string | string[], cwd?: string): Promise<string[]>;
|
|
25
|
+
/**
|
|
26
|
+
* Bundle configuration options
|
|
27
|
+
*/
|
|
28
|
+
export declare interface BundleConfig {
|
|
29
|
+
entry: string | string[]
|
|
30
|
+
output: string
|
|
31
|
+
name?: string
|
|
32
|
+
includeSourceComments?: boolean
|
|
33
|
+
preserveFileSections?: boolean
|
|
34
|
+
externals?: string[]
|
|
35
|
+
banner?: string
|
|
36
|
+
footer?: string
|
|
37
|
+
sortDeclarations?: boolean
|
|
38
|
+
mergeDuplicates?: boolean
|
|
39
|
+
ambient?: boolean
|
|
40
|
+
moduleName?: string
|
|
41
|
+
includeReferences?: boolean
|
|
42
|
+
references?: string[]
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Bundle result containing the combined declarations
|
|
46
|
+
*/
|
|
47
|
+
export declare interface BundleResult {
|
|
48
|
+
content: string
|
|
49
|
+
files: string[]
|
|
50
|
+
declarationCount: number
|
|
51
|
+
importCount: number
|
|
52
|
+
exportCount: number
|
|
53
|
+
size: number
|
|
54
|
+
warnings: string[]
|
|
55
|
+
}
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { DtsGenerationConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Add .dtsx-cache to .gitignore if not already present
|
|
4
|
+
*/
|
|
5
|
+
export declare function ensureGitignore(cwd: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Cache entry for a single file
|
|
8
|
+
*/
|
|
9
|
+
export declare interface CacheEntry {
|
|
10
|
+
sourcePath: string
|
|
11
|
+
sourceHash: string
|
|
12
|
+
sourceMtime: number
|
|
13
|
+
dtsContent: string
|
|
14
|
+
dtsHash: string
|
|
15
|
+
generatedAt: number
|
|
16
|
+
configHash: string
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Cache manifest containing all cached entries
|
|
20
|
+
*/
|
|
21
|
+
export declare interface CacheManifest {
|
|
22
|
+
version: number
|
|
23
|
+
configHash: string
|
|
24
|
+
entries: Record<string, CacheEntry>
|
|
25
|
+
createdAt: number
|
|
26
|
+
updatedAt: number
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Incremental build cache manager
|
|
30
|
+
*/
|
|
31
|
+
export declare class BuildCache {
|
|
32
|
+
constructor(config: DtsGenerationConfig);
|
|
33
|
+
load(): boolean;
|
|
34
|
+
save(): void;
|
|
35
|
+
needsRegeneration(filePath: string, cwd: string): boolean;
|
|
36
|
+
getCached(filePath: string, cwd: string): string | null;
|
|
37
|
+
getCachedIfValid(filePath: string, cwd: string): string | null;
|
|
38
|
+
update(filePath: string, sourceContent: string, dtsContent: string, cwd: string): void;
|
|
39
|
+
remove(filePath: string, cwd: string): void;
|
|
40
|
+
clear(): void;
|
|
41
|
+
getStats(): { entries: number, size: number };
|
|
42
|
+
prune(existingFiles: Set<string>, cwd: string): number;
|
|
43
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import ts from 'typescript';
|
|
2
|
+
import type { DtsGenerationConfig } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Load TypeScript compiler options from tsconfig.json
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadCompilerOptions(tsconfigPath: string, overrides?: Partial<ts.CompilerOptions>): ts.CompilerOptions;
|
|
7
|
+
/**
|
|
8
|
+
* Type check TypeScript/declaration files
|
|
9
|
+
*/
|
|
10
|
+
export declare function typeCheck(files: string[], config?: TypeCheckConfig): Promise<TypeCheckResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Validate that generated .d.ts files are valid TypeScript
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateDeclarations(dtsFiles: string[], config?: TypeCheckConfig): Promise<TypeCheckResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Check if source files are compatible with TypeScript's isolatedDeclarations mode
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkIsolatedDeclarations(files: string[], tsconfigPath?: string): Promise<Map<string, IsolatedDeclarationsResult>>;
|
|
19
|
+
/**
|
|
20
|
+
* Get type information for a specific position in a file
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTypeAtPosition(filePath: string, line: number, column: number, tsconfigPath?: string): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Get quick info (hover information) for a position
|
|
25
|
+
*/
|
|
26
|
+
export declare function getQuickInfo(filePath: string, line: number, column: number, tsconfigPath?: string): { type: string, documentation?: string } | null;
|
|
27
|
+
/**
|
|
28
|
+
* Format type check results as a human-readable string
|
|
29
|
+
*/
|
|
30
|
+
export declare function formatTypeCheckResults(result: TypeCheckResult): string;
|
|
31
|
+
/**
|
|
32
|
+
* Integrate type checking into DTS generation config
|
|
33
|
+
*/
|
|
34
|
+
export declare function typeCheckWithConfig(config: DtsGenerationConfig): Promise<TypeCheckResult>;
|
|
35
|
+
/**
|
|
36
|
+
* Validate generated declarations match the source types
|
|
37
|
+
*/
|
|
38
|
+
export declare function validateGeneratedDeclarations(_sourceFiles: string[], _dtsFiles: string[], _tsconfigPath?: string): Promise<{
|
|
39
|
+
valid: boolean
|
|
40
|
+
mismatches: Array<{
|
|
41
|
+
sourceName: string
|
|
42
|
+
sourceType: string
|
|
43
|
+
dtsType: string
|
|
44
|
+
}>
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* A diagnostic message from type checking
|
|
48
|
+
*/
|
|
49
|
+
export declare interface TypeDiagnostic {
|
|
50
|
+
file: string
|
|
51
|
+
line: number
|
|
52
|
+
column: number
|
|
53
|
+
message: string
|
|
54
|
+
code: number
|
|
55
|
+
severity: DiagnosticSeverity
|
|
56
|
+
source?: string
|
|
57
|
+
suggestion?: string
|
|
58
|
+
category: string
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Result of type checking
|
|
62
|
+
*/
|
|
63
|
+
export declare interface TypeCheckResult {
|
|
64
|
+
success: boolean
|
|
65
|
+
diagnostics: TypeDiagnostic[]
|
|
66
|
+
errorCount: number
|
|
67
|
+
warningCount: number
|
|
68
|
+
infoCount: number
|
|
69
|
+
filesChecked: string[]
|
|
70
|
+
durationMs: number
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Type checking configuration
|
|
74
|
+
*/
|
|
75
|
+
export declare interface TypeCheckConfig {
|
|
76
|
+
tsconfigPath?: string
|
|
77
|
+
rootDir?: string
|
|
78
|
+
strict?: boolean
|
|
79
|
+
declarationsOnly?: boolean
|
|
80
|
+
skipLibCheck?: boolean
|
|
81
|
+
include?: string[]
|
|
82
|
+
exclude?: string[]
|
|
83
|
+
warningsAsErrors?: boolean
|
|
84
|
+
maxErrors?: number
|
|
85
|
+
compilerOptions?: Partial<ts.CompilerOptions>
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Isolated declarations checking result
|
|
89
|
+
*/
|
|
90
|
+
export declare interface IsolatedDeclarationsResult {
|
|
91
|
+
compatible: boolean
|
|
92
|
+
issues: IsolatedDeclarationsIssue[]
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* An issue found during isolated declarations checking
|
|
96
|
+
*/
|
|
97
|
+
export declare interface IsolatedDeclarationsIssue {
|
|
98
|
+
line: number
|
|
99
|
+
column: number
|
|
100
|
+
message: string
|
|
101
|
+
declarationName?: string
|
|
102
|
+
missingAnnotation?: 'return' | 'parameter' | 'variable' | 'property'
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Diagnostic severity levels
|
|
106
|
+
*/
|
|
107
|
+
export type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tb as y}from"./chunk-9a6yn7sv.js";import{Vc as H,Xc as F}from"./chunk-57agx6g8.js";import{cd as R}from"./chunk-rw6j20e2.js";import{existsSync as V,readFileSync as G}from"fs";import{dirname as M,join as X,resolve as x}from"path";async function S(E){let A=[],z=new Set;async function q(I,L){let w=x(I);if(z.has(w))return;if(z.add(w),!V(w)){H.warn(`tsconfig not found: ${w}`);return}try{let O=G(w,"utf-8").replace(/\/\*[\s\S]*?\*\/|\/\/.*/g,""),K=JSON.parse(O),U=M(w),Y=B(U,L),W=[];if(K.references)for(let D of K.references){let $=x(U,D.path),J=V(X($,"tsconfig.json"))?X($,"tsconfig.json"):$;await q(J,Y);let b=B(M(J),Y);W.push(b)}let Z="./src";if(K.compilerOptions?.rootDir)Z=K.compilerOptions.rootDir;else if(K.include&&K.include.length>0){if(K.include[0].startsWith("src/"))Z="./src"}let _="./dist";if(K.compilerOptions?.outDir)_=K.compilerOptions.outDir;else if(K.compilerOptions?.declarationDir)_=K.compilerOptions.declarationDir;A.push({name:Y,root:U,tsconfigPath:w,references:W,config:{root:Z,outdir:_}})}catch(Q){let O=Q instanceof Error?Q.message:String(Q);H.warn(`Failed to parse ${w}: ${O}`)}}return await q(E),A}function B(E,A){let z=X(E,"package.json");if(V(z))try{let I=G(z,"utf-8"),L=JSON.parse(I);if(L.name)return L.name}catch{}let q=E.split("/").pop()||"unknown";return A?`${A}/${q}`:q}function N(E){let A=new Map(E.map((w)=>[w.name,w])),z=[],q=new Set,I=new Set;function L(w){if(q.has(w))return;if(I.has(w)){H.warn(`Circular dependency detected involving: ${w}`);return}I.add(w);let Q=A.get(w);if(Q){for(let O of Q.references)L(O);z.push(Q)}I.delete(w),q.add(w)}for(let w of E)L(w.name);return z}async function T(E){let A=Date.now(),z=N(E.projects);H.info(`Generating declarations for ${z.length} projects...`);let q=[],I=!0;for(let O of z){H.info(`
|
|
3
|
+
[${O.name}] Generating...`);try{let K={...E.sharedConfig,...O.config,cwd:O.root,tsconfigPath:O.tsconfigPath},U=await y(K),Y=U.filesFailed===0;if(!Y)I=!1;q.push({name:O.name,stats:U,success:Y}),H.info(`[${O.name}] Generated ${U.filesGenerated} files`)}catch(K){I=!1;let U=K instanceof Error?K.message:String(K);q.push({name:O.name,stats:{filesProcessed:0,filesGenerated:0,filesFailed:0,filesValidated:0,validationErrors:0,declarationsFound:0,importsProcessed:0,exportsProcessed:0,durationMs:0,errors:[]},success:!1,error:U}),H.error(`[${O.name}] Failed: ${U}`)}}let L=Date.now()-A,w=q.filter((O)=>O.success).length,Q=q.length-w;if(H.info(`
|
|
4
|
+
--- Workspace Generation Summary ---`),H.info(`Projects processed: ${q.length}`),H.info(`Successful: ${w}`),Q>0)H.info(`Failed: ${Q}`);return H.info(`Total duration: ${L}ms`),H.info(`------------------------------------
|
|
5
|
+
`),{success:I,projects:q,durationMs:L}}async function f(E,A){if(A?.logLevel)F(A.logLevel);let z=X(E,"tsconfig.json");if(!V(z))throw Error(`Root tsconfig.json not found at: ${z}`);H.info("Discovering workspace projects...");let q=await S(z);if(q.length===0)return H.warn("No projects found in workspace"),{success:!0,projects:[],durationMs:0};return H.info(`Found ${q.length} projects`),T({root:E,projects:q,sharedConfig:A})}async function v(E){let A=X(E,"package.json");if(!V(A))return[];try{let z=G(A,"utf-8"),q=JSON.parse(z),I=[];if(Array.isArray(q.workspaces))I=q.workspaces;else if(q.workspaces?.packages)I=q.workspaces.packages;return I}catch{return[]}}async function C(E,A){let{Glob:z}=awaitPromise.resolve(globalThis.Bun),q=[];for(let I of A){let L=new z(I);for await(let w of L.scan({cwd:E,absolute:!0,onlyFiles:!1})){let Q=X(w,"package.json");if(V(Q))q.push(w)}}return q}async function l(E,A){if(A?.logLevel)F(A.logLevel);let z=await v(E);if(z.length===0)return H.warn("No workspace patterns found in package.json"),{success:!0,projects:[],durationMs:0};H.info(`Found workspace patterns: ${z.join(", ")}`);let q=await C(E,z);if(q.length===0)return H.warn("No projects found matching workspace patterns"),{success:!0,projects:[],durationMs:0};H.info(`Found ${q.length} workspace packages`);let I=q.map((L)=>{let w=X(L,"tsconfig.json");return{name:B(L),root:L,tsconfigPath:V(w)?w:"",references:[]}});return T({root:E,projects:I,sharedConfig:A})}
|
|
6
|
+
export{S as l,N as m,T as n,f as o,v as p,C as q,l as r};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ac as v,Bc as w,oc as j,pc as k,qc as l,rc as m,sc as n,tc as o,uc as p,vc as q,wc as r,xc as s,yc as t,zc as u}from"./chunk-begk3j01.js";import{Ec as a,Fc as b,Gc as c,Hc as d,Ic as e,Jc as f,Kc as g,Lc as h,Mc as i}from"./chunk-xnq1xw73.js";import"./chunk-rw6j20e2.js";export{l as processVariableDeclaration,n as processTypeDeclaration,s as processModuleDeclaration,m as processInterfaceDeclaration,q as processImportDeclaration,k as processFunctionDeclaration,r as processExportDeclaration,p as processEnumDeclaration,w as processDeclarations,o as processClassDeclaration,u as parseImportStatement,d as parseArrayElements,h as isGenericType,e as inferObjectType,b as inferNarrowTypeInUnion,a as inferNarrowType,g as inferFunctionType,c as inferArrayType,j as formatComments,f as findMatchingBracket,i as extractSatisfiesType,v as extractAllImportedItems,t as clearProcessorCaches};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tb as I}from"./chunk-9a6yn7sv.js";function z(J={}){let{onBuildStart:K=!1,onBuildEnd:L=!0,onGenerated:M,onError:C,...N}=J,w,q,F=async()=>{let j={...N};if(!j.outdir&&w)j.outdir=w;if(!j.entrypoints&&q)j.entrypoints=q;try{let k=await I(j);M?.(k)}catch(k){let H=k instanceof Error?k:Error(String(k));if(C?.(H),!C)console.error("[dtsx] Generation failed:",H.message)}};return{name:"dtsx",esbuildOptions(j){if(j.outdir&&typeof j.outdir==="string")w=j.outdir;if(j.entryPoints){if(Array.isArray(j.entryPoints))q=j.entryPoints;else if(typeof j.entryPoints==="object")q=Object.values(j.entryPoints)}},async buildStart(){if(K)await F()},async buildEnd(j){if(L)await F()}}}var R=z,T=z,V=z;
|
|
3
|
+
export{z as ma,R as na,T as oa,V as pa};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Q as a,R as b,S as c,T as d,U as e,V as f,W as g,X as h,Y as i}from"./chunk-r1ywapeb.js";import"./chunk-p1d09y82.js";import"./chunk-rw6j20e2.js";export{e as getGraphSummary,d as formatCircularAnalysis,f as findAllDependents,g as findAllDependencies,i as exportGraphAsJson,h as exportGraphAsDot,b as detectCircularDependencies,a as buildDependencyGraph,c as analyzeCircularDependencies};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tb as I}from"./chunk-9a6yn7sv.js";class H{options;generateOptions;constructor(j={}){let{onCompile:F=!1,afterEmit:w=!0,onWatchRun:q=!1,onGenerated:z,onError:B,...J}=j;this.options={onCompile:F,afterEmit:w,onWatchRun:q,onGenerated:z,onError:B},this.generateOptions=J}apply(j){if(!this.generateOptions.outdir&&j.options.output?.path)this.generateOptions.outdir=j.options.output.path;if(!this.generateOptions.cwd&&j.options.context)this.generateOptions.cwd=j.options.context;if(!this.generateOptions.entrypoints&&j.options.entry){let w=j.options.entry;if(typeof w==="string")this.generateOptions.entrypoints=[w];else if(Array.isArray(w))this.generateOptions.entrypoints=w;else if(typeof w==="object"&&w!==null){let q=[];for(let z of Object.values(w))if(typeof z==="string")q.push(z);else if(Array.isArray(z))q.push(...z.filter((B)=>typeof B==="string"));else if(typeof z==="object"&&z!==null&&"import"in z){let B=z.import;if(typeof B==="string")q.push(B);else if(Array.isArray(B))q.push(...B)}if(q.length>0)this.generateOptions.entrypoints=q}}if(this.options.onCompile)j.hooks.compile.tap("DtsxWebpackPlugin",()=>{this.runGenerate()});if(this.options.afterEmit)j.hooks.afterEmit.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()});if(this.options.onWatchRun)j.hooks.watchRun.tapAsync("DtsxWebpackPlugin",async(w,q)=>{await this.runGenerate(),q()})}async runGenerate(){try{let j=await I(this.generateOptions);this.options.onGenerated?.(j)}catch(j){let F=j instanceof Error?j:Error(String(j));if(this.options.onError?.(F),!this.options.onError)console.error("[dtsx] Generation failed:",F.message)}}}function K(j={}){return new H(j)}var M=K,Q=H;
|
|
3
|
+
export{H as qa,K as ra,M as sa,Q as ta};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var K={debug:0,info:1,warn:2,error:3,silent:4},B="info",F="[dtsx]",I=!1,H=null;function y(j){return K[j]>=K[B]}function Q(){if(!I)return"";return`[${new Date().toISOString().slice(11,23)}] `}function S(j,C){let k=Q();if(j||k)return[`${k}${j}`,...C];return C}function z(j,C,k){let q=S(C,k);if(H){H(j,...q);return}switch(j){case"debug":console.debug(...q);break;case"info":console.log(...q);break;case"warn":console.warn(...q);break;case"error":console.error(...q);break}}function J(j){return{debug:(...k)=>{if(y("debug"))z("debug",j,k)},info:(...k)=>{if(y("info"))z("info",j,k)},warn:(...k)=>{if(y("warn"))z("warn",j,k)},error:(...k)=>{if(y("error"))z("error",j,k)},setLevel:(k)=>{B=k},getLevel:()=>B,child:(k)=>{let q=j?`${j}:${k}`:`[${k}]`;return J(q)},time:(k)=>{let q=performance.now();return()=>{let M=performance.now()-q;if(y("debug"))z("debug",j,[`${k}: ${M.toFixed(2)}ms`])}},progress:(k)=>{if(y("info"))if(typeof process<"u"&&process.stdout?.isTTY)process.stdout.write(`\r${j} ${k}`);else z("info",j,[k])}}}function Y(j={}){if(j.level)B=j.level;if(j.prefix!==void 0)F=j.prefix;if(j.timestamps!==void 0)I=j.timestamps;if(j.output)H=j.output;return J(F)}var U=J(F);function Z(j){return U.child(j)}function $(j){B=j}function N(){return B}function D(j){F=j}function G(j){I=j}var X={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{},setLevel:()=>{},getLevel:()=>"silent",child:()=>X,time:()=>()=>{},progress:()=>{}};
|
|
3
|
+
export{Y as Uc,U as Vc,Z as Wc,$ as Xc,N as Yc,D as Zc,G as _c,X as $c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{s as a,t as b,u as c,v as d,w as e,x as f,y as g}from"./chunk-w9abhtgg.js";import"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-begk3j01.js";import"./chunk-xnq1xw73.js";import"./chunk-rw6j20e2.js";export{f as startLSPServer,g as createFileWatcher,b as SymbolKind,a as LspDiagnosticSeverity,e as DtsxLanguageServer,d as DocumentHighlightKind,c as CompletionItemKind};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{tb as b,ub as c,vb as d}from"./chunk-9a6yn7sv.js";import"./chunk-wfevdmvd.js";import"./chunk-p1d09y82.js";import{ic as a}from"./chunk-hrmnrn4p.js";import"./chunk-74j5mydx.js";import"./chunk-rnt0wkrk.js";import"./chunk-begk3j01.js";import"./chunk-xnq1xw73.js";import"./chunk-f18nyrrb.js";import"./chunk-57agx6g8.js";import"./chunk-rw6j20e2.js";export{d as watch,a as processSource,c as processFile,b as generate};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Vc as I}from"./chunk-57agx6g8.js";import{cpus as K}from"os";import{resolve as J}from"path";import{Worker as M}from"worker_threads";var __dirname="/home/runner/work/dtsx/dtsx/packages/dtsx/src";class L{workers=[];taskQueue=[];config;stats={totalTasks:0,completedTasks:0,failedTasks:0,averageDuration:0,activeWorkers:0,idleWorkers:0};isShuttingDown=!1;idleCheckInterval=null;constructor(q={}){let y=q.maxWorkers??Math.max(1,K().length-1);this.config={maxWorkers:y,taskTimeout:q.taskTimeout??30000,recycleAfter:q.recycleAfter??100,idleTimeout:q.idleTimeout??1e4,initialWorkers:q.initialWorkers??Math.min(2,y)}}async init(){let q=Math.min(this.config.initialWorkers,this.config.maxWorkers);for(let y=0;y<q;y++)this.createWorker();if(this.config.idleTimeout>0){if(this.idleCheckInterval=setInterval(()=>{this.checkIdleWorkers()},5000),this.idleCheckInterval&&typeof this.idleCheckInterval==="object"&&"unref"in this.idleCheckInterval)this.idleCheckInterval.unref()}}createWorker(){let q=`
|
|
3
|
+
const { parentPort } = require('worker_threads');
|
|
4
|
+
const bun = typeof Bun !== 'undefined' ? Bun : null;
|
|
5
|
+
const fs = bun ? null : require('node:fs');
|
|
6
|
+
|
|
7
|
+
const libsPromise = (async () => {
|
|
8
|
+
const { extractDeclarations } = await import('${J(__dirname,"extractor.js")}');
|
|
9
|
+
const { processDeclarations } = await import('${J(__dirname,"processor.js")}');
|
|
10
|
+
return { extractDeclarations, processDeclarations };
|
|
11
|
+
})();
|
|
12
|
+
|
|
13
|
+
// Dynamic import for ESM compatibility
|
|
14
|
+
async function processTask(task) {
|
|
15
|
+
const startTime = Date.now();
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const { extractDeclarations, processDeclarations } = await libsPromise;
|
|
19
|
+
|
|
20
|
+
const keepComments = task.config?.keepComments;
|
|
21
|
+
const isolatedDeclarations = task.config?.isolatedDeclarations;
|
|
22
|
+
const importOrder = task.config?.importOrder;
|
|
23
|
+
|
|
24
|
+
if (task.type === 'process-batch') {
|
|
25
|
+
const filePaths = task.filePaths;
|
|
26
|
+
const outPaths = task.outPaths;
|
|
27
|
+
const files = filePaths ? null : (task.files || []);
|
|
28
|
+
const fileCount = filePaths ? filePaths.length : files.length;
|
|
29
|
+
const writeOutput = task.writeOutput === true;
|
|
30
|
+
const results = writeOutput ? null : new Array(fileCount);
|
|
31
|
+
let errorResults = null;
|
|
32
|
+
|
|
33
|
+
let sources = task.sources;
|
|
34
|
+
if (!sources && fileCount > 0) {
|
|
35
|
+
const readPromises = new Array(fileCount);
|
|
36
|
+
for (let i = 0; i < fileCount; i++) {
|
|
37
|
+
const file = files ? files[i] : null;
|
|
38
|
+
const sourceCode = file ? file.sourceCode : undefined;
|
|
39
|
+
const filePath = filePaths ? filePaths[i] : file.filePath;
|
|
40
|
+
if (sourceCode != null) {
|
|
41
|
+
readPromises[i] = Promise.resolve(sourceCode);
|
|
42
|
+
} else if (bun) {
|
|
43
|
+
readPromises[i] = bun.file(filePath).text();
|
|
44
|
+
} else {
|
|
45
|
+
readPromises[i] = Promise.resolve(fs.readFileSync(filePath, 'utf-8'));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
sources = await Promise.all(readPromises);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const ctx = { filePath: '', sourceCode: '', declarations: [] };
|
|
52
|
+
const writePromises = writeOutput && bun ? new Array(fileCount) : null;
|
|
53
|
+
let success = true;
|
|
54
|
+
|
|
55
|
+
for (let i = 0; i < fileCount; i++) {
|
|
56
|
+
const file = files ? files[i] : null;
|
|
57
|
+
const filePath = filePaths ? filePaths[i] : file.filePath;
|
|
58
|
+
const outPath = outPaths ? outPaths[i] : (file ? file.outPath : undefined);
|
|
59
|
+
try {
|
|
60
|
+
const sourceCode = sources ? sources[i] : (file?.sourceCode || '');
|
|
61
|
+
const declarations = extractDeclarations(sourceCode, filePath, keepComments, isolatedDeclarations);
|
|
62
|
+
ctx.filePath = filePath;
|
|
63
|
+
ctx.sourceCode = sourceCode;
|
|
64
|
+
ctx.declarations = declarations;
|
|
65
|
+
const content = processDeclarations(declarations, ctx, true, importOrder);
|
|
66
|
+
|
|
67
|
+
if (writeOutput) {
|
|
68
|
+
if (!outPath) {
|
|
69
|
+
throw new Error('Missing outPath for ' + filePath);
|
|
70
|
+
}
|
|
71
|
+
if (bun) {
|
|
72
|
+
writePromises[i] = bun.write(outPath, content);
|
|
73
|
+
} else {
|
|
74
|
+
fs.writeFileSync(outPath, content);
|
|
75
|
+
}
|
|
76
|
+
} else if (results) {
|
|
77
|
+
results[i] = {
|
|
78
|
+
filePath,
|
|
79
|
+
success: true,
|
|
80
|
+
content,
|
|
81
|
+
declarations,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
const message = error && error.message ? error.message : String(error);
|
|
86
|
+
if (writeOutput) {
|
|
87
|
+
if (!errorResults) {
|
|
88
|
+
errorResults = [];
|
|
89
|
+
}
|
|
90
|
+
errorResults.push({
|
|
91
|
+
filePath,
|
|
92
|
+
success: false,
|
|
93
|
+
error: message,
|
|
94
|
+
});
|
|
95
|
+
} else if (results) {
|
|
96
|
+
results[i] = {
|
|
97
|
+
filePath,
|
|
98
|
+
success: false,
|
|
99
|
+
error: message,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
success = false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (writePromises) {
|
|
107
|
+
await Promise.all(writePromises);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const errorMessage = errorResults?.length
|
|
111
|
+
? (errorResults[0].filePath + ': ' + (errorResults[0].error || 'Worker batch failed'))
|
|
112
|
+
: undefined;
|
|
113
|
+
|
|
114
|
+
return {
|
|
115
|
+
id: task.id,
|
|
116
|
+
success,
|
|
117
|
+
filePath: task.filePath,
|
|
118
|
+
batchResults: writeOutput ? errorResults || undefined : results,
|
|
119
|
+
error: errorMessage,
|
|
120
|
+
duration: Date.now() - startTime,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (task.type === 'extract') {
|
|
125
|
+
const declarations = extractDeclarations(task.sourceCode, task.filePath, keepComments, isolatedDeclarations);
|
|
126
|
+
return {
|
|
127
|
+
id: task.id,
|
|
128
|
+
success: true,
|
|
129
|
+
filePath: task.filePath,
|
|
130
|
+
declarations,
|
|
131
|
+
duration: Date.now() - startTime,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (task.type === 'process') {
|
|
136
|
+
const declarations = extractDeclarations(task.sourceCode, task.filePath, keepComments, isolatedDeclarations);
|
|
137
|
+
const content = processDeclarations(declarations, {
|
|
138
|
+
filePath: task.filePath,
|
|
139
|
+
sourceCode: task.sourceCode,
|
|
140
|
+
declarations,
|
|
141
|
+
}, true, importOrder);
|
|
142
|
+
|
|
143
|
+
return {
|
|
144
|
+
id: task.id,
|
|
145
|
+
success: true,
|
|
146
|
+
filePath: task.filePath,
|
|
147
|
+
content,
|
|
148
|
+
declarations,
|
|
149
|
+
duration: Date.now() - startTime,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
throw new Error('Unknown task type: ' + task.type);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
return {
|
|
156
|
+
id: task.id,
|
|
157
|
+
success: false,
|
|
158
|
+
filePath: task.filePath,
|
|
159
|
+
error: error.message,
|
|
160
|
+
duration: Date.now() - startTime,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
parentPort.on('message', async (task) => {
|
|
166
|
+
const result = await processTask(task);
|
|
167
|
+
parentPort.postMessage(result);
|
|
168
|
+
});
|
|
169
|
+
`,y=new M(q,{eval:!0}),F={worker:y,busy:!1,taskCount:0,lastActive:Date.now(),currentTask:null};return y.on("message",(E)=>{this.handleWorkerResult(F,E)}),y.on("error",(E)=>{I.error("Worker error:",E),this.handleWorkerError(F,E)}),y.on("exit",(E)=>{if(E!==0&&!this.isShuttingDown)I.error(`Worker exited with code ${E}`),this.removeWorker(F)}),this.workers.push(F),this.updateStats(),F}handleWorkerResult(q,y){if(q.busy=!1,q.taskCount++,q.lastActive=Date.now(),q.currentTask&&q.currentTask.id===y.id){clearTimeout(q.currentTask.timeout);let{resolve:E}=q.currentTask;q.currentTask=null,E(y)}if(y.success)this.stats.completedTasks++;else this.stats.failedTasks++;let F=this.stats.averageDuration*(this.stats.completedTasks+this.stats.failedTasks-1)+y.duration;if(this.stats.averageDuration=F/(this.stats.completedTasks+this.stats.failedTasks),this.updateStats(),q.taskCount>=this.config.recycleAfter)this.recycleWorker(q);this.processQueue()}handleWorkerError(q,y){if(q.busy=!1,q.currentTask){clearTimeout(q.currentTask.timeout);let{reject:F}=q.currentTask;q.currentTask=null,F(y)}this.stats.failedTasks++,this.updateStats(),this.recycleWorker(q),this.processQueue()}removeWorker(q){let y=this.workers.indexOf(q);if(y!==-1)this.workers.splice(y,1),q.worker.terminate();this.updateStats()}recycleWorker(q){if(this.removeWorker(q),!this.isShuttingDown&&this.workers.length<this.config.maxWorkers)this.createWorker()}checkIdleWorkers(){let q=Date.now(),y=1;for(let F=this.workers.length-1;F>=0;F--){let E=this.workers[F];if(!E.busy&&q-E.lastActive>this.config.idleTimeout&&this.workers.length>1)this.removeWorker(E)}}processQueue(){while(this.taskQueue.length>0){let q;for(let G=0;G<this.workers.length;G++)if(!this.workers[G].busy){q=this.workers[G];break}if(!q&&this.workers.length<this.config.maxWorkers)q=this.createWorker();if(!q)return;let{task:y,resolve:F,reject:E}=this.taskQueue.shift();q.busy=!0,q.lastActive=Date.now();let H=setTimeout(()=>{if(q.currentTask?.id===y.id)q.currentTask=null;E(Error(`Task ${y.id} timed out`)),this.recycleWorker(q)},this.config.taskTimeout);q.currentTask={id:y.id,resolve:F,reject:E,timeout:H},q.worker.postMessage(y),this.updateStats()}}async submit(q){return this.stats.totalTasks++,new Promise((y,F)=>{this.taskQueue.push({task:q,resolve:y,reject:F}),this.processQueue()})}async processFiles(q,y={}){let F=q.map((E,H)=>({id:`task-${H}-${Date.now()}`,type:"process",filePath:E.path,sourceCode:E.content,config:y}));return Promise.all(F.map((E)=>this.submit(E)))}updateStats(){let q=0;for(let y=0;y<this.workers.length;y++)if(this.workers[y].busy)q++;this.stats.activeWorkers=q,this.stats.idleWorkers=this.workers.length-q}getStats(){return{...this.stats}}async shutdown(){if(this.isShuttingDown=!0,this.idleCheckInterval)clearInterval(this.idleCheckInterval);while(this.taskQueue.length>0||this.workers.some((q)=>q.busy))await new Promise((q)=>setTimeout(q,100));await Promise.all(this.workers.map((q)=>q.worker.terminate())),this.workers=[]}}function N(q={}){return new L(q)}async function U(q,y={},F={}){let E=N(F);await E.init();try{return await E.processFiles(q,y)}finally{await E.shutdown()}}function V(q,y){let F=[];for(let E=0;E<q.length;E+=y)F.push(q.slice(E,E+y));return F}function X(q,y=K().length){if(q<=y)return 1;let E=y*3;return Math.max(1,Math.ceil(q/E))}
|
|
170
|
+
export{L as Z,N as _,U as $,V as aa,X as ba};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{nc as J}from"./chunk-rnt0wkrk.js";var S=typeof globalThis.Bun?.hash==="function";function z(u){if(S)return Bun.hash(u);let g=0;for(let f=0;f<u.length;f++){let b=u.charCodeAt(f);g=(g<<5)-g+b,g=g&g}return g}var T=100,G=0,B=new Map;function Y(u,g,f=!0,b=!1){let x=z(u),F=`${g}:${f?1:0}:${b?1:0}`,p=B.get(F);if(p&&p.contentHash===x)return p.lastAccess=++G,p.declarations;let j=J(u,g,f,b);if(B.set(F,{declarations:j,contentHash:x,lastAccess:++G}),B.size>T){let w=null,q=1/0;for(let[Q,v]of B)if(v.lastAccess<q)q=v.lastAccess,w=Q;if(w)B.delete(w)}return j}function $(){B.clear()}
|
|
3
|
+
export{z as kc,Y as lc,$ as mc};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{A as b,B as c,C as d,D as e,E as f,F as g,G as h,H as i,z as a}from"./chunk-jm5ywn4e.js";import"./chunk-p1d09y82.js";import"./chunk-rw6j20e2.js";export{i as validateGeneratedDeclarations,c as validateDeclarations,h as typeCheckWithConfig,b as typeCheck,a as loadCompilerOptions,e as getTypeAtPosition,f as getQuickInfo,g as formatTypeCheckResults,d as checkIsolatedDeclarations};
|