web-streams-polyfill 3.2.1 → 4.0.0-beta.3

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.
Files changed (48) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +62 -41
  3. package/dist/polyfill.es5.js +8 -0
  4. package/dist/polyfill.js +6 -4380
  5. package/dist/ponyfill.es5.js +8 -0
  6. package/dist/ponyfill.es5.mjs +8 -0
  7. package/dist/ponyfill.js +6 -4352
  8. package/dist/ponyfill.mjs +6 -4330
  9. package/es5/package.json +6 -0
  10. package/package.json +62 -37
  11. package/polyfill/es5/package.json +5 -0
  12. package/polyfill/package.json +5 -0
  13. package/types/polyfill.d.ts +62 -0
  14. package/{dist/types/ts3.6/polyfill.d.ts → types/ponyfill.d.ts} +10 -6
  15. package/{dist/types → types}/tsdoc-metadata.json +1 -1
  16. package/dist/polyfill.es2018.js +0 -4241
  17. package/dist/polyfill.es2018.js.map +0 -1
  18. package/dist/polyfill.es2018.min.js +0 -2
  19. package/dist/polyfill.es2018.min.js.map +0 -1
  20. package/dist/polyfill.es2018.mjs +0 -4219
  21. package/dist/polyfill.es2018.mjs.map +0 -1
  22. package/dist/polyfill.es6.js +0 -4252
  23. package/dist/polyfill.es6.js.map +0 -1
  24. package/dist/polyfill.es6.min.js +0 -2
  25. package/dist/polyfill.es6.min.js.map +0 -1
  26. package/dist/polyfill.es6.mjs +0 -4230
  27. package/dist/polyfill.es6.mjs.map +0 -1
  28. package/dist/polyfill.js.map +0 -1
  29. package/dist/polyfill.min.js +0 -2
  30. package/dist/polyfill.min.js.map +0 -1
  31. package/dist/polyfill.mjs +0 -4360
  32. package/dist/polyfill.mjs.map +0 -1
  33. package/dist/ponyfill.es2018.js +0 -4213
  34. package/dist/ponyfill.es2018.js.map +0 -1
  35. package/dist/ponyfill.es2018.mjs +0 -4191
  36. package/dist/ponyfill.es2018.mjs.map +0 -1
  37. package/dist/ponyfill.es6.js +0 -4224
  38. package/dist/ponyfill.es6.js.map +0 -1
  39. package/dist/ponyfill.es6.mjs +0 -4202
  40. package/dist/ponyfill.es6.mjs.map +0 -1
  41. package/dist/ponyfill.js.map +0 -1
  42. package/dist/ponyfill.mjs.map +0 -1
  43. package/dist/types/polyfill.d.ts +0 -771
  44. package/es2018/package.json +0 -7
  45. package/es6/package.json +0 -7
  46. package/ponyfill/es2018/package.json +0 -6
  47. package/ponyfill/es6/package.json +0 -6
  48. package/ponyfill/package.json +0 -6
@@ -0,0 +1,6 @@
1
+ {
2
+ "name": "web-streams-polyfill",
3
+ "main": "../dist/ponyfill.es5.js",
4
+ "module": "../dist/ponyfill.es5.mjs",
5
+ "types": "../types/ponyfill.d.ts"
6
+ }
package/package.json CHANGED
@@ -1,39 +1,60 @@
1
1
  {
2
2
  "name": "web-streams-polyfill",
3
- "version": "3.2.1",
3
+ "version": "4.0.0-beta.3",
4
4
  "description": "Web Streams, based on the WHATWG spec reference implementation",
5
- "main": "dist/polyfill",
6
- "browser": "dist/polyfill.min.js",
7
- "module": "dist/polyfill.mjs",
8
- "types": "dist/types/polyfill.d.ts",
9
- "typesVersions": {
10
- ">=3.6": {
11
- "dist/types/*": [
12
- "dist/types/ts3.6/*"
13
- ]
14
- }
5
+ "main": "dist/ponyfill.js",
6
+ "module": "dist/ponyfill.mjs",
7
+ "types": "types/ponyfill.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./types/ponyfill.d.ts",
11
+ "import": "./dist/ponyfill.mjs",
12
+ "require": "./dist/ponyfill.js"
13
+ },
14
+ "./es5": {
15
+ "types": "./types/ponyfill.d.ts",
16
+ "import": "./dist/ponyfill.es5.mjs",
17
+ "require": "./dist/ponyfill.es5.js"
18
+ },
19
+ "./polyfill": {
20
+ "types": "./types/polyfill.d.ts",
21
+ "default": "./dist/polyfill.js"
22
+ },
23
+ "./polyfill/es5": {
24
+ "types": "./types/polyfill.d.ts",
25
+ "default": "./dist/polyfill.es5.js"
26
+ },
27
+ "./dist/*": "./dist/*",
28
+ "./types/*": "./types/*",
29
+ "./package": "./package.json",
30
+ "./package.json": "./package.json"
15
31
  },
