@orkestrel/server 0.0.24 → 0.0.26

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.
@@ -395,11 +395,11 @@ export declare function createNegotiator(): NegotiatorInterface;
395
395
  export declare function createServer<TState>(options: ServerOptions<TState>): ServerInterface<TState>;
396
396
 
397
397
  /**
398
- * Creates a {@link StreamInterface} — a generic Server-Sent-Events stream whose
398
+ * Creates an {@link SSEStreamInterface} — a generic Server-Sent-Events stream whose
399
399
  * `response` is a fetch-standard streaming `Response` a route returns.
400
400
  *
401
401
  * @param options - {@link StreamOptions}
402
- * @returns A {@link StreamInterface} whose stream is open
402
+ * @returns An {@link SSEStreamInterface} whose stream is open
403
403
  *
404
404
  * @example
405
405
  * ```ts
@@ -414,7 +414,7 @@ export declare function createServer<TState>(options: ServerOptions<TState>): Se
414
414
  * // return stream.response from the route handler
415
415
  * ```
416
416
  */
417
- export declare function createStream(options?: StreamOptions): StreamInterface;
417
+ export declare function createStream(options?: StreamOptions): SSEStreamInterface;
418
418
 
419
419
  /**
420
420
  * Decodes a cookie value with `decodeURIComponent`, falling back to the raw
@@ -2056,62 +2056,6 @@ export declare interface SSEMessage {
2056
2056
  readonly retry?: number;
2057
2057
  }
2058
2058
 
2059
- /**
2060
- * Represents the Server-Sent-Events handle over an open, fetch-standard streaming
2061
- * `Response`. Implements exactly {@link StreamInterface}.
2062
- *
2063
- * @remarks
2064
- * Builds the `Response` at construction from
2065
- * {@link import('./constants.js').SSE_HEADERS} with any `options.headers`
2066
- * merged over them, at `options.status` (default `200`). A caller repeating one
2067
- * of those keys therefore replaces the seam's value, in any casing. The
2068
- * instance owns the stream's
2069
- * controller, its text encoder, the closed flag, and the parked producer's
2070
- * wakeup, so the whole handle is one entity rather than a closure over four
2071
- * bindings.
2072
- *
2073
- * `write` serializes one message ({@link serializeEvent}), enqueues it, and
2074
- * returns whether the controller still has positive desired size. A producer
2075
- * receiving `false` awaits `drain()`; that promise resolves on the next
2076
- * consumer pull restoring capacity, or on stream closure. `comment` writes a
2077
- * `: text` keep-alive line a conforming SSE parser ignores; `end` closes the
2078
- * stream. Every method is a safe no-op once `closed` (ended by `end()`, or
2079
- * the consumer cancelled the stream), so a late write never throws.
2080
- *
2081
- * The readiness signal reflects only the process-local `ReadableStream`
2082
- * queue — it is not proof that a remote peer consumed bytes. When the response
2083
- * pump honors its socket sink's drain state, socket pressure stops body pulls
2084
- * and therefore keeps this queue full, letting a cooperative producer bound
2085
- * its buffering. Ignoring the return value preserves an unconditional-enqueue
2086
- * producer. The default stream strategy counts chunks rather than their byte
2087
- * length, so a byte-bounded producer must also cap each message. Return
2088
- * `response` before awaiting a `false` write, because the consumer cannot pull
2089
- * until it receives the response.
2090
- *
2091
- * @example
2092
- * ```ts
2093
- * import { Stream } from '@src/server'
2094
- *
2095
- * const stream = new Stream()
2096
- * void Promise.resolve().then(async () => {
2097
- * if (!stream.write({ event: 'token', data: 'hello' })) await stream.drain()
2098
- * stream.comment('keep-alive')
2099
- * stream.end()
2100
- * })
2101
- * // return stream.response from the route handler
2102
- * ```
2103
- */
2104
- export declare class Stream implements StreamInterface {
2105
- #private;
2106
- constructor(options?: StreamOptions);
2107
- get response(): Response;
2108
- get closed(): boolean;
2109
- write(message: SSEMessage): boolean;
2110
- comment(text: string): void;
2111
- drain(): Promise<void>;
2112
- end(): void;
2113
- }
2114
-
2115
2059
  /**
2116
2060
  * Represents a handle to write Server-Sent Events to an open, fetch-standard streaming
2117
2061
  * `Response` — the generic streaming surface `createStream` returns over a
@@ -2140,7 +2084,7 @@ export declare class Stream implements StreamInterface {
2140
2084
  * Return `response` before awaiting a `false` write: the consumer cannot pull
2141
2085
  * until it receives the response.
2142
2086
  */
