@libsql/hrana-client
Advanced tools
Comparing version 0.3.10 to 0.3.11
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Client = exports.protocolVersions = void 0; | ||
const isomorphic_ws_1 = require("@libsql/isomorphic-ws"); | ||
const id_alloc_js_1 = require("./id_alloc.js"); | ||
@@ -19,2 +18,4 @@ const errors_js_1 = require("./errors.js"); | ||
#openCallbacks; | ||
// Have we already transitioned from CONNECTING to OPEN and fired the callbacks in #openCallbacks? | ||
#opened; | ||
// Stores the error that caused us to close the client (and the socket). If we are not closed, this is | ||
@@ -44,2 +45,3 @@ // `undefined`. | ||
this.#openCallbacks = []; | ||
this.#opened = false; | ||
this.#closed = undefined; | ||
@@ -64,3 +66,3 @@ this.#recvdHello = false; | ||
} | ||
if (this.#socket.readyState >= isomorphic_ws_1.WebSocket.OPEN) { | ||
if (this.#opened) { | ||
this.#sendToSocket(msg); | ||
@@ -90,2 +92,3 @@ } | ||
this.#openCallbacks.length = 0; | ||
this.#opened = true; | ||
} | ||
@@ -102,9 +105,9 @@ #sendToSocket(msg) { | ||
} | ||
else if (this.#version !== undefined) { | ||
versionCallback(this.#version); | ||
} | ||
else { | ||
else if (!this.#opened) { | ||
const openCallback = () => versionCallback(this.#version); | ||
this.#openCallbacks.push({ openCallback, errorCallback }); | ||
} | ||
else { | ||
versionCallback(this.#version); | ||
} | ||
}); | ||
@@ -111,0 +114,0 @@ } |
@@ -1,2 +0,1 @@ | ||
import { WebSocket } from "@libsql/isomorphic-ws"; | ||
import { IdAlloc } from "./id_alloc.js"; | ||
@@ -16,2 +15,4 @@ import { ClientError, ProtoError, ClosedError, WebSocketError, ProtocolVersionError } from "./errors.js"; | ||
#openCallbacks; | ||
// Have we already transitioned from CONNECTING to OPEN and fired the callbacks in #openCallbacks? | ||
#opened; | ||
// Stores the error that caused us to close the client (and the socket). If we are not closed, this is | ||
@@ -41,2 +42,3 @@ // `undefined`. | ||
this.#openCallbacks = []; | ||
this.#opened = false; | ||
this.#closed = undefined; | ||
@@ -61,3 +63,3 @@ this.#recvdHello = false; | ||
} | ||
if (this.#socket.readyState >= WebSocket.OPEN) { | ||
if (this.#opened) { | ||
this.#sendToSocket(msg); | ||
@@ -87,2 +89,3 @@ } | ||
this.#openCallbacks.length = 0; | ||
this.#opened = true; | ||
} | ||
@@ -99,9 +102,9 @@ #sendToSocket(msg) { | ||
} | ||
else if (this.#version !== undefined) { | ||
versionCallback(this.#version); | ||
} | ||
else { | ||
else if (!this.#opened) { | ||
const openCallback = () => versionCallback(this.#version); | ||
this.#openCallbacks.push({ openCallback, errorCallback }); | ||
} | ||
else { | ||
versionCallback(this.#version); | ||
} | ||
}); | ||
@@ -108,0 +111,0 @@ } |
{ | ||
"name": "@libsql/hrana-client", | ||
"version": "0.3.10", | ||
"version": "0.3.11", | ||
"keywords": [ | ||
@@ -5,0 +5,0 @@ "hrana", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
102139
2594