16
32
  "scripts": {
17
- "test": "npm run test:types && npm run test:unit && npm run test:wpt",
18
- "test:wpt": "node --expose_gc ./test/run-web-platform-tests.js",
19
- "pretest:wpt": "git submodule update --init --recursive",
33
+ "test": "npm run test:types && npm run test:unit && npm run test:wpt && npm run test:bundler",
34
+ "test:wpt": "npm run test:wpt:node && npm run test:wpt:chromium && npm run test:wpt:firefox",
35
+ "test:wpt:node": "node --expose_gc ./test/wpt/node/run.js",
36
+ "test:wpt:chromium": "node ./test/wpt/browser/run.js --browser chromium",
37
+ "test:wpt:firefox": "node ./test/wpt/browser/run.js --browser firefox",
38
+ "test:bundler": "npm run test:bundler:rollup && npm run test:bundler:webpack",
39
+ "test:bundler:rollup": "cd test/rollup && npm ci && npm test",
40
+ "test:bundler:webpack": "cd test/webpack && npm ci && npm test",
20
41
  "test:types": "tsc -p ./test/types/tsconfig.json",
21
- "test:unit": "jasmine --config=test/unit/jasmine.json",
42
+ "test:unit": "node --experimental-import-meta-resolve ./node_modules/jasmine/bin/jasmine.js --config=test/unit/jasmine.json",
22
43
  "lint": "eslint \"src/**/*.ts\"",
23
44
  "build": "npm run build:bundle && npm run build:types",
24
45
  "build:bundle": "rollup -c",
25
- "build:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run && node ./build/downlevel-dts.js",
26
- "accept:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run --local && node ./build/downlevel-dts.js",
46
+ "build:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run",
47
+ "accept:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run --local",
27
48
  "prepare": "npm run build"
28
49
  },
29
50
  "files": [
30
51
  "dist",
31
- "es6",
32
- "es2018",
33
- "ponyfill"
52
+ "es5",
53
+ "polyfill",
54
+ "types"
34
55
  ],
35
56
  "engines": {
36
- "node": ">= 8"
57
+ "node": ">= 14"
37
58
  },
38
59
  "repository": {
39
60
  "type": "git",
@@ -54,23 +75,27 @@
54
75
  },
55
76
  "homepage": "https://github.com/MattiasBuelens/web-streams-polyfill#readme",
56
77
  "devDependencies": {
57
- "@microsoft/api-extractor": "^7.13.4",
58
- "@rollup/plugin-inject": "^4.0.2",
59
- "@rollup/plugin-replace": "^2.4.2",
60
- "@rollup/plugin-strip": "^2.0.0",
61
- "@rollup/plugin-typescript": "^8.2.1",
62
- "@types/node": "^14.14.37",
63
- "@typescript-eslint/eslint-plugin": "^4.21.0",
64
- "@typescript-eslint/parser": "^4.21.0",
78
+ "@microsoft/api-extractor": "^7.21.2",
79
+ "@rollup/plugin-inject": "^4.0.4",
80
+ "@rollup/plugin-replace": "^4.0.0",
81
+ "@rollup/plugin-strip": "^2.1.0",
82
+ "@rollup/plugin-typescript": "^8.3.1",
83
+ "@types/jasmine": "^4.0.2",
84
+ "@types/node": "^14.18.12",
85
+ "@typescript-eslint/eslint-plugin": "^5.19.0",
86
+ "@typescript-eslint/parser": "^5.19.0",
65
87
  "@ungap/promise-all-settled": "^1.1.2",
66
- "eslint": "^7.23.0",
67
- "jasmine": "^3.7.0",
68
- "micromatch": "^4.0.2",
69
- "rollup": "^2.44.0",
88
+ "abort-controller": "^3.0.0",
89
+ "eslint": "^8.13.0",
90
+ "jasmine": "^4.0.2",
91
+ "micromatch": "^4.0.5",
92
+ "minimist": "^1.2.6",
93
+ "playwright": "^1.20.2",
94
+ "recursive-readdir": "^2.2.2",
95
+ "rollup": "^2.70.1",
70
96
  "rollup-plugin-terser": "^7.0.2",
71
- "ts-morph": "^10.0.2",
72
- "tslib": "^2.2.0",
73
- "typescript": "^4.2.4",
74
- "wpt-runner": "^3.2.1"
97
+ "tslib": "^2.3.1",
98
+ "typescript": "^4.7.0-beta",
99
+ "wpt-runner": "^4.1.0"
75
100
  }
