@c9up/ream 0.2.23 → 0.2.25

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 (64) hide show
  1. package/dist/Codemods.d.ts +1 -0
  2. package/dist/Codemods.d.ts.map +1 -1
  3. package/dist/Codemods.js +44 -0
  4. package/dist/Codemods.js.map +1 -1
  5. package/dist/Ignitor.d.ts +50 -0
  6. package/dist/Ignitor.d.ts.map +1 -1
  7. package/dist/Ignitor.js +15 -15
  8. package/dist/Ignitor.js.map +1 -1
  9. package/dist/dev/fullReload.d.ts +23 -0
  10. package/dist/dev/fullReload.d.ts.map +1 -0
  11. package/dist/dev/fullReload.js +26 -0
  12. package/dist/dev/fullReload.js.map +1 -0
  13. package/dist/dev/hmr.d.ts +52 -4
  14. package/dist/dev/hmr.d.ts.map +1 -1
  15. package/dist/dev/hmr.js +75 -9
  16. package/dist/dev/hmr.js.map +1 -1
  17. package/dist/dev/hotGlob.d.ts +35 -0
  18. package/dist/dev/hotGlob.d.ts.map +1 -0
  19. package/dist/dev/hotGlob.js +92 -0
  20. package/dist/dev/hotGlob.js.map +1 -0
  21. package/dist/dev/hotGraph.d.ts +58 -0
  22. package/dist/dev/hotGraph.d.ts.map +1 -0
  23. package/dist/dev/hotGraph.js +91 -0
  24. package/dist/dev/hotGraph.js.map +1 -0
  25. package/dist/dev/hotWatcher.d.ts +34 -0
  26. package/dist/dev/hotWatcher.d.ts.map +1 -0
  27. package/dist/dev/hotWatcher.js +72 -0
  28. package/dist/dev/hotWatcher.js.map +1 -0
  29. package/dist/env/loadEnvFiles.d.ts +13 -0
  30. package/dist/env/loadEnvFiles.d.ts.map +1 -1
  31. package/dist/env/loadEnvFiles.js +65 -13
  32. package/dist/env/loadEnvFiles.js.map +1 -1
  33. package/dist/hot.d.ts +13 -16
  34. package/dist/hot.d.ts.map +1 -1
  35. package/dist/hot.js +161 -84
  36. package/dist/hot.js.map +1 -1
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +1 -1
  39. package/events.darwin-arm64.node +0 -0
  40. package/events.darwin-x64.node +0 -0
  41. package/events.linux-arm64-gnu.node +0 -0
  42. package/events.linux-x64-gnu.node +0 -0
  43. package/events.win32-x64-msvc.node +0 -0
  44. package/index.darwin-arm64.node +0 -0
  45. package/index.darwin-x64.node +0 -0
  46. package/index.linux-arm64-gnu.node +0 -0
  47. package/index.linux-x64-gnu.node +0 -0
  48. package/index.win32-x64-msvc.node +0 -0
  49. package/package.json +4 -7
  50. package/scheduler.darwin-arm64.node +0 -0
  51. package/scheduler.darwin-x64.node +0 -0
  52. package/scheduler.linux-arm64-gnu.node +0 -0
  53. package/scheduler.linux-x64-gnu.node +0 -0
  54. package/scheduler.win32-x64-msvc.node +0 -0
  55. package/src/Codemods.ts +53 -0
  56. package/src/Ignitor.ts +68 -14
  57. package/src/dev/fullReload.ts +34 -0
  58. package/src/dev/hmr.ts +102 -9
  59. package/src/dev/hotGlob.ts +91 -0
  60. package/src/dev/hotGraph.ts +109 -0
  61. package/src/dev/hotWatcher.ts +89 -0
  62. package/src/env/loadEnvFiles.ts +69 -14
  63. package/src/hot.ts +169 -102
  64. package/src/index.ts +1 -1
@@ -1,8 +1,56 @@
1
1
  import { readFileSync } from 'node:fs';
