@noodleseed/one 0.5.0 → 0.6.0

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 (279) hide show
  1. package/dist/cli.js +5 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/shared.d.ts +1 -1
  4. package/dist/commands/shared.d.ts.map +1 -1
  5. package/dist/commands/shared.js +2 -2
  6. package/dist/commands/shared.js.map +1 -1
  7. package/dist/react-widget-build.js +20 -1
  8. package/dist/react-widget-build.js.map +1 -1
  9. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.d.ts.map +1 -1
  10. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js +1 -0
  11. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js.map +1 -1
  12. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
  13. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +1 -0
  14. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js.map +1 -1
  15. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  16. package/package.json +2 -20
  17. package/node_modules/@oxc-project/types/LICENSE +0 -22
  18. package/node_modules/@oxc-project/types/README.md +0 -3
  19. package/node_modules/@oxc-project/types/package.json +0 -26
  20. package/node_modules/@oxc-project/types/types.d.ts +0 -1912
  21. package/node_modules/@rolldown/binding-linux-x64-gnu/README.md +0 -3
  22. package/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
  23. package/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
  24. package/node_modules/@rolldown/pluginutils/LICENSE +0 -21
  25. package/node_modules/@rolldown/pluginutils/README.md +0 -145
  26. package/node_modules/@rolldown/pluginutils/dist/filter/index.d.mts +0 -194
  27. package/node_modules/@rolldown/pluginutils/dist/filter/index.mjs +0 -2
  28. package/node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs +0 -323
  29. package/node_modules/@rolldown/pluginutils/dist/index.d.mts +0 -2
  30. package/node_modules/@rolldown/pluginutils/dist/index.mjs +0 -2
  31. package/node_modules/@rolldown/pluginutils/package.json +0 -40
  32. package/node_modules/@vitejs/plugin-react/LICENSE +0 -21
  33. package/node_modules/@vitejs/plugin-react/README.md +0 -169
  34. package/node_modules/@vitejs/plugin-react/dist/index.d.ts +0 -48
  35. package/node_modules/@vitejs/plugin-react/dist/index.js +0 -200
  36. package/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js +0 -663
  37. package/node_modules/@vitejs/plugin-react/package.json +0 -87
  38. package/node_modules/@vitejs/plugin-react/types/optionalTypes.d.ts +0 -12
  39. package/node_modules/@vitejs/plugin-react/types/preamble.d.ts +0 -1
  40. package/node_modules/detect-libc/LICENSE +0 -201
  41. package/node_modules/detect-libc/README.md +0 -163
  42. package/node_modules/detect-libc/index.d.ts +0 -14
  43. package/node_modules/detect-libc/lib/detect-libc.js +0 -313
  44. package/node_modules/detect-libc/lib/elf.js +0 -39
  45. package/node_modules/detect-libc/lib/filesystem.js +0 -51
  46. package/node_modules/detect-libc/lib/process.js +0 -24
  47. package/node_modules/detect-libc/package.json +0 -44
  48. package/node_modules/fdir/LICENSE +0 -7
  49. package/node_modules/fdir/README.md +0 -91
  50. package/node_modules/fdir/dist/index.cjs +0 -588
  51. package/node_modules/fdir/dist/index.d.cts +0 -155
  52. package/node_modules/fdir/dist/index.d.mts +0 -155
  53. package/node_modules/fdir/dist/index.mjs +0 -570
  54. package/node_modules/fdir/package.json +0 -103
  55. package/node_modules/lightningcss/LICENSE +0 -373
  56. package/node_modules/lightningcss/README.md +0 -105
  57. package/node_modules/lightningcss/node/ast.d.ts +0 -9892
  58. package/node_modules/lightningcss/node/ast.js.flow +0 -10539
  59. package/node_modules/lightningcss/node/browserslistToTargets.js +0 -48
  60. package/node_modules/lightningcss/node/composeVisitors.js +0 -450
  61. package/node_modules/lightningcss/node/flags.js +0 -28
  62. package/node_modules/lightningcss/node/index.d.ts +0 -494
  63. package/node_modules/lightningcss/node/index.js +0 -59
  64. package/node_modules/lightningcss/node/index.js.flow +0 -843
  65. package/node_modules/lightningcss/node/index.mjs +0 -4
  66. package/node_modules/lightningcss/node/targets.d.ts +0 -40
  67. package/node_modules/lightningcss/node/targets.js.flow +0 -39
  68. package/node_modules/lightningcss/package.json +0 -110
  69. package/node_modules/lightningcss-linux-x64-gnu/LICENSE +0 -373
  70. package/node_modules/lightningcss-linux-x64-gnu/README.md +0 -1
  71. package/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node +0 -0
  72. package/node_modules/lightningcss-linux-x64-gnu/package.json +0 -37
  73. package/node_modules/nanoid/.claude/settings.local.json +0 -14
  74. package/node_modules/nanoid/LICENSE +0 -20
  75. package/node_modules/nanoid/README.md +0 -39
  76. package/node_modules/nanoid/async/index.browser.cjs +0 -69
  77. package/node_modules/nanoid/async/index.browser.js +0 -34
  78. package/node_modules/nanoid/async/index.cjs +0 -71
  79. package/node_modules/nanoid/async/index.d.ts +0 -56
  80. package/node_modules/nanoid/async/index.js +0 -35
  81. package/node_modules/nanoid/async/index.native.js +0 -26
  82. package/node_modules/nanoid/async/package.json +0 -12
  83. package/node_modules/nanoid/bin/nanoid.cjs +0 -55
  84. package/node_modules/nanoid/index.browser.cjs +0 -72
  85. package/node_modules/nanoid/index.browser.js +0 -34
  86. package/node_modules/nanoid/index.cjs +0 -86
  87. package/node_modules/nanoid/index.d.cts +0 -91
  88. package/node_modules/nanoid/index.d.ts +0 -91
  89. package/node_modules/nanoid/index.js +0 -46
  90. package/node_modules/nanoid/nanoid.js +0 -1
  91. package/node_modules/nanoid/non-secure/index.cjs +0 -34
  92. package/node_modules/nanoid/non-secure/index.d.ts +0 -33
  93. package/node_modules/nanoid/non-secure/index.js +0 -21
  94. package/node_modules/nanoid/non-secure/package.json +0 -6
  95. package/node_modules/nanoid/package.json +0 -89
  96. package/node_modules/nanoid/url-alphabet/index.cjs +0 -7
  97. package/node_modules/nanoid/url-alphabet/index.js +0 -3
  98. package/node_modules/nanoid/url-alphabet/package.json +0 -6
  99. package/node_modules/picocolors/LICENSE +0 -15
  100. package/node_modules/picocolors/README.md +0 -21
  101. package/node_modules/picocolors/package.json +0 -25
  102. package/node_modules/picocolors/picocolors.browser.js +0 -4
  103. package/node_modules/picocolors/picocolors.d.ts +0 -5
  104. package/node_modules/picocolors/picocolors.js +0 -75
  105. package/node_modules/picocolors/types.d.ts +0 -51
  106. package/node_modules/picomatch/LICENSE +0 -21
  107. package/node_modules/picomatch/README.md +0 -749
  108. package/node_modules/picomatch/index.js +0 -17
  109. package/node_modules/picomatch/lib/constants.js +0 -184
  110. package/node_modules/picomatch/lib/parse.js +0 -1386
  111. package/node_modules/picomatch/lib/picomatch.js +0 -349
  112. package/node_modules/picomatch/lib/scan.js +0 -391
  113. package/node_modules/picomatch/lib/utils.js +0 -72
  114. package/node_modules/picomatch/package.json +0 -82
  115. package/node_modules/picomatch/posix.js +0 -3
  116. package/node_modules/postcss/LICENSE +0 -20
  117. package/node_modules/postcss/README.md +0 -28
  118. package/node_modules/postcss/lib/at-rule.d.ts +0 -139
  119. package/node_modules/postcss/lib/at-rule.js +0 -25
  120. package/node_modules/postcss/lib/comment.d.ts +0 -67
  121. package/node_modules/postcss/lib/comment.js +0 -13
  122. package/node_modules/postcss/lib/container.d.ts +0 -478
  123. package/node_modules/postcss/lib/container.js +0 -447
  124. package/node_modules/postcss/lib/css-syntax-error.d.ts +0 -247
  125. package/node_modules/postcss/lib/css-syntax-error.js +0 -133
  126. package/node_modules/postcss/lib/declaration.d.ts +0 -150
  127. package/node_modules/postcss/lib/declaration.js +0 -24
  128. package/node_modules/postcss/lib/document.d.ts +0 -68
  129. package/node_modules/postcss/lib/document.js +0 -33
  130. package/node_modules/postcss/lib/fromJSON.d.ts +0 -9
  131. package/node_modules/postcss/lib/fromJSON.js +0 -54
  132. package/node_modules/postcss/lib/input.d.ts +0 -226
  133. package/node_modules/postcss/lib/input.js +0 -273
  134. package/node_modules/postcss/lib/lazy-result.d.ts +0 -189
  135. package/node_modules/postcss/lib/lazy-result.js +0 -563
  136. package/node_modules/postcss/lib/list.d.ts +0 -60
  137. package/node_modules/postcss/lib/list.js +0 -58
  138. package/node_modules/postcss/lib/map-generator.js +0 -376
  139. package/node_modules/postcss/lib/no-work-result.d.ts +0 -45
  140. package/node_modules/postcss/lib/no-work-result.js +0 -137
  141. package/node_modules/postcss/lib/node.d.ts +0 -555
  142. package/node_modules/postcss/lib/node.js +0 -449
  143. package/node_modules/postcss/lib/parse.d.ts +0 -9
  144. package/node_modules/postcss/lib/parse.js +0 -42
  145. package/node_modules/postcss/lib/parser.js +0 -618
  146. package/node_modules/postcss/lib/postcss.d.mts +0 -66
  147. package/node_modules/postcss/lib/postcss.d.ts +0 -461
  148. package/node_modules/postcss/lib/postcss.js +0 -101
  149. package/node_modules/postcss/lib/postcss.mjs +0 -30
  150. package/node_modules/postcss/lib/previous-map.d.ts +0 -80
  151. package/node_modules/postcss/lib/previous-map.js +0 -161
  152. package/node_modules/postcss/lib/processor.d.ts +0 -114
  153. package/node_modules/postcss/lib/processor.js +0 -67
  154. package/node_modules/postcss/lib/result.d.ts +0 -204
  155. package/node_modules/postcss/lib/result.js +0 -42
  156. package/node_modules/postcss/lib/root.d.ts +0 -86
  157. package/node_modules/postcss/lib/root.js +0 -61
  158. package/node_modules/postcss/lib/rule.d.ts +0 -126
  159. package/node_modules/postcss/lib/rule.js +0 -27
  160. package/node_modules/postcss/lib/stringifier.d.ts +0 -45
  161. package/node_modules/postcss/lib/stringifier.js +0 -374
  162. package/node_modules/postcss/lib/stringify.d.ts +0 -9
  163. package/node_modules/postcss/lib/stringify.js +0 -11
  164. package/node_modules/postcss/lib/symbols.js +0 -5
  165. package/node_modules/postcss/lib/terminal-highlight.js +0 -70
  166. package/node_modules/postcss/lib/tokenize.js +0 -270
  167. package/node_modules/postcss/lib/warn-once.js +0 -13
  168. package/node_modules/postcss/lib/warning.d.ts +0 -146
  169. package/node_modules/postcss/lib/warning.js +0 -37
  170. package/node_modules/postcss/package.json +0 -88
  171. package/node_modules/rolldown/LICENSE +0 -25
  172. package/node_modules/rolldown/README.md +0 -11
  173. package/node_modules/rolldown/bin/cli.mjs +0 -2
  174. package/node_modules/rolldown/dist/cli.d.mts +0 -1
  175. package/node_modules/rolldown/dist/cli.mjs +0 -1202
  176. package/node_modules/rolldown/dist/config.d.mts +0 -14
  177. package/node_modules/rolldown/dist/config.mjs +0 -4
  178. package/node_modules/rolldown/dist/experimental-index.d.mts +0 -280
  179. package/node_modules/rolldown/dist/experimental-index.mjs +0 -330
  180. package/node_modules/rolldown/dist/experimental-runtime-types.d.ts +0 -107
  181. package/node_modules/rolldown/dist/filter-index.d.mts +0 -195
  182. package/node_modules/rolldown/dist/filter-index.mjs +0 -380
  183. package/node_modules/rolldown/dist/get-log-filter.d.mts +0 -3
  184. package/node_modules/rolldown/dist/get-log-filter.mjs +0 -68
  185. package/node_modules/rolldown/dist/index.d.mts +0 -4
  186. package/node_modules/rolldown/dist/index.mjs +0 -50
  187. package/node_modules/rolldown/dist/parallel-plugin-worker.d.mts +0 -1
  188. package/node_modules/rolldown/dist/parallel-plugin-worker.mjs +0 -28
  189. package/node_modules/rolldown/dist/parallel-plugin.d.mts +0 -13
  190. package/node_modules/rolldown/dist/parallel-plugin.mjs +0 -6
  191. package/node_modules/rolldown/dist/parse-ast-index.d.mts +0 -32
  192. package/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
  193. package/node_modules/rolldown/dist/plugins-index.d.mts +0 -33
  194. package/node_modules/rolldown/dist/plugins-index.mjs +0 -40
  195. package/node_modules/rolldown/dist/shared/binding-B1q9aYT-.d.mts +0 -1947
  196. package/node_modules/rolldown/dist/shared/binding-Dh6LYCIB.mjs +0 -589
  197. package/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs +0 -2240
  198. package/node_modules/rolldown/dist/shared/constructors-688OwP2q.mjs +0 -65
  199. package/node_modules/rolldown/dist/shared/constructors-awZ1VNvg.d.mts +0 -36
  200. package/node_modules/rolldown/dist/shared/define-config-Demdg3_4.mjs +0 -6
  201. package/node_modules/rolldown/dist/shared/define-config-sxBscJ3M.d.mts +0 -3901
  202. package/node_modules/rolldown/dist/shared/error-B68YLzl3.mjs +0 -85
  203. package/node_modules/rolldown/dist/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  204. package/node_modules/rolldown/dist/shared/load-config-BvPPEM7l.mjs +0 -120
  205. package/node_modules/rolldown/dist/shared/logging-BSNejiLS.d.mts +0 -50
  206. package/node_modules/rolldown/dist/shared/logs-aMKUxRpj.mjs +0 -180
  207. package/node_modules/rolldown/dist/shared/misc-CoQm4NHO.mjs +0 -21
  208. package/node_modules/rolldown/dist/shared/normalize-string-or-regex-BpXHYeN4.mjs +0 -68
  209. package/node_modules/rolldown/dist/shared/parse-CTgsjpo8.mjs +0 -74
  210. package/node_modules/rolldown/dist/shared/prompt-B1Yc1NPt.mjs +0 -847
  211. package/node_modules/rolldown/dist/shared/resolve-tsconfig-BkhP9bkX.mjs +0 -124
  212. package/node_modules/rolldown/dist/shared/rolldown-Brph2NSU.mjs +0 -40
  213. package/node_modules/rolldown/dist/shared/rolldown-build-DR0wzp0V.mjs +0 -3264
  214. package/node_modules/rolldown/dist/shared/transform-CEmFsvJW.d.mts +0 -149
  215. package/node_modules/rolldown/dist/shared/watch-FrHSqg24.mjs +0 -374
  216. package/node_modules/rolldown/dist/utils-index.d.mts +0 -376
  217. package/node_modules/rolldown/dist/utils-index.mjs +0 -2414
  218. package/node_modules/rolldown/package.json +0 -153
  219. package/node_modules/source-map-js/LICENSE +0 -28
  220. package/node_modules/source-map-js/README.md +0 -765
  221. package/node_modules/source-map-js/lib/array-set.js +0 -121
  222. package/node_modules/source-map-js/lib/base64-vlq.js +0 -140
  223. package/node_modules/source-map-js/lib/base64.js +0 -67
  224. package/node_modules/source-map-js/lib/binary-search.js +0 -111
  225. package/node_modules/source-map-js/lib/mapping-list.js +0 -79
  226. package/node_modules/source-map-js/lib/quick-sort.js +0 -132
  227. package/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
  228. package/node_modules/source-map-js/lib/source-map-consumer.js +0 -1188
  229. package/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
  230. package/node_modules/source-map-js/lib/source-map-generator.js +0 -444
  231. package/node_modules/source-map-js/lib/source-node.d.ts +0 -1
  232. package/node_modules/source-map-js/lib/source-node.js +0 -413
  233. package/node_modules/source-map-js/lib/util.js +0 -594
  234. package/node_modules/source-map-js/package.json +0 -71
  235. package/node_modules/source-map-js/source-map.d.ts +0 -104
  236. package/node_modules/source-map-js/source-map.js +0 -8
  237. package/node_modules/tinyglobby/LICENSE +0 -21
  238. package/node_modules/tinyglobby/README.md +0 -25
  239. package/node_modules/tinyglobby/dist/index.cjs +0 -335
  240. package/node_modules/tinyglobby/dist/index.d.cts +0 -148
  241. package/node_modules/tinyglobby/dist/index.d.mts +0 -148
  242. package/node_modules/tinyglobby/dist/index.mjs +0 -307
  243. package/node_modules/tinyglobby/package.json +0 -70
  244. package/node_modules/vite/LICENSE.md +0 -2287
  245. package/node_modules/vite/README.md +0 -20
  246. package/node_modules/vite/bin/openChrome.js +0 -68
  247. package/node_modules/vite/bin/vite.js +0 -79
  248. package/node_modules/vite/client.d.ts +0 -285
  249. package/node_modules/vite/dist/client/client.mjs +0 -1269
  250. package/node_modules/vite/dist/client/env.mjs +0 -18
  251. package/node_modules/vite/dist/node/chunks/build.js +0 -5371
  252. package/node_modules/vite/dist/node/chunks/dist.js +0 -6784
  253. package/node_modules/vite/dist/node/chunks/lib.js +0 -371
  254. package/node_modules/vite/dist/node/chunks/logger.js +0 -364
  255. package/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +0 -96
  256. package/node_modules/vite/dist/node/chunks/node.js +0 -35770
  257. package/node_modules/vite/dist/node/chunks/postcss-import.js +0 -467
  258. package/node_modules/vite/dist/node/cli.js +0 -836
  259. package/node_modules/vite/dist/node/index.d.ts +0 -4010
  260. package/node_modules/vite/dist/node/index.js +0 -3
  261. package/node_modules/vite/dist/node/internal.d.ts +0 -2
  262. package/node_modules/vite/dist/node/internal.js +0 -2
  263. package/node_modules/vite/dist/node/module-runner.d.ts +0 -314
  264. package/node_modules/vite/dist/node/module-runner.js +0 -1274
  265. package/node_modules/vite/misc/false.js +0 -1
  266. package/node_modules/vite/misc/true.js +0 -1
  267. package/node_modules/vite/package.json +0 -194
  268. package/node_modules/vite/types/customEvent.d.ts +0 -79
  269. package/node_modules/vite/types/hmrPayload.d.ts +0 -80
  270. package/node_modules/vite/types/hot.d.ts +0 -39
  271. package/node_modules/vite/types/import-meta.d.ts +0 -5
  272. package/node_modules/vite/types/importGlob.d.ts +0 -131
  273. package/node_modules/vite/types/importMeta.d.ts +0 -30
  274. package/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +0 -44
  275. package/node_modules/vite/types/internal/esbuildOptions.d.ts +0 -28
  276. package/node_modules/vite/types/internal/lightningcssOptions.d.ts +0 -18
  277. package/node_modules/vite/types/internal/rollupTypeCompat.d.ts +0 -24
  278. package/node_modules/vite/types/internal/terserOptions.d.ts +0 -11
  279. package/node_modules/vite/types/metadata.d.ts +0 -47
