@deepseek-ai/dsh-typert-generator 0.0.1-rc.1
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 +28 -0
- package/README.i18n.yaml +6 -0
- package/README.md +41 -0
- package/README.zh.md +41 -0
- package/lib/index.js +3922 -0
- package/lib/invariant.js +24 -0
- package/lib/types/analyzer.d.ts +143 -0
- package/lib/types/analyzer.js +2723 -0
- package/lib/types/cordis-catalog.d.ts +148 -0
- package/lib/types/cordis-catalog.js +695 -0
- package/lib/types/emitter.d.ts +55 -0
- package/lib/types/emitter.js +745 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/index.js +12 -0
- package/lib/types/invariant.d.ts +16 -0
- package/lib/types/invariant.js +23 -0
- package/lib/types/model.d.ts +409 -0
- package/lib/types/model.js +48 -0
- package/lib/types/renderer.d.ts +90 -0
- package/lib/types/renderer.js +351 -0
- package/lib/types/tsdown-plugin.d.ts +34 -0
- package/lib/types/tsdown-plugin.js +136 -0
- package/lib/types/workspace.d.ts +36 -0
- package/lib/types/workspace.js +114 -0
- package/package.json +54 -0
package/lib/invariant.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region lib/types/invariant.js
|
|
2
|
+
/**
|
|
3
|
+
* Package-owned invariant companion for `@deepseek-ai/dsh-typert-generator`.
|
|
4
|
+
* @module @deepseek-ai/dsh-typert-generator/invariant
|
|
5
|
+
*/
|
|
6
|
+
const PACKAGE_NAME = "@deepseek-ai/dsh-typert-generator";
|
|
7
|
+
/** Cordis companion plugin name. */
|
|
8
|
+
const name = "typert-generator-invariant";
|
|
9
|
+
/** Service required before the companion can reserve package ownership. */
|
|
10
|
+
const inject = ["invariants"];
|
|
11
|
+
/**
|
|
12
|
+
* No runtime invariant: this source-project analyzer and build-time emitter
|
|
13
|
+
* runs outside any cordis runtime; model snapshots, executable artifacts, and
|
|
14
|
+
* consuming-package typechecks enforce its output contract.
|
|
15
|
+
*/
|
|
16
|
+
const install = () => {};
|
|
17
|
+
/**
|
|
18
|
+
* Register this package's invariant companion.
|
|
19
|
+
* @param ctx - Cordis context carrying the invariant service.
|
|
20
|
+
* @returns the installed registration's disposer after setup succeeds.
|
|
21
|
+
*/
|
|
22
|
+
const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
23
|
+
//#endregion
|
|
24
|
+
export { apply, inject, name };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript project analyzer for the compiler-independent Typert model.
|
|
3
|
+
* Programs, symbols, and syntax nodes remain extraction-only implementation
|
|
4
|
+
* details; callers receive only the model declared in {@link ./model.ts}.
|
|
5
|
+
* @module @deepseek-ai/dsh-typert-generator/analyzer
|
|
6
|
+
*/
|
|
7
|
+
import ts from 'typescript';
|
|
8
|
+
import type { SourceDeclarationModel, TypertFace, WorkspaceModel } from './model.ts';
|
|
9
|
+
/** Analysis failure with a source-oriented diagnostic. */
|
|
10
|
+
export declare class TypertAnalysisError extends Error {
|
|
11
|
+
name: string;
|
|
12
|
+
}
|
|
13
|
+
/** Missing-annotation handling at public business boundaries. */
|
|
14
|
+
export type AnalysisMode = 'check' | 'write';
|
|
15
|
+
/** Workspace analysis configuration. */
|
|
16
|
+
export interface WorkspaceAnalyzerOptions {
|
|
17
|
+
/** Workspace root containing the face tsconfigs. */
|
|
18
|
+
readonly root: string;
|
|
19
|
+
/** Host aggregate path, relative to {@link root}; absent files are skipped. */
|
|
20
|
+
readonly hostConfig?: string;
|
|
21
|
+
/** Client aggregate path, relative to {@link root}; absent files are skipped. */
|
|
22
|
+
readonly clientConfig?: string;
|
|
23
|
+
/** Optional package-name subset for an incremental generation pass. */
|
|
24
|
+
readonly packages?: readonly string[];
|
|
25
|
+
/** Independently compiled faces to materialize; both are analyzed by default. */
|
|
26
|
+
readonly faces?: readonly TypertFace[];
|
|
27
|
+
/** Whether to repeat TypeScript project diagnostics before model extraction. */
|
|
28
|
+
readonly checkDiagnostics?: boolean;
|
|
29
|
+
/** Whether missing annotations fail or are written before a clean re-analysis. */
|
|
30
|
+
readonly mode?: AnalysisMode;
|
|
31
|
+
/** Shared workspace memo; supply one instance to reuse parses across analyzers. */
|
|
32
|
+
readonly caches?: WorkspaceCaches;
|
|
33
|
+
}
|
|
34
|
+
/** One package face whose public export graph contains Typert business declarations. */
|
|
35
|
+
export interface DiscoveredTypertPackage {
|
|
36
|
+
readonly package: string;
|
|
37
|
+
readonly root: string;
|
|
38
|
+
readonly faces: readonly TypertFace[];
|
|
39
|
+
}
|
|
40
|
+
/** One parsed tsconfig, memoizable per workspace snapshot. */
|
|
41
|
+
export interface ParsedConfig {
|
|
42
|
+
/** Absolute config path. */
|
|
43
|
+
readonly path: string;
|
|
44
|
+
/** The TypeScript parse result. */
|
|
45
|
+
readonly parsed: ts.ParsedCommandLine;
|
|
46
|
+
}
|
|
47
|
+
/** One package face registration discovered from an aggregate tsconfig. */
|
|
48
|
+
export interface PackageRegistration {
|
|
49
|
+
/** The face whose aggregate references this package project. */
|
|
50
|
+
readonly face: TypertFace;
|
|
51
|
+
/** The package manifest name. */
|
|
52
|
+
readonly name: string;
|
|
53
|
+
/** Real package root directory. */
|
|
54
|
+
readonly root: string;
|
|
55
|
+
/** The package's own parsed tsconfig. */
|
|
56
|
+
readonly config: ParsedConfig;
|
|
57
|
+
/** The parsed package.json content. */
|
|
58
|
+
readonly manifest: Record<string, unknown>;
|
|
59
|
+
/** Export subpaths owned by this face for dual-face packages. */
|
|
60
|
+
readonly exportSubpaths?: readonly string[];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Shared memo over one immutable workspace snapshot. Passing one instance to
|
|
64
|
+
* several analyzers (the batched and write-mode children reuse their parent's
|
|
65
|
+
* automatically) reuses parsed tsconfigs, the registration inventory, and
|
|
66
|
+
* per-face compiler hosts whose parsed and bound source files and module
|
|
67
|
+
* resolutions carry across programs. Callers that mutate workspace files
|
|
68
|
+
* between analyses must start from a fresh instance; write-mode source edits
|
|
69
|
+
* invalidate themselves through {@link invalidate}.
|
|
70
|
+
*/
|
|
71
|
+
export declare class WorkspaceCaches {
|
|
72
|
+
/** Parsed tsconfig files by absolute config path. */
|
|
73
|
+
readonly configs: Map<string, ParsedConfig>;
|
|
74
|
+
/** Registration inventories keyed by root and aggregate config paths. */
|
|
75
|
+
readonly registrations: Map<string, PackageRegistration[]>;
|
|
76
|
+
private readonly hosts;
|
|
77
|
+
/**
|
|
78
|
+
* Parse one tsconfig once per workspace snapshot.
|
|
79
|
+
* @param path - absolute config path.
|
|
80
|
+
* @returns the memoized parse result.
|
|
81
|
+
*/
|
|
82
|
+
config(path: string): ParsedConfig;
|
|
83
|
+
/**
|
|
84
|
+
* Return the shared compiler host for one face. Every program of one face
|
|
85
|
+
* is built from the same aggregate compiler options (the first call wins),
|
|
86
|
+
* so parsed source files, binder state, and module resolutions are safe to
|
|
87
|
+
* reuse across the face's batched programs.
|
|
88
|
+
* @param face - the face whose programs share this host.
|
|
89
|
+
* @param options - the face's effective compiler options.
|
|
90
|
+
* @returns a compiler host with source-file and module-resolution caches.
|
|
91
|
+
*/
|
|
92
|
+
programHost(face: TypertFace, options: ts.CompilerOptions): ts.CompilerHost;
|
|
93
|
+
/**
|
|
94
|
+
* Drop cached parses of one edited source file so the next analysis reads
|
|
95
|
+
* the written content.
|
|
96
|
+
* @param file - path of the edited file.
|
|
97
|
+
*/
|
|
98
|
+
invalidate(file: string): void;
|
|
99
|
+
}
|
|
100
|
+
/** Analyze host and client as independent TypeScript programs. */
|
|
101
|
+
export declare class WorkspaceAnalyzer {
|
|
102
|
+
private readonly options;
|
|
103
|
+
private queuedEdit;
|
|
104
|
+
private readonly crossFaceLinks;
|
|
105
|
+
private readonly checkedProjects;
|
|
106
|
+
private registrations;
|
|
107
|
+
private readonly caches;
|
|
108
|
+
constructor(options: WorkspaceAnalyzerOptions);
|
|
109
|
+
/**
|
|
110
|
+
* Build the workspace model. Write mode applies inferred annotations and then
|
|
111
|
+
* returns a fresh check-mode analysis of the edited projects.
|
|
112
|
+
* @returns the independent face models and their explicit cross-face links.
|
|
113
|
+
*/
|
|
114
|
+
analyze(): WorkspaceModel;
|
|
115
|
+
/**
|
|
116
|
+
* Analyze an explicit package selection through bounded compiler programs.
|
|
117
|
+
* The resulting model is identical in shape to {@link analyze}; stable graph
|
|
118
|
+
* ids let repeated dependency declarations merge without flattening types.
|
|
119
|
+
* @param batchSize - maximum selected packages in one face program.
|
|
120
|
+
* @returns one merged workspace model.
|
|
121
|
+
*/
|
|
122
|
+
analyzeInBatches(batchSize?: number): WorkspaceModel;
|
|
123
|
+
/**
|
|
124
|
+
* Discover package faces from public-export-reachable Cordis augmentations
|
|
125
|
+
* and explicit `@typert` roots without constructing a type-checker program.
|
|
126
|
+
* @returns contributors grouped by package with deterministic face order.
|
|
127
|
+
*/
|
|
128
|
+
discoverPackages(): DiscoveredTypertPackage[];
|
|
129
|
+
/**
|
|
130
|
+
* Index top-level exported type declarations without promoting them to graph
|
|
131
|
+
* roots. Consumers use this lexical index for ambiguity checks while all
|
|
132
|
+
* semantic traversal continues through {@link TypeGraph}.
|
|
133
|
+
* @returns declarations from the selected faces and package projects.
|
|
134
|
+
*/
|
|
135
|
+
indexSourceDeclarations(): SourceDeclarationModel[];
|
|
136
|
+
private loadRegistrations;
|
|
137
|
+
private entrySourcePaths;
|
|
138
|
+
private registrationHasSurface;
|
|
139
|
+
private checkProject;
|
|
140
|
+
private queueEdit;
|
|
141
|
+
private applyEdit;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=analyzer.d.ts.map
|