@voidzero-dev/vite-plus-test 0.0.0-0bfcc90f.20260209-0731

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 (318) hide show
  1. package/LICENSE.md +691 -0
  2. package/browser/context.d.ts +4 -0
  3. package/browser/context.js +20 -0
  4. package/config.d.ts +3 -0
  5. package/coverage.d.ts +1 -0
  6. package/dist/@vitest/browser/client/.vite/manifest.json +24 -0
  7. package/dist/@vitest/browser/client/__vitest__/assets/index-BUCFJtth.js +57 -0
  8. package/dist/@vitest/browser/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
  9. package/dist/@vitest/browser/client/__vitest__/bg.png +0 -0
  10. package/dist/@vitest/browser/client/__vitest__/favicon.ico +0 -0
  11. package/dist/@vitest/browser/client/__vitest__/favicon.svg +5 -0
  12. package/dist/@vitest/browser/client/__vitest__/index.html +32 -0
  13. package/dist/@vitest/browser/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
  14. package/dist/@vitest/browser/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
  15. package/dist/@vitest/browser/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
  16. package/dist/@vitest/browser/client/error-catcher.js +82 -0
  17. package/dist/@vitest/browser/client/esm-client-injector.js +67 -0
  18. package/dist/@vitest/browser/client/favicon.svg +5 -0
  19. package/dist/@vitest/browser/client/orchestrator.html +35 -0
  20. package/dist/@vitest/browser/client/tester/tester.html +13 -0
  21. package/dist/@vitest/browser/client.js +456 -0
  22. package/dist/@vitest/browser/context.d.ts +792 -0
  23. package/dist/@vitest/browser/context.js +541 -0
  24. package/dist/@vitest/browser/expect-element.js +32 -0
  25. package/dist/@vitest/browser/index-D6m36C6U.js +11 -0
  26. package/dist/@vitest/browser/index.d.ts +73 -0
  27. package/dist/@vitest/browser/index.js +3513 -0
  28. package/dist/@vitest/browser/jest-dom.d.ts +724 -0
  29. package/dist/@vitest/browser/locators.d.ts +354 -0
  30. package/dist/@vitest/browser/locators.js +1 -0
  31. package/dist/@vitest/browser/matchers.d.ts +29 -0
  32. package/dist/@vitest/browser/shared/screenshotMatcher/types.d.ts +22 -0
  33. package/dist/@vitest/browser/state.js +280 -0
  34. package/dist/@vitest/browser/types.d.ts +69 -0
  35. package/dist/@vitest/browser-playwright/context.d.ts +1 -0
  36. package/dist/@vitest/browser-playwright/index.d.ts +106 -0
  37. package/dist/@vitest/browser-playwright/index.js +1111 -0
  38. package/dist/@vitest/browser-playwright/locators.js +114 -0
  39. package/dist/@vitest/browser-preview/context.d.ts +1 -0
  40. package/dist/@vitest/browser-preview/index.d.ts +19 -0
  41. package/dist/@vitest/browser-preview/index.js +148 -0
  42. package/dist/@vitest/browser-preview/locators.js +79 -0
  43. package/dist/@vitest/browser-webdriverio/context.d.ts +1 -0
  44. package/dist/@vitest/browser-webdriverio/index.d.ts +63 -0
  45. package/dist/@vitest/browser-webdriverio/index.js +600 -0
  46. package/dist/@vitest/browser-webdriverio/locators.js +163 -0
  47. package/dist/@vitest/expect/index.d.ts +807 -0
  48. package/dist/@vitest/expect/index.js +1875 -0
  49. package/dist/@vitest/mocker/auto-register.d.ts +2 -0
  50. package/dist/@vitest/mocker/auto-register.js +9 -0
  51. package/dist/@vitest/mocker/automock.d.ts +12 -0
  52. package/dist/@vitest/mocker/automock.js +1 -0
  53. package/dist/@vitest/mocker/browser.d.ts +53 -0
  54. package/dist/@vitest/mocker/browser.js +91 -0
  55. package/dist/@vitest/mocker/chunk-automock.js +354 -0
  56. package/dist/@vitest/mocker/chunk-interceptor-native.js +15 -0
  57. package/dist/@vitest/mocker/chunk-mocker.js +521 -0
  58. package/dist/@vitest/mocker/chunk-pathe.M-eThtNZ.js +174 -0
  59. package/dist/@vitest/mocker/chunk-registry.js +185 -0
  60. package/dist/@vitest/mocker/chunk-utils.js +16 -0
  61. package/dist/@vitest/mocker/index.d-C-sLYZi-.d.ts +25 -0
  62. package/dist/@vitest/mocker/index.d.ts +2 -0
  63. package/dist/@vitest/mocker/index.js +185 -0
  64. package/dist/@vitest/mocker/mocker.d-TnKRhz7N.d.ts +81 -0
  65. package/dist/@vitest/mocker/node.d.ts +800 -0
  66. package/dist/@vitest/mocker/node.js +966 -0
  67. package/dist/@vitest/mocker/redirect.d.ts +3 -0
  68. package/dist/@vitest/mocker/redirect.js +79 -0
  69. package/dist/@vitest/mocker/register.d.ts +9 -0
  70. package/dist/@vitest/mocker/register.js +41 -0
  71. package/dist/@vitest/mocker/types.d-B8CCKmHt.d.ts +107 -0
  72. package/dist/@vitest/pretty-format/index.d.ts +124 -0
  73. package/dist/@vitest/pretty-format/index.js +1022 -0
  74. package/dist/@vitest/runner/chunk-tasks.js +340 -0
  75. package/dist/@vitest/runner/index.d.ts +180 -0
  76. package/dist/@vitest/runner/index.js +2114 -0
  77. package/dist/@vitest/runner/tasks.d-C7UxawJ9.d.ts +834 -0
  78. package/dist/@vitest/runner/types.d.ts +183 -0
  79. package/dist/@vitest/runner/types.js +1 -0
  80. package/dist/@vitest/runner/utils.d.ts +45 -0
  81. package/dist/@vitest/runner/utils.js +5 -0
  82. package/dist/@vitest/snapshot/environment.d-DHdQ1Csl.d.ts +22 -0
  83. package/dist/@vitest/snapshot/environment.d.ts +16 -0
  84. package/dist/@vitest/snapshot/environment.js +40 -0
  85. package/dist/@vitest/snapshot/index.d.ts +130 -0
  86. package/dist/@vitest/snapshot/index.js +1437 -0
  87. package/dist/@vitest/snapshot/manager.d.ts +18 -0
  88. package/dist/@vitest/snapshot/manager.js +73 -0
  89. package/dist/@vitest/snapshot/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
  90. package/dist/@vitest/spy/index.d.ts +384 -0
  91. package/dist/@vitest/spy/index.js +433 -0
  92. package/dist/@vitest/utils/chunk-_commonjsHelpers.js +5 -0
  93. package/dist/@vitest/utils/chunk-pathe.M-eThtNZ.js +156 -0
  94. package/dist/@vitest/utils/constants.d.ts +21 -0
  95. package/dist/@vitest/utils/constants.js +49 -0
  96. package/dist/@vitest/utils/diff.d.ts +93 -0
  97. package/dist/@vitest/utils/diff.js +2199 -0
  98. package/dist/@vitest/utils/display.d.ts +29 -0
  99. package/dist/@vitest/utils/display.js +742 -0
  100. package/dist/@vitest/utils/error.d.ts +7 -0
  101. package/dist/@vitest/utils/error.js +42 -0
  102. package/dist/@vitest/utils/helpers.d.ts +73 -0
  103. package/dist/@vitest/utils/helpers.js +295 -0
  104. package/dist/@vitest/utils/highlight.d.ts +9 -0
  105. package/dist/@vitest/utils/highlight.js +538 -0
  106. package/dist/@vitest/utils/index.d.ts +5 -0
  107. package/dist/@vitest/utils/index.js +1 -0
  108. package/dist/@vitest/utils/offset.d.ts +5 -0
  109. package/dist/@vitest/utils/offset.js +32 -0
  110. package/dist/@vitest/utils/resolver.d.ts +7 -0
  111. package/dist/@vitest/utils/resolver.js +71 -0
  112. package/dist/@vitest/utils/serialize.d.ts +3 -0
  113. package/dist/@vitest/utils/serialize.js +118 -0
  114. package/dist/@vitest/utils/source-map.d.ts +55 -0
  115. package/dist/@vitest/utils/source-map.js +478 -0
  116. package/dist/@vitest/utils/timers.d.ts +33 -0
  117. package/dist/@vitest/utils/timers.js +49 -0
  118. package/dist/@vitest/utils/types.d-BCElaP-c.d.ts +53 -0
  119. package/dist/@vitest/utils/types.d.ts +34 -0
  120. package/dist/@vitest/utils/types.js +1 -0
  121. package/dist/browser-compat.js +3 -0
  122. package/dist/browser.d.ts +46 -0
  123. package/dist/browser.js +20 -0
  124. package/dist/chunks/_commonjsHelpers.D26ty3Ew.js +6 -0
  125. package/dist/chunks/base.CJ0Y4ePK.js +165 -0
  126. package/dist/chunks/benchmark.B3N2zMcH.js +40 -0
  127. package/dist/chunks/benchmark.d.DAaHLpsq.d.ts +24 -0
  128. package/dist/chunks/browser.d.ChKACdzH.d.ts +59 -0
  129. package/dist/chunks/cac.DVeoLl0M.js +1409 -0
  130. package/dist/chunks/cli-api.B7PN_QUv.js +13672 -0
  131. package/dist/chunks/config.d.Cy95HiCx.d.ts +210 -0
  132. package/dist/chunks/console.Cf-YriPC.js +146 -0
  133. package/dist/chunks/constants.D_Q9UYh-.js +36 -0
  134. package/dist/chunks/coverage.AVPTjMgw.js +3292 -0
  135. package/dist/chunks/coverage.D_JHT54q.js +25 -0
  136. package/dist/chunks/coverage.d.BZtK59WP.d.ts +37 -0
  137. package/dist/chunks/creator.DAmOKTvJ.js +673 -0
  138. package/dist/chunks/date.Bq6ZW5rf.js +73 -0
  139. package/dist/chunks/defaults.BOqNVLsY.js +74 -0
  140. package/dist/chunks/env.D4Lgay0q.js +8 -0
  141. package/dist/chunks/environment.d.CrsxCzP1.d.ts +29 -0
  142. package/dist/chunks/evaluatedModules.Dg1zASAC.js +17 -0
  143. package/dist/chunks/evaluatedModules.d.BxJ5omdx.d.ts +7 -0
  144. package/dist/chunks/git.Bm2pzPAa.js +71 -0
  145. package/dist/chunks/global.d.B15mdLcR.d.ts +99 -0
  146. package/dist/chunks/globals.DOayXfHP.js +30 -0
  147. package/dist/chunks/index.6Qv1eEA6.js +109 -0
  148. package/dist/chunks/index.C5r1PdPD.js +231 -0
  149. package/dist/chunks/index.Chj8NDwU.js +206 -0
  150. package/dist/chunks/index.CyBMJtT7.js +727 -0
  151. package/dist/chunks/index.D3XRDfWc.js +213 -0
  152. package/dist/chunks/index.D4KonVSU.js +6343 -0
  153. package/dist/chunks/index.M8mOzt4Y.js +3839 -0
  154. package/dist/chunks/index.Z5E_ObnR.js +37 -0
  155. package/dist/chunks/init-forks._y3TW739.js +41 -0
  156. package/dist/chunks/init-threads.DBO2kn-p.js +18 -0
  157. package/dist/chunks/init.B6MLFIaN.js +334 -0
  158. package/dist/chunks/inspector.CvyFGlXm.js +53 -0
  159. package/dist/chunks/modules.BJuCwlRJ.js +36 -0
  160. package/dist/chunks/node.Ce0vMQM7.js +14 -0
  161. package/dist/chunks/plugin.d.CtqpEehP.d.ts +38 -0
  162. package/dist/chunks/reporters.d.CWXNI2jG.d.ts +3271 -0
  163. package/dist/chunks/rpc.BoxB0q7B.js +76 -0
  164. package/dist/chunks/rpc.d.RH3apGEf.d.ts +64 -0
  165. package/dist/chunks/setup-common.Cm-kSBVi.js +60 -0
  166. package/dist/chunks/startModuleRunner.DEj0jb3e.js +861 -0
  167. package/dist/chunks/suite.d.BJWk38HB.d.ts +10 -0
  168. package/dist/chunks/test.B8ej_ZHS.js +254 -0
  169. package/dist/chunks/traces.CCmnQaNT.js +217 -0
  170. package/dist/chunks/traces.d.402V_yFI.d.ts +18 -0
  171. package/dist/chunks/utils.DvEY5TfP.js +52 -0
  172. package/dist/chunks/vi.2VT5v0um.js +3919 -0
  173. package/dist/chunks/vm.D3epNOPZ.js +744 -0
  174. package/dist/chunks/worker.d.Dyxm8DEL.d.ts +255 -0
  175. package/dist/cli.js +28 -0
  176. package/dist/client/.vite/manifest.json +24 -0
  177. package/dist/client/__vitest__/assets/index-BUCFJtth.js +57 -0
  178. package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
  179. package/dist/client/__vitest__/bg.png +0 -0
  180. package/dist/client/__vitest__/favicon.ico +0 -0
  181. package/dist/client/__vitest__/favicon.svg +5 -0
  182. package/dist/client/__vitest__/index.html +32 -0
  183. package/dist/client/__vitest_browser__/orchestrator-S_3e_uzt.js +345 -0
  184. package/dist/client/__vitest_browser__/tester-k74mgIRa.js +2171 -0
  185. package/dist/client/__vitest_browser__/utils-uxqdqUz8.js +223 -0
  186. package/dist/client/error-catcher.js +82 -0
  187. package/dist/client/esm-client-injector.js +67 -0
  188. package/dist/client/favicon.svg +5 -0
  189. package/dist/client/orchestrator.html +35 -0
  190. package/dist/client/tester/tester.html +13 -0
  191. package/dist/client.js +456 -0
  192. package/dist/config.cjs +94 -0
  193. package/dist/config.d.ts +104 -0
  194. package/dist/config.js +15 -0
  195. package/dist/context.js +541 -0
  196. package/dist/coverage.d.ts +118 -0
  197. package/dist/coverage.js +23 -0
  198. package/dist/dummy.js +2 -0
  199. package/dist/environments.d.ts +22 -0
  200. package/dist/environments.js +3 -0
  201. package/dist/expect-element.js +27 -0
  202. package/dist/index-D6m36C6U.js +6 -0
  203. package/dist/index-node.js +7 -0
  204. package/dist/index.d.ts +510 -0
  205. package/dist/index.js +19 -0
  206. package/dist/locators.d.ts +354 -0
  207. package/dist/locators.js +1 -0
  208. package/dist/mocker.d.ts +1 -0
  209. package/dist/mocker.js +1 -0
  210. package/dist/module-evaluator.d.ts +124 -0
  211. package/dist/module-evaluator.js +343 -0
  212. package/dist/module-runner-stub.js +44 -0
  213. package/dist/module-runner.js +17 -0
  214. package/dist/node.d.ts +251 -0
  215. package/dist/node.js +98 -0
  216. package/dist/path.js +7 -0
  217. package/dist/plugins/browser-client.mjs +2 -0
  218. package/dist/plugins/browser-context.mjs +2 -0
  219. package/dist/plugins/browser-locators.mjs +2 -0
  220. package/dist/plugins/browser-playwright.mjs +2 -0
  221. package/dist/plugins/browser-preview.mjs +2 -0
  222. package/dist/plugins/browser-webdriverio.mjs +2 -0
  223. package/dist/plugins/browser.mjs +2 -0
  224. package/dist/plugins/expect.mjs +2 -0
  225. package/dist/plugins/mocker-automock.mjs +2 -0
  226. package/dist/plugins/mocker-browser.mjs +2 -0
  227. package/dist/plugins/mocker-node.mjs +2 -0
  228. package/dist/plugins/mocker-redirect.mjs +2 -0
  229. package/dist/plugins/mocker-register.mjs +2 -0
  230. package/dist/plugins/mocker.mjs +2 -0
  231. package/dist/plugins/pretty-format.mjs +2 -0
  232. package/dist/plugins/runner-types.mjs +2 -0
  233. package/dist/plugins/runner-utils.mjs +2 -0
  234. package/dist/plugins/runner.mjs +2 -0
  235. package/dist/plugins/snapshot-environment.mjs +2 -0
  236. package/dist/plugins/snapshot-manager.mjs +2 -0
  237. package/dist/plugins/snapshot.mjs +2 -0
  238. package/dist/plugins/spy.mjs +2 -0
  239. package/dist/plugins/utils-constants.mjs +2 -0
  240. package/dist/plugins/utils-diff.mjs +2 -0
  241. package/dist/plugins/utils-display.mjs +2 -0
  242. package/dist/plugins/utils-error.mjs +2 -0
  243. package/dist/plugins/utils-helpers.mjs +2 -0
  244. package/dist/plugins/utils-highlight.mjs +2 -0
  245. package/dist/plugins/utils-offset.mjs +2 -0
  246. package/dist/plugins/utils-resolver.mjs +2 -0
  247. package/dist/plugins/utils-serialize.mjs +2 -0
  248. package/dist/plugins/utils-source-map.mjs +2 -0
  249. package/dist/plugins/utils-timers.mjs +2 -0
  250. package/dist/plugins/utils.mjs +2 -0
  251. package/dist/reporters.d.ts +27 -0
  252. package/dist/reporters.js +24 -0
  253. package/dist/runners.d.ts +50 -0
  254. package/dist/runners.js +19 -0
  255. package/dist/shared/screenshotMatcher/types.d.ts +22 -0
  256. package/dist/snapshot.d.ts +9 -0
  257. package/dist/snapshot.js +4 -0
  258. package/dist/spy.js +1 -0
  259. package/dist/state.js +280 -0
  260. package/dist/suite.d.ts +5 -0
  261. package/dist/suite.js +6 -0
  262. package/dist/types.d.ts +69 -0
  263. package/dist/vendor/chai.d.mts +1 -0
  264. package/dist/vendor/chai.mjs +3577 -0
  265. package/dist/vendor/es-module-lexer.d.mts +193 -0
  266. package/dist/vendor/es-module-lexer.mjs +79 -0
  267. package/dist/vendor/estree-walker.d.mts +583 -0
  268. package/dist/vendor/estree-walker.mjs +339 -0
  269. package/dist/vendor/expect-type.d.mts +1574 -0
  270. package/dist/vendor/expect-type.mjs +214 -0
  271. package/dist/vendor/magic-string.d.mts +261 -0
  272. package/dist/vendor/magic-string.mjs +1700 -0
  273. package/dist/vendor/obug.d.mts +56 -0
  274. package/dist/vendor/obug.mjs +276 -0
  275. package/dist/vendor/pathe.d.mts +46 -0
  276. package/dist/vendor/pathe.mjs +496 -0
  277. package/dist/vendor/picomatch.d.mts +1 -0
  278. package/dist/vendor/picomatch.mjs +1855 -0
  279. package/dist/vendor/shared-3g9mwCWP.mjs +31 -0
  280. package/dist/vendor/std-env.d.mts +88 -0
  281. package/dist/vendor/std-env.mjs +159 -0
  282. package/dist/vendor/tinybench.d.mts +317 -0
  283. package/dist/vendor/tinybench.mjs +504 -0
  284. package/dist/vendor/tinyexec.d.mts +72 -0
  285. package/dist/vendor/tinyexec.mjs +637 -0
  286. package/dist/vendor/tinyglobby.d.mts +157 -0
  287. package/dist/vendor/tinyglobby.mjs +832 -0
  288. package/dist/vendor/tinyrainbow.d.mts +60 -0
  289. package/dist/vendor/tinyrainbow.mjs +93 -0
  290. package/dist/vendor/vitest_browser.mjs +2 -0
  291. package/dist/vendor/vitest_internal_browser.mjs +2 -0
  292. package/dist/vendor/vitest_runner.mjs +2 -0
  293. package/dist/vendor/vitest_runners.mjs +2 -0
  294. package/dist/worker.d.ts +32 -0
  295. package/dist/worker.js +48 -0
  296. package/dist/workers/forks.js +54 -0
  297. package/dist/workers/runVmTests.js +95 -0
  298. package/dist/workers/threads.js +55 -0
  299. package/dist/workers/vmForks.js +36 -0
  300. package/dist/workers/vmThreads.js +37 -0
  301. package/environments.d.ts +1 -0
  302. package/globals.d.ts +20 -0
  303. package/import-meta.d.ts +5 -0
  304. package/importMeta.d.ts +4 -0
  305. package/index.cjs +5 -0
  306. package/index.d.cts +1 -0
  307. package/jsdom.d.ts +6 -0
  308. package/mocker.d.ts +1 -0
  309. package/node.d.ts +1 -0
  310. package/optional-types.d.ts +7 -0
  311. package/package.json +335 -0
  312. package/reporters.d.ts +1 -0
  313. package/runners.d.ts +1 -0
  314. package/snapshot.d.ts +1 -0
  315. package/suite.d.ts +1 -0
  316. package/suppress-warnings.cjs +21 -0
  317. package/vitest.mjs +2 -0
  318. package/worker.d.ts +1 -0
