revdeck 0.2.0 → 0.2.1

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/daemon.js CHANGED
@@ -1055,7 +1055,7 @@ rename to ${newPath}
1055
1055
 
1056
1056
  // src/daemon/main.ts
1057
1057
  import { existsSync as existsSync4, readFileSync } from "node:fs";
1058
- import { appendFile, open as open2, readFile as readFile3, unlink as unlink3 } from "node:fs/promises";
1058
+ import { appendFile, open as open2, readFile as readFile3, unlink as unlink4 } from "node:fs/promises";
1059
1059
  import net2 from "node:net";
1060
1060
  import path8 from "node:path";
1061
1061
  import { fileURLToPath } from "node:url";
@@ -1099,6 +1099,22 @@ function socketPath() {
1099
1099
  function daemonInfoPath() {
1100
1100
  return path.join(stateDir(), "daemon.json");
1101
1101
  }
1102
+ function devcontainerBridgeDir() {
1103
+ if (process.env.REVDECK_DEVCONTAINER_DIR) return path.resolve(process.env.REVDECK_DEVCONTAINER_DIR);
1104
+ return path.join(os.homedir(), ".local", "state", "revdeck", "devcontainer");
1105
+ }
1106
+ function devcontainerRunDir() {
1107
+ return path.join(devcontainerBridgeDir(), "run");
1108
+ }
1109
+ function devcontainerStateDir() {
1110
+ return path.join(devcontainerBridgeDir(), "state");
1111
+ }
1112
+ function devcontainerSocketPath() {
1113
+ return path.join(devcontainerRunDir(), "daemon.sock");
1114
+ }
1115
+ function devcontainerInfoPath() {
1116
+ return path.join(devcontainerStateDir(), "daemon.json");
1117
+ }
1102
1118
  function logPath() {
1103
1119
  return path.join(stateDir(), "daemon.log");
1104
1120
  }
@@ -1149,7 +1165,7 @@ async function writeFileAtomic(file, data, mode = 384) {
1149
1165
  init_redact();
1150
1166
 
1151
1167
  // src/version.ts
1152
- var VERSION = "0.2.0";
1168
+ var VERSION = "0.2.1";
1153
1169
  var PROTOCOL_VERSION = 1;
1154
1170
 
1155
1171
  // src/daemon/main.ts
@@ -3819,6 +3835,28 @@ data: ${JSON.stringify(event)}
3819
3835
  };
3820
3836
  }
3821
3837
 
3838
+ // src/daemon/bridge.ts
3839
+ import { unlink as unlink3 } from "node:fs/promises";
3840
+ async function startDevcontainerBridge(service, info) {
3841
+ await ensureDir(devcontainerRunDir(), 448);
3842
+ await ensureDir(devcontainerStateDir(), 448);
3843
+ const rpc = await startRpcServer(service, devcontainerSocketPath());
3844
+ try {
3845
+ const payload = { ...info, socket: devcontainerSocketPath() };
3846
+ await writeFileAtomic(devcontainerInfoPath(), `${JSON.stringify(payload, null, 2)}
3847
+ `, 384);
3848
+ } catch (error) {
3849
+ await rpc.close();
3850
+ throw error;
3851
+ }
3852
+ return {
3853
+ close: async () => {
3854
+ await rpc.close();
3855
+ await unlink3(devcontainerInfoPath()).catch(() => void 0);
3856
+ }
3857
+ };
3858
+ }
3859
+
3822
3860
  // src/daemon/main.ts
3823
3861
  async function main() {
3824
3862
  setLocale(detectLocale());
@@ -3889,6 +3927,12 @@ async function main() {
3889
3927
  };
3890
3928
  await writeFileAtomic(daemonInfoPath(), `${JSON.stringify(info, null, 2)}
3891
3929
  `, 384);
3930
+ let bridge = null;
3931
+ try {
3932
+ bridge = await startDevcontainerBridge(service, info);
3933
+ } catch (error) {
3934
+ await log(`devcontainer bridge unavailable: ${redactLine(error instanceof Error ? error.message : error)}`);
3935
+ }
3892
3936
  service.startSync();
3893
3937
  process.stdout.write(
3894
3938
  [
@@ -3906,13 +3950,14 @@ async function main() {
3906
3950
  closing = true;
3907
3951
  await log(`daemon stopping (${signal})`);
3908
3952
  try {
3953
+ await bridge?.close();
3909
3954
  await rpc.close();
3910
3955
  await http2.close();
3911
3956
  } finally {
3912
3957
  service.close();
3913
- await unlink3(daemonInfoPath()).catch(() => void 0);
3958
+ await unlink4(daemonInfoPath()).catch(() => void 0);
3914
3959
  await lock.close().catch(() => void 0);
3915
- await unlink3(path8.join(stateDir(), "daemon.lock")).catch(() => void 0);
3960
+ await unlink4(path8.join(stateDir(), "daemon.lock")).catch(() => void 0);
3916
3961
  process.exit(0);
3917
3962
  }
3918
3963
  };
@@ -3989,7 +4034,7 @@ async function acquireLock() {
3989
4034
  } catch {
3990
4035
  }
3991
4036
  }
3992
- await unlink3(file).catch(() => void 0);
4037
+ await unlink4(file).catch(() => void 0);
3993
4038
  }
3994
4039
  }
3995
4040
  return null;