@vue/compiler-sfc 3.5.0-rc.1 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.0-rc.1
2
+ * @vue/compiler-sfc v3.5.0
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -277,6 +277,13 @@ function escapeHtml(string) {
277
277
  }
278
278
  return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
279
279
  }
280
+ const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
281
+ function getEscapedCssVarName(key, doubleEscape) {
282
+ return key.replace(
283
+ cssVarNameEscapeSymbolsRE,
284
+ (s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
285
+ );
286
+ }
280
287
 
281
288
  const isRef = (val) => {
282
289
  return !!(val && val["__v_isRef"] === true);
@@ -25810,304 +25817,6 @@ var CompilerDOM = /*#__PURE__*/Object.freeze({
25810
25817
  warnDeprecation: warnDeprecation
25811
25818
  });
25812
25819
 
25813
- // Copyright Joyent, Inc. and other Node contributors.
25814
- //
25815
- // Permission is hereby granted, free of charge, to any person obtaining a
25816
- // copy of this software and associated documentation files (the
25817
- // "Software"), to deal in the Software without restriction, including
25818
- // without limitation the rights to use, copy, modify, merge, publish,
25819
- // distribute, sublicense, and/or sell copies of the Software, and to permit
25820
- // persons to whom the Software is furnished to do so, subject to the
25821
- // following conditions:
25822
- //
25823
- // The above copyright notice and this permission notice shall be included
25824
- // in all copies or substantial portions of the Software.
25825
- //
25826
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25827
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25828
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
25829
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
25830
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
25831
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25832
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
25833
-
25834
- // resolves . and .. elements in a path array with directory names there
25835
- // must be no slashes, empty elements, or device names (c:\) in the array
25836
- // (so also no leading and trailing slashes - it does not distinguish
25837
- // relative and absolute paths)
25838
- function normalizeArray(parts, allowAboveRoot) {
25839
- // if the path tries to go above the root, `up` ends up > 0
25840
- var up = 0;
25841
- for (var i = parts.length - 1; i >= 0; i--) {
25842
- var last = parts[i];
25843
- if (last === '.') {
25844
- parts.splice(i, 1);
25845
- } else if (last === '..') {
25846
- parts.splice(i, 1);
25847
- up++;
25848
- } else if (up) {
25849
- parts.splice(i, 1);
25850
- up--;
25851
- }
25852
- }
25853
-
25854
- // if the path is allowed to go above the root, restore leading ..s
25855
- if (allowAboveRoot) {
25856
- for (; up--; up) {
25857
- parts.unshift('..');
25858
- }
25859
- }
25860
-
25861
- return parts;
25862
- }
25863
-
25864
- // Split a filename into [root, dir, basename, ext], unix version
25865
- // 'root' is just a slash, or nothing.
25866
- var splitPathRe =
25867
- /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
25868
- var splitPath = function(filename) {
25869
- return splitPathRe.exec(filename).slice(1);
25870
- };
25871
-
25872
- // path.resolve([from ...], to)
25873
- // posix version
25874
- function resolve$2() {
25875
- var resolvedPath = '',
25876
- resolvedAbsolute = false;
25877
-
25878
- for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
25879
- var path = (i >= 0) ? arguments[i] : '/';
25880
-
25881
- // Skip empty and invalid entries
25882
- if (typeof path !== 'string') {
25883
- throw new TypeError('Arguments to path.resolve must be strings');
25884
- } else if (!path) {
25885
- continue;
25886
- }
25887
-
25888
- resolvedPath = path + '/' + resolvedPath;
25889
- resolvedAbsolute = path.charAt(0) === '/';
25890
- }
25891
-
25892
- // At this point the path should be resolved to a full absolute path, but
25893
- // handle relative paths to be safe (might happen when process.cwd() fails)
25894
-
25895
- // Normalize the path
25896
- resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
25897
- return !!p;
25898
- }), !resolvedAbsolute).join('/');
25899
-
25900
- return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
25901
- }
25902
- // path.normalize(path)
25903
- // posix version
25904
- function normalize$1(path) {
25905
- var isPathAbsolute = isAbsolute$1(path),
25906
- trailingSlash = substr(path, -1) === '/';
25907
-
25908
- // Normalize the path
25909
- path = normalizeArray(filter(path.split('/'), function(p) {
25910
- return !!p;
25911
- }), !isPathAbsolute).join('/');
25912
-
25913
- if (!path && !isPathAbsolute) {
25914
- path = '.';
25915
- }
25916
- if (path && trailingSlash) {
25917
- path += '/';
25918
- }
25919
-
25920
- return (isPathAbsolute ? '/' : '') + path;
25921
- }
25922
- // posix version
25923
- function isAbsolute$1(path) {
25924
- return path.charAt(0) === '/';
25925
- }
25926
-
25927
- // posix version
25928
- function join$1() {
25929
- var paths = Array.prototype.slice.call(arguments, 0);
25930
- return normalize$1(filter(paths, function(p, index) {
25931
- if (typeof p !== 'string') {
25932
- throw new TypeError('Arguments to path.join must be strings');
25933
- }
25934
- return p;
25935
- }).join('/'));
25936
- }
25937
-
25938
-
25939
- // path.relative(from, to)
25940
- // posix version
25941
- function relative$1(from, to) {
25942
- from = resolve$2(from).substr(1);
25943
- to = resolve$2(to).substr(1);
25944
-
25945
- function trim(arr) {
25946
- var start = 0;
25947
- for (; start < arr.length; start++) {
25948
- if (arr[start] !== '') break;
25949
- }
25950
-
25951
- var end = arr.length - 1;
25952
- for (; end >= 0; end--) {
25953
- if (arr[end] !== '') break;
25954
- }
25955
-
25956
- if (start > end) return [];
25957
- return arr.slice(start, end - start + 1);
25958
- }
25959
-
25960
- var fromParts = trim(from.split('/'));
25961
- var toParts = trim(to.split('/'));
25962
-
25963
- var length = Math.min(fromParts.length, toParts.length);
25964
- var samePartsLength = length;
25965
- for (var i = 0; i < length; i++) {
25966
- if (fromParts[i] !== toParts[i]) {
25967
- samePartsLength = i;
25968
- break;
25969
- }
25970
- }
25971
-
25972
- var outputParts = [];
25973
- for (var i = samePartsLength; i < fromParts.length; i++) {
25974
- outputParts.push('..');
25975
- }
25976
-
25977
- outputParts = outputParts.concat(toParts.slice(samePartsLength));
25978
-
25979
- return outputParts.join('/');
25980
- }
25981
-
25982
- var sep$1 = '/';
25983
- var delimiter$1 = ':';
25984
-
25985
- function dirname$2(path) {
25986
- var result = splitPath(path),
25987
- root = result[0],
25988
- dir = result[1];
25989
-
25990
- if (!root && !dir) {
25991
- // No dirname whatsoever
25992
- return '.';
25993
- }
25994
-
25995
- if (dir) {
25996
- // It has a dirname, strip trailing slash
25997
- dir = dir.substr(0, dir.length - 1);
25998
- }
25999
-
26000
- return root + dir;
26001
- }
26002
-
26003
- function basename(path, ext) {
26004
- var f = splitPath(path)[2];
26005
- // TODO: make this comparison case-insensitive on windows?
26006
- if (ext && f.substr(-1 * ext.length) === ext) {
26007
- f = f.substr(0, f.length - ext.length);
26008
- }
26009
- return f;
26010
- }
26011
-
26012
-
26013
- function extname(path) {
26014
- return splitPath(path)[3];
26015
- }
26016
- var path = {
26017
- extname: extname,
26018
- basename: basename,
26019
- dirname: dirname$2,
26020
- sep: sep$1,
26021
- delimiter: delimiter$1,
26022
- relative: relative$1,
26023
- join: join$1,
26024
- isAbsolute: isAbsolute$1,
26025
- normalize: normalize$1,
26026
- resolve: resolve$2
26027
- };
26028
- function filter (xs, f) {
26029
- if (xs.filter) return xs.filter(f);
26030
- var res = [];
26031
- for (var i = 0; i < xs.length; i++) {
26032
- if (f(xs[i], i, xs)) res.push(xs[i]);
26033
- }
26034
- return res;
26035
- }
26036
-
26037
- // String.prototype.substr - negative index don't work in IE8
26038
- var substr = 'ab'.substr(-1) === 'b' ?
26039
- function (str, start, len) { return str.substr(start, len) } :
26040
- function (str, start, len) {
26041
- if (start < 0) start = str.length + start;
26042
- return str.substr(start, len);
26043
- }
26044
- ;
26045
-
26046
- var _polyfillNode_path = /*#__PURE__*/Object.freeze({
26047
- __proto__: null,
26048
- basename: basename,
26049
- default: path,
26050
- delimiter: delimiter$1,
26051
- dirname: dirname$2,
26052
- extname: extname,
26053
- isAbsolute: isAbsolute$1,
26054
- join: join$1,
26055
- normalize: normalize$1,
26056
- relative: relative$1,
26057
- resolve: resolve$2,
26058
- sep: sep$1
26059
- });
26060
-
26061
- const UNKNOWN_TYPE = "Unknown";
26062
- function resolveObjectKey(node, computed) {
26063
- switch (node.type) {
26064
- case "StringLiteral":
26065
- case "NumericLiteral":
26066
- return String(node.value);
26067
- case "Identifier":
26068
- if (!computed) return node.name;
26069
- }
26070
- return void 0;
26071
- }
26072
- function concatStrings(strs) {
26073
- return strs.filter((s) => !!s).join(", ");
26074
- }
26075
- function isLiteralNode(node) {
26076
- return node.type.endsWith("Literal");
26077
- }
26078
- function isCallOf(node, test) {
26079
- return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
26080
- }
26081
- function toRuntimeTypeString(types) {
26082
- return types.length > 1 ? `[${types.join(", ")}]` : types[0];
26083
- }
26084
- function getImportedName(specifier) {
26085
- if (specifier.type === "ImportSpecifier")
26086
- return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
26087
- else if (specifier.type === "ImportNamespaceSpecifier") return "*";
26088
- return "default";
26089
- }
26090
- function getId(node) {
26091
- return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
26092
- }
26093
- const normalize = (path.posix || path).normalize;
26094
- const windowsSlashRE = /\\/g;
26095
- function normalizePath(p) {
26096
- return normalize(p.replace(windowsSlashRE, "/"));
26097
- }
26098
- const joinPaths = (path.posix || path).join;
26099
- const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
26100
- function getEscapedPropName(key) {
26101
- return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
26102
- }
26103
- const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
26104
- function getEscapedCssVarName(key, doubleEscape) {
26105
- return key.replace(
26106
- cssVarNameEscapeSymbolsRE,
26107
- (s) => doubleEscape ? `\\\\${s}` : `\\${s}`
26108
- );
26109
- }
26110
-
26111
25820
  function pad$1 (hash, len) {
26112
25821
  while (hash.length < len) {
26113
25822
  hash = '0' + hash;
@@ -26579,7 +26288,7 @@ function resolveTemplateUsedIdentifiers(sfc) {
26579
26288
  } else if (prop.exp) {
26580
26289
  extractIdentifiers(ids, prop.exp);
26581
26290
  } else if (prop.name === "bind" && !prop.exp) {
26582
- ids.add(prop.arg.content);
26291
+ ids.add(camelize(prop.arg.content));
26583
26292
  }
26584
26293
  }
26585
26294
  if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
@@ -26921,6 +26630,254 @@ function dedent(s) {
26921
26630
  ];
26922
26631
  }
26923
26632
 
26633
+ // Copyright Joyent, Inc. and other Node contributors.
26634
+ //
26635
+ // Permission is hereby granted, free of charge, to any person obtaining a
26636
+ // copy of this software and associated documentation files (the
26637
+ // "Software"), to deal in the Software without restriction, including
26638
+ // without limitation the rights to use, copy, modify, merge, publish,
26639
+ // distribute, sublicense, and/or sell copies of the Software, and to permit
26640
+ // persons to whom the Software is furnished to do so, subject to the
26641
+ // following conditions:
26642
+ //
26643
+ // The above copyright notice and this permission notice shall be included
26644
+ // in all copies or substantial portions of the Software.
26645
+ //
26646
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
26647
+ // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26648
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
26649
+ // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
26650
+ // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
26651
+ // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
26652
+ // USE OR OTHER DEALINGS IN THE SOFTWARE.
26653
+
26654
+ // resolves . and .. elements in a path array with directory names there
26655
+ // must be no slashes, empty elements, or device names (c:\) in the array
26656
+ // (so also no leading and trailing slashes - it does not distinguish
26657
+ // relative and absolute paths)
26658
+ function normalizeArray(parts, allowAboveRoot) {
26659
+ // if the path tries to go above the root, `up` ends up > 0
26660
+ var up = 0;
26661
+ for (var i = parts.length - 1; i >= 0; i--) {
26662
+ var last = parts[i];
26663
+ if (last === '.') {
26664
+ parts.splice(i, 1);
26665
+ } else if (last === '..') {
26666
+ parts.splice(i, 1);
26667
+ up++;
26668
+ } else if (up) {
26669
+ parts.splice(i, 1);
26670
+ up--;
26671
+ }
26672
+ }
26673
+
26674
+ // if the path is allowed to go above the root, restore leading ..s
26675
+ if (allowAboveRoot) {
26676
+ for (; up--; up) {
26677
+ parts.unshift('..');
26678
+ }
26679
+ }
26680
+
26681
+ return parts;
26682
+ }
26683
+
26684
+ // Split a filename into [root, dir, basename, ext], unix version
26685
+ // 'root' is just a slash, or nothing.
26686
+ var splitPathRe =
26687
+ /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
26688
+ var splitPath = function(filename) {
26689
+ return splitPathRe.exec(filename).slice(1);
26690
+ };
26691
+
26692
+ // path.resolve([from ...], to)
26693
+ // posix version
26694
+ function resolve$2() {
26695
+ var resolvedPath = '',
26696
+ resolvedAbsolute = false;
26697
+
26698
+ for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
26699
+ var path = (i >= 0) ? arguments[i] : '/';
26700
+
26701
+ // Skip empty and invalid entries
26702
+ if (typeof path !== 'string') {
26703
+ throw new TypeError('Arguments to path.resolve must be strings');
26704
+ } else if (!path) {
26705
+ continue;
26706
+ }
26707
+
26708
+ resolvedPath = path + '/' + resolvedPath;
26709
+ resolvedAbsolute = path.charAt(0) === '/';
26710
+ }
26711
+
26712
+ // At this point the path should be resolved to a full absolute path, but
26713
+ // handle relative paths to be safe (might happen when process.cwd() fails)
26714
+
26715
+ // Normalize the path
26716
+ resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
26717
+ return !!p;
26718
+ }), !resolvedAbsolute).join('/');
26719
+
26720
+ return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
26721
+ }
26722
+ // path.normalize(path)
26723
+ // posix version
26724
+ function normalize$1(path) {
26725
+ var isPathAbsolute = isAbsolute$1(path),
26726
+ trailingSlash = substr(path, -1) === '/';
26727
+
26728
+ // Normalize the path
26729
+ path = normalizeArray(filter(path.split('/'), function(p) {
26730
+ return !!p;
26731
+ }), !isPathAbsolute).join('/');
26732
+
26733
+ if (!path && !isPathAbsolute) {
26734
+ path = '.';
26735
+ }
26736
+ if (path && trailingSlash) {
26737
+ path += '/';
26738
+ }
26739
+
26740
+ return (isPathAbsolute ? '/' : '') + path;
26741
+ }
26742
+ // posix version
26743
+ function isAbsolute$1(path) {
26744
+ return path.charAt(0) === '/';
26745
+ }
26746
+
26747
+ // posix version
26748
+ function join$1() {
26749
+ var paths = Array.prototype.slice.call(arguments, 0);
26750
+ return normalize$1(filter(paths, function(p, index) {
26751
+ if (typeof p !== 'string') {
26752
+ throw new TypeError('Arguments to path.join must be strings');
26753
+ }
26754
+ return p;
26755
+ }).join('/'));
26756
+ }
26757
+
26758
+
26759
+ // path.relative(from, to)
26760
+ // posix version
26761
+ function relative$1(from, to) {
26762
+ from = resolve$2(from).substr(1);
26763
+ to = resolve$2(to).substr(1);
26764
+
26765
+ function trim(arr) {
26766
+ var start = 0;
26767
+ for (; start < arr.length; start++) {
26768
+ if (arr[start] !== '') break;
26769
+ }
26770
+
26771
+ var end = arr.length - 1;
26772
+ for (; end >= 0; end--) {
26773
+ if (arr[end] !== '') break;
26774
+ }
26775
+
26776
+ if (start > end) return [];
26777
+ return arr.slice(start, end - start + 1);
26778
+ }
26779
+
26780
+ var fromParts = trim(from.split('/'));
26781
+ var toParts = trim(to.split('/'));
26782
+
26783
+ var length = Math.min(fromParts.length, toParts.length);
26784
+ var samePartsLength = length;
26785
+ for (var i = 0; i < length; i++) {
26786
+ if (fromParts[i] !== toParts[i]) {
26787
+ samePartsLength = i;
26788
+ break;
26789
+ }
26790
+ }
26791
+
26792
+ var outputParts = [];
26793
+ for (var i = samePartsLength; i < fromParts.length; i++) {
26794
+ outputParts.push('..');
26795
+ }
26796
+
26797
+ outputParts = outputParts.concat(toParts.slice(samePartsLength));
26798
+
26799
+ return outputParts.join('/');
26800
+ }
26801
+
26802
+ var sep$1 = '/';
26803
+ var delimiter$1 = ':';
26804
+
26805
+ function dirname$2(path) {
26806
+ var result = splitPath(path),
26807
+ root = result[0],
26808
+ dir = result[1];
26809
+
26810
+ if (!root && !dir) {
26811
+ // No dirname whatsoever
26812
+ return '.';
26813
+ }
26814
+
26815
+ if (dir) {
26816
+ // It has a dirname, strip trailing slash
26817
+ dir = dir.substr(0, dir.length - 1);
26818
+ }
26819
+
26820
+ return root + dir;
26821
+ }
26822
+
26823
+ function basename(path, ext) {
26824
+ var f = splitPath(path)[2];
26825
+ // TODO: make this comparison case-insensitive on windows?
26826
+ if (ext && f.substr(-1 * ext.length) === ext) {
26827
+ f = f.substr(0, f.length - ext.length);
26828
+ }
26829
+ return f;
26830
+ }
26831
+
26832
+
26833
+ function extname(path) {
26834
+ return splitPath(path)[3];
26835
+ }
26836
+ var path = {
26837
+ extname: extname,
26838
+ basename: basename,
26839
+ dirname: dirname$2,
26840
+ sep: sep$1,
26841
+ delimiter: delimiter$1,
26842
+ relative: relative$1,
26843
+ join: join$1,
26844
+ isAbsolute: isAbsolute$1,
26845
+ normalize: normalize$1,
26846
+ resolve: resolve$2
26847
+ };
26848
+ function filter (xs, f) {
26849
+ if (xs.filter) return xs.filter(f);
26850
+ var res = [];
26851
+ for (var i = 0; i < xs.length; i++) {
26852
+ if (f(xs[i], i, xs)) res.push(xs[i]);
26853
+ }
26854
+ return res;
26855
+ }
26856
+
26857
+ // String.prototype.substr - negative index don't work in IE8
26858
+ var substr = 'ab'.substr(-1) === 'b' ?
26859
+ function (str, start, len) { return str.substr(start, len) } :
26860
+ function (str, start, len) {
26861
+ if (start < 0) start = str.length + start;
26862
+ return str.substr(start, len);
26863
+ }
26864
+ ;
26865
+
26866
+ var _polyfillNode_path = /*#__PURE__*/Object.freeze({
26867
+ __proto__: null,
26868
+ basename: basename,
26869
+ default: path,
26870
+ delimiter: delimiter$1,
26871
+ dirname: dirname$2,
26872
+ extname: extname,
26873
+ isAbsolute: isAbsolute$1,
26874
+ join: join$1,
26875
+ normalize: normalize$1,
26876
+ relative: relative$1,
26877
+ resolve: resolve$2,
26878
+ sep: sep$1
26879
+ });
26880
+
26924
26881
  /*! https://mths.be/punycode v1.4.1 by @mathias */
