@stacksjs/dtsx 0.9.8 → 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.
Files changed (113) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +243 -15
  3. package/dist/bin/cli.js +10 -22
  4. package/dist/branded-types.d.ts +168 -0
  5. package/dist/bundler.d.ts +55 -0
  6. package/dist/cache.d.ts +43 -0
  7. package/dist/checker.d.ts +107 -0
  8. package/dist/chunk-09zp67d8.js +6 -0
  9. package/dist/chunk-0kmfaaz6.js +2 -0
  10. package/dist/chunk-1mm3t0nr.js +3 -0
  11. package/dist/chunk-2f046tgr.js +2 -0
  12. package/dist/chunk-3g2v2ns2.js +2 -0
  13. package/dist/chunk-3j7r0fxz.js +2 -0
  14. package/dist/chunk-3mxzfgcv.js +75 -0
  15. package/dist/chunk-4ev1n7r7.js +3 -0
  16. package/dist/chunk-57agx6g8.js +3 -0
  17. package/dist/chunk-6ppqaypd.js +2 -0
  18. package/dist/chunk-6qv7p9sg.js +170 -0
  19. package/dist/chunk-6s7n1gt0.js +2 -0
  20. package/dist/chunk-74j5mydx.js +3 -0
  21. package/dist/chunk-7cpp6v8f.js +2 -0
  22. package/dist/chunk-9a3jfxnc.js +3 -0
  23. package/dist/chunk-9mjc7ddv.js +19 -0
  24. package/dist/chunk-axb2kjeq.js +2 -0
  25. package/dist/chunk-bn29kee5.js +102 -0
  26. package/dist/chunk-c18vx9sq.js +2 -0
  27. package/dist/chunk-d0p3jzwb.js +34 -0
  28. package/dist/chunk-dk2vv0np.js +15 -0
  29. package/dist/chunk-e3j9tecw.js +3 -0
  30. package/dist/chunk-f18nyrrb.js +32 -0
  31. package/dist/chunk-fbqcsr60.js +22 -0
  32. package/dist/chunk-ffqpf34b.js +3 -0
  33. package/dist/chunk-fw6wcdfd.js +4 -0
  34. package/dist/chunk-h12gdfk9.js +2 -0
  35. package/dist/chunk-j22v8wfe.js +33 -0
  36. package/dist/chunk-jm5ywn4e.js +13 -0
  37. package/dist/chunk-jvz9t6pq.js +2 -0
  38. package/dist/chunk-k5h5ppp5.js +2 -0
  39. package/dist/chunk-p1d09y82.js +449 -0
  40. package/dist/chunk-pyxbb193.js +2 -0
  41. package/dist/chunk-q75q4w1s.js +3 -0
  42. package/dist/chunk-r1m3q3dj.js +2 -0
  43. package/dist/chunk-r1ywapeb.js +6 -0
  44. package/dist/chunk-rnt0wkrk.js +23 -0
  45. package/dist/chunk-rrkq4k1n.js +2 -0
  46. package/dist/chunk-rw6j20e2.js +3 -0
  47. package/dist/chunk-v96rjx7x.js +134 -0
  48. package/dist/circular.d.ts +82 -0
  49. package/dist/compat.d.ts +108 -0
  50. package/dist/config.d.ts +33 -3
  51. package/dist/diff.d.ts +82 -0
  52. package/dist/docs.d.ts +97 -0
  53. package/dist/errors.d.ts +113 -0
  54. package/dist/extractor/builders.d.ts +38 -0
  55. package/dist/extractor/cache.d.ts +47 -0
  56. package/dist/extractor/declarations.d.ts +50 -0
  57. package/dist/extractor/directives.d.ts +9 -0
  58. package/dist/extractor/extract.d.ts +10 -0
  59. package/dist/extractor/hash.d.ts +1 -0
  60. package/dist/extractor/helpers.d.ts +39 -0
  61. package/dist/extractor/index.d.ts +70 -0
  62. package/dist/extractor/scanner.d.ts +6 -0
  63. package/dist/extractor.d.ts +3 -4
  64. package/dist/formats.d.ts +50 -0
  65. package/dist/formatter.d.ts +61 -0
  66. package/dist/generator.d.ts +12 -3
  67. package/dist/import-sorter.d.ts +99 -0
  68. package/dist/incremental.d.ts +84 -0
  69. package/dist/index.d.ts +54 -1
  70. package/dist/logger.d.ts +57 -0
  71. package/dist/lsp.d.ts +317 -0
  72. package/dist/memory.d.ts +110 -0
  73. package/dist/merger.d.ts +38 -0
  74. package/dist/optimizer.d.ts +52 -0
  75. package/dist/output-normalizer.d.ts +123 -0
  76. package/dist/parallel-processor.d.ts +63 -0
  77. package/dist/parser.d.ts +24 -15
  78. package/dist/plugins/bun.d.ts +58 -0
  79. package/dist/plugins/esbuild.d.ts +63 -0
  80. package/dist/plugins/index.d.ts +14 -0
  81. package/dist/plugins/tsup.d.ts +53 -0
  82. package/dist/plugins/vite.d.ts +49 -0
  83. package/dist/plugins/webpack.d.ts +66 -0
  84. package/dist/plugins.d.ts +83 -0
  85. package/dist/process-source.d.ts +11 -0
  86. package/dist/processor/cache.d.ts +16 -0
  87. package/dist/processor/comments.d.ts +7 -0
  88. package/dist/processor/declarations.d.ts +37 -0
  89. package/dist/processor/imports.d.ts +65 -0
  90. package/dist/processor/index.d.ts +34 -0
  91. package/dist/processor/type-inference.d.ts +106 -0
  92. package/dist/processor.d.ts +3 -43
  93. package/dist/profiling.d.ts +101 -0
  94. package/dist/security.d.ts +100 -0
  95. package/dist/sourcemap.d.ts +125 -0
  96. package/dist/src/index.js +55 -2
  97. package/dist/src/plugins/bun.js +2 -0
  98. package/dist/src/plugins/esbuild.js +2 -0
  99. package/dist/src/plugins/index.js +2 -0
  100. package/dist/src/plugins/tsup.js +2 -0
  101. package/dist/src/plugins/vite.js +2 -0
  102. package/dist/src/plugins/webpack.js +2 -0
  103. package/dist/tracking.d.ts +89 -0
  104. package/dist/transformers.d.ts +173 -0
  105. package/dist/tree-shaker.d.ts +69 -0
  106. package/dist/type-mappings.d.ts +148 -0
  107. package/dist/types.d.ts +137 -7
  108. package/dist/utils.d.ts +53 -1
  109. package/dist/watcher.d.ts +64 -0
  110. package/dist/worker.d.ts +84 -0
  111. package/dist/workspace.d.ts +62 -0
  112. package/package.json +49 -11
  113. package/dist/chunk-qsyn1k3w.js +0 -504
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Get preset mappings
3
+ */
4
+ export declare function getPresetMappings(preset: TypeMappingPreset): TypeMappingRule[];
5
+ /**
6
+ * Create a type mapper with configuration
7
+ */
8
+ export declare function createTypeMapper(config?: TypeMappingConfig): TypeMapper;
9
+ /**
10
+ * Apply type mappings to declaration text
11
+ */
12
+ export declare function applyTypeMappings(declarationText: string, mapper: TypeMapper, context?: Partial<TypeMappingContext>): string;
13
+ /**
14
+ * Default type mapper instance
15
+ */
16
+ export declare const defaultTypeMapper: TypeMapper;
17
+ /**
18
+ * Strict type mapper instance
19
+ */
20
+ export declare const strictTypeMapper: TypeMapper;
21
+ /**
22
+ * Built-in type transformers
23
+ * @defaultValue
24
+ * ```ts
25
+ * {
26
+ * /**
27
+ * * Make all types readonly
28
+ * */
29
+ * makeReadonly: (type: string) => any,
30
+ * /**
31
+ * * Make type nullable
32
+ * */
33
+ * makeNullable: (type: string) => any,
34
+ * /**
35
+ * * Make type optional (add undefined)
36
+ * */
37
+ * makeOptional: (type: string) => any,
38
+ * /**
39
+ * * Remove null/undefined from type
40
+ * */
41
+ * makeRequired: (type: string) => any,
42
+ * /**
43
+ * * Wrap in Promise
44
+ * */
45
+ * promisify: (type: string) => any,
46
+ * /**
47
+ * * Unwrap Promise
48
+ * */
49
+ * unpromisify: (type: string) => any,
50
+ * /**
51
+ * * Convert to array type
52
+ * */
53
+ * arrayify: (type: string) => any,
54
+ * /**
55
+ * * Unwrap array type
56
+ * */
57
+ * unarrayify: (type: string) => any
58
+ * }
59
+ * ```
60
+ */
61
+ export declare const TypeTransformers: {
62
+ /**
63
+ * Make all types readonly
64
+ */
65
+ makeReadonly: (type: string) => any;
66
+ /**
67
+ * Make type nullable
68
+ */
69
+ makeNullable: (type: string) => any;
70
+ /**
71
+ * Make type optional (add undefined)
72
+ */
73
+ makeOptional: (type: string) => any;
74
+ /**
75
+ * Remove null/undefined from type
76
+ */
77
+ makeRequired: (type: string) => any;
78
+ /**
79
+ * Wrap in Promise
80
+ */
81
+ promisify: (type: string) => any;
82
+ /**
83
+ * Unwrap Promise
84
+ */
85
+ unpromisify: (type: string) => any;
86
+ /**
87
+ * Convert to array type
88
+ */
89
+ arrayify: (type: string) => any;
90
+ /**
91
+ * Unwrap array type
92
+ */
93
+ unarrayify: (type: string) => any
94
+ };
95
+ /**
96
+ * Custom type mappings for DTS generation
97
+ * Allows users to specify type replacements and transformations
98
+ */
99
+ /**
100
+ * Type mapping rule
101
+ */
102
+ export declare interface TypeMappingRule {
103
+ pattern: string | RegExp
104
+ replacement: string
105
+ condition?: (context: TypeMappingContext) => boolean
106
+ global?: boolean
107
+ priority?: number
108
+ }
109
+ /**
110
+ * Context passed to type mapping functions
111
+ */
112
+ export declare interface TypeMappingContext {
113
+ type: string
114
+ declarationName?: string
115
+ declarationKind?: string
116
+ filePath?: string
117
+ isReturnType?: boolean
118
+ isParameterType?: boolean
119
+ isPropertyType?: boolean
120
+ }
121
+ /**
122
+ * Type mapping configuration
123
+ */
124
+ export declare interface TypeMappingConfig {
125
+ rules: TypeMappingRule[]
126
+ presets?: TypeMappingPreset[]
127
+ includeDefaults?: boolean
128
+ }
129
+ /**
130
+ * Available type mapping presets
131
+ */
132
+ export type TypeMappingPreset = | 'strict' // Convert 'any' to 'unknown'
133
+ | 'readonly' // Add readonly to array types
134
+ | 'nullable' // Convert undefined unions to optional
135
+ | 'branded' // Use branded types for primitives
136
+ | 'simplified' // Simplify complex utility types;
137
+ /**
138
+ * Type mapper class for applying transformations
139
+ */
140
+ export declare class TypeMapper {
141
+ constructor(config?: TypeMappingConfig);
142
+ map(type: string, context?: Partial<TypeMappingContext>): string;
143
+ mapAll(types: string[], context?: Partial<TypeMappingContext>): string[];
144
+ addRule(rule: TypeMappingRule): void;
145
+ removeRules(pattern: string | RegExp): number;
146
+ clearCache(): void;
147
+ getRules(): readonly TypeMappingRule[];
148
+ }
package/dist/types.d.ts CHANGED
@@ -13,6 +13,131 @@ export declare interface DtsGenerationConfig {
13
13
  tsconfigPath: string
14
14
  verbose: boolean | string[]
15
15
  outputStructure?: 'mirror' | 'flat'
16
+ importOrder?: string[]
17
+ dryRun?: boolean
18
+ stats?: boolean
19
+ continueOnError?: boolean
20
+ logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'silent'
21
+ exclude?: string[]
22
+ outputFormat?: 'text' | 'json'
23
+ progress?: boolean
24
+ diff?: boolean
25
+ validate?: boolean
26
+ watch?: boolean
27
+ parallel?: boolean
28
+ concurrency?: number
29
+ declarationMap?: boolean
30
+ plugins?: import('./plugins').Plugin[]
31
+ bundle?: boolean
32
+ bundleOutput?: string
33
+ incremental?: boolean
34
+ clearCache?: boolean
35
+ indentStyle?: 'spaces' | 'tabs'
36
+ indentSize?: number
37
+ prettier?: boolean
38
+ include?: string[]
39
+ isolatedDeclarations?: boolean
40
+ typeMappings?: import('./type-mappings').TypeMappingConfig
41
+ lineEnding?: 'lf' | 'crlf' | 'auto'
42
+ normalizeOutput?: boolean
43
+ declarationOrder?: {
44
+ kinds?: import('./types').DeclarationKind[]
45
+ alphabetize?: boolean
46
+ groupExports?: boolean
47
+ }
48
+ tracking?: TrackingConfig
49
+ profiling?: ProfilingConfig
50
+ typeInference?: TypeInferenceConfig
51
+ typeChecking?: TypeCheckingConfig
52
+ typeValidation?: TypeValidationConfig
53
+ }
54
+ /**
55
+ * Tracking configuration for debugging type and import usage
56
+ */
57
+ export declare interface TrackingConfig {
58
+ types?: boolean
59
+ relationships?: boolean
60
+ usage?: boolean
61
+ imports?: boolean
62
+ importUsage?: boolean
63
+ importRelationships?: boolean
64
+ }
65
+ /**
66
+ * Profiling configuration for performance analysis
67
+ */
68
+ export declare interface ProfilingConfig {
69
+ memory?: boolean
70
+ memoryLimit?: number
71
+ cpu?: boolean
72
+ samplingInterval?: number
73
+ io?: boolean
74
+ trackOperations?: ('read' | 'write')[]
75
+ outputFile?: string
76
+ }
77
+ /**
78
+ * Type inference configuration
79
+ */
80
+ export declare interface TypeInferenceConfig {
81
+ enabled?: boolean
82
+ strictness?: 'loose' | 'normal' | 'strict'
83
+ inferReturnTypes?: boolean
84
+ inferConstTypes?: boolean
85
+ }
86
+ /**
87
+ * Type checking configuration
88
+ */
89
+ export declare interface TypeCheckingConfig {
90
+ enabled?: boolean
91
+ strictness?: 'loose' | 'normal' | 'strict'
92
+ warningsAsErrors?: boolean
93
+ maxErrors?: number
94
+ }
95
+ /**
96
+ * Type validation configuration
97
+ */
98
+ export declare interface TypeValidationConfig {
99
+ enabled?: boolean
100
+ rules?: {
101
+ noAny?: boolean
102
+ noUnknown?: boolean
103
+ noImplicitAny?: boolean
104
+ explicitReturnTypes?: boolean
105
+ explicitParameterTypes?: boolean
106
+ }
107
+ }
108
+ /**
109
+ * Source location for error reporting
110
+ */
111
+ export declare interface SourceLocation {
112
+ line: number
113
+ column: number
114
+ offset?: number
115
+ }
116
+ /**
117
+ * Detailed error information with source location
118
+ */
119
+ export declare interface DtsError {
120
+ file: string
121
+ message: string
122
+ code?: string
123
+ location?: SourceLocation
124
+ stack?: string
125
+ suggestion?: string
126
+ }
127
+ /**
128
+ * Generation statistics
129
+ */
130
+ export declare interface GenerationStats {
131
+ filesProcessed: number
132
+ filesGenerated: number
133
+ filesFailed: number
134
+ filesValidated: number
135
+ validationErrors: number
136
+ declarationsFound: number
137
+ importsProcessed: number
138
+ exportsProcessed: number
139
+ durationMs: number
140
+ errors: DtsError[]
16
141
  }
17
142
  /**
18
143
  * Declaration
@@ -20,7 +145,7 @@ export declare interface DtsGenerationConfig {
20
145
  * Represents a parsed declaration from TypeScript source
21
146
  */
22
147
  export declare interface Declaration {
23
- kind: 'function' | 'variable' | 'interface' | 'type' | 'class' | 'enum' | 'import' | 'export' | 'module'
148
+ kind: DeclarationKind
24
149
  name: string
25
150
  text: string
26
151
  leadingComments?: string[]
@@ -34,10 +159,11 @@ export declare interface Declaration {
34
159
  members?: Declaration[]
35
160
  parameters?: ParameterDeclaration[]
36
161
  returnType?: string
37
- value?: any
162
+ value?: unknown
38
163
  source?: string
39
164
  specifiers?: ImportSpecifier[]
40
165
  isTypeOnly?: boolean
166
+ isSideEffect?: boolean
41
167
  isAsync?: boolean
42
168
  isGenerator?: boolean
43
169
  overloads?: string[]
@@ -71,19 +197,23 @@ export declare interface ProcessingContext {
71
197
  filePath: string
72
198
  sourceCode: string
73
199
  declarations: Declaration[]
74
- imports: Map<string, Set<string>>
75
- exports: Set<string>
76
- usedTypes: Set<string>
200
+ imports?: Map<string, Set<string>>
201
+ exports?: Set<string>
202
+ usedTypes?: Set<string>
77
203
  }
78
204
  /**
79
205
  * DtsGenerationOption
80
206
  *
81
207
  * This is the configuration object for the DTS generation process.
82
208
  */
83
- export type DtsGenerationOption = Partial<DtsGenerationConfig>
209
+ export type DtsGenerationOption = Partial<DtsGenerationConfig>;
84
210
  /**
85
211
  * DtsGenerationOptions
86
212
  *
87
213
  * This is the configuration object for the DTS generation process.
88
214
  */
89
- export type DtsGenerationOptions = DtsGenerationOption | DtsGenerationOption[]
215
+ export type DtsGenerationOptions = DtsGenerationOption | DtsGenerationOption[];
216
+ /**
217
+ * Declaration kind - all possible declaration types
218
+ */
219
+ export type DeclarationKind = 'function' | 'variable' | 'interface' | 'type' | 'class' | 'enum' | 'import' | 'export' | 'module' | 'namespace' | 'unknown';
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,57 @@
1
1
  import type { DtsGenerationConfig } from './types';
2
+ /**
3
+ * Exhaustive check helper for switch statements
4
+ * This function should never be called if all cases are handled
5
+ * TypeScript will error if a case is missing
6
+ */
7
+ export declare function assertNever(value: never, message?: string): never;
2
8
  export declare function writeToFile(filePath: string, content: string): Promise<void>;
3
9
  export declare function getAllTypeScriptFiles(directory?: string): Promise<string[]>;
4
10
  // only checks for 2 potentially nested levels
5
- export declare function checkIsolatedDeclarations(options?: DtsGenerationConfig): Promise<boolean>;
11
+ export declare function checkIsolatedDeclarationsConfig(options?: DtsGenerationConfig): Promise<boolean>;
12
+ /**
13
+ * Validate a .d.ts file content against TypeScript compiler
14
+ */
15
+ export declare function validateDtsContent(content: string, filename: string): ValidationResult;
16
+ /**
17
+ * Simple line-by-line diff between two strings
18
+ * Returns formatted diff output with +/- prefixes
19
+ */
20
+ export declare function createDiff(oldContent: string, newContent: string, filename: string): string;
21
+ /**
22
+ * Generate a simple source map for a declaration file
23
+ * This creates a basic 1:1 mapping since we're doing declaration extraction
24
+ */
25
+ export declare function generateDeclarationMap(dtsContent: string, dtsFilename: string, sourceFilename: string, sourceContent: string): DeclarationSourceMap;
26
+ /**
27
+ * Add source map URL comment to declaration content
28
+ */
29
+ export declare function addSourceMapComment(dtsContent: string, mapFilename: string): string;
30
+ /**
31
+ * Validation error details
32
+ */
33
+ export declare interface ValidationError {
34
+ line: number
35
+ column: number
36
+ message: string
37
+ code?: string
38
+ suggestion?: string
39
+ }
40
+ /**
41
+ * Validation result for a .d.ts file
42
+ */
43
+ export declare interface ValidationResult {
44
+ isValid: boolean
45
+ errors: ValidationError[]
46
+ }
47
+ /**
48
+ * Source map for declaration files
49
+ */
50
+ export declare interface DeclarationSourceMap {
51
+ version: 3
52
+ file: string
53
+ sourceRoot: string
54
+ sources: string[]
55
+ sourcesContent: string[]
56
+ mappings: string
57
+ }
@@ -0,0 +1,64 @@
1
+ import type { DtsGenerationConfig } from './types';
2
+ /**
3
+ * Create a file watcher for .d.ts generation
4
+ */
5
+ export declare function createWatcher(config: WatchConfig, buildFn: (files?: string[]) => Promise<WatchBuildResult>): Watcher;
6
+ /**
7
+ * Watch and generate .d.ts files
8
+ */
9
+ export declare function watchAndGenerate(config: DtsGenerationConfig & WatchConfig, generator: (config: DtsGenerationConfig) => Promise<{ filesProcessed: number, errors: string[] }>): Promise<Watcher>;
10
+ /**
11
+ * Format watch build result for display
12
+ */
13
+ export declare function formatWatchResult(result: WatchBuildResult): string;
14
+ /**
15
+ * Create a simple console logger for watch mode
16
+ */
17
+ export declare function createWatchLogger(): {
18
+ onChange: (event: WatchEvent) => void
19
+ onBuildStart: () => void
20
+ onBuildComplete: (result: WatchBuildResult) => void
21
+ onError: (error: Error) => void
22
+ };
23
+ /**
24
+ * Watch configuration
25
+ */
26
+ export declare interface WatchConfig {
27
+ root: string
28
+ include?: string[]
29
+ exclude?: string[]
30
+ debounce?: number
31
+ initialBuild?: boolean
32
+ clearScreen?: boolean
33
+ onChange?: (event: WatchEvent) => void | Promise<void>
34
+ onBuildStart?: () => void | Promise<void>
35
+ onBuildComplete?: (result: WatchBuildResult) => void | Promise<void>
36
+ onError?: (error: Error) => void | Promise<void>
37
+ }
38
+ /**
39
+ * Watch event
40
+ */
41
+ export declare interface WatchEvent {
42
+ type: 'add' | 'change' | 'unlink'
43
+ path: string
44
+ relativePath: string
45
+ }
46
+ /**
47
+ * Build result from watch
48
+ */
49
+ export declare interface WatchBuildResult {
50
+ success: boolean
51
+ duration: number
52
+ filesProcessed: number
53
+ errors: string[]
54
+ }
55
+ /**
56
+ * Watcher instance
57
+ */
58
+ export declare interface Watcher {
59
+ start: () => Promise<void>
60
+ stop: () => void
61
+ rebuild: () => Promise<WatchBuildResult>
62
+ isWatching: () => boolean
63
+ getWatchedFiles: () => string[]
64
+ }
@@ -0,0 +1,84 @@
1
+ import type { Declaration, DtsGenerationConfig } from './types';
2
+ /**
3
+ * Create a worker pool with default configuration
4
+ */
5
+ export declare function createWorkerPool(config?: WorkerPoolConfig): WorkerPool;
6
+ /**
7
+ * Process files in parallel using a temporary worker pool
8
+ */
9
+ export declare function parallelProcess(files: Array<{ path: string, content: string }>, config?: Partial<DtsGenerationConfig>, poolConfig?: WorkerPoolConfig): Promise<WorkerResult[]>;
10
+ /**
11
+ * Batch files into chunks for processing
12
+ */
13
+ export declare function batchFiles<T>(files: T[], batchSize: number): T[][];
14
+ /**
15
+ * Calculate optimal batch size based on file count and CPU cores
16
+ */
17
+ export declare function calculateOptimalBatchSize(fileCount: number, cpuCount?: number): number;
18
+ /**
19
+ * Worker pool configuration
20
+ */
21
+ export declare interface WorkerPoolConfig {
22
+ maxWorkers?: number
23
+ taskTimeout?: number
24
+ recycleAfter?: number
25
+ idleTimeout?: number
26
+ initialWorkers?: number
27
+ }
28
+ /**
29
+ * Task to be processed by a worker
30
+ */
31
+ export declare interface WorkerTask {
32
+ id: string
33
+ type: 'process' | 'extract' | 'transform' | 'process-batch'
34
+ filePath: string
35
+ sourceCode?: string
36
+ files?: Array<{ filePath: string, sourceCode?: string, outPath?: string }>
37
+ filePaths?: string[]
38
+ sources?: string[]
39
+ outPaths?: string[]
40
+ config: Partial<DtsGenerationConfig>
41
+ writeOutput?: boolean
42
+ }
43
+ /**
44
+ * Result from a worker task
45
+ */
46
+ export declare interface WorkerBatchResult {
47
+ filePath: string
48
+ success: boolean
49
+ content?: string
50
+ declarations?: Declaration[]
51
+ error?: string
52
+ }
53
+ export declare interface WorkerResult {
54
+ id: string
55
+ success: boolean
56
+ filePath: string
57
+ content?: string
58
+ declarations?: Declaration[]
59
+ batchResults?: WorkerBatchResult[]
60
+ error?: string
61
+ duration: number
62
+ }
63
+ /**
64
+ * Worker statistics
65
+ */
66
+ export declare interface WorkerStats {
67
+ totalTasks: number
68
+ completedTasks: number
69
+ failedTasks: number
70
+ averageDuration: number
71
+ activeWorkers: number
72
+ idleWorkers: number
73
+ }
74
+ /**
75
+ * Worker pool for parallel processing
76
+ */
77
+ export declare class WorkerPool {
78
+ constructor(config?: WorkerPoolConfig);
79
+ init(): Promise<void>;
80
+ submit(task: WorkerTask): Promise<WorkerResult>;
81
+ processFiles(files: Array<{ path: string, content: string }>, config?: Partial<DtsGenerationConfig>): Promise<WorkerResult[]>;
82
+ getStats(): WorkerStats;
83
+ shutdown(): Promise<void>;
84
+ }
@@ -0,0 +1,62 @@
1
+ import type { DtsGenerationConfig, GenerationStats } from './types';
2
+ /**
3
+ * Discover workspace projects from TypeScript project references
4
+ */
5
+ export declare function discoverWorkspaceProjects(rootTsConfig: string): Promise<WorkspaceProject[]>;
6
+ /**
7
+ * Sort projects by their dependencies (topological sort)
8
+ * Projects with no dependencies come first
9
+ */
10
+ export declare function sortProjectsByDependencies(projects: WorkspaceProject[]): WorkspaceProject[];
11
+ /**
12
+ * Generate declarations for all projects in a workspace
13
+ */
14
+ export declare function generateWorkspace(config: WorkspaceConfig): Promise<WorkspaceGenerationResult>;
15
+ /**
16
+ * Discover and generate declarations for a monorepo
17
+ * Automatically discovers projects from TypeScript project references
18
+ */
19
+ export declare function generateMonorepo(rootPath: string, options?: Partial<DtsGenerationConfig>): Promise<WorkspaceGenerationResult>;
20
+ /**
21
+ * Parse workspace patterns from package.json workspaces field
22
+ */
23
+ export declare function discoverWorkspaceFromPackageJson(rootPath: string): Promise<string[]>;
24
+ /**
25
+ * Resolve workspace patterns to actual project paths
26
+ */
27
+ export declare function resolveWorkspacePatterns(rootPath: string, patterns: string[]): Promise<string[]>;
28
+ /**
29
+ * Generate declarations for a workspace defined in package.json
30
+ */
31
+ export declare function generateFromPackageWorkspaces(rootPath: string, options?: Partial<DtsGenerationConfig>): Promise<WorkspaceGenerationResult>;
32
+ /**
33
+ * Workspace project configuration
34
+ */
35
+ export declare interface WorkspaceProject {
36
+ name: string
37
+ root: string
38
+ tsconfigPath: string
39
+ references: string[]
40
+ config?: Partial<DtsGenerationConfig>
41
+ }
42
+ /**
43
+ * Workspace configuration
44
+ */
45
+ export declare interface WorkspaceConfig {
46
+ root: string
47
+ projects: WorkspaceProject[]
48
+ sharedConfig?: Partial<DtsGenerationConfig>
49
+ }
50
+ /**
51
+ * Result of workspace generation
52
+ */
53
+ export declare interface WorkspaceGenerationResult {
54
+ success: boolean
55
+ projects: Array<{
56
+ name: string
57
+ stats: GenerationStats
58
+ success: boolean
59
+ error?: string
60
+ }>
61
+ durationMs: number
62
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/dtsx",
3
3
  "type": "module",
4
- "version": "0.9.8",
4
+ "version": "0.9.10",
5
5
  "description": "A modern, fast .d.ts generation tool, powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -25,9 +25,35 @@
25
25
  ],
26
26
  "exports": {
27
27
  ".": {
28
+ "types": "./dist/index.d.ts",
28
29
  "import": "./dist/src/index.js"
29
30
  },
31
+ "./vite": {
32
+ "types": "./dist/plugins/vite.d.ts",
33
+ "import": "./dist/src/plugins/vite.js"
34
+ },
35
+ "./bun": {
36
+ "types": "./dist/plugins/bun.d.ts",
37
+ "import": "./dist/src/plugins/bun.js"
38
+ },
39
+ "./esbuild": {
40
+ "types": "./dist/plugins/esbuild.d.ts",
41
+ "import": "./dist/src/plugins/esbuild.js"
42
+ },
43
+ "./tsup": {
44
+ "types": "./dist/plugins/tsup.d.ts",
45
+ "import": "./dist/src/plugins/tsup.js"
46
+ },
47
+ "./webpack": {
48
+ "types": "./dist/plugins/webpack.d.ts",
49
+ "import": "./dist/src/plugins/webpack.js"
50
+ },
51
+ "./plugins": {
52
+ "types": "./dist/plugins/index.d.ts",
53
+ "import": "./dist/src/plugins/index.js"
54
+ },
30
55
  "./*": {
56
+ "types": "./dist/*.d.ts",
31
57
  "import": "./dist/*"
32
58
  }
33
59
  },
@@ -40,16 +66,19 @@
40
66
  "dist"
41
67
  ],
42
68
  "scripts": {
69
+ "benchmark": "bun run benchmark.ts",
70
+ "benchmark:ci": "bun run benchmark.ts --ci --json",
71
+ "benchmark:quick": "bun run benchmark.ts --quick",
43
72
  "build": "bun build.ts && bun run compile",
44
- "compile": "bun build ./bin/cli.ts --compile --minify --outfile bin/dtsx",
73
+ "compile": "bun build ./bin/cli.ts --compile --minify --format=esm --outfile bin/dtsx",
45
74
  "compile:all": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64",
46
- "compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile bin/dtsx-linux-x64",
47
- "compile:linux-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile bin/dtsx-linux-arm64",
48
- "compile:windows-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile bin/dtsx-windows-x64.exe",
49
- "compile:darwin-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile bin/dtsx-darwin-x64",
50
- "compile:darwin-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile bin/dtsx-darwin-arm64",
51
- "lint": "bunx --bun eslint .",
52
- "lint:fix": "bunx --bun eslint . --fix",
75
+ "compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --format=esm --target=bun-linux-x64 --outfile bin/dtsx-linux-x64",
76
+ "compile:linux-arm64": "bun build ./bin/cli.ts --compile --minify --format=esm --target=bun-linux-arm64 --outfile bin/dtsx-linux-arm64",
77
+ "compile:windows-x64": "bun build ./bin/cli.ts --compile --minify --format=esm --target=bun-windows-x64 --outfile bin/dtsx-windows-x64.exe",
78
+ "compile:darwin-x64": "bun build ./bin/cli.ts --compile --minify --format=esm --target=bun-darwin-x64 --outfile bin/dtsx-darwin-x64",
79
+ "compile:darwin-arm64": "bun build ./bin/cli.ts --compile --minify --format=esm --target=bun-darwin-arm64 --outfile bin/dtsx-darwin-arm64",
80
+ "lint": "bunx --bun pickier run . --mode lint",
81
+ "lint:fix": "bunx --bun pickier run . --mode lint --fix",
53
82
  "fresh": "bunx rimraf node_modules/ bun.lock && bun i",
54
83
  "changelog": "bunx changelogen --output CHANGELOG.md",
55
84
  "prepublishOnly": "bun --bun run build && bun run compile:all && bun run zip",
@@ -64,17 +93,26 @@
64
93
  "zip:darwin-x64": "zip -j bin/dtsx-darwin-x64.zip bin/dtsx-darwin-x64",
65
94
  "zip:darwin-arm64": "zip -j bin/dtsx-darwin-arm64.zip bin/dtsx-darwin-arm64"
66
95
  },
96
+ "peerDependencies": {
97
+ "typescript": ">=5.9.3"
98
+ },
99
+ "peerDependenciesMeta": {
100
+ "typescript": {
101
+ "optional": false
102
+ }
103
+ },
67
104
  "dependencies": {
68
105
  "@stacksjs/clapp": "^0.2.0"
69
106
  },
70
107
  "devDependencies": {
71
108
  "bunfig": "^0.15.6",
72
- "tinyglobby": "^0.2.15"
109
+ "oxc-parser": "^0.112.0",
110
+ "typescript": "^5.9.3"
73
111
  },
74
112
  "git-hooks": {
75
113
  "pre-commit": {
76
114
  "staged-lint": {
77
- "*.{js,ts,json,yaml,yml,md}": "bunx --bun eslint . --fix"
115
+ "*.{js,ts,json,yaml,yml,md}": "bunx --bun pickier run . --mode lint --fix"
78
116
  }
79
117
  }
80
118
  }