@rspress/core 2.0.18 → 2.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/dist/2711~0.js +3007 -0
  2. package/dist/{4538.js → 4538~0.js} +1 -1
  3. package/dist/{5357.js → 5357~0.js} +1 -1
  4. package/dist/{3553.js → 8472~0.js} +3 -3
  5. package/dist/{0~execa.js → 864~0.js} +11 -11
  6. package/dist/cli/index.js +13 -40
  7. package/dist/config/defineConfig.d.ts +15 -15
  8. package/dist/config/loadConfigFile.js +2 -3
  9. package/dist/eject-theme/components/HoverGroup/index.scss +16 -0
  10. package/dist/eject-theme/components/HoverGroup/index.tsx +22 -1
  11. package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +2 -6
  12. package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +2 -5
  13. package/dist/eject-theme/components/Llms/LlmsHint.test.tsx +104 -0
  14. package/dist/eject-theme/components/Llms/LlmsHint.tsx +74 -0
  15. package/dist/eject-theme/components/Llms/getLlmsCopyContent.test.ts +21 -0
  16. package/dist/eject-theme/components/Llms/getLlmsCopyContent.ts +20 -0
  17. package/dist/eject-theme/components/Llms/index.tsx +1 -1
  18. package/dist/eject-theme/components/Nav/NavMenu.scss +16 -0
  19. package/dist/eject-theme/components/Nav/NavMenu.tsx +12 -0
  20. package/dist/eject-theme/components/Nav/hooks.tsx +1 -2
  21. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.scss +18 -2
  22. package/dist/eject-theme/components/NavScreen/NavScreenMenuItem.tsx +27 -19
  23. package/dist/eject-theme/components/NavScreen/index.scss +4 -0
  24. package/dist/eject-theme/components/Outline/index.scss +4 -0
  25. package/dist/eject-theme/components/Search/logic/providers/LocalProvider.ts +1 -1
  26. package/dist/eject-theme/components/Sidebar/SidebarGroup.tsx +3 -0
  27. package/dist/eject-theme/components/Sidebar/SidebarItem.scss +16 -0
  28. package/dist/eject-theme/components/Sidebar/SidebarItem.test.tsx +51 -0
  29. package/dist/eject-theme/components/Sidebar/SidebarItem.tsx +10 -1
  30. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.scss +15 -0
  31. package/dist/eject-theme/components/Sidebar/SidebarSectionHeader.tsx +6 -1
  32. package/dist/eject-theme/components/Sidebar/index.tsx +1 -0
  33. package/dist/index.js +1 -1
  34. package/dist/node/PluginDriver.js +1 -1
  35. package/dist/node/auto-nav-sidebar/index.js +1 -1
  36. package/dist/node/auto-nav-sidebar/locales.js +1 -1
  37. package/dist/node/auto-nav-sidebar/normalize.js +40 -12
  38. package/dist/node/auto-nav-sidebar/type.d.ts +7 -0
  39. package/dist/node/auto-nav-sidebar/utils.d.ts +1 -0
  40. package/dist/node/auto-nav-sidebar/utils.js +2 -1
  41. package/dist/node/auto-nav-sidebar/walk.js +1 -1
  42. package/dist/node/constants.d.ts +2 -1
  43. package/dist/node/constants.js +50 -2
  44. package/dist/node/dev.d.ts +2 -1
  45. package/dist/node/dev.js +7 -2
  46. package/dist/node/eject.js +3 -3
  47. package/dist/node/initRsbuild.d.ts +6 -2
  48. package/dist/node/initRsbuild.js +37 -13
  49. package/dist/node/last-updated/index.js +113 -16
  50. package/dist/node/logger/hint.js +2 -2
  51. package/dist/node/mdx/options.js +3 -2
  52. package/dist/node/mdx/processor.js +1 -1
  53. package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
  54. package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
  55. package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
  56. package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
  57. package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +3 -3
  58. package/dist/node/mdx/remarkPlugins/image.js +3 -3
  59. package/dist/node/mdx/remarkPlugins/link.d.ts +2 -1
  60. package/dist/node/mdx/remarkPlugins/link.js +8 -7
  61. package/dist/node/mdx/remarkPlugins/toc.js +1 -1
  62. package/dist/node/medium-zoom/index.js +1 -1
  63. package/dist/node/route/RoutePage.d.ts +0 -1
  64. package/dist/node/route/RoutePage.js +4 -6
  65. package/dist/node/route/RouteService.js +1 -1
  66. package/dist/node/route/extractPageData.js +3 -15
  67. package/dist/node/route/normalizeRoutePath.js +2 -3
  68. package/dist/node/runtimeModule/i18n.js +3 -3
  69. package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
  70. package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
  71. package/dist/node/runtimeModule/searchHooks.js +1 -1
  72. package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
  73. package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
  74. package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
  75. package/dist/node/serve.js +1 -1
  76. package/dist/node/ssg/alternateLinks.js +1 -1
  77. package/dist/node/ssg/htmlFile.js +1 -1
  78. package/dist/node/ssg/renderHtmlTemplate.js +1 -1
  79. package/dist/node/ssg/renderPage.js +3 -3
  80. package/dist/node/ssg/renderPageWorker.js +2 -2
  81. package/dist/node/ssg/renderPages.js +6 -6
  82. package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
  83. package/dist/node/ssg/ssgEnv.js +1 -1
  84. package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
  85. package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
  86. package/dist/node/ssg-md/remarkSplitMdx.js +8 -10
  87. package/dist/node/ssg-md/renderPage.js +3 -3
  88. package/dist/node/ssg-md/renderPages.js +4 -4
  89. package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
  90. package/dist/node/utils/checkLanguageParity.js +1 -1
  91. package/dist/node/utils/createHash.js +1 -1
  92. package/dist/node/utils/error.js +2 -2
  93. package/dist/node/utils/flattenMdxContent.js +2 -2
  94. package/dist/node/utils/fs.js +1 -1
  95. package/dist/node/utils/getPageKey.js +1 -1
  96. package/dist/node/utils/normalizePath.js +1 -1
  97. package/dist/node/utils/reactAlias.js +3 -3
  98. package/dist/runtime/App.js +7 -4
  99. package/dist/runtime/csrClientEntry.js +7 -2
  100. package/dist/runtime/index.d.ts +1 -0
  101. package/dist/runtime/index.js +1 -0
  102. package/dist/runtime/reactDom.d.ts +19 -0
  103. package/dist/runtime/reactDom.js +5 -0
  104. package/dist/runtime/route.d.ts +10 -0
  105. package/dist/runtime/route.js +13 -2
  106. package/dist/runtime/ssrClientEntry.js +2 -0
  107. package/dist/theme/components/HoverGroup/index.css +15 -0
  108. package/dist/theme/components/HoverGroup/index.js +17 -1
  109. package/dist/theme/components/Llms/LlmsCopyButton.js +3 -4
  110. package/dist/theme/components/Llms/LlmsCopyRow.js +2 -3
  111. package/dist/theme/components/Llms/LlmsHint.d.ts +2 -0
  112. package/dist/theme/components/Llms/LlmsHint.js +44 -0
  113. package/dist/theme/components/Llms/getLlmsCopyContent.d.ts +1 -0
  114. package/dist/theme/components/Llms/getLlmsCopyContent.js +14 -0
  115. package/dist/theme/components/Llms/index.d.ts +1 -1
  116. package/dist/theme/components/Llms/index.js +1 -1
  117. package/dist/theme/components/Nav/NavMenu.css +15 -0
  118. package/dist/theme/components/Nav/NavMenu.js +8 -0
  119. package/dist/theme/components/Nav/hooks.js +1 -2
  120. package/dist/theme/components/NavScreen/NavScreenMenuItem.css +17 -2
  121. package/dist/theme/components/NavScreen/NavScreenMenuItem.js +21 -22
  122. package/dist/theme/components/NavScreen/index.css +4 -0
  123. package/dist/theme/components/Outline/index.css +4 -0
  124. package/dist/theme/components/Search/logic/providers/LocalProvider.js +1 -1
  125. package/dist/theme/components/Sidebar/SidebarGroup.js +4 -1
  126. package/dist/theme/components/Sidebar/SidebarItem.css +15 -0
  127. package/dist/theme/components/Sidebar/SidebarItem.d.ts +2 -1
  128. package/dist/theme/components/Sidebar/SidebarItem.js +7 -2
  129. package/dist/theme/components/Sidebar/SidebarSectionHeader.css +14 -0
  130. package/dist/theme/components/Sidebar/SidebarSectionHeader.d.ts +2 -1
  131. package/dist/theme/components/Sidebar/SidebarSectionHeader.js +12 -6
  132. package/dist/theme/components/Sidebar/index.js +1 -0
  133. package/dist/theme/components/SwitchAppearance/global.css +3 -16
  134. package/dist/theme/index.d.ts +1 -2
  135. package/dist/theme/index.js +1 -2
  136. package/dist/theme/layout/Layout/index.js +1 -2
  137. package/dist/theme/logic/utils.d.ts +4 -0
  138. package/dist/theme/logic/utils.js +23 -2
  139. package/dist/theme/styles/preflight.css +0 -2
  140. package/meta-json-schema.json +33 -3
  141. package/nav-json-schema.json +9 -0
  142. package/package.json +18 -23
  143. package/dist/5871.js +0 -7275
  144. package/dist/5871.js.LICENSE.txt +0 -41
  145. package/dist/eject-theme/components/Llms/LlmsHiddenHint.test.tsx +0 -23
  146. package/dist/eject-theme/components/Llms/LlmsHiddenHint.tsx +0 -15
  147. package/dist/theme/components/Llms/LlmsHiddenHint.d.ts +0 -1
  148. package/dist/theme/components/Llms/LlmsHiddenHint.js +0 -18
  149. package/dist/theme/logic/useRedirect4FirstVisit.d.ts +0 -5
  150. package/dist/theme/logic/useRedirect4FirstVisit.js +0 -31
  151. /package/dist/{102.js → 102~0.js} +0 -0
  152. /package/dist/{7748.js → 7748~0.js} +0 -0
  153. /package/dist/{0~8016.js → 8016~0.js} +0 -0
  154. /package/dist/{9857.js → 9857~0.js} +0 -0
  155. /package/dist/{9940.js → 9940~0.js} +0 -0
  156. /package/dist/{0~rslib-runtime.js → rslib-runtime~0.js} +0 -0
  157. /package/dist/{0~tinypool.js → tinypool~0.js} +0 -0
