zedbee 0.1.0-beta.15 → 0.1.0-beta.17

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 (645) hide show
  1. package/THIRD_PARTY_NOTICES.md +70 -74
  2. package/dist/attribution/metrics.d.ts.map +1 -1
  3. package/dist/attribution/metrics.js +8 -5
  4. package/dist/attribution/metrics.js.map +1 -1
  5. package/dist/attribution/pair-locations.d.ts.map +1 -1
  6. package/dist/attribution/pair-locations.js +20 -10
  7. package/dist/attribution/pair-locations.js.map +1 -1
  8. package/dist/attribution/pair-source-moves.d.ts +12 -0
  9. package/dist/attribution/pair-source-moves.d.ts.map +1 -0
  10. package/dist/attribution/pair-source-moves.js +108 -0
  11. package/dist/attribution/pair-source-moves.js.map +1 -0
  12. package/dist/attribution/source-moves.d.ts +47 -0
  13. package/dist/attribution/source-moves.d.ts.map +1 -0
  14. package/dist/attribution/source-moves.js +199 -0
  15. package/dist/attribution/source-moves.js.map +1 -0
  16. package/dist/cache/store.d.ts +1 -0
  17. package/dist/cache/store.d.ts.map +1 -1
  18. package/dist/cache/store.js +2 -0
  19. package/dist/cache/store.js.map +1 -1
  20. package/dist/checks/adapter.d.ts +3 -0
  21. package/dist/checks/adapter.d.ts.map +1 -1
  22. package/dist/checks/applicability.d.ts.map +1 -1
  23. package/dist/checks/applicability.js +14 -2
  24. package/dist/checks/applicability.js.map +1 -1
  25. package/dist/checks/changed-file-paths.d.ts.map +1 -1
  26. package/dist/checks/changed-file-paths.js +7 -1
  27. package/dist/checks/changed-file-paths.js.map +1 -1
  28. package/dist/checks/closed-compiler-project.d.ts +5 -0
  29. package/dist/checks/closed-compiler-project.d.ts.map +1 -0
  30. package/dist/checks/closed-compiler-project.js +106 -0
  31. package/dist/checks/closed-compiler-project.js.map +1 -0
  32. package/dist/checks/comparison-context.d.ts +26 -0
  33. package/dist/checks/comparison-context.d.ts.map +1 -0
  34. package/dist/checks/comparison-context.js +187 -0
  35. package/dist/checks/comparison-context.js.map +1 -0
  36. package/dist/checks/compiler-inputs.d.ts +1 -1
  37. package/dist/checks/compiler-inputs.d.ts.map +1 -1
  38. package/dist/checks/compiler-inputs.js +39 -2
  39. package/dist/checks/compiler-inputs.js.map +1 -1
  40. package/dist/checks/complexity/adapter.d.ts.map +1 -1
  41. package/dist/checks/complexity/adapter.js +21 -2
  42. package/dist/checks/complexity/adapter.js.map +1 -1
  43. package/dist/checks/dead-code/adapter.d.ts.map +1 -1
  44. package/dist/checks/dead-code/adapter.js +16 -5
  45. package/dist/checks/dead-code/adapter.js.map +1 -1
  46. package/dist/checks/dead-code/entry-configuration.d.ts +6 -0
  47. package/dist/checks/dead-code/entry-configuration.d.ts.map +1 -0
  48. package/dist/checks/dead-code/entry-configuration.js +48 -0
  49. package/dist/checks/dead-code/entry-configuration.js.map +1 -0
  50. package/dist/checks/dead-code/managed-config.d.ts +1 -1
  51. package/dist/checks/dead-code/managed-config.d.ts.map +1 -1
  52. package/dist/checks/dead-code/managed-config.js +24 -3
  53. package/dist/checks/dead-code/managed-config.js.map +1 -1
  54. package/dist/checks/dead-code/vite-entrypoints.d.ts +13 -0
  55. package/dist/checks/dead-code/vite-entrypoints.d.ts.map +1 -0
  56. package/dist/checks/dead-code/vite-entrypoints.js +314 -0
  57. package/dist/checks/dead-code/vite-entrypoints.js.map +1 -0
  58. package/dist/checks/diagnostic-details.d.ts +28 -0
  59. package/dist/checks/diagnostic-details.d.ts.map +1 -0
  60. package/dist/checks/diagnostic-details.js +442 -0
  61. package/dist/checks/diagnostic-details.js.map +1 -0
  62. package/dist/checks/dispatch-cache.d.ts.map +1 -1
  63. package/dist/checks/dispatch-cache.js +64 -5
  64. package/dist/checks/dispatch-cache.js.map +1 -1
  65. package/dist/checks/dispatch-target.d.ts.map +1 -1
  66. package/dist/checks/dispatch-target.js +6 -0
  67. package/dist/checks/dispatch-target.js.map +1 -1
  68. package/dist/checks/dispatcher.d.ts.map +1 -1
  69. package/dist/checks/dispatcher.js +14 -2
  70. package/dist/checks/dispatcher.js.map +1 -1
  71. package/dist/checks/engine-identity.d.ts.map +1 -1
  72. package/dist/checks/engine-identity.js +9 -7
  73. package/dist/checks/engine-identity.js.map +1 -1
  74. package/dist/checks/eslint/convert-message.d.ts.map +1 -1
  75. package/dist/checks/eslint/convert-message.js +9 -3
  76. package/dist/checks/eslint/convert-message.js.map +1 -1
  77. package/dist/checks/eslint/lint-adapter.d.ts.map +1 -1
  78. package/dist/checks/eslint/lint-adapter.js +7 -0
  79. package/dist/checks/eslint/lint-adapter.js.map +1 -1
  80. package/dist/checks/eslint/managed-config.d.ts +3 -0
  81. package/dist/checks/eslint/managed-config.d.ts.map +1 -1
  82. package/dist/checks/eslint/managed-config.js +18 -3
  83. package/dist/checks/eslint/managed-config.js.map +1 -1
  84. package/dist/checks/eslint/project/adapter.d.ts +3 -0
  85. package/dist/checks/eslint/project/adapter.d.ts.map +1 -0
  86. package/dist/checks/eslint/project/adapter.js +143 -0
  87. package/dist/checks/eslint/project/adapter.js.map +1 -0
  88. package/dist/checks/eslint/project/diagnostics.d.ts +15 -0
  89. package/dist/checks/eslint/project/diagnostics.d.ts.map +1 -0
  90. package/dist/checks/eslint/project/diagnostics.js +38 -0
  91. package/dist/checks/eslint/project/diagnostics.js.map +1 -0
  92. package/dist/checks/eslint/project/engine.d.ts +5 -0
  93. package/dist/checks/eslint/project/engine.d.ts.map +1 -0
  94. package/dist/checks/eslint/project/engine.js +207 -0
  95. package/dist/checks/eslint/project/engine.js.map +1 -0
  96. package/dist/checks/eslint/project/installation.d.ts +3 -0
  97. package/dist/checks/eslint/project/installation.d.ts.map +1 -0
  98. package/dist/checks/eslint/project/installation.js +118 -0
  99. package/dist/checks/eslint/project/installation.js.map +1 -0
  100. package/dist/checks/eslint/project/protocol.d.ts +6 -0
  101. package/dist/checks/eslint/project/protocol.d.ts.map +1 -0
  102. package/dist/checks/eslint/project/protocol.js +90 -0
  103. package/dist/checks/eslint/project/protocol.js.map +1 -0
  104. package/dist/checks/eslint/project/trust.d.ts +18 -0
  105. package/dist/checks/eslint/project/trust.d.ts.map +1 -0
  106. package/dist/checks/eslint/project/trust.js +93 -0
  107. package/dist/checks/eslint/project/trust.js.map +1 -0
  108. package/dist/checks/eslint/project/types.d.ts +53 -0
  109. package/dist/checks/eslint/project/types.d.ts.map +1 -0
  110. package/dist/checks/eslint/project/types.js +24 -0
  111. package/dist/checks/eslint/project/types.js.map +1 -0
  112. package/dist/checks/eslint/project/worker.d.ts +2 -0
  113. package/dist/checks/eslint/project/worker.d.ts.map +1 -0
  114. package/dist/checks/eslint/project/worker.js +89 -0
  115. package/dist/checks/eslint/project/worker.js.map +1 -0
  116. package/dist/checks/eslint/project/workspace.d.ts +7 -0
  117. package/dist/checks/eslint/project/workspace.d.ts.map +1 -0
  118. package/dist/checks/eslint/project/workspace.js +100 -0
  119. package/dist/checks/eslint/project/workspace.js.map +1 -0
  120. package/dist/checks/eslint/rule-settings.d.ts.map +1 -1
  121. package/dist/checks/eslint/rule-settings.js +2 -2
  122. package/dist/checks/eslint/rule-settings.js.map +1 -1
  123. package/dist/checks/observation-result.d.ts.map +1 -1
  124. package/dist/checks/observation-result.js +89 -9
  125. package/dist/checks/observation-result.js.map +1 -1
  126. package/dist/checks/policy-scheduling.d.ts.map +1 -1
  127. package/dist/checks/policy-scheduling.js +6 -0
  128. package/dist/checks/policy-scheduling.js.map +1 -1
  129. package/dist/checks/prettier/settings.d.ts +2 -2
  130. package/dist/checks/project-inputs.d.ts +1 -1
  131. package/dist/checks/project-inputs.d.ts.map +1 -1
  132. package/dist/checks/project-inputs.js +10 -1
  133. package/dist/checks/project-inputs.js.map +1 -1
  134. package/dist/checks/react/accessibility-settings.d.ts +14 -0
  135. package/dist/checks/react/accessibility-settings.d.ts.map +1 -0
  136. package/dist/checks/react/accessibility-settings.js +37 -0
  137. package/dist/checks/react/accessibility-settings.js.map +1 -0
  138. package/dist/checks/react/adapter.d.ts.map +1 -1
  139. package/dist/checks/react/adapter.js +28 -3
  140. package/dist/checks/react/adapter.js.map +1 -1
  141. package/dist/checks/react/config.d.ts +2 -1
  142. package/dist/checks/react/config.d.ts.map +1 -1
  143. package/dist/checks/react/config.js +9 -3
  144. package/dist/checks/react/config.js.map +1 -1
  145. package/dist/checks/react/managed-accessibility-plugin.d.ts +21 -0
  146. package/dist/checks/react/managed-accessibility-plugin.d.ts.map +1 -0
  147. package/dist/checks/react/managed-accessibility-plugin.js +83 -0
  148. package/dist/checks/react/managed-accessibility-plugin.js.map +1 -0
  149. package/dist/checks/react/managed-hooks-identity.d.ts +3 -0
  150. package/dist/checks/react/managed-hooks-identity.d.ts.map +1 -0
  151. package/dist/checks/react/managed-hooks-identity.js +4 -0
  152. package/dist/checks/react/managed-hooks-identity.js.map +1 -0
  153. package/dist/checks/react/managed-hooks-plugin.d.ts +5 -0
  154. package/dist/checks/react/managed-hooks-plugin.d.ts.map +1 -0
  155. package/dist/checks/react/managed-hooks-plugin.js +45 -0
  156. package/dist/checks/react/managed-hooks-plugin.js.map +1 -0
  157. package/dist/checks/runner/executor.d.ts +2 -0
  158. package/dist/checks/runner/executor.d.ts.map +1 -1
  159. package/dist/checks/runner/executor.js +16 -0
  160. package/dist/checks/runner/executor.js.map +1 -1
  161. package/dist/checks/runner/protocol.d.ts.map +1 -1
  162. package/dist/checks/runner/protocol.js +8 -0
  163. package/dist/checks/runner/protocol.js.map +1 -1
  164. package/dist/checks/runner/run-job.d.ts +1 -0
  165. package/dist/checks/runner/run-job.d.ts.map +1 -1
  166. package/dist/checks/runner/run-job.js +8 -1
  167. package/dist/checks/runner/run-job.js.map +1 -1
  168. package/dist/checks/runner/worker-slot.d.ts.map +1 -1
  169. package/dist/checks/runner/worker-slot.js +17 -1
  170. package/dist/checks/runner/worker-slot.js.map +1 -1
  171. package/dist/checks/runner/worker.js +4 -1
  172. package/dist/checks/runner/worker.js.map +1 -1
  173. package/dist/checks/sanitize-result.d.ts +4 -0
  174. package/dist/checks/sanitize-result.d.ts.map +1 -1
  175. package/dist/checks/sanitize-result.js +45 -0
  176. package/dist/checks/sanitize-result.js.map +1 -1
  177. package/dist/checks/secrets/normalize.js +1 -1
  178. package/dist/checks/secrets/normalize.js.map +1 -1
  179. package/dist/checks/source-moves.d.ts +9 -0
  180. package/dist/checks/source-moves.d.ts.map +1 -0
  181. package/dist/checks/source-moves.js +184 -0
  182. package/dist/checks/source-moves.js.map +1 -0
  183. package/dist/checks/typescript/adapter.d.ts.map +1 -1
  184. package/dist/checks/typescript/adapter.js +2 -0
  185. package/dist/checks/typescript/adapter.js.map +1 -1
  186. package/dist/checks/typescript/compiler-host.d.ts.map +1 -1
  187. package/dist/checks/typescript/compiler-host.js +2 -0
  188. package/dist/checks/typescript/compiler-host.js.map +1 -1
  189. package/dist/checks/typescript/compiler-options-provenance.d.ts +4 -0
  190. package/dist/checks/typescript/compiler-options-provenance.d.ts.map +1 -0
  191. package/dist/checks/typescript/compiler-options-provenance.js +13 -0
  192. package/dist/checks/typescript/compiler-options-provenance.js.map +1 -0
  193. package/dist/checks/typescript/convert-diagnostic.d.ts.map +1 -1
  194. package/dist/checks/typescript/convert-diagnostic.js +4 -1
  195. package/dist/checks/typescript/convert-diagnostic.js.map +1 -1
  196. package/dist/checks/typescript/project-coverage.d.ts.map +1 -1
  197. package/dist/checks/typescript/project-coverage.js +19 -2
  198. package/dist/checks/typescript/project-coverage.js.map +1 -1
  199. package/dist/cli.d.ts.map +1 -1
  200. package/dist/cli.js +22 -0
  201. package/dist/cli.js.map +1 -1
  202. package/dist/commands/checks.d.ts.map +1 -1
  203. package/dist/commands/checks.js +12 -7
  204. package/dist/commands/checks.js.map +1 -1
  205. package/dist/commands/diagnostics.d.ts +1 -0
  206. package/dist/commands/diagnostics.d.ts.map +1 -1
  207. package/dist/commands/diagnostics.js +28 -0
  208. package/dist/commands/diagnostics.js.map +1 -1
  209. package/dist/commands/fix.d.ts.map +1 -1
  210. package/dist/commands/fix.js +4 -1
  211. package/dist/commands/fix.js.map +1 -1
  212. package/dist/commands/init.d.ts +4 -0
  213. package/dist/commands/init.d.ts.map +1 -1
  214. package/dist/commands/init.js +13 -0
  215. package/dist/commands/init.js.map +1 -1
  216. package/dist/commands/scan.d.ts +2 -1
  217. package/dist/commands/scan.d.ts.map +1 -1
  218. package/dist/commands/scan.js +10 -0
  219. package/dist/commands/scan.js.map +1 -1
  220. package/dist/config/immutable-configuration.d.ts +2 -0
  221. package/dist/config/immutable-configuration.d.ts.map +1 -0
  222. package/dist/config/immutable-configuration.js +81 -0
  223. package/dist/config/immutable-configuration.js.map +1 -0
  224. package/dist/config/load-config.d.ts.map +1 -1
  225. package/dist/config/load-config.js +8 -1
  226. package/dist/config/load-config.js.map +1 -1
  227. package/dist/config/profiles.d.ts.map +1 -1
  228. package/dist/config/profiles.js +30 -3
  229. package/dist/config/profiles.js.map +1 -1
  230. package/dist/config/schema.d.ts +152 -26
  231. package/dist/config/schema.d.ts.map +1 -1
  232. package/dist/config/schema.js +47 -3
  233. package/dist/config/schema.js.map +1 -1
  234. package/dist/config/settings-registry.d.ts +3 -1
  235. package/dist/config/settings-registry.d.ts.map +1 -1
  236. package/dist/config/settings-registry.js +9 -81
  237. package/dist/config/settings-registry.js.map +1 -1
  238. package/dist/config/target-policy.d.ts +4 -1
  239. package/dist/config/target-policy.d.ts.map +1 -1
  240. package/dist/config/target-policy.js +96 -0
  241. package/dist/config/target-policy.js.map +1 -1
  242. package/dist/core/types.d.ts +15 -0
  243. package/dist/core/types.d.ts.map +1 -1
  244. package/dist/diagnostics/scan-performance.d.ts +50 -0
  245. package/dist/diagnostics/scan-performance.d.ts.map +1 -0
  246. package/dist/diagnostics/scan-performance.js +153 -0
  247. package/dist/diagnostics/scan-performance.js.map +1 -0
  248. package/dist/doctor/diagnostics.d.ts +2 -1
  249. package/dist/doctor/diagnostics.d.ts.map +1 -1
  250. package/dist/doctor/diagnostics.js +5 -0
  251. package/dist/doctor/diagnostics.js.map +1 -1
  252. package/dist/doctor/project-eslint.d.ts +4 -0
  253. package/dist/doctor/project-eslint.d.ts.map +1 -0
  254. package/dist/doctor/project-eslint.js +98 -0
  255. package/dist/doctor/project-eslint.js.map +1 -0
  256. package/dist/hooks/command.d.ts.map +1 -1
  257. package/dist/hooks/command.js +2 -4
  258. package/dist/hooks/command.js.map +1 -1
  259. package/dist/hooks/husky.d.ts.map +1 -1
  260. package/dist/hooks/husky.js +7 -1
  261. package/dist/hooks/husky.js.map +1 -1
  262. package/dist/hooks/install.d.ts.map +1 -1
  263. package/dist/hooks/install.js +5 -0
  264. package/dist/hooks/install.js.map +1 -1
  265. package/dist/hooks/installed-command.d.ts +11 -0
  266. package/dist/hooks/installed-command.d.ts.map +1 -0
  267. package/dist/hooks/installed-command.js +36 -0
  268. package/dist/hooks/installed-command.js.map +1 -0
  269. package/dist/init/eslint-setup.d.ts +16 -0
  270. package/dist/init/eslint-setup.d.ts.map +1 -0
  271. package/dist/init/eslint-setup.js +98 -0
  272. package/dist/init/eslint-setup.js.map +1 -0
  273. package/dist/init/presentation.d.ts +9 -2
  274. package/dist/init/presentation.d.ts.map +1 -1
  275. package/dist/init/presentation.js +20 -0
  276. package/dist/init/presentation.js.map +1 -1
  277. package/dist/init/recommend.d.ts.map +1 -1
  278. package/dist/init/recommend.js +28 -0
  279. package/dist/init/recommend.js.map +1 -1
  280. package/dist/init/selection-policy.d.ts +4 -0
  281. package/dist/init/selection-policy.d.ts.map +1 -1
  282. package/dist/init/selection-policy.js +17 -0
  283. package/dist/init/selection-policy.js.map +1 -1
  284. package/dist/init/types.d.ts +14 -0
  285. package/dist/init/types.d.ts.map +1 -1
  286. package/dist/init/write-config.d.ts.map +1 -1
  287. package/dist/init/write-config.js +34 -0
  288. package/dist/init/write-config.js.map +1 -1
  289. package/dist/policy/evaluate.d.ts.map +1 -1
  290. package/dist/policy/evaluate.js +19 -4
  291. package/dist/policy/evaluate.js.map +1 -1
  292. package/dist/renderers/json.d.ts.map +1 -1
  293. package/dist/renderers/json.js +21 -0
  294. package/dist/renderers/json.js.map +1 -1
  295. package/dist/renderers/text.d.ts.map +1 -1
  296. package/dist/renderers/text.js +45 -7
  297. package/dist/renderers/text.js.map +1 -1
  298. package/dist/reporting/agent-guidance.d.ts +1 -0
  299. package/dist/reporting/agent-guidance.d.ts.map +1 -1
  300. package/dist/reporting/agent-guidance.js +25 -0
  301. package/dist/reporting/agent-guidance.js.map +1 -1
  302. package/dist/reporting/check-coverage.d.ts +9 -0
  303. package/dist/reporting/check-coverage.d.ts.map +1 -0
  304. package/dist/reporting/check-coverage.js +38 -0
  305. package/dist/reporting/check-coverage.js.map +1 -0
  306. package/dist/reporting/finding-priority.d.ts +6 -0
  307. package/dist/reporting/finding-priority.d.ts.map +1 -0
  308. package/dist/reporting/finding-priority.js +69 -0
  309. package/dist/reporting/finding-priority.js.map +1 -0
  310. package/dist/reporting/fix-plan-store.d.ts +2 -5
  311. package/dist/reporting/fix-plan-store.d.ts.map +1 -1
  312. package/dist/reporting/fix-plan-store.js +2 -1
  313. package/dist/reporting/fix-plan-store.js.map +1 -1
  314. package/dist/reporting/fix-presentation.d.ts +1 -1
  315. package/dist/reporting/presentation.d.ts +3 -1
  316. package/dist/reporting/presentation.d.ts.map +1 -1
  317. package/dist/reporting/presentation.js +19 -7
  318. package/dist/reporting/presentation.js.map +1 -1
  319. package/dist/reporting/project-eslint-notices.d.ts +3 -0
  320. package/dist/reporting/project-eslint-notices.d.ts.map +1 -0
  321. package/dist/reporting/project-eslint-notices.js +9 -0
  322. package/dist/reporting/project-eslint-notices.js.map +1 -0
  323. package/dist/reporting/report-callouts.d.ts +2 -2
  324. package/dist/reporting/report-callouts.d.ts.map +1 -1
  325. package/dist/reporting/report-callouts.js +5 -2
  326. package/dist/reporting/report-callouts.js.map +1 -1
  327. package/dist/reporting/result-sections.d.ts +1 -0
  328. package/dist/reporting/result-sections.d.ts.map +1 -1
  329. package/dist/reporting/result-sections.js +12 -0
  330. package/dist/reporting/result-sections.js.map +1 -1
  331. package/dist/reporting/source-identity.d.ts +1 -0
  332. package/dist/reporting/source-identity.d.ts.map +1 -1
  333. package/dist/reporting/source-identity.js +6 -0
  334. package/dist/reporting/source-identity.js.map +1 -1
  335. package/dist/reporting/temporary-report-common.d.ts +13 -1
  336. package/dist/reporting/temporary-report-common.d.ts.map +1 -1
  337. package/dist/reporting/temporary-report-common.js +4 -1
  338. package/dist/reporting/temporary-report-common.js.map +1 -1
  339. package/dist/reporting/temporary-report-lifecycle.d.ts +3 -3
  340. package/dist/reporting/temporary-report-lifecycle.d.ts.map +1 -1
  341. package/dist/reporting/temporary-report-lifecycle.js +18 -4
  342. package/dist/reporting/temporary-report-lifecycle.js.map +1 -1
  343. package/dist/reporting/temporary-reports.d.ts +1 -1
  344. package/dist/reporting/temporary-reports.d.ts.map +1 -1
  345. package/dist/reporting/temporary-reports.js +22 -3
  346. package/dist/reporting/temporary-reports.js.map +1 -1
  347. package/dist/scan/analysis-session.d.ts +3 -0
  348. package/dist/scan/analysis-session.d.ts.map +1 -1
  349. package/dist/scan/analysis-session.js +28 -1
  350. package/dist/scan/analysis-session.js.map +1 -1
  351. package/dist/scan/change-summary.d.ts +9 -0
  352. package/dist/scan/change-summary.d.ts.map +1 -0
  353. package/dist/scan/change-summary.js +7 -0
  354. package/dist/scan/change-summary.js.map +1 -0
  355. package/dist/scan/incomplete-report.d.ts +2 -0
  356. package/dist/scan/incomplete-report.d.ts.map +1 -1
  357. package/dist/scan/incomplete-report.js +3 -0
  358. package/dist/scan/incomplete-report.js.map +1 -1
  359. package/dist/scan/merge-scan.d.ts.map +1 -1
  360. package/dist/scan/merge-scan.js +2 -1
  361. package/dist/scan/merge-scan.js.map +1 -1
  362. package/dist/scan/report.d.ts +2 -0
  363. package/dist/scan/report.d.ts.map +1 -1
  364. package/dist/scan/run-scan.d.ts +3 -0
  365. package/dist/scan/run-scan.d.ts.map +1 -1
  366. package/dist/scan/run-scan.js +57 -3
  367. package/dist/scan/run-scan.js.map +1 -1
  368. package/dist/scan/source-excerpts.d.ts.map +1 -1
  369. package/dist/scan/source-excerpts.js +7 -0
  370. package/dist/scan/source-excerpts.js.map +1 -1
  371. package/dist/service/client-connection.js +1 -1
  372. package/dist/service/client-connection.js.map +1 -1
  373. package/dist/service/client-executor.d.ts.map +1 -1
  374. package/dist/service/client-executor.js +35 -2
  375. package/dist/service/client-executor.js.map +1 -1
  376. package/dist/service/server-connection.d.ts.map +1 -1
  377. package/dist/service/server-connection.js +11 -2
  378. package/dist/service/server-connection.js.map +1 -1
  379. package/dist/telemetry/client.d.ts +5 -1
  380. package/dist/telemetry/client.d.ts.map +1 -1
  381. package/dist/telemetry/client.js +20 -3
  382. package/dist/telemetry/client.js.map +1 -1
  383. package/dist/telemetry/details-store.d.ts +8 -4
  384. package/dist/telemetry/details-store.d.ts.map +1 -1
  385. package/dist/telemetry/details-store.js +28 -5
  386. package/dist/telemetry/details-store.js.map +1 -1
  387. package/dist/telemetry/performance-summary.d.ts +7 -0
  388. package/dist/telemetry/performance-summary.d.ts.map +1 -0
  389. package/dist/telemetry/performance-summary.js +49 -0
  390. package/dist/telemetry/performance-summary.js.map +1 -0
  391. package/dist/telemetry/schema.d.ts +813 -166
  392. package/dist/telemetry/schema.d.ts.map +1 -1
  393. package/dist/telemetry/schema.js +78 -0
  394. package/dist/telemetry/schema.js.map +1 -1
  395. package/dist/telemetry/state.d.ts +12 -12
  396. package/dist/ui/init-app.d.ts.map +1 -1
  397. package/dist/ui/init-app.js +41 -1
  398. package/dist/ui/init-app.js.map +1 -1
  399. package/dist/ui/init-view.d.ts.map +1 -1
  400. package/dist/ui/init-view.js +14 -4
  401. package/dist/ui/init-view.js.map +1 -1
  402. package/dist/ui/outcome-strip.d.ts.map +1 -1
  403. package/dist/ui/outcome-strip.js +7 -3
  404. package/dist/ui/outcome-strip.js.map +1 -1
  405. package/dist/ui/scan-app.d.ts.map +1 -1
  406. package/dist/ui/scan-app.js +2 -1
  407. package/dist/ui/scan-app.js.map +1 -1
  408. package/dist/ui/scan-result-dashboard.d.ts.map +1 -1
  409. package/dist/ui/scan-result-dashboard.js +7 -6
  410. package/dist/ui/scan-result-dashboard.js.map +1 -1
  411. package/dist/vendor/react-hooks/7.1.1/LICENSE +21 -0
  412. package/dist/vendor/react-hooks/7.1.1/development.cjs +55824 -0
  413. package/dist/vendor/react-hooks/7.1.1/index.cjs +2 -0
  414. package/dist/vendor/react-hooks/7.1.1/production.cjs +55649 -0
  415. package/dist/vendor/react-hooks/7.1.1/provenance.json +26 -0
  416. package/docs/checks.md +213 -4
  417. package/docs/cli-reference.md +28 -1
  418. package/docs/privacy.md +31 -1
  419. package/docs/react-analysis.md +66 -0
  420. package/docs/reporting.md +52 -1
  421. package/docs/support.md +23 -0
  422. package/{node_modules/dependency-cruiser/node_modules/picomatch/LICENSE → licenses/overrides/jscpd-5.4.2-LICENSE} +5 -5
  423. package/licenses/overrides/napi-rs-wasm-runtime-1.2.5-LICENSE +43 -0
  424. package/licenses/reviewed-overrides.json +70 -0
  425. package/node_modules/acorn/CHANGELOG.md +14 -0
  426. package/node_modules/acorn/dist/acorn.js +42 -14
  427. package/node_modules/acorn/dist/acorn.mjs +42 -14
  428. package/node_modules/acorn/package.json +1 -1
  429. package/node_modules/dependency-cruiser/README.md +7 -8
  430. package/node_modules/dependency-cruiser/bin/depcruise-baseline.mjs +12 -5
  431. package/node_modules/dependency-cruiser/bin/{dependency-cruise.mjs → dependency-cruiser.mjs} +24 -14
  432. package/node_modules/dependency-cruiser/configs/rules/no-duplicate-dependency-types.cjs +1 -1
  433. package/node_modules/dependency-cruiser/node_modules/ignore/README.md +138 -8
  434. package/node_modules/dependency-cruiser/node_modules/ignore/index.d.ts +56 -20
  435. package/node_modules/dependency-cruiser/node_modules/ignore/index.js +1032 -229
  436. package/node_modules/dependency-cruiser/node_modules/ignore/legacy.js +868 -184
  437. package/node_modules/dependency-cruiser/node_modules/ignore/package.json +10 -4
  438. package/node_modules/dependency-cruiser/node_modules/semver/LICENSE +15 -0
  439. package/node_modules/dependency-cruiser/node_modules/semver/README.md +680 -0
  440. package/node_modules/dependency-cruiser/node_modules/semver/bin/semver.js +195 -0
  441. package/node_modules/dependency-cruiser/node_modules/semver/classes/comparator.js +143 -0
  442. package/node_modules/dependency-cruiser/node_modules/semver/classes/index.js +7 -0
  443. package/node_modules/dependency-cruiser/node_modules/semver/classes/range.js +577 -0
  444. package/node_modules/dependency-cruiser/node_modules/semver/classes/semver.js +350 -0
  445. package/node_modules/dependency-cruiser/node_modules/semver/functions/clean.js +8 -0
  446. package/node_modules/dependency-cruiser/node_modules/semver/functions/cmp.js +54 -0
  447. package/node_modules/dependency-cruiser/node_modules/semver/functions/coerce.js +62 -0
  448. package/node_modules/dependency-cruiser/node_modules/semver/functions/compare-build.js +9 -0
  449. package/node_modules/dependency-cruiser/node_modules/semver/functions/compare-loose.js +5 -0
  450. package/node_modules/dependency-cruiser/node_modules/semver/functions/compare.js +7 -0
  451. package/node_modules/dependency-cruiser/node_modules/semver/functions/diff.js +60 -0
  452. package/node_modules/dependency-cruiser/node_modules/semver/functions/eq.js +5 -0
  453. package/node_modules/dependency-cruiser/node_modules/semver/functions/gt.js +5 -0
  454. package/node_modules/dependency-cruiser/node_modules/semver/functions/gte.js +5 -0
  455. package/node_modules/dependency-cruiser/node_modules/semver/functions/inc.js +21 -0
  456. package/node_modules/dependency-cruiser/node_modules/semver/functions/lt.js +5 -0
  457. package/node_modules/dependency-cruiser/node_modules/semver/functions/lte.js +5 -0
  458. package/node_modules/dependency-cruiser/node_modules/semver/functions/major.js +5 -0
  459. package/node_modules/dependency-cruiser/node_modules/semver/functions/minor.js +5 -0
  460. package/node_modules/dependency-cruiser/node_modules/semver/functions/neq.js +5 -0
  461. package/node_modules/dependency-cruiser/node_modules/semver/functions/parse.js +18 -0
  462. package/node_modules/dependency-cruiser/node_modules/semver/functions/patch.js +5 -0
  463. package/node_modules/dependency-cruiser/node_modules/semver/functions/prerelease.js +8 -0
  464. package/node_modules/dependency-cruiser/node_modules/semver/functions/rcompare.js +5 -0
  465. package/node_modules/dependency-cruiser/node_modules/semver/functions/rsort.js +5 -0
  466. package/node_modules/dependency-cruiser/node_modules/semver/functions/satisfies.js +12 -0
  467. package/node_modules/dependency-cruiser/node_modules/semver/functions/sort.js +5 -0
  468. package/node_modules/dependency-cruiser/node_modules/semver/functions/truncate.js +48 -0
  469. package/node_modules/dependency-cruiser/node_modules/semver/functions/valid.js +8 -0
  470. package/node_modules/dependency-cruiser/node_modules/semver/index.js +93 -0
  471. package/node_modules/dependency-cruiser/node_modules/semver/internal/constants.js +67 -0
  472. package/node_modules/dependency-cruiser/node_modules/semver/internal/debug.js +11 -0
  473. package/node_modules/dependency-cruiser/node_modules/semver/internal/identifiers.js +29 -0
  474. package/node_modules/dependency-cruiser/node_modules/semver/internal/lrucache.js +42 -0
  475. package/node_modules/dependency-cruiser/node_modules/semver/internal/parse-options.js +17 -0
  476. package/node_modules/dependency-cruiser/node_modules/semver/internal/re.js +223 -0
  477. package/node_modules/dependency-cruiser/node_modules/semver/internal/trim-comparator-whitespace.js +438 -0
  478. package/node_modules/dependency-cruiser/node_modules/semver/package.json +78 -0
  479. package/node_modules/dependency-cruiser/node_modules/semver/preload.js +4 -0
  480. package/node_modules/dependency-cruiser/node_modules/semver/range.bnf +17 -0
  481. package/node_modules/dependency-cruiser/node_modules/semver/ranges/gtr.js +6 -0
  482. package/node_modules/dependency-cruiser/node_modules/semver/ranges/intersects.js +9 -0
  483. package/node_modules/dependency-cruiser/node_modules/semver/ranges/ltr.js +6 -0
  484. package/node_modules/dependency-cruiser/node_modules/semver/ranges/max-satisfying.js +27 -0
  485. package/node_modules/dependency-cruiser/node_modules/semver/ranges/min-satisfying.js +26 -0
  486. package/node_modules/dependency-cruiser/node_modules/semver/ranges/min-version.js +63 -0
  487. package/node_modules/dependency-cruiser/node_modules/semver/ranges/outside.js +82 -0
  488. package/node_modules/dependency-cruiser/node_modules/semver/ranges/simplify.js +49 -0
  489. package/node_modules/dependency-cruiser/node_modules/semver/ranges/subset.js +249 -0
  490. package/node_modules/dependency-cruiser/node_modules/semver/ranges/to-comparators.js +10 -0
  491. package/node_modules/dependency-cruiser/node_modules/semver/ranges/valid.js +13 -0
  492. package/node_modules/dependency-cruiser/package.json +16 -10
  493. package/node_modules/dependency-cruiser/src/analyze/analyze-modules.mjs +5 -1
  494. package/node_modules/dependency-cruiser/src/analyze/index.mjs +3 -3
  495. package/node_modules/dependency-cruiser/src/analyze/soften-known-violations.mjs +4 -2
  496. package/node_modules/dependency-cruiser/src/analyze/summarize/get-stats.mjs +38 -3
  497. package/node_modules/dependency-cruiser/src/analyze/summarize/index.mjs +28 -105
  498. package/node_modules/dependency-cruiser/src/analyze/summarize/summarize-options.mjs +3 -0
  499. package/node_modules/dependency-cruiser/src/analyze/summarize/verify-environment.mjs +146 -0
  500. package/node_modules/dependency-cruiser/src/cache/cache.mjs +1 -1
  501. package/node_modules/dependency-cruiser/src/cache/options-compatible.mjs +3 -0
  502. package/node_modules/dependency-cruiser/src/cli/defaults.mjs +0 -1
  503. package/node_modules/dependency-cruiser/src/cli/index.mjs +11 -3
  504. package/node_modules/dependency-cruiser/src/cli/init-config/build-config.mjs +14 -0
  505. package/node_modules/dependency-cruiser/src/cli/init-config/config-template.mjs +7 -2
  506. package/node_modules/dependency-cruiser/src/cli/init-config/environment-helpers.mjs +5 -1
  507. package/node_modules/dependency-cruiser/src/cli/init-config/get-user-input.mjs +11 -0
  508. package/node_modules/dependency-cruiser/src/cli/init-config/index.mjs +1 -0
  509. package/node_modules/dependency-cruiser/src/cli/init-config/normalize-init-options.mjs +1 -1
  510. package/node_modules/dependency-cruiser/src/cli/init-config/types.d.mts +4 -0
  511. package/node_modules/dependency-cruiser/src/cli/init-config/write-run-scripts-to-manifest.mjs +7 -7
  512. package/node_modules/dependency-cruiser/src/cli/normalize-cli-options.mjs +63 -2
  513. package/node_modules/dependency-cruiser/src/config-utl/extract-ts-config.mjs +1 -1
  514. package/node_modules/dependency-cruiser/src/extract/helpers.mjs +1 -0
  515. package/node_modules/dependency-cruiser/src/extract/resolve/determine-dependency-types.mjs +15 -7
  516. package/node_modules/dependency-cruiser/src/extract/resolve/merge-manifests.mjs +6 -3
  517. package/node_modules/dependency-cruiser/src/extract/swc/dependency-visitor.mjs +21 -4
  518. package/node_modules/dependency-cruiser/src/extract/swc/parse.mjs +14 -4
  519. package/node_modules/dependency-cruiser/src/extract/transpile/index.mjs +1 -1
  520. package/node_modules/dependency-cruiser/src/extract/transpile/meta.mjs +15 -3
  521. package/node_modules/dependency-cruiser/src/extract/transpile/svelte-wrap.mjs +23 -2
  522. package/node_modules/dependency-cruiser/src/extract/transpile/try-import-available.mjs +2 -2
  523. package/node_modules/dependency-cruiser/src/extract/transpile/typescript-wrap.mjs +23 -1
  524. package/node_modules/dependency-cruiser/src/extract/tsc/extract-typescript-deps.mjs +57 -12
  525. package/node_modules/dependency-cruiser/src/extract/tsc/extract.mjs +2 -0
  526. package/node_modules/dependency-cruiser/src/graph-utl/add-focus.mjs +2 -2
  527. package/node_modules/dependency-cruiser/src/graph-utl/compare.mjs +113 -14
  528. package/node_modules/dependency-cruiser/src/main/cruise.mjs +1 -2
  529. package/node_modules/dependency-cruiser/src/main/format.mjs +1 -1
  530. package/node_modules/dependency-cruiser/src/main/options/defaults.mjs +1 -0
  531. package/node_modules/dependency-cruiser/src/main/options/normalize.mjs +13 -4
  532. package/node_modules/dependency-cruiser/src/main/report-wrap.mjs +4 -2
  533. package/node_modules/dependency-cruiser/src/main/resolve-options/normalize.mjs +0 -27
  534. package/node_modules/dependency-cruiser/src/meta.cjs +1 -1
  535. package/node_modules/dependency-cruiser/src/report/anon/index.mjs +1 -1
  536. package/node_modules/dependency-cruiser/src/report/azure-devops.mjs +15 -11
  537. package/node_modules/dependency-cruiser/src/report/baseline.mjs +67 -10
  538. package/node_modules/dependency-cruiser/src/report/csv.mjs +1 -1
  539. package/node_modules/dependency-cruiser/src/report/dot/index.mjs +1 -1
  540. package/node_modules/dependency-cruiser/src/report/dot-webpage/dot-module.mjs +1 -1
  541. package/node_modules/dependency-cruiser/src/report/error-html/error-html-template.mjs +2 -0
  542. package/node_modules/dependency-cruiser/src/report/error-html/index.mjs +84 -8
  543. package/node_modules/dependency-cruiser/src/report/error.mjs +62 -13
  544. package/node_modules/dependency-cruiser/src/report/html/index.mjs +1 -1
  545. package/node_modules/dependency-cruiser/src/report/index.mjs +3 -2
  546. package/node_modules/dependency-cruiser/src/report/markdown.mjs +89 -19
  547. package/node_modules/dependency-cruiser/src/report/metrics.mjs +3 -3
  548. package/node_modules/dependency-cruiser/src/report/null.mjs +6 -3
  549. package/node_modules/dependency-cruiser/src/report/teamcity.mjs +4 -1
  550. package/node_modules/dependency-cruiser/src/schema/configuration.validate.mjs +1 -1
  551. package/node_modules/dependency-cruiser/src/schema/cruise-result.validate.mjs +1 -1
  552. package/node_modules/dependency-cruiser/src/utl/try-import.mjs +1 -1
  553. package/node_modules/dependency-cruiser/types/cruise-result.d.mts +14 -0
  554. package/node_modules/dependency-cruiser/types/dependency-cruiser.d.mts +6 -0
  555. package/node_modules/dependency-cruiser/types/options.d.mts +37 -2
  556. package/node_modules/dependency-cruiser/types/reporter-options.d.mts +30 -5
  557. package/node_modules/dependency-cruiser/types/restrictions.d.mts +2 -2
  558. package/node_modules/dependency-cruiser/types/shared-types.d.mts +16 -13
  559. package/node_modules/enhanced-resolve/README.md +46 -1
  560. package/node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js +31 -6
  561. package/node_modules/enhanced-resolve/lib/ImportsFieldPlugin.js +27 -6
  562. package/node_modules/enhanced-resolve/lib/PackageMapPlugin.js +297 -0
  563. package/node_modules/enhanced-resolve/lib/Resolver.js +37 -30
  564. package/node_modules/enhanced-resolve/lib/ResolverFactory.js +104 -11
  565. package/node_modules/enhanced-resolve/lib/getPaths.js +6 -1
  566. package/node_modules/enhanced-resolve/lib/index.js +4 -0
  567. package/node_modules/enhanced-resolve/lib/util/entrypoints.js +104 -0
  568. package/node_modules/enhanced-resolve/lib/util/graceful-fs-browser.js +5 -1
  569. package/node_modules/enhanced-resolve/lib/util/identifier.js +4 -2
  570. package/node_modules/enhanced-resolve/lib/util/packageMap.js +224 -0
  571. package/node_modules/enhanced-resolve/lib/util/path.js +29 -8
  572. package/node_modules/enhanced-resolve/lib/util/pathToFileURL.js +87 -0
  573. package/node_modules/enhanced-resolve/package.json +8 -9
  574. package/node_modules/enhanced-resolve/types/AliasFieldPlugin.d.ts +41 -0
  575. package/node_modules/enhanced-resolve/types/AliasPlugin.d.ts +32 -0
  576. package/node_modules/enhanced-resolve/types/AliasUtils.d.ts +128 -0
  577. package/node_modules/enhanced-resolve/types/AppendPlugin.d.ts +27 -0
  578. package/node_modules/enhanced-resolve/types/CachedInputFileSystem.d.ts +224 -0
  579. package/node_modules/enhanced-resolve/types/CloneBasenamePlugin.d.ts +24 -0
  580. package/node_modules/enhanced-resolve/types/ConditionalPlugin.d.ts +33 -0
  581. package/node_modules/enhanced-resolve/types/DescriptionFilePlugin.d.ts +30 -0
  582. package/node_modules/enhanced-resolve/types/DescriptionFileUtils.d.ts +83 -0
  583. package/node_modules/enhanced-resolve/types/DirectoryExistsPlugin.d.ts +23 -0
  584. package/node_modules/enhanced-resolve/types/ExportsFieldPlugin.d.ts +45 -0
  585. package/node_modules/enhanced-resolve/types/ExtensionAliasPlugin.d.ts +31 -0
  586. package/node_modules/enhanced-resolve/types/FileExistsPlugin.d.ts +23 -0
  587. package/node_modules/enhanced-resolve/types/ImportsFieldPlugin.d.ts +45 -0
  588. package/node_modules/enhanced-resolve/types/JoinRequestPartPlugin.d.ts +24 -0
  589. package/node_modules/enhanced-resolve/types/JoinRequestPlugin.d.ts +24 -0
  590. package/node_modules/enhanced-resolve/types/LogInfoPlugin.d.ts +18 -0
  591. package/node_modules/enhanced-resolve/types/MainFieldPlugin.d.ts +41 -0
  592. package/node_modules/enhanced-resolve/types/ModulesInHierachicDirectoriesPlugin.d.ts +2 -0
  593. package/node_modules/enhanced-resolve/types/ModulesInHierarchicalDirectoriesPlugin.d.ts +26 -0
  594. package/node_modules/enhanced-resolve/types/ModulesInRootPlugin.d.ts +27 -0
  595. package/node_modules/enhanced-resolve/types/ModulesUtils.d.ts +25 -0
  596. package/node_modules/enhanced-resolve/types/NextPlugin.d.ts +23 -0
  597. package/node_modules/enhanced-resolve/types/PackageMapPlugin.d.ts +85 -0
  598. package/node_modules/enhanced-resolve/types/ParsePlugin.d.ts +27 -0
  599. package/node_modules/enhanced-resolve/types/PnpPlugin.d.ts +42 -0
  600. package/node_modules/enhanced-resolve/types/Resolver.d.ts +1545 -0
  601. package/node_modules/enhanced-resolve/types/ResolverFactory.d.ts +340 -0
  602. package/node_modules/enhanced-resolve/types/RestrictionsPlugin.d.ts +52 -0
  603. package/node_modules/enhanced-resolve/types/ResultPlugin.d.ts +18 -0
  604. package/node_modules/enhanced-resolve/types/RootsPlugin.d.ts +30 -0
  605. package/node_modules/enhanced-resolve/types/SelfReferencePlugin.d.ts +31 -0
  606. package/node_modules/enhanced-resolve/types/SymlinkPlugin.d.ts +24 -0
  607. package/node_modules/enhanced-resolve/types/SyncAsyncFileSystemDecorator.d.ts +52 -0
  608. package/node_modules/enhanced-resolve/types/TryNextPlugin.d.ts +26 -0
  609. package/node_modules/enhanced-resolve/types/TsconfigPathsPlugin.d.ts +204 -0
  610. package/node_modules/enhanced-resolve/types/UnsafeCachePlugin.d.ts +43 -0
  611. package/node_modules/enhanced-resolve/types/UseFilePlugin.d.ts +27 -0
  612. package/node_modules/enhanced-resolve/types/createInnerContext.d.ts +10 -0
  613. package/node_modules/enhanced-resolve/types/forEachBail.d.ts +15 -0
  614. package/node_modules/enhanced-resolve/types/getInnerRequest.d.ts +7 -0
  615. package/node_modules/enhanced-resolve/types/getPaths.d.ts +34 -0
  616. package/node_modules/enhanced-resolve/types/index.d.ts +131 -0
  617. package/node_modules/enhanced-resolve/types/util/entrypoints.d.ts +62 -0
  618. package/node_modules/enhanced-resolve/types/util/fileURLToPath.d.ts +14 -0
  619. package/node_modules/enhanced-resolve/types/util/fs.d.ts +38 -0
  620. package/node_modules/enhanced-resolve/types/util/graceful-fs-browser.d.ts +22 -0
  621. package/node_modules/enhanced-resolve/types/util/identifier.d.ts +7 -0
  622. package/node_modules/enhanced-resolve/types/util/memoize.d.ts +15 -0
  623. package/node_modules/enhanced-resolve/types/util/module-browser.d.ts +1 -0
  624. package/node_modules/enhanced-resolve/types/util/packageMap.d.ts +118 -0
  625. package/node_modules/enhanced-resolve/types/util/path-browser.d.ts +45 -0
  626. package/node_modules/enhanced-resolve/types/util/path.d.ts +125 -0
  627. package/node_modules/enhanced-resolve/types/util/pathToFileURL.d.ts +14 -0
  628. package/node_modules/enhanced-resolve/types/util/process-browser.d.ts +3 -0
  629. package/node_modules/enhanced-resolve/types/util/strip-json-comments.d.ts +24 -0
  630. package/node_modules/enhanced-resolve/types/util/url-browser.d.ts +1 -0
  631. package/node_modules/enhanced-resolve/types.d.ts +5 -2057
  632. package/node_modules/is-installed-globally/index.js +26 -4
  633. package/node_modules/is-installed-globally/package.json +1 -1
  634. package/package.json +12 -6
  635. package/plugins/swarm/references/scan.md +2 -0
  636. package/schema/zedbee.schema.json +146 -3
  637. package/node_modules/dependency-cruiser/node_modules/picomatch/README.md +0 -743
  638. package/node_modules/dependency-cruiser/node_modules/picomatch/index.js +0 -17
  639. package/node_modules/dependency-cruiser/node_modules/picomatch/lib/constants.js +0 -184
  640. package/node_modules/dependency-cruiser/node_modules/picomatch/lib/parse.js +0 -1416
  641. package/node_modules/dependency-cruiser/node_modules/picomatch/lib/picomatch.js +0 -361
  642. package/node_modules/dependency-cruiser/node_modules/picomatch/lib/scan.js +0 -391
  643. package/node_modules/dependency-cruiser/node_modules/picomatch/lib/utils.js +0 -72
  644. package/node_modules/dependency-cruiser/node_modules/picomatch/package.json +0 -83
  645. package/node_modules/dependency-cruiser/node_modules/picomatch/posix.js +0 -3
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
 
