@standardserver/fetch 0.0.18 → 0.0.20
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 +8 -0
- package/dist/index.mjs +6 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -130,3 +130,11 @@ const response = await fetch('/upload', {
|
|
|
130
130
|
## Learn more
|
|
131
131
|
|
|
132
132
|
For the higher-level project overview, see the root [Standard Server README](../../README.md).
|
|
133
|
+
|
|
134
|
+
## Sponsors
|
|
135
|
+
|
|
136
|
+
<p align="center">
|
|
137
|
+
<a href="https://cdn.jsdelivr.net/gh/middleapi/static/sponsors.svg">
|
|
138
|
+
<img src='https://cdn.jsdelivr.net/gh/middleapi/static/sponsors.svg' alt="Sponsors"/>
|
|
139
|
+
</a>
|
|
140
|
+
</p>
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EventStreamDecoderStream,
|
|
1
|
+
import { EventStreamDecoderStream, withEventMeta, EventIteratorErrorEvent, encodeEventStreamMessage, unwrapEvent, getEventMeta, getFilenameFromContentDisposition, generateContentDisposition } from '@standardserver/core';
|
|
2
2
|
import { AsyncIteratorClass, parseEmptyableJSON, isTypescriptObject, stringifyJSON, AbortError, isAsyncIteratorObject } from '@standardserver/shared';
|
|
3
3
|
|
|
4
4
|
function toEventIterator(stream) {
|
|
@@ -21,19 +21,19 @@ function toEventIterator(stream) {
|
|
|
21
21
|
case "message": {
|
|
22
22
|
let message = parseEmptyableJSON(value.data);
|
|
23
23
|
if (isTypescriptObject(message)) {
|
|
24
|
-
message =
|
|
24
|
+
message = withEventMeta(message, value);
|
|
25
25
|
}
|
|
26
26
|
return { done: false, value: message };
|
|
27
27
|
}
|
|
28
28
|
case "error": {
|
|
29
29
|
let error = new EventIteratorErrorEvent(parseEmptyableJSON(value.data));
|
|
30
|
-
error =
|
|
30
|
+
error = withEventMeta(error, value);
|
|
31
31
|
throw error;
|
|
32
32
|
}
|
|
33
33
|
case "close": {
|
|
34
34
|
let close = parseEmptyableJSON(value.data);
|
|
35
35
|
if (isTypescriptObject(close)) {
|
|
36
|
-
close =
|
|
36
|
+
close = withEventMeta(close, value);
|
|
37
37
|
}
|
|
38
38
|
return { done: true, value: close };
|
|
39
39
|
}
|
|
@@ -77,7 +77,7 @@ function toEventStream(iterator, options = {}) {
|
|
|
77
77
|
if (cancelled) {
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
|
-
const [data, meta] =
|
|
80
|
+
const [data, meta] = unwrapEvent(result.value);
|
|
81
81
|
if (!result.done || data !== void 0 || meta !== void 0 || emptyCloseEventEnabled) {
|
|
82
82
|
const event = result.done ? "close" : "message";
|
|
83
83
|
controller.enqueue(encodeEventStreamMessage({
|
|
@@ -96,7 +96,7 @@ function toEventStream(iterator, options = {}) {
|
|
|
96
96
|
}
|
|
97
97
|
if (err instanceof EventIteratorErrorEvent) {
|
|
98
98
|
controller.enqueue(encodeEventStreamMessage({
|
|
99
|
-
...
|
|
99
|
+
...getEventMeta(err),
|
|
100
100
|
event: "error",
|
|
101
101
|
data: stringifyJSON(err.data)
|
|
102
102
|
}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@standardserver/fetch",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.20",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://standardserver.dev",
|
|
7
7
|
"repository": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@standardserver/core": "0.0.
|
|
26
|
-
"@standardserver/shared": "0.0.
|
|
25
|
+
"@standardserver/core": "0.0.20",
|
|
26
|
+
"@standardserver/shared": "0.0.20"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@hono/node-server": "^2.0.1"
|