@gitpod/gitpod-protocol 0.1.5-sh-ace-test.0 → 0.1.5-siddhant-k-code-allow-github-prebuilds-10358.2

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/data/gitpod-schema.json +163 -74
  2. package/lib/accounting-protocol.d.ts +163 -0
  3. package/lib/accounting-protocol.d.ts.map +1 -0
  4. package/lib/accounting-protocol.js +111 -0
  5. package/lib/accounting-protocol.js.map +1 -0
  6. package/lib/admin-protocol.d.ts +51 -6
  7. package/lib/admin-protocol.d.ts.map +1 -1
  8. package/lib/admin-protocol.js +17 -2
  9. package/lib/admin-protocol.js.map +1 -1
  10. package/lib/analytics.d.ts +44 -0
  11. package/lib/analytics.d.ts.map +1 -0
  12. package/lib/analytics.js +10 -0
  13. package/lib/analytics.js.map +1 -0
  14. package/lib/attribution.d.ts +24 -0
  15. package/lib/attribution.d.ts.map +1 -0
  16. package/lib/attribution.js +54 -0
  17. package/lib/attribution.js.map +1 -0
  18. package/lib/auth.d.ts +25 -0
  19. package/lib/auth.d.ts.map +1 -0
  20. package/lib/auth.js +16 -0
  21. package/lib/auth.js.map +1 -0
  22. package/lib/billing-mode.d.ts +45 -0
  23. package/lib/billing-mode.d.ts.map +1 -0
  24. package/lib/billing-mode.js +44 -0
  25. package/lib/billing-mode.js.map +1 -0
  26. package/lib/blocked-repositories-protocol.d.ts +13 -0
  27. package/lib/blocked-repositories-protocol.d.ts.map +1 -0
  28. package/lib/blocked-repositories-protocol.js +8 -0
  29. package/lib/blocked-repositories-protocol.js.map +1 -0
  30. package/lib/context-url.d.ts +30 -0
  31. package/lib/context-url.d.ts.map +1 -0
  32. package/lib/context-url.js +100 -0
  33. package/lib/context-url.js.map +1 -0
  34. package/lib/context-url.spec.d.ts +12 -0
  35. package/lib/context-url.spec.d.ts.map +1 -0
  36. package/lib/context-url.spec.js +81 -0
  37. package/lib/context-url.spec.js.map +1 -0
  38. package/lib/encryption/container-module.d.ts +2 -2
  39. package/lib/encryption/container-module.d.ts.map +1 -1
  40. package/lib/encryption/container-module.js +8 -6
  41. package/lib/encryption/container-module.js.map +1 -1
  42. package/lib/encryption/encryption-engine.d.ts +2 -2
  43. package/lib/encryption/encryption-engine.d.ts.map +1 -1
  44. package/lib/encryption/encryption-engine.js +28 -28
  45. package/lib/encryption/encryption-engine.js.map +1 -1
  46. package/lib/encryption/encryption-engine.spec.d.ts +3 -3
  47. package/lib/encryption/encryption-engine.spec.d.ts.map +1 -1
  48. package/lib/encryption/encryption-engine.spec.js +32 -39
  49. package/lib/encryption/encryption-engine.spec.js.map +1 -1
  50. package/lib/encryption/encryption-service.d.ts +2 -2
  51. package/lib/encryption/encryption-service.d.ts.map +1 -1
  52. package/lib/encryption/encryption-service.js +33 -46
  53. package/lib/encryption/encryption-service.js.map +1 -1
  54. package/lib/encryption/key-provider.d.ts +3 -3
  55. package/lib/encryption/key-provider.d.ts.map +1 -1
  56. package/lib/encryption/key-provider.js +34 -40
  57. package/lib/encryption/key-provider.js.map +1 -1
  58. package/lib/env.d.ts +2 -8
  59. package/lib/env.d.ts.map +1 -1
  60. package/lib/env.js +10 -29
  61. package/lib/env.js.map +1 -1
  62. package/lib/experiments/always-default.d.ts +8 -0
  63. package/lib/experiments/always-default.d.ts.map +1 -0
  64. package/lib/experiments/always-default.js +20 -0
  65. package/lib/experiments/always-default.js.map +1 -0
  66. package/lib/experiments/configcat-server.d.ts +10 -0
  67. package/lib/experiments/configcat-server.d.ts.map +1 -0
  68. package/lib/experiments/configcat-server.js +37 -0
  69. package/lib/experiments/configcat-server.js.map +1 -0
  70. package/lib/experiments/configcat.d.ts +21 -0
  71. package/lib/experiments/configcat.d.ts.map +1 -0
  72. package/lib/experiments/configcat.js +51 -0
  73. package/lib/experiments/configcat.js.map +1 -0
  74. package/lib/experiments/types.d.ts +22 -0
  75. package/lib/experiments/types.d.ts.map +1 -0
  76. package/lib/experiments/types.js +10 -0
  77. package/lib/experiments/types.js.map +1 -0
  78. package/lib/frontend-dashboard-service.d.ts +90 -0
  79. package/lib/frontend-dashboard-service.d.ts.map +1 -0
  80. package/lib/frontend-dashboard-service.js +49 -0
  81. package/lib/frontend-dashboard-service.js.map +1 -0
  82. package/lib/gitpod-file-parser.d.ts +2 -2
  83. package/lib/gitpod-file-parser.d.ts.map +1 -1
  84. package/lib/gitpod-file-parser.js +29 -44
  85. package/lib/gitpod-file-parser.js.map +1 -1
  86. package/lib/gitpod-file-parser.spec.d.ts +2 -2
  87. package/lib/gitpod-file-parser.spec.js +147 -144
  88. package/lib/gitpod-file-parser.spec.js.map +1 -1
  89. package/lib/gitpod-service.d.ts +241 -50
  90. package/lib/gitpod-service.d.ts.map +1 -1
  91. package/lib/gitpod-service.js +275 -123
  92. package/lib/gitpod-service.js.map +1 -1
  93. package/lib/headless-workspace-log.d.ts +11 -13
  94. package/lib/headless-workspace-log.d.ts.map +1 -1
  95. package/lib/headless-workspace-log.js +8 -9
  96. package/lib/headless-workspace-log.js.map +1 -1
  97. package/lib/ide-frontend-service.d.ts +26 -0
  98. package/lib/ide-frontend-service.d.ts.map +1 -0
  99. package/lib/ide-frontend-service.js +8 -0
  100. package/lib/ide-frontend-service.js.map +1 -0
  101. package/lib/ide-protocol.d.ts +126 -0
  102. package/lib/ide-protocol.d.ts.map +1 -0
  103. package/lib/ide-protocol.js +18 -0
  104. package/lib/ide-protocol.js.map +1 -0
  105. package/lib/index.d.ts +18 -12
  106. package/lib/index.d.ts.map +1 -1
  107. package/lib/index.js +28 -13
  108. package/lib/index.js.map +1 -1
  109. package/lib/installation-admin-protocol.d.ts +30 -0
  110. package/lib/installation-admin-protocol.d.ts.map +1 -0
  111. package/lib/installation-admin-protocol.js +31 -0
  112. package/lib/installation-admin-protocol.js.map +1 -0
  113. package/lib/license-protocol.d.ts +9 -2
  114. package/lib/license-protocol.d.ts.map +1 -1
  115. package/lib/license-protocol.js +3 -2
  116. package/lib/license-protocol.js.map +1 -1
  117. package/lib/messaging/browser/connection.d.ts +6 -4
  118. package/lib/messaging/browser/connection.d.ts.map +1 -1
  119. package/lib/messaging/browser/connection.js +188 -48
  120. package/lib/messaging/browser/connection.js.map +1 -1
  121. package/lib/messaging/browser/window-connection.d.ts +9 -4
  122. package/lib/messaging/browser/window-connection.d.ts.map +1 -1
  123. package/lib/messaging/browser/window-connection.js +48 -59
  124. package/lib/messaging/browser/window-connection.js.map +1 -1
  125. package/lib/messaging/client-call-metrics.d.ts +21 -0
  126. package/lib/messaging/client-call-metrics.d.ts.map +1 -0
  127. package/lib/messaging/client-call-metrics.js +95 -0
  128. package/lib/messaging/client-call-metrics.js.map +1 -0
  129. package/lib/messaging/error.d.ts +17 -4
  130. package/lib/messaging/error.d.ts.map +1 -1
  131. package/lib/messaging/error.js +34 -7
  132. package/lib/messaging/error.js.map +1 -1
  133. package/lib/messaging/handler.d.ts +10 -0
  134. package/lib/messaging/handler.d.ts.map +1 -1
  135. package/lib/messaging/handler.js +2 -1
  136. package/lib/messaging/handler.js.map +1 -1
  137. package/lib/messaging/node/connection.d.ts +1 -17
  138. package/lib/messaging/node/connection.d.ts.map +1 -1
  139. package/lib/messaging/node/connection.js +24 -59
  140. package/lib/messaging/node/connection.js.map +1 -1
  141. package/lib/messaging/proxy-factory.d.ts +3 -1
  142. package/lib/messaging/proxy-factory.d.ts.map +1 -1
  143. package/lib/messaging/proxy-factory.js +76 -162
  144. package/lib/messaging/proxy-factory.js.map +1 -1
  145. package/lib/oss-allowlist.d.ts +14 -0
  146. package/lib/oss-allowlist.d.ts.map +1 -0
  147. package/lib/oss-allowlist.js +8 -0
  148. package/lib/oss-allowlist.js.map +1 -0
  149. package/lib/payment-protocol.d.ts +18 -0
  150. package/lib/payment-protocol.d.ts.map +1 -0
  151. package/lib/payment-protocol.js +13 -0
  152. package/lib/payment-protocol.js.map +1 -0
  153. package/lib/permission.d.ts +26 -15
  154. package/lib/permission.d.ts.map +1 -1
  155. package/lib/permission.js +50 -36
  156. package/lib/permission.js.map +1 -1
  157. package/lib/plans.d.ts +211 -0
  158. package/lib/plans.d.ts.map +1 -0
  159. package/lib/plans.js +609 -0
  160. package/lib/plans.js.map +1 -0
  161. package/lib/protocol.d.ts +300 -112
  162. package/lib/protocol.d.ts.map +1 -1
  163. package/lib/protocol.js +393 -201
  164. package/lib/protocol.js.map +1 -1
  165. package/lib/protocol.spec.d.ts +7 -0
  166. package/lib/protocol.spec.d.ts.map +1 -0
  167. package/lib/protocol.spec.js +127 -0
  168. package/lib/protocol.spec.js.map +1 -0
  169. package/lib/snapshot-url.d.ts +14 -0
  170. package/lib/snapshot-url.d.ts.map +1 -0
  171. package/lib/snapshot-url.js +26 -0
  172. package/lib/snapshot-url.js.map +1 -0
  173. package/lib/snapshot-url.spec.d.ts +7 -0
  174. package/lib/snapshot-url.spec.d.ts.map +1 -0
  175. package/lib/snapshot-url.spec.js +41 -0
  176. package/lib/snapshot-url.spec.js.map +1 -0
  177. package/lib/team-subscription-protocol.d.ts +92 -0
  178. package/lib/team-subscription-protocol.d.ts.map +1 -0
  179. package/lib/team-subscription-protocol.js +78 -0
  180. package/lib/team-subscription-protocol.js.map +1 -0
  181. package/lib/teams-projects-protocol.d.ts +136 -0
  182. package/lib/teams-projects-protocol.d.ts.map +1 -0
  183. package/lib/teams-projects-protocol.js +37 -0
  184. package/lib/teams-projects-protocol.js.map +1 -0
  185. package/lib/typings/globals.d.ts +4 -3
  186. package/lib/typings/globals.d.ts.map +1 -1
  187. package/lib/typings/globals.js +2 -2
  188. package/lib/usage.d.ts +73 -0
  189. package/lib/usage.d.ts.map +1 -0
  190. package/lib/usage.js +20 -0
  191. package/lib/usage.js.map +1 -0
  192. package/lib/util/analytics.d.ts +8 -0
  193. package/lib/util/analytics.d.ts.map +1 -0
  194. package/lib/util/analytics.js +88 -0
  195. package/lib/util/analytics.js.map +1 -0
  196. package/lib/util/async-iterator.d.ts +2 -2
  197. package/lib/util/async-iterator.d.ts.map +1 -1
  198. package/lib/util/async-iterator.js +60 -137
  199. package/lib/util/async-iterator.js.map +1 -1
  200. package/lib/util/cancelable.d.ts +2 -2
  201. package/lib/util/cancelable.js +20 -61
  202. package/lib/util/cancelable.js.map +1 -1
  203. package/lib/util/date-time.d.ts +2 -2
  204. package/lib/util/date-time.js +14 -13
  205. package/lib/util/date-time.js.map +1 -1
  206. package/lib/util/debug-app.d.ts +25 -0
  207. package/lib/util/debug-app.d.ts.map +1 -0
  208. package/lib/util/debug-app.js +100 -0
  209. package/lib/util/debug-app.js.map +1 -0
  210. package/lib/util/deep-partial.d.ts +2 -2
  211. package/lib/util/deep-partial.js +2 -2
  212. package/lib/util/deferred.d.ts +2 -2
  213. package/lib/util/deferred.js +13 -14
  214. package/lib/util/deferred.js.map +1 -1
  215. package/lib/util/disposable.d.ts +2 -2
  216. package/lib/util/disposable.d.ts.map +1 -1
  217. package/lib/util/disposable.js +28 -40
  218. package/lib/util/disposable.js.map +1 -1
  219. package/lib/util/event.d.ts +1 -1
  220. package/lib/util/event.d.ts.map +1 -1
  221. package/lib/util/event.js +64 -77
  222. package/lib/util/event.js.map +1 -1
  223. package/lib/util/garbage-collected-cache.d.ts +3 -2
  224. package/lib/util/garbage-collected-cache.d.ts.map +1 -1
  225. package/lib/util/garbage-collected-cache.js +35 -49
  226. package/lib/util/garbage-collected-cache.js.map +1 -1
  227. package/lib/util/generate-workspace-id.d.ts +9 -0
  228. package/lib/util/generate-workspace-id.d.ts.map +1 -0
  229. package/lib/util/generate-workspace-id.js +491 -0
  230. package/lib/util/generate-workspace-id.js.map +1 -0
  231. package/lib/util/generate-workspace-id.spec.d.ts +7 -0
  232. package/lib/util/generate-workspace-id.spec.d.ts.map +1 -0
  233. package/lib/util/generate-workspace-id.spec.js +98 -0
  234. package/lib/util/generate-workspace-id.spec.js.map +1 -0
  235. package/lib/util/gitpod-cookie.d.ts +20 -0
  236. package/lib/util/gitpod-cookie.d.ts.map +1 -0
  237. package/lib/util/gitpod-cookie.js +41 -0
  238. package/lib/util/gitpod-cookie.js.map +1 -0
  239. package/lib/util/gitpod-host-url.d.ts +20 -7
  240. package/lib/util/gitpod-host-url.d.ts.map +1 -1
  241. package/lib/util/gitpod-host-url.js +146 -85
  242. package/lib/util/gitpod-host-url.js.map +1 -1
  243. package/lib/util/gitpod-host-url.spec.d.ts +16 -0
  244. package/lib/util/gitpod-host-url.spec.d.ts.map +1 -0
  245. package/lib/util/gitpod-host-url.spec.js +134 -0
  246. package/lib/util/gitpod-host-url.spec.js.map +1 -0
  247. package/lib/util/grpc.d.ts +35 -0
  248. package/lib/util/grpc.d.ts.map +1 -0
  249. package/lib/util/grpc.js +90 -0
  250. package/lib/util/grpc.js.map +1 -0
  251. package/lib/util/jaeger-client-types.d.ts +68 -0
  252. package/lib/util/jaeger-client-types.d.ts.map +1 -0
  253. package/lib/util/jaeger-client-types.js +8 -0
  254. package/lib/util/jaeger-client-types.js.map +1 -0
  255. package/lib/util/logging.d.ts +58 -35
  256. package/lib/util/logging.d.ts.map +1 -1
  257. package/lib/util/logging.js +144 -129
  258. package/lib/util/logging.js.map +1 -1
  259. package/lib/util/logging.spec.d.ts +7 -0
  260. package/lib/util/logging.spec.d.ts.map +1 -0
  261. package/lib/util/logging.spec.js +52 -0
  262. package/lib/util/logging.spec.js.map +1 -0
  263. package/lib/util/make-link.d.ts +2 -2
  264. package/lib/util/make-link.js +8 -7
  265. package/lib/util/make-link.js.map +1 -1
  266. package/lib/util/nice-grpc.d.ts +9 -0
  267. package/lib/util/nice-grpc.d.ts.map +1 -0
  268. package/lib/util/nice-grpc.js +121 -0
  269. package/lib/util/nice-grpc.js.map +1 -0
  270. package/lib/util/parse-workspace-id.d.ts +15 -5
  271. package/lib/util/parse-workspace-id.d.ts.map +1 -1
  272. package/lib/util/parse-workspace-id.js +39 -9
  273. package/lib/util/parse-workspace-id.js.map +1 -1
  274. package/lib/util/parse-workspace-id.spec.d.ts +10 -2
  275. package/lib/util/parse-workspace-id.spec.d.ts.map +1 -1
  276. package/lib/util/parse-workspace-id.spec.js +130 -49
  277. package/lib/util/parse-workspace-id.spec.js.map +1 -1
  278. package/lib/util/queue.d.ts +2 -2
  279. package/lib/util/queue.js +19 -57
  280. package/lib/util/queue.js.map +1 -1
  281. package/lib/util/queue.spec.d.ts +2 -2
  282. package/lib/util/queue.spec.js +149 -288
  283. package/lib/util/queue.spec.js.map +1 -1
  284. package/lib/util/repeat.d.ts +15 -0
  285. package/lib/util/repeat.d.ts.map +1 -0
  286. package/lib/util/repeat.js +55 -0
  287. package/lib/util/repeat.js.map +1 -0
  288. package/lib/util/semaphore.d.ts +2 -2
  289. package/lib/util/semaphore.d.ts.map +1 -1
  290. package/lib/util/semaphore.js +18 -48
  291. package/lib/util/semaphore.js.map +1 -1
  292. package/lib/util/skip-if.d.ts +2 -2
  293. package/lib/util/skip-if.d.ts.map +1 -1
  294. package/lib/util/skip-if.js +9 -8
  295. package/lib/util/skip-if.js.map +1 -1
  296. package/lib/util/timeutil.d.ts +4 -2
  297. package/lib/util/timeutil.d.ts.map +1 -1
  298. package/lib/util/timeutil.js +43 -18
  299. package/lib/util/timeutil.js.map +1 -1
  300. package/lib/util/timeutil.spec.d.ts +4 -2
  301. package/lib/util/timeutil.spec.d.ts.map +1 -1
  302. package/lib/util/timeutil.spec.js +57 -25
  303. package/lib/util/timeutil.spec.js.map +1 -1
  304. package/lib/util/tracing.d.ts +54 -8
  305. package/lib/util/tracing.d.ts.map +1 -1
  306. package/lib/util/tracing.js +200 -66
  307. package/lib/util/tracing.js.map +1 -1
  308. package/lib/util/tracing.spec.d.ts +7 -0
  309. package/lib/util/tracing.spec.d.ts.map +1 -0
  310. package/lib/util/tracing.spec.js +121 -0
  311. package/lib/util/tracing.spec.js.map +1 -0
  312. package/lib/util/workspace-port-authentication.d.ts +9 -9
  313. package/lib/util/workspace-port-authentication.d.ts.map +1 -1
  314. package/lib/util/workspace-port-authentication.js +13 -14
  315. package/lib/util/workspace-port-authentication.js.map +1 -1
  316. package/lib/webhook-event.d.ts +44 -0
  317. package/lib/webhook-event.d.ts.map +1 -0
  318. package/lib/webhook-event.js +8 -0
  319. package/lib/webhook-event.js.map +1 -0
  320. package/lib/workspace-class.d.ts +14 -0
  321. package/lib/workspace-class.d.ts.map +1 -0
  322. package/lib/workspace-class.js +8 -0
  323. package/lib/workspace-class.js.map +1 -0
  324. package/lib/workspace-cluster.d.ts +75 -0
  325. package/lib/workspace-cluster.d.ts.map +1 -0
  326. package/lib/workspace-cluster.js +31 -0
  327. package/lib/workspace-cluster.js.map +1 -0
  328. package/lib/workspace-instance.d.ts +51 -8
  329. package/lib/workspace-instance.d.ts.map +1 -1
  330. package/lib/workspace-instance.js +2 -2
  331. package/lib/wsready.d.ts +8 -2
  332. package/lib/wsready.d.ts.map +1 -1
  333. package/lib/wsready.js +4 -3
  334. package/lib/wsready.js.map +1 -1
  335. package/package.json +42 -18
  336. package/pkg-yarn.lock +24 -10
  337. package/provenance-bundle.jsonl +2 -0
  338. package/src/accounting-protocol.ts +244 -0
  339. package/src/admin-protocol.ts +96 -21
  340. package/src/analytics.ts +52 -0
  341. package/src/attribution.ts +63 -0
  342. package/src/auth.ts +27 -0
  343. package/src/billing-mode.ts +84 -0
  344. package/src/blocked-repositories-protocol.ts +13 -0
  345. package/src/context-url.spec.ts +49 -0
  346. package/src/context-url.ts +107 -0
  347. package/src/encryption/container-module.ts +4 -5
  348. package/src/encryption/encryption-engine.spec.ts +11 -10
  349. package/src/encryption/encryption-engine.ts +22 -18
  350. package/src/encryption/encryption-service.ts +6 -7
  351. package/src/encryption/key-provider.ts +18 -21
  352. package/src/env.ts +3 -26
  353. package/src/experiments/always-default.ts +24 -0
  354. package/src/experiments/configcat-server.ts +42 -0
  355. package/src/experiments/configcat.ts +56 -0
  356. package/src/experiments/types.ts +34 -0
  357. package/src/frontend-dashboard-service.ts +125 -0
  358. package/src/gitpod-file-parser.spec.ts +57 -63
  359. package/src/gitpod-file-parser.ts +18 -19
  360. package/src/gitpod-service.ts +534 -99
  361. package/src/headless-workspace-log.ts +14 -16
  362. package/src/ide-frontend-service.ts +28 -0
  363. package/src/ide-protocol.ts +147 -0
  364. package/src/index.ts +18 -12
  365. package/src/installation-admin-protocol.ts +45 -0
  366. package/src/license-protocol.ts +14 -8
  367. package/src/messaging/browser/connection.ts +202 -26
  368. package/src/messaging/browser/window-connection.ts +45 -29
  369. package/src/messaging/client-call-metrics.ts +94 -0
  370. package/src/messaging/error.ts +47 -10
  371. package/src/messaging/handler.ts +13 -1
  372. package/src/messaging/node/connection.ts +23 -70
  373. package/src/messaging/proxy-factory.ts +35 -34
  374. package/src/oss-allowlist.ts +15 -0
  375. package/src/payment-protocol.ts +20 -0
  376. package/src/permission.ts +53 -40
  377. package/src/plans.ts +683 -0
  378. package/src/protocol.spec.ts +97 -0
  379. package/src/protocol.ts +706 -299
  380. package/src/snapshot-url.spec.ts +27 -0
  381. package/src/snapshot-url.ts +27 -0
  382. package/src/team-subscription-protocol.ts +150 -0
  383. package/src/teams-projects-protocol.ts +177 -0
  384. package/src/typings/globals.ts +7 -5
  385. package/src/usage.ts +85 -0
  386. package/src/util/analytics.ts +109 -0
  387. package/src/util/async-iterator.ts +6 -7
  388. package/src/util/cancelable.ts +5 -5
  389. package/src/util/date-time.ts +10 -10
  390. package/src/util/debug-app.ts +81 -0
  391. package/src/util/deep-partial.ts +2 -2
  392. package/src/util/deferred.ts +8 -8
  393. package/src/util/disposable.ts +3 -6
  394. package/src/util/event.ts +9 -11
  395. package/src/util/garbage-collected-cache.ts +18 -10
  396. package/src/util/generate-workspace-id.spec.ts +58 -0
  397. package/src/util/generate-workspace-id.ts +481 -0
  398. package/src/util/gitpod-cookie.ts +38 -0
  399. package/src/util/gitpod-host-url.spec.ts +76 -0
  400. package/src/util/gitpod-host-url.ts +121 -38
  401. package/src/util/grpc.ts +107 -0
  402. package/src/util/jaeger-client-types.ts +102 -0
  403. package/src/util/logging.spec.ts +23 -0
  404. package/src/util/logging.ts +163 -73
  405. package/src/util/make-link.ts +8 -9
  406. package/src/util/nice-grpc.ts +96 -0
  407. package/src/util/parse-workspace-id.spec.ts +62 -12
  408. package/src/util/parse-workspace-id.ts +40 -10
  409. package/src/util/queue.spec.ts +30 -28
  410. package/src/util/queue.ts +2 -2
  411. package/src/util/repeat.ts +45 -0
  412. package/src/util/semaphore.ts +8 -10
  413. package/src/util/skip-if.ts +12 -9
  414. package/src/util/timeutil.spec.ts +42 -16
  415. package/src/util/timeutil.ts +33 -17
  416. package/src/util/tracing.spec.ts +88 -0
  417. package/src/util/tracing.ts +202 -33
  418. package/src/util/workspace-port-authentication.ts +12 -15
  419. package/src/webhook-event.ts +55 -0
  420. package/src/workspace-class.ts +14 -0
  421. package/src/workspace-cluster.ts +110 -0
  422. package/src/workspace-instance.ts +119 -35
  423. package/src/wsready.ts +11 -4
  424. package/data/builtin-theia-plugins.json +0 -362
  425. package/lib/email-protocol.d.ts +0 -49
  426. package/lib/email-protocol.d.ts.map +0 -1
  427. package/lib/email-protocol.js +0 -27
  428. package/lib/email-protocol.js.map +0 -1
  429. package/lib/messaging/connection-error-handler.d.ts +0 -27
  430. package/lib/messaging/connection-error-handler.d.ts.map +0 -1
  431. package/lib/messaging/connection-error-handler.js +0 -45
  432. package/lib/messaging/connection-error-handler.js.map +0 -1
  433. package/lib/theia-plugins.d.ts +0 -11
  434. package/lib/theia-plugins.d.ts.map +0 -1
  435. package/lib/theia-plugins.js +0 -8
  436. package/lib/theia-plugins.js.map +0 -1
  437. package/lib/util/repeater.d.ts +0 -22
  438. package/lib/util/repeater.d.ts.map +0 -1
  439. package/lib/util/repeater.js +0 -117
  440. package/lib/util/repeater.js.map +0 -1
  441. package/lib/util/safe-promise.d.ts +0 -11
  442. package/lib/util/safe-promise.d.ts.map +0 -1
  443. package/lib/util/safe-promise.js +0 -33
  444. package/lib/util/safe-promise.js.map +0 -1
  445. package/lib/util/without.d.ts +0 -7
  446. package/lib/util/without.d.ts.map +0 -1
  447. package/lib/util/without.js +0 -8
  448. package/lib/util/without.js.map +0 -1
  449. package/src/email-protocol.ts +0 -67
  450. package/src/messaging/connection-error-handler.ts +0 -62
  451. package/src/theia-plugins.ts +0 -11
  452. package/src/util/jaeger-client.d.ts +0 -105
  453. package/src/util/repeater.ts +0 -49
  454. package/src/util/safe-promise.ts +0 -26
  455. package/src/util/without.ts +0 -8
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/messaging/error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,yBAAiB,UAAU,CAAC;IAEjB,MAAM,iBAAiB,MAAM,CAAC;IAG9B,MAAM,iBAAiB,MAAM,CAAC;IAG9B,MAAM,iBAAiB,MAAM,CAAC;IAG9B,MAAM,SAAS,MAAM,CAAC;IAGtB,MAAM,QAAQ,MAAM,CAAC;IAGrB,MAAM,cAAc,MAAM,CAAC;IAG3B,MAAM,0BAA0B,MAAM,CAAC;IAGvC,MAAM,mBAAmB,MAAM,CAAC;IAGhC,MAAM,aAAa,MAAM,CAAC;IAG1B,MAAM,YAAY,MAAM,CAAC;IAGzB,MAAM,YAAY,MAAM,CAAC;IAGzB,MAAM,iCAAiC,MAAM,CAAC;IAG9C,MAAM,0BAA0B,MAAM,CAAC;IAGvC,MAAM,8BAA8B,MAAM,CAAC;IAG3C,MAAM,2BAA2B,MAAM,CAAC;IAGxC,MAAM,UAAU,MAAM,CAAC;IAGvB,MAAM,mBAAmB,MAAM,CAAC;IAGhC,MAAM,kCAAkC,MAAM,CAAC;IAG/C,MAAM,mCAAmC,MAAM,CAAC;IAGhD,MAAM,eAAe,MAAM,CAAC;CACtC"}
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/messaging/error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,yBAAiB,UAAU,CAAC;IAEjB,MAAM,WAAW,MAAM,CAAC;IAGxB,MAAM,iBAAiB,MAAM,CAAC;IAG9B,MAAM,iBAAiB,MAAM,CAAC;IAG9B,MAAM,iBAAiB,MAAM,CAAC;IAG9B,MAAM,SAAS,MAAM,CAAC;IAGtB,MAAM,QAAQ,MAAM,CAAC;IAGrB,MAAM,cAAc,MAAM,CAAC;IAG3B,MAAM,kBAAkB,MAAM,CAAC;IAG/B,MAAM,iBAAiB,MAAM,CAAC;IAG9B,MAAM,0BAA0B,MAAM,CAAC;IAGvC,MAAM,gBAAgB,MAAM,CAAC;IAG7B,MAAM,aAAa,MAAM,CAAC;IAG1B,MAAM,8BAA8B,MAAM,CAAC;IAG3C,MAAM,kBAAkB,MAAM,CAAC;IAG/B,MAAM,mBAAmB,MAAM,CAAC;IAGhC,MAAM,mBAAmB,MAAM,CAAC;IAGhC,MAAM,kBAAkB,MAAM,CAAC;IAG/B,MAAM,YAAY,MAAM,CAAC;IAGzB,MAAM,YAAY,MAAM,CAAC;IAGzB,MAAM,8BAA8B,MAAM,CAAC;IAG3C,MAAM,iCAAiC,MAAM,CAAC;IAG9C,MAAM,0BAA0B,MAAM,CAAC;IAGvC,MAAM,8BAA8B,MAAM,CAAC;IAG3C,MAAM,2BAA2B,MAAM,CAAC;IAGxC,MAAM,qBAAqB,MAAM,CAAC;IAGlC,MAAM,UAAU,MAAM,CAAC;IAGvB,MAAM,mBAAmB,MAAM,CAAC;IAGhC,MAAM,YAAY,MAAM,CAAC;IAGzB,MAAM,kCAAkC,MAAM,CAAC;IAG/C,MAAM,mCAAmC,MAAM,CAAC;IAGhD,MAAM,cAAc,MAAM,CAAC;IAG3B,MAAM,8BAA8B,MAAM,CAAC;IAG3C,MAAM,aAAa,MAAM,CAAC;CACpC"}
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2020 TypeFox GmbH. All rights reserved.
3
+ * Copyright (c) 2020 Gitpod GmbH. All rights reserved.
4
4
  * Licensed under the GNU Affero General Public License (AGPL).
