@visulima/fs 5.0.0-alpha.9 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/CHANGELOG.md +461 -0
  2. package/LICENSE.md +81 -4
  3. package/README.md +65 -0
  4. package/dist/eol.d.ts +30 -0
  5. package/dist/eol.js +3 -26
  6. package/dist/error.d.ts +243 -13
  7. package/dist/error.js +1 -7
  8. package/dist/glob-parent.d.ts +30 -0
  9. package/dist/glob-parent.js +1 -90
  10. package/dist/glob.d.ts +3 -4
  11. package/dist/glob.js +1 -2
  12. package/dist/index.d.ts +877 -28
  13. package/dist/index.js +1 -38
  14. package/dist/ini.d.ts +64 -4
  15. package/dist/ini.js +1 -4
  16. package/dist/is-glob.d.ts +29 -0
  17. package/dist/is-glob.js +1 -9
  18. package/dist/json5.d.ts +28 -4
  19. package/dist/json5.js +1 -4
  20. package/dist/jsonc.d.ts +59 -4
  21. package/dist/jsonc.js +1 -4
  22. package/dist/match.d.ts +77 -2
  23. package/dist/match.js +1 -15
  24. package/dist/packem_shared/AlreadyExistsError-DEb3UWja.js +1 -0
  25. package/dist/packem_shared/DirectoryError-BtwSTLmT.js +1 -0
  26. package/dist/packem_shared/FIND_UP_STOP-CAwY1qU7.js +1 -0
  27. package/dist/packem_shared/JSONError-Cvp9ycba.js +4 -0
  28. package/dist/packem_shared/NotEmptyError-DZ1Ix089.js +1 -0
  29. package/dist/packem_shared/NotFoundError-CnRY6lVp.js +1 -0
  30. package/dist/packem_shared/PermissionError-DJ_2VWEj.js +1 -0
  31. package/dist/packem_shared/WalkError-B8qTd-v-.js +1 -0
  32. package/dist/packem_shared/_commonjsHelpers-CWAkuNXM.js +1 -0
  33. package/dist/packem_shared/assertValidFileContents-CbIN7sy7.js +1 -0
  34. package/dist/packem_shared/assertValidFileOrDirectoryPath-BTlt945W.js +1 -0
  35. package/dist/packem_shared/build-rm-options-avnusYx-.js +1 -0
  36. package/dist/packem_shared/collect-CIKDOMiD.js +1 -0
  37. package/dist/packem_shared/collectSync-D0FRLLqg.js +1 -0
  38. package/dist/packem_shared/copy-Beb64BYG.js +1 -0
  39. package/dist/packem_shared/copySync-CagcIEBi.js +1 -0
  40. package/dist/packem_shared/emptyDir-C7lyd1lW.js +1 -0
  41. package/dist/packem_shared/emptyDirSync-B8EYpmO9.js +1 -0
  42. package/dist/packem_shared/ensureDir-DGarVZw8.js +1 -0
  43. package/dist/packem_shared/ensureDirSync-CsgPrsDH.js +1 -0
  44. package/dist/packem_shared/ensureFile-CMugWljp.js +1 -0
  45. package/dist/packem_shared/ensureFileSync-CJYTEx2r.js +1 -0
  46. package/dist/packem_shared/ensureLink-ChShf3lf.js +1 -0
  47. package/dist/packem_shared/ensureLinkSync-DPpq0I2Z.js +1 -0
  48. package/dist/packem_shared/ensureSymlink-y4FZjfxA.js +1 -0
  49. package/dist/packem_shared/ensureSymlinkSync-TcHssCH7.js +1 -0
  50. package/dist/packem_shared/findUp-Cii5ATt5.js +1 -0
  51. package/dist/packem_shared/findUpSync-C9Lkh7-v.js +1 -0
  52. package/dist/packem_shared/get-file-info-type-DzWpohDB.js +1 -0
  53. package/dist/packem_shared/glob-DMbPwGSj.js +1 -0
  54. package/dist/packem_shared/glob-sync.d-hXe38TnZ.d.ts +54 -0
  55. package/dist/packem_shared/globSync-DiP2rtGn.js +1 -0
  56. package/dist/packem_shared/index-B2MhYg3r.js +1 -0
  57. package/dist/packem_shared/index-BHy3Kcr7.js +11 -0
  58. package/dist/packem_shared/index-Ct4GqZSP.js +1 -0
  59. package/dist/packem_shared/index-LUKYN3u3.js +1 -0
  60. package/dist/packem_shared/ini-preserve-D1DopDLd.js +4 -0
  61. package/dist/packem_shared/is-stats-identical-l1GRN4Qu.js +1 -0
  62. package/dist/packem_shared/isAccessible-PmWJhV6I.js +1 -0
  63. package/dist/packem_shared/isAccessibleSync-BrbOtwdr.js +1 -0
  64. package/dist/packem_shared/json-error.d-DVILOyHc.d.ts +52 -0
  65. package/dist/packem_shared/jsonc-merge-Bkw73TLW.js +2 -0
  66. package/dist/packem_shared/map-read-error-CR3rQUxx.js +1 -0
  67. package/dist/packem_shared/move-DopmzT-2.js +1 -0
  68. package/dist/packem_shared/parseJson-EASgP4J9.js +1 -0
  69. package/dist/packem_shared/readFile-BswaBgM0.js +1 -0
  70. package/dist/packem_shared/readFileSync-_fDF6Oj1.js +1 -0
  71. package/dist/packem_shared/readIni-BsXudu2r.js +1 -0
  72. package/dist/packem_shared/readIniSync-DKwRbbs9.js +1 -0
  73. package/dist/packem_shared/readJson-CcAsHxE5.js +1 -0
  74. package/dist/packem_shared/readJson5-CM1TIiHd.js +1 -0
  75. package/dist/packem_shared/readJson5Sync-Bc26c3Fy.js +1 -0
  76. package/dist/packem_shared/readJsonSync-DuMMeB3s.js +1 -0
  77. package/dist/packem_shared/readJsonc-BZjMw_0f.js +1 -0
  78. package/dist/packem_shared/readJsoncSync-C-xzeZz4.js +1 -0
  79. package/dist/packem_shared/readToml-D4jpe9q_.js +1 -0
  80. package/dist/packem_shared/readTomlSync-B5PIYT9z.js +1 -0
  81. package/dist/packem_shared/readYaml-DvPxndW_.js +1 -0
  82. package/dist/packem_shared/readYamlSync-DZ-0hSbZ.js +1 -0
  83. package/dist/packem_shared/remove-CSbrd0dl.js +1 -0
  84. package/dist/packem_shared/removeSync-BoLAzRQE.js +1 -0
  85. package/dist/packem_shared/renderError-B3ePOoBG-Bi9WKMjv.js +6 -0
  86. package/dist/packem_shared/resolve-symlink-target-CWrn0v4P.js +1 -0
  87. package/dist/packem_shared/sanitize-DGZ3w-_w.js +1 -0
  88. package/dist/packem_shared/stripJsonComments-Bfcn2PKv.js +1 -0
  89. package/dist/packem_shared/to-uint-8-array-BImOQNXm.js +1 -0
  90. package/dist/packem_shared/types.d-BMdL_ygj.d.ts +1773 -0
  91. package/dist/packem_shared/walk-OX4-6oCP.js +1 -0
  92. package/dist/packem_shared/walk-include-BXhGSn6t.js +1 -0
  93. package/dist/packem_shared/walkSync-BPs6czIM.js +1 -0
  94. package/dist/packem_shared/writeFile-BrMtsJY7.js +1 -0
  95. package/dist/packem_shared/writeFileSync-W7Mf4BNy.js +1 -0
  96. package/dist/packem_shared/writeIni-BWX3cP1K.js +4 -0
  97. package/dist/packem_shared/writeIniSync-fOdgPFfL.js +4 -0
  98. package/dist/packem_shared/writeJson-bEVi25gX.js +4 -0
  99. package/dist/packem_shared/writeJson5-Ch8TpNPI.js +4 -0
  100. package/dist/packem_shared/writeJson5Sync-BrctV_Mk.js +4 -0
  101. package/dist/packem_shared/writeJsonSync-DkGnd416.js +4 -0
  102. package/dist/packem_shared/writeJsonc-CefrwsOc.js +4 -0
  103. package/dist/packem_shared/writeJsoncSync-BskDjn8o.js +4 -0
  104. package/dist/packem_shared/writeToml-IuMO-yDu.js +1 -0
  105. package/dist/packem_shared/writeTomlSync-DhL7hHzB.js +1 -0
  106. package/dist/packem_shared/writeYaml-ClQgvQID.js +1 -0
  107. package/dist/packem_shared/writeYamlSync-DrXtHQQq.js +1 -0
  108. package/dist/size.d.ts +244 -0
  109. package/dist/size.js +1 -146
  110. package/dist/toml.d.ts +57 -3
  111. package/dist/toml.js +1 -4
  112. package/dist/utils.d.ts +92 -4
  113. package/dist/utils.js +1 -6
  114. package/dist/yaml.d.ts +3 -4
  115. package/dist/yaml.js +1 -4
  116. package/package.json +41 -44
  117. package/dist/packem_shared/AlreadyExistsError-6Y9hjgMn.js +0 -27
  118. package/dist/packem_shared/DirectoryError-BfYPkIYP.js +0 -27
  119. package/dist/packem_shared/F_OK-MldBaGxb.js +0 -8
  120. package/dist/packem_shared/JSONError-BkHRnInH.js +0 -26
  121. package/dist/packem_shared/NotEmptyError-B21RUlVr.js +0 -27
  122. package/dist/packem_shared/NotFoundError-BIp61X6k.js +0 -27
  123. package/dist/packem_shared/PermissionError-CjoiJgip.js +0 -27
  124. package/dist/packem_shared/WalkError-DER5A43G.js +0 -24
  125. package/dist/packem_shared/_commonjsHelpers-BqLXS_qQ.js +0 -5
  126. package/dist/packem_shared/assertValidFileContents-BmcLtsGd.js +0 -7
  127. package/dist/packem_shared/assertValidFileOrDirectoryPath-8HANmVjk.js +0 -7
  128. package/dist/packem_shared/build-rm-options-Cl3VDY4O.js +0 -12
  129. package/dist/packem_shared/collect-CqQ3eVab.js +0 -14
  130. package/dist/packem_shared/collectSync-noE08NNv.js +0 -14
  131. package/dist/packem_shared/emptyDir-DnwENOaV.js +0 -46
  132. package/dist/packem_shared/emptyDirSync-6WiHBo8a.js +0 -43
  133. package/dist/packem_shared/ensureDir-DNlPftys.js +0 -53
  134. package/dist/packem_shared/ensureDirSync-DcPZFMy5.js +0 -53
  135. package/dist/packem_shared/ensureFile-BRQpUOUM.js +0 -47
  136. package/dist/packem_shared/ensureFileSync-SBY7A9-C.js +0 -47
  137. package/dist/packem_shared/ensureLink-DJQeauEn.js +0 -55
  138. package/dist/packem_shared/ensureLinkSync-D9RVAglV.js +0 -55
  139. package/dist/packem_shared/ensureSymlink-CoRYDRwr.js +0 -80
  140. package/dist/packem_shared/ensureSymlinkSync-CFimFlgh.js +0 -81
  141. package/dist/packem_shared/findUp-YcNLKdfV.js +0 -84
  142. package/dist/packem_shared/findUpSync-BfA5fheN.js +0 -83
  143. package/dist/packem_shared/get-file-info-type-FD4-jsyg.js +0 -14
  144. package/dist/packem_shared/glob-DY8l7izD.js +0 -5
  145. package/dist/packem_shared/glob-sync.d-B83kqwUd.d.ts +0 -4
  146. package/dist/packem_shared/globSync-5P2KJf_g.js +0 -5
  147. package/dist/packem_shared/index-C8W8sfzP.js +0 -830
  148. package/dist/packem_shared/index-CHM-in-V.js +0 -100
  149. package/dist/packem_shared/index-bhgnhm4u.js +0 -167
  150. package/dist/packem_shared/index-xe4o3cYi.js +0 -1784
  151. package/dist/packem_shared/indexToLineColumn-BUb0GPKl-BF770uX7.js +0 -171
  152. package/dist/packem_shared/ini-preserve-Dq_Q_Jgb.js +0 -251
  153. package/dist/packem_shared/is-stats-identical-D8FxpvQU.js +0 -3
  154. package/dist/packem_shared/isAccessible-DuVrTNFV.js +0 -38
  155. package/dist/packem_shared/isAccessibleSync-DI8mM0fA.js +0 -38
  156. package/dist/packem_shared/isFsCaseSensitive-DunL7Iry.js +0 -62
  157. package/dist/packem_shared/json-error.d-DgKaeuIf.d.ts +0 -10
  158. package/dist/packem_shared/jsonc-merge-C6jWcfWh.js +0 -72
  159. package/dist/packem_shared/move-DbpW5_vA.js +0 -134
  160. package/dist/packem_shared/parseJson-BIp89Xjo.js +0 -63
  161. package/dist/packem_shared/readFile-Iz7kvCCk.js +0 -65
  162. package/dist/packem_shared/readFileSync-gm9yfIhh.js +0 -54
  163. package/dist/packem_shared/readIni-CJ2xfpjB.js +0 -10
  164. package/dist/packem_shared/readIniSync-9LUjaSSp.js +0 -10
  165. package/dist/packem_shared/readJson-C_rwm-wq.js +0 -22
  166. package/dist/packem_shared/readJson5-mBoTZppy.js +0 -15
  167. package/dist/packem_shared/readJson5Sync-8WS2yUok.js +0 -15
  168. package/dist/packem_shared/readJsonSync-BMEmCcJ6.js +0 -22
  169. package/dist/packem_shared/readJsonc-j-OS-APg.js +0 -28
  170. package/dist/packem_shared/readJsoncSync-Aw6EMlWO.js +0 -16
  171. package/dist/packem_shared/readToml-B2MHaSes.js +0 -9
  172. package/dist/packem_shared/readTomlSync-DNbK8NEb.js +0 -9
  173. package/dist/packem_shared/readYaml-D5q2a0e1.js +0 -10
  174. package/dist/packem_shared/readYamlSync-BKX-PAfq.js +0 -10
  175. package/dist/packem_shared/remove-C8_gl3jF.js +0 -39
  176. package/dist/packem_shared/removeSync-BJR_wTwN.js +0 -39
  177. package/dist/packem_shared/resolve-symlink-target-Kh4GovFf.js +0 -16
  178. package/dist/packem_shared/sanitize-BZoLN9Fg.js +0 -205
  179. package/dist/packem_shared/stripJsonComments-vo4k0mpF.js +0 -19
  180. package/dist/packem_shared/to-uint-8-array-Dz2nF1y1.js +0 -19
  181. package/dist/packem_shared/types.d-dP-lAGNn.d.ts +0 -145
  182. package/dist/packem_shared/walk-CSZgCuDx.js +0 -124
  183. package/dist/packem_shared/walk-include-CZco7BvN.js +0 -16
  184. package/dist/packem_shared/walkSync-C4Cy28xb.js +0 -123
  185. package/dist/packem_shared/writeFile-B8HX0JIQ.js +0 -81
  186. package/dist/packem_shared/writeFileSync-DB8vv8xR.js +0 -81
  187. package/dist/packem_shared/writeIni-i55QrL8y.js +0 -65
  188. package/dist/packem_shared/writeIniSync-CLqJE5t3.js +0 -64
  189. package/dist/packem_shared/writeJson-Bo7C2UHw.js +0 -50
  190. package/dist/packem_shared/writeJson5-vVmHUQOd.js +0 -53
  191. package/dist/packem_shared/writeJson5Sync-oJ546h5k.js +0 -53
  192. package/dist/packem_shared/writeJsonSync-BKZ_9Acr.js +0 -50
  193. package/dist/packem_shared/writeJsonc-BufH_oC5.js +0 -60
  194. package/dist/packem_shared/writeJsoncSync-DB9be1YL.js +0 -59
  195. package/dist/packem_shared/writeToml-DgTW_-7F.js +0 -8
  196. package/dist/packem_shared/writeTomlSync-DiBiE9ja.js +0 -8
  197. package/dist/packem_shared/writeYaml-BWCOome-.js +0 -24
  198. package/dist/packem_shared/writeYamlSync-DBVnXmuY.js +0 -24
