@typed/virtual-modules 1.0.0-beta.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.
Files changed (82) hide show
  1. package/README.md +135 -0
  2. package/dist/CompilerHostAdapter.d.ts +3 -0
  3. package/dist/CompilerHostAdapter.d.ts.map +1 -0
  4. package/dist/CompilerHostAdapter.js +160 -0
  5. package/dist/LanguageServiceAdapter.d.ts +3 -0
  6. package/dist/LanguageServiceAdapter.d.ts.map +1 -0
  7. package/dist/LanguageServiceAdapter.js +488 -0
  8. package/dist/LanguageServiceSession.d.ts +16 -0
  9. package/dist/LanguageServiceSession.d.ts.map +1 -0
  10. package/dist/LanguageServiceSession.js +122 -0
  11. package/dist/NodeModulePluginLoader.d.ts +8 -0
  12. package/dist/NodeModulePluginLoader.d.ts.map +1 -0
  13. package/dist/NodeModulePluginLoader.js +175 -0
  14. package/dist/PluginManager.d.ts +10 -0
  15. package/dist/PluginManager.d.ts.map +1 -0
  16. package/dist/PluginManager.js +151 -0
  17. package/dist/TypeInfoApi.d.ts +71 -0
  18. package/dist/TypeInfoApi.d.ts.map +1 -0
  19. package/dist/TypeInfoApi.js +855 -0
  20. package/dist/VmcConfigLoader.d.ts +31 -0
  21. package/dist/VmcConfigLoader.d.ts.map +1 -0
  22. package/dist/VmcConfigLoader.js +231 -0
  23. package/dist/VmcResolverLoader.d.ts +30 -0
  24. package/dist/VmcResolverLoader.d.ts.map +1 -0
  25. package/dist/VmcResolverLoader.js +71 -0
  26. package/dist/collectTypeTargetSpecs.d.ts +6 -0
  27. package/dist/collectTypeTargetSpecs.d.ts.map +1 -0
  28. package/dist/collectTypeTargetSpecs.js +19 -0
  29. package/dist/index.d.ts +13 -0
  30. package/dist/index.d.ts.map +1 -0
  31. package/dist/index.js +12 -0
  32. package/dist/internal/VirtualRecordStore.d.ts +60 -0
  33. package/dist/internal/VirtualRecordStore.d.ts.map +1 -0
  34. package/dist/internal/VirtualRecordStore.js +199 -0
  35. package/dist/internal/materializeVirtualFile.d.ts +12 -0
  36. package/dist/internal/materializeVirtualFile.d.ts.map +1 -0
  37. package/dist/internal/materializeVirtualFile.js +28 -0
  38. package/dist/internal/path.d.ts +40 -0
  39. package/dist/internal/path.d.ts.map +1 -0
  40. package/dist/internal/path.js +71 -0
  41. package/dist/internal/sanitize.d.ts +6 -0
  42. package/dist/internal/sanitize.d.ts.map +1 -0
  43. package/dist/internal/sanitize.js +15 -0
  44. package/dist/internal/tsInternal.d.ts +65 -0
  45. package/dist/internal/tsInternal.d.ts.map +1 -0
  46. package/dist/internal/tsInternal.js +99 -0
  47. package/dist/internal/validation.d.ts +28 -0
  48. package/dist/internal/validation.d.ts.map +1 -0
  49. package/dist/internal/validation.js +66 -0
  50. package/dist/typeTargetBootstrap.d.ts +33 -0
  51. package/dist/typeTargetBootstrap.d.ts.map +1 -0
  52. package/dist/typeTargetBootstrap.js +57 -0
  53. package/dist/types.d.ts +405 -0
  54. package/dist/types.d.ts.map +1 -0
  55. package/dist/types.js +15 -0
  56. package/package.json +38 -0
  57. package/src/CompilerHostAdapter.test.ts +180 -0
  58. package/src/CompilerHostAdapter.ts +316 -0
  59. package/src/LanguageServiceAdapter.test.ts +521 -0
  60. package/src/LanguageServiceAdapter.ts +631 -0
  61. package/src/LanguageServiceSession.ts +160 -0
  62. package/src/LanguageServiceTester.integration.test.ts +268 -0
  63. package/src/NodeModulePluginLoader.test.ts +170 -0
  64. package/src/NodeModulePluginLoader.ts +268 -0
  65. package/src/PluginManager.test.ts +178 -0
  66. package/src/PluginManager.ts +218 -0
  67. package/src/TypeInfoApi.test.ts +1211 -0
  68. package/src/TypeInfoApi.ts +1228 -0
  69. package/src/VmcConfigLoader.test.ts +108 -0
  70. package/src/VmcConfigLoader.ts +297 -0
  71. package/src/VmcResolverLoader.test.ts +181 -0
  72. package/src/VmcResolverLoader.ts +116 -0
  73. package/src/collectTypeTargetSpecs.ts +22 -0
  74. package/src/index.ts +35 -0
  75. package/src/internal/VirtualRecordStore.ts +304 -0
  76. package/src/internal/materializeVirtualFile.ts +38 -0
  77. package/src/internal/path.ts +106 -0
  78. package/src/internal/sanitize.ts +16 -0
  79. package/src/internal/tsInternal.ts +127 -0
  80. package/src/internal/validation.ts +85 -0
  81. package/src/typeTargetBootstrap.ts +75 -0
  82. package/src/types.ts +535 -0
