@orpc/client 2.0.0-beta.49 → 2.0.0-beta.50

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.
Files changed (75) hide show
  1. package/dist/adapters/fetch/index.d.ts +3 -2
  2. package/dist/adapters/fetch/index.js +2 -2
  3. package/dist/adapters/fetch/rpc-link.d.ts +8 -8
  4. package/dist/adapters/fetch/rpc-link.js +16 -13
  5. package/dist/adapters/fetch/transport.d.ts +29 -31
  6. package/dist/adapters/fetch/transport.js +49 -63
  7. package/dist/adapters/message-port/index.d.ts +4 -3
  8. package/dist/adapters/message-port/index.js +3 -3
  9. package/dist/adapters/message-port/message-port.d.ts +13 -13
  10. package/dist/adapters/message-port/message-port.js +35 -53
  11. package/dist/adapters/message-port/rpc-link.d.ts +8 -8
  12. package/dist/adapters/message-port/rpc-link.js +17 -14
  13. package/dist/adapters/message-port/transport.d.ts +31 -34
  14. package/dist/adapters/message-port/transport.js +38 -52
  15. package/dist/adapters/standard/codec.d.ts +10 -10
  16. package/dist/adapters/standard/index.d.ts +6 -5
  17. package/dist/adapters/standard/index.js +2 -4
  18. package/dist/adapters/standard/link.d.ts +31 -31
  19. package/dist/adapters/standard/link.js +101 -85
  20. package/dist/adapters/standard/plugin.d.ts +25 -31
  21. package/dist/adapters/standard/plugin.js +14 -16
  22. package/dist/adapters/standard/rpc-link-codec.d.ts +53 -60
  23. package/dist/adapters/standard/rpc-link-codec.js +98 -102
  24. package/dist/adapters/standard/transport.d.ts +7 -7
  25. package/dist/adapters/websocket/index.d.ts +3 -2
  26. package/dist/adapters/websocket/index.js +2 -2
  27. package/dist/adapters/websocket/rpc-link.d.ts +8 -8
  28. package/dist/adapters/websocket/rpc-link.js +16 -13
  29. package/dist/adapters/websocket/transport.d.ts +101 -100
  30. package/dist/adapters/websocket/transport.js +102 -130
  31. package/dist/async-iterator-object.d.ts +2 -2
  32. package/dist/async-iterator-object.js +27 -28
  33. package/dist/client-safe.d.ts +4 -6
  34. package/dist/client-safe.js +29 -34
  35. package/dist/client.d.ts +24 -26
  36. package/dist/client.js +35 -37
  37. package/dist/consts.d.ts +1 -1
  38. package/dist/consts.js +18 -41
  39. package/dist/dynamic-link.d.ts +6 -6
  40. package/dist/dynamic-link.js +16 -16
  41. package/dist/error-utils.d.ts +3 -4
  42. package/dist/error-utils.js +47 -51
  43. package/dist/error.d.ts +79 -79
  44. package/dist/error.js +154 -166
  45. package/dist/index.d.ts +14 -53
  46. package/dist/index.js +12 -40
  47. package/dist/plugins/batch.d.ts +122 -155
  48. package/dist/plugins/batch.js +320 -391
  49. package/dist/plugins/cookie-jar.d.ts +64 -61
  50. package/dist/plugins/cookie-jar.js +208 -245
  51. package/dist/plugins/dedupe.d.ts +49 -53
  52. package/dist/plugins/dedupe.js +168 -211
  53. package/dist/plugins/index.d.ts +9 -28
  54. package/dist/plugins/index.js +8 -23
  55. package/dist/plugins/request-compression.d.ts +38 -35
  56. package/dist/plugins/request-compression.js +131 -177
  57. package/dist/plugins/response-compression.d.ts +21 -18
  58. package/dist/plugins/response-compression.js +64 -88
  59. package/dist/plugins/retry-after.d.ts +31 -38
  60. package/dist/plugins/retry-after.js +60 -85
  61. package/dist/plugins/retry.d.ts +55 -55
  62. package/dist/plugins/retry.js +118 -137
  63. package/dist/plugins/timeout.d.ts +19 -17
  64. package/dist/plugins/timeout.js +41 -36
  65. package/dist/rpc-json-serializer.d.ts +84 -84
  66. package/dist/rpc-json-serializer.js +338 -383
  67. package/dist/rpc-serializer.d.ts +20 -21
  68. package/dist/rpc-serializer.js +97 -125
  69. package/dist/types.d.ts +19 -31
  70. package/dist/utils.d.ts +18 -29
  71. package/dist/utils.js +63 -47
  72. package/package.json +5 -5
  73. package/dist/adapters/standard/codec.js +0 -1
  74. package/dist/adapters/standard/transport.js +0 -1
  75. package/dist/types.js +0 -1
