nitro-nightly 4.0.0-20251030-091344-d4418b98 → 4.0.0-20251030-122334-09c1a7a8

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 (334) hide show
  1. package/dist/_build/common.mjs +763 -0
  2. package/dist/_build/rolldown.mjs +216 -0
  3. package/dist/_build/rollup.mjs +359 -0
  4. package/dist/_build/vite.build.mjs +67 -0
  5. package/dist/_build/vite.plugin.mjs +762 -0
  6. package/dist/_chunks/B-7HiF0V.mjs +1303 -0
  7. package/dist/_chunks/B3asVbT4.mjs +151 -0
  8. package/dist/_chunks/B5ooyfLk.mjs +372 -0
  9. package/dist/_chunks/DXMHy5ca.mjs +43 -0
  10. package/dist/_dev.d.mts +12 -0
  11. package/dist/_dev.mjs +675 -0
  12. package/dist/_libs/acorn.mjs +5034 -0
  13. package/dist/_libs/c12.mjs +2798 -0
  14. package/dist/_libs/chokidar.mjs +1560 -0
  15. package/dist/_libs/citty.mjs +333 -0
  16. package/dist/_libs/commondir.mjs +22 -0
  17. package/dist/_libs/compatx.mjs +46 -0
  18. package/dist/_libs/confbox.mjs +2920 -0
  19. package/dist/_libs/debug.mjs +848 -0
  20. package/dist/_libs/deepmerge.mjs +86 -0
  21. package/dist/_libs/depd.mjs +314 -0
  22. package/dist/_libs/dot-prop.mjs +138 -0
  23. package/dist/_libs/duplexer.mjs +71 -0
  24. package/dist/_libs/ee-first.mjs +68 -0
  25. package/dist/_libs/encodeurl.mjs +49 -0
  26. package/dist/_libs/escape-html.mjs +58 -0
  27. package/dist/_libs/escape-string-regexp.mjs +8 -0
  28. package/dist/_libs/estree-walker.mjs +330 -0
  29. package/dist/_libs/etag.mjs +75 -0
  30. package/dist/{_chunks/_deps → _libs}/fdir.mjs +49 -104
  31. package/dist/_libs/fresh.mjs +85 -0
  32. package/dist/_libs/function-bind.mjs +63 -0
  33. package/dist/_libs/gen-mapping.mjs +612 -0
  34. package/dist/_libs/giget.mjs +19076 -0
  35. package/dist/_libs/gzip-size.mjs +21 -0
  36. package/dist/_libs/hasown.mjs +14 -0
  37. package/dist/_libs/http-errors.mjs +436 -0
  38. package/dist/_libs/httpxy.mjs +410 -0
  39. package/dist/_libs/is-core-module.mjs +220 -0
  40. package/dist/_libs/is-module.mjs +13 -0
  41. package/dist/_libs/is-reference.mjs +32 -0
  42. package/dist/{_chunks/_deps → _libs}/js-tokens.mjs +83 -112
  43. package/dist/_libs/klona.mjs +90 -0
  44. package/dist/_libs/knitwork.mjs +124 -0
  45. package/dist/_libs/local-pkg.mjs +1686 -0
  46. package/dist/{_chunks/_deps → _libs}/magic-string.mjs +272 -629
  47. package/dist/_libs/mime-db.mjs +7642 -0
  48. package/dist/_libs/mime-types.mjs +162 -0
  49. package/dist/_libs/mime.mjs +1391 -0
  50. package/dist/_libs/node-fetch-native.mjs +173 -0
  51. package/dist/_libs/on-finished.mjs +170 -0
  52. package/dist/_libs/parseurl.mjs +103 -0
  53. package/dist/_libs/path-parse.mjs +47 -0
  54. package/dist/_libs/pathe.mjs +41 -0
  55. package/dist/_libs/picomatch.mjs +1673 -0
  56. package/dist/_libs/plugin-alias.mjs +64 -0
  57. package/dist/_libs/plugin-commonjs.mjs +1489 -0
  58. package/dist/_libs/plugin-inject.mjs +135 -0
  59. package/dist/_libs/plugin-json.mjs +36 -0
  60. package/dist/_libs/plugin-node-resolve.mjs +1553 -0
  61. package/dist/_libs/plugin-replace.mjs +104 -0
  62. package/dist/_libs/pretty-bytes.mjs +116 -0
  63. package/dist/_libs/range-parser.mjs +102 -0
  64. package/dist/_libs/remapping.mjs +117 -0
  65. package/dist/{_chunks/_deps → _libs}/rou3.mjs +7 -22
  66. package/dist/_libs/send.mjs +857 -0
  67. package/dist/_libs/serve-static.mjs +124 -0
  68. package/dist/_libs/std-env.mjs +158 -0
  69. package/dist/_libs/strip-literal.mjs +51 -0
  70. package/dist/{_chunks/_deps → _libs}/tinyglobby.mjs +32 -33
  71. package/dist/_libs/ultrahtml.mjs +138 -0
  72. package/dist/_libs/unimport.mjs +3520 -0
  73. package/dist/_libs/untyped.mjs +271 -0
  74. package/dist/_libs/unwasm.mjs +5825 -0
  75. package/dist/{_chunks/_deps/@pi0 → _libs}/vite-plugin-fullstack.mjs +28 -42
  76. package/dist/_presets.mjs +1723 -0
  77. package/dist/builder.d.mts +37 -35
  78. package/dist/builder.mjs +45 -117
  79. package/dist/cli/_chunks/build.mjs +43 -0
  80. package/dist/cli/_chunks/common.mjs +15 -0
  81. package/dist/cli/_chunks/detect-acorn.mjs +12 -0
  82. package/dist/cli/_chunks/dev.mjs +79 -0
  83. package/dist/cli/_chunks/dist.mjs +3 -0
  84. package/dist/cli/_chunks/dist2.mjs +4 -0
  85. package/dist/cli/_chunks/esm.mjs +3 -0
  86. package/dist/cli/_chunks/json5.mjs +4 -0
  87. package/dist/cli/_chunks/jsonc.mjs +4 -0
  88. package/dist/cli/_chunks/list.mjs +27 -0
  89. package/dist/cli/_chunks/multipart-parser.mjs +6 -0
  90. package/dist/cli/_chunks/prepare.mjs +19 -0
  91. package/dist/cli/_chunks/run.mjs +55 -0
  92. package/dist/cli/_chunks/task.mjs +16 -0
  93. package/dist/cli/_chunks/toml.mjs +4 -0
  94. package/dist/cli/_chunks/yaml.mjs +4 -0
  95. package/dist/cli/index.d.mts +1 -1
  96. package/dist/cli/index.mjs +19 -18
  97. package/dist/presets/_nitro/runtime/nitro-dev.d.mts +1 -0
  98. package/dist/presets/_nitro/runtime/nitro-dev.mjs +42 -33
  99. package/dist/presets/_nitro/runtime/nitro-prerenderer.d.mts +2 -2
  100. package/dist/presets/_nitro/runtime/nitro-prerenderer.mjs +4 -8
  101. package/dist/presets/_nitro/runtime/service-worker.d.mts +1 -0
  102. package/dist/presets/_nitro/runtime/service-worker.mjs +14 -11
  103. package/dist/presets/aws-amplify/runtime/aws-amplify.d.mts +1 -0
  104. package/dist/presets/aws-amplify/runtime/aws-amplify.mjs +6 -5
  105. package/dist/presets/aws-lambda/runtime/_utils.d.mts +8 -13
  106. package/dist/presets/aws-lambda/runtime/_utils.mjs +95 -81
  107. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.d.mts +1 -2
  108. package/dist/presets/aws-lambda/runtime/aws-lambda-streaming.mjs +25 -27
  109. package/dist/presets/aws-lambda/runtime/aws-lambda.mjs +7 -7
  110. package/dist/presets/azure/runtime/_utils.mjs +43 -43
  111. package/dist/presets/azure/runtime/azure-swa.d.mts +2 -2
  112. package/dist/presets/azure/runtime/azure-swa.mjs +22 -21
  113. package/dist/presets/bun/runtime/bun.d.mts +1 -0
  114. package/dist/presets/bun/runtime/bun.mjs +18 -17
  115. package/dist/presets/cloudflare/runtime/_module-handler.d.mts +10 -7
  116. package/dist/presets/cloudflare/runtime/_module-handler.mjs +78 -87
  117. package/dist/presets/cloudflare/runtime/cloudflare-durable.d.mts +6 -14
  118. package/dist/presets/cloudflare/runtime/cloudflare-durable.mjs +53 -58
  119. package/dist/presets/cloudflare/runtime/cloudflare-module.d.mts +1 -7
  120. package/dist/presets/cloudflare/runtime/cloudflare-module.mjs +12 -14
  121. package/dist/presets/cloudflare/runtime/cloudflare-pages.d.mts +12 -12
  122. package/dist/presets/cloudflare/runtime/cloudflare-pages.mjs +35 -39
  123. package/dist/presets/cloudflare/runtime/plugin.dev.d.mts +2 -2
  124. package/dist/presets/cloudflare/runtime/plugin.dev.mjs +86 -76
  125. package/dist/presets/deno/runtime/deno-deploy.d.mts +1 -0
  126. package/dist/presets/deno/runtime/deno-deploy.mjs +12 -11
  127. package/dist/presets/deno/runtime/deno-server.d.mts +2 -1
  128. package/dist/presets/deno/runtime/deno-server.mjs +31 -39
  129. package/dist/presets/netlify/runtime/netlify-edge.d.mts +2 -1
  130. package/dist/presets/netlify/runtime/netlify-edge.mjs +14 -11
  131. package/dist/presets/netlify/runtime/netlify.mjs +11 -17
  132. package/dist/presets/node/runtime/node-cluster.mjs +49 -48
  133. package/dist/presets/node/runtime/node-middleware.d.mts +3 -2
  134. package/dist/presets/node/runtime/node-middleware.mjs +7 -6
  135. package/dist/presets/node/runtime/node-server.mjs +33 -23
  136. package/dist/presets/standard/runtime/server.d.mts +1 -3
  137. package/dist/presets/standard/runtime/server.mjs +1 -3
  138. package/dist/presets/stormkit/runtime/stormkit.d.mts +13 -13
  139. package/dist/presets/stormkit/runtime/stormkit.mjs +20 -20
  140. package/dist/presets/vercel/runtime/vercel.d.mts +3 -3
  141. package/dist/presets/vercel/runtime/vercel.mjs +15 -14
  142. package/dist/presets/winterjs/runtime/winterjs.d.mts +2 -0
  143. package/dist/presets/winterjs/runtime/winterjs.mjs +72 -68
  144. package/dist/presets/zeabur/runtime/zeabur.d.mts +1 -1
  145. package/dist/runtime/index.d.mts +12 -1
  146. package/dist/runtime/index.mjs +12 -7
  147. package/dist/runtime/internal/app.mjs +175 -162
  148. package/dist/runtime/internal/cache.d.mts +10 -4
  149. package/dist/runtime/internal/cache.mjs +247 -216
  150. package/dist/runtime/internal/context.d.mts +9 -9
  151. package/dist/runtime/internal/context.mjs +17 -10
  152. package/dist/runtime/internal/database.mjs +8 -10
  153. package/dist/runtime/internal/error/dev.d.mts +5 -4
  154. package/dist/runtime/internal/error/dev.mjs +106 -105
  155. package/dist/runtime/internal/error/prod.d.mts +2 -2
  156. package/dist/runtime/internal/error/prod.mjs +48 -52
  157. package/dist/runtime/internal/error/utils.d.mts +4 -4
  158. package/dist/runtime/internal/error/utils.mjs +1 -1
  159. package/dist/runtime/internal/index.d.mts +2 -0
  160. package/dist/runtime/internal/index.mjs +2 -0
  161. package/dist/runtime/internal/lib/http-graceful-shutdown.d.mts +14 -14
  162. package/dist/runtime/internal/lib/http-graceful-shutdown.mjs +248 -209
  163. package/dist/runtime/internal/meta.d.mts +1 -1
  164. package/dist/runtime/internal/meta.mjs +1 -1
  165. package/dist/runtime/internal/plugin.d.mts +2 -2
  166. package/dist/runtime/internal/plugin.mjs +1 -1
  167. package/dist/runtime/internal/renderer.mjs +39 -31
  168. package/dist/runtime/internal/route-rules.d.mts +8 -8
  169. package/dist/runtime/internal/route-rules.mjs +53 -51
  170. package/dist/runtime/internal/routes/dev-tasks.d.mts +1 -30
  171. package/dist/runtime/internal/routes/dev-tasks.mjs +15 -17
  172. package/dist/runtime/internal/routes/openapi.d.mts +1 -0
  173. package/dist/runtime/internal/routes/openapi.mjs +81 -87
  174. package/dist/runtime/internal/routes/renderer-template.d.mts +1 -1
  175. package/dist/runtime/internal/routes/renderer-template.dev.d.mts +1 -2
  176. package/dist/runtime/internal/routes/renderer-template.dev.mjs +10 -17
  177. package/dist/runtime/internal/routes/renderer-template.mjs +1 -1
  178. package/dist/runtime/internal/routes/scalar.d.mts +1 -0
  179. package/dist/runtime/internal/routes/scalar.mjs +22 -23
  180. package/dist/runtime/internal/routes/swagger.d.mts +1 -0
  181. package/dist/runtime/internal/routes/swagger.mjs +9 -11
  182. package/dist/runtime/internal/runtime-config.d.mts +4 -4
  183. package/dist/runtime/internal/runtime-config.mjs +40 -35
  184. package/dist/runtime/internal/shutdown.d.mts +2 -7
  185. package/dist/runtime/internal/shutdown.mjs +30 -29
  186. package/dist/runtime/internal/static.mjs +63 -74
  187. package/dist/runtime/internal/storage.mjs +2 -2
  188. package/dist/runtime/internal/task.d.mts +6 -6
  189. package/dist/runtime/internal/task.mjs +56 -59
  190. package/dist/runtime/internal/utils.d.mts +1 -1
  191. package/dist/runtime/internal/utils.mjs +4 -10
  192. package/dist/types/index.d.mts +2566 -3851
  193. package/dist/types/index.mjs +1 -1
  194. package/dist/vite.d.mts +61 -51
  195. package/dist/vite.mjs +55 -132
  196. package/package.json +10 -10
  197. package/dist/_build/build.mjs +0 -368
  198. package/dist/_build/build2.mjs +0 -556
  199. package/dist/_build/info.mjs +0 -1002
  200. package/dist/_build/prepare.mjs +0 -1511
  201. package/dist/_build/snapshot.mjs +0 -185
  202. package/dist/_build/vite.mjs +0 -959
  203. package/dist/_build/vite2.mjs +0 -149
  204. package/dist/_chunks/_deps/@jridgewell/gen-mapping.mjs +0 -189
  205. package/dist/_chunks/_deps/@jridgewell/remapping.mjs +0 -137
  206. package/dist/_chunks/_deps/@jridgewell/resolve-uri.mjs +0 -231
  207. package/dist/_chunks/_deps/@jridgewell/sourcemap-codec.mjs +0 -173
  208. package/dist/_chunks/_deps/@jridgewell/trace-mapping.mjs +0 -170
  209. package/dist/_chunks/_deps/@rollup/plugin-alias.mjs +0 -89
  210. package/dist/_chunks/_deps/@rollup/plugin-commonjs.mjs +0 -2376
  211. package/dist/_chunks/_deps/@rollup/plugin-inject.mjs +0 -212
  212. package/dist/_chunks/_deps/@rollup/plugin-json.mjs +0 -37
  213. package/dist/_chunks/_deps/@rollup/plugin-node-resolve.mjs +0 -1386
  214. package/dist/_chunks/_deps/@rollup/plugin-replace.mjs +0 -133
  215. package/dist/_chunks/_deps/@rollup/pluginutils.mjs +0 -346
  216. package/dist/_chunks/_deps/acorn.mjs +0 -6225
  217. package/dist/_chunks/_deps/c12.mjs +0 -510
  218. package/dist/_chunks/_deps/chokidar.mjs +0 -1428
  219. package/dist/_chunks/_deps/citty.mjs +0 -460
  220. package/dist/_chunks/_deps/commondir.mjs +0 -77
  221. package/dist/_chunks/_deps/compatx.mjs +0 -76
  222. package/dist/_chunks/_deps/confbox.mjs +0 -300
  223. package/dist/_chunks/_deps/debug.mjs +0 -885
  224. package/dist/_chunks/_deps/deepmerge.mjs +0 -147
  225. package/dist/_chunks/_deps/depd.mjs +0 -550
  226. package/dist/_chunks/_deps/dot-prop.mjs +0 -282
  227. package/dist/_chunks/_deps/dotenv.mjs +0 -555
  228. package/dist/_chunks/_deps/duplexer.mjs +0 -1
  229. package/dist/_chunks/_deps/ee-first.mjs +0 -104
  230. package/dist/_chunks/_deps/encodeurl.mjs +0 -69
  231. package/dist/_chunks/_deps/escape-html.mjs +0 -87
  232. package/dist/_chunks/_deps/escape-string-regexp.mjs +0 -13
  233. package/dist/_chunks/_deps/estree-walker.mjs +0 -433
  234. package/dist/_chunks/_deps/etag.mjs +0 -147
  235. package/dist/_chunks/_deps/exsolve.mjs +0 -1416
  236. package/dist/_chunks/_deps/fresh.mjs +0 -145
  237. package/dist/_chunks/_deps/function-bind.mjs +0 -106
  238. package/dist/_chunks/_deps/giget.mjs +0 -451
  239. package/dist/_chunks/_deps/gzip-size.mjs +0 -19
  240. package/dist/_chunks/_deps/hasown.mjs +0 -19
  241. package/dist/_chunks/_deps/http-errors.mjs +0 -307
  242. package/dist/_chunks/_deps/httpxy.mjs +0 -580
  243. package/dist/_chunks/_deps/inherits.mjs +0 -57
  244. package/dist/_chunks/_deps/is-core-module.mjs +0 -596
  245. package/dist/_chunks/_deps/is-module.mjs +0 -25
  246. package/dist/_chunks/_deps/is-reference.mjs +0 -31
  247. package/dist/_chunks/_deps/klona.mjs +0 -137
  248. package/dist/_chunks/_deps/knitwork.mjs +0 -172
  249. package/dist/_chunks/_deps/local-pkg.mjs +0 -163
  250. package/dist/_chunks/_deps/mime-db.mjs +0 -11685
  251. package/dist/_chunks/_deps/mime-types.mjs +0 -287
  252. package/dist/_chunks/_deps/mime.mjs +0 -1172
  253. package/dist/_chunks/_deps/mlly.mjs +0 -2413
  254. package/dist/_chunks/_deps/ms.mjs +0 -172
  255. package/dist/_chunks/_deps/node-fetch-native.mjs +0 -3
  256. package/dist/_chunks/_deps/nypm.mjs +0 -219
  257. package/dist/_chunks/_deps/on-finished.mjs +0 -246
  258. package/dist/_chunks/_deps/parseurl.mjs +0 -168
  259. package/dist/_chunks/_deps/path-parse.mjs +0 -85
  260. package/dist/_chunks/_deps/pathe.mjs +0 -251
  261. package/dist/_chunks/_deps/perfect-debounce.mjs +0 -88
  262. package/dist/_chunks/_deps/picomatch.mjs +0 -2144
  263. package/dist/_chunks/_deps/pkg-types.mjs +0 -247
  264. package/dist/_chunks/_deps/pretty-bytes.mjs +0 -180
  265. package/dist/_chunks/_deps/quansync.mjs +0 -99
  266. package/dist/_chunks/_deps/range-parser.mjs +0 -171
  267. package/dist/_chunks/_deps/rc9.mjs +0 -219
  268. package/dist/_chunks/_deps/readdirp.mjs +0 -245
  269. package/dist/_chunks/_deps/resolve.mjs +0 -1260
  270. package/dist/_chunks/_deps/send.mjs +0 -1022
  271. package/dist/_chunks/_deps/serve-static.mjs +0 -228
  272. package/dist/_chunks/_deps/setprototypeof.mjs +0 -26
  273. package/dist/_chunks/_deps/statuses.mjs +0 -457
  274. package/dist/_chunks/_deps/std-env.mjs +0 -3
  275. package/dist/_chunks/_deps/strip-literal.mjs +0 -67
  276. package/dist/_chunks/_deps/supports-color.mjs +0 -44
  277. package/dist/_chunks/_deps/tinyexec.mjs +0 -552
  278. package/dist/_chunks/_deps/toidentifier.mjs +0 -41
  279. package/dist/_chunks/_deps/ultrahtml.mjs +0 -3
  280. package/dist/_chunks/_deps/unimport.mjs +0 -2267
  281. package/dist/_chunks/_deps/unplugin-utils.mjs +0 -65
  282. package/dist/_chunks/_deps/unplugin.mjs +0 -1294
  283. package/dist/_chunks/_deps/untyped.mjs +0 -375
  284. package/dist/_chunks/_deps/unwasm.mjs +0 -6959
  285. package/dist/_chunks/_deps/webpack-virtual-modules.mjs +0 -360
  286. package/dist/_chunks/_presets/_all.mjs +0 -59
  287. package/dist/_chunks/_presets/_nitro.mjs +0 -74
  288. package/dist/_chunks/_presets/_resolve.mjs +0 -64
  289. package/dist/_chunks/_presets/_static.mjs +0 -69
  290. package/dist/_chunks/_presets/_types.mjs +0 -3
  291. package/dist/_chunks/_presets/_utils.mjs +0 -31
  292. package/dist/_chunks/_presets/alwaysdata.mjs +0 -17
  293. package/dist/_chunks/_presets/aws-amplify.mjs +0 -111
  294. package/dist/_chunks/_presets/aws-lambda.mjs +0 -23
  295. package/dist/_chunks/_presets/azure.mjs +0 -162
  296. package/dist/_chunks/_presets/bun.mjs +0 -19
  297. package/dist/_chunks/_presets/cleavr.mjs +0 -15
  298. package/dist/_chunks/_presets/cloudflare.mjs +0 -608
  299. package/dist/_chunks/_presets/deno.mjs +0 -196
  300. package/dist/_chunks/_presets/digitalocean.mjs +0 -14
  301. package/dist/_chunks/_presets/firebase.mjs +0 -47
  302. package/dist/_chunks/_presets/flightcontrol.mjs +0 -14
  303. package/dist/_chunks/_presets/genezio.mjs +0 -13
  304. package/dist/_chunks/_presets/heroku.mjs +0 -14
  305. package/dist/_chunks/_presets/iis.mjs +0 -194
  306. package/dist/_chunks/_presets/index.mjs +0 -62
  307. package/dist/_chunks/_presets/koyeb.mjs +0 -14
  308. package/dist/_chunks/_presets/netlify.mjs +0 -241
  309. package/dist/_chunks/_presets/node.mjs +0 -54
  310. package/dist/_chunks/_presets/platform.mjs +0 -14
  311. package/dist/_chunks/_presets/render.mjs +0 -14
  312. package/dist/_chunks/_presets/standard.mjs +0 -23
  313. package/dist/_chunks/_presets/stormkit.mjs +0 -18
  314. package/dist/_chunks/_presets/vercel.mjs +0 -375
  315. package/dist/_chunks/_presets/winterjs.mjs +0 -22
  316. package/dist/_chunks/_presets/zeabur.mjs +0 -69
  317. package/dist/_chunks/_presets/zerops.mjs +0 -27
  318. package/dist/_chunks/app.mjs +0 -600
  319. package/dist/_chunks/builder.mjs +0 -648
  320. package/dist/_chunks/server.mjs +0 -256
  321. package/dist/_cli/build.mjs +0 -49
  322. package/dist/_cli/common.mjs +0 -13
  323. package/dist/_cli/dev.mjs +0 -121
  324. package/dist/_cli/index.mjs +0 -16
  325. package/dist/_cli/list.mjs +0 -33
  326. package/dist/_cli/prepare.mjs +0 -23
  327. package/dist/_cli/run.mjs +0 -59
  328. package/dist/presets/cloudflare/runtime/shims/workers.dev.d.mts +0 -21
  329. package/dist/runtime/internal/empty.d.mts +0 -0
  330. package/dist/runtime/internal/vite/dev-entry.d.mts +0 -1
  331. package/dist/runtime/internal/vite/dev-worker.d.mts +0 -1
  332. package/dist/runtime/internal/vite/prod-setup.d.mts +0 -4
  333. package/dist/runtime/internal/vite/ssr-renderer.d.mts +0 -4
  334. /package/lib/{indexd.mts → index.d.mts} +0 -0
