Add rollup-plugin-minify-html-template-literals to node_modules
R=jacktfranklin@chromium.org
Bug: 1213034
Change-Id: I5da8225f60b53870a1c67d6b5d02a464c08f4eb2
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2917088
Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org>
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
diff --git a/node_modules/clean-css/lib/writer/source-maps.js b/node_modules/clean-css/lib/writer/source-maps.js
new file mode 100644
index 0000000..6856579
--- /dev/null
+++ b/node_modules/clean-css/lib/writer/source-maps.js
@@ -0,0 +1,101 @@
+var SourceMapGenerator = require('source-map').SourceMapGenerator;
+var all = require('./helpers').all;
+
+var isRemoteResource = require('../utils/is-remote-resource');
+
+var isWindows = process.platform == 'win32';
+
+var NIX_SEPARATOR_PATTERN = /\//g;
+var UNKNOWN_SOURCE = '$stdin';
+var WINDOWS_SEPARATOR = '\\';
+
+function store(serializeContext, element) {
+ var fromString = typeof element == 'string';
+ var value = fromString ? element : element[1];
+ var mappings = fromString ? null : element[2];
+ var wrap = serializeContext.wrap;
+
+ wrap(serializeContext, value);
+ track(serializeContext, value, mappings);
+ serializeContext.output.push(value);
+}
+
+function wrap(serializeContext, value) {
+ if (serializeContext.column + value.length > serializeContext.format.wrapAt) {
+ track(serializeContext, serializeContext.format.breakWith, false);
+ serializeContext.output.push(serializeContext.format.breakWith);
+ }
+}
+
+function track(serializeContext, value, mappings) {
+ var parts = value.split('\n');
+
+ if (mappings) {
+ trackAllMappings(serializeContext, mappings);
+ }
+
+ serializeContext.line += parts.length - 1;
+ serializeContext.column = parts.length > 1 ? 0 : (serializeContext.column + parts.pop().length);
+}
+
+function trackAllMappings(serializeContext, mappings) {
+ for (var i = 0, l = mappings.length; i < l; i++) {
+ trackMapping(serializeContext, mappings[i]);
+ }
+}
+
+function trackMapping(serializeContext, mapping) {
+ var line = mapping[0];
+ var column = mapping[1];
+ var originalSource = mapping[2];
+ var source = originalSource;
+ var storedSource = source || UNKNOWN_SOURCE;
+
+ if (isWindows && source && !isRemoteResource(source)) {
+ storedSource = source.replace(NIX_SEPARATOR_PATTERN, WINDOWS_SEPARATOR);
+ }
+
+ serializeContext.outputMap.addMapping({
+ generated: {
+ line: serializeContext.line,
+ column: serializeContext.column
+ },
+ source: storedSource,
+ original: {
+ line: line,
+ column: column
+ }
+ });
+
+ if (serializeContext.inlineSources && (originalSource in serializeContext.sourcesContent)) {
+ serializeContext.outputMap.setSourceContent(storedSource, serializeContext.sourcesContent[originalSource]);
+ }
+}
+
+function serializeStylesAndSourceMap(tokens, context) {
+ var serializeContext = {
+ column: 0,
+ format: context.options.format,
+ indentBy: 0,
+ indentWith: '',
+ inlineSources: context.options.sourceMapInlineSources,
+ line: 1,
+ output: [],
+ outputMap: new SourceMapGenerator(),
+ sourcesContent: context.sourcesContent,
+ spaceAfterClosingBrace: context.options.compatibility.properties.spaceAfterClosingBrace,
+ store: store,
+ wrap: context.options.format.wrapAt ?
+ wrap :
+ function () { /* noop */ }
+ };
+
+ all(serializeContext, tokens);
+
+ return {
+ sourceMap: serializeContext.outputMap,
+ styles: serializeContext.output.join('')
+ };
+}
+
+module.exports = serializeStylesAndSourceMap;