@@ -1,46 +1,42 @@
1
- import type { Value } from '@orpc/shared';
2
- import type { StandardLinkOptions, StandardLinkPlugin, StandardLinkTransportInterceptorOptions } from '../adapters/standard/index.ts';
3
- import type { ClientContext } from '../types.ts';
1
+ import "../adapters/standard/index.js";
2
+ import { StandardLinkPlugin } from "../adapters/standard/plugin.js";
3
+ import { StandardLinkOptions, StandardLinkTransportInterceptorOptions } from "../adapters/standard/link.js";
4
+ import { ClientContext } from "../types.js";
5
+ import { Value } from "@orpc/shared";
4
6
  export interface DedupeLinkPluginGroup<T extends ClientContext> {
5
- condition: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
6
- /**
7
- * The context used for the rest of the request lifecycle.
8
- */
9
- context: Value<T, [
10
- items: [
11
- StandardLinkTransportInterceptorOptions<T>,
12
- StandardLinkTransportInterceptorOptions<T>,
13
- ...StandardLinkTransportInterceptorOptions<T>[]
14
- ]
15
- ]>;
7
+ condition: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
8
+ /**
9
+ * The context used for the rest of the request lifecycle.
10
+ */
11
+ context: Value<T, [items: [StandardLinkTransportInterceptorOptions<T>, StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
16
12
  }
17
13
  export interface DedupeLinkPluginOptions<T extends ClientContext> {
18
- /**
19
- * To enable deduplication, a request must match at least one defined group.
20
- * Requests that fall into the same group are considered for deduplication together.
21
- */
22
- groups: [DedupeLinkPluginGroup<T>, ...DedupeLinkPluginGroup<T>[]];
23
- /**
24
- * Filters requests to dedupe.
25
- *
26
- * @default ({ request }) => request.method === 'GET' || request.method === 'QUERY'
27
- */
28
- filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
29
- /**
30
- * Only requests with the same scope are deduplicated together.
31
- * On the server, return a value unique to the incoming request so different users never share a response.
32
- *
33
- * @default () => undefined
34
- */
35
- scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
36
- /**
37
- * How long (in ms) to wait for more identical requests before sending,
38
- * counted from the first queued request.
39
- * With `0`, only requests made in the same event loop tick are deduplicated.
40
- *
41
- * @default 0
42
- */
43
- wait?: number | undefined;
14
+ /**
15
+ * To enable deduplication, a request must match at least one defined group.
16
+ * Requests that fall into the same group are considered for deduplication together.
17
+ */
18
+ groups: [DedupeLinkPluginGroup<T>, ...DedupeLinkPluginGroup<T>[]];
19
+ /**
20
+ * Filters requests to dedupe.
21
+ *
22
+ * @default ({ request }) => request.method === 'GET' || request.method === 'QUERY'
23
+ */
24
+ filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
25
+ /**
26
+ * Only requests with the same scope are deduplicated together.
27
+ * On the server, return a value unique to the incoming request so different users never share a response.
28
+ *
29
+ * @default () => undefined
30
+ */
31
+ scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
32
+ /**
33
+ * How long (in ms) to wait for more identical requests before sending,
34
+ * counted from the first queued request.
35
+ * With `0`, only requests made in the same event loop tick are deduplicated.
36
+ *
37
+ * @default 0
38
+ */
39
+ wait?: number | undefined;
44
40
  }
45
41
  /**
46
42
  * Prevents redundant requests by deduplicating similar in-flight requests,
@@ -49,16 +45,16 @@ export interface DedupeLinkPluginOptions<T extends ClientContext> {
49
45
  * @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
50
46
  */
51
47
  export declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
52
- name: string;
53
- before: string[];
54
- private readonly groups;
55
- private readonly filter;
56
- private readonly scope;
57
- private readonly wait;
58
- private readonly queue;
59
- constructor(options: NoInfer<DedupeLinkPluginOptions<T>>);
60
- init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
61
- private enqueue;
62
- private processPendingRequests;
63
- private execute;
64
- }
48
+ name: string;
49
+ before: string[];
50
+ private readonly groups;
51
+ private readonly filter;
52
+ private readonly scope;
53
+ private readonly wait;
54
+ private readonly queue;
55
+ constructor(options: NoInfer<DedupeLinkPluginOptions<T>>);
56
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
57
+ private enqueue;
58
+ private processPendingRequests;
59
+ private execute;
60
+ }
@@ -1,226 +1,183 @@
1
- import { captureAsyncContext, defer, disposableAllAbortSignal, isAsyncIteratorObject, replicateAsyncIterator, replicateReadableStream, runWithSignal, stringifyJSON, throwIfAborted, toArray, value, wrapAsyncIterator, } from '@orpc/shared';
1
+ import { captureAsyncContext, defer, disposableAllAbortSignal, isAsyncIteratorObject, listenAbort, replicateAsyncIterator, replicateReadableStream, runWithSignal, stringifyJSON, throwIfAborted, toArray, value, wrapAsyncIterator } from "@orpc/shared";
2
+ // src/plugins/dedupe.ts
2
3
  /**
3
- * Prevents redundant requests by deduplicating similar in-flight requests,
4
- * reducing the number of requests sent to the server.
5
- *
6
- * @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
7
- */
8
- export class DedupeLinkPlugin {
9
- name = '~dedupe';
10
- before = ['~batch'];
11
- groups;
12
- filter;
13
- scope;
14
- wait;
15
- queue = new Map();
16
- constructor(options) {
17
- this.groups = options.groups;
18
- this.filter =
19
- options.filter ?? (({ request }) => request.method === 'GET' || request.method === 'QUERY');
20
- this.scope = options.scope ?? (() => undefined);
21
- this.wait = options.wait ?? 0;
22
- }
23
- init(options) {
24
- const transportInterceptor = (interceptorOptions) => {
25
- if (!canDedupeRequest(interceptorOptions.request) ||
26
- !value(this.filter, interceptorOptions)) {
27
- return interceptorOptions.next();
28
- }
29
- const group = this.groups.find((group) => value(group.condition, interceptorOptions));
30
- if (!group) {
31
- return interceptorOptions.next();
32
- }
33
- const scope = this.scope(interceptorOptions);
34
- return runWithSignal(interceptorOptions.request.signal, () => new Promise((resolve, reject) => {
35
- // Schedule only for the first queued request, so later ones cannot extend or split the wait.
36
- if (!this.queue.size) {
37
- defer(() => this.processPendingRequests(), this.wait);
38
- }
39
- this.enqueue(scope, group, {
40
- options: interceptorOptions,
41
- resolve,
42
- reject,
43
- runInOwnContext: captureAsyncContext(),
44
- });
45
- }));
46
- };
47
- return {
48
- ...options,
49
- transportInterceptors: [...toArray(options.transportInterceptors), transportInterceptor],
50
- };
51
- }
52
- enqueue(scope, group, caller) {
53
- let groups = this.queue.get(scope);
54
- if (!groups) {
55
- groups = new Map();
56
- this.queue.set(scope, groups);
57
- }
58
- let queue = groups.get(group);
59
- if (!queue) {
60
- queue = new Map();
61
- groups.set(group, queue);
62
- }
63
- const requestKey = createRequestKey(caller.options.path, caller.options.request);
64
- const matched = queue.get(requestKey);
65
- if (matched) {
66
- matched.push(caller);
67
- return;
68
- }
69
- queue.set(requestKey, [caller]);
70
- }
71
- async processPendingRequests() {
72
- const pending = [...this.queue.values()];
73
- this.queue.clear();
74
- const executions = [];
75
- for (const groups of pending) {
76
- for (const [group, items] of groups) {
77
- for (const callers of items.values()) {
78
- const activeCallers = callers.filter((caller) => !caller.options.request.signal?.aborted);
79
- const [first] = activeCallers;
80
- if (first) {
81
- // Send in the first active caller's async context instead of the timer's, so the transport sees its request state.
82
- executions.push(first.runInOwnContext(() => this.execute(group, activeCallers)));
83
- }
84
- }
85
- }
86
- }
87
- await Promise.all(executions);
88
- }
89
- async execute(group, activeCallers) {
90
- const first = activeCallers[0];
91
- const matchedOptions = activeCallers.map((caller) => caller.options);
92
- let sharedSignal;
93
- try {
94
- if (!shouldDedupe(matchedOptions)) {
95
- const response = await first.options.next(first.options);
96
- first.resolve(response);
97
- return;
98
- }
99
- const context = value(group.context, matchedOptions);
100
- const signals = matchedOptions.map((options) => options.request.signal);
101
- sharedSignal = disposableAllAbortSignal(signals);
102
- const request = {
103
- ...first.options.request,
104
- signal: sharedSignal.signal,
105
- };
106
- const response = await first.options.next({
107
- ...first.options,
108
- request,
109
- signal: request.signal,
110
- context,
111
- });
112
- const { dispose } = sharedSignal;
113
- const replicatedResponses = replicateLazyResponse({ ...response, resolveBody: (hint) => response.resolveBody(hint).finally(dispose) }, signals);
114
- activeCallers.forEach((caller, index) => caller.resolve(replicatedResponses[index]));
115
- }
116
- catch (error) {
117
- sharedSignal?.dispose();
118
- for (const caller of activeCallers) {
119
- caller.reject(error);
120
- }
121
- }
122
- }
123
- }
4
+ * Prevents redundant requests by deduplicating similar in-flight requests,
5
+ * reducing the number of requests sent to the server.
6
+ *
7
+ * @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
8
+ */
9
+ var DedupeLinkPlugin = class {
10
+ name = "~dedupe";
11
+ before = ["~batch"];
12
+ groups;
13
+ filter;
14
+ scope;
15
+ wait;
16
+ queue = /* @__PURE__ */ new Map();
17
+ constructor(options) {
18
+ this.groups = options.groups;
19
+ this.filter = options.filter ?? (({ request }) => request.method === "GET" || request.method === "QUERY");
20
+ this.scope = options.scope ?? (() => void 0);
21
+ this.wait = options.wait ?? 0;
22
+ }
23
+ init(options) {
24
+ const transportInterceptor = (interceptorOptions) => {
25
+ if (!canDedupeRequest(interceptorOptions.request) || !value(this.filter, interceptorOptions)) return interceptorOptions.next();
26
+ const group = this.groups.find((group) => value(group.condition, interceptorOptions));
27
+ if (!group) return interceptorOptions.next();
28
+ const scope = this.scope(interceptorOptions);
29
+ return runWithSignal(interceptorOptions.request.signal, () => new Promise((resolve, reject) => {
30
+ if (!this.queue.size) defer(() => this.processPendingRequests(), this.wait);
31
+ this.enqueue(scope, group, {
32
+ options: interceptorOptions,
33
+ resolve,
34
+ reject,
35
+ runInOwnContext: captureAsyncContext()
36
+ });
37
+ }));
38
+ };
39
+ return {
40
+ ...options,
41
+ transportInterceptors: [...toArray(options.transportInterceptors), transportInterceptor]
42
+ };
43
+ }
44
+ enqueue(scope, group, caller) {
45
+ let groups = this.queue.get(scope);
46
+ if (!groups) {
47
+ groups = /* @__PURE__ */ new Map();
48
+ this.queue.set(scope, groups);
49
+ }
50
+ let queue = groups.get(group);
51
+ if (!queue) {
52
+ queue = /* @__PURE__ */ new Map();
53
+ groups.set(group, queue);
54
+ }
55
+ const requestKey = createRequestKey(caller.options.path, caller.options.request);
56
+ const matched = queue.get(requestKey);
57
+ if (matched) {
58
+ matched.push(caller);
59
+ return;
60
+ }
61
+ queue.set(requestKey, [caller]);
62
+ }
63
+ async processPendingRequests() {
64
+ const pending = [...this.queue.values()];
65
+ this.queue.clear();
66
+ const executions = [];
67
+ for (const groups of pending) for (const [group, items] of groups) for (const callers of items.values()) {
68
+ const activeCallers = callers.filter((caller) => !caller.options.request.signal?.aborted);
69
+ const [first] = activeCallers;
70
+ if (first) executions.push(first.runInOwnContext(() => this.execute(group, activeCallers)));
71
+ }
72
+ await Promise.all(executions);
73
+ }
74
+ async execute(group, activeCallers) {
75
+ const first = activeCallers[0];
76
+ const matchedOptions = activeCallers.map((caller) => caller.options);
77
+ let sharedSignal;
78
+ try {
79
+ if (!shouldDedupe(matchedOptions)) {
80
+ const response = await first.options.next(first.options);
81
+ first.resolve(response);
82
+ return;
83
+ }
84
+ const context = value(group.context, matchedOptions);
85
+ const signals = matchedOptions.map((options) => options.request.signal);
86
+ sharedSignal = disposableAllAbortSignal(signals);
87
+ const request = {
88
+ ...first.options.request,
89
+ signal: sharedSignal.signal
90
+ };
91
+ const response = await first.options.next({
92
+ ...first.options,
93
+ request,
94
+ signal: request.signal,
95
+ context
96
+ });
97
+ const { dispose } = sharedSignal;
98
+ const replicatedResponses = replicateLazyResponse({
99
+ ...response,
100
+ resolveBody: (hint) => response.resolveBody(hint).finally(dispose)
101
+ }, signals);
102
+ activeCallers.forEach((caller, index) => caller.resolve(replicatedResponses[index]));
103
+ } catch (error) {
104
+ sharedSignal?.dispose();
105
+ for (const caller of activeCallers) caller.reject(error);
106
+ }
107
+ }
108
+ };
124
109
  function canDedupeRequest(request) {
125
- return !(request.body instanceof Blob ||
126
- request.body instanceof FormData ||
127
- request.body instanceof URLSearchParams ||
128
- request.body instanceof ReadableStream ||
129
- isAsyncIteratorObject(request.body) ||
130
- request.signal?.aborted);
110
+ return !(request.body instanceof Blob || request.body instanceof FormData || request.body instanceof URLSearchParams || request.body instanceof ReadableStream || isAsyncIteratorObject(request.body) || request.signal?.aborted);
131
111
  }
