@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.
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 +150 -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-1bav913n.js +6 -0
  9. package/dist/chunk-2wbhe1k8.js +2 -0
  10. package/dist/chunk-3d18fhrg.js +3 -0
  11. package/dist/chunk-3g2v2ns2.js +2 -0
  12. package/dist/chunk-3j7r0fxz.js +2 -0
  13. package/dist/chunk-4qpg9xnt.js +3 -0
  14. package/dist/chunk-57agx6g8.js +3 -0
  15. package/dist/chunk-5vqtjws2.js +2 -0
  16. package/dist/chunk-6mwq397e.js +2 -0
  17. package/dist/chunk-6qv7p9sg.js +170 -0
  18. package/dist/chunk-6s7n1gt0.js +2 -0
  19. package/dist/chunk-74j5mydx.js +3 -0
  20. package/dist/chunk-7cpp6v8f.js +2 -0
  21. package/dist/chunk-9a6yn7sv.js +75 -0
  22. package/dist/chunk-axb2kjeq.js +2 -0
  23. package/dist/chunk-begk3j01.js +33 -0
  24. package/dist/chunk-cmenkst5.js +3 -0
  25. package/dist/chunk-d0p3jzwb.js +34 -0
  26. package/dist/chunk-f18nyrrb.js +32 -0
  27. package/dist/chunk-fb4c98h2.js +2 -0
  28. package/dist/chunk-ggmn4a8c.js +4 -0
  29. package/dist/chunk-hrmnrn4p.js +3 -0
  30. package/dist/chunk-j0y71ank.js +2 -0
  31. package/dist/chunk-j6aqdbc4.js +2 -0
  32. package/dist/chunk-jm5ywn4e.js +13 -0
  33. package/dist/chunk-knkfbqze.js +2 -0
  34. package/dist/chunk-n28rjf9h.js +3 -0
  35. package/dist/chunk-p1d09y82.js +449 -0
  36. package/dist/chunk-r1m3q3dj.js +2 -0
  37. package/dist/chunk-r1ywapeb.js +6 -0
  38. package/dist/chunk-rnt0wkrk.js +23 -0
  39. package/dist/chunk-rw6j20e2.js +3 -0
  40. package/dist/chunk-v96rjx7x.js +134 -0
  41. package/dist/chunk-w9abhtgg.js +22 -0
  42. package/dist/chunk-wfevdmvd.js +19 -0
  43. package/dist/chunk-ws2dmfvj.js +2 -0
  44. package/dist/chunk-xnq1xw73.js +15 -0
  45. package/dist/chunk-xyctgc6x.js +102 -0
  46. package/dist/chunk-y3q50bn2.js +2 -0
  47. package/dist/chunk-ywd4k4hn.js +3 -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 +124 -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,49 @@
