source: frontend/node_modules/webpack-sources/lib/helpers/streamChunks.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const streamChunksOfRawSource = require("./streamChunksOfRawSource");
9const streamChunksOfSourceMap = require("./streamChunksOfSourceMap");
10
11/** @typedef {import("../Source")} Source */
12/** @typedef {import("./getGeneratedSourceInfo").GeneratedSourceInfo} GeneratedSourceInfo */
13/** @typedef {(chunk: string | undefined, generatedLine: number, generatedColumn: number, sourceIndex: number, originalLine: number, originalColumn: number, nameIndex: number) => void} OnChunk */
14/** @typedef {(sourceIndex: number, source: string | null, sourceContent: string | undefined) => void} OnSource */
15/** @typedef {(nameIndex: number, name: string) => void} OnName */
16
17/** @typedef {{ source?: boolean, finalSource?: boolean, columns?: boolean }} Options */
18
19/**
20 * @callback StreamChunksFunction
21 * @param {Options} options options
22 * @param {OnChunk} onChunk on chunk
23 * @param {OnSource} onSource on source
24 * @param {OnName} onName on name
25 */
26
27/** @typedef {Source & { streamChunks?: StreamChunksFunction }} SourceMaybeWithStreamChunksFunction */
28
29/**
30 * @param {SourceMaybeWithStreamChunksFunction} source source
31 * @param {Options} options options
32 * @param {OnChunk} onChunk on chunk
33 * @param {OnSource} onSource on source
34 * @param {OnName} onName on name
35 * @returns {GeneratedSourceInfo} generated source info
36 */
37module.exports = (source, options, onChunk, onSource, onName) => {
38 if (typeof source.streamChunks === "function") {
39 return source.streamChunks(options, onChunk, onSource, onName);
40 }
41 const sourceAndMap = source.sourceAndMap(options);
42 if (sourceAndMap.map) {
43 return streamChunksOfSourceMap(
44 /** @type {string} */
45 (sourceAndMap.source),
46 sourceAndMap.map,
47 onChunk,
48 onSource,
49 onName,
50 Boolean(options && options.finalSource),
51 Boolean(options && options.columns !== false),
52 );
53 }
54 return streamChunksOfRawSource(
55 /** @type {string} */
56 (sourceAndMap.source),
57 onChunk,
58 onSource,
59 onName,
60 Boolean(options && options.finalSource),
61 );
62};
Note: See TracBrowser for help on using the repository browser.