5
- * See License-AGPL.txt in the project root for license information.
5
+ * See License.AGPL.txt in the project root for license information.
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.ErrorCodes = void 0;
8
9
  var ErrorCodes;
9
10
  (function (ErrorCodes) {
11
+ // 400 Unauthorized
12
+ ErrorCodes.BAD_REQUEST = 400;
10
13
  // 401 Unauthorized
11
14
  ErrorCodes.NOT_AUTHENTICATED = 401;
12
15
  // 402 Payment Required
@@ -19,16 +22,32 @@ var ErrorCodes;
19
22
  ErrorCodes.CONFLICT = 409;
20
23
  // 410 No User
21
24
  ErrorCodes.SETUP_REQUIRED = 410;
25
+ // 411 No User
26
+ ErrorCodes.NEEDS_VERIFICATION = 411;
27
+ // 429 Too Many Requests
28
+ ErrorCodes.TOO_MANY_REQUESTS = 429;
22
29
  // 430 Repository not whitelisted (custom status code)
23
30
  ErrorCodes.REPOSITORY_NOT_WHITELISTED = 430;
24
- // 460 Context Parse Error (custom status code)
25
- ErrorCodes.CONTEXT_PARSE_ERROR = 460;
31
+ // 440 Prebuilds now always require a project (custom status code)
32
+ ErrorCodes.PROJECT_REQUIRED = 440;
26
33
  // 450 Payment error
27
34
  ErrorCodes.PAYMENT_ERROR = 450;
35
+ // 451 Out of credits
36
+ ErrorCodes.PAYMENT_SPENDING_LIMIT_REACHED = 451;
37
+ // 451 Error creating a subscription
38
+ ErrorCodes.SUBSCRIPTION_ERROR = 452;
39
+ // 455 Invalid cost center (custom status code)
40
+ ErrorCodes.INVALID_COST_CENTER = 455;
41
+ // 460 Context Parse Error (custom status code)
42
+ ErrorCodes.CONTEXT_PARSE_ERROR = 460;
43
+ // 461 Invalid gitpod yml (custom status code)
44
+ ErrorCodes.INVALID_GITPOD_YML = 461;
28
45
  // 470 User Blocked (custom status code)
29
46
  ErrorCodes.USER_BLOCKED = 470;
30
- // 471 User Blocked (custom status code)
47
+ // 471 User Deleted (custom status code)
31
48
  ErrorCodes.USER_DELETED = 471;
49
+ // 472 Terms Acceptance Required (custom status code)
50
+ ErrorCodes.USER_TERMS_ACCEPTANCE_REQUIRED = 472;
32
51
  // 480 Plan does not allow private repos
33
52
  ErrorCodes.PLAN_DOES_NOT_ALLOW_PRIVATE_REPOS = 480;
34
53
  // 481 Professional plan is required for this operation
@@ -37,15 +56,23 @@ var ErrorCodes;
37
56
  ErrorCodes.PLAN_ONLY_ALLOWED_FOR_STUDENTS = 485;
38
57
  // 490 Too Many Running Workspace
39
58
  ErrorCodes.TOO_MANY_RUNNING_WORKSPACES = 490;
59
+ // 500 Internal Server Error
60
+ ErrorCodes.INTERNAL_SERVER_ERROR = 500;
40
61
  // 501 EE Feature
41
62
  ErrorCodes.EE_FEATURE = 501;
42
63
  // 555 EE License Required
43
64
  ErrorCodes.EE_LICENSE_REQUIRED = 555;
65
+ // 601 SaaS Feature
66
+ ErrorCodes.SAAS_FEATURE = 601;
44
67
  // 610 Invalid Team Subscription Quantity
45
68
  ErrorCodes.TEAM_SUBSCRIPTION_INVALID_QUANTITY = 610;
46
69
  // 620 Team Subscription Assignment Failed
47
70
  ErrorCodes.TEAM_SUBSCRIPTION_ASSIGNMENT_FAILED = 620;
48
- // 666 Not Implemented TODO IO-SPLIT remove
49
- ErrorCodes.NOT_IMPLEMENTED = 666;
71
+ // 630 Snapshot Error
72
+ ErrorCodes.SNAPSHOT_ERROR = 630;
73
+ // 640 Headless logs are not available (yet)
74
+ ErrorCodes.HEADLESS_LOG_NOT_YET_AVAILABLE = 640;
75
+ // 650 Invalid Value
76
+ ErrorCodes.INVALID_VALUE = 650;
50
77
  })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
