node_modules
.bin
@ampproject
@babel
@discoveryjs
@gar
@istanbuljs
@jridgewell
@leichtgewicht
@npmcli
@riotjs
@tootallnate
@types
@ungap
@webassemblyjs
@webpack-cli
@xtuc
abab
abbrev
accepts
acorn
acorn-globals
acorn-import-assertions
acorn-walk
agent-base
agentkeepalive
aggregate-error
ajv
ajv-formats
ajv-keywords
ansi-colors
ansi-html-community
ansi-regex
ansi-styles
anymatch
append-transform
aproba
archy
are-we-there-yet
argparse
array-flatten
arrify
assertion-error
ast-types
async-foreach
asynckit
babel-plugin-dynamic-import-node
babel-plugin-polyfill-corejs2
babel-plugin-polyfill-corejs3
babel-plugin-polyfill-regenerator
balanced-match
batch
bianco.attr
bianco.dom-to-array
bianco.events
bianco.query
big.js
binary-extensions
body-parser
bonjour-service
boolbase
brace-expansion
braces
browser-process-hrtime
browser-stdout
browserslist
buffer-from
bytes
cacache
caching-transform
call-bind
camel-case
camelcase
camelcase-keys
caniuse-lite
chai
chalk
check-error
chokidar
chownr
chrome-trace-event
clean-css
clean-stack
cliui
clone-deep
color-convert
color-name
color-support
colorette
combined-stream
commander
commondir
compressible
compression
concat-map
connect-history-api-fallback
console-control-strings
content-disposition
content-type
convert-source-map
cookie
cookie-signature
core-js-compat
core-util-is
cross-spawn
css-select
css-what
cssesc
cssom
cssstyle
cumpa
curri
data-urls
debug
decamelize
decamelize-keys
decimal.js
deep-eql
deep-is
default-gateway
default-require-extensions
define-lazy-prop
define-properties
delayed-stream
delegates
depd
destroy
detect-node
diff
dns-equal
dns-packet
dom-converter
dom-nodes
dom-serializer
domelementtype
domexception
domhandler
domutils
dot-case
ee-first
electron-to-chromium
emoji-regex
emojis-list
encodeurl
encoding
enhanced-resolve
entities
env-paths
envinfo
err-code
erre
error-ex
es-module-lexer
es6-error
escalade
escape-html
escape-string-regexp
escodegen
eslint-scope
esm
esprima
esrecurse
estraverse
esutils
etag
eventemitter3
events
execa
express
fast-deep-equal
fast-json-stable-stringify
fast-levenshtein
fastest-levenshtein
faye-websocket
fill-range
finalhandler
find-up
flat
follow-redirects
foreground-child
form-data
forwarded
fresh
fromentries
fs-minipass
fs-monkey
fs.realpath
function-bind
gauge
gaze
gensync
get-caller-file
get-func-name
get-intrinsic
get-package-type
get-stdin
get-stream
glob
glob-parent
glob-to-regexp
globals
globule
graceful-fs
growl
handle-thing
hard-rejection
has
has-flag
has-property-descriptors
has-symbols
has-unicode
hasha
he
hosted-git-info
hpack.js
html-encoding-sniffer
html-entities
html-escaper
html-minifier-terser
html-webpack-plugin
htmlparser2
http-cache-semantics
http-deceiver
http-errors
http-parser-js
http-proxy
http-proxy-agent
http-proxy-middleware
https-proxy-agent
human-signals
humanize-ms
iconv-lite
imurmurhash
indent-string
infer-owner
inflight
inherits
interpret
ip
ipaddr.js
is-arrayish
is-binary-path
is-core-module
is-docker
is-extglob
is-fullwidth-code-point
is-glob
is-lambda
is-number
is-plain-obj
is-plain-object
is-potential-custom-element-name
is-stream
is-typedarray
is-windows
is-wsl
isarray
isexe
isobject
istanbul-lib-coverage
istanbul-lib-hook
istanbul-lib-instrument
istanbul-lib-processinfo
istanbul-lib-report
istanbul-lib-source-maps
istanbul-reports
jest-worker
js-base64
js-tokens
js-yaml
jsdom
jsdom-global
jsesc
json-parse-even-better-errors
json-schema-traverse
json5
kind-of
levn
lines-and-columns
loader-runner
locate-path
lodash
lodash.debounce
lodash.flattendeep
log-symbols
loupe
lower-case
lru-cache
make-fetch-happen
map-obj
media-typer
memfs
meow
merge-descriptors
merge-stream
methods
micromatch
mime
mime-db
mime-types
mimic-fn
min-indent
minimalistic-assert
minimatch
minimist-options
minipass
minipass-collect
minipass-fetch
minipass-flush
minipass-pipeline
minipass-sized
minizlib
mkdirp
mocha
ms
multicast-dns
nan
nanoid
negotiator
neo-async
no-case
node-forge
node-gyp
node-preload
node-releases
node-sass
nopt
normalize-package-data
normalize-path
npm-run-path
npmlog
nth-check
nwsapi
nyc
object-inspect
object-keys
object.assign
obuf
on-finished
on-headers
once
onetime
open
optionator
p-limit
p-locate
p-map
p-retry
p-try
package-hash
param-case
parse-json
parse5
parseurl
pascal-case
path-exists
path-is-absolute
path-key
path-parse
path-to-regexp
pathval
picocolors
picomatch
pirates
prelude-ls
pretty-error
process-nextick-args
process-on-spawn
promise-inflight
promise-retry
proxy-addr
psl
punycode
qs
quick-lru
randombytes
range-parser
raw-body
rawth
read-pkg
read-pkg-up
readable-stream
readdirp
recast
rechoir
redent
regenerate
regenerate-unicode-properties
regenerator-runtime
regenerator-transform
regexpu-core
regjsgen
regjsparser
relateurl
release-zalgo
renderkid
require-directory
require-from-string
require-main-filename
requires-port
resolve
retry
rimraf
riot
ruit
safe-buffer
safer-buffer
sass-graph
saxes
schema-utils
scss-tokenizer
select-hose
selfsigned
semver
send
serialize-javascript
serve-index
serve-static
set-blocking
setprototypeof
shallow-clone
shebang-command
shebang-regex
side-channel
signal-exit
smart-buffer
sockjs
socks
socks-proxy-agent
source-map
source-map-support
spawn-wrap
spdx-correct
spdx-exceptions
spdx-expression-parse
spdx-license-ids
spdy
spdy-transport
sprintf-js
ssri
statuses
stdout-stream
string-width
string_decoder
strip-ansi
strip-final-newline
strip-indent
strip-json-comments
supports-color
symbol-tree
tapable
tar
terser
terser-webpack-plugin
test-exclude
thunky
to-fast-properties
to-regex-range
toidentifier
tough-cookie
tr46
trim-newlines
true-case-path
tslib
type-check
type-detect
type-fest
type-is
typedarray-to-buffer
unicode-canonical-property-names-ecmascript
unicode-match-property-ecmascript
unicode-match-property-value-ecmascript
unicode-property-aliases-ecmascript
unique-filename
unique-slug
universalify
unpipe
update-browserslist-db
uri-js
util-deprecate
utila
utils-merge
uuid
validate-npm-package-license
vary
w3c-hr-time
w3c-xmlserializer
watchpack
wbuf
webidl-conversions
webpack
webpack-cli
webpack-dev-middleware
webpack-dev-server
webpack-merge
webpack-sources
lib
helpers
createMappingsSerializer.js
getFromStreamChunks.js
getGeneratedSourceInfo.js
getName.js
getSource.js
readMappings.js
splitIntoLines.js
splitIntoPotentialTokens.js
streamAndGetSourceAndMap.js
streamChunks.js
streamChunksOfCombinedSourceMap.js
streamChunksOfRawSource.js
streamChunksOfSourceMap.js
CachedSource.js
CompatSource.js
ConcatSource.js
OriginalSource.js
PrefixSource.js
RawSource.js
ReplaceSource.js
SizeOnlySource.js
Source.js
SourceMapSource.js
index.js
LICENSE
README.md
package.json
websocket-driver
websocket-extensions
whatwg-encoding
whatwg-mimetype
whatwg-url
which
which-module
wide-align
wildcard
word-wrap
workerpool
wrap-ansi
wrappy
write-file-atomic
ws
xml-name-validator
xmlchars
y18n
yallist
yargs
yargs-parser
yargs-unparser
yocto-queue
.package-lock.json
src
LICENSE
package-lock.json
package.json
readme.md
webpack.config.js
330 lines
9.9 KiB
JavaScript
330 lines
9.9 KiB
JavaScript
/*
|
|
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;
|