@standardserver/fetch 0.0.22 → 0.0.24

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.d.mts CHANGED
@@ -4,38 +4,54 @@ import { AsyncIteratorClass } from '@standardserver/shared';
4
4
  declare function toEventIterator(stream: ReadableStream<Uint8Array<ArrayBuffer>> | null): AsyncIteratorClass<unknown>;
5
5
  interface ToEventStreamOptions {
6
6
  /**
7
- * If true, a ping comment is sent periodically to keep the connection alive.
8
- *
9
- * @default true
10
- */
11
- keepAliveEnabled?: boolean;
12
- /**
13
- * Interval (in milliseconds) between ping comments sent after the last event.
14
- *
15
- * @default 5000
16
- */
17
- keepAliveInterval?: number;
18
- /**
19
- * The content of the ping comment. Must not include newline characters.
20
- *
21
- * @default ''
22
- */
23
- keepAliveComment?: string;
24
- /**
25
- * If true, an initial comment is sent immediately upon stream start to flush headers.
7
+ * If enabled, an initial comment is sent immediately upon stream start to flush headers.
26
8
  * This allows the receiving side to establish the connection without waiting for the first event.
27
9
  *
28
- * @default true
10
+ * @default { enabled: true }
29
11
  */
30
- initialCommentEnabled?: boolean;
12
+ initialComment?: undefined | {
13
+ /**
14
+ * If true, an initial comment is sent immediately upon stream start to flush headers.
15
+ * This allows the receiving side to establish the connection without waiting for the first event.
16
+ *
17
+ * @default true
18
+ */
19
+ enabled?: boolean;
20
+ /**
21
+ * The content of the initial comment sent upon stream start. Must not include newline characters.
22
+ *
23
+ * @default ''
24
+ */
25
+ comment?: string;
26
+ };
31
27
  /**
32
- * The content of the initial comment sent upon stream start. Must not include newline characters.
28
+ * If enabled, a ping comment is sent periodically to keep the connection alive.
33
29
  *
34
- * @default ''
30
+ * @default { enabled: true }
35
31
  */
36
- initialComment?: string;
32
+ keepAlive?: undefined | {
33
+ /**
34
+ * If true, a ping comment is sent periodically to keep the connection alive.
35
+ *
36
+ * @default true
37
+ */
38
+ enabled: boolean;
39
+ /**
40
+ * Interval (in milliseconds) between ping comments sent after the last event.
41
+ *
42
+ * @default 5000
43
+ */
44
+ interval?: number;
45
+ /**
46
+ * The content of the ping comment. Must not include newline characters.
47
+ *
48
+ * @default ''
49
+ */
50
+ comment?: string;
51
+ };
37
52
  /**
38
- * If true, a empty `close` event is sent when the iterator completes with `undefined`.
53
+ * If true, a `close` event is sent even when the iterator completes with `undefined`.
54
+ * When the iterator returns a value, a `close` event is always emitted regardless of this setting.
39
55
  *
40
56
  * @default true
41
57
  */
package/dist/index.d.ts CHANGED
@@ -4,38 +4,54 @@ import { AsyncIteratorClass } from '@standardserver/shared';
4
4
  declare function toEventIterator(stream: ReadableStream<Uint8Array<ArrayBuffer>> | null): AsyncIteratorClass<unknown>;
5
5
  interface ToEventStreamOptions {
6
6
  /**
7
- * If true, a ping comment is sent periodically to keep the connection alive.
8
- *
9
- * @default true
10
- */
11
- keepAliveEnabled?: boolean;
12
- /**
13
- * Interval (in milliseconds) between ping comments sent after the last event.
14
- *
15
- * @default 5000
16
- */
17
- keepAliveInterval?: number;
18
- /**
19
- * The content of the ping comment. Must not include newline characters.
20
- *
21
- * @default ''
22
- */
23
- keepAliveComment?: string;
24
- /**
25
- * If true, an initial comment is sent immediately upon stream start to flush headers.
7
+ * If enabled, an initial comment is sent immediately upon stream start to flush headers.
26
8
  * This allows the receiving side to establish the connection without waiting for the first event.
27
9
  *
28
- * @default true
10
+ * @default { enabled: true }
29
11
  */
30
- initialCommentEnabled?: boolean;
12
+ initialComment?: undefined | {
13
+ /**
14
+ * If true, an initial comment is sent immediately upon stream start to flush headers.
15
+ * This allows the receiving side to establish the connection without waiting for the first event.
16
+ *
17
+ * @default true
18
+ */
19
+ enabled?: boolean;
20
+ /**
21
+ * The content of the initial comment sent upon stream start. Must not include newline characters.
22
+ *
23
+ * @default ''
24
+ */
25
+ comment?: string;
26
+ };
31
27
  /**
32
- * The content of the initial comment sent upon stream start. Must not include newline characters.
28
+ * If enabled, a ping comment is sent periodically to keep the connection alive.
33
29
  *
34
- * @default ''
30
+ * @default { enabled: true }
35
31
  */
36
- initialComment?: string;
32
+ keepAlive?: undefined | {
33
+ /**
34
+ * If true, a ping comment is sent periodically to keep the connection alive.
35
+ *
36
+ * @default true
37
+ */
38
+ enabled: boolean;
39
+ /**
40
+ * Interval (in milliseconds) between ping comments sent after the last event.
41
+ *
42
+ * @default 5000
43
+ */
44
+ interval?: number;
45
+ /**
46
+ * The content of the ping comment. Must not include newline characters.
47
+ *
48
+ * @default ''
49
+ */
50
+ comment?: string;
51
+ };
37
52
  /**
38
- * If true, a empty `close` event is sent when the iterator completes with `undefined`.
53
+ * If true, a `close` event is sent even when the iterator completes with `undefined`.
54
+ * When the iterator returns a value, a `close` event is always emitted regardless of this setting.
39
55
  *
40
56
  * @default true
41
57
  */
package/dist/index.mjs CHANGED
@@ -47,11 +47,11 @@ function toEventIterator(stream) {
47
47
  });
48
48
  }
49
49
  function toEventStream(iterator, options = {}) {
50
- const keepAliveEnabled = options.keepAliveEnabled ?? true;
51
- const keepAliveInterval = options.keepAliveInterval ?? 5e3;
52
- const keepAliveComment = options.keepAliveComment ?? "";
53
- const initialCommentEnabled = options.initialCommentEnabled ?? true;
54
- const initialComment = options.initialComment ?? "";
50
+ const keepAliveEnabled = options.keepAlive?.enabled ?? true;
51
+ const keepAliveInterval = options.keepAlive?.interval ?? 5e3;
52
+ const keepAliveComment = options.keepAlive?.comment ?? "";
53
+ const initialCommentEnabled = options.initialComment?.enabled ?? true;
54
+ const initialComment = options.initialComment?.comment ?? "";
55
55
  const emptyCloseEventEnabled = options.emptyCloseEventEnabled ?? true;
56
56
  let cancelled = false;
57
57
  let timeout;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@standardserver/fetch",
3
3
  "type": "module",
4
- "version": "0.0.22",
4
+ "version": "0.0.24",
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.22",
26
- "@standardserver/shared": "0.0.22"
25
+ "@standardserver/core": "0.0.24",
26
+ "@standardserver/shared": "0.0.24"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@hono/node-server": "^2.0.1"