132
112
  function createRequestKey(path, request) {
133
- return stringifyJSON({
134
- path,
135
- body: request.body,
136
- headers: request.headers,
137
- method: request.method,
138
- url: request.url,
139
- });
113
+ return stringifyJSON({
114
+ path,
115
+ body: request.body,
116
+ headers: request.headers,
117
+ method: request.method,
118
+ url: request.url
119
+ });
140
120
  }
141
121
  /**
142
- * Replicates the response once per signal. Like an unshared response, each replica's body
143
- * fails and stops streaming once its own signal aborts, without affecting the other replicas.
144
- */
122
+ * Replicates the response once per signal. Like an unshared response, each replica's body
123
+ * fails and stops streaming once its own signal aborts, without affecting the other replicas.
124
+ */
145
125
  function replicateLazyResponse(response, signals) {
146
- let bodiesPromise;
147
- return signals.map((signal, i) => ({
148
- ...response,
149
- resolveBody: (hint) => runWithSignal(signal, async () => {
150
- bodiesPromise ??= response.resolveBody(hint).then((body) => {
151
- if (isAsyncIteratorObject(body)) {
152
- return replicateAsyncIterator(body, signals.length).map((replica, index) => closeAsyncIteratorOnAbort(replica, signals[index]));
153
- }
154
- if (body instanceof ReadableStream) {
155
- return replicateReadableStream(body, signals.length).map((replica, index) => closeReadableStreamOnAbort(replica, signals[index]));
156
- }
157
- return signals.map(() => body);
158
- });
159
- return (await bodiesPromise)[i];
160
- }),
161
- }));
126
+ let bodiesPromise;
127
+ return signals.map((signal, i) => ({
128
+ ...response,
129
+ resolveBody: (hint) => runWithSignal(signal, async () => {
130
+ bodiesPromise ??= response.resolveBody(hint).then((body) => {
131
+ if (isAsyncIteratorObject(body)) return replicateAsyncIterator(body, signals.length).map((replica, index) => closeAsyncIteratorOnAbort(replica, signals[index]));
132
+ if (body instanceof ReadableStream) return replicateReadableStream(body, signals.length).map((replica, index) => closeReadableStreamOnAbort(replica, signals[index]));
133
+ return signals.map(() => body);
134
+ });
135
+ return (await bodiesPromise)[i];
136
+ })
137
+ }));
162
138
  }
