@supacloud/compiler 0.5.0 → 0.6.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.
@@ -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;
@@ -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,16 @@ 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
+ /** Generated services key; follows a custom useClass provider token when present. */
175
+ serviceKey: string;
176
+ scope: Scope;
177
+ aspects?: AspectRefNode[];
131
178
  }
132
179
  export interface QueryNode {
133
180
  className: string;
@@ -146,7 +193,10 @@ export interface ModuleNode {
146
193
  providers: ProviderNode[];
147
194
  controllers: ControllerNode[];
148
195
  commands: CommandNode[];
196
+ jobs?: JobNode[];
149
197
  queries: QueryNode[];
198
+ /** Explicit aspects applied to all routes and commands in this module. */
199
+ aspects?: AspectRefNode[];
150
200
  /** Exported token names. */
151
201
  exports: string[];
152
202
  }
@@ -202,6 +252,21 @@ export interface CompileOptions {
202
252
  treeShakeUnusedProviders?: boolean;
203
253
  /** Incremental dependency graph cache. */
204
254
  cache?: DependencyGraphCache;
255
+ /**
256
+ * Changed source paths supplied by the watch/incremental driver.
257
+ * This is an implementation hint and does not change the public graph shape.
258
+ */
259
+ changedPaths?: string[];
260
+ /** Type-safety gates for generated artifacts and production source. */
261
+ typeSafety?: TypeSafetyOptions;
262
+ }
263
+ export interface TypeSafetyOptions {
264
+ /** Reject the `any` keyword in generated TypeScript artifacts. */
265
+ noAnyInGenerated?: boolean;
266
+ /** Scan non-test production source for unsafe type escapes and widening. */
267
+ scanProductionSource?: boolean;
268
+ /** Additional relative glob patterns excluded from the production-source scan. */
269
+ exclude?: string[];
205
270
  }
206
271
  export interface ModuleBoundaryRule {
207
272
  /** Source module tag pattern or tag (for example, 'type:ui', 'scope:case', or '*'). */
@@ -300,12 +365,17 @@ export interface DependencyGraphCache {
300
365
  modules: Map<string, CachedModuleEntry>;
301
366
  /** Global file hashes by relative file path. */
302
367
  fileHashes: Map<string, string>;
303
- /** Retained AST project for true incremental graph re-analysis. */
304
- project?: any;
368
+ /** Retained native TypeScript BuilderProgram session. */
369
+ programSession?: IncrementalProgramSession;
305
370
  /** Retained module dependency graph tracking imports and reverse dependents. */
306
- dependencyGraph?: any;
371
+ dependencyGraph?: DependencyGraphIndex;
372
+ /** Content hashes for generated artifacts, used by the incremental emitter. */
373
+ generatedHashes?: Map<string, string>;
307
374
  lastStats?: {
308
375
  reusedModules: string[];
309
376
  reanalyzedModules: string[];
310
377
  };
311
378
  }
379
+ export interface DependencyGraphIndex {
380
+ getAffectedModules(changedFiles: string[]): string[];
381
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/compiler",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
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 ts-morph",
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
- "ts-morph": "^28.0.0"
47
+ "@typescript/typescript6": "^6.0.2"
48
48
  },
49
49
  "devDependencies": {
50
50
  "@types/bun": "^1.4.0",