@supacloud/compiler 0.5.0 → 0.6.0
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/README.md +33 -3
- package/dist/analyze.d.ts +2 -2
- package/dist/cli.js +1859 -500
- package/dist/generate.d.ts +2 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.js +1851 -495
- package/dist/program.d.ts +30 -0
- package/dist/traits.d.ts +32 -0
- package/dist/type-safety.d.ts +9 -0
- package/dist/types.d.ts +71 -3
- package/package.json +3 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as ts from "@typescript/typescript6";
|
|
2
|
+
import { type TraitRecord } from "./traits";
|
|
3
|
+
export interface IncrementalProgramSession {
|
|
4
|
+
/** The current TypeScript program used as the semantic compilation boundary. */
|
|
5
|
+
getProgram(): ts.Program;
|
|
6
|
+
/** The current TypeScript type checker. */
|
|
7
|
+
getTypeChecker(): ts.TypeChecker;
|
|
8
|
+
/** Update the program while preserving TypeScript's incremental state. */
|
|
9
|
+
update(rootNames: string[], changedPaths?: string[]): ProgramUpdate;
|
|
10
|
+
/** Local Angular-style metadata records compiled from the current Program. */
|
|
11
|
+
getTraits(): readonly TraitRecord[];
|
|
12
|
+
/** TypeScript syntactic diagnostics for the current Program. */
|
|
13
|
+
getDiagnostics(): readonly ts.Diagnostic[];
|
|
14
|
+
/** Emit the current TypeScript program using the builder's incremental state. */
|
|
15
|
+
emit(): ts.EmitResult;
|
|
16
|
+
/** Drop the retained builder and source versions. */
|
|
17
|
+
reset(): void;
|
|
18
|
+
}
|
|
19
|
+
export interface ProgramUpdate {
|
|
20
|
+
changedFiles: string[];
|
|
21
|
+
reusedFiles: string[];
|
|
22
|
+
program: ts.Program;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Angular-style semantic boundary around TypeScript's incremental program.
|
|
26
|
+
*
|
|
27
|
+
* This deliberately owns only TypeScript program state. SupaCloud metadata
|
|
28
|
+
* handlers and ApplicationGraph linking remain separate layers.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createIncrementalProgramSession(projectRoot: string): IncrementalProgramSession;
|
package/dist/traits.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as ts from "@typescript/typescript6";
|
|
2
|
+
export type TraitKind = "module" | "injectable" | "controller" | "command" | "query" | "defineModule" | "injectionToken";
|
|
3
|
+
export interface TraitRecord {
|
|
4
|
+
kind: TraitKind;
|
|
5
|
+
name: string;
|
|
6
|
+
file: string;
|
|
7
|
+
start: number;
|
|
8
|
+
end: number;
|
|
9
|
+
fingerprint: string;
|
|
10
|
+
}
|
|
11
|
+
export interface TraitCompilation {
|
|
12
|
+
byFile: Map<string, TraitRecord[]>;
|
|
13
|
+
all: TraitRecord[];
|
|
14
|
+
}
|
|
15
|
+
export interface TraitHandler {
|
|
16
|
+
readonly kind: TraitKind;
|
|
17
|
+
detect(node: ts.Node): string | undefined;
|
|
18
|
+
}
|
|
19
|
+
export declare class TraitCompiler {
|
|
20
|
+
private readonly handlers;
|
|
21
|
+
constructor(handlers?: readonly TraitHandler[]);
|
|
22
|
+
/**
|
|
23
|
+
* Angular-style local metadata compiler.
|
|
24
|
+
*
|
|
25
|
+
* This pass is intentionally syntax-only. It discovers candidate declarations
|
|
26
|
+
* cheaply; handlers that need symbols or types run later against the Program's
|
|
27
|
+
* TypeChecker.
|
|
28
|
+
*/
|
|
29
|
+
compile(program: ts.Program, previous: TraitCompilation | undefined, changedFiles: Set<string>): TraitCompilation;
|
|
30
|
+
private compileSourceFile;
|
|
31
|
+
}
|
|
32
|
+
export declare function compileTraits(program: ts.Program, previous: TraitCompilation | undefined, changedFiles: Set<string>): TraitCompilation;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Diagnostic, TypeSafetyOptions } from "./types";
|
|
2
|
+
export interface TypeSafetyScanOptions extends TypeSafetyOptions {
|
|
3
|
+
rootDir: string;
|
|
4
|
+
include?: string[];
|
|
5
|
+
outDir?: string;
|
|
6
|
+
strict?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function scanGeneratedArtifacts(artifacts: Record<string, string | undefined>, strict?: boolean): Diagnostic[];
|
|
9
|
+
export declare function scanProductionSource(options: TypeSafetyScanOptions): Diagnostic[];
|
package/dist/types.d.ts
CHANGED
|
@@ -2,9 +2,34 @@
|
|
|
2
2
|
* ApplicationGraph: Static application graph built by the compiler from source AST.
|
|
3
3
|
* No runtime reflection or container; all metadata is explicitly represented here and in generated code.
|
|
4
4
|
*/
|
|
5
|
+
import type { IncrementalProgramSession } from "./program";
|
|
5
6
|
export type Scope = "application" | "request" | "job";
|
|
6
7
|
export type ProviderKind = "class" | "value" | "factory" | "existing";
|
|
7
8
|
export type TokenKind = "injection-token" | "class";
|
|
9
|
+
export interface FunctionalInjectNode {
|
|
10
|
+
/** Logical token name used by the application graph. */
|
|
11
|
+
token: string;
|
|
12
|
+
/** Source expression used to identify the runtime token. */
|
|
13
|
+
expression: string;
|
|
14
|
+
/** Relative source module path for the token expression. */
|
|
15
|
+
importPath?: string;
|
|
16
|
+
/** Package module specifier for a library token. */
|
|
17
|
+
importModule?: string;
|
|
18
|
+
optional?: boolean;
|
|
19
|
+
self?: boolean;
|
|
20
|
+
skipSelf?: boolean;
|
|
21
|
+
host?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface AspectRefNode {
|
|
24
|
+
/** Exported symbol name used in the generated static import. */
|
|
25
|
+
name: string;
|
|
26
|
+
/** Source expression retained for diagnostics and manifest inspection. */
|
|
27
|
+
expression: string;
|
|
28
|
+
/** Relative source module path for a project-local aspect. */
|
|
29
|
+
importPath?: string;
|
|
30
|
+
/** Package module specifier for a library aspect. */
|
|
31
|
+
importModule?: string;
|
|
32
|
+
}
|
|
8
33
|
export interface Diagnostic {
|
|
9
34
|
severity: "error" | "warn";
|
|
10
35
|
code: string;
|
|
@@ -38,6 +63,8 @@ export interface ProviderNode {
|
|
|
38
63
|
skipSelfDeps?: string[];
|
|
39
64
|
/** Parameter tokens marked @Host(). */
|
|
40
65
|
hostDeps?: string[];
|
|
66
|
+
/** Property-level Angular functional inject() calls compiled into a static context. */
|
|
67
|
+
functionalInjects?: FunctionalInjectNode[];
|
|
41
68
|
/** When true, multiple providers can contribute to this token as an array of instances (Angular multi-providers). */
|
|
42
69
|
multi?: boolean;
|
|
43
70
|
/** Automatically provided in the root injector context without manual module declaration (Angular-style). */
|
|
@@ -49,6 +76,8 @@ export interface ProviderNode {
|
|
|
49
76
|
line: number;
|
|
50
77
|
/** Relative module path of useClass/useFactory/useValue symbol (for import generation). */
|
|
51
78
|
importPath?: string;
|
|
79
|
+
/** Package module specifier for providers supplied by a library. */
|
|
80
|
+
importModule?: string;
|
|
52
81
|
}
|
|
53
82
|
export interface HandlerParamNode {
|
|
54
83
|
name: string;
|
|
@@ -101,16 +130,24 @@ export interface RouteNode {
|
|
|
101
130
|
data?: Record<string, unknown>;
|
|
102
131
|
/** Detailed method parameter metadata for compile-time typed invoker generation. */
|
|
103
132
|
handlerParams?: HandlerParamNode[];
|
|
133
|
+
/** Explicit aspects applied around this route. */
|
|
134
|
+
aspects?: AspectRefNode[];
|
|
104
135
|
}
|
|
105
136
|
export interface ControllerNode {
|
|
106
137
|
className: string;
|
|
107
138
|
path: string;
|
|
108
139
|
scope: Scope;
|
|
109
140
|
deps: string[];
|
|
141
|
+
/** Class implements OnDestroy interface or onDestroy method. */
|
|
142
|
+
hasOnDestroy?: boolean;
|
|
110
143
|
/** Parameter tokens marked @Optional(). */
|
|
111
144
|
optionalDeps?: string[];
|
|
112
145
|
selfDeps?: string[];
|
|
113
146
|
skipSelfDeps?: string[];
|
|
147
|
+
/** Parameter tokens marked @Host(). */
|
|
148
|
+
hostDeps?: string[];
|
|
149
|
+
/** Property-level Angular functional inject() calls compiled into a static context. */
|
|
150
|
+
functionalInjects?: FunctionalInjectNode[];
|
|
114
151
|
/** Automatically registered without manual module declaration (Angular standalone controller style). */
|
|
115
152
|
standalone?: boolean;
|
|
116
153
|
routes: RouteNode[];
|
|
@@ -128,6 +165,14 @@ export interface CommandNode {
|
|
|
128
165
|
idempotency: "required" | "none";
|
|
129
166
|
/** Automatically registered without manual module declaration. */
|
|
130
167
|
standalone?: boolean;
|
|
168
|
+
/** Explicit aspects applied around this command. */
|
|
169
|
+
aspects?: AspectRefNode[];
|
|
170
|
+
}
|
|
171
|
+
export interface JobNode {
|
|
172
|
+
className: string;
|
|
173
|
+
name: string;
|
|
174
|
+
scope: Scope;
|
|
175
|
+
aspects?: AspectRefNode[];
|
|
131
176
|
}
|
|
132
177
|
export interface QueryNode {
|
|
133
178
|
className: string;
|
|
@@ -146,7 +191,10 @@ export interface ModuleNode {
|
|
|
146
191
|
providers: ProviderNode[];
|
|
147
192
|
controllers: ControllerNode[];
|
|
148
193
|
commands: CommandNode[];
|
|
194
|
+
jobs?: JobNode[];
|
|
149
195
|
queries: QueryNode[];
|
|
196
|
+
/** Explicit aspects applied to all routes and commands in this module. */
|
|
197
|
+
aspects?: AspectRefNode[];
|
|
150
198
|
/** Exported token names. */
|
|
151
199
|
exports: string[];
|
|
152
200
|
}
|
|
@@ -202,6 +250,21 @@ export interface CompileOptions {
|
|
|
202
250
|
treeShakeUnusedProviders?: boolean;
|
|
203
251
|
/** Incremental dependency graph cache. */
|
|
204
252
|
cache?: DependencyGraphCache;
|
|
253
|
+
/**
|
|
254
|
+
* Changed source paths supplied by the watch/incremental driver.
|
|
255
|
+
* This is an implementation hint and does not change the public graph shape.
|
|
256
|
+
*/
|
|
257
|
+
changedPaths?: string[];
|
|
258
|
+
/** Type-safety gates for generated artifacts and production source. */
|
|
259
|
+
typeSafety?: TypeSafetyOptions;
|
|
260
|
+
}
|
|
261
|
+
export interface TypeSafetyOptions {
|
|
262
|
+
/** Reject the `any` keyword in generated TypeScript artifacts. */
|
|
263
|
+
noAnyInGenerated?: boolean;
|
|
264
|
+
/** Scan non-test production source for unsafe type escapes and widening. */
|
|
265
|
+
scanProductionSource?: boolean;
|
|
266
|
+
/** Additional relative glob patterns excluded from the production-source scan. */
|
|
267
|
+
exclude?: string[];
|
|
205
268
|
}
|
|
206
269
|
export interface ModuleBoundaryRule {
|
|
207
270
|
/** Source module tag pattern or tag (for example, 'type:ui', 'scope:case', or '*'). */
|
|
@@ -300,12 +363,17 @@ export interface DependencyGraphCache {
|
|
|
300
363
|
modules: Map<string, CachedModuleEntry>;
|
|
301
364
|
/** Global file hashes by relative file path. */
|
|
302
365
|
fileHashes: Map<string, string>;
|
|
303
|
-
/** Retained
|
|
304
|
-
|
|
366
|
+
/** Retained native TypeScript BuilderProgram session. */
|
|
367
|
+
programSession?: IncrementalProgramSession;
|
|
305
368
|
/** Retained module dependency graph tracking imports and reverse dependents. */
|
|
306
|
-
dependencyGraph?:
|
|
369
|
+
dependencyGraph?: DependencyGraphIndex;
|
|
370
|
+
/** Content hashes for generated artifacts, used by the incremental emitter. */
|
|
371
|
+
generatedHashes?: Map<string, string>;
|
|
307
372
|
lastStats?: {
|
|
308
373
|
reusedModules: string[];
|
|
309
374
|
reanalyzedModules: string[];
|
|
310
375
|
};
|
|
311
376
|
}
|
|
377
|
+
export interface DependencyGraphIndex {
|
|
378
|
+
getAffectedModules(changedFiles: string[]): string[];
|
|
379
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supacloud/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Static compiler for @supacloud/app metadata: builds the application graph from AST, validates it, and generates reflection-free factory code",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "bun run clean && bun run build:js && bun run build:types",
|
|
25
|
-
"build:js": "bun build src/index.ts src/cli.ts --outdir dist --target node --external
|
|
25
|
+
"build:js": "bun build src/index.ts src/cli.ts --outdir dist --target node --external @typescript/typescript6",
|
|
26
26
|
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
|
|
27
27
|
"clean": "rm -rf dist",
|
|
28
28
|
"prepublishOnly": "bun run build",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"directory": "packages/compiler"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"
|
|
47
|
+
"@typescript/typescript6": "^6.0.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/bun": "^1.4.0",
|