@orpc/standard-server-fetch 0.52.0 → 0.53.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.mjs +18 -16
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { stringifyJSON, parseEmptyableJSON, isTypescriptObject, isAsyncIteratorObject, once } from '@orpc/shared';
|
|
2
|
-
import { EventDecoderStream, encodeEventMessage, getEventMeta, ErrorEvent, withEventMeta,
|
|
2
|
+
import { EventDecoderStream, encodeEventMessage, getEventMeta, ErrorEvent, withEventMeta, getFilenameFromContentDisposition, generateContentDisposition } from '@orpc/standard-server';
|
|
3
3
|
|
|
4
4
|
function toEventIterator(stream) {
|
|
5
5
|
const eventStream = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventDecoderStream());
|
|
@@ -59,11 +59,14 @@ function toEventStream(iterator, options = {}) {
|
|
|
59
59
|
}
|
|
60
60
|
const value = await iterator.next();
|
|
61
61
|
clearInterval(timeout);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
const meta = getEventMeta(value.value);
|
|
63
|
+
if (!value.done || value.value !== void 0 || meta !== void 0) {
|
|
64
|
+
controller.enqueue(encodeEventMessage({
|
|
65
|
+
...meta,
|
|
66
|
+
event: value.done ? "done" : "message",
|
|
67
|
+
data: stringifyJSON(value.value)
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
67
70
|
if (value.done) {
|
|
68
71
|
controller.close();
|
|
69
72
|
}
|
|
@@ -92,15 +95,13 @@ async function toStandardBody(re) {
|
|
|
92
95
|
if (!re.body) {
|
|
93
96
|
return void 0;
|
|
94
97
|
}
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
97
|
-
const fileName =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
103
|
-
}
|
|
98
|
+
const contentDisposition = re.headers.get("content-disposition");
|
|
99
|
+
if (typeof contentDisposition === "string") {
|
|
100
|
+
const fileName = getFilenameFromContentDisposition(contentDisposition) ?? "blob";
|
|
101
|
+
const blob2 = await re.blob();
|
|
102
|
+
return new File([blob2], fileName, {
|
|
103
|
+
type: blob2.type
|
|
104
|
+
});
|
|
104
105
|
}
|
|
105
106
|
const contentType = re.headers.get("content-type");
|
|
106
107
|
if (!contentType || contentType.startsWith("application/json")) {
|
|
@@ -126,6 +127,7 @@ async function toStandardBody(re) {
|
|
|
126
127
|
});
|
|
127
128
|
}
|
|
128
129
|
function toFetchBody(body, headers, options = {}) {
|
|
130
|
+
const currentContentDisposition = headers.get("content-disposition");
|
|
129
131
|
headers.delete("content-type");
|
|
130
132
|
headers.delete("content-disposition");
|
|
131
133
|
if (body === void 0) {
|
|
@@ -136,7 +138,7 @@ function toFetchBody(body, headers, options = {}) {
|
|
|
136
138
|
headers.set("content-length", body.size.toString());
|
|
137
139
|
headers.set(
|
|
138
140
|
"content-disposition",
|
|
139
|
-
|
|
141
|
+
currentContentDisposition ?? generateContentDisposition(body instanceof File ? body.name : "blob")
|
|
140
142
|
);
|
|
141
143
|
return body;
|
|
142
144
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/standard-server-fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.53.0",
|
|
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/
|
|
27
|
-
"@orpc/
|
|
26
|
+
"@orpc/standard-server": "0.53.0",
|
|
27
|
+
"@orpc/shared": "0.53.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@hono/node-server": "^1.13.8"
|