@@ -1,1386 +0,0 @@
1
- 'use strict';
2
-
3
- const constants = require('./constants');
4
- const utils = require('./utils');
5
-
6
- /**
7
- * Constants
8
- */
9
-
10
- const {
11
- MAX_LENGTH,
12
- POSIX_REGEX_SOURCE,
13
- REGEX_NON_SPECIAL_CHARS,
14
- REGEX_SPECIAL_CHARS_BACKREF,
15
- REPLACEMENTS
16
- } = constants;
17
-
18
- /**
19
- * Helpers
20
- */
21
-
22
- const expandRange = (args, options) => {
23
- if (typeof options.expandRange === 'function') {
24
- return options.expandRange(...args, options);
25
- }
26
-
27
- args.sort();
28
- const value = `[${args.join('-')}]`;
29
-
30
- try {
31
- /* eslint-disable-next-line no-new */
32
- new RegExp(value);
33
- } catch (ex) {
34
- return args.map(v => utils.escapeRegex(v)).join('..');
35
- }
36
-
37
- return value;
38
- };
39
-
40
- /**
41
- * Create the message for a syntax error
42
- */
43
-
44
- const syntaxError = (type, char) => {
45
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
46
- };
47
-
48
- const splitTopLevel = input => {
49
- const parts = [];
50
- let bracket = 0;
51
- let paren = 0;
52
- let quote = 0;
53
- let value = '';
54
- let escaped = false;
55
-
56
- for (const ch of input) {
57
- if (escaped === true) {
58
- value += ch;
59
- escaped = false;
60
- continue;
61
- }
62
-
63
- if (ch === '\\') {
64
- value += ch;
65
- escaped = true;
66
- continue;
67
- }
68
-
69
- if (ch === '"') {
70
- quote = quote === 1 ? 0 : 1;
71
- value += ch;
72
- continue;
73
- }
74
-
75
- if (quote === 0) {
76
- if (ch === '[') {
77
- bracket++;
78
- } else if (ch === ']' && bracket > 0) {
79
- bracket--;
80
- } else if (bracket === 0) {
81
- if (ch === '(') {
82
- paren++;
83
- } else if (ch === ')' && paren > 0) {
84
- paren--;
85
- } else if (ch === '|' && paren === 0) {
86
- parts.push(value);
87
- value = '';
88
- continue;
89
- }
90
- }
91
- }
92
-
93
- value += ch;
94
- }
95
-
96
- parts.push(value);
97
- return parts;
98
- };
99
-
100
- const isPlainBranch = branch => {
101
- let escaped = false;
102
-
103
- for (const ch of branch) {
104
- if (escaped === true) {
105
- escaped = false;
106
- continue;
107
- }
108
-
109
- if (ch === '\\') {
110
- escaped = true;
111
- continue;
112
- }
113
-
114
- if (/[?*+@!()[\]{}]/.test(ch)) {
115
- return false;
116
- }
117
- }
118
-
119
- return true;
120
- };
121
-
122
- const normalizeSimpleBranch = branch => {
123
- let value = branch.trim();
124
- let changed = true;
125
-
126
- while (changed === true) {
127
- changed = false;
128
-
129
- if (/^@\([^\\()[\]{}|]+\)$/.test(value)) {
130
- value = value.slice(2, -1);
131
- changed = true;
132
- }
133
- }
134
-
135
- if (!isPlainBranch(value)) {
136
- return;
137
- }
138
-
139
- return value.replace(/\\(.)/g, '$1');
140
- };
141
-
142
- const hasRepeatedCharPrefixOverlap = branches => {
143
- const values = branches.map(normalizeSimpleBranch).filter(Boolean);
144
-
145
- for (let i = 0; i < values.length; i++) {
146
- for (let j = i + 1; j < values.length; j++) {
147
- const a = values[i];
148
- const b = values[j];
149
- const char = a[0];
150
-
151
- if (!char || a !== char.repeat(a.length) || b !== char.repeat(b.length)) {
152
- continue;
153
- }
154
-
155
- if (a === b || a.startsWith(b) || b.startsWith(a)) {
156
- return true;
157
- }
158
- }
159
- }
160
-
161
- return false;
162
- };
163
-
164
- const parseRepeatedExtglob = (pattern, requireEnd = true) => {
165
- if ((pattern[0] !== '+' && pattern[0] !== '*') || pattern[1] !== '(') {
166
- return;
167
- }
168
-
169
- let bracket = 0;
170
- let paren = 0;
171
- let quote = 0;
172
- let escaped = false;
173
-
174
- for (let i = 1; i < pattern.length; i++) {
175
- const ch = pattern[i];
176
-
177
- if (escaped === true) {
178
- escaped = false;
179
- continue;
180
- }
181
-
182
- if (ch === '\\') {
183
- escaped = true;
184
- continue;
185
- }
186
-
187
- if (ch === '"') {
188
- quote = quote === 1 ? 0 : 1;
189
- continue;
190
- }
191
-
192
- if (quote === 1) {
193
- continue;
194
- }
195
-
196
- if (ch === '[') {
197
- bracket++;
198
- continue;
199
- }
200
-
201
- if (ch === ']' && bracket > 0) {
202
- bracket--;
203
- continue;
204
- }
205
-
206
- if (bracket > 0) {
207
- continue;
208
- }
209
-
210
- if (ch === '(') {
211
- paren++;
212
- continue;
213
- }
214
-
215
- if (ch === ')') {
216
- paren--;
217
-
218
- if (paren === 0) {
219
- if (requireEnd === true && i !== pattern.length - 1) {
220
- return;
221
- }
222
-
223
- return {
224
- type: pattern[0],
225
- body: pattern.slice(2, i),
226
- end: i
227
- };
228
- }
229
- }
230
- }
231
- };
232
-
233
- const getStarExtglobSequenceOutput = pattern => {
234
- let index = 0;
235
- const chars = [];
236
-
237
- while (index < pattern.length) {
238
- const match = parseRepeatedExtglob(pattern.slice(index), false);
239
-
240
- if (!match || match.type !== '*') {
241
- return;
242
- }
243
-
244
- const branches = splitTopLevel(match.body).map(branch => branch.trim());
245
- if (branches.length !== 1) {
246
- return;
247
- }
248
-
249
- const branch = normalizeSimpleBranch(branches[0]);
250
- if (!branch || branch.length !== 1) {
251
- return;
252
- }
253
-
254
- chars.push(branch);
255
- index += match.end + 1;
256
- }
257
-
258
- if (chars.length < 1) {
259
- return;
260
- }
261
-
262
- const source = chars.length === 1
263
- ? utils.escapeRegex(chars[0])
264
- : `[${chars.map(ch => utils.escapeRegex(ch)).join('')}]`;
265
-
266
- return `${source}*`;
267
- };
268
-
269
- const repeatedExtglobRecursion = pattern => {
270
- let depth = 0;
271
- let value = pattern.trim();
272
- let match = parseRepeatedExtglob(value);
273
-
274
- while (match) {
275
- depth++;
276
- value = match.body.trim();
277
- match = parseRepeatedExtglob(value);
278
- }
279
-
280
- return depth;
281
- };
282
-
283
- const analyzeRepeatedExtglob = (body, options) => {
284
- if (options.maxExtglobRecursion === false) {
285
- return { risky: false };
286
- }
287
-
288
- const max =
289
- typeof options.maxExtglobRecursion === 'number'
290
- ? options.maxExtglobRecursion
291
- : constants.DEFAULT_MAX_EXTGLOB_RECURSION;
292
-
293
- const branches = splitTopLevel(body).map(branch => branch.trim());
294
-
295
- if (branches.length > 1) {
296
- if (
297
- branches.some(branch => branch === '') ||
298
- branches.some(branch => /^[*?]+$/.test(branch)) ||
299
- hasRepeatedCharPrefixOverlap(branches)
300
- ) {
301
- return { risky: true };
302
- }
303
- }
304
-
305
- for (const branch of branches) {
306
- const safeOutput = getStarExtglobSequenceOutput(branch);
307
- if (safeOutput) {
308
- return { risky: true, safeOutput };
309
- }
310
-
311
- if (repeatedExtglobRecursion(branch) > max) {
312
- return { risky: true };
313
- }
314
- }
315
-
316
- return { risky: false };
317
- };
318
-
319
- /**
320
- * Parse the given input string.
321
- * @param {String} input
322
- * @param {Object} options
323
- * @return {Object}
324
- */
325
-
326
- const parse = (input, options) => {
327
- if (typeof input !== 'string') {
328
- throw new TypeError('Expected a string');
329
- }
330
-
331
- input = REPLACEMENTS[input] || input;
332
-
333
- const opts = { ...options };
334
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
335
-
336
- let len = input.length;
337
- if (len > max) {
338
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
339
- }
340
-
341
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
342
- const tokens = [bos];
343
-
344
- const capture = opts.capture ? '' : '?:';
345
-
346
- // create constants based on platform, for windows or posix
347
- const PLATFORM_CHARS = constants.globChars(opts.windows);
348
- const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
349
-
350
- const {
351
- DOT_LITERAL,
352
- PLUS_LITERAL,
353
- SLASH_LITERAL,
354
- ONE_CHAR,
355
- DOTS_SLASH,
356
- NO_DOT,
357
- NO_DOT_SLASH,
358
- NO_DOTS_SLASH,
359
- QMARK,
360
- QMARK_NO_DOT,
361
- STAR,
362
- START_ANCHOR
363
- } = PLATFORM_CHARS;
364
-
365
- const globstar = opts => {
366
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
367
- };
368
-
369
- const nodot = opts.dot ? '' : NO_DOT;
370
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
371
- let star = opts.bash === true ? globstar(opts) : STAR;
372
-
373
- if (opts.capture) {
374
- star = `(${star})`;
375
- }
376
-
377
- // minimatch options support
378
- if (typeof opts.noext === 'boolean') {
379
- opts.noextglob = opts.noext;
380
- }
381
-
382
- const state = {
383
- input,
384
- index: -1,
385
- start: 0,
386
- dot: opts.dot === true,
387
- consumed: '',
388
- output: '',
389
- prefix: '',
390
- backtrack: false,
391
- negated: false,
392
- brackets: 0,
393
- braces: 0,
394
- parens: 0,
395
- quotes: 0,
396
- globstar: false,
397
- tokens
398
- };
399
-
400
- input = utils.removePrefix(input, state);
401
- len = input.length;
402
-
403
- const extglobs = [];
404
- const braces = [];
405
- const stack = [];
406
- let prev = bos;
407
- let value;
408
-
409
- /**
410
- * Tokenizing helpers
411
- */
412
-
413
- const eos = () => state.index === len - 1;
414
- const peek = state.peek = (n = 1) => input[state.index + n];
415
- const advance = state.advance = () => input[++state.index] || '';
416
- const remaining = () => input.slice(state.index + 1);
417
- const consume = (value = '', num = 0) => {
418
- state.consumed += value;
419
- state.index += num;
420
- };
421
-
422
- const append = token => {
423
- state.output += token.output != null ? token.output : token.value;
424
- consume(token.value);
425
- };
426
-
427
- const negate = () => {
428
- let count = 1;
429
-
430
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
431
- advance();
432
- state.start++;
433
- count++;
434
- }
435
-
436
- if (count % 2 === 0) {
437
- return false;
438
- }
439
-
440
- state.negated = true;
441
- state.start++;
442
- return true;
443
- };
444
-
445
- const increment = type => {
446
- state[type]++;
447
- stack.push(type);
448
- };
449
-
450
- const decrement = type => {
451
- state[type]--;
452
- stack.pop();
453
- };
454
-
455
- /**
456
- * Push tokens onto the tokens array. This helper speeds up
457
- * tokenizing by 1) helping us avoid backtracking as much as possible,
458
- * and 2) helping us avoid creating extra tokens when consecutive
459
- * characters are plain text. This improves performance and simplifies
460
- * lookbehinds.
461
- */
462
-
463
- const push = tok => {
464
- if (prev.type === 'globstar') {
465
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
466
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
467
-
468
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
469
- state.output = state.output.slice(0, -prev.output.length);
470
- prev.type = 'star';
471
- prev.value = '*';
472
- prev.output = star;
473
- state.output += prev.output;
474
- }
475
- }
476
-
477
- if (extglobs.length && tok.type !== 'paren') {
478
- extglobs[extglobs.length - 1].inner += tok.value;
479
- }
480
-
481
- if (tok.value || tok.output) append(tok);
482
- if (prev && prev.type === 'text' && tok.type === 'text') {
483
- prev.output = (prev.output || prev.value) + tok.value;
484
- prev.value += tok.value;
485
- return;
486
- }
487
-
488
- tok.prev = prev;
489
- tokens.push(tok);
490
- prev = tok;
491
- };
492
-
493
- const extglobOpen = (type, value) => {
494
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
495
-
496
- token.prev = prev;
497
- token.parens = state.parens;
498
- token.output = state.output;
499
- token.startIndex = state.index;
500
- token.tokensIndex = tokens.length;
501
- const output = (opts.capture ? '(' : '') + token.open;
502
-
503
- increment('parens');
504
- push({ type, value, output: state.output ? '' : ONE_CHAR });
505
- push({ type: 'paren', extglob: true, value: advance(), output });
506
- extglobs.push(token);
507
- };
508
-
509
- const extglobClose = token => {
510
- const literal = input.slice(token.startIndex, state.index + 1);
511
- const body = input.slice(token.startIndex + 2, state.index);
512
- const analysis = analyzeRepeatedExtglob(body, opts);
513
-
514
- if ((token.type === 'plus' || token.type === 'star') && analysis.risky) {
515
- const safeOutput = analysis.safeOutput
516
- ? (token.output ? '' : ONE_CHAR) + (opts.capture ? `(${analysis.safeOutput})` : analysis.safeOutput)
517
- : undefined;
518
- const open = tokens[token.tokensIndex];
519
-
520
- open.type = 'text';
521
- open.value = literal;
522
- open.output = safeOutput || utils.escapeRegex(literal);
523
-
524
- for (let i = token.tokensIndex + 1; i < tokens.length; i++) {
525
- tokens[i].value = '';
526
- tokens[i].output = '';
527
- delete tokens[i].suffix;
528
- }
529
-
530
- state.output = token.output + open.output;
531
- state.backtrack = true;
532
-
533
- push({ type: 'paren', extglob: true, value, output: '' });
534
- decrement('parens');
535
- return;
536
- }
537
-
538
- let output = token.close + (opts.capture ? ')' : '');
539
- let rest;
540
-
541
- if (token.type === 'negate') {
542
- let extglobStar = star;
543
-
544
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
545
- extglobStar = globstar(opts);
546
- }
547
-
548
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
549
- output = token.close = `)$))${extglobStar}`;
550
- }
551
-
552
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
553
- // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
554
- // In this case, we need to parse the string and use it in the output of the original pattern.
555
- // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
556
- //
557
- // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
558
- const expression = parse(rest, { ...options, fastpaths: false }).output;
559
-
560
- output = token.close = `)${expression})${extglobStar})`;
561
- }
562
-
563
- if (token.prev.type === 'bos') {
564
- state.negatedExtglob = true;
565
- }
566
- }
567
-
568
- push({ type: 'paren', extglob: true, value, output });
569
- decrement('parens');
570
- };
571
-
572
- /**
573
- * Fast paths
574
- */
575
-
576
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
577
- let backslashes = false;
578
-
579
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
580
- if (first === '\\') {
581
- backslashes = true;
582
- return m;
583
- }
584
-
585
- if (first === '?') {
586
- if (esc) {
587
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
588
- }
589
- if (index === 0) {
590
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
591
- }
592
- return QMARK.repeat(chars.length);
593
- }
594
-
595
- if (first === '.') {
596
- return DOT_LITERAL.repeat(chars.length);
597
- }
598
-
599
- if (first === '*') {
600
- if (esc) {
601
- return esc + first + (rest ? star : '');
602
- }
603
- return star;
604
- }
605
- return esc ? m : `\\${m}`;
606
- });
607
-
608
- if (backslashes === true) {
609
- if (opts.unescape === true) {
610
- output = output.replace(/\\/g, '');
611
- } else {
612
- output = output.replace(/\\+/g, m => {
613
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
614
- });
615
- }
616
- }
617
-
618
- if (output === input && opts.contains === true) {
619
- state.output = input;
620
- return state;
621
- }
622
-
623
- state.output = utils.wrapOutput(output, state, options);
624
- return state;
625
- }
626
-
627
- /**
628
- * Tokenize input until we reach end-of-string
629
- */
630
-
631
- while (!eos()) {
632
- value = advance();
633
-
634
- if (value === '\u0000') {
635
- continue;
636
- }
637
-
638
- /**
639
- * Escaped characters
640
- */
641
-
642
- if (value === '\\') {
643
- const next = peek();
644
-
645
- if (next === '/' && opts.bash !== true) {
646
- continue;
647
- }
648
-
649
- if (next === '.' || next === ';') {
650
- continue;
651
- }
652
-
653
- if (!next) {
654
- value += '\\';
655
- push({ type: 'text', value });
656
- continue;
657
- }
658
-
659
- // collapse slashes to reduce potential for exploits
660
- const match = /^\\+/.exec(remaining());
661
- let slashes = 0;
662
-
663
- if (match && match[0].length > 2) {
664
- slashes = match[0].length;
665
- state.index += slashes;
666
- if (slashes % 2 !== 0) {
667
- value += '\\';
668
- }
669
- }
670
-
671
- if (opts.unescape === true) {
672
- value = advance();
673
- } else {
674
- value += advance();
675
- }
676
-
677
- if (state.brackets === 0) {
678
- push({ type: 'text', value });
679
- continue;
680
- }
681
- }
682
-
683
- /**
684
- * If we're inside a regex character class, continue
685
- * until we reach the closing bracket.
686
- */
687
-
688
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
689
- if (opts.posix !== false && value === ':') {
690
- const inner = prev.value.slice(1);
691
- if (inner.includes('[')) {
692
- prev.posix = true;
693
-
694
- if (inner.includes(':')) {
695
- const idx = prev.value.lastIndexOf('[');
696
- const pre = prev.value.slice(0, idx);
697
- const rest = prev.value.slice(idx + 2);
698
- const posix = POSIX_REGEX_SOURCE[rest];
699
- if (posix) {
700
- prev.value = pre + posix;
701
- state.backtrack = true;
702
- advance();
703
-
704
- if (!bos.output && tokens.indexOf(prev) === 1) {
705
- bos.output = ONE_CHAR;
706
- }
707
- continue;
708
- }
709
- }
710
- }
711
- }
712
-
713
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
714
- value = `\\${value}`;
715
- }
716
-
717
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
718
- value = `\\${value}`;
719
- }
720
-
721
- if (opts.posix === true && value === '!' && prev.value === '[') {
722
- value = '^';
723
- }
724
-
725
- prev.value += value;
726
- append({ value });
727
- continue;
728
- }
729
-
730
- /**
731
- * If we're inside a quoted string, continue
732
- * until we reach the closing double quote.
733
- */
734
-
735
- if (state.quotes === 1 && value !== '"') {
736
- value = utils.escapeRegex(value);
737
- prev.value += value;
738
- append({ value });
739
- continue;
740
- }
741
-
742
- /**
743
- * Double quotes
744
- */
745
-
746
- if (value === '"') {
747
- state.quotes = state.quotes === 1 ? 0 : 1;
748
- if (opts.keepQuotes === true) {
749
- push({ type: 'text', value });
750
- }
751
- continue;
752
- }
753
-
754
- /**
755
- * Parentheses
756
- */
757
-
758
- if (value === '(') {
759
- increment('parens');
760
- push({ type: 'paren', value });
761
- continue;
762
- }
763
-
764
- if (value === ')') {
765
- if (state.parens === 0 && opts.strictBrackets === true) {
766
- throw new SyntaxError(syntaxError('opening', '('));
767
- }
768
-
769
- const extglob = extglobs[extglobs.length - 1];
770
- if (extglob && state.parens === extglob.parens + 1) {
771
- extglobClose(extglobs.pop());
772
- continue;
773
- }
774
-
775
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
776
- decrement('parens');
777
- continue;
778
- }
779
-
780
- /**
781
- * Square brackets
782
- */
783
-
784
- if (value === '[') {
785
- if (opts.nobracket === true || !remaining().includes(']')) {
786
- if (opts.nobracket !== true && opts.strictBrackets === true) {
787
- throw new SyntaxError(syntaxError('closing', ']'));
788
- }
789
-
790
- value = `\\${value}`;
791
- } else {
792
- increment('brackets');
793
- }
794
-
795
- push({ type: 'bracket', value });
796
- continue;
797
- }
798
-
799
- if (value === ']') {
800
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
801
- push({ type: 'text', value, output: `\\${value}` });
802
- continue;
803
- }
804
-
805
- if (state.brackets === 0) {
806
- if (opts.strictBrackets === true) {
807
- throw new SyntaxError(syntaxError('opening', '['));
808
- }
809
-
810
- push({ type: 'text', value, output: `\\${value}` });
811
- continue;
812
- }
813
-
814
- decrement('brackets');
815
-
816
- const prevValue = prev.value.slice(1);
817
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
818
- value = `/${value}`;
819
- }
820
-
821
- prev.value += value;
822
- append({ value });
823
-
824
- // when literal brackets are explicitly disabled
825
- // assume we should match with a regex character class
826
- if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
827
- continue;
828
- }
829
-
830
- const escaped = utils.escapeRegex(prev.value);
831
- state.output = state.output.slice(0, -prev.value.length);
832
-
833
- // when literal brackets are explicitly enabled
834
- // assume we should escape the brackets to match literal characters
835
- if (opts.literalBrackets === true) {
836
- state.output += escaped;
837
- prev.value = escaped;
838
- continue;
839
- }
840
-
841
- // when the user specifies nothing, try to match both
842
- prev.value = `(${capture}${escaped}|${prev.value})`;
843
- state.output += prev.value;
844
- continue;
845
- }
846
-
847
- /**
848
- * Braces
849
- */
850
-
851
- if (value === '{' && opts.nobrace !== true) {
852
- increment('braces');
853
-
854
- const open = {
855
- type: 'brace',
856
- value,
857
- output: '(',
858
- outputIndex: state.output.length,
859
- tokensIndex: state.tokens.length
860
- };
861
-
862
- braces.push(open);
863
- push(open);
864
- continue;
865
- }
866
-
867
- if (value === '}') {
868
- const brace = braces[braces.length - 1];
869
-
870
- if (opts.nobrace === true || !brace) {
871
- push({ type: 'text', value, output: value });
872
- continue;
873
- }
874
-
875
- let output = ')';
876
-
877
- if (brace.dots === true) {
878
- const arr = tokens.slice();
879
- const range = [];
880
-
881
- for (let i = arr.length - 1; i >= 0; i--) {
882
- tokens.pop();
883
- if (arr[i].type === 'brace') {
884
- break;
885
- }
886
- if (arr[i].type !== 'dots') {
887
- range.unshift(arr[i].value);
888
- }
889
- }
890
-
891
- output = expandRange(range, opts);
892
- state.backtrack = true;
893
- }
894
-
895
- if (brace.comma !== true && brace.dots !== true) {
896
- const out = state.output.slice(0, brace.outputIndex);
897
- const toks = state.tokens.slice(brace.tokensIndex);
898
- brace.value = brace.output = '\\{';
899
- value = output = '\\}';
900
- state.output = out;
901
- for (const t of toks) {
902
- state.output += (t.output || t.value);
903
- }
904
- }
905
-
906
- push({ type: 'brace', value, output });
907
- decrement('braces');
908
- braces.pop();
909
- continue;
910
- }
911
-
912
- /**
913
- * Pipes
914
- */
915
-
916
- if (value === '|') {
917
- if (extglobs.length > 0) {
918
- extglobs[extglobs.length - 1].conditions++;
919
- }
920
- push({ type: 'text', value });
921
- continue;
922
- }
923
-
924
- /**
925
- * Commas
926
- */
927
-
928
- if (value === ',') {
929
- let output = value;
930
-
931
- const brace = braces[braces.length - 1];
932
- if (brace && stack[stack.length - 1] === 'braces') {
933
- brace.comma = true;
934
- output = '|';
935
- }
936
-
937
- push({ type: 'comma', value, output });
938
- continue;
939
- }
940
-
941
- /**
942
- * Slashes
943
- */
944
-
945
- if (value === '/') {
946
- // if the beginning of the glob is "./", advance the start
947
- // to the current index, and don't add the "./" characters
948
- // to the state. This greatly simplifies lookbehinds when
949
- // checking for BOS characters like "!" and "." (not "./")
950
- if (prev.type === 'dot' && state.index === state.start + 1) {
951
- state.start = state.index + 1;
952
- state.consumed = '';
953
- state.output = '';
954
- tokens.pop();
955
- prev = bos; // reset "prev" to the first token
956
- continue;
957
- }
958
-
959
- push({ type: 'slash', value, output: SLASH_LITERAL });
960
- continue;
961
- }
962
-
963
- /**
964
- * Dots
965
- */
966
-
967
- if (value === '.') {
968
- if (state.braces > 0 && prev.type === 'dot') {
969
- if (prev.value === '.') prev.output = DOT_LITERAL;
970
- const brace = braces[braces.length - 1];
971
- prev.type = 'dots';
972
- prev.output += value;
973
- prev.value += value;
974
- brace.dots = true;
975
- continue;
976
- }
977
-
978
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
979
- push({ type: 'text', value, output: DOT_LITERAL });
980
- continue;
981
- }
982
-
983
- push({ type: 'dot', value, output: DOT_LITERAL });
984
- continue;
985
- }
986
-
987
- /**
988
- * Question marks
989
- */
990
-
991
- if (value === '?') {
992
- const isGroup = prev && prev.value === '(';
993
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
994
- extglobOpen('qmark', value);
995
- continue;
996
- }
997
-
998
- if (prev && prev.type === 'paren') {
999
- const next = peek();
1000
- let output = value;
1001
-
1002
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
1003
- output = `\\${value}`;
1004
- }
1005
-
1006
- push({ type: 'text', value, output });
1007
- continue;
1008
- }
1009
-
1010
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
1011
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
1012
- continue;
1013
- }
1014
-
1015
- push({ type: 'qmark', value, output: QMARK });
1016
- continue;
1017
- }
1018
-
1019
- /**
1020
- * Exclamation
1021
- */
1022
-
1023
- if (value === '!') {
1024
- if (opts.noextglob !== true && peek() === '(') {
1025
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
1026
- extglobOpen('negate', value);
1027
- continue;
1028
- }
1029
- }
1030
-
1031
- if (opts.nonegate !== true && state.index === 0) {
1032
- negate();
1033
- continue;
1034
- }
1035
- }
1036
-
1037
- /**
1038
- * Plus
1039
- */
1040
-
1041
- if (value === '+') {
1042
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1043
- extglobOpen('plus', value);
1044
- continue;
1045
- }
1046
-
1047
- if ((prev && prev.value === '(') || opts.regex === false) {
1048
- push({ type: 'plus', value, output: PLUS_LITERAL });
1049
- continue;
1050
- }
1051
-
1052
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
1053
- push({ type: 'plus', value });
1054
- continue;
1055
- }
1056
-
1057
- push({ type: 'plus', value: PLUS_LITERAL });
1058
- continue;
1059
- }
1060
-
1061
- /**
1062
- * Plain text
1063
- */
1064
-
1065
- if (value === '@') {
1066
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
1067
- push({ type: 'at', extglob: true, value, output: '' });
1068
- continue;
1069
- }
1070
-
1071
- push({ type: 'text', value });
1072
- continue;
1073
- }
1074
-
1075
- /**
1076
- * Plain text
1077
- */
1078
-
1079
- if (value !== '*') {
1080
- if (value === '$' || value === '^') {
1081
- value = `\\${value}`;
1082
- }
1083
-
1084
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
1085
- if (match) {
1086
- value += match[0];
1087
- state.index += match[0].length;
1088
- }
1089
-
1090
- push({ type: 'text', value });
1091
- continue;
1092
- }
1093
-
1094
- /**
1095
- * Stars
1096
- */
1097
-
1098
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
1099
- prev.type = 'star';
1100
- prev.star = true;
1101
- prev.value += value;
1102
- prev.output = star;
1103
- state.backtrack = true;
1104
- state.globstar = true;
1105
- consume(value);
1106
- continue;
1107
- }
1108
-
1109
- let rest = remaining();
1110
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
1111
- extglobOpen('star', value);
1112
- continue;
1113
- }
1114
-
1115
- if (prev.type === 'star') {
1116
- if (opts.noglobstar === true) {
1117
- consume(value);
1118
- continue;
1119
- }
1120
-
1121
- const prior = prev.prev;
1122
- const before = prior.prev;
1123
- const isStart = prior.type === 'slash' || prior.type === 'bos';
1124
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
1125
-
1126
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
1127
- push({ type: 'star', value, output: '' });
1128
- continue;
1129
- }
1130
-
1131
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
1132
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
1133
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
1134
- push({ type: 'star', value, output: '' });
1135
- continue;
1136
- }
1137
-
1138
- // strip consecutive `/**/`
1139
- while (rest.slice(0, 3) === '/**') {
1140
- const after = input[state.index + 4];
1141
- if (after && after !== '/') {
1142
- break;
1143
- }
1144
- rest = rest.slice(3);
1145
- consume('/**', 3);
1146
- }
1147
-
1148
- if (prior.type === 'bos' && eos()) {
1149
- prev.type = 'globstar';
1150
- prev.value += value;
1151
- prev.output = globstar(opts);
1152
- state.output = prev.output;
1153
- state.globstar = true;
1154
- consume(value);
1155
- continue;
1156
- }
1157
-
1158
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
1159
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1160
- prior.output = `(?:${prior.output}`;
1161
-
1162
- prev.type = 'globstar';
1163
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
1164
- prev.value += value;
1165
- state.globstar = true;
1166
- state.output += prior.output + prev.output;
1167
- consume(value);
1168
- continue;
1169
- }
1170
-
1171
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
1172
- const end = rest[1] !== void 0 ? '|$' : '';
1173
-
1174
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
1175
- prior.output = `(?:${prior.output}`;
1176
-
1177
- prev.type = 'globstar';
1178
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
1179
- prev.value += value;
1180
-
1181
- state.output += prior.output + prev.output;
1182
- state.globstar = true;
1183
-
1184
- consume(value + advance());
1185
-
1186
- push({ type: 'slash', value: '/', output: '' });
1187
- continue;
1188
- }
1189
-
1190
- if (prior.type === 'bos' && rest[0] === '/') {
1191
- prev.type = 'globstar';
1192
- prev.value += value;
1193
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
1194
- state.output = prev.output;
1195
- state.globstar = true;
1196
- consume(value + advance());
1197
- push({ type: 'slash', value: '/', output: '' });
1198
- continue;
1199
- }
1200
-
1201
- // remove single star from output
1202
- state.output = state.output.slice(0, -prev.output.length);
1203
-
1204
- // reset previous token to globstar
1205
- prev.type = 'globstar';
1206
- prev.output = globstar(opts);
1207
- prev.value += value;
1208
-
1209
- // reset output with globstar
1210
- state.output += prev.output;
1211
- state.globstar = true;
1212
- consume(value);
1213
- continue;
1214
- }
1215
-
1216
- const token = { type: 'star', value, output: star };
1217
-
1218
- if (opts.bash === true) {
1219
- token.output = '.*?';
1220
- if (prev.type === 'bos' || prev.type === 'slash') {
1221
- token.output = nodot + token.output;
1222
- }
1223
- push(token);
1224
- continue;
1225
- }
1226
-
1227
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
1228
- token.output = value;
1229
- push(token);
1230
- continue;
1231
- }
1232
-
1233
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
1234
- if (prev.type === 'dot') {
1235
- state.output += NO_DOT_SLASH;
1236
- prev.output += NO_DOT_SLASH;
1237
-
1238
- } else if (opts.dot === true) {
1239
- state.output += NO_DOTS_SLASH;
1240
- prev.output += NO_DOTS_SLASH;
1241
-
1242
- } else {
1243
- state.output += nodot;
1244
- prev.output += nodot;
1245
- }
1246
-
1247
- if (peek() !== '*') {
1248
- state.output += ONE_CHAR;
1249
- prev.output += ONE_CHAR;
1250
- }
1251
- }
1252
-
1253
- push(token);
1254
- }
1255
-
1256
- while (state.brackets > 0) {
1257
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
1258
- state.output = utils.escapeLast(state.output, '[');
1259
- decrement('brackets');
1260
- }
1261
-
1262
- while (state.parens > 0) {
1263
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
1264
- state.output = utils.escapeLast(state.output, '(');
1265
- decrement('parens');
1266
- }
1267
-
1268
- while (state.braces > 0) {
1269
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
1270
- state.output = utils.escapeLast(state.output, '{');
1271
- decrement('braces');
1272
- }
1273
-
1274
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
1275
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
1276
- }
1277
-
1278
- // rebuild the output if we had to backtrack at any point
1279
- if (state.backtrack === true) {
1280
- state.output = '';
1281
-
1282
- for (const token of state.tokens) {
1283
- state.output += token.output != null ? token.output : token.value;
1284
-
1285
- if (token.suffix) {
1286
- state.output += token.suffix;
1287
- }
1288
- }
1289
- }
1290
-
1291
- return state;
1292
- };
1293
-
1294
- /**
1295
- * Fast paths for creating regular expressions for common glob patterns.
1296
- * This can significantly speed up processing and has very little downside
1297
- * impact when none of the fast paths match.
1298
- */
1299
-
1300
- parse.fastpaths = (input, options) => {
1301
- const opts = { ...options };
1302
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
1303
- const len = input.length;
1304
- if (len > max) {
1305
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
1306
- }
1307
-
1308
- input = REPLACEMENTS[input] || input;
1309
-
1310
- // create constants based on platform, for windows or posix
1311
- const {
1312
- DOT_LITERAL,
1313
- SLASH_LITERAL,
1314
- ONE_CHAR,
1315
- DOTS_SLASH,
1316
- NO_DOT,
1317
- NO_DOTS,
1318
- NO_DOTS_SLASH,
1319
- STAR,
1320
- START_ANCHOR
1321
- } = constants.globChars(opts.windows);
1322
-
1323
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
1324
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
1325
- const capture = opts.capture ? '' : '?:';
1326
- const state = { negated: false, prefix: '' };
1327
- let star = opts.bash === true ? '.*?' : STAR;
1328
-
1329
- if (opts.capture) {
1330
- star = `(${star})`;
1331
- }
1332
-
1333
- const globstar = opts => {
1334
- if (opts.noglobstar === true) return star;
1335
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
1336
- };
1337
-
1338
- const create = str => {
1339
- switch (str) {
1340
- case '*':
1341
- return `${nodot}${ONE_CHAR}${star}`;
1342
-
1343
- case '.*':
1344
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
1345
-
1346
- case '*.*':
1347
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1348
-
1349
- case '*/*':
1350
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
1351
-
1352
- case '**':
1353
- return nodot + globstar(opts);
1354
-
1355
- case '**/*':
1356
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
1357
-
1358
- case '**/*.*':
1359
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
1360
-
1361
- case '**/.*':
1362
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
1363
-
1364
- default: {
1365
- const match = /^(.*?)\.(\w+)$/.exec(str);
1366
- if (!match) return;
1367
-
1368
- const source = create(match[1]);
1369
- if (!source) return;
1370
-
1371
- return source + DOT_LITERAL + match[2];
1372
- }
1373
- }
1374
- };
1375
-
1376
- const output = utils.removePrefix(input, state);
1377
- let source = create(output);
1378
-
1379
- if (source && opts.strictSlashes !== true) {
1380
- source += `${SLASH_LITERAL}?`;
1381
- }
1382
-
1383
- return source;
1384
- };
1385
-
1386
- module.exports = parse;