package/dist/2711~0.js ADDED
@@ -0,0 +1,3007 @@
1
+ import { __webpack_require__ } from "./rslib-runtime~0.js";
2
+ import { fileURLToPath as external_url_fileURLToPath } from "url";
3
+ import node_path, { extname, join, relative as external_node_path_relative } from "node:path";
4
+ import { basename, dirname, isAbsolute, normalize, posix, relative as external_path_relative, resolve, sep } from "path";
5
+ import * as __rspack_external_fs from "fs";
6
+ import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
7
+ import { createRequire as external_module_createRequire } from "module";
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?cdbd" (module) {
1634
+ module.exports = __rspack_createRequire_require("fs");
1635
+ },
1636
+ "path?37f5" (module) {
1637
+ module.exports = __rspack_createRequire_require("path");
1638
+ },
1639
+ stream (module) {
1640
+ module.exports = __rspack_createRequire_require("stream");
1641
+ }
1642
+ });
1643
+ function toArr(any) {
1644
+ return null == any ? [] : Array.isArray(any) ? any : [
1645
+ any
1646
+ ];
1647
+ }
1648
+ function toVal(out, key, val, opts) {
1649
+ var x, old = out[key], nxt = ~opts.string.indexOf(key) ? null == val || true === val ? "" : String(val) : "boolean" == typeof val ? val : ~opts.boolean.indexOf(key) ? "false" === val ? false : "true" === val || (out._.push((x = +val, 0 * x === 0) ? x : val), !!val) : (x = +val, 0 * x === 0) ? x : val;
1650
+ out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
1651
+ old,
1652
+ nxt
1653
+ ];
1654
+ }
1655
+ function lib_default(args, opts) {
1656
+ args = args || [];
1657
+ opts = opts || {};
1658
+ var k, arr, arg, name, val, out = {
1659
+ _: []
1660
+ };
1661
+ var i = 0, j = 0, idx = 0, len = args.length;
1662
+ const alibi = void 0 !== opts.alias;
1663
+ const strict = void 0 !== opts.unknown;
1664
+ const defaults = void 0 !== opts.default;
1665
+ opts.alias = opts.alias || {};
1666
+ opts.string = toArr(opts.string);
1667
+ opts.boolean = toArr(opts.boolean);
1668
+ if (alibi) for(k in opts.alias){
1669
+ arr = opts.alias[k] = toArr(opts.alias[k]);
1670
+ for(i = 0; i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
1671
+ }
1672
+ for(i = opts.boolean.length; i-- > 0;){
1673
+ arr = opts.alias[opts.boolean[i]] || [];
1674
+ for(j = arr.length; j-- > 0;)opts.boolean.push(arr[j]);
1675
+ }
1676
+ for(i = opts.string.length; i-- > 0;){
1677
+ arr = opts.alias[opts.string[i]] || [];
1678
+ for(j = arr.length; j-- > 0;)opts.string.push(arr[j]);
1679
+ }
1680
+ if (defaults) for(k in opts.default){
1681
+ name = typeof opts.default[k];
1682
+ arr = opts.alias[k] = opts.alias[k] || [];
1683
+ if (void 0 !== opts[name]) {
1684
+ opts[name].push(k);
1685
+ for(i = 0; i < arr.length; i++)opts[name].push(arr[i]);
1686
+ }
1687
+ }
1688
+ const keys = strict ? Object.keys(opts.alias) : [];
1689
+ for(i = 0; i < len; i++){
1690
+ arg = args[i];
1691
+ if ("--" === arg) {
1692
+ out._ = out._.concat(args.slice(++i));
1693
+ break;
1694
+ }
1695
+ for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
1696
+ if (0 === j) out._.push(arg);
1697
+ else if ("no-" === arg.substring(j, j + 3)) {
1698
+ name = arg.substring(j + 3);
1699
+ if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
1700
+ out[name] = false;
1701
+ } else {
1702
+ for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
1703
+ name = arg.substring(j, idx);
1704
+ val = arg.substring(++idx) || i + 1 === len || 45 === ("" + args[i + 1]).charCodeAt(0) || args[++i];
1705
+ arr = 2 === j ? [
1706
+ name
1707
+ ] : name;
1708
+ for(idx = 0; idx < arr.length; idx++){
1709
+ name = arr[idx];
1710
+ if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
1711
+ toVal(out, name, idx + 1 < arr.length || val, opts);
1712
+ }
1713
+ }
1714
+ }
1715
+ if (defaults) {
1716
+ for(k in opts.default)if (void 0 === out[k]) out[k] = opts.default[k];
1717
+ }
1718
+ if (alibi) for(k in out){
1719
+ arr = opts.alias[k] || [];
1720
+ while(arr.length > 0)out[arr.shift()] = out[k];
1721
+ }
1722
+ return out;
1723
+ }
1724
+ function removeBrackets(v) {
1725
+ return v.replace(/[<[].+/, "").trim();
1726
+ }
1727
+ function findAllBrackets(v) {
1728
+ const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
1729
+ const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
1730
+ const res = [];
1731
+ const parse = (match)=>{
1732
+ let variadic = false;
1733
+ let value = match[1];
1734
+ if (value.startsWith("...")) {
1735
+ value = value.slice(3);
1736
+ variadic = true;
1737
+ }
1738
+ return {
1739
+ required: match[0].startsWith("<"),
1740
+ value,
1741
+ variadic
1742
+ };
1743
+ };
1744
+ let angledMatch;
1745
+ while(angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v))res.push(parse(angledMatch));
1746
+ let squareMatch;
1747
+ while(squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))res.push(parse(squareMatch));
1748
+ return res;
1749
+ }
1750
+ function getMriOptions(options) {
1751
+ const result = {
1752
+ alias: {},
1753
+ boolean: []
1754
+ };
1755
+ for (const [index, option] of options.entries()){
1756
+ if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
1757
+ if (option.isBoolean) if (option.negated) {
1758
+ if (!options.some((o, i)=>i !== index && o.names.some((name)=>option.names.includes(name)) && "boolean" == typeof o.required)) result.boolean.push(option.names[0]);
1759
+ } else result.boolean.push(option.names[0]);
1760
+ }
1761
+ return result;
1762
+ }
1763
+ function findLongest(arr) {
1764
+ return arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
1765
+ }
1766
+ function padRight(str, length) {
1767
+ return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
1768
+ }
1769
+ function camelcase(input) {
1770
+ return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
1771
+ }
1772
+ function setDotProp(obj, keys, val) {
1773
+ let current = obj;
1774
+ for(let i = 0; i < keys.length; i++){
1775
+ const key = keys[i];
1776
+ if (i === keys.length - 1) {
1777
+ current[key] = val;
1778
+ return;
1779
+ }
1780
+ if (null == current[key]) {
1781
+ const nextKeyIsArrayIndex = +keys[i + 1] > -1;
1782
+ current[key] = nextKeyIsArrayIndex ? [] : {};
1783
+ }
1784
+ current = current[key];
1785
+ }
1786
+ }
1787
+ function setByType(obj, transforms) {
1788
+ for (const key of Object.keys(transforms)){
1789
+ const transform = transforms[key];
1790
+ if (transform.shouldTransform) {
1791
+ obj[key] = [
1792
+ obj[key]
1793
+ ].flat();
1794
+ if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
1795
+ }
1796
+ }
1797
+ }
1798
+ function getFileName(input) {
1799
+ const m = /([^\\/]+)$/.exec(input);
1800
+ return m ? m[1] : "";
1801
+ }
1802
+ function camelcaseOptionName(name) {
1803
+ return name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
1804
+ }
1805
+ var CACError = class extends Error {
1806
+ constructor(message){
1807
+ super(message);
1808
+ this.name = "CACError";
1809
+ if ("function" != typeof Error.captureStackTrace) this.stack = new Error(message).stack;
1810
+ }
1811
+ };
1812
+ var Option = class {
1813
+ rawName;
1814
+ description;
1815
+ name;
1816
+ names;
1817
+ isBoolean;
1818
+ required;
1819
+ config;
1820
+ negated;
1821
+ constructor(rawName, description, config){
1822
+ this.rawName = rawName;
1823
+ this.description = description;
1824
+ this.config = Object.assign({}, config);
1825
+ rawName = rawName.replaceAll(".*", "");
1826
+ this.negated = false;
1827
+ this.names = removeBrackets(rawName).split(",").map((v)=>{
1828
+ let name = v.trim().replace(/^-{1,2}/, "");
1829
+ if (name.startsWith("no-")) {
1830
+ this.negated = true;
1831
+ name = name.replace(/^no-/, "");
1832
+ }
1833
+ return camelcaseOptionName(name);
1834
+ }).sort((a, b)=>a.length > b.length ? 1 : -1);
1835
+ this.name = this.names.at(-1);
1836
+ if (this.negated && null == this.config.default) this.config.default = true;
1837
+ if (rawName.includes("<")) this.required = true;
1838
+ else if (rawName.includes("[")) this.required = false;
1839
+ else this.isBoolean = true;
1840
+ }
1841
+ };
1842
+ let runtimeProcessArgs;
1843
+ let runtimeInfo;
1844
+ if ("u" > typeof process) {
1845
+ let runtimeName;
1846
+ runtimeName = "u" > typeof Deno && "string" == typeof Deno.version?.deno ? "deno" : "u" > typeof Bun && "string" == typeof Bun.version ? "bun" : "node";
1847
+ runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
1848
+ runtimeProcessArgs = process.argv;
1849
+ } else runtimeInfo = "u" < typeof navigator ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
1850
+ var Command = class {
1851
+ rawName;
1852
+ description;
1853
+ config;
1854
+ cli;
1855
+ options;
1856
+ aliasNames;
1857
+ name;
1858
+ args;
1859
+ commandAction;
1860
+ usageText;
1861
+ versionNumber;
1862
+ examples;
1863
+ helpCallback;
1864
+ globalCommand;
1865
+ constructor(rawName, description, config = {}, cli){
1866
+ this.rawName = rawName;
1867
+ this.description = description;
1868
+ this.config = config;
1869
+ this.cli = cli;
1870
+ this.options = [];
1871
+ this.aliasNames = [];
1872
+ this.name = removeBrackets(rawName);
1873
+ this.args = findAllBrackets(rawName);
1874
+ this.examples = [];
1875
+ }
1876
+ usage(text) {
1877
+ this.usageText = text;
1878
+ return this;
1879
+ }
1880
+ allowUnknownOptions() {
1881
+ this.config.allowUnknownOptions = true;
1882
+ return this;
1883
+ }
1884
+ ignoreOptionDefaultValue() {
1885
+ this.config.ignoreOptionDefaultValue = true;
1886
+ return this;
1887
+ }
1888
+ version(version, customFlags = "-v, --version") {
1889
+ this.versionNumber = version;
1890
+ this.option(customFlags, "Display version number");
1891
+ return this;
1892
+ }
1893
+ example(example) {
1894
+ this.examples.push(example);
1895
+ return this;
1896
+ }
1897
+ option(rawName, description, config) {
1898
+ const option = new Option(rawName, description, config);
1899
+ this.options.push(option);
1900
+ return this;
1901
+ }
1902
+ alias(name) {
1903
+ this.aliasNames.push(name);
1904
+ return this;
1905
+ }
1906
+ action(callback) {
1907
+ this.commandAction = callback;
1908
+ return this;
1909
+ }
1910
+ isMatched(name) {
1911
+ return this.name === name || this.aliasNames.includes(name);
1912
+ }
1913
+ get isDefaultCommand() {
1914
+ return "" === this.name || this.aliasNames.includes("!");
1915
+ }
1916
+ get isGlobalCommand() {
1917
+ return this instanceof GlobalCommand;
1918
+ }
1919
+ hasOption(name) {
1920
+ name = name.split(".")[0];
1921
+ return this.options.find((option)=>option.names.includes(name));
1922
+ }
1923
+ outputHelp() {
1924
+ const { name, commands } = this.cli;
1925
+ const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
1926
+ let sections = [
1927
+ {
1928
+ body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
1929
+ }
1930
+ ];
1931
+ sections.push({
1932
+ title: "Usage",
1933
+ body: ` $ ${name} ${this.usageText || this.rawName}`
1934
+ });
1935
+ if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
1936
+ const longestCommandName = findLongest(commands.map((command)=>command.rawName));
1937
+ sections.push({
1938
+ title: "Commands",
1939
+ body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
1940
+ }, {
1941
+ title: "For more info, run any command with the `--help` flag",
1942
+ body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
1943
+ });
1944
+ }
1945
+ let options = this.isGlobalCommand ? globalOptions : [
1946
+ ...this.options,
1947
+ ...globalOptions || []
1948
+ ];
1949
+ if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option)=>"version" !== option.name);
1950
+ if (options.length > 0) {
1951
+ const longestOptionName = findLongest(options.map((option)=>option.rawName));
1952
+ sections.push({
1953
+ title: "Options",
1954
+ body: options.map((option)=>` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${void 0 === option.config.default ? "" : `(default: ${option.config.default})`}`).join("\n")
1955
+ });
1956
+ }
1957
+ if (this.examples.length > 0) sections.push({
1958
+ title: "Examples",
1959
+ body: this.examples.map((example)=>{
1960
+ if ("function" == typeof example) return example(name);
1961
+ return example;
1962
+ }).join("\n")
1963
+ });
1964
+ if (helpCallback) sections = helpCallback(sections) || sections;
1965
+ console.info(sections.map((section)=>section.title ? `${section.title}:\n${section.body}` : section.body).join("\n\n"));
1966
+ }
1967
+ outputVersion() {
1968
+ const { name } = this.cli;
1969
+ const { versionNumber } = this.cli.globalCommand;
1970
+ if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
1971
+ }
1972
+ checkRequiredArgs() {
1973
+ const minimalArgsCount = this.args.filter((arg)=>arg.required).length;
1974
+ if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
1975
+ }
1976
+ checkUnknownOptions() {
1977
+ const { options, globalCommand } = this.cli;
1978
+ if (!this.config.allowUnknownOptions) {
1979
+ for (const name of Object.keys(options))if ("--" !== name && !this.hasOption(name) && !globalCommand.hasOption(name)) throw new CACError(`Unknown option \`${name.length > 1 ? `--${name}` : `-${name}`}\``);
1980
+ }
1981
+ }
1982
+ checkOptionValue() {
1983
+ const { options: parsedOptions, globalCommand } = this.cli;
1984
+ const options = [
1985
+ ...globalCommand.options,
1986
+ ...this.options
1987
+ ];
1988
+ for (const option of options){
1989
+ const value = parsedOptions[option.name.split(".")[0]];
1990
+ if (option.required) {
1991
+ const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
1992
+ if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
1993
+ }
1994
+ }
1995
+ }
1996
+ checkUnusedArgs() {
1997
+ const maximumArgsCount = this.args.some((arg)=>arg.variadic) ? 1 / 0 : this.args.length;
1998
+ if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg)=>`\`${arg}\``).join(", ")}`);
1999
+ }
2000
+ };
2001
+ var GlobalCommand = class extends Command {
2002
+ constructor(cli){
2003
+ super("@@global@@", "", {}, cli);
2004
+ }
2005
+ };
2006
+ var CAC = class extends EventTarget {
2007
+ name;
2008
+ commands;
2009
+ globalCommand;
2010
+ matchedCommand;
2011
+ matchedCommandName;
2012
+ rawArgs;
2013
+ args;
2014
+ options;
2015
+ showHelpOnExit;
2016
+ showVersionOnExit;
2017
+ constructor(name = ""){
2018
+ super();
2019
+ this.name = name;
2020
+ this.commands = [];
2021
+ this.rawArgs = [];
2022
+ this.args = [];
2023
+ this.options = {};
2024
+ this.globalCommand = new GlobalCommand(this);
2025
+ this.globalCommand.usage("<command> [options]");
2026
+ }
2027
+ usage(text) {
2028
+ this.globalCommand.usage(text);
2029
+ return this;
2030
+ }
2031
+ command(rawName, description, config) {
2032
+ const command = new Command(rawName, description || "", config, this);
2033
+ command.globalCommand = this.globalCommand;
2034
+ this.commands.push(command);
2035
+ return command;
2036
+ }
2037
+ option(rawName, description, config) {
2038
+ this.globalCommand.option(rawName, description, config);
2039
+ return this;
2040
+ }
2041
+ help(callback) {
2042
+ this.globalCommand.option("-h, --help", "Display this message");
2043
+ this.globalCommand.helpCallback = callback;
2044
+ this.showHelpOnExit = true;
2045
+ return this;
2046
+ }
2047
+ version(version, customFlags = "-v, --version") {
2048
+ this.globalCommand.version(version, customFlags);
2049
+ this.showVersionOnExit = true;
2050
+ return this;
2051
+ }
2052
+ example(example) {
2053
+ this.globalCommand.example(example);
2054
+ return this;
2055
+ }
2056
+ outputHelp() {
2057
+ if (this.matchedCommand) this.matchedCommand.outputHelp();
2058
+ else this.globalCommand.outputHelp();
2059
+ }
2060
+ outputVersion() {
2061
+ this.globalCommand.outputVersion();
2062
+ }
2063
+ setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
2064
+ this.args = args;
2065
+ this.options = options;
2066
+ if (matchedCommand) this.matchedCommand = matchedCommand;
2067
+ if (matchedCommandName) this.matchedCommandName = matchedCommandName;
2068
+ return this;
2069
+ }
2070
+ unsetMatchedCommand() {
2071
+ this.matchedCommand = void 0;
2072
+ this.matchedCommandName = void 0;
2073
+ }
2074
+ parse(argv, { run = true } = {}) {
2075
+ if (!argv) {
2076
+ if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
2077
+ argv = runtimeProcessArgs;
2078
+ }
2079
+ this.rawArgs = argv;
2080
+ if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
2081
+ let shouldParse = true;
2082
+ for (const command of this.commands){
2083
+ const parsed = this.mri(argv.slice(2), command);
2084
+ const commandName = parsed.args[0];
2085
+ if (command.isMatched(commandName)) {
2086
+ shouldParse = false;
2087
+ const parsedInfo = {
2088
+ ...parsed,
2089
+ args: parsed.args.slice(1)
2090
+ };
2091
+ this.setParsedInfo(parsedInfo, command, commandName);
2092
+ this.dispatchEvent(new CustomEvent(`command:${commandName}`, {
2093
+ detail: command
2094
+ }));
2095
+ }
2096
+ }
2097
+ if (shouldParse) {
2098
+ for (const command of this.commands)if (command.isDefaultCommand) {
2099
+ shouldParse = false;
2100
+ const parsed = this.mri(argv.slice(2), command);
2101
+ this.setParsedInfo(parsed, command);
2102
+ this.dispatchEvent(new CustomEvent("command:!", {
2103
+ detail: command
2104
+ }));
2105
+ }
2106
+ }
2107
+ if (shouldParse) {
2108
+ const parsed = this.mri(argv.slice(2));
2109
+ this.setParsedInfo(parsed);
2110
+ }
2111
+ if (this.options.help && this.showHelpOnExit) {
2112
+ this.outputHelp();
2113
+ run = false;
2114
+ this.unsetMatchedCommand();
2115
+ }
2116
+ if (this.options.version && this.showVersionOnExit && null == this.matchedCommandName) {
2117
+ this.outputVersion();
2118
+ run = false;
2119
+ this.unsetMatchedCommand();
2120
+ }
2121
+ const parsedArgv = {
2122
+ args: this.args,
2123
+ options: this.options
2124
+ };
2125
+ if (run) this.runMatchedCommand();
2126
+ if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", {
2127
+ detail: this.args[0]
2128
+ }));
2129
+ return parsedArgv;
2130
+ }
2131
+ mri(argv, command) {
2132
+ const cliOptions = [
2133
+ ...this.globalCommand.options,
2134
+ ...command ? command.options : []
2135
+ ];
2136
+ const mriOptions = getMriOptions(cliOptions);
2137
+ let argsAfterDoubleDashes = [];
2138
+ const doubleDashesIndex = argv.indexOf("--");
2139
+ if (-1 !== doubleDashesIndex) {
2140
+ argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
2141
+ argv = argv.slice(0, doubleDashesIndex);
2142
+ }
2143
+ let parsed = lib_default(argv, mriOptions);
2144
+ parsed = Object.keys(parsed).reduce((res, name)=>({
2145
+ ...res,
2146
+ [camelcaseOptionName(name)]: parsed[name]
2147
+ }), {
2148
+ _: []
2149
+ });
2150
+ const args = parsed._;
2151
+ const options = {
2152
+ "--": argsAfterDoubleDashes
2153
+ };
2154
+ const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
2155
+ const transforms = Object.create(null);
2156
+ for (const cliOption of cliOptions){
2157
+ if (!ignoreDefault && void 0 !== cliOption.config.default) for (const name of cliOption.names)options[name] = cliOption.config.default;
2158
+ if (Array.isArray(cliOption.config.type) && void 0 === transforms[cliOption.name]) {
2159
+ transforms[cliOption.name] = Object.create(null);
2160
+ transforms[cliOption.name].shouldTransform = true;
2161
+ transforms[cliOption.name].transformFunction = cliOption.config.type[0];
2162
+ }
2163
+ }
2164
+ for (const key of Object.keys(parsed))if ("_" !== key) {
2165
+ setDotProp(options, key.split("."), parsed[key]);
2166
+ setByType(options, transforms);
2167
+ }
2168
+ return {
2169
+ args,
2170
+ options
2171
+ };
2172
+ }
2173
+ runMatchedCommand() {
2174
+ const { args, options, matchedCommand: command } = this;
2175
+ if (!command || !command.commandAction) return;
2176
+ command.checkUnknownOptions();
2177
+ command.checkOptionValue();
2178
+ command.checkRequiredArgs();
2179
+ command.checkUnusedArgs();
2180
+ const actionArgs = [];
2181
+ command.args.forEach((arg, index)=>{
2182
+ if (arg.variadic) actionArgs.push(args.slice(index));
2183
+ else actionArgs.push(args[index]);
2184
+ });
2185
+ actionArgs.push(options);
2186
+ return command.commandAction.apply(this, actionArgs);
2187
+ }
2188
+ };
2189
+ const cac = (name = "")=>new CAC(name);
2190
+ const PLUGIN_VIRTUAL_MODULE_NAME = 'rsbuild:virtual-module';
2191
+ const pluginVirtualModule = (pluginOptions = {})=>({
2192
+ name: PLUGIN_VIRTUAL_MODULE_NAME,
2193
+ async setup (api) {
2194
+ const { virtualModules = {}, tempDir: virtualFolderName = '.rsbuild-virtual-module' } = pluginOptions;
2195
+ const TEMP_DIR = join(api.context.rootPath, virtualFolderName);
2196
+ const virtualFileAbsolutePaths = Object.keys(virtualModules).map((i)=>{
2197
+ let absolutePath = join(TEMP_DIR, i);
2198
+ if (!extname(absolutePath)) absolutePath = `${absolutePath}.js`;
2199
+ return [
2200
+ i,
2201
+ absolutePath
2202
+ ];
2203
+ });
2204
+ api.modifyBundlerChain((chain, { rspack })=>{
2205
+ const pluginId = 'RSBUILD_VIRTUAL_MODULE_PLUGIN';
2206
+ const virtualModules = Object.fromEntries(virtualFileAbsolutePaths.map((i)=>[
2207
+ i[1],
2208
+ ''
2209
+ ]));
2210
+ if (chain.plugins.has(pluginId)) chain.plugin(pluginId).tap((options)=>{
2211
+ const existingPaths = new Set(Object.keys(options[0] ?? {}));
2212
+ const conflictPath = virtualFileAbsolutePaths.find(([, path])=>existingPaths.has(path));
2213
+ if (conflictPath) throw new Error(`Virtual module name conflicted: ${conflictPath[0]}`);
2214
+ return [
2215
+ {
2216
+ ...options[0],
2217
+ ...virtualModules
2218
+ }
2219
+ ];
2220
+ });
2221
+ else chain.plugin(pluginId).use(rspack.experiments.VirtualModulesPlugin, [
2222
+ virtualModules
2223
+ ]);
2224
+ chain.resolve.alias.merge(Object.fromEntries(virtualFileAbsolutePaths));
2225
+ });
2226
+ for (const [moduleName, absolutePath] of virtualFileAbsolutePaths){
2227
+ const handler = virtualModules[moduleName];
2228
+ if (handler) api.transform({
2229
+ test: absolutePath
2230
+ }, handler);
2231
+ }
2232
+ }
2233
+ });
2234
+ var __require = /* @__PURE__ */ external_module_createRequire(import.meta.url);
2235
+ function cleanPath(path) {
2236
+ let normalized = normalize(path);
2237
+ if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
2238
+ return normalized;
2239
+ }
2240
+ const SLASHES_REGEX = /[\\/]/g;
2241
+ function convertSlashes(path, separator) {
2242
+ return path.replace(SLASHES_REGEX, separator);
2243
+ }
2244
+ const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
2245
+ function isRootDirectory(path) {
2246
+ return "/" === path || WINDOWS_ROOT_DIR_REGEX.test(path);
2247
+ }
2248
+ function normalizePath(path, options) {
2249
+ const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
2250
+ const pathNeedsCleaning = "win32" === process.platform && path.includes("/") || path.startsWith(".");
2251
+ if (resolvePaths) path = resolve(path);
2252
+ if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
2253
+ if ("." === path) return "";
2254
+ const needsSeperator = path[path.length - 1] !== pathSeparator;
2255
+ return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
2256
+ }
2257
+ function joinPathWithBasePath(filename, directoryPath) {
2258
+ return directoryPath + filename;
2259
+ }
2260
+ function joinPathWithRelativePath(root, options) {
2261
+ return function(filename, directoryPath) {
2262
+ const sameRoot = directoryPath.startsWith(root);
2263
+ if (sameRoot) return directoryPath.slice(root.length) + filename;
2264
+ return convertSlashes(external_path_relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
2265
+ };
2266
+ }
2267
+ function joinPath(filename) {
2268
+ return filename;
2269
+ }
2270
+ function joinDirectoryPath(filename, directoryPath, separator) {
2271
+ return directoryPath + filename + separator;
2272
+ }
2273
+ function build$7(root, options) {
2274
+ const { relativePaths, includeBasePath } = options;
2275
+ return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
2276
+ }
2277
+ function pushDirectoryWithRelativePath(root) {
2278
+ return function(directoryPath, paths) {
2279
+ paths.push(directoryPath.substring(root.length) || ".");
2280
+ };
2281
+ }
2282
+ function pushDirectoryFilterWithRelativePath(root) {
2283
+ return function(directoryPath, paths, filters) {
2284
+ const relativePath = directoryPath.substring(root.length) || ".";
2285
+ if (filters.every((filter)=>filter(relativePath, true))) paths.push(relativePath);
2286
+ };
2287
+ }
2288
+ const pushDirectory = (directoryPath, paths)=>{
2289
+ paths.push(directoryPath || ".");
2290
+ };
2291
+ const pushDirectoryFilter = (directoryPath, paths, filters)=>{
2292
+ const path = directoryPath || ".";
2293
+ if (filters.every((filter)=>filter(path, true))) paths.push(path);
2294
+ };
2295
+ const empty$2 = ()=>{};
2296
+ function build$6(root, options) {
2297
+ const { includeDirs, filters, relativePaths } = options;
2298
+ if (!includeDirs) return empty$2;
2299
+ if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
2300
+ return filters && filters.length ? pushDirectoryFilter : pushDirectory;
2301
+ }
2302
+ const pushFileFilterAndCount = (filename, _paths, counts, filters)=>{
2303
+ if (filters.every((filter)=>filter(filename, false))) counts.files++;
2304
+ };
2305
+ const pushFileFilter = (filename, paths, _counts, filters)=>{
2306
+ if (filters.every((filter)=>filter(filename, false))) paths.push(filename);
2307
+ };
2308
+ const pushFileCount = (_filename, _paths, counts, _filters)=>{
2309
+ counts.files++;
2310
+ };
2311
+ const pushFile = (filename, paths)=>{
2312
+ paths.push(filename);
2313
+ };
2314
+ const empty$1 = ()=>{};
2315
+ function build$5(options) {
2316
+ const { excludeFiles, filters, onlyCounts } = options;
2317
+ if (excludeFiles) return empty$1;
2318
+ if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
2319
+ if (onlyCounts) return pushFileCount;
2320
+ return pushFile;
2321
+ }
2322
+ const getArray = (paths)=>paths;
2323
+ const getArrayGroup = ()=>[
2324
+ ""
2325
+ ].slice(0, 0);
2326
+ function build$4(options) {
2327
+ return options.group ? getArrayGroup : getArray;
2328
+ }
2329
+ const groupFiles = (groups, directory, files)=>{
2330
+ groups.push({
2331
+ directory,
2332
+ files,
2333
+ dir: directory
2334
+ });
2335
+ };
2336
+ const empty = ()=>{};
2337
+ function build$3(options) {
2338
+ return options.group ? groupFiles : empty;
2339
+ }
2340
+ const resolveSymlinksAsync = function(path, state, callback$1) {
2341
+ const { queue, fs, options: { suppressErrors } } = state;
2342
+ queue.enqueue();
2343
+ fs.realpath(path, (error, resolvedPath)=>{
2344
+ if (error) return queue.dequeue(suppressErrors ? null : error, state);
2345
+ fs.stat(resolvedPath, (error$1, stat)=>{
2346
+ if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
2347
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
2348
+ callback$1(stat, resolvedPath);
2349
+ queue.dequeue(null, state);
2350
+ });
2351
+ });
2352
+ };
2353
+ const resolveSymlinks = function(path, state, callback$1) {
2354
+ const { queue, fs, options: { suppressErrors } } = state;
2355
+ queue.enqueue();
2356
+ try {
2357
+ const resolvedPath = fs.realpathSync(path);
2358
+ const stat = fs.statSync(resolvedPath);
2359
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
2360
+ callback$1(stat, resolvedPath);
2361
+ } catch (e) {
2362
+ if (!suppressErrors) throw e;
2363
+ }
2364
+ };
2365
+ function build$2(options, isSynchronous) {
2366
+ if (!options.resolveSymlinks || options.excludeSymlinks) return null;
2367
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
2368
+ }
2369
+ function isRecursive(path, resolved, state) {
2370
+ if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
2371
+ let parent = dirname(path);
2372
+ let depth = 1;
2373
+ while(parent !== state.root && depth < 2){
2374
+ const resolvedPath = state.symlinks.get(parent);
2375
+ const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
2376
+ if (isSameRoot) depth++;
2377
+ else parent = dirname(parent);
2378
+ }
2379
+ state.symlinks.set(path, resolved);
2380
+ return depth > 1;
2381
+ }
2382
+ function isRecursiveUsingRealPaths(resolved, state) {
2383
+ return state.visited.includes(resolved + state.options.pathSeparator);
2384
+ }
2385
+ const onlyCountsSync = (state)=>state.counts;
2386
+ const groupsSync = (state)=>state.groups;
2387
+ const defaultSync = (state)=>state.paths;
2388
+ const limitFilesSync = (state)=>state.paths.slice(0, state.options.maxFiles);
2389
+ const onlyCountsAsync = (state, error, callback$1)=>{
2390
+ report(error, callback$1, state.counts, state.options.suppressErrors);
2391
+ return null;
2392
+ };
2393
+ const defaultAsync = (state, error, callback$1)=>{
2394
+ report(error, callback$1, state.paths, state.options.suppressErrors);
2395
+ return null;
2396
+ };
2397
+ const limitFilesAsync = (state, error, callback$1)=>{
2398
+ report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
2399
+ return null;
2400
+ };
2401
+ const groupsAsync = (state, error, callback$1)=>{
2402
+ report(error, callback$1, state.groups, state.options.suppressErrors);
2403
+ return null;
2404
+ };
2405
+ function report(error, callback$1, output, suppressErrors) {
2406
+ callback$1(error && !suppressErrors ? error : null, output);
2407
+ }
2408
+ function build$1(options, isSynchronous) {
2409
+ const { onlyCounts, group, maxFiles } = options;
2410
+ if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
2411
+ if (group) return isSynchronous ? groupsSync : groupsAsync;
2412
+ if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
2413
+ return isSynchronous ? defaultSync : defaultAsync;
2414
+ }
2415
+ const readdirOpts = {
2416
+ withFileTypes: true
2417
+ };
2418
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
2419
+ state.queue.enqueue();
2420
+ if (currentDepth < 0) return state.queue.dequeue(null, state);
2421
+ const { fs } = state;
2422
+ state.visited.push(crawlPath);
2423
+ state.counts.directories++;
2424
+ fs.readdir(crawlPath || ".", readdirOpts, (error, entries = [])=>{
2425
+ callback$1(entries, directoryPath, currentDepth);
2426
+ state.queue.dequeue(state.options.suppressErrors ? null : error, state);
2427
+ });
2428
+ };
2429
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1)=>{
2430
+ const { fs } = state;
2431
+ if (currentDepth < 0) return;
2432
+ state.visited.push(crawlPath);
2433
+ state.counts.directories++;
2434
+ let entries = [];
2435
+ try {
2436
+ entries = fs.readdirSync(crawlPath || ".", readdirOpts);
2437
+ } catch (e) {
2438
+ if (!state.options.suppressErrors) throw e;
2439
+ }
2440
+ callback$1(entries, directoryPath, currentDepth);
2441
+ };
2442
+ function build(isSynchronous) {
2443
+ return isSynchronous ? walkSync : walkAsync;
2444
+ }
2445
+ var Queue = class {
2446
+ count = 0;
2447
+ constructor(onQueueEmpty){
2448
+ this.onQueueEmpty = onQueueEmpty;
2449
+ }
2450
+ enqueue() {
2451
+ this.count++;
2452
+ return this.count;
2453
+ }
2454
+ dequeue(error, output) {
2455
+ if (this.onQueueEmpty && (--this.count <= 0 || error)) {
2456
+ this.onQueueEmpty(error, output);
2457
+ if (error) {
2458
+ output.controller.abort();
2459
+ this.onQueueEmpty = void 0;
2460
+ }
2461
+ }
2462
+ }
2463
+ };
2464
+ var Counter = class {
2465
+ _files = 0;
2466
+ _directories = 0;
2467
+ set files(num) {
2468
+ this._files = num;
2469
+ }
2470
+ get files() {
2471
+ return this._files;
2472
+ }
2473
+ set directories(num) {
2474
+ this._directories = num;
2475
+ }
2476
+ get directories() {
2477
+ return this._directories;
2478
+ }
2479
+ get dirs() {
2480
+ return this._directories;
2481
+ }
2482
+ };
2483
+ var Aborter = class {
2484
+ aborted = false;
2485
+ abort() {
2486
+ this.aborted = true;
2487
+ }
2488
+ };
2489
+ var Walker = class {
2490
+ root;
2491
+ isSynchronous;
2492
+ state;
2493
+ joinPath;
2494
+ pushDirectory;
2495
+ pushFile;
2496
+ getArray;
2497
+ groupFiles;
2498
+ resolveSymlink;
2499
+ walkDirectory;
2500
+ callbackInvoker;
2501
+ constructor(root, options, callback$1){
2502
+ this.isSynchronous = !callback$1;
2503
+ this.callbackInvoker = build$1(options, this.isSynchronous);
2504
+ this.root = normalizePath(root, options);
2505
+ this.state = {
2506
+ root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
2507
+ paths: [
2508
+ ""
2509
+ ].slice(0, 0),
2510
+ groups: [],
2511
+ counts: new Counter(),
2512
+ options,
2513
+ queue: new Queue((error, state)=>this.callbackInvoker(state, error, callback$1)),
2514
+ symlinks: /* @__PURE__ */ new Map(),
2515
+ visited: [
2516
+ ""
2517
+ ].slice(0, 0),
2518
+ controller: new Aborter(),
2519
+ fs: options.fs || __rspack_external_fs
2520
+ };
2521
+ this.joinPath = build$7(this.root, options);
2522
+ this.pushDirectory = build$6(this.root, options);
2523
+ this.pushFile = build$5(options);
2524
+ this.getArray = build$4(options);
2525
+ this.groupFiles = build$3(options);
2526
+ this.resolveSymlink = build$2(options, this.isSynchronous);
2527
+ this.walkDirectory = build(this.isSynchronous);
2528
+ }
2529
+ start() {
2530
+ this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
2531
+ this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
2532
+ return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
2533
+ }
2534
+ walk = (entries, directoryPath, depth)=>{
2535
+ const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
2536
+ if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
2537
+ const files = this.getArray(this.state.paths);
2538
+ for(let i = 0; i < entries.length; ++i){
2539
+ const entry = entries[i];
2540
+ if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
2541
+ const filename = this.joinPath(entry.name, directoryPath);
2542
+ this.pushFile(filename, files, this.state.counts, filters);
2543
+ } else if (entry.isDirectory()) {
2544
+ let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
2545
+ if (exclude && exclude(entry.name, path)) continue;
2546
+ this.pushDirectory(path, paths, filters);
2547
+ this.walkDirectory(this.state, path, path, depth - 1, this.walk);
2548
+ } else if (this.resolveSymlink && entry.isSymbolicLink()) {
2549
+ let path = joinPathWithBasePath(entry.name, directoryPath);
2550
+ this.resolveSymlink(path, this.state, (stat, resolvedPath)=>{
2551
+ if (stat.isDirectory()) {
2552
+ resolvedPath = normalizePath(resolvedPath, this.state.options);
2553
+ if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
2554
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
2555
+ } else {
2556
+ resolvedPath = useRealPaths ? resolvedPath : path;
2557
+ const filename = basename(resolvedPath);
2558
+ const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
2559
+ resolvedPath = this.joinPath(filename, directoryPath$1);
2560
+ this.pushFile(resolvedPath, files, this.state.counts, filters);
2561
+ }
2562
+ });
2563
+ }
2564
+ }
2565
+ this.groupFiles(this.state.groups, directoryPath, files);
2566
+ };
2567
+ };
2568
+ function promise(root, options) {
2569
+ return new Promise((resolve$1, reject)=>{
2570
+ dist_callback(root, options, (err, output)=>{
2571
+ if (err) return reject(err);
2572
+ resolve$1(output);
2573
+ });
2574
+ });
2575
+ }
2576
+ function dist_callback(root, options, callback$1) {
2577
+ let walker = new Walker(root, options, callback$1);
2578
+ walker.start();
2579
+ }
2580
+ function sync(root, options) {
2581
+ const walker = new Walker(root, options);
2582
+ return walker.start();
2583
+ }
2584
+ var APIBuilder = class {
2585
+ constructor(root, options){
2586
+ this.root = root;
2587
+ this.options = options;
2588
+ }
2589
+ withPromise() {
2590
+ return promise(this.root, this.options);
2591
+ }
2592
+ withCallback(cb) {
2593
+ dist_callback(this.root, this.options, cb);
2594
+ }
2595
+ sync() {
2596
+ return sync(this.root, this.options);
2597
+ }
2598
+ };
2599
+ let pm = null;
2600
+ try {
2601
+ __require.resolve("picomatch");
2602
+ pm = __require("picomatch");
2603
+ } catch {}
2604
+ var Builder = class {
2605
+ globCache = {};
2606
+ options = {
2607
+ maxDepth: 1 / 0,
2608
+ suppressErrors: true,
2609
+ pathSeparator: sep,
2610
+ filters: []
2611
+ };
2612
+ globFunction;
2613
+ constructor(options){
2614
+ this.options = {
2615
+ ...this.options,
2616
+ ...options
2617
+ };
2618
+ this.globFunction = this.options.globFunction;
2619
+ }
2620
+ group() {
2621
+ this.options.group = true;
2622
+ return this;
2623
+ }
2624
+ withPathSeparator(separator) {
2625
+ this.options.pathSeparator = separator;
2626
+ return this;
2627
+ }
2628
+ withBasePath() {
2629
+ this.options.includeBasePath = true;
2630
+ return this;
2631
+ }
2632
+ withRelativePaths() {
2633
+ this.options.relativePaths = true;
2634
+ return this;
2635
+ }
2636
+ withDirs() {
2637
+ this.options.includeDirs = true;
2638
+ return this;
2639
+ }
2640
+ withMaxDepth(depth) {
2641
+ this.options.maxDepth = depth;
2642
+ return this;
2643
+ }
2644
+ withMaxFiles(limit) {
2645
+ this.options.maxFiles = limit;
2646
+ return this;
2647
+ }
2648
+ withFullPaths() {
2649
+ this.options.resolvePaths = true;
2650
+ this.options.includeBasePath = true;
2651
+ return this;
2652
+ }
2653
+ withErrors() {
2654
+ this.options.suppressErrors = false;
2655
+ return this;
2656
+ }
2657
+ withSymlinks({ resolvePaths = true } = {}) {
2658
+ this.options.resolveSymlinks = true;
2659
+ this.options.useRealPaths = resolvePaths;
2660
+ return this.withFullPaths();
2661
+ }
2662
+ withAbortSignal(signal) {
2663
+ this.options.signal = signal;
2664
+ return this;
2665
+ }
2666
+ normalize() {
2667
+ this.options.normalizePath = true;
2668
+ return this;
2669
+ }
2670
+ filter(predicate) {
2671
+ this.options.filters.push(predicate);
2672
+ return this;
2673
+ }
2674
+ onlyDirs() {
2675
+ this.options.excludeFiles = true;
2676
+ this.options.includeDirs = true;
2677
+ return this;
2678
+ }
2679
+ exclude(predicate) {
2680
+ this.options.exclude = predicate;
2681
+ return this;
2682
+ }
2683
+ onlyCounts() {
2684
+ this.options.onlyCounts = true;
2685
+ return this;
2686
+ }
2687
+ crawl(root) {
2688
+ return new APIBuilder(root || ".", this.options);
2689
+ }
2690
+ withGlobFunction(fn) {
2691
+ this.globFunction = fn;
2692
+ return this;
2693
+ }
2694
+ crawlWithOptions(root, options) {
2695
+ this.options = {
2696
+ ...this.options,
2697
+ ...options
2698
+ };
2699
+ return new APIBuilder(root || ".", this.options);
2700
+ }
2701
+ glob(...patterns) {
2702
+ if (this.globFunction) return this.globWithOptions(patterns);
2703
+ return this.globWithOptions(patterns, {
2704
+ dot: true
2705
+ });
2706
+ }
2707
+ globWithOptions(patterns, ...options) {
2708
+ const globFn = this.globFunction || pm;
2709
+ if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
2710
+ var isMatch = this.globCache[patterns.join("\0")];
2711
+ if (!isMatch) {
2712
+ isMatch = globFn(patterns, ...options);
2713
+ this.globCache[patterns.join("\0")] = isMatch;
2714
+ }
2715
+ this.options.filters.push((path)=>isMatch(path));
2716
+ return this;
2717
+ }
2718
+ };
2719
+ const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
2720
+ const isReadonlyArray = Array.isArray;
2721
+ const BACKSLASHES = /\\/g;
2722
+ const DRIVE_RELATIVE_PATH = /^[A-Za-z]:$/;
2723
+ const isWin = "win32" === process.platform;
2724
+ const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
2725
+ function getPartialMatcher(patterns, options = {}) {
2726
+ const patternsCount = patterns.length;
2727
+ const patternsParts = Array(patternsCount);
2728
+ const matchers = Array(patternsCount);
2729
+ let i, j;
2730
+ for(i = 0; i < patternsCount; i++){
2731
+ const parts = splitPattern(patterns[i]);
2732
+ patternsParts[i] = parts;
2733
+ const partsCount = parts.length;
2734
+ const partMatchers = Array(partsCount);
2735
+ for(j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
2736
+ matchers[i] = partMatchers;
2737
+ }
2738
+ return (input)=>{
2739
+ const inputParts = input.split("/");
2740
+ if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
2741
+ for(i = 0; i < patternsCount; i++){
2742
+ const patternParts = patternsParts[i];
2743
+ const matcher = matchers[i];
2744
+ const inputPatternCount = inputParts.length;
2745
+ const minParts = Math.min(inputPatternCount, patternParts.length);
2746
+ j = 0;
2747
+ while(j < minParts){
2748
+ const part = patternParts[j];
2749
+ if (part.includes("/")) return true;
2750
+ if (!matcher[j](inputParts[j])) break;
2751
+ if (!options.noglobstar && "**" === part) return true;
2752
+ j++;
2753
+ }
2754
+ if (j === inputPatternCount) return true;
2755
+ }
2756
+ return false;
2757
+ };
2758
+ }
2759
+ const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
2760
+ const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
2761
+ function buildFormat(cwd, root, absolute) {
2762
+ if (cwd === root || root.startsWith(`${cwd}/`)) {
2763
+ if (absolute) {
2764
+ const start = cwd.length + +!isRoot(cwd);
2765
+ return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
2766
+ }
2767
+ const prefix = root.slice(cwd.length + 1);
2768
+ if (prefix) return (p, isDir)=>{
2769
+ if ("." === p) return prefix;
2770
+ const result = `${prefix}/${p}`;
2771
+ return isDir ? result.slice(0, -1) : result;
2772
+ };
2773
+ return (p, isDir)=>isDir && "." !== p ? p.slice(0, -1) : p;
2774
+ }
2775
+ if (absolute) return (p)=>posix.relative(cwd, p) || ".";
2776
+ return (p)=>posix.relative(cwd, `${root}/${p}`) || ".";
2777
+ }
2778
+ function buildRelative(cwd, root) {
2779
+ if (root.startsWith(`${cwd}/`)) {
2780
+ const prefix = root.slice(cwd.length + 1);
2781
+ return (p)=>`${prefix}/${p}`;
2782
+ }
2783
+ return (p)=>{
2784
+ const result = posix.relative(cwd, `${root}/${p}`);
2785
+ return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
2786
+ };
2787
+ }
2788
+ function ensureNonDriveRelativePath(path) {
2789
+ return path.replace(DRIVE_RELATIVE_PATH, (match)=>`${match}/`);
2790
+ }
2791
+ const splitPatternOptions = {
2792
+ parts: true
2793
+ };
2794
+ function splitPattern(path) {
2795
+ var _result$parts;
2796
+ const result = picomatch.scan(path, splitPatternOptions);
2797
+ return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
2798
+ path
2799
+ ];
2800
+ }
2801
+ const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
2802
+ const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
2803
+ const escapePosixPath = (path)=>path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2804
+ const escapeWin32Path = (path)=>path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
2805
+ const escapePath = isWin ? escapeWin32Path : escapePosixPath;
2806
+ function isDynamicPattern(pattern, options) {
2807
+ if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
2808
+ const scan = picomatch.scan(pattern);
2809
+ return scan.isGlob || scan.negated;
2810
+ }
2811
+ function log(...tasks) {
2812
+ console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
2813
+ }
2814
+ function ensureStringArray(value) {
2815
+ return "string" == typeof value ? [
2816
+ value
2817
+ ] : null != value ? value : [];
2818
+ }
2819
+ const PARENT_DIRECTORY = /^(\/?\.\.)+/;
2820
+ const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
2821
+ function normalizePattern(pattern, opts, props, isIgnore) {
2822
+ var _PARENT_DIRECTORY$exe;
2823
+ const cwd = opts.cwd;
2824
+ let result = pattern;
2825
+ if ("/" === pattern[pattern.length - 1]) result = pattern.slice(0, -1);
2826
+ if ("*" !== result[result.length - 1] && opts.expandDirectories) result += "/**";
2827
+ const escapedCwd = escapePath(cwd);
2828
+ result = isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
2829
+ const parentDir = null == (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) ? void 0 : _PARENT_DIRECTORY$exe[0];
2830
+ const parts = splitPattern(result);
2831
+ if (parentDir) {
2832
+ const n = (parentDir.length + 1) / 3;
2833
+ let i = 0;
2834
+ const cwdParts = escapedCwd.split("/");
2835
+ while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
2836
+ result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
2837
+ i++;
2838
+ }
2839
+ const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
2840
+ if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
2841
+ props.root = ensureNonDriveRelativePath(potentialRoot);
2842
+ props.depthOffset = -n + i;
2843
+ }
2844
+ }
2845
+ if (!isIgnore && props.depthOffset >= 0) {
2846
+ null != props.commonPath || (props.commonPath = parts);
2847
+ const newCommonPath = [];
2848
+ const length = Math.min(props.commonPath.length, parts.length);
2849
+ for(let i = 0; i < length; i++){
2850
+ const part = parts[i];
2851
+ if ("**" === part && !parts[i + 1]) {
2852
+ newCommonPath.pop();
2853
+ break;
2854
+ }
2855
+ if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
2856
+ newCommonPath.push(part);
2857
+ }
2858
+ props.depthOffset = newCommonPath.length;
2859
+ props.commonPath = newCommonPath;
2860
+ props.root = ensureNonDriveRelativePath(newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd);
2861
+ }
2862
+ return result;
2863
+ }
2864
+ function processPatterns(options, patterns, props) {
2865
+ const matchPatterns = [];
2866
+ const ignorePatterns = [];
2867
+ for (const pattern of options.ignore)if (pattern) {
2868
+ if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, options, props, true));
2869
+ }
2870
+ for (const pattern of patterns)if (pattern) {
2871
+ if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, options, props, false));
2872
+ else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
2873
+ }
2874
+ return {
2875
+ match: matchPatterns,
2876
+ ignore: ignorePatterns
2877
+ };
2878
+ }
2879
+ function buildCrawler(options, patterns) {
2880
+ const cwd = options.cwd;
2881
+ const props = {
2882
+ root: cwd,
2883
+ depthOffset: 0
2884
+ };
2885
+ const processed = processPatterns(options, patterns, props);
2886
+ if (options.debug) log("internal processing patterns:", processed);
2887
+ const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
2888
+ const root = props.root.replace(BACKSLASHES, "");
2889
+ const matchOptions = {
2890
+ dot,
2891
+ nobrace: false === options.braceExpansion,
2892
+ nocase: !caseSensitiveMatch,
2893
+ noextglob: false === options.extglob,
2894
+ noglobstar: false === options.globstar,
2895
+ posix: true
2896
+ };
2897
+ const matcher = picomatch(processed.match, matchOptions);
2898
+ const ignore = picomatch(processed.ignore, matchOptions);
2899
+ const partialMatcher = getPartialMatcher(processed.match, matchOptions);
2900
+ const format = buildFormat(cwd, root, absolute);
2901
+ const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
2902
+ const excludePredicate = (_, p)=>{
2903
+ const relativePath = excludeFormatter(p, true);
2904
+ return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
2905
+ };
2906
+ let maxDepth;
2907
+ if (void 0 !== options.deep) maxDepth = Math.round(options.deep - props.depthOffset);
2908
+ const crawler = new Builder({
2909
+ filters: [
2910
+ debug ? (p, isDirectory)=>{
2911
+ const path = format(p, isDirectory);
2912
+ const matches = matcher(path) && !ignore(path);
2913
+ if (matches) log(`matched ${path}`);
2914
+ return matches;
2915
+ } : (p, isDirectory)=>{
2916
+ const path = format(p, isDirectory);
2917
+ return matcher(path) && !ignore(path);
2918
+ }
2919
+ ],
2920
+ exclude: debug ? (_, p)=>{
2921
+ const skipped = excludePredicate(_, p);
2922
+ log(`${skipped ? "skipped" : "crawling"} ${p}`);
2923
+ return skipped;
2924
+ } : excludePredicate,
2925
+ fs: options.fs,
2926
+ pathSeparator: "/",
2927
+ relativePaths: !absolute,
2928
+ resolvePaths: absolute,
2929
+ includeBasePath: absolute,
2930
+ resolveSymlinks: followSymbolicLinks,
2931
+ excludeSymlinks: !followSymbolicLinks,
2932
+ excludeFiles: onlyDirectories,
2933
+ includeDirs: onlyDirectories || !options.onlyFiles,
2934
+ maxDepth,
2935
+ signal: options.signal
2936
+ }).crawl(root);
2937
+ if (options.debug) log("internal properties:", {
2938
+ ...props,
2939
+ root
2940
+ });
2941
+ return [
2942
+ crawler,
2943
+ cwd !== root && !absolute && buildRelative(cwd, root)
2944
+ ];
2945
+ }
2946
+ function formatPaths(paths, mapper) {
2947
+ if (mapper) for(let i = paths.length - 1; i >= 0; i--)paths[i] = mapper(paths[i]);
2948
+ return paths;
2949
+ }
2950
+ const defaultOptions = {
2951
+ caseSensitiveMatch: true,
2952
+ debug: !!process.env.TINYGLOBBY_DEBUG,
2953
+ expandDirectories: true,
2954
+ followSymbolicLinks: true,
2955
+ onlyFiles: true
2956
+ };
2957
+ function getOptions(options) {
2958
+ const opts = Object.assign({}, options);
2959
+ for(const key in defaultOptions)if (void 0 === opts[key]) Object.assign(opts, {
2960
+ [key]: defaultOptions[key]
2961
+ });
2962
+ opts.cwd = (opts.cwd instanceof URL ? external_url_fileURLToPath(opts.cwd) : resolve(opts.cwd || process.cwd())).replace(BACKSLASHES, "/");
2963
+ opts.ignore = ensureStringArray(opts.ignore);
2964
+ opts.fs && (opts.fs = {
2965
+ readdir: opts.fs.readdir || readdir,
2966
+ readdirSync: opts.fs.readdirSync || readdirSync,
2967
+ realpath: opts.fs.realpath || realpath,
2968
+ realpathSync: opts.fs.realpathSync || realpathSync,
2969
+ stat: opts.fs.stat || external_fs_stat,
2970
+ statSync: opts.fs.statSync || statSync
2971
+ });
2972
+ if (opts.debug) log("globbing with options:", opts);
2973
+ return opts;
2974
+ }
2975
+ function getCrawler(globInput, inputOptions = {}) {
2976
+ var _ref;
2977
+ if (globInput && (null == inputOptions ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
2978
+ const isModern = isReadonlyArray(globInput) || "string" == typeof globInput;
2979
+ const patterns = ensureStringArray(null != (_ref = isModern ? globInput : globInput.patterns) ? _ref : "**/*");
2980
+ const options = getOptions(isModern ? inputOptions : globInput);
2981
+ return patterns.length > 0 ? buildCrawler(options, patterns) : [];
2982
+ }
2983
+ async function glob(globInput, options) {
2984
+ const [crawler, relative] = getCrawler(globInput, options);
2985
+ return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
2986
+ }
2987
+ export { logger } from "@rspress/shared/logger";
2988
+ export { default as node_fs } from "node:fs";
2989
+ export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME, DEFAULT_PAGE_EXTENSIONS } from "@rspress/shared/constants";
2990
+ export { default as promises, mkdir, readdir as promises_readdir, rm, stat as promises_stat, writeFile } from "node:fs/promises";
2991
+ export { createRequire } from "node:module";
2992
+ export { cwd as external_node_process_cwd } from "node:process";
2993
+ export { fileURLToPath, pathToFileURL } from "node:url";
2994
+ export { PLUGIN_REACT_NAME, pluginReact } from "@rsbuild/plugin-react";
2995
+ export { MDX_OR_MD_REGEXP, RSPRESS_TEMP_DIR, SEARCH_INDEX_NAME, addLeadingSlash, addTrailingSlash, getSidebarDataGroup, isDebugMode, isExternalUrl, isProduction, normalizeDarkMode, normalizeHref, normalizePosixPath, removeLeadingSlash, removeTrailingSlash, slash, withBase, withSiteOrigin } from "@rspress/shared";
2996
+ export { createHash } from "node:crypto";
2997
+ export { chunk, groupBy } from "@rspress/shared/lodash-es";
2998
+ export { extractTextAndId, getIconUrlPath, loadFrontMatter } from "@rspress/shared/node-utils";
2999
+ export { default as remark_gfm } from "remark-gfm";
3000
+ export { default as remark_parse } from "remark-parse";
3001
+ export { unified } from "unified";
3002
+ export { createProcessor } from "@mdx-js/mdx";
3003
+ export { mergeRsbuildConfig, rspack as core_rspack } from "@rsbuild/core";
3004
+ export { default as node_os } from "node:os";
3005
+ export { matchPath } from "react-router-dom";
3006
+ export { createHead } from "@unhead/react/server";
3007
+ export { cac, external_node_path_relative, extname, glob, join, node_path, pluginVirtualModule };