@decohere/flux 0.0.1-dev.109 → 0.0.1-dev.11
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/commonjs/src/flux.command.js +2 -2
- package/commonjs/src/flux.module.js +7 -8
- package/commonjs/src/hot-reload-server.js +215 -302
- package/commonjs/src/index.js +2 -34
- package/commonjs/src/serve.action.js +5 -76
- package/commonjs/src/serve.command.js +3 -31
- package/es6/src/flux.command.js +2 -2
- package/es6/src/flux.module.js +7 -8
- package/es6/src/hot-reload-server.js +172 -283
- package/es6/src/index.js +3 -5
- package/es6/src/serve.action.js +7 -71
- package/es6/src/serve.command.js +3 -31
- package/package.json +6 -7
- package/types/src/flux.module.d.ts +0 -2
- package/types/src/hot-reload-server.d.ts +22 -55
- package/types/src/index.d.ts +1 -8
- package/types/src/serve.action.d.ts +1 -11
- package/types/src/serve.command.d.ts +0 -5
- package/README.md +0 -247
- package/commonjs/bench/load.bench.js +0 -145
- package/commonjs/src/deferred-script-runner.js +0 -56
- package/commonjs/src/flux.js +0 -56
- package/commonjs/src/rewrite-serve-specifier.js +0 -59
- package/commonjs/src/run.action.js +0 -47
- package/commonjs/src/run.command.js +0 -65
- package/commonjs/src/slice-serve.js +0 -130
- package/commonjs/src/source-module-loader.js +0 -237
- package/es6/bench/load.bench.js +0 -136
- package/es6/src/deferred-script-runner.js +0 -46
- package/es6/src/flux.js +0 -41
- package/es6/src/rewrite-serve-specifier.js +0 -49
- package/es6/src/run.action.js +0 -37
- package/es6/src/run.command.js +0 -55
- package/es6/src/slice-serve.js +0 -105
- package/es6/src/source-module-loader.js +0 -181
- package/types/bench/load.bench.d.ts +0 -1
- package/types/src/deferred-script-runner.d.ts +0 -18
- package/types/src/flux.d.ts +0 -43
- package/types/src/rewrite-serve-specifier.d.ts +0 -14
- package/types/src/run.action.d.ts +0 -15
- package/types/src/run.command.d.ts +0 -11
- package/types/src/slice-serve.d.ts +0 -52
- package/types/src/source-module-loader.d.ts +0 -58
package/es6/src/slice-serve.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Directory-slice helpers for `flux serve <dir>…` — classify Mesh packages as
|
|
3
|
-
* Flux apps, Nixpacks-style script deferrals, or libraries to skip.
|
|
4
|
-
*/ /** Preferred package scripts for foreign toolchains (Nixpacks-style). */ export const DEFER_SCRIPT_CANDIDATES = [
|
|
5
|
-
"dev",
|
|
6
|
-
"serve"
|
|
7
|
-
];
|
|
8
|
-
/**
|
|
9
|
-
* Normalize a CLI slice token to a `projects/…` prefix without a trailing slash.
|
|
10
|
-
* `funding` and `projects/funding` both become `projects/funding`.
|
|
11
|
-
*/ export function normalizeSlicePrefix(slice) {
|
|
12
|
-
const trimmed = slice.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
13
|
-
if (trimmed === "" || trimmed === ".") {
|
|
14
|
-
throw new Error("Slice directory must be a non-empty path");
|
|
15
|
-
}
|
|
16
|
-
if (trimmed === "projects" || trimmed.startsWith("projects/")) {
|
|
17
|
-
return trimmed;
|
|
18
|
-
}
|
|
19
|
-
return `projects/${trimmed}`;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* True when `projectDirectory` belongs to the slice token.
|
|
23
|
-
*
|
|
24
|
-
* Matches:
|
|
25
|
-
* - nested: `projects/funding`, `projects/funding/api`
|
|
26
|
-
* - flat dotted package dirs: `projects/funding.web` for token `funding`
|
|
27
|
-
*
|
|
28
|
-
* Does not match siblings that only share a string prefix (`funding` vs `funding-fee.api`).
|
|
29
|
-
*/ export function isUnderSlice(projectDirectory, slicePrefix) {
|
|
30
|
-
const dir = projectDirectory.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
31
|
-
const prefix = slicePrefix.replaceAll("\\", "/").replace(/\/+$/, "");
|
|
32
|
-
if (dir === prefix || dir.startsWith(`${prefix}/`)) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
// Flat monorepo packages: projects/<module>.<role>
|
|
36
|
-
return dir.startsWith(`${prefix}.`);
|
|
37
|
-
}
|
|
38
|
-
export function projectsInSlice(projects, slice) {
|
|
39
|
-
const prefix = normalizeSlicePrefix(slice);
|
|
40
|
-
return projects.filter((p)=>isUnderSlice(p.projectDirectory, prefix));
|
|
41
|
-
}
|
|
42
|
-
/** Union of packages under any of the slice tokens (deduped by package name). */ export function projectsInSlices(projects, slices) {
|
|
43
|
-
const byName = new Map();
|
|
44
|
-
for (const slice of slices){
|
|
45
|
-
for (const project of projectsInSlice(projects, slice)){
|
|
46
|
-
byName.set(project.name, project);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return [
|
|
50
|
-
...byName.values()
|
|
51
|
-
];
|
|
52
|
-
}
|
|
53
|
-
/** Script invokes Flux (in-process serve stays on Flux, not deferred). */ export function isFluxOwnedScript(script) {
|
|
54
|
-
return /\bflux\b/i.test(script);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* First Nixpacks-style serve script that is not Flux-owned.
|
|
58
|
-
* Prefers `dev`, then `serve`.
|
|
59
|
-
*/ export function resolveDeferScript(scripts) {
|
|
60
|
-
for (const name of DEFER_SCRIPT_CANDIDATES){
|
|
61
|
-
const body = scripts[name];
|
|
62
|
-
if (body != null && body !== "" && !isFluxOwnedScript(body)) {
|
|
63
|
-
return name;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return undefined;
|
|
67
|
-
}
|
|
68
|
-
/** Convention: Flux Node apps use `main` ending in `main.ts` / `main.tsx`. */ export function isFluxAppMain(main) {
|
|
69
|
-
const normalized = main.replaceAll("\\", "/");
|
|
70
|
-
return /(^|\/)main\.tsx?$/.test(normalized);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Classify one package. Foreign serve scripts win over `main.ts` (Vite apps
|
|
74
|
-
* often have a main entry but must not be HMR-booted by Flux).
|
|
75
|
-
*/ export function classifySliceProject(project) {
|
|
76
|
-
if (resolveDeferScript(project.scripts) != null) {
|
|
77
|
-
return "defer";
|
|
78
|
-
}
|
|
79
|
-
if (isFluxAppMain(project.main)) {
|
|
80
|
-
return "flux";
|
|
81
|
-
}
|
|
82
|
-
return "skip";
|
|
83
|
-
}
|
|
84
|
-
export function classifySliceProjects(projects, slices) {
|
|
85
|
-
const tokens = typeof slices === "string" ? [
|
|
86
|
-
slices
|
|
87
|
-
] : [
|
|
88
|
-
...slices
|
|
89
|
-
];
|
|
90
|
-
const inSlice = projectsInSlices(projects, tokens);
|
|
91
|
-
const flux = [];
|
|
92
|
-
const defer = [];
|
|
93
|
-
const skip = [];
|
|
94
|
-
for (const project of inSlice){
|
|
95
|
-
const kind = classifySliceProject(project);
|
|
96
|
-
if (kind === "flux") flux.push(project);
|
|
97
|
-
else if (kind === "defer") defer.push(project);
|
|
98
|
-
else skip.push(project);
|
|
99
|
-
}
|
|
100
|
-
return {
|
|
101
|
-
flux,
|
|
102
|
-
defer,
|
|
103
|
-
skip
|
|
104
|
-
};
|
|
105
|
-
}
|
|
@@ -1,181 +0,0 @@
|
|
|
1
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
import { registerHooks } from "node:module";
|
|
8
|
-
import path from "node:path";
|
|
9
|
-
import { fileURLToPath } from "node:url";
|
|
10
|
-
import { injectable } from "@decohere/crucible/decorators";
|
|
11
|
-
import { BuildTargets, createWorkspace, SwcTranspiler } from "@decohere/forge";
|
|
12
|
-
import { packageAliases } from "@decohere/mesh";
|
|
13
|
-
import { FileEx, io } from "@decohere/nexus/io";
|
|
14
|
-
import { scribe } from "@decohere/scribe";
|
|
15
|
-
import { rewriteServeSpecifier } from "./rewrite-serve-specifier.js";
|
|
16
|
-
export class SourceModuleLoader {
|
|
17
|
-
logger = scribe.logger(SourceModuleLoader.name);
|
|
18
|
-
transpiler = new SwcTranspiler();
|
|
19
|
-
disposed = false;
|
|
20
|
-
hooksRegistered = false;
|
|
21
|
-
workspace;
|
|
22
|
-
buildConfig = "debug";
|
|
23
|
-
fileInfoMap = new Map();
|
|
24
|
-
transpileCache = new Map();
|
|
25
|
-
/** SWC options per project, built on first use and kept until the next `configure()`. */ swcConfigs = new Map();
|
|
26
|
-
aliasPaths = {};
|
|
27
|
-
aliasBaseUrl = path.resolve(".");
|
|
28
|
-
versionFileUrl = (fileUrl)=>fileUrl;
|
|
29
|
-
onResolved;
|
|
30
|
-
getWorkspace() {
|
|
31
|
-
return this.workspace;
|
|
32
|
-
}
|
|
33
|
-
getBuildConfig() {
|
|
34
|
-
return this.buildConfig;
|
|
35
|
-
}
|
|
36
|
-
hasSourceFile(absolutePath) {
|
|
37
|
-
return this.fileInfoMap.has(absolutePath);
|
|
38
|
-
}
|
|
39
|
-
sourceFilePaths() {
|
|
40
|
-
return this.fileInfoMap.keys();
|
|
41
|
-
}
|
|
42
|
-
setSourceFile(absolutePath, project) {
|
|
43
|
-
this.fileInfoMap.set(absolutePath, {
|
|
44
|
-
project
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
async configure(options) {
|
|
48
|
-
this.disposed = false;
|
|
49
|
-
this.transpileCache.clear();
|
|
50
|
-
this.swcConfigs.clear();
|
|
51
|
-
this.buildConfig = options.buildConfig;
|
|
52
|
-
this.workspace = options.workspace ?? await createWorkspace();
|
|
53
|
-
this.versionFileUrl = options.versionFileUrl ?? ((fileUrl)=>fileUrl);
|
|
54
|
-
this.onResolved = options.onResolved;
|
|
55
|
-
this.fileInfoMap = await this.buildFileInfoMap(this.buildConfig);
|
|
56
|
-
const aliases = this.workspace.getPackageAliases(this.buildConfig);
|
|
57
|
-
this.aliasBaseUrl = aliases.baseUrl;
|
|
58
|
-
this.aliasPaths = aliases.paths;
|
|
59
|
-
}
|
|
60
|
-
registerHooks() {
|
|
61
|
-
if (this.hooksRegistered) return;
|
|
62
|
-
this.hooksRegistered = true;
|
|
63
|
-
// Compiled code carries inline source maps; Node only applies them to stack traces when
|
|
64
|
-
// this is on. Without it, errors point at compiled line numbers (#506).
|
|
65
|
-
process.setSourceMapsEnabled(true);
|
|
66
|
-
registerHooks({
|
|
67
|
-
resolve: (specifier, context, next)=>{
|
|
68
|
-
if (this.disposed) return next(specifier, context);
|
|
69
|
-
const parentUrl = context.parentURL ?? "";
|
|
70
|
-
const rewritten = rewriteServeSpecifier({
|
|
71
|
-
specifier,
|
|
72
|
-
parentUrl,
|
|
73
|
-
isWatchedTs: (filePath)=>this.fileInfoMap.has(filePath),
|
|
74
|
-
resolveBare: (bare)=>packageAliases.resolvePath(bare, this.aliasPaths, this.aliasBaseUrl),
|
|
75
|
-
versionFileUrl: this.versionFileUrl
|
|
76
|
-
}) ?? specifier;
|
|
77
|
-
const result = next(rewritten, context);
|
|
78
|
-
this.onResolved?.(result, parentUrl);
|
|
79
|
-
return result;
|
|
80
|
-
},
|
|
81
|
-
load: (url, context, next)=>{
|
|
82
|
-
if (this.disposed) return next(url, context);
|
|
83
|
-
const result = this.loadTs(url);
|
|
84
|
-
if (result != null) {
|
|
85
|
-
return {
|
|
86
|
-
format: "module",
|
|
87
|
-
source: result.source,
|
|
88
|
-
shortCircuit: true
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return next(url, context);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
async importEntry(absolutePath) {
|
|
96
|
-
const url = this.versionFileUrl(io.pathToFileUrl(path.resolve(absolutePath)));
|
|
97
|
-
return import(url);
|
|
98
|
-
}
|
|
99
|
-
invalidateTranspile(...absolutePaths) {
|
|
100
|
-
for (const fullPath of absolutePaths){
|
|
101
|
-
this.transpileCache.delete(fullPath);
|
|
102
|
-
this.transpiler.invalidateContentCache(new FileEx({
|
|
103
|
-
fullPath
|
|
104
|
-
}));
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
dispose() {
|
|
108
|
-
this.disposed = true;
|
|
109
|
-
this.transpileCache.clear();
|
|
110
|
-
this.swcConfigs.clear();
|
|
111
|
-
this.fileInfoMap.clear();
|
|
112
|
-
this.workspace?.[Symbol.dispose]();
|
|
113
|
-
this.workspace = undefined;
|
|
114
|
-
}
|
|
115
|
-
async buildFileInfoMap(buildConfig) {
|
|
116
|
-
const projects = this.workspace?.getProjects(buildConfig) ?? [];
|
|
117
|
-
const entries = await Promise.all(projects.map(async (project)=>{
|
|
118
|
-
const files = await project.getAllFiles();
|
|
119
|
-
return files.map((file)=>[
|
|
120
|
-
file.fullPath,
|
|
121
|
-
{
|
|
122
|
-
project
|
|
123
|
-
}
|
|
124
|
-
]);
|
|
125
|
-
}));
|
|
126
|
-
return new Map(entries.flat());
|
|
127
|
-
}
|
|
128
|
-
loadTs(url) {
|
|
129
|
-
if (!url.startsWith("file:")) return null;
|
|
130
|
-
// fileURLToPath, not URL.pathname: decodes %20 and gives Windows paths, so files
|
|
131
|
-
// whose path has a space still match Mesh's list (#511).
|
|
132
|
-
const cleanPath = fileURLToPath(url);
|
|
133
|
-
const fileInfo = this.fileInfoMap.get(cleanPath);
|
|
134
|
-
if (fileInfo == null) return null;
|
|
135
|
-
const cached = this.transpileCache.get(cleanPath);
|
|
136
|
-
if (cached != null) return {
|
|
137
|
-
source: cached
|
|
138
|
-
};
|
|
139
|
-
const file = new FileEx({
|
|
140
|
-
fullPath: cleanPath
|
|
141
|
-
});
|
|
142
|
-
const response = this.transpiler.transformFileSync(file, BuildTargets.es6, {}, this.swcConfigFor(fileInfo.project));
|
|
143
|
-
if (response.outcome !== "success") {
|
|
144
|
-
this.logger.error(`Failed to transpile ${cleanPath}`, response);
|
|
145
|
-
throw new Error(`Failed to transpile ${cleanPath}`);
|
|
146
|
-
}
|
|
147
|
-
this.transpileCache.set(cleanPath, response.code);
|
|
148
|
-
return {
|
|
149
|
-
source: response.code
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* The project's SWC options, built once: rebuilding them for every file was about a quarter
|
|
154
|
-
* of load time (#513). Import specifiers are left as written, without `jsc.paths` or
|
|
155
|
-
* `resolveFully`: the resolve hook maps them to source files (aliases, `.js` to `.ts`,
|
|
156
|
-
* directory indexes), so SWC does not resolve them a second time against the disk.
|
|
157
|
-
*/ swcConfigFor(project) {
|
|
158
|
-
const cached = this.swcConfigs.get(project);
|
|
159
|
-
if (cached != null) return cached;
|
|
160
|
-
const base = this.transpiler.createBaseConfig(BuildTargets.es6, {
|
|
161
|
-
tsConfig: project.getTsConfigSync(),
|
|
162
|
-
userConfig: project.getSwcConfigSync(),
|
|
163
|
-
aliasPaths: false,
|
|
164
|
-
workspace: this.workspace
|
|
165
|
-
});
|
|
166
|
-
// `module` is the ES module config (`type: "es6"` above); the spread loses the narrowing.
|
|
167
|
-
const module = {
|
|
168
|
-
...base.module,
|
|
169
|
-
resolveFully: false
|
|
170
|
-
};
|
|
171
|
-
const config = {
|
|
172
|
-
...base,
|
|
173
|
-
module
|
|
174
|
-
};
|
|
175
|
-
this.swcConfigs.set(project, config);
|
|
176
|
-
return config;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
SourceModuleLoader = _ts_decorate([
|
|
180
|
-
injectable()
|
|
181
|
-
], SourceModuleLoader);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type ChildProcess } from "node:child_process";
|
|
2
|
-
export type DeferredScriptStart = {
|
|
3
|
-
readonly label: string;
|
|
4
|
-
readonly cwd: string;
|
|
5
|
-
readonly script: string;
|
|
6
|
-
/** Workspace root used to detect pnpm/npm/yarn. */
|
|
7
|
-
readonly workspaceRoot: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Nixpacks-style child processes for foreign packages in a flux serve slice.
|
|
11
|
-
* Killed when the Flux container disposes (SIGINT → RootModule teardown).
|
|
12
|
-
*/
|
|
13
|
-
export declare class DeferredScriptRunner implements AsyncDisposable {
|
|
14
|
-
private readonly logger;
|
|
15
|
-
private readonly children;
|
|
16
|
-
start(options: DeferredScriptStart): ChildProcess;
|
|
17
|
-
[Symbol.asyncDispose](): Promise<void>;
|
|
18
|
-
}
|
package/types/src/flux.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Workspace } from "@decohere/mesh";
|
|
2
|
-
import { HotReloadServer } from "./hot-reload-server.js";
|
|
3
|
-
export type FluxRunOptions = {
|
|
4
|
-
/** Mesh/Forge configuration name. Defaults to `debug` (`--configuration`). */
|
|
5
|
-
configuration?: string;
|
|
6
|
-
/** Arguments forwarded to the entry (bin-style `process.argv.slice(2)`). */
|
|
7
|
-
args?: string[];
|
|
8
|
-
/**
|
|
9
|
-
* Pre-built Workspace instead of `WorkspaceFactory`.
|
|
10
|
-
* Useful in tests to skip filesystem discovery.
|
|
11
|
-
*/
|
|
12
|
-
workspace?: Workspace;
|
|
13
|
-
};
|
|
14
|
-
export type FluxServeOptions = {
|
|
15
|
-
/** Mesh/Forge configuration name. Defaults to `debug` (`--configuration`). */
|
|
16
|
-
configuration?: string;
|
|
17
|
-
/** Name of the project to serve. Defaults to the first project in the workspace. */
|
|
18
|
-
project?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Multiple Flux app package names to boot in one process (directory slice).
|
|
21
|
-
* When set, takes precedence over {@link project}.
|
|
22
|
-
*/
|
|
23
|
-
projects?: readonly string[];
|
|
24
|
-
/**
|
|
25
|
-
* Pre-built Workspace instead of `WorkspaceFactory`.
|
|
26
|
-
* Useful in tests to skip filesystem discovery.
|
|
27
|
-
*/
|
|
28
|
-
workspace?: Workspace;
|
|
29
|
-
/**
|
|
30
|
-
* Quiet window in milliseconds after the last affecting save before a reboot.
|
|
31
|
-
* Raise this for agent save trains.
|
|
32
|
-
*/
|
|
33
|
-
rebootDebounceMs?: number;
|
|
34
|
-
};
|
|
35
|
-
declare function run(entry: string, options?: FluxRunOptions): Promise<unknown>;
|
|
36
|
-
declare function serve(options?: FluxServeOptions): Promise<HotReloadServer>;
|
|
37
|
-
declare function dispose(): void;
|
|
38
|
-
export declare const flux: {
|
|
39
|
-
run: typeof run;
|
|
40
|
-
serve: typeof serve;
|
|
41
|
-
dispose: typeof dispose;
|
|
42
|
-
};
|
|
43
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type RewriteServeSpecifierOptions = {
|
|
2
|
-
specifier: string;
|
|
3
|
-
parentUrl: string;
|
|
4
|
-
isWatchedTs: (absolutePath: string) => boolean;
|
|
5
|
-
resolveBare: (specifier: string) => string | null;
|
|
6
|
-
versionFileUrl: (fileUrl: string) => string;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Map a resolve-hook specifier to a versioned watched `.ts` file URL.
|
|
10
|
-
* Covers relative `.js` / `.ts` / extensionless imports, directory imports (`./models` is
|
|
11
|
-
* `./models/index.ts`), and bare workspace package names and subpaths. Flux compiles without
|
|
12
|
-
* SWC's own path resolution, so this is the only place imports are mapped to sources (#513).
|
|
13
|
-
*/
|
|
14
|
-
export declare function rewriteServeSpecifier(options: RewriteServeSpecifierOptions): string | null;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Workspace } from "@decohere/mesh";
|
|
2
|
-
import { type Action, ActionResponse } from "@decohere/nexus/cli";
|
|
3
|
-
export type RunOptions = {
|
|
4
|
-
/** Absolute or cwd-relative path to a `.ts` entry file. */
|
|
5
|
-
entry: string;
|
|
6
|
-
configuration: string;
|
|
7
|
-
/** Arguments forwarded to the entry (bin-style `process.argv.slice(2)`). */
|
|
8
|
-
args?: string[];
|
|
9
|
-
};
|
|
10
|
-
export declare class RunAction implements Action<RunOptions> {
|
|
11
|
-
private readonly workspace;
|
|
12
|
-
private readonly logger;
|
|
13
|
-
constructor(workspace: Workspace);
|
|
14
|
-
run(options: RunOptions): Promise<ActionResponse>;
|
|
15
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { DecohereCommand } from "@decohere/nexus/cli";
|
|
2
|
-
import { RunAction } from "./run.action.js";
|
|
3
|
-
export declare class RunCommand extends DecohereCommand {
|
|
4
|
-
get actions(): (typeof RunAction)[];
|
|
5
|
-
constructor(name: string);
|
|
6
|
-
/**
|
|
7
|
-
* Commander passes positionals before options when `<entry> [args...]` is declared.
|
|
8
|
-
* The CLI host ModuleFactory expects `(opts, cmd)` — normalize and stash entry/args on opts.
|
|
9
|
-
*/
|
|
10
|
-
action(fn: (...args: any[]) => void | Promise<void>): this;
|
|
11
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Directory-slice helpers for `flux serve <dir>…` — classify Mesh packages as
|
|
3
|
-
* Flux apps, Nixpacks-style script deferrals, or libraries to skip.
|
|
4
|
-
*/
|
|
5
|
-
export type SliceProjectView = {
|
|
6
|
-
readonly name: string;
|
|
7
|
-
/** Relative project dir from workspace root (e.g. `projects/funding/api`). */
|
|
8
|
-
readonly projectDirectory: string;
|
|
9
|
-
readonly main: string;
|
|
10
|
-
readonly scripts: Record<string, string>;
|
|
11
|
-
};
|
|
12
|
-
export type SliceKind = "flux" | "defer" | "skip";
|
|
13
|
-
export type ClassifiedSlice = {
|
|
14
|
-
readonly flux: SliceProjectView[];
|
|
15
|
-
readonly defer: SliceProjectView[];
|
|
16
|
-
readonly skip: SliceProjectView[];
|
|
17
|
-
};
|
|
18
|
-
/** Preferred package scripts for foreign toolchains (Nixpacks-style). */
|
|
19
|
-
export declare const DEFER_SCRIPT_CANDIDATES: readonly ["dev", "serve"];
|
|
20
|
-
/**
|
|
21
|
-
* Normalize a CLI slice token to a `projects/…` prefix without a trailing slash.
|
|
22
|
-
* `funding` and `projects/funding` both become `projects/funding`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function normalizeSlicePrefix(slice: string): string;
|
|
25
|
-
/**
|
|
26
|
-
* True when `projectDirectory` belongs to the slice token.
|
|
27
|
-
*
|
|
28
|
-
* Matches:
|
|
29
|
-
* - nested: `projects/funding`, `projects/funding/api`
|
|
30
|
-
* - flat dotted package dirs: `projects/funding.web` for token `funding`
|
|
31
|
-
*
|
|
32
|
-
* Does not match siblings that only share a string prefix (`funding` vs `funding-fee.api`).
|
|
33
|
-
*/
|
|
34
|
-
export declare function isUnderSlice(projectDirectory: string, slicePrefix: string): boolean;
|
|
35
|
-
export declare function projectsInSlice(projects: readonly SliceProjectView[], slice: string): SliceProjectView[];
|
|
36
|
-
/** Union of packages under any of the slice tokens (deduped by package name). */
|
|
37
|
-
export declare function projectsInSlices(projects: readonly SliceProjectView[], slices: readonly string[]): SliceProjectView[];
|
|
38
|
-
/** Script invokes Flux (in-process serve stays on Flux, not deferred). */
|
|
39
|
-
export declare function isFluxOwnedScript(script: string): boolean;
|
|
40
|
-
/**
|
|
41
|
-
* First Nixpacks-style serve script that is not Flux-owned.
|
|
42
|
-
* Prefers `dev`, then `serve`.
|
|
43
|
-
*/
|
|
44
|
-
export declare function resolveDeferScript(scripts: Record<string, string>): string | undefined;
|
|
45
|
-
/** Convention: Flux Node apps use `main` ending in `main.ts` / `main.tsx`. */
|
|
46
|
-
export declare function isFluxAppMain(main: string): boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Classify one package. Foreign serve scripts win over `main.ts` (Vite apps
|
|
49
|
-
* often have a main entry but must not be HMR-booted by Flux).
|
|
50
|
-
*/
|
|
51
|
-
export declare function classifySliceProject(project: SliceProjectView): SliceKind;
|
|
52
|
-
export declare function classifySliceProjects(projects: readonly SliceProjectView[], slices: string | readonly string[]): ClassifiedSlice;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { ResolveFnOutput } from "node:module";
|
|
2
|
-
import type { Project, Workspace } from "@decohere/mesh";
|
|
3
|
-
export interface SourceModuleLoaderOptions {
|
|
4
|
-
/** Build configuration name. */
|
|
5
|
-
buildConfig: string;
|
|
6
|
-
/**
|
|
7
|
-
* Pre-built Workspace instance to use instead of running WorkspaceFactory.
|
|
8
|
-
* Useful in tests to bypass filesystem-based workspace discovery.
|
|
9
|
-
*/
|
|
10
|
-
workspace?: Workspace;
|
|
11
|
-
/**
|
|
12
|
-
* Map a watched `.ts` file URL for ESM resolution.
|
|
13
|
-
* Hot reload passes a `?version=` bust; one-shot run uses identity.
|
|
14
|
-
*/
|
|
15
|
-
versionFileUrl?: (fileUrl: string) => string;
|
|
16
|
-
/** Optional post-resolve hook (e.g. dependency tracking for HMR). */
|
|
17
|
-
onResolved?: (result: ResolveFnOutput, parentUrl: string) => void;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Registers Node ESM resolve/load hooks and SWC-transpiles workspace `.ts`
|
|
21
|
-
* on the fly. No file watching and no entry reboot — that belongs to
|
|
22
|
-
* {@link HotReloadServer}.
|
|
23
|
-
*/
|
|
24
|
-
export declare class SourceModuleLoader {
|
|
25
|
-
private readonly logger;
|
|
26
|
-
private readonly transpiler;
|
|
27
|
-
private disposed;
|
|
28
|
-
private hooksRegistered;
|
|
29
|
-
private workspace?;
|
|
30
|
-
private buildConfig;
|
|
31
|
-
private fileInfoMap;
|
|
32
|
-
private transpileCache;
|
|
33
|
-
/** SWC options per project, built on first use and kept until the next `configure()`. */
|
|
34
|
-
private swcConfigs;
|
|
35
|
-
private aliasPaths;
|
|
36
|
-
private aliasBaseUrl;
|
|
37
|
-
private versionFileUrl;
|
|
38
|
-
private onResolved?;
|
|
39
|
-
getWorkspace(): Workspace | undefined;
|
|
40
|
-
getBuildConfig(): string;
|
|
41
|
-
hasSourceFile(absolutePath: string): boolean;
|
|
42
|
-
sourceFilePaths(): IterableIterator<string>;
|
|
43
|
-
setSourceFile(absolutePath: string, project: Project): void;
|
|
44
|
-
configure(options: SourceModuleLoaderOptions): Promise<void>;
|
|
45
|
-
registerHooks(): void;
|
|
46
|
-
importEntry(absolutePath: string): Promise<unknown>;
|
|
47
|
-
invalidateTranspile(...absolutePaths: string[]): void;
|
|
48
|
-
dispose(): void;
|
|
49
|
-
private buildFileInfoMap;
|
|
50
|
-
private loadTs;
|
|
51
|
-
/**
|
|
52
|
-
* The project's SWC options, built once: rebuilding them for every file was about a quarter
|
|
53
|
-
* of load time (#513). Import specifiers are left as written, without `jsc.paths` or
|
|
54
|
-
* `resolveFully`: the resolve hook maps them to source files (aliases, `.js` to `.ts`,
|
|
55
|
-
* directory indexes), so SWC does not resolve them a second time against the disk.
|
|
56
|
-
*/
|
|
57
|
-
private swcConfigFor;
|
|
58
|
-
}
|