webpack-sources
Advanced tools
Comparing version 0.1.5 to 0.2.0
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -39,6 +39,5 @@ /* | ||
var map = this._source.listMap(options); | ||
map.mapGeneratedCode(function(code) { | ||
return map.mapGeneratedCode(function(code) { | ||
return prefix + code.replace(REPLACE_REGEX, "\n" + prefix); | ||
}); | ||
return map; | ||
}; | ||
@@ -45,0 +44,0 @@ |
@@ -0,0 +0,0 @@ /* |
@@ -95,23 +95,50 @@ /* | ||
ReplaceSource.prototype.listMap = function(options) { | ||
this._sortReplacements(); | ||
var map = this._source.listMap(options); | ||
if(map.children.length !== 1) { | ||
var code = map.toString(); | ||
code = this._replaceString(code).split("\n"); | ||
var currentIndex = 0; | ||
map.mapGeneratedCode(function(str) { | ||
var idx = -1; | ||
var count = -1; | ||
do { | ||
count++; | ||
idx = str.indexOf("\n", idx + 1); | ||
} while (idx >= 0); | ||
if(!count) return ""; | ||
var result = code.slice(currentIndex, currentIndex + count).join("\n") + "\n"; | ||
currentIndex += count; | ||
return result; | ||
}); | ||
map.add(code.slice(currentIndex).join("\n")); | ||
} else { | ||
map.mapGeneratedCode(this._replaceString.bind(this)); | ||
var currentIndex = 0; | ||
var replacements = this.replacements; | ||
var idxReplacement = replacements.length - 1; | ||
var removeChars = 0; | ||
map = map.mapGeneratedCode(function(str) { | ||
var newCurrentIndex = currentIndex + str.length; | ||
if(removeChars > str.length) { | ||
removeChars -= str.length; | ||
str = ""; | ||
} else { | ||
if(removeChars > 0) { | ||
str = str.substr(removeChars); | ||
currentIndex += removeChars; | ||
removeChars = 0; | ||
} | ||
var finalStr = ""; | ||
while(idxReplacement >= 0 && replacements[idxReplacement][0] < newCurrentIndex) { | ||
var repl = replacements[idxReplacement]; | ||
var start = Math.floor(repl[0]); | ||
var end = Math.floor(repl[1] + 1); | ||
var before = str.substr(0, Math.max(0, start - currentIndex)); | ||
if(end <= newCurrentIndex) { | ||
var after = str.substr(Math.max(0, end - currentIndex)); | ||
finalStr += before + repl[2]; | ||
str = after; | ||
currentIndex = Math.max(currentIndex, end); | ||
} else { | ||
finalStr = before + repl[2]; | ||
str = ""; | ||
removeChars = end - newCurrentIndex; | ||
} | ||
idxReplacement--; | ||
} | ||
str = finalStr + str; | ||
} | ||
currentIndex = newCurrentIndex; | ||
return str; | ||
}); | ||
var extraCode = ""; | ||
while(idxReplacement >= 0) { | ||
extraCode += replacements[idxReplacement][2]; | ||
idxReplacement--; | ||
} | ||
if(extraCode) { | ||
map.add(extraCode); | ||
} | ||
return map; | ||
@@ -118,0 +145,0 @@ }; |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
@@ -0,0 +0,0 @@ /* |
{ | ||
"name": "webpack-sources", | ||
"version": "0.1.5", | ||
"version": "0.2.0", | ||
"description": "Source code handling classes for webpack", | ||
@@ -19,3 +19,3 @@ "main": "./lib/index.js", | ||
"source-map": "~0.5.3", | ||
"source-list-map": "~0.1.7" | ||
"source-list-map": "^1.0.1" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
@@ -0,0 +0,0 @@ # webpack-sources |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
27505
629
0
+ Addedsource-list-map@1.1.2(transitive)
- Removedsource-list-map@0.1.8(transitive)
Updatedsource-list-map@^1.0.1