pubblue 0.4.1 → 0.4.2

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.
@@ -10,6 +10,10 @@ import * as fs from "fs";
10
10
  import * as net from "net";
11
11
  import * as path from "path";
12
12
  var OFFER_TIMEOUT_MS = 1e4;
13
+ var NOT_CONNECTED_WRITE_ERROR = "No browser connected. Ask the user to open the tunnel URL first, then retry.";
14
+ function getTunnelWriteReadinessError(isConnected) {
15
+ return isConnected ? null : NOT_CONNECTED_WRITE_ERROR;
16
+ }
13
17
  async function startDaemon(config) {
14
18
  const { tunnelId, apiClient, socketPath, infoPath } = config;
15
19
  const ndc = await import("node-datachannel");
@@ -237,6 +241,8 @@ async function startDaemon(config) {
237
241
  switch (req.method) {
238
242
  case "write": {
239
243
  const channel = req.params.channel || CHANNELS.CHAT;
244
+ const readinessError = getTunnelWriteReadinessError(connected);
245
+ if (readinessError) return { ok: false, error: readinessError };
240
246
  const msg = req.params.msg;
241
247
  const binaryBase64 = typeof req.params.binaryBase64 === "string" ? req.params.binaryBase64 : void 0;
242
248
  const dc = channels.get(channel);
@@ -338,5 +344,6 @@ function generateOffer(peer, timeoutMs) {
338
344
  }
339
345
 
340
346
  export {
347
+ getTunnelWriteReadinessError,
341
348
  startDaemon
342
349
  };
package/dist/index.js CHANGED
@@ -227,7 +227,7 @@ function registerTunnelCommands(program2) {
227
227
  const socketPath = getSocketPath(result.tunnelId);
228
228
  const infoPath = tunnelInfoPath(result.tunnelId);
229
229
  if (opts.foreground) {
230
- const { startDaemon } = await import("./tunnel-daemon-QBJSX4JM.js");
230
+ const { startDaemon } = await import("./tunnel-daemon-K7Z7FUFN.js");
231
231
  console.log(`Tunnel started: ${result.url}`);
232
232
  console.log(`Tunnel ID: ${result.tunnelId}`);
233
233
  console.log(`Expires: ${new Date(result.expiresAt).toISOString()}`);
@@ -579,7 +579,7 @@ function readFile(filePath) {
579
579
  basename: path3.basename(resolved)
580
580
  };
581
581
  }
582
- program.name("pubblue").description("Publish static content and get shareable URLs").version("0.4.1");
582
+ program.name("pubblue").description("Publish static content and get shareable URLs").version("0.4.2");
583
583
  program.command("configure").description("Configure the CLI with your API key").option("--api-key <key>", "Your API key (less secure: appears in shell history)").option("--api-key-stdin", "Read API key from stdin").action(async (opts) => {
584
584
  try {
585
585
  const apiKey = await resolveConfigureApiKey(opts);
@@ -0,0 +1,9 @@
1
+ import {
2
+ getTunnelWriteReadinessError,
3
+ startDaemon
4
+ } from "./chunk-3RFMAQOM.js";
5
+ import "./chunk-56IKFMJ2.js";
6
+ export {
7
+ getTunnelWriteReadinessError,
8
+ startDaemon
9
+ };
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-BV423NLA.js";
4
4
  import {
5
5
  startDaemon
6
- } from "./chunk-77HFJKLW.js";
6
+ } from "./chunk-3RFMAQOM.js";
7
7
  import "./chunk-56IKFMJ2.js";
8
8
 
9
9
  // src/tunnel-daemon-entry.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubblue",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "CLI tool for publishing static content via pub.blue",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +0,0 @@
1
- import {
2
- startDaemon
3
- } from "./chunk-77HFJKLW.js";
4
- import "./chunk-56IKFMJ2.js";
5
- export {
6
- startDaemon
7
- };