{“version”:3,“file”:“workbox-streams.dev.js”,“sources”:,“sourcesContent”:[“"use strict";n// @ts-ignorentry {n self && _();n}ncatch (e) { }n”,“/*n Copyright 2018 Google LLCnn Use of this source code is governed by an MIT-stylen license that can be found in the LICENSE file or atn opensource.org/licenses/MIT.n*/nimport { logger } from 'workbox-core/_private/logger.js';nimport { assert } from 'workbox-core/_private/assert.js';nimport { Deferred } from 'workbox-core/_private/Deferred.js';nimport './_version.js';n/**n * Takes either a Response, a ReadableStream, or an * [BodyInit](fetch.spec.whatwg.org/#bodyinit) and returns then * ReadableStreamReader object associated with it.n *n * @param {module:workbox-streams.StreamSource} sourcen * @return {ReadableStreamReader}n * @privaten */nfunction _getReaderFromSource(source) {n if (source instanceof Response) {n return source.body.getReader();n }n if (source instanceof ReadableStream) {n return source.getReader();n }n return new Response(source).body.getReader();n}n/**n * Takes multiple source Promises, each of which could resolve to a Response, an * ReadableStream, or a [BodyInit](fetch.spec.whatwg.org/#bodyinit).n *n * Returns an object exposing a ReadableStream with each individual stream'sn * data returned in sequence, along with a Promise which signals when then * stream is finished (useful for passing to a FetchEvent's waitUntil()).n *n * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromisesn * @return {Object<{done: Promise, stream: ReadableStream}>}n *n * @memberof module:workbox-streamsn */nfunction concatenate(sourcePromises) {n if (process.env.NODE_ENV !== 'production') {n assert.isArray(sourcePromises, {n moduleName: 'workbox-streams',n funcName: 'concatenate',n paramName: 'sourcePromises',n });n }n const readerPromises = sourcePromises.map((sourcePromise) => {n return Promise.resolve(sourcePromise).then((source) => {n return _getReaderFromSource(source);n });n });n const streamDeferred = new Deferred();n let i = 0;n const logMessages = [];n const stream = new ReadableStream({n pull(controller) {n return readerPromisesn .then((reader) => reader.read())n .then((result) => {n if (result.done) {n if (process.env.NODE_ENV !== 'production') {n logMessages.push(['Reached the end of source:',n sourcePromises]);n }n i++;n if (i >= readerPromises.length) {n // Log all the messages in the group at once in a single group.n if (process.env.NODE_ENV !== 'production') {n logger.groupCollapsed(`Concatenating ${readerPromises.length} sources.`);n for (const message of logMessages) {n if (Array.isArray(message)) {n logger.log(…message);n }n else {n logger.log(message);n }n }n logger.log('Finished reading all sources.');n logger.groupEnd();n }n controller.close();n streamDeferred.resolve();n return;n }n // The `pull` method is defined because we're inside it.n return this.pull(controller);n }n else {n controller.enqueue(result.value);n }n }).catch((error) => {n if (process.env.NODE_ENV !== 'production') {n logger.error('An error occurred:', error);n }n streamDeferred.reject(error);n throw error;n });n },n cancel() {n if (process.env.NODE_ENV !== 'production') {n logger.warn('The ReadableStream was cancelled.');n }n streamDeferred.resolve();n },n });n return { done: streamDeferred.promise, stream };n}nexport { concatenate };n”,“/*n Copyright 2018 Google LLCnn Use of this source code is governed by an MIT-stylen license that can be found in the LICENSE file or atn opensource.org/licenses/MIT.n*/nimport '../_version.js';n/**n * This is a utility method that determines whether the current browser supportsn * the features required to create streamed responses. Currently, it checks ifn * [`ReadableStream`](developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)n * is available.n *n * @privaten * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,n * `'text/html'` will be used by default.n * @return {boolean} `true`, if the current browser meets the requirements forn * streaming responses, and `false` otherwise.n *n * @memberof module:workbox-streamsn */nfunction createHeaders(headersInit = {}) {n // See github.com/GoogleChrome/workbox/issues/1461n const headers = new Headers(headersInit);n if (!headers.has('content-type')) {n headers.set('content-type', 'text/html');n }n return headers;n}nexport { createHeaders };n”,“/*n Copyright 2018 Google LLCnn Use of this source code is governed by an MIT-stylen license that can be found in the LICENSE file or atn opensource.org/licenses/MIT.n*/nimport { createHeaders } from './utils/createHeaders.js';nimport { concatenate } from './concatenate.js';nimport './_version.js';n/**n * Takes multiple source Promises, each of which could resolve to a Response, an * ReadableStream, or a [BodyInit](fetch.spec.whatwg.org/#bodyinit),n * along with an * [HeadersInit](fetch.spec.whatwg.org/#typedefdef-headersinit).n *n * Returns an object exposing a Response whose body consists of each individualn * stream's data returned in sequence, along with a Promise which signals whenn * the stream is finished (useful for passing to a FetchEvent's waitUntil()).n *n * @param {Array<Promise<module:workbox-streams.StreamSource>>} sourcePromisesn * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,n * `'text/html'` will be used by default.n * @return {Object<{done: Promise, response: Response}>}n *n * @memberof module:workbox-streamsn */nfunction concatenateToResponse(sourcePromises, headersInit) {n const { done, stream } = concatenate(sourcePromises);n const headers = createHeaders(headersInit);n const response = new Response(stream, { headers });n return { done, response };n}nexport { concatenateToResponse };n”,“/*n Copyright 2018 Google LLCnn Use of this source code is governed by an MIT-stylen license that can be found in the LICENSE file or atn opensource.org/licenses/MIT.n*/nimport { canConstructReadableStream } from 'workbox-core/_private/canConstructReadableStream.js';nimport './_version.js';n/**n * This is a utility method that determines whether the current browser supportsn * the features required to create streamed responses. Currently, it checks ifn * [`ReadableStream`](developer.mozilla.org/en-US/docs/Web/API/ReadableStream/ReadableStream)n * can be created.n *n * @return {boolean} `true`, if the current browser meets the requirements forn * streaming responses, and `false` otherwise.n *n * @memberof module:workbox-streamsn */nfunction isSupported() {n return canConstructReadableStream();n}nexport { isSupported };n”,“/*n Copyright 2018 Google LLCnn Use of this source code is governed by an MIT-stylen license that can be found in the LICENSE file or atn opensource.org/licenses/MIT.n*/nimport { logger } from 'workbox-core/_private/logger.js';nimport { createHeaders } from './utils/createHeaders.js';nimport { concatenateToResponse } from './concatenateToResponse.js';nimport { isSupported } from './isSupported.js';nimport './_version.js';n/**n * A shortcut to create a strategy that could be dropped-in to Workbox's router.n *n * On browsers that do not support constructing new `ReadableStream`s, thisn * strategy will automatically wait for all the `sourceFunctions` to complete,n * and create a final response that concatenates their values together.n *n * @param {Array<function({event, request, url, params})>} sourceFunctionsn * An array of functions similar to {@link module:workbox-routing~handlerCallback}n * but that instead return a {@link module:workbox-streams.StreamSource} (or an * Promise which resolves to one).n * @param {HeadersInit} [headersInit] If there's no `Content-Type` specified,n * `'text/html'` will be used by default.n * @return {module:workbox-routing~handlerCallback}n * @memberof module:workbox-streamsn */nfunction strategy(sourceFunctions, headersInit) {n return async ({ event, request, url, params }) => {n const sourcePromises = sourceFunctions.map((fn) => {n // Ensure the return value of the function is always a promise.n return Promise.resolve(fn({ event, request, url, params }));n });n if (isSupported()) {n const { done, response } = concatenateToResponse(sourcePromises, headersInit);n if (event) {n event.waitUntil(done);n }n return response;n }n if (process.env.NODE_ENV !== 'production') {n logger.log(`The current browser doesn't support creating response ` +n `streams. Falling back to non-streaming response instead.`);n }n // Fallback to waiting for everything to finish, and concatenating then // responses.n const blobPartsPromises = sourcePromises.map(async (sourcePromise) => {n const source = await sourcePromise;n if (source instanceof Response) {n return source.blob();n }n else {n // Technically, a `StreamSource` object can include any validn // `BodyInit` type, including `FormData` and `URLSearchParams`, whichn // cannot be passed to the Blob constructor directly, so we have ton // convert them to actual Blobs first.n return new Response(source).blob();n }n });n const blobParts = await Promise.all(blobPartsPromises);n const headers = createHeaders(headersInit);n // Constructing a new Response from a Blob source is well-supported.n // So is constructing a new Blob from multiple source Blobs or strings.n return new Response(new Blob(blobParts), { headers });n };n}nexport { strategy };n”],“names”:,“mappings”:“;;;;IAEA,IAAI;IACAA,EAAAA,IAAI,CAAC,uBAAD,CAAJ,IAAiCC,CAAC,EAAlC;IACH,CAFD,CAGA,OAAOC,CAAP,EAAU;;ICLV;;;;;;;AAOA,IAIA;;;;;;;;;;IASA,SAASC,oBAAT,CAA8BC,MAA9B,EAAsC;IAClC,MAAIA,MAAM,YAAYC,QAAtB,EAAgC;IAC5B,WAAOD,MAAM,CAACE,IAAP,CAAYC,SAAZ,EAAP;IACH;;IACD,MAAIH,MAAM,YAAYI,cAAtB,EAAsC;IAClC,WAAOJ,MAAM,CAACG,SAAP,EAAP;IACH;;IACD,SAAO,IAAIF,QAAJ,CAAaD,MAAb,EAAqBE,IAArB,CAA0BC,SAA1B,EAAP;IACH;IACD;;;;;;;;;;;;;;;IAaA,SAASE,WAAT,CAAqBC,cAArB,EAAqC;IACjC,EAA2C;IACvC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