2143
- export declare interface StreamInterface {
2087
+ export declare interface SSEStreamInterface {
2144
2088
  /** Holds the streaming `Response` to return from the route handler. */
2145
2089
  readonly response: Response;
2146
2090
  /** Reports whether the underlying stream is done (ended, or the consumer disconnected). */
@@ -2183,7 +2127,63 @@ export declare interface StreamInterface {
2183
2127
  }
2184
2128
 
2185
2129
  /**
2186
- * Options for a {@link StreamInterface} — how `createStream` opens the
2130
+ * Represents the Server-Sent-Events handle over an open, fetch-standard streaming
2131
+ * `Response`. Implements exactly {@link SSEStreamInterface}.
2132
+ *
2133
+ * @remarks
2134
+ * Builds the `Response` at construction from
2135
+ * {@link import('./constants.js').SSE_HEADERS} with any `options.headers`
2136
+ * merged over them, at `options.status` (default `200`). A caller repeating one
2137
+ * of those keys therefore replaces the seam's value, in any casing. The
2138
+ * instance owns the stream's
2139
+ * controller, its text encoder, the closed flag, and the parked producer's
2140
+ * wakeup, so the whole handle is one entity rather than a closure over four
2141
+ * bindings.
2142
+ *
2143
+ * `write` serializes one message ({@link serializeEvent}), enqueues it, and
2144
+ * returns whether the controller still has positive desired size. A producer
2145
+ * receiving `false` awaits `drain()`; that promise resolves on the next
2146
+ * consumer pull restoring capacity, or on stream closure. `comment` writes a
2147
+ * `: text` keep-alive line a conforming SSE parser ignores; `end` closes the
2148
+ * stream. Every method is a safe no-op once `closed` (ended by `end()`, or
2149
+ * the consumer cancelled the stream), so a late write never throws.
2150
+ *
2151
+ * The readiness signal reflects only the process-local `ReadableStream`
2152
+ * queue — it is not proof that a remote peer consumed bytes. When the response
2153
+ * pump honors its socket sink's drain state, socket pressure stops body pulls
2154
+ * and therefore keeps this queue full, letting a cooperative producer bound
2155
+ * its buffering. Ignoring the return value preserves an unconditional-enqueue
2156
+ * producer. The default stream strategy counts chunks rather than their byte
2157
+ * length, so a byte-bounded producer must also cap each message. Return
2158
+ * `response` before awaiting a `false` write, because the consumer cannot pull
2159
+ * until it receives the response.
2160
+ *
2161
+ * @example
2162
+ * ```ts
2163
+ * import { Stream } from '@src/server'
2164
+ *
2165
+ * const stream = new Stream()
2166
+ * void Promise.resolve().then(async () => {
2167
+ * if (!stream.write({ event: 'token', data: 'hello' })) await stream.drain()
2168
+ * stream.comment('keep-alive')
2169
+ * stream.end()
2170
+ * })
2171
+ * // return stream.response from the route handler
2172
+ * ```
2173
+ */
2174
+ export declare class Stream implements SSEStreamInterface {
2175
+ #private;
2176
+ constructor(options?: StreamOptions);
2177
+ get response(): Response;
2178
+ get closed(): boolean;
2179
+ write(message: SSEMessage): boolean;
2180
+ comment(text: string): void;
2181
+ drain(): Promise<void>;
2182
+ end(): void;
2183
+ }
2184
+
2185
+ /**
2186
+ * Options for an {@link SSEStreamInterface} — how `createStream` opens the
2187
2187
  * streaming response.
2188
2188
  *
2189
2189
  * @param status - The HTTP status the streaming response is opened with;
@@ -395,11 +395,11 @@ export declare function createNegotiator(): NegotiatorInterface;
395
395
  export declare function createServer<TState>(options: ServerOptions<TState>): ServerInterface<TState>;
396
396
 
397
397
  /**
398
- * Creates a {@link StreamInterface} — a generic Server-Sent-Events stream whose
398
+ * Creates an {@link SSEStreamInterface} — a generic Server-Sent-Events stream whose
399
399
  * `response` is a fetch-standard streaming `Response` a route returns.
400
400
  *
401
401
  * @param options - {@link StreamOptions}
402
- * @returns A {@link StreamInterface} whose stream is open
402
+ * @returns An {@link SSEStreamInterface} whose stream is open
403
403
  *
404
404
  * @example
405
405
  * ```ts
@@ -414,7 +414,7 @@ export declare function createServer<TState>(options: ServerOptions<TState>): Se
414
414
  * // return stream.response from the route handler
415
415
  * ```
416
416
  */
417
- export declare function createStream(options?: StreamOptions): StreamInterface;
417
+ export declare function createStream(options?: StreamOptions): SSEStreamInterface;
418
418
 
419
419
  /**
420
420
  * Decodes a cookie value with `decodeURIComponent`, falling back to the raw
@@ -2056,62 +2056,6 @@ export declare interface SSEMessage {
2056
2056
  readonly retry?: number;
2057
2057
  }
2058
2058
 
2059
- /**
2060
- * Represents the Server-Sent-Events handle over an open, fetch-standard streaming
2061
- * `Response`. Implements exactly {@link StreamInterface}.
2062
- *
2063
- * @remarks
2064
- * Builds the `Response` at construction from
2065
- * {@link import('./constants.js').SSE_HEADERS} with any `options.headers`
2066
- * merged over them, at `options.status` (default `200`). A caller repeating one
2067
- * of those keys therefore replaces the seam's value, in any casing. The
2068
- * instance owns the stream's
2069
- * controller, its text encoder, the closed flag, and the parked producer's
2070
- * wakeup, so the whole handle is one entity rather than a closure over four
2071
- * bindings.
2072
- *
2073
- * `write` serializes one message ({@link serializeEvent}), enqueues it, and
2074
- * returns whether the controller still has positive desired size. A producer
2075
- * receiving `false` awaits `drain()`; that promise resolves on the next
2076
- * consumer pull restoring capacity, or on stream closure. `comment` writes a
2077
- * `: text` keep-alive line a conforming SSE parser ignores; `end` closes the
2078
- * stream. Every method is a safe no-op once `closed` (ended by `end()`, or
2079
- * the consumer cancelled the stream), so a late write never throws.
2080
- *
2081
- * The readiness signal reflects only the process-local `ReadableStream`
2082
- * queue — it is not proof that a remote peer consumed bytes. When the response
2083
- * pump honors its socket sink's drain state, socket pressure stops body pulls
2084
- * and therefore keeps this queue full, letting a cooperative producer bound
2085
- * its buffering. Ignoring the return value preserves an unconditional-enqueue
2086
- * producer. The default stream strategy counts chunks rather than their byte
2087
- * length, so a byte-bounded producer must also cap each message. Return
2088
- * `response` before awaiting a `false` write, because the consumer cannot pull
2089
- * until it receives the response.
2090
- *
2091
- * @example
2092
- * ```ts
2093
- * import { Stream } from '@src/server'
2094
- *
2095
- * const stream = new Stream()
2096
- * void Promise.resolve().then(async () => {
2097
- * if (!stream.write({ event: 'token', data: 'hello' })) await stream.drain()
2098
- * stream.comment('keep-alive')
2099
- * stream.end()
2100
- * })
2101
- * // return stream.response from the route handler
2102
- * ```
2103
- */
2104
- export declare class Stream implements StreamInterface {
2105
- #private;
2106
- constructor(options?: StreamOptions);
2107
- get response(): Response;
2108
- get closed(): boolean;
2109
- write(message: SSEMessage): boolean;
2110
- comment(text: string): void;
2111
- drain(): Promise<void>;
2112
- end(): void;
2113
- }
2114
-
2115
2059
  /**
2116
2060
  * Represents a handle to write Server-Sent Events to an open, fetch-standard streaming
2117
2061
  * `Response` — the generic streaming surface `createStream` returns over a
@@ -2140,7 +2084,7 @@ export declare class Stream implements StreamInterface {
2140
2084
  * Return `response` before awaiting a `false` write: the consumer cannot pull
2141
2085
  * until it receives the response.
2142
2086
  */
2143
- export declare interface StreamInterface {
2087
+ export declare interface SSEStreamInterface {
2144
2088
  /** Holds the streaming `Response` to return from the route handler. */
2145
2089
  readonly response: Response;
2146
2090
  /** Reports whether the underlying stream is done (ended, or the consumer disconnected). */
@@ -2183,7 +2127,63 @@ export declare interface StreamInterface {
2183
2127
  }
2184
2128
 
2185
2129
  /**
2186
- * Options for a {@link StreamInterface} — how `createStream` opens the
2130
+ * Represents the Server-Sent-Events handle over an open, fetch-standard streaming
2131
+ * `Response`. Implements exactly {@link SSEStreamInterface}.
2132
+ *
2133
+ * @remarks
2134
+ * Builds the `Response` at construction from
2135
+ * {@link import('./constants.js').SSE_HEADERS} with any `options.headers`
2136
+ * merged over them, at `options.status` (default `200`). A caller repeating one
2137
+ * of those keys therefore replaces the seam's value, in any casing. The
2138
+ * instance owns the stream's
2139
+ * controller, its text encoder, the closed flag, and the parked producer's
2140
+ * wakeup, so the whole handle is one entity rather than a closure over four
2141
+ * bindings.
2142
+ *
2143
+ * `write` serializes one message ({@link serializeEvent}), enqueues it, and
2144
+ * returns whether the controller still has positive desired size. A producer
2145
+ * receiving `false` awaits `drain()`; that promise resolves on the next
2146
+ * consumer pull restoring capacity, or on stream closure. `comment` writes a
2147
+ * `: text` keep-alive line a conforming SSE parser ignores; `end` closes the
2148
+ * stream. Every method is a safe no-op once `closed` (ended by `end()`, or
2149
+ * the consumer cancelled the stream), so a late write never throws.
2150
+ *
2151
+ * The readiness signal reflects only the process-local `ReadableStream`
2152
+ * queue — it is not proof that a remote peer consumed bytes. When the response
2153
+ * pump honors its socket sink's drain state, socket pressure stops body pulls
2154
+ * and therefore keeps this queue full, letting a cooperative producer bound
2155
+ * its buffering. Ignoring the return value preserves an unconditional-enqueue
2156
+ * producer. The default stream strategy counts chunks rather than their byte
2157
+ * length, so a byte-bounded producer must also cap each message. Return
2158
+ * `response` before awaiting a `false` write, because the consumer cannot pull
2159
+ * until it receives the response.
2160
+ *
2161
+ * @example
2162
+ * ```ts
2163
+ * import { Stream } from '@src/server'
2164
+ *
2165
+ * const stream = new Stream()
2166
+ * void Promise.resolve().then(async () => {
2167
+ * if (!stream.write({ event: 'token', data: 'hello' })) await stream.drain()
2168
+ * stream.comment('keep-alive')
2169
+ * stream.end()
2170
+ * })
2171
+ * // return stream.response from the route handler
2172
+ * ```
2173
+ */
2174
+ export declare class Stream implements SSEStreamInterface {
2175
+ #private;
2176
+ constructor(options?: StreamOptions);
2177
+ get response(): Response;
2178
+ get closed(): boolean;
2179
+ write(message: SSEMessage): boolean;
2180
+ comment(text: string): void;
2181
+ drain(): Promise<void>;
2182
+ end(): void;
2183
+ }
2184
+
2185
+ /**
2186
+ * Options for an {@link SSEStreamInterface} — how `createStream` opens the
2187
2187
  * streaming response.
2188
2188
  *
2189
2189
  * @param status - The HTTP status the streaming response is opened with;
@@ -2202,7 +2202,7 @@ var Server = class {
2202
2202
  // src/server/Stream.ts
2203
2203
  /**
2204
2204
  * Represents the Server-Sent-Events handle over an open, fetch-standard streaming
2205
- * `Response`. Implements exactly {@link StreamInterface}.
2205
+ * `Response`. Implements exactly {@link SSEStreamInterface}.
2206
2206
  *
2207
2207
  * @remarks
2208
2208
  * Builds the `Response` at construction from
@@ -2378,11 +2378,11 @@ function createServer(options) {
2378
2378
  return new Server(options);
2379
2379
  }
2380
2380
  /**
2381
- * Creates a {@link StreamInterface} — a generic Server-Sent-Events stream whose
2381
+ * Creates an {@link SSEStreamInterface} — a generic Server-Sent-Events stream whose
2382
2382
  * `response` is a fetch-standard streaming `Response` a route returns.
2383
2383
  *
2384
2384
  * @param options - {@link StreamOptions}
2385
- * @returns A {@link StreamInterface} whose stream is open
2385
+ * @returns An {@link SSEStreamInterface} whose stream is open
2386
2386
  *
2387
2387
  * @example
2388
2388
  * ```ts