163
139
  function closeAsyncIteratorOnAbort(replica, signal) {
164
- if (!signal) {
165
- return replica;
166
- }
167
- const abort = () => replica.return().catch(() => { });
168
- if (signal.aborted) {
169
- void abort();
170
- }
171
- else {
172
- signal.addEventListener('abort', abort, { once: true });
173
- }
174
- return wrapAsyncIterator(replica, {
175
- mapResult(result) {
176
- // Ending the replica reports its reads as done rather than failed.
177
- throwIfAborted(signal);
178
- return result;
179
- },
180
- onFinish: () => signal.removeEventListener('abort', abort),
181
- });
140
+ if (!signal) return replica;
141
+ const removeAbortListener = listenAbort(signal, () => void replica.return().catch(() => {}));
142
+ return wrapAsyncIterator(replica, {
143
+ mapResult(result) {
144
+ throwIfAborted(signal);
145
+ return result;
146
+ },
147
+ onFinish: removeAbortListener
148
+ });
182
149
  }
183
150
  /**
184
- * Cancels the replica on abort even when nothing is reading it, which an aborted
185
- * `pipeThrough` would not do until the in-flight chunk is read.
186
- */
151
+ * Cancels the replica on abort even when nothing is reading it, which an aborted
152
+ * `pipeThrough` would not do until the in-flight chunk is read.
153
+ */
187
154
  function closeReadableStreamOnAbort(replica, signal) {
188
- if (!signal) {
189
- return replica;
190
- }
191
- const reader = replica.getReader();
192
- const abort = () => reader.cancel(signal.reason).catch(() => { });
193
- if (signal.aborted) {
194
- void abort();
195
- }
196
- else {
197
- signal.addEventListener('abort', abort, { once: true });
198
- }
199
- return new ReadableStream({
200
- async pull(controller) {
201
- try {
202
- const result = await reader.read();
203
- // Cancelling the replica reports its reads as done rather than failed.
204
- throwIfAborted(signal);
205
- if (result.done) {
206
- signal.removeEventListener('abort', abort);
207
- controller.close();
208
- }
209
- else {
210
- controller.enqueue(result.value);
211
- }
212
- }
213
- catch (error) {
214
- signal.removeEventListener('abort', abort);
215
- throw error;
216
- }
217
- },
218
- async cancel(reason) {
219
- signal.removeEventListener('abort', abort);
220
- await reader.cancel(reason);
221
- },
222
- }, { highWaterMark: 0 });
155
+ if (!signal) return replica;
156
+ const reader = replica.getReader();
157
+ const removeAbortListener = listenAbort(signal, (reason) => {
158
+ reader.cancel(reason).catch(() => {});
159
+ });
160
+ return new ReadableStream({
161
+ async pull(controller) {
162
+ try {
163
+ const result = await reader.read();
164
+ throwIfAborted(signal);
165
+ if (result.done) {
166
+ removeAbortListener();
167
+ controller.close();
168
+ } else controller.enqueue(result.value);
169
+ } catch (error) {
170
+ removeAbortListener();
171
+ throw error;
172
+ }
173
+ },
174
+ async cancel(reason) {
175
+ removeAbortListener();
176
+ await reader.cancel(reason);
177
+ }
178
+ }, { highWaterMark: 0 });
223
179
  }
