@rspress/core 2.0.16 → 2.0.18
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/bin/rspress.js +6 -1
- package/dist/0~execa.js +1 -1
- package/dist/{9882.js → 102.js} +1 -1
- package/dist/{9958.js → 3553.js} +2 -2
- package/dist/{5580.js → 5871.js} +2455 -6
- package/dist/cli/index.d.ts +8 -1
- package/dist/cli/index.js +105 -102
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/DocContent/docComponents/title.tsx +1 -1
- package/dist/eject-theme/components/HomeFeature/index.scss +1 -0
- package/dist/eject-theme/components/HomeFeature/index.tsx +1 -1
- package/dist/eject-theme/components/HoverGroup/index.scss +9 -0
- package/dist/eject-theme/components/Link/index.tsx +1 -1
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +17 -4
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +23 -0
- package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +15 -0
- package/dist/eject-theme/components/Llms/LlmsOpenRow.tsx +51 -64
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +65 -51
- package/dist/eject-theme/components/Llms/index.tsx +6 -1
- package/dist/eject-theme/components/Outline/index.tsx +1 -1
- package/dist/eject-theme/components/SocialLinks/GithubStars.test.tsx +48 -0
- package/dist/eject-theme/components/SocialLinks/GithubStars.tsx +35 -20
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +2 -2
- package/dist/node/auto-nav-sidebar/utils.js +1 -1
- package/dist/node/auto-nav-sidebar/walk.js +1 -1
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +2 -2
- package/dist/node/initRsbuild.js +19 -8
- package/dist/node/llms.d.ts +3 -0
- package/dist/node/llms.js +8 -0
- package/dist/node/logger/hint.js +1 -1
- package/dist/node/mdx/options.js +1 -1
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +2 -2
- package/dist/node/mdx/remarkPlugins/image.js +2 -2
- package/dist/node/mdx/remarkPlugins/link.js +2 -2
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/medium-zoom/index.js +1 -1
- package/dist/node/route/RoutePage.js +5 -3
- package/dist/node/route/RouteService.js +8 -3
- package/dist/node/route/extractPageData.js +1 -1
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/route/routeChunkAssets.d.ts +15 -0
- package/dist/node/route/routeChunkAssets.js +56 -0
- package/dist/node/runtimeModule/i18n.js +3 -3
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +6 -2
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/alternateLinks.d.ts +7 -0
- package/dist/node/ssg/alternateLinks.js +40 -0
- package/dist/node/ssg/htmlFile.js +1 -1
- package/dist/node/ssg/renderHtmlTemplate.d.ts +3 -1
- package/dist/node/ssg/renderHtmlTemplate.js +25 -3
- package/dist/node/ssg/renderPage.d.ts +3 -1
- package/dist/node/ssg/renderPage.js +4 -4
- package/dist/node/ssg/renderPageWorker.js +5 -5
- package/dist/node/ssg/renderPages.d.ts +3 -2
- package/dist/node/ssg/renderPages.js +16 -11
- package/dist/node/ssg/rsbuildPluginCSR.d.ts +3 -1
- package/dist/node/ssg/rsbuildPluginCSR.js +2 -2
- package/dist/node/ssg/rsbuildPluginSSG.d.ts +3 -1
- package/dist/node/ssg/rsbuildPluginSSG.js +3 -3
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +3 -3
- package/dist/node/ssg-md/llms/llmsTxt.d.ts +4 -4
- package/dist/node/ssg-md/llms/llmsTxt.js +54 -40
- package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
- package/dist/node/ssg-md/renderPage.js +2 -2
- package/dist/node/ssg-md/renderPages.js +3 -3
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.d.ts +1 -1
- package/dist/node/utils/createHash.js +3 -3
- package/dist/node/utils/error.js +1 -1
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +2 -2
- package/dist/runtime/App.js +2 -0
- package/dist/runtime/ClientApp.js +3 -2
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.js +1 -1
- package/dist/runtime/route.js +2 -0
- package/dist/runtime/utils.d.ts +2 -1
- package/dist/runtime/utils.js +5 -2
- package/dist/theme/assets/anthropic.js +15 -0
- package/dist/theme/assets/open-in-chat.js +19 -0
- package/dist/theme/assets/openai.js +15 -0
- package/dist/theme/components/DocContent/docComponents/index.d.ts +25 -18
- package/dist/theme/components/DocContent/docComponents/title.js +1 -1
- package/dist/theme/components/HomeFeature/index.css +1 -0
- package/dist/theme/components/HomeFeature/index.js +32 -34
- package/dist/theme/components/HoverGroup/index.css +7 -0
- package/dist/theme/components/Link/index.d.ts +1 -1
- package/dist/theme/components/Link/useLinkNavigate.d.ts +1 -1
- package/dist/theme/components/Link/useLinkNavigate.js +13 -5
- package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +1 -0
- package/dist/theme/components/Llms/LlmsHiddenHint.js +18 -0
- package/dist/theme/components/Llms/LlmsOpenRow.js +31 -57
- package/dist/theme/components/Llms/LlmsViewOptions.d.ts +6 -4
- package/dist/theme/components/Llms/LlmsViewOptions.js +28 -45
- package/dist/theme/components/Llms/index.d.ts +2 -1
- package/dist/theme/components/Llms/index.js +1 -0
- package/dist/theme/components/Outline/index.js +1 -1
- package/dist/theme/components/Search/SearchPanel.js +8 -8
- package/dist/theme/components/SocialLinks/GithubStars.js +27 -17
- package/dist/theme/icons.d.ts +4 -1
- package/dist/theme/icons.js +8 -2
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/logic/getCopyableText.js +1 -0
- package/package.json +11 -11
- package/dist/6010.js +0 -2461
- package/dist/{0~8787.js → 0~8016.js} +0 -0
- package/dist/{7986.js → 4538.js} +0 -0
- package/dist/{3358.js → 5357.js} +0 -0
- package/dist/{5580.js.LICENSE.txt → 5871.js.LICENSE.txt} +0 -0
- package/dist/{8005.js → 7748.js} +2 -2
- /package/dist/{6646.js → 9857.js} +0 -0
- /package/dist/{9283.js → 9940.js} +0 -0
package/dist/6010.js
DELETED
|
@@ -1,2461 +0,0 @@
|
|
|
1
|
-
import node_path, { extname, join, relative as external_node_path_relative } from "node:path";
|
|
2
|
-
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
|
-
import { fileURLToPath } from "url";
|
|
4
|
-
import { createRequire } from "module";
|
|
5
|
-
import * as __rspack_external_fs from "fs";
|
|
6
|
-
import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
|
|
7
|
-
import { basename, dirname, isAbsolute, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
|
|
8
|
-
import { createRequire as __rspack_createRequire } from "node:module";
|
|
9
|
-
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
10
|
-
__webpack_require__.add({
|
|
11
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
12
|
-
const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js");
|
|
13
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
14
|
-
function picomatch(glob, options, returnState = false) {
|
|
15
|
-
if (options && (null === options.windows || void 0 === options.windows)) options = {
|
|
16
|
-
...options,
|
|
17
|
-
windows: utils.isWindows()
|
|
18
|
-
};
|
|
19
|
-
return pico(glob, options, returnState);
|
|
20
|
-
}
|
|
21
|
-
Object.assign(picomatch, pico);
|
|
22
|
-
module.exports = picomatch;
|
|
23
|
-
},
|
|
24
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js" (module) {
|
|
25
|
-
const WIN_SLASH = '\\\\/';
|
|
26
|
-
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
27
|
-
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
28
|
-
const DOT_LITERAL = '\\.';
|
|
29
|
-
const PLUS_LITERAL = '\\+';
|
|
30
|
-
const QMARK_LITERAL = '\\?';
|
|
31
|
-
const SLASH_LITERAL = '\\/';
|
|
32
|
-
const ONE_CHAR = '(?=.)';
|
|
33
|
-
const QMARK = '[^/]';
|
|
34
|
-
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
35
|
-
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
36
|
-
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
37
|
-
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
38
|
-
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
39
|
-
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
40
|
-
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
41
|
-
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
42
|
-
const STAR = `${QMARK}*?`;
|
|
43
|
-
const SEP = '/';
|
|
44
|
-
const POSIX_CHARS = {
|
|
45
|
-
DOT_LITERAL,
|
|
46
|
-
PLUS_LITERAL,
|
|
47
|
-
QMARK_LITERAL,
|
|
48
|
-
SLASH_LITERAL,
|
|
49
|
-
ONE_CHAR,
|
|
50
|
-
QMARK,
|
|
51
|
-
END_ANCHOR,
|
|
52
|
-
DOTS_SLASH,
|
|
53
|
-
NO_DOT,
|
|
54
|
-
NO_DOTS,
|
|
55
|
-
NO_DOT_SLASH,
|
|
56
|
-
NO_DOTS_SLASH,
|
|
57
|
-
QMARK_NO_DOT,
|
|
58
|
-
STAR,
|
|
59
|
-
START_ANCHOR,
|
|
60
|
-
SEP
|
|
61
|
-
};
|
|
62
|
-
const WINDOWS_CHARS = {
|
|
63
|
-
...POSIX_CHARS,
|
|
64
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
65
|
-
QMARK: WIN_NO_SLASH,
|
|
66
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
67
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
68
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
69
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
70
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
71
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
72
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
73
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
74
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
75
|
-
SEP: '\\'
|
|
76
|
-
};
|
|
77
|
-
const POSIX_REGEX_SOURCE = {
|
|
78
|
-
__proto__: null,
|
|
79
|
-
alnum: 'a-zA-Z0-9',
|
|
80
|
-
alpha: 'a-zA-Z',
|
|
81
|
-
ascii: '\\x00-\\x7F',
|
|
82
|
-
blank: ' \\t',
|
|
83
|
-
cntrl: '\\x00-\\x1F\\x7F',
|
|
84
|
-
digit: '0-9',
|
|
85
|
-
graph: '\\x21-\\x7E',
|
|
86
|
-
lower: 'a-z',
|
|
87
|
-
print: '\\x20-\\x7E ',
|
|
88
|
-
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
89
|
-
space: ' \\t\\r\\n\\v\\f',
|
|
90
|
-
upper: 'A-Z',
|
|
91
|
-
word: 'A-Za-z0-9_',
|
|
92
|
-
xdigit: 'A-Fa-f0-9'
|
|
93
|
-
};
|
|
94
|
-
module.exports = {
|
|
95
|
-
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
96
|
-
MAX_LENGTH: 65536,
|
|
97
|
-
POSIX_REGEX_SOURCE,
|
|
98
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
99
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
100
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
101
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
102
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
103
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
104
|
-
REPLACEMENTS: {
|
|
105
|
-
__proto__: null,
|
|
106
|
-
'***': '*',
|
|
107
|
-
'**/**': '**',
|
|
108
|
-
'**/**/**': '**'
|
|
109
|
-
},
|
|
110
|
-
CHAR_0: 48,
|
|
111
|
-
CHAR_9: 57,
|
|
112
|
-
CHAR_UPPERCASE_A: 65,
|
|
113
|
-
CHAR_LOWERCASE_A: 97,
|
|
114
|
-
CHAR_UPPERCASE_Z: 90,
|
|
115
|
-
CHAR_LOWERCASE_Z: 122,
|
|
116
|
-
CHAR_LEFT_PARENTHESES: 40,
|
|
117
|
-
CHAR_RIGHT_PARENTHESES: 41,
|
|
118
|
-
CHAR_ASTERISK: 42,
|
|
119
|
-
CHAR_AMPERSAND: 38,
|
|
120
|
-
CHAR_AT: 64,
|
|
121
|
-
CHAR_BACKWARD_SLASH: 92,
|
|
122
|
-
CHAR_CARRIAGE_RETURN: 13,
|
|
123
|
-
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
124
|
-
CHAR_COLON: 58,
|
|
125
|
-
CHAR_COMMA: 44,
|
|
126
|
-
CHAR_DOT: 46,
|
|
127
|
-
CHAR_DOUBLE_QUOTE: 34,
|
|
128
|
-
CHAR_EQUAL: 61,
|
|
129
|
-
CHAR_EXCLAMATION_MARK: 33,
|
|
130
|
-
CHAR_FORM_FEED: 12,
|
|
131
|
-
CHAR_FORWARD_SLASH: 47,
|
|
132
|
-
CHAR_GRAVE_ACCENT: 96,
|
|
133
|
-
CHAR_HASH: 35,
|
|
134
|
-
CHAR_HYPHEN_MINUS: 45,
|
|
135
|
-
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
136
|
-
CHAR_LEFT_CURLY_BRACE: 123,
|
|
137
|
-
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
138
|
-
CHAR_LINE_FEED: 10,
|
|
139
|
-
CHAR_NO_BREAK_SPACE: 160,
|
|
140
|
-
CHAR_PERCENT: 37,
|
|
141
|
-
CHAR_PLUS: 43,
|
|
142
|
-
CHAR_QUESTION_MARK: 63,
|
|
143
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
144
|
-
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
145
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
146
|
-
CHAR_SEMICOLON: 59,
|
|
147
|
-
CHAR_SINGLE_QUOTE: 39,
|
|
148
|
-
CHAR_SPACE: 32,
|
|
149
|
-
CHAR_TAB: 9,
|
|
150
|
-
CHAR_UNDERSCORE: 95,
|
|
151
|
-
CHAR_VERTICAL_LINE: 124,
|
|
152
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
153
|
-
extglobChars (chars) {
|
|
154
|
-
return {
|
|
155
|
-
'!': {
|
|
156
|
-
type: 'negate',
|
|
157
|
-
open: '(?:(?!(?:',
|
|
158
|
-
close: `))${chars.STAR})`
|
|
159
|
-
},
|
|
160
|
-
'?': {
|
|
161
|
-
type: 'qmark',
|
|
162
|
-
open: '(?:',
|
|
163
|
-
close: ')?'
|
|
164
|
-
},
|
|
165
|
-
'+': {
|
|
166
|
-
type: 'plus',
|
|
167
|
-
open: '(?:',
|
|
168
|
-
close: ')+'
|
|
169
|
-
},
|
|
170
|
-
'*': {
|
|
171
|
-
type: 'star',
|
|
172
|
-
open: '(?:',
|
|
173
|
-
close: ')*'
|
|
174
|
-
},
|
|
175
|
-
'@': {
|
|
176
|
-
type: 'at',
|
|
177
|
-
open: '(?:',
|
|
178
|
-
close: ')'
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
},
|
|
182
|
-
globChars (win32) {
|
|
183
|
-
return true === win32 ? WINDOWS_CHARS : POSIX_CHARS;
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
},
|
|
187
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
188
|
-
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
189
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
190
|
-
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
191
|
-
const expandRange = (args, options)=>{
|
|
192
|
-
if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
|
|
193
|
-
args.sort();
|
|
194
|
-
const value = `[${args.join('-')}]`;
|
|
195
|
-
try {
|
|
196
|
-
new RegExp(value);
|
|
197
|
-
} catch (ex) {
|
|
198
|
-
return args.map((v)=>utils.escapeRegex(v)).join('..');
|
|
199
|
-
}
|
|
200
|
-
return value;
|
|
201
|
-
};
|
|
202
|
-
const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
203
|
-
const splitTopLevel = (input)=>{
|
|
204
|
-
const parts = [];
|
|
205
|
-
let bracket = 0;
|
|
206
|
-
let paren = 0;
|
|
207
|
-
let quote = 0;
|
|
208
|
-
let value = '';
|
|
209
|
-
let escaped = false;
|
|
210
|
-
for (const ch of input){
|
|
211
|
-
if (true === escaped) {
|
|
212
|
-
value += ch;
|
|
213
|
-
escaped = false;
|
|
214
|
-
continue;
|
|
215
|
-
}
|
|
216
|
-
if ('\\' === ch) {
|
|
217
|
-
value += ch;
|
|
218
|
-
escaped = true;
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
if ('"' === ch) {
|
|
222
|
-
quote = 1 === quote ? 0 : 1;
|
|
223
|
-
value += ch;
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
if (0 === quote) {
|
|
227
|
-
if ('[' === ch) bracket++;
|
|
228
|
-
else if (']' === ch && bracket > 0) bracket--;
|
|
229
|
-
else if (0 === bracket) {
|
|
230
|
-
if ('(' === ch) paren++;
|
|
231
|
-
else if (')' === ch && paren > 0) paren--;
|
|
232
|
-
else if ('|' === ch && 0 === paren) {
|
|
233
|
-
parts.push(value);
|
|
234
|
-
value = '';
|
|
235
|
-
continue;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
value += ch;
|
|
240
|
-
}
|
|
241
|
-
parts.push(value);
|
|
242
|
-
return parts;
|
|
243
|
-
};
|
|
244
|
-
const isPlainBranch = (branch)=>{
|
|
245
|
-
let escaped = false;
|
|
246
|
-
for (const ch of branch){
|
|
247
|
-
if (true === escaped) {
|
|
248
|
-
escaped = false;
|
|
249
|
-
continue;
|
|
250
|
-
}
|
|
251
|
-
if ('\\' === ch) {
|
|
252
|
-
escaped = true;
|
|
253
|
-
continue;
|
|
254
|
-
}
|
|
255
|
-
if (/[?*+@!()[\]{}]/.test(ch)) return false;
|
|
256
|
-
}
|
|
257
|
-
return true;
|
|
258
|
-
};
|
|
259
|
-
const normalizeSimpleBranch = (branch)=>{
|
|
260
|
-
let value = branch.trim();
|
|
261
|
-
let changed = true;
|
|
262
|
-
while(true === changed){
|
|
263
|
-
changed = false;
|
|
264
|
-
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
265
|
-
value = value.slice(2, -1);
|
|
266
|
-
changed = true;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
if (!isPlainBranch(value)) return;
|
|
270
|
-
return value.replace(/\\(.)/g, '$1');
|
|
271
|
-
};
|
|
272
|
-
const hasRepeatedCharPrefixOverlap = (branches)=>{
|
|
273
|
-
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
274
|
-
for(let i = 0; i < values.length; i++)for(let j = i + 1; j < values.length; j++){
|
|
275
|
-
const a = values[i];
|
|
276
|
-
const b = values[j];
|
|
277
|
-
const char = a[0];
|
|
278
|
-
if (char && a === char.repeat(a.length) && b === char.repeat(b.length)) {
|
|
279
|
-
if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
return false;
|
|
283
|
-
};
|
|
284
|
-
const parseRepeatedExtglob = (pattern, requireEnd = true)=>{
|
|
285
|
-
if ('+' !== pattern[0] && '*' !== pattern[0] || '(' !== pattern[1]) return;
|
|
286
|
-
let bracket = 0;
|
|
287
|
-
let paren = 0;
|
|
288
|
-
let quote = 0;
|
|
289
|
-
let escaped = false;
|
|
290
|
-
for(let i = 1; i < pattern.length; i++){
|
|
291
|
-
const ch = pattern[i];
|
|
292
|
-
if (true === escaped) {
|
|
293
|
-
escaped = false;
|
|
294
|
-
continue;
|
|
295
|
-
}
|
|
296
|
-
if ('\\' === ch) {
|
|
297
|
-
escaped = true;
|
|
298
|
-
continue;
|
|
299
|
-
}
|
|
300
|
-
if ('"' === ch) {
|
|
301
|
-
quote = 1 === quote ? 0 : 1;
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
if (1 !== quote) {
|
|
305
|
-
if ('[' === ch) {
|
|
306
|
-
bracket++;
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
if (']' === ch && bracket > 0) {
|
|
310
|
-
bracket--;
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
if (!(bracket > 0)) {
|
|
314
|
-
if ('(' === ch) {
|
|
315
|
-
paren++;
|
|
316
|
-
continue;
|
|
317
|
-
}
|
|
318
|
-
if (')' === ch) {
|
|
319
|
-
paren--;
|
|
320
|
-
if (0 === paren) {
|
|
321
|
-
if (true === requireEnd && i !== pattern.length - 1) return;
|
|
322
|
-
return {
|
|
323
|
-
type: pattern[0],
|
|
324
|
-
body: pattern.slice(2, i),
|
|
325
|
-
end: i
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
const getStarExtglobSequenceOutput = (pattern)=>{
|
|
334
|
-
let index = 0;
|
|
335
|
-
const chars = [];
|
|
336
|
-
while(index < pattern.length){
|
|
337
|
-
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
338
|
-
if (!match || '*' !== match.type) return;
|
|
339
|
-
const branches = splitTopLevel(match.body).map((branch)=>branch.trim());
|
|
340
|
-
if (1 !== branches.length) return;
|
|
341
|
-
const branch = normalizeSimpleBranch(branches[0]);
|
|
342
|
-
if (!branch || 1 !== branch.length) return;
|
|
343
|
-
chars.push(branch);
|
|
344
|
-
index += match.end + 1;
|
|
345
|
-
}
|
|
346
|
-
if (chars.length < 1) return;
|
|
347
|
-
const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
|
|
348
|
-
return `${source}*`;
|
|
349
|
-
};
|
|
350
|
-
const repeatedExtglobRecursion = (pattern)=>{
|
|
351
|
-
let depth = 0;
|
|
352
|
-
let value = pattern.trim();
|
|
353
|
-
let match = parseRepeatedExtglob(value);
|
|
354
|
-
while(match){
|
|
355
|
-
depth++;
|
|
356
|
-
value = match.body.trim();
|
|
357
|
-
match = parseRepeatedExtglob(value);
|
|
358
|
-
}
|
|
359
|
-
return depth;
|
|
360
|
-
};
|
|
361
|
-
const analyzeRepeatedExtglob = (body, options)=>{
|
|
362
|
-
if (false === options.maxExtglobRecursion) return {
|
|
363
|
-
risky: false
|
|
364
|
-
};
|
|
365
|
-
const max = 'number' == typeof options.maxExtglobRecursion ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
366
|
-
const branches = splitTopLevel(body).map((branch)=>branch.trim());
|
|
367
|
-
if (branches.length > 1) {
|
|
368
|
-
if (branches.some((branch)=>'' === branch) || branches.some((branch)=>/^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return {
|
|
369
|
-
risky: true
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
for (const branch of branches){
|
|
373
|
-
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
374
|
-
if (safeOutput) return {
|
|
375
|
-
risky: true,
|
|
376
|
-
safeOutput
|
|
377
|
-
};
|
|
378
|
-
if (repeatedExtglobRecursion(branch) > max) return {
|
|
379
|
-
risky: true
|
|
380
|
-
};
|
|
381
|
-
}
|
|
382
|
-
return {
|
|
383
|
-
risky: false
|
|
384
|
-
};
|
|
385
|
-
};
|
|
386
|
-
const parse = (input, options)=>{
|
|
387
|
-
if ('string' != typeof input) throw new TypeError('Expected a string');
|
|
388
|
-
input = REPLACEMENTS[input] || input;
|
|
389
|
-
const opts = {
|
|
390
|
-
...options
|
|
391
|
-
};
|
|
392
|
-
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
393
|
-
let len = input.length;
|
|
394
|
-
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
395
|
-
const bos = {
|
|
396
|
-
type: 'bos',
|
|
397
|
-
value: '',
|
|
398
|
-
output: opts.prepend || ''
|
|
399
|
-
};
|
|
400
|
-
const tokens = [
|
|
401
|
-
bos
|
|
402
|
-
];
|
|
403
|
-
const capture = opts.capture ? '' : '?:';
|
|
404
|
-
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
405
|
-
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
406
|
-
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;
|
|
407
|
-
const globstar = (opts)=>`(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
408
|
-
const nodot = opts.dot ? '' : NO_DOT;
|
|
409
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
410
|
-
let star = true === opts.bash ? globstar(opts) : STAR;
|
|
411
|
-
if (opts.capture) star = `(${star})`;
|
|
412
|
-
if ('boolean' == typeof opts.noext) opts.noextglob = opts.noext;
|
|
413
|
-
const state = {
|
|
414
|
-
input,
|
|
415
|
-
index: -1,
|
|
416
|
-
start: 0,
|
|
417
|
-
dot: true === opts.dot,
|
|
418
|
-
consumed: '',
|
|
419
|
-
output: '',
|
|
420
|
-
prefix: '',
|
|
421
|
-
backtrack: false,
|
|
422
|
-
negated: false,
|
|
423
|
-
brackets: 0,
|
|
424
|
-
braces: 0,
|
|
425
|
-
parens: 0,
|
|
426
|
-
quotes: 0,
|
|
427
|
-
globstar: false,
|
|
428
|
-
tokens
|
|
429
|
-
};
|
|
430
|
-
input = utils.removePrefix(input, state);
|
|
431
|
-
len = input.length;
|
|
432
|
-
const extglobs = [];
|
|
433
|
-
const braces = [];
|
|
434
|
-
const stack = [];
|
|
435
|
-
let prev = bos;
|
|
436
|
-
let value;
|
|
437
|
-
const eos = ()=>state.index === len - 1;
|
|
438
|
-
const peek = state.peek = (n = 1)=>input[state.index + n];
|
|
439
|
-
const advance = state.advance = ()=>input[++state.index] || '';
|
|
440
|
-
const remaining = ()=>input.slice(state.index + 1);
|
|
441
|
-
const consume = (value = '', num = 0)=>{
|
|
442
|
-
state.consumed += value;
|
|
443
|
-
state.index += num;
|
|
444
|
-
};
|
|
445
|
-
const append = (token)=>{
|
|
446
|
-
state.output += null != token.output ? token.output : token.value;
|
|
447
|
-
consume(token.value);
|
|
448
|
-
};
|
|
449
|
-
const negate = ()=>{
|
|
450
|
-
let count = 1;
|
|
451
|
-
while('!' === peek() && ('(' !== peek(2) || '?' === peek(3))){
|
|
452
|
-
advance();
|
|
453
|
-
state.start++;
|
|
454
|
-
count++;
|
|
455
|
-
}
|
|
456
|
-
if (count % 2 === 0) return false;
|
|
457
|
-
state.negated = true;
|
|
458
|
-
state.start++;
|
|
459
|
-
return true;
|
|
460
|
-
};
|
|
461
|
-
const increment = (type)=>{
|
|
462
|
-
state[type]++;
|
|
463
|
-
stack.push(type);
|
|
464
|
-
};
|
|
465
|
-
const decrement = (type)=>{
|
|
466
|
-
state[type]--;
|
|
467
|
-
stack.pop();
|
|
468
|
-
};
|
|
469
|
-
const push = (tok)=>{
|
|
470
|
-
if ('globstar' === prev.type) {
|
|
471
|
-
const isBrace = state.braces > 0 && ('comma' === tok.type || 'brace' === tok.type);
|
|
472
|
-
const isExtglob = true === tok.extglob || extglobs.length && ('pipe' === tok.type || 'paren' === tok.type);
|
|
473
|
-
if ('slash' !== tok.type && 'paren' !== tok.type && !isBrace && !isExtglob) {
|
|
474
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
475
|
-
prev.type = 'star';
|
|
476
|
-
prev.value = '*';
|
|
477
|
-
prev.output = star;
|
|
478
|
-
state.output += prev.output;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
if (extglobs.length && 'paren' !== tok.type) extglobs[extglobs.length - 1].inner += tok.value;
|
|
482
|
-
if (tok.value || tok.output) append(tok);
|
|
483
|
-
if (prev && 'text' === prev.type && 'text' === tok.type) {
|
|
484
|
-
prev.output = (prev.output || prev.value) + tok.value;
|
|
485
|
-
prev.value += tok.value;
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
tok.prev = prev;
|
|
489
|
-
tokens.push(tok);
|
|
490
|
-
prev = tok;
|
|
491
|
-
};
|
|
492
|
-
const extglobOpen = (type, value)=>{
|
|
493
|
-
const token = {
|
|
494
|
-
...EXTGLOB_CHARS[value],
|
|
495
|
-
conditions: 1,
|
|
496
|
-
inner: ''
|
|
497
|
-
};
|
|
498
|
-
token.prev = prev;
|
|
499
|
-
token.parens = state.parens;
|
|
500
|
-
token.output = state.output;
|
|
501
|
-
token.startIndex = state.index;
|
|
502
|
-
token.tokensIndex = tokens.length;
|
|
503
|
-
const output = (opts.capture ? '(' : '') + token.open;
|
|
504
|
-
increment('parens');
|
|
505
|
-
push({
|
|
506
|
-
type,
|
|
507
|
-
value,
|
|
508
|
-
output: state.output ? '' : ONE_CHAR
|
|
509
|
-
});
|
|
510
|
-
push({
|
|
511
|
-
type: 'paren',
|
|
512
|
-
extglob: true,
|
|
513
|
-
value: advance(),
|
|
514
|
-
output
|
|
515
|
-
});
|
|
516
|
-
extglobs.push(token);
|
|
517
|
-
};
|
|
518
|
-
const extglobClose = (token)=>{
|
|
519
|
-
const literal = input.slice(token.startIndex, state.index + 1);
|
|
520
|
-
const body = input.slice(token.startIndex + 2, state.index);
|
|
521
|
-
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
522
|
-
if (('plus' === token.type || 'star' === token.type) && analysis.risky) {
|
|
523
|
-
const safeOutput = analysis.safeOutput ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
524
|
-
const open = tokens[token.tokensIndex];
|
|
525
|
-
open.type = 'text';
|
|
526
|
-
open.value = literal;
|
|
527
|
-
open.output = safeOutput || utils.escapeRegex(literal);
|
|
528
|
-
for(let i = token.tokensIndex + 1; i < tokens.length; i++){
|
|
529
|
-
tokens[i].value = '';
|
|
530
|
-
tokens[i].output = '';
|
|
531
|
-
delete tokens[i].suffix;
|
|
532
|
-
}
|
|
533
|
-
state.output = token.output + open.output;
|
|
534
|
-
state.backtrack = true;
|
|
535
|
-
push({
|
|
536
|
-
type: 'paren',
|
|
537
|
-
extglob: true,
|
|
538
|
-
value,
|
|
539
|
-
output: ''
|
|
540
|
-
});
|
|
541
|
-
decrement('parens');
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
|
-
let output = token.close + (opts.capture ? ')' : '');
|
|
545
|
-
let rest;
|
|
546
|
-
if ('negate' === token.type) {
|
|
547
|
-
let extglobStar = star;
|
|
548
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) extglobStar = globstar(opts);
|
|
549
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
550
|
-
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
551
|
-
const expression = parse(rest, {
|
|
552
|
-
...options,
|
|
553
|
-
fastpaths: false
|
|
554
|
-
}).output;
|
|
555
|
-
output = token.close = `)${expression})${extglobStar})`;
|
|
556
|
-
}
|
|
557
|
-
if ('bos' === token.prev.type) state.negatedExtglob = true;
|
|
558
|
-
}
|
|
559
|
-
push({
|
|
560
|
-
type: 'paren',
|
|
561
|
-
extglob: true,
|
|
562
|
-
value,
|
|
563
|
-
output
|
|
564
|
-
});
|
|
565
|
-
decrement('parens');
|
|
566
|
-
};
|
|
567
|
-
if (false !== opts.fastpaths && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
568
|
-
let backslashes = false;
|
|
569
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index)=>{
|
|
570
|
-
if ('\\' === first) {
|
|
571
|
-
backslashes = true;
|
|
572
|
-
return m;
|
|
573
|
-
}
|
|
574
|
-
if ('?' === first) {
|
|
575
|
-
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
576
|
-
if (0 === index) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
577
|
-
return QMARK.repeat(chars.length);
|
|
578
|
-
}
|
|
579
|
-
if ('.' === first) return DOT_LITERAL.repeat(chars.length);
|
|
580
|
-
if ('*' === first) {
|
|
581
|
-
if (esc) return esc + first + (rest ? star : '');
|
|
582
|
-
return star;
|
|
583
|
-
}
|
|
584
|
-
return esc ? m : `\\${m}`;
|
|
585
|
-
});
|
|
586
|
-
if (true === backslashes) output = true === opts.unescape ? output.replace(/\\/g, '') : output.replace(/\\+/g, (m)=>m.length % 2 === 0 ? '\\\\' : m ? '\\' : '');
|
|
587
|
-
if (output === input && true === opts.contains) {
|
|
588
|
-
state.output = input;
|
|
589
|
-
return state;
|
|
590
|
-
}
|
|
591
|
-
state.output = utils.wrapOutput(output, state, options);
|
|
592
|
-
return state;
|
|
593
|
-
}
|
|
594
|
-
while(!eos()){
|
|
595
|
-
value = advance();
|
|
596
|
-
if ('\u0000' === value) continue;
|
|
597
|
-
if ('\\' === value) {
|
|
598
|
-
const next = peek();
|
|
599
|
-
if ('/' === next && true !== opts.bash) continue;
|
|
600
|
-
if ('.' === next || ';' === next) continue;
|
|
601
|
-
if (!next) {
|
|
602
|
-
value += '\\';
|
|
603
|
-
push({
|
|
604
|
-
type: 'text',
|
|
605
|
-
value
|
|
606
|
-
});
|
|
607
|
-
continue;
|
|
608
|
-
}
|
|
609
|
-
const match = /^\\+/.exec(remaining());
|
|
610
|
-
let slashes = 0;
|
|
611
|
-
if (match && match[0].length > 2) {
|
|
612
|
-
slashes = match[0].length;
|
|
613
|
-
state.index += slashes;
|
|
614
|
-
if (slashes % 2 !== 0) value += '\\';
|
|
615
|
-
}
|
|
616
|
-
if (true === opts.unescape) value = advance();
|
|
617
|
-
else value += advance();
|
|
618
|
-
if (0 === state.brackets) {
|
|
619
|
-
push({
|
|
620
|
-
type: 'text',
|
|
621
|
-
value
|
|
622
|
-
});
|
|
623
|
-
continue;
|
|
624
|
-
}
|
|
625
|
-
}
|
|
626
|
-
if (state.brackets > 0 && (']' !== value || '[' === prev.value || '[^' === prev.value)) {
|
|
627
|
-
if (false !== opts.posix && ':' === value) {
|
|
628
|
-
const inner = prev.value.slice(1);
|
|
629
|
-
if (inner.includes('[')) {
|
|
630
|
-
prev.posix = true;
|
|
631
|
-
if (inner.includes(':')) {
|
|
632
|
-
const idx = prev.value.lastIndexOf('[');
|
|
633
|
-
const pre = prev.value.slice(0, idx);
|
|
634
|
-
const rest = prev.value.slice(idx + 2);
|
|
635
|
-
const posix = POSIX_REGEX_SOURCE[rest];
|
|
636
|
-
if (posix) {
|
|
637
|
-
prev.value = pre + posix;
|
|
638
|
-
state.backtrack = true;
|
|
639
|
-
advance();
|
|
640
|
-
if (!bos.output && 1 === tokens.indexOf(prev)) bos.output = ONE_CHAR;
|
|
641
|
-
continue;
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
if ('[' === value && ':' !== peek() || '-' === value && ']' === peek()) value = `\\${value}`;
|
|
647
|
-
if (']' === value && ('[' === prev.value || '[^' === prev.value)) value = `\\${value}`;
|
|
648
|
-
if (true === opts.posix && '!' === value && '[' === prev.value) value = '^';
|
|
649
|
-
prev.value += value;
|
|
650
|
-
append({
|
|
651
|
-
value
|
|
652
|
-
});
|
|
653
|
-
continue;
|
|
654
|
-
}
|
|
655
|
-
if (1 === state.quotes && '"' !== value) {
|
|
656
|
-
value = utils.escapeRegex(value);
|
|
657
|
-
prev.value += value;
|
|
658
|
-
append({
|
|
659
|
-
value
|
|
660
|
-
});
|
|
661
|
-
continue;
|
|
662
|
-
}
|
|
663
|
-
if ('"' === value) {
|
|
664
|
-
state.quotes = 1 === state.quotes ? 0 : 1;
|
|
665
|
-
if (true === opts.keepQuotes) push({
|
|
666
|
-
type: 'text',
|
|
667
|
-
value
|
|
668
|
-
});
|
|
669
|
-
continue;
|
|
670
|
-
}
|
|
671
|
-
if ('(' === value) {
|
|
672
|
-
increment('parens');
|
|
673
|
-
push({
|
|
674
|
-
type: 'paren',
|
|
675
|
-
value
|
|
676
|
-
});
|
|
677
|
-
continue;
|
|
678
|
-
}
|
|
679
|
-
if (')' === value) {
|
|
680
|
-
if (0 === state.parens && true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '('));
|
|
681
|
-
const extglob = extglobs[extglobs.length - 1];
|
|
682
|
-
if (extglob && state.parens === extglob.parens + 1) {
|
|
683
|
-
extglobClose(extglobs.pop());
|
|
684
|
-
continue;
|
|
685
|
-
}
|
|
686
|
-
push({
|
|
687
|
-
type: 'paren',
|
|
688
|
-
value,
|
|
689
|
-
output: state.parens ? ')' : '\\)'
|
|
690
|
-
});
|
|
691
|
-
decrement('parens');
|
|
692
|
-
continue;
|
|
693
|
-
}
|
|
694
|
-
if ('[' === value) {
|
|
695
|
-
if (true !== opts.nobracket && remaining().includes(']')) increment('brackets');
|
|
696
|
-
else {
|
|
697
|
-
if (true !== opts.nobracket && true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
698
|
-
value = `\\${value}`;
|
|
699
|
-
}
|
|
700
|
-
push({
|
|
701
|
-
type: 'bracket',
|
|
702
|
-
value
|
|
703
|
-
});
|
|
704
|
-
continue;
|
|
705
|
-
}
|
|
706
|
-
if (']' === value) {
|
|
707
|
-
if (true === opts.nobracket || prev && 'bracket' === prev.type && 1 === prev.value.length) {
|
|
708
|
-
push({
|
|
709
|
-
type: 'text',
|
|
710
|
-
value,
|
|
711
|
-
output: `\\${value}`
|
|
712
|
-
});
|
|
713
|
-
continue;
|
|
714
|
-
}
|
|
715
|
-
if (0 === state.brackets) {
|
|
716
|
-
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '['));
|
|
717
|
-
push({
|
|
718
|
-
type: 'text',
|
|
719
|
-
value,
|
|
720
|
-
output: `\\${value}`
|
|
721
|
-
});
|
|
722
|
-
continue;
|
|
723
|
-
}
|
|
724
|
-
decrement('brackets');
|
|
725
|
-
const prevValue = prev.value.slice(1);
|
|
726
|
-
if (true !== prev.posix && '^' === prevValue[0] && !prevValue.includes('/')) value = `/${value}`;
|
|
727
|
-
prev.value += value;
|
|
728
|
-
append({
|
|
729
|
-
value
|
|
730
|
-
});
|
|
731
|
-
if (false === opts.literalBrackets || utils.hasRegexChars(prevValue)) continue;
|
|
732
|
-
const escaped = utils.escapeRegex(prev.value);
|
|
733
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
734
|
-
if (true === opts.literalBrackets) {
|
|
735
|
-
state.output += escaped;
|
|
736
|
-
prev.value = escaped;
|
|
737
|
-
continue;
|
|
738
|
-
}
|
|
739
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
740
|
-
state.output += prev.value;
|
|
741
|
-
continue;
|
|
742
|
-
}
|
|
743
|
-
if ('{' === value && true !== opts.nobrace) {
|
|
744
|
-
increment('braces');
|
|
745
|
-
const open = {
|
|
746
|
-
type: 'brace',
|
|
747
|
-
value,
|
|
748
|
-
output: '(',
|
|
749
|
-
outputIndex: state.output.length,
|
|
750
|
-
tokensIndex: state.tokens.length
|
|
751
|
-
};
|
|
752
|
-
braces.push(open);
|
|
753
|
-
push(open);
|
|
754
|
-
continue;
|
|
755
|
-
}
|
|
756
|
-
if ('}' === value) {
|
|
757
|
-
const brace = braces[braces.length - 1];
|
|
758
|
-
if (true === opts.nobrace || !brace) {
|
|
759
|
-
push({
|
|
760
|
-
type: 'text',
|
|
761
|
-
value,
|
|
762
|
-
output: value
|
|
763
|
-
});
|
|
764
|
-
continue;
|
|
765
|
-
}
|
|
766
|
-
let output = ')';
|
|
767
|
-
if (true === brace.dots) {
|
|
768
|
-
const arr = tokens.slice();
|
|
769
|
-
const range = [];
|
|
770
|
-
for(let i = arr.length - 1; i >= 0; i--){
|
|
771
|
-
tokens.pop();
|
|
772
|
-
if ('brace' === arr[i].type) break;
|
|
773
|
-
if ('dots' !== arr[i].type) range.unshift(arr[i].value);
|
|
774
|
-
}
|
|
775
|
-
output = expandRange(range, opts);
|
|
776
|
-
state.backtrack = true;
|
|
777
|
-
}
|
|
778
|
-
if (true !== brace.comma && true !== brace.dots) {
|
|
779
|
-
const out = state.output.slice(0, brace.outputIndex);
|
|
780
|
-
const toks = state.tokens.slice(brace.tokensIndex);
|
|
781
|
-
brace.value = brace.output = '\\{';
|
|
782
|
-
value = output = '\\}';
|
|
783
|
-
state.output = out;
|
|
784
|
-
for (const t of toks)state.output += t.output || t.value;
|
|
785
|
-
}
|
|
786
|
-
push({
|
|
787
|
-
type: 'brace',
|
|
788
|
-
value,
|
|
789
|
-
output
|
|
790
|
-
});
|
|
791
|
-
decrement('braces');
|
|
792
|
-
braces.pop();
|
|
793
|
-
continue;
|
|
794
|
-
}
|
|
795
|
-
if ('|' === value) {
|
|
796
|
-
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
797
|
-
push({
|
|
798
|
-
type: 'text',
|
|
799
|
-
value
|
|
800
|
-
});
|
|
801
|
-
continue;
|
|
802
|
-
}
|
|
803
|
-
if (',' === value) {
|
|
804
|
-
let output = value;
|
|
805
|
-
const brace = braces[braces.length - 1];
|
|
806
|
-
if (brace && 'braces' === stack[stack.length - 1]) {
|
|
807
|
-
brace.comma = true;
|
|
808
|
-
output = '|';
|
|
809
|
-
}
|
|
810
|
-
push({
|
|
811
|
-
type: 'comma',
|
|
812
|
-
value,
|
|
813
|
-
output
|
|
814
|
-
});
|
|
815
|
-
continue;
|
|
816
|
-
}
|
|
817
|
-
if ('/' === value) {
|
|
818
|
-
if ('dot' === prev.type && state.index === state.start + 1) {
|
|
819
|
-
state.start = state.index + 1;
|
|
820
|
-
state.consumed = '';
|
|
821
|
-
state.output = '';
|
|
822
|
-
tokens.pop();
|
|
823
|
-
prev = bos;
|
|
824
|
-
continue;
|
|
825
|
-
}
|
|
826
|
-
push({
|
|
827
|
-
type: 'slash',
|
|
828
|
-
value,
|
|
829
|
-
output: SLASH_LITERAL
|
|
830
|
-
});
|
|
831
|
-
continue;
|
|
832
|
-
}
|
|
833
|
-
if ('.' === value) {
|
|
834
|
-
if (state.braces > 0 && 'dot' === prev.type) {
|
|
835
|
-
if ('.' === prev.value) prev.output = DOT_LITERAL;
|
|
836
|
-
const brace = braces[braces.length - 1];
|
|
837
|
-
prev.type = 'dots';
|
|
838
|
-
prev.output += value;
|
|
839
|
-
prev.value += value;
|
|
840
|
-
brace.dots = true;
|
|
841
|
-
continue;
|
|
842
|
-
}
|
|
843
|
-
if (state.braces + state.parens === 0 && 'bos' !== prev.type && 'slash' !== prev.type) {
|
|
844
|
-
push({
|
|
845
|
-
type: 'text',
|
|
846
|
-
value,
|
|
847
|
-
output: DOT_LITERAL
|
|
848
|
-
});
|
|
849
|
-
continue;
|
|
850
|
-
}
|
|
851
|
-
push({
|
|
852
|
-
type: 'dot',
|
|
853
|
-
value,
|
|
854
|
-
output: DOT_LITERAL
|
|
855
|
-
});
|
|
856
|
-
continue;
|
|
857
|
-
}
|
|
858
|
-
if ('?' === value) {
|
|
859
|
-
const isGroup = prev && '(' === prev.value;
|
|
860
|
-
if (!isGroup && true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
861
|
-
extglobOpen('qmark', value);
|
|
862
|
-
continue;
|
|
863
|
-
}
|
|
864
|
-
if (prev && 'paren' === prev.type) {
|
|
865
|
-
const next = peek();
|
|
866
|
-
let output = value;
|
|
867
|
-
if ('(' === prev.value && !/[!=<:]/.test(next) || '<' === next && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
868
|
-
push({
|
|
869
|
-
type: 'text',
|
|
870
|
-
value,
|
|
871
|
-
output
|
|
872
|
-
});
|
|
873
|
-
continue;
|
|
874
|
-
}
|
|
875
|
-
if (true !== opts.dot && ('slash' === prev.type || 'bos' === prev.type)) {
|
|
876
|
-
push({
|
|
877
|
-
type: 'qmark',
|
|
878
|
-
value,
|
|
879
|
-
output: QMARK_NO_DOT
|
|
880
|
-
});
|
|
881
|
-
continue;
|
|
882
|
-
}
|
|
883
|
-
push({
|
|
884
|
-
type: 'qmark',
|
|
885
|
-
value,
|
|
886
|
-
output: QMARK
|
|
887
|
-
});
|
|
888
|
-
continue;
|
|
889
|
-
}
|
|
890
|
-
if ('!' === value) {
|
|
891
|
-
if (true !== opts.noextglob && '(' === peek()) {
|
|
892
|
-
if ('?' !== peek(2) || !/[!=<:]/.test(peek(3))) {
|
|
893
|
-
extglobOpen('negate', value);
|
|
894
|
-
continue;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
if (true !== opts.nonegate && 0 === state.index) {
|
|
898
|
-
negate();
|
|
899
|
-
continue;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
if ('+' === value) {
|
|
903
|
-
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
904
|
-
extglobOpen('plus', value);
|
|
905
|
-
continue;
|
|
906
|
-
}
|
|
907
|
-
if (prev && '(' === prev.value || false === opts.regex) {
|
|
908
|
-
push({
|
|
909
|
-
type: 'plus',
|
|
910
|
-
value,
|
|
911
|
-
output: PLUS_LITERAL
|
|
912
|
-
});
|
|
913
|
-
continue;
|
|
914
|
-
}
|
|
915
|
-
if (prev && ('bracket' === prev.type || 'paren' === prev.type || 'brace' === prev.type) || state.parens > 0) {
|
|
916
|
-
push({
|
|
917
|
-
type: 'plus',
|
|
918
|
-
value
|
|
919
|
-
});
|
|
920
|
-
continue;
|
|
921
|
-
}
|
|
922
|
-
push({
|
|
923
|
-
type: 'plus',
|
|
924
|
-
value: PLUS_LITERAL
|
|
925
|
-
});
|
|
926
|
-
continue;
|
|
927
|
-
}
|
|
928
|
-
if ('@' === value) {
|
|
929
|
-
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
930
|
-
push({
|
|
931
|
-
type: 'at',
|
|
932
|
-
extglob: true,
|
|
933
|
-
value,
|
|
934
|
-
output: ''
|
|
935
|
-
});
|
|
936
|
-
continue;
|
|
937
|
-
}
|
|
938
|
-
push({
|
|
939
|
-
type: 'text',
|
|
940
|
-
value
|
|
941
|
-
});
|
|
942
|
-
continue;
|
|
943
|
-
}
|
|
944
|
-
if ('*' !== value) {
|
|
945
|
-
if ('$' === value || '^' === value) value = `\\${value}`;
|
|
946
|
-
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
947
|
-
if (match) {
|
|
948
|
-
value += match[0];
|
|
949
|
-
state.index += match[0].length;
|
|
950
|
-
}
|
|
951
|
-
push({
|
|
952
|
-
type: 'text',
|
|
953
|
-
value
|
|
954
|
-
});
|
|
955
|
-
continue;
|
|
956
|
-
}
|
|
957
|
-
if (prev && ('globstar' === prev.type || true === prev.star)) {
|
|
958
|
-
prev.type = 'star';
|
|
959
|
-
prev.star = true;
|
|
960
|
-
prev.value += value;
|
|
961
|
-
prev.output = star;
|
|
962
|
-
state.backtrack = true;
|
|
963
|
-
state.globstar = true;
|
|
964
|
-
consume(value);
|
|
965
|
-
continue;
|
|
966
|
-
}
|
|
967
|
-
let rest = remaining();
|
|
968
|
-
if (true !== opts.noextglob && /^\([^?]/.test(rest)) {
|
|
969
|
-
extglobOpen('star', value);
|
|
970
|
-
continue;
|
|
971
|
-
}
|
|
972
|
-
if ('star' === prev.type) {
|
|
973
|
-
if (true === opts.noglobstar) {
|
|
974
|
-
consume(value);
|
|
975
|
-
continue;
|
|
976
|
-
}
|
|
977
|
-
const prior = prev.prev;
|
|
978
|
-
const before = prior.prev;
|
|
979
|
-
const isStart = 'slash' === prior.type || 'bos' === prior.type;
|
|
980
|
-
const afterStar = before && ('star' === before.type || 'globstar' === before.type);
|
|
981
|
-
if (true === opts.bash && (!isStart || rest[0] && '/' !== rest[0])) {
|
|
982
|
-
push({
|
|
983
|
-
type: 'star',
|
|
984
|
-
value,
|
|
985
|
-
output: ''
|
|
986
|
-
});
|
|
987
|
-
continue;
|
|
988
|
-
}
|
|
989
|
-
const isBrace = state.braces > 0 && ('comma' === prior.type || 'brace' === prior.type);
|
|
990
|
-
const isExtglob = extglobs.length && ('pipe' === prior.type || 'paren' === prior.type);
|
|
991
|
-
if (!isStart && 'paren' !== prior.type && !isBrace && !isExtglob) {
|
|
992
|
-
push({
|
|
993
|
-
type: 'star',
|
|
994
|
-
value,
|
|
995
|
-
output: ''
|
|
996
|
-
});
|
|
997
|
-
continue;
|
|
998
|
-
}
|
|
999
|
-
while('/**' === rest.slice(0, 3)){
|
|
1000
|
-
const after = input[state.index + 4];
|
|
1001
|
-
if (after && '/' !== after) break;
|
|
1002
|
-
rest = rest.slice(3);
|
|
1003
|
-
consume('/**', 3);
|
|
1004
|
-
}
|
|
1005
|
-
if ('bos' === prior.type && eos()) {
|
|
1006
|
-
prev.type = 'globstar';
|
|
1007
|
-
prev.value += value;
|
|
1008
|
-
prev.output = globstar(opts);
|
|
1009
|
-
state.output = prev.output;
|
|
1010
|
-
state.globstar = true;
|
|
1011
|
-
consume(value);
|
|
1012
|
-
continue;
|
|
1013
|
-
}
|
|
1014
|
-
if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
|
|
1015
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1016
|
-
prior.output = `(?:${prior.output}`;
|
|
1017
|
-
prev.type = 'globstar';
|
|
1018
|
-
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
1019
|
-
prev.value += value;
|
|
1020
|
-
state.globstar = true;
|
|
1021
|
-
state.output += prior.output + prev.output;
|
|
1022
|
-
consume(value);
|
|
1023
|
-
continue;
|
|
1024
|
-
}
|
|
1025
|
-
if ('slash' === prior.type && 'bos' !== prior.prev.type && '/' === rest[0]) {
|
|
1026
|
-
const end = void 0 !== rest[1] ? '|$' : '';
|
|
1027
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1028
|
-
prior.output = `(?:${prior.output}`;
|
|
1029
|
-
prev.type = 'globstar';
|
|
1030
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1031
|
-
prev.value += value;
|
|
1032
|
-
state.output += prior.output + prev.output;
|
|
1033
|
-
state.globstar = true;
|
|
1034
|
-
consume(value + advance());
|
|
1035
|
-
push({
|
|
1036
|
-
type: 'slash',
|
|
1037
|
-
value: '/',
|
|
1038
|
-
output: ''
|
|
1039
|
-
});
|
|
1040
|
-
continue;
|
|
1041
|
-
}
|
|
1042
|
-
if ('bos' === prior.type && '/' === rest[0]) {
|
|
1043
|
-
prev.type = 'globstar';
|
|
1044
|
-
prev.value += value;
|
|
1045
|
-
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1046
|
-
state.output = prev.output;
|
|
1047
|
-
state.globstar = true;
|
|
1048
|
-
consume(value + advance());
|
|
1049
|
-
push({
|
|
1050
|
-
type: 'slash',
|
|
1051
|
-
value: '/',
|
|
1052
|
-
output: ''
|
|
1053
|
-
});
|
|
1054
|
-
continue;
|
|
1055
|
-
}
|
|
1056
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
1057
|
-
prev.type = 'globstar';
|
|
1058
|
-
prev.output = globstar(opts);
|
|
1059
|
-
prev.value += value;
|
|
1060
|
-
state.output += prev.output;
|
|
1061
|
-
state.globstar = true;
|
|
1062
|
-
consume(value);
|
|
1063
|
-
continue;
|
|
1064
|
-
}
|
|
1065
|
-
const token = {
|
|
1066
|
-
type: 'star',
|
|
1067
|
-
value,
|
|
1068
|
-
output: star
|
|
1069
|
-
};
|
|
1070
|
-
if (true === opts.bash) {
|
|
1071
|
-
token.output = '.*?';
|
|
1072
|
-
if ('bos' === prev.type || 'slash' === prev.type) token.output = nodot + token.output;
|
|
1073
|
-
push(token);
|
|
1074
|
-
continue;
|
|
1075
|
-
}
|
|
1076
|
-
if (prev && ('bracket' === prev.type || 'paren' === prev.type) && true === opts.regex) {
|
|
1077
|
-
token.output = value;
|
|
1078
|
-
push(token);
|
|
1079
|
-
continue;
|
|
1080
|
-
}
|
|
1081
|
-
if (state.index === state.start || 'slash' === prev.type || 'dot' === prev.type) {
|
|
1082
|
-
if ('dot' === prev.type) {
|
|
1083
|
-
state.output += NO_DOT_SLASH;
|
|
1084
|
-
prev.output += NO_DOT_SLASH;
|
|
1085
|
-
} else if (true === opts.dot) {
|
|
1086
|
-
state.output += NO_DOTS_SLASH;
|
|
1087
|
-
prev.output += NO_DOTS_SLASH;
|
|
1088
|
-
} else {
|
|
1089
|
-
state.output += nodot;
|
|
1090
|
-
prev.output += nodot;
|
|
1091
|
-
}
|
|
1092
|
-
if ('*' !== peek()) {
|
|
1093
|
-
state.output += ONE_CHAR;
|
|
1094
|
-
prev.output += ONE_CHAR;
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
push(token);
|
|
1098
|
-
}
|
|
1099
|
-
while(state.brackets > 0){
|
|
1100
|
-
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
1101
|
-
state.output = utils.escapeLast(state.output, '[');
|
|
1102
|
-
decrement('brackets');
|
|
1103
|
-
}
|
|
1104
|
-
while(state.parens > 0){
|
|
1105
|
-
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ')'));
|
|
1106
|
-
state.output = utils.escapeLast(state.output, '(');
|
|
1107
|
-
decrement('parens');
|
|
1108
|
-
}
|
|
1109
|
-
while(state.braces > 0){
|
|
1110
|
-
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', '}'));
|
|
1111
|
-
state.output = utils.escapeLast(state.output, '{');
|
|
1112
|
-
decrement('braces');
|
|
1113
|
-
}
|
|
1114
|
-
if (true !== opts.strictSlashes && ('star' === prev.type || 'bracket' === prev.type)) push({
|
|
1115
|
-
type: 'maybe_slash',
|
|
1116
|
-
value: '',
|
|
1117
|
-
output: `${SLASH_LITERAL}?`
|
|
1118
|
-
});
|
|
1119
|
-
if (true === state.backtrack) {
|
|
1120
|
-
state.output = '';
|
|
1121
|
-
for (const token of state.tokens){
|
|
1122
|
-
state.output += null != token.output ? token.output : token.value;
|
|
1123
|
-
if (token.suffix) state.output += token.suffix;
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
return state;
|
|
1127
|
-
};
|
|
1128
|
-
parse.fastpaths = (input, options)=>{
|
|
1129
|
-
const opts = {
|
|
1130
|
-
...options
|
|
1131
|
-
};
|
|
1132
|
-
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1133
|
-
const len = input.length;
|
|
1134
|
-
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1135
|
-
input = REPLACEMENTS[input] || input;
|
|
1136
|
-
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
1137
|
-
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1138
|
-
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1139
|
-
const capture = opts.capture ? '' : '?:';
|
|
1140
|
-
const state = {
|
|
1141
|
-
negated: false,
|
|
1142
|
-
prefix: ''
|
|
1143
|
-
};
|
|
1144
|
-
let star = true === opts.bash ? '.*?' : STAR;
|
|
1145
|
-
if (opts.capture) star = `(${star})`;
|
|
1146
|
-
const globstar = (opts)=>{
|
|
1147
|
-
if (true === opts.noglobstar) return star;
|
|
1148
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1149
|
-
};
|
|
1150
|
-
const create = (str)=>{
|
|
1151
|
-
switch(str){
|
|
1152
|
-
case '*':
|
|
1153
|
-
return `${nodot}${ONE_CHAR}${star}`;
|
|
1154
|
-
case '.*':
|
|
1155
|
-
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1156
|
-
case '*.*':
|
|
1157
|
-
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1158
|
-
case '*/*':
|
|
1159
|
-
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1160
|
-
case '**':
|
|
1161
|
-
return nodot + globstar(opts);
|
|
1162
|
-
case '**/*':
|
|
1163
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1164
|
-
case '**/*.*':
|
|
1165
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1166
|
-
case '**/.*':
|
|
1167
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1168
|
-
default:
|
|
1169
|
-
{
|
|
1170
|
-
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1171
|
-
if (!match) return;
|
|
1172
|
-
const source = create(match[1]);
|
|
1173
|
-
if (!source) return;
|
|
1174
|
-
return source + DOT_LITERAL + match[2];
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
const output = utils.removePrefix(input, state);
|
|
1179
|
-
let source = create(output);
|
|
1180
|
-
if (source && true !== opts.strictSlashes) source += `${SLASH_LITERAL}?`;
|
|
1181
|
-
return source;
|
|
1182
|
-
};
|
|
1183
|
-
module.exports = parse;
|
|
1184
|
-
},
|
|
1185
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1186
|
-
const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js");
|
|
1187
|
-
const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js");
|
|
1188
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
1189
|
-
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1190
|
-
const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
|
|
1191
|
-
const picomatch = (glob, options, returnState = false)=>{
|
|
1192
|
-
if (Array.isArray(glob)) {
|
|
1193
|
-
const fns = glob.map((input)=>picomatch(input, options, returnState));
|
|
1194
|
-
const arrayMatcher = (str)=>{
|
|
1195
|
-
for (const isMatch of fns){
|
|
1196
|
-
const state = isMatch(str);
|
|
1197
|
-
if (state) return state;
|
|
1198
|
-
}
|
|
1199
|
-
return false;
|
|
1200
|
-
};
|
|
1201
|
-
return arrayMatcher;
|
|
1202
|
-
}
|
|
1203
|
-
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1204
|
-
if ('' === glob || 'string' != typeof glob && !isState) throw new TypeError('Expected pattern to be a non-empty string');
|
|
1205
|
-
const opts = options || {};
|
|
1206
|
-
const posix = opts.windows;
|
|
1207
|
-
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1208
|
-
const state = regex.state;
|
|
1209
|
-
delete regex.state;
|
|
1210
|
-
let isIgnored = ()=>false;
|
|
1211
|
-
if (opts.ignore) {
|
|
1212
|
-
const ignoreOpts = {
|
|
1213
|
-
...options,
|
|
1214
|
-
ignore: null,
|
|
1215
|
-
onMatch: null,
|
|
1216
|
-
onResult: null
|
|
1217
|
-
};
|
|
1218
|
-
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1219
|
-
}
|
|
1220
|
-
const matcher = (input, returnObject = false)=>{
|
|
1221
|
-
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
1222
|
-
glob,
|
|
1223
|
-
posix
|
|
1224
|
-
});
|
|
1225
|
-
const result = {
|
|
1226
|
-
glob,
|
|
1227
|
-
state,
|
|
1228
|
-
regex,
|
|
1229
|
-
posix,
|
|
1230
|
-
input,
|
|
1231
|
-
output,
|
|
1232
|
-
match,
|
|
1233
|
-
isMatch
|
|
1234
|
-
};
|
|
1235
|
-
if ('function' == typeof opts.onResult) opts.onResult(result);
|
|
1236
|
-
if (false === isMatch) {
|
|
1237
|
-
result.isMatch = false;
|
|
1238
|
-
return returnObject ? result : false;
|
|
1239
|
-
}
|
|
1240
|
-
if (isIgnored(input)) {
|
|
1241
|
-
if ('function' == typeof opts.onIgnore) opts.onIgnore(result);
|
|
1242
|
-
result.isMatch = false;
|
|
1243
|
-
return returnObject ? result : false;
|
|
1244
|
-
}
|
|
1245
|
-
if ('function' == typeof opts.onMatch) opts.onMatch(result);
|
|
1246
|
-
return returnObject ? result : true;
|
|
1247
|
-
};
|
|
1248
|
-
if (returnState) matcher.state = state;
|
|
1249
|
-
return matcher;
|
|
1250
|
-
};
|
|
1251
|
-
picomatch.test = (input, regex, options, { glob, posix } = {})=>{
|
|
1252
|
-
if ('string' != typeof input) throw new TypeError('Expected input to be a string');
|
|
1253
|
-
if ('' === input) return {
|
|
1254
|
-
isMatch: false,
|
|
1255
|
-
output: ''
|
|
1256
|
-
};
|
|
1257
|
-
const opts = options || {};
|
|
1258
|
-
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1259
|
-
let match = input === glob;
|
|
1260
|
-
let output = match && format ? format(input) : input;
|
|
1261
|
-
if (false === match) {
|
|
1262
|
-
output = format ? format(input) : input;
|
|
1263
|
-
match = output === glob;
|
|
1264
|
-
}
|
|
1265
|
-
if (false === match || true === opts.capture) match = true === opts.matchBase || true === opts.basename ? picomatch.matchBase(input, regex, options, posix) : regex.exec(output);
|
|
1266
|
-
return {
|
|
1267
|
-
isMatch: Boolean(match),
|
|
1268
|
-
match,
|
|
1269
|
-
output
|
|
1270
|
-
};
|
|
1271
|
-
};
|
|
1272
|
-
picomatch.matchBase = (input, glob, options)=>{
|
|
1273
|
-
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1274
|
-
return regex.test(utils.basename(input));
|
|
1275
|
-
};
|
|
1276
|
-
picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
|
|
1277
|
-
picomatch.parse = (pattern, options)=>{
|
|
1278
|
-
if (Array.isArray(pattern)) return pattern.map((p)=>picomatch.parse(p, options));
|
|
1279
|
-
return parse(pattern, {
|
|
1280
|
-
...options,
|
|
1281
|
-
fastpaths: false
|
|
1282
|
-
});
|
|
1283
|
-
};
|
|
1284
|
-
picomatch.scan = (input, options)=>scan(input, options);
|
|
1285
|
-
picomatch.compileRe = (state, options, returnOutput = false, returnState = false)=>{
|
|
1286
|
-
if (true === returnOutput) return state.output;
|
|
1287
|
-
const opts = options || {};
|
|
1288
|
-
const prepend = opts.contains ? '' : '^';
|
|
1289
|
-
const append = opts.contains ? '' : '$';
|
|
1290
|
-
let source = `${prepend}(?:${state.output})${append}`;
|
|
1291
|
-
if (state && true === state.negated) source = `^(?!${source}).*$`;
|
|
1292
|
-
const regex = picomatch.toRegex(source, options);
|
|
1293
|
-
if (true === returnState) regex.state = state;
|
|
1294
|
-
return regex;
|
|
1295
|
-
};
|
|
1296
|
-
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false)=>{
|
|
1297
|
-
if (!input || 'string' != typeof input) throw new TypeError('Expected a non-empty string');
|
|
1298
|
-
let parsed = {
|
|
1299
|
-
negated: false,
|
|
1300
|
-
fastpaths: true
|
|
1301
|
-
};
|
|
1302
|
-
if (false !== options.fastpaths && ('.' === input[0] || '*' === input[0])) parsed.output = parse.fastpaths(input, options);
|
|
1303
|
-
if (!parsed.output) parsed = parse(input, options);
|
|
1304
|
-
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1305
|
-
};
|
|
1306
|
-
picomatch.toRegex = (source, options)=>{
|
|
1307
|
-
try {
|
|
1308
|
-
const opts = options || {};
|
|
1309
|
-
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
1310
|
-
} catch (err) {
|
|
1311
|
-
if (options && true === options.debug) throw err;
|
|
1312
|
-
return /$^/;
|
|
1313
|
-
}
|
|
1314
|
-
};
|
|
1315
|
-
picomatch.constants = constants;
|
|
1316
|
-
module.exports = picomatch;
|
|
1317
|
-
},
|
|
1318
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1319
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
1320
|
-
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1321
|
-
const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1322
|
-
const depth = (token)=>{
|
|
1323
|
-
if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
|
|
1324
|
-
};
|
|
1325
|
-
const scan = (input, options)=>{
|
|
1326
|
-
const opts = options || {};
|
|
1327
|
-
const length = input.length - 1;
|
|
1328
|
-
const scanToEnd = true === opts.parts || true === opts.scanToEnd;
|
|
1329
|
-
const slashes = [];
|
|
1330
|
-
const tokens = [];
|
|
1331
|
-
const parts = [];
|
|
1332
|
-
let str = input;
|
|
1333
|
-
let index = -1;
|
|
1334
|
-
let start = 0;
|
|
1335
|
-
let lastIndex = 0;
|
|
1336
|
-
let isBrace = false;
|
|
1337
|
-
let isBracket = false;
|
|
1338
|
-
let isGlob = false;
|
|
1339
|
-
let isExtglob = false;
|
|
1340
|
-
let isGlobstar = false;
|
|
1341
|
-
let braceEscaped = false;
|
|
1342
|
-
let backslashes = false;
|
|
1343
|
-
let negated = false;
|
|
1344
|
-
let negatedExtglob = false;
|
|
1345
|
-
let finished = false;
|
|
1346
|
-
let braces = 0;
|
|
1347
|
-
let prev;
|
|
1348
|
-
let code;
|
|
1349
|
-
let token = {
|
|
1350
|
-
value: '',
|
|
1351
|
-
depth: 0,
|
|
1352
|
-
isGlob: false
|
|
1353
|
-
};
|
|
1354
|
-
const eos = ()=>index >= length;
|
|
1355
|
-
const peek = ()=>str.charCodeAt(index + 1);
|
|
1356
|
-
const advance = ()=>{
|
|
1357
|
-
prev = code;
|
|
1358
|
-
return str.charCodeAt(++index);
|
|
1359
|
-
};
|
|
1360
|
-
while(index < length){
|
|
1361
|
-
code = advance();
|
|
1362
|
-
let next;
|
|
1363
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
1364
|
-
backslashes = token.backslashes = true;
|
|
1365
|
-
code = advance();
|
|
1366
|
-
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
1367
|
-
continue;
|
|
1368
|
-
}
|
|
1369
|
-
if (true === braceEscaped || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1370
|
-
braces++;
|
|
1371
|
-
while(true !== eos() && (code = advance())){
|
|
1372
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
1373
|
-
backslashes = token.backslashes = true;
|
|
1374
|
-
advance();
|
|
1375
|
-
continue;
|
|
1376
|
-
}
|
|
1377
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1378
|
-
braces++;
|
|
1379
|
-
continue;
|
|
1380
|
-
}
|
|
1381
|
-
if (true !== braceEscaped && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1382
|
-
isBrace = token.isBrace = true;
|
|
1383
|
-
isGlob = token.isGlob = true;
|
|
1384
|
-
finished = true;
|
|
1385
|
-
if (true === scanToEnd) continue;
|
|
1386
|
-
break;
|
|
1387
|
-
}
|
|
1388
|
-
if (true !== braceEscaped && code === CHAR_COMMA) {
|
|
1389
|
-
isBrace = token.isBrace = true;
|
|
1390
|
-
isGlob = token.isGlob = true;
|
|
1391
|
-
finished = true;
|
|
1392
|
-
if (true === scanToEnd) continue;
|
|
1393
|
-
break;
|
|
1394
|
-
}
|
|
1395
|
-
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1396
|
-
braces--;
|
|
1397
|
-
if (0 === braces) {
|
|
1398
|
-
braceEscaped = false;
|
|
1399
|
-
isBrace = token.isBrace = true;
|
|
1400
|
-
finished = true;
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
if (true === scanToEnd) continue;
|
|
1406
|
-
break;
|
|
1407
|
-
}
|
|
1408
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
1409
|
-
slashes.push(index);
|
|
1410
|
-
tokens.push(token);
|
|
1411
|
-
token = {
|
|
1412
|
-
value: '',
|
|
1413
|
-
depth: 0,
|
|
1414
|
-
isGlob: false
|
|
1415
|
-
};
|
|
1416
|
-
if (true === finished) continue;
|
|
1417
|
-
if (prev === CHAR_DOT && index === start + 1) {
|
|
1418
|
-
start += 2;
|
|
1419
|
-
continue;
|
|
1420
|
-
}
|
|
1421
|
-
lastIndex = index + 1;
|
|
1422
|
-
continue;
|
|
1423
|
-
}
|
|
1424
|
-
if (true !== opts.noext) {
|
|
1425
|
-
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
1426
|
-
if (true === isExtglobChar && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1427
|
-
isGlob = token.isGlob = true;
|
|
1428
|
-
isExtglob = token.isExtglob = true;
|
|
1429
|
-
finished = true;
|
|
1430
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
1431
|
-
if (true === scanToEnd) {
|
|
1432
|
-
while(true !== eos() && (code = advance())){
|
|
1433
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
1434
|
-
backslashes = token.backslashes = true;
|
|
1435
|
-
code = advance();
|
|
1436
|
-
continue;
|
|
1437
|
-
}
|
|
1438
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1439
|
-
isGlob = token.isGlob = true;
|
|
1440
|
-
finished = true;
|
|
1441
|
-
break;
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
continue;
|
|
1445
|
-
}
|
|
1446
|
-
break;
|
|
1447
|
-
}
|
|
1448
|
-
}
|
|
1449
|
-
if (code === CHAR_ASTERISK) {
|
|
1450
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1451
|
-
isGlob = token.isGlob = true;
|
|
1452
|
-
finished = true;
|
|
1453
|
-
if (true === scanToEnd) continue;
|
|
1454
|
-
break;
|
|
1455
|
-
}
|
|
1456
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
1457
|
-
isGlob = token.isGlob = true;
|
|
1458
|
-
finished = true;
|
|
1459
|
-
if (true === scanToEnd) continue;
|
|
1460
|
-
break;
|
|
1461
|
-
}
|
|
1462
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1463
|
-
while(true !== eos() && (next = advance())){
|
|
1464
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
1465
|
-
backslashes = token.backslashes = true;
|
|
1466
|
-
advance();
|
|
1467
|
-
continue;
|
|
1468
|
-
}
|
|
1469
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1470
|
-
isBracket = token.isBracket = true;
|
|
1471
|
-
isGlob = token.isGlob = true;
|
|
1472
|
-
finished = true;
|
|
1473
|
-
break;
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
if (true === scanToEnd) continue;
|
|
1477
|
-
break;
|
|
1478
|
-
}
|
|
1479
|
-
if (true !== opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1480
|
-
negated = token.negated = true;
|
|
1481
|
-
start++;
|
|
1482
|
-
continue;
|
|
1483
|
-
}
|
|
1484
|
-
if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
|
|
1485
|
-
isGlob = token.isGlob = true;
|
|
1486
|
-
if (true === scanToEnd) {
|
|
1487
|
-
while(true !== eos() && (code = advance())){
|
|
1488
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1489
|
-
backslashes = token.backslashes = true;
|
|
1490
|
-
code = advance();
|
|
1491
|
-
continue;
|
|
1492
|
-
}
|
|
1493
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1494
|
-
finished = true;
|
|
1495
|
-
break;
|
|
1496
|
-
}
|
|
1497
|
-
}
|
|
1498
|
-
continue;
|
|
1499
|
-
}
|
|
1500
|
-
break;
|
|
1501
|
-
}
|
|
1502
|
-
if (true === isGlob) {
|
|
1503
|
-
finished = true;
|
|
1504
|
-
if (true === scanToEnd) continue;
|
|
1505
|
-
break;
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
if (true === opts.noext) {
|
|
1509
|
-
isExtglob = false;
|
|
1510
|
-
isGlob = false;
|
|
1511
|
-
}
|
|
1512
|
-
let base = str;
|
|
1513
|
-
let prefix = '';
|
|
1514
|
-
let glob = '';
|
|
1515
|
-
if (start > 0) {
|
|
1516
|
-
prefix = str.slice(0, start);
|
|
1517
|
-
str = str.slice(start);
|
|
1518
|
-
lastIndex -= start;
|
|
1519
|
-
}
|
|
1520
|
-
if (base && true === isGlob && lastIndex > 0) {
|
|
1521
|
-
base = str.slice(0, lastIndex);
|
|
1522
|
-
glob = str.slice(lastIndex);
|
|
1523
|
-
} else if (true === isGlob) {
|
|
1524
|
-
base = '';
|
|
1525
|
-
glob = str;
|
|
1526
|
-
} else base = str;
|
|
1527
|
-
if (base && '' !== base && '/' !== base && base !== str) {
|
|
1528
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
1529
|
-
}
|
|
1530
|
-
if (true === opts.unescape) {
|
|
1531
|
-
if (glob) glob = utils.removeBackslashes(glob);
|
|
1532
|
-
if (base && true === backslashes) base = utils.removeBackslashes(base);
|
|
1533
|
-
}
|
|
1534
|
-
const state = {
|
|
1535
|
-
prefix,
|
|
1536
|
-
input,
|
|
1537
|
-
start,
|
|
1538
|
-
base,
|
|
1539
|
-
glob,
|
|
1540
|
-
isBrace,
|
|
1541
|
-
isBracket,
|
|
1542
|
-
isGlob,
|
|
1543
|
-
isExtglob,
|
|
1544
|
-
isGlobstar,
|
|
1545
|
-
negated,
|
|
1546
|
-
negatedExtglob
|
|
1547
|
-
};
|
|
1548
|
-
if (true === opts.tokens) {
|
|
1549
|
-
state.maxDepth = 0;
|
|
1550
|
-
if (!isPathSeparator(code)) tokens.push(token);
|
|
1551
|
-
state.tokens = tokens;
|
|
1552
|
-
}
|
|
1553
|
-
if (true === opts.parts || true === opts.tokens) {
|
|
1554
|
-
let prevIndex;
|
|
1555
|
-
for(let idx = 0; idx < slashes.length; idx++){
|
|
1556
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
1557
|
-
const i = slashes[idx];
|
|
1558
|
-
const value = input.slice(n, i);
|
|
1559
|
-
if (opts.tokens) {
|
|
1560
|
-
if (0 === idx && 0 !== start) {
|
|
1561
|
-
tokens[idx].isPrefix = true;
|
|
1562
|
-
tokens[idx].value = prefix;
|
|
1563
|
-
} else tokens[idx].value = value;
|
|
1564
|
-
depth(tokens[idx]);
|
|
1565
|
-
state.maxDepth += tokens[idx].depth;
|
|
1566
|
-
}
|
|
1567
|
-
if (0 !== idx || '' !== value) parts.push(value);
|
|
1568
|
-
prevIndex = i;
|
|
1569
|
-
}
|
|
1570
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1571
|
-
const value = input.slice(prevIndex + 1);
|
|
1572
|
-
parts.push(value);
|
|
1573
|
-
if (opts.tokens) {
|
|
1574
|
-
tokens[tokens.length - 1].value = value;
|
|
1575
|
-
depth(tokens[tokens.length - 1]);
|
|
1576
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
state.slashes = slashes;
|
|
1580
|
-
state.parts = parts;
|
|
1581
|
-
}
|
|
1582
|
-
return state;
|
|
1583
|
-
};
|
|
1584
|
-
module.exports = scan;
|
|
1585
|
-
},
|
|
1586
|
-
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
1587
|
-
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1588
|
-
exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
1589
|
-
exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
|
|
1590
|
-
exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
|
|
1591
|
-
exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
1592
|
-
exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
|
|
1593
|
-
exports.isWindows = ()=>{
|
|
1594
|
-
if ("u" > typeof navigator && navigator.platform) {
|
|
1595
|
-
const platform = navigator.platform.toLowerCase();
|
|
1596
|
-
return 'win32' === platform || 'windows' === platform;
|
|
1597
|
-
}
|
|
1598
|
-
if ("u" > typeof process && process.platform) return 'win32' === process.platform;
|
|
1599
|
-
return false;
|
|
1600
|
-
};
|
|
1601
|
-
exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
|
|
1602
|
-
exports.escapeLast = (input, char, lastIdx)=>{
|
|
1603
|
-
const idx = input.lastIndexOf(char, lastIdx);
|
|
1604
|
-
if (-1 === idx) return input;
|
|
1605
|
-
if ('\\' === input[idx - 1]) return exports.escapeLast(input, char, idx - 1);
|
|
1606
|
-
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
1607
|
-
};
|
|
1608
|
-
exports.removePrefix = (input, state = {})=>{
|
|
1609
|
-
let output = input;
|
|
1610
|
-
if (output.startsWith('./')) {
|
|
1611
|
-
output = output.slice(2);
|
|
1612
|
-
state.prefix = './';
|
|
1613
|
-
}
|
|
1614
|
-
return output;
|
|
1615
|
-
};
|
|
1616
|
-
exports.wrapOutput = (input, state = {}, options = {})=>{
|
|
1617
|
-
const prepend = options.contains ? '' : '^';
|
|
1618
|
-
const append = options.contains ? '' : '$';
|
|
1619
|
-
let output = `${prepend}(?:${input})${append}`;
|
|
1620
|
-
if (true === state.negated) output = `(?:^(?!${output}).*$)`;
|
|
1621
|
-
return output;
|
|
1622
|
-
};
|
|
1623
|
-
exports.basename = (path, { windows } = {})=>{
|
|
1624
|
-
const segs = path.split(windows ? /[\\/]/ : '/');
|
|
1625
|
-
const last = segs[segs.length - 1];
|
|
1626
|
-
if ('' === last) return segs[segs.length - 2];
|
|
1627
|
-
return last;
|
|
1628
|
-
};
|
|
1629
|
-
},
|
|
1630
|
-
child_process (module) {
|
|
1631
|
-
module.exports = __rspack_createRequire_require("child_process");
|
|
1632
|
-
},
|
|
1633
|
-
"fs?8b28" (module) {
|
|
1634
|
-
module.exports = __rspack_createRequire_require("fs");
|
|
1635
|
-
},
|
|
1636
|
-
"path?aeb1" (module) {
|
|
1637
|
-
module.exports = __rspack_createRequire_require("path");
|
|
1638
|
-
},
|
|
1639
|
-
stream (module) {
|
|
1640
|
-
module.exports = __rspack_createRequire_require("stream");
|
|
1641
|
-
}
|
|
1642
|
-
});
|
|
1643
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
1644
|
-
function cleanPath(path) {
|
|
1645
|
-
let normalized = normalize(path);
|
|
1646
|
-
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
1647
|
-
return normalized;
|
|
1648
|
-
}
|
|
1649
|
-
const SLASHES_REGEX = /[\\/]/g;
|
|
1650
|
-
function convertSlashes(path, separator) {
|
|
1651
|
-
return path.replace(SLASHES_REGEX, separator);
|
|
1652
|
-
}
|
|
1653
|
-
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
1654
|
-
function isRootDirectory(path) {
|
|
1655
|
-
return "/" === path || WINDOWS_ROOT_DIR_REGEX.test(path);
|
|
1656
|
-
}
|
|
1657
|
-
function normalizePath(path, options) {
|
|
1658
|
-
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
1659
|
-
const pathNeedsCleaning = "win32" === process.platform && path.includes("/") || path.startsWith(".");
|
|
1660
|
-
if (resolvePaths) path = resolve(path);
|
|
1661
|
-
if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
|
|
1662
|
-
if ("." === path) return "";
|
|
1663
|
-
const needsSeperator = path[path.length - 1] !== pathSeparator;
|
|
1664
|
-
return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
|
|
1665
|
-
}
|
|
1666
|
-
function joinPathWithBasePath(filename, directoryPath) {
|
|
1667
|
-
return directoryPath + filename;
|
|
1668
|
-
}
|
|
1669
|
-
function joinPathWithRelativePath(root, options) {
|
|
1670
|
-
return function(filename, directoryPath) {
|
|
1671
|
-
const sameRoot = directoryPath.startsWith(root);
|
|
1672
|
-
if (sameRoot) return directoryPath.slice(root.length) + filename;
|
|
1673
|
-
return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
1674
|
-
};
|
|
1675
|
-
}
|
|
1676
|
-
function joinPath(filename) {
|
|
1677
|
-
return filename;
|
|
1678
|
-
}
|
|
1679
|
-
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
1680
|
-
return directoryPath + filename + separator;
|
|
1681
|
-
}
|
|
1682
|
-
function build$7(root, options) {
|
|
1683
|
-
const { relativePaths, includeBasePath } = options;
|
|
1684
|
-
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
1685
|
-
}
|
|
1686
|
-
function pushDirectoryWithRelativePath(root) {
|
|
1687
|
-
return function(directoryPath, paths) {
|
|
1688
|
-
paths.push(directoryPath.substring(root.length) || ".");
|
|
1689
|
-
};
|
|
1690
|
-
}
|
|
1691
|
-
function pushDirectoryFilterWithRelativePath(root) {
|
|
1692
|
-
return function(directoryPath, paths, filters) {
|
|
1693
|
-
const relativePath = directoryPath.substring(root.length) || ".";
|
|
1694
|
-
if (filters.every((filter)=>filter(relativePath, true))) paths.push(relativePath);
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
const pushDirectory = (directoryPath, paths)=>{
|
|
1698
|
-
paths.push(directoryPath || ".");
|
|
1699
|
-
};
|
|
1700
|
-
const pushDirectoryFilter = (directoryPath, paths, filters)=>{
|
|
1701
|
-
const path = directoryPath || ".";
|
|
1702
|
-
if (filters.every((filter)=>filter(path, true))) paths.push(path);
|
|
1703
|
-
};
|
|
1704
|
-
const empty$2 = ()=>{};
|
|
1705
|
-
function build$6(root, options) {
|
|
1706
|
-
const { includeDirs, filters, relativePaths } = options;
|
|
1707
|
-
if (!includeDirs) return empty$2;
|
|
1708
|
-
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
1709
|
-
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
1710
|
-
}
|
|
1711
|
-
const pushFileFilterAndCount = (filename, _paths, counts, filters)=>{
|
|
1712
|
-
if (filters.every((filter)=>filter(filename, false))) counts.files++;
|
|
1713
|
-
};
|
|
1714
|
-
const pushFileFilter = (filename, paths, _counts, filters)=>{
|
|
1715
|
-
if (filters.every((filter)=>filter(filename, false))) paths.push(filename);
|
|
1716
|
-
};
|
|
1717
|
-
const pushFileCount = (_filename, _paths, counts, _filters)=>{
|
|
1718
|
-
counts.files++;
|
|
1719
|
-
};
|
|
1720
|
-
const pushFile = (filename, paths)=>{
|
|
1721
|
-
paths.push(filename);
|
|
1722
|
-
};
|
|
1723
|
-
const empty$1 = ()=>{};
|
|
1724
|
-
function build$5(options) {
|
|
1725
|
-
const { excludeFiles, filters, onlyCounts } = options;
|
|
1726
|
-
if (excludeFiles) return empty$1;
|
|
1727
|
-
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
1728
|
-
if (onlyCounts) return pushFileCount;
|
|
1729
|
-
return pushFile;
|
|
1730
|
-
}
|
|
1731
|
-
const getArray = (paths)=>paths;
|
|
1732
|
-
const getArrayGroup = ()=>[
|
|
1733
|
-
""
|
|
1734
|
-
].slice(0, 0);
|
|
1735
|
-
function build$4(options) {
|
|
1736
|
-
return options.group ? getArrayGroup : getArray;
|
|
1737
|
-
}
|
|
1738
|
-
const groupFiles = (groups, directory, files)=>{
|
|
1739
|
-
groups.push({
|
|
1740
|
-
directory,
|
|
1741
|
-
files,
|
|
1742
|
-
dir: directory
|
|
1743
|
-
});
|
|
1744
|
-
};
|
|
1745
|
-
const empty = ()=>{};
|
|
1746
|
-
function build$3(options) {
|
|
1747
|
-
return options.group ? groupFiles : empty;
|
|
1748
|
-
}
|
|
1749
|
-
const resolveSymlinksAsync = function(path, state, callback$1) {
|
|
1750
|
-
const { queue, fs, options: { suppressErrors } } = state;
|
|
1751
|
-
queue.enqueue();
|
|
1752
|
-
fs.realpath(path, (error, resolvedPath)=>{
|
|
1753
|
-
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
1754
|
-
fs.stat(resolvedPath, (error$1, stat)=>{
|
|
1755
|
-
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
1756
|
-
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
|
|
1757
|
-
callback$1(stat, resolvedPath);
|
|
1758
|
-
queue.dequeue(null, state);
|
|
1759
|
-
});
|
|
1760
|
-
});
|
|
1761
|
-
};
|
|
1762
|
-
const resolveSymlinks = function(path, state, callback$1) {
|
|
1763
|
-
const { queue, fs, options: { suppressErrors } } = state;
|
|
1764
|
-
queue.enqueue();
|
|
1765
|
-
try {
|
|
1766
|
-
const resolvedPath = fs.realpathSync(path);
|
|
1767
|
-
const stat = fs.statSync(resolvedPath);
|
|
1768
|
-
if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
|
|
1769
|
-
callback$1(stat, resolvedPath);
|
|
1770
|
-
} catch (e) {
|
|
1771
|
-
if (!suppressErrors) throw e;
|
|
1772
|
-
}
|
|
1773
|
-
};
|
|
1774
|
-
function build$2(options, isSynchronous) {
|
|
1775
|
-
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
1776
|
-
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
1777
|
-
}
|
|
1778
|
-
function isRecursive(path, resolved, state) {
|
|
1779
|
-
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
1780
|
-
let parent = dirname(path);
|
|
1781
|
-
let depth = 1;
|
|
1782
|
-
while(parent !== state.root && depth < 2){
|
|
1783
|
-
const resolvedPath = state.symlinks.get(parent);
|
|
1784
|
-
const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
|
|
1785
|
-
if (isSameRoot) depth++;
|
|
1786
|
-
else parent = dirname(parent);
|
|
1787
|
-
}
|
|
1788
|
-
state.symlinks.set(path, resolved);
|
|
1789
|
-
return depth > 1;
|
|
1790
|
-
}
|
|
1791
|
-
function isRecursiveUsingRealPaths(resolved, state) {
|
|
1792
|
-
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
1793
|
-
}
|
|
1794
|
-
const onlyCountsSync = (state)=>state.counts;
|
|
1795
|
-
const groupsSync = (state)=>state.groups;
|
|
1796
|
-
const defaultSync = (state)=>state.paths;
|
|
1797
|
-
const limitFilesSync = (state)=>state.paths.slice(0, state.options.maxFiles);
|
|
1798
|
-
const onlyCountsAsync = (state, error, callback$1)=>{
|
|
1799
|
-
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
1800
|
-
return null;
|
|
1801
|
-
};
|
|
1802
|
-
const defaultAsync = (state, error, callback$1)=>{
|
|
1803
|
-
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
1804
|
-
return null;
|
|
1805
|
-
};
|
|
1806
|
-
const limitFilesAsync = (state, error, callback$1)=>{
|
|
1807
|
-
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
1808
|
-
return null;
|
|
1809
|
-
};
|
|
1810
|
-
const groupsAsync = (state, error, callback$1)=>{
|
|
1811
|
-
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
1812
|
-
return null;
|
|
1813
|
-
};
|
|
1814
|
-
function report(error, callback$1, output, suppressErrors) {
|
|
1815
|
-
callback$1(error && !suppressErrors ? error : null, output);
|
|
1816
|
-
}
|
|
1817
|
-
function build$1(options, isSynchronous) {
|
|
1818
|
-
const { onlyCounts, group, maxFiles } = options;
|
|
1819
|
-
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
1820
|
-
if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
1821
|
-
if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
1822
|
-
return isSynchronous ? defaultSync : defaultAsync;
|
|
1823
|
-
}
|
|
1824
|
-
const readdirOpts = {
|
|
1825
|
-
withFileTypes: true
|
|
1826
|
-
};
|
|
1827
|
-
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
|
|
1828
|
-
state.queue.enqueue();
|
|
1829
|
-
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
1830
|
-
const { fs } = state;
|
|
1831
|
-
state.visited.push(crawlPath);
|
|
1832
|
-
state.counts.directories++;
|
|
1833
|
-
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = [])=>{
|
|
1834
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
1835
|
-
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
1836
|
-
});
|
|
1837
|
-
};
|
|
1838
|
-
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
|
|
1839
|
-
const { fs } = state;
|
|
1840
|
-
if (currentDepth < 0) return;
|
|
1841
|
-
state.visited.push(crawlPath);
|
|
1842
|
-
state.counts.directories++;
|
|
1843
|
-
let entries = [];
|
|
1844
|
-
try {
|
|
1845
|
-
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
1846
|
-
} catch (e) {
|
|
1847
|
-
if (!state.options.suppressErrors) throw e;
|
|
1848
|
-
}
|
|
1849
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
1850
|
-
};
|
|
1851
|
-
function build(isSynchronous) {
|
|
1852
|
-
return isSynchronous ? walkSync : walkAsync;
|
|
1853
|
-
}
|
|
1854
|
-
var Queue = class {
|
|
1855
|
-
count = 0;
|
|
1856
|
-
constructor(onQueueEmpty){
|
|
1857
|
-
this.onQueueEmpty = onQueueEmpty;
|
|
1858
|
-
}
|
|
1859
|
-
enqueue() {
|
|
1860
|
-
this.count++;
|
|
1861
|
-
return this.count;
|
|
1862
|
-
}
|
|
1863
|
-
dequeue(error, output) {
|
|
1864
|
-
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
1865
|
-
this.onQueueEmpty(error, output);
|
|
1866
|
-
if (error) {
|
|
1867
|
-
output.controller.abort();
|
|
1868
|
-
this.onQueueEmpty = void 0;
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
};
|
|
1873
|
-
var Counter = class {
|
|
1874
|
-
_files = 0;
|
|
1875
|
-
_directories = 0;
|
|
1876
|
-
set files(num) {
|
|
1877
|
-
this._files = num;
|
|
1878
|
-
}
|
|
1879
|
-
get files() {
|
|
1880
|
-
return this._files;
|
|
1881
|
-
}
|
|
1882
|
-
set directories(num) {
|
|
1883
|
-
this._directories = num;
|
|
1884
|
-
}
|
|
1885
|
-
get directories() {
|
|
1886
|
-
return this._directories;
|
|
1887
|
-
}
|
|
1888
|
-
get dirs() {
|
|
1889
|
-
return this._directories;
|
|
1890
|
-
}
|
|
1891
|
-
};
|
|
1892
|
-
var Aborter = class {
|
|
1893
|
-
aborted = false;
|
|
1894
|
-
abort() {
|
|
1895
|
-
this.aborted = true;
|
|
1896
|
-
}
|
|
1897
|
-
};
|
|
1898
|
-
var Walker = class {
|
|
1899
|
-
root;
|
|
1900
|
-
isSynchronous;
|
|
1901
|
-
state;
|
|
1902
|
-
joinPath;
|
|
1903
|
-
pushDirectory;
|
|
1904
|
-
pushFile;
|
|
1905
|
-
getArray;
|
|
1906
|
-
groupFiles;
|
|
1907
|
-
resolveSymlink;
|
|
1908
|
-
walkDirectory;
|
|
1909
|
-
callbackInvoker;
|
|
1910
|
-
constructor(root, options, callback$1){
|
|
1911
|
-
this.isSynchronous = !callback$1;
|
|
1912
|
-
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
1913
|
-
this.root = normalizePath(root, options);
|
|
1914
|
-
this.state = {
|
|
1915
|
-
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
1916
|
-
paths: [
|
|
1917
|
-
""
|
|
1918
|
-
].slice(0, 0),
|
|
1919
|
-
groups: [],
|
|
1920
|
-
counts: new Counter(),
|
|
1921
|
-
options,
|
|
1922
|
-
queue: new Queue((error, state)=>this.callbackInvoker(state, error, callback$1)),
|
|
1923
|
-
symlinks: /* @__PURE__ */ new Map(),
|
|
1924
|
-
visited: [
|
|
1925
|
-
""
|
|
1926
|
-
].slice(0, 0),
|
|
1927
|
-
controller: new Aborter(),
|
|
1928
|
-
fs: options.fs || __rspack_external_fs
|
|
1929
|
-
};
|
|
1930
|
-
this.joinPath = build$7(this.root, options);
|
|
1931
|
-
this.pushDirectory = build$6(this.root, options);
|
|
1932
|
-
this.pushFile = build$5(options);
|
|
1933
|
-
this.getArray = build$4(options);
|
|
1934
|
-
this.groupFiles = build$3(options);
|
|
1935
|
-
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
1936
|
-
this.walkDirectory = build(this.isSynchronous);
|
|
1937
|
-
}
|
|
1938
|
-
start() {
|
|
1939
|
-
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
1940
|
-
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
1941
|
-
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
1942
|
-
}
|
|
1943
|
-
walk = (entries, directoryPath, depth)=>{
|
|
1944
|
-
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
1945
|
-
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
1946
|
-
const files = this.getArray(this.state.paths);
|
|
1947
|
-
for(let i = 0; i < entries.length; ++i){
|
|
1948
|
-
const entry = entries[i];
|
|
1949
|
-
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
1950
|
-
const filename = this.joinPath(entry.name, directoryPath);
|
|
1951
|
-
this.pushFile(filename, files, this.state.counts, filters);
|
|
1952
|
-
} else if (entry.isDirectory()) {
|
|
1953
|
-
let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
1954
|
-
if (exclude && exclude(entry.name, path)) continue;
|
|
1955
|
-
this.pushDirectory(path, paths, filters);
|
|
1956
|
-
this.walkDirectory(this.state, path, path, depth - 1, this.walk);
|
|
1957
|
-
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
1958
|
-
let path = joinPathWithBasePath(entry.name, directoryPath);
|
|
1959
|
-
this.resolveSymlink(path, this.state, (stat, resolvedPath)=>{
|
|
1960
|
-
if (stat.isDirectory()) {
|
|
1961
|
-
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
1962
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
|
|
1963
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
|
|
1964
|
-
} else {
|
|
1965
|
-
resolvedPath = useRealPaths ? resolvedPath : path;
|
|
1966
|
-
const filename = basename(resolvedPath);
|
|
1967
|
-
const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
|
|
1968
|
-
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
1969
|
-
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
1970
|
-
}
|
|
1971
|
-
});
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
this.groupFiles(this.state.groups, directoryPath, files);
|
|
1975
|
-
};
|
|
1976
|
-
};
|
|
1977
|
-
function promise(root, options) {
|
|
1978
|
-
return new Promise((resolve$1, reject)=>{
|
|
1979
|
-
callback(root, options, (err, output)=>{
|
|
1980
|
-
if (err) return reject(err);
|
|
1981
|
-
resolve$1(output);
|
|
1982
|
-
});
|
|
1983
|
-
});
|
|
1984
|
-
}
|
|
1985
|
-
function callback(root, options, callback$1) {
|
|
1986
|
-
let walker = new Walker(root, options, callback$1);
|
|
1987
|
-
walker.start();
|
|
1988
|
-
}
|
|
1989
|
-
function sync(root, options) {
|
|
1990
|
-
const walker = new Walker(root, options);
|
|
1991
|
-
return walker.start();
|
|
1992
|
-
}
|
|
1993
|
-
var APIBuilder = class {
|
|
1994
|
-
constructor(root, options){
|
|
1995
|
-
this.root = root;
|
|
1996
|
-
this.options = options;
|
|
1997
|
-
}
|
|
1998
|
-
withPromise() {
|
|
1999
|
-
return promise(this.root, this.options);
|
|
2000
|
-
}
|
|
2001
|
-
withCallback(cb) {
|
|
2002
|
-
callback(this.root, this.options, cb);
|
|
2003
|
-
}
|
|
2004
|
-
sync() {
|
|
2005
|
-
return sync(this.root, this.options);
|
|
2006
|
-
}
|
|
2007
|
-
};
|
|
2008
|
-
let pm = null;
|
|
2009
|
-
try {
|
|
2010
|
-
__require.resolve("picomatch");
|
|
2011
|
-
pm = __require("picomatch");
|
|
2012
|
-
} catch {}
|
|
2013
|
-
var Builder = class {
|
|
2014
|
-
globCache = {};
|
|
2015
|
-
options = {
|
|
2016
|
-
maxDepth: 1 / 0,
|
|
2017
|
-
suppressErrors: true,
|
|
2018
|
-
pathSeparator: sep,
|
|
2019
|
-
filters: []
|
|
2020
|
-
};
|
|
2021
|
-
globFunction;
|
|
2022
|
-
constructor(options){
|
|
2023
|
-
this.options = {
|
|
2024
|
-
...this.options,
|
|
2025
|
-
...options
|
|
2026
|
-
};
|
|
2027
|
-
this.globFunction = this.options.globFunction;
|
|
2028
|
-
}
|
|
2029
|
-
group() {
|
|
2030
|
-
this.options.group = true;
|
|
2031
|
-
return this;
|
|
2032
|
-
}
|
|
2033
|
-
withPathSeparator(separator) {
|
|
2034
|
-
this.options.pathSeparator = separator;
|
|
2035
|
-
return this;
|
|
2036
|
-
}
|
|
2037
|
-
withBasePath() {
|
|
2038
|
-
this.options.includeBasePath = true;
|
|
2039
|
-
return this;
|
|
2040
|
-
}
|
|
2041
|
-
withRelativePaths() {
|
|
2042
|
-
this.options.relativePaths = true;
|
|
2043
|
-
return this;
|
|
2044
|
-
}
|
|
2045
|
-
withDirs() {
|
|
2046
|
-
this.options.includeDirs = true;
|
|
2047
|
-
return this;
|
|
2048
|
-
}
|
|
2049
|
-
withMaxDepth(depth) {
|
|
2050
|
-
this.options.maxDepth = depth;
|
|
2051
|
-
return this;
|
|
2052
|
-
}
|
|
2053
|
-
withMaxFiles(limit) {
|
|
2054
|
-
this.options.maxFiles = limit;
|
|
2055
|
-
return this;
|
|
2056
|
-
}
|
|
2057
|
-
withFullPaths() {
|
|
2058
|
-
this.options.resolvePaths = true;
|
|
2059
|
-
this.options.includeBasePath = true;
|
|
2060
|
-
return this;
|
|
2061
|
-
}
|
|
2062
|
-
withErrors() {
|
|
2063
|
-
this.options.suppressErrors = false;
|
|
2064
|
-
return this;
|
|
2065
|
-
}
|
|
2066
|
-
withSymlinks({ resolvePaths = true } = {}) {
|
|
2067
|
-
this.options.resolveSymlinks = true;
|
|
2068
|
-
this.options.useRealPaths = resolvePaths;
|
|
2069
|
-
return this.withFullPaths();
|
|
2070
|
-
}
|
|
2071
|
-
withAbortSignal(signal) {
|
|
2072
|
-
this.options.signal = signal;
|
|
2073
|
-
return this;
|
|
2074
|
-
}
|
|
2075
|
-
normalize() {
|
|
2076
|
-
this.options.normalizePath = true;
|
|
2077
|
-
return this;
|
|
2078
|
-
}
|
|
2079
|
-
filter(predicate) {
|
|
2080
|
-
this.options.filters.push(predicate);
|
|
2081
|
-
return this;
|
|
2082
|
-
}
|
|
2083
|
-
onlyDirs() {
|
|
2084
|
-
this.options.excludeFiles = true;
|
|
2085
|
-
this.options.includeDirs = true;
|
|
2086
|
-
return this;
|
|
2087
|
-
}
|
|
2088
|
-
exclude(predicate) {
|
|
2089
|
-
this.options.exclude = predicate;
|
|
2090
|
-
return this;
|
|
2091
|
-
}
|
|
2092
|
-
onlyCounts() {
|
|
2093
|
-
this.options.onlyCounts = true;
|
|
2094
|
-
return this;
|
|
2095
|
-
}
|
|
2096
|
-
crawl(root) {
|
|
2097
|
-
return new APIBuilder(root || ".", this.options);
|
|
2098
|
-
}
|
|
2099
|
-
withGlobFunction(fn) {
|
|
2100
|
-
this.globFunction = fn;
|
|
2101
|
-
return this;
|
|
2102
|
-
}
|
|
2103
|
-
crawlWithOptions(root, options) {
|
|
2104
|
-
this.options = {
|
|
2105
|
-
...this.options,
|
|
2106
|
-
...options
|
|
2107
|
-
};
|
|
2108
|
-
return new APIBuilder(root || ".", this.options);
|
|
2109
|
-
}
|
|
2110
|
-
glob(...patterns) {
|
|
2111
|
-
if (this.globFunction) return this.globWithOptions(patterns);
|
|
2112
|
-
return this.globWithOptions(patterns, {
|
|
2113
|
-
dot: true
|
|
2114
|
-
});
|
|
2115
|
-
}
|
|
2116
|
-
globWithOptions(patterns, ...options) {
|
|
2117
|
-
const globFn = this.globFunction || pm;
|
|
2118
|
-
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
2119
|
-
var isMatch = this.globCache[patterns.join("\0")];
|
|
2120
|
-
if (!isMatch) {
|
|
2121
|
-
isMatch = globFn(patterns, ...options);
|
|
2122
|
-
this.globCache[patterns.join("\0")] = isMatch;
|
|
2123
|
-
}
|
|
2124
|
-
this.options.filters.push((path)=>isMatch(path));
|
|
2125
|
-
return this;
|
|
2126
|
-
}
|
|
2127
|
-
};
|
|
2128
|
-
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
|
|
2129
|
-
const isReadonlyArray = Array.isArray;
|
|
2130
|
-
const BACKSLASHES = /\\/g;
|
|
2131
|
-
const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
|
|
2132
|
-
const isWin = "win32" === process.platform;
|
|
2133
|
-
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2134
|
-
function getPartialMatcher(patterns, options = {}) {
|
|
2135
|
-
const patternsCount = patterns.length;
|
|
2136
|
-
const patternsParts = Array(patternsCount);
|
|
2137
|
-
const matchers = Array(patternsCount);
|
|
2138
|
-
let i, j;
|
|
2139
|
-
for(i = 0; i < patternsCount; i++){
|
|
2140
|
-
const parts = splitPattern(patterns[i]);
|
|
2141
|
-
patternsParts[i] = parts;
|
|
2142
|
-
const partsCount = parts.length;
|
|
2143
|
-
const partMatchers = Array(partsCount);
|
|
2144
|
-
for(j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
|
|
2145
|
-
matchers[i] = partMatchers;
|
|
2146
|
-
}
|
|
2147
|
-
return (input)=>{
|
|
2148
|
-
const inputParts = input.split("/");
|
|
2149
|
-
if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
2150
|
-
for(i = 0; i < patternsCount; i++){
|
|
2151
|
-
const patternParts = patternsParts[i];
|
|
2152
|
-
const matcher = matchers[i];
|
|
2153
|
-
const inputPatternCount = inputParts.length;
|
|
2154
|
-
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2155
|
-
j = 0;
|
|
2156
|
-
while(j < minParts){
|
|
2157
|
-
const part = patternParts[j];
|
|
2158
|
-
if (part.includes("/")) return true;
|
|
2159
|
-
if (!matcher[j](inputParts[j])) break;
|
|
2160
|
-
if (!options.noglobstar && "**" === part) return true;
|
|
2161
|
-
j++;
|
|
2162
|
-
}
|
|
2163
|
-
if (j === inputPatternCount) return true;
|
|
2164
|
-
}
|
|
2165
|
-
return false;
|
|
2166
|
-
};
|
|
2167
|
-
}
|
|
2168
|
-
const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
|
|
2169
|
-
const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
|
|
2170
|
-
function buildFormat(cwd, root, absolute) {
|
|
2171
|
-
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
|
2172
|
-
if (absolute) {
|
|
2173
|
-
const start = cwd.length + +!isRoot(cwd);
|
|
2174
|
-
return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
|
|
2175
|
-
}
|
|
2176
|
-
const prefix = root.slice(cwd.length + 1);
|
|
2177
|
-
if (prefix) return (p, isDir)=>{
|
|
2178
|
-
if ("." === p) return prefix;
|
|
2179
|
-
const result = `${prefix}/${p}`;
|
|
2180
|
-
return isDir ? result.slice(0, -1) : result;
|
|
2181
|
-
};
|
|
2182
|
-
return (p, isDir)=>isDir && "." !== p ? p.slice(0, -1) : p;
|
|
2183
|
-
}
|
|
2184
|
-
if (absolute) return (p)=>posix.relative(cwd, p) || ".";
|
|
2185
|
-
return (p)=>posix.relative(cwd, `${root}/${p}`) || ".";
|
|
2186
|
-
}
|
|
2187
|
-
function buildRelative(cwd, root) {
|
|
2188
|
-
if (root.startsWith(`${cwd}/`)) {
|
|
2189
|
-
const prefix = root.slice(cwd.length + 1);
|
|
2190
|
-
return (p)=>`${prefix}/${p}`;
|
|
2191
|
-
}
|
|
2192
|
-
return (p)=>{
|
|
2193
|
-
const result = posix.relative(cwd, `${root}/${p}`);
|
|
2194
|
-
return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
|
|
2195
|
-
};
|
|
2196
|
-
}
|
|
2197
|
-
function ensureNonDriveRelativePath(path) {
|
|
2198
|
-
return path.replace(DRIVE_RELATIVE_PATH, (match)=>`${match}/`);
|
|
2199
|
-
}
|
|
2200
|
-
const splitPatternOptions = {
|
|
2201
|
-
parts: true
|
|
2202
|
-
};
|
|
2203
|
-
function splitPattern(path) {
|
|
2204
|
-
var _result$parts;
|
|
2205
|
-
const result = picomatch.scan(path, splitPatternOptions);
|
|
2206
|
-
return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
|
|
2207
|
-
path
|
|
2208
|
-
];
|
|
2209
|
-
}
|
|
2210
|
-
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
2211
|
-
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
2212
|
-
const escapePosixPath = (path)=>path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2213
|
-
const escapeWin32Path = (path)=>path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2214
|
-
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
2215
|
-
function isDynamicPattern(pattern, options) {
|
|
2216
|
-
if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
2217
|
-
const scan = picomatch.scan(pattern);
|
|
2218
|
-
return scan.isGlob || scan.negated;
|
|
2219
|
-
}
|
|
2220
|
-
function log(...tasks) {
|
|
2221
|
-
console.log(`[tinyglobby ${/* @__PURE__ */ new Date().toLocaleTimeString("es")}]`, ...tasks);
|
|
2222
|
-
}
|
|
2223
|
-
function ensureStringArray(value) {
|
|
2224
|
-
return "string" == typeof value ? [
|
|
2225
|
-
value
|
|
2226
|
-
] : null != value ? value : [];
|
|
2227
|
-
}
|
|
2228
|
-
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
2229
|
-
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
2230
|
-
function normalizePattern(pattern, opts, props, isIgnore) {
|
|
2231
|
-
var _PARENT_DIRECTORY$exe;
|
|
2232
|
-
const cwd = opts.cwd;
|
|
2233
|
-
let result = pattern;
|
|
2234
|
-
if ("/" === pattern[pattern.length - 1]) result = pattern.slice(0, -1);
|
|
2235
|
-
if ("*" !== result[result.length - 1] && opts.expandDirectories) result += "/**";
|
|
2236
|
-
const escapedCwd = escapePath(cwd);
|
|
2237
|
-
result = isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
|
|
2238
|
-
const parentDir = null == (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) ? void 0 : _PARENT_DIRECTORY$exe[0];
|
|
2239
|
-
const parts = splitPattern(result);
|
|
2240
|
-
if (parentDir) {
|
|
2241
|
-
const n = (parentDir.length + 1) / 3;
|
|
2242
|
-
let i = 0;
|
|
2243
|
-
const cwdParts = escapedCwd.split("/");
|
|
2244
|
-
while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
|
|
2245
|
-
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2246
|
-
i++;
|
|
2247
|
-
}
|
|
2248
|
-
const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
|
|
2249
|
-
if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
|
|
2250
|
-
props.root = ensureNonDriveRelativePath(potentialRoot);
|
|
2251
|
-
props.depthOffset = -n + i;
|
|
2252
|
-
}
|
|
2253
|
-
}
|
|
2254
|
-
if (!isIgnore && props.depthOffset >= 0) {
|
|
2255
|
-
null != props.commonPath || (props.commonPath = parts);
|
|
2256
|
-
const newCommonPath = [];
|
|
2257
|
-
const length = Math.min(props.commonPath.length, parts.length);
|
|
2258
|
-
for(let i = 0; i < length; i++){
|
|
2259
|
-
const part = parts[i];
|
|
2260
|
-
if ("**" === part && !parts[i + 1]) {
|
|
2261
|
-
newCommonPath.pop();
|
|
2262
|
-
break;
|
|
2263
|
-
}
|
|
2264
|
-
if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
|
|
2265
|
-
newCommonPath.push(part);
|
|
2266
|
-
}
|
|
2267
|
-
props.depthOffset = newCommonPath.length;
|
|
2268
|
-
props.commonPath = newCommonPath;
|
|
2269
|
-
props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
|
|
2270
|
-
}
|
|
2271
|
-
return result;
|
|
2272
|
-
}
|
|
2273
|
-
function processPatterns(options, patterns, props) {
|
|
2274
|
-
const matchPatterns = [];
|
|
2275
|
-
const ignorePatterns = [];
|
|
2276
|
-
for (const pattern of options.ignore)if (pattern) {
|
|
2277
|
-
if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, options, props, true));
|
|
2278
|
-
}
|
|
2279
|
-
for (const pattern of patterns)if (pattern) {
|
|
2280
|
-
if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, options, props, false));
|
|
2281
|
-
else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
|
|
2282
|
-
}
|
|
2283
|
-
return {
|
|
2284
|
-
match: matchPatterns,
|
|
2285
|
-
ignore: ignorePatterns
|
|
2286
|
-
};
|
|
2287
|
-
}
|
|
2288
|
-
function buildCrawler(options, patterns) {
|
|
2289
|
-
const cwd = options.cwd;
|
|
2290
|
-
const props = {
|
|
2291
|
-
root: cwd,
|
|
2292
|
-
depthOffset: 0
|
|
2293
|
-
};
|
|
2294
|
-
const processed = processPatterns(options, patterns, props);
|
|
2295
|
-
if (options.debug) log("internal processing patterns:", processed);
|
|
2296
|
-
const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
|
|
2297
|
-
const root = props.root.replace(BACKSLASHES, "");
|
|
2298
|
-
const matchOptions = {
|
|
2299
|
-
dot,
|
|
2300
|
-
nobrace: false === options.braceExpansion,
|
|
2301
|
-
nocase: !caseSensitiveMatch,
|
|
2302
|
-
noextglob: false === options.extglob,
|
|
2303
|
-
noglobstar: false === options.globstar,
|
|
2304
|
-
posix: true
|
|
2305
|
-
};
|
|
2306
|
-
const matcher = picomatch(processed.match, matchOptions);
|
|
2307
|
-
const ignore = picomatch(processed.ignore, matchOptions);
|
|
2308
|
-
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
|
2309
|
-
const format = buildFormat(cwd, root, absolute);
|
|
2310
|
-
const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
|
|
2311
|
-
const excludePredicate = (_, p)=>{
|
|
2312
|
-
const relativePath = excludeFormatter(p, true);
|
|
2313
|
-
return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2314
|
-
};
|
|
2315
|
-
let maxDepth;
|
|
2316
|
-
if (void 0 !== options.deep) maxDepth = Math.round(options.deep - props.depthOffset);
|
|
2317
|
-
const crawler = new Builder({
|
|
2318
|
-
filters: [
|
|
2319
|
-
debug ? (p, isDirectory)=>{
|
|
2320
|
-
const path = format(p, isDirectory);
|
|
2321
|
-
const matches = matcher(path) && !ignore(path);
|
|
2322
|
-
if (matches) log(`matched ${path}`);
|
|
2323
|
-
return matches;
|
|
2324
|
-
} : (p, isDirectory)=>{
|
|
2325
|
-
const path = format(p, isDirectory);
|
|
2326
|
-
return matcher(path) && !ignore(path);
|
|
2327
|
-
}
|
|
2328
|
-
],
|
|
2329
|
-
exclude: debug ? (_, p)=>{
|
|
2330
|
-
const skipped = excludePredicate(_, p);
|
|
2331
|
-
log(`${skipped ? "skipped" : "crawling"} ${p}`);
|
|
2332
|
-
return skipped;
|
|
2333
|
-
} : excludePredicate,
|
|
2334
|
-
fs: options.fs,
|
|
2335
|
-
pathSeparator: "/",
|
|
2336
|
-
relativePaths: !absolute,
|
|
2337
|
-
resolvePaths: absolute,
|
|
2338
|
-
includeBasePath: absolute,
|
|
2339
|
-
resolveSymlinks: followSymbolicLinks,
|
|
2340
|
-
excludeSymlinks: !followSymbolicLinks,
|
|
2341
|
-
excludeFiles: onlyDirectories,
|
|
2342
|
-
includeDirs: onlyDirectories || !options.onlyFiles,
|
|
2343
|
-
maxDepth,
|
|
2344
|
-
signal: options.signal
|
|
2345
|
-
}).crawl(root);
|
|
2346
|
-
if (options.debug) log("internal properties:", {
|
|
2347
|
-
...props,
|
|
2348
|
-
root
|
|
2349
|
-
});
|
|
2350
|
-
return [
|
|
2351
|
-
crawler,
|
|
2352
|
-
cwd !== root && !absolute && buildRelative(cwd, root)
|
|
2353
|
-
];
|
|
2354
|
-
}
|
|
2355
|
-
function formatPaths(paths, mapper) {
|
|
2356
|
-
if (mapper) for(let i = paths.length - 1; i >= 0; i--)paths[i] = mapper(paths[i]);
|
|
2357
|
-
return paths;
|
|
2358
|
-
}
|
|
2359
|
-
const defaultOptions = {
|
|
2360
|
-
caseSensitiveMatch: true,
|
|
2361
|
-
debug: !!process.env.TINYGLOBBY_DEBUG,
|
|
2362
|
-
expandDirectories: true,
|
|
2363
|
-
followSymbolicLinks: true,
|
|
2364
|
-
onlyFiles: true
|
|
2365
|
-
};
|
|
2366
|
-
function getOptions(options) {
|
|
2367
|
-
const opts = Object.assign({}, options);
|
|
2368
|
-
for(const key in defaultOptions)if (void 0 === opts[key]) Object.assign(opts, {
|
|
2369
|
-
[key]: defaultOptions[key]
|
|
2370
|
-
});
|
|
2371
|
-
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : resolve(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
|
|
2372
|
-
opts.ignore = ensureStringArray(opts.ignore);
|
|
2373
|
-
opts.fs && (opts.fs = {
|
|
2374
|
-
readdir: opts.fs.readdir || readdir,
|
|
2375
|
-
readdirSync: opts.fs.readdirSync || readdirSync,
|
|
2376
|
-
realpath: opts.fs.realpath || realpath,
|
|
2377
|
-
realpathSync: opts.fs.realpathSync || realpathSync,
|
|
2378
|
-
stat: opts.fs.stat || external_fs_stat,
|
|
2379
|
-
statSync: opts.fs.statSync || statSync
|
|
2380
|
-
});
|
|
2381
|
-
if (opts.debug) log("globbing with options:", opts);
|
|
2382
|
-
return opts;
|
|
2383
|
-
}
|
|
2384
|
-
function getCrawler(globInput, inputOptions = {}) {
|
|
2385
|
-
var _ref;
|
|
2386
|
-
if (globInput && (null == inputOptions ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2387
|
-
const isModern = isReadonlyArray(globInput) || "string" == typeof globInput;
|
|
2388
|
-
const patterns = ensureStringArray(null != (_ref = isModern ? globInput : globInput.patterns) ? _ref : "**/*");
|
|
2389
|
-
const options = getOptions(isModern ? inputOptions : globInput);
|
|
2390
|
-
return patterns.length > 0 ? buildCrawler(options, patterns) : [];
|
|
2391
|
-
}
|
|
2392
|
-
async function glob(globInput, options) {
|
|
2393
|
-
const [crawler, relative] = getCrawler(globInput, options);
|
|
2394
|
-
return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
|
|
2395
|
-
}
|
|
2396
|
-
const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
|
|
2397
|
-
const pluginVirtualModule = (pluginOptions = {})=>({
|
|
2398
|
-
name: PLUGIN_VIRTUAL_MODULE_NAME,
|
|
2399
|
-
async setup (api) {
|
|
2400
|
-
const { virtualModules = {}, tempDir: virtualFolderName = '.rsbuild-virtual-module' } = pluginOptions;
|
|
2401
|
-
const TEMP_DIR = join(api.context.rootPath, virtualFolderName);
|
|
2402
|
-
const virtualFileAbsolutePaths = Object.keys(virtualModules).map((i)=>{
|
|
2403
|
-
let absolutePath = join(TEMP_DIR, i);
|
|
2404
|
-
if (!extname(absolutePath)) absolutePath = `${absolutePath}.js`;
|
|
2405
|
-
return [
|
|
2406
|
-
i,
|
|
2407
|
-
absolutePath
|
|
2408
|
-
];
|
|
2409
|
-
});
|
|
2410
|
-
api.modifyBundlerChain((chain, { rspack })=>{
|
|
2411
|
-
const pluginId = 'RSBUILD_VIRTUAL_MODULE_PLUGIN';
|
|
2412
|
-
const virtualModules = Object.fromEntries(virtualFileAbsolutePaths.map((i)=>[
|
|
2413
|
-
i[1],
|
|
2414
|
-
''
|
|
2415
|
-
]));
|
|
2416
|
-
if (chain.plugins.has(pluginId)) chain.plugin(pluginId).tap((options)=>{
|
|
2417
|
-
const existingPaths = new Set(Object.keys(options[0] ?? {}));
|
|
2418
|
-
const conflictPath = virtualFileAbsolutePaths.find(([, path])=>existingPaths.has(path));
|
|
2419
|
-
if (conflictPath) throw new Error(`Virtual module name conflicted: ${conflictPath[0]}`);
|
|
2420
|
-
return [
|
|
2421
|
-
{
|
|
2422
|
-
...options[0],
|
|
2423
|
-
...virtualModules
|
|
2424
|
-
}
|
|
2425
|
-
];
|
|
2426
|
-
});
|
|
2427
|
-
else chain.plugin(pluginId).use(rspack.experiments.VirtualModulesPlugin, [
|
|
2428
|
-
virtualModules
|
|
2429
|
-
]);
|
|
2430
|
-
chain.resolve.alias.merge(Object.fromEntries(virtualFileAbsolutePaths));
|
|
2431
|
-
});
|
|
2432
|
-
for (const [moduleName, absolutePath] of virtualFileAbsolutePaths){
|
|
2433
|
-
const handler = virtualModules[moduleName];
|
|
2434
|
-
if (handler) api.transform({
|
|
2435
|
-
test: absolutePath
|
|
2436
|
-
}, handler);
|
|
2437
|
-
}
|
|
2438
|
-
}
|
|
2439
|
-
});
|
|
2440
|
-
export { DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
|
|
2441
|
-
export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
|
|
2442
|
-
export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeDarkMode, normalizeHref, removeLeadingSlash, removeTrailingSlash, slash, withBase } from "@rspress/shared";
|
|
2443
|
-
export { logger } from "@rspress/shared/logger";
|
|
2444
|
-
export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
|
|
2445
|
-
export { createRequire as external_node_module_createRequire } from "node:module";
|
|
2446
|
-
export { cwd as external_node_process_cwd } from "node:process";
|
|
2447
|
-
export { fileURLToPath as external_node_url_fileURLToPath, pathToFileURL } from "node:url";
|
|
2448
|
-
export { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
|
|
2449
|
-
export { chunk, groupBy } from "@rspress/shared/lodash-es";
|
|
2450
|
-
export { default as remark_gfm } from "remark-gfm";
|
|
2451
|
-
export { default as remark_parse } from "remark-parse";
|
|
2452
|
-
export { unified } from "unified";
|
|
2453
|
-
export { remove } from "unist-util-remove";
|
|
2454
|
-
export { default as node_fs } from "node:fs";
|
|
2455
|
-
export { createProcessor } from "@mdx-js/mdx";
|
|
2456
|
-
export { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
|
|
2457
|
-
export { createHash } from "node:crypto";
|
|
2458
|
-
export { default as node_os } from "node:os";
|
|
2459
|
-
export { matchPath } from "react-router-dom";
|
|
2460
|
-
export { createHead } from "@unhead/react/server";
|
|
2461
|
-
export { external_node_path_relative, extname, glob, join, node_path, pluginVirtualModule };
|