3
- var _TRAILING_WILD_CARD_R;
4
3
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
5
4
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
5
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
6
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
9
10
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
11
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
11
12
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12
13
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
13
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
15
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
16
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
15
  // A simple implementation of make-array
18
16
  function makeArray(subject) {
19
17
  return Array.isArray(subject) ? subject : [subject];
@@ -22,8 +20,14 @@ var UNDEFINED = undefined;
22
20
  var EMPTY = '';
23
21
  var SPACE = ' ';
24
22
  var ESCAPE = '\\';
25
- var REGEX_TEST_BLANK_LINE = /^\s+$/;
23
+
24
+ // The characters that carry a meaning of their own inside a regular
25
+ // expression, so a literal one has to be escaped before it is emitted.
26
+ var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
27
+ var BOM = "\uFEFF";
26
28
  var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
29
+ // A run of two or more asterisks is a globstar (#175)
30
+ var REGEX_ANCHORED_GLOBSTAR = /^\/\*{2,}$/;
27
31
  var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
28
32
  var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
29
33
  var REGEX_SPLITALL_CRLF = /\r?\n/g;
@@ -36,8 +40,9 @@ var REGEX_SPLITALL_CRLF = /\r?\n/g;
36
40
  // - ..
37
41
  // Valid:
38
42
  // - .foo
39
- var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
40
- var REGEX_TEST_TRAILING_SLASH = /\/$/;
43
+ var DOUBLE_SLASH = '//';
44
+ var SLASH_CODE = 47;
45
+ var DOT_CODE = 46;
41
46
  var SLASH = '/';
42
47
 
43
48
  // Do not use ternary expression here, since "istanbul ignore next" is buggy
@@ -53,37 +58,295 @@ var define = function define(object, key, value) {
53
58
  });
