pax_global_header00006660000000000000000000000064142236442370014521gustar00rootroot0000000000000052 comment=d354a7457ca8a24030dbd0a135ee40baed7c774d web-streams-polyfill-3.2.1/000077500000000000000000000000001422364423700156055ustar00rootroot00000000000000web-streams-polyfill-3.2.1/.eslintrc.json000066400000000000000000000221411422364423700204010ustar00rootroot00000000000000{ "extends": ["plugin:@typescript-eslint/recommended"], "root": true, "env": { "node": true, "browser": true, "es6": true }, "parserOptions": { "ecmaVersion": 2018, "sourceType": "module" }, "globals": { "ReadableStream": false, "WritableStream": false, "TransformStream": false, "ByteLengthQueuingStrategy": false, "CountQueuingStrategy": false, "AbortSignal": false, "DEBUG": false, "GCController": false, "gc": false }, "rules": { // Possible errors "comma-dangle": ["error", "never"], "no-cond-assign": ["error", "except-parens"], "no-console": "error", "no-constant-condition": "error", "no-control-regex": "error", "no-debugger": "error", "no-dupe-args": "error", "no-dupe-keys": "error", "no-duplicate-case": "error", "no-empty": "error", "no-empty-character-class": "error", "no-ex-assign": "error", "no-extra-boolean-cast": "error", "no-extra-parens": "off", // incompatible with explicit type casts "no-extra-semi": "error", "no-func-assign": "error", "no-inner-declarations": "off", "no-invalid-regexp": "error", "no-irregular-whitespace": "error", "no-negated-in-lhs": "error", "no-obj-calls": "error", "no-regex-spaces": "error", "no-sparse-arrays": "error", "no-unexpected-multiline": "error", "no-unreachable": "error", "no-unsafe-finally": "off", "use-isnan": "error", "valid-jsdoc": "off", "valid-typeof": "error", // Best practices "accessor-pairs": "error", "array-callback-return": "error", "block-scoped-var": "off", "complexity": "off", "consistent-return": "error", "curly": ["error", "all"], "default-case": "off", "dot-location": ["error", "property"], "dot-notation": "error", "eqeqeq": "error", "guard-for-in": "off", "no-alert": "error", "no-caller": "error", "no-case-declarations": "error", "no-div-regex": "off", "no-else-return": "error", "no-empty-function": "off", "no-empty-pattern": "error", "no-eq-null": "error", "no-eval": "error", "no-extend-native": "error", "no-extra-bind": "error", "no-extra-label": "error", "no-fallthrough": "error", "no-floating-decimal": "error", "no-implicit-coercion": "error", "no-implicit-globals": "error", "no-implied-eval": "off", "no-invalid-this": "off", // meh "no-iterator": "error", "no-labels": ["error", { "allowLoop": true }], "no-lone-blocks": "error", "no-loop-func": "off", "no-magic-numbers": "off", "no-multi-spaces": "error", "no-multi-str": "error", "no-native-reassign": "error", "no-new": "off", "no-new-func": "error", "no-new-wrappers": "error", "no-octal": "error", "no-octal-escape": "error", "no-param-reassign": "off", "no-process-env": "error", "no-proto": "error", "no-redeclare": "error", "no-return-assign": ["error", "except-parens"], "no-script-url": "off", "no-self-assign": "error", "no-self-compare": "error", "no-sequences": "error", "no-throw-literal": "error", "no-unmodified-loop-condition": "error", "no-unused-expressions": "error", "no-unused-labels": "error", "no-useless-call": "error", "no-useless-concat": "error", "no-useless-escape": "error", "no-void": "error", "no-warning-comments": "off", "no-with": "error", "radix": ["error", "as-needed"], "vars-on-top": "off", "wrap-iife": ["error", "outside"], "yoda": ["error", "never"], // Strict Mode "strict": ["error", "global"], // Variables "init-declarations": "off", "no-catch-shadow": "error", "no-delete-var": "error", "no-label-var": "error", "no-restricted-globals": "off", "no-shadow": "error", "no-shadow-restricted-names": "error", "no-undef": "error", "no-undef-init": "error", "no-undefined": "off", "no-unused-vars": "off", // handled by @typescript-eslint/no-unused-vars "no-use-before-define": "off", // Node.js and CommonJS "callback-return": "off", "global-require": "error", "handle-callback-err": "error", "no-mixed-requires": ["error", true], "no-new-require": "error", "no-path-concat": "error", "no-process-exit": "error", "no-restricted-imports": "off", "no-restricted-modules": "off", "no-sync": "off", // Stylistic Issues "array-bracket-spacing": ["error", "never"], "block-spacing": ["error", "always"], "brace-style": ["error", "1tbs", { "allowSingleLine": true }], "camelcase": "off", "comma-spacing": ["error", { "before": false, "after": true }], "comma-style": ["error", "last"], "computed-property-spacing": ["error", "never"], "consistent-this": "off", "eol-last": "error", "func-names": "off", "func-style": "off", "id-blacklist": "off", "id-length": "off", "id-match": "off", "indent": "off", // handled by @typescript-eslint/indent "jsx-quotes": "off", "key-spacing": ["error", { "beforeColon": false, "afterColon": true, "mode": "strict" }], "keyword-spacing": ["error", { "before": true, "after": true }], "linebreak-style": ["error", "unix"], "lines-around-comment": "off", "max-depth": "off", "max-len": ["error", 120, { "ignoreUrls": true }], "max-nested-callbacks": "off", "max-params": "off", "max-statements": "off", "max-statements-per-line": ["error", { "max": 1 }], "new-cap": "off", "new-parens": "error", "newline-after-var": "off", "newline-before-return": "off", "newline-per-chained-call": "off", "no-array-constructor": "error", "no-bitwise": "off", "no-continue": "off", "no-inline-comments": "off", "no-lonely-if": "error", "no-mixed-spaces-and-tabs": "error", "no-multiple-empty-lines": "error", "no-negated-condition": "off", "no-nested-ternary": "error", "no-new-object": "error", "no-plusplus": "off", "no-restricted-syntax": "off", "no-spaced-func": "error", "no-ternary": "off", "no-trailing-spaces": "error", "no-underscore-dangle": "off", "no-unneeded-ternary": "error", "no-whitespace-before-property": "error", "object-curly-spacing": ["error", "always"], "object-property-newline": "off", "one-var": ["error", "never"], "one-var-declaration-per-line": ["error", "initializations"], "operator-assignment": ["error", "always"], "operator-linebreak": ["error", "after"], "padded-blocks": ["error", "never"], "quote-props": ["error", "as-needed"], "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": true }], "require-jsdoc": "off", "semi": ["error", "always"], "semi-spacing": "error", "sort-imports": "off", "sort-vars": "off", "space-before-blocks": ["error", "always"], "space-before-function-paren": ["error", { "anonymous": "always", "named": "never" }], "space-in-parens": ["error", "never"], "space-infix-ops": "error", "space-unary-ops": ["error", { "words": true, "nonwords": false }], "spaced-comment": ["error", "always", { "markers": ["/"] }], "wrap-regex": "off", // ECMAScript 6 "arrow-body-style": "off", // meh "arrow-parens": ["error", "as-needed"], "arrow-spacing": "error", "constructor-super": "error", "generator-star-spacing": ["error", "after"], "no-class-assign": "error", "no-confusing-arrow": "off", "no-const-assign": "error", "no-dupe-class-members": "off", // incompatible with method overload signatures "no-duplicate-imports": "error", "no-new-symbol": "error", "no-this-before-super": "error", "no-useless-computed-key": "error", "no-useless-constructor": "off", // handled by @typescript-eslint/no-useless-constructor "no-var": "error", "object-shorthand": "error", "prefer-arrow-callback": "error", "prefer-const": ["error", { "ignoreReadBeforeAssign": true }], "prefer-reflect": "off", "prefer-rest-params": "error", "prefer-spread": "error", "prefer-template": "off", "require-yield": "error", "template-curly-spacing": ["error", "never"], "yield-star-spacing": ["error", "after"], // TypeScript "@typescript-eslint/array-type": ["error", { "default": "array-simple" }], "@typescript-eslint/ban-types": "off", // FIXME "@typescript-eslint/camelcase": "off", "@typescript-eslint/explicit-function-return-type": "off", // FIXME "@typescript-eslint/explicit-member-accessibility": "off", // FIXME "@typescript-eslint/explicit-module-boundary-types": "off", // FIXME "@typescript-eslint/indent": ["error", 2, { "SwitchCase": 1, "FunctionDeclaration": { "parameters": "first" }, "FunctionExpression": { "parameters": "first" }, "CallExpression": { "arguments": "first" }, "ArrayExpression": "first", "ObjectExpression": "first", "ImportDeclaration": "first" }], "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/no-non-null-assertion": "off", "@typescript-eslint/no-use-before-define": "off", "@typescript-eslint/no-useless-constructor": "error" } } web-streams-polyfill-3.2.1/.github/000077500000000000000000000000001422364423700171455ustar00rootroot00000000000000web-streams-polyfill-3.2.1/.github/workflows/000077500000000000000000000000001422364423700212025ustar00rootroot00000000000000web-streams-polyfill-3.2.1/.github/workflows/pull-request.yml000066400000000000000000000016431422364423700243730ustar00rootroot00000000000000name: Build pull request on: [pull_request] jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [10.x, 12.x] # Run only on non-merged non-draft mergeable pull requests if: | !( (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') && !github.event.pull_request.draft && !github.event.pull_request.merged && github.event.pull_request.merge_commit_sha != null ) steps: - name: Check out merge commit of pull request uses: actions/checkout@v2 with: ref: ${{ github.event.pull_request.merge_commit_sha }} - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - name: npm install and test run: | npm install npm test web-streams-polyfill-3.2.1/.github/workflows/push.yml000066400000000000000000000011101422364423700226750ustar00rootroot00000000000000name: Build on push on: [push] jobs: build: runs-on: ubuntu-latest strategy: matrix: node-version: [10.x, 12.x] # Skip job if commit message contains "[skip ci]" if: | !contains(github.event.head_commit.message, '[skip ci]') steps: - name: Check out commit uses: actions/checkout@v2 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v1 with: node-version: ${{ matrix.node-version }} - name: npm install and test run: | npm install npm test web-streams-polyfill-3.2.1/.gitignore000066400000000000000000000046231422364423700176020ustar00rootroot00000000000000### JetBrains template # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 # User-specific stuff .idea/**/workspace.xml .idea/**/tasks.xml .idea/**/usage.statistics.xml .idea/**/dictionaries .idea/**/shelf # Sensitive or high-churn files .idea/**/dataSources/ .idea/**/dataSources.ids .idea/**/dataSources.local.xml .idea/**/sqlDataSources.xml .idea/**/dynamic.xml .idea/**/uiDesigner.xml .idea/**/dbnavigator.xml # Gradle .idea/**/gradle.xml .idea/**/libraries # Gradle and Maven with auto-import # When using Gradle or Maven with auto-import, you should exclude module files, # since they will be recreated, and may cause churn. Uncomment if using # auto-import. # .idea/modules.xml # .idea/*.iml # .idea/modules # CMake cmake-build-*/ # Mongo Explorer plugin .idea/**/mongoSettings.xml # File-based project format *.iws # IntelliJ out/ # mpeltonen/sbt-idea plugin .idea_modules/ # JIRA plugin atlassian-ide-plugin.xml # Cursive Clojure plugin .idea/replstate.xml # Crashlytics plugin (for Android Studio and IntelliJ) com_crashlytics_export_strings.xml crashlytics.properties crashlytics-build.properties fabric.properties # Editor-based Rest Client .idea/httpRequests ### Node template # Logs logs *.log npm-debug.log* yarn-debug.log* yarn-error.log* # Runtime data pids *.pid *.seed *.pid.lock # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # nyc test coverage .nyc_output # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # Bower dependency directory (https://bower.io/) bower_components # node-waf configuration .lock-wscript # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release # Dependency directories node_modules/ jspm_packages/ # TypeScript v1 declaration files typings/ # Optional npm cache directory .npm # Optional eslint cache .eslintcache # Optional REPL history .node_repl_history # Output of 'npm pack' *.tgz # Yarn Integrity file .yarn-integrity # dotenv environment variables file .env # parcel-bundler cache (https://parceljs.org/) .cache # next.js build output .next # nuxt.js build output .nuxt # vuepress build output .vuepress/dist # Serverless directories .serverless ### Project /dist/ /lib/ /temp/ web-streams-polyfill-3.2.1/.gitmodules000066400000000000000000000001731422364423700177630ustar00rootroot00000000000000[submodule "test/web-platform-tests"] path = test/web-platform-tests url = https://github.com/web-platform-tests/wpt.git web-streams-polyfill-3.2.1/.idea/000077500000000000000000000000001422364423700165655ustar00rootroot00000000000000web-streams-polyfill-3.2.1/.idea/codeStyles/000077500000000000000000000000001422364423700207035ustar00rootroot00000000000000web-streams-polyfill-3.2.1/.idea/codeStyles/Project.xml000066400000000000000000000040461422364423700230370ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/codeStyles/codeStyleConfig.xml000066400000000000000000000002221422364423700245020ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/encodings.xml000066400000000000000000000002121422364423700212530ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/inspectionProfiles/000077500000000000000000000000001422364423700224445ustar00rootroot00000000000000web-streams-polyfill-3.2.1/.idea/inspectionProfiles/Project_Default.xml000066400000000000000000000003711422364423700262410ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/jsonSchemas.xml000066400000000000000000000015541422364423700215710ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/misc.xml000066400000000000000000000002561422364423700202450ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/modules.xml000066400000000000000000000004441422364423700207610ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/vcs.xml000066400000000000000000000004001422364423700200740ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/.idea/web-streams-polyfill.iml000066400000000000000000000013461422364423700233550ustar00rootroot00000000000000 web-streams-polyfill-3.2.1/CHANGELOG.md000066400000000000000000000242221422364423700174200ustar00rootroot00000000000000# Changelog > **Tags:** > - 💥 Breaking Change > - 👓 Spec Compliance > - 🚀 New Feature > - 🐛 Bug Fix > - 👎 Deprecation > - 📝 Documentation > - 🏠 Internal > - 💅 Polish ## v3.2.1 (2022-04-07) * 🐛 Fix an error in very old browsers where `Function.name` is non-configurable. ([#112](https://github.com/MattiasBuelens/web-streams-polyfill/pull/112)) ## v3.2.0 (2021-11-06) * 👎 Deprecate `WritableStreamDefaultController.abortReason` ([#102](https://github.com/MattiasBuelens/web-streams-polyfill/pull/102)) * Use `WritableStreamDefaultController.signal.reason` instead. * 👓 Align with [spec version `4b6b93c`](https://github.com/whatwg/streams/tree/4b6b93c69e531e2fe45a6ed4cb1484a7ba4eb8bb/) ([#103](https://github.com/MattiasBuelens/web-streams-polyfill/pull/103)) ## v3.1.1 (2021-09-06) * 🐛 Fix compatibility with TypeScript's DOM types for `ReadableStream` and `TransformStream` ([#85](https://github.com/MattiasBuelens/web-streams-polyfill/issues/85), [#86](https://github.com/MattiasBuelens/web-streams-polyfill/pull/86)) ## v3.1.0 (2021-07-21) * 🚀 Calling `ReadableStream.tee()` on a readable byte stream now returns two readable byte streams. ([#81](https://github.com/MattiasBuelens/web-streams-polyfill/pull/81)) * 🚀 Add `WritableStreamDefaultController.signal` and `.abortReason`. ([#81](https://github.com/MattiasBuelens/web-streams-polyfill/pull/81)) * `.signal` requires a global `AbortController` constructor to be available. If necessary, use a polyfill. * 🐛 Make sure streams created with a different version of the polyfill do not pass the brand checks. ([#75](https://github.com/MattiasBuelens/web-streams-polyfill/issues/75), [#77](https://github.com/MattiasBuelens/web-streams-polyfill/pull/77)) * 👓 Align with [spec version `cada812`](https://github.com/whatwg/streams/tree/cada8129edcc4803b2878a7a3f5e1d8325dc0c23/) ([#79](https://github.com/MattiasBuelens/web-streams-polyfill/pull/79), [#81](https://github.com/MattiasBuelens/web-streams-polyfill/pull/81)) ## v3.0.3 (2021-04-09) * 💅 Change `Promise` to `Promise` in TypeScript type definitions ([#72](https://github.com/MattiasBuelens/web-streams-polyfill/pull/72)) * 🐛 Fix `ReadableStream.tee()` resolving its `cancel()` promise too early ([#73](https://github.com/MattiasBuelens/web-streams-polyfill/pull/73)) * 👓 Align with [spec version `6762cdb`](https://github.com/whatwg/streams/tree/6762cdb4c6421cfa0da1d834d5a14fdd7326aaa5/) ([#73](https://github.com/MattiasBuelens/web-streams-polyfill/pull/73)) ## v3.0.2 (2021-02-10) * 👓 Align with [spec version `200c971`](https://github.com/whatwg/streams/tree/200c971563b1a695fce3eebe6dab45c348ff0ac0/) ([#69](https://github.com/MattiasBuelens/web-streams-polyfill/pull/69)) ## v3.0.1 (2020-11-12) * 📝 Add documentation to type definitions ([#62](https://github.com/MattiasBuelens/web-streams-polyfill/pull/62)) * 👓 Align with [spec version `6cd5e81`](https://github.com/whatwg/streams/tree/6cd5e81f6191fed9e7d99ee73d4941e3060311ce/) ([#63](https://github.com/MattiasBuelens/web-streams-polyfill/pull/63)) * 🐛 Fix an issue where the polyfill could throw an error when resolving/rejecting `reader.closed` when it was already resolved/rejected ([#66](https://github.com/MattiasBuelens/web-streams-polyfill/issues/66), [#67](https://github.com/MattiasBuelens/web-streams-polyfill/pull/67)) ## v3.0.0 (2020-07-20) * 💥 Align with [spec version `62fe4c8`](https://github.com/whatwg/streams/tree/62fe4c8c0df34cec4ff28db9bfa69aec6c65e38d/) ([#52](https://github.com/MattiasBuelens/web-streams-polyfill/pull/52), [#57](https://github.com/MattiasBuelens/web-streams-polyfill/pull/57), [#59](https://github.com/MattiasBuelens/web-streams-polyfill/pull/59)) This includes the following **breaking changes**: * All classes are now exposed globally. Concretely, this adds the following classes: * `ReadableStreamDefaultController` * `ReadableByteStreamController` * `ReadableStreamBYOBRequest` * `ReadableStreamDefaultReader` * `ReadableStreamBYOBReader` * `WritableStreamDefaultController` * `WritableStreamDefaultWriter` * `TransformStreamDefaultController` * `ReadableStream.getIterator()` is renamed to `ReadableStream.values()` * `ReadableByteStreamController.byobRequest` can be `null` (instead of `undefined`) if there is no current BYOB request. * `ReadableStreamBYOBRequest.view` can be `null` (instead of `undefined`) if the BYOB request has already been responded to. * Constructors and methods have stricter type checking for object arguments. For example, `new ReadableStream(null)` would previously behave like `new ReadableStream({})`, but now it throws a `TypeError` instead. * Some constructors and methods may throw slightly different errors when given invalid arguments. * Various byte-stream-related APIs now prohibit zero-length views or buffers. * The async iterator of a `ReadableStream` now behaves more like an async generator, e.g. returning promises fulfilled with `{ value: undefined, done: true }` after `return()`ing the iterator, instead of returning a rejected promise. * 💥 Updated TypeScript types to align with new specification ([#60](https://github.com/MattiasBuelens/web-streams-polyfill/pull/60)) While these are _technically_ breaking changes, you should only be affected if you manually reference these types from your code. * `PipeOptions` is renamed to `StreamPipeOptions` * `ReadResult` is replaced by `ReadableStreamDefaultReadResult` and `ReadableStreamBYOBReadResult` * `ReadableStreamDefaultControllerCallback` is replaced by `UnderlyingSourceStartCallback` and `UnderlyingSourcePullCallback` * `ReadableByteStreamControllerCallback` is replaced by `UnderlyingByteSourceStartCallback` and `UnderlyingByteSourcePullCallback` * `ReadableStreamErrorCallback` is renamed to `UnderlyingSourceCancelCallback` * `WritableStreamDefaultControllerStartCallback` is renamed to `UnderlyingSinkStartCallback` * `WritableStreamDefaultControllerWriteCallback` is renamed to `UnderlyingSinkWriteCallback` * `WritableStreamDefaultControllerCloseCallback` is renamed to `UnderlyingSinkCloseCallback` * `WritableStreamErrorCallback` is renamed to `UnderlyingSinkAbortCallback` * `TransformStreamDefaultControllerCallback` is replaced by `TransformerStartCallback` and `TransformerFlushCallback` * `TransformStreamDefaultControllerTransformCallback` is renamed to `TransformerTransformCallback` ## v2.1.1 (2020-04-11) * 💅 Improve `ReadResult` in TypeScript type definitions. ([759506e](https://github.com/MattiasBuelens/web-streams-polyfill/commit/759506e00e55289ae6f92f30922b8855fcddd9ab), [#49](https://github.com/MattiasBuelens/web-streams-polyfill/pull/49)) ## v2.1.0 (2020-02-23) * 👓 Align with [spec version `ed00d2f`](https://github.com/whatwg/streams/tree/ed00d2fe2d53ac5ad9ff8e727c7ef0a68f424074/) ([#43](https://github.com/MattiasBuelens/web-streams-polyfill/issues/43), [#44](https://github.com/MattiasBuelens/web-streams-polyfill/pull/44)) * 🏠 Down-level type definitions for older TypeScript versions. ([#41](https://github.com/MattiasBuelens/web-streams-polyfill/pull/41)) ## v2.0.6 (2019-11-08) * 🐛 Fix type definitions to be compatible with TypeScript 3.3 and lower. ([#39](https://github.com/MattiasBuelens/web-streams-polyfill/issues/39), [#40](https://github.com/MattiasBuelens/web-streams-polyfill/pull/40)) ## v2.0.5 (2019-10-08) * 👓 Align with [spec version `ae5e0cb`](https://github.com/whatwg/streams/tree/ae5e0cb41e9f72cdd97f3a6d47bc674c1f4049d1/) ([#33](https://github.com/MattiasBuelens/web-streams-polyfill/pull/33)) * 🐛 Fix support for non-browser environments, such as Node. * Accept polyfilled `AbortSignal`s. ([#36](https://github.com/MattiasBuelens/web-streams-polyfill/pull/36)) * Polyfill `DOMException` if necessary. ([#37](https://github.com/MattiasBuelens/web-streams-polyfill/pull/37)) ## v2.0.4 (2019-08-01) * 🐛 Fix pipe not aborting when both `preventAbort` and `preventCancel` are set ([#31](https://github.com/MattiasBuelens/web-streams-polyfill/pull/31)) * 👓 Align with [spec version `e4d3b1a`](https://github.com/whatwg/streams/tree/e4d3b1a826e34d27a7cb5485a1cc4b078608c9ec/) ([#31](https://github.com/MattiasBuelens/web-streams-polyfill/pull/31)) ## v2.0.3 (2019-04-04) * 👓 Align with [spec version `6f94580`](https://github.com/whatwg/streams/tree/6f94580f6731d1e017c516af097d47c45aad1f56/) ([#21](https://github.com/MattiasBuelens/web-streams-polyfill/pull/21)) * 🏠 Run web platform tests on ES5 variant ([#19](https://github.com/MattiasBuelens/web-streams-polyfill/pull/19)) ## v2.0.2 (2019-03-17) * 💅 Improve performance of `reader.read()` and `writer.write()` ([#17](https://github.com/MattiasBuelens/web-streams-polyfill/pull/17), [#18](https://github.com/MattiasBuelens/web-streams-polyfill/pull/18)) ## v2.0.1 (2019-03-16) * 🐛 Fix performance issue with large queues ([#15](https://github.com/MattiasBuelens/web-streams-polyfill/pull/15), [#16](https://github.com/MattiasBuelens/web-streams-polyfill/pull/16)) ## v2.0.0 (2019-03-10) * 💥 Ownership change: [@mattiasbuelens/web-streams-polyfill](https://www.npmjs.com/package/@mattiasbuelens/web-streams-polyfill/v/0.3.2) has been republished as [web-streams-polyfill](https://www.npmjs.com/package/web-streams-polyfill). For the full list of changes between web-streams-polyfill v1.3.2 and this version, [visit the fork's changelog](https://github.com/MattiasBuelens/web-streams-polyfill/blob/v0.3.2/CHANGELOG.md). * 💥 CommonJS entry points have been moved to `dist/`: * `index.js` ➡ `dist/polyfill.js` * `index.es6.js` ➡ `dist/polyfill.es6.js` However, we recommend migrating to a [variant sub-package](https://github.com/MattiasBuelens/web-streams-polyfill#usage) instead: * `require('web-streams-polyfill/index.js')` ➡ `require('web-streams-polyfill')` * `require('web-streams-polyfill/index.es6.js')` ➡ `require('web-streams-polyfill/es6')` * 👓 Align with [spec version `2c8f35e`](https://github.com/whatwg/streams/tree/2c8f35ed23451ffc9b32ec37b56def4a5349abb1/) * 🏠 Code moved from [creatorrr/web-streams-polyfill](https://github.com/creatorrr/web-streams-polyfill) to [MattiasBuelens/web-streams-polyfill](https://github.com/MattiasBuelens/web-streams-polyfill) web-streams-polyfill-3.2.1/CONTRIBUTING.md000066400000000000000000000031331422364423700200360ustar00rootroot00000000000000# Guidelines ## Setting up 1. Clone the repository 1. Run `npm install` ## Scripts - `npm run build` generates the bundled JavaScript (`.js`) and TypeScript type definitions (`.d.ts`), and outputs them to `dist/`. These generated files are **not** checked into version control. - `npm test` runs the three test suites: - `npm run test:wpt` runs the [Web Platform Tests for Streams][wpt-streams] against the generated JavaScript bundle, to verify that the polyfill's run-time behavior matches the specification. - `npm run test:types` runs the TypeScript compiler against some reference code that uses the generated type definitions, to verify that the code successfully passes the type check. - `npm run test:unit` runs a few unit tests in a Node environment, to verify that the polyfill also works without a browser environment. ## Miscellaneous - Do not manually change any files within `test/web-platform-tests`, as they are part of a Git submodule. - If you want to update the polyfill to a newer version of the streams specification: 1. Find the commit of the `web-platform-tests` Git submodule of [the reference implementation][ref-impl]. 1. Update the submodule in `test/web-platform-tests` to the same commit. 1. Update the polyfill implementation to pass the new tests. 1. Commit, push and open a pull request. Thanks! 😁 - The polyfill's API should remain backwards compatible. The type tests can help to check API compatibility. [wpt-streams]: https://github.com/web-platform-tests/wpt/tree/master/streams/ [ref-impl]: https://github.com/whatwg/streams/tree/master/reference-implementation/ web-streams-polyfill-3.2.1/LICENSE000066400000000000000000000021401422364423700166070ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2020 Mattias Buelens Copyright (c) 2016 Diwank Singh Tomer Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. web-streams-polyfill-3.2.1/README.md000066400000000000000000000163531422364423700170740ustar00rootroot00000000000000# web-streams-polyfill Web Streams, based on the WHATWG spec reference implementation. [![build status](https://api.travis-ci.com/MattiasBuelens/web-streams-polyfill.svg?branch=master)](https://travis-ci.com/MattiasBuelens/web-streams-polyfill) [![npm version](https://img.shields.io/npm/v/web-streams-polyfill.svg)](https://www.npmjs.com/package/web-streams-polyfill) [![license](https://img.shields.io/npm/l/web-streams-polyfill.svg)](https://github.com/MattiasBuelens/web-streams-polyfill/blob/master/LICENSE) [![Join the chat at https://gitter.im/web-streams-polyfill/Lobby](https://badges.gitter.im/web-streams-polyfill/Lobby.svg)](https://gitter.im/web-streams-polyfill/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ## Links - [Official spec][spec] - [Reference implementation][ref-impl] ## Usage This library comes in multiple variants: * `web-streams-polyfill`: a polyfill that replaces the native stream implementations. Recommended for use in web apps supporting older browsers through a ` ``` Usage as a Node module: ```js var streams = require("web-streams-polyfill/ponyfill"); var readable = new streams.ReadableStream(); ``` Usage as a ES2015 module: ```js import { ReadableStream } from "web-streams-polyfill/ponyfill"; const readable = new ReadableStream(); ``` ### Compatibility The `polyfill` and `ponyfill` variants work in any ES5-compatible environment that has a global `Promise`. If you need to support older browsers or Node versions that do not have a native `Promise` implementation (check the [support table][promise-support]), you must first include a `Promise` polyfill (e.g. [promise-polyfill][promise-polyfill]). The `polyfill/es6` and `ponyfill/es6` variants work in any ES2015-compatible environment. The `polyfill/es2018` and `ponyfill/es2018` variants work in any ES2018-compatible environment. [Async iterable support for `ReadableStream`][rs-asynciterator] is available in all variants, but requires an ES2018-compatible environment or a polyfill for `Symbol.asyncIterator`. [`WritableStreamDefaultController.signal`][ws-controller-signal] is available in all variants, but requires a global `AbortController` constructor. If necessary, consider using a polyfill such as [abortcontroller-polyfill]. ### Compliance The polyfill implements [version `4b6b93c` (25 Oct 2021)][spec-snapshot] of the streams specification. The polyfill is tested against the same [web platform tests][wpt] that are used by browsers to test their native implementations. The polyfill aims to pass all tests, although it allows some exceptions for practical reasons: * The `es2018` variant passes all of the tests, except for the ["bad buffers and views" tests for readable byte streams][wpt-bad-buffers]. These tests require the implementation to synchronously transfer the contents of an `ArrayBuffer`, which is not yet possible from JavaScript (although there is a [proposal][proposal-arraybuffer-transfer] to make it possible). The reference implementation "cheats" on these tests [by making a copy instead][ref-impl-transferarraybuffer], but that is unacceptable for the polyfill's performance ([#3][issue-3]). * The `es6` variant passes the same tests as the `es2018` variant, except for the [test for the prototype of `ReadableStream`'s async iterator][wpt-async-iterator-prototype]. Retrieving the correct `%AsyncIteratorPrototype%` requires using an async generator (`async function* () {}`), which is invalid syntax before ES2018. Instead, the polyfill [creates its own version][stub-async-iterator-prototype] which is functionally equivalent to the real prototype. * The `es5` variant passes the same tests as the `es6` variant, except for various tests about specific characteristics of the constructors, properties and methods. These test failures do not affect the run-time behavior of the polyfill. For example: * The `name` property of down-leveled constructors is incorrect. * The `length` property of down-leveled constructors and methods with optional arguments is incorrect. * Not all properties and methods are correctly marked as non-enumerable. * Down-leveled class methods are not correctly marked as non-constructable. The type definitions are compatible with the built-in stream types of TypeScript 3.3. ### Contributors Thanks to these people for their work on [the original polyfill][creatorrr-polyfill]: - Diwank Singh Tomer ([creatorrr](https://github.com/creatorrr)) - Anders Riutta ([ariutta](https://github.com/ariutta)) [spec]: https://streams.spec.whatwg.org [ref-impl]: https://github.com/whatwg/streams [ponyfill]: https://github.com/sindresorhus/ponyfill [promise-support]: https://kangax.github.io/compat-table/es6/#test-Promise [promise-polyfill]: https://www.npmjs.com/package/promise-polyfill [rs-asynciterator]: https://streams.spec.whatwg.org/#rs-asynciterator [ws-controller-signal]: https://streams.spec.whatwg.org/#ws-default-controller-signal [abortcontroller-polyfill]: https://www.npmjs.com/package/abortcontroller-polyfill [spec-snapshot]: https://streams.spec.whatwg.org/commit-snapshots/4b6b93c69e531e2fe45a6ed4cb1484a7ba4eb8bb/ [wpt]: https://github.com/web-platform-tests/wpt/tree/96ca25f0f7526282c0d47e6bf6a7edd439da1968/streams [wpt-bad-buffers]: https://github.com/web-platform-tests/wpt/blob/96ca25f0f7526282c0d47e6bf6a7edd439da1968/streams/readable-byte-streams/bad-buffers-and-views.any.js [proposal-arraybuffer-transfer]: https://github.com/domenic/proposal-arraybuffer-transfer [ref-impl-transferarraybuffer]: https://github.com/whatwg/streams/blob/4b6b93c69e531e2fe45a6ed4cb1484a7ba4eb8bb/reference-implementation/lib/abstract-ops/ecmascript.js#L16 [issue-3]: https://github.com/MattiasBuelens/web-streams-polyfill/issues/3 [wpt-async-iterator-prototype]: https://github.com/web-platform-tests/wpt/blob/96ca25f0f7526282c0d47e6bf6a7edd439da1968/streams/readable-streams/async-iterator.any.js#L24 [stub-async-iterator-prototype]: https://github.com/MattiasBuelens/web-streams-polyfill/blob/v2.0.0/src/target/es5/stub/async-iterator-prototype.ts [creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill web-streams-polyfill-3.2.1/api-extractor.json000066400000000000000000000336131422364423700212700ustar00rootroot00000000000000/** * Config file for API Extractor. For more info, please visit: https://api-extractor.com */ { "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", /** * Optionally specifies another JSON config file that this file extends from. This provides a way for * standard settings to be shared across multiple projects. * * If the path starts with "./" or "../", the path is resolved relative to the folder of the file that contains * the "extends" field. Otherwise, the first path segment is interpreted as an NPM package name, and will be * resolved using NodeJS require(). * * SUPPORTED TOKENS: none * DEFAULT VALUE: "" */ // "extends": "./shared/api-extractor-base.json" // "extends": "my-package/include/api-extractor-base.json" /** * Determines the "" token that can be used with other config file settings. The project folder * typically contains the tsconfig.json and package.json config files, but the path is user-defined. * * The path is resolved relative to the folder of the config file that contains the setting. * * The default value for "projectFolder" is the token "", which means the folder is determined by traversing * parent folders, starting from the folder containing api-extractor.json, and stopping at the first folder * that contains a tsconfig.json file. If a tsconfig.json file cannot be found in this way, then an error * will be reported. * * SUPPORTED TOKENS: * DEFAULT VALUE: "" */ "projectFolder": ".", /** * (REQUIRED) Specifies the .d.ts file to be used as the starting point for analysis. API Extractor * analyzes the symbols exported by this module. * * The file extension must be ".d.ts" and not ".ts". * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * SUPPORTED TOKENS: , , */ "mainEntryPointFilePath": "/lib/polyfill.d.ts", /** * A list of NPM package names whose exports should be treated as part of this package. * * For example, suppose that Webpack is used to generate a distributed bundle for the project "library1", * and another NPM package "library2" is embedded in this bundle. Some types from library2 may become part * of the exported API for library1, but by default API Extractor would generate a .d.ts rollup that explicitly * imports library2. To avoid this, we can specify: * * "bundledPackages": [ "library2" ], * * This would direct API Extractor to embed those types directly in the .d.ts rollup, as if they had been * local files for library1. */ "bundledPackages": [], /** * Determines how the TypeScript compiler engine will be invoked by API Extractor. */ "compiler": { /** * Specifies the path to the tsconfig.json file to be used by API Extractor when analyzing the project. * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * Note: This setting will be ignored if "overrideTsconfig" is used. * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "/tsconfig.json" */ "tsconfigFilePath": "/tsconfig.json", /** * Provides a compiler configuration that will be used instead of reading the tsconfig.json file from disk. * The object must conform to the TypeScript tsconfig schema: * * http://json.schemastore.org/tsconfig * * If omitted, then the tsconfig.json file will be read from the "projectFolder". * * DEFAULT VALUE: no overrideTsconfig section */ // "overrideTsconfig": { // . . . // } /** * This option causes the compiler to be invoked with the --skipLibCheck option. This option is not recommended * and may cause API Extractor to produce incomplete or incorrect declarations, but it may be required when * dependencies contain declarations that are incompatible with the TypeScript engine that API Extractor uses * for its analysis. Where possible, the underlying issue should be fixed rather than relying on skipLibCheck. * * DEFAULT VALUE: false */ // "skipLibCheck": true, }, /** * Configures how the API report file (*.api.md) will be generated. */ "apiReport": { /** * (REQUIRED) Whether to generate an API report. */ "enabled": true /** * The filename for the API report files. It will be combined with "reportFolder" or "reportTempFolder" to produce * a full file path. * * The file extension should be ".api.md", and the string should not contain a path separator such as "\" or "/". * * SUPPORTED TOKENS: , * DEFAULT VALUE: ".api.md" */ // "reportFileName": ".api.md", /** * Specifies the folder where the API report file is written. The file name portion is determined by * the "reportFileName" setting. * * The API report file is normally tracked by Git. Changes to it can be used to trigger a branch policy, * e.g. for an API review. * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "/etc/" */ // "reportFolder": "/etc/", /** * Specifies the folder where the temporary report file is written. The file name portion is determined by * the "reportFileName" setting. * * After the temporary file is written to disk, it is compared with the file in the "reportFolder". * If they are different, a production build will fail. * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "/temp/" */ // "reportTempFolder": "/temp/" }, /** * Configures how the doc model file (*.api.json) will be generated. */ "docModel": { /** * (REQUIRED) Whether to generate a doc model file. */ "enabled": true /** * The output path for the doc model file. The file extension should be ".api.json". * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "/temp/.api.json" */ // "apiJsonFilePath": "/temp/.api.json" }, /** * Configures how the .d.ts rollup file will be generated. */ "dtsRollup": { /** * (REQUIRED) Whether to generate the .d.ts rollup file. */ "enabled": true, /** * Specifies the output path for a .d.ts rollup file to be generated without any trimming. * This file will include all declarations that are exported by the main entry point. * * If the path is an empty string, then this file will not be written. * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "/dist/.d.ts" */ "untrimmedFilePath": "/dist/types/polyfill.d.ts", /** * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "beta" release. * This file will include only declarations that are marked as "@public" or "@beta". * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "" */ // "betaTrimmedFilePath": "/dist/-beta.d.ts", /** * Specifies the output path for a .d.ts rollup file to be generated with trimming for a "public" release. * This file will include only declarations that are marked as "@public". * * If the path is an empty string, then this file will not be written. * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "" */ // "publicTrimmedFilePath": "/dist/-public.d.ts", /** * When a declaration is trimmed, by default it will be replaced by a code comment such as * "Excluded from this release type: exampleMember". Set "omitTrimmingComments" to true to remove the * declaration completely. * * DEFAULT VALUE: false */ // "omitTrimmingComments": true }, /** * Configures how the tsdoc-metadata.json file will be generated. */ "tsdocMetadata": { /** * Whether to generate the tsdoc-metadata.json file. * * DEFAULT VALUE: true */ // "enabled": true, /** * Specifies where the TSDoc metadata file should be written. * * The path is resolved relative to the folder of the config file that contains the setting; to change this, * prepend a folder token such as "". * * The default value is "", which causes the path to be automatically inferred from the "tsdocMetadata", * "typings" or "main" fields of the project's package.json. If none of these fields are set, the lookup * falls back to "tsdoc-metadata.json" in the package folder. * * SUPPORTED TOKENS: , , * DEFAULT VALUE: "" */ // "tsdocMetadataFilePath": "/dist/tsdoc-metadata.json" }, /** * Specifies what type of newlines API Extractor should use when writing output files. By default, the output files * will be written with Windows-style newlines. To use POSIX-style newlines, specify "lf" instead. * To use the OS's default newline kind, specify "os". * * DEFAULT VALUE: "crlf" */ "newlineKind": "lf", /** * Configures how API Extractor reports error and warning messages produced during analysis. * * There are three sources of messages: compiler messages, API Extractor messages, and TSDoc messages. */ "messages": { /** * Configures handling of diagnostic messages reported by the TypeScript compiler engine while analyzing * the input .d.ts files. * * TypeScript message identifiers start with "TS" followed by an integer. For example: "TS2551" * * DEFAULT VALUE: A single "default" entry with logLevel=warning. */ "compilerMessageReporting": { /** * Configures the default routing for messages that don't match an explicit rule in this table. */ "default": { /** * Specifies whether the message should be written to the the tool's output log. Note that * the "addToApiReportFile" property may supersede this option. * * Possible values: "error", "warning", "none" * * Errors cause the build to fail and return a nonzero exit code. Warnings cause a production build fail * and return a nonzero exit code. For a non-production build (e.g. when "api-extractor run" includes * the "--local" option), the warning is displayed but the build will not fail. * * DEFAULT VALUE: "warning" */ "logLevel": "warning" /** * When addToApiReportFile is true: If API Extractor is configured to write an API report file (.api.md), * then the message will be written inside that file; otherwise, the message is instead logged according to * the "logLevel" option. * * DEFAULT VALUE: false */ // "addToApiReportFile": false } // "TS2551": { // "logLevel": "warning", // "addToApiReportFile": true // }, // // . . . }, /** * Configures handling of messages reported by API Extractor during its analysis. * * API Extractor message identifiers start with "ae-". For example: "ae-extra-release-tag" * * DEFAULT VALUE: See api-extractor-defaults.json for the complete table of extractorMessageReporting mappings */ "extractorMessageReporting": { "default": { "logLevel": "warning" // "addToApiReportFile": false } // "ae-extra-release-tag": { // "logLevel": "warning", // "addToApiReportFile": true // }, // // . . . }, /** * Configures handling of messages reported by the TSDoc parser when analyzing code comments. * * TSDoc message identifiers start with "tsdoc-". For example: "tsdoc-link-tag-unescaped-text" * * DEFAULT VALUE: A single "default" entry with logLevel=warning. */ "tsdocMessageReporting": { "default": { "logLevel": "warning" // "addToApiReportFile": false } // "tsdoc-link-tag-unescaped-text": { // "logLevel": "warning", // "addToApiReportFile": true // }, // // . . . } } } web-streams-polyfill-3.2.1/build/000077500000000000000000000000001422364423700167045ustar00rootroot00000000000000web-streams-polyfill-3.2.1/build/downlevel-dts.js000066400000000000000000000044401422364423700220330ustar00rootroot00000000000000// Based on downlevel-dts (MIT licensed) by Nathan Shively-Sanders // https://github.com/sandersn/downlevel-dts/blob/e7d1cb5aced5686826fe8aac4d4af2f745a9ef60/index.js const { Project, ts } = require('ts-morph'); const path = require('path'); const project = new Project(); const inputDir = project.addDirectoryAtPath(path.join(__dirname, '../dist/types/')); // Create output directory const ts36Dir = inputDir.createDirectory('ts3.6'); project.saveSync(); // Down-level all *.d.ts files in input directory const files = inputDir.addSourceFilesAtPaths('*.d.ts'); for (const f of files) { // Create copy for TypeScript 3.6+ f.copyToDirectory(ts36Dir, { overwrite: true }); downlevelTS36(f); downlevelTS34(f); // Original file will be overwritten by down-leveled file when saved } project.saveSync(); /** * Down-level TypeScript 3.6 types in the given source file */ function downlevelTS36(f) { // Replace get/set accessors with (read-only) properties const gs = f.getDescendantsOfKind(ts.SyntaxKind.GetAccessor); for (const g of gs) { const s = g.getSetAccessor(); const returnTypeNode = g.getReturnTypeNode(); const returnType = returnTypeNode ? returnTypeNode.getText() : 'any'; g.getParent().insertProperty(g.getChildIndex(), Object.assign({}, g.getStructure(), { type: returnType, isReadonly: !s })); g.remove(); if (s) { s.remove(); } } const ss = f.getDescendantsOfKind(ts.SyntaxKind.SetAccessor); for (const s of ss) { const g = s.getGetAccessor(); if (!g) { const firstParam = s.getParameters()[0]; const firstParamTypeNode = firstParam && firstParam.getTypeNode(); const firstParamType = firstParamTypeNode ? firstParamTypeNode.getText() : 'any'; s.getParent().insertProperty(s.getChildIndex(), Object.assign({}, s.getStructure(), { type: firstParamType, isReadonly: false })); s.remove(); } } } /** * Down-level TypeScript 3.4 types in the given source file */ function downlevelTS34(f) { // Replace "es2018.asynciterable" with "esnext.asynciterable" in lib references const refs = f.getLibReferenceDirectives(); for (const r of refs) { if (r.getFileName() === 'es2018.asynciterable') { f.replaceText([r.getPos(), r.getEnd()], 'esnext.asynciterable'); } } } web-streams-polyfill-3.2.1/es2018/000077500000000000000000000000001422364423700165275ustar00rootroot00000000000000web-streams-polyfill-3.2.1/es2018/package.json000066400000000000000000000003251422364423700210150ustar00rootroot00000000000000{ "name": "web-streams-polyfill-es2018", "main": "../dist/polyfill.es2018", "browser": "../dist/polyfill.es2018.min.js", "module": "../dist/polyfill.es2018.mjs", "types": "../dist/types/polyfill.d.ts" } web-streams-polyfill-3.2.1/es6/000077500000000000000000000000001422364423700163025ustar00rootroot00000000000000web-streams-polyfill-3.2.1/es6/package.json000066400000000000000000000003111422364423700205630ustar00rootroot00000000000000{ "name": "web-streams-polyfill-es6", "main": "../dist/polyfill.es6", "browser": "../dist/polyfill.es6.min.js", "module": "../dist/polyfill.es6.mjs", "types": "../dist/types/polyfill.d.ts" } web-streams-polyfill-3.2.1/etc/000077500000000000000000000000001422364423700163605ustar00rootroot00000000000000web-streams-polyfill-3.2.1/etc/web-streams-polyfill.api.md000066400000000000000000000204131422364423700235330ustar00rootroot00000000000000## API Report File for "web-streams-polyfill" > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts // @public export interface AbortSignal { readonly aborted: boolean; addEventListener(type: 'abort', listener: () => void): void; removeEventListener(type: 'abort', listener: () => void): void; } // @public export class ByteLengthQueuingStrategy implements QueuingStrategy { constructor(options: QueuingStrategyInit); get highWaterMark(): number; get size(): (chunk: ArrayBufferView) => number; } // @public export class CountQueuingStrategy implements QueuingStrategy { constructor(options: QueuingStrategyInit); get highWaterMark(): number; get size(): (chunk: any) => 1; } // @public export interface QueuingStrategy { highWaterMark?: number; // Warning: (ae-forgotten-export) The symbol "QueuingStrategySizeCallback" needs to be exported by the entry point polyfill.d.ts size?: QueuingStrategySizeCallback; } // @public (undocumented) export interface QueuingStrategyInit { highWaterMark: number; } // @public export class ReadableByteStreamController { get byobRequest(): ReadableStreamBYOBRequest | null; close(): void; get desiredSize(): number | null; enqueue(chunk: ArrayBufferView): void; error(e?: any): void; } // @public export class ReadableStream { [Symbol.asyncIterator]: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator; constructor(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number; size?: undefined; }); constructor(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy); cancel(reason?: any): Promise; getReader({ mode }: { mode: 'byob'; }): ReadableStreamBYOBReader; getReader(): ReadableStreamDefaultReader; get locked(): boolean; pipeThrough(transform: { readable: RS; writable: WritableStream; }, options?: StreamPipeOptions): RS; pipeTo(destination: WritableStream, options?: StreamPipeOptions): Promise; tee(): [ReadableStream, ReadableStream]; values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator; } // @public export interface ReadableStreamAsyncIterator extends AsyncIterator { // (undocumented) next(): Promise>; // (undocumented) return(value?: any): Promise>; } // @public export class ReadableStreamBYOBReader { // Warning: (ae-forgotten-export) The symbol "ReadableByteStream" needs to be exported by the entry point polyfill.d.ts constructor(stream: ReadableByteStream); cancel(reason?: any): Promise; get closed(): Promise; read(view: T): Promise>; releaseLock(): void; } // @public export type ReadableStreamBYOBReadResult = { done: false; value: T; } | { done: true; value: T | undefined; }; // @public export class ReadableStreamBYOBRequest { respond(bytesWritten: number): void; respondWithNewView(view: ArrayBufferView): void; get view(): ArrayBufferView | null; } // @public export class ReadableStreamDefaultController { close(): void; get desiredSize(): number | null; enqueue(chunk: R): void; error(e?: any): void; } // @public export class ReadableStreamDefaultReader { constructor(stream: ReadableStream); cancel(reason?: any): Promise; get closed(): Promise; read(): Promise>; releaseLock(): void; } // @public export type ReadableStreamDefaultReadResult = { done: false; value: T; } | { done: true; value?: undefined; }; // @public export interface ReadableStreamIteratorOptions { // (undocumented) preventCancel?: boolean; } // @public export interface ReadableWritablePair { // (undocumented) readable: ReadableStream; // (undocumented) writable: WritableStream; } // @public export interface StreamPipeOptions { preventAbort?: boolean; preventCancel?: boolean; preventClose?: boolean; signal?: AbortSignal; } // @public export interface Transformer { flush?: TransformerFlushCallback; // (undocumented) readableType?: undefined; start?: TransformerStartCallback; transform?: TransformerTransformCallback; // (undocumented) writableType?: undefined; } // @public (undocumented) export type TransformerFlushCallback = (controller: TransformStreamDefaultController) => void | PromiseLike; // @public (undocumented) export type TransformerStartCallback = (controller: TransformStreamDefaultController) => void | PromiseLike; // @public (undocumented) export type TransformerTransformCallback = (chunk: I, controller: TransformStreamDefaultController) => void | PromiseLike; // @public export class TransformStream { constructor(transformer?: Transformer, writableStrategy?: QueuingStrategy, readableStrategy?: QueuingStrategy); get readable(): ReadableStream; get writable(): WritableStream; } // @public export class TransformStreamDefaultController { get desiredSize(): number | null; enqueue(chunk: O): void; error(reason?: any): void; terminate(): void; } // @public export interface UnderlyingByteSource { autoAllocateChunkSize?: number; cancel?: UnderlyingSourceCancelCallback; pull?: UnderlyingByteSourcePullCallback; start?: UnderlyingByteSourceStartCallback; type: 'bytes'; } // @public (undocumented) export type UnderlyingByteSourcePullCallback = (controller: ReadableByteStreamController) => void | PromiseLike; // @public (undocumented) export type UnderlyingByteSourceStartCallback = (controller: ReadableByteStreamController) => void | PromiseLike; // @public export interface UnderlyingSink { abort?: UnderlyingSinkAbortCallback; close?: UnderlyingSinkCloseCallback; start?: UnderlyingSinkStartCallback; // (undocumented) type?: undefined; write?: UnderlyingSinkWriteCallback; } // @public (undocumented) export type UnderlyingSinkAbortCallback = (reason: any) => void | PromiseLike; // @public (undocumented) export type UnderlyingSinkCloseCallback = () => void | PromiseLike; // @public (undocumented) export type UnderlyingSinkStartCallback = (controller: WritableStreamDefaultController) => void | PromiseLike; // @public (undocumented) export type UnderlyingSinkWriteCallback = (chunk: W, controller: WritableStreamDefaultController) => void | PromiseLike; // @public export interface UnderlyingSource { cancel?: UnderlyingSourceCancelCallback; pull?: UnderlyingSourcePullCallback; start?: UnderlyingSourceStartCallback; // (undocumented) type?: undefined; } // @public (undocumented) export type UnderlyingSourceCancelCallback = (reason: any) => void | PromiseLike; // @public (undocumented) export type UnderlyingSourcePullCallback = (controller: ReadableStreamDefaultController) => void | PromiseLike; // @public (undocumented) export type UnderlyingSourceStartCallback = (controller: ReadableStreamDefaultController) => void | PromiseLike; // @public export class WritableStream { constructor(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy); abort(reason?: any): Promise; close(): Promise; getWriter(): WritableStreamDefaultWriter; get locked(): boolean; } // @public export class WritableStreamDefaultController { // @deprecated get abortReason(): any; error(e?: any): void; get signal(): AbortSignal; } // @public export class WritableStreamDefaultWriter { constructor(stream: WritableStream); abort(reason?: any): Promise; close(): Promise; get closed(): Promise; get desiredSize(): number | null; get ready(): Promise; releaseLock(): void; write(chunk: W): Promise; } // (No @packageDocumentation comment for this package) ``` web-streams-polyfill-3.2.1/package-lock.json000066400000000000000000003230671422364423700210340ustar00rootroot00000000000000{ "name": "web-streams-polyfill", "version": "3.2.1", "lockfileVersion": 1, "requires": true, "dependencies": { "@babel/code-frame": { "version": "7.12.13", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.13.tgz", "integrity": "sha512-HV1Cm0Q3ZrpCR93tkWOYiuYIgLxZXZFVG2VgK+MBWjUqZTundupbfx2aXarXuw5Ko5aMcjtJgbSs4vUGBS5v6g==", "dev": true, "requires": { "@babel/highlight": "^7.12.13" } }, "@babel/helper-validator-identifier": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.12.11.tgz", "integrity": "sha512-np/lG3uARFybkoHokJUmf1QfEvRVCPbmQeUQpKow5cQ3xWrV9i3rUHodKDJPQfTVX61qKi+UdYk8kik84n7XOw==", "dev": true }, "@babel/highlight": { "version": "7.12.13", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.12.13.tgz", "integrity": "sha512-kocDQvIbgMKlWxXe9fof3TQ+gkIPOUSEYhJjqUjvKMez3krV7vbzYCDq39Oj11UAVK7JqPVGQPlgE85dPNlQww==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.12.11", "chalk": "^2.0.0", "js-tokens": "^4.0.0" }, "dependencies": { "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", "supports-color": "^5.3.0" } } } }, "@eslint/eslintrc": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-0.4.0.tgz", "integrity": "sha512-2ZPCc+uNbjV5ERJr+aKSPRwZgKd2z11x0EgLvb1PURmUrn9QNRXFqje0Ldq454PfAVyaJYyrDvvIKSFP4NnBog==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.1.1", "espree": "^7.3.0", "globals": "^12.1.0", "ignore": "^4.0.6", "import-fresh": "^3.2.1", "js-yaml": "^3.13.1", "minimatch": "^3.0.4", "strip-json-comments": "^3.1.1" }, "dependencies": { "globals": { "version": "12.4.0", "resolved": "https://registry.npmjs.org/globals/-/globals-12.4.0.tgz", "integrity": "sha512-BWICuzzDvDoH54NHKCseDanAhE3CeDorgDL5MT6LMXXj2WCnd9UC2szdk4AWLfjdgNBCXLUanXYcpBBKOSWGwg==", "dev": true, "requires": { "type-fest": "^0.8.1" } }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true } } }, "@microsoft/api-extractor": { "version": "7.13.4", "resolved": "https://registry.npmjs.org/@microsoft/api-extractor/-/api-extractor-7.13.4.tgz", "integrity": "sha512-Y/XxSKL9velCpd0DffSFG6kYpH47KE2eECN28ompu8CUG7jbYFUJcMgk/6R/d44vlg3V77FnF8TZ+KzTlnN9SQ==", "dev": true, "requires": { "@microsoft/api-extractor-model": "7.12.4", "@microsoft/tsdoc": "0.12.24", "@rushstack/node-core-library": "3.36.1", "@rushstack/rig-package": "0.2.11", "@rushstack/ts-command-line": "4.7.9", "colors": "~1.2.1", "lodash": "~4.17.15", "resolve": "~1.17.0", "semver": "~7.3.0", "source-map": "~0.6.1", "typescript": "~4.1.3" }, "dependencies": { "typescript": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.5.tgz", "integrity": "sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA==", "dev": true } } }, "@microsoft/api-extractor-model": { "version": "7.12.4", "resolved": "https://registry.npmjs.org/@microsoft/api-extractor-model/-/api-extractor-model-7.12.4.tgz", "integrity": "sha512-uTLpqr48g3ICFMadIE2rQvEhA/y4Ez3m2KqQ9qtsr/weIJ/64LI+ItZTKrrKHAxP7tLgGv0FodLsy5E7cyJy/A==", "dev": true, "requires": { "@microsoft/tsdoc": "0.12.24", "@rushstack/node-core-library": "3.36.1" } }, "@microsoft/tsdoc": { "version": "0.12.24", "resolved": "https://registry.npmjs.org/@microsoft/tsdoc/-/tsdoc-0.12.24.tgz", "integrity": "sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg==", "dev": true }, "@nodelib/fs.scandir": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.4.tgz", "integrity": "sha512-33g3pMJk3bg5nXbL/+CY6I2eJDzZAni49PfJnL5fghPTggPvBd/pFNSgJsdAgWptuFu7qq/ERvOYFlhvsLTCKA==", "dev": true, "requires": { "@nodelib/fs.stat": "2.0.4", "run-parallel": "^1.1.9" } }, "@nodelib/fs.stat": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.4.tgz", "integrity": "sha512-IYlHJA0clt2+Vg7bccq+TzRdJvv19c2INqBSsoOLp1je7xjtr7J26+WXR72MCdvU9q1qTzIWDfhMf+DRvQJK4Q==", "dev": true }, "@nodelib/fs.walk": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.6.tgz", "integrity": "sha512-8Broas6vTtW4GIXTAHDoE32hnN2M5ykgCpWGbuXHQ15vEMqr23pB76e/GZcYsZCHALv50ktd24qhEyKr6wBtow==", "dev": true, "requires": { "@nodelib/fs.scandir": "2.1.4", "fastq": "^1.6.0" } }, "@rollup/plugin-inject": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@rollup/plugin-inject/-/plugin-inject-4.0.2.tgz", "integrity": "sha512-TSLMA8waJ7Dmgmoc8JfPnwUwVZgLjjIAM6MqeIFqPO2ODK36JqE0Cf2F54UTgCUuW8da93Mvoj75a6KAVWgylw==", "dev": true, "requires": { "@rollup/pluginutils": "^3.0.4", "estree-walker": "^1.0.1", "magic-string": "^0.25.5" } }, "@rollup/plugin-replace": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/@rollup/plugin-replace/-/plugin-replace-2.4.2.tgz", "integrity": "sha512-IGcu+cydlUMZ5En85jxHH4qj2hta/11BHq95iHEyb2sbgiN0eCdzvUcHw5gt9pBL5lTi4JDYJ1acCoMGpTvEZg==", "dev": true, "requires": { "@rollup/pluginutils": "^3.1.0", "magic-string": "^0.25.7" } }, "@rollup/plugin-strip": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-strip/-/plugin-strip-2.0.0.tgz", "integrity": "sha512-1xtE2FDk7Wwr2dEPugkQp3M2FGtSVYeRQaJnHJIkHzcXpBlxT/z+jJoVUvm8LGXso+bLWgO65WrmQ6bC6e/x+A==", "dev": true, "requires": { "@rollup/pluginutils": "^3.0.4", "estree-walker": "^1.0.1", "magic-string": "^0.25.5" } }, "@rollup/plugin-typescript": { "version": "8.2.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-8.2.1.tgz", "integrity": "sha512-Qd2E1pleDR4bwyFxqbjt4eJf+wB0UKVMLc7/BAFDGVdAXQMCsD4DUv5/7/ww47BZCYxWtJqe1Lo0KVNswBJlRw==", "dev": true, "requires": { "@rollup/pluginutils": "^3.1.0", "resolve": "^1.17.0" } }, "@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", "dev": true, "requires": { "@types/estree": "0.0.39", "estree-walker": "^1.0.1", "picomatch": "^2.2.2" }, "dependencies": { "picomatch": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "dev": true } } }, "@rushstack/node-core-library": { "version": "3.36.1", "resolved": "https://registry.npmjs.org/@rushstack/node-core-library/-/node-core-library-3.36.1.tgz", "integrity": "sha512-YMXJ0bEpxG9AnK1shZTOay5xSIuerzxCV9sscn3xynnndBdma0oE243V79Fb25zzLfkZ1Xg9TbOXc5zmF7NYYA==", "dev": true, "requires": { "@types/node": "10.17.13", "colors": "~1.2.1", "fs-extra": "~7.0.1", "import-lazy": "~4.0.0", "jju": "~1.4.0", "resolve": "~1.17.0", "semver": "~7.3.0", "timsort": "~0.3.0", "z-schema": "~3.18.3" }, "dependencies": { "@types/node": { "version": "10.17.13", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.13.tgz", "integrity": "sha512-pMCcqU2zT4TjqYFrWtYHKal7Sl30Ims6ulZ4UFXxI4xbtQqK/qqKwkDoBFCfooRqqmRu9vY3xaJRwxSh673aYg==", "dev": true } } }, "@rushstack/rig-package": { "version": "0.2.11", "resolved": "https://registry.npmjs.org/@rushstack/rig-package/-/rig-package-0.2.11.tgz", "integrity": "sha512-6Q07ZxjnthXWSXfDy/CgjhhGaqb/0RvZbqWScLr216Cy7fuAAmjbMhE2E53+rjXOsolrS5Ep7Xcl5TQre723cA==", "dev": true, "requires": { "resolve": "~1.17.0", "strip-json-comments": "~3.1.1" } }, "@rushstack/ts-command-line": { "version": "4.7.9", "resolved": "https://registry.npmjs.org/@rushstack/ts-command-line/-/ts-command-line-4.7.9.tgz", "integrity": "sha512-Jq5O4t0op9xdFfS9RbUV/ZFlAFxX6gdVTY+69UFRTn9pwWOzJR0kroty01IlnDByPCgvHH8RMz9sEXzD9Qxdrg==", "dev": true, "requires": { "@types/argparse": "1.0.38", "argparse": "~1.0.9", "colors": "~1.2.1", "string-argv": "~0.3.1" } }, "@ts-morph/common": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/@ts-morph/common/-/common-0.9.0.tgz", "integrity": "sha512-yPcW6koNVK1hVKUu+KhPzhfgMb0uwzr2FewF+q8kxLerl0b+YZwmjvFMU2qbIawytIHT2VBI4bi+C09EFPB4aw==", "dev": true, "requires": { "fast-glob": "^3.2.5", "minimatch": "^3.0.4", "mkdirp": "^1.0.4" } }, "@types/argparse": { "version": "1.0.38", "resolved": "https://registry.npmjs.org/@types/argparse/-/argparse-1.0.38.tgz", "integrity": "sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA==", "dev": true }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, "@types/json-schema": { "version": "7.0.7", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.7.tgz", "integrity": "sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==", "dev": true }, "@types/node": { "version": "14.14.37", "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.37.tgz", "integrity": "sha512-XYmBiy+ohOR4Lh5jE379fV2IU+6Jn4g5qASinhitfyO71b/sCo6MKsMLF5tc7Zf2CE8hViVQyYSobJNke8OvUw==", "dev": true }, "@typescript-eslint/eslint-plugin": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.21.0.tgz", "integrity": "sha512-FPUyCPKZbVGexmbCFI3EQHzCZdy2/5f+jv6k2EDljGdXSRc0cKvbndd2nHZkSLqCNOPk0jB6lGzwIkglXcYVsQ==", "dev": true, "requires": { "@typescript-eslint/experimental-utils": "4.21.0", "@typescript-eslint/scope-manager": "4.21.0", "debug": "^4.1.1", "functional-red-black-tree": "^1.0.1", "lodash": "^4.17.15", "regexpp": "^3.0.0", "semver": "^7.3.2", "tsutils": "^3.17.1" } }, "@typescript-eslint/experimental-utils": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-4.21.0.tgz", "integrity": "sha512-cEbgosW/tUFvKmkg3cU7LBoZhvUs+ZPVM9alb25XvR0dal4qHL3SiUqHNrzoWSxaXA9gsifrYrS1xdDV6w/gIA==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", "@typescript-eslint/scope-manager": "4.21.0", "@typescript-eslint/types": "4.21.0", "@typescript-eslint/typescript-estree": "4.21.0", "eslint-scope": "^5.0.0", "eslint-utils": "^2.0.0" } }, "@typescript-eslint/parser": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.21.0.tgz", "integrity": "sha512-eyNf7QmE5O/l1smaQgN0Lj2M/1jOuNg2NrBm1dqqQN0sVngTLyw8tdCbih96ixlhbF1oINoN8fDCyEH9SjLeIA==", "dev": true, "requires": { "@typescript-eslint/scope-manager": "4.21.0", "@typescript-eslint/types": "4.21.0", "@typescript-eslint/typescript-estree": "4.21.0", "debug": "^4.1.1" } }, "@typescript-eslint/scope-manager": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.21.0.tgz", "integrity": "sha512-kfOjF0w1Ix7+a5T1knOw00f7uAP9Gx44+OEsNQi0PvvTPLYeXJlsCJ4tYnDj5PQEYfpcgOH5yBlw7K+UEI9Agw==", "dev": true, "requires": { "@typescript-eslint/types": "4.21.0", "@typescript-eslint/visitor-keys": "4.21.0" } }, "@typescript-eslint/types": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.21.0.tgz", "integrity": "sha512-+OQaupjGVVc8iXbt6M1oZMwyKQNehAfLYJJ3SdvnofK2qcjfor9pEM62rVjBknhowTkh+2HF+/KdRAc/wGBN2w==", "dev": true }, "@typescript-eslint/typescript-estree": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.21.0.tgz", "integrity": "sha512-ZD3M7yLaVGVYLw4nkkoGKumb7Rog7QID9YOWobFDMQKNl+vPxqVIW/uDk+MDeGc+OHcoG2nJ2HphwiPNajKw3w==", "dev": true, "requires": { "@typescript-eslint/types": "4.21.0", "@typescript-eslint/visitor-keys": "4.21.0", "debug": "^4.1.1", "globby": "^11.0.1", "is-glob": "^4.0.1", "semver": "^7.3.2", "tsutils": "^3.17.1" } }, "@typescript-eslint/visitor-keys": { "version": "4.21.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.21.0.tgz", "integrity": "sha512-dH22dROWGi5Z6p+Igc8bLVLmwy7vEe8r+8c+raPQU0LxgogPUrRAtRGtvBWmlr9waTu3n+QLt/qrS/hWzk1x5w==", "dev": true, "requires": { "@typescript-eslint/types": "4.21.0", "eslint-visitor-keys": "^2.0.0" } }, "@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", "dev": true }, "abab": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz", "integrity": "sha512-9IK9EadsbHo6jLWIpxpR6pL0sazTXV6+SQv25ZB+F7Bj9mJNaOc4nCRabwd5M/JwmUa8idz6Eci6eKfJryPs6Q==", "dev": true }, "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", "dev": true }, "acorn-globals": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz", "integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==", "dev": true, "requires": { "acorn": "^7.1.1", "acorn-walk": "^7.1.1" } }, "acorn-jsx": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.1.tgz", "integrity": "sha512-K0Ptm/47OKfQRpNQ2J/oIN/3QYiK6FwW+eJbILhsdxh2WTLdl+30o8aGdTbm5JbffpFFAg/g+zi1E+jvJha5ng==", "dev": true }, "acorn-walk": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz", "integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==", "dev": true }, "ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", "json-schema-traverse": "^0.4.1", "uri-js": "^4.2.2" } }, "ansi-colors": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", "dev": true }, "ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", "dev": true }, "ansi-styles": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { "color-convert": "^1.9.0" } }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", "dev": true, "requires": { "sprintf-js": "~1.0.2" } }, "array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", "dev": true }, "asn1": { "version": "0.2.4", "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", "dev": true, "requires": { "safer-buffer": "~2.1.0" } }, "assert-plus": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", "dev": true }, "astral-regex": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/astral-regex/-/astral-regex-2.0.0.tgz", "integrity": "sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==", "dev": true }, "async-cache": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/async-cache/-/async-cache-1.1.0.tgz", "integrity": "sha1-SppaidBl7F2OUlS9nulrp2xTK1o=", "dev": true, "requires": { "lru-cache": "^4.0.0" }, "dependencies": { "lru-cache": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, "requires": { "pseudomap": "^1.0.2", "yallist": "^2.1.2" } }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", "dev": true } } }, "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", "dev": true }, "aws-sign2": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", "dev": true }, "aws4": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, "base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", "dev": true }, "bcrypt-pbkdf": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", "dev": true, "requires": { "tweetnacl": "^0.14.3" } }, "bl": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", "dev": true, "requires": { "buffer": "^5.5.0", "inherits": "^2.0.4", "readable-stream": "^3.4.0" } }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" } }, "braces": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", "dev": true, "requires": { "fill-range": "^7.0.1" } }, "browser-process-hrtime": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==", "dev": true }, "buffer": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "dev": true, "requires": { "base64-js": "^1.3.1", "ieee754": "^1.1.13" } }, "buffer-from": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, "call-bind": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" } }, "callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, "caseless": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, "chalk": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", "dev": true, "requires": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" }, "dependencies": { "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { "color-convert": "^2.0.1" } }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { "has-flag": "^4.0.0" } } } }, "cliui": { "version": "7.0.4", "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", "dev": true, "requires": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", "wrap-ansi": "^7.0.0" } }, "code-block-writer": { "version": "10.1.1", "resolved": "https://registry.npmjs.org/code-block-writer/-/code-block-writer-10.1.1.tgz", "integrity": "sha512-67ueh2IRGst/51p0n6FvPrnRjAGHY5F8xdjkgrYE7DDzpJe6qA07RYQ9VcoUeo5ATOjSOiWpSL3SWBRRbempMw==", "dev": true }, "color-convert": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, "requires": { "color-name": "1.1.3" } }, "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "dev": true }, "colors": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/colors/-/colors-1.2.5.tgz", "integrity": "sha512-erNRLao/Y3Fv54qUa0LBB+//Uf3YwMUmdJinN20yMXm9zdKKqH9wt7R9IIVZ+K7ShzfpLV/Zg8+VyrBJYB4lpg==", "dev": true }, "combined-stream": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", "dev": true, "requires": { "delayed-stream": "~1.0.0" } }, "commander": { "version": "2.20.3", "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", "dev": true }, "core-util-is": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, "cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, "requires": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "cssom": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.4.4.tgz", "integrity": "sha512-p3pvU7r1MyyqbTk+WbNJIgJjG2VmTIaB10rI93LzVPrmDJKkzKYMtxxyAvQXR/NS6otuzveI7+7BBq3SjBS2mw==", "dev": true }, "cssstyle": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/cssstyle/-/cssstyle-2.3.0.tgz", "integrity": "sha512-AZL67abkUzIuvcHqk7c09cezpGNcxUxU4Ioi/05xHk4DQeTkWmGYftIE6ctU6AEt+Gn4n1lDStOtj7FKycP71A==", "dev": true, "requires": { "cssom": "~0.3.6" }, "dependencies": { "cssom": { "version": "0.3.8", "resolved": "https://registry.npmjs.org/cssom/-/cssom-0.3.8.tgz", "integrity": "sha512-b0tGHbfegbhPJpxpiBPU2sCkigAqtM9O121le6bbOlgyV+NyGyCmVfJ6QW9eRjz8CpNfWEOYBIMIGRYkLwsIYg==", "dev": true } } }, "dashdash": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", "dev": true, "requires": { "assert-plus": "^1.0.0" } }, "data-urls": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-2.0.0.tgz", "integrity": "sha512-X5eWTSXO/BJmpdIKCRuKUgSCgAN0OwliVK3yPKbwIWU1Tdw5BRajxlzMidvh+gwko9AfQ9zIj52pzF91Q3YAvQ==", "dev": true, "requires": { "abab": "^2.0.3", "whatwg-mimetype": "^2.3.0", "whatwg-url": "^8.0.0" } }, "debug": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { "ms": "2.1.2" } }, "decimal.js": { "version": "10.2.1", "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.2.1.tgz", "integrity": "sha512-KaL7+6Fw6i5A2XSnsbhm/6B+NuEA7TZ4vqxnd5tXz9sbKtrN9Srj8ab4vKVdK8YAqZO9P1kg45Y6YLoduPf+kw==", "dev": true }, "deep-is": { "version": "0.1.3", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", "dev": true }, "dir-glob": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", "dev": true, "requires": { "path-type": "^4.0.0" } }, "doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", "integrity": "sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==", "dev": true, "requires": { "esutils": "^2.0.2" } }, "domexception": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/domexception/-/domexception-2.0.1.tgz", "integrity": "sha512-yxJ2mFy/sibVQlu5qHjOkf9J3K6zgmCxgJ94u2EdvDOV09H+32LtRswEcUsmUWN72pVLOEnTSRaIVVzVQgS0dg==", "dev": true, "requires": { "webidl-conversions": "^5.0.0" }, "dependencies": { "webidl-conversions": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-5.0.0.tgz", "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==", "dev": true } } }, "ecc-jsbn": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", "dev": true, "requires": { "jsbn": "~0.1.0", "safer-buffer": "^2.1.0" } }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, "enquirer": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", "dev": true, "requires": { "ansi-colors": "^4.1.1" } }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", "dev": true }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, "escodegen": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.0.0.tgz", "integrity": "sha512-mmHKys/C8BFUGI+MAWNcSYoORYLMdPzjrknd2Vc+bUsjN5bXcr8EhrNB+UTqfL1y3I9c4fw2ihgtMPQLBRiQxw==", "dev": true, "requires": { "esprima": "^4.0.1", "estraverse": "^5.2.0", "esutils": "^2.0.2", "optionator": "^0.8.1", "source-map": "~0.6.1" }, "dependencies": { "estraverse": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", "dev": true }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", "dev": true, "requires": { "prelude-ls": "~1.1.2", "type-check": "~0.3.2" } }, "optionator": { "version": "0.8.3", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.3.tgz", "integrity": "sha512-+IW9pACdk3XWmmTXG8m3upGUJst5XRGzxMRjXzAuJ1XnIFNvfhjjIuYkDvysnPQ7qzqVzLt78BCruntqRhWQbA==", "dev": true, "requires": { "deep-is": "~0.1.3", "fast-levenshtein": "~2.0.6", "levn": "~0.3.0", "prelude-ls": "~1.1.2", "type-check": "~0.3.2", "word-wrap": "~1.2.3" } }, "prelude-ls": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz", "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, "type-check": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.3.2.tgz", "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=", "dev": true, "requires": { "prelude-ls": "~1.1.2" } } } }, "eslint": { "version": "7.23.0", "resolved": "https://registry.npmjs.org/eslint/-/eslint-7.23.0.tgz", "integrity": "sha512-kqvNVbdkjzpFy0XOszNwjkKzZ+6TcwCQ/h+ozlcIWwaimBBuhlQ4nN6kbiM2L+OjDcznkTJxzYfRFH92sx4a0Q==", "dev": true, "requires": { "@babel/code-frame": "7.12.11", "@eslint/eslintrc": "^0.4.0", "ajv": "^6.10.0", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.0.1", "doctrine": "^3.0.0", "enquirer": "^2.3.5", "eslint-scope": "^5.1.1", "eslint-utils": "^2.1.0", "eslint-visitor-keys": "^2.0.0", "espree": "^7.3.1", "esquery": "^1.4.0", "esutils": "^2.0.2", "file-entry-cache": "^6.0.1", "functional-red-black-tree": "^1.0.1", "glob-parent": "^5.0.0", "globals": "^13.6.0", "ignore": "^4.0.6", "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "js-yaml": "^3.13.1", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash": "^4.17.21", "minimatch": "^3.0.4", "natural-compare": "^1.4.0", "optionator": "^0.9.1", "progress": "^2.0.0", "regexpp": "^3.1.0", "semver": "^7.2.1", "strip-ansi": "^6.0.0", "strip-json-comments": "^3.1.0", "table": "^6.0.4", "text-table": "^0.2.0", "v8-compile-cache": "^2.0.3" }, "dependencies": { "@babel/code-frame": { "version": "7.12.11", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz", "integrity": "sha512-Zt1yodBx1UcyiePMSkWnU4hPqhwq7hGi2nFL1LeA3EUl+q2LQx16MISgJ0+z7dnmgvP9QtIleuETGOiOH1RcIw==", "dev": true, "requires": { "@babel/highlight": "^7.10.4" } }, "ignore": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", "dev": true } } }, "eslint-scope": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", "dev": true, "requires": { "esrecurse": "^4.3.0", "estraverse": "^4.1.1" } }, "eslint-utils": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.1.0.tgz", "integrity": "sha512-w94dQYoauyvlDc43XnGB8lU3Zt713vNChgt4EWwhXAP2XkBvndfxF0AgIqKOOasjPIPzj9JqgwkwbCYD0/V3Zg==", "dev": true, "requires": { "eslint-visitor-keys": "^1.1.0" }, "dependencies": { "eslint-visitor-keys": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true } } }, "eslint-visitor-keys": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz", "integrity": "sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ==", "dev": true }, "espree": { "version": "7.3.1", "resolved": "https://registry.npmjs.org/espree/-/espree-7.3.1.tgz", "integrity": "sha512-v3JCNCE64umkFpmkFGqzVKsOT0tN1Zr+ueqLZfpV1Ob8e+CEgPWa+OxCoGH3tnhimMKIaBm4m/vaRpJ/krRz2g==", "dev": true, "requires": { "acorn": "^7.4.0", "acorn-jsx": "^5.3.1", "eslint-visitor-keys": "^1.3.0" }, "dependencies": { "eslint-visitor-keys": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz", "integrity": "sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==", "dev": true } } }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, "esquery": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.4.0.tgz", "integrity": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", "dev": true, "requires": { "estraverse": "^5.1.0" }, "dependencies": { "estraverse": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", "dev": true } } }, "esrecurse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", "dev": true, "requires": { "estraverse": "^5.2.0" }, "dependencies": { "estraverse": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.2.0.tgz", "integrity": "sha512-BxbNGGNm0RyRYvUdHpIwv9IWzeM9XClbOxwoATuFdOE7ZE6wHL+HQ5T8hoPM+zHvmKzzsEqhgy0GrQ5X13afiQ==", "dev": true } } }, "estraverse": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", "dev": true }, "estree-walker": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", "dev": true }, "esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", "dev": true }, "extsprintf": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", "dev": true }, "fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, "fast-glob": { "version": "3.2.5", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz", "integrity": "sha512-2DtFcgT68wiTTiwZ2hNdJfcHNke9XOfnwmBRWXhmeKM8rF0TGwmC/Qto3S7RoZKp5cilZbxzO5iTNTQsJ+EeDg==", "dev": true, "requires": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.0", "merge2": "^1.3.0", "micromatch": "^4.0.2", "picomatch": "^2.2.1" }, "dependencies": { "picomatch": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "dev": true } } }, "fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", "dev": true }, "fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", "dev": true }, "fastq": { "version": "1.11.0", "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.11.0.tgz", "integrity": "sha512-7Eczs8gIPDrVzT+EksYBcupqMyxSHXXrHOLRRxU2/DicV8789MRBRR8+Hc2uWzUupOs4YS4JzBmBxjjCVBxD/g==", "dev": true, "requires": { "reusify": "^1.0.4" } }, "fd": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/fd/-/fd-0.0.3.tgz", "integrity": "sha512-iAHrIslQb3U68OcMSP0kkNWabp7sSN6d2TBSb2JO3gcLJVDd4owr/hKM4SFJovFOUeeXeItjYgouEDTMWiVAnA==", "dev": true }, "file-entry-cache": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-6.0.1.tgz", "integrity": "sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==", "dev": true, "requires": { "flat-cache": "^3.0.4" } }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", "dev": true, "requires": { "to-regex-range": "^5.0.1" } }, "flat-cache": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-3.0.4.tgz", "integrity": "sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==", "dev": true, "requires": { "flatted": "^3.1.0", "rimraf": "^3.0.2" } }, "flatted": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.1.1.tgz", "integrity": "sha512-zAoAQiudy+r5SvnSw3KJy5os/oRJYHzrzja/tBDqrZtNhUw8bt6y8OBzMWcjWr+8liV8Eb6yOhw8WZ7VFZ5ZzA==", "dev": true }, "forever-agent": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", "dev": true }, "form-data": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", "dev": true, "requires": { "asynckit": "^0.4.0", "combined-stream": "^1.0.6", "mime-types": "^2.1.12" } }, "fs-extra": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", "dev": true, "requires": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", "universalify": "^0.1.0" } }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", "dev": true }, "fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, "optional": true }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", "dev": true }, "functional-red-black-tree": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", "integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=", "dev": true }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, "get-intrinsic": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", "has-symbols": "^1.0.1" } }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", "dev": true, "requires": { "assert-plus": "^1.0.0" } }, "glob": { "version": "7.1.6", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", "dev": true, "requires": { "is-glob": "^4.0.1" } }, "globals": { "version": "13.7.0", "resolved": "https://registry.npmjs.org/globals/-/globals-13.7.0.tgz", "integrity": "sha512-Aipsz6ZKRxa/xQkZhNg0qIWXT6x6rD46f6x/PCnBomlttdIyAPak4YD9jTmKpZ72uROSMU87qJtcgpgHaVchiA==", "dev": true, "requires": { "type-fest": "^0.20.2" }, "dependencies": { "type-fest": { "version": "0.20.2", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.20.2.tgz", "integrity": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", "dev": true } } }, "globby": { "version": "11.0.3", "resolved": "https://registry.npmjs.org/globby/-/globby-11.0.3.tgz", "integrity": "sha512-ffdmosjA807y7+lA1NM0jELARVmYul/715xiILEjo3hBLPTcirgQNnXECn5g3mtR8TOLCVbkfua1Hpen25/Xcg==", "dev": true, "requires": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", "fast-glob": "^3.1.1", "ignore": "^5.1.4", "merge2": "^1.3.0", "slash": "^3.0.0" } }, "graceful-fs": { "version": "4.2.6", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.6.tgz", "integrity": "sha512-nTnJ528pbqxYanhpDYsi4Rd8MAeaBA67+RZ10CM1m3bTAVFEDcd5AuA4a6W5YkGZ1iNXHzZz8T6TBKLeBuNriQ==", "dev": true }, "har-schema": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", "dev": true }, "har-validator": { "version": "5.1.5", "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", "dev": true, "requires": { "ajv": "^6.12.3", "har-schema": "^2.0.0" } }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", "dev": true, "requires": { "function-bind": "^1.1.1" } }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, "has-symbols": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", "dev": true }, "html-encoding-sniffer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", "integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==", "dev": true, "requires": { "whatwg-encoding": "^1.0.5" } }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", "dev": true, "requires": { "assert-plus": "^1.0.0", "jsprim": "^1.2.2", "sshpk": "^1.7.0" } }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } }, "ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "dev": true }, "ignore": { "version": "5.1.8", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.1.8.tgz", "integrity": "sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw==", "dev": true }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", "dev": true, "requires": { "parent-module": "^1.0.0", "resolve-from": "^4.0.0" } }, "import-lazy": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/import-lazy/-/import-lazy-4.0.0.tgz", "integrity": "sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw==", "dev": true }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" } }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "dev": true }, "is-boolean-object": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.0.tgz", "integrity": "sha512-a7Uprx8UtD+HWdyYwnD1+ExtTgqQtD2k/1yJgtXP6wnMm8byhkoTZRl+95LLThpzNZJ5aEvi46cdH+ayMFRwmA==", "dev": true, "requires": { "call-bind": "^1.0.0" } }, "is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", "dev": true }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true }, "is-glob": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", "dev": true, "requires": { "is-extglob": "^2.1.1" } }, "is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true }, "is-number-object": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.4.tgz", "integrity": "sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw==", "dev": true }, "is-potential-custom-element-name": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz", "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==", "dev": true }, "is-string": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", "dev": true }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, "isstream": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", "dev": true }, "jasmine": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.7.0.tgz", "integrity": "sha512-wlzGQ+cIFzMEsI+wDqmOwvnjTvolLFwlcpYLCqSPPH0prOQaW3P+IzMhHYn934l1imNvw07oCyX+vGUv3wmtSQ==", "dev": true, "requires": { "glob": "^7.1.6", "jasmine-core": "~3.7.0" } }, "jasmine-core": { "version": "3.7.1", "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.7.1.tgz", "integrity": "sha512-DH3oYDS/AUvvr22+xUBW62m1Xoy7tUlY1tsxKEJvl5JeJ7q8zd1K5bUwiOxdH+erj6l2vAMM3hV25Xs9/WrmuQ==", "dev": true }, "jest-worker": { "version": "26.6.2", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-26.6.2.tgz", "integrity": "sha512-KWYVV1c4i+jbMpaBC+U++4Va0cp8OisU185o73T1vo99hqi7w8tSJfUXYswwqqrjzwxa6KpRK54WhPvwf5w6PQ==", "dev": true, "requires": { "@types/node": "*", "merge-stream": "^2.0.0", "supports-color": "^7.0.0" }, "dependencies": { "has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", "dev": true }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", "dev": true, "requires": { "has-flag": "^4.0.0" } } } }, "jju": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/jju/-/jju-1.4.0.tgz", "integrity": "sha1-o6vicYryQaKykE+EpiWXDzia4yo=", "dev": true }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", "dev": true }, "js-yaml": { "version": "3.14.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" } }, "jsbn": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "dev": true }, "jsdom": { "version": "16.5.2", "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.5.2.tgz", "integrity": "sha512-JxNtPt9C1ut85boCbJmffaQ06NBnzkQY/MWO3YxPW8IWS38A26z+B1oBvA9LwKrytewdfymnhi4UNH3/RAgZrg==", "dev": true, "requires": { "abab": "^2.0.5", "acorn": "^8.1.0", "acorn-globals": "^6.0.0", "cssom": "^0.4.4", "cssstyle": "^2.3.0", "data-urls": "^2.0.0", "decimal.js": "^10.2.1", "domexception": "^2.0.1", "escodegen": "^2.0.0", "html-encoding-sniffer": "^2.0.1", "is-potential-custom-element-name": "^1.0.0", "nwsapi": "^2.2.0", "parse5": "6.0.1", "request": "^2.88.2", "request-promise-native": "^1.0.9", "saxes": "^5.0.1", "symbol-tree": "^3.2.4", "tough-cookie": "^4.0.0", "w3c-hr-time": "^1.0.2", "w3c-xmlserializer": "^2.0.0", "webidl-conversions": "^6.1.0", "whatwg-encoding": "^1.0.5", "whatwg-mimetype": "^2.3.0", "whatwg-url": "^8.5.0", "ws": "^7.4.4", "xml-name-validator": "^3.0.0" }, "dependencies": { "acorn": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.1.0.tgz", "integrity": "sha512-LWCF/Wn0nfHOmJ9rzQApGnxnvgfROzGilS8936rqN/lfcYkY9MYZzdMqN+2NJ4SlTc+m5HiSa+kNfDtI64dwUA==", "dev": true } } }, "json-schema": { "version": "0.2.3", "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", "dev": true }, "json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", "dev": true }, "json-stable-stringify-without-jsonify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, "json-stringify-safe": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "dev": true, "requires": { "graceful-fs": "^4.1.6" } }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", "dev": true, "requires": { "assert-plus": "1.0.0", "extsprintf": "1.3.0", "json-schema": "0.2.3", "verror": "1.10.0" } }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", "dev": true, "requires": { "prelude-ls": "^1.2.1", "type-check": "~0.4.0" } }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "lodash.clonedeep": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=", "dev": true }, "lodash.flatten": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=", "dev": true }, "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, "lodash.isequal": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", "integrity": "sha1-QVxEePK8wwEgwizhDtMib30+GOA=", "dev": true }, "lodash.truncate": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.truncate/-/lodash.truncate-4.4.2.tgz", "integrity": "sha1-WjUNoLERO4N+z//VgSy+WNbq4ZM=", "dev": true }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", "dev": true, "requires": { "yallist": "^4.0.0" } }, "magic-string": { "version": "0.25.7", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", "dev": true, "requires": { "sourcemap-codec": "^1.4.4" } }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, "merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true }, "micromatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.2.tgz", "integrity": "sha512-y7FpHSbMUMoyPbYUSzO6PaZ6FyRnQOpHuKwbo1G+Knck95XVU4QAiKdGEnj5wwoS7PlOgthX/09u5iFJ+aYf5Q==", "dev": true, "requires": { "braces": "^3.0.1", "picomatch": "^2.0.5" } }, "mime": { "version": "2.5.2", "resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz", "integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg==", "dev": true }, "mime-db": { "version": "1.47.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.47.0.tgz", "integrity": "sha512-QBmA/G2y+IfeS4oktet3qRZ+P5kPhCKRXxXnQEudYqUaEioAU1/Lq2us3D/t1Jfo4hE9REQPrbB7K5sOczJVIw==", "dev": true }, "mime-types": { "version": "2.1.30", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.30.tgz", "integrity": "sha512-crmjA4bLtR8m9qLpHvgxSChT+XoSlZi8J4n/aIdn3z92e/U47Z0V/yl+Wh9W046GgFVAmoNR/fmdbZYcSSIUeg==", "dev": true, "requires": { "mime-db": "1.47.0" } }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { "brace-expansion": "^1.1.7" } }, "mkdirp": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", "dev": true }, "ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=", "dev": true }, "negotiator": { "version": "0.6.2", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", "dev": true }, "nwsapi": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.2.0.tgz", "integrity": "sha512-h2AatdwYH+JHiZpv7pt/gSX1XoRGb7L/qSIeuqA6GwYoF9w1vP1cw42TO0aI2pNyshRK5893hNSl+1//vHK7hQ==", "dev": true }, "oauth-sign": { "version": "0.9.0", "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", "dev": true }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { "wrappy": "1" } }, "optionator": { "version": "0.9.1", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", "dev": true, "requires": { "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", "type-check": "^0.4.0", "word-wrap": "^1.2.3" } }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", "dev": true, "requires": { "callsites": "^3.0.0" } }, "parse5": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz", "integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw==", "dev": true }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, "path-key": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", "dev": true }, "path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "path-type": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", "dev": true }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "dev": true }, "picomatch": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.0.7.tgz", "integrity": "sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA==", "dev": true }, "prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", "dev": true }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", "dev": true }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, "psl": { "version": "1.8.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.8.0.tgz", "integrity": "sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==", "dev": true }, "punycode": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", "dev": true }, "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, "queue-microtask": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", "dev": true }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, "requires": { "safe-buffer": "^5.1.0" } }, "readable-stream": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", "util-deprecate": "^1.0.1" } }, "recursive-readdir": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz", "integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==", "dev": true, "requires": { "minimatch": "3.0.4" } }, "regexpp": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.1.0.tgz", "integrity": "sha512-ZOIzd8yVsQQA7j8GCSlPGXwg5PfmA1mrq0JP4nGhh54LaKN3xdai/vHUDu74pKwV8OxseMS65u2NImosQcSD0Q==", "dev": true }, "request": { "version": "2.88.2", "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", "dev": true, "requires": { "aws-sign2": "~0.7.0", "aws4": "^1.8.0", "caseless": "~0.12.0", "combined-stream": "~1.0.6", "extend": "~3.0.2", "forever-agent": "~0.6.1", "form-data": "~2.3.2", "har-validator": "~5.1.3", "http-signature": "~1.2.0", "is-typedarray": "~1.0.0", "isstream": "~0.1.2", "json-stringify-safe": "~5.0.1", "mime-types": "~2.1.19", "oauth-sign": "~0.9.0", "performance-now": "^2.1.0", "qs": "~6.5.2", "safe-buffer": "^5.1.2", "tough-cookie": "~2.5.0", "tunnel-agent": "^0.6.0", "uuid": "^3.3.2" }, "dependencies": { "tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "dev": true, "requires": { "psl": "^1.1.28", "punycode": "^2.1.1" } } } }, "request-promise-core": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.4.tgz", "integrity": "sha512-TTbAfBBRdWD7aNNOoVOBH4pN/KigV6LyapYNNlAPA8JwbovRti1E88m3sYAwsLi5ryhPKsE9APwnjFTgdUjTpw==", "dev": true, "requires": { "lodash": "^4.17.19" } }, "request-promise-native": { "version": "1.0.9", "resolved": "https://registry.npmjs.org/request-promise-native/-/request-promise-native-1.0.9.tgz", "integrity": "sha512-wcW+sIUiWnKgNY0dqCpOZkUbF/I+YPi+f09JZIDa39Ec+q82CpSYniDp+ISgTTbKmnpJWASeJBPZmoxH84wt3g==", "dev": true, "requires": { "request-promise-core": "1.1.4", "stealthy-require": "^1.1.1", "tough-cookie": "^2.3.3" }, "dependencies": { "tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", "dev": true, "requires": { "psl": "^1.1.28", "punycode": "^2.1.1" } } } }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==", "dev": true }, "resolve": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", "dev": true, "requires": { "path-parse": "^1.0.6" } }, "resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", "dev": true }, "reusify": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", "dev": true }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "requires": { "glob": "^7.1.3" } }, "rollup": { "version": "2.44.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.44.0.tgz", "integrity": "sha512-rGSF4pLwvuaH/x4nAS+zP6UNn5YUDWf/TeEU5IoXSZKBbKRNTCI3qMnYXKZgrC0D2KzS2baiOZt1OlqhMu5rnQ==", "dev": true, "requires": { "fsevents": "~2.3.1" } }, "rollup-plugin-terser": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", "integrity": "sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==", "dev": true, "requires": { "@babel/code-frame": "^7.10.4", "jest-worker": "^26.2.1", "serialize-javascript": "^4.0.0", "terser": "^5.0.0" } }, "run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", "dev": true, "requires": { "queue-microtask": "^1.2.2" } }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", "dev": true }, "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", "dev": true }, "saxes": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.1.tgz", "integrity": "sha512-5LBh1Tls8c9xgGjw3QrMwETmTMVk0oFgvrFSvWx62llR2hcEInrKNZ2GZCCuuy2lvWrdl5jhbpeqc5hRYKFOcw==", "dev": true, "requires": { "xmlchars": "^2.2.0" } }, "semver": { "version": "7.3.5", "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", "dev": true, "requires": { "lru-cache": "^6.0.0" } }, "serialize-javascript": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-4.0.0.tgz", "integrity": "sha512-GaNA54380uFefWghODBWEGisLZFj00nS5ACs6yHa9nLqlLpVLO8ChDGeKRjZnV4Nh4n0Qi7nhYZD/9fCPzEqkw==", "dev": true, "requires": { "randombytes": "^2.1.0" } }, "shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "requires": { "shebang-regex": "^3.0.0" } }, "shebang-regex": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", "dev": true }, "slice-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-4.0.0.tgz", "integrity": "sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==", "dev": true, "requires": { "ansi-styles": "^4.0.0", "astral-regex": "^2.0.0", "is-fullwidth-code-point": "^3.0.0" }, "dependencies": { "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { "color-convert": "^2.0.1" } }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true } } }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, "source-map-support": { "version": "0.5.19", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.19.tgz", "integrity": "sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw==", "dev": true, "requires": { "buffer-from": "^1.0.0", "source-map": "^0.6.0" } }, "sourcemap-codec": { "version": "1.4.8", "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", "dev": true }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, "sshpk": { "version": "1.16.1", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.1.tgz", "integrity": "sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==", "dev": true, "requires": { "asn1": "~0.2.3", "assert-plus": "^1.0.0", "bcrypt-pbkdf": "^1.0.0", "dashdash": "^1.12.0", "ecc-jsbn": "~0.1.1", "getpass": "^0.1.1", "jsbn": "~0.1.0", "safer-buffer": "^2.0.2", "tweetnacl": "~0.14.0" } }, "st": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/st/-/st-2.0.0.tgz", "integrity": "sha512-drN+aGYnrZPNYIymmNwIY7LXYJ8MqsqXj4fMRue3FOgGMdGjSX10fhJ3qx0sVQPhcWxhEaN4U/eWM4O4dbYNAw==", "dev": true, "requires": { "async-cache": "^1.1.0", "bl": "^4.0.0", "fd": "~0.0.2", "graceful-fs": "^4.2.3", "mime": "^2.4.4", "negotiator": "~0.6.2" } }, "stealthy-require": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/stealthy-require/-/stealthy-require-1.1.1.tgz", "integrity": "sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=", "dev": true }, "string-argv": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/string-argv/-/string-argv-0.3.1.tgz", "integrity": "sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg==", "dev": true }, "string-width": { "version": "4.2.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", "dev": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", "strip-ansi": "^6.0.0" } }, "string_decoder": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", "dev": true, "requires": { "safe-buffer": "~5.2.0" } }, "strip-ansi": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", "dev": true, "requires": { "ansi-regex": "^5.0.0" } }, "strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", "dev": true, "requires": { "has-flag": "^3.0.0" } }, "symbol-tree": { "version": "3.2.4", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz", "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, "table": { "version": "6.0.9", "resolved": "https://registry.npmjs.org/table/-/table-6.0.9.tgz", "integrity": "sha512-F3cLs9a3hL1Z7N4+EkSscsel3z55XT950AvB05bwayrNg5T1/gykXtigioTAjbltvbMSJvvhFCbnf6mX+ntnJQ==", "dev": true, "requires": { "ajv": "^8.0.1", "is-boolean-object": "^1.1.0", "is-number-object": "^1.0.4", "is-string": "^1.0.5", "lodash.clonedeep": "^4.5.0", "lodash.flatten": "^4.4.0", "lodash.truncate": "^4.4.2", "slice-ansi": "^4.0.0", "string-width": "^4.2.0" }, "dependencies": { "ajv": { "version": "8.0.5", "resolved": "https://registry.npmjs.org/ajv/-/ajv-8.0.5.tgz", "integrity": "sha512-RkiLa/AeJx7+9OvniQ/qeWu0w74A8DiPPBclQ6ji3ZQkv5KamO+QGpqmi7O4JIw3rHGUXZ6CoP9tsAkn3gyazg==", "dev": true, "requires": { "fast-deep-equal": "^3.1.1", "json-schema-traverse": "^1.0.0", "require-from-string": "^2.0.2", "uri-js": "^4.2.2" } }, "json-schema-traverse": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz", "integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==", "dev": true } } }, "terser": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/terser/-/terser-5.6.0.tgz", "integrity": "sha512-vyqLMoqadC1uR0vywqOZzriDYzgEkNJFK4q9GeyOBHIbiECHiWLKcWfbQWAUaPfxkjDhapSlZB9f7fkMrvkVjA==", "dev": true, "requires": { "commander": "^2.20.0", "source-map": "~0.7.2", "source-map-support": "~0.5.19" }, "dependencies": { "source-map": { "version": "0.7.3", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", "dev": true } } }, "text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "integrity": "sha1-f17oI66AUgfACvLfSoTsP8+lcLQ=", "dev": true }, "timsort": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=", "dev": true }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, "requires": { "is-number": "^7.0.0" } }, "tough-cookie": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz", "integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==", "dev": true, "requires": { "psl": "^1.1.33", "punycode": "^2.1.1", "universalify": "^0.1.2" } }, "tr46": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.2.tgz", "integrity": "sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg==", "dev": true, "requires": { "punycode": "^2.1.1" } }, "ts-morph": { "version": "10.0.2", "resolved": "https://registry.npmjs.org/ts-morph/-/ts-morph-10.0.2.tgz", "integrity": "sha512-TVuIfEqtr9dW25K3Jajqpqx7t/zLRFxKu2rXQZSDjTm4MO4lfmuj1hn8WEryjeDDBFcNOCi+yOmYUYR4HucrAg==", "dev": true, "requires": { "@ts-morph/common": "~0.9.0", "code-block-writer": "^10.1.1" } }, "tslib": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.2.0.tgz", "integrity": "sha512-gS9GVHRU+RGn5KQM2rllAlR3dU6m7AcpJKdtH8gFvQiC4Otgk98XnmMU+nZenHt/+VhnBPWwgrJsyrdcw6i23w==", "dev": true }, "tsutils": { "version": "3.21.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz", "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==", "dev": true, "requires": { "tslib": "^1.8.1" }, "dependencies": { "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true } } }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", "dev": true, "requires": { "safe-buffer": "^5.0.1" } }, "tweetnacl": { "version": "0.14.5", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", "dev": true }, "type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", "dev": true, "requires": { "prelude-ls": "^1.2.1" } }, "type-fest": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", "dev": true }, "typescript": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.2.4.tgz", "integrity": "sha512-V+evlYHZnQkaz8TRBuxTA92yZBPotr5H+WhQ7bD3hZUndx5tGOa1fuCgeSjxAzM1RiN5IzvadIXTVefuuwZCRg==", "dev": true }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "dev": true }, "uri-js": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", "dev": true, "requires": { "punycode": "^2.1.0" } }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true }, "v8-compile-cache": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz", "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, "validator": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/validator/-/validator-8.2.0.tgz", "integrity": "sha512-Yw5wW34fSv5spzTXNkokD6S6/Oq92d8q/t14TqsS3fAiA1RYnxSFSIZ+CY3n6PGGRCq5HhJTSepQvFUS2QUDxA==", "dev": true }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", "dev": true, "requires": { "assert-plus": "^1.0.0", "core-util-is": "1.0.2", "extsprintf": "^1.2.0" } }, "w3c-hr-time": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", "dev": true, "requires": { "browser-process-hrtime": "^1.0.0" } }, "w3c-xmlserializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-2.0.0.tgz", "integrity": "sha512-4tzD0mF8iSiMiNs30BiLO3EpfGLZUT2MSX/G+o7ZywDzliWQ3OPtTZ0PTC3B3ca1UAf4cJMHB+2Bf56EriJuRA==", "dev": true, "requires": { "xml-name-validator": "^3.0.0" } }, "webidl-conversions": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-6.1.0.tgz", "integrity": "sha512-qBIvFLGiBpLjfwmYAaHPXsn+ho5xZnGvyGvsarywGNc8VyQJUMHJ8OBKGGrPER0okBeMDaan4mNBlgBROxuI8w==", "dev": true }, "whatwg-encoding": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", "integrity": "sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==", "dev": true, "requires": { "iconv-lite": "0.4.24" } }, "whatwg-mimetype": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz", "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", "dev": true }, "whatwg-url": { "version": "8.5.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-8.5.0.tgz", "integrity": "sha512-fy+R77xWv0AiqfLl4nuGUlQ3/6b5uNfQ4WAbGQVMYshCTCCPK9psC1nWh3XHuxGVCtlcDDQPQW1csmmIQo+fwg==", "dev": true, "requires": { "lodash": "^4.7.0", "tr46": "^2.0.2", "webidl-conversions": "^6.1.0" } }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, "requires": { "isexe": "^2.0.0" } }, "word-wrap": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz", "integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==", "dev": true }, "wpt-runner": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/wpt-runner/-/wpt-runner-3.2.1.tgz", "integrity": "sha512-NE4O88dIfb0wlFQO2y2QL5ZgOh3V8WoMS61fjWPl3pQ4xG3d6olquP2CLliB5kb1Zp0CwPDzm4NfQpkHSNv54Q==", "dev": true, "requires": { "colors": "^1.4.0", "jsdom": "^16.5.1", "recursive-readdir": "^2.2.2", "st": "^2.0.0", "yargs": "^16.2.0" }, "dependencies": { "colors": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz", "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==", "dev": true } } }, "wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, "requires": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, "dependencies": { "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, "requires": { "color-convert": "^2.0.1" } }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, "requires": { "color-name": "~1.1.4" } }, "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true } } }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, "ws": { "version": "7.4.6", "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", "dev": true }, "xml-name-validator": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", "integrity": "sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==", "dev": true }, "xmlchars": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz", "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==", "dev": true }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true }, "yallist": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", "dev": true, "requires": { "cliui": "^7.0.2", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", "string-width": "^4.2.0", "y18n": "^5.0.5", "yargs-parser": "^20.2.2" } }, "yargs-parser": { "version": "20.2.7", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.7.tgz", "integrity": "sha512-FiNkvbeHzB/syOjIUxFDCnhSfzAL8R5vs40MgLFBorXACCOAEaWu0gRZl14vG8MR9AOJIZbmkjhusqBYZ3HTHw==", "dev": true }, "z-schema": { "version": "3.18.4", "resolved": "https://registry.npmjs.org/z-schema/-/z-schema-3.18.4.tgz", "integrity": "sha512-DUOKC/IhbkdLKKiV89gw9DUauTV8U/8yJl1sjf6MtDmzevLKOF2duNJ495S3MFVjqZarr+qNGCPbkg4mu4PpLw==", "dev": true, "requires": { "commander": "^2.7.1", "lodash.get": "^4.0.0", "lodash.isequal": "^4.0.0", "validator": "^8.0.0" } } } } web-streams-polyfill-3.2.1/package.json000066400000000000000000000045711422364423700201020ustar00rootroot00000000000000{ "name": "web-streams-polyfill", "version": "3.2.1", "description": "Web Streams, based on the WHATWG spec reference implementation", "main": "dist/polyfill", "browser": "dist/polyfill.min.js", "module": "dist/polyfill.mjs", "types": "dist/types/polyfill.d.ts", "typesVersions": { ">=3.6": { "dist/types/*": [ "dist/types/ts3.6/*" ] } }, "scripts": { "test": "npm run test:types && npm run test:unit && npm run test:wpt", "test:wpt": "node --expose_gc ./test/run-web-platform-tests.js", "pretest:wpt": "git submodule update --init --recursive", "test:types": "tsc -p ./test/types/tsconfig.json", "test:unit": "jasmine --config=test/unit/jasmine.json", "lint": "eslint \"src/**/*.ts\"", "build": "npm run build:bundle && npm run build:types", "build:bundle": "rollup -c", "build:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run && node ./build/downlevel-dts.js", "accept:types": "tsc --project . --emitDeclarationOnly --declarationDir ./lib && api-extractor run --local && node ./build/downlevel-dts.js", "prepare": "npm run build" }, "files": [ "dist", "es6", "es2018", "ponyfill" ], "engines": { "node": ">= 8" }, "repository": { "type": "git", "url": "git+https://github.com/MattiasBuelens/web-streams-polyfill.git" }, "keywords": [ "streams", "whatwg", "polyfill" ], "author": "Mattias Buelens ", "contributors": [ "Diwank Singh " ], "license": "MIT", "bugs": { "url": "https://github.com/MattiasBuelens/web-streams-polyfill/issues" }, "homepage": "https://github.com/MattiasBuelens/web-streams-polyfill#readme", "devDependencies": { "@microsoft/api-extractor": "^7.13.4", "@rollup/plugin-inject": "^4.0.2", "@rollup/plugin-replace": "^2.4.2", "@rollup/plugin-strip": "^2.0.0", "@rollup/plugin-typescript": "^8.2.1", "@types/node": "^14.14.37", "@typescript-eslint/eslint-plugin": "^4.21.0", "@typescript-eslint/parser": "^4.21.0", "@ungap/promise-all-settled": "^1.1.2", "eslint": "^7.23.0", "jasmine": "^3.7.0", "micromatch": "^4.0.2", "rollup": "^2.44.0", "rollup-plugin-terser": "^7.0.2", "ts-morph": "^10.0.2", "tslib": "^2.2.0", "typescript": "^4.2.4", "wpt-runner": "^3.2.1" } } web-streams-polyfill-3.2.1/ponyfill/000077500000000000000000000000001422364423700174415ustar00rootroot00000000000000web-streams-polyfill-3.2.1/ponyfill/es2018/000077500000000000000000000000001422364423700203635ustar00rootroot00000000000000web-streams-polyfill-3.2.1/ponyfill/es2018/package.json000066400000000000000000000002571422364423700226550ustar00rootroot00000000000000{ "name": "web-streams-ponyfill-es2018", "main": "../../dist/ponyfill.es2018", "module": "../../dist/ponyfill.es2018.mjs", "types": "../../dist/types/polyfill.d.ts" } web-streams-polyfill-3.2.1/ponyfill/es6/000077500000000000000000000000001422364423700201365ustar00rootroot00000000000000web-streams-polyfill-3.2.1/ponyfill/es6/package.json000066400000000000000000000002461422364423700224260ustar00rootroot00000000000000{ "name": "web-streams-ponyfill-es6", "main": "../../dist/ponyfill.es6", "module": "../../dist/ponyfill.es6.mjs", "types": "../../dist/types/polyfill.d.ts" } web-streams-polyfill-3.2.1/ponyfill/package.json000066400000000000000000000002211422364423700217220ustar00rootroot00000000000000{ "name": "web-streams-ponyfill", "main": "../dist/ponyfill", "module": "../dist/ponyfill.mjs", "types": "../dist/types/polyfill.d.ts" } web-streams-polyfill-3.2.1/rollup.config.js000066400000000000000000000056431422364423700207340ustar00rootroot00000000000000const path = require('path'); const typescript = require('@rollup/plugin-typescript'); const inject = require('@rollup/plugin-inject'); const strip = require('@rollup/plugin-strip'); const replace = require('@rollup/plugin-replace'); const { terser } = require('rollup-plugin-terser'); const debug = false; const pkg = require('./package.json'); const banner = ` /** * ${pkg.name} v${pkg.version} */ `.trim(); const keepNames = [ // Class names 'ReadableStream', 'ReadableStreamDefaultController', 'ReadableByteStreamController', 'ReadableStreamBYOBRequest', 'ReadableStreamDefaultReader', 'ReadableStreamBYOBReader', 'WritableStream', 'WritableStreamDefaultWriter', 'WritableStreamDefaultController', 'ByteLengthQueuingStrategy', 'CountQueuingStrategy', 'TransformStream', 'TransformStreamDefaultController', // Queuing strategy "size" getter 'size' ]; const keepRegex = new RegExp(`^(${keepNames.join('|')})$`); function bundle(entry, { esm = false, minify = false, target = 'es5' } = {}) { const outname = `${entry}${target === 'es5' ? '' : `.${target}`}`; return { input: `src/${entry}.ts`, output: [ { file: `dist/${outname}${minify ? '.min' : ''}.js`, format: 'umd', name: 'WebStreamsPolyfill', banner, freeze: false, sourcemap: true }, esm ? { file: `dist/${outname}${minify ? '.min' : ''}.mjs`, format: 'es', banner, freeze: false, sourcemap: true } : undefined ].filter(Boolean), plugins: [ typescript({ tsconfig: `tsconfig${target === 'es5' ? '' : `-${target}`}.json`, declaration: false, declarationMap: false }), inject({ include: 'src/**/*.ts', exclude: 'src/stub/symbol.ts', modules: { Symbol: path.resolve(__dirname, './src/stub/symbol.ts') } }), replace({ include: 'src/**/*.ts', preventAssignment: true, values: { DEBUG: debug } }), !debug ? strip({ include: 'src/**/*.ts', functions: ['assert'], sourceMap: true }) : undefined, minify ? terser({ keep_classnames: keepRegex, // needed for WPT keep_fnames: keepRegex, mangle: { toplevel: true } }) : undefined ].filter(Boolean) }; } module.exports = [ // polyfill bundle('polyfill', { esm: true }), bundle('polyfill', { minify: true }), // polyfill/es6 bundle('polyfill', { target: 'es6', esm: true }), bundle('polyfill', { target: 'es6', minify: true }), // polyfill/es2018 bundle('polyfill', { target: 'es2018', esm: true }), bundle('polyfill', { target: 'es2018', minify: true }), // ponyfill bundle('ponyfill', { esm: true }), // ponyfill/es6 bundle('ponyfill', { target: 'es6', esm: true }), // ponyfill/es2018 bundle('ponyfill', { target: 'es2018', esm: true }) ]; web-streams-polyfill-3.2.1/src/000077500000000000000000000000001422364423700163745ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/global.d.ts000066400000000000000000000000361422364423700204250ustar00rootroot00000000000000declare const DEBUG: boolean; web-streams-polyfill-3.2.1/src/lib/000077500000000000000000000000001422364423700171425ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/lib/abort-signal.ts000066400000000000000000000042201422364423700220720ustar00rootroot00000000000000/** * A signal object that allows you to communicate with a request and abort it if required * via its associated `AbortController` object. * * @remarks * This interface is compatible with the `AbortSignal` interface defined in TypeScript's DOM types. * It is redefined here, so it can be polyfilled without a DOM, for example with * {@link https://www.npmjs.com/package/abortcontroller-polyfill | abortcontroller-polyfill} in a Node environment. * * @public */ export interface AbortSignal { /** * Whether the request is aborted. */ readonly aborted: boolean; /** * Add an event listener to be triggered when this signal becomes aborted. */ addEventListener(type: 'abort', listener: () => void): void; /** * Remove an event listener that was previously added with {@link AbortSignal.addEventListener}. */ removeEventListener(type: 'abort', listener: () => void): void; } export function isAbortSignal(value: unknown): value is AbortSignal { if (typeof value !== 'object' || value === null) { return false; } try { return typeof (value as AbortSignal).aborted === 'boolean'; } catch { // AbortSignal.prototype.aborted throws if its brand check fails return false; } } /** * A controller object that allows you to abort an `AbortSignal` when desired. * * @remarks * This interface is compatible with the `AbortController` interface defined in TypeScript's DOM types. * It is redefined here, so it can be polyfilled without a DOM, for example with * {@link https://www.npmjs.com/package/abortcontroller-polyfill | abortcontroller-polyfill} in a Node environment. * * @internal */ export interface AbortController { readonly signal: AbortSignal; abort(): void; } interface AbortControllerConstructor { new(): AbortController; } const supportsAbortController = typeof (AbortController as any) === 'function'; /** * Construct a new AbortController, if supported by the platform. * * @internal */ export function createAbortController(): AbortController | undefined { if (supportsAbortController) { return new (AbortController as AbortControllerConstructor)(); } return undefined; } web-streams-polyfill-3.2.1/src/lib/abstract-ops/000077500000000000000000000000001422364423700215445ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/lib/abstract-ops/ecmascript.ts000066400000000000000000000027411422364423700242520ustar00rootroot00000000000000export function CreateArrayFromList(elements: T): T { // We use arrays to represent lists, so this is basically a no-op. // Do a slice though just in case we happen to depend on the unique-ness. return elements.slice() as T; } export function CopyDataBlockBytes(dest: ArrayBuffer, destOffset: number, src: ArrayBuffer, srcOffset: number, n: number) { new Uint8Array(dest).set(new Uint8Array(src, srcOffset, n), destOffset); } // Not implemented correctly export function TransferArrayBuffer(O: T): T { return O; } // Not implemented correctly // eslint-disable-next-line @typescript-eslint/no-unused-vars export function CanTransferArrayBuffer(O: ArrayBufferLike): boolean { return true; } // Not implemented correctly // eslint-disable-next-line @typescript-eslint/no-unused-vars export function IsDetachedBuffer(O: ArrayBufferLike): boolean { return false; } export function ArrayBufferSlice(buffer: ArrayBufferLike, begin: number, end: number): ArrayBufferLike { // ArrayBuffer.prototype.slice is not available on IE10 // https://www.caniuse.com/mdn-javascript_builtins_arraybuffer_slice if (buffer.slice) { return buffer.slice(begin, end); } const length = end - begin; const slice = new ArrayBuffer(length); CopyDataBlockBytes(slice, 0, buffer, begin, length); return slice; } web-streams-polyfill-3.2.1/src/lib/abstract-ops/internal-methods.ts000066400000000000000000000003201422364423700253640ustar00rootroot00000000000000export const AbortSteps = Symbol('[[AbortSteps]]'); export const ErrorSteps = Symbol('[[ErrorSteps]]'); export const CancelSteps = Symbol('[[CancelSteps]]'); export const PullSteps = Symbol('[[PullSteps]]'); web-streams-polyfill-3.2.1/src/lib/abstract-ops/miscellaneous.ts000066400000000000000000000007731422364423700247660ustar00rootroot00000000000000import NumberIsNaN from '../../stub/number-isnan'; import { ArrayBufferSlice } from './ecmascript'; export function IsNonNegativeNumber(v: number): boolean { if (typeof v !== 'number') { return false; } if (NumberIsNaN(v)) { return false; } if (v < 0) { return false; } return true; } export function CloneAsUint8Array(O: ArrayBufferView): Uint8Array { const buffer = ArrayBufferSlice(O.buffer, O.byteOffset, O.byteOffset + O.byteLength); return new Uint8Array(buffer); } web-streams-polyfill-3.2.1/src/lib/abstract-ops/queue-with-sizes.ts000066400000000000000000000027731422364423700253550ustar00rootroot00000000000000import assert from '../../stub/assert'; import { SimpleQueue } from '../simple-queue'; import { IsNonNegativeNumber } from './miscellaneous'; export interface QueueContainer { _queue: SimpleQueue; _queueTotalSize: number; } export interface QueuePair { value: T; size: number; } export function DequeueValue(container: QueueContainer>): T { assert('_queue' in container && '_queueTotalSize' in container); assert(container._queue.length > 0); const pair = container._queue.shift()!; container._queueTotalSize -= pair.size; if (container._queueTotalSize < 0) { container._queueTotalSize = 0; } return pair.value; } export function EnqueueValueWithSize(container: QueueContainer>, value: T, size: number) { assert('_queue' in container && '_queueTotalSize' in container); if (!IsNonNegativeNumber(size) || size === Infinity) { throw new RangeError('Size must be a finite, non-NaN, non-negative number.'); } container._queue.push({ value, size }); container._queueTotalSize += size; } export function PeekQueueValue(container: QueueContainer>): T { assert('_queue' in container && '_queueTotalSize' in container); assert(container._queue.length > 0); const pair = container._queue.peek(); return pair.value; } export function ResetQueue(container: QueueContainer) { assert('_queue' in container && '_queueTotalSize' in container); container._queue = new SimpleQueue(); container._queueTotalSize = 0; } web-streams-polyfill-3.2.1/src/lib/abstract-ops/queuing-strategy.ts000066400000000000000000000012311422364423700254260ustar00rootroot00000000000000import { QueuingStrategy, QueuingStrategySizeCallback } from '../queuing-strategy'; import NumberIsNaN from '../../stub/number-isnan'; export function ExtractHighWaterMark(strategy: QueuingStrategy, defaultHWM: number): number { const { highWaterMark } = strategy; if (highWaterMark === undefined) { return defaultHWM; } if (NumberIsNaN(highWaterMark) || highWaterMark < 0) { throw new RangeError('Invalid highWaterMark'); } return highWaterMark; } export function ExtractSizeAlgorithm(strategy: QueuingStrategy): QueuingStrategySizeCallback { const { size } = strategy; if (!size) { return () => 1; } return size; } web-streams-polyfill-3.2.1/src/lib/byte-length-queuing-strategy.ts000066400000000000000000000053161422364423700252540ustar00rootroot00000000000000import { QueuingStrategy, QueuingStrategyInit } from './queuing-strategy'; import { typeIsObject } from './helpers/miscellaneous'; import { assertRequiredArgument } from './validators/basic'; import { convertQueuingStrategyInit } from './validators/queuing-strategy-init'; // The size function must not have a prototype property nor be a constructor const byteLengthSizeFunction = (chunk: ArrayBufferView): number => { return chunk.byteLength; }; try { Object.defineProperty(byteLengthSizeFunction, 'name', { value: 'size', configurable: true }); } catch { // This property is non-configurable in older browsers, so ignore if this throws. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility } /** * A queuing strategy that counts the number of bytes in each chunk. * * @public */ export default class ByteLengthQueuingStrategy implements QueuingStrategy { /** @internal */ readonly _byteLengthQueuingStrategyHighWaterMark: number; constructor(options: QueuingStrategyInit) { assertRequiredArgument(options, 1, 'ByteLengthQueuingStrategy'); options = convertQueuingStrategyInit(options, 'First parameter'); this._byteLengthQueuingStrategyHighWaterMark = options.highWaterMark; } /** * Returns the high water mark provided to the constructor. */ get highWaterMark(): number { if (!IsByteLengthQueuingStrategy(this)) { throw byteLengthBrandCheckException('highWaterMark'); } return this._byteLengthQueuingStrategyHighWaterMark; } /** * Measures the size of `chunk` by returning the value of its `byteLength` property. */ get size(): (chunk: ArrayBufferView) => number { if (!IsByteLengthQueuingStrategy(this)) { throw byteLengthBrandCheckException('size'); } return byteLengthSizeFunction; } } Object.defineProperties(ByteLengthQueuingStrategy.prototype, { highWaterMark: { enumerable: true }, size: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(ByteLengthQueuingStrategy.prototype, Symbol.toStringTag, { value: 'ByteLengthQueuingStrategy', configurable: true }); } // Helper functions for the ByteLengthQueuingStrategy. function byteLengthBrandCheckException(name: string): TypeError { return new TypeError(`ByteLengthQueuingStrategy.prototype.${name} can only be used on a ByteLengthQueuingStrategy`); } export function IsByteLengthQueuingStrategy(x: any): x is ByteLengthQueuingStrategy { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_byteLengthQueuingStrategyHighWaterMark')) { return false; } return x instanceof ByteLengthQueuingStrategy; } web-streams-polyfill-3.2.1/src/lib/count-queuing-strategy.ts000066400000000000000000000051071422364423700241600ustar00rootroot00000000000000import { QueuingStrategy, QueuingStrategyInit } from './queuing-strategy'; import { typeIsObject } from './helpers/miscellaneous'; import { assertRequiredArgument } from './validators/basic'; import { convertQueuingStrategyInit } from './validators/queuing-strategy-init'; // The size function must not have a prototype property nor be a constructor const countSizeFunction = (): 1 => { return 1; }; try { Object.defineProperty(countSizeFunction, 'name', { value: 'size', configurable: true }); } catch { // This property is non-configurable in older browsers, so ignore if this throws. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name#browser_compatibility } /** * A queuing strategy that counts the number of chunks. * * @public */ export default class CountQueuingStrategy implements QueuingStrategy { /** @internal */ readonly _countQueuingStrategyHighWaterMark!: number; constructor(options: QueuingStrategyInit) { assertRequiredArgument(options, 1, 'CountQueuingStrategy'); options = convertQueuingStrategyInit(options, 'First parameter'); this._countQueuingStrategyHighWaterMark = options.highWaterMark; } /** * Returns the high water mark provided to the constructor. */ get highWaterMark(): number { if (!IsCountQueuingStrategy(this)) { throw countBrandCheckException('highWaterMark'); } return this._countQueuingStrategyHighWaterMark; } /** * Measures the size of `chunk` by always returning 1. * This ensures that the total queue size is a count of the number of chunks in the queue. */ get size(): (chunk: any) => 1 { if (!IsCountQueuingStrategy(this)) { throw countBrandCheckException('size'); } return countSizeFunction; } } Object.defineProperties(CountQueuingStrategy.prototype, { highWaterMark: { enumerable: true }, size: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(CountQueuingStrategy.prototype, Symbol.toStringTag, { value: 'CountQueuingStrategy', configurable: true }); } // Helper functions for the CountQueuingStrategy. function countBrandCheckException(name: string): TypeError { return new TypeError(`CountQueuingStrategy.prototype.${name} can only be used on a CountQueuingStrategy`); } export function IsCountQueuingStrategy(x: any): x is CountQueuingStrategy { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_countQueuingStrategyHighWaterMark')) { return false; } return x instanceof CountQueuingStrategy; } web-streams-polyfill-3.2.1/src/lib/helpers/000077500000000000000000000000001422364423700206045ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/lib/helpers/miscellaneous.ts000066400000000000000000000013231422364423700240160ustar00rootroot00000000000000import { noop } from '../../utils'; import { AssertionError } from '../../stub/assert'; export function typeIsObject(x: any): x is object { return (typeof x === 'object' && x !== null) || typeof x === 'function'; } export const rethrowAssertionErrorRejection: (e: any) => void = DEBUG ? e => { // Used throughout the reference implementation, as `.catch(rethrowAssertionErrorRejection)`, to ensure any errors // get shown. There are places in the spec where we do promise transformations and purposefully ignore or don't // expect any errors, but assertion errors are always problematic. if (e && e instanceof AssertionError) { setTimeout(() => { throw e; }, 0); } } : noop; web-streams-polyfill-3.2.1/src/lib/helpers/webidl.ts000066400000000000000000000066541422364423700224350ustar00rootroot00000000000000import { globals } from '../../utils'; import { rethrowAssertionErrorRejection } from './miscellaneous'; import assert from '../../stub/assert'; const originalPromise = Promise; const originalPromiseThen = Promise.prototype.then; const originalPromiseResolve = Promise.resolve.bind(originalPromise); const originalPromiseReject = Promise.reject.bind(originalPromise); export function newPromise(executor: ( resolve: (value: T | PromiseLike) => void, reject: (reason?: any) => void ) => void): Promise { return new originalPromise(executor); } export function promiseResolvedWith(value: T | PromiseLike): Promise { return originalPromiseResolve(value); } export function promiseRejectedWith(reason: any): Promise { return originalPromiseReject(reason); } export function PerformPromiseThen( promise: Promise, onFulfilled?: (value: T) => TResult1 | PromiseLike, onRejected?: (reason: any) => TResult2 | PromiseLike): Promise { // There doesn't appear to be any way to correctly emulate the behaviour from JavaScript, so this is just an // approximation. return originalPromiseThen.call(promise, onFulfilled, onRejected) as Promise; } export function uponPromise( promise: Promise, onFulfilled?: (value: T) => void | PromiseLike, onRejected?: (reason: any) => void | PromiseLike): void { PerformPromiseThen( PerformPromiseThen(promise, onFulfilled, onRejected), undefined, rethrowAssertionErrorRejection ); } export function uponFulfillment(promise: Promise, onFulfilled: (value: T) => void | PromiseLike): void { uponPromise(promise, onFulfilled); } export function uponRejection(promise: Promise, onRejected: (reason: any) => void | PromiseLike): void { uponPromise(promise, undefined, onRejected); } export function transformPromiseWith( promise: Promise, fulfillmentHandler?: (value: T) => TResult1 | PromiseLike, rejectionHandler?: (reason: any) => TResult2 | PromiseLike): Promise { return PerformPromiseThen(promise, fulfillmentHandler, rejectionHandler); } export function setPromiseIsHandledToTrue(promise: Promise): void { PerformPromiseThen(promise, undefined, rethrowAssertionErrorRejection); } export const queueMicrotask: (fn: () => void) => void = (() => { const globalQueueMicrotask = globals && globals.queueMicrotask; if (typeof globalQueueMicrotask === 'function') { return globalQueueMicrotask; } const resolvedPromise = promiseResolvedWith(undefined); return (fn: () => void) => PerformPromiseThen(resolvedPromise, fn); })(); export function reflectCall(F: (this: T, ...fnArgs: A) => R, V: T, args: A): R { if (typeof F !== 'function') { throw new TypeError('Argument is not a function'); } return Function.prototype.apply.call(F, V, args); } export function promiseCall(F: (this: T, ...fnArgs: A) => R | PromiseLike, V: T, args: A): Promise { assert(typeof F === 'function'); assert(V !== undefined); assert(Array.isArray(args)); try { return promiseResolvedWith(reflectCall(F, V, args)); } catch (value) { return promiseRejectedWith(value); } } web-streams-polyfill-3.2.1/src/lib/queuing-strategy.ts000066400000000000000000000011311422364423700230230ustar00rootroot00000000000000export type QueuingStrategySizeCallback = (chunk: T) => number; /** * @public */ export interface QueuingStrategyInit { /** * {@inheritDoc QueuingStrategy.highWaterMark} */ highWaterMark: number; } /** * A queuing strategy. * * @public */ export interface QueuingStrategy { /** * A non-negative number indicating the high water mark of the stream using this queuing strategy. */ highWaterMark?: number; /** * A function that computes and returns the finite non-negative size of the given chunk value. */ size?: QueuingStrategySizeCallback; } web-streams-polyfill-3.2.1/src/lib/readable-stream.ts000066400000000000000000000457431422364423700225570ustar00rootroot00000000000000import assert from '../stub/assert'; import { promiseRejectedWith, promiseResolvedWith, setPromiseIsHandledToTrue, transformPromiseWith } from './helpers/webidl'; import { QueuingStrategy, QueuingStrategySizeCallback } from './queuing-strategy'; import { AcquireReadableStreamAsyncIterator, ReadableStreamAsyncIterator } from './readable-stream/async-iterator'; import { defaultReaderClosedPromiseReject, defaultReaderClosedPromiseResolve } from './readable-stream/generic-reader'; import { AcquireReadableStreamDefaultReader, IsReadableStreamDefaultReader, ReadableStreamDefaultReader, ReadableStreamDefaultReadResult } from './readable-stream/default-reader'; import { AcquireReadableStreamBYOBReader, IsReadableStreamBYOBReader, ReadableStreamBYOBReader, ReadableStreamBYOBReadResult } from './readable-stream/byob-reader'; import { ReadableStreamPipeTo } from './readable-stream/pipe'; import { ReadableStreamTee } from './readable-stream/tee'; import { IsWritableStream, IsWritableStreamLocked, WritableStream } from './writable-stream'; import { SimpleQueue } from './simple-queue'; import { ReadableByteStreamController, ReadableStreamBYOBRequest, SetUpReadableByteStreamController, SetUpReadableByteStreamControllerFromUnderlyingSource } from './readable-stream/byte-stream-controller'; import { ReadableStreamDefaultController, SetUpReadableStreamDefaultController, SetUpReadableStreamDefaultControllerFromUnderlyingSource } from './readable-stream/default-controller'; import { UnderlyingByteSource, UnderlyingByteSourcePullCallback, UnderlyingByteSourceStartCallback, UnderlyingSource, UnderlyingSourceCancelCallback, UnderlyingSourcePullCallback, UnderlyingSourceStartCallback } from './readable-stream/underlying-source'; import { noop } from '../utils'; import { typeIsObject } from './helpers/miscellaneous'; import { CreateArrayFromList } from './abstract-ops/ecmascript'; import { CancelSteps } from './abstract-ops/internal-methods'; import { IsNonNegativeNumber } from './abstract-ops/miscellaneous'; import { assertObject, assertRequiredArgument } from './validators/basic'; import { convertQueuingStrategy } from './validators/queuing-strategy'; import { ExtractHighWaterMark, ExtractSizeAlgorithm } from './abstract-ops/queuing-strategy'; import { convertUnderlyingDefaultOrByteSource } from './validators/underlying-source'; import { ReadableStreamGetReaderOptions } from './readable-stream/reader-options'; import { convertReaderOptions } from './validators/reader-options'; import { StreamPipeOptions, ValidatedStreamPipeOptions } from './readable-stream/pipe-options'; import { ReadableStreamIteratorOptions } from './readable-stream/iterator-options'; import { convertIteratorOptions } from './validators/iterator-options'; import { convertPipeOptions } from './validators/pipe-options'; import { ReadableWritablePair } from './readable-stream/readable-writable-pair'; import { convertReadableWritablePair } from './validators/readable-writable-pair'; export type ReadableByteStream = ReadableStream & { _readableStreamController: ReadableByteStreamController }; type ReadableStreamState = 'readable' | 'closed' | 'errored'; /** * A readable stream represents a source of data, from which you can read. * * @public */ export class ReadableStream { /** @internal */ _state!: ReadableStreamState; /** @internal */ _reader: ReadableStreamReader | undefined; /** @internal */ _storedError: any; /** @internal */ _disturbed!: boolean; /** @internal */ _readableStreamController!: ReadableStreamDefaultController | ReadableByteStreamController; constructor(underlyingSource: UnderlyingByteSource, strategy?: { highWaterMark?: number; size?: undefined }); constructor(underlyingSource?: UnderlyingSource, strategy?: QueuingStrategy); constructor(rawUnderlyingSource: UnderlyingSource | UnderlyingByteSource | null | undefined = {}, rawStrategy: QueuingStrategy | null | undefined = {}) { if (rawUnderlyingSource === undefined) { rawUnderlyingSource = null; } else { assertObject(rawUnderlyingSource, 'First parameter'); } const strategy = convertQueuingStrategy(rawStrategy, 'Second parameter'); const underlyingSource = convertUnderlyingDefaultOrByteSource(rawUnderlyingSource, 'First parameter'); InitializeReadableStream(this); if (underlyingSource.type === 'bytes') { if (strategy.size !== undefined) { throw new RangeError('The strategy for a byte stream cannot have a size function'); } const highWaterMark = ExtractHighWaterMark(strategy, 0); SetUpReadableByteStreamControllerFromUnderlyingSource( this as unknown as ReadableByteStream, underlyingSource, highWaterMark ); } else { assert(underlyingSource.type === undefined); const sizeAlgorithm = ExtractSizeAlgorithm(strategy); const highWaterMark = ExtractHighWaterMark(strategy, 1); SetUpReadableStreamDefaultControllerFromUnderlyingSource( this, underlyingSource, highWaterMark, sizeAlgorithm ); } } /** * Whether or not the readable stream is locked to a {@link ReadableStreamDefaultReader | reader}. */ get locked(): boolean { if (!IsReadableStream(this)) { throw streamBrandCheckException('locked'); } return IsReadableStreamLocked(this); } /** * Cancels the stream, signaling a loss of interest in the stream by a consumer. * * The supplied `reason` argument will be given to the underlying source's {@link UnderlyingSource.cancel | cancel()} * method, which might or might not use it. */ cancel(reason: any = undefined): Promise { if (!IsReadableStream(this)) { return promiseRejectedWith(streamBrandCheckException('cancel')); } if (IsReadableStreamLocked(this)) { return promiseRejectedWith(new TypeError('Cannot cancel a stream that already has a reader')); } return ReadableStreamCancel(this, reason); } /** * Creates a {@link ReadableStreamBYOBReader} and locks the stream to the new reader. * * This call behaves the same way as the no-argument variant, except that it only works on readable byte streams, * i.e. streams which were constructed specifically with the ability to handle "bring your own buffer" reading. * The returned BYOB reader provides the ability to directly read individual chunks from the stream via its * {@link ReadableStreamBYOBReader.read | read()} method, into developer-supplied buffers, allowing more precise * control over allocation. */ getReader({ mode }: { mode: 'byob' }): ReadableStreamBYOBReader; /** * Creates a {@link ReadableStreamDefaultReader} and locks the stream to the new reader. * While the stream is locked, no other reader can be acquired until this one is released. * * This functionality is especially useful for creating abstractions that desire the ability to consume a stream * in its entirety. By getting a reader for the stream, you can ensure nobody else can interleave reads with yours * or cancel the stream, which would interfere with your abstraction. */ getReader(): ReadableStreamDefaultReader; getReader( rawOptions: ReadableStreamGetReaderOptions | null | undefined = undefined ): ReadableStreamDefaultReader | ReadableStreamBYOBReader { if (!IsReadableStream(this)) { throw streamBrandCheckException('getReader'); } const options = convertReaderOptions(rawOptions, 'First parameter'); if (options.mode === undefined) { return AcquireReadableStreamDefaultReader(this); } assert(options.mode === 'byob'); return AcquireReadableStreamBYOBReader(this as unknown as ReadableByteStream); } /** * Provides a convenient, chainable way of piping this readable stream through a transform stream * (or any other `{ writable, readable }` pair). It simply {@link ReadableStream.pipeTo | pipes} the stream * into the writable side of the supplied pair, and returns the readable side for further use. * * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. */ pipeThrough( transform: { readable: RS; writable: WritableStream }, options?: StreamPipeOptions ): RS; pipeThrough( rawTransform: { readable: RS; writable: WritableStream } | null | undefined, rawOptions: StreamPipeOptions | null | undefined = {} ): RS { if (!IsReadableStream(this)) { throw streamBrandCheckException('pipeThrough'); } assertRequiredArgument(rawTransform, 1, 'pipeThrough'); const transform = convertReadableWritablePair(rawTransform, 'First parameter'); const options = convertPipeOptions(rawOptions, 'Second parameter'); if (IsReadableStreamLocked(this)) { throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream'); } if (IsWritableStreamLocked(transform.writable)) { throw new TypeError('ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream'); } const promise = ReadableStreamPipeTo( this, transform.writable, options.preventClose, options.preventAbort, options.preventCancel, options.signal ); setPromiseIsHandledToTrue(promise); return transform.readable; } /** * Pipes this readable stream to a given writable stream. The way in which the piping process behaves under * various error conditions can be customized with a number of passed options. It returns a promise that fulfills * when the piping process completes successfully, or rejects if any errors were encountered. * * Piping a stream will lock it for the duration of the pipe, preventing any other consumer from acquiring a reader. */ pipeTo(destination: WritableStream, options?: StreamPipeOptions): Promise; pipeTo(destination: WritableStream | null | undefined, rawOptions: StreamPipeOptions | null | undefined = {}): Promise { if (!IsReadableStream(this)) { return promiseRejectedWith(streamBrandCheckException('pipeTo')); } if (destination === undefined) { return promiseRejectedWith(`Parameter 1 is required in 'pipeTo'.`); } if (!IsWritableStream(destination)) { return promiseRejectedWith( new TypeError(`ReadableStream.prototype.pipeTo's first argument must be a WritableStream`) ); } let options: ValidatedStreamPipeOptions; try { options = convertPipeOptions(rawOptions, 'Second parameter'); } catch (e) { return promiseRejectedWith(e); } if (IsReadableStreamLocked(this)) { return promiseRejectedWith( new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream') ); } if (IsWritableStreamLocked(destination)) { return promiseRejectedWith( new TypeError('ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream') ); } return ReadableStreamPipeTo( this, destination, options.preventClose, options.preventAbort, options.preventCancel, options.signal ); } /** * Tees this readable stream, returning a two-element array containing the two resulting branches as * new {@link ReadableStream} instances. * * Teeing a stream will lock it, preventing any other consumer from acquiring a reader. * To cancel the stream, cancel both of the resulting branches; a composite cancellation reason will then be * propagated to the stream's underlying source. * * Note that the chunks seen in each branch will be the same object. If the chunks are not immutable, * this could allow interference between the two branches. */ tee(): [ReadableStream, ReadableStream] { if (!IsReadableStream(this)) { throw streamBrandCheckException('tee'); } const branches = ReadableStreamTee(this, false); return CreateArrayFromList(branches); } /** * Asynchronously iterates over the chunks in the stream's internal queue. * * Asynchronously iterating over the stream will lock it, preventing any other consumer from acquiring a reader. * The lock will be released if the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method * is called, e.g. by breaking out of the loop. * * By default, calling the async iterator's {@link ReadableStreamAsyncIterator.return | return()} method will also * cancel the stream. To prevent this, use the stream's {@link ReadableStream.values | values()} method, passing * `true` for the `preventCancel` option. */ values(options?: ReadableStreamIteratorOptions): ReadableStreamAsyncIterator; values(rawOptions: ReadableStreamIteratorOptions | null | undefined = undefined): ReadableStreamAsyncIterator { if (!IsReadableStream(this)) { throw streamBrandCheckException('values'); } const options = convertIteratorOptions(rawOptions, 'First parameter'); return AcquireReadableStreamAsyncIterator(this, options.preventCancel); } /** * {@inheritDoc ReadableStream.values} */ [Symbol.asyncIterator]: (options?: ReadableStreamIteratorOptions) => ReadableStreamAsyncIterator; } Object.defineProperties(ReadableStream.prototype, { cancel: { enumerable: true }, getReader: { enumerable: true }, pipeThrough: { enumerable: true }, pipeTo: { enumerable: true }, tee: { enumerable: true }, values: { enumerable: true }, locked: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(ReadableStream.prototype, Symbol.toStringTag, { value: 'ReadableStream', configurable: true }); } if (typeof Symbol.asyncIterator === 'symbol') { Object.defineProperty(ReadableStream.prototype, Symbol.asyncIterator, { value: ReadableStream.prototype.values, writable: true, configurable: true }); } export { ReadableStreamAsyncIterator, ReadableStreamDefaultReadResult, ReadableStreamBYOBReadResult, UnderlyingByteSource, UnderlyingSource, UnderlyingSourceStartCallback, UnderlyingSourcePullCallback, UnderlyingSourceCancelCallback, UnderlyingByteSourceStartCallback, UnderlyingByteSourcePullCallback, StreamPipeOptions, ReadableWritablePair, ReadableStreamIteratorOptions }; // Abstract operations for the ReadableStream. // Throws if and only if startAlgorithm throws. export function CreateReadableStream(startAlgorithm: () => void | PromiseLike, pullAlgorithm: () => Promise, cancelAlgorithm: (reason: any) => Promise, highWaterMark = 1, sizeAlgorithm: QueuingStrategySizeCallback = () => 1): ReadableStream { assert(IsNonNegativeNumber(highWaterMark)); const stream: ReadableStream = Object.create(ReadableStream.prototype); InitializeReadableStream(stream); const controller: ReadableStreamDefaultController = Object.create(ReadableStreamDefaultController.prototype); SetUpReadableStreamDefaultController( stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm ); return stream; } // Throws if and only if startAlgorithm throws. export function CreateReadableByteStream( startAlgorithm: () => void | PromiseLike, pullAlgorithm: () => Promise, cancelAlgorithm: (reason: any) => Promise ): ReadableByteStream { const stream: ReadableByteStream = Object.create(ReadableStream.prototype); InitializeReadableStream(stream); const controller: ReadableByteStreamController = Object.create(ReadableByteStreamController.prototype); SetUpReadableByteStreamController(stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, 0, undefined); return stream; } function InitializeReadableStream(stream: ReadableStream) { stream._state = 'readable'; stream._reader = undefined; stream._storedError = undefined; stream._disturbed = false; } export function IsReadableStream(x: unknown): x is ReadableStream { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_readableStreamController')) { return false; } return x instanceof ReadableStream; } export function IsReadableStreamDisturbed(stream: ReadableStream): boolean { assert(IsReadableStream(stream)); return stream._disturbed; } export function IsReadableStreamLocked(stream: ReadableStream): boolean { assert(IsReadableStream(stream)); if (stream._reader === undefined) { return false; } return true; } // ReadableStream API exposed for controllers. export function ReadableStreamCancel(stream: ReadableStream, reason: any): Promise { stream._disturbed = true; if (stream._state === 'closed') { return promiseResolvedWith(undefined); } if (stream._state === 'errored') { return promiseRejectedWith(stream._storedError); } ReadableStreamClose(stream); const reader = stream._reader; if (reader !== undefined && IsReadableStreamBYOBReader(reader)) { reader._readIntoRequests.forEach(readIntoRequest => { readIntoRequest._closeSteps(undefined); }); reader._readIntoRequests = new SimpleQueue(); } const sourceCancelPromise = stream._readableStreamController[CancelSteps](reason); return transformPromiseWith(sourceCancelPromise, noop); } export function ReadableStreamClose(stream: ReadableStream): void { assert(stream._state === 'readable'); stream._state = 'closed'; const reader = stream._reader; if (reader === undefined) { return; } defaultReaderClosedPromiseResolve(reader); if (IsReadableStreamDefaultReader(reader)) { reader._readRequests.forEach(readRequest => { readRequest._closeSteps(); }); reader._readRequests = new SimpleQueue(); } } export function ReadableStreamError(stream: ReadableStream, e: any): void { assert(IsReadableStream(stream)); assert(stream._state === 'readable'); stream._state = 'errored'; stream._storedError = e; const reader = stream._reader; if (reader === undefined) { return; } defaultReaderClosedPromiseReject(reader, e); if (IsReadableStreamDefaultReader(reader)) { reader._readRequests.forEach(readRequest => { readRequest._errorSteps(e); }); reader._readRequests = new SimpleQueue(); } else { assert(IsReadableStreamBYOBReader(reader)); reader._readIntoRequests.forEach(readIntoRequest => { readIntoRequest._errorSteps(e); }); reader._readIntoRequests = new SimpleQueue(); } } // Readers export type ReadableStreamReader = ReadableStreamDefaultReader | ReadableStreamBYOBReader; export { ReadableStreamDefaultReader, ReadableStreamBYOBReader }; // Controllers export { ReadableStreamDefaultController, ReadableStreamBYOBRequest, ReadableByteStreamController }; // Helper functions for the ReadableStream. function streamBrandCheckException(name: string): TypeError { return new TypeError(`ReadableStream.prototype.${name} can only be used on a ReadableStream`); } web-streams-polyfill-3.2.1/src/lib/readable-stream/000077500000000000000000000000001422364423700221725ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/lib/readable-stream/async-iterator.ts000066400000000000000000000147111422364423700255120ustar00rootroot00000000000000/// import { ReadableStream } from '../readable-stream'; import { AcquireReadableStreamDefaultReader, ReadableStreamDefaultReader, ReadableStreamDefaultReaderRead, ReadableStreamDefaultReadResult, ReadRequest } from './default-reader'; import { ReadableStreamReaderGenericCancel, ReadableStreamReaderGenericRelease, readerLockException } from './generic-reader'; import assert from '../../stub/assert'; import { AsyncIteratorPrototype } from '@@target/stub/async-iterator-prototype'; import { typeIsObject } from '../helpers/miscellaneous'; import { newPromise, promiseRejectedWith, promiseResolvedWith, queueMicrotask, transformPromiseWith } from '../helpers/webidl'; /** * An async iterator returned by {@link ReadableStream.values}. * * @public */ export interface ReadableStreamAsyncIterator extends AsyncIterator { next(): Promise>; return(value?: any): Promise>; } export class ReadableStreamAsyncIteratorImpl { private readonly _reader: ReadableStreamDefaultReader; private readonly _preventCancel: boolean; private _ongoingPromise: Promise> | undefined = undefined; private _isFinished = false; constructor(reader: ReadableStreamDefaultReader, preventCancel: boolean) { this._reader = reader; this._preventCancel = preventCancel; } next(): Promise> { const nextSteps = () => this._nextSteps(); this._ongoingPromise = this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, nextSteps, nextSteps) : nextSteps(); return this._ongoingPromise; } return(value: any): Promise> { const returnSteps = () => this._returnSteps(value); return this._ongoingPromise ? transformPromiseWith(this._ongoingPromise, returnSteps, returnSteps) : returnSteps(); } private _nextSteps(): Promise> { if (this._isFinished) { return Promise.resolve({ value: undefined, done: true }); } const reader = this._reader; if (reader._ownerReadableStream === undefined) { return promiseRejectedWith(readerLockException('iterate')); } let resolvePromise!: (result: ReadableStreamDefaultReadResult) => void; let rejectPromise!: (reason: any) => void; const promise = newPromise>((resolve, reject) => { resolvePromise = resolve; rejectPromise = reject; }); const readRequest: ReadRequest = { _chunkSteps: chunk => { this._ongoingPromise = undefined; // This needs to be delayed by one microtask, otherwise we stop pulling too early which breaks a test. // FIXME Is this a bug in the specification, or in the test? queueMicrotask(() => resolvePromise({ value: chunk, done: false })); }, _closeSteps: () => { this._ongoingPromise = undefined; this._isFinished = true; ReadableStreamReaderGenericRelease(reader); resolvePromise({ value: undefined, done: true }); }, _errorSteps: reason => { this._ongoingPromise = undefined; this._isFinished = true; ReadableStreamReaderGenericRelease(reader); rejectPromise(reason); } }; ReadableStreamDefaultReaderRead(reader, readRequest); return promise; } private _returnSteps(value: any): Promise> { if (this._isFinished) { return Promise.resolve({ value, done: true }); } this._isFinished = true; const reader = this._reader; if (reader._ownerReadableStream === undefined) { return promiseRejectedWith(readerLockException('finish iterating')); } assert(reader._readRequests.length === 0); if (!this._preventCancel) { const result = ReadableStreamReaderGenericCancel(reader, value); ReadableStreamReaderGenericRelease(reader); return transformPromiseWith(result, () => ({ value, done: true })); } ReadableStreamReaderGenericRelease(reader); return promiseResolvedWith({ value, done: true }); } } declare class ReadableStreamAsyncIteratorInstance implements ReadableStreamAsyncIterator { /** @interal */ _asyncIteratorImpl: ReadableStreamAsyncIteratorImpl; next(): Promise>; return(value?: any): Promise>; } const ReadableStreamAsyncIteratorPrototype: ReadableStreamAsyncIteratorInstance = { next(this: ReadableStreamAsyncIteratorInstance): Promise> { if (!IsReadableStreamAsyncIterator(this)) { return promiseRejectedWith(streamAsyncIteratorBrandCheckException('next')); } return this._asyncIteratorImpl.next(); }, return(this: ReadableStreamAsyncIteratorInstance, value: any): Promise> { if (!IsReadableStreamAsyncIterator(this)) { return promiseRejectedWith(streamAsyncIteratorBrandCheckException('return')); } return this._asyncIteratorImpl.return(value); } } as any; if (AsyncIteratorPrototype !== undefined) { Object.setPrototypeOf(ReadableStreamAsyncIteratorPrototype, AsyncIteratorPrototype); } // Abstract operations for the ReadableStream. export function AcquireReadableStreamAsyncIterator(stream: ReadableStream, preventCancel: boolean): ReadableStreamAsyncIterator { const reader = AcquireReadableStreamDefaultReader(stream); const impl = new ReadableStreamAsyncIteratorImpl(reader, preventCancel); const iterator: ReadableStreamAsyncIteratorInstance = Object.create(ReadableStreamAsyncIteratorPrototype); iterator._asyncIteratorImpl = impl; return iterator; } function IsReadableStreamAsyncIterator(x: any): x is ReadableStreamAsyncIterator { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_asyncIteratorImpl')) { return false; } try { // noinspection SuspiciousTypeOfGuard return (x as ReadableStreamAsyncIteratorInstance)._asyncIteratorImpl instanceof ReadableStreamAsyncIteratorImpl; } catch { return false; } } // Helper functions for the ReadableStream. function streamAsyncIteratorBrandCheckException(name: string): TypeError { return new TypeError(`ReadableStreamAsyncIterator.${name} can only be used on a ReadableSteamAsyncIterator`); } web-streams-polyfill-3.2.1/src/lib/readable-stream/byob-reader.ts000066400000000000000000000216261422364423700247440ustar00rootroot00000000000000import assert from '../../stub/assert'; import { SimpleQueue } from '../simple-queue'; import { ReadableStreamReaderGenericCancel, ReadableStreamReaderGenericInitialize, ReadableStreamReaderGenericRelease, readerLockException } from './generic-reader'; import { IsReadableStreamLocked, ReadableByteStream, ReadableStream } from '../readable-stream'; import { IsReadableByteStreamController, ReadableByteStreamController, ReadableByteStreamControllerPullInto } from './byte-stream-controller'; import { typeIsObject } from '../helpers/miscellaneous'; import { newPromise, promiseRejectedWith } from '../helpers/webidl'; import { assertRequiredArgument } from '../validators/basic'; import { assertReadableStream } from '../validators/readable-stream'; import { IsDetachedBuffer } from '../abstract-ops/ecmascript'; /** * A result returned by {@link ReadableStreamBYOBReader.read}. * * @public */ export type ReadableStreamBYOBReadResult = { done: false; value: T; } | { done: true; value: T | undefined; }; // Abstract operations for the ReadableStream. export function AcquireReadableStreamBYOBReader(stream: ReadableByteStream): ReadableStreamBYOBReader { return new ReadableStreamBYOBReader(stream); } // ReadableStream API exposed for controllers. export function ReadableStreamAddReadIntoRequest(stream: ReadableByteStream, readIntoRequest: ReadIntoRequest): void { assert(IsReadableStreamBYOBReader(stream._reader)); assert(stream._state === 'readable' || stream._state === 'closed'); (stream._reader! as ReadableStreamBYOBReader)._readIntoRequests.push(readIntoRequest); } export function ReadableStreamFulfillReadIntoRequest(stream: ReadableByteStream, chunk: ArrayBufferView, done: boolean) { const reader = stream._reader as ReadableStreamBYOBReader; assert(reader._readIntoRequests.length > 0); const readIntoRequest = reader._readIntoRequests.shift()!; if (done) { readIntoRequest._closeSteps(chunk); } else { readIntoRequest._chunkSteps(chunk); } } export function ReadableStreamGetNumReadIntoRequests(stream: ReadableByteStream): number { return (stream._reader as ReadableStreamBYOBReader)._readIntoRequests.length; } export function ReadableStreamHasBYOBReader(stream: ReadableByteStream): boolean { const reader = stream._reader; if (reader === undefined) { return false; } if (!IsReadableStreamBYOBReader(reader)) { return false; } return true; } // Readers export interface ReadIntoRequest { _chunkSteps(chunk: T): void; _closeSteps(chunk: T | undefined): void; _errorSteps(e: any): void; } /** * A BYOB reader vended by a {@link ReadableStream}. * * @public */ export class ReadableStreamBYOBReader { /** @internal */ _ownerReadableStream!: ReadableByteStream; /** @internal */ _closedPromise!: Promise; /** @internal */ _closedPromise_resolve?: (value?: undefined) => void; /** @internal */ _closedPromise_reject?: (reason: any) => void; /** @internal */ _readIntoRequests: SimpleQueue>; constructor(stream: ReadableByteStream) { assertRequiredArgument(stream, 1, 'ReadableStreamBYOBReader'); assertReadableStream(stream, 'First parameter'); if (IsReadableStreamLocked(stream)) { throw new TypeError('This stream has already been locked for exclusive reading by another reader'); } if (!IsReadableByteStreamController(stream._readableStreamController)) { throw new TypeError('Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte ' + 'source'); } ReadableStreamReaderGenericInitialize(this, stream); this._readIntoRequests = new SimpleQueue(); } /** * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or * the reader's lock is released before the stream finishes closing. */ get closed(): Promise { if (!IsReadableStreamBYOBReader(this)) { return promiseRejectedWith(byobReaderBrandCheckException('closed')); } return this._closedPromise; } /** * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}. */ cancel(reason: any = undefined): Promise { if (!IsReadableStreamBYOBReader(this)) { return promiseRejectedWith(byobReaderBrandCheckException('cancel')); } if (this._ownerReadableStream === undefined) { return promiseRejectedWith(readerLockException('cancel')); } return ReadableStreamReaderGenericCancel(this, reason); } /** * Attempts to reads bytes into view, and returns a promise resolved with the result. * * If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source. */ read(view: T): Promise> { if (!IsReadableStreamBYOBReader(this)) { return promiseRejectedWith(byobReaderBrandCheckException('read')); } if (!ArrayBuffer.isView(view)) { return promiseRejectedWith(new TypeError('view must be an array buffer view')); } if (view.byteLength === 0) { return promiseRejectedWith(new TypeError('view must have non-zero byteLength')); } if (view.buffer.byteLength === 0) { return promiseRejectedWith(new TypeError(`view's buffer must have non-zero byteLength`)); } if (IsDetachedBuffer(view.buffer)) { return promiseRejectedWith(new TypeError('view\'s buffer has been detached')); } if (this._ownerReadableStream === undefined) { return promiseRejectedWith(readerLockException('read from')); } let resolvePromise!: (result: ReadableStreamBYOBReadResult) => void; let rejectPromise!: (reason: any) => void; const promise = newPromise>((resolve, reject) => { resolvePromise = resolve; rejectPromise = reject; }); const readIntoRequest: ReadIntoRequest = { _chunkSteps: chunk => resolvePromise({ value: chunk, done: false }), _closeSteps: chunk => resolvePromise({ value: chunk, done: true }), _errorSteps: e => rejectPromise(e) }; ReadableStreamBYOBReaderRead(this, view, readIntoRequest); return promise; } /** * Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active. * If the associated stream is errored when the lock is released, the reader will appear errored in the same way * from now on; otherwise, the reader will appear closed. * * A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by * the reader's {@link ReadableStreamBYOBReader.read | read()} method has not yet been settled. Attempting to * do so will throw a `TypeError` and leave the reader locked to the stream. */ releaseLock(): void { if (!IsReadableStreamBYOBReader(this)) { throw byobReaderBrandCheckException('releaseLock'); } if (this._ownerReadableStream === undefined) { return; } if (this._readIntoRequests.length > 0) { throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled'); } ReadableStreamReaderGenericRelease(this); } } Object.defineProperties(ReadableStreamBYOBReader.prototype, { cancel: { enumerable: true }, read: { enumerable: true }, releaseLock: { enumerable: true }, closed: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(ReadableStreamBYOBReader.prototype, Symbol.toStringTag, { value: 'ReadableStreamBYOBReader', configurable: true }); } // Abstract operations for the readers. export function IsReadableStreamBYOBReader(x: any): x is ReadableStreamBYOBReader { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_readIntoRequests')) { return false; } return x instanceof ReadableStreamBYOBReader; } export function ReadableStreamBYOBReaderRead( reader: ReadableStreamBYOBReader, view: T, readIntoRequest: ReadIntoRequest ): void { const stream = reader._ownerReadableStream; assert(stream !== undefined); stream._disturbed = true; if (stream._state === 'errored') { readIntoRequest._errorSteps(stream._storedError); } else { ReadableByteStreamControllerPullInto( stream._readableStreamController as ReadableByteStreamController, view, readIntoRequest ); } } // Helper functions for the ReadableStreamBYOBReader. function byobReaderBrandCheckException(name: string): TypeError { return new TypeError( `ReadableStreamBYOBReader.prototype.${name} can only be used on a ReadableStreamBYOBReader`); } web-streams-polyfill-3.2.1/src/lib/readable-stream/byte-stream-controller.ts000066400000000000000000001071231422364423700271630ustar00rootroot00000000000000import assert from '../../stub/assert'; import { SimpleQueue } from '../simple-queue'; import { ResetQueue } from '../abstract-ops/queue-with-sizes'; import { ReadableStreamAddReadRequest, ReadableStreamFulfillReadRequest, ReadableStreamGetNumReadRequests, ReadableStreamHasDefaultReader, ReadRequest } from './default-reader'; import { ReadableStreamAddReadIntoRequest, ReadableStreamFulfillReadIntoRequest, ReadableStreamGetNumReadIntoRequests, ReadableStreamHasBYOBReader, ReadIntoRequest } from './byob-reader'; import NumberIsInteger from '../../stub/number-isinteger'; import { IsReadableStreamLocked, ReadableByteStream, ReadableStreamClose, ReadableStreamError } from '../readable-stream'; import { ValidatedUnderlyingByteSource } from './underlying-source'; import { typeIsObject } from '../helpers/miscellaneous'; import { ArrayBufferSlice, CanTransferArrayBuffer, CopyDataBlockBytes, IsDetachedBuffer, TransferArrayBuffer } from '../abstract-ops/ecmascript'; import { CancelSteps, PullSteps } from '../abstract-ops/internal-methods'; import { promiseResolvedWith, uponPromise } from '../helpers/webidl'; import { assertRequiredArgument, convertUnsignedLongLongWithEnforceRange } from '../validators/basic'; /** * A pull-into request in a {@link ReadableByteStreamController}. * * @public */ export class ReadableStreamBYOBRequest { /** @internal */ _associatedReadableByteStreamController!: ReadableByteStreamController; /** @internal */ _view!: ArrayBufferView | null; private constructor() { throw new TypeError('Illegal constructor'); } /** * Returns the view for writing in to, or `null` if the BYOB request has already been responded to. */ get view(): ArrayBufferView | null { if (!IsReadableStreamBYOBRequest(this)) { throw byobRequestBrandCheckException('view'); } return this._view; } /** * Indicates to the associated readable byte stream that `bytesWritten` bytes were written into * {@link ReadableStreamBYOBRequest.view | view}, causing the result be surfaced to the consumer. * * After this method is called, {@link ReadableStreamBYOBRequest.view | view} will be transferred and no longer * modifiable. */ respond(bytesWritten: number): void; respond(bytesWritten: number | undefined): void { if (!IsReadableStreamBYOBRequest(this)) { throw byobRequestBrandCheckException('respond'); } assertRequiredArgument(bytesWritten, 1, 'respond'); bytesWritten = convertUnsignedLongLongWithEnforceRange(bytesWritten, 'First parameter'); if (this._associatedReadableByteStreamController === undefined) { throw new TypeError('This BYOB request has been invalidated'); } if (IsDetachedBuffer(this._view!.buffer)) { throw new TypeError(`The BYOB request's buffer has been detached and so cannot be used as a response`); } assert(this._view!.byteLength > 0); assert(this._view!.buffer.byteLength > 0); ReadableByteStreamControllerRespond(this._associatedReadableByteStreamController, bytesWritten); } /** * Indicates to the associated readable byte stream that instead of writing into * {@link ReadableStreamBYOBRequest.view | view}, the underlying byte source is providing a new `ArrayBufferView`, * which will be given to the consumer of the readable byte stream. * * After this method is called, `view` will be transferred and no longer modifiable. */ respondWithNewView(view: ArrayBufferView): void; respondWithNewView(view: ArrayBufferView | undefined): void { if (!IsReadableStreamBYOBRequest(this)) { throw byobRequestBrandCheckException('respondWithNewView'); } assertRequiredArgument(view, 1, 'respondWithNewView'); if (!ArrayBuffer.isView(view)) { throw new TypeError('You can only respond with array buffer views'); } if (this._associatedReadableByteStreamController === undefined) { throw new TypeError('This BYOB request has been invalidated'); } if (IsDetachedBuffer(view.buffer)) { throw new TypeError('The given view\'s buffer has been detached and so cannot be used as a response'); } ReadableByteStreamControllerRespondWithNewView(this._associatedReadableByteStreamController, view); } } Object.defineProperties(ReadableStreamBYOBRequest.prototype, { respond: { enumerable: true }, respondWithNewView: { enumerable: true }, view: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(ReadableStreamBYOBRequest.prototype, Symbol.toStringTag, { value: 'ReadableStreamBYOBRequest', configurable: true }); } interface ArrayBufferViewConstructor { new(buffer: ArrayBufferLike, byteOffset: number, length?: number): T; readonly prototype: T; readonly BYTES_PER_ELEMENT: number; } interface ByteQueueElement { buffer: ArrayBufferLike; byteOffset: number; byteLength: number; } type PullIntoDescriptor = DefaultPullIntoDescriptor | BYOBPullIntoDescriptor; interface DefaultPullIntoDescriptor { buffer: ArrayBufferLike; bufferByteLength: number; byteOffset: number; byteLength: number; bytesFilled: number; elementSize: number; viewConstructor: ArrayBufferViewConstructor; readerType: 'default'; } interface BYOBPullIntoDescriptor { buffer: ArrayBufferLike; bufferByteLength: number; byteOffset: number; byteLength: number; bytesFilled: number; elementSize: number; viewConstructor: ArrayBufferViewConstructor; readerType: 'byob'; } /** * Allows control of a {@link ReadableStream | readable byte stream}'s state and internal queue. * * @public */ export class ReadableByteStreamController { /** @internal */ _controlledReadableByteStream!: ReadableByteStream; /** @internal */ _queue!: SimpleQueue; /** @internal */ _queueTotalSize!: number; /** @internal */ _started!: boolean; /** @internal */ _closeRequested!: boolean; /** @internal */ _pullAgain!: boolean; /** @internal */ _pulling !: boolean; /** @internal */ _strategyHWM!: number; /** @internal */ _pullAlgorithm!: () => Promise; /** @internal */ _cancelAlgorithm!: (reason: any) => Promise; /** @internal */ _autoAllocateChunkSize: number | undefined; /** @internal */ _byobRequest: ReadableStreamBYOBRequest | null; /** @internal */ _pendingPullIntos!: SimpleQueue; private constructor() { throw new TypeError('Illegal constructor'); } /** * Returns the current BYOB pull request, or `null` if there isn't one. */ get byobRequest(): ReadableStreamBYOBRequest | null { if (!IsReadableByteStreamController(this)) { throw byteStreamControllerBrandCheckException('byobRequest'); } return ReadableByteStreamControllerGetBYOBRequest(this); } /** * Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is * over-full. An underlying byte source ought to use this information to determine when and how to apply backpressure. */ get desiredSize(): number | null { if (!IsReadableByteStreamController(this)) { throw byteStreamControllerBrandCheckException('desiredSize'); } return ReadableByteStreamControllerGetDesiredSize(this); } /** * Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from * the stream, but once those are read, the stream will become closed. */ close(): void { if (!IsReadableByteStreamController(this)) { throw byteStreamControllerBrandCheckException('close'); } if (this._closeRequested) { throw new TypeError('The stream has already been closed; do not close it again!'); } const state = this._controlledReadableByteStream._state; if (state !== 'readable') { throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be closed`); } ReadableByteStreamControllerClose(this); } /** * Enqueues the given chunk chunk in the controlled readable stream. * The chunk has to be an `ArrayBufferView` instance, or else a `TypeError` will be thrown. */ enqueue(chunk: ArrayBufferView): void; enqueue(chunk: ArrayBufferView | undefined): void { if (!IsReadableByteStreamController(this)) { throw byteStreamControllerBrandCheckException('enqueue'); } assertRequiredArgument(chunk, 1, 'enqueue'); if (!ArrayBuffer.isView(chunk)) { throw new TypeError('chunk must be an array buffer view'); } if (chunk.byteLength === 0) { throw new TypeError('chunk must have non-zero byteLength'); } if (chunk.buffer.byteLength === 0) { throw new TypeError(`chunk's buffer must have non-zero byteLength`); } if (this._closeRequested) { throw new TypeError('stream is closed or draining'); } const state = this._controlledReadableByteStream._state; if (state !== 'readable') { throw new TypeError(`The stream (in ${state} state) is not in the readable state and cannot be enqueued to`); } ReadableByteStreamControllerEnqueue(this, chunk); } /** * Errors the controlled readable stream, making all future interactions with it fail with the given error `e`. */ error(e: any = undefined): void { if (!IsReadableByteStreamController(this)) { throw byteStreamControllerBrandCheckException('error'); } ReadableByteStreamControllerError(this, e); } /** @internal */ [CancelSteps](reason: any): Promise { ReadableByteStreamControllerClearPendingPullIntos(this); ResetQueue(this); const result = this._cancelAlgorithm(reason); ReadableByteStreamControllerClearAlgorithms(this); return result; } /** @internal */ [PullSteps](readRequest: ReadRequest): void { const stream = this._controlledReadableByteStream; assert(ReadableStreamHasDefaultReader(stream)); if (this._queueTotalSize > 0) { assert(ReadableStreamGetNumReadRequests(stream) === 0); const entry = this._queue.shift()!; this._queueTotalSize -= entry.byteLength; ReadableByteStreamControllerHandleQueueDrain(this); const view = new Uint8Array(entry.buffer, entry.byteOffset, entry.byteLength); readRequest._chunkSteps(view); return; } const autoAllocateChunkSize = this._autoAllocateChunkSize; if (autoAllocateChunkSize !== undefined) { let buffer: ArrayBuffer; try { buffer = new ArrayBuffer(autoAllocateChunkSize); } catch (bufferE) { readRequest._errorSteps(bufferE); return; } const pullIntoDescriptor: DefaultPullIntoDescriptor = { buffer, bufferByteLength: autoAllocateChunkSize, byteOffset: 0, byteLength: autoAllocateChunkSize, bytesFilled: 0, elementSize: 1, viewConstructor: Uint8Array, readerType: 'default' }; this._pendingPullIntos.push(pullIntoDescriptor); } ReadableStreamAddReadRequest(stream, readRequest); ReadableByteStreamControllerCallPullIfNeeded(this); } } Object.defineProperties(ReadableByteStreamController.prototype, { close: { enumerable: true }, enqueue: { enumerable: true }, error: { enumerable: true }, byobRequest: { enumerable: true }, desiredSize: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(ReadableByteStreamController.prototype, Symbol.toStringTag, { value: 'ReadableByteStreamController', configurable: true }); } // Abstract operations for the ReadableByteStreamController. export function IsReadableByteStreamController(x: any): x is ReadableByteStreamController { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableByteStream')) { return false; } return x instanceof ReadableByteStreamController; } function IsReadableStreamBYOBRequest(x: any): x is ReadableStreamBYOBRequest { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_associatedReadableByteStreamController')) { return false; } return x instanceof ReadableStreamBYOBRequest; } function ReadableByteStreamControllerCallPullIfNeeded(controller: ReadableByteStreamController): void { const shouldPull = ReadableByteStreamControllerShouldCallPull(controller); if (!shouldPull) { return; } if (controller._pulling) { controller._pullAgain = true; return; } assert(!controller._pullAgain); controller._pulling = true; // TODO: Test controller argument const pullPromise = controller._pullAlgorithm(); uponPromise( pullPromise, () => { controller._pulling = false; if (controller._pullAgain) { controller._pullAgain = false; ReadableByteStreamControllerCallPullIfNeeded(controller); } }, e => { ReadableByteStreamControllerError(controller, e); } ); } function ReadableByteStreamControllerClearPendingPullIntos(controller: ReadableByteStreamController) { ReadableByteStreamControllerInvalidateBYOBRequest(controller); controller._pendingPullIntos = new SimpleQueue(); } function ReadableByteStreamControllerCommitPullIntoDescriptor( stream: ReadableByteStream, pullIntoDescriptor: PullIntoDescriptor ) { assert(stream._state !== 'errored'); let done = false; if (stream._state === 'closed') { assert(pullIntoDescriptor.bytesFilled === 0); done = true; } const filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor); if (pullIntoDescriptor.readerType === 'default') { ReadableStreamFulfillReadRequest(stream, filledView as unknown as Uint8Array, done); } else { assert(pullIntoDescriptor.readerType === 'byob'); ReadableStreamFulfillReadIntoRequest(stream, filledView, done); } } function ReadableByteStreamControllerConvertPullIntoDescriptor( pullIntoDescriptor: PullIntoDescriptor ): T { const bytesFilled = pullIntoDescriptor.bytesFilled; const elementSize = pullIntoDescriptor.elementSize; assert(bytesFilled <= pullIntoDescriptor.byteLength); assert(bytesFilled % elementSize === 0); return new pullIntoDescriptor.viewConstructor( pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, bytesFilled / elementSize) as T; } function ReadableByteStreamControllerEnqueueChunkToQueue(controller: ReadableByteStreamController, buffer: ArrayBufferLike, byteOffset: number, byteLength: number) { controller._queue.push({ buffer, byteOffset, byteLength }); controller._queueTotalSize += byteLength; } function ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller: ReadableByteStreamController, pullIntoDescriptor: PullIntoDescriptor) { const elementSize = pullIntoDescriptor.elementSize; const currentAlignedBytes = pullIntoDescriptor.bytesFilled - pullIntoDescriptor.bytesFilled % elementSize; const maxBytesToCopy = Math.min(controller._queueTotalSize, pullIntoDescriptor.byteLength - pullIntoDescriptor.bytesFilled); const maxBytesFilled = pullIntoDescriptor.bytesFilled + maxBytesToCopy; const maxAlignedBytes = maxBytesFilled - maxBytesFilled % elementSize; let totalBytesToCopyRemaining = maxBytesToCopy; let ready = false; if (maxAlignedBytes > currentAlignedBytes) { totalBytesToCopyRemaining = maxAlignedBytes - pullIntoDescriptor.bytesFilled; ready = true; } const queue = controller._queue; while (totalBytesToCopyRemaining > 0) { const headOfQueue = queue.peek(); const bytesToCopy = Math.min(totalBytesToCopyRemaining, headOfQueue.byteLength); const destStart = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled; CopyDataBlockBytes(pullIntoDescriptor.buffer, destStart, headOfQueue.buffer, headOfQueue.byteOffset, bytesToCopy); if (headOfQueue.byteLength === bytesToCopy) { queue.shift(); } else { headOfQueue.byteOffset += bytesToCopy; headOfQueue.byteLength -= bytesToCopy; } controller._queueTotalSize -= bytesToCopy; ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesToCopy, pullIntoDescriptor); totalBytesToCopyRemaining -= bytesToCopy; } if (!ready) { assert(controller._queueTotalSize === 0); assert(pullIntoDescriptor.bytesFilled > 0); assert(pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize); } return ready; } function ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller: ReadableByteStreamController, size: number, pullIntoDescriptor: PullIntoDescriptor) { assert(controller._pendingPullIntos.length === 0 || controller._pendingPullIntos.peek() === pullIntoDescriptor); assert(controller._byobRequest === null); pullIntoDescriptor.bytesFilled += size; } function ReadableByteStreamControllerHandleQueueDrain(controller: ReadableByteStreamController) { assert(controller._controlledReadableByteStream._state === 'readable'); if (controller._queueTotalSize === 0 && controller._closeRequested) { ReadableByteStreamControllerClearAlgorithms(controller); ReadableStreamClose(controller._controlledReadableByteStream); } else { ReadableByteStreamControllerCallPullIfNeeded(controller); } } function ReadableByteStreamControllerInvalidateBYOBRequest(controller: ReadableByteStreamController) { if (controller._byobRequest === null) { return; } controller._byobRequest._associatedReadableByteStreamController = undefined!; controller._byobRequest._view = null!; controller._byobRequest = null; } function ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller: ReadableByteStreamController) { assert(!controller._closeRequested); while (controller._pendingPullIntos.length > 0) { if (controller._queueTotalSize === 0) { return; } const pullIntoDescriptor = controller._pendingPullIntos.peek(); if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor)) { ReadableByteStreamControllerShiftPendingPullInto(controller); ReadableByteStreamControllerCommitPullIntoDescriptor( controller._controlledReadableByteStream, pullIntoDescriptor ); } } } export function ReadableByteStreamControllerPullInto( controller: ReadableByteStreamController, view: T, readIntoRequest: ReadIntoRequest ): void { const stream = controller._controlledReadableByteStream; let elementSize = 1; if (view.constructor !== DataView) { elementSize = (view.constructor as ArrayBufferViewConstructor).BYTES_PER_ELEMENT; } const ctor = view.constructor as ArrayBufferViewConstructor; // try { const buffer = TransferArrayBuffer(view.buffer); // } catch (e) { // readIntoRequest._errorSteps(e); // return; // } const pullIntoDescriptor: BYOBPullIntoDescriptor = { buffer, bufferByteLength: buffer.byteLength, byteOffset: view.byteOffset, byteLength: view.byteLength, bytesFilled: 0, elementSize, viewConstructor: ctor, readerType: 'byob' }; if (controller._pendingPullIntos.length > 0) { controller._pendingPullIntos.push(pullIntoDescriptor); // No ReadableByteStreamControllerCallPullIfNeeded() call since: // - No change happens on desiredSize // - The source has already been notified of that there's at least 1 pending read(view) ReadableStreamAddReadIntoRequest(stream, readIntoRequest); return; } if (stream._state === 'closed') { const emptyView = new ctor(pullIntoDescriptor.buffer, pullIntoDescriptor.byteOffset, 0); readIntoRequest._closeSteps(emptyView); return; } if (controller._queueTotalSize > 0) { if (ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(controller, pullIntoDescriptor)) { const filledView = ReadableByteStreamControllerConvertPullIntoDescriptor(pullIntoDescriptor); ReadableByteStreamControllerHandleQueueDrain(controller); readIntoRequest._chunkSteps(filledView); return; } if (controller._closeRequested) { const e = new TypeError('Insufficient bytes to fill elements in the given buffer'); ReadableByteStreamControllerError(controller, e); readIntoRequest._errorSteps(e); return; } } controller._pendingPullIntos.push(pullIntoDescriptor); ReadableStreamAddReadIntoRequest(stream, readIntoRequest); ReadableByteStreamControllerCallPullIfNeeded(controller); } function ReadableByteStreamControllerRespondInClosedState(controller: ReadableByteStreamController, firstDescriptor: PullIntoDescriptor) { assert(firstDescriptor.bytesFilled === 0); const stream = controller._controlledReadableByteStream; if (ReadableStreamHasBYOBReader(stream)) { while (ReadableStreamGetNumReadIntoRequests(stream) > 0) { const pullIntoDescriptor = ReadableByteStreamControllerShiftPendingPullInto(controller); ReadableByteStreamControllerCommitPullIntoDescriptor(stream, pullIntoDescriptor); } } } function ReadableByteStreamControllerRespondInReadableState(controller: ReadableByteStreamController, bytesWritten: number, pullIntoDescriptor: PullIntoDescriptor) { assert(pullIntoDescriptor.bytesFilled + bytesWritten <= pullIntoDescriptor.byteLength); ReadableByteStreamControllerFillHeadPullIntoDescriptor(controller, bytesWritten, pullIntoDescriptor); if (pullIntoDescriptor.bytesFilled < pullIntoDescriptor.elementSize) { return; } ReadableByteStreamControllerShiftPendingPullInto(controller); const remainderSize = pullIntoDescriptor.bytesFilled % pullIntoDescriptor.elementSize; if (remainderSize > 0) { const end = pullIntoDescriptor.byteOffset + pullIntoDescriptor.bytesFilled; const remainder = ArrayBufferSlice(pullIntoDescriptor.buffer, end - remainderSize, end); ReadableByteStreamControllerEnqueueChunkToQueue(controller, remainder, 0, remainder.byteLength); } pullIntoDescriptor.bytesFilled -= remainderSize; ReadableByteStreamControllerCommitPullIntoDescriptor(controller._controlledReadableByteStream, pullIntoDescriptor); ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller); } function ReadableByteStreamControllerRespondInternal(controller: ReadableByteStreamController, bytesWritten: number) { const firstDescriptor = controller._pendingPullIntos.peek(); assert(CanTransferArrayBuffer(firstDescriptor.buffer)); ReadableByteStreamControllerInvalidateBYOBRequest(controller); const state = controller._controlledReadableByteStream._state; if (state === 'closed') { assert(bytesWritten === 0); ReadableByteStreamControllerRespondInClosedState(controller, firstDescriptor); } else { assert(state === 'readable'); assert(bytesWritten > 0); ReadableByteStreamControllerRespondInReadableState(controller, bytesWritten, firstDescriptor); } ReadableByteStreamControllerCallPullIfNeeded(controller); } function ReadableByteStreamControllerShiftPendingPullInto( controller: ReadableByteStreamController ): PullIntoDescriptor { assert(controller._byobRequest === null); const descriptor = controller._pendingPullIntos.shift()!; return descriptor; } function ReadableByteStreamControllerShouldCallPull(controller: ReadableByteStreamController): boolean { const stream = controller._controlledReadableByteStream; if (stream._state !== 'readable') { return false; } if (controller._closeRequested) { return false; } if (!controller._started) { return false; } if (ReadableStreamHasDefaultReader(stream) && ReadableStreamGetNumReadRequests(stream) > 0) { return true; } if (ReadableStreamHasBYOBReader(stream) && ReadableStreamGetNumReadIntoRequests(stream) > 0) { return true; } const desiredSize = ReadableByteStreamControllerGetDesiredSize(controller); assert(desiredSize !== null); if (desiredSize! > 0) { return true; } return false; } function ReadableByteStreamControllerClearAlgorithms(controller: ReadableByteStreamController) { controller._pullAlgorithm = undefined!; controller._cancelAlgorithm = undefined!; } // A client of ReadableByteStreamController may use these functions directly to bypass state check. export function ReadableByteStreamControllerClose(controller: ReadableByteStreamController) { const stream = controller._controlledReadableByteStream; if (controller._closeRequested || stream._state !== 'readable') { return; } if (controller._queueTotalSize > 0) { controller._closeRequested = true; return; } if (controller._pendingPullIntos.length > 0) { const firstPendingPullInto = controller._pendingPullIntos.peek(); if (firstPendingPullInto.bytesFilled > 0) { const e = new TypeError('Insufficient bytes to fill elements in the given buffer'); ReadableByteStreamControllerError(controller, e); throw e; } } ReadableByteStreamControllerClearAlgorithms(controller); ReadableStreamClose(stream); } export function ReadableByteStreamControllerEnqueue(controller: ReadableByteStreamController, chunk: ArrayBufferView) { const stream = controller._controlledReadableByteStream; if (controller._closeRequested || stream._state !== 'readable') { return; } const buffer = chunk.buffer; const byteOffset = chunk.byteOffset; const byteLength = chunk.byteLength; if (IsDetachedBuffer(buffer)) { throw new TypeError('chunk\'s buffer is detached and so cannot be enqueued'); } const transferredBuffer = TransferArrayBuffer(buffer); if (controller._pendingPullIntos.length > 0) { const firstPendingPullInto = controller._pendingPullIntos.peek(); if (IsDetachedBuffer(firstPendingPullInto.buffer)) { throw new TypeError( 'The BYOB request\'s buffer has been detached and so cannot be filled with an enqueued chunk' ); } firstPendingPullInto.buffer = TransferArrayBuffer(firstPendingPullInto.buffer); } ReadableByteStreamControllerInvalidateBYOBRequest(controller); if (ReadableStreamHasDefaultReader(stream)) { if (ReadableStreamGetNumReadRequests(stream) === 0) { assert(controller._pendingPullIntos.length === 0); ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength); } else { assert(controller._queue.length === 0); if (controller._pendingPullIntos.length > 0) { assert(controller._pendingPullIntos.peek().readerType === 'default'); ReadableByteStreamControllerShiftPendingPullInto(controller); } const transferredView = new Uint8Array(transferredBuffer, byteOffset, byteLength); ReadableStreamFulfillReadRequest(stream, transferredView, false); } } else if (ReadableStreamHasBYOBReader(stream)) { // TODO: Ideally in this branch detaching should happen only if the buffer is not consumed fully. ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength); ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(controller); } else { assert(!IsReadableStreamLocked(stream)); ReadableByteStreamControllerEnqueueChunkToQueue(controller, transferredBuffer, byteOffset, byteLength); } ReadableByteStreamControllerCallPullIfNeeded(controller); } export function ReadableByteStreamControllerError(controller: ReadableByteStreamController, e: any) { const stream = controller._controlledReadableByteStream; if (stream._state !== 'readable') { return; } ReadableByteStreamControllerClearPendingPullIntos(controller); ResetQueue(controller); ReadableByteStreamControllerClearAlgorithms(controller); ReadableStreamError(stream, e); } export function ReadableByteStreamControllerGetBYOBRequest( controller: ReadableByteStreamController ): ReadableStreamBYOBRequest | null { if (controller._byobRequest === null && controller._pendingPullIntos.length > 0) { const firstDescriptor = controller._pendingPullIntos.peek(); const view = new Uint8Array(firstDescriptor.buffer, firstDescriptor.byteOffset + firstDescriptor.bytesFilled, firstDescriptor.byteLength - firstDescriptor.bytesFilled); const byobRequest: ReadableStreamBYOBRequest = Object.create(ReadableStreamBYOBRequest.prototype); SetUpReadableStreamBYOBRequest(byobRequest, controller, view); controller._byobRequest = byobRequest; } return controller._byobRequest; } function ReadableByteStreamControllerGetDesiredSize(controller: ReadableByteStreamController): number | null { const state = controller._controlledReadableByteStream._state; if (state === 'errored') { return null; } if (state === 'closed') { return 0; } return controller._strategyHWM - controller._queueTotalSize; } export function ReadableByteStreamControllerRespond(controller: ReadableByteStreamController, bytesWritten: number) { assert(controller._pendingPullIntos.length > 0); const firstDescriptor = controller._pendingPullIntos.peek(); const state = controller._controlledReadableByteStream._state; if (state === 'closed') { if (bytesWritten !== 0) { throw new TypeError('bytesWritten must be 0 when calling respond() on a closed stream'); } } else { assert(state === 'readable'); if (bytesWritten === 0) { throw new TypeError('bytesWritten must be greater than 0 when calling respond() on a readable stream'); } if (firstDescriptor.bytesFilled + bytesWritten > firstDescriptor.byteLength) { throw new RangeError('bytesWritten out of range'); } } firstDescriptor.buffer = TransferArrayBuffer(firstDescriptor.buffer); ReadableByteStreamControllerRespondInternal(controller, bytesWritten); } export function ReadableByteStreamControllerRespondWithNewView(controller: ReadableByteStreamController, view: ArrayBufferView) { assert(controller._pendingPullIntos.length > 0); assert(!IsDetachedBuffer(view.buffer)); const firstDescriptor = controller._pendingPullIntos.peek(); const state = controller._controlledReadableByteStream._state; if (state === 'closed') { if (view.byteLength !== 0) { throw new TypeError('The view\'s length must be 0 when calling respondWithNewView() on a closed stream'); } } else { assert(state === 'readable'); if (view.byteLength === 0) { throw new TypeError( 'The view\'s length must be greater than 0 when calling respondWithNewView() on a readable stream' ); } } if (firstDescriptor.byteOffset + firstDescriptor.bytesFilled !== view.byteOffset) { throw new RangeError('The region specified by view does not match byobRequest'); } if (firstDescriptor.bufferByteLength !== view.buffer.byteLength) { throw new RangeError('The buffer of view has different capacity than byobRequest'); } if (firstDescriptor.bytesFilled + view.byteLength > firstDescriptor.byteLength) { throw new RangeError('The region specified by view is larger than byobRequest'); } const viewByteLength = view.byteLength; firstDescriptor.buffer = TransferArrayBuffer(view.buffer); ReadableByteStreamControllerRespondInternal(controller, viewByteLength); } export function SetUpReadableByteStreamController(stream: ReadableByteStream, controller: ReadableByteStreamController, startAlgorithm: () => void | PromiseLike, pullAlgorithm: () => Promise, cancelAlgorithm: (reason: any) => Promise, highWaterMark: number, autoAllocateChunkSize: number | undefined) { assert(stream._readableStreamController === undefined); if (autoAllocateChunkSize !== undefined) { assert(NumberIsInteger(autoAllocateChunkSize)); assert(autoAllocateChunkSize > 0); } controller._controlledReadableByteStream = stream; controller._pullAgain = false; controller._pulling = false; controller._byobRequest = null; // Need to set the slots so that the assert doesn't fire. In the spec the slots already exist implicitly. controller._queue = controller._queueTotalSize = undefined!; ResetQueue(controller); controller._closeRequested = false; controller._started = false; controller._strategyHWM = highWaterMark; controller._pullAlgorithm = pullAlgorithm; controller._cancelAlgorithm = cancelAlgorithm; controller._autoAllocateChunkSize = autoAllocateChunkSize; controller._pendingPullIntos = new SimpleQueue(); stream._readableStreamController = controller; const startResult = startAlgorithm(); uponPromise( promiseResolvedWith(startResult), () => { controller._started = true; assert(!controller._pulling); assert(!controller._pullAgain); ReadableByteStreamControllerCallPullIfNeeded(controller); }, r => { ReadableByteStreamControllerError(controller, r); } ); } export function SetUpReadableByteStreamControllerFromUnderlyingSource( stream: ReadableByteStream, underlyingByteSource: ValidatedUnderlyingByteSource, highWaterMark: number ) { const controller: ReadableByteStreamController = Object.create(ReadableByteStreamController.prototype); let startAlgorithm: () => void | PromiseLike = () => undefined; let pullAlgorithm: () => Promise = () => promiseResolvedWith(undefined); let cancelAlgorithm: (reason: any) => Promise = () => promiseResolvedWith(undefined); if (underlyingByteSource.start !== undefined) { startAlgorithm = () => underlyingByteSource.start!(controller); } if (underlyingByteSource.pull !== undefined) { pullAlgorithm = () => underlyingByteSource.pull!(controller); } if (underlyingByteSource.cancel !== undefined) { cancelAlgorithm = reason => underlyingByteSource.cancel!(reason); } const autoAllocateChunkSize = underlyingByteSource.autoAllocateChunkSize; if (autoAllocateChunkSize === 0) { throw new TypeError('autoAllocateChunkSize must be greater than 0'); } SetUpReadableByteStreamController( stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, autoAllocateChunkSize ); } function SetUpReadableStreamBYOBRequest(request: ReadableStreamBYOBRequest, controller: ReadableByteStreamController, view: ArrayBufferView) { assert(IsReadableByteStreamController(controller)); assert(typeof view === 'object'); assert(ArrayBuffer.isView(view)); assert(!IsDetachedBuffer(view.buffer)); request._associatedReadableByteStreamController = controller; request._view = view; } // Helper functions for the ReadableStreamBYOBRequest. function byobRequestBrandCheckException(name: string): TypeError { return new TypeError( `ReadableStreamBYOBRequest.prototype.${name} can only be used on a ReadableStreamBYOBRequest`); } // Helper functions for the ReadableByteStreamController. function byteStreamControllerBrandCheckException(name: string): TypeError { return new TypeError( `ReadableByteStreamController.prototype.${name} can only be used on a ReadableByteStreamController`); } web-streams-polyfill-3.2.1/src/lib/readable-stream/default-controller.ts000066400000000000000000000302741422364423700263550ustar00rootroot00000000000000import { QueuingStrategySizeCallback } from '../queuing-strategy'; import assert from '../../stub/assert'; import { DequeueValue, EnqueueValueWithSize, QueuePair, ResetQueue } from '../abstract-ops/queue-with-sizes'; import { ReadableStreamAddReadRequest, ReadableStreamFulfillReadRequest, ReadableStreamGetNumReadRequests, ReadRequest } from './default-reader'; import { SimpleQueue } from '../simple-queue'; import { IsReadableStreamLocked, ReadableStream, ReadableStreamClose, ReadableStreamError } from '../readable-stream'; import { ValidatedUnderlyingSource } from './underlying-source'; import { typeIsObject } from '../helpers/miscellaneous'; import { CancelSteps, PullSteps } from '../abstract-ops/internal-methods'; import { promiseResolvedWith, uponPromise } from '../helpers/webidl'; /** * Allows control of a {@link ReadableStream | readable stream}'s state and internal queue. * * @public */ export class ReadableStreamDefaultController { /** @internal */ _controlledReadableStream!: ReadableStream; /** @internal */ _queue!: SimpleQueue>; /** @internal */ _queueTotalSize!: number; /** @internal */ _started!: boolean; /** @internal */ _closeRequested!: boolean; /** @internal */ _pullAgain!: boolean; /** @internal */ _pulling !: boolean; /** @internal */ _strategySizeAlgorithm!: QueuingStrategySizeCallback; /** @internal */ _strategyHWM!: number; /** @internal */ _pullAlgorithm!: () => Promise; /** @internal */ _cancelAlgorithm!: (reason: any) => Promise; private constructor() { throw new TypeError('Illegal constructor'); } /** * Returns the desired size to fill the controlled stream's internal queue. It can be negative, if the queue is * over-full. An underlying source ought to use this information to determine when and how to apply backpressure. */ get desiredSize(): number | null { if (!IsReadableStreamDefaultController(this)) { throw defaultControllerBrandCheckException('desiredSize'); } return ReadableStreamDefaultControllerGetDesiredSize(this); } /** * Closes the controlled readable stream. Consumers will still be able to read any previously-enqueued chunks from * the stream, but once those are read, the stream will become closed. */ close(): void { if (!IsReadableStreamDefaultController(this)) { throw defaultControllerBrandCheckException('close'); } if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) { throw new TypeError('The stream is not in a state that permits close'); } ReadableStreamDefaultControllerClose(this); } /** * Enqueues the given chunk `chunk` in the controlled readable stream. */ enqueue(chunk: R): void; enqueue(chunk: R = undefined!): void { if (!IsReadableStreamDefaultController(this)) { throw defaultControllerBrandCheckException('enqueue'); } if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(this)) { throw new TypeError('The stream is not in a state that permits enqueue'); } return ReadableStreamDefaultControllerEnqueue(this, chunk); } /** * Errors the controlled readable stream, making all future interactions with it fail with the given error `e`. */ error(e: any = undefined): void { if (!IsReadableStreamDefaultController(this)) { throw defaultControllerBrandCheckException('error'); } ReadableStreamDefaultControllerError(this, e); } /** @internal */ [CancelSteps](reason: any): Promise { ResetQueue(this); const result = this._cancelAlgorithm(reason); ReadableStreamDefaultControllerClearAlgorithms(this); return result; } /** @internal */ [PullSteps](readRequest: ReadRequest): void { const stream = this._controlledReadableStream; if (this._queue.length > 0) { const chunk = DequeueValue(this); if (this._closeRequested && this._queue.length === 0) { ReadableStreamDefaultControllerClearAlgorithms(this); ReadableStreamClose(stream); } else { ReadableStreamDefaultControllerCallPullIfNeeded(this); } readRequest._chunkSteps(chunk); } else { ReadableStreamAddReadRequest(stream, readRequest); ReadableStreamDefaultControllerCallPullIfNeeded(this); } } } Object.defineProperties(ReadableStreamDefaultController.prototype, { close: { enumerable: true }, enqueue: { enumerable: true }, error: { enumerable: true }, desiredSize: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(ReadableStreamDefaultController.prototype, Symbol.toStringTag, { value: 'ReadableStreamDefaultController', configurable: true }); } // Abstract operations for the ReadableStreamDefaultController. function IsReadableStreamDefaultController(x: any): x is ReadableStreamDefaultController { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_controlledReadableStream')) { return false; } return x instanceof ReadableStreamDefaultController; } function ReadableStreamDefaultControllerCallPullIfNeeded(controller: ReadableStreamDefaultController): void { const shouldPull = ReadableStreamDefaultControllerShouldCallPull(controller); if (!shouldPull) { return; } if (controller._pulling) { controller._pullAgain = true; return; } assert(!controller._pullAgain); controller._pulling = true; const pullPromise = controller._pullAlgorithm(); uponPromise( pullPromise, () => { controller._pulling = false; if (controller._pullAgain) { controller._pullAgain = false; ReadableStreamDefaultControllerCallPullIfNeeded(controller); } }, e => { ReadableStreamDefaultControllerError(controller, e); } ); } function ReadableStreamDefaultControllerShouldCallPull(controller: ReadableStreamDefaultController): boolean { const stream = controller._controlledReadableStream; if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller)) { return false; } if (!controller._started) { return false; } if (IsReadableStreamLocked(stream) && ReadableStreamGetNumReadRequests(stream) > 0) { return true; } const desiredSize = ReadableStreamDefaultControllerGetDesiredSize(controller); assert(desiredSize !== null); if (desiredSize! > 0) { return true; } return false; } function ReadableStreamDefaultControllerClearAlgorithms(controller: ReadableStreamDefaultController) { controller._pullAlgorithm = undefined!; controller._cancelAlgorithm = undefined!; controller._strategySizeAlgorithm = undefined!; } // A client of ReadableStreamDefaultController may use these functions directly to bypass state check. export function ReadableStreamDefaultControllerClose(controller: ReadableStreamDefaultController) { if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller)) { return; } const stream = controller._controlledReadableStream; controller._closeRequested = true; if (controller._queue.length === 0) { ReadableStreamDefaultControllerClearAlgorithms(controller); ReadableStreamClose(stream); } } export function ReadableStreamDefaultControllerEnqueue( controller: ReadableStreamDefaultController, chunk: R ): void { if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(controller)) { return; } const stream = controller._controlledReadableStream; if (IsReadableStreamLocked(stream) && ReadableStreamGetNumReadRequests(stream) > 0) { ReadableStreamFulfillReadRequest(stream, chunk, false); } else { let chunkSize; try { chunkSize = controller._strategySizeAlgorithm(chunk); } catch (chunkSizeE) { ReadableStreamDefaultControllerError(controller, chunkSizeE); throw chunkSizeE; } try { EnqueueValueWithSize(controller, chunk, chunkSize); } catch (enqueueE) { ReadableStreamDefaultControllerError(controller, enqueueE); throw enqueueE; } } ReadableStreamDefaultControllerCallPullIfNeeded(controller); } export function ReadableStreamDefaultControllerError(controller: ReadableStreamDefaultController, e: any) { const stream = controller._controlledReadableStream; if (stream._state !== 'readable') { return; } ResetQueue(controller); ReadableStreamDefaultControllerClearAlgorithms(controller); ReadableStreamError(stream, e); } export function ReadableStreamDefaultControllerGetDesiredSize( controller: ReadableStreamDefaultController ): number | null { const state = controller._controlledReadableStream._state; if (state === 'errored') { return null; } if (state === 'closed') { return 0; } return controller._strategyHWM - controller._queueTotalSize; } // This is used in the implementation of TransformStream. export function ReadableStreamDefaultControllerHasBackpressure( controller: ReadableStreamDefaultController ): boolean { if (ReadableStreamDefaultControllerShouldCallPull(controller)) { return false; } return true; } export function ReadableStreamDefaultControllerCanCloseOrEnqueue( controller: ReadableStreamDefaultController ): boolean { const state = controller._controlledReadableStream._state; if (!controller._closeRequested && state === 'readable') { return true; } return false; } export function SetUpReadableStreamDefaultController(stream: ReadableStream, controller: ReadableStreamDefaultController, startAlgorithm: () => void | PromiseLike, pullAlgorithm: () => Promise, cancelAlgorithm: (reason: any) => Promise, highWaterMark: number, sizeAlgorithm: QueuingStrategySizeCallback) { assert(stream._readableStreamController === undefined); controller._controlledReadableStream = stream; controller._queue = undefined!; controller._queueTotalSize = undefined!; ResetQueue(controller); controller._started = false; controller._closeRequested = false; controller._pullAgain = false; controller._pulling = false; controller._strategySizeAlgorithm = sizeAlgorithm; controller._strategyHWM = highWaterMark; controller._pullAlgorithm = pullAlgorithm; controller._cancelAlgorithm = cancelAlgorithm; stream._readableStreamController = controller; const startResult = startAlgorithm(); uponPromise( promiseResolvedWith(startResult), () => { controller._started = true; assert(!controller._pulling); assert(!controller._pullAgain); ReadableStreamDefaultControllerCallPullIfNeeded(controller); }, r => { ReadableStreamDefaultControllerError(controller, r); } ); } export function SetUpReadableStreamDefaultControllerFromUnderlyingSource( stream: ReadableStream, underlyingSource: ValidatedUnderlyingSource, highWaterMark: number, sizeAlgorithm: QueuingStrategySizeCallback ) { const controller: ReadableStreamDefaultController = Object.create(ReadableStreamDefaultController.prototype); let startAlgorithm: () => void | PromiseLike = () => undefined; let pullAlgorithm: () => Promise = () => promiseResolvedWith(undefined); let cancelAlgorithm: (reason: any) => Promise = () => promiseResolvedWith(undefined); if (underlyingSource.start !== undefined) { startAlgorithm = () => underlyingSource.start!(controller); } if (underlyingSource.pull !== undefined) { pullAlgorithm = () => underlyingSource.pull!(controller); } if (underlyingSource.cancel !== undefined) { cancelAlgorithm = reason => underlyingSource.cancel!(reason); } SetUpReadableStreamDefaultController( stream, controller, startAlgorithm, pullAlgorithm, cancelAlgorithm, highWaterMark, sizeAlgorithm ); } // Helper functions for the ReadableStreamDefaultController. function defaultControllerBrandCheckException(name: string): TypeError { return new TypeError( `ReadableStreamDefaultController.prototype.${name} can only be used on a ReadableStreamDefaultController`); } web-streams-polyfill-3.2.1/src/lib/readable-stream/default-reader.ts000066400000000000000000000175061422364423700254370ustar00rootroot00000000000000import assert from '../../stub/assert'; import { SimpleQueue } from '../simple-queue'; import { ReadableStreamReaderGenericCancel, ReadableStreamReaderGenericInitialize, ReadableStreamReaderGenericRelease, readerLockException } from './generic-reader'; import { IsReadableStreamLocked, ReadableStream } from '../readable-stream'; import { typeIsObject } from '../helpers/miscellaneous'; import { PullSteps } from '../abstract-ops/internal-methods'; import { newPromise, promiseRejectedWith } from '../helpers/webidl'; import { assertRequiredArgument } from '../validators/basic'; import { assertReadableStream } from '../validators/readable-stream'; /** * A result returned by {@link ReadableStreamDefaultReader.read}. * * @public */ export type ReadableStreamDefaultReadResult = { done: false; value: T; } | { done: true; value?: undefined; } // Abstract operations for the ReadableStream. export function AcquireReadableStreamDefaultReader(stream: ReadableStream): ReadableStreamDefaultReader { return new ReadableStreamDefaultReader(stream); } // ReadableStream API exposed for controllers. export function ReadableStreamAddReadRequest(stream: ReadableStream, readRequest: ReadRequest): void { assert(IsReadableStreamDefaultReader(stream._reader)); assert(stream._state === 'readable'); (stream._reader! as ReadableStreamDefaultReader)._readRequests.push(readRequest); } export function ReadableStreamFulfillReadRequest(stream: ReadableStream, chunk: R | undefined, done: boolean) { const reader = stream._reader as ReadableStreamDefaultReader; assert(reader._readRequests.length > 0); const readRequest = reader._readRequests.shift()!; if (done) { readRequest._closeSteps(); } else { readRequest._chunkSteps(chunk!); } } export function ReadableStreamGetNumReadRequests(stream: ReadableStream): number { return (stream._reader as ReadableStreamDefaultReader)._readRequests.length; } export function ReadableStreamHasDefaultReader(stream: ReadableStream): boolean { const reader = stream._reader; if (reader === undefined) { return false; } if (!IsReadableStreamDefaultReader(reader)) { return false; } return true; } // Readers export interface ReadRequest { _chunkSteps(chunk: R): void; _closeSteps(): void; _errorSteps(e: any): void; } /** * A default reader vended by a {@link ReadableStream}. * * @public */ export class ReadableStreamDefaultReader { /** @internal */ _ownerReadableStream!: ReadableStream; /** @internal */ _closedPromise!: Promise; /** @internal */ _closedPromise_resolve?: (value?: undefined) => void; /** @internal */ _closedPromise_reject?: (reason: any) => void; /** @internal */ _readRequests: SimpleQueue>; constructor(stream: ReadableStream) { assertRequiredArgument(stream, 1, 'ReadableStreamDefaultReader'); assertReadableStream(stream, 'First parameter'); if (IsReadableStreamLocked(stream)) { throw new TypeError('This stream has already been locked for exclusive reading by another reader'); } ReadableStreamReaderGenericInitialize(this, stream); this._readRequests = new SimpleQueue(); } /** * Returns a promise that will be fulfilled when the stream becomes closed, * or rejected if the stream ever errors or the reader's lock is released before the stream finishes closing. */ get closed(): Promise { if (!IsReadableStreamDefaultReader(this)) { return promiseRejectedWith(defaultReaderBrandCheckException('closed')); } return this._closedPromise; } /** * If the reader is active, behaves the same as {@link ReadableStream.cancel | stream.cancel(reason)}. */ cancel(reason: any = undefined): Promise { if (!IsReadableStreamDefaultReader(this)) { return promiseRejectedWith(defaultReaderBrandCheckException('cancel')); } if (this._ownerReadableStream === undefined) { return promiseRejectedWith(readerLockException('cancel')); } return ReadableStreamReaderGenericCancel(this, reason); } /** * Returns a promise that allows access to the next chunk from the stream's internal queue, if available. * * If reading a chunk causes the queue to become empty, more data will be pulled from the underlying source. */ read(): Promise> { if (!IsReadableStreamDefaultReader(this)) { return promiseRejectedWith(defaultReaderBrandCheckException('read')); } if (this._ownerReadableStream === undefined) { return promiseRejectedWith(readerLockException('read from')); } let resolvePromise!: (result: ReadableStreamDefaultReadResult) => void; let rejectPromise!: (reason: any) => void; const promise = newPromise>((resolve, reject) => { resolvePromise = resolve; rejectPromise = reject; }); const readRequest: ReadRequest = { _chunkSteps: chunk => resolvePromise({ value: chunk, done: false }), _closeSteps: () => resolvePromise({ value: undefined, done: true }), _errorSteps: e => rejectPromise(e) }; ReadableStreamDefaultReaderRead(this, readRequest); return promise; } /** * Releases the reader's lock on the corresponding stream. After the lock is released, the reader is no longer active. * If the associated stream is errored when the lock is released, the reader will appear errored in the same way * from now on; otherwise, the reader will appear closed. * * A reader's lock cannot be released while it still has a pending read request, i.e., if a promise returned by * the reader's {@link ReadableStreamDefaultReader.read | read()} method has not yet been settled. Attempting to * do so will throw a `TypeError` and leave the reader locked to the stream. */ releaseLock(): void { if (!IsReadableStreamDefaultReader(this)) { throw defaultReaderBrandCheckException('releaseLock'); } if (this._ownerReadableStream === undefined) { return; } if (this._readRequests.length > 0) { throw new TypeError('Tried to release a reader lock when that reader has pending read() calls un-settled'); } ReadableStreamReaderGenericRelease(this); } } Object.defineProperties(ReadableStreamDefaultReader.prototype, { cancel: { enumerable: true }, read: { enumerable: true }, releaseLock: { enumerable: true }, closed: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(ReadableStreamDefaultReader.prototype, Symbol.toStringTag, { value: 'ReadableStreamDefaultReader', configurable: true }); } // Abstract operations for the readers. export function IsReadableStreamDefaultReader(x: any): x is ReadableStreamDefaultReader { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_readRequests')) { return false; } return x instanceof ReadableStreamDefaultReader; } export function ReadableStreamDefaultReaderRead(reader: ReadableStreamDefaultReader, readRequest: ReadRequest): void { const stream = reader._ownerReadableStream; assert(stream !== undefined); stream._disturbed = true; if (stream._state === 'closed') { readRequest._closeSteps(); } else if (stream._state === 'errored') { readRequest._errorSteps(stream._storedError); } else { assert(stream._state === 'readable'); stream._readableStreamController[PullSteps](readRequest as ReadRequest); } } // Helper functions for the ReadableStreamDefaultReader. function defaultReaderBrandCheckException(name: string): TypeError { return new TypeError( `ReadableStreamDefaultReader.prototype.${name} can only be used on a ReadableStreamDefaultReader`); } web-streams-polyfill-3.2.1/src/lib/readable-stream/generic-reader.ts000066400000000000000000000070721422364423700254240ustar00rootroot00000000000000import assert from '../../stub/assert'; import { ReadableStream, ReadableStreamCancel, ReadableStreamReader } from '../readable-stream'; import { newPromise, setPromiseIsHandledToTrue } from '../helpers/webidl'; export function ReadableStreamReaderGenericInitialize(reader: ReadableStreamReader, stream: ReadableStream) { reader._ownerReadableStream = stream; stream._reader = reader; if (stream._state === 'readable') { defaultReaderClosedPromiseInitialize(reader); } else if (stream._state === 'closed') { defaultReaderClosedPromiseInitializeAsResolved(reader); } else { assert(stream._state === 'errored'); defaultReaderClosedPromiseInitializeAsRejected(reader, stream._storedError); } } // A client of ReadableStreamDefaultReader and ReadableStreamBYOBReader may use these functions directly to bypass state // check. export function ReadableStreamReaderGenericCancel(reader: ReadableStreamReader, reason: any): Promise { const stream = reader._ownerReadableStream; assert(stream !== undefined); return ReadableStreamCancel(stream, reason); } export function ReadableStreamReaderGenericRelease(reader: ReadableStreamReader) { assert(reader._ownerReadableStream !== undefined); assert(reader._ownerReadableStream._reader === reader); if (reader._ownerReadableStream._state === 'readable') { defaultReaderClosedPromiseReject( reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`)); } else { defaultReaderClosedPromiseResetToRejected( reader, new TypeError(`Reader was released and can no longer be used to monitor the stream's closedness`)); } reader._ownerReadableStream._reader = undefined; reader._ownerReadableStream = undefined!; } // Helper functions for the readers. export function readerLockException(name: string): TypeError { return new TypeError('Cannot ' + name + ' a stream using a released reader'); } // Helper functions for the ReadableStreamDefaultReader. export function defaultReaderClosedPromiseInitialize(reader: ReadableStreamReader) { reader._closedPromise = newPromise((resolve, reject) => { reader._closedPromise_resolve = resolve; reader._closedPromise_reject = reject; }); } export function defaultReaderClosedPromiseInitializeAsRejected(reader: ReadableStreamReader, reason: any) { defaultReaderClosedPromiseInitialize(reader); defaultReaderClosedPromiseReject(reader, reason); } export function defaultReaderClosedPromiseInitializeAsResolved(reader: ReadableStreamReader) { defaultReaderClosedPromiseInitialize(reader); defaultReaderClosedPromiseResolve(reader); } export function defaultReaderClosedPromiseReject(reader: ReadableStreamReader, reason: any) { if (reader._closedPromise_reject === undefined) { return; } setPromiseIsHandledToTrue(reader._closedPromise); reader._closedPromise_reject(reason); reader._closedPromise_resolve = undefined; reader._closedPromise_reject = undefined; } export function defaultReaderClosedPromiseResetToRejected(reader: ReadableStreamReader, reason: any) { assert(reader._closedPromise_resolve === undefined); assert(reader._closedPromise_reject === undefined); defaultReaderClosedPromiseInitializeAsRejected(reader, reason); } export function defaultReaderClosedPromiseResolve(reader: ReadableStreamReader) { if (reader._closedPromise_resolve === undefined) { return; } reader._closedPromise_resolve(undefined); reader._closedPromise_resolve = undefined; reader._closedPromise_reject = undefined; } web-streams-polyfill-3.2.1/src/lib/readable-stream/iterator-options.ts000066400000000000000000000004141422364423700260630ustar00rootroot00000000000000/** * Options for {@link ReadableStream.values | async iterating} a stream. * * @public */ export interface ReadableStreamIteratorOptions { preventCancel?: boolean; } export type ValidatedReadableStreamIteratorOptions = Required; web-streams-polyfill-3.2.1/src/lib/readable-stream/pipe-options.ts000066400000000000000000000022021422364423700251640ustar00rootroot00000000000000import { AbortSignal } from '../abort-signal'; /** * Options for {@link ReadableStream.pipeTo | piping} a stream. * * @public */ export interface StreamPipeOptions { /** * If set to true, {@link ReadableStream.pipeTo} will not abort the writable stream if the readable stream errors. */ preventAbort?: boolean; /** * If set to true, {@link ReadableStream.pipeTo} will not cancel the readable stream if the writable stream closes * or errors. */ preventCancel?: boolean; /** * If set to true, {@link ReadableStream.pipeTo} will not close the writable stream if the readable stream closes. */ preventClose?: boolean; /** * Can be set to an {@link AbortSignal} to allow aborting an ongoing pipe operation via the corresponding * `AbortController`. In this case, the source readable stream will be canceled, and the destination writable stream * aborted, unless the respective options `preventCancel` or `preventAbort` are set. */ signal?: AbortSignal; } export interface ValidatedStreamPipeOptions { preventAbort: boolean; preventCancel: boolean; preventClose: boolean; signal?: AbortSignal; } web-streams-polyfill-3.2.1/src/lib/readable-stream/pipe.ts000066400000000000000000000176451422364423700235140ustar00rootroot00000000000000import { IsReadableStream, IsReadableStreamLocked, ReadableStream, ReadableStreamCancel } from '../readable-stream'; import { AcquireReadableStreamDefaultReader, ReadableStreamDefaultReaderRead } from './default-reader'; import { ReadableStreamReaderGenericRelease } from './generic-reader'; import { AcquireWritableStreamDefaultWriter, IsWritableStream, IsWritableStreamLocked, WritableStream, WritableStreamAbort, WritableStreamCloseQueuedOrInFlight, WritableStreamDefaultWriterCloseWithErrorPropagation, WritableStreamDefaultWriterRelease, WritableStreamDefaultWriterWrite } from '../writable-stream'; import assert from '../../stub/assert'; import { newPromise, PerformPromiseThen, promiseResolvedWith, setPromiseIsHandledToTrue, uponFulfillment, uponPromise, uponRejection } from '../helpers/webidl'; import { noop } from '../../utils'; import { AbortSignal, isAbortSignal } from '../abort-signal'; import { DOMException } from '../../stub/dom-exception'; export function ReadableStreamPipeTo(source: ReadableStream, dest: WritableStream, preventClose: boolean, preventAbort: boolean, preventCancel: boolean, signal: AbortSignal | undefined): Promise { assert(IsReadableStream(source)); assert(IsWritableStream(dest)); assert(typeof preventClose === 'boolean'); assert(typeof preventAbort === 'boolean'); assert(typeof preventCancel === 'boolean'); assert(signal === undefined || isAbortSignal(signal)); assert(!IsReadableStreamLocked(source)); assert(!IsWritableStreamLocked(dest)); const reader = AcquireReadableStreamDefaultReader(source); const writer = AcquireWritableStreamDefaultWriter(dest); source._disturbed = true; let shuttingDown = false; // This is used to keep track of the spec's requirement that we wait for ongoing writes during shutdown. let currentWrite = promiseResolvedWith(undefined); return newPromise((resolve, reject) => { let abortAlgorithm: () => void; if (signal !== undefined) { abortAlgorithm = () => { const error = new DOMException('Aborted', 'AbortError'); const actions: Array<() => Promise> = []; if (!preventAbort) { actions.push(() => { if (dest._state === 'writable') { return WritableStreamAbort(dest, error); } return promiseResolvedWith(undefined); }); } if (!preventCancel) { actions.push(() => { if (source._state === 'readable') { return ReadableStreamCancel(source, error); } return promiseResolvedWith(undefined); }); } shutdownWithAction(() => Promise.all(actions.map(action => action())), true, error); }; if (signal.aborted) { abortAlgorithm(); return; } signal.addEventListener('abort', abortAlgorithm); } // Using reader and writer, read all chunks from this and write them to dest // - Backpressure must be enforced // - Shutdown must stop all activity function pipeLoop() { return newPromise((resolveLoop, rejectLoop) => { function next(done: boolean) { if (done) { resolveLoop(); } else { // Use `PerformPromiseThen` instead of `uponPromise` to avoid // adding unnecessary `.catch(rethrowAssertionErrorRejection)` handlers PerformPromiseThen(pipeStep(), next, rejectLoop); } } next(false); }); } function pipeStep(): Promise { if (shuttingDown) { return promiseResolvedWith(true); } return PerformPromiseThen(writer._readyPromise, () => { return newPromise((resolveRead, rejectRead) => { ReadableStreamDefaultReaderRead( reader, { _chunkSteps: chunk => { currentWrite = PerformPromiseThen(WritableStreamDefaultWriterWrite(writer, chunk), undefined, noop); resolveRead(false); }, _closeSteps: () => resolveRead(true), _errorSteps: rejectRead } ); }); }); } // Errors must be propagated forward isOrBecomesErrored(source, reader._closedPromise, storedError => { if (!preventAbort) { shutdownWithAction(() => WritableStreamAbort(dest, storedError), true, storedError); } else { shutdown(true, storedError); } }); // Errors must be propagated backward isOrBecomesErrored(dest, writer._closedPromise, storedError => { if (!preventCancel) { shutdownWithAction(() => ReadableStreamCancel(source, storedError), true, storedError); } else { shutdown(true, storedError); } }); // Closing must be propagated forward isOrBecomesClosed(source, reader._closedPromise, () => { if (!preventClose) { shutdownWithAction(() => WritableStreamDefaultWriterCloseWithErrorPropagation(writer)); } else { shutdown(); } }); // Closing must be propagated backward if (WritableStreamCloseQueuedOrInFlight(dest) || dest._state === 'closed') { const destClosed = new TypeError('the destination writable stream closed before all data could be piped to it'); if (!preventCancel) { shutdownWithAction(() => ReadableStreamCancel(source, destClosed), true, destClosed); } else { shutdown(true, destClosed); } } setPromiseIsHandledToTrue(pipeLoop()); function waitForWritesToFinish(): Promise { // Another write may have started while we were waiting on this currentWrite, so we have to be sure to wait // for that too. const oldCurrentWrite = currentWrite; return PerformPromiseThen( currentWrite, () => oldCurrentWrite !== currentWrite ? waitForWritesToFinish() : undefined ); } function isOrBecomesErrored(stream: ReadableStream | WritableStream, promise: Promise, action: (reason: any) => void) { if (stream._state === 'errored') { action(stream._storedError); } else { uponRejection(promise, action); } } function isOrBecomesClosed(stream: ReadableStream | WritableStream, promise: Promise, action: () => void) { if (stream._state === 'closed') { action(); } else { uponFulfillment(promise, action); } } function shutdownWithAction(action: () => Promise, originalIsError?: boolean, originalError?: any) { if (shuttingDown) { return; } shuttingDown = true; if (dest._state === 'writable' && !WritableStreamCloseQueuedOrInFlight(dest)) { uponFulfillment(waitForWritesToFinish(), doTheRest); } else { doTheRest(); } function doTheRest() { uponPromise( action(), () => finalize(originalIsError, originalError), newError => finalize(true, newError) ); } } function shutdown(isError?: boolean, error?: any) { if (shuttingDown) { return; } shuttingDown = true; if (dest._state === 'writable' && !WritableStreamCloseQueuedOrInFlight(dest)) { uponFulfillment(waitForWritesToFinish(), () => finalize(isError, error)); } else { finalize(isError, error); } } function finalize(isError?: boolean, error?: any) { WritableStreamDefaultWriterRelease(writer); ReadableStreamReaderGenericRelease(reader); if (signal !== undefined) { signal.removeEventListener('abort', abortAlgorithm); } if (isError) { reject(error); } else { resolve(undefined); } } }); } web-streams-polyfill-3.2.1/src/lib/readable-stream/readable-writable-pair.ts000066400000000000000000000006211422364423700270400ustar00rootroot00000000000000import { ReadableStream } from '../readable-stream'; import { WritableStream } from '../writable-stream'; /** * A pair of a {@link ReadableStream | readable stream} and {@link WritableStream | writable stream} that can be passed * to {@link ReadableStream.pipeThrough}. * * @public */ export interface ReadableWritablePair { readable: ReadableStream; writable: WritableStream; } web-streams-polyfill-3.2.1/src/lib/readable-stream/reader-options.ts000066400000000000000000000001051422364423700254710ustar00rootroot00000000000000export interface ReadableStreamGetReaderOptions { mode?: 'byob'; } web-streams-polyfill-3.2.1/src/lib/readable-stream/tee.ts000066400000000000000000000355251422364423700233310ustar00rootroot00000000000000import { CreateReadableByteStream, CreateReadableStream, IsReadableStream, ReadableByteStream, ReadableStream, ReadableStreamCancel, ReadableStreamReader } from '../readable-stream'; import { ReadableStreamReaderGenericRelease } from './generic-reader'; import { AcquireReadableStreamDefaultReader, IsReadableStreamDefaultReader, ReadableStreamDefaultReaderRead, ReadRequest } from './default-reader'; import { AcquireReadableStreamBYOBReader, IsReadableStreamBYOBReader, ReadableStreamBYOBReaderRead, ReadIntoRequest } from './byob-reader'; import assert from '../../stub/assert'; import { newPromise, promiseResolvedWith, queueMicrotask, uponRejection } from '../helpers/webidl'; import { ReadableStreamDefaultController, ReadableStreamDefaultControllerClose, ReadableStreamDefaultControllerEnqueue, ReadableStreamDefaultControllerError } from './default-controller'; import { IsReadableByteStreamController, ReadableByteStreamControllerClose, ReadableByteStreamControllerEnqueue, ReadableByteStreamControllerError, ReadableByteStreamControllerGetBYOBRequest, ReadableByteStreamControllerRespond, ReadableByteStreamControllerRespondWithNewView } from './byte-stream-controller'; import { CreateArrayFromList } from '../abstract-ops/ecmascript'; import { CloneAsUint8Array } from '../abstract-ops/miscellaneous'; export function ReadableStreamTee(stream: ReadableStream, cloneForBranch2: boolean): [ReadableStream, ReadableStream] { assert(IsReadableStream(stream)); assert(typeof cloneForBranch2 === 'boolean'); if (IsReadableByteStreamController(stream._readableStreamController)) { return ReadableByteStreamTee(stream as unknown as ReadableByteStream) as unknown as [ReadableStream, ReadableStream]; } return ReadableStreamDefaultTee(stream, cloneForBranch2); } export function ReadableStreamDefaultTee(stream: ReadableStream, cloneForBranch2: boolean): [ReadableStream, ReadableStream] { assert(IsReadableStream(stream)); assert(typeof cloneForBranch2 === 'boolean'); const reader = AcquireReadableStreamDefaultReader(stream); let reading = false; let readAgain = false; let canceled1 = false; let canceled2 = false; let reason1: any; let reason2: any; let branch1: ReadableStream; let branch2: ReadableStream; let resolveCancelPromise: (value: undefined | Promise) => void; const cancelPromise = newPromise(resolve => { resolveCancelPromise = resolve; }); function pullAlgorithm(): Promise { if (reading) { readAgain = true; return promiseResolvedWith(undefined); } reading = true; const readRequest: ReadRequest = { _chunkSteps: chunk => { // This needs to be delayed a microtask because it takes at least a microtask to detect errors (using // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let // successful synchronously-available reads get ahead of asynchronously-available errors. queueMicrotask(() => { readAgain = false; const chunk1 = chunk; const chunk2 = chunk; // There is no way to access the cloning code right now in the reference implementation. // If we add one then we'll need an implementation for serializable objects. // if (!canceled2 && cloneForBranch2) { // chunk2 = StructuredDeserialize(StructuredSerialize(chunk2)); // } if (!canceled1) { ReadableStreamDefaultControllerEnqueue( branch1._readableStreamController as ReadableStreamDefaultController, chunk1 ); } if (!canceled2) { ReadableStreamDefaultControllerEnqueue( branch2._readableStreamController as ReadableStreamDefaultController, chunk2 ); } reading = false; if (readAgain) { pullAlgorithm(); } }); }, _closeSteps: () => { reading = false; if (!canceled1) { ReadableStreamDefaultControllerClose(branch1._readableStreamController as ReadableStreamDefaultController); } if (!canceled2) { ReadableStreamDefaultControllerClose(branch2._readableStreamController as ReadableStreamDefaultController); } if (!canceled1 || !canceled2) { resolveCancelPromise(undefined); } }, _errorSteps: () => { reading = false; } }; ReadableStreamDefaultReaderRead(reader, readRequest); return promiseResolvedWith(undefined); } function cancel1Algorithm(reason: any): Promise { canceled1 = true; reason1 = reason; if (canceled2) { const compositeReason = CreateArrayFromList([reason1, reason2]); const cancelResult = ReadableStreamCancel(stream, compositeReason); resolveCancelPromise(cancelResult); } return cancelPromise; } function cancel2Algorithm(reason: any): Promise { canceled2 = true; reason2 = reason; if (canceled1) { const compositeReason = CreateArrayFromList([reason1, reason2]); const cancelResult = ReadableStreamCancel(stream, compositeReason); resolveCancelPromise(cancelResult); } return cancelPromise; } function startAlgorithm() { // do nothing } branch1 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel1Algorithm); branch2 = CreateReadableStream(startAlgorithm, pullAlgorithm, cancel2Algorithm); uponRejection(reader._closedPromise, (r: any) => { ReadableStreamDefaultControllerError(branch1._readableStreamController as ReadableStreamDefaultController, r); ReadableStreamDefaultControllerError(branch2._readableStreamController as ReadableStreamDefaultController, r); if (!canceled1 || !canceled2) { resolveCancelPromise(undefined); } }); return [branch1, branch2]; } export function ReadableByteStreamTee(stream: ReadableByteStream): [ReadableByteStream, ReadableByteStream] { assert(IsReadableStream(stream)); assert(IsReadableByteStreamController(stream._readableStreamController)); let reader: ReadableStreamReader = AcquireReadableStreamDefaultReader(stream); let reading = false; let readAgainForBranch1 = false; let readAgainForBranch2 = false; let canceled1 = false; let canceled2 = false; let reason1: any; let reason2: any; let branch1: ReadableByteStream; let branch2: ReadableByteStream; let resolveCancelPromise: (value: undefined | Promise) => void; const cancelPromise = newPromise(resolve => { resolveCancelPromise = resolve; }); function forwardReaderError(thisReader: ReadableStreamReader) { uponRejection(thisReader._closedPromise, r => { if (thisReader !== reader) { return; } ReadableByteStreamControllerError(branch1._readableStreamController, r); ReadableByteStreamControllerError(branch2._readableStreamController, r); if (!canceled1 || !canceled2) { resolveCancelPromise(undefined); } }); } function pullWithDefaultReader() { if (IsReadableStreamBYOBReader(reader)) { assert(reader._readIntoRequests.length === 0); ReadableStreamReaderGenericRelease(reader); reader = AcquireReadableStreamDefaultReader(stream); forwardReaderError(reader); } const readRequest: ReadRequest = { _chunkSteps: chunk => { // This needs to be delayed a microtask because it takes at least a microtask to detect errors (using // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let // successful synchronously-available reads get ahead of asynchronously-available errors. queueMicrotask(() => { readAgainForBranch1 = false; readAgainForBranch2 = false; const chunk1 = chunk; let chunk2 = chunk; if (!canceled1 && !canceled2) { try { chunk2 = CloneAsUint8Array(chunk); } catch (cloneE) { ReadableByteStreamControllerError(branch1._readableStreamController, cloneE); ReadableByteStreamControllerError(branch2._readableStreamController, cloneE); resolveCancelPromise(ReadableStreamCancel(stream, cloneE)); return; } } if (!canceled1) { ReadableByteStreamControllerEnqueue(branch1._readableStreamController, chunk1); } if (!canceled2) { ReadableByteStreamControllerEnqueue(branch2._readableStreamController, chunk2); } reading = false; if (readAgainForBranch1) { pull1Algorithm(); } else if (readAgainForBranch2) { pull2Algorithm(); } }); }, _closeSteps: () => { reading = false; if (!canceled1) { ReadableByteStreamControllerClose(branch1._readableStreamController); } if (!canceled2) { ReadableByteStreamControllerClose(branch2._readableStreamController); } if (branch1._readableStreamController._pendingPullIntos.length > 0) { ReadableByteStreamControllerRespond(branch1._readableStreamController, 0); } if (branch2._readableStreamController._pendingPullIntos.length > 0) { ReadableByteStreamControllerRespond(branch2._readableStreamController, 0); } if (!canceled1 || !canceled2) { resolveCancelPromise(undefined); } }, _errorSteps: () => { reading = false; } }; ReadableStreamDefaultReaderRead(reader, readRequest); } function pullWithBYOBReader(view: ArrayBufferView, forBranch2: boolean) { if (IsReadableStreamDefaultReader(reader)) { assert(reader._readRequests.length === 0); ReadableStreamReaderGenericRelease(reader); reader = AcquireReadableStreamBYOBReader(stream); forwardReaderError(reader); } const byobBranch = forBranch2 ? branch2 : branch1; const otherBranch = forBranch2 ? branch1 : branch2; const readIntoRequest: ReadIntoRequest = { _chunkSteps: chunk => { // This needs to be delayed a microtask because it takes at least a microtask to detect errors (using // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let // successful synchronously-available reads get ahead of asynchronously-available errors. queueMicrotask(() => { readAgainForBranch1 = false; readAgainForBranch2 = false; const byobCanceled = forBranch2 ? canceled2 : canceled1; const otherCanceled = forBranch2 ? canceled1 : canceled2; if (!otherCanceled) { let clonedChunk; try { clonedChunk = CloneAsUint8Array(chunk); } catch (cloneE) { ReadableByteStreamControllerError(byobBranch._readableStreamController, cloneE); ReadableByteStreamControllerError(otherBranch._readableStreamController, cloneE); resolveCancelPromise(ReadableStreamCancel(stream, cloneE)); return; } if (!byobCanceled) { ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk); } ReadableByteStreamControllerEnqueue(otherBranch._readableStreamController, clonedChunk); } else if (!byobCanceled) { ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk); } reading = false; if (readAgainForBranch1) { pull1Algorithm(); } else if (readAgainForBranch2) { pull2Algorithm(); } }); }, _closeSteps: chunk => { reading = false; const byobCanceled = forBranch2 ? canceled2 : canceled1; const otherCanceled = forBranch2 ? canceled1 : canceled2; if (!byobCanceled) { ReadableByteStreamControllerClose(byobBranch._readableStreamController); } if (!otherCanceled) { ReadableByteStreamControllerClose(otherBranch._readableStreamController); } if (chunk !== undefined) { assert(chunk.byteLength === 0); if (!byobCanceled) { ReadableByteStreamControllerRespondWithNewView(byobBranch._readableStreamController, chunk); } if (!otherCanceled && otherBranch._readableStreamController._pendingPullIntos.length > 0) { ReadableByteStreamControllerRespond(otherBranch._readableStreamController, 0); } } if (!byobCanceled || !otherCanceled) { resolveCancelPromise(undefined); } }, _errorSteps: () => { reading = false; } }; ReadableStreamBYOBReaderRead(reader, view, readIntoRequest); } function pull1Algorithm(): Promise { if (reading) { readAgainForBranch1 = true; return promiseResolvedWith(undefined); } reading = true; const byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch1._readableStreamController); if (byobRequest === null) { pullWithDefaultReader(); } else { pullWithBYOBReader(byobRequest._view!, false); } return promiseResolvedWith(undefined); } function pull2Algorithm(): Promise { if (reading) { readAgainForBranch2 = true; return promiseResolvedWith(undefined); } reading = true; const byobRequest = ReadableByteStreamControllerGetBYOBRequest(branch2._readableStreamController); if (byobRequest === null) { pullWithDefaultReader(); } else { pullWithBYOBReader(byobRequest._view!, true); } return promiseResolvedWith(undefined); } function cancel1Algorithm(reason: any): Promise { canceled1 = true; reason1 = reason; if (canceled2) { const compositeReason = CreateArrayFromList([reason1, reason2]); const cancelResult = ReadableStreamCancel(stream, compositeReason); resolveCancelPromise(cancelResult); } return cancelPromise; } function cancel2Algorithm(reason: any): Promise { canceled2 = true; reason2 = reason; if (canceled1) { const compositeReason = CreateArrayFromList([reason1, reason2]); const cancelResult = ReadableStreamCancel(stream, compositeReason); resolveCancelPromise(cancelResult); } return cancelPromise; } function startAlgorithm(): void { return; } branch1 = CreateReadableByteStream(startAlgorithm, pull1Algorithm, cancel1Algorithm); branch2 = CreateReadableByteStream(startAlgorithm, pull2Algorithm, cancel2Algorithm); forwardReaderError(reader); return [branch1, branch2]; } web-streams-polyfill-3.2.1/src/lib/readable-stream/underlying-source.ts000066400000000000000000000106721422364423700262260ustar00rootroot00000000000000import { ReadableStreamDefaultController } from './default-controller'; import { ReadableByteStreamController } from './byte-stream-controller'; export type ReadableStreamController = ReadableStreamDefaultController | ReadableByteStreamController; export type UnderlyingDefaultOrByteSourceStartCallback = (controller: ReadableStreamController) => void | PromiseLike; export type UnderlyingDefaultOrByteSourcePullCallback = (controller: ReadableStreamController) => void | PromiseLike; /** @public */ export type UnderlyingSourceStartCallback = (controller: ReadableStreamDefaultController) => void | PromiseLike; /** @public */ export type UnderlyingSourcePullCallback = (controller: ReadableStreamDefaultController) => void | PromiseLike; /** @public */ export type UnderlyingByteSourceStartCallback = (controller: ReadableByteStreamController) => void | PromiseLike; /** @public */ export type UnderlyingByteSourcePullCallback = (controller: ReadableByteStreamController) => void | PromiseLike; /** @public */ export type UnderlyingSourceCancelCallback = (reason: any) => void | PromiseLike; export type ReadableStreamType = 'bytes'; /** * An underlying source for constructing a {@link ReadableStream}. * * @public */ export interface UnderlyingSource { /** * A function that is called immediately during creation of the {@link ReadableStream}. */ start?: UnderlyingSourceStartCallback; /** * A function that is called whenever the stream’s internal queue of chunks becomes not full, * i.e. whenever the queue’s desired size becomes positive. Generally, it will be called repeatedly * until the queue reaches its high water mark (i.e. until the desired size becomes non-positive). */ pull?: UnderlyingSourcePullCallback; /** * A function that is called whenever the consumer cancels the stream, via * {@link ReadableStream.cancel | stream.cancel()}, * {@link ReadableStreamDefaultReader.cancel | defaultReader.cancel()}, or * {@link ReadableStreamBYOBReader.cancel | byobReader.cancel()}. * It takes as its argument the same value as was passed to those methods by the consumer. */ cancel?: UnderlyingSourceCancelCallback; type?: undefined; } /** * An underlying byte source for constructing a {@link ReadableStream}. * * @public */ export interface UnderlyingByteSource { /** * {@inheritDoc UnderlyingSource.start} */ start?: UnderlyingByteSourceStartCallback; /** * {@inheritDoc UnderlyingSource.pull} */ pull?: UnderlyingByteSourcePullCallback; /** * {@inheritDoc UnderlyingSource.cancel} */ cancel?: UnderlyingSourceCancelCallback; /** * Can be set to "bytes" to signal that the constructed {@link ReadableStream} is a readable byte stream. * This ensures that the resulting {@link ReadableStream} will successfully be able to vend BYOB readers via its * {@link ReadableStream.(getReader:1) | getReader()} method. * It also affects the controller argument passed to the {@link UnderlyingByteSource.start | start()} * and {@link UnderlyingByteSource.pull | pull()} methods. */ type: 'bytes'; /** * Can be set to a positive integer to cause the implementation to automatically allocate buffers for the * underlying source code to write into. In this case, when a consumer is using a default reader, the stream * implementation will automatically allocate an ArrayBuffer of the given size, so that * {@link ReadableByteStreamController.byobRequest | controller.byobRequest} is always present, * as if the consumer was using a BYOB reader. */ autoAllocateChunkSize?: number; } export interface UnderlyingDefaultOrByteSource { start?: UnderlyingDefaultOrByteSourceStartCallback; pull?: UnderlyingDefaultOrByteSourcePullCallback; cancel?: UnderlyingSourceCancelCallback; type?: ReadableStreamType; autoAllocateChunkSize?: number; } export interface ValidatedUnderlyingSource extends UnderlyingSource { pull?: (controller: ReadableStreamDefaultController) => Promise; cancel?: (reason: any) => Promise; } export interface ValidatedUnderlyingByteSource extends UnderlyingByteSource { pull?: (controller: ReadableByteStreamController) => Promise; cancel?: (reason: any) => Promise; } export type ValidatedUnderlyingDefaultOrByteSource = | ValidatedUnderlyingSource | ValidatedUnderlyingByteSource; web-streams-polyfill-3.2.1/src/lib/simple-queue.ts000066400000000000000000000100411422364423700221210ustar00rootroot00000000000000import assert from '../stub/assert'; // Original from Chromium // https://chromium.googlesource.com/chromium/src/+/0aee4434a4dba42a42abaea9bfbc0cd196a63bc1/third_party/blink/renderer/core/streams/SimpleQueue.js const QUEUE_MAX_ARRAY_SIZE = 16384; interface Node { _elements: T[]; _next: Node | undefined; } /** * Simple queue structure. * * Avoids scalability issues with using a packed array directly by using * multiple arrays in a linked list and keeping the array size bounded. */ export class SimpleQueue { private _front: Node; private _back: Node; private _cursor = 0; private _size = 0; constructor() { // _front and _back are always defined. this._front = { _elements: [], _next: undefined }; this._back = this._front; // The cursor is used to avoid calling Array.shift(). // It contains the index of the front element of the array inside the // front-most node. It is always in the range [0, QUEUE_MAX_ARRAY_SIZE). this._cursor = 0; // When there is only one node, size === elements.length - cursor. this._size = 0; } get length(): number { return this._size; } // For exception safety, this method is structured in order: // 1. Read state // 2. Calculate required state mutations // 3. Perform state mutations push(element: T): void { const oldBack = this._back; let newBack = oldBack; assert(oldBack._next === undefined); if (oldBack._elements.length === QUEUE_MAX_ARRAY_SIZE - 1) { newBack = { _elements: [], _next: undefined }; } // push() is the mutation most likely to throw an exception, so it // goes first. oldBack._elements.push(element); if (newBack !== oldBack) { this._back = newBack; oldBack._next = newBack; } ++this._size; } // Like push(), shift() follows the read -> calculate -> mutate pattern for // exception safety. shift(): T { assert(this._size > 0); // must not be called on an empty queue const oldFront = this._front; let newFront = oldFront; const oldCursor = this._cursor; let newCursor = oldCursor + 1; const elements = oldFront._elements; const element = elements[oldCursor]; if (newCursor === QUEUE_MAX_ARRAY_SIZE) { assert(elements.length === QUEUE_MAX_ARRAY_SIZE); assert(oldFront._next !== undefined); newFront = oldFront._next!; newCursor = 0; } // No mutations before this point. --this._size; this._cursor = newCursor; if (oldFront !== newFront) { this._front = newFront; } // Permit shifted element to be garbage collected. elements[oldCursor] = undefined!; return element; } // The tricky thing about forEach() is that it can be called // re-entrantly. The queue may be mutated inside the callback. It is easy to // see that push() within the callback has no negative effects since the end // of the queue is checked for on every iteration. If shift() is called // repeatedly within the callback then the next iteration may return an // element that has been removed. In this case the callback will be called // with undefined values until we either "catch up" with elements that still // exist or reach the back of the queue. forEach(callback: (element: T) => void): void { let i = this._cursor; let node = this._front; let elements = node._elements; while (i !== elements.length || node._next !== undefined) { if (i === elements.length) { assert(node._next !== undefined); assert(i === QUEUE_MAX_ARRAY_SIZE); node = node._next!; elements = node._elements; i = 0; if (elements.length === 0) { break; } } callback(elements[i]); ++i; } } // Return the element that would be returned if shift() was called now, // without modifying the queue. peek(): T { assert(this._size > 0); // must not be called on an empty queue const front = this._front; const cursor = this._cursor; return front._elements[cursor]; } } web-streams-polyfill-3.2.1/src/lib/transform-stream.ts000066400000000000000000000472231422364423700230260ustar00rootroot00000000000000import assert from '../stub/assert'; import { newPromise, promiseRejectedWith, promiseResolvedWith, transformPromiseWith } from './helpers/webidl'; import { CreateReadableStream, ReadableStream, ReadableStreamDefaultController } from './readable-stream'; import { ReadableStreamDefaultControllerCanCloseOrEnqueue, ReadableStreamDefaultControllerClose, ReadableStreamDefaultControllerEnqueue, ReadableStreamDefaultControllerError, ReadableStreamDefaultControllerGetDesiredSize, ReadableStreamDefaultControllerHasBackpressure } from './readable-stream/default-controller'; import { QueuingStrategy, QueuingStrategySizeCallback } from './queuing-strategy'; import { CreateWritableStream, WritableStream, WritableStreamDefaultControllerErrorIfNeeded } from './writable-stream'; import { typeIsObject } from './helpers/miscellaneous'; import { IsNonNegativeNumber } from './abstract-ops/miscellaneous'; import { convertQueuingStrategy } from './validators/queuing-strategy'; import { ExtractHighWaterMark, ExtractSizeAlgorithm } from './abstract-ops/queuing-strategy'; import { Transformer, TransformerFlushCallback, TransformerStartCallback, TransformerTransformCallback, ValidatedTransformer } from './transform-stream/transformer'; import { convertTransformer } from './validators/transformer'; // Class TransformStream /** * A transform stream consists of a pair of streams: a {@link WritableStream | writable stream}, * known as its writable side, and a {@link ReadableStream | readable stream}, known as its readable side. * In a manner specific to the transform stream in question, writes to the writable side result in new data being * made available for reading from the readable side. * * @public */ export class TransformStream { /** @internal */ _writable!: WritableStream; /** @internal */ _readable!: ReadableStream; /** @internal */ _backpressure!: boolean; /** @internal */ _backpressureChangePromise!: Promise; /** @internal */ _backpressureChangePromise_resolve!: () => void; /** @internal */ _transformStreamController!: TransformStreamDefaultController; constructor( transformer?: Transformer, writableStrategy?: QueuingStrategy, readableStrategy?: QueuingStrategy ); constructor(rawTransformer: Transformer | null | undefined = {}, rawWritableStrategy: QueuingStrategy | null | undefined = {}, rawReadableStrategy: QueuingStrategy | null | undefined = {}) { if (rawTransformer === undefined) { rawTransformer = null; } const writableStrategy = convertQueuingStrategy(rawWritableStrategy, 'Second parameter'); const readableStrategy = convertQueuingStrategy(rawReadableStrategy, 'Third parameter'); const transformer = convertTransformer(rawTransformer, 'First parameter'); if (transformer.readableType !== undefined) { throw new RangeError('Invalid readableType specified'); } if (transformer.writableType !== undefined) { throw new RangeError('Invalid writableType specified'); } const readableHighWaterMark = ExtractHighWaterMark(readableStrategy, 0); const readableSizeAlgorithm = ExtractSizeAlgorithm(readableStrategy); const writableHighWaterMark = ExtractHighWaterMark(writableStrategy, 1); const writableSizeAlgorithm = ExtractSizeAlgorithm(writableStrategy); let startPromise_resolve!: (value: void | PromiseLike) => void; const startPromise = newPromise(resolve => { startPromise_resolve = resolve; }); InitializeTransformStream( this, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm ); SetUpTransformStreamDefaultControllerFromTransformer(this, transformer); if (transformer.start !== undefined) { startPromise_resolve(transformer.start(this._transformStreamController)); } else { startPromise_resolve(undefined); } } /** * The readable side of the transform stream. */ get readable(): ReadableStream { if (!IsTransformStream(this)) { throw streamBrandCheckException('readable'); } return this._readable; } /** * The writable side of the transform stream. */ get writable(): WritableStream { if (!IsTransformStream(this)) { throw streamBrandCheckException('writable'); } return this._writable; } } Object.defineProperties(TransformStream.prototype, { readable: { enumerable: true }, writable: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(TransformStream.prototype, Symbol.toStringTag, { value: 'TransformStream', configurable: true }); } export { Transformer, TransformerStartCallback, TransformerFlushCallback, TransformerTransformCallback }; // Transform Stream Abstract Operations export function CreateTransformStream(startAlgorithm: () => void | PromiseLike, transformAlgorithm: (chunk: I) => Promise, flushAlgorithm: () => Promise, writableHighWaterMark = 1, writableSizeAlgorithm: QueuingStrategySizeCallback = () => 1, readableHighWaterMark = 0, readableSizeAlgorithm: QueuingStrategySizeCallback = () => 1) { assert(IsNonNegativeNumber(writableHighWaterMark)); assert(IsNonNegativeNumber(readableHighWaterMark)); const stream: TransformStream = Object.create(TransformStream.prototype); let startPromise_resolve!: (value: void | PromiseLike) => void; const startPromise = newPromise(resolve => { startPromise_resolve = resolve; }); InitializeTransformStream(stream, startPromise, writableHighWaterMark, writableSizeAlgorithm, readableHighWaterMark, readableSizeAlgorithm); const controller: TransformStreamDefaultController = Object.create(TransformStreamDefaultController.prototype); SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm); const startResult = startAlgorithm(); startPromise_resolve(startResult); return stream; } function InitializeTransformStream(stream: TransformStream, startPromise: Promise, writableHighWaterMark: number, writableSizeAlgorithm: QueuingStrategySizeCallback, readableHighWaterMark: number, readableSizeAlgorithm: QueuingStrategySizeCallback) { function startAlgorithm(): Promise { return startPromise; } function writeAlgorithm(chunk: I): Promise { return TransformStreamDefaultSinkWriteAlgorithm(stream, chunk); } function abortAlgorithm(reason: any): Promise { return TransformStreamDefaultSinkAbortAlgorithm(stream, reason); } function closeAlgorithm(): Promise { return TransformStreamDefaultSinkCloseAlgorithm(stream); } stream._writable = CreateWritableStream(startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, writableHighWaterMark, writableSizeAlgorithm); function pullAlgorithm(): Promise { return TransformStreamDefaultSourcePullAlgorithm(stream); } function cancelAlgorithm(reason: any): Promise { TransformStreamErrorWritableAndUnblockWrite(stream, reason); return promiseResolvedWith(undefined); } stream._readable = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, readableHighWaterMark, readableSizeAlgorithm); // The [[backpressure]] slot is set to undefined so that it can be initialised by TransformStreamSetBackpressure. stream._backpressure = undefined!; stream._backpressureChangePromise = undefined!; stream._backpressureChangePromise_resolve = undefined!; TransformStreamSetBackpressure(stream, true); stream._transformStreamController = undefined!; } function IsTransformStream(x: unknown): x is TransformStream { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_transformStreamController')) { return false; } return x instanceof TransformStream; } // This is a no-op if both sides are already errored. function TransformStreamError(stream: TransformStream, e: any) { ReadableStreamDefaultControllerError( stream._readable._readableStreamController as ReadableStreamDefaultController, e ); TransformStreamErrorWritableAndUnblockWrite(stream, e); } function TransformStreamErrorWritableAndUnblockWrite(stream: TransformStream, e: any) { TransformStreamDefaultControllerClearAlgorithms(stream._transformStreamController); WritableStreamDefaultControllerErrorIfNeeded(stream._writable._writableStreamController, e); if (stream._backpressure) { // Pretend that pull() was called to permit any pending write() calls to complete. TransformStreamSetBackpressure() // cannot be called from enqueue() or pull() once the ReadableStream is errored, so this will will be the final time // _backpressure is set. TransformStreamSetBackpressure(stream, false); } } function TransformStreamSetBackpressure(stream: TransformStream, backpressure: boolean) { // Passes also when called during construction. assert(stream._backpressure !== backpressure); if (stream._backpressureChangePromise !== undefined) { stream._backpressureChangePromise_resolve(); } stream._backpressureChangePromise = newPromise(resolve => { stream._backpressureChangePromise_resolve = resolve; }); stream._backpressure = backpressure; } // Class TransformStreamDefaultController /** * Allows control of the {@link ReadableStream} and {@link WritableStream} of the associated {@link TransformStream}. * * @public */ export class TransformStreamDefaultController { /** @internal */ _controlledTransformStream: TransformStream; /** @internal */ _transformAlgorithm: (chunk: any) => Promise; /** @internal */ _flushAlgorithm: () => Promise; private constructor() { throw new TypeError('Illegal constructor'); } /** * Returns the desired size to fill the readable side’s internal queue. It can be negative, if the queue is over-full. */ get desiredSize(): number | null { if (!IsTransformStreamDefaultController(this)) { throw defaultControllerBrandCheckException('desiredSize'); } const readableController = this._controlledTransformStream._readable._readableStreamController; return ReadableStreamDefaultControllerGetDesiredSize(readableController as ReadableStreamDefaultController); } /** * Enqueues the given chunk `chunk` in the readable side of the controlled transform stream. */ enqueue(chunk: O): void; enqueue(chunk: O = undefined!): void { if (!IsTransformStreamDefaultController(this)) { throw defaultControllerBrandCheckException('enqueue'); } TransformStreamDefaultControllerEnqueue(this, chunk); } /** * Errors both the readable side and the writable side of the controlled transform stream, making all future * interactions with it fail with the given error `e`. Any chunks queued for transformation will be discarded. */ error(reason: any = undefined): void { if (!IsTransformStreamDefaultController(this)) { throw defaultControllerBrandCheckException('error'); } TransformStreamDefaultControllerError(this, reason); } /** * Closes the readable side and errors the writable side of the controlled transform stream. This is useful when the * transformer only needs to consume a portion of the chunks written to the writable side. */ terminate(): void { if (!IsTransformStreamDefaultController(this)) { throw defaultControllerBrandCheckException('terminate'); } TransformStreamDefaultControllerTerminate(this); } } Object.defineProperties(TransformStreamDefaultController.prototype, { enqueue: { enumerable: true }, error: { enumerable: true }, terminate: { enumerable: true }, desiredSize: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(TransformStreamDefaultController.prototype, Symbol.toStringTag, { value: 'TransformStreamDefaultController', configurable: true }); } // Transform Stream Default Controller Abstract Operations function IsTransformStreamDefaultController(x: any): x is TransformStreamDefaultController { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_controlledTransformStream')) { return false; } return x instanceof TransformStreamDefaultController; } function SetUpTransformStreamDefaultController(stream: TransformStream, controller: TransformStreamDefaultController, transformAlgorithm: (chunk: I) => Promise, flushAlgorithm: () => Promise) { assert(IsTransformStream(stream)); assert(stream._transformStreamController === undefined); controller._controlledTransformStream = stream; stream._transformStreamController = controller; controller._transformAlgorithm = transformAlgorithm; controller._flushAlgorithm = flushAlgorithm; } function SetUpTransformStreamDefaultControllerFromTransformer(stream: TransformStream, transformer: ValidatedTransformer) { const controller: TransformStreamDefaultController = Object.create(TransformStreamDefaultController.prototype); let transformAlgorithm = (chunk: I): Promise => { try { TransformStreamDefaultControllerEnqueue(controller, chunk as unknown as O); return promiseResolvedWith(undefined); } catch (transformResultE) { return promiseRejectedWith(transformResultE); } }; let flushAlgorithm: () => Promise = () => promiseResolvedWith(undefined); if (transformer.transform !== undefined) { transformAlgorithm = chunk => transformer.transform!(chunk, controller); } if (transformer.flush !== undefined) { flushAlgorithm = () => transformer.flush!(controller); } SetUpTransformStreamDefaultController(stream, controller, transformAlgorithm, flushAlgorithm); } function TransformStreamDefaultControllerClearAlgorithms(controller: TransformStreamDefaultController) { controller._transformAlgorithm = undefined!; controller._flushAlgorithm = undefined!; } function TransformStreamDefaultControllerEnqueue(controller: TransformStreamDefaultController, chunk: O) { const stream = controller._controlledTransformStream; const readableController = stream._readable._readableStreamController as ReadableStreamDefaultController; if (!ReadableStreamDefaultControllerCanCloseOrEnqueue(readableController)) { throw new TypeError('Readable side is not in a state that permits enqueue'); } // We throttle transform invocations based on the backpressure of the ReadableStream, but we still // accept TransformStreamDefaultControllerEnqueue() calls. try { ReadableStreamDefaultControllerEnqueue(readableController, chunk); } catch (e) { // This happens when readableStrategy.size() throws. TransformStreamErrorWritableAndUnblockWrite(stream, e); throw stream._readable._storedError; } const backpressure = ReadableStreamDefaultControllerHasBackpressure(readableController); if (backpressure !== stream._backpressure) { assert(backpressure); TransformStreamSetBackpressure(stream, true); } } function TransformStreamDefaultControllerError(controller: TransformStreamDefaultController, e: any) { TransformStreamError(controller._controlledTransformStream, e); } function TransformStreamDefaultControllerPerformTransform(controller: TransformStreamDefaultController, chunk: I) { const transformPromise = controller._transformAlgorithm(chunk); return transformPromiseWith(transformPromise, undefined, r => { TransformStreamError(controller._controlledTransformStream, r); throw r; }); } function TransformStreamDefaultControllerTerminate(controller: TransformStreamDefaultController) { const stream = controller._controlledTransformStream; const readableController = stream._readable._readableStreamController as ReadableStreamDefaultController; ReadableStreamDefaultControllerClose(readableController); const error = new TypeError('TransformStream terminated'); TransformStreamErrorWritableAndUnblockWrite(stream, error); } // TransformStreamDefaultSink Algorithms function TransformStreamDefaultSinkWriteAlgorithm(stream: TransformStream, chunk: I): Promise { assert(stream._writable._state === 'writable'); const controller = stream._transformStreamController; if (stream._backpressure) { const backpressureChangePromise = stream._backpressureChangePromise; assert(backpressureChangePromise !== undefined); return transformPromiseWith(backpressureChangePromise, () => { const writable = stream._writable; const state = writable._state; if (state === 'erroring') { throw writable._storedError; } assert(state === 'writable'); return TransformStreamDefaultControllerPerformTransform(controller, chunk); }); } return TransformStreamDefaultControllerPerformTransform(controller, chunk); } function TransformStreamDefaultSinkAbortAlgorithm(stream: TransformStream, reason: any): Promise { // abort() is not called synchronously, so it is possible for abort() to be called when the stream is already // errored. TransformStreamError(stream, reason); return promiseResolvedWith(undefined); } function TransformStreamDefaultSinkCloseAlgorithm(stream: TransformStream): Promise { // stream._readable cannot change after construction, so caching it across a call to user code is safe. const readable = stream._readable; const controller = stream._transformStreamController; const flushPromise = controller._flushAlgorithm(); TransformStreamDefaultControllerClearAlgorithms(controller); // Return a promise that is fulfilled with undefined on success. return transformPromiseWith(flushPromise, () => { if (readable._state === 'errored') { throw readable._storedError; } ReadableStreamDefaultControllerClose(readable._readableStreamController as ReadableStreamDefaultController); }, r => { TransformStreamError(stream, r); throw readable._storedError; }); } // TransformStreamDefaultSource Algorithms function TransformStreamDefaultSourcePullAlgorithm(stream: TransformStream): Promise { // Invariant. Enforced by the promises returned by start() and pull(). assert(stream._backpressure); assert(stream._backpressureChangePromise !== undefined); TransformStreamSetBackpressure(stream, false); // Prevent the next pull() call until there is backpressure. return stream._backpressureChangePromise; } // Helper functions for the TransformStreamDefaultController. function defaultControllerBrandCheckException(name: string): TypeError { return new TypeError( `TransformStreamDefaultController.prototype.${name} can only be used on a TransformStreamDefaultController`); } // Helper functions for the TransformStream. function streamBrandCheckException(name: string): TypeError { return new TypeError( `TransformStream.prototype.${name} can only be used on a TransformStream`); } web-streams-polyfill-3.2.1/src/lib/transform-stream/000077500000000000000000000000001422364423700224465ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/lib/transform-stream/transformer.ts000066400000000000000000000027751422364423700253730ustar00rootroot00000000000000import { TransformStreamDefaultController } from '../transform-stream'; /** @public */ export type TransformerStartCallback = (controller: TransformStreamDefaultController) => void | PromiseLike; /** @public */ export type TransformerFlushCallback = (controller: TransformStreamDefaultController) => void | PromiseLike; /** @public */ export type TransformerTransformCallback = (chunk: I, controller: TransformStreamDefaultController) => void | PromiseLike; /** * A transformer for constructing a {@link TransformStream}. * * @public */ export interface Transformer { /** * A function that is called immediately during creation of the {@link TransformStream}. */ start?: TransformerStartCallback; /** * A function called when a new chunk originally written to the writable side is ready to be transformed. */ transform?: TransformerTransformCallback; /** * A function called after all chunks written to the writable side have been transformed by successfully passing * through {@link Transformer.transform | transform()}, and the writable side is about to be closed. */ flush?: TransformerFlushCallback; readableType?: undefined; writableType?: undefined; } export interface ValidatedTransformer extends Transformer { transform?: (chunk: I, controller: TransformStreamDefaultController) => Promise; flush?: (controller: TransformStreamDefaultController) => Promise; } web-streams-polyfill-3.2.1/src/lib/validators/000077500000000000000000000000001422364423700213125ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/lib/validators/basic.ts000066400000000000000000000056321422364423700227510ustar00rootroot00000000000000import NumberIsFinite from '../../stub/number-isfinite'; import MathTrunc from '../../stub/math-trunc'; // https://heycam.github.io/webidl/#idl-dictionaries export function isDictionary(x: any): x is object | null { return typeof x === 'object' || typeof x === 'function'; } export function assertDictionary(obj: unknown, context: string): asserts obj is object | null | undefined { if (obj !== undefined && !isDictionary(obj)) { throw new TypeError(`${context} is not an object.`); } } export type AnyFunction = (...args: any[]) => any; // https://heycam.github.io/webidl/#idl-callback-functions export function assertFunction(x: unknown, context: string): asserts x is AnyFunction { if (typeof x !== 'function') { throw new TypeError(`${context} is not a function.`); } } // https://heycam.github.io/webidl/#idl-object export function isObject(x: any): x is object { return (typeof x === 'object' && x !== null) || typeof x === 'function'; } export function assertObject(x: unknown, context: string): asserts x is object { if (!isObject(x)) { throw new TypeError(`${context} is not an object.`); } } export function assertRequiredArgument(x: T | undefined, position: number, context: string): asserts x is T { if (x === undefined) { throw new TypeError(`Parameter ${position} is required in '${context}'.`); } } export function assertRequiredField(x: T | undefined, field: string, context: string): asserts x is T { if (x === undefined) { throw new TypeError(`${field} is required in '${context}'.`); } } // https://heycam.github.io/webidl/#idl-unrestricted-double export function convertUnrestrictedDouble(value: unknown): number { return Number(value); } function censorNegativeZero(x: number): number { return x === 0 ? 0 : x; } function integerPart(x: number): number { return censorNegativeZero(MathTrunc(x)); } // https://heycam.github.io/webidl/#idl-unsigned-long-long export function convertUnsignedLongLongWithEnforceRange(value: unknown, context: string): number { const lowerBound = 0; const upperBound = Number.MAX_SAFE_INTEGER; let x = Number(value); x = censorNegativeZero(x); if (!NumberIsFinite(x)) { throw new TypeError(`${context} is not a finite number`); } x = integerPart(x); if (x < lowerBound || x > upperBound) { throw new TypeError(`${context} is outside the accepted range of ${lowerBound} to ${upperBound}, inclusive`); } if (!NumberIsFinite(x) || x === 0) { return 0; } // TODO Use BigInt if supported? // let xBigInt = BigInt(integerPart(x)); // xBigInt = BigInt.asUintN(64, xBigInt); // return Number(xBigInt); return x; } web-streams-polyfill-3.2.1/src/lib/validators/iterator-options.ts000066400000000000000000000007761422364423700252160ustar00rootroot00000000000000import { assertDictionary } from './basic'; import { ReadableStreamIteratorOptions, ValidatedReadableStreamIteratorOptions } from '../readable-stream/iterator-options'; export function convertIteratorOptions(options: ReadableStreamIteratorOptions | null | undefined, context: string): ValidatedReadableStreamIteratorOptions { assertDictionary(options, context); const preventCancel = options?.preventCancel; return { preventCancel: Boolean(preventCancel) }; } web-streams-polyfill-3.2.1/src/lib/validators/pipe-options.ts000066400000000000000000000020111422364423700243020ustar00rootroot00000000000000import { assertDictionary } from './basic'; import { StreamPipeOptions, ValidatedStreamPipeOptions } from '../readable-stream/pipe-options'; import { AbortSignal, isAbortSignal } from '../abort-signal'; export function convertPipeOptions(options: StreamPipeOptions | null | undefined, context: string): ValidatedStreamPipeOptions { assertDictionary(options, context); const preventAbort = options?.preventAbort; const preventCancel = options?.preventCancel; const preventClose = options?.preventClose; const signal = options?.signal; if (signal !== undefined) { assertAbortSignal(signal, `${context} has member 'signal' that`); } return { preventAbort: Boolean(preventAbort), preventCancel: Boolean(preventCancel), preventClose: Boolean(preventClose), signal }; } function assertAbortSignal(signal: unknown, context: string): asserts signal is AbortSignal { if (!isAbortSignal(signal)) { throw new TypeError(`${context} is not an AbortSignal.`); } } web-streams-polyfill-3.2.1/src/lib/validators/queuing-strategy-init.ts000066400000000000000000000010601422364423700261350ustar00rootroot00000000000000import { QueuingStrategyInit } from '../queuing-strategy'; import { assertDictionary, assertRequiredField, convertUnrestrictedDouble } from './basic'; export function convertQueuingStrategyInit(init: QueuingStrategyInit | null | undefined, context: string): QueuingStrategyInit { assertDictionary(init, context); const highWaterMark = init?.highWaterMark; assertRequiredField(highWaterMark, 'highWaterMark', 'QueuingStrategyInit'); return { highWaterMark: convertUnrestrictedDouble(highWaterMark) }; } web-streams-polyfill-3.2.1/src/lib/validators/queuing-strategy.ts000066400000000000000000000016501422364423700252010ustar00rootroot00000000000000import { QueuingStrategy, QueuingStrategySizeCallback } from '../queuing-strategy'; import { assertDictionary, assertFunction, convertUnrestrictedDouble } from './basic'; export function convertQueuingStrategy(init: QueuingStrategy | null | undefined, context: string): QueuingStrategy { assertDictionary(init, context); const highWaterMark = init?.highWaterMark; const size = init?.size; return { highWaterMark: highWaterMark === undefined ? undefined : convertUnrestrictedDouble(highWaterMark), size: size === undefined ? undefined : convertQueuingStrategySize(size, `${context} has member 'size' that`) }; } function convertQueuingStrategySize(fn: QueuingStrategySizeCallback, context: string): QueuingStrategySizeCallback { assertFunction(fn, context); return chunk => convertUnrestrictedDouble(fn(chunk)); } web-streams-polyfill-3.2.1/src/lib/validators/readable-stream.ts000066400000000000000000000004151422364423700247120ustar00rootroot00000000000000import { IsReadableStream, ReadableStream } from '../readable-stream'; export function assertReadableStream(x: unknown, context: string): asserts x is ReadableStream { if (!IsReadableStream(x)) { throw new TypeError(`${context} is not a ReadableStream.`); } } web-streams-polyfill-3.2.1/src/lib/validators/readable-writable-pair.ts000066400000000000000000000016431422364423700261650ustar00rootroot00000000000000import { assertDictionary, assertRequiredField } from './basic'; import { ReadableStream } from '../readable-stream'; import { WritableStream } from '../writable-stream'; import { assertReadableStream } from './readable-stream'; import { assertWritableStream } from './writable-stream'; export function convertReadableWritablePair( pair: { readable: RS; writable: WS } | null | undefined, context: string ): { readable: RS; writable: WS } { assertDictionary(pair, context); const readable = pair?.readable; assertRequiredField(readable, 'readable', 'ReadableWritablePair'); assertReadableStream(readable, `${context} has member 'readable' that`); const writable = pair?.writable; assertRequiredField(writable, 'writable', 'ReadableWritablePair'); assertWritableStream(writable, `${context} has member 'writable' that`); return { readable, writable }; } web-streams-polyfill-3.2.1/src/lib/validators/reader-options.ts000066400000000000000000000014121422364423700246130ustar00rootroot00000000000000import { assertDictionary } from './basic'; import { ReadableStreamGetReaderOptions } from '../readable-stream/reader-options'; export function convertReaderOptions(options: ReadableStreamGetReaderOptions | null | undefined, context: string): ReadableStreamGetReaderOptions { assertDictionary(options, context); const mode = options?.mode; return { mode: mode === undefined ? undefined : convertReadableStreamReaderMode(mode, `${context} has member 'mode' that`) }; } function convertReadableStreamReaderMode(mode: string, context: string): 'byob' { mode = `${mode}`; if (mode !== 'byob') { throw new TypeError(`${context} '${mode}' is not a valid enumeration value for ReadableStreamReaderMode`); } return mode; } web-streams-polyfill-3.2.1/src/lib/validators/transformer.ts000066400000000000000000000044061422364423700242300ustar00rootroot00000000000000import { assertDictionary, assertFunction } from './basic'; import { promiseCall, reflectCall } from '../helpers/webidl'; import { Transformer, TransformerFlushCallback, TransformerStartCallback, TransformerTransformCallback, ValidatedTransformer } from '../transform-stream/transformer'; import { TransformStreamDefaultController } from '../transform-stream'; export function convertTransformer(original: Transformer | null, context: string): ValidatedTransformer { assertDictionary(original, context); const flush = original?.flush; const readableType = original?.readableType; const start = original?.start; const transform = original?.transform; const writableType = original?.writableType; return { flush: flush === undefined ? undefined : convertTransformerFlushCallback(flush, original!, `${context} has member 'flush' that`), readableType, start: start === undefined ? undefined : convertTransformerStartCallback(start, original!, `${context} has member 'start' that`), transform: transform === undefined ? undefined : convertTransformerTransformCallback(transform, original!, `${context} has member 'transform' that`), writableType }; } function convertTransformerFlushCallback( fn: TransformerFlushCallback, original: Transformer, context: string ): (controller: TransformStreamDefaultController) => Promise { assertFunction(fn, context); return (controller: TransformStreamDefaultController) => promiseCall(fn, original, [controller]); } function convertTransformerStartCallback( fn: TransformerStartCallback, original: Transformer, context: string ): TransformerStartCallback { assertFunction(fn, context); return (controller: TransformStreamDefaultController) => reflectCall(fn, original, [controller]); } function convertTransformerTransformCallback( fn: TransformerTransformCallback, original: Transformer, context: string ): (chunk: I, controller: TransformStreamDefaultController) => Promise { assertFunction(fn, context); return (chunk: I, controller: TransformStreamDefaultController) => promiseCall(fn, original, [chunk, controller]); } web-streams-polyfill-3.2.1/src/lib/validators/underlying-sink.ts000066400000000000000000000047661422364423700250210ustar00rootroot00000000000000import { assertDictionary, assertFunction } from './basic'; import { promiseCall, reflectCall } from '../helpers/webidl'; import { UnderlyingSink, UnderlyingSinkAbortCallback, UnderlyingSinkCloseCallback, UnderlyingSinkStartCallback, UnderlyingSinkWriteCallback, ValidatedUnderlyingSink } from '../writable-stream/underlying-sink'; import { WritableStreamDefaultController } from '../writable-stream'; export function convertUnderlyingSink(original: UnderlyingSink | null, context: string): ValidatedUnderlyingSink { assertDictionary(original, context); const abort = original?.abort; const close = original?.close; const start = original?.start; const type = original?.type; const write = original?.write; return { abort: abort === undefined ? undefined : convertUnderlyingSinkAbortCallback(abort, original!, `${context} has member 'abort' that`), close: close === undefined ? undefined : convertUnderlyingSinkCloseCallback(close, original!, `${context} has member 'close' that`), start: start === undefined ? undefined : convertUnderlyingSinkStartCallback(start, original!, `${context} has member 'start' that`), write: write === undefined ? undefined : convertUnderlyingSinkWriteCallback(write, original!, `${context} has member 'write' that`), type }; } function convertUnderlyingSinkAbortCallback( fn: UnderlyingSinkAbortCallback, original: UnderlyingSink, context: string ): (reason: any) => Promise { assertFunction(fn, context); return (reason: any) => promiseCall(fn, original, [reason]); } function convertUnderlyingSinkCloseCallback( fn: UnderlyingSinkCloseCallback, original: UnderlyingSink, context: string ): () => Promise { assertFunction(fn, context); return () => promiseCall(fn, original, []); } function convertUnderlyingSinkStartCallback( fn: UnderlyingSinkStartCallback, original: UnderlyingSink, context: string ): UnderlyingSinkStartCallback { assertFunction(fn, context); return (controller: WritableStreamDefaultController) => reflectCall(fn, original, [controller]); } function convertUnderlyingSinkWriteCallback( fn: UnderlyingSinkWriteCallback, original: UnderlyingSink, context: string ): (chunk: W, controller: WritableStreamDefaultController) => Promise { assertFunction(fn, context); return (chunk: W, controller: WritableStreamDefaultController) => promiseCall(fn, original, [chunk, controller]); } web-streams-polyfill-3.2.1/src/lib/validators/underlying-source.ts000066400000000000000000000057231422364423700253470ustar00rootroot00000000000000import { assertDictionary, assertFunction, convertUnsignedLongLongWithEnforceRange } from './basic'; import { ReadableStreamController, UnderlyingByteSource, UnderlyingDefaultOrByteSource, UnderlyingDefaultOrByteSourcePullCallback, UnderlyingDefaultOrByteSourceStartCallback, UnderlyingSource, UnderlyingSourceCancelCallback, ValidatedUnderlyingDefaultOrByteSource } from '../readable-stream/underlying-source'; import { promiseCall, reflectCall } from '../helpers/webidl'; export function convertUnderlyingDefaultOrByteSource( source: UnderlyingSource | UnderlyingByteSource | null, context: string ): ValidatedUnderlyingDefaultOrByteSource { assertDictionary(source, context); const original = source as (UnderlyingDefaultOrByteSource | null); const autoAllocateChunkSize = original?.autoAllocateChunkSize; const cancel = original?.cancel; const pull = original?.pull; const start = original?.start; const type = original?.type; return { autoAllocateChunkSize: autoAllocateChunkSize === undefined ? undefined : convertUnsignedLongLongWithEnforceRange( autoAllocateChunkSize, `${context} has member 'autoAllocateChunkSize' that` ), cancel: cancel === undefined ? undefined : convertUnderlyingSourceCancelCallback(cancel, original!, `${context} has member 'cancel' that`), pull: pull === undefined ? undefined : convertUnderlyingSourcePullCallback(pull, original!, `${context} has member 'pull' that`), start: start === undefined ? undefined : convertUnderlyingSourceStartCallback(start, original!, `${context} has member 'start' that`), type: type === undefined ? undefined : convertReadableStreamType(type, `${context} has member 'type' that`) }; } function convertUnderlyingSourceCancelCallback( fn: UnderlyingSourceCancelCallback, original: UnderlyingDefaultOrByteSource, context: string ): (reason: any) => Promise { assertFunction(fn, context); return (reason: any) => promiseCall(fn, original, [reason]); } function convertUnderlyingSourcePullCallback( fn: UnderlyingDefaultOrByteSourcePullCallback, original: UnderlyingDefaultOrByteSource, context: string ): (controller: ReadableStreamController) => Promise { assertFunction(fn, context); return (controller: ReadableStreamController) => promiseCall(fn, original, [controller]); } function convertUnderlyingSourceStartCallback( fn: UnderlyingDefaultOrByteSourceStartCallback, original: UnderlyingDefaultOrByteSource, context: string ): UnderlyingDefaultOrByteSourceStartCallback { assertFunction(fn, context); return (controller: ReadableStreamController) => reflectCall(fn, original, [controller]); } function convertReadableStreamType(type: string, context: string): 'bytes' { type = `${type}`; if (type !== 'bytes') { throw new TypeError(`${context} '${type}' is not a valid enumeration value for ReadableStreamType`); } return type; } web-streams-polyfill-3.2.1/src/lib/validators/writable-stream.ts000066400000000000000000000004151422364423700247640ustar00rootroot00000000000000import { IsWritableStream, WritableStream } from '../writable-stream'; export function assertWritableStream(x: unknown, context: string): asserts x is WritableStream { if (!IsWritableStream(x)) { throw new TypeError(`${context} is not a WritableStream.`); } } web-streams-polyfill-3.2.1/src/lib/writable-stream.ts000066400000000000000000001401101422364423700226110ustar00rootroot00000000000000import assert from '../stub/assert'; import { newPromise, promiseRejectedWith, promiseResolvedWith, setPromiseIsHandledToTrue, uponPromise } from './helpers/webidl'; import { DequeueValue, EnqueueValueWithSize, PeekQueueValue, QueuePair, ResetQueue } from './abstract-ops/queue-with-sizes'; import { QueuingStrategy, QueuingStrategySizeCallback } from './queuing-strategy'; import { SimpleQueue } from './simple-queue'; import { typeIsObject } from './helpers/miscellaneous'; import { AbortSteps, ErrorSteps } from './abstract-ops/internal-methods'; import { IsNonNegativeNumber } from './abstract-ops/miscellaneous'; import { ExtractHighWaterMark, ExtractSizeAlgorithm } from './abstract-ops/queuing-strategy'; import { convertQueuingStrategy } from './validators/queuing-strategy'; import { UnderlyingSink, UnderlyingSinkAbortCallback, UnderlyingSinkCloseCallback, UnderlyingSinkStartCallback, UnderlyingSinkWriteCallback, ValidatedUnderlyingSink } from './writable-stream/underlying-sink'; import { assertObject, assertRequiredArgument } from './validators/basic'; import { convertUnderlyingSink } from './validators/underlying-sink'; import { assertWritableStream } from './validators/writable-stream'; import { AbortController, AbortSignal, createAbortController } from './abort-signal'; type WritableStreamState = 'writable' | 'closed' | 'erroring' | 'errored'; interface WriteOrCloseRequest { _resolve: (value?: undefined) => void; _reject: (reason: any) => void; } type WriteRequest = WriteOrCloseRequest; type CloseRequest = WriteOrCloseRequest; interface PendingAbortRequest { _promise: Promise; _resolve: (value?: undefined) => void; _reject: (reason: any) => void; _reason: any; _wasAlreadyErroring: boolean; } /** * A writable stream represents a destination for data, into which you can write. * * @public */ class WritableStream { /** @internal */ _state!: WritableStreamState; /** @internal */ _storedError: any; /** @internal */ _writer: WritableStreamDefaultWriter | undefined; /** @internal */ _writableStreamController!: WritableStreamDefaultController; /** @internal */ _writeRequests!: SimpleQueue; /** @internal */ _inFlightWriteRequest: WriteRequest | undefined; /** @internal */ _closeRequest: CloseRequest | undefined; /** @internal */ _inFlightCloseRequest: CloseRequest | undefined; /** @internal */ _pendingAbortRequest: PendingAbortRequest | undefined; /** @internal */ _backpressure!: boolean; constructor(underlyingSink?: UnderlyingSink, strategy?: QueuingStrategy); constructor(rawUnderlyingSink: UnderlyingSink | null | undefined = {}, rawStrategy: QueuingStrategy | null | undefined = {}) { if (rawUnderlyingSink === undefined) { rawUnderlyingSink = null; } else { assertObject(rawUnderlyingSink, 'First parameter'); } const strategy = convertQueuingStrategy(rawStrategy, 'Second parameter'); const underlyingSink = convertUnderlyingSink(rawUnderlyingSink, 'First parameter'); InitializeWritableStream(this); const type = underlyingSink.type; if (type !== undefined) { throw new RangeError('Invalid type is specified'); } const sizeAlgorithm = ExtractSizeAlgorithm(strategy); const highWaterMark = ExtractHighWaterMark(strategy, 1); SetUpWritableStreamDefaultControllerFromUnderlyingSink(this, underlyingSink, highWaterMark, sizeAlgorithm); } /** * Returns whether or not the writable stream is locked to a writer. */ get locked(): boolean { if (!IsWritableStream(this)) { throw streamBrandCheckException('locked'); } return IsWritableStreamLocked(this); } /** * Aborts the stream, signaling that the producer can no longer successfully write to the stream and it is to be * immediately moved to an errored state, with any queued-up writes discarded. This will also execute any abort * mechanism of the underlying sink. * * The returned promise will fulfill if the stream shuts down successfully, or reject if the underlying sink signaled * that there was an error doing so. Additionally, it will reject with a `TypeError` (without attempting to cancel * the stream) if the stream is currently locked. */ abort(reason: any = undefined): Promise { if (!IsWritableStream(this)) { return promiseRejectedWith(streamBrandCheckException('abort')); } if (IsWritableStreamLocked(this)) { return promiseRejectedWith(new TypeError('Cannot abort a stream that already has a writer')); } return WritableStreamAbort(this, reason); } /** * Closes the stream. The underlying sink will finish processing any previously-written chunks, before invoking its * close behavior. During this time any further attempts to write will fail (without erroring the stream). * * The method returns a promise that will fulfill if all remaining chunks are successfully written and the stream * successfully closes, or rejects if an error is encountered during this process. Additionally, it will reject with * a `TypeError` (without attempting to cancel the stream) if the stream is currently locked. */ close() { if (!IsWritableStream(this)) { return promiseRejectedWith(streamBrandCheckException('close')); } if (IsWritableStreamLocked(this)) { return promiseRejectedWith(new TypeError('Cannot close a stream that already has a writer')); } if (WritableStreamCloseQueuedOrInFlight(this)) { return promiseRejectedWith(new TypeError('Cannot close an already-closing stream')); } return WritableStreamClose(this); } /** * Creates a {@link WritableStreamDefaultWriter | writer} and locks the stream to the new writer. While the stream * is locked, no other writer can be acquired until this one is released. * * This functionality is especially useful for creating abstractions that desire the ability to write to a stream * without interruption or interleaving. By getting a writer for the stream, you can ensure nobody else can write at * the same time, which would cause the resulting written data to be unpredictable and probably useless. */ getWriter(): WritableStreamDefaultWriter { if (!IsWritableStream(this)) { throw streamBrandCheckException('getWriter'); } return AcquireWritableStreamDefaultWriter(this); } } Object.defineProperties(WritableStream.prototype, { abort: { enumerable: true }, close: { enumerable: true }, getWriter: { enumerable: true }, locked: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(WritableStream.prototype, Symbol.toStringTag, { value: 'WritableStream', configurable: true }); } export { AcquireWritableStreamDefaultWriter, CreateWritableStream, IsWritableStream, IsWritableStreamLocked, WritableStream, WritableStreamAbort, WritableStreamDefaultControllerErrorIfNeeded, WritableStreamDefaultWriterCloseWithErrorPropagation, WritableStreamDefaultWriterRelease, WritableStreamDefaultWriterWrite, WritableStreamCloseQueuedOrInFlight, UnderlyingSink, UnderlyingSinkStartCallback, UnderlyingSinkWriteCallback, UnderlyingSinkCloseCallback, UnderlyingSinkAbortCallback }; // Abstract operations for the WritableStream. function AcquireWritableStreamDefaultWriter(stream: WritableStream): WritableStreamDefaultWriter { return new WritableStreamDefaultWriter(stream); } // Throws if and only if startAlgorithm throws. function CreateWritableStream(startAlgorithm: () => void | PromiseLike, writeAlgorithm: (chunk: W) => Promise, closeAlgorithm: () => Promise, abortAlgorithm: (reason: any) => Promise, highWaterMark = 1, sizeAlgorithm: QueuingStrategySizeCallback = () => 1) { assert(IsNonNegativeNumber(highWaterMark)); const stream: WritableStream = Object.create(WritableStream.prototype); InitializeWritableStream(stream); const controller: WritableStreamDefaultController = Object.create(WritableStreamDefaultController.prototype); SetUpWritableStreamDefaultController(stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm); return stream; } function InitializeWritableStream(stream: WritableStream) { stream._state = 'writable'; // The error that will be reported by new method calls once the state becomes errored. Only set when [[state]] is // 'erroring' or 'errored'. May be set to an undefined value. stream._storedError = undefined; stream._writer = undefined; // Initialize to undefined first because the constructor of the controller checks this // variable to validate the caller. stream._writableStreamController = undefined!; // This queue is placed here instead of the writer class in order to allow for passing a writer to the next data // producer without waiting for the queued writes to finish. stream._writeRequests = new SimpleQueue(); // Write requests are removed from _writeRequests when write() is called on the underlying sink. This prevents // them from being erroneously rejected on error. If a write() call is in-flight, the request is stored here. stream._inFlightWriteRequest = undefined; // The promise that was returned from writer.close(). Stored here because it may be fulfilled after the writer // has been detached. stream._closeRequest = undefined; // Close request is removed from _closeRequest when close() is called on the underlying sink. This prevents it // from being erroneously rejected on error. If a close() call is in-flight, the request is stored here. stream._inFlightCloseRequest = undefined; // The promise that was returned from writer.abort(). This may also be fulfilled after the writer has detached. stream._pendingAbortRequest = undefined; // The backpressure signal set by the controller. stream._backpressure = false; } function IsWritableStream(x: unknown): x is WritableStream { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_writableStreamController')) { return false; } return x instanceof WritableStream; } function IsWritableStreamLocked(stream: WritableStream): boolean { assert(IsWritableStream(stream)); if (stream._writer === undefined) { return false; } return true; } function WritableStreamAbort(stream: WritableStream, reason: any): Promise { if (stream._state === 'closed' || stream._state === 'errored') { return promiseResolvedWith(undefined); } stream._writableStreamController._abortReason = reason; stream._writableStreamController._abortController?.abort(); // TypeScript narrows the type of `stream._state` down to 'writable' | 'erroring', // but it doesn't know that signaling abort runs author code that might have changed the state. // Widen the type again by casting to WritableStreamState. const state = stream._state as WritableStreamState; if (state === 'closed' || state === 'errored') { return promiseResolvedWith(undefined); } if (stream._pendingAbortRequest !== undefined) { return stream._pendingAbortRequest._promise; } assert(state === 'writable' || state === 'erroring'); let wasAlreadyErroring = false; if (state === 'erroring') { wasAlreadyErroring = true; // reason will not be used, so don't keep a reference to it. reason = undefined; } const promise = newPromise((resolve, reject) => { stream._pendingAbortRequest = { _promise: undefined!, _resolve: resolve, _reject: reject, _reason: reason, _wasAlreadyErroring: wasAlreadyErroring }; }); stream._pendingAbortRequest!._promise = promise; if (!wasAlreadyErroring) { WritableStreamStartErroring(stream, reason); } return promise; } function WritableStreamClose(stream: WritableStream): Promise { const state = stream._state; if (state === 'closed' || state === 'errored') { return promiseRejectedWith(new TypeError( `The stream (in ${state} state) is not in the writable state and cannot be closed`)); } assert(state === 'writable' || state === 'erroring'); assert(!WritableStreamCloseQueuedOrInFlight(stream)); const promise = newPromise((resolve, reject) => { const closeRequest: CloseRequest = { _resolve: resolve, _reject: reject }; stream._closeRequest = closeRequest; }); const writer = stream._writer; if (writer !== undefined && stream._backpressure && state === 'writable') { defaultWriterReadyPromiseResolve(writer); } WritableStreamDefaultControllerClose(stream._writableStreamController); return promise; } // WritableStream API exposed for controllers. function WritableStreamAddWriteRequest(stream: WritableStream): Promise { assert(IsWritableStreamLocked(stream)); assert(stream._state === 'writable'); const promise = newPromise((resolve, reject) => { const writeRequest: WriteRequest = { _resolve: resolve, _reject: reject }; stream._writeRequests.push(writeRequest); }); return promise; } function WritableStreamDealWithRejection(stream: WritableStream, error: any) { const state = stream._state; if (state === 'writable') { WritableStreamStartErroring(stream, error); return; } assert(state === 'erroring'); WritableStreamFinishErroring(stream); } function WritableStreamStartErroring(stream: WritableStream, reason: any) { assert(stream._storedError === undefined); assert(stream._state === 'writable'); const controller = stream._writableStreamController; assert(controller !== undefined); stream._state = 'erroring'; stream._storedError = reason; const writer = stream._writer; if (writer !== undefined) { WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, reason); } if (!WritableStreamHasOperationMarkedInFlight(stream) && controller._started) { WritableStreamFinishErroring(stream); } } function WritableStreamFinishErroring(stream: WritableStream) { assert(stream._state === 'erroring'); assert(!WritableStreamHasOperationMarkedInFlight(stream)); stream._state = 'errored'; stream._writableStreamController[ErrorSteps](); const storedError = stream._storedError; stream._writeRequests.forEach(writeRequest => { writeRequest._reject(storedError); }); stream._writeRequests = new SimpleQueue(); if (stream._pendingAbortRequest === undefined) { WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); return; } const abortRequest = stream._pendingAbortRequest; stream._pendingAbortRequest = undefined; if (abortRequest._wasAlreadyErroring) { abortRequest._reject(storedError); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); return; } const promise = stream._writableStreamController[AbortSteps](abortRequest._reason); uponPromise( promise, () => { abortRequest._resolve(); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); }, (reason: any) => { abortRequest._reject(reason); WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream); }); } function WritableStreamFinishInFlightWrite(stream: WritableStream) { assert(stream._inFlightWriteRequest !== undefined); stream._inFlightWriteRequest!._resolve(undefined); stream._inFlightWriteRequest = undefined; } function WritableStreamFinishInFlightWriteWithError(stream: WritableStream, error: any) { assert(stream._inFlightWriteRequest !== undefined); stream._inFlightWriteRequest!._reject(error); stream._inFlightWriteRequest = undefined; assert(stream._state === 'writable' || stream._state === 'erroring'); WritableStreamDealWithRejection(stream, error); } function WritableStreamFinishInFlightClose(stream: WritableStream) { assert(stream._inFlightCloseRequest !== undefined); stream._inFlightCloseRequest!._resolve(undefined); stream._inFlightCloseRequest = undefined; const state = stream._state; assert(state === 'writable' || state === 'erroring'); if (state === 'erroring') { // The error was too late to do anything, so it is ignored. stream._storedError = undefined; if (stream._pendingAbortRequest !== undefined) { stream._pendingAbortRequest._resolve(); stream._pendingAbortRequest = undefined; } } stream._state = 'closed'; const writer = stream._writer; if (writer !== undefined) { defaultWriterClosedPromiseResolve(writer); } assert(stream._pendingAbortRequest === undefined); assert(stream._storedError === undefined); } function WritableStreamFinishInFlightCloseWithError(stream: WritableStream, error: any) { assert(stream._inFlightCloseRequest !== undefined); stream._inFlightCloseRequest!._reject(error); stream._inFlightCloseRequest = undefined; assert(stream._state === 'writable' || stream._state === 'erroring'); // Never execute sink abort() after sink close(). if (stream._pendingAbortRequest !== undefined) { stream._pendingAbortRequest._reject(error); stream._pendingAbortRequest = undefined; } WritableStreamDealWithRejection(stream, error); } // TODO(ricea): Fix alphabetical order. function WritableStreamCloseQueuedOrInFlight(stream: WritableStream): boolean { if (stream._closeRequest === undefined && stream._inFlightCloseRequest === undefined) { return false; } return true; } function WritableStreamHasOperationMarkedInFlight(stream: WritableStream): boolean { if (stream._inFlightWriteRequest === undefined && stream._inFlightCloseRequest === undefined) { return false; } return true; } function WritableStreamMarkCloseRequestInFlight(stream: WritableStream) { assert(stream._inFlightCloseRequest === undefined); assert(stream._closeRequest !== undefined); stream._inFlightCloseRequest = stream._closeRequest; stream._closeRequest = undefined; } function WritableStreamMarkFirstWriteRequestInFlight(stream: WritableStream) { assert(stream._inFlightWriteRequest === undefined); assert(stream._writeRequests.length !== 0); stream._inFlightWriteRequest = stream._writeRequests.shift(); } function WritableStreamRejectCloseAndClosedPromiseIfNeeded(stream: WritableStream) { assert(stream._state === 'errored'); if (stream._closeRequest !== undefined) { assert(stream._inFlightCloseRequest === undefined); stream._closeRequest._reject(stream._storedError); stream._closeRequest = undefined; } const writer = stream._writer; if (writer !== undefined) { defaultWriterClosedPromiseReject(writer, stream._storedError); } } function WritableStreamUpdateBackpressure(stream: WritableStream, backpressure: boolean) { assert(stream._state === 'writable'); assert(!WritableStreamCloseQueuedOrInFlight(stream)); const writer = stream._writer; if (writer !== undefined && backpressure !== stream._backpressure) { if (backpressure) { defaultWriterReadyPromiseReset(writer); } else { assert(!backpressure); defaultWriterReadyPromiseResolve(writer); } } stream._backpressure = backpressure; } /** * A default writer vended by a {@link WritableStream}. * * @public */ export class WritableStreamDefaultWriter { /** @internal */ _ownerWritableStream: WritableStream; /** @internal */ _closedPromise!: Promise; /** @internal */ _closedPromise_resolve?: (value?: undefined) => void; /** @internal */ _closedPromise_reject?: (reason: any) => void; /** @internal */ _closedPromiseState!: 'pending' | 'resolved' | 'rejected'; /** @internal */ _readyPromise!: Promise; /** @internal */ _readyPromise_resolve?: (value?: undefined) => void; /** @internal */ _readyPromise_reject?: (reason: any) => void; /** @internal */ _readyPromiseState!: 'pending' | 'fulfilled' | 'rejected'; constructor(stream: WritableStream) { assertRequiredArgument(stream, 1, 'WritableStreamDefaultWriter'); assertWritableStream(stream, 'First parameter'); if (IsWritableStreamLocked(stream)) { throw new TypeError('This stream has already been locked for exclusive writing by another writer'); } this._ownerWritableStream = stream; stream._writer = this; const state = stream._state; if (state === 'writable') { if (!WritableStreamCloseQueuedOrInFlight(stream) && stream._backpressure) { defaultWriterReadyPromiseInitialize(this); } else { defaultWriterReadyPromiseInitializeAsResolved(this); } defaultWriterClosedPromiseInitialize(this); } else if (state === 'erroring') { defaultWriterReadyPromiseInitializeAsRejected(this, stream._storedError); defaultWriterClosedPromiseInitialize(this); } else if (state === 'closed') { defaultWriterReadyPromiseInitializeAsResolved(this); defaultWriterClosedPromiseInitializeAsResolved(this); } else { assert(state === 'errored'); const storedError = stream._storedError; defaultWriterReadyPromiseInitializeAsRejected(this, storedError); defaultWriterClosedPromiseInitializeAsRejected(this, storedError); } } /** * Returns a promise that will be fulfilled when the stream becomes closed, or rejected if the stream ever errors or * the writer’s lock is released before the stream finishes closing. */ get closed(): Promise { if (!IsWritableStreamDefaultWriter(this)) { return promiseRejectedWith(defaultWriterBrandCheckException('closed')); } return this._closedPromise; } /** * Returns the desired size to fill the stream’s internal queue. It can be negative, if the queue is over-full. * A producer can use this information to determine the right amount of data to write. * * It will be `null` if the stream cannot be successfully written to (due to either being errored, or having an abort * queued up). It will return zero if the stream is closed. And the getter will throw an exception if invoked when * the writer’s lock is released. */ get desiredSize(): number | null { if (!IsWritableStreamDefaultWriter(this)) { throw defaultWriterBrandCheckException('desiredSize'); } if (this._ownerWritableStream === undefined) { throw defaultWriterLockException('desiredSize'); } return WritableStreamDefaultWriterGetDesiredSize(this); } /** * Returns a promise that will be fulfilled when the desired size to fill the stream’s internal queue transitions * from non-positive to positive, signaling that it is no longer applying backpressure. Once the desired size dips * back to zero or below, the getter will return a new promise that stays pending until the next transition. * * If the stream becomes errored or aborted, or the writer’s lock is released, the returned promise will become * rejected. */ get ready(): Promise { if (!IsWritableStreamDefaultWriter(this)) { return promiseRejectedWith(defaultWriterBrandCheckException('ready')); } return this._readyPromise; } /** * If the reader is active, behaves the same as {@link WritableStream.abort | stream.abort(reason)}. */ abort(reason: any = undefined): Promise { if (!IsWritableStreamDefaultWriter(this)) { return promiseRejectedWith(defaultWriterBrandCheckException('abort')); } if (this._ownerWritableStream === undefined) { return promiseRejectedWith(defaultWriterLockException('abort')); } return WritableStreamDefaultWriterAbort(this, reason); } /** * If the reader is active, behaves the same as {@link WritableStream.close | stream.close()}. */ close(): Promise { if (!IsWritableStreamDefaultWriter(this)) { return promiseRejectedWith(defaultWriterBrandCheckException('close')); } const stream = this._ownerWritableStream; if (stream === undefined) { return promiseRejectedWith(defaultWriterLockException('close')); } if (WritableStreamCloseQueuedOrInFlight(stream)) { return promiseRejectedWith(new TypeError('Cannot close an already-closing stream')); } return WritableStreamDefaultWriterClose(this); } /** * Releases the writer’s lock on the corresponding stream. After the lock is released, the writer is no longer active. * If the associated stream is errored when the lock is released, the writer will appear errored in the same way from * now on; otherwise, the writer will appear closed. * * Note that the lock can still be released even if some ongoing writes have not yet finished (i.e. even if the * promises returned from previous calls to {@link WritableStreamDefaultWriter.write | write()} have not yet settled). * It’s not necessary to hold the lock on the writer for the duration of the write; the lock instead simply prevents * other producers from writing in an interleaved manner. */ releaseLock(): void { if (!IsWritableStreamDefaultWriter(this)) { throw defaultWriterBrandCheckException('releaseLock'); } const stream = this._ownerWritableStream; if (stream === undefined) { return; } assert(stream._writer !== undefined); WritableStreamDefaultWriterRelease(this); } /** * Writes the given chunk to the writable stream, by waiting until any previous writes have finished successfully, * and then sending the chunk to the underlying sink's {@link UnderlyingSink.write | write()} method. It will return * a promise that fulfills with undefined upon a successful write, or rejects if the write fails or stream becomes * errored before the writing process is initiated. * * Note that what "success" means is up to the underlying sink; it might indicate simply that the chunk has been * accepted, and not necessarily that it is safely saved to its ultimate destination. */ write(chunk: W): Promise; write(chunk: W = undefined!): Promise { if (!IsWritableStreamDefaultWriter(this)) { return promiseRejectedWith(defaultWriterBrandCheckException('write')); } if (this._ownerWritableStream === undefined) { return promiseRejectedWith(defaultWriterLockException('write to')); } return WritableStreamDefaultWriterWrite(this, chunk); } } Object.defineProperties(WritableStreamDefaultWriter.prototype, { abort: { enumerable: true }, close: { enumerable: true }, releaseLock: { enumerable: true }, write: { enumerable: true }, closed: { enumerable: true }, desiredSize: { enumerable: true }, ready: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(WritableStreamDefaultWriter.prototype, Symbol.toStringTag, { value: 'WritableStreamDefaultWriter', configurable: true }); } // Abstract operations for the WritableStreamDefaultWriter. function IsWritableStreamDefaultWriter(x: any): x is WritableStreamDefaultWriter { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_ownerWritableStream')) { return false; } return x instanceof WritableStreamDefaultWriter; } // A client of WritableStreamDefaultWriter may use these functions directly to bypass state check. function WritableStreamDefaultWriterAbort(writer: WritableStreamDefaultWriter, reason: any) { const stream = writer._ownerWritableStream; assert(stream !== undefined); return WritableStreamAbort(stream, reason); } function WritableStreamDefaultWriterClose(writer: WritableStreamDefaultWriter): Promise { const stream = writer._ownerWritableStream; assert(stream !== undefined); return WritableStreamClose(stream); } function WritableStreamDefaultWriterCloseWithErrorPropagation(writer: WritableStreamDefaultWriter): Promise { const stream = writer._ownerWritableStream; assert(stream !== undefined); const state = stream._state; if (WritableStreamCloseQueuedOrInFlight(stream) || state === 'closed') { return promiseResolvedWith(undefined); } if (state === 'errored') { return promiseRejectedWith(stream._storedError); } assert(state === 'writable' || state === 'erroring'); return WritableStreamDefaultWriterClose(writer); } function WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer: WritableStreamDefaultWriter, error: any) { if (writer._closedPromiseState === 'pending') { defaultWriterClosedPromiseReject(writer, error); } else { defaultWriterClosedPromiseResetToRejected(writer, error); } } function WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer: WritableStreamDefaultWriter, error: any) { if (writer._readyPromiseState === 'pending') { defaultWriterReadyPromiseReject(writer, error); } else { defaultWriterReadyPromiseResetToRejected(writer, error); } } function WritableStreamDefaultWriterGetDesiredSize(writer: WritableStreamDefaultWriter): number | null { const stream = writer._ownerWritableStream; const state = stream._state; if (state === 'errored' || state === 'erroring') { return null; } if (state === 'closed') { return 0; } return WritableStreamDefaultControllerGetDesiredSize(stream._writableStreamController); } function WritableStreamDefaultWriterRelease(writer: WritableStreamDefaultWriter) { const stream = writer._ownerWritableStream; assert(stream !== undefined); assert(stream._writer === writer); const releasedError = new TypeError( `Writer was released and can no longer be used to monitor the stream's closedness`); WritableStreamDefaultWriterEnsureReadyPromiseRejected(writer, releasedError); // The state transitions to "errored" before the sink abort() method runs, but the writer.closed promise is not // rejected until afterwards. This means that simply testing state will not work. WritableStreamDefaultWriterEnsureClosedPromiseRejected(writer, releasedError); stream._writer = undefined; writer._ownerWritableStream = undefined!; } function WritableStreamDefaultWriterWrite(writer: WritableStreamDefaultWriter, chunk: W): Promise { const stream = writer._ownerWritableStream; assert(stream !== undefined); const controller = stream._writableStreamController; const chunkSize = WritableStreamDefaultControllerGetChunkSize(controller, chunk); if (stream !== writer._ownerWritableStream) { return promiseRejectedWith(defaultWriterLockException('write to')); } const state = stream._state; if (state === 'errored') { return promiseRejectedWith(stream._storedError); } if (WritableStreamCloseQueuedOrInFlight(stream) || state === 'closed') { return promiseRejectedWith(new TypeError('The stream is closing or closed and cannot be written to')); } if (state === 'erroring') { return promiseRejectedWith(stream._storedError); } assert(state === 'writable'); const promise = WritableStreamAddWriteRequest(stream); WritableStreamDefaultControllerWrite(controller, chunk, chunkSize); return promise; } const closeSentinel: unique symbol = {} as any; type QueueRecord = W | typeof closeSentinel; /** * Allows control of a {@link WritableStream | writable stream}'s state and internal queue. * * @public */ export class WritableStreamDefaultController { /** @internal */ _controlledWritableStream!: WritableStream; /** @internal */ _queue!: SimpleQueue>>; /** @internal */ _queueTotalSize!: number; /** @internal */ _abortReason: any; /** @internal */ _abortController: AbortController | undefined; /** @internal */ _started!: boolean; /** @internal */ _strategySizeAlgorithm!: QueuingStrategySizeCallback; /** @internal */ _strategyHWM!: number; /** @internal */ _writeAlgorithm!: (chunk: W) => Promise; /** @internal */ _closeAlgorithm!: () => Promise; /** @internal */ _abortAlgorithm!: (reason: any) => Promise; private constructor() { throw new TypeError('Illegal constructor'); } /** * The reason which was passed to `WritableStream.abort(reason)` when the stream was aborted. * * @deprecated * This property has been removed from the specification, see https://github.com/whatwg/streams/pull/1177. * Use {@link WritableStreamDefaultController.signal}'s `reason` instead. */ get abortReason(): any { if (!IsWritableStreamDefaultController(this)) { throw defaultControllerBrandCheckException('abortReason'); } return this._abortReason; } /** * An `AbortSignal` that can be used to abort the pending write or close operation when the stream is aborted. */ get signal(): AbortSignal { if (!IsWritableStreamDefaultController(this)) { throw defaultControllerBrandCheckException('signal'); } if (this._abortController === undefined) { // Older browsers or older Node versions may not support `AbortController` or `AbortSignal`. // We don't want to bundle and ship an `AbortController` polyfill together with our polyfill, // so instead we only implement support for `signal` if we find a global `AbortController` constructor. throw new TypeError('WritableStreamDefaultController.prototype.signal is not supported'); } return this._abortController.signal; } /** * Closes the controlled writable stream, making all future interactions with it fail with the given error `e`. * * This method is rarely used, since usually it suffices to return a rejected promise from one of the underlying * sink's methods. However, it can be useful for suddenly shutting down a stream in response to an event outside the * normal lifecycle of interactions with the underlying sink. */ error(e: any = undefined): void { if (!IsWritableStreamDefaultController(this)) { throw defaultControllerBrandCheckException('error'); } const state = this._controlledWritableStream._state; if (state !== 'writable') { // The stream is closed, errored or will be soon. The sink can't do anything useful if it gets an error here, so // just treat it as a no-op. return; } WritableStreamDefaultControllerError(this, e); } /** @internal */ [AbortSteps](reason: any): Promise { const result = this._abortAlgorithm(reason); WritableStreamDefaultControllerClearAlgorithms(this); return result; } /** @internal */ [ErrorSteps]() { ResetQueue(this); } } Object.defineProperties(WritableStreamDefaultController.prototype, { abortReason: { enumerable: true }, signal: { enumerable: true }, error: { enumerable: true } }); if (typeof Symbol.toStringTag === 'symbol') { Object.defineProperty(WritableStreamDefaultController.prototype, Symbol.toStringTag, { value: 'WritableStreamDefaultController', configurable: true }); } // Abstract operations implementing interface required by the WritableStream. function IsWritableStreamDefaultController(x: any): x is WritableStreamDefaultController { if (!typeIsObject(x)) { return false; } if (!Object.prototype.hasOwnProperty.call(x, '_controlledWritableStream')) { return false; } return x instanceof WritableStreamDefaultController; } function SetUpWritableStreamDefaultController(stream: WritableStream, controller: WritableStreamDefaultController, startAlgorithm: () => void | PromiseLike, writeAlgorithm: (chunk: W) => Promise, closeAlgorithm: () => Promise, abortAlgorithm: (reason: any) => Promise, highWaterMark: number, sizeAlgorithm: QueuingStrategySizeCallback) { assert(IsWritableStream(stream)); assert(stream._writableStreamController === undefined); controller._controlledWritableStream = stream; stream._writableStreamController = controller; // Need to set the slots so that the assert doesn't fire. In the spec the slots already exist implicitly. controller._queue = undefined!; controller._queueTotalSize = undefined!; ResetQueue(controller); controller._abortReason = undefined; controller._abortController = createAbortController(); controller._started = false; controller._strategySizeAlgorithm = sizeAlgorithm; controller._strategyHWM = highWaterMark; controller._writeAlgorithm = writeAlgorithm; controller._closeAlgorithm = closeAlgorithm; controller._abortAlgorithm = abortAlgorithm; const backpressure = WritableStreamDefaultControllerGetBackpressure(controller); WritableStreamUpdateBackpressure(stream, backpressure); const startResult = startAlgorithm(); const startPromise = promiseResolvedWith(startResult); uponPromise( startPromise, () => { assert(stream._state === 'writable' || stream._state === 'erroring'); controller._started = true; WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); }, r => { assert(stream._state === 'writable' || stream._state === 'erroring'); controller._started = true; WritableStreamDealWithRejection(stream, r); } ); } function SetUpWritableStreamDefaultControllerFromUnderlyingSink(stream: WritableStream, underlyingSink: ValidatedUnderlyingSink, highWaterMark: number, sizeAlgorithm: QueuingStrategySizeCallback) { const controller = Object.create(WritableStreamDefaultController.prototype); let startAlgorithm: () => void | PromiseLike = () => undefined; let writeAlgorithm: (chunk: W) => Promise = () => promiseResolvedWith(undefined); let closeAlgorithm: () => Promise = () => promiseResolvedWith(undefined); let abortAlgorithm: (reason: any) => Promise = () => promiseResolvedWith(undefined); if (underlyingSink.start !== undefined) { startAlgorithm = () => underlyingSink.start!(controller); } if (underlyingSink.write !== undefined) { writeAlgorithm = chunk => underlyingSink.write!(chunk, controller); } if (underlyingSink.close !== undefined) { closeAlgorithm = () => underlyingSink.close!(); } if (underlyingSink.abort !== undefined) { abortAlgorithm = reason => underlyingSink.abort!(reason); } SetUpWritableStreamDefaultController( stream, controller, startAlgorithm, writeAlgorithm, closeAlgorithm, abortAlgorithm, highWaterMark, sizeAlgorithm ); } // ClearAlgorithms may be called twice. Erroring the same stream in multiple ways will often result in redundant calls. function WritableStreamDefaultControllerClearAlgorithms(controller: WritableStreamDefaultController) { controller._writeAlgorithm = undefined!; controller._closeAlgorithm = undefined!; controller._abortAlgorithm = undefined!; controller._strategySizeAlgorithm = undefined!; } function WritableStreamDefaultControllerClose(controller: WritableStreamDefaultController) { EnqueueValueWithSize(controller, closeSentinel, 0); WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); } function WritableStreamDefaultControllerGetChunkSize(controller: WritableStreamDefaultController, chunk: W): number { try { return controller._strategySizeAlgorithm(chunk); } catch (chunkSizeE) { WritableStreamDefaultControllerErrorIfNeeded(controller, chunkSizeE); return 1; } } function WritableStreamDefaultControllerGetDesiredSize(controller: WritableStreamDefaultController): number { return controller._strategyHWM - controller._queueTotalSize; } function WritableStreamDefaultControllerWrite(controller: WritableStreamDefaultController, chunk: W, chunkSize: number) { try { EnqueueValueWithSize(controller, chunk, chunkSize); } catch (enqueueE) { WritableStreamDefaultControllerErrorIfNeeded(controller, enqueueE); return; } const stream = controller._controlledWritableStream; if (!WritableStreamCloseQueuedOrInFlight(stream) && stream._state === 'writable') { const backpressure = WritableStreamDefaultControllerGetBackpressure(controller); WritableStreamUpdateBackpressure(stream, backpressure); } WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); } // Abstract operations for the WritableStreamDefaultController. function WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller: WritableStreamDefaultController) { const stream = controller._controlledWritableStream; if (!controller._started) { return; } if (stream._inFlightWriteRequest !== undefined) { return; } const state = stream._state; assert(state !== 'closed' && state !== 'errored'); if (state === 'erroring') { WritableStreamFinishErroring(stream); return; } if (controller._queue.length === 0) { return; } const value = PeekQueueValue(controller); if (value === closeSentinel) { WritableStreamDefaultControllerProcessClose(controller); } else { WritableStreamDefaultControllerProcessWrite(controller, value); } } function WritableStreamDefaultControllerErrorIfNeeded(controller: WritableStreamDefaultController, error: any) { if (controller._controlledWritableStream._state === 'writable') { WritableStreamDefaultControllerError(controller, error); } } function WritableStreamDefaultControllerProcessClose(controller: WritableStreamDefaultController) { const stream = controller._controlledWritableStream; WritableStreamMarkCloseRequestInFlight(stream); DequeueValue(controller); assert(controller._queue.length === 0); const sinkClosePromise = controller._closeAlgorithm(); WritableStreamDefaultControllerClearAlgorithms(controller); uponPromise( sinkClosePromise, () => { WritableStreamFinishInFlightClose(stream); }, reason => { WritableStreamFinishInFlightCloseWithError(stream, reason); } ); } function WritableStreamDefaultControllerProcessWrite(controller: WritableStreamDefaultController, chunk: W) { const stream = controller._controlledWritableStream; WritableStreamMarkFirstWriteRequestInFlight(stream); const sinkWritePromise = controller._writeAlgorithm(chunk); uponPromise( sinkWritePromise, () => { WritableStreamFinishInFlightWrite(stream); const state = stream._state; assert(state === 'writable' || state === 'erroring'); DequeueValue(controller); if (!WritableStreamCloseQueuedOrInFlight(stream) && state === 'writable') { const backpressure = WritableStreamDefaultControllerGetBackpressure(controller); WritableStreamUpdateBackpressure(stream, backpressure); } WritableStreamDefaultControllerAdvanceQueueIfNeeded(controller); }, reason => { if (stream._state === 'writable') { WritableStreamDefaultControllerClearAlgorithms(controller); } WritableStreamFinishInFlightWriteWithError(stream, reason); } ); } function WritableStreamDefaultControllerGetBackpressure(controller: WritableStreamDefaultController): boolean { const desiredSize = WritableStreamDefaultControllerGetDesiredSize(controller); return desiredSize <= 0; } // A client of WritableStreamDefaultController may use these functions directly to bypass state check. function WritableStreamDefaultControllerError(controller: WritableStreamDefaultController, error: any) { const stream = controller._controlledWritableStream; assert(stream._state === 'writable'); WritableStreamDefaultControllerClearAlgorithms(controller); WritableStreamStartErroring(stream, error); } // Helper functions for the WritableStream. function streamBrandCheckException(name: string): TypeError { return new TypeError(`WritableStream.prototype.${name} can only be used on a WritableStream`); } // Helper functions for the WritableStreamDefaultController. function defaultControllerBrandCheckException(name: string): TypeError { return new TypeError( `WritableStreamDefaultController.prototype.${name} can only be used on a WritableStreamDefaultController`); } // Helper functions for the WritableStreamDefaultWriter. function defaultWriterBrandCheckException(name: string): TypeError { return new TypeError( `WritableStreamDefaultWriter.prototype.${name} can only be used on a WritableStreamDefaultWriter`); } function defaultWriterLockException(name: string): TypeError { return new TypeError('Cannot ' + name + ' a stream using a released writer'); } function defaultWriterClosedPromiseInitialize(writer: WritableStreamDefaultWriter) { writer._closedPromise = newPromise((resolve, reject) => { writer._closedPromise_resolve = resolve; writer._closedPromise_reject = reject; writer._closedPromiseState = 'pending'; }); } function defaultWriterClosedPromiseInitializeAsRejected(writer: WritableStreamDefaultWriter, reason: any) { defaultWriterClosedPromiseInitialize(writer); defaultWriterClosedPromiseReject(writer, reason); } function defaultWriterClosedPromiseInitializeAsResolved(writer: WritableStreamDefaultWriter) { defaultWriterClosedPromiseInitialize(writer); defaultWriterClosedPromiseResolve(writer); } function defaultWriterClosedPromiseReject(writer: WritableStreamDefaultWriter, reason: any) { if (writer._closedPromise_reject === undefined) { return; } assert(writer._closedPromiseState === 'pending'); setPromiseIsHandledToTrue(writer._closedPromise); writer._closedPromise_reject(reason); writer._closedPromise_resolve = undefined; writer._closedPromise_reject = undefined; writer._closedPromiseState = 'rejected'; } function defaultWriterClosedPromiseResetToRejected(writer: WritableStreamDefaultWriter, reason: any) { assert(writer._closedPromise_resolve === undefined); assert(writer._closedPromise_reject === undefined); assert(writer._closedPromiseState !== 'pending'); defaultWriterClosedPromiseInitializeAsRejected(writer, reason); } function defaultWriterClosedPromiseResolve(writer: WritableStreamDefaultWriter) { if (writer._closedPromise_resolve === undefined) { return; } assert(writer._closedPromiseState === 'pending'); writer._closedPromise_resolve(undefined); writer._closedPromise_resolve = undefined; writer._closedPromise_reject = undefined; writer._closedPromiseState = 'resolved'; } function defaultWriterReadyPromiseInitialize(writer: WritableStreamDefaultWriter) { writer._readyPromise = newPromise((resolve, reject) => { writer._readyPromise_resolve = resolve; writer._readyPromise_reject = reject; }); writer._readyPromiseState = 'pending'; } function defaultWriterReadyPromiseInitializeAsRejected(writer: WritableStreamDefaultWriter, reason: any) { defaultWriterReadyPromiseInitialize(writer); defaultWriterReadyPromiseReject(writer, reason); } function defaultWriterReadyPromiseInitializeAsResolved(writer: WritableStreamDefaultWriter) { defaultWriterReadyPromiseInitialize(writer); defaultWriterReadyPromiseResolve(writer); } function defaultWriterReadyPromiseReject(writer: WritableStreamDefaultWriter, reason: any) { if (writer._readyPromise_reject === undefined) { return; } setPromiseIsHandledToTrue(writer._readyPromise); writer._readyPromise_reject(reason); writer._readyPromise_resolve = undefined; writer._readyPromise_reject = undefined; writer._readyPromiseState = 'rejected'; } function defaultWriterReadyPromiseReset(writer: WritableStreamDefaultWriter) { assert(writer._readyPromise_resolve === undefined); assert(writer._readyPromise_reject === undefined); defaultWriterReadyPromiseInitialize(writer); } function defaultWriterReadyPromiseResetToRejected(writer: WritableStreamDefaultWriter, reason: any) { assert(writer._readyPromise_resolve === undefined); assert(writer._readyPromise_reject === undefined); defaultWriterReadyPromiseInitializeAsRejected(writer, reason); } function defaultWriterReadyPromiseResolve(writer: WritableStreamDefaultWriter) { if (writer._readyPromise_resolve === undefined) { return; } writer._readyPromise_resolve(undefined); writer._readyPromise_resolve = undefined; writer._readyPromise_reject = undefined; writer._readyPromiseState = 'fulfilled'; } web-streams-polyfill-3.2.1/src/lib/writable-stream/000077500000000000000000000000001422364423700222445ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/lib/writable-stream/underlying-sink.ts000066400000000000000000000054411422364423700257420ustar00rootroot00000000000000import { WritableStreamDefaultController } from '../writable-stream'; /** @public */ export type UnderlyingSinkStartCallback = (controller: WritableStreamDefaultController) => void | PromiseLike; /** @public */ export type UnderlyingSinkWriteCallback = (chunk: W, controller: WritableStreamDefaultController) => void | PromiseLike; /** @public */ export type UnderlyingSinkCloseCallback = () => void | PromiseLike; /** @public */ export type UnderlyingSinkAbortCallback = (reason: any) => void | PromiseLike; /** * An underlying sink for constructing a {@link WritableStream}. * * @public */ export interface UnderlyingSink { /** * A function that is called immediately during creation of the {@link WritableStream}. */ start?: UnderlyingSinkStartCallback; /** * A function that is called when a new chunk of data is ready to be written to the underlying sink. The stream * implementation guarantees that this function will be called only after previous writes have succeeded, and never * before {@link UnderlyingSink.start | start()} has succeeded or after {@link UnderlyingSink.close | close()} or * {@link UnderlyingSink.abort | abort()} have been called. * * This function is used to actually send the data to the resource presented by the underlying sink, for example by * calling a lower-level API. */ write?: UnderlyingSinkWriteCallback; /** * A function that is called after the producer signals, via * {@link WritableStreamDefaultWriter.close | writer.close()}, that they are done writing chunks to the stream, and * subsequently all queued-up writes have successfully completed. * * This function can perform any actions necessary to finalize or flush writes to the underlying sink, and release * access to any held resources. */ close?: UnderlyingSinkCloseCallback; /** * A function that is called after the producer signals, via {@link WritableStream.abort | stream.abort()} or * {@link WritableStreamDefaultWriter.abort | writer.abort()}, that they wish to abort the stream. It takes as its * argument the same value as was passed to those methods by the producer. * * Writable streams can additionally be aborted under certain conditions during piping; see the definition of the * {@link ReadableStream.pipeTo | pipeTo()} method for more details. * * This function can clean up any held resources, much like {@link UnderlyingSink.close | close()}, but perhaps with * some custom handling. */ abort?: UnderlyingSinkAbortCallback; type?: undefined; } export interface ValidatedUnderlyingSink extends UnderlyingSink { write?: (chunk: W, controller: WritableStreamDefaultController) => Promise; close?: () => Promise; abort?: (reason: any) => Promise; } web-streams-polyfill-3.2.1/src/polyfill.ts000066400000000000000000000022541422364423700206010ustar00rootroot00000000000000import { ByteLengthQueuingStrategy, CountQueuingStrategy, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, TransformStream, TransformStreamDefaultController, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter } from './ponyfill'; import { globals } from './utils'; // Export export * from './ponyfill'; const exports = { ReadableStream, ReadableStreamDefaultController, ReadableByteStreamController, ReadableStreamBYOBRequest, ReadableStreamDefaultReader, ReadableStreamBYOBReader, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, ByteLengthQueuingStrategy, CountQueuingStrategy, TransformStream, TransformStreamDefaultController }; // Add classes to global scope if (typeof globals !== 'undefined') { for (const prop in exports) { if (Object.prototype.hasOwnProperty.call(exports, prop)) { Object.defineProperty(globals, prop, { value: exports[prop as (keyof typeof exports)], writable: true, configurable: true }); } } } web-streams-polyfill-3.2.1/src/ponyfill.ts000066400000000000000000000045571422364423700206130ustar00rootroot00000000000000import { ReadableByteStreamController, ReadableStream, ReadableStreamAsyncIterator, ReadableStreamBYOBReader, ReadableStreamBYOBReadResult, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, ReadableStreamDefaultReadResult, ReadableStreamIteratorOptions, ReadableWritablePair, StreamPipeOptions, UnderlyingByteSource, UnderlyingByteSourcePullCallback, UnderlyingByteSourceStartCallback, UnderlyingSource, UnderlyingSourceCancelCallback, UnderlyingSourcePullCallback, UnderlyingSourceStartCallback } from './lib/readable-stream'; import { UnderlyingSink, UnderlyingSinkAbortCallback, UnderlyingSinkCloseCallback, UnderlyingSinkStartCallback, UnderlyingSinkWriteCallback, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter } from './lib/writable-stream'; import { QueuingStrategy, QueuingStrategyInit } from './lib/queuing-strategy'; import ByteLengthQueuingStrategy from './lib/byte-length-queuing-strategy'; import CountQueuingStrategy from './lib/count-queuing-strategy'; import { Transformer, TransformerFlushCallback, TransformerStartCallback, TransformerTransformCallback, TransformStream, TransformStreamDefaultController } from './lib/transform-stream'; import { AbortSignal } from './lib/abort-signal'; export { ReadableStream, UnderlyingSource, UnderlyingByteSource, UnderlyingSourceStartCallback, UnderlyingSourcePullCallback, UnderlyingSourceCancelCallback, UnderlyingByteSourceStartCallback, UnderlyingByteSourcePullCallback, ReadableWritablePair, StreamPipeOptions, ReadableStreamDefaultReadResult, ReadableStreamBYOBReadResult, ReadableStreamDefaultController, ReadableByteStreamController, ReadableStreamBYOBRequest, ReadableStreamDefaultReader, ReadableStreamBYOBReader, ReadableStreamAsyncIterator, ReadableStreamIteratorOptions, WritableStream, UnderlyingSink, UnderlyingSinkStartCallback, UnderlyingSinkWriteCallback, UnderlyingSinkCloseCallback, UnderlyingSinkAbortCallback, WritableStreamDefaultController, WritableStreamDefaultWriter, QueuingStrategy, QueuingStrategyInit, ByteLengthQueuingStrategy, CountQueuingStrategy, TransformStream, Transformer, TransformerStartCallback, TransformerFlushCallback, TransformerTransformCallback, TransformStreamDefaultController, AbortSignal }; web-streams-polyfill-3.2.1/src/stub/000077500000000000000000000000001422364423700173515ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/stub/assert.ts000066400000000000000000000007221422364423700212230ustar00rootroot00000000000000import { noop } from '../utils'; export const AssertionError = /* @__PURE__*/ class AssertionError extends Error { constructor(message: string) { super(message); Object.setPrototypeOf(this, new.target.prototype); } }; const assert: (test: boolean, message?: string) => void = DEBUG ? (test, message) => { if (!test) { throw new AssertionError('Assertion failed' + (message ? `: ${message}` : '')); } } : noop; export default assert; web-streams-polyfill-3.2.1/src/stub/dom-exception.ts000066400000000000000000000025141422364423700224760ustar00rootroot00000000000000/// import { NativeDOMException } from './native'; declare class DOMExceptionClass extends Error { constructor(message?: string, name?: string); name: string; message: string; } type DOMException = DOMExceptionClass; type DOMExceptionConstructor = typeof DOMExceptionClass; function isDOMExceptionConstructor(ctor: unknown): ctor is DOMExceptionConstructor { if (!(typeof ctor === 'function' || typeof ctor === 'object')) { return false; } try { new (ctor as DOMExceptionConstructor)(); return true; } catch { return false; } } function createDOMExceptionPolyfill(): DOMExceptionConstructor { // eslint-disable-next-line no-shadow const ctor = function DOMException(this: DOMException, message?: string, name?: string) { this.message = message || ''; this.name = name || 'Error'; if (Error.captureStackTrace) { Error.captureStackTrace(this, this.constructor); } } as any; ctor.prototype = Object.create(Error.prototype); Object.defineProperty(ctor.prototype, 'constructor', { value: ctor, writable: true, configurable: true }); return ctor; } // eslint-disable-next-line no-redeclare const DOMException: DOMExceptionConstructor = isDOMExceptionConstructor(NativeDOMException) ? NativeDOMException : createDOMExceptionPolyfill(); export { DOMException }; web-streams-polyfill-3.2.1/src/stub/math-trunc.ts000066400000000000000000000004341422364423700220040ustar00rootroot00000000000000/// // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc#Polyfill const MathTrunc: typeof Math.trunc = Math.trunc || function (v) { return v < 0 ? Math.ceil(v) : Math.floor(v); }; export default MathTrunc; web-streams-polyfill-3.2.1/src/stub/native.ts000066400000000000000000000002411422364423700212040ustar00rootroot00000000000000/// export const NativeDOMException: typeof DOMException | undefined = typeof DOMException !== 'undefined' ? DOMException : undefined; web-streams-polyfill-3.2.1/src/stub/number-isfinite.ts000066400000000000000000000004651422364423700230260ustar00rootroot00000000000000/// // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isFinite#Polyfill const NumberIsFinite: typeof Number.isFinite = Number.isFinite || function (x) { return typeof x === 'number' && isFinite(x); }; export default NumberIsFinite; web-streams-polyfill-3.2.1/src/stub/number-isinteger.ts000066400000000000000000000005551422364423700232050ustar00rootroot00000000000000/// // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger#Polyfill const NumberIsInteger: typeof Number.isInteger = Number.isInteger || function (value) { return typeof value === 'number' && isFinite(value) && Math.floor(value) === value; }; export default NumberIsInteger; web-streams-polyfill-3.2.1/src/stub/number-isnan.ts000066400000000000000000000004671422364423700223260ustar00rootroot00000000000000/// // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN#Polyfill const NumberIsNaN: typeof Number.isNaN = Number.isNaN || function (x) { // eslint-disable-next-line no-self-compare return x !== x; }; export default NumberIsNaN; web-streams-polyfill-3.2.1/src/stub/symbol.ts000066400000000000000000000004231422364423700212250ustar00rootroot00000000000000/// const SymbolPolyfill: (description?: string) => symbol = typeof Symbol === 'function' && typeof Symbol.iterator === 'symbol' ? Symbol : description => `Symbol(${description})` as any as symbol; export default SymbolPolyfill; web-streams-polyfill-3.2.1/src/target/000077500000000000000000000000001422364423700176625ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/target/es2018/000077500000000000000000000000001422364423700206045ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/target/es2018/stub/000077500000000000000000000000001422364423700215615ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/target/es2018/stub/async-iterator-prototype.ts000066400000000000000000000004331422364423700271400ustar00rootroot00000000000000/// /* eslint-disable @typescript-eslint/no-empty-function */ export const AsyncIteratorPrototype: AsyncIterable | undefined = Object.getPrototypeOf(Object.getPrototypeOf(async function* (): AsyncIterableIterator {}).prototype); web-streams-polyfill-3.2.1/src/target/es5/000077500000000000000000000000001422364423700203565ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/target/es5/stub/000077500000000000000000000000001422364423700213335ustar00rootroot00000000000000web-streams-polyfill-3.2.1/src/target/es5/stub/async-iterator-prototype.ts000066400000000000000000000013011422364423700267050ustar00rootroot00000000000000/// export let AsyncIteratorPrototype: AsyncIterable | undefined; if (typeof Symbol.asyncIterator === 'symbol') { // We're running inside a ES2018+ environment, but we're compiling to an older syntax. // We cannot access %AsyncIteratorPrototype% without non-ES2018 syntax, but we can re-create it. AsyncIteratorPrototype = { // 25.1.3.1 %AsyncIteratorPrototype% [ @@asyncIterator ] ( ) // https://tc39.github.io/ecma262/#sec-asynciteratorprototype-asynciterator [Symbol.asyncIterator](this: AsyncIterator) { return this; } }; Object.defineProperty(AsyncIteratorPrototype, Symbol.asyncIterator, { enumerable: false }); } web-streams-polyfill-3.2.1/src/utils.ts000066400000000000000000000005501422364423700201040ustar00rootroot00000000000000/// export function noop(): undefined { return undefined; } function getGlobals() { if (typeof self !== 'undefined') { return self; } else if (typeof window !== 'undefined') { return window; } else if (typeof global !== 'undefined') { return global; } return undefined; } export const globals = getGlobals(); web-streams-polyfill-3.2.1/test/000077500000000000000000000000001422364423700165645ustar00rootroot00000000000000web-streams-polyfill-3.2.1/test/.eslintrc.json000066400000000000000000000001511422364423700213550ustar00rootroot00000000000000{ "extends": ["../.eslintrc.json"], "rules": { "@typescript-eslint/no-var-requires": "off" } } web-streams-polyfill-3.2.1/test/benchmark/000077500000000000000000000000001422364423700205165ustar00rootroot00000000000000web-streams-polyfill-3.2.1/test/benchmark/index.js000066400000000000000000000026231422364423700221660ustar00rootroot00000000000000const Benchmark = require('benchmark'); const polyfill = require('../../dist/polyfill.es6.js'); const stardazed = require('@stardazed/streams'); const suite = new Benchmark.Suite(); const implementations = [ ['web-streams-polyfill', polyfill], ['@stardazed/streams', stardazed] ]; // https://github.com/MattiasBuelens/web-streams-polyfill/issues/15 function testCount(impl, count, deferred) { const rs = new impl.ReadableStream({ start(controller) { for (let i = 0; i < count; ++i) { controller.enqueue(i); } controller.close(); } }); const reader = rs.getReader(); return readLoop(count, reader) .then(() => deferred.resolve()); } function readLoop(count, reader) { return reader.read().then(result => { if (result.done) { return undefined; } return readLoop(count, reader); }); } for (const [name, impl] of implementations) { for (let count = 3545; count <= 113440; count *= 2) { suite.add( `${name} testCount(${count})`, deferred => testCount(impl, count, deferred), { defer: true } ); } } suite .on('cycle', event => { // eslint-disable-next-line no-console const bench = event.target; console.log(`${String(bench)} (period: ${(bench.times.period * 1000).toFixed(2)}ms)`); }) .on('complete', () => { // eslint-disable-next-line no-console console.log('Done'); }) .run({ async: true }); web-streams-polyfill-3.2.1/test/benchmark/package-lock.json000066400000000000000000000023321422364423700237320ustar00rootroot00000000000000{ "name": "web-streams-polyfill-benchmark", "version": "0.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { "@stardazed/streams": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@stardazed/streams/-/streams-3.0.0.tgz", "integrity": "sha512-CCZmu6xD8SPhI/llli4KV4YyLqUlP75rymxSRJu/Cp67ECKrOj5OxWSxuJBEG7iebd5wiPbP3DeXjvs7DMtAYA==", "dev": true }, "benchmark": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz", "integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=", "dev": true, "requires": { "lodash": "^4.17.4", "platform": "^1.3.3" } }, "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "dev": true }, "platform": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/platform/-/platform-1.3.5.tgz", "integrity": "sha512-TuvHS8AOIZNAlE77WUDiR4rySV/VMptyMfcfeoMgs4P8apaZM3JrnbzBiixKUv+XR6i+BXrQh8WAnjaSPFO65Q==", "dev": true } } } web-streams-polyfill-3.2.1/test/benchmark/package.json000066400000000000000000000004041422364423700230020ustar00rootroot00000000000000{ "name": "web-streams-polyfill-benchmark", "version": "0.0.0", "private": true, "main": "index.js", "scripts": { "benchmark": "node --prof index.js" }, "devDependencies": { "@stardazed/streams": "^3.0.0", "benchmark": "^2.1.4" } } web-streams-polyfill-3.2.1/test/run-web-platform-tests.js000066400000000000000000000204651422364423700234720ustar00rootroot00000000000000// This runs the web platform tests against the reference implementation, in Node.js using jsdom, for easier rapid // development of the reference implementation and the web platform tests. /* eslint-disable no-console */ const path = require('path'); const fs = require('fs'); const { promisify } = require('util'); const micromatch = require('micromatch'); const wptRunner = require('wpt-runner'); const consoleReporter = require('wpt-runner/lib/console-reporter.js'); const { FilteringReporter } = require('./wpt-util/filtering-reporter.js'); const allSettled = require('@ungap/promise-all-settled'); const readFileAsync = promisify(fs.readFile); const queueMicrotask = global.queueMicrotask || (fn => Promise.resolve().then(fn)); // wpt-runner does not yet support unhandled rejection tracking a la // https://github.com/w3c/testharness.js/commit/7716e2581a86dfd9405a9c00547a7504f0c7fe94 // So we emulate it with Node.js events const rejections = new Map(); process.on('unhandledRejection', (reason, promise) => { rejections.set(promise, reason); }); process.on('rejectionHandled', promise => { rejections.delete(promise); }); main().catch(e => { console.error(e.stack); process.exitCode = 1; }); async function main() { const supportsES2018 = runtimeSupportsAsyncGenerators(); const excludedTests = [ // We cannot polyfill TransferArrayBuffer yet, so disable tests for detached array buffers // See https://github.com/MattiasBuelens/web-streams-polyfill/issues/3 'readable-byte-streams/bad-buffers-and-views.any.html', 'readable-byte-streams/enqueue-with-detached-buffer.window.html', 'readable-byte-streams/non-transferable-buffers.any.html', // Disable tests for different size functions per realm, since they need a working