224
180
  function shouldDedupe(items) {
225
- return items.length >= 2;
181
+ return items.length >= 2;
226
182
  }
183
+ export { DedupeLinkPlugin };
@@ -1,28 +1,9 @@
1
- export * from './batch.ts';
2
- export * from './cookie-jar.ts';
3
- export * from './dedupe.ts';
4
- export {
5
- /**
6
- * @deprecated Use `DedupeLinkPlugin` instead.
7
- */
8
- DedupeLinkPlugin as DedupeRequestsPlugin, } from './dedupe.ts';
9
- export * from './request-compression.ts';
10
- export * from './response-compression.ts';
11
- export * from './retry.ts';
12
- export {
13
- /**
14
- * @deprecated Use `RetryLinkPlugin` instead.
15
- */
16
- RetryLinkPlugin as ClientRetryPlugin, } from './retry.ts';
17
- export type {
18
- /**
19
- * @deprecated Use `RetryLinkPluginContext` instead.
20
- */
21
- RetryLinkPluginContext as ClientRetryPluginContext, } from './retry.ts';
22
- export * from './retry-after.ts';
23
- export {
24
- /**
25
- * @deprecated Use `RetryAfterLinkPlugin` instead.
26
- */
27
- RetryAfterLinkPlugin as RetryAfterPlugin, } from './retry-after.ts';
28
- export * from './timeout.ts';
1
+ import { BATCH_HEADER, BatchLinkPlugin, BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DEFAULT_BATCH_MAX_SIZE } from "./batch.js";
2
+ import { CookieJar, CookieJarLinkPlugin, CookieJarLinkPluginOptions, StoredCookie } from "./cookie-jar.js";
3
+ import { DedupeLinkPlugin, DedupeLinkPluginGroup, DedupeLinkPluginOptions } from "./dedupe.js";
4
+ import { RequestCompressionLinkPlugin, RequestCompressionLinkPluginOptions } from "./request-compression.js";
5
+ import { ResponseCompressionLinkPlugin, ResponseCompressionLinkPluginOptions } from "./response-compression.js";
6
+ import { RetryLinkPlugin, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, isRetryableError } from "./retry.js";
7
+ import { RetryAfterLinkPlugin, RetryAfterLinkPluginOptions } from "./retry-after.js";
8
+ import { TimeoutLinkPlugin, TimeoutLinkPluginOptions } from "./timeout.js";
9
+ export { BATCH_HEADER, BatchLinkPlugin, BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, RetryLinkPlugin as ClientRetryPlugin, type RetryLinkPluginContext as ClientRetryPluginContext, CookieJar, CookieJarLinkPlugin, CookieJarLinkPluginOptions, DEFAULT_BATCH_MAX_SIZE, DedupeLinkPlugin, DedupeLinkPluginGroup, DedupeLinkPluginOptions, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPlugin, ResponseCompressionLinkPluginOptions, RetryAfterLinkPlugin, RetryAfterLinkPluginOptions, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, StoredCookie, TimeoutLinkPlugin, TimeoutLinkPluginOptions, isRetryableError };
@@ -1,23 +1,8 @@
1
- export * from './batch.js';
2
- export * from './cookie-jar.js';
3
- export * from './dedupe.js';
4
- export {
5
- /**
6
- * @deprecated Use `DedupeLinkPlugin` instead.
7
- */
8
- DedupeLinkPlugin as DedupeRequestsPlugin, } from './dedupe.js';
9
- export * from './request-compression.js';
10
- export * from './response-compression.js';
11
- export * from './retry.js';
12
- export {
13
- /**
14
- * @deprecated Use `RetryLinkPlugin` instead.
15
- */
16
- RetryLinkPlugin as ClientRetryPlugin, } from './retry.js';
17
- export * from './retry-after.js';
18
- export {
19
- /**
20
- * @deprecated Use `RetryAfterLinkPlugin` instead.
21
- */
22
- RetryAfterLinkPlugin as RetryAfterPlugin, } from './retry-after.js';
23
- export * from './timeout.js';
1
+ export { BATCH_HEADER, BatchLinkPlugin, DEFAULT_BATCH_MAX_SIZE } from "./batch.js";
2
+ export { CookieJar, CookieJarLinkPlugin } from "./cookie-jar.js";
3
+ export { DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin } from "./dedupe.js";
4
+ export { RequestCompressionLinkPlugin } from "./request-compression.js";
5
+ export { ResponseCompressionLinkPlugin } from "./response-compression.js";
6
+ export { RetryLinkPlugin as ClientRetryPlugin, RetryLinkPlugin, isRetryableError } from "./retry.js";
7
+ export { RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin } from "./retry-after.js";
8
+ export { TimeoutLinkPlugin } from "./timeout.js";