54
59
  return value;
55
60
  };
56
- var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
57
61
  var RETURN_FALSE = function RETURN_FALSE() {
58
62
  return false;
59
63
  };
60
64
 
61
- // Sanitize the range of a regular expression
62
- // The cases are complicated, see test cases for details
63
- var sanitizeRange = function sanitizeRange(range) {
64
- return range.replace(REGEX_REGEXP_RANGE, function (match, from, to) {
65
- return from.charCodeAt(0) <= to.charCodeAt(0) ? match
66
- // Invalid range (out of order) which is ok for gitignore rules but
67
- // fatal for JavaScript regular expression, so eliminate it.
68
- : EMPTY;
69
- });
65
+ // > The range notation, e.g. [a-zA-Z],
66
+ // > can be used to match one of the characters in a range.
67
+ //
68
+ // gitignore(5) defers to fnmatch(3) for this, and git implements it in
69
+ // `wildmatch.c`. A bracket expression has a sub-grammar of its own, which
70
+ // is neither the surrounding pattern grammar nor the JavaScript one:
71
+ //
72
+ // - a `]` right after `[` or `[!` is a literal member, not the terminator
73
+ // - `[:alpha:]` names one of twelve POSIX classes
74
+ // - `\` escapes the next member, `]` included
75
+ // - `*`, `?` and `.` are plain literal members
76
+ // - an unterminated expression makes the whole pattern match nothing
77
+ //
78
+ // which means the expression can not be located -- let alone translated -- by
79
+ // a regular expression. It is scanned out of the pattern before the
80
+ // replacers below run, and put back once they are done, so that neither the
81
+ // metacharacter escaper nor the `?` / `*` replacers ever see its body.
82
+
83
+ // git classifies with its own ASCII-only ctype macros (`wildmatch.c`), never
84
+ // with the C library ones, so these must not be mapped onto `\d` / `\w` /
85
+ // `\s`, which are wider. `/` is left out of every expansion, because a
86
+ // bracket expression never matches a path separator.
87
+ var POSIX_CLASSES = {
88
+ alnum: '0-9A-Za-z',
89
+ alpha: 'A-Za-z',
90
+ blank: ' \\t',
91
+ cntrl: '\\x00-\\x1f\\x7f',
92
+ digit: '0-9',
93
+ graph: '!-.0-~',
94
+ lower: 'a-z',
95
+ print: ' -.0-~',
96
+ punct: '!-.:-@\\[-`{-~',
97
+ // git's `sane-ctype.h` classifies \v and \f as control, not space,
98
+ // unlike C's `isspace`
99
+ space: ' \\t\\n\\r',
100
+ upper: 'A-Z',
101
+ xdigit: '0-9A-Fa-f'
102
+ };
103
+ var CLASS_MEMBERS_TO_ESCAPE = '\\]^-[';
104
+ var escapeMember = function escapeMember(_char) {
105
+ return CLASS_MEMBERS_TO_ESCAPE.indexOf(_char) < 0 ? _char : ESCAPE + _char;
106
+ };
107
+
108
+ // > if (matched == negated || ((flags & WM_PATHNAME) && text_ch == '/'))
109
+ // > return WM_ABORT_TO_STARSTAR; (git, `wildmatch.c`)
110
+ // A bracket expression never matches a path separator, whatever its members
111
+ // say, so a negated class gets `/` as one more excluded character, while a
112
+ // plain one -- where a literal member or a range could still let `/` in --
113
+ // is guarded with a lookahead, `/` being impossible to subtract from a
114
+ // JavaScript character class.
115
+ var NON_SLASH = '(?!\\/)';
116
+ var classSource = function classSource(negated, body) {
117
+ if (negated) {
118
+ return "[^\\/".concat(body, "]");
119
+ }
120
+ var source = "[".concat(body, "]");
121
+ return new RegExp(source).test('/') ? NON_SLASH + source : source;
122
+ };
123
+
124
+ // Scan the bracket expression that starts at `pattern[start] === '['`,
125
+ // mirroring the member loop of git's `wildmatch.c`.
126
+ // @returns {{end: number, source: string} | null} `null` if the expression is
127
+ // never terminated, which makes the whole pattern match nothing.
128
+ var scanBracket = function scanBracket(pattern, start) {
129
+ var length = pattern.length;
130
+ var index = start + 1;
131
+ var negated = EMPTY;
132
+ var lead = pattern[index];
133
+ if (lead === '!' || lead === '^') {
134
+ negated = '^';
135
+ index++;
136
+ }
137
+ var body = EMPTY;
138
+
139
+ // The member a `-` could start a range from, or EMPTY when the previous
140
+ // member can not open one (start of the body, or a range / POSIX class
141
+ // that has just closed)
142
+ var prev = EMPTY;
143
+
144
+ // git scans the members with a do-while, so the first one is consumed
145
+ // unconditionally. That is the whole reason a leading `]` is a member
146
+ // and not the terminator.
147
+ for (;;) {
148
+ var _char2 = pattern[index];
149
+ if (_char2 === UNDEFINED) {
150
+ return null;
151
+ }
152
+ if (_char2 === ESCAPE) {
153
+ var escaped = pattern[index + 1];
154
+ if (escaped === UNDEFINED) {
155
+ return null;
156
+ }
157
+ body += escapeMember(escaped);
158
+ prev = escaped;
159
+ index++;
160
+ } else if (_char2 === '-' && prev && index + 1 < length && pattern[index + 1] !== ']') {
161
+ index++;
162
+ var to = pattern[index];
163
+ if (to === ESCAPE) {
164
+ // A pattern can not end on a lone backslash -- `checkPattern` has
165
+ // already thrown it away -- so there is an upper bound to read.
166
+ to = pattern[index += 1];
167
+ }
168
+ // An out-of-order range matches nothing in git but is a syntax error in
169
+ // JavaScript, so it is dropped. Its lower bound stays: git tests it
170
+ // as a plain member before it ever looks at the `-`, so `[c-a]` does
171
+ // match `c`.
172
+ if (prev <= to) {
173
+ body += "-".concat(escapeMember(to));
174
+ }
175
+ prev = EMPTY;
176
+ } else if (_char2 === '[' && pattern[index + 1] === ':') {
177
+ var nameStart = index + 2;
178
+ var end = nameStart;
179
+ while (end < length && pattern[end] !== ']') {
180
+ end++;
181
+ }
182
+ if (end === length) {
183
+ return null;
184
+ }
185
+ if (end > nameStart && pattern[end - 1] === ':') {
186
+ var name = pattern.slice(nameStart, end - 1);
187
+
188
+ // An unknown class name makes the whole pattern match nothing
189
+ if (!Object.prototype.hasOwnProperty.call(POSIX_CLASSES, name)) {
190
+ return null;
191
+ }
192
+ body += POSIX_CLASSES[name];
193
+ prev = EMPTY;
194
+ index = end;
195
+ } else {
196
+ // No `:]` to close it, so the `[` is a plain member and scanning
197
+ // resumes right after it.
198
+ body += escapeMember('[');
199
+ prev = '[';
200
+ index = nameStart - 2;
201
+ }
202
+ } else {
203
+ body += escapeMember(_char2);
204
+ prev = _char2;
205
+ }
206
+ index++;
207
+ if (pattern[index] === ']') {
208
+ return {
209
+ end: index,
210
+ source: classSource(negated, body)
211
+ };
212
+ }
213
+ }
70
214
  };
71
215
 
72
- // > An optional `!` or `^` at the start of a class negates it, so that it
73
- // > matches any character not in the set. (gitignore(5), fnmatch(3))
74
- // The leading `^` has already been escaped to `\^` by the metacharacter
75
- // escaper, so we strip the literal `!` or escaped `^` and emit a single
76
- // regex `^` which is the JavaScript negation token.
77
- var negateRange = function negateRange(range) {
78
- return range.startsWith('!') || range.startsWith('\\^') ? "^".concat(range.slice(range[0] === '!' ? 1 : 2)) : range;
216
+ // An empty JavaScript class can never match, which is how a pattern that git
217
+ // gives up on (`WM_ABORT_ALL`) is expressed here.
218
+ var NEVER_MATCH = '[]';
219
+
220
+ // A NUL can appear in neither a `.gitignore` line nor a path, which makes it
221
+ // the one safe placeholder character. A literal one in the pattern is
222
+ // held aside all the same, so a collision is impossible by construction.
223
+ var PLACEHOLDER = "\0";
224
+ var REGEX_RESTORE_PLACEHOLDER = new RegExp("".concat(PLACEHOLDER, "(\\d+)").concat(PLACEHOLDER), 'g');
225
+
226
+ // The one wildcard the chain does not expand for itself is a trailing `*`. How
227
+ // it expands depends on the mode (`regex` vs `checkRegex`), so `_make` is
228
+ // left to do it, and until then the pending wildcard travels as this marker.
229
+ // That is what keeps it apart from a user-escaped literal `\*`: the unescape
230
+ // steps collapse the escaped one to the exact `\*` a wildcard would leave
231
+ // behind, so by the time `_make` runs the two are otherwise the same string
232
+ // and a literal star gets wrongly rewritten into a wildcard. The marker is a
233
+ // private-use character, and `extractBrackets` keeps one that came out of the
234
+ // pattern apart from it, so the only marker `_make` ever turns back into a
235
+ // real wildcard is the one this chain put there itself.
236
+ var TRAILING_WILDCARD = "\uE000";
237
+
238
+ // A trailing "/**" is deferred the same way, because `checkRegex` has to tell
239
+ // it apart from a trailing "/*" (see `checkSourceOf`). For `.ignores()` it
240
+ // still never matches the folder itself (#21).
241
+ var TRAILING_DOUBLESTAR = "\uE001";
242
+
243
+ // The three characters above mean something to the chain that builds the
244
+ // source rather than to the path, so one that came out of the pattern is
245
+ // held aside like a bracket expression instead of going straight out. Being
246
+ // held is what makes it safe: the restore runs after the step that anchors
247
+ // the source, so the character comes back in the middle of the source and
248
+ // not at its end, which is the one place `_make` and `checkSourceOf` look
249
+ // for a marker. Without it a pattern's own character lands where a pending
250
+ // marker sits, and `_make` turns it into a real trailing wildcard.
251
+ //
252
+ // It is held as a one-member class rather than bare, in both of the branches
253
+ // a reserved character can reach, so that the property can be
254
+ // read off this function alone -- a reserved character never goes out on
255
+ // its own -- rather than depending on where in the chain the restore
256
+ // happens to run. In the expression built here `[x]` matches exactly what
257
+ // `x` matches, none of the three being special to a regular expression or
258
+ // inside a class, so no test can tell the two apart: the class is insurance,
259
+ // and the paragraph above is the reason it is not needed.
260
+ var isReserved = function isReserved(_char3) {
261
+ return _char3 === PLACEHOLDER || _char3 === TRAILING_WILDCARD || _char3 === TRAILING_DOUBLESTAR;
79
262
  };
80
263
 
81
- // See fixtures #59
82
- var cleanRangeBackSlash = function cleanRangeBackSlash(slashes) {
83
- var length = slashes.length;
84
- return slashes.slice(0, length - length % 2);
264
+ // Replace every bracket expression with a placeholder the replacers below
265
+ // leave alone, and translate it separately.
266
+ var extractBrackets = function extractBrackets(pattern) {
267
+ var sources = [];
268
+ var hold = function hold(source) {
269
+ return "".concat(PLACEHOLDER).concat(sources.push(source) - 1).concat(PLACEHOLDER);
270
+ };
271
+ var length = pattern.length;
272
+ var out = EMPTY;
273
+ var index = 0;
274
+ while (index < length) {
275
+ var _char4 = pattern[index];
276
+ if (_char4 === ESCAPE) {
277
+ // > Put a backslash ("\") in front of ... a character to make it literal.
278
+ // (gitignore(5) -> fnmatch(3))
279
+ // A backslash quotes the next character, whatever it is, so `\d` is a
280
+ // literal `d`, not the regex digit class, and `\?` is a literal `?`,
281
+ // not a wildcard. Held aside as its literal here, the escape never
282
+ // reaches the replacers below, which would otherwise let `\d`, `\b`,
283
+ // `\1`, `\/` keep their regular-expression meaning, and would turn a
284
+ // `\?` into `[^\/]`.
285
+ //
286
+ // Three escapes are still left for the chain: `\*` (a literal star,
287
+ // told apart from a wildcard by `TRAILING_WILDCARD` and the wildcard
288
+ // replacers), `\[` (a literal bracket, the one `[` the bracket
289
+ // replacer still expects), and `\ ` (a quoted space, which one pass
290
+ // below rewrites in bulk -- holding each one aside instead costs more
291
+ // on a pattern built out of them). A lone trailing backslash can reach
292
+ // here after line-ending cleanup.
293
+ //
294
+ // A quoted backslash is not among them. The chain doubles every
295
+ // backslash, then takes the doubling back out again, and a quoted one
296
+ // standing next to a character the chain also escapes left the two
297
+ // counts sharing a run, so one of the escapes was lost. Held here as
298
+ // the literal it means, it never joins that run.
299
+ var escaped = pattern[index + 1];
300
+ if (escaped === UNDEFINED || escaped === SLASH && index + 2 === length) {
301
+ // Git removes a final directory slash before matching. An escape
302
+ // without a character after that removal makes the pattern invalid.
303
+ out += hold(NEVER_MATCH);
304
+ } else if (escaped === '*' || escaped === '[' || escaped === SPACE) {
305
+ out += pattern.slice(index, index + 2);
306
+ } else {
307
+ out += hold(REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : isReserved(escaped) ? "[".concat(escaped, "]") : escaped);
308
+ }
309
+ index += 2;
310
+ } else if (isReserved(_char4)) {
311
+ out += hold("[".concat(_char4, "]"));
312
+ index++;
313
+ } else if (_char4 === '[') {
314
+ var scanned = scanBracket(pattern, index);
315
+ if (scanned === null) {
316
+ // git gives up on the whole pattern (`WM_ABORT_ALL`), so whatever
317
+ // follows can not make it match either.
318
+ out += hold(NEVER_MATCH);
319
+ index = length;
320
+ } else {
321
+ out += hold(scanned.source);
322
+ index = scanned.end + 1;
323
+ }
324
+ } else {
325
+ out += _char4;
326
+ index++;
327
+ }
328
+ }
329
+ return {
330
+ source: out,
331
+ sources: sources
332
+ };
85
333
  };
86
334
 
335
+ // A step of the chain below is normally a `[matcher, replacer]` pair handed
336
+ // to `String.replace`. `DIRECT` marks the ones that are plain string work
337
+ // instead, and take `(source, pattern)`.
338
+ //
339
+ // Anchoring the two ends is exactly that -- a test of one character and a
340
+ // concatenation -- and putting it through the regular expression engine
341
+ // cost a third of this chain for nothing: 167ns where 10ns does the same
342
+ // job. The two are still steps in the same list, in the same places,
343
+ // because their position in the order is part of what they mean.
344
+ var DIRECT = null;
345
+
346
+ // A separator at the beginning or in the middle of a pattern, as opposed to
347
+ // one at the very end.
348
+ var REGEX_INNER_SLASH = /\/(?!$)/;
349
+
87
350
  // > If the pattern ends with a slash,
88
351
  // > it is removed for the purpose of the following description,
89
352
  // > but it would only find a match with a directory.
@@ -95,30 +358,48 @@ var cleanRangeBackSlash = function cleanRangeBackSlash(slashes) {
95
358
  // you could use option `mark: true` with `glob`
96
359
 
97
360
  // '`foo/`' should not continue with the '`..`'
98
- var REPLACERS = [[
99
- // Remove BOM
100
- // TODO:
101
- // Other similar zero-width characters?
102
- /^\uFEFF/, function () {
103
- return EMPTY;
104
- }],
105
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
106
- [
107
- // (a\ ) -> (a )
108
- // (a ) -> (a)
109
- // (a ) -> (a)
110
- // (a \ ) -> (a )
111
- /((?:\\\\)*?)(\\?\s+)$/, function (_, m1, m2) {
112
- return m1 + (m2.indexOf('\\') === 0 ? SPACE : EMPTY);
113
- }],
361
+ // The chain that turns one gitignore pattern into a regular expression
362
+ // source, in order. A step is either
363
+ //
364
+ // [matcher, replacer] handed to `String.replace`
365
+ // [matcher, replacer, required] the same, but skipped outright unless
366
+ // `required` appears in the string, which
367
+ // the matcher cannot match without
368
+ // [DIRECT, transform] plain string work, taking (source, pattern)
369
+ //
370
+ // The `required` character is only ever a shortcut: finding it does not mean
371
+ // the matcher will match, and not finding it means it cannot. It is there
372
+ // because scanning for one character costs a fraction of running a matcher
373
+ // that then finds nothing -- for the wildcard step, whose `[^\\]+`
374
+ // backtracks its way through the whole string before giving up, 11ns
375
+ // against 400ns.
376
+ var REPLACERS = [
114
377
  // Replace (\ ) with ' '
378
+ // Only a space: an escaped tab or other whitespace is already a literal by
379
+ // the time it reaches here, and a bare tab must be left as one, not turned
380
+ // into a space.
115
381
  // (\ ) -> ' '
116
382
  // (\\ ) -> '\\ '
117
383
  // (\\\ ) -> '\\ '
118
- [/(\\+?)\s/g, function (_, m1) {
119
- var length = m1.length;
120
- return m1.slice(0, length - length % 2) + SPACE;
121
- }],
384
+ [
385
+ // A run of backslashes is taken whole, from its first one, so no match
386
+ // ever starts again inside it -- `(\\+?) ` did, which made a long run
387
+ // quadratic.
388
+ /(\\+)( ?)/g, function (_, run, space) {
389
+ return space ? run.slice(0, run.length - run.length % 2) + SPACE : run;
390
+ }, ESCAPE + SPACE],
391
+ // git's wildmatch() reads a run of two or more asterisks as one globstar
392
+ // whenever the run fills a path segment: it starts the pattern or follows
393
+ // a `/`, and it ends the pattern or comes before a `/`. A run of two is
394
+ // already `**`; a longer one is folded into `**` here, so the steps
395
+ // below only ever have to know `**`.
396
+ // `***/foo` -> `**/foo`, `a/***/b` -> `a/**/b`, `a/***` -> `a/**`
397
+ // git also takes a run beside a literal prefix (`a***/b`) or beside an
398
+ // escaped slash (`***\/b`) as a globstar, and this does not; the README
399
+ // lists both, under "A run of asterisks".
400
+ [/(^|\/)\*{3,}(?=\/|$)/g, function (_, start) {
401
+ return "".concat(start, "**");
402
+ }, '*'],
122
403
  // Escape metacharacters
123
404
  // which is written down by users but means special for regular expressions.
124
405
 
@@ -142,7 +423,7 @@ var REPLACERS = [[
142
423
  // > a question mark (?) matches a single character
143
424
  /(?!\\)\?/g, function () {
144
425
  return '[^/]';
145
- }],
426
+ }, '?'],
146
427
  // leading slash
147
428
  [
148
429
  // > A leading slash matches the beginning of the pathname.
@@ -150,11 +431,11 @@ var REPLACERS = [[
150
431
  // A leading slash matches the beginning of the pathname
151
432
  /^\//, function () {
152
433
  return '^';
153
- }],
434
+ }, SLASH],
154
435
  // replace special metacharacter slash after the leading slash
155
436
  [/\//g, function () {
156
437
  return '\\/';
157
- }], [
438
+ }, SLASH], [
158
439
  // > A leading "**" followed by a slash means match in all directories.
159
440
  // > For example, "**/foo" matches file or directory "foo" anywhere,
160
441
  // > the same as pattern "foo".
@@ -165,15 +446,20 @@ var REPLACERS = [[
165
446
  // '**/foo' <-> 'foo'
166
447
  function () {
167
448
  return '^(?:.*\\/)?';
168
- }],
449
+ }, '*'],
169
450
  // starting
170
451
  [
171
452
  // there will be no leading '/'
172
453
  // (which has been replaced by section "leading slash")
173
454
  // If starts with '**', adding a '^' to the regular expression also works
174
- /^(?=[^^])/, function startingReplacer() {
455
+ DIRECT, function (source, pattern) {
456
+ // Nothing to anchor to, or already anchored
457
+ if (!source || source[0] === '^') {
458
+ return source;
459
+ }
460
+
175
461
  // If has a slash `/` at the beginning or middle
176
- return !/\/(?!$)/.test(this)
462
+ var anchor = !REGEX_INNER_SLASH.test(pattern)
177
463
  // > Prior to 2.22.1
178
464
  // > If the pattern does not contain a slash /,
179
465
  // > Git treats it as a shell glob pattern
@@ -191,6 +477,7 @@ function () {
191
477
  // > Otherwise, Git treats the pattern as a shell glob suitable for
192
478
  // > consumption by fnmatch(3)
193
479
  : '^';
480
+ return anchor + source;
194
481
  }],
195
482
  // two globstars
196
483
  [
@@ -203,19 +490,27 @@ function () {
203
490
  function (_, index, str) {
204
491
  return index + 6 < str.length
205
492
 
493
+ // case: /**/ at the end of the pattern, i.e. a trailing `'/**/'`
494
+ // > A trailing `"/**/"` (a trailing `"/**"` restricted to directories)
495
+ // > matches everything inside, but it should not match the current
496
+ // > folder itself, so it requires at least one directory segment.
497
+ // 'a/**/' matches 'a/b/', 'a/x/y/' but not 'a/'
498
+ ? str.slice(index + 6) === '\\/' ? '(?:\\/[^\\/]+)+'
499
+
206
500
  // case: /**/
207
501
  // > A slash followed by two consecutive asterisks then a slash matches
208
502
  // > zero or more directories.
209
503
  // > For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
210
504
  // '/**/'
211
- ? '(?:\\/[^\\/]+)*'
505
+ : '(?:\\/[^\\/]+)*'
212
506
 
213
507
  // case: /**
214
508
  // > A trailing `"/**"` matches everything inside.
215
509
 
216
- // #21: everything inside but it should not include the current folder
217
- : '\\/.+';
218
- }],
510
+ // #21: everything inside but it should not include the current folder,
511
+ // resolved by `_make`
512
+ : "\\/".concat(TRAILING_DOUBLESTAR);
513
+ }, '*'],
219
514
  // normal intermediate wildcards
220
515
  [
221
516
  // Never replace escaped '*'
@@ -235,37 +530,54 @@ function (_, p1, p2) {
235
530
  // > and will match according to the previous rules.
236
531
  var unescaped = p2.replace(/\\\*/g, '[^\\/]*');
237
532
  return p1 + unescaped;
238
- }], [
533
+ }, '*'],
534
+ // trailing wildcard, held apart from a literal star
535
+ [
536
+ // The step above leaves a trailing `*` alone, so a single `\*` is all that
537
+ // can be left at the end here, and what stands in front of it says which
538
+ // kind it is. A wildcard arrives as the escaper wrote it, `\*` with
539
+ // nothing before it; a literal arrives as the user's own escape, which
540
+ // the escaper doubled, and then the star's own -- `\\` and then `\*`.
541
+ // There is no third case: every backslash still reaching the chain is
542
+ // one `\*`, `\[` or `\ ` carries itself, and each is followed by its
543
+ // own character, so a longer run can never form. This runs while the
544
+ // two are still distinct, before the unescape steps below collapse the
545
+ // literal onto the very `\*` a wildcard leaves behind.
546
+ /(^|[^\\])((?:\\\\)*)\\\*$/, function (match, p1, p2) {
547
+ return p2 === EMPTY
548
+ // A real wildcard: carry it to `_make` as the marker, so the unescape
549
+ // steps and the trailing-wildcard rewrite can never mistake it for a
550
+ // literal `\*` (nor the reverse).
551
+ ? p1 + TRAILING_WILDCARD
552
+ // A literal star: leave it exactly as it stands for the unescape steps.
553
+ : match;
554
+ }, '*'], [
239
555
  // unescape, revert step 3 except for back slash
240
556
  // For example, if a user escape a '\\*',
241
557
  // after step 3, the result will be '\\\\\\*'
242
558
  /\\\\\\(?=[$.|*+(){^])/g, function () {
243
559
  return ESCAPE;
244
- }], [
560
+ }, ESCAPE + ESCAPE], [
245
561
  // '\\\\' -> '\\'
246
562
  /\\\\/g, function () {
247
563
  return ESCAPE;
248
- }], [
249
- // > The range notation, e.g. [a-zA-Z],
250
- // > can be used to match one of the characters in a range.
564
+ }, ESCAPE + ESCAPE], [
565
+ // Every real bracket expression -- POSIX classes included -- has already
566
+ // been held aside by `extractBrackets`, so the only `[` left in the
567
+ // pattern is an escaped, literal one.
251
568
 
252
- // `\` is escaped by step 3
253
- /(\\)?\[([^\]/]*?)(\\*)($|\])/g, function (match, leadEscape, range, endEscape, close) {
254
- return leadEscape === ESCAPE
255
- // '\\[bar]' -> '\\\\[bar\\]'
256
- ? "\\[".concat(range).concat(cleanRangeBackSlash(endEscape)).concat(close) : close === ']' ? endEscape.length % 2 === 0
257
- // A normal case, and it is a range notation
258
- // '[bar]'
259
- // '[bar\\\\]'
260
- ? "[".concat(negateRange(sanitizeRange(range))).concat(endEscape, "]") // Invalid range notaton
261
- // '[bar\\]' -> '[bar\\\\]'
262
- : '[]' : '[]';
263
- }],
569
+ // A backslash could only stand at the end of the range if it quoted the
570
+ // `]`, and `\]` is held aside long before this.
571
+ /\\\[([^\]/]*?)($|\])/g,
572
+ // '\\[bar]' -> '\\\\[bar]'
573
+ function (match, range, close) {
574
+ return "\\[".concat(range).concat(close);
575
+ }, '['],
264
576
  // ending
