@powerlines/plugin-rspack 0.5.298 → 0.5.300

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