@nomalism-com/api 0.45.10 → 0.45.14
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
|
@@ -135,9 +135,9 @@ var MAX_BACKOFF_MS = 3e4;
|
|
|
135
135
|
var BASE_BACKOFF_MS = 1e3;
|
|
136
136
|
var Service = class {
|
|
137
137
|
constructor({ route }) {
|
|
138
|
-
this.route = route;
|
|
138
|
+
this.route = route.replace(/^http(s?):/i, "ws$1:");
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
openSocket({
|
|
141
141
|
token,
|
|
142
142
|
onEvent,
|
|
143
143
|
onOpen,
|
|
@@ -165,7 +165,7 @@ var Service = class {
|
|
|
165
165
|
try {
|
|
166
166
|
ws.send(JSON.stringify({ type: "ping" }));
|
|
167
167
|
} catch (err) {
|
|
168
|
-
console.warn("
|
|
168
|
+
console.warn("WebSocket ping failed", err);
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}, PING_INTERVAL_MS);
|
|
@@ -181,7 +181,7 @@ var Service = class {
|
|
|
181
181
|
try {
|
|
182
182
|
ws = new WebSocket(this.route, [subprotocol]);
|
|
183
183
|
} catch (err) {
|
|
184
|
-
console.error("
|
|
184
|
+
console.error("WebSocket constructor threw", err);
|
|
185
185
|
scheduleReconnect();
|
|
186
186
|
return;
|
|
187
187
|
}
|
|
@@ -200,30 +200,30 @@ var Service = class {
|
|
|
200
200
|
try {
|
|
201
201
|
payload = JSON.parse(msg.data);
|
|
202
202
|
} catch {
|
|
203
|
-
console.warn("
|
|
203
|
+
console.warn("WebSocket received non-JSON frame", msg.data);
|
|
204
204
|
return;
|
|
205
205
|
}
|
|
206
206
|
if (payload.type === "ping" || payload.type === "pong") return;
|
|
207
207
|
try {
|
|
208
208
|
onEvent(payload);
|
|
209
209
|
} catch (err) {
|
|
210
|
-
console.error("
|
|
210
|
+
console.error("WebSocket event handler threw", err, payload);
|
|
211
211
|
}
|
|
212
212
|
};
|
|
213
213
|
ws.onerror = (err) => {
|
|
214
|
-
console.warn("
|
|
214
|
+
console.warn("WebSocket error", err);
|
|
215
215
|
};
|
|
216
216
|
ws.onclose = (e) => {
|
|
217
217
|
stopPing();
|
|
218
218
|
ws = null;
|
|
219
219
|
onClose?.();
|
|
220
220
|
if (e.code === CLOSE_AUTH_REJECTED) {
|
|
221
|
-
console.error("
|
|
221
|
+
console.error("WebSocket auth rejected by server, not reconnecting");
|
|
222
222
|
closedByCaller = true;
|
|
223
223
|
return;
|
|
224
224
|
}
|
|
225
225
|
if (e.code === CLOSE_AUTH_UNAVAILABLE) {
|
|
226
|
-
console.warn("
|
|
226
|
+
console.warn("WebSocket auth verifier unavailable, retrying");
|
|
227
227
|
attempts = Math.min(attempts, 2);
|
|
228
228
|
onAuthUnverified?.();
|
|
229
229
|
scheduleReconnect();
|
|
@@ -3,5 +3,5 @@ import type { IModuleConstructor } from '../../main';
|
|
|
3
3
|
export default class Service implements Nomalism.WebSocket.IClient {
|
|
4
4
|
route: string;
|
|
5
5
|
constructor({ route }: IModuleConstructor);
|
|
6
|
-
|
|
6
|
+
openSocket<T extends Nomalism.WebSocket.IEvent>({ token, onEvent, onOpen, onReconnect, onClose, onAuthUnverified, }: Nomalism.WebSocket.SocketOptions<T>): Nomalism.WebSocket.SocketHandle;
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomalism-com/api",
|
|
3
3
|
"description": "A nomalism API package for performing HTTP requests on API endpoints",
|
|
4
|
-
"version": "0.45.
|
|
4
|
+
"version": "0.45.14",
|
|
5
5
|
"author": "Nomalism <it.nomalism@gmail.com> (https://https://nomalism.com/)",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"type": "module",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
"prepack": "npm run lint && npm run build"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@nomalism-com/types": "^0.45.
|
|
26
|
+
"@nomalism-com/types": "^0.45.17",
|
|
27
27
|
"axios": "^1.16.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@swc/core": "^1.15.
|
|
30
|
+
"@swc/core": "^1.15.40",
|
|
31
31
|
"@types/node": "^24.12.4",
|
|
32
32
|
"@typescript-eslint/eslint-plugin": "^8.59.4",
|
|
33
33
|
"@typescript-eslint/parser": "^8.59.4",
|