rsbuild-plugin-dts 0.21.0 → 0.21.2
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/350.js +367 -165
- package/dist/index.js +1 -1
- package/dist/tsc.js +8 -8
- package/dist/tsgo.js +4 -4
- package/dist/utils.d.ts +3 -3
- package/package.json +6 -6
package/dist/350.js
CHANGED
|
@@ -5,17 +5,18 @@ import { platform } from "node:os";
|
|
|
5
5
|
import node_path, { basename, dirname, extname, isAbsolute, join, normalize, relative as external_node_path_relative, resolve } from "node:path";
|
|
6
6
|
import { styleText } from "node:util";
|
|
7
7
|
import { logger } from "@rsbuild/core";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import * as __rspack_external_fs from "fs";
|
|
9
|
+
import { readdir, readdirSync, realpath, realpathSync, stat as external_fs_stat, statSync } from "fs";
|
|
10
|
+
import { basename as external_path_basename, dirname as external_path_dirname, isAbsolute as external_path_isAbsolute, normalize as external_path_normalize, posix, relative as external_path_relative, resolve as external_path_resolve, sep as external_path_sep } from "path";
|
|
10
11
|
import { fileURLToPath } from "url";
|
|
11
12
|
import { createRequire as external_module_createRequire } from "module";
|
|
12
13
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
13
14
|
import { createRequire as __rspack_createRequire } from "node:module";
|
|
14
15
|
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
15
16
|
__webpack_require__.add({
|
|
16
|
-
"../../node_modules/.pnpm/picomatch@4.0.
|
|
17
|
-
const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
18
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
17
|
+
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
18
|
+
const pico = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js");
|
|
19
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
19
20
|
function picomatch(glob, options, returnState = false) {
|
|
20
21
|
if (options && (null === options.windows || void 0 === options.windows)) options = {
|
|
21
22
|
...options,
|
|
@@ -26,9 +27,10 @@ __webpack_require__.add({
|
|
|
26
27
|
Object.assign(picomatch, pico);
|
|
27
28
|
module.exports = picomatch;
|
|
28
29
|
},
|
|
29
|
-
"../../node_modules/.pnpm/picomatch@4.0.
|
|
30
|
+
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js" (module) {
|
|
30
31
|
const WIN_SLASH = '\\\\/';
|
|
31
32
|
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
33
|
+
const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
|
|
32
34
|
const DOT_LITERAL = '\\.';
|
|
33
35
|
const PLUS_LITERAL = '\\+';
|
|
34
36
|
const QMARK_LITERAL = '\\?';
|
|
@@ -79,6 +81,7 @@ __webpack_require__.add({
|
|
|
79
81
|
SEP: '\\'
|
|
80
82
|
};
|
|
81
83
|
const POSIX_REGEX_SOURCE = {
|
|
84
|
+
__proto__: null,
|
|
82
85
|
alnum: 'a-zA-Z0-9',
|
|
83
86
|
alpha: 'a-zA-Z',
|
|
84
87
|
ascii: '\\x00-\\x7F',
|
|
@@ -95,6 +98,7 @@ __webpack_require__.add({
|
|
|
95
98
|
xdigit: 'A-Fa-f0-9'
|
|
96
99
|
};
|
|
97
100
|
module.exports = {
|
|
101
|
+
DEFAULT_MAX_EXTGLOB_RECURSION,
|
|
98
102
|
MAX_LENGTH: 65536,
|
|
99
103
|
POSIX_REGEX_SOURCE,
|
|
100
104
|
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
@@ -186,9 +190,9 @@ __webpack_require__.add({
|
|
|
186
190
|
}
|
|
187
191
|
};
|
|
188
192
|
},
|
|
189
|
-
"../../node_modules/.pnpm/picomatch@4.0.
|
|
190
|
-
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
191
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
193
|
+
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
194
|
+
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
195
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
192
196
|
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
193
197
|
const expandRange = (args, options)=>{
|
|
194
198
|
if ('function' == typeof options.expandRange) return options.expandRange(...args, options);
|
|
@@ -202,6 +206,189 @@ __webpack_require__.add({
|
|
|
202
206
|
return value;
|
|
203
207
|
};
|
|
204
208
|
const syntaxError = (type, char)=>`Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
209
|
+
const splitTopLevel = (input)=>{
|
|
210
|
+
const parts = [];
|
|
211
|
+
let bracket = 0;
|
|
212
|
+
let paren = 0;
|
|
213
|
+
let quote = 0;
|
|
214
|
+
let value = '';
|
|
215
|
+
let escaped = false;
|
|
216
|
+
for (const ch of input){
|
|
217
|
+
if (true === escaped) {
|
|
218
|
+
value += ch;
|
|
219
|
+
escaped = false;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if ('\\' === ch) {
|
|
223
|
+
value += ch;
|
|
224
|
+
escaped = true;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if ('"' === ch) {
|
|
228
|
+
quote = 1 === quote ? 0 : 1;
|
|
229
|
+
value += ch;
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
if (0 === quote) {
|
|
233
|
+
if ('[' === ch) bracket++;
|
|
234
|
+
else if (']' === ch && bracket > 0) bracket--;
|
|
235
|
+
else if (0 === bracket) {
|
|
236
|
+
if ('(' === ch) paren++;
|
|
237
|
+
else if (')' === ch && paren > 0) paren--;
|
|
238
|
+
else if ('|' === ch && 0 === paren) {
|
|
239
|
+
parts.push(value);
|
|
240
|
+
value = '';
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
value += ch;
|
|
246
|
+
}
|
|
247
|
+
parts.push(value);
|
|
248
|
+
return parts;
|
|
249
|
+
};
|
|
250
|
+
const isPlainBranch = (branch)=>{
|
|
251
|
+
let escaped = false;
|
|
252
|
+
for (const ch of branch){
|
|
253
|
+
if (true === escaped) {
|
|
254
|
+
escaped = false;
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
if ('\\' === ch) {
|
|
258
|
+
escaped = true;
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
if (/[?*+@!()[\]{}]/.test(ch)) return false;
|
|
262
|
+
}
|
|
263
|
+
return true;
|
|
264
|
+
};
|
|
265
|
+
const normalizeSimpleBranch = (branch)=>{
|
|
266
|
+
let value = branch.trim();
|
|
267
|
+
let changed = true;
|
|
268
|
+
while(true === changed){
|
|
269
|
+
changed = false;
|
|
270
|
+
if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
|
|
271
|
+
value = value.slice(2, -1);
|
|
272
|
+
changed = true;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
if (!isPlainBranch(value)) return;
|
|
276
|
+
return value.replace(/\\(.)/g, '$1');
|
|
277
|
+
};
|
|
278
|
+
const hasRepeatedCharPrefixOverlap = (branches)=>{
|
|
279
|
+
const values = branches.map(normalizeSimpleBranch).filter(Boolean);
|
|
280
|
+
for(let i = 0; i < values.length; i++)for(let j = i + 1; j < values.length; j++){
|
|
281
|
+
const a = values[i];
|
|
282
|
+
const b = values[j];
|
|
283
|
+
const char = a[0];
|
|
284
|
+
if (char && a === char.repeat(a.length) && b === char.repeat(b.length)) {
|
|
285
|
+
if (a === b || a.startsWith(b) || b.startsWith(a)) return true;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
return false;
|
|
289
|
+
};
|
|
290
|
+
const parseRepeatedExtglob = (pattern, requireEnd = true)=>{
|
|
291
|
+
if ('+' !== pattern[0] && '*' !== pattern[0] || '(' !== pattern[1]) return;
|
|
292
|
+
let bracket = 0;
|
|
293
|
+
let paren = 0;
|
|
294
|
+
let quote = 0;
|
|
295
|
+
let escaped = false;
|
|
296
|
+
for(let i = 1; i < pattern.length; i++){
|
|
297
|
+
const ch = pattern[i];
|
|
298
|
+
if (true === escaped) {
|
|
299
|
+
escaped = false;
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
if ('\\' === ch) {
|
|
303
|
+
escaped = true;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if ('"' === ch) {
|
|
307
|
+
quote = 1 === quote ? 0 : 1;
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (1 !== quote) {
|
|
311
|
+
if ('[' === ch) {
|
|
312
|
+
bracket++;
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (']' === ch && bracket > 0) {
|
|
316
|
+
bracket--;
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
if (!(bracket > 0)) {
|
|
320
|
+
if ('(' === ch) {
|
|
321
|
+
paren++;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (')' === ch) {
|
|
325
|
+
paren--;
|
|
326
|
+
if (0 === paren) {
|
|
327
|
+
if (true === requireEnd && i !== pattern.length - 1) return;
|
|
328
|
+
return {
|
|
329
|
+
type: pattern[0],
|
|
330
|
+
body: pattern.slice(2, i),
|
|
331
|
+
end: i
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
};
|
|
339
|
+
const getStarExtglobSequenceOutput = (pattern)=>{
|
|
340
|
+
let index = 0;
|
|
341
|
+
const chars = [];
|
|
342
|
+
while(index < pattern.length){
|
|
343
|
+
const match = parseRepeatedExtglob(pattern.slice(index), false);
|
|
344
|
+
if (!match || '*' !== match.type) return;
|
|
345
|
+
const branches = splitTopLevel(match.body).map((branch)=>branch.trim());
|
|
346
|
+
if (1 !== branches.length) return;
|
|
347
|
+
const branch = normalizeSimpleBranch(branches[0]);
|
|
348
|
+
if (!branch || 1 !== branch.length) return;
|
|
349
|
+
chars.push(branch);
|
|
350
|
+
index += match.end + 1;
|
|
351
|
+
}
|
|
352
|
+
if (chars.length < 1) return;
|
|
353
|
+
const source = 1 === chars.length ? utils.escapeRegex(chars[0]) : `[${chars.map((ch)=>utils.escapeRegex(ch)).join('')}]`;
|
|
354
|
+
return `${source}*`;
|
|
355
|
+
};
|
|
356
|
+
const repeatedExtglobRecursion = (pattern)=>{
|
|
357
|
+
let depth = 0;
|
|
358
|
+
let value = pattern.trim();
|
|
359
|
+
let match = parseRepeatedExtglob(value);
|
|
360
|
+
while(match){
|
|
361
|
+
depth++;
|
|
362
|
+
value = match.body.trim();
|
|
363
|
+
match = parseRepeatedExtglob(value);
|
|
364
|
+
}
|
|
365
|
+
return depth;
|
|
366
|
+
};
|
|
367
|
+
const analyzeRepeatedExtglob = (body, options)=>{
|
|
368
|
+
if (false === options.maxExtglobRecursion) return {
|
|
369
|
+
risky: false
|
|
370
|
+
};
|
|
371
|
+
const max = 'number' == typeof options.maxExtglobRecursion ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
|
|
372
|
+
const branches = splitTopLevel(body).map((branch)=>branch.trim());
|
|
373
|
+
if (branches.length > 1) {
|
|
374
|
+
if (branches.some((branch)=>'' === branch) || branches.some((branch)=>/^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) return {
|
|
375
|
+
risky: true
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
for (const branch of branches){
|
|
379
|
+
const safeOutput = getStarExtglobSequenceOutput(branch);
|
|
380
|
+
if (safeOutput) return {
|
|
381
|
+
risky: true,
|
|
382
|
+
safeOutput
|
|
383
|
+
};
|
|
384
|
+
if (repeatedExtglobRecursion(branch) > max) return {
|
|
385
|
+
risky: true
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
return {
|
|
389
|
+
risky: false
|
|
390
|
+
};
|
|
391
|
+
};
|
|
205
392
|
const parse = (input, options)=>{
|
|
206
393
|
if ('string' != typeof input) throw new TypeError('Expected a string');
|
|
207
394
|
input = REPLACEMENTS[input] || input;
|
|
@@ -317,6 +504,8 @@ __webpack_require__.add({
|
|
|
317
504
|
token.prev = prev;
|
|
318
505
|
token.parens = state.parens;
|
|
319
506
|
token.output = state.output;
|
|
507
|
+
token.startIndex = state.index;
|
|
508
|
+
token.tokensIndex = tokens.length;
|
|
320
509
|
const output = (opts.capture ? '(' : '') + token.open;
|
|
321
510
|
increment('parens');
|
|
322
511
|
push({
|
|
@@ -333,6 +522,31 @@ __webpack_require__.add({
|
|
|
333
522
|
extglobs.push(token);
|
|
334
523
|
};
|
|
335
524
|
const extglobClose = (token)=>{
|
|
525
|
+
const literal = input.slice(token.startIndex, state.index + 1);
|
|
526
|
+
const body = input.slice(token.startIndex + 2, state.index);
|
|
527
|
+
const analysis = analyzeRepeatedExtglob(body, opts);
|
|
528
|
+
if (('plus' === token.type || 'star' === token.type) && analysis.risky) {
|
|
529
|
+
const safeOutput = analysis.safeOutput ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
|
|
530
|
+
const open = tokens[token.tokensIndex];
|
|
531
|
+
open.type = 'text';
|
|
532
|
+
open.value = literal;
|
|
533
|
+
open.output = safeOutput || utils.escapeRegex(literal);
|
|
534
|
+
for(let i = token.tokensIndex + 1; i < tokens.length; i++){
|
|
535
|
+
tokens[i].value = '';
|
|
536
|
+
tokens[i].output = '';
|
|
537
|
+
delete tokens[i].suffix;
|
|
538
|
+
}
|
|
539
|
+
state.output = token.output + open.output;
|
|
540
|
+
state.backtrack = true;
|
|
541
|
+
push({
|
|
542
|
+
type: 'paren',
|
|
543
|
+
extglob: true,
|
|
544
|
+
value,
|
|
545
|
+
output: ''
|
|
546
|
+
});
|
|
547
|
+
decrement('parens');
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
336
550
|
let output = token.close + (opts.capture ? ')' : '');
|
|
337
551
|
let rest;
|
|
338
552
|
if ('negate' === token.type) {
|
|
@@ -974,11 +1188,11 @@ __webpack_require__.add({
|
|
|
974
1188
|
};
|
|
975
1189
|
module.exports = parse;
|
|
976
1190
|
},
|
|
977
|
-
"../../node_modules/.pnpm/picomatch@4.0.
|
|
978
|
-
const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
979
|
-
const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
980
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
981
|
-
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
1191
|
+
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/picomatch.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1192
|
+
const scan = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js");
|
|
1193
|
+
const parse = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/parse.js");
|
|
1194
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
1195
|
+
const constants = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
982
1196
|
const isObject = (val)=>val && 'object' == typeof val && !Array.isArray(val);
|
|
983
1197
|
const picomatch = (glob, options, returnState = false)=>{
|
|
984
1198
|
if (Array.isArray(glob)) {
|
|
@@ -1107,9 +1321,9 @@ __webpack_require__.add({
|
|
|
1107
1321
|
picomatch.constants = constants;
|
|
1108
1322
|
module.exports = picomatch;
|
|
1109
1323
|
},
|
|
1110
|
-
"../../node_modules/.pnpm/picomatch@4.0.
|
|
1111
|
-
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
1112
|
-
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
1324
|
+
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/scan.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1325
|
+
const utils = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js");
|
|
1326
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1113
1327
|
const isPathSeparator = (code)=>code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1114
1328
|
const depth = (token)=>{
|
|
1115
1329
|
if (true !== token.isPrefix) token.depth = token.isGlobstar ? 1 / 0 : 1;
|
|
@@ -1375,8 +1589,8 @@ __webpack_require__.add({
|
|
|
1375
1589
|
};
|
|
1376
1590
|
module.exports = scan;
|
|
1377
1591
|
},
|
|
1378
|
-
"../../node_modules/.pnpm/picomatch@4.0.
|
|
1379
|
-
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
1592
|
+
"../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/utils.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
1593
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/lib/constants.js");
|
|
1380
1594
|
exports.isObject = (val)=>null !== val && 'object' == typeof val && !Array.isArray(val);
|
|
1381
1595
|
exports.hasRegexChars = (str)=>REGEX_SPECIAL_CHARS.test(str);
|
|
1382
1596
|
exports.isRegexChar = (str)=>1 === str.length && exports.hasRegexChars(str);
|
|
@@ -1905,38 +2119,38 @@ var Builder = class {
|
|
|
1905
2119
|
return this;
|
|
1906
2120
|
}
|
|
1907
2121
|
};
|
|
1908
|
-
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.
|
|
2122
|
+
const picomatch = __webpack_require__("../../node_modules/.pnpm/picomatch@4.0.4/node_modules/picomatch/index.js");
|
|
1909
2123
|
const isReadonlyArray = Array.isArray;
|
|
2124
|
+
const BACKSLASHES = /\\/g;
|
|
1910
2125
|
const isWin = "win32" === process.platform;
|
|
1911
2126
|
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
1912
2127
|
function getPartialMatcher(patterns, options = {}) {
|
|
1913
2128
|
const patternsCount = patterns.length;
|
|
1914
2129
|
const patternsParts = Array(patternsCount);
|
|
1915
2130
|
const matchers = Array(patternsCount);
|
|
1916
|
-
|
|
1917
|
-
for(
|
|
2131
|
+
let i, j;
|
|
2132
|
+
for(i = 0; i < patternsCount; i++){
|
|
1918
2133
|
const parts = splitPattern(patterns[i]);
|
|
1919
2134
|
patternsParts[i] = parts;
|
|
1920
2135
|
const partsCount = parts.length;
|
|
1921
2136
|
const partMatchers = Array(partsCount);
|
|
1922
|
-
for(
|
|
2137
|
+
for(j = 0; j < partsCount; j++)partMatchers[j] = picomatch(parts[j], options);
|
|
1923
2138
|
matchers[i] = partMatchers;
|
|
1924
2139
|
}
|
|
1925
2140
|
return (input)=>{
|
|
1926
2141
|
const inputParts = input.split("/");
|
|
1927
2142
|
if (".." === inputParts[0] && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
1928
|
-
for(
|
|
2143
|
+
for(i = 0; i < patternsCount; i++){
|
|
1929
2144
|
const patternParts = patternsParts[i];
|
|
1930
2145
|
const matcher = matchers[i];
|
|
1931
2146
|
const inputPatternCount = inputParts.length;
|
|
1932
2147
|
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
1933
|
-
|
|
2148
|
+
j = 0;
|
|
1934
2149
|
while(j < minParts){
|
|
1935
2150
|
const part = patternParts[j];
|
|
1936
2151
|
if (part.includes("/")) return true;
|
|
1937
|
-
|
|
1938
|
-
if (!
|
|
1939
|
-
if (globstarEnabled && "**" === part) return true;
|
|
2152
|
+
if (!matcher[j](inputParts[j])) break;
|
|
2153
|
+
if (!options.noglobstar && "**" === part) return true;
|
|
1940
2154
|
j++;
|
|
1941
2155
|
}
|
|
1942
2156
|
if (j === inputPatternCount) return true;
|
|
@@ -1949,7 +2163,7 @@ const isRoot = isWin ? (p)=>WIN32_ROOT_DIR.test(p) : (p)=>"/" === p;
|
|
|
1949
2163
|
function buildFormat(cwd, root, absolute) {
|
|
1950
2164
|
if (cwd === root || root.startsWith(`${cwd}/`)) {
|
|
1951
2165
|
if (absolute) {
|
|
1952
|
-
const start =
|
|
2166
|
+
const start = cwd.length + +!isRoot(cwd);
|
|
1953
2167
|
return (p, isDir)=>p.slice(start, isDir ? -1 : void 0) || ".";
|
|
1954
2168
|
}
|
|
1955
2169
|
const prefix = root.slice(cwd.length + 1);
|
|
@@ -1970,32 +2184,31 @@ function buildRelative(cwd, root) {
|
|
|
1970
2184
|
}
|
|
1971
2185
|
return (p)=>{
|
|
1972
2186
|
const result = posix.relative(cwd, `${root}/${p}`);
|
|
1973
|
-
|
|
1974
|
-
return result || ".";
|
|
2187
|
+
return "/" === p[p.length - 1] && "" !== result ? `${result}/` : result || ".";
|
|
1975
2188
|
};
|
|
1976
2189
|
}
|
|
1977
2190
|
const splitPatternOptions = {
|
|
1978
2191
|
parts: true
|
|
1979
2192
|
};
|
|
1980
|
-
function splitPattern(path
|
|
2193
|
+
function splitPattern(path) {
|
|
1981
2194
|
var _result$parts;
|
|
1982
|
-
const result = picomatch.scan(path
|
|
2195
|
+
const result = picomatch.scan(path, splitPatternOptions);
|
|
1983
2196
|
return (null == (_result$parts = result.parts) ? void 0 : _result$parts.length) ? result.parts : [
|
|
1984
|
-
path
|
|
2197
|
+
path
|
|
1985
2198
|
];
|
|
1986
2199
|
}
|
|
1987
2200
|
const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
|
|
1988
|
-
function convertPosixPathToPattern(path
|
|
1989
|
-
return escapePosixPath(path
|
|
2201
|
+
function convertPosixPathToPattern(path) {
|
|
2202
|
+
return escapePosixPath(path);
|
|
1990
2203
|
}
|
|
1991
|
-
function convertWin32PathToPattern(path
|
|
1992
|
-
return escapeWin32Path(path
|
|
2204
|
+
function convertWin32PathToPattern(path) {
|
|
2205
|
+
return escapeWin32Path(path).replace(ESCAPED_WIN32_BACKSLASHES, "/");
|
|
1993
2206
|
}
|
|
1994
2207
|
const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
|
|
1995
2208
|
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
1996
2209
|
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
1997
|
-
const escapePosixPath = (path
|
|
1998
|
-
const escapeWin32Path = (path
|
|
2210
|
+
const escapePosixPath = (path)=>path.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2211
|
+
const escapeWin32Path = (path)=>path.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
1999
2212
|
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
2000
2213
|
function isDynamicPattern(pattern, options) {
|
|
2001
2214
|
if ((null == options ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
@@ -2005,27 +2218,33 @@ function isDynamicPattern(pattern, options) {
|
|
|
2005
2218
|
function log(...tasks) {
|
|
2006
2219
|
console.log(`[tinyglobby ${/* @__PURE__ */ new Date().toLocaleTimeString("es")}]`, ...tasks);
|
|
2007
2220
|
}
|
|
2221
|
+
function ensureStringArray(value) {
|
|
2222
|
+
return "string" == typeof value ? [
|
|
2223
|
+
value
|
|
2224
|
+
] : null != value ? value : [];
|
|
2225
|
+
}
|
|
2008
2226
|
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
2009
2227
|
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
2010
|
-
|
|
2011
|
-
|
|
2228
|
+
function normalizePattern(pattern, opts, props, isIgnore) {
|
|
2229
|
+
var _PARENT_DIRECTORY$exe;
|
|
2230
|
+
const cwd = opts.cwd;
|
|
2012
2231
|
let result = pattern;
|
|
2013
|
-
if (
|
|
2014
|
-
if (
|
|
2232
|
+
if ("/" === pattern[pattern.length - 1]) result = pattern.slice(0, -1);
|
|
2233
|
+
if ("*" !== result[result.length - 1] && opts.expandDirectories) result += "/**";
|
|
2015
2234
|
const escapedCwd = escapePath(cwd);
|
|
2016
|
-
result =
|
|
2017
|
-
const
|
|
2235
|
+
result = external_path_isAbsolute(result.replace(ESCAPING_BACKSLASHES, "")) ? posix.relative(escapedCwd, result) : posix.normalize(result);
|
|
2236
|
+
const parentDir = null == (_PARENT_DIRECTORY$exe = PARENT_DIRECTORY.exec(result)) ? void 0 : _PARENT_DIRECTORY$exe[0];
|
|
2018
2237
|
const parts = splitPattern(result);
|
|
2019
|
-
if (
|
|
2020
|
-
const n = (
|
|
2238
|
+
if (parentDir) {
|
|
2239
|
+
const n = (parentDir.length + 1) / 3;
|
|
2021
2240
|
let i = 0;
|
|
2022
2241
|
const cwdParts = escapedCwd.split("/");
|
|
2023
2242
|
while(i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]){
|
|
2024
2243
|
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2025
2244
|
i++;
|
|
2026
2245
|
}
|
|
2027
|
-
const potentialRoot = posix.join(cwd,
|
|
2028
|
-
if (
|
|
2246
|
+
const potentialRoot = posix.join(cwd, parentDir.slice(3 * i));
|
|
2247
|
+
if ("." !== potentialRoot[0] && props.root.length > potentialRoot.length) {
|
|
2029
2248
|
props.root = potentialRoot;
|
|
2030
2249
|
props.depthOffset = -n + i;
|
|
2031
2250
|
}
|
|
@@ -2040,7 +2259,7 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
2040
2259
|
newCommonPath.pop();
|
|
2041
2260
|
break;
|
|
2042
2261
|
}
|
|
2043
|
-
if (part !== props.commonPath[i] || isDynamicPattern(part)
|
|
2262
|
+
if (i === parts.length - 1 || part !== props.commonPath[i] || isDynamicPattern(part)) break;
|
|
2044
2263
|
newCommonPath.push(part);
|
|
2045
2264
|
}
|
|
2046
2265
|
props.depthOffset = newCommonPath.length;
|
|
@@ -2049,147 +2268,129 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
2049
2268
|
}
|
|
2050
2269
|
return result;
|
|
2051
2270
|
}
|
|
2052
|
-
function processPatterns(
|
|
2053
|
-
"**/*"
|
|
2054
|
-
], ignore = [], expandDirectories = true }, cwd, props) {
|
|
2055
|
-
if ("string" == typeof patterns) patterns = [
|
|
2056
|
-
patterns
|
|
2057
|
-
];
|
|
2058
|
-
if ("string" == typeof ignore) ignore = [
|
|
2059
|
-
ignore
|
|
2060
|
-
];
|
|
2271
|
+
function processPatterns(options, patterns, props) {
|
|
2061
2272
|
const matchPatterns = [];
|
|
2062
2273
|
const ignorePatterns = [];
|
|
2063
|
-
for (const pattern of ignore)if (pattern) {
|
|
2064
|
-
if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern,
|
|
2274
|
+
for (const pattern of options.ignore)if (pattern) {
|
|
2275
|
+
if ("!" !== pattern[0] || "(" === pattern[1]) ignorePatterns.push(normalizePattern(pattern, options, props, true));
|
|
2065
2276
|
}
|
|
2066
2277
|
for (const pattern of patterns)if (pattern) {
|
|
2067
|
-
if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern,
|
|
2068
|
-
else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1),
|
|
2278
|
+
if ("!" !== pattern[0] || "(" === pattern[1]) matchPatterns.push(normalizePattern(pattern, options, props, false));
|
|
2279
|
+
else if ("!" !== pattern[1] || "(" === pattern[2]) ignorePatterns.push(normalizePattern(pattern.slice(1), options, props, true));
|
|
2069
2280
|
}
|
|
2070
2281
|
return {
|
|
2071
2282
|
match: matchPatterns,
|
|
2072
2283
|
ignore: ignorePatterns
|
|
2073
2284
|
};
|
|
2074
2285
|
}
|
|
2075
|
-
function
|
|
2076
|
-
|
|
2077
|
-
const path$1 = paths[i];
|
|
2078
|
-
paths[i] = relative(path$1);
|
|
2079
|
-
}
|
|
2080
|
-
return paths;
|
|
2081
|
-
}
|
|
2082
|
-
function normalizeCwd(cwd) {
|
|
2083
|
-
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
|
|
2084
|
-
if (cwd instanceof URL) return fileURLToPath(cwd).replace(BACKSLASHES, "/");
|
|
2085
|
-
return path_0.resolve(cwd).replace(BACKSLASHES, "/");
|
|
2086
|
-
}
|
|
2087
|
-
function getCrawler(patterns, inputOptions = {}) {
|
|
2088
|
-
const options = process.env.TINYGLOBBY_DEBUG ? {
|
|
2089
|
-
...inputOptions,
|
|
2090
|
-
debug: true
|
|
2091
|
-
} : inputOptions;
|
|
2092
|
-
const cwd = normalizeCwd(options.cwd);
|
|
2093
|
-
if (options.debug) log("globbing with:", {
|
|
2094
|
-
patterns,
|
|
2095
|
-
options,
|
|
2096
|
-
cwd
|
|
2097
|
-
});
|
|
2098
|
-
if (Array.isArray(patterns) && 0 === patterns.length) return [
|
|
2099
|
-
{
|
|
2100
|
-
sync: ()=>[],
|
|
2101
|
-
withPromise: async ()=>[]
|
|
2102
|
-
},
|
|
2103
|
-
false
|
|
2104
|
-
];
|
|
2286
|
+
function buildCrawler(options, patterns) {
|
|
2287
|
+
const cwd = options.cwd;
|
|
2105
2288
|
const props = {
|
|
2106
2289
|
root: cwd,
|
|
2107
|
-
commonPath: null,
|
|
2108
2290
|
depthOffset: 0
|
|
2109
2291
|
};
|
|
2110
|
-
const processed = processPatterns(
|
|
2111
|
-
...options,
|
|
2112
|
-
patterns
|
|
2113
|
-
}, cwd, props);
|
|
2292
|
+
const processed = processPatterns(options, patterns, props);
|
|
2114
2293
|
if (options.debug) log("internal processing patterns:", processed);
|
|
2294
|
+
const { absolute, caseSensitiveMatch, debug, dot, followSymbolicLinks, onlyDirectories } = options;
|
|
2295
|
+
const root = props.root.replace(BACKSLASHES, "");
|
|
2115
2296
|
const matchOptions = {
|
|
2116
|
-
dot
|
|
2297
|
+
dot,
|
|
2117
2298
|
nobrace: false === options.braceExpansion,
|
|
2118
|
-
nocase:
|
|
2299
|
+
nocase: !caseSensitiveMatch,
|
|
2119
2300
|
noextglob: false === options.extglob,
|
|
2120
2301
|
noglobstar: false === options.globstar,
|
|
2121
2302
|
posix: true
|
|
2122
2303
|
};
|
|
2123
|
-
const matcher = picomatch(processed.match,
|
|
2124
|
-
...matchOptions,
|
|
2125
|
-
ignore: processed.ignore
|
|
2126
|
-
});
|
|
2304
|
+
const matcher = picomatch(processed.match, matchOptions);
|
|
2127
2305
|
const ignore = picomatch(processed.ignore, matchOptions);
|
|
2128
2306
|
const partialMatcher = getPartialMatcher(processed.match, matchOptions);
|
|
2129
|
-
const format = buildFormat(cwd,
|
|
2130
|
-
const
|
|
2131
|
-
const
|
|
2307
|
+
const format = buildFormat(cwd, root, absolute);
|
|
2308
|
+
const excludeFormatter = absolute ? format : buildFormat(cwd, root, true);
|
|
2309
|
+
const excludePredicate = (_, p)=>{
|
|
2310
|
+
const relativePath = excludeFormatter(p, true);
|
|
2311
|
+
return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2312
|
+
};
|
|
2313
|
+
let maxDepth;
|
|
2314
|
+
if (void 0 !== options.deep) maxDepth = Math.round(options.deep - props.depthOffset);
|
|
2315
|
+
const crawler = new Builder({
|
|
2132
2316
|
filters: [
|
|
2133
|
-
|
|
2134
|
-
const path
|
|
2135
|
-
const matches = matcher(path
|
|
2136
|
-
if (matches) log(`matched ${path
|
|
2317
|
+
debug ? (p, isDirectory)=>{
|
|
2318
|
+
const path = format(p, isDirectory);
|
|
2319
|
+
const matches = matcher(path) && !ignore(path);
|
|
2320
|
+
if (matches) log(`matched ${path}`);
|
|
2137
2321
|
return matches;
|
|
2138
|
-
} : (p, isDirectory)=>
|
|
2322
|
+
} : (p, isDirectory)=>{
|
|
2323
|
+
const path = format(p, isDirectory);
|
|
2324
|
+
return matcher(path) && !ignore(path);
|
|
2325
|
+
}
|
|
2139
2326
|
],
|
|
2140
|
-
exclude:
|
|
2141
|
-
const
|
|
2142
|
-
|
|
2143
|
-
skipped ? log(`skipped ${p}`) : log(`crawling ${p}`);
|
|
2327
|
+
exclude: debug ? (_, p)=>{
|
|
2328
|
+
const skipped = excludePredicate(_, p);
|
|
2329
|
+
log(`${skipped ? "skipped" : "crawling"} ${p}`);
|
|
2144
2330
|
return skipped;
|
|
2145
|
-
} :
|
|
2146
|
-
|
|
2147
|
-
return "." !== relativePath && !partialMatcher(relativePath) || ignore(relativePath);
|
|
2148
|
-
},
|
|
2149
|
-
fs: options.fs ? {
|
|
2150
|
-
readdir: options.fs.readdir || fs_0.readdir,
|
|
2151
|
-
readdirSync: options.fs.readdirSync || fs_0.readdirSync,
|
|
2152
|
-
realpath: options.fs.realpath || fs_0.realpath,
|
|
2153
|
-
realpathSync: options.fs.realpathSync || fs_0.realpathSync,
|
|
2154
|
-
stat: options.fs.stat || fs_0.stat,
|
|
2155
|
-
statSync: options.fs.statSync || fs_0.statSync
|
|
2156
|
-
} : void 0,
|
|
2331
|
+
} : excludePredicate,
|
|
2332
|
+
fs: options.fs,
|
|
2157
2333
|
pathSeparator: "/",
|
|
2158
|
-
relativePaths:
|
|
2159
|
-
|
|
2334
|
+
relativePaths: !absolute,
|
|
2335
|
+
resolvePaths: absolute,
|
|
2336
|
+
includeBasePath: absolute,
|
|
2337
|
+
resolveSymlinks: followSymbolicLinks,
|
|
2338
|
+
excludeSymlinks: !followSymbolicLinks,
|
|
2339
|
+
excludeFiles: onlyDirectories,
|
|
2340
|
+
includeDirs: onlyDirectories || !options.onlyFiles,
|
|
2341
|
+
maxDepth,
|
|
2160
2342
|
signal: options.signal
|
|
2161
|
-
};
|
|
2162
|
-
if (
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
fdirOptions.includeBasePath = true;
|
|
2167
|
-
}
|
|
2168
|
-
if (false === options.followSymbolicLinks) {
|
|
2169
|
-
fdirOptions.resolveSymlinks = false;
|
|
2170
|
-
fdirOptions.excludeSymlinks = true;
|
|
2171
|
-
}
|
|
2172
|
-
if (options.onlyDirectories) {
|
|
2173
|
-
fdirOptions.excludeFiles = true;
|
|
2174
|
-
fdirOptions.includeDirs = true;
|
|
2175
|
-
} else if (false === options.onlyFiles) fdirOptions.includeDirs = true;
|
|
2176
|
-
props.root = props.root.replace(BACKSLASHES, "");
|
|
2177
|
-
const root = props.root;
|
|
2178
|
-
if (options.debug) log("internal properties:", props);
|
|
2179
|
-
const relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
|
|
2343
|
+
}).crawl(root);
|
|
2344
|
+
if (options.debug) log("internal properties:", {
|
|
2345
|
+
...props,
|
|
2346
|
+
root
|
|
2347
|
+
});
|
|
2180
2348
|
return [
|
|
2181
|
-
|
|
2182
|
-
|
|
2349
|
+
crawler,
|
|
2350
|
+
cwd !== root && !absolute && buildRelative(cwd, root)
|
|
2183
2351
|
];
|
|
2184
2352
|
}
|
|
2185
|
-
|
|
2186
|
-
if (
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2353
|
+
function formatPaths(paths, mapper) {
|
|
2354
|
+
if (mapper) for(let i = paths.length - 1; i >= 0; i--)paths[i] = mapper(paths[i]);
|
|
2355
|
+
return paths;
|
|
2356
|
+
}
|
|
2357
|
+
const defaultOptions = {
|
|
2358
|
+
caseSensitiveMatch: true,
|
|
2359
|
+
cwd: process.cwd(),
|
|
2360
|
+
debug: !!process.env.TINYGLOBBY_DEBUG,
|
|
2361
|
+
expandDirectories: true,
|
|
2362
|
+
followSymbolicLinks: true,
|
|
2363
|
+
onlyFiles: true
|
|
2364
|
+
};
|
|
2365
|
+
function getOptions(options) {
|
|
2366
|
+
const opts = {
|
|
2367
|
+
...defaultOptions,
|
|
2368
|
+
...options
|
|
2369
|
+
};
|
|
2370
|
+
opts.cwd = (opts.cwd instanceof URL ? fileURLToPath(opts.cwd) : external_path_resolve(opts.cwd)).replace(BACKSLASHES, "/");
|
|
2371
|
+
opts.ignore = ensureStringArray(opts.ignore);
|
|
2372
|
+
opts.fs && (opts.fs = {
|
|
2373
|
+
readdir: opts.fs.readdir || readdir,
|
|
2374
|
+
readdirSync: opts.fs.readdirSync || readdirSync,
|
|
2375
|
+
realpath: opts.fs.realpath || realpath,
|
|
2376
|
+
realpathSync: opts.fs.realpathSync || realpathSync,
|
|
2377
|
+
stat: opts.fs.stat || external_fs_stat,
|
|
2378
|
+
statSync: opts.fs.statSync || statSync
|
|
2379
|
+
});
|
|
2380
|
+
if (opts.debug) log("globbing with options:", opts);
|
|
2381
|
+
return opts;
|
|
2382
|
+
}
|
|
2383
|
+
function getCrawler(globInput, inputOptions = {}) {
|
|
2384
|
+
var _ref;
|
|
2385
|
+
if (globInput && (null == inputOptions ? void 0 : inputOptions.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
2386
|
+
const isModern = isReadonlyArray(globInput) || "string" == typeof globInput;
|
|
2387
|
+
const patterns = ensureStringArray(null != (_ref = isModern ? globInput : globInput.patterns) ? _ref : "**/*");
|
|
2388
|
+
const options = getOptions(isModern ? inputOptions : globInput);
|
|
2389
|
+
return patterns.length > 0 ? buildCrawler(options, patterns) : [];
|
|
2390
|
+
}
|
|
2391
|
+
async function glob(globInput, options) {
|
|
2392
|
+
const [crawler, relative] = getCrawler(globInput, options);
|
|
2393
|
+
return crawler ? formatPaths(await crawler.withPromise(), relative) : [];
|
|
2193
2394
|
}
|
|
2194
2395
|
const index_js_namespaceObject = __rspack_createRequire_require("../compiled/tsconfig-paths/index.js");
|
|
2195
2396
|
var comma = ",".charCodeAt(0);
|
|
@@ -3476,7 +3677,7 @@ async function redirectDtsImports(dtsFile, dtsExtension, redirect, matchPath, ou
|
|
|
3476
3677
|
}
|
|
3477
3678
|
if (code.hasChanged()) await promises.writeFile(dtsFile, code.toString());
|
|
3478
3679
|
}
|
|
3479
|
-
async function processDtsFiles(bundle, dir, dtsExtension, redirect, tsconfigPath, rootDir, paths, banner, footer) {
|
|
3680
|
+
async function processDtsFiles(bundle, cwd, dir, dtsExtension, redirect, tsconfigPath, rootDir, paths, banner, footer) {
|
|
3480
3681
|
if (bundle) return;
|
|
3481
3682
|
let matchPath;
|
|
3482
3683
|
if (redirect.path || redirect.extension) {
|
|
@@ -3486,7 +3687,7 @@ async function processDtsFiles(bundle, dir, dtsExtension, redirect, tsconfigPath
|
|
|
3486
3687
|
const mainFields = [];
|
|
3487
3688
|
matchPath = (0, index_js_namespaceObject.createMatchPath)(absoluteBaseUrl, paths, mainFields, addMatchAll);
|
|
3488
3689
|
}
|
|
3489
|
-
const dtsFiles = await globDtsFiles(dir, [
|
|
3690
|
+
const dtsFiles = await globDtsFiles(cwd, dir, [
|
|
3490
3691
|
`/**/*${dtsExtension}`
|
|
3491
3692
|
]);
|
|
3492
3693
|
await Promise.all(dtsFiles.map(async (file)=>{
|
|
@@ -3533,14 +3734,15 @@ async function calcLongestCommonPath(absPaths) {
|
|
|
3533
3734
|
if (stats?.isFile()) lca = node_path.dirname(lca);
|
|
3534
3735
|
return lca;
|
|
3535
3736
|
}
|
|
3536
|
-
const globDtsFiles = async (dir, patterns)=>{
|
|
3737
|
+
const globDtsFiles = async (cwd, dir, patterns)=>{
|
|
3537
3738
|
const dtsFiles = await Promise.all(patterns.map(async (pattern)=>glob(convertPath(join(dir, pattern)), {
|
|
3739
|
+
cwd,
|
|
3538
3740
|
absolute: true,
|
|
3539
3741
|
dot: true
|
|
3540
3742
|
})));
|
|
3541
3743
|
return dtsFiles.flat();
|
|
3542
3744
|
};
|
|
3543
|
-
async function cleanDtsFiles(dir) {
|
|
3745
|
+
async function cleanDtsFiles(cwd, dir) {
|
|
3544
3746
|
const patterns = [
|
|
3545
3747
|
'/**/*.d.ts',
|
|
3546
3748
|
'/**/*.d.cts',
|
|
@@ -3549,7 +3751,7 @@ async function cleanDtsFiles(dir) {
|
|
|
3549
3751
|
'/**/*.d.cts.map',
|
|
3550
3752
|
'/**/*.d.mts.map'
|
|
3551
3753
|
];
|
|
3552
|
-
const allFiles = await globDtsFiles(dir, patterns);
|
|
3754
|
+
const allFiles = await globDtsFiles(cwd, dir, patterns);
|
|
3553
3755
|
await Promise.all(allFiles.map(async (file)=>promises.rm(file, {
|
|
3554
3756
|
force: true
|
|
3555
3757
|
})));
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,7 @@ const pluginDts = (options = {})=>({
|
|
|
43
43
|
const dtsEmitPath = getDtsEmitPath(options.distPath, declarationDir, distPathRoot);
|
|
44
44
|
warnIfOutside(cwd, declarationDir, 'declarationDir');
|
|
45
45
|
warnIfOutside(cwd, outDir, 'outDir');
|
|
46
|
-
if (false !== config.output.cleanDistPath) await cleanDtsFiles(dtsEmitPath);
|
|
46
|
+
if (false !== config.output.cleanDistPath) await cleanDtsFiles(cwd, dtsEmitPath);
|
|
47
47
|
if (bundle) await clearTempDeclarationDir(cwd);
|
|
48
48
|
if (composite || incremental || options.build) await cleanTsBuildInfoFile(tsconfigPath, rawCompilerOptions);
|
|
49
49
|
const jsExtension = extname(import.meta.filename);
|
package/dist/tsc.js
CHANGED
|
@@ -6,7 +6,7 @@ const formatHost = {
|
|
|
6
6
|
getCurrentDirectory: ts.sys.getCurrentDirectory.bind(ts.sys),
|
|
7
7
|
getNewLine: ()=>ts.sys.newLine
|
|
8
8
|
};
|
|
9
|
-
async function handleDiagnosticsAndProcessFiles(diagnostics, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name) {
|
|
9
|
+
async function handleDiagnosticsAndProcessFiles(diagnostics, configPath, bundle, cwd, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name) {
|
|
10
10
|
const diagnosticMessages = [];
|
|
11
11
|
for (const diagnostic of diagnostics){
|
|
12
12
|
const message = ts.formatDiagnosticsWithColorAndContext([
|
|
@@ -14,7 +14,7 @@ async function handleDiagnosticsAndProcessFiles(diagnostics, configPath, bundle,
|
|
|
14
14
|
], formatHost);
|
|
15
15
|
diagnosticMessages.push(message);
|
|
16
16
|
}
|
|
17
|
-
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
17
|
+
await processDtsFiles(bundle, cwd, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
18
18
|
if (diagnosticMessages.length) {
|
|
19
19
|
for (const message of diagnosticMessages)logger.error(logPrefixTsc, message);
|
|
20
20
|
const error = new Error(`Failed to generate declaration files. ${color.dim(`(${name})`)}`);
|
|
@@ -24,7 +24,7 @@ async function handleDiagnosticsAndProcessFiles(diagnostics, configPath, bundle,
|
|
|
24
24
|
}
|
|
25
25
|
async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false, build = false) {
|
|
26
26
|
const start = Date.now();
|
|
27
|
-
const { configPath, tsConfigResult, declarationDir, name, dtsExtension, rootDir, banner, footer, paths, redirect } = options;
|
|
27
|
+
const { configPath, tsConfigResult, declarationDir, name, dtsExtension, rootDir, cwd, banner, footer, paths, redirect } = options;
|
|
28
28
|
const { options: rawCompilerOptions, fileNames, projectReferences } = tsConfigResult;
|
|
29
29
|
const compilerOptions = {
|
|
30
30
|
...rawCompilerOptions,
|
|
@@ -49,11 +49,11 @@ async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false,
|
|
|
49
49
|
logger.info(logPrefixTsc, message);
|
|
50
50
|
onComplete(true);
|
|
51
51
|
}
|
|
52
|
-
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
52
|
+
await processDtsFiles(bundle, cwd, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
53
53
|
}
|
|
54
54
|
if (6193 === diagnostic.code) {
|
|
55
55
|
logger.error(logPrefixTsc, message);
|
|
56
|
-
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
56
|
+
await processDtsFiles(bundle, cwd, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
const system = {
|
|
@@ -100,7 +100,7 @@ async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false,
|
|
|
100
100
|
const emitResult = program.emit();
|
|
101
101
|
allDiagnostics.push(...emitResult.diagnostics);
|
|
102
102
|
const sortAndDeduplicateDiagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
|
|
103
|
-
await handleDiagnosticsAndProcessFiles(sortAndDeduplicateDiagnostics, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
103
|
+
await handleDiagnosticsAndProcessFiles(sortAndDeduplicateDiagnostics, configPath, bundle, cwd, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
104
104
|
} else {
|
|
105
105
|
let errorNumber = 0;
|
|
106
106
|
const reportErrorSummary = (errorCount)=>{
|
|
@@ -111,7 +111,7 @@ async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false,
|
|
|
111
111
|
configPath
|
|
112
112
|
], compilerOptions);
|
|
113
113
|
solutionBuilder.build();
|
|
114
|
-
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
114
|
+
await processDtsFiles(bundle, cwd, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
115
115
|
if (errorNumber > 0) {
|
|
116
116
|
const error = new Error(`Failed to generate declaration files. ${color.dim(`(${name})`)}`);
|
|
117
117
|
error.stack = '';
|
|
@@ -139,7 +139,7 @@ async function emitDtsTsc(options, onComplete, bundle = false, isWatch = false,
|
|
|
139
139
|
const emitResult = program.emit();
|
|
140
140
|
const allDiagnostics = preEmitDiagnostics.concat(emitResult.diagnostics);
|
|
141
141
|
const sortAndDeduplicateDiagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
|
|
142
|
-
await handleDiagnosticsAndProcessFiles(sortAndDeduplicateDiagnostics, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
142
|
+
await handleDiagnosticsAndProcessFiles(sortAndDeduplicateDiagnostics, configPath, bundle, cwd, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
143
143
|
}
|
|
144
144
|
if (bundle) logger.info(`declaration files prepared in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
145
145
|
else logger.ready(`declaration files generated in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
package/dist/tsgo.js
CHANGED
|
@@ -29,9 +29,9 @@ const generateTsgoArgs = (configPath, declarationDir, build, isWatch)=>{
|
|
|
29
29
|
args.push('--emitDeclarationOnly');
|
|
30
30
|
return args;
|
|
31
31
|
};
|
|
32
|
-
async function handleDiagnosticsAndProcessFiles(isWatch, hasErrors, tsConfigResult, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name) {
|
|
32
|
+
async function handleDiagnosticsAndProcessFiles(isWatch, hasErrors, tsConfigResult, configPath, bundle, cwd, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name) {
|
|
33
33
|
if (!bundle) {
|
|
34
|
-
const dtsFiles = await globDtsFiles(declarationDir, [
|
|
34
|
+
const dtsFiles = await globDtsFiles(cwd, declarationDir, [
|
|
35
35
|
'/**/*.d.ts',
|
|
36
36
|
'/**/*.d.ts.map'
|
|
37
37
|
]);
|
|
@@ -45,7 +45,7 @@ async function handleDiagnosticsAndProcessFiles(isWatch, hasErrors, tsConfigResu
|
|
|
45
45
|
}
|
|
46
46
|
}));
|
|
47
47
|
}
|
|
48
|
-
await processDtsFiles(bundle, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
48
|
+
await processDtsFiles(bundle, cwd, declarationDir, dtsExtension, redirect, configPath, rootDir, paths, banner, footer);
|
|
49
49
|
if (hasErrors && !isWatch) {
|
|
50
50
|
const error = new Error(`Failed to generate declaration files. ${color.dim(`(${name})`)}`);
|
|
51
51
|
error.stack = '';
|
|
@@ -84,7 +84,7 @@ async function emitDtsTsgo(options, _onComplete, bundle = false, isWatch = false
|
|
|
84
84
|
childProcess.on('close', async (code)=>{
|
|
85
85
|
try {
|
|
86
86
|
if (0 !== code) hasErrors = true;
|
|
87
|
-
await handleDiagnosticsAndProcessFiles(isWatch, hasErrors, tsConfigResult, configPath, bundle, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
87
|
+
await handleDiagnosticsAndProcessFiles(isWatch, hasErrors, tsConfigResult, configPath, bundle, cwd, declarationDir, dtsExtension, redirect, rootDir, paths, banner, footer, name);
|
|
88
88
|
if (!hasErrors) if (bundle) logger.info(`declaration files prepared with tsgo in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
89
89
|
else logger.ready(`declaration files generated with tsgo in ${getTimeCost(start)} ${color.dim(`(${name})`)}`);
|
|
90
90
|
resolve(hasErrors);
|
package/dist/utils.d.ts
CHANGED
|
@@ -27,11 +27,11 @@ export declare const prettyTime: (seconds: number) => string;
|
|
|
27
27
|
export declare function getTimeCost(start: number): string;
|
|
28
28
|
export declare function addBannerAndFooter(dtsFile: string, banner?: string, footer?: string): Promise<void>;
|
|
29
29
|
export declare function redirectDtsImports(dtsFile: string, dtsExtension: string, redirect: DtsRedirect, matchPath: MatchPath, outDir: string, rootDir: string): Promise<void>;
|
|
30
|
-
export declare function processDtsFiles(bundle: boolean, dir: string, dtsExtension: string, redirect: DtsRedirect, tsconfigPath: string, rootDir: string, paths: Record<string, string[]>, banner?: string, footer?: string): Promise<void>;
|
|
30
|
+
export declare function processDtsFiles(bundle: boolean, cwd: string, dir: string, dtsExtension: string, redirect: DtsRedirect, tsconfigPath: string, rootDir: string, paths: Record<string, string[]>, banner?: string, footer?: string): Promise<void>;
|
|
31
31
|
export declare function processSourceEntry(bundle: boolean, entryConfig: NonNullable<RsbuildConfig['source']>['entry']): DtsEntry[];
|
|
32
32
|
export declare function calcLongestCommonPath(absPaths: string[]): Promise<string | null>;
|
|
33
|
-
export declare const globDtsFiles: (dir: string, patterns: string[]) => Promise<string[]>;
|
|
34
|
-
export declare function cleanDtsFiles(dir: string): Promise<void>;
|
|
33
|
+
export declare const globDtsFiles: (cwd: string, dir: string, patterns: string[]) => Promise<string[]>;
|
|
34
|
+
export declare function cleanDtsFiles(cwd: string, dir: string): Promise<void>;
|
|
35
35
|
export declare function cleanTsBuildInfoFile(tsconfigPath: string, compilerOptions: CompilerOptions): Promise<void>;
|
|
36
36
|
export declare function getDtsEmitPath(pathFromPlugin: string | undefined, declarationDir: string | undefined, distPathRoot: string): string;
|
|
37
37
|
export declare function warnIfOutside(cwd: string, dir: string | undefined, label: string): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-dts",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"description": "Rsbuild plugin that supports emitting declaration files for TypeScript.",
|
|
5
5
|
"homepage": "https://rslib.rs",
|
|
6
6
|
"bugs": {
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"@ast-grep/napi": "0.37.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@microsoft/api-extractor": "^7.58.
|
|
33
|
-
"@rsbuild/core": "2.0.0-rc.
|
|
34
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
32
|
+
"@microsoft/api-extractor": "^7.58.2",
|
|
33
|
+
"@rsbuild/core": "2.0.0-rc.3",
|
|
34
|
+
"@typescript/native-preview": "7.0.0-dev.20260415.1",
|
|
35
35
|
"magic-string": "^0.30.21",
|
|
36
36
|
"prebundle": "1.6.4",
|
|
37
37
|
"rsbuild-plugin-publint": "^0.3.4",
|
|
38
|
-
"rslib": "npm:@rslib/core@0.
|
|
39
|
-
"tinyglobby": "^0.2.
|
|
38
|
+
"rslib": "npm:@rslib/core@0.21.1",
|
|
39
|
+
"tinyglobby": "^0.2.16",
|
|
40
40
|
"tsconfig-paths": "^4.2.0",
|
|
41
41
|
"typescript": "^6.0.2",
|
|
42
42
|
"@rslib/tsconfig": "0.0.1"
|