@orpc/standard-server-fetch 0.0.0-next.d5f6b77 → 0.0.0-next.d8301f4

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/README.md CHANGED
@@ -49,6 +49,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
49
49
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
50
50
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
51
51
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
52
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with NestJS.
52
53
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
53
54
  - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
54
55
  - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
2
2
 
3
- declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncGenerator<unknown | void, unknown | void, void>;
3
+ declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncIteratorObject<unknown | void, unknown | void, void> & AsyncGenerator<unknown | void, unknown | void, void>;
4
4
  interface ToEventStreamOptions {
5
5
  /**
6
6
  * If true, a ping comment is sent periodically to keep the connection alive.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { StandardBody, StandardHeaders, StandardLazyRequest, StandardRequest, StandardResponse, StandardLazyResponse } from '@orpc/standard-server';
2
2
 
3
- declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncGenerator<unknown | void, unknown | void, void>;
3
+ declare function toEventIterator(stream: ReadableStream<Uint8Array>): AsyncIteratorObject<unknown | void, unknown | void, void> & AsyncGenerator<unknown | void, unknown | void, void>;
4
4
  interface ToEventStreamOptions {
5
5
  /**
6
6
  * If true, a ping comment is sent periodically to keep the connection alive.
package/dist/index.mjs CHANGED
@@ -1,46 +1,42 @@
1
- import { stringifyJSON, parseEmptyableJSON, isTypescriptObject, isAsyncIteratorObject, once } from '@orpc/shared';
2
- import { EventDecoderStream, encodeEventMessage, getEventMeta, ErrorEvent, withEventMeta, getFilenameFromContentDisposition, generateContentDisposition } from '@orpc/standard-server';
1
+ import { createAsyncIteratorObject, parseEmptyableJSON, isTypescriptObject, stringifyJSON, isAsyncIteratorObject, once } from '@orpc/shared';
2
+ import { EventDecoderStream, withEventMeta, ErrorEvent, encodeEventMessage, getEventMeta, getFilenameFromContentDisposition, generateContentDisposition } from '@orpc/standard-server';
3
3
 
4
4
  function toEventIterator(stream) {
5
5
  const eventStream = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
6
6
  const reader = eventStream.getReader();
7
- async function* gen() {
8
- try {
9
- while (true) {
10
- const { done, value } = await reader.read();
11
- if (done) {
12
- return;
13
- }
14
- switch (value.event) {
15
- case "message": {
16
- let message = parseEmptyableJSON(value.data);
17
- if (isTypescriptObject(message)) {
18
- message = withEventMeta(message, value);
19
- }
20
- yield message;
21
- break;
22
- }
23
- case "error": {
24
- let error = new ErrorEvent({
25
- data: parseEmptyableJSON(value.data)
26
- });
27
- error = withEventMeta(error, value);
28
- throw error;
7
+ return createAsyncIteratorObject(async () => {
8
+ while (true) {
9
+ const { done, value } = await reader.read();
10
+ if (done) {
11
+ return { done: true, value: void 0 };
12
+ }
13
+ switch (value.event) {
14
+ case "message": {
15
+ let message = parseEmptyableJSON(value.data);
16
+ if (isTypescriptObject(message)) {
17
+ message = withEventMeta(message, value);
29
18
  }
30
- case "done": {
31
- let done2 = parseEmptyableJSON(value.data);
32
- if (isTypescriptObject(done2)) {
33
- done2 = withEventMeta(done2, value);
34
- }
35
- return done2;
19
+ return { done: false, value: message };
20
+ }
21
+ case "error": {
22
+ let error = new ErrorEvent({
23
+ data: parseEmptyableJSON(value.data)
24
+ });
25
+ error = withEventMeta(error, value);
26
+ throw error;
27
+ }
28
+ case "done": {
29
+ let done2 = parseEmptyableJSON(value.data);
30
+ if (isTypescriptObject(done2)) {
31
+ done2 = withEventMeta(done2, value);
36
32
  }
33
+ return { done: true, value: done2 };
37
34
  }
38
35
  }
39
- } finally {
40
- await reader.cancel();
41
36
  }
42
- }
43
- return gen();
37
+ }, async () => {
38
+ await reader.cancel();
39
+ });
44
40
  }
45
41
  function toEventStream(iterator, options = {}) {
46
42
  const keepAliveEnabled = options.eventIteratorKeepAliveEnabled ?? true;
@@ -87,14 +83,10 @@ function toEventStream(iterator, options = {}) {
87
83
  controller.close();
88
84
  }
89
85
  },
90
- async cancel(reason) {
86
+ async cancel() {
91
87
  cancelled = true;
92
88
  clearInterval(timeout);
93
- if (reason) {
94
- await iterator.throw?.(reason);
95
- } else {
96
- await iterator.return?.();
97
- }
89
+ await iterator.return?.();
98
90
  }
99
91
  }).pipeThrough(new TextEncoderStream());
100
92
  return stream;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/standard-server-fetch",
3
3
  "type": "module",
4
- "version": "0.0.0-next.d5f6b77",
4
+ "version": "0.0.0-next.d8301f4",
5
5
  "license": "MIT",
6
6
  "homepage": "https://unnoq.com",
7
7
  "repository": {
@@ -23,8 +23,8 @@
23
23
  "dist"
24
24
  ],
25
25
  "dependencies": {
26
- "@orpc/shared": "0.0.0-next.d5f6b77",
27
- "@orpc/standard-server": "0.0.0-next.d5f6b77"
26
+ "@orpc/shared": "0.0.0-next.d8301f4",
27
+ "@orpc/standard-server": "0.0.0-next.d8301f4"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@hono/node-server": "^1.14.1"