@serwist/streams 9.0.0-preview.9 → 9.0.1

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { assert, Deferred, logger, SerwistError, canConstructReadableStream } from '@serwist/core/internal';
1
+ import { assert, Deferred, logger, SerwistError, canConstructReadableStream } from 'serwist/internal';
2
2
 
3
3
  function _getReaderFromSource(source) {
4
4
  if (source instanceof Response) {
@@ -107,9 +107,7 @@ function concatenateToResponse(sourcePromises, headersInit) {
107
107
  };
108
108
  }
109
109
 
110
- function isSupported() {
111
- return canConstructReadableStream();
112
- }
110
+ const isSupported = ()=>canConstructReadableStream();
113
111
 
114
112
  const strategy = (sourceFunctions, headersInit)=>{
115
113
  return async ({ event, request, url, params })=>{
@@ -7,6 +7,5 @@
7
7
  * @returns `true`, if the current browser meets the requirements for
8
8
  * streaming responses, and `false` otherwise.
9
9
  */
10
- declare function isSupported(): boolean;
11
- export { isSupported };
10
+ export declare const isSupported: () => boolean;
12
11
  //# sourceMappingURL=isSupported.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isSupported.d.ts","sourceRoot":"","sources":["../src/isSupported.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,iBAAS,WAAW,IAAI,OAAO,CAE9B;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"isSupported.d.ts","sourceRoot":"","sources":["../src/isSupported.ts"],"names":[],"mappings":"AAUA;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,QAAO,OAAuC,CAAC"}
@@ -1,16 +1,14 @@
1
- import type { RouteHandlerCallback, RouteHandlerCallbackOptions } from "@serwist/core";
1
+ import type { RouteHandlerCallback, RouteHandlerCallbackOptions } from "serwist";
2
2
  import type { StreamSource } from "./_types.js";
3
- export interface StreamsHandlerCallback {
4
- ({ url, request, event, params }: RouteHandlerCallbackOptions): Promise<StreamSource> | StreamSource;
5
- }
3
+ export type StreamsHandlerCallback = ({ url, request, event, params }: RouteHandlerCallbackOptions) => Promise<StreamSource> | StreamSource;
6
4
  /**
7
- * A shortcut to create a strategy that could be dropped-in to Serwist's router.
5
+ * A shortcut to create a strategy that could be dropped-in to Serwist's `Router`.
8
6
  *
9
7
  * On browsers that do not support constructing new `ReadableStream`s, this
10
8
  * strategy will automatically wait for all the `sourceFunctions` to complete,
11
9
  * and create a final response that concatenates their values together.
12
10
  *
13
- * @param sourceFunctions An array of functions similar to `@serwist/routing.handlerCallback`
11
+ * @param sourceFunctions An array of functions similar to `serwist.handlerCallback`
14
12
  * but that instead return a `@serwist/streams.StreamSource` (or a Promise which resolves to one).
15
13
  * @param headersInit If there's no `Content-Type` specified, `'text/html'` will be used by default.
16
14
  * @returns
@@ -1 +1 @@
1
- {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../src/strategy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAGvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,MAAM,WAAW,sBAAsB;IACrC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,2BAA2B,GAAG,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;CACtG;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,oBAAqB,sBAAsB,EAAE,eAAe,WAAW,KAAG,oBAwC9F,CAAC"}
1
+ {"version":3,"file":"strategy.d.ts","sourceRoot":"","sources":["../src/strategy.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAGjF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,MAAM,MAAM,sBAAsB,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,2BAA2B,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAE5I;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,QAAQ,oBAAqB,sBAAsB,EAAE,eAAe,WAAW,KAAG,oBAwC9F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serwist/streams",
3
- "version": "9.0.0-preview.9",
3
+ "version": "9.0.1",
4
4
  "type": "module",
5
5
  "description": "A library that makes it easier to work with Streams in the browser.",
6
6
  "files": [
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "author": "Google's Web DevRel Team, Serwist's Team",
19
19
  "license": "MIT",
20
- "repository": "serwist/serwist",
20
+ "repository": "https://github.com/serwist/serwist",
21
21
  "bugs": "https://github.com/serwist/serwist/issues",
22
22
  "homepage": "https://serwist.pages.dev",
23
23
  "main": "./dist/index.js",
@@ -30,13 +30,12 @@
30
30
  "./package.json": "./package.json"
31
31
  },
32
32
  "dependencies": {
33
- "@serwist/core": "9.0.0-preview.9",
34
- "@serwist/routing": "9.0.0-preview.9"
33
+ "serwist": "9.0.0"
35
34
  },
36
35
  "devDependencies": {
37
- "rollup": "4.9.6",
38
- "typescript": "5.4.0-dev.20240206",
39
- "@serwist/constants": "9.0.0-preview.9"
36
+ "rollup": "4.14.3",
37
+ "typescript": "5.5.0-dev.20240415",
38
+ "@serwist/configs": "9.0.1"
40
39
  },
41
40
  "peerDependencies": {
42
41
  "typescript": ">=5.0.0"
@@ -6,7 +6,7 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { assert, Deferred, SerwistError, logger } from "@serwist/core/internal";
9
+ import { assert, Deferred, SerwistError, logger } from "serwist/internal";
10
10
 
11
11
  import type { StreamSource } from "./_types.js";
12
12
 
@@ -6,7 +6,7 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import { canConstructReadableStream } from "@serwist/core/internal";
9
+ import { canConstructReadableStream } from "serwist/internal";
10
10
 
11
11
  /**
12
12
  * This is a utility method that determines whether the current browser supports
@@ -17,8 +17,4 @@ import { canConstructReadableStream } from "@serwist/core/internal";
17
17
  * @returns `true`, if the current browser meets the requirements for
18
18
  * streaming responses, and `false` otherwise.
19
19
  */
20
- function isSupported(): boolean {
21
- return canConstructReadableStream();
22
- }
23
-
24
- export { isSupported };
20
+ export const isSupported = (): boolean => canConstructReadableStream();
package/src/strategy.ts CHANGED
@@ -6,26 +6,24 @@
6
6
  https://opensource.org/licenses/MIT.
7
7
  */
8
8
 
9
- import type { RouteHandlerCallback, RouteHandlerCallbackOptions } from "@serwist/core";
10
- import { logger } from "@serwist/core/internal";
9
+ import type { RouteHandlerCallback, RouteHandlerCallbackOptions } from "serwist";
10
+ import { logger } from "serwist/internal";
11
11
 
12
12
  import type { StreamSource } from "./_types.js";
13
13
  import { concatenateToResponse } from "./concatenateToResponse.js";
14
14
  import { isSupported } from "./isSupported.js";
15
15
  import { createHeaders } from "./utils/createHeaders.js";
16
16
 
17
- export interface StreamsHandlerCallback {
18
- ({ url, request, event, params }: RouteHandlerCallbackOptions): Promise<StreamSource> | StreamSource;
19
- }
17
+ export type StreamsHandlerCallback = ({ url, request, event, params }: RouteHandlerCallbackOptions) => Promise<StreamSource> | StreamSource;
20
18
 
21
19
  /**
22
- * A shortcut to create a strategy that could be dropped-in to Serwist's router.
20
+ * A shortcut to create a strategy that could be dropped-in to Serwist's `Router`.
23
21
  *
24
22
  * On browsers that do not support constructing new `ReadableStream`s, this
25
23
  * strategy will automatically wait for all the `sourceFunctions` to complete,
26
24
  * and create a final response that concatenates their values together.
27
25
  *
28
- * @param sourceFunctions An array of functions similar to `@serwist/routing.handlerCallback`
26
+ * @param sourceFunctions An array of functions similar to `serwist.handlerCallback`
29
27
  * but that instead return a `@serwist/streams.StreamSource` (or a Promise which resolves to one).
30
28
  * @param headersInit If there's no `Content-Type` specified, `'text/html'` will be used by default.
31
29
  * @returns