@stencil/core 4.39.0 → 4.40.1-dev.1766552834.64f6089
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.
- package/cli/index.cjs +1616 -41
- package/cli/index.js +1616 -41
- package/cli/package.json +1 -1
- package/compiler/package.json +1 -1
- package/compiler/stencil.js +2791 -2515
- package/dev-server/client/index.js +1 -1
- package/dev-server/client/package.json +1 -1
- package/dev-server/connector.html +2 -2
- package/dev-server/index.js +1 -1
- package/dev-server/package.json +1 -1
- package/dev-server/server-process.js +1665 -90
- package/internal/app-data/index.cjs +1 -0
- package/internal/app-data/index.js +1 -0
- package/internal/app-data/package.json +1 -1
- package/internal/app-globals/package.json +1 -1
- package/internal/client/index.js +1746 -105
- package/internal/client/package.json +1 -1
- package/internal/client/patch-browser.js +1 -1
- package/internal/hydrate/index.js +1770 -133
- package/internal/hydrate/package.json +1 -1
- package/internal/hydrate/runner.js +1794 -104
- package/internal/package.json +1 -1
- package/internal/stencil-private.d.ts +25 -2
- package/internal/stencil-public-compiler.d.ts +33 -3
- package/internal/stencil-public-runtime.d.ts +14 -3
- package/internal/testing/index.js +1758 -133
- package/internal/testing/package.json +1 -1
- package/mock-doc/index.cjs +8 -1
- package/mock-doc/index.js +8 -1
- package/mock-doc/package.json +1 -1
- package/package.json +1 -1
- package/screenshot/index.js +1608 -30
- package/screenshot/package.json +1 -1
- package/screenshot/pixel-match.js +1 -1
- package/sys/node/index.js +28 -28
- package/sys/node/package.json +1 -1
- package/sys/node/worker.js +1 -1
- package/testing/index.js +1696 -109
- package/testing/package.json +1 -1
|
@@ -1,11 +1,253 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Stencil Hydrate Runner v4.
|
|
2
|
+
Stencil Hydrate Runner v4.40.1-dev.1766552834.64f6089 | MIT Licensed | https://stenciljs.com
|
|
3
3
|
*/
|
|
4
|
+
var __create = Object.create;
|
|
4
5
|
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __typeError = (msg) => {
|
|
11
|
+
throw TypeError(msg);
|
|
12
|
+
};
|
|
13
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
14
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
5
17
|
var __export = (target, all) => {
|
|
6
18
|
for (var name in all)
|
|
7
19
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
20
|
};
|
|
21
|
+
var __copyProps = (to, from, except, desc) => {
|
|
22
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23
|
+
for (let key of __getOwnPropNames(from))
|
|
24
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
25
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
26
|
+
}
|
|
27
|
+
return to;
|
|
28
|
+
};
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
30
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
31
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
32
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
33
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
38
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
39
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
40
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
41
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
42
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
43
|
+
|
|
44
|
+
// node_modules/balanced-match/index.js
|
|
45
|
+
var require_balanced_match = __commonJS({
|
|
46
|
+
"node_modules/balanced-match/index.js"(exports, module) {
|
|
47
|
+
"use strict";
|
|
48
|
+
module.exports = balanced;
|
|
49
|
+
function balanced(a, b, str) {
|
|
50
|
+
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
51
|
+
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
52
|
+
var r = range(a, b, str);
|
|
53
|
+
return r && {
|
|
54
|
+
start: r[0],
|
|
55
|
+
end: r[1],
|
|
56
|
+
pre: str.slice(0, r[0]),
|
|
57
|
+
body: str.slice(r[0] + a.length, r[1]),
|
|
58
|
+
post: str.slice(r[1] + b.length)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function maybeMatch(reg, str) {
|
|
62
|
+
var m = str.match(reg);
|
|
63
|
+
return m ? m[0] : null;
|
|
64
|
+
}
|
|
65
|
+
balanced.range = range;
|
|
66
|
+
function range(a, b, str) {
|
|
67
|
+
var begs, beg, left, right, result;
|
|
68
|
+
var ai = str.indexOf(a);
|
|
69
|
+
var bi = str.indexOf(b, ai + 1);
|
|
70
|
+
var i = ai;
|
|
71
|
+
if (ai >= 0 && bi > 0) {
|
|
72
|
+
if (a === b) {
|
|
73
|
+
return [ai, bi];
|
|
74
|
+
}
|
|
75
|
+
begs = [];
|
|
76
|
+
left = str.length;
|
|
77
|
+
while (i >= 0 && !result) {
|
|
78
|
+
if (i == ai) {
|
|
79
|
+
begs.push(i);
|
|
80
|
+
ai = str.indexOf(a, i + 1);
|
|
81
|
+
} else if (begs.length == 1) {
|
|
82
|
+
result = [begs.pop(), bi];
|
|
83
|
+
} else {
|
|
84
|
+
beg = begs.pop();
|
|
85
|
+
if (beg < left) {
|
|
86
|
+
left = beg;
|
|
87
|
+
right = bi;
|
|
88
|
+
}
|
|
89
|
+
bi = str.indexOf(b, i + 1);
|
|
90
|
+
}
|
|
91
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
92
|
+
}
|
|
93
|
+
if (begs.length) {
|
|
94
|
+
result = [left, right];
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// node_modules/brace-expansion/index.js
|
|
103
|
+
var require_brace_expansion = __commonJS({
|
|
104
|
+
"node_modules/brace-expansion/index.js"(exports, module) {
|
|
105
|
+
var balanced = require_balanced_match();
|
|
106
|
+
module.exports = expandTop;
|
|
107
|
+
var escSlash = "\0SLASH" + Math.random() + "\0";
|
|
108
|
+
var escOpen = "\0OPEN" + Math.random() + "\0";
|
|
109
|
+
var escClose = "\0CLOSE" + Math.random() + "\0";
|
|
110
|
+
var escComma = "\0COMMA" + Math.random() + "\0";
|
|
111
|
+
var escPeriod = "\0PERIOD" + Math.random() + "\0";
|
|
112
|
+
function numeric(str) {
|
|
113
|
+
return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
|
|
114
|
+
}
|
|
115
|
+
function escapeBraces(str) {
|
|
116
|
+
return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
|
|
117
|
+
}
|
|
118
|
+
function unescapeBraces(str) {
|
|
119
|
+
return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
|
|
120
|
+
}
|
|
121
|
+
function parseCommaParts(str) {
|
|
122
|
+
if (!str)
|
|
123
|
+
return [""];
|
|
124
|
+
var parts = [];
|
|
125
|
+
var m = balanced("{", "}", str);
|
|
126
|
+
if (!m)
|
|
127
|
+
return str.split(",");
|
|
128
|
+
var pre = m.pre;
|
|
129
|
+
var body = m.body;
|
|
130
|
+
var post = m.post;
|
|
131
|
+
var p = pre.split(",");
|
|
132
|
+
p[p.length - 1] += "{" + body + "}";
|
|
133
|
+
var postParts = parseCommaParts(post);
|
|
134
|
+
if (post.length) {
|
|
135
|
+
p[p.length - 1] += postParts.shift();
|
|
136
|
+
p.push.apply(p, postParts);
|
|
137
|
+
}
|
|
138
|
+
parts.push.apply(parts, p);
|
|
139
|
+
return parts;
|
|
140
|
+
}
|
|
141
|
+
function expandTop(str) {
|
|
142
|
+
if (!str)
|
|
143
|
+
return [];
|
|
144
|
+
if (str.substr(0, 2) === "{}") {
|
|
145
|
+
str = "\\{\\}" + str.substr(2);
|
|
146
|
+
}
|
|
147
|
+
return expand2(escapeBraces(str), true).map(unescapeBraces);
|
|
148
|
+
}
|
|
149
|
+
function embrace(str) {
|
|
150
|
+
return "{" + str + "}";
|
|
151
|
+
}
|
|
152
|
+
function isPadded(el) {
|
|
153
|
+
return /^-?0\d/.test(el);
|
|
154
|
+
}
|
|
155
|
+
function lte(i, y) {
|
|
156
|
+
return i <= y;
|
|
157
|
+
}
|
|
158
|
+
function gte(i, y) {
|
|
159
|
+
return i >= y;
|
|
160
|
+
}
|
|
161
|
+
function expand2(str, isTop) {
|
|
162
|
+
var expansions = [];
|
|
163
|
+
var m = balanced("{", "}", str);
|
|
164
|
+
if (!m) return [str];
|
|
165
|
+
var pre = m.pre;
|
|
166
|
+
var post = m.post.length ? expand2(m.post, false) : [""];
|
|
167
|
+
if (/\$$/.test(m.pre)) {
|
|
168
|
+
for (var k = 0; k < post.length; k++) {
|
|
169
|
+
var expansion = pre + "{" + m.body + "}" + post[k];
|
|
170
|
+
expansions.push(expansion);
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
174
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
175
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
176
|
+
var isOptions = m.body.indexOf(",") >= 0;
|
|
177
|
+
if (!isSequence && !isOptions) {
|
|
178
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
179
|
+
str = m.pre + "{" + m.body + escClose + m.post;
|
|
180
|
+
return expand2(str);
|
|
181
|
+
}
|
|
182
|
+
return [str];
|
|
183
|
+
}
|
|
184
|
+
var n;
|
|
185
|
+
if (isSequence) {
|
|
186
|
+
n = m.body.split(/\.\./);
|
|
187
|
+
} else {
|
|
188
|
+
n = parseCommaParts(m.body);
|
|
189
|
+
if (n.length === 1) {
|
|
190
|
+
n = expand2(n[0], false).map(embrace);
|
|
191
|
+
if (n.length === 1) {
|
|
192
|
+
return post.map(function(p) {
|
|
193
|
+
return m.pre + n[0] + p;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
var N;
|
|
199
|
+
if (isSequence) {
|
|
200
|
+
var x = numeric(n[0]);
|
|
201
|
+
var y = numeric(n[1]);
|
|
202
|
+
var width = Math.max(n[0].length, n[1].length);
|
|
203
|
+
var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1;
|
|
204
|
+
var test = lte;
|
|
205
|
+
var reverse = y < x;
|
|
206
|
+
if (reverse) {
|
|
207
|
+
incr *= -1;
|
|
208
|
+
test = gte;
|
|
209
|
+
}
|
|
210
|
+
var pad = n.some(isPadded);
|
|
211
|
+
N = [];
|
|
212
|
+
for (var i = x; test(i, y); i += incr) {
|
|
213
|
+
var c;
|
|
214
|
+
if (isAlphaSequence) {
|
|
215
|
+
c = String.fromCharCode(i);
|
|
216
|
+
if (c === "\\")
|
|
217
|
+
c = "";
|
|
218
|
+
} else {
|
|
219
|
+
c = String(i);
|
|
220
|
+
if (pad) {
|
|
221
|
+
var need = width - c.length;
|
|
222
|
+
if (need > 0) {
|
|
223
|
+
var z = new Array(need + 1).join("0");
|
|
224
|
+
if (i < 0)
|
|
225
|
+
c = "-" + z + c.slice(1);
|
|
226
|
+
else
|
|
227
|
+
c = z + c;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
N.push(c);
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
N = [];
|
|
235
|
+
for (var j = 0; j < n.length; j++) {
|
|
236
|
+
N.push.apply(N, expand2(n[j], false));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
for (var j = 0; j < N.length; j++) {
|
|
240
|
+
for (var k = 0; k < post.length; k++) {
|
|
241
|
+
var expansion = pre + N[j] + post[k];
|
|
242
|
+
if (!isTop || isSequence || expansion)
|
|
243
|
+
expansions.push(expansion);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return expansions;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
});
|
|
9
251
|
|
|
10
252
|
// src/client/client-build.ts
|
|
11
253
|
import { BUILD } from "@stencil/core/internal/app-data";
|
|
@@ -82,6 +324,9 @@ var H = win.HTMLElement || class {
|
|
|
82
324
|
var supportsShadow = BUILD6.shadowDom;
|
|
83
325
|
var supportsConstructableStylesheets = BUILD6.constructableCSS ? /* @__PURE__ */ (() => {
|
|
84
326
|
try {
|
|
327
|
+
if (!win.document.adoptedStyleSheets) {
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
85
330
|
new CSSStyleSheet();
|
|
86
331
|
return typeof new CSSStyleSheet().replaceSync === "function";
|
|
87
332
|
} catch (e) {
|
|
@@ -362,6 +607,1359 @@ var shouldIgnoreError = (msg) => {
|
|
|
362
607
|
};
|
|
363
608
|
var TASK_CANCELED_MSG = `task canceled`;
|
|
364
609
|
|
|
610
|
+
// node_modules/minimatch/dist/esm/index.js
|
|
611
|
+
var import_brace_expansion = __toESM(require_brace_expansion(), 1);
|
|
612
|
+
|
|
613
|
+
// node_modules/minimatch/dist/esm/assert-valid-pattern.js
|
|
614
|
+
var MAX_PATTERN_LENGTH = 1024 * 64;
|
|
615
|
+
var assertValidPattern = (pattern) => {
|
|
616
|
+
if (typeof pattern !== "string") {
|
|
617
|
+
throw new TypeError("invalid pattern");
|
|
618
|
+
}
|
|
619
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
620
|
+
throw new TypeError("pattern is too long");
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
// node_modules/minimatch/dist/esm/brace-expressions.js
|
|
625
|
+
var posixClasses = {
|
|
626
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
|
|
627
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", true],
|
|
628
|
+
"[:ascii:]": ["\\x00-\\x7f", false],
|
|
629
|
+
"[:blank:]": ["\\p{Zs}\\t", true],
|
|
630
|
+
"[:cntrl:]": ["\\p{Cc}", true],
|
|
631
|
+
"[:digit:]": ["\\p{Nd}", true],
|
|
632
|
+
"[:graph:]": ["\\p{Z}\\p{C}", true, true],
|
|
633
|
+
"[:lower:]": ["\\p{Ll}", true],
|
|
634
|
+
"[:print:]": ["\\p{C}", true],
|
|
635
|
+
"[:punct:]": ["\\p{P}", true],
|
|
636
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
|
|
637
|
+
"[:upper:]": ["\\p{Lu}", true],
|
|
638
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
|
|
639
|
+
"[:xdigit:]": ["A-Fa-f0-9", false]
|
|
640
|
+
};
|
|
641
|
+
var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
|
|
642
|
+
var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
643
|
+
var rangesToString = (ranges) => ranges.join("");
|
|
644
|
+
var parseClass = (glob, position) => {
|
|
645
|
+
const pos = position;
|
|
646
|
+
if (glob.charAt(pos) !== "[") {
|
|
647
|
+
throw new Error("not in a brace expression");
|
|
648
|
+
}
|
|
649
|
+
const ranges = [];
|
|
650
|
+
const negs = [];
|
|
651
|
+
let i = pos + 1;
|
|
652
|
+
let sawStart = false;
|
|
653
|
+
let uflag = false;
|
|
654
|
+
let escaping = false;
|
|
655
|
+
let negate = false;
|
|
656
|
+
let endPos = pos;
|
|
657
|
+
let rangeStart = "";
|
|
658
|
+
WHILE: while (i < glob.length) {
|
|
659
|
+
const c = glob.charAt(i);
|
|
660
|
+
if ((c === "!" || c === "^") && i === pos + 1) {
|
|
661
|
+
negate = true;
|
|
662
|
+
i++;
|
|
663
|
+
continue;
|
|
664
|
+
}
|
|
665
|
+
if (c === "]" && sawStart && !escaping) {
|
|
666
|
+
endPos = i + 1;
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
sawStart = true;
|
|
670
|
+
if (c === "\\") {
|
|
671
|
+
if (!escaping) {
|
|
672
|
+
escaping = true;
|
|
673
|
+
i++;
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
if (c === "[" && !escaping) {
|
|
678
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
679
|
+
if (glob.startsWith(cls, i)) {
|
|
680
|
+
if (rangeStart) {
|
|
681
|
+
return ["$.", false, glob.length - pos, true];
|
|
682
|
+
}
|
|
683
|
+
i += cls.length;
|
|
684
|
+
if (neg)
|
|
685
|
+
negs.push(unip);
|
|
686
|
+
else
|
|
687
|
+
ranges.push(unip);
|
|
688
|
+
uflag = uflag || u;
|
|
689
|
+
continue WHILE;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
escaping = false;
|
|
694
|
+
if (rangeStart) {
|
|
695
|
+
if (c > rangeStart) {
|
|
696
|
+
ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
|
|
697
|
+
} else if (c === rangeStart) {
|
|
698
|
+
ranges.push(braceEscape(c));
|
|
699
|
+
}
|
|
700
|
+
rangeStart = "";
|
|
701
|
+
i++;
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
if (glob.startsWith("-]", i + 1)) {
|
|
705
|
+
ranges.push(braceEscape(c + "-"));
|
|
706
|
+
i += 2;
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (glob.startsWith("-", i + 1)) {
|
|
710
|
+
rangeStart = c;
|
|
711
|
+
i += 2;
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
ranges.push(braceEscape(c));
|
|
715
|
+
i++;
|
|
716
|
+
}
|
|
717
|
+
if (endPos < i) {
|
|
718
|
+
return ["", false, 0, false];
|
|
719
|
+
}
|
|
720
|
+
if (!ranges.length && !negs.length) {
|
|
721
|
+
return ["$.", false, glob.length - pos, true];
|
|
722
|
+
}
|
|
723
|
+
if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
|
|
724
|
+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
725
|
+
return [regexpEscape(r), false, endPos - pos, false];
|
|
726
|
+
}
|
|
727
|
+
const sranges = "[" + (negate ? "^" : "") + rangesToString(ranges) + "]";
|
|
728
|
+
const snegs = "[" + (negate ? "" : "^") + rangesToString(negs) + "]";
|
|
729
|
+
const comb = ranges.length && negs.length ? "(" + sranges + "|" + snegs + ")" : ranges.length ? sranges : snegs;
|
|
730
|
+
return [comb, uflag, endPos - pos, true];
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// node_modules/minimatch/dist/esm/unescape.js
|
|
734
|
+
var unescape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
735
|
+
return windowsPathsNoEscape ? s.replace(/\[([^\/\\])\]/g, "$1") : s.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1");
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
// node_modules/minimatch/dist/esm/ast.js
|
|
739
|
+
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
|
|
740
|
+
var isExtglobType = (c) => types.has(c);
|
|
741
|
+
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
742
|
+
var startNoDot = "(?!\\.)";
|
|
743
|
+
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
|
|
744
|
+
var justDots = /* @__PURE__ */ new Set(["..", "."]);
|
|
745
|
+
var reSpecials = new Set("().*{}+?[]^$\\!");
|
|
746
|
+
var regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
747
|
+
var qmark = "[^/]";
|
|
748
|
+
var star = qmark + "*?";
|
|
749
|
+
var starNoEmpty = qmark + "+?";
|
|
750
|
+
var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _AST_instances, fillNegs_fn, _AST_static, parseAST_fn, partsToRegExp_fn, parseGlob_fn;
|
|
751
|
+
var _AST = class _AST {
|
|
752
|
+
constructor(type, parent, options = {}) {
|
|
753
|
+
__privateAdd(this, _AST_instances);
|
|
754
|
+
__publicField(this, "type");
|
|
755
|
+
__privateAdd(this, _root);
|
|
756
|
+
__privateAdd(this, _hasMagic);
|
|
757
|
+
__privateAdd(this, _uflag, false);
|
|
758
|
+
__privateAdd(this, _parts, []);
|
|
759
|
+
__privateAdd(this, _parent);
|
|
760
|
+
__privateAdd(this, _parentIndex);
|
|
761
|
+
__privateAdd(this, _negs);
|
|
762
|
+
__privateAdd(this, _filledNegs, false);
|
|
763
|
+
__privateAdd(this, _options);
|
|
764
|
+
__privateAdd(this, _toString);
|
|
765
|
+
// set to true if it's an extglob with no children
|
|
766
|
+
// (which really means one child of '')
|
|
767
|
+
__privateAdd(this, _emptyExt, false);
|
|
768
|
+
this.type = type;
|
|
769
|
+
if (type)
|
|
770
|
+
__privateSet(this, _hasMagic, true);
|
|
771
|
+
__privateSet(this, _parent, parent);
|
|
772
|
+
__privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this);
|
|
773
|
+
__privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options));
|
|
774
|
+
__privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs));
|
|
775
|
+
if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
|
|
776
|
+
__privateGet(this, _negs).push(this);
|
|
777
|
+
__privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0);
|
|
778
|
+
}
|
|
779
|
+
get hasMagic() {
|
|
780
|
+
if (__privateGet(this, _hasMagic) !== void 0)
|
|
781
|
+
return __privateGet(this, _hasMagic);
|
|
782
|
+
for (const p of __privateGet(this, _parts)) {
|
|
783
|
+
if (typeof p === "string")
|
|
784
|
+
continue;
|
|
785
|
+
if (p.type || p.hasMagic)
|
|
786
|
+
return __privateSet(this, _hasMagic, true);
|
|
787
|
+
}
|
|
788
|
+
return __privateGet(this, _hasMagic);
|
|
789
|
+
}
|
|
790
|
+
// reconstructs the pattern
|
|
791
|
+
toString() {
|
|
792
|
+
if (__privateGet(this, _toString) !== void 0)
|
|
793
|
+
return __privateGet(this, _toString);
|
|
794
|
+
if (!this.type) {
|
|
795
|
+
return __privateSet(this, _toString, __privateGet(this, _parts).map((p) => String(p)).join(""));
|
|
796
|
+
} else {
|
|
797
|
+
return __privateSet(this, _toString, this.type + "(" + __privateGet(this, _parts).map((p) => String(p)).join("|") + ")");
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
push(...parts) {
|
|
801
|
+
for (const p of parts) {
|
|
802
|
+
if (p === "")
|
|
803
|
+
continue;
|
|
804
|
+
if (typeof p !== "string" && !(p instanceof _AST && __privateGet(p, _parent) === this)) {
|
|
805
|
+
throw new Error("invalid part: " + p);
|
|
806
|
+
}
|
|
807
|
+
__privateGet(this, _parts).push(p);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
toJSON() {
|
|
811
|
+
var _a2;
|
|
812
|
+
const ret = this.type === null ? __privateGet(this, _parts).slice().map((p) => typeof p === "string" ? p : p.toJSON()) : [this.type, ...__privateGet(this, _parts).map((p) => p.toJSON())];
|
|
813
|
+
if (this.isStart() && !this.type)
|
|
814
|
+
ret.unshift([]);
|
|
815
|
+
if (this.isEnd() && (this === __privateGet(this, _root) || __privateGet(__privateGet(this, _root), _filledNegs) && ((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!")) {
|
|
816
|
+
ret.push({});
|
|
817
|
+
}
|
|
818
|
+
return ret;
|
|
819
|
+
}
|
|
820
|
+
isStart() {
|
|
821
|
+
var _a2;
|
|
822
|
+
if (__privateGet(this, _root) === this)
|
|
823
|
+
return true;
|
|
824
|
+
if (!((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.isStart()))
|
|
825
|
+
return false;
|
|
826
|
+
if (__privateGet(this, _parentIndex) === 0)
|
|
827
|
+
return true;
|
|
828
|
+
const p = __privateGet(this, _parent);
|
|
829
|
+
for (let i = 0; i < __privateGet(this, _parentIndex); i++) {
|
|
830
|
+
const pp = __privateGet(p, _parts)[i];
|
|
831
|
+
if (!(pp instanceof _AST && pp.type === "!")) {
|
|
832
|
+
return false;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return true;
|
|
836
|
+
}
|
|
837
|
+
isEnd() {
|
|
838
|
+
var _a2, _b, _c;
|
|
839
|
+
if (__privateGet(this, _root) === this)
|
|
840
|
+
return true;
|
|
841
|
+
if (((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!")
|
|
842
|
+
return true;
|
|
843
|
+
if (!((_b = __privateGet(this, _parent)) == null ? void 0 : _b.isEnd()))
|
|
844
|
+
return false;
|
|
845
|
+
if (!this.type)
|
|
846
|
+
return (_c = __privateGet(this, _parent)) == null ? void 0 : _c.isEnd();
|
|
847
|
+
const pl = __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0;
|
|
848
|
+
return __privateGet(this, _parentIndex) === pl - 1;
|
|
849
|
+
}
|
|
850
|
+
copyIn(part) {
|
|
851
|
+
if (typeof part === "string")
|
|
852
|
+
this.push(part);
|
|
853
|
+
else
|
|
854
|
+
this.push(part.clone(this));
|
|
855
|
+
}
|
|
856
|
+
clone(parent) {
|
|
857
|
+
const c = new _AST(this.type, parent);
|
|
858
|
+
for (const p of __privateGet(this, _parts)) {
|
|
859
|
+
c.copyIn(p);
|
|
860
|
+
}
|
|
861
|
+
return c;
|
|
862
|
+
}
|
|
863
|
+
static fromGlob(pattern, options = {}) {
|
|
864
|
+
var _a2;
|
|
865
|
+
const ast = new _AST(null, void 0, options);
|
|
866
|
+
__privateMethod(_a2 = _AST, _AST_static, parseAST_fn).call(_a2, pattern, ast, 0, options);
|
|
867
|
+
return ast;
|
|
868
|
+
}
|
|
869
|
+
// returns the regular expression if there's magic, or the unescaped
|
|
870
|
+
// string if not.
|
|
871
|
+
toMMPattern() {
|
|
872
|
+
if (this !== __privateGet(this, _root))
|
|
873
|
+
return __privateGet(this, _root).toMMPattern();
|
|
874
|
+
const glob = this.toString();
|
|
875
|
+
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
876
|
+
const anyMagic = hasMagic || __privateGet(this, _hasMagic) || __privateGet(this, _options).nocase && !__privateGet(this, _options).nocaseMagicOnly && glob.toUpperCase() !== glob.toLowerCase();
|
|
877
|
+
if (!anyMagic) {
|
|
878
|
+
return body;
|
|
879
|
+
}
|
|
880
|
+
const flags = (__privateGet(this, _options).nocase ? "i" : "") + (uflag ? "u" : "");
|
|
881
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
882
|
+
_src: re,
|
|
883
|
+
_glob: glob
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
get options() {
|
|
887
|
+
return __privateGet(this, _options);
|
|
888
|
+
}
|
|
889
|
+
// returns the string match, the regexp source, whether there's magic
|
|
890
|
+
// in the regexp (so a regular expression is required) and whether or
|
|
891
|
+
// not the uflag is needed for the regular expression (for posix classes)
|
|
892
|
+
// TODO: instead of injecting the start/end at this point, just return
|
|
893
|
+
// the BODY of the regexp, along with the start/end portions suitable
|
|
894
|
+
// for binding the start/end in either a joined full-path makeRe context
|
|
895
|
+
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
896
|
+
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
897
|
+
//
|
|
898
|
+
// In part-matching mode, the start is:
|
|
899
|
+
// - if not isStart: nothing
|
|
900
|
+
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
901
|
+
// - if dots allowed or not possible: ^
|
|
902
|
+
// - if dots possible and not allowed: ^(?!\.)
|
|
903
|
+
// end is:
|
|
904
|
+
// - if not isEnd(): nothing
|
|
905
|
+
// - else: $
|
|
906
|
+
//
|
|
907
|
+
// In full-path matching mode, we put the slash at the START of the
|
|
908
|
+
// pattern, so start is:
|
|
909
|
+
// - if first pattern: same as part-matching mode
|
|
910
|
+
// - if not isStart(): nothing
|
|
911
|
+
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
912
|
+
// - if dots allowed or not possible: /
|
|
913
|
+
// - if dots possible and not allowed: /(?!\.)
|
|
914
|
+
// end is:
|
|
915
|
+
// - if last pattern, same as part-matching mode
|
|
916
|
+
// - else nothing
|
|
917
|
+
//
|
|
918
|
+
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
919
|
+
// there to bind the end of the negated pattern portion, and it's easier to
|
|
920
|
+
// just stick it in now rather than try to inject it later in the middle of
|
|
921
|
+
// the pattern.
|
|
922
|
+
//
|
|
923
|
+
// We can just always return the same end, and leave it up to the caller
|
|
924
|
+
// to know whether it's going to be used joined or in parts.
|
|
925
|
+
// And, if the start is adjusted slightly, can do the same there:
|
|
926
|
+
// - if not isStart: nothing
|
|
927
|
+
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
928
|
+
// - if dots allowed or not possible: (?:/|^)
|
|
929
|
+
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
930
|
+
//
|
|
931
|
+
// But it's better to have a simpler binding without a conditional, for
|
|
932
|
+
// performance, so probably better to return both start options.
|
|
933
|
+
//
|
|
934
|
+
// Then the caller just ignores the end if it's not the first pattern,
|
|
935
|
+
// and the start always gets applied.
|
|
936
|
+
//
|
|
937
|
+
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
938
|
+
// so the caller can just attach $ at the end of the pattern when building.
|
|
939
|
+
//
|
|
940
|
+
// So the todo is:
|
|
941
|
+
// - better detect what kind of start is needed
|
|
942
|
+
// - return both flavors of starting pattern
|
|
943
|
+
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
944
|
+
//
|
|
945
|
+
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
946
|
+
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
947
|
+
// that dot prevention biz to live in the extglob portions, because eg
|
|
948
|
+
// +(*|.x*) can match .xy but not .yx.
|
|
949
|
+
//
|
|
950
|
+
// So, return the two flavors if it's #root and the first child is not an
|
|
951
|
+
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
952
|
+
// use the (?:^|/) style of start binding.
|
|
953
|
+
//
|
|
954
|
+
// Even simplified further:
|
|
955
|
+
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
956
|
+
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
957
|
+
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
958
|
+
toRegExpSource(allowDot) {
|
|
959
|
+
var _a2;
|
|
960
|
+
const dot = allowDot != null ? allowDot : !!__privateGet(this, _options).dot;
|
|
961
|
+
if (__privateGet(this, _root) === this)
|
|
962
|
+
__privateMethod(this, _AST_instances, fillNegs_fn).call(this);
|
|
963
|
+
if (!this.type) {
|
|
964
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
965
|
+
const src = __privateGet(this, _parts).map((p) => {
|
|
966
|
+
var _a3;
|
|
967
|
+
const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a3 = _AST, _AST_static, parseGlob_fn).call(_a3, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
|
|
968
|
+
__privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
|
|
969
|
+
__privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
|
|
970
|
+
return re;
|
|
971
|
+
}).join("");
|
|
972
|
+
let start2 = "";
|
|
973
|
+
if (this.isStart()) {
|
|
974
|
+
if (typeof __privateGet(this, _parts)[0] === "string") {
|
|
975
|
+
const dotTravAllowed = __privateGet(this, _parts).length === 1 && justDots.has(__privateGet(this, _parts)[0]);
|
|
976
|
+
if (!dotTravAllowed) {
|
|
977
|
+
const aps = addPatternStart;
|
|
978
|
+
const needNoTrav = (
|
|
979
|
+
// dots are allowed, and the pattern starts with [ or .
|
|
980
|
+
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
|
|
981
|
+
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
|
|
982
|
+
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
|
|
983
|
+
);
|
|
984
|
+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
985
|
+
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
let end = "";
|
|
990
|
+
if (this.isEnd() && __privateGet(__privateGet(this, _root), _filledNegs) && ((_a2 = __privateGet(this, _parent)) == null ? void 0 : _a2.type) === "!") {
|
|
991
|
+
end = "(?:$|\\/)";
|
|
992
|
+
}
|
|
993
|
+
const final2 = start2 + src + end;
|
|
994
|
+
return [
|
|
995
|
+
final2,
|
|
996
|
+
unescape(src),
|
|
997
|
+
__privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
|
|
998
|
+
__privateGet(this, _uflag)
|
|
999
|
+
];
|
|
1000
|
+
}
|
|
1001
|
+
const repeated = this.type === "*" || this.type === "+";
|
|
1002
|
+
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
|
|
1003
|
+
let body = __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, dot);
|
|
1004
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
|
|
1005
|
+
const s = this.toString();
|
|
1006
|
+
__privateSet(this, _parts, [s]);
|
|
1007
|
+
this.type = null;
|
|
1008
|
+
__privateSet(this, _hasMagic, void 0);
|
|
1009
|
+
return [s, unescape(this.toString()), false, false];
|
|
1010
|
+
}
|
|
1011
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _AST_instances, partsToRegExp_fn).call(this, true);
|
|
1012
|
+
if (bodyDotAllowed === body) {
|
|
1013
|
+
bodyDotAllowed = "";
|
|
1014
|
+
}
|
|
1015
|
+
if (bodyDotAllowed) {
|
|
1016
|
+
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
1017
|
+
}
|
|
1018
|
+
let final = "";
|
|
1019
|
+
if (this.type === "!" && __privateGet(this, _emptyExt)) {
|
|
1020
|
+
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
|
|
1021
|
+
} else {
|
|
1022
|
+
const close = this.type === "!" ? (
|
|
1023
|
+
// !() must match something,but !(x) can match ''
|
|
1024
|
+
"))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star + ")"
|
|
1025
|
+
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
|
|
1026
|
+
final = start + body + close;
|
|
1027
|
+
}
|
|
1028
|
+
return [
|
|
1029
|
+
final,
|
|
1030
|
+
unescape(body),
|
|
1031
|
+
__privateSet(this, _hasMagic, !!__privateGet(this, _hasMagic)),
|
|
1032
|
+
__privateGet(this, _uflag)
|
|
1033
|
+
];
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
_root = new WeakMap();
|
|
1037
|
+
_hasMagic = new WeakMap();
|
|
1038
|
+
_uflag = new WeakMap();
|
|
1039
|
+
_parts = new WeakMap();
|
|
1040
|
+
_parent = new WeakMap();
|
|
1041
|
+
_parentIndex = new WeakMap();
|
|
1042
|
+
_negs = new WeakMap();
|
|
1043
|
+
_filledNegs = new WeakMap();
|
|
1044
|
+
_options = new WeakMap();
|
|
1045
|
+
_toString = new WeakMap();
|
|
1046
|
+
_emptyExt = new WeakMap();
|
|
1047
|
+
_AST_instances = new WeakSet();
|
|
1048
|
+
fillNegs_fn = function() {
|
|
1049
|
+
if (this !== __privateGet(this, _root))
|
|
1050
|
+
throw new Error("should only call on root");
|
|
1051
|
+
if (__privateGet(this, _filledNegs))
|
|
1052
|
+
return this;
|
|
1053
|
+
this.toString();
|
|
1054
|
+
__privateSet(this, _filledNegs, true);
|
|
1055
|
+
let n;
|
|
1056
|
+
while (n = __privateGet(this, _negs).pop()) {
|
|
1057
|
+
if (n.type !== "!")
|
|
1058
|
+
continue;
|
|
1059
|
+
let p = n;
|
|
1060
|
+
let pp = __privateGet(p, _parent);
|
|
1061
|
+
while (pp) {
|
|
1062
|
+
for (let i = __privateGet(p, _parentIndex) + 1; !pp.type && i < __privateGet(pp, _parts).length; i++) {
|
|
1063
|
+
for (const part of __privateGet(n, _parts)) {
|
|
1064
|
+
if (typeof part === "string") {
|
|
1065
|
+
throw new Error("string part in extglob AST??");
|
|
1066
|
+
}
|
|
1067
|
+
part.copyIn(__privateGet(pp, _parts)[i]);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
p = pp;
|
|
1071
|
+
pp = __privateGet(p, _parent);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return this;
|
|
1075
|
+
};
|
|
1076
|
+
_AST_static = new WeakSet();
|
|
1077
|
+
parseAST_fn = function(str, ast, pos, opt) {
|
|
1078
|
+
var _a2, _b;
|
|
1079
|
+
let escaping = false;
|
|
1080
|
+
let inBrace = false;
|
|
1081
|
+
let braceStart = -1;
|
|
1082
|
+
let braceNeg = false;
|
|
1083
|
+
if (ast.type === null) {
|
|
1084
|
+
let i2 = pos;
|
|
1085
|
+
let acc2 = "";
|
|
1086
|
+
while (i2 < str.length) {
|
|
1087
|
+
const c = str.charAt(i2++);
|
|
1088
|
+
if (escaping || c === "\\") {
|
|
1089
|
+
escaping = !escaping;
|
|
1090
|
+
acc2 += c;
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (inBrace) {
|
|
1094
|
+
if (i2 === braceStart + 1) {
|
|
1095
|
+
if (c === "^" || c === "!") {
|
|
1096
|
+
braceNeg = true;
|
|
1097
|
+
}
|
|
1098
|
+
} else if (c === "]" && !(i2 === braceStart + 2 && braceNeg)) {
|
|
1099
|
+
inBrace = false;
|
|
1100
|
+
}
|
|
1101
|
+
acc2 += c;
|
|
1102
|
+
continue;
|
|
1103
|
+
} else if (c === "[") {
|
|
1104
|
+
inBrace = true;
|
|
1105
|
+
braceStart = i2;
|
|
1106
|
+
braceNeg = false;
|
|
1107
|
+
acc2 += c;
|
|
1108
|
+
continue;
|
|
1109
|
+
}
|
|
1110
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
|
|
1111
|
+
ast.push(acc2);
|
|
1112
|
+
acc2 = "";
|
|
1113
|
+
const ext2 = new _AST(c, ast);
|
|
1114
|
+
i2 = __privateMethod(_a2 = _AST, _AST_static, parseAST_fn).call(_a2, str, ext2, i2, opt);
|
|
1115
|
+
ast.push(ext2);
|
|
1116
|
+
continue;
|
|
1117
|
+
}
|
|
1118
|
+
acc2 += c;
|
|
1119
|
+
}
|
|
1120
|
+
ast.push(acc2);
|
|
1121
|
+
return i2;
|
|
1122
|
+
}
|
|
1123
|
+
let i = pos + 1;
|
|
1124
|
+
let part = new _AST(null, ast);
|
|
1125
|
+
const parts = [];
|
|
1126
|
+
let acc = "";
|
|
1127
|
+
while (i < str.length) {
|
|
1128
|
+
const c = str.charAt(i++);
|
|
1129
|
+
if (escaping || c === "\\") {
|
|
1130
|
+
escaping = !escaping;
|
|
1131
|
+
acc += c;
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
if (inBrace) {
|
|
1135
|
+
if (i === braceStart + 1) {
|
|
1136
|
+
if (c === "^" || c === "!") {
|
|
1137
|
+
braceNeg = true;
|
|
1138
|
+
}
|
|
1139
|
+
} else if (c === "]" && !(i === braceStart + 2 && braceNeg)) {
|
|
1140
|
+
inBrace = false;
|
|
1141
|
+
}
|
|
1142
|
+
acc += c;
|
|
1143
|
+
continue;
|
|
1144
|
+
} else if (c === "[") {
|
|
1145
|
+
inBrace = true;
|
|
1146
|
+
braceStart = i;
|
|
1147
|
+
braceNeg = false;
|
|
1148
|
+
acc += c;
|
|
1149
|
+
continue;
|
|
1150
|
+
}
|
|
1151
|
+
if (isExtglobType(c) && str.charAt(i) === "(") {
|
|
1152
|
+
part.push(acc);
|
|
1153
|
+
acc = "";
|
|
1154
|
+
const ext2 = new _AST(c, part);
|
|
1155
|
+
part.push(ext2);
|
|
1156
|
+
i = __privateMethod(_b = _AST, _AST_static, parseAST_fn).call(_b, str, ext2, i, opt);
|
|
1157
|
+
continue;
|
|
1158
|
+
}
|
|
1159
|
+
if (c === "|") {
|
|
1160
|
+
part.push(acc);
|
|
1161
|
+
acc = "";
|
|
1162
|
+
parts.push(part);
|
|
1163
|
+
part = new _AST(null, ast);
|
|
1164
|
+
continue;
|
|
1165
|
+
}
|
|
1166
|
+
if (c === ")") {
|
|
1167
|
+
if (acc === "" && __privateGet(ast, _parts).length === 0) {
|
|
1168
|
+
__privateSet(ast, _emptyExt, true);
|
|
1169
|
+
}
|
|
1170
|
+
part.push(acc);
|
|
1171
|
+
acc = "";
|
|
1172
|
+
ast.push(...parts, part);
|
|
1173
|
+
return i;
|
|
1174
|
+
}
|
|
1175
|
+
acc += c;
|
|
1176
|
+
}
|
|
1177
|
+
ast.type = null;
|
|
1178
|
+
__privateSet(ast, _hasMagic, void 0);
|
|
1179
|
+
__privateSet(ast, _parts, [str.substring(pos - 1)]);
|
|
1180
|
+
return i;
|
|
1181
|
+
};
|
|
1182
|
+
partsToRegExp_fn = function(dot) {
|
|
1183
|
+
return __privateGet(this, _parts).map((p) => {
|
|
1184
|
+
if (typeof p === "string") {
|
|
1185
|
+
throw new Error("string type in extglob ast??");
|
|
1186
|
+
}
|
|
1187
|
+
const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
|
|
1188
|
+
__privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
|
|
1189
|
+
return re;
|
|
1190
|
+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
|
|
1191
|
+
};
|
|
1192
|
+
parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
|
|
1193
|
+
let escaping = false;
|
|
1194
|
+
let re = "";
|
|
1195
|
+
let uflag = false;
|
|
1196
|
+
for (let i = 0; i < glob.length; i++) {
|
|
1197
|
+
const c = glob.charAt(i);
|
|
1198
|
+
if (escaping) {
|
|
1199
|
+
escaping = false;
|
|
1200
|
+
re += (reSpecials.has(c) ? "\\" : "") + c;
|
|
1201
|
+
continue;
|
|
1202
|
+
}
|
|
1203
|
+
if (c === "\\") {
|
|
1204
|
+
if (i === glob.length - 1) {
|
|
1205
|
+
re += "\\\\";
|
|
1206
|
+
} else {
|
|
1207
|
+
escaping = true;
|
|
1208
|
+
}
|
|
1209
|
+
continue;
|
|
1210
|
+
}
|
|
1211
|
+
if (c === "[") {
|
|
1212
|
+
const [src, needUflag, consumed, magic] = parseClass(glob, i);
|
|
1213
|
+
if (consumed) {
|
|
1214
|
+
re += src;
|
|
1215
|
+
uflag = uflag || needUflag;
|
|
1216
|
+
i += consumed - 1;
|
|
1217
|
+
hasMagic = hasMagic || magic;
|
|
1218
|
+
continue;
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
if (c === "*") {
|
|
1222
|
+
if (noEmpty && glob === "*")
|
|
1223
|
+
re += starNoEmpty;
|
|
1224
|
+
else
|
|
1225
|
+
re += star;
|
|
1226
|
+
hasMagic = true;
|
|
1227
|
+
continue;
|
|
1228
|
+
}
|
|
1229
|
+
if (c === "?") {
|
|
1230
|
+
re += qmark;
|
|
1231
|
+
hasMagic = true;
|
|
1232
|
+
continue;
|
|
1233
|
+
}
|
|
1234
|
+
re += regExpEscape(c);
|
|
1235
|
+
}
|
|
1236
|
+
return [re, unescape(glob), !!hasMagic, uflag];
|
|
1237
|
+
};
|
|
1238
|
+
__privateAdd(_AST, _AST_static);
|
|
1239
|
+
var AST = _AST;
|
|
1240
|
+
|
|
1241
|
+
// node_modules/minimatch/dist/esm/escape.js
|
|
1242
|
+
var escape = (s, { windowsPathsNoEscape = false } = {}) => {
|
|
1243
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, "[$&]") : s.replace(/[?*()[\]\\]/g, "\\$&");
|
|
1244
|
+
};
|
|
1245
|
+
|
|
1246
|
+
// node_modules/minimatch/dist/esm/index.js
|
|
1247
|
+
var minimatch = (p, pattern, options = {}) => {
|
|
1248
|
+
assertValidPattern(pattern);
|
|
1249
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
1250
|
+
return false;
|
|
1251
|
+
}
|
|
1252
|
+
return new Minimatch(pattern, options).match(p);
|
|
1253
|
+
};
|
|
1254
|
+
var starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
1255
|
+
var starDotExtTest = (ext2) => (f) => !f.startsWith(".") && f.endsWith(ext2);
|
|
1256
|
+
var starDotExtTestDot = (ext2) => (f) => f.endsWith(ext2);
|
|
1257
|
+
var starDotExtTestNocase = (ext2) => {
|
|
1258
|
+
ext2 = ext2.toLowerCase();
|
|
1259
|
+
return (f) => !f.startsWith(".") && f.toLowerCase().endsWith(ext2);
|
|
1260
|
+
};
|
|
1261
|
+
var starDotExtTestNocaseDot = (ext2) => {
|
|
1262
|
+
ext2 = ext2.toLowerCase();
|
|
1263
|
+
return (f) => f.toLowerCase().endsWith(ext2);
|
|
1264
|
+
};
|
|
1265
|
+
var starDotStarRE = /^\*+\.\*+$/;
|
|
1266
|
+
var starDotStarTest = (f) => !f.startsWith(".") && f.includes(".");
|
|
1267
|
+
var starDotStarTestDot = (f) => f !== "." && f !== ".." && f.includes(".");
|
|
1268
|
+
var dotStarRE = /^\.\*+$/;
|
|
1269
|
+
var dotStarTest = (f) => f !== "." && f !== ".." && f.startsWith(".");
|
|
1270
|
+
var starRE = /^\*+$/;
|
|
1271
|
+
var starTest = (f) => f.length !== 0 && !f.startsWith(".");
|
|
1272
|
+
var starTestDot = (f) => f.length !== 0 && f !== "." && f !== "..";
|
|
1273
|
+
var qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
1274
|
+
var qmarksTestNocase = ([$0, ext2 = ""]) => {
|
|
1275
|
+
const noext = qmarksTestNoExt([$0]);
|
|
1276
|
+
if (!ext2)
|
|
1277
|
+
return noext;
|
|
1278
|
+
ext2 = ext2.toLowerCase();
|
|
1279
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
1280
|
+
};
|
|
1281
|
+
var qmarksTestNocaseDot = ([$0, ext2 = ""]) => {
|
|
1282
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
1283
|
+
if (!ext2)
|
|
1284
|
+
return noext;
|
|
1285
|
+
ext2 = ext2.toLowerCase();
|
|
1286
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext2);
|
|
1287
|
+
};
|
|
1288
|
+
var qmarksTestDot = ([$0, ext2 = ""]) => {
|
|
1289
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
1290
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
1291
|
+
};
|
|
1292
|
+
var qmarksTest = ([$0, ext2 = ""]) => {
|
|
1293
|
+
const noext = qmarksTestNoExt([$0]);
|
|
1294
|
+
return !ext2 ? noext : (f) => noext(f) && f.endsWith(ext2);
|
|
1295
|
+
};
|
|
1296
|
+
var qmarksTestNoExt = ([$0]) => {
|
|
1297
|
+
const len = $0.length;
|
|
1298
|
+
return (f) => f.length === len && !f.startsWith(".");
|
|
1299
|
+
};
|
|
1300
|
+
var qmarksTestNoExtDot = ([$0]) => {
|
|
1301
|
+
const len = $0.length;
|
|
1302
|
+
return (f) => f.length === len && f !== "." && f !== "..";
|
|
1303
|
+
};
|
|
1304
|
+
var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
1305
|
+
var path = {
|
|
1306
|
+
win32: { sep: "\\" },
|
|
1307
|
+
posix: { sep: "/" }
|
|
1308
|
+
};
|
|
1309
|
+
var sep = defaultPlatform === "win32" ? path.win32.sep : path.posix.sep;
|
|
1310
|
+
minimatch.sep = sep;
|
|
1311
|
+
var GLOBSTAR = Symbol("globstar **");
|
|
1312
|
+
minimatch.GLOBSTAR = GLOBSTAR;
|
|
1313
|
+
var qmark2 = "[^/]";
|
|
1314
|
+
var star2 = qmark2 + "*?";
|
|
1315
|
+
var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
1316
|
+
var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
1317
|
+
var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
|
|
1318
|
+
minimatch.filter = filter;
|
|
1319
|
+
var ext = (a, b = {}) => Object.assign({}, a, b);
|
|
1320
|
+
var defaults = (def) => {
|
|
1321
|
+
if (!def || typeof def !== "object" || !Object.keys(def).length) {
|
|
1322
|
+
return minimatch;
|
|
1323
|
+
}
|
|
1324
|
+
const orig = minimatch;
|
|
1325
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
1326
|
+
return Object.assign(m, {
|
|
1327
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
1328
|
+
constructor(pattern, options = {}) {
|
|
1329
|
+
super(pattern, ext(def, options));
|
|
1330
|
+
}
|
|
1331
|
+
static defaults(options) {
|
|
1332
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
1333
|
+
}
|
|
1334
|
+
},
|
|
1335
|
+
AST: class AST extends orig.AST {
|
|
1336
|
+
/* c8 ignore start */
|
|
1337
|
+
constructor(type, parent, options = {}) {
|
|
1338
|
+
super(type, parent, ext(def, options));
|
|
1339
|
+
}
|
|
1340
|
+
/* c8 ignore stop */
|
|
1341
|
+
static fromGlob(pattern, options = {}) {
|
|
1342
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
1346
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
1347
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
1348
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
1349
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
1350
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
1351
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
1352
|
+
sep: orig.sep,
|
|
1353
|
+
GLOBSTAR
|
|
1354
|
+
});
|
|
1355
|
+
};
|
|
1356
|
+
minimatch.defaults = defaults;
|
|
1357
|
+
var braceExpand = (pattern, options = {}) => {
|
|
1358
|
+
assertValidPattern(pattern);
|
|
1359
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
1360
|
+
return [pattern];
|
|
1361
|
+
}
|
|
1362
|
+
return (0, import_brace_expansion.default)(pattern);
|
|
1363
|
+
};
|
|
1364
|
+
minimatch.braceExpand = braceExpand;
|
|
1365
|
+
var makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
1366
|
+
minimatch.makeRe = makeRe;
|
|
1367
|
+
var match = (list, pattern, options = {}) => {
|
|
1368
|
+
const mm = new Minimatch(pattern, options);
|
|
1369
|
+
list = list.filter((f) => mm.match(f));
|
|
1370
|
+
if (mm.options.nonull && !list.length) {
|
|
1371
|
+
list.push(pattern);
|
|
1372
|
+
}
|
|
1373
|
+
return list;
|
|
1374
|
+
};
|
|
1375
|
+
minimatch.match = match;
|
|
1376
|
+
var globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
1377
|
+
var regExpEscape2 = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
1378
|
+
var Minimatch = class {
|
|
1379
|
+
options;
|
|
1380
|
+
set;
|
|
1381
|
+
pattern;
|
|
1382
|
+
windowsPathsNoEscape;
|
|
1383
|
+
nonegate;
|
|
1384
|
+
negate;
|
|
1385
|
+
comment;
|
|
1386
|
+
empty;
|
|
1387
|
+
preserveMultipleSlashes;
|
|
1388
|
+
partial;
|
|
1389
|
+
globSet;
|
|
1390
|
+
globParts;
|
|
1391
|
+
nocase;
|
|
1392
|
+
isWindows;
|
|
1393
|
+
platform;
|
|
1394
|
+
windowsNoMagicRoot;
|
|
1395
|
+
regexp;
|
|
1396
|
+
constructor(pattern, options = {}) {
|
|
1397
|
+
assertValidPattern(pattern);
|
|
1398
|
+
options = options || {};
|
|
1399
|
+
this.options = options;
|
|
1400
|
+
this.pattern = pattern;
|
|
1401
|
+
this.platform = options.platform || defaultPlatform;
|
|
1402
|
+
this.isWindows = this.platform === "win32";
|
|
1403
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
1404
|
+
if (this.windowsPathsNoEscape) {
|
|
1405
|
+
this.pattern = this.pattern.replace(/\\/g, "/");
|
|
1406
|
+
}
|
|
1407
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
1408
|
+
this.regexp = null;
|
|
1409
|
+
this.negate = false;
|
|
1410
|
+
this.nonegate = !!options.nonegate;
|
|
1411
|
+
this.comment = false;
|
|
1412
|
+
this.empty = false;
|
|
1413
|
+
this.partial = !!options.partial;
|
|
1414
|
+
this.nocase = !!this.options.nocase;
|
|
1415
|
+
this.windowsNoMagicRoot = options.windowsNoMagicRoot !== void 0 ? options.windowsNoMagicRoot : !!(this.isWindows && this.nocase);
|
|
1416
|
+
this.globSet = [];
|
|
1417
|
+
this.globParts = [];
|
|
1418
|
+
this.set = [];
|
|
1419
|
+
this.make();
|
|
1420
|
+
}
|
|
1421
|
+
hasMagic() {
|
|
1422
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
1423
|
+
return true;
|
|
1424
|
+
}
|
|
1425
|
+
for (const pattern of this.set) {
|
|
1426
|
+
for (const part of pattern) {
|
|
1427
|
+
if (typeof part !== "string")
|
|
1428
|
+
return true;
|
|
1429
|
+
}
|
|
1430
|
+
}
|
|
1431
|
+
return false;
|
|
1432
|
+
}
|
|
1433
|
+
debug(..._) {
|
|
1434
|
+
}
|
|
1435
|
+
make() {
|
|
1436
|
+
const pattern = this.pattern;
|
|
1437
|
+
const options = this.options;
|
|
1438
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
1439
|
+
this.comment = true;
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
if (!pattern) {
|
|
1443
|
+
this.empty = true;
|
|
1444
|
+
return;
|
|
1445
|
+
}
|
|
1446
|
+
this.parseNegate();
|
|
1447
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
1448
|
+
if (options.debug) {
|
|
1449
|
+
this.debug = (...args) => console.error(...args);
|
|
1450
|
+
}
|
|
1451
|
+
this.debug(this.pattern, this.globSet);
|
|
1452
|
+
const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
|
|
1453
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
1454
|
+
this.debug(this.pattern, this.globParts);
|
|
1455
|
+
let set = this.globParts.map((s, _, __) => {
|
|
1456
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
1457
|
+
const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
|
|
1458
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
1459
|
+
if (isUNC) {
|
|
1460
|
+
return [...s.slice(0, 4), ...s.slice(4).map((ss) => this.parse(ss))];
|
|
1461
|
+
} else if (isDrive) {
|
|
1462
|
+
return [s[0], ...s.slice(1).map((ss) => this.parse(ss))];
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
return s.map((ss) => this.parse(ss));
|
|
1466
|
+
});
|
|
1467
|
+
this.debug(this.pattern, set);
|
|
1468
|
+
this.set = set.filter((s) => s.indexOf(false) === -1);
|
|
1469
|
+
if (this.isWindows) {
|
|
1470
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
1471
|
+
const p = this.set[i];
|
|
1472
|
+
if (p[0] === "" && p[1] === "" && this.globParts[i][2] === "?" && typeof p[3] === "string" && /^[a-z]:$/i.test(p[3])) {
|
|
1473
|
+
p[2] = "?";
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
this.debug(this.pattern, this.set);
|
|
1478
|
+
}
|
|
1479
|
+
// various transforms to equivalent pattern sets that are
|
|
1480
|
+
// faster to process in a filesystem walk. The goal is to
|
|
1481
|
+
// eliminate what we can, and push all ** patterns as far
|
|
1482
|
+
// to the right as possible, even if it increases the number
|
|
1483
|
+
// of patterns that we have to process.
|
|
1484
|
+
preprocess(globParts) {
|
|
1485
|
+
if (this.options.noglobstar) {
|
|
1486
|
+
for (let i = 0; i < globParts.length; i++) {
|
|
1487
|
+
for (let j = 0; j < globParts[i].length; j++) {
|
|
1488
|
+
if (globParts[i][j] === "**") {
|
|
1489
|
+
globParts[i][j] = "*";
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
const { optimizationLevel = 1 } = this.options;
|
|
1495
|
+
if (optimizationLevel >= 2) {
|
|
1496
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
1497
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
1498
|
+
} else if (optimizationLevel >= 1) {
|
|
1499
|
+
globParts = this.levelOneOptimize(globParts);
|
|
1500
|
+
} else {
|
|
1501
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
1502
|
+
}
|
|
1503
|
+
return globParts;
|
|
1504
|
+
}
|
|
1505
|
+
// just get rid of adjascent ** portions
|
|
1506
|
+
adjascentGlobstarOptimize(globParts) {
|
|
1507
|
+
return globParts.map((parts) => {
|
|
1508
|
+
let gs = -1;
|
|
1509
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
1510
|
+
let i = gs;
|
|
1511
|
+
while (parts[i + 1] === "**") {
|
|
1512
|
+
i++;
|
|
1513
|
+
}
|
|
1514
|
+
if (i !== gs) {
|
|
1515
|
+
parts.splice(gs, i - gs);
|
|
1516
|
+
}
|
|
1517
|
+
}
|
|
1518
|
+
return parts;
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1521
|
+
// get rid of adjascent ** and resolve .. portions
|
|
1522
|
+
levelOneOptimize(globParts) {
|
|
1523
|
+
return globParts.map((parts) => {
|
|
1524
|
+
parts = parts.reduce((set, part) => {
|
|
1525
|
+
const prev = set[set.length - 1];
|
|
1526
|
+
if (part === "**" && prev === "**") {
|
|
1527
|
+
return set;
|
|
1528
|
+
}
|
|
1529
|
+
if (part === "..") {
|
|
1530
|
+
if (prev && prev !== ".." && prev !== "." && prev !== "**") {
|
|
1531
|
+
set.pop();
|
|
1532
|
+
return set;
|
|
1533
|
+
}
|
|
1534
|
+
}
|
|
1535
|
+
set.push(part);
|
|
1536
|
+
return set;
|
|
1537
|
+
}, []);
|
|
1538
|
+
return parts.length === 0 ? [""] : parts;
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
levelTwoFileOptimize(parts) {
|
|
1542
|
+
if (!Array.isArray(parts)) {
|
|
1543
|
+
parts = this.slashSplit(parts);
|
|
1544
|
+
}
|
|
1545
|
+
let didSomething = false;
|
|
1546
|
+
do {
|
|
1547
|
+
didSomething = false;
|
|
1548
|
+
if (!this.preserveMultipleSlashes) {
|
|
1549
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
1550
|
+
const p = parts[i];
|
|
1551
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
1552
|
+
continue;
|
|
1553
|
+
if (p === "." || p === "") {
|
|
1554
|
+
didSomething = true;
|
|
1555
|
+
parts.splice(i, 1);
|
|
1556
|
+
i--;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
1560
|
+
didSomething = true;
|
|
1561
|
+
parts.pop();
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
let dd = 0;
|
|
1565
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
1566
|
+
const p = parts[dd - 1];
|
|
1567
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
1568
|
+
didSomething = true;
|
|
1569
|
+
parts.splice(dd - 1, 2);
|
|
1570
|
+
dd -= 2;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
} while (didSomething);
|
|
1574
|
+
return parts.length === 0 ? [""] : parts;
|
|
1575
|
+
}
|
|
1576
|
+
// First phase: single-pattern processing
|
|
1577
|
+
// <pre> is 1 or more portions
|
|
1578
|
+
// <rest> is 1 or more portions
|
|
1579
|
+
// <p> is any portion other than ., .., '', or **
|
|
1580
|
+
// <e> is . or ''
|
|
1581
|
+
//
|
|
1582
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
1583
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
1584
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
1585
|
+
// or most strings (other than .., ., and '') can be.
|
|
1586
|
+
//
|
|
1587
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
1588
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
1589
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
1590
|
+
// **/**/<rest> -> **/<rest>
|
|
1591
|
+
//
|
|
1592
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
1593
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
1594
|
+
firstPhasePreProcess(globParts) {
|
|
1595
|
+
let didSomething = false;
|
|
1596
|
+
do {
|
|
1597
|
+
didSomething = false;
|
|
1598
|
+
for (let parts of globParts) {
|
|
1599
|
+
let gs = -1;
|
|
1600
|
+
while (-1 !== (gs = parts.indexOf("**", gs + 1))) {
|
|
1601
|
+
let gss = gs;
|
|
1602
|
+
while (parts[gss + 1] === "**") {
|
|
1603
|
+
gss++;
|
|
1604
|
+
}
|
|
1605
|
+
if (gss > gs) {
|
|
1606
|
+
parts.splice(gs + 1, gss - gs);
|
|
1607
|
+
}
|
|
1608
|
+
let next = parts[gs + 1];
|
|
1609
|
+
const p = parts[gs + 2];
|
|
1610
|
+
const p2 = parts[gs + 3];
|
|
1611
|
+
if (next !== "..")
|
|
1612
|
+
continue;
|
|
1613
|
+
if (!p || p === "." || p === ".." || !p2 || p2 === "." || p2 === "..") {
|
|
1614
|
+
continue;
|
|
1615
|
+
}
|
|
1616
|
+
didSomething = true;
|
|
1617
|
+
parts.splice(gs, 1);
|
|
1618
|
+
const other = parts.slice(0);
|
|
1619
|
+
other[gs] = "**";
|
|
1620
|
+
globParts.push(other);
|
|
1621
|
+
gs--;
|
|
1622
|
+
}
|
|
1623
|
+
if (!this.preserveMultipleSlashes) {
|
|
1624
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
1625
|
+
const p = parts[i];
|
|
1626
|
+
if (i === 1 && p === "" && parts[0] === "")
|
|
1627
|
+
continue;
|
|
1628
|
+
if (p === "." || p === "") {
|
|
1629
|
+
didSomething = true;
|
|
1630
|
+
parts.splice(i, 1);
|
|
1631
|
+
i--;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
if (parts[0] === "." && parts.length === 2 && (parts[1] === "." || parts[1] === "")) {
|
|
1635
|
+
didSomething = true;
|
|
1636
|
+
parts.pop();
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
let dd = 0;
|
|
1640
|
+
while (-1 !== (dd = parts.indexOf("..", dd + 1))) {
|
|
1641
|
+
const p = parts[dd - 1];
|
|
1642
|
+
if (p && p !== "." && p !== ".." && p !== "**") {
|
|
1643
|
+
didSomething = true;
|
|
1644
|
+
const needDot = dd === 1 && parts[dd + 1] === "**";
|
|
1645
|
+
const splin = needDot ? ["."] : [];
|
|
1646
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
1647
|
+
if (parts.length === 0)
|
|
1648
|
+
parts.push("");
|
|
1649
|
+
dd -= 2;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
} while (didSomething);
|
|
1654
|
+
return globParts;
|
|
1655
|
+
}
|
|
1656
|
+
// second phase: multi-pattern dedupes
|
|
1657
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
1658
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
1659
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
1660
|
+
//
|
|
1661
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
1662
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
1663
|
+
secondPhasePreProcess(globParts) {
|
|
1664
|
+
for (let i = 0; i < globParts.length - 1; i++) {
|
|
1665
|
+
for (let j = i + 1; j < globParts.length; j++) {
|
|
1666
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
1667
|
+
if (!matched)
|
|
1668
|
+
continue;
|
|
1669
|
+
globParts[i] = matched;
|
|
1670
|
+
globParts[j] = [];
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return globParts.filter((gs) => gs.length);
|
|
1674
|
+
}
|
|
1675
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
1676
|
+
let ai = 0;
|
|
1677
|
+
let bi = 0;
|
|
1678
|
+
let result = [];
|
|
1679
|
+
let which = "";
|
|
1680
|
+
while (ai < a.length && bi < b.length) {
|
|
1681
|
+
if (a[ai] === b[bi]) {
|
|
1682
|
+
result.push(which === "b" ? b[bi] : a[ai]);
|
|
1683
|
+
ai++;
|
|
1684
|
+
bi++;
|
|
1685
|
+
} else if (emptyGSMatch && a[ai] === "**" && b[bi] === a[ai + 1]) {
|
|
1686
|
+
result.push(a[ai]);
|
|
1687
|
+
ai++;
|
|
1688
|
+
} else if (emptyGSMatch && b[bi] === "**" && a[ai] === b[bi + 1]) {
|
|
1689
|
+
result.push(b[bi]);
|
|
1690
|
+
bi++;
|
|
1691
|
+
} else if (a[ai] === "*" && b[bi] && (this.options.dot || !b[bi].startsWith(".")) && b[bi] !== "**") {
|
|
1692
|
+
if (which === "b")
|
|
1693
|
+
return false;
|
|
1694
|
+
which = "a";
|
|
1695
|
+
result.push(a[ai]);
|
|
1696
|
+
ai++;
|
|
1697
|
+
bi++;
|
|
1698
|
+
} else if (b[bi] === "*" && a[ai] && (this.options.dot || !a[ai].startsWith(".")) && a[ai] !== "**") {
|
|
1699
|
+
if (which === "a")
|
|
1700
|
+
return false;
|
|
1701
|
+
which = "b";
|
|
1702
|
+
result.push(b[bi]);
|
|
1703
|
+
ai++;
|
|
1704
|
+
bi++;
|
|
1705
|
+
} else {
|
|
1706
|
+
return false;
|
|
1707
|
+
}
|
|
1708
|
+
}
|
|
1709
|
+
return a.length === b.length && result;
|
|
1710
|
+
}
|
|
1711
|
+
parseNegate() {
|
|
1712
|
+
if (this.nonegate)
|
|
1713
|
+
return;
|
|
1714
|
+
const pattern = this.pattern;
|
|
1715
|
+
let negate = false;
|
|
1716
|
+
let negateOffset = 0;
|
|
1717
|
+
for (let i = 0; i < pattern.length && pattern.charAt(i) === "!"; i++) {
|
|
1718
|
+
negate = !negate;
|
|
1719
|
+
negateOffset++;
|
|
1720
|
+
}
|
|
1721
|
+
if (negateOffset)
|
|
1722
|
+
this.pattern = pattern.slice(negateOffset);
|
|
1723
|
+
this.negate = negate;
|
|
1724
|
+
}
|
|
1725
|
+
// set partial to true to test if, for example,
|
|
1726
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
1727
|
+
// Partial means, if you run out of file before you run
|
|
1728
|
+
// out of pattern, then that's fine, as long as all
|
|
1729
|
+
// the parts match.
|
|
1730
|
+
matchOne(file, pattern, partial = false) {
|
|
1731
|
+
const options = this.options;
|
|
1732
|
+
if (this.isWindows) {
|
|
1733
|
+
const fileDrive = typeof file[0] === "string" && /^[a-z]:$/i.test(file[0]);
|
|
1734
|
+
const fileUNC = !fileDrive && file[0] === "" && file[1] === "" && file[2] === "?" && /^[a-z]:$/i.test(file[3]);
|
|
1735
|
+
const patternDrive = typeof pattern[0] === "string" && /^[a-z]:$/i.test(pattern[0]);
|
|
1736
|
+
const patternUNC = !patternDrive && pattern[0] === "" && pattern[1] === "" && pattern[2] === "?" && typeof pattern[3] === "string" && /^[a-z]:$/i.test(pattern[3]);
|
|
1737
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : void 0;
|
|
1738
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : void 0;
|
|
1739
|
+
if (typeof fdi === "number" && typeof pdi === "number") {
|
|
1740
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
1741
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
1742
|
+
pattern[pdi] = fd;
|
|
1743
|
+
if (pdi > fdi) {
|
|
1744
|
+
pattern = pattern.slice(pdi);
|
|
1745
|
+
} else if (fdi > pdi) {
|
|
1746
|
+
file = file.slice(fdi);
|
|
1747
|
+
}
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
}
|
|
1751
|
+
const { optimizationLevel = 1 } = this.options;
|
|
1752
|
+
if (optimizationLevel >= 2) {
|
|
1753
|
+
file = this.levelTwoFileOptimize(file);
|
|
1754
|
+
}
|
|
1755
|
+
this.debug("matchOne", this, { file, pattern });
|
|
1756
|
+
this.debug("matchOne", file.length, pattern.length);
|
|
1757
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
1758
|
+
this.debug("matchOne loop");
|
|
1759
|
+
var p = pattern[pi];
|
|
1760
|
+
var f = file[fi];
|
|
1761
|
+
this.debug(pattern, p, f);
|
|
1762
|
+
if (p === false) {
|
|
1763
|
+
return false;
|
|
1764
|
+
}
|
|
1765
|
+
if (p === GLOBSTAR) {
|
|
1766
|
+
this.debug("GLOBSTAR", [pattern, p, f]);
|
|
1767
|
+
var fr = fi;
|
|
1768
|
+
var pr = pi + 1;
|
|
1769
|
+
if (pr === pl) {
|
|
1770
|
+
this.debug("** at the end");
|
|
1771
|
+
for (; fi < fl; fi++) {
|
|
1772
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
1773
|
+
return false;
|
|
1774
|
+
}
|
|
1775
|
+
return true;
|
|
1776
|
+
}
|
|
1777
|
+
while (fr < fl) {
|
|
1778
|
+
var swallowee = file[fr];
|
|
1779
|
+
this.debug("\nglobstar while", file, fr, pattern, pr, swallowee);
|
|
1780
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
1781
|
+
this.debug("globstar found match!", fr, fl, swallowee);
|
|
1782
|
+
return true;
|
|
1783
|
+
} else {
|
|
1784
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
1785
|
+
this.debug("dot detected!", file, fr, pattern, pr);
|
|
1786
|
+
break;
|
|
1787
|
+
}
|
|
1788
|
+
this.debug("globstar swallow a segment, and continue");
|
|
1789
|
+
fr++;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
if (partial) {
|
|
1793
|
+
this.debug("\n>>> no match, partial?", file, fr, pattern, pr);
|
|
1794
|
+
if (fr === fl) {
|
|
1795
|
+
return true;
|
|
1796
|
+
}
|
|
1797
|
+
}
|
|
1798
|
+
return false;
|
|
1799
|
+
}
|
|
1800
|
+
let hit;
|
|
1801
|
+
if (typeof p === "string") {
|
|
1802
|
+
hit = f === p;
|
|
1803
|
+
this.debug("string match", p, f, hit);
|
|
1804
|
+
} else {
|
|
1805
|
+
hit = p.test(f);
|
|
1806
|
+
this.debug("pattern match", p, f, hit);
|
|
1807
|
+
}
|
|
1808
|
+
if (!hit)
|
|
1809
|
+
return false;
|
|
1810
|
+
}
|
|
1811
|
+
if (fi === fl && pi === pl) {
|
|
1812
|
+
return true;
|
|
1813
|
+
} else if (fi === fl) {
|
|
1814
|
+
return partial;
|
|
1815
|
+
} else if (pi === pl) {
|
|
1816
|
+
return fi === fl - 1 && file[fi] === "";
|
|
1817
|
+
} else {
|
|
1818
|
+
throw new Error("wtf?");
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
braceExpand() {
|
|
1822
|
+
return braceExpand(this.pattern, this.options);
|
|
1823
|
+
}
|
|
1824
|
+
parse(pattern) {
|
|
1825
|
+
assertValidPattern(pattern);
|
|
1826
|
+
const options = this.options;
|
|
1827
|
+
if (pattern === "**")
|
|
1828
|
+
return GLOBSTAR;
|
|
1829
|
+
if (pattern === "")
|
|
1830
|
+
return "";
|
|
1831
|
+
let m;
|
|
1832
|
+
let fastTest = null;
|
|
1833
|
+
if (m = pattern.match(starRE)) {
|
|
1834
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
1835
|
+
} else if (m = pattern.match(starDotExtRE)) {
|
|
1836
|
+
fastTest = (options.nocase ? options.dot ? starDotExtTestNocaseDot : starDotExtTestNocase : options.dot ? starDotExtTestDot : starDotExtTest)(m[1]);
|
|
1837
|
+
} else if (m = pattern.match(qmarksRE)) {
|
|
1838
|
+
fastTest = (options.nocase ? options.dot ? qmarksTestNocaseDot : qmarksTestNocase : options.dot ? qmarksTestDot : qmarksTest)(m);
|
|
1839
|
+
} else if (m = pattern.match(starDotStarRE)) {
|
|
1840
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
1841
|
+
} else if (m = pattern.match(dotStarRE)) {
|
|
1842
|
+
fastTest = dotStarTest;
|
|
1843
|
+
}
|
|
1844
|
+
const re = AST.fromGlob(pattern, this.options).toMMPattern();
|
|
1845
|
+
if (fastTest && typeof re === "object") {
|
|
1846
|
+
Reflect.defineProperty(re, "test", { value: fastTest });
|
|
1847
|
+
}
|
|
1848
|
+
return re;
|
|
1849
|
+
}
|
|
1850
|
+
makeRe() {
|
|
1851
|
+
if (this.regexp || this.regexp === false)
|
|
1852
|
+
return this.regexp;
|
|
1853
|
+
const set = this.set;
|
|
1854
|
+
if (!set.length) {
|
|
1855
|
+
this.regexp = false;
|
|
1856
|
+
return this.regexp;
|
|
1857
|
+
}
|
|
1858
|
+
const options = this.options;
|
|
1859
|
+
const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
|
|
1860
|
+
const flags = new Set(options.nocase ? ["i"] : []);
|
|
1861
|
+
let re = set.map((pattern) => {
|
|
1862
|
+
const pp = pattern.map((p) => {
|
|
1863
|
+
if (p instanceof RegExp) {
|
|
1864
|
+
for (const f of p.flags.split(""))
|
|
1865
|
+
flags.add(f);
|
|
1866
|
+
}
|
|
1867
|
+
return typeof p === "string" ? regExpEscape2(p) : p === GLOBSTAR ? GLOBSTAR : p._src;
|
|
1868
|
+
});
|
|
1869
|
+
pp.forEach((p, i) => {
|
|
1870
|
+
const next = pp[i + 1];
|
|
1871
|
+
const prev = pp[i - 1];
|
|
1872
|
+
if (p !== GLOBSTAR || prev === GLOBSTAR) {
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
if (prev === void 0) {
|
|
1876
|
+
if (next !== void 0 && next !== GLOBSTAR) {
|
|
1877
|
+
pp[i + 1] = "(?:\\/|" + twoStar + "\\/)?" + next;
|
|
1878
|
+
} else {
|
|
1879
|
+
pp[i] = twoStar;
|
|
1880
|
+
}
|
|
1881
|
+
} else if (next === void 0) {
|
|
1882
|
+
pp[i - 1] = prev + "(?:\\/|" + twoStar + ")?";
|
|
1883
|
+
} else if (next !== GLOBSTAR) {
|
|
1884
|
+
pp[i - 1] = prev + "(?:\\/|\\/" + twoStar + "\\/)" + next;
|
|
1885
|
+
pp[i + 1] = GLOBSTAR;
|
|
1886
|
+
}
|
|
1887
|
+
});
|
|
1888
|
+
return pp.filter((p) => p !== GLOBSTAR).join("/");
|
|
1889
|
+
}).join("|");
|
|
1890
|
+
const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
1891
|
+
re = "^" + open + re + close + "$";
|
|
1892
|
+
if (this.negate)
|
|
1893
|
+
re = "^(?!" + re + ").+$";
|
|
1894
|
+
try {
|
|
1895
|
+
this.regexp = new RegExp(re, [...flags].join(""));
|
|
1896
|
+
} catch (ex) {
|
|
1897
|
+
this.regexp = false;
|
|
1898
|
+
}
|
|
1899
|
+
return this.regexp;
|
|
1900
|
+
}
|
|
1901
|
+
slashSplit(p) {
|
|
1902
|
+
if (this.preserveMultipleSlashes) {
|
|
1903
|
+
return p.split("/");
|
|
1904
|
+
} else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
1905
|
+
return ["", ...p.split(/\/+/)];
|
|
1906
|
+
} else {
|
|
1907
|
+
return p.split(/\/+/);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
match(f, partial = this.partial) {
|
|
1911
|
+
this.debug("match", f, this.pattern);
|
|
1912
|
+
if (this.comment) {
|
|
1913
|
+
return false;
|
|
1914
|
+
}
|
|
1915
|
+
if (this.empty) {
|
|
1916
|
+
return f === "";
|
|
1917
|
+
}
|
|
1918
|
+
if (f === "/" && partial) {
|
|
1919
|
+
return true;
|
|
1920
|
+
}
|
|
1921
|
+
const options = this.options;
|
|
1922
|
+
if (this.isWindows) {
|
|
1923
|
+
f = f.split("\\").join("/");
|
|
1924
|
+
}
|
|
1925
|
+
const ff = this.slashSplit(f);
|
|
1926
|
+
this.debug(this.pattern, "split", ff);
|
|
1927
|
+
const set = this.set;
|
|
1928
|
+
this.debug(this.pattern, "set", set);
|
|
1929
|
+
let filename = ff[ff.length - 1];
|
|
1930
|
+
if (!filename) {
|
|
1931
|
+
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
1932
|
+
filename = ff[i];
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
for (let i = 0; i < set.length; i++) {
|
|
1936
|
+
const pattern = set[i];
|
|
1937
|
+
let file = ff;
|
|
1938
|
+
if (options.matchBase && pattern.length === 1) {
|
|
1939
|
+
file = [filename];
|
|
1940
|
+
}
|
|
1941
|
+
const hit = this.matchOne(file, pattern, partial);
|
|
1942
|
+
if (hit) {
|
|
1943
|
+
if (options.flipNegate) {
|
|
1944
|
+
return true;
|
|
1945
|
+
}
|
|
1946
|
+
return !this.negate;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
if (options.flipNegate) {
|
|
1950
|
+
return false;
|
|
1951
|
+
}
|
|
1952
|
+
return this.negate;
|
|
1953
|
+
}
|
|
1954
|
+
static defaults(def) {
|
|
1955
|
+
return minimatch.defaults(def).Minimatch;
|
|
1956
|
+
}
|
|
1957
|
+
};
|
|
1958
|
+
minimatch.AST = AST;
|
|
1959
|
+
minimatch.Minimatch = Minimatch;
|
|
1960
|
+
minimatch.escape = escape;
|
|
1961
|
+
minimatch.unescape = unescape;
|
|
1962
|
+
|
|
365
1963
|
// src/utils/regular-expression.ts
|
|
366
1964
|
var escapeRegExpSpecialCharacters = (text) => {
|
|
367
1965
|
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -9212,16 +10810,16 @@ var getCodePoint = (
|
|
|
9212
10810
|
)
|
|
9213
10811
|
);
|
|
9214
10812
|
function getEscaper(regex, map2) {
|
|
9215
|
-
return function
|
|
9216
|
-
let
|
|
10813
|
+
return function escape2(data) {
|
|
10814
|
+
let match2;
|
|
9217
10815
|
let lastIdx = 0;
|
|
9218
10816
|
let result = "";
|
|
9219
|
-
while (
|
|
9220
|
-
if (lastIdx !==
|
|
9221
|
-
result += data.substring(lastIdx,
|
|
10817
|
+
while (match2 = regex.exec(data)) {
|
|
10818
|
+
if (lastIdx !== match2.index) {
|
|
10819
|
+
result += data.substring(lastIdx, match2.index);
|
|
9222
10820
|
}
|
|
9223
|
-
result += map2.get(
|
|
9224
|
-
lastIdx =
|
|
10821
|
+
result += map2.get(match2[0].charCodeAt(0));
|
|
10822
|
+
lastIdx = match2.index + 1;
|
|
9225
10823
|
}
|
|
9226
10824
|
return result + data.substring(lastIdx);
|
|
9227
10825
|
};
|
|
@@ -9873,8 +11471,8 @@ var jquery_default = (
|
|
|
9873
11471
|
)
|
|
9874
11472
|
};
|
|
9875
11473
|
var rpseudo = new RegExp(pseudos);
|
|
9876
|
-
var runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function(
|
|
9877
|
-
var high = "0x" +
|
|
11474
|
+
var runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function(escape2, nonHex) {
|
|
11475
|
+
var high = "0x" + escape2.slice(1) - 65536;
|
|
9878
11476
|
if (nonHex) {
|
|
9879
11477
|
return nonHex;
|
|
9880
11478
|
}
|
|
@@ -9889,7 +11487,7 @@ var jquery_default = (
|
|
|
9889
11487
|
var rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*");
|
|
9890
11488
|
var tokenCache = createCache();
|
|
9891
11489
|
function tokenize(selector, parseOnly) {
|
|
9892
|
-
var matched,
|
|
11490
|
+
var matched, match2, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "];
|
|
9893
11491
|
if (cached) {
|
|
9894
11492
|
return parseOnly ? 0 : cached.slice(0);
|
|
9895
11493
|
}
|
|
@@ -9897,29 +11495,29 @@ var jquery_default = (
|
|
|
9897
11495
|
groups = [];
|
|
9898
11496
|
preFilters = jQuery.expr.preFilter;
|
|
9899
11497
|
while (soFar) {
|
|
9900
|
-
if (!matched || (
|
|
9901
|
-
if (
|
|
9902
|
-
soFar = soFar.slice(
|
|
11498
|
+
if (!matched || (match2 = rcomma.exec(soFar))) {
|
|
11499
|
+
if (match2) {
|
|
11500
|
+
soFar = soFar.slice(match2[0].length) || soFar;
|
|
9903
11501
|
}
|
|
9904
11502
|
groups.push(tokens = []);
|
|
9905
11503
|
}
|
|
9906
11504
|
matched = false;
|
|
9907
|
-
if (
|
|
9908
|
-
matched =
|
|
11505
|
+
if (match2 = rleadingCombinator.exec(soFar)) {
|
|
11506
|
+
matched = match2.shift();
|
|
9909
11507
|
tokens.push({
|
|
9910
11508
|
value: matched,
|
|
9911
11509
|
// Cast descendant combinators to space
|
|
9912
|
-
type:
|
|
11510
|
+
type: match2[0].replace(rtrimCSS, " ")
|
|
9913
11511
|
});
|
|
9914
11512
|
soFar = soFar.slice(matched.length);
|
|
9915
11513
|
}
|
|
9916
11514
|
for (type in filterMatchExpr) {
|
|
9917
|
-
if ((
|
|
9918
|
-
matched =
|
|
11515
|
+
if ((match2 = jQuery.expr.match[type].exec(soFar)) && (!preFilters[type] || (match2 = preFilters[type](match2)))) {
|
|
11516
|
+
matched = match2.shift();
|
|
9919
11517
|
tokens.push({
|
|
9920
11518
|
value: matched,
|
|
9921
11519
|
type,
|
|
9922
|
-
matches:
|
|
11520
|
+
matches: match2
|
|
9923
11521
|
});
|
|
9924
11522
|
soFar = soFar.slice(matched.length);
|
|
9925
11523
|
}
|
|
@@ -9937,41 +11535,41 @@ var jquery_default = (
|
|
|
9937
11535
|
);
|
|
9938
11536
|
}
|
|
9939
11537
|
var preFilter = {
|
|
9940
|
-
ATTR: function(
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
if (
|
|
9944
|
-
|
|
11538
|
+
ATTR: function(match2) {
|
|
11539
|
+
match2[1] = unescapeSelector(match2[1]);
|
|
11540
|
+
match2[3] = unescapeSelector(match2[3] || match2[4] || match2[5] || "");
|
|
11541
|
+
if (match2[2] === "~=") {
|
|
11542
|
+
match2[3] = " " + match2[3] + " ";
|
|
9945
11543
|
}
|
|
9946
|
-
return
|
|
11544
|
+
return match2.slice(0, 4);
|
|
9947
11545
|
},
|
|
9948
|
-
CHILD: function(
|
|
9949
|
-
|
|
9950
|
-
if (
|
|
9951
|
-
if (!
|
|
9952
|
-
selectorError(
|
|
11546
|
+
CHILD: function(match2) {
|
|
11547
|
+
match2[1] = match2[1].toLowerCase();
|
|
11548
|
+
if (match2[1].slice(0, 3) === "nth") {
|
|
11549
|
+
if (!match2[3]) {
|
|
11550
|
+
selectorError(match2[0]);
|
|
9953
11551
|
}
|
|
9954
|
-
|
|
9955
|
-
|
|
9956
|
-
} else if (
|
|
9957
|
-
selectorError(
|
|
11552
|
+
match2[4] = +(match2[4] ? match2[5] + (match2[6] || 1) : 2 * (match2[3] === "even" || match2[3] === "odd"));
|
|
11553
|
+
match2[5] = +(match2[7] + match2[8] || match2[3] === "odd");
|
|
11554
|
+
} else if (match2[3]) {
|
|
11555
|
+
selectorError(match2[0]);
|
|
9958
11556
|
}
|
|
9959
|
-
return
|
|
11557
|
+
return match2;
|
|
9960
11558
|
},
|
|
9961
|
-
PSEUDO: function(
|
|
9962
|
-
var excess, unquoted = !
|
|
9963
|
-
if (filterMatchExpr.CHILD.test(
|
|
11559
|
+
PSEUDO: function(match2) {
|
|
11560
|
+
var excess, unquoted = !match2[6] && match2[2];
|
|
11561
|
+
if (filterMatchExpr.CHILD.test(match2[0])) {
|
|
9964
11562
|
return null;
|
|
9965
11563
|
}
|
|
9966
|
-
if (
|
|
9967
|
-
|
|
11564
|
+
if (match2[3]) {
|
|
11565
|
+
match2[2] = match2[4] || match2[5] || "";
|
|
9968
11566
|
} else if (unquoted && rpseudo.test(unquoted) && // Get excess from tokenize (recursively)
|
|
9969
11567
|
(excess = tokenize(unquoted, true)) && // advance to the next closing parenthesis
|
|
9970
11568
|
(excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
|
|
9971
|
-
|
|
9972
|
-
|
|
11569
|
+
match2[0] = match2[0].slice(0, excess);
|
|
11570
|
+
match2[2] = unquoted.slice(0, excess);
|
|
9973
11571
|
}
|
|
9974
|
-
return
|
|
11572
|
+
return match2.slice(0, 3);
|
|
9975
11573
|
}
|
|
9976
11574
|
};
|
|
9977
11575
|
function toSelector(tokens) {
|
|
@@ -10054,7 +11652,7 @@ var jquery_default = (
|
|
|
10054
11652
|
{ dir: "parentNode", next: "legend" }
|
|
10055
11653
|
);
|
|
10056
11654
|
function find(selector, context, results, seed) {
|
|
10057
|
-
var m, i2, elem, nid,
|
|
11655
|
+
var m, i2, elem, nid, match2, groups, newSelector, newContext = context && context.ownerDocument, nodeType = context ? context.nodeType : 9;
|
|
10058
11656
|
results = results || [];
|
|
10059
11657
|
if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) {
|
|
10060
11658
|
return results;
|
|
@@ -10063,8 +11661,8 @@ var jquery_default = (
|
|
|
10063
11661
|
setDocument(context);
|
|
10064
11662
|
context = context || document$1;
|
|
10065
11663
|
if (documentIsHTML) {
|
|
10066
|
-
if (nodeType !== 11 && (
|
|
10067
|
-
if (m =
|
|
11664
|
+
if (nodeType !== 11 && (match2 = rquickExpr.exec(selector))) {
|
|
11665
|
+
if (m = match2[1]) {
|
|
10068
11666
|
if (nodeType === 9) {
|
|
10069
11667
|
if (elem = context.getElementById(m)) {
|
|
10070
11668
|
push.call(results, elem);
|
|
@@ -10076,10 +11674,10 @@ var jquery_default = (
|
|
|
10076
11674
|
return results;
|
|
10077
11675
|
}
|
|
10078
11676
|
}
|
|
10079
|
-
} else if (
|
|
11677
|
+
} else if (match2[2]) {
|
|
10080
11678
|
push.apply(results, context.getElementsByTagName(selector));
|
|
10081
11679
|
return results;
|
|
10082
|
-
} else if ((m =
|
|
11680
|
+
} else if ((m = match2[3]) && context.getElementsByClassName) {
|
|
10083
11681
|
push.apply(results, context.getElementsByClassName(m));
|
|
10084
11682
|
return results;
|
|
10085
11683
|
}
|
|
@@ -10575,11 +12173,11 @@ var jquery_default = (
|
|
|
10575
12173
|
}
|
|
10576
12174
|
return results;
|
|
10577
12175
|
}
|
|
10578
|
-
function condense(unmatched, map2,
|
|
12176
|
+
function condense(unmatched, map2, filter2, context, xml) {
|
|
10579
12177
|
var elem, newUnmatched = [], i2 = 0, len = unmatched.length, mapped = map2 != null;
|
|
10580
12178
|
for (; i2 < len; i2++) {
|
|
10581
12179
|
if (elem = unmatched[i2]) {
|
|
10582
|
-
if (!
|
|
12180
|
+
if (!filter2 || filter2(elem, context, xml)) {
|
|
10583
12181
|
newUnmatched.push(elem);
|
|
10584
12182
|
if (mapped) {
|
|
10585
12183
|
map2.push(i2);
|
|
@@ -10755,15 +12353,15 @@ var jquery_default = (
|
|
|
10755
12353
|
};
|
|
10756
12354
|
return bySet ? markFunction(superMatcher) : superMatcher;
|
|
10757
12355
|
}
|
|
10758
|
-
function compile(selector,
|
|
12356
|
+
function compile(selector, match2) {
|
|
10759
12357
|
var i2, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + " "];
|
|
10760
12358
|
if (!cached) {
|
|
10761
|
-
if (!
|
|
10762
|
-
|
|
12359
|
+
if (!match2) {
|
|
12360
|
+
match2 = tokenize(selector);
|
|
10763
12361
|
}
|
|
10764
|
-
i2 =
|
|
12362
|
+
i2 = match2.length;
|
|
10765
12363
|
while (i2--) {
|
|
10766
|
-
cached = matcherFromTokens(
|
|
12364
|
+
cached = matcherFromTokens(match2[i2]);
|
|
10767
12365
|
if (cached[jQuery.expando]) {
|
|
10768
12366
|
setMatchers.push(cached);
|
|
10769
12367
|
} else {
|
|
@@ -10779,10 +12377,10 @@ var jquery_default = (
|
|
|
10779
12377
|
return cached;
|
|
10780
12378
|
}
|
|
10781
12379
|
function select(selector, context, results, seed) {
|
|
10782
|
-
var i2, tokens, token, type, find2, compiled = typeof selector === "function" && selector,
|
|
12380
|
+
var i2, tokens, token, type, find2, compiled = typeof selector === "function" && selector, match2 = !seed && tokenize(selector = compiled.selector || selector);
|
|
10783
12381
|
results = results || [];
|
|
10784
|
-
if (
|
|
10785
|
-
tokens =
|
|
12382
|
+
if (match2.length === 1) {
|
|
12383
|
+
tokens = match2[0] = match2[0].slice(0);
|
|
10786
12384
|
if (tokens.length > 2 && (token = tokens[0]).type === "ID" && context.nodeType === 9 && documentIsHTML && jQuery.expr.relative[tokens[1].type]) {
|
|
10787
12385
|
context = (jQuery.expr.find.ID(
|
|
10788
12386
|
unescapeSelector(token.matches[0]),
|
|
@@ -10817,7 +12415,7 @@ var jquery_default = (
|
|
|
10817
12415
|
}
|
|
10818
12416
|
}
|
|
10819
12417
|
}
|
|
10820
|
-
(compiled || compile(selector,
|
|
12418
|
+
(compiled || compile(selector, match2))(
|
|
10821
12419
|
seed,
|
|
10822
12420
|
context,
|
|
10823
12421
|
!documentIsHTML,
|
|
@@ -10964,6 +12562,9 @@ function* streamToHtml(node, opts, output) {
|
|
|
10964
12562
|
if (attrName === "style") {
|
|
10965
12563
|
continue;
|
|
10966
12564
|
}
|
|
12565
|
+
if (tag === "template" && isShadowRoot && (attrName === "shadowrootmode" || attrName === "shadowrootdelegatesfocus")) {
|
|
12566
|
+
continue;
|
|
12567
|
+
}
|
|
10967
12568
|
let attrValue = attr.value;
|
|
10968
12569
|
if (opts.removeEmptyAttributes && attrValue === "" && REMOVE_EMPTY_ATTR.has(attrName)) {
|
|
10969
12570
|
continue;
|
|
@@ -10999,6 +12600,9 @@ function* streamToHtml(node, opts, output) {
|
|
|
10999
12600
|
attrValue = attr.value = attrValue.split(" ").filter((t) => t !== "").sort().join(" ").trim();
|
|
11000
12601
|
}
|
|
11001
12602
|
if (attrValue === "") {
|
|
12603
|
+
if (attrName === "shadowrootdelegatesfocus") {
|
|
12604
|
+
continue;
|
|
12605
|
+
}
|
|
11002
12606
|
if (opts.removeBooleanAttributeQuotes && BOOLEAN_ATTR.has(attrName)) {
|
|
11003
12607
|
continue;
|
|
11004
12608
|
}
|
|
@@ -11303,6 +12907,7 @@ var BOOLEAN_ATTR = /* @__PURE__ */ new Set([
|
|
|
11303
12907
|
"scoped",
|
|
11304
12908
|
"seamless",
|
|
11305
12909
|
"selected",
|
|
12910
|
+
"shadowrootdelegatesfocus",
|
|
11306
12911
|
"sortable",
|
|
11307
12912
|
"truespeed",
|
|
11308
12913
|
"typemustmatch",
|
|
@@ -11699,7 +13304,7 @@ var MockElement = class extends MockNode2 {
|
|
|
11699
13304
|
get firstElementChild() {
|
|
11700
13305
|
return this.children[0] || null;
|
|
11701
13306
|
}
|
|
11702
|
-
focus(
|
|
13307
|
+
focus(_options2) {
|
|
11703
13308
|
dispatchEvent(
|
|
11704
13309
|
this,
|
|
11705
13310
|
new MockFocusEvent("focus", { relatedTarget: null, bubbles: true, cancelable: true, composed: true })
|
|
@@ -12906,7 +14511,7 @@ var MockSVGElement = class extends MockElement {
|
|
|
12906
14511
|
}
|
|
12907
14512
|
};
|
|
12908
14513
|
var MockSVGGraphicsElement = class extends MockSVGElement {
|
|
12909
|
-
getBBox(
|
|
14514
|
+
getBBox(_options2) {
|
|
12910
14515
|
return new MockSVGRect();
|
|
12911
14516
|
}
|
|
12912
14517
|
getCTM() {
|
|
@@ -13131,10 +14736,10 @@ function fullUrl(elm, attrName) {
|
|
|
13131
14736
|
}
|
|
13132
14737
|
return val.replace(/\'|\"/g, "").trim();
|
|
13133
14738
|
}
|
|
13134
|
-
function patchPropAttributes(prototype, attrs,
|
|
14739
|
+
function patchPropAttributes(prototype, attrs, defaults2 = {}) {
|
|
13135
14740
|
Object.keys(attrs).forEach((propName) => {
|
|
13136
14741
|
const attr = attrs[propName];
|
|
13137
|
-
const defaultValue =
|
|
14742
|
+
const defaultValue = defaults2[propName];
|
|
13138
14743
|
if (attr === Boolean) {
|
|
13139
14744
|
Object.defineProperty(prototype, propName, {
|
|
13140
14745
|
get() {
|
|
@@ -14895,16 +16500,16 @@ var parseCss = (css, filePath) => {
|
|
|
14895
16500
|
const stylesheet = () => {
|
|
14896
16501
|
const rulesList = rules();
|
|
14897
16502
|
return {
|
|
14898
|
-
type:
|
|
16503
|
+
type: 15 /* StyleSheet */,
|
|
14899
16504
|
stylesheet: {
|
|
14900
16505
|
source: filePath,
|
|
14901
16506
|
rules: rulesList
|
|
14902
16507
|
}
|
|
14903
16508
|
};
|
|
14904
16509
|
};
|
|
14905
|
-
const open = () =>
|
|
14906
|
-
const close = () =>
|
|
14907
|
-
const
|
|
16510
|
+
const open = () => match2(/^{\s*/);
|
|
16511
|
+
const close = () => match2(/^}/);
|
|
16512
|
+
const match2 = (re) => {
|
|
14908
16513
|
const m = re.exec(css);
|
|
14909
16514
|
if (!m) return;
|
|
14910
16515
|
const str = m[0];
|
|
@@ -14923,7 +16528,7 @@ var parseCss = (css, filePath) => {
|
|
|
14923
16528
|
}
|
|
14924
16529
|
return rules2;
|
|
14925
16530
|
};
|
|
14926
|
-
const whitespace = () =>
|
|
16531
|
+
const whitespace = () => match2(/^\s*/);
|
|
14927
16532
|
const comments = (rules2) => {
|
|
14928
16533
|
let c;
|
|
14929
16534
|
rules2 = rules2 || [];
|
|
@@ -14952,7 +16557,7 @@ var parseCss = (css, filePath) => {
|
|
|
14952
16557
|
});
|
|
14953
16558
|
};
|
|
14954
16559
|
const selector = () => {
|
|
14955
|
-
const m =
|
|
16560
|
+
const m = match2(/^([^{]+)/);
|
|
14956
16561
|
if (!m) return null;
|
|
14957
16562
|
return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, "").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function(m2) {
|
|
14958
16563
|
return m2.replace(/,/g, "\u200C");
|
|
@@ -14962,17 +16567,17 @@ var parseCss = (css, filePath) => {
|
|
|
14962
16567
|
};
|
|
14963
16568
|
const declaration = () => {
|
|
14964
16569
|
const pos = position();
|
|
14965
|
-
let prop =
|
|
16570
|
+
let prop = match2(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
|
|
14966
16571
|
if (!prop) return null;
|
|
14967
16572
|
prop = trim(prop[0]);
|
|
14968
|
-
if (!
|
|
14969
|
-
const val =
|
|
16573
|
+
if (!match2(/^:\s*/)) return error(`property missing ':'`);
|
|
16574
|
+
const val = match2(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
|
|
14970
16575
|
const ret = pos({
|
|
14971
16576
|
type: 4 /* Declaration */,
|
|
14972
16577
|
property: prop.replace(commentre, ""),
|
|
14973
16578
|
value: val ? trim(val[0]).replace(commentre, "") : ""
|
|
14974
16579
|
});
|
|
14975
|
-
|
|
16580
|
+
match2(/^[;\s]*/);
|
|
14976
16581
|
return ret;
|
|
14977
16582
|
};
|
|
14978
16583
|
const declarations = () => {
|
|
@@ -14991,9 +16596,9 @@ var parseCss = (css, filePath) => {
|
|
|
14991
16596
|
let m;
|
|
14992
16597
|
const values = [];
|
|
14993
16598
|
const pos = position();
|
|
14994
|
-
while (m =
|
|
16599
|
+
while (m = match2(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
|
|
14995
16600
|
values.push(m[1]);
|
|
14996
|
-
|
|
16601
|
+
match2(/^,\s*/);
|
|
14997
16602
|
}
|
|
14998
16603
|
if (!values.length) return null;
|
|
14999
16604
|
return pos({
|
|
@@ -15004,10 +16609,10 @@ var parseCss = (css, filePath) => {
|
|
|
15004
16609
|
};
|
|
15005
16610
|
const atkeyframes = () => {
|
|
15006
16611
|
const pos = position();
|
|
15007
|
-
let m =
|
|
16612
|
+
let m = match2(/^@([-\w]+)?keyframes\s*/);
|
|
15008
16613
|
if (!m) return null;
|
|
15009
16614
|
const vendor = m[1];
|
|
15010
|
-
m =
|
|
16615
|
+
m = match2(/^([-\w]+)\s*/);
|
|
15011
16616
|
if (!m) return error(`@keyframes missing name`);
|
|
15012
16617
|
const name = m[1];
|
|
15013
16618
|
if (!open()) return error(`@keyframes missing '{'`);
|
|
@@ -15027,21 +16632,21 @@ var parseCss = (css, filePath) => {
|
|
|
15027
16632
|
};
|
|
15028
16633
|
const atsupports = () => {
|
|
15029
16634
|
const pos = position();
|
|
15030
|
-
const m =
|
|
16635
|
+
const m = match2(/^@supports *([^{]+)/);
|
|
15031
16636
|
if (!m) return null;
|
|
15032
16637
|
const supports = trim(m[1]);
|
|
15033
16638
|
if (!open()) return error(`@supports missing '{'`);
|
|
15034
16639
|
const style = comments().concat(rules());
|
|
15035
16640
|
if (!close()) return error(`@supports missing '}'`);
|
|
15036
16641
|
return pos({
|
|
15037
|
-
type:
|
|
16642
|
+
type: 16 /* Supports */,
|
|
15038
16643
|
supports,
|
|
15039
16644
|
rules: style
|
|
15040
16645
|
});
|
|
15041
16646
|
};
|
|
15042
16647
|
const athost = () => {
|
|
15043
16648
|
const pos = position();
|
|
15044
|
-
const m =
|
|
16649
|
+
const m = match2(/^@host\s*/);
|
|
15045
16650
|
if (!m) return null;
|
|
15046
16651
|
if (!open()) return error(`@host missing '{'`);
|
|
15047
16652
|
const style = comments().concat(rules());
|
|
@@ -15051,23 +16656,42 @@ var parseCss = (css, filePath) => {
|
|
|
15051
16656
|
rules: style
|
|
15052
16657
|
});
|
|
15053
16658
|
};
|
|
15054
|
-
const
|
|
16659
|
+
const atquery = (name) => {
|
|
15055
16660
|
const pos = position();
|
|
15056
|
-
const
|
|
16661
|
+
const regex = new RegExp("^@" + name + " *([^{]+)");
|
|
16662
|
+
const m = match2(regex);
|
|
15057
16663
|
if (!m) return null;
|
|
15058
16664
|
const media = trim(m[1]);
|
|
15059
|
-
if (!open()) return error(
|
|
16665
|
+
if (!open()) return error(`@${name} missing '{'`);
|
|
15060
16666
|
const style = comments().concat(rules());
|
|
15061
|
-
if (!close()) return error(
|
|
16667
|
+
if (!close()) return error(`@${name} missing '}'`);
|
|
15062
16668
|
return pos({
|
|
15063
|
-
type: 10 /* Media */,
|
|
16669
|
+
type: name === "media" ? 10 /* Media */ : 11 /* Container */,
|
|
15064
16670
|
media,
|
|
15065
16671
|
rules: style
|
|
15066
16672
|
});
|
|
15067
16673
|
};
|
|
16674
|
+
const nestedAtQuery = (name) => {
|
|
16675
|
+
const pos = position();
|
|
16676
|
+
const regex = new RegExp("^@" + name + " *([^{]+)");
|
|
16677
|
+
const m = match2(regex);
|
|
16678
|
+
if (!m) return null;
|
|
16679
|
+
const media = trim(m[1]);
|
|
16680
|
+
const decls = declarations();
|
|
16681
|
+
if (!decls) return null;
|
|
16682
|
+
return pos({
|
|
16683
|
+
type: name === "media" ? 10 /* Media */ : name === "container" ? 11 /* Container */ : 16 /* Supports */,
|
|
16684
|
+
media,
|
|
16685
|
+
declarations: decls
|
|
16686
|
+
});
|
|
16687
|
+
};
|
|
16688
|
+
const nestedAtrule = () => {
|
|
16689
|
+
if (css[0] !== "@") return null;
|
|
16690
|
+
return nestedAtQuery("media") || nestedAtQuery("supports") || nestedAtQuery("container");
|
|
16691
|
+
};
|
|
15068
16692
|
const atcustommedia = () => {
|
|
15069
16693
|
const pos = position();
|
|
15070
|
-
const m =
|
|
16694
|
+
const m = match2(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
|
|
15071
16695
|
if (!m) return null;
|
|
15072
16696
|
return pos({
|
|
15073
16697
|
type: 2 /* CustomMedia */,
|
|
@@ -15077,7 +16701,7 @@ var parseCss = (css, filePath) => {
|
|
|
15077
16701
|
};
|
|
15078
16702
|
const atpage = () => {
|
|
15079
16703
|
const pos = position();
|
|
15080
|
-
const m =
|
|
16704
|
+
const m = match2(/^@page */);
|
|
15081
16705
|
if (!m) return null;
|
|
15082
16706
|
const sel = selector() || [];
|
|
15083
16707
|
if (!open()) return error(`@page missing '{'`);
|
|
@@ -15089,14 +16713,14 @@ var parseCss = (css, filePath) => {
|
|
|
15089
16713
|
}
|
|
15090
16714
|
if (!close()) return error(`@page missing '}'`);
|
|
15091
16715
|
return pos({
|
|
15092
|
-
type:
|
|
16716
|
+
type: 13 /* Page */,
|
|
15093
16717
|
selectors: sel,
|
|
15094
16718
|
declarations: decls
|
|
15095
16719
|
});
|
|
15096
16720
|
};
|
|
15097
16721
|
const atdocument = () => {
|
|
15098
16722
|
const pos = position();
|
|
15099
|
-
const m =
|
|
16723
|
+
const m = match2(/^@([-\w]+)?document *([^{]+)/);
|
|
15100
16724
|
if (!m) return null;
|
|
15101
16725
|
const vendor = trim(m[1]);
|
|
15102
16726
|
const doc = trim(m[2]);
|
|
@@ -15112,7 +16736,7 @@ var parseCss = (css, filePath) => {
|
|
|
15112
16736
|
};
|
|
15113
16737
|
const atfontface = () => {
|
|
15114
16738
|
const pos = position();
|
|
15115
|
-
const m =
|
|
16739
|
+
const m = match2(/^@font-face\s*/);
|
|
15116
16740
|
if (!m) return null;
|
|
15117
16741
|
if (!open()) return error(`@font-face missing '{'`);
|
|
15118
16742
|
let decls = comments();
|
|
@@ -15131,7 +16755,7 @@ var parseCss = (css, filePath) => {
|
|
|
15131
16755
|
const re = new RegExp("^@" + nodeName + "\\s*([^;]+);");
|
|
15132
16756
|
return () => {
|
|
15133
16757
|
const pos = position();
|
|
15134
|
-
const m =
|
|
16758
|
+
const m = match2(re);
|
|
15135
16759
|
if (!m) return null;
|
|
15136
16760
|
const node = {
|
|
15137
16761
|
type: nodeType
|
|
@@ -15142,20 +16766,69 @@ var parseCss = (css, filePath) => {
|
|
|
15142
16766
|
};
|
|
15143
16767
|
const atimport = compileAtrule("import", 7 /* Import */);
|
|
15144
16768
|
const atcharset = compileAtrule("charset", 0 /* Charset */);
|
|
15145
|
-
const atnamespace = compileAtrule("namespace",
|
|
16769
|
+
const atnamespace = compileAtrule("namespace", 12 /* Namespace */);
|
|
15146
16770
|
const atrule = () => {
|
|
15147
16771
|
if (css[0] !== "@") return null;
|
|
15148
|
-
return atkeyframes() ||
|
|
16772
|
+
return atkeyframes() || atquery("media") || atquery("container") || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
|
|
15149
16773
|
};
|
|
15150
16774
|
const rule = () => {
|
|
15151
16775
|
const pos = position();
|
|
15152
16776
|
const sel = selector();
|
|
15153
16777
|
if (!sel) return error("selector missing");
|
|
15154
16778
|
comments();
|
|
16779
|
+
if (!open()) return error(`missing '{'`);
|
|
16780
|
+
const decls = [];
|
|
16781
|
+
const nestedRules = [];
|
|
16782
|
+
comments(decls);
|
|
16783
|
+
while (css.length && css.charAt(0) !== "}") {
|
|
16784
|
+
whitespace();
|
|
16785
|
+
if (!css.length || css.charAt(0) === "}") {
|
|
16786
|
+
break;
|
|
16787
|
+
}
|
|
16788
|
+
const nextChar = css.charAt(0);
|
|
16789
|
+
if (nextChar === "@") {
|
|
16790
|
+
const nestedAt = nestedAtrule();
|
|
16791
|
+
if (nestedAt) {
|
|
16792
|
+
nestedRules.push(nestedAt);
|
|
16793
|
+
comments(nestedRules);
|
|
16794
|
+
continue;
|
|
16795
|
+
}
|
|
16796
|
+
}
|
|
16797
|
+
if (nextChar === "&" || nextChar === ":" || /[a-zA-Z\.\#\[]/.test(nextChar)) {
|
|
16798
|
+
let hasOpenBrace = false;
|
|
16799
|
+
if (nextChar === "&" || nextChar === ":") {
|
|
16800
|
+
const lookAhead = css.match(/^[^{}]+/);
|
|
16801
|
+
hasOpenBrace = lookAhead && css[lookAhead[0].length] === "{";
|
|
16802
|
+
} else {
|
|
16803
|
+
const lookAhead = css.match(/^[^{};]+/);
|
|
16804
|
+
if (lookAhead) {
|
|
16805
|
+
const nextSigChar = css[lookAhead[0].length];
|
|
16806
|
+
hasOpenBrace = nextSigChar === "{";
|
|
16807
|
+
}
|
|
16808
|
+
}
|
|
16809
|
+
if (hasOpenBrace) {
|
|
16810
|
+
const nestedRule = rule();
|
|
16811
|
+
if (nestedRule) {
|
|
16812
|
+
nestedRules.push(nestedRule);
|
|
16813
|
+
comments(nestedRules);
|
|
16814
|
+
continue;
|
|
16815
|
+
}
|
|
16816
|
+
}
|
|
16817
|
+
}
|
|
16818
|
+
const decl = declaration();
|
|
16819
|
+
if (decl) {
|
|
16820
|
+
decls.push(decl);
|
|
16821
|
+
comments(decls);
|
|
16822
|
+
continue;
|
|
16823
|
+
}
|
|
16824
|
+
break;
|
|
16825
|
+
}
|
|
16826
|
+
if (!close()) return error(`missing '}'`);
|
|
15155
16827
|
return pos({
|
|
15156
|
-
type:
|
|
16828
|
+
type: 14 /* Rule */,
|
|
15157
16829
|
selectors: sel,
|
|
15158
|
-
declarations:
|
|
16830
|
+
declarations: decls,
|
|
16831
|
+
rules: nestedRules.length > 0 ? nestedRules : null
|
|
15159
16832
|
});
|
|
15160
16833
|
};
|
|
15161
16834
|
class ParsePosition {
|
|
@@ -15258,7 +16931,7 @@ var serializeCssVisitNode = (opts, node, index, len) => {
|
|
|
15258
16931
|
if (nodeType === 4 /* Declaration */) {
|
|
15259
16932
|
return serializeCssDeclaration(node, index, len);
|
|
15260
16933
|
}
|
|
15261
|
-
if (nodeType ===
|
|
16934
|
+
if (nodeType === 14 /* Rule */) {
|
|
15262
16935
|
return serializeCssRule(opts, node);
|
|
15263
16936
|
}
|
|
15264
16937
|
if (nodeType === 1 /* Comment */) {
|
|
@@ -15271,6 +16944,9 @@ var serializeCssVisitNode = (opts, node, index, len) => {
|
|
|
15271
16944
|
if (nodeType === 10 /* Media */) {
|
|
15272
16945
|
return serializeCssMedia(opts, node);
|
|
15273
16946
|
}
|
|
16947
|
+
if (nodeType === 11 /* Container */) {
|
|
16948
|
+
return serializeCssContainer(opts, node);
|
|
16949
|
+
}
|
|
15274
16950
|
if (nodeType === 8 /* KeyFrames */) {
|
|
15275
16951
|
return serializeCssKeyframes(opts, node);
|
|
15276
16952
|
}
|
|
@@ -15280,7 +16956,7 @@ var serializeCssVisitNode = (opts, node, index, len) => {
|
|
|
15280
16956
|
if (nodeType === 5 /* FontFace */) {
|
|
15281
16957
|
return serializeCssFontFace(opts, node);
|
|
15282
16958
|
}
|
|
15283
|
-
if (nodeType ===
|
|
16959
|
+
if (nodeType === 16 /* Supports */) {
|
|
15284
16960
|
return serializeCssSupports(opts, node);
|
|
15285
16961
|
}
|
|
15286
16962
|
if (nodeType === 7 /* Import */) {
|
|
@@ -15289,7 +16965,7 @@ var serializeCssVisitNode = (opts, node, index, len) => {
|
|
|
15289
16965
|
if (nodeType === 0 /* Charset */) {
|
|
15290
16966
|
return "@charset " + node.charset + ";";
|
|
15291
16967
|
}
|
|
15292
|
-
if (nodeType ===
|
|
16968
|
+
if (nodeType === 13 /* Page */) {
|
|
15293
16969
|
return serializeCssPage(opts, node);
|
|
15294
16970
|
}
|
|
15295
16971
|
if (nodeType === 6 /* Host */) {
|
|
@@ -15301,7 +16977,7 @@ var serializeCssVisitNode = (opts, node, index, len) => {
|
|
|
15301
16977
|
if (nodeType === 3 /* Document */) {
|
|
15302
16978
|
return serializeCssDocument(opts, node);
|
|
15303
16979
|
}
|
|
15304
|
-
if (nodeType ===
|
|
16980
|
+
if (nodeType === 12 /* Namespace */) {
|
|
15305
16981
|
return "@namespace " + node.namespace + ";";
|
|
15306
16982
|
}
|
|
15307
16983
|
return "";
|
|
@@ -15311,7 +16987,9 @@ var serializeCssRule = (opts, node) => {
|
|
|
15311
16987
|
const decls = node.declarations;
|
|
15312
16988
|
const usedSelectors = opts.usedSelectors;
|
|
15313
16989
|
const selectors = (_b = (_a2 = node.selectors) == null ? void 0 : _a2.slice()) != null ? _b : [];
|
|
15314
|
-
|
|
16990
|
+
const hasDecls = decls != null && decls.length > 0;
|
|
16991
|
+
const hasNestedRules = node.rules != null && node.rules.length > 0;
|
|
16992
|
+
if (!hasDecls && !hasNestedRules) {
|
|
15315
16993
|
return "";
|
|
15316
16994
|
}
|
|
15317
16995
|
if (usedSelectors) {
|
|
@@ -15381,7 +17059,12 @@ var serializeCssRule = (opts, node) => {
|
|
|
15381
17059
|
}
|
|
15382
17060
|
}
|
|
15383
17061
|
}
|
|
15384
|
-
|
|
17062
|
+
let declsCss = decls && decls.length > 0 ? serializeCssMapVisit(opts, decls) : "";
|
|
17063
|
+
const nestedRulesCss = node.rules ? serializeCssMapVisit(opts, node.rules) : "";
|
|
17064
|
+
if (declsCss && nestedRulesCss && declsCss.length > 0) {
|
|
17065
|
+
declsCss += ";";
|
|
17066
|
+
}
|
|
17067
|
+
return `${cleanedSelectors}{${declsCss}${nestedRulesCss}}`;
|
|
15385
17068
|
};
|
|
15386
17069
|
var serializeCssDeclaration = (node, index, len) => {
|
|
15387
17070
|
if (node.value === "") {
|
|
@@ -15393,7 +17076,7 @@ var serializeCssDeclaration = (node, index, len) => {
|
|
|
15393
17076
|
return node.property + ":" + node.value + ";";
|
|
15394
17077
|
};
|
|
15395
17078
|
var serializeCssMedia = (opts, node) => {
|
|
15396
|
-
const mediaCss = serializeCssMapVisit(opts, node.rules);
|
|
17079
|
+
const mediaCss = node.declarations ? serializeCssMapVisit(opts, node.declarations) : serializeCssMapVisit(opts, node.rules);
|
|
15397
17080
|
if (mediaCss === "") {
|
|
15398
17081
|
return "";
|
|
15399
17082
|
}
|
|
@@ -15418,12 +17101,19 @@ var serializeCssFontFace = (opts, node) => {
|
|
|
15418
17101
|
return "@font-face{" + fontCss + "}";
|
|
15419
17102
|
};
|
|
15420
17103
|
var serializeCssSupports = (opts, node) => {
|
|
15421
|
-
const supportsCss = serializeCssMapVisit(opts, node.rules);
|
|
17104
|
+
const supportsCss = node.declarations ? serializeCssMapVisit(opts, node.declarations) : serializeCssMapVisit(opts, node.rules);
|
|
15422
17105
|
if (supportsCss === "") {
|
|
15423
17106
|
return "";
|
|
15424
17107
|
}
|
|
15425
17108
|
return "@supports " + node.supports + "{" + supportsCss + "}";
|
|
15426
17109
|
};
|
|
17110
|
+
var serializeCssContainer = (opts, node) => {
|
|
17111
|
+
const containerCss = node.declarations ? serializeCssMapVisit(opts, node.declarations) : serializeCssMapVisit(opts, node.rules);
|
|
17112
|
+
if (containerCss === "") {
|
|
17113
|
+
return "";
|
|
17114
|
+
}
|
|
17115
|
+
return "@container " + removeMediaWhitespace(node.media) + "{" + containerCss + "}";
|
|
17116
|
+
};
|
|
15427
17117
|
var serializeCssPage = (opts, node) => {
|
|
15428
17118
|
var _a2, _b;
|
|
15429
17119
|
const sel = (_b = (_a2 = node.selectors) == null ? void 0 : _a2.join(", ")) != null ? _b : "";
|