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