@shaykec/bridge 0.4.24 → 0.4.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.
- package/package.json +5 -3
- package/src/server.js +17 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shaykec/bridge",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.25",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Communication hub — HTTP + WebSocket + SSE server with template engine",
|
|
6
6
|
"main": "src/server.js",
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"start": "node src/server.js",
|
|
16
|
-
"test": "vitest run --config ../../vitest.config.js"
|
|
16
|
+
"test": "vitest run --config ../../vitest.config.js",
|
|
17
|
+
"prepack": "cp -r ../modules ./modules && cp -r ../journeys ./journeys",
|
|
18
|
+
"postpack": "rm -rf ./modules ./journeys"
|
|
17
19
|
},
|
|
18
20
|
"publishConfig": {
|
|
19
21
|
"access": "public"
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
"license": "MIT",
|
|
22
24
|
"dependencies": {
|
|
23
25
|
"@shaykec/agent-web": "^0.3.0",
|
|
24
|
-
"@shaykec/shared": "0.1.
|
|
26
|
+
"@shaykec/shared": "0.1.8",
|
|
25
27
|
"node-pty": "^1.1.0",
|
|
26
28
|
"ws": "^8.16.0"
|
|
27
29
|
}
|
package/src/server.js
CHANGED
|
@@ -76,6 +76,16 @@ const CANVAS_DIST = existsSync(join(CANVAS_DIST_BUNDLED, 'index.html'))
|
|
|
76
76
|
? CANVAS_DIST_BUNDLED
|
|
77
77
|
: CANVAS_DIST_MONOREPO;
|
|
78
78
|
|
|
79
|
+
/** Resolve a data directory — check bundled (npx) first, then monorepo layout */
|
|
80
|
+
function resolveDataDir(name) {
|
|
81
|
+
const bundled = resolve(__dirname, '..', name);
|
|
82
|
+
if (existsSync(bundled)) return bundled;
|
|
83
|
+
return resolve(__dirname, '..', '..', name);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const MODULES_DIR = resolveDataDir('modules');
|
|
87
|
+
const JOURNEYS_DIR = resolveDataDir('journeys');
|
|
88
|
+
|
|
79
89
|
/** MIME types for static file serving */
|
|
80
90
|
const MIME_TYPES = {
|
|
81
91
|
'.html': 'text/html',
|
|
@@ -858,7 +868,7 @@ function handleApiProgress(res, options) {
|
|
|
858
868
|
}
|
|
859
869
|
|
|
860
870
|
// Enrich modules with catalog metadata
|
|
861
|
-
const modulesDir =
|
|
871
|
+
const modulesDir = MODULES_DIR;
|
|
862
872
|
const moduleMap = buildModuleMap(modulesDir);
|
|
863
873
|
progress.modules = enrichModulesWithMetadata(progress.modules, moduleMap);
|
|
864
874
|
|
|
@@ -902,7 +912,7 @@ function handleApiProgress(res, options) {
|
|
|
902
912
|
* GET /api/modules — return module catalog from built-in + installed modules.
|
|
903
913
|
*/
|
|
904
914
|
function handleApiModules(res) {
|
|
905
|
-
const modulesDir =
|
|
915
|
+
const modulesDir = MODULES_DIR;
|
|
906
916
|
const modules = [];
|
|
907
917
|
|
|
908
918
|
try {
|
|
@@ -955,7 +965,7 @@ function handleApiModules(res) {
|
|
|
955
965
|
*/
|
|
956
966
|
function handleApiJourneys(res, options) {
|
|
957
967
|
try {
|
|
958
|
-
const journeysDir =
|
|
968
|
+
const journeysDir = JOURNEYS_DIR;
|
|
959
969
|
const journeys = [];
|
|
960
970
|
|
|
961
971
|
if (existsSync(journeysDir)) {
|
|
@@ -976,7 +986,7 @@ function handleApiJourneys(res, options) {
|
|
|
976
986
|
progress = options.progressProvider.getProgress();
|
|
977
987
|
}
|
|
978
988
|
|
|
979
|
-
const modulesDir =
|
|
989
|
+
const modulesDir = MODULES_DIR;
|
|
980
990
|
const moduleMap = buildModuleMap(modulesDir);
|
|
981
991
|
|
|
982
992
|
const resolved = journeys.map(j => resolveJourneyForApi(j, moduleMap, progress));
|
|
@@ -1276,7 +1286,7 @@ function handleApiProgressWrite(req, res, options, router) {
|
|
|
1276
1286
|
|
|
1277
1287
|
// Broadcast updated progress to connected canvas clients (enriched with catalog metadata)
|
|
1278
1288
|
if (router) {
|
|
1279
|
-
const modulesDir =
|
|
1289
|
+
const modulesDir = MODULES_DIR;
|
|
1280
1290
|
const moduleMap = buildModuleMap(modulesDir);
|
|
1281
1291
|
const enriched = enrichModulesWithMetadata(progress.modules, moduleMap);
|
|
1282
1292
|
const modules = Object.entries(enriched).map(([slug, m]) => ({ slug, ...m }));
|
|
@@ -1303,7 +1313,7 @@ function handleApiProgressWrite(req, res, options, router) {
|
|
|
1303
1313
|
* GET /api/module/:slug — serve full module content.
|
|
1304
1314
|
*/
|
|
1305
1315
|
function handleApiModuleContent(res, slug) {
|
|
1306
|
-
const modulesDir =
|
|
1316
|
+
const modulesDir = MODULES_DIR;
|
|
1307
1317
|
const moduleDir = join(modulesDir, slug);
|
|
1308
1318
|
|
|
1309
1319
|
if (!existsSync(join(moduleDir, 'module.yaml'))) {
|
|
@@ -1382,7 +1392,7 @@ function handleApiModuleResource(res, slug, filename) {
|
|
|
1382
1392
|
return;
|
|
1383
1393
|
}
|
|
1384
1394
|
|
|
1385
|
-
const modulesDir =
|
|
1395
|
+
const modulesDir = MODULES_DIR;
|
|
1386
1396
|
const filePath = join(modulesDir, slug, 'resources', filename);
|
|
1387
1397
|
|
|
1388
1398
|
if (!existsSync(filePath)) {
|