265
577
  [
266
578
  // 'js' will not match 'js.'
267
579
  // 'ab' will not match 'abc'
268
- /(?:[^*])$/,
580
+ DIRECT,
269
581
  // WTF!
270
582
  // https://git-scm.com/docs/gitignore
271
583
  // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
@@ -278,17 +590,26 @@ function (_, p1, p2) {
278
590
  // 'js*' will not match 'a.js'
279
591
  // 'js/' will not match 'a.js'
280
592
  // 'js' will match 'a.js' and 'a.js/'
281
- function (match) {
282
- return /\/$/.test(match)
593
+ function (source) {
594
+ var last = source[source.length - 1];
595
+
596
+ // The pattern is empty, or ends in a pending marker `_make` owns --
597
+ // the trailing wildcard, or a trailing "/**". A trailing `*` that is
598
+ // not the marker is a literal star, which anchors like any other
599
+ // final character.
600
+ if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
601
+ return source;
602
+ }
603
+ return last === SLASH
283
604
  // foo/ will not match 'foo'
284
- ? "".concat(match, "$") // foo matches 'foo' and 'foo/'
285
- : "".concat(match, "(?=$|\\/$)");
605
+ ? "".concat(source, "$") // foo matches 'foo' and 'foo/'
606
+ : "".concat(source, "(?=$|\\/$)");
286
607
  }]];