2
- import { fileURLToPath } from 'node:url';
2
+ import { fileURLToPath, pathToFileURL } from 'node:url';
3
3
  import { parseEnv } from 'node:util';
4
4
  import { interpolate } from './interpolate.js';
5
5
  import { normalizeNodeEnv } from './nodeEnv.js';
6
+ /**
7
+ * The `.env*` files that will be read, most-specific first.
8
+ *
9
+ * Exported because `@c9up/ream/hot` has to WATCH exactly this list: nothing
10
+ * imports an env file, so hot-hook's dependency tree never sees one and an
11
+ * edit to `.env` changed nothing at all. A second copy of the list in the
12
+ * loader entry would drift from this one the first time the naming changes.
13
+ *
14
+ * @param options.skipEnvLocal Skip `.env.local` — see {@link loadEnvFiles}.
15
+ */
16
+ export function envFileNames(options = {}) {
17
+ // Normalised, so `NODE_ENV=prod` loads `.env.production` — the file the
18
+ // deployment actually wrote — instead of looking for `.env.prod`.
19
+ const raw = normalizeNodeEnv(process.env.NODE_ENV);
20
+ const nodeEnv = raw === 'unknown' ? undefined : raw;
21
+ return [
22
+ nodeEnv ? `.env.${nodeEnv}.local` : null,
23
+ options.skipEnvLocal ? null : '.env.local',
24
+ nodeEnv ? `.env.${nodeEnv}` : null,
25
+ '.env',
26
+ ].filter((name) => name !== null);
27
+ }
28
+ /**
29
+ * Where the `.env*` files are read from.
30
+ *
31
+ * Normally beside the application, which is what `appRoot` names. A BUILT
32
+ * application moves: `start/env.js` sits in `dist/`, so `new URL('../',
33
+ * import.meta.url)` resolves there and the files at the project root become
34
+ * invisible — `ream start` died on a `.env` it was standing next to.
35
+ *
36
+ * `ENV_PATH` is AdonisJS's own variable for this, named and shaped the same
37
+ * way: a DIRECTORY to read the files from, as in
38
+ * `ENV_PATH=/etc/secrets node server.js`. An application moving over keeps
39
+ * whatever it already sets.
40
+ *
41
+ * It is also why the ordering rule stays here rather than in the CLI: node's
42
+ * `--env-file` applies files last-wins while this loader applies them
43
+ * most-specific-first, and a second copy of that would be one to keep in step
44
+ * forever.
45
+ */
46
+ function envDirectory(appRoot) {
47
+ const override = process.env.ENV_PATH;
48
+ if (override === undefined || override.trim() === '')
49
+ return appRoot;
50
+ // A directory URL, so `new URL('.env', directory)` lands inside it rather
51
+ // than beside it.
52
+ return pathToFileURL(override.endsWith('/') ? override : `${override}/`);
53
+ }
6
54
  /**
7
55
  * Load `.env` files into `process.env` — the shared primitive behind both the
8
56
  * Ignitor (HTTP/console boot) and `Env.create()` (config/test flow), mirroring
@@ -17,24 +65,17 @@ import { normalizeNodeEnv } from './nodeEnv.js';
17
65
  * developer's local overrides don't leak into tests).
18
66
  */