76
101
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "web-streams-polyfill",
3
+ "main": "../../dist/polyfill.es5.js",
4
+ "types": "../../types/polyfill.d.ts"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "web-streams-polyfill",
3
+ "main": "../dist/polyfill.js",
4
+ "types": "../types/polyfill.d.ts"
5
+ }
@@ -0,0 +1,62 @@
1
+ /// <reference lib="dom" />
2
+ /// <reference lib="es2018.asynciterable" />
3
+
4
+ import type {
5
+ ReadableStreamAsyncIterator,
6
+ ReadableStreamBYOBReader,
7
+ ReadableStreamBYOBReadResult,
8
+ ReadableStreamIteratorOptions
9
+ } from './ponyfill';
10
+
11
+ export type {
12
+ ReadableStreamAsyncIterator,
13
+ ReadableStreamBYOBReader,
14
+ ReadableStreamBYOBReadResult,
15
+ ReadableStreamIteratorOptions
16
+ };
17
+
18
+ declare global {
19
+ interface ReadableStream<R = any> {
20
+ /**
21
+ * Creates a {@link ReadableStreamBYOBReader} and locks the stream to the new reader.
22
+ *
23
+ * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams,
24
+ * i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading.
25
+ * The returned BYOB reader provides the ability to directly read individual chunks from the stream via its
26
+ * {@link ReadableStreamBYOBReader.read | read()} method, into developer-supplied buffers, allowing more precise
27
+ * control over allocation.
28
+ */
29
+ getReader({ mode }: {
30
+ mode: 'byob';
31
+ }): ReadableStreamBYOBReader;
32
+
33
+ /**
34
+ * Creates a {@link ReadableStreamDefaultReader} and locks the stream to the new reader.
35
+ * While the stream is locked, no other reader can be acquired until this one is released.
36
+ *
37
+ * This functionality is especially useful for creating abstractions that desire the ability to consume a stream
38
+ * in its entirety. By getting a reader for the stream, you can ensure nobody else can interleave reads with yours
39
+ * or cancel the stream, which would interfere with your abstraction.
40
+ */
41
+ getReader(): ReadableStreamDefaultReader<R>;
42
+
43
+ /**
44
+ * Asynchronously iterates over the chunks in the stream's internal queue.
45
+ *
46
+ * Asynchronously iterating over the stream will lock it, preventing any other consumer from acquiring a reader.
47
+ * The lock will be released if the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method
48
+ * is called, e.g. by breaking out of the loop.
49
+ *
50
+ * By default, calling the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method will also
51
+ * cancel the stream. To prevent this, use the stream's {@link ReadableStream.values | values()} method, passing
52
+ * `true` for the `preventCancel` option.
53
+ */
54
+ values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator<R>;
55
+
56
+ /**
57
+ * {@inheritDoc ReadableStream.values}
58
+ */
59
+ [Symbol.asyncIterator]: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator<R>;
60
+ }
61
+ }
62
+
@@ -16,6 +16,10 @@ export declare interface AbortSignal {
16
16
  * Whether the request is aborted.
17
17
  */
18
18
  readonly aborted: boolean;
19
+ /**
20
+ * The abort reason.
21
+ */
22
+ readonly reason?: any;
19
23
  /**
20
24
  * Add an event listener to be triggered when this signal becomes aborted.
21
25
  */
@@ -87,11 +91,11 @@ export declare interface QueuingStrategyInit {
87
91
  highWaterMark: number;
88
92
  }
89
93
 
90
- declare type QueuingStrategySizeCallback<T = any> = (chunk: T) => number;
91
-
92
- declare type ReadableByteStream = ReadableStream<Uint8Array> & {
93
- _readableStreamController: ReadableByteStreamController;
94
- };
94
+ /**
95
+ * {@inheritDoc QueuingStrategy.size}
96
+ * @public
97
+ */
98
+ export declare type QueuingStrategySizeCallback<T = any> = (chunk: T) => number;
95
99
 
96
100
  /**
97
101
  * Allows control of a {@link ReadableStream | readable byte stream}'s state and internal queue.
@@ -233,7 +237,7 @@ export declare interface ReadableStreamAsyncIterator<R> extends AsyncIterator<R>
233
237
  * @public
234
238
  */
235
239
  export declare class ReadableStreamBYOBReader {
236
- constructor(stream: ReadableByteStream);
240
+ constructor(stream: ReadableStream<Uint8Array>);
237
241
  /**
238
242
  * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or
239
243
  * the reader's lock is released before the stream finishes closing.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.13.4"
8
+ "packageVersion": "7.21.2"
9
9
  }
10
10
  ]
11
11
  }