@arrirpc/client 0.69.1 → 0.70.1
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.cjs +24 -33
- package/dist/index.mjs +17 -33
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -9,12 +9,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
|
|
10
10
|
const NodeWebsocket__default = /*#__PURE__*/_interopDefaultCompat(NodeWebsocket);
|
|
11
11
|
|
|
12
|
-
var __defProp$1 = Object.defineProperty;
|
|
13
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
-
var __publicField$1 = (obj, key, value) => {
|
|
15
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
16
|
-
return value;
|
|
17
|
-
};
|
|
18
12
|
function isArriError(input) {
|
|
19
13
|
if (typeof input !== "object" || input === null) {
|
|
20
14
|
return false;
|
|
@@ -28,12 +22,12 @@ function isArriError(input) {
|
|
|
28
22
|
return "code" in input && typeof input.code === "number" && "message" in input && typeof input.message === "string";
|
|
29
23
|
}
|
|
30
24
|
class ArriErrorInstance extends Error {
|
|
25
|
+
code;
|
|
26
|
+
data;
|
|
27
|
+
serverStack;
|
|
28
|
+
_internalMessage;
|
|
31
29
|
constructor(input) {
|
|
32
30
|
super(input.message);
|
|
33
|
-
__publicField$1(this, "code");
|
|
34
|
-
__publicField$1(this, "data");
|
|
35
|
-
__publicField$1(this, "serverStack");
|
|
36
|
-
__publicField$1(this, "_internalMessage");
|
|
37
31
|
this.code = input.code;
|
|
38
32
|
this.serverStack = input.stack;
|
|
39
33
|
this._internalMessage = input.message;
|
|
@@ -104,10 +98,8 @@ async function arriRequest(opts) {
|
|
|
104
98
|
}
|
|
105
99
|
try {
|
|
106
100
|
const headers = await getHeaders(opts.headers) ?? {};
|
|
107
|
-
if (contentType)
|
|
108
|
-
|
|
109
|
-
if (opts.clientVersion)
|
|
110
|
-
headers["client-version"] = opts.clientVersion;
|
|
101
|
+
if (contentType) headers["Content-Type"] = contentType;
|
|
102
|
+
if (opts.clientVersion) headers["client-version"] = opts.clientVersion;
|
|
111
103
|
const result = await ofetch.ofetch(url, {
|
|
112
104
|
method: opts.method,
|
|
113
105
|
body,
|
|
@@ -127,8 +119,7 @@ async function arriRequest(opts) {
|
|
|
127
119
|
stack: error.stack
|
|
128
120
|
});
|
|
129
121
|
}
|
|
130
|
-
if (opts.onError)
|
|
131
|
-
opts.onError(arriError);
|
|
122
|
+
if (opts.onError) opts.onError(arriError);
|
|
132
123
|
throw arriError;
|
|
133
124
|
}
|
|
134
125
|
}
|
|
@@ -281,12 +272,6 @@ function arriSseRequest(opts, options) {
|
|
|
281
272
|
return controller;
|
|
282
273
|
}
|
|
283
274
|
|
|
284
|
-
var __defProp = Object.defineProperty;
|
|
285
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
286
|
-
var __publicField = (obj, key, value) => {
|
|
287
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
288
|
-
return value;
|
|
289
|
-
};
|
|
290
275
|
function isBrowser() {
|
|
291
276
|
return typeof window !== "undefined";
|
|
292
277
|
}
|
|
@@ -302,8 +287,7 @@ async function arriWsRequest(opts, retryCount = 0) {
|
|
|
302
287
|
let url = opts.url.replace("http://", "ws://").replace("https://", "wss://");
|
|
303
288
|
const headers = await getHeaders(opts.headers);
|
|
304
289
|
if (headers) {
|
|
305
|
-
if (opts.clientVersion)
|
|
306
|
-
headers["client-version"] = opts.clientVersion;
|
|
290
|
+
if (opts.clientVersion) headers["client-version"] = opts.clientVersion;
|
|
307
291
|
const queryParts = [];
|
|
308
292
|
for (const key of Object.keys(headers)) {
|
|
309
293
|
queryParts.push(`${key}=${headers[key]}`);
|
|
@@ -332,16 +316,16 @@ async function arriWsRequest(opts, retryCount = 0) {
|
|
|
332
316
|
}
|
|
333
317
|
}
|
|
334
318
|
class WsController {
|
|
319
|
+
url;
|
|
320
|
+
_ws;
|
|
321
|
+
_serializer;
|
|
322
|
+
_parser;
|
|
323
|
+
onMessage;
|
|
324
|
+
onErrorMessage;
|
|
325
|
+
onConnectionError;
|
|
326
|
+
onOpen;
|
|
327
|
+
onClose;
|
|
335
328
|
constructor(opts) {
|
|
336
|
-
__publicField(this, "url");
|
|
337
|
-
__publicField(this, "_ws");
|
|
338
|
-
__publicField(this, "_serializer");
|
|
339
|
-
__publicField(this, "_parser");
|
|
340
|
-
__publicField(this, "onMessage");
|
|
341
|
-
__publicField(this, "onErrorMessage");
|
|
342
|
-
__publicField(this, "onConnectionError");
|
|
343
|
-
__publicField(this, "onOpen");
|
|
344
|
-
__publicField(this, "onClose");
|
|
345
329
|
this.url = opts.url;
|
|
346
330
|
this._serializer = opts.serializer;
|
|
347
331
|
this._parser = opts.responseFromString;
|
|
@@ -461,6 +445,13 @@ exports.isArriError = isArriError;
|
|
|
461
445
|
exports.isObject = isObject;
|
|
462
446
|
exports.parsedWsResponse = parsedWsResponse;
|
|
463
447
|
exports.serializeString = serializeString;
|
|
448
|
+
Object.prototype.hasOwnProperty.call(eventSourcePlus, '__proto__') &&
|
|
449
|
+
!Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
|
|
450
|
+
Object.defineProperty(exports, '__proto__', {
|
|
451
|
+
enumerable: true,
|
|
452
|
+
value: eventSourcePlus['__proto__']
|
|
453
|
+
});
|
|
454
|
+
|
|
464
455
|
Object.keys(eventSourcePlus).forEach(function (k) {
|
|
465
456
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = eventSourcePlus[k];
|
|
466
457
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -4,12 +4,6 @@ import { EventSourcePlus } from 'event-source-plus';
|
|
|
4
4
|
export * from 'event-source-plus';
|
|
5
5
|
import NodeWebsocket from 'ws';
|
|
6
6
|
|
|
7
|
-
var __defProp$1 = Object.defineProperty;
|
|
8
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __publicField$1 = (obj, key, value) => {
|
|
10
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
-
return value;
|
|
12
|
-
};
|
|
13
7
|
function isArriError(input) {
|
|
14
8
|
if (typeof input !== "object" || input === null) {
|
|
15
9
|
return false;
|
|
@@ -23,12 +17,12 @@ function isArriError(input) {
|
|
|
23
17
|
return "code" in input && typeof input.code === "number" && "message" in input && typeof input.message === "string";
|
|
24
18
|
}
|
|
25
19
|
class ArriErrorInstance extends Error {
|
|
20
|
+
code;
|
|
21
|
+
data;
|
|
22
|
+
serverStack;
|
|
23
|
+
_internalMessage;
|
|
26
24
|
constructor(input) {
|
|
27
25
|
super(input.message);
|
|
28
|
-
__publicField$1(this, "code");
|
|
29
|
-
__publicField$1(this, "data");
|
|
30
|
-
__publicField$1(this, "serverStack");
|
|
31
|
-
__publicField$1(this, "_internalMessage");
|
|
32
26
|
this.code = input.code;
|
|
33
27
|
this.serverStack = input.stack;
|
|
34
28
|
this._internalMessage = input.message;
|
|
@@ -99,10 +93,8 @@ async function arriRequest(opts) {
|
|
|
99
93
|
}
|
|
100
94
|
try {
|
|
101
95
|
const headers = await getHeaders(opts.headers) ?? {};
|
|
102
|
-
if (contentType)
|
|
103
|
-
|
|
104
|
-
if (opts.clientVersion)
|
|
105
|
-
headers["client-version"] = opts.clientVersion;
|
|
96
|
+
if (contentType) headers["Content-Type"] = contentType;
|
|
97
|
+
if (opts.clientVersion) headers["client-version"] = opts.clientVersion;
|
|
106
98
|
const result = await ofetch(url, {
|
|
107
99
|
method: opts.method,
|
|
108
100
|
body,
|
|
@@ -122,8 +114,7 @@ async function arriRequest(opts) {
|
|
|
122
114
|
stack: error.stack
|
|
123
115
|
});
|
|
124
116
|
}
|
|
125
|
-
if (opts.onError)
|
|
126
|
-
opts.onError(arriError);
|
|
117
|
+
if (opts.onError) opts.onError(arriError);
|
|
127
118
|
throw arriError;
|
|
128
119
|
}
|
|
129
120
|
}
|
|
@@ -276,12 +267,6 @@ function arriSseRequest(opts, options) {
|
|
|
276
267
|
return controller;
|
|
277
268
|
}
|
|
278
269
|
|
|
279
|
-
var __defProp = Object.defineProperty;
|
|
280
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
281
|
-
var __publicField = (obj, key, value) => {
|
|
282
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
283
|
-
return value;
|
|
284
|
-
};
|
|
285
270
|
function isBrowser() {
|
|
286
271
|
return typeof window !== "undefined";
|
|
287
272
|
}
|
|
@@ -297,8 +282,7 @@ async function arriWsRequest(opts, retryCount = 0) {
|
|
|
297
282
|
let url = opts.url.replace("http://", "ws://").replace("https://", "wss://");
|
|
298
283
|
const headers = await getHeaders(opts.headers);
|
|
299
284
|
if (headers) {
|
|
300
|
-
if (opts.clientVersion)
|
|
301
|
-
headers["client-version"] = opts.clientVersion;
|
|
285
|
+
if (opts.clientVersion) headers["client-version"] = opts.clientVersion;
|
|
302
286
|
const queryParts = [];
|
|
303
287
|
for (const key of Object.keys(headers)) {
|
|
304
288
|
queryParts.push(`${key}=${headers[key]}`);
|
|
@@ -327,16 +311,16 @@ async function arriWsRequest(opts, retryCount = 0) {
|
|
|
327
311
|
}
|
|
328
312
|
}
|
|
329
313
|
class WsController {
|
|
314
|
+
url;
|
|
315
|
+
_ws;
|
|
316
|
+
_serializer;
|
|
317
|
+
_parser;
|
|
318
|
+
onMessage;
|
|
319
|
+
onErrorMessage;
|
|
320
|
+
onConnectionError;
|
|
321
|
+
onOpen;
|
|
322
|
+
onClose;
|
|
330
323
|
constructor(opts) {
|
|
331
|
-
__publicField(this, "url");
|
|
332
|
-
__publicField(this, "_ws");
|
|
333
|
-
__publicField(this, "_serializer");
|
|
334
|
-
__publicField(this, "_parser");
|
|
335
|
-
__publicField(this, "onMessage");
|
|
336
|
-
__publicField(this, "onErrorMessage");
|
|
337
|
-
__publicField(this, "onConnectionError");
|
|
338
|
-
__publicField(this, "onOpen");
|
|
339
|
-
__publicField(this, "onClose");
|
|
340
324
|
this.url = opts.url;
|
|
341
325
|
this._serializer = opts.serializer;
|
|
342
326
|
this._parser = opts.responseFromString;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.70.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"event-source-plus": "^0.1.8",
|
|
26
26
|
"ofetch": "^1.4.1",
|
|
27
27
|
"ws": "^8.18.0",
|
|
28
|
-
"@arrirpc/schema": "0.
|
|
28
|
+
"@arrirpc/schema": "0.70.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.5.13"
|