@@ -0,0 +1,832 @@
1
+ import { n as __toESM } from "./shared-3g9mwCWP.mjs";
2
+ import { t as require_picomatch } from "./picomatch.mjs";
3
+ import { createRequire } from "module";
4
+ import * as nativeFs$1 from "fs";
5
+ import nativeFs from "fs";
6
+ import path, { basename, dirname, normalize, posix, relative, resolve, sep } from "path";
7
+ import { fileURLToPath } from "url";
8
+
9
+ //#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
10
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
11
+ function cleanPath(path) {
12
+ let normalized = normalize(path);
13
+ if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
14
+ return normalized;
15
+ }
16
+ const SLASHES_REGEX = /[\\/]/g;
17
+ function convertSlashes(path, separator) {
18
+ return path.replace(SLASHES_REGEX, separator);
19
+ }
20
+ const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
21
+ function isRootDirectory(path) {
22
+ return path === "/" || WINDOWS_ROOT_DIR_REGEX.test(path);
23
+ }
24
+ function normalizePath(path, options) {
25
+ const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
26
+ const pathNeedsCleaning = process.platform === "win32" && path.includes("/") || path.startsWith(".");
27
+ if (resolvePaths) path = resolve(path);
28
+ if (normalizePath$1 || pathNeedsCleaning) path = cleanPath(path);
29
+ if (path === ".") return "";
30
+ const needsSeperator = path[path.length - 1] !== pathSeparator;
31
+ return convertSlashes(needsSeperator ? path + pathSeparator : path, pathSeparator);
32
+ }
33
+ function joinPathWithBasePath(filename, directoryPath) {
34
+ return directoryPath + filename;
35
+ }
36
+ function joinPathWithRelativePath(root, options) {
37
+ return function(filename, directoryPath) {
38
+ const sameRoot = directoryPath.startsWith(root);
39
+ if (sameRoot) return directoryPath.slice(root.length) + filename;
40
+ else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
41
+ };
42
+ }
43
+ function joinPath(filename) {
44
+ return filename;
45
+ }
46
+ function joinDirectoryPath(filename, directoryPath, separator) {
47
+ return directoryPath + filename + separator;
48
+ }
49
+ function build$7(root, options) {
50
+ const { relativePaths, includeBasePath } = options;
51
+ return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
52
+ }
53
+ function pushDirectoryWithRelativePath(root) {
54
+ return function(directoryPath, paths) {
55
+ paths.push(directoryPath.substring(root.length) || ".");
56
+ };
57
+ }
58
+ function pushDirectoryFilterWithRelativePath(root) {
59
+ return function(directoryPath, paths, filters) {
60
+ const relativePath = directoryPath.substring(root.length) || ".";
61
+ if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
62
+ };
63
+ }
64
+ const pushDirectory = (directoryPath, paths) => {
65
+ paths.push(directoryPath || ".");
66
+ };
67
+ const pushDirectoryFilter = (directoryPath, paths, filters) => {
68
+ const path = directoryPath || ".";
69
+ if (filters.every((filter) => filter(path, true))) paths.push(path);
70
+ };
71
+ const empty$2 = () => {};
72
+ function build$6(root, options) {
73
+ const { includeDirs, filters, relativePaths } = options;
74
+ if (!includeDirs) return empty$2;
75
+ if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
76
+ return filters && filters.length ? pushDirectoryFilter : pushDirectory;
77
+ }
78
+ const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
79
+ if (filters.every((filter) => filter(filename, false))) counts.files++;
80
+ };
81
+ const pushFileFilter = (filename, paths, _counts, filters) => {
82
+ if (filters.every((filter) => filter(filename, false))) paths.push(filename);
83
+ };
84
+ const pushFileCount = (_filename, _paths, counts, _filters) => {
85
+ counts.files++;
86
+ };
87
+ const pushFile = (filename, paths) => {
88
+ paths.push(filename);
89
+ };
90
+ const empty$1 = () => {};
91
+ function build$5(options) {
92
+ const { excludeFiles, filters, onlyCounts } = options;
93
+ if (excludeFiles) return empty$1;
94
+ if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
95
+ else if (onlyCounts) return pushFileCount;
96
+ else return pushFile;
97
+ }
98
+ const getArray = (paths) => {
99
+ return paths;
100
+ };
101
+ const getArrayGroup = () => {
102
+ return [""].slice(0, 0);
103
+ };
104
+ function build$4(options) {
105
+ return options.group ? getArrayGroup : getArray;
106
+ }
107
+ const groupFiles = (groups, directory, files) => {
108
+ groups.push({
109
+ directory,
110
+ files,
111
+ dir: directory
112
+ });
113
+ };
114
+ const empty = () => {};
115
+ function build$3(options) {
116
+ return options.group ? groupFiles : empty;
117
+ }
118
+ const resolveSymlinksAsync = function(path, state, callback$1) {
119
+ const { queue, fs, options: { suppressErrors } } = state;
120
+ queue.enqueue();
121
+ fs.realpath(path, (error, resolvedPath) => {
122
+ if (error) return queue.dequeue(suppressErrors ? null : error, state);
123
+ fs.stat(resolvedPath, (error$1, stat) => {
124
+ if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
125
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return queue.dequeue(null, state);
126
+ callback$1(stat, resolvedPath);
127
+ queue.dequeue(null, state);
128
+ });
129
+ });
130
+ };
131
+ const resolveSymlinks = function(path, state, callback$1) {
132
+ const { queue, fs, options: { suppressErrors } } = state;
133
+ queue.enqueue();
134
+ try {
135
+ const resolvedPath = fs.realpathSync(path);
136
+ const stat = fs.statSync(resolvedPath);
137
+ if (stat.isDirectory() && isRecursive(path, resolvedPath, state)) return;
138
+ callback$1(stat, resolvedPath);
139
+ } catch (e) {
140
+ if (!suppressErrors) throw e;
141
+ }
142
+ };
143
+ function build$2(options, isSynchronous) {
144
+ if (!options.resolveSymlinks || options.excludeSymlinks) return null;
145
+ return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
146
+ }
147
+ function isRecursive(path, resolved, state) {
148
+ if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
149
+ let parent = dirname(path);
150
+ let depth = 1;
151
+ while (parent !== state.root && depth < 2) {
152
+ const resolvedPath = state.symlinks.get(parent);
153
+ const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
154
+ if (isSameRoot) depth++;
155
+ else parent = dirname(parent);
156
+ }
157
+ state.symlinks.set(path, resolved);
158
+ return depth > 1;
159
+ }
160
+ function isRecursiveUsingRealPaths(resolved, state) {
161
+ return state.visited.includes(resolved + state.options.pathSeparator);
162
+ }
163
+ const onlyCountsSync = (state) => {
164
+ return state.counts;
165
+ };
166
+ const groupsSync = (state) => {
167
+ return state.groups;
168
+ };
169
+ const defaultSync = (state) => {
170
+ return state.paths;
171
+ };
172
+ const limitFilesSync = (state) => {
173
+ return state.paths.slice(0, state.options.maxFiles);
174
+ };
175
+ const onlyCountsAsync = (state, error, callback$1) => {
176
+ report(error, callback$1, state.counts, state.options.suppressErrors);
177
+ return null;
178
+ };
179
+ const defaultAsync = (state, error, callback$1) => {
180
+ report(error, callback$1, state.paths, state.options.suppressErrors);
181
+ return null;
182
+ };
183
+ const limitFilesAsync = (state, error, callback$1) => {
184
+ report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
185
+ return null;
186
+ };
187
+ const groupsAsync = (state, error, callback$1) => {
188
+ report(error, callback$1, state.groups, state.options.suppressErrors);
189
+ return null;
190
+ };
191
+ function report(error, callback$1, output, suppressErrors) {
192
+ if (error && !suppressErrors) callback$1(error, output);
193
+ else callback$1(null, output);
194
+ }
195
+ function build$1(options, isSynchronous) {
196
+ const { onlyCounts, group, maxFiles } = options;
197
+ if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
198
+ else if (group) return isSynchronous ? groupsSync : groupsAsync;
199
+ else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
200
+ else return isSynchronous ? defaultSync : defaultAsync;
201
+ }
202
+ const readdirOpts = { withFileTypes: true };
203
+ const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
204
+ state.queue.enqueue();
205
+ if (currentDepth < 0) return state.queue.dequeue(null, state);
206
+ const { fs } = state;
207
+ state.visited.push(crawlPath);
208
+ state.counts.directories++;
209
+ fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
210
+ callback$1(entries, directoryPath, currentDepth);
211
+ state.queue.dequeue(state.options.suppressErrors ? null : error, state);
212
+ });
213
+ };
214
+ const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
215
+ const { fs } = state;
216
+ if (currentDepth < 0) return;
217
+ state.visited.push(crawlPath);
218
+ state.counts.directories++;
219
+ let entries = [];
220
+ try {
221
+ entries = fs.readdirSync(crawlPath || ".", readdirOpts);
222
+ } catch (e) {
223
+ if (!state.options.suppressErrors) throw e;
224
+ }
225
+ callback$1(entries, directoryPath, currentDepth);
226
+ };
227
+ function build(isSynchronous) {
228
+ return isSynchronous ? walkSync : walkAsync;
229
+ }
230
+ /**
231
+ * This is a custom stateless queue to track concurrent async fs calls.
232
+ * It increments a counter whenever a call is queued and decrements it
233
+ * as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
234
+ */
235
+ var Queue = class {
236
+ count = 0;
237
+ constructor(onQueueEmpty) {
238
+ this.onQueueEmpty = onQueueEmpty;
239
+ }
240
+ enqueue() {
241
+ this.count++;
242
+ return this.count;
243
+ }
244
+ dequeue(error, output) {
245
+ if (this.onQueueEmpty && (--this.count <= 0 || error)) {
246
+ this.onQueueEmpty(error, output);
247
+ if (error) {
248
+ output.controller.abort();
249
+ this.onQueueEmpty = void 0;
250
+ }
251
+ }
252
+ }
253
+ };
254
+ var Counter = class {
255
+ _files = 0;
256
+ _directories = 0;
257
+ set files(num) {
258
+ this._files = num;
259
+ }
260
+ get files() {
261
+ return this._files;
262
+ }
263
+ set directories(num) {
264
+ this._directories = num;
265
+ }
266
+ get directories() {
267
+ return this._directories;
268
+ }
269
+ /**
270
+ * @deprecated use `directories` instead
271
+ */
272
+ /* c8 ignore next 3 */
273
+ get dirs() {
274
+ return this._directories;
275
+ }
276
+ };
277
+ /**
278
+ * AbortController is not supported on Node 14 so we use this until we can drop
279
+ * support for Node 14.
280
+ */
281
+ var Aborter = class {
282
+ aborted = false;
283
+ abort() {
284
+ this.aborted = true;
285
+ }
286
+ };
287
+ var Walker = class {
288
+ root;
289
+ isSynchronous;
290
+ state;
291
+ joinPath;
292
+ pushDirectory;
293
+ pushFile;
294
+ getArray;
295
+ groupFiles;
296
+ resolveSymlink;
297
+ walkDirectory;
298
+ callbackInvoker;
299
+ constructor(root, options, callback$1) {
300
+ this.isSynchronous = !callback$1;
301
+ this.callbackInvoker = build$1(options, this.isSynchronous);
302
+ this.root = normalizePath(root, options);
303
+ this.state = {
304
+ root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
305
+ paths: [""].slice(0, 0),
306
+ groups: [],
307
+ counts: new Counter(),
308
+ options,
309
+ queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
310
+ symlinks: /* @__PURE__ */ new Map(),
311
+ visited: [""].slice(0, 0),
312
+ controller: new Aborter(),
313
+ fs: options.fs || nativeFs$1
314
+ };
315
+ this.joinPath = build$7(this.root, options);
316
+ this.pushDirectory = build$6(this.root, options);
317
+ this.pushFile = build$5(options);
318
+ this.getArray = build$4(options);
319
+ this.groupFiles = build$3(options);
320
+ this.resolveSymlink = build$2(options, this.isSynchronous);
321
+ this.walkDirectory = build(this.isSynchronous);
322
+ }
323
+ start() {
324
+ this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
325
+ this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
326
+ return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
327
+ }
328
+ walk = (entries, directoryPath, depth) => {
329
+ const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
330
+ if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
331
+ const files = this.getArray(this.state.paths);
332
+ for (let i = 0; i < entries.length; ++i) {
333
+ const entry = entries[i];
334
+ if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
335
+ const filename = this.joinPath(entry.name, directoryPath);
336
+ this.pushFile(filename, files, this.state.counts, filters);
337
+ } else if (entry.isDirectory()) {
338
+ let path = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
339
+ if (exclude && exclude(entry.name, path)) continue;
340
+ this.pushDirectory(path, paths, filters);
341
+ this.walkDirectory(this.state, path, path, depth - 1, this.walk);
342
+ } else if (this.resolveSymlink && entry.isSymbolicLink()) {
343
+ let path = joinPathWithBasePath(entry.name, directoryPath);
344
+ this.resolveSymlink(path, this.state, (stat, resolvedPath) => {
345
+ if (stat.isDirectory()) {
346
+ resolvedPath = normalizePath(resolvedPath, this.state.options);
347
+ if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path + pathSeparator)) return;
348
+ this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path + pathSeparator, depth - 1, this.walk);
349
+ } else {
350
+ resolvedPath = useRealPaths ? resolvedPath : path;
351
+ const filename = basename(resolvedPath);
352
+ const directoryPath$1 = normalizePath(dirname(resolvedPath), this.state.options);
353
+ resolvedPath = this.joinPath(filename, directoryPath$1);
354
+ this.pushFile(resolvedPath, files, this.state.counts, filters);
355
+ }
356
+ });
357
+ }
358
+ }
359
+ this.groupFiles(this.state.groups, directoryPath, files);
360
+ };
361
+ };
362
+ function promise(root, options) {
363
+ return new Promise((resolve$1, reject) => {
364
+ callback(root, options, (err, output) => {
365
+ if (err) return reject(err);
366
+ resolve$1(output);
367
+ });
368
+ });
369
+ }
370
+ function callback(root, options, callback$1) {
371
+ let walker = new Walker(root, options, callback$1);
372
+ walker.start();
373
+ }
374
+ function sync(root, options) {
375
+ const walker = new Walker(root, options);
376
+ return walker.start();
377
+ }
378
+ var APIBuilder = class {
379
+ constructor(root, options) {
380
+ this.root = root;
381
+ this.options = options;
382
+ }
383
+ withPromise() {
384
+ return promise(this.root, this.options);
385
+ }
386
+ withCallback(cb) {
387
+ callback(this.root, this.options, cb);
388
+ }
389
+ sync() {
390
+ return sync(this.root, this.options);
391
+ }
392
+ };
393
+ let pm = null;
394
+ /* c8 ignore next 6 */
395
+ try {
396
+ __require.resolve("picomatch");
397
+ pm = __require("picomatch");
398
+ } catch {}
399
+ var Builder = class {
400
+ globCache = {};
401
+ options = {
402
+ maxDepth: Infinity,
403
+ suppressErrors: true,
404
+ pathSeparator: sep,
405
+ filters: []
406
+ };
407
+ globFunction;
408
+ constructor(options) {
409
+ this.options = {
410
+ ...this.options,
411
+ ...options
412
+ };
413
+ this.globFunction = this.options.globFunction;
414
+ }
415
+ group() {
416
+ this.options.group = true;
417
+ return this;
418
+ }
419
+ withPathSeparator(separator) {
420
+ this.options.pathSeparator = separator;
421
+ return this;
422
+ }
423
+ withBasePath() {
424
+ this.options.includeBasePath = true;
425
+ return this;
426
+ }
427
+ withRelativePaths() {
428
+ this.options.relativePaths = true;
429
+ return this;
430
+ }
431
+ withDirs() {
432
+ this.options.includeDirs = true;
433
+ return this;
434
+ }
435
+ withMaxDepth(depth) {
436
+ this.options.maxDepth = depth;
437
+ return this;
438
+ }
439
+ withMaxFiles(limit) {
440
+ this.options.maxFiles = limit;
441
+ return this;
442
+ }
443
+ withFullPaths() {
444
+ this.options.resolvePaths = true;
445
+ this.options.includeBasePath = true;
446
+ return this;
447
+ }
448
+ withErrors() {
449
+ this.options.suppressErrors = false;
450
+ return this;
451
+ }
452
+ withSymlinks({ resolvePaths = true } = {}) {
453
+ this.options.resolveSymlinks = true;
454
+ this.options.useRealPaths = resolvePaths;
455
+ return this.withFullPaths();
456
+ }
457
+ withAbortSignal(signal) {
458
+ this.options.signal = signal;
459
+ return this;
460
+ }
461
+ normalize() {
462
+ this.options.normalizePath = true;
463
+ return this;
464
+ }
465
+ filter(predicate) {
466
+ this.options.filters.push(predicate);
467
+ return this;
468
+ }
469
+ onlyDirs() {
470
+ this.options.excludeFiles = true;
471
+ this.options.includeDirs = true;
472
+ return this;
473
+ }
474
+ exclude(predicate) {
475
+ this.options.exclude = predicate;
476
+ return this;
477
+ }
478
+ onlyCounts() {
479
+ this.options.onlyCounts = true;
480
+ return this;
481
+ }
482
+ crawl(root) {
483
+ return new APIBuilder(root || ".", this.options);
484
+ }
485
+ withGlobFunction(fn) {
486
+ this.globFunction = fn;
487
+ return this;
488
+ }
489
+ /**
490
+ * @deprecated Pass options using the constructor instead:
491
+ * ```ts
492
+ * new fdir(options).crawl("/path/to/root");
493
+ * ```
494
+ * This method will be removed in v7.0
495
+ */
496
+ /* c8 ignore next 4 */
497
+ crawlWithOptions(root, options) {
498
+ this.options = {
499
+ ...this.options,
500
+ ...options
501
+ };
502
+ return new APIBuilder(root || ".", this.options);
503
+ }
504
+ glob(...patterns) {
505
+ if (this.globFunction) return this.globWithOptions(patterns);
506
+ return this.globWithOptions(patterns, ...[{ dot: true }]);
507
+ }
508
+ globWithOptions(patterns, ...options) {
509
+ const globFn = this.globFunction || pm;
510
+ /* c8 ignore next 5 */
511
+ if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
512
+ var isMatch = this.globCache[patterns.join("\0")];
513
+ if (!isMatch) {
514
+ isMatch = globFn(patterns, ...options);
515
+ this.globCache[patterns.join("\0")] = isMatch;
516
+ }
517
+ this.options.filters.push((path) => isMatch(path));
518
+ return this;
519
+ }
520
+ };
521
+
522
+ //#endregion
523
+ //#region ../../node_modules/.pnpm/tinyglobby@0.2.15/node_modules/tinyglobby/dist/index.mjs
524
+ var import_picomatch = /* @__PURE__ */ __toESM(require_picomatch(), 1);
525
+ const isReadonlyArray = Array.isArray;
526
+ const isWin = process.platform === "win32";
527
+ const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
528
+ function getPartialMatcher(patterns, options = {}) {
529
+ const patternsCount = patterns.length;
530
+ const patternsParts = Array(patternsCount);
531
+ const matchers = Array(patternsCount);
532
+ const globstarEnabled = !options.noglobstar;
533
+ for (let i = 0; i < patternsCount; i++) {
534
+ const parts = splitPattern(patterns[i]);
535
+ patternsParts[i] = parts;
536
+ const partsCount = parts.length;
537
+ const partMatchers = Array(partsCount);
538
+ for (let j = 0; j < partsCount; j++) partMatchers[j] = (0, import_picomatch.default)(parts[j], options);
539
+ matchers[i] = partMatchers;
540
+ }
541
+ return (input) => {
542
+ const inputParts = input.split("/");
543
+ if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
544
+ for (let i = 0; i < patterns.length; i++) {
545
+ const patternParts = patternsParts[i];
546
+ const matcher = matchers[i];
547
+ const inputPatternCount = inputParts.length;
548
+ const minParts = Math.min(inputPatternCount, patternParts.length);
549
+ let j = 0;
550
+ while (j < minParts) {
551
+ const part = patternParts[j];
552
+ if (part.includes("/")) return true;
553
+ const match = matcher[j](inputParts[j]);
554
+ if (!match) break;
555
+ if (globstarEnabled && part === "**") return true;
556
+ j++;
557
+ }
558
+ if (j === inputPatternCount) return true;
559
+ }
560
+ return false;
561
+ };
562
+ }
563
+ /* node:coverage ignore next 2 */
564
+ const WIN32_ROOT_DIR = /^[A-Z]:\/$/i;
565
+ const isRoot = isWin ? (p) => WIN32_ROOT_DIR.test(p) : (p) => p === "/";
566
+ function buildFormat(cwd, root, absolute) {
567
+ if (cwd === root || root.startsWith(`${cwd}/`)) {
568
+ if (absolute) {
569
+ const start = isRoot(cwd) ? cwd.length : cwd.length + 1;
570
+ return (p, isDir) => p.slice(start, isDir ? -1 : void 0) || ".";
571
+ }
572
+ const prefix = root.slice(cwd.length + 1);
573
+ if (prefix) return (p, isDir) => {
574
+ if (p === ".") return prefix;
575
+ const result = `${prefix}/${p}`;
576
+ return isDir ? result.slice(0, -1) : result;
577
+ };
578
+ return (p, isDir) => isDir && p !== "." ? p.slice(0, -1) : p;
579
+ }
580
+ if (absolute) return (p) => posix.relative(cwd, p) || ".";
581
+ return (p) => posix.relative(cwd, `${root}/${p}`) || ".";
582
+ }
583
+ function buildRelative(cwd, root) {
584
+ if (root.startsWith(`${cwd}/`)) {
585
+ const prefix = root.slice(cwd.length + 1);
586
+ return (p) => `${prefix}/${p}`;
587
+ }
588
+ return (p) => {
589
+ const result = posix.relative(cwd, `${root}/${p}`);
590
+ if (p.endsWith("/") && result !== "") return `${result}/`;
591
+ return result || ".";
592
+ };
593
+ }
594
+ const splitPatternOptions = { parts: true };
595
+ function splitPattern(path$1) {
596
+ var _result$parts;
597
+ const result = import_picomatch.default.scan(path$1, splitPatternOptions);
598
+ return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
599
+ }
600
+ const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
601
+ function convertPosixPathToPattern(path$1) {
602
+ return escapePosixPath(path$1);
603
+ }
604
+ function convertWin32PathToPattern(path$1) {
605
+ return escapeWin32Path(path$1).replace(ESCAPED_WIN32_BACKSLASHES, "/");
606
+ }
607
+ /**
608
+ * Converts a path to a pattern depending on the platform.
609
+ * Identical to {@link escapePath} on POSIX systems.
610
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#convertPathToPattern}
611
+ */
612
+ /* node:coverage ignore next 3 */
613
+ const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
614
+ const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
615
+ const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
616
+ const escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
617
+ const escapeWin32Path = (path$1) => path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
618
+ /**
619
+ * Escapes a path's special characters depending on the platform.
620
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
621
+ */
622
+ /* node:coverage ignore next */
623
+ const escapePath = isWin ? escapeWin32Path : escapePosixPath;
624
+ /**
625
+ * Checks if a pattern has dynamic parts.
626
+ *
627
+ * Has a few minor differences with [`fast-glob`](https://github.com/mrmlnc/fast-glob) for better accuracy:
628
+ *
629
+ * - Doesn't necessarily return `false` on patterns that include `\`.
630
+ * - Returns `true` if the pattern includes parentheses, regardless of them representing one single pattern or not.
631
+ * - Returns `true` for unfinished glob extensions i.e. `(h`, `+(h`.
632
+ * - Returns `true` for unfinished brace expansions as long as they include `,` or `..`.
633
+ *
634
+ * @see {@link https://superchupu.dev/tinyglobby/documentation#isDynamicPattern}
635
+ */
636
+ function isDynamicPattern(pattern, options) {
637
+ if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
638
+ const scan = import_picomatch.default.scan(pattern);
639
+ return scan.isGlob || scan.negated;
640
+ }
641
+ function log(...tasks) {
642
+ console.log(`[tinyglobby ${(/* @__PURE__ */ new Date()).toLocaleTimeString("es")}]`, ...tasks);
643
+ }
644
+ const PARENT_DIRECTORY = /^(\/?\.\.)+/;
645
+ const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
646
+ const BACKSLASHES = /\\/g;
647
+ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
648
+ let result = pattern;
649
+ if (pattern.endsWith("/")) result = pattern.slice(0, -1);
650
+ if (!result.endsWith("*") && expandDirectories) result += "/**";
651
+ const escapedCwd = escapePath(cwd);
652
+ if (path.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = posix.relative(escapedCwd, result);
653
+ else result = posix.normalize(result);
654
+ const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
655
+ const parts = splitPattern(result);
656
+ if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
657
+ const n = (parentDirectoryMatch[0].length + 1) / 3;
658
+ let i = 0;
659
+ const cwdParts = escapedCwd.split("/");
660
+ while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
661
+ result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
662
+ i++;
663
+ }
664
+ const potentialRoot = posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
665
+ if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
666
+ props.root = potentialRoot;
667
+ props.depthOffset = -n + i;
668
+ }
669
+ }
670
+ if (!isIgnore && props.depthOffset >= 0) {
671
+ var _props$commonPath;
672
+ (_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
673
+ const newCommonPath = [];
674
+ const length = Math.min(props.commonPath.length, parts.length);
675
+ for (let i = 0; i < length; i++) {
676
+ const part = parts[i];
677
+ if (part === "**" && !parts[i + 1]) {
678
+ newCommonPath.pop();
679
+ break;
680
+ }
681
+ if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
682
+ newCommonPath.push(part);
683
+ }
684
+ props.depthOffset = newCommonPath.length;
685
+ props.commonPath = newCommonPath;
686
+ props.root = newCommonPath.length > 0 ? posix.join(cwd, ...newCommonPath) : cwd;
687
+ }
688
+ return result;
689
+ }
690
+ function processPatterns({ patterns = ["**/*"], ignore = [], expandDirectories = true }, cwd, props) {
691
+ if (typeof patterns === "string") patterns = [patterns];
692
+ if (typeof ignore === "string") ignore = [ignore];
693
+ const matchPatterns = [];
694
+ const ignorePatterns = [];
695
+ for (const pattern of ignore) {
696
+ if (!pattern) continue;
697
+ if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
698
+ }
699
+ for (const pattern of patterns) {
700
+ if (!pattern) continue;
701
+ if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
702
+ else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
703
+ }
704
+ return {
705
+ match: matchPatterns,
706
+ ignore: ignorePatterns
707
+ };
708
+ }
709
+ function formatPaths(paths, relative) {
710
+ for (let i = paths.length - 1; i >= 0; i--) {
711
+ const path$1 = paths[i];
712
+ paths[i] = relative(path$1);
713
+ }
714
+ return paths;
715
+ }
716
+ function normalizeCwd(cwd) {
717
+ if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
718
+ if (cwd instanceof URL) return fileURLToPath(cwd).replace(BACKSLASHES, "/");
719
+ return path.resolve(cwd).replace(BACKSLASHES, "/");
720
+ }
721
+ function getCrawler(patterns, inputOptions = {}) {
722
+ const options = process.env.TINYGLOBBY_DEBUG ? {
723
+ ...inputOptions,
724
+ debug: true
725
+ } : inputOptions;
726
+ const cwd = normalizeCwd(options.cwd);
727
+ if (options.debug) log("globbing with:", {
728
+ patterns,
729
+ options,
730
+ cwd
731
+ });
732
+ if (Array.isArray(patterns) && patterns.length === 0) return [{
733
+ sync: () => [],
734
+ withPromise: async () => []
735
+ }, false];
736
+ const props = {
737
+ root: cwd,
738
+ commonPath: null,
739
+ depthOffset: 0
740
+ };
741
+ const processed = processPatterns({
742
+ ...options,
743
+ patterns
744
+ }, cwd, props);
745
+ if (options.debug) log("internal processing patterns:", processed);
746
+ const matchOptions = {
747
+ dot: options.dot,
748
+ nobrace: options.braceExpansion === false,
749
+ nocase: options.caseSensitiveMatch === false,
750
+ noextglob: options.extglob === false,
751
+ noglobstar: options.globstar === false,
752
+ posix: true
753
+ };
754
+ const matcher = (0, import_picomatch.default)(processed.match, {
755
+ ...matchOptions,
756
+ ignore: processed.ignore
757
+ });
758
+ const ignore = (0, import_picomatch.default)(processed.ignore, matchOptions);
759
+ const partialMatcher = getPartialMatcher(processed.match, matchOptions);
760
+ const format = buildFormat(cwd, props.root, options.absolute);
761
+ const formatExclude = options.absolute ? format : buildFormat(cwd, props.root, true);
762
+ const fdirOptions = {
763
+ filters: [options.debug ? (p, isDirectory) => {
764
+ const path$1 = format(p, isDirectory);
765
+ const matches = matcher(path$1);
766
+ if (matches) log(`matched ${path$1}`);
767
+ return matches;
768
+ } : (p, isDirectory) => matcher(format(p, isDirectory))],
769
+ exclude: options.debug ? (_, p) => {
770
+ const relativePath = formatExclude(p, true);
771
+ const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
772
+ if (skipped) log(`skipped ${p}`);
773
+ else log(`crawling ${p}`);
774
+ return skipped;
775
+ } : (_, p) => {
776
+ const relativePath = formatExclude(p, true);
777
+ return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
778
+ },
779
+ fs: options.fs ? {
780
+ readdir: options.fs.readdir || nativeFs.readdir,
781
+ readdirSync: options.fs.readdirSync || nativeFs.readdirSync,
782
+ realpath: options.fs.realpath || nativeFs.realpath,
783
+ realpathSync: options.fs.realpathSync || nativeFs.realpathSync,
784
+ stat: options.fs.stat || nativeFs.stat,
785
+ statSync: options.fs.statSync || nativeFs.statSync
786
+ } : void 0,
787
+ pathSeparator: "/",
788
+ relativePaths: true,
789
+ resolveSymlinks: true,
790
+ signal: options.signal
791
+ };
792
+ if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
793
+ if (options.absolute) {
794
+ fdirOptions.relativePaths = false;
795
+ fdirOptions.resolvePaths = true;
796
+ fdirOptions.includeBasePath = true;
797
+ }
798
+ if (options.followSymbolicLinks === false) {
799
+ fdirOptions.resolveSymlinks = false;
800
+ fdirOptions.excludeSymlinks = true;
801
+ }
802
+ if (options.onlyDirectories) {
803
+ fdirOptions.excludeFiles = true;
804
+ fdirOptions.includeDirs = true;
805
+ } else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
806
+ props.root = props.root.replace(BACKSLASHES, "");
807
+ const root = props.root;
808
+ if (options.debug) log("internal properties:", props);
809
+ const relative = cwd !== root && !options.absolute && buildRelative(cwd, props.root);
810
+ return [new Builder(fdirOptions).crawl(root), relative];
811
+ }
812
+ async function glob(patternsOrOptions, options) {
813
+ if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
814
+ const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
815
+ const opts = isModern ? options : patternsOrOptions;
816
+ const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
817
+ const [crawler, relative] = getCrawler(patterns, opts);
818
+ if (!relative) return crawler.withPromise();
819
+ return formatPaths(await crawler.withPromise(), relative);
820
+ }
821
+ function globSync(patternsOrOptions, options) {
822
+ if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
823
+ const isModern = isReadonlyArray(patternsOrOptions) || typeof patternsOrOptions === "string";
824
+ const opts = isModern ? options : patternsOrOptions;
825
+ const patterns = isModern ? patternsOrOptions : patternsOrOptions.patterns;
826
+ const [crawler, relative] = getCrawler(patterns, opts);
827
+ if (!relative) return crawler.sync();
828
+ return formatPaths(crawler.sync(), relative);
829
+ }
830
+
831
+ //#endregion
832
+ export { convertPathToPattern, escapePath, glob, globSync, isDynamicPattern };