51
78
  //# sourceMappingURL=error.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/messaging/error.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAIH,IAAiB,UAAU,CA4D1B;AA5DD,WAAiB,UAAU;IACvB,mBAAmB;IACN,4BAAiB,GAAG,GAAG,CAAC;IAErC,uBAAuB;IACV,4BAAiB,GAAG,GAAG,CAAC;IAErC,gBAAgB;IACH,4BAAiB,GAAG,GAAG,CAAC;IAErC,gBAAgB;IACH,oBAAS,GAAG,GAAG,CAAC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AC;IAElD,oBAAoB;IACP,wBAAa,GAAG,GAAG,CAAC;AACrC,CAAC,EAnGgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAmG1B"}
@@ -4,4 +4,14 @@ export interface ConnectionHandler {
4
4
  readonly path: string;
5
5
  onConnection(connection: MessageConnection, session?: object): void;
6
6
  }
7
+ export interface ConnectionEventHandler {
8
+ /**
9
+ * Called when the transport underpinning the connection got closed
10
+ */
11
+ onTransportDidClose(): void;
12
+ /**
13
+ * Called when the transport underpinning the connection is (re-)opened
14
+ */
15
+ onTransportDidOpen(): void;
16
+ }
7
17
  //# sourceMappingURL=handler.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/messaging/handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,UAAU,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvE"}
