@opensumi/ide-core-common 2.12.1-next-079c1930

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 (450) hide show
  1. package/lib/application-error.d.ts +36 -0
  2. package/lib/application-error.d.ts.map +1 -0
  3. package/lib/application-error.js +64 -0
  4. package/lib/application-error.js.map +1 -0
  5. package/lib/application-props.d.ts +26 -0
  6. package/lib/application-props.d.ts.map +1 -0
  7. package/lib/application-props.js +3 -0
  8. package/lib/application-props.js.map +1 -0
  9. package/lib/arrays.d.ts +131 -0
  10. package/lib/arrays.d.ts.map +1 -0
  11. package/lib/arrays.js +533 -0
  12. package/lib/arrays.js.map +1 -0
  13. package/lib/async.d.ts +165 -0
  14. package/lib/async.d.ts.map +1 -0
  15. package/lib/async.js +417 -0
  16. package/lib/async.js.map +1 -0
  17. package/lib/browser-fs/ensure-dir.d.ts +7 -0
  18. package/lib/browser-fs/ensure-dir.d.ts.map +1 -0
  19. package/lib/browser-fs/ensure-dir.js +40 -0
  20. package/lib/browser-fs/ensure-dir.js.map +1 -0
  21. package/lib/browser-fs/util.d.ts +18 -0
  22. package/lib/browser-fs/util.d.ts.map +1 -0
  23. package/lib/browser-fs/util.js +21 -0
  24. package/lib/browser-fs/util.js.map +1 -0
  25. package/lib/cache.d.ts +12 -0
  26. package/lib/cache.d.ts.map +1 -0
  27. package/lib/cache.js +36 -0
  28. package/lib/cache.js.map +1 -0
  29. package/lib/cancellation.d.ts +23 -0
  30. package/lib/cancellation.d.ts.map +1 -0
  31. package/lib/cancellation.js +116 -0
  32. package/lib/cancellation.js.map +1 -0
  33. package/lib/charCode.d.ts +406 -0
  34. package/lib/charCode.d.ts.map +1 -0
  35. package/lib/charCode.js +8 -0
  36. package/lib/charCode.js.map +1 -0
  37. package/lib/character-classifier.d.ts +25 -0
  38. package/lib/character-classifier.d.ts.map +1 -0
  39. package/lib/character-classifier.js +58 -0
  40. package/lib/character-classifier.js.map +1 -0
  41. package/lib/command.d.ts +350 -0
  42. package/lib/command.d.ts.map +1 -0
  43. package/lib/command.js +408 -0
  44. package/lib/command.js.map +1 -0
  45. package/lib/connection.d.ts +8 -0
  46. package/lib/connection.d.ts.map +1 -0
  47. package/lib/connection.js +17 -0
  48. package/lib/connection.js.map +1 -0
  49. package/lib/const/application.d.ts +3 -0
  50. package/lib/const/application.d.ts.map +1 -0
  51. package/lib/const/application.js +6 -0
  52. package/lib/const/application.js.map +1 -0
  53. package/lib/const/encodings.d.ts +10 -0
  54. package/lib/const/encodings.d.ts.map +1 -0
  55. package/lib/const/encodings.js +244 -0
  56. package/lib/const/encodings.js.map +1 -0
  57. package/lib/const/index.d.ts +2 -0
  58. package/lib/const/index.d.ts.map +1 -0
  59. package/lib/const/index.js +5 -0
  60. package/lib/const/index.js.map +1 -0
  61. package/lib/contribution-provider.d.ts +38 -0
  62. package/lib/contribution-provider.d.ts.map +1 -0
  63. package/lib/contribution-provider.js +60 -0
  64. package/lib/contribution-provider.js.map +1 -0
  65. package/lib/credential.d.ts +21 -0
  66. package/lib/credential.d.ts.map +1 -0
  67. package/lib/credential.js +6 -0
  68. package/lib/credential.js.map +1 -0
  69. package/lib/cryptr.d.ts +7 -0
  70. package/lib/cryptr.d.ts.map +1 -0
  71. package/lib/cryptr.js +6 -0
  72. package/lib/cryptr.js.map +1 -0
  73. package/lib/date.d.ts +2 -0
  74. package/lib/date.d.ts.map +1 -0
  75. package/lib/date.js +16 -0
  76. package/lib/date.js.map +1 -0
  77. package/lib/declare.d.ts +3 -0
  78. package/lib/declare.d.ts.map +1 -0
  79. package/lib/declare.js +3 -0
  80. package/lib/declare.js.map +1 -0
  81. package/lib/di-helper/domain-helper.d.ts +14 -0
  82. package/lib/di-helper/domain-helper.d.ts.map +1 -0
  83. package/lib/di-helper/domain-helper.js +48 -0
  84. package/lib/di-helper/domain-helper.js.map +1 -0
  85. package/lib/di-helper/index.d.ts +2 -0
  86. package/lib/di-helper/index.d.ts.map +1 -0
  87. package/lib/di-helper/index.js +5 -0
  88. package/lib/di-helper/index.js.map +1 -0
  89. package/lib/disposable.d.ts +88 -0
  90. package/lib/disposable.d.ts.map +1 -0
  91. package/lib/disposable.js +309 -0
  92. package/lib/disposable.js.map +1 -0
  93. package/lib/electron.d.ts +118 -0
  94. package/lib/electron.d.ts.map +1 -0
  95. package/lib/electron.js +7 -0
  96. package/lib/electron.js.map +1 -0
  97. package/lib/encoding/index.d.ts +34 -0
  98. package/lib/encoding/index.d.ts.map +1 -0
  99. package/lib/encoding/index.js +219 -0
  100. package/lib/encoding/index.js.map +1 -0
  101. package/lib/env.d.ts +2 -0
  102. package/lib/env.d.ts.map +1 -0
  103. package/lib/env.js +5 -0
  104. package/lib/env.js.map +1 -0
  105. package/lib/errors.d.ts +60 -0
  106. package/lib/errors.d.ts.map +1 -0
  107. package/lib/errors.js +148 -0
  108. package/lib/errors.js.map +1 -0
  109. package/lib/event-bus/basic-event.d.ts +5 -0
  110. package/lib/event-bus/basic-event.d.ts.map +1 -0
  111. package/lib/event-bus/basic-event.js +10 -0
  112. package/lib/event-bus/basic-event.js.map +1 -0
  113. package/lib/event-bus/event-bus-types.d.ts +66 -0
  114. package/lib/event-bus/event-bus-types.d.ts.map +1 -0
  115. package/lib/event-bus/event-bus-types.js +5 -0
  116. package/lib/event-bus/event-bus-types.js.map +1 -0
  117. package/lib/event-bus/event-bus.d.ts +13 -0
  118. package/lib/event-bus/event-bus.d.ts.map +1 -0
  119. package/lib/event-bus/event-bus.js +55 -0
  120. package/lib/event-bus/event-bus.js.map +1 -0
  121. package/lib/event-bus/event-decorator.d.ts +10 -0
  122. package/lib/event-bus/event-decorator.d.ts.map +1 -0
  123. package/lib/event-bus/event-decorator.js +34 -0
  124. package/lib/event-bus/event-decorator.js.map +1 -0
  125. package/lib/event-bus/index.d.ts +5 -0
  126. package/lib/event-bus/index.d.ts.map +1 -0
  127. package/lib/event-bus/index.js +8 -0
  128. package/lib/event-bus/index.js.map +1 -0
  129. package/lib/event.d.ts +270 -0
  130. package/lib/event.d.ts.map +1 -0
  131. package/lib/event.js +810 -0
  132. package/lib/event.js.map +1 -0
  133. package/lib/filters.d.ts +51 -0
  134. package/lib/filters.d.ts.map +1 -0
  135. package/lib/filters.js +688 -0
  136. package/lib/filters.js.map +1 -0
  137. package/lib/functional.d.ts +4 -0
  138. package/lib/functional.d.ts.map +1 -0
  139. package/lib/functional.js +45 -0
  140. package/lib/functional.js.map +1 -0
  141. package/lib/hash-calculate/WASMInterface.d.ts +61 -0
  142. package/lib/hash-calculate/WASMInterface.d.ts.map +1 -0
  143. package/lib/hash-calculate/WASMInterface.js +180 -0
  144. package/lib/hash-calculate/WASMInterface.js.map +1 -0
  145. package/lib/hash-calculate/hash-calculate.d.ts +13 -0
  146. package/lib/hash-calculate/hash-calculate.d.ts.map +1 -0
  147. package/lib/hash-calculate/hash-calculate.js +41 -0
  148. package/lib/hash-calculate/hash-calculate.js.map +1 -0
  149. package/lib/hash-calculate/lockedCreate.d.ts +4 -0
  150. package/lib/hash-calculate/lockedCreate.d.ts.map +1 -0
  151. package/lib/hash-calculate/lockedCreate.js +17 -0
  152. package/lib/hash-calculate/lockedCreate.js.map +1 -0
  153. package/lib/hash-calculate/md5.wasm.json +1 -0
  154. package/lib/hash-calculate/mutex.d.ts +6 -0
  155. package/lib/hash-calculate/mutex.d.ts.map +1 -0
  156. package/lib/hash-calculate/mutex.js +32 -0
  157. package/lib/hash-calculate/mutex.js.map +1 -0
  158. package/lib/hash-calculate/util.d.ts +12 -0
  159. package/lib/hash-calculate/util.d.ts.map +1 -0
  160. package/lib/hash-calculate/util.js +166 -0
  161. package/lib/hash-calculate/util.js.map +1 -0
  162. package/lib/id-generator.d.ts +8 -0
  163. package/lib/id-generator.d.ts.map +1 -0
  164. package/lib/id-generator.js +15 -0
  165. package/lib/id-generator.js.map +1 -0
  166. package/lib/index.d.ts +47 -0
  167. package/lib/index.d.ts.map +1 -0
  168. package/lib/index.js +50 -0
  169. package/lib/index.js.map +1 -0
  170. package/lib/iterator.d.ts +14 -0
  171. package/lib/iterator.d.ts.map +1 -0
  172. package/lib/iterator.js +9 -0
  173. package/lib/iterator.js.map +1 -0
  174. package/lib/json-schema.d.ts +65 -0
  175. package/lib/json-schema.d.ts.map +1 -0
  176. package/lib/json-schema.js +3 -0
  177. package/lib/json-schema.js.map +1 -0
  178. package/lib/keyboard/index.d.ts +3 -0
  179. package/lib/keyboard/index.d.ts.map +1 -0
  180. package/lib/keyboard/index.js +6 -0
  181. package/lib/keyboard/index.js.map +1 -0
  182. package/lib/keyboard/keyboard-layout-provider.d.ts +38 -0
  183. package/lib/keyboard/keyboard-layout-provider.d.ts.map +1 -0
  184. package/lib/keyboard/keyboard-layout-provider.js +23 -0
  185. package/lib/keyboard/keyboard-layout-provider.js.map +1 -0
  186. package/lib/keyboard/keymap.d.ts +71 -0
  187. package/lib/keyboard/keymap.d.ts.map +1 -0
  188. package/lib/keyboard/keymap.js +128 -0
  189. package/lib/keyboard/keymap.js.map +1 -0
  190. package/lib/lifecycle.d.ts +17 -0
  191. package/lib/lifecycle.d.ts.map +1 -0
  192. package/lib/lifecycle.js +37 -0
  193. package/lib/lifecycle.js.map +1 -0
  194. package/lib/line-text.d.ts +17 -0
  195. package/lib/line-text.d.ts.map +1 -0
  196. package/lib/line-text.js +72 -0
  197. package/lib/line-text.js.map +1 -0
  198. package/lib/linked-list.d.ts +18 -0
  199. package/lib/linked-list.d.ts.map +1 -0
  200. package/lib/linked-list.js +138 -0
  201. package/lib/linked-list.js.map +1 -0
  202. package/lib/linkedText.d.ts +13 -0
  203. package/lib/linkedText.d.ts.map +1 -0
  204. package/lib/linkedText.js +50 -0
  205. package/lib/linkedText.js.map +1 -0
  206. package/lib/localize.d.ts +52 -0
  207. package/lib/localize.d.ts.map +1 -0
  208. package/lib/localize.js +128 -0
  209. package/lib/localize.js.map +1 -0
  210. package/lib/log.d.ts +181 -0
  211. package/lib/log.d.ts.map +1 -0
  212. package/lib/log.js +163 -0
  213. package/lib/log.js.map +1 -0
  214. package/lib/map.d.ts +124 -0
  215. package/lib/map.d.ts.map +1 -0
  216. package/lib/map.js +819 -0
  217. package/lib/map.js.map +1 -0
  218. package/lib/menu.d.ts +27 -0
  219. package/lib/menu.d.ts.map +1 -0
  220. package/lib/menu.js +5 -0
  221. package/lib/menu.js.map +1 -0
  222. package/lib/mocks/electron/browserMock.d.ts +2 -0
  223. package/lib/mocks/electron/browserMock.d.ts.map +1 -0
  224. package/lib/mocks/electron/browserMock.js +15 -0
  225. package/lib/mocks/electron/browserMock.js.map +1 -0
  226. package/lib/mocks/electron/ipcRenderer.d.ts +13 -0
  227. package/lib/mocks/electron/ipcRenderer.d.ts.map +1 -0
  228. package/lib/mocks/electron/ipcRenderer.js +32 -0
  229. package/lib/mocks/electron/ipcRenderer.js.map +1 -0
  230. package/lib/module.d.ts +23 -0
  231. package/lib/module.d.ts.map +1 -0
  232. package/lib/module.js +22 -0
  233. package/lib/module.js.map +1 -0
  234. package/lib/network.d.ts +33 -0
  235. package/lib/network.d.ts.map +1 -0
  236. package/lib/network.js +37 -0
  237. package/lib/network.js.map +1 -0
  238. package/lib/node/port.d.ts +14 -0
  239. package/lib/node/port.d.ts.map +1 -0
  240. package/lib/node/port.js +124 -0
  241. package/lib/node/port.js.map +1 -0
  242. package/lib/path.d.ts +92 -0
  243. package/lib/path.d.ts.map +1 -0
  244. package/lib/path.js +1711 -0
  245. package/lib/path.js.map +1 -0
  246. package/lib/platform.d.ts +48 -0
  247. package/lib/platform.d.ts.map +1 -0
  248. package/lib/platform.js +143 -0
  249. package/lib/platform.js.map +1 -0
  250. package/lib/preferences/index.d.ts +3 -0
  251. package/lib/preferences/index.d.ts.map +1 -0
  252. package/lib/preferences/index.js +6 -0
  253. package/lib/preferences/index.js.map +1 -0
  254. package/lib/preferences/preference-schema.d.ts +76 -0
  255. package/lib/preferences/preference-schema.d.ts.map +1 -0
  256. package/lib/preferences/preference-schema.js +59 -0
  257. package/lib/preferences/preference-schema.js.map +1 -0
  258. package/lib/preferences/preference-scope.d.ts +15 -0
  259. package/lib/preferences/preference-scope.d.ts.map +1 -0
  260. package/lib/preferences/preference-scope.js +54 -0
  261. package/lib/preferences/preference-scope.js.map +1 -0
  262. package/lib/problem-matcher.d.ts +111 -0
  263. package/lib/problem-matcher.d.ts.map +1 -0
  264. package/lib/problem-matcher.js +294 -0
  265. package/lib/problem-matcher.js.map +1 -0
  266. package/lib/problem-pattern.d.ts +193 -0
  267. package/lib/problem-pattern.d.ts.map +1 -0
  268. package/lib/problem-pattern.js +416 -0
  269. package/lib/problem-pattern.js.map +1 -0
  270. package/lib/process.d.ts +5 -0
  271. package/lib/process.d.ts.map +1 -0
  272. package/lib/process.js +15 -0
  273. package/lib/process.js.map +1 -0
  274. package/lib/progress.d.ts +56 -0
  275. package/lib/progress.d.ts.map +1 -0
  276. package/lib/progress.js +25 -0
  277. package/lib/progress.js.map +1 -0
  278. package/lib/range.d.ts +7 -0
  279. package/lib/range.d.ts.map +1 -0
  280. package/lib/range.js +28 -0
  281. package/lib/range.js.map +1 -0
  282. package/lib/reference.d.ts +35 -0
  283. package/lib/reference.d.ts.map +1 -0
  284. package/lib/reference.js +122 -0
  285. package/lib/reference.js.map +1 -0
  286. package/lib/reporter.d.ts +16 -0
  287. package/lib/reporter.d.ts.map +1 -0
  288. package/lib/reporter.js +66 -0
  289. package/lib/reporter.js.map +1 -0
  290. package/lib/sequence.d.ts +20 -0
  291. package/lib/sequence.d.ts.map +1 -0
  292. package/lib/sequence.js +17 -0
  293. package/lib/sequence.js.map +1 -0
  294. package/lib/storage.d.ts +64 -0
  295. package/lib/storage.d.ts.map +1 -0
  296. package/lib/storage.js +70 -0
  297. package/lib/storage.js.map +1 -0
  298. package/lib/task-definition.d.ts +45 -0
  299. package/lib/task-definition.d.ts.map +1 -0
  300. package/lib/task-definition.js +130 -0
  301. package/lib/task-definition.js.map +1 -0
  302. package/lib/theme.d.ts +5 -0
  303. package/lib/theme.d.ts.map +1 -0
  304. package/lib/theme.js +8 -0
  305. package/lib/theme.js.map +1 -0
  306. package/lib/types/accessibility.d.ts +5 -0
  307. package/lib/types/accessibility.d.ts.map +1 -0
  308. package/lib/types/accessibility.js +3 -0
  309. package/lib/types/accessibility.js.map +1 -0
  310. package/lib/types/application.d.ts +13 -0
  311. package/lib/types/application.d.ts.map +1 -0
  312. package/lib/types/application.js +5 -0
  313. package/lib/types/application.js.map +1 -0
  314. package/lib/types/authentication.d.ts +90 -0
  315. package/lib/types/authentication.d.ts.map +1 -0
  316. package/lib/types/authentication.js +8 -0
  317. package/lib/types/authentication.js.map +1 -0
  318. package/lib/types/common.d.ts +10 -0
  319. package/lib/types/common.d.ts.map +1 -0
  320. package/lib/types/common.js +6 -0
  321. package/lib/types/common.js.map +1 -0
  322. package/lib/types/dnd.d.ts +8 -0
  323. package/lib/types/dnd.d.ts.map +1 -0
  324. package/lib/types/dnd.js +9 -0
  325. package/lib/types/dnd.js.map +1 -0
  326. package/lib/types/editor.d.ts +157 -0
  327. package/lib/types/editor.d.ts.map +1 -0
  328. package/lib/types/editor.js +148 -0
  329. package/lib/types/editor.js.map +1 -0
  330. package/lib/types/extension.d.ts +73 -0
  331. package/lib/types/extension.d.ts.map +1 -0
  332. package/lib/types/extension.js +28 -0
  333. package/lib/types/extension.js.map +1 -0
  334. package/lib/types/file-watch.d.ts +70 -0
  335. package/lib/types/file-watch.d.ts.map +1 -0
  336. package/lib/types/file-watch.js +72 -0
  337. package/lib/types/file-watch.js.map +1 -0
  338. package/lib/types/file.d.ts +219 -0
  339. package/lib/types/file.d.ts.map +1 -0
  340. package/lib/types/file.js +51 -0
  341. package/lib/types/file.js.map +1 -0
  342. package/lib/types/index.d.ts +13 -0
  343. package/lib/types/index.d.ts.map +1 -0
  344. package/lib/types/index.js +16 -0
  345. package/lib/types/index.js.map +1 -0
  346. package/lib/types/markers/index.d.ts +3 -0
  347. package/lib/types/markers/index.d.ts.map +1 -0
  348. package/lib/types/markers/index.js +6 -0
  349. package/lib/types/markers/index.js.map +1 -0
  350. package/lib/types/markers/markers-manager.d.ts +120 -0
  351. package/lib/types/markers/markers-manager.d.ts.map +1 -0
  352. package/lib/types/markers/markers-manager.js +307 -0
  353. package/lib/types/markers/markers-manager.js.map +1 -0
  354. package/lib/types/markers/markers.d.ts +76 -0
  355. package/lib/types/markers/markers.d.ts.map +1 -0
  356. package/lib/types/markers/markers.js +76 -0
  357. package/lib/types/markers/markers.js.map +1 -0
  358. package/lib/types/message.d.ts +7 -0
  359. package/lib/types/message.d.ts.map +1 -0
  360. package/lib/types/message.js +11 -0
  361. package/lib/types/message.js.map +1 -0
  362. package/lib/types/reporter.d.ts +83 -0
  363. package/lib/types/reporter.d.ts.map +1 -0
  364. package/lib/types/reporter.js +63 -0
  365. package/lib/types/reporter.js.map +1 -0
  366. package/lib/types/string.d.ts +4 -0
  367. package/lib/types/string.d.ts.map +1 -0
  368. package/lib/types/string.js +3 -0
  369. package/lib/types/string.js.map +1 -0
  370. package/lib/uint.d.ts +32 -0
  371. package/lib/uint.d.ts.map +1 -0
  372. package/lib/uint.js +28 -0
  373. package/lib/uint.js.map +1 -0
  374. package/lib/uri.d.ts +94 -0
  375. package/lib/uri.d.ts.map +1 -0
  376. package/lib/uri.js +226 -0
  377. package/lib/uri.js.map +1 -0
  378. package/lib/utils/ansi.d.ts +5 -0
  379. package/lib/utils/ansi.d.ts.map +1 -0
  380. package/lib/utils/ansi.js +16 -0
  381. package/lib/utils/ansi.js.map +1 -0
  382. package/lib/utils/arrays.d.ts +62 -0
  383. package/lib/utils/arrays.d.ts.map +1 -0
  384. package/lib/utils/arrays.js +254 -0
  385. package/lib/utils/arrays.js.map +1 -0
  386. package/lib/utils/buffer.d.ts +36 -0
  387. package/lib/utils/buffer.d.ts.map +1 -0
  388. package/lib/utils/buffer.js +178 -0
  389. package/lib/utils/buffer.js.map +1 -0
  390. package/lib/utils/comparers.d.ts +7 -0
  391. package/lib/utils/comparers.d.ts.map +1 -0
  392. package/lib/utils/comparers.js +135 -0
  393. package/lib/utils/comparers.js.map +1 -0
  394. package/lib/utils/decorators.d.ts +13 -0
  395. package/lib/utils/decorators.d.ts.map +1 -0
  396. package/lib/utils/decorators.js +150 -0
  397. package/lib/utils/decorators.js.map +1 -0
  398. package/lib/utils/file-uri.d.ts +30 -0
  399. package/lib/utils/file-uri.d.ts.map +1 -0
  400. package/lib/utils/file-uri.js +62 -0
  401. package/lib/utils/file-uri.js.map +1 -0
  402. package/lib/utils/glob.d.ts +46 -0
  403. package/lib/utils/glob.d.ts.map +1 -0
  404. package/lib/utils/glob.js +546 -0
  405. package/lib/utils/glob.js.map +1 -0
  406. package/lib/utils/index.d.ts +14 -0
  407. package/lib/utils/index.d.ts.map +1 -0
  408. package/lib/utils/index.js +17 -0
  409. package/lib/utils/index.js.map +1 -0
  410. package/lib/utils/ipc.d.ts +2 -0
  411. package/lib/utils/ipc.d.ts.map +1 -0
  412. package/lib/utils/ipc.js +21 -0
  413. package/lib/utils/ipc.js.map +1 -0
  414. package/lib/utils/json.d.ts +78 -0
  415. package/lib/utils/json.d.ts.map +1 -0
  416. package/lib/utils/json.js +190 -0
  417. package/lib/utils/json.js.map +1 -0
  418. package/lib/utils/marshalling.d.ts +7 -0
  419. package/lib/utils/marshalling.d.ts.map +1 -0
  420. package/lib/utils/marshalling.js +57 -0
  421. package/lib/utils/marshalling.js.map +1 -0
  422. package/lib/utils/objects.d.ts +6 -0
  423. package/lib/utils/objects.d.ts.map +1 -0
  424. package/lib/utils/objects.js +103 -0
  425. package/lib/utils/objects.js.map +1 -0
  426. package/lib/utils/os.d.ts +42 -0
  427. package/lib/utils/os.d.ts.map +1 -0
  428. package/lib/utils/os.js +94 -0
  429. package/lib/utils/os.js.map +1 -0
  430. package/lib/utils/paths.d.ts +35 -0
  431. package/lib/utils/paths.d.ts.map +1 -0
  432. package/lib/utils/paths.js +318 -0
  433. package/lib/utils/paths.js.map +1 -0
  434. package/lib/utils/promise-util.d.ts +10 -0
  435. package/lib/utils/promise-util.d.ts.map +1 -0
  436. package/lib/utils/promise-util.js +17 -0
  437. package/lib/utils/promise-util.js.map +1 -0
  438. package/lib/utils/strings.d.ts +177 -0
  439. package/lib/utils/strings.d.ts.map +1 -0
  440. package/lib/utils/strings.js +837 -0
  441. package/lib/utils/strings.js.map +1 -0
  442. package/lib/utils/types.d.ts +65 -0
  443. package/lib/utils/types.d.ts.map +1 -0
  444. package/lib/utils/types.js +194 -0
  445. package/lib/utils/types.js.map +1 -0
  446. package/lib/uuid.d.ts +2 -0
  447. package/lib/uuid.d.ts.map +1 -0
  448. package/lib/uuid.js +10 -0
  449. package/lib/uuid.js.map +1 -0
  450. package/package.json +30 -0
