@base44-preview/cli 0.1.32-pr.664.89779c9 → 0.1.32-pr.664.f359bf9

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/cli/index.js CHANGED
@@ -261003,6 +261003,7 @@ var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
261003
261003
  var ADAPTER = `"use strict";
261004
261004
  const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
261005
261005
  const READY_STATES = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
261006
+ const later = (fn, ...args) => queueMicrotask(() => fn(...args));
261006
261007
  const upgradeHeaders = (options) => {
261007
261008
  const headers = new Headers(options?.headers);
261008
261009
  for (const name of headers.keys()) if (name !== "user-agent") return headers;
@@ -261017,6 +261018,7 @@ class WebSocket {
261017
261018
  #state = 0;
261018
261019
  #url;
261019
261020
  #closeRequested = null;
261021
+ #terminated = false;
261020
261022
  #listeners = new Map();
261021
261023
  constructor(address, protocols, options) {
261022
261024
  if (protocols && typeof protocols === "object" && !Array.isArray(protocols)) {
@@ -261031,7 +261033,10 @@ class WebSocket {
261031
261033
  this.#attach(new globalThis.WebSocket(this.#url, protocols));
261032
261034
  }
261033
261035
  }
261034
- get readyState() { return this.#socket ? this.#socket.readyState : this.#state; }
261036
+ get readyState() {
261037
+ if (this.#terminated) return 3;
261038
+ return this.#socket ? this.#socket.readyState : this.#state;
261039
+ }
261035
261040
  get url() { return this.#url; }
261036
261041
  get protocol() { return this.#socket ? this.#socket.protocol ?? "" : ""; }
261037
261042
  on(name, listener) { return this.#add(name, listener, false); }
@@ -261075,7 +261080,20 @@ class WebSocket {
261075
261080
  this.#state = 2;
261076
261081
  }
261077
261082
  }
261078
- terminate() { this.close(); }
261083
+ // \`ws\` tears the connection down at once. workerd has no abrupt close, so the
261084
+ // socket is closed normally and "close" is reported now, not on the reply.
261085
+ terminate() {
261086
+ if (this.#terminated || this.readyState === 3) return;
261087
+ this.#terminated = true;
261088
+ if (this.#socket) {
261089
+ try { this.#socket.close(); } catch {}
261090
+ } else {
261091
+ // Upgrade still in flight: close it on arrival, without an "open".
261092
+ this.#closeRequested = [];
261093
+ this.#state = 3;
261094
+ }
261095
+ later(() => this.emit("close", 1006, toBuffer("")));
261096
+ }
261079
261097
  #attach(socket) {
261080
261098
  this.#socket = socket;
261081
261099
  try { socket.binaryType = "arraybuffer"; } catch {}
@@ -261085,7 +261103,9 @@ class WebSocket {
261085
261103
  this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
261086
261104
  });
261087
261105
  socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
261088
- socket.addEventListener("close", (event) => this.emit("close", event.code, toBuffer(event.reason ?? "")));
261106
+ socket.addEventListener("close", (event) => {
261107
+ if (!this.#terminated) this.emit("close", event.code, toBuffer(event.reason ?? ""));
261108
+ });
261089
261109
  }
261090
261110
  #upgrade(headers, protocols) {
261091
261111
  headers.set("Upgrade", "websocket");
@@ -261093,6 +261113,7 @@ class WebSocket {
261093
261113
  const httpUrl = this.#url.replace(/^ws(s?):/i, "http$1:");
261094
261114
  const fail = (error) => {
261095
261115
  this.#state = 3;
261116
+ if (this.#terminated) return;
261096
261117
  this.emit("error", error);
261097
261118
  this.emit("close", 1006, toBuffer(""));
261098
261119
  };
@@ -271556,4 +271577,4 @@ export {
271556
271577
  runCLI
271557
271578
  };
271558
271579
 
271559
- //# debugId=B28345EB77F07FBF64756E2164756E21
271580
+ //# debugId=FAC4CC784F55ED6664756E2164756E21