@@ -1,2144 +0,0 @@
1
- import { a as getDefaultExportFromCjs } from './commondir.mjs';
2
-
3
- var utils = {};
4
-
5
- var constants;
6
- var hasRequiredConstants;
7
-
8
- function requireConstants () {
9
- if (hasRequiredConstants) return constants;
10
- hasRequiredConstants = 1;
11
-
12
- const WIN_SLASH = '\\\\/';
13
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
14
-
15
- /**
16
- * Posix glob regex
17
- */
18
-
19
- const DOT_LITERAL = '\\.';
20
- const PLUS_LITERAL = '\\+';
21
- const QMARK_LITERAL = '\\?';
22
- const SLASH_LITERAL = '\\/';
23
- const ONE_CHAR = '(?=.)';
24
- const QMARK = '[^/]';
25
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
26
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
27
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
28
- const NO_DOT = `(?!${DOT_LITERAL})`;
29
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
30
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
31
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
32
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
33
- const STAR = `${QMARK}*?`;
34
- const SEP = '/';
35
-
36
- const POSIX_CHARS = {
37
- DOT_LITERAL,
38
- PLUS_LITERAL,
39
- QMARK_LITERAL,
40
- SLASH_LITERAL,
41
- ONE_CHAR,
42
- QMARK,
43
- END_ANCHOR,
44
- DOTS_SLASH,
45
- NO_DOT,
46
- NO_DOTS,
47
- NO_DOT_SLASH,
48
- NO_DOTS_SLASH,
49
- QMARK_NO_DOT,
50
- STAR,
51
- START_ANCHOR,
52
- SEP
53
- };
54
-
55
- /**
56
- * Windows glob regex
57
- */
58
-
59
- const WINDOWS_CHARS = {
60
- ...POSIX_CHARS,
61
-
62
- SLASH_LITERAL: `[${WIN_SLASH}]`,
63
- QMARK: WIN_NO_SLASH,
64
- STAR: `${WIN_NO_SLASH}*?`,
65
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
66
- NO_DOT: `(?!${DOT_LITERAL})`,
67
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
68
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
69
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
70
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
71
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
72
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
73
- SEP: '\\'
74
- };
75
-
76
- /**
77
- * POSIX Bracket Regex
78
- */
79
-
80
- const POSIX_REGEX_SOURCE = {
81
- alnum: 'a-zA-Z0-9',
82
- alpha: 'a-zA-Z',
83
- ascii: '\\x00-\\x7F',
84
- blank: ' \\t',
85
- cntrl: '\\x00-\\x1F\\x7F',
86
- digit: '0-9',
87
- graph: '\\x21-\\x7E',
88
- lower: 'a-z',
89
- print: '\\x20-\\x7E ',
90
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
91
- space: ' \\t\\r\\n\\v\\f',
92
- upper: 'A-Z',
93
- word: 'A-Za-z0-9_',
94
- xdigit: 'A-Fa-f0-9'
95
- };
96
-
97
- constants = {
98
- MAX_LENGTH: 1024 * 64,
99
- POSIX_REGEX_SOURCE,
100
-
101
- // regular expressions
102
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
103
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
104
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
105
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
106
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
107
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
108
-
109
- // Replace globs with equivalent patterns to reduce parsing time.
110
- REPLACEMENTS: {
111
- __proto__: null,
112
- '***': '*',
113
- '**/**': '**',
114
- '**/**/**': '**'
115
- },
116
-
117
- // Digits
118
- CHAR_0: 48, /* 0 */
119
- CHAR_9: 57, /* 9 */
120
-
121
- // Alphabet chars.
122
- CHAR_UPPERCASE_A: 65, /* A */
123
- CHAR_LOWERCASE_A: 97, /* a */
124
- CHAR_UPPERCASE_Z: 90, /* Z */
125
- CHAR_LOWERCASE_Z: 122, /* z */
126
-
127
- CHAR_LEFT_PARENTHESES: 40, /* ( */
128
- CHAR_RIGHT_PARENTHESES: 41, /* ) */
129
-
130
- CHAR_ASTERISK: 42, /* * */
131
-
132
- // Non-alphabetic chars.
133
- CHAR_AMPERSAND: 38, /* & */
134
- CHAR_AT: 64, /* @ */
135
- CHAR_BACKWARD_SLASH: 92, /* \ */
136
- CHAR_CARRIAGE_RETURN: 13, /* \r */
137
- CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
138
- CHAR_COLON: 58, /* : */
139
- CHAR_COMMA: 44, /* , */
140
- CHAR_DOT: 46, /* . */
141
- CHAR_DOUBLE_QUOTE: 34, /* " */
142
- CHAR_EQUAL: 61, /* = */
143
- CHAR_EXCLAMATION_MARK: 33, /* ! */
144
- CHAR_FORM_FEED: 12, /* \f */
145
- CHAR_FORWARD_SLASH: 47, /* / */
146
- CHAR_GRAVE_ACCENT: 96, /* ` */
147
- CHAR_HASH: 35, /* # */
148
- CHAR_HYPHEN_MINUS: 45, /* - */
149
- CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
150
- CHAR_LEFT_CURLY_BRACE: 123, /* { */
151
- CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
152
- CHAR_LINE_FEED: 10, /* \n */
153
- CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
154
- CHAR_PERCENT: 37, /* % */
155
- CHAR_PLUS: 43, /* + */
156
- CHAR_QUESTION_MARK: 63, /* ? */
157
- CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
158
- CHAR_RIGHT_CURLY_BRACE: 125, /* } */
159
- CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
160
- CHAR_SEMICOLON: 59, /* ; */
161
- CHAR_SINGLE_QUOTE: 39, /* ' */
162
- CHAR_SPACE: 32, /* */
163
- CHAR_TAB: 9, /* \t */
164
- CHAR_UNDERSCORE: 95, /* _ */
165
- CHAR_VERTICAL_LINE: 124, /* | */
166
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
167
-
168
- /**
169
- * Create EXTGLOB_CHARS
170
- */
171
-
172
- extglobChars(chars) {
173
- return {
174
- '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
175
- '?': { type: 'qmark', open: '(?:', close: ')?' },
176
- '+': { type: 'plus', open: '(?:', close: ')+' },
177
- '*': { type: 'star', open: '(?:', close: ')*' },
178
- '@': { type: 'at', open: '(?:', close: ')' }
179
- };
180
- },
181
-
182
- /**
183
- * Create GLOB_CHARS
184
- */
185
-
186
- globChars(win32) {
187
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
188
- }
189
- };
190
- return constants;
191
- }
192
-
193
- /*global navigator*/
194
-
195
- var hasRequiredUtils;
196
-
197
- function requireUtils () {
198
- if (hasRequiredUtils) return utils;
199
- hasRequiredUtils = 1;
200
- (function (exports) {
201
-
202
- const {
203
- REGEX_BACKSLASH,
204
- REGEX_REMOVE_BACKSLASH,
205
- REGEX_SPECIAL_CHARS,
206
- REGEX_SPECIAL_CHARS_GLOBAL
207
- } = /*@__PURE__*/ requireConstants();
208
-
209
- exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
210
- exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
211
- exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
212
- exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
213
- exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
214
-
215
- exports.isWindows = () => {
216
- if (typeof navigator !== 'undefined' && navigator.platform) {
217
- const platform = navigator.platform.toLowerCase();
218
- return platform === 'win32' || platform === 'windows';
219
- }
220
-
221
- if (typeof process !== 'undefined' && process.platform) {
222
- return process.platform === 'win32';
223
- }
224
-
225
- return false;
226
- };
227
-
228
- exports.removeBackslashes = str => {
229
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
230
- return match === '\\' ? '' : match;
231
- });
232
- };
233
-
234
- exports.escapeLast = (input, char, lastIdx) => {
235
- const idx = input.lastIndexOf(char, lastIdx);
236
- if (idx === -1) return input;
237
- if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
238
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
239
- };
240
-
241
- exports.removePrefix = (input, state = {}) => {
242
- let output = input;
243
- if (output.startsWith('./')) {
244
- output = output.slice(2);
245
- state.prefix = './';
246
- }
247
- return output;
248
- };
249
-
250
- exports.wrapOutput = (input, state = {}, options = {}) => {
251
- const prepend = options.contains ? '' : '^';
252
- const append = options.contains ? '' : '$';
253
-
254
- let output = `${prepend}(?:${input})${append}`;
255
- if (state.negated === true) {
256
- output = `(?:^(?!${output}).*$)`;
257
- }
258
- return output;
259
- };
260
-
261
- exports.basename = (path, { windows } = {}) => {
262
- const segs = path.split(windows ? /[\\/]/ : '/');
263
- const last = segs[segs.length - 1];
264
-
265
- if (last === '') {
266
- return segs[segs.length - 2];
267
- }
268
-
269
- return last;
270
- };
271
- } (utils));
272
- return utils;
273
- }
274
-
275
- var scan_1;
276
- var hasRequiredScan;
277
-
278
- function requireScan () {
279
- if (hasRequiredScan) return scan_1;
280
- hasRequiredScan = 1;
281
-
282
- const utils = /*@__PURE__*/ requireUtils();
283
- const {
284
- CHAR_ASTERISK, /* * */
285
- CHAR_AT, /* @ */
286
- CHAR_BACKWARD_SLASH, /* \ */
287
- CHAR_COMMA, /* , */
288
- CHAR_DOT, /* . */
289
- CHAR_EXCLAMATION_MARK, /* ! */
290
- CHAR_FORWARD_SLASH, /* / */
291
- CHAR_LEFT_CURLY_BRACE, /* { */
292
- CHAR_LEFT_PARENTHESES, /* ( */
293
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
294
- CHAR_PLUS, /* + */
295
- CHAR_QUESTION_MARK, /* ? */
296
- CHAR_RIGHT_CURLY_BRACE, /* } */
297
- CHAR_RIGHT_PARENTHESES, /* ) */
298
- CHAR_RIGHT_SQUARE_BRACKET /* ] */
299
- } = /*@__PURE__*/ requireConstants();
300
-
301
- const isPathSeparator = code => {
302
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
303
- };
304
-
305
- const depth = token => {
306
- if (token.isPrefix !== true) {
307
- token.depth = token.isGlobstar ? Infinity : 1;
308
- }
309
- };
310
-
311
- /**
312
- * Quickly scans a glob pattern and returns an object with a handful of
313
- * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
314
- * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
315
- * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
316
- *
317
- * ```js
318
- * const pm = require('picomatch');
319
- * console.log(pm.scan('foo/bar/*.js'));
320
- * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
321
- * ```
322
- * @param {String} `str`
323
- * @param {Object} `options`
324
- * @return {Object} Returns an object with tokens and regex source string.
325
- * @api public
326
- */
327
-
328
- const scan = (input, options) => {
329
- const opts = options || {};
330
-
331
- const length = input.length - 1;
332
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
333
- const slashes = [];
334
- const tokens = [];
335
- const parts = [];
336
-
337
- let str = input;
338
- let index = -1;
339
- let start = 0;
340
- let lastIndex = 0;
341
- let isBrace = false;
342
- let isBracket = false;
343
- let isGlob = false;
344
- let isExtglob = false;
345
- let isGlobstar = false;
346
- let braceEscaped = false;
347
- let backslashes = false;
348
- let negated = false;
349
- let negatedExtglob = false;
350
- let finished = false;
351
- let braces = 0;
352
- let prev;
353
- let code;
354
- let token = { value: '', depth: 0, isGlob: false };
355
-
356
- const eos = () => index >= length;
357
- const peek = () => str.charCodeAt(index + 1);
358
- const advance = () => {
359
- prev = code;
360
- return str.charCodeAt(++index);
361
- };
362
-
363
- while (index < length) {
364
- code = advance();
365
- let next;
366
-
367
- if (code === CHAR_BACKWARD_SLASH) {
368
- backslashes = token.backslashes = true;
369
- code = advance();
370
-
371
- if (code === CHAR_LEFT_CURLY_BRACE) {
372
- braceEscaped = true;
373
- }
374
- continue;
375
- }
376
-
377
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
378
- braces++;
379
-
380
- while (eos() !== true && (code = advance())) {
381
- if (code === CHAR_BACKWARD_SLASH) {
382
- backslashes = token.backslashes = true;
383
- advance();
384
- continue;
385
- }
386
-
387
- if (code === CHAR_LEFT_CURLY_BRACE) {
388
- braces++;
389
- continue;
390
- }
391
-
392
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
393
- isBrace = token.isBrace = true;
394
- isGlob = token.isGlob = true;
395
- finished = true;
396
-
397
- if (scanToEnd === true) {
398
- continue;
399
- }
400
-
401
- break;
402
- }
403
-
404
- if (braceEscaped !== true && code === CHAR_COMMA) {
405
- isBrace = token.isBrace = true;
406
- isGlob = token.isGlob = true;
407
- finished = true;
408
-
409
- if (scanToEnd === true) {
410
- continue;
411
- }
412
-
413
- break;
414
- }
415
-
416
- if (code === CHAR_RIGHT_CURLY_BRACE) {
417
- braces--;
418
-
419
- if (braces === 0) {
420
- braceEscaped = false;
421
- isBrace = token.isBrace = true;
422
- finished = true;
423
- break;
424
- }
425
- }
426
- }
427
-
428
- if (scanToEnd === true) {
429
- continue;
430
- }
431
-
432
- break;
433
- }
434
-
435
- if (code === CHAR_FORWARD_SLASH) {
436
- slashes.push(index);
437
- tokens.push(token);
438
- token = { value: '', depth: 0, isGlob: false };
439
-
440
- if (finished === true) continue;
441
- if (prev === CHAR_DOT && index === (start + 1)) {
442
- start += 2;
443
- continue;
444
- }
445
-
446
- lastIndex = index + 1;
447
- continue;
448
- }
449
-
450
- if (opts.noext !== true) {
451
- const isExtglobChar = code === CHAR_PLUS
452
- || code === CHAR_AT
453
- || code === CHAR_ASTERISK
454
- || code === CHAR_QUESTION_MARK
455
- || code === CHAR_EXCLAMATION_MARK;
456
-
457
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
458
- isGlob = token.isGlob = true;
459
- isExtglob = token.isExtglob = true;
460
- finished = true;
461
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
462
- negatedExtglob = true;
463
- }
464
-
465
- if (scanToEnd === true) {
466
- while (eos() !== true && (code = advance())) {
467
- if (code === CHAR_BACKWARD_SLASH) {
468
- backslashes = token.backslashes = true;
469
- code = advance();
470
- continue;
471
- }
472
-
473
- if (code === CHAR_RIGHT_PARENTHESES) {
474
- isGlob = token.isGlob = true;
475
- finished = true;
476
- break;
477
- }
478
- }
479
- continue;
480
- }
481
- break;
482
- }
483
- }
484
-
485
- if (code === CHAR_ASTERISK) {
486
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
487
- isGlob = token.isGlob = true;
488
- finished = true;
489
-
490
- if (scanToEnd === true) {
491
- continue;
492
- }
493
- break;
494
- }
495
-
496
- if (code === CHAR_QUESTION_MARK) {
497
- isGlob = token.isGlob = true;
498
- finished = true;
499
-
500
- if (scanToEnd === true) {
501
- continue;
502
- }
503
- break;
504
- }
505
-
506
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
507
- while (eos() !== true && (next = advance())) {
508
- if (next === CHAR_BACKWARD_SLASH) {
509
- backslashes = token.backslashes = true;
510
- advance();
511
- continue;
512
- }
513
-
514
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
515
- isBracket = token.isBracket = true;
516
- isGlob = token.isGlob = true;
517
- finished = true;
518
- break;
519
- }
520
- }
521
-
522
- if (scanToEnd === true) {
523
- continue;
524
- }
525
-
526
- break;
527
- }
528
-
529
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
530
- negated = token.negated = true;
531
- start++;
532
- continue;
533
- }
534
-
535
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
536
- isGlob = token.isGlob = true;
537
-
538
- if (scanToEnd === true) {
539
- while (eos() !== true && (code = advance())) {
540
- if (code === CHAR_LEFT_PARENTHESES) {
541
- backslashes = token.backslashes = true;
542
- code = advance();
543
- continue;
544
- }
545
-
546
- if (code === CHAR_RIGHT_PARENTHESES) {
547
- finished = true;
548
- break;
549
- }
550
- }
551
- continue;
552
- }
553
- break;
554
- }
555
-
556
- if (isGlob === true) {
557
- finished = true;
558
-
559
- if (scanToEnd === true) {
560
- continue;
561
- }
562
-
563
- break;
564
- }
565
- }
566
-
567
- if (opts.noext === true) {
568
- isExtglob = false;
569
- isGlob = false;
570
- }
571
-
572
- let base = str;
573
- let prefix = '';
574
- let glob = '';
575
-
576
- if (start > 0) {
577
- prefix = str.slice(0, start);
578
- str = str.slice(start);
579
- lastIndex -= start;
580
- }
581
-
582
- if (base && isGlob === true && lastIndex > 0) {
583
- base = str.slice(0, lastIndex);
584
- glob = str.slice(lastIndex);
585
- } else if (isGlob === true) {
586
- base = '';
587
- glob = str;
588
- } else {
589
- base = str;
590
- }
591
-
592
- if (base && base !== '' && base !== '/' && base !== str) {
593
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
594
- base = base.slice(0, -1);
595
- }
596
- }
597
-
598
- if (opts.unescape === true) {
599
- if (glob) glob = utils.removeBackslashes(glob);
600
-
601
- if (base && backslashes === true) {
602
- base = utils.removeBackslashes(base);
603
- }
604
- }
605
-
606
- const state = {
607
- prefix,
608
- input,
609
- start,
610
- base,
611
- glob,
612
- isBrace,
613
- isBracket,
614
- isGlob,
615
- isExtglob,
616
- isGlobstar,
617
- negated,
618
- negatedExtglob
619
- };
620
-
621
- if (opts.tokens === true) {
622
- state.maxDepth = 0;
623
- if (!isPathSeparator(code)) {
624
- tokens.push(token);
625
- }
626
- state.tokens = tokens;
627
- }
628
-
629
- if (opts.parts === true || opts.tokens === true) {
630
- let prevIndex;
631
-
632
- for (let idx = 0; idx < slashes.length; idx++) {
633
- const n = prevIndex ? prevIndex + 1 : start;
634
- const i = slashes[idx];
635
- const value = input.slice(n, i);
636
- if (opts.tokens) {
637
- if (idx === 0 && start !== 0) {
638
- tokens[idx].isPrefix = true;
639
- tokens[idx].value = prefix;
640
- } else {
641
- tokens[idx].value = value;
642
- }
643
- depth(tokens[idx]);
644
- state.maxDepth += tokens[idx].depth;
645
- }
646
- if (idx !== 0 || value !== '') {
647
- parts.push(value);
648
- }
649
- prevIndex = i;
650
- }
651
-
652
- if (prevIndex && prevIndex + 1 < input.length) {
653
- const value = input.slice(prevIndex + 1);
654
- parts.push(value);
655
-
656
- if (opts.tokens) {
657
- tokens[tokens.length - 1].value = value;
658
- depth(tokens[tokens.length - 1]);
659
- state.maxDepth += tokens[tokens.length - 1].depth;
660
- }
661
- }
662
-
663
- state.slashes = slashes;
664
- state.parts = parts;
665
- }
666
-
667
- return state;
668
- };
669
-
670
- scan_1 = scan;
671
- return scan_1;
672
- }
673
-
674
- var parse_1;
675
- var hasRequiredParse;
676
-
677
- function requireParse () {
678
- if (hasRequiredParse) return parse_1;
679
- hasRequiredParse = 1;
680
-
681
- const constants = /*@__PURE__*/ requireConstants();
682
- const utils = /*@__PURE__*/ requireUtils();
683
-
684
- /**
685
- * Constants
686
- */
687
-
688
- const {
689
- MAX_LENGTH,
690
- POSIX_REGEX_SOURCE,
691
- REGEX_NON_SPECIAL_CHARS,
692
- REGEX_SPECIAL_CHARS_BACKREF,
693
- REPLACEMENTS
694
- } = constants;
695
-
696
- /**
697
- * Helpers
698
- */
699
-
700
- const expandRange = (args, options) => {
701
- if (typeof options.expandRange === 'function') {
702
- return options.expandRange(...args, options);
703
- }
704
-
705
- args.sort();
706
- const value = `[${args.join('-')}]`;
707
-
708
- try {
709
- /* eslint-disable-next-line no-new */
710
- new RegExp(value);
711
- } catch (ex) {
712
- return args.map(v => utils.escapeRegex(v)).join('..');
713
- }
714
-
715
- return value;
716
- };
717
-
718
- /**
719
- * Create the message for a syntax error
720
- */
721
-
722
- const syntaxError = (type, char) => {
723
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
724
- };
725
-
726
- /**
727
- * Parse the given input string.
728
- * @param {String} input
729
- * @param {Object} options
730
- * @return {Object}
731
- */
732
-
733
- const parse = (input, options) => {
734
- if (typeof input !== 'string') {
735
- throw new TypeError('Expected a string');
736
- }
737
-
738
- input = REPLACEMENTS[input] || input;
739
-
740
- const opts = { ...options };
741
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
742
-
743
- let len = input.length;
744
- if (len > max) {
745
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
746
- }
747
-
748
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
749
- const tokens = [bos];
750
-
751
- const capture = opts.capture ? '' : '?:';
752
-
753
- // create constants based on platform, for windows or posix
754
- const PLATFORM_CHARS = constants.globChars(opts.windows);
755
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
756
-
757
- const {
758
- DOT_LITERAL,
759
- PLUS_LITERAL,
760
- SLASH_LITERAL,
761
- ONE_CHAR,
762
- DOTS_SLASH,
763
- NO_DOT,
764
- NO_DOT_SLASH,
765
- NO_DOTS_SLASH,
766
- QMARK,
767
- QMARK_NO_DOT,
768
- STAR,
769
- START_ANCHOR
770
- } = PLATFORM_CHARS;
771
-
772
- const globstar = opts => {
773
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
774
- };
775
-
776
- const nodot = opts.dot ? '' : NO_DOT;
777
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
778
- let star = opts.bash === true ? globstar(opts) : STAR;
779
-
780
- if (opts.capture) {
781
- star = `(${star})`;
782
- }
783
-
784
- // minimatch options support
785
- if (typeof opts.noext === 'boolean') {
786
- opts.noextglob = opts.noext;
787
- }
788
-
789
- const state = {
790
- input,
791
- index: -1,
792
- start: 0,
793
- dot: opts.dot === true,
794
- consumed: '',
795
- output: '',
796
- prefix: '',
797
- backtrack: false,
798
- negated: false,
799
- brackets: 0,
800
- braces: 0,
801
- parens: 0,
802
- quotes: 0,
803
- globstar: false,
804
- tokens
805
- };
806
-
807
- input = utils.removePrefix(input, state);
808
- len = input.length;
809
-
810
- const extglobs = [];
811
- const braces = [];
812
- const stack = [];
813
- let prev = bos;
814
- let value;
815
-
816
- /**
817
- * Tokenizing helpers
818
- */
819
-
820
- const eos = () => state.index === len - 1;
821
- const peek = state.peek = (n = 1) => input[state.index + n];
822
- const advance = state.advance = () => input[++state.index] || '';
823
- const remaining = () => input.slice(state.index + 1);
824
- const consume = (value = '', num = 0) => {
825
- state.consumed += value;
826
- state.index += num;
827
- };
828
-
829
- const append = token => {
830
- state.output += token.output != null ? token.output : token.value;
831
- consume(token.value);
832
- };
833
-
834
- const negate = () => {
835
- let count = 1;
836
-
837
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
838
- advance();
839
- state.start++;
840
- count++;
841
- }
842
-
843
- if (count % 2 === 0) {
844
- return false;
845
- }
846
-
847
- state.negated = true;
848
- state.start++;
849
- return true;
850
- };
851
-
852
- const increment = type => {
853
- state[type]++;
854
- stack.push(type);
855
- };
856
-
857
- const decrement = type => {
858
- state[type]--;
859
- stack.pop();
860
- };
861
-
862
- /**
863
- * Push tokens onto the tokens array. This helper speeds up
864
- * tokenizing by 1) helping us avoid backtracking as much as possible,
865
- * and 2) helping us avoid creating extra tokens when consecutive
866
- * characters are plain text. This improves performance and simplifies
867
- * lookbehinds.
868
- */
869
-
870
- const push = tok => {
871
- if (prev.type === 'globstar') {
872
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
873
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
874
-
875
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
876
- state.output = state.output.slice(0, -prev.output.length);
877
- prev.type = 'star';
878
- prev.value = '*';
879
- prev.output = star;
880
- state.output += prev.output;
881
- }
882
- }
883
-
884
- if (extglobs.length && tok.type !== 'paren') {
885
- extglobs[extglobs.length - 1].inner += tok.value;
886
- }
887
-
888
- if (tok.value || tok.output) append(tok);
889
- if (prev && prev.type === 'text' && tok.type === 'text') {
890
- prev.output = (prev.output || prev.value) + tok.value;
891
- prev.value += tok.value;
892
- return;
893
- }
894
-
895
- tok.prev = prev;
896
- tokens.push(tok);
897
- prev = tok;
898
- };
899
-
900
- const extglobOpen = (type, value) => {
901
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
902
-
903
- token.prev = prev;
904
- token.parens = state.parens;
905
- token.output = state.output;
906
- const output = (opts.capture ? '(' : '') + token.open;
907
-
908
- increment('parens');
909
- push({ type, value, output: state.output ? '' : ONE_CHAR });
910
- push({ type: 'paren', extglob: true, value: advance(), output });
911
- extglobs.push(token);
912
- };
913
-
914
- const extglobClose = token => {
915
- let output = token.close + (opts.capture ? ')' : '');
916
- let rest;
917
-
918
- if (token.type === 'negate') {
919
- let extglobStar = star;
920
-
921
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
922
- extglobStar = globstar(opts);
923
- }
924
-
925
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
926
- output = token.close = `)$))${extglobStar}`;
927
- }
928
-
929
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
930
- // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
931
- // In this case, we need to parse the string and use it in the output of the original pattern.
932
- // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
933
- //
934
- // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
935
- const expression = parse(rest, { ...options, fastpaths: false }).output;
936
-
937
- output = token.close = `)${expression})${extglobStar})`;
938
- }
939
-
940
- if (token.prev.type === 'bos') {
941
- state.negatedExtglob = true;
942
- }
943
- }
944
-
945
- push({ type: 'paren', extglob: true, value, output });
946
- decrement('parens');
947
- };
948
-
949
- /**
950
- * Fast paths
951
- */
952
-
953
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
954
- let backslashes = false;
955
-
956
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
957
- if (first === '\\') {
958
- backslashes = true;
959
- return m;
960
- }
961
-
962
- if (first === '?') {
963
- if (esc) {
964
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
965
- }
966
- if (index === 0) {
967
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
968
- }
969
- return QMARK.repeat(chars.length);
970
- }
971
-
972
- if (first === '.') {
973
- return DOT_LITERAL.repeat(chars.length);
974
- }
975
-
976
- if (first === '*') {
977
- if (esc) {
978
- return esc + first + (rest ? star : '');
979
- }
980
- return star;
981
- }
982
- return esc ? m : `\\${m}`;
983
- });
984
-
985
- if (backslashes === true) {
986
- if (opts.unescape === true) {
987
- output = output.replace(/\\/g, '');
988
- } else {
989
- output = output.replace(/\\+/g, m => {
990
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
991
- });
992
- }
993
- }
994
-
995
- if (output === input && opts.contains === true) {
996
- state.output = input;
997
- return state;
998
- }
999
-
1000
- state.output = utils.wrapOutput(output, state, options);
1001
- return state;
1002
- }
1003
-
1004
- /**
1005
- * Tokenize input until we reach end-of-string
1006
- */
1007
-
1008
- while (!eos()) {
1009
- value = advance();
1010
-
1011
- if (value === '\u0000') {
1012
- continue;
1013
- }
1014
-
1015
- /**
1016
- * Escaped characters
1017
- */
1018
-
1019
- if (value === '\\') {
1020
- const next = peek();
1021
-
1022
- if (next === '/' && opts.bash !== true) {
1023
- continue;
1024
- }
1025
-
1026
- if (next === '.' || next === ';') {
1027
- continue;
1028
- }
1029
-
1030
- if (!next) {
1031
- value += '\\';
1032
- push({ type: 'text', value });
1033
- continue;
1034
- }
1035
-
1036
- // collapse slashes to reduce potential for exploits
1037
- const match = /^\\+/.exec(remaining());
1038
- let slashes = 0;
1039
-
1040
- if (match && match[0].length > 2) {
1041
- slashes = match[0].length;
1042
- state.index += slashes;
1043
- if (slashes % 2 !== 0) {
1044
- value += '\\';
1045
- }
1046
- }
1047
-
1048
- if (opts.unescape === true) {
1049
- value = advance();
1050
- } else {
1051
- value += advance();
1052
- }
1053
-
1054
- if (state.brackets === 0) {
1055
- push({ type: 'text', value });
1056
- continue;
1057
- }
1058
- }
1059
-
1060
- /**
1061
- * If we're inside a regex character class, continue
1062
- * until we reach the closing bracket.
1063
- */
1064
-
1065
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
1066
- if (opts.posix !== false && value === ':') {
1067
- const inner = prev.value.slice(1);
1068
- if (inner.includes('[')) {
1069
- prev.posix = true;
1070
-
1071
- if (inner.includes(':')) {
1072
- const idx = prev.value.lastIndexOf('[');
1073
- const pre = prev.value.slice(0, idx);
1074
- const rest = prev.value.slice(idx + 2);
1075
- const posix = POSIX_REGEX_SOURCE[rest];
1076
- if (posix) {
1077
- prev.value = pre + posix;
1078
- state.backtrack = true;
1079
- advance();
1080
-
1081
- if (!bos.output && tokens.indexOf(prev) === 1) {
1082
- bos.output = ONE_CHAR;
1083
- }
1084
- continue;
1085
- }
1086
- }
1087
- }
1088
- }
1089
-
1090
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
1091
- value = `\\${value}`;
1092
- }
1093
-
1094
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
1095
- value = `\\${value}`;
1096
- }
1097
-
1098
- if (opts.posix === true && value === '!' && prev.value === '[') {
1099
- value = '^';
1100
- }
1101
-
1102
- prev.value += value;
1103
- append({ value });
1104
- continue;
1105
- }
1106
-
1107
- /**
1108
- * If we're inside a quoted string, continue
1109
- * until we reach the closing double quote.
1110
- */
1111
-
1112
- if (state.quotes === 1 && value !== '"') {
1113
- value = utils.escapeRegex(value);
1114
- prev.value += value;
1115
- append({ value });
1116
- continue;
1117
- }
1118
-
1119
- /**
1120
- * Double quotes
1121
- */
1122
-
1123
- if (value === '"') {
1124
- state.quotes = state.quotes === 1 ? 0 : 1;
1125
- if (opts.keepQuotes === true) {
1126
- push({ type: 'text', value });
1127
- }
1128
- continue;
1129
- }
1130
-
1131
- /**
1132
- * Parentheses
1133
- */
1134
-
1135
- if (value === '(') {
1136
- increment('parens');
1137
- push({ type: 'paren', value });
1138
- continue;
1139
- }
1140
-
1141
- if (value === ')') {
1142
- if (state.parens === 0 && opts.strictBrackets === true) {
1143
- throw new SyntaxError(syntaxError('opening', '('));
1144
- }
1145
-
1146
- const extglob = extglobs[extglobs.length - 1];
1147
- if (extglob && state.parens === extglob.parens + 1) {
1148
- extglobClose(extglobs.pop());
1149
- continue;
1150
- }
1151
-
1152
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
1153
- decrement('parens');
1154
- continue;
1155
- }
1156
-
1157
- /**
1158
- * Square brackets
1159
- */
1160
-
1161
- if (value === '[') {
1162
- if (opts.nobracket === true || !remaining().includes(']')) {
1163
- if (opts.nobracket !== true && opts.strictBrackets === true) {
1164
- throw new SyntaxError(syntaxError('closing', ']'));
1165
- }
1166
-
1167
- value = `\\${value}`;
1168
- } else {
1169
- increment('brackets');
1170
- }
1171
-
1172
- push({ type: 'bracket', value });
1173
- continue;
1174
- }
1175
-
1176
- if (value === ']') {
1177
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
1178
- push({ type: 'text', value, output: `\\${value}` });
1179
- continue;
1180
- }
1181
-
1182
- if (state.brackets === 0) {
1183
- if (opts.strictBrackets === true) {
1184
- throw new SyntaxError(syntaxError('opening', '['));
1185
- }
1186
-
1187
- push({ type: 'text', value, output: `\\${value}` });
1188
- continue;
1189
- }
1190
-
1191
- decrement('brackets');
1192
-
1193
- const prevValue = prev.value.slice(1);
1194
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
1195
- value = `/${value}`;
1196
- }
1197
-
1198
- prev.value += value;
1199
- append({ value });
1200
-
1201
- // when literal brackets are explicitly disabled
1202
- // assume we should match with a regex character class
1203
- if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
1204
- continue;
1205
- }
1206
-
1207
- const escaped = utils.escapeRegex(prev.value);
1208
- state.output = state.output.slice(0, -prev.value.length);
1209
-
1210
- // when literal brackets are explicitly enabled
1211
- // assume we should escape the brackets to match literal characters
1212
- if (opts.literalBrackets === true) {
1213
- state.output += escaped;
1214
- prev.value = escaped;
1215
- continue;
1216
- }
1217
-
1218
- // when the user specifies nothing, try to match both
1219
- prev.value = `(${capture}${escaped}|${prev.value})`;
1220
- state.output += prev.value;
1221
- continue;
1222
- }
1223
-
1224
- /**
1225
- * Braces
1226
- */
1227
-
1228
- if (value === '{' && opts.nobrace !== true) {
1229
- increment('braces');
1230
-
1231
- const open = {
1232
- type: 'brace',
1233
- value,
1234
- output: '(',
1235
- outputIndex: state.output.length,
1236
- tokensIndex: state.tokens.length
1237
- };
1238
-
1239
- braces.push(open);
1240
- push(open);
1241
- continue;
1242
- }
1243
-
1244
- if (value === '}') {
1245
- const brace = braces[braces.length - 1];
1246
-
1247
- if (opts.nobrace === true || !brace) {
1248
- push({ type: 'text', value, output: value });
1249
- continue;
1250
- }
1251
-
1252
- let output = ')';
1253
-
1254
- if (brace.dots === true) {
1255
- const arr = tokens.slice();
1256
- const range = [];
1257
-
1258
- for (let i = arr.length - 1; i >= 0; i--) {
1259
- tokens.pop();
1260
- if (arr[i].type === 'brace') {
1261
- break;
1262
- }
1263
- if (arr[i].type !== 'dots') {
1264
- range.unshift(arr[i].value);
1265
- }
1266
- }
1267
-
1268
- output = expandRange(range, opts);
1269
- state.backtrack = true;
1270
- }
1271
-
1272
- if (brace.comma !== true && brace.dots !== true) {
1273
- const out = state.output.slice(0, brace.outputIndex);
1274
- const toks = state.tokens.slice(brace.tokensIndex);
1275
- brace.value = brace.output = '\\{';
1276
- value = output = '\\}';
1277
- state.output = out;
1278
- for (const t of toks) {
1279
- state.output += (t.output || t.value);
1280
- }
1281
- }
1282
-
1283
- push({ type: 'brace', value, output });
1284
- decrement('braces');
1285
- braces.pop();
1286
- continue;
1287
- }
1288
-
1289
- /**
1290
- * Pipes
1291
- */
1292
-
1293
- if (value === '|') {
1294
- if (extglobs.length > 0) {
1295
- extglobs[extglobs.length - 1].conditions++;
1296
- }
1297
- push({ type: 'text', value });
1298
- continue;
1299
- }
1300
-
1301
- /**
1302
- * Commas
1303
- */
1304
-
1305
- if (value === ',') {
1306
- let output = value;
1307
-
1308
- const brace = braces[braces.length - 1];
1309
- if (brace && stack[stack.length - 1] === 'braces') {
1310
- brace.comma = true;
1311
- output = '|';
1312
- }
1313
-
1314
- push({ type: 'comma', value, output });
1315
- continue;
1316
- }
1317
-
1318
- /**
1319
- * Slashes
1320
- */
1321
-
1322
- if (value === '/') {
1323
- // if the beginning of the glob is "./", advance the start
1324
- // to the current index, and don't add the "./" characters
1325
- // to the state. This greatly simplifies lookbehinds when
1326
- // checking for BOS characters like "!" and "." (not "./")
1327
- if (prev.type === 'dot' && state.index === state.start + 1) {
1328
- state.start = state.index + 1;
1329
- state.consumed = '';
1330
- state.output = '';
1331
- tokens.pop();
1332
- prev = bos; // reset "prev" to the first token
1333
- continue;
1334
- }
1335
-
1336
- push({ type: 'slash', value, output: SLASH_LITERAL });
1337
- continue;
1338
- }
1339
-
1340
- /**
1341
- * Dots
1342
- */
1343
-
1344
- if (value === '.') {
1345
- if (state.braces > 0 && prev.type === 'dot') {
1346
- if (prev.value === '.') prev.output = DOT_LITERAL;
1347
- const brace = braces[braces.length - 1];
1348
- prev.type = 'dots';
1349
- prev.output += value;
1350
- prev.value += value;
1351
- brace.dots = true;
1352
- continue;
1353
- }
1354
-
1355
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
1356
- push({ type: 'text', value, output: DOT_LITERAL });
1357
- continue;
1358
- }
1359
-
1360
- push({ type: 'dot', value, output: DOT_LITERAL });
1361
- continue;
1362
- }
1363
-
1364
- /**
1365
- * Question marks
1366
- */
1367
-
1368
- if (value === '?') {
1369
- const isGroup = prev && prev.value === '(';
1370
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1371
- extglobOpen('qmark', value);
1372
- continue;
1373
- }
1374
-
1375
- if (prev && prev.type === 'paren') {
1376
- const next = peek();
1377
- let output = value;
1378
-
1379
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
1380
- output = `\\${value}`;
1381
- }
1382
-
1383
- push({ type: 'text', value, output });
1384
- continue;
1385
- }
1386
-
1387
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
1388
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
1389
- continue;
1390
- }
1391
-
1392
- push({ type: 'qmark', value, output: QMARK });
1393
- continue;
1394
- }
1395
-
1396
- /**
1397
- * Exclamation
1398
- */
1399
-
1400
- if (value === '!') {
1401
- if (opts.noextglob !== true && peek() === '(') {
1402
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
1403
- extglobOpen('negate', value);
1404
- continue;
1405
- }
1406
- }
1407
-
1408
- if (opts.nonegate !== true && state.index === 0) {
1409
- negate();
1410
- continue;
1411
- }
1412
- }
1413
-
1414
- /**
1415
- * Plus
1416
- */
1417
-
1418
- if (value === '+') {
1419
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1420
- extglobOpen('plus', value);
1421
- continue;
1422
- }
1423
-
1424
- if ((prev && prev.value === '(') || opts.regex === false) {
1425
- push({ type: 'plus', value, output: PLUS_LITERAL });
1426
- continue;
1427
- }
1428
-
1429
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
1430
- push({ type: 'plus', value });
1431
- continue;
1432
- }
1433
-
1434
- push({ type: 'plus', value: PLUS_LITERAL });
1435
- continue;
1436
- }
1437
-
1438
- /**
1439
- * Plain text
1440
- */
1441
-
1442
- if (value === '@') {
1443
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1444
- push({ type: 'at', extglob: true, value, output: '' });
1445
- continue;
1446
- }
1447
-
1448
- push({ type: 'text', value });
1449
- continue;
1450
- }
1451
-
1452
- /**
1453
- * Plain text
1454
- */
1455
-
1456
- if (value !== '*') {
1457
- if (value === '$' || value === '^') {
1458
- value = `\\${value}`;
1459
- }
1460
-
1461
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1462
- if (match) {
1463
- value += match[0];
1464
- state.index += match[0].length;
1465
- }
1466
-
1467
- push({ type: 'text', value });
1468
- continue;
1469
- }
1470
-
1471
- /**
1472
- * Stars
1473
- */
1474
-
1475
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
1476
- prev.type = 'star';
1477
- prev.star = true;
1478
- prev.value += value;
1479
- prev.output = star;
1480
- state.backtrack = true;
1481
- state.globstar = true;
1482
- consume(value);
1483
- continue;
1484
- }
1485
-
1486
- let rest = remaining();
1487
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1488
- extglobOpen('star', value);
1489
- continue;
1490
- }
1491
-
1492
- if (prev.type === 'star') {
1493
- if (opts.noglobstar === true) {
1494
- consume(value);
1495
- continue;
1496
- }
1497
-
1498
- const prior = prev.prev;
1499
- const before = prior.prev;
1500
- const isStart = prior.type === 'slash' || prior.type === 'bos';
1501
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
1502
-
1503
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
1504
- push({ type: 'star', value, output: '' });
1505
- continue;
1506
- }
1507
-
1508
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
1509
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
1510
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
1511
- push({ type: 'star', value, output: '' });
1512
- continue;
1513
- }
1514
-
1515
- // strip consecutive `/**/`
1516
- while (rest.slice(0, 3) === '/**') {
1517
- const after = input[state.index + 4];
1518
- if (after && after !== '/') {
1519
- break;
1520
- }
1521
- rest = rest.slice(3);
1522
- consume('/**', 3);
1523
- }
1524
-
1525
- if (prior.type === 'bos' && eos()) {
1526
- prev.type = 'globstar';
1527
- prev.value += value;
1528
- prev.output = globstar(opts);
1529
- state.output = prev.output;
1530
- state.globstar = true;
1531
- consume(value);
1532
- continue;
1533
- }
1534
-
1535
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
1536
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1537
- prior.output = `(?:${prior.output}`;
1538
-
1539
- prev.type = 'globstar';
1540
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
1541
- prev.value += value;
1542
- state.globstar = true;
1543
- state.output += prior.output + prev.output;
1544
- consume(value);
1545
- continue;
1546
- }
1547
-
1548
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
1549
- const end = rest[1] !== void 0 ? '|$' : '';
1550
-
1551
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1552
- prior.output = `(?:${prior.output}`;
1553
-
1554
- prev.type = 'globstar';
1555
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1556
- prev.value += value;
1557
-
1558
- state.output += prior.output + prev.output;
1559
- state.globstar = true;
1560
-
1561
- consume(value + advance());
1562
-
1563
- push({ type: 'slash', value: '/', output: '' });
1564
- continue;
1565
- }
1566
-
1567
- if (prior.type === 'bos' && rest[0] === '/') {
1568
- prev.type = 'globstar';
1569
- prev.value += value;
1570
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1571
- state.output = prev.output;
1572
- state.globstar = true;
1573
- consume(value + advance());
1574
- push({ type: 'slash', value: '/', output: '' });
1575
- continue;
1576
- }
1577
-
1578
- // remove single star from output
1579
- state.output = state.output.slice(0, -prev.output.length);
1580
-
1581
- // reset previous token to globstar
1582
- prev.type = 'globstar';
1583
- prev.output = globstar(opts);
1584
- prev.value += value;
1585
-
1586
- // reset output with globstar
1587
- state.output += prev.output;
1588
- state.globstar = true;
1589
- consume(value);
1590
- continue;
1591
- }
1592
-
1593
- const token = { type: 'star', value, output: star };
1594
-
1595
- if (opts.bash === true) {
1596
- token.output = '.*?';
1597
- if (prev.type === 'bos' || prev.type === 'slash') {
1598
- token.output = nodot + token.output;
1599
- }
1600
- push(token);
1601
- continue;
1602
- }
1603
-
1604
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
1605
- token.output = value;
1606
- push(token);
1607
- continue;
1608
- }
1609
-
1610
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
1611
- if (prev.type === 'dot') {
1612
- state.output += NO_DOT_SLASH;
1613
- prev.output += NO_DOT_SLASH;
1614
-
1615
- } else if (opts.dot === true) {
1616
- state.output += NO_DOTS_SLASH;
1617
- prev.output += NO_DOTS_SLASH;
1618
-
1619
- } else {
1620
- state.output += nodot;
1621
- prev.output += nodot;
1622
- }
1623
-
1624
- if (peek() !== '*') {
1625
- state.output += ONE_CHAR;
1626
- prev.output += ONE_CHAR;
1627
- }
1628
- }
1629
-
1630
- push(token);
1631
- }
1632
-
1633
- while (state.brackets > 0) {
1634
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
1635
- state.output = utils.escapeLast(state.output, '[');
1636
- decrement('brackets');
1637
- }
1638
-
1639
- while (state.parens > 0) {
1640
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
1641
- state.output = utils.escapeLast(state.output, '(');
1642
- decrement('parens');
1643
- }
1644
-
1645
- while (state.braces > 0) {
1646
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
1647
- state.output = utils.escapeLast(state.output, '{');
1648
- decrement('braces');
1649
- }
1650
-
1651
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
1652
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
1653
- }
1654
-
1655
- // rebuild the output if we had to backtrack at any point
1656
- if (state.backtrack === true) {
1657
- state.output = '';
1658
-
1659
- for (const token of state.tokens) {
1660
- state.output += token.output != null ? token.output : token.value;
1661
-
1662
- if (token.suffix) {
1663
- state.output += token.suffix;
1664
- }
1665
- }
1666
- }
1667
-
1668
- return state;
1669
- };
1670
-
1671
- /**
1672
- * Fast paths for creating regular expressions for common glob patterns.
1673
- * This can significantly speed up processing and has very little downside
1674
- * impact when none of the fast paths match.
1675
- */
1676
-
1677
- parse.fastpaths = (input, options) => {
1678
- const opts = { ...options };
1679
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1680
- const len = input.length;
1681
- if (len > max) {
1682
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1683
- }
1684
-
1685
- input = REPLACEMENTS[input] || input;
1686
-
1687
- // create constants based on platform, for windows or posix
1688
- const {
1689
- DOT_LITERAL,
1690
- SLASH_LITERAL,
1691
- ONE_CHAR,
1692
- DOTS_SLASH,
1693
- NO_DOT,
1694
- NO_DOTS,
1695
- NO_DOTS_SLASH,
1696
- STAR,
1697
- START_ANCHOR
1698
- } = constants.globChars(opts.windows);
1699
-
1700
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
1701
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1702
- const capture = opts.capture ? '' : '?:';
1703
- const state = { negated: false, prefix: '' };
1704
- let star = opts.bash === true ? '.*?' : STAR;
1705
-
1706
- if (opts.capture) {
1707
- star = `(${star})`;
1708
- }
1709
-
1710
- const globstar = opts => {
1711
- if (opts.noglobstar === true) return star;
1712
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1713
- };
1714
-
1715
- const create = str => {
1716
- switch (str) {
1717
- case '*':
1718
- return `${nodot}${ONE_CHAR}${star}`;
1719
-
1720
- case '.*':
1721
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1722
-
1723
- case '*.*':
1724
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1725
-
1726
- case '*/*':
1727
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1728
-
1729
- case '**':
1730
- return nodot + globstar(opts);
1731
-
1732
- case '**/*':
1733
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1734
-
1735
- case '**/*.*':
1736
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1737
-
1738
- case '**/.*':
1739
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1740
-
1741
- default: {
1742
- const match = /^(.*?)\.(\w+)$/.exec(str);
1743
- if (!match) return;
1744
-
1745
- const source = create(match[1]);
1746
- if (!source) return;
1747
-
1748
- return source + DOT_LITERAL + match[2];
1749
- }
1750
- }
1751
- };
1752
-
1753
- const output = utils.removePrefix(input, state);
1754
- let source = create(output);
1755
-
1756
- if (source && opts.strictSlashes !== true) {
1757
- source += `${SLASH_LITERAL}?`;
1758
- }
1759
-
1760
- return source;
1761
- };
1762
-
1763
- parse_1 = parse;
1764
- return parse_1;
1765
- }
1766
-
1767
- var picomatch_1$1;
1768
- var hasRequiredPicomatch$1;
1769
-
1770
- function requirePicomatch$1 () {
1771
- if (hasRequiredPicomatch$1) return picomatch_1$1;
1772
- hasRequiredPicomatch$1 = 1;
1773
-
1774
- const scan = /*@__PURE__*/ requireScan();
1775
- const parse = /*@__PURE__*/ requireParse();
1776
- const utils = /*@__PURE__*/ requireUtils();
1777
- const constants = /*@__PURE__*/ requireConstants();
1778
- const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
1779
-
1780
- /**
1781
- * Creates a matcher function from one or more glob patterns. The
1782
- * returned function takes a string to match as its first argument,
1783
- * and returns true if the string is a match. The returned matcher
1784
- * function also takes a boolean as the second argument that, when true,
1785
- * returns an object with additional information.
1786
- *
1787
- * ```js
1788
- * const picomatch = require('picomatch');
1789
- * // picomatch(glob[, options]);
1790
- *
1791
- * const isMatch = picomatch('*.!(*a)');
1792
- * console.log(isMatch('a.a')); //=> false
1793
- * console.log(isMatch('a.b')); //=> true
1794
- * ```
1795
- * @name picomatch
1796
- * @param {String|Array} `globs` One or more glob patterns.
1797
- * @param {Object=} `options`
1798
- * @return {Function=} Returns a matcher function.
1799
- * @api public
1800
- */
1801
-
1802
- const picomatch = (glob, options, returnState = false) => {
1803
- if (Array.isArray(glob)) {
1804
- const fns = glob.map(input => picomatch(input, options, returnState));
1805
- const arrayMatcher = str => {
1806
- for (const isMatch of fns) {
1807
- const state = isMatch(str);
1808
- if (state) return state;
1809
- }
1810
- return false;
1811
- };
1812
- return arrayMatcher;
1813
- }
1814
-
1815
- const isState = isObject(glob) && glob.tokens && glob.input;
1816
-
1817
- if (glob === '' || (typeof glob !== 'string' && !isState)) {
1818
- throw new TypeError('Expected pattern to be a non-empty string');
1819
- }
1820
-
1821
- const opts = options || {};
1822
- const posix = opts.windows;
1823
- const regex = isState
1824
- ? picomatch.compileRe(glob, options)
1825
- : picomatch.makeRe(glob, options, false, true);
1826
-
1827
- const state = regex.state;
1828
- delete regex.state;
1829
-
1830
- let isIgnored = () => false;
1831
- if (opts.ignore) {
1832
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
1833
- isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
1834
- }
1835
-
1836
- const matcher = (input, returnObject = false) => {
1837
- const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
1838
- const result = { glob, state, regex, posix, input, output, match, isMatch };
1839
-
1840
- if (typeof opts.onResult === 'function') {
1841
- opts.onResult(result);
1842
- }
1843
-
1844
- if (isMatch === false) {
1845
- result.isMatch = false;
1846
- return returnObject ? result : false;
1847
- }
1848
-
1849
- if (isIgnored(input)) {
1850
- if (typeof opts.onIgnore === 'function') {
1851
- opts.onIgnore(result);
1852
- }
1853
- result.isMatch = false;
1854
- return returnObject ? result : false;
1855
- }
1856
-
1857
- if (typeof opts.onMatch === 'function') {
1858
- opts.onMatch(result);
1859
- }
1860
- return returnObject ? result : true;
1861
- };
1862
-
1863
- if (returnState) {
1864
- matcher.state = state;
1865
- }
1866
-
1867
- return matcher;
1868
- };
1869
-
1870
- /**
1871
- * Test `input` with the given `regex`. This is used by the main
1872
- * `picomatch()` function to test the input string.
1873
- *
1874
- * ```js
1875
- * const picomatch = require('picomatch');
1876
- * // picomatch.test(input, regex[, options]);
1877
- *
1878
- * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
1879
- * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
1880
- * ```
1881
- * @param {String} `input` String to test.
1882
- * @param {RegExp} `regex`
1883
- * @return {Object} Returns an object with matching info.
1884
- * @api public
1885
- */
1886
-
1887
- picomatch.test = (input, regex, options, { glob, posix } = {}) => {
1888
- if (typeof input !== 'string') {
1889
- throw new TypeError('Expected input to be a string');
1890
- }
1891
-
1892
- if (input === '') {
1893
- return { isMatch: false, output: '' };
1894
- }
1895
-
1896
- const opts = options || {};
1897
- const format = opts.format || (posix ? utils.toPosixSlashes : null);
1898
- let match = input === glob;
1899
- let output = (match && format) ? format(input) : input;
1900
-
1901
- if (match === false) {
1902
- output = format ? format(input) : input;
1903
- match = output === glob;
1904
- }
1905
-
1906
- if (match === false || opts.capture === true) {
1907
- if (opts.matchBase === true || opts.basename === true) {
1908
- match = picomatch.matchBase(input, regex, options, posix);
1909
- } else {
1910
- match = regex.exec(output);
1911
- }
1912
- }
1913
-
1914
- return { isMatch: Boolean(match), match, output };
1915
- };
1916
-
1917
- /**
1918
- * Match the basename of a filepath.
1919
- *
1920
- * ```js
1921
- * const picomatch = require('picomatch');
1922
- * // picomatch.matchBase(input, glob[, options]);
1923
- * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
1924
- * ```
1925
- * @param {String} `input` String to test.
1926
- * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
1927
- * @return {Boolean}
1928
- * @api public
1929
- */
1930
-
1931
- picomatch.matchBase = (input, glob, options) => {
1932
- const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
1933
- return regex.test(utils.basename(input));
1934
- };
1935
-
1936
- /**
1937
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
1938
- *
1939
- * ```js
1940
- * const picomatch = require('picomatch');
1941
- * // picomatch.isMatch(string, patterns[, options]);
1942
- *
1943
- * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
1944
- * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
1945
- * ```
1946
- * @param {String|Array} str The string to test.
1947
- * @param {String|Array} patterns One or more glob patterns to use for matching.
1948
- * @param {Object} [options] See available [options](#options).
1949
- * @return {Boolean} Returns true if any patterns match `str`
1950
- * @api public
1951
- */
1952
-
1953
- picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
1954
-
1955
- /**
1956
- * Parse a glob pattern to create the source string for a regular
1957
- * expression.
1958
- *
1959
- * ```js
1960
- * const picomatch = require('picomatch');
1961
- * const result = picomatch.parse(pattern[, options]);
1962
- * ```
1963
- * @param {String} `pattern`
1964
- * @param {Object} `options`
1965
- * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
1966
- * @api public
1967
- */
1968
-
1969
- picomatch.parse = (pattern, options) => {
1970
- if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
1971
- return parse(pattern, { ...options, fastpaths: false });
1972
- };
1973
-
1974
- /**
1975
- * Scan a glob pattern to separate the pattern into segments.
1976
- *
1977
- * ```js
1978
- * const picomatch = require('picomatch');
1979
- * // picomatch.scan(input[, options]);
1980
- *
1981
- * const result = picomatch.scan('!./foo/*.js');
1982
- * console.log(result);
1983
- * { prefix: '!./',
1984
- * input: '!./foo/*.js',
1985
- * start: 3,
1986
- * base: 'foo',
1987
- * glob: '*.js',
1988
- * isBrace: false,
1989
- * isBracket: false,
1990
- * isGlob: true,
1991
- * isExtglob: false,
1992
- * isGlobstar: false,
1993
- * negated: true }
1994
- * ```
1995
- * @param {String} `input` Glob pattern to scan.
1996
- * @param {Object} `options`
1997
- * @return {Object} Returns an object with
1998
- * @api public
1999
- */
2000
-
2001
- picomatch.scan = (input, options) => scan(input, options);
2002
-
2003
- /**
2004
- * Compile a regular expression from the `state` object returned by the
2005
- * [parse()](#parse) method.
2006
- *
2007
- * @param {Object} `state`
2008
- * @param {Object} `options`
2009
- * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
2010
- * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
2011
- * @return {RegExp}
2012
- * @api public
2013
- */
2014
-
2015
- picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
2016
- if (returnOutput === true) {
2017
- return state.output;
2018
- }
2019
-
2020
- const opts = options || {};
2021
- const prepend = opts.contains ? '' : '^';
2022
- const append = opts.contains ? '' : '$';
2023
-
2024
- let source = `${prepend}(?:${state.output})${append}`;
2025
- if (state && state.negated === true) {
2026
- source = `^(?!${source}).*$`;
2027
- }
2028
-
2029
- const regex = picomatch.toRegex(source, options);
2030
- if (returnState === true) {
2031
- regex.state = state;
2032
- }
2033
-
2034
- return regex;
2035
- };
2036
-
2037
- /**
2038
- * Create a regular expression from a parsed glob pattern.
2039
- *
2040
- * ```js
2041
- * const picomatch = require('picomatch');
2042
- * const state = picomatch.parse('*.js');
2043
- * // picomatch.compileRe(state[, options]);
2044
- *
2045
- * console.log(picomatch.compileRe(state));
2046
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2047
- * ```
2048
- * @param {String} `state` The object returned from the `.parse` method.
2049
- * @param {Object} `options`
2050
- * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
2051
- * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
2052
- * @return {RegExp} Returns a regex created from the given pattern.
2053
- * @api public
2054
- */
2055
-
2056
- picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
2057
- if (!input || typeof input !== 'string') {
2058
- throw new TypeError('Expected a non-empty string');
2059
- }
2060
-
2061
- let parsed = { negated: false, fastpaths: true };
2062
-
2063
- if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
2064
- parsed.output = parse.fastpaths(input, options);
2065
- }
2066
-
2067
- if (!parsed.output) {
2068
- parsed = parse(input, options);
2069
- }
2070
-
2071
- return picomatch.compileRe(parsed, options, returnOutput, returnState);
2072
- };
2073
-
2074
- /**
2075
- * Create a regular expression from the given regex source string.
2076
- *
2077
- * ```js
2078
- * const picomatch = require('picomatch');
2079
- * // picomatch.toRegex(source[, options]);
2080
- *
2081
- * const { output } = picomatch.parse('*.js');
2082
- * console.log(picomatch.toRegex(output));
2083
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
2084
- * ```
2085
- * @param {String} `source` Regular expression source string.
2086
- * @param {Object} `options`
2087
- * @return {RegExp}
2088
- * @api public
2089
- */
2090
-
2091
- picomatch.toRegex = (source, options) => {
2092
- try {
2093
- const opts = options || {};
2094
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
2095
- } catch (err) {
2096
- if (options && options.debug === true) throw err;
2097
- return /$^/;
2098
- }
2099
- };
2100
-
2101
- /**
2102
- * Picomatch constants.
2103
- * @return {Object}
2104
- */
2105
-
2106
- picomatch.constants = constants;
2107
-
2108
- /**
2109
- * Expose "picomatch"
2110
- */
2111
-
2112
- picomatch_1$1 = picomatch;
2113
- return picomatch_1$1;
2114
- }
2115
-
2116
- var picomatch_1;
2117
- var hasRequiredPicomatch;
2118
-
2119
- function requirePicomatch () {
2120
- if (hasRequiredPicomatch) return picomatch_1;
2121
- hasRequiredPicomatch = 1;
2122
-
2123
- const pico = /*@__PURE__*/ requirePicomatch$1();
2124
- const utils = /*@__PURE__*/ requireUtils();
2125
-
2126
- function picomatch(glob, options, returnState = false) {
2127
- // default to os.platform()
2128
- if (options && (options.windows === null || options.windows === undefined)) {
2129
- // don't mutate the original options object
2130
- options = { ...options, windows: utils.isWindows() };
2131
- }
2132
-
2133
- return pico(glob, options, returnState);
2134
- }
2135
-
2136
- Object.assign(picomatch, pico);
2137
- picomatch_1 = picomatch;
2138
- return picomatch_1;
2139
- }
2140
-
2141
- var picomatchExports = /*@__PURE__*/ requirePicomatch();
2142
- const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
2143
-
2144
- export { pm as p };