@opensumi/ide-core-common 1.1.4-next-1641353261.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (455) hide show
  1. package/LICENSE +21 -0
  2. package/lib/application-error.d.ts +36 -0
  3. package/lib/application-error.d.ts.map +1 -0
  4. package/lib/application-error.js +64 -0
  5. package/lib/application-error.js.map +1 -0
  6. package/lib/application-props.d.ts +26 -0
  7. package/lib/application-props.d.ts.map +1 -0
  8. package/lib/application-props.js +3 -0
  9. package/lib/application-props.js.map +1 -0
  10. package/lib/arrays.d.ts +134 -0
  11. package/lib/arrays.d.ts.map +1 -0
  12. package/lib/arrays.js +545 -0
  13. package/lib/arrays.js.map +1 -0
  14. package/lib/async.d.ts +175 -0
  15. package/lib/async.d.ts.map +1 -0
  16. package/lib/async.js +448 -0
  17. package/lib/async.js.map +1 -0
  18. package/lib/browser-fs/ensure-dir.d.ts +7 -0
  19. package/lib/browser-fs/ensure-dir.d.ts.map +1 -0
  20. package/lib/browser-fs/ensure-dir.js +40 -0
  21. package/lib/browser-fs/ensure-dir.js.map +1 -0
  22. package/lib/browser-fs/util.d.ts +18 -0
  23. package/lib/browser-fs/util.d.ts.map +1 -0
  24. package/lib/browser-fs/util.js +21 -0
  25. package/lib/browser-fs/util.js.map +1 -0
  26. package/lib/cache.d.ts +12 -0
  27. package/lib/cache.d.ts.map +1 -0
  28. package/lib/cache.js +36 -0
  29. package/lib/cache.js.map +1 -0
  30. package/lib/cancellation.d.ts +23 -0
  31. package/lib/cancellation.d.ts.map +1 -0
  32. package/lib/cancellation.js +120 -0
  33. package/lib/cancellation.js.map +1 -0
  34. package/lib/charCode.d.ts +406 -0
  35. package/lib/charCode.d.ts.map +1 -0
  36. package/lib/charCode.js +8 -0
  37. package/lib/charCode.js.map +1 -0
  38. package/lib/character-classifier.d.ts +25 -0
  39. package/lib/character-classifier.d.ts.map +1 -0
  40. package/lib/character-classifier.js +59 -0
  41. package/lib/character-classifier.js.map +1 -0
  42. package/lib/command.d.ts +334 -0
  43. package/lib/command.d.ts.map +1 -0
  44. package/lib/command.js +414 -0
  45. package/lib/command.js.map +1 -0
  46. package/lib/connection.d.ts +8 -0
  47. package/lib/connection.d.ts.map +1 -0
  48. package/lib/connection.js +14 -0
  49. package/lib/connection.js.map +1 -0
  50. package/lib/const/application.d.ts +5 -0
  51. package/lib/const/application.d.ts.map +1 -0
  52. package/lib/const/application.js +8 -0
  53. package/lib/const/application.js.map +1 -0
  54. package/lib/const/encodings.d.ts +10 -0
  55. package/lib/const/encodings.d.ts.map +1 -0
  56. package/lib/const/encodings.js +244 -0
  57. package/lib/const/encodings.js.map +1 -0
  58. package/lib/const/index.d.ts +2 -0
  59. package/lib/const/index.d.ts.map +1 -0
  60. package/lib/const/index.js +5 -0
  61. package/lib/const/index.js.map +1 -0
  62. package/lib/contribution-provider.d.ts +38 -0
  63. package/lib/contribution-provider.d.ts.map +1 -0
  64. package/lib/contribution-provider.js +60 -0
  65. package/lib/contribution-provider.js.map +1 -0
  66. package/lib/credential.d.ts +21 -0
  67. package/lib/credential.d.ts.map +1 -0
  68. package/lib/credential.js +6 -0
  69. package/lib/credential.js.map +1 -0
  70. package/lib/cryptr.d.ts +7 -0
  71. package/lib/cryptr.d.ts.map +1 -0
  72. package/lib/cryptr.js +6 -0
  73. package/lib/cryptr.js.map +1 -0
  74. package/lib/date.d.ts +2 -0
  75. package/lib/date.d.ts.map +1 -0
  76. package/lib/date.js +22 -0
  77. package/lib/date.js.map +1 -0
  78. package/lib/declare.d.ts +3 -0
  79. package/lib/declare.d.ts.map +1 -0
  80. package/lib/declare.js +3 -0
  81. package/lib/declare.js.map +1 -0
  82. package/lib/di-helper/domain-helper.d.ts +14 -0
  83. package/lib/di-helper/domain-helper.d.ts.map +1 -0
  84. package/lib/di-helper/domain-helper.js +48 -0
  85. package/lib/di-helper/domain-helper.js.map +1 -0
  86. package/lib/di-helper/index.d.ts +2 -0
  87. package/lib/di-helper/index.d.ts.map +1 -0
  88. package/lib/di-helper/index.js +5 -0
  89. package/lib/di-helper/index.js.map +1 -0
  90. package/lib/disposable.d.ts +88 -0
  91. package/lib/disposable.d.ts.map +1 -0
  92. package/lib/disposable.js +312 -0
  93. package/lib/disposable.js.map +1 -0
  94. package/lib/electron.d.ts +117 -0
  95. package/lib/electron.d.ts.map +1 -0
  96. package/lib/electron.js +7 -0
  97. package/lib/electron.js.map +1 -0
  98. package/lib/encoding/index.d.ts +34 -0
  99. package/lib/encoding/index.d.ts.map +1 -0
  100. package/lib/encoding/index.js +219 -0
  101. package/lib/encoding/index.js.map +1 -0
  102. package/lib/env.d.ts +2 -0
  103. package/lib/env.d.ts.map +1 -0
  104. package/lib/env.js +5 -0
  105. package/lib/env.js.map +1 -0
  106. package/lib/errors.d.ts +56 -0
  107. package/lib/errors.d.ts.map +1 -0
  108. package/lib/errors.js +148 -0
  109. package/lib/errors.js.map +1 -0
  110. package/lib/event-bus/basic-event.d.ts +5 -0
  111. package/lib/event-bus/basic-event.d.ts.map +1 -0
  112. package/lib/event-bus/basic-event.js +10 -0
  113. package/lib/event-bus/basic-event.js.map +1 -0
  114. package/lib/event-bus/event-bus-types.d.ts +64 -0
  115. package/lib/event-bus/event-bus-types.d.ts.map +1 -0
  116. package/lib/event-bus/event-bus-types.js +5 -0
  117. package/lib/event-bus/event-bus-types.js.map +1 -0
  118. package/lib/event-bus/event-bus.d.ts +13 -0
  119. package/lib/event-bus/event-bus.d.ts.map +1 -0
  120. package/lib/event-bus/event-bus.js +53 -0
  121. package/lib/event-bus/event-bus.js.map +1 -0
  122. package/lib/event-bus/event-decorator.d.ts +10 -0
  123. package/lib/event-bus/event-decorator.d.ts.map +1 -0
  124. package/lib/event-bus/event-decorator.js +32 -0
  125. package/lib/event-bus/event-decorator.js.map +1 -0
  126. package/lib/event-bus/index.d.ts +5 -0
  127. package/lib/event-bus/index.d.ts.map +1 -0
  128. package/lib/event-bus/index.js +8 -0
  129. package/lib/event-bus/index.js.map +1 -0
  130. package/lib/event.d.ts +268 -0
  131. package/lib/event.d.ts.map +1 -0
  132. package/lib/event.js +814 -0
  133. package/lib/event.js.map +1 -0
  134. package/lib/filters.d.ts +47 -0
  135. package/lib/filters.d.ts.map +1 -0
  136. package/lib/filters.js +696 -0
  137. package/lib/filters.js.map +1 -0
  138. package/lib/functional.d.ts +4 -0
  139. package/lib/functional.d.ts.map +1 -0
  140. package/lib/functional.js +45 -0
  141. package/lib/functional.js.map +1 -0
  142. package/lib/hash-calculate/WASMInterface.d.ts +61 -0
  143. package/lib/hash-calculate/WASMInterface.d.ts.map +1 -0
  144. package/lib/hash-calculate/WASMInterface.js +180 -0
  145. package/lib/hash-calculate/WASMInterface.js.map +1 -0
  146. package/lib/hash-calculate/hash-calculate.d.ts +13 -0
  147. package/lib/hash-calculate/hash-calculate.d.ts.map +1 -0
  148. package/lib/hash-calculate/hash-calculate.js +36 -0
  149. package/lib/hash-calculate/hash-calculate.js.map +1 -0
  150. package/lib/hash-calculate/lockedCreate.d.ts +4 -0
  151. package/lib/hash-calculate/lockedCreate.d.ts.map +1 -0
  152. package/lib/hash-calculate/lockedCreate.js +17 -0
  153. package/lib/hash-calculate/lockedCreate.js.map +1 -0
  154. package/lib/hash-calculate/md5.wasm.json +1 -0
  155. package/lib/hash-calculate/mutex.d.ts +6 -0
  156. package/lib/hash-calculate/mutex.d.ts.map +1 -0
  157. package/lib/hash-calculate/mutex.js +32 -0
  158. package/lib/hash-calculate/mutex.js.map +1 -0
  159. package/lib/hash-calculate/util.d.ts +12 -0
  160. package/lib/hash-calculate/util.d.ts.map +1 -0
  161. package/lib/hash-calculate/util.js +167 -0
  162. package/lib/hash-calculate/util.js.map +1 -0
  163. package/lib/id-generator.d.ts +8 -0
  164. package/lib/id-generator.d.ts.map +1 -0
  165. package/lib/id-generator.js +15 -0
  166. package/lib/id-generator.js.map +1 -0
  167. package/lib/index.d.ts +48 -0
  168. package/lib/index.d.ts.map +1 -0
  169. package/lib/index.js +51 -0
  170. package/lib/index.js.map +1 -0
  171. package/lib/iterator.d.ts +17 -0
  172. package/lib/iterator.d.ts.map +1 -0
  173. package/lib/iterator.js +24 -0
  174. package/lib/iterator.js.map +1 -0
  175. package/lib/json-schema.d.ts +65 -0
  176. package/lib/json-schema.d.ts.map +1 -0
  177. package/lib/json-schema.js +3 -0
  178. package/lib/json-schema.js.map +1 -0
  179. package/lib/keyboard/index.d.ts +3 -0
  180. package/lib/keyboard/index.d.ts.map +1 -0
  181. package/lib/keyboard/index.js +6 -0
  182. package/lib/keyboard/index.js.map +1 -0
  183. package/lib/keyboard/keyboard-layout-provider.d.ts +38 -0
  184. package/lib/keyboard/keyboard-layout-provider.d.ts.map +1 -0
  185. package/lib/keyboard/keyboard-layout-provider.js +23 -0
  186. package/lib/keyboard/keyboard-layout-provider.js.map +1 -0
  187. package/lib/keyboard/keymap.d.ts +71 -0
  188. package/lib/keyboard/keymap.d.ts.map +1 -0
  189. package/lib/keyboard/keymap.js +129 -0
  190. package/lib/keyboard/keymap.js.map +1 -0
  191. package/lib/lifecycle.d.ts +17 -0
  192. package/lib/lifecycle.d.ts.map +1 -0
  193. package/lib/lifecycle.js +39 -0
  194. package/lib/lifecycle.js.map +1 -0
  195. package/lib/line-text.d.ts +17 -0
  196. package/lib/line-text.d.ts.map +1 -0
  197. package/lib/line-text.js +71 -0
  198. package/lib/line-text.js.map +1 -0
  199. package/lib/linked-list.d.ts +18 -0
  200. package/lib/linked-list.d.ts.map +1 -0
  201. package/lib/linked-list.js +138 -0
  202. package/lib/linked-list.js.map +1 -0
  203. package/lib/linkedText.d.ts +13 -0
  204. package/lib/linkedText.d.ts.map +1 -0
  205. package/lib/linkedText.js +50 -0
  206. package/lib/linkedText.js.map +1 -0
  207. package/lib/localize.d.ts +52 -0
  208. package/lib/localize.d.ts.map +1 -0
  209. package/lib/localize.js +128 -0
  210. package/lib/localize.js.map +1 -0
  211. package/lib/log.d.ts +179 -0
  212. package/lib/log.d.ts.map +1 -0
  213. package/lib/log.js +160 -0
  214. package/lib/log.js.map +1 -0
  215. package/lib/map.d.ts +124 -0
  216. package/lib/map.d.ts.map +1 -0
  217. package/lib/map.js +819 -0
  218. package/lib/map.js.map +1 -0
  219. package/lib/menu.d.ts +27 -0
  220. package/lib/menu.d.ts.map +1 -0
  221. package/lib/menu.js +5 -0
  222. package/lib/menu.js.map +1 -0
  223. package/lib/mocks/electron/browserMock.d.ts +2 -0
  224. package/lib/mocks/electron/browserMock.d.ts.map +1 -0
  225. package/lib/mocks/electron/browserMock.js +13 -0
  226. package/lib/mocks/electron/browserMock.js.map +1 -0
  227. package/lib/mocks/electron/ipcRenderer.d.ts +13 -0
  228. package/lib/mocks/electron/ipcRenderer.d.ts.map +1 -0
  229. package/lib/mocks/electron/ipcRenderer.js +31 -0
  230. package/lib/mocks/electron/ipcRenderer.js.map +1 -0
  231. package/lib/module.d.ts +23 -0
  232. package/lib/module.d.ts.map +1 -0
  233. package/lib/module.js +22 -0
  234. package/lib/module.js.map +1 -0
  235. package/lib/network.d.ts +33 -0
  236. package/lib/network.d.ts.map +1 -0
  237. package/lib/network.js +37 -0
  238. package/lib/network.js.map +1 -0
  239. package/lib/node/port.d.ts +14 -0
  240. package/lib/node/port.d.ts.map +1 -0
  241. package/lib/node/port.js +124 -0
  242. package/lib/node/port.js.map +1 -0
  243. package/lib/path.d.ts +92 -0
  244. package/lib/path.d.ts.map +1 -0
  245. package/lib/path.js +1695 -0
  246. package/lib/path.js.map +1 -0
  247. package/lib/platform.d.ts +48 -0
  248. package/lib/platform.d.ts.map +1 -0
  249. package/lib/platform.js +153 -0
  250. package/lib/platform.js.map +1 -0
  251. package/lib/preferences/index.d.ts +3 -0
  252. package/lib/preferences/index.d.ts.map +1 -0
  253. package/lib/preferences/index.js +6 -0
  254. package/lib/preferences/index.js.map +1 -0
  255. package/lib/preferences/preference-schema.d.ts +76 -0
  256. package/lib/preferences/preference-schema.d.ts.map +1 -0
  257. package/lib/preferences/preference-schema.js +59 -0
  258. package/lib/preferences/preference-schema.js.map +1 -0
  259. package/lib/preferences/preference-scope.d.ts +15 -0
  260. package/lib/preferences/preference-scope.d.ts.map +1 -0
  261. package/lib/preferences/preference-scope.js +53 -0
  262. package/lib/preferences/preference-scope.js.map +1 -0
  263. package/lib/problem-matcher.d.ts +111 -0
  264. package/lib/problem-matcher.d.ts.map +1 -0
  265. package/lib/problem-matcher.js +296 -0
  266. package/lib/problem-matcher.js.map +1 -0
  267. package/lib/problem-pattern.d.ts +193 -0
  268. package/lib/problem-pattern.d.ts.map +1 -0
  269. package/lib/problem-pattern.js +420 -0
  270. package/lib/problem-pattern.js.map +1 -0
  271. package/lib/process.d.ts +5 -0
  272. package/lib/process.d.ts.map +1 -0
  273. package/lib/process.js +23 -0
  274. package/lib/process.js.map +1 -0
  275. package/lib/progress.d.ts +56 -0
  276. package/lib/progress.d.ts.map +1 -0
  277. package/lib/progress.js +27 -0
  278. package/lib/progress.js.map +1 -0
  279. package/lib/range.d.ts +7 -0
  280. package/lib/range.d.ts.map +1 -0
  281. package/lib/range.js +28 -0
  282. package/lib/range.js.map +1 -0
  283. package/lib/reference.d.ts +35 -0
  284. package/lib/reference.d.ts.map +1 -0
  285. package/lib/reference.js +120 -0
  286. package/lib/reference.js.map +1 -0
  287. package/lib/reporter.d.ts +16 -0
  288. package/lib/reporter.d.ts.map +1 -0
  289. package/lib/reporter.js +65 -0
  290. package/lib/reporter.js.map +1 -0
  291. package/lib/sequence.d.ts +20 -0
  292. package/lib/sequence.d.ts.map +1 -0
  293. package/lib/sequence.js +17 -0
  294. package/lib/sequence.js.map +1 -0
  295. package/lib/storage.d.ts +64 -0
  296. package/lib/storage.d.ts.map +1 -0
  297. package/lib/storage.js +70 -0
  298. package/lib/storage.js.map +1 -0
  299. package/lib/task-definition.d.ts +45 -0
  300. package/lib/task-definition.d.ts.map +1 -0
  301. package/lib/task-definition.js +130 -0
  302. package/lib/task-definition.js.map +1 -0
  303. package/lib/theme.d.ts +5 -0
  304. package/lib/theme.d.ts.map +1 -0
  305. package/lib/theme.js +8 -0
  306. package/lib/theme.js.map +1 -0
  307. package/lib/types/accessibility.d.ts +5 -0
  308. package/lib/types/accessibility.d.ts.map +1 -0
  309. package/lib/types/accessibility.js +3 -0
  310. package/lib/types/accessibility.js.map +1 -0
  311. package/lib/types/application.d.ts +13 -0
  312. package/lib/types/application.d.ts.map +1 -0
  313. package/lib/types/application.js +5 -0
  314. package/lib/types/application.js.map +1 -0
  315. package/lib/types/authentication.d.ts +90 -0
  316. package/lib/types/authentication.d.ts.map +1 -0
  317. package/lib/types/authentication.js +8 -0
  318. package/lib/types/authentication.js.map +1 -0
  319. package/lib/types/common.d.ts +10 -0
  320. package/lib/types/common.d.ts.map +1 -0
  321. package/lib/types/common.js +6 -0
  322. package/lib/types/common.js.map +1 -0
  323. package/lib/types/dnd.d.ts +8 -0
  324. package/lib/types/dnd.d.ts.map +1 -0
  325. package/lib/types/dnd.js +8 -0
  326. package/lib/types/dnd.js.map +1 -0
  327. package/lib/types/editor.d.ts +157 -0
  328. package/lib/types/editor.d.ts.map +1 -0
  329. package/lib/types/editor.js +143 -0
  330. package/lib/types/editor.js.map +1 -0
  331. package/lib/types/extension.d.ts +75 -0
  332. package/lib/types/extension.d.ts.map +1 -0
  333. package/lib/types/extension.js +31 -0
  334. package/lib/types/extension.js.map +1 -0
  335. package/lib/types/file-watch.d.ts +70 -0
  336. package/lib/types/file-watch.d.ts.map +1 -0
  337. package/lib/types/file-watch.js +72 -0
  338. package/lib/types/file-watch.js.map +1 -0
  339. package/lib/types/file.d.ts +219 -0
  340. package/lib/types/file.d.ts.map +1 -0
  341. package/lib/types/file.js +52 -0
  342. package/lib/types/file.js.map +1 -0
  343. package/lib/types/index.d.ts +13 -0
  344. package/lib/types/index.d.ts.map +1 -0
  345. package/lib/types/index.js +16 -0
  346. package/lib/types/index.js.map +1 -0
  347. package/lib/types/markers/index.d.ts +3 -0
  348. package/lib/types/markers/index.d.ts.map +1 -0
  349. package/lib/types/markers/index.js +6 -0
  350. package/lib/types/markers/index.js.map +1 -0
  351. package/lib/types/markers/markers-manager.d.ts +120 -0
  352. package/lib/types/markers/markers-manager.d.ts.map +1 -0
  353. package/lib/types/markers/markers-manager.js +308 -0
  354. package/lib/types/markers/markers-manager.js.map +1 -0
  355. package/lib/types/markers/markers.d.ts +76 -0
  356. package/lib/types/markers/markers.d.ts.map +1 -0
  357. package/lib/types/markers/markers.js +77 -0
  358. package/lib/types/markers/markers.js.map +1 -0
  359. package/lib/types/message.d.ts +7 -0
  360. package/lib/types/message.d.ts.map +1 -0
  361. package/lib/types/message.js +11 -0
  362. package/lib/types/message.js.map +1 -0
  363. package/lib/types/reporter.d.ts +83 -0
  364. package/lib/types/reporter.d.ts.map +1 -0
  365. package/lib/types/reporter.js +63 -0
  366. package/lib/types/reporter.js.map +1 -0
  367. package/lib/types/string.d.ts +4 -0
  368. package/lib/types/string.d.ts.map +1 -0
  369. package/lib/types/string.js +3 -0
  370. package/lib/types/string.js.map +1 -0
  371. package/lib/uint.d.ts +32 -0
  372. package/lib/uint.d.ts.map +1 -0
  373. package/lib/uint.js +28 -0
  374. package/lib/uint.js.map +1 -0
  375. package/lib/uri.d.ts +94 -0
  376. package/lib/uri.d.ts.map +1 -0
  377. package/lib/uri.js +230 -0
  378. package/lib/uri.js.map +1 -0
  379. package/lib/utils/ansi.d.ts +5 -0
  380. package/lib/utils/ansi.d.ts.map +1 -0
  381. package/lib/utils/ansi.js +14 -0
  382. package/lib/utils/ansi.js.map +1 -0
  383. package/lib/utils/arrays.d.ts +62 -0
  384. package/lib/utils/arrays.d.ts.map +1 -0
  385. package/lib/utils/arrays.js +252 -0
  386. package/lib/utils/arrays.js.map +1 -0
  387. package/lib/utils/buffer.d.ts +35 -0
  388. package/lib/utils/buffer.d.ts.map +1 -0
  389. package/lib/utils/buffer.js +174 -0
  390. package/lib/utils/buffer.js.map +1 -0
  391. package/lib/utils/comparers.d.ts +7 -0
  392. package/lib/utils/comparers.d.ts.map +1 -0
  393. package/lib/utils/comparers.js +136 -0
  394. package/lib/utils/comparers.js.map +1 -0
  395. package/lib/utils/decorators.d.ts +11 -0
  396. package/lib/utils/decorators.d.ts.map +1 -0
  397. package/lib/utils/decorators.js +150 -0
  398. package/lib/utils/decorators.js.map +1 -0
  399. package/lib/utils/file-uri.d.ts +30 -0
  400. package/lib/utils/file-uri.d.ts.map +1 -0
  401. package/lib/utils/file-uri.js +61 -0
  402. package/lib/utils/file-uri.js.map +1 -0
  403. package/lib/utils/glob.d.ts +46 -0
  404. package/lib/utils/glob.d.ts.map +1 -0
  405. package/lib/utils/glob.js +556 -0
  406. package/lib/utils/glob.js.map +1 -0
  407. package/lib/utils/hash.d.ts +38 -0
  408. package/lib/utils/hash.d.ts.map +1 -0
  409. package/lib/utils/hash.js +294 -0
  410. package/lib/utils/hash.js.map +1 -0
  411. package/lib/utils/index.d.ts +14 -0
  412. package/lib/utils/index.d.ts.map +1 -0
  413. package/lib/utils/index.js +17 -0
  414. package/lib/utils/index.js.map +1 -0
  415. package/lib/utils/ipc.d.ts +2 -0
  416. package/lib/utils/ipc.d.ts.map +1 -0
  417. package/lib/utils/ipc.js +21 -0
  418. package/lib/utils/ipc.js.map +1 -0
  419. package/lib/utils/json.d.ts +76 -0
  420. package/lib/utils/json.d.ts.map +1 -0
  421. package/lib/utils/json.js +188 -0
  422. package/lib/utils/json.js.map +1 -0
  423. package/lib/utils/marshalling.d.ts +7 -0
  424. package/lib/utils/marshalling.d.ts.map +1 -0
  425. package/lib/utils/marshalling.js +59 -0
  426. package/lib/utils/marshalling.js.map +1 -0
  427. package/lib/utils/objects.d.ts +6 -0
  428. package/lib/utils/objects.d.ts.map +1 -0
  429. package/lib/utils/objects.js +103 -0
  430. package/lib/utils/objects.js.map +1 -0
  431. package/lib/utils/os.d.ts +42 -0
  432. package/lib/utils/os.d.ts.map +1 -0
  433. package/lib/utils/os.js +91 -0
  434. package/lib/utils/os.js.map +1 -0
  435. package/lib/utils/paths.d.ts +35 -0
  436. package/lib/utils/paths.d.ts.map +1 -0
  437. package/lib/utils/paths.js +313 -0
  438. package/lib/utils/paths.js.map +1 -0
  439. package/lib/utils/promise-util.d.ts +10 -0
  440. package/lib/utils/promise-util.d.ts.map +1 -0
  441. package/lib/utils/promise-util.js +17 -0
  442. package/lib/utils/promise-util.js.map +1 -0
  443. package/lib/utils/strings.d.ts +177 -0
  444. package/lib/utils/strings.d.ts.map +1 -0
  445. package/lib/utils/strings.js +844 -0
  446. package/lib/utils/strings.js.map +1 -0
  447. package/lib/utils/types.d.ts +69 -0
  448. package/lib/utils/types.d.ts.map +1 -0
  449. package/lib/utils/types.js +201 -0
  450. package/lib/utils/types.js.map +1 -0
  451. package/lib/uuid.d.ts +2 -0
  452. package/lib/uuid.d.ts.map +1 -0
  453. package/lib/uuid.js +10 -0
  454. package/lib/uuid.js.map +1 -0
  455. package/package.json +31 -0
