@powerlines/plugin-rspack 0.5.261 → 0.5.263
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/dist/_virtual/rolldown_runtime.cjs +31 -0
- package/dist/_virtual/rolldown_runtime.mjs +32 -0
- package/dist/helpers/index.cjs +2 -3
- package/dist/helpers/index.d.cts +1 -3
- package/dist/helpers/index.d.mts +1 -3
- package/dist/helpers/index.mjs +1 -2
- package/dist/helpers/unplugin.cjs +10 -2
- package/dist/helpers/unplugin.d.cts +8 -3
- package/dist/helpers/unplugin.d.cts.map +1 -0
- package/dist/helpers/unplugin.d.mts +8 -3
- package/dist/helpers/unplugin.d.mts.map +1 -0
- package/dist/helpers/unplugin.mjs +10 -2
- package/dist/helpers/unplugin.mjs.map +1 -0
- package/dist/index.cjs +6 -7
- package/dist/index.d.cts +4 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +2 -4
- package/dist/index.mjs.map +1 -1
- package/dist/node_modules/.pnpm/@jridgewell_gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.cjs +2 -0
- package/dist/node_modules/.pnpm/@jridgewell_gen-mapping@0.3.13/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.mjs +4 -0
- package/dist/node_modules/.pnpm/@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.cjs +2 -0
- package/dist/node_modules/.pnpm/@jridgewell_remapping@2.3.5/node_modules/@jridgewell/remapping/dist/remapping.mjs +4 -0
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +15 -0
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +16 -0
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@jridgewell_trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.cjs +1 -0
- package/dist/node_modules/.pnpm/@jridgewell_trace-mapping@0.3.31/node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs +3 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.cjs +28 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.mjs +24 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.cjs +175 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.mjs +171 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.mjs.map +1 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.cjs +871 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.mjs +867 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.mjs.map +1 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.cjs +307 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.mjs +303 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.mjs.map +1 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.cjs +300 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.mjs +296 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.mjs.map +1 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.cjs +60 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.mjs +56 -0
- package/dist/node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.mjs.map +1 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.cjs +46 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.mjs +45 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/context-CehLHpzV.mjs.map +1 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.cjs +142 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.mjs +141 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.cjs +114 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.mjs +113 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/parse-CRORloGP.mjs.map +1 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.cjs +59 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.mjs +55 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/utils-CuyC8gTr.mjs.map +1 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.cjs +35 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.mjs +34 -0
- package/dist/node_modules/.pnpm/unplugin@3.0.0-beta.3/node_modules/unplugin/dist/webpack-like-BU9ULG6P.mjs.map +1 -0
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.cjs +236 -0
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.mjs +232 -0
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/index.mjs.map +1 -0
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.cjs +54 -0
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.mjs +50 -0
- package/dist/node_modules/.pnpm/webpack-virtual-modules@0.6.2/node_modules/webpack-virtual-modules/lib/virtual-stats.mjs.map +1 -0
- package/dist/types/index.cjs +0 -2
- package/dist/types/index.d.cts +1 -2
- package/dist/types/index.d.mts +1 -2
- package/dist/types/index.mjs +0 -3
- package/dist/types/plugin.cjs +0 -1
- package/dist/types/plugin.d.cts +14 -2
- package/dist/types/plugin.d.cts.map +1 -0
- package/dist/types/plugin.d.mts +14 -2
- package/dist/types/plugin.d.mts.map +1 -0
- package/dist/types/plugin.mjs +0 -2
- package/package.json +8 -8
- package/dist/helpers-B15z10jN.mjs +0 -1
- package/dist/helpers-LF26RHol.cjs +0 -0
- package/dist/index-9iG2qHLe.d.mts +0 -1
- package/dist/index-D4ELpJXS.d.cts +0 -1
- package/dist/index-D6CnpA_r.d.cts +0 -1
- package/dist/index-DL0uimUT.d.mts +0 -1
- package/dist/plugin-Bba7oDr4.d.cts +0 -14
- package/dist/plugin-Bba7oDr4.d.cts.map +0 -1
- package/dist/plugin-ifZVa20V.mjs +0 -1
- package/dist/plugin-pBKbb5K9.cjs +0 -0
- package/dist/plugin-wK3Y5uKl.d.mts +0 -14
- package/dist/plugin-wK3Y5uKl.d.mts.map +0 -1
- package/dist/types-U3zd8PTP.mjs +0 -1
- package/dist/types-o3zWarRp.cjs +0 -0
- package/dist/unplugin-BNXnCNtR.mjs +0 -2349
- package/dist/unplugin-BNXnCNtR.mjs.map +0 -1
- package/dist/unplugin-BxYrF3Ze.d.cts +0 -8
- package/dist/unplugin-BxYrF3Ze.d.cts.map +0 -1
- package/dist/unplugin-C-ffDFJ6.cjs +0 -2359
- package/dist/unplugin-Cxu6PlCY.d.mts +0 -8
- package/dist/unplugin-Cxu6PlCY.d.mts.map +0 -1
|
@@ -0,0 +1,867 @@
|
|
|
1
|
+
import { __commonJSMin } from "../../../../../../_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { require_constants } from "./constants.mjs";
|
|
3
|
+
import { require_utils } from "./utils.mjs";
|
|
4
|
+
|
|
5
|
+
//#region ../../node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
6
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
7
|
+
const constants = require_constants();
|
|
8
|
+
const utils = require_utils();
|
|
9
|
+
/**
|
|
10
|
+
* Constants
|
|
11
|
+
*/
|
|
12
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
13
|
+
/**
|
|
14
|
+
* Helpers
|
|
15
|
+
*/
|
|
16
|
+
const expandRange = (args, options) => {
|
|
17
|
+
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
|
|
18
|
+
args.sort();
|
|
19
|
+
const value = `[${args.join("-")}]`;
|
|
20
|
+
try {
|
|
21
|
+
new RegExp(value);
|
|
22
|
+
} catch (ex) {
|
|
23
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Create the message for a syntax error
|
|
29
|
+
*/
|
|
30
|
+
const syntaxError = (type, char) => {
|
|
31
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Parse the given input string.
|
|
35
|
+
* @param {String} input
|
|
36
|
+
* @param {Object} options
|
|
37
|
+
* @return {Object}
|
|
38
|
+
*/
|
|
39
|
+
const parse = (input, options) => {
|
|
40
|
+
if (typeof input !== "string") throw new TypeError("Expected a string");
|
|
41
|
+
input = REPLACEMENTS[input] || input;
|
|
42
|
+
const opts = { ...options };
|
|
43
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
44
|
+
let len = input.length;
|
|
45
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
46
|
+
const bos = {
|
|
47
|
+
type: "bos",
|
|
48
|
+
value: "",
|
|
49
|
+
output: opts.prepend || ""
|
|
50
|
+
};
|
|
51
|
+
const tokens = [bos];
|
|
52
|
+
const capture = opts.capture ? "" : "?:";
|
|
53
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
54
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
55
|
+
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
56
|
+
const globstar = (opts$1) => {
|
|
57
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
58
|
+
};
|
|
59
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
60
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
61
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
62
|
+
if (opts.capture) star = `(${star})`;
|
|
63
|
+
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
|
|
64
|
+
const state = {
|
|
65
|
+
input,
|
|
66
|
+
index: -1,
|
|
67
|
+
start: 0,
|
|
68
|
+
dot: opts.dot === true,
|
|
69
|
+
consumed: "",
|
|
70
|
+
output: "",
|
|
71
|
+
prefix: "",
|
|
72
|
+
backtrack: false,
|
|
73
|
+
negated: false,
|
|
74
|
+
brackets: 0,
|
|
75
|
+
braces: 0,
|
|
76
|
+
parens: 0,
|
|
77
|
+
quotes: 0,
|
|
78
|
+
globstar: false,
|
|
79
|
+
tokens
|
|
80
|
+
};
|
|
81
|
+
input = utils.removePrefix(input, state);
|
|
82
|
+
len = input.length;
|
|
83
|
+
const extglobs = [];
|
|
84
|
+
const braces = [];
|
|
85
|
+
const stack = [];
|
|
86
|
+
let prev = bos;
|
|
87
|
+
let value;
|
|
88
|
+
/**
|
|
89
|
+
* Tokenizing helpers
|
|
90
|
+
*/
|
|
91
|
+
const eos = () => state.index === len - 1;
|
|
92
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
93
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
94
|
+
const remaining = () => input.slice(state.index + 1);
|
|
95
|
+
const consume = (value$1 = "", num = 0) => {
|
|
96
|
+
state.consumed += value$1;
|
|
97
|
+
state.index += num;
|
|
98
|
+
};
|
|
99
|
+
const append = (token) => {
|
|
100
|
+
state.output += token.output != null ? token.output : token.value;
|
|
101
|
+
consume(token.value);
|
|
102
|
+
};
|
|
103
|
+
const negate = () => {
|
|
104
|
+
let count = 1;
|
|
105
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
106
|
+
advance();
|
|
107
|
+
state.start++;
|
|
108
|
+
count++;
|
|
109
|
+
}
|
|
110
|
+
if (count % 2 === 0) return false;
|
|
111
|
+
state.negated = true;
|
|
112
|
+
state.start++;
|
|
113
|
+
return true;
|
|
114
|
+
};
|
|
115
|
+
const increment = (type) => {
|
|
116
|
+
state[type]++;
|
|
117
|
+
stack.push(type);
|
|
118
|
+
};
|
|
119
|
+
const decrement = (type) => {
|
|
120
|
+
state[type]--;
|
|
121
|
+
stack.pop();
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
125
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
126
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
127
|
+
* characters are plain text. This improves performance and simplifies
|
|
128
|
+
* lookbehinds.
|
|
129
|
+
*/
|
|
130
|
+
const push = (tok) => {
|
|
131
|
+
if (prev.type === "globstar") {
|
|
132
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
133
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
134
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
135
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
136
|
+
prev.type = "star";
|
|
137
|
+
prev.value = "*";
|
|
138
|
+
prev.output = star;
|
|
139
|
+
state.output += prev.output;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
|
|
143
|
+
if (tok.value || tok.output) append(tok);
|
|
144
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
145
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
146
|
+
prev.value += tok.value;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
tok.prev = prev;
|
|
150
|
+
tokens.push(tok);
|
|
151
|
+
prev = tok;
|
|
152
|
+
};
|
|
153
|
+
const extglobOpen = (type, value$1) => {
|
|
154
|
+
const token = {
|
|
155
|
+
...EXTGLOB_CHARS[value$1],
|
|
156
|
+
conditions: 1,
|
|
157
|
+
inner: ""
|
|
158
|
+
};
|
|
159
|
+
token.prev = prev;
|
|
160
|
+
token.parens = state.parens;
|
|
161
|
+
token.output = state.output;
|
|
162
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
163
|
+
increment("parens");
|
|
164
|
+
push({
|
|
165
|
+
type,
|
|
166
|
+
value: value$1,
|
|
167
|
+
output: state.output ? "" : ONE_CHAR
|
|
168
|
+
});
|
|
169
|
+
push({
|
|
170
|
+
type: "paren",
|
|
171
|
+
extglob: true,
|
|
172
|
+
value: advance(),
|
|
173
|
+
output
|
|
174
|
+
});
|
|
175
|
+
extglobs.push(token);
|
|
176
|
+
};
|
|
177
|
+
const extglobClose = (token) => {
|
|
178
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
179
|
+
let rest;
|
|
180
|
+
if (token.type === "negate") {
|
|
181
|
+
let extglobStar = star;
|
|
182
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
|
|
183
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
184
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
|
|
185
|
+
...options,
|
|
186
|
+
fastpaths: false
|
|
187
|
+
}).output})${extglobStar})`;
|
|
188
|
+
if (token.prev.type === "bos") state.negatedExtglob = true;
|
|
189
|
+
}
|
|
190
|
+
push({
|
|
191
|
+
type: "paren",
|
|
192
|
+
extglob: true,
|
|
193
|
+
value,
|
|
194
|
+
output
|
|
195
|
+
});
|
|
196
|
+
decrement("parens");
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* Fast paths
|
|
200
|
+
*/
|
|
201
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
202
|
+
let backslashes = false;
|
|
203
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
204
|
+
if (first === "\\") {
|
|
205
|
+
backslashes = true;
|
|
206
|
+
return m;
|
|
207
|
+
}
|
|
208
|
+
if (first === "?") {
|
|
209
|
+
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
210
|
+
if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
211
|
+
return QMARK.repeat(chars.length);
|
|
212
|
+
}
|
|
213
|
+
if (first === ".") return DOT_LITERAL.repeat(chars.length);
|
|
214
|
+
if (first === "*") {
|
|
215
|
+
if (esc) return esc + first + (rest ? star : "");
|
|
216
|
+
return star;
|
|
217
|
+
}
|
|
218
|
+
return esc ? m : `\\${m}`;
|
|
219
|
+
});
|
|
220
|
+
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
221
|
+
else output = output.replace(/\\+/g, (m) => {
|
|
222
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
223
|
+
});
|
|
224
|
+
if (output === input && opts.contains === true) {
|
|
225
|
+
state.output = input;
|
|
226
|
+
return state;
|
|
227
|
+
}
|
|
228
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
229
|
+
return state;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Tokenize input until we reach end-of-string
|
|
233
|
+
*/
|
|
234
|
+
while (!eos()) {
|
|
235
|
+
value = advance();
|
|
236
|
+
if (value === "\0") continue;
|
|
237
|
+
/**
|
|
238
|
+
* Escaped characters
|
|
239
|
+
*/
|
|
240
|
+
if (value === "\\") {
|
|
241
|
+
const next = peek();
|
|
242
|
+
if (next === "/" && opts.bash !== true) continue;
|
|
243
|
+
if (next === "." || next === ";") continue;
|
|
244
|
+
if (!next) {
|
|
245
|
+
value += "\\";
|
|
246
|
+
push({
|
|
247
|
+
type: "text",
|
|
248
|
+
value
|
|
249
|
+
});
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const match = /^\\+/.exec(remaining());
|
|
253
|
+
let slashes = 0;
|
|
254
|
+
if (match && match[0].length > 2) {
|
|
255
|
+
slashes = match[0].length;
|
|
256
|
+
state.index += slashes;
|
|
257
|
+
if (slashes % 2 !== 0) value += "\\";
|
|
258
|
+
}
|
|
259
|
+
if (opts.unescape === true) value = advance();
|
|
260
|
+
else value += advance();
|
|
261
|
+
if (state.brackets === 0) {
|
|
262
|
+
push({
|
|
263
|
+
type: "text",
|
|
264
|
+
value
|
|
265
|
+
});
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* If we're inside a regex character class, continue
|
|
271
|
+
* until we reach the closing bracket.
|
|
272
|
+
*/
|
|
273
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
274
|
+
if (opts.posix !== false && value === ":") {
|
|
275
|
+
const inner = prev.value.slice(1);
|
|
276
|
+
if (inner.includes("[")) {
|
|
277
|
+
prev.posix = true;
|
|
278
|
+
if (inner.includes(":")) {
|
|
279
|
+
const idx = prev.value.lastIndexOf("[");
|
|
280
|
+
const pre = prev.value.slice(0, idx);
|
|
281
|
+
const posix = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
|
|
282
|
+
if (posix) {
|
|
283
|
+
prev.value = pre + posix;
|
|
284
|
+
state.backtrack = true;
|
|
285
|
+
advance();
|
|
286
|
+
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
|
|
293
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
|
|
294
|
+
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
|
|
295
|
+
prev.value += value;
|
|
296
|
+
append({ value });
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* If we're inside a quoted string, continue
|
|
301
|
+
* until we reach the closing double quote.
|
|
302
|
+
*/
|
|
303
|
+
if (state.quotes === 1 && value !== "\"") {
|
|
304
|
+
value = utils.escapeRegex(value);
|
|
305
|
+
prev.value += value;
|
|
306
|
+
append({ value });
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Double quotes
|
|
311
|
+
*/
|
|
312
|
+
if (value === "\"") {
|
|
313
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
314
|
+
if (opts.keepQuotes === true) push({
|
|
315
|
+
type: "text",
|
|
316
|
+
value
|
|
317
|
+
});
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Parentheses
|
|
322
|
+
*/
|
|
323
|
+
if (value === "(") {
|
|
324
|
+
increment("parens");
|
|
325
|
+
push({
|
|
326
|
+
type: "paren",
|
|
327
|
+
value
|
|
328
|
+
});
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
if (value === ")") {
|
|
332
|
+
if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
|
|
333
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
334
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
335
|
+
extglobClose(extglobs.pop());
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
push({
|
|
339
|
+
type: "paren",
|
|
340
|
+
value,
|
|
341
|
+
output: state.parens ? ")" : "\\)"
|
|
342
|
+
});
|
|
343
|
+
decrement("parens");
|
|
344
|
+
continue;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Square brackets
|
|
348
|
+
*/
|
|
349
|
+
if (value === "[") {
|
|
350
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
351
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
352
|
+
value = `\\${value}`;
|
|
353
|
+
} else increment("brackets");
|
|
354
|
+
push({
|
|
355
|
+
type: "bracket",
|
|
356
|
+
value
|
|
357
|
+
});
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (value === "]") {
|
|
361
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
362
|
+
push({
|
|
363
|
+
type: "text",
|
|
364
|
+
value,
|
|
365
|
+
output: `\\${value}`
|
|
366
|
+
});
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (state.brackets === 0) {
|
|
370
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
|
|
371
|
+
push({
|
|
372
|
+
type: "text",
|
|
373
|
+
value,
|
|
374
|
+
output: `\\${value}`
|
|
375
|
+
});
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
decrement("brackets");
|
|
379
|
+
const prevValue = prev.value.slice(1);
|
|
380
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
|
|
381
|
+
prev.value += value;
|
|
382
|
+
append({ value });
|
|
383
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
|
|
384
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
385
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
386
|
+
if (opts.literalBrackets === true) {
|
|
387
|
+
state.output += escaped;
|
|
388
|
+
prev.value = escaped;
|
|
389
|
+
continue;
|
|
390
|
+
}
|
|
391
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
392
|
+
state.output += prev.value;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Braces
|
|
397
|
+
*/
|
|
398
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
399
|
+
increment("braces");
|
|
400
|
+
const open = {
|
|
401
|
+
type: "brace",
|
|
402
|
+
value,
|
|
403
|
+
output: "(",
|
|
404
|
+
outputIndex: state.output.length,
|
|
405
|
+
tokensIndex: state.tokens.length
|
|
406
|
+
};
|
|
407
|
+
braces.push(open);
|
|
408
|
+
push(open);
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
411
|
+
if (value === "}") {
|
|
412
|
+
const brace = braces[braces.length - 1];
|
|
413
|
+
if (opts.nobrace === true || !brace) {
|
|
414
|
+
push({
|
|
415
|
+
type: "text",
|
|
416
|
+
value,
|
|
417
|
+
output: value
|
|
418
|
+
});
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
let output = ")";
|
|
422
|
+
if (brace.dots === true) {
|
|
423
|
+
const arr = tokens.slice();
|
|
424
|
+
const range = [];
|
|
425
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
426
|
+
tokens.pop();
|
|
427
|
+
if (arr[i].type === "brace") break;
|
|
428
|
+
if (arr[i].type !== "dots") range.unshift(arr[i].value);
|
|
429
|
+
}
|
|
430
|
+
output = expandRange(range, opts);
|
|
431
|
+
state.backtrack = true;
|
|
432
|
+
}
|
|
433
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
434
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
435
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
436
|
+
brace.value = brace.output = "\\{";
|
|
437
|
+
value = output = "\\}";
|
|
438
|
+
state.output = out;
|
|
439
|
+
for (const t of toks) state.output += t.output || t.value;
|
|
440
|
+
}
|
|
441
|
+
push({
|
|
442
|
+
type: "brace",
|
|
443
|
+
value,
|
|
444
|
+
output
|
|
445
|
+
});
|
|
446
|
+
decrement("braces");
|
|
447
|
+
braces.pop();
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Pipes
|
|
452
|
+
*/
|
|
453
|
+
if (value === "|") {
|
|
454
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
455
|
+
push({
|
|
456
|
+
type: "text",
|
|
457
|
+
value
|
|
458
|
+
});
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Commas
|
|
463
|
+
*/
|
|
464
|
+
if (value === ",") {
|
|
465
|
+
let output = value;
|
|
466
|
+
const brace = braces[braces.length - 1];
|
|
467
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
468
|
+
brace.comma = true;
|
|
469
|
+
output = "|";
|
|
470
|
+
}
|
|
471
|
+
push({
|
|
472
|
+
type: "comma",
|
|
473
|
+
value,
|
|
474
|
+
output
|
|
475
|
+
});
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Slashes
|
|
480
|
+
*/
|
|
481
|
+
if (value === "/") {
|
|
482
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
483
|
+
state.start = state.index + 1;
|
|
484
|
+
state.consumed = "";
|
|
485
|
+
state.output = "";
|
|
486
|
+
tokens.pop();
|
|
487
|
+
prev = bos;
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
push({
|
|
491
|
+
type: "slash",
|
|
492
|
+
value,
|
|
493
|
+
output: SLASH_LITERAL
|
|
494
|
+
});
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Dots
|
|
499
|
+
*/
|
|
500
|
+
if (value === ".") {
|
|
501
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
502
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
503
|
+
const brace = braces[braces.length - 1];
|
|
504
|
+
prev.type = "dots";
|
|
505
|
+
prev.output += value;
|
|
506
|
+
prev.value += value;
|
|
507
|
+
brace.dots = true;
|
|
508
|
+
continue;
|
|
509
|
+
}
|
|
510
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
511
|
+
push({
|
|
512
|
+
type: "text",
|
|
513
|
+
value,
|
|
514
|
+
output: DOT_LITERAL
|
|
515
|
+
});
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
push({
|
|
519
|
+
type: "dot",
|
|
520
|
+
value,
|
|
521
|
+
output: DOT_LITERAL
|
|
522
|
+
});
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Question marks
|
|
527
|
+
*/
|
|
528
|
+
if (value === "?") {
|
|
529
|
+
if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
530
|
+
extglobOpen("qmark", value);
|
|
531
|
+
continue;
|
|
532
|
+
}
|
|
533
|
+
if (prev && prev.type === "paren") {
|
|
534
|
+
const next = peek();
|
|
535
|
+
let output = value;
|
|
536
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
537
|
+
push({
|
|
538
|
+
type: "text",
|
|
539
|
+
value,
|
|
540
|
+
output
|
|
541
|
+
});
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
545
|
+
push({
|
|
546
|
+
type: "qmark",
|
|
547
|
+
value,
|
|
548
|
+
output: QMARK_NO_DOT
|
|
549
|
+
});
|
|
550
|
+
continue;
|
|
551
|
+
}
|
|
552
|
+
push({
|
|
553
|
+
type: "qmark",
|
|
554
|
+
value,
|
|
555
|
+
output: QMARK
|
|
556
|
+
});
|
|
557
|
+
continue;
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Exclamation
|
|
561
|
+
*/
|
|
562
|
+
if (value === "!") {
|
|
563
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
564
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
565
|
+
extglobOpen("negate", value);
|
|
566
|
+
continue;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
570
|
+
negate();
|
|
571
|
+
continue;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Plus
|
|
576
|
+
*/
|
|
577
|
+
if (value === "+") {
|
|
578
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
579
|
+
extglobOpen("plus", value);
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
583
|
+
push({
|
|
584
|
+
type: "plus",
|
|
585
|
+
value,
|
|
586
|
+
output: PLUS_LITERAL
|
|
587
|
+
});
|
|
588
|
+
continue;
|
|
589
|
+
}
|
|
590
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
591
|
+
push({
|
|
592
|
+
type: "plus",
|
|
593
|
+
value
|
|
594
|
+
});
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
push({
|
|
598
|
+
type: "plus",
|
|
599
|
+
value: PLUS_LITERAL
|
|
600
|
+
});
|
|
601
|
+
continue;
|
|
602
|
+
}
|
|
603
|
+
/**
|
|
604
|
+
* Plain text
|
|
605
|
+
*/
|
|
606
|
+
if (value === "@") {
|
|
607
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
608
|
+
push({
|
|
609
|
+
type: "at",
|
|
610
|
+
extglob: true,
|
|
611
|
+
value,
|
|
612
|
+
output: ""
|
|
613
|
+
});
|
|
614
|
+
continue;
|
|
615
|
+
}
|
|
616
|
+
push({
|
|
617
|
+
type: "text",
|
|
618
|
+
value
|
|
619
|
+
});
|
|
620
|
+
continue;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Plain text
|
|
624
|
+
*/
|
|
625
|
+
if (value !== "*") {
|
|
626
|
+
if (value === "$" || value === "^") value = `\\${value}`;
|
|
627
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
628
|
+
if (match) {
|
|
629
|
+
value += match[0];
|
|
630
|
+
state.index += match[0].length;
|
|
631
|
+
}
|
|
632
|
+
push({
|
|
633
|
+
type: "text",
|
|
634
|
+
value
|
|
635
|
+
});
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Stars
|
|
640
|
+
*/
|
|
641
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
642
|
+
prev.type = "star";
|
|
643
|
+
prev.star = true;
|
|
644
|
+
prev.value += value;
|
|
645
|
+
prev.output = star;
|
|
646
|
+
state.backtrack = true;
|
|
647
|
+
state.globstar = true;
|
|
648
|
+
consume(value);
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
let rest = remaining();
|
|
652
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
653
|
+
extglobOpen("star", value);
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
if (prev.type === "star") {
|
|
657
|
+
if (opts.noglobstar === true) {
|
|
658
|
+
consume(value);
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
const prior = prev.prev;
|
|
662
|
+
const before = prior.prev;
|
|
663
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
664
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
665
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
666
|
+
push({
|
|
667
|
+
type: "star",
|
|
668
|
+
value,
|
|
669
|
+
output: ""
|
|
670
|
+
});
|
|
671
|
+
continue;
|
|
672
|
+
}
|
|
673
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
674
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
675
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
676
|
+
push({
|
|
677
|
+
type: "star",
|
|
678
|
+
value,
|
|
679
|
+
output: ""
|
|
680
|
+
});
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
while (rest.slice(0, 3) === "/**") {
|
|
684
|
+
const after = input[state.index + 4];
|
|
685
|
+
if (after && after !== "/") break;
|
|
686
|
+
rest = rest.slice(3);
|
|
687
|
+
consume("/**", 3);
|
|
688
|
+
}
|
|
689
|
+
if (prior.type === "bos" && eos()) {
|
|
690
|
+
prev.type = "globstar";
|
|
691
|
+
prev.value += value;
|
|
692
|
+
prev.output = globstar(opts);
|
|
693
|
+
state.output = prev.output;
|
|
694
|
+
state.globstar = true;
|
|
695
|
+
consume(value);
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
699
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
700
|
+
prior.output = `(?:${prior.output}`;
|
|
701
|
+
prev.type = "globstar";
|
|
702
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
703
|
+
prev.value += value;
|
|
704
|
+
state.globstar = true;
|
|
705
|
+
state.output += prior.output + prev.output;
|
|
706
|
+
consume(value);
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
710
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
711
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
712
|
+
prior.output = `(?:${prior.output}`;
|
|
713
|
+
prev.type = "globstar";
|
|
714
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
715
|
+
prev.value += value;
|
|
716
|
+
state.output += prior.output + prev.output;
|
|
717
|
+
state.globstar = true;
|
|
718
|
+
consume(value + advance());
|
|
719
|
+
push({
|
|
720
|
+
type: "slash",
|
|
721
|
+
value: "/",
|
|
722
|
+
output: ""
|
|
723
|
+
});
|
|
724
|
+
continue;
|
|
725
|
+
}
|
|
726
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
727
|
+
prev.type = "globstar";
|
|
728
|
+
prev.value += value;
|
|
729
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
730
|
+
state.output = prev.output;
|
|
731
|
+
state.globstar = true;
|
|
732
|
+
consume(value + advance());
|
|
733
|
+
push({
|
|
734
|
+
type: "slash",
|
|
735
|
+
value: "/",
|
|
736
|
+
output: ""
|
|
737
|
+
});
|
|
738
|
+
continue;
|
|
739
|
+
}
|
|
740
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
741
|
+
prev.type = "globstar";
|
|
742
|
+
prev.output = globstar(opts);
|
|
743
|
+
prev.value += value;
|
|
744
|
+
state.output += prev.output;
|
|
745
|
+
state.globstar = true;
|
|
746
|
+
consume(value);
|
|
747
|
+
continue;
|
|
748
|
+
}
|
|
749
|
+
const token = {
|
|
750
|
+
type: "star",
|
|
751
|
+
value,
|
|
752
|
+
output: star
|
|
753
|
+
};
|
|
754
|
+
if (opts.bash === true) {
|
|
755
|
+
token.output = ".*?";
|
|
756
|
+
if (prev.type === "bos" || prev.type === "slash") token.output = nodot + token.output;
|
|
757
|
+
push(token);
|
|
758
|
+
continue;
|
|
759
|
+
}
|
|
760
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
761
|
+
token.output = value;
|
|
762
|
+
push(token);
|
|
763
|
+
continue;
|
|
764
|
+
}
|
|
765
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
766
|
+
if (prev.type === "dot") {
|
|
767
|
+
state.output += NO_DOT_SLASH;
|
|
768
|
+
prev.output += NO_DOT_SLASH;
|
|
769
|
+
} else if (opts.dot === true) {
|
|
770
|
+
state.output += NO_DOTS_SLASH;
|
|
771
|
+
prev.output += NO_DOTS_SLASH;
|
|
772
|
+
} else {
|
|
773
|
+
state.output += nodot;
|
|
774
|
+
prev.output += nodot;
|
|
775
|
+
}
|
|
776
|
+
if (peek() !== "*") {
|
|
777
|
+
state.output += ONE_CHAR;
|
|
778
|
+
prev.output += ONE_CHAR;
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
push(token);
|
|
782
|
+
}
|
|
783
|
+
while (state.brackets > 0) {
|
|
784
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
785
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
786
|
+
decrement("brackets");
|
|
787
|
+
}
|
|
788
|
+
while (state.parens > 0) {
|
|
789
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
790
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
791
|
+
decrement("parens");
|
|
792
|
+
}
|
|
793
|
+
while (state.braces > 0) {
|
|
794
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
795
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
796
|
+
decrement("braces");
|
|
797
|
+
}
|
|
798
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
|
|
799
|
+
type: "maybe_slash",
|
|
800
|
+
value: "",
|
|
801
|
+
output: `${SLASH_LITERAL}?`
|
|
802
|
+
});
|
|
803
|
+
if (state.backtrack === true) {
|
|
804
|
+
state.output = "";
|
|
805
|
+
for (const token of state.tokens) {
|
|
806
|
+
state.output += token.output != null ? token.output : token.value;
|
|
807
|
+
if (token.suffix) state.output += token.suffix;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return state;
|
|
811
|
+
};
|
|
812
|
+
/**
|
|
813
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
814
|
+
* This can significantly speed up processing and has very little downside
|
|
815
|
+
* impact when none of the fast paths match.
|
|
816
|
+
*/
|
|
817
|
+
parse.fastpaths = (input, options) => {
|
|
818
|
+
const opts = { ...options };
|
|
819
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
820
|
+
const len = input.length;
|
|
821
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
822
|
+
input = REPLACEMENTS[input] || input;
|
|
823
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
824
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
825
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
826
|
+
const capture = opts.capture ? "" : "?:";
|
|
827
|
+
const state = {
|
|
828
|
+
negated: false,
|
|
829
|
+
prefix: ""
|
|
830
|
+
};
|
|
831
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
832
|
+
if (opts.capture) star = `(${star})`;
|
|
833
|
+
const globstar = (opts$1) => {
|
|
834
|
+
if (opts$1.noglobstar === true) return star;
|
|
835
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
836
|
+
};
|
|
837
|
+
const create = (str) => {
|
|
838
|
+
switch (str) {
|
|
839
|
+
case "*": return `${nodot}${ONE_CHAR}${star}`;
|
|
840
|
+
case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
841
|
+
case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
842
|
+
case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
843
|
+
case "**": return nodot + globstar(opts);
|
|
844
|
+
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
845
|
+
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
846
|
+
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
847
|
+
default: {
|
|
848
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
849
|
+
if (!match) return;
|
|
850
|
+
const source$1 = create(match[1]);
|
|
851
|
+
if (!source$1) return;
|
|
852
|
+
return source$1 + DOT_LITERAL + match[2];
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
let source = create(utils.removePrefix(input, state));
|
|
857
|
+
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
|
|
858
|
+
return source;
|
|
859
|
+
};
|
|
860
|
+
module.exports = parse;
|
|
861
|
+
}));
|
|
862
|
+
|
|
863
|
+
//#endregion
|
|
864
|
+
export default require_parse();
|
|
865
|
+
|
|
866
|
+
export { require_parse };
|
|
867
|
+
//# sourceMappingURL=parse.mjs.map
|