@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.
- package/LICENSE.md +21 -0
- package/README.md +243 -15
- package/dist/bin/cli.js +10 -22
- package/dist/branded-types.d.ts +168 -0
- package/dist/bundler.d.ts +55 -0
- package/dist/cache.d.ts +43 -0
- package/dist/checker.d.ts +107 -0
- package/dist/chunk-09zp67d8.js +6 -0
- package/dist/chunk-0kmfaaz6.js +2 -0
- package/dist/chunk-1mm3t0nr.js +3 -0
- package/dist/chunk-2f046tgr.js +2 -0
- package/dist/chunk-3g2v2ns2.js +2 -0
- package/dist/chunk-3j7r0fxz.js +2 -0
- package/dist/chunk-3mxzfgcv.js +75 -0
- package/dist/chunk-4ev1n7r7.js +3 -0
- package/dist/chunk-57agx6g8.js +3 -0
- package/dist/chunk-6ppqaypd.js +2 -0
- package/dist/chunk-6qv7p9sg.js +170 -0
- package/dist/chunk-6s7n1gt0.js +2 -0
- package/dist/chunk-74j5mydx.js +3 -0
- package/dist/chunk-7cpp6v8f.js +2 -0
- package/dist/chunk-9a3jfxnc.js +3 -0
- package/dist/chunk-9mjc7ddv.js +19 -0
- package/dist/chunk-axb2kjeq.js +2 -0
- package/dist/chunk-bn29kee5.js +102 -0
- package/dist/chunk-c18vx9sq.js +2 -0
- package/dist/chunk-d0p3jzwb.js +34 -0
- package/dist/chunk-dk2vv0np.js +15 -0
- package/dist/chunk-e3j9tecw.js +3 -0
- package/dist/chunk-f18nyrrb.js +32 -0
- package/dist/chunk-fbqcsr60.js +22 -0
- package/dist/chunk-ffqpf34b.js +3 -0
- package/dist/chunk-fw6wcdfd.js +4 -0
- package/dist/chunk-h12gdfk9.js +2 -0
- package/dist/chunk-j22v8wfe.js +33 -0
- package/dist/chunk-jm5ywn4e.js +13 -0
- package/dist/chunk-jvz9t6pq.js +2 -0
- package/dist/chunk-k5h5ppp5.js +2 -0
- package/dist/chunk-p1d09y82.js +449 -0
- package/dist/chunk-pyxbb193.js +2 -0
- package/dist/chunk-q75q4w1s.js +3 -0
- package/dist/chunk-r1m3q3dj.js +2 -0
- package/dist/chunk-r1ywapeb.js +6 -0
- package/dist/chunk-rnt0wkrk.js +23 -0
- package/dist/chunk-rrkq4k1n.js +2 -0
- package/dist/chunk-rw6j20e2.js +3 -0
- package/dist/chunk-v96rjx7x.js +134 -0
- package/dist/circular.d.ts +82 -0
- package/dist/compat.d.ts +108 -0
- package/dist/config.d.ts +33 -3
- package/dist/diff.d.ts +82 -0
- package/dist/docs.d.ts +97 -0
- package/dist/errors.d.ts +113 -0
- package/dist/extractor/builders.d.ts +38 -0
- package/dist/extractor/cache.d.ts +47 -0
- package/dist/extractor/declarations.d.ts +50 -0
- package/dist/extractor/directives.d.ts +9 -0
- package/dist/extractor/extract.d.ts +10 -0
- package/dist/extractor/hash.d.ts +1 -0
- package/dist/extractor/helpers.d.ts +39 -0
- package/dist/extractor/index.d.ts +70 -0
- package/dist/extractor/scanner.d.ts +6 -0
- package/dist/extractor.d.ts +3 -4
- package/dist/formats.d.ts +50 -0
- package/dist/formatter.d.ts +61 -0
- package/dist/generator.d.ts +12 -3
- package/dist/import-sorter.d.ts +99 -0
- package/dist/incremental.d.ts +84 -0
- package/dist/index.d.ts +54 -1
- package/dist/logger.d.ts +57 -0
- package/dist/lsp.d.ts +317 -0
- package/dist/memory.d.ts +110 -0
- package/dist/merger.d.ts +38 -0
- package/dist/optimizer.d.ts +52 -0
- package/dist/output-normalizer.d.ts +123 -0
- package/dist/parallel-processor.d.ts +63 -0
- package/dist/parser.d.ts +24 -15
- package/dist/plugins/bun.d.ts +58 -0
- package/dist/plugins/esbuild.d.ts +63 -0
- package/dist/plugins/index.d.ts +14 -0
- package/dist/plugins/tsup.d.ts +53 -0
- package/dist/plugins/vite.d.ts +49 -0
- package/dist/plugins/webpack.d.ts +66 -0
- package/dist/plugins.d.ts +83 -0
- package/dist/process-source.d.ts +11 -0
- package/dist/processor/cache.d.ts +16 -0
- package/dist/processor/comments.d.ts +7 -0
- package/dist/processor/declarations.d.ts +37 -0
- package/dist/processor/imports.d.ts +65 -0
- package/dist/processor/index.d.ts +34 -0
- package/dist/processor/type-inference.d.ts +106 -0
- package/dist/processor.d.ts +3 -43
- package/dist/profiling.d.ts +101 -0
- package/dist/security.d.ts +100 -0
- package/dist/sourcemap.d.ts +125 -0
- package/dist/src/index.js +55 -2
- package/dist/src/plugins/bun.js +2 -0
- package/dist/src/plugins/esbuild.js +2 -0
- package/dist/src/plugins/index.js +2 -0
- package/dist/src/plugins/tsup.js +2 -0
- package/dist/src/plugins/vite.js +2 -0
- package/dist/src/plugins/webpack.js +2 -0
- package/dist/tracking.d.ts +89 -0
- package/dist/transformers.d.ts +173 -0
- package/dist/tree-shaker.d.ts +69 -0
- package/dist/type-mappings.d.ts +148 -0
- package/dist/types.d.ts +137 -7
- package/dist/utils.d.ts +53 -1
- package/dist/watcher.d.ts +64 -0
- package/dist/worker.d.ts +84 -0
- package/dist/workspace.d.ts +62 -0
- package/package.json +49 -11
- package/dist/chunk-qsyn1k3w.js +0 -504
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { extractClassDeclaration, extractEnumDeclaration, extractExportAssignment, extractExportDeclaration, extractFunctionDeclaration, extractImportDeclaration, extractInterfaceDeclaration, extractModuleDeclaration, extractTypeAliasDeclaration, extractVariableStatement, findReferencedTypes } from './declarations';
|
|
2
|
+
import { getSourceFileAsync } from './cache';
|
|
3
|
+
import { shouldIncludeNonExportedFunction, shouldIncludeNonExportedInterface } from './helpers';
|
|
4
|
+
import type { AsyncParseConfig } from './cache';
|
|
5
|
+
import type { Declaration } from '../types';
|
|
6
|
+
export type { AsyncParseConfig } from './cache';
|
|
7
|
+
/**
|
|
8
|
+
* Clear all extractor caches (source files and declarations)
|
|
9
|
+
*/
|
|
10
|
+
export declare function clearSourceFileCache(): void;
|
|
11
|
+
/**
|
|
12
|
+
* Extract only public API declarations from TypeScript source code
|
|
13
|
+
* Uses fast string-based scanner (no TypeScript parser) for maximum performance.
|
|
14
|
+
* Delegates to extract.ts which owns the shared declaration cache with proper LRU eviction.
|
|
15
|
+
*/
|
|
16
|
+
export declare function extractDeclarations(sourceCode: string, filePath: string, keepComments?: boolean, isolatedDeclarations?: boolean): Declaration[];
|
|
17
|
+
/**
|
|
18
|
+
* Async version of extractDeclarations that yields to the event loop for large files
|
|
19
|
+
* Use this when processing many files in parallel to prevent blocking
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractDeclarationsAsync(sourceCode: string, filePath: string, keepComments?: boolean, config?: AsyncParseConfig): Promise<Declaration[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Batch extract declarations from multiple files asynchronously
|
|
24
|
+
* Useful for processing many files while keeping the event loop responsive
|
|
25
|
+
*/
|
|
26
|
+
export declare function batchExtractDeclarations(files: Array<{ filePath: string, sourceCode: string, keepComments?: boolean }>, config?: AsyncParseConfig & { concurrency?: number }): Promise<Map<string, Declaration[]>>;
|
|
27
|
+
export {
|
|
28
|
+
buildClassBody,
|
|
29
|
+
buildClassDeclaration,
|
|
30
|
+
buildFunctionSignature,
|
|
31
|
+
buildInterfaceDeclaration,
|
|
32
|
+
buildModuleBody,
|
|
33
|
+
buildModuleDeclaration,
|
|
34
|
+
buildTypeDeclaration,
|
|
35
|
+
buildVariableDeclaration,
|
|
36
|
+
getInterfaceBody,
|
|
37
|
+
} from './builders';
|
|
38
|
+
export {
|
|
39
|
+
batchParseSourceFiles,
|
|
40
|
+
getPendingParseCount,
|
|
41
|
+
getSourceFileAsync,
|
|
42
|
+
getSourceFileCacheSize,
|
|
43
|
+
shouldUseAsyncParsing,
|
|
44
|
+
} from './cache';
|
|
45
|
+
export {
|
|
46
|
+
extractClassDeclaration,
|
|
47
|
+
extractEnumDeclaration,
|
|
48
|
+
extractExportAssignment,
|
|
49
|
+
extractExportDeclaration,
|
|
50
|
+
extractFunctionDeclaration,
|
|
51
|
+
extractImportDeclaration,
|
|
52
|
+
extractInterfaceDeclaration,
|
|
53
|
+
extractModuleDeclaration,
|
|
54
|
+
extractReferencedTypeDeclarations,
|
|
55
|
+
extractTypeAliasDeclaration,
|
|
56
|
+
extractVariableStatement,
|
|
57
|
+
findReferencedTypes,
|
|
58
|
+
} from './declarations';
|
|
59
|
+
export {
|
|
60
|
+
extractJSDocComments,
|
|
61
|
+
extractTripleSlashDirectives,
|
|
62
|
+
extractTypesFromModuleText,
|
|
63
|
+
getNodeText,
|
|
64
|
+
getParameterName,
|
|
65
|
+
hasAsyncModifier,
|
|
66
|
+
hasExportModifier,
|
|
67
|
+
isBuiltInType,
|
|
68
|
+
shouldIncludeNonExportedFunction,
|
|
69
|
+
shouldIncludeNonExportedInterface,
|
|
70
|
+
} from './helpers';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Declaration } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Scan TypeScript source code and extract declarations without using the TypeScript parser.
|
|
4
|
+
* This is the fast path that replaces createSourceFile() + AST walk.
|
|
5
|
+
*/
|
|
6
|
+
export declare function scanDeclarations(_source: string, _filename: string, _keepComments?: boolean, _isolatedDeclarations?: boolean): Declaration[];
|
package/dist/extractor.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Declaration } from './types';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Extractor module - re-exports from modular structure
|
|
3
|
+
* @deprecated Import from './extractor/index' directly for better tree-shaking
|
|
5
4
|
*/
|
|
6
|
-
export
|
|
5
|
+
export * from './extractor/index';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Declaration } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Convert declarations to JSON Schema
|
|
4
|
+
*/
|
|
5
|
+
export declare function toJsonSchema(declarations: Declaration[], options?: Partial<FormatOptions>): string;
|
|
6
|
+
/**
|
|
7
|
+
* Convert declarations to Zod schema
|
|
8
|
+
*/
|
|
9
|
+
export declare function toZod(declarations: Declaration[], options?: Partial<FormatOptions>): string;
|
|
10
|
+
/**
|
|
11
|
+
* Convert declarations to Valibot schema
|
|
12
|
+
*/
|
|
13
|
+
export declare function toValibot(declarations: Declaration[], options?: Partial<FormatOptions>): string;
|
|
14
|
+
/**
|
|
15
|
+
* Convert declarations to io-ts codec
|
|
16
|
+
*/
|
|
17
|
+
export declare function toIoTs(declarations: Declaration[], options?: Partial<FormatOptions>): string;
|
|
18
|
+
/**
|
|
19
|
+
* Convert declarations to Yup schema
|
|
20
|
+
*/
|
|
21
|
+
export declare function toYup(declarations: Declaration[], options?: Partial<FormatOptions>): string;
|
|
22
|
+
/**
|
|
23
|
+
* Convert declarations to ArkType schema
|
|
24
|
+
*/
|
|
25
|
+
export declare function toArkType(declarations: Declaration[], options?: Partial<FormatOptions>): string;
|
|
26
|
+
/**
|
|
27
|
+
* Convert declarations to the specified format
|
|
28
|
+
*/
|
|
29
|
+
export declare function convertToFormat(declarations: Declaration[], options: FormatOptions): string;
|
|
30
|
+
/**
|
|
31
|
+
* Get file extension for output format
|
|
32
|
+
*/
|
|
33
|
+
export declare function getFormatExtension(format: OutputFormat): string;
|
|
34
|
+
/**
|
|
35
|
+
* Options for format conversion
|
|
36
|
+
*/
|
|
37
|
+
export declare interface FormatOptions {
|
|
38
|
+
format: OutputFormat
|
|
39
|
+
includeSchema?: boolean
|
|
40
|
+
jsonSchemaDraft?: '2020-12' | '2019-09' | 'draft-07'
|
|
41
|
+
allOptional?: boolean
|
|
42
|
+
includeDescriptions?: boolean
|
|
43
|
+
indent?: number
|
|
44
|
+
exportName?: string
|
|
45
|
+
useInfer?: boolean
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Supported output formats
|
|
49
|
+
*/
|
|
50
|
+
export type OutputFormat = 'dts' | 'json-schema' | 'zod' | 'io-ts' | 'yup' | 'valibot' | 'arktype';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format declaration file content
|
|
3
|
+
*/
|
|
4
|
+
export declare function formatDts(content: string, config?: FormatterConfig, filePath?: string): Promise<FormatResult>;
|
|
5
|
+
/**
|
|
6
|
+
* Format multiple files
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatFiles(files: Map<string, string>, config?: FormatterConfig): Promise<Map<string, FormatResult>>;
|
|
9
|
+
/**
|
|
10
|
+
* Create a formatter with preset configuration
|
|
11
|
+
*/
|
|
12
|
+
export declare function createFormatter(config?: FormatterConfig): {
|
|
13
|
+
format: (content: string, filePath?: string) => Promise<FormatResult>
|
|
14
|
+
formatMany: (files: Map<string, string>) => Promise<Map<string, FormatResult>>
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Quick format with sensible defaults
|
|
18
|
+
*/
|
|
19
|
+
export declare function quickFormat(content: string): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Formatter configuration options
|
|
22
|
+
*/
|
|
23
|
+
export declare interface FormatterConfig {
|
|
24
|
+
usePrettier?: boolean
|
|
25
|
+
prettierConfigPath?: string
|
|
26
|
+
prettierOptions?: PrettierOptions
|
|
27
|
+
builtIn?: BuiltInFormatterOptions
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Prettier-compatible options
|
|
31
|
+
*/
|
|
32
|
+
export declare interface PrettierOptions {
|
|
33
|
+
printWidth?: number
|
|
34
|
+
tabWidth?: number
|
|
35
|
+
useTabs?: boolean
|
|
36
|
+
semi?: boolean
|
|
37
|
+
singleQuote?: boolean
|
|
38
|
+
trailingComma?: 'none' | 'es5' | 'all'
|
|
39
|
+
bracketSpacing?: boolean
|
|
40
|
+
parser?: string
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Built-in formatter options (when Prettier is not available)
|
|
44
|
+
*/
|
|
45
|
+
export declare interface BuiltInFormatterOptions {
|
|
46
|
+
indentSize?: number
|
|
47
|
+
useTabs?: boolean
|
|
48
|
+
maxLineWidth?: number
|
|
49
|
+
trailingNewline?: boolean
|
|
50
|
+
normalizeWhitespace?: boolean
|
|
51
|
+
sortImports?: boolean
|
|
52
|
+
groupImports?: boolean
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Result of formatting operation
|
|
56
|
+
*/
|
|
57
|
+
export declare interface FormatResult {
|
|
58
|
+
content: string
|
|
59
|
+
usedPrettier: boolean
|
|
60
|
+
warnings?: string[]
|
|
61
|
+
}
|
package/dist/generator.d.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import type { DtsGenerationConfig } from './types';
|
|
1
|
+
import type { DtsGenerationConfig, GenerationStats } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Generate DTS files from TypeScript source files
|
|
4
4
|
*/
|
|
5
|
-
export declare function generate(options?: Partial<DtsGenerationConfig>): Promise<
|
|
5
|
+
export declare function generate(options?: Partial<DtsGenerationConfig>): Promise<GenerationStats>;
|
|
6
6
|
/**
|
|
7
7
|
* Process a single TypeScript file and generate its DTS
|
|
8
8
|
*/
|
|
9
|
-
export declare function processFile(filePath: string, config: DtsGenerationConfig): Promise<string>;
|
|
9
|
+
export declare function processFile(filePath: string, config: DtsGenerationConfig): Promise<string>;
|
|
10
|
+
/**
|
|
11
|
+
* Watch mode - regenerate DTS files on source changes
|
|
12
|
+
*/
|
|
13
|
+
export declare function watch(options?: Partial<DtsGenerationConfig>): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Process TypeScript source code from a string (for stdin support)
|
|
16
|
+
* Re-exported from process-source.ts for backward compatibility
|
|
17
|
+
*/
|
|
18
|
+
export { processSource } from './process-source';
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse an import statement
|
|
3
|
+
*/
|
|
4
|
+
export declare function parseImport(statement: string): ParsedImport | null;
|
|
5
|
+
/**
|
|
6
|
+
* Detect the group for an import source
|
|
7
|
+
*/
|
|
8
|
+
export declare function detectGroup(source: string, isTypeOnly?: boolean): ImportGroup;
|
|
9
|
+
/**
|
|
10
|
+
* Sort imports according to configuration
|
|
11
|
+
*/
|
|
12
|
+
export declare function sortImports(imports: string[], config?: ImportSortConfig): string[];
|
|
13
|
+
/**
|
|
14
|
+
* Sort imports in a file content
|
|
15
|
+
*/
|
|
16
|
+
export declare function sortImportsInContent(content: string, config?: ImportSortConfig): string;
|
|
17
|
+
/**
|
|
18
|
+
* Create a configured import sorter
|
|
19
|
+
*/
|
|
20
|
+
export declare function createImportSorter(config?: ImportSortConfig): {
|
|
21
|
+
sort: (imports: string[]) => string[]
|
|
22
|
+
sortContent: (content: string) => string
|
|
23
|
+
parse: typeof parseImport
|
|
24
|
+
detectGroup: typeof detectGroup
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Default import group order
|
|
28
|
+
*/
|
|
29
|
+
export declare const DEFAULT_GROUP_ORDER: ImportGroup[];
|
|
30
|
+
/**
|
|
31
|
+
* Preset configurations
|
|
32
|
+
*/
|
|
33
|
+
export declare const presets: {
|
|
34
|
+
/**
|
|
35
|
+
* Default preset - groups by type, alphabetizes
|
|
36
|
+
*/
|
|
37
|
+
default: unknown;
|
|
38
|
+
/**
|
|
39
|
+
* Node.js style - node: first, then external, then relative
|
|
40
|
+
*/
|
|
41
|
+
node: unknown;
|
|
42
|
+
/**
|
|
43
|
+
* Bun style - bun first
|
|
44
|
+
*/
|
|
45
|
+
bun: unknown;
|
|
46
|
+
/**
|
|
47
|
+
* Type imports separated
|
|
48
|
+
*/
|
|
49
|
+
typeSeparated: unknown;
|
|
50
|
+
/**
|
|
51
|
+
* No grouping, just alphabetize
|
|
52
|
+
*/
|
|
53
|
+
alphabetical: unknown;
|
|
54
|
+
/**
|
|
55
|
+
* Keep original order
|
|
56
|
+
*/
|
|
57
|
+
none: unknown
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Import sorting module for organizing imports in declaration files
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* Import sorting configuration
|
|
64
|
+
*/
|
|
65
|
+
export declare interface ImportSortConfig {
|
|
66
|
+
order?: string[]
|
|
67
|
+
groupByType?: boolean
|
|
68
|
+
groups?: ImportGroup[]
|
|
69
|
+
alphabetize?: boolean
|
|
70
|
+
caseInsensitive?: boolean
|
|
71
|
+
typeImportsLast?: boolean
|
|
72
|
+
separateTypeImports?: boolean
|
|
73
|
+
customGroups?: Record<string, string[]>
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Parsed import information
|
|
77
|
+
*/
|
|
78
|
+
export declare interface ParsedImport {
|
|
79
|
+
statement: string
|
|
80
|
+
source: string
|
|
81
|
+
isTypeOnly: boolean
|
|
82
|
+
group: ImportGroup
|
|
83
|
+
specifiers: string[]
|
|
84
|
+
defaultImport?: string
|
|
85
|
+
namespaceImport?: string
|
|
86
|
+
lineNumber?: number
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Import group types
|
|
90
|
+
*/
|
|
91
|
+
export type ImportGroup = | 'builtin'
|
|
92
|
+
| 'external'
|
|
93
|
+
| 'internal'
|
|
94
|
+
| 'parent'
|
|
95
|
+
| 'sibling'
|
|
96
|
+
| 'index'
|
|
97
|
+
| 'type'
|
|
98
|
+
| 'unknown'
|
|
99
|
+
| string // Custom group name;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Declaration, DtsGenerationConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create an incremental build wrapper
|
|
4
|
+
*/
|
|
5
|
+
export declare function createIncrementalBuilder(cache: IncrementalCache, configHash: string): void;
|
|
6
|
+
/**
|
|
7
|
+
* Prune old cache entries
|
|
8
|
+
*/
|
|
9
|
+
export declare function pruneCache(cache: IncrementalCache, _maxAge?: number, // 7 days default: unknown): Promise<number>;
|
|
10
|
+
/**
|
|
11
|
+
* Format incremental build result
|
|
12
|
+
*/
|
|
13
|
+
export declare function formatIncrementalResult(result: IncrementalBuildResult): string;
|
|
14
|
+
/**
|
|
15
|
+
* Extract dependencies from source content
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractDependencies(content: string, basePath: string): string[];
|
|
18
|
+
/**
|
|
19
|
+
* Incremental build configuration
|
|
20
|
+
*/
|
|
21
|
+
export declare interface IncrementalConfig {
|
|
22
|
+
enabled?: boolean
|
|
23
|
+
cacheDir?: string
|
|
24
|
+
format?: 'json' | 'binary'
|
|
25
|
+
maxAge?: number
|
|
26
|
+
force?: boolean
|
|
27
|
+
validateCache?: boolean
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Cached file entry for incremental builds
|
|
31
|
+
*/
|
|
32
|
+
export declare interface IncrementalCacheEntry {
|
|
33
|
+
filePath: string
|
|
34
|
+
hash: string
|
|
35
|
+
mtime: number
|
|
36
|
+
declarations: Declaration[]
|
|
37
|
+
dtsContent: string
|
|
38
|
+
dependencies: string[]
|
|
39
|
+
cachedAt: number
|
|
40
|
+
configHash: string
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Cache manifest for incremental builds
|
|
44
|
+
*/
|
|
45
|
+
export declare interface IncrementalCacheManifest {
|
|
46
|
+
version: string
|
|
47
|
+
entries: Record<string, IncrementalCacheEntry>
|
|
48
|
+
createdAt: number
|
|
49
|
+
updatedAt: number
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Incremental build result
|
|
53
|
+
*/
|
|
54
|
+
export declare interface IncrementalBuildResult {
|
|
55
|
+
rebuilt: string[]
|
|
56
|
+
cached: string[]
|
|
57
|
+
skipped: string[]
|
|
58
|
+
stats: CacheStats
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Cache statistics
|
|
62
|
+
*/
|
|
63
|
+
export declare interface CacheStats {
|
|
64
|
+
totalEntries: number
|
|
65
|
+
hits: number
|
|
66
|
+
misses: number
|
|
67
|
+
hitRatio: number
|
|
68
|
+
sizeBytes: number
|
|
69
|
+
timeSavedMs: number
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Incremental build cache manager
|
|
73
|
+
*/
|
|
74
|
+
export declare class IncrementalCache {
|
|
75
|
+
constructor(config?: IncrementalConfig);
|
|
76
|
+
init(): Promise<void>;
|
|
77
|
+
save(): Promise<void>;
|
|
78
|
+
get(filePath: string, configHash: string): Promise<IncrementalCacheEntry | null>;
|
|
79
|
+
set(filePath: string, content: string, declarations: Declaration[], dtsContent: string, dependencies: string[], configHash: string): Promise<void>;
|
|
80
|
+
invalidate(filePath: string): void;
|
|
81
|
+
clear(): Promise<void>;
|
|
82
|
+
getStats(): CacheStats;
|
|
83
|
+
static hashConfig(config: DtsGenerationConfig): string;
|
|
84
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @stacksjs/dtsx - A modern, fast .d.ts generation tool
|
|
3
|
+
*
|
|
4
|
+
* This module exports the full API. For minimal bundle size when only
|
|
5
|
+
* using the core generator, import directly from './generator'.
|
|
6
|
+
*
|
|
7
|
+
* Core exports (most commonly used):
|
|
8
|
+
* - generate, watch, processFile, processSource from './generator'
|
|
9
|
+
* - extractDeclarations, extractDeclarationsAsync from './extractor'
|
|
10
|
+
* - processDeclarations from './processor'
|
|
11
|
+
* - DtsGenerationConfig, Declaration types from './types'
|
|
12
|
+
*
|
|
13
|
+
* Optional/Advanced exports are available but may increase bundle size:
|
|
14
|
+
* - LSP support: './lsp'
|
|
15
|
+
* - Type checking: './checker'
|
|
16
|
+
* - Circular dependency detection: './circular'
|
|
17
|
+
* - Custom transformers: './transformers'
|
|
18
|
+
* - Worker pool: './worker'
|
|
19
|
+
*/
|
|
20
|
+
// Common utilities
|
|
21
|
+
export * from './branded-types';
|
|
22
|
+
export * from './bundler';
|
|
23
|
+
export * from './cache';
|
|
24
|
+
export * from './checker';
|
|
25
|
+
// Advanced features - larger bundle impact
|
|
26
|
+
export * from './circular';
|
|
27
|
+
export * from './compat';
|
|
1
28
|
export * from './config';
|
|
29
|
+
export * from './diff';
|
|
30
|
+
export * from './docs';
|
|
31
|
+
export * from './errors';
|
|
2
32
|
export * from './extractor';
|
|
33
|
+
export * from './formats';
|
|
34
|
+
export * from './formatter';
|
|
35
|
+
// Core API - essential for dts generation
|
|
3
36
|
export * from './generator';
|
|
37
|
+
export * from './import-sorter';
|
|
38
|
+
export * from './incremental';
|
|
39
|
+
export * from './logger';
|
|
40
|
+
export * from './lsp';
|
|
41
|
+
export * from './memory';
|
|
42
|
+
export * from './merger';
|
|
43
|
+
export * from './optimizer';
|
|
44
|
+
export * from './output-normalizer';
|
|
45
|
+
export * from './parallel-processor';
|
|
4
46
|
export * from './parser';
|
|
47
|
+
export * from './plugins';
|
|
5
48
|
export * from './processor';
|
|
49
|
+
export * from './profiling';
|
|
50
|
+
export * from './security';
|
|
51
|
+
export * from './sourcemap';
|
|
52
|
+
export * from './tracking';
|
|
53
|
+
export * from './transformers';
|
|
54
|
+
export * from './tree-shaker';
|
|
55
|
+
export * from './type-mappings';
|
|
6
56
|
export * from './types';
|
|
7
|
-
export * from './utils';
|
|
57
|
+
export * from './utils';
|
|
58
|
+
export * from './watcher';
|
|
59
|
+
export * from './worker';
|
|
60
|
+
export * from './workspace';
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a logger instance
|
|
3
|
+
*/
|
|
4
|
+
export declare function createLogger(options?: LoggerOptions): Logger;
|
|
5
|
+
/**
|
|
6
|
+
* Create a scoped logger for a specific module
|
|
7
|
+
* @example
|
|
8
|
+
* const log = scopedLogger('extractor')
|
|
9
|
+
* log.debug('Parsing file...') // [dtsx:extractor] Parsing file...
|
|
10
|
+
*/
|
|
11
|
+
export declare function scopedLogger(scope: string): Logger;
|
|
12
|
+
/**
|
|
13
|
+
* Set the global log level
|
|
14
|
+
*/
|
|
15
|
+
export declare function setLogLevel(level: LogLevel): void;
|
|
16
|
+
/**
|
|
17
|
+
* Get the current log level
|
|
18
|
+
*/
|
|
19
|
+
export declare function getLogLevel(): LogLevel;
|
|
20
|
+
/**
|
|
21
|
+
* Set the log prefix
|
|
22
|
+
*/
|
|
23
|
+
export declare function setLogPrefix(prefix: string): void;
|
|
24
|
+
/**
|
|
25
|
+
* Enable or disable timestamps
|
|
26
|
+
*/
|
|
27
|
+
export declare function setTimestamps(enabled: boolean): void;
|
|
28
|
+
/**
|
|
29
|
+
* Default logger instance
|
|
30
|
+
*/
|
|
31
|
+
export declare const logger: Logger;
|
|
32
|
+
/**
|
|
33
|
+
* No-op logger for silent mode or testing
|
|
34
|
+
*/
|
|
35
|
+
export declare const nullLogger: Logger;
|
|
36
|
+
export declare interface LoggerOptions {
|
|
37
|
+
level?: LogLevel
|
|
38
|
+
prefix?: string
|
|
39
|
+
timestamps?: boolean
|
|
40
|
+
output?: (level: LogLevel, ...args: unknown[]) => void
|
|
41
|
+
}
|
|
42
|
+
export declare interface Logger {
|
|
43
|
+
debug: (...args: unknown[]) => void
|
|
44
|
+
info: (...args: unknown[]) => void
|
|
45
|
+
warn: (...args: unknown[]) => void
|
|
46
|
+
error: (...args: unknown[]) => void
|
|
47
|
+
setLevel: (level: LogLevel) => void
|
|
48
|
+
getLevel: () => LogLevel
|
|
49
|
+
child: (scope: string) => Logger
|
|
50
|
+
time: (label: string) => () => void
|
|
51
|
+
progress: (message: string) => void
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Logger abstraction for dtsx
|
|
55
|
+
* Provides configurable logging with verbosity levels and scoped loggers
|
|
56
|
+
*/
|
|
57
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent';
|