@decohere/forge 0.0.1-dev.112 → 0.0.1-dev.114

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 (58) hide show
  1. package/README.md +2 -0
  2. package/commonjs/src/actions/index.js +1 -0
  3. package/commonjs/src/actions/paths.action.js +109 -0
  4. package/commonjs/src/commands/index.js +1 -0
  5. package/commonjs/src/commands/paths.command.js +24 -0
  6. package/commonjs/src/extensions/project.extensions.js +1 -1
  7. package/commonjs/src/factories/swc-config.factory.js +10 -1
  8. package/commonjs/src/forge.module.js +2 -0
  9. package/commonjs/src/index.js +4 -0
  10. package/commonjs/src/packaging/release-exports.js +4 -2
  11. package/commonjs/src/services/file-writer.service.js +0 -7
  12. package/commonjs/src/services/incremental-watch.js +24 -0
  13. package/commonjs/src/services/output-cache.js +39 -0
  14. package/commonjs/src/services/swc-transpiler.js +40 -119
  15. package/commonjs/src/services/transpile-cache.js +44 -0
  16. package/commonjs/src/services/type-emitter.js +13 -6
  17. package/commonjs/src/types/transform-response.model.js +3 -16
  18. package/commonjs/src/vitest/forge-build.plugin.js +4 -10
  19. package/es6/src/actions/index.js +1 -0
  20. package/es6/src/actions/paths.action.js +86 -0
  21. package/es6/src/commands/index.js +1 -0
  22. package/es6/src/commands/paths.command.js +14 -0
  23. package/es6/src/extensions/project.extensions.js +1 -1
  24. package/es6/src/factories/swc-config.factory.js +10 -1
  25. package/es6/src/forge.module.js +2 -0
  26. package/es6/src/index.js +1 -0
  27. package/es6/src/packaging/release-exports.js +4 -2
  28. package/es6/src/services/file-writer.service.js +0 -7
  29. package/es6/src/services/incremental-watch.js +18 -0
  30. package/es6/src/services/output-cache.js +29 -0
  31. package/es6/src/services/swc-transpiler.js +40 -119
  32. package/es6/src/services/transpile-cache.js +29 -0
  33. package/es6/src/services/type-emitter.js +13 -6
  34. package/es6/src/types/transform-response.model.js +0 -5
  35. package/es6/src/vitest/forge-build.plugin.js +5 -11
  36. package/package.json +5 -5
  37. package/types/src/actions/index.d.ts +1 -0
  38. package/types/src/actions/paths.action.d.ts +28 -0
  39. package/types/src/commands/index.d.ts +1 -0
  40. package/types/src/commands/paths.command.d.ts +6 -0
  41. package/types/src/factories/swc-config.factory.d.ts +1 -1
  42. package/types/src/forge.module.d.ts +2 -0
  43. package/types/src/index.d.ts +1 -0
  44. package/types/src/packaging/release-exports.d.ts +2 -2
  45. package/types/src/services/file-writer.service.d.ts +0 -1
  46. package/types/src/services/incremental-watch.d.ts +13 -0
  47. package/types/src/services/output-cache.d.ts +10 -0
  48. package/types/src/services/swc-transpiler.d.ts +12 -24
  49. package/types/src/services/transpile-cache.d.ts +17 -0
  50. package/types/src/services/type-emitter.d.ts +6 -7
  51. package/types/src/types/transform-response.model.d.ts +0 -5
  52. package/types/src/types/transformer.type.d.ts +0 -9
  53. package/commonjs/src/mixins/caches-outputs.mixin.js +0 -42
  54. package/commonjs/src/mixins/incremental-transform.mixin.js +0 -34
  55. package/es6/src/mixins/caches-outputs.mixin.js +0 -32
  56. package/es6/src/mixins/incremental-transform.mixin.js +0 -24
  57. package/types/src/mixins/caches-outputs.mixin.d.ts +0 -7
  58. package/types/src/mixins/incremental-transform.mixin.d.ts +0 -13
@@ -9,11 +9,10 @@ function _ts_metadata(k, v) {
9
9
  }