287
- var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
608
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
288
609
  var MODE_IGNORE = 'regex';
289
610
  var MODE_CHECK_IGNORE = 'checkRegex';
290
611
  var UNDERSCORE = '_';
291
- var TRAILING_WILD_CARD_REPLACERS = (_TRAILING_WILD_CARD_R = {}, _defineProperty(_TRAILING_WILD_CARD_R, MODE_IGNORE, function (_, p1) {
612
+ var replaceTrailingWildcard = function replaceTrailingWildcard(_, p1) {
292
613
  var prefix = p1
293
614
  // '\^':
294
615
  // '/*' does not match EMPTY
@@ -300,36 +621,268 @@ var TRAILING_WILD_CARD_REPLACERS = (_TRAILING_WILD_CARD_R = {}, _defineProperty(
300
621
  // 'a*' matches 'aa'
301
622
  : '[^/]*';
302
623
  return "".concat(prefix, "(?=$|\\/$)");
303
- }), _defineProperty(_TRAILING_WILD_CARD_R, MODE_CHECK_IGNORE, function (_, p1) {
304
- // When doing `git check-ignore`
305
- var prefix = p1
306
- // '\\\/':
307
- // 'abc/*' DOES match 'abc/' !
308
- ? "".concat(p1, "[^/]*") // 'a*' matches 'a'
309
- // 'a*' matches 'aa'
310
- : '[^/]*';
311
- return "".concat(prefix, "(?=$|\\/$)");
312
- }), _TRAILING_WILD_CARD_R);
624
+ };
625
+ var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
626
+
627
+ // 'abc/**' matches everything under 'abc', but not 'abc/' itself (#21)
628
+ var replaceTrailingDoublestar = function replaceTrailingDoublestar() {
629
+ return '.+(?=$|\\/$)';
630
+ };
631
+ var WILDCARD = '[^\\/]*';
632
+
633
+ // The fixed piece between the wildcard at `at` and the next wildcard of the
634
+ // run: the tokens that separate them, joined as they appear in the source.
635
+ // A run never holds two wildcards in a row, so there is always at least one
636
+ // token.
637
+ var separatorAfter = function separatorAfter(run, at) {
638
+ var separator = EMPTY;
639
+ for (var index = at + 1; index < run.length && !run[index].wildcard; index++) {
640
+ separator += run[index].single;
641
+ }
642
+ return separator;
643
+ };
644
+
645
+ // Where a run of non-slash wildcards is split by fixed pieces --
646
+ // `[^/]*ab[^/]*cd...` -- the engine has many equivalent ways to lay the
647
+ // input across the wildcards, and on input that does not match it works
648
+ // through all of them, so the time grows with the number of wildcards
649
+ // rather than the length of the path. Every wildcard but the last in such a
650
+ // run can be pinned to stop where the piece after it begins, which leaves
651
+ // one way to lay out the input and no rewinding, without changing which
652
+ // paths match: the fixed pieces still bound the count, and the last
653
+ // wildcard still absorbs the rest.
654
+ //
655
+ // A wildcard is pinned to the whole piece, never to the piece's first
656
+ // character. The pin leaves no way back, so a wildcard that stopped at that
657
+ // first character would hand over wherever the character happens to turn
658
+ // up, including the places the rest of the piece cannot follow -- which is
659
+ // how `f*o/*/*` came to miss `foo/b/c`, the first `o` of `foo` not being
660
+ // the one the `o/` after it needs. Every token of a piece matches exactly
661
+ // one character, so the first place the whole piece fits is the leftmost
662
+ // place it can sit, and whatever is left over goes to the wildcards that
663
+ // follow.
664
+ //
665
+ // The source is read one token at a time -- a wildcard, a single-character
666
+ // piece (a literal, an escape, a class), or a parenthesised group or anchor
667
+ // that ends the run -- so only a genuine wildcard is touched.
668
+ var pinWildcards = function pinWildcards(source) {
669
+ if (source.indexOf(WILDCARD) < 0) {
670
+ return source;
671
+ }
672
+ var tokens = [];
673
+ var length = source.length;
674
+ var index = 0;
675
+ while (index < length) {
676
+ var _char5 = source[index];
677
+ if (source.startsWith(WILDCARD, index)) {
678
+ tokens.push({
679
+ wildcard: true
680
+ });
681
+ index += WILDCARD.length;
682
+ } else if (_char5 === '[') {
683
+ var end = index + 1;
684
+ if (source[end] === '^') {
685
+ end++;
686
+ }
687
+ if (source[end] === ']') {
688
+ end++;
689
+ }
690
+ while (end < length && source[end] !== ']') {
691
+ end += source[end] === ESCAPE ? 2 : 1;
692
+ }
693
+ end++;
694
+ tokens.push({
695
+ single: source.slice(index, end)
696
+ });
697
+ index = end;
698
+ } else if (_char5 === ESCAPE) {
699
+ tokens.push({
700
+ single: source.slice(index, index + 2)
701
+ });
702
+ index += 2;
703
+ } else if (_char5 === '(') {
704
+ var depth = 0;
705
+ var _end = index;
706
+ do {
707
+ if (source[_end] === ESCAPE) {
708
+ _end++;
709
+ } else if (source[_end] === '(') {
710
+ depth++;
711
+ } else if (source[_end] === ')') {
712
+ depth--;
713
+ }
714
+ _end++;
715
+ } while (_end < length && depth > 0);
716
+ if ('*+?'.indexOf(source[_end]) >= 0) {
717
+ _end++;
718
+ }
719
+ tokens.push({
720
+ boundary: source.slice(index, _end)
721
+ });
722
+ index = _end;
723
+ } else if (_char5 === '^' || _char5 === '$') {
724
+ tokens.push({
725
+ boundary: _char5
726
+ });
727
+ index++;
728
+ } else {
729
+ tokens.push({
730
+ single: _char5
731
+ });
732
+ index++;
733
+ }
734
+ }
735
+ var out = EMPTY;
736
+ var run = [];
737
+ var flush = function flush() {
738
+ var lastWildcard;
739
+ run.forEach(function (token, at) {
740
+ if (token.wildcard) {
741
+ lastWildcard = at;
742
+ }
743
+ });
744
+ run.forEach(function (token, at) {
745
+ if (!token.wildcard) {
746
+ out += token.single;
747
+ return;
748
+ }
749
+
750
+ // Every wildcard but the last is pinned to the whole piece that
751
+ // follows it, for the reason set out above this function. The last
752
+ // one stays as it is and takes up the rest.
753
+ out += at === lastWildcard ? WILDCARD : "(?:(?!".concat(separatorAfter(run, at), ")[^\\/])*");
754
+ });
755
+ run = [];
756
+ };
757
+ tokens.forEach(function (token) {
758
+ if (token.boundary === undefined) {
759
+ run.push(token);
760
+ return;
761
+ }
762
+ flush();
763
+ out += token.boundary;
764
+ });
765
+ flush();
766
+ return out;
767
+ };
313
768
 
314
769
  // @param {pattern}
315
770
  var makeRegexPrefix = function makeRegexPrefix(pattern) {
316
- return REPLACERS.reduce(function (prev, _ref) {
317
- var _ref2 = _slicedToArray(_ref, 2),
771
+ // `/**` matches every path, as `**` does. The translation below only finds
772
+ // a globstar beside a slash it keeps, and the leading one is turned into
773
+ // an anchor, so `/**` would come out as `/*` and match one level only.
774
+ // Here rather than in `createRule`, so that `checkSourceOf`, which
775
+ // compiles `/**/` again without its trailing slash, gets it too.
776
+ if (REGEX_ANCHORED_GLOBSTAR.test(pattern)) {
777
+ pattern = '**';
778
+ }
779
+ var _extractBrackets = extractBrackets(pattern),
780
+ source = _extractBrackets.source,
781
+ sources = _extractBrackets.sources;
782
+ var replaced = REPLACERS.reduce(
783
+ // A pass whose matcher finds nothing hands back the very string it was
784
+ // given, so asking first costs a search and saves a rewrite. Ten of the
785
+ // fifteen passes never fire for a typical .gitignore line, and between
786
+ // them they were 45% of this chain.
787
+ function (prev, _ref) {
788
+ var _ref2 = _slicedToArray(_ref, 3),
318
789
  matcher = _ref2[0],
319
- replacer = _ref2[1];
320
- return prev.replace(matcher, replacer.bind(pattern));
321
- }, pattern);
790
+ replacer = _ref2[1],
791
+ required = _ref2[2];
792
+ if (matcher === DIRECT) {
793
+ return replacer(prev, pattern);
794
+ }
795
+ if (required !== UNDEFINED && prev.indexOf(required) < 0) {
796
+ return prev;
797
+ }
798
+
799
+ // A pass whose matcher finds nothing hands back the very string it was
800
+ // given, so asking first costs a search and saves a rewrite.
801
+ return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
802
+ }, source);
803
+
804
+ // Most patterns hold no bracket expression at all, and then there is
805
+ // nothing to put back.
806
+ return sources.length ? replaced.replace(REGEX_RESTORE_PLACEHOLDER, function (match, index) {
807
+ return sources[index];
808
+ }) : replaced;
809
+ };
810
+
811
+ // `checkRegex` tests a path with a trailing slash, 'abc/', the way
812
+ // `git check-ignore` matches that literal string once the directory itself
813
+ // is known not to be excluded (see `checkIgnore`): a trailing '/' of the
814
+ // pattern is dropped, a basename pattern sees an empty basename, and only a
815
+ // pattern whose last segment is a pending wildcard can match what is left
816
+ // after the final slash -- 'abc/*' and 'abc/**' match 'abc/', and 'abc/**'
817
+ // also matches 'abc/d/' (#77, #169).
818
+ var checkSourceOf = function checkSourceOf(body, prefix) {
819
+ if (body[body.length - 1] === SLASH) {
820
+ prefix = makeRegexPrefix(body.slice(0, -1));
821
+ }
822
+ var head = prefix.slice(0, -1);
823
+ var last = prefix[prefix.length - 1];
824
+ return last === TRAILING_WILDCARD ? "".concat(head, "$") : last === TRAILING_DOUBLESTAR ? "".concat(head, ".*$") : NEVER_MATCH;
825
+ };
826
+
827
+ // A trailing slash does not stop a pattern being basename-only: it restricts
828
+ // the match to a directory, it does not let the pattern reach across one.
829
+ // Everything else a pattern can hold -- a wildcard, a character class, an
830
+ // escape -- stays inside a single path segment too, so a pattern with no
831
+ // separator in it can only ever describe the last one.
832
+ var matchesBasename = function matchesBasename(body) {
833
+ var index = body.indexOf(SLASH);
834
+ return index < 0 || index === body.length - 1;
835
+ };
836
+
837
+ // The last segment of a path, keeping a trailing slash, because a pattern that
838
+ // ends in one matches only a directory.
839
+ // 'a/b/c.js' -> 'c.js'; 'a/b/' -> 'b/'; 'c.js' -> 'c.js' (no copy made)
840
+ var basenameOf = function basenameOf(path) {
841
+ var end = path.length - 1;
842
+ var index = path.lastIndexOf(SLASH, path[end] === SLASH ? end - 1 : end);
843
+ return index < 0 ? path : path.slice(index + 1);
844
+ };
845
+
846
+ // The parent directory of a path, with its trailing separator, or EMPTY when
847
+ // the path has none.
848
+ // 'a/b/c' -> 'a/b/'; 'a/b/' -> 'a/'; 'a' -> EMPTY; 'a/' -> EMPTY
849
+ //
850
+ // A path holding an empty segment has to be taken apart, because its
851
+ // ancestors are not prefixes of it: the parent of 'a//b' is 'a/', not
852
+ // 'a//', and the parent of '/a/' is nothing at all. Both shapes reach here
853
+ // -- 'a//b' is accepted outright, and `checkIgnore` does not put the path
854
+ // it is given through the relative-path check.
855
+ //
856
+ // Every other path is a prefix of itself, and cutting one costs a fraction of
857
+ // splitting it into an array and joining that back at every level: 73ns
858
+ // against 207ns.
859
+ var parentOf = function parentOf(path) {
860
+ if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
861
+ var slices = path.split(SLASH).filter(Boolean);
862
+ slices.pop();
863
+ return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
864
+ }
865
+ var end = path.length - 1;
866
+
867
+ // Look back from before a trailing separator, since that one belongs to the
868
+ // path itself.
869
+ //
870
+ // A negative place to start would be a trap here: `lastIndexOf` clamps one
871
+ // to 0 and searches there rather than reporting no match, so '/' would
872
+ // come back as its own parent and the walk would never end. It cannot
873
+ // happen -- that is the only path short enough to produce one, and the
874
+ // test above has already sent it the other way.
875
+ var cut = path.lastIndexOf(SLASH, path.charCodeAt(end) === SLASH_CODE ? end - 1 : end);
876
+ return cut < 0 ? EMPTY : path.slice(0, cut + 1);
322
877
  };
323
878
  var isString = function isString(subject) {
324
879
  return typeof subject === 'string';
325
880
  };
326
881
 
327
- // > A blank line matches no files, so it can serve as a separator for readability.
882
+ // Blank lines and comments are told by `createRule`, once the pattern is
883
+ // normalized.
328
884
  var checkPattern = function checkPattern(pattern) {
329
- return pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern)
330
-
331
- // > A line starting with # serves as a comment.
332
- && pattern.indexOf('#') !== 0;
885
+ return pattern && isString(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern);
333
886
  };