@@ -0,0 +1,844 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.uppercaseFirstLetter = exports.containsUppercaseCharacter = exports.fuzzyContains = exports.repeat = exports.safeBtoa = exports.stripUTF8BOM = exports.startsWithUTF8BOM = exports.UTF8_BOM_CHARACTER = exports.removeAccents = exports.removeAnsiEscapeCodes = exports.lcut = exports.isFullWidthCharacter = exports.containsFullWidthCharacter = exports.isBasicASCII = exports.containsEmoji = exports.containsRTL = exports.isLowSurrogate = exports.isHighSurrogate = exports.overlap = exports.commonSuffixLength = exports.commonPrefixLength = exports.startsWithIgnoreCase = exports.equalsIgnoreCase = exports.isUpperAsciiLetter = exports.isLowerAsciiLetter = exports.compareIgnoreCase = exports.compare = exports.lastNonWhitespaceIndex = exports.getLeadingWhitespace = exports.firstNonWhitespaceIndex = exports.regExpFlags = exports.regExpContainsBackreference = exports.regExpLeadsToEndlessLoop = exports.createRegExp = exports.endsWith = exports.startsWith = exports.stripWildcards = exports.convertSimple2RegExpPattern = exports.rtrim = exports.multiRightTrim = exports.ltrim = exports.trim = exports.escapeRegExpCharacters = exports.escape = exports.mnemonicButtonLabel = exports.format = exports.pad = exports.isFalsyOrWhitespace = exports.stringUtils = exports.empty = void 0;
4
+ exports.decodeUTF8 = exports.encodeUTF8 = exports.getNextCodePoint = exports.computeCodePoint = exports.getNLines = void 0;
5
+ const os_1 = require("./os");
6
+ /**
7
+ * The empty string.
8
+ */
9
+ exports.empty = '';
10
+ const hasTextEncoder = typeof TextEncoder !== 'undefined';
11
+ const hasTextDecoder = typeof TextDecoder !== 'undefined';
12
+ /**
13
+ * 浏览器全局可以直接使用 TextEncoder/TextDecoder
14
+ * Node.js 11+ 才可以全局使用,以下需要 require('util')
15
+ */
16
+ var stringUtils;
17
+ (function (stringUtils) {
18
+ stringUtils.StringTextEncoder = hasTextEncoder ? TextEncoder : require('util').TextEncoder;
19
+ stringUtils.StringTextDecoder = hasTextDecoder ? TextDecoder : require('util').TextDecoder;
20
+ })(stringUtils = exports.stringUtils || (exports.stringUtils = {}));
21
+ function isFalsyOrWhitespace(str) {
22
+ if (!str || typeof str !== 'string') {
23
+ return true;
24
+ }
25
+ return str.trim().length === 0;
26
+ }
27
+ exports.isFalsyOrWhitespace = isFalsyOrWhitespace;
28
+ /**
29
+ * @returns the provided number with the given number of preceding zeros.
30
+ */
31
+ function pad(n, l, char = '0') {
32
+ const str = '' + n;
33
+ const r = [str];
34
+ for (let i = str.length; i < l; i++) {
35
+ r.push(char);
36
+ }
37
+ return r.reverse().join('');
38
+ }
39
+ exports.pad = pad;
40
+ const _formatRegexp = /{(\d+)}/g;
41
+ /**
42
+ * Helper to produce a string with a variable number of arguments. Insert variable segments
43
+ * into the string using the {n} notation where N is the index of the argument following the string.
44
+ * @param value string to which formatting is applied
45
+ * @param args replacements for {n}-entries
46
+ */
47
+ function format(value, ...args) {
48
+ if (args.length === 0) {
49
+ return value;
50
+ }
51
+ return value.replace(_formatRegexp, function (match, group) {
52
+ const idx = parseInt(group, 10);
53
+ return isNaN(idx) || idx < 0 || idx >= args.length ? match : args[idx];
54
+ });
55
+ }
56
+ exports.format = format;
57
+ /**
58
+ * Handles mnemonics for buttons. Depending on OS:
59
+ * - Windows: Supported via & character (replace && with & and & with && for escaping)
60
+ * - Linux: Supported via _ character (replace && with _)
61
+ * - macOS: Unsupported (replace && with empty string)
62
+ */
63
+ function mnemonicButtonLabel(label, forceDisableMnemonics) {
64
+ if (os_1.isOSX || forceDisableMnemonics) {
65
+ return label.replace(/\(&&\w\)|&&/g, '');
66
+ }
67
+ if (os_1.isWindows) {
68
+ return label.replace(/&&|&/g, (m) => (m === '&' ? '&&' : '&'));
69
+ }
70
+ return label.replace(/&&/g, '_');
71
+ }
72
+ exports.mnemonicButtonLabel = mnemonicButtonLabel;
73
+ /**
74
+ * Converts HTML characters inside the string to use entities instead. Makes the string safe from
75
+ * being used e.g. in HTMLElement.innerHTML.
76
+ */
77
+ function escape(html) {
78
+ return html.replace(/[<>&]/g, function (match) {
79
+ switch (match) {
80
+ case '<':
81
+ return '&lt;';
82
+ case '>':
83
+ return '&gt;';
84
+ case '&':
85
+ return '&amp;';
86
+ default:
87
+ return match;
88
+ }
89
+ });
90
+ }
91
+ exports.escape = escape;
92
+ /**
93
+ * Escapes regular expression characters in a given string
94
+ */
95
+ function escapeRegExpCharacters(value) {
96
+ return value.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g, '\\$&');
97
+ }
98
+ exports.escapeRegExpCharacters = escapeRegExpCharacters;
99
+ /**
100
+ * Removes all occurrences of needle from the beginning and end of haystack.
101
+ * @param haystack string to trim
102
+ * @param needle the thing to trim (default is a blank)
103
+ */
104
+ function trim(haystack, needle = ' ') {
105
+ const trimmed = ltrim(haystack, needle);
106
+ return rtrim(trimmed, needle);
107
+ }
108
+ exports.trim = trim;
109
+ /**
110
+ * Removes all occurrences of needle from the beginning of haystack.
111
+ * @param haystack string to trim
112
+ * @param needle the thing to trim
113
+ */
114
+ function ltrim(haystack, needle) {
115
+ if (!haystack || !needle) {
116
+ return haystack;
117
+ }
118
+ const needleLen = needle.length;
119
+ if (needleLen === 0 || haystack.length === 0) {
120
+ return haystack;
121
+ }
122
+ let offset = 0;
123
+ while (haystack.indexOf(needle, offset) === offset) {
124
+ offset = offset + needleLen;
125
+ }
126
+ return haystack.substring(offset);
127
+ }
128
+ exports.ltrim = ltrim;
129
+ /**
130
+ * Removes all occurrences of needles from the end of haystack.
131
+ * @param source
132
+ * @param needles
133
+ * @example
134
+ * ```ts
135
+ * let source = '/path/to/file.ts,;';
136
+ * const res = multiRightTrim(source, [`,`, ';']);
137
+ * // res === '/path/to/file.ts';
138
+ * ```
139
+ */
140
+ function multiRightTrim(source, needles) {
141
+ let result = decodeURIComponent(source);
142
+ for (const needle of needles) {
143
+ result = rtrim(result, needle);
144
+ }
145
+ return result;
146
+ }
147
+ exports.multiRightTrim = multiRightTrim;
148
+ /**
149
+ * Removes all occurrences of needle from the end of haystack.
150
+ * @param haystack string to trim
151
+ * @param needle the thing to trim
152
+ */
153
+ function rtrim(haystack, needle) {
154
+ if (!haystack || !needle) {
155
+ return haystack;
156
+ }
157
+ const needleLen = needle.length;
158
+ const haystackLen = haystack.length;
159
+ if (needleLen === 0 || haystackLen === 0) {
160
+ return haystack;
161
+ }
162
+ let offset = haystackLen;
163
+ let idx = -1;
164
+ while (true) {
165
+ idx = haystack.lastIndexOf(needle, offset - 1);
166
+ if (idx === -1 || idx + needleLen !== offset) {
167
+ break;
168
+ }
169
+ if (idx === 0) {
170
+ return '';
171
+ }
172
+ offset = idx;
173
+ }
174
+ return haystack.substring(0, offset);
175
+ }
176
+ exports.rtrim = rtrim;
177
+ function convertSimple2RegExpPattern(pattern) {
178
+ return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
179
+ }
180
+ exports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;
181
+ function stripWildcards(pattern) {
182
+ return pattern.replace(/\*/g, '');
183
+ }
184
+ exports.stripWildcards = stripWildcards;
185
+ /**
186
+ * Determines if haystack starts with needle.
187
+ */
188
+ function startsWith(haystack, needle) {
189
+ if (haystack.length < needle.length) {
190
+ return false;
191
+ }
192
+ if (haystack === needle) {
193
+ return true;
194
+ }
195
+ for (let i = 0; i < needle.length; i++) {
196
+ if (haystack[i] !== needle[i]) {
197
+ return false;
198
+ }
199
+ }
200
+ return true;
201
+ }
202
+ exports.startsWith = startsWith;
203
+ /**
204
+ * Determines if haystack ends with needle.
205
+ */
206
+ function endsWith(haystack, needle) {
207
+ const diff = haystack.length - needle.length;
208
+ if (diff > 0) {
209
+ return haystack.indexOf(needle, diff) === diff;
210
+ }
211
+ else if (diff === 0) {
212
+ return haystack === needle;
213
+ }
214
+ else {
215
+ return false;
216
+ }
217
+ }
218
+ exports.endsWith = endsWith;
219
+ function createRegExp(searchString, isRegex, options = {}) {
220
+ if (!searchString) {
221
+ throw new Error('Cannot create regex from empty string');
222
+ }
223
+ if (!isRegex) {
224
+ searchString = escapeRegExpCharacters(searchString);
225
+ }
226
+ if (options.wholeWord) {
227
+ if (!/\B/.test(searchString.charAt(0))) {
228
+ searchString = '\\b' + searchString;
229
+ }
230
+ if (!/\B/.test(searchString.charAt(searchString.length - 1))) {
231
+ searchString = searchString + '\\b';
232
+ }
233
+ }
234
+ let modifiers = '';
235
+ if (options.global) {
236
+ modifiers += 'g';
237
+ }
238
+ if (!options.matchCase) {
239
+ modifiers += 'i';
240
+ }
241
+ if (options.multiline) {
242
+ modifiers += 'm';
243
+ }
244
+ if (options.unicode) {
245
+ modifiers += 'u';
246
+ }
247
+ return new RegExp(searchString, modifiers);
248
+ }
249
+ exports.createRegExp = createRegExp;
250
+ function regExpLeadsToEndlessLoop(regexp) {
251
+ // Exit early if it's one of these special cases which are meant to match
252
+ // against an empty string
253
+ if (regexp.source === '^' || regexp.source === '^$' || regexp.source === '$' || regexp.source === '^\\s*$') {
254
+ return false;
255
+ }
256
+ // We check against an empty string. If the regular expression doesn't advance
257
+ // (e.g. ends in an endless loop) it will match an empty string.
258
+ const match = regexp.exec('');
259
+ return !!(match && regexp.lastIndex === 0);
260
+ }
261
+ exports.regExpLeadsToEndlessLoop = regExpLeadsToEndlessLoop;
262
+ function regExpContainsBackreference(regexpValue) {
263
+ return !!regexpValue.match(/([^\\]|^)(\\\\)*\\\d+/);
264
+ }
265
+ exports.regExpContainsBackreference = regExpContainsBackreference;
266
+ function regExpFlags(regexp) {
267
+ return ((regexp.global ? 'g' : '') +
268
+ (regexp.ignoreCase ? 'i' : '') +
269
+ (regexp.multiline ? 'm' : '') +
270
+ (regexp.unicode ? 'u' : ''));
271
+ }
272
+ exports.regExpFlags = regExpFlags;
273
+ /**
274
+ * Returns first index of the string that is not whitespace.
275
+ * If string is empty or contains only whitespaces, returns -1
276
+ */
277
+ function firstNonWhitespaceIndex(str) {
278
+ for (let i = 0, len = str.length; i < len; i++) {
279
+ const chCode = str.charCodeAt(i);
280
+ if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
281
+ return i;
282
+ }
283
+ }
284
+ return -1;
285
+ }
286
+ exports.firstNonWhitespaceIndex = firstNonWhitespaceIndex;
287
+ /**
288
+ * Returns the leading whitespace of the string.
289
+ * If the string contains only whitespaces, returns entire string
290
+ */
291
+ function getLeadingWhitespace(str, start = 0, end = str.length) {
292
+ for (let i = start; i < end; i++) {
293
+ const chCode = str.charCodeAt(i);
294
+ if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
295
+ return str.substring(start, i);
296
+ }
297
+ }
298
+ return str.substring(start, end);
299
+ }
300
+ exports.getLeadingWhitespace = getLeadingWhitespace;
301
+ /**
302
+ * Returns last index of the string that is not whitespace.
303
+ * If string is empty or contains only whitespaces, returns -1
304
+ */
305
+ function lastNonWhitespaceIndex(str, startIndex = str.length - 1) {
306
+ for (let i = startIndex; i >= 0; i--) {
307
+ const chCode = str.charCodeAt(i);
308
+ if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
309
+ return i;
310
+ }
311
+ }
312
+ return -1;
313
+ }
314
+ exports.lastNonWhitespaceIndex = lastNonWhitespaceIndex;
315
+ function compare(a, b) {
316
+ if (a < b) {
317
+ return -1;
318
+ }
319
+ else if (a > b) {
320
+ return 1;
321
+ }
322
+ else {
323
+ return 0;
324
+ }
325
+ }
326
+ exports.compare = compare;
327
+ function compareIgnoreCase(a, b) {
328
+ const len = Math.min(a.length, b.length);
329
+ for (let i = 0; i < len; i++) {
330
+ let codeA = a.charCodeAt(i);
331
+ let codeB = b.charCodeAt(i);
332
+ if (codeA === codeB) {
333
+ // equal
334
+ continue;
335
+ }
336
+ if (isUpperAsciiLetter(codeA)) {
337
+ codeA += 32;
338
+ }
339
+ if (isUpperAsciiLetter(codeB)) {
340
+ codeB += 32;
341
+ }
342
+ const diff = codeA - codeB;
343
+ if (diff === 0) {
344
+ // equal -> ignoreCase
345
+ continue;
346
+ }
347
+ else if (isLowerAsciiLetter(codeA) && isLowerAsciiLetter(codeB)) {
348
+ //
349
+ return diff;
350
+ }
351
+ else {
352
+ return compare(a.toLowerCase(), b.toLowerCase());
353
+ }
354
+ }
355
+ if (a.length < b.length) {
356
+ return -1;
357
+ }
358
+ else if (a.length > b.length) {
359
+ return 1;
360
+ }
361
+ else {
362
+ return 0;
363
+ }
364
+ }
365
+ exports.compareIgnoreCase = compareIgnoreCase;
366
+ function isLowerAsciiLetter(code) {
367
+ return code >= 97 /* a */ && code <= 122 /* z */;
368
+ }
369
+ exports.isLowerAsciiLetter = isLowerAsciiLetter;
370
+ function isUpperAsciiLetter(code) {
371
+ return code >= 65 /* A */ && code <= 90 /* Z */;
372
+ }
373
+ exports.isUpperAsciiLetter = isUpperAsciiLetter;
374
+ function isAsciiLetter(code) {
375
+ return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);
376
+ }
377
+ function equalsIgnoreCase(a, b) {
378
+ const len1 = a ? a.length : 0;
379
+ const len2 = b ? b.length : 0;
380
+ if (len1 !== len2) {
381
+ return false;
382
+ }
383
+ return doEqualsIgnoreCase(a, b);
384
+ }
385
+ exports.equalsIgnoreCase = equalsIgnoreCase;
386
+ function doEqualsIgnoreCase(a, b, stopAt = a.length) {
387
+ if (typeof a !== 'string' || typeof b !== 'string') {
388
+ return false;
389
+ }
390
+ for (let i = 0; i < stopAt; i++) {
391
+ const codeA = a.charCodeAt(i);
392
+ const codeB = b.charCodeAt(i);
393
+ if (codeA === codeB) {
394
+ continue;
395
+ }
396
+ // a-z A-Z
397
+ if (isAsciiLetter(codeA) && isAsciiLetter(codeB)) {
398
+ const diff = Math.abs(codeA - codeB);
399
+ if (diff !== 0 && diff !== 32) {
400
+ return false;
401
+ }
402
+ }
403
+ else {
404
+ // Any other charcode
405
+ if (String.fromCharCode(codeA).toLowerCase() !== String.fromCharCode(codeB).toLowerCase()) {
406
+ return false;
407
+ }
408
+ }
409
+ }
410
+ return true;
411
+ }
412
+ function startsWithIgnoreCase(str, candidate) {
413
+ const candidateLength = candidate.length;
414
+ if (candidate.length > str.length) {
415
+ return false;
416
+ }
417
+ return doEqualsIgnoreCase(str, candidate, candidateLength);
418
+ }
419
+ exports.startsWithIgnoreCase = startsWithIgnoreCase;
420
+ /**
421
+ * @returns the length of the common prefix of the two strings.
422
+ */
423
+ function commonPrefixLength(a, b) {
424
+ let i;
425
+ const len = Math.min(a.length, b.length);
426
+ for (i = 0; i < len; i++) {
427
+ if (a.charCodeAt(i) !== b.charCodeAt(i)) {
428
+ return i;
429
+ }
430
+ }
431
+ return len;
432
+ }
433
+ exports.commonPrefixLength = commonPrefixLength;
434
+ /**
435
+ * @returns the length of the common suffix of the two strings.
436
+ */
437
+ function commonSuffixLength(a, b) {
438
+ let i;
439
+ const len = Math.min(a.length, b.length);
440
+ const aLastIndex = a.length - 1;
441
+ const bLastIndex = b.length - 1;
442
+ for (i = 0; i < len; i++) {
443
+ if (a.charCodeAt(aLastIndex - i) !== b.charCodeAt(bLastIndex - i)) {
444
+ return i;
445
+ }
446
+ }
447
+ return len;
448
+ }
449
+ exports.commonSuffixLength = commonSuffixLength;
450
+ function substrEquals(a, aStart, aEnd, b, bStart, bEnd) {
451
+ while (aStart < aEnd && bStart < bEnd) {
452
+ if (a[aStart] !== b[bStart]) {
453
+ return false;
454
+ }
455
+ aStart += 1;
456
+ bStart += 1;
457
+ }
458
+ return true;
459
+ }
460
+ /**
461
+ * Return the overlap between the suffix of `a` and the prefix of `b`.
462
+ * For instance `overlap("foobar", "arr, I'm a pirate") === 2`.
463
+ */
464
+ function overlap(a, b) {
465
+ const aEnd = a.length;
466
+ let bEnd = b.length;
467
+ let aStart = aEnd - bEnd;
468
+ if (aStart === 0) {
469
+ return a === b ? aEnd : 0;
470
+ }
471
+ else if (aStart < 0) {
472
+ bEnd += aStart;
473
+ aStart = 0;
474
+ }
475
+ while (aStart < aEnd && bEnd > 0) {
476
+ if (substrEquals(a, aStart, aEnd, b, 0, bEnd)) {
477
+ return bEnd;
478
+ }
479
+ bEnd -= 1;
480
+ aStart += 1;
481
+ }
482
+ return 0;
483
+ }
484
+ exports.overlap = overlap;
485
+ // --- unicode
486
+ // http://en.wikipedia.org/wiki/Surrogate_pair
487
+ // Returns the code point starting at a specified index in a string
488
+ // Code points U+0000 to U+D7FF and U+E000 to U+FFFF are represented on a single character
489
+ // Code points U+10000 to U+10FFFF are represented on two consecutive characters
490
+ // export function getUnicodePoint(str:string, index:number, len:number):number {
491
+ // const chrCode = str.charCodeAt(index);
492
+ // if (0xD800 <= chrCode && chrCode <= 0xDBFF && index + 1 < len) {
493
+ // const nextChrCode = str.charCodeAt(index + 1);
494
+ // if (0xDC00 <= nextChrCode && nextChrCode <= 0xDFFF) {
495
+ // return (chrCode - 0xD800) << 10 + (nextChrCode - 0xDC00) + 0x10000;
496
+ // }
497
+ // }
498
+ // return chrCode;
499
+ // }
500
+ function isHighSurrogate(charCode) {
501
+ return 0xd800 <= charCode && charCode <= 0xdbff;
502
+ }
503
+ exports.isHighSurrogate = isHighSurrogate;
504
+ function isLowSurrogate(charCode) {
505
+ return 0xdc00 <= charCode && charCode <= 0xdfff;
506
+ }
507
+ exports.isLowSurrogate = isLowSurrogate;
508
+ /**
509
+ * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-rtl-test.js
510
+ */
511
+ const CONTAINS_RTL = /(?:[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05F4\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u0710\u0712-\u072F\u074D-\u07A5\u07B1-\u07EA\u07F4\u07F5\u07FA-\u0815\u081A\u0824\u0828\u0830-\u0858\u085E-\u08BD\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFD3D\uFD50-\uFDFC\uFE70-\uFEFC]|\uD802[\uDC00-\uDD1B\uDD20-\uDE00\uDE10-\uDE33\uDE40-\uDEE4\uDEEB-\uDF35\uDF40-\uDFFF]|\uD803[\uDC00-\uDCFF]|\uD83A[\uDC00-\uDCCF\uDD00-\uDD43\uDD50-\uDFFF]|\uD83B[\uDC00-\uDEBB])/;
512
+ /**
513
+ * Returns true if `str` contains any Unicode character that is classified as "R" or "AL".
514
+ */
515
+ function containsRTL(str) {
516
+ return CONTAINS_RTL.test(str);
517
+ }
518
+ exports.containsRTL = containsRTL;
519
+ /**
520
+ * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-emoji-test.js
521
+ */
522
+ const CONTAINS_EMOJI = /(?:[\u231A\u231B\u23F0\u23F3\u2600-\u27BF\u2B50\u2B55]|\uD83C[\uDDE6-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F\uDE80-\uDEF8]|\uD83E[\uDD00-\uDDE6])/;
523
+ function containsEmoji(str) {
524
+ return CONTAINS_EMOJI.test(str);
525
+ }
526
+ exports.containsEmoji = containsEmoji;
527
+ const IS_BASIC_ASCII = /^[\t\n\r\x20-\x7E]*$/;
528
+ /**
529
+ * Returns true if `str` contains only basic ASCII characters in the range 32 - 126 (including 32 and 126) or \n, \r, \t
530
+ */
531
+ function isBasicASCII(str) {
532
+ return IS_BASIC_ASCII.test(str);
533
+ }
534
+ exports.isBasicASCII = isBasicASCII;
535
+ function containsFullWidthCharacter(str) {
536
+ for (let i = 0, len = str.length; i < len; i++) {
537
+ if (isFullWidthCharacter(str.charCodeAt(i))) {
538
+ return true;
539
+ }
540
+ }
541
+ return false;
542
+ }
543
+ exports.containsFullWidthCharacter = containsFullWidthCharacter;
544
+ function isFullWidthCharacter(charCode) {
545
+ // Do a cheap trick to better support wrapping of wide characters, treat them as 2 columns
546
+ // http://jrgraphix.net/research/unicode_blocks.php
547
+ // 2E80 — 2EFF CJK Radicals Supplement
548
+ // 2F00 — 2FDF Kangxi Radicals
549
+ // 2FF0 — 2FFF Ideographic Description Characters
550
+ // 3000 — 303F CJK Symbols and Punctuation
551
+ // 3040 — 309F Hiragana
552
+ // 30A0 — 30FF Katakana
553
+ // 3100 — 312F Bopomofo
554
+ // 3130 — 318F Hangul Compatibility Jamo
555
+ // 3190 — 319F Kanbun
556
+ // 31A0 — 31BF Bopomofo Extended
557
+ // 31F0 — 31FF Katakana Phonetic Extensions
558
+ // 3200 — 32FF Enclosed CJK Letters and Months
559
+ // 3300 — 33FF CJK Compatibility
560
+ // 3400 — 4DBF CJK Unified Ideographs Extension A
561
+ // 4DC0 — 4DFF Yijing Hexagram Symbols
562
+ // 4E00 — 9FFF CJK Unified Ideographs
563
+ // A000 — A48F Yi Syllables
564
+ // A490 — A4CF Yi Radicals
565
+ // AC00 — D7AF Hangul Syllables
566
+ // [IGNORE] D800 — DB7F High Surrogates
567
+ // [IGNORE] DB80 — DBFF High Private Use Surrogates
568
+ // [IGNORE] DC00 — DFFF Low Surrogates
569
+ // [IGNORE] E000 — F8FF Private Use Area
570
+ // F900 — FAFF CJK Compatibility Ideographs
571
+ // [IGNORE] FB00 — FB4F Alphabetic Presentation Forms
572
+ // [IGNORE] FB50 — FDFF Arabic Presentation Forms-A
573
+ // [IGNORE] FE00 — FE0F Variation Selectors
574
+ // [IGNORE] FE20 — FE2F Combining Half Marks
575
+ // [IGNORE] FE30 — FE4F CJK Compatibility Forms
576
+ // [IGNORE] FE50 — FE6F Small Form Variants
577
+ // [IGNORE] FE70 — FEFF Arabic Presentation Forms-B
578
+ // FF00 — FFEF Halfwidth and Fullwidth Forms
579
+ // [https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]
580
+ // of which FF01 - FF5E fullwidth ASCII of 21 to 7E
581
+ // [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul
582
+ // [IGNORE] FFF0 — FFFF Specials
583
+ charCode = +charCode; // @perf
584
+ return ((charCode >= 0x2e80 && charCode <= 0xd7af) ||
585
+ (charCode >= 0xf900 && charCode <= 0xfaff) ||
586
+ (charCode >= 0xff01 && charCode <= 0xff5e));
587
+ }
588
+ exports.isFullWidthCharacter = isFullWidthCharacter;
589
+ /**
590
+ * Given a string and a max length returns a shorted version. Shorting
591
+ * happens at favorable positions - such as whitespace or punctuation characters.
592
+ */
593
+ function lcut(text, n) {
594
+ if (text.length < n) {
595
+ return text;
596
+ }
597
+ const re = /\b/g;
598
+ let i = 0;
599
+ while (re.test(text)) {
600
+ if (text.length - re.lastIndex < n) {
601
+ break;
602
+ }
603
+ i = re.lastIndex;
604
+ re.lastIndex += 1;
605
+ }
606
+ return text.substring(i).replace(/^\s/, exports.empty);
607
+ }
608
+ exports.lcut = lcut;
609
+ // Escape codes
610
+ // http://en.wikipedia.org/wiki/ANSI_escape_code
611
+ const EL = /\x1B\x5B[12]?K/g; // Erase in line
612
+ const COLOR_START = /\x1b\[\d+m/g; // Color
613
+ const COLOR_END = /\x1b\[0?m/g; // Color
614
+ function removeAnsiEscapeCodes(str) {
615
+ if (str) {
616
+ str = str.replace(EL, '');
617
+ str = str.replace(COLOR_START, '');
618
+ str = str.replace(COLOR_END, '');
619
+ }
620
+ return str;
621
+ }
622
+ exports.removeAnsiEscapeCodes = removeAnsiEscapeCodes;
623
+ exports.removeAccents = (function () {
624
+ if (typeof String.prototype.normalize !== 'function') {
625
+ // ☹️ no ES6 features...
626
+ return function (str) {
627
+ return str;
628
+ };
629
+ }
630
+ else {
631
+ // transform into NFD form and remove accents
632
+ // see: https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript/37511463#37511463
633
+ const regex = /[\u0300-\u036f]/g;
634
+ return function (str) {
635
+ return str.normalize('NFD').replace(regex, exports.empty);
636
+ };
637
+ }
638
+ })();
639
+ // -- UTF-8 BOM
640
+ exports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* UTF8_BOM */);
641
+ function startsWithUTF8BOM(str) {
642
+ return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* UTF8_BOM */);
643
+ }
644
+ exports.startsWithUTF8BOM = startsWithUTF8BOM;
645
+ function stripUTF8BOM(str) {
646
+ return startsWithUTF8BOM(str) ? str.substr(1) : str;
647
+ }
648
+ exports.stripUTF8BOM = stripUTF8BOM;
649
+ function safeBtoa(str) {
650
+ return btoa(encodeURIComponent(str)); // we use encodeURIComponent because btoa fails for non Latin 1 values
651
+ }
652
+ exports.safeBtoa = safeBtoa;
653
+ function repeat(s, count) {
654
+ let result = '';
655
+ for (let i = 0; i < count; i++) {
656
+ result += s;
657
+ }
658
+ return result;
659
+ }
660
+ exports.repeat = repeat;
661
+ /**
662
+ * Checks if the characters of the provided query string are included in the
663
+ * target string. The characters do not have to be contiguous within the string.
664
+ */
665
+ function fuzzyContains(target, query) {
666
+ if (!target || !query) {
667
+ return false; // return early if target or query are undefined
668
+ }
669
+ if (target.length < query.length) {
670
+ return false; // impossible for query to be contained in target
671
+ }
672
+ const queryLen = query.length;
673
+ const targetLower = target.toLowerCase();
674
+ let index = 0;
675
+ let lastIndexOf = -1;
676
+ while (index < queryLen) {
677
+ const indexOf = targetLower.indexOf(query[index], lastIndexOf + 1);
678
+ if (indexOf < 0) {
679
+ return false;
680
+ }
681
+ lastIndexOf = indexOf;
682
+ index++;
683
+ }
684
+ return true;
685
+ }
686
+ exports.fuzzyContains = fuzzyContains;
687
+ function containsUppercaseCharacter(target, ignoreEscapedChars = false) {
688
+ if (!target) {
689
+ return false;
690
+ }
691
+ if (ignoreEscapedChars) {
692
+ target = target.replace(/\\./g, '');
693
+ }
694
+ return target.toLowerCase() !== target;
695
+ }
696
+ exports.containsUppercaseCharacter = containsUppercaseCharacter;
697
+ function uppercaseFirstLetter(str) {
698
+ return str.charAt(0).toUpperCase() + str.slice(1);
699
+ }
700
+ exports.uppercaseFirstLetter = uppercaseFirstLetter;
701
+ function getNLines(str, n = 1) {
702
+ if (n === 0) {
703
+ return '';
704
+ }
705
+ let idx = -1;
706
+ do {
707
+ idx = str.indexOf('\n', idx + 1);
708
+ n--;
709
+ } while (n > 0 && idx >= 0);
710
+ return idx >= 0 ? str.substr(0, idx) : str;
711
+ }
712
+ exports.getNLines = getNLines;
713
+ /**
714
+ * See http://en.wikipedia.org/wiki/Surrogate_pair
715
+ */
716
+ function computeCodePoint(highSurrogate, lowSurrogate) {
717
+ return ((highSurrogate - 0xd800) << 10) + (lowSurrogate - 0xdc00) + 0x10000;
718
+ }
719
+ exports.computeCodePoint = computeCodePoint;
720
+ /**
721
+ * get the code point that begins at offset `offset`
722
+ */
723
+ function getNextCodePoint(str, len, offset) {
724
+ const charCode = str.charCodeAt(offset);
725
+ if (isHighSurrogate(charCode) && offset + 1 < len) {
726
+ const nextCharCode = str.charCodeAt(offset + 1);
727
+ if (isLowSurrogate(nextCharCode)) {
728
+ return computeCodePoint(charCode, nextCharCode);
729
+ }
730
+ }
731
+ return charCode;
732
+ }
733
+ exports.getNextCodePoint = getNextCodePoint;
734
+ /**
735
+ * A manual encoding of `str` to UTF8.
736
+ * Use only in environments which do not offer native conversion methods!
737
+ */
738
+ function encodeUTF8(str) {
739
+ const strLen = str.length;
740
+ // See https://en.wikipedia.org/wiki/UTF-8
741
+ // first loop to establish needed buffer size
742
+ let neededSize = 0;
743
+ let strOffset = 0;
744
+ while (strOffset < strLen) {
745
+ const codePoint = getNextCodePoint(str, strLen, strOffset);
746
+ strOffset += codePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1;
747
+ if (codePoint < 0x0080) {
748
+ neededSize += 1;
749
+ }
750
+ else if (codePoint < 0x0800) {
751
+ neededSize += 2;
752
+ }
753
+ else if (codePoint < 0x10000) {
754
+ neededSize += 3;
755
+ }
756
+ else {
757
+ neededSize += 4;
758
+ }
759
+ }
760
+ // second loop to actually encode
761
+ const arr = new Uint8Array(neededSize);
762
+ strOffset = 0;
763
+ let arrOffset = 0;
764
+ while (strOffset < strLen) {
765
+ const codePoint = getNextCodePoint(str, strLen, strOffset);
766
+ strOffset += codePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1;
767
+ if (codePoint < 0x0080) {
768
+ arr[arrOffset++] = codePoint;
769
+ }
770
+ else if (codePoint < 0x0800) {
771
+ arr[arrOffset++] = 0b11000000 | ((codePoint & 0b00000000000000000000011111000000) >>> 6);
772
+ arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);
773
+ }
774
+ else if (codePoint < 0x10000) {
775
+ arr[arrOffset++] = 0b11100000 | ((codePoint & 0b00000000000000001111000000000000) >>> 12);
776
+ arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);
777
+ arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);
778
+ }
779
+ else {
780
+ arr[arrOffset++] = 0b11110000 | ((codePoint & 0b00000000000111000000000000000000) >>> 18);
781
+ arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000111111000000000000) >>> 12);
782
+ arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000111111000000) >>> 6);
783
+ arr[arrOffset++] = 0b10000000 | ((codePoint & 0b00000000000000000000000000111111) >>> 0);
784
+ }
785
+ }
786
+ return arr;
787
+ }
788
+ exports.encodeUTF8 = encodeUTF8;
789
+ /**
790
+ * A manual decoding of a UTF8 string.
791
+ * Use only in environments which do not offer native conversion methods!
792
+ */
793
+ function decodeUTF8(buffer) {
794
+ // https://en.wikipedia.org/wiki/UTF-8
795
+ const len = buffer.byteLength;
796
+ const result = [];
797
+ let offset = 0;
798
+ while (offset < len) {
799
+ const v0 = buffer[offset];
800
+ let codePoint;
801
+ if (v0 >= 0b11110000 && offset + 3 < len) {
802
+ // 4 bytes
803
+ codePoint =
804
+ (((buffer[offset++] & 0b00000111) << 18) >>> 0) |
805
+ (((buffer[offset++] & 0b00111111) << 12) >>> 0) |
806
+ (((buffer[offset++] & 0b00111111) << 6) >>> 0) |
807
+ (((buffer[offset++] & 0b00111111) << 0) >>> 0);
808
+ }
809
+ else if (v0 >= 0b11100000 && offset + 2 < len) {
810
+ // 3 bytes
811
+ codePoint =
812
+ (((buffer[offset++] & 0b00001111) << 12) >>> 0) |
813
+ (((buffer[offset++] & 0b00111111) << 6) >>> 0) |
814
+ (((buffer[offset++] & 0b00111111) << 0) >>> 0);
815
+ }
816
+ else if (v0 >= 0b11000000 && offset + 1 < len) {
817
+ // 2 bytes
818
+ codePoint = (((buffer[offset++] & 0b00011111) << 6) >>> 0) | (((buffer[offset++] & 0b00111111) << 0) >>> 0);
819
+ }
820
+ else {
821
+ // 1 byte
822
+ codePoint = buffer[offset++];
823
+ }
824
+ if ((codePoint >= 0 && codePoint <= 0xd7ff) || (codePoint >= 0xe000 && codePoint <= 0xffff)) {
825
+ // Basic Multilingual Plane
826
+ result.push(String.fromCharCode(codePoint));
827
+ }
828
+ else if (codePoint >= 0x010000 && codePoint <= 0x10ffff) {
829
+ // Supplementary Planes
830
+ const uPrime = codePoint - 0x10000;
831
+ const w1 = 0xd800 + ((uPrime & 0b11111111110000000000) >>> 10);
832
+ const w2 = 0xdc00 + ((uPrime & 0b00000000001111111111) >>> 0);
833
+ result.push(String.fromCharCode(w1));
834
+ result.push(String.fromCharCode(w2));
835
+ }
836
+ else {
837
+ // illegal code point
838
+ result.push(String.fromCharCode(0xfffd));
839
+ }
840
+ }
841
+ return result.join('');
842
+ }
843
+ exports.decodeUTF8 = decodeUTF8;
844
+ //# sourceMappingURL=strings.js.map