@camstack/server 1.2.283 → 1.2.285
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.purgeRequireCacheUnder = purgeRequireCacheUnder;
|
|
7
|
+
exports.bundleGraphRootFor = bundleGraphRootFor;
|
|
8
|
+
/**
|
|
9
|
+
* require-cache — evicting an addon's own modules so a hot-updated bundle
|
|
10
|
+
* is actually re-read.
|
|
11
|
+
*
|
|
12
|
+
* Lives in its own file because the behaviour it encodes is a Node semantic
|
|
13
|
+
* that cannot be observed from inside the test runner: the runner transforms
|
|
14
|
+
* modules itself, so only a real `node` process re-executing a real CommonJS
|
|
15
|
+
* file proves anything. `require-cache.spec.ts` spawns one.
|
|
16
|
+
*/
|
|
17
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
18
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
19
|
+
/**
|
|
20
|
+
* Drop every `require`-cached module that lives under `dir`.
|
|
21
|
+
*
|
|
22
|
+
* Node's ESM loader serves a CommonJS module from the require cache, keyed by
|
|
23
|
+
* the resolved filename — the `?t=` query an ESM import uses to force a re-read
|
|
24
|
+
* is stripped before that lookup and therefore does nothing. Since every addon
|
|
25
|
+
* bundle here is CJS, evicting the addon's own entries is what makes a
|
|
26
|
+
* hot-updated bundle actually load.
|
|
27
|
+
*
|
|
28
|
+
* Matched against the REAL path as well as the given one. Node keys the cache
|
|
29
|
+
* by the resolved-and-symlink-followed filename, while an addon directory is
|
|
30
|
+
* assembled from the configured `dataDir` and never realpath'd — so a single
|
|
31
|
+
* symlink anywhere above it (a `dataDir` under macOS's `/tmp`, a relocated data
|
|
32
|
+
* root) makes a prefix match on the given path miss every entry and this
|
|
33
|
+
* function silently do nothing. Which is precisely the failure it exists to
|
|
34
|
+
* fix, wearing its clothes: the catalog would look refreshed and be stale.
|
|
35
|
+
*
|
|
36
|
+
* Scoped to one directory on purpose: a blanket cache clear would evict the
|
|
37
|
+
* hub's own modules and every other addon's, turning a catalog refresh into a
|
|
38
|
+
* process-wide reload. Best-effort — a cache that cannot be walked leaves the
|
|
39
|
+
* previous (stale) behaviour rather than failing the caller.
|
|
40
|
+
*
|
|
41
|
+
* **The directory must be the whole BUNDLE, never the entry's own folder** —
|
|
42
|
+
* see {@link bundleGraphRootFor}. A narrower scope purges half a module graph,
|
|
43
|
+
* which is worse than purging none of it.
|
|
44
|
+
*/
|
|
45
|
+
function purgeRequireCacheUnder(dir) {
|
|
46
|
+
try {
|
|
47
|
+
const cache = require.cache;
|
|
48
|
+
if (cache === undefined)
|
|
49
|
+
return;
|
|
50
|
+
const prefixes = candidatePrefixes(dir);
|
|
51
|
+
for (const key of Object.keys(cache)) {
|
|
52
|
+
if (prefixes.some((prefix) => key.startsWith(prefix)))
|
|
53
|
+
delete cache[key];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
// Non-CJS host, or a frozen cache. The caller's import still runs.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The directory that holds one addon bundle's WHOLE module graph.
|
|
62
|
+
*
|
|
63
|
+
* A multi-entry bundle does not live under its entry's folder. Every addon in
|
|
64
|
+
* this repo builds through `tools/build/vite-lib.preset.ts`, whose entries are
|
|
65
|
+
* `dist/<addon>/index.js` — and whose SHARED CHUNKS (`dist/dist-<hash>.js`,
|
|
66
|
+
* `dist/node-<hash>.js`, …) sit one level up, in `dist/`. Purging
|
|
67
|
+
* `dirname(entryPath)` therefore evicts the entry and leaves the chunks, so the
|
|
68
|
+
* re-import RE-EXECUTES the entry against module state that was never reset.
|
|
69
|
+
*
|
|
70
|
+
* That is not a stale-cache bug, it is a corrupted one, and it took the hub's
|
|
71
|
+
* `stream-broker` down on 2026-08-29: the entry chunk carries
|
|
72
|
+
* `log-channels.ts`'s module-scope `declareLogChannel` calls while the
|
|
73
|
+
* `LogChannelRegistry` singleton they write to is inlined into the shared
|
|
74
|
+
* chunk. Half the graph re-ran, the registry did not, and the second
|
|
75
|
+
* declaration threw `log channel "stream-broker.webrtc" is already declared in
|
|
76
|
+
* this process` — a message that is correct, and that named the loader rather
|
|
77
|
+
* than the addon. `dist/` is the unit the bundler emits, so `dist/` is the unit
|
|
78
|
+
* the cache is purged in.
|
|
79
|
+
*
|
|
80
|
+
* `node_modules/` under the addon is deliberately OUTSIDE this root: a package
|
|
81
|
+
* that declares `camstack.nativeDependencies` installs `.node` bindings there,
|
|
82
|
+
* and re-`dlopen`ing a native addon is not a refresh, it is a coin flip.
|
|
83
|
+
*
|
|
84
|
+
* Falls back to the entry's directory when there is no `dist/` above it (a
|
|
85
|
+
* loose `loadFromPath` module in a test or a dev tree) — the historical
|
|
86
|
+
* behaviour, for the shape that has no bundle.
|
|
87
|
+
*/
|
|
88
|
+
function bundleGraphRootFor(addonDir, entryPath) {
|
|
89
|
+
const distDir = node_path_1.default.resolve(addonDir, 'dist');
|
|
90
|
+
const withSep = distDir.endsWith(node_path_1.default.sep) ? distDir : `${distDir}${node_path_1.default.sep}`;
|
|
91
|
+
return entryPath.startsWith(withSep) ? distDir : node_path_1.default.dirname(entryPath);
|
|
92
|
+
}
|
|
93
|
+
/** The directory as given and as Node sees it, both as trailing-separator prefixes. */
|
|
94
|
+
function candidatePrefixes(dir) {
|
|
95
|
+
const withSep = (d) => (d.endsWith(node_path_1.default.sep) ? d : `${d}${node_path_1.default.sep}`);
|
|
96
|
+
const given = withSep(dir);
|
|
97
|
+
let real = given;
|
|
98
|
+
try {
|
|
99
|
+
real = withSep(node_fs_1.default.realpathSync(dir));
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
// Directory gone between the caller's existsSync and here — `given` alone
|
|
103
|
+
// is still a correct (if narrower) match.
|
|
104
|
+
}
|
|
105
|
+
return real === given ? [given] : [given, real];
|
|
106
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.285",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
]
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@camstack/addon-admin-ui": "
|
|
39
|
-
"@camstack/addon-agent-ui": "
|
|
40
|
-
"@camstack/addon-auth": "
|
|
41
|
-
"@camstack/addon-decoder-nodeav": "
|
|
42
|
-
"@camstack/addon-notifiers": "
|
|
43
|
-
"@camstack/addon-pipeline": "
|
|
44
|
-
"@camstack/addon-pipeline-orchestrator": "
|
|
45
|
-
"@camstack/addon-post-analysis": "
|
|
46
|
-
"@camstack/sdk": "
|
|
47
|
-
"@camstack/system": "
|
|
48
|
-
"@camstack/types": "
|
|
49
|
-
"@camstack/ui-library": "
|
|
38
|
+
"@camstack/addon-admin-ui": "*",
|
|
39
|
+
"@camstack/addon-agent-ui": "*",
|
|
40
|
+
"@camstack/addon-auth": "*",
|
|
41
|
+
"@camstack/addon-decoder-nodeav": "*",
|
|
42
|
+
"@camstack/addon-notifiers": "*",
|
|
43
|
+
"@camstack/addon-pipeline": "*",
|
|
44
|
+
"@camstack/addon-pipeline-orchestrator": "*",
|
|
45
|
+
"@camstack/addon-post-analysis": "*",
|
|
46
|
+
"@camstack/sdk": "*",
|
|
47
|
+
"@camstack/system": "*",
|
|
48
|
+
"@camstack/types": "*",
|
|
49
|
+
"@camstack/ui-library": "*",
|
|
50
50
|
"@fastify/compress": "^9.0.0",
|
|
51
51
|
"@fastify/cookie": "^11.0.2",
|
|
52
52
|
"@fastify/cors": "^11.2.0",
|