@base44-preview/cli 0.1.32-pr.664.478a865 → 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 +100 -19
- package/dist/cli/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -253402,8 +253402,12 @@ var deno2 = Object.freeze({
|
|
|
253402
253402
|
});
|
|
253403
253403
|
globalThis.Deno = deno2;
|
|
253404
253404
|
globalThis.Buffer = Buffer2;
|
|
253405
|
-
|
|
253406
|
-
|
|
253405
|
+
try {
|
|
253406
|
+
new AsyncLocalStorage().enterWith(void 0);
|
|
253407
|
+
} catch {
|
|
253408
|
+
AsyncLocalStorage.prototype.enterWith = () => {
|
|
253409
|
+
};
|
|
253410
|
+
}
|
|
253407
253411
|
function getRegisteredHandler() {
|
|
253408
253412
|
return registeredHandler;
|
|
253409
253413
|
}
|
|
@@ -260998,27 +261002,43 @@ var NAMESPACE4 = "base44-ws-native";
|
|
|
260998
261002
|
var WS_SPECIFIER = /^(npm:)?ws(@[^/]+)?$/;
|
|
260999
261003
|
var ADAPTER = `"use strict";
|
|
261000
261004
|
const toBuffer = (value) => (globalThis.Buffer ? globalThis.Buffer.from(value) : value);
|
|
261005
|
+
const READY_STATES = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"];
|
|
261006
|
+
const later = (fn, ...args) => queueMicrotask(() => fn(...args));
|
|
261007
|
+
const upgradeHeaders = (options) => {
|
|
261008
|
+
const headers = new Headers(options?.headers);
|
|
261009
|
+
for (const name of headers.keys()) if (name !== "user-agent") return headers;
|
|
261010
|
+
return null;
|
|
261011
|
+
};
|
|
261001
261012
|
class WebSocket {
|
|
261002
261013
|
static CONNECTING = 0;
|
|
261003
261014
|
static OPEN = 1;
|
|
261004
261015
|
static CLOSING = 2;
|
|
261005
261016
|
static CLOSED = 3;
|
|
261006
|
-
#socket;
|
|
261017
|
+
#socket = null;
|
|
261018
|
+
#state = 0;
|
|
261019
|
+
#url;
|
|
261020
|
+
#closeRequested = null;
|
|
261021
|
+
#terminated = false;
|
|
261007
261022
|
#listeners = new Map();
|
|
261008
|
-
constructor(address, protocols) {
|
|
261009
|
-
|
|
261010
|
-
|
|
261011
|
-
|
|
261012
|
-
|
|
261013
|
-
|
|
261014
|
-
|
|
261015
|
-
|
|
261016
|
-
|
|
261017
|
-
|
|
261023
|
+
constructor(address, protocols, options) {
|
|
261024
|
+
if (protocols && typeof protocols === "object" && !Array.isArray(protocols)) {
|
|
261025
|
+
options = protocols;
|
|
261026
|
+
protocols = undefined;
|
|
261027
|
+
}
|
|
261028
|
+
this.#url = String(address);
|
|
261029
|
+
const headers = upgradeHeaders(options);
|
|
261030
|
+
if (headers) {
|
|
261031
|
+
this.#upgrade(headers, protocols);
|
|
261032
|
+
} else {
|
|
261033
|
+
this.#attach(new globalThis.WebSocket(this.#url, protocols));
|
|
261034
|
+
}
|
|
261018
261035
|
}
|
|
261019
|
-
get readyState() {
|
|
261020
|
-
|
|
261021
|
-
|
|
261036
|
+
get readyState() {
|
|
261037
|
+
if (this.#terminated) return 3;
|
|
261038
|
+
return this.#socket ? this.#socket.readyState : this.#state;
|
|
261039
|
+
}
|
|
261040
|
+
get url() { return this.#url; }
|
|
261041
|
+
get protocol() { return this.#socket ? this.#socket.protocol ?? "" : ""; }
|
|
261022
261042
|
on(name, listener) { return this.#add(name, listener, false); }
|
|
261023
261043
|
addListener(name, listener) { return this.#add(name, listener, false); }
|
|
261024
261044
|
once(name, listener) { return this.#add(name, listener, true); }
|
|
@@ -261042,6 +261062,9 @@ class WebSocket {
|
|
|
261042
261062
|
send(data, options, callback) {
|
|
261043
261063
|
const done = typeof options === "function" ? options : callback;
|
|
261044
261064
|
try {
|
|
261065
|
+
if (!this.#socket) {
|
|
261066
|
+
throw new Error("WebSocket is not open: readyState " + this.#state + " (" + READY_STATES[this.#state] + ")");
|
|
261067
|
+
}
|
|
261045
261068
|
this.#socket.send(data);
|
|
261046
261069
|
done?.();
|
|
261047
261070
|
} catch (error) {
|
|
@@ -261049,8 +261072,66 @@ class WebSocket {
|
|
|
261049
261072
|
done(error);
|
|
261050
261073
|
}
|
|
261051
261074
|
}
|
|
261052
|
-
close(code, reason) {
|
|
261053
|
-
|
|
261075
|
+
close(code, reason) {
|
|
261076
|
+
if (this.#socket) this.#socket.close(code, reason);
|
|
261077
|
+
else if (this.#state === 0) {
|
|
261078
|
+
// Upgrade still in flight: close as soon as it lands.
|
|
261079
|
+
this.#closeRequested = [code, reason];
|
|
261080
|
+
this.#state = 2;
|
|
261081
|
+
}
|
|
261082
|
+
}
|
|
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
|
+
}
|
|
261097
|
+
#attach(socket) {
|
|
261098
|
+
this.#socket = socket;
|
|
261099
|
+
try { socket.binaryType = "arraybuffer"; } catch {}
|
|
261100
|
+
socket.addEventListener("open", () => this.emit("open"));
|
|
261101
|
+
socket.addEventListener("message", (event) => {
|
|
261102
|
+
const isBinary = typeof event.data !== "string";
|
|
261103
|
+
this.emit("message", toBuffer(isBinary ? new Uint8Array(event.data) : event.data), isBinary);
|
|
261104
|
+
});
|
|
261105
|
+
socket.addEventListener("error", (event) => this.emit("error", event.error ?? new Error(event.message || "WebSocket error")));
|
|
261106
|
+
socket.addEventListener("close", (event) => {
|
|
261107
|
+
if (!this.#terminated) this.emit("close", event.code, toBuffer(event.reason ?? ""));
|
|
261108
|
+
});
|
|
261109
|
+
}
|
|
261110
|
+
#upgrade(headers, protocols) {
|
|
261111
|
+
headers.set("Upgrade", "websocket");
|
|
261112
|
+
if (protocols) headers.set("Sec-WebSocket-Protocol", [].concat(protocols).join(", "));
|
|
261113
|
+
const httpUrl = this.#url.replace(/^ws(s?):/i, "http$1:");
|
|
261114
|
+
const fail = (error) => {
|
|
261115
|
+
this.#state = 3;
|
|
261116
|
+
if (this.#terminated) return;
|
|
261117
|
+
this.emit("error", error);
|
|
261118
|
+
this.emit("close", 1006, toBuffer(""));
|
|
261119
|
+
};
|
|
261120
|
+
// Two-argument then(): an exception from an "open" listener must not be
|
|
261121
|
+
// reported as a failed upgrade.
|
|
261122
|
+
fetch(httpUrl, { headers }).then((response) => {
|
|
261123
|
+
const socket = response.webSocket;
|
|
261124
|
+
if (!socket) {
|
|
261125
|
+
response.body?.cancel();
|
|
261126
|
+
return fail(new Error("Unexpected server response: " + response.status));
|
|
261127
|
+
}
|
|
261128
|
+
socket.accept();
|
|
261129
|
+
this.#attach(socket);
|
|
261130
|
+
if (this.#closeRequested) return socket.close(...this.#closeRequested);
|
|
261131
|
+
// accept() opens the socket without dispatching an "open" event.
|
|
261132
|
+
this.emit("open");
|
|
261133
|
+
}, fail);
|
|
261134
|
+
}
|
|
261054
261135
|
#add(name, listener, once) {
|
|
261055
261136
|
const listeners = this.#listeners.get(name) ?? [];
|
|
261056
261137
|
listeners.push({ listener, once });
|
|
@@ -271496,4 +271577,4 @@ export {
|
|
|
271496
271577
|
runCLI
|
|
271497
271578
|
};
|
|
271498
271579
|
|
|
271499
|
-
//# debugId=
|
|
271580
|
+
//# debugId=FAC4CC784F55ED6664756E2164756E21
|