@bytespell/shella 0.1.13 → 0.1.15
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/dist/bin/cli.js +83 -40
- package/dist/bin/cli.js.map +1 -1
- package/dist/index.js +83 -40
- package/dist/index.js.map +1 -1
- package/dist/public/assets/{_baseUniq-EGFlDlSf.js → _baseUniq-rFeuIcJP.js} +1 -1
- package/{public/assets/arc-BmFavzWc.js → dist/public/assets/arc-Ciq1-gt2.js} +1 -1
- package/{public/assets/architectureDiagram-VXUJARFQ-CZnDNYtj.js → dist/public/assets/architectureDiagram-VXUJARFQ-DQOTLTYJ.js} +1 -1
- package/{public/assets/blockDiagram-VD42YOAC-CabGM_NX.js → dist/public/assets/blockDiagram-VD42YOAC-DrkXLslH.js} +1 -1
- package/dist/public/assets/{c4Diagram-YG6GDRKO-BTq0tfrY.js → c4Diagram-YG6GDRKO-CGep4UQM.js} +1 -1
- package/dist/public/assets/channel-EWtlBi79.js +1 -0
- package/dist/public/assets/{chunk-4BX2VUAB-DP2HLRAj.js → chunk-4BX2VUAB-DXU1pWcl.js} +1 -1
- package/dist/public/assets/{chunk-55IACEB6-_ByWPNnF.js → chunk-55IACEB6-Bx-cpVYk.js} +1 -1
- package/{public/assets/chunk-B4BG7PRW-BkPl9d2w.js → dist/public/assets/chunk-B4BG7PRW-DN5-a04I.js} +1 -1
- package/{public/assets/chunk-DI55MBZ5-Bx6nm2tL.js → dist/public/assets/chunk-DI55MBZ5-CO01g9LM.js} +1 -1
- package/dist/public/assets/{chunk-FMBD7UC4-DZpP7ydN.js → chunk-FMBD7UC4-B2M8wU-E.js} +1 -1
- package/dist/public/assets/{chunk-QN33PNHL-DSX4eX_h.js → chunk-QN33PNHL-ZWjnlJD9.js} +1 -1
- package/dist/public/assets/{chunk-QZHKN3VN-1uzZkVFg.js → chunk-QZHKN3VN-CB-E8xvs.js} +1 -1
- package/dist/public/assets/{chunk-TZMSLE5B-BwKElFeo.js → chunk-TZMSLE5B-C7K7-xdt.js} +1 -1
- package/dist/public/assets/classDiagram-2ON5EDUG-Bhl8gu7O.js +1 -0
- package/dist/public/assets/classDiagram-v2-WZHVMYZB-Bhl8gu7O.js +1 -0
- package/dist/public/assets/clone-DGIXUqRz.js +1 -0
- package/dist/public/assets/{code-block-IT6T5CEO-BoXZl_RQ.js → code-block-IT6T5CEO-oEJfzIXW.js} +1 -1
- package/dist/public/assets/{cose-bilkent-S5V4N54A-Dux9YKGp.js → cose-bilkent-S5V4N54A-Byu8718_.js} +1 -1
- package/dist/public/assets/{dagre-6UL2VRFP-Bcdq9Aj5.js → dagre-6UL2VRFP-C2C-oI3k.js} +1 -1
- package/dist/public/assets/{diagram-PSM6KHXK-CA-sK31I.js → diagram-PSM6KHXK-Bc_wpePT.js} +1 -1
- package/dist/public/assets/{diagram-QEK2KX5R-De47GBMW.js → diagram-QEK2KX5R-R_dh2lcc.js} +1 -1
- package/dist/public/assets/{diagram-S2PKOQOG-DJm2AaGk.js → diagram-S2PKOQOG-CtO72gsq.js} +1 -1
- package/{public/assets/erDiagram-Q2GNP2WA-Lu5P0RSi.js → dist/public/assets/erDiagram-Q2GNP2WA-NyJ20Tcw.js} +1 -1
- package/{public/assets/flowDiagram-NV44I4VS-DflY4Ld4.js → dist/public/assets/flowDiagram-NV44I4VS-Cd0USqQr.js} +1 -1
- package/dist/public/assets/{ganttDiagram-JELNMOA3-B8jvAfhh.js → ganttDiagram-JELNMOA3-CAanRDED.js} +1 -1
- package/dist/public/assets/{gitGraphDiagram-NY62KEGX-B5ATDGVE.js → gitGraphDiagram-NY62KEGX-Cfsu6ghS.js} +1 -1
- package/dist/public/assets/{graph-8Q4ZN1_7.js → graph-QKFq9c4B.js} +1 -1
- package/dist/public/assets/{index-BEOKXaJG.js → index-BVgUdnkK.js} +1 -1
- package/dist/public/assets/{index-DRWhjxj6.js → index-CnzhCX95.js} +127 -127
- package/dist/public/assets/index-DAuITrPV.css +1 -0
- package/dist/public/assets/{infoDiagram-WHAUD3N6-qrN7AH1w.js → infoDiagram-WHAUD3N6-Dj8jXmxi.js} +1 -1
- package/dist/public/assets/{journeyDiagram-XKPGCS4Q-CnL6w_Jf.js → journeyDiagram-XKPGCS4Q-CPgbzNru.js} +1 -1
- package/{public/assets/kanban-definition-3W4ZIXB7-tuy_lNx5.js → dist/public/assets/kanban-definition-3W4ZIXB7-WJ4DpsDz.js} +1 -1
- package/dist/public/assets/{layout-BCBlc1xg.js → layout-CYzA-TWJ.js} +1 -1
- package/dist/public/assets/{linear-BzyanBSW.js → linear--TKGjpXE.js} +1 -1
- package/dist/public/assets/{mermaid.core-CKdMcV_T.js → mermaid.core-Cf8Vm-zi.js} +5 -5
- package/dist/public/assets/{min-CQR8eUcq.js → min-TcvkLLDD.js} +1 -1
- package/dist/public/assets/{mindmap-definition-VGOIOE7T-fQec8JxD.js → mindmap-definition-VGOIOE7T-Cn1Dyi7A.js} +1 -1
- package/dist/public/assets/{pieDiagram-ADFJNKIX-BrLsJv83.js → pieDiagram-ADFJNKIX-D62bbfWm.js} +1 -1
- package/{public/assets/quadrantDiagram-AYHSOK5B-BPHHSjXt.js → dist/public/assets/quadrantDiagram-AYHSOK5B-8_KQ7LcH.js} +1 -1
- package/dist/public/assets/{requirementDiagram-UZGBJVZJ-Bb93lhEQ.js → requirementDiagram-UZGBJVZJ-Cux_-KLZ.js} +1 -1
- package/{public/assets/sankeyDiagram-TZEHDZUN-CDK30tx7.js → dist/public/assets/sankeyDiagram-TZEHDZUN-SGGXtbp5.js} +1 -1
- package/dist/public/assets/{sequenceDiagram-WL72ISMW-B2WQiW_k.js → sequenceDiagram-WL72ISMW-BmSoaDsd.js} +1 -1
- package/{public/assets/stateDiagram-FKZM4ZOC-uM1w_xjr.js → dist/public/assets/stateDiagram-FKZM4ZOC-laPJWPGD.js} +1 -1
- package/dist/public/assets/stateDiagram-v2-4FDKWEC3-uyrwe5Bi.js +1 -0
- package/{public/assets/timeline-definition-IT6M3QCI-07DImEJ7.js → dist/public/assets/timeline-definition-IT6M3QCI-DnEEd3PS.js} +1 -1
- package/dist/public/assets/{treemap-KMMF4GRG-N0jjjXe0.js → treemap-KMMF4GRG-CEr_nAYt.js} +1 -1
- package/{public/assets/xychartDiagram-PRI3JC2R-BV-5VcHE.js → dist/public/assets/xychartDiagram-PRI3JC2R-BA6uWNes.js} +1 -1
- package/dist/public/index.html +3 -3
- package/package.json +1 -1
- package/public/assets/{_baseUniq-EGFlDlSf.js → _baseUniq-rFeuIcJP.js} +1 -1
- package/{dist/public/assets/arc-BmFavzWc.js → public/assets/arc-Ciq1-gt2.js} +1 -1
- package/{dist/public/assets/architectureDiagram-VXUJARFQ-CZnDNYtj.js → public/assets/architectureDiagram-VXUJARFQ-DQOTLTYJ.js} +1 -1
- package/{dist/public/assets/blockDiagram-VD42YOAC-CabGM_NX.js → public/assets/blockDiagram-VD42YOAC-DrkXLslH.js} +1 -1
- package/public/assets/{c4Diagram-YG6GDRKO-BTq0tfrY.js → c4Diagram-YG6GDRKO-CGep4UQM.js} +1 -1
- package/public/assets/channel-EWtlBi79.js +1 -0
- package/public/assets/{chunk-4BX2VUAB-DP2HLRAj.js → chunk-4BX2VUAB-DXU1pWcl.js} +1 -1
- package/public/assets/{chunk-55IACEB6-_ByWPNnF.js → chunk-55IACEB6-Bx-cpVYk.js} +1 -1
- package/{dist/public/assets/chunk-B4BG7PRW-BkPl9d2w.js → public/assets/chunk-B4BG7PRW-DN5-a04I.js} +1 -1
- package/{dist/public/assets/chunk-DI55MBZ5-Bx6nm2tL.js → public/assets/chunk-DI55MBZ5-CO01g9LM.js} +1 -1
- package/public/assets/{chunk-FMBD7UC4-DZpP7ydN.js → chunk-FMBD7UC4-B2M8wU-E.js} +1 -1
- package/public/assets/{chunk-QN33PNHL-DSX4eX_h.js → chunk-QN33PNHL-ZWjnlJD9.js} +1 -1
- package/public/assets/{chunk-QZHKN3VN-1uzZkVFg.js → chunk-QZHKN3VN-CB-E8xvs.js} +1 -1
- package/public/assets/{chunk-TZMSLE5B-BwKElFeo.js → chunk-TZMSLE5B-C7K7-xdt.js} +1 -1
- package/public/assets/classDiagram-2ON5EDUG-Bhl8gu7O.js +1 -0
- package/public/assets/classDiagram-v2-WZHVMYZB-Bhl8gu7O.js +1 -0
- package/public/assets/clone-DGIXUqRz.js +1 -0
- package/public/assets/{code-block-IT6T5CEO-BoXZl_RQ.js → code-block-IT6T5CEO-oEJfzIXW.js} +1 -1
- package/public/assets/{cose-bilkent-S5V4N54A-Dux9YKGp.js → cose-bilkent-S5V4N54A-Byu8718_.js} +1 -1
- package/public/assets/{dagre-6UL2VRFP-Bcdq9Aj5.js → dagre-6UL2VRFP-C2C-oI3k.js} +1 -1
- package/public/assets/{diagram-PSM6KHXK-CA-sK31I.js → diagram-PSM6KHXK-Bc_wpePT.js} +1 -1
- package/public/assets/{diagram-QEK2KX5R-De47GBMW.js → diagram-QEK2KX5R-R_dh2lcc.js} +1 -1
- package/public/assets/{diagram-S2PKOQOG-DJm2AaGk.js → diagram-S2PKOQOG-CtO72gsq.js} +1 -1
- package/{dist/public/assets/erDiagram-Q2GNP2WA-Lu5P0RSi.js → public/assets/erDiagram-Q2GNP2WA-NyJ20Tcw.js} +1 -1
- package/{dist/public/assets/flowDiagram-NV44I4VS-DflY4Ld4.js → public/assets/flowDiagram-NV44I4VS-Cd0USqQr.js} +1 -1
- package/public/assets/{ganttDiagram-JELNMOA3-B8jvAfhh.js → ganttDiagram-JELNMOA3-CAanRDED.js} +1 -1
- package/public/assets/{gitGraphDiagram-NY62KEGX-B5ATDGVE.js → gitGraphDiagram-NY62KEGX-Cfsu6ghS.js} +1 -1
- package/public/assets/{graph-8Q4ZN1_7.js → graph-QKFq9c4B.js} +1 -1
- package/public/assets/{index-BEOKXaJG.js → index-BVgUdnkK.js} +1 -1
- package/public/assets/{index-DRWhjxj6.js → index-CnzhCX95.js} +127 -127
- package/public/assets/index-DAuITrPV.css +1 -0
- package/public/assets/{infoDiagram-WHAUD3N6-qrN7AH1w.js → infoDiagram-WHAUD3N6-Dj8jXmxi.js} +1 -1
- package/public/assets/{journeyDiagram-XKPGCS4Q-CnL6w_Jf.js → journeyDiagram-XKPGCS4Q-CPgbzNru.js} +1 -1
- package/{dist/public/assets/kanban-definition-3W4ZIXB7-tuy_lNx5.js → public/assets/kanban-definition-3W4ZIXB7-WJ4DpsDz.js} +1 -1
- package/public/assets/{layout-BCBlc1xg.js → layout-CYzA-TWJ.js} +1 -1
- package/public/assets/{linear-BzyanBSW.js → linear--TKGjpXE.js} +1 -1
- package/public/assets/{mermaid.core-CKdMcV_T.js → mermaid.core-Cf8Vm-zi.js} +5 -5
- package/public/assets/{min-CQR8eUcq.js → min-TcvkLLDD.js} +1 -1
- package/public/assets/{mindmap-definition-VGOIOE7T-fQec8JxD.js → mindmap-definition-VGOIOE7T-Cn1Dyi7A.js} +1 -1
- package/public/assets/{pieDiagram-ADFJNKIX-BrLsJv83.js → pieDiagram-ADFJNKIX-D62bbfWm.js} +1 -1
- package/{dist/public/assets/quadrantDiagram-AYHSOK5B-BPHHSjXt.js → public/assets/quadrantDiagram-AYHSOK5B-8_KQ7LcH.js} +1 -1
- package/public/assets/{requirementDiagram-UZGBJVZJ-Bb93lhEQ.js → requirementDiagram-UZGBJVZJ-Cux_-KLZ.js} +1 -1
- package/{dist/public/assets/sankeyDiagram-TZEHDZUN-CDK30tx7.js → public/assets/sankeyDiagram-TZEHDZUN-SGGXtbp5.js} +1 -1
- package/public/assets/{sequenceDiagram-WL72ISMW-B2WQiW_k.js → sequenceDiagram-WL72ISMW-BmSoaDsd.js} +1 -1
- package/{dist/public/assets/stateDiagram-FKZM4ZOC-uM1w_xjr.js → public/assets/stateDiagram-FKZM4ZOC-laPJWPGD.js} +1 -1
- package/public/assets/stateDiagram-v2-4FDKWEC3-uyrwe5Bi.js +1 -0
- package/{dist/public/assets/timeline-definition-IT6M3QCI-07DImEJ7.js → public/assets/timeline-definition-IT6M3QCI-DnEEd3PS.js} +1 -1
- package/public/assets/{treemap-KMMF4GRG-N0jjjXe0.js → treemap-KMMF4GRG-CEr_nAYt.js} +1 -1
- package/{dist/public/assets/xychartDiagram-PRI3JC2R-BV-5VcHE.js → public/assets/xychartDiagram-PRI3JC2R-BA6uWNes.js} +1 -1
- package/public/index.html +3 -3
- package/dist/public/assets/channel-CNSk0Rnk.js +0 -1
- package/dist/public/assets/classDiagram-2ON5EDUG-CNctsmkW.js +0 -1
- package/dist/public/assets/classDiagram-v2-WZHVMYZB-CNctsmkW.js +0 -1
- package/dist/public/assets/clone-CUs-4v14.js +0 -1
- package/dist/public/assets/index-B-jh1L5n.css +0 -1
- package/dist/public/assets/stateDiagram-v2-4FDKWEC3-BGfXuXW9.js +0 -1
- package/public/assets/channel-CNSk0Rnk.js +0 -1
- package/public/assets/classDiagram-2ON5EDUG-CNctsmkW.js +0 -1
- package/public/assets/classDiagram-v2-WZHVMYZB-CNctsmkW.js +0 -1
- package/public/assets/clone-CUs-4v14.js +0 -1
- package/public/assets/index-B-jh1L5n.css +0 -1
- package/public/assets/stateDiagram-v2-4FDKWEC3-BGfXuXW9.js +0 -1
package/dist/bin/cli.js
CHANGED
|
@@ -15,7 +15,7 @@ import * as p from "@clack/prompts";
|
|
|
15
15
|
import express from "express";
|
|
16
16
|
import { createServer } from "http";
|
|
17
17
|
import { WebSocketServer } from "ws";
|
|
18
|
-
import
|
|
18
|
+
import path10 from "path";
|
|
19
19
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
20
20
|
import { createExpressMiddleware } from "@trpc/server/adapters/express";
|
|
21
21
|
import { applyWSSHandler } from "@trpc/server/adapters/ws";
|
|
@@ -881,13 +881,13 @@ function getAllPaneIds(node) {
|
|
|
881
881
|
}
|
|
882
882
|
return [...getAllPaneIds(node.first), ...getAllPaneIds(node.second)];
|
|
883
883
|
}
|
|
884
|
-
function findPanePath(node, paneId,
|
|
884
|
+
function findPanePath(node, paneId, path11 = []) {
|
|
885
885
|
if (node.type === "leaf") {
|
|
886
|
-
return node.paneId === paneId ?
|
|
886
|
+
return node.paneId === paneId ? path11 : null;
|
|
887
887
|
}
|
|
888
|
-
const firstPath = findPanePath(node.first, paneId, [...
|
|
888
|
+
const firstPath = findPanePath(node.first, paneId, [...path11, "first"]);
|
|
889
889
|
if (firstPath) return firstPath;
|
|
890
|
-
return findPanePath(node.second, paneId, [...
|
|
890
|
+
return findPanePath(node.second, paneId, [...path11, "second"]);
|
|
891
891
|
}
|
|
892
892
|
function replacePaneWithNode(root, paneId, newNode) {
|
|
893
893
|
if (root.type === "leaf") {
|
|
@@ -924,15 +924,15 @@ function removePane(root, paneId) {
|
|
|
924
924
|
}
|
|
925
925
|
return root;
|
|
926
926
|
}
|
|
927
|
-
function updateRatio(root,
|
|
928
|
-
if (
|
|
927
|
+
function updateRatio(root, path11, newRatio) {
|
|
928
|
+
if (path11.length === 0) {
|
|
929
929
|
if (root.type === "branch") {
|
|
930
930
|
return { ...root, ratio: Math.max(10, Math.min(90, newRatio)) };
|
|
931
931
|
}
|
|
932
932
|
return root;
|
|
933
933
|
}
|
|
934
934
|
if (root.type === "leaf") return root;
|
|
935
|
-
const [next, ...rest] =
|
|
935
|
+
const [next, ...rest] = path11;
|
|
936
936
|
if (next === "first") {
|
|
937
937
|
return { ...root, first: updateRatio(root.first, rest, newRatio) };
|
|
938
938
|
} else {
|
|
@@ -940,11 +940,11 @@ function updateRatio(root, path9, newRatio) {
|
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
942
|
function getAdjacentPane(root, currentPaneId, direction) {
|
|
943
|
-
const
|
|
944
|
-
if (!
|
|
943
|
+
const path11 = findPanePath(root, currentPaneId);
|
|
944
|
+
if (!path11) return null;
|
|
945
945
|
let node = root;
|
|
946
946
|
const pathNodes = [];
|
|
947
|
-
for (const step of
|
|
947
|
+
for (const step of path11) {
|
|
948
948
|
if (node.type === "branch") {
|
|
949
949
|
pathNodes.push({ node, childSide: step });
|
|
950
950
|
node = step === "first" ? node.first : node.second;
|
|
@@ -1138,7 +1138,18 @@ var windowsRouter = router({
|
|
|
1138
1138
|
// src/trpc/layout.ts
|
|
1139
1139
|
import { z as z2 } from "zod";
|
|
1140
1140
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
1141
|
+
import * as path6 from "path";
|
|
1142
|
+
import * as os3 from "os";
|
|
1141
1143
|
import { eq as eq4 } from "drizzle-orm";
|
|
1144
|
+
function expandTilde(p2) {
|
|
1145
|
+
if (p2.startsWith("~/")) {
|
|
1146
|
+
return path6.join(os3.homedir(), p2.slice(2));
|
|
1147
|
+
}
|
|
1148
|
+
if (p2 === "~") {
|
|
1149
|
+
return os3.homedir();
|
|
1150
|
+
}
|
|
1151
|
+
return p2;
|
|
1152
|
+
}
|
|
1142
1153
|
var amux2;
|
|
1143
1154
|
function setAmuxBridge2(bridge) {
|
|
1144
1155
|
amux2 = bridge;
|
|
@@ -1331,8 +1342,9 @@ var layoutRouter = router({
|
|
|
1331
1342
|
throw new Error(`Pane ${input.paneId} already has an event stream`);
|
|
1332
1343
|
}
|
|
1333
1344
|
const configId = input.streamConfigId ?? input.agentConfigId;
|
|
1345
|
+
const directory = input.directory ? expandTilde(input.directory) : process.cwd();
|
|
1334
1346
|
const stream = await amux2.createStream({
|
|
1335
|
-
directory
|
|
1347
|
+
directory,
|
|
1336
1348
|
streamConfigId: configId
|
|
1337
1349
|
});
|
|
1338
1350
|
const eventStream = { type: stream.streamType, streamId: stream.id };
|
|
@@ -1477,11 +1489,42 @@ var streamsRouter = router({
|
|
|
1477
1489
|
|
|
1478
1490
|
// src/trpc/files.ts
|
|
1479
1491
|
import { z as z4 } from "zod";
|
|
1492
|
+
import * as fs6 from "fs/promises";
|
|
1493
|
+
import * as path7 from "path";
|
|
1494
|
+
import * as os4 from "os";
|
|
1495
|
+
function expandTilde2(p2) {
|
|
1496
|
+
if (p2.startsWith("~/")) {
|
|
1497
|
+
return path7.join(os4.homedir(), p2.slice(2));
|
|
1498
|
+
}
|
|
1499
|
+
if (p2 === "~") {
|
|
1500
|
+
return os4.homedir();
|
|
1501
|
+
}
|
|
1502
|
+
return p2;
|
|
1503
|
+
}
|
|
1480
1504
|
var amux4;
|
|
1481
1505
|
function setAmuxBridge4(bridge) {
|
|
1482
1506
|
amux4 = bridge;
|
|
1483
1507
|
}
|
|
1484
1508
|
var filesRouter = router({
|
|
1509
|
+
/**
|
|
1510
|
+
* Get server's current working directory.
|
|
1511
|
+
*/
|
|
1512
|
+
getCwd: publicProcedure.query(() => process.cwd()),
|
|
1513
|
+
/**
|
|
1514
|
+
* List directories in a given path.
|
|
1515
|
+
* Used by DirectoryPicker for browsing.
|
|
1516
|
+
*/
|
|
1517
|
+
listDirectory: publicProcedure.input(z4.object({
|
|
1518
|
+
directory: z4.string()
|
|
1519
|
+
})).query(async ({ input }) => {
|
|
1520
|
+
try {
|
|
1521
|
+
const absPath = path7.resolve(expandTilde2(input.directory));
|
|
1522
|
+
const entries = await fs6.readdir(absPath, { withFileTypes: true });
|
|
1523
|
+
return entries.filter((e) => e.isDirectory()).map((e) => ({ name: e.name, isDirectory: true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
1524
|
+
} catch {
|
|
1525
|
+
return [];
|
|
1526
|
+
}
|
|
1527
|
+
}),
|
|
1485
1528
|
/**
|
|
1486
1529
|
* List files/directories matching a partial path for autocomplete.
|
|
1487
1530
|
* Returns files in the session's working directory.
|
|
@@ -1569,22 +1612,22 @@ import { observable as observable2 } from "@trpc/server/observable";
|
|
|
1569
1612
|
|
|
1570
1613
|
// src/lib/rendererWatcher.ts
|
|
1571
1614
|
import chokidar2 from "chokidar";
|
|
1572
|
-
import * as
|
|
1573
|
-
import * as
|
|
1574
|
-
import * as
|
|
1615
|
+
import * as path9 from "path";
|
|
1616
|
+
import * as os5 from "os";
|
|
1617
|
+
import * as fs8 from "fs/promises";
|
|
1575
1618
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
1576
1619
|
|
|
1577
1620
|
// src/lib/rendererCompiler.ts
|
|
1578
1621
|
import { build as build2 } from "esbuild";
|
|
1579
|
-
import * as
|
|
1580
|
-
import * as
|
|
1622
|
+
import * as fs7 from "fs/promises";
|
|
1623
|
+
import * as path8 from "path";
|
|
1581
1624
|
async function compileRenderer(pluginDir) {
|
|
1582
|
-
const metaPath =
|
|
1583
|
-
const entryPath =
|
|
1584
|
-
const pkgPath =
|
|
1625
|
+
const metaPath = path8.join(pluginDir, "meta.json");
|
|
1626
|
+
const entryPath = path8.join(pluginDir, "index.tsx");
|
|
1627
|
+
const pkgPath = path8.join(pluginDir, "package.json");
|
|
1585
1628
|
let meta;
|
|
1586
1629
|
try {
|
|
1587
|
-
const metaContent = await
|
|
1630
|
+
const metaContent = await fs7.readFile(metaPath, "utf-8");
|
|
1588
1631
|
meta = JSON.parse(metaContent);
|
|
1589
1632
|
} catch (err) {
|
|
1590
1633
|
throw new Error(
|
|
@@ -1599,7 +1642,7 @@ async function compileRenderer(pluginDir) {
|
|
|
1599
1642
|
}
|
|
1600
1643
|
let hasPackageJson = false;
|
|
1601
1644
|
try {
|
|
1602
|
-
const pkgContent = await
|
|
1645
|
+
const pkgContent = await fs7.readFile(pkgPath, "utf-8");
|
|
1603
1646
|
const pkg = JSON.parse(pkgContent);
|
|
1604
1647
|
hasPackageJson = true;
|
|
1605
1648
|
const deps = pkg.dependencies || {};
|
|
@@ -1622,11 +1665,11 @@ async function compileRenderer(pluginDir) {
|
|
|
1622
1665
|
target: "es2020",
|
|
1623
1666
|
external: ["react", "react-dom", "react/jsx-runtime", "@bytespell/shella-sdk", "@bytespell/shella-sdk/components/ui"],
|
|
1624
1667
|
// If plugin has package.json, look for node_modules
|
|
1625
|
-
nodePaths: hasPackageJson ? [
|
|
1668
|
+
nodePaths: hasPackageJson ? [path8.join(pluginDir, "node_modules")] : [],
|
|
1626
1669
|
minify: false
|
|
1627
1670
|
});
|
|
1628
1671
|
const code = result.outputFiles[0].text;
|
|
1629
|
-
const id = `user:${
|
|
1672
|
+
const id = `user:${path8.basename(pluginDir)}`;
|
|
1630
1673
|
return {
|
|
1631
1674
|
id,
|
|
1632
1675
|
name: meta.name,
|
|
@@ -1637,8 +1680,8 @@ async function compileRenderer(pluginDir) {
|
|
|
1637
1680
|
}
|
|
1638
1681
|
async function isValidPlugin(dirPath) {
|
|
1639
1682
|
try {
|
|
1640
|
-
await
|
|
1641
|
-
await
|
|
1683
|
+
await fs7.access(path8.join(dirPath, "meta.json"));
|
|
1684
|
+
await fs7.access(path8.join(dirPath, "index.tsx"));
|
|
1642
1685
|
return true;
|
|
1643
1686
|
} catch {
|
|
1644
1687
|
return false;
|
|
@@ -1658,7 +1701,7 @@ var RendererEventEmitter = class extends EventEmitter2 {
|
|
|
1658
1701
|
}
|
|
1659
1702
|
};
|
|
1660
1703
|
function watchRenderers(emitter) {
|
|
1661
|
-
const userPath =
|
|
1704
|
+
const userPath = path9.join(os5.homedir(), ".shella", "renderers");
|
|
1662
1705
|
ensureDir2(userPath);
|
|
1663
1706
|
const knownPlugins = /* @__PURE__ */ new Map();
|
|
1664
1707
|
const pendingCompiles = /* @__PURE__ */ new Map();
|
|
@@ -1673,10 +1716,10 @@ function watchRenderers(emitter) {
|
|
|
1673
1716
|
// Watch inside plugin folders for nested components
|
|
1674
1717
|
});
|
|
1675
1718
|
const getPluginDir = (filePath) => {
|
|
1676
|
-
const relative3 =
|
|
1677
|
-
const parts = relative3.split(
|
|
1719
|
+
const relative3 = path9.relative(userPath, filePath);
|
|
1720
|
+
const parts = relative3.split(path9.sep);
|
|
1678
1721
|
if (parts.length >= 1 && parts[0]) {
|
|
1679
|
-
return
|
|
1722
|
+
return path9.join(userPath, parts[0]);
|
|
1680
1723
|
}
|
|
1681
1724
|
return null;
|
|
1682
1725
|
};
|
|
@@ -1722,7 +1765,7 @@ function watchRenderers(emitter) {
|
|
|
1722
1765
|
});
|
|
1723
1766
|
watcher.on("unlinkDir", (dirPath) => {
|
|
1724
1767
|
if (knownPlugins.has(dirPath)) {
|
|
1725
|
-
const id = `user:${
|
|
1768
|
+
const id = `user:${path9.basename(dirPath)}`;
|
|
1726
1769
|
knownPlugins.delete(dirPath);
|
|
1727
1770
|
console.log(`[renderers] Removed: ${id}`);
|
|
1728
1771
|
emitter.emit("renderer:removed", { id });
|
|
@@ -1741,18 +1784,18 @@ function watchRenderers(emitter) {
|
|
|
1741
1784
|
}
|
|
1742
1785
|
async function ensureDir2(dirPath) {
|
|
1743
1786
|
try {
|
|
1744
|
-
await
|
|
1787
|
+
await fs8.mkdir(dirPath, { recursive: true });
|
|
1745
1788
|
} catch {
|
|
1746
1789
|
}
|
|
1747
1790
|
}
|
|
1748
1791
|
async function scanRenderers() {
|
|
1749
|
-
const userPath =
|
|
1792
|
+
const userPath = path9.join(os5.homedir(), ".shella", "renderers");
|
|
1750
1793
|
const renderers = [];
|
|
1751
1794
|
try {
|
|
1752
|
-
const entries = await
|
|
1795
|
+
const entries = await fs8.readdir(userPath, { withFileTypes: true });
|
|
1753
1796
|
for (const entry of entries) {
|
|
1754
1797
|
if (!entry.isDirectory()) continue;
|
|
1755
|
-
const pluginDir =
|
|
1798
|
+
const pluginDir = path9.join(userPath, entry.name);
|
|
1756
1799
|
if (await isValidPlugin(pluginDir)) {
|
|
1757
1800
|
try {
|
|
1758
1801
|
const compiled = await compileRenderer(pluginDir);
|
|
@@ -1838,7 +1881,7 @@ var shellaRouter = router({
|
|
|
1838
1881
|
|
|
1839
1882
|
// src/index.ts
|
|
1840
1883
|
discoverAndRegisterConfigs(builtInDiscoverers);
|
|
1841
|
-
var __dirname2 =
|
|
1884
|
+
var __dirname2 = path10.dirname(fileURLToPath2(import.meta.url));
|
|
1842
1885
|
function createShellaServer(options = {}) {
|
|
1843
1886
|
const port = options.port ?? 3067;
|
|
1844
1887
|
if (options.verbose) {
|
|
@@ -1862,12 +1905,12 @@ function createShellaServer(options = {}) {
|
|
|
1862
1905
|
initializeRouters(amuxBridge);
|
|
1863
1906
|
const app = express();
|
|
1864
1907
|
app.use(express.json());
|
|
1865
|
-
const publicPath =
|
|
1908
|
+
const publicPath = path10.join(__dirname2, "..", "public");
|
|
1866
1909
|
app.use(express.static(publicPath));
|
|
1867
1910
|
app.use("/trpc", createExpressMiddleware({ router: shellaRouter }));
|
|
1868
1911
|
app.get("/health", (_req, res) => res.json({ status: "ok" }));
|
|
1869
1912
|
app.get("/{*splat}", (_req, res) => {
|
|
1870
|
-
res.sendFile(
|
|
1913
|
+
res.sendFile(path10.join(publicPath, "index.html"));
|
|
1871
1914
|
});
|
|
1872
1915
|
const server = createServer(app);
|
|
1873
1916
|
const wss = new WebSocketServer({ server, path: "/trpc" });
|
|
@@ -1876,7 +1919,7 @@ function createShellaServer(options = {}) {
|
|
|
1876
1919
|
start: async () => {
|
|
1877
1920
|
await scanDrivers();
|
|
1878
1921
|
stopDriverWatcher = watchDrivers(driverEmitter);
|
|
1879
|
-
return new Promise((
|
|
1922
|
+
return new Promise((resolve4, reject) => {
|
|
1880
1923
|
server.once("error", (err) => {
|
|
1881
1924
|
if (err.code === "EADDRINUSE") {
|
|
1882
1925
|
reject(new Error(`Port ${port} is already in use. Kill the other process or use a different port.`));
|
|
@@ -1888,7 +1931,7 @@ function createShellaServer(options = {}) {
|
|
|
1888
1931
|
const url = `http://localhost:${port}`;
|
|
1889
1932
|
debug("shella", `Running on ${url}`);
|
|
1890
1933
|
options.onReady?.(url);
|
|
1891
|
-
|
|
1934
|
+
resolve4();
|
|
1892
1935
|
});
|
|
1893
1936
|
});
|
|
1894
1937
|
},
|