@arrirpc/client 0.76.0 → 0.76.2-beta.0
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 +5 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.mjs +4 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -100,7 +100,8 @@ async function arriRequest(opts) {
|
|
|
100
100
|
const headers = await getHeaders(opts.headers) ?? {};
|
|
101
101
|
if (contentType) headers["Content-Type"] = contentType;
|
|
102
102
|
if (opts.clientVersion) headers["client-version"] = opts.clientVersion;
|
|
103
|
-
const
|
|
103
|
+
const fetchInstance = opts.ofetch ?? ofetch.ofetch;
|
|
104
|
+
const result = await fetchInstance(url, {
|
|
104
105
|
method: opts.method,
|
|
105
106
|
body,
|
|
106
107
|
headers
|
|
@@ -205,6 +206,7 @@ function arriSseRequest(opts, options) {
|
|
|
205
206
|
}
|
|
206
207
|
const eventSource = new eventSourcePlus.EventSourcePlus(url, {
|
|
207
208
|
method: opts.method ?? "get",
|
|
209
|
+
fetch: opts.ofetch?.native,
|
|
208
210
|
headers: async () => {
|
|
209
211
|
const headers = await getHeaders(opts.headers) ?? {};
|
|
210
212
|
if (opts.clientVersion) {
|
|
@@ -423,6 +425,8 @@ function parsedWsResponse(input) {
|
|
|
423
425
|
};
|
|
424
426
|
}
|
|
425
427
|
|
|
428
|
+
exports.createFetch = ofetch.createFetch;
|
|
429
|
+
exports.ofetch = ofetch.ofetch;
|
|
426
430
|
exports.ArriErrorInstance = ArriErrorInstance;
|
|
427
431
|
exports.INT16_MAX = INT16_MAX;
|
|
428
432
|
exports.INT16_MIN = INT16_MIN;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HttpMethod, EventSourcePlusOptions, OnRequestContext, OnRequestErrorContext, OnResponseContext, OnResponseErrorContext, EventSourceController } from 'event-source-plus';
|
|
2
2
|
export * from 'event-source-plus';
|
|
3
|
+
import { $Fetch } from 'ofetch';
|
|
4
|
+
export { $Fetch, Fetch, createFetch, ofetch } from 'ofetch';
|
|
3
5
|
|
|
4
6
|
interface ArriError {
|
|
5
7
|
code: number;
|
|
@@ -36,6 +38,10 @@ interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined =
|
|
|
36
38
|
responseFromJson: (input: Record<string, unknown>) => TType;
|
|
37
39
|
responseFromString: (input: string) => TType;
|
|
38
40
|
onError?: (err: unknown) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Override the default ofetch implementation
|
|
43
|
+
*/
|
|
44
|
+
ofetch?: $Fetch;
|
|
39
45
|
serializer: (input: TParams) => TParams extends undefined ? undefined : string;
|
|
40
46
|
clientVersion: string;
|
|
41
47
|
}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HttpMethod, EventSourcePlusOptions, OnRequestContext, OnRequestErrorContext, OnResponseContext, OnResponseErrorContext, EventSourceController } from 'event-source-plus';
|
|
2
2
|
export * from 'event-source-plus';
|
|
3
|
+
import { $Fetch } from 'ofetch';
|
|
4
|
+
export { $Fetch, Fetch, createFetch, ofetch } from 'ofetch';
|
|
3
5
|
|
|
4
6
|
interface ArriError {
|
|
5
7
|
code: number;
|
|
@@ -36,6 +38,10 @@ interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined =
|
|
|
36
38
|
responseFromJson: (input: Record<string, unknown>) => TType;
|
|
37
39
|
responseFromString: (input: string) => TType;
|
|
38
40
|
onError?: (err: unknown) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Override the default ofetch implementation
|
|
43
|
+
*/
|
|
44
|
+
ofetch?: $Fetch;
|
|
39
45
|
serializer: (input: TParams) => TParams extends undefined ? undefined : string;
|
|
40
46
|
clientVersion: string;
|
|
41
47
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { HttpMethod, EventSourcePlusOptions, OnRequestContext, OnRequestErrorContext, OnResponseContext, OnResponseErrorContext, EventSourceController } from 'event-source-plus';
|
|
2
2
|
export * from 'event-source-plus';
|
|
3
|
+
import { $Fetch } from 'ofetch';
|
|
4
|
+
export { $Fetch, Fetch, createFetch, ofetch } from 'ofetch';
|
|
3
5
|
|
|
4
6
|
interface ArriError {
|
|
5
7
|
code: number;
|
|
@@ -36,6 +38,10 @@ interface ArriRequestOpts<TType, TParams extends Record<any, any> | undefined =
|
|
|
36
38
|
responseFromJson: (input: Record<string, unknown>) => TType;
|
|
37
39
|
responseFromString: (input: string) => TType;
|
|
38
40
|
onError?: (err: unknown) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Override the default ofetch implementation
|
|
43
|
+
*/
|
|
44
|
+
ofetch?: $Fetch;
|
|
39
45
|
serializer: (input: TParams) => TParams extends undefined ? undefined : string;
|
|
40
46
|
clientVersion: string;
|
|
41
47
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { serializeSmallString } from '@arrirpc/schema';
|
|
2
2
|
import { ofetch, FetchError } from 'ofetch';
|
|
3
|
+
export { createFetch, ofetch } from 'ofetch';
|
|
3
4
|
import { EventSourcePlus } from 'event-source-plus';
|
|
4
5
|
export * from 'event-source-plus';
|
|
5
6
|
import NodeWebsocket from 'ws';
|
|
@@ -95,7 +96,8 @@ async function arriRequest(opts) {
|
|
|
95
96
|
const headers = await getHeaders(opts.headers) ?? {};
|
|
96
97
|
if (contentType) headers["Content-Type"] = contentType;
|
|
97
98
|
if (opts.clientVersion) headers["client-version"] = opts.clientVersion;
|
|
98
|
-
const
|
|
99
|
+
const fetchInstance = opts.ofetch ?? ofetch;
|
|
100
|
+
const result = await fetchInstance(url, {
|
|
99
101
|
method: opts.method,
|
|
100
102
|
body,
|
|
101
103
|
headers
|
|
@@ -200,6 +202,7 @@ function arriSseRequest(opts, options) {
|
|
|
200
202
|
}
|
|
201
203
|
const eventSource = new EventSourcePlus(url, {
|
|
202
204
|
method: opts.method ?? "get",
|
|
205
|
+
fetch: opts.ofetch?.native,
|
|
203
206
|
headers: async () => {
|
|
204
207
|
const headers = await getHeaders(opts.headers) ?? {};
|
|
205
208
|
if (opts.clientVersion) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arrirpc/client",
|
|
3
|
-
"version": "0.76.0",
|
|
3
|
+
"version": "0.76.2-beta.0",
|
|
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.76.0"
|
|
28
|
+
"@arrirpc/schema": "0.76.2-beta.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/ws": "^8.5.14"
|