diff options
Diffstat (limited to 'node_modules/webpack-sources/lib')
24 files changed, 0 insertions, 3303 deletions
diff --git a/node_modules/webpack-sources/lib/CachedSource.js b/node_modules/webpack-sources/lib/CachedSource.js deleted file mode 100644 index 5fc2d4c9..00000000 --- a/node_modules/webpack-sources/lib/CachedSource.js +++ /dev/null @@ -1,274 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Source = require("./Source"); -const streamChunksOfSourceMap = require("./helpers/streamChunksOfSourceMap"); -const streamChunksOfRawSource = require("./helpers/streamChunksOfRawSource"); -const streamAndGetSourceAndMap = require("./helpers/streamAndGetSourceAndMap"); - -const mapToBufferedMap = map => { - if (typeof map !== "object" || !map) return map; - const bufferedMap = Object.assign({}, map); - if (map.mappings) { - bufferedMap.mappings = Buffer.from(map.mappings, "utf-8"); - } - if (map.sourcesContent) { - bufferedMap.sourcesContent = map.sourcesContent.map( - str => str && Buffer.from(str, "utf-8") - ); - } - return bufferedMap; -}; - -const bufferedMapToMap = bufferedMap => { - if (typeof bufferedMap !== "object" || !bufferedMap) return bufferedMap; - const map = Object.assign({}, bufferedMap); - if (bufferedMap.mappings) { - map.mappings = bufferedMap.mappings.toString("utf-8"); - } - if (bufferedMap.sourcesContent) { - map.sourcesContent = bufferedMap.sourcesContent.map( - buffer => buffer && buffer.toString("utf-8") - ); - } - return map; -}; - -class CachedSource extends Source { - constructor(source, cachedData) { - super(); - this._source = source; - this._cachedSourceType = cachedData ? cachedData.source : undefined; - this._cachedSource = undefined; - this._cachedBuffer = cachedData ? cachedData.buffer : undefined; - this._cachedSize = cachedData ? cachedData.size : undefined; - this._cachedMaps = cachedData ? cachedData.maps : new Map(); - this._cachedHashUpdate = cachedData ? cachedData.hash : undefined; - } - - getCachedData() { - const bufferedMaps = new Map(); - for (const pair of this._cachedMaps) { - let cacheEntry = pair[1]; - if (cacheEntry.bufferedMap === undefined) { - cacheEntry.bufferedMap = mapToBufferedMap( - this._getMapFromCacheEntry(cacheEntry) - ); - } - bufferedMaps.set(pair[0], { - map: undefined, - bufferedMap: cacheEntry.bufferedMap - }); - } - // We don't want to cache strings - // So if we have a caches sources - // create a buffer from it and only store - // if it was a Buffer or string - if (this._cachedSource) { - this.buffer(); - } - return { - buffer: this._cachedBuffer, - source: - this._cachedSourceType !== undefined - ? this._cachedSourceType - : typeof this._cachedSource === "string" - ? true - : Buffer.isBuffer(this._cachedSource) - ? false - : undefined, - size: this._cachedSize, - maps: bufferedMaps, - hash: this._cachedHashUpdate - }; - } - - originalLazy() { - return this._source; - } - - original() { - if (typeof this._source === "function") this._source = this._source(); - return this._source; - } - - source() { - const source = this._getCachedSource(); - if (source !== undefined) return source; - return (this._cachedSource = this.original().source()); - } - - _getMapFromCacheEntry(cacheEntry) { - if (cacheEntry.map !== undefined) { - return cacheEntry.map; - } else if (cacheEntry.bufferedMap !== undefined) { - return (cacheEntry.map = bufferedMapToMap(cacheEntry.bufferedMap)); - } - } - - _getCachedSource() { - if (this._cachedSource !== undefined) return this._cachedSource; - if (this._cachedBuffer && this._cachedSourceType !== undefined) { - return (this._cachedSource = this._cachedSourceType - ? this._cachedBuffer.toString("utf-8") - : this._cachedBuffer); - } - } - - buffer() { - if (this._cachedBuffer !== undefined) return this._cachedBuffer; - if (this._cachedSource !== undefined) { - if (Buffer.isBuffer(this._cachedSource)) { - return (this._cachedBuffer = this._cachedSource); - } - return (this._cachedBuffer = Buffer.from(this._cachedSource, "utf-8")); - } - if (typeof this.original().buffer === "function") { - return (this._cachedBuffer = this.original().buffer()); - } - const bufferOrString = this.source(); - if (Buffer.isBuffer(bufferOrString)) { - return (this._cachedBuffer = bufferOrString); - } - return (this._cachedBuffer = Buffer.from(bufferOrString, "utf-8")); - } - - size() { - if (this._cachedSize !== undefined) return this._cachedSize; - if (this._cachedBuffer !== undefined) { - return (this._cachedSize = this._cachedBuffer.length); - } - const source = this._getCachedSource(); - if (source !== undefined) { - return (this._cachedSize = Buffer.byteLength(source)); - } - return (this._cachedSize = this.original().size()); - } - - sourceAndMap(options) { - const key = options ? JSON.stringify(options) : "{}"; - const cacheEntry = this._cachedMaps.get(key); - // Look for a cached map - if (cacheEntry !== undefined) { - // We have a cached map in some representation - const map = this._getMapFromCacheEntry(cacheEntry); - // Either get the cached source or compute it - return { source: this.source(), map }; - } - // Look for a cached source - let source = this._getCachedSource(); - // Compute the map - let map; - if (source !== undefined) { - map = this.original().map(options); - } else { - // Compute the source and map together. - const sourceAndMap = this.original().sourceAndMap(options); - source = sourceAndMap.source; - map = sourceAndMap.map; - this._cachedSource = source; - } - this._cachedMaps.set(key, { - map, - bufferedMap: undefined - }); - return { source, map }; - } - - streamChunks(options, onChunk, onSource, onName) { - const key = options ? JSON.stringify(options) : "{}"; - if ( - this._cachedMaps.has(key) && - (this._cachedBuffer !== undefined || this._cachedSource !== undefined) - ) { - const { source, map } = this.sourceAndMap(options); - if (map) { - return streamChunksOfSourceMap( - source, - map, - onChunk, - onSource, - onName, - !!(options && options.finalSource), - true - ); - } else { - return streamChunksOfRawSource( - source, - onChunk, - onSource, - onName, - !!(options && options.finalSource) - ); - } - } - const { result, source, map } = streamAndGetSourceAndMap( - this.original(), - options, - onChunk, - onSource, - onName - ); - this._cachedSource = source; - this._cachedMaps.set(key, { - map, - bufferedMap: undefined - }); - return result; - } - - map(options) { - const key = options ? JSON.stringify(options) : "{}"; - const cacheEntry = this._cachedMaps.get(key); - if (cacheEntry !== undefined) { - return this._getMapFromCacheEntry(cacheEntry); - } - const map = this.original().map(options); - this._cachedMaps.set(key, { - map, - bufferedMap: undefined - }); - return map; - } - - updateHash(hash) { - if (this._cachedHashUpdate !== undefined) { - for (const item of this._cachedHashUpdate) hash.update(item); - return; - } - const update = []; - let currentString = undefined; - const tracker = { - update: item => { - if (typeof item === "string" && item.length < 10240) { - if (currentString === undefined) { - currentString = item; - } else { - currentString += item; - if (currentString.length > 102400) { - update.push(Buffer.from(currentString)); - currentString = undefined; - } - } - } else { - if (currentString !== undefined) { - update.push(Buffer.from(currentString)); - currentString = undefined; - } - update.push(item); - } - } - }; - this.original().updateHash(tracker); - if (currentString !== undefined) { - update.push(Buffer.from(currentString)); - } - for (const item of update) hash.update(item); - this._cachedHashUpdate = update; - } -} - -module.exports = CachedSource; diff --git a/node_modules/webpack-sources/lib/CompatSource.js b/node_modules/webpack-sources/lib/CompatSource.js deleted file mode 100644 index 0b9d9bdb..00000000 --- a/node_modules/webpack-sources/lib/CompatSource.js +++ /dev/null @@ -1,66 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Source = require("./Source"); - -class CompatSource extends Source { - static from(sourceLike) { - return sourceLike instanceof Source - ? sourceLike - : new CompatSource(sourceLike); - } - - constructor(sourceLike) { - super(); - this._sourceLike = sourceLike; - } - - source() { - return this._sourceLike.source(); - } - - buffer() { - if (typeof this._sourceLike.buffer === "function") { - return this._sourceLike.buffer(); - } - return super.buffer(); - } - - size() { - if (typeof this._sourceLike.size === "function") { - return this._sourceLike.size(); - } - return super.size(); - } - - map(options) { - if (typeof this._sourceLike.map === "function") { - return this._sourceLike.map(options); - } - return super.map(options); - } - - sourceAndMap(options) { - if (typeof this._sourceLike.sourceAndMap === "function") { - return this._sourceLike.sourceAndMap(options); - } - return super.sourceAndMap(options); - } - - updateHash(hash) { - if (typeof this._sourceLike.updateHash === "function") { - return this._sourceLike.updateHash(hash); - } - if (typeof this._sourceLike.map === "function") { - throw new Error( - "A Source-like object with a 'map' method must also provide an 'updateHash' method" - ); - } - hash.update(this.buffer()); - } -} - -module.exports = CompatSource; diff --git a/node_modules/webpack-sources/lib/ConcatSource.js b/node_modules/webpack-sources/lib/ConcatSource.js deleted file mode 100644 index 3c7e7f28..00000000 --- a/node_modules/webpack-sources/lib/ConcatSource.js +++ /dev/null @@ -1,319 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Source = require("./Source"); -const RawSource = require("./RawSource"); -const streamChunks = require("./helpers/streamChunks"); -const { getMap, getSourceAndMap } = require("./helpers/getFromStreamChunks"); - -const stringsAsRawSources = new WeakSet(); - -class ConcatSource extends Source { - constructor() { - super(); - this._children = []; - for (let i = 0; i < arguments.length; i++) { - const item = arguments[i]; - if (item instanceof ConcatSource) { - for (const child of item._children) { - this._children.push(child); - } - } else { - this._children.push(item); - } - } - this._isOptimized = arguments.length === 0; - } - - getChildren() { - if (!this._isOptimized) this._optimize(); - return this._children; - } - - add(item) { - if (item instanceof ConcatSource) { - for (const child of item._children) { - this._children.push(child); - } - } else { - this._children.push(item); - } - this._isOptimized = false; - } - - addAllSkipOptimizing(items) { - for (const item of items) { - this._children.push(item); - } - } - - buffer() { - if (!this._isOptimized) this._optimize(); - const buffers = []; - for (const child of this._children) { - if (typeof child.buffer === "function") { - buffers.push(child.buffer()); - } else { - const bufferOrString = child.source(); - if (Buffer.isBuffer(bufferOrString)) { - buffers.push(bufferOrString); - } else { - // This will not happen - buffers.push(Buffer.from(bufferOrString, "utf-8")); - } - } - } - return Buffer.concat(buffers); - } - - source() { - if (!this._isOptimized) this._optimize(); - let source = ""; - for (const child of this._children) { - source += child.source(); - } - return source; - } - - size() { - if (!this._isOptimized) this._optimize(); - let size = 0; - for (const child of this._children) { - size += child.size(); - } - return size; - } - - map(options) { - return getMap(this, options); - } - - sourceAndMap(options) { - return getSourceAndMap(this, options); - } - - streamChunks(options, onChunk, onSource, onName) { - if (!this._isOptimized) this._optimize(); - if (this._children.length === 1) - return this._children[0].streamChunks(options, onChunk, onSource, onName); - let currentLineOffset = 0; - let currentColumnOffset = 0; - let sourceMapping = new Map(); - let nameMapping = new Map(); - const finalSource = !!(options && options.finalSource); - let code = ""; - let needToCloseMapping = false; - for (const item of this._children) { - const sourceIndexMapping = []; - const nameIndexMapping = []; - let lastMappingLine = 0; - const { generatedLine, generatedColumn, source } = streamChunks( - item, - options, - // eslint-disable-next-line no-loop-func - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - const line = generatedLine + currentLineOffset; - const column = - generatedLine === 1 - ? generatedColumn + currentColumnOffset - : generatedColumn; - if (needToCloseMapping) { - if (generatedLine !== 1 || generatedColumn !== 0) { - onChunk( - undefined, - currentLineOffset + 1, - currentColumnOffset, - -1, - -1, - -1, - -1 - ); - } - needToCloseMapping = false; - } - const resultSourceIndex = - sourceIndex < 0 || sourceIndex >= sourceIndexMapping.length - ? -1 - : sourceIndexMapping[sourceIndex]; - const resultNameIndex = - nameIndex < 0 || nameIndex >= nameIndexMapping.length - ? -1 - : nameIndexMapping[nameIndex]; - lastMappingLine = resultSourceIndex < 0 ? 0 : generatedLine; - if (finalSource) { - if (chunk !== undefined) code += chunk; - if (resultSourceIndex >= 0) { - onChunk( - undefined, - line, - column, - resultSourceIndex, - originalLine, - originalColumn, - resultNameIndex - ); - } - } else { - if (resultSourceIndex < 0) { - onChunk(chunk, line, column, -1, -1, -1, -1); - } else { - onChunk( - chunk, - line, - column, - resultSourceIndex, - originalLine, - originalColumn, - resultNameIndex - ); - } - } - }, - (i, source, sourceContent) => { - let globalIndex = sourceMapping.get(source); - if (globalIndex === undefined) { - sourceMapping.set(source, (globalIndex = sourceMapping.size)); - onSource(globalIndex, source, sourceContent); - } - sourceIndexMapping[i] = globalIndex; - }, - (i, name) => { - let globalIndex = nameMapping.get(name); - if (globalIndex === undefined) { - nameMapping.set(name, (globalIndex = nameMapping.size)); - onName(globalIndex, name); - } - nameIndexMapping[i] = globalIndex; - } - ); - if (source !== undefined) code += source; - if (needToCloseMapping) { - if (generatedLine !== 1 || generatedColumn !== 0) { - onChunk( - undefined, - currentLineOffset + 1, - currentColumnOffset, - -1, - -1, - -1, - -1 - ); - needToCloseMapping = false; - } - } - if (generatedLine > 1) { - currentColumnOffset = generatedColumn; - } else { - currentColumnOffset += generatedColumn; - } - needToCloseMapping = - needToCloseMapping || - (finalSource && lastMappingLine === generatedLine); - currentLineOffset += generatedLine - 1; - } - return { - generatedLine: currentLineOffset + 1, - generatedColumn: currentColumnOffset, - source: finalSource ? code : undefined - }; - } - - updateHash(hash) { - if (!this._isOptimized) this._optimize(); - hash.update("ConcatSource"); - for (const item of this._children) { - item.updateHash(hash); - } - } - - _optimize() { - const newChildren = []; - let currentString = undefined; - let currentRawSources = undefined; - const addStringToRawSources = string => { - if (currentRawSources === undefined) { - currentRawSources = string; - } else if (Array.isArray(currentRawSources)) { - currentRawSources.push(string); - } else { - currentRawSources = [ - typeof currentRawSources === "string" - ? currentRawSources - : currentRawSources.source(), - string - ]; - } - }; - const addSourceToRawSources = source => { - if (currentRawSources === undefined) { - currentRawSources = source; - } else if (Array.isArray(currentRawSources)) { - currentRawSources.push(source.source()); - } else { - currentRawSources = [ - typeof currentRawSources === "string" - ? currentRawSources - : currentRawSources.source(), - source.source() - ]; - } - }; - const mergeRawSources = () => { - if (Array.isArray(currentRawSources)) { - const rawSource = new RawSource(currentRawSources.join("")); - stringsAsRawSources.add(rawSource); - newChildren.push(rawSource); - } else if (typeof currentRawSources === "string") { - const rawSource = new RawSource(currentRawSources); - stringsAsRawSources.add(rawSource); - newChildren.push(rawSource); - } else { - newChildren.push(currentRawSources); - } - }; - for (const child of this._children) { - if (typeof child === "string") { - if (currentString === undefined) { - currentString = child; - } else { - currentString += child; - } - } else { - if (currentString !== undefined) { - addStringToRawSources(currentString); - currentString = undefined; - } - if (stringsAsRawSources.has(child)) { - addSourceToRawSources(child); - } else { - if (currentRawSources !== undefined) { - mergeRawSources(); - currentRawSources = undefined; - } - newChildren.push(child); - } - } - } - if (currentString !== undefined) { - addStringToRawSources(currentString); - } - if (currentRawSources !== undefined) { - mergeRawSources(); - } - this._children = newChildren; - this._isOptimized = true; - } -} - -module.exports = ConcatSource; diff --git a/node_modules/webpack-sources/lib/OriginalSource.js b/node_modules/webpack-sources/lib/OriginalSource.js deleted file mode 100644 index 59da29ab..00000000 --- a/node_modules/webpack-sources/lib/OriginalSource.js +++ /dev/null @@ -1,135 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const { getMap, getSourceAndMap } = require("./helpers/getFromStreamChunks"); -const splitIntoLines = require("./helpers/splitIntoLines"); -const getGeneratedSourceInfo = require("./helpers/getGeneratedSourceInfo"); -const Source = require("./Source"); -const splitIntoPotentialTokens = require("./helpers/splitIntoPotentialTokens"); - -class OriginalSource extends Source { - constructor(value, name) { - super(); - const isBuffer = Buffer.isBuffer(value); - this._value = isBuffer ? undefined : value; - this._valueAsBuffer = isBuffer ? value : undefined; - this._name = name; - } - - getName() { - return this._name; - } - - source() { - if (this._value === undefined) { - this._value = this._valueAsBuffer.toString("utf-8"); - } - return this._value; - } - - buffer() { - if (this._valueAsBuffer === undefined) { - this._valueAsBuffer = Buffer.from(this._value, "utf-8"); - } - return this._valueAsBuffer; - } - - map(options) { - return getMap(this, options); - } - - sourceAndMap(options) { - return getSourceAndMap(this, options); - } - - /** - * @param {object} options options - * @param {function(string, number, number, number, number, number, number): void} onChunk called for each chunk of code - * @param {function(number, string, string)} onSource called for each source - * @param {function(number, string)} onName called for each name - * @returns {void} - */ - streamChunks(options, onChunk, onSource, onName) { - if (this._value === undefined) { - this._value = this._valueAsBuffer.toString("utf-8"); - } - onSource(0, this._name, this._value); - const finalSource = !!(options && options.finalSource); - if (!options || options.columns !== false) { - // With column info we need to read all lines and split them - const matches = splitIntoPotentialTokens(this._value); - let line = 1; - let column = 0; - if (matches !== null) { - for (const match of matches) { - const isEndOfLine = match.endsWith("\n"); - if (isEndOfLine && match.length === 1) { - if (!finalSource) onChunk(match, line, column, -1, -1, -1, -1); - } else { - const chunk = finalSource ? undefined : match; - onChunk(chunk, line, column, 0, line, column, -1); - } - if (isEndOfLine) { - line++; - column = 0; - } else { - column += match.length; - } - } - } - return { - generatedLine: line, - generatedColumn: column, - source: finalSource ? this._value : undefined - }; - } else if (finalSource) { - // Without column info and with final source we only - // need meta info to generate mapping - const result = getGeneratedSourceInfo(this._value); - const { generatedLine, generatedColumn } = result; - if (generatedColumn === 0) { - for (let line = 1; line < generatedLine; line++) - onChunk(undefined, line, 0, 0, line, 0, -1); - } else { - for (let line = 1; line <= generatedLine; line++) - onChunk(undefined, line, 0, 0, line, 0, -1); - } - return result; - } else { - // Without column info, but also without final source - // we need to split source by lines - let line = 1; - const matches = splitIntoLines(this._value); - let match; - for (match of matches) { - onChunk(finalSource ? undefined : match, line, 0, 0, line, 0, -1); - line++; - } - return matches.length === 0 || match.endsWith("\n") - ? { - generatedLine: matches.length + 1, - generatedColumn: 0, - source: finalSource ? this._value : undefined - } - : { - generatedLine: matches.length, - generatedColumn: match.length, - source: finalSource ? this._value : undefined - }; - } - } - - updateHash(hash) { - if (this._valueAsBuffer === undefined) { - this._valueAsBuffer = Buffer.from(this._value, "utf-8"); - } - hash.update("OriginalSource"); - hash.update(this._valueAsBuffer); - hash.update(this._name || ""); - } -} - -module.exports = OriginalSource; diff --git a/node_modules/webpack-sources/lib/PrefixSource.js b/node_modules/webpack-sources/lib/PrefixSource.js deleted file mode 100644 index a54314cb..00000000 --- a/node_modules/webpack-sources/lib/PrefixSource.js +++ /dev/null @@ -1,114 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Source = require("./Source"); -const RawSource = require("./RawSource"); -const streamChunks = require("./helpers/streamChunks"); -const { getMap, getSourceAndMap } = require("./helpers/getFromStreamChunks"); - -const REPLACE_REGEX = /\n(?=.|\s)/g; - -class PrefixSource extends Source { - constructor(prefix, source) { - super(); - this._source = - typeof source === "string" || Buffer.isBuffer(source) - ? new RawSource(source, true) - : source; - this._prefix = prefix; - } - - getPrefix() { - return this._prefix; - } - - original() { - return this._source; - } - - source() { - const node = this._source.source(); - const prefix = this._prefix; - return prefix + node.replace(REPLACE_REGEX, "\n" + prefix); - } - - // TODO efficient buffer() implementation - - map(options) { - return getMap(this, options); - } - - sourceAndMap(options) { - return getSourceAndMap(this, options); - } - - streamChunks(options, onChunk, onSource, onName) { - const prefix = this._prefix; - const prefixOffset = prefix.length; - const linesOnly = !!(options && options.columns === false); - const { generatedLine, generatedColumn, source } = streamChunks( - this._source, - options, - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - if (generatedColumn !== 0) { - // In the middle of the line, we just adject the column - generatedColumn += prefixOffset; - } else if (chunk !== undefined) { - // At the start of the line, when we have source content - // add the prefix as generated mapping - // (in lines only mode we just add it to the original mapping - // for performance reasons) - if (linesOnly || sourceIndex < 0) { - chunk = prefix + chunk; - } else if (prefixOffset > 0) { - onChunk(prefix, generatedLine, generatedColumn, -1, -1, -1, -1); - generatedColumn += prefixOffset; - } - } else if (!linesOnly) { - // Without source content, we only need to adject the column info - // expect in lines only mode where prefix is added to original mapping - generatedColumn += prefixOffset; - } - onChunk( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ); - }, - onSource, - onName - ); - return { - generatedLine, - generatedColumn: - generatedColumn === 0 ? 0 : prefixOffset + generatedColumn, - source: - source !== undefined - ? prefix + source.replace(REPLACE_REGEX, "\n" + prefix) - : undefined - }; - } - - updateHash(hash) { - hash.update("PrefixSource"); - this._source.updateHash(hash); - hash.update(this._prefix); - } -} - -module.exports = PrefixSource; diff --git a/node_modules/webpack-sources/lib/RawSource.js b/node_modules/webpack-sources/lib/RawSource.js deleted file mode 100644 index 71f1341c..00000000 --- a/node_modules/webpack-sources/lib/RawSource.js +++ /dev/null @@ -1,81 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const streamChunksOfRawSource = require("./helpers/streamChunksOfRawSource"); -const Source = require("./Source"); - -class RawSource extends Source { - constructor(value, convertToString = false) { - super(); - const isBuffer = Buffer.isBuffer(value); - if (!isBuffer && typeof value !== "string") { - throw new TypeError("argument 'value' must be either string of Buffer"); - } - this._valueIsBuffer = !convertToString && isBuffer; - this._value = convertToString && isBuffer ? undefined : value; - this._valueAsBuffer = isBuffer ? value : undefined; - this._valueAsString = isBuffer ? undefined : value; - } - - isBuffer() { - return this._valueIsBuffer; - } - - source() { - if (this._value === undefined) { - this._value = this._valueAsBuffer.toString("utf-8"); - } - return this._value; - } - - buffer() { - if (this._valueAsBuffer === undefined) { - this._valueAsBuffer = Buffer.from(this._value, "utf-8"); - } - return this._valueAsBuffer; - } - - map(options) { - return null; - } - - /** - * @param {object} options options - * @param {function(string, number, number, number, number, number, number): void} onChunk called for each chunk of code - * @param {function(number, string, string)} onSource called for each source - * @param {function(number, string)} onName called for each name - * @returns {void} - */ - streamChunks(options, onChunk, onSource, onName) { - if (this._value === undefined) { - this._value = Buffer.from(this._valueAsBuffer, "utf-8"); - } - if (this._valueAsString === undefined) { - this._valueAsString = - typeof this._value === "string" - ? this._value - : this._value.toString("utf-8"); - } - return streamChunksOfRawSource( - this._valueAsString, - onChunk, - onSource, - onName, - !!(options && options.finalSource) - ); - } - - updateHash(hash) { - if (this._valueAsBuffer === undefined) { - this._valueAsBuffer = Buffer.from(this._value, "utf-8"); - } - hash.update("RawSource"); - hash.update(this._valueAsBuffer); - } -} - -module.exports = RawSource; diff --git a/node_modules/webpack-sources/lib/ReplaceSource.js b/node_modules/webpack-sources/lib/ReplaceSource.js deleted file mode 100644 index 1a678d17..00000000 --- a/node_modules/webpack-sources/lib/ReplaceSource.js +++ /dev/null @@ -1,467 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const { getMap, getSourceAndMap } = require("./helpers/getFromStreamChunks"); -const streamChunks = require("./helpers/streamChunks"); -const Source = require("./Source"); -const splitIntoLines = require("./helpers/splitIntoLines"); - -// since v8 7.0, Array.prototype.sort is stable -const hasStableSort = - typeof process === "object" && - process.versions && - typeof process.versions.v8 === "string" && - !/^[0-6]\./.test(process.versions.v8); - -// This is larger than max string length -const MAX_SOURCE_POSITION = 0x20000000; - -class Replacement { - constructor(start, end, content, name) { - this.start = start; - this.end = end; - this.content = content; - this.name = name; - if (!hasStableSort) { - this.index = -1; - } - } -} - -class ReplaceSource extends Source { - constructor(source, name) { - super(); - this._source = source; - this._name = name; - /** @type {Replacement[]} */ - this._replacements = []; - this._isSorted = true; - } - - getName() { - return this._name; - } - - getReplacements() { - this._sortReplacements(); - return this._replacements; - } - - replace(start, end, newValue, name) { - if (typeof newValue !== "string") - throw new Error( - "insertion must be a string, but is a " + typeof newValue - ); - this._replacements.push(new Replacement(start, end, newValue, name)); - this._isSorted = false; - } - - insert(pos, newValue, name) { - if (typeof newValue !== "string") - throw new Error( - "insertion must be a string, but is a " + - typeof newValue + - ": " + - newValue - ); - this._replacements.push(new Replacement(pos, pos - 1, newValue, name)); - this._isSorted = false; - } - - source() { - if (this._replacements.length === 0) { - return this._source.source(); - } - let current = this._source.source(); - let pos = 0; - const result = []; - - this._sortReplacements(); - for (const replacement of this._replacements) { - const start = Math.floor(replacement.start); - const end = Math.floor(replacement.end + 1); - if (pos < start) { - const offset = start - pos; - result.push(current.slice(0, offset)); - current = current.slice(offset); - pos = start; - } - result.push(replacement.content); - if (pos < end) { - const offset = end - pos; - current = current.slice(offset); - pos = end; - } - } - result.push(current); - return result.join(""); - } - - map(options) { - if (this._replacements.length === 0) { - return this._source.map(options); - } - return getMap(this, options); - } - - sourceAndMap(options) { - if (this._replacements.length === 0) { - return this._source.sourceAndMap(options); - } - return getSourceAndMap(this, options); - } - - original() { - return this._source; - } - - _sortReplacements() { - if (this._isSorted) return; - if (hasStableSort) { - this._replacements.sort(function (a, b) { - const diff1 = a.start - b.start; - if (diff1 !== 0) return diff1; - const diff2 = a.end - b.end; - if (diff2 !== 0) return diff2; - return 0; - }); - } else { - this._replacements.forEach((repl, i) => (repl.index = i)); - this._replacements.sort(function (a, b) { - const diff1 = a.start - b.start; - if (diff1 !== 0) return diff1; - const diff2 = a.end - b.end; - if (diff2 !== 0) return diff2; - return a.index - b.index; - }); - } - this._isSorted = true; - } - - streamChunks(options, onChunk, onSource, onName) { - this._sortReplacements(); - const repls = this._replacements; - let pos = 0; - let i = 0; - let replacmentEnd = -1; - let nextReplacement = - i < repls.length ? Math.floor(repls[i].start) : MAX_SOURCE_POSITION; - let generatedLineOffset = 0; - let generatedColumnOffset = 0; - let generatedColumnOffsetLine = 0; - const sourceContents = []; - const nameMapping = new Map(); - const nameIndexMapping = []; - const checkOriginalContent = (sourceIndex, line, column, expectedChunk) => { - let content = - sourceIndex < sourceContents.length - ? sourceContents[sourceIndex] - : undefined; - if (content === undefined) return false; - if (typeof content === "string") { - content = splitIntoLines(content); - sourceContents[sourceIndex] = content; - } - const contentLine = line <= content.length ? content[line - 1] : null; - if (contentLine === null) return false; - return ( - contentLine.slice(column, column + expectedChunk.length) === - expectedChunk - ); - }; - let { generatedLine, generatedColumn } = streamChunks( - this._source, - Object.assign({}, options, { finalSource: false }), - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - let chunkPos = 0; - let endPos = pos + chunk.length; - - // Skip over when it has been replaced - if (replacmentEnd > pos) { - // Skip over the whole chunk - if (replacmentEnd >= endPos) { - const line = generatedLine + generatedLineOffset; - if (chunk.endsWith("\n")) { - generatedLineOffset--; - if (generatedColumnOffsetLine === line) { - // undo exiting corrections form the current line - generatedColumnOffset += generatedColumn; - } - } else if (generatedColumnOffsetLine === line) { - generatedColumnOffset -= chunk.length; - } else { - generatedColumnOffset = -chunk.length; - generatedColumnOffsetLine = line; - } - pos = endPos; - return; - } - - // Partially skip over chunk - chunkPos = replacmentEnd - pos; - if ( - checkOriginalContent( - sourceIndex, - originalLine, - originalColumn, - chunk.slice(0, chunkPos) - ) - ) { - originalColumn += chunkPos; - } - pos += chunkPos; - const line = generatedLine + generatedLineOffset; - if (generatedColumnOffsetLine === line) { - generatedColumnOffset -= chunkPos; - } else { - generatedColumnOffset = -chunkPos; - generatedColumnOffsetLine = line; - } - generatedColumn += chunkPos; - } - - // Is a replacement in the chunk? - if (nextReplacement < endPos) { - do { - let line = generatedLine + generatedLineOffset; - if (nextReplacement > pos) { - // Emit chunk until replacement - const offset = nextReplacement - pos; - const chunkSlice = chunk.slice(chunkPos, chunkPos + offset); - onChunk( - chunkSlice, - line, - generatedColumn + - (line === generatedColumnOffsetLine - ? generatedColumnOffset - : 0), - sourceIndex, - originalLine, - originalColumn, - nameIndex < 0 || nameIndex >= nameIndexMapping.length - ? -1 - : nameIndexMapping[nameIndex] - ); - generatedColumn += offset; - chunkPos += offset; - pos = nextReplacement; - if ( - checkOriginalContent( - sourceIndex, - originalLine, - originalColumn, - chunkSlice - ) - ) { - originalColumn += chunkSlice.length; - } - } - - // Insert replacement content splitted into chunks by lines - const { content, name } = repls[i]; - let matches = splitIntoLines(content); - let replacementNameIndex = nameIndex; - if (sourceIndex >= 0 && name) { - let globalIndex = nameMapping.get(name); - if (globalIndex === undefined) { - globalIndex = nameMapping.size; - nameMapping.set(name, globalIndex); - onName(globalIndex, name); - } - replacementNameIndex = globalIndex; - } - for (let m = 0; m < matches.length; m++) { - const contentLine = matches[m]; - onChunk( - contentLine, - line, - generatedColumn + - (line === generatedColumnOffsetLine - ? generatedColumnOffset - : 0), - sourceIndex, - originalLine, - originalColumn, - replacementNameIndex - ); - - // Only the first chunk has name assigned - replacementNameIndex = -1; - - if (m === matches.length - 1 && !contentLine.endsWith("\n")) { - if (generatedColumnOffsetLine === line) { - generatedColumnOffset += contentLine.length; - } else { - generatedColumnOffset = contentLine.length; - generatedColumnOffsetLine = line; - } - } else { - generatedLineOffset++; - line++; - generatedColumnOffset = -generatedColumn; - generatedColumnOffsetLine = line; - } - } - - // Remove replaced content by settings this variable - replacmentEnd = Math.max( - replacmentEnd, - Math.floor(repls[i].end + 1) - ); - - // Move to next replacment - i++; - nextReplacement = - i < repls.length - ? Math.floor(repls[i].start) - : MAX_SOURCE_POSITION; - - // Skip over when it has been replaced - const offset = chunk.length - endPos + replacmentEnd - chunkPos; - if (offset > 0) { - // Skip over whole chunk - if (replacmentEnd >= endPos) { - let line = generatedLine + generatedLineOffset; - if (chunk.endsWith("\n")) { - generatedLineOffset--; - if (generatedColumnOffsetLine === line) { - // undo exiting corrections form the current line - generatedColumnOffset += generatedColumn; - } - } else if (generatedColumnOffsetLine === line) { - generatedColumnOffset -= chunk.length - chunkPos; - } else { - generatedColumnOffset = chunkPos - chunk.length; - generatedColumnOffsetLine = line; - } - pos = endPos; - return; - } - - // Partially skip over chunk - const line = generatedLine + generatedLineOffset; - if ( - checkOriginalContent( - sourceIndex, - originalLine, - originalColumn, - chunk.slice(chunkPos, chunkPos + offset) - ) - ) { - originalColumn += offset; - } - chunkPos += offset; - pos += offset; - if (generatedColumnOffsetLine === line) { - generatedColumnOffset -= offset; - } else { - generatedColumnOffset = -offset; - generatedColumnOffsetLine = line; - } - generatedColumn += offset; - } - } while (nextReplacement < endPos); - } - - // Emit remaining chunk - if (chunkPos < chunk.length) { - const chunkSlice = chunkPos === 0 ? chunk : chunk.slice(chunkPos); - const line = generatedLine + generatedLineOffset; - onChunk( - chunkSlice, - line, - generatedColumn + - (line === generatedColumnOffsetLine ? generatedColumnOffset : 0), - sourceIndex, - originalLine, - originalColumn, - nameIndex < 0 ? -1 : nameIndexMapping[nameIndex] - ); - } - pos = endPos; - }, - (sourceIndex, source, sourceContent) => { - while (sourceContents.length < sourceIndex) - sourceContents.push(undefined); - sourceContents[sourceIndex] = sourceContent; - onSource(sourceIndex, source, sourceContent); - }, - (nameIndex, name) => { - let globalIndex = nameMapping.get(name); - if (globalIndex === undefined) { - globalIndex = nameMapping.size; - nameMapping.set(name, globalIndex); - onName(globalIndex, name); - } - nameIndexMapping[nameIndex] = globalIndex; - } - ); - - // Handle remaining replacements - let remainer = ""; - for (; i < repls.length; i++) { - remainer += repls[i].content; - } - - // Insert remaining replacements content splitted into chunks by lines - let line = generatedLine + generatedLineOffset; - let matches = splitIntoLines(remainer); - for (let m = 0; m < matches.length; m++) { - const contentLine = matches[m]; - onChunk( - contentLine, - line, - generatedColumn + - (line === generatedColumnOffsetLine ? generatedColumnOffset : 0), - -1, - -1, - -1, - -1 - ); - - if (m === matches.length - 1 && !contentLine.endsWith("\n")) { - if (generatedColumnOffsetLine === line) { - generatedColumnOffset += contentLine.length; - } else { - generatedColumnOffset = contentLine.length; - generatedColumnOffsetLine = line; - } - } else { - generatedLineOffset++; - line++; - generatedColumnOffset = -generatedColumn; - generatedColumnOffsetLine = line; - } - } - - return { - generatedLine: line, - generatedColumn: - generatedColumn + - (line === generatedColumnOffsetLine ? generatedColumnOffset : 0) - }; - } - - updateHash(hash) { - this._sortReplacements(); - hash.update("ReplaceSource"); - this._source.updateHash(hash); - hash.update(this._name || ""); - for (const repl of this._replacements) { - hash.update(`${repl.start}${repl.end}${repl.content}${repl.name}`); - } - } -} - -module.exports = ReplaceSource; diff --git a/node_modules/webpack-sources/lib/SizeOnlySource.js b/node_modules/webpack-sources/lib/SizeOnlySource.js deleted file mode 100644 index a6e92943..00000000 --- a/node_modules/webpack-sources/lib/SizeOnlySource.js +++ /dev/null @@ -1,42 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Source = require("./Source"); - -class SizeOnlySource extends Source { - constructor(size) { - super(); - this._size = size; - } - - _error() { - return new Error( - "Content and Map of this Source is not available (only size() is supported)" - ); - } - - size() { - return this._size; - } - - source() { - throw this._error(); - } - - buffer() { - throw this._error(); - } - - map(options) { - throw this._error(); - } - - updateHash() { - throw this._error(); - } -} - -module.exports = SizeOnlySource; diff --git a/node_modules/webpack-sources/lib/Source.js b/node_modules/webpack-sources/lib/Source.js deleted file mode 100644 index fb86c2e9..00000000 --- a/node_modules/webpack-sources/lib/Source.js +++ /dev/null @@ -1,38 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -class Source { - source() { - throw new Error("Abstract"); - } - - buffer() { - const source = this.source(); - if (Buffer.isBuffer(source)) return source; - return Buffer.from(source, "utf-8"); - } - - size() { - return this.buffer().length; - } - - map(options) { - return null; - } - - sourceAndMap(options) { - return { - source: this.source(), - map: this.map(options) - }; - } - - updateHash(hash) { - throw new Error("Abstract"); - } -} - -module.exports = Source; diff --git a/node_modules/webpack-sources/lib/SourceMapSource.js b/node_modules/webpack-sources/lib/SourceMapSource.js deleted file mode 100644 index 88a7cb8f..00000000 --- a/node_modules/webpack-sources/lib/SourceMapSource.js +++ /dev/null @@ -1,247 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ -"use strict"; - -const Source = require("./Source"); -const streamChunksOfSourceMap = require("./helpers/streamChunksOfSourceMap"); -const streamChunksOfCombinedSourceMap = require("./helpers/streamChunksOfCombinedSourceMap"); -const { getMap, getSourceAndMap } = require("./helpers/getFromStreamChunks"); - -class SourceMapSource extends Source { - constructor( - value, - name, - sourceMap, - originalSource, - innerSourceMap, - removeOriginalSource - ) { - super(); - const valueIsBuffer = Buffer.isBuffer(value); - this._valueAsString = valueIsBuffer ? undefined : value; - this._valueAsBuffer = valueIsBuffer ? value : undefined; - - this._name = name; - - this._hasSourceMap = !!sourceMap; - const sourceMapIsBuffer = Buffer.isBuffer(sourceMap); - const sourceMapIsString = typeof sourceMap === "string"; - this._sourceMapAsObject = - sourceMapIsBuffer || sourceMapIsString ? undefined : sourceMap; - this._sourceMapAsString = sourceMapIsString ? sourceMap : undefined; - this._sourceMapAsBuffer = sourceMapIsBuffer ? sourceMap : undefined; - - this._hasOriginalSource = !!originalSource; - const originalSourceIsBuffer = Buffer.isBuffer(originalSource); - this._originalSourceAsString = originalSourceIsBuffer - ? undefined - : originalSource; - this._originalSourceAsBuffer = originalSourceIsBuffer - ? originalSource - : undefined; - - this._hasInnerSourceMap = !!innerSourceMap; - const innerSourceMapIsBuffer = Buffer.isBuffer(innerSourceMap); - const innerSourceMapIsString = typeof innerSourceMap === "string"; - this._innerSourceMapAsObject = - innerSourceMapIsBuffer || innerSourceMapIsString - ? undefined - : innerSourceMap; - this._innerSourceMapAsString = innerSourceMapIsString - ? innerSourceMap - : undefined; - this._innerSourceMapAsBuffer = innerSourceMapIsBuffer - ? innerSourceMap - : undefined; - - this._removeOriginalSource = removeOriginalSource; - } - - _ensureValueBuffer() { - if (this._valueAsBuffer === undefined) { - this._valueAsBuffer = Buffer.from(this._valueAsString, "utf-8"); - } - } - - _ensureValueString() { - if (this._valueAsString === undefined) { - this._valueAsString = this._valueAsBuffer.toString("utf-8"); - } - } - - _ensureOriginalSourceBuffer() { - if (this._originalSourceAsBuffer === undefined && this._hasOriginalSource) { - this._originalSourceAsBuffer = Buffer.from( - this._originalSourceAsString, - "utf-8" - ); - } - } - - _ensureOriginalSourceString() { - if (this._originalSourceAsString === undefined && this._hasOriginalSource) { - this._originalSourceAsString = this._originalSourceAsBuffer.toString( - "utf-8" - ); - } - } - - _ensureInnerSourceMapObject() { - if (this._innerSourceMapAsObject === undefined && this._hasInnerSourceMap) { - this._ensureInnerSourceMapString(); - this._innerSourceMapAsObject = JSON.parse(this._innerSourceMapAsString); - } - } - - _ensureInnerSourceMapBuffer() { - if (this._innerSourceMapAsBuffer === undefined && this._hasInnerSourceMap) { - this._ensureInnerSourceMapString(); - this._innerSourceMapAsBuffer = Buffer.from( - this._innerSourceMapAsString, - "utf-8" - ); - } - } - - _ensureInnerSourceMapString() { - if (this._innerSourceMapAsString === undefined && this._hasInnerSourceMap) { - if (this._innerSourceMapAsBuffer !== undefined) { - this._innerSourceMapAsString = this._innerSourceMapAsBuffer.toString( - "utf-8" - ); - } else { - this._innerSourceMapAsString = JSON.stringify( - this._innerSourceMapAsObject - ); - } - } - } - - _ensureSourceMapObject() { - if (this._sourceMapAsObject === undefined) { - this._ensureSourceMapString(); - this._sourceMapAsObject = JSON.parse(this._sourceMapAsString); - } - } - - _ensureSourceMapBuffer() { - if (this._sourceMapAsBuffer === undefined) { - this._ensureSourceMapString(); - this._sourceMapAsBuffer = Buffer.from(this._sourceMapAsString, "utf-8"); - } - } - - _ensureSourceMapString() { - if (this._sourceMapAsString === undefined) { - if (this._sourceMapAsBuffer !== undefined) { - this._sourceMapAsString = this._sourceMapAsBuffer.toString("utf-8"); - } else { - this._sourceMapAsString = JSON.stringify(this._sourceMapAsObject); - } - } - } - - getArgsAsBuffers() { - this._ensureValueBuffer(); - this._ensureSourceMapBuffer(); - this._ensureOriginalSourceBuffer(); - this._ensureInnerSourceMapBuffer(); - return [ - this._valueAsBuffer, - this._name, - this._sourceMapAsBuffer, - this._originalSourceAsBuffer, - this._innerSourceMapAsBuffer, - this._removeOriginalSource - ]; - } - - buffer() { - this._ensureValueBuffer(); - return this._valueAsBuffer; - } - - source() { - this._ensureValueString(); - return this._valueAsString; - } - - map(options) { - if (!this._hasInnerSourceMap) { - this._ensureSourceMapObject(); - return this._sourceMapAsObject; - } - return getMap(this, options); - } - - sourceAndMap(options) { - if (!this._hasInnerSourceMap) { - this._ensureValueString(); - this._ensureSourceMapObject(); - return { - source: this._valueAsString, - map: this._sourceMapAsObject - }; - } - return getSourceAndMap(this, options); - } - - streamChunks(options, onChunk, onSource, onName) { - this._ensureValueString(); - this._ensureSourceMapObject(); - this._ensureOriginalSourceString(); - if (this._hasInnerSourceMap) { - this._ensureInnerSourceMapObject(); - return streamChunksOfCombinedSourceMap( - this._valueAsString, - this._sourceMapAsObject, - this._name, - this._originalSourceAsString, - this._innerSourceMapAsObject, - this._removeOriginalSource, - onChunk, - onSource, - onName, - !!(options && options.finalSource), - !!(options && options.columns !== false) - ); - } else { - return streamChunksOfSourceMap( - this._valueAsString, - this._sourceMapAsObject, - onChunk, - onSource, - onName, - !!(options && options.finalSource), - !!(options && options.columns !== false) - ); - } - } - - updateHash(hash) { - this._ensureValueBuffer(); - this._ensureSourceMapBuffer(); - this._ensureOriginalSourceBuffer(); - this._ensureInnerSourceMapBuffer(); - - hash.update("SourceMapSource"); - - hash.update(this._valueAsBuffer); - - hash.update(this._sourceMapAsBuffer); - - if (this._hasOriginalSource) { - hash.update(this._originalSourceAsBuffer); - } - - if (this._hasInnerSourceMap) { - hash.update(this._innerSourceMapAsBuffer); - } - - hash.update(this._removeOriginalSource ? "true" : "false"); - } -} - -module.exports = SourceMapSource; diff --git a/node_modules/webpack-sources/lib/helpers/createMappingsSerializer.js b/node_modules/webpack-sources/lib/helpers/createMappingsSerializer.js deleted file mode 100644 index 8dafe438..00000000 --- a/node_modules/webpack-sources/lib/helpers/createMappingsSerializer.js +++ /dev/null @@ -1,206 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split( - "" -); - -const CONTINUATION_BIT = 0x20; - -const createMappingsSerializer = options => { - const linesOnly = options && options.columns === false; - return linesOnly - ? createLinesOnlyMappingsSerializer() - : createFullMappingsSerializer(); -}; - -const createFullMappingsSerializer = () => { - let currentLine = 1; - let currentColumn = 0; - let currentSourceIndex = 0; - let currentOriginalLine = 1; - let currentOriginalColumn = 0; - let currentNameIndex = 0; - let activeMapping = false; - let activeName = false; - let initial = true; - return ( - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - if (activeMapping && currentLine === generatedLine) { - // A mapping is still active - if ( - sourceIndex === currentSourceIndex && - originalLine === currentOriginalLine && - originalColumn === currentOriginalColumn && - !activeName && - nameIndex < 0 - ) { - // avoid repeating the same original mapping - return ""; - } - } else { - // No mapping is active - if (sourceIndex < 0) { - // avoid writing unneccessary generated mappings - return ""; - } - } - - let str; - if (currentLine < generatedLine) { - str = ";".repeat(generatedLine - currentLine); - currentLine = generatedLine; - currentColumn = 0; - initial = false; - } else if (initial) { - str = ""; - initial = false; - } else { - str = ","; - } - - const writeValue = value => { - const sign = (value >>> 31) & 1; - const mask = value >> 31; - const absValue = (value + mask) ^ mask; - let data = (absValue << 1) | sign; - for (;;) { - const sextet = data & 0x1f; - data >>= 5; - if (data === 0) { - str += ALPHABET[sextet]; - break; - } else { - str += ALPHABET[sextet | CONTINUATION_BIT]; - } - } - }; - writeValue(generatedColumn - currentColumn); - currentColumn = generatedColumn; - if (sourceIndex >= 0) { - activeMapping = true; - if (sourceIndex === currentSourceIndex) { - str += "A"; - } else { - writeValue(sourceIndex - currentSourceIndex); - currentSourceIndex = sourceIndex; - } - writeValue(originalLine - currentOriginalLine); - currentOriginalLine = originalLine; - if (originalColumn === currentOriginalColumn) { - str += "A"; - } else { - writeValue(originalColumn - currentOriginalColumn); - currentOriginalColumn = originalColumn; - } - if (nameIndex >= 0) { - writeValue(nameIndex - currentNameIndex); - currentNameIndex = nameIndex; - activeName = true; - } else { - activeName = false; - } - } else { - activeMapping = false; - } - return str; - }; -}; - -const createLinesOnlyMappingsSerializer = () => { - let lastWrittenLine = 0; - let currentLine = 1; - let currentSourceIndex = 0; - let currentOriginalLine = 1; - return ( - generatedLine, - _generatedColumn, - sourceIndex, - originalLine, - _originalColumn, - _nameIndex - ) => { - if (sourceIndex < 0) { - // avoid writing generated mappings at all - return ""; - } - if (lastWrittenLine === generatedLine) { - // avoid writing multiple original mappings per line - return ""; - } - let str; - const writeValue = value => { - const sign = (value >>> 31) & 1; - const mask = value >> 31; - const absValue = (value + mask) ^ mask; - let data = (absValue << 1) | sign; - for (;;) { - const sextet = data & 0x1f; - data >>= 5; - if (data === 0) { - str += ALPHABET[sextet]; - break; - } else { - str += ALPHABET[sextet | CONTINUATION_BIT]; - } - } - }; - lastWrittenLine = generatedLine; - if (generatedLine === currentLine + 1) { - currentLine = generatedLine; - if (sourceIndex === currentSourceIndex) { - currentSourceIndex = sourceIndex; - if (originalLine === currentOriginalLine + 1) { - currentOriginalLine = originalLine; - return ";AACA"; - } else { - str = ";AA"; - writeValue(originalLine - currentOriginalLine); - currentOriginalLine = originalLine; - return str + "A"; - } - } else { - str = ";A"; - writeValue(sourceIndex - currentSourceIndex); - currentSourceIndex = sourceIndex; - writeValue(originalLine - currentOriginalLine); - currentOriginalLine = originalLine; - return str + "A"; - } - } else { - str = ";".repeat(generatedLine - currentLine); - currentLine = generatedLine; - if (sourceIndex === currentSourceIndex) { - currentSourceIndex = sourceIndex; - if (originalLine === currentOriginalLine + 1) { - currentOriginalLine = originalLine; - return str + "AACA"; - } else { - str += "AA"; - writeValue(originalLine - currentOriginalLine); - currentOriginalLine = originalLine; - return str + "A"; - } - } else { - str += "A"; - writeValue(sourceIndex - currentSourceIndex); - currentSourceIndex = sourceIndex; - writeValue(originalLine - currentOriginalLine); - currentOriginalLine = originalLine; - return str + "A"; - } - } - }; -}; - -module.exports = createMappingsSerializer; diff --git a/node_modules/webpack-sources/lib/helpers/getFromStreamChunks.js b/node_modules/webpack-sources/lib/helpers/getFromStreamChunks.js deleted file mode 100644 index f45c639c..00000000 --- a/node_modules/webpack-sources/lib/helpers/getFromStreamChunks.js +++ /dev/null @@ -1,129 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const createMappingsSerializer = require("./createMappingsSerializer"); - -exports.getSourceAndMap = (inputSource, options) => { - let code = ""; - let mappings = ""; - let sources = []; - let sourcesContent = []; - let names = []; - const addMapping = createMappingsSerializer(options); - const { source } = inputSource.streamChunks( - Object.assign({}, options, { finalSource: true }), - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - if (chunk !== undefined) code += chunk; - mappings += addMapping( - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ); - }, - (sourceIndex, source, sourceContent) => { - while (sources.length < sourceIndex) { - sources.push(null); - } - sources[sourceIndex] = source; - if (sourceContent !== undefined) { - while (sourcesContent.length < sourceIndex) { - sourcesContent.push(null); - } - sourcesContent[sourceIndex] = sourceContent; - } - }, - (nameIndex, name) => { - while (names.length < nameIndex) { - names.push(null); - } - names[nameIndex] = name; - } - ); - return { - source: source !== undefined ? source : code, - map: - mappings.length > 0 - ? { - version: 3, - file: "x", - mappings, - sources, - sourcesContent: - sourcesContent.length > 0 ? sourcesContent : undefined, - names - } - : null - }; -}; - -exports.getMap = (source, options) => { - let mappings = ""; - let sources = []; - let sourcesContent = []; - let names = []; - const addMapping = createMappingsSerializer(options); - source.streamChunks( - Object.assign({}, options, { source: false, finalSource: true }), - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - mappings += addMapping( - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ); - }, - (sourceIndex, source, sourceContent) => { - while (sources.length < sourceIndex) { - sources.push(null); - } - sources[sourceIndex] = source; - if (sourceContent !== undefined) { - while (sourcesContent.length < sourceIndex) { - sourcesContent.push(null); - } - sourcesContent[sourceIndex] = sourceContent; - } - }, - (nameIndex, name) => { - while (names.length < nameIndex) { - names.push(null); - } - names[nameIndex] = name; - } - ); - return mappings.length > 0 - ? { - version: 3, - file: "x", - mappings, - sources, - sourcesContent: sourcesContent.length > 0 ? sourcesContent : undefined, - names - } - : null; -}; diff --git a/node_modules/webpack-sources/lib/helpers/getGeneratedSourceInfo.js b/node_modules/webpack-sources/lib/helpers/getGeneratedSourceInfo.js deleted file mode 100644 index 2cc12fcd..00000000 --- a/node_modules/webpack-sources/lib/helpers/getGeneratedSourceInfo.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const CHAR_CODE_NEW_LINE = "\n".charCodeAt(0); - -const getGeneratedSourceInfo = source => { - if (source === undefined) { - return {}; - } - const lastLineStart = source.lastIndexOf("\n"); - if (lastLineStart === -1) { - return { - generatedLine: 1, - generatedColumn: source.length, - source - }; - } - let generatedLine = 2; - for (let i = 0; i < lastLineStart; i++) { - if (source.charCodeAt(i) === CHAR_CODE_NEW_LINE) generatedLine++; - } - return { - generatedLine, - generatedColumn: source.length - lastLineStart - 1, - source - }; -}; - -module.exports = getGeneratedSourceInfo; diff --git a/node_modules/webpack-sources/lib/helpers/getName.js b/node_modules/webpack-sources/lib/helpers/getName.js deleted file mode 100644 index db6a863a..00000000 --- a/node_modules/webpack-sources/lib/helpers/getName.js +++ /dev/null @@ -1,14 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const getName = (sourceMap, index) => { - if (index < 0) return null; - const { names } = sourceMap; - return names[index]; -}; - -module.exports = getName; diff --git a/node_modules/webpack-sources/lib/helpers/getSource.js b/node_modules/webpack-sources/lib/helpers/getSource.js deleted file mode 100644 index b236563d..00000000 --- a/node_modules/webpack-sources/lib/helpers/getSource.js +++ /dev/null @@ -1,17 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const getSource = (sourceMap, index) => { - if (index < 0) return null; - const { sourceRoot, sources } = sourceMap; - const source = sources[index]; - if (!sourceRoot) return source; - if (sourceRoot.endsWith("/")) return sourceRoot + source; - return sourceRoot + "/" + source; -}; - -module.exports = getSource; diff --git a/node_modules/webpack-sources/lib/helpers/readMappings.js b/node_modules/webpack-sources/lib/helpers/readMappings.js deleted file mode 100644 index 31cb48d2..00000000 --- a/node_modules/webpack-sources/lib/helpers/readMappings.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const ALPHABET = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - -const CONTINUATION_BIT = 0x20; -const END_SEGMENT_BIT = 0x40; -const NEXT_LINE = END_SEGMENT_BIT | 0x01; -const INVALID = END_SEGMENT_BIT | 0x02; -const DATA_MASK = 0x1f; - -const ccToValue = new Uint8Array("z".charCodeAt(0) + 1); -{ - ccToValue.fill(INVALID); - for (let i = 0; i < ALPHABET.length; i++) { - ccToValue[ALPHABET.charCodeAt(i)] = i; - } - ccToValue[",".charCodeAt(0)] = END_SEGMENT_BIT; - ccToValue[";".charCodeAt(0)] = NEXT_LINE; -} -const ccMax = ccToValue.length - 1; - -/** - * @param {string} mappings the mappings string - * @param {function(number, number, number, number, number, number): void} onMapping called for each mapping - * @returns {void} - */ -const readMappings = (mappings, onMapping) => { - // generatedColumn, [sourceIndex, originalLine, orignalColumn, [nameIndex]] - const currentData = new Uint32Array([0, 0, 1, 0, 0]); - let currentDataPos = 0; - // currentValue will include a sign bit at bit 0 - let currentValue = 0; - let currentValuePos = 0; - let generatedLine = 1; - let generatedColumn = -1; - for (let i = 0; i < mappings.length; i++) { - const cc = mappings.charCodeAt(i); - if (cc > ccMax) continue; - const value = ccToValue[cc]; - if ((value & END_SEGMENT_BIT) !== 0) { - // End current segment - if (currentData[0] > generatedColumn) { - if (currentDataPos === 1) { - onMapping(generatedLine, currentData[0], -1, -1, -1, -1); - } else if (currentDataPos === 4) { - onMapping( - generatedLine, - currentData[0], - currentData[1], - currentData[2], - currentData[3], - -1 - ); - } else if (currentDataPos === 5) { - onMapping( - generatedLine, - currentData[0], - currentData[1], - currentData[2], - currentData[3], - currentData[4] - ); - } - generatedColumn = currentData[0]; - } - currentDataPos = 0; - if (value === NEXT_LINE) { - // Start new line - generatedLine++; - currentData[0] = 0; - generatedColumn = -1; - } - } else if ((value & CONTINUATION_BIT) === 0) { - // last sextet - currentValue |= value << currentValuePos; - const finalValue = - currentValue & 1 ? -(currentValue >> 1) : currentValue >> 1; - currentData[currentDataPos++] += finalValue; - currentValuePos = 0; - currentValue = 0; - } else { - currentValue |= (value & DATA_MASK) << currentValuePos; - currentValuePos += 5; - } - } - // End current segment - if (currentDataPos === 1) { - onMapping(generatedLine, currentData[0], -1, -1, -1, -1); - } else if (currentDataPos === 4) { - onMapping( - generatedLine, - currentData[0], - currentData[1], - currentData[2], - currentData[3], - -1 - ); - } else if (currentDataPos === 5) { - onMapping( - generatedLine, - currentData[0], - currentData[1], - currentData[2], - currentData[3], - currentData[4] - ); - } -}; - -module.exports = readMappings; diff --git a/node_modules/webpack-sources/lib/helpers/splitIntoLines.js b/node_modules/webpack-sources/lib/helpers/splitIntoLines.js deleted file mode 100644 index e9ccafdf..00000000 --- a/node_modules/webpack-sources/lib/helpers/splitIntoLines.js +++ /dev/null @@ -1,21 +0,0 @@ -const splitIntoLines = str => { - const results = []; - const len = str.length; - let i = 0; - for (; i < len; ) { - const cc = str.charCodeAt(i); - // 10 is "\n".charCodeAt(0) - if (cc === 10) { - results.push("\n"); - i++; - } else { - let j = i + 1; - // 10 is "\n".charCodeAt(0) - while (j < len && str.charCodeAt(j) !== 10) j++; - results.push(str.slice(i, j + 1)); - i = j + 1; - } - } - return results; -}; -module.exports = splitIntoLines; diff --git a/node_modules/webpack-sources/lib/helpers/splitIntoPotentialTokens.js b/node_modules/webpack-sources/lib/helpers/splitIntoPotentialTokens.js deleted file mode 100644 index 0f0bc421..00000000 --- a/node_modules/webpack-sources/lib/helpers/splitIntoPotentialTokens.js +++ /dev/null @@ -1,41 +0,0 @@ -// \n = 10 -// ; = 59 -// { = 123 -// } = 125 -// <space> = 32 -// \r = 13 -// \t = 9 - -const splitIntoPotentialTokens = str => { - const len = str.length; - if (len === 0) return null; - const results = []; - let i = 0; - for (; i < len; ) { - const s = i; - block: { - let cc = str.charCodeAt(i); - while (cc !== 10 && cc !== 59 && cc !== 123 && cc !== 125) { - if (++i >= len) break block; - cc = str.charCodeAt(i); - } - while ( - cc === 59 || - cc === 32 || - cc === 123 || - cc === 125 || - cc === 13 || - cc === 9 - ) { - if (++i >= len) break block; - cc = str.charCodeAt(i); - } - if (cc === 10) { - i++; - } - } - results.push(str.slice(s, i)); - } - return results; -}; -module.exports = splitIntoPotentialTokens; diff --git a/node_modules/webpack-sources/lib/helpers/streamAndGetSourceAndMap.js b/node_modules/webpack-sources/lib/helpers/streamAndGetSourceAndMap.js deleted file mode 100644 index 529fd766..00000000 --- a/node_modules/webpack-sources/lib/helpers/streamAndGetSourceAndMap.js +++ /dev/null @@ -1,102 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const createMappingsSerializer = require("./createMappingsSerializer"); -const streamChunks = require("./streamChunks"); - -const streamAndGetSourceAndMap = ( - inputSource, - options, - onChunk, - onSource, - onName -) => { - let code = ""; - let mappings = ""; - let sources = []; - let sourcesContent = []; - let names = []; - const addMapping = createMappingsSerializer( - Object.assign({}, options, { columns: true }) - ); - const finalSource = !!(options && options.finalSource); - const { generatedLine, generatedColumn, source } = streamChunks( - inputSource, - options, - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - if (chunk !== undefined) code += chunk; - mappings += addMapping( - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ); - return onChunk( - finalSource ? undefined : chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ); - }, - (sourceIndex, source, sourceContent) => { - while (sources.length < sourceIndex) { - sources.push(null); - } - sources[sourceIndex] = source; - if (sourceContent !== undefined) { - while (sourcesContent.length < sourceIndex) { - sourcesContent.push(null); - } - sourcesContent[sourceIndex] = sourceContent; - } - return onSource(sourceIndex, source, sourceContent); - }, - (nameIndex, name) => { - while (names.length < nameIndex) { - names.push(null); - } - names[nameIndex] = name; - return onName(nameIndex, name); - } - ); - const resultSource = source !== undefined ? source : code; - return { - result: { - generatedLine, - generatedColumn, - source: finalSource ? resultSource : undefined - }, - source: resultSource, - map: - mappings.length > 0 - ? { - version: 3, - file: "x", - mappings, - sources, - sourcesContent: - sourcesContent.length > 0 ? sourcesContent : undefined, - names - } - : null - }; -}; - -module.exports = streamAndGetSourceAndMap; diff --git a/node_modules/webpack-sources/lib/helpers/streamChunks.js b/node_modules/webpack-sources/lib/helpers/streamChunks.js deleted file mode 100644 index 4bd3824a..00000000 --- a/node_modules/webpack-sources/lib/helpers/streamChunks.js +++ /dev/null @@ -1,36 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const streamChunksOfRawSource = require("./streamChunksOfRawSource"); -const streamChunksOfSourceMap = require("./streamChunksOfSourceMap"); - -module.exports = (source, options, onChunk, onSource, onName) => { - if (typeof source.streamChunks === "function") { - return source.streamChunks(options, onChunk, onSource, onName); - } else { - const sourceAndMap = source.sourceAndMap(options); - if (sourceAndMap.map) { - return streamChunksOfSourceMap( - sourceAndMap.source, - sourceAndMap.map, - onChunk, - onSource, - onName, - !!(options && options.finalSource), - !!(options && options.columns !== false) - ); - } else { - return streamChunksOfRawSource( - sourceAndMap.source, - onChunk, - onSource, - onName, - !!(options && options.finalSource) - ); - } - } -}; diff --git a/node_modules/webpack-sources/lib/helpers/streamChunksOfCombinedSourceMap.js b/node_modules/webpack-sources/lib/helpers/streamChunksOfCombinedSourceMap.js deleted file mode 100644 index b40774d5..00000000 --- a/node_modules/webpack-sources/lib/helpers/streamChunksOfCombinedSourceMap.js +++ /dev/null @@ -1,329 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const streamChunksOfSourceMap = require("./streamChunksOfSourceMap"); -const splitIntoLines = require("./splitIntoLines"); - -const streamChunksOfCombinedSourceMap = ( - source, - sourceMap, - innerSourceName, - innerSource, - innerSourceMap, - removeInnerSource, - onChunk, - onSource, - onName, - finalSource, - columns -) => { - let sourceMapping = new Map(); - let nameMapping = new Map(); - const sourceIndexMapping = []; - const nameIndexMapping = []; - const nameIndexValueMapping = []; - let innerSourceIndex = -2; - const innerSourceIndexMapping = []; - const innerSourceIndexValueMapping = []; - const innerSourceContents = []; - const innerSourceContentLines = []; - const innerNameIndexMapping = []; - const innerNameIndexValueMapping = []; - const innerSourceMapLineData = []; - const findInnerMapping = (line, column) => { - if (line > innerSourceMapLineData.length) return -1; - const { mappingsData } = innerSourceMapLineData[line - 1]; - let l = 0; - let r = mappingsData.length / 5; - while (l < r) { - let m = (l + r) >> 1; - if (mappingsData[m * 5] <= column) { - l = m + 1; - } else { - r = m; - } - } - if (l === 0) return -1; - return l - 1; - }; - return streamChunksOfSourceMap( - source, - sourceMap, - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - // Check if this is a mapping to the inner source - if (sourceIndex === innerSourceIndex) { - // Check if there is a mapping in the inner source - const idx = findInnerMapping(originalLine, originalColumn); - if (idx !== -1) { - const { chunks, mappingsData } = innerSourceMapLineData[ - originalLine - 1 - ]; - const mi = idx * 5; - const innerSourceIndex = mappingsData[mi + 1]; - const innerOriginalLine = mappingsData[mi + 2]; - let innerOriginalColumn = mappingsData[mi + 3]; - let innerNameIndex = mappingsData[mi + 4]; - if (innerSourceIndex >= 0) { - // Check for an identity mapping - // where we are allowed to adjust the original column - const innerChunk = chunks[idx]; - const innerGeneratedColumn = mappingsData[mi]; - const locationInChunk = originalColumn - innerGeneratedColumn; - if (locationInChunk > 0) { - let originalSourceLines = - innerSourceIndex < innerSourceContentLines.length - ? innerSourceContentLines[innerSourceIndex] - : null; - if (originalSourceLines === undefined) { - const originalSource = innerSourceContents[innerSourceIndex]; - originalSourceLines = originalSource - ? splitIntoLines(originalSource) - : null; - innerSourceContentLines[innerSourceIndex] = originalSourceLines; - } - if (originalSourceLines !== null) { - const originalChunk = - innerOriginalLine <= originalSourceLines.length - ? originalSourceLines[innerOriginalLine - 1].slice( - innerOriginalColumn, - innerOriginalColumn + locationInChunk - ) - : ""; - if (innerChunk.slice(0, locationInChunk) === originalChunk) { - innerOriginalColumn += locationInChunk; - innerNameIndex = -1; - } - } - } - - // We have a inner mapping to original source - - // emit source when needed and compute global source index - let sourceIndex = - innerSourceIndex < innerSourceIndexMapping.length - ? innerSourceIndexMapping[innerSourceIndex] - : -2; - if (sourceIndex === -2) { - const [source, sourceContent] = - innerSourceIndex < innerSourceIndexValueMapping.length - ? innerSourceIndexValueMapping[innerSourceIndex] - : [null, undefined]; - let globalIndex = sourceMapping.get(source); - if (globalIndex === undefined) { - sourceMapping.set(source, (globalIndex = sourceMapping.size)); - onSource(globalIndex, source, sourceContent); - } - sourceIndex = globalIndex; - innerSourceIndexMapping[innerSourceIndex] = sourceIndex; - } - - // emit name when needed and compute global name index - let finalNameIndex = -1; - if (innerNameIndex >= 0) { - // when we have a inner name - finalNameIndex = - innerNameIndex < innerNameIndexMapping.length - ? innerNameIndexMapping[innerNameIndex] - : -2; - if (finalNameIndex === -2) { - const name = - innerNameIndex < innerNameIndexValueMapping.length - ? innerNameIndexValueMapping[innerNameIndex] - : undefined; - if (name) { - let globalIndex = nameMapping.get(name); - if (globalIndex === undefined) { - nameMapping.set(name, (globalIndex = nameMapping.size)); - onName(globalIndex, name); - } - finalNameIndex = globalIndex; - } else { - finalNameIndex = -1; - } - innerNameIndexMapping[innerNameIndex] = finalNameIndex; - } - } else if (nameIndex >= 0) { - // when we don't have an inner name, - // but we have an outer name - // it can be used when inner original code equals to the name - let originalSourceLines = - innerSourceContentLines[innerSourceIndex]; - if (originalSourceLines === undefined) { - const originalSource = innerSourceContents[innerSourceIndex]; - originalSourceLines = originalSource - ? splitIntoLines(originalSource) - : null; - innerSourceContentLines[innerSourceIndex] = originalSourceLines; - } - if (originalSourceLines !== null) { - const name = nameIndexValueMapping[nameIndex]; - const originalName = - innerOriginalLine <= originalSourceLines.length - ? originalSourceLines[innerOriginalLine - 1].slice( - innerOriginalColumn, - innerOriginalColumn + name.length - ) - : ""; - if (name === originalName) { - finalNameIndex = - nameIndex < nameIndexMapping.length - ? nameIndexMapping[nameIndex] - : -2; - if (finalNameIndex === -2) { - const name = nameIndexValueMapping[nameIndex]; - if (name) { - let globalIndex = nameMapping.get(name); - if (globalIndex === undefined) { - nameMapping.set(name, (globalIndex = nameMapping.size)); - onName(globalIndex, name); - } - finalNameIndex = globalIndex; - } else { - finalNameIndex = -1; - } - nameIndexMapping[nameIndex] = finalNameIndex; - } - } - } - } - onChunk( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - innerOriginalLine, - innerOriginalColumn, - finalNameIndex - ); - return; - } - } - - // We have a mapping to the inner source, but no inner mapping - if (removeInnerSource) { - onChunk(chunk, generatedLine, generatedColumn, -1, -1, -1, -1); - return; - } else { - if (sourceIndexMapping[sourceIndex] === -2) { - let globalIndex = sourceMapping.get(innerSourceName); - if (globalIndex === undefined) { - sourceMapping.set(source, (globalIndex = sourceMapping.size)); - onSource(globalIndex, innerSourceName, innerSource); - } - sourceIndexMapping[sourceIndex] = globalIndex; - } - } - } - - const finalSourceIndex = - sourceIndex < 0 || sourceIndex >= sourceIndexMapping.length - ? -1 - : sourceIndexMapping[sourceIndex]; - if (finalSourceIndex < 0) { - // no source, so we make it a generated chunk - onChunk(chunk, generatedLine, generatedColumn, -1, -1, -1, -1); - } else { - // Pass through the chunk with mapping - let finalNameIndex = -1; - if (nameIndex >= 0 && nameIndex < nameIndexMapping.length) { - finalNameIndex = nameIndexMapping[nameIndex]; - if (finalNameIndex === -2) { - const name = nameIndexValueMapping[nameIndex]; - let globalIndex = nameMapping.get(name); - if (globalIndex === undefined) { - nameMapping.set(name, (globalIndex = nameMapping.size)); - onName(globalIndex, name); - } - finalNameIndex = globalIndex; - nameIndexMapping[nameIndex] = finalNameIndex; - } - } - onChunk( - chunk, - generatedLine, - generatedColumn, - finalSourceIndex, - originalLine, - originalColumn, - finalNameIndex - ); - } - }, - (i, source, sourceContent) => { - if (source === innerSourceName) { - innerSourceIndex = i; - if (innerSource !== undefined) sourceContent = innerSource; - else innerSource = sourceContent; - sourceIndexMapping[i] = -2; - streamChunksOfSourceMap( - sourceContent, - innerSourceMap, - ( - chunk, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - while (innerSourceMapLineData.length < generatedLine) { - innerSourceMapLineData.push({ - mappingsData: [], - chunks: [] - }); - } - const data = innerSourceMapLineData[generatedLine - 1]; - data.mappingsData.push( - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ); - data.chunks.push(chunk); - }, - (i, source, sourceContent) => { - innerSourceContents[i] = sourceContent; - innerSourceContentLines[i] = undefined; - innerSourceIndexMapping[i] = -2; - innerSourceIndexValueMapping[i] = [source, sourceContent]; - }, - (i, name) => { - innerNameIndexMapping[i] = -2; - innerNameIndexValueMapping[i] = name; - }, - false, - columns - ); - } else { - let globalIndex = sourceMapping.get(source); - if (globalIndex === undefined) { - sourceMapping.set(source, (globalIndex = sourceMapping.size)); - onSource(globalIndex, source, sourceContent); - } - sourceIndexMapping[i] = globalIndex; - } - }, - (i, name) => { - nameIndexMapping[i] = -2; - nameIndexValueMapping[i] = name; - }, - finalSource, - columns - ); -}; - -module.exports = streamChunksOfCombinedSourceMap; diff --git a/node_modules/webpack-sources/lib/helpers/streamChunksOfRawSource.js b/node_modules/webpack-sources/lib/helpers/streamChunksOfRawSource.js deleted file mode 100644 index 133022a9..00000000 --- a/node_modules/webpack-sources/lib/helpers/streamChunksOfRawSource.js +++ /dev/null @@ -1,34 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const getGeneratedSourceInfo = require("./getGeneratedSourceInfo"); -const splitIntoLines = require("./splitIntoLines"); - -const streamChunksOfRawSource = (source, onChunk, onSource, onName) => { - let line = 1; - const matches = splitIntoLines(source); - let match; - for (match of matches) { - onChunk(match, line, 0, -1, -1, -1, -1); - line++; - } - return matches.length === 0 || match.endsWith("\n") - ? { - generatedLine: matches.length + 1, - generatedColumn: 0 - } - : { - generatedLine: matches.length, - generatedColumn: match.length - }; -}; - -module.exports = (source, onChunk, onSource, onName, finalSource) => { - return finalSource - ? getGeneratedSourceInfo(source) - : streamChunksOfRawSource(source, onChunk, onSource, onName); -}; diff --git a/node_modules/webpack-sources/lib/helpers/streamChunksOfSourceMap.js b/node_modules/webpack-sources/lib/helpers/streamChunksOfSourceMap.js deleted file mode 100644 index c57cb34b..00000000 --- a/node_modules/webpack-sources/lib/helpers/streamChunksOfSourceMap.js +++ /dev/null @@ -1,412 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const getGeneratedSourceInfo = require("./getGeneratedSourceInfo"); -const getSource = require("./getSource"); -const readMappings = require("./readMappings"); -const splitIntoLines = require("./splitIntoLines"); - -const streamChunksOfSourceMapFull = ( - source, - sourceMap, - onChunk, - onSource, - onName -) => { - const lines = splitIntoLines(source); - if (lines.length === 0) { - return { - generatedLine: 1, - generatedColumn: 0 - }; - } - const { sources, sourcesContent, names, mappings } = sourceMap; - for (let i = 0; i < sources.length; i++) { - onSource( - i, - getSource(sourceMap, i), - (sourcesContent && sourcesContent[i]) || undefined - ); - } - if (names) { - for (let i = 0; i < names.length; i++) { - onName(i, names[i]); - } - } - - const lastLine = lines[lines.length - 1]; - const lastNewLine = lastLine.endsWith("\n"); - const finalLine = lastNewLine ? lines.length + 1 : lines.length; - const finalColumn = lastNewLine ? 0 : lastLine.length; - - let currentGeneratedLine = 1; - let currentGeneratedColumn = 0; - - let mappingActive = false; - let activeMappingSourceIndex = -1; - let activeMappingOriginalLine = -1; - let activeMappingOriginalColumn = -1; - let activeMappingNameIndex = -1; - - const onMapping = ( - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - if (mappingActive && currentGeneratedLine <= lines.length) { - let chunk; - const mappingLine = currentGeneratedLine; - const mappingColumn = currentGeneratedColumn; - const line = lines[currentGeneratedLine - 1]; - if (generatedLine !== currentGeneratedLine) { - chunk = line.slice(currentGeneratedColumn); - currentGeneratedLine++; - currentGeneratedColumn = 0; - } else { - chunk = line.slice(currentGeneratedColumn, generatedColumn); - currentGeneratedColumn = generatedColumn; - } - if (chunk) { - onChunk( - chunk, - mappingLine, - mappingColumn, - activeMappingSourceIndex, - activeMappingOriginalLine, - activeMappingOriginalColumn, - activeMappingNameIndex - ); - } - mappingActive = false; - } - if (generatedLine > currentGeneratedLine && currentGeneratedColumn > 0) { - if (currentGeneratedLine <= lines.length) { - const chunk = lines[currentGeneratedLine - 1].slice( - currentGeneratedColumn - ); - onChunk( - chunk, - currentGeneratedLine, - currentGeneratedColumn, - -1, - -1, - -1, - -1 - ); - } - currentGeneratedLine++; - currentGeneratedColumn = 0; - } - while (generatedLine > currentGeneratedLine) { - if (currentGeneratedLine <= lines.length) { - onChunk( - lines[currentGeneratedLine - 1], - currentGeneratedLine, - 0, - -1, - -1, - -1, - -1 - ); - } - currentGeneratedLine++; - } - if (generatedColumn > currentGeneratedColumn) { - if (currentGeneratedLine <= lines.length) { - const chunk = lines[currentGeneratedLine - 1].slice( - currentGeneratedColumn, - generatedColumn - ); - onChunk( - chunk, - currentGeneratedLine, - currentGeneratedColumn, - -1, - -1, - -1, - -1 - ); - } - currentGeneratedColumn = generatedColumn; - } - if ( - sourceIndex >= 0 && - (generatedLine < finalLine || - (generatedLine === finalLine && generatedColumn < finalColumn)) - ) { - mappingActive = true; - activeMappingSourceIndex = sourceIndex; - activeMappingOriginalLine = originalLine; - activeMappingOriginalColumn = originalColumn; - activeMappingNameIndex = nameIndex; - } - }; - readMappings(mappings, onMapping); - onMapping(finalLine, finalColumn, -1, -1, -1, -1); - return { - generatedLine: finalLine, - generatedColumn: finalColumn - }; -}; - -const streamChunksOfSourceMapLinesFull = ( - source, - sourceMap, - onChunk, - onSource, - _onName -) => { - const lines = splitIntoLines(source); - if (lines.length === 0) { - return { - generatedLine: 1, - generatedColumn: 0 - }; - } - const { sources, sourcesContent, mappings } = sourceMap; - for (let i = 0; i < sources.length; i++) { - onSource( - i, - getSource(sourceMap, i), - (sourcesContent && sourcesContent[i]) || undefined - ); - } - - let currentGeneratedLine = 1; - - const onMapping = ( - generatedLine, - _generatedColumn, - sourceIndex, - originalLine, - originalColumn, - _nameIndex - ) => { - if ( - sourceIndex < 0 || - generatedLine < currentGeneratedLine || - generatedLine > lines.length - ) { - return; - } - while (generatedLine > currentGeneratedLine) { - if (currentGeneratedLine <= lines.length) { - onChunk( - lines[currentGeneratedLine - 1], - currentGeneratedLine, - 0, - -1, - -1, - -1, - -1 - ); - } - currentGeneratedLine++; - } - if (generatedLine <= lines.length) { - onChunk( - lines[generatedLine - 1], - generatedLine, - 0, - sourceIndex, - originalLine, - originalColumn, - -1 - ); - currentGeneratedLine++; - } - }; - readMappings(mappings, onMapping); - for (; currentGeneratedLine <= lines.length; currentGeneratedLine++) { - onChunk( - lines[currentGeneratedLine - 1], - currentGeneratedLine, - 0, - -1, - -1, - -1, - -1 - ); - } - - const lastLine = lines[lines.length - 1]; - const lastNewLine = lastLine.endsWith("\n"); - - const finalLine = lastNewLine ? lines.length + 1 : lines.length; - const finalColumn = lastNewLine ? 0 : lastLine.length; - - return { - generatedLine: finalLine, - generatedColumn: finalColumn - }; -}; - -const streamChunksOfSourceMapFinal = ( - source, - sourceMap, - onChunk, - onSource, - onName -) => { - const result = getGeneratedSourceInfo(source); - const { generatedLine: finalLine, generatedColumn: finalColumn } = result; - - if (finalLine === 1 && finalColumn === 0) return result; - const { sources, sourcesContent, names, mappings } = sourceMap; - for (let i = 0; i < sources.length; i++) { - onSource( - i, - getSource(sourceMap, i), - (sourcesContent && sourcesContent[i]) || undefined - ); - } - if (names) { - for (let i = 0; i < names.length; i++) { - onName(i, names[i]); - } - } - - let mappingActiveLine = 0; - - const onMapping = ( - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ) => { - if ( - generatedLine >= finalLine && - (generatedColumn >= finalColumn || generatedLine > finalLine) - ) { - return; - } - if (sourceIndex >= 0) { - onChunk( - undefined, - generatedLine, - generatedColumn, - sourceIndex, - originalLine, - originalColumn, - nameIndex - ); - mappingActiveLine = generatedLine; - } else if (mappingActiveLine === generatedLine) { - onChunk(undefined, generatedLine, generatedColumn, -1, -1, -1, -1); - mappingActiveLine = 0; - } - }; - readMappings(mappings, onMapping); - return result; -}; - -const streamChunksOfSourceMapLinesFinal = ( - source, - sourceMap, - onChunk, - onSource, - _onName -) => { - const result = getGeneratedSourceInfo(source); - const { generatedLine, generatedColumn } = result; - if (generatedLine === 1 && generatedColumn === 0) { - return { - generatedLine: 1, - generatedColumn: 0 - }; - } - - const { sources, sourcesContent, mappings } = sourceMap; - for (let i = 0; i < sources.length; i++) { - onSource( - i, - getSource(sourceMap, i), - (sourcesContent && sourcesContent[i]) || undefined - ); - } - - const finalLine = generatedColumn === 0 ? generatedLine - 1 : generatedLine; - - let currentGeneratedLine = 1; - - const onMapping = ( - generatedLine, - _generatedColumn, - sourceIndex, - originalLine, - originalColumn, - _nameIndex - ) => { - if ( - sourceIndex >= 0 && - currentGeneratedLine <= generatedLine && - generatedLine <= finalLine - ) { - onChunk( - undefined, - generatedLine, - 0, - sourceIndex, - originalLine, - originalColumn, - -1 - ); - currentGeneratedLine = generatedLine + 1; - } - }; - readMappings(mappings, onMapping); - return result; -}; - -module.exports = ( - source, - sourceMap, - onChunk, - onSource, - onName, - finalSource, - columns -) => { - if (columns) { - return finalSource - ? streamChunksOfSourceMapFinal( - source, - sourceMap, - onChunk, - onSource, - onName - ) - : streamChunksOfSourceMapFull( - source, - sourceMap, - onChunk, - onSource, - onName - ); - } else { - return finalSource - ? streamChunksOfSourceMapLinesFinal( - source, - sourceMap, - onChunk, - onSource, - onName - ) - : streamChunksOfSourceMapLinesFull( - source, - sourceMap, - onChunk, - onSource, - onName - ); - } -}; diff --git a/node_modules/webpack-sources/lib/index.js b/node_modules/webpack-sources/lib/index.js deleted file mode 100644 index 0c11c2f4..00000000 --- a/node_modules/webpack-sources/lib/index.js +++ /dev/null @@ -1,30 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -const defineExport = (name, fn) => { - let value; - Object.defineProperty(exports, name, { - get: () => { - if (fn !== undefined) { - value = fn(); - fn = undefined; - } - return value; - }, - configurable: true - }); -}; - -defineExport("Source", () => require("./Source")); - -defineExport("RawSource", () => require("./RawSource")); -defineExport("OriginalSource", () => require("./OriginalSource")); -defineExport("SourceMapSource", () => require("./SourceMapSource")); -defineExport("CachedSource", () => require("./CachedSource")); -defineExport("ConcatSource", () => require("./ConcatSource")); -defineExport("ReplaceSource", () => require("./ReplaceSource")); -defineExport("PrefixSource", () => require("./PrefixSource")); -defineExport("SizeOnlySource", () => require("./SizeOnlySource")); -defineExport("CompatSource", () => require("./CompatSource")); |
