shiplocal 0.1.4 → 0.1.5

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/index.js CHANGED
@@ -4109,6 +4109,10 @@ var errorMessageSchema = external_exports.object({
4109
4109
  type: external_exports.literal("error"),
4110
4110
  message: external_exports.string()
4111
4111
  });
4112
+ var terminatedMessageSchema = external_exports.object({
4113
+ type: external_exports.literal("terminated"),
4114
+ message: external_exports.string()
4115
+ });
4112
4116
  var tunnelMessageSchema = external_exports.discriminatedUnion("type", [
4113
4117
  registerMessageSchema,
4114
4118
  registeredMessageSchema,
@@ -4116,7 +4120,8 @@ var tunnelMessageSchema = external_exports.discriminatedUnion("type", [
4116
4120
  pongMessageSchema,
4117
4121
  tunnelRequestMessageSchema,
4118
4122
  tunnelResponseMessageSchema,
4119
- errorMessageSchema
4123
+ errorMessageSchema,
4124
+ terminatedMessageSchema
4120
4125
  ]);
4121
4126
  function parseTunnelMessage(data) {
4122
4127
  const parsed = typeof data === "string" ? JSON.parse(data) : data;
@@ -4349,6 +4354,13 @@ function createTunnelClient(options) {
4349
4354
  }
4350
4355
  return;
4351
4356
  }
4357
+ if (message.type === "terminated") {
4358
+ intentionalClose = true;
4359
+ publicUrl = null;
4360
+ options.onTerminated?.(message.message);
4361
+ ws?.close();
4362
+ return;
4363
+ }
4352
4364
  if (message.type === "ping") {
4353
4365
  ws?.send(JSON.stringify({ type: "pong" }));
4354
4366
  return;
@@ -4561,7 +4573,7 @@ async function isLocalPortOpen(port, timeoutMs = 2e3) {
4561
4573
 
4562
4574
  // src/index.ts
4563
4575
  var program = new Command();
4564
- program.name("shiplocal").description("Share localhost with clients in seconds").version("0.1.4");
4576
+ program.name("shiplocal").description("Share localhost with clients in seconds").version("0.1.5");
4565
4577
  program.command("login").description("Authenticate with ShipLocal Cloud").action(async () => {
4566
4578
  const rl = createInterface({ input, output });
4567
4579
  const apiUrl = await resolveApiUrlAsync();
@@ -4642,6 +4654,12 @@ program.argument("[port]", "Local port to expose", String(DEFAULT_TUNNEL_PORT)).
4642
4654
  },
4643
4655
  onReconnecting: (attempt) => {
4644
4656
  console.log(`Reconnecting\u2026 (attempt ${String(attempt)})`);
4657
+ },
4658
+ onTerminated: (message) => {
4659
+ console.log("");
4660
+ console.log(message);
4661
+ console.log("Run shiplocal again to start a new tunnel.");
4662
+ console.log("");
4645
4663
  }
4646
4664
  });
4647
4665
  const shutdown = () => {