19
67
  export function loadEnvFiles(appRoot, options = {}) {
20
- // Normalised, so `NODE_ENV=prod` loads `.env.production` — the file the
21
- // deployment actually wrote — instead of looking for `.env.prod`.
22
- const raw = normalizeNodeEnv(process.env.NODE_ENV);
23
- const nodeEnv = raw === 'unknown' ? undefined : raw;
24
- const files = [
25
- nodeEnv ? `.env.${nodeEnv}.local` : null,
26
- options.skipEnvLocal ? null : '.env.local',
27
- nodeEnv ? `.env.${nodeEnv}` : null,
28
- '.env',
29
- ].filter((name) => name !== null);
30
- for (const name of files) {
68
+ const directory = envDirectory(appRoot);
69
+ let found = false;
70
+ for (const name of envFileNames(options)) {
31
71
  let contents;
32
72
  try {
33
- contents = readFileSync(fileURLToPath(new URL(name, appRoot)), 'utf8');
73
+ contents = readFileSync(fileURLToPath(new URL(name, directory)), 'utf8');
34
74
  }
35
75
  catch {
36
76
  continue; // file absent — nothing to load
37
77
  }
78
+ found = true;
38
79
  const parsed = parseEnv(contents);
39
80
  for (const [key, value] of Object.entries(parsed)) {
40
81
  if (typeof value !== 'string' || process.env[key] !== undefined)
@@ -50,5 +91,16 @@ export function loadEnvFiles(appRoot, options = {}) {
50
91
  });
51
92
  }
52
93
  }
94
+ // Upstream raises when `ENV_PATH` names a place with no env file in it, and
95
+ // for the reason silence would be wrong: the variable is somebody saying
96
+ // where the file IS. A typo in the path would otherwise start a server on
97
+ // whatever defaults happened to be around, which is how a deployment reads
98
+ // its staging config in production and nobody finds out until later.
99
+ //
100
+ // Without `ENV_PATH` a missing file stays silent: an application may have
101
+ // none at all, and every value may come from the environment.
102
+ if (!found && process.env.ENV_PATH !== undefined && process.env.ENV_PATH.trim() !== '') {
103
+ throw new Error(`ENV_PATH points at ${process.env.ENV_PATH}, which holds none of ${envFileNames(options).join(', ')}`);
104
+ }
53
105
  }
54
106
  //# sourceMappingURL=loadEnvFiles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"loadEnvFiles.js","sourceRoot":"","sources":["../../src/env/loadEnvFiles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAA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KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,SAAS;gBAAE,SAAQ;YACzE,uEAAuE;YACvE,iEAAiE;YACjE,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;gBAC7C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;gBACrC,IAAI,WAAW,KAAK,SAAS;oBAAE,OAAO,WAAW,CAAA;gBACjD,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;gBAC7B,OAAO,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAA;YAC5D,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,4EAA4E;IAC5E,yEAAyE;IACzE,0EAA0E;IAC1E,2EAA2E;IAC3E,qEAAqE;IACrE,EAAE;IACF,0EAA0E;IAC1E,8DAA8D;IAC9D,IAAI,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,SAAS,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACvF,MAAM,IAAI,KAAK,CACb,sBAAsB,OAAO,CAAC,GAAG,CAAC,QAAQ,yBAAyB,YAAY,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACtG,CAAA;IACH,CAAC;AACH,CAAC"}
package/dist/hot.d.ts CHANGED
@@ -5,25 +5,22 @@
5
5
  *
6
6
  * node --import @swc-node/register/esm-register --import @c9up/ream/hot bin/server.ts
7
7
  *
8
- * It is a thin shim over `hot-hook`, which does the actual work: it registers
9
- * an ESM loader that tracks the import graph, and when a file inside a declared
10
- * boundary changes it invalidates just that module instead of the process. The
11
- * `hotHook` key in the application's `package.json` configures it, exactly as
12
- * upstream reads it.
8
+ * It replaces a module that changed instead of the process that was serving it,
9
+ * so the container, the pools and the connections survive a save.
13
10
  *
14
- * NAMED DEVIATION — why this file exists at all.
11
+ * NAMED DEVIATION — this is ream's own, where AdonisJS uses `hot-hook`.
15
12
  *
16
- * Upstream's dev server is itself a Node process: it forks the app, so the two
17
- * talk over Node's IPC channel, and `hot-hook` reports a change it cannot swap
18
- * by calling `process.send({ type: 'hot-hook:full-reload' })`. Our dev server is
19
- * a Rust binary. A process it spawns has NO IPC channel, so `process.send` is
20
- * `undefined` and that message goes nowhere: the server would keep serving the
21
- * old module and say nothing.
13
+ * Upstream ships that package in its starter kit, which means every application
14
+ * installs it, and one created before the convention existed silently loses hot
15
+ * reloading. The parts that once justified a library are now in Node:
16
+ * `module.registerHooks` gives the import graph, `fs.watch` gives the changes.
17
+ * What is left is the decision of what to invalidate, which is this file and
18
+ * its three neighbours — and no entry in anyone's `package.json`.
22
19
  *