package/lib/filters.js ADDED
@@ -0,0 +1,688 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Microsoft Corporation. All rights reserved.
4
+ * Licensed under the MIT License. See License.txt in the project root for license information.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ // Some code copued and modified from https://github.com/microsoft/vscode/blob/1.44.0/src/vs/base/common/filters.ts
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.fuzzyScoreGraceful = exports.fuzzyScoreGracefulAggressive = exports.fuzzyScore = exports.FuzzyScore = exports.isPatternInWord = exports.createMatches = exports.anyScore = exports.matchesFuzzy2 = exports.matchesFuzzy = exports.matchesWords = exports.matchesCamelCase = exports.isUpper = exports.matchesSubString = exports.matchesContiguousSubString = exports.matchesPrefix = exports.matchesStrictPrefix = exports.or = void 0;
9
+ const tslib_1 = require("tslib");
10
+ const map_1 = require("./map");
11
+ const strings = (0, tslib_1.__importStar)(require("./utils/strings"));
12
+ // Combined filters
13
+ /**
14
+ * @returns A filter which combines the provided set
15
+ * of filters with an or. The *first* filters that
16
+ * matches defined the return value of the returned
17
+ * filter.
18
+ */
19
+ function or(...filter) {
20
+ return function (word, wordToMatchAgainst) {
21
+ for (let i = 0, len = filter.length; i < len; i++) {
22
+ const match = filter[i](word, wordToMatchAgainst);
23
+ if (match) {
24
+ return match;
25
+ }
26
+ }
27
+ return null;
28
+ };
29
+ }
30
+ exports.or = or;
31
+ // Prefix
32
+ exports.matchesStrictPrefix = _matchesPrefix.bind(undefined, false);
33
+ exports.matchesPrefix = _matchesPrefix.bind(undefined, true);
34
+ function _matchesPrefix(ignoreCase, word, wordToMatchAgainst) {
35
+ if (!wordToMatchAgainst || wordToMatchAgainst.length < word.length) {
36
+ return null;
37
+ }
38
+ let matches;
39
+ if (ignoreCase) {
40
+ matches = strings.startsWithIgnoreCase(wordToMatchAgainst, word);
41
+ }
42
+ else {
43
+ matches = wordToMatchAgainst.indexOf(word) === 0;
44
+ }
45
+ if (!matches) {
46
+ return null;
47
+ }
48
+ return word.length > 0 ? [{ start: 0, end: word.length }] : [];
49
+ }
50
+ // Contiguous Substring
51
+ function matchesContiguousSubString(word, wordToMatchAgainst) {
52
+ const index = wordToMatchAgainst.toLowerCase().indexOf(word.toLowerCase());
53
+ if (index === -1) {
54
+ return null;
55
+ }
56
+ return [{ start: index, end: index + word.length }];
57
+ }
58
+ exports.matchesContiguousSubString = matchesContiguousSubString;
59
+ // Substring
60
+ function matchesSubString(word, wordToMatchAgainst) {
61
+ return _matchesSubString(word.toLowerCase(), wordToMatchAgainst.toLowerCase(), 0, 0);
62
+ }
63
+ exports.matchesSubString = matchesSubString;
64
+ function _matchesSubString(word, wordToMatchAgainst, i, j) {
65
+ if (i === word.length) {
66
+ return [];
67
+ }
68
+ else if (j === wordToMatchAgainst.length) {
69
+ return null;
70
+ }
71
+ else {
72
+ if (word[i] === wordToMatchAgainst[j]) {
73
+ let result = null;
74
+ if (result = _matchesSubString(word, wordToMatchAgainst, i + 1, j + 1)) {
75
+ return join({ start: j, end: j + 1 }, result);
76
+ }
77
+ return null;
78
+ }
79
+ return _matchesSubString(word, wordToMatchAgainst, i, j + 1);
80
+ }
81
+ }
82
+ // CamelCase
83
+ function isLower(code) {
84
+ return 97 /* a */ <= code && code <= 122 /* z */;
85
+ }
86
+ function isUpper(code) {
87
+ return 65 /* A */ <= code && code <= 90 /* Z */;
88
+ }
89
+ exports.isUpper = isUpper;
90
+ function isNumber(code) {
91
+ return 48 /* Digit0 */ <= code && code <= 57 /* Digit9 */;
92
+ }
93
+ function isWhitespace(code) {
94
+ return (code === 32 /* Space */
95
+ || code === 9 /* Tab */
96
+ || code === 10 /* LineFeed */
97
+ || code === 13 /* CarriageReturn */);
98
+ }
99
+ const wordSeparators = new Set();
100
+ '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?'
101
+ .split('')
102
+ .forEach(s => wordSeparators.add(s.charCodeAt(0)));
103
+ function isWordSeparator(code) {
104
+ return isWhitespace(code) || wordSeparators.has(code);
105
+ }
106
+ function charactersMatch(codeA, codeB) {
107
+ return (codeA === codeB) || (isWordSeparator(codeA) && isWordSeparator(codeB));
108
+ }
109
+ function isAlphanumeric(code) {
110
+ return isLower(code) || isUpper(code) || isNumber(code);
111
+ }
112
+ function join(head, tail) {
113
+ if (tail.length === 0) {
114
+ tail = [head];
115
+ }
116
+ else if (head.end === tail[0].start) {
117
+ tail[0].start = head.start;
118
+ }
119
+ else {
120
+ tail.unshift(head);
121
+ }
122
+ return tail;
123
+ }
124
+ function nextAnchor(camelCaseWord, start) {
125
+ for (let i = start; i < camelCaseWord.length; i++) {
126
+ const c = camelCaseWord.charCodeAt(i);
127
+ if (isUpper(c) || isNumber(c) || (i > 0 && !isAlphanumeric(camelCaseWord.charCodeAt(i - 1)))) {
128
+ return i;
129
+ }
130
+ }
131
+ return camelCaseWord.length;
132
+ }
133
+ function _matchesCamelCase(word, camelCaseWord, i, j) {
134
+ if (i === word.length) {
135
+ return [];
136
+ }
137
+ else if (j === camelCaseWord.length) {
138
+ return null;
139
+ }
140
+ else if (word[i] !== camelCaseWord[j].toLowerCase()) {
141
+ return null;
142
+ }
143
+ else {
144
+ let result = null;
145
+ let nextUpperIndex = j + 1;
146
+ result = _matchesCamelCase(word, camelCaseWord, i + 1, j + 1);
147
+ while (!result && (nextUpperIndex = nextAnchor(camelCaseWord, nextUpperIndex)) < camelCaseWord.length) {
148
+ result = _matchesCamelCase(word, camelCaseWord, i + 1, nextUpperIndex);
149
+ nextUpperIndex++;
150
+ }
151
+ return result === null ? null : join({ start: j, end: j + 1 }, result);
152
+ }
153
+ }
154
+ // Heuristic to avoid computing camel case matcher for words that don't
155
+ // look like camelCaseWords.
156
+ function analyzeCamelCaseWord(word) {
157
+ let upper = 0, lower = 0, alpha = 0, numeric = 0, code = 0;
158
+ for (let i = 0; i < word.length; i++) {
159
+ code = word.charCodeAt(i);
160
+ if (isUpper(code)) {
161
+ upper++;
162
+ }
163
+ if (isLower(code)) {
164
+ lower++;
165
+ }
166
+ if (isAlphanumeric(code)) {
167
+ alpha++;
168
+ }
169
+ if (isNumber(code)) {
170
+ numeric++;
171
+ }
172
+ }
173
+ const upperPercent = upper / word.length;
174
+ const lowerPercent = lower / word.length;
175
+ const alphaPercent = alpha / word.length;
176
+ const numericPercent = numeric / word.length;
177
+ return { upperPercent, lowerPercent, alphaPercent, numericPercent };
178
+ }
179
+ function isUpperCaseWord(analysis) {
180
+ const { upperPercent, lowerPercent } = analysis;
181
+ return lowerPercent === 0 && upperPercent > 0.6;
182
+ }
183
+ function isCamelCaseWord(analysis) {
184
+ const { upperPercent, lowerPercent, alphaPercent, numericPercent } = analysis;
185
+ return lowerPercent > 0.2 && upperPercent < 0.8 && alphaPercent > 0.6 && numericPercent < 0.2;
186
+ }
187
+ // Heuristic to avoid computing camel case matcher for words that don't
188
+ // look like camel case patterns.
189
+ function isCamelCasePattern(word) {
190
+ let upper = 0, lower = 0, code = 0, whitespace = 0;
191
+ for (let i = 0; i < word.length; i++) {
192
+ code = word.charCodeAt(i);
193
+ if (isUpper(code)) {
194
+ upper++;
195
+ }
196
+ if (isLower(code)) {
197
+ lower++;
198
+ }
199
+ if (isWhitespace(code)) {
200
+ whitespace++;
201
+ }
202
+ }
203
+ if ((upper === 0 || lower === 0) && whitespace === 0) {
204
+ return word.length <= 30;
205
+ }
206
+ else {
207
+ return upper <= 5;
208
+ }
209
+ }
210
+ function matchesCamelCase(word, camelCaseWord) {
211
+ if (!camelCaseWord) {
212
+ return null;
213
+ }
214
+ camelCaseWord = camelCaseWord.trim();
215
+ if (camelCaseWord.length === 0) {
216
+ return null;
217
+ }
218
+ if (!isCamelCasePattern(word)) {
219
+ return null;
220
+ }
221
+ if (camelCaseWord.length > 60) {
222
+ return null;
223
+ }
224
+ const analysis = analyzeCamelCaseWord(camelCaseWord);
225
+ if (!isCamelCaseWord(analysis)) {
226
+ if (!isUpperCaseWord(analysis)) {
227
+ return null;
228
+ }
229
+ camelCaseWord = camelCaseWord.toLowerCase();
230
+ }
231
+ let result = null;
232
+ let i = 0;
233
+ word = word.toLowerCase();
234
+ while (i < camelCaseWord.length && (result = _matchesCamelCase(word, camelCaseWord, 0, i)) === null) {
235
+ i = nextAnchor(camelCaseWord, i + 1);
236
+ }
237
+ return result;
238
+ }
239
+ exports.matchesCamelCase = matchesCamelCase;
240
+ // Matches beginning of words supporting non-ASCII languages
241
+ // If `contiguous` is true then matches word with beginnings of the words in the target. E.g. "pul" will match "Git: Pull"
242
+ // Otherwise also matches sub string of the word with beginnings of the words in the target. E.g. "gp" or "g p" will match "Git: Pull"
243
+ // Useful in cases where the target is words (e.g. command labels)
244
+ function matchesWords(word, target, contiguous = false) {
245
+ if (!target || target.length === 0) {
246
+ return null;
247
+ }
248
+ let result = null;
249
+ let i = 0;
250
+ word = word.toLowerCase();
251
+ target = target.toLowerCase();
252
+ while (i < target.length && (result = _matchesWords(word, target, 0, i, contiguous)) === null) {
253
+ i = nextWord(target, i + 1);
254
+ }
255
+ return result;
256
+ }
257
+ exports.matchesWords = matchesWords;
258
+ function _matchesWords(word, target, i, j, contiguous) {
259
+ if (i === word.length) {
260
+ return [];
261
+ }
262
+ else if (j === target.length) {
263
+ return null;
264
+ }
265
+ else if (!charactersMatch(word.charCodeAt(i), target.charCodeAt(j))) {
266
+ return null;
267
+ }
268
+ else {
269
+ let result = null;
270
+ let nextWordIndex = j + 1;
271
+ result = _matchesWords(word, target, i + 1, j + 1, contiguous);
272
+ if (!contiguous) {
273
+ while (!result && (nextWordIndex = nextWord(target, nextWordIndex)) < target.length) {
274
+ result = _matchesWords(word, target, i + 1, nextWordIndex, contiguous);
275
+ nextWordIndex++;
276
+ }
277
+ }
278
+ return result === null ? null : join({ start: j, end: j + 1 }, result);
279
+ }
280
+ }
281
+ function nextWord(word, start) {
282
+ for (let i = start; i < word.length; i++) {
283
+ if (isWordSeparator(word.charCodeAt(i)) ||
284
+ (i > 0 && isWordSeparator(word.charCodeAt(i - 1)))) {
285
+ return i;
286
+ }
287
+ }
288
+ return word.length;
289
+ }
290
+ // Fuzzy
291
+ const fuzzyContiguousFilter = or(exports.matchesPrefix, matchesCamelCase, matchesContiguousSubString);
292
+ const fuzzySeparateFilter = or(exports.matchesPrefix, matchesCamelCase, matchesSubString);
293
+ const fuzzyRegExpCache = new map_1.LRUCache(10000); // bounded to 10000 elements
294
+ function matchesFuzzy(word, wordToMatchAgainst, enableSeparateSubstringMatching = false) {
295
+ if (typeof word !== 'string' || typeof wordToMatchAgainst !== 'string') {
296
+ return null; // return early for invalid input
297
+ }
298
+ // Form RegExp for wildcard matches
299
+ let regexp = fuzzyRegExpCache.get(word);
300
+ if (!regexp) {
301
+ regexp = new RegExp(strings.convertSimple2RegExpPattern(word), 'i');
302
+ fuzzyRegExpCache.set(word, regexp);
303
+ }
304
+ // RegExp Filter
305
+ const match = regexp.exec(wordToMatchAgainst);
306
+ if (match) {
307
+ return [{ start: match.index, end: match.index + match[0].length }];
308
+ }
309
+ // Default Filter
310
+ return enableSeparateSubstringMatching ? fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
311
+ }
312
+ exports.matchesFuzzy = matchesFuzzy;
313
+ /**
314
+ * Match pattern againt word in a fuzzy way. As in IntelliSense and faster and more
315
+ * powerfull than `matchesFuzzy`
316
+ */
317
+ function matchesFuzzy2(pattern, word) {
318
+ const score = fuzzyScore(pattern, pattern.toLowerCase(), 0, word, word.toLowerCase(), 0, true);
319
+ return score ? createMatches(score) : null;
320
+ }
321
+ exports.matchesFuzzy2 = matchesFuzzy2;
322
+ function anyScore(pattern, lowPattern, _patternPos, word, lowWord, _wordPos) {
323
+ const result = fuzzyScore(pattern, lowPattern, 0, word, lowWord, 0, true);
324
+ if (result) {
325
+ return result;
326
+ }
327
+ let matches = 0;
328
+ let score = 0;
329
+ let idx = _wordPos;
330
+ for (let patternPos = 0; patternPos < lowPattern.length && patternPos < _maxLen; ++patternPos) {
331
+ const wordPos = lowWord.indexOf(lowPattern.charAt(patternPos), idx);
332
+ if (wordPos >= 0) {
333
+ score += 1;
334
+ matches += 2 ** wordPos;
335
+ idx = wordPos + 1;
336
+ }
337
+ else if (matches !== 0) {
338
+ // once we have started matching things
339
+ // we need to match the remaining pattern
340
+ // characters
341
+ break;
342
+ }
343
+ }
344
+ return [score, matches, _wordPos];
345
+ }
346
+ exports.anyScore = anyScore;
347
+ //#region --- fuzzyScore ---
348
+ function createMatches(score) {
349
+ if (typeof score === 'undefined') {
350
+ return [];
351
+ }
352
+ const matches = score[1].toString(2);
353
+ const wordStart = score[2];
354
+ const res = [];
355
+ for (let pos = wordStart; pos < _maxLen; pos++) {
356
+ if (matches[matches.length - (pos + 1)] === '1') {
357
+ const last = res[res.length - 1];
358
+ if (last && last.end === pos) {
359
+ last.end = pos + 1;
360
+ }
361
+ else {
362
+ res.push({ start: pos, end: pos + 1 });
363
+ }
364
+ }
365
+ }
366
+ return res;
367
+ }
368
+ exports.createMatches = createMatches;
369
+ const _maxLen = 128;
370
+ function initTable() {
371
+ const table = [];
372
+ const row = [0];
373
+ for (let i = 1; i <= _maxLen; i++) {
374
+ row.push(-i);
375
+ }
376
+ for (let i = 0; i <= _maxLen; i++) {
377
+ const thisRow = row.slice(0);
378
+ thisRow[0] = -i;
379
+ table.push(thisRow);
380
+ }
381
+ return table;
382
+ }
383
+ const _table = initTable();
384
+ const _scores = initTable();
385
+ const _arrows = initTable();
386
+ const _debug = false;
387
+ function printTable(table, pattern, patternLen, word, wordLen) {
388
+ function pad(s, n, pad = ' ') {
389
+ while (s.length < n) {
390
+ s = pad + s;
391
+ }
392
+ return s;
393
+ }
394
+ let ret = ` | |${word.split('').map(c => pad(c, 3)).join('|')}\n`;
395
+ for (let i = 0; i <= patternLen; i++) {
396
+ if (i === 0) {
397
+ ret += ' |';
398
+ }
399
+ else {
400
+ ret += `${pattern[i - 1]}|`;
401
+ }
402
+ ret += table[i].slice(0, wordLen + 1).map(n => pad(n.toString(), 3)).join('|') + '\n';
403
+ }
404
+ return ret;
405
+ }
406
+ function isSeparatorAtPos(value, index) {
407
+ if (index < 0 || index >= value.length) {
408
+ return false;
409
+ }
410
+ const code = value.charCodeAt(index);
411
+ switch (code) {
412
+ case 95 /* Underline */:
413
+ case 45 /* Dash */:
414
+ case 46 /* Period */:
415
+ case 32 /* Space */:
416
+ case 47 /* Slash */:
417
+ case 92 /* Backslash */:
418
+ case 39 /* SingleQuote */:
419
+ case 34 /* DoubleQuote */:
420
+ case 58 /* Colon */:
421
+ case 36 /* DollarSign */:
422
+ return true;
423
+ default:
424
+ return false;
425
+ }
426
+ }
427
+ function isWhitespaceAtPos(value, index) {
428
+ if (index < 0 || index >= value.length) {
429
+ return false;
430
+ }
431
+ const code = value.charCodeAt(index);
432
+ switch (code) {
433
+ case 32 /* Space */:
434
+ case 9 /* Tab */:
435
+ return true;
436
+ default:
437
+ return false;
438
+ }
439
+ }
440
+ function isUpperCaseAtPos(pos, word, wordLow) {
441
+ return word[pos] !== wordLow[pos];
442
+ }
443
+ function isPatternInWord(patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) {
444
+ while (patternPos < patternLen && wordPos < wordLen) {
445
+ if (patternLow[patternPos] === wordLow[wordPos]) {
446
+ patternPos += 1;
447
+ }
448
+ wordPos += 1;
449
+ }
450
+ return patternPos === patternLen; // pattern must be exhausted
451
+ }
452
+ exports.isPatternInWord = isPatternInWord;
453
+ var FuzzyScore;
454
+ (function (FuzzyScore) {
455
+ /**
456
+ * No matches and value `-100`
457
+ */
458
+ FuzzyScore.Default = Object.freeze([-100, 0, 0]);
459
+ function isDefault(score) {
460
+ return !score || (score[0] === -100 && score[1] === 0 && score[2] === 0);
461
+ }
462
+ FuzzyScore.isDefault = isDefault;
463
+ })(FuzzyScore = exports.FuzzyScore || (exports.FuzzyScore = {}));
464
+ function fuzzyScore(pattern, patternLow, patternPos, word, wordLow, wordPos, firstMatchCanBeWeak) {
465
+ const patternLen = pattern.length > _maxLen ? _maxLen : pattern.length;
466
+ const wordLen = word.length > _maxLen ? _maxLen : word.length;
467
+ if (patternPos >= patternLen || wordPos >= wordLen || patternLen > wordLen) {
468
+ return undefined;
469
+ }
470
+ // Run a simple check if the characters of pattern occur
471
+ // (in order) at all in word. If that isn't the case we
472
+ // stop because no match will be possible
473
+ if (!isPatternInWord(patternLow, patternPos, patternLen, wordLow, wordPos, wordLen)) {
474
+ return undefined;
475
+ }
476
+ const patternStartPos = patternPos;
477
+ const wordStartPos = wordPos;
478
+ // There will be a mach, fill in tables
479
+ for (patternPos = patternStartPos + 1; patternPos <= patternLen; patternPos++) {
480
+ for (wordPos = 1; wordPos <= wordLen; wordPos++) {
481
+ let score = -1;
482
+ if (patternLow[patternPos - 1] === wordLow[wordPos - 1]) {
483
+ if (wordPos === (patternPos - patternStartPos)) {
484
+ // common prefix: `foobar <-> foobaz`
485
+ // ^^^^^
486
+ if (pattern[patternPos - 1] === word[wordPos - 1]) {
487
+ score = 7;
488
+ }
489
+ else {
490
+ score = 5;
491
+ }
492
+ }
493
+ else if (isUpperCaseAtPos(wordPos - 1, word, wordLow) && (wordPos === 1 || !isUpperCaseAtPos(wordPos - 2, word, wordLow))) {
494
+ // hitting upper-case: `foo <-> forOthers`
495
+ // ^^ ^
496
+ if (pattern[patternPos - 1] === word[wordPos - 1]) {
497
+ score = 7;
498
+ }
499
+ else {
500
+ score = 5;
501
+ }
502
+ }
503
+ else if (isSeparatorAtPos(wordLow, wordPos - 2) || isWhitespaceAtPos(wordLow, wordPos - 2)) {
504
+ // post separator: `foo <-> bar_foo`
505
+ // ^^^
506
+ score = 5;
507
+ }
508
+ else {
509
+ score = 1;
510
+ }
511
+ }
512
+ _scores[patternPos][wordPos] = score;
513
+ const diag = _table[patternPos - 1][wordPos - 1] + (score > 1 ? 1 : score);
514
+ const top = _table[patternPos - 1][wordPos] + -1;
515
+ const left = _table[patternPos][wordPos - 1] + -1;
516
+ if (left >= top) {
517
+ // left or diag
518
+ if (left > diag) {
519
+ _table[patternPos][wordPos] = left;
520
+ _arrows[patternPos][wordPos] = 4 /* Left */;
521
+ }
522
+ else if (left === diag) {
523
+ _table[patternPos][wordPos] = left;
524
+ _arrows[patternPos][wordPos] = 4 /* Left */ | 2 /* Diag */;
525
+ }
526
+ else {
527
+ _table[patternPos][wordPos] = diag;
528
+ _arrows[patternPos][wordPos] = 2 /* Diag */;
529
+ }
530
+ }
531
+ else {
532
+ // top or diag
533
+ if (top > diag) {
534
+ _table[patternPos][wordPos] = top;
535
+ _arrows[patternPos][wordPos] = 1 /* Top */;
536
+ }
537
+ else if (top === diag) {
538
+ _table[patternPos][wordPos] = top;
539
+ _arrows[patternPos][wordPos] = 1 /* Top */ | 2 /* Diag */;
540
+ }
541
+ else {
542
+ _table[patternPos][wordPos] = diag;
543
+ _arrows[patternPos][wordPos] = 2 /* Diag */;
544
+ }
545
+ }
546
+ }
547
+ }
548
+ if (_debug) {
549
+ console.log(printTable(_table, pattern, patternLen, word, wordLen));
550
+ console.log(printTable(_arrows, pattern, patternLen, word, wordLen));
551
+ console.log(printTable(_scores, pattern, patternLen, word, wordLen));
552
+ }
553
+ _matchesCount = 0;
554
+ _topScore = -100;
555
+ _patternStartPos = patternStartPos;
556
+ _firstMatchCanBeWeak = firstMatchCanBeWeak;
557
+ _findAllMatches2(patternLen, wordLen, patternLen === wordLen ? 1 : 0, 0, false);
558
+ if (_matchesCount === 0) {
559
+ return undefined;
560
+ }
561
+ return [_topScore, _topMatch2, wordStartPos];
562
+ }
563
+ exports.fuzzyScore = fuzzyScore;
564
+ let _matchesCount = 0;
565
+ let _topMatch2 = 0;
566
+ let _topScore = 0;
567
+ let _patternStartPos = 0;
568
+ let _firstMatchCanBeWeak = false;
569
+ function _findAllMatches2(patternPos, wordPos, total, matches, lastMatched) {
570
+ if (_matchesCount >= 10 || total < -25) {
571
+ // stop when having already 10 results, or
572
+ // when a potential alignment as already 5 gaps
573
+ return;
574
+ }
575
+ let simpleMatchCount = 0;
576
+ while (patternPos > _patternStartPos && wordPos > 0) {
577
+ const score = _scores[patternPos][wordPos];
578
+ const arrow = _arrows[patternPos][wordPos];
579
+ if (arrow === 4 /* Left */) {
580
+ // left -> no match, skip a word character
581
+ wordPos -= 1;
582
+ if (lastMatched) {
583
+ total -= 5; // new gap penalty
584
+ }
585
+ else if (matches !== 0) {
586
+ total -= 1; // gap penalty after first match
587
+ }
588
+ lastMatched = false;
589
+ simpleMatchCount = 0;
590
+ }
591
+ else if (arrow & 2 /* Diag */) {
592
+ if (arrow & 4 /* Left */) {
593
+ // left
594
+ _findAllMatches2(patternPos, wordPos - 1, matches !== 0 ? total - 1 : total, // gap penalty after first match
595
+ matches, lastMatched);
596
+ }
597
+ // diag
598
+ total += score;
599
+ patternPos -= 1;
600
+ wordPos -= 1;
601
+ lastMatched = true;
602
+ // match -> set a 1 at the word pos
603
+ matches += 2 ** wordPos;
604
+ // count simple matches and boost a row of
605
+ // simple matches when they yield in a
606
+ // strong match.
607
+ if (score === 1) {
608
+ simpleMatchCount += 1;
609
+ if (patternPos === _patternStartPos && !_firstMatchCanBeWeak) {
610
+ // when the first match is a weak
611
+ // match we discard it
612
+ return undefined;
613
+ }
614
+ }
615
+ else {
616
+ // boost
617
+ total += 1 + (simpleMatchCount * (score - 1));
618
+ simpleMatchCount = 0;
619
+ }
620
+ }
621
+ else {
622
+ return undefined;
623
+ }
624
+ }
625
+ total -= wordPos >= 3 ? 9 : wordPos * 3; // late start penalty
626
+ // dynamically keep track of the current top score
627
+ // and insert the current best score at head, the rest at tail
628
+ _matchesCount += 1;
629
+ if (total > _topScore) {
630
+ _topScore = total;
631
+ _topMatch2 = matches;
632
+ }
633
+ }
634
+ //#endregion
635
+ //#region --- graceful ---
636
+ function fuzzyScoreGracefulAggressive(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
637
+ return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, true, firstMatchCanBeWeak);
638
+ }
639
+ exports.fuzzyScoreGracefulAggressive = fuzzyScoreGracefulAggressive;
640
+ function fuzzyScoreGraceful(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
641
+ return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, false, firstMatchCanBeWeak);
642
+ }
643
+ exports.fuzzyScoreGraceful = fuzzyScoreGraceful;
644
+ function fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, aggressive, firstMatchCanBeWeak) {
645
+ let top = fuzzyScore(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
646
+ if (top && !aggressive) {
647
+ // when using the original pattern yield a result we`
648
+ // return it unless we are aggressive and try to find
649
+ // a better alignment, e.g. `cno` -> `^co^ns^ole` or `^c^o^nsole`.
650
+ return top;
651
+ }
652
+ if (pattern.length >= 3) {
653
+ // When the pattern is long enough then try a few (max 7)
654
+ // permutations of the pattern to find a better match. The
655
+ // permutations only swap neighbouring characters, e.g
656
+ // `cnoso` becomes `conso`, `cnsoo`, `cnoos`.
657
+ const tries = Math.min(7, pattern.length - 1);
658
+ for (let movingPatternPos = patternPos + 1; movingPatternPos < tries; movingPatternPos++) {
659
+ const newPattern = nextTypoPermutation(pattern, movingPatternPos);
660
+ if (newPattern) {
661
+ const candidate = fuzzyScore(newPattern, newPattern.toLowerCase(), patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
662
+ if (candidate) {
663
+ candidate[0] -= 3; // permutation penalty
664
+ if (!top || candidate[0] > top[0]) {
665
+ top = candidate;
666
+ }
667
+ }
668
+ }
669
+ }
670
+ }
671
+ return top;
672
+ }
673
+ function nextTypoPermutation(pattern, patternPos) {
674
+ if (patternPos + 1 >= pattern.length) {
675
+ return undefined;
676
+ }
677
+ const swap1 = pattern[patternPos];
678
+ const swap2 = pattern[patternPos + 1];
679
+ if (swap1 === swap2) {
680
+ return undefined;
681
+ }
682
+ return pattern.slice(0, patternPos)
683
+ + swap2
684
+ + swap1
685
+ + pattern.slice(patternPos + 2);
686
+ }
687
+ //#endregion
688
+ //# sourceMappingURL=filters.js.map