1
+ {"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/messaging/handler.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnD,eAAO,MAAM,iBAAiB,eAA8B,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,UAAU,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvE;AAED,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,mBAAmB,IAAI,IAAI,CAAC;IAE5B;;OAEG;IACH,kBAAkB,IAAI,IAAI,CAAC;CAC9B"}
@@ -6,5 +6,6 @@
6
6
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ConnectionHandler = Symbol('ConnectionHandler');
9
+ exports.ConnectionHandler = void 0;
10
+ exports.ConnectionHandler = Symbol("ConnectionHandler");
10
11
  //# sourceMappingURL=handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/messaging/handler.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAIU,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
1
+ {"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/messaging/handler.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAIU,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
@@ -1,20 +1,4 @@
1
- /// <reference types="node" />
2
1
  import * as ws from "ws";
3
- import * as http from "http";
4
- import * as https from "https";
5
- import * as net from "net";
6
- import { MessageConnection } from "vscode-jsonrpc";
7
2
  import { IWebSocket } from "vscode-ws-jsonrpc";
8
- export interface IServerOptions {
9
- readonly server: http.Server | https.Server;
10
- readonly path?: string;
11
- matches?(request: http.IncomingMessage): boolean;
12
- }
13
- export declare function createServerWebSocketConnection(options: IServerOptions, onConnect: (connection: MessageConnection) => void): void;
14
- export declare function openJsonRpcSocket(options: IServerOptions, onOpen: (socket: IWebSocket) => void): void;
15
- export interface OnOpen {
16
- (webSocket: ws, request: http.IncomingMessage, socket: net.Socket, head: Buffer): void;
17
- }
18
- export declare function openSocket(options: IServerOptions, onOpen: OnOpen): void;
19
- export declare function toIWebSocket(webSocket: ws): IWebSocket;
3
+ export declare function toIWebSocket(ws: ws): IWebSocket;
20
4
  //# sourceMappingURL=connection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/messaging/node/connection.ts"],"names":[],"mappings":";AAOA,OAAO,KAAK,EAAE,M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Y,CAAC,EAAE,EAAE,EAAE,cA6BlC"}
@@ -6,70 +6,35 @@
6
6
  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- var ws = require("ws");
10
- var url = require("url");
11
- var vscode_ws_jsonrpc_1 = require("vscode-ws-jsonrpc");
12
- var logging_1 = require("../../util/logging");
13
- function createServerWebSocketConnection(options, onConnect) {
14
- openJsonRpcSocket(options, function (socket) {
15
- onConnect(vscode_ws_jsonrpc_1.createWebSocketConnection(socket, console));
16
- });
17
- }
18
- exports.createServerWebSocketConnection = createServerWebSocketConnection;
19
- function openJsonRpcSocket(options, onOpen) {
20
- openSocket(options, function (socket) {
21
- var webSocket = toIWebSocket(socket);
22
- onOpen(webSocket);
23
- });
24
- }
25
- exports.openJsonRpcSocket = openJsonRpcSocket;
26
- function openSocket(options, onOpen) {
27
- var wss = new ws.Server({
28
- noServer: true,
29
- perMessageDeflate: {
30
- // don't compress if a message is less than 256kb
31
- threshold: 256 * 1024
32
- }
33
- });
34
- options.server.on('upgrade', function (request, socket, head) {
35
- var pathname = request.url ? url.parse(request.url).pathname : undefined;
36
- if (options.path && pathname === options.path || options.matches && options.matches(request)) {
37
- wss.handleUpgrade(request, socket, head, function (webSocket) {
38
- if (webSocket.readyState === webSocket.OPEN) {
39
- onOpen(webSocket, request, socket, head);
40
- }
41
- else {
42
- webSocket.on('open', function () { return onOpen(webSocket, request, socket, head); });
43
- }
44
- });
45
- }
46
- });
47
- }
48
- exports.openSocket = openSocket;
49
- function toIWebSocket(webSocket) {
50
- var sendsAfterOpen = 0;
9
+ exports.toIWebSocket = void 0;
10
+ function toIWebSocket(ws) {
51
11
  return {
52
- send: function (content) {
53
- if (webSocket.readyState !== ws.OPEN) {
54
- if (sendsAfterOpen++ > 3) {
55
- logging_1.log.error("Repeated try to send on closed web socket (readyState was " + webSocket.readyState + ")", { ws: ws });
56
- }
12
+ send: (content) => {
13
+ if (ws.readyState >= ws.CLOSING) {
14
+ // ws is already CLOSING/CLOSED, send() would just return an error.
57
15
  return;
58
16
  }
59
- webSocket.send(content, function (err) {
60
- if (err) {
61
- logging_1.log.error('Error in ws.send()', err, { ws: ws });
62
- }
63
- });
17
+ // in general send-errors should trigger an 'error' event already, we just make sure it actually happens.
18
+ try {
19
+ ws.send(content, (err) => {
20
+ if (!err) {
21
+ return;
22
+ }
23
+ ws.emit("error", err);
24
+ });
25
+ }
26
+ catch (err) {
27
+ ws.emit("error", err);
28
+ }
64
29
  },
65
- onMessage: function (cb) { return webSocket.on('message', cb); },
66
- onError: function (cb) { return webSocket.on('error', cb); },
67
- onClose: function (cb) { return webSocket.on('close', cb); },
68
- dispose: function () {
69
- if (webSocket.readyState < ws.CLOSING) {
70
- webSocket.close();
30
+ onMessage: (cb) => ws.on("message", cb),
31
+ onError: (cb) => ws.on("error", cb),
32
+ onClose: (cb) => ws.on("close", cb),
33
+ dispose: () => {
34
+ if (ws.readyState < ws.CLOSING) {
35
+ ws.close();
71
36
  }
72
- }
37
+ },
73
38
  };
74
39
  }
75
40
  exports.toIWebSocket = toIWebSocket;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/messaging/node/connection.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,uBAAyB;AAGzB,yBAA2B;AAG3B,uDAA0E;AAC1E,8CAAyC;AAQzC,SAAgB,+BAA+B,CAAC,OAAuB,EAAE,SAAkD;IACvH,iBAAiB,CAAC,OAAO,EAAE,UAAA,MAAM;QAC7B,SAAS,CAAC,6CAAyB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACP,CAAC;AAJD,0EAIC;AAED,SAAgB,iBAAiB,CAAC,OAAuB,EAAE,MAAoC;IAC3F,UAAU,CAAC,OAAO,EAAE,UAAA,MAAM;QACtB,IAAM,SAAS,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACvC,M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IAAI;gBACA,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;oBACrB,IAAI,CAAC,GAAG,EAAE;wBACN,OAAO;qBACV;oBACD,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;gBAC1B,CAAC,CAAC,CAAC;aACN;YAAC,OAAO,GAAG,EAAE;gBACV,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;aACzB;QACL,CAAC;QACD,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;QACvC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACnC,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC;QACnC,OAAO,EAAE,GAAG,EAAE;YACV,IAAI,EAAE,CAAC,UAAU,GAAG,EAAE,CAAC,OAAO,EAAE;gBAC5B,EAAE,CAAC,KAAK,EAAE,CAAC;aACd;QACL,CAAC;KACJ,CAAC;AACN,CAAC;AA7BD,oCA6BC"}
@@ -1,7 +1,7 @@
1
1
  import { MessageConnection } from "vscode-jsonrpc";
2
2
  import { Event, Emitter } from "../util/event";
3
3
  import { Disposable } from "../util/disposable";
4
- import { ConnectionHandler } from './handler';
4
+ import { ConnectionHandler } from "./handler";
5
5
  export declare type JsonRpcServer<Client> = Disposable & {
6
6
  /**
7
7
  * If this server is a proxy to a remote server then
@@ -77,6 +77,8 @@ export declare class JsonRpcProxyFactory<T extends object> implements ProxyHandl
77
77
  */
78
78
  constructor(target?: any);
79
79
  protected waitForConnection(): void;
80
+ fireConnectionClosed(): void;
81
+ fireConnectionOpened(): void;
80
82
  /**
81
83
  * Connect a MessageConnection to the factory.
82
84
  *
@@ -1 +1 @@
1
- {"version":3,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,CAAC,KAAK;IAI/B,SAAS,CAAC,iBAAiB,IAAI,IAAI;IAQnC,oBAAoB;IAIpB,oBAAoB;IAIpB;;;;;OAKG;IACH,MAAM,CAAC,UAAU,EAAE,iBAAiB;IAQpC;;;;;;;;;;;OAWG;cACa,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAavE;;;;;OAKG;IACH,SAAS,CAAC,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAM9D;;;;;;OAMG;IACH,WAAW,IAAI,YAAY,CAAC,CAAC,CAAC;IAK9B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,GAAG,GAAG;IAgClD;;;;;;;;OAQG;IACH,SAAS,CAAC,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO;CAGpD"}
@@ -14,70 +14,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
14
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
15
15
  });
16
16
  };
17
- var __generator = (this && this.__generator) || function (thisArg, body) {
18
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
19
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
20
- function verb(n) { return function (v) { return step([n, v]); }; }
21
- function step(op) {
22
- if (f) throw new TypeError("Generator is already executing.");
23
- while (_) try {
24
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
25
- if (y = 0, t) op = [op[0] & 2, t.value];
26
- switch (op[0]) {
27
- case 0: case 1: t = op; break;
28
- case 4: _.label++; return { value: op[1], done: false };
29
- case 5: _.label++; y = op[1]; op = [0]; continue;
30
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
31
- default:
32
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
33
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
34
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
35
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
36
- if (t[2]) _.ops.pop();
37
- _.trys.pop(); continue;
38
- }
39
- op = body.call(thisArg, _);
40
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
41
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
42
- }
43
- };
44
- var __read = (this && this.__read) || function (o, n) {
45
- var m = typeof Symbol === "function" && o[Symbol.iterator];
46
- if (!m) return o;
47
- var i = m.call(o), r, ar = [], e;
48
- try {
49
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
50
- }
51
- catch (error) { e = { error: error }; }
52
- finally {
53
- try {
54
- if (r && !r.done && (m = i["return"])) m.call(i);
55
- }
56
- finally { if (e) throw e.error; }
57
- }
58
- return ar;
59
- };
60
- var __spread = (this && this.__spread) || function () {
61
- for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
62
- return ar;
63
- };
64
17
  Object.defineProperty(exports, "__esModule", { value: true });
65
- var vscode_jsonrpc_1 = require("vscode-jsonrpc");
66
- var event_1 = require("../util/event");
67
- var logging_1 = require("../util/logging");
68
- var JsonRpcConnectionHandler = /** @class */ (function () {
69
- function JsonRpcConnectionHandler(path, targetFactory) {
18
+ exports.JsonRpcProxyFactory = exports.JsonRpcConnectionHandler = void 0;
19
+ const vscode_jsonrpc_1 = require("vscode-jsonrpc");
20
+ const event_1 = require("../util/event");
21
+ const logging_1 = require("../util/logging");
22
+ class JsonRpcConnectionHandler {
23
+ constructor(path, targetFactory) {
70
24
  this.path = path;
71
25
  this.targetFactory = targetFactory;
72
26
  }
73
- JsonRpcConnectionHandler.prototype.onConnection = function (connection, request) {
74
- var factory = new JsonRpcProxyFactory();
75
- var proxy = factory.createProxy();
27
+ onConnection(connection, request) {
28
+ const factory = new JsonRpcProxyFactory();
29
+ const proxy = factory.createProxy();
76
30
  factory.target = this.targetFactory(proxy, request);
77
31
  factory.listen(connection);
78
- };
79
- return JsonRpcConnectionHandler;
80
- }());
32
+ }
33
+ }
81
34
  exports.JsonRpcConnectionHandler = JsonRpcConnectionHandler;
82
35
  /**
83
36
  * Factory for JSON-RPC proxy objects.
@@ -121,57 +74,45 @@ exports.JsonRpcConnectionHandler = JsonRpcConnectionHandler;
121
74
  *
122
75
  * @param <T> - The type of the object to expose to JSON-RPC.
123
76
  */
124
- var JsonRpcProxyFactory = /** @class */ (function () {
77
+ class JsonRpcProxyFactory {
125
78
  /**
126
79
  * Build a new JsonRpcProxyFactory.
127
80
  *
128
81
  * @param target - The object to expose to JSON-RPC methods calls. If this
129
82
  * is omitted, the proxy won't be able to handle requests, only send them.
130
83
  */
131
- function JsonRpcProxyFactory(target) {
84
+ constructor(target) {
132
85
  this.target = target;
133
86
  this.onDidOpenConnectionEmitter = new event_1.Emitter();
134
87
  this.onDidCloseConnectionEmitter = new event_1.Emitter();
135
88
  this.waitForConnection();
136
89
  }
137
- JsonRpcProxyFactory.prototype.waitForConnection = function () {
138
- var _this = this;
139
- this.connectionPromise = new Promise(function (resolve) {
140
- return _this.connectionPromiseResolve = resolve;
141
- });
142
- this.connectionPromise.then(function (connection) {
143
- connection.onClose(function () {
144
- return _this.onDidCloseConnectionEmitter.fire(undefined);
145
- });
146
- _this.onDidOpenConnectionEmitter.fire(undefined);
90
+ waitForConnection() {
91
+ this.connectionPromise = new Promise((resolve) => (this.connectionPromiseResolve = resolve));
92
+ this.connectionPromise.then((connection) => {
93
+ connection.onClose(() => this.fireConnectionClosed());
94
+ this.fireConnectionOpened();
147
95
  });
148
- };
96
+ }
97
+ fireConnectionClosed() {
98
+ this.onDidCloseConnectionEmitter.fire(undefined);
99
+ }
100
+ fireConnectionOpened() {
101
+ this.onDidOpenConnectionEmitter.fire(undefined);
102
+ }
149
103
  /**
150
104
  * Connect a MessageConnection to the factory.
151
105
  *
152
106
  * This connection will be used to send/receive JSON-RPC requests and
153
107
  * response.
154
108
  */
155
- JsonRpcProxyFactory.prototype.listen = function (connection) {
156
- var _this = this;
157
- connection.onRequest(function (method) {
158
- var params = [];
159
- for (var _i = 1; _i < arguments.length; _i++) {
160
- params[_i - 1] = arguments[_i];
161
- }
162
- return _this.onRequest.apply(_this, __spread([method], params));
163
- });
164
- connection.onNotification(function (method) {
165
- var params = [];
166
- for (var _i = 1; _i < arguments.length; _i++) {
167
- params[_i - 1] = arguments[_i];
168
- }
169
- return _this.onNotification.apply(_this, __spread([method], params));
170
- });
171
- connection.onDispose(function () { return _this.waitForConnection(); });
109
+ listen(connection) {
110
+ connection.onRequest((method, ...params) => this.onRequest(method, ...params));
111
+ connection.onNotification((method, ...params) => this.onNotification(method, ...params));
112
+ connection.onDispose(() => this.waitForConnection());
172
113
  connection.listen();
173
114
  this.connectionPromiseResolve(connection);
174
- };
115
+ }
175
116
  /**
176
117
  * Process an incoming JSON-RPC method call.
177
118
  *
@@ -184,48 +125,33 @@ var JsonRpcProxyFactory = /** @class */ (function () {
184
125
  *
185
126
  * @returns A promise of the method call completion.
186
127
  */
187
- JsonRpcProxyFactory.prototype.onRequest = function (method) {
188
- var args = [];
189
- for (var _i = 1; _i < arguments.length; _i++) {
190
- args[_i - 1] = arguments[_i];
191
- }
192
- return __awaiter(this, void 0, void 0, function () {
193
- var e_1;
194
- var _a;
195
- return __generator(this, function (_b) {
196
- switch (_b.label) {
197
- case 0:
198
- _b.trys.push([0, 2, , 3]);
199
- return [4 /*yield*/, (_a = this.target)[method].apply(_a, __spread(args))];
200
- case 1: return [2 /*return*/, _b.sent()];
201
- case 2:
202
- e_1 = _b.sent();
203
- if (e_1 instanceof vscode_jsonrpc_1.ResponseError) {
204
- logging_1.log.info("Request " + method + " unsuccessful: " + e_1.code + "/\"" + e_1.message + "\"", { method: method, args: args });
205
- }
206
- else {
207
- logging_1.log.error("Request " + method + " failed with internal server error", e_1, { method: method, args: args });
208
- }
209
- throw e_1;
210
- case 3: return [2 /*return*/];
128
+ onRequest(method, ...args) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ try {
131
+ return yield this.target[method](...args);
132
+ }
133
+ catch (e) {
134
+ if (e instanceof vscode_jsonrpc_1.ResponseError) {
135
+ logging_1.log.info(`Request ${method} unsuccessful: ${e.code}/"${e.message}"`, { method, args });
136
+ }
137
+ else {
138
+ logging_1.log.error(`Request ${method} failed with internal server error`, e, { method, args });
211
139
  }
212
- });
140
+ throw e;
141
+ }
213
142
  });
214
- };
143
+ }
215
144
  /**
216
145
  * Process an incoming JSON-RPC notification.
217
146
  *
218
147
  * Same as [[onRequest]], but called on incoming notifications rather than
219
148
  * methods calls.
220
149
  */
221
- JsonRpcProxyFactory.prototype.onNotification = function (method) {
222
- var _a;
223
- var args = [];
224
- for (var _i = 1; _i < arguments.length; _i++) {
225
- args[_i - 1] = arguments[_i];
150
+ onNotification(method, ...args) {
151
+ if (this.target[method]) {
152
+ this.target[method](...args);
226
153
  }
227
- (_a = this.target)[method].apply(_a, __spread(args));
228
- };
154
+ }
229
155
  /**
230
156
  * Create a Proxy exposing the interface of an object of type T. This Proxy
231
157
  * can be used to do JSON-RPC method calls on the remote target object as
@@ -233,10 +159,10 @@ var JsonRpcProxyFactory = /** @class */ (function () {
233
159
  *
234
160
  * If `T` implements `JsonRpcServer` then a client is used as a target object for a remote target object.
235
161
  */
236
- JsonRpcProxyFactory.prototype.createProxy = function () {
237
- var result = new Proxy(this, this);
162
+ createProxy() {
163
+ const result = new Proxy(this, this);
238
164
  return result;
239
- };
165
+ }
240
166
  /**
241
167
  * Get a callable object that executes a JSON-RPC method call.
242
168
  *
@@ -259,46 +185,35 @@ var JsonRpcProxyFactory = /** @class */ (function () {
259
185
  * @param receiver - unused.
260
186
  * @returns A callable that executes the JSON-RPC call.
261
187
  */
262
- JsonRpcProxyFactory.prototype.get = function (target, p, receiver) {
263
- var _this = this;
264
- if (p === 'setClient') {
265
- return function (client) {
266
- _this.target = client;
188
+ get(target, p, receiver) {
189
+ if (p === "setClient") {
190
+ return (client) => {
191
+ this.target = client;
267
192
  };
268
193
  }
269
- if (p === 'onDidOpenConnection') {
194
+ if (p === "onDidOpenConnection") {
270
195
  return this.onDidOpenConnectionEmitter.event;
271
196
  }
272
- if (p === 'onDidCloseConnection') {
197
+ if (p === "onDidCloseConnection") {
273
198
  return this.onDidCloseConnectionEmitter.event;
274
199
  }
275
- var isNotify = this.isNotification(p);
276
- return function () {
277
- var args = [];
278
- for (var _i = 0; _i < arguments.length; _i++) {
279
- args[_i] = arguments[_i];
200
+ const isNotify = this.isNotification(p);
201
+ return (...args) => this.connectionPromise.then((connection) => new Promise((resolve, reject) => {
202
+ try {
203
+ if (isNotify) {
204
+ connection.sendNotification(p.toString(), ...args);
205
+ resolve(undefined);
206
+ }
207
+ else {
208
+ const resultPromise = connection.sendRequest(p.toString(), ...args);
209
+ resultPromise.catch((err) => reject(err)).then((result) => resolve(result));
210
+ }
280
211
  }
281
- return _this.connectionPromise.then(function (connection) {
282
- return new Promise(function (resolve, reject) {
283
- try {
284
- if (isNotify) {
285
- connection.sendNotification.apply(connection, __spread([p.toString()], args));
286
- resolve();
287
- }
288
- else {
289
- var resultPromise = connection.sendRequest.apply(connection, __spread([p.toString()], args));
290
- resultPromise
291
- .catch(function (err) { return reject(err); })
292
- .then(function (result) { return resolve(result); });
293
- }
294
- }
295
- catch (err) {
296
- reject(err);
297
- }
298
- });
299
- });
300
- };
301
- };
212
+ catch (err) {
213
+ reject(err);
214
+ }
215
+ }));
216
+ }
302
217
  /**
303
218
  * Return whether the given property represents a notification.
304
219
  *
@@ -308,10 +223,9 @@ var JsonRpcProxyFactory = /** @class */ (function () {
308
223
  * @param p - The property being called on the proxy.
309
224
  * @return Whether `p` represents a notification.
310
225
  */
311
- JsonRpcProxyFactory.prototype.isNotification = function (p) {
226
+ isNotification(p) {
312
227
  return p.toString().startsWith("notify") || p.toString().startsWith("on");
313
- };
314
- return JsonRpcProxyFactory;
315
- }());
228
+ }
229
+ }
316
230
  exports.JsonRpcProxyFactory = JsonRpcProxyFactory;
317
231
  //# sourceMappingURL=proxy-factory.js.map