@bytespell/shella 0.1.13 → 0.1.14
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-DFrDAdNH.js} +1 -1
- package/{public/assets/arc-BmFavzWc.js → dist/public/assets/arc-Dn-EBh2M.js} +1 -1
- package/{public/assets/architectureDiagram-VXUJARFQ-CZnDNYtj.js → dist/public/assets/architectureDiagram-VXUJARFQ-cLPhT_VH.js} +1 -1
- package/{public/assets/blockDiagram-VD42YOAC-CabGM_NX.js → dist/public/assets/blockDiagram-VD42YOAC-D9YWCJd4.js} +1 -1
- package/dist/public/assets/{c4Diagram-YG6GDRKO-BTq0tfrY.js → c4Diagram-YG6GDRKO-7iBiFNxv.js} +1 -1
- package/dist/public/assets/channel-Bc28uGr5.js +1 -0
- package/dist/public/assets/{chunk-4BX2VUAB-DP2HLRAj.js → chunk-4BX2VUAB-DHospLZi.js} +1 -1
- package/dist/public/assets/{chunk-55IACEB6-_ByWPNnF.js → chunk-55IACEB6-DYi5BOlX.js} +1 -1
- package/{public/assets/chunk-B4BG7PRW-BkPl9d2w.js → dist/public/assets/chunk-B4BG7PRW-B9aL4JLb.js} +1 -1
- package/{public/assets/chunk-DI55MBZ5-Bx6nm2tL.js → dist/public/assets/chunk-DI55MBZ5-ljO7G9dq.js} +1 -1
- package/dist/public/assets/{chunk-FMBD7UC4-DZpP7ydN.js → chunk-FMBD7UC4-Cwe-EPLG.js} +1 -1
- package/dist/public/assets/{chunk-QN33PNHL-DSX4eX_h.js → chunk-QN33PNHL-DEnaVKU1.js} +1 -1
- package/dist/public/assets/{chunk-QZHKN3VN-1uzZkVFg.js → chunk-QZHKN3VN-CWDdzKRs.js} +1 -1
- package/dist/public/assets/{chunk-TZMSLE5B-BwKElFeo.js → chunk-TZMSLE5B-Bpz-P3mQ.js} +1 -1
- package/dist/public/assets/classDiagram-2ON5EDUG-DJRc91IB.js +1 -0
- package/dist/public/assets/classDiagram-v2-WZHVMYZB-DJRc91IB.js +1 -0
- package/dist/public/assets/clone-CkWk6F_f.js +1 -0
- package/dist/public/assets/{code-block-IT6T5CEO-BoXZl_RQ.js → code-block-IT6T5CEO-Cd4wcD52.js} +1 -1
- package/dist/public/assets/{cose-bilkent-S5V4N54A-Dux9YKGp.js → cose-bilkent-S5V4N54A-BWl9wqzp.js} +1 -1
- package/dist/public/assets/{dagre-6UL2VRFP-Bcdq9Aj5.js → dagre-6UL2VRFP-DGDxxVd8.js} +1 -1
- package/dist/public/assets/{diagram-PSM6KHXK-CA-sK31I.js → diagram-PSM6KHXK-iQjjIACd.js} +1 -1
- package/dist/public/assets/{diagram-QEK2KX5R-De47GBMW.js → diagram-QEK2KX5R-D-rDIvx4.js} +1 -1
- package/dist/public/assets/{diagram-S2PKOQOG-DJm2AaGk.js → diagram-S2PKOQOG-BV8jEZTk.js} +1 -1
- package/{public/assets/erDiagram-Q2GNP2WA-Lu5P0RSi.js → dist/public/assets/erDiagram-Q2GNP2WA-XJ0647Zi.js} +1 -1
- package/{public/assets/flowDiagram-NV44I4VS-DflY4Ld4.js → dist/public/assets/flowDiagram-NV44I4VS-DSH4uel9.js} +1 -1
- package/dist/public/assets/{ganttDiagram-JELNMOA3-B8jvAfhh.js → ganttDiagram-JELNMOA3-Cz4yT-vm.js} +1 -1
- package/dist/public/assets/{gitGraphDiagram-NY62KEGX-B5ATDGVE.js → gitGraphDiagram-NY62KEGX-Y2DLg6xz.js} +1 -1
- package/dist/public/assets/{graph-8Q4ZN1_7.js → graph-z0wljCJ_.js} +1 -1
- package/dist/public/assets/index-CCsulXgB.css +1 -0
- package/dist/public/assets/{index-DRWhjxj6.js → index-DplAQDze.js} +122 -122
- package/dist/public/assets/{index-BEOKXaJG.js → index-iDg75qrw.js} +1 -1
- package/dist/public/assets/{infoDiagram-WHAUD3N6-qrN7AH1w.js → infoDiagram-WHAUD3N6-G5NGCtYh.js} +1 -1
- package/dist/public/assets/{journeyDiagram-XKPGCS4Q-CnL6w_Jf.js → journeyDiagram-XKPGCS4Q-BQ7qAaof.js} +1 -1
- package/{public/assets/kanban-definition-3W4ZIXB7-tuy_lNx5.js → dist/public/assets/kanban-definition-3W4ZIXB7-DnMJJT5X.js} +1 -1
- package/dist/public/assets/{layout-BCBlc1xg.js → layout-CbJei3Fo.js} +1 -1
- package/dist/public/assets/{linear-BzyanBSW.js → linear-3YD7PkfQ.js} +1 -1
- package/dist/public/assets/{mermaid.core-CKdMcV_T.js → mermaid.core-DjfX8Ewh.js} +5 -5
- package/dist/public/assets/{min-CQR8eUcq.js → min-Chhh-zX-.js} +1 -1
- package/dist/public/assets/{mindmap-definition-VGOIOE7T-fQec8JxD.js → mindmap-definition-VGOIOE7T-CLM5K3ub.js} +1 -1
- package/dist/public/assets/{pieDiagram-ADFJNKIX-BrLsJv83.js → pieDiagram-ADFJNKIX-BFiT_I_m.js} +1 -1
- package/{public/assets/quadrantDiagram-AYHSOK5B-BPHHSjXt.js → dist/public/assets/quadrantDiagram-AYHSOK5B-Be7QQurL.js} +1 -1
- package/dist/public/assets/{requirementDiagram-UZGBJVZJ-Bb93lhEQ.js → requirementDiagram-UZGBJVZJ-5NrHk2Xy.js} +1 -1
- package/{public/assets/sankeyDiagram-TZEHDZUN-CDK30tx7.js → dist/public/assets/sankeyDiagram-TZEHDZUN-DQ8Siqqh.js} +1 -1
- package/dist/public/assets/{sequenceDiagram-WL72ISMW-B2WQiW_k.js → sequenceDiagram-WL72ISMW-Bj_sOA9D.js} +1 -1
- package/{public/assets/stateDiagram-FKZM4ZOC-uM1w_xjr.js → dist/public/assets/stateDiagram-FKZM4ZOC-DncnQ-99.js} +1 -1
- package/dist/public/assets/stateDiagram-v2-4FDKWEC3-BdQ5RGa6.js +1 -0
- package/{public/assets/timeline-definition-IT6M3QCI-07DImEJ7.js → dist/public/assets/timeline-definition-IT6M3QCI-C9uFv_GY.js} +1 -1
- package/dist/public/assets/{treemap-KMMF4GRG-N0jjjXe0.js → treemap-KMMF4GRG-CTzKLdTW.js} +1 -1
- package/{public/assets/xychartDiagram-PRI3JC2R-BV-5VcHE.js → dist/public/assets/xychartDiagram-PRI3JC2R-BP2VkXwS.js} +1 -1
- package/dist/public/index.html +2 -2
- package/package.json +1 -1
- package/public/assets/{_baseUniq-EGFlDlSf.js → _baseUniq-DFrDAdNH.js} +1 -1
- package/{dist/public/assets/arc-BmFavzWc.js → public/assets/arc-Dn-EBh2M.js} +1 -1
- package/{dist/public/assets/architectureDiagram-VXUJARFQ-CZnDNYtj.js → public/assets/architectureDiagram-VXUJARFQ-cLPhT_VH.js} +1 -1
- package/{dist/public/assets/blockDiagram-VD42YOAC-CabGM_NX.js → public/assets/blockDiagram-VD42YOAC-D9YWCJd4.js} +1 -1
- package/public/assets/{c4Diagram-YG6GDRKO-BTq0tfrY.js → c4Diagram-YG6GDRKO-7iBiFNxv.js} +1 -1
- package/public/assets/channel-Bc28uGr5.js +1 -0
- package/public/assets/{chunk-4BX2VUAB-DP2HLRAj.js → chunk-4BX2VUAB-DHospLZi.js} +1 -1
- package/public/assets/{chunk-55IACEB6-_ByWPNnF.js → chunk-55IACEB6-DYi5BOlX.js} +1 -1
- package/{dist/public/assets/chunk-B4BG7PRW-BkPl9d2w.js → public/assets/chunk-B4BG7PRW-B9aL4JLb.js} +1 -1
- package/{dist/public/assets/chunk-DI55MBZ5-Bx6nm2tL.js → public/assets/chunk-DI55MBZ5-ljO7G9dq.js} +1 -1
- package/public/assets/{chunk-FMBD7UC4-DZpP7ydN.js → chunk-FMBD7UC4-Cwe-EPLG.js} +1 -1
- package/public/assets/{chunk-QN33PNHL-DSX4eX_h.js → chunk-QN33PNHL-DEnaVKU1.js} +1 -1
- package/public/assets/{chunk-QZHKN3VN-1uzZkVFg.js → chunk-QZHKN3VN-CWDdzKRs.js} +1 -1
- package/public/assets/{chunk-TZMSLE5B-BwKElFeo.js → chunk-TZMSLE5B-Bpz-P3mQ.js} +1 -1
- package/public/assets/classDiagram-2ON5EDUG-DJRc91IB.js +1 -0
- package/public/assets/classDiagram-v2-WZHVMYZB-DJRc91IB.js +1 -0
- package/public/assets/clone-CkWk6F_f.js +1 -0
- package/public/assets/{code-block-IT6T5CEO-BoXZl_RQ.js → code-block-IT6T5CEO-Cd4wcD52.js} +1 -1
- package/public/assets/{cose-bilkent-S5V4N54A-Dux9YKGp.js → cose-bilkent-S5V4N54A-BWl9wqzp.js} +1 -1
- package/public/assets/{dagre-6UL2VRFP-Bcdq9Aj5.js → dagre-6UL2VRFP-DGDxxVd8.js} +1 -1
- package/public/assets/{diagram-PSM6KHXK-CA-sK31I.js → diagram-PSM6KHXK-iQjjIACd.js} +1 -1
- package/public/assets/{diagram-QEK2KX5R-De47GBMW.js → diagram-QEK2KX5R-D-rDIvx4.js} +1 -1
- package/public/assets/{diagram-S2PKOQOG-DJm2AaGk.js → diagram-S2PKOQOG-BV8jEZTk.js} +1 -1
- package/{dist/public/assets/erDiagram-Q2GNP2WA-Lu5P0RSi.js → public/assets/erDiagram-Q2GNP2WA-XJ0647Zi.js} +1 -1
- package/{dist/public/assets/flowDiagram-NV44I4VS-DflY4Ld4.js → public/assets/flowDiagram-NV44I4VS-DSH4uel9.js} +1 -1
- package/public/assets/{ganttDiagram-JELNMOA3-B8jvAfhh.js → ganttDiagram-JELNMOA3-Cz4yT-vm.js} +1 -1
- package/public/assets/{gitGraphDiagram-NY62KEGX-B5ATDGVE.js → gitGraphDiagram-NY62KEGX-Y2DLg6xz.js} +1 -1
- package/public/assets/{graph-8Q4ZN1_7.js → graph-z0wljCJ_.js} +1 -1
- package/public/assets/index-CCsulXgB.css +1 -0
- package/public/assets/{index-DRWhjxj6.js → index-DplAQDze.js} +122 -122
- package/public/assets/{index-BEOKXaJG.js → index-iDg75qrw.js} +1 -1
- package/public/assets/{infoDiagram-WHAUD3N6-qrN7AH1w.js → infoDiagram-WHAUD3N6-G5NGCtYh.js} +1 -1
- package/public/assets/{journeyDiagram-XKPGCS4Q-CnL6w_Jf.js → journeyDiagram-XKPGCS4Q-BQ7qAaof.js} +1 -1
- package/{dist/public/assets/kanban-definition-3W4ZIXB7-tuy_lNx5.js → public/assets/kanban-definition-3W4ZIXB7-DnMJJT5X.js} +1 -1
- package/public/assets/{layout-BCBlc1xg.js → layout-CbJei3Fo.js} +1 -1
- package/public/assets/{linear-BzyanBSW.js → linear-3YD7PkfQ.js} +1 -1
- package/public/assets/{mermaid.core-CKdMcV_T.js → mermaid.core-DjfX8Ewh.js} +5 -5
- package/public/assets/{min-CQR8eUcq.js → min-Chhh-zX-.js} +1 -1
- package/public/assets/{mindmap-definition-VGOIOE7T-fQec8JxD.js → mindmap-definition-VGOIOE7T-CLM5K3ub.js} +1 -1
- package/public/assets/{pieDiagram-ADFJNKIX-BrLsJv83.js → pieDiagram-ADFJNKIX-BFiT_I_m.js} +1 -1
- package/{dist/public/assets/quadrantDiagram-AYHSOK5B-BPHHSjXt.js → public/assets/quadrantDiagram-AYHSOK5B-Be7QQurL.js} +1 -1
- package/public/assets/{requirementDiagram-UZGBJVZJ-Bb93lhEQ.js → requirementDiagram-UZGBJVZJ-5NrHk2Xy.js} +1 -1
- package/{dist/public/assets/sankeyDiagram-TZEHDZUN-CDK30tx7.js → public/assets/sankeyDiagram-TZEHDZUN-DQ8Siqqh.js} +1 -1
- package/public/assets/{sequenceDiagram-WL72ISMW-B2WQiW_k.js → sequenceDiagram-WL72ISMW-Bj_sOA9D.js} +1 -1
- package/{dist/public/assets/stateDiagram-FKZM4ZOC-uM1w_xjr.js → public/assets/stateDiagram-FKZM4ZOC-DncnQ-99.js} +1 -1
- package/public/assets/stateDiagram-v2-4FDKWEC3-BdQ5RGa6.js +1 -0
- package/{dist/public/assets/timeline-definition-IT6M3QCI-07DImEJ7.js → public/assets/timeline-definition-IT6M3QCI-C9uFv_GY.js} +1 -1
- package/public/assets/{treemap-KMMF4GRG-N0jjjXe0.js → treemap-KMMF4GRG-CTzKLdTW.js} +1 -1
- package/{dist/public/assets/xychartDiagram-PRI3JC2R-BV-5VcHE.js → public/assets/xychartDiagram-PRI3JC2R-BP2VkXwS.js} +1 -1
- package/public/index.html +2 -2
- 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/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var __export = (target, all) => {
|
|
|
8
8
|
import express from "express";
|
|
9
9
|
import { createServer } from "http";
|
|
10
10
|
import { WebSocketServer } from "ws";
|
|
11
|
-
import
|
|
11
|
+
import path10 from "path";
|
|
12
12
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
13
13
|
import { createExpressMiddleware } from "@trpc/server/adapters/express";
|
|
14
14
|
import { applyWSSHandler } from "@trpc/server/adapters/ws";
|
|
@@ -874,13 +874,13 @@ function getAllPaneIds(node) {
|
|
|
874
874
|
}
|
|
875
875
|
return [...getAllPaneIds(node.first), ...getAllPaneIds(node.second)];
|
|
876
876
|
}
|
|
877
|
-
function findPanePath(node, paneId,
|
|
877
|
+
function findPanePath(node, paneId, path11 = []) {
|
|
878
878
|
if (node.type === "leaf") {
|
|
879
|
-
return node.paneId === paneId ?
|
|
879
|
+
return node.paneId === paneId ? path11 : null;
|
|
880
880
|
}
|
|
881
|
-
const firstPath = findPanePath(node.first, paneId, [...
|
|
881
|
+
const firstPath = findPanePath(node.first, paneId, [...path11, "first"]);
|
|
882
882
|
if (firstPath) return firstPath;
|
|
883
|
-
return findPanePath(node.second, paneId, [...
|
|
883
|
+
return findPanePath(node.second, paneId, [...path11, "second"]);
|
|
884
884
|
}
|
|
885
885
|
function replacePaneWithNode(root, paneId, newNode) {
|
|
886
886
|
if (root.type === "leaf") {
|
|
@@ -917,15 +917,15 @@ function removePane(root, paneId) {
|
|
|
917
917
|
}
|
|
918
918
|
return root;
|
|
919
919
|
}
|
|
920
|
-
function updateRatio(root,
|
|
921
|
-
if (
|
|
920
|
+
function updateRatio(root, path11, newRatio) {
|
|
921
|
+
if (path11.length === 0) {
|
|
922
922
|
if (root.type === "branch") {
|
|
923
923
|
return { ...root, ratio: Math.max(10, Math.min(90, newRatio)) };
|
|
924
924
|
}
|
|
925
925
|
return root;
|
|
926
926
|
}
|
|
927
927
|
if (root.type === "leaf") return root;
|
|
928
|
-
const [next, ...rest] =
|
|
928
|
+
const [next, ...rest] = path11;
|
|
929
929
|
if (next === "first") {
|
|
930
930
|
return { ...root, first: updateRatio(root.first, rest, newRatio) };
|
|
931
931
|
} else {
|
|
@@ -933,11 +933,11 @@ function updateRatio(root, path9, newRatio) {
|
|
|
933
933
|
}
|
|
934
934
|
}
|
|
935
935
|
function getAdjacentPane(root, currentPaneId, direction) {
|
|
936
|
-
const
|
|
937
|
-
if (!
|
|
936
|
+
const path11 = findPanePath(root, currentPaneId);
|
|
937
|
+
if (!path11) return null;
|
|
938
938
|
let node = root;
|
|
939
939
|
const pathNodes = [];
|
|
940
|
-
for (const step of
|
|
940
|
+
for (const step of path11) {
|
|
941
941
|
if (node.type === "branch") {
|
|
942
942
|
pathNodes.push({ node, childSide: step });
|
|
943
943
|
node = step === "first" ? node.first : node.second;
|
|
@@ -1131,7 +1131,18 @@ var windowsRouter = router({
|
|
|
1131
1131
|
// src/trpc/layout.ts
|
|
1132
1132
|
import { z as z2 } from "zod";
|
|
1133
1133
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
1134
|
+
import * as path6 from "path";
|
|
1135
|
+
import * as os3 from "os";
|
|
1134
1136
|
import { eq as eq4 } from "drizzle-orm";
|
|
1137
|
+
function expandTilde(p) {
|
|
1138
|
+
if (p.startsWith("~/")) {
|
|
1139
|
+
return path6.join(os3.homedir(), p.slice(2));
|
|
1140
|
+
}
|
|
1141
|
+
if (p === "~") {
|
|
1142
|
+
return os3.homedir();
|
|
1143
|
+
}
|
|
1144
|
+
return p;
|
|
1145
|
+
}
|
|
1135
1146
|
var amux2;
|
|
1136
1147
|
function setAmuxBridge2(bridge) {
|
|
1137
1148
|
amux2 = bridge;
|
|
@@ -1324,8 +1335,9 @@ var layoutRouter = router({
|
|
|
1324
1335
|
throw new Error(`Pane ${input.paneId} already has an event stream`);
|
|
1325
1336
|
}
|
|
1326
1337
|
const configId = input.streamConfigId ?? input.agentConfigId;
|
|
1338
|
+
const directory = input.directory ? expandTilde(input.directory) : process.cwd();
|
|
1327
1339
|
const stream = await amux2.createStream({
|
|
1328
|
-
directory
|
|
1340
|
+
directory,
|
|
1329
1341
|
streamConfigId: configId
|
|
1330
1342
|
});
|
|
1331
1343
|
const eventStream = { type: stream.streamType, streamId: stream.id };
|
|
@@ -1470,11 +1482,42 @@ var streamsRouter = router({
|
|
|
1470
1482
|
|
|
1471
1483
|
// src/trpc/files.ts
|
|
1472
1484
|
import { z as z4 } from "zod";
|
|
1485
|
+
import * as fs6 from "fs/promises";
|
|
1486
|
+
import * as path7 from "path";
|
|
1487
|
+
import * as os4 from "os";
|
|
1488
|
+
function expandTilde2(p) {
|
|
1489
|
+
if (p.startsWith("~/")) {
|
|
1490
|
+
return path7.join(os4.homedir(), p.slice(2));
|
|
1491
|
+
}
|
|
1492
|
+
if (p === "~") {
|
|
1493
|
+
return os4.homedir();
|
|
1494
|
+
}
|
|
1495
|
+
return p;
|
|
1496
|
+
}
|
|
1473
1497
|
var amux4;
|
|
1474
1498
|
function setAmuxBridge4(bridge) {
|
|
1475
1499
|
amux4 = bridge;
|
|
1476
1500
|
}
|
|
1477
1501
|
var filesRouter = router({
|
|
1502
|
+
/**
|
|
1503
|
+
* Get server's current working directory.
|
|
1504
|
+
*/
|
|
1505
|
+
getCwd: publicProcedure.query(() => process.cwd()),
|
|
1506
|
+
/**
|
|
1507
|
+
* List directories in a given path.
|
|
1508
|
+
* Used by DirectoryPicker for browsing.
|
|
1509
|
+
*/
|
|
1510
|
+
listDirectory: publicProcedure.input(z4.object({
|
|
1511
|
+
directory: z4.string()
|
|
1512
|
+
})).query(async ({ input }) => {
|
|
1513
|
+
try {
|
|
1514
|
+
const absPath = path7.resolve(expandTilde2(input.directory));
|
|
1515
|
+
const entries = await fs6.readdir(absPath, { withFileTypes: true });
|
|
1516
|
+
return entries.filter((e) => e.isDirectory()).map((e) => ({ name: e.name, isDirectory: true })).sort((a, b) => a.name.localeCompare(b.name));
|
|
1517
|
+
} catch {
|
|
1518
|
+
return [];
|
|
1519
|
+
}
|
|
1520
|
+
}),
|
|
1478
1521
|
/**
|
|
1479
1522
|
* List files/directories matching a partial path for autocomplete.
|
|
1480
1523
|
* Returns files in the session's working directory.
|
|
@@ -1562,22 +1605,22 @@ import { observable as observable2 } from "@trpc/server/observable";
|
|
|
1562
1605
|
|
|
1563
1606
|
// src/lib/rendererWatcher.ts
|
|
1564
1607
|
import chokidar2 from "chokidar";
|
|
1565
|
-
import * as
|
|
1566
|
-
import * as
|
|
1567
|
-
import * as
|
|
1608
|
+
import * as path9 from "path";
|
|
1609
|
+
import * as os5 from "os";
|
|
1610
|
+
import * as fs8 from "fs/promises";
|
|
1568
1611
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
1569
1612
|
|
|
1570
1613
|
// src/lib/rendererCompiler.ts
|
|
1571
1614
|
import { build as build2 } from "esbuild";
|
|
1572
|
-
import * as
|
|
1573
|
-
import * as
|
|
1615
|
+
import * as fs7 from "fs/promises";
|
|
1616
|
+
import * as path8 from "path";
|
|
1574
1617
|
async function compileRenderer(pluginDir) {
|
|
1575
|
-
const metaPath =
|
|
1576
|
-
const entryPath =
|
|
1577
|
-
const pkgPath =
|
|
1618
|
+
const metaPath = path8.join(pluginDir, "meta.json");
|
|
1619
|
+
const entryPath = path8.join(pluginDir, "index.tsx");
|
|
1620
|
+
const pkgPath = path8.join(pluginDir, "package.json");
|
|
1578
1621
|
let meta;
|
|
1579
1622
|
try {
|
|
1580
|
-
const metaContent = await
|
|
1623
|
+
const metaContent = await fs7.readFile(metaPath, "utf-8");
|
|
1581
1624
|
meta = JSON.parse(metaContent);
|
|
1582
1625
|
} catch (err) {
|
|
1583
1626
|
throw new Error(
|
|
@@ -1592,7 +1635,7 @@ async function compileRenderer(pluginDir) {
|
|
|
1592
1635
|
}
|
|
1593
1636
|
let hasPackageJson = false;
|
|
1594
1637
|
try {
|
|
1595
|
-
const pkgContent = await
|
|
1638
|
+
const pkgContent = await fs7.readFile(pkgPath, "utf-8");
|
|
1596
1639
|
const pkg = JSON.parse(pkgContent);
|
|
1597
1640
|
hasPackageJson = true;
|
|
1598
1641
|
const deps = pkg.dependencies || {};
|
|
@@ -1615,11 +1658,11 @@ async function compileRenderer(pluginDir) {
|
|
|
1615
1658
|
target: "es2020",
|
|
1616
1659
|
external: ["react", "react-dom", "react/jsx-runtime", "@bytespell/shella-sdk", "@bytespell/shella-sdk/components/ui"],
|
|
1617
1660
|
// If plugin has package.json, look for node_modules
|
|
1618
|
-
nodePaths: hasPackageJson ? [
|
|
1661
|
+
nodePaths: hasPackageJson ? [path8.join(pluginDir, "node_modules")] : [],
|
|
1619
1662
|
minify: false
|
|
1620
1663
|
});
|
|
1621
1664
|
const code = result.outputFiles[0].text;
|
|
1622
|
-
const id = `user:${
|
|
1665
|
+
const id = `user:${path8.basename(pluginDir)}`;
|
|
1623
1666
|
return {
|
|
1624
1667
|
id,
|
|
1625
1668
|
name: meta.name,
|
|
@@ -1630,8 +1673,8 @@ async function compileRenderer(pluginDir) {
|
|
|
1630
1673
|
}
|
|
1631
1674
|
async function isValidPlugin(dirPath) {
|
|
1632
1675
|
try {
|
|
1633
|
-
await
|
|
1634
|
-
await
|
|
1676
|
+
await fs7.access(path8.join(dirPath, "meta.json"));
|
|
1677
|
+
await fs7.access(path8.join(dirPath, "index.tsx"));
|
|
1635
1678
|
return true;
|
|
1636
1679
|
} catch {
|
|
1637
1680
|
return false;
|
|
@@ -1651,7 +1694,7 @@ var RendererEventEmitter = class extends EventEmitter2 {
|
|
|
1651
1694
|
}
|
|
1652
1695
|
};
|
|
1653
1696
|
function watchRenderers(emitter) {
|
|
1654
|
-
const userPath =
|
|
1697
|
+
const userPath = path9.join(os5.homedir(), ".shella", "renderers");
|
|
1655
1698
|
ensureDir2(userPath);
|
|
1656
1699
|
const knownPlugins = /* @__PURE__ */ new Map();
|
|
1657
1700
|
const pendingCompiles = /* @__PURE__ */ new Map();
|
|
@@ -1666,10 +1709,10 @@ function watchRenderers(emitter) {
|
|
|
1666
1709
|
// Watch inside plugin folders for nested components
|
|
1667
1710
|
});
|
|
1668
1711
|
const getPluginDir = (filePath) => {
|
|
1669
|
-
const relative3 =
|
|
1670
|
-
const parts = relative3.split(
|
|
1712
|
+
const relative3 = path9.relative(userPath, filePath);
|
|
1713
|
+
const parts = relative3.split(path9.sep);
|
|
1671
1714
|
if (parts.length >= 1 && parts[0]) {
|
|
1672
|
-
return
|
|
1715
|
+
return path9.join(userPath, parts[0]);
|
|
1673
1716
|
}
|
|
1674
1717
|
return null;
|
|
1675
1718
|
};
|
|
@@ -1715,7 +1758,7 @@ function watchRenderers(emitter) {
|
|
|
1715
1758
|
});
|
|
1716
1759
|
watcher.on("unlinkDir", (dirPath) => {
|
|
1717
1760
|
if (knownPlugins.has(dirPath)) {
|
|
1718
|
-
const id = `user:${
|
|
1761
|
+
const id = `user:${path9.basename(dirPath)}`;
|
|
1719
1762
|
knownPlugins.delete(dirPath);
|
|
1720
1763
|
console.log(`[renderers] Removed: ${id}`);
|
|
1721
1764
|
emitter.emit("renderer:removed", { id });
|
|
@@ -1734,18 +1777,18 @@ function watchRenderers(emitter) {
|
|
|
1734
1777
|
}
|
|
1735
1778
|
async function ensureDir2(dirPath) {
|
|
1736
1779
|
try {
|
|
1737
|
-
await
|
|
1780
|
+
await fs8.mkdir(dirPath, { recursive: true });
|
|
1738
1781
|
} catch {
|
|
1739
1782
|
}
|
|
1740
1783
|
}
|
|
1741
1784
|
async function scanRenderers() {
|
|
1742
|
-
const userPath =
|
|
1785
|
+
const userPath = path9.join(os5.homedir(), ".shella", "renderers");
|
|
1743
1786
|
const renderers = [];
|
|
1744
1787
|
try {
|
|
1745
|
-
const entries = await
|
|
1788
|
+
const entries = await fs8.readdir(userPath, { withFileTypes: true });
|
|
1746
1789
|
for (const entry of entries) {
|
|
1747
1790
|
if (!entry.isDirectory()) continue;
|
|
1748
|
-
const pluginDir =
|
|
1791
|
+
const pluginDir = path9.join(userPath, entry.name);
|
|
1749
1792
|
if (await isValidPlugin(pluginDir)) {
|
|
1750
1793
|
try {
|
|
1751
1794
|
const compiled = await compileRenderer(pluginDir);
|
|
@@ -1831,7 +1874,7 @@ var shellaRouter = router({
|
|
|
1831
1874
|
|
|
1832
1875
|
// src/index.ts
|
|
1833
1876
|
discoverAndRegisterConfigs(builtInDiscoverers);
|
|
1834
|
-
var __dirname2 =
|
|
1877
|
+
var __dirname2 = path10.dirname(fileURLToPath2(import.meta.url));
|
|
1835
1878
|
function createShellaServer(options = {}) {
|
|
1836
1879
|
const port = options.port ?? 3067;
|
|
1837
1880
|
if (options.verbose) {
|
|
@@ -1855,12 +1898,12 @@ function createShellaServer(options = {}) {
|
|
|
1855
1898
|
initializeRouters(amuxBridge);
|
|
1856
1899
|
const app = express();
|
|
1857
1900
|
app.use(express.json());
|
|
1858
|
-
const publicPath =
|
|
1901
|
+
const publicPath = path10.join(__dirname2, "..", "public");
|
|
1859
1902
|
app.use(express.static(publicPath));
|
|
1860
1903
|
app.use("/trpc", createExpressMiddleware({ router: shellaRouter }));
|
|
1861
1904
|
app.get("/health", (_req, res) => res.json({ status: "ok" }));
|
|
1862
1905
|
app.get("/{*splat}", (_req, res) => {
|
|
1863
|
-
res.sendFile(
|
|
1906
|
+
res.sendFile(path10.join(publicPath, "index.html"));
|
|
1864
1907
|
});
|
|
1865
1908
|
const server = createServer(app);
|
|
1866
1909
|
const wss = new WebSocketServer({ server, path: "/trpc" });
|
|
@@ -1869,7 +1912,7 @@ function createShellaServer(options = {}) {
|
|
|
1869
1912
|
start: async () => {
|
|
1870
1913
|
await scanDrivers();
|
|
1871
1914
|
stopDriverWatcher = watchDrivers(driverEmitter);
|
|
1872
|
-
return new Promise((
|
|
1915
|
+
return new Promise((resolve4, reject) => {
|
|
1873
1916
|
server.once("error", (err) => {
|
|
1874
1917
|
if (err.code === "EADDRINUSE") {
|
|
1875
1918
|
reject(new Error(`Port ${port} is already in use. Kill the other process or use a different port.`));
|
|
@@ -1881,7 +1924,7 @@ function createShellaServer(options = {}) {
|
|
|
1881
1924
|
const url = `http://localhost:${port}`;
|
|
1882
1925
|
debug("shella", `Running on ${url}`);
|
|
1883
1926
|
options.onReady?.(url);
|
|
1884
|
-
|
|
1927
|
+
resolve4();
|
|
1885
1928
|
});
|
|
1886
1929
|
});
|
|
1887
1930
|
},
|