334
887
  var splitPattern = function splitPattern(pattern) {
335
888
  return pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
@@ -344,7 +897,18 @@ var IgnoreRule = /*#__PURE__*/function () {
344
897
  define(this, 'ignoreCase', ignoreCase);
345
898
  define(this, 'regexPrefix', prefix);
346
899
  }
900
+
901
+ // Worked out on first use and kept behind an own property, the way `regex`
902
+ // caches itself in `_regex`. Deciding it in the constructor instead would
903
+ // add a fourth `defineProperty` to every rule ever built, which cost 4% of
904
+ // every compile -- including the compiles of rules that are never matched
905
+ // against anything.
347
906
  _createClass(IgnoreRule, [{
907
+ key: "_basenameOnly",
908
+ get: function get() {
909
+ return define(this, '_basenameOnly', matchesBasename(this.body));
910
+ }
911
+ }, {
348
912
  key: "regex",
349
913
  get: function get() {
350
914
  var key = UNDERSCORE + MODE_IGNORE;
@@ -365,25 +929,73 @@ var IgnoreRule = /*#__PURE__*/function () {
365
929
  }, {
366
930
  key: "_make",
367
931
  value: function _make(mode, key) {
368
- var str = this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD,
369
- // It does not need to bind pattern
370
- TRAILING_WILD_CARD_REPLACERS[mode]);
932
+ var str = pinWildcards(mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix));
371
933
  var regex = this.ignoreCase ? new RegExp(str, 'i') : new RegExp(str);
372
934
  return define(this, key, regex);
373
935
  }
374
936
  }]);
375
937
  return IgnoreRule;
376
938
  }();