@@ -0,0 +1,33 @@
1
+ import type * as ts from "typescript";
2
+ import type { TypeTargetSpec } from "./types.js";
3
+ /**
4
+ * Canonical relative path for the type-target bootstrap file.
5
+ * Always under node_modules so it is git-ignored and does not pollute the project.
6
+ */
7
+ export declare const TYPE_TARGET_BOOTSTRAP_RELATIVE = "node_modules/.typed/type-target-bootstrap.ts";
8
+ /**
9
+ * Returns the canonical path for the type-target bootstrap file.
10
+ * Always under projectRoot/node_modules/.typed/ so it is git-ignored.
11
+ * All consumers (TS plugin, VSCode resolver, VMC, Vite plugin) should use this path.
12
+ */
13
+ export declare function getTypeTargetBootstrapPath(projectRoot: string): string;
14
+ export interface EnsureTypeTargetBootstrapFileFs {
15
+ mkdirSync(path: string, options?: {
16
+ recursive?: boolean;
17
+ }): void;
18
+ writeFile(path: string, content: string): void;
19
+ }
20
+ /**
21
+ * Ensures the type-target bootstrap file exists on disk. Writes to
22
+ * projectRoot/node_modules/.typed/type-target-bootstrap.ts (git-ignored via node_modules).
23
+ * Creates node_modules/.typed if needed. Returns the bootstrap path.
24
+ * Use default Node fs unless passing custom fs (e.g. ts.sys for VMC).
25
+ */
26
+ export declare function ensureTypeTargetBootstrapFile(projectRoot: string, typeTargetSpecs: readonly TypeTargetSpec[], fs?: EnsureTypeTargetBootstrapFileFs): string;
27
+ /**
28
+ * Returns a program that includes the type-target bootstrap file in rootNames when
29
+ * typeTargetSpecs is non-empty, so resolveTypeTargetsFromSpecs can find types.
30
+ * If typeTargetSpecs is empty or the program already includes the bootstrap, returns program unchanged.
31
+ */
32
+ export declare function getProgramWithTypeTargetBootstrap(tsMod: typeof import("typescript"), program: ts.Program, projectRoot: string, typeTargetSpecs: readonly TypeTargetSpec[] | undefined): ts.Program;
33
+ //# sourceMappingURL=typeTargetBootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeTargetBootstrap.d.ts","sourceRoot":"","sources":["../src/typeTargetBootstrap.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,8BAA8B,iDAAiD,CAAC;AAE7F;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,MAAM,WAAW,+BAA+B;IAC9C,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;IACjE,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChD;AAWD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,EAAE,GAAE,+BAA2C,GAC9C,MAAM,CAOR;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC/C,KAAK,EAAE,cAAc,YAAY,CAAC,EAClC,OAAO,EAAE,EAAE,CAAC,OAAO,EACnB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,GACrD,EAAE,CAAC,OAAO,CAUZ"}
@@ -0,0 +1,57 @@
1
+ import { mkdirSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { createTypeTargetBootstrapContent } from "./TypeInfoApi.js";
4
+ /**
5
+ * Canonical relative path for the type-target bootstrap file.
6
+ * Always under node_modules so it is git-ignored and does not pollute the project.
7
+ */
8
+ export const TYPE_TARGET_BOOTSTRAP_RELATIVE = "node_modules/.typed/type-target-bootstrap.ts";
9
+ /**
10
+ * Returns the canonical path for the type-target bootstrap file.
11
+ * Always under projectRoot/node_modules/.typed/ so it is git-ignored.
12
+ * All consumers (TS plugin, VSCode resolver, VMC, Vite plugin) should use this path.
13
+ */
14
+ export function getTypeTargetBootstrapPath(projectRoot) {
15
+ return join(projectRoot, "node_modules", ".typed", "type-target-bootstrap.ts");
16
+ }
17
+ const defaultFs = {
18
+ mkdirSync(path, options) {
19
+ mkdirSync(path, options);
20
+ },
21
+ writeFile(path, content) {
22
+ writeFileSync(path, content, "utf8");
23
+ },
24
+ };
25
+ /**
26
+ * Ensures the type-target bootstrap file exists on disk. Writes to
27
+ * projectRoot/node_modules/.typed/type-target-bootstrap.ts (git-ignored via node_modules).
28
+ * Creates node_modules/.typed if needed. Returns the bootstrap path.
29
+ * Use default Node fs unless passing custom fs (e.g. ts.sys for VMC).
30
+ */
31
+ export function ensureTypeTargetBootstrapFile(projectRoot, typeTargetSpecs, fs = defaultFs) {
32
+ const bootstrapPath = getTypeTargetBootstrapPath(projectRoot);
33
+ if (typeTargetSpecs.length === 0)
34
+ return bootstrapPath;
35
+ const dir = dirname(bootstrapPath);
36
+ fs.mkdirSync(dir, { recursive: true });
37
+ fs.writeFile(bootstrapPath, createTypeTargetBootstrapContent(typeTargetSpecs));
38
+ return bootstrapPath;
39
+ }
40
+ /**
41
+ * Returns a program that includes the type-target bootstrap file in rootNames when
42
+ * typeTargetSpecs is non-empty, so resolveTypeTargetsFromSpecs can find types.
43
+ * If typeTargetSpecs is empty or the program already includes the bootstrap, returns program unchanged.
44
+ */
45
+ export function getProgramWithTypeTargetBootstrap(tsMod, program, projectRoot, typeTargetSpecs) {
46
+ if (!typeTargetSpecs?.length)
47
+ return program;
48
+ const bootstrapPath = ensureTypeTargetBootstrapFile(projectRoot, typeTargetSpecs);
49
+ const rootNames = program.getRootFileNames();
50
+ const canonicalBootstrap = resolve(bootstrapPath);
51
+ const alreadyHasBootstrap = rootNames.some((p) => resolve(p) === canonicalBootstrap);
52
+ if (alreadyHasBootstrap)
53
+ return program;
54
+ const opts = program.getCompilerOptions();
55
+ const host = tsMod.createCompilerHost(opts, true);
56
+ return tsMod.createProgram([...rootNames, bootstrapPath], opts, host);
57
+ }
@@ -0,0 +1,405 @@
1
+ import type * as ts from "typescript";
2
+ /**
3
+ * Type-safe AST for serialized types. Discriminated union by `kind`.
4
+ * Use `node.kind` to narrow; each variant exposes only its fields (e.g. `UnionTypeNode.elements`, `FunctionTypeNode.parameters`).
5
+ *
6
+ * Forward-compatible consumer guidance: Use a switch with a default branch that handles unknown kinds
7
+ * (e.g. `return node.text` or fallback behavior). New `kind` values may be added over time;
8
+ * consumers that only care about specific variants should explicitly list them and treat others as opaque.
9
+ *
10
+ * @example
11
+ * function visit(node: TypeNode): string {
12
+ * switch (node.kind) {
13
+ * case "union": return node.elements.map(visit).join(" | ");
14
+ * case "function": return `(${node.parameters.map(p => p.name).join(", ")}) => ${visit(node.returnType)}`;
15
+ * case "object": return `{ ${node.properties.map(p => p.name).join(", ")} }`;
16
+ * default: return node.text;
17
+ * }
18
+ * }
19
+ */
20
+ export type TypeNode = LiteralTypeNode | PrimitiveTypeNode | AnyTypeNode | UnknownTypeNode | NeverTypeNode | UnionTypeNode | IntersectionTypeNode | TupleTypeNode | ArrayTypeNode | FunctionTypeNode | ReferenceTypeNode | ObjectTypeNode | ConditionalTypeNode | IndexedAccessTypeNode | TemplateLiteralTypeNode | MappedTypeNode | TypeOperatorTypeNode | ConstructorTypeNode | IndexSignatureTypeNode | OverloadSetTypeNode | EnumTypeNode;
21
+ export interface LiteralTypeNode {
22
+ readonly kind: "literal";
23
+ readonly text: string;
24
+ }
25
+ export interface PrimitiveTypeNode {
26
+ readonly kind: "primitive";
27
+ readonly text: string;
28
+ }
29
+ export interface AnyTypeNode {
30
+ readonly kind: "any";
31
+ readonly text: string;
32
+ }
33
+ export interface UnknownTypeNode {
34
+ readonly kind: "unknown";
35
+ readonly text: string;
36
+ }
37
+ export interface NeverTypeNode {
38
+ readonly kind: "never";
39
+ readonly text: string;
40
+ }
41
+ export interface UnionTypeNode {
42
+ readonly kind: "union";
43
+ readonly text: string;
44
+ readonly elements: readonly TypeNode[];
45
+ }
46
+ export interface IntersectionTypeNode {
47
+ readonly kind: "intersection";
48
+ readonly text: string;
49
+ readonly elements: readonly TypeNode[];
50
+ }
51
+ export interface TupleTypeNode {
52
+ readonly kind: "tuple";
53
+ readonly text: string;
54
+ readonly elements: readonly TypeNode[];
55
+ }
56
+ export interface ArrayTypeNode {
57
+ readonly kind: "array";
58
+ readonly text: string;
59
+ readonly elements: readonly TypeNode[];
60
+ }
61
+ export interface TypeParameter {
62
+ readonly name: string;
63
+ readonly optional: boolean;
64
+ readonly type: TypeNode;
65
+ }
66
+ export interface FunctionTypeNode {
67
+ readonly kind: "function";
68
+ readonly text: string;
69
+ readonly parameters: readonly TypeParameter[];
70
+ readonly returnType: TypeNode;
71
+ }
72
+ export interface ReferenceTypeNode {
73
+ readonly kind: "reference";
74
+ readonly text: string;
75
+ readonly typeArguments?: readonly TypeNode[];
76
+ }
77
+ export interface ObjectProperty {
78
+ readonly name: string;
79
+ readonly optional: boolean;
80
+ readonly readonly: boolean;
81
+ readonly type: TypeNode;
82
+ }
83
+ export interface ObjectTypeNode {
84
+ readonly kind: "object";
85
+ readonly text: string;
86
+ readonly properties: readonly ObjectProperty[];
87
+ /** Optional index signature for `[key: K]: V` when present. */
88
+ readonly indexSignature?: IndexSignatureInfo;
89
+ }
90
+ export interface IndexSignatureInfo {
91
+ readonly keyType: TypeNode;
92
+ readonly valueType: TypeNode;
93
+ readonly readonly: boolean;
94
+ }
95
+ export interface ConditionalTypeNode {
96
+ readonly kind: "conditional";
97
+ readonly text: string;
98
+ readonly checkType: TypeNode;
99
+ readonly extendsType: TypeNode;
100
+ readonly trueType: TypeNode;
101
+ readonly falseType: TypeNode;
102
+ }
103
+ export interface IndexedAccessTypeNode {
104
+ readonly kind: "indexedAccess";
105
+ readonly text: string;
106
+ readonly objectType: TypeNode;
107
+ readonly indexType: TypeNode;
108
+ }
109
+ export interface TemplateLiteralTypeNode {
110
+ readonly kind: "templateLiteral";
111
+ readonly text: string;
112
+ readonly texts: readonly string[];
113
+ readonly types: readonly TypeNode[];
114
+ }
115
+ export interface MappedTypeNode {
116
+ readonly kind: "mapped";
117
+ readonly text: string;
118
+ readonly constraintType: TypeNode;
119
+ readonly mappedType: TypeNode;
120
+ readonly readonlyModifier?: "+" | "-" | undefined;
121
+ readonly optionalModifier?: "+" | "-" | undefined;
122
+ }
123
+ export interface TypeOperatorTypeNode {
124
+ readonly kind: "typeOperator";
125
+ readonly text: string;
126
+ readonly operator: "keyof" | "unique" | "readonly";
127
+ readonly type: TypeNode;
128
+ }
129
+ export interface ConstructorTypeNode {
130
+ readonly kind: "constructor";
131
+ readonly text: string;
132
+ readonly parameters: readonly TypeParameter[];
133
+ readonly returnType: TypeNode;
134
+ }
135
+ export interface IndexSignatureTypeNode {
136
+ readonly kind: "indexSignature";
137
+ readonly text: string;
138
+ readonly keyType: TypeNode;
139
+ readonly valueType: TypeNode;
140
+ readonly readonly: boolean;
141
+ }
142
+ export interface FunctionSignature {
143
+ readonly parameters: readonly TypeParameter[];
144
+ readonly returnType: TypeNode;
145
+ }
146
+ export interface OverloadSetTypeNode {
147
+ readonly kind: "overloadSet";
148
+ readonly text: string;
149
+ readonly signatures: readonly FunctionSignature[];
150
+ }
151
+ export interface EnumTypeNode {
152
+ readonly kind: "enum";
153
+ readonly text: string;
154
+ readonly members?: readonly {
155
+ readonly name: string;
156
+ readonly value?: string | number;
157
+ }[];
158
+ }
159
+ export interface ExportedTypeInfo {
160
+ readonly name: string;
161
+ readonly declarationKind?: string;
162
+ readonly declarationText?: string;
163
+ readonly docs?: string;
164
+ readonly type: TypeNode;
165
+ }
166
+ /**
167
+ * A step that navigates from one type to a sub-type during assignability checking.
168
+ * Steps chain left-to-right when composed in an array.
169
+ */
170
+ export type TypeProjectionStep = {
171
+ readonly kind: "returnType";
172
+ } | {
173
+ readonly kind: "param";
174
+ readonly index: number;
175
+ } | {
176
+ readonly kind: "typeArg";
177
+ readonly index: number;
178
+ } | {
179
+ readonly kind: "property";
180
+ readonly name: string;
181
+ } | {
182
+ readonly kind: "ensure";
183
+ readonly targetId: string;
184
+ } | {
185
+ readonly kind: "predicate";
186
+ readonly fn: (node: TypeNode) => boolean;
187
+ };
188
+ /**
189
+ * Spec for resolving a type from program imports for structural assignability checks.
190
+ * Used with createTypeInfoApiSession typeTargetSpecs option; resolution happens internally.
191
+ */
192
+ export interface TypeTargetSpec {
193
+ readonly id: string;
194
+ readonly module: string;
195
+ readonly exportName: string;
196
+ /**
197
+ * When the export is a merged interface+namespace with a type member that accepts
198
+ * all generic instantiations (e.g. Route.Any = Route<any, any>), use this to
199
+ * resolve that member's type for assignability checks.
200
+ * Enables Route.Parse("/status") (Route<"/status">) to pass assignableTo.Route
201
+ * by comparing against Route.Any instead of the uninstantiated generic.
202
+ */
203
+ readonly typeMember?: string;
204
+ }
205
+ /**
206
+ * Import information for cross-file reference resolution.
207
+ * Enables plugins to trace symbols to their source declarations.
208
+ */
209
+ export interface ImportInfo {
210
+ readonly moduleSpecifier: string;
211
+ readonly importedNames?: readonly string[];
212
+ readonly defaultImport?: string;
213
+ readonly namespaceImport?: string;
214
+ /**
215
+ * Resolved absolute path when the module resolves to a project file.
216
+ * Optional; not currently populated by the API. Reserved for future use (e.g. plugin navigation).
217
+ */
218
+ readonly resolvedFilePath?: string;
219
+ }
220
+ export interface TypeInfoFileSnapshot {
221
+ readonly filePath: string;
222
+ readonly exports: readonly ExportedTypeInfo[];
223
+ /** Imports present in the file for cross-file reference resolution. */
224
+ readonly imports?: readonly ImportInfo[];
225
+ }
226
+ export interface FileSnapshotSuccess {
227
+ readonly ok: true;
228
+ readonly snapshot: TypeInfoFileSnapshot;
229
+ }
230
+ export type FileSnapshotErrorCode = "file-not-in-program" | "path-escapes-base" | "invalid-input";
231
+ export interface FileSnapshotError {
232
+ readonly ok: false;
233
+ readonly error: FileSnapshotErrorCode;
234
+ readonly path?: string;
235
+ }
236
+ export type FileSnapshotResult = FileSnapshotSuccess | FileSnapshotError;
237
+ export interface TypeInfoFileQueryOptions {
238
+ readonly baseDir: string;
239
+ readonly watch?: boolean;
240
+ }
241
+ export interface TypeInfoDirectoryQueryOptions {
242
+ readonly baseDir: string;
243
+ readonly recursive: boolean;
244
+ readonly watch?: boolean;
245
+ }
246
+ export interface FileWatchDependencyDescriptor {
247
+ readonly type: "file";
248
+ readonly path: string;
249
+ }
250
+ export interface GlobWatchDependencyDescriptor {
251
+ readonly type: "glob";
252
+ readonly baseDir: string;
253
+ readonly relativeGlobs: readonly string[];
254
+ readonly recursive: boolean;
255
+ }
256
+ export type WatchDependencyDescriptor = FileWatchDependencyDescriptor | GlobWatchDependencyDescriptor;
257
+ export interface TypeInfoApi {
258
+ file(relativePath: string, options: TypeInfoFileQueryOptions): FileSnapshotResult;
259
+ directory(relativeGlobs: string | readonly string[], options: TypeInfoDirectoryQueryOptions): readonly TypeInfoFileSnapshot[];
260
+ /**
261
+ * Resolve an export by name from a file. Use baseDir-relative filePath.
262
+ * Returns undefined when the file is not in the program or the export is not found.
263
+ */
264
+ resolveExport(baseDir: string, filePath: string, exportName: string): ExportedTypeInfo | undefined;
265
+ /**
266
+ * Dynamic structural assignability check. Looks up the ts.Type backing `node`
267
+ * (registered during serialization), optionally applies projection steps to
268
+ * navigate to a sub-type, then checks assignability against the resolved target.
269
+ *
270
+ * Returns false when: node was not created by this API, projection fails
271
+ * (e.g. returnType on non-function), or targetId was not resolved.
272
+ *
273
+ * Plugins can navigate the TypeNode tree themselves and pass any sub-node
274
+ * (e.g. `functionNode.returnType`, `referenceNode.typeArguments[0]`) since
275
+ * all nodes are registered during serialization.
276
+ */
277
+ isAssignableTo(node: TypeNode, targetId: string, projection?: readonly TypeProjectionStep[]): boolean;
278
+ }
279
+ export interface TypeInfoApiSession {
280
+ readonly api: TypeInfoApi;
281
+ consumeDependencies(): readonly WatchDependencyDescriptor[];
282
+ }
283
+ export interface TypeInfoApiFactoryParams {
284
+ readonly id: string;
285
+ readonly importer: string;
286
+ }
287
+ export type CreateTypeInfoApiSession = (params: TypeInfoApiFactoryParams) => TypeInfoApiSession;
288
+ /** Result of a successful build; plain string is treated as { sourceText }. */
289
+ export interface VirtualModuleBuildSuccess {
290
+ readonly sourceText: string;
291
+ readonly warnings?: readonly VirtualModuleDiagnostic[];
292
+ }
293
+ /** Result of a failed build with structured errors. */
294
+ export interface VirtualModuleBuildError {
295
+ readonly errors: readonly VirtualModuleDiagnostic[];
296
+ }
297
+ export type VirtualModuleBuildResult = string | VirtualModuleBuildSuccess | VirtualModuleBuildError;
298
+ /** Type guard: true when the build result indicates failure with structured errors. */
299
+ export declare function isVirtualModuleBuildError(result: VirtualModuleBuildResult): result is VirtualModuleBuildError;
300
+ /** Type guard: true when the build result indicates success with sourceText. */
301
+ export declare function isVirtualModuleBuildSuccess(result: VirtualModuleBuildResult): result is VirtualModuleBuildSuccess;
302
+ export interface VirtualModulePlugin {
303
+ readonly name: string;
304
+ shouldResolve(id: string, importer: string): boolean;
305
+ build(id: string, importer: string, api: TypeInfoApi): VirtualModuleBuildResult;
306
+ /**
307
+ * Optional type target specs for structural assignability checks.
308
+ * Plugins that need assignableTo (e.g. Route, Effect) should declare them here.
309
+ * Specs from all plugins are merged (deduped by id) when creating the TypeInfo session.
310
+ */
311
+ readonly typeTargetSpecs?: readonly TypeTargetSpec[];
312
+ }
313
+ export interface VirtualModuleDiagnostic {
314
+ readonly code: "plugin-should-resolve-threw" | "plugin-build-threw" | "session-creation-failed" | "invalid-build-output" | "invalid-options" | "re-entrant-resolution" | (string & {});
315
+ readonly message: string;
316
+ readonly pluginName: string;
317
+ }
318
+ export interface VirtualModuleResolved {
319
+ readonly status: "resolved";
320
+ readonly pluginName: string;
321
+ readonly sourceText: string;
322
+ readonly dependencies: readonly WatchDependencyDescriptor[];
323
+ readonly warnings?: readonly VirtualModuleDiagnostic[];
324
+ }
325
+ export interface VirtualModuleUnresolved {
326
+ readonly status: "unresolved";
327
+ }
328
+ export interface VirtualModuleError {
329
+ readonly status: "error";
330
+ readonly diagnostic: VirtualModuleDiagnostic;
331
+ }
332
+ export type VirtualModuleResolution = VirtualModuleResolved | VirtualModuleUnresolved | VirtualModuleError;
333
+ export interface ResolveVirtualModuleOptions {
334
+ readonly id: string;
335
+ readonly importer: string;
336
+ readonly createTypeInfoApiSession?: CreateTypeInfoApiSession;
337
+ }
338
+ export interface VirtualModuleResolver {
339
+ resolveModule(options: ResolveVirtualModuleOptions): VirtualModuleResolution;
340
+ }
341
+ export interface NodeModulePluginRequest {
342
+ readonly specifier: string;
343
+ readonly baseDir: string;
344
+ }
345
+ export type NodeModulePluginLoadInput = VirtualModulePlugin | NodeModulePluginRequest;
346
+ export interface NodeModulePluginLoadSuccess {
347
+ readonly status: "loaded";
348
+ readonly plugin: VirtualModulePlugin;
349
+ readonly resolvedPath: string;
350
+ }
351
+ export interface NodeModulePluginLoadError {
352
+ readonly status: "error";
353
+ readonly specifier: string;
354
+ readonly baseDir: string;
355
+ readonly code: "module-not-found" | "module-load-failed" | "invalid-plugin-export" | "path-escapes-base" | "invalid-request";
356
+ readonly message: string;
357
+ }
358
+ export type NodeModulePluginLoadResult = NodeModulePluginLoadSuccess | NodeModulePluginLoadError;
359
+ export interface VirtualModuleRecord {
360
+ readonly key: string;
361
+ readonly id: string;
362
+ readonly importer: string;
363
+ readonly pluginName: string;
364
+ readonly virtualFileName: string;
365
+ readonly sourceText: string;
366
+ readonly dependencies: readonly WatchDependencyDescriptor[];
367
+ readonly diagnostic?: VirtualModuleDiagnostic;
368
+ readonly warnings?: readonly VirtualModuleDiagnostic[];
369
+ readonly version: number;
370
+ readonly stale: boolean;
371
+ }
372
+ export interface LanguageServiceWatchHost {
373
+ watchFile?: (path: string, callback: ts.FileWatcherCallback, pollingInterval?: number, options?: ts.WatchOptions) => ts.FileWatcher;
374
+ watchDirectory?: (path: string, callback: ts.DirectoryWatcherCallback, recursive?: boolean, options?: ts.WatchOptions) => ts.FileWatcher;
375
+ }
376
+ export interface LanguageServiceAdapterOptions {
377
+ readonly ts: typeof import("typescript");
378
+ readonly languageService: ts.LanguageService;
379
+ readonly languageServiceHost: ts.LanguageServiceHost;
380
+ readonly resolver: VirtualModuleResolver;
381
+ readonly projectRoot: string;
382
+ readonly createTypeInfoApiSession?: CreateTypeInfoApiSession;
383
+ readonly watchHost?: LanguageServiceWatchHost;
384
+ /** Coalesce rapid watch events (ms). When set, markStale is deferred until after the delay. */
385
+ readonly debounceMs?: number;
386
+ }
387
+ export interface CompilerHostAdapterOptions {
388
+ readonly ts: typeof import("typescript");
389
+ readonly compilerHost: ts.CompilerHost;
390
+ readonly resolver: VirtualModuleResolver;
391
+ readonly projectRoot: string;
392
+ readonly createTypeInfoApiSession?: CreateTypeInfoApiSession;
393
+ readonly watchHost?: LanguageServiceWatchHost;
394
+ /** Coalesce rapid watch events (ms). When set, markStale is deferred until after the delay. */
395
+ readonly debounceMs?: number;
396
+ /**
397
+ * When provided, called when a virtual module rebuild fails (stale record).
398
+ * Use to surface diagnostics to match LanguageServiceAdapter behavior.
399
+ */
400
+ readonly reportDiagnostic?: ts.DiagnosticReporter;
401
+ }
402
+ export interface VirtualModuleAdapterHandle {
403
+ dispose(): void;
404
+ }
405
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,QAAQ,GAChB,eAAe,GACf,iBAAiB,GACjB,WAAW,GACX,eAAe,GACf,aAAa,GACb,aAAa,GACb,oBAAoB,GACpB,aAAa,GACb,aAAa,GACb,gBAAgB,GAChB,iBAAiB,GACjB,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,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,EAAE,EAAE,cAAc,YAAY,CAAC,CAAC;IACzC,QAAQ,CAAC,eAAe,EAAE,EAAE,CAAC,eAAe,CAAC;IAC7C,QAAQ,CAAC,mBAAmB,EAAE,EAAE,CAAC,mBAAmB,CAAC;IACrD,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,wBAAwB,CAAC;IAC9C,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,EAAE,cAAc,YAAY,CAAC,CAAC;IACzC,QAAQ,CAAC,YAAY,EAAE,EAAE,CAAC,YAAY,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IAC7D,QAAQ,CAAC,SAAS,CAAC,EAAE,wBAAwB,CAAC;IAC9C,+FAA+F;IAC/F,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,kBAAkB,CAAC;CACnD;AAED,MAAM,WAAW,0BAA0B;IACzC,OAAO,IAAI,IAAI,CAAC;CACjB"}
package/dist/types.js ADDED
@@ -0,0 +1,15 @@
1
+ /** Type guard: true when the build result indicates failure with structured errors. */
2
+ export function isVirtualModuleBuildError(result) {
3
+ return (typeof result === "object" &&
4
+ result !== null &&
5
+ "errors" in result &&
6
+ Array.isArray(result.errors) &&
7
+ result.errors.length > 0);
8
+ }
9
+ /** Type guard: true when the build result indicates success with sourceText. */
10
+ export function isVirtualModuleBuildSuccess(result) {
11
+ return (typeof result === "object" &&
12
+ result !== null &&
13
+ "sourceText" in result &&
14
+ typeof result.sourceText === "string");
15
+ }
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@typed/virtual-modules",
3
+ "version": "1.0.0-beta.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ },
10
+ "./*": {
11
+ "types": "./dist/*.d.ts",
12
+ "import": "./dist/*.js"
13
+ }
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "build": "[ -d dist ] || rm -f tsconfig.tsbuildinfo; tsc",
20
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
21
+ "test": "vitest run --passWithNoTests",
22
+ "test:coverage": "vitest run --coverage"
23
+ },
24
+ "devDependencies": {
25
+ "@manuth/typescript-languageservice-tester": "^5.0.2",
26
+ "@types/node": "^25.3.0",
27
+ "@vitest/coverage-v8": "^4.0.0",
28
+ "typescript": "catalog:",
29
+ "vitest": "catalog:"
30
+ },
31
+ "peerDependencies": {
32
+ "typescript": "catalog:"
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "src"
37
+ ]
38
+ }