23
- * `hot.init()` takes an `onFullReloadAsked` callback for exactly this case, and
24
- * that is the whole of the shim: turn "I cannot hot-swap this" into an exit
25
- * code the Rust parent understands and restarts on. Everything else is
26
- * upstream's behaviour, unmodified.
20
+ * The graph comes from the resolver rather than from reading files: a resolve
21
+ * hook is handed the importer and the imported, which is exactly an edge, and
22
+ * it sees a dynamic import at the moment it happens rather than guessing at it
23
+ * from the source.
27
24
  */
28
25
  export {};
29
26
  //# sourceMappingURL=hot.d.ts.map
package/dist/hot.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hot.d.ts","sourceRoot":"","sources":["../src/hot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
1
+ {"version":3,"file":"hot.d.ts","sourceRoot":"","sources":["../src/hot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG"}
package/dist/hot.js CHANGED
@@ -5,108 +5,185 @@
5
5
  *
6
6
  * node --import @swc-node/register/esm-register --import @c9up/ream/hot bin/server.ts
7
7
  *
8
- * It is a thin shim over `hot-hook`, which does the actual work: it registers
9
- * an ESM loader that tracks the import graph, and when a file inside a declared
10
- * boundary changes it invalidates just that module instead of the process. The
11
- * `hotHook` key in the application's `package.json` configures it, exactly as
12
- * upstream reads it.
8
+ * It replaces a module that changed instead of the process that was serving it,
9
+ * so the container, the pools and the connections survive a save.
13
10
  *
14
- * NAMED DEVIATION — why this file exists at all.
11
+ * NAMED DEVIATION — this is ream's own, where AdonisJS uses `hot-hook`.
15
12
  *
16
- * Upstream's dev server is itself a Node process: it forks the app, so the two
17
- * talk over Node's IPC channel, and `hot-hook` reports a change it cannot swap
18
- * by calling `process.send({ type: 'hot-hook:full-reload' })`. Our dev server is
19
- * a Rust binary. A process it spawns has NO IPC channel, so `process.send` is
20
- * `undefined` and that message goes nowhere: the server would keep serving the
21
- * old module and say nothing.
13
+ * Upstream ships that package in its starter kit, which means every application
14
+ * installs it, and one created before the convention existed silently loses hot
15
+ * reloading. The parts that once justified a library are now in Node:
16
+ * `module.registerHooks` gives the import graph, `fs.watch` gives the changes.
17
+ * What is left is the decision of what to invalidate, which is this file and
18
+ * its three neighbours — and no entry in anyone's `package.json`.
22
19
  *
23
- * `hot.init()` takes an `onFullReloadAsked` callback for exactly this case, and
24
- * that is the whole of the shim: turn "I cannot hot-swap this" into an exit
25
- * code the Rust parent understands and restarts on. Everything else is
26
- * upstream's behaviour, unmodified.
20
+ * The graph comes from the resolver rather than from reading files: a resolve
21
+ * hook is handed the importer and the imported, which is exactly an edge, and
22
+ * it sees a dynamic import at the moment it happens rather than guessing at it
23
+ * from the source.
27
24
  */
25
+ import { existsSync, writeSync } from 'node:fs';
26
+ import { readFile } from 'node:fs/promises';
27
+ import { registerHooks } from 'node:module';
28
+ import { dirname, relative, resolve as resolvePath } from 'node:path';
29
+ import { fileURLToPath, pathToFileURL } from 'node:url';
30
+ import { fullReloadNotice } from './dev/fullReload.js';
28
31
  import { hotReloadHappened } from './dev/hmr.js';
29
32
  import { readHotHookConfig } from './dev/hotConfig.js';
33
+ import { globMatcher } from './dev/hotGlob.js';
34
+ import { HotGraph } from './dev/hotGraph.js';
35
+ import { watchProject } from './dev/hotWatcher.js';
36
+ import { envFileNames } from './env/loadEnvFiles.js';
30
37
  /** Exit code meaning "restart me" — see `EXIT_RESTART` in the CLI's dev module. */
31
38
  const FULL_RELOAD_EXIT_CODE = 75;
32
- const { readFile } = await import('node:fs/promises');
33
- const { dirname, resolve } = await import('node:path');
34
- const packageJsonPath = resolve(process.cwd(), 'package.json');
39
+ /** The query parameter that makes the loader fetch a module again. */
40
+ const VERSION_PARAM = 'ream_hot';
41
+ /** Directories a project keeps its own code in — the CLI watches the same list. */
42
+ const WATCH_DIRS = ['app', 'bin', 'config', 'start', 'database', 'providers', 'commands'];
43
+ const packageJsonPath = resolvePath(process.cwd(), 'package.json');
44
+ const root = dirname(packageJsonPath);
35
45
  let config = {};
36
46
  try {
37
47
  config = readHotHookConfig(JSON.parse(await readFile(packageJsonPath, 'utf8')));
38
48
  }
39
49
  catch {
40
- // No package.json, or unreadable: fall through to the conventional
41
- // boundaries below rather than stopping dev over it.
50
+ // No package.json, or unreadable: a project with no boundaries declared gets
51
+ // a working server that restarts on change, which is the old behaviour.
42
52
  }
43
- // `hot-hook` is an optional peer, declared by the application because it is a
44
- // dev dependency there and has no business in a production install. Imported by
45
- // specifier built at runtime so a production bundle never resolves it.
46
- function isHotHook(value) {
47
- return (typeof value === 'object' && value !== null && typeof Reflect.get(value, 'init') === 'function');
48
- }
49
- // `hot-hook` belongs to the APPLICATION: it is a dev dependency there and has
50
- // no business in a production install of the framework. So it is resolved from
51
- // the project directory rather than from this file — under pnpm's strict layout
52
- // a bare `import("hot-hook")` here looks inside @c9up/ream and finds nothing.
53
- // It is the same reason upstream passes `hot-hook/register` from the app's own
54
- // cwd instead of re-exporting it from the framework.
55
- const { createRequire } = await import('node:module');
56
- const { pathToFileURL } = await import('node:url');
57
- let hot;
58
- try {
59
- const resolved = createRequire(packageJsonPath).resolve('hot-hook');
60
- const module = await import(pathToFileURL(resolved).href);
61
- const candidate = typeof module === 'object' && module !== null ? Reflect.get(module, 'hot') : undefined;
62
- if (!isHotHook(candidate)) {
63
- throw new Error('hot-hook did not expose a `hot` object with init()');
53
+ const { boundaries = [], restart = [] } = config;
54
+ // Env files are not modules: nothing imports one, so the graph never sees them
55
+ // and an edit to `.env` did nothing at all — the values are read once, at boot.
56
+ // They always restart.
57
+ const restartFiles = new Set(envFileNames()
58
+ .map((name) => resolvePath(root, name))
59
+ .filter((file) => existsSync(file)));
60
+ /**
61
+ * `metaFiles` entries that asked for a restart.
62
+ *
63
+ * Non-module files the application owns — translations, view templates — live
64
+ * in `reamrc.ts` because the BUILD has to copy them. A change to one is
65
+ * invisible to the import graph, so the only way it can do anything in
66
+ * development is by being named here.
67
+ *
68
+ * `reloadServer: false` is the interesting default, and the one upstream picks
69
+ * for translations: the entry exists so the file ships, and an edit does NOT
70
+ * restart. NAMED DEVIATION — upstream still logs such a change, because its
71
+ * watcher covers the whole project anyway. This one watches a fixed list of
72
+ * directories on purpose (`resources/` belongs to the asset watcher, and a
73
+ * stylesheet edit must not restart the server), so a `false` entry is simply
74
+ * not watched. The observable behaviour is the same: nothing happens.
75
+ */
76
+ async function readReloadPatterns() {
77
+ try {
78
+ const rc = (await import(pathToFileURL(resolvePath(root, 'reamrc.ts')).href));
79
+ return (rc.default?.metaFiles ?? [])
80
+ .filter((entry) => entry.reloadServer === true && typeof entry.pattern === 'string')
81
+ .map((entry) => String(entry.pattern));
82
+ }
83
+ catch {
84
+ // No rc file, or one that does not load. The server itself reports a broken
85
+ // rc far more clearly than the loader could, and a dev server that refuses
86
+ // to start because of a watch list helps nobody.
87
+ return [];
64
88
  }
65
- hot = candidate;
66
89
  }
67
- catch (error) {
68
- // Loud, and it names the fix. Silence here would start a perfectly healthy
69
- // server that never picks up an edit, which reads as "HMR is broken" rather
70
- // than "HMR is not installed".
71
- //
72
- // It does NOT throw: a dev server that refuses to start is worse than one
73
- // without hot reloading, and the CLI only loads this file when it has
74
- // already seen hot-hook in the project — so reaching here means it went
75
- // missing under a running session.
76
- console.error(`[ream] hot module replacement is unavailable: ${error instanceof Error ? error.message : String(error)}\n` +
77
- '[ream] Install it with: pnpm add -D hot-hook, then restart `ream dev`.\n' +
78
- '[ream] Until then the server runs, but an edit will not be picked up.');
90
+ const reloadPatterns = await readReloadPatterns();
91
+ /**
92
+ * The directory a pattern lives under — everything before its first wildcard.
93
+ *
94
+ * `resources/lang/**\/*.json` is watched as `resources/lang`. Watching the
95
+ * project root instead would pull in `node_modules` and the build output.
96
+ */
97
+ function watchRootOf(pattern) {
98
+ const segments = pattern.replace(/^\.\//, '').split('/');
99
+ const fixed = [];
100
+ for (const segment of segments) {
101
+ if (/[*?{[]/.test(segment))
102
+ break;
103
+ fixed.push(segment);
104
+ }
105
+ // A pattern that is a bare glob has no directory to narrow to.
106
+ return fixed.slice(0, -1).join('/') || fixed.join('/');
79
107
  }
80
- // Impersonate the IPC channel upstream's dev server provides.
81
- //
82
- // hot-hook reports BOTH of its outcomes through `process.send`: a change it
83
- // swapped in place (`hot-hook:invalidated`) and one it could not
84
- // (`hot-hook:full-reload`). Under a Node parent that function exists and both
85
- // arrive; under our Rust parent it is `undefined` and both are dropped —
86
- // `onFullReloadAsked` alone recovers only half of that, leaving a hot swap
87
- // invisible to the very process it happened in, and so to the browser.
88
- //
89
- // This is not a trick played on hot-hook: it is exactly the contract it
90
- // expects, provided by us instead of by Node.
91
- const previousSend = process.send;
92
- process.send = (message, ...rest) => {
93
- const type = typeof message === 'object' && message !== null ? Reflect.get(message, 'type') : undefined;
94
- if (type === 'hot-hook:invalidated') {
95
- hotReloadHappened();
108
+ const relativeToRoot = (file) => relative(root, file).replace(/\\/g, '/');
109
+ const matchesBoundary = globMatcher(boundaries);
110
+ const matchesRestartGlob = globMatcher([...restart, ...reloadPatterns]);
111
+ const graph = new HotGraph({
112
+ isBoundary: (file) => matchesBoundary(relativeToRoot(file)),
113
+ isRestart: (file) => restartFiles.has(file) || matchesRestartGlob(relativeToRoot(file)),
114
+ });
115
+ /**
116
+ * Track every edge the resolver reports, and hand back a versioned URL for a
117
+ * module that has been invalidated.
118
+ *
119
+ * The version travels in the URL because that is the only handle V8 offers: a
120
+ * module is keyed by its URL, so a different one is a different module. The
121
+ * parameter is stripped off the importer before delegating, or a relative
122
+ * specifier would be resolved against a URL that does not name a directory.
123
+ */
124
+ registerHooks({
125
+ resolve(specifier, context, nextResolve) {
126
+ let parentURL = context.parentURL;
127
+ let parentPath;
128
+ if (typeof parentURL === 'string' && parentURL.startsWith('file:')) {
129
+ const url = new URL(parentURL);
130
+ if (url.searchParams.has(VERSION_PARAM)) {
131
+ url.searchParams.delete(VERSION_PARAM);
132
+ parentURL = url.href;
133
+ }
134
+ parentPath = fileURLToPath(url);
135
+ }
136
+ const result = nextResolve(specifier, { ...context, parentURL });
137
+ if (!result.url.startsWith('file:'))
138
+ return result;
139
+ const resolved = new URL(result.url);
140
+ resolved.searchParams.delete(VERSION_PARAM);
141
+ const file = fileURLToPath(resolved);
142
+ graph.link(file, parentPath);
143
+ const version = graph.version(file);
144
+ if (version === 0)
145
+ return result;
146
+ resolved.searchParams.set(VERSION_PARAM, String(version));
147
+ return { ...result, url: resolved.href };
148
+ },
149
+ });
150
+ /** Print a line that must survive the exit on the very next statement. */
151
+ function sayNow(line) {
152
+ // Synchronously: a piped stdout — what `ream dev` hands this process when it
153
+ // runs an asset watcher alongside — is asynchronous, and the line would be
154
+ // dropped on the way out.
155
+ try {
156
+ writeSync(1, `${line}\n`);
96
157
  }
97
- // If a real channel ever exists (embedded under a Node supervisor) it still
98
- // gets its message: this observes, it does not intercept.
99
- if (typeof previousSend === 'function') {
100
- return Reflect.apply(previousSend, process, [message, ...rest]) === true;
158
+ catch {
159
+ // The parent can close the pipe first on Ctrl-C. Losing the line is fine.
101
160
  }
102
- return true;
103
- };
104
- await hot?.init({
105
- ...config,
106
- rootDirectory: dirname(packageJsonPath),
107
- root: config.root ? resolve(dirname(packageJsonPath), config.root) : undefined,
108
- // Exiting on a known code is how the Rust parent learns it must restart —
109
- // see `EXIT_RESTART` in the CLI's dev module.
110
- onFullReloadAsked: () => process.exit(FULL_RELOAD_EXIT_CODE),
161
+ }
162
+ watchProject({
163
+ root,
164
+ directories: [
165
+ ...WATCH_DIRS,
166
+ // Whatever a `reloadServer: true` entry named, and nothing else: the
167
+ // directories above are the ones the graph can reason about.
168
+ ...reloadPatterns.map(watchRootOf).filter((dir) => dir !== ''),
169
+ ],
170
+ files: [...restartFiles].map((file) => relative(root, file)),
171
+ onChange: (file) => {
172
+ const decision = graph.decide(file);
173
+ if (decision.kind === 'ignore')
174
+ return;
175
+ if (decision.kind === 'reload') {
176
+ sayNow(fullReloadNotice(decision.file, decision.reason, relativeToRoot));
177
+ // Exiting on a known code is how the Rust parent learns it must restart —
178
+ // see `EXIT_RESTART` in the CLI's dev module.
179
+ process.exit(FULL_RELOAD_EXIT_CODE);
180
+ }
181
+ // The router caches a promoted controller per route, and the kernel drops
182
+ // that cache when this counter moves. Without it the swap happens and the
183
+ // process keeps serving the class it promoted: a stable PID and stale
184
+ // output, which is exactly how it was first reported.
185
+ hotReloadHappened();
186
+ sayNow(`[ream] hot swap — ${relativeToRoot(file)}`);
187
+ },
111
188
  });
112
189
  //# sourceMappingURL=hot.js.map
package/dist/hot.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"hot.js","sourceRoot":"","sources":["../src/hot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAsB,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE1E,mFAAmF;AACnF,MAAM,qBAAqB,GAAG,EAAE,CAAA;AAchC,MAAM,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AAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAA;YACxE,0EAA0E;YAC1E,8CAA8C;YAC9C,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;QACrC,CAAC;QACD,0EAA0E;QAC1E,0EAA0E;QAC1E,sEAAsE;QACtE,sDAAsD;QACtD,iBAAiB,EAAE,CAAA;QACnB,MAAM,CAAC,qBAAqB,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACrD,CAAC;CACF,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -121,5 +121,5 @@ export { BaseEvent, Emitter, type EmitterResolver, type ListenerClass, } from '.
121
121
  export { type BufferedEvent, type BufferedEventName, type EventFinder, EventsBuffer, } from './events/EventsBuffer.js';
122
122
  export type { ErrorReporter, LockBackend, LockBackendFactory, LockRedisClient, LockRedisResolver, RunTaskOutcome, ScheduleEvent, ScheduleEventSink, ScheduleInvocation, ScheduleMetadata, ScheduleProviderOptions, SchedulerConfig, SchedulerOptions, ScheduleTaskCompletedEvent, ScheduleTaskFailedEvent, ScheduleTaskSkippedEvent, ScheduleTaskStartedEvent, TaskInfo, TaskStats, } from './scheduler/index.js';
123
123
  export { defineSchedulerConfig, getScheduleMetadata, locks, MemoryLockBackend, RedisLockBackend, SCHEDULE_METADATA_KEY, Schedule, ScheduleProvider, Scheduler, StatsTracker, } from './scheduler/index.js';
124
- export declare const VERSION = "0.2.23";
124
+ export declare const VERSION = "0.2.25";
125
125
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -92,5 +92,5 @@ export { defineConfig as defineEventsConfig } from './events/config.js';
92
92
  export { BaseEvent, Emitter, } from './events/Emitter.js';
93
93
  export { EventsBuffer, } from './events/EventsBuffer.js';
94
94
  export { defineSchedulerConfig, getScheduleMetadata, locks, MemoryLockBackend, RedisLockBackend, SCHEDULE_METADATA_KEY, Schedule, ScheduleProvider, Scheduler, StatsTracker, } from './scheduler/index.js';
95
- export const VERSION = '0.2.23';
95
+ export const VERSION = '0.2.25';
96
96
  //# sourceMappingURL=index.js.map
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@c9up/ream",
3
- "version": "0.2.23",
3
+ "version": "0.2.25",
4
4
  "description": "Ream — Rust-powered Node.js application framework",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -233,8 +233,7 @@
233
233
  },
234
234
  "peerDependencies": {
235
235
  "@c9up/comet": "^0.1.0",
236
- "@c9up/quasar": "^0.1.0 || ^0.2.0",
237
- "hot-hook": "^1.0.0"
236
+ "@c9up/quasar": "^0.1.0 || ^0.2.0"
238
237
  },
239
238
  "peerDependenciesMeta": {
240
239
  "@c9up/comet": {
@@ -242,9 +241,6 @@
242
241
  },
243
242
  "@c9up/quasar": {
244
243
  "optional": true
245
- },
246
- "hot-hook": {
247
- "optional": true
248
244
  }
249
245
  },
250
246
  "devDependencies": {
@@ -257,8 +253,9 @@
257
253
  "typescript": "^6.0.3",
258
254
  "vitest": "4.1.11"
259
255
  },
256
+ "//engines": "Node 24, not 22, because AsyncLocalStorage sits on the request hot path — the container resolves through it, HttpContext is it, and the emitter reads it on every event. Node 24 backs it with AsyncContextFrame by default, and measured on that exact pattern (one context per request, six async boundaries, several reads) it costs 0.61 us per request instead of 1.55 us: 2.5x, on every request, for free. Before 24 the same mechanism existed only behind an experimental flag, and a framework cannot base its performance on a flag the application has to remember to pass. This is NOT 'track the current LTS' — security fixes still land in 22 until 2027, npm 11 is irrelevant under pnpm, and node:sqlite is not what atlas uses.",
260
257
  "engines": {
261
- "node": ">=22.0.0"
258
+ "node": ">=24.0.0"
262
259
  },
263
260
  "publishConfig": {
264
261
  "access": "public"
Binary file
Binary file
Binary file
Binary file
Binary file