26925
26882
 
26926
26883
 
@@ -32883,8 +32840,8 @@ var tokenize$1 = function tokenizer(input, options = {}) {
32883
32840
  let css = input.css.valueOf();
32884
32841
  let ignore = options.ignoreErrors;
32885
32842
 
32886
- let code, next, quote, content, escape;
32887
- let escaped, escapePos, prev, n, currentToken;
32843
+ let code, content, escape, next, quote;
32844
+ let currentToken, escaped, escapePos, n, prev;
32888
32845
 
32889
32846
  let length = css.length;
32890
32847
  let pos = 0;
@@ -33240,37 +33197,70 @@ let CssSyntaxError$3 = class CssSyntaxError extends Error {
33240
33197
 
33241
33198
  let css = this.source;
33242
33199
  if (color == null) color = pico.isColorSupported;
33243
- if (terminalHighlight$1) {
33244
- if (color) css = terminalHighlight$1(css);
33245
- }
33246
33200
 
33247
- let lines = css.split(/\r?\n/);
33248
- let start = Math.max(this.line - 3, 0);
33249
- let end = Math.min(this.line + 2, lines.length);
33250
-
33251
- let maxWidth = String(end).length;
33252
-
33253
- let mark, aside;
33201
+ let aside = text => text;
33202
+ let mark = text => text;
33203
+ let highlight = text => text;
33254
33204
  if (color) {
33255
33205
  let { bold, gray, red } = pico.createColors(true);
33256
33206
  mark = text => bold(red(text));
33257
33207
  aside = text => gray(text);
33258
- } else {
33259
- mark = aside = str => str;
33208
+ if (terminalHighlight$1) {
33209
+ highlight = text => terminalHighlight$1(text);
33210
+ }
33260
33211
  }
33261
33212
 
33213
+ let lines = css.split(/\r?\n/);
33214
+ let start = Math.max(this.line - 3, 0);
33215
+ let end = Math.min(this.line + 2, lines.length);
33216
+ let maxWidth = String(end).length;
33217
+
33262
33218
  return lines
33263
33219
  .slice(start, end)
33264
33220
  .map((line, index) => {
33265
33221
  let number = start + 1 + index;
33266
33222
  let gutter = ' ' + (' ' + number).slice(-maxWidth) + ' | ';
33267
33223
  if (number === this.line) {
33224
+ if (line.length > 160) {
33225
+ let padding = 20;
33226
+ let subLineStart = Math.max(0, this.column - padding);
33227
+ let subLineEnd = Math.max(
33228
+ this.column + padding,
33229
+ this.endColumn + padding
33230
+ );
33231
+ let subLine = line.slice(subLineStart, subLineEnd);
33232
+
33233
+ let spacing =
33234
+ aside(gutter.replace(/\d/g, ' ')) +
33235
+ line
33236
+ .slice(0, Math.min(this.column - 1, padding - 1))
33237
+ .replace(/[^\t]/g, ' ');
33238
+
33239
+ return (
33240
+ mark('>') +
33241
+ aside(gutter) +
33242
+ highlight(subLine) +
33243
+ '\n ' +
33244
+ spacing +
33245
+ mark('^')
33246
+ )
33247
+ }
33248
+
33268
33249
  let spacing =
33269
33250
  aside(gutter.replace(/\d/g, ' ')) +
33270
33251
  line.slice(0, this.column - 1).replace(/[^\t]/g, ' ');
33271
- return mark('>') + aside(gutter) + line + '\n ' + spacing + mark('^')
33252
+
33253
+ return (
33254
+ mark('>') +
33255
+ aside(gutter) +
33256
+ highlight(line) +
33257
+ '\n ' +
33258
+ spacing +
33259
+ mark('^')
33260
+ )
33272
33261
  }
33273
- return ' ' + aside(gutter) + line
33262
+
33263
+ return ' ' + aside(gutter) + highlight(line)
33274
33264
  })
33275
33265
  .join('\n')
33276
33266
  }
@@ -33287,12 +33277,6 @@ let CssSyntaxError$3 = class CssSyntaxError extends Error {
33287
33277
  var cssSyntaxError = CssSyntaxError$3;
33288
33278
  CssSyntaxError$3.default = CssSyntaxError$3;
33289
33279
 
33290
- var symbols = {};
33291
-
33292
- symbols.isClean = Symbol('isClean');
33293
-
33294
- symbols.my = Symbol('my');
33295
-
33296
33280
  const DEFAULT_RAW = {
33297
33281
  after: '\n',
33298
33282
  beforeClose: '\n',
@@ -33655,10 +33639,16 @@ function stringify$4(node, builder) {
33655
33639
  var stringify_1 = stringify$4;
33656
33640
  stringify$4.default = stringify$4;
33657
33641
 
33658
- let { isClean: isClean$2, my: my$2 } = symbols;
33642
+ var symbols = {};
33643
+
33644
+ symbols.isClean = Symbol('isClean');
33645
+
33646
+ symbols.my = Symbol('my');
33647
+
33659
33648
  let CssSyntaxError$2 = cssSyntaxError;
33660
33649
  let Stringifier = stringifier;
33661
33650
  let stringify$3 = stringify_1;
33651
+ let { isClean: isClean$2, my: my$2 } = symbols;
33662
33652
 
33663
33653
  function cloneNode(obj, parent) {
33664
33654
  let cloned = new obj.constructor();
@@ -33808,6 +33798,10 @@ let Node$4 = class Node {
33808
33798
  }
33809
33799
  }
33810
33800
 
33801
+ markClean() {
33802
+ this[isClean$2] = true;
33803
+ }
33804
+
33811
33805
  markDirty() {
33812
33806
  if (this[isClean$2]) {
33813
33807
  this[isClean$2] = false;
@@ -34037,7 +34031,19 @@ Node$4.default = Node$4;
34037
34031
 
34038
34032
  let Node$3 = node$2;
34039
34033
 
34040
- let Declaration$4 = class Declaration extends Node$3 {
34034
+ let Comment$4 = class Comment extends Node$3 {
34035
+ constructor(defaults) {
34036
+ super(defaults);
34037
+ this.type = 'comment';
34038
+ }
34039
+ };
34040
+
34041
+ var comment$3 = Comment$4;
34042
+ Comment$4.default = Comment$4;
34043
+
34044
+ let Node$2 = node$2;
34045
+
34046
+ let Declaration$4 = class Declaration extends Node$2 {
34041
34047
  constructor(defaults) {
34042
34048
  if (
34043
34049
  defaults &&
@@ -34058,1537 +34064,1488 @@ let Declaration$4 = class Declaration extends Node$3 {
34058
34064
  var declaration = Declaration$4;
34059
34065
  Declaration$4.default = Declaration$4;
34060
34066
 
34061
- var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
34067
+ let Comment$3 = comment$3;
34068
+ let Declaration$3 = declaration;
34069
+ let Node$1 = node$2;
34070
+ let { isClean: isClean$1, my: my$1 } = symbols;
34062
34071
 
34063
- let urlAlphabet =
34064
- 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
34065
- let customAlphabet = (alphabet, defaultSize = 21) => {
34066
- return (size = defaultSize) => {
34067
- let id = '';
34068
- let i = size;
34069
- while (i--) {
34070
- id += alphabet[(Math.random() * alphabet.length) | 0];
34071
- }
34072
- return id
34073
- }
34074
- };
34075
- let nanoid$1 = (size = 21) => {
34076
- let id = '';
34077
- let i = size;
34078
- while (i--) {
34079
- id += urlAlphabet[(Math.random() * 64) | 0];
34080
- }
34081
- return id
34082
- };
34083
- var nonSecure = { nanoid: nanoid$1, customAlphabet };
34072
+ let AtRule$4, parse$4, Root$6, Rule$4;
34084
34073
 
34085
- let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$5 } = sourceMap$2;
34086
- let { existsSync, readFileSync } = require$$0$2;
34087
- let { dirname: dirname$1, join } = require$$1;
34074
+ function cleanSource(nodes) {
34075
+ return nodes.map(i => {
34076
+ if (i.nodes) i.nodes = cleanSource(i.nodes);
34077
+ delete i.source;
34078
+ return i
34079
+ })
34080
+ }
34088
34081
 
34089
- function fromBase64(str) {
34090
- if (Buffer$1) {
34091
- return Buffer$1.from(str, 'base64').toString()
34092
- } else {
34093
- /* c8 ignore next 2 */
34094
- return window.atob(str)
34082
+ function markTreeDirty(node) {
34083
+ node[isClean$1] = false;
34084
+ if (node.proxyOf.nodes) {
34085
+ for (let i of node.proxyOf.nodes) {
34086
+ markTreeDirty(i);
34087
+ }
34095
34088
  }
34096
34089
  }
34097
34090
 
34098
- let PreviousMap$2 = class PreviousMap {
34099
- constructor(css, opts) {
34100
- if (opts.map === false) return
34101
- this.loadAnnotation(css);
34102
- this.inline = this.startWith(this.annotation, 'data:');
34103
-
34104
- let prev = opts.map ? opts.map.prev : undefined;
34105
- let text = this.loadMap(opts.from, prev);
34106
- if (!this.mapFile && opts.from) {
34107
- this.mapFile = opts.from;
34091
+ let Container$7 = class Container extends Node$1 {
34092
+ append(...children) {
34093
+ for (let child of children) {
34094
+ let nodes = this.normalize(child, this.last);
34095
+ for (let node of nodes) this.proxyOf.nodes.push(node);
34108
34096
  }
34109
- if (this.mapFile) this.root = dirname$1(this.mapFile);
34110
- if (text) this.text = text;
34097
+
34098
+ this.markDirty();
34099
+
34100
+ return this
34111
34101
  }
34112
34102
 
34113
- consumer() {
34114
- if (!this.consumerCache) {
34115
- this.consumerCache = new SourceMapConsumer$4(this.text);
34103
+ cleanRaws(keepBetween) {
34104
+ super.cleanRaws(keepBetween);
34105
+ if (this.nodes) {
34106
+ for (let node of this.nodes) node.cleanRaws(keepBetween);
34116
34107
  }
34117
- return this.consumerCache
34118
34108
  }
34119
34109
 
34120
- decodeInline(text) {
34121
- let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
34122
- let baseUri = /^data:application\/json;base64,/;
34123
- let charsetUri = /^data:application\/json;charset=utf-?8,/;
34124
- let uri = /^data:application\/json,/;
34110
+ each(callback) {
34111
+ if (!this.proxyOf.nodes) return undefined
34112
+ let iterator = this.getIterator();
34125
34113
 
34126
- let uriMatch = text.match(charsetUri) || text.match(uri);
34127
- if (uriMatch) {
34128
- return decodeURIComponent(text.substr(uriMatch[0].length))
34129
- }
34114
+ let index, result;
34115
+ while (this.indexes[iterator] < this.proxyOf.nodes.length) {
34116
+ index = this.indexes[iterator];
34117
+ result = callback(this.proxyOf.nodes[index], index);
34118
+ if (result === false) break
34130
34119
 
34131
- let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
34132
- if (baseUriMatch) {
34133
- return fromBase64(text.substr(baseUriMatch[0].length))
34120
+ this.indexes[iterator] += 1;
34134
34121
  }
34135
34122
 
34136
- let encoding = text.match(/data:application\/json;([^,]+),/)[1];
34137
- throw new Error('Unsupported source map encoding ' + encoding)
34138
- }
34139
-
34140
- getAnnotationURL(sourceMapString) {
34141
- return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
34123
+ delete this.indexes[iterator];
34124
+ return result
34142
34125
  }
34143
34126
 
34144
- isMap(map) {
34145
- if (typeof map !== 'object') return false
34146
- return (
34147
- typeof map.mappings === 'string' ||
34148
- typeof map._mappings === 'string' ||
34149
- Array.isArray(map.sections)
34150
- )
34127
+ every(condition) {
34128
+ return this.nodes.every(condition)
34151
34129
  }
34152
34130
 
34153
- loadAnnotation(css) {
34154
- let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
34155
- if (!comments) return
34156
-
34157
- // sourceMappingURLs from comments, strings, etc.
34158
- let start = css.lastIndexOf(comments.pop());
34159
- let end = css.indexOf('*/', start);
34131
+ getIterator() {
34132
+ if (!this.lastEach) this.lastEach = 0;
34133
+ if (!this.indexes) this.indexes = {};
34160
34134
 
34161
- if (start > -1 && end > -1) {
34162
- // Locate the last sourceMappingURL to avoid pickin
34163
- this.annotation = this.getAnnotationURL(css.substring(start, end));
34164
- }
34165
- }
34135
+ this.lastEach += 1;
34136
+ let iterator = this.lastEach;
34137
+ this.indexes[iterator] = 0;
34166
34138
 
34167
- loadFile(path) {
34168
- this.root = dirname$1(path);
34169
- if (existsSync(path)) {
34170
- this.mapFile = path;
34171
- return readFileSync(path, 'utf-8').toString().trim()
34172
- }
34139
+ return iterator
34173
34140
  }
34174
34141
 
34175
- loadMap(file, prev) {
34176
- if (prev === false) return false
34177
-
34178
- if (prev) {
34179
- if (typeof prev === 'string') {
34180
- return prev
34181
- } else if (typeof prev === 'function') {
34182
- let prevPath = prev(file);
34183
- if (prevPath) {
34184
- let map = this.loadFile(prevPath);
34185
- if (!map) {
34186
- throw new Error(
34187
- 'Unable to load previous source map: ' + prevPath.toString()
34142
+ getProxyProcessor() {
34143
+ return {
34144
+ get(node, prop) {
34145
+ if (prop === 'proxyOf') {
34146
+ return node
34147
+ } else if (!node[prop]) {
34148
+ return node[prop]
34149
+ } else if (
34150
+ prop === 'each' ||
34151
+ (typeof prop === 'string' && prop.startsWith('walk'))
34152
+ ) {
34153
+ return (...args) => {
34154
+ return node[prop](
34155
+ ...args.map(i => {
34156
+ if (typeof i === 'function') {
34157
+ return (child, index) => i(child.toProxy(), index)
34158
+ } else {
34159
+ return i
34160
+ }
34161
+ })
34188
34162
  )
34189
34163
  }
34190
- return map
34164
+ } else if (prop === 'every' || prop === 'some') {
34165
+ return cb => {
34166
+ return node[prop]((child, ...other) =>
34167
+ cb(child.toProxy(), ...other)
34168
+ )
34169
+ }
34170
+ } else if (prop === 'root') {
34171
+ return () => node.root().toProxy()
34172
+ } else if (prop === 'nodes') {
34173
+ return node.nodes.map(i => i.toProxy())
34174
+ } else if (prop === 'first' || prop === 'last') {
34175
+ return node[prop].toProxy()
34176
+ } else {
34177
+ return node[prop]
34191
34178
  }
34192
- } else if (prev instanceof SourceMapConsumer$4) {
34193
- return SourceMapGenerator$5.fromSourceMap(prev).toString()
34194
- } else if (prev instanceof SourceMapGenerator$5) {
34195
- return prev.toString()
34196
- } else if (this.isMap(prev)) {
34197
- return JSON.stringify(prev)
34198
- } else {
34199
- throw new Error(
34200
- 'Unsupported previous source map format: ' + prev.toString()
34201
- )
34179
+ },
34180
+
34181
+ set(node, prop, value) {
34182
+ if (node[prop] === value) return true
34183
+ node[prop] = value;
34184
+ if (prop === 'name' || prop === 'params' || prop === 'selector') {
34185
+ node.markDirty();
34186
+ }
34187
+ return true
34202
34188
  }
34203
- } else if (this.inline) {
34204
- return this.decodeInline(this.annotation)
34205
- } else if (this.annotation) {
34206
- let map = this.annotation;
34207
- if (file) map = join(dirname$1(file), map);
34208
- return this.loadFile(map)
34209
34189
  }
34210
34190
  }
34211
34191
 
34212
- startWith(string, start) {
34213
- if (!string) return false
34214
- return string.substr(0, start.length) === start
34215
- }
34216
-
34217
- withContent() {
34218
- return !!(
34219
- this.consumer().sourcesContent &&
34220
- this.consumer().sourcesContent.length > 0
34221
- )
34192
+ index(child) {
34193
+ if (typeof child === 'number') return child
34194
+ if (child.proxyOf) child = child.proxyOf;
34195
+ return this.proxyOf.nodes.indexOf(child)
34222
34196
  }
34223
- };
34224
34197
 
34225
- var previousMap = PreviousMap$2;
34226
- PreviousMap$2.default = PreviousMap$2;
34198
+ insertAfter(exist, add) {
34199
+ let existIndex = this.index(exist);
34200
+ let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
34201
+ existIndex = this.index(exist);
34202
+ for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
34227
34203
 
34228
- let { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$4 } = sourceMap$2;
34229
- let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
34230
- let { isAbsolute, resolve: resolve$1 } = require$$1;
34231
- let { nanoid } = nonSecure;
34204
+ let index;
34205
+ for (let id in this.indexes) {
34206
+ index = this.indexes[id];
34207
+ if (existIndex < index) {
34208
+ this.indexes[id] = index + nodes.length;
34209
+ }
34210
+ }
34232
34211
 
34233
- let terminalHighlight = terminalHighlight_1;
34234
- let CssSyntaxError$1 = cssSyntaxError;
34235
- let PreviousMap$1 = previousMap;
34212
+ this.markDirty();
34236
34213
 
34237
- let fromOffsetCache = Symbol('fromOffsetCache');
34214
+ return this
34215
+ }
34238
34216
 
34239
- let sourceMapAvailable$1 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$4);
34240
- let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
34217
+ insertBefore(exist, add) {
34218
+ let existIndex = this.index(exist);
34219
+ let type = existIndex === 0 ? 'prepend' : false;
34220
+ let nodes = this.normalize(
34221
+ add,
34222
+ this.proxyOf.nodes[existIndex],
34223
+ type
34224
+ ).reverse();
34225
+ existIndex = this.index(exist);
34226
+ for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
34241
34227
 
34242
- let Input$4 = class Input {
34243
- constructor(css, opts = {}) {
34244
- if (
34245
- css === null ||
34246
- typeof css === 'undefined' ||
34247
- (typeof css === 'object' && !css.toString)
34248
- ) {
34249
- throw new Error(`PostCSS received ${css} instead of CSS string`)
34228
+ let index;
34229
+ for (let id in this.indexes) {
34230
+ index = this.indexes[id];
34231
+ if (existIndex <= index) {
34232
+ this.indexes[id] = index + nodes.length;
34233
+ }
34250
34234
  }
34251
34235
 
34252
- this.css = css.toString();
34236
+ this.markDirty();
34253
34237
 
34254
- if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
34255
- this.hasBOM = true;
34256
- this.css = this.css.slice(1);
34257
- } else {
34258
- this.hasBOM = false;
34259
- }
34238
+ return this
34239
+ }
34260
34240
 
34261
- if (opts.from) {
34262
- if (
34263
- !pathAvailable$1 ||
34264
- /^\w+:\/\//.test(opts.from) ||
34265
- isAbsolute(opts.from)
34266
- ) {
34267
- this.file = opts.from;
34268
- } else {
34269
- this.file = resolve$1(opts.from);
34241
+ normalize(nodes, sample) {
34242
+ if (typeof nodes === 'string') {
34243
+ nodes = cleanSource(parse$4(nodes).nodes);
34244
+ } else if (typeof nodes === 'undefined') {
34245
+ nodes = [];
34246
+ } else if (Array.isArray(nodes)) {
34247
+ nodes = nodes.slice(0);
34248
+ for (let i of nodes) {
34249
+ if (i.parent) i.parent.removeChild(i, 'ignore');
34250
+ }
34251
+ } else if (nodes.type === 'root' && this.type !== 'document') {
34252
+ nodes = nodes.nodes.slice(0);
34253
+ for (let i of nodes) {
34254
+ if (i.parent) i.parent.removeChild(i, 'ignore');
34255
+ }
34256
+ } else if (nodes.type) {
34257
+ nodes = [nodes];
34258
+ } else if (nodes.prop) {
34259
+ if (typeof nodes.value === 'undefined') {
34260
+ throw new Error('Value field is missed in node creation')
34261
+ } else if (typeof nodes.value !== 'string') {
34262
+ nodes.value = String(nodes.value);
34270
34263
  }
34264
+ nodes = [new Declaration$3(nodes)];
34265
+ } else if (nodes.selector || nodes.selectors) {
34266
+ nodes = [new Rule$4(nodes)];
34267
+ } else if (nodes.name) {
34268
+ nodes = [new AtRule$4(nodes)];
34269
+ } else if (nodes.text) {
34270
+ nodes = [new Comment$3(nodes)];
34271
+ } else {
34272
+ throw new Error('Unknown node type in node creation')
34271
34273
  }
34272
34274
 
34273
- if (pathAvailable$1 && sourceMapAvailable$1) {
34274
- let map = new PreviousMap$1(this.css, opts);
34275
- if (map.text) {
34276
- this.map = map;
34277
- let file = map.consumer().file;
34278
- if (!this.file && file) this.file = this.mapResolve(file);
34275
+ let processed = nodes.map(i => {
34276
+ /* c8 ignore next */
34277
+ if (!i[my$1] || !i.markClean) Container.rebuild(i);
34278
+ i = i.proxyOf;
34279
+ if (i.parent) i.parent.removeChild(i);
34280
+ if (i[isClean$1]) markTreeDirty(i);
34281
+ if (typeof i.raws.before === 'undefined') {
34282
+ if (sample && typeof sample.raws.before !== 'undefined') {
34283
+ i.raws.before = sample.raws.before.replace(/\S/g, '');
34284
+ }
34279
34285
  }
34280
- }
34286
+ i.parent = this.proxyOf;
34287
+ return i
34288
+ });
34281
34289
 
34282
- if (!this.file) {
34283
- this.id = '<input css ' + nanoid(6) + '>';
34284
- }
34285
- if (this.map) this.map.file = this.from;
34290
+ return processed
34286
34291
  }
34287
34292
 
34288
- error(message, line, column, opts = {}) {
34289
- let result, endLine, endColumn;
34290
-
34291
- if (line && typeof line === 'object') {
34292
- let start = line;
34293
- let end = column;
34294
- if (typeof start.offset === 'number') {
34295
- let pos = this.fromOffset(start.offset);
34296
- line = pos.line;
34297
- column = pos.col;
34298
- } else {
34299
- line = start.line;
34300
- column = start.column;
34301
- }
34302
- if (typeof end.offset === 'number') {
34303
- let pos = this.fromOffset(end.offset);
34304
- endLine = pos.line;
34305
- endColumn = pos.col;
34306
- } else {
34307
- endLine = end.line;
34308
- endColumn = end.column;
34293
+ prepend(...children) {
34294
+ children = children.reverse();
34295
+ for (let child of children) {
34296
+ let nodes = this.normalize(child, this.first, 'prepend').reverse();
34297
+ for (let node of nodes) this.proxyOf.nodes.unshift(node);
34298
+ for (let id in this.indexes) {
34299
+ this.indexes[id] = this.indexes[id] + nodes.length;
34309
34300
  }
34310
- } else if (!column) {
34311
- let pos = this.fromOffset(line);
34312
- line = pos.line;
34313
- column = pos.col;
34314
34301
  }
34315
34302
 
34316
- let origin = this.origin(line, column, endLine, endColumn);
34317
- if (origin) {
34318
- result = new CssSyntaxError$1(
34319
- message,
34320
- origin.endLine === undefined
34321
- ? origin.line
34322
- : { column: origin.column, line: origin.line },
34323
- origin.endLine === undefined
34324
- ? origin.column
34325
- : { column: origin.endColumn, line: origin.endLine },
34326
- origin.source,
34327
- origin.file,
34328
- opts.plugin
34329
- );
34330
- } else {
34331
- result = new CssSyntaxError$1(
34332
- message,
34333
- endLine === undefined ? line : { column, line },
34334
- endLine === undefined ? column : { column: endColumn, line: endLine },
34335
- this.css,
34336
- this.file,
34337
- opts.plugin
34338
- );
34339
- }
34303
+ this.markDirty();
34340
34304
 
34341
- result.input = { column, endColumn, endLine, line, source: this.css };
34342
- if (this.file) {
34343
- if (pathToFileURL$1) {
34344
- result.input.url = pathToFileURL$1(this.file).toString();
34345
- }
34346
- result.input.file = this.file;
34347
- }
34305
+ return this
34306
+ }
34348
34307
 
34349
- return result
34308
+ push(child) {
34309
+ child.parent = this;
34310
+ this.proxyOf.nodes.push(child);
34311
+ return this
34350
34312
  }
34351
34313
 
34352
- fromOffset(offset) {
34353
- let lastLine, lineToIndex;
34354
- if (!this[fromOffsetCache]) {
34355
- let lines = this.css.split('\n');
34356
- lineToIndex = new Array(lines.length);
34357
- let prevIndex = 0;
34314
+ removeAll() {
34315
+ for (let node of this.proxyOf.nodes) node.parent = undefined;
34316
+ this.proxyOf.nodes = [];
34358
34317
 
34359
- for (let i = 0, l = lines.length; i < l; i++) {
34360
- lineToIndex[i] = prevIndex;
34361
- prevIndex += lines[i].length + 1;
34362
- }
34318
+ this.markDirty();
34363
34319
 
34364
- this[fromOffsetCache] = lineToIndex;
34365
- } else {
34366
- lineToIndex = this[fromOffsetCache];
34367
- }
34368
- lastLine = lineToIndex[lineToIndex.length - 1];
34320
+ return this
34321
+ }
34369
34322
 
34370
- let min = 0;
34371
- if (offset >= lastLine) {
34372
- min = lineToIndex.length - 1;
34373
- } else {
34374
- let max = lineToIndex.length - 2;
34375
- let mid;
34376
- while (min < max) {
34377
- mid = min + ((max - min) >> 1);
34378
- if (offset < lineToIndex[mid]) {
34379
- max = mid - 1;
34380
- } else if (offset >= lineToIndex[mid + 1]) {
34381
- min = mid + 1;
34382
- } else {
34383
- min = mid;
34384
- break
34385
- }
34323
+ removeChild(child) {
34324
+ child = this.index(child);
34325
+ this.proxyOf.nodes[child].parent = undefined;
34326
+ this.proxyOf.nodes.splice(child, 1);
34327
+
34328
+ let index;
34329
+ for (let id in this.indexes) {
34330
+ index = this.indexes[id];
34331
+ if (index >= child) {
34332
+ this.indexes[id] = index - 1;
34386
34333
  }
34387
34334
  }
34388
- return {
34389
- col: offset - lineToIndex[min] + 1,
34390
- line: min + 1
34391
- }
34392
- }
34393
34335
 
34394
- mapResolve(file) {
34395
- if (/^\w+:\/\//.test(file)) {
34396
- return file
34397
- }
34398
- return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
34336
+ this.markDirty();
34337
+
34338
+ return this
34399
34339
  }
34400
34340
 
34401
- origin(line, column, endLine, endColumn) {
34402
- if (!this.map) return false
34403
- let consumer = this.map.consumer();
34341
+ replaceValues(pattern, opts, callback) {
34342
+ if (!callback) {
34343
+ callback = opts;
34344
+ opts = {};
34345
+ }
34404
34346
 
34405
- let from = consumer.originalPositionFor({ column, line });
34406
- if (!from.source) return false
34347
+ this.walkDecls(decl => {
34348
+ if (opts.props && !opts.props.includes(decl.prop)) return
34349
+ if (opts.fast && !decl.value.includes(opts.fast)) return
34407
34350
 
34408
- let to;
34409
- if (typeof endLine === 'number') {
34410
- to = consumer.originalPositionFor({ column: endColumn, line: endLine });
34411
- }
34351
+ decl.value = decl.value.replace(pattern, callback);
34352
+ });
34412
34353
 
34413
- let fromUrl;
34354
+ this.markDirty();
34414
34355
 
34415
- if (isAbsolute(from.source)) {
34416
- fromUrl = pathToFileURL$1(from.source);
34417
- } else {
34418
- fromUrl = new URL(
34419
- from.source,
34420
- this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
34421
- );
34422
- }
34356
+ return this
34357
+ }
34423
34358
 
34424
- let result = {
34425
- column: from.column,
34426
- endColumn: to && to.column,
34427
- endLine: to && to.line,
34428
- line: from.line,
34429
- url: fromUrl.toString()
34430
- };
34359
+ some(condition) {
34360
+ return this.nodes.some(condition)
34361
+ }
34431
34362
 
34432
- if (fromUrl.protocol === 'file:') {
34433
- if (fileURLToPath) {
34434
- result.file = fileURLToPath(fromUrl);
34435
- } else {
34436
- /* c8 ignore next 2 */
34437
- throw new Error(`file: protocol is not available in this PostCSS build`)
34363
+ walk(callback) {
34364
+ return this.each((child, i) => {
34365
+ let result;
34366
+ try {
34367
+ result = callback(child, i);
34368
+ } catch (e) {
34369
+ throw child.addToError(e)
34370
+ }
34371
+ if (result !== false && child.walk) {
34372
+ result = child.walk(callback);
34438
34373
  }
34439
- }
34440
34374
 
34441
- let source = consumer.sourceContentFor(from.source);
34442
- if (source) result.source = source;
34375
+ return result
34376
+ })
34377
+ }
34443
34378
 
34444
- return result
34379
+ walkAtRules(name, callback) {
34380
+ if (!callback) {
34381
+ callback = name;
34382
+ return this.walk((child, i) => {
34383
+ if (child.type === 'atrule') {
34384
+ return callback(child, i)
34385
+ }
34386
+ })
34387
+ }
34388
+ if (name instanceof RegExp) {
34389
+ return this.walk((child, i) => {
34390
+ if (child.type === 'atrule' && name.test(child.name)) {
34391
+ return callback(child, i)
34392
+ }
34393
+ })
34394
+ }
34395
+ return this.walk((child, i) => {
34396
+ if (child.type === 'atrule' && child.name === name) {
34397
+ return callback(child, i)
34398
+ }
34399
+ })
34445
34400
  }
34446
34401
 
34447
- toJSON() {
34448
- let json = {};
34449
- for (let name of ['hasBOM', 'css', 'file', 'id']) {
34450
- if (this[name] != null) {
34451
- json[name] = this[name];
34402
+ walkComments(callback) {
34403
+ return this.walk((child, i) => {
34404
+ if (child.type === 'comment') {
34405
+ return callback(child, i)
34452
34406
  }
34407
+ })
34408
+ }
34409
+
34410
+ walkDecls(prop, callback) {
34411
+ if (!callback) {
34412
+ callback = prop;
34413
+ return this.walk((child, i) => {
34414
+ if (child.type === 'decl') {
34415
+ return callback(child, i)
34416
+ }
34417
+ })
34453
34418
  }
34454
- if (this.map) {
34455
- json.map = { ...this.map };
34456
- if (json.map.consumerCache) {
34457
- json.map.consumerCache = undefined;
34419
+ if (prop instanceof RegExp) {
34420
+ return this.walk((child, i) => {
34421
+ if (child.type === 'decl' && prop.test(child.prop)) {
34422
+ return callback(child, i)
34423
+ }
34424
+ })
34425
+ }
34426
+ return this.walk((child, i) => {
34427
+ if (child.type === 'decl' && child.prop === prop) {
34428
+ return callback(child, i)
34458
34429
  }
34430
+ })
34431
+ }
34432
+
34433
+ walkRules(selector, callback) {
34434
+ if (!callback) {
34435
+ callback = selector;
34436
+
34437
+ return this.walk((child, i) => {
34438
+ if (child.type === 'rule') {
34439
+ return callback(child, i)
34440
+ }
34441
+ })
34459
34442
  }
34460
- return json
34443
+ if (selector instanceof RegExp) {
34444
+ return this.walk((child, i) => {
34445
+ if (child.type === 'rule' && selector.test(child.selector)) {
34446
+ return callback(child, i)
34447
+ }
34448
+ })
34449
+ }
34450
+ return this.walk((child, i) => {
34451
+ if (child.type === 'rule' && child.selector === selector) {
34452
+ return callback(child, i)
34453
+ }
34454
+ })
34461
34455
  }
34462
34456
 
34463
- get from() {
34464
- return this.file || this.id
34457
+ get first() {
34458
+ if (!this.proxyOf.nodes) return undefined
34459
+ return this.proxyOf.nodes[0]
34465
34460
  }
34466
- };
34467
34461
 
34468
- var input = Input$4;
34469
- Input$4.default = Input$4;
34462
+ get last() {
34463
+ if (!this.proxyOf.nodes) return undefined
34464
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
34465
+ }
34466
+ };
34470
34467
 
34471
- if (terminalHighlight && terminalHighlight.registerInput) {
34472
- terminalHighlight.registerInput(Input$4);
34473
- }
34468
+ Container$7.registerParse = dependant => {
34469
+ parse$4 = dependant;
34470
+ };
34474
34471
 
34475
- let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$3 } = sourceMap$2;
34476
- let { dirname, relative, resolve, sep } = require$$1;
34477
- let { pathToFileURL } = require$$2;
34472
+ Container$7.registerRule = dependant => {
34473
+ Rule$4 = dependant;
34474
+ };
34478
34475
 
34479
- let Input$3 = input;
34476
+ Container$7.registerAtRule = dependant => {
34477
+ AtRule$4 = dependant;
34478
+ };
34480
34479
 
34481
- let sourceMapAvailable = Boolean(SourceMapConsumer$2 && SourceMapGenerator$3);
34482
- let pathAvailable = Boolean(dirname && resolve && relative && sep);
34480
+ Container$7.registerRoot = dependant => {
34481
+ Root$6 = dependant;
34482
+ };
34483
34483
 
34484
- let MapGenerator$2 = class MapGenerator {
34485
- constructor(stringify, root, opts, cssString) {
34486
- this.stringify = stringify;
34487
- this.mapOpts = opts.map || {};
34488
- this.root = root;
34489
- this.opts = opts;
34490
- this.css = cssString;
34491
- this.originalCSS = cssString;
34492
- this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
34484
+ var container$1 = Container$7;
34485
+ Container$7.default = Container$7;
34493
34486
 
34494
- this.memoizedFileURLs = new Map();
34495
- this.memoizedPaths = new Map();
34496
- this.memoizedURLs = new Map();
34487
+ /* c8 ignore start */
34488
+ Container$7.rebuild = node => {
34489
+ if (node.type === 'atrule') {
34490
+ Object.setPrototypeOf(node, AtRule$4.prototype);
34491
+ } else if (node.type === 'rule') {
34492
+ Object.setPrototypeOf(node, Rule$4.prototype);
34493
+ } else if (node.type === 'decl') {
34494
+ Object.setPrototypeOf(node, Declaration$3.prototype);
34495
+ } else if (node.type === 'comment') {
34496
+ Object.setPrototypeOf(node, Comment$3.prototype);
34497
+ } else if (node.type === 'root') {
34498
+ Object.setPrototypeOf(node, Root$6.prototype);
34497
34499
  }
34498
34500
 
34499
- addAnnotation() {
34500
- let content;
34501
-
34502
- if (this.isInline()) {
34503
- content =
34504
- 'data:application/json;base64,' + this.toBase64(this.map.toString());
34505
- } else if (typeof this.mapOpts.annotation === 'string') {
34506
- content = this.mapOpts.annotation;
34507
- } else if (typeof this.mapOpts.annotation === 'function') {
34508
- content = this.mapOpts.annotation(this.opts.to, this.root);
34509
- } else {
34510
- content = this.outputFile() + '.map';
34511
- }
34512
- let eol = '\n';
34513
- if (this.css.includes('\r\n')) eol = '\r\n';
34501
+ node[my$1] = true;
34514
34502
 
34515
- this.css += eol + '/*# sourceMappingURL=' + content + ' */';
34503
+ if (node.nodes) {
34504
+ node.nodes.forEach(child => {
34505
+ Container$7.rebuild(child);
34506
+ });
34516
34507
  }
34508
+ };
34517
34509
 
34518
- applyPrevMaps() {
34519
- for (let prev of this.previous()) {
34520
- let from = this.toUrl(this.path(prev.file));
34521
- let root = prev.root || dirname(prev.file);
34522
- let map;
34523
-
34524
- if (this.mapOpts.sourcesContent === false) {
34525
- map = new SourceMapConsumer$2(prev.text);
34526
- if (map.sourcesContent) {
34527
- map.sourcesContent = null;
34528
- }
34529
- } else {
34530
- map = prev.consumer();
34531
- }
34510
+ let Container$6 = container$1;
34532
34511
 
34533
- this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
34534
- }
34512
+ let AtRule$3 = class AtRule extends Container$6 {
34513
+ constructor(defaults) {
34514
+ super(defaults);
34515
+ this.type = 'atrule';
34535
34516
  }
34536
34517
 
34537
- clearAnnotation() {
34538
- if (this.mapOpts.annotation === false) return
34539
-
34540
- if (this.root) {
34541
- let node;
34542
- for (let i = this.root.nodes.length - 1; i >= 0; i--) {
34543
- node = this.root.nodes[i];
34544
- if (node.type !== 'comment') continue
34545
- if (node.text.indexOf('# sourceMappingURL=') === 0) {
34546
- this.root.removeChild(i);
34547
- }
34548
- }
34549
- } else if (this.css) {
34550
- this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
34551
- }
34518
+ append(...children) {
34519
+ if (!this.proxyOf.nodes) this.nodes = [];
34520
+ return super.append(...children)
34552
34521
  }
34553
34522
 
34554
- generate() {
34555
- this.clearAnnotation();
34556
- if (pathAvailable && sourceMapAvailable && this.isMap()) {
34557
- return this.generateMap()
34558
- } else {
34559
- let result = '';
34560
- this.stringify(this.root, i => {
34561
- result += i;
34562
- });
34563
- return [result]
34564
- }
34523
+ prepend(...children) {
34524
+ if (!this.proxyOf.nodes) this.nodes = [];
34525
+ return super.prepend(...children)
34565
34526
  }
34527
+ };
34566
34528
 
34567
- generateMap() {
34568
- if (this.root) {
34569
- this.generateString();
34570
- } else if (this.previous().length === 1) {
34571
- let prev = this.previous()[0].consumer();
34572
- prev.file = this.outputFile();
34573
- this.map = SourceMapGenerator$3.fromSourceMap(prev, {
34574
- ignoreInvalidMapping: true
34575
- });
34576
- } else {
34577
- this.map = new SourceMapGenerator$3({
34578
- file: this.outputFile(),
34579
- ignoreInvalidMapping: true
34580
- });
34581
- this.map.addMapping({
34582
- generated: { column: 0, line: 1 },
34583
- original: { column: 0, line: 1 },
34584
- source: this.opts.from
34585
- ? this.toUrl(this.path(this.opts.from))
34586
- : '<no source>'
34587
- });
34588
- }
34529
+ var atRule = AtRule$3;
34530
+ AtRule$3.default = AtRule$3;
34589
34531
 
34590
- if (this.isSourcesContent()) this.setSourcesContent();
34591
- if (this.root && this.previous().length > 0) this.applyPrevMaps();
34592
- if (this.isAnnotation()) this.addAnnotation();
34532
+ Container$6.registerAtRule(AtRule$3);
34593
34533
 
34594
- if (this.isInline()) {
34595
- return [this.css]
34596
- } else {
34597
- return [this.css, this.map]
34598
- }
34599
- }
34534
+ let Container$5 = container$1;
34600
34535
 
34601
- generateString() {
34602
- this.css = '';
34603
- this.map = new SourceMapGenerator$3({
34604
- file: this.outputFile(),
34605
- ignoreInvalidMapping: true
34606
- });
34536
+ let LazyResult$4, Processor$3;
34607
34537
 
34608
- let line = 1;
34609
- let column = 1;
34538
+ let Document$3 = class Document extends Container$5 {
34539
+ constructor(defaults) {
34540
+ // type needs to be passed to super, otherwise child roots won't be normalized correctly
34541
+ super({ type: 'document', ...defaults });
34610
34542
 
34611
- let noSource = '<no source>';
34612
- let mapping = {
34613
- generated: { column: 0, line: 0 },
34614
- original: { column: 0, line: 0 },
34615
- source: ''
34616
- };
34543
+ if (!this.nodes) {
34544
+ this.nodes = [];
34545
+ }
34546
+ }
34617
34547
 
34618
- let lines, last;
34619
- this.stringify(this.root, (str, node, type) => {
34620
- this.css += str;
34548
+ toResult(opts = {}) {
34549
+ let lazy = new LazyResult$4(new Processor$3(), this, opts);
34621
34550
 
34622
- if (node && type !== 'end') {
34623
- mapping.generated.line = line;
34624
- mapping.generated.column = column - 1;
34625
- if (node.source && node.source.start) {
34626
- mapping.source = this.sourcePath(node);
34627
- mapping.original.line = node.source.start.line;
34628
- mapping.original.column = node.source.start.column - 1;
34629
- this.map.addMapping(mapping);
34630
- } else {
34631
- mapping.source = noSource;
34632
- mapping.original.line = 1;
34633
- mapping.original.column = 0;
34634
- this.map.addMapping(mapping);
34635
- }
34636
- }
34551
+ return lazy.stringify()
34552
+ }
34553
+ };
34637
34554
 
34638
- lines = str.match(/\n/g);
34639
- if (lines) {
34640
- line += lines.length;
34641
- last = str.lastIndexOf('\n');
34642
- column = str.length - last;
34643
- } else {
34644
- column += str.length;
34645
- }
34555
+ Document$3.registerLazyResult = dependant => {
34556
+ LazyResult$4 = dependant;
34557
+ };
34646
34558
 
34647
- if (node && type !== 'start') {
34648
- let p = node.parent || { raws: {} };
34649
- let childless =
34650
- node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
34651
- if (!childless || node !== p.last || p.raws.semicolon) {
34652
- if (node.source && node.source.end) {
34653
- mapping.source = this.sourcePath(node);
34654
- mapping.original.line = node.source.end.line;
34655
- mapping.original.column = node.source.end.column - 1;
34656
- mapping.generated.line = line;
34657
- mapping.generated.column = column - 2;
34658
- this.map.addMapping(mapping);
34659
- } else {
34660
- mapping.source = noSource;
34661
- mapping.original.line = 1;
34662
- mapping.original.column = 0;
34663
- mapping.generated.line = line;
34664
- mapping.generated.column = column - 1;
34665
- this.map.addMapping(mapping);
34666
- }
34667
- }
34668
- }
34669
- });
34670
- }
34559
+ Document$3.registerProcessor = dependant => {
34560
+ Processor$3 = dependant;
34561
+ };
34671
34562
 
34672
- isAnnotation() {
34673
- if (this.isInline()) {
34674
- return true
34675
- }
34676
- if (typeof this.mapOpts.annotation !== 'undefined') {
34677
- return this.mapOpts.annotation
34678
- }
34679
- if (this.previous().length) {
34680
- return this.previous().some(i => i.annotation)
34563
+ var document = Document$3;
34564
+ Document$3.default = Document$3;
34565
+
34566
+ let urlAlphabet =
34567
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
34568
+ let customAlphabet = (alphabet, defaultSize = 21) => {
34569
+ return (size = defaultSize) => {
34570
+ let id = '';
34571
+ let i = size;
34572
+ while (i--) {
34573
+ id += alphabet[(Math.random() * alphabet.length) | 0];
34681
34574
  }
34682
- return true
34575
+ return id
34683
34576
  }
34577
+ };
34578
+ let nanoid$1 = (size = 21) => {
34579
+ let id = '';
34580
+ let i = size;
34581
+ while (i--) {
34582
+ id += urlAlphabet[(Math.random() * 64) | 0];
34583
+ }
34584
+ return id
34585
+ };
34586
+ var nonSecure = { nanoid: nanoid$1, customAlphabet };
34684
34587
 
34685
- isInline() {
34686
- if (typeof this.mapOpts.inline !== 'undefined') {
34687
- return this.mapOpts.inline
34688
- }
34588
+ var require$$2 = /*@__PURE__*/getAugmentedNamespace(_polyfillNode_url$1);
34689
34589
 
34690
- let annotation = this.mapOpts.annotation;
34691
- if (typeof annotation !== 'undefined' && annotation !== true) {
34692
- return false
34693
- }
34590
+ let { existsSync, readFileSync } = require$$0$2;
34591
+ let { dirname: dirname$1, join } = require$$1;
34592
+ let { SourceMapConsumer: SourceMapConsumer$4, SourceMapGenerator: SourceMapGenerator$5 } = sourceMap$2;
34694
34593
 
34695
- if (this.previous().length) {
34696
- return this.previous().some(i => i.inline)
34697
- }
34698
- return true
34594
+ function fromBase64(str) {
34595
+ if (Buffer$1) {
34596
+ return Buffer$1.from(str, 'base64').toString()
34597
+ } else {
34598
+ /* c8 ignore next 2 */
34599
+ return window.atob(str)
34699
34600
  }
34601
+ }
34700
34602
 
34701
- isMap() {
34702
- if (typeof this.opts.map !== 'undefined') {
34703
- return !!this.opts.map
34704
- }
34705
- return this.previous().length > 0
34706
- }
34603
+ let PreviousMap$2 = class PreviousMap {
34604
+ constructor(css, opts) {
34605
+ if (opts.map === false) return
34606
+ this.loadAnnotation(css);
34607
+ this.inline = this.startWith(this.annotation, 'data:');
34707
34608
 
34708
- isSourcesContent() {
34709
- if (typeof this.mapOpts.sourcesContent !== 'undefined') {
34710
- return this.mapOpts.sourcesContent
34711
- }
34712
- if (this.previous().length) {
34713
- return this.previous().some(i => i.withContent())
34609
+ let prev = opts.map ? opts.map.prev : undefined;
34610
+ let text = this.loadMap(opts.from, prev);
34611
+ if (!this.mapFile && opts.from) {
34612
+ this.mapFile = opts.from;
34714
34613
  }
34715
- return true
34614
+ if (this.mapFile) this.root = dirname$1(this.mapFile);
34615
+ if (text) this.text = text;
34716
34616
  }
34717
34617
 
34718
- outputFile() {
34719
- if (this.opts.to) {
34720
- return this.path(this.opts.to)
34721
- } else if (this.opts.from) {
34722
- return this.path(this.opts.from)
34723
- } else {
34724
- return 'to.css'
34618
+ consumer() {
34619
+ if (!this.consumerCache) {
34620
+ this.consumerCache = new SourceMapConsumer$4(this.text);
34725
34621
  }
34622
+ return this.consumerCache
34726
34623
  }
34727
34624
 
34728
- path(file) {
34729
- if (this.mapOpts.absolute) return file
34730
- if (file.charCodeAt(0) === 60 /* `<` */) return file
34731
- if (/^\w+:\/\//.test(file)) return file
34732
- let cached = this.memoizedPaths.get(file);
34733
- if (cached) return cached
34734
-
34735
- let from = this.opts.to ? dirname(this.opts.to) : '.';
34625
+ decodeInline(text) {
34626
+ let baseCharsetUri = /^data:application\/json;charset=utf-?8;base64,/;
34627
+ let baseUri = /^data:application\/json;base64,/;
34628
+ let charsetUri = /^data:application\/json;charset=utf-?8,/;
34629
+ let uri = /^data:application\/json,/;
34736
34630
 
34737
- if (typeof this.mapOpts.annotation === 'string') {
34738
- from = dirname(resolve(from, this.mapOpts.annotation));
34631
+ let uriMatch = text.match(charsetUri) || text.match(uri);
34632
+ if (uriMatch) {
34633
+ return decodeURIComponent(text.substr(uriMatch[0].length))
34739
34634
  }
34740
34635
 
34741
- let path = relative(from, file);
34742
- this.memoizedPaths.set(file, path);
34743
-
34744
- return path
34745
- }
34746
-
34747
- previous() {
34748
- if (!this.previousMaps) {
34749
- this.previousMaps = [];
34750
- if (this.root) {
34751
- this.root.walk(node => {
34752
- if (node.source && node.source.input.map) {
34753
- let map = node.source.input.map;
34754
- if (!this.previousMaps.includes(map)) {
34755
- this.previousMaps.push(map);
34756
- }
34757
- }
34758
- });
34759
- } else {
34760
- let input = new Input$3(this.originalCSS, this.opts);
34761
- if (input.map) this.previousMaps.push(input.map);
34762
- }
34636
+ let baseUriMatch = text.match(baseCharsetUri) || text.match(baseUri);
34637
+ if (baseUriMatch) {
34638
+ return fromBase64(text.substr(baseUriMatch[0].length))
34763
34639
  }
34764
34640
 
34765
- return this.previousMaps
34641
+ let encoding = text.match(/data:application\/json;([^,]+),/)[1];
34642
+ throw new Error('Unsupported source map encoding ' + encoding)
34766
34643
  }
34767
34644
 
34768
- setSourcesContent() {
34769
- let already = {};
34770
- if (this.root) {
34771
- this.root.walk(node => {
34772
- if (node.source) {
34773
- let from = node.source.input.from;
34774
- if (from && !already[from]) {
34775
- already[from] = true;
34776
- let fromUrl = this.usesFileUrls
34777
- ? this.toFileUrl(from)
34778
- : this.toUrl(this.path(from));
34779
- this.map.setSourceContent(fromUrl, node.source.input.css);
34780
- }
34781
- }
34782
- });
34783
- } else if (this.css) {
34784
- let from = this.opts.from
34785
- ? this.toUrl(this.path(this.opts.from))
34786
- : '<no source>';
34787
- this.map.setSourceContent(from, this.css);
34788
- }
34645
+ getAnnotationURL(sourceMapString) {
34646
+ return sourceMapString.replace(/^\/\*\s*# sourceMappingURL=/, '').trim()
34789
34647
  }
34790
34648
 
34791
- sourcePath(node) {
34792
- if (this.mapOpts.from) {
34793
- return this.toUrl(this.mapOpts.from)
34794
- } else if (this.usesFileUrls) {
34795
- return this.toFileUrl(node.source.input.from)
34796
- } else {
34797
- return this.toUrl(this.path(node.source.input.from))
34798
- }
34649
+ isMap(map) {
34650
+ if (typeof map !== 'object') return false
34651
+ return (
34652
+ typeof map.mappings === 'string' ||
34653
+ typeof map._mappings === 'string' ||
34654
+ Array.isArray(map.sections)
34655
+ )
34799
34656
  }
34800
34657
 
34801
- toBase64(str) {
34802
- if (Buffer$1) {
34803
- return Buffer$1.from(str).toString('base64')
34804
- } else {
34805
- return window.btoa(unescape(encodeURIComponent(str)))
34806
- }
34807
- }
34658
+ loadAnnotation(css) {
34659
+ let comments = css.match(/\/\*\s*# sourceMappingURL=/g);
34660
+ if (!comments) return
34808
34661
 
34809
- toFileUrl(path) {
34810
- let cached = this.memoizedFileURLs.get(path);
34811
- if (cached) return cached
34662
+ // sourceMappingURLs from comments, strings, etc.
34663
+ let start = css.lastIndexOf(comments.pop());
34664
+ let end = css.indexOf('*/', start);
34812
34665
 
34813
- if (pathToFileURL) {
34814
- let fileURL = pathToFileURL(path).toString();
34815
- this.memoizedFileURLs.set(path, fileURL);
34666
+ if (start > -1 && end > -1) {
34667
+ // Locate the last sourceMappingURL to avoid pickin
34668
+ this.annotation = this.getAnnotationURL(css.substring(start, end));
34669
+ }
34670
+ }
34816
34671
 
34817
- return fileURL
34818
- } else {
34819
- throw new Error(
34820
- '`map.absolute` option is not available in this PostCSS build'
34821
- )
34672
+ loadFile(path) {
34673
+ this.root = dirname$1(path);
34674
+ if (existsSync(path)) {
34675
+ this.mapFile = path;
34676
+ return readFileSync(path, 'utf-8').toString().trim()
34822
34677
  }
34823
34678
  }
34824
34679
 
34825
- toUrl(path) {
34826
- let cached = this.memoizedURLs.get(path);
34827
- if (cached) return cached
34680
+ loadMap(file, prev) {
34681
+ if (prev === false) return false
34828
34682
 
34829
- if (sep === '\\') {
34830
- path = path.replace(/\\/g, '/');
34683
+ if (prev) {
34684
+ if (typeof prev === 'string') {
34685
+ return prev
34686
+ } else if (typeof prev === 'function') {
34687
+ let prevPath = prev(file);
34688
+ if (prevPath) {
34689
+ let map = this.loadFile(prevPath);
34690
+ if (!map) {
34691
+ throw new Error(
34692
+ 'Unable to load previous source map: ' + prevPath.toString()
34693
+ )
34694
+ }
34695
+ return map
34696
+ }
34697
+ } else if (prev instanceof SourceMapConsumer$4) {
34698
+ return SourceMapGenerator$5.fromSourceMap(prev).toString()
34699
+ } else if (prev instanceof SourceMapGenerator$5) {
34700
+ return prev.toString()
34701
+ } else if (this.isMap(prev)) {
34702
+ return JSON.stringify(prev)
34703
+ } else {
34704
+ throw new Error(
34705
+ 'Unsupported previous source map format: ' + prev.toString()
34706
+ )
34707
+ }
34708
+ } else if (this.inline) {
34709
+ return this.decodeInline(this.annotation)
34710
+ } else if (this.annotation) {
34711
+ let map = this.annotation;
34712
+ if (file) map = join(dirname$1(file), map);
34713
+ return this.loadFile(map)
34831
34714
  }
34715
+ }
34832
34716
 
34833
- let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
34834
- this.memoizedURLs.set(path, url);
34717
+ startWith(string, start) {
34718
+ if (!string) return false
34719
+ return string.substr(0, start.length) === start
34720
+ }
34835
34721
 
34836
- return url
34722
+ withContent() {
34723
+ return !!(
34724
+ this.consumer().sourcesContent &&
34725
+ this.consumer().sourcesContent.length > 0
34726
+ )
34837
34727
  }
34838
34728
  };
34839
34729
 
34840
- var mapGenerator = MapGenerator$2;
34730
+ var previousMap = PreviousMap$2;
34731
+ PreviousMap$2.default = PreviousMap$2;
34841
34732
 
34842
- let Node$2 = node$2;
34733
+ let { nanoid } = nonSecure;
34734
+ let { isAbsolute, resolve: resolve$1 } = require$$1;
34735
+ let { SourceMapConsumer: SourceMapConsumer$3, SourceMapGenerator: SourceMapGenerator$4 } = sourceMap$2;
34736
+ let { fileURLToPath, pathToFileURL: pathToFileURL$1 } = require$$2;
34843
34737
 
34844
- let Comment$4 = class Comment extends Node$2 {
34845
- constructor(defaults) {
34846
- super(defaults);
34847
- this.type = 'comment';
34848
- }
34849
- };
34738
+ let CssSyntaxError$1 = cssSyntaxError;
34739
+ let PreviousMap$1 = previousMap;
34740
+ let terminalHighlight = terminalHighlight_1;
34850
34741
 
34851
- var comment$3 = Comment$4;
34852
- Comment$4.default = Comment$4;
34742
+ let fromOffsetCache = Symbol('fromOffsetCache');
34853
34743
 
34854
- let { isClean: isClean$1, my: my$1 } = symbols;
34855
- let Declaration$3 = declaration;
34856
- let Comment$3 = comment$3;
34857
- let Node$1 = node$2;
34744
+ let sourceMapAvailable$1 = Boolean(SourceMapConsumer$3 && SourceMapGenerator$4);
34745
+ let pathAvailable$1 = Boolean(resolve$1 && isAbsolute);
34858
34746
 
34859
- let parse$4, Rule$4, AtRule$4, Root$6;
34747
+ let Input$4 = class Input {
34748
+ constructor(css, opts = {}) {
34749
+ if (
34750
+ css === null ||
34751
+ typeof css === 'undefined' ||
34752
+ (typeof css === 'object' && !css.toString)
34753
+ ) {
34754
+ throw new Error(`PostCSS received ${css} instead of CSS string`)
34755
+ }
34860
34756
 
34861
- function cleanSource(nodes) {
34862
- return nodes.map(i => {
34863
- if (i.nodes) i.nodes = cleanSource(i.nodes);
34864
- delete i.source;
34865
- return i
34866
- })
34867
- }
34757
+ this.css = css.toString();
34868
34758
 
34869
- function markTreeDirty(node) {
34870
- node[isClean$1] = false;
34871
- if (node.proxyOf.nodes) {
34872
- for (let i of node.proxyOf.nodes) {
34873
- markTreeDirty(i);
34759
+ if (this.css[0] === '\uFEFF' || this.css[0] === '\uFFFE') {
34760
+ this.hasBOM = true;
34761
+ this.css = this.css.slice(1);
34762
+ } else {
34763
+ this.hasBOM = false;
34874
34764
  }
34875
- }
34876
- }
34877
34765
 
34878
- let Container$7 = class Container extends Node$1 {
34879
- append(...children) {
34880
- for (let child of children) {
34881
- let nodes = this.normalize(child, this.last);
34882
- for (let node of nodes) this.proxyOf.nodes.push(node);
34766
+ if (opts.from) {
34767
+ if (
34768
+ !pathAvailable$1 ||
34769
+ /^\w+:\/\//.test(opts.from) ||
34770
+ isAbsolute(opts.from)
34771
+ ) {
34772
+ this.file = opts.from;
34773
+ } else {
34774
+ this.file = resolve$1(opts.from);
34775
+ }
34883
34776
  }
34884
34777
 
34885
- this.markDirty();
34886
-
34887
- return this
34888
- }
34778
+ if (pathAvailable$1 && sourceMapAvailable$1) {
34779
+ let map = new PreviousMap$1(this.css, opts);
34780
+ if (map.text) {
34781
+ this.map = map;
34782
+ let file = map.consumer().file;
34783
+ if (!this.file && file) this.file = this.mapResolve(file);
34784
+ }
34785
+ }
34889
34786
 
34890
- cleanRaws(keepBetween) {
34891
- super.cleanRaws(keepBetween);
34892
- if (this.nodes) {
34893
- for (let node of this.nodes) node.cleanRaws(keepBetween);
34787
+ if (!this.file) {
34788
+ this.id = '<input css ' + nanoid(6) + '>';
34894
34789
  }
34790
+ if (this.map) this.map.file = this.from;
34895
34791
  }
34896
34792
 
34897
- each(callback) {
34898
- if (!this.proxyOf.nodes) return undefined
34899
- let iterator = this.getIterator();
34793
+ error(message, line, column, opts = {}) {
34794
+ let endColumn, endLine, result;
34900
34795
 
34901
- let index, result;
34902
- while (this.indexes[iterator] < this.proxyOf.nodes.length) {
34903
- index = this.indexes[iterator];
34904
- result = callback(this.proxyOf.nodes[index], index);
34905
- if (result === false) break
34796
+ if (line && typeof line === 'object') {
34797
+ let start = line;
34798
+ let end = column;
34799
+ if (typeof start.offset === 'number') {
34800
+ let pos = this.fromOffset(start.offset);
34801
+ line = pos.line;
34802
+ column = pos.col;
34803
+ } else {
34804
+ line = start.line;
34805
+ column = start.column;
34806
+ }
34807
+ if (typeof end.offset === 'number') {
34808
+ let pos = this.fromOffset(end.offset);
34809
+ endLine = pos.line;
34810
+ endColumn = pos.col;
34811
+ } else {
34812
+ endLine = end.line;
34813
+ endColumn = end.column;
34814
+ }
34815
+ } else if (!column) {
34816
+ let pos = this.fromOffset(line);
34817
+ line = pos.line;
34818
+ column = pos.col;
34819
+ }
34906
34820
 
34907
- this.indexes[iterator] += 1;
34821
+ let origin = this.origin(line, column, endLine, endColumn);
34822
+ if (origin) {
34823
+ result = new CssSyntaxError$1(
34824
+ message,
34825
+ origin.endLine === undefined
34826
+ ? origin.line
34827
+ : { column: origin.column, line: origin.line },
34828
+ origin.endLine === undefined
34829
+ ? origin.column
34830
+ : { column: origin.endColumn, line: origin.endLine },
34831
+ origin.source,
34832
+ origin.file,
34833
+ opts.plugin
34834
+ );
34835
+ } else {
34836
+ result = new CssSyntaxError$1(
34837
+ message,
34838
+ endLine === undefined ? line : { column, line },
34839
+ endLine === undefined ? column : { column: endColumn, line: endLine },
34840
+ this.css,
34841
+ this.file,
34842
+ opts.plugin
34843
+ );
34908
34844
  }
34909
34845
 
34910
- delete this.indexes[iterator];
34911
- return result
34912
- }
34846
+ result.input = { column, endColumn, endLine, line, source: this.css };
34847
+ if (this.file) {
34848
+ if (pathToFileURL$1) {
34849
+ result.input.url = pathToFileURL$1(this.file).toString();
34850
+ }
34851
+ result.input.file = this.file;
34852
+ }
34913
34853
 
34914
- every(condition) {
34915
- return this.nodes.every(condition)
34854
+ return result
34916
34855
  }
34917
34856
 
34918
- getIterator() {
34919
- if (!this.lastEach) this.lastEach = 0;
34920
- if (!this.indexes) this.indexes = {};
34857
+ fromOffset(offset) {
34858
+ let lastLine, lineToIndex;
34859
+ if (!this[fromOffsetCache]) {
34860
+ let lines = this.css.split('\n');
34861
+ lineToIndex = new Array(lines.length);
34862
+ let prevIndex = 0;
34921
34863
 
34922
- this.lastEach += 1;
34923
- let iterator = this.lastEach;
34924
- this.indexes[iterator] = 0;
34864
+ for (let i = 0, l = lines.length; i < l; i++) {
34865
+ lineToIndex[i] = prevIndex;
34866
+ prevIndex += lines[i].length + 1;
34867
+ }
34925
34868
 
34926
- return iterator
34927
- }
34869
+ this[fromOffsetCache] = lineToIndex;
34870
+ } else {
34871
+ lineToIndex = this[fromOffsetCache];
34872
+ }
34873
+ lastLine = lineToIndex[lineToIndex.length - 1];
34928
34874
 
34929
- getProxyProcessor() {
34930
- return {
34931
- get(node, prop) {
34932
- if (prop === 'proxyOf') {
34933
- return node
34934
- } else if (!node[prop]) {
34935
- return node[prop]
34936
- } else if (
34937
- prop === 'each' ||
34938
- (typeof prop === 'string' && prop.startsWith('walk'))
34939
- ) {
34940
- return (...args) => {
34941
- return node[prop](
34942
- ...args.map(i => {
34943
- if (typeof i === 'function') {
34944
- return (child, index) => i(child.toProxy(), index)
34945
- } else {
34946
- return i
34947
- }
34948
- })
34949
- )
34950
- }
34951
- } else if (prop === 'every' || prop === 'some') {
34952
- return cb => {
34953
- return node[prop]((child, ...other) =>
34954
- cb(child.toProxy(), ...other)
34955
- )
34956
- }
34957
- } else if (prop === 'root') {
34958
- return () => node.root().toProxy()
34959
- } else if (prop === 'nodes') {
34960
- return node.nodes.map(i => i.toProxy())
34961
- } else if (prop === 'first' || prop === 'last') {
34962
- return node[prop].toProxy()
34875
+ let min = 0;
34876
+ if (offset >= lastLine) {
34877
+ min = lineToIndex.length - 1;
34878
+ } else {
34879
+ let max = lineToIndex.length - 2;
34880
+ let mid;
34881
+ while (min < max) {
34882
+ mid = min + ((max - min) >> 1);
34883
+ if (offset < lineToIndex[mid]) {
34884
+ max = mid - 1;
34885
+ } else if (offset >= lineToIndex[mid + 1]) {
34886
+ min = mid + 1;
34963
34887
  } else {
34964
- return node[prop]
34965
- }
34966
- },
34967
-
34968
- set(node, prop, value) {
34969
- if (node[prop] === value) return true
34970
- node[prop] = value;
34971
- if (prop === 'name' || prop === 'params' || prop === 'selector') {
34972
- node.markDirty();
34888
+ min = mid;
34889
+ break
34973
34890
  }
34974
- return true
34975
34891
  }
34976
34892
  }
34893
+ return {
34894
+ col: offset - lineToIndex[min] + 1,
34895
+ line: min + 1
34896
+ }
34977
34897
  }
34978
34898
 
34979
- index(child) {
34980
- if (typeof child === 'number') return child
34981
- if (child.proxyOf) child = child.proxyOf;
34982
- return this.proxyOf.nodes.indexOf(child)
34899
+ mapResolve(file) {
34900
+ if (/^\w+:\/\//.test(file)) {
34901
+ return file
34902
+ }
34903
+ return resolve$1(this.map.consumer().sourceRoot || this.map.root || '.', file)
34983
34904
  }
34984
34905
 
34985
- insertAfter(exist, add) {
34986
- let existIndex = this.index(exist);
34987
- let nodes = this.normalize(add, this.proxyOf.nodes[existIndex]).reverse();
34988
- existIndex = this.index(exist);
34989
- for (let node of nodes) this.proxyOf.nodes.splice(existIndex + 1, 0, node);
34906
+ origin(line, column, endLine, endColumn) {
34907
+ if (!this.map) return false
34908
+ let consumer = this.map.consumer();
34990
34909
 
34991
- let index;
34992
- for (let id in this.indexes) {
34993
- index = this.indexes[id];
34994
- if (existIndex < index) {
34995
- this.indexes[id] = index + nodes.length;
34996
- }
34910
+ let from = consumer.originalPositionFor({ column, line });
34911
+ if (!from.source) return false
34912
+
34913
+ let to;
34914
+ if (typeof endLine === 'number') {
34915
+ to = consumer.originalPositionFor({ column: endColumn, line: endLine });
34997
34916
  }
34998
34917
 
34999
- this.markDirty();
34918
+ let fromUrl;
35000
34919
 
35001
- return this
35002
- }
34920
+ if (isAbsolute(from.source)) {
34921
+ fromUrl = pathToFileURL$1(from.source);
34922
+ } else {
34923
+ fromUrl = new URL(
34924
+ from.source,
34925
+ this.map.consumer().sourceRoot || pathToFileURL$1(this.map.mapFile)
34926
+ );
34927
+ }
35003
34928
 
35004
- insertBefore(exist, add) {
35005
- let existIndex = this.index(exist);
35006
- let type = existIndex === 0 ? 'prepend' : false;
35007
- let nodes = this.normalize(
35008
- add,
35009
- this.proxyOf.nodes[existIndex],
35010
- type
35011
- ).reverse();
35012
- existIndex = this.index(exist);
35013
- for (let node of nodes) this.proxyOf.nodes.splice(existIndex, 0, node);
34929
+ let result = {
34930
+ column: from.column,
34931
+ endColumn: to && to.column,
34932
+ endLine: to && to.line,
34933
+ line: from.line,
34934
+ url: fromUrl.toString()
34935
+ };
35014
34936
 
35015
- let index;
35016
- for (let id in this.indexes) {
35017
- index = this.indexes[id];
35018
- if (existIndex <= index) {
35019
- this.indexes[id] = index + nodes.length;
34937
+ if (fromUrl.protocol === 'file:') {
34938
+ if (fileURLToPath) {
34939
+ result.file = fileURLToPath(fromUrl);
34940
+ } else {
34941
+ /* c8 ignore next 2 */
34942
+ throw new Error(`file: protocol is not available in this PostCSS build`)
35020
34943
  }
35021
34944
  }
35022
34945
 
35023
- this.markDirty();
34946
+ let source = consumer.sourceContentFor(from.source);
34947
+ if (source) result.source = source;
35024
34948
 
35025
- return this
34949
+ return result
35026
34950
  }
35027
34951
 
35028
- normalize(nodes, sample) {
35029
- if (typeof nodes === 'string') {
35030
- nodes = cleanSource(parse$4(nodes).nodes);
35031
- } else if (typeof nodes === 'undefined') {
35032
- nodes = [];
35033
- } else if (Array.isArray(nodes)) {
35034
- nodes = nodes.slice(0);
35035
- for (let i of nodes) {
35036
- if (i.parent) i.parent.removeChild(i, 'ignore');
35037
- }
35038
- } else if (nodes.type === 'root' && this.type !== 'document') {
35039
- nodes = nodes.nodes.slice(0);
35040
- for (let i of nodes) {
35041
- if (i.parent) i.parent.removeChild(i, 'ignore');
35042
- }
35043
- } else if (nodes.type) {
35044
- nodes = [nodes];
35045
- } else if (nodes.prop) {
35046
- if (typeof nodes.value === 'undefined') {
35047
- throw new Error('Value field is missed in node creation')
35048
- } else if (typeof nodes.value !== 'string') {
35049
- nodes.value = String(nodes.value);
34952
+ toJSON() {
34953
+ let json = {};
34954
+ for (let name of ['hasBOM', 'css', 'file', 'id']) {
34955
+ if (this[name] != null) {
34956
+ json[name] = this[name];
35050
34957
  }
35051
- nodes = [new Declaration$3(nodes)];
35052
- } else if (nodes.selector || nodes.selectors) {
35053
- nodes = [new Rule$4(nodes)];
35054
- } else if (nodes.name) {
35055
- nodes = [new AtRule$4(nodes)];
35056
- } else if (nodes.text) {
35057
- nodes = [new Comment$3(nodes)];
35058
- } else {
35059
- throw new Error('Unknown node type in node creation')
35060
34958
  }
35061
-
35062
- let processed = nodes.map(i => {
35063
- /* c8 ignore next */
35064
- if (!i[my$1]) Container.rebuild(i);
35065
- i = i.proxyOf;
35066
- if (i.parent) i.parent.removeChild(i);
35067
- if (i[isClean$1]) markTreeDirty(i);
35068
- if (typeof i.raws.before === 'undefined') {
35069
- if (sample && typeof sample.raws.before !== 'undefined') {
35070
- i.raws.before = sample.raws.before.replace(/\S/g, '');
35071
- }
34959
+ if (this.map) {
34960
+ json.map = { ...this.map };
34961
+ if (json.map.consumerCache) {
34962
+ json.map.consumerCache = undefined;
35072
34963
  }
35073
- i.parent = this.proxyOf;
35074
- return i
35075
- });
34964
+ }
34965
+ return json
34966
+ }
35076
34967
 
35077
- return processed
34968
+ get from() {
34969
+ return this.file || this.id
35078
34970
  }
34971
+ };
35079
34972
 
35080
- prepend(...children) {
35081
- children = children.reverse();
35082
- for (let child of children) {
35083
- let nodes = this.normalize(child, this.first, 'prepend').reverse();
35084
- for (let node of nodes) this.proxyOf.nodes.unshift(node);
35085
- for (let id in this.indexes) {
35086
- this.indexes[id] = this.indexes[id] + nodes.length;
35087
- }
35088
- }
34973
+ var input = Input$4;
34974
+ Input$4.default = Input$4;
35089
34975
 
35090
- this.markDirty();
34976
+ if (terminalHighlight && terminalHighlight.registerInput) {
34977
+ terminalHighlight.registerInput(Input$4);
34978
+ }
35091
34979
 
35092
- return this
35093
- }
34980
+ let Container$4 = container$1;
35094
34981
 
35095
- push(child) {
35096
- child.parent = this;
35097
- this.proxyOf.nodes.push(child);
35098
- return this
34982
+ let LazyResult$3, Processor$2;
34983
+
34984
+ let Root$5 = class Root extends Container$4 {
34985
+ constructor(defaults) {
34986
+ super(defaults);
34987
+ this.type = 'root';
34988
+ if (!this.nodes) this.nodes = [];
35099
34989
  }
35100
34990
 
35101
- removeAll() {
35102
- for (let node of this.proxyOf.nodes) node.parent = undefined;
35103
- this.proxyOf.nodes = [];
34991
+ normalize(child, sample, type) {
34992
+ let nodes = super.normalize(child);
35104
34993
 
35105
- this.markDirty();
34994
+ if (sample) {
34995
+ if (type === 'prepend') {
34996
+ if (this.nodes.length > 1) {
34997
+ sample.raws.before = this.nodes[1].raws.before;
34998
+ } else {
34999
+ delete sample.raws.before;
35000
+ }
35001
+ } else if (this.first !== sample) {
35002
+ for (let node of nodes) {
35003
+ node.raws.before = sample.raws.before;
35004
+ }
35005
+ }
35006
+ }
35106
35007
 
35107
- return this
35008
+ return nodes
35108
35009
  }
35109
35010
 
35110
- removeChild(child) {
35111
- child = this.index(child);
35112
- this.proxyOf.nodes[child].parent = undefined;
35113
- this.proxyOf.nodes.splice(child, 1);
35011
+ removeChild(child, ignore) {
35012
+ let index = this.index(child);
35114
35013
 
35115
- let index;
35116
- for (let id in this.indexes) {
35117
- index = this.indexes[id];
35118
- if (index >= child) {
35119
- this.indexes[id] = index - 1;
35120
- }
35014
+ if (!ignore && index === 0 && this.nodes.length > 1) {
35015
+ this.nodes[1].raws.before = this.nodes[index].raws.before;
35121
35016
  }
35122
35017
 
35123
- this.markDirty();
35018
+ return super.removeChild(child)
35019
+ }
35124
35020
 
35125
- return this
35021
+ toResult(opts = {}) {
35022
+ let lazy = new LazyResult$3(new Processor$2(), this, opts);
35023
+ return lazy.stringify()
35126
35024
  }
35025
+ };
35127
35026
 
35128
- replaceValues(pattern, opts, callback) {
35129
- if (!callback) {
35130
- callback = opts;
35131
- opts = {};
35132
- }
35027
+ Root$5.registerLazyResult = dependant => {
35028
+ LazyResult$3 = dependant;
35029
+ };
35133
35030
 
35134
- this.walkDecls(decl => {
35135
- if (opts.props && !opts.props.includes(decl.prop)) return
35136
- if (opts.fast && !decl.value.includes(opts.fast)) return
35031
+ Root$5.registerProcessor = dependant => {
35032
+ Processor$2 = dependant;
35033
+ };
35137
35034
 
35138
- decl.value = decl.value.replace(pattern, callback);
35139
- });
35035
+ var root$2 = Root$5;
35036
+ Root$5.default = Root$5;
35140
35037
 
35141
- this.markDirty();
35038
+ Container$4.registerRoot(Root$5);
35142
35039
 
35143
- return this
35144
- }
35040
+ let list$2 = {
35041
+ comma(string) {
35042
+ return list$2.split(string, [','], true)
35043
+ },
35145
35044
 
35146
- some(condition) {
35147
- return this.nodes.some(condition)
35148
- }
35045
+ space(string) {
35046
+ let spaces = [' ', '\n', '\t'];
35047
+ return list$2.split(string, spaces)
35048
+ },
35149
35049
 
35150
- walk(callback) {
35151
- return this.each((child, i) => {
35152
- let result;
35153
- try {
35154
- result = callback(child, i);
35155
- } catch (e) {
35156
- throw child.addToError(e)
35157
- }
35158
- if (result !== false && child.walk) {
35159
- result = child.walk(callback);
35160
- }
35050
+ split(string, separators, last) {
35051
+ let array = [];
35052
+ let current = '';
35053
+ let split = false;
35161
35054
 
35162
- return result
35163
- })
35164
- }
35055
+ let func = 0;
35056
+ let inQuote = false;
35057
+ let prevQuote = '';
35058
+ let escape = false;
35165
35059
 
35166
- walkAtRules(name, callback) {
35167
- if (!callback) {
35168
- callback = name;
35169
- return this.walk((child, i) => {
35170
- if (child.type === 'atrule') {
35171
- return callback(child, i)
35172
- }
35173
- })
35174
- }
35175
- if (name instanceof RegExp) {
35176
- return this.walk((child, i) => {
35177
- if (child.type === 'atrule' && name.test(child.name)) {
35178
- return callback(child, i)
35060
+ for (let letter of string) {
35061
+ if (escape) {
35062
+ escape = false;
35063
+ } else if (letter === '\\') {
35064
+ escape = true;
35065
+ } else if (inQuote) {
35066
+ if (letter === prevQuote) {
35067
+ inQuote = false;
35179
35068
  }
35180
- })
35181
- }
35182
- return this.walk((child, i) => {
35183
- if (child.type === 'atrule' && child.name === name) {
35184
- return callback(child, i)
35069
+ } else if (letter === '"' || letter === "'") {
35070
+ inQuote = true;
35071
+ prevQuote = letter;
35072
+ } else if (letter === '(') {
35073
+ func += 1;
35074
+ } else if (letter === ')') {
35075
+ if (func > 0) func -= 1;
35076
+ } else if (func === 0) {
35077
+ if (separators.includes(letter)) split = true;
35185
35078
  }
35186
- })
35187
- }
35188
35079
 
35189
- walkComments(callback) {
35190
- return this.walk((child, i) => {
35191
- if (child.type === 'comment') {
35192
- return callback(child, i)
35080
+ if (split) {
35081
+ if (current !== '') array.push(current.trim());
35082
+ current = '';
35083
+ split = false;
35084
+ } else {
35085
+ current += letter;
35193
35086
  }
35194
- })
35195
- }
35196
-
35197
- walkDecls(prop, callback) {
35198
- if (!callback) {
35199
- callback = prop;
35200
- return this.walk((child, i) => {
35201
- if (child.type === 'decl') {
35202
- return callback(child, i)
35203
- }
35204
- })
35205
- }
35206
- if (prop instanceof RegExp) {
35207
- return this.walk((child, i) => {
35208
- if (child.type === 'decl' && prop.test(child.prop)) {
35209
- return callback(child, i)
35210
- }
35211
- })
35212
35087
  }
35213
- return this.walk((child, i) => {
35214
- if (child.type === 'decl' && child.prop === prop) {
35215
- return callback(child, i)
35216
- }
35217
- })
35088
+
35089
+ if (last || current !== '') array.push(current.trim());
35090
+ return array
35218
35091
  }
35092
+ };
35219
35093
 
35220
- walkRules(selector, callback) {
35221
- if (!callback) {
35222
- callback = selector;
35094
+ var list_1 = list$2;
35095
+ list$2.default = list$2;
35223
35096
 
35224
- return this.walk((child, i) => {
35225
- if (child.type === 'rule') {
35226
- return callback(child, i)
35227
- }
35228
- })
35229
- }
35230
- if (selector instanceof RegExp) {
35231
- return this.walk((child, i) => {
35232
- if (child.type === 'rule' && selector.test(child.selector)) {
35233
- return callback(child, i)
35234
- }
35235
- })
35236
- }
35237
- return this.walk((child, i) => {
35238
- if (child.type === 'rule' && child.selector === selector) {
35239
- return callback(child, i)
35240
- }
35241
- })
35242
- }
35097
+ let Container$3 = container$1;
35098
+ let list$1 = list_1;
35243
35099
 
35244
- get first() {
35245
- if (!this.proxyOf.nodes) return undefined
35246
- return this.proxyOf.nodes[0]
35100
+ let Rule$3 = class Rule extends Container$3 {
35101
+ constructor(defaults) {
35102
+ super(defaults);
35103
+ this.type = 'rule';
35104
+ if (!this.nodes) this.nodes = [];
35247
35105
  }
35248
35106
 
35249
- get last() {
35250
- if (!this.proxyOf.nodes) return undefined
35251
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1]
35107
+ get selectors() {
35108
+ return list$1.comma(this.selector)
35252
35109
  }
35253
- };
35254
35110
 
35255
- Container$7.registerParse = dependant => {
35256
- parse$4 = dependant;
35111
+ set selectors(values) {
35112
+ let match = this.selector ? this.selector.match(/,\s*/) : null;
35113
+ let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
35114
+ this.selector = values.join(sep);
35115
+ }
35257
35116
  };
35258
35117
 
35259
- Container$7.registerRule = dependant => {
35260
- Rule$4 = dependant;
35261
- };
35118
+ var rule = Rule$3;
35119
+ Rule$3.default = Rule$3;
35262
35120
 
35263
- Container$7.registerAtRule = dependant => {
35264
- AtRule$4 = dependant;
35265
- };
35121
+ Container$3.registerRule(Rule$3);
35266
35122
 
35267
- Container$7.registerRoot = dependant => {
35268
- Root$6 = dependant;
35269
- };
35123
+ let AtRule$2 = atRule;
35124
+ let Comment$2 = comment$3;
35125
+ let Declaration$2 = declaration;
35126
+ let Input$3 = input;
35127
+ let PreviousMap = previousMap;
35128
+ let Root$4 = root$2;
35129
+ let Rule$2 = rule;
35270
35130
 
35271
- var container$1 = Container$7;
35272
- Container$7.default = Container$7;
35131
+ function fromJSON$1(json, inputs) {
35132
+ if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
35273
35133
 
35274
- /* c8 ignore start */
35275
- Container$7.rebuild = node => {
35276
- if (node.type === 'atrule') {
35277
- Object.setPrototypeOf(node, AtRule$4.prototype);
35278
- } else if (node.type === 'rule') {
35279
- Object.setPrototypeOf(node, Rule$4.prototype);
35280
- } else if (node.type === 'decl') {
35281
- Object.setPrototypeOf(node, Declaration$3.prototype);
35282
- } else if (node.type === 'comment') {
35283
- Object.setPrototypeOf(node, Comment$3.prototype);
35284
- } else if (node.type === 'root') {
35285
- Object.setPrototypeOf(node, Root$6.prototype);
35134
+ let { inputs: ownInputs, ...defaults } = json;
35135
+ if (ownInputs) {
35136
+ inputs = [];
35137
+ for (let input of ownInputs) {
35138
+ let inputHydrated = { ...input, __proto__: Input$3.prototype };
35139
+ if (inputHydrated.map) {
35140
+ inputHydrated.map = {
35141
+ ...inputHydrated.map,
35142
+ __proto__: PreviousMap.prototype
35143
+ };
35144
+ }
35145
+ inputs.push(inputHydrated);
35146
+ }
35286
35147
  }
35287
-
35288
- node[my$1] = true;
35289
-
35290
- if (node.nodes) {
35291
- node.nodes.forEach(child => {
35292
- Container$7.rebuild(child);
35293
- });
35148
+ if (defaults.nodes) {
35149
+ defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
35294
35150
  }
35295
- };
35151
+ if (defaults.source) {
35152
+ let { inputId, ...source } = defaults.source;
35153
+ defaults.source = source;
35154
+ if (inputId != null) {
35155
+ defaults.source.input = inputs[inputId];
35156
+ }
35157
+ }
35158
+ if (defaults.type === 'root') {
35159
+ return new Root$4(defaults)
35160
+ } else if (defaults.type === 'decl') {
35161
+ return new Declaration$2(defaults)
35162
+ } else if (defaults.type === 'rule') {
35163
+ return new Rule$2(defaults)
35164
+ } else if (defaults.type === 'comment') {
35165
+ return new Comment$2(defaults)
35166
+ } else if (defaults.type === 'atrule') {
35167
+ return new AtRule$2(defaults)
35168
+ } else {
35169
+ throw new Error('Unknown node type: ' + json.type)
35170
+ }
35171
+ }
35296
35172
 
35297
- let Container$6 = container$1;
35173
+ var fromJSON_1 = fromJSON$1;
35174
+ fromJSON$1.default = fromJSON$1;
35298
35175
 
35299
- let LazyResult$4, Processor$3;
35176
+ let { dirname, relative, resolve, sep } = require$$1;
35177
+ let { SourceMapConsumer: SourceMapConsumer$2, SourceMapGenerator: SourceMapGenerator$3 } = sourceMap$2;
35178
+ let { pathToFileURL } = require$$2;
35300
35179
 
35301
- let Document$3 = class Document extends Container$6 {
35302
- constructor(defaults) {
35303
- // type needs to be passed to super, otherwise child roots won't be normalized correctly
35304
- super({ type: 'document', ...defaults });
35180
+ let Input$2 = input;
35305
35181
 
35306
- if (!this.nodes) {
35307
- this.nodes = [];
35308
- }
35309
- }
35182
+ let sourceMapAvailable = Boolean(SourceMapConsumer$2 && SourceMapGenerator$3);
35183
+ let pathAvailable = Boolean(dirname && resolve && relative && sep);
35310
35184
 
35311
- toResult(opts = {}) {
35312
- let lazy = new LazyResult$4(new Processor$3(), this, opts);
35185
+ let MapGenerator$2 = class MapGenerator {
35186
+ constructor(stringify, root, opts, cssString) {
35187
+ this.stringify = stringify;
35188
+ this.mapOpts = opts.map || {};
35189
+ this.root = root;
35190
+ this.opts = opts;
35191
+ this.css = cssString;
35192
+ this.originalCSS = cssString;
35193
+ this.usesFileUrls = !this.mapOpts.from && this.mapOpts.absolute;
35313
35194
 
35314
- return lazy.stringify()
35195
+ this.memoizedFileURLs = new Map();
35196
+ this.memoizedPaths = new Map();
35197
+ this.memoizedURLs = new Map();
35315
35198
  }
35316
- };
35317
-
35318
- Document$3.registerLazyResult = dependant => {
35319
- LazyResult$4 = dependant;
35320
- };
35321
35199
 
35322
- Document$3.registerProcessor = dependant => {
35323
- Processor$3 = dependant;
35324
- };
35200
+ addAnnotation() {
35201
+ let content;
35325
35202
 
35326
- var document = Document$3;
35327
- Document$3.default = Document$3;
35203
+ if (this.isInline()) {
35204
+ content =
35205
+ 'data:application/json;base64,' + this.toBase64(this.map.toString());
35206
+ } else if (typeof this.mapOpts.annotation === 'string') {
35207
+ content = this.mapOpts.annotation;
35208
+ } else if (typeof this.mapOpts.annotation === 'function') {
35209
+ content = this.mapOpts.annotation(this.opts.to, this.root);
35210
+ } else {
35211
+ content = this.outputFile() + '.map';
35212
+ }
35213
+ let eol = '\n';
35214
+ if (this.css.includes('\r\n')) eol = '\r\n';
35328
35215
 
35329
- /* eslint-disable no-console */
35216
+ this.css += eol + '/*# sourceMappingURL=' + content + ' */';
35217
+ }
35330
35218
 
35331
- let printed = {};
35219
+ applyPrevMaps() {
35220
+ for (let prev of this.previous()) {
35221
+ let from = this.toUrl(this.path(prev.file));
35222
+ let root = prev.root || dirname(prev.file);
35223
+ let map;
35332
35224
 
35333
- var warnOnce$2 = function warnOnce(message) {
35334
- if (printed[message]) return
35335
- printed[message] = true;
35225
+ if (this.mapOpts.sourcesContent === false) {
35226
+ map = new SourceMapConsumer$2(prev.text);
35227
+ if (map.sourcesContent) {
35228
+ map.sourcesContent = null;
35229
+ }
35230
+ } else {
35231
+ map = prev.consumer();
35232
+ }
35336
35233
 
35337
- if (typeof console !== 'undefined' && console.warn) {
35338
- console.warn(message);
35234
+ this.map.applySourceMap(map, from, this.toUrl(this.path(root)));
35235
+ }
35339
35236
  }
35340
- };
35341
35237
 
35342
- let Warning$2 = class Warning {
35343
- constructor(text, opts = {}) {
35344
- this.type = 'warning';
35345
- this.text = text;
35238
+ clearAnnotation() {
35239
+ if (this.mapOpts.annotation === false) return
35346
35240
 
35347
- if (opts.node && opts.node.source) {
35348
- let range = opts.node.rangeBy(opts);
35349
- this.line = range.start.line;
35350
- this.column = range.start.column;
35351
- this.endLine = range.end.line;
35352
- this.endColumn = range.end.column;
35241
+ if (this.root) {
35242
+ let node;
35243
+ for (let i = this.root.nodes.length - 1; i >= 0; i--) {
35244
+ node = this.root.nodes[i];
35245
+ if (node.type !== 'comment') continue
35246
+ if (node.text.startsWith('# sourceMappingURL=')) {
35247
+ this.root.removeChild(i);
35248
+ }
35249
+ }
35250
+ } else if (this.css) {
35251
+ this.css = this.css.replace(/\n*\/\*#[\S\s]*?\*\/$/gm, '');
35353
35252
  }
35354
-
35355
- for (let opt in opts) this[opt] = opts[opt];
35356
35253
  }
35357
35254
 
35358
- toString() {
35359
- if (this.node) {
35360
- return this.node.error(this.text, {
35361
- index: this.index,
35362
- plugin: this.plugin,
35363
- word: this.word
35364
- }).message
35255
+ generate() {
35256
+ this.clearAnnotation();
35257
+ if (pathAvailable && sourceMapAvailable && this.isMap()) {
35258
+ return this.generateMap()
35259
+ } else {
35260
+ let result = '';
35261
+ this.stringify(this.root, i => {
35262
+ result += i;
35263
+ });
35264
+ return [result]
35365
35265
  }
35266
+ }
35366
35267
 
35367
- if (this.plugin) {
35368
- return this.plugin + ': ' + this.text
35268
+ generateMap() {
35269
+ if (this.root) {
35270
+ this.generateString();
35271
+ } else if (this.previous().length === 1) {
35272
+ let prev = this.previous()[0].consumer();
35273
+ prev.file = this.outputFile();
35274
+ this.map = SourceMapGenerator$3.fromSourceMap(prev, {
35275
+ ignoreInvalidMapping: true
35276
+ });
35277
+ } else {
35278
+ this.map = new SourceMapGenerator$3({
35279
+ file: this.outputFile(),
35280
+ ignoreInvalidMapping: true
35281
+ });
35282
+ this.map.addMapping({
35283
+ generated: { column: 0, line: 1 },
35284
+ original: { column: 0, line: 1 },
35285
+ source: this.opts.from
35286
+ ? this.toUrl(this.path(this.opts.from))
35287
+ : '<no source>'
35288
+ });
35369
35289
  }
35370
35290
 
35371
- return this.text
35291
+ if (this.isSourcesContent()) this.setSourcesContent();
35292
+ if (this.root && this.previous().length > 0) this.applyPrevMaps();
35293
+ if (this.isAnnotation()) this.addAnnotation();
35294
+
35295
+ if (this.isInline()) {
35296
+ return [this.css]
35297
+ } else {
35298
+ return [this.css, this.map]
35299
+ }
35372
35300
  }
35373
- };
35374
35301
 
35375
- var warning = Warning$2;
35376
- Warning$2.default = Warning$2;
35302
+ generateString() {
35303
+ this.css = '';
35304
+ this.map = new SourceMapGenerator$3({
35305
+ file: this.outputFile(),
35306
+ ignoreInvalidMapping: true
35307
+ });
35377
35308
 
35378
- let Warning$1 = warning;
35309
+ let line = 1;
35310
+ let column = 1;
35379
35311
 
35380
- let Result$3 = class Result {
35381
- constructor(processor, root, opts) {
35382
- this.processor = processor;
35383
- this.messages = [];
35384
- this.root = root;
35385
- this.opts = opts;
35386
- this.css = undefined;
35387
- this.map = undefined;
35388
- }
35312
+ let noSource = '<no source>';
35313
+ let mapping = {
35314
+ generated: { column: 0, line: 0 },
35315
+ original: { column: 0, line: 0 },
35316
+ source: ''
35317
+ };
35389
35318
 
35390
- toString() {
35391
- return this.css
35392
- }
35319
+ let last, lines;
35320
+ this.stringify(this.root, (str, node, type) => {
35321
+ this.css += str;
35393
35322
 
35394
- warn(text, opts = {}) {
35395
- if (!opts.plugin) {
35396
- if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
35397
- opts.plugin = this.lastPlugin.postcssPlugin;
35323
+ if (node && type !== 'end') {
35324
+ mapping.generated.line = line;
35325
+ mapping.generated.column = column - 1;
35326
+ if (node.source && node.source.start) {
35327
+ mapping.source = this.sourcePath(node);
35328
+ mapping.original.line = node.source.start.line;
35329
+ mapping.original.column = node.source.start.column - 1;
35330
+ this.map.addMapping(mapping);
35331
+ } else {
35332
+ mapping.source = noSource;
35333
+ mapping.original.line = 1;
35334
+ mapping.original.column = 0;
35335
+ this.map.addMapping(mapping);
35336
+ }
35337
+ }
35338
+
35339
+ lines = str.match(/\n/g);
35340
+ if (lines) {
35341
+ line += lines.length;
35342
+ last = str.lastIndexOf('\n');
35343
+ column = str.length - last;
35344
+ } else {
35345
+ column += str.length;
35346
+ }
35347
+
35348
+ if (node && type !== 'start') {
35349
+ let p = node.parent || { raws: {} };
35350
+ let childless =
35351
+ node.type === 'decl' || (node.type === 'atrule' && !node.nodes);
35352
+ if (!childless || node !== p.last || p.raws.semicolon) {
35353
+ if (node.source && node.source.end) {
35354
+ mapping.source = this.sourcePath(node);
35355
+ mapping.original.line = node.source.end.line;
35356
+ mapping.original.column = node.source.end.column - 1;
35357
+ mapping.generated.line = line;
35358
+ mapping.generated.column = column - 2;
35359
+ this.map.addMapping(mapping);
35360
+ } else {
35361
+ mapping.source = noSource;
35362
+ mapping.original.line = 1;
35363
+ mapping.original.column = 0;
35364
+ mapping.generated.line = line;
35365
+ mapping.generated.column = column - 1;
35366
+ this.map.addMapping(mapping);
35367
+ }
35368
+ }
35398
35369
  }
35399
- }
35400
-
35401
- let warning = new Warning$1(text, opts);
35402
- this.messages.push(warning);
35403
-
35404
- return warning
35370
+ });
35405
35371
  }
35406
35372
 
35407
- warnings() {
35408
- return this.messages.filter(i => i.type === 'warning')
35373
+ isAnnotation() {
35374
+ if (this.isInline()) {
35375
+ return true
35376
+ }
35377
+ if (typeof this.mapOpts.annotation !== 'undefined') {
35378
+ return this.mapOpts.annotation
35379
+ }
35380
+ if (this.previous().length) {
35381
+ return this.previous().some(i => i.annotation)
35382
+ }
35383
+ return true
35409
35384
  }
35410
35385
 
35411
- get content() {
35412
- return this.css
35413
- }
35414
- };
35386
+ isInline() {
35387
+ if (typeof this.mapOpts.inline !== 'undefined') {
35388
+ return this.mapOpts.inline
35389
+ }
35415
35390
 
35416
- var result = Result$3;
35417
- Result$3.default = Result$3;
35391
+ let annotation = this.mapOpts.annotation;
35392
+ if (typeof annotation !== 'undefined' && annotation !== true) {
35393
+ return false
35394
+ }
35418
35395
 
35419
- let Container$5 = container$1;
35396
+ if (this.previous().length) {
35397
+ return this.previous().some(i => i.inline)
35398
+ }
35399
+ return true
35400
+ }
35420
35401
 
35421
- let AtRule$3 = class AtRule extends Container$5 {
35422
- constructor(defaults) {
35423
- super(defaults);
35424
- this.type = 'atrule';
35402
+ isMap() {
35403
+ if (typeof this.opts.map !== 'undefined') {
35404
+ return !!this.opts.map
35405
+ }
35406
+ return this.previous().length > 0
35425
35407
  }
35426
35408
 
35427
- append(...children) {
35428
- if (!this.proxyOf.nodes) this.nodes = [];
35429
- return super.append(...children)
35409
+ isSourcesContent() {
35410
+ if (typeof this.mapOpts.sourcesContent !== 'undefined') {
35411
+ return this.mapOpts.sourcesContent
35412
+ }
35413
+ if (this.previous().length) {
35414
+ return this.previous().some(i => i.withContent())
35415
+ }
35416
+ return true
35430
35417
  }
35431
35418
 
35432
- prepend(...children) {
35433
- if (!this.proxyOf.nodes) this.nodes = [];
35434
- return super.prepend(...children)
35419
+ outputFile() {
35420
+ if (this.opts.to) {
35421
+ return this.path(this.opts.to)
35422
+ } else if (this.opts.from) {
35423
+ return this.path(this.opts.from)
35424
+ } else {
35425
+ return 'to.css'
35426
+ }
35435
35427
  }
35436
- };
35437
35428
 
35438
- var atRule = AtRule$3;
35439
- AtRule$3.default = AtRule$3;
35429
+ path(file) {
35430
+ if (this.mapOpts.absolute) return file
35431
+ if (file.charCodeAt(0) === 60 /* `<` */) return file
35432
+ if (/^\w+:\/\//.test(file)) return file
35433
+ let cached = this.memoizedPaths.get(file);
35434
+ if (cached) return cached
35440
35435
 
35441
- Container$5.registerAtRule(AtRule$3);
35436
+ let from = this.opts.to ? dirname(this.opts.to) : '.';
35442
35437
 
35443
- let Container$4 = container$1;
35438
+ if (typeof this.mapOpts.annotation === 'string') {
35439
+ from = dirname(resolve(from, this.mapOpts.annotation));
35440
+ }
35444
35441
 
35445
- let LazyResult$3, Processor$2;
35442
+ let path = relative(from, file);
35443
+ this.memoizedPaths.set(file, path);
35446
35444
 
35447
- let Root$5 = class Root extends Container$4 {
35448
- constructor(defaults) {
35449
- super(defaults);
35450
- this.type = 'root';
35451
- if (!this.nodes) this.nodes = [];
35445
+ return path
35452
35446
  }
35453
35447
 
35454
- normalize(child, sample, type) {
35455
- let nodes = super.normalize(child);
35456
-
35457
- if (sample) {
35458
- if (type === 'prepend') {
35459
- if (this.nodes.length > 1) {
35460
- sample.raws.before = this.nodes[1].raws.before;
35461
- } else {
35462
- delete sample.raws.before;
35463
- }
35464
- } else if (this.first !== sample) {
35465
- for (let node of nodes) {
35466
- node.raws.before = sample.raws.before;
35467
- }
35448
+ previous() {
35449
+ if (!this.previousMaps) {
35450
+ this.previousMaps = [];
35451
+ if (this.root) {
35452
+ this.root.walk(node => {
35453
+ if (node.source && node.source.input.map) {
35454
+ let map = node.source.input.map;
35455
+ if (!this.previousMaps.includes(map)) {
35456
+ this.previousMaps.push(map);
35457
+ }
35458
+ }
35459
+ });
35460
+ } else {
35461
+ let input = new Input$2(this.originalCSS, this.opts);
35462
+ if (input.map) this.previousMaps.push(input.map);
35468
35463
  }
35469
35464
  }
35470
35465
 
35471
- return nodes
35466
+ return this.previousMaps
35472
35467
  }
35473
35468
 
35474
- removeChild(child, ignore) {
35475
- let index = this.index(child);
35476
-
35477
- if (!ignore && index === 0 && this.nodes.length > 1) {
35478
- this.nodes[1].raws.before = this.nodes[index].raws.before;
35469
+ setSourcesContent() {
35470
+ let already = {};
35471
+ if (this.root) {
35472
+ this.root.walk(node => {
35473
+ if (node.source) {
35474
+ let from = node.source.input.from;
35475
+ if (from && !already[from]) {
35476
+ already[from] = true;
35477
+ let fromUrl = this.usesFileUrls
35478
+ ? this.toFileUrl(from)
35479
+ : this.toUrl(this.path(from));
35480
+ this.map.setSourceContent(fromUrl, node.source.input.css);
35481
+ }
35482
+ }
35483
+ });
35484
+ } else if (this.css) {
35485
+ let from = this.opts.from
35486
+ ? this.toUrl(this.path(this.opts.from))
35487
+ : '<no source>';
35488
+ this.map.setSourceContent(from, this.css);
35479
35489
  }
35480
-
35481
- return super.removeChild(child)
35482
35490
  }
35483
35491
 
35484
- toResult(opts = {}) {
35485
- let lazy = new LazyResult$3(new Processor$2(), this, opts);
35486
- return lazy.stringify()
35492
+ sourcePath(node) {
35493
+ if (this.mapOpts.from) {
35494
+ return this.toUrl(this.mapOpts.from)
35495
+ } else if (this.usesFileUrls) {
35496
+ return this.toFileUrl(node.source.input.from)
35497
+ } else {
35498
+ return this.toUrl(this.path(node.source.input.from))
35499
+ }
35487
35500
  }
35488
- };
35489
-
35490
- Root$5.registerLazyResult = dependant => {
35491
- LazyResult$3 = dependant;
35492
- };
35493
-
35494
- Root$5.registerProcessor = dependant => {
35495
- Processor$2 = dependant;
35496
- };
35497
-
35498
- var root$2 = Root$5;
35499
- Root$5.default = Root$5;
35500
-
35501
- Container$4.registerRoot(Root$5);
35502
35501
 
35503
- let list$2 = {
35504
- comma(string) {
35505
- return list$2.split(string, [','], true)
35506
- },
35507
-
35508
- space(string) {
35509
- let spaces = [' ', '\n', '\t'];
35510
- return list$2.split(string, spaces)
35511
- },
35512
-
35513
- split(string, separators, last) {
35514
- let array = [];
35515
- let current = '';
35516
- let split = false;
35502
+ toBase64(str) {
35503
+ if (Buffer$1) {
35504
+ return Buffer$1.from(str).toString('base64')
35505
+ } else {
35506
+ return window.btoa(unescape(encodeURIComponent(str)))
35507
+ }
35508
+ }
35517
35509
 
35518
- let func = 0;
35519
- let inQuote = false;
35520
- let prevQuote = '';
35521
- let escape = false;
35510
+ toFileUrl(path) {
35511
+ let cached = this.memoizedFileURLs.get(path);
35512
+ if (cached) return cached
35522
35513
 
35523
- for (let letter of string) {
35524
- if (escape) {
35525
- escape = false;
35526
- } else if (letter === '\\') {
35527
- escape = true;
35528
- } else if (inQuote) {
35529
- if (letter === prevQuote) {
35530
- inQuote = false;
35531
- }
35532
- } else if (letter === '"' || letter === "'") {
35533
- inQuote = true;
35534
- prevQuote = letter;
35535
- } else if (letter === '(') {
35536
- func += 1;
35537
- } else if (letter === ')') {
35538
- if (func > 0) func -= 1;
35539
- } else if (func === 0) {
35540
- if (separators.includes(letter)) split = true;
35541
- }
35514
+ if (pathToFileURL) {
35515
+ let fileURL = pathToFileURL(path).toString();
35516
+ this.memoizedFileURLs.set(path, fileURL);
35542
35517
 
35543
- if (split) {
35544
- if (current !== '') array.push(current.trim());
35545
- current = '';
35546
- split = false;
35547
- } else {
35548
- current += letter;
35549
- }
35518
+ return fileURL
35519
+ } else {
35520
+ throw new Error(
35521
+ '`map.absolute` option is not available in this PostCSS build'
35522
+ )
35550
35523
  }
35551
-
35552
- if (last || current !== '') array.push(current.trim());
35553
- return array
35554
35524
  }
35555
- };
35556
-
35557
- var list_1 = list$2;
35558
- list$2.default = list$2;
35559
35525
 
35560
- let Container$3 = container$1;
35561
- let list$1 = list_1;
35526
+ toUrl(path) {
35527
+ let cached = this.memoizedURLs.get(path);
35528
+ if (cached) return cached
35562
35529
 
35563
- let Rule$3 = class Rule extends Container$3 {
35564
- constructor(defaults) {
35565
- super(defaults);
35566
- this.type = 'rule';
35567
- if (!this.nodes) this.nodes = [];
35568
- }
35530
+ if (sep === '\\') {
35531
+ path = path.replace(/\\/g, '/');
35532
+ }
35569
35533
 
35570
- get selectors() {
35571
- return list$1.comma(this.selector)
35572
- }
35534
+ let url = encodeURI(path).replace(/[#?]/g, encodeURIComponent);
35535
+ this.memoizedURLs.set(path, url);
35573
35536
 
35574
- set selectors(values) {
35575
- let match = this.selector ? this.selector.match(/,\s*/) : null;
35576
- let sep = match ? match[0] : ',' + this.raw('between', 'beforeOpen');
35577
- this.selector = values.join(sep);
35537
+ return url
35578
35538
  }
35579
35539
  };
35580
35540
 
35581
- var rule = Rule$3;
35582
- Rule$3.default = Rule$3;
35583
-
35584
- Container$3.registerRule(Rule$3);
35541
+ var mapGenerator = MapGenerator$2;
35585
35542
 
35586
- let Declaration$2 = declaration;
35543
+ let AtRule$1 = atRule;
35544
+ let Comment$1 = comment$3;
35545
+ let Declaration$1 = declaration;
35546
+ let Root$3 = root$2;
35547
+ let Rule$1 = rule;
35587
35548
  let tokenizer = tokenize$1;
35588
- let Comment$2 = comment$3;
35589
- let AtRule$2 = atRule;
35590
- let Root$4 = root$2;
35591
- let Rule$2 = rule;
35592
35549
 
35593
35550
  const SAFE_COMMENT_NEIGHBOR = {
35594
35551
  empty: true,
@@ -35607,7 +35564,7 @@ let Parser$1 = class Parser {
35607
35564
  constructor(input) {
35608
35565
  this.input = input;
35609
35566
 
35610
- this.root = new Root$4();
35567
+ this.root = new Root$3();
35611
35568
  this.current = this.root;
35612
35569
  this.spaces = '';
35613
35570
  this.semicolon = false;
@@ -35617,7 +35574,7 @@ let Parser$1 = class Parser {
35617
35574
  }
35618
35575
 
35619
35576
  atrule(token) {
35620
- let node = new AtRule$2();
35577
+ let node = new AtRule$1();
35621
35578
  node.name = token[1].slice(1);
35622
35579
  if (node.name === '') {
35623
35580
  this.unnamedAtrule(node, token);
@@ -35726,7 +35683,7 @@ let Parser$1 = class Parser {
35726
35683
 
35727
35684
  colon(tokens) {
35728
35685
  let brackets = 0;
35729
- let token, type, prev;
35686
+ let prev, token, type;
35730
35687
  for (let [i, element] of tokens.entries()) {
35731
35688
  token = element;
35732
35689
  type = token[0];
@@ -35753,7 +35710,7 @@ let Parser$1 = class Parser {
35753
35710
  }
35754
35711
 
35755
35712
  comment(token) {
35756
- let node = new Comment$2();
35713
+ let node = new Comment$1();
35757
35714
  this.init(node, token[2]);
35758
35715
  node.source.end = this.getPosition(token[3] || token[2]);
35759
35716
  node.source.end.offset++;
@@ -35776,7 +35733,7 @@ let Parser$1 = class Parser {
35776
35733
  }
35777
35734
 
35778
35735
  decl(tokens, customProperty) {
35779
- let node = new Declaration$2();
35736
+ let node = new Declaration$1();
35780
35737
  this.init(node, tokens[0][2]);
35781
35738
 
35782
35739
  let last = tokens[tokens.length - 1];
@@ -35850,12 +35807,12 @@ let Parser$1 = class Parser {
35850
35807
  let str = '';
35851
35808
  for (let j = i; j > 0; j--) {
35852
35809
  let type = cache[j][0];
35853
- if (str.trim().indexOf('!') === 0 && type !== 'space') {
35810
+ if (str.trim().startsWith('!') && type !== 'space') {
35854
35811
  break
35855
35812
  }
35856
35813
  str = cache.pop()[1] + str;
35857
35814
  }
35858
- if (str.trim().indexOf('!') === 0) {
35815
+ if (str.trim().startsWith('!')) {
35859
35816
  node.important = true;
35860
35817
  node.raws.important = str;
35861
35818
  tokens = cache;
@@ -35889,7 +35846,7 @@ let Parser$1 = class Parser {
35889
35846
  }
35890
35847
 
35891
35848
  emptyRule(token) {
35892
- let node = new Rule$2();
35849
+ let node = new Rule$1();
35893
35850
  this.init(node, token[2]);
35894
35851
  node.selector = '';
35895
35852
  node.raws.between = '';
@@ -36099,7 +36056,7 @@ let Parser$1 = class Parser {
36099
36056
  rule(tokens) {
36100
36057
  tokens.pop();
36101
36058
 
36102
- let node = new Rule$2();
36059
+ let node = new Rule$1();
36103
36060
  this.init(node, tokens[0][2]);
36104
36061
 
36105
36062
  node.raws.between = this.spacesAndCommentsFromEnd(tokens);
@@ -36192,11 +36149,11 @@ let Parser$1 = class Parser {
36192
36149
  var parser$1 = Parser$1;
36193
36150
 
36194
36151
  let Container$2 = container$1;
36152
+ let Input$1 = input;
36195
36153
  let Parser = parser$1;
36196
- let Input$2 = input;
36197
36154
 
36198
36155
  function parse$3(css, opts) {
36199
- let input = new Input$2(css, opts);
36156
+ let input = new Input$1(css, opts);
36200
36157
  let parser = new Parser(input);
36201
36158
  try {
36202
36159
  parser.parse();
@@ -36232,15 +36189,105 @@ parse$3.default = parse$3;
36232
36189
 
36233
36190
  Container$2.registerParse(parse$3);
36234
36191
 
36235
- let { isClean, my } = symbols;
36236
- let MapGenerator$1 = mapGenerator;
36237
- let stringify$2 = stringify_1;
36192
+ let Warning$2 = class Warning {
36193
+ constructor(text, opts = {}) {
36194
+ this.type = 'warning';
36195
+ this.text = text;
36196
+
36197
+ if (opts.node && opts.node.source) {
36198
+ let range = opts.node.rangeBy(opts);
36199
+ this.line = range.start.line;
36200
+ this.column = range.start.column;
36201
+ this.endLine = range.end.line;
36202
+ this.endColumn = range.end.column;
36203
+ }
36204
+
36205
+ for (let opt in opts) this[opt] = opts[opt];
36206
+ }
36207
+
36208
+ toString() {
36209
+ if (this.node) {
36210
+ return this.node.error(this.text, {
36211
+ index: this.index,
36212
+ plugin: this.plugin,
36213
+ word: this.word
36214
+ }).message
36215
+ }
36216
+
36217
+ if (this.plugin) {
36218
+ return this.plugin + ': ' + this.text
36219
+ }
36220
+
36221
+ return this.text
36222
+ }
36223
+ };
36224
+
36225
+ var warning = Warning$2;
36226
+ Warning$2.default = Warning$2;
36227
+
36228
+ let Warning$1 = warning;
36229
+
36230
+ let Result$3 = class Result {
36231
+ constructor(processor, root, opts) {
36232
+ this.processor = processor;
36233
+ this.messages = [];
36234
+ this.root = root;
36235
+ this.opts = opts;
36236
+ this.css = undefined;
36237
+ this.map = undefined;
36238
+ }
36239
+
36240
+ toString() {
36241
+ return this.css
36242
+ }
36243
+
36244
+ warn(text, opts = {}) {
36245
+ if (!opts.plugin) {
36246
+ if (this.lastPlugin && this.lastPlugin.postcssPlugin) {
36247
+ opts.plugin = this.lastPlugin.postcssPlugin;
36248
+ }
36249
+ }
36250
+
36251
+ let warning = new Warning$1(text, opts);
36252
+ this.messages.push(warning);
36253
+
36254
+ return warning
36255
+ }
36256
+
36257
+ warnings() {
36258
+ return this.messages.filter(i => i.type === 'warning')
36259
+ }
36260
+
36261
+ get content() {
36262
+ return this.css
36263
+ }
36264
+ };
36265
+
36266
+ var result = Result$3;
36267
+ Result$3.default = Result$3;
36268
+
36269
+ /* eslint-disable no-console */
36270
+
36271
+ let printed = {};
36272
+
36273
+ var warnOnce$2 = function warnOnce(message) {
36274
+ if (printed[message]) return
36275
+ printed[message] = true;
36276
+
36277
+ if (typeof console !== 'undefined' && console.warn) {
36278
+ console.warn(message);
36279
+ }
36280
+ };
36281
+
36238
36282
  let Container$1 = container$1;
36239
36283
  let Document$2 = document;
36240
- let warnOnce$1 = warnOnce$2;
36241
- let Result$2 = result;
36284
+ let MapGenerator$1 = mapGenerator;
36242
36285
  let parse$2 = parse_1;
36243
- let Root$3 = root$2;
36286
+ let Result$2 = result;
36287
+ let Root$2 = root$2;
36288
+ let stringify$2 = stringify_1;
36289
+ let { isClean, my } = symbols;
36290
+ let warnOnce$1 = warnOnce$2;
36244
36291
 
36245
36292
  const TYPE_TO_CLASS_NAME = {
36246
36293
  atrule: 'AtRule',
@@ -36778,14 +36825,14 @@ LazyResult$2.registerPostcss = dependant => {
36778
36825
  var lazyResult = LazyResult$2;
36779
36826
  LazyResult$2.default = LazyResult$2;
36780
36827
 
36781
- Root$3.registerLazyResult(LazyResult$2);
36828
+ Root$2.registerLazyResult(LazyResult$2);
36782
36829
  Document$2.registerLazyResult(LazyResult$2);
36783
36830
 
36784
36831
  let MapGenerator = mapGenerator;
36785
- let stringify$1 = stringify_1;
36786
- let warnOnce = warnOnce$2;
36787
36832
  let parse$1 = parse_1;
36788
36833
  const Result$1 = result;
36834
+ let stringify$1 = stringify_1;
36835
+ let warnOnce = warnOnce$2;
36789
36836
 
36790
36837
  let NoWorkResult$1 = class NoWorkResult {
36791
36838
  constructor(processor, css, opts) {
@@ -36918,14 +36965,14 @@ let NoWorkResult$1 = class NoWorkResult {
36918
36965
  var noWorkResult = NoWorkResult$1;
36919
36966
  NoWorkResult$1.default = NoWorkResult$1;
36920
36967
 
36921
- let NoWorkResult = noWorkResult;
36922
- let LazyResult$1 = lazyResult;
36923
36968
  let Document$1 = document;
36924
- let Root$2 = root$2;
36969
+ let LazyResult$1 = lazyResult;
36970
+ let NoWorkResult = noWorkResult;
36971
+ let Root$1 = root$2;
36925
36972
 
36926
36973
  let Processor$1 = class Processor {
36927
36974
  constructor(plugins = []) {
36928
- this.version = '8.4.41';
36975
+ this.version = '8.4.44';
36929
36976
  this.plugins = this.normalize(plugins);
36930
36977
  }
36931
36978
 
@@ -36981,80 +37028,27 @@ let Processor$1 = class Processor {
36981
37028
  var processor$1 = Processor$1;
36982
37029
  Processor$1.default = Processor$1;
36983
37030
 
36984
- Root$2.registerProcessor(Processor$1);
37031
+ Root$1.registerProcessor(Processor$1);
36985
37032
  Document$1.registerProcessor(Processor$1);
36986
37033
 
36987
- let Declaration$1 = declaration;
36988
- let PreviousMap = previousMap;
36989
- let Comment$1 = comment$3;
36990
- let AtRule$1 = atRule;
36991
- let Input$1 = input;
36992
- let Root$1 = root$2;
36993
- let Rule$1 = rule;
36994
-
36995
- function fromJSON$1(json, inputs) {
36996
- if (Array.isArray(json)) return json.map(n => fromJSON$1(n))
36997
-
36998
- let { inputs: ownInputs, ...defaults } = json;
36999
- if (ownInputs) {
37000
- inputs = [];
37001
- for (let input of ownInputs) {
37002
- let inputHydrated = { ...input, __proto__: Input$1.prototype };
37003
- if (inputHydrated.map) {
37004
- inputHydrated.map = {
37005
- ...inputHydrated.map,
37006
- __proto__: PreviousMap.prototype
37007
- };
37008
- }
37009
- inputs.push(inputHydrated);
37010
- }
37011
- }
37012
- if (defaults.nodes) {
37013
- defaults.nodes = json.nodes.map(n => fromJSON$1(n, inputs));
37014
- }
37015
- if (defaults.source) {
37016
- let { inputId, ...source } = defaults.source;
37017
- defaults.source = source;
37018
- if (inputId != null) {
37019
- defaults.source.input = inputs[inputId];
37020
- }
37021
- }
37022
- if (defaults.type === 'root') {
37023
- return new Root$1(defaults)
37024
- } else if (defaults.type === 'decl') {
37025
- return new Declaration$1(defaults)
37026
- } else if (defaults.type === 'rule') {
37027
- return new Rule$1(defaults)
37028
- } else if (defaults.type === 'comment') {
37029
- return new Comment$1(defaults)
37030
- } else if (defaults.type === 'atrule') {
37031
- return new AtRule$1(defaults)
37032
- } else {
37033
- throw new Error('Unknown node type: ' + json.type)
37034
- }
37035
- }
37036
-
37037
- var fromJSON_1 = fromJSON$1;
37038
- fromJSON$1.default = fromJSON$1;
37039
-
37034
+ let AtRule = atRule;
37035
+ let Comment = comment$3;
37036
+ let Container = container$1;
37040
37037
  let CssSyntaxError = cssSyntaxError;
37041
37038
  let Declaration = declaration;
37042
- let LazyResult = lazyResult;
37043
- let Container = container$1;
37044
- let Processor = processor$1;
37045
- let stringify = stringify_1;
37046
- let fromJSON = fromJSON_1;
37047
37039
  let Document = document;
37048
- let Warning = warning;
37049
- let Comment = comment$3;
37050
- let AtRule = atRule;
37051
- let Result = result;
37040
+ let fromJSON = fromJSON_1;
37052
37041
  let Input = input;
37053
- let parse = parse_1;
37042
+ let LazyResult = lazyResult;
37054
37043
  let list = list_1;
37055
- let Rule = rule;
37056
- let Root = root$2;
37057
37044
  let Node = node$2;
37045
+ let parse = parse_1;
37046
+ let Processor = processor$1;
37047
+ let Result = result;
37048
+ let Root = root$2;
37049
+ let Rule = rule;
37050
+ let stringify = stringify_1;
37051
+ let Warning = warning;
37058
37052
 
37059
37053
  function postcss(...plugins) {
37060
37054
  if (plugins.length === 1 && Array.isArray(plugins[0])) {
@@ -44259,6 +44253,49 @@ function preprocess(options, preprocessor) {
44259
44253
  );
44260
44254
  }
44261
44255
 
44256
+ const UNKNOWN_TYPE = "Unknown";
44257
+ function resolveObjectKey(node, computed) {
44258
+ switch (node.type) {
44259
+ case "StringLiteral":
44260
+ case "NumericLiteral":
44261
+ return String(node.value);
44262
+ case "Identifier":
44263
+ if (!computed) return node.name;
44264
+ }
44265
+ return void 0;
44266
+ }
44267
+ function concatStrings(strs) {
44268
+ return strs.filter((s) => !!s).join(", ");
44269
+ }
44270
+ function isLiteralNode(node) {
44271
+ return node.type.endsWith("Literal");
44272
+ }
44273
+ function isCallOf(node, test) {
44274
+ return !!(node && test && node.type === "CallExpression" && node.callee.type === "Identifier" && (typeof test === "string" ? node.callee.name === test : test(node.callee.name)));
44275
+ }
44276
+ function toRuntimeTypeString(types) {
44277
+ return types.length > 1 ? `[${types.join(", ")}]` : types[0];
44278
+ }
44279
+ function getImportedName(specifier) {
44280
+ if (specifier.type === "ImportSpecifier")
44281
+ return specifier.imported.type === "Identifier" ? specifier.imported.name : specifier.imported.value;
44282
+ else if (specifier.type === "ImportNamespaceSpecifier") return "*";
44283
+ return "default";
44284
+ }
44285
+ function getId(node) {
44286
+ return node.type === "Identifier" ? node.name : node.type === "StringLiteral" ? node.value : null;
44287
+ }
44288
+ const normalize = (path.posix || path).normalize;
44289
+ const windowsSlashRE = /\\/g;
44290
+ function normalizePath(p) {
44291
+ return normalize(p.replace(windowsSlashRE, "/"));
44292
+ }
44293
+ const joinPaths = (path.posix || path).join;
44294
+ const propNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~\-]/;
44295
+ function getEscapedPropName(key) {
44296
+ return propNameEscapeSymbolsRE.test(key) ? JSON.stringify(key) : key;
44297
+ }
44298
+
44262
44299
  function analyzeScriptBindings(ast) {
44263
44300
  for (const node of ast) {
44264
44301
  if (node.type === "ExportDefaultDeclaration" && node.declaration.type === "ObjectExpression") {
@@ -48853,7 +48890,7 @@ var __spreadValues = (a, b) => {
48853
48890
  }
48854
48891
  return a;
48855
48892
  };
48856
- const version = "3.5.0-rc.1";
48893
+ const version = "3.5.0";
48857
48894
  const parseCache = parseCache$1;
48858
48895
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
48859
48896
  const walk = walk$2;