@@ -1,1784 +0,0 @@
1
- import { g as getDefaultExportFromCjs } from './_commonjsHelpers-BqLXS_qQ.js';
2
-
3
- var utils = {};
4
-
5
- var constants;
6
- var hasRequiredConstants;
7
-
8
- function requireConstants () {
9
- if (hasRequiredConstants) return constants;
10
- hasRequiredConstants = 1;
11
- const WIN_SLASH = "\\\\/";
12
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
13
- const DEFAULT_MAX_EXTGLOB_RECURSION = 0;
14
- const UNIGNORE = /* @__PURE__ */ Symbol("unignore");
15
- const DOT_LITERAL = "\\.";
16
- const PLUS_LITERAL = "\\+";
17
- const QMARK_LITERAL = "\\?";
18
- const SLASH_LITERAL = "\\/";
19
- const ONE_CHAR = "(?=.)";
20
- const QMARK = "[^/]";
21
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
22
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
23
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
24
- const NO_DOT = `(?!${DOT_LITERAL})`;
25
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
26
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
27
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
28
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
29
- const STAR = `${QMARK}*?`;
30
- const SEP = "/";
31
- const POSIX_CHARS = {
32
- DOT_LITERAL,
33
- PLUS_LITERAL,
34
- QMARK_LITERAL,
35
- SLASH_LITERAL,
36
- ONE_CHAR,
37
- QMARK,
38
- END_ANCHOR,
39
- DOTS_SLASH,
40
- NO_DOT,
41
- NO_DOTS,
42
- NO_DOT_SLASH,
43
- NO_DOTS_SLASH,
44
- QMARK_NO_DOT,
45
- STAR,
46
- START_ANCHOR,
47
- SEP
48
- };
49
- const WINDOWS_CHARS = {
50
- ...POSIX_CHARS,
51
- SLASH_LITERAL: `[${WIN_SLASH}]`,
52
- QMARK: WIN_NO_SLASH,
53
- STAR: `${WIN_NO_SLASH}*?`,
54
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
55
- NO_DOT: `(?!${DOT_LITERAL})`,
56
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
57
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
58
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
59
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
60
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
61
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
62
- SEP: "\\"
63
- };
64
- const POSIX_REGEX_SOURCE = {
65
- __proto__: null,
66
- alnum: "a-zA-Z0-9",
67
- alpha: "a-zA-Z",
68
- ascii: "\\x00-\\x7F",
69
- blank: " \\t",
70
- cntrl: "\\x00-\\x1F\\x7F",
71
- digit: "0-9",
72
- graph: "\\x21-\\x7E",
73
- lower: "a-z",
74
- print: "\\x20-\\x7E ",
75
- punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
76
- space: " \\t\\r\\n\\v\\f",
77
- upper: "A-Z",
78
- word: "A-Za-z0-9_",
79
- xdigit: "A-Fa-f0-9"
80
- };
81
- constants = {
82
- DEFAULT_MAX_EXTGLOB_RECURSION,
83
- MAX_LENGTH: 1024 * 64,
84
- POSIX_REGEX_SOURCE,
85
- // token to un-ignore results in onIgnore
86
- UNIGNORE,
87
- // regular expressions
88
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
89
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
90
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
91
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
92
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
93
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
94
- // Replace globs with equivalent patterns to reduce parsing time.
95
- REPLACEMENTS: {
96
- __proto__: null,
97
- "***": "*",
98
- "**/**": "**",
99
- "**/**/**": "**"
100
- },
101
- // Digits
102
- CHAR_0: 48,
103
- /* 0 */
104
- CHAR_9: 57,
105
- /* 9 */
106
- // Alphabet chars.
107
- CHAR_UPPERCASE_A: 65,
108
- /* A */
109
- CHAR_LOWERCASE_A: 97,
110
- /* a */
111
- CHAR_UPPERCASE_Z: 90,
112
- /* Z */
113
- CHAR_LOWERCASE_Z: 122,
114
- /* z */
115
- CHAR_LEFT_PARENTHESES: 40,
116
- /* ( */
117
- CHAR_RIGHT_PARENTHESES: 41,
118
- /* ) */
119
- CHAR_ASTERISK: 42,
120
- /* * */
121
- // Non-alphabetic chars.
122
- CHAR_AMPERSAND: 38,
123
- /* & */
124
- CHAR_AT: 64,
125
- /* @ */
126
- CHAR_BACKWARD_SLASH: 92,
127
- /* \ */
128
- CHAR_CARRIAGE_RETURN: 13,
129
- /* \r */
130
- CHAR_CIRCUMFLEX_ACCENT: 94,
131
- /* ^ */
132
- CHAR_COLON: 58,
133
- /* : */
134
- CHAR_COMMA: 44,
135
- /* , */
136
- CHAR_DOT: 46,
137
- /* . */
138
- CHAR_DOUBLE_QUOTE: 34,
139
- /* " */
140
- CHAR_EQUAL: 61,
141
- /* = */
142
- CHAR_EXCLAMATION_MARK: 33,
143
- /* ! */
144
- CHAR_FORM_FEED: 12,
145
- /* \f */
146
- CHAR_FORWARD_SLASH: 47,
147
- /* / */
148
- CHAR_GRAVE_ACCENT: 96,
149
- /* ` */
150
- CHAR_HASH: 35,
151
- /* # */
152
- CHAR_HYPHEN_MINUS: 45,
153
- /* - */
154
- CHAR_LEFT_ANGLE_BRACKET: 60,
155
- /* < */
156
- CHAR_LEFT_CURLY_BRACE: 123,
157
- /* { */
158
- CHAR_LEFT_SQUARE_BRACKET: 91,
159
- /* [ */
160
- CHAR_LINE_FEED: 10,
161
- /* \n */
162
- CHAR_NO_BREAK_SPACE: 160,
163
- /* \u00A0 */
164
- CHAR_PERCENT: 37,
165
- /* % */
166
- CHAR_PLUS: 43,
167
- /* + */
168
- CHAR_QUESTION_MARK: 63,
169
- /* ? */
170
- CHAR_RIGHT_ANGLE_BRACKET: 62,
171
- /* > */
172
- CHAR_RIGHT_CURLY_BRACE: 125,
173
- /* } */
174
- CHAR_RIGHT_SQUARE_BRACKET: 93,
175
- /* ] */
176
- CHAR_SEMICOLON: 59,
177
- /* ; */
178
- CHAR_SINGLE_QUOTE: 39,
179
- /* ' */
180
- CHAR_SPACE: 32,
181
- /* */
182
- CHAR_TAB: 9,
183
- /* \t */
184
- CHAR_UNDERSCORE: 95,
185
- /* _ */
186
- CHAR_VERTICAL_LINE: 124,
187
- /* | */
188
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
189
- /* \uFEFF */
190
- /**
191
- * Create EXTGLOB_CHARS
192
- */
193
- extglobChars(chars) {
194
- return {
195
- "!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
196
- "?": { type: "qmark", open: "(?:", close: ")?" },
197
- "+": { type: "plus", open: "(?:", close: ")+" },
198
- "*": { type: "star", open: "(?:", close: ")*" },
199
- "@": { type: "at", open: "(?:", close: ")" }
200
- };
201
- },
202
- /**
203
- * Create GLOB_CHARS
204
- */
205
- globChars(win32) {
206
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
207
- }
208
- };
209
- return constants;
210
- }
211
-
212
- var hasRequiredUtils;
213
-
214
- function requireUtils () {
215
- if (hasRequiredUtils) return utils;
216
- hasRequiredUtils = 1;
217
- (function (exports$1) {
218
- const {
219
- REGEX_BACKSLASH,
220
- REGEX_REMOVE_BACKSLASH,
221
- REGEX_SPECIAL_CHARS,
222
- REGEX_SPECIAL_CHARS_GLOBAL
223
- } = /*@__PURE__*/ requireConstants();
224
- exports$1.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
225
- exports$1.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
226
- exports$1.isRegexChar = (str) => str.length === 1 && exports$1.hasRegexChars(str);
227
- exports$1.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
228
- exports$1.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
229
- exports$1.isWindows = () => {
230
- if (typeof navigator !== "undefined" && navigator.platform) {
231
- const platform = navigator.platform.toLowerCase();
232
- return platform === "win32" || platform === "windows";
233
- }
234
- if (process.platform) {
235
- return process.platform === "win32";
236
- }
237
- return false;
238
- };
239
- exports$1.removeBackslashes = (str) => {
240
- return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
241
- return match === "\\" ? "" : match;
242
- });
243
- };
244
- exports$1.escapeLast = (input, char, lastIdx) => {
245
- const idx = input.lastIndexOf(char, lastIdx);
246
- if (idx === -1) return input;
247
- if (input[idx - 1] === "\\") return exports$1.escapeLast(input, char, idx - 1);
248
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
249
- };
250
- exports$1.removePrefix = (input, state = {}) => {
251
- let output = input;
252
- if (output.startsWith("./")) {
253
- output = output.slice(2);
254
- state.prefix = "./";
255
- }
256
- return output;
257
- };
258
- exports$1.wrapOutput = (input, state = {}, options = {}) => {
259
- const prepend = options.contains ? "" : "^";
260
- const append = options.contains ? "" : "$";
261
- let output = `${prepend}(?:${input})${append}`;
262
- if (state.negated === true) {
263
- output = `(?:^(?!${output}).*$)`;
264
- }
265
- return output;
266
- };
267
- exports$1.basename = (path, { windows } = {}) => {
268
- const segs = path.split(windows ? /[\\/]/ : "/");
269
- const last = segs[segs.length - 1];
270
- if (last === "") {
271
- return segs[segs.length - 2];
272
- }
273
- return last;
274
- };
275
- } (utils));
276
- return utils;
277
- }
278
-
279
- var scan_1;
280
- var hasRequiredScan;
281
-
282
- function requireScan () {
283
- if (hasRequiredScan) return scan_1;
284
- hasRequiredScan = 1;
285
- const utils = /*@__PURE__*/ requireUtils();
286
- const {
287
- CHAR_ASTERISK,
288
- /* * */
289
- CHAR_AT,
290
- /* @ */
291
- CHAR_BACKWARD_SLASH,
292
- /* \ */
293
- CHAR_COMMA,
294
- /* , */
295
- CHAR_DOT,
296
- /* . */
297
- CHAR_EXCLAMATION_MARK,
298
- /* ! */
299
- CHAR_FORWARD_SLASH,
300
- /* / */
301
- CHAR_LEFT_CURLY_BRACE,
302
- /* { */
303
- CHAR_LEFT_PARENTHESES,
304
- /* ( */
305
- CHAR_LEFT_SQUARE_BRACKET,
306
- /* [ */
307
- CHAR_PLUS,
308
- /* + */
309
- CHAR_QUESTION_MARK,
310
- /* ? */
311
- CHAR_RIGHT_CURLY_BRACE,
312
- /* } */
313
- CHAR_RIGHT_PARENTHESES,
314
- /* ) */
315
- CHAR_RIGHT_SQUARE_BRACKET
316
- /* ] */
317
- } = /*@__PURE__*/ requireConstants();
318
- const isPathSeparator = (code) => {
319
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
320
- };
321
- const depth = (token) => {
322
- if (token.isPrefix !== true) {
323
- token.depth = token.isGlobstar ? Infinity : 1;
324
- }
325
- };
326
- const scan = (input, options) => {
327
- const opts = options || {};
328
- const length = input.length - 1;
329
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
330
- const slashes = [];
331
- const tokens = [];
332
- const parts = [];
333
- let str = input;
334
- let index = -1;
335
- let start = 0;
336
- let lastIndex = 0;
337
- let isBrace = false;
338
- let isBracket = false;
339
- let isGlob = false;
340
- let isExtglob = false;
341
- let isGlobstar = false;
342
- let braceEscaped = false;
343
- let backslashes = false;
344
- let negated = false;
345
- let negatedExtglob = false;
346
- let finished = false;
347
- let braces = 0;
348
- let prev;
349
- let code;
350
- let token = { value: "", depth: 0, isGlob: false };
351
- const eos = () => index >= length;
352
- const peek = () => str.charCodeAt(index + 1);
353
- const advance = () => {
354
- prev = code;
355
- return str.charCodeAt(++index);
356
- };
357
- while (index < length) {
358
- code = advance();
359
- let next;
360
- if (code === CHAR_BACKWARD_SLASH) {
361
- backslashes = token.backslashes = true;
362
- code = advance();
363
- if (code === CHAR_LEFT_CURLY_BRACE) {
364
- braceEscaped = true;
365
- }
366
- continue;
367
- }
368
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
369
- braces++;
370
- while (eos() !== true && (code = advance())) {
371
- if (code === CHAR_BACKWARD_SLASH) {
372
- backslashes = token.backslashes = true;
373
- advance();
374
- continue;
375
- }
376
- if (code === CHAR_LEFT_CURLY_BRACE) {
377
- braces++;
378
- continue;
379
- }
380
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
381
- isBrace = token.isBrace = true;
382
- isGlob = token.isGlob = true;
383
- finished = true;
384
- if (scanToEnd === true) {
385
- continue;
386
- }
387
- break;
388
- }
389
- if (braceEscaped !== true && code === CHAR_COMMA) {
390
- isBrace = token.isBrace = true;
391
- isGlob = token.isGlob = true;
392
- finished = true;
393
- if (scanToEnd === true) {
394
- continue;
395
- }
396
- break;
397
- }
398
- if (code === CHAR_RIGHT_CURLY_BRACE) {
399
- braces--;
400
- if (braces === 0) {
401
- braceEscaped = false;
402
- isBrace = token.isBrace = true;
403
- finished = true;
404
- break;
405
- }
406
- }
407
- }
408
- if (scanToEnd === true) {
409
- continue;
410
- }
411
- break;
412
- }
413
- if (code === CHAR_FORWARD_SLASH) {
414
- slashes.push(index);
415
- tokens.push(token);
416
- token = { value: "", depth: 0, isGlob: false };
417
- if (finished === true) continue;
418
- if (prev === CHAR_DOT && index === start + 1) {
419
- start += 2;
420
- continue;
421
- }
422
- lastIndex = index + 1;
423
- continue;
424
- }
425
- if (opts.noext !== true) {
426
- const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
427
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
428
- isGlob = token.isGlob = true;
429
- isExtglob = token.isExtglob = true;
430
- finished = true;
431
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
432
- negatedExtglob = true;
433
- }
434
- if (scanToEnd === true) {
435
- while (eos() !== true && (code = advance())) {
436
- if (code === CHAR_BACKWARD_SLASH) {
437
- backslashes = token.backslashes = true;
438
- code = advance();
439
- continue;
440
- }
441
- if (code === CHAR_RIGHT_PARENTHESES) {
442
- isGlob = token.isGlob = true;
443
- finished = true;
444
- break;
445
- }
446
- }
447
- continue;
448
- }
449
- break;
450
- }
451
- }
452
- if (code === CHAR_ASTERISK) {
453
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
454
- isGlob = token.isGlob = true;
455
- finished = true;
456
- if (scanToEnd === true) {
457
- continue;
458
- }
459
- break;
460
- }
461
- if (code === CHAR_QUESTION_MARK) {
462
- isGlob = token.isGlob = true;
463
- finished = true;
464
- if (scanToEnd === true) {
465
- continue;
466
- }
467
- break;
468
- }
469
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
470
- while (eos() !== true && (next = advance())) {
471
- if (next === CHAR_BACKWARD_SLASH) {
472
- backslashes = token.backslashes = true;
473
- advance();
474
- continue;
475
- }
476
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
477
- isBracket = token.isBracket = true;
478
- isGlob = token.isGlob = true;
479
- finished = true;
480
- break;
481
- }
482
- }
483
- if (scanToEnd === true) {
484
- continue;
485
- }
486
- break;
487
- }
488
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
489
- negated = token.negated = true;
490
- start++;
491
- continue;
492
- }
493
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
494
- isGlob = token.isGlob = true;
495
- if (scanToEnd === true) {
496
- while (eos() !== true && (code = advance())) {
497
- if (code === CHAR_LEFT_PARENTHESES) {
498
- backslashes = token.backslashes = true;
499
- code = advance();
500
- continue;
501
- }
502
- if (code === CHAR_RIGHT_PARENTHESES) {
503
- finished = true;
504
- break;
505
- }
506
- }
507
- continue;
508
- }
509
- break;
510
- }
511
- if (isGlob === true) {
512
- finished = true;
513
- if (scanToEnd === true) {
514
- continue;
515
- }
516
- break;
517
- }
518
- }
519
- if (opts.noext === true) {
520
- isExtglob = false;
521
- isGlob = false;
522
- }
523
- let base = str;
524
- let prefix = "";
525
- let glob = "";
526
- if (start > 0) {
527
- prefix = str.slice(0, start);
528
- str = str.slice(start);
529
- lastIndex -= start;
530
- }
531
- if (base && isGlob === true && lastIndex > 0) {
532
- base = str.slice(0, lastIndex);
533
- glob = str.slice(lastIndex);
534
- } else if (isGlob === true) {
535
- base = "";
536
- glob = str;
537
- } else {
538
- base = str;
539
- }
540
- if (base && base !== "" && base !== "/" && base !== str) {
541
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
542
- base = base.slice(0, -1);
543
- }
544
- }
545
- if (opts.unescape === true) {
546
- if (glob) glob = utils.removeBackslashes(glob);
547
- if (base && backslashes === true) {
548
- base = utils.removeBackslashes(base);
549
- }
550
- }
551
- const state = {
552
- prefix,
553
- input,
554
- start,
555
- base,
556
- glob,
557
- isBrace,
558
- isBracket,
559
- isGlob,
560
- isExtglob,
561
- isGlobstar,
562
- negated,
563
- negatedExtglob
564
- };
565
- if (opts.tokens === true) {
566
- state.maxDepth = 0;
567
- if (!isPathSeparator(code)) {
568
- tokens.push(token);
569
- }
570
- state.tokens = tokens;
571
- }
572
- if (opts.parts === true || opts.tokens === true) {
573
- let prevIndex;
574
- for (let idx = 0; idx < slashes.length; idx++) {
575
- const n = prevIndex ? prevIndex + 1 : start;
576
- const i = slashes[idx];
577
- const value = input.slice(n, i);
578
- if (opts.tokens) {
579
- if (idx === 0 && start !== 0) {
580
- tokens[idx].isPrefix = true;
581
- tokens[idx].value = prefix;
582
- } else {
583
- tokens[idx].value = value;
584
- }
585
- depth(tokens[idx]);
586
- state.maxDepth += tokens[idx].depth;
587
- }
588
- if (idx !== 0 || value !== "") {
589
- parts.push(value);
590
- }
591
- prevIndex = i;
592
- }
593
- if (prevIndex && prevIndex + 1 < input.length) {
594
- const value = input.slice(prevIndex + 1);
595
- parts.push(value);
596
- if (opts.tokens) {
597
- tokens[tokens.length - 1].value = value;
598
- depth(tokens[tokens.length - 1]);
599
- state.maxDepth += tokens[tokens.length - 1].depth;
600
- }
601
- }
602
- state.slashes = slashes;
603
- state.parts = parts;
604
- }
605
- return state;
606
- };
607
- scan_1 = scan;
608
- return scan_1;
609
- }
610
-
611
- var parse_1;
612
- var hasRequiredParse;
613
-
614
- function requireParse () {
615
- if (hasRequiredParse) return parse_1;
616
- hasRequiredParse = 1;
617
- const constants = /*@__PURE__*/ requireConstants();
618
- const utils = /*@__PURE__*/ requireUtils();
619
- const {
620
- MAX_LENGTH,
621
- POSIX_REGEX_SOURCE,
622
- REGEX_NON_SPECIAL_CHARS,
623
- REGEX_SPECIAL_CHARS_BACKREF,
624
- REPLACEMENTS
625
- } = constants;
626
- const expandRange = (args, options) => {
627
- if (typeof options.expandRange === "function") {
628
- return options.expandRange(...args, options);
629
- }
630
- args.sort();
631
- const value = `[${args.join("-")}]`;
632
- return value;
633
- };
634
- const syntaxError = (type, char) => {
635
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
636
- };
637
- const splitTopLevel = (input) => {
638
- const parts = [];
639
- let bracket = 0;
640
- let paren = 0;
641
- let quote = 0;
642
- let value = "";
643
- let escaped = false;
644
- for (const ch of input) {
645
- if (escaped === true) {
646
- value += ch;
647
- escaped = false;
648
- continue;
649
- }
650
- if (ch === "\\") {
651
- value += ch;
652
- escaped = true;
653
- continue;
654
- }
655
- if (ch === '"') {
656
- quote = quote === 1 ? 0 : 1;
657
- value += ch;
658
- continue;
659
- }
660
- if (quote === 0) {
661
- if (ch === "[") {
662
- bracket++;
663
- } else if (ch === "]" && bracket > 0) {
664
- bracket--;
665
- } else if (bracket === 0) {
666
- if (ch === "(") {
667
- paren++;
668
- } else if (ch === ")" && paren > 0) {
669
- paren--;
670
- } else if (ch === "|" && paren === 0) {
671
- parts.push(value);
672
- value = "";
673
- continue;
674
- }
675
- }
676
- }
677
- value += ch;
678
- }
679
- parts.push(value);
680
- return parts;
681
- };
682
- const isPlainBranch = (branch) => {
683
- let escaped = false;
684
- for (const ch of branch) {
685
- if (escaped === true) {
686
- escaped = false;
687
- continue;
688
- }
689
- if (ch === "\\") {
690
- escaped = true;
691
- continue;
692
- }
693
- if (/[?*+@!()[\]{}]/.test(ch)) {
694
- return false;
695
- }
696
- }
697
- return true;
698
- };
699
- const normalizeSimpleBranch = (branch) => {
700
- let value = branch.trim();
701
- let changed = true;
702
- while (changed === true) {
703
- changed = false;
704
- if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
705
- value = value.slice(2, -1);
706
- changed = true;
707
- }
708
- }
709
- if (!isPlainBranch(value)) {
710
- return;
711
- }
712
- return value.replace(/\\(.)/g, "$1");
713
- };
714
- const hasRepeatedCharPrefixOverlap = (branches) => {
715
- const values = branches.map(normalizeSimpleBranch).filter(Boolean);
716
- for (let i = 0; i < values.length; i++) {
717
- for (let j = i + 1; j < values.length; j++) {
718
- const a = values[i];
719
- const b = values[j];
720
- const char = a[0];
721
- if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
722
- continue;
723
- }
724
- if (a === b || a.startsWith(b) || b.startsWith(a)) {
725
- return true;
726
- }
727
- }
728
- }
729
- return false;
730
- };
731
- const parseRepeatedExtglob = (pattern, requireEnd = true) => {
732
- if (pattern[0] !== "+" && pattern[0] !== "*" || pattern[1] !== "(") {
733
- return;
734
- }
735
- let bracket = 0;
736
- let paren = 0;
737
- let quote = 0;
738
- let escaped = false;
739
- for (let i = 1; i < pattern.length; i++) {
740
- const ch = pattern[i];
741
- if (escaped === true) {
742
- escaped = false;
743
- continue;
744
- }
745
- if (ch === "\\") {
746
- escaped = true;
747
- continue;
748
- }
749
- if (ch === '"') {
750
- quote = quote === 1 ? 0 : 1;
751
- continue;
752
- }
753
- if (quote === 1) {
754
- continue;
755
- }
756
- if (ch === "[") {
757
- bracket++;
758
- continue;
759
- }
760
- if (ch === "]" && bracket > 0) {
761
- bracket--;
762
- continue;
763
- }
764
- if (bracket > 0) {
765
- continue;
766
- }
767
- if (ch === "(") {
768
- paren++;
769
- continue;
770
- }
771
- if (ch === ")") {
772
- paren--;
773
- if (paren === 0) {
774
- if (requireEnd === true && i !== pattern.length - 1) {
775
- return;
776
- }
777
- return {
778
- type: pattern[0],
779
- body: pattern.slice(2, i),
780
- end: i
781
- };
782
- }
783
- }
784
- }
785
- };
786
- const getStarExtglobSequenceOutput = (pattern) => {
787
- let index = 0;
788
- const chars = [];
789
- while (index < pattern.length) {
790
- const match = parseRepeatedExtglob(pattern.slice(index), false);
791
- if (!match || match.type !== "*") {
792
- return;
793
- }
794
- const branches = splitTopLevel(match.body).map((branch2) => branch2.trim());
795
- if (branches.length !== 1) {
796
- return;
797
- }
798
- const branch = normalizeSimpleBranch(branches[0]);
799
- if (!branch || branch.length !== 1) {
800
- return;
801
- }
802
- chars.push(branch);
803
- index += match.end + 1;
804
- }
805
- if (chars.length < 1) {
806
- return;
807
- }
808
- const source = chars.length === 1 ? utils.escapeRegex(chars[0]) : `[${chars.map((ch) => utils.escapeRegex(ch)).join("")}]`;
809
- return `${source}*`;
810
- };
811
- const repeatedExtglobRecursion = (pattern) => {
812
- let depth = 0;
813
- let value = pattern.trim();
814
- let match = parseRepeatedExtglob(value);
815
- while (match) {
816
- depth++;
817
- value = match.body.trim();
818
- match = parseRepeatedExtglob(value);
819
- }
820
- return depth;
821
- };
822
- const analyzeRepeatedExtglob = (body, options) => {
823
- if (options.maxExtglobRecursion === false) {
824
- return { risky: false };
825
- }
826
- const max = typeof options.maxExtglobRecursion === "number" ? options.maxExtglobRecursion : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
827
- const branches = splitTopLevel(body).map((branch) => branch.trim());
828
- if (branches.length > 1) {
829
- if (branches.some((branch) => branch === "") || branches.some((branch) => /^[*?]+$/.test(branch)) || hasRepeatedCharPrefixOverlap(branches)) {
830
- return { risky: true };
831
- }
832
- }
833
- for (const branch of branches) {
834
- const safeOutput = getStarExtglobSequenceOutput(branch);
835
- if (safeOutput) {
836
- return { risky: true, safeOutput };
837
- }
838
- if (repeatedExtglobRecursion(branch) > max) {
839
- return { risky: true };
840
- }
841
- }
842
- return { risky: false };
843
- };
844
- const parse = (input, options) => {
845
- if (typeof input !== "string") {
846
- throw new TypeError("Expected a string");
847
- }
848
- input = REPLACEMENTS[input] || input;
849
- const opts = { ...options };
850
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
851
- let len = input.length;
852
- if (len > max) {
853
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
854
- }
855
- const bos = { type: "bos", value: "", output: opts.prepend || "" };
856
- const tokens = [bos];
857
- const capture = opts.capture ? "" : "?:";
858
- const PLATFORM_CHARS = constants.globChars(opts.windows);
859
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
860
- const {
861
- DOT_LITERAL,
862
- PLUS_LITERAL,
863
- SLASH_LITERAL,
864
- ONE_CHAR,
865
- DOTS_SLASH,
866
- NO_DOT,
867
- NO_DOT_SLASH,
868
- NO_DOTS_SLASH,
869
- QMARK,
870
- QMARK_NO_DOT,
871
- STAR,
872
- START_ANCHOR
873
- } = PLATFORM_CHARS;
874
- const globstar = (opts2) => {
875
- return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
876
- };
877
- const nodot = opts.dot ? "" : NO_DOT;
878
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
879
- let star = opts.bash === true ? globstar(opts) : STAR;
880
- if (opts.capture) {
881
- star = `(${star})`;
882
- }
883
- if (typeof opts.noext === "boolean") {
884
- opts.noextglob = opts.noext;
885
- }
886
- const state = {
887
- input,
888
- index: -1,
889
- start: 0,
890
- dot: opts.dot === true,
891
- consumed: "",
892
- output: "",
893
- prefix: "",
894
- backtrack: false,
895
- negated: false,
896
- brackets: 0,
897
- braces: 0,
898
- parens: 0,
899
- quotes: 0,
900
- globstar: false,
901
- tokens
902
- };
903
- input = utils.removePrefix(input, state);
904
- len = input.length;
905
- const extglobs = [];
906
- const braces = [];
907
- const stack = [];
908
- let prev = bos;
909
- let value;
910
- const eos = () => state.index === len - 1;
911
- const peek = state.peek = (n = 1) => input[state.index + n];
912
- const advance = state.advance = () => input[++state.index] || "";
913
- const remaining = () => input.slice(state.index + 1);
914
- const consume = (value2 = "", num = 0) => {
915
- state.consumed += value2;
916
- state.index += num;
917
- };
918
- const append = (token) => {
919
- state.output += token.output != null ? token.output : token.value;
920
- consume(token.value);
921
- };
922
- const negate = () => {
923
- let count = 1;
924
- while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
925
- advance();
926
- state.start++;
927
- count++;
928
- }
929
- if (count % 2 === 0) {
930
- return false;
931
- }
932
- state.negated = true;
933
- state.start++;
934
- return true;
935
- };
936
- const increment = (type) => {
937
- state[type]++;
938
- stack.push(type);
939
- };
940
- const decrement = (type) => {
941
- state[type]--;
942
- stack.pop();
943
- };
944
- const push = (tok) => {
945
- if (prev.type === "globstar") {
946
- const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
947
- const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
948
- if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
949
- state.output = state.output.slice(0, -prev.output.length);
950
- prev.type = "star";
951
- prev.value = "*";
952
- prev.output = star;
953
- state.output += prev.output;
954
- }
955
- }
956
- if (extglobs.length && tok.type !== "paren") {
957
- extglobs[extglobs.length - 1].inner += tok.value;
958
- }
959
- if (tok.value || tok.output) append(tok);
960
- if (prev && prev.type === "text" && tok.type === "text") {
961
- prev.output = (prev.output || prev.value) + tok.value;
962
- prev.value += tok.value;
963
- return;
964
- }
965
- tok.prev = prev;
966
- tokens.push(tok);
967
- prev = tok;
968
- };
969
- const extglobOpen = (type, value2) => {
970
- const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
971
- token.prev = prev;
972
- token.parens = state.parens;
973
- token.output = state.output;
974
- token.startIndex = state.index;
975
- token.tokensIndex = tokens.length;
976
- const output = (opts.capture ? "(" : "") + token.open;
977
- increment("parens");
978
- push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
979
- push({ type: "paren", extglob: true, value: advance(), output });
980
- extglobs.push(token);
981
- };
982
- const extglobClose = (token) => {
983
- const literal = input.slice(token.startIndex, state.index + 1);
984
- const body = input.slice(token.startIndex + 2, state.index);
985
- const analysis = analyzeRepeatedExtglob(body, opts);
986
- if ((token.type === "plus" || token.type === "star") && analysis.risky) {
987
- const safeOutput = analysis.safeOutput ? (token.output ? "" : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput) : void 0;
988
- const open = tokens[token.tokensIndex];
989
- open.type = "text";
990
- open.value = literal;
991
- open.output = safeOutput || utils.escapeRegex(literal);
992
- for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
993
- tokens[i].value = "";
994
- tokens[i].output = "";
995
- delete tokens[i].suffix;
996
- }
997
- state.output = token.output + open.output;
998
- state.backtrack = true;
999
- push({ type: "paren", extglob: true, value, output: "" });
1000
- decrement("parens");
1001
- return;
1002
- }
1003
- let output = token.close + (opts.capture ? ")" : "");
1004
- let rest;
1005
- if (token.type === "negate") {
1006
- let extglobStar = star;
1007
- if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
1008
- extglobStar = globstar(opts);
1009
- }
1010
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
1011
- output = token.close = `)$))${extglobStar}`;
1012
- }
1013
- if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
1014
- const expression = parse(rest, { ...options, fastpaths: false }).output;
1015
- output = token.close = `)${expression})${extglobStar})`;
1016
- }
1017
- if (token.prev.type === "bos") {
1018
- state.negatedExtglob = true;
1019
- }
1020
- }
1021
- push({ type: "paren", extglob: true, value, output });
1022
- decrement("parens");
1023
- };
1024
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
1025
- let backslashes = false;
1026
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
1027
- if (first === "\\") {
1028
- backslashes = true;
1029
- return m;
1030
- }
1031
- if (first === "?") {
1032
- if (esc) {
1033
- return esc + first + (rest ? QMARK.repeat(rest.length) : "");
1034
- }
1035
- if (index === 0) {
1036
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
1037
- }
1038
- return QMARK.repeat(chars.length);
1039
- }
1040
- if (first === ".") {
1041
- return DOT_LITERAL.repeat(chars.length);
1042
- }
1043
- if (first === "*") {
1044
- if (esc) {
1045
- return esc + first + (rest ? star : "");
1046
- }
1047
- return star;
1048
- }
1049
- return esc ? m : `\\${m}`;
1050
- });
1051
- if (backslashes === true) {
1052
- if (opts.unescape === true) {
1053
- output = output.replace(/\\/g, "");
1054
- } else {
1055
- output = output.replace(/\\+/g, (m) => {
1056
- return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
1057
- });
1058
- }
1059
- }
1060
- if (output === input && opts.contains === true) {
1061
- state.output = input;
1062
- return state;
1063
- }
1064
- state.output = utils.wrapOutput(output, state, options);
1065
- return state;
1066
- }
1067
- while (!eos()) {
1068
- value = advance();
1069
- if (value === "\0") {
1070
- continue;
1071
- }
1072
- if (value === "\\") {
1073
- const next = peek();
1074
- if (next === "/" && opts.bash !== true) {
1075
- continue;
1076
- }
1077
- if (next === "." || next === ";") {
1078
- continue;
1079
- }
1080
- if (!next) {
1081
- value += "\\";
1082
- push({ type: "text", value });
1083
- continue;
1084
- }
1085
- const match = /^\\+/.exec(remaining());
1086
- let slashes = 0;
1087
- if (match && match[0].length > 2) {
1088
- slashes = match[0].length;
1089
- state.index += slashes;
1090
- if (slashes % 2 !== 0) {
1091
- value += "\\";
1092
- }
1093
- }
1094
- if (opts.unescape === true) {
1095
- value = advance();
1096
- } else {
1097
- value += advance();
1098
- }
1099
- if (state.brackets === 0) {
1100
- push({ type: "text", value });
1101
- continue;
1102
- }
1103
- }
1104
- if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
1105
- if (opts.posix !== false && value === ":") {
1106
- const inner = prev.value.slice(1);
1107
- if (inner.includes("[")) {
1108
- prev.posix = true;
1109
- if (inner.includes(":")) {
1110
- const idx = prev.value.lastIndexOf("[");
1111
- const pre = prev.value.slice(0, idx);
1112
- const rest2 = prev.value.slice(idx + 2);
1113
- const posix = POSIX_REGEX_SOURCE[rest2];
1114
- if (posix) {
1115
- prev.value = pre + posix;
1116
- state.backtrack = true;
1117
- advance();
1118
- if (!bos.output && tokens.indexOf(prev) === 1) {
1119
- bos.output = ONE_CHAR;
1120
- }
1121
- continue;
1122
- }
1123
- }
1124
- }
1125
- }
1126
- if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
1127
- value = `\\${value}`;
1128
- }
1129
- if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
1130
- value = `\\${value}`;
1131
- }
1132
- if (opts.posix === true && value === "!" && prev.value === "[") {
1133
- value = "^";
1134
- }
1135
- prev.value += value;
1136
- append({ value });
1137
- continue;
1138
- }
1139
- if (state.quotes === 1 && value !== '"') {
1140
- value = utils.escapeRegex(value);
1141
- prev.value += value;
1142
- append({ value });
1143
- continue;
1144
- }
1145
- if (value === '"') {
1146
- state.quotes = state.quotes === 1 ? 0 : 1;
1147
- if (opts.keepQuotes === true) {
1148
- push({ type: "text", value });
1149
- }
1150
- continue;
1151
- }
1152
- if (value === "(") {
1153
- increment("parens");
1154
- push({ type: "paren", value });
1155
- continue;
1156
- }
1157
- if (value === ")") {
1158
- if (state.parens === 0 && opts.strictBrackets === true) {
1159
- throw new SyntaxError(syntaxError("opening", "("));
1160
- }
1161
- const extglob = extglobs[extglobs.length - 1];
1162
- if (extglob && state.parens === extglob.parens + 1) {
1163
- extglobClose(extglobs.pop());
1164
- continue;
1165
- }
1166
- push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
1167
- decrement("parens");
1168
- continue;
1169
- }
1170
- if (value === "[") {
1171
- if (opts.nobracket === true || !remaining().includes("]")) {
1172
- if (opts.nobracket !== true && opts.strictBrackets === true) {
1173
- throw new SyntaxError(syntaxError("closing", "]"));
1174
- }
1175
- value = `\\${value}`;
1176
- } else {
1177
- increment("brackets");
1178
- }
1179
- push({ type: "bracket", value });
1180
- continue;
1181
- }
1182
- if (value === "]") {
1183
- if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
1184
- push({ type: "text", value, output: `\\${value}` });
1185
- continue;
1186
- }
1187
- if (state.brackets === 0) {
1188
- if (opts.strictBrackets === true) {
1189
- throw new SyntaxError(syntaxError("opening", "["));
1190
- }
1191
- push({ type: "text", value, output: `\\${value}` });
1192
- continue;
1193
- }
1194
- decrement("brackets");
1195
- const prevValue = prev.value.slice(1);
1196
- if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
1197
- value = `/${value}`;
1198
- }
1199
- prev.value += value;
1200
- append({ value });
1201
- if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
1202
- continue;
1203
- }
1204
- const escaped = utils.escapeRegex(prev.value);
1205
- state.output = state.output.slice(0, -prev.value.length);
1206
- if (opts.literalBrackets === true) {
1207
- state.output += escaped;
1208
- prev.value = escaped;
1209
- continue;
1210
- }
1211
- prev.value = `(${capture}${escaped}|${prev.value})`;
1212
- state.output += prev.value;
1213
- continue;
1214
- }
1215
- if (value === "{" && opts.nobrace !== true) {
1216
- increment("braces");
1217
- const open = {
1218
- type: "brace",
1219
- value,
1220
- output: "(",
1221
- outputIndex: state.output.length,
1222
- tokensIndex: state.tokens.length
1223
- };
1224
- braces.push(open);
1225
- push(open);
1226
- continue;
1227
- }
1228
- if (value === "}") {
1229
- const brace = braces[braces.length - 1];
1230
- if (opts.nobrace === true || !brace) {
1231
- push({ type: "text", value, output: value });
1232
- continue;
1233
- }
1234
- let output = ")";
1235
- if (brace.dots === true) {
1236
- const arr = tokens.slice();
1237
- const range = [];
1238
- for (let i = arr.length - 1; i >= 0; i--) {
1239
- tokens.pop();
1240
- if (arr[i].type === "brace") {
1241
- break;
1242
- }
1243
- if (arr[i].type !== "dots") {
1244
- range.unshift(arr[i].value);
1245
- }
1246
- }
1247
- output = expandRange(range, opts);
1248
- state.backtrack = true;
1249
- }
1250
- if (brace.comma !== true && brace.dots !== true) {
1251
- const out = state.output.slice(0, brace.outputIndex);
1252
- const toks = state.tokens.slice(brace.tokensIndex);
1253
- brace.value = brace.output = "\\{";
1254
- value = output = "\\}";
1255
- state.output = out;
1256
- for (const t of toks) {
1257
- state.output += t.output || t.value;
1258
- }
1259
- }
1260
- push({ type: "brace", value, output });
1261
- decrement("braces");
1262
- braces.pop();
1263
- continue;
1264
- }
1265
- if (value === "|") {
1266
- if (extglobs.length > 0) {
1267
- extglobs[extglobs.length - 1].conditions++;
1268
- }
1269
- push({ type: "text", value });
1270
- continue;
1271
- }
1272
- if (value === ",") {
1273
- let output = value;
1274
- const brace = braces[braces.length - 1];
1275
- if (brace && stack[stack.length - 1] === "braces") {
1276
- brace.comma = true;
1277
- output = "|";
1278
- }
1279
- push({ type: "comma", value, output });
1280
- continue;
1281
- }
1282
- if (value === "/") {
1283
- if (prev.type === "dot" && state.index === state.start + 1) {
1284
- state.start = state.index + 1;
1285
- state.consumed = "";
1286
- state.output = "";
1287
- tokens.pop();
1288
- prev = bos;
1289
- continue;
1290
- }
1291
- push({ type: "slash", value, output: SLASH_LITERAL });
1292
- continue;
1293
- }
1294
- if (value === ".") {
1295
- if (state.braces > 0 && prev.type === "dot") {
1296
- if (prev.value === ".") prev.output = DOT_LITERAL;
1297
- const brace = braces[braces.length - 1];
1298
- prev.type = "dots";
1299
- prev.output += value;
1300
- prev.value += value;
1301
- brace.dots = true;
1302
- continue;
1303
- }
1304
- if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
1305
- push({ type: "text", value, output: DOT_LITERAL });
1306
- continue;
1307
- }
1308
- push({ type: "dot", value, output: DOT_LITERAL });
1309
- continue;
1310
- }
1311
- if (value === "?") {
1312
- const isGroup = prev && prev.value === "(";
1313
- if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1314
- extglobOpen("qmark", value);
1315
- continue;
1316
- }
1317
- if (prev && prev.type === "paren") {
1318
- const next = peek();
1319
- let output = value;
1320
- if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
1321
- output = `\\${value}`;
1322
- }
1323
- push({ type: "text", value, output });
1324
- continue;
1325
- }
1326
- if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
1327
- push({ type: "qmark", value, output: QMARK_NO_DOT });
1328
- continue;
1329
- }
1330
- push({ type: "qmark", value, output: QMARK });
1331
- continue;
1332
- }
1333
- if (value === "!") {
1334
- if (opts.noextglob !== true && peek() === "(") {
1335
- if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
1336
- extglobOpen("negate", value);
1337
- continue;
1338
- }
1339
- }
1340
- if (opts.nonegate !== true && state.index === 0) {
1341
- negate();
1342
- continue;
1343
- }
1344
- }
1345
- if (value === "+") {
1346
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1347
- extglobOpen("plus", value);
1348
- continue;
1349
- }
1350
- if (prev && prev.value === "(" || opts.regex === false) {
1351
- push({ type: "plus", value, output: PLUS_LITERAL });
1352
- continue;
1353
- }
1354
- if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
1355
- push({ type: "plus", value });
1356
- continue;
1357
- }
1358
- push({ type: "plus", value: PLUS_LITERAL });
1359
- continue;
1360
- }
1361
- if (value === "@") {
1362
- if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
1363
- push({ type: "at", extglob: true, value, output: "" });
1364
- continue;
1365
- }
1366
- push({ type: "text", value });
1367
- continue;
1368
- }
1369
- if (value !== "*") {
1370
- if (value === "$" || value === "^") {
1371
- value = `\\${value}`;
1372
- }
1373
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1374
- if (match) {
1375
- value += match[0];
1376
- state.index += match[0].length;
1377
- }
1378
- push({ type: "text", value });
1379
- continue;
1380
- }
1381
- if (prev && (prev.type === "globstar" || prev.star === true)) {
1382
- prev.type = "star";
1383
- prev.star = true;
1384
- prev.value += value;
1385
- prev.output = star;
1386
- state.backtrack = true;
1387
- state.globstar = true;
1388
- consume(value);
1389
- continue;
1390
- }
1391
- let rest = remaining();
1392
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1393
- extglobOpen("star", value);
1394
- continue;
1395
- }
1396
- if (prev.type === "star") {
1397
- if (opts.noglobstar === true) {
1398
- consume(value);
1399
- continue;
1400
- }
1401
- const prior = prev.prev;
1402
- const before = prior.prev;
1403
- const isStart = prior.type === "slash" || prior.type === "bos";
1404
- const afterStar = before && (before.type === "star" || before.type === "globstar");
1405
- if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
1406
- push({ type: "star", value, output: "" });
1407
- continue;
1408
- }
1409
- const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
1410
- const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
1411
- if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
1412
- push({ type: "star", value, output: "" });
1413
- continue;
1414
- }
1415
- while (rest.slice(0, 3) === "/**") {
1416
- const after = input[state.index + 4];
1417
- if (after && after !== "/") {
1418
- break;
1419
- }
1420
- rest = rest.slice(3);
1421
- consume("/**", 3);
1422
- }
1423
- if (prior.type === "bos" && eos()) {
1424
- prev.type = "globstar";
1425
- prev.value += value;
1426
- prev.output = globstar(opts);
1427
- state.output = prev.output;
1428
- state.globstar = true;
1429
- consume(value);
1430
- continue;
1431
- }
1432
- if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
1433
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1434
- prior.output = `(?:${prior.output}`;
1435
- prev.type = "globstar";
1436
- prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
1437
- prev.value += value;
1438
- state.globstar = true;
1439
- state.output += prior.output + prev.output;
1440
- consume(value);
1441
- continue;
1442
- }
1443
- if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
1444
- const end = rest[1] !== void 0 ? "|$" : "";
1445
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1446
- prior.output = `(?:${prior.output}`;
1447
- prev.type = "globstar";
1448
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1449
- prev.value += value;
1450
- state.output += prior.output + prev.output;
1451
- state.globstar = true;
1452
- consume(value + advance());
1453
- push({ type: "slash", value: "/", output: "" });
1454
- continue;
1455
- }
1456
- if (prior.type === "bos" && rest[0] === "/") {
1457
- prev.type = "globstar";
1458
- prev.value += value;
1459
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1460
- state.output = prev.output;
1461
- state.globstar = true;
1462
- consume(value + advance());
1463
- push({ type: "slash", value: "/", output: "" });
1464
- continue;
1465
- }
1466
- if (isBrace && rest[0] === "/") {
1467
- prev.type = "globstar";
1468
- prev.value += value;
1469
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1470
- state.output += prev.output;
1471
- state.globstar = true;
1472
- consume(value + advance());
1473
- push({ type: "slash", value: "/", output: "" });
1474
- continue;
1475
- }
1476
- state.output = state.output.slice(0, -prev.output.length);
1477
- prev.type = "globstar";
1478
- prev.output = globstar(opts);
1479
- prev.value += value;
1480
- state.output += prev.output;
1481
- state.globstar = true;
1482
- consume(value);
1483
- continue;
1484
- }
1485
- const token = { type: "star", value, output: star };
1486
- if (opts.bash === true) {
1487
- token.output = ".*?";
1488
- if (prev.type === "bos" || prev.type === "slash") {
1489
- token.output = nodot + token.output;
1490
- }
1491
- push(token);
1492
- continue;
1493
- }
1494
- if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
1495
- token.output = value;
1496
- push(token);
1497
- continue;
1498
- }
1499
- if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
1500
- if (prev.type === "dot") {
1501
- state.output += NO_DOT_SLASH;
1502
- prev.output += NO_DOT_SLASH;
1503
- } else if (opts.dot === true) {
1504
- state.output += NO_DOTS_SLASH;
1505
- prev.output += NO_DOTS_SLASH;
1506
- } else {
1507
- state.output += nodot;
1508
- prev.output += nodot;
1509
- }
1510
- if (peek() !== "*") {
1511
- state.output += ONE_CHAR;
1512
- prev.output += ONE_CHAR;
1513
- }
1514
- }
1515
- push(token);
1516
- }
1517
- while (state.brackets > 0) {
1518
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
1519
- state.output = utils.escapeLast(state.output, "[");
1520
- decrement("brackets");
1521
- }
1522
- while (state.parens > 0) {
1523
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
1524
- state.output = utils.escapeLast(state.output, "(");
1525
- decrement("parens");
1526
- }
1527
- while (state.braces > 0) {
1528
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
1529
- state.output = utils.escapeLast(state.output, "{");
1530
- decrement("braces");
1531
- }
1532
- if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
1533
- push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
1534
- }
1535
- if (state.backtrack === true) {
1536
- state.output = "";
1537
- for (const token of state.tokens) {
1538
- state.output += token.output != null ? token.output : token.value;
1539
- if (token.suffix) {
1540
- state.output += token.suffix;
1541
- }
1542
- }
1543
- }
1544
- return state;
1545
- };
1546
- parse.fastpaths = (input, options) => {
1547
- const opts = { ...options };
1548
- const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1549
- const len = input.length;
1550
- if (len > max) {
1551
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1552
- }
1553
- input = REPLACEMENTS[input] || input;
1554
- const {
1555
- DOT_LITERAL,
1556
- SLASH_LITERAL,
1557
- ONE_CHAR,
1558
- DOTS_SLASH,
1559
- NO_DOT,
1560
- NO_DOTS,
1561
- NO_DOTS_SLASH,
1562
- STAR,
1563
- START_ANCHOR
1564
- } = constants.globChars(opts.windows);
1565
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
1566
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1567
- const capture = opts.capture ? "" : "?:";
1568
- const state = { negated: false, prefix: "" };
1569
- let star = opts.bash === true ? ".*?" : STAR;
1570
- if (opts.capture) {
1571
- star = `(${star})`;
1572
- }
1573
- const globstar = (opts2) => {
1574
- if (opts2.noglobstar === true) return star;
1575
- return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1576
- };
1577
- const create = (str) => {
1578
- switch (str) {
1579
- case "*":
1580
- return `${nodot}${ONE_CHAR}${star}`;
1581
- case ".*":
1582
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1583
- case "*.*":
1584
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1585
- case "*/*":
1586
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1587
- case "**":
1588
- return nodot + globstar(opts);
1589
- case "**/*":
1590
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1591
- case "**/*.*":
1592
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1593
- case "**/.*":
1594
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1595
- default: {
1596
- const match = /^(.*?)\.(\w+)$/.exec(str);
1597
- if (!match) return;
1598
- const source2 = create(match[1]);
1599
- if (!source2) return;
1600
- return source2 + DOT_LITERAL + match[2];
1601
- }
1602
- }
1603
- };
1604
- const output = utils.removePrefix(input, state);
1605
- let source = create(output);
1606
- if (source && opts.strictSlashes !== true) {
1607
- source += `${SLASH_LITERAL}?`;
1608
- }
1609
- return source;
1610
- };
1611
- parse_1 = parse;
1612
- return parse_1;
1613
- }
1614
-
1615
- var picomatch_1$1;
1616
- var hasRequiredPicomatch$1;
1617
-
1618
- function requirePicomatch$1 () {
1619
- if (hasRequiredPicomatch$1) return picomatch_1$1;
1620
- hasRequiredPicomatch$1 = 1;
1621
- const scan = /*@__PURE__*/ requireScan();
1622
- const parse = /*@__PURE__*/ requireParse();
1623
- const utils = /*@__PURE__*/ requireUtils();
1624
- const constants = /*@__PURE__*/ requireConstants();
1625
- const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
1626
- const picomatch = (glob, options, returnState = false) => {
1627
- if (Array.isArray(glob)) {
1628
- const fns = glob.map((input) => picomatch(input, options, returnState));
1629
- const arrayMatcher = (str) => {
1630
- for (const isMatch of fns) {
1631
- const state2 = isMatch(str);
1632
- if (state2) return state2;
1633
- }
1634
- return false;
1635
- };
1636
- return arrayMatcher;
1637
- }
1638
- const isState = isObject(glob) && glob.tokens && glob.input;
1639
- if (glob === "" || typeof glob !== "string" && !isState) {
1640
- throw new TypeError("Expected pattern to be a non-empty string");
1641
- }
1642
- const opts = options || {};
1643
- const posix = opts.windows;
1644
- const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
1645
- const state = regex.state;
1646
- delete regex.state;
1647
- let isIgnored = () => false;
1648
- if (opts.ignore) {
1649
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1650
- isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
1651
- }
1652
- const matcher = (input, returnObject = false) => {
1653
- const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
1654
- const result = { glob, state, regex, posix, input, output, match, isMatch };
1655
- if (typeof opts.onResult === "function") {
1656
- opts.onResult(result);
1657
- }
1658
- if (isMatch === false) {
1659
- result.isMatch = false;
1660
- return returnObject ? result : false;
1661
- }
1662
- ignored: {
1663
- if (isIgnored(input)) {
1664
- if (typeof opts.onIgnore === "function") {
1665
- if (opts.onIgnore(result) === constants.UNIGNORE) {
1666
- result.isMatch = true;
1667
- break ignored;
1668
- }
1669
- }
1670
- result.isMatch = false;
1671
- return returnObject ? result : false;
1672
- }
1673
- }
1674
- if (typeof opts.onMatch === "function") {
1675
- opts.onMatch(result);
1676
- }
1677
- return returnObject ? result : true;
1678
- };
1679
- if (returnState) {
1680
- matcher.state = state;
1681
- }
1682
- return matcher;
1683
- };
1684
- picomatch.test = (input, regex, options, { glob, posix } = {}) => {
1685
- if (typeof input !== "string") {
1686
- throw new TypeError("Expected input to be a string");
1687
- }
1688
- if (input === "") {
1689
- return { isMatch: false, output: "" };
1690
- }
1691
- const opts = options || {};
1692
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
1693
- let match = input === glob;
1694
- let output = match && format ? format(input) : input;
1695
- if (match === false) {
1696
- output = format ? format(input) : input;
1697
- match = output === glob;
1698
- }
1699
- if (match === false || opts.capture === true) {
1700
- if (opts.matchBase === true || opts.basename === true) {
1701
- match = picomatch.matchBase(input, regex, options, posix);
1702
- } else {
1703
- match = regex.exec(output);
1704
- }
1705
- }
1706
- return { isMatch: Boolean(match), match, output };
1707
- };
1708
- picomatch.matchBase = (input, glob, options) => {
1709
- const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1710
- return regex.test(utils.basename(input));
1711
- };
1712
- picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
1713
- picomatch.parse = (pattern, options) => {
1714
- if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
1715
- return parse(pattern, { ...options, fastpaths: false });
1716
- };
1717
- picomatch.scan = (input, options) => scan(input, options);
1718
- picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
1719
- if (returnOutput === true) {
1720
- return state.output;
1721
- }
1722
- const opts = options || {};
1723
- const prepend = opts.contains ? "" : "^";
1724
- const append = opts.contains ? "" : "$";
1725
- let source = `${prepend}(?:${state.output})${append}`;
1726
- if (state && state.negated === true) {
1727
- source = `^(?!${source}).*$`;
1728
- }
1729
- const regex = picomatch.toRegex(source, options);
1730
- if (returnState === true) {
1731
- regex.state = state;
1732
- }
1733
- return regex;
1734
- };
1735
- picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
1736
- if (!input || typeof input !== "string") {
1737
- throw new TypeError("Expected a non-empty string");
1738
- }
1739
- let parsed = { negated: false, fastpaths: true };
1740
- if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
1741
- parsed.output = parse.fastpaths(input, options);
1742
- }
1743
- if (!parsed.output) {
1744
- parsed = parse(input, options);
1745
- }
1746
- return picomatch.compileRe(parsed, options, returnOutput, returnState);
1747
- };
1748
- picomatch.toRegex = (source, options) => {
1749
- try {
1750
- const opts = options || {};
1751
- return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
1752
- } catch (err) {
1753
- if (options && options.debug === true) throw err;
1754
- return /$^/;
1755
- }
1756
- };
1757
- picomatch.constants = constants;
1758
- picomatch_1$1 = picomatch;
1759
- return picomatch_1$1;
1760
- }
1761
-
1762
- var picomatch_1;
1763
- var hasRequiredPicomatch;
1764
-
1765
- function requirePicomatch () {
1766
- if (hasRequiredPicomatch) return picomatch_1;
1767
- hasRequiredPicomatch = 1;
1768
- const pico = /*@__PURE__*/ requirePicomatch$1();
1769
- const utils = /*@__PURE__*/ requireUtils();
1770
- function picomatch(glob, options, returnState = false) {
1771
- if (options && (options.windows === null || options.windows === void 0)) {
1772
- options = { ...options, windows: utils.isWindows() };
1773
- }
1774
- return pico(glob, options, returnState);
1775
- }
1776
- Object.assign(picomatch, pico);
1777
- picomatch_1 = picomatch;
1778
- return picomatch_1;
1779
- }
1780
-
1781
- var picomatchExports = /*@__PURE__*/ requirePicomatch();
1782
- const picomatch = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
1783
-
1784
- export { picomatch as p };