939
+ var isLineEnd = function isLineEnd(_char6) {
940
+ return _char6 === '\r' || _char6 === '\n';
941
+ };
942
+
943
+ // Drop a line terminator, which can remain when patterns are passed as an
944
+ // array, and then the trailing spaces. Git trims spaces only, and a space
945
+ // escaped by an odd run of backslashes stays, unescaped, as the last one.
946
+ // Scanned from the end: a regular expression can only try each start in
947
+ // turn, which is quadratic over a long run of spaces or backslashes.
948
+ // 'a ' -> 'a'; 'a\ ' -> 'a '; 'a\\ ' -> 'a\\'; 'a\t' -> 'a\t'
949
+ var trimEnd = function trimEnd(body) {
950
+ var end = body.length;
951
+ while (end && isLineEnd(body[end - 1])) {
952
+ end--;
953
+ }
954
+ var lineEnd = end;
955
+ while (end && body[end - 1] === SPACE) {
956
+ end--;
957
+ }
958
+ if (end === lineEnd) {
959
+ return body.slice(0, end);
960
+ }
961
+ var backslashes = 0;
962
+ while (backslashes < end && body[end - backslashes - 1] === ESCAPE) {
963
+ backslashes++;
964
+ }
965
+ return backslashes % 2 ? body.slice(0, end - 1) + SPACE : body.slice(0, end);
966
+ };
377
967
  var createRule = function createRule(_ref3, ignoreCase) {
378
968
  var pattern = _ref3.pattern,
379
969
  mark = _ref3.mark;
970
+ // Git drops a BOM before it reads the first line, so before anything else.
971
+ var body = pattern[0] === BOM ? pattern.slice(1) : pattern;
972
+
973
+ // > A line starting with # serves as a comment.
974
+ if (body[0] === '#') {
975
+ return;
976
+ }
380
977
  var negative = false;
381
- var body = pattern;
382
978
 
383
979
  // > An optional prefix "!" which negates the pattern;
384
- if (body.indexOf('!') === 0) {
980
+ if (body[0] === '!') {
385
981
  negative = true;
386
- body = body.substr(1);
982
+ body = body.slice(1);
983
+ }
984
+
985
+ // Normalize the body before checking which slashes anchor the pattern.
986
+ // Otherwise `bar/ ` is mistaken for a pattern containing an inner slash.
987
+ // Only a body ending in a space or a line terminator has anything to trim.
988
+ var last = body[body.length - 1];
989
+ if (last === SPACE || last === '\r' || last === '\n') {
990
+ body = trimEnd(body);
991
+ }
992
+
993
+ // > A blank line matches no files, so it can serve as a separator for
994
+ // > readability.
995
+ // Nor does a lone "!", or anything else left empty here: an empty pattern
996
+ // would compile to a regex matching every path.
997
+ if (!body) {
998
+ return;
387
999
  }
388
1000
  body = body
389
1001
  // > Put a backslash ("\") in front of the first "!" for patterns that
@@ -400,6 +1012,21 @@ var RuleManager = /*#__PURE__*/function () {
400
1012
  _classCallCheck(this, RuleManager);
401
1013
  this._ignoreCase = ignoreCase;
402
1014
  this._rules = [];
1015
+
1016
+ // How many of the rules git would tag `EXC_FLAG_NODIR`.
1017
+ //
1018
+ // The scan uses it to decide, once for the whole set, whether handing
1019
+ // those rules the basename is worth what it costs the others. The
1020
+ // shortcut saves a full-path scan on every rule it applies to and costs
1021
+ // a check on every rule it does not, so a set where almost nothing is
1022
+ // basename-only comes out behind -- a 955 pattern set with 44 of them
1023
+ // measured 19% slower with the shortcut always on.
1024
+ //
1025
+ // Deciding this by measurement rather than by meaning is safe: a
1026
+ // basename-only pattern gives the very same answer against the whole
1027
+ // path, it just takes longer to say so. The choice can only change how
1028
+ // fast the scan runs, never what it returns.
1029
+ this._basenameCount = 0;
403
1030
  }
404
1031
  _createClass(RuleManager, [{
405
1032
  key: "_add",
@@ -407,6 +1034,7 @@ var RuleManager = /*#__PURE__*/function () {
407
1034
  // #32
408
1035
  if (pattern && pattern[KEY_IGNORE]) {
409
1036
  this._rules = this._rules.concat(pattern._rules._rules);
1037
+ this._basenameCount += pattern._rules._basenameCount;
410
1038
  this._added = true;
411
1039
  return;
412
1040
  }
@@ -415,10 +1043,17 @@ var RuleManager = /*#__PURE__*/function () {
415
1043
  pattern: pattern
416
1044
  };
417
1045
  }
418
- if (checkPattern(pattern.pattern)) {
419
- var rule = createRule(pattern, this._ignoreCase);
1046
+ var rule = checkPattern(pattern.pattern) && createRule(pattern, this._ignoreCase);
1047
+ if (rule) {
420
1048
  this._added = true;
421
1049
  this._rules.push(rule);
1050
+
1051
+ // Deliberately not `rule._basenameOnly`: reading that would materialise
1052
+ // the rule's own copy, and the whole point of leaving it lazy is that
1053
+ // a rule which is compiled and never matched never pays for it.
1054
+ if (matchesBasename(rule.body)) {
1055
+ this._basenameCount++;
1056
+ }
422
1057
  }
423
1058
  }
424
1059
 
@@ -428,48 +1063,34 @@ var RuleManager = /*#__PURE__*/function () {
428
1063
  value: function add(pattern) {
429
1064
  this._added = false;
430
1065
  makeArray(isString(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
1066
+ if (this._added) {
1067
+ this._literalRules = UNDEFINED;
1068
+ }
431
1069
  return this._added;
432
1070
  }
433
1071
 
434
- // Test one single path without recursively checking parent directories
435
- //
436
- // - checkUnignored `boolean` whether should check if the path is unignored,
437
- // setting `checkUnignored` to `false` could reduce additional
438
- // path matching.
439
- // - check `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
440
-
441
- // @returns {TestResult} true if a file is ignored
1072
+ // Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
1073
+ // ending in a wildcard can match it (see `checkSourceOf`), so the rest
1074
+ // are left out once, rather than tested or compiled for every path.
442
1075
  }, {
443
- key: "test",
444
- value: function test(path, checkUnignored, mode) {
1076
+ key: "testLiteral",
1077
+ value: function testLiteral(path) {
1078
+ var rules = this._literalRules || (this._literalRules = this._rules.filter(function (_ref4) {
1079
+ var body = _ref4.body;
1080
+ return body[body.length - (body[body.length - 1] === SLASH ? 2 : 1)] === '*';
1081
+ }));
445
1082
  var ignored = false;
446
1083
  var unignored = false;
447
1084
  var matchedRule;
448
- this._rules.forEach(function (rule) {
449
- var negative = rule.negative;
450
-
451
- // | ignored : unignored
452
- // -------- | ---------------------------------------
453
- // negative | 0:0 | 0:1 | 1:0 | 1:1
454
- // -------- | ------- | ------- | ------- | --------
455
- // 0 | TEST | TEST | SKIP | X
456
- // 1 | TESTIF | SKIP | TEST | X
457
-
458
- // - SKIP: always skip
459
- // - TEST: always test
460
- // - TESTIF: only test if checkUnignored
461
- // - X: that never happen
462
- if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
463
- return;
1085
+ for (var index = rules.length - 1; index >= 0; index--) {
1086
+ var rule = rules[index];
1087
+ if (rule.checkRegex.test(path)) {
1088
+ ignored = !rule.negative;
1089
+ unignored = rule.negative;
1090
+ matchedRule = rule.negative ? UNDEFINED : rule;
1091
+ break;
464
1092
  }
465
- var matched = rule[mode].test(path);
466
- if (!matched) {
467
- return;
468
- }
469
- ignored = !negative;
470
- unignored = negative;
471
- matchedRule = negative ? UNDEFINED : rule;
472
- });
1093
+ }
473
1094
  var ret = {
474
1095
  ignored: ignored,
475
1096
  unignored: unignored
@@ -479,6 +1100,51 @@ var RuleManager = /*#__PURE__*/function () {
479
1100
  }
480
1101
  return ret;
481
1102
  }
1103
+
1104
+ // Test one single path without recursively checking parent directories
1105
+ //
1106
+ // - mode `string` either `MODE_IGNORE` or `MODE_CHECK_IGNORE`
1107
+
1108
+ // @returns {TestResult}
1109
+ }, {
1110
+ key: "test",
1111
+ value: function test(path, mode) {
1112
+ // Most of a .gitignore is patterns with no slash in them, and running
1113
+ // those against the whole path makes the regular expression engine walk
1114
+ // every directory name on the way to the only segment that could match.
1115
+ // Handing them the basename instead is what git does, and it is where
1116
+ // the time in a directory walk goes: the rule scan was two thirds of it.
1117
+ var rules = this._rules;
1118
+ var length = rules.length;
1119
+ var shortcut = this._basenameCount * 2 >= length;
1120
+ var basename = shortcut ? basenameOf(path) : path;
1121
+
1122
+ // The last rule to match decides, as in git, and it is the rule
1123
+ // `git check-ignore -v` reports, so the scan runs from the end and stops
1124
+ // at the first match.
1125
+ // A plain loop rather than `forEach`, so that `path`, `basename` and
1126
+ // `shortcut` are locals. As a callback they became closure variables,
1127
+ // and reaching for one of those once per rule cost 10% of a scan over a
1128
+ // large rule set -- more than the shortcut they were there to serve.
1129
+ for (var index = length - 1; index >= 0; index--) {
1130
+ var rule = rules[index];
1131
+ if (rule[mode].test(shortcut && rule._basenameOnly ? basename : path)) {
1132
+ var negative = rule.negative;
1133
+ var ret = {
1134
+ ignored: !negative,
1135
+ unignored: negative
1136
+ };
1137
+ if (!negative) {
1138
+ ret.rule = rule;
1139
+ }
1140
+ return ret;
1141
+ }
1142
+ }
1143
+ return {
1144
+ ignored: false,
1145
+ unignored: false
1146
+ };
1147
+ }
482
1148
  }]);
483
1149
  return RuleManager;
484
1150
  }();
@@ -502,8 +1168,39 @@ var checkPath = function checkPath(path, originalPath, doThrow) {
502
1168
  }
503
1169
  return true;
504
1170
  };
1171
+
1172
+ // > pathname should be a `path.relative()`d one
1173
+ //
1174
+ // The same thing `REGEX_TEST_INVALID_PATH` says, spelled out: a path is not
1175
+ // relative if it begins with a separator, or with `./` or `../`, or is
1176
+ // nothing but `.` or `..`. Every match is decided by the first three
1177
+ // characters, and this runs on every path handed to the library -- where it
1178
+ // was 55% of a cached lookup, more than the cache lookup itself.
505
1179
  var isNotRelative = function isNotRelative(path) {
506
- return REGEX_TEST_INVALID_PATH.test(path);
1180
+ var first = path.charCodeAt(0);
1181
+ if (first === SLASH_CODE) {
1182
+ return true;
1183
+ }
1184
+ if (first !== DOT_CODE) {
1185
+ return false;
1186
+ }
1187
+
1188
+ // '.'
1189
+ if (path.length === 1) {
1190
+ return true;
1191
+ }
1192
+ var second = path.charCodeAt(1);
1193
+
1194
+ // './'
1195
+ if (second === SLASH_CODE) {
1196
+ return true;
1197
+ }
1198
+ if (second !== DOT_CODE) {
1199
+ return false;
1200
+ }
1201
+
1202
+ // '..' or '../'
1203
+ return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
507
1204
  };
508
1205
  checkPath.isNotRelative = isNotRelative;
509
1206
 
@@ -514,13 +1211,13 @@ checkPath.convert = function (p) {
514
1211
  };
515
1212
  var Ignore = /*#__PURE__*/function () {
516
1213
  function Ignore() {
517
- var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
518
- _ref4$ignorecase = _ref4.ignorecase,
519
- ignorecase = _ref4$ignorecase === void 0 ? true : _ref4$ignorecase,
520
- _ref4$ignoreCase = _ref4.ignoreCase,
521
- ignoreCase = _ref4$ignoreCase === void 0 ? ignorecase : _ref4$ignoreCase,
522
- _ref4$allowRelativePa = _ref4.allowRelativePaths,
523
- allowRelativePaths = _ref4$allowRelativePa === void 0 ? false : _ref4$allowRelativePa;
1214
+ var _ref5 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
1215
+ _ref5$ignorecase = _ref5.ignorecase,
1216
+ ignorecase = _ref5$ignorecase === void 0 ? true : _ref5$ignorecase,
1217
+ _ref5$ignoreCase = _ref5.ignoreCase,
1218
+ ignoreCase = _ref5$ignoreCase === void 0 ? ignorecase : _ref5$ignoreCase,
1219
+ _ref5$allowRelativePa = _ref5.allowRelativePaths,
1220
+ allowRelativePaths = _ref5$allowRelativePa === void 0 ? false : _ref5$allowRelativePa;
524
1221
  _classCallCheck(this, Ignore);
525
1222
  define(this, KEY_IGNORE, true);
526
1223
  this._rules = new RuleManager(ignoreCase);
@@ -558,30 +1255,31 @@ var Ignore = /*#__PURE__*/function () {
558
1255
  // @returns {TestResult}
559
1256
  }, {
560
1257
  key: "_test",
561
- value: function _test(originalPath, cache, checkUnignored, slices) {
1258
+ value: function _test(originalPath, cache) {
562
1259
  var path = originalPath
563
1260
  // Supports nullable path
564
1261
  && checkPath.convert(originalPath);
565
1262
  checkPath(path, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
566
- return this._t(path, cache, checkUnignored, slices);
1263
+ return this._t(path, cache);
567
1264
  }
568
1265
  }, {
569
1266
  key: "checkIgnore",
570
1267
  value: function checkIgnore(path) {
571
1268
  // If the path doest not end with a slash, `.ignores()` is much equivalent
572
1269
  // to `git check-ignore`
573
- if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
1270
+ if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
574
1271
  return this.test(path);
575
1272
  }
576
- var slices = path.split(SLASH).filter(Boolean);
577
- slices.pop();
578
- if (slices.length) {
579
- var parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
580
- if (parent.ignored) {
581
- return parent;
582
- }
1273
+
1274
+ // Like `git check-ignore`: a directory excluded by itself or by an
1275
+ // ancestor settles it, and only then is the literal 'abc/' matched
1276
+ // against the rules (see `checkSourceOf`).
1277
+ var dir = this._t(path, this._testCache);
1278
+ if (dir.ignored) {
1279
+ return dir;
583
1280
  }
584
- return this._rules.test(path, false, MODE_CHECK_IGNORE);
1281
+ var literal = this._rules.testLiteral(path);
1282
+ return literal.ignored || literal.unignored ? literal : dir;
585
1283
  }
586
1284
  }, {
587
1285
  key: "_t",
@@ -589,37 +1287,23 @@ var Ignore = /*#__PURE__*/function () {
589
1287
  // The path to be tested
590
1288
  path,
591
1289
  // The cache for the result of a certain checking
592
- cache,
593
- // Whether should check if the path is unignored
594
- checkUnignored,
595
- // The path slices
596
- slices) {
1290
+ cache) {
597
1291
  if (path in cache) {
598
1292
  return cache[path];
599
1293
  }
600
- if (!slices) {
601
- // path/to/a.js
602
- // ['path', 'to', 'a.js']
603
- slices = path.split(SLASH).filter(Boolean);
604
- }
605
- slices.pop();
606
-
607
- // If the path has no parent directory, just test it
608
- if (!slices.length) {
609
- return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
610
- }
611
- var parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
1294
+ var parentPath = parentOf(path);
612
1295
 
613
1296
  // If the path contains a parent directory, check the parent first
614
- return cache[path] = parent.ignored
1297
+ var parent = parentPath ? this._t(parentPath, cache) : UNDEFINED;
1298
+ return cache[path] = parent && parent.ignored
615
1299
  // > It is not possible to re-include a file if a parent directory of
616
1300
  // > that file is excluded.
617
- ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
1301
+ ? parent : this._rules.test(path, MODE_IGNORE);
618
1302
  }
619
1303
  }, {
620
1304
  key: "ignores",
621
1305
  value: function ignores(path) {
622
- return this._test(path, this._ignoreCache, false).ignored;
1306
+ return this._test(path, this._ignoreCache).ignored;
623
1307
  }
624
1308
  }, {
625
1309
  key: "createFilter",
@@ -639,7 +1323,7 @@ var Ignore = /*#__PURE__*/function () {
639
1323
  }, {
640
1324
  key: "test",
641
1325
  value: function test(path) {
642
- return this._test(path, this._testCache, true);
1326
+ return this._test(path, this._testCache);
643
1327
  }
644
1328
  }]);
645
1329
  return Ignore;