@rspress/core 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/0~execa.js +8 -8
- package/dist/0~rslib-runtime.js +20 -0
- package/dist/0~tinypool.js +828 -0
- package/dist/{8311.js → 1688.js} +1 -7
- package/dist/{7397.js → 2240.js} +4 -2
- package/dist/2287.js +2458 -0
- package/dist/{1361.js → 3294.js} +1 -1
- package/dist/{1965.js → 3425.js} +0 -1
- package/dist/8006.js +77 -0
- package/dist/8857.js +4826 -0
- package/dist/8857.js.LICENSE.txt +41 -0
- package/dist/cli/index.js +14 -7
- package/dist/config/loadConfigFile.js +1 -1
- package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.scss +1 -1
- package/dist/eject-theme/components/CodeButtonGroup/CopyCodeButton.tsx +17 -21
- package/dist/eject-theme/components/CodeButtonGroup/index.scss +1 -1
- package/dist/eject-theme/components/DocContent/doc.scss +16 -41
- package/dist/eject-theme/components/FallbackHeading/index.tsx +1 -1
- package/dist/eject-theme/components/Link/useLinkNavigate.ts +4 -1
- package/dist/eject-theme/components/Llms/LlmsCopyButton.scss +3 -3
- package/dist/eject-theme/components/Llms/LlmsCopyButton.tsx +13 -6
- package/dist/eject-theme/components/Llms/LlmsCopyRow.tsx +13 -5
- package/dist/eject-theme/components/Llms/LlmsViewOptions.tsx +7 -3
- package/dist/eject-theme/components/Outline/index.scss +1 -1
- package/dist/eject-theme/components/Prompt/icons.tsx +80 -0
- package/dist/eject-theme/components/Prompt/index.scss +478 -0
- package/dist/eject-theme/components/Prompt/index.tsx +335 -0
- package/dist/eject-theme/components/Search/SearchPanel.tsx +1 -1
- package/dist/eject-theme/components/SidebarMenu/index.tsx +5 -1
- package/dist/eject-theme/components/Steps/index.scss +32 -13
- package/dist/node/PluginDriver.js +1 -1
- package/dist/node/auto-nav-sidebar/index.js +1 -1
- package/dist/node/auto-nav-sidebar/locales.js +1 -1
- package/dist/node/auto-nav-sidebar/normalize.js +10 -6
- package/dist/node/auto-nav-sidebar/utils.js +8 -2
- package/dist/node/auto-nav-sidebar/walk.js +2 -8
- package/dist/node/constants.js +1 -1
- package/dist/node/eject.js +12 -7
- package/dist/node/initRsbuild.js +6 -6
- package/dist/node/logger/hint.js +9 -6
- package/dist/node/mdx/options.js +13 -2
- package/dist/node/mdx/processor.js +1 -1
- package/dist/node/mdx/rehypePlugins/codeMeta.js +1 -1
- package/dist/node/mdx/rehypePlugins/headerAnchor.js +1 -1
- package/dist/node/mdx/rehypePlugins/shiki.js +1 -1
- package/dist/node/mdx/remarkPlugins/builtin.js +1 -1
- package/dist/node/mdx/remarkPlugins/fileCodeBlock.js +6 -2
- package/dist/node/mdx/remarkPlugins/image.d.ts +7 -2
- package/dist/node/mdx/remarkPlugins/image.js +51 -2
- package/dist/node/mdx/remarkPlugins/link.js +7 -3
- package/dist/node/mdx/remarkPlugins/toc.js +1 -1
- package/dist/node/route/RoutePage.js +1 -1
- package/dist/node/route/RouteService.js +1 -1
- package/dist/node/route/extractPageData.js +75 -26
- package/dist/node/route/normalizeRoutePath.js +1 -1
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.d.ts +28 -0
- package/dist/node/runtimeModule/DEFAULT_I18N_TEXT.js +28 -0
- package/dist/node/runtimeModule/i18n.js +10 -6
- package/dist/node/runtimeModule/pageData/createPageData.js +1 -1
- package/dist/node/runtimeModule/pageData/rsbuildPlugin.js +1 -1
- package/dist/node/runtimeModule/searchHooks.js +1 -1
- package/dist/node/runtimeModule/siteData/createSiteData.js +1 -1
- package/dist/node/runtimeModule/siteData/normalizeThemeConfig.js +1 -1
- package/dist/node/runtimeModule/siteData/rsbuildPlugin.js +1 -1
- package/dist/node/serve.js +1 -1
- package/dist/node/ssg/renderPage.js +8 -4
- package/dist/node/ssg/renderPageWorker.js +1 -1
- package/dist/node/ssg/renderPages.js +9 -5
- package/dist/node/ssg/rsbuildPluginSSG.js +1 -1
- package/dist/node/ssg/ssgEnv.js +1 -1
- package/dist/node/ssg-md/llms/emitLlmsTxt.js +1 -1
- package/dist/node/ssg-md/llms/llmsTxt.js +1 -1
- package/dist/node/ssg-md/remarkSplitMdx.js +1 -1
- package/dist/node/ssg-md/renderPage.js +8 -4
- package/dist/node/ssg-md/renderPages.js +7 -3
- package/dist/node/ssg-md/rsbuildPluginSSGMD.js +1 -1
- package/dist/node/utils/checkLanguageParity.js +1 -1
- package/dist/node/utils/createHash.js +1 -1
- package/dist/node/utils/error.js +5 -2
- package/dist/node/utils/flattenMdxContent.js +1 -1
- package/dist/node/utils/fs.js +1 -1
- package/dist/node/utils/getPageKey.js +1 -1
- package/dist/node/utils/normalizePath.js +1 -1
- package/dist/node/utils/reactAlias.js +7 -3
- package/dist/runtime/App.js +4 -1
- package/dist/runtime/index.d.ts +2 -1
- package/dist/runtime/index.js +2 -1
- package/dist/runtime/initPageData.d.ts +3 -0
- package/dist/runtime/initPageData.js +37 -2
- package/dist/runtime/ssrClientEntry.js +4 -2
- package/dist/theme/assets/success.js +1 -1
- package/dist/theme/assets/wrapped.js +1 -1
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.css +1 -1
- package/dist/theme/components/CodeButtonGroup/CopyCodeButton.js +14 -12
- package/dist/theme/components/CodeButtonGroup/index.css +1 -1
- package/dist/theme/components/DocContent/doc.css +14 -21
- package/dist/theme/components/FallbackHeading/index.js +1 -1
- package/dist/theme/components/Link/useLinkNavigate.js +3 -2
- package/dist/theme/components/Llms/LlmsCopyButton.css +5 -5
- package/dist/theme/components/Llms/LlmsCopyButton.js +5 -6
- package/dist/theme/components/Llms/LlmsCopyRow.js +5 -5
- package/dist/theme/components/Llms/LlmsViewOptions.js +1 -3
- package/dist/theme/components/Outline/index.css +1 -1
- package/dist/theme/components/Prompt/icons.d.ts +10 -0
- package/dist/theme/components/Prompt/icons.js +64 -0
- package/dist/theme/components/Prompt/index.css +352 -0
- package/dist/theme/components/Prompt/index.d.ts +33 -0
- package/dist/theme/components/Prompt/index.js +262 -0
- package/dist/theme/components/Search/SearchPanel.js +1 -1
- package/dist/theme/components/SidebarMenu/index.js +2 -1
- package/dist/theme/components/Steps/index.css +23 -12
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +3 -0
- package/dist/theme/layout/DocLayout/index.css +5 -1
- package/dist/theme/layout/DocLayout/index.js +8 -4
- package/dist/theme/logic/copyToClipboard.d.ts +1 -0
- package/dist/theme/{components/Llms/copy.js → logic/copyToClipboard.js} +4 -3
- package/dist/theme/logic/getCopyableText.d.ts +5 -0
- package/dist/theme/logic/getCopyableText.js +52 -0
- package/dist/theme/logic/useThemeState.js +1 -1
- package/dist/theme/styles/vars/base-vars.css +4 -4
- package/package.json +20 -23
- package/dist/4454.js +0 -8
- package/dist/7319.js +0 -88
- package/dist/8885.js +0 -4
- package/dist/eject-theme/components/Llms/copy.ts +0 -12
- package/dist/theme/components/Llms/copy.d.ts +0 -1
package/dist/8857.js
ADDED
|
@@ -0,0 +1,4826 @@
|
|
|
1
|
+
/*! LICENSE: 8857.js.LICENSE.txt */
|
|
2
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
|
+
import "./2287.js";
|
|
4
|
+
import { createRequire as __rspack_createRequire } from "node:module";
|
|
5
|
+
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
6
|
+
__webpack_require__.add({
|
|
7
|
+
"../../node_modules/.pnpm/anymatch@3.1.3/node_modules/anymatch/index.js" (module, exports, __webpack_require__) {
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js");
|
|
12
|
+
const normalizePath = __webpack_require__("../../node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js");
|
|
13
|
+
const BANG = '!';
|
|
14
|
+
const DEFAULT_OPTIONS = {
|
|
15
|
+
returnIndex: false
|
|
16
|
+
};
|
|
17
|
+
const arrify = (item)=>Array.isArray(item) ? item : [
|
|
18
|
+
item
|
|
19
|
+
];
|
|
20
|
+
const createPattern = (matcher, options)=>{
|
|
21
|
+
if ('function' == typeof matcher) return matcher;
|
|
22
|
+
if ('string' == typeof matcher) {
|
|
23
|
+
const glob = picomatch(matcher, options);
|
|
24
|
+
return (string)=>matcher === string || glob(string);
|
|
25
|
+
}
|
|
26
|
+
if (matcher instanceof RegExp) return (string)=>matcher.test(string);
|
|
27
|
+
return (string)=>false;
|
|
28
|
+
};
|
|
29
|
+
const matchPatterns = (patterns, negPatterns, args, returnIndex)=>{
|
|
30
|
+
const isList = Array.isArray(args);
|
|
31
|
+
const _path = isList ? args[0] : args;
|
|
32
|
+
if (!isList && 'string' != typeof _path) throw new TypeError('anymatch: second argument must be a string: got ' + Object.prototype.toString.call(_path));
|
|
33
|
+
const path = normalizePath(_path, false);
|
|
34
|
+
for(let index = 0; index < negPatterns.length; index++){
|
|
35
|
+
const nglob = negPatterns[index];
|
|
36
|
+
if (nglob(path)) return returnIndex ? -1 : false;
|
|
37
|
+
}
|
|
38
|
+
const applied = isList && [
|
|
39
|
+
path
|
|
40
|
+
].concat(args.slice(1));
|
|
41
|
+
for(let index = 0; index < patterns.length; index++){
|
|
42
|
+
const pattern = patterns[index];
|
|
43
|
+
if (isList ? pattern(...applied) : pattern(path)) return returnIndex ? index : true;
|
|
44
|
+
}
|
|
45
|
+
return returnIndex ? -1 : false;
|
|
46
|
+
};
|
|
47
|
+
const anymatch = (matchers, testString, options = DEFAULT_OPTIONS)=>{
|
|
48
|
+
if (null == matchers) throw new TypeError('anymatch: specify first argument');
|
|
49
|
+
const opts = 'boolean' == typeof options ? {
|
|
50
|
+
returnIndex: options
|
|
51
|
+
} : options;
|
|
52
|
+
const returnIndex = opts.returnIndex || false;
|
|
53
|
+
const mtchers = arrify(matchers);
|
|
54
|
+
const negatedGlobs = mtchers.filter((item)=>'string' == typeof item && item.charAt(0) === BANG).map((item)=>item.slice(1)).map((item)=>picomatch(item, opts));
|
|
55
|
+
const patterns = mtchers.filter((item)=>'string' != typeof item || 'string' == typeof item && item.charAt(0) !== BANG).map((matcher)=>createPattern(matcher, opts));
|
|
56
|
+
if (null == testString) return (testString, ri = false)=>{
|
|
57
|
+
const returnIndex = 'boolean' == typeof ri ? ri : false;
|
|
58
|
+
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
|
59
|
+
};
|
|
60
|
+
return matchPatterns(patterns, negatedGlobs, testString, returnIndex);
|
|
61
|
+
};
|
|
62
|
+
anymatch.default = anymatch;
|
|
63
|
+
module.exports = anymatch;
|
|
64
|
+
},
|
|
65
|
+
"../../node_modules/.pnpm/binary-extensions@2.3.0/node_modules/binary-extensions/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
66
|
+
module.exports = __webpack_require__("../../node_modules/.pnpm/binary-extensions@2.3.0/node_modules/binary-extensions/binary-extensions.json");
|
|
67
|
+
},
|
|
68
|
+
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
69
|
+
const stringify = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
|
|
70
|
+
const compile = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/compile.js");
|
|
71
|
+
const expand = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/expand.js");
|
|
72
|
+
const parse = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/parse.js");
|
|
73
|
+
const braces = (input, options = {})=>{
|
|
74
|
+
let output = [];
|
|
75
|
+
if (Array.isArray(input)) for (const pattern of input){
|
|
76
|
+
const result = braces.create(pattern, options);
|
|
77
|
+
if (Array.isArray(result)) output.push(...result);
|
|
78
|
+
else output.push(result);
|
|
79
|
+
}
|
|
80
|
+
else output = [].concat(braces.create(input, options));
|
|
81
|
+
if (options && true === options.expand && true === options.nodupes) output = [
|
|
82
|
+
...new Set(output)
|
|
83
|
+
];
|
|
84
|
+
return output;
|
|
85
|
+
};
|
|
86
|
+
braces.parse = (input, options = {})=>parse(input, options);
|
|
87
|
+
braces.stringify = (input, options = {})=>{
|
|
88
|
+
if ('string' == typeof input) return stringify(braces.parse(input, options), options);
|
|
89
|
+
return stringify(input, options);
|
|
90
|
+
};
|
|
91
|
+
braces.compile = (input, options = {})=>{
|
|
92
|
+
if ('string' == typeof input) input = braces.parse(input, options);
|
|
93
|
+
return compile(input, options);
|
|
94
|
+
};
|
|
95
|
+
braces.expand = (input, options = {})=>{
|
|
96
|
+
if ('string' == typeof input) input = braces.parse(input, options);
|
|
97
|
+
let result = expand(input, options);
|
|
98
|
+
if (true === options.noempty) result = result.filter(Boolean);
|
|
99
|
+
if (true === options.nodupes) result = [
|
|
100
|
+
...new Set(result)
|
|
101
|
+
];
|
|
102
|
+
return result;
|
|
103
|
+
};
|
|
104
|
+
braces.create = (input, options = {})=>{
|
|
105
|
+
if ('' === input || input.length < 3) return [
|
|
106
|
+
input
|
|
107
|
+
];
|
|
108
|
+
return true !== options.expand ? braces.compile(input, options) : braces.expand(input, options);
|
|
109
|
+
};
|
|
110
|
+
module.exports = braces;
|
|
111
|
+
},
|
|
112
|
+
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/compile.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
113
|
+
const fill = __webpack_require__("../../node_modules/.pnpm/fill-range@7.1.1/node_modules/fill-range/index.js");
|
|
114
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js");
|
|
115
|
+
const compile = (ast, options = {})=>{
|
|
116
|
+
const walk = (node, parent = {})=>{
|
|
117
|
+
const invalidBlock = utils.isInvalidBrace(parent);
|
|
118
|
+
const invalidNode = true === node.invalid && true === options.escapeInvalid;
|
|
119
|
+
const invalid = true === invalidBlock || true === invalidNode;
|
|
120
|
+
const prefix = true === options.escapeInvalid ? '\\' : '';
|
|
121
|
+
let output = '';
|
|
122
|
+
if (true === node.isOpen) return prefix + node.value;
|
|
123
|
+
if (true === node.isClose) {
|
|
124
|
+
console.log('node.isClose', prefix, node.value);
|
|
125
|
+
return prefix + node.value;
|
|
126
|
+
}
|
|
127
|
+
if ('open' === node.type) return invalid ? prefix + node.value : '(';
|
|
128
|
+
if ('close' === node.type) return invalid ? prefix + node.value : ')';
|
|
129
|
+
if ('comma' === node.type) return 'comma' === node.prev.type ? '' : invalid ? node.value : '|';
|
|
130
|
+
if (node.value) return node.value;
|
|
131
|
+
if (node.nodes && node.ranges > 0) {
|
|
132
|
+
const args = utils.reduce(node.nodes);
|
|
133
|
+
const range = fill(...args, {
|
|
134
|
+
...options,
|
|
135
|
+
wrap: false,
|
|
136
|
+
toRegex: true,
|
|
137
|
+
strictZeros: true
|
|
138
|
+
});
|
|
139
|
+
if (0 !== range.length) return args.length > 1 && range.length > 1 ? `(${range})` : range;
|
|
140
|
+
}
|
|
141
|
+
if (node.nodes) for (const child of node.nodes)output += walk(child, node);
|
|
142
|
+
return output;
|
|
143
|
+
};
|
|
144
|
+
return walk(ast);
|
|
145
|
+
};
|
|
146
|
+
module.exports = compile;
|
|
147
|
+
},
|
|
148
|
+
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/constants.js" (module) {
|
|
149
|
+
module.exports = {
|
|
150
|
+
MAX_LENGTH: 10000,
|
|
151
|
+
CHAR_0: '0',
|
|
152
|
+
CHAR_9: '9',
|
|
153
|
+
CHAR_UPPERCASE_A: 'A',
|
|
154
|
+
CHAR_LOWERCASE_A: 'a',
|
|
155
|
+
CHAR_UPPERCASE_Z: 'Z',
|
|
156
|
+
CHAR_LOWERCASE_Z: 'z',
|
|
157
|
+
CHAR_LEFT_PARENTHESES: '(',
|
|
158
|
+
CHAR_RIGHT_PARENTHESES: ')',
|
|
159
|
+
CHAR_ASTERISK: '*',
|
|
160
|
+
CHAR_AMPERSAND: '&',
|
|
161
|
+
CHAR_AT: '@',
|
|
162
|
+
CHAR_BACKSLASH: '\\',
|
|
163
|
+
CHAR_BACKTICK: '`',
|
|
164
|
+
CHAR_CARRIAGE_RETURN: '\r',
|
|
165
|
+
CHAR_CIRCUMFLEX_ACCENT: '^',
|
|
166
|
+
CHAR_COLON: ':',
|
|
167
|
+
CHAR_COMMA: ',',
|
|
168
|
+
CHAR_DOLLAR: '$',
|
|
169
|
+
CHAR_DOT: '.',
|
|
170
|
+
CHAR_DOUBLE_QUOTE: '"',
|
|
171
|
+
CHAR_EQUAL: '=',
|
|
172
|
+
CHAR_EXCLAMATION_MARK: '!',
|
|
173
|
+
CHAR_FORM_FEED: '\f',
|
|
174
|
+
CHAR_FORWARD_SLASH: '/',
|
|
175
|
+
CHAR_HASH: '#',
|
|
176
|
+
CHAR_HYPHEN_MINUS: '-',
|
|
177
|
+
CHAR_LEFT_ANGLE_BRACKET: '<',
|
|
178
|
+
CHAR_LEFT_CURLY_BRACE: '{',
|
|
179
|
+
CHAR_LEFT_SQUARE_BRACKET: '[',
|
|
180
|
+
CHAR_LINE_FEED: '\n',
|
|
181
|
+
CHAR_NO_BREAK_SPACE: '\u00A0',
|
|
182
|
+
CHAR_PERCENT: '%',
|
|
183
|
+
CHAR_PLUS: '+',
|
|
184
|
+
CHAR_QUESTION_MARK: '?',
|
|
185
|
+
CHAR_RIGHT_ANGLE_BRACKET: '>',
|
|
186
|
+
CHAR_RIGHT_CURLY_BRACE: '}',
|
|
187
|
+
CHAR_RIGHT_SQUARE_BRACKET: ']',
|
|
188
|
+
CHAR_SEMICOLON: ';',
|
|
189
|
+
CHAR_SINGLE_QUOTE: '\'',
|
|
190
|
+
CHAR_SPACE: ' ',
|
|
191
|
+
CHAR_TAB: '\t',
|
|
192
|
+
CHAR_UNDERSCORE: '_',
|
|
193
|
+
CHAR_VERTICAL_LINE: '|',
|
|
194
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF'
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/expand.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
198
|
+
const fill = __webpack_require__("../../node_modules/.pnpm/fill-range@7.1.1/node_modules/fill-range/index.js");
|
|
199
|
+
const stringify = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
|
|
200
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js");
|
|
201
|
+
const append = (queue = '', stash = '', enclose = false)=>{
|
|
202
|
+
const result = [];
|
|
203
|
+
queue = [].concat(queue);
|
|
204
|
+
stash = [].concat(stash);
|
|
205
|
+
if (!stash.length) return queue;
|
|
206
|
+
if (!queue.length) return enclose ? utils.flatten(stash).map((ele)=>`{${ele}}`) : stash;
|
|
207
|
+
for (const item of queue)if (Array.isArray(item)) for (const value of item)result.push(append(value, stash, enclose));
|
|
208
|
+
else for (let ele of stash){
|
|
209
|
+
if (true === enclose && 'string' == typeof ele) ele = `{${ele}}`;
|
|
210
|
+
result.push(Array.isArray(ele) ? append(item, ele, enclose) : item + ele);
|
|
211
|
+
}
|
|
212
|
+
return utils.flatten(result);
|
|
213
|
+
};
|
|
214
|
+
const expand = (ast, options = {})=>{
|
|
215
|
+
const rangeLimit = void 0 === options.rangeLimit ? 1000 : options.rangeLimit;
|
|
216
|
+
const walk = (node, parent = {})=>{
|
|
217
|
+
node.queue = [];
|
|
218
|
+
let p = parent;
|
|
219
|
+
let q = parent.queue;
|
|
220
|
+
while('brace' !== p.type && 'root' !== p.type && p.parent){
|
|
221
|
+
p = p.parent;
|
|
222
|
+
q = p.queue;
|
|
223
|
+
}
|
|
224
|
+
if (node.invalid || node.dollar) return void q.push(append(q.pop(), stringify(node, options)));
|
|
225
|
+
if ('brace' === node.type && true !== node.invalid && 2 === node.nodes.length) return void q.push(append(q.pop(), [
|
|
226
|
+
'{}'
|
|
227
|
+
]));
|
|
228
|
+
if (node.nodes && node.ranges > 0) {
|
|
229
|
+
const args = utils.reduce(node.nodes);
|
|
230
|
+
if (utils.exceedsLimit(...args, options.step, rangeLimit)) throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
|
|
231
|
+
let range = fill(...args, options);
|
|
232
|
+
if (0 === range.length) range = stringify(node, options);
|
|
233
|
+
q.push(append(q.pop(), range));
|
|
234
|
+
node.nodes = [];
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const enclose = utils.encloseBrace(node);
|
|
238
|
+
let queue = node.queue;
|
|
239
|
+
let block = node;
|
|
240
|
+
while('brace' !== block.type && 'root' !== block.type && block.parent){
|
|
241
|
+
block = block.parent;
|
|
242
|
+
queue = block.queue;
|
|
243
|
+
}
|
|
244
|
+
for(let i = 0; i < node.nodes.length; i++){
|
|
245
|
+
const child = node.nodes[i];
|
|
246
|
+
if ('comma' === child.type && 'brace' === node.type) {
|
|
247
|
+
if (1 === i) queue.push('');
|
|
248
|
+
queue.push('');
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if ('close' === child.type) {
|
|
252
|
+
q.push(append(q.pop(), queue, enclose));
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (child.value && 'open' !== child.type) {
|
|
256
|
+
queue.push(append(queue.pop(), child.value));
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (child.nodes) walk(child, node);
|
|
260
|
+
}
|
|
261
|
+
return queue;
|
|
262
|
+
};
|
|
263
|
+
return utils.flatten(walk(ast));
|
|
264
|
+
};
|
|
265
|
+
module.exports = expand;
|
|
266
|
+
},
|
|
267
|
+
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
268
|
+
const stringify = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js");
|
|
269
|
+
const { MAX_LENGTH, CHAR_BACKSLASH, CHAR_BACKTICK, CHAR_COMMA, CHAR_DOT, CHAR_LEFT_PARENTHESES, CHAR_RIGHT_PARENTHESES, CHAR_LEFT_CURLY_BRACE, CHAR_RIGHT_CURLY_BRACE, CHAR_LEFT_SQUARE_BRACKET, CHAR_RIGHT_SQUARE_BRACKET, CHAR_DOUBLE_QUOTE, CHAR_SINGLE_QUOTE, CHAR_NO_BREAK_SPACE, CHAR_ZERO_WIDTH_NOBREAK_SPACE } = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/constants.js");
|
|
270
|
+
const parse = (input, options = {})=>{
|
|
271
|
+
if ('string' != typeof input) throw new TypeError('Expected a string');
|
|
272
|
+
const opts = options || {};
|
|
273
|
+
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
274
|
+
if (input.length > max) throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
|
|
275
|
+
const ast = {
|
|
276
|
+
type: 'root',
|
|
277
|
+
input,
|
|
278
|
+
nodes: []
|
|
279
|
+
};
|
|
280
|
+
const stack = [
|
|
281
|
+
ast
|
|
282
|
+
];
|
|
283
|
+
let block = ast;
|
|
284
|
+
let prev = ast;
|
|
285
|
+
let brackets = 0;
|
|
286
|
+
const length = input.length;
|
|
287
|
+
let index = 0;
|
|
288
|
+
let depth = 0;
|
|
289
|
+
let value;
|
|
290
|
+
const advance = ()=>input[index++];
|
|
291
|
+
const push = (node)=>{
|
|
292
|
+
if ('text' === node.type && 'dot' === prev.type) prev.type = 'text';
|
|
293
|
+
if (prev && 'text' === prev.type && 'text' === node.type) {
|
|
294
|
+
prev.value += node.value;
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
block.nodes.push(node);
|
|
298
|
+
node.parent = block;
|
|
299
|
+
node.prev = prev;
|
|
300
|
+
prev = node;
|
|
301
|
+
return node;
|
|
302
|
+
};
|
|
303
|
+
push({
|
|
304
|
+
type: 'bos'
|
|
305
|
+
});
|
|
306
|
+
while(index < length){
|
|
307
|
+
block = stack[stack.length - 1];
|
|
308
|
+
value = advance();
|
|
309
|
+
if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) continue;
|
|
310
|
+
if (value === CHAR_BACKSLASH) {
|
|
311
|
+
push({
|
|
312
|
+
type: 'text',
|
|
313
|
+
value: (options.keepEscaping ? value : '') + advance()
|
|
314
|
+
});
|
|
315
|
+
continue;
|
|
316
|
+
}
|
|
317
|
+
if (value === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
318
|
+
push({
|
|
319
|
+
type: 'text',
|
|
320
|
+
value: '\\' + value
|
|
321
|
+
});
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (value === CHAR_LEFT_SQUARE_BRACKET) {
|
|
325
|
+
brackets++;
|
|
326
|
+
let next;
|
|
327
|
+
while(index < length && (next = advance())){
|
|
328
|
+
value += next;
|
|
329
|
+
if (next === CHAR_LEFT_SQUARE_BRACKET) {
|
|
330
|
+
brackets++;
|
|
331
|
+
continue;
|
|
332
|
+
}
|
|
333
|
+
if (next === CHAR_BACKSLASH) {
|
|
334
|
+
value += advance();
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
338
|
+
brackets--;
|
|
339
|
+
if (0 === brackets) break;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
push({
|
|
343
|
+
type: 'text',
|
|
344
|
+
value
|
|
345
|
+
});
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
if (value === CHAR_LEFT_PARENTHESES) {
|
|
349
|
+
block = push({
|
|
350
|
+
type: 'paren',
|
|
351
|
+
nodes: []
|
|
352
|
+
});
|
|
353
|
+
stack.push(block);
|
|
354
|
+
push({
|
|
355
|
+
type: 'text',
|
|
356
|
+
value
|
|
357
|
+
});
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
if (value === CHAR_RIGHT_PARENTHESES) {
|
|
361
|
+
if ('paren' !== block.type) {
|
|
362
|
+
push({
|
|
363
|
+
type: 'text',
|
|
364
|
+
value
|
|
365
|
+
});
|
|
366
|
+
continue;
|
|
367
|
+
}
|
|
368
|
+
block = stack.pop();
|
|
369
|
+
push({
|
|
370
|
+
type: 'text',
|
|
371
|
+
value
|
|
372
|
+
});
|
|
373
|
+
block = stack[stack.length - 1];
|
|
374
|
+
continue;
|
|
375
|
+
}
|
|
376
|
+
if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
|
|
377
|
+
const open = value;
|
|
378
|
+
let next;
|
|
379
|
+
if (true !== options.keepQuotes) value = '';
|
|
380
|
+
while(index < length && (next = advance())){
|
|
381
|
+
if (next === CHAR_BACKSLASH) {
|
|
382
|
+
value += next + advance();
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
if (next === open) {
|
|
386
|
+
if (true === options.keepQuotes) value += next;
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
value += next;
|
|
390
|
+
}
|
|
391
|
+
push({
|
|
392
|
+
type: 'text',
|
|
393
|
+
value
|
|
394
|
+
});
|
|
395
|
+
continue;
|
|
396
|
+
}
|
|
397
|
+
if (value === CHAR_LEFT_CURLY_BRACE) {
|
|
398
|
+
depth++;
|
|
399
|
+
const dollar = prev.value && '$' === prev.value.slice(-1) || true === block.dollar;
|
|
400
|
+
const brace = {
|
|
401
|
+
type: 'brace',
|
|
402
|
+
open: true,
|
|
403
|
+
close: false,
|
|
404
|
+
dollar,
|
|
405
|
+
depth,
|
|
406
|
+
commas: 0,
|
|
407
|
+
ranges: 0,
|
|
408
|
+
nodes: []
|
|
409
|
+
};
|
|
410
|
+
block = push(brace);
|
|
411
|
+
stack.push(block);
|
|
412
|
+
push({
|
|
413
|
+
type: 'open',
|
|
414
|
+
value
|
|
415
|
+
});
|
|
416
|
+
continue;
|
|
417
|
+
}
|
|
418
|
+
if (value === CHAR_RIGHT_CURLY_BRACE) {
|
|
419
|
+
if ('brace' !== block.type) {
|
|
420
|
+
push({
|
|
421
|
+
type: 'text',
|
|
422
|
+
value
|
|
423
|
+
});
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
const type = 'close';
|
|
427
|
+
block = stack.pop();
|
|
428
|
+
block.close = true;
|
|
429
|
+
push({
|
|
430
|
+
type,
|
|
431
|
+
value
|
|
432
|
+
});
|
|
433
|
+
depth--;
|
|
434
|
+
block = stack[stack.length - 1];
|
|
435
|
+
continue;
|
|
436
|
+
}
|
|
437
|
+
if (value === CHAR_COMMA && depth > 0) {
|
|
438
|
+
if (block.ranges > 0) {
|
|
439
|
+
block.ranges = 0;
|
|
440
|
+
const open = block.nodes.shift();
|
|
441
|
+
block.nodes = [
|
|
442
|
+
open,
|
|
443
|
+
{
|
|
444
|
+
type: 'text',
|
|
445
|
+
value: stringify(block)
|
|
446
|
+
}
|
|
447
|
+
];
|
|
448
|
+
}
|
|
449
|
+
push({
|
|
450
|
+
type: 'comma',
|
|
451
|
+
value
|
|
452
|
+
});
|
|
453
|
+
block.commas++;
|
|
454
|
+
continue;
|
|
455
|
+
}
|
|
456
|
+
if (value === CHAR_DOT && depth > 0 && 0 === block.commas) {
|
|
457
|
+
const siblings = block.nodes;
|
|
458
|
+
if (0 === depth || 0 === siblings.length) {
|
|
459
|
+
push({
|
|
460
|
+
type: 'text',
|
|
461
|
+
value
|
|
462
|
+
});
|
|
463
|
+
continue;
|
|
464
|
+
}
|
|
465
|
+
if ('dot' === prev.type) {
|
|
466
|
+
block.range = [];
|
|
467
|
+
prev.value += value;
|
|
468
|
+
prev.type = 'range';
|
|
469
|
+
if (3 !== block.nodes.length && 5 !== block.nodes.length) {
|
|
470
|
+
block.invalid = true;
|
|
471
|
+
block.ranges = 0;
|
|
472
|
+
prev.type = 'text';
|
|
473
|
+
continue;
|
|
474
|
+
}
|
|
475
|
+
block.ranges++;
|
|
476
|
+
block.args = [];
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
if ('range' === prev.type) {
|
|
480
|
+
siblings.pop();
|
|
481
|
+
const before = siblings[siblings.length - 1];
|
|
482
|
+
before.value += prev.value + value;
|
|
483
|
+
prev = before;
|
|
484
|
+
block.ranges--;
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
push({
|
|
488
|
+
type: 'dot',
|
|
489
|
+
value
|
|
490
|
+
});
|
|
491
|
+
continue;
|
|
492
|
+
}
|
|
493
|
+
push({
|
|
494
|
+
type: 'text',
|
|
495
|
+
value
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
do {
|
|
499
|
+
block = stack.pop();
|
|
500
|
+
if ('root' !== block.type) {
|
|
501
|
+
block.nodes.forEach((node)=>{
|
|
502
|
+
if (!node.nodes) {
|
|
503
|
+
if ('open' === node.type) node.isOpen = true;
|
|
504
|
+
if ('close' === node.type) node.isClose = true;
|
|
505
|
+
if (!node.nodes) node.type = 'text';
|
|
506
|
+
node.invalid = true;
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
const parent = stack[stack.length - 1];
|
|
510
|
+
const index = parent.nodes.indexOf(block);
|
|
511
|
+
parent.nodes.splice(index, 1, ...block.nodes);
|
|
512
|
+
}
|
|
513
|
+
}while (stack.length > 0);
|
|
514
|
+
push({
|
|
515
|
+
type: 'eos'
|
|
516
|
+
});
|
|
517
|
+
return ast;
|
|
518
|
+
};
|
|
519
|
+
module.exports = parse;
|
|
520
|
+
},
|
|
521
|
+
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/stringify.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
522
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js");
|
|
523
|
+
module.exports = (ast, options = {})=>{
|
|
524
|
+
const stringify = (node, parent = {})=>{
|
|
525
|
+
const invalidBlock = options.escapeInvalid && utils.isInvalidBrace(parent);
|
|
526
|
+
const invalidNode = true === node.invalid && true === options.escapeInvalid;
|
|
527
|
+
let output = '';
|
|
528
|
+
if (node.value) {
|
|
529
|
+
if ((invalidBlock || invalidNode) && utils.isOpenOrClose(node)) return '\\' + node.value;
|
|
530
|
+
return node.value;
|
|
531
|
+
}
|
|
532
|
+
if (node.value) return node.value;
|
|
533
|
+
if (node.nodes) for (const child of node.nodes)output += stringify(child);
|
|
534
|
+
return output;
|
|
535
|
+
};
|
|
536
|
+
return stringify(ast);
|
|
537
|
+
};
|
|
538
|
+
},
|
|
539
|
+
"../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/lib/utils.js" (__unused_rspack_module, exports) {
|
|
540
|
+
exports.isInteger = (num)=>{
|
|
541
|
+
if ('number' == typeof num) return Number.isInteger(num);
|
|
542
|
+
if ('string' == typeof num && '' !== num.trim()) return Number.isInteger(Number(num));
|
|
543
|
+
return false;
|
|
544
|
+
};
|
|
545
|
+
exports.find = (node, type)=>node.nodes.find((node)=>node.type === type);
|
|
546
|
+
exports.exceedsLimit = (min, max, step = 1, limit)=>{
|
|
547
|
+
if (false === limit) return false;
|
|
548
|
+
if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
|
|
549
|
+
return (Number(max) - Number(min)) / Number(step) >= limit;
|
|
550
|
+
};
|
|
551
|
+
exports.escapeNode = (block, n = 0, type)=>{
|
|
552
|
+
const node = block.nodes[n];
|
|
553
|
+
if (!node) return;
|
|
554
|
+
if (type && node.type === type || 'open' === node.type || 'close' === node.type) {
|
|
555
|
+
if (true !== node.escaped) {
|
|
556
|
+
node.value = '\\' + node.value;
|
|
557
|
+
node.escaped = true;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
exports.encloseBrace = (node)=>{
|
|
562
|
+
if ('brace' !== node.type) return false;
|
|
563
|
+
if (node.commas >> 0 + node.ranges === 0) {
|
|
564
|
+
node.invalid = true;
|
|
565
|
+
return true;
|
|
566
|
+
}
|
|
567
|
+
return false;
|
|
568
|
+
};
|
|
569
|
+
exports.isInvalidBrace = (block)=>{
|
|
570
|
+
if ('brace' !== block.type) return false;
|
|
571
|
+
if (true === block.invalid || block.dollar) return true;
|
|
572
|
+
if (block.commas >> 0 + block.ranges === 0) {
|
|
573
|
+
block.invalid = true;
|
|
574
|
+
return true;
|
|
575
|
+
}
|
|
576
|
+
if (true !== block.open || true !== block.close) {
|
|
577
|
+
block.invalid = true;
|
|
578
|
+
return true;
|
|
579
|
+
}
|
|
580
|
+
return false;
|
|
581
|
+
};
|
|
582
|
+
exports.isOpenOrClose = (node)=>{
|
|
583
|
+
if ('open' === node.type || 'close' === node.type) return true;
|
|
584
|
+
return true === node.open || true === node.close;
|
|
585
|
+
};
|
|
586
|
+
exports.reduce = (nodes)=>nodes.reduce((acc, node)=>{
|
|
587
|
+
if ('text' === node.type) acc.push(node.value);
|
|
588
|
+
if ('range' === node.type) node.type = 'text';
|
|
589
|
+
return acc;
|
|
590
|
+
}, []);
|
|
591
|
+
exports.flatten = (...args)=>{
|
|
592
|
+
const result = [];
|
|
593
|
+
const flat = (arr)=>{
|
|
594
|
+
for(let i = 0; i < arr.length; i++){
|
|
595
|
+
const ele = arr[i];
|
|
596
|
+
if (Array.isArray(ele)) {
|
|
597
|
+
flat(ele);
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
if (void 0 !== ele) result.push(ele);
|
|
601
|
+
}
|
|
602
|
+
return result;
|
|
603
|
+
};
|
|
604
|
+
flat(args);
|
|
605
|
+
return result;
|
|
606
|
+
};
|
|
607
|
+
},
|
|
608
|
+
"../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/index.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
609
|
+
const { EventEmitter } = __webpack_require__("events");
|
|
610
|
+
const fs = __webpack_require__("fs?8b28");
|
|
611
|
+
const sysPath = __webpack_require__("path?aeb1");
|
|
612
|
+
const { promisify } = __webpack_require__("util");
|
|
613
|
+
const readdirp = __webpack_require__("../../node_modules/.pnpm/readdirp@3.6.0/node_modules/readdirp/index.js");
|
|
614
|
+
const anymatch = __webpack_require__("../../node_modules/.pnpm/anymatch@3.1.3/node_modules/anymatch/index.js")["default"];
|
|
615
|
+
const globParent = __webpack_require__("../../node_modules/.pnpm/glob-parent@5.1.2/node_modules/glob-parent/index.js");
|
|
616
|
+
const isGlob = __webpack_require__("../../node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js");
|
|
617
|
+
const braces = __webpack_require__("../../node_modules/.pnpm/braces@3.0.3/node_modules/braces/index.js");
|
|
618
|
+
const normalizePath = __webpack_require__("../../node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js");
|
|
619
|
+
const NodeFsHandler = __webpack_require__("../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/nodefs-handler.js");
|
|
620
|
+
const FsEventsHandler = __webpack_require__("../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/fsevents-handler.js");
|
|
621
|
+
const { EV_ALL, EV_READY, EV_ADD, EV_CHANGE, EV_UNLINK, EV_ADD_DIR, EV_UNLINK_DIR, EV_RAW, EV_ERROR, STR_CLOSE, STR_END, BACK_SLASH_RE, DOUBLE_SLASH_RE, SLASH_OR_BACK_SLASH_RE, DOT_RE, REPLACER_RE, SLASH, SLASH_SLASH, BRACE_START, BANG, ONE_DOT, TWO_DOTS, GLOBSTAR, SLASH_GLOBSTAR, ANYMATCH_OPTS, STRING_TYPE, FUNCTION_TYPE, EMPTY_STR, EMPTY_FN, isWindows, isMacos, isIBMi } = __webpack_require__("../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/constants.js");
|
|
622
|
+
const stat = promisify(fs.stat);
|
|
623
|
+
const readdir = promisify(fs.readdir);
|
|
624
|
+
const arrify = (value = [])=>Array.isArray(value) ? value : [
|
|
625
|
+
value
|
|
626
|
+
];
|
|
627
|
+
const flatten = (list, result = [])=>{
|
|
628
|
+
list.forEach((item)=>{
|
|
629
|
+
if (Array.isArray(item)) flatten(item, result);
|
|
630
|
+
else result.push(item);
|
|
631
|
+
});
|
|
632
|
+
return result;
|
|
633
|
+
};
|
|
634
|
+
const unifyPaths = (paths_)=>{
|
|
635
|
+
const paths = flatten(arrify(paths_));
|
|
636
|
+
if (!paths.every((p)=>typeof p === STRING_TYPE)) throw new TypeError(`Non-string provided as watch path: ${paths}`);
|
|
637
|
+
return paths.map(normalizePathToUnix);
|
|
638
|
+
};
|
|
639
|
+
const toUnix = (string)=>{
|
|
640
|
+
let str = string.replace(BACK_SLASH_RE, SLASH);
|
|
641
|
+
let prepend = false;
|
|
642
|
+
if (str.startsWith(SLASH_SLASH)) prepend = true;
|
|
643
|
+
while(str.match(DOUBLE_SLASH_RE))str = str.replace(DOUBLE_SLASH_RE, SLASH);
|
|
644
|
+
if (prepend) str = SLASH + str;
|
|
645
|
+
return str;
|
|
646
|
+
};
|
|
647
|
+
const normalizePathToUnix = (path)=>toUnix(sysPath.normalize(toUnix(path)));
|
|
648
|
+
const normalizeIgnored = (cwd = EMPTY_STR)=>(path)=>{
|
|
649
|
+
if (typeof path !== STRING_TYPE) return path;
|
|
650
|
+
return normalizePathToUnix(sysPath.isAbsolute(path) ? path : sysPath.join(cwd, path));
|
|
651
|
+
};
|
|
652
|
+
const getAbsolutePath = (path, cwd)=>{
|
|
653
|
+
if (sysPath.isAbsolute(path)) return path;
|
|
654
|
+
if (path.startsWith(BANG)) return BANG + sysPath.join(cwd, path.slice(1));
|
|
655
|
+
return sysPath.join(cwd, path);
|
|
656
|
+
};
|
|
657
|
+
const undef = (opts, key)=>void 0 === opts[key];
|
|
658
|
+
class DirEntry {
|
|
659
|
+
constructor(dir, removeWatcher){
|
|
660
|
+
this.path = dir;
|
|
661
|
+
this._removeWatcher = removeWatcher;
|
|
662
|
+
this.items = new Set();
|
|
663
|
+
}
|
|
664
|
+
add(item) {
|
|
665
|
+
const { items } = this;
|
|
666
|
+
if (!items) return;
|
|
667
|
+
if (item !== ONE_DOT && item !== TWO_DOTS) items.add(item);
|
|
668
|
+
}
|
|
669
|
+
async remove(item) {
|
|
670
|
+
const { items } = this;
|
|
671
|
+
if (!items) return;
|
|
672
|
+
items.delete(item);
|
|
673
|
+
if (items.size > 0) return;
|
|
674
|
+
const dir = this.path;
|
|
675
|
+
try {
|
|
676
|
+
await readdir(dir);
|
|
677
|
+
} catch (err) {
|
|
678
|
+
if (this._removeWatcher) this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
has(item) {
|
|
682
|
+
const { items } = this;
|
|
683
|
+
if (!items) return;
|
|
684
|
+
return items.has(item);
|
|
685
|
+
}
|
|
686
|
+
getChildren() {
|
|
687
|
+
const { items } = this;
|
|
688
|
+
if (!items) return;
|
|
689
|
+
return [
|
|
690
|
+
...items.values()
|
|
691
|
+
];
|
|
692
|
+
}
|
|
693
|
+
dispose() {
|
|
694
|
+
this.items.clear();
|
|
695
|
+
delete this.path;
|
|
696
|
+
delete this._removeWatcher;
|
|
697
|
+
delete this.items;
|
|
698
|
+
Object.freeze(this);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
const STAT_METHOD_F = 'stat';
|
|
702
|
+
const STAT_METHOD_L = 'lstat';
|
|
703
|
+
class WatchHelper {
|
|
704
|
+
constructor(path, watchPath, follow, fsw){
|
|
705
|
+
this.fsw = fsw;
|
|
706
|
+
this.path = path = path.replace(REPLACER_RE, EMPTY_STR);
|
|
707
|
+
this.watchPath = watchPath;
|
|
708
|
+
this.fullWatchPath = sysPath.resolve(watchPath);
|
|
709
|
+
this.hasGlob = watchPath !== path;
|
|
710
|
+
if (path === EMPTY_STR) this.hasGlob = false;
|
|
711
|
+
this.globSymlink = this.hasGlob && follow ? void 0 : false;
|
|
712
|
+
this.globFilter = this.hasGlob ? anymatch(path, void 0, ANYMATCH_OPTS) : false;
|
|
713
|
+
this.dirParts = this.getDirParts(path);
|
|
714
|
+
this.dirParts.forEach((parts)=>{
|
|
715
|
+
if (parts.length > 1) parts.pop();
|
|
716
|
+
});
|
|
717
|
+
this.followSymlinks = follow;
|
|
718
|
+
this.statMethod = follow ? STAT_METHOD_F : STAT_METHOD_L;
|
|
719
|
+
}
|
|
720
|
+
checkGlobSymlink(entry) {
|
|
721
|
+
if (void 0 === this.globSymlink) this.globSymlink = entry.fullParentDir === this.fullWatchPath ? false : {
|
|
722
|
+
realPath: entry.fullParentDir,
|
|
723
|
+
linkPath: this.fullWatchPath
|
|
724
|
+
};
|
|
725
|
+
if (this.globSymlink) return entry.fullPath.replace(this.globSymlink.realPath, this.globSymlink.linkPath);
|
|
726
|
+
return entry.fullPath;
|
|
727
|
+
}
|
|
728
|
+
entryPath(entry) {
|
|
729
|
+
return sysPath.join(this.watchPath, sysPath.relative(this.watchPath, this.checkGlobSymlink(entry)));
|
|
730
|
+
}
|
|
731
|
+
filterPath(entry) {
|
|
732
|
+
const { stats } = entry;
|
|
733
|
+
if (stats && stats.isSymbolicLink()) return this.filterDir(entry);
|
|
734
|
+
const resolvedPath = this.entryPath(entry);
|
|
735
|
+
const matchesGlob = this.hasGlob && typeof this.globFilter === FUNCTION_TYPE ? this.globFilter(resolvedPath) : true;
|
|
736
|
+
return matchesGlob && this.fsw._isntIgnored(resolvedPath, stats) && this.fsw._hasReadPermissions(stats);
|
|
737
|
+
}
|
|
738
|
+
getDirParts(path) {
|
|
739
|
+
if (!this.hasGlob) return [];
|
|
740
|
+
const parts = [];
|
|
741
|
+
const expandedPath = path.includes(BRACE_START) ? braces.expand(path) : [
|
|
742
|
+
path
|
|
743
|
+
];
|
|
744
|
+
expandedPath.forEach((path)=>{
|
|
745
|
+
parts.push(sysPath.relative(this.watchPath, path).split(SLASH_OR_BACK_SLASH_RE));
|
|
746
|
+
});
|
|
747
|
+
return parts;
|
|
748
|
+
}
|
|
749
|
+
filterDir(entry) {
|
|
750
|
+
if (this.hasGlob) {
|
|
751
|
+
const entryParts = this.getDirParts(this.checkGlobSymlink(entry));
|
|
752
|
+
let globstar = false;
|
|
753
|
+
this.unmatchedGlob = !this.dirParts.some((parts)=>parts.every((part, i)=>{
|
|
754
|
+
if (part === GLOBSTAR) globstar = true;
|
|
755
|
+
return globstar || !entryParts[0][i] || anymatch(part, entryParts[0][i], ANYMATCH_OPTS);
|
|
756
|
+
}));
|
|
757
|
+
}
|
|
758
|
+
return !this.unmatchedGlob && this.fsw._isntIgnored(this.entryPath(entry), entry.stats);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
class FSWatcher extends EventEmitter {
|
|
762
|
+
constructor(_opts){
|
|
763
|
+
super();
|
|
764
|
+
const opts = {};
|
|
765
|
+
if (_opts) Object.assign(opts, _opts);
|
|
766
|
+
this._watched = new Map();
|
|
767
|
+
this._closers = new Map();
|
|
768
|
+
this._ignoredPaths = new Set();
|
|
769
|
+
this._throttled = new Map();
|
|
770
|
+
this._symlinkPaths = new Map();
|
|
771
|
+
this._streams = new Set();
|
|
772
|
+
this.closed = false;
|
|
773
|
+
if (undef(opts, 'persistent')) opts.persistent = true;
|
|
774
|
+
if (undef(opts, 'ignoreInitial')) opts.ignoreInitial = false;
|
|
775
|
+
if (undef(opts, 'ignorePermissionErrors')) opts.ignorePermissionErrors = false;
|
|
776
|
+
if (undef(opts, 'interval')) opts.interval = 100;
|
|
777
|
+
if (undef(opts, 'binaryInterval')) opts.binaryInterval = 300;
|
|
778
|
+
if (undef(opts, 'disableGlobbing')) opts.disableGlobbing = false;
|
|
779
|
+
opts.enableBinaryInterval = opts.binaryInterval !== opts.interval;
|
|
780
|
+
if (undef(opts, 'useFsEvents')) opts.useFsEvents = !opts.usePolling;
|
|
781
|
+
const canUseFsEvents = FsEventsHandler.canUse();
|
|
782
|
+
if (!canUseFsEvents) opts.useFsEvents = false;
|
|
783
|
+
if (undef(opts, 'usePolling') && !opts.useFsEvents) opts.usePolling = isMacos;
|
|
784
|
+
if (isIBMi) opts.usePolling = true;
|
|
785
|
+
const envPoll = process.env.CHOKIDAR_USEPOLLING;
|
|
786
|
+
if (void 0 !== envPoll) {
|
|
787
|
+
const envLower = envPoll.toLowerCase();
|
|
788
|
+
if ('false' === envLower || '0' === envLower) opts.usePolling = false;
|
|
789
|
+
else if ('true' === envLower || '1' === envLower) opts.usePolling = true;
|
|
790
|
+
else opts.usePolling = !!envLower;
|
|
791
|
+
}
|
|
792
|
+
const envInterval = process.env.CHOKIDAR_INTERVAL;
|
|
793
|
+
if (envInterval) opts.interval = Number.parseInt(envInterval, 10);
|
|
794
|
+
if (undef(opts, 'atomic')) opts.atomic = !opts.usePolling && !opts.useFsEvents;
|
|
795
|
+
if (opts.atomic) this._pendingUnlinks = new Map();
|
|
796
|
+
if (undef(opts, 'followSymlinks')) opts.followSymlinks = true;
|
|
797
|
+
if (undef(opts, 'awaitWriteFinish')) opts.awaitWriteFinish = false;
|
|
798
|
+
if (true === opts.awaitWriteFinish) opts.awaitWriteFinish = {};
|
|
799
|
+
const awf = opts.awaitWriteFinish;
|
|
800
|
+
if (awf) {
|
|
801
|
+
if (!awf.stabilityThreshold) awf.stabilityThreshold = 2000;
|
|
802
|
+
if (!awf.pollInterval) awf.pollInterval = 100;
|
|
803
|
+
this._pendingWrites = new Map();
|
|
804
|
+
}
|
|
805
|
+
if (opts.ignored) opts.ignored = arrify(opts.ignored);
|
|
806
|
+
let readyCalls = 0;
|
|
807
|
+
this._emitReady = ()=>{
|
|
808
|
+
readyCalls++;
|
|
809
|
+
if (readyCalls >= this._readyCount) {
|
|
810
|
+
this._emitReady = EMPTY_FN;
|
|
811
|
+
this._readyEmitted = true;
|
|
812
|
+
process.nextTick(()=>this.emit(EV_READY));
|
|
813
|
+
}
|
|
814
|
+
};
|
|
815
|
+
this._emitRaw = (...args)=>this.emit(EV_RAW, ...args);
|
|
816
|
+
this._readyEmitted = false;
|
|
817
|
+
this.options = opts;
|
|
818
|
+
if (opts.useFsEvents) this._fsEventsHandler = new FsEventsHandler(this);
|
|
819
|
+
else this._nodeFsHandler = new NodeFsHandler(this);
|
|
820
|
+
Object.freeze(opts);
|
|
821
|
+
}
|
|
822
|
+
add(paths_, _origAdd, _internal) {
|
|
823
|
+
const { cwd, disableGlobbing } = this.options;
|
|
824
|
+
this.closed = false;
|
|
825
|
+
let paths = unifyPaths(paths_);
|
|
826
|
+
if (cwd) paths = paths.map((path)=>{
|
|
827
|
+
const absPath = getAbsolutePath(path, cwd);
|
|
828
|
+
if (disableGlobbing || !isGlob(path)) return absPath;
|
|
829
|
+
return normalizePath(absPath);
|
|
830
|
+
});
|
|
831
|
+
paths = paths.filter((path)=>{
|
|
832
|
+
if (path.startsWith(BANG)) {
|
|
833
|
+
this._ignoredPaths.add(path.slice(1));
|
|
834
|
+
return false;
|
|
835
|
+
}
|
|
836
|
+
this._ignoredPaths.delete(path);
|
|
837
|
+
this._ignoredPaths.delete(path + SLASH_GLOBSTAR);
|
|
838
|
+
this._userIgnored = void 0;
|
|
839
|
+
return true;
|
|
840
|
+
});
|
|
841
|
+
if (this.options.useFsEvents && this._fsEventsHandler) {
|
|
842
|
+
if (!this._readyCount) this._readyCount = paths.length;
|
|
843
|
+
if (this.options.persistent) this._readyCount += paths.length;
|
|
844
|
+
paths.forEach((path)=>this._fsEventsHandler._addToFsEvents(path));
|
|
845
|
+
} else {
|
|
846
|
+
if (!this._readyCount) this._readyCount = 0;
|
|
847
|
+
this._readyCount += paths.length;
|
|
848
|
+
Promise.all(paths.map(async (path)=>{
|
|
849
|
+
const res = await this._nodeFsHandler._addToNodeFs(path, !_internal, 0, 0, _origAdd);
|
|
850
|
+
if (res) this._emitReady();
|
|
851
|
+
return res;
|
|
852
|
+
})).then((results)=>{
|
|
853
|
+
if (this.closed) return;
|
|
854
|
+
results.filter((item)=>item).forEach((item)=>{
|
|
855
|
+
this.add(sysPath.dirname(item), sysPath.basename(_origAdd || item));
|
|
856
|
+
});
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
return this;
|
|
860
|
+
}
|
|
861
|
+
unwatch(paths_) {
|
|
862
|
+
if (this.closed) return this;
|
|
863
|
+
const paths = unifyPaths(paths_);
|
|
864
|
+
const { cwd } = this.options;
|
|
865
|
+
paths.forEach((path)=>{
|
|
866
|
+
if (!sysPath.isAbsolute(path) && !this._closers.has(path)) {
|
|
867
|
+
if (cwd) path = sysPath.join(cwd, path);
|
|
868
|
+
path = sysPath.resolve(path);
|
|
869
|
+
}
|
|
870
|
+
this._closePath(path);
|
|
871
|
+
this._ignoredPaths.add(path);
|
|
872
|
+
if (this._watched.has(path)) this._ignoredPaths.add(path + SLASH_GLOBSTAR);
|
|
873
|
+
this._userIgnored = void 0;
|
|
874
|
+
});
|
|
875
|
+
return this;
|
|
876
|
+
}
|
|
877
|
+
close() {
|
|
878
|
+
if (this.closed) return this._closePromise;
|
|
879
|
+
this.closed = true;
|
|
880
|
+
this.removeAllListeners();
|
|
881
|
+
const closers = [];
|
|
882
|
+
this._closers.forEach((closerList)=>closerList.forEach((closer)=>{
|
|
883
|
+
const promise = closer();
|
|
884
|
+
if (promise instanceof Promise) closers.push(promise);
|
|
885
|
+
}));
|
|
886
|
+
this._streams.forEach((stream)=>stream.destroy());
|
|
887
|
+
this._userIgnored = void 0;
|
|
888
|
+
this._readyCount = 0;
|
|
889
|
+
this._readyEmitted = false;
|
|
890
|
+
this._watched.forEach((dirent)=>dirent.dispose());
|
|
891
|
+
[
|
|
892
|
+
'closers',
|
|
893
|
+
'watched',
|
|
894
|
+
'streams',
|
|
895
|
+
'symlinkPaths',
|
|
896
|
+
'throttled'
|
|
897
|
+
].forEach((key)=>{
|
|
898
|
+
this[`_${key}`].clear();
|
|
899
|
+
});
|
|
900
|
+
this._closePromise = closers.length ? Promise.all(closers).then(()=>void 0) : Promise.resolve();
|
|
901
|
+
return this._closePromise;
|
|
902
|
+
}
|
|
903
|
+
getWatched() {
|
|
904
|
+
const watchList = {};
|
|
905
|
+
this._watched.forEach((entry, dir)=>{
|
|
906
|
+
const key = this.options.cwd ? sysPath.relative(this.options.cwd, dir) : dir;
|
|
907
|
+
watchList[key || ONE_DOT] = entry.getChildren().sort();
|
|
908
|
+
});
|
|
909
|
+
return watchList;
|
|
910
|
+
}
|
|
911
|
+
emitWithAll(event, args) {
|
|
912
|
+
this.emit(...args);
|
|
913
|
+
if (event !== EV_ERROR) this.emit(EV_ALL, ...args);
|
|
914
|
+
}
|
|
915
|
+
async _emit(event, path, val1, val2, val3) {
|
|
916
|
+
if (this.closed) return;
|
|
917
|
+
const opts = this.options;
|
|
918
|
+
if (isWindows) path = sysPath.normalize(path);
|
|
919
|
+
if (opts.cwd) path = sysPath.relative(opts.cwd, path);
|
|
920
|
+
const args = [
|
|
921
|
+
event,
|
|
922
|
+
path
|
|
923
|
+
];
|
|
924
|
+
if (void 0 !== val3) args.push(val1, val2, val3);
|
|
925
|
+
else if (void 0 !== val2) args.push(val1, val2);
|
|
926
|
+
else if (void 0 !== val1) args.push(val1);
|
|
927
|
+
const awf = opts.awaitWriteFinish;
|
|
928
|
+
let pw;
|
|
929
|
+
if (awf && (pw = this._pendingWrites.get(path))) {
|
|
930
|
+
pw.lastChange = new Date();
|
|
931
|
+
return this;
|
|
932
|
+
}
|
|
933
|
+
if (opts.atomic) {
|
|
934
|
+
if (event === EV_UNLINK) {
|
|
935
|
+
this._pendingUnlinks.set(path, args);
|
|
936
|
+
setTimeout(()=>{
|
|
937
|
+
this._pendingUnlinks.forEach((entry, path)=>{
|
|
938
|
+
this.emit(...entry);
|
|
939
|
+
this.emit(EV_ALL, ...entry);
|
|
940
|
+
this._pendingUnlinks.delete(path);
|
|
941
|
+
});
|
|
942
|
+
}, 'number' == typeof opts.atomic ? opts.atomic : 100);
|
|
943
|
+
return this;
|
|
944
|
+
}
|
|
945
|
+
if (event === EV_ADD && this._pendingUnlinks.has(path)) {
|
|
946
|
+
event = args[0] = EV_CHANGE;
|
|
947
|
+
this._pendingUnlinks.delete(path);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
if (awf && (event === EV_ADD || event === EV_CHANGE) && this._readyEmitted) {
|
|
951
|
+
const awfEmit = (err, stats)=>{
|
|
952
|
+
if (err) {
|
|
953
|
+
event = args[0] = EV_ERROR;
|
|
954
|
+
args[1] = err;
|
|
955
|
+
this.emitWithAll(event, args);
|
|
956
|
+
} else if (stats) {
|
|
957
|
+
if (args.length > 2) args[2] = stats;
|
|
958
|
+
else args.push(stats);
|
|
959
|
+
this.emitWithAll(event, args);
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
this._awaitWriteFinish(path, awf.stabilityThreshold, event, awfEmit);
|
|
963
|
+
return this;
|
|
964
|
+
}
|
|
965
|
+
if (event === EV_CHANGE) {
|
|
966
|
+
const isThrottled = !this._throttle(EV_CHANGE, path, 50);
|
|
967
|
+
if (isThrottled) return this;
|
|
968
|
+
}
|
|
969
|
+
if (opts.alwaysStat && void 0 === val1 && (event === EV_ADD || event === EV_ADD_DIR || event === EV_CHANGE)) {
|
|
970
|
+
const fullPath = opts.cwd ? sysPath.join(opts.cwd, path) : path;
|
|
971
|
+
let stats;
|
|
972
|
+
try {
|
|
973
|
+
stats = await stat(fullPath);
|
|
974
|
+
} catch (err) {}
|
|
975
|
+
if (!stats || this.closed) return;
|
|
976
|
+
args.push(stats);
|
|
977
|
+
}
|
|
978
|
+
this.emitWithAll(event, args);
|
|
979
|
+
return this;
|
|
980
|
+
}
|
|
981
|
+
_handleError(error) {
|
|
982
|
+
const code = error && error.code;
|
|
983
|
+
if (error && 'ENOENT' !== code && 'ENOTDIR' !== code && (!this.options.ignorePermissionErrors || 'EPERM' !== code && 'EACCES' !== code)) this.emit(EV_ERROR, error);
|
|
984
|
+
return error || this.closed;
|
|
985
|
+
}
|
|
986
|
+
_throttle(actionType, path, timeout) {
|
|
987
|
+
if (!this._throttled.has(actionType)) this._throttled.set(actionType, new Map());
|
|
988
|
+
const action = this._throttled.get(actionType);
|
|
989
|
+
const actionPath = action.get(path);
|
|
990
|
+
if (actionPath) {
|
|
991
|
+
actionPath.count++;
|
|
992
|
+
return false;
|
|
993
|
+
}
|
|
994
|
+
let timeoutObject;
|
|
995
|
+
const clear = ()=>{
|
|
996
|
+
const item = action.get(path);
|
|
997
|
+
const count = item ? item.count : 0;
|
|
998
|
+
action.delete(path);
|
|
999
|
+
clearTimeout(timeoutObject);
|
|
1000
|
+
if (item) clearTimeout(item.timeoutObject);
|
|
1001
|
+
return count;
|
|
1002
|
+
};
|
|
1003
|
+
timeoutObject = setTimeout(clear, timeout);
|
|
1004
|
+
const thr = {
|
|
1005
|
+
timeoutObject,
|
|
1006
|
+
clear,
|
|
1007
|
+
count: 0
|
|
1008
|
+
};
|
|
1009
|
+
action.set(path, thr);
|
|
1010
|
+
return thr;
|
|
1011
|
+
}
|
|
1012
|
+
_incrReadyCount() {
|
|
1013
|
+
return this._readyCount++;
|
|
1014
|
+
}
|
|
1015
|
+
_awaitWriteFinish(path, threshold, event, awfEmit) {
|
|
1016
|
+
let timeoutHandler;
|
|
1017
|
+
let fullPath = path;
|
|
1018
|
+
if (this.options.cwd && !sysPath.isAbsolute(path)) fullPath = sysPath.join(this.options.cwd, path);
|
|
1019
|
+
const now = new Date();
|
|
1020
|
+
const awaitWriteFinish = (prevStat)=>{
|
|
1021
|
+
fs.stat(fullPath, (err, curStat)=>{
|
|
1022
|
+
if (err || !this._pendingWrites.has(path)) {
|
|
1023
|
+
if (err && 'ENOENT' !== err.code) awfEmit(err);
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
const now = Number(new Date());
|
|
1027
|
+
if (prevStat && curStat.size !== prevStat.size) this._pendingWrites.get(path).lastChange = now;
|
|
1028
|
+
const pw = this._pendingWrites.get(path);
|
|
1029
|
+
const df = now - pw.lastChange;
|
|
1030
|
+
if (df >= threshold) {
|
|
1031
|
+
this._pendingWrites.delete(path);
|
|
1032
|
+
awfEmit(void 0, curStat);
|
|
1033
|
+
} else timeoutHandler = setTimeout(awaitWriteFinish, this.options.awaitWriteFinish.pollInterval, curStat);
|
|
1034
|
+
});
|
|
1035
|
+
};
|
|
1036
|
+
if (!this._pendingWrites.has(path)) {
|
|
1037
|
+
this._pendingWrites.set(path, {
|
|
1038
|
+
lastChange: now,
|
|
1039
|
+
cancelWait: ()=>{
|
|
1040
|
+
this._pendingWrites.delete(path);
|
|
1041
|
+
clearTimeout(timeoutHandler);
|
|
1042
|
+
return event;
|
|
1043
|
+
}
|
|
1044
|
+
});
|
|
1045
|
+
timeoutHandler = setTimeout(awaitWriteFinish, this.options.awaitWriteFinish.pollInterval);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
_getGlobIgnored() {
|
|
1049
|
+
return [
|
|
1050
|
+
...this._ignoredPaths.values()
|
|
1051
|
+
];
|
|
1052
|
+
}
|
|
1053
|
+
_isIgnored(path, stats) {
|
|
1054
|
+
if (this.options.atomic && DOT_RE.test(path)) return true;
|
|
1055
|
+
if (!this._userIgnored) {
|
|
1056
|
+
const { cwd } = this.options;
|
|
1057
|
+
const ign = this.options.ignored;
|
|
1058
|
+
const ignored = ign && ign.map(normalizeIgnored(cwd));
|
|
1059
|
+
const paths = arrify(ignored).filter((path)=>typeof path === STRING_TYPE && !isGlob(path)).map((path)=>path + SLASH_GLOBSTAR);
|
|
1060
|
+
const list = this._getGlobIgnored().map(normalizeIgnored(cwd)).concat(ignored, paths);
|
|
1061
|
+
this._userIgnored = anymatch(list, void 0, ANYMATCH_OPTS);
|
|
1062
|
+
}
|
|
1063
|
+
return this._userIgnored([
|
|
1064
|
+
path,
|
|
1065
|
+
stats
|
|
1066
|
+
]);
|
|
1067
|
+
}
|
|
1068
|
+
_isntIgnored(path, stat) {
|
|
1069
|
+
return !this._isIgnored(path, stat);
|
|
1070
|
+
}
|
|
1071
|
+
_getWatchHelpers(path, depth) {
|
|
1072
|
+
const watchPath = depth || this.options.disableGlobbing || !isGlob(path) ? path : globParent(path);
|
|
1073
|
+
const follow = this.options.followSymlinks;
|
|
1074
|
+
return new WatchHelper(path, watchPath, follow, this);
|
|
1075
|
+
}
|
|
1076
|
+
_getWatchedDir(directory) {
|
|
1077
|
+
if (!this._boundRemove) this._boundRemove = this._remove.bind(this);
|
|
1078
|
+
const dir = sysPath.resolve(directory);
|
|
1079
|
+
if (!this._watched.has(dir)) this._watched.set(dir, new DirEntry(dir, this._boundRemove));
|
|
1080
|
+
return this._watched.get(dir);
|
|
1081
|
+
}
|
|
1082
|
+
_hasReadPermissions(stats) {
|
|
1083
|
+
if (this.options.ignorePermissionErrors) return true;
|
|
1084
|
+
const md = stats && Number.parseInt(stats.mode, 10);
|
|
1085
|
+
const st = 511 & md;
|
|
1086
|
+
const it = Number.parseInt(st.toString(8)[0], 10);
|
|
1087
|
+
return Boolean(4 & it);
|
|
1088
|
+
}
|
|
1089
|
+
_remove(directory, item, isDirectory) {
|
|
1090
|
+
const path = sysPath.join(directory, item);
|
|
1091
|
+
const fullPath = sysPath.resolve(path);
|
|
1092
|
+
isDirectory = null != isDirectory ? isDirectory : this._watched.has(path) || this._watched.has(fullPath);
|
|
1093
|
+
if (!this._throttle('remove', path, 100)) return;
|
|
1094
|
+
if (!isDirectory && !this.options.useFsEvents && 1 === this._watched.size) this.add(directory, item, true);
|
|
1095
|
+
const wp = this._getWatchedDir(path);
|
|
1096
|
+
const nestedDirectoryChildren = wp.getChildren();
|
|
1097
|
+
nestedDirectoryChildren.forEach((nested)=>this._remove(path, nested));
|
|
1098
|
+
const parent = this._getWatchedDir(directory);
|
|
1099
|
+
const wasTracked = parent.has(item);
|
|
1100
|
+
parent.remove(item);
|
|
1101
|
+
if (this._symlinkPaths.has(fullPath)) this._symlinkPaths.delete(fullPath);
|
|
1102
|
+
let relPath = path;
|
|
1103
|
+
if (this.options.cwd) relPath = sysPath.relative(this.options.cwd, path);
|
|
1104
|
+
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
1105
|
+
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
1106
|
+
if (event === EV_ADD) return;
|
|
1107
|
+
}
|
|
1108
|
+
this._watched.delete(path);
|
|
1109
|
+
this._watched.delete(fullPath);
|
|
1110
|
+
const eventName = isDirectory ? EV_UNLINK_DIR : EV_UNLINK;
|
|
1111
|
+
if (wasTracked && !this._isIgnored(path)) this._emit(eventName, path);
|
|
1112
|
+
if (!this.options.useFsEvents) this._closePath(path);
|
|
1113
|
+
}
|
|
1114
|
+
_closePath(path) {
|
|
1115
|
+
this._closeFile(path);
|
|
1116
|
+
const dir = sysPath.dirname(path);
|
|
1117
|
+
this._getWatchedDir(dir).remove(sysPath.basename(path));
|
|
1118
|
+
}
|
|
1119
|
+
_closeFile(path) {
|
|
1120
|
+
const closers = this._closers.get(path);
|
|
1121
|
+
if (!closers) return;
|
|
1122
|
+
closers.forEach((closer)=>closer());
|
|
1123
|
+
this._closers.delete(path);
|
|
1124
|
+
}
|
|
1125
|
+
_addPathCloser(path, closer) {
|
|
1126
|
+
if (!closer) return;
|
|
1127
|
+
let list = this._closers.get(path);
|
|
1128
|
+
if (!list) {
|
|
1129
|
+
list = [];
|
|
1130
|
+
this._closers.set(path, list);
|
|
1131
|
+
}
|
|
1132
|
+
list.push(closer);
|
|
1133
|
+
}
|
|
1134
|
+
_readdirp(root, opts) {
|
|
1135
|
+
if (this.closed) return;
|
|
1136
|
+
const options = {
|
|
1137
|
+
type: EV_ALL,
|
|
1138
|
+
alwaysStat: true,
|
|
1139
|
+
lstat: true,
|
|
1140
|
+
...opts
|
|
1141
|
+
};
|
|
1142
|
+
let stream = readdirp(root, options);
|
|
1143
|
+
this._streams.add(stream);
|
|
1144
|
+
stream.once(STR_CLOSE, ()=>{
|
|
1145
|
+
stream = void 0;
|
|
1146
|
+
});
|
|
1147
|
+
stream.once(STR_END, ()=>{
|
|
1148
|
+
if (stream) {
|
|
1149
|
+
this._streams.delete(stream);
|
|
1150
|
+
stream = void 0;
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
return stream;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
const watch = (paths, options)=>{
|
|
1157
|
+
const watcher = new FSWatcher(options);
|
|
1158
|
+
watcher.add(paths);
|
|
1159
|
+
return watcher;
|
|
1160
|
+
};
|
|
1161
|
+
exports.w = watch;
|
|
1162
|
+
},
|
|
1163
|
+
"../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/constants.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
1164
|
+
const { sep } = __webpack_require__("path?aeb1");
|
|
1165
|
+
const { platform } = process;
|
|
1166
|
+
const os = __webpack_require__("os");
|
|
1167
|
+
exports.EV_ALL = 'all';
|
|
1168
|
+
exports.EV_READY = 'ready';
|
|
1169
|
+
exports.EV_ADD = 'add';
|
|
1170
|
+
exports.EV_CHANGE = 'change';
|
|
1171
|
+
exports.EV_ADD_DIR = 'addDir';
|
|
1172
|
+
exports.EV_UNLINK = 'unlink';
|
|
1173
|
+
exports.EV_UNLINK_DIR = 'unlinkDir';
|
|
1174
|
+
exports.EV_RAW = 'raw';
|
|
1175
|
+
exports.EV_ERROR = 'error';
|
|
1176
|
+
exports.STR_DATA = 'data';
|
|
1177
|
+
exports.STR_END = 'end';
|
|
1178
|
+
exports.STR_CLOSE = 'close';
|
|
1179
|
+
exports.FSEVENT_CREATED = 'created';
|
|
1180
|
+
exports.FSEVENT_MODIFIED = 'modified';
|
|
1181
|
+
exports.FSEVENT_DELETED = 'deleted';
|
|
1182
|
+
exports.FSEVENT_MOVED = 'moved';
|
|
1183
|
+
'cloned';
|
|
1184
|
+
exports.FSEVENT_UNKNOWN = 'unknown';
|
|
1185
|
+
exports.FSEVENT_FLAG_MUST_SCAN_SUBDIRS = 1;
|
|
1186
|
+
exports.FSEVENT_TYPE_FILE = 'file';
|
|
1187
|
+
exports.FSEVENT_TYPE_DIRECTORY = 'directory';
|
|
1188
|
+
exports.FSEVENT_TYPE_SYMLINK = 'symlink';
|
|
1189
|
+
exports.KEY_LISTENERS = 'listeners';
|
|
1190
|
+
exports.KEY_ERR = 'errHandlers';
|
|
1191
|
+
exports.KEY_RAW = 'rawEmitters';
|
|
1192
|
+
exports.HANDLER_KEYS = [
|
|
1193
|
+
exports.KEY_LISTENERS,
|
|
1194
|
+
exports.KEY_ERR,
|
|
1195
|
+
exports.KEY_RAW
|
|
1196
|
+
];
|
|
1197
|
+
exports.DOT_SLASH = `.${sep}`;
|
|
1198
|
+
exports.BACK_SLASH_RE = /\\/g;
|
|
1199
|
+
exports.DOUBLE_SLASH_RE = /\/\//;
|
|
1200
|
+
exports.SLASH_OR_BACK_SLASH_RE = /[/\\]/;
|
|
1201
|
+
exports.DOT_RE = /\..*\.(sw[px])$|~$|\.subl.*\.tmp/;
|
|
1202
|
+
exports.REPLACER_RE = /^\.[/\\]/;
|
|
1203
|
+
exports.SLASH = '/';
|
|
1204
|
+
exports.SLASH_SLASH = '//';
|
|
1205
|
+
exports.BRACE_START = '{';
|
|
1206
|
+
exports.BANG = '!';
|
|
1207
|
+
exports.ONE_DOT = '.';
|
|
1208
|
+
exports.TWO_DOTS = '..';
|
|
1209
|
+
exports.STAR = '*';
|
|
1210
|
+
exports.GLOBSTAR = '**';
|
|
1211
|
+
exports.ROOT_GLOBSTAR = '/**/*';
|
|
1212
|
+
exports.SLASH_GLOBSTAR = '/**';
|
|
1213
|
+
exports.DIR_SUFFIX = 'Dir';
|
|
1214
|
+
exports.ANYMATCH_OPTS = {
|
|
1215
|
+
dot: true
|
|
1216
|
+
};
|
|
1217
|
+
exports.STRING_TYPE = 'string';
|
|
1218
|
+
exports.FUNCTION_TYPE = 'function';
|
|
1219
|
+
exports.EMPTY_STR = '';
|
|
1220
|
+
exports.EMPTY_FN = ()=>{};
|
|
1221
|
+
exports.IDENTITY_FN = (val)=>val;
|
|
1222
|
+
exports.isWindows = 'win32' === platform;
|
|
1223
|
+
exports.isMacos = 'darwin' === platform;
|
|
1224
|
+
exports.isLinux = 'linux' === platform;
|
|
1225
|
+
exports.isIBMi = 'OS400' === os.type();
|
|
1226
|
+
},
|
|
1227
|
+
"../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/fsevents-handler.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1228
|
+
const fs = __webpack_require__("fs?8b28");
|
|
1229
|
+
const sysPath = __webpack_require__("path?aeb1");
|
|
1230
|
+
const { promisify } = __webpack_require__("util");
|
|
1231
|
+
let fsevents;
|
|
1232
|
+
try {
|
|
1233
|
+
fsevents = __webpack_require__(Object(function() {
|
|
1234
|
+
var e = new Error("Cannot find module 'fsevents'");
|
|
1235
|
+
e.code = 'MODULE_NOT_FOUND';
|
|
1236
|
+
throw e;
|
|
1237
|
+
}()));
|
|
1238
|
+
} catch (error) {
|
|
1239
|
+
if (process.env.CHOKIDAR_PRINT_FSEVENTS_REQUIRE_ERROR) console.error(error);
|
|
1240
|
+
}
|
|
1241
|
+
if (fsevents) {
|
|
1242
|
+
const mtch = process.version.match(/v(\d+)\.(\d+)/);
|
|
1243
|
+
if (mtch && mtch[1] && mtch[2]) {
|
|
1244
|
+
const maj = Number.parseInt(mtch[1], 10);
|
|
1245
|
+
const min = Number.parseInt(mtch[2], 10);
|
|
1246
|
+
if (8 === maj && min < 16) fsevents = void 0;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
const { EV_ADD, EV_CHANGE, EV_ADD_DIR, EV_UNLINK, EV_ERROR, STR_DATA, STR_END, FSEVENT_CREATED, FSEVENT_MODIFIED, FSEVENT_DELETED, FSEVENT_MOVED, FSEVENT_UNKNOWN, FSEVENT_FLAG_MUST_SCAN_SUBDIRS, FSEVENT_TYPE_FILE, FSEVENT_TYPE_DIRECTORY, FSEVENT_TYPE_SYMLINK, ROOT_GLOBSTAR, DIR_SUFFIX, DOT_SLASH, FUNCTION_TYPE, EMPTY_FN, IDENTITY_FN } = __webpack_require__("../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/constants.js");
|
|
1250
|
+
const Depth = (value)=>isNaN(value) ? {} : {
|
|
1251
|
+
depth: value
|
|
1252
|
+
};
|
|
1253
|
+
const stat = promisify(fs.stat);
|
|
1254
|
+
const lstat = promisify(fs.lstat);
|
|
1255
|
+
const realpath = promisify(fs.realpath);
|
|
1256
|
+
const statMethods = {
|
|
1257
|
+
stat,
|
|
1258
|
+
lstat
|
|
1259
|
+
};
|
|
1260
|
+
const FSEventsWatchers = new Map();
|
|
1261
|
+
const consolidateThreshhold = 10;
|
|
1262
|
+
const wrongEventFlags = new Set([
|
|
1263
|
+
69888,
|
|
1264
|
+
70400,
|
|
1265
|
+
71424,
|
|
1266
|
+
72704,
|
|
1267
|
+
73472,
|
|
1268
|
+
131328,
|
|
1269
|
+
131840,
|
|
1270
|
+
262912
|
|
1271
|
+
]);
|
|
1272
|
+
const createFSEventsInstance = (path, callback)=>{
|
|
1273
|
+
const stop = fsevents.watch(path, callback);
|
|
1274
|
+
return {
|
|
1275
|
+
stop
|
|
1276
|
+
};
|
|
1277
|
+
};
|
|
1278
|
+
function setFSEventsListener(path, realPath, listener, rawEmitter) {
|
|
1279
|
+
let watchPath = sysPath.extname(realPath) ? sysPath.dirname(realPath) : realPath;
|
|
1280
|
+
const parentPath = sysPath.dirname(watchPath);
|
|
1281
|
+
let cont = FSEventsWatchers.get(watchPath);
|
|
1282
|
+
if (couldConsolidate(parentPath)) watchPath = parentPath;
|
|
1283
|
+
const resolvedPath = sysPath.resolve(path);
|
|
1284
|
+
const hasSymlink = resolvedPath !== realPath;
|
|
1285
|
+
const filteredListener = (fullPath, flags, info)=>{
|
|
1286
|
+
if (hasSymlink) fullPath = fullPath.replace(realPath, resolvedPath);
|
|
1287
|
+
if (fullPath === resolvedPath || !fullPath.indexOf(resolvedPath + sysPath.sep)) listener(fullPath, flags, info);
|
|
1288
|
+
};
|
|
1289
|
+
let watchedParent = false;
|
|
1290
|
+
for (const watchedPath of FSEventsWatchers.keys())if (0 === realPath.indexOf(sysPath.resolve(watchedPath) + sysPath.sep)) {
|
|
1291
|
+
watchPath = watchedPath;
|
|
1292
|
+
cont = FSEventsWatchers.get(watchPath);
|
|
1293
|
+
watchedParent = true;
|
|
1294
|
+
break;
|
|
1295
|
+
}
|
|
1296
|
+
if (cont || watchedParent) cont.listeners.add(filteredListener);
|
|
1297
|
+
else {
|
|
1298
|
+
cont = {
|
|
1299
|
+
listeners: new Set([
|
|
1300
|
+
filteredListener
|
|
1301
|
+
]),
|
|
1302
|
+
rawEmitter,
|
|
1303
|
+
watcher: createFSEventsInstance(watchPath, (fullPath, flags)=>{
|
|
1304
|
+
if (!cont.listeners.size) return;
|
|
1305
|
+
if (flags & FSEVENT_FLAG_MUST_SCAN_SUBDIRS) return;
|
|
1306
|
+
const info = fsevents.getInfo(fullPath, flags);
|
|
1307
|
+
cont.listeners.forEach((list)=>{
|
|
1308
|
+
list(fullPath, flags, info);
|
|
1309
|
+
});
|
|
1310
|
+
cont.rawEmitter(info.event, fullPath, info);
|
|
1311
|
+
})
|
|
1312
|
+
};
|
|
1313
|
+
FSEventsWatchers.set(watchPath, cont);
|
|
1314
|
+
}
|
|
1315
|
+
return ()=>{
|
|
1316
|
+
const lst = cont.listeners;
|
|
1317
|
+
lst.delete(filteredListener);
|
|
1318
|
+
if (!lst.size) {
|
|
1319
|
+
FSEventsWatchers.delete(watchPath);
|
|
1320
|
+
if (cont.watcher) return cont.watcher.stop().then(()=>{
|
|
1321
|
+
cont.rawEmitter = cont.watcher = void 0;
|
|
1322
|
+
Object.freeze(cont);
|
|
1323
|
+
});
|
|
1324
|
+
}
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
const couldConsolidate = (path)=>{
|
|
1328
|
+
let count = 0;
|
|
1329
|
+
for (const watchPath of FSEventsWatchers.keys())if (0 === watchPath.indexOf(path)) {
|
|
1330
|
+
count++;
|
|
1331
|
+
if (count >= consolidateThreshhold) return true;
|
|
1332
|
+
}
|
|
1333
|
+
return false;
|
|
1334
|
+
};
|
|
1335
|
+
const canUse = ()=>fsevents && FSEventsWatchers.size < 128;
|
|
1336
|
+
const calcDepth = (path, root)=>{
|
|
1337
|
+
let i = 0;
|
|
1338
|
+
while(!path.indexOf(root) && (path = sysPath.dirname(path)) !== root)i++;
|
|
1339
|
+
return i;
|
|
1340
|
+
};
|
|
1341
|
+
const sameTypes = (info, stats)=>info.type === FSEVENT_TYPE_DIRECTORY && stats.isDirectory() || info.type === FSEVENT_TYPE_SYMLINK && stats.isSymbolicLink() || info.type === FSEVENT_TYPE_FILE && stats.isFile();
|
|
1342
|
+
class FsEventsHandler {
|
|
1343
|
+
constructor(fsw){
|
|
1344
|
+
this.fsw = fsw;
|
|
1345
|
+
}
|
|
1346
|
+
checkIgnored(path, stats) {
|
|
1347
|
+
const ipaths = this.fsw._ignoredPaths;
|
|
1348
|
+
if (this.fsw._isIgnored(path, stats)) {
|
|
1349
|
+
ipaths.add(path);
|
|
1350
|
+
if (stats && stats.isDirectory()) ipaths.add(path + ROOT_GLOBSTAR);
|
|
1351
|
+
return true;
|
|
1352
|
+
}
|
|
1353
|
+
ipaths.delete(path);
|
|
1354
|
+
ipaths.delete(path + ROOT_GLOBSTAR);
|
|
1355
|
+
}
|
|
1356
|
+
addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
|
|
1357
|
+
const event = watchedDir.has(item) ? EV_CHANGE : EV_ADD;
|
|
1358
|
+
this.handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1359
|
+
}
|
|
1360
|
+
async checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts) {
|
|
1361
|
+
try {
|
|
1362
|
+
const stats = await stat(path);
|
|
1363
|
+
if (this.fsw.closed) return;
|
|
1364
|
+
if (sameTypes(info, stats)) this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1365
|
+
else this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1366
|
+
} catch (error) {
|
|
1367
|
+
if ('EACCES' === error.code) this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1368
|
+
else this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
handleEvent(event, path, fullPath, realPath, parent, watchedDir, item, info, opts) {
|
|
1372
|
+
if (this.fsw.closed || this.checkIgnored(path)) return;
|
|
1373
|
+
if (event === EV_UNLINK) {
|
|
1374
|
+
const isDirectory = info.type === FSEVENT_TYPE_DIRECTORY;
|
|
1375
|
+
if (isDirectory || watchedDir.has(item)) this.fsw._remove(parent, item, isDirectory);
|
|
1376
|
+
} else {
|
|
1377
|
+
if (event === EV_ADD) {
|
|
1378
|
+
if (info.type === FSEVENT_TYPE_DIRECTORY) this.fsw._getWatchedDir(path);
|
|
1379
|
+
if (info.type === FSEVENT_TYPE_SYMLINK && opts.followSymlinks) {
|
|
1380
|
+
const curDepth = void 0 === opts.depth ? void 0 : calcDepth(fullPath, realPath) + 1;
|
|
1381
|
+
return this._addToFsEvents(path, false, true, curDepth);
|
|
1382
|
+
}
|
|
1383
|
+
this.fsw._getWatchedDir(parent).add(item);
|
|
1384
|
+
}
|
|
1385
|
+
const eventName = info.type === FSEVENT_TYPE_DIRECTORY ? event + DIR_SUFFIX : event;
|
|
1386
|
+
this.fsw._emit(eventName, path);
|
|
1387
|
+
if (eventName === EV_ADD_DIR) this._addToFsEvents(path, false, true);
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
_watchWithFsEvents(watchPath, realPath, transform, globFilter) {
|
|
1391
|
+
if (this.fsw.closed || this.fsw._isIgnored(watchPath)) return;
|
|
1392
|
+
const opts = this.fsw.options;
|
|
1393
|
+
const watchCallback = async (fullPath, flags, info)=>{
|
|
1394
|
+
if (this.fsw.closed) return;
|
|
1395
|
+
if (void 0 !== opts.depth && calcDepth(fullPath, realPath) > opts.depth) return;
|
|
1396
|
+
const path = transform(sysPath.join(watchPath, sysPath.relative(watchPath, fullPath)));
|
|
1397
|
+
if (globFilter && !globFilter(path)) return;
|
|
1398
|
+
const parent = sysPath.dirname(path);
|
|
1399
|
+
const item = sysPath.basename(path);
|
|
1400
|
+
const watchedDir = this.fsw._getWatchedDir(info.type === FSEVENT_TYPE_DIRECTORY ? path : parent);
|
|
1401
|
+
if (wrongEventFlags.has(flags) || info.event === FSEVENT_UNKNOWN) if (typeof opts.ignored === FUNCTION_TYPE) {
|
|
1402
|
+
let stats;
|
|
1403
|
+
try {
|
|
1404
|
+
stats = await stat(path);
|
|
1405
|
+
} catch (error) {}
|
|
1406
|
+
if (this.fsw.closed) return;
|
|
1407
|
+
if (this.checkIgnored(path, stats)) return;
|
|
1408
|
+
if (sameTypes(info, stats)) this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1409
|
+
else this.handleEvent(EV_UNLINK, path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1410
|
+
} else this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1411
|
+
else switch(info.event){
|
|
1412
|
+
case FSEVENT_CREATED:
|
|
1413
|
+
case FSEVENT_MODIFIED:
|
|
1414
|
+
return this.addOrChange(path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1415
|
+
case FSEVENT_DELETED:
|
|
1416
|
+
case FSEVENT_MOVED:
|
|
1417
|
+
return this.checkExists(path, fullPath, realPath, parent, watchedDir, item, info, opts);
|
|
1418
|
+
}
|
|
1419
|
+
};
|
|
1420
|
+
const closer = setFSEventsListener(watchPath, realPath, watchCallback, this.fsw._emitRaw);
|
|
1421
|
+
this.fsw._emitReady();
|
|
1422
|
+
return closer;
|
|
1423
|
+
}
|
|
1424
|
+
async _handleFsEventsSymlink(linkPath, fullPath, transform, curDepth) {
|
|
1425
|
+
if (this.fsw.closed || this.fsw._symlinkPaths.has(fullPath)) return;
|
|
1426
|
+
this.fsw._symlinkPaths.set(fullPath, true);
|
|
1427
|
+
this.fsw._incrReadyCount();
|
|
1428
|
+
try {
|
|
1429
|
+
const linkTarget = await realpath(linkPath);
|
|
1430
|
+
if (this.fsw.closed) return;
|
|
1431
|
+
if (this.fsw._isIgnored(linkTarget)) return this.fsw._emitReady();
|
|
1432
|
+
this.fsw._incrReadyCount();
|
|
1433
|
+
this._addToFsEvents(linkTarget || linkPath, (path)=>{
|
|
1434
|
+
let aliasedPath = linkPath;
|
|
1435
|
+
if (linkTarget && linkTarget !== DOT_SLASH) aliasedPath = path.replace(linkTarget, linkPath);
|
|
1436
|
+
else if (path !== DOT_SLASH) aliasedPath = sysPath.join(linkPath, path);
|
|
1437
|
+
return transform(aliasedPath);
|
|
1438
|
+
}, false, curDepth);
|
|
1439
|
+
} catch (error) {
|
|
1440
|
+
if (this.fsw._handleError(error)) return this.fsw._emitReady();
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
emitAdd(newPath, stats, processPath, opts, forceAdd) {
|
|
1444
|
+
const pp = processPath(newPath);
|
|
1445
|
+
const isDir = stats.isDirectory();
|
|
1446
|
+
const dirObj = this.fsw._getWatchedDir(sysPath.dirname(pp));
|
|
1447
|
+
const base = sysPath.basename(pp);
|
|
1448
|
+
if (isDir) this.fsw._getWatchedDir(pp);
|
|
1449
|
+
if (dirObj.has(base)) return;
|
|
1450
|
+
dirObj.add(base);
|
|
1451
|
+
if (!opts.ignoreInitial || true === forceAdd) this.fsw._emit(isDir ? EV_ADD_DIR : EV_ADD, pp, stats);
|
|
1452
|
+
}
|
|
1453
|
+
initWatch(realPath, path, wh, processPath) {
|
|
1454
|
+
if (this.fsw.closed) return;
|
|
1455
|
+
const closer = this._watchWithFsEvents(wh.watchPath, sysPath.resolve(realPath || wh.watchPath), processPath, wh.globFilter);
|
|
1456
|
+
this.fsw._addPathCloser(path, closer);
|
|
1457
|
+
}
|
|
1458
|
+
async _addToFsEvents(path, transform, forceAdd, priorDepth) {
|
|
1459
|
+
if (this.fsw.closed) return;
|
|
1460
|
+
const opts = this.fsw.options;
|
|
1461
|
+
const processPath = typeof transform === FUNCTION_TYPE ? transform : IDENTITY_FN;
|
|
1462
|
+
const wh = this.fsw._getWatchHelpers(path);
|
|
1463
|
+
try {
|
|
1464
|
+
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
|
1465
|
+
if (this.fsw.closed) return;
|
|
1466
|
+
if (this.fsw._isIgnored(wh.watchPath, stats)) throw null;
|
|
1467
|
+
if (stats.isDirectory()) {
|
|
1468
|
+
if (!wh.globFilter) this.emitAdd(processPath(path), stats, processPath, opts, forceAdd);
|
|
1469
|
+
if (priorDepth && priorDepth > opts.depth) return;
|
|
1470
|
+
this.fsw._readdirp(wh.watchPath, {
|
|
1471
|
+
fileFilter: (entry)=>wh.filterPath(entry),
|
|
1472
|
+
directoryFilter: (entry)=>wh.filterDir(entry),
|
|
1473
|
+
...Depth(opts.depth - (priorDepth || 0))
|
|
1474
|
+
}).on(STR_DATA, (entry)=>{
|
|
1475
|
+
if (this.fsw.closed) return;
|
|
1476
|
+
if (entry.stats.isDirectory() && !wh.filterPath(entry)) return;
|
|
1477
|
+
const joinedPath = sysPath.join(wh.watchPath, entry.path);
|
|
1478
|
+
const { fullPath } = entry;
|
|
1479
|
+
if (wh.followSymlinks && entry.stats.isSymbolicLink()) {
|
|
1480
|
+
const curDepth = void 0 === opts.depth ? void 0 : calcDepth(joinedPath, sysPath.resolve(wh.watchPath)) + 1;
|
|
1481
|
+
this._handleFsEventsSymlink(joinedPath, fullPath, processPath, curDepth);
|
|
1482
|
+
} else this.emitAdd(joinedPath, entry.stats, processPath, opts, forceAdd);
|
|
1483
|
+
}).on(EV_ERROR, EMPTY_FN).on(STR_END, ()=>{
|
|
1484
|
+
this.fsw._emitReady();
|
|
1485
|
+
});
|
|
1486
|
+
} else {
|
|
1487
|
+
this.emitAdd(wh.watchPath, stats, processPath, opts, forceAdd);
|
|
1488
|
+
this.fsw._emitReady();
|
|
1489
|
+
}
|
|
1490
|
+
} catch (error) {
|
|
1491
|
+
if (!error || this.fsw._handleError(error)) {
|
|
1492
|
+
this.fsw._emitReady();
|
|
1493
|
+
this.fsw._emitReady();
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
if (opts.persistent && true !== forceAdd) if (typeof transform === FUNCTION_TYPE) this.initWatch(void 0, path, wh, processPath);
|
|
1497
|
+
else {
|
|
1498
|
+
let realPath;
|
|
1499
|
+
try {
|
|
1500
|
+
realPath = await realpath(wh.watchPath);
|
|
1501
|
+
} catch (e) {}
|
|
1502
|
+
this.initWatch(realPath, path, wh, processPath);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
module.exports = FsEventsHandler;
|
|
1507
|
+
module.exports.canUse = canUse;
|
|
1508
|
+
},
|
|
1509
|
+
"../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/nodefs-handler.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1510
|
+
const fs = __webpack_require__("fs?8b28");
|
|
1511
|
+
const sysPath = __webpack_require__("path?aeb1");
|
|
1512
|
+
const { promisify } = __webpack_require__("util");
|
|
1513
|
+
const isBinaryPath = __webpack_require__("../../node_modules/.pnpm/is-binary-path@2.1.0/node_modules/is-binary-path/index.js");
|
|
1514
|
+
const { isWindows, isLinux, EMPTY_FN, EMPTY_STR, KEY_LISTENERS, KEY_ERR, KEY_RAW, HANDLER_KEYS, EV_CHANGE, EV_ADD, EV_ADD_DIR, EV_ERROR, STR_DATA, STR_END, BRACE_START, STAR } = __webpack_require__("../../node_modules/.pnpm/chokidar@3.6.0/node_modules/chokidar/lib/constants.js");
|
|
1515
|
+
const THROTTLE_MODE_WATCH = 'watch';
|
|
1516
|
+
const open = promisify(fs.open);
|
|
1517
|
+
const stat = promisify(fs.stat);
|
|
1518
|
+
const lstat = promisify(fs.lstat);
|
|
1519
|
+
const close = promisify(fs.close);
|
|
1520
|
+
const fsrealpath = promisify(fs.realpath);
|
|
1521
|
+
const statMethods = {
|
|
1522
|
+
lstat,
|
|
1523
|
+
stat
|
|
1524
|
+
};
|
|
1525
|
+
const foreach = (val, fn)=>{
|
|
1526
|
+
if (val instanceof Set) val.forEach(fn);
|
|
1527
|
+
else fn(val);
|
|
1528
|
+
};
|
|
1529
|
+
const addAndConvert = (main, prop, item)=>{
|
|
1530
|
+
let container = main[prop];
|
|
1531
|
+
if (!(container instanceof Set)) main[prop] = container = new Set([
|
|
1532
|
+
container
|
|
1533
|
+
]);
|
|
1534
|
+
container.add(item);
|
|
1535
|
+
};
|
|
1536
|
+
const clearItem = (cont)=>(key)=>{
|
|
1537
|
+
const set = cont[key];
|
|
1538
|
+
if (set instanceof Set) set.clear();
|
|
1539
|
+
else delete cont[key];
|
|
1540
|
+
};
|
|
1541
|
+
const delFromSet = (main, prop, item)=>{
|
|
1542
|
+
const container = main[prop];
|
|
1543
|
+
if (container instanceof Set) container.delete(item);
|
|
1544
|
+
else if (container === item) delete main[prop];
|
|
1545
|
+
};
|
|
1546
|
+
const isEmptySet = (val)=>val instanceof Set ? 0 === val.size : !val;
|
|
1547
|
+
const FsWatchInstances = new Map();
|
|
1548
|
+
function createFsWatchInstance(path, options, listener, errHandler, emitRaw) {
|
|
1549
|
+
const handleEvent = (rawEvent, evPath)=>{
|
|
1550
|
+
listener(path);
|
|
1551
|
+
emitRaw(rawEvent, evPath, {
|
|
1552
|
+
watchedPath: path
|
|
1553
|
+
});
|
|
1554
|
+
if (evPath && path !== evPath) fsWatchBroadcast(sysPath.resolve(path, evPath), KEY_LISTENERS, sysPath.join(path, evPath));
|
|
1555
|
+
};
|
|
1556
|
+
try {
|
|
1557
|
+
return fs.watch(path, options, handleEvent);
|
|
1558
|
+
} catch (error) {
|
|
1559
|
+
errHandler(error);
|
|
1560
|
+
}
|
|
1561
|
+
}
|
|
1562
|
+
const fsWatchBroadcast = (fullPath, type, val1, val2, val3)=>{
|
|
1563
|
+
const cont = FsWatchInstances.get(fullPath);
|
|
1564
|
+
if (!cont) return;
|
|
1565
|
+
foreach(cont[type], (listener)=>{
|
|
1566
|
+
listener(val1, val2, val3);
|
|
1567
|
+
});
|
|
1568
|
+
};
|
|
1569
|
+
const setFsWatchListener = (path, fullPath, options, handlers)=>{
|
|
1570
|
+
const { listener, errHandler, rawEmitter } = handlers;
|
|
1571
|
+
let cont = FsWatchInstances.get(fullPath);
|
|
1572
|
+
let watcher;
|
|
1573
|
+
if (!options.persistent) {
|
|
1574
|
+
watcher = createFsWatchInstance(path, options, listener, errHandler, rawEmitter);
|
|
1575
|
+
return watcher.close.bind(watcher);
|
|
1576
|
+
}
|
|
1577
|
+
if (cont) {
|
|
1578
|
+
addAndConvert(cont, KEY_LISTENERS, listener);
|
|
1579
|
+
addAndConvert(cont, KEY_ERR, errHandler);
|
|
1580
|
+
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
1581
|
+
} else {
|
|
1582
|
+
watcher = createFsWatchInstance(path, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
1583
|
+
if (!watcher) return;
|
|
1584
|
+
watcher.on(EV_ERROR, async (error)=>{
|
|
1585
|
+
const broadcastErr = fsWatchBroadcast.bind(null, fullPath, KEY_ERR);
|
|
1586
|
+
cont.watcherUnusable = true;
|
|
1587
|
+
if (isWindows && 'EPERM' === error.code) try {
|
|
1588
|
+
const fd = await open(path, 'r');
|
|
1589
|
+
await close(fd);
|
|
1590
|
+
broadcastErr(error);
|
|
1591
|
+
} catch (err) {}
|
|
1592
|
+
else broadcastErr(error);
|
|
1593
|
+
});
|
|
1594
|
+
cont = {
|
|
1595
|
+
listeners: listener,
|
|
1596
|
+
errHandlers: errHandler,
|
|
1597
|
+
rawEmitters: rawEmitter,
|
|
1598
|
+
watcher
|
|
1599
|
+
};
|
|
1600
|
+
FsWatchInstances.set(fullPath, cont);
|
|
1601
|
+
}
|
|
1602
|
+
return ()=>{
|
|
1603
|
+
delFromSet(cont, KEY_LISTENERS, listener);
|
|
1604
|
+
delFromSet(cont, KEY_ERR, errHandler);
|
|
1605
|
+
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
1606
|
+
if (isEmptySet(cont.listeners)) {
|
|
1607
|
+
cont.watcher.close();
|
|
1608
|
+
FsWatchInstances.delete(fullPath);
|
|
1609
|
+
HANDLER_KEYS.forEach(clearItem(cont));
|
|
1610
|
+
cont.watcher = void 0;
|
|
1611
|
+
Object.freeze(cont);
|
|
1612
|
+
}
|
|
1613
|
+
};
|
|
1614
|
+
};
|
|
1615
|
+
const FsWatchFileInstances = new Map();
|
|
1616
|
+
const setFsWatchFileListener = (path, fullPath, options, handlers)=>{
|
|
1617
|
+
const { listener, rawEmitter } = handlers;
|
|
1618
|
+
let cont = FsWatchFileInstances.get(fullPath);
|
|
1619
|
+
new Set();
|
|
1620
|
+
new Set();
|
|
1621
|
+
const copts = cont && cont.options;
|
|
1622
|
+
if (copts && (copts.persistent < options.persistent || copts.interval > options.interval)) {
|
|
1623
|
+
cont.listeners;
|
|
1624
|
+
cont.rawEmitters;
|
|
1625
|
+
fs.unwatchFile(fullPath);
|
|
1626
|
+
cont = void 0;
|
|
1627
|
+
}
|
|
1628
|
+
if (cont) {
|
|
1629
|
+
addAndConvert(cont, KEY_LISTENERS, listener);
|
|
1630
|
+
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
1631
|
+
} else {
|
|
1632
|
+
cont = {
|
|
1633
|
+
listeners: listener,
|
|
1634
|
+
rawEmitters: rawEmitter,
|
|
1635
|
+
options,
|
|
1636
|
+
watcher: fs.watchFile(fullPath, options, (curr, prev)=>{
|
|
1637
|
+
foreach(cont.rawEmitters, (rawEmitter)=>{
|
|
1638
|
+
rawEmitter(EV_CHANGE, fullPath, {
|
|
1639
|
+
curr,
|
|
1640
|
+
prev
|
|
1641
|
+
});
|
|
1642
|
+
});
|
|
1643
|
+
const currmtime = curr.mtimeMs;
|
|
1644
|
+
if (curr.size !== prev.size || currmtime > prev.mtimeMs || 0 === currmtime) foreach(cont.listeners, (listener)=>listener(path, curr));
|
|
1645
|
+
})
|
|
1646
|
+
};
|
|
1647
|
+
FsWatchFileInstances.set(fullPath, cont);
|
|
1648
|
+
}
|
|
1649
|
+
return ()=>{
|
|
1650
|
+
delFromSet(cont, KEY_LISTENERS, listener);
|
|
1651
|
+
delFromSet(cont, KEY_RAW, rawEmitter);
|
|
1652
|
+
if (isEmptySet(cont.listeners)) {
|
|
1653
|
+
FsWatchFileInstances.delete(fullPath);
|
|
1654
|
+
fs.unwatchFile(fullPath);
|
|
1655
|
+
cont.options = cont.watcher = void 0;
|
|
1656
|
+
Object.freeze(cont);
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
};
|
|
1660
|
+
class NodeFsHandler {
|
|
1661
|
+
constructor(fsW){
|
|
1662
|
+
this.fsw = fsW;
|
|
1663
|
+
this._boundHandleError = (error)=>fsW._handleError(error);
|
|
1664
|
+
}
|
|
1665
|
+
_watchWithNodeFs(path, listener) {
|
|
1666
|
+
const opts = this.fsw.options;
|
|
1667
|
+
const directory = sysPath.dirname(path);
|
|
1668
|
+
const basename = sysPath.basename(path);
|
|
1669
|
+
const parent = this.fsw._getWatchedDir(directory);
|
|
1670
|
+
parent.add(basename);
|
|
1671
|
+
const absolutePath = sysPath.resolve(path);
|
|
1672
|
+
const options = {
|
|
1673
|
+
persistent: opts.persistent
|
|
1674
|
+
};
|
|
1675
|
+
if (!listener) listener = EMPTY_FN;
|
|
1676
|
+
let closer;
|
|
1677
|
+
if (opts.usePolling) {
|
|
1678
|
+
options.interval = opts.enableBinaryInterval && isBinaryPath(basename) ? opts.binaryInterval : opts.interval;
|
|
1679
|
+
closer = setFsWatchFileListener(path, absolutePath, options, {
|
|
1680
|
+
listener,
|
|
1681
|
+
rawEmitter: this.fsw._emitRaw
|
|
1682
|
+
});
|
|
1683
|
+
} else closer = setFsWatchListener(path, absolutePath, options, {
|
|
1684
|
+
listener,
|
|
1685
|
+
errHandler: this._boundHandleError,
|
|
1686
|
+
rawEmitter: this.fsw._emitRaw
|
|
1687
|
+
});
|
|
1688
|
+
return closer;
|
|
1689
|
+
}
|
|
1690
|
+
_handleFile(file, stats, initialAdd) {
|
|
1691
|
+
if (this.fsw.closed) return;
|
|
1692
|
+
const dirname = sysPath.dirname(file);
|
|
1693
|
+
const basename = sysPath.basename(file);
|
|
1694
|
+
const parent = this.fsw._getWatchedDir(dirname);
|
|
1695
|
+
let prevStats = stats;
|
|
1696
|
+
if (parent.has(basename)) return;
|
|
1697
|
+
const listener = async (path, newStats)=>{
|
|
1698
|
+
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5)) return;
|
|
1699
|
+
if (newStats && 0 !== newStats.mtimeMs) {
|
|
1700
|
+
if (parent.has(basename)) {
|
|
1701
|
+
const at = newStats.atimeMs;
|
|
1702
|
+
const mt = newStats.mtimeMs;
|
|
1703
|
+
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV_CHANGE, file, newStats);
|
|
1704
|
+
prevStats = newStats;
|
|
1705
|
+
}
|
|
1706
|
+
} else try {
|
|
1707
|
+
const newStats = await stat(file);
|
|
1708
|
+
if (this.fsw.closed) return;
|
|
1709
|
+
const at = newStats.atimeMs;
|
|
1710
|
+
const mt = newStats.mtimeMs;
|
|
1711
|
+
if (!at || at <= mt || mt !== prevStats.mtimeMs) this.fsw._emit(EV_CHANGE, file, newStats);
|
|
1712
|
+
if (isLinux && prevStats.ino !== newStats.ino) {
|
|
1713
|
+
this.fsw._closeFile(path);
|
|
1714
|
+
prevStats = newStats;
|
|
1715
|
+
this.fsw._addPathCloser(path, this._watchWithNodeFs(file, listener));
|
|
1716
|
+
} else prevStats = newStats;
|
|
1717
|
+
} catch (error) {
|
|
1718
|
+
this.fsw._remove(dirname, basename);
|
|
1719
|
+
}
|
|
1720
|
+
};
|
|
1721
|
+
const closer = this._watchWithNodeFs(file, listener);
|
|
1722
|
+
if (!(initialAdd && this.fsw.options.ignoreInitial) && this.fsw._isntIgnored(file)) {
|
|
1723
|
+
if (!this.fsw._throttle(EV_ADD, file, 0)) return;
|
|
1724
|
+
this.fsw._emit(EV_ADD, file, stats);
|
|
1725
|
+
}
|
|
1726
|
+
return closer;
|
|
1727
|
+
}
|
|
1728
|
+
async _handleSymlink(entry, directory, path, item) {
|
|
1729
|
+
if (this.fsw.closed) return;
|
|
1730
|
+
const full = entry.fullPath;
|
|
1731
|
+
const dir = this.fsw._getWatchedDir(directory);
|
|
1732
|
+
if (!this.fsw.options.followSymlinks) {
|
|
1733
|
+
this.fsw._incrReadyCount();
|
|
1734
|
+
let linkPath;
|
|
1735
|
+
try {
|
|
1736
|
+
linkPath = await fsrealpath(path);
|
|
1737
|
+
} catch (e) {
|
|
1738
|
+
this.fsw._emitReady();
|
|
1739
|
+
return true;
|
|
1740
|
+
}
|
|
1741
|
+
if (this.fsw.closed) return;
|
|
1742
|
+
if (dir.has(item)) {
|
|
1743
|
+
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
1744
|
+
this.fsw._symlinkPaths.set(full, linkPath);
|
|
1745
|
+
this.fsw._emit(EV_CHANGE, path, entry.stats);
|
|
1746
|
+
}
|
|
1747
|
+
} else {
|
|
1748
|
+
dir.add(item);
|
|
1749
|
+
this.fsw._symlinkPaths.set(full, linkPath);
|
|
1750
|
+
this.fsw._emit(EV_ADD, path, entry.stats);
|
|
1751
|
+
}
|
|
1752
|
+
this.fsw._emitReady();
|
|
1753
|
+
return true;
|
|
1754
|
+
}
|
|
1755
|
+
if (this.fsw._symlinkPaths.has(full)) return true;
|
|
1756
|
+
this.fsw._symlinkPaths.set(full, true);
|
|
1757
|
+
}
|
|
1758
|
+
_handleRead(directory, initialAdd, wh, target, dir, depth, throttler) {
|
|
1759
|
+
directory = sysPath.join(directory, EMPTY_STR);
|
|
1760
|
+
if (!wh.hasGlob) {
|
|
1761
|
+
throttler = this.fsw._throttle('readdir', directory, 1000);
|
|
1762
|
+
if (!throttler) return;
|
|
1763
|
+
}
|
|
1764
|
+
const previous = this.fsw._getWatchedDir(wh.path);
|
|
1765
|
+
const current = new Set();
|
|
1766
|
+
let stream = this.fsw._readdirp(directory, {
|
|
1767
|
+
fileFilter: (entry)=>wh.filterPath(entry),
|
|
1768
|
+
directoryFilter: (entry)=>wh.filterDir(entry),
|
|
1769
|
+
depth: 0
|
|
1770
|
+
}).on(STR_DATA, async (entry)=>{
|
|
1771
|
+
if (this.fsw.closed) {
|
|
1772
|
+
stream = void 0;
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
const item = entry.path;
|
|
1776
|
+
let path = sysPath.join(directory, item);
|
|
1777
|
+
current.add(item);
|
|
1778
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path, item)) return;
|
|
1779
|
+
if (this.fsw.closed) {
|
|
1780
|
+
stream = void 0;
|
|
1781
|
+
return;
|
|
1782
|
+
}
|
|
1783
|
+
if (item === target || !target && !previous.has(item)) {
|
|
1784
|
+
this.fsw._incrReadyCount();
|
|
1785
|
+
path = sysPath.join(dir, sysPath.relative(dir, path));
|
|
1786
|
+
this._addToNodeFs(path, initialAdd, wh, depth + 1);
|
|
1787
|
+
}
|
|
1788
|
+
}).on(EV_ERROR, this._boundHandleError);
|
|
1789
|
+
return new Promise((resolve)=>stream.once(STR_END, ()=>{
|
|
1790
|
+
if (this.fsw.closed) {
|
|
1791
|
+
stream = void 0;
|
|
1792
|
+
return;
|
|
1793
|
+
}
|
|
1794
|
+
const wasThrottled = throttler ? throttler.clear() : false;
|
|
1795
|
+
resolve();
|
|
1796
|
+
previous.getChildren().filter((item)=>item !== directory && !current.has(item) && (!wh.hasGlob || wh.filterPath({
|
|
1797
|
+
fullPath: sysPath.resolve(directory, item)
|
|
1798
|
+
}))).forEach((item)=>{
|
|
1799
|
+
this.fsw._remove(directory, item);
|
|
1800
|
+
});
|
|
1801
|
+
stream = void 0;
|
|
1802
|
+
if (wasThrottled) this._handleRead(directory, false, wh, target, dir, depth, throttler);
|
|
1803
|
+
}));
|
|
1804
|
+
}
|
|
1805
|
+
async _handleDir(dir, stats, initialAdd, depth, target, wh, realpath) {
|
|
1806
|
+
const parentDir = this.fsw._getWatchedDir(sysPath.dirname(dir));
|
|
1807
|
+
const tracked = parentDir.has(sysPath.basename(dir));
|
|
1808
|
+
if (!(initialAdd && this.fsw.options.ignoreInitial) && !target && !tracked) {
|
|
1809
|
+
if (!wh.hasGlob || wh.globFilter(dir)) this.fsw._emit(EV_ADD_DIR, dir, stats);
|
|
1810
|
+
}
|
|
1811
|
+
parentDir.add(sysPath.basename(dir));
|
|
1812
|
+
this.fsw._getWatchedDir(dir);
|
|
1813
|
+
let throttler;
|
|
1814
|
+
let closer;
|
|
1815
|
+
const oDepth = this.fsw.options.depth;
|
|
1816
|
+
if ((null == oDepth || depth <= oDepth) && !this.fsw._symlinkPaths.has(realpath)) {
|
|
1817
|
+
if (!target) {
|
|
1818
|
+
await this._handleRead(dir, initialAdd, wh, target, dir, depth, throttler);
|
|
1819
|
+
if (this.fsw.closed) return;
|
|
1820
|
+
}
|
|
1821
|
+
closer = this._watchWithNodeFs(dir, (dirPath, stats)=>{
|
|
1822
|
+
if (stats && 0 === stats.mtimeMs) return;
|
|
1823
|
+
this._handleRead(dirPath, false, wh, target, dir, depth, throttler);
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
return closer;
|
|
1827
|
+
}
|
|
1828
|
+
async _addToNodeFs(path, initialAdd, priorWh, depth, target) {
|
|
1829
|
+
const ready = this.fsw._emitReady;
|
|
1830
|
+
if (this.fsw._isIgnored(path) || this.fsw.closed) {
|
|
1831
|
+
ready();
|
|
1832
|
+
return false;
|
|
1833
|
+
}
|
|
1834
|
+
const wh = this.fsw._getWatchHelpers(path, depth);
|
|
1835
|
+
if (!wh.hasGlob && priorWh) {
|
|
1836
|
+
wh.hasGlob = priorWh.hasGlob;
|
|
1837
|
+
wh.globFilter = priorWh.globFilter;
|
|
1838
|
+
wh.filterPath = (entry)=>priorWh.filterPath(entry);
|
|
1839
|
+
wh.filterDir = (entry)=>priorWh.filterDir(entry);
|
|
1840
|
+
}
|
|
1841
|
+
try {
|
|
1842
|
+
const stats = await statMethods[wh.statMethod](wh.watchPath);
|
|
1843
|
+
if (this.fsw.closed) return;
|
|
1844
|
+
if (this.fsw._isIgnored(wh.watchPath, stats)) {
|
|
1845
|
+
ready();
|
|
1846
|
+
return false;
|
|
1847
|
+
}
|
|
1848
|
+
const follow = this.fsw.options.followSymlinks && !path.includes(STAR) && !path.includes(BRACE_START);
|
|
1849
|
+
let closer;
|
|
1850
|
+
if (stats.isDirectory()) {
|
|
1851
|
+
const absPath = sysPath.resolve(path);
|
|
1852
|
+
const targetPath = follow ? await fsrealpath(path) : path;
|
|
1853
|
+
if (this.fsw.closed) return;
|
|
1854
|
+
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
1855
|
+
if (this.fsw.closed) return;
|
|
1856
|
+
if (absPath !== targetPath && void 0 !== targetPath) this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
1857
|
+
} else if (stats.isSymbolicLink()) {
|
|
1858
|
+
const targetPath = follow ? await fsrealpath(path) : path;
|
|
1859
|
+
if (this.fsw.closed) return;
|
|
1860
|
+
const parent = sysPath.dirname(wh.watchPath);
|
|
1861
|
+
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
1862
|
+
this.fsw._emit(EV_ADD, wh.watchPath, stats);
|
|
1863
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path, wh, targetPath);
|
|
1864
|
+
if (this.fsw.closed) return;
|
|
1865
|
+
if (void 0 !== targetPath) this.fsw._symlinkPaths.set(sysPath.resolve(path), targetPath);
|
|
1866
|
+
} else closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
1867
|
+
ready();
|
|
1868
|
+
this.fsw._addPathCloser(path, closer);
|
|
1869
|
+
return false;
|
|
1870
|
+
} catch (error) {
|
|
1871
|
+
if (this.fsw._handleError(error)) {
|
|
1872
|
+
ready();
|
|
1873
|
+
return path;
|
|
1874
|
+
}
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
module.exports = NodeFsHandler;
|
|
1879
|
+
},
|
|
1880
|
+
"../../node_modules/.pnpm/fill-range@7.1.1/node_modules/fill-range/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1881
|
+
/*!
|
|
1882
|
+
* fill-range <https://github.com/jonschlinkert/fill-range>
|
|
1883
|
+
*
|
|
1884
|
+
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
1885
|
+
* Licensed under the MIT License.
|
|
1886
|
+
*/ const util = __webpack_require__("util");
|
|
1887
|
+
const toRegexRange = __webpack_require__("../../node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js");
|
|
1888
|
+
const isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
1889
|
+
const transform = (toNumber)=>(value)=>true === toNumber ? Number(value) : String(value);
|
|
1890
|
+
const isValidValue = (value)=>'number' == typeof value || 'string' == typeof value && '' !== value;
|
|
1891
|
+
const isNumber = (num)=>Number.isInteger(+num);
|
|
1892
|
+
const zeros = (input)=>{
|
|
1893
|
+
let value = `${input}`;
|
|
1894
|
+
let index = -1;
|
|
1895
|
+
if ('-' === value[0]) value = value.slice(1);
|
|
1896
|
+
if ('0' === value) return false;
|
|
1897
|
+
while('0' === value[++index]);
|
|
1898
|
+
return index > 0;
|
|
1899
|
+
};
|
|
1900
|
+
const stringify = (start, end, options)=>{
|
|
1901
|
+
if ('string' == typeof start || 'string' == typeof end) return true;
|
|
1902
|
+
return true === options.stringify;
|
|
1903
|
+
};
|
|
1904
|
+
const pad = (input, maxLength, toNumber)=>{
|
|
1905
|
+
if (maxLength > 0) {
|
|
1906
|
+
let dash = '-' === input[0] ? '-' : '';
|
|
1907
|
+
if (dash) input = input.slice(1);
|
|
1908
|
+
input = dash + input.padStart(dash ? maxLength - 1 : maxLength, '0');
|
|
1909
|
+
}
|
|
1910
|
+
if (false === toNumber) return String(input);
|
|
1911
|
+
return input;
|
|
1912
|
+
};
|
|
1913
|
+
const toMaxLen = (input, maxLength)=>{
|
|
1914
|
+
let negative = '-' === input[0] ? '-' : '';
|
|
1915
|
+
if (negative) {
|
|
1916
|
+
input = input.slice(1);
|
|
1917
|
+
maxLength--;
|
|
1918
|
+
}
|
|
1919
|
+
while(input.length < maxLength)input = '0' + input;
|
|
1920
|
+
return negative ? '-' + input : input;
|
|
1921
|
+
};
|
|
1922
|
+
const toSequence = (parts, options, maxLen)=>{
|
|
1923
|
+
parts.negatives.sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
|
|
1924
|
+
parts.positives.sort((a, b)=>a < b ? -1 : a > b ? 1 : 0);
|
|
1925
|
+
let prefix = options.capture ? '' : '?:';
|
|
1926
|
+
let positives = '';
|
|
1927
|
+
let negatives = '';
|
|
1928
|
+
let result;
|
|
1929
|
+
if (parts.positives.length) positives = parts.positives.map((v)=>toMaxLen(String(v), maxLen)).join('|');
|
|
1930
|
+
if (parts.negatives.length) negatives = `-(${prefix}${parts.negatives.map((v)=>toMaxLen(String(v), maxLen)).join('|')})`;
|
|
1931
|
+
result = positives && negatives ? `${positives}|${negatives}` : positives || negatives;
|
|
1932
|
+
if (options.wrap) return `(${prefix}${result})`;
|
|
1933
|
+
return result;
|
|
1934
|
+
};
|
|
1935
|
+
const toRange = (a, b, isNumbers, options)=>{
|
|
1936
|
+
if (isNumbers) return toRegexRange(a, b, {
|
|
1937
|
+
wrap: false,
|
|
1938
|
+
...options
|
|
1939
|
+
});
|
|
1940
|
+
let start = String.fromCharCode(a);
|
|
1941
|
+
if (a === b) return start;
|
|
1942
|
+
let stop = String.fromCharCode(b);
|
|
1943
|
+
return `[${start}-${stop}]`;
|
|
1944
|
+
};
|
|
1945
|
+
const toRegex = (start, end, options)=>{
|
|
1946
|
+
if (Array.isArray(start)) {
|
|
1947
|
+
let wrap = true === options.wrap;
|
|
1948
|
+
let prefix = options.capture ? '' : '?:';
|
|
1949
|
+
return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
|
|
1950
|
+
}
|
|
1951
|
+
return toRegexRange(start, end, options);
|
|
1952
|
+
};
|
|
1953
|
+
const rangeError = (...args)=>new RangeError('Invalid range arguments: ' + util.inspect(...args));
|
|
1954
|
+
const invalidRange = (start, end, options)=>{
|
|
1955
|
+
if (true === options.strictRanges) throw rangeError([
|
|
1956
|
+
start,
|
|
1957
|
+
end
|
|
1958
|
+
]);
|
|
1959
|
+
return [];
|
|
1960
|
+
};
|
|
1961
|
+
const invalidStep = (step, options)=>{
|
|
1962
|
+
if (true === options.strictRanges) throw new TypeError(`Expected step "${step}" to be a number`);
|
|
1963
|
+
return [];
|
|
1964
|
+
};
|
|
1965
|
+
const fillNumbers = (start, end, step = 1, options = {})=>{
|
|
1966
|
+
let a = Number(start);
|
|
1967
|
+
let b = Number(end);
|
|
1968
|
+
if (!Number.isInteger(a) || !Number.isInteger(b)) {
|
|
1969
|
+
if (true === options.strictRanges) throw rangeError([
|
|
1970
|
+
start,
|
|
1971
|
+
end
|
|
1972
|
+
]);
|
|
1973
|
+
return [];
|
|
1974
|
+
}
|
|
1975
|
+
if (0 === a) a = 0;
|
|
1976
|
+
if (0 === b) b = 0;
|
|
1977
|
+
let descending = a > b;
|
|
1978
|
+
let startString = String(start);
|
|
1979
|
+
let endString = String(end);
|
|
1980
|
+
let stepString = String(step);
|
|
1981
|
+
step = Math.max(Math.abs(step), 1);
|
|
1982
|
+
let padded = zeros(startString) || zeros(endString) || zeros(stepString);
|
|
1983
|
+
let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
|
|
1984
|
+
let toNumber = false === padded && false === stringify(start, end, options);
|
|
1985
|
+
let format = options.transform || transform(toNumber);
|
|
1986
|
+
if (options.toRegex && 1 === step) return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
|
|
1987
|
+
let parts = {
|
|
1988
|
+
negatives: [],
|
|
1989
|
+
positives: []
|
|
1990
|
+
};
|
|
1991
|
+
let push = (num)=>parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
|
|
1992
|
+
let range = [];
|
|
1993
|
+
let index = 0;
|
|
1994
|
+
while(descending ? a >= b : a <= b){
|
|
1995
|
+
if (true === options.toRegex && step > 1) push(a);
|
|
1996
|
+
else range.push(pad(format(a, index), maxLen, toNumber));
|
|
1997
|
+
a = descending ? a - step : a + step;
|
|
1998
|
+
index++;
|
|
1999
|
+
}
|
|
2000
|
+
if (true === options.toRegex) return step > 1 ? toSequence(parts, options, maxLen) : toRegex(range, null, {
|
|
2001
|
+
wrap: false,
|
|
2002
|
+
...options
|
|
2003
|
+
});
|
|
2004
|
+
return range;
|
|
2005
|
+
};
|
|
2006
|
+
const fillLetters = (start, end, step = 1, options = {})=>{
|
|
2007
|
+
if (!isNumber(start) && start.length > 1 || !isNumber(end) && end.length > 1) return invalidRange(start, end, options);
|
|
2008
|
+
let format = options.transform || ((val)=>String.fromCharCode(val));
|
|
2009
|
+
let a = `${start}`.charCodeAt(0);
|
|
2010
|
+
let b = `${end}`.charCodeAt(0);
|
|
2011
|
+
let descending = a > b;
|
|
2012
|
+
let min = Math.min(a, b);
|
|
2013
|
+
let max = Math.max(a, b);
|
|
2014
|
+
if (options.toRegex && 1 === step) return toRange(min, max, false, options);
|
|
2015
|
+
let range = [];
|
|
2016
|
+
let index = 0;
|
|
2017
|
+
while(descending ? a >= b : a <= b){
|
|
2018
|
+
range.push(format(a, index));
|
|
2019
|
+
a = descending ? a - step : a + step;
|
|
2020
|
+
index++;
|
|
2021
|
+
}
|
|
2022
|
+
if (true === options.toRegex) return toRegex(range, null, {
|
|
2023
|
+
wrap: false,
|
|
2024
|
+
options
|
|
2025
|
+
});
|
|
2026
|
+
return range;
|
|
2027
|
+
};
|
|
2028
|
+
const fill = (start, end, step, options = {})=>{
|
|
2029
|
+
if (null == end && isValidValue(start)) return [
|
|
2030
|
+
start
|
|
2031
|
+
];
|
|
2032
|
+
if (!isValidValue(start) || !isValidValue(end)) return invalidRange(start, end, options);
|
|
2033
|
+
if ('function' == typeof step) return fill(start, end, 1, {
|
|
2034
|
+
transform: step
|
|
2035
|
+
});
|
|
2036
|
+
if (isObject(step)) return fill(start, end, 0, step);
|
|
2037
|
+
let opts = {
|
|
2038
|
+
...options
|
|
2039
|
+
};
|
|
2040
|
+
if (true === opts.capture) opts.wrap = true;
|
|
2041
|
+
step = step || opts.step || 1;
|
|
2042
|
+
if (!isNumber(step)) {
|
|
2043
|
+
if (null != step && !isObject(step)) return invalidStep(step, opts);
|
|
2044
|
+
return fill(start, end, 1, step);
|
|
2045
|
+
}
|
|
2046
|
+
if (isNumber(start) && isNumber(end)) return fillNumbers(start, end, step, opts);
|
|
2047
|
+
return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
|
|
2048
|
+
};
|
|
2049
|
+
module.exports = fill;
|
|
2050
|
+
},
|
|
2051
|
+
"../../node_modules/.pnpm/glob-parent@5.1.2/node_modules/glob-parent/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2052
|
+
var isGlob = __webpack_require__("../../node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js");
|
|
2053
|
+
var pathPosixDirname = __webpack_require__("path?aeb1").posix.dirname;
|
|
2054
|
+
var isWin32 = 'win32' === __webpack_require__("os").platform();
|
|
2055
|
+
var slash = '/';
|
|
2056
|
+
var backslash = /\\/g;
|
|
2057
|
+
var enclosure = /[\{\[].*[\}\]]$/;
|
|
2058
|
+
var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/;
|
|
2059
|
+
var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g;
|
|
2060
|
+
module.exports = function(str, opts) {
|
|
2061
|
+
var options = Object.assign({
|
|
2062
|
+
flipBackslashes: true
|
|
2063
|
+
}, opts);
|
|
2064
|
+
if (options.flipBackslashes && isWin32 && str.indexOf(slash) < 0) str = str.replace(backslash, slash);
|
|
2065
|
+
if (enclosure.test(str)) str += slash;
|
|
2066
|
+
str += 'a';
|
|
2067
|
+
do str = pathPosixDirname(str);
|
|
2068
|
+
while (isGlob(str) || globby.test(str));
|
|
2069
|
+
return str.replace(escaped, '$1');
|
|
2070
|
+
};
|
|
2071
|
+
},
|
|
2072
|
+
"../../node_modules/.pnpm/is-binary-path@2.1.0/node_modules/is-binary-path/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2073
|
+
const path = __webpack_require__("path?aeb1");
|
|
2074
|
+
const binaryExtensions = __webpack_require__("../../node_modules/.pnpm/binary-extensions@2.3.0/node_modules/binary-extensions/index.js");
|
|
2075
|
+
const extensions = new Set(binaryExtensions);
|
|
2076
|
+
module.exports = (filePath)=>extensions.has(path.extname(filePath).slice(1).toLowerCase());
|
|
2077
|
+
},
|
|
2078
|
+
"../../node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js" (module) {
|
|
2079
|
+
/*!
|
|
2080
|
+
* is-extglob <https://github.com/jonschlinkert/is-extglob>
|
|
2081
|
+
*
|
|
2082
|
+
* Copyright (c) 2014-2016, Jon Schlinkert.
|
|
2083
|
+
* Licensed under the MIT License.
|
|
2084
|
+
*/ module.exports = function(str) {
|
|
2085
|
+
if ('string' != typeof str || '' === str) return false;
|
|
2086
|
+
var match;
|
|
2087
|
+
while(match = /(\\).|([@?!+*]\(.*\))/g.exec(str)){
|
|
2088
|
+
if (match[2]) return true;
|
|
2089
|
+
str = str.slice(match.index + match[0].length);
|
|
2090
|
+
}
|
|
2091
|
+
return false;
|
|
2092
|
+
};
|
|
2093
|
+
},
|
|
2094
|
+
"../../node_modules/.pnpm/is-glob@4.0.3/node_modules/is-glob/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2095
|
+
/*!
|
|
2096
|
+
* is-glob <https://github.com/jonschlinkert/is-glob>
|
|
2097
|
+
*
|
|
2098
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
2099
|
+
* Released under the MIT License.
|
|
2100
|
+
*/ var isExtglob = __webpack_require__("../../node_modules/.pnpm/is-extglob@2.1.1/node_modules/is-extglob/index.js");
|
|
2101
|
+
var chars = {
|
|
2102
|
+
'{': '}',
|
|
2103
|
+
'(': ')',
|
|
2104
|
+
'[': ']'
|
|
2105
|
+
};
|
|
2106
|
+
var strictCheck = function(str) {
|
|
2107
|
+
if ('!' === str[0]) return true;
|
|
2108
|
+
var index = 0;
|
|
2109
|
+
var pipeIndex = -2;
|
|
2110
|
+
var closeSquareIndex = -2;
|
|
2111
|
+
var closeCurlyIndex = -2;
|
|
2112
|
+
var closeParenIndex = -2;
|
|
2113
|
+
var backSlashIndex = -2;
|
|
2114
|
+
while(index < str.length){
|
|
2115
|
+
if ('*' === str[index]) return true;
|
|
2116
|
+
if ('?' === str[index + 1] && /[\].+)]/.test(str[index])) return true;
|
|
2117
|
+
if (-1 !== closeSquareIndex && '[' === str[index] && ']' !== str[index + 1]) {
|
|
2118
|
+
if (closeSquareIndex < index) closeSquareIndex = str.indexOf(']', index);
|
|
2119
|
+
if (closeSquareIndex > index) {
|
|
2120
|
+
if (-1 === backSlashIndex || backSlashIndex > closeSquareIndex) return true;
|
|
2121
|
+
backSlashIndex = str.indexOf('\\', index);
|
|
2122
|
+
if (-1 === backSlashIndex || backSlashIndex > closeSquareIndex) return true;
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
if (-1 !== closeCurlyIndex && '{' === str[index] && '}' !== str[index + 1]) {
|
|
2126
|
+
closeCurlyIndex = str.indexOf('}', index);
|
|
2127
|
+
if (closeCurlyIndex > index) {
|
|
2128
|
+
backSlashIndex = str.indexOf('\\', index);
|
|
2129
|
+
if (-1 === backSlashIndex || backSlashIndex > closeCurlyIndex) return true;
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
if (-1 !== closeParenIndex && '(' === str[index] && '?' === str[index + 1] && /[:!=]/.test(str[index + 2]) && ')' !== str[index + 3]) {
|
|
2133
|
+
closeParenIndex = str.indexOf(')', index);
|
|
2134
|
+
if (closeParenIndex > index) {
|
|
2135
|
+
backSlashIndex = str.indexOf('\\', index);
|
|
2136
|
+
if (-1 === backSlashIndex || backSlashIndex > closeParenIndex) return true;
|
|
2137
|
+
}
|
|
2138
|
+
}
|
|
2139
|
+
if (-1 !== pipeIndex && '(' === str[index] && '|' !== str[index + 1]) {
|
|
2140
|
+
if (pipeIndex < index) pipeIndex = str.indexOf('|', index);
|
|
2141
|
+
if (-1 !== pipeIndex && ')' !== str[pipeIndex + 1]) {
|
|
2142
|
+
closeParenIndex = str.indexOf(')', pipeIndex);
|
|
2143
|
+
if (closeParenIndex > pipeIndex) {
|
|
2144
|
+
backSlashIndex = str.indexOf('\\', pipeIndex);
|
|
2145
|
+
if (-1 === backSlashIndex || backSlashIndex > closeParenIndex) return true;
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2149
|
+
if ('\\' === str[index]) {
|
|
2150
|
+
var open = str[index + 1];
|
|
2151
|
+
index += 2;
|
|
2152
|
+
var close = chars[open];
|
|
2153
|
+
if (close) {
|
|
2154
|
+
var n = str.indexOf(close, index);
|
|
2155
|
+
if (-1 !== n) index = n + 1;
|
|
2156
|
+
}
|
|
2157
|
+
if ('!' === str[index]) return true;
|
|
2158
|
+
} else index++;
|
|
2159
|
+
}
|
|
2160
|
+
return false;
|
|
2161
|
+
};
|
|
2162
|
+
var relaxedCheck = function(str) {
|
|
2163
|
+
if ('!' === str[0]) return true;
|
|
2164
|
+
var index = 0;
|
|
2165
|
+
while(index < str.length){
|
|
2166
|
+
if (/[*?{}()[\]]/.test(str[index])) return true;
|
|
2167
|
+
if ('\\' === str[index]) {
|
|
2168
|
+
var open = str[index + 1];
|
|
2169
|
+
index += 2;
|
|
2170
|
+
var close = chars[open];
|
|
2171
|
+
if (close) {
|
|
2172
|
+
var n = str.indexOf(close, index);
|
|
2173
|
+
if (-1 !== n) index = n + 1;
|
|
2174
|
+
}
|
|
2175
|
+
if ('!' === str[index]) return true;
|
|
2176
|
+
} else index++;
|
|
2177
|
+
}
|
|
2178
|
+
return false;
|
|
2179
|
+
};
|
|
2180
|
+
module.exports = function(str, options) {
|
|
2181
|
+
if ('string' != typeof str || '' === str) return false;
|
|
2182
|
+
if (isExtglob(str)) return true;
|
|
2183
|
+
var check = strictCheck;
|
|
2184
|
+
if (options && false === options.strict) check = relaxedCheck;
|
|
2185
|
+
return check(str);
|
|
2186
|
+
};
|
|
2187
|
+
},
|
|
2188
|
+
"../../node_modules/.pnpm/is-number@7.0.0/node_modules/is-number/index.js" (module) {
|
|
2189
|
+
/*!
|
|
2190
|
+
* is-number <https://github.com/jonschlinkert/is-number>
|
|
2191
|
+
*
|
|
2192
|
+
* Copyright (c) 2014-present, Jon Schlinkert.
|
|
2193
|
+
* Released under the MIT License.
|
|
2194
|
+
*/ module.exports = function(num) {
|
|
2195
|
+
if ('number' == typeof num) return num - num === 0;
|
|
2196
|
+
if ('string' == typeof num && '' !== num.trim()) return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
|
|
2197
|
+
return false;
|
|
2198
|
+
};
|
|
2199
|
+
},
|
|
2200
|
+
"../../node_modules/.pnpm/normalize-path@3.0.0/node_modules/normalize-path/index.js" (module) {
|
|
2201
|
+
/*!
|
|
2202
|
+
* normalize-path <https://github.com/jonschlinkert/normalize-path>
|
|
2203
|
+
*
|
|
2204
|
+
* Copyright (c) 2014-2018, Jon Schlinkert.
|
|
2205
|
+
* Released under the MIT License.
|
|
2206
|
+
*/ module.exports = function(path, stripTrailing) {
|
|
2207
|
+
if ('string' != typeof path) throw new TypeError('expected path to be a string');
|
|
2208
|
+
if ('\\' === path || '/' === path) return '/';
|
|
2209
|
+
var len = path.length;
|
|
2210
|
+
if (len <= 1) return path;
|
|
2211
|
+
var prefix = '';
|
|
2212
|
+
if (len > 4 && '\\' === path[3]) {
|
|
2213
|
+
var ch = path[2];
|
|
2214
|
+
if (('?' === ch || '.' === ch) && '\\\\' === path.slice(0, 2)) {
|
|
2215
|
+
path = path.slice(2);
|
|
2216
|
+
prefix = '//';
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
var segs = path.split(/[/\\]+/);
|
|
2220
|
+
if (false !== stripTrailing && '' === segs[segs.length - 1]) segs.pop();
|
|
2221
|
+
return prefix + segs.join('/');
|
|
2222
|
+
};
|
|
2223
|
+
},
|
|
2224
|
+
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2225
|
+
module.exports = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js");
|
|
2226
|
+
},
|
|
2227
|
+
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2228
|
+
const path = __webpack_require__("path?aeb1");
|
|
2229
|
+
const WIN_SLASH = '\\\\/';
|
|
2230
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
2231
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
2232
|
+
const DOT_LITERAL = '\\.';
|
|
2233
|
+
const PLUS_LITERAL = '\\+';
|
|
2234
|
+
const QMARK_LITERAL = '\\?';
|
|
2235
|
+
const SLASH_LITERAL = '\\/';
|
|
2236
|
+
const ONE_CHAR = '(?=.)';
|
|
2237
|
+
const QMARK = '[^/]';
|
|
2238
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
2239
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
2240
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
2241
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
2242
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
2243
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
2244
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
2245
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
2246
|
+
const STAR = `${QMARK}*?`;
|
|
2247
|
+
const POSIX_CHARS = {
|
|
2248
|
+
DOT_LITERAL,
|
|
2249
|
+
PLUS_LITERAL,
|
|
2250
|
+
QMARK_LITERAL,
|
|
2251
|
+
SLASH_LITERAL,
|
|
2252
|
+
ONE_CHAR,
|
|
2253
|
+
QMARK,
|
|
2254
|
+
END_ANCHOR,
|
|
2255
|
+
DOTS_SLASH,
|
|
2256
|
+
NO_DOT,
|
|
2257
|
+
NO_DOTS,
|
|
2258
|
+
NO_DOT_SLASH,
|
|
2259
|
+
NO_DOTS_SLASH,
|
|
2260
|
+
QMARK_NO_DOT,
|
|
2261
|
+
STAR,
|
|
2262
|
+
START_ANCHOR
|
|
2263
|
+
};
|
|
2264
|
+
const WINDOWS_CHARS = {
|
|
2265
|
+
...POSIX_CHARS,
|
|
2266
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
2267
|
+
QMARK: WIN_NO_SLASH,
|
|
2268
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
2269
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
2270
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
2271
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
2272
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
2273
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
2274
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
2275
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
2276
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
2277
|
+
};
|
|
2278
|
+
const POSIX_REGEX_SOURCE = {
|
|
2279
|
+
__proto__: null,
|
|
2280
|
+
alnum: 'a-zA-Z0-9',
|
|
2281
|
+
alpha: 'a-zA-Z',
|
|
2282
|
+
ascii: '\\x00-\\x7F',
|
|
2283
|
+
blank: ' \\t',
|
|
2284
|
+
cntrl: '\\x00-\\x1F\\x7F',
|
|
2285
|
+
digit: '0-9',
|
|
2286
|
+
graph: '\\x21-\\x7E',
|
|
2287
|
+
lower: 'a-z',
|
|
2288
|
+
print: '\\x20-\\x7E ',
|
|
2289
|
+
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
2290
|
+
space: ' \\t\\r\\n\\v\\f',
|
|
2291
|
+
upper: 'A-Z',
|
|
2292
|
+
word: 'A-Za-z0-9_',
|
|
2293
|
+
xdigit: 'A-Fa-f0-9'
|
|
2294
|
+
};
|
|
2295
|
+
module.exports = {
|
|
2296
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
2297
|
+
MAX_LENGTH: 65536,
|
|
2298
|
+
POSIX_REGEX_SOURCE,
|
|
2299
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
2300
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
2301
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
2302
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
2303
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
2304
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
2305
|
+
REPLACEMENTS: {
|
|
2306
|
+
__proto__: null,
|
|
2307
|
+
'***': '*',
|
|
2308
|
+
'**/**': '**',
|
|
2309
|
+
'**/**/**': '**'
|
|
2310
|
+
},
|
|
2311
|
+
CHAR_0: 48,
|
|
2312
|
+
CHAR_9: 57,
|
|
2313
|
+
CHAR_UPPERCASE_A: 65,
|
|
2314
|
+
CHAR_LOWERCASE_A: 97,
|
|
2315
|
+
CHAR_UPPERCASE_Z: 90,
|
|
2316
|
+
CHAR_LOWERCASE_Z: 122,
|
|
2317
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
2318
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
2319
|
+
CHAR_ASTERISK: 42,
|
|
2320
|
+
CHAR_AMPERSAND: 38,
|
|
2321
|
+
CHAR_AT: 64,
|
|
2322
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
2323
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
2324
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
2325
|
+
CHAR_COLON: 58,
|
|
2326
|
+
CHAR_COMMA: 44,
|
|
2327
|
+
CHAR_DOT: 46,
|
|
2328
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
2329
|
+
CHAR_EQUAL: 61,
|
|
2330
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
2331
|
+
CHAR_FORM_FEED: 12,
|
|
2332
|
+
CHAR_FORWARD_SLASH: 47,
|
|
2333
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
2334
|
+
CHAR_HASH: 35,
|
|
2335
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
2336
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
2337
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
2338
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
2339
|
+
CHAR_LINE_FEED: 10,
|
|
2340
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
2341
|
+
CHAR_PERCENT: 37,
|
|
2342
|
+
CHAR_PLUS: 43,
|
|
2343
|
+
CHAR_QUESTION_MARK: 63,
|
|
2344
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
2345
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
2346
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
2347
|
+
CHAR_SEMICOLON: 59,
|
|
2348
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
2349
|
+
CHAR_SPACE: 32,
|
|
2350
|
+
CHAR_TAB: 9,
|
|
2351
|
+
CHAR_UNDERSCORE: 95,
|
|
2352
|
+
CHAR_VERTICAL_LINE: 124,
|
|
2353
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
2354
|
+
SEP: path.sep,
|
|
2355
|
+
extglobChars (chars) {
|
|
2356
|
+
return {
|
|
2357
|
+
'!': {
|
|
2358
|
+
type: 'negate',
|
|
2359
|
+
open: '(?:(?!(?:',
|
|
2360
|
+
close: `))${chars.STAR})`
|
|
2361
|
+
},
|
|
2362
|
+
'?': {
|
|
2363
|
+
type: 'qmark',
|
|
2364
|
+
open: '(?:',
|
|
2365
|
+
close: ')?'
|
|
2366
|
+
},
|
|
2367
|
+
'+': {
|
|
2368
|
+
type: 'plus',
|
|
2369
|
+
open: '(?:',
|
|
2370
|
+
close: ')+'
|
|
2371
|
+
},
|
|
2372
|
+
'*': {
|
|
2373
|
+
type: 'star',
|
|
2374
|
+
open: '(?:',
|
|
2375
|
+
close: ')*'
|
|
2376
|
+
},
|
|
2377
|
+
'@': {
|
|
2378
|
+
type: 'at',
|
|
2379
|
+
open: '(?:',
|
|
2380
|
+
close: ')'
|
|
2381
|
+
}
|
|
2382
|
+
};
|
|
2383
|
+
},
|
|
2384
|
+
globChars (win32) {
|
|
2385
|
+
return true === win32 ? WINDOWS_CHARS : POSIX_CHARS;
|
|
2386
|
+
}
|
|
2387
|
+
};
|
|
2388
|
+
},
|
|
2389
|
+
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
2390
|
+
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
|
|
2391
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
|
|
2392
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
2393
|
+
const expandRange = (args, options)=>{
|
|
2394
|
+
if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
|
|
2395
|
+
args.sort();
|
|
2396
|
+
const value = `[${args.join('-')}]`;
|
|
2397
|
+
try {
|
|
2398
|
+
new RegExp(value);
|
|
2399
|
+
} catch (ex) {
|
|
2400
|
+
return args.map((v)=>utils.escapeRegex(v)).join('..');
|
|
2401
|
+
}
|
|
2402
|
+
return value;
|
|
2403
|
+
};
|
|
2404
|
+
const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
2405
|
+
const splitTopLevel = (input)=>{
|
|
2406
|
+
const parts = [];
|
|
2407
|
+
let bracket = 0;
|
|
2408
|
+
let paren = 0;
|
|
2409
|
+
let quote = 0;
|
|
2410
|
+
let value = '';
|
|
2411
|
+
let escaped = false;
|
|
2412
|
+
for (const ch of input){
|
|
2413
|
+
if (true === escaped) {
|
|
2414
|
+
value += ch;
|
|
2415
|
+
escaped = false;
|
|
2416
|
+
continue;
|
|
2417
|
+
}
|
|
2418
|
+
if ('\\' === ch) {
|
|
2419
|
+
value += ch;
|
|
2420
|
+
escaped = true;
|
|
2421
|
+
continue;
|
|
2422
|
+
}
|
|
2423
|
+
if ('"' === ch) {
|
|
2424
|
+
quote = 1 === quote ? 0 : 1;
|
|
2425
|
+
value += ch;
|
|
2426
|
+
continue;
|
|
2427
|
+
}
|
|
2428
|
+
if (0 === quote) {
|
|
2429
|
+
if ('[' === ch) bracket++;
|
|
2430
|
+
else if (']' === ch && bracket > 0) bracket--;
|
|
2431
|
+
else if (0 === bracket) {
|
|
2432
|
+
if ('(' === ch) paren++;
|
|
2433
|
+
else if (')' === ch && paren > 0) paren--;
|
|
2434
|
+
else if ('|' === ch && 0 === paren) {
|
|
2435
|
+
parts.push(value);
|
|
2436
|
+
value = '';
|
|
2437
|
+
continue;
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
}
|
|
2441
|
+
value += ch;
|
|
2442
|
+
}
|
|
2443
|
+
parts.push(value);
|
|
2444
|
+
return parts;
|
|
2445
|
+
};
|
|
2446
|
+
const isPlainBranch = (branch)=>{
|
|
2447
|
+
let escaped = false;
|
|
2448
|
+
for (const ch of branch){
|
|
2449
|
+
if (true === escaped) {
|
|
2450
|
+
escaped = false;
|
|
2451
|
+
continue;
|
|
2452
|
+
}
|
|
2453
|
+
if ('\\' === ch) {
|
|
2454
|
+
escaped = true;
|
|
2455
|
+
continue;
|
|
2456
|
+
}
|
|
2457
|
+
if (/[?*+@!()[\]{}]/.test(ch)) return false;
|
|
2458
|
+
}
|
|
2459
|
+
return true;
|
|
2460
|
+
};
|
|
2461
|
+
const normalizeSimpleBranch = (branch)=>{
|
|
2462
|
+
let value = branch.trim();
|
|
2463
|
+
let changed = true;
|
|
2464
|
+
while(true === changed){
|
|
2465
|
+
changed = false;
|
|
2466
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
2467
|
+
value = value.slice(2, -1);
|
|
2468
|
+
changed = true;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
if (!isPlainBranch(value)) return;
|
|
2472
|
+
return value.replace(/\\(.)/g, '$1');
|
|
2473
|
+
};
|
|
2474
|
+
const hasRepeatedCharPrefixOverlap = (branches)=>{
|
|
2475
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
2476
|
+
for(let i = 0; i < values.length; i++)for(let j = i + 1; j < values.length; j++){
|
|
2477
|
+
const a = values[i];
|
|
2478
|
+
const b = values[j];
|
|
2479
|
+
const char = a[0];
|
|
2480
|
+
if (char && a === char.repeat(a.length) && b === char.repeat(b.length)) {
|
|
2481
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
return false;
|
|
2485
|
+
};
|
|
2486
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true)=>{
|
|
2487
|
+
if ('+' !== pattern[0] && '*' !== pattern[0] || '(' !== pattern[1]) return;
|
|
2488
|
+
let bracket = 0;
|
|
2489
|
+
let paren = 0;
|
|
2490
|
+
let quote = 0;
|
|
2491
|
+
let escaped = false;
|
|
2492
|
+
for(let i = 1; i < pattern.length; i++){
|
|
2493
|
+
const ch = pattern[i];
|
|
2494
|
+
if (true === escaped) {
|
|
2495
|
+
escaped = false;
|
|
2496
|
+
continue;
|
|
2497
|
+
}
|
|
2498
|
+
if ('\\' === ch) {
|
|
2499
|
+
escaped = true;
|
|
2500
|
+
continue;
|
|
2501
|
+
}
|
|
2502
|
+
if ('"' === ch) {
|
|
2503
|
+
quote = 1 === quote ? 0 : 1;
|
|
2504
|
+
continue;
|
|
2505
|
+
}
|
|
2506
|
+
if (1 !== quote) {
|
|
2507
|
+
if ('[' === ch) {
|
|
2508
|
+
bracket++;
|
|
2509
|
+
continue;
|
|
2510
|
+
}
|
|
2511
|
+
if (']' === ch && bracket > 0) {
|
|
2512
|
+
bracket--;
|
|
2513
|
+
continue;
|
|
2514
|
+
}
|
|
2515
|
+
if (!(bracket > 0)) {
|
|
2516
|
+
if ('(' === ch) {
|
|
2517
|
+
paren++;
|
|
2518
|
+
continue;
|
|
2519
|
+
}
|
|
2520
|
+
if (')' === ch) {
|
|
2521
|
+
paren--;
|
|
2522
|
+
if (0 === paren) {
|
|
2523
|
+
if (true === requireEnd && i !== pattern.length - 1) return;
|
|
2524
|
+
return {
|
|
2525
|
+
type: pattern[0],
|
|
2526
|
+
body: pattern.slice(2, i),
|
|
2527
|
+
end: i
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
};
|
|
2535
|
+
const getStarExtglobSequenceOutput = (pattern)=>{
|
|
2536
|
+
let index = 0;
|
|
2537
|
+
const chars = [];
|
|
2538
|
+
while(index < pattern.length){
|
|
2539
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
2540
|
+
if (!match || '*' !== match.type) return;
|
|
2541
|
+
const branches = splitTopLevel(match.body).map((branch)=>branch.trim());
|
|
2542
|
+
if (1 !== branches.length) return;
|
|
2543
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
2544
|
+
if (!branch || 1 !== branch.length) return;
|
|
2545
|
+
chars.push(branch);
|
|
2546
|
+
index += match.end + 1;
|
|
2547
|
+
}
|
|
2548
|
+
if (chars.length < 1) return;
|
|
2549
|
+
const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
|
|
2550
|
+
return `${source}*`;
|
|
2551
|
+
};
|
|
2552
|
+
const repeatedExtglobRecursion = (pattern)=>{
|
|
2553
|
+
let depth = 0;
|
|
2554
|
+
let value = pattern.trim();
|
|
2555
|
+
let match = parseRepeatedExtglob(value);
|
|
2556
|
+
while(match){
|
|
2557
|
+
depth++;
|
|
2558
|
+
value = match.body.trim();
|
|
2559
|
+
match = parseRepeatedExtglob(value);
|
|
2560
|
+
}
|
|
2561
|
+
return depth;
|
|
2562
|
+
};
|
|
2563
|
+
const analyzeRepeatedExtglob = (body, options)=>{
|
|
2564
|
+
if (false === options.maxExtglobRecursion) return {
|
|
2565
|
+
risky: false
|
|
2566
|
+
};
|
|
2567
|
+
const max = 'number' == typeof options.maxExtglobRecursion ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
2568
|
+
const branches = splitTopLevel(body).map((branch)=>branch.trim());
|
|
2569
|
+
if (branches.length > 1) {
|
|
2570
|
+
if (branches.some((branch)=>'' === branch) || branches.some((branch)=>/^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return {
|
|
2571
|
+
risky: true
|
|
2572
|
+
};
|
|
2573
|
+
}
|
|
2574
|
+
for (const branch of branches){
|
|
2575
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
2576
|
+
if (safeOutput) return {
|
|
2577
|
+
risky: true,
|
|
2578
|
+
safeOutput
|
|
2579
|
+
};
|
|
2580
|
+
if (repeatedExtglobRecursion(branch) > max) return {
|
|
2581
|
+
risky: true
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
return {
|
|
2585
|
+
risky: false
|
|
2586
|
+
};
|
|
2587
|
+
};
|
|
2588
|
+
const parse = (input, options)=>{
|
|
2589
|
+
if ('string' != typeof input) throw new TypeError('Expected a string');
|
|
2590
|
+
input = REPLACEMENTS[input] || input;
|
|
2591
|
+
const opts = {
|
|
2592
|
+
...options
|
|
2593
|
+
};
|
|
2594
|
+
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2595
|
+
let len = input.length;
|
|
2596
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2597
|
+
const bos = {
|
|
2598
|
+
type: 'bos',
|
|
2599
|
+
value: '',
|
|
2600
|
+
output: opts.prepend || ''
|
|
2601
|
+
};
|
|
2602
|
+
const tokens = [
|
|
2603
|
+
bos
|
|
2604
|
+
];
|
|
2605
|
+
const capture = opts.capture ? '' : '?:';
|
|
2606
|
+
const win32 = utils.isWindows(options);
|
|
2607
|
+
const PLATFORM_CHARS = constants.globChars(win32);
|
|
2608
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
2609
|
+
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;
|
|
2610
|
+
const globstar = (opts)=>`(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
2611
|
+
const nodot = opts.dot ? '' : NO_DOT;
|
|
2612
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
2613
|
+
let star = true === opts.bash ? globstar(opts) : STAR;
|
|
2614
|
+
if (opts.capture) star = `(${star})`;
|
|
2615
|
+
if ('boolean' == typeof opts.noext) opts.noextglob = opts.noext;
|
|
2616
|
+
const state = {
|
|
2617
|
+
input,
|
|
2618
|
+
index: -1,
|
|
2619
|
+
start: 0,
|
|
2620
|
+
dot: true === opts.dot,
|
|
2621
|
+
consumed: '',
|
|
2622
|
+
output: '',
|
|
2623
|
+
prefix: '',
|
|
2624
|
+
backtrack: false,
|
|
2625
|
+
negated: false,
|
|
2626
|
+
brackets: 0,
|
|
2627
|
+
braces: 0,
|
|
2628
|
+
parens: 0,
|
|
2629
|
+
quotes: 0,
|
|
2630
|
+
globstar: false,
|
|
2631
|
+
tokens
|
|
2632
|
+
};
|
|
2633
|
+
input = utils.removePrefix(input, state);
|
|
2634
|
+
len = input.length;
|
|
2635
|
+
const extglobs = [];
|
|
2636
|
+
const braces = [];
|
|
2637
|
+
const stack = [];
|
|
2638
|
+
let prev = bos;
|
|
2639
|
+
let value;
|
|
2640
|
+
const eos = ()=>state.index === len - 1;
|
|
2641
|
+
const peek = state.peek = (n = 1)=>input[state.index + n];
|
|
2642
|
+
const advance = state.advance = ()=>input[++state.index] || '';
|
|
2643
|
+
const remaining = ()=>input.slice(state.index + 1);
|
|
2644
|
+
const consume = (value = '', num = 0)=>{
|
|
2645
|
+
state.consumed += value;
|
|
2646
|
+
state.index += num;
|
|
2647
|
+
};
|
|
2648
|
+
const append = (token)=>{
|
|
2649
|
+
state.output += null != token.output ? token.output : token.value;
|
|
2650
|
+
consume(token.value);
|
|
2651
|
+
};
|
|
2652
|
+
const negate = ()=>{
|
|
2653
|
+
let count = 1;
|
|
2654
|
+
while('!' === peek() && ('(' !== peek(2) || '?' === peek(3))){
|
|
2655
|
+
advance();
|
|
2656
|
+
state.start++;
|
|
2657
|
+
count++;
|
|
2658
|
+
}
|
|
2659
|
+
if (count % 2 === 0) return false;
|
|
2660
|
+
state.negated = true;
|
|
2661
|
+
state.start++;
|
|
2662
|
+
return true;
|
|
2663
|
+
};
|
|
2664
|
+
const increment = (type)=>{
|
|
2665
|
+
state[type]++;
|
|
2666
|
+
stack.push(type);
|
|
2667
|
+
};
|
|
2668
|
+
const decrement = (type)=>{
|
|
2669
|
+
state[type]--;
|
|
2670
|
+
stack.pop();
|
|
2671
|
+
};
|
|
2672
|
+
const push = (tok)=>{
|
|
2673
|
+
if ('globstar' === prev.type) {
|
|
2674
|
+
const isBrace = state.braces > 0 && ('comma' === tok.type || 'brace' === tok.type);
|
|
2675
|
+
const isExtglob = true === tok.extglob || extglobs.length && ('pipe' === tok.type || 'paren' === tok.type);
|
|
2676
|
+
if ('slash' !== tok.type && 'paren' !== tok.type && !isBrace && !isExtglob) {
|
|
2677
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
2678
|
+
prev.type = 'star';
|
|
2679
|
+
prev.value = '*';
|
|
2680
|
+
prev.output = star;
|
|
2681
|
+
state.output += prev.output;
|
|
2682
|
+
}
|
|
2683
|
+
}
|
|
2684
|
+
if (extglobs.length && 'paren' !== tok.type) extglobs[extglobs.length - 1].inner += tok.value;
|
|
2685
|
+
if (tok.value || tok.output) append(tok);
|
|
2686
|
+
if (prev && 'text' === prev.type && 'text' === tok.type) {
|
|
2687
|
+
prev.value += tok.value;
|
|
2688
|
+
prev.output = (prev.output || '') + tok.value;
|
|
2689
|
+
return;
|
|
2690
|
+
}
|
|
2691
|
+
tok.prev = prev;
|
|
2692
|
+
tokens.push(tok);
|
|
2693
|
+
prev = tok;
|
|
2694
|
+
};
|
|
2695
|
+
const extglobOpen = (type, value)=>{
|
|
2696
|
+
const token = {
|
|
2697
|
+
...EXTGLOB_CHARS[value],
|
|
2698
|
+
conditions: 1,
|
|
2699
|
+
inner: ''
|
|
2700
|
+
};
|
|
2701
|
+
token.prev = prev;
|
|
2702
|
+
token.parens = state.parens;
|
|
2703
|
+
token.output = state.output;
|
|
2704
|
+
token.startIndex = state.index;
|
|
2705
|
+
token.tokensIndex = tokens.length;
|
|
2706
|
+
const output = (opts.capture ? '(' : '') + token.open;
|
|
2707
|
+
increment('parens');
|
|
2708
|
+
push({
|
|
2709
|
+
type,
|
|
2710
|
+
value,
|
|
2711
|
+
output: state.output ? '' : ONE_CHAR
|
|
2712
|
+
});
|
|
2713
|
+
push({
|
|
2714
|
+
type: 'paren',
|
|
2715
|
+
extglob: true,
|
|
2716
|
+
value: advance(),
|
|
2717
|
+
output
|
|
2718
|
+
});
|
|
2719
|
+
extglobs.push(token);
|
|
2720
|
+
};
|
|
2721
|
+
const extglobClose = (token)=>{
|
|
2722
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
2723
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
2724
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
2725
|
+
if (('plus' === token.type || 'star' === token.type) && analysis.risky) {
|
|
2726
|
+
const safeOutput = analysis.safeOutput ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
2727
|
+
const open = tokens[token.tokensIndex];
|
|
2728
|
+
open.type = 'text';
|
|
2729
|
+
open.value = literal;
|
|
2730
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
2731
|
+
for(let i = token.tokensIndex + 1; i < tokens.length; i++){
|
|
2732
|
+
tokens[i].value = '';
|
|
2733
|
+
tokens[i].output = '';
|
|
2734
|
+
delete tokens[i].suffix;
|
|
2735
|
+
}
|
|
2736
|
+
state.output = token.output + open.output;
|
|
2737
|
+
state.backtrack = true;
|
|
2738
|
+
push({
|
|
2739
|
+
type: 'paren',
|
|
2740
|
+
extglob: true,
|
|
2741
|
+
value,
|
|
2742
|
+
output: ''
|
|
2743
|
+
});
|
|
2744
|
+
decrement('parens');
|
|
2745
|
+
return;
|
|
2746
|
+
}
|
|
2747
|
+
let output = token.close + (opts.capture ? ')' : '');
|
|
2748
|
+
let rest;
|
|
2749
|
+
if ('negate' === token.type) {
|
|
2750
|
+
let extglobStar = star;
|
|
2751
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) extglobStar = globstar(opts);
|
|
2752
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
2753
|
+
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
2754
|
+
const expression = parse(rest, {
|
|
2755
|
+
...options,
|
|
2756
|
+
fastpaths: false
|
|
2757
|
+
}).output;
|
|
2758
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
2759
|
+
}
|
|
2760
|
+
if ('bos' === token.prev.type) state.negatedExtglob = true;
|
|
2761
|
+
}
|
|
2762
|
+
push({
|
|
2763
|
+
type: 'paren',
|
|
2764
|
+
extglob: true,
|
|
2765
|
+
value,
|
|
2766
|
+
output
|
|
2767
|
+
});
|
|
2768
|
+
decrement('parens');
|
|
2769
|
+
};
|
|
2770
|
+
if (false !== opts.fastpaths && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
2771
|
+
let backslashes = false;
|
|
2772
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index)=>{
|
|
2773
|
+
if ('\\' === first) {
|
|
2774
|
+
backslashes = true;
|
|
2775
|
+
return m;
|
|
2776
|
+
}
|
|
2777
|
+
if ('?' === first) {
|
|
2778
|
+
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
2779
|
+
if (0 === index) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
2780
|
+
return QMARK.repeat(chars.length);
|
|
2781
|
+
}
|
|
2782
|
+
if ('.' === first) return DOT_LITERAL.repeat(chars.length);
|
|
2783
|
+
if ('*' === first) {
|
|
2784
|
+
if (esc) return esc + first + (rest ? star : '');
|
|
2785
|
+
return star;
|
|
2786
|
+
}
|
|
2787
|
+
return esc ? m : `\\${m}`;
|
|
2788
|
+
});
|
|
2789
|
+
if (true === backslashes) output = true === opts.unescape ? output.replace(/\\/g, '') : output.replace(/\\+/g, (m)=>m.length % 2 === 0 ? '\\\\' : m ? '\\' : '');
|
|
2790
|
+
if (output === input && true === opts.contains) {
|
|
2791
|
+
state.output = input;
|
|
2792
|
+
return state;
|
|
2793
|
+
}
|
|
2794
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
2795
|
+
return state;
|
|
2796
|
+
}
|
|
2797
|
+
while(!eos()){
|
|
2798
|
+
value = advance();
|
|
2799
|
+
if ('\u0000' === value) continue;
|
|
2800
|
+
if ('\\' === value) {
|
|
2801
|
+
const next = peek();
|
|
2802
|
+
if ('/' === next && true !== opts.bash) continue;
|
|
2803
|
+
if ('.' === next || ';' === next) continue;
|
|
2804
|
+
if (!next) {
|
|
2805
|
+
value += '\\';
|
|
2806
|
+
push({
|
|
2807
|
+
type: 'text',
|
|
2808
|
+
value
|
|
2809
|
+
});
|
|
2810
|
+
continue;
|
|
2811
|
+
}
|
|
2812
|
+
const match = /^\\+/.exec(remaining());
|
|
2813
|
+
let slashes = 0;
|
|
2814
|
+
if (match && match[0].length > 2) {
|
|
2815
|
+
slashes = match[0].length;
|
|
2816
|
+
state.index += slashes;
|
|
2817
|
+
if (slashes % 2 !== 0) value += '\\';
|
|
2818
|
+
}
|
|
2819
|
+
if (true === opts.unescape) value = advance();
|
|
2820
|
+
else value += advance();
|
|
2821
|
+
if (0 === state.brackets) {
|
|
2822
|
+
push({
|
|
2823
|
+
type: 'text',
|
|
2824
|
+
value
|
|
2825
|
+
});
|
|
2826
|
+
continue;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
if (state.brackets > 0 && (']' !== value || '[' === prev.value || '[^' === prev.value)) {
|
|
2830
|
+
if (false !== opts.posix && ':' === value) {
|
|
2831
|
+
const inner = prev.value.slice(1);
|
|
2832
|
+
if (inner.includes('[')) {
|
|
2833
|
+
prev.posix = true;
|
|
2834
|
+
if (inner.includes(':')) {
|
|
2835
|
+
const idx = prev.value.lastIndexOf('[');
|
|
2836
|
+
const pre = prev.value.slice(0, idx);
|
|
2837
|
+
const rest = prev.value.slice(idx + 2);
|
|
2838
|
+
const posix = POSIX_REGEX_SOURCE[rest];
|
|
2839
|
+
if (posix) {
|
|
2840
|
+
prev.value = pre + posix;
|
|
2841
|
+
state.backtrack = true;
|
|
2842
|
+
advance();
|
|
2843
|
+
if (!bos.output && 1 === tokens.indexOf(prev)) bos.output = ONE_CHAR;
|
|
2844
|
+
continue;
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
}
|
|
2848
|
+
}
|
|
2849
|
+
if ('[' === value && ':' !== peek() || '-' === value && ']' === peek()) value = `\\${value}`;
|
|
2850
|
+
if (']' === value && ('[' === prev.value || '[^' === prev.value)) value = `\\${value}`;
|
|
2851
|
+
if (true === opts.posix && '!' === value && '[' === prev.value) value = '^';
|
|
2852
|
+
prev.value += value;
|
|
2853
|
+
append({
|
|
2854
|
+
value
|
|
2855
|
+
});
|
|
2856
|
+
continue;
|
|
2857
|
+
}
|
|
2858
|
+
if (1 === state.quotes && '"' !== value) {
|
|
2859
|
+
value = utils.escapeRegex(value);
|
|
2860
|
+
prev.value += value;
|
|
2861
|
+
append({
|
|
2862
|
+
value
|
|
2863
|
+
});
|
|
2864
|
+
continue;
|
|
2865
|
+
}
|
|
2866
|
+
if ('"' === value) {
|
|
2867
|
+
state.quotes = 1 === state.quotes ? 0 : 1;
|
|
2868
|
+
if (true === opts.keepQuotes) push({
|
|
2869
|
+
type: 'text',
|
|
2870
|
+
value
|
|
2871
|
+
});
|
|
2872
|
+
continue;
|
|
2873
|
+
}
|
|
2874
|
+
if ('(' === value) {
|
|
2875
|
+
increment('parens');
|
|
2876
|
+
push({
|
|
2877
|
+
type: 'paren',
|
|
2878
|
+
value
|
|
2879
|
+
});
|
|
2880
|
+
continue;
|
|
2881
|
+
}
|
|
2882
|
+
if (')' === value) {
|
|
2883
|
+
if (0 === state.parens && true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '('));
|
|
2884
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
2885
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
2886
|
+
extglobClose(extglobs.pop());
|
|
2887
|
+
continue;
|
|
2888
|
+
}
|
|
2889
|
+
push({
|
|
2890
|
+
type: 'paren',
|
|
2891
|
+
value,
|
|
2892
|
+
output: state.parens ? ')' : '\\)'
|
|
2893
|
+
});
|
|
2894
|
+
decrement('parens');
|
|
2895
|
+
continue;
|
|
2896
|
+
}
|
|
2897
|
+
if ('[' === value) {
|
|
2898
|
+
if (true !== opts.nobracket && remaining().includes(']')) increment('brackets');
|
|
2899
|
+
else {
|
|
2900
|
+
if (true !== opts.nobracket && true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
2901
|
+
value = `\\${value}`;
|
|
2902
|
+
}
|
|
2903
|
+
push({
|
|
2904
|
+
type: 'bracket',
|
|
2905
|
+
value
|
|
2906
|
+
});
|
|
2907
|
+
continue;
|
|
2908
|
+
}
|
|
2909
|
+
if (']' === value) {
|
|
2910
|
+
if (true === opts.nobracket || prev && 'bracket' === prev.type && 1 === prev.value.length) {
|
|
2911
|
+
push({
|
|
2912
|
+
type: 'text',
|
|
2913
|
+
value,
|
|
2914
|
+
output: `\\${value}`
|
|
2915
|
+
});
|
|
2916
|
+
continue;
|
|
2917
|
+
}
|
|
2918
|
+
if (0 === state.brackets) {
|
|
2919
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('opening', '['));
|
|
2920
|
+
push({
|
|
2921
|
+
type: 'text',
|
|
2922
|
+
value,
|
|
2923
|
+
output: `\\${value}`
|
|
2924
|
+
});
|
|
2925
|
+
continue;
|
|
2926
|
+
}
|
|
2927
|
+
decrement('brackets');
|
|
2928
|
+
const prevValue = prev.value.slice(1);
|
|
2929
|
+
if (true !== prev.posix && '^' === prevValue[0] && !prevValue.includes('/')) value = `/${value}`;
|
|
2930
|
+
prev.value += value;
|
|
2931
|
+
append({
|
|
2932
|
+
value
|
|
2933
|
+
});
|
|
2934
|
+
if (false === opts.literalBrackets || utils.hasRegexChars(prevValue)) continue;
|
|
2935
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
2936
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
2937
|
+
if (true === opts.literalBrackets) {
|
|
2938
|
+
state.output += escaped;
|
|
2939
|
+
prev.value = escaped;
|
|
2940
|
+
continue;
|
|
2941
|
+
}
|
|
2942
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
2943
|
+
state.output += prev.value;
|
|
2944
|
+
continue;
|
|
2945
|
+
}
|
|
2946
|
+
if ('{' === value && true !== opts.nobrace) {
|
|
2947
|
+
increment('braces');
|
|
2948
|
+
const open = {
|
|
2949
|
+
type: 'brace',
|
|
2950
|
+
value,
|
|
2951
|
+
output: '(',
|
|
2952
|
+
outputIndex: state.output.length,
|
|
2953
|
+
tokensIndex: state.tokens.length
|
|
2954
|
+
};
|
|
2955
|
+
braces.push(open);
|
|
2956
|
+
push(open);
|
|
2957
|
+
continue;
|
|
2958
|
+
}
|
|
2959
|
+
if ('}' === value) {
|
|
2960
|
+
const brace = braces[braces.length - 1];
|
|
2961
|
+
if (true === opts.nobrace || !brace) {
|
|
2962
|
+
push({
|
|
2963
|
+
type: 'text',
|
|
2964
|
+
value,
|
|
2965
|
+
output: value
|
|
2966
|
+
});
|
|
2967
|
+
continue;
|
|
2968
|
+
}
|
|
2969
|
+
let output = ')';
|
|
2970
|
+
if (true === brace.dots) {
|
|
2971
|
+
const arr = tokens.slice();
|
|
2972
|
+
const range = [];
|
|
2973
|
+
for(let i = arr.length - 1; i >= 0; i--){
|
|
2974
|
+
tokens.pop();
|
|
2975
|
+
if ('brace' === arr[i].type) break;
|
|
2976
|
+
if ('dots' !== arr[i].type) range.unshift(arr[i].value);
|
|
2977
|
+
}
|
|
2978
|
+
output = expandRange(range, opts);
|
|
2979
|
+
state.backtrack = true;
|
|
2980
|
+
}
|
|
2981
|
+
if (true !== brace.comma && true !== brace.dots) {
|
|
2982
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
2983
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
2984
|
+
brace.value = brace.output = '\\{';
|
|
2985
|
+
value = output = '\\}';
|
|
2986
|
+
state.output = out;
|
|
2987
|
+
for (const t of toks)state.output += t.output || t.value;
|
|
2988
|
+
}
|
|
2989
|
+
push({
|
|
2990
|
+
type: 'brace',
|
|
2991
|
+
value,
|
|
2992
|
+
output
|
|
2993
|
+
});
|
|
2994
|
+
decrement('braces');
|
|
2995
|
+
braces.pop();
|
|
2996
|
+
continue;
|
|
2997
|
+
}
|
|
2998
|
+
if ('|' === value) {
|
|
2999
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
3000
|
+
push({
|
|
3001
|
+
type: 'text',
|
|
3002
|
+
value
|
|
3003
|
+
});
|
|
3004
|
+
continue;
|
|
3005
|
+
}
|
|
3006
|
+
if (',' === value) {
|
|
3007
|
+
let output = value;
|
|
3008
|
+
const brace = braces[braces.length - 1];
|
|
3009
|
+
if (brace && 'braces' === stack[stack.length - 1]) {
|
|
3010
|
+
brace.comma = true;
|
|
3011
|
+
output = '|';
|
|
3012
|
+
}
|
|
3013
|
+
push({
|
|
3014
|
+
type: 'comma',
|
|
3015
|
+
value,
|
|
3016
|
+
output
|
|
3017
|
+
});
|
|
3018
|
+
continue;
|
|
3019
|
+
}
|
|
3020
|
+
if ('/' === value) {
|
|
3021
|
+
if ('dot' === prev.type && state.index === state.start + 1) {
|
|
3022
|
+
state.start = state.index + 1;
|
|
3023
|
+
state.consumed = '';
|
|
3024
|
+
state.output = '';
|
|
3025
|
+
tokens.pop();
|
|
3026
|
+
prev = bos;
|
|
3027
|
+
continue;
|
|
3028
|
+
}
|
|
3029
|
+
push({
|
|
3030
|
+
type: 'slash',
|
|
3031
|
+
value,
|
|
3032
|
+
output: SLASH_LITERAL
|
|
3033
|
+
});
|
|
3034
|
+
continue;
|
|
3035
|
+
}
|
|
3036
|
+
if ('.' === value) {
|
|
3037
|
+
if (state.braces > 0 && 'dot' === prev.type) {
|
|
3038
|
+
if ('.' === prev.value) prev.output = DOT_LITERAL;
|
|
3039
|
+
const brace = braces[braces.length - 1];
|
|
3040
|
+
prev.type = 'dots';
|
|
3041
|
+
prev.output += value;
|
|
3042
|
+
prev.value += value;
|
|
3043
|
+
brace.dots = true;
|
|
3044
|
+
continue;
|
|
3045
|
+
}
|
|
3046
|
+
if (state.braces + state.parens === 0 && 'bos' !== prev.type && 'slash' !== prev.type) {
|
|
3047
|
+
push({
|
|
3048
|
+
type: 'text',
|
|
3049
|
+
value,
|
|
3050
|
+
output: DOT_LITERAL
|
|
3051
|
+
});
|
|
3052
|
+
continue;
|
|
3053
|
+
}
|
|
3054
|
+
push({
|
|
3055
|
+
type: 'dot',
|
|
3056
|
+
value,
|
|
3057
|
+
output: DOT_LITERAL
|
|
3058
|
+
});
|
|
3059
|
+
continue;
|
|
3060
|
+
}
|
|
3061
|
+
if ('?' === value) {
|
|
3062
|
+
const isGroup = prev && '(' === prev.value;
|
|
3063
|
+
if (!isGroup && true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
3064
|
+
extglobOpen('qmark', value);
|
|
3065
|
+
continue;
|
|
3066
|
+
}
|
|
3067
|
+
if (prev && 'paren' === prev.type) {
|
|
3068
|
+
const next = peek();
|
|
3069
|
+
let output = value;
|
|
3070
|
+
if ('<' === next && !utils.supportsLookbehinds()) throw new Error('Node.js v10 or higher is required for regex lookbehinds');
|
|
3071
|
+
if ('(' === prev.value && !/[!=<:]/.test(next) || '<' === next && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
3072
|
+
push({
|
|
3073
|
+
type: 'text',
|
|
3074
|
+
value,
|
|
3075
|
+
output
|
|
3076
|
+
});
|
|
3077
|
+
continue;
|
|
3078
|
+
}
|
|
3079
|
+
if (true !== opts.dot && ('slash' === prev.type || 'bos' === prev.type)) {
|
|
3080
|
+
push({
|
|
3081
|
+
type: 'qmark',
|
|
3082
|
+
value,
|
|
3083
|
+
output: QMARK_NO_DOT
|
|
3084
|
+
});
|
|
3085
|
+
continue;
|
|
3086
|
+
}
|
|
3087
|
+
push({
|
|
3088
|
+
type: 'qmark',
|
|
3089
|
+
value,
|
|
3090
|
+
output: QMARK
|
|
3091
|
+
});
|
|
3092
|
+
continue;
|
|
3093
|
+
}
|
|
3094
|
+
if ('!' === value) {
|
|
3095
|
+
if (true !== opts.noextglob && '(' === peek()) {
|
|
3096
|
+
if ('?' !== peek(2) || !/[!=<:]/.test(peek(3))) {
|
|
3097
|
+
extglobOpen('negate', value);
|
|
3098
|
+
continue;
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
if (true !== opts.nonegate && 0 === state.index) {
|
|
3102
|
+
negate();
|
|
3103
|
+
continue;
|
|
3104
|
+
}
|
|
3105
|
+
}
|
|
3106
|
+
if ('+' === value) {
|
|
3107
|
+
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
3108
|
+
extglobOpen('plus', value);
|
|
3109
|
+
continue;
|
|
3110
|
+
}
|
|
3111
|
+
if (prev && '(' === prev.value || false === opts.regex) {
|
|
3112
|
+
push({
|
|
3113
|
+
type: 'plus',
|
|
3114
|
+
value,
|
|
3115
|
+
output: PLUS_LITERAL
|
|
3116
|
+
});
|
|
3117
|
+
continue;
|
|
3118
|
+
}
|
|
3119
|
+
if (prev && ('bracket' === prev.type || 'paren' === prev.type || 'brace' === prev.type) || state.parens > 0) {
|
|
3120
|
+
push({
|
|
3121
|
+
type: 'plus',
|
|
3122
|
+
value
|
|
3123
|
+
});
|
|
3124
|
+
continue;
|
|
3125
|
+
}
|
|
3126
|
+
push({
|
|
3127
|
+
type: 'plus',
|
|
3128
|
+
value: PLUS_LITERAL
|
|
3129
|
+
});
|
|
3130
|
+
continue;
|
|
3131
|
+
}
|
|
3132
|
+
if ('@' === value) {
|
|
3133
|
+
if (true !== opts.noextglob && '(' === peek() && '?' !== peek(2)) {
|
|
3134
|
+
push({
|
|
3135
|
+
type: 'at',
|
|
3136
|
+
extglob: true,
|
|
3137
|
+
value,
|
|
3138
|
+
output: ''
|
|
3139
|
+
});
|
|
3140
|
+
continue;
|
|
3141
|
+
}
|
|
3142
|
+
push({
|
|
3143
|
+
type: 'text',
|
|
3144
|
+
value
|
|
3145
|
+
});
|
|
3146
|
+
continue;
|
|
3147
|
+
}
|
|
3148
|
+
if ('*' !== value) {
|
|
3149
|
+
if ('$' === value || '^' === value) value = `\\${value}`;
|
|
3150
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
3151
|
+
if (match) {
|
|
3152
|
+
value += match[0];
|
|
3153
|
+
state.index += match[0].length;
|
|
3154
|
+
}
|
|
3155
|
+
push({
|
|
3156
|
+
type: 'text',
|
|
3157
|
+
value
|
|
3158
|
+
});
|
|
3159
|
+
continue;
|
|
3160
|
+
}
|
|
3161
|
+
if (prev && ('globstar' === prev.type || true === prev.star)) {
|
|
3162
|
+
prev.type = 'star';
|
|
3163
|
+
prev.star = true;
|
|
3164
|
+
prev.value += value;
|
|
3165
|
+
prev.output = star;
|
|
3166
|
+
state.backtrack = true;
|
|
3167
|
+
state.globstar = true;
|
|
3168
|
+
consume(value);
|
|
3169
|
+
continue;
|
|
3170
|
+
}
|
|
3171
|
+
let rest = remaining();
|
|
3172
|
+
if (true !== opts.noextglob && /^\([^?]/.test(rest)) {
|
|
3173
|
+
extglobOpen('star', value);
|
|
3174
|
+
continue;
|
|
3175
|
+
}
|
|
3176
|
+
if ('star' === prev.type) {
|
|
3177
|
+
if (true === opts.noglobstar) {
|
|
3178
|
+
consume(value);
|
|
3179
|
+
continue;
|
|
3180
|
+
}
|
|
3181
|
+
const prior = prev.prev;
|
|
3182
|
+
const before = prior.prev;
|
|
3183
|
+
const isStart = 'slash' === prior.type || 'bos' === prior.type;
|
|
3184
|
+
const afterStar = before && ('star' === before.type || 'globstar' === before.type);
|
|
3185
|
+
if (true === opts.bash && (!isStart || rest[0] && '/' !== rest[0])) {
|
|
3186
|
+
push({
|
|
3187
|
+
type: 'star',
|
|
3188
|
+
value,
|
|
3189
|
+
output: ''
|
|
3190
|
+
});
|
|
3191
|
+
continue;
|
|
3192
|
+
}
|
|
3193
|
+
const isBrace = state.braces > 0 && ('comma' === prior.type || 'brace' === prior.type);
|
|
3194
|
+
const isExtglob = extglobs.length && ('pipe' === prior.type || 'paren' === prior.type);
|
|
3195
|
+
if (!isStart && 'paren' !== prior.type && !isBrace && !isExtglob) {
|
|
3196
|
+
push({
|
|
3197
|
+
type: 'star',
|
|
3198
|
+
value,
|
|
3199
|
+
output: ''
|
|
3200
|
+
});
|
|
3201
|
+
continue;
|
|
3202
|
+
}
|
|
3203
|
+
while('/**' === rest.slice(0, 3)){
|
|
3204
|
+
const after = input[state.index + 4];
|
|
3205
|
+
if (after && '/' !== after) break;
|
|
3206
|
+
rest = rest.slice(3);
|
|
3207
|
+
consume('/**', 3);
|
|
3208
|
+
}
|
|
3209
|
+
if ('bos' === prior.type && eos()) {
|
|
3210
|
+
prev.type = 'globstar';
|
|
3211
|
+
prev.value += value;
|
|
3212
|
+
prev.output = globstar(opts);
|
|
3213
|
+
state.output = prev.output;
|
|
3214
|
+
state.globstar = true;
|
|
3215
|
+
consume(value);
|
|
3216
|
+
continue;
|
|
3217
|
+
}
|
|
3218
|
+
if ('slash' === prior.type && 'bos' !== prior.prev.type && !afterStar && eos()) {
|
|
3219
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
3220
|
+
prior.output = `(?:${prior.output}`;
|
|
3221
|
+
prev.type = 'globstar';
|
|
3222
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
3223
|
+
prev.value += value;
|
|
3224
|
+
state.globstar = true;
|
|
3225
|
+
state.output += prior.output + prev.output;
|
|
3226
|
+
consume(value);
|
|
3227
|
+
continue;
|
|
3228
|
+
}
|
|
3229
|
+
if ('slash' === prior.type && 'bos' !== prior.prev.type && '/' === rest[0]) {
|
|
3230
|
+
const end = void 0 !== rest[1] ? '|$' : '';
|
|
3231
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
3232
|
+
prior.output = `(?:${prior.output}`;
|
|
3233
|
+
prev.type = 'globstar';
|
|
3234
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
3235
|
+
prev.value += value;
|
|
3236
|
+
state.output += prior.output + prev.output;
|
|
3237
|
+
state.globstar = true;
|
|
3238
|
+
consume(value + advance());
|
|
3239
|
+
push({
|
|
3240
|
+
type: 'slash',
|
|
3241
|
+
value: '/',
|
|
3242
|
+
output: ''
|
|
3243
|
+
});
|
|
3244
|
+
continue;
|
|
3245
|
+
}
|
|
3246
|
+
if ('bos' === prior.type && '/' === rest[0]) {
|
|
3247
|
+
prev.type = 'globstar';
|
|
3248
|
+
prev.value += value;
|
|
3249
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
3250
|
+
state.output = prev.output;
|
|
3251
|
+
state.globstar = true;
|
|
3252
|
+
consume(value + advance());
|
|
3253
|
+
push({
|
|
3254
|
+
type: 'slash',
|
|
3255
|
+
value: '/',
|
|
3256
|
+
output: ''
|
|
3257
|
+
});
|
|
3258
|
+
continue;
|
|
3259
|
+
}
|
|
3260
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
3261
|
+
prev.type = 'globstar';
|
|
3262
|
+
prev.output = globstar(opts);
|
|
3263
|
+
prev.value += value;
|
|
3264
|
+
state.output += prev.output;
|
|
3265
|
+
state.globstar = true;
|
|
3266
|
+
consume(value);
|
|
3267
|
+
continue;
|
|
3268
|
+
}
|
|
3269
|
+
const token = {
|
|
3270
|
+
type: 'star',
|
|
3271
|
+
value,
|
|
3272
|
+
output: star
|
|
3273
|
+
};
|
|
3274
|
+
if (true === opts.bash) {
|
|
3275
|
+
token.output = '.*?';
|
|
3276
|
+
if ('bos' === prev.type || 'slash' === prev.type) token.output = nodot + token.output;
|
|
3277
|
+
push(token);
|
|
3278
|
+
continue;
|
|
3279
|
+
}
|
|
3280
|
+
if (prev && ('bracket' === prev.type || 'paren' === prev.type) && true === opts.regex) {
|
|
3281
|
+
token.output = value;
|
|
3282
|
+
push(token);
|
|
3283
|
+
continue;
|
|
3284
|
+
}
|
|
3285
|
+
if (state.index === state.start || 'slash' === prev.type || 'dot' === prev.type) {
|
|
3286
|
+
if ('dot' === prev.type) {
|
|
3287
|
+
state.output += NO_DOT_SLASH;
|
|
3288
|
+
prev.output += NO_DOT_SLASH;
|
|
3289
|
+
} else if (true === opts.dot) {
|
|
3290
|
+
state.output += NO_DOTS_SLASH;
|
|
3291
|
+
prev.output += NO_DOTS_SLASH;
|
|
3292
|
+
} else {
|
|
3293
|
+
state.output += nodot;
|
|
3294
|
+
prev.output += nodot;
|
|
3295
|
+
}
|
|
3296
|
+
if ('*' !== peek()) {
|
|
3297
|
+
state.output += ONE_CHAR;
|
|
3298
|
+
prev.output += ONE_CHAR;
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
push(token);
|
|
3302
|
+
}
|
|
3303
|
+
while(state.brackets > 0){
|
|
3304
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ']'));
|
|
3305
|
+
state.output = utils.escapeLast(state.output, '[');
|
|
3306
|
+
decrement('brackets');
|
|
3307
|
+
}
|
|
3308
|
+
while(state.parens > 0){
|
|
3309
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', ')'));
|
|
3310
|
+
state.output = utils.escapeLast(state.output, '(');
|
|
3311
|
+
decrement('parens');
|
|
3312
|
+
}
|
|
3313
|
+
while(state.braces > 0){
|
|
3314
|
+
if (true === opts.strictBrackets) throw new SyntaxError(syntaxError('closing', '}'));
|
|
3315
|
+
state.output = utils.escapeLast(state.output, '{');
|
|
3316
|
+
decrement('braces');
|
|
3317
|
+
}
|
|
3318
|
+
if (true !== opts.strictSlashes && ('star' === prev.type || 'bracket' === prev.type)) push({
|
|
3319
|
+
type: 'maybe_slash',
|
|
3320
|
+
value: '',
|
|
3321
|
+
output: `${SLASH_LITERAL}?`
|
|
3322
|
+
});
|
|
3323
|
+
if (true === state.backtrack) {
|
|
3324
|
+
state.output = '';
|
|
3325
|
+
for (const token of state.tokens){
|
|
3326
|
+
state.output += null != token.output ? token.output : token.value;
|
|
3327
|
+
if (token.suffix) state.output += token.suffix;
|
|
3328
|
+
}
|
|
3329
|
+
}
|
|
3330
|
+
return state;
|
|
3331
|
+
};
|
|
3332
|
+
parse.fastpaths = (input, options)=>{
|
|
3333
|
+
const opts = {
|
|
3334
|
+
...options
|
|
3335
|
+
};
|
|
3336
|
+
const max = 'number' == typeof opts.maxLength ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
3337
|
+
const len = input.length;
|
|
3338
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
3339
|
+
input = REPLACEMENTS[input] || input;
|
|
3340
|
+
const win32 = utils.isWindows(options);
|
|
3341
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(win32);
|
|
3342
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
3343
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
3344
|
+
const capture = opts.capture ? '' : '?:';
|
|
3345
|
+
const state = {
|
|
3346
|
+
negated: false,
|
|
3347
|
+
prefix: ''
|
|
3348
|
+
};
|
|
3349
|
+
let star = true === opts.bash ? '.*?' : STAR;
|
|
3350
|
+
if (opts.capture) star = `(${star})`;
|
|
3351
|
+
const globstar = (opts)=>{
|
|
3352
|
+
if (true === opts.noglobstar) return star;
|
|
3353
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
3354
|
+
};
|
|
3355
|
+
const create = (str)=>{
|
|
3356
|
+
switch(str){
|
|
3357
|
+
case '*':
|
|
3358
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
3359
|
+
case '.*':
|
|
3360
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3361
|
+
case '*.*':
|
|
3362
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3363
|
+
case '*/*':
|
|
3364
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
3365
|
+
case '**':
|
|
3366
|
+
return nodot + globstar(opts);
|
|
3367
|
+
case '**/*':
|
|
3368
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
3369
|
+
case '**/*.*':
|
|
3370
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3371
|
+
case '**/.*':
|
|
3372
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
3373
|
+
default:
|
|
3374
|
+
{
|
|
3375
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
3376
|
+
if (!match) return;
|
|
3377
|
+
const source = create(match[1]);
|
|
3378
|
+
if (!source) return;
|
|
3379
|
+
return source + DOT_LITERAL + match[2];
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
};
|
|
3383
|
+
const output = utils.removePrefix(input, state);
|
|
3384
|
+
let source = create(output);
|
|
3385
|
+
if (source && true !== opts.strictSlashes) source += `${SLASH_LITERAL}?`;
|
|
3386
|
+
return source;
|
|
3387
|
+
};
|
|
3388
|
+
module.exports = parse;
|
|
3389
|
+
},
|
|
3390
|
+
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
3391
|
+
const path = __webpack_require__("path?aeb1");
|
|
3392
|
+
const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/scan.js");
|
|
3393
|
+
const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/parse.js");
|
|
3394
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
|
|
3395
|
+
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
|
|
3396
|
+
const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
|
|
3397
|
+
const picomatch = (glob, options, returnState = false)=>{
|
|
3398
|
+
if (Array.isArray(glob)) {
|
|
3399
|
+
const fns = glob.map((input)=>picomatch(input, options, returnState));
|
|
3400
|
+
const arrayMatcher = (str)=>{
|
|
3401
|
+
for (const isMatch of fns){
|
|
3402
|
+
const state = isMatch(str);
|
|
3403
|
+
if (state) return state;
|
|
3404
|
+
}
|
|
3405
|
+
return false;
|
|
3406
|
+
};
|
|
3407
|
+
return arrayMatcher;
|
|
3408
|
+
}
|
|
3409
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
3410
|
+
if ('' === glob || 'string' != typeof glob && !isState) throw new TypeError('Expected pattern to be a non-empty string');
|
|
3411
|
+
const opts = options || {};
|
|
3412
|
+
const posix = utils.isWindows(options);
|
|
3413
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
3414
|
+
const state = regex.state;
|
|
3415
|
+
delete regex.state;
|
|
3416
|
+
let isIgnored = ()=>false;
|
|
3417
|
+
if (opts.ignore) {
|
|
3418
|
+
const ignoreOpts = {
|
|
3419
|
+
...options,
|
|
3420
|
+
ignore: null,
|
|
3421
|
+
onMatch: null,
|
|
3422
|
+
onResult: null
|
|
3423
|
+
};
|
|
3424
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
3425
|
+
}
|
|
3426
|
+
const matcher = (input, returnObject = false)=>{
|
|
3427
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
3428
|
+
glob,
|
|
3429
|
+
posix
|
|
3430
|
+
});
|
|
3431
|
+
const result = {
|
|
3432
|
+
glob,
|
|
3433
|
+
state,
|
|
3434
|
+
regex,
|
|
3435
|
+
posix,
|
|
3436
|
+
input,
|
|
3437
|
+
output,
|
|
3438
|
+
match,
|
|
3439
|
+
isMatch
|
|
3440
|
+
};
|
|
3441
|
+
if ('function' == typeof opts.onResult) opts.onResult(result);
|
|
3442
|
+
if (false === isMatch) {
|
|
3443
|
+
result.isMatch = false;
|
|
3444
|
+
return returnObject ? result : false;
|
|
3445
|
+
}
|
|
3446
|
+
if (isIgnored(input)) {
|
|
3447
|
+
if ('function' == typeof opts.onIgnore) opts.onIgnore(result);
|
|
3448
|
+
result.isMatch = false;
|
|
3449
|
+
return returnObject ? result : false;
|
|
3450
|
+
}
|
|
3451
|
+
if ('function' == typeof opts.onMatch) opts.onMatch(result);
|
|
3452
|
+
return returnObject ? result : true;
|
|
3453
|
+
};
|
|
3454
|
+
if (returnState) matcher.state = state;
|
|
3455
|
+
return matcher;
|
|
3456
|
+
};
|
|
3457
|
+
picomatch.test = (input, regex, options, { glob, posix } = {})=>{
|
|
3458
|
+
if ('string' != typeof input) throw new TypeError('Expected input to be a string');
|
|
3459
|
+
if ('' === input) return {
|
|
3460
|
+
isMatch: false,
|
|
3461
|
+
output: ''
|
|
3462
|
+
};
|
|
3463
|
+
const opts = options || {};
|
|
3464
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
3465
|
+
let match = input === glob;
|
|
3466
|
+
let output = match && format ? format(input) : input;
|
|
3467
|
+
if (false === match) {
|
|
3468
|
+
output = format ? format(input) : input;
|
|
3469
|
+
match = output === glob;
|
|
3470
|
+
}
|
|
3471
|
+
if (false === match || true === opts.capture) match = true === opts.matchBase || true === opts.basename ? picomatch.matchBase(input, regex, options, posix) : regex.exec(output);
|
|
3472
|
+
return {
|
|
3473
|
+
isMatch: Boolean(match),
|
|
3474
|
+
match,
|
|
3475
|
+
output
|
|
3476
|
+
};
|
|
3477
|
+
};
|
|
3478
|
+
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options))=>{
|
|
3479
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
3480
|
+
return regex.test(path.basename(input));
|
|
3481
|
+
};
|
|
3482
|
+
picomatch.isMatch = (str, patterns, options)=>picomatch(patterns, options)(str);
|
|
3483
|
+
picomatch.parse = (pattern, options)=>{
|
|
3484
|
+
if (Array.isArray(pattern)) return pattern.map((p)=>picomatch.parse(p, options));
|
|
3485
|
+
return parse(pattern, {
|
|
3486
|
+
...options,
|
|
3487
|
+
fastpaths: false
|
|
3488
|
+
});
|
|
3489
|
+
};
|
|
3490
|
+
picomatch.scan = (input, options)=>scan(input, options);
|
|
3491
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false)=>{
|
|
3492
|
+
if (true === returnOutput) return state.output;
|
|
3493
|
+
const opts = options || {};
|
|
3494
|
+
const prepend = opts.contains ? '' : '^';
|
|
3495
|
+
const append = opts.contains ? '' : '$';
|
|
3496
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
3497
|
+
if (state && true === state.negated) source = `^(?!${source}).*$`;
|
|
3498
|
+
const regex = picomatch.toRegex(source, options);
|
|
3499
|
+
if (true === returnState) regex.state = state;
|
|
3500
|
+
return regex;
|
|
3501
|
+
};
|
|
3502
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false)=>{
|
|
3503
|
+
if (!input || 'string' != typeof input) throw new TypeError('Expected a non-empty string');
|
|
3504
|
+
let parsed = {
|
|
3505
|
+
negated: false,
|
|
3506
|
+
fastpaths: true
|
|
3507
|
+
};
|
|
3508
|
+
if (false !== options.fastpaths && ('.' === input[0] || '*' === input[0])) parsed.output = parse.fastpaths(input, options);
|
|
3509
|
+
if (!parsed.output) parsed = parse(input, options);
|
|
3510
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
3511
|
+
};
|
|
3512
|
+
picomatch.toRegex = (source, options)=>{
|
|
3513
|
+
try {
|
|
3514
|
+
const opts = options || {};
|
|
3515
|
+
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
3516
|
+
} catch (err) {
|
|
3517
|
+
if (options && true === options.debug) throw err;
|
|
3518
|
+
return /$^/;
|
|
3519
|
+
}
|
|
3520
|
+
};
|
|
3521
|
+
picomatch.constants = constants;
|
|
3522
|
+
module.exports = picomatch;
|
|
3523
|
+
},
|
|
3524
|
+
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
3525
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js");
|
|
3526
|
+
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@2.3.2/node_modules/picomatch/lib/constants.js");
|
|
3527
|
+
const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
3528
|
+
const depth = (token)=>{
|
|
3529
|
+
if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
|
|
3530
|
+
};
|
|
3531
|
+
const scan = (input, options)=>{
|
|
3532
|
+
const opts = options || {};
|
|
3533
|
+
const length = input.length - 1;
|
|
3534
|
+
const scanToEnd = true === opts.parts || true === opts.scanToEnd;
|
|
3535
|
+
const slashes = [];
|
|
3536
|
+
const tokens = [];
|
|
3537
|
+
const parts = [];
|
|
3538
|
+
let str = input;
|
|
3539
|
+
let index = -1;
|
|
3540
|
+
let start = 0;
|
|
3541
|
+
let lastIndex = 0;
|
|
3542
|
+
let isBrace = false;
|
|
3543
|
+
let isBracket = false;
|
|
3544
|
+
let isGlob = false;
|
|
3545
|
+
let isExtglob = false;
|
|
3546
|
+
let isGlobstar = false;
|
|
3547
|
+
let braceEscaped = false;
|
|
3548
|
+
let backslashes = false;
|
|
3549
|
+
let negated = false;
|
|
3550
|
+
let negatedExtglob = false;
|
|
3551
|
+
let finished = false;
|
|
3552
|
+
let braces = 0;
|
|
3553
|
+
let prev;
|
|
3554
|
+
let code;
|
|
3555
|
+
let token = {
|
|
3556
|
+
value: '',
|
|
3557
|
+
depth: 0,
|
|
3558
|
+
isGlob: false
|
|
3559
|
+
};
|
|
3560
|
+
const eos = ()=>index >= length;
|
|
3561
|
+
const peek = ()=>str.charCodeAt(index + 1);
|
|
3562
|
+
const advance = ()=>{
|
|
3563
|
+
prev = code;
|
|
3564
|
+
return str.charCodeAt(++index);
|
|
3565
|
+
};
|
|
3566
|
+
while(index < length){
|
|
3567
|
+
code = advance();
|
|
3568
|
+
let next;
|
|
3569
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
3570
|
+
backslashes = token.backslashes = true;
|
|
3571
|
+
code = advance();
|
|
3572
|
+
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
3573
|
+
continue;
|
|
3574
|
+
}
|
|
3575
|
+
if (true === braceEscaped || code === CHAR_LEFT_CURLY_BRACE) {
|
|
3576
|
+
braces++;
|
|
3577
|
+
while(true !== eos() && (code = advance())){
|
|
3578
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
3579
|
+
backslashes = token.backslashes = true;
|
|
3580
|
+
advance();
|
|
3581
|
+
continue;
|
|
3582
|
+
}
|
|
3583
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
3584
|
+
braces++;
|
|
3585
|
+
continue;
|
|
3586
|
+
}
|
|
3587
|
+
if (true !== braceEscaped && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
3588
|
+
isBrace = token.isBrace = true;
|
|
3589
|
+
isGlob = token.isGlob = true;
|
|
3590
|
+
finished = true;
|
|
3591
|
+
if (true === scanToEnd) continue;
|
|
3592
|
+
break;
|
|
3593
|
+
}
|
|
3594
|
+
if (true !== braceEscaped && code === CHAR_COMMA) {
|
|
3595
|
+
isBrace = token.isBrace = true;
|
|
3596
|
+
isGlob = token.isGlob = true;
|
|
3597
|
+
finished = true;
|
|
3598
|
+
if (true === scanToEnd) continue;
|
|
3599
|
+
break;
|
|
3600
|
+
}
|
|
3601
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
3602
|
+
braces--;
|
|
3603
|
+
if (0 === braces) {
|
|
3604
|
+
braceEscaped = false;
|
|
3605
|
+
isBrace = token.isBrace = true;
|
|
3606
|
+
finished = true;
|
|
3607
|
+
break;
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
if (true === scanToEnd) continue;
|
|
3612
|
+
break;
|
|
3613
|
+
}
|
|
3614
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
3615
|
+
slashes.push(index);
|
|
3616
|
+
tokens.push(token);
|
|
3617
|
+
token = {
|
|
3618
|
+
value: '',
|
|
3619
|
+
depth: 0,
|
|
3620
|
+
isGlob: false
|
|
3621
|
+
};
|
|
3622
|
+
if (true === finished) continue;
|
|
3623
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
3624
|
+
start += 2;
|
|
3625
|
+
continue;
|
|
3626
|
+
}
|
|
3627
|
+
lastIndex = index + 1;
|
|
3628
|
+
continue;
|
|
3629
|
+
}
|
|
3630
|
+
if (true !== opts.noext) {
|
|
3631
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
3632
|
+
if (true === isExtglobChar && peek() === CHAR_LEFT_PARENTHESES) {
|
|
3633
|
+
isGlob = token.isGlob = true;
|
|
3634
|
+
isExtglob = token.isExtglob = true;
|
|
3635
|
+
finished = true;
|
|
3636
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
3637
|
+
if (true === scanToEnd) {
|
|
3638
|
+
while(true !== eos() && (code = advance())){
|
|
3639
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
3640
|
+
backslashes = token.backslashes = true;
|
|
3641
|
+
code = advance();
|
|
3642
|
+
continue;
|
|
3643
|
+
}
|
|
3644
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
3645
|
+
isGlob = token.isGlob = true;
|
|
3646
|
+
finished = true;
|
|
3647
|
+
break;
|
|
3648
|
+
}
|
|
3649
|
+
}
|
|
3650
|
+
continue;
|
|
3651
|
+
}
|
|
3652
|
+
break;
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
if (code === CHAR_ASTERISK) {
|
|
3656
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
3657
|
+
isGlob = token.isGlob = true;
|
|
3658
|
+
finished = true;
|
|
3659
|
+
if (true === scanToEnd) continue;
|
|
3660
|
+
break;
|
|
3661
|
+
}
|
|
3662
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
3663
|
+
isGlob = token.isGlob = true;
|
|
3664
|
+
finished = true;
|
|
3665
|
+
if (true === scanToEnd) continue;
|
|
3666
|
+
break;
|
|
3667
|
+
}
|
|
3668
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
3669
|
+
while(true !== eos() && (next = advance())){
|
|
3670
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
3671
|
+
backslashes = token.backslashes = true;
|
|
3672
|
+
advance();
|
|
3673
|
+
continue;
|
|
3674
|
+
}
|
|
3675
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
3676
|
+
isBracket = token.isBracket = true;
|
|
3677
|
+
isGlob = token.isGlob = true;
|
|
3678
|
+
finished = true;
|
|
3679
|
+
break;
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
if (true === scanToEnd) continue;
|
|
3683
|
+
break;
|
|
3684
|
+
}
|
|
3685
|
+
if (true !== opts.nonegate && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
3686
|
+
negated = token.negated = true;
|
|
3687
|
+
start++;
|
|
3688
|
+
continue;
|
|
3689
|
+
}
|
|
3690
|
+
if (true !== opts.noparen && code === CHAR_LEFT_PARENTHESES) {
|
|
3691
|
+
isGlob = token.isGlob = true;
|
|
3692
|
+
if (true === scanToEnd) {
|
|
3693
|
+
while(true !== eos() && (code = advance())){
|
|
3694
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
3695
|
+
backslashes = token.backslashes = true;
|
|
3696
|
+
code = advance();
|
|
3697
|
+
continue;
|
|
3698
|
+
}
|
|
3699
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
3700
|
+
finished = true;
|
|
3701
|
+
break;
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
continue;
|
|
3705
|
+
}
|
|
3706
|
+
break;
|
|
3707
|
+
}
|
|
3708
|
+
if (true === isGlob) {
|
|
3709
|
+
finished = true;
|
|
3710
|
+
if (true === scanToEnd) continue;
|
|
3711
|
+
break;
|
|
3712
|
+
}
|
|
3713
|
+
}
|
|
3714
|
+
if (true === opts.noext) {
|
|
3715
|
+
isExtglob = false;
|
|
3716
|
+
isGlob = false;
|
|
3717
|
+
}
|
|
3718
|
+
let base = str;
|
|
3719
|
+
let prefix = '';
|
|
3720
|
+
let glob = '';
|
|
3721
|
+
if (start > 0) {
|
|
3722
|
+
prefix = str.slice(0, start);
|
|
3723
|
+
str = str.slice(start);
|
|
3724
|
+
lastIndex -= start;
|
|
3725
|
+
}
|
|
3726
|
+
if (base && true === isGlob && lastIndex > 0) {
|
|
3727
|
+
base = str.slice(0, lastIndex);
|
|
3728
|
+
glob = str.slice(lastIndex);
|
|
3729
|
+
} else if (true === isGlob) {
|
|
3730
|
+
base = '';
|
|
3731
|
+
glob = str;
|
|
3732
|
+
} else base = str;
|
|
3733
|
+
if (base && '' !== base && '/' !== base && base !== str) {
|
|
3734
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
3735
|
+
}
|
|
3736
|
+
if (true === opts.unescape) {
|
|
3737
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
3738
|
+
if (base && true === backslashes) base = utils.removeBackslashes(base);
|
|
3739
|
+
}
|
|
3740
|
+
const state = {
|
|
3741
|
+
prefix,
|
|
3742
|
+
input,
|
|
3743
|
+
start,
|
|
3744
|
+
base,
|
|
3745
|
+
glob,
|
|
3746
|
+
isBrace,
|
|
3747
|
+
isBracket,
|
|
3748
|
+
isGlob,
|
|
3749
|
+
isExtglob,
|
|
3750
|
+
isGlobstar,
|
|
3751
|
+
negated,
|
|
3752
|
+
negatedExtglob
|
|
3753
|
+
};
|
|
3754
|
+
if (true === opts.tokens) {
|
|
3755
|
+
state.maxDepth = 0;
|
|
3756
|
+
if (!isPathSeparator(code)) tokens.push(token);
|
|
3757
|
+
state.tokens = tokens;
|
|
3758
|
+
}
|
|
3759
|
+
if (true === opts.parts || true === opts.tokens) {
|
|
3760
|
+
let prevIndex;
|
|
3761
|
+
for(let idx = 0; idx < slashes.length; idx++){
|
|
3762
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
3763
|
+
const i = slashes[idx];
|
|
3764
|
+
const value = input.slice(n, i);
|
|
3765
|
+
if (opts.tokens) {
|
|
3766
|
+
if (0 === idx && 0 !== start) {
|
|
3767
|
+
tokens[idx].isPrefix = true;
|
|
3768
|
+
tokens[idx].value = prefix;
|
|
3769
|
+
} else tokens[idx].value = value;
|
|
3770
|
+
depth(tokens[idx]);
|
|
3771
|
+
state.maxDepth += tokens[idx].depth;
|
|
3772
|
+
}
|
|
3773
|
+
if (0 !== idx || '' !== value) parts.push(value);
|
|
3774
|
+
prevIndex = i;
|
|
3775
|
+
}
|
|
3776
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
3777
|
+
const value = input.slice(prevIndex + 1);
|
|
3778
|
+
parts.push(value);
|
|
3779
|
+
if (opts.tokens) {
|
|
3780
|
+
tokens[tokens.length - 1].value = value;
|
|
3781
|
+
depth(tokens[tokens.length - 1]);
|
|
3782
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
state.slashes = slashes;
|
|
3786
|
+
state.parts = parts;
|
|
3787
|
+
}
|
|
3788
|
+
return state;
|
|
3789
|
+
};
|
|
3790
|
+
module.exports = scan;
|
|
3791
|
+
},
|
|
3792
|
+
"../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
3793
|
+
const path = __webpack_require__("path?aeb1");
|
|
3794
|
+
const win32 = 'win32' === process.platform;
|
|
3795
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/lib/constants.js");
|
|
3796
|
+
exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
3797
|
+
exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
|
|
3798
|
+
exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
|
|
3799
|
+
exports.escapeRegex = (str)=>str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
3800
|
+
exports.toPosixSlashes = (str)=>str.replace(REGEX_BACKSLASH, '/');
|
|
3801
|
+
exports.removeBackslashes = (str)=>str.replace(REGEX_REMOVE_BACKSLASH, (match)=>'\\' === match ? '' : match);
|
|
3802
|
+
exports.supportsLookbehinds = ()=>{
|
|
3803
|
+
const segs = process.version.slice(1).split('.').map(Number);
|
|
3804
|
+
if (3 === segs.length && segs[0] >= 9 || 8 === segs[0] && segs[1] >= 10) return true;
|
|
3805
|
+
return false;
|
|
3806
|
+
};
|
|
3807
|
+
exports.isWindows = (options)=>{
|
|
3808
|
+
if (options && 'boolean' == typeof options.windows) return options.windows;
|
|
3809
|
+
return true === win32 || '\\' === path.sep;
|
|
3810
|
+
};
|
|
3811
|
+
exports.escapeLast = (input, char, lastIdx)=>{
|
|
3812
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
3813
|
+
if (-1 === idx) return input;
|
|
3814
|
+
if ('\\' === input[idx - 1]) return exports.escapeLast(input, char, idx - 1);
|
|
3815
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
3816
|
+
};
|
|
3817
|
+
exports.removePrefix = (input, state = {})=>{
|
|
3818
|
+
let output = input;
|
|
3819
|
+
if (output.startsWith('./')) {
|
|
3820
|
+
output = output.slice(2);
|
|
3821
|
+
state.prefix = './';
|
|
3822
|
+
}
|
|
3823
|
+
return output;
|
|
3824
|
+
};
|
|
3825
|
+
exports.wrapOutput = (input, state = {}, options = {})=>{
|
|
3826
|
+
const prepend = options.contains ? '' : '^';
|
|
3827
|
+
const append = options.contains ? '' : '$';
|
|
3828
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
3829
|
+
if (true === state.negated) output = `(?:^(?!${output}).*$)`;
|
|
3830
|
+
return output;
|
|
3831
|
+
};
|
|
3832
|
+
},
|
|
3833
|
+
"../../node_modules/.pnpm/readdirp@3.6.0/node_modules/readdirp/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
3834
|
+
const fs = __webpack_require__("fs?8b28");
|
|
3835
|
+
const { Readable } = __webpack_require__("stream");
|
|
3836
|
+
const sysPath = __webpack_require__("path?aeb1");
|
|
3837
|
+
const { promisify } = __webpack_require__("util");
|
|
3838
|
+
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@2.3.2/node_modules/picomatch/index.js");
|
|
3839
|
+
const readdir = promisify(fs.readdir);
|
|
3840
|
+
const stat = promisify(fs.stat);
|
|
3841
|
+
const lstat = promisify(fs.lstat);
|
|
3842
|
+
const realpath = promisify(fs.realpath);
|
|
3843
|
+
const BANG = '!';
|
|
3844
|
+
const RECURSIVE_ERROR_CODE = 'READDIRP_RECURSIVE_ERROR';
|
|
3845
|
+
const NORMAL_FLOW_ERRORS = new Set([
|
|
3846
|
+
'ENOENT',
|
|
3847
|
+
'EPERM',
|
|
3848
|
+
'EACCES',
|
|
3849
|
+
'ELOOP',
|
|
3850
|
+
RECURSIVE_ERROR_CODE
|
|
3851
|
+
]);
|
|
3852
|
+
const FILE_TYPE = 'files';
|
|
3853
|
+
const DIR_TYPE = 'directories';
|
|
3854
|
+
const FILE_DIR_TYPE = 'files_directories';
|
|
3855
|
+
const EVERYTHING_TYPE = 'all';
|
|
3856
|
+
const ALL_TYPES = [
|
|
3857
|
+
FILE_TYPE,
|
|
3858
|
+
DIR_TYPE,
|
|
3859
|
+
FILE_DIR_TYPE,
|
|
3860
|
+
EVERYTHING_TYPE
|
|
3861
|
+
];
|
|
3862
|
+
const isNormalFlowError = (error)=>NORMAL_FLOW_ERRORS.has(error.code);
|
|
3863
|
+
const [maj, min] = process.versions.node.split('.').slice(0, 2).map((n)=>Number.parseInt(n, 10));
|
|
3864
|
+
const wantBigintFsStats = 'win32' === process.platform && (maj > 10 || 10 === maj && min >= 5);
|
|
3865
|
+
const normalizeFilter = (filter)=>{
|
|
3866
|
+
if (void 0 === filter) return;
|
|
3867
|
+
if ('function' == typeof filter) return filter;
|
|
3868
|
+
if ('string' == typeof filter) {
|
|
3869
|
+
const glob = picomatch(filter.trim());
|
|
3870
|
+
return (entry)=>glob(entry.basename);
|
|
3871
|
+
}
|
|
3872
|
+
if (Array.isArray(filter)) {
|
|
3873
|
+
const positive = [];
|
|
3874
|
+
const negative = [];
|
|
3875
|
+
for (const item of filter){
|
|
3876
|
+
const trimmed = item.trim();
|
|
3877
|
+
if (trimmed.charAt(0) === BANG) negative.push(picomatch(trimmed.slice(1)));
|
|
3878
|
+
else positive.push(picomatch(trimmed));
|
|
3879
|
+
}
|
|
3880
|
+
if (negative.length > 0) {
|
|
3881
|
+
if (positive.length > 0) return (entry)=>positive.some((f)=>f(entry.basename)) && !negative.some((f)=>f(entry.basename));
|
|
3882
|
+
return (entry)=>!negative.some((f)=>f(entry.basename));
|
|
3883
|
+
}
|
|
3884
|
+
return (entry)=>positive.some((f)=>f(entry.basename));
|
|
3885
|
+
}
|
|
3886
|
+
};
|
|
3887
|
+
class ReaddirpStream extends Readable {
|
|
3888
|
+
static get defaultOptions() {
|
|
3889
|
+
return {
|
|
3890
|
+
root: '.',
|
|
3891
|
+
fileFilter: (path)=>true,
|
|
3892
|
+
directoryFilter: (path)=>true,
|
|
3893
|
+
type: FILE_TYPE,
|
|
3894
|
+
lstat: false,
|
|
3895
|
+
depth: 2147483648,
|
|
3896
|
+
alwaysStat: false
|
|
3897
|
+
};
|
|
3898
|
+
}
|
|
3899
|
+
constructor(options = {}){
|
|
3900
|
+
super({
|
|
3901
|
+
objectMode: true,
|
|
3902
|
+
autoDestroy: true,
|
|
3903
|
+
highWaterMark: options.highWaterMark || 4096
|
|
3904
|
+
});
|
|
3905
|
+
const opts = {
|
|
3906
|
+
...ReaddirpStream.defaultOptions,
|
|
3907
|
+
...options
|
|
3908
|
+
};
|
|
3909
|
+
const { root, type } = opts;
|
|
3910
|
+
this._fileFilter = normalizeFilter(opts.fileFilter);
|
|
3911
|
+
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
3912
|
+
const statMethod = opts.lstat ? lstat : stat;
|
|
3913
|
+
if (wantBigintFsStats) this._stat = (path)=>statMethod(path, {
|
|
3914
|
+
bigint: true
|
|
3915
|
+
});
|
|
3916
|
+
else this._stat = statMethod;
|
|
3917
|
+
this._maxDepth = opts.depth;
|
|
3918
|
+
this._wantsDir = [
|
|
3919
|
+
DIR_TYPE,
|
|
3920
|
+
FILE_DIR_TYPE,
|
|
3921
|
+
EVERYTHING_TYPE
|
|
3922
|
+
].includes(type);
|
|
3923
|
+
this._wantsFile = [
|
|
3924
|
+
FILE_TYPE,
|
|
3925
|
+
FILE_DIR_TYPE,
|
|
3926
|
+
EVERYTHING_TYPE
|
|
3927
|
+
].includes(type);
|
|
3928
|
+
this._wantsEverything = type === EVERYTHING_TYPE;
|
|
3929
|
+
this._root = sysPath.resolve(root);
|
|
3930
|
+
this._isDirent = 'Dirent' in fs && !opts.alwaysStat;
|
|
3931
|
+
this._statsProp = this._isDirent ? 'dirent' : 'stats';
|
|
3932
|
+
this._rdOptions = {
|
|
3933
|
+
encoding: 'utf8',
|
|
3934
|
+
withFileTypes: this._isDirent
|
|
3935
|
+
};
|
|
3936
|
+
this.parents = [
|
|
3937
|
+
this._exploreDir(root, 1)
|
|
3938
|
+
];
|
|
3939
|
+
this.reading = false;
|
|
3940
|
+
this.parent = void 0;
|
|
3941
|
+
}
|
|
3942
|
+
async _read(batch) {
|
|
3943
|
+
if (this.reading) return;
|
|
3944
|
+
this.reading = true;
|
|
3945
|
+
try {
|
|
3946
|
+
while(!this.destroyed && batch > 0){
|
|
3947
|
+
const { path, depth, files = [] } = this.parent || {};
|
|
3948
|
+
if (files.length > 0) {
|
|
3949
|
+
const slice = files.splice(0, batch).map((dirent)=>this._formatEntry(dirent, path));
|
|
3950
|
+
for (const entry of (await Promise.all(slice))){
|
|
3951
|
+
if (this.destroyed) return;
|
|
3952
|
+
const entryType = await this._getEntryType(entry);
|
|
3953
|
+
if ('directory' === entryType && this._directoryFilter(entry)) {
|
|
3954
|
+
if (depth <= this._maxDepth) this.parents.push(this._exploreDir(entry.fullPath, depth + 1));
|
|
3955
|
+
if (this._wantsDir) {
|
|
3956
|
+
this.push(entry);
|
|
3957
|
+
batch--;
|
|
3958
|
+
}
|
|
3959
|
+
} else if (('file' === entryType || this._includeAsFile(entry)) && this._fileFilter(entry)) {
|
|
3960
|
+
if (this._wantsFile) {
|
|
3961
|
+
this.push(entry);
|
|
3962
|
+
batch--;
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
} else {
|
|
3967
|
+
const parent = this.parents.pop();
|
|
3968
|
+
if (!parent) {
|
|
3969
|
+
this.push(null);
|
|
3970
|
+
break;
|
|
3971
|
+
}
|
|
3972
|
+
this.parent = await parent;
|
|
3973
|
+
if (this.destroyed) return;
|
|
3974
|
+
}
|
|
3975
|
+
}
|
|
3976
|
+
} catch (error) {
|
|
3977
|
+
this.destroy(error);
|
|
3978
|
+
} finally{
|
|
3979
|
+
this.reading = false;
|
|
3980
|
+
}
|
|
3981
|
+
}
|
|
3982
|
+
async _exploreDir(path, depth) {
|
|
3983
|
+
let files;
|
|
3984
|
+
try {
|
|
3985
|
+
files = await readdir(path, this._rdOptions);
|
|
3986
|
+
} catch (error) {
|
|
3987
|
+
this._onError(error);
|
|
3988
|
+
}
|
|
3989
|
+
return {
|
|
3990
|
+
files,
|
|
3991
|
+
depth,
|
|
3992
|
+
path
|
|
3993
|
+
};
|
|
3994
|
+
}
|
|
3995
|
+
async _formatEntry(dirent, path) {
|
|
3996
|
+
let entry;
|
|
3997
|
+
try {
|
|
3998
|
+
const basename = this._isDirent ? dirent.name : dirent;
|
|
3999
|
+
const fullPath = sysPath.resolve(sysPath.join(path, basename));
|
|
4000
|
+
entry = {
|
|
4001
|
+
path: sysPath.relative(this._root, fullPath),
|
|
4002
|
+
fullPath,
|
|
4003
|
+
basename
|
|
4004
|
+
};
|
|
4005
|
+
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
4006
|
+
} catch (err) {
|
|
4007
|
+
this._onError(err);
|
|
4008
|
+
}
|
|
4009
|
+
return entry;
|
|
4010
|
+
}
|
|
4011
|
+
_onError(err) {
|
|
4012
|
+
if (isNormalFlowError(err) && !this.destroyed) this.emit('warn', err);
|
|
4013
|
+
else this.destroy(err);
|
|
4014
|
+
}
|
|
4015
|
+
async _getEntryType(entry) {
|
|
4016
|
+
const stats = entry && entry[this._statsProp];
|
|
4017
|
+
if (!stats) return;
|
|
4018
|
+
if (stats.isFile()) return 'file';
|
|
4019
|
+
if (stats.isDirectory()) return 'directory';
|
|
4020
|
+
if (stats && stats.isSymbolicLink()) {
|
|
4021
|
+
const full = entry.fullPath;
|
|
4022
|
+
try {
|
|
4023
|
+
const entryRealPath = await realpath(full);
|
|
4024
|
+
const entryRealPathStats = await lstat(entryRealPath);
|
|
4025
|
+
if (entryRealPathStats.isFile()) return 'file';
|
|
4026
|
+
if (entryRealPathStats.isDirectory()) {
|
|
4027
|
+
const len = entryRealPath.length;
|
|
4028
|
+
if (full.startsWith(entryRealPath) && full.substr(len, 1) === sysPath.sep) {
|
|
4029
|
+
const recursiveError = new Error(`Circular symlink detected: "${full}" points to "${entryRealPath}"`);
|
|
4030
|
+
recursiveError.code = RECURSIVE_ERROR_CODE;
|
|
4031
|
+
return this._onError(recursiveError);
|
|
4032
|
+
}
|
|
4033
|
+
return 'directory';
|
|
4034
|
+
}
|
|
4035
|
+
} catch (error) {
|
|
4036
|
+
this._onError(error);
|
|
4037
|
+
}
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
_includeAsFile(entry) {
|
|
4041
|
+
const stats = entry && entry[this._statsProp];
|
|
4042
|
+
return stats && this._wantsEverything && !stats.isDirectory();
|
|
4043
|
+
}
|
|
4044
|
+
}
|
|
4045
|
+
const readdirp = (root, options = {})=>{
|
|
4046
|
+
let type = options.entryType || options.type;
|
|
4047
|
+
if ('both' === type) type = FILE_DIR_TYPE;
|
|
4048
|
+
if (type) options.type = type;
|
|
4049
|
+
if (root) {
|
|
4050
|
+
if ('string' != typeof root) throw new TypeError('readdirp: root argument must be a string. Usage: readdirp(root, options)');
|
|
4051
|
+
else if (type && !ALL_TYPES.includes(type)) throw new Error(`readdirp: Invalid type passed. Use one of ${ALL_TYPES.join(', ')}`);
|
|
4052
|
+
} else throw new Error('readdirp: root argument is required. Usage: readdirp(root, options)');
|
|
4053
|
+
options.root = root;
|
|
4054
|
+
return new ReaddirpStream(options);
|
|
4055
|
+
};
|
|
4056
|
+
const readdirpPromise = (root, options = {})=>new Promise((resolve, reject)=>{
|
|
4057
|
+
const files = [];
|
|
4058
|
+
readdirp(root, options).on('data', (entry)=>files.push(entry)).on('end', ()=>resolve(files)).on('error', (error)=>reject(error));
|
|
4059
|
+
});
|
|
4060
|
+
readdirp.promise = readdirpPromise;
|
|
4061
|
+
readdirp.ReaddirpStream = ReaddirpStream;
|
|
4062
|
+
readdirp.default = readdirp;
|
|
4063
|
+
module.exports = readdirp;
|
|
4064
|
+
},
|
|
4065
|
+
"../../node_modules/.pnpm/to-regex-range@5.0.1/node_modules/to-regex-range/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
4066
|
+
/*!
|
|
4067
|
+
* to-regex-range <https://github.com/micromatch/to-regex-range>
|
|
4068
|
+
*
|
|
4069
|
+
* Copyright (c) 2015-present, Jon Schlinkert.
|
|
4070
|
+
* Released under the MIT License.
|
|
4071
|
+
*/ const isNumber = __webpack_require__("../../node_modules/.pnpm/is-number@7.0.0/node_modules/is-number/index.js");
|
|
4072
|
+
const toRegexRange = (min, max, options)=>{
|
|
4073
|
+
if (false === isNumber(min)) throw new TypeError('toRegexRange: expected the first argument to be a number');
|
|
4074
|
+
if (void 0 === max || min === max) return String(min);
|
|
4075
|
+
if (false === isNumber(max)) throw new TypeError('toRegexRange: expected the second argument to be a number.');
|
|
4076
|
+
let opts = {
|
|
4077
|
+
relaxZeros: true,
|
|
4078
|
+
...options
|
|
4079
|
+
};
|
|
4080
|
+
if ('boolean' == typeof opts.strictZeros) opts.relaxZeros = false === opts.strictZeros;
|
|
4081
|
+
let relax = String(opts.relaxZeros);
|
|
4082
|
+
let shorthand = String(opts.shorthand);
|
|
4083
|
+
let capture = String(opts.capture);
|
|
4084
|
+
let wrap = String(opts.wrap);
|
|
4085
|
+
let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
|
|
4086
|
+
if (toRegexRange.cache.hasOwnProperty(cacheKey)) return toRegexRange.cache[cacheKey].result;
|
|
4087
|
+
let a = Math.min(min, max);
|
|
4088
|
+
let b = Math.max(min, max);
|
|
4089
|
+
if (1 === Math.abs(a - b)) {
|
|
4090
|
+
let result = min + '|' + max;
|
|
4091
|
+
if (opts.capture) return `(${result})`;
|
|
4092
|
+
if (false === opts.wrap) return result;
|
|
4093
|
+
return `(?:${result})`;
|
|
4094
|
+
}
|
|
4095
|
+
let isPadded = hasPadding(min) || hasPadding(max);
|
|
4096
|
+
let state = {
|
|
4097
|
+
min,
|
|
4098
|
+
max,
|
|
4099
|
+
a,
|
|
4100
|
+
b
|
|
4101
|
+
};
|
|
4102
|
+
let positives = [];
|
|
4103
|
+
let negatives = [];
|
|
4104
|
+
if (isPadded) {
|
|
4105
|
+
state.isPadded = isPadded;
|
|
4106
|
+
state.maxLen = String(state.max).length;
|
|
4107
|
+
}
|
|
4108
|
+
if (a < 0) {
|
|
4109
|
+
let newMin = b < 0 ? Math.abs(b) : 1;
|
|
4110
|
+
negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
|
|
4111
|
+
a = state.a = 0;
|
|
4112
|
+
}
|
|
4113
|
+
if (b >= 0) positives = splitToPatterns(a, b, state, opts);
|
|
4114
|
+
state.negatives = negatives;
|
|
4115
|
+
state.positives = positives;
|
|
4116
|
+
state.result = collatePatterns(negatives, positives, opts);
|
|
4117
|
+
if (true === opts.capture) state.result = `(${state.result})`;
|
|
4118
|
+
else if (false !== opts.wrap && positives.length + negatives.length > 1) state.result = `(?:${state.result})`;
|
|
4119
|
+
toRegexRange.cache[cacheKey] = state;
|
|
4120
|
+
return state.result;
|
|
4121
|
+
};
|
|
4122
|
+
function collatePatterns(neg, pos, options) {
|
|
4123
|
+
let onlyNegative = filterPatterns(neg, pos, '-', false, options) || [];
|
|
4124
|
+
let onlyPositive = filterPatterns(pos, neg, '', false, options) || [];
|
|
4125
|
+
let intersected = filterPatterns(neg, pos, '-?', true, options) || [];
|
|
4126
|
+
let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
|
|
4127
|
+
return subpatterns.join('|');
|
|
4128
|
+
}
|
|
4129
|
+
function splitToRanges(min, max) {
|
|
4130
|
+
let nines = 1;
|
|
4131
|
+
let zeros = 1;
|
|
4132
|
+
let stop = countNines(min, nines);
|
|
4133
|
+
let stops = new Set([
|
|
4134
|
+
max
|
|
4135
|
+
]);
|
|
4136
|
+
while(min <= stop && stop <= max){
|
|
4137
|
+
stops.add(stop);
|
|
4138
|
+
nines += 1;
|
|
4139
|
+
stop = countNines(min, nines);
|
|
4140
|
+
}
|
|
4141
|
+
stop = countZeros(max + 1, zeros) - 1;
|
|
4142
|
+
while(min < stop && stop <= max){
|
|
4143
|
+
stops.add(stop);
|
|
4144
|
+
zeros += 1;
|
|
4145
|
+
stop = countZeros(max + 1, zeros) - 1;
|
|
4146
|
+
}
|
|
4147
|
+
stops = [
|
|
4148
|
+
...stops
|
|
4149
|
+
];
|
|
4150
|
+
stops.sort(compare);
|
|
4151
|
+
return stops;
|
|
4152
|
+
}
|
|
4153
|
+
function rangeToPattern(start, stop, options) {
|
|
4154
|
+
if (start === stop) return {
|
|
4155
|
+
pattern: start,
|
|
4156
|
+
count: [],
|
|
4157
|
+
digits: 0
|
|
4158
|
+
};
|
|
4159
|
+
let zipped = zip(start, stop);
|
|
4160
|
+
let digits = zipped.length;
|
|
4161
|
+
let pattern = '';
|
|
4162
|
+
let count = 0;
|
|
4163
|
+
for(let i = 0; i < digits; i++){
|
|
4164
|
+
let [startDigit, stopDigit] = zipped[i];
|
|
4165
|
+
if (startDigit === stopDigit) pattern += startDigit;
|
|
4166
|
+
else if ('0' !== startDigit || '9' !== stopDigit) pattern += toCharacterClass(startDigit, stopDigit, options);
|
|
4167
|
+
else count++;
|
|
4168
|
+
}
|
|
4169
|
+
if (count) pattern += true === options.shorthand ? '\\d' : '[0-9]';
|
|
4170
|
+
return {
|
|
4171
|
+
pattern,
|
|
4172
|
+
count: [
|
|
4173
|
+
count
|
|
4174
|
+
],
|
|
4175
|
+
digits
|
|
4176
|
+
};
|
|
4177
|
+
}
|
|
4178
|
+
function splitToPatterns(min, max, tok, options) {
|
|
4179
|
+
let ranges = splitToRanges(min, max);
|
|
4180
|
+
let tokens = [];
|
|
4181
|
+
let start = min;
|
|
4182
|
+
let prev;
|
|
4183
|
+
for(let i = 0; i < ranges.length; i++){
|
|
4184
|
+
let max = ranges[i];
|
|
4185
|
+
let obj = rangeToPattern(String(start), String(max), options);
|
|
4186
|
+
let zeros = '';
|
|
4187
|
+
if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
|
|
4188
|
+
if (prev.count.length > 1) prev.count.pop();
|
|
4189
|
+
prev.count.push(obj.count[0]);
|
|
4190
|
+
prev.string = prev.pattern + toQuantifier(prev.count);
|
|
4191
|
+
start = max + 1;
|
|
4192
|
+
continue;
|
|
4193
|
+
}
|
|
4194
|
+
if (tok.isPadded) zeros = padZeros(max, tok, options);
|
|
4195
|
+
obj.string = zeros + obj.pattern + toQuantifier(obj.count);
|
|
4196
|
+
tokens.push(obj);
|
|
4197
|
+
start = max + 1;
|
|
4198
|
+
prev = obj;
|
|
4199
|
+
}
|
|
4200
|
+
return tokens;
|
|
4201
|
+
}
|
|
4202
|
+
function filterPatterns(arr, comparison, prefix, intersection, options) {
|
|
4203
|
+
let result = [];
|
|
4204
|
+
for (let ele of arr){
|
|
4205
|
+
let { string } = ele;
|
|
4206
|
+
if (!intersection && !contains(comparison, 'string', string)) result.push(prefix + string);
|
|
4207
|
+
if (intersection && contains(comparison, 'string', string)) result.push(prefix + string);
|
|
4208
|
+
}
|
|
4209
|
+
return result;
|
|
4210
|
+
}
|
|
4211
|
+
function zip(a, b) {
|
|
4212
|
+
let arr = [];
|
|
4213
|
+
for(let i = 0; i < a.length; i++)arr.push([
|
|
4214
|
+
a[i],
|
|
4215
|
+
b[i]
|
|
4216
|
+
]);
|
|
4217
|
+
return arr;
|
|
4218
|
+
}
|
|
4219
|
+
function compare(a, b) {
|
|
4220
|
+
return a > b ? 1 : b > a ? -1 : 0;
|
|
4221
|
+
}
|
|
4222
|
+
function contains(arr, key, val) {
|
|
4223
|
+
return arr.some((ele)=>ele[key] === val);
|
|
4224
|
+
}
|
|
4225
|
+
function countNines(min, len) {
|
|
4226
|
+
return Number(String(min).slice(0, -len) + '9'.repeat(len));
|
|
4227
|
+
}
|
|
4228
|
+
function countZeros(integer, zeros) {
|
|
4229
|
+
return integer - integer % Math.pow(10, zeros);
|
|
4230
|
+
}
|
|
4231
|
+
function toQuantifier(digits) {
|
|
4232
|
+
let [start = 0, stop = ''] = digits;
|
|
4233
|
+
if (stop || start > 1) return `{${start + (stop ? ',' + stop : '')}}`;
|
|
4234
|
+
return '';
|
|
4235
|
+
}
|
|
4236
|
+
function toCharacterClass(a, b, options) {
|
|
4237
|
+
return `[${a}${b - a === 1 ? '' : '-'}${b}]`;
|
|
4238
|
+
}
|
|
4239
|
+
function hasPadding(str) {
|
|
4240
|
+
return /^-?(0+)\d/.test(str);
|
|
4241
|
+
}
|
|
4242
|
+
function padZeros(value, tok, options) {
|
|
4243
|
+
if (!tok.isPadded) return value;
|
|
4244
|
+
let diff = Math.abs(tok.maxLen - String(value).length);
|
|
4245
|
+
let relax = false !== options.relaxZeros;
|
|
4246
|
+
switch(diff){
|
|
4247
|
+
case 0:
|
|
4248
|
+
return '';
|
|
4249
|
+
case 1:
|
|
4250
|
+
return relax ? '0?' : '0';
|
|
4251
|
+
case 2:
|
|
4252
|
+
return relax ? '0{0,2}' : '00';
|
|
4253
|
+
default:
|
|
4254
|
+
return relax ? `0{0,${diff}}` : `0{${diff}}`;
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
toRegexRange.cache = {};
|
|
4258
|
+
toRegexRange.clearCache = ()=>toRegexRange.cache = {};
|
|
4259
|
+
module.exports = toRegexRange;
|
|
4260
|
+
},
|
|
4261
|
+
events (module) {
|
|
4262
|
+
module.exports = __rspack_createRequire_require("events");
|
|
4263
|
+
},
|
|
4264
|
+
os (module) {
|
|
4265
|
+
module.exports = __rspack_createRequire_require("os");
|
|
4266
|
+
},
|
|
4267
|
+
util (module) {
|
|
4268
|
+
module.exports = __rspack_createRequire_require("util");
|
|
4269
|
+
},
|
|
4270
|
+
"../../node_modules/.pnpm/binary-extensions@2.3.0/node_modules/binary-extensions/binary-extensions.json" (module) {
|
|
4271
|
+
module.exports = JSON.parse('["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]');
|
|
4272
|
+
}
|
|
4273
|
+
});
|
|
4274
|
+
function toArr(any) {
|
|
4275
|
+
return null == any ? [] : Array.isArray(any) ? any : [
|
|
4276
|
+
any
|
|
4277
|
+
];
|
|
4278
|
+
}
|
|
4279
|
+
function toVal(out, key, val, opts) {
|
|
4280
|
+
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;
|
|
4281
|
+
out[key] = null == old ? nxt : Array.isArray(old) ? old.concat(nxt) : [
|
|
4282
|
+
old,
|
|
4283
|
+
nxt
|
|
4284
|
+
];
|
|
4285
|
+
}
|
|
4286
|
+
function lib_default(args, opts) {
|
|
4287
|
+
args = args || [];
|
|
4288
|
+
opts = opts || {};
|
|
4289
|
+
var k, arr, arg, name, val, out = {
|
|
4290
|
+
_: []
|
|
4291
|
+
};
|
|
4292
|
+
var i = 0, j = 0, idx = 0, len = args.length;
|
|
4293
|
+
const alibi = void 0 !== opts.alias;
|
|
4294
|
+
const strict = void 0 !== opts.unknown;
|
|
4295
|
+
const defaults = void 0 !== opts.default;
|
|
4296
|
+
opts.alias = opts.alias || {};
|
|
4297
|
+
opts.string = toArr(opts.string);
|
|
4298
|
+
opts.boolean = toArr(opts.boolean);
|
|
4299
|
+
if (alibi) for(k in opts.alias){
|
|
4300
|
+
arr = opts.alias[k] = toArr(opts.alias[k]);
|
|
4301
|
+
for(i = 0; i < arr.length; i++)(opts.alias[arr[i]] = arr.concat(k)).splice(i, 1);
|
|
4302
|
+
}
|
|
4303
|
+
for(i = opts.boolean.length; i-- > 0;){
|
|
4304
|
+
arr = opts.alias[opts.boolean[i]] || [];
|
|
4305
|
+
for(j = arr.length; j-- > 0;)opts.boolean.push(arr[j]);
|
|
4306
|
+
}
|
|
4307
|
+
for(i = opts.string.length; i-- > 0;){
|
|
4308
|
+
arr = opts.alias[opts.string[i]] || [];
|
|
4309
|
+
for(j = arr.length; j-- > 0;)opts.string.push(arr[j]);
|
|
4310
|
+
}
|
|
4311
|
+
if (defaults) for(k in opts.default){
|
|
4312
|
+
name = typeof opts.default[k];
|
|
4313
|
+
arr = opts.alias[k] = opts.alias[k] || [];
|
|
4314
|
+
if (void 0 !== opts[name]) {
|
|
4315
|
+
opts[name].push(k);
|
|
4316
|
+
for(i = 0; i < arr.length; i++)opts[name].push(arr[i]);
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
const keys = strict ? Object.keys(opts.alias) : [];
|
|
4320
|
+
for(i = 0; i < len; i++){
|
|
4321
|
+
arg = args[i];
|
|
4322
|
+
if ("--" === arg) {
|
|
4323
|
+
out._ = out._.concat(args.slice(++i));
|
|
4324
|
+
break;
|
|
4325
|
+
}
|
|
4326
|
+
for(j = 0; j < arg.length && 45 === arg.charCodeAt(j); j++);
|
|
4327
|
+
if (0 === j) out._.push(arg);
|
|
4328
|
+
else if ("no-" === arg.substring(j, j + 3)) {
|
|
4329
|
+
name = arg.substring(j + 3);
|
|
4330
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown(arg);
|
|
4331
|
+
out[name] = false;
|
|
4332
|
+
} else {
|
|
4333
|
+
for(idx = j + 1; idx < arg.length && 61 !== arg.charCodeAt(idx); idx++);
|
|
4334
|
+
name = arg.substring(j, idx);
|
|
4335
|
+
val = arg.substring(++idx) || i + 1 === len || 45 === ("" + args[i + 1]).charCodeAt(0) || args[++i];
|
|
4336
|
+
arr = 2 === j ? [
|
|
4337
|
+
name
|
|
4338
|
+
] : name;
|
|
4339
|
+
for(idx = 0; idx < arr.length; idx++){
|
|
4340
|
+
name = arr[idx];
|
|
4341
|
+
if (strict && !~keys.indexOf(name)) return opts.unknown("-".repeat(j) + name);
|
|
4342
|
+
toVal(out, name, idx + 1 < arr.length || val, opts);
|
|
4343
|
+
}
|
|
4344
|
+
}
|
|
4345
|
+
}
|
|
4346
|
+
if (defaults) {
|
|
4347
|
+
for(k in opts.default)if (void 0 === out[k]) out[k] = opts.default[k];
|
|
4348
|
+
}
|
|
4349
|
+
if (alibi) for(k in out){
|
|
4350
|
+
arr = opts.alias[k] || [];
|
|
4351
|
+
while(arr.length > 0)out[arr.shift()] = out[k];
|
|
4352
|
+
}
|
|
4353
|
+
return out;
|
|
4354
|
+
}
|
|
4355
|
+
function removeBrackets(v) {
|
|
4356
|
+
return v.replace(/[<[].+/, "").trim();
|
|
4357
|
+
}
|
|
4358
|
+
function findAllBrackets(v) {
|
|
4359
|
+
const ANGLED_BRACKET_RE_GLOBAL = /<([^>]+)>/g;
|
|
4360
|
+
const SQUARE_BRACKET_RE_GLOBAL = /\[([^\]]+)\]/g;
|
|
4361
|
+
const res = [];
|
|
4362
|
+
const parse = (match)=>{
|
|
4363
|
+
let variadic = false;
|
|
4364
|
+
let value = match[1];
|
|
4365
|
+
if (value.startsWith("...")) {
|
|
4366
|
+
value = value.slice(3);
|
|
4367
|
+
variadic = true;
|
|
4368
|
+
}
|
|
4369
|
+
return {
|
|
4370
|
+
required: match[0].startsWith("<"),
|
|
4371
|
+
value,
|
|
4372
|
+
variadic
|
|
4373
|
+
};
|
|
4374
|
+
};
|
|
4375
|
+
let angledMatch;
|
|
4376
|
+
while(angledMatch = ANGLED_BRACKET_RE_GLOBAL.exec(v))res.push(parse(angledMatch));
|
|
4377
|
+
let squareMatch;
|
|
4378
|
+
while(squareMatch = SQUARE_BRACKET_RE_GLOBAL.exec(v))res.push(parse(squareMatch));
|
|
4379
|
+
return res;
|
|
4380
|
+
}
|
|
4381
|
+
function getMriOptions(options) {
|
|
4382
|
+
const result = {
|
|
4383
|
+
alias: {},
|
|
4384
|
+
boolean: []
|
|
4385
|
+
};
|
|
4386
|
+
for (const [index, option] of options.entries()){
|
|
4387
|
+
if (option.names.length > 1) result.alias[option.names[0]] = option.names.slice(1);
|
|
4388
|
+
if (option.isBoolean) if (option.negated) {
|
|
4389
|
+
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]);
|
|
4390
|
+
} else result.boolean.push(option.names[0]);
|
|
4391
|
+
}
|
|
4392
|
+
return result;
|
|
4393
|
+
}
|
|
4394
|
+
function findLongest(arr) {
|
|
4395
|
+
return arr.sort((a, b)=>a.length > b.length ? -1 : 1)[0];
|
|
4396
|
+
}
|
|
4397
|
+
function padRight(str, length) {
|
|
4398
|
+
return str.length >= length ? str : `${str}${" ".repeat(length - str.length)}`;
|
|
4399
|
+
}
|
|
4400
|
+
function camelcase(input) {
|
|
4401
|
+
return input.replaceAll(/([a-z])-([a-z])/g, (_, p1, p2)=>p1 + p2.toUpperCase());
|
|
4402
|
+
}
|
|
4403
|
+
function setDotProp(obj, keys, val) {
|
|
4404
|
+
let current = obj;
|
|
4405
|
+
for(let i = 0; i < keys.length; i++){
|
|
4406
|
+
const key = keys[i];
|
|
4407
|
+
if (i === keys.length - 1) {
|
|
4408
|
+
current[key] = val;
|
|
4409
|
+
return;
|
|
4410
|
+
}
|
|
4411
|
+
if (null == current[key]) {
|
|
4412
|
+
const nextKeyIsArrayIndex = +keys[i + 1] > -1;
|
|
4413
|
+
current[key] = nextKeyIsArrayIndex ? [] : {};
|
|
4414
|
+
}
|
|
4415
|
+
current = current[key];
|
|
4416
|
+
}
|
|
4417
|
+
}
|
|
4418
|
+
function setByType(obj, transforms) {
|
|
4419
|
+
for (const key of Object.keys(transforms)){
|
|
4420
|
+
const transform = transforms[key];
|
|
4421
|
+
if (transform.shouldTransform) {
|
|
4422
|
+
obj[key] = [
|
|
4423
|
+
obj[key]
|
|
4424
|
+
].flat();
|
|
4425
|
+
if ("function" == typeof transform.transformFunction) obj[key] = obj[key].map(transform.transformFunction);
|
|
4426
|
+
}
|
|
4427
|
+
}
|
|
4428
|
+
}
|
|
4429
|
+
function getFileName(input) {
|
|
4430
|
+
const m = /([^\\/]+)$/.exec(input);
|
|
4431
|
+
return m ? m[1] : "";
|
|
4432
|
+
}
|
|
4433
|
+
function camelcaseOptionName(name) {
|
|
4434
|
+
return name.split(".").map((v, i)=>0 === i ? camelcase(v) : v).join(".");
|
|
4435
|
+
}
|
|
4436
|
+
var CACError = class extends Error {
|
|
4437
|
+
constructor(message){
|
|
4438
|
+
super(message);
|
|
4439
|
+
this.name = "CACError";
|
|
4440
|
+
if ("function" != typeof Error.captureStackTrace) this.stack = new Error(message).stack;
|
|
4441
|
+
}
|
|
4442
|
+
};
|
|
4443
|
+
var Option = class {
|
|
4444
|
+
rawName;
|
|
4445
|
+
description;
|
|
4446
|
+
name;
|
|
4447
|
+
names;
|
|
4448
|
+
isBoolean;
|
|
4449
|
+
required;
|
|
4450
|
+
config;
|
|
4451
|
+
negated;
|
|
4452
|
+
constructor(rawName, description, config){
|
|
4453
|
+
this.rawName = rawName;
|
|
4454
|
+
this.description = description;
|
|
4455
|
+
this.config = Object.assign({}, config);
|
|
4456
|
+
rawName = rawName.replaceAll(".*", "");
|
|
4457
|
+
this.negated = false;
|
|
4458
|
+
this.names = removeBrackets(rawName).split(",").map((v)=>{
|
|
4459
|
+
let name = v.trim().replace(/^-{1,2}/, "");
|
|
4460
|
+
if (name.startsWith("no-")) {
|
|
4461
|
+
this.negated = true;
|
|
4462
|
+
name = name.replace(/^no-/, "");
|
|
4463
|
+
}
|
|
4464
|
+
return camelcaseOptionName(name);
|
|
4465
|
+
}).sort((a, b)=>a.length > b.length ? 1 : -1);
|
|
4466
|
+
this.name = this.names.at(-1);
|
|
4467
|
+
if (this.negated && null == this.config.default) this.config.default = true;
|
|
4468
|
+
if (rawName.includes("<")) this.required = true;
|
|
4469
|
+
else if (rawName.includes("[")) this.required = false;
|
|
4470
|
+
else this.isBoolean = true;
|
|
4471
|
+
}
|
|
4472
|
+
};
|
|
4473
|
+
let runtimeProcessArgs;
|
|
4474
|
+
let runtimeInfo;
|
|
4475
|
+
if ("u" > typeof process) {
|
|
4476
|
+
let runtimeName;
|
|
4477
|
+
runtimeName = "u" > typeof Deno && "string" == typeof Deno.version?.deno ? "deno" : "u" > typeof Bun && "string" == typeof Bun.version ? "bun" : "node";
|
|
4478
|
+
runtimeInfo = `${process.platform}-${process.arch} ${runtimeName}-${process.version}`;
|
|
4479
|
+
runtimeProcessArgs = process.argv;
|
|
4480
|
+
} else runtimeInfo = "u" < typeof navigator ? "unknown" : `${navigator.platform} ${navigator.userAgent}`;
|
|
4481
|
+
var Command = class {
|
|
4482
|
+
rawName;
|
|
4483
|
+
description;
|
|
4484
|
+
config;
|
|
4485
|
+
cli;
|
|
4486
|
+
options;
|
|
4487
|
+
aliasNames;
|
|
4488
|
+
name;
|
|
4489
|
+
args;
|
|
4490
|
+
commandAction;
|
|
4491
|
+
usageText;
|
|
4492
|
+
versionNumber;
|
|
4493
|
+
examples;
|
|
4494
|
+
helpCallback;
|
|
4495
|
+
globalCommand;
|
|
4496
|
+
constructor(rawName, description, config = {}, cli){
|
|
4497
|
+
this.rawName = rawName;
|
|
4498
|
+
this.description = description;
|
|
4499
|
+
this.config = config;
|
|
4500
|
+
this.cli = cli;
|
|
4501
|
+
this.options = [];
|
|
4502
|
+
this.aliasNames = [];
|
|
4503
|
+
this.name = removeBrackets(rawName);
|
|
4504
|
+
this.args = findAllBrackets(rawName);
|
|
4505
|
+
this.examples = [];
|
|
4506
|
+
}
|
|
4507
|
+
usage(text) {
|
|
4508
|
+
this.usageText = text;
|
|
4509
|
+
return this;
|
|
4510
|
+
}
|
|
4511
|
+
allowUnknownOptions() {
|
|
4512
|
+
this.config.allowUnknownOptions = true;
|
|
4513
|
+
return this;
|
|
4514
|
+
}
|
|
4515
|
+
ignoreOptionDefaultValue() {
|
|
4516
|
+
this.config.ignoreOptionDefaultValue = true;
|
|
4517
|
+
return this;
|
|
4518
|
+
}
|
|
4519
|
+
version(version, customFlags = "-v, --version") {
|
|
4520
|
+
this.versionNumber = version;
|
|
4521
|
+
this.option(customFlags, "Display version number");
|
|
4522
|
+
return this;
|
|
4523
|
+
}
|
|
4524
|
+
example(example) {
|
|
4525
|
+
this.examples.push(example);
|
|
4526
|
+
return this;
|
|
4527
|
+
}
|
|
4528
|
+
option(rawName, description, config) {
|
|
4529
|
+
const option = new Option(rawName, description, config);
|
|
4530
|
+
this.options.push(option);
|
|
4531
|
+
return this;
|
|
4532
|
+
}
|
|
4533
|
+
alias(name) {
|
|
4534
|
+
this.aliasNames.push(name);
|
|
4535
|
+
return this;
|
|
4536
|
+
}
|
|
4537
|
+
action(callback) {
|
|
4538
|
+
this.commandAction = callback;
|
|
4539
|
+
return this;
|
|
4540
|
+
}
|
|
4541
|
+
isMatched(name) {
|
|
4542
|
+
return this.name === name || this.aliasNames.includes(name);
|
|
4543
|
+
}
|
|
4544
|
+
get isDefaultCommand() {
|
|
4545
|
+
return "" === this.name || this.aliasNames.includes("!");
|
|
4546
|
+
}
|
|
4547
|
+
get isGlobalCommand() {
|
|
4548
|
+
return this instanceof GlobalCommand;
|
|
4549
|
+
}
|
|
4550
|
+
hasOption(name) {
|
|
4551
|
+
name = name.split(".")[0];
|
|
4552
|
+
return this.options.find((option)=>option.names.includes(name));
|
|
4553
|
+
}
|
|
4554
|
+
outputHelp() {
|
|
4555
|
+
const { name, commands } = this.cli;
|
|
4556
|
+
const { versionNumber, options: globalOptions, helpCallback } = this.cli.globalCommand;
|
|
4557
|
+
let sections = [
|
|
4558
|
+
{
|
|
4559
|
+
body: `${name}${versionNumber ? `/${versionNumber}` : ""}`
|
|
4560
|
+
}
|
|
4561
|
+
];
|
|
4562
|
+
sections.push({
|
|
4563
|
+
title: "Usage",
|
|
4564
|
+
body: ` $ ${name} ${this.usageText || this.rawName}`
|
|
4565
|
+
});
|
|
4566
|
+
if ((this.isGlobalCommand || this.isDefaultCommand) && commands.length > 0) {
|
|
4567
|
+
const longestCommandName = findLongest(commands.map((command)=>command.rawName));
|
|
4568
|
+
sections.push({
|
|
4569
|
+
title: "Commands",
|
|
4570
|
+
body: commands.map((command)=>` ${padRight(command.rawName, longestCommandName.length)} ${command.description}`).join("\n")
|
|
4571
|
+
}, {
|
|
4572
|
+
title: "For more info, run any command with the `--help` flag",
|
|
4573
|
+
body: commands.map((command)=>` $ ${name}${"" === command.name ? "" : ` ${command.name}`} --help`).join("\n")
|
|
4574
|
+
});
|
|
4575
|
+
}
|
|
4576
|
+
let options = this.isGlobalCommand ? globalOptions : [
|
|
4577
|
+
...this.options,
|
|
4578
|
+
...globalOptions || []
|
|
4579
|
+
];
|
|
4580
|
+
if (!this.isGlobalCommand && !this.isDefaultCommand) options = options.filter((option)=>"version" !== option.name);
|
|
4581
|
+
if (options.length > 0) {
|
|
4582
|
+
const longestOptionName = findLongest(options.map((option)=>option.rawName));
|
|
4583
|
+
sections.push({
|
|
4584
|
+
title: "Options",
|
|
4585
|
+
body: options.map((option)=>` ${padRight(option.rawName, longestOptionName.length)} ${option.description} ${void 0 === option.config.default ? "" : `(default: ${option.config.default})`}`).join("\n")
|
|
4586
|
+
});
|
|
4587
|
+
}
|
|
4588
|
+
if (this.examples.length > 0) sections.push({
|
|
4589
|
+
title: "Examples",
|
|
4590
|
+
body: this.examples.map((example)=>{
|
|
4591
|
+
if ("function" == typeof example) return example(name);
|
|
4592
|
+
return example;
|
|
4593
|
+
}).join("\n")
|
|
4594
|
+
});
|
|
4595
|
+
if (helpCallback) sections = helpCallback(sections) || sections;
|
|
4596
|
+
console.info(sections.map((section)=>section.title ? `${section.title}:\n${section.body}` : section.body).join("\n\n"));
|
|
4597
|
+
}
|
|
4598
|
+
outputVersion() {
|
|
4599
|
+
const { name } = this.cli;
|
|
4600
|
+
const { versionNumber } = this.cli.globalCommand;
|
|
4601
|
+
if (versionNumber) console.info(`${name}/${versionNumber} ${runtimeInfo}`);
|
|
4602
|
+
}
|
|
4603
|
+
checkRequiredArgs() {
|
|
4604
|
+
const minimalArgsCount = this.args.filter((arg)=>arg.required).length;
|
|
4605
|
+
if (this.cli.args.length < minimalArgsCount) throw new CACError(`missing required args for command \`${this.rawName}\``);
|
|
4606
|
+
}
|
|
4607
|
+
checkUnknownOptions() {
|
|
4608
|
+
const { options, globalCommand } = this.cli;
|
|
4609
|
+
if (!this.config.allowUnknownOptions) {
|
|
4610
|
+
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}`}\``);
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
checkOptionValue() {
|
|
4614
|
+
const { options: parsedOptions, globalCommand } = this.cli;
|
|
4615
|
+
const options = [
|
|
4616
|
+
...globalCommand.options,
|
|
4617
|
+
...this.options
|
|
4618
|
+
];
|
|
4619
|
+
for (const option of options){
|
|
4620
|
+
const value = parsedOptions[option.name.split(".")[0]];
|
|
4621
|
+
if (option.required) {
|
|
4622
|
+
const hasNegated = options.some((o)=>o.negated && o.names.includes(option.name));
|
|
4623
|
+
if (true === value || false === value && !hasNegated) throw new CACError(`option \`${option.rawName}\` value is missing`);
|
|
4624
|
+
}
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
checkUnusedArgs() {
|
|
4628
|
+
const maximumArgsCount = this.args.some((arg)=>arg.variadic) ? 1 / 0 : this.args.length;
|
|
4629
|
+
if (maximumArgsCount < this.cli.args.length) throw new CACError(`Unused args: ${this.cli.args.slice(maximumArgsCount).map((arg)=>`\`${arg}\``).join(", ")}`);
|
|
4630
|
+
}
|
|
4631
|
+
};
|
|
4632
|
+
var GlobalCommand = class extends Command {
|
|
4633
|
+
constructor(cli){
|
|
4634
|
+
super("@@global@@", "", {}, cli);
|
|
4635
|
+
}
|
|
4636
|
+
};
|
|
4637
|
+
var CAC = class extends EventTarget {
|
|
4638
|
+
name;
|
|
4639
|
+
commands;
|
|
4640
|
+
globalCommand;
|
|
4641
|
+
matchedCommand;
|
|
4642
|
+
matchedCommandName;
|
|
4643
|
+
rawArgs;
|
|
4644
|
+
args;
|
|
4645
|
+
options;
|
|
4646
|
+
showHelpOnExit;
|
|
4647
|
+
showVersionOnExit;
|
|
4648
|
+
constructor(name = ""){
|
|
4649
|
+
super();
|
|
4650
|
+
this.name = name;
|
|
4651
|
+
this.commands = [];
|
|
4652
|
+
this.rawArgs = [];
|
|
4653
|
+
this.args = [];
|
|
4654
|
+
this.options = {};
|
|
4655
|
+
this.globalCommand = new GlobalCommand(this);
|
|
4656
|
+
this.globalCommand.usage("<command> [options]");
|
|
4657
|
+
}
|
|
4658
|
+
usage(text) {
|
|
4659
|
+
this.globalCommand.usage(text);
|
|
4660
|
+
return this;
|
|
4661
|
+
}
|
|
4662
|
+
command(rawName, description, config) {
|
|
4663
|
+
const command = new Command(rawName, description || "", config, this);
|
|
4664
|
+
command.globalCommand = this.globalCommand;
|
|
4665
|
+
this.commands.push(command);
|
|
4666
|
+
return command;
|
|
4667
|
+
}
|
|
4668
|
+
option(rawName, description, config) {
|
|
4669
|
+
this.globalCommand.option(rawName, description, config);
|
|
4670
|
+
return this;
|
|
4671
|
+
}
|
|
4672
|
+
help(callback) {
|
|
4673
|
+
this.globalCommand.option("-h, --help", "Display this message");
|
|
4674
|
+
this.globalCommand.helpCallback = callback;
|
|
4675
|
+
this.showHelpOnExit = true;
|
|
4676
|
+
return this;
|
|
4677
|
+
}
|
|
4678
|
+
version(version, customFlags = "-v, --version") {
|
|
4679
|
+
this.globalCommand.version(version, customFlags);
|
|
4680
|
+
this.showVersionOnExit = true;
|
|
4681
|
+
return this;
|
|
4682
|
+
}
|
|
4683
|
+
example(example) {
|
|
4684
|
+
this.globalCommand.example(example);
|
|
4685
|
+
return this;
|
|
4686
|
+
}
|
|
4687
|
+
outputHelp() {
|
|
4688
|
+
if (this.matchedCommand) this.matchedCommand.outputHelp();
|
|
4689
|
+
else this.globalCommand.outputHelp();
|
|
4690
|
+
}
|
|
4691
|
+
outputVersion() {
|
|
4692
|
+
this.globalCommand.outputVersion();
|
|
4693
|
+
}
|
|
4694
|
+
setParsedInfo({ args, options }, matchedCommand, matchedCommandName) {
|
|
4695
|
+
this.args = args;
|
|
4696
|
+
this.options = options;
|
|
4697
|
+
if (matchedCommand) this.matchedCommand = matchedCommand;
|
|
4698
|
+
if (matchedCommandName) this.matchedCommandName = matchedCommandName;
|
|
4699
|
+
return this;
|
|
4700
|
+
}
|
|
4701
|
+
unsetMatchedCommand() {
|
|
4702
|
+
this.matchedCommand = void 0;
|
|
4703
|
+
this.matchedCommandName = void 0;
|
|
4704
|
+
}
|
|
4705
|
+
parse(argv, { run = true } = {}) {
|
|
4706
|
+
if (!argv) {
|
|
4707
|
+
if (!runtimeProcessArgs) throw new Error("No argv provided and runtime process argv is not available.");
|
|
4708
|
+
argv = runtimeProcessArgs;
|
|
4709
|
+
}
|
|
4710
|
+
this.rawArgs = argv;
|
|
4711
|
+
if (!this.name) this.name = argv[1] ? getFileName(argv[1]) : "cli";
|
|
4712
|
+
let shouldParse = true;
|
|
4713
|
+
for (const command of this.commands){
|
|
4714
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
4715
|
+
const commandName = parsed.args[0];
|
|
4716
|
+
if (command.isMatched(commandName)) {
|
|
4717
|
+
shouldParse = false;
|
|
4718
|
+
const parsedInfo = {
|
|
4719
|
+
...parsed,
|
|
4720
|
+
args: parsed.args.slice(1)
|
|
4721
|
+
};
|
|
4722
|
+
this.setParsedInfo(parsedInfo, command, commandName);
|
|
4723
|
+
this.dispatchEvent(new CustomEvent(`command:${commandName}`, {
|
|
4724
|
+
detail: command
|
|
4725
|
+
}));
|
|
4726
|
+
}
|
|
4727
|
+
}
|
|
4728
|
+
if (shouldParse) {
|
|
4729
|
+
for (const command of this.commands)if (command.isDefaultCommand) {
|
|
4730
|
+
shouldParse = false;
|
|
4731
|
+
const parsed = this.mri(argv.slice(2), command);
|
|
4732
|
+
this.setParsedInfo(parsed, command);
|
|
4733
|
+
this.dispatchEvent(new CustomEvent("command:!", {
|
|
4734
|
+
detail: command
|
|
4735
|
+
}));
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4738
|
+
if (shouldParse) {
|
|
4739
|
+
const parsed = this.mri(argv.slice(2));
|
|
4740
|
+
this.setParsedInfo(parsed);
|
|
4741
|
+
}
|
|
4742
|
+
if (this.options.help && this.showHelpOnExit) {
|
|
4743
|
+
this.outputHelp();
|
|
4744
|
+
run = false;
|
|
4745
|
+
this.unsetMatchedCommand();
|
|
4746
|
+
}
|
|
4747
|
+
if (this.options.version && this.showVersionOnExit && null == this.matchedCommandName) {
|
|
4748
|
+
this.outputVersion();
|
|
4749
|
+
run = false;
|
|
4750
|
+
this.unsetMatchedCommand();
|
|
4751
|
+
}
|
|
4752
|
+
const parsedArgv = {
|
|
4753
|
+
args: this.args,
|
|
4754
|
+
options: this.options
|
|
4755
|
+
};
|
|
4756
|
+
if (run) this.runMatchedCommand();
|
|
4757
|
+
if (!this.matchedCommand && this.args[0]) this.dispatchEvent(new CustomEvent("command:*", {
|
|
4758
|
+
detail: this.args[0]
|
|
4759
|
+
}));
|
|
4760
|
+
return parsedArgv;
|
|
4761
|
+
}
|
|
4762
|
+
mri(argv, command) {
|
|
4763
|
+
const cliOptions = [
|
|
4764
|
+
...this.globalCommand.options,
|
|
4765
|
+
...command ? command.options : []
|
|
4766
|
+
];
|
|
4767
|
+
const mriOptions = getMriOptions(cliOptions);
|
|
4768
|
+
let argsAfterDoubleDashes = [];
|
|
4769
|
+
const doubleDashesIndex = argv.indexOf("--");
|
|
4770
|
+
if (-1 !== doubleDashesIndex) {
|
|
4771
|
+
argsAfterDoubleDashes = argv.slice(doubleDashesIndex + 1);
|
|
4772
|
+
argv = argv.slice(0, doubleDashesIndex);
|
|
4773
|
+
}
|
|
4774
|
+
let parsed = lib_default(argv, mriOptions);
|
|
4775
|
+
parsed = Object.keys(parsed).reduce((res, name)=>({
|
|
4776
|
+
...res,
|
|
4777
|
+
[camelcaseOptionName(name)]: parsed[name]
|
|
4778
|
+
}), {
|
|
4779
|
+
_: []
|
|
4780
|
+
});
|
|
4781
|
+
const args = parsed._;
|
|
4782
|
+
const options = {
|
|
4783
|
+
"--": argsAfterDoubleDashes
|
|
4784
|
+
};
|
|
4785
|
+
const ignoreDefault = command && command.config.ignoreOptionDefaultValue ? command.config.ignoreOptionDefaultValue : this.globalCommand.config.ignoreOptionDefaultValue;
|
|
4786
|
+
const transforms = Object.create(null);
|
|
4787
|
+
for (const cliOption of cliOptions){
|
|
4788
|
+
if (!ignoreDefault && void 0 !== cliOption.config.default) for (const name of cliOption.names)options[name] = cliOption.config.default;
|
|
4789
|
+
if (Array.isArray(cliOption.config.type) && void 0 === transforms[cliOption.name]) {
|
|
4790
|
+
transforms[cliOption.name] = Object.create(null);
|
|
4791
|
+
transforms[cliOption.name].shouldTransform = true;
|
|
4792
|
+
transforms[cliOption.name].transformFunction = cliOption.config.type[0];
|
|
4793
|
+
}
|
|
4794
|
+
}
|
|
4795
|
+
for (const key of Object.keys(parsed))if ("_" !== key) {
|
|
4796
|
+
setDotProp(options, key.split("."), parsed[key]);
|
|
4797
|
+
setByType(options, transforms);
|
|
4798
|
+
}
|
|
4799
|
+
return {
|
|
4800
|
+
args,
|
|
4801
|
+
options
|
|
4802
|
+
};
|
|
4803
|
+
}
|
|
4804
|
+
runMatchedCommand() {
|
|
4805
|
+
const { args, options, matchedCommand: command } = this;
|
|
4806
|
+
if (!command || !command.commandAction) return;
|
|
4807
|
+
command.checkUnknownOptions();
|
|
4808
|
+
command.checkOptionValue();
|
|
4809
|
+
command.checkRequiredArgs();
|
|
4810
|
+
command.checkUnusedArgs();
|
|
4811
|
+
const actionArgs = [];
|
|
4812
|
+
command.args.forEach((arg, index)=>{
|
|
4813
|
+
if (arg.variadic) actionArgs.push(args.slice(index));
|
|
4814
|
+
else actionArgs.push(args[index]);
|
|
4815
|
+
});
|
|
4816
|
+
actionArgs.push(options);
|
|
4817
|
+
return command.commandAction.apply(this, actionArgs);
|
|
4818
|
+
}
|
|
4819
|
+
};
|
|
4820
|
+
const cac = (name = "")=>new CAC(name);
|
|
4821
|
+
export { default as node_path, join } from "node:path";
|
|
4822
|
+
export { logger } from "@rspress/shared/logger";
|
|
4823
|
+
export { default as node_fs } from "node:fs";
|
|
4824
|
+
export { DEFAULT_CONFIG_EXTENSIONS, DEFAULT_CONFIG_NAME } from "@rspress/shared/constants";
|
|
4825
|
+
export { default as promises } from "node:fs/promises";
|
|
4826
|
+
export { cac };
|