10
10
  import { invalidateCache } from "@decohere/nexus/caching";
11
11
  import { Trace } from "@decohere/nexus/diagnostics";
12
- import { mixwith } from "@decohere/nexus/extensibility";
13
12
  import { io } from "@decohere/nexus/io";
14
13
  import "../extensions/project.extensions.js";
15
- import { CachesOutputs } from "../mixins/caches-outputs.mixin.js";
16
- import { IncrementalTransform } from "../mixins/incremental-transform.mixin.js";
14
+ import { IncrementalWatch } from "./incremental-watch.js";
15
+ import { OutputCache } from "./output-cache.js";
17
16
  import { TsProgramHost } from "./ts-program-host.js";
18
17
  import { TypeEmissionProgram } from "./type-emission-program.js";
19
18
  import { BuildTargets } from "../types/build-target.type.js";
@@ -45,12 +44,20 @@ import { BuildTargets } from "../types/build-target.type.js";
45
44
  /** Compiler options enforced for `forge typecheck` — never emit JS or declarations. */ export const REQUIRED_TYPE_CHECK_OPTIONS = {
46
45
  noEmit: true
47
46
  };
48
- export class TypeEmitter extends mixwith(CachesOutputs, IncrementalTransform) {
47
+ export class TypeEmitter {
49
48
  buildTargets = [
50
49
  BuildTargets.types
51
50
  ];
52
51
  /** Prepared programs from init(), consumed once by the next transformProject() call. */ #programs;
53
52
  #host = new TsProgramHost();
53
+ #outputs = new OutputCache();
54
+ #incremental = new IncrementalWatch();
55
+ get incrementalTransform$() {
56
+ return this.#incremental.results$;
57
+ }
58
+ watch(workspace) {
59
+ this.#incremental.watch(workspace, (evt)=>this.onIncrementalFileEvent(evt));
60
+ }
54
61
  /**
55
62
  * Phase 1: fetch files, create TypeScript programs sequentially.
56
63
  * Called before transformProject() so that the heavy createProgram work
@@ -69,7 +76,7 @@ export class TypeEmitter extends mixwith(CachesOutputs, IncrementalTransform) {
69
76
  return [];
70
77
  }
71
78
  const responses = (await Promise.all(programs.map((program)=>program.emit(filter, onOutput)))).flat();
72
- this.cacheOutputs(responses);
79
+ this.#outputs.record(responses);
73
80
  return responses;
74
81
  }
75
82
  /**
@@ -123,7 +130,7 @@ export class TypeEmitter extends mixwith(CachesOutputs, IncrementalTransform) {
123
130
  async onIncrementalFileEvent(evt) {
124
131
  const { file, project } = evt;
125
132
  if (evt.eventName === io.WatchEvents.unlink) {
126
- this.deleteCachedOutputs(file.fullPath);
133
+ this.#outputs.delete(file.fullPath);
127
134
  return [];
128
135
  }
129
136
  if (!project.isSourceFile(file)) {
@@ -1,8 +1,3 @@
1
- export const TransformOutcomes = {
2
- success: "success",
3
- failure: "failure",
4
- skipped: "skipped"
5
- };
6
1
  export class TransformResponse {
7
2
  static Success(data) {
8
3
  return new TransformResponse({
@@ -1,6 +1,6 @@
1
1
  import { existsSync } from "node:fs";
2
2
  import path from "node:path";
3
- import { WorkspaceFactory } from "@decohere/mesh";
3
+ import { sourceExtensions, WorkspaceFactory } from "@decohere/mesh";
4
4
  import { FileEx } from "@decohere/nexus/io";
5
5
  import { ConsoleAdapter, scribe } from "@decohere/scribe";
6
6
  import { SwcTranspiler } from "../services/swc-transpiler.js";
@@ -9,11 +9,6 @@ import { WorkspaceDefaults } from "../workspace.config.js";
9
9
  // Above fatal (60) so all standard levels are nooped when logLevel is "silent"
10
10
  const SILENT_LEVEL = 999;
11
11
  const PLUGIN_NAME = "forge-vitest-source";
12
- const TS_EXTENSIONS = [
13
- ".ts",
14
- ".tsx",
15
- ".mts"
16
- ];
17
12
  export function forgeBuild(options) {
18
13
  const buildConfig = options?.buildConfig ?? "debug";
19
14
  const workspaceRoot = options?.workspaceRoot ?? process.cwd();
@@ -62,11 +57,10 @@ export function forgeBuild(options) {
62
57
  logger.debug("Plugin loaded");
63
58
  },
64
59
  resolveId (source, importer) {
65
- if (importer != null && source.endsWith(".js") && source.startsWith(".")) {
66
- const importerDirectory = path.dirname(importer);
67
- const withoutExtension = source.slice(0, -3);
68
- const candidates = TS_EXTENSIONS.map((ext)=>path.resolve(importerDirectory, `${withoutExtension}${ext}`));
69
- return candidates.find((c)=>existsSync(c)) ?? null;
60
+ // `./a.js` is `a.ts` or `a.tsx`, `./a.mjs` is `a.mts`, `./a.cjs` is `a.cts` (#518).
61
+ if (importer != null && /\.[mc]?jsx?$/.test(source) && source.startsWith(".")) {
62
+ const written = path.resolve(path.dirname(importer), source);
63
+ return sourceExtensions.candidates(written).find((c)=>existsSync(c)) ?? null;
70
64
  }
71
65
  return null;
72
66
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/forge",
3
- "version": "0.0.1-dev.112",
3
+ "version": "0.0.1-dev.114",
4
4
  "description": "TypeScript monorepo build system — zero config, fast compilation, streamlined developer workflow",
5
5
  "keywords": [
6
6
  "typescript",
@@ -29,10 +29,10 @@
29
29
  "test": "echo \"Error: no test specified\" && exit 1"
30
30
  },
31
31
  "dependencies": {
32
- "@decohere/crucible": "0.0.1-dev.112",
33
- "@decohere/mesh": "0.0.1-dev.112",
34
- "@decohere/nexus": "0.0.1-dev.112",
35
- "@decohere/scribe": "0.0.1-dev.112",
32
+ "@decohere/crucible": "0.0.1-dev.114",
33
+ "@decohere/mesh": "0.0.1-dev.114",
34
+ "@decohere/nexus": "0.0.1-dev.114",
35
+ "@decohere/scribe": "0.0.1-dev.114",
36
36
  "@swc/core": "^1.11.11",
37
37
  "async": "^3.2.6",
38
38
  "parse-imports": "^2.2.1",
@@ -7,6 +7,7 @@ export * from "./dependency-sync.action.js";
7
7
  export * from "./docker.action.js";
8
8
  export * from "./link.action.js";
9
9
  export * from "./package.action.js";
10
+ export * from "./paths.action.js";
10
11
  export * from "./publish.action.js";
11
12
  export * from "./sync-lock-file.action.js";
12
13
  export * from "./tag.action.js";
@@ -0,0 +1,28 @@
1
+ import { Workspace } from "@decohere/mesh";
2
+ import type { Action } from "@decohere/nexus/cli";
3
+ import { ActionResponse } from "@decohere/nexus/cli";
4
+ export declare const PATHS_FILE = "tsconfig.paths.json";
5
+ export type PathsOptions = {
6
+ /** Fail if the file is missing or out of date, instead of writing it. */
7
+ check?: boolean;
8
+ };
9
+ export type PathsResponse = {
10
+ file: string;
11
+ changed: boolean;
12
+ succeeded: boolean;
13
+ error?: string;
14
+ };
15
+ /**
16
+ * Writes `tsconfig.paths.json`: tsconfig `paths` for every workspace package and the subpaths it
17
+ * exports, from Mesh's aliases (#518). Without `node_modules` links, `tsc` finds workspace
18
+ * packages only through `paths`; generating them keeps them in step with what Flux, the Vitest
19
+ * plugin and builds resolve. The root tsconfig extends the file.
20
+ */
21
+ export declare class Paths implements Action<PathsOptions> {
22
+ #private;
23
+ private readonly workspace;
24
+ constructor(workspace: Workspace);
25
+ run(options: PathsOptions): Promise<ActionResponse<PathsResponse>>;
26
+ /** The file's content: convention and exported subpaths only, never the tsconfig's own paths. */
27
+ static render(workspace: Workspace): string;
28
+ }
@@ -4,6 +4,7 @@ export * from "./docker.command.js";
4
4
  export * from "./forge.command.js";
5
5
  export * from "./link.command.js";
6
6
  export * from "./package.command.js";
7
+ export * from "./paths.command.js";
7
8
  export * from "./publish.command.js";
8
9
  export * from "./tag.command.js";
9
10
  export * from "./typecheck.command.js";
@@ -0,0 +1,6 @@
1
+ import { DecohereCommand } from "@decohere/nexus/cli";
2
+ import { Paths } from "../actions/paths.action.js";
3
+ export declare class PathsCommand extends DecohereCommand {
4
+ get actions(): (typeof Paths)[];
5
+ constructor(name: string);
6
+ }
@@ -8,7 +8,7 @@ export declare class SwcConfigFactory {
8
8
  * Call once per (project, target) and then use createFileConfig() per file.
9
9
  */
10
10
  createBaseConfig(buildTarget: TranspileTarget, configOptions: SwcConfigOptions): Options;
11
- /** Stamps a per-file filename onto a pre-built base config. */
11
+ /** Stamps a per-file filename onto a pre-built base config; `.tsx` also turns on JSX (#518). */
12
12
  createFileConfig(file: FileEx, baseConfig: Options): Options;
13
13
  private static nonemptyPaths;
14
14
  /**
@@ -19,6 +19,7 @@ export declare class ForgeModule extends ModuleManifest {
19
19
  reportDependencies: typeof Actions.ReportDependencies;
20
20
  version: typeof Actions.Version;
21
21
  tag: typeof Actions.Tag;
22
+ paths: typeof Actions.Paths;
22
23
  typecheck: typeof Actions.TypeCheck;
23
24
  commitFiles: typeof Actions.CommitFiles;
24
25
  link: typeof Actions.Link;
@@ -32,6 +33,7 @@ export declare class ForgeModule extends ModuleManifest {
32
33
  package: typeof Commands.PackageCommand;
33
34
  version: typeof Commands.VersionCommand;
34
35
  tag: typeof Commands.TagCommand;
36
+ paths: typeof Commands.PathsCommand;
35
37
  typecheck: typeof Commands.TypeCheckCommand;
36
38
  link: typeof Commands.LinkCommand;
37
39
  unlink: typeof Commands.UnlinkCommand;
@@ -3,6 +3,7 @@ export { ForgeError } from "./errors.js";
3
3
  export { ForgeModule } from "./forge.module.js";
4
4
  export type { TranspileOptions } from "./services/swc-transpiler.js";
5
5
  export { SwcTranspiler } from "./services/swc-transpiler.js";
6
+ export { transpileCache } from "./services/transpile-cache.js";
6
7
  export type { BuildTarget, TranspileTarget } from "./types/build-target.type.js";
7
8
  export { BuildTargets } from "./types/build-target.type.js";
8
9
  export type { ForgeConfiguration } from "./types/configuration.type.js";
@@ -1,7 +1,7 @@
1
- import type { PackageJson } from "@decohere/mesh";
1
+ import { type PackageJson } from "@decohere/mesh";
2
2
  /** Release `exports`: subpath (`.`, `./testing`) to a file path inside the release output. */
3
3
  export type ReleaseExports = Record<string, string>;
4
- /** `src/main.ts` becomes `src/main.js`, with any leading `./` dropped. */
4
+ /** `src/main.ts` becomes `src/main.js` (`.mts` `.mjs`, `.cts` `.cjs`), with any leading `./` dropped. */
5
5
  declare function toJs(filePath: string): string;
6
6
  /**
7
7
  * The `exports` a library needs once only its `es6/` output is shipped: the library's own
@@ -3,7 +3,6 @@ import "../extensions/project.extensions.js";
3
3
  import type { TransformResponse } from "../types/transform-response.model.js";
4
4
  export declare class FileWriterService {
5
5
  #private;
6
- initialize(): Promise<void>;
7
6
  warmup(projects: Project[]): Promise<void>;
8
7
  enqueueOutput(response: TransformResponse): void;
9
8
  enqueueOutputs(responses: TransformResponse[]): void;
@@ -0,0 +1,13 @@
1
+ import type { ProjectFileEvent, Workspace } from "@decohere/mesh";
2
+ import type { Observable } from "rxjs";
3
+ import type { TransformResponse } from "../types/transform-response.model.js";
4
+ /**
5
+ * Runs a transformer's handler for every workspace file change and emits what it built. The
6
+ * handler invalidates the transformer's own caches, rebuilds, and returns the responses (empty
7
+ * for a deletion or when nothing was built).
8
+ */
9
+ export declare class IncrementalWatch {
10
+ #private;
11
+ get results$(): Observable<TransformResponse[]>;
12
+ watch(workspace: Workspace, handler: (evt: ProjectFileEvent) => Promise<TransformResponse[]>): void;
13
+ }
@@ -0,0 +1,10 @@
1
+ import type { TransformResponse } from "../types/transform-response.model.js";
2
+ /** The outputs each source file last built to, so watch mode can delete them when it goes. */
3
+ export declare class OutputCache {
4
+ #private;
5
+ get(sourcePath: string): TransformResponse[] | undefined;
6
+ /** Records the successful outputs, replacing what each of their source files had before. */
7
+ record(responses: TransformResponse[]): void;
8
+ /** Deletes the files a source built to and forgets them. */
9
+ delete(sourcePath: string): void;
10
+ }
@@ -1,10 +1,9 @@
1
- import type { Project, ProjectFileEvent, Tsconfig, Workspace } from "@decohere/mesh";
1
+ import { type Project, type Tsconfig, type Workspace } from "@decohere/mesh";
2
2
  import type { FileEx } from "@decohere/nexus/io";
3
3
  import { type Options } from "@swc/core";
4
+ import type { Observable } from "rxjs";
4
5
  import { type BuildTarget, type TranspileTarget } from "../types/build-target.type.js";
5
6
  import "../extensions/project.extensions.js";
6
- import { CachesOutputs } from "../mixins/caches-outputs.mixin.js";
7
- import { IncrementalTransform } from "../mixins/incremental-transform.mixin.js";
8
7
  import type { SwcConfig } from "../types/swc-config.type.js";
9
8
  import { TransformResponse } from "../types/transform-response.model.js";
10
9
  import type { Transformer } from "../types/transformer.type.js";
@@ -16,44 +15,33 @@ export type TranspileOptions = {
16
15
  workspace?: Workspace;
17
16
  projects?: readonly Project[];
18
17
  };
19
- declare const SwcTranspiler_base: abstract new (...args: unknown[]) => CachesOutputs & IncrementalTransform;
20
- export declare class SwcTranspiler extends SwcTranspiler_base implements Transformer {
18
+ export declare class SwcTranspiler implements Transformer {
21
19
  #private;
22
20
  buildTargets: BuildTarget[];
21
+ get incrementalTransform$(): Observable<TransformResponse[]>;
23
22
  watch(workspace: Workspace): void;
24
23
  private withAliasContext;
25
24
  transformProject(projectArrayLike: Project | Project[], fileFilter?: (project: Project) => Promise<FileEx[]>, onOutput?: (response: TransformResponse) => void): Promise<TransformResponse[]>;
26
- transformFile(fileArrayLike: FileEx[] | FileEx, buildTarget: TranspileTarget, options?: TranspileOptions): Promise<TransformResponse[]>;
27
25
  /**
28
26
  * The SWC options for one project and target, without a filename. Building them reads the
29
27
  * workspace's aliases and merges configs, so a caller that transpiles many files builds them
30
- * once and passes them to {@link transformFileSync}.
28
+ * once and passes them to {@link transformCode}.
31
29
  */
32
30
  createBaseConfig(buildTarget: TranspileTarget, options?: TranspileOptions): Options;
33
- /**
34
- * Synchronous, single-file variant of `transformFile`.
35
- * Reads the file with `fs.readFileSync` and transpiles via `swc.transformSync`.
36
- * Intended for callers that cannot await (e.g. Node.js `registerHooks` load hook).
37
- * Pass `baseConfig` from {@link createBaseConfig} to skip rebuilding it for every file.
38
- */
39
- transformFileSync(file: FileEx, buildTarget: TranspileTarget, options?: TranspileOptions, baseConfig?: Options): TransformResponse;
40
- /**
41
- * Async variant of {@link transformFileSync}, with the same result for the same file. SWC
42
- * runs it on libuv's thread pool, so many calls in flight compile in parallel (#661).
43
- */
44
- transformFileAsync(file: FileEx, buildTarget: TranspileTarget, options?: TranspileOptions, baseConfig?: Options): Promise<TransformResponse>;
31
+ /** Sync variant of {@link transformCode}, for the load hook, which cannot await (#514). */
32
+ transformCodeSync(content: string, file: FileEx, buildTarget: TranspileTarget, baseConfig: Options): TransformResponse;
45
33
  /**
46
34
  * Compiles `content` as the source of `file`, without reading the file: for callers that
47
35
  * already hold the code, such as the Vitest plugin, which must compile what Vite passes it
48
- * rather than an earlier read of the disk (#517). Async SWC, on the thread pool.
36
+ * rather than an earlier read of the disk (#517). Async SWC, on the thread pool, so many
37
+ * calls in flight compile in parallel (#661). With a `project`, the response carries where
38
+ * the build writes the output.
49
39
  */
50
- transformCode(content: string, file: FileEx, buildTarget: TranspileTarget, baseConfig: Options): Promise<TransformResponse>;
40
+ transformCode(content: string, file: FileEx, buildTarget: TranspileTarget, baseConfig: Options, project?: Project): Promise<TransformResponse>;
51
41
  private static skippedEmpty;
52
42
  private static succeeded;
53
43
  private transformTarget;
54
- private runTransform;
55
- protected onIncrementalFileEvent(evt: ProjectFileEvent): Promise<TransformResponse[]>;
44
+ private onIncrementalFileEvent;
56
45
  invalidateContentCache(_file: FileEx): void;
57
46
  private getFileContent;
58
47
  }
59
- export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Where compiled code is cached on disk (#514), or null when caching is off:
3
+ *
4
+ * - `DECOHERE_CACHE=0` turns it off.
5
+ * - `DECOHERE_CACHE_DIR` puts it in that directory.
6
+ * - Otherwise `<root>/node_modules/.cache/decohere`, where tools keep caches, or when the
7
+ * workspace has no `node_modules`, `$XDG_CACHE_HOME/decohere`, then the OS temp directory.
8
+ *
9
+ * Flux keeps its entries in the `flux` folder inside it; `forge clean` removes the folder.
10
+ */
11
+ declare function directory(rootDir: string, env?: NodeJS.ProcessEnv): string | null;
12
+ /** The SWC version compiling: part of every cache key, so upgrading SWC misses. */
13
+ export declare const transpileCache: {
14
+ directory: typeof directory;
15
+ swcVersion: string;
16
+ };
17
+ export {};
@@ -1,9 +1,8 @@
1
- import type { Project, ProjectFileEvent } from "@decohere/mesh";
1
+ import type { Project, Workspace } from "@decohere/mesh";
2
2
  import type { FileEx } from "@decohere/nexus/io";
3
+ import type { Observable } from "rxjs";
3
4
  import type ts from "typescript";
4
5
  import "../extensions/project.extensions.js";
5
- import { CachesOutputs } from "../mixins/caches-outputs.mixin.js";
6
- import { IncrementalTransform } from "../mixins/incremental-transform.mixin.js";
7
6
  import { type BuildTarget } from "../types/build-target.type.js";
8
7
  import type { TransformResponse } from "../types/transform-response.model.js";
9
8
  import type { Transformer } from "../types/transformer.type.js";
@@ -31,10 +30,11 @@ export type PrepareProgramsOptions = {
31
30
  includeAllProjects?: boolean;
32
31
  requiredCompilerOptions?: ts.CompilerOptions;
33
32
  };
34
- declare const TypeEmitter_base: abstract new (...args: unknown[]) => CachesOutputs & IncrementalTransform;
35
- export declare class TypeEmitter extends TypeEmitter_base implements Transformer {
33
+ export declare class TypeEmitter implements Transformer {
36
34
  #private;
37
35
  buildTargets: BuildTarget[];
36
+ get incrementalTransform$(): Observable<TransformResponse[]>;
37
+ watch(workspace: Workspace): void;
38
38
  /**
39
39
  * Phase 1: fetch files, create TypeScript programs sequentially.
40
40
  * Called before transformProject() so that the heavy createProgram work
@@ -51,7 +51,6 @@ export declare class TypeEmitter extends TypeEmitter_base implements Transformer
51
51
  formatted: string;
52
52
  }>;
53
53
  private preparePrograms;
54
- protected onIncrementalFileEvent(evt: ProjectFileEvent): Promise<TransformResponse[]>;
54
+ private onIncrementalFileEvent;
55
55
  private invalidateReadFileCache;
56
56
  }
57
- export {};
@@ -2,11 +2,6 @@ import type { Project } from "@decohere/mesh";
2
2
  import type { File } from "@decohere/nexus/io";
3
3
  import type { BuildTarget } from "./build-target.type.js";
4
4
  export type TransformOutcome = "success" | "failure" | "skipped";
5
- export declare const TransformOutcomes: {
6
- success: "success";
7
- failure: "failure";
8
- skipped: "skipped";
9
- };
10
5
  type TransformResponseBase = {
11
6
  file: File;
12
7
  config: unknown;
@@ -3,15 +3,6 @@ import type { FileEx } from "@decohere/nexus/io";
3
3
  import type { Observable } from "rxjs";
4
4
  import type { BuildTarget } from "../types/build-target.type.js";
5
5
  import type { TransformResponse } from "./transform-response.model.js";
6
- export type FileEvent = {
7
- type: "changed" | "added";
8
- file: FileEx;
9
- project?: Project;
10
- } | {
11
- type: "deleted";
12
- file: FileEx;
13
- project: Project;
14
- };
15
6
  export declare const TransformerKey: unique symbol;
16
7
  export interface Transformer {
17
8
  readonly buildTargets: BuildTarget[];
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "CachesOutputs", {
6
- enumerable: true,
7
- get: function() {
8
- return CachesOutputs;
9
- }
10
- });
11
- const _io = require("@decohere/nexus/io");
12
- class CachesOutputs {
13
- /** Maps source file fullPath -> output TransformResponses for cleanup in watch mode. */ get outputCache() {
14
- const self = this;
15
- if (self.__outputCache == null) {
16
- self.__outputCache = new Map();
17
- }
18
- return self.__outputCache;
19
- }
20
- cacheOutputs(responses) {
21
- const byFile = new Map();
22
- for (const response of responses){
23
- if (response.outcome !== "success") continue;
24
- const group = byFile.get(response.file.fullPath) ?? [];
25
- group.push(response);
26
- byFile.set(response.file.fullPath, group);
27
- }
28
- for (const [fullPath, group] of byFile){
29
- this.outputCache.set(fullPath, group);
30
- }
31
- }
32
- deleteCachedOutputs(filePath) {
33
- const outputs = this.outputCache.get(filePath);
34
- if (outputs == null) return;
35
- for (const response of outputs){
36
- if (response.outputPath != null) {
37
- void _io.io.deleteFile(response.outputPath);
38
- }
39
- }
40
- this.outputCache.delete(filePath);
41
- }
42
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "IncrementalTransform", {
6
- enumerable: true,
7
- get: function() {
8
- return IncrementalTransform;
9
- }
10
- });
11
- const _rxjs = require("rxjs");
12
- // WeakMap avoids the private-field-in-mixin problem: private class fields (#x)
13
- // are not accessible when methods are copied onto a different class prototype.
14
- const subjects = new WeakMap();
15
- function getSubject(instance) {
16
- let subject = subjects.get(instance);
17
- if (subject == null) {
18
- subject = new _rxjs.Subject();
19
- subjects.set(instance, subject);
20
- }
21
- return subject;
22
- }
23
- class IncrementalTransform {
24
- get incrementalTransform$() {
25
- return getSubject(this).asObservable();
26
- }
27
- watch(workspace) {
28
- workspace.projectFileChanged$.subscribe((evt)=>{
29
- void this.onIncrementalFileEvent(evt).then((responses)=>{
30
- getSubject(this).next(responses);
31
- });
32
- });
33
- }
34
- }
@@ -1,32 +0,0 @@
1
- import { io } from "@decohere/nexus/io";
2
- export class CachesOutputs {
3
- /** Maps source file fullPath -> output TransformResponses for cleanup in watch mode. */ get outputCache() {
4
- const self = this;
5
- if (self.__outputCache == null) {
6
- self.__outputCache = new Map();
7
- }
8
- return self.__outputCache;
9
- }
10
- cacheOutputs(responses) {
11
- const byFile = new Map();
12
- for (const response of responses){
13
- if (response.outcome !== "success") continue;
14
- const group = byFile.get(response.file.fullPath) ?? [];
15
- group.push(response);
16
- byFile.set(response.file.fullPath, group);
17
- }
18
- for (const [fullPath, group] of byFile){
19
- this.outputCache.set(fullPath, group);
20
- }
21
- }
22
- deleteCachedOutputs(filePath) {
23
- const outputs = this.outputCache.get(filePath);
24
- if (outputs == null) return;
25
- for (const response of outputs){
26
- if (response.outputPath != null) {
27
- void io.deleteFile(response.outputPath);
28
- }
29
- }
30
- this.outputCache.delete(filePath);
31
- }
32
- }
@@ -1,24 +0,0 @@
1
- import { Subject } from "rxjs";
2
- // WeakMap avoids the private-field-in-mixin problem: private class fields (#x)
3
- // are not accessible when methods are copied onto a different class prototype.
4
- const subjects = new WeakMap();
5
- function getSubject(instance) {
6
- let subject = subjects.get(instance);
7
- if (subject == null) {
8
- subject = new Subject();
9
- subjects.set(instance, subject);
10
- }
11
- return subject;
12
- }
13
- export class IncrementalTransform {
14
- get incrementalTransform$() {
15
- return getSubject(this).asObservable();
16
- }
17
- watch(workspace) {
18
- workspace.projectFileChanged$.subscribe((evt)=>{
19
- void this.onIncrementalFileEvent(evt).then((responses)=>{
20
- getSubject(this).next(responses);
21
- });
22
- });
23
- }
24
- }
@@ -1,7 +0,0 @@
1
- import type { TransformResponse } from "../types/transform-response.model.js";
2
- export declare abstract class CachesOutputs {
3
- /** Maps source file fullPath -> output TransformResponses for cleanup in watch mode. */
4
- protected get outputCache(): Map<string, TransformResponse[]>;
5
- protected cacheOutputs(responses: TransformResponse[]): void;
6
- protected deleteCachedOutputs(filePath: string): void;
7
- }
@@ -1,13 +0,0 @@
1
- import type { ProjectFileEvent, Workspace } from "@decohere/mesh";
2
- import type { Observable } from "rxjs";
3
- import type { TransformResponse } from "../types/transform-response.model.js";
4
- export declare abstract class IncrementalTransform {
5
- get incrementalTransform$(): Observable<TransformResponse[]>;
6
- watch(workspace: Workspace): void;
7
- /**
8
- * Called for every workspace file change. Implementations should invalidate
9
- * any internal caches, perform the incremental transform, and return the results.
10
- * Return an empty array for deletions or when no output is produced.
11
- */
12
- protected abstract onIncrementalFileEvent(evt: ProjectFileEvent): Promise<TransformResponse[]>;
13
- }