1
+ import type { DtsGenerationConfig, GenerationStats } from '../types';
2
+ /**
3
+ * Create a Vite plugin for dtsx
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * // vite.config.ts
8
+ * import { dts } from '@stacksjs/dtsx/plugins/vite'
9
+ *
10
+ * export default {
11
+ * plugins: [
12
+ * dts({
13
+ * root: './src',
14
+ * outdir: './dist',
15
+ * }),
16
+ * ],
17
+ * }
18
+ * ```
19
+ */
20
+ export declare function dts(options?: VitePluginOptions): VitePlugin;
21
+ /**
22
+ * Alias for dts
23
+ */
24
+ export declare const viteDts: typeof dts;
25
+ /**
26
+ * Vite plugin options
27
+ */
28
+ export declare interface VitePluginOptions extends Partial<DtsGenerationConfig> {
29
+ buildStart?: boolean
30
+ buildEnd?: boolean
31
+ writeBundle?: boolean
32
+ modes?: string[]
33
+ onGenerated?: (stats: GenerationStats) => void
34
+ onError?: (error: Error) => void
35
+ }
36
+ /**
37
+ * Vite plugin interface (minimal type for compatibility)
38
+ */
39
+ declare interface VitePlugin {
40
+ name: string
41
+ apply?: 'build' | 'serve' | ((_config: { mode: string }) => boolean)
42
+ buildStart?: () => Promise<void> | void
43
+ buildEnd?: () => Promise<void> | void
44
+ writeBundle?: () => Promise<void> | void
45
+ }
46
+ /**
47
+ * Default export
48
+ */
49
+ export default dts;
@@ -0,0 +1,66 @@
1
+ import type { DtsGenerationConfig, GenerationStats } from '../types';
2
+ /**
3
+ * Factory function for creating webpack plugin
4
+ */
5
+ export declare function dtsxWebpack(options?: WebpackPluginOptions): DtsxWebpackPlugin;
6
+ /**
7
+ * Alias matching common naming convention
8
+ */
9
+ export declare const dts: typeof dtsxWebpack;
10
+ /**
11
+ * webpack plugin options
12
+ */
13
+ export declare interface WebpackPluginOptions extends Partial<DtsGenerationConfig> {
14
+ onCompile?: boolean
15
+ afterEmit?: boolean
16
+ onWatchRun?: boolean
17
+ onGenerated?: (stats: GenerationStats) => void
18
+ onError?: (error: Error) => void
19
+ }
20
+ /**
21
+ * webpack compiler interface (minimal type)
22
+ */
23
+ declare interface WebpackCompiler {
24
+ hooks: {
25
+ compile: { tap: (name: string, callback: () => void) => void }
26
+ afterEmit: { tapAsync: (name: string, callback: (compilation: unknown, done: () => void) => void) => void }
27
+ watchRun: { tapAsync: (name: string, callback: (compiler: unknown, done: () => void) => void) => void }
28
+ }
29
+ options: {
30
+ entry?: unknown
31
+ output?: {
32
+ path?: string
33
+ }
34
+ context?: string
35
+ }
36
+ }
37
+ /**
38
+ * webpack plugin for dtsx
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * // webpack.config.js
43
+ * const { DtsxWebpackPlugin } = require('@stacksjs/dtsx/plugins/webpack')
44
+ *
45
+ * module.exports = {
46
+ * entry: './src/index.ts',
47
+ * output: {
48
+ * path: path.resolve(__dirname, 'dist'),
49
+ * },
50
+ * plugins: [
51
+ * new DtsxWebpackPlugin({
52
+ * root: './src',
53
+ * outdir: './dist',
54
+ * }),
55
+ * ],
56
+ * }
57
+ * ```
58
+ */
59
+ export declare class DtsxWebpackPlugin {
60
+ constructor(options?: WebpackPluginOptions);
61
+ apply(compiler: WebpackCompiler): void;
62
+ }
63
+ /**
64
+ * Default export
65
+ */
66
+ export default DtsxWebpackPlugin;
@@ -0,0 +1,83 @@
1
+ import type { Declaration, DtsGenerationConfig, GenerationStats } from './types';
2
+ /**
3
+ * Helper to create a plugin
4
+ */
5
+ export declare function definePlugin(plugin: Plugin): Plugin;
6
+ /**
7
+ * Built-in plugin: Add banner comment
8
+ * Adds a banner comment to the top of generated files
9
+ */
10
+ export declare function createBannerPlugin(banner: string): Plugin;
11
+ /**
12
+ * Built-in plugin: Filter exports
13
+ * Only include declarations matching the filter
14
+ */
15
+ export declare function createFilterPlugin(filter: (name: string) => boolean): Plugin;
16
+ /**
17
+ * Global plugin manager instance
18
+ */
19
+ export declare const pluginManager: PluginManager;
20
+ /**
21
+ * Built-in plugin: Strip internal declarations
22
+ * Removes declarations marked with @internal in JSDoc
23
+ */
24
+ export declare const stripInternalPlugin: Plugin;
25
+ /**
26
+ * Context passed to plugin hooks
27
+ */
28
+ export declare interface PluginContext {
29
+ filePath: string
30
+ sourceCode: string
31
+ config: DtsGenerationConfig
32
+ log: {
33
+ debug: (message: string) => void
34
+ info: (message: string) => void
35
+ warn: (message: string) => void
36
+ error: (message: string) => void
37
+ }
38
+ }
39
+ /**
40
+ * Transform context with mutable content
41
+ */
42
+ export declare interface TransformContext extends PluginContext {
43
+ content: string
44
+ }
45
+ /**
46
+ * Declaration context for declaration hooks
47
+ */
48
+ export declare interface DeclarationContext extends PluginContext {
49
+ declarations: Declaration[]
50
+ }
51
+ /**
52
+ * Plugin hook definitions
53
+ */
54
+ export declare interface PluginHooks {
55
+ onStart?: (config: DtsGenerationConfig) => DtsGenerationConfig | void | Promise<DtsGenerationConfig | void>
56
+ onBeforeFile?: (ctx: TransformContext) => string | void | Promise<string | void>
57
+ onDeclarations?: (ctx: DeclarationContext) => Declaration[] | void | Promise<Declaration[] | void>
58
+ onAfterFile?: (ctx: TransformContext) => string | void | Promise<string | void>
59
+ onEnd?: (stats: GenerationStats) => void | Promise<void>
60
+ onError?: (error: Error, ctx: PluginContext) => void | Promise<void>
61
+ }
62
+ /**
63
+ * Plugin definition
64
+ */
65
+ export declare interface Plugin extends PluginHooks {
66
+ name: string
67
+ version?: string
68
+ description?: string
69
+ }
70
+ /**
71
+ * Plugin manager for handling multiple plugins
72
+ */
73
+ export declare class PluginManager {
74
+ register(plugin: Plugin): void;
75
+ unregister(name: string): boolean;
76
+ getPlugins(): readonly Plugin[];
77
+ runOnStart(config: DtsGenerationConfig): Promise<DtsGenerationConfig>;
78
+ runOnBeforeFile(filePath: string, sourceCode: string): Promise<string>;
79
+ runOnDeclarations(filePath: string, sourceCode: string, declarations: Declaration[]): Promise<Declaration[]>;
80
+ runOnAfterFile(filePath: string, sourceCode: string, dtsContent: string): Promise<string>;
81
+ runOnEnd(stats: GenerationStats): Promise<void>;
82
+ runOnError(error: Error, filePath: string, sourceCode: string): Promise<void>;
83
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Process TypeScript source code from a string (for stdin support)
3
+ * This is a lightweight module that avoids pulling in heavy dependencies
4
+ * like bun Glob, fs/promises, bundler, cache, config, etc.
5
+ */
6
+ export declare function processSource(sourceCode: string, filename?: string, keepComments?: boolean, importOrder?: string[], isolatedDeclarations?: boolean): string;
7
+ /**
8
+ * Fast path for project mode — skips cache lookup/store.
9
+ * Use when processing many files once (no cache benefit).
10
+ */
11
+ export declare function processSourceDirect(sourceCode: string, filename?: string, keepComments?: boolean, importOrder?: string[], isolatedDeclarations?: boolean): string;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Get or create a cached RegExp for word boundary matching
3
+ */
4
+ export declare function getCachedRegex(pattern: string): RegExp;
5
+ /**
6
+ * Get cached import items or null if not cached
7
+ */
8
+ export declare function getImportItemsFromCache(importText: string): string[] | null;
9
+ /**
10
+ * Store import items in cache with eviction
11
+ */
12
+ export declare function setImportItemsCache(importText: string, items: string[]): void;
13
+ /**
14
+ * Clear processor caches (useful for testing or memory management)
15
+ */
16
+ export declare function clearProcessorCaches(): void;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Comment formatting utilities for DTS output
3
+ */
4
+ /**
5
+ * Format comments for DTS output
6
+ */
7
+ export declare function formatComments(comments: string[] | undefined, keepComments?: boolean): string;
@@ -0,0 +1,37 @@
1
+ import type { Declaration } from '../types';
2
+ /**
3
+ * Process function declaration to DTS format
4
+ */
5
+ export declare function processFunctionDeclaration(decl: Declaration, keepComments?: boolean): string;
6
+ /**
7
+ * Process variable declaration to DTS format
8
+ */
9
+ export declare function processVariableDeclaration(decl: Declaration, keepComments?: boolean): string;
10
+ /**
11
+ * Process interface declaration to DTS format
12
+ */
13
+ export declare function processInterfaceDeclaration(decl: Declaration, keepComments?: boolean): string;
14
+ /**
15
+ * Process type alias declaration to DTS format
16
+ */
17
+ export declare function processTypeDeclaration(decl: Declaration, keepComments?: boolean): string;
18
+ /**
19
+ * Process class declaration to DTS format
20
+ */
21
+ export declare function processClassDeclaration(decl: Declaration, keepComments?: boolean): string;
22
+ /**
23
+ * Process enum declaration to DTS format
24
+ */
25
+ export declare function processEnumDeclaration(decl: Declaration, keepComments?: boolean): string;
26
+ /**
27
+ * Process import statement
28
+ */
29
+ export declare function processImportDeclaration(decl: Declaration): string;
30
+ /**
31
+ * Process export statement
32
+ */
33
+ export declare function processExportDeclaration(decl: Declaration, keepComments?: boolean): string;
34
+ /**
35
+ * Process module/namespace declaration to DTS format
36
+ */
37
+ export declare function processModuleDeclaration(decl: Declaration, keepComments?: boolean): string;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Parse an import statement into its components using string operations
3
+ * Avoids regex backtracking issues
4
+ */
5
+ export declare function parseImportStatement(importText: string): {
6
+ defaultName: string | null
7
+ namedItems: string[]
8
+ source: string
9
+ isTypeOnly: boolean
10
+ } | null;
11
+ /**
12
+ * Extract all imported items from an import statement (with caching)
13
+ * Uses simple string operations to avoid regex backtracking
14
+ */
15
+ export declare function extractAllImportedItems(importText: string): string[];
16
+ /**
17
+ * Parse an import statement with detailed type-only information for each item
18
+ * Handles: import type { X }, import { type X, Y }, import * as X, etc.
19
+ */
20
+ export declare function parseImportDetailed(importText: string): ParsedImport | null;
21
+ /**
22
+ * Parse an export statement with detailed type-only information
23
+ * Handles: export type { X }, export { type X, Y }, export * from, etc.
24
+ */
25
+ export declare function parseExportDetailed(exportText: string): {
26
+ namedItems: ImportItem[]
27
+ source: string | null
28
+ isTypeOnly: boolean
29
+ isNamespace: boolean
30
+ isDefault: boolean
31
+ } | null;
32
+ /**
33
+ * Check if an import item is type-only
34
+ */
35
+ export declare function isTypeOnlyImportItem(itemText: string): boolean;
36
+ /**
37
+ * Convert import items to type-only format
38
+ * E.g., "{ X, Y }" becomes "{ type X, type Y }"
39
+ */
40
+ export declare function convertToTypeOnlyImport(importText: string): string;
41
+ /**
42
+ * Merge value and type imports from the same module
43
+ * Combines separate import statements into one where possible
44
+ */
45
+ export declare function mergeImports(imports: string[]): string[];
46
+ /**
47
+ * Represents a single imported item with its type-only status
48
+ */
49
+ export declare interface ImportItem {
50
+ name: string
51
+ originalName: string
52
+ isTypeOnly: boolean
53
+ isDefault: boolean
54
+ }
55
+ /**
56
+ * Detailed import statement parse result
57
+ */
58
+ export declare interface ParsedImport {
59
+ defaultName: string | null
60
+ namedItems: ImportItem[]
61
+ source: string
62
+ isTypeOnly: boolean
63
+ isNamespace: boolean
64
+ namespaceName: string | null
65
+ }
@@ -0,0 +1,34 @@
1
+ import { extractAllImportedItems, parseImportStatement } from './imports';
2
+ import { formatComments } from './comments';
3
+ import { processClassDeclaration, processEnumDeclaration, processFunctionDeclaration, processInterfaceDeclaration, processModuleDeclaration, processTypeDeclaration, processVariableDeclaration } from './declarations';
4
+ import type { Declaration, ProcessingContext } from '../types';
5
+ /**
6
+ * Process declarations and convert them to narrow DTS format
7
+ */
8
+ export declare function processDeclarations(declarations: Declaration[], context: ProcessingContext, keepComments?: boolean, importOrder?: string[]): string;
9
+ // Re-export all public APIs
10
+ export { clearProcessorCaches } from './cache';
11
+ export { formatComments } from './comments';
12
+ export {
13
+ processClassDeclaration,
14
+ processEnumDeclaration,
15
+ processExportDeclaration,
16
+ processFunctionDeclaration,
17
+ processImportDeclaration,
18
+ processInterfaceDeclaration,
19
+ processModuleDeclaration,
20
+ processTypeDeclaration,
21
+ processVariableDeclaration,
22
+ } from './declarations';
23
+ export { extractAllImportedItems, parseImportStatement } from './imports';
24
+ export {
25
+ extractSatisfiesType,
26
+ findMatchingBracket,
27
+ inferArrayType,
28
+ inferFunctionType,
29
+ inferNarrowType,
30
+ inferNarrowTypeInUnion,
31
+ inferObjectType,
32
+ isGenericType,
33
+ parseArrayElements,
34
+ } from './type-inference';
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Enable clean default collection for the next type inference pass.
3
+ * Must be called before inferNarrowType when you need a @defaultValue.
4
+ */
5
+ export declare function enableCleanDefaultCollection(): void;
6
+ /**
7
+ * Consume the computed clean default (also disables collection).
8
+ * Returns null if no clean default was computed.
9
+ */
10
+ export declare function consumeCleanDefault(): string | null;
11
+ /**
12
+ * Infer and narrow types from values
13
+ * @param inUnion - When true, widens number/boolean literals to their base types (used in array union contexts)
14
+ * @param _depth - Internal recursion depth counter (do not set manually)
15
+ */
16
+ export declare function inferNarrowType(value: unknown, isConst?: boolean, inUnion?: boolean, _depth?: number): string;
17
+ /**
18
+ * Infer and narrow types from values in union context (for arrays)
19
+ * Widens number/boolean literals to base types unless const
20
+ */
21
+ export declare function inferNarrowTypeInUnion(value: unknown, isConst?: boolean, _depth?: number): string;
22
+ /**
23
+ * Infer array type from array literal
24
+ */
25
+ export declare function inferArrayType(value: string, isConst: boolean, _depth?: number): string;
26
+ /**
27
+ * Parse array elements handling nested structures
28
+ */
29
+ export declare function parseArrayElements(content: string): string[];
30
+ /**
31
+ * Infer object type from object literal
32
+ */
33
+ export declare function inferObjectType(value: string, isConst: boolean, _depth?: number): string;
34
+ /**
35
+ * Clean parameter defaults from function parameters
36
+ */
37
+ export declare function cleanParameterDefaults(params: string): string;
38
+ /**
39
+ * Find matching bracket for nested structures
40
+ */
41
+ export declare function findMatchingBracket(str: string, start: number, openChar: string, closeChar: string): number;
42
+ /**
43
+ * Infer function type from function expression
44
+ */
45
+ export declare function inferFunctionType(value: string, inUnion?: boolean, _depth?: number, isConst?: boolean): string;
46
+ /**
47
+ * Check if a type annotation is a generic/broad type that should be replaced with narrow inference
48
+ */
49
+ export declare function isGenericType(typeAnnotation: string): boolean;
50
+ /**
51
+ * Extract type from 'satisfies' operator
52
+ * e.g., "{ port: 3000 } satisfies { port: number }" returns "{ port: number }"
53
+ */
54
+ export declare function extractSatisfiesType(value: string): string | null;
55
+ /**
56
+ * Infer mapped type from type expression
57
+ * Handles patterns like { [K in keyof T]: V }
58
+ */
59
+ export declare function inferMappedType(typeStr: string): string | null;
60
+ /**
61
+ * Infer conditional type from type expression
62
+ * Handles patterns like T extends U ? X : Y
63
+ */
64
+ export declare function inferConditionalType(typeStr: string): string | null;
65
+ /**
66
+ * Infer template literal type from type expression
67
+ * Handles patterns like `${string}-${number}`
68
+ */
69
+ export declare function inferTemplateLiteralTypeAdvanced(typeStr: string): string | null;
70
+ /**
71
+ * Infer infer keyword usage in conditional types
72
+ * Handles patterns like T extends (infer U)[] ? U : never
73
+ */
74
+ export declare function extractInferTypes(typeStr: string): string[];
75
+ /**
76
+ * Check if a type uses advanced TypeScript features
77
+ */
78
+ export declare function isComplexType(_typeStr: string): boolean;
79
+ /**
80
+ * Simplify complex type for declaration output
81
+ * Returns simplified version if too complex
82
+ */
83
+ export declare function simplifyComplexType(typeStr: string, maxDepth?: number): string;
84
+ /**
85
+ * Parse utility type and extract its parameters
86
+ * Handles Partial<T>, Required<T>, Pick<T, K>, Omit<T, K>, etc.
87
+ */
88
+ export declare function parseUtilityType(typeStr: string): { name: string, params: string[] } | null;
89
+ /**
90
+ * Parse type parameters from a comma-separated string
91
+ * Handles nested types properly
92
+ */
93
+ export declare function parseTypeParameters(paramsStr: string): string[];
94
+ /**
95
+ * Infer keyof type
96
+ */
97
+ export declare function inferKeyofType(typeStr: string): string | null;
98
+ /**
99
+ * Infer typeof type
100
+ */
101
+ export declare function inferTypeofType(typeStr: string): string | null;
102
+ /**
103
+ * Check if type is an indexed access type
104
+ * e.g., T[K], Person['name']
105
+ */
106
+ export declare function isIndexedAccessType(typeStr: string): boolean;
@@ -1,45 +1,5 @@
1
- import type { Declaration, ProcessingContext } from './types';
2
1
  /**
3
- * Process declarations and convert them to narrow DTS format
2
+ * Processor module - re-exports from modular structure
3
+ * @deprecated Import from './processor/index' directly for better tree-shaking
4
4
  */
5
- export declare function processDeclarations(declarations: Declaration[], context: ProcessingContext, keepComments?: boolean): string;
6
- /**
7
- * Process function declaration to DTS format
8
- */
9
- export declare function processFunctionDeclaration(decl: Declaration, keepComments?: boolean): string;
10
- /**
11
- * Process variable declaration to DTS format
12
- */
13
- export declare function processVariableDeclaration(decl: Declaration, keepComments?: boolean): string;
14
- /**
15
- * Process interface declaration to DTS format
16
- */
17
- export declare function processInterfaceDeclaration(decl: Declaration, keepComments?: boolean): string;
18
- /**
19
- * Process type alias declaration to DTS format
20
- */
21
- export declare function processTypeDeclaration(decl: Declaration, keepComments?: boolean): string;
22
- /**
23
- * Process class declaration to DTS format
24
- */
25
- export declare function processClassDeclaration(decl: Declaration, keepComments?: boolean): string;
26
- /**
27
- * Process enum declaration to DTS format
28
- */
29
- export declare function processEnumDeclaration(decl: Declaration, keepComments?: boolean): string;
30
- /**
31
- * Process import statement
32
- */
33
- export declare function processImportDeclaration(decl: Declaration): string;
34
- /**
35
- * Process export statement
36
- */
37
- export declare function processExportDeclaration(decl: Declaration): string;
38
- /**
39
- * Process module/namespace declaration to DTS format
40
- */
41
- export declare function processModuleDeclaration(decl: Declaration, keepComments?: boolean): string;
42
- /**
43
- * Infer and narrow types from values
44
- */
45
- export declare function inferNarrowType(value: any, isConst?: boolean): string;
5
+ export * from './processor/index';
@@ -0,0 +1,101 @@
1
+ import type { ProfilingConfig } from './types';
2
+ /**
3
+ * Create a new profiler instance
4
+ */
5
+ export declare function createProfiler(config?: ProfilingConfig): Profiler;
6
+ /**
7
+ * Profile a function execution
8
+ */
9
+ export declare function profileExecution<T>(fn: () => T | Promise<T>, config?: ProfilingConfig): Promise<{ result: T, profile: ProfilingResults }>;
10
+ /**
11
+ * Create a profiled I/O wrapper
12
+ */
13
+ export declare function createProfiledIo(profiler: Profiler): {
14
+ read: <T>(path: string, fn: () => Promise<T>) => Promise<T>
15
+ write: (path: string, fn: () => Promise<void>, size: number) => Promise<void>
16
+ };
17
+ /**
18
+ * Create a simple timer
19
+ */
20
+ export declare function createTimer(): Timer;
21
+ /**
22
+ * Memory profiling data snapshot
23
+ */
24
+ export declare interface MemoryProfileSnapshot {
25
+ timestamp: number
26
+ heapUsed: number
27
+ heapTotal: number
28
+ external: number
29
+ arrayBuffers: number
30
+ rss: number
31
+ }
32
+ /**
33
+ * CPU profiling data
34
+ */
35
+ export declare interface CpuProfile {
36
+ timestamp: number
37
+ user: number
38
+ system: number
39
+ total: number
40
+ }
41
+ /**
42
+ * I/O operation record
43
+ */
44
+ export declare interface IoOperation {
45
+ timestamp: number
46
+ operation: 'read' | 'write'
47
+ path: string
48
+ size: number
49
+ durationMs: number
50
+ }
51
+ /**
52
+ * Profiling results
53
+ */
54
+ export declare interface ProfilingResults {
55
+ startTime: number
56
+ endTime: number
57
+ durationMs: number
58
+ memory: {
59
+ samples: MemoryProfileSnapshot[]
60
+ peak: MemoryProfileSnapshot
61
+ average: MemoryProfileSnapshot
62
+ warnings: string[]
63
+ }
64
+ cpu: {
65
+ samples: CpuProfile[]
66
+ totalUser: number
67
+ totalSystem: number
68
+ }
69
+ io: {
70
+ operations: IoOperation[]
71
+ totalReads: number
72
+ totalWrites: number
73
+ totalReadBytes: number
74
+ totalWriteBytes: number
75
+ totalReadMs: number
76
+ totalWriteMs: number
77
+ }
78
+ }
79
+ /**
80
+ * Profiler class for collecting performance data
81
+ */
82
+ export declare class Profiler {
83
+ constructor(config?: ProfilingConfig);
84
+ start(): void;
85
+ stop(): void;
86
+ recordIo(operation: 'read' | 'write', path: string, size: number, durationMs: number): void;
87
+ getResults(): ProfilingResults;
88
+ formatResults(): string;
89
+ writeResults(): Promise<void>;
90
+ }
91
+ /**
92
+ * Simple timer for manual profiling
93
+ */
94
+ export declare class Timer {
95
+ mark(name: string): void;
96
+ measure(name: string, fromMark: string): number;
97
+ getDurations(name: string): number[];
98
+ getAverage(name: string): number;
99
+ getSummary(): Map<string, { count: number, total: number, average: number, min: number, max: number }>;
100
+ clear(): void;
101
+ }