@decohere/flux 0.0.1-dev.115 → 0.0.1-dev.116
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 +9 -9
- package/commonjs/src/deferred-script-runner.js +1 -1
- package/commonjs/src/flux.command.js +1 -1
- package/commonjs/src/flux.module.js +1 -1
- package/commonjs/src/hot-reload-server.js +2 -2
- package/commonjs/src/rewrite-serve-specifier.js +6 -6
- package/commonjs/src/run.action.js +3 -3
- package/commonjs/src/run.command.js +1 -1
- package/commonjs/src/serve.action.js +3 -3
- package/commonjs/src/serve.command.js +1 -1
- package/commonjs/src/slice-serve.js +1 -1
- package/commonjs/src/source-module-loader.js +7 -7
- package/es6/src/deferred-script-runner.js +1 -1
- package/es6/src/flux.command.js +1 -1
- package/es6/src/flux.module.js +1 -1
- package/es6/src/hot-reload-server.js +2 -2
- package/es6/src/rewrite-serve-specifier.js +2 -2
- package/es6/src/run.action.js +2 -2
- package/es6/src/run.command.js +1 -1
- package/es6/src/serve.action.js +2 -2
- package/es6/src/serve.command.js +1 -1
- package/es6/src/slice-serve.js +1 -1
- package/es6/src/source-module-loader.js +3 -3
- package/package.json +6 -6
- package/types/src/flux.command.d.ts +2 -2
- package/types/src/flux.d.ts +3 -3
- package/types/src/flux.module.d.ts +4 -4
- package/types/src/hot-reload-server.d.ts +1 -1
- package/types/src/run.action.d.ts +2 -2
- package/types/src/run.command.d.ts +1 -1
- package/types/src/serve.action.d.ts +2 -2
- package/types/src/serve.command.d.ts +1 -1
- package/types/src/slice-serve.d.ts +1 -1
- package/types/src/source-module-loader.d.ts +1 -1
package/README.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
In-process TypeScript load for Node.js ESM apps — either one-shot (`flux run`) or hot-reload serve (`flux serve`).
|
|
4
4
|
|
|
5
|
-
Use Flux when you want to run source `.ts` directly. Flux transpiles with the **Forge** SWC compiler and maps imports to source with path aliases
|
|
5
|
+
Use Flux when you want to run source `.ts` directly. Flux transpiles with the **Forge** SWC compiler and maps imports to source with path aliases the workspace package builds dynamically from the workspace (`package.json` `name` → source `main`). Do not use Flux as a browser bundler, a worker-thread HMR, or a production process manager.
|
|
6
6
|
|
|
7
|
-
Point Flux at a tree of TypeScript packages (`package.json` at each project root). [
|
|
7
|
+
Point Flux at a tree of TypeScript packages (`package.json` at each project root). [`@decohere/workspace`](../workspace/README.md) is how that tree is deduced — you do not run Flux against the workspace package. Layout and glob overrides: [the workspace package — workspace layout](../workspace/README.md#workspace-layout).
|
|
8
8
|
|
|
9
9
|
This package is the Flux API. You use it through the `flux` CLI (`flux run` / `flux serve`), not by importing `@decohere/flux` from application code. The [Programmatic API](#programmatic-api) is only for embedding Flux in another tool.
|
|
10
10
|
|
|
11
|
-
Related: [
|
|
11
|
+
Related: [`@decohere/workspace`](../workspace/README.md) (package discovery), [Forge](../forge/README.md) (SWC + debug aliases). The `flux` command ships in `@decohere/cli`.
|
|
12
12
|
|
|
13
13
|
## When to use
|
|
14
14
|
|
|
@@ -49,7 +49,7 @@ Scaffolded apps already depend on `@decohere/cli` — use those scripts (`pnpm d
|
|
|
49
49
|
|
|
50
50
|
## CLI
|
|
51
51
|
|
|
52
|
-
Host options (`--config-file`, `--log-level`) are parsed before the subcommand. `--config-file` (default `.decohere.js` if present) is optional
|
|
52
|
+
Host options (`--config-file`, `--log-level`) are parsed before the subcommand. `--config-file` (default `.decohere.js` if present) is optional workspace config for package discovery. Omit it to use [workspace defaults](../workspace/README.md#workspace-layout).
|
|
53
53
|
|
|
54
54
|
### `flux run` — one-shot script
|
|
55
55
|
|
|
@@ -119,7 +119,7 @@ flux serve --reboot-debounce-ms 500
|
|
|
119
119
|
|
|
120
120
|
| | What it does |
|
|
121
121
|
|---|---|
|
|
122
|
-
| `flux serve` | Boots the first discovered project (
|
|
122
|
+
| `flux serve` | Boots the first discovered project (the workspace package lists packages by `package.json` `name`, A→Z). |
|
|
123
123
|
| `--project my-api` | Boots that package by name. |
|
|
124
124
|
| `--reboot-debounce-ms 500` | Same serve, but waits 500ms after the last save before rebooting (default 250ms). |
|
|
125
125
|
|
|
@@ -160,13 +160,13 @@ So keep the default. An agent's saves in one go land inside it, and its one-at-a
|
|
|
160
160
|
|
|
161
161
|
The `export default { async [Symbol.asyncDispose]() { … } }` in the server example above is that contract. Close servers, pools, and timers there — not in a `process.on("SIGINT")` handler Flux does not own.
|
|
162
162
|
|
|
163
|
-
**
|
|
163
|
+
**HTTP APIs** scaffold `export default app`. `App.dispose` disposes the root DI container, then Scribe. Constructed services that implement `Symbol.asyncDispose` (or `Symbol.dispose`) are torn down automatically — including the HTTP provider. Background work (timers, feeds, pollers) belongs in a [hosted service](../http/README.md#hosted-services): its signal is aborted and it is stopped on every reboot, so nothing keeps running into the next one. Put teardown on the service; do not wrap the default export, and do not keep workers in globals across reboots.
|
|
164
164
|
|
|
165
165
|
Flux clears its reference to the object *before* calling dispose, so a failed boot cannot dispose the same instance twice.
|
|
166
166
|
|
|
167
167
|
## Directory slice (`flux serve <token>…`)
|
|
168
168
|
|
|
169
|
-
A slice is a path token. Flux keeps
|
|
169
|
+
A slice is a path token. Flux keeps workspace packages whose directory sits under that token, then [classifies](#classification-convention) each one. `flux serve shop` and `flux serve projects/shop` are the same token.
|
|
170
170
|
|
|
171
171
|
Example workspace (every leaf directory here has its own `package.json`):
|
|
172
172
|
|
|
@@ -240,7 +240,7 @@ Only source files (`.ts`) that a served entry imports trigger a reboot.
|
|
|
240
240
|
|
|
241
241
|
**Memory grows over a long session.** Each reboot imports changed modules under a new `?version=` URL, and Node's ES module cache never releases the old versions. That's fine for a working day; if a session runs for days with thousands of reboots, restart it.
|
|
242
242
|
|
|
243
|
-
Flux uses **Forge’s compiler**, with one SWC config per project built once per run. SWC leaves imports as written; Flux's resolve hook maps each one to its TypeScript source: `@scope/pkg` and `@scope/pkg/sub` through the
|
|
243
|
+
Flux uses **Forge’s compiler**, with one SWC config per project built once per run. SWC leaves imports as written; Flux's resolve hook maps each one to its TypeScript source: `@scope/pkg` and `@scope/pkg/sub` through the the workspace package aliases (and tsconfig `paths`), `./file.js` and `./file` to `file.ts` or `file.tsx`, `./file.mjs` to `file.mts`, `./file.cjs` to `file.cts` (which runs as CommonJS), and `./dir` to `dir/index.ts`. Doing it in one place, instead of in SWC (`jsc.paths`, `resolveFully`) and again in the hook, made loading about 20% faster once Node and SWC are warm (`pnpm bench flux-load`, #513). Before Node imports an entry, Flux compiles it and the files it imports, following their imports out from the entry, in parallel on SWC's thread pool (#661). The load hook is synchronous and would otherwise compile one file at a time; files the app never imports, such as tests, are not compiled. A file that fails to compile there is compiled again when Node loads it, and that load fails with the file's name, as before. That is a debug rule so you can edit a library and hit HMR without a pre-build or `node_modules` workspace symlink. Release still resolves through real `node_modules` (published `exports` / `main`).
|
|
244
244
|
|
|
245
245
|
Why aliases, and a tree of where a symlink misses `src/index.ts`: [Forge — debug path aliases](../forge/README.md#debug-path-aliases-not-node_modules-links).
|
|
246
246
|
|
|
@@ -266,7 +266,7 @@ server.on("reboot", () => {}); // after dispose + boot attempt for affected entr
|
|
|
266
266
|
await server.dispose();
|
|
267
267
|
```
|
|
268
268
|
|
|
269
|
-
`configuration` is the
|
|
269
|
+
`configuration` is the workspace configuration **name** (`debug`, `release`, …), matching `--configuration`. Defaults to `debug`. Pass `workspace` in tests to skip `WorkspaceFactory`.
|
|
270
270
|
|
|
271
271
|
`flux.run` keeps Node ESM hooks registered for the process so the imported graph can still load `.ts`. Do not dispose the loader after a successful run.
|
|
272
272
|
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "DeferredScriptRunner", {
|
|
|
10
10
|
});
|
|
11
11
|
const _nodechild_process = require("node:child_process");
|
|
12
12
|
const _decorators = require("@decohere/crucible/decorators");
|
|
13
|
-
const _interop = require("@decohere/
|
|
13
|
+
const _interop = require("@decohere/core/interop");
|
|
14
14
|
const _scribe = require("@decohere/scribe");
|
|
15
15
|
function _ts_decorate(decorators, target, key, desc) {
|
|
16
16
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "FluxCommand", {
|
|
|
8
8
|
return FluxCommand;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _cli = require("@decohere/
|
|
11
|
+
const _cli = require("@decohere/core/cli");
|
|
12
12
|
const _runcommand = require("./run.command.js");
|
|
13
13
|
const _servecommand = require("./serve.command.js");
|
|
14
14
|
class FluxCommand extends _cli.DecohereCommand {
|
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "FluxModule", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _forge = require("@decohere/forge");
|
|
12
|
-
const _cli = require("@decohere/
|
|
12
|
+
const _cli = require("@decohere/core/cli");
|
|
13
13
|
const _deferredscriptrunner = require("./deferred-script-runner.js");
|
|
14
14
|
const _fluxcommand = require("./flux.command.js");
|
|
15
15
|
const _hotreloadserver = require("./hot-reload-server.js");
|
|
@@ -27,8 +27,8 @@ _export(exports, {
|
|
|
27
27
|
});
|
|
28
28
|
const _nodeevents = require("node:events");
|
|
29
29
|
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
30
|
-
const _io = require("@decohere/
|
|
31
|
-
const _system = require("@decohere/
|
|
30
|
+
const _io = require("@decohere/core/io");
|
|
31
|
+
const _system = require("@decohere/core/system");
|
|
32
32
|
const _scribe = require("@decohere/scribe");
|
|
33
33
|
const _sourcemoduleloader = require("./source-module-loader.js");
|
|
34
34
|
function _interop_require_default(obj) {
|
|
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "rewriteServeSpecifier", {
|
|
|
10
10
|
});
|
|
11
11
|
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
12
12
|
const _nodeurl = require("node:url");
|
|
13
|
-
const
|
|
13
|
+
const _workspace = require("@decohere/workspace");
|
|
14
14
|
function _interop_require_default(obj) {
|
|
15
15
|
return obj && obj.__esModule ? obj : {
|
|
16
16
|
default: obj
|
|
@@ -35,18 +35,18 @@ function rewriteServeSpecifier(options) {
|
|
|
35
35
|
* `index` source of the directory it names. A file wins over a directory of the same name.
|
|
36
36
|
*/ function watchedTs(filePath, isWatchedTs) {
|
|
37
37
|
const withoutSlash = filePath.replace(/[/\\]+$/, "");
|
|
38
|
-
//
|
|
38
|
+
// The workspace alias lookup may have added `.ts` to a subpath that names a directory (`@lib/models`
|
|
39
39
|
// arrives as `…/models.ts`), so the directory is the path without any extension.
|
|
40
40
|
const directory = withoutSlash.replace(/\.([mc]?[jt]sx?)$/, "");
|
|
41
41
|
const candidates = [
|
|
42
|
-
...
|
|
43
|
-
...
|
|
44
|
-
...
|
|
42
|
+
..._workspace.sourceExtensions.candidates(withoutSlash),
|
|
43
|
+
..._workspace.sourceExtensions.candidates(directory),
|
|
44
|
+
..._workspace.sourceExtensions.candidates(_nodepath.default.join(directory, "index"))
|
|
45
45
|
];
|
|
46
46
|
return candidates.find((candidate)=>isWatchedTs(candidate)) ?? null;
|
|
47
47
|
}
|
|
48
48
|
function resolveRelativeWatchedTs(specifier, parentUrl, isWatchedTs) {
|
|
49
|
-
if (
|
|
49
|
+
if (_workspace.packageAliases.isBareSpecifier(specifier)) return null;
|
|
50
50
|
if (!(specifier.startsWith(".") || specifier.startsWith("/"))) return null;
|
|
51
51
|
const parentClean = parentUrl.split("?")[0];
|
|
52
52
|
if (parentClean == null || parentClean === "") return null;
|
|
@@ -9,8 +9,8 @@ Object.defineProperty(exports, "RunAction", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _decorators = require("@decohere/crucible/decorators");
|
|
12
|
-
const
|
|
13
|
-
const _cli = require("@decohere/
|
|
12
|
+
const _workspace = require("@decohere/workspace");
|
|
13
|
+
const _cli = require("@decohere/core/cli");
|
|
14
14
|
const _scribe = require("@decohere/scribe");
|
|
15
15
|
const _flux = require("./flux.js");
|
|
16
16
|
function _ts_decorate(decorators, target, key, desc) {
|
|
@@ -42,6 +42,6 @@ RunAction = _ts_decorate([
|
|
|
42
42
|
(0, _decorators.injectable)(),
|
|
43
43
|
_ts_metadata("design:type", Function),
|
|
44
44
|
_ts_metadata("design:paramtypes", [
|
|
45
|
-
typeof
|
|
45
|
+
typeof _workspace.Workspace === "undefined" ? Object : _workspace.Workspace
|
|
46
46
|
])
|
|
47
47
|
], RunAction);
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "RunCommand", {
|
|
|
8
8
|
return RunCommand;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _cli = require("@decohere/
|
|
11
|
+
const _cli = require("@decohere/core/cli");
|
|
12
12
|
const _runaction = require("./run.action.js");
|
|
13
13
|
class RunCommand extends _cli.DecohereCommand {
|
|
14
14
|
get actions() {
|
|
@@ -10,8 +10,8 @@ Object.defineProperty(exports, "ServeAction", {
|
|
|
10
10
|
});
|
|
11
11
|
const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
12
12
|
const _decorators = require("@decohere/crucible/decorators");
|
|
13
|
-
const
|
|
14
|
-
const _cli = require("@decohere/
|
|
13
|
+
const _workspace = require("@decohere/workspace");
|
|
14
|
+
const _cli = require("@decohere/core/cli");
|
|
15
15
|
const _scribe = require("@decohere/scribe");
|
|
16
16
|
const _deferredscriptrunner = require("./deferred-script-runner.js");
|
|
17
17
|
const _hotreloadserver = require("./hot-reload-server.js");
|
|
@@ -114,7 +114,7 @@ ServeAction = _ts_decorate([
|
|
|
114
114
|
_ts_metadata("design:type", Function),
|
|
115
115
|
_ts_metadata("design:paramtypes", [
|
|
116
116
|
typeof _hotreloadserver.HotReloadServer === "undefined" ? Object : _hotreloadserver.HotReloadServer,
|
|
117
|
-
typeof
|
|
117
|
+
typeof _workspace.Workspace === "undefined" ? Object : _workspace.Workspace,
|
|
118
118
|
typeof _deferredscriptrunner.DeferredScriptRunner === "undefined" ? Object : _deferredscriptrunner.DeferredScriptRunner
|
|
119
119
|
])
|
|
120
120
|
], ServeAction);
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "ServeCommand", {
|
|
|
8
8
|
return ServeCommand;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
-
const _cli = require("@decohere/
|
|
11
|
+
const _cli = require("@decohere/core/cli");
|
|
12
12
|
const _hotreloadserver = require("./hot-reload-server.js");
|
|
13
13
|
const _serveaction = require("./serve.action.js");
|
|
14
14
|
class ServeCommand extends _cli.DecohereCommand {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Directory-slice helpers for `flux serve <dir>…` — classify
|
|
2
|
+
* Directory-slice helpers for `flux serve <dir>…` — classify workspace packages as
|
|
3
3
|
* Flux apps, Nixpacks-style script deferrals, or libraries to skip.
|
|
4
4
|
*/ "use strict";
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -14,8 +14,8 @@ const _nodepath = /*#__PURE__*/ _interop_require_default(require("node:path"));
|
|
|
14
14
|
const _nodeurl = require("node:url");
|
|
15
15
|
const _decorators = require("@decohere/crucible/decorators");
|
|
16
16
|
const _forge = require("@decohere/forge");
|
|
17
|
-
const
|
|
18
|
-
const _io = require("@decohere/
|
|
17
|
+
const _workspace = require("@decohere/workspace");
|
|
18
|
+
const _io = require("@decohere/core/io");
|
|
19
19
|
const _scribe = require("@decohere/scribe");
|
|
20
20
|
const _rewriteservespecifier = require("./rewrite-serve-specifier.js");
|
|
21
21
|
const _staticimports = require("./static-imports.js");
|
|
@@ -138,7 +138,7 @@ class SourceModuleLoader {
|
|
|
138
138
|
specifier,
|
|
139
139
|
parentUrl,
|
|
140
140
|
isWatchedTs: (filePath)=>this.fileInfoMap.has(filePath),
|
|
141
|
-
resolveBare: (bare)=>
|
|
141
|
+
resolveBare: (bare)=>_workspace.packageAliases.resolvePath(bare, this.aliasPaths, this.aliasBaseUrl),
|
|
142
142
|
versionFileUrl: this.versionFileUrl
|
|
143
143
|
}) ?? specifier;
|
|
144
144
|
const result = next(rewritten, context);
|
|
@@ -251,7 +251,7 @@ class SourceModuleLoader {
|
|
|
251
251
|
specifier,
|
|
252
252
|
parentUrl,
|
|
253
253
|
isWatchedTs: (filePath)=>this.fileInfoMap.has(filePath),
|
|
254
|
-
resolveBare: (bare)=>
|
|
254
|
+
resolveBare: (bare)=>_workspace.packageAliases.resolvePath(bare, this.aliasPaths, this.aliasBaseUrl),
|
|
255
255
|
versionFileUrl: (fileUrl)=>fileUrl
|
|
256
256
|
});
|
|
257
257
|
return url == null ? null : (0, _nodeurl.fileURLToPath)(url);
|
|
@@ -259,11 +259,11 @@ class SourceModuleLoader {
|
|
|
259
259
|
loadTs(url) {
|
|
260
260
|
if (!url.startsWith("file:")) return null;
|
|
261
261
|
// fileURLToPath, not URL.pathname: decodes %20 and gives Windows paths, so files
|
|
262
|
-
// whose path has a space still match
|
|
262
|
+
// whose path has a space still match the workspace's package list (#511).
|
|
263
263
|
const cleanPath = (0, _nodeurl.fileURLToPath)(url);
|
|
264
264
|
const fileInfo = this.fileInfoMap.get(cleanPath);
|
|
265
265
|
if (fileInfo == null) return null;
|
|
266
|
-
const format =
|
|
266
|
+
const format = _workspace.sourceExtensions.isCommonJs(cleanPath) ? "commonjs" : "module";
|
|
267
267
|
const cached = this.transpileCache.get(cleanPath);
|
|
268
268
|
if (cached != null) return {
|
|
269
269
|
source: cached,
|
|
@@ -337,7 +337,7 @@ class SourceModuleLoader {
|
|
|
337
337
|
* directory indexes), so SWC does not resolve them a second time against the disk.
|
|
338
338
|
*/ swcConfigFor(project, fullPath) {
|
|
339
339
|
const config = this.esModuleConfigFor(project);
|
|
340
|
-
if (!
|
|
340
|
+
if (!_workspace.sourceExtensions.isCommonJs(fullPath)) return config;
|
|
341
341
|
// `.cts` is CommonJS: Node loads it with `require` semantics, so SWC emits CommonJS (#518).
|
|
342
342
|
// Kept per project, like the ES module options, so the disk cache hashes them once.
|
|
343
343
|
const cached = this.commonJsConfigs.get(project);
|
|
@@ -6,7 +6,7 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
6
6
|
}
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
8
8
|
import { injectable } from "@decohere/crucible/decorators";
|
|
9
|
-
import { detectPackageManager, packageManagerFromString } from "@decohere/
|
|
9
|
+
import { detectPackageManager, packageManagerFromString } from "@decohere/core/interop";
|
|
10
10
|
import { scribe } from "@decohere/scribe";
|
|
11
11
|
export class DeferredScriptRunner {
|
|
12
12
|
logger = scribe.logger(DeferredScriptRunner.name);
|
package/es6/src/flux.command.js
CHANGED
package/es6/src/flux.module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createWorkspace } from "@decohere/forge";
|
|
2
|
-
import { ModuleManifest } from "@decohere/
|
|
2
|
+
import { ModuleManifest } from "@decohere/core/cli";
|
|
3
3
|
import { DeferredScriptRunner } from "./deferred-script-runner.js";
|
|
4
4
|
import { FluxCommand } from "./flux.command.js";
|
|
5
5
|
import { HotReloadServer } from "./hot-reload-server.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { io } from "@decohere/
|
|
4
|
-
import { debounce } from "@decohere/
|
|
3
|
+
import { io } from "@decohere/core/io";
|
|
4
|
+
import { debounce } from "@decohere/core/system";
|
|
5
5
|
import { scribe } from "@decohere/scribe";
|
|
6
6
|
import { SourceModuleLoader } from "./source-module-loader.js";
|
|
7
7
|
const currentFilePath = io.fileUrlToPath(import.meta.url);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
-
import { packageAliases, sourceExtensions } from "@decohere/
|
|
3
|
+
import { packageAliases, sourceExtensions } from "@decohere/workspace";
|
|
4
4
|
/**
|
|
5
5
|
* Map a resolve-hook specifier to a versioned watched `.ts` file URL.
|
|
6
6
|
* Covers relative `.js` / `.ts` / extensionless imports, directory imports (`./models` is
|
|
@@ -25,7 +25,7 @@ import { packageAliases, sourceExtensions } from "@decohere/mesh";
|
|
|
25
25
|
* `index` source of the directory it names. A file wins over a directory of the same name.
|
|
26
26
|
*/ function watchedTs(filePath, isWatchedTs) {
|
|
27
27
|
const withoutSlash = filePath.replace(/[/\\]+$/, "");
|
|
28
|
-
//
|
|
28
|
+
// The workspace alias lookup may have added `.ts` to a subpath that names a directory (`@lib/models`
|
|
29
29
|
// arrives as `…/models.ts`), so the directory is the path without any extension.
|
|
30
30
|
const directory = withoutSlash.replace(/\.([mc]?[jt]sx?)$/, "");
|
|
31
31
|
const candidates = [
|
package/es6/src/run.action.js
CHANGED
|
@@ -8,8 +8,8 @@ function _ts_metadata(k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
}
|
|
10
10
|
import { injectable } from "@decohere/crucible/decorators";
|
|
11
|
-
import { Workspace } from "@decohere/
|
|
12
|
-
import { ActionResponse } from "@decohere/
|
|
11
|
+
import { Workspace } from "@decohere/workspace";
|
|
12
|
+
import { ActionResponse } from "@decohere/core/cli";
|
|
13
13
|
import { scribe } from "@decohere/scribe";
|
|
14
14
|
import { flux } from "./flux.js";
|
|
15
15
|
export class RunAction {
|
package/es6/src/run.command.js
CHANGED
package/es6/src/serve.action.js
CHANGED
|
@@ -9,8 +9,8 @@ function _ts_metadata(k, v) {
|
|
|
9
9
|
}
|
|
10
10
|
import path from "node:path";
|
|
11
11
|
import { injectable } from "@decohere/crucible/decorators";
|
|
12
|
-
import { Workspace } from "@decohere/
|
|
13
|
-
import { ActionResponse } from "@decohere/
|
|
12
|
+
import { Workspace } from "@decohere/workspace";
|
|
13
|
+
import { ActionResponse } from "@decohere/core/cli";
|
|
14
14
|
import { scribe } from "@decohere/scribe";
|
|
15
15
|
import { DeferredScriptRunner } from "./deferred-script-runner.js";
|
|
16
16
|
import { HotReloadServer } from "./hot-reload-server.js";
|
package/es6/src/serve.command.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigurationOption, DecohereCommand, ProjectOption } from "@decohere/
|
|
1
|
+
import { ConfigurationOption, DecohereCommand, ProjectOption } from "@decohere/core/cli";
|
|
2
2
|
import { DEFAULT_REBOOT_DEBOUNCE_MS, resolveRebootDebounceMs } from "./hot-reload-server.js";
|
|
3
3
|
import { ServeAction } from "./serve.action.js";
|
|
4
4
|
export class ServeCommand extends DecohereCommand {
|
package/es6/src/slice-serve.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Directory-slice helpers for `flux serve <dir>…` — classify
|
|
2
|
+
* Directory-slice helpers for `flux serve <dir>…` — classify workspace packages as
|
|
3
3
|
* Flux apps, Nixpacks-style script deferrals, or libraries to skip.
|
|
4
4
|
*/ /** Preferred package scripts for foreign toolchains (Nixpacks-style). */ export const DEFER_SCRIPT_CANDIDATES = [
|
|
5
5
|
"dev",
|
|
@@ -10,8 +10,8 @@ import path from "node:path";
|
|
|
10
10
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
11
11
|
import { injectable } from "@decohere/crucible/decorators";
|
|
12
12
|
import { BuildTargets, createWorkspace, SwcTranspiler } from "@decohere/forge";
|
|
13
|
-
import { packageAliases, sourceExtensions } from "@decohere/
|
|
14
|
-
import { FileEx, io } from "@decohere/
|
|
13
|
+
import { packageAliases, sourceExtensions } from "@decohere/workspace";
|
|
14
|
+
import { FileEx, io } from "@decohere/core/io";
|
|
15
15
|
import { scribe } from "@decohere/scribe";
|
|
16
16
|
import { rewriteServeSpecifier } from "./rewrite-serve-specifier.js";
|
|
17
17
|
import { staticImports } from "./static-imports.js";
|
|
@@ -203,7 +203,7 @@ export class SourceModuleLoader {
|
|
|
203
203
|
loadTs(url) {
|
|
204
204
|
if (!url.startsWith("file:")) return null;
|
|
205
205
|
// fileURLToPath, not URL.pathname: decodes %20 and gives Windows paths, so files
|
|
206
|
-
// whose path has a space still match
|
|
206
|
+
// whose path has a space still match the workspace's package list (#511).
|
|
207
207
|
const cleanPath = fileURLToPath(url);
|
|
208
208
|
const fileInfo = this.fileInfoMap.get(cleanPath);
|
|
209
209
|
if (fileInfo == null) return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decohere/flux",
|
|
3
|
-
"version": "0.0.1-dev.
|
|
3
|
+
"version": "0.0.1-dev.116",
|
|
4
4
|
"description": "Hot module reload server for Node.js ESM applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@decohere/
|
|
29
|
-
"@decohere/
|
|
30
|
-
"@decohere/
|
|
31
|
-
"@decohere/
|
|
32
|
-
"@decohere/
|
|
28
|
+
"@decohere/core": "0.0.1-dev.116",
|
|
29
|
+
"@decohere/crucible": "0.0.1-dev.116",
|
|
30
|
+
"@decohere/forge": "0.0.1-dev.116",
|
|
31
|
+
"@decohere/scribe": "0.0.1-dev.116",
|
|
32
|
+
"@decohere/workspace": "0.0.1-dev.116",
|
|
33
33
|
"commander": "^13.1.0",
|
|
34
34
|
"rxjs": "^7.8.2"
|
|
35
35
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Actions } from "@decohere/
|
|
2
|
-
import { type CommandHandler, type CommandResponse, type CommandType, DecohereCommand } from "@decohere/
|
|
1
|
+
import type { Actions } from "@decohere/core/cli";
|
|
2
|
+
import { type CommandHandler, type CommandResponse, type CommandType, DecohereCommand } from "@decohere/core/cli";
|
|
3
3
|
export declare class FluxCommand extends DecohereCommand {
|
|
4
4
|
constructor(commands: Record<string, CommandType>, handler: CommandHandler);
|
|
5
5
|
run(_actions: Actions, _options: never): Promise<CommandResponse>;
|
package/types/src/flux.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Workspace } from "@decohere/
|
|
1
|
+
import type { Workspace } from "@decohere/workspace";
|
|
2
2
|
import { HotReloadServer } from "./hot-reload-server.js";
|
|
3
3
|
export type FluxRunOptions = {
|
|
4
|
-
/**
|
|
4
|
+
/** Workspace configuration name. Defaults to `debug` (`--configuration`). */
|
|
5
5
|
configuration?: string;
|
|
6
6
|
/** Arguments forwarded to the entry (bin-style `process.argv.slice(2)`). */
|
|
7
7
|
args?: string[];
|
|
@@ -12,7 +12,7 @@ export type FluxRunOptions = {
|
|
|
12
12
|
workspace?: Workspace;
|
|
13
13
|
};
|
|
14
14
|
export type FluxServeOptions = {
|
|
15
|
-
/**
|
|
15
|
+
/** Workspace configuration name. Defaults to `debug` (`--configuration`). */
|
|
16
16
|
configuration?: string;
|
|
17
17
|
/** Name of the project to serve. Defaults to the first project in the workspace. */
|
|
18
18
|
project?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { WorkspaceFactoryOptions } from "@decohere/
|
|
2
|
-
import { ModuleManifest } from "@decohere/
|
|
3
|
-
import type { ContainerBuilder } from "@decohere/
|
|
1
|
+
import type { WorkspaceFactoryOptions } from "@decohere/core/cli";
|
|
2
|
+
import { ModuleManifest } from "@decohere/core/cli";
|
|
3
|
+
import type { ContainerBuilder } from "@decohere/core/composition";
|
|
4
4
|
import { FluxCommand } from "./flux.command.js";
|
|
5
5
|
import { RunAction } from "./run.action.js";
|
|
6
6
|
import { ServeAction } from "./serve.action.js";
|
|
@@ -12,5 +12,5 @@ export declare class FluxModule extends ModuleManifest {
|
|
|
12
12
|
run: typeof RunAction;
|
|
13
13
|
};
|
|
14
14
|
registerServices(builder: ContainerBuilder): void;
|
|
15
|
-
createWorkspace(options: WorkspaceFactoryOptions): Promise<import("@decohere/
|
|
15
|
+
createWorkspace(options: WorkspaceFactoryOptions): Promise<import("@decohere/workspace").Workspace>;
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
|
-
import type { Workspace } from "@decohere/
|
|
2
|
+
import type { Workspace } from "@decohere/workspace";
|
|
3
3
|
/** Default quiet window before a file-change reboot. */
|
|
4
4
|
export declare const DEFAULT_REBOOT_DEBOUNCE_MS = 250;
|
|
5
5
|
export declare function resolveRebootDebounceMs(value: number | undefined): number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Workspace } from "@decohere/
|
|
2
|
-
import { type Action, ActionResponse } from "@decohere/
|
|
1
|
+
import { Workspace } from "@decohere/workspace";
|
|
2
|
+
import { type Action, ActionResponse } from "@decohere/core/cli";
|
|
3
3
|
export type RunOptions = {
|
|
4
4
|
/** Absolute or cwd-relative path to a `.ts` entry file. */
|
|
5
5
|
entry: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Workspace } from "@decohere/
|
|
2
|
-
import { type Action, ActionResponse } from "@decohere/
|
|
1
|
+
import { Workspace } from "@decohere/workspace";
|
|
2
|
+
import { type Action, ActionResponse } from "@decohere/core/cli";
|
|
3
3
|
import { DeferredScriptRunner } from "./deferred-script-runner.js";
|
|
4
4
|
import { HotReloadServer } from "./hot-reload-server.js";
|
|
5
5
|
export type ServeOptions = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Directory-slice helpers for `flux serve <dir>…` — classify
|
|
2
|
+
* Directory-slice helpers for `flux serve <dir>…` — classify workspace packages as
|
|
3
3
|
* Flux apps, Nixpacks-style script deferrals, or libraries to skip.
|
|
4
4
|
*/
|
|
5
5
|
export type SliceProjectView = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ResolveFnOutput } from "node:module";
|
|
2
|
-
import type { Project, Workspace } from "@decohere/
|
|
2
|
+
import type { Project, Workspace } from "@decohere/workspace";
|
|
3
3
|
export interface SourceModuleLoaderOptions {
|
|
4
4
|
/** Build configuration